diff --git a/packages/server/src/jsRunner/bundles/bson.ivm.bundle.js b/packages/server/src/jsRunner/bundles/bson.ivm.bundle.js index 96154a4036..5c49ce78e6 100644 --- a/packages/server/src/jsRunner/bundles/bson.ivm.bundle.js +++ b/packages/server/src/jsRunner/bundles/bson.ivm.bundle.js @@ -1,3814 +1,7 @@ -"use strict"; -var bson = (() => { - var __defProp = Object.defineProperty; - var __getOwnPropDesc = Object.getOwnPropertyDescriptor; - var __getOwnPropNames = Object.getOwnPropertyNames; - var __hasOwnProp = Object.prototype.hasOwnProperty; - var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { - get: (a, b) => (typeof require !== "undefined" ? require : a)[b] - }) : x)(function(x) { - if (typeof require !== "undefined") - return require.apply(this, arguments); - throw Error('Dynamic require of "' + x + '" is not supported'); - }); - var __commonJS = (cb, mod) => function __require2() { - return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; - }; - var __export = (target, all) => { - for (var name in all) - __defProp(target, name, { get: all[name], enumerable: true }); - }; - 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 }); - } - return to; - }; - var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); - - // ../../node_modules/bson/lib/bson.cjs - var require_bson = __commonJS({ - "../../node_modules/bson/lib/bson.cjs"(exports) { - "use strict"; - function isAnyArrayBuffer(value) { - return ["[object ArrayBuffer]", "[object SharedArrayBuffer]"].includes(Object.prototype.toString.call(value)); - } - function isUint8Array(value) { - return Object.prototype.toString.call(value) === "[object Uint8Array]"; - } - function isRegExp(d) { - return Object.prototype.toString.call(d) === "[object RegExp]"; - } - function isMap(d) { - return Object.prototype.toString.call(d) === "[object Map]"; - } - function isDate(d) { - return Object.prototype.toString.call(d) === "[object Date]"; - } - function defaultInspect(x, _options) { - return JSON.stringify(x, (k, v) => { - if (typeof v === "bigint") { - return { $numberLong: `${v}` }; - } else if (isMap(v)) { - return Object.fromEntries(v); - } - return v; - }); - } - function getStylizeFunction(options) { - const stylizeExists = options != null && typeof options === "object" && "stylize" in options && typeof options.stylize === "function"; - if (stylizeExists) { - return options.stylize; - } - } - var BSON_MAJOR_VERSION = 6; - var BSON_INT32_MAX = 2147483647; - var BSON_INT32_MIN = -2147483648; - var BSON_INT64_MAX = Math.pow(2, 63) - 1; - var BSON_INT64_MIN = -Math.pow(2, 63); - var JS_INT_MAX = Math.pow(2, 53); - var JS_INT_MIN = -Math.pow(2, 53); - var BSON_DATA_NUMBER = 1; - var BSON_DATA_STRING = 2; - var BSON_DATA_OBJECT = 3; - var BSON_DATA_ARRAY = 4; - var BSON_DATA_BINARY = 5; - var BSON_DATA_UNDEFINED = 6; - var BSON_DATA_OID = 7; - var BSON_DATA_BOOLEAN = 8; - var BSON_DATA_DATE = 9; - var BSON_DATA_NULL = 10; - var BSON_DATA_REGEXP = 11; - var BSON_DATA_DBPOINTER = 12; - var BSON_DATA_CODE = 13; - var BSON_DATA_SYMBOL = 14; - var BSON_DATA_CODE_W_SCOPE = 15; - var BSON_DATA_INT = 16; - var BSON_DATA_TIMESTAMP = 17; - var BSON_DATA_LONG = 18; - var BSON_DATA_DECIMAL128 = 19; - var BSON_DATA_MIN_KEY = 255; - var BSON_DATA_MAX_KEY = 127; - var BSON_BINARY_SUBTYPE_DEFAULT = 0; - var BSON_BINARY_SUBTYPE_UUID_NEW = 4; - var BSONType = Object.freeze({ - double: 1, - string: 2, - object: 3, - array: 4, - binData: 5, - undefined: 6, - objectId: 7, - bool: 8, - date: 9, - null: 10, - regex: 11, - dbPointer: 12, - javascript: 13, - symbol: 14, - javascriptWithScope: 15, - int: 16, - timestamp: 17, - long: 18, - decimal: 19, - minKey: -1, - maxKey: 127 - }); - var BSONError = class extends Error { - get bsonError() { - return true; - } - get name() { - return "BSONError"; - } - constructor(message, options) { - super(message, options); - } - static isBSONError(value) { - return value != null && typeof value === "object" && "bsonError" in value && value.bsonError === true && "name" in value && "message" in value && "stack" in value; - } - }; - var BSONVersionError = class extends BSONError { - get name() { - return "BSONVersionError"; - } - constructor() { - super(`Unsupported BSON version, bson types must be from bson ${BSON_MAJOR_VERSION}.x.x`); - } - }; - var BSONRuntimeError = class extends BSONError { - get name() { - return "BSONRuntimeError"; - } - constructor(message) { - super(message); - } - }; - var FIRST_BIT = 128; - var FIRST_TWO_BITS = 192; - var FIRST_THREE_BITS = 224; - var FIRST_FOUR_BITS = 240; - var FIRST_FIVE_BITS = 248; - var TWO_BIT_CHAR = 192; - var THREE_BIT_CHAR = 224; - var FOUR_BIT_CHAR = 240; - var CONTINUING_CHAR = 128; - function validateUtf8(bytes, start, end) { - let continuation = 0; - for (let i = start; i < end; i += 1) { - const byte = bytes[i]; - if (continuation) { - if ((byte & FIRST_TWO_BITS) !== CONTINUING_CHAR) { - return false; - } - continuation -= 1; - } else if (byte & FIRST_BIT) { - if ((byte & FIRST_THREE_BITS) === TWO_BIT_CHAR) { - continuation = 1; - } else if ((byte & FIRST_FOUR_BITS) === THREE_BIT_CHAR) { - continuation = 2; - } else if ((byte & FIRST_FIVE_BITS) === FOUR_BIT_CHAR) { - continuation = 3; - } else { - return false; - } - } - } - return !continuation; - } - function tryLatin(uint8array, start, end) { - if (uint8array.length === 0) { - return ""; - } - const stringByteLength = end - start; - if (stringByteLength === 0) { - return ""; - } - if (stringByteLength > 20) { - return null; - } - if (stringByteLength === 1 && uint8array[start] < 128) { - return String.fromCharCode(uint8array[start]); - } - if (stringByteLength === 2 && uint8array[start] < 128 && uint8array[start + 1] < 128) { - return String.fromCharCode(uint8array[start]) + String.fromCharCode(uint8array[start + 1]); - } - if (stringByteLength === 3 && uint8array[start] < 128 && uint8array[start + 1] < 128 && uint8array[start + 2] < 128) { - return String.fromCharCode(uint8array[start]) + String.fromCharCode(uint8array[start + 1]) + String.fromCharCode(uint8array[start + 2]); - } - const latinBytes = []; - for (let i = start; i < end; i++) { - const byte = uint8array[i]; - if (byte > 127) { - return null; - } - latinBytes.push(byte); - } - return String.fromCharCode(...latinBytes); - } - function nodejsMathRandomBytes(byteLength) { - return nodeJsByteUtils.fromNumberArray(Array.from({ length: byteLength }, () => Math.floor(Math.random() * 256))); - } - var nodejsRandomBytes = (() => { - try { - return __require("crypto").randomBytes; - } catch { - return nodejsMathRandomBytes; - } - })(); - var nodeJsByteUtils = { - toLocalBufferType(potentialBuffer) { - if (Buffer.isBuffer(potentialBuffer)) { - return potentialBuffer; - } - if (ArrayBuffer.isView(potentialBuffer)) { - return Buffer.from(potentialBuffer.buffer, potentialBuffer.byteOffset, potentialBuffer.byteLength); - } - const stringTag = potentialBuffer?.[Symbol.toStringTag] ?? Object.prototype.toString.call(potentialBuffer); - if (stringTag === "ArrayBuffer" || stringTag === "SharedArrayBuffer" || stringTag === "[object ArrayBuffer]" || stringTag === "[object SharedArrayBuffer]") { - return Buffer.from(potentialBuffer); - } - throw new BSONError(`Cannot create Buffer from ${String(potentialBuffer)}`); - }, - allocate(size) { - return Buffer.alloc(size); - }, - equals(a, b) { - return nodeJsByteUtils.toLocalBufferType(a).equals(b); - }, - fromNumberArray(array) { - return Buffer.from(array); - }, - fromBase64(base64) { - return Buffer.from(base64, "base64"); - }, - toBase64(buffer2) { - return nodeJsByteUtils.toLocalBufferType(buffer2).toString("base64"); - }, - fromISO88591(codePoints) { - return Buffer.from(codePoints, "binary"); - }, - toISO88591(buffer2) { - return nodeJsByteUtils.toLocalBufferType(buffer2).toString("binary"); - }, - fromHex(hex) { - return Buffer.from(hex, "hex"); - }, - toHex(buffer2) { - return nodeJsByteUtils.toLocalBufferType(buffer2).toString("hex"); - }, - fromUTF8(text) { - return Buffer.from(text, "utf8"); - }, - toUTF8(buffer2, start, end, fatal) { - const basicLatin = end - start <= 20 ? tryLatin(buffer2, start, end) : null; - if (basicLatin != null) { - return basicLatin; - } - const string = nodeJsByteUtils.toLocalBufferType(buffer2).toString("utf8", start, end); - if (fatal) { - for (let i = 0; i < string.length; i++) { - if (string.charCodeAt(i) === 65533) { - if (!validateUtf8(buffer2, start, end)) { - throw new BSONError("Invalid UTF-8 string in BSON document"); - } - break; - } - } - } - return string; - }, - utf8ByteLength(input) { - return Buffer.byteLength(input, "utf8"); - }, - encodeUTF8Into(buffer2, source, byteOffset) { - return nodeJsByteUtils.toLocalBufferType(buffer2).write(source, byteOffset, void 0, "utf8"); - }, - randomBytes: nodejsRandomBytes - }; - function isReactNative() { - const { navigator } = globalThis; - return typeof navigator === "object" && navigator.product === "ReactNative"; - } - function webMathRandomBytes(byteLength) { - if (byteLength < 0) { - throw new RangeError(`The argument 'byteLength' is invalid. Received ${byteLength}`); - } - return webByteUtils.fromNumberArray(Array.from({ length: byteLength }, () => Math.floor(Math.random() * 256))); - } - var webRandomBytes = (() => { - const { crypto } = globalThis; - if (crypto != null && typeof crypto.getRandomValues === "function") { - return (byteLength) => { - return crypto.getRandomValues(webByteUtils.allocate(byteLength)); - }; - } else { - if (isReactNative()) { - const { console } = globalThis; - console?.warn?.("BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values."); - } - return webMathRandomBytes; - } - })(); - var HEX_DIGIT = /(\d|[a-f])/i; - var webByteUtils = { - toLocalBufferType(potentialUint8array) { - const stringTag = potentialUint8array?.[Symbol.toStringTag] ?? Object.prototype.toString.call(potentialUint8array); - if (stringTag === "Uint8Array") { - return potentialUint8array; - } - if (ArrayBuffer.isView(potentialUint8array)) { - return new Uint8Array(potentialUint8array.buffer.slice(potentialUint8array.byteOffset, potentialUint8array.byteOffset + potentialUint8array.byteLength)); - } - if (stringTag === "ArrayBuffer" || stringTag === "SharedArrayBuffer" || stringTag === "[object ArrayBuffer]" || stringTag === "[object SharedArrayBuffer]") { - return new Uint8Array(potentialUint8array); - } - throw new BSONError(`Cannot make a Uint8Array from ${String(potentialUint8array)}`); - }, - allocate(size) { - if (typeof size !== "number") { - throw new TypeError(`The "size" argument must be of type number. Received ${String(size)}`); - } - return new Uint8Array(size); - }, - equals(a, b) { - if (a.byteLength !== b.byteLength) { - return false; - } - for (let i = 0; i < a.byteLength; i++) { - if (a[i] !== b[i]) { - return false; - } - } - return true; - }, - fromNumberArray(array) { - return Uint8Array.from(array); - }, - fromBase64(base64) { - return Uint8Array.from(atob(base64), (c) => c.charCodeAt(0)); - }, - toBase64(uint8array) { - return btoa(webByteUtils.toISO88591(uint8array)); - }, - fromISO88591(codePoints) { - return Uint8Array.from(codePoints, (c) => c.charCodeAt(0) & 255); - }, - toISO88591(uint8array) { - return Array.from(Uint16Array.from(uint8array), (b) => String.fromCharCode(b)).join(""); - }, - fromHex(hex) { - const evenLengthHex = hex.length % 2 === 0 ? hex : hex.slice(0, hex.length - 1); - const buffer2 = []; - for (let i = 0; i < evenLengthHex.length; i += 2) { - const firstDigit = evenLengthHex[i]; - const secondDigit = evenLengthHex[i + 1]; - if (!HEX_DIGIT.test(firstDigit)) { - break; - } - if (!HEX_DIGIT.test(secondDigit)) { - break; - } - const hexDigit = Number.parseInt(`${firstDigit}${secondDigit}`, 16); - buffer2.push(hexDigit); - } - return Uint8Array.from(buffer2); - }, - toHex(uint8array) { - return Array.from(uint8array, (byte) => byte.toString(16).padStart(2, "0")).join(""); - }, - fromUTF8(text) { - return new TextEncoder().encode(text); - }, - toUTF8(uint8array, start, end, fatal) { - const basicLatin = end - start <= 20 ? tryLatin(uint8array, start, end) : null; - if (basicLatin != null) { - return basicLatin; - } - if (fatal) { - try { - return new TextDecoder("utf8", { fatal }).decode(uint8array.slice(start, end)); - } catch (cause) { - throw new BSONError("Invalid UTF-8 string in BSON document", { cause }); - } - } - return new TextDecoder("utf8", { fatal }).decode(uint8array.slice(start, end)); - }, - utf8ByteLength(input) { - return webByteUtils.fromUTF8(input).byteLength; - }, - encodeUTF8Into(buffer2, source, byteOffset) { - const bytes = webByteUtils.fromUTF8(source); - buffer2.set(bytes, byteOffset); - return bytes.byteLength; - }, - randomBytes: webRandomBytes - }; - var hasGlobalBuffer = typeof Buffer === "function" && Buffer.prototype?._isBuffer !== true; - var ByteUtils = hasGlobalBuffer ? nodeJsByteUtils : webByteUtils; - var BSONDataView = class extends DataView { - static fromUint8Array(input) { - return new DataView(input.buffer, input.byteOffset, input.byteLength); - } - }; - var BSONValue = class { - get [Symbol.for("@@mdb.bson.version")]() { - return BSON_MAJOR_VERSION; - } - [Symbol.for("nodejs.util.inspect.custom")](depth, options, inspect) { - return this.inspect(depth, options, inspect); - } - }; - var Binary = class _Binary extends BSONValue { - get _bsontype() { - return "Binary"; - } - constructor(buffer2, subType) { - super(); - if (!(buffer2 == null) && typeof buffer2 === "string" && !ArrayBuffer.isView(buffer2) && !isAnyArrayBuffer(buffer2) && !Array.isArray(buffer2)) { - throw new BSONError("Binary can only be constructed from Uint8Array or number[]"); - } - this.sub_type = subType ?? _Binary.BSON_BINARY_SUBTYPE_DEFAULT; - if (buffer2 == null) { - this.buffer = ByteUtils.allocate(_Binary.BUFFER_SIZE); - this.position = 0; - } else { - this.buffer = Array.isArray(buffer2) ? ByteUtils.fromNumberArray(buffer2) : ByteUtils.toLocalBufferType(buffer2); - this.position = this.buffer.byteLength; - } - } - put(byteValue) { - if (typeof byteValue === "string" && byteValue.length !== 1) { - throw new BSONError("only accepts single character String"); - } else if (typeof byteValue !== "number" && byteValue.length !== 1) - throw new BSONError("only accepts single character Uint8Array or Array"); - let decodedByte; - if (typeof byteValue === "string") { - decodedByte = byteValue.charCodeAt(0); - } else if (typeof byteValue === "number") { - decodedByte = byteValue; - } else { - decodedByte = byteValue[0]; - } - if (decodedByte < 0 || decodedByte > 255) { - throw new BSONError("only accepts number in a valid unsigned byte range 0-255"); - } - if (this.buffer.byteLength > this.position) { - this.buffer[this.position++] = decodedByte; - } else { - const newSpace = ByteUtils.allocate(_Binary.BUFFER_SIZE + this.buffer.length); - newSpace.set(this.buffer, 0); - this.buffer = newSpace; - this.buffer[this.position++] = decodedByte; - } - } - write(sequence, offset) { - offset = typeof offset === "number" ? offset : this.position; - if (this.buffer.byteLength < offset + sequence.length) { - const newSpace = ByteUtils.allocate(this.buffer.byteLength + sequence.length); - newSpace.set(this.buffer, 0); - this.buffer = newSpace; - } - if (ArrayBuffer.isView(sequence)) { - this.buffer.set(ByteUtils.toLocalBufferType(sequence), offset); - this.position = offset + sequence.byteLength > this.position ? offset + sequence.length : this.position; - } else if (typeof sequence === "string") { - throw new BSONError("input cannot be string"); - } - } - read(position, length) { - length = length && length > 0 ? length : this.position; - return this.buffer.slice(position, position + length); - } - value() { - return this.buffer.length === this.position ? this.buffer : this.buffer.subarray(0, this.position); - } - length() { - return this.position; - } - toJSON() { - return ByteUtils.toBase64(this.buffer); - } - toString(encoding) { - if (encoding === "hex") - return ByteUtils.toHex(this.buffer); - if (encoding === "base64") - return ByteUtils.toBase64(this.buffer); - if (encoding === "utf8" || encoding === "utf-8") - return ByteUtils.toUTF8(this.buffer, 0, this.buffer.byteLength, false); - return ByteUtils.toUTF8(this.buffer, 0, this.buffer.byteLength, false); - } - toExtendedJSON(options) { - options = options || {}; - const base64String = ByteUtils.toBase64(this.buffer); - const subType = Number(this.sub_type).toString(16); - if (options.legacy) { - return { - $binary: base64String, - $type: subType.length === 1 ? "0" + subType : subType - }; - } - return { - $binary: { - base64: base64String, - subType: subType.length === 1 ? "0" + subType : subType - } - }; - } - toUUID() { - if (this.sub_type === _Binary.SUBTYPE_UUID) { - return new UUID(this.buffer.slice(0, this.position)); - } - throw new BSONError(`Binary sub_type "${this.sub_type}" is not supported for converting to UUID. Only "${_Binary.SUBTYPE_UUID}" is currently supported.`); - } - static createFromHexString(hex, subType) { - return new _Binary(ByteUtils.fromHex(hex), subType); - } - static createFromBase64(base64, subType) { - return new _Binary(ByteUtils.fromBase64(base64), subType); - } - static fromExtendedJSON(doc, options) { - options = options || {}; - let data; - let type; - if ("$binary" in doc) { - if (options.legacy && typeof doc.$binary === "string" && "$type" in doc) { - type = doc.$type ? parseInt(doc.$type, 16) : 0; - data = ByteUtils.fromBase64(doc.$binary); - } else { - if (typeof doc.$binary !== "string") { - type = doc.$binary.subType ? parseInt(doc.$binary.subType, 16) : 0; - data = ByteUtils.fromBase64(doc.$binary.base64); - } - } - } else if ("$uuid" in doc) { - type = 4; - data = UUID.bytesFromString(doc.$uuid); - } - if (!data) { - throw new BSONError(`Unexpected Binary Extended JSON format ${JSON.stringify(doc)}`); - } - return type === BSON_BINARY_SUBTYPE_UUID_NEW ? new UUID(data) : new _Binary(data, type); - } - inspect(depth, options, inspect) { - inspect ??= defaultInspect; - const base64 = ByteUtils.toBase64(this.buffer.subarray(0, this.position)); - const base64Arg = inspect(base64, options); - const subTypeArg = inspect(this.sub_type, options); - return `Binary.createFromBase64(${base64Arg}, ${subTypeArg})`; - } - }; - Binary.BSON_BINARY_SUBTYPE_DEFAULT = 0; - Binary.BUFFER_SIZE = 256; - Binary.SUBTYPE_DEFAULT = 0; - Binary.SUBTYPE_FUNCTION = 1; - Binary.SUBTYPE_BYTE_ARRAY = 2; - Binary.SUBTYPE_UUID_OLD = 3; - Binary.SUBTYPE_UUID = 4; - Binary.SUBTYPE_MD5 = 5; - Binary.SUBTYPE_ENCRYPTED = 6; - Binary.SUBTYPE_COLUMN = 7; - Binary.SUBTYPE_USER_DEFINED = 128; - var UUID_BYTE_LENGTH = 16; - var UUID_WITHOUT_DASHES = /^[0-9A-F]{32}$/i; - var UUID_WITH_DASHES = /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i; - var UUID = class _UUID extends Binary { - constructor(input) { - let bytes; - if (input == null) { - bytes = _UUID.generate(); - } else if (input instanceof _UUID) { - bytes = ByteUtils.toLocalBufferType(new Uint8Array(input.buffer)); - } else if (ArrayBuffer.isView(input) && input.byteLength === UUID_BYTE_LENGTH) { - bytes = ByteUtils.toLocalBufferType(input); - } else if (typeof input === "string") { - bytes = _UUID.bytesFromString(input); - } else { - throw new BSONError("Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)."); - } - super(bytes, BSON_BINARY_SUBTYPE_UUID_NEW); - } - get id() { - return this.buffer; - } - set id(value) { - this.buffer = value; - } - toHexString(includeDashes = true) { - if (includeDashes) { - return [ - ByteUtils.toHex(this.buffer.subarray(0, 4)), - ByteUtils.toHex(this.buffer.subarray(4, 6)), - ByteUtils.toHex(this.buffer.subarray(6, 8)), - ByteUtils.toHex(this.buffer.subarray(8, 10)), - ByteUtils.toHex(this.buffer.subarray(10, 16)) - ].join("-"); - } - return ByteUtils.toHex(this.buffer); - } - toString(encoding) { - if (encoding === "hex") - return ByteUtils.toHex(this.id); - if (encoding === "base64") - return ByteUtils.toBase64(this.id); - return this.toHexString(); - } - toJSON() { - return this.toHexString(); - } - equals(otherId) { - if (!otherId) { - return false; - } - if (otherId instanceof _UUID) { - return ByteUtils.equals(otherId.id, this.id); - } - try { - return ByteUtils.equals(new _UUID(otherId).id, this.id); - } catch { - return false; - } - } - toBinary() { - return new Binary(this.id, Binary.SUBTYPE_UUID); - } - static generate() { - const bytes = ByteUtils.randomBytes(UUID_BYTE_LENGTH); - bytes[6] = bytes[6] & 15 | 64; - bytes[8] = bytes[8] & 63 | 128; - return bytes; - } - static isValid(input) { - if (!input) { - return false; - } - if (typeof input === "string") { - return _UUID.isValidUUIDString(input); - } - if (isUint8Array(input)) { - return input.byteLength === UUID_BYTE_LENGTH; - } - return input._bsontype === "Binary" && input.sub_type === this.SUBTYPE_UUID && input.buffer.byteLength === 16; - } - static createFromHexString(hexString) { - const buffer2 = _UUID.bytesFromString(hexString); - return new _UUID(buffer2); - } - static createFromBase64(base64) { - return new _UUID(ByteUtils.fromBase64(base64)); - } - static bytesFromString(representation) { - if (!_UUID.isValidUUIDString(representation)) { - throw new BSONError("UUID string representation must be 32 hex digits or canonical hyphenated representation"); - } - return ByteUtils.fromHex(representation.replace(/-/g, "")); - } - static isValidUUIDString(representation) { - return UUID_WITHOUT_DASHES.test(representation) || UUID_WITH_DASHES.test(representation); - } - inspect(depth, options, inspect) { - inspect ??= defaultInspect; - return `new UUID(${inspect(this.toHexString(), options)})`; - } - }; - var Code = class _Code extends BSONValue { - get _bsontype() { - return "Code"; - } - constructor(code, scope) { - super(); - this.code = code.toString(); - this.scope = scope ?? null; - } - toJSON() { - if (this.scope != null) { - return { code: this.code, scope: this.scope }; - } - return { code: this.code }; - } - toExtendedJSON() { - if (this.scope) { - return { $code: this.code, $scope: this.scope }; - } - return { $code: this.code }; - } - static fromExtendedJSON(doc) { - return new _Code(doc.$code, doc.$scope); - } - inspect(depth, options, inspect) { - inspect ??= defaultInspect; - let parametersString = inspect(this.code, options); - const multiLineFn = parametersString.includes("\n"); - if (this.scope != null) { - parametersString += `,${multiLineFn ? "\n" : " "}${inspect(this.scope, options)}`; - } - const endingNewline = multiLineFn && this.scope === null; - return `new Code(${multiLineFn ? "\n" : ""}${parametersString}${endingNewline ? "\n" : ""})`; - } - }; - function isDBRefLike(value) { - return value != null && typeof value === "object" && "$id" in value && value.$id != null && "$ref" in value && typeof value.$ref === "string" && (!("$db" in value) || "$db" in value && typeof value.$db === "string"); - } - var DBRef = class _DBRef extends BSONValue { - get _bsontype() { - return "DBRef"; - } - constructor(collection, oid, db, fields) { - super(); - const parts = collection.split("."); - if (parts.length === 2) { - db = parts.shift(); - collection = parts.shift(); - } - this.collection = collection; - this.oid = oid; - this.db = db; - this.fields = fields || {}; - } - get namespace() { - return this.collection; - } - set namespace(value) { - this.collection = value; - } - toJSON() { - const o = Object.assign({ - $ref: this.collection, - $id: this.oid - }, this.fields); - if (this.db != null) - o.$db = this.db; - return o; - } - toExtendedJSON(options) { - options = options || {}; - let o = { - $ref: this.collection, - $id: this.oid - }; - if (options.legacy) { - return o; - } - if (this.db) - o.$db = this.db; - o = Object.assign(o, this.fields); - return o; - } - static fromExtendedJSON(doc) { - const copy = Object.assign({}, doc); - delete copy.$ref; - delete copy.$id; - delete copy.$db; - return new _DBRef(doc.$ref, doc.$id, doc.$db, copy); - } - inspect(depth, options, inspect) { - inspect ??= defaultInspect; - const args = [ - inspect(this.namespace, options), - inspect(this.oid, options), - ...this.db ? [inspect(this.db, options)] : [], - ...Object.keys(this.fields).length > 0 ? [inspect(this.fields, options)] : [] - ]; - args[1] = inspect === defaultInspect ? `new ObjectId(${args[1]})` : args[1]; - return `new DBRef(${args.join(", ")})`; - } - }; - var wasm = void 0; - try { - wasm = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 13, 2, 96, 0, 1, 127, 96, 4, 127, 127, 127, 127, 1, 127, 3, 7, 6, 0, 1, 1, 1, 1, 1, 6, 6, 1, 127, 1, 65, 0, 11, 7, 50, 6, 3, 109, 117, 108, 0, 1, 5, 100, 105, 118, 95, 115, 0, 2, 5, 100, 105, 118, 95, 117, 0, 3, 5, 114, 101, 109, 95, 115, 0, 4, 5, 114, 101, 109, 95, 117, 0, 5, 8, 103, 101, 116, 95, 104, 105, 103, 104, 0, 0, 10, 191, 1, 6, 4, 0, 35, 0, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 126, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 127, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 128, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 129, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 130, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11])), {}).exports; - } catch { - } - var TWO_PWR_16_DBL = 1 << 16; - var TWO_PWR_24_DBL = 1 << 24; - var TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL; - var TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL; - var TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2; - var INT_CACHE = {}; - var UINT_CACHE = {}; - var MAX_INT64_STRING_LENGTH = 20; - var DECIMAL_REG_EX = /^(\+?0|(\+|-)?[1-9][0-9]*)$/; - var Long = class _Long extends BSONValue { - get _bsontype() { - return "Long"; - } - get __isLong__() { - return true; - } - constructor(low = 0, high, unsigned) { - super(); - if (typeof low === "bigint") { - Object.assign(this, _Long.fromBigInt(low, !!high)); - } else if (typeof low === "string") { - Object.assign(this, _Long.fromString(low, !!high)); - } else { - this.low = low | 0; - this.high = high | 0; - this.unsigned = !!unsigned; - } - } - static fromBits(lowBits, highBits, unsigned) { - return new _Long(lowBits, highBits, unsigned); - } - static fromInt(value, unsigned) { - let obj, cachedObj, cache; - if (unsigned) { - value >>>= 0; - if (cache = 0 <= value && value < 256) { - cachedObj = UINT_CACHE[value]; - if (cachedObj) - return cachedObj; - } - obj = _Long.fromBits(value, (value | 0) < 0 ? -1 : 0, true); - if (cache) - UINT_CACHE[value] = obj; - return obj; - } else { - value |= 0; - if (cache = -128 <= value && value < 128) { - cachedObj = INT_CACHE[value]; - if (cachedObj) - return cachedObj; - } - obj = _Long.fromBits(value, value < 0 ? -1 : 0, false); - if (cache) - INT_CACHE[value] = obj; - return obj; - } - } - static fromNumber(value, unsigned) { - if (isNaN(value)) - return unsigned ? _Long.UZERO : _Long.ZERO; - if (unsigned) { - if (value < 0) - return _Long.UZERO; - if (value >= TWO_PWR_64_DBL) - return _Long.MAX_UNSIGNED_VALUE; - } else { - if (value <= -TWO_PWR_63_DBL) - return _Long.MIN_VALUE; - if (value + 1 >= TWO_PWR_63_DBL) - return _Long.MAX_VALUE; - } - if (value < 0) - return _Long.fromNumber(-value, unsigned).neg(); - return _Long.fromBits(value % TWO_PWR_32_DBL | 0, value / TWO_PWR_32_DBL | 0, unsigned); - } - static fromBigInt(value, unsigned) { - return _Long.fromString(value.toString(), unsigned); - } - static fromString(str, unsigned, radix) { - if (str.length === 0) - throw new BSONError("empty string"); - if (str === "NaN" || str === "Infinity" || str === "+Infinity" || str === "-Infinity") - return _Long.ZERO; - if (typeof unsigned === "number") { - radix = unsigned, unsigned = false; - } else { - unsigned = !!unsigned; - } - radix = radix || 10; - if (radix < 2 || 36 < radix) - throw new BSONError("radix"); - let p; - if ((p = str.indexOf("-")) > 0) - throw new BSONError("interior hyphen"); - else if (p === 0) { - return _Long.fromString(str.substring(1), unsigned, radix).neg(); - } - const radixToPower = _Long.fromNumber(Math.pow(radix, 8)); - let result = _Long.ZERO; - for (let i = 0; i < str.length; i += 8) { - const size = Math.min(8, str.length - i), value = parseInt(str.substring(i, i + size), radix); - if (size < 8) { - const power = _Long.fromNumber(Math.pow(radix, size)); - result = result.mul(power).add(_Long.fromNumber(value)); - } else { - result = result.mul(radixToPower); - result = result.add(_Long.fromNumber(value)); - } - } - result.unsigned = unsigned; - return result; - } - static fromBytes(bytes, unsigned, le) { - return le ? _Long.fromBytesLE(bytes, unsigned) : _Long.fromBytesBE(bytes, unsigned); - } - static fromBytesLE(bytes, unsigned) { - return new _Long(bytes[0] | bytes[1] << 8 | bytes[2] << 16 | bytes[3] << 24, bytes[4] | bytes[5] << 8 | bytes[6] << 16 | bytes[7] << 24, unsigned); - } - static fromBytesBE(bytes, unsigned) { - return new _Long(bytes[4] << 24 | bytes[5] << 16 | bytes[6] << 8 | bytes[7], bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3], unsigned); - } - static isLong(value) { - return value != null && typeof value === "object" && "__isLong__" in value && value.__isLong__ === true; - } - static fromValue(val, unsigned) { - if (typeof val === "number") - return _Long.fromNumber(val, unsigned); - if (typeof val === "string") - return _Long.fromString(val, unsigned); - return _Long.fromBits(val.low, val.high, typeof unsigned === "boolean" ? unsigned : val.unsigned); - } - add(addend) { - if (!_Long.isLong(addend)) - addend = _Long.fromValue(addend); - const a48 = this.high >>> 16; - const a32 = this.high & 65535; - const a16 = this.low >>> 16; - const a00 = this.low & 65535; - const b48 = addend.high >>> 16; - const b32 = addend.high & 65535; - const b16 = addend.low >>> 16; - const b00 = addend.low & 65535; - let c48 = 0, c32 = 0, c16 = 0, c00 = 0; - c00 += a00 + b00; - c16 += c00 >>> 16; - c00 &= 65535; - c16 += a16 + b16; - c32 += c16 >>> 16; - c16 &= 65535; - c32 += a32 + b32; - c48 += c32 >>> 16; - c32 &= 65535; - c48 += a48 + b48; - c48 &= 65535; - return _Long.fromBits(c16 << 16 | c00, c48 << 16 | c32, this.unsigned); - } - and(other) { - if (!_Long.isLong(other)) - other = _Long.fromValue(other); - return _Long.fromBits(this.low & other.low, this.high & other.high, this.unsigned); - } - compare(other) { - if (!_Long.isLong(other)) - other = _Long.fromValue(other); - if (this.eq(other)) - return 0; - const thisNeg = this.isNegative(), otherNeg = other.isNegative(); - if (thisNeg && !otherNeg) - return -1; - if (!thisNeg && otherNeg) - return 1; - if (!this.unsigned) - return this.sub(other).isNegative() ? -1 : 1; - return other.high >>> 0 > this.high >>> 0 || other.high === this.high && other.low >>> 0 > this.low >>> 0 ? -1 : 1; - } - comp(other) { - return this.compare(other); - } - divide(divisor) { - if (!_Long.isLong(divisor)) - divisor = _Long.fromValue(divisor); - if (divisor.isZero()) - throw new BSONError("division by zero"); - if (wasm) { - if (!this.unsigned && this.high === -2147483648 && divisor.low === -1 && divisor.high === -1) { - return this; - } - const low = (this.unsigned ? wasm.div_u : wasm.div_s)(this.low, this.high, divisor.low, divisor.high); - return _Long.fromBits(low, wasm.get_high(), this.unsigned); - } - if (this.isZero()) - return this.unsigned ? _Long.UZERO : _Long.ZERO; - let approx, rem, res; - if (!this.unsigned) { - if (this.eq(_Long.MIN_VALUE)) { - if (divisor.eq(_Long.ONE) || divisor.eq(_Long.NEG_ONE)) - return _Long.MIN_VALUE; - else if (divisor.eq(_Long.MIN_VALUE)) - return _Long.ONE; - else { - const halfThis = this.shr(1); - approx = halfThis.div(divisor).shl(1); - if (approx.eq(_Long.ZERO)) { - return divisor.isNegative() ? _Long.ONE : _Long.NEG_ONE; - } else { - rem = this.sub(divisor.mul(approx)); - res = approx.add(rem.div(divisor)); - return res; - } - } - } else if (divisor.eq(_Long.MIN_VALUE)) - return this.unsigned ? _Long.UZERO : _Long.ZERO; - if (this.isNegative()) { - if (divisor.isNegative()) - return this.neg().div(divisor.neg()); - return this.neg().div(divisor).neg(); - } else if (divisor.isNegative()) - return this.div(divisor.neg()).neg(); - res = _Long.ZERO; - } else { - if (!divisor.unsigned) - divisor = divisor.toUnsigned(); - if (divisor.gt(this)) - return _Long.UZERO; - if (divisor.gt(this.shru(1))) - return _Long.UONE; - res = _Long.UZERO; - } - rem = this; - while (rem.gte(divisor)) { - approx = Math.max(1, Math.floor(rem.toNumber() / divisor.toNumber())); - const log2 = Math.ceil(Math.log(approx) / Math.LN2); - const delta = log2 <= 48 ? 1 : Math.pow(2, log2 - 48); - let approxRes = _Long.fromNumber(approx); - let approxRem = approxRes.mul(divisor); - while (approxRem.isNegative() || approxRem.gt(rem)) { - approx -= delta; - approxRes = _Long.fromNumber(approx, this.unsigned); - approxRem = approxRes.mul(divisor); - } - if (approxRes.isZero()) - approxRes = _Long.ONE; - res = res.add(approxRes); - rem = rem.sub(approxRem); - } - return res; - } - div(divisor) { - return this.divide(divisor); - } - equals(other) { - if (!_Long.isLong(other)) - other = _Long.fromValue(other); - if (this.unsigned !== other.unsigned && this.high >>> 31 === 1 && other.high >>> 31 === 1) - return false; - return this.high === other.high && this.low === other.low; - } - eq(other) { - return this.equals(other); - } - getHighBits() { - return this.high; - } - getHighBitsUnsigned() { - return this.high >>> 0; - } - getLowBits() { - return this.low; - } - getLowBitsUnsigned() { - return this.low >>> 0; - } - getNumBitsAbs() { - if (this.isNegative()) { - return this.eq(_Long.MIN_VALUE) ? 64 : this.neg().getNumBitsAbs(); - } - const val = this.high !== 0 ? this.high : this.low; - let bit; - for (bit = 31; bit > 0; bit--) - if ((val & 1 << bit) !== 0) - break; - return this.high !== 0 ? bit + 33 : bit + 1; - } - greaterThan(other) { - return this.comp(other) > 0; - } - gt(other) { - return this.greaterThan(other); - } - greaterThanOrEqual(other) { - return this.comp(other) >= 0; - } - gte(other) { - return this.greaterThanOrEqual(other); - } - ge(other) { - return this.greaterThanOrEqual(other); - } - isEven() { - return (this.low & 1) === 0; - } - isNegative() { - return !this.unsigned && this.high < 0; - } - isOdd() { - return (this.low & 1) === 1; - } - isPositive() { - return this.unsigned || this.high >= 0; - } - isZero() { - return this.high === 0 && this.low === 0; - } - lessThan(other) { - return this.comp(other) < 0; - } - lt(other) { - return this.lessThan(other); - } - lessThanOrEqual(other) { - return this.comp(other) <= 0; - } - lte(other) { - return this.lessThanOrEqual(other); - } - modulo(divisor) { - if (!_Long.isLong(divisor)) - divisor = _Long.fromValue(divisor); - if (wasm) { - const low = (this.unsigned ? wasm.rem_u : wasm.rem_s)(this.low, this.high, divisor.low, divisor.high); - return _Long.fromBits(low, wasm.get_high(), this.unsigned); - } - return this.sub(this.div(divisor).mul(divisor)); - } - mod(divisor) { - return this.modulo(divisor); - } - rem(divisor) { - return this.modulo(divisor); - } - multiply(multiplier) { - if (this.isZero()) - return _Long.ZERO; - if (!_Long.isLong(multiplier)) - multiplier = _Long.fromValue(multiplier); - if (wasm) { - const low = wasm.mul(this.low, this.high, multiplier.low, multiplier.high); - return _Long.fromBits(low, wasm.get_high(), this.unsigned); - } - if (multiplier.isZero()) - return _Long.ZERO; - if (this.eq(_Long.MIN_VALUE)) - return multiplier.isOdd() ? _Long.MIN_VALUE : _Long.ZERO; - if (multiplier.eq(_Long.MIN_VALUE)) - return this.isOdd() ? _Long.MIN_VALUE : _Long.ZERO; - if (this.isNegative()) { - if (multiplier.isNegative()) - return this.neg().mul(multiplier.neg()); - else - return this.neg().mul(multiplier).neg(); - } else if (multiplier.isNegative()) - return this.mul(multiplier.neg()).neg(); - if (this.lt(_Long.TWO_PWR_24) && multiplier.lt(_Long.TWO_PWR_24)) - return _Long.fromNumber(this.toNumber() * multiplier.toNumber(), this.unsigned); - const a48 = this.high >>> 16; - const a32 = this.high & 65535; - const a16 = this.low >>> 16; - const a00 = this.low & 65535; - const b48 = multiplier.high >>> 16; - const b32 = multiplier.high & 65535; - const b16 = multiplier.low >>> 16; - const b00 = multiplier.low & 65535; - let c48 = 0, c32 = 0, c16 = 0, c00 = 0; - c00 += a00 * b00; - c16 += c00 >>> 16; - c00 &= 65535; - c16 += a16 * b00; - c32 += c16 >>> 16; - c16 &= 65535; - c16 += a00 * b16; - c32 += c16 >>> 16; - c16 &= 65535; - c32 += a32 * b00; - c48 += c32 >>> 16; - c32 &= 65535; - c32 += a16 * b16; - c48 += c32 >>> 16; - c32 &= 65535; - c32 += a00 * b32; - c48 += c32 >>> 16; - c32 &= 65535; - c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48; - c48 &= 65535; - return _Long.fromBits(c16 << 16 | c00, c48 << 16 | c32, this.unsigned); - } - mul(multiplier) { - return this.multiply(multiplier); - } - negate() { - if (!this.unsigned && this.eq(_Long.MIN_VALUE)) - return _Long.MIN_VALUE; - return this.not().add(_Long.ONE); - } - neg() { - return this.negate(); - } - not() { - return _Long.fromBits(~this.low, ~this.high, this.unsigned); - } - notEquals(other) { - return !this.equals(other); - } - neq(other) { - return this.notEquals(other); - } - ne(other) { - return this.notEquals(other); - } - or(other) { - if (!_Long.isLong(other)) - other = _Long.fromValue(other); - return _Long.fromBits(this.low | other.low, this.high | other.high, this.unsigned); - } - shiftLeft(numBits) { - if (_Long.isLong(numBits)) - numBits = numBits.toInt(); - if ((numBits &= 63) === 0) - return this; - else if (numBits < 32) - return _Long.fromBits(this.low << numBits, this.high << numBits | this.low >>> 32 - numBits, this.unsigned); - else - return _Long.fromBits(0, this.low << numBits - 32, this.unsigned); - } - shl(numBits) { - return this.shiftLeft(numBits); - } - shiftRight(numBits) { - if (_Long.isLong(numBits)) - numBits = numBits.toInt(); - if ((numBits &= 63) === 0) - return this; - else if (numBits < 32) - return _Long.fromBits(this.low >>> numBits | this.high << 32 - numBits, this.high >> numBits, this.unsigned); - else - return _Long.fromBits(this.high >> numBits - 32, this.high >= 0 ? 0 : -1, this.unsigned); - } - shr(numBits) { - return this.shiftRight(numBits); - } - shiftRightUnsigned(numBits) { - if (_Long.isLong(numBits)) - numBits = numBits.toInt(); - numBits &= 63; - if (numBits === 0) - return this; - else { - const high = this.high; - if (numBits < 32) { - const low = this.low; - return _Long.fromBits(low >>> numBits | high << 32 - numBits, high >>> numBits, this.unsigned); - } else if (numBits === 32) - return _Long.fromBits(high, 0, this.unsigned); - else - return _Long.fromBits(high >>> numBits - 32, 0, this.unsigned); - } - } - shr_u(numBits) { - return this.shiftRightUnsigned(numBits); - } - shru(numBits) { - return this.shiftRightUnsigned(numBits); - } - subtract(subtrahend) { - if (!_Long.isLong(subtrahend)) - subtrahend = _Long.fromValue(subtrahend); - return this.add(subtrahend.neg()); - } - sub(subtrahend) { - return this.subtract(subtrahend); - } - toInt() { - return this.unsigned ? this.low >>> 0 : this.low; - } - toNumber() { - if (this.unsigned) - return (this.high >>> 0) * TWO_PWR_32_DBL + (this.low >>> 0); - return this.high * TWO_PWR_32_DBL + (this.low >>> 0); - } - toBigInt() { - return BigInt(this.toString()); - } - toBytes(le) { - return le ? this.toBytesLE() : this.toBytesBE(); - } - toBytesLE() { - const hi = this.high, lo = this.low; - return [ - lo & 255, - lo >>> 8 & 255, - lo >>> 16 & 255, - lo >>> 24, - hi & 255, - hi >>> 8 & 255, - hi >>> 16 & 255, - hi >>> 24 - ]; - } - toBytesBE() { - const hi = this.high, lo = this.low; - return [ - hi >>> 24, - hi >>> 16 & 255, - hi >>> 8 & 255, - hi & 255, - lo >>> 24, - lo >>> 16 & 255, - lo >>> 8 & 255, - lo & 255 - ]; - } - toSigned() { - if (!this.unsigned) - return this; - return _Long.fromBits(this.low, this.high, false); - } - toString(radix) { - radix = radix || 10; - if (radix < 2 || 36 < radix) - throw new BSONError("radix"); - if (this.isZero()) - return "0"; - if (this.isNegative()) { - if (this.eq(_Long.MIN_VALUE)) { - const radixLong = _Long.fromNumber(radix), div = this.div(radixLong), rem1 = div.mul(radixLong).sub(this); - return div.toString(radix) + rem1.toInt().toString(radix); - } else - return "-" + this.neg().toString(radix); - } - const radixToPower = _Long.fromNumber(Math.pow(radix, 6), this.unsigned); - let rem = this; - let result = ""; - while (true) { - const remDiv = rem.div(radixToPower); - const intval = rem.sub(remDiv.mul(radixToPower)).toInt() >>> 0; - let digits = intval.toString(radix); - rem = remDiv; - if (rem.isZero()) { - return digits + result; - } else { - while (digits.length < 6) - digits = "0" + digits; - result = "" + digits + result; - } - } - } - toUnsigned() { - if (this.unsigned) - return this; - return _Long.fromBits(this.low, this.high, true); - } - xor(other) { - if (!_Long.isLong(other)) - other = _Long.fromValue(other); - return _Long.fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned); - } - eqz() { - return this.isZero(); - } - le(other) { - return this.lessThanOrEqual(other); - } - toExtendedJSON(options) { - if (options && options.relaxed) - return this.toNumber(); - return { $numberLong: this.toString() }; - } - static fromExtendedJSON(doc, options) { - const { useBigInt64 = false, relaxed = true } = { ...options }; - if (doc.$numberLong.length > MAX_INT64_STRING_LENGTH) { - throw new BSONError("$numberLong string is too long"); - } - if (!DECIMAL_REG_EX.test(doc.$numberLong)) { - throw new BSONError(`$numberLong string "${doc.$numberLong}" is in an invalid format`); - } - if (useBigInt64) { - const bigIntResult = BigInt(doc.$numberLong); - return BigInt.asIntN(64, bigIntResult); - } - const longResult = _Long.fromString(doc.$numberLong); - if (relaxed) { - return longResult.toNumber(); - } - return longResult; - } - inspect(depth, options, inspect) { - inspect ??= defaultInspect; - const longVal = inspect(this.toString(), options); - const unsignedVal = this.unsigned ? `, ${inspect(this.unsigned, options)}` : ""; - return `new Long(${longVal}${unsignedVal})`; - } - }; - Long.TWO_PWR_24 = Long.fromInt(TWO_PWR_24_DBL); - Long.MAX_UNSIGNED_VALUE = Long.fromBits(4294967295 | 0, 4294967295 | 0, true); - Long.ZERO = Long.fromInt(0); - Long.UZERO = Long.fromInt(0, true); - Long.ONE = Long.fromInt(1); - Long.UONE = Long.fromInt(1, true); - Long.NEG_ONE = Long.fromInt(-1); - Long.MAX_VALUE = Long.fromBits(4294967295 | 0, 2147483647 | 0, false); - Long.MIN_VALUE = Long.fromBits(0, 2147483648 | 0, false); - var PARSE_STRING_REGEXP = /^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/; - var PARSE_INF_REGEXP = /^(\+|-)?(Infinity|inf)$/i; - var PARSE_NAN_REGEXP = /^(\+|-)?NaN$/i; - var EXPONENT_MAX = 6111; - var EXPONENT_MIN = -6176; - var EXPONENT_BIAS = 6176; - var MAX_DIGITS = 34; - var NAN_BUFFER = ByteUtils.fromNumberArray([ - 124, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ].reverse()); - var INF_NEGATIVE_BUFFER = ByteUtils.fromNumberArray([ - 248, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ].reverse()); - var INF_POSITIVE_BUFFER = ByteUtils.fromNumberArray([ - 120, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ].reverse()); - var EXPONENT_REGEX = /^([-+])?(\d+)?$/; - var COMBINATION_MASK = 31; - var EXPONENT_MASK = 16383; - var COMBINATION_INFINITY = 30; - var COMBINATION_NAN = 31; - function isDigit(value) { - return !isNaN(parseInt(value, 10)); - } - function divideu128(value) { - const DIVISOR = Long.fromNumber(1e3 * 1e3 * 1e3); - let _rem = Long.fromNumber(0); - if (!value.parts[0] && !value.parts[1] && !value.parts[2] && !value.parts[3]) { - return { quotient: value, rem: _rem }; - } - for (let i = 0; i <= 3; i++) { - _rem = _rem.shiftLeft(32); - _rem = _rem.add(new Long(value.parts[i], 0)); - value.parts[i] = _rem.div(DIVISOR).low; - _rem = _rem.modulo(DIVISOR); - } - return { quotient: value, rem: _rem }; - } - function multiply64x2(left, right) { - if (!left && !right) { - return { high: Long.fromNumber(0), low: Long.fromNumber(0) }; - } - const leftHigh = left.shiftRightUnsigned(32); - const leftLow = new Long(left.getLowBits(), 0); - const rightHigh = right.shiftRightUnsigned(32); - const rightLow = new Long(right.getLowBits(), 0); - let productHigh = leftHigh.multiply(rightHigh); - let productMid = leftHigh.multiply(rightLow); - const productMid2 = leftLow.multiply(rightHigh); - let productLow = leftLow.multiply(rightLow); - productHigh = productHigh.add(productMid.shiftRightUnsigned(32)); - productMid = new Long(productMid.getLowBits(), 0).add(productMid2).add(productLow.shiftRightUnsigned(32)); - productHigh = productHigh.add(productMid.shiftRightUnsigned(32)); - productLow = productMid.shiftLeft(32).add(new Long(productLow.getLowBits(), 0)); - return { high: productHigh, low: productLow }; - } - function lessThan(left, right) { - const uhleft = left.high >>> 0; - const uhright = right.high >>> 0; - if (uhleft < uhright) { - return true; - } else if (uhleft === uhright) { - const ulleft = left.low >>> 0; - const ulright = right.low >>> 0; - if (ulleft < ulright) - return true; - } - return false; - } - function invalidErr(string, message) { - throw new BSONError(`"${string}" is not a valid Decimal128 string - ${message}`); - } - var Decimal128 = class _Decimal128 extends BSONValue { - get _bsontype() { - return "Decimal128"; - } - constructor(bytes) { - super(); - if (typeof bytes === "string") { - this.bytes = _Decimal128.fromString(bytes).bytes; - } else if (isUint8Array(bytes)) { - if (bytes.byteLength !== 16) { - throw new BSONError("Decimal128 must take a Buffer of 16 bytes"); - } - this.bytes = bytes; - } else { - throw new BSONError("Decimal128 must take a Buffer or string"); - } - } - static fromString(representation) { - return _Decimal128._fromString(representation, { allowRounding: false }); - } - static fromStringWithRounding(representation) { - return _Decimal128._fromString(representation, { allowRounding: true }); - } - static _fromString(representation, options) { - let isNegative = false; - let sawSign = false; - let sawRadix = false; - let foundNonZero = false; - let significantDigits = 0; - let nDigitsRead = 0; - let nDigits = 0; - let radixPosition = 0; - let firstNonZero = 0; - const digits = [0]; - let nDigitsStored = 0; - let digitsInsert = 0; - let lastDigit = 0; - let exponent = 0; - let significandHigh = new Long(0, 0); - let significandLow = new Long(0, 0); - let biasedExponent = 0; - let index = 0; - if (representation.length >= 7e3) { - throw new BSONError("" + representation + " not a valid Decimal128 string"); - } - const stringMatch = representation.match(PARSE_STRING_REGEXP); - const infMatch = representation.match(PARSE_INF_REGEXP); - const nanMatch = representation.match(PARSE_NAN_REGEXP); - if (!stringMatch && !infMatch && !nanMatch || representation.length === 0) { - throw new BSONError("" + representation + " not a valid Decimal128 string"); - } - if (stringMatch) { - const unsignedNumber = stringMatch[2]; - const e = stringMatch[4]; - const expSign = stringMatch[5]; - const expNumber = stringMatch[6]; - if (e && expNumber === void 0) - invalidErr(representation, "missing exponent power"); - if (e && unsignedNumber === void 0) - invalidErr(representation, "missing exponent base"); - if (e === void 0 && (expSign || expNumber)) { - invalidErr(representation, "missing e before exponent"); - } - } - if (representation[index] === "+" || representation[index] === "-") { - sawSign = true; - isNegative = representation[index++] === "-"; - } - if (!isDigit(representation[index]) && representation[index] !== ".") { - if (representation[index] === "i" || representation[index] === "I") { - return new _Decimal128(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER); - } else if (representation[index] === "N") { - return new _Decimal128(NAN_BUFFER); - } - } - while (isDigit(representation[index]) || representation[index] === ".") { - if (representation[index] === ".") { - if (sawRadix) - invalidErr(representation, "contains multiple periods"); - sawRadix = true; - index = index + 1; - continue; - } - if (nDigitsStored < MAX_DIGITS) { - if (representation[index] !== "0" || foundNonZero) { - if (!foundNonZero) { - firstNonZero = nDigitsRead; - } - foundNonZero = true; - digits[digitsInsert++] = parseInt(representation[index], 10); - nDigitsStored = nDigitsStored + 1; - } - } - if (foundNonZero) - nDigits = nDigits + 1; - if (sawRadix) - radixPosition = radixPosition + 1; - nDigitsRead = nDigitsRead + 1; - index = index + 1; - } - if (sawRadix && !nDigitsRead) - throw new BSONError("" + representation + " not a valid Decimal128 string"); - if (representation[index] === "e" || representation[index] === "E") { - const match = representation.substr(++index).match(EXPONENT_REGEX); - if (!match || !match[2]) - return new _Decimal128(NAN_BUFFER); - exponent = parseInt(match[0], 10); - index = index + match[0].length; - } - if (representation[index]) - return new _Decimal128(NAN_BUFFER); - if (!nDigitsStored) { - digits[0] = 0; - nDigits = 1; - nDigitsStored = 1; - significantDigits = 0; - } else { - lastDigit = nDigitsStored - 1; - significantDigits = nDigits; - if (significantDigits !== 1) { - while (representation[firstNonZero + significantDigits - 1 + Number(sawSign) + Number(sawRadix)] === "0") { - significantDigits = significantDigits - 1; - } - } - } - if (exponent <= radixPosition && radixPosition > exponent + (1 << 14)) { - exponent = EXPONENT_MIN; - } else { - exponent = exponent - radixPosition; - } - while (exponent > EXPONENT_MAX) { - lastDigit = lastDigit + 1; - if (lastDigit >= MAX_DIGITS) { - if (significantDigits === 0) { - exponent = EXPONENT_MAX; - break; - } - invalidErr(representation, "overflow"); - } - exponent = exponent - 1; - } - if (options.allowRounding) { - while (exponent < EXPONENT_MIN || nDigitsStored < nDigits) { - if (lastDigit === 0 && significantDigits < nDigitsStored) { - exponent = EXPONENT_MIN; - significantDigits = 0; - break; - } - if (nDigitsStored < nDigits) { - nDigits = nDigits - 1; - } else { - lastDigit = lastDigit - 1; - } - if (exponent < EXPONENT_MAX) { - exponent = exponent + 1; - } else { - const digitsString = digits.join(""); - if (digitsString.match(/^0+$/)) { - exponent = EXPONENT_MAX; - break; - } - invalidErr(representation, "overflow"); - } - } - if (lastDigit + 1 < significantDigits) { - let endOfString = nDigitsRead; - if (sawRadix) { - firstNonZero = firstNonZero + 1; - endOfString = endOfString + 1; - } - if (sawSign) { - firstNonZero = firstNonZero + 1; - endOfString = endOfString + 1; - } - const roundDigit = parseInt(representation[firstNonZero + lastDigit + 1], 10); - let roundBit = 0; - if (roundDigit >= 5) { - roundBit = 1; - if (roundDigit === 5) { - roundBit = digits[lastDigit] % 2 === 1 ? 1 : 0; - for (let i = firstNonZero + lastDigit + 2; i < endOfString; i++) { - if (parseInt(representation[i], 10)) { - roundBit = 1; - break; - } - } - } - } - if (roundBit) { - let dIdx = lastDigit; - for (; dIdx >= 0; dIdx--) { - if (++digits[dIdx] > 9) { - digits[dIdx] = 0; - if (dIdx === 0) { - if (exponent < EXPONENT_MAX) { - exponent = exponent + 1; - digits[dIdx] = 1; - } else { - return new _Decimal128(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER); - } - } - } else { - break; - } - } - } - } - } else { - while (exponent < EXPONENT_MIN || nDigitsStored < nDigits) { - if (lastDigit === 0) { - if (significantDigits === 0) { - exponent = EXPONENT_MIN; - break; - } - invalidErr(representation, "exponent underflow"); - } - if (nDigitsStored < nDigits) { - if (representation[nDigits - 1 + Number(sawSign) + Number(sawRadix)] !== "0" && significantDigits !== 0) { - invalidErr(representation, "inexact rounding"); - } - nDigits = nDigits - 1; - } else { - if (digits[lastDigit] !== 0) { - invalidErr(representation, "inexact rounding"); - } - lastDigit = lastDigit - 1; - } - if (exponent < EXPONENT_MAX) { - exponent = exponent + 1; - } else { - invalidErr(representation, "overflow"); - } - } - if (lastDigit + 1 < significantDigits) { - if (sawRadix) { - firstNonZero = firstNonZero + 1; - } - if (sawSign) { - firstNonZero = firstNonZero + 1; - } - const roundDigit = parseInt(representation[firstNonZero + lastDigit + 1], 10); - if (roundDigit !== 0) { - invalidErr(representation, "inexact rounding"); - } - } - } - significandHigh = Long.fromNumber(0); - significandLow = Long.fromNumber(0); - if (significantDigits === 0) { - significandHigh = Long.fromNumber(0); - significandLow = Long.fromNumber(0); - } else if (lastDigit < 17) { - let dIdx = 0; - significandLow = Long.fromNumber(digits[dIdx++]); - significandHigh = new Long(0, 0); - for (; dIdx <= lastDigit; dIdx++) { - significandLow = significandLow.multiply(Long.fromNumber(10)); - significandLow = significandLow.add(Long.fromNumber(digits[dIdx])); - } - } else { - let dIdx = 0; - significandHigh = Long.fromNumber(digits[dIdx++]); - for (; dIdx <= lastDigit - 17; dIdx++) { - significandHigh = significandHigh.multiply(Long.fromNumber(10)); - significandHigh = significandHigh.add(Long.fromNumber(digits[dIdx])); - } - significandLow = Long.fromNumber(digits[dIdx++]); - for (; dIdx <= lastDigit; dIdx++) { - significandLow = significandLow.multiply(Long.fromNumber(10)); - significandLow = significandLow.add(Long.fromNumber(digits[dIdx])); - } - } - const significand = multiply64x2(significandHigh, Long.fromString("100000000000000000")); - significand.low = significand.low.add(significandLow); - if (lessThan(significand.low, significandLow)) { - significand.high = significand.high.add(Long.fromNumber(1)); - } - biasedExponent = exponent + EXPONENT_BIAS; - const dec = { low: Long.fromNumber(0), high: Long.fromNumber(0) }; - if (significand.high.shiftRightUnsigned(49).and(Long.fromNumber(1)).equals(Long.fromNumber(1))) { - dec.high = dec.high.or(Long.fromNumber(3).shiftLeft(61)); - dec.high = dec.high.or(Long.fromNumber(biasedExponent).and(Long.fromNumber(16383).shiftLeft(47))); - dec.high = dec.high.or(significand.high.and(Long.fromNumber(140737488355327))); - } else { - dec.high = dec.high.or(Long.fromNumber(biasedExponent & 16383).shiftLeft(49)); - dec.high = dec.high.or(significand.high.and(Long.fromNumber(562949953421311))); - } - dec.low = significand.low; - if (isNegative) { - dec.high = dec.high.or(Long.fromString("9223372036854775808")); - } - const buffer2 = ByteUtils.allocate(16); - index = 0; - buffer2[index++] = dec.low.low & 255; - buffer2[index++] = dec.low.low >> 8 & 255; - buffer2[index++] = dec.low.low >> 16 & 255; - buffer2[index++] = dec.low.low >> 24 & 255; - buffer2[index++] = dec.low.high & 255; - buffer2[index++] = dec.low.high >> 8 & 255; - buffer2[index++] = dec.low.high >> 16 & 255; - buffer2[index++] = dec.low.high >> 24 & 255; - buffer2[index++] = dec.high.low & 255; - buffer2[index++] = dec.high.low >> 8 & 255; - buffer2[index++] = dec.high.low >> 16 & 255; - buffer2[index++] = dec.high.low >> 24 & 255; - buffer2[index++] = dec.high.high & 255; - buffer2[index++] = dec.high.high >> 8 & 255; - buffer2[index++] = dec.high.high >> 16 & 255; - buffer2[index++] = dec.high.high >> 24 & 255; - return new _Decimal128(buffer2); - } - toString() { - let biased_exponent; - let significand_digits = 0; - const significand = new Array(36); - for (let i = 0; i < significand.length; i++) - significand[i] = 0; - let index = 0; - let is_zero = false; - let significand_msb; - let significand128 = { parts: [0, 0, 0, 0] }; - let j, k; - const string = []; - index = 0; - const buffer2 = this.bytes; - const low = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24; - const midl = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24; - const midh = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24; - const high = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24; - index = 0; - const dec = { - low: new Long(low, midl), - high: new Long(midh, high) - }; - if (dec.high.lessThan(Long.ZERO)) { - string.push("-"); - } - const combination = high >> 26 & COMBINATION_MASK; - if (combination >> 3 === 3) { - if (combination === COMBINATION_INFINITY) { - return string.join("") + "Infinity"; - } else if (combination === COMBINATION_NAN) { - return "NaN"; - } else { - biased_exponent = high >> 15 & EXPONENT_MASK; - significand_msb = 8 + (high >> 14 & 1); - } - } else { - significand_msb = high >> 14 & 7; - biased_exponent = high >> 17 & EXPONENT_MASK; - } - const exponent = biased_exponent - EXPONENT_BIAS; - significand128.parts[0] = (high & 16383) + ((significand_msb & 15) << 14); - significand128.parts[1] = midh; - significand128.parts[2] = midl; - significand128.parts[3] = low; - if (significand128.parts[0] === 0 && significand128.parts[1] === 0 && significand128.parts[2] === 0 && significand128.parts[3] === 0) { - is_zero = true; - } else { - for (k = 3; k >= 0; k--) { - let least_digits = 0; - const result = divideu128(significand128); - significand128 = result.quotient; - least_digits = result.rem.low; - if (!least_digits) - continue; - for (j = 8; j >= 0; j--) { - significand[k * 9 + j] = least_digits % 10; - least_digits = Math.floor(least_digits / 10); - } - } - } - if (is_zero) { - significand_digits = 1; - significand[index] = 0; - } else { - significand_digits = 36; - while (!significand[index]) { - significand_digits = significand_digits - 1; - index = index + 1; - } - } - const scientific_exponent = significand_digits - 1 + exponent; - if (scientific_exponent >= 34 || scientific_exponent <= -7 || exponent > 0) { - if (significand_digits > 34) { - string.push(`${0}`); - if (exponent > 0) - string.push(`E+${exponent}`); - else if (exponent < 0) - string.push(`E${exponent}`); - return string.join(""); - } - string.push(`${significand[index++]}`); - significand_digits = significand_digits - 1; - if (significand_digits) { - string.push("."); - } - for (let i = 0; i < significand_digits; i++) { - string.push(`${significand[index++]}`); - } - string.push("E"); - if (scientific_exponent > 0) { - string.push(`+${scientific_exponent}`); - } else { - string.push(`${scientific_exponent}`); - } - } else { - if (exponent >= 0) { - for (let i = 0; i < significand_digits; i++) { - string.push(`${significand[index++]}`); - } - } else { - let radix_position = significand_digits + exponent; - if (radix_position > 0) { - for (let i = 0; i < radix_position; i++) { - string.push(`${significand[index++]}`); - } - } else { - string.push("0"); - } - string.push("."); - while (radix_position++ < 0) { - string.push("0"); - } - for (let i = 0; i < significand_digits - Math.max(radix_position - 1, 0); i++) { - string.push(`${significand[index++]}`); - } - } - } - return string.join(""); - } - toJSON() { - return { $numberDecimal: this.toString() }; - } - toExtendedJSON() { - return { $numberDecimal: this.toString() }; - } - static fromExtendedJSON(doc) { - return _Decimal128.fromString(doc.$numberDecimal); - } - inspect(depth, options, inspect) { - inspect ??= defaultInspect; - const d128string = inspect(this.toString(), options); - return `new Decimal128(${d128string})`; - } - }; - var Double = class _Double extends BSONValue { - get _bsontype() { - return "Double"; - } - constructor(value) { - super(); - if (value instanceof Number) { - value = value.valueOf(); - } - this.value = +value; - } - valueOf() { - return this.value; - } - toJSON() { - return this.value; - } - toString(radix) { - return this.value.toString(radix); - } - toExtendedJSON(options) { - if (options && (options.legacy || options.relaxed && isFinite(this.value))) { - return this.value; - } - if (Object.is(Math.sign(this.value), -0)) { - return { $numberDouble: "-0.0" }; - } - return { - $numberDouble: Number.isInteger(this.value) ? this.value.toFixed(1) : this.value.toString() - }; - } - static fromExtendedJSON(doc, options) { - const doubleValue = parseFloat(doc.$numberDouble); - return options && options.relaxed ? doubleValue : new _Double(doubleValue); - } - inspect(depth, options, inspect) { - inspect ??= defaultInspect; - return `new Double(${inspect(this.value, options)})`; - } - }; - var Int32 = class _Int32 extends BSONValue { - get _bsontype() { - return "Int32"; - } - constructor(value) { - super(); - if (value instanceof Number) { - value = value.valueOf(); - } - this.value = +value | 0; - } - valueOf() { - return this.value; - } - toString(radix) { - return this.value.toString(radix); - } - toJSON() { - return this.value; - } - toExtendedJSON(options) { - if (options && (options.relaxed || options.legacy)) - return this.value; - return { $numberInt: this.value.toString() }; - } - static fromExtendedJSON(doc, options) { - return options && options.relaxed ? parseInt(doc.$numberInt, 10) : new _Int32(doc.$numberInt); - } - inspect(depth, options, inspect) { - inspect ??= defaultInspect; - return `new Int32(${inspect(this.value, options)})`; - } - }; - var MaxKey = class _MaxKey extends BSONValue { - get _bsontype() { - return "MaxKey"; - } - toExtendedJSON() { - return { $maxKey: 1 }; - } - static fromExtendedJSON() { - return new _MaxKey(); - } - inspect() { - return "new MaxKey()"; - } - }; - var MinKey = class _MinKey extends BSONValue { - get _bsontype() { - return "MinKey"; - } - toExtendedJSON() { - return { $minKey: 1 }; - } - static fromExtendedJSON() { - return new _MinKey(); - } - inspect() { - return "new MinKey()"; - } - }; - var checkForHexRegExp = new RegExp("^[0-9a-fA-F]{24}$"); - var PROCESS_UNIQUE = null; - var kId = Symbol("id"); - var ObjectId = class _ObjectId extends BSONValue { - get _bsontype() { - return "ObjectId"; - } - constructor(inputId) { - super(); - let workingId; - if (typeof inputId === "object" && inputId && "id" in inputId) { - if (typeof inputId.id !== "string" && !ArrayBuffer.isView(inputId.id)) { - throw new BSONError("Argument passed in must have an id that is of type string or Buffer"); - } - if ("toHexString" in inputId && typeof inputId.toHexString === "function") { - workingId = ByteUtils.fromHex(inputId.toHexString()); - } else { - workingId = inputId.id; - } - } else { - workingId = inputId; - } - if (workingId == null || typeof workingId === "number") { - this[kId] = _ObjectId.generate(typeof workingId === "number" ? workingId : void 0); - } else if (ArrayBuffer.isView(workingId) && workingId.byteLength === 12) { - this[kId] = ByteUtils.toLocalBufferType(workingId); - } else if (typeof workingId === "string") { - if (workingId.length === 24 && checkForHexRegExp.test(workingId)) { - this[kId] = ByteUtils.fromHex(workingId); - } else { - throw new BSONError("input must be a 24 character hex string, 12 byte Uint8Array, or an integer"); - } - } else { - throw new BSONError("Argument passed in does not match the accepted types"); - } - if (_ObjectId.cacheHexString) { - this.__id = ByteUtils.toHex(this.id); - } - } - get id() { - return this[kId]; - } - set id(value) { - this[kId] = value; - if (_ObjectId.cacheHexString) { - this.__id = ByteUtils.toHex(value); - } - } - toHexString() { - if (_ObjectId.cacheHexString && this.__id) { - return this.__id; - } - const hexString = ByteUtils.toHex(this.id); - if (_ObjectId.cacheHexString && !this.__id) { - this.__id = hexString; - } - return hexString; - } - static getInc() { - return _ObjectId.index = (_ObjectId.index + 1) % 16777215; - } - static generate(time) { - if ("number" !== typeof time) { - time = Math.floor(Date.now() / 1e3); - } - const inc = _ObjectId.getInc(); - const buffer2 = ByteUtils.allocate(12); - BSONDataView.fromUint8Array(buffer2).setUint32(0, time, false); - if (PROCESS_UNIQUE === null) { - PROCESS_UNIQUE = ByteUtils.randomBytes(5); - } - buffer2[4] = PROCESS_UNIQUE[0]; - buffer2[5] = PROCESS_UNIQUE[1]; - buffer2[6] = PROCESS_UNIQUE[2]; - buffer2[7] = PROCESS_UNIQUE[3]; - buffer2[8] = PROCESS_UNIQUE[4]; - buffer2[11] = inc & 255; - buffer2[10] = inc >> 8 & 255; - buffer2[9] = inc >> 16 & 255; - return buffer2; - } - toString(encoding) { - if (encoding === "base64") - return ByteUtils.toBase64(this.id); - if (encoding === "hex") - return this.toHexString(); - return this.toHexString(); - } - toJSON() { - return this.toHexString(); - } - static is(variable) { - return variable != null && typeof variable === "object" && "_bsontype" in variable && variable._bsontype === "ObjectId"; - } - equals(otherId) { - if (otherId === void 0 || otherId === null) { - return false; - } - if (_ObjectId.is(otherId)) { - return this[kId][11] === otherId[kId][11] && ByteUtils.equals(this[kId], otherId[kId]); - } - if (typeof otherId === "string") { - return otherId.toLowerCase() === this.toHexString(); - } - if (typeof otherId === "object" && typeof otherId.toHexString === "function") { - const otherIdString = otherId.toHexString(); - const thisIdString = this.toHexString(); - return typeof otherIdString === "string" && otherIdString.toLowerCase() === thisIdString; - } - return false; - } - getTimestamp() { - const timestamp = /* @__PURE__ */ new Date(); - const time = BSONDataView.fromUint8Array(this.id).getUint32(0, false); - timestamp.setTime(Math.floor(time) * 1e3); - return timestamp; - } - static createPk() { - return new _ObjectId(); - } - static createFromTime(time) { - const buffer2 = ByteUtils.fromNumberArray([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); - BSONDataView.fromUint8Array(buffer2).setUint32(0, time, false); - return new _ObjectId(buffer2); - } - static createFromHexString(hexString) { - if (hexString?.length !== 24) { - throw new BSONError("hex string must be 24 characters"); - } - return new _ObjectId(ByteUtils.fromHex(hexString)); - } - static createFromBase64(base64) { - if (base64?.length !== 16) { - throw new BSONError("base64 string must be 16 characters"); - } - return new _ObjectId(ByteUtils.fromBase64(base64)); - } - static isValid(id) { - if (id == null) - return false; - try { - new _ObjectId(id); - return true; - } catch { - return false; - } - } - toExtendedJSON() { - if (this.toHexString) - return { $oid: this.toHexString() }; - return { $oid: this.toString("hex") }; - } - static fromExtendedJSON(doc) { - return new _ObjectId(doc.$oid); - } - inspect(depth, options, inspect) { - inspect ??= defaultInspect; - return `new ObjectId(${inspect(this.toHexString(), options)})`; - } - }; - ObjectId.index = Math.floor(Math.random() * 16777215); - function internalCalculateObjectSize(object, serializeFunctions, ignoreUndefined) { - let totalLength = 4 + 1; - if (Array.isArray(object)) { - for (let i = 0; i < object.length; i++) { - totalLength += calculateElement(i.toString(), object[i], serializeFunctions, true, ignoreUndefined); - } - } else { - if (typeof object?.toBSON === "function") { - object = object.toBSON(); - } - for (const key of Object.keys(object)) { - totalLength += calculateElement(key, object[key], serializeFunctions, false, ignoreUndefined); - } - } - return totalLength; - } - function calculateElement(name, value, serializeFunctions = false, isArray = false, ignoreUndefined = false) { - if (typeof value?.toBSON === "function") { - value = value.toBSON(); - } - switch (typeof value) { - case "string": - return 1 + ByteUtils.utf8ByteLength(name) + 1 + 4 + ByteUtils.utf8ByteLength(value) + 1; - case "number": - if (Math.floor(value) === value && value >= JS_INT_MIN && value <= JS_INT_MAX) { - if (value >= BSON_INT32_MIN && value <= BSON_INT32_MAX) { - return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (4 + 1); - } else { - return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (8 + 1); - } - } else { - return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (8 + 1); - } - case "undefined": - if (isArray || !ignoreUndefined) - return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + 1; - return 0; - case "boolean": - return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (1 + 1); - case "object": - if (value != null && typeof value._bsontype === "string" && value[Symbol.for("@@mdb.bson.version")] !== BSON_MAJOR_VERSION) { - throw new BSONVersionError(); - } else if (value == null || value._bsontype === "MinKey" || value._bsontype === "MaxKey") { - return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + 1; - } else if (value._bsontype === "ObjectId") { - return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (12 + 1); - } else if (value instanceof Date || isDate(value)) { - return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (8 + 1); - } else if (ArrayBuffer.isView(value) || value instanceof ArrayBuffer || isAnyArrayBuffer(value)) { - return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (1 + 4 + 1) + value.byteLength; - } else if (value._bsontype === "Long" || value._bsontype === "Double" || value._bsontype === "Timestamp") { - return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (8 + 1); - } else if (value._bsontype === "Decimal128") { - return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (16 + 1); - } else if (value._bsontype === "Code") { - if (value.scope != null && Object.keys(value.scope).length > 0) { - return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + 1 + 4 + 4 + ByteUtils.utf8ByteLength(value.code.toString()) + 1 + internalCalculateObjectSize(value.scope, serializeFunctions, ignoreUndefined); - } else { - return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + 1 + 4 + ByteUtils.utf8ByteLength(value.code.toString()) + 1; - } - } else if (value._bsontype === "Binary") { - const binary = value; - if (binary.sub_type === Binary.SUBTYPE_BYTE_ARRAY) { - return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (binary.position + 1 + 4 + 1 + 4); - } else { - return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (binary.position + 1 + 4 + 1); - } - } else if (value._bsontype === "Symbol") { - return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + ByteUtils.utf8ByteLength(value.value) + 4 + 1 + 1; - } else if (value._bsontype === "DBRef") { - const ordered_values = Object.assign({ - $ref: value.collection, - $id: value.oid - }, value.fields); - if (value.db != null) { - ordered_values["$db"] = value.db; - } - return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + 1 + internalCalculateObjectSize(ordered_values, serializeFunctions, ignoreUndefined); - } else if (value instanceof RegExp || isRegExp(value)) { - return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + 1 + ByteUtils.utf8ByteLength(value.source) + 1 + (value.global ? 1 : 0) + (value.ignoreCase ? 1 : 0) + (value.multiline ? 1 : 0) + 1; - } else if (value._bsontype === "BSONRegExp") { - return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + 1 + ByteUtils.utf8ByteLength(value.pattern) + 1 + ByteUtils.utf8ByteLength(value.options) + 1; - } else { - return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + internalCalculateObjectSize(value, serializeFunctions, ignoreUndefined) + 1; - } - case "function": - if (serializeFunctions) { - return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + 1 + 4 + ByteUtils.utf8ByteLength(value.toString()) + 1; - } - } - return 0; - } - function alphabetize(str) { - return str.split("").sort().join(""); - } - var BSONRegExp = class _BSONRegExp extends BSONValue { - get _bsontype() { - return "BSONRegExp"; - } - constructor(pattern, options) { - super(); - this.pattern = pattern; - this.options = alphabetize(options ?? ""); - if (this.pattern.indexOf("\0") !== -1) { - throw new BSONError(`BSON Regex patterns cannot contain null bytes, found: ${JSON.stringify(this.pattern)}`); - } - if (this.options.indexOf("\0") !== -1) { - throw new BSONError(`BSON Regex options cannot contain null bytes, found: ${JSON.stringify(this.options)}`); - } - for (let i = 0; i < this.options.length; i++) { - if (!(this.options[i] === "i" || this.options[i] === "m" || this.options[i] === "x" || this.options[i] === "l" || this.options[i] === "s" || this.options[i] === "u")) { - throw new BSONError(`The regular expression option [${this.options[i]}] is not supported`); - } - } - } - static parseOptions(options) { - return options ? options.split("").sort().join("") : ""; - } - toExtendedJSON(options) { - options = options || {}; - if (options.legacy) { - return { $regex: this.pattern, $options: this.options }; - } - return { $regularExpression: { pattern: this.pattern, options: this.options } }; - } - static fromExtendedJSON(doc) { - if ("$regex" in doc) { - if (typeof doc.$regex !== "string") { - if (doc.$regex._bsontype === "BSONRegExp") { - return doc; - } - } else { - return new _BSONRegExp(doc.$regex, _BSONRegExp.parseOptions(doc.$options)); - } - } - if ("$regularExpression" in doc) { - return new _BSONRegExp(doc.$regularExpression.pattern, _BSONRegExp.parseOptions(doc.$regularExpression.options)); - } - throw new BSONError(`Unexpected BSONRegExp EJSON object form: ${JSON.stringify(doc)}`); - } - inspect(depth, options, inspect) { - const stylize = getStylizeFunction(options) ?? ((v) => v); - inspect ??= defaultInspect; - const pattern = stylize(inspect(this.pattern), "regexp"); - const flags = stylize(inspect(this.options), "regexp"); - return `new BSONRegExp(${pattern}, ${flags})`; - } - }; - var BSONSymbol = class _BSONSymbol extends BSONValue { - get _bsontype() { - return "BSONSymbol"; - } - constructor(value) { - super(); - this.value = value; - } - valueOf() { - return this.value; - } - toString() { - return this.value; - } - toJSON() { - return this.value; - } - toExtendedJSON() { - return { $symbol: this.value }; - } - static fromExtendedJSON(doc) { - return new _BSONSymbol(doc.$symbol); - } - inspect(depth, options, inspect) { - inspect ??= defaultInspect; - return `new BSONSymbol(${inspect(this.value, options)})`; - } - }; - var LongWithoutOverridesClass = Long; - var Timestamp = class _Timestamp extends LongWithoutOverridesClass { - get _bsontype() { - return "Timestamp"; - } - constructor(low) { - if (low == null) { - super(0, 0, true); - } else if (typeof low === "bigint") { - super(low, true); - } else if (Long.isLong(low)) { - super(low.low, low.high, true); - } else if (typeof low === "object" && "t" in low && "i" in low) { - if (typeof low.t !== "number" && (typeof low.t !== "object" || low.t._bsontype !== "Int32")) { - throw new BSONError("Timestamp constructed from { t, i } must provide t as a number"); - } - if (typeof low.i !== "number" && (typeof low.i !== "object" || low.i._bsontype !== "Int32")) { - throw new BSONError("Timestamp constructed from { t, i } must provide i as a number"); - } - const t = Number(low.t); - const i = Number(low.i); - if (t < 0 || Number.isNaN(t)) { - throw new BSONError("Timestamp constructed from { t, i } must provide a positive t"); - } - if (i < 0 || Number.isNaN(i)) { - throw new BSONError("Timestamp constructed from { t, i } must provide a positive i"); - } - if (t > 4294967295) { - throw new BSONError("Timestamp constructed from { t, i } must provide t equal or less than uint32 max"); - } - if (i > 4294967295) { - throw new BSONError("Timestamp constructed from { t, i } must provide i equal or less than uint32 max"); - } - super(i, t, true); - } else { - throw new BSONError("A Timestamp can only be constructed with: bigint, Long, or { t: number; i: number }"); - } - } - toJSON() { - return { - $timestamp: this.toString() - }; - } - static fromInt(value) { - return new _Timestamp(Long.fromInt(value, true)); - } - static fromNumber(value) { - return new _Timestamp(Long.fromNumber(value, true)); - } - static fromBits(lowBits, highBits) { - return new _Timestamp({ i: lowBits, t: highBits }); - } - static fromString(str, optRadix) { - return new _Timestamp(Long.fromString(str, true, optRadix)); - } - toExtendedJSON() { - return { $timestamp: { t: this.high >>> 0, i: this.low >>> 0 } }; - } - static fromExtendedJSON(doc) { - const i = Long.isLong(doc.$timestamp.i) ? doc.$timestamp.i.getLowBitsUnsigned() : doc.$timestamp.i; - const t = Long.isLong(doc.$timestamp.t) ? doc.$timestamp.t.getLowBitsUnsigned() : doc.$timestamp.t; - return new _Timestamp({ t, i }); - } - inspect(depth, options, inspect) { - inspect ??= defaultInspect; - const t = inspect(this.high >>> 0, options); - const i = inspect(this.low >>> 0, options); - return `new Timestamp({ t: ${t}, i: ${i} })`; - } - }; - Timestamp.MAX_VALUE = Long.MAX_UNSIGNED_VALUE; - var JS_INT_MAX_LONG = Long.fromNumber(JS_INT_MAX); - var JS_INT_MIN_LONG = Long.fromNumber(JS_INT_MIN); - function internalDeserialize(buffer2, options, isArray) { - options = options == null ? {} : options; - const index = options && options.index ? options.index : 0; - const size = buffer2[index] | buffer2[index + 1] << 8 | buffer2[index + 2] << 16 | buffer2[index + 3] << 24; - if (size < 5) { - throw new BSONError(`bson size must be >= 5, is ${size}`); - } - if (options.allowObjectSmallerThanBufferSize && buffer2.length < size) { - throw new BSONError(`buffer length ${buffer2.length} must be >= bson size ${size}`); - } - if (!options.allowObjectSmallerThanBufferSize && buffer2.length !== size) { - throw new BSONError(`buffer length ${buffer2.length} must === bson size ${size}`); - } - if (size + index > buffer2.byteLength) { - throw new BSONError(`(bson size ${size} + options.index ${index} must be <= buffer length ${buffer2.byteLength})`); - } - if (buffer2[index + size - 1] !== 0) { - throw new BSONError("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00"); - } - return deserializeObject(buffer2, index, options, isArray); - } - var allowedDBRefKeys = /^\$ref$|^\$id$|^\$db$/; - function deserializeObject(buffer2, index, options, isArray = false) { - const fieldsAsRaw = options["fieldsAsRaw"] == null ? null : options["fieldsAsRaw"]; - const raw = options["raw"] == null ? false : options["raw"]; - const bsonRegExp = typeof options["bsonRegExp"] === "boolean" ? options["bsonRegExp"] : false; - const promoteBuffers = options.promoteBuffers ?? false; - const promoteLongs = options.promoteLongs ?? true; - const promoteValues = options.promoteValues ?? true; - const useBigInt64 = options.useBigInt64 ?? false; - if (useBigInt64 && !promoteValues) { - throw new BSONError("Must either request bigint or Long for int64 deserialization"); - } - if (useBigInt64 && !promoteLongs) { - throw new BSONError("Must either request bigint or Long for int64 deserialization"); - } - const validation = options.validation == null ? { utf8: true } : options.validation; - let globalUTFValidation = true; - let validationSetting; - const utf8KeysSet = /* @__PURE__ */ new Set(); - const utf8ValidatedKeys = validation.utf8; - if (typeof utf8ValidatedKeys === "boolean") { - validationSetting = utf8ValidatedKeys; - } else { - globalUTFValidation = false; - const utf8ValidationValues = Object.keys(utf8ValidatedKeys).map(function(key) { - return utf8ValidatedKeys[key]; - }); - if (utf8ValidationValues.length === 0) { - throw new BSONError("UTF-8 validation setting cannot be empty"); - } - if (typeof utf8ValidationValues[0] !== "boolean") { - throw new BSONError("Invalid UTF-8 validation option, must specify boolean values"); - } - validationSetting = utf8ValidationValues[0]; - if (!utf8ValidationValues.every((item) => item === validationSetting)) { - throw new BSONError("Invalid UTF-8 validation option - keys must be all true or all false"); - } - } - if (!globalUTFValidation) { - for (const key of Object.keys(utf8ValidatedKeys)) { - utf8KeysSet.add(key); - } - } - const startIndex = index; - if (buffer2.length < 5) - throw new BSONError("corrupt bson message < 5 bytes long"); - const size = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24; - if (size < 5 || size > buffer2.length) - throw new BSONError("corrupt bson message"); - const object = isArray ? [] : {}; - let arrayIndex = 0; - const done = false; - let isPossibleDBRef = isArray ? false : null; - const dataview = new DataView(buffer2.buffer, buffer2.byteOffset, buffer2.byteLength); - while (!done) { - const elementType = buffer2[index++]; - if (elementType === 0) - break; - let i = index; - while (buffer2[i] !== 0 && i < buffer2.length) { - i++; - } - if (i >= buffer2.byteLength) - throw new BSONError("Bad BSON Document: illegal CString"); - const name = isArray ? arrayIndex++ : ByteUtils.toUTF8(buffer2, index, i, false); - let shouldValidateKey = true; - if (globalUTFValidation || utf8KeysSet.has(name)) { - shouldValidateKey = validationSetting; - } else { - shouldValidateKey = !validationSetting; - } - if (isPossibleDBRef !== false && name[0] === "$") { - isPossibleDBRef = allowedDBRefKeys.test(name); - } - let value; - index = i + 1; - if (elementType === BSON_DATA_STRING) { - const stringSize = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24; - if (stringSize <= 0 || stringSize > buffer2.length - index || buffer2[index + stringSize - 1] !== 0) { - throw new BSONError("bad string length in bson"); - } - value = ByteUtils.toUTF8(buffer2, index, index + stringSize - 1, shouldValidateKey); - index = index + stringSize; - } else if (elementType === BSON_DATA_OID) { - const oid = ByteUtils.allocate(12); - oid.set(buffer2.subarray(index, index + 12)); - value = new ObjectId(oid); - index = index + 12; - } else if (elementType === BSON_DATA_INT && promoteValues === false) { - value = new Int32(buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24); - } else if (elementType === BSON_DATA_INT) { - value = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24; - } else if (elementType === BSON_DATA_NUMBER && promoteValues === false) { - value = new Double(dataview.getFloat64(index, true)); - index = index + 8; - } else if (elementType === BSON_DATA_NUMBER) { - value = dataview.getFloat64(index, true); - index = index + 8; - } else if (elementType === BSON_DATA_DATE) { - const lowBits = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24; - const highBits = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24; - value = new Date(new Long(lowBits, highBits).toNumber()); - } else if (elementType === BSON_DATA_BOOLEAN) { - if (buffer2[index] !== 0 && buffer2[index] !== 1) - throw new BSONError("illegal boolean type value"); - value = buffer2[index++] === 1; - } else if (elementType === BSON_DATA_OBJECT) { - const _index = index; - const objectSize = buffer2[index] | buffer2[index + 1] << 8 | buffer2[index + 2] << 16 | buffer2[index + 3] << 24; - if (objectSize <= 0 || objectSize > buffer2.length - index) - throw new BSONError("bad embedded document length in bson"); - if (raw) { - value = buffer2.slice(index, index + objectSize); - } else { - let objectOptions = options; - if (!globalUTFValidation) { - objectOptions = { ...options, validation: { utf8: shouldValidateKey } }; - } - value = deserializeObject(buffer2, _index, objectOptions, false); - } - index = index + objectSize; - } else if (elementType === BSON_DATA_ARRAY) { - const _index = index; - const objectSize = buffer2[index] | buffer2[index + 1] << 8 | buffer2[index + 2] << 16 | buffer2[index + 3] << 24; - let arrayOptions = options; - const stopIndex = index + objectSize; - if (fieldsAsRaw && fieldsAsRaw[name]) { - arrayOptions = { ...options, raw: true }; - } - if (!globalUTFValidation) { - arrayOptions = { ...arrayOptions, validation: { utf8: shouldValidateKey } }; - } - value = deserializeObject(buffer2, _index, arrayOptions, true); - index = index + objectSize; - if (buffer2[index - 1] !== 0) - throw new BSONError("invalid array terminator byte"); - if (index !== stopIndex) - throw new BSONError("corrupted array bson"); - } else if (elementType === BSON_DATA_UNDEFINED) { - value = void 0; - } else if (elementType === BSON_DATA_NULL) { - value = null; - } else if (elementType === BSON_DATA_LONG) { - const dataview2 = BSONDataView.fromUint8Array(buffer2.subarray(index, index + 8)); - const lowBits = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24; - const highBits = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24; - const long = new Long(lowBits, highBits); - if (useBigInt64) { - value = dataview2.getBigInt64(0, true); - } else if (promoteLongs && promoteValues === true) { - value = long.lessThanOrEqual(JS_INT_MAX_LONG) && long.greaterThanOrEqual(JS_INT_MIN_LONG) ? long.toNumber() : long; - } else { - value = long; - } - } else if (elementType === BSON_DATA_DECIMAL128) { - const bytes = ByteUtils.allocate(16); - bytes.set(buffer2.subarray(index, index + 16), 0); - index = index + 16; - value = new Decimal128(bytes); - } else if (elementType === BSON_DATA_BINARY) { - let binarySize = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24; - const totalBinarySize = binarySize; - const subType = buffer2[index++]; - if (binarySize < 0) - throw new BSONError("Negative binary type element size found"); - if (binarySize > buffer2.byteLength) - throw new BSONError("Binary type size larger than document size"); - if (buffer2["slice"] != null) { - if (subType === Binary.SUBTYPE_BYTE_ARRAY) { - binarySize = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24; - if (binarySize < 0) - throw new BSONError("Negative binary type element size found for subtype 0x02"); - if (binarySize > totalBinarySize - 4) - throw new BSONError("Binary type with subtype 0x02 contains too long binary size"); - if (binarySize < totalBinarySize - 4) - throw new BSONError("Binary type with subtype 0x02 contains too short binary size"); - } - if (promoteBuffers && promoteValues) { - value = ByteUtils.toLocalBufferType(buffer2.slice(index, index + binarySize)); - } else { - value = new Binary(buffer2.slice(index, index + binarySize), subType); - if (subType === BSON_BINARY_SUBTYPE_UUID_NEW && UUID.isValid(value)) { - value = value.toUUID(); - } - } - } else { - const _buffer = ByteUtils.allocate(binarySize); - if (subType === Binary.SUBTYPE_BYTE_ARRAY) { - binarySize = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24; - if (binarySize < 0) - throw new BSONError("Negative binary type element size found for subtype 0x02"); - if (binarySize > totalBinarySize - 4) - throw new BSONError("Binary type with subtype 0x02 contains too long binary size"); - if (binarySize < totalBinarySize - 4) - throw new BSONError("Binary type with subtype 0x02 contains too short binary size"); - } - for (i = 0; i < binarySize; i++) { - _buffer[i] = buffer2[index + i]; - } - if (promoteBuffers && promoteValues) { - value = _buffer; - } else { - value = new Binary(buffer2.slice(index, index + binarySize), subType); - if (subType === BSON_BINARY_SUBTYPE_UUID_NEW && UUID.isValid(value)) { - value = value.toUUID(); - } - } - } - index = index + binarySize; - } else if (elementType === BSON_DATA_REGEXP && bsonRegExp === false) { - i = index; - while (buffer2[i] !== 0 && i < buffer2.length) { - i++; - } - if (i >= buffer2.length) - throw new BSONError("Bad BSON Document: illegal CString"); - const source = ByteUtils.toUTF8(buffer2, index, i, false); - index = i + 1; - i = index; - while (buffer2[i] !== 0 && i < buffer2.length) { - i++; - } - if (i >= buffer2.length) - throw new BSONError("Bad BSON Document: illegal CString"); - const regExpOptions = ByteUtils.toUTF8(buffer2, index, i, false); - index = i + 1; - const optionsArray = new Array(regExpOptions.length); - for (i = 0; i < regExpOptions.length; i++) { - switch (regExpOptions[i]) { - case "m": - optionsArray[i] = "m"; - break; - case "s": - optionsArray[i] = "g"; - break; - case "i": - optionsArray[i] = "i"; - break; - } - } - value = new RegExp(source, optionsArray.join("")); - } else if (elementType === BSON_DATA_REGEXP && bsonRegExp === true) { - i = index; - while (buffer2[i] !== 0 && i < buffer2.length) { - i++; - } - if (i >= buffer2.length) - throw new BSONError("Bad BSON Document: illegal CString"); - const source = ByteUtils.toUTF8(buffer2, index, i, false); - index = i + 1; - i = index; - while (buffer2[i] !== 0 && i < buffer2.length) { - i++; - } - if (i >= buffer2.length) - throw new BSONError("Bad BSON Document: illegal CString"); - const regExpOptions = ByteUtils.toUTF8(buffer2, index, i, false); - index = i + 1; - value = new BSONRegExp(source, regExpOptions); - } else if (elementType === BSON_DATA_SYMBOL) { - const stringSize = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24; - if (stringSize <= 0 || stringSize > buffer2.length - index || buffer2[index + stringSize - 1] !== 0) { - throw new BSONError("bad string length in bson"); - } - const symbol = ByteUtils.toUTF8(buffer2, index, index + stringSize - 1, shouldValidateKey); - value = promoteValues ? symbol : new BSONSymbol(symbol); - index = index + stringSize; - } else if (elementType === BSON_DATA_TIMESTAMP) { - const i2 = buffer2[index++] + buffer2[index++] * (1 << 8) + buffer2[index++] * (1 << 16) + buffer2[index++] * (1 << 24); - const t = buffer2[index++] + buffer2[index++] * (1 << 8) + buffer2[index++] * (1 << 16) + buffer2[index++] * (1 << 24); - value = new Timestamp({ i: i2, t }); - } else if (elementType === BSON_DATA_MIN_KEY) { - value = new MinKey(); - } else if (elementType === BSON_DATA_MAX_KEY) { - value = new MaxKey(); - } else if (elementType === BSON_DATA_CODE) { - const stringSize = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24; - if (stringSize <= 0 || stringSize > buffer2.length - index || buffer2[index + stringSize - 1] !== 0) { - throw new BSONError("bad string length in bson"); - } - const functionString = ByteUtils.toUTF8(buffer2, index, index + stringSize - 1, shouldValidateKey); - value = new Code(functionString); - index = index + stringSize; - } else if (elementType === BSON_DATA_CODE_W_SCOPE) { - const totalSize = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24; - if (totalSize < 4 + 4 + 4 + 1) { - throw new BSONError("code_w_scope total size shorter minimum expected length"); - } - const stringSize = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24; - if (stringSize <= 0 || stringSize > buffer2.length - index || buffer2[index + stringSize - 1] !== 0) { - throw new BSONError("bad string length in bson"); - } - const functionString = ByteUtils.toUTF8(buffer2, index, index + stringSize - 1, shouldValidateKey); - index = index + stringSize; - const _index = index; - const objectSize = buffer2[index] | buffer2[index + 1] << 8 | buffer2[index + 2] << 16 | buffer2[index + 3] << 24; - const scopeObject = deserializeObject(buffer2, _index, options, false); - index = index + objectSize; - if (totalSize < 4 + 4 + objectSize + stringSize) { - throw new BSONError("code_w_scope total size is too short, truncating scope"); - } - if (totalSize > 4 + 4 + objectSize + stringSize) { - throw new BSONError("code_w_scope total size is too long, clips outer document"); - } - value = new Code(functionString, scopeObject); - } else if (elementType === BSON_DATA_DBPOINTER) { - const stringSize = buffer2[index++] | buffer2[index++] << 8 | buffer2[index++] << 16 | buffer2[index++] << 24; - if (stringSize <= 0 || stringSize > buffer2.length - index || buffer2[index + stringSize - 1] !== 0) - throw new BSONError("bad string length in bson"); - if (validation != null && validation.utf8) { - if (!validateUtf8(buffer2, index, index + stringSize - 1)) { - throw new BSONError("Invalid UTF-8 string in BSON document"); - } - } - const namespace = ByteUtils.toUTF8(buffer2, index, index + stringSize - 1, false); - index = index + stringSize; - const oidBuffer = ByteUtils.allocate(12); - oidBuffer.set(buffer2.subarray(index, index + 12), 0); - const oid = new ObjectId(oidBuffer); - index = index + 12; - value = new DBRef(namespace, oid); - } else { - throw new BSONError(`Detected unknown BSON type ${elementType.toString(16)} for fieldname "${name}"`); - } - if (name === "__proto__") { - Object.defineProperty(object, name, { - value, - writable: true, - enumerable: true, - configurable: true - }); - } else { - object[name] = value; - } - } - if (size !== index - startIndex) { - if (isArray) - throw new BSONError("corrupt array bson"); - throw new BSONError("corrupt object bson"); - } - if (!isPossibleDBRef) - return object; - if (isDBRefLike(object)) { - const copy = Object.assign({}, object); - delete copy.$ref; - delete copy.$id; - delete copy.$db; - return new DBRef(object.$ref, object.$id, object.$db, copy); - } - return object; - } - var regexp = /\x00/; - var ignoreKeys = /* @__PURE__ */ new Set(["$db", "$ref", "$id", "$clusterTime"]); - function serializeString(buffer2, key, value, index) { - buffer2[index++] = BSON_DATA_STRING; - const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index); - index = index + numberOfWrittenBytes + 1; - buffer2[index - 1] = 0; - const size = ByteUtils.encodeUTF8Into(buffer2, value, index + 4); - buffer2[index + 3] = size + 1 >> 24 & 255; - buffer2[index + 2] = size + 1 >> 16 & 255; - buffer2[index + 1] = size + 1 >> 8 & 255; - buffer2[index] = size + 1 & 255; - index = index + 4 + size; - buffer2[index++] = 0; - return index; - } - var NUMBER_SPACE = new DataView(new ArrayBuffer(8), 0, 8); - var FOUR_BYTE_VIEW_ON_NUMBER = new Uint8Array(NUMBER_SPACE.buffer, 0, 4); - var EIGHT_BYTE_VIEW_ON_NUMBER = new Uint8Array(NUMBER_SPACE.buffer, 0, 8); - function serializeNumber(buffer2, key, value, index) { - const isNegativeZero = Object.is(value, -0); - const type = !isNegativeZero && Number.isSafeInteger(value) && value <= BSON_INT32_MAX && value >= BSON_INT32_MIN ? BSON_DATA_INT : BSON_DATA_NUMBER; - if (type === BSON_DATA_INT) { - NUMBER_SPACE.setInt32(0, value, true); - } else { - NUMBER_SPACE.setFloat64(0, value, true); - } - const bytes = type === BSON_DATA_INT ? FOUR_BYTE_VIEW_ON_NUMBER : EIGHT_BYTE_VIEW_ON_NUMBER; - buffer2[index++] = type; - const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index); - index = index + numberOfWrittenBytes; - buffer2[index++] = 0; - buffer2.set(bytes, index); - index += bytes.byteLength; - return index; - } - function serializeBigInt(buffer2, key, value, index) { - buffer2[index++] = BSON_DATA_LONG; - const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index); - index += numberOfWrittenBytes; - buffer2[index++] = 0; - NUMBER_SPACE.setBigInt64(0, value, true); - buffer2.set(EIGHT_BYTE_VIEW_ON_NUMBER, index); - index += EIGHT_BYTE_VIEW_ON_NUMBER.byteLength; - return index; - } - function serializeNull(buffer2, key, _, index) { - buffer2[index++] = BSON_DATA_NULL; - const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index); - index = index + numberOfWrittenBytes; - buffer2[index++] = 0; - return index; - } - function serializeBoolean(buffer2, key, value, index) { - buffer2[index++] = BSON_DATA_BOOLEAN; - const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index); - index = index + numberOfWrittenBytes; - buffer2[index++] = 0; - buffer2[index++] = value ? 1 : 0; - return index; - } - function serializeDate(buffer2, key, value, index) { - buffer2[index++] = BSON_DATA_DATE; - const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index); - index = index + numberOfWrittenBytes; - buffer2[index++] = 0; - const dateInMilis = Long.fromNumber(value.getTime()); - const lowBits = dateInMilis.getLowBits(); - const highBits = dateInMilis.getHighBits(); - buffer2[index++] = lowBits & 255; - buffer2[index++] = lowBits >> 8 & 255; - buffer2[index++] = lowBits >> 16 & 255; - buffer2[index++] = lowBits >> 24 & 255; - buffer2[index++] = highBits & 255; - buffer2[index++] = highBits >> 8 & 255; - buffer2[index++] = highBits >> 16 & 255; - buffer2[index++] = highBits >> 24 & 255; - return index; - } - function serializeRegExp(buffer2, key, value, index) { - buffer2[index++] = BSON_DATA_REGEXP; - const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index); - index = index + numberOfWrittenBytes; - buffer2[index++] = 0; - if (value.source && value.source.match(regexp) != null) { - throw new BSONError("value " + value.source + " must not contain null bytes"); - } - index = index + ByteUtils.encodeUTF8Into(buffer2, value.source, index); - buffer2[index++] = 0; - if (value.ignoreCase) - buffer2[index++] = 105; - if (value.global) - buffer2[index++] = 115; - if (value.multiline) - buffer2[index++] = 109; - buffer2[index++] = 0; - return index; - } - function serializeBSONRegExp(buffer2, key, value, index) { - buffer2[index++] = BSON_DATA_REGEXP; - const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index); - index = index + numberOfWrittenBytes; - buffer2[index++] = 0; - if (value.pattern.match(regexp) != null) { - throw new BSONError("pattern " + value.pattern + " must not contain null bytes"); - } - index = index + ByteUtils.encodeUTF8Into(buffer2, value.pattern, index); - buffer2[index++] = 0; - const sortedOptions = value.options.split("").sort().join(""); - index = index + ByteUtils.encodeUTF8Into(buffer2, sortedOptions, index); - buffer2[index++] = 0; - return index; - } - function serializeMinMax(buffer2, key, value, index) { - if (value === null) { - buffer2[index++] = BSON_DATA_NULL; - } else if (value._bsontype === "MinKey") { - buffer2[index++] = BSON_DATA_MIN_KEY; - } else { - buffer2[index++] = BSON_DATA_MAX_KEY; - } - const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index); - index = index + numberOfWrittenBytes; - buffer2[index++] = 0; - return index; - } - function serializeObjectId(buffer2, key, value, index) { - buffer2[index++] = BSON_DATA_OID; - const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index); - index = index + numberOfWrittenBytes; - buffer2[index++] = 0; - const idValue = value.id; - if (isUint8Array(idValue)) { - for (let i = 0; i < 12; i++) { - buffer2[index++] = idValue[i]; - } - } else { - throw new BSONError("object [" + JSON.stringify(value) + "] is not a valid ObjectId"); - } - return index; - } - function serializeBuffer(buffer2, key, value, index) { - buffer2[index++] = BSON_DATA_BINARY; - const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index); - index = index + numberOfWrittenBytes; - buffer2[index++] = 0; - const size = value.length; - buffer2[index++] = size & 255; - buffer2[index++] = size >> 8 & 255; - buffer2[index++] = size >> 16 & 255; - buffer2[index++] = size >> 24 & 255; - buffer2[index++] = BSON_BINARY_SUBTYPE_DEFAULT; - buffer2.set(value, index); - index = index + size; - return index; - } - function serializeObject(buffer2, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path) { - if (path.has(value)) { - throw new BSONError("Cannot convert circular structure to BSON"); - } - path.add(value); - buffer2[index++] = Array.isArray(value) ? BSON_DATA_ARRAY : BSON_DATA_OBJECT; - const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index); - index = index + numberOfWrittenBytes; - buffer2[index++] = 0; - const endIndex = serializeInto(buffer2, value, checkKeys, index, depth + 1, serializeFunctions, ignoreUndefined, path); - path.delete(value); - return endIndex; - } - function serializeDecimal128(buffer2, key, value, index) { - buffer2[index++] = BSON_DATA_DECIMAL128; - const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index); - index = index + numberOfWrittenBytes; - buffer2[index++] = 0; - buffer2.set(value.bytes.subarray(0, 16), index); - return index + 16; - } - function serializeLong(buffer2, key, value, index) { - buffer2[index++] = value._bsontype === "Long" ? BSON_DATA_LONG : BSON_DATA_TIMESTAMP; - const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index); - index = index + numberOfWrittenBytes; - buffer2[index++] = 0; - const lowBits = value.getLowBits(); - const highBits = value.getHighBits(); - buffer2[index++] = lowBits & 255; - buffer2[index++] = lowBits >> 8 & 255; - buffer2[index++] = lowBits >> 16 & 255; - buffer2[index++] = lowBits >> 24 & 255; - buffer2[index++] = highBits & 255; - buffer2[index++] = highBits >> 8 & 255; - buffer2[index++] = highBits >> 16 & 255; - buffer2[index++] = highBits >> 24 & 255; - return index; - } - function serializeInt32(buffer2, key, value, index) { - value = value.valueOf(); - buffer2[index++] = BSON_DATA_INT; - const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index); - index = index + numberOfWrittenBytes; - buffer2[index++] = 0; - buffer2[index++] = value & 255; - buffer2[index++] = value >> 8 & 255; - buffer2[index++] = value >> 16 & 255; - buffer2[index++] = value >> 24 & 255; - return index; - } - function serializeDouble(buffer2, key, value, index) { - buffer2[index++] = BSON_DATA_NUMBER; - const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index); - index = index + numberOfWrittenBytes; - buffer2[index++] = 0; - NUMBER_SPACE.setFloat64(0, value.value, true); - buffer2.set(EIGHT_BYTE_VIEW_ON_NUMBER, index); - index = index + 8; - return index; - } - function serializeFunction(buffer2, key, value, index) { - buffer2[index++] = BSON_DATA_CODE; - const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index); - index = index + numberOfWrittenBytes; - buffer2[index++] = 0; - const functionString = value.toString(); - const size = ByteUtils.encodeUTF8Into(buffer2, functionString, index + 4) + 1; - buffer2[index] = size & 255; - buffer2[index + 1] = size >> 8 & 255; - buffer2[index + 2] = size >> 16 & 255; - buffer2[index + 3] = size >> 24 & 255; - index = index + 4 + size - 1; - buffer2[index++] = 0; - return index; - } - function serializeCode(buffer2, key, value, index, checkKeys = false, depth = 0, serializeFunctions = false, ignoreUndefined = true, path) { - if (value.scope && typeof value.scope === "object") { - buffer2[index++] = BSON_DATA_CODE_W_SCOPE; - const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index); - index = index + numberOfWrittenBytes; - buffer2[index++] = 0; - let startIndex = index; - const functionString = value.code; - index = index + 4; - const codeSize = ByteUtils.encodeUTF8Into(buffer2, functionString, index + 4) + 1; - buffer2[index] = codeSize & 255; - buffer2[index + 1] = codeSize >> 8 & 255; - buffer2[index + 2] = codeSize >> 16 & 255; - buffer2[index + 3] = codeSize >> 24 & 255; - buffer2[index + 4 + codeSize - 1] = 0; - index = index + codeSize + 4; - const endIndex = serializeInto(buffer2, value.scope, checkKeys, index, depth + 1, serializeFunctions, ignoreUndefined, path); - index = endIndex - 1; - const totalSize = endIndex - startIndex; - buffer2[startIndex++] = totalSize & 255; - buffer2[startIndex++] = totalSize >> 8 & 255; - buffer2[startIndex++] = totalSize >> 16 & 255; - buffer2[startIndex++] = totalSize >> 24 & 255; - buffer2[index++] = 0; - } else { - buffer2[index++] = BSON_DATA_CODE; - const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index); - index = index + numberOfWrittenBytes; - buffer2[index++] = 0; - const functionString = value.code.toString(); - const size = ByteUtils.encodeUTF8Into(buffer2, functionString, index + 4) + 1; - buffer2[index] = size & 255; - buffer2[index + 1] = size >> 8 & 255; - buffer2[index + 2] = size >> 16 & 255; - buffer2[index + 3] = size >> 24 & 255; - index = index + 4 + size - 1; - buffer2[index++] = 0; - } - return index; - } - function serializeBinary(buffer2, key, value, index) { - buffer2[index++] = BSON_DATA_BINARY; - const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index); - index = index + numberOfWrittenBytes; - buffer2[index++] = 0; - const data = value.buffer; - let size = value.position; - if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) - size = size + 4; - buffer2[index++] = size & 255; - buffer2[index++] = size >> 8 & 255; - buffer2[index++] = size >> 16 & 255; - buffer2[index++] = size >> 24 & 255; - buffer2[index++] = value.sub_type; - if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) { - size = size - 4; - buffer2[index++] = size & 255; - buffer2[index++] = size >> 8 & 255; - buffer2[index++] = size >> 16 & 255; - buffer2[index++] = size >> 24 & 255; - } - buffer2.set(data, index); - index = index + value.position; - return index; - } - function serializeSymbol(buffer2, key, value, index) { - buffer2[index++] = BSON_DATA_SYMBOL; - const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index); - index = index + numberOfWrittenBytes; - buffer2[index++] = 0; - const size = ByteUtils.encodeUTF8Into(buffer2, value.value, index + 4) + 1; - buffer2[index] = size & 255; - buffer2[index + 1] = size >> 8 & 255; - buffer2[index + 2] = size >> 16 & 255; - buffer2[index + 3] = size >> 24 & 255; - index = index + 4 + size - 1; - buffer2[index++] = 0; - return index; - } - function serializeDBRef(buffer2, key, value, index, depth, serializeFunctions, path) { - buffer2[index++] = BSON_DATA_OBJECT; - const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer2, key, index); - index = index + numberOfWrittenBytes; - buffer2[index++] = 0; - let startIndex = index; - let output = { - $ref: value.collection || value.namespace, - $id: value.oid - }; - if (value.db != null) { - output.$db = value.db; - } - output = Object.assign(output, value.fields); - const endIndex = serializeInto(buffer2, output, false, index, depth + 1, serializeFunctions, true, path); - const size = endIndex - startIndex; - buffer2[startIndex++] = size & 255; - buffer2[startIndex++] = size >> 8 & 255; - buffer2[startIndex++] = size >> 16 & 255; - buffer2[startIndex++] = size >> 24 & 255; - return endIndex; - } - function serializeInto(buffer2, object, checkKeys, startingIndex, depth, serializeFunctions, ignoreUndefined, path) { - if (path == null) { - if (object == null) { - buffer2[0] = 5; - buffer2[1] = 0; - buffer2[2] = 0; - buffer2[3] = 0; - buffer2[4] = 0; - return 5; - } - if (Array.isArray(object)) { - throw new BSONError("serialize does not support an array as the root input"); - } - if (typeof object !== "object") { - throw new BSONError("serialize does not support non-object as the root input"); - } else if ("_bsontype" in object && typeof object._bsontype === "string") { - throw new BSONError(`BSON types cannot be serialized as a document`); - } else if (isDate(object) || isRegExp(object) || isUint8Array(object) || isAnyArrayBuffer(object)) { - throw new BSONError(`date, regexp, typedarray, and arraybuffer cannot be BSON documents`); - } - path = /* @__PURE__ */ new Set(); - } - path.add(object); - let index = startingIndex + 4; - if (Array.isArray(object)) { - for (let i = 0; i < object.length; i++) { - const key = `${i}`; - let value = object[i]; - if (typeof value?.toBSON === "function") { - value = value.toBSON(); - } - if (typeof value === "string") { - index = serializeString(buffer2, key, value, index); - } else if (typeof value === "number") { - index = serializeNumber(buffer2, key, value, index); - } else if (typeof value === "bigint") { - index = serializeBigInt(buffer2, key, value, index); - } else if (typeof value === "boolean") { - index = serializeBoolean(buffer2, key, value, index); - } else if (value instanceof Date || isDate(value)) { - index = serializeDate(buffer2, key, value, index); - } else if (value === void 0) { - index = serializeNull(buffer2, key, value, index); - } else if (value === null) { - index = serializeNull(buffer2, key, value, index); - } else if (isUint8Array(value)) { - index = serializeBuffer(buffer2, key, value, index); - } else if (value instanceof RegExp || isRegExp(value)) { - index = serializeRegExp(buffer2, key, value, index); - } else if (typeof value === "object" && value._bsontype == null) { - index = serializeObject(buffer2, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path); - } else if (typeof value === "object" && value[Symbol.for("@@mdb.bson.version")] !== BSON_MAJOR_VERSION) { - throw new BSONVersionError(); - } else if (value._bsontype === "ObjectId") { - index = serializeObjectId(buffer2, key, value, index); - } else if (value._bsontype === "Decimal128") { - index = serializeDecimal128(buffer2, key, value, index); - } else if (value._bsontype === "Long" || value._bsontype === "Timestamp") { - index = serializeLong(buffer2, key, value, index); - } else if (value._bsontype === "Double") { - index = serializeDouble(buffer2, key, value, index); - } else if (typeof value === "function" && serializeFunctions) { - index = serializeFunction(buffer2, key, value, index); - } else if (value._bsontype === "Code") { - index = serializeCode(buffer2, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path); - } else if (value._bsontype === "Binary") { - index = serializeBinary(buffer2, key, value, index); - } else if (value._bsontype === "BSONSymbol") { - index = serializeSymbol(buffer2, key, value, index); - } else if (value._bsontype === "DBRef") { - index = serializeDBRef(buffer2, key, value, index, depth, serializeFunctions, path); - } else if (value._bsontype === "BSONRegExp") { - index = serializeBSONRegExp(buffer2, key, value, index); - } else if (value._bsontype === "Int32") { - index = serializeInt32(buffer2, key, value, index); - } else if (value._bsontype === "MinKey" || value._bsontype === "MaxKey") { - index = serializeMinMax(buffer2, key, value, index); - } else if (typeof value._bsontype !== "undefined") { - throw new BSONError(`Unrecognized or invalid _bsontype: ${String(value._bsontype)}`); - } - } - } else if (object instanceof Map || isMap(object)) { - const iterator = object.entries(); - let done = false; - while (!done) { - const entry = iterator.next(); - done = !!entry.done; - if (done) - continue; - const key = entry.value[0]; - let value = entry.value[1]; - if (typeof value?.toBSON === "function") { - value = value.toBSON(); - } - const type = typeof value; - if (typeof key === "string" && !ignoreKeys.has(key)) { - if (key.match(regexp) != null) { - throw new BSONError("key " + key + " must not contain null bytes"); - } - if (checkKeys) { - if ("$" === key[0]) { - throw new BSONError("key " + key + " must not start with '$'"); - } else if (~key.indexOf(".")) { - throw new BSONError("key " + key + " must not contain '.'"); - } - } - } - if (type === "string") { - index = serializeString(buffer2, key, value, index); - } else if (type === "number") { - index = serializeNumber(buffer2, key, value, index); - } else if (type === "bigint") { - index = serializeBigInt(buffer2, key, value, index); - } else if (type === "boolean") { - index = serializeBoolean(buffer2, key, value, index); - } else if (value instanceof Date || isDate(value)) { - index = serializeDate(buffer2, key, value, index); - } else if (value === null || value === void 0 && ignoreUndefined === false) { - index = serializeNull(buffer2, key, value, index); - } else if (isUint8Array(value)) { - index = serializeBuffer(buffer2, key, value, index); - } else if (value instanceof RegExp || isRegExp(value)) { - index = serializeRegExp(buffer2, key, value, index); - } else if (type === "object" && value._bsontype == null) { - index = serializeObject(buffer2, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path); - } else if (typeof value === "object" && value[Symbol.for("@@mdb.bson.version")] !== BSON_MAJOR_VERSION) { - throw new BSONVersionError(); - } else if (value._bsontype === "ObjectId") { - index = serializeObjectId(buffer2, key, value, index); - } else if (type === "object" && value._bsontype === "Decimal128") { - index = serializeDecimal128(buffer2, key, value, index); - } else if (value._bsontype === "Long" || value._bsontype === "Timestamp") { - index = serializeLong(buffer2, key, value, index); - } else if (value._bsontype === "Double") { - index = serializeDouble(buffer2, key, value, index); - } else if (value._bsontype === "Code") { - index = serializeCode(buffer2, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path); - } else if (typeof value === "function" && serializeFunctions) { - index = serializeFunction(buffer2, key, value, index); - } else if (value._bsontype === "Binary") { - index = serializeBinary(buffer2, key, value, index); - } else if (value._bsontype === "BSONSymbol") { - index = serializeSymbol(buffer2, key, value, index); - } else if (value._bsontype === "DBRef") { - index = serializeDBRef(buffer2, key, value, index, depth, serializeFunctions, path); - } else if (value._bsontype === "BSONRegExp") { - index = serializeBSONRegExp(buffer2, key, value, index); - } else if (value._bsontype === "Int32") { - index = serializeInt32(buffer2, key, value, index); - } else if (value._bsontype === "MinKey" || value._bsontype === "MaxKey") { - index = serializeMinMax(buffer2, key, value, index); - } else if (typeof value._bsontype !== "undefined") { - throw new BSONError(`Unrecognized or invalid _bsontype: ${String(value._bsontype)}`); - } - } - } else { - if (typeof object?.toBSON === "function") { - object = object.toBSON(); - if (object != null && typeof object !== "object") { - throw new BSONError("toBSON function did not return an object"); - } - } - for (const key of Object.keys(object)) { - let value = object[key]; - if (typeof value?.toBSON === "function") { - value = value.toBSON(); - } - const type = typeof value; - if (typeof key === "string" && !ignoreKeys.has(key)) { - if (key.match(regexp) != null) { - throw new BSONError("key " + key + " must not contain null bytes"); - } - if (checkKeys) { - if ("$" === key[0]) { - throw new BSONError("key " + key + " must not start with '$'"); - } else if (~key.indexOf(".")) { - throw new BSONError("key " + key + " must not contain '.'"); - } - } - } - if (type === "string") { - index = serializeString(buffer2, key, value, index); - } else if (type === "number") { - index = serializeNumber(buffer2, key, value, index); - } else if (type === "bigint") { - index = serializeBigInt(buffer2, key, value, index); - } else if (type === "boolean") { - index = serializeBoolean(buffer2, key, value, index); - } else if (value instanceof Date || isDate(value)) { - index = serializeDate(buffer2, key, value, index); - } else if (value === void 0) { - if (ignoreUndefined === false) - index = serializeNull(buffer2, key, value, index); - } else if (value === null) { - index = serializeNull(buffer2, key, value, index); - } else if (isUint8Array(value)) { - index = serializeBuffer(buffer2, key, value, index); - } else if (value instanceof RegExp || isRegExp(value)) { - index = serializeRegExp(buffer2, key, value, index); - } else if (type === "object" && value._bsontype == null) { - index = serializeObject(buffer2, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path); - } else if (typeof value === "object" && value[Symbol.for("@@mdb.bson.version")] !== BSON_MAJOR_VERSION) { - throw new BSONVersionError(); - } else if (value._bsontype === "ObjectId") { - index = serializeObjectId(buffer2, key, value, index); - } else if (type === "object" && value._bsontype === "Decimal128") { - index = serializeDecimal128(buffer2, key, value, index); - } else if (value._bsontype === "Long" || value._bsontype === "Timestamp") { - index = serializeLong(buffer2, key, value, index); - } else if (value._bsontype === "Double") { - index = serializeDouble(buffer2, key, value, index); - } else if (value._bsontype === "Code") { - index = serializeCode(buffer2, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path); - } else if (typeof value === "function" && serializeFunctions) { - index = serializeFunction(buffer2, key, value, index); - } else if (value._bsontype === "Binary") { - index = serializeBinary(buffer2, key, value, index); - } else if (value._bsontype === "BSONSymbol") { - index = serializeSymbol(buffer2, key, value, index); - } else if (value._bsontype === "DBRef") { - index = serializeDBRef(buffer2, key, value, index, depth, serializeFunctions, path); - } else if (value._bsontype === "BSONRegExp") { - index = serializeBSONRegExp(buffer2, key, value, index); - } else if (value._bsontype === "Int32") { - index = serializeInt32(buffer2, key, value, index); - } else if (value._bsontype === "MinKey" || value._bsontype === "MaxKey") { - index = serializeMinMax(buffer2, key, value, index); - } else if (typeof value._bsontype !== "undefined") { - throw new BSONError(`Unrecognized or invalid _bsontype: ${String(value._bsontype)}`); - } - } - } - path.delete(object); - buffer2[index++] = 0; - const size = index - startingIndex; - buffer2[startingIndex++] = size & 255; - buffer2[startingIndex++] = size >> 8 & 255; - buffer2[startingIndex++] = size >> 16 & 255; - buffer2[startingIndex++] = size >> 24 & 255; - return index; - } - function isBSONType(value) { - return value != null && typeof value === "object" && "_bsontype" in value && typeof value._bsontype === "string"; - } - var keysToCodecs = { - $oid: ObjectId, - $binary: Binary, - $uuid: Binary, - $symbol: BSONSymbol, - $numberInt: Int32, - $numberDecimal: Decimal128, - $numberDouble: Double, - $numberLong: Long, - $minKey: MinKey, - $maxKey: MaxKey, - $regex: BSONRegExp, - $regularExpression: BSONRegExp, - $timestamp: Timestamp - }; - function deserializeValue(value, options = {}) { - if (typeof value === "number") { - const in32BitRange = value <= BSON_INT32_MAX && value >= BSON_INT32_MIN; - const in64BitRange = value <= BSON_INT64_MAX && value >= BSON_INT64_MIN; - if (options.relaxed || options.legacy) { - return value; - } - if (Number.isInteger(value) && !Object.is(value, -0)) { - if (in32BitRange) { - return new Int32(value); - } - if (in64BitRange) { - if (options.useBigInt64) { - return BigInt(value); - } - return Long.fromNumber(value); - } - } - return new Double(value); - } - if (value == null || typeof value !== "object") - return value; - if (value.$undefined) - return null; - const keys = Object.keys(value).filter((k) => k.startsWith("$") && value[k] != null); - for (let i = 0; i < keys.length; i++) { - const c = keysToCodecs[keys[i]]; - if (c) - return c.fromExtendedJSON(value, options); - } - if (value.$date != null) { - const d = value.$date; - const date = /* @__PURE__ */ new Date(); - if (options.legacy) { - if (typeof d === "number") - date.setTime(d); - else if (typeof d === "string") - date.setTime(Date.parse(d)); - else if (typeof d === "bigint") - date.setTime(Number(d)); - else - throw new BSONRuntimeError(`Unrecognized type for EJSON date: ${typeof d}`); - } else { - if (typeof d === "string") - date.setTime(Date.parse(d)); - else if (Long.isLong(d)) - date.setTime(d.toNumber()); - else if (typeof d === "number" && options.relaxed) - date.setTime(d); - else if (typeof d === "bigint") - date.setTime(Number(d)); - else - throw new BSONRuntimeError(`Unrecognized type for EJSON date: ${typeof d}`); - } - return date; - } - if (value.$code != null) { - const copy = Object.assign({}, value); - if (value.$scope) { - copy.$scope = deserializeValue(value.$scope); - } - return Code.fromExtendedJSON(value); - } - if (isDBRefLike(value) || value.$dbPointer) { - const v = value.$ref ? value : value.$dbPointer; - if (v instanceof DBRef) - return v; - const dollarKeys = Object.keys(v).filter((k) => k.startsWith("$")); - let valid = true; - dollarKeys.forEach((k) => { - if (["$ref", "$id", "$db"].indexOf(k) === -1) - valid = false; - }); - if (valid) - return DBRef.fromExtendedJSON(v); - } - return value; - } - function serializeArray(array, options) { - return array.map((v, index) => { - options.seenObjects.push({ propertyName: `index ${index}`, obj: null }); - try { - return serializeValue(v, options); - } finally { - options.seenObjects.pop(); - } - }); - } - function getISOString(date) { - const isoStr = date.toISOString(); - return date.getUTCMilliseconds() !== 0 ? isoStr : isoStr.slice(0, -5) + "Z"; - } - function serializeValue(value, options) { - if (value instanceof Map || isMap(value)) { - const obj = /* @__PURE__ */ Object.create(null); - for (const [k, v] of value) { - if (typeof k !== "string") { - throw new BSONError("Can only serialize maps with string keys"); - } - obj[k] = v; - } - return serializeValue(obj, options); - } - if ((typeof value === "object" || typeof value === "function") && value !== null) { - const index = options.seenObjects.findIndex((entry) => entry.obj === value); - if (index !== -1) { - const props = options.seenObjects.map((entry) => entry.propertyName); - const leadingPart = props.slice(0, index).map((prop) => `${prop} -> `).join(""); - const alreadySeen = props[index]; - const circularPart = " -> " + props.slice(index + 1, props.length - 1).map((prop) => `${prop} -> `).join(""); - const current = props[props.length - 1]; - const leadingSpace = " ".repeat(leadingPart.length + alreadySeen.length / 2); - const dashes = "-".repeat(circularPart.length + (alreadySeen.length + current.length) / 2 - 1); - throw new BSONError(`Converting circular structure to EJSON: - ${leadingPart}${alreadySeen}${circularPart}${current} - ${leadingSpace}\\${dashes}/`); - } - options.seenObjects[options.seenObjects.length - 1].obj = value; - } - if (Array.isArray(value)) - return serializeArray(value, options); - if (value === void 0) - return null; - if (value instanceof Date || isDate(value)) { - const dateNum = value.getTime(), inRange = dateNum > -1 && dateNum < 2534023188e5; - if (options.legacy) { - return options.relaxed && inRange ? { $date: value.getTime() } : { $date: getISOString(value) }; - } - return options.relaxed && inRange ? { $date: getISOString(value) } : { $date: { $numberLong: value.getTime().toString() } }; - } - if (typeof value === "number" && (!options.relaxed || !isFinite(value))) { - if (Number.isInteger(value) && !Object.is(value, -0)) { - if (value >= BSON_INT32_MIN && value <= BSON_INT32_MAX) { - return { $numberInt: value.toString() }; - } - if (value >= BSON_INT64_MIN && value <= BSON_INT64_MAX) { - return { $numberLong: value.toString() }; - } - } - return { $numberDouble: Object.is(value, -0) ? "-0.0" : value.toString() }; - } - if (typeof value === "bigint") { - if (!options.relaxed) { - return { $numberLong: BigInt.asIntN(64, value).toString() }; - } - return Number(BigInt.asIntN(64, value)); - } - if (value instanceof RegExp || isRegExp(value)) { - let flags = value.flags; - if (flags === void 0) { - const match = value.toString().match(/[gimuy]*$/); - if (match) { - flags = match[0]; - } - } - const rx = new BSONRegExp(value.source, flags); - return rx.toExtendedJSON(options); - } - if (value != null && typeof value === "object") - return serializeDocument(value, options); - return value; - } - var BSON_TYPE_MAPPINGS = { - Binary: (o) => new Binary(o.value(), o.sub_type), - Code: (o) => new Code(o.code, o.scope), - DBRef: (o) => new DBRef(o.collection || o.namespace, o.oid, o.db, o.fields), - Decimal128: (o) => new Decimal128(o.bytes), - Double: (o) => new Double(o.value), - Int32: (o) => new Int32(o.value), - Long: (o) => Long.fromBits(o.low != null ? o.low : o.low_, o.low != null ? o.high : o.high_, o.low != null ? o.unsigned : o.unsigned_), - MaxKey: () => new MaxKey(), - MinKey: () => new MinKey(), - ObjectId: (o) => new ObjectId(o), - BSONRegExp: (o) => new BSONRegExp(o.pattern, o.options), - BSONSymbol: (o) => new BSONSymbol(o.value), - Timestamp: (o) => Timestamp.fromBits(o.low, o.high) - }; - function serializeDocument(doc, options) { - if (doc == null || typeof doc !== "object") - throw new BSONError("not an object instance"); - const bsontype = doc._bsontype; - if (typeof bsontype === "undefined") { - const _doc = {}; - for (const name of Object.keys(doc)) { - options.seenObjects.push({ propertyName: name, obj: null }); - try { - const value = serializeValue(doc[name], options); - if (name === "__proto__") { - Object.defineProperty(_doc, name, { - value, - writable: true, - enumerable: true, - configurable: true - }); - } else { - _doc[name] = value; - } - } finally { - options.seenObjects.pop(); - } - } - return _doc; - } else if (doc != null && typeof doc === "object" && typeof doc._bsontype === "string" && doc[Symbol.for("@@mdb.bson.version")] !== BSON_MAJOR_VERSION) { - throw new BSONVersionError(); - } else if (isBSONType(doc)) { - let outDoc = doc; - if (typeof outDoc.toExtendedJSON !== "function") { - const mapper = BSON_TYPE_MAPPINGS[doc._bsontype]; - if (!mapper) { - throw new BSONError("Unrecognized or invalid _bsontype: " + doc._bsontype); - } - outDoc = mapper(outDoc); - } - if (bsontype === "Code" && outDoc.scope) { - outDoc = new Code(outDoc.code, serializeValue(outDoc.scope, options)); - } else if (bsontype === "DBRef" && outDoc.oid) { - outDoc = new DBRef(serializeValue(outDoc.collection, options), serializeValue(outDoc.oid, options), serializeValue(outDoc.db, options), serializeValue(outDoc.fields, options)); - } - return outDoc.toExtendedJSON(options); - } else { - throw new BSONError("_bsontype must be a string, but was: " + typeof bsontype); - } - } - function parse(text, options) { - const ejsonOptions = { - useBigInt64: options?.useBigInt64 ?? false, - relaxed: options?.relaxed ?? true, - legacy: options?.legacy ?? false - }; - return JSON.parse(text, (key, value) => { - if (key.indexOf("\0") !== -1) { - throw new BSONError(`BSON Document field names cannot contain null bytes, found: ${JSON.stringify(key)}`); - } - return deserializeValue(value, ejsonOptions); - }); - } - function stringify(value, replacer, space, options) { - if (space != null && typeof space === "object") { - options = space; - space = 0; - } - if (replacer != null && typeof replacer === "object" && !Array.isArray(replacer)) { - options = replacer; - replacer = void 0; - space = 0; - } - const serializeOptions = Object.assign({ relaxed: true, legacy: false }, options, { - seenObjects: [{ propertyName: "(root)", obj: null }] - }); - const doc = serializeValue(value, serializeOptions); - return JSON.stringify(doc, replacer, space); - } - function EJSONserialize(value, options) { - options = options || {}; - return JSON.parse(stringify(value, options)); - } - function EJSONdeserialize(ejson, options) { - options = options || {}; - return parse(JSON.stringify(ejson), options); - } - var EJSON = /* @__PURE__ */ Object.create(null); - EJSON.parse = parse; - EJSON.stringify = stringify; - EJSON.serialize = EJSONserialize; - EJSON.deserialize = EJSONdeserialize; - Object.freeze(EJSON); - var MAXSIZE = 1024 * 1024 * 17; - var buffer = ByteUtils.allocate(MAXSIZE); - function setInternalBufferSize(size) { - if (buffer.length < size) { - buffer = ByteUtils.allocate(size); - } - } - function serialize(object, options = {}) { - const checkKeys = typeof options.checkKeys === "boolean" ? options.checkKeys : false; - const serializeFunctions = typeof options.serializeFunctions === "boolean" ? options.serializeFunctions : false; - const ignoreUndefined = typeof options.ignoreUndefined === "boolean" ? options.ignoreUndefined : true; - const minInternalBufferSize = typeof options.minInternalBufferSize === "number" ? options.minInternalBufferSize : MAXSIZE; - if (buffer.length < minInternalBufferSize) { - buffer = ByteUtils.allocate(minInternalBufferSize); - } - const serializationIndex = serializeInto(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined, null); - const finishedBuffer = ByteUtils.allocate(serializationIndex); - finishedBuffer.set(buffer.subarray(0, serializationIndex), 0); - return finishedBuffer; - } - function serializeWithBufferAndIndex(object, finalBuffer, options = {}) { - const checkKeys = typeof options.checkKeys === "boolean" ? options.checkKeys : false; - const serializeFunctions = typeof options.serializeFunctions === "boolean" ? options.serializeFunctions : false; - const ignoreUndefined = typeof options.ignoreUndefined === "boolean" ? options.ignoreUndefined : true; - const startIndex = typeof options.index === "number" ? options.index : 0; - const serializationIndex = serializeInto(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined, null); - finalBuffer.set(buffer.subarray(0, serializationIndex), startIndex); - return startIndex + serializationIndex - 1; - } - function deserialize2(buffer2, options = {}) { - return internalDeserialize(ByteUtils.toLocalBufferType(buffer2), options); - } - function calculateObjectSize(object, options = {}) { - options = options || {}; - const serializeFunctions = typeof options.serializeFunctions === "boolean" ? options.serializeFunctions : false; - const ignoreUndefined = typeof options.ignoreUndefined === "boolean" ? options.ignoreUndefined : true; - return internalCalculateObjectSize(object, serializeFunctions, ignoreUndefined); - } - function deserializeStream(data, startIndex, numberOfDocuments, documents, docStartIndex, options) { - const internalOptions = Object.assign({ allowObjectSmallerThanBufferSize: true, index: 0 }, options); - const bufferData = ByteUtils.toLocalBufferType(data); - let index = startIndex; - for (let i = 0; i < numberOfDocuments; i++) { - const size = bufferData[index] | bufferData[index + 1] << 8 | bufferData[index + 2] << 16 | bufferData[index + 3] << 24; - internalOptions.index = index; - documents[docStartIndex + i] = internalDeserialize(bufferData, internalOptions); - index = index + size; - } - return index; - } - var bson = /* @__PURE__ */ Object.freeze({ - __proto__: null, - BSONError, - BSONRegExp, - BSONRuntimeError, - BSONSymbol, - BSONType, - BSONValue, - BSONVersionError, - Binary, - Code, - DBRef, - Decimal128, - Double, - EJSON, - Int32, - Long, - MaxKey, - MinKey, - ObjectId, - Timestamp, - UUID, - calculateObjectSize, - deserialize: deserialize2, - deserializeStream, - serialize, - serializeWithBufferAndIndex, - setInternalBufferSize - }); - exports.BSON = bson; - exports.BSONError = BSONError; - exports.BSONRegExp = BSONRegExp; - exports.BSONRuntimeError = BSONRuntimeError; - exports.BSONSymbol = BSONSymbol; - exports.BSONType = BSONType; - exports.BSONValue = BSONValue; - exports.BSONVersionError = BSONVersionError; - exports.Binary = Binary; - exports.Code = Code; - exports.DBRef = DBRef; - exports.Decimal128 = Decimal128; - exports.Double = Double; - exports.EJSON = EJSON; - exports.Int32 = Int32; - exports.Long = Long; - exports.MaxKey = MaxKey; - exports.MinKey = MinKey; - exports.ObjectId = ObjectId; - exports.Timestamp = Timestamp; - exports.UUID = UUID; - exports.calculateObjectSize = calculateObjectSize; - exports.deserialize = deserialize2; - exports.deserializeStream = deserializeStream; - exports.serialize = serialize; - exports.serializeWithBufferAndIndex = serializeWithBufferAndIndex; - exports.setInternalBufferSize = setInternalBufferSize; - } - }); - - // src/jsRunner/bundles/bsonPackage.ts - var bsonPackage_exports = {}; - __export(bsonPackage_exports, { - deserialize: () => deserialize, - toJson: () => toJson - }); - var deserialize = require_bson().deserialize; - var toJson = require_bson().EJSON.deserialize; - return __toCommonJS(bsonPackage_exports); -})(); +"use strict";var bson=(()=>{var Ut=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var tn=Object.getOwnPropertyNames;var en=Object.prototype.hasOwnProperty;var nn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,s)=>(typeof require<"u"?require:t)[s]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var sn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),rn=(e,t)=>{for(var s in t)Ut(e,s,{get:t[s],enumerable:!0})},on=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of tn(t))!en.call(e,r)&&r!==s&&Ut(e,r,{get:()=>t[r],enumerable:!(n=ve(t,r))||n.enumerable});return e};var fn=e=>on(Ut({},"__esModule",{value:!0}),e);var oe=sn(U=>{"use strict";function vt(e){return["[object ArrayBuffer]","[object SharedArrayBuffer]"].includes(Object.prototype.toString.call(e))}function tt(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}function lt(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function te(e){return Object.prototype.toString.call(e)==="[object Map]"}function ct(e){return Object.prototype.toString.call(e)==="[object Date]"}function F(e,t){return JSON.stringify(e,(s,n)=>typeof n=="bigint"?{$numberLong:`${n}`}:te(n)?Object.fromEntries(n):n)}function ln(e){if(e!=null&&typeof e=="object"&&"stylize"in e&&typeof e.stylize=="function")return e.stylize}var et=6,At=2147483647,$t=-2147483648,Oe=Math.pow(2,63)-1,be=-Math.pow(2,63),Ee=Math.pow(2,53),Te=-Math.pow(2,53),bt=1,Ie=2,ee=3,de=4,ne=5,cn=6,Ae=7,$e=8,_e=9,se=10,Et=11,hn=12,re=13,Ue=14,Le=15,at=16,Re=17,ie=18,De=19,je=255,ze=127,an=0,Tt=4,Fe=Object.freeze({double:1,string:2,object:3,array:4,binData:5,undefined:6,objectId:7,bool:8,date:9,null:10,regex:11,dbPointer:12,javascript:13,symbol:14,javascriptWithScope:15,int:16,timestamp:17,long:18,decimal:19,minKey:-1,maxKey:127}),a=class extends Error{get bsonError(){return!0}get name(){return"BSONError"}constructor(t,s){super(t,s)}static isBSONError(t){return t!=null&&typeof t=="object"&&"bsonError"in t&&t.bsonError===!0&&"name"in t&&"message"in t&&"stack"in t}},P=class extends a{get name(){return"BSONVersionError"}constructor(){super(`Unsupported BSON version, bson types must be from bson ${et}.x.x`)}},yt=class extends a{get name(){return"BSONRuntimeError"}constructor(t){super(t)}},gn=128,un=192,yn=224,mn=240,wn=248,pn=192,Sn=224,Nn=240,Bn=128;function Me(e,t,s){let n=0;for(let r=t;r20)return null;if(n===1&&e[t]<128)return String.fromCharCode(e[t]);if(n===2&&e[t]<128&&e[t+1]<128)return String.fromCharCode(e[t])+String.fromCharCode(e[t+1]);if(n===3&&e[t]<128&&e[t+1]<128&&e[t+2]<128)return String.fromCharCode(e[t])+String.fromCharCode(e[t+1])+String.fromCharCode(e[t+2]);let r=[];for(let o=t;o127)return null;r.push(c)}return String.fromCharCode(...r)}function On(e){return Z.fromNumberArray(Array.from({length:e},()=>Math.floor(Math.random()*256)))}var bn=(()=>{try{return nn("crypto").randomBytes}catch{return On}})(),Z={toLocalBufferType(e){if(Buffer.isBuffer(e))return e;if(ArrayBuffer.isView(e))return Buffer.from(e.buffer,e.byteOffset,e.byteLength);let t=e?.[Symbol.toStringTag]??Object.prototype.toString.call(e);if(t==="ArrayBuffer"||t==="SharedArrayBuffer"||t==="[object ArrayBuffer]"||t==="[object SharedArrayBuffer]")return Buffer.from(e);throw new a(`Cannot create Buffer from ${String(e)}`)},allocate(e){return Buffer.alloc(e)},equals(e,t){return Z.toLocalBufferType(e).equals(t)},fromNumberArray(e){return Buffer.from(e)},fromBase64(e){return Buffer.from(e,"base64")},toBase64(e){return Z.toLocalBufferType(e).toString("base64")},fromISO88591(e){return Buffer.from(e,"binary")},toISO88591(e){return Z.toLocalBufferType(e).toString("binary")},fromHex(e){return Buffer.from(e,"hex")},toHex(e){return Z.toLocalBufferType(e).toString("hex")},fromUTF8(e){return Buffer.from(e,"utf8")},toUTF8(e,t,s,n){let r=s-t<=20?xe(e,t,s):null;if(r!=null)return r;let o=Z.toLocalBufferType(e).toString("utf8",t,s);if(n){for(let c=0;cMath.floor(Math.random()*256)))}var In=(()=>{let{crypto:e}=globalThis;if(e!=null&&typeof e.getRandomValues=="function")return t=>e.getRandomValues(gt.allocate(t));if(En()){let{console:t}=globalThis;t?.warn?.("BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.")}return Tn})(),fe=/(\d|[a-f])/i,gt={toLocalBufferType(e){let t=e?.[Symbol.toStringTag]??Object.prototype.toString.call(e);if(t==="Uint8Array")return e;if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength));if(t==="ArrayBuffer"||t==="SharedArrayBuffer"||t==="[object ArrayBuffer]"||t==="[object SharedArrayBuffer]")return new Uint8Array(e);throw new a(`Cannot make a Uint8Array from ${String(e)}`)},allocate(e){if(typeof e!="number")throw new TypeError(`The "size" argument must be of type number. Received ${String(e)}`);return new Uint8Array(e)},equals(e,t){if(e.byteLength!==t.byteLength)return!1;for(let s=0;st.charCodeAt(0))},toBase64(e){return btoa(gt.toISO88591(e))},fromISO88591(e){return Uint8Array.from(e,t=>t.charCodeAt(0)&255)},toISO88591(e){return Array.from(Uint16Array.from(e),t=>String.fromCharCode(t)).join("")},fromHex(e){let t=e.length%2===0?e:e.slice(0,e.length-1),s=[];for(let n=0;nt.toString(16).padStart(2,"0")).join("")},fromUTF8(e){return new TextEncoder().encode(e)},toUTF8(e,t,s,n){let r=s-t<=20?xe(e,t,s):null;if(r!=null)return r;if(n)try{return new TextDecoder("utf8",{fatal:n}).decode(e.slice(t,s))}catch(o){throw new a("Invalid UTF-8 string in BSON document",{cause:o})}return new TextDecoder("utf8",{fatal:n}).decode(e.slice(t,s))},utf8ByteLength(e){return gt.fromUTF8(e).byteLength},encodeUTF8Into(e,t,s){let n=gt.fromUTF8(t);return e.set(n,s),n.byteLength},randomBytes:In},dn=typeof Buffer=="function"&&Buffer.prototype?._isBuffer!==!0,l=dn?Z:gt,ut=class extends DataView{static fromUint8Array(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}},j=class{get[Symbol.for("@@mdb.bson.version")](){return et}[Symbol.for("nodejs.util.inspect.custom")](t,s,n){return this.inspect(t,s,n)}},_=class e extends j{get _bsontype(){return"Binary"}constructor(t,s){if(super(),t!=null&&typeof t=="string"&&!ArrayBuffer.isView(t)&&!vt(t)&&!Array.isArray(t))throw new a("Binary can only be constructed from Uint8Array or number[]");this.sub_type=s??e.BSON_BINARY_SUBTYPE_DEFAULT,t==null?(this.buffer=l.allocate(e.BUFFER_SIZE),this.position=0):(this.buffer=Array.isArray(t)?l.fromNumberArray(t):l.toLocalBufferType(t),this.position=this.buffer.byteLength)}put(t){if(typeof t=="string"&&t.length!==1)throw new a("only accepts single character String");if(typeof t!="number"&&t.length!==1)throw new a("only accepts single character Uint8Array or Array");let s;if(typeof t=="string"?s=t.charCodeAt(0):typeof t=="number"?s=t:s=t[0],s<0||s>255)throw new a("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.byteLength>this.position)this.buffer[this.position++]=s;else{let n=l.allocate(e.BUFFER_SIZE+this.buffer.length);n.set(this.buffer,0),this.buffer=n,this.buffer[this.position++]=s}}write(t,s){if(s=typeof s=="number"?s:this.position,this.buffer.byteLengththis.position?s+t.length:this.position;else if(typeof t=="string")throw new a("input cannot be string")}read(t,s){return s=s&&s>0?s:this.position,this.buffer.slice(t,t+s)}value(){return this.buffer.length===this.position?this.buffer:this.buffer.subarray(0,this.position)}length(){return this.position}toJSON(){return l.toBase64(this.buffer)}toString(t){return t==="hex"?l.toHex(this.buffer):t==="base64"?l.toBase64(this.buffer):t==="utf8"||t==="utf-8"?l.toUTF8(this.buffer,0,this.buffer.byteLength,!1):l.toUTF8(this.buffer,0,this.buffer.byteLength,!1)}toExtendedJSON(t){t=t||{};let s=l.toBase64(this.buffer),n=Number(this.sub_type).toString(16);return t.legacy?{$binary:s,$type:n.length===1?"0"+n:n}:{$binary:{base64:s,subType:n.length===1?"0"+n:n}}}toUUID(){if(this.sub_type===e.SUBTYPE_UUID)return new W(this.buffer.slice(0,this.position));throw new a(`Binary sub_type "${this.sub_type}" is not supported for converting to UUID. Only "${e.SUBTYPE_UUID}" is currently supported.`)}static createFromHexString(t,s){return new e(l.fromHex(t),s)}static createFromBase64(t,s){return new e(l.fromBase64(t),s)}static fromExtendedJSON(t,s){s=s||{};let n,r;if("$binary"in t?s.legacy&&typeof t.$binary=="string"&&"$type"in t?(r=t.$type?parseInt(t.$type,16):0,n=l.fromBase64(t.$binary)):typeof t.$binary!="string"&&(r=t.$binary.subType?parseInt(t.$binary.subType,16):0,n=l.fromBase64(t.$binary.base64)):"$uuid"in t&&(r=4,n=W.bytesFromString(t.$uuid)),!n)throw new a(`Unexpected Binary Extended JSON format ${JSON.stringify(t)}`);return r===Tt?new W(n):new e(n,r)}inspect(t,s,n){n??=F;let r=l.toBase64(this.buffer.subarray(0,this.position)),o=n(r,s),c=n(this.sub_type,s);return`Binary.createFromBase64(${o}, ${c})`}};_.BSON_BINARY_SUBTYPE_DEFAULT=0;_.BUFFER_SIZE=256;_.SUBTYPE_DEFAULT=0;_.SUBTYPE_FUNCTION=1;_.SUBTYPE_BYTE_ARRAY=2;_.SUBTYPE_UUID_OLD=3;_.SUBTYPE_UUID=4;_.SUBTYPE_MD5=5;_.SUBTYPE_ENCRYPTED=6;_.SUBTYPE_COLUMN=7;_.SUBTYPE_USER_DEFINED=128;var Lt=16,An=/^[0-9A-F]{32}$/i,$n=/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i,W=class e extends _{constructor(t){let s;if(t==null)s=e.generate();else if(t instanceof e)s=l.toLocalBufferType(new Uint8Array(t.buffer));else if(ArrayBuffer.isView(t)&&t.byteLength===Lt)s=l.toLocalBufferType(t);else if(typeof t=="string")s=e.bytesFromString(t);else throw new a("Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).");super(s,Tt)}get id(){return this.buffer}set id(t){this.buffer=t}toHexString(t=!0){return t?[l.toHex(this.buffer.subarray(0,4)),l.toHex(this.buffer.subarray(4,6)),l.toHex(this.buffer.subarray(6,8)),l.toHex(this.buffer.subarray(8,10)),l.toHex(this.buffer.subarray(10,16))].join("-"):l.toHex(this.buffer)}toString(t){return t==="hex"?l.toHex(this.id):t==="base64"?l.toBase64(this.id):this.toHexString()}toJSON(){return this.toHexString()}equals(t){if(!t)return!1;if(t instanceof e)return l.equals(t.id,this.id);try{return l.equals(new e(t).id,this.id)}catch{return!1}}toBinary(){return new _(this.id,_.SUBTYPE_UUID)}static generate(){let t=l.randomBytes(Lt);return t[6]=t[6]&15|64,t[8]=t[8]&63|128,t}static isValid(t){return t?typeof t=="string"?e.isValidUUIDString(t):tt(t)?t.byteLength===Lt:t._bsontype==="Binary"&&t.sub_type===this.SUBTYPE_UUID&&t.buffer.byteLength===16:!1}static createFromHexString(t){let s=e.bytesFromString(t);return new e(s)}static createFromBase64(t){return new e(l.fromBase64(t))}static bytesFromString(t){if(!e.isValidUUIDString(t))throw new a("UUID string representation must be 32 hex digits or canonical hyphenated representation");return l.fromHex(t.replace(/-/g,""))}static isValidUUIDString(t){return An.test(t)||$n.test(t)}inspect(t,s,n){return n??=F,`new UUID(${n(this.toHexString(),s)})`}},Y=class e extends j{get _bsontype(){return"Code"}constructor(t,s){super(),this.code=t.toString(),this.scope=s??null}toJSON(){return this.scope!=null?{code:this.code,scope:this.scope}:{code:this.code}}toExtendedJSON(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}}static fromExtendedJSON(t){return new e(t.$code,t.$scope)}inspect(t,s,n){n??=F;let r=n(this.code,s),o=r.includes(` +`);this.scope!=null&&(r+=`,${o?` +`:" "}${n(this.scope,s)}`);let c=o&&this.scope===null;return`new Code(${o?` +`:""}${r}${c?` +`:""})`}};function Je(e){return e!=null&&typeof e=="object"&&"$id"in e&&e.$id!=null&&"$ref"in e&&typeof e.$ref=="string"&&(!("$db"in e)||"$db"in e&&typeof e.$db=="string")}var C=class e extends j{get _bsontype(){return"DBRef"}constructor(t,s,n,r){super();let o=t.split(".");o.length===2&&(n=o.shift(),t=o.shift()),this.collection=t,this.oid=s,this.db=n,this.fields=r||{}}get namespace(){return this.collection}set namespace(t){this.collection=t}toJSON(){let t=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return this.db!=null&&(t.$db=this.db),t}toExtendedJSON(t){t=t||{};let s={$ref:this.collection,$id:this.oid};return t.legacy||(this.db&&(s.$db=this.db),s=Object.assign(s,this.fields)),s}static fromExtendedJSON(t){let s=Object.assign({},t);return delete s.$ref,delete s.$id,delete s.$db,new e(t.$ref,t.$id,t.$db,s)}inspect(t,s,n){n??=F;let r=[n(this.namespace,s),n(this.oid,s),...this.db?[n(this.db,s)]:[],...Object.keys(this.fields).length>0?[n(this.fields,s)]:[]];return r[1]=n===F?`new ObjectId(${r[1]})`:r[1],`new DBRef(${r.join(", ")})`}},M;try{M=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}var le=65536,_n=1<<24,ht=le*le,Ce=ht*ht,ce=Ce/2,he={},ae={},Un=20,Ln=/^(\+?0|(\+|-)?[1-9][0-9]*)$/,y=class e extends j{get _bsontype(){return"Long"}get __isLong__(){return!0}constructor(t=0,s,n){super(),typeof t=="bigint"?Object.assign(this,e.fromBigInt(t,!!s)):typeof t=="string"?Object.assign(this,e.fromString(t,!!s)):(this.low=t|0,this.high=s|0,this.unsigned=!!n)}static fromBits(t,s,n){return new e(t,s,n)}static fromInt(t,s){let n,r,o;return s?(t>>>=0,(o=0<=t&&t<256)&&(r=ae[t],r)?r:(n=e.fromBits(t,(t|0)<0?-1:0,!0),o&&(ae[t]=n),n)):(t|=0,(o=-128<=t&&t<128)&&(r=he[t],r)?r:(n=e.fromBits(t,t<0?-1:0,!1),o&&(he[t]=n),n))}static fromNumber(t,s){if(isNaN(t))return s?e.UZERO:e.ZERO;if(s){if(t<0)return e.UZERO;if(t>=Ce)return e.MAX_UNSIGNED_VALUE}else{if(t<=-ce)return e.MIN_VALUE;if(t+1>=ce)return e.MAX_VALUE}return t<0?e.fromNumber(-t,s).neg():e.fromBits(t%ht|0,t/ht|0,s)}static fromBigInt(t,s){return e.fromString(t.toString(),s)}static fromString(t,s,n){if(t.length===0)throw new a("empty string");if(t==="NaN"||t==="Infinity"||t==="+Infinity"||t==="-Infinity")return e.ZERO;if(typeof s=="number"?(n=s,s=!1):s=!!s,n=n||10,n<2||360)throw new a("interior hyphen");if(r===0)return e.fromString(t.substring(1),s,n).neg();let o=e.fromNumber(Math.pow(n,8)),c=e.ZERO;for(let g=0;g>>16,n=this.high&65535,r=this.low>>>16,o=this.low&65535,c=t.high>>>16,g=t.high&65535,i=t.low>>>16,S=t.low&65535,u=0,f=0,h=0,N=0;return N+=o+S,h+=N>>>16,N&=65535,h+=r+i,f+=h>>>16,h&=65535,f+=n+g,u+=f>>>16,f&=65535,u+=s+c,u&=65535,e.fromBits(h<<16|N,u<<16|f,this.unsigned)}and(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low&t.low,this.high&t.high,this.unsigned)}compare(t){if(e.isLong(t)||(t=e.fromValue(t)),this.eq(t))return 0;let s=this.isNegative(),n=t.isNegative();return s&&!n?-1:!s&&n?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1}comp(t){return this.compare(t)}divide(t){if(e.isLong(t)||(t=e.fromValue(t)),t.isZero())throw new a("division by zero");if(M){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;let o=(this.unsigned?M.div_u:M.div_s)(this.low,this.high,t.low,t.high);return e.fromBits(o,M.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?e.UZERO:e.ZERO;let s,n,r;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return e.UZERO;if(t.gt(this.shru(1)))return e.UONE;r=e.UZERO}else{if(this.eq(e.MIN_VALUE))return t.eq(e.ONE)||t.eq(e.NEG_ONE)?e.MIN_VALUE:t.eq(e.MIN_VALUE)?e.ONE:(s=this.shr(1).div(t).shl(1),s.eq(e.ZERO)?t.isNegative()?e.ONE:e.NEG_ONE:(n=this.sub(t.mul(s)),r=s.add(n.div(t)),r));if(t.eq(e.MIN_VALUE))return this.unsigned?e.UZERO:e.ZERO;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();r=e.ZERO}for(n=this;n.gte(t);){s=Math.max(1,Math.floor(n.toNumber()/t.toNumber()));let o=Math.ceil(Math.log(s)/Math.LN2),c=o<=48?1:Math.pow(2,o-48),g=e.fromNumber(s),i=g.mul(t);for(;i.isNegative()||i.gt(n);)s-=c,g=e.fromNumber(s,this.unsigned),i=g.mul(t);g.isZero()&&(g=e.ONE),r=r.add(g),n=n.sub(i)}return r}div(t){return this.divide(t)}equals(t){return e.isLong(t)||(t=e.fromValue(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low}eq(t){return this.equals(t)}getHighBits(){return this.high}getHighBitsUnsigned(){return this.high>>>0}getLowBits(){return this.low}getLowBitsUnsigned(){return this.low>>>0}getNumBitsAbs(){if(this.isNegative())return this.eq(e.MIN_VALUE)?64:this.neg().getNumBitsAbs();let t=this.high!==0?this.high:this.low,s;for(s=31;s>0&&!(t&1<0}gt(t){return this.greaterThan(t)}greaterThanOrEqual(t){return this.comp(t)>=0}gte(t){return this.greaterThanOrEqual(t)}ge(t){return this.greaterThanOrEqual(t)}isEven(){return(this.low&1)===0}isNegative(){return!this.unsigned&&this.high<0}isOdd(){return(this.low&1)===1}isPositive(){return this.unsigned||this.high>=0}isZero(){return this.high===0&&this.low===0}lessThan(t){return this.comp(t)<0}lt(t){return this.lessThan(t)}lessThanOrEqual(t){return this.comp(t)<=0}lte(t){return this.lessThanOrEqual(t)}modulo(t){if(e.isLong(t)||(t=e.fromValue(t)),M){let s=(this.unsigned?M.rem_u:M.rem_s)(this.low,this.high,t.low,t.high);return e.fromBits(s,M.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))}mod(t){return this.modulo(t)}rem(t){return this.modulo(t)}multiply(t){if(this.isZero())return e.ZERO;if(e.isLong(t)||(t=e.fromValue(t)),M){let p=M.mul(this.low,this.high,t.low,t.high);return e.fromBits(p,M.get_high(),this.unsigned)}if(t.isZero())return e.ZERO;if(this.eq(e.MIN_VALUE))return t.isOdd()?e.MIN_VALUE:e.ZERO;if(t.eq(e.MIN_VALUE))return this.isOdd()?e.MIN_VALUE:e.ZERO;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(e.TWO_PWR_24)&&t.lt(e.TWO_PWR_24))return e.fromNumber(this.toNumber()*t.toNumber(),this.unsigned);let s=this.high>>>16,n=this.high&65535,r=this.low>>>16,o=this.low&65535,c=t.high>>>16,g=t.high&65535,i=t.low>>>16,S=t.low&65535,u=0,f=0,h=0,N=0;return N+=o*S,h+=N>>>16,N&=65535,h+=r*S,f+=h>>>16,h&=65535,h+=o*i,f+=h>>>16,h&=65535,f+=n*S,u+=f>>>16,f&=65535,f+=r*i,u+=f>>>16,f&=65535,f+=o*g,u+=f>>>16,f&=65535,u+=s*S+n*i+r*g+o*c,u&=65535,e.fromBits(h<<16|N,u<<16|f,this.unsigned)}mul(t){return this.multiply(t)}negate(){return!this.unsigned&&this.eq(e.MIN_VALUE)?e.MIN_VALUE:this.not().add(e.ONE)}neg(){return this.negate()}not(){return e.fromBits(~this.low,~this.high,this.unsigned)}notEquals(t){return!this.equals(t)}neq(t){return this.notEquals(t)}ne(t){return this.notEquals(t)}or(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low|t.low,this.high|t.high,this.unsigned)}shiftLeft(t){return e.isLong(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?e.fromBits(this.low<>>32-t,this.unsigned):e.fromBits(0,this.low<>>t|this.high<<32-t,this.high>>t,this.unsigned):e.fromBits(this.high>>t-32,this.high>=0?0:-1,this.unsigned)}shr(t){return this.shiftRight(t)}shiftRightUnsigned(t){if(e.isLong(t)&&(t=t.toInt()),t&=63,t===0)return this;{let s=this.high;if(t<32){let n=this.low;return e.fromBits(n>>>t|s<<32-t,s>>>t,this.unsigned)}else return t===32?e.fromBits(s,0,this.unsigned):e.fromBits(s>>>t-32,0,this.unsigned)}}shr_u(t){return this.shiftRightUnsigned(t)}shru(t){return this.shiftRightUnsigned(t)}subtract(t){return e.isLong(t)||(t=e.fromValue(t)),this.add(t.neg())}sub(t){return this.subtract(t)}toInt(){return this.unsigned?this.low>>>0:this.low}toNumber(){return this.unsigned?(this.high>>>0)*ht+(this.low>>>0):this.high*ht+(this.low>>>0)}toBigInt(){return BigInt(this.toString())}toBytes(t){return t?this.toBytesLE():this.toBytesBE()}toBytesLE(){let t=this.high,s=this.low;return[s&255,s>>>8&255,s>>>16&255,s>>>24,t&255,t>>>8&255,t>>>16&255,t>>>24]}toBytesBE(){let t=this.high,s=this.low;return[t>>>24,t>>>16&255,t>>>8&255,t&255,s>>>24,s>>>16&255,s>>>8&255,s&255]}toSigned(){return this.unsigned?e.fromBits(this.low,this.high,!1):this}toString(t){if(t=t||10,t<2||36>>0).toString(t);if(n=o,n.isZero())return g+r;for(;g.length<6;)g="0"+g;r=""+g+r}}toUnsigned(){return this.unsigned?this:e.fromBits(this.low,this.high,!0)}xor(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low^t.low,this.high^t.high,this.unsigned)}eqz(){return this.isZero()}le(t){return this.lessThanOrEqual(t)}toExtendedJSON(t){return t&&t.relaxed?this.toNumber():{$numberLong:this.toString()}}static fromExtendedJSON(t,s){let{useBigInt64:n=!1,relaxed:r=!0}={...s};if(t.$numberLong.length>Un)throw new a("$numberLong string is too long");if(!Ln.test(t.$numberLong))throw new a(`$numberLong string "${t.$numberLong}" is in an invalid format`);if(n){let c=BigInt(t.$numberLong);return BigInt.asIntN(64,c)}let o=e.fromString(t.$numberLong);return r?o.toNumber():o}inspect(t,s,n){n??=F;let r=n(this.toString(),s),o=this.unsigned?`, ${n(this.unsigned,s)}`:"";return`new Long(${r}${o})`}};y.TWO_PWR_24=y.fromInt(_n);y.MAX_UNSIGNED_VALUE=y.fromBits(-1,-1,!0);y.ZERO=y.fromInt(0);y.UZERO=y.fromInt(0,!0);y.ONE=y.fromInt(1);y.UONE=y.fromInt(1,!0);y.NEG_ONE=y.fromInt(-1);y.MAX_VALUE=y.fromBits(-1,2147483647,!1);y.MIN_VALUE=y.fromBits(0,-2147483648,!1);var Rn=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,Dn=/^(\+|-)?(Infinity|inf)$/i,jn=/^(\+|-)?NaN$/i,ft=6111,wt=-6176,ge=6176,ue=34,Rt=l.fromNumberArray([124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),ye=l.fromNumberArray([248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),me=l.fromNumberArray([120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),zn=/^([-+])?(\d+)?$/,Fn=31,we=16383,Mn=30,xn=31;function pe(e){return!isNaN(parseInt(e,10))}function Jn(e){let t=y.fromNumber(1e9),s=y.fromNumber(0);if(!e.parts[0]&&!e.parts[1]&&!e.parts[2]&&!e.parts[3])return{quotient:e,rem:s};for(let n=0;n<=3;n++)s=s.shiftLeft(32),s=s.add(new y(e.parts[n],0)),e.parts[n]=s.div(t).low,s=s.modulo(t);return{quotient:e,rem:s}}function Cn(e,t){if(!e&&!t)return{high:y.fromNumber(0),low:y.fromNumber(0)};let s=e.shiftRightUnsigned(32),n=new y(e.getLowBits(),0),r=t.shiftRightUnsigned(32),o=new y(t.getLowBits(),0),c=s.multiply(r),g=s.multiply(o),i=n.multiply(r),S=n.multiply(o);return c=c.add(g.shiftRightUnsigned(32)),g=new y(g.getLowBits(),0).add(i).add(S.shiftRightUnsigned(32)),c=c.add(g.shiftRightUnsigned(32)),S=g.shiftLeft(32).add(new y(S.getLowBits(),0)),{high:c,low:S}}function Hn(e,t){let s=e.high>>>0,n=t.high>>>0;if(s>>0,o=t.low>>>0;if(r=7e3)throw new a(""+t+" not a valid Decimal128 string");let R=t.match(Rn),Nt=t.match(Dn),T=t.match(jn);if(!R&&!Nt&&!T||t.length===0)throw new a(""+t+" not a valid Decimal128 string");if(R){let w=R[2],m=R[4],b=R[5],I=R[6];m&&I===void 0&&J(t,"missing exponent power"),m&&w===void 0&&J(t,"missing exponent base"),m===void 0&&(b||I)&&J(t,"missing e before exponent")}if((t[B]==="+"||t[B]==="-")&&(r=!0,n=t[B++]==="-"),!pe(t[B])&&t[B]!=="."){if(t[B]==="i"||t[B]==="I")return new e(n?ye:me);if(t[B]==="N")return new e(Rt)}for(;pe(t[B])||t[B]===".";){if(t[B]==="."){o&&J(t,"contains multiple periods"),o=!0,B=B+1;continue}N$+16384?$=wt:$=$-u;$>ft;){if(E=E+1,E>=ue){if(g===0){$=ft;break}J(t,"overflow")}$=$-1}if(s.allowRounding){for(;$=5&&(b=1,m===5)){b=h[E]%2===1?1:0;for(let I=f+E+2;I=0&&++h[I]>9;I--)if(h[I]=0,I===0)if($>8&255,L[B++]=d.low.low>>16&255,L[B++]=d.low.low>>24&255,L[B++]=d.low.high&255,L[B++]=d.low.high>>8&255,L[B++]=d.low.high>>16&255,L[B++]=d.low.high>>24&255,L[B++]=d.high.low&255,L[B++]=d.high.low>>8&255,L[B++]=d.high.low>>16&255,L[B++]=d.high.low>>24&255,L[B++]=d.high.high&255,L[B++]=d.high.high>>8&255,L[B++]=d.high.high>>16&255,L[B++]=d.high.high>>24&255,new e(L)}toString(){let t,s=0,n=new Array(36);for(let B=0;B>26&Fn;if(D>>3===3){if(D===Mn)return u.join("")+"Infinity";if(D===xn)return"NaN";t=E>>15&we,c=8+(E>>14&1)}else c=E>>14&7,t=E>>17&we;let A=t-ge;if(g.parts[0]=(E&16383)+((c&15)<<14),g.parts[1]=p,g.parts[2]=N,g.parts[3]=h,g.parts[0]===0&&g.parts[1]===0&&g.parts[2]===0&&g.parts[3]===0)o=!0;else for(S=3;S>=0;S--){let B=0,R=Jn(g);if(g=R.quotient,B=R.rem.low,!!B)for(i=8;i>=0;i--)n[S*9+i]=B%10,B=Math.floor(B/10)}if(o)s=1,n[r]=0;else for(s=36;!n[r];)s=s-1,r=r+1;let x=s-1+A;if(x>=34||x<=-7||A>0){if(s>34)return u.push("0"),A>0?u.push(`E+${A}`):A<0&&u.push(`E${A}`),u.join("");u.push(`${n[r++]}`),s=s-1,s&&u.push(".");for(let B=0;B0?u.push(`+${x}`):u.push(`${x}`)}else if(A>=0)for(let B=0;B0)for(let R=0;R>8&255,n[9]=s>>16&255,n}toString(t){return t==="base64"?l.toBase64(this.id):t==="hex"?this.toHexString():this.toHexString()}toJSON(){return this.toHexString()}static is(t){return t!=null&&typeof t=="object"&&"_bsontype"in t&&t._bsontype==="ObjectId"}equals(t){if(t==null)return!1;if(e.is(t))return this[H][11]===t[H][11]&&l.equals(this[H],t[H]);if(typeof t=="string")return t.toLowerCase()===this.toHexString();if(typeof t=="object"&&typeof t.toHexString=="function"){let s=t.toHexString(),n=this.toHexString();return typeof s=="string"&&s.toLowerCase()===n}return!1}getTimestamp(){let t=new Date,s=ut.fromUint8Array(this.id).getUint32(0,!1);return t.setTime(Math.floor(s)*1e3),t}static createPk(){return new e}static createFromTime(t){let s=l.fromNumberArray([0,0,0,0,0,0,0,0,0,0,0,0]);return ut.fromUint8Array(s).setUint32(0,t,!1),new e(s)}static createFromHexString(t){if(t?.length!==24)throw new a("hex string must be 24 characters");return new e(l.fromHex(t))}static createFromBase64(t){if(t?.length!==16)throw new a("base64 string must be 16 characters");return new e(l.fromBase64(t))}static isValid(t){if(t==null)return!1;try{return new e(t),!0}catch{return!1}}toExtendedJSON(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}}static fromExtendedJSON(t){return new e(t.$oid)}inspect(t,s,n){return n??=F,`new ObjectId(${n(this.toHexString(),s)})`}};k.index=Math.floor(Math.random()*16777215);function Bt(e,t,s){let n=5;if(Array.isArray(e))for(let r=0;r=Te&&t<=Ee&&t>=$t&&t<=At?(e!=null?l.utf8ByteLength(e)+1:0)+(4+1):(e!=null?l.utf8ByteLength(e)+1:0)+(8+1);case"undefined":return n||!r?(e!=null?l.utf8ByteLength(e)+1:0)+1:0;case"boolean":return(e!=null?l.utf8ByteLength(e)+1:0)+(1+1);case"object":if(t!=null&&typeof t._bsontype=="string"&&t[Symbol.for("@@mdb.bson.version")]!==et)throw new P;if(t==null||t._bsontype==="MinKey"||t._bsontype==="MaxKey")return(e!=null?l.utf8ByteLength(e)+1:0)+1;if(t._bsontype==="ObjectId")return(e!=null?l.utf8ByteLength(e)+1:0)+(12+1);if(t instanceof Date||ct(t))return(e!=null?l.utf8ByteLength(e)+1:0)+(8+1);if(ArrayBuffer.isView(t)||t instanceof ArrayBuffer||vt(t))return(e!=null?l.utf8ByteLength(e)+1:0)+(1+4+1)+t.byteLength;if(t._bsontype==="Long"||t._bsontype==="Double"||t._bsontype==="Timestamp")return(e!=null?l.utf8ByteLength(e)+1:0)+(8+1);if(t._bsontype==="Decimal128")return(e!=null?l.utf8ByteLength(e)+1:0)+(16+1);if(t._bsontype==="Code")return t.scope!=null&&Object.keys(t.scope).length>0?(e!=null?l.utf8ByteLength(e)+1:0)+1+4+4+l.utf8ByteLength(t.code.toString())+1+Bt(t.scope,s,r):(e!=null?l.utf8ByteLength(e)+1:0)+1+4+l.utf8ByteLength(t.code.toString())+1;if(t._bsontype==="Binary"){let o=t;return o.sub_type===_.SUBTYPE_BYTE_ARRAY?(e!=null?l.utf8ByteLength(e)+1:0)+(o.position+1+4+1+4):(e!=null?l.utf8ByteLength(e)+1:0)+(o.position+1+4+1)}else{if(t._bsontype==="Symbol")return(e!=null?l.utf8ByteLength(e)+1:0)+l.utf8ByteLength(t.value)+4+1+1;if(t._bsontype==="DBRef"){let o=Object.assign({$ref:t.collection,$id:t.oid},t.fields);return t.db!=null&&(o.$db=t.db),(e!=null?l.utf8ByteLength(e)+1:0)+1+Bt(o,s,r)}else return t instanceof RegExp||lt(t)?(e!=null?l.utf8ByteLength(e)+1:0)+1+l.utf8ByteLength(t.source)+1+(t.global?1:0)+(t.ignoreCase?1:0)+(t.multiline?1:0)+1:t._bsontype==="BSONRegExp"?(e!=null?l.utf8ByteLength(e)+1:0)+1+l.utf8ByteLength(t.pattern)+1+l.utf8ByteLength(t.options)+1:(e!=null?l.utf8ByteLength(e)+1:0)+Bt(t,s,r)+1}case"function":if(s)return(e!=null?l.utf8ByteLength(e)+1:0)+1+4+l.utf8ByteLength(t.toString())+1}return 0}function Pn(e){return e.split("").sort().join("")}var q=class e extends j{get _bsontype(){return"BSONRegExp"}constructor(t,s){if(super(),this.pattern=t,this.options=Pn(s??""),this.pattern.indexOf("\0")!==-1)throw new a(`BSON Regex patterns cannot contain null bytes, found: ${JSON.stringify(this.pattern)}`);if(this.options.indexOf("\0")!==-1)throw new a(`BSON Regex options cannot contain null bytes, found: ${JSON.stringify(this.options)}`);for(let n=0;ng);n??=F;let o=r(n(this.pattern),"regexp"),c=r(n(this.options),"regexp");return`new BSONRegExp(${o}, ${c})`}},it=class e extends j{get _bsontype(){return"BSONSymbol"}constructor(t){super(),this.value=t}valueOf(){return this.value}toString(){return this.value}toJSON(){return this.value}toExtendedJSON(){return{$symbol:this.value}}static fromExtendedJSON(t){return new e(t.$symbol)}inspect(t,s,n){return n??=F,`new BSONSymbol(${n(this.value,s)})`}},Wn=y,Q=class e extends Wn{get _bsontype(){return"Timestamp"}constructor(t){if(t==null)super(0,0,!0);else if(typeof t=="bigint")super(t,!0);else if(y.isLong(t))super(t.low,t.high,!0);else if(typeof t=="object"&&"t"in t&&"i"in t){if(typeof t.t!="number"&&(typeof t.t!="object"||t.t._bsontype!=="Int32"))throw new a("Timestamp constructed from { t, i } must provide t as a number");if(typeof t.i!="number"&&(typeof t.i!="object"||t.i._bsontype!=="Int32"))throw new a("Timestamp constructed from { t, i } must provide i as a number");let s=Number(t.t),n=Number(t.i);if(s<0||Number.isNaN(s))throw new a("Timestamp constructed from { t, i } must provide a positive t");if(n<0||Number.isNaN(n))throw new a("Timestamp constructed from { t, i } must provide a positive i");if(s>4294967295)throw new a("Timestamp constructed from { t, i } must provide t equal or less than uint32 max");if(n>4294967295)throw new a("Timestamp constructed from { t, i } must provide i equal or less than uint32 max");super(n,s,!0)}else throw new a("A Timestamp can only be constructed with: bigint, Long, or { t: number; i: number }")}toJSON(){return{$timestamp:this.toString()}}static fromInt(t){return new e(y.fromInt(t,!0))}static fromNumber(t){return new e(y.fromNumber(t,!0))}static fromBits(t,s){return new e({i:t,t:s})}static fromString(t,s){return new e(y.fromString(t,!0,s))}toExtendedJSON(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}}static fromExtendedJSON(t){let s=y.isLong(t.$timestamp.i)?t.$timestamp.i.getLowBitsUnsigned():t.$timestamp.i,n=y.isLong(t.$timestamp.t)?t.$timestamp.t.getLowBitsUnsigned():t.$timestamp.t;return new e({t:n,i:s})}inspect(t,s,n){n??=F;let r=n(this.high>>>0,s),o=n(this.low>>>0,s);return`new Timestamp({ t: ${r}, i: ${o} })`}};Q.MAX_VALUE=y.MAX_UNSIGNED_VALUE;var Yn=y.fromNumber(Ee),kn=y.fromNumber(Te);function He(e,t,s){t=t??{};let n=t&&t.index?t.index:0,r=e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24;if(r<5)throw new a(`bson size must be >= 5, is ${r}`);if(t.allowObjectSmallerThanBufferSize&&e.length= bson size ${r}`);if(!t.allowObjectSmallerThanBufferSize&&e.length!==r)throw new a(`buffer length ${e.length} must === bson size ${r}`);if(r+n>e.byteLength)throw new a(`(bson size ${r} + options.index ${n} must be <= buffer length ${e.byteLength})`);if(e[n+r-1]!==0)throw new a("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");return Ot(e,n,t,s)}var qn=/^\$ref$|^\$id$|^\$db$/;function Ot(e,t,s,n=!1){let r=s.fieldsAsRaw==null?null:s.fieldsAsRaw,o=s.raw==null?!1:s.raw,c=typeof s.bsonRegExp=="boolean"?s.bsonRegExp:!1,g=s.promoteBuffers??!1,i=s.promoteLongs??!0,S=s.promoteValues??!0,u=s.useBigInt64??!1;if(u&&!S)throw new a("Must either request bigint or Long for int64 deserialization");if(u&&!i)throw new a("Must either request bigint or Long for int64 deserialization");let f=s.validation==null?{utf8:!0}:s.validation,h=!0,N,p=new Set,E=f.utf8;if(typeof E=="boolean")N=E;else{h=!1;let T=Object.keys(E).map(function(O){return E[O]});if(T.length===0)throw new a("UTF-8 validation setting cannot be empty");if(typeof T[0]!="boolean")throw new a("Invalid UTF-8 validation option, must specify boolean values");if(N=T[0],!T.every(O=>O===N))throw new a("Invalid UTF-8 validation option - keys must be all true or all false")}if(!h)for(let T of Object.keys(E))p.add(T);let $=t;if(e.length<5)throw new a("corrupt bson message < 5 bytes long");let D=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(D<5||D>e.length)throw new a("corrupt bson message");let A=n?[]:{},x=0,B=!1,R=n?!1:null,Nt=new DataView(e.buffer,e.byteOffset,e.byteLength);for(;!B;){let T=e[t++];if(T===0)break;let O=t;for(;e[O]!==0&&O=e.byteLength)throw new a("Bad BSON Document: illegal CString");let d=n?x++:l.toUTF8(e,t,O,!1),L=!0;h||p.has(d)?L=N:L=!N,R!==!1&&d[0]==="$"&&(R=qn.test(d));let w;if(t=O+1,T===Ie){let m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(m<=0||m>e.length-t||e[t+m-1]!==0)throw new a("bad string length in bson");w=l.toUTF8(e,t,t+m-1,L),t=t+m}else if(T===Ae){let m=l.allocate(12);m.set(e.subarray(t,t+12)),w=new k(m),t=t+12}else if(T===at&&S===!1)w=new X(e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24);else if(T===at)w=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;else if(T===bt&&S===!1)w=new G(Nt.getFloat64(t,!0)),t=t+8;else if(T===bt)w=Nt.getFloat64(t,!0),t=t+8;else if(T===_e){let m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,b=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;w=new Date(new y(m,b).toNumber())}else if(T===$e){if(e[t]!==0&&e[t]!==1)throw new a("illegal boolean type value");w=e[t++]===1}else if(T===ee){let m=t,b=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24;if(b<=0||b>e.length-t)throw new a("bad embedded document length in bson");if(o)w=e.slice(t,t+b);else{let I=s;h||(I={...s,validation:{utf8:L}}),w=Ot(e,m,I,!1)}t=t+b}else if(T===de){let m=t,b=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,I=s,z=t+b;if(r&&r[d]&&(I={...s,raw:!0}),h||(I={...I,validation:{utf8:L}}),w=Ot(e,m,I,!0),t=t+b,e[t-1]!==0)throw new a("invalid array terminator byte");if(t!==z)throw new a("corrupted array bson")}else if(T===cn)w=void 0;else if(T===se)w=null;else if(T===ie){let m=ut.fromUint8Array(e.subarray(t,t+8)),b=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,I=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,z=new y(b,I);u?w=m.getBigInt64(0,!0):i&&S===!0?w=z.lessThanOrEqual(Yn)&&z.greaterThanOrEqual(kn)?z.toNumber():z:w=z}else if(T===De){let m=l.allocate(16);m.set(e.subarray(t,t+16),0),t=t+16,w=new nt(m)}else if(T===ne){let m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,b=m,I=e[t++];if(m<0)throw new a("Negative binary type element size found");if(m>e.byteLength)throw new a("Binary type size larger than document size");if(e.slice!=null){if(I===_.SUBTYPE_BYTE_ARRAY){if(m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,m<0)throw new a("Negative binary type element size found for subtype 0x02");if(m>b-4)throw new a("Binary type with subtype 0x02 contains too long binary size");if(mb-4)throw new a("Binary type with subtype 0x02 contains too long binary size");if(m=e.length)throw new a("Bad BSON Document: illegal CString");let m=l.toUTF8(e,t,O,!1);for(t=O+1,O=t;e[O]!==0&&O=e.length)throw new a("Bad BSON Document: illegal CString");let b=l.toUTF8(e,t,O,!1);t=O+1;let I=new Array(b.length);for(O=0;O=e.length)throw new a("Bad BSON Document: illegal CString");let m=l.toUTF8(e,t,O,!1);for(t=O+1,O=t;e[O]!==0&&O=e.length)throw new a("Bad BSON Document: illegal CString");let b=l.toUTF8(e,t,O,!1);t=O+1,w=new q(m,b)}else if(T===Ue){let m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(m<=0||m>e.length-t||e[t+m-1]!==0)throw new a("bad string length in bson");let b=l.toUTF8(e,t,t+m-1,L);w=S?b:new it(b),t=t+m}else if(T===Re){let m=e[t++]+e[t++]*256+e[t++]*65536+e[t++]*16777216,b=e[t++]+e[t++]*256+e[t++]*65536+e[t++]*(1<<24);w=new Q({i:m,t:b})}else if(T===je)w=new rt;else if(T===ze)w=new st;else if(T===re){let m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(m<=0||m>e.length-t||e[t+m-1]!==0)throw new a("bad string length in bson");let b=l.toUTF8(e,t,t+m-1,L);w=new Y(b),t=t+m}else if(T===Le){let m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(m<4+4+4+1)throw new a("code_w_scope total size shorter minimum expected length");let b=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(b<=0||b>e.length-t||e[t+b-1]!==0)throw new a("bad string length in bson");let I=l.toUTF8(e,t,t+b-1,L);t=t+b;let z=t,_t=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,Qe=Ot(e,z,s,!1);if(t=t+_t,m<4+4+_t+b)throw new a("code_w_scope total size is too short, truncating scope");if(m>4+4+_t+b)throw new a("code_w_scope total size is too long, clips outer document");w=new Y(I,Qe)}else if(T===hn){let m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(m<=0||m>e.length-t||e[t+m-1]!==0)throw new a("bad string length in bson");if(f!=null&&f.utf8&&!Me(e,t,t+m-1))throw new a("Invalid UTF-8 string in BSON document");let b=l.toUTF8(e,t,t+m-1,!1);t=t+m;let I=l.allocate(12);I.set(e.subarray(t,t+12),0);let z=new k(I);t=t+12,w=new C(b,z)}else throw new a(`Detected unknown BSON type ${T.toString(16)} for fieldname "${d}"`);d==="__proto__"?Object.defineProperty(A,d,{value:w,writable:!0,enumerable:!0,configurable:!0}):A[d]=w}if(D!==t-$)throw n?new a("corrupt array bson"):new a("corrupt object bson");if(!R)return A;if(Je(A)){let T=Object.assign({},A);return delete T.$ref,delete T.$id,delete T.$db,new C(A.$ref,A.$id,A.$db,T)}return A}var It=/\x00/,Ne=new Set(["$db","$ref","$id","$clusterTime"]);function Dt(e,t,s,n){e[n++]=Ie;let r=l.encodeUTF8Into(e,t,n);n=n+r+1,e[n-1]=0;let o=l.encodeUTF8Into(e,s,n+4);return e[n+3]=o+1>>24&255,e[n+2]=o+1>>16&255,e[n+1]=o+1>>8&255,e[n]=o+1&255,n=n+4+o,e[n++]=0,n}var mt=new DataView(new ArrayBuffer(8),0,8),Zn=new Uint8Array(mt.buffer,0,4),dt=new Uint8Array(mt.buffer,0,8);function jt(e,t,s,n){let o=!Object.is(s,-0)&&Number.isSafeInteger(s)&&s<=At&&s>=$t?at:bt;o===at?mt.setInt32(0,s,!0):mt.setFloat64(0,s,!0);let c=o===at?Zn:dt;e[n++]=o;let g=l.encodeUTF8Into(e,t,n);return n=n+g,e[n++]=0,e.set(c,n),n+=c.byteLength,n}function zt(e,t,s,n){e[n++]=ie;let r=l.encodeUTF8Into(e,t,n);return n+=r,e[n++]=0,mt.setBigInt64(0,s,!0),e.set(dt,n),n+=dt.byteLength,n}function pt(e,t,s,n){e[n++]=se;let r=l.encodeUTF8Into(e,t,n);return n=n+r,e[n++]=0,n}function Ft(e,t,s,n){e[n++]=$e;let r=l.encodeUTF8Into(e,t,n);return n=n+r,e[n++]=0,e[n++]=s?1:0,n}function Mt(e,t,s,n){e[n++]=_e;let r=l.encodeUTF8Into(e,t,n);n=n+r,e[n++]=0;let o=y.fromNumber(s.getTime()),c=o.getLowBits(),g=o.getHighBits();return e[n++]=c&255,e[n++]=c>>8&255,e[n++]=c>>16&255,e[n++]=c>>24&255,e[n++]=g&255,e[n++]=g>>8&255,e[n++]=g>>16&255,e[n++]=g>>24&255,n}function xt(e,t,s,n){e[n++]=Et;let r=l.encodeUTF8Into(e,t,n);if(n=n+r,e[n++]=0,s.source&&s.source.match(It)!=null)throw new a("value "+s.source+" must not contain null bytes");return n=n+l.encodeUTF8Into(e,s.source,n),e[n++]=0,s.ignoreCase&&(e[n++]=105),s.global&&(e[n++]=115),s.multiline&&(e[n++]=109),e[n++]=0,n}function Jt(e,t,s,n){e[n++]=Et;let r=l.encodeUTF8Into(e,t,n);if(n=n+r,e[n++]=0,s.pattern.match(It)!=null)throw new a("pattern "+s.pattern+" must not contain null bytes");n=n+l.encodeUTF8Into(e,s.pattern,n),e[n++]=0;let o=s.options.split("").sort().join("");return n=n+l.encodeUTF8Into(e,o,n),e[n++]=0,n}function Ct(e,t,s,n){s===null?e[n++]=se:s._bsontype==="MinKey"?e[n++]=je:e[n++]=ze;let r=l.encodeUTF8Into(e,t,n);return n=n+r,e[n++]=0,n}function Ht(e,t,s,n){e[n++]=Ae;let r=l.encodeUTF8Into(e,t,n);n=n+r,e[n++]=0;let o=s.id;if(tt(o))for(let c=0;c<12;c++)e[n++]=o[c];else throw new a("object ["+JSON.stringify(s)+"] is not a valid ObjectId");return n}function Vt(e,t,s,n){e[n++]=ne;let r=l.encodeUTF8Into(e,t,n);n=n+r,e[n++]=0;let o=s.length;return e[n++]=o&255,e[n++]=o>>8&255,e[n++]=o>>16&255,e[n++]=o>>24&255,e[n++]=an,e.set(s,n),n=n+o,n}function Pt(e,t,s,n,r,o,c,g,i){if(i.has(s))throw new a("Cannot convert circular structure to BSON");i.add(s),e[n++]=Array.isArray(s)?de:ee;let S=l.encodeUTF8Into(e,t,n);n=n+S,e[n++]=0;let u=St(e,s,r,n,o+1,c,g,i);return i.delete(s),u}function Wt(e,t,s,n){e[n++]=De;let r=l.encodeUTF8Into(e,t,n);return n=n+r,e[n++]=0,e.set(s.bytes.subarray(0,16),n),n+16}function Yt(e,t,s,n){e[n++]=s._bsontype==="Long"?ie:Re;let r=l.encodeUTF8Into(e,t,n);n=n+r,e[n++]=0;let o=s.getLowBits(),c=s.getHighBits();return e[n++]=o&255,e[n++]=o>>8&255,e[n++]=o>>16&255,e[n++]=o>>24&255,e[n++]=c&255,e[n++]=c>>8&255,e[n++]=c>>16&255,e[n++]=c>>24&255,n}function kt(e,t,s,n){s=s.valueOf(),e[n++]=at;let r=l.encodeUTF8Into(e,t,n);return n=n+r,e[n++]=0,e[n++]=s&255,e[n++]=s>>8&255,e[n++]=s>>16&255,e[n++]=s>>24&255,n}function qt(e,t,s,n){e[n++]=bt;let r=l.encodeUTF8Into(e,t,n);return n=n+r,e[n++]=0,mt.setFloat64(0,s.value,!0),e.set(dt,n),n=n+8,n}function Zt(e,t,s,n){e[n++]=re;let r=l.encodeUTF8Into(e,t,n);n=n+r,e[n++]=0;let o=s.toString(),c=l.encodeUTF8Into(e,o,n+4)+1;return e[n]=c&255,e[n+1]=c>>8&255,e[n+2]=c>>16&255,e[n+3]=c>>24&255,n=n+4+c-1,e[n++]=0,n}function Kt(e,t,s,n,r=!1,o=0,c=!1,g=!0,i){if(s.scope&&typeof s.scope=="object"){e[n++]=Le;let S=l.encodeUTF8Into(e,t,n);n=n+S,e[n++]=0;let u=n,f=s.code;n=n+4;let h=l.encodeUTF8Into(e,f,n+4)+1;e[n]=h&255,e[n+1]=h>>8&255,e[n+2]=h>>16&255,e[n+3]=h>>24&255,e[n+4+h-1]=0,n=n+h+4;let N=St(e,s.scope,r,n,o+1,c,g,i);n=N-1;let p=N-u;e[u++]=p&255,e[u++]=p>>8&255,e[u++]=p>>16&255,e[u++]=p>>24&255,e[n++]=0}else{e[n++]=re;let S=l.encodeUTF8Into(e,t,n);n=n+S,e[n++]=0;let u=s.code.toString(),f=l.encodeUTF8Into(e,u,n+4)+1;e[n]=f&255,e[n+1]=f>>8&255,e[n+2]=f>>16&255,e[n+3]=f>>24&255,n=n+4+f-1,e[n++]=0}return n}function Gt(e,t,s,n){e[n++]=ne;let r=l.encodeUTF8Into(e,t,n);n=n+r,e[n++]=0;let o=s.buffer,c=s.position;return s.sub_type===_.SUBTYPE_BYTE_ARRAY&&(c=c+4),e[n++]=c&255,e[n++]=c>>8&255,e[n++]=c>>16&255,e[n++]=c>>24&255,e[n++]=s.sub_type,s.sub_type===_.SUBTYPE_BYTE_ARRAY&&(c=c-4,e[n++]=c&255,e[n++]=c>>8&255,e[n++]=c>>16&255,e[n++]=c>>24&255),e.set(o,n),n=n+s.position,n}function Xt(e,t,s,n){e[n++]=Ue;let r=l.encodeUTF8Into(e,t,n);n=n+r,e[n++]=0;let o=l.encodeUTF8Into(e,s.value,n+4)+1;return e[n]=o&255,e[n+1]=o>>8&255,e[n+2]=o>>16&255,e[n+3]=o>>24&255,n=n+4+o-1,e[n++]=0,n}function Qt(e,t,s,n,r,o,c){e[n++]=ee;let g=l.encodeUTF8Into(e,t,n);n=n+g,e[n++]=0;let i=n,S={$ref:s.collection||s.namespace,$id:s.oid};s.db!=null&&(S.$db=s.db),S=Object.assign(S,s.fields);let u=St(e,S,!1,n,r+1,o,!0,c),f=u-i;return e[i++]=f&255,e[i++]=f>>8&255,e[i++]=f>>16&255,e[i++]=f>>24&255,u}function St(e,t,s,n,r,o,c,g){if(g==null){if(t==null)return e[0]=5,e[1]=0,e[2]=0,e[3]=0,e[4]=0,5;if(Array.isArray(t))throw new a("serialize does not support an array as the root input");if(typeof t!="object")throw new a("serialize does not support non-object as the root input");if("_bsontype"in t&&typeof t._bsontype=="string")throw new a("BSON types cannot be serialized as a document");if(ct(t)||lt(t)||tt(t)||vt(t))throw new a("date, regexp, typedarray, and arraybuffer cannot be BSON documents");g=new Set}g.add(t);let i=n+4;if(Array.isArray(t))for(let u=0;u>8&255,e[n++]=S>>16&255,e[n++]=S>>24&255,i}function Kn(e){return e!=null&&typeof e=="object"&&"_bsontype"in e&&typeof e._bsontype=="string"}var Gn={$oid:k,$binary:_,$uuid:_,$symbol:it,$numberInt:X,$numberDecimal:nt,$numberDouble:G,$numberLong:y,$minKey:rt,$maxKey:st,$regex:q,$regularExpression:q,$timestamp:Q};function Ve(e,t={}){if(typeof e=="number"){let n=e<=At&&e>=$t,r=e<=Oe&&e>=be;if(t.relaxed||t.legacy)return e;if(Number.isInteger(e)&&!Object.is(e,-0)){if(n)return new X(e);if(r)return t.useBigInt64?BigInt(e):y.fromNumber(e)}return new G(e)}if(e==null||typeof e!="object")return e;if(e.$undefined)return null;let s=Object.keys(e).filter(n=>n.startsWith("$")&&e[n]!=null);for(let n=0;nc.startsWith("$")),o=!0;if(r.forEach(c=>{["$ref","$id","$db"].indexOf(c)===-1&&(o=!1)}),o)return C.fromExtendedJSON(n)}return e}function Xn(e,t){return e.map((s,n)=>{t.seenObjects.push({propertyName:`index ${n}`,obj:null});try{return V(s,t)}finally{t.seenObjects.pop()}})}function Be(e){let t=e.toISOString();return e.getUTCMilliseconds()!==0?t:t.slice(0,-5)+"Z"}function V(e,t){if(e instanceof Map||te(e)){let s=Object.create(null);for(let[n,r]of e){if(typeof n!="string")throw new a("Can only serialize maps with string keys");s[n]=r}return V(s,t)}if((typeof e=="object"||typeof e=="function")&&e!==null){let s=t.seenObjects.findIndex(n=>n.obj===e);if(s!==-1){let n=t.seenObjects.map(u=>u.propertyName),r=n.slice(0,s).map(u=>`${u} -> `).join(""),o=n[s],c=" -> "+n.slice(s+1,n.length-1).map(u=>`${u} -> `).join(""),g=n[n.length-1],i=" ".repeat(r.length+o.length/2),S="-".repeat(c.length+(o.length+g.length)/2-1);throw new a(`Converting circular structure to EJSON: + ${r}${o}${c}${g} + ${i}\\${S}/`)}t.seenObjects[t.seenObjects.length-1].obj=e}if(Array.isArray(e))return Xn(e,t);if(e===void 0)return null;if(e instanceof Date||ct(e)){let s=e.getTime(),n=s>-1&&s<2534023188e5;return t.legacy?t.relaxed&&n?{$date:e.getTime()}:{$date:Be(e)}:t.relaxed&&n?{$date:Be(e)}:{$date:{$numberLong:e.getTime().toString()}}}if(typeof e=="number"&&(!t.relaxed||!isFinite(e))){if(Number.isInteger(e)&&!Object.is(e,-0)){if(e>=$t&&e<=At)return{$numberInt:e.toString()};if(e>=be&&e<=Oe)return{$numberLong:e.toString()}}return{$numberDouble:Object.is(e,-0)?"-0.0":e.toString()}}if(typeof e=="bigint")return t.relaxed?Number(BigInt.asIntN(64,e)):{$numberLong:BigInt.asIntN(64,e).toString()};if(e instanceof RegExp||lt(e)){let s=e.flags;if(s===void 0){let r=e.toString().match(/[gimuy]*$/);r&&(s=r[0])}return new q(e.source,s).toExtendedJSON(t)}return e!=null&&typeof e=="object"?vn(e,t):e}var Qn={Binary:e=>new _(e.value(),e.sub_type),Code:e=>new Y(e.code,e.scope),DBRef:e=>new C(e.collection||e.namespace,e.oid,e.db,e.fields),Decimal128:e=>new nt(e.bytes),Double:e=>new G(e.value),Int32:e=>new X(e.value),Long:e=>y.fromBits(e.low!=null?e.low:e.low_,e.low!=null?e.high:e.high_,e.low!=null?e.unsigned:e.unsigned_),MaxKey:()=>new st,MinKey:()=>new rt,ObjectId:e=>new k(e),BSONRegExp:e=>new q(e.pattern,e.options),BSONSymbol:e=>new it(e.value),Timestamp:e=>Q.fromBits(e.low,e.high)};function vn(e,t){if(e==null||typeof e!="object")throw new a("not an object instance");let s=e._bsontype;if(typeof s>"u"){let n={};for(let r of Object.keys(e)){t.seenObjects.push({propertyName:r,obj:null});try{let o=V(e[r],t);r==="__proto__"?Object.defineProperty(n,r,{value:o,writable:!0,enumerable:!0,configurable:!0}):n[r]=o}finally{t.seenObjects.pop()}}return n}else{if(e!=null&&typeof e=="object"&&typeof e._bsontype=="string"&&e[Symbol.for("@@mdb.bson.version")]!==et)throw new P;if(Kn(e)){let n=e;if(typeof n.toExtendedJSON!="function"){let r=Qn[e._bsontype];if(!r)throw new a("Unrecognized or invalid _bsontype: "+e._bsontype);n=r(n)}return s==="Code"&&n.scope?n=new Y(n.code,V(n.scope,t)):s==="DBRef"&&n.oid&&(n=new C(V(n.collection,t),V(n.oid,t),V(n.db,t),V(n.fields,t))),n.toExtendedJSON(t)}else throw new a("_bsontype must be a string, but was: "+typeof s)}}function Pe(e,t){let s={useBigInt64:t?.useBigInt64??!1,relaxed:t?.relaxed??!0,legacy:t?.legacy??!1};return JSON.parse(e,(n,r)=>{if(n.indexOf("\0")!==-1)throw new a(`BSON Document field names cannot contain null bytes, found: ${JSON.stringify(n)}`);return Ve(r,s)})}function We(e,t,s,n){s!=null&&typeof s=="object"&&(n=s,s=0),t!=null&&typeof t=="object"&&!Array.isArray(t)&&(n=t,t=void 0,s=0);let r=Object.assign({relaxed:!0,legacy:!1},n,{seenObjects:[{propertyName:"(root)",obj:null}]}),o=V(e,r);return JSON.stringify(o,t,s)}function ts(e,t){return t=t||{},JSON.parse(We(e,t))}function es(e,t){return t=t||{},Pe(JSON.stringify(e),t)}var ot=Object.create(null);ot.parse=Pe;ot.stringify=We;ot.serialize=ts;ot.deserialize=es;Object.freeze(ot);var Ye=1024*1024*17,K=l.allocate(Ye);function ke(e){K.lengthss,toJson:()=>rs});var ss=oe().deserialize,rs=oe().EJSON.deserialize;return fn(is);})(); diff --git a/packages/server/src/jsRunner/bundles/index-helpers.ivm.bundle.js b/packages/server/src/jsRunner/bundles/index-helpers.ivm.bundle.js index b2e9f29892..ff8d7265c6 100644 --- a/packages/server/src/jsRunner/bundles/index-helpers.ivm.bundle.js +++ b/packages/server/src/jsRunner/bundles/index-helpers.ivm.bundle.js @@ -1,3560 +1,4 @@ -"use strict"; -var helpers = (() => { - 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 __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { - get: (a, b) => (typeof require !== "undefined" ? require : a)[b] - }) : x)(function(x) { - if (typeof require !== "undefined") - return require.apply(this, arguments); - throw Error('Dynamic require of "' + x + '" is not supported'); - }); - var __esm = (fn, res) => function __init() { - return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; - }; - var __commonJS = (cb, mod) => function __require2() { - return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; - }; - var __export = (target, all) => { - for (var name in all) - __defProp(target, name, { get: all[name], enumerable: true }); - }; - 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 }); - } - return to; - }; - var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( - // If the importer is in node compatibility mode or this is not an ESM - // file that has been converted to a CommonJS file using a Babel- - // compatible transform (i.e. "__esModule" has not been set), then set - // "default" to the CommonJS "module.exports" for node compatibility. - isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, - mod - )); - var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); - - // ../../node_modules/dayjs/dayjs.min.js - var require_dayjs_min = __commonJS({ - "../../node_modules/dayjs/dayjs.min.js"(exports, module) { - !function(t, e) { - "object" == typeof exports && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : (t = "undefined" != typeof globalThis ? globalThis : t || self).dayjs = e(); - }(exports, function() { - "use strict"; - var t = 1e3, e = 6e4, n = 36e5, r = "millisecond", i = "second", s = "minute", u = "hour", a = "day", o = "week", c = "month", f = "quarter", h = "year", d = "date", l = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(t2) { - var e2 = ["th", "st", "nd", "rd"], n2 = t2 % 100; - return "[" + t2 + (e2[(n2 - 20) % 10] || e2[n2] || e2[0]) + "]"; - } }, m = function(t2, e2, n2) { - var r2 = String(t2); - return !r2 || r2.length >= e2 ? t2 : "" + Array(e2 + 1 - r2.length).join(n2) + t2; - }, v = { s: m, z: function(t2) { - var e2 = -t2.utcOffset(), n2 = Math.abs(e2), r2 = Math.floor(n2 / 60), i2 = n2 % 60; - return (e2 <= 0 ? "+" : "-") + m(r2, 2, "0") + ":" + m(i2, 2, "0"); - }, m: function t2(e2, n2) { - if (e2.date() < n2.date()) - return -t2(n2, e2); - var r2 = 12 * (n2.year() - e2.year()) + (n2.month() - e2.month()), i2 = e2.clone().add(r2, c), s2 = n2 - i2 < 0, u2 = e2.clone().add(r2 + (s2 ? -1 : 1), c); - return +(-(r2 + (n2 - i2) / (s2 ? i2 - u2 : u2 - i2)) || 0); - }, a: function(t2) { - return t2 < 0 ? Math.ceil(t2) || 0 : Math.floor(t2); - }, p: function(t2) { - return { M: c, y: h, w: o, d: a, D: d, h: u, m: s, s: i, ms: r, Q: f }[t2] || String(t2 || "").toLowerCase().replace(/s$/, ""); - }, u: function(t2) { - return void 0 === t2; - } }, g = "en", D = {}; - D[g] = M; - var p = "$isDayjsObject", S = function(t2) { - return t2 instanceof _ || !(!t2 || !t2[p]); - }, w = function t2(e2, n2, r2) { - var i2; - if (!e2) - return g; - if ("string" == typeof e2) { - var s2 = e2.toLowerCase(); - D[s2] && (i2 = s2), n2 && (D[s2] = n2, i2 = s2); - var u2 = e2.split("-"); - if (!i2 && u2.length > 1) - return t2(u2[0]); - } else { - var a2 = e2.name; - D[a2] = e2, i2 = a2; - } - return !r2 && i2 && (g = i2), i2 || !r2 && g; - }, O = function(t2, e2) { - if (S(t2)) - return t2.clone(); - var n2 = "object" == typeof e2 ? e2 : {}; - return n2.date = t2, n2.args = arguments, new _(n2); - }, b = v; - b.l = w, b.i = S, b.w = function(t2, e2) { - return O(t2, { locale: e2.$L, utc: e2.$u, x: e2.$x, $offset: e2.$offset }); - }; - var _ = function() { - function M2(t2) { - this.$L = w(t2.locale, null, true), this.parse(t2), this.$x = this.$x || t2.x || {}, this[p] = true; - } - var m2 = M2.prototype; - return m2.parse = function(t2) { - this.$d = function(t3) { - var e2 = t3.date, n2 = t3.utc; - if (null === e2) - return /* @__PURE__ */ new Date(NaN); - if (b.u(e2)) - return /* @__PURE__ */ new Date(); - if (e2 instanceof Date) - return new Date(e2); - if ("string" == typeof e2 && !/Z$/i.test(e2)) { - var r2 = e2.match($); - if (r2) { - var i2 = r2[2] - 1 || 0, s2 = (r2[7] || "0").substring(0, 3); - return n2 ? new Date(Date.UTC(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2)) : new Date(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2); - } - } - return new Date(e2); - }(t2), this.init(); - }, m2.init = function() { - var t2 = this.$d; - this.$y = t2.getFullYear(), this.$M = t2.getMonth(), this.$D = t2.getDate(), this.$W = t2.getDay(), this.$H = t2.getHours(), this.$m = t2.getMinutes(), this.$s = t2.getSeconds(), this.$ms = t2.getMilliseconds(); - }, m2.$utils = function() { - return b; - }, m2.isValid = function() { - return !(this.$d.toString() === l); - }, m2.isSame = function(t2, e2) { - var n2 = O(t2); - return this.startOf(e2) <= n2 && n2 <= this.endOf(e2); - }, m2.isAfter = function(t2, e2) { - return O(t2) < this.startOf(e2); - }, m2.isBefore = function(t2, e2) { - return this.endOf(e2) < O(t2); - }, m2.$g = function(t2, e2, n2) { - return b.u(t2) ? this[e2] : this.set(n2, t2); - }, m2.unix = function() { - return Math.floor(this.valueOf() / 1e3); - }, m2.valueOf = function() { - return this.$d.getTime(); - }, m2.startOf = function(t2, e2) { - var n2 = this, r2 = !!b.u(e2) || e2, f2 = b.p(t2), l2 = function(t3, e3) { - var i2 = b.w(n2.$u ? Date.UTC(n2.$y, e3, t3) : new Date(n2.$y, e3, t3), n2); - return r2 ? i2 : i2.endOf(a); - }, $2 = function(t3, e3) { - return b.w(n2.toDate()[t3].apply(n2.toDate("s"), (r2 ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e3)), n2); - }, y2 = this.$W, M3 = this.$M, m3 = this.$D, v2 = "set" + (this.$u ? "UTC" : ""); - switch (f2) { - case h: - return r2 ? l2(1, 0) : l2(31, 11); - case c: - return r2 ? l2(1, M3) : l2(0, M3 + 1); - case o: - var g2 = this.$locale().weekStart || 0, D2 = (y2 < g2 ? y2 + 7 : y2) - g2; - return l2(r2 ? m3 - D2 : m3 + (6 - D2), M3); - case a: - case d: - return $2(v2 + "Hours", 0); - case u: - return $2(v2 + "Minutes", 1); - case s: - return $2(v2 + "Seconds", 2); - case i: - return $2(v2 + "Milliseconds", 3); - default: - return this.clone(); - } - }, m2.endOf = function(t2) { - return this.startOf(t2, false); - }, m2.$set = function(t2, e2) { - var n2, o2 = b.p(t2), f2 = "set" + (this.$u ? "UTC" : ""), l2 = (n2 = {}, n2[a] = f2 + "Date", n2[d] = f2 + "Date", n2[c] = f2 + "Month", n2[h] = f2 + "FullYear", n2[u] = f2 + "Hours", n2[s] = f2 + "Minutes", n2[i] = f2 + "Seconds", n2[r] = f2 + "Milliseconds", n2)[o2], $2 = o2 === a ? this.$D + (e2 - this.$W) : e2; - if (o2 === c || o2 === h) { - var y2 = this.clone().set(d, 1); - y2.$d[l2]($2), y2.init(), this.$d = y2.set(d, Math.min(this.$D, y2.daysInMonth())).$d; - } else - l2 && this.$d[l2]($2); - return this.init(), this; - }, m2.set = function(t2, e2) { - return this.clone().$set(t2, e2); - }, m2.get = function(t2) { - return this[b.p(t2)](); - }, m2.add = function(r2, f2) { - var d2, l2 = this; - r2 = Number(r2); - var $2 = b.p(f2), y2 = function(t2) { - var e2 = O(l2); - return b.w(e2.date(e2.date() + Math.round(t2 * r2)), l2); - }; - if ($2 === c) - return this.set(c, this.$M + r2); - if ($2 === h) - return this.set(h, this.$y + r2); - if ($2 === a) - return y2(1); - if ($2 === o) - return y2(7); - var M3 = (d2 = {}, d2[s] = e, d2[u] = n, d2[i] = t, d2)[$2] || 1, m3 = this.$d.getTime() + r2 * M3; - return b.w(m3, this); - }, m2.subtract = function(t2, e2) { - return this.add(-1 * t2, e2); - }, m2.format = function(t2) { - var e2 = this, n2 = this.$locale(); - if (!this.isValid()) - return n2.invalidDate || l; - var r2 = t2 || "YYYY-MM-DDTHH:mm:ssZ", i2 = b.z(this), s2 = this.$H, u2 = this.$m, a2 = this.$M, o2 = n2.weekdays, c2 = n2.months, f2 = n2.meridiem, h2 = function(t3, n3, i3, s3) { - return t3 && (t3[n3] || t3(e2, r2)) || i3[n3].slice(0, s3); - }, d2 = function(t3) { - return b.s(s2 % 12 || 12, t3, "0"); - }, $2 = f2 || function(t3, e3, n3) { - var r3 = t3 < 12 ? "AM" : "PM"; - return n3 ? r3.toLowerCase() : r3; - }; - return r2.replace(y, function(t3, r3) { - return r3 || function(t4) { - switch (t4) { - case "YY": - return String(e2.$y).slice(-2); - case "YYYY": - return b.s(e2.$y, 4, "0"); - case "M": - return a2 + 1; - case "MM": - return b.s(a2 + 1, 2, "0"); - case "MMM": - return h2(n2.monthsShort, a2, c2, 3); - case "MMMM": - return h2(c2, a2); - case "D": - return e2.$D; - case "DD": - return b.s(e2.$D, 2, "0"); - case "d": - return String(e2.$W); - case "dd": - return h2(n2.weekdaysMin, e2.$W, o2, 2); - case "ddd": - return h2(n2.weekdaysShort, e2.$W, o2, 3); - case "dddd": - return o2[e2.$W]; - case "H": - return String(s2); - case "HH": - return b.s(s2, 2, "0"); - case "h": - return d2(1); - case "hh": - return d2(2); - case "a": - return $2(s2, u2, true); - case "A": - return $2(s2, u2, false); - case "m": - return String(u2); - case "mm": - return b.s(u2, 2, "0"); - case "s": - return String(e2.$s); - case "ss": - return b.s(e2.$s, 2, "0"); - case "SSS": - return b.s(e2.$ms, 3, "0"); - case "Z": - return i2; - } - return null; - }(t3) || i2.replace(":", ""); - }); - }, m2.utcOffset = function() { - return 15 * -Math.round(this.$d.getTimezoneOffset() / 15); - }, m2.diff = function(r2, d2, l2) { - var $2, y2 = this, M3 = b.p(d2), m3 = O(r2), v2 = (m3.utcOffset() - this.utcOffset()) * e, g2 = this - m3, D2 = function() { - return b.m(y2, m3); - }; - switch (M3) { - case h: - $2 = D2() / 12; - break; - case c: - $2 = D2(); - break; - case f: - $2 = D2() / 3; - break; - case o: - $2 = (g2 - v2) / 6048e5; - break; - case a: - $2 = (g2 - v2) / 864e5; - break; - case u: - $2 = g2 / n; - break; - case s: - $2 = g2 / e; - break; - case i: - $2 = g2 / t; - break; - default: - $2 = g2; - } - return l2 ? $2 : b.a($2); - }, m2.daysInMonth = function() { - return this.endOf(c).$D; - }, m2.$locale = function() { - return D[this.$L]; - }, m2.locale = function(t2, e2) { - if (!t2) - return this.$L; - var n2 = this.clone(), r2 = w(t2, e2, true); - return r2 && (n2.$L = r2), n2; - }, m2.clone = function() { - return b.w(this.$d, this); - }, m2.toDate = function() { - return new Date(this.valueOf()); - }, m2.toJSON = function() { - return this.isValid() ? this.toISOString() : null; - }, m2.toISOString = function() { - return this.$d.toISOString(); - }, m2.toString = function() { - return this.$d.toUTCString(); - }, M2; - }(), k = _.prototype; - return O.prototype = k, [["$ms", r], ["$s", i], ["$m", s], ["$H", u], ["$W", a], ["$M", c], ["$y", h], ["$D", d]].forEach(function(t2) { - k[t2[1]] = function(e2) { - return this.$g(e2, t2[0], t2[1]); - }; - }), O.extend = function(t2, e2) { - return t2.$i || (t2(e2, _, O), t2.$i = true), O; - }, O.locale = w, O.isDayjs = S, O.unix = function(t2) { - return O(1e3 * t2); - }, O.en = D[g], O.Ls = D, O.p = {}, O; - }); - } - }); - - // ../../node_modules/dayjs/plugin/duration.js - var require_duration = __commonJS({ - "../../node_modules/dayjs/plugin/duration.js"(exports, module) { - !function(t, s) { - "object" == typeof exports && "undefined" != typeof module ? module.exports = s() : "function" == typeof define && define.amd ? define(s) : (t = "undefined" != typeof globalThis ? globalThis : t || self).dayjs_plugin_duration = s(); - }(exports, function() { - "use strict"; - var t, s, n = 1e3, i = 6e4, e = 36e5, r = 864e5, o = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, u = 31536e6, d = 2628e6, a = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/, h = { years: u, months: d, days: r, hours: e, minutes: i, seconds: n, milliseconds: 1, weeks: 6048e5 }, c = function(t2) { - return t2 instanceof g; - }, f = function(t2, s2, n2) { - return new g(t2, n2, s2.$l); - }, m = function(t2) { - return s.p(t2) + "s"; - }, l = function(t2) { - return t2 < 0; - }, $ = function(t2) { - return l(t2) ? Math.ceil(t2) : Math.floor(t2); - }, y = function(t2) { - return Math.abs(t2); - }, v = function(t2, s2) { - return t2 ? l(t2) ? { negative: true, format: "" + y(t2) + s2 } : { negative: false, format: "" + t2 + s2 } : { negative: false, format: "" }; - }, g = function() { - function l2(t2, s2, n2) { - var i2 = this; - if (this.$d = {}, this.$l = n2, void 0 === t2 && (this.$ms = 0, this.parseFromMilliseconds()), s2) - return f(t2 * h[m(s2)], this); - if ("number" == typeof t2) - return this.$ms = t2, this.parseFromMilliseconds(), this; - if ("object" == typeof t2) - return Object.keys(t2).forEach(function(s3) { - i2.$d[m(s3)] = t2[s3]; - }), this.calMilliseconds(), this; - if ("string" == typeof t2) { - var e2 = t2.match(a); - if (e2) { - var r2 = e2.slice(2).map(function(t3) { - return null != t3 ? Number(t3) : 0; - }); - return this.$d.years = r2[0], this.$d.months = r2[1], this.$d.weeks = r2[2], this.$d.days = r2[3], this.$d.hours = r2[4], this.$d.minutes = r2[5], this.$d.seconds = r2[6], this.calMilliseconds(), this; - } - } - return this; - } - var y2 = l2.prototype; - return y2.calMilliseconds = function() { - var t2 = this; - this.$ms = Object.keys(this.$d).reduce(function(s2, n2) { - return s2 + (t2.$d[n2] || 0) * h[n2]; - }, 0); - }, y2.parseFromMilliseconds = function() { - var t2 = this.$ms; - this.$d.years = $(t2 / u), t2 %= u, this.$d.months = $(t2 / d), t2 %= d, this.$d.days = $(t2 / r), t2 %= r, this.$d.hours = $(t2 / e), t2 %= e, this.$d.minutes = $(t2 / i), t2 %= i, this.$d.seconds = $(t2 / n), t2 %= n, this.$d.milliseconds = t2; - }, y2.toISOString = function() { - var t2 = v(this.$d.years, "Y"), s2 = v(this.$d.months, "M"), n2 = +this.$d.days || 0; - this.$d.weeks && (n2 += 7 * this.$d.weeks); - var i2 = v(n2, "D"), e2 = v(this.$d.hours, "H"), r2 = v(this.$d.minutes, "M"), o2 = this.$d.seconds || 0; - this.$d.milliseconds && (o2 += this.$d.milliseconds / 1e3, o2 = Math.round(1e3 * o2) / 1e3); - var u2 = v(o2, "S"), d2 = t2.negative || s2.negative || i2.negative || e2.negative || r2.negative || u2.negative, a2 = e2.format || r2.format || u2.format ? "T" : "", h2 = (d2 ? "-" : "") + "P" + t2.format + s2.format + i2.format + a2 + e2.format + r2.format + u2.format; - return "P" === h2 || "-P" === h2 ? "P0D" : h2; - }, y2.toJSON = function() { - return this.toISOString(); - }, y2.format = function(t2) { - var n2 = t2 || "YYYY-MM-DDTHH:mm:ss", i2 = { Y: this.$d.years, YY: s.s(this.$d.years, 2, "0"), YYYY: s.s(this.$d.years, 4, "0"), M: this.$d.months, MM: s.s(this.$d.months, 2, "0"), D: this.$d.days, DD: s.s(this.$d.days, 2, "0"), H: this.$d.hours, HH: s.s(this.$d.hours, 2, "0"), m: this.$d.minutes, mm: s.s(this.$d.minutes, 2, "0"), s: this.$d.seconds, ss: s.s(this.$d.seconds, 2, "0"), SSS: s.s(this.$d.milliseconds, 3, "0") }; - return n2.replace(o, function(t3, s2) { - return s2 || String(i2[t3]); - }); - }, y2.as = function(t2) { - return this.$ms / h[m(t2)]; - }, y2.get = function(t2) { - var s2 = this.$ms, n2 = m(t2); - return "milliseconds" === n2 ? s2 %= 1e3 : s2 = "weeks" === n2 ? $(s2 / h[n2]) : this.$d[n2], s2 || 0; - }, y2.add = function(t2, s2, n2) { - var i2; - return i2 = s2 ? t2 * h[m(s2)] : c(t2) ? t2.$ms : f(t2, this).$ms, f(this.$ms + i2 * (n2 ? -1 : 1), this); - }, y2.subtract = function(t2, s2) { - return this.add(t2, s2, true); - }, y2.locale = function(t2) { - var s2 = this.clone(); - return s2.$l = t2, s2; - }, y2.clone = function() { - return f(this.$ms, this); - }, y2.humanize = function(s2) { - return t().add(this.$ms, "ms").locale(this.$l).fromNow(!s2); - }, y2.valueOf = function() { - return this.asMilliseconds(); - }, y2.milliseconds = function() { - return this.get("milliseconds"); - }, y2.asMilliseconds = function() { - return this.as("milliseconds"); - }, y2.seconds = function() { - return this.get("seconds"); - }, y2.asSeconds = function() { - return this.as("seconds"); - }, y2.minutes = function() { - return this.get("minutes"); - }, y2.asMinutes = function() { - return this.as("minutes"); - }, y2.hours = function() { - return this.get("hours"); - }, y2.asHours = function() { - return this.as("hours"); - }, y2.days = function() { - return this.get("days"); - }, y2.asDays = function() { - return this.as("days"); - }, y2.weeks = function() { - return this.get("weeks"); - }, y2.asWeeks = function() { - return this.as("weeks"); - }, y2.months = function() { - return this.get("months"); - }, y2.asMonths = function() { - return this.as("months"); - }, y2.years = function() { - return this.get("years"); - }, y2.asYears = function() { - return this.as("years"); - }, l2; - }(), p = function(t2, s2, n2) { - return t2.add(s2.years() * n2, "y").add(s2.months() * n2, "M").add(s2.days() * n2, "d").add(s2.hours() * n2, "h").add(s2.minutes() * n2, "m").add(s2.seconds() * n2, "s").add(s2.milliseconds() * n2, "ms"); - }; - return function(n2, i2, e2) { - t = e2, s = e2().$utils(), e2.duration = function(t2, s2) { - var n3 = e2.locale(); - return f(t2, { $l: n3 }, s2); - }, e2.isDuration = c; - var r2 = i2.prototype.add, o2 = i2.prototype.subtract; - i2.prototype.add = function(t2, s2) { - return c(t2) ? p(this, t2, 1) : r2.bind(this)(t2, s2); - }, i2.prototype.subtract = function(t2, s2) { - return c(t2) ? p(this, t2, -1) : o2.bind(this)(t2, s2); - }; - }; - }); - } - }); - - // ../../node_modules/dayjs/plugin/advancedFormat.js - var require_advancedFormat = __commonJS({ - "../../node_modules/dayjs/plugin/advancedFormat.js"(exports, module) { - !function(e, t) { - "object" == typeof exports && "undefined" != typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define(t) : (e = "undefined" != typeof globalThis ? globalThis : e || self).dayjs_plugin_advancedFormat = t(); - }(exports, function() { - "use strict"; - return function(e, t) { - var r = t.prototype, n = r.format; - r.format = function(e2) { - var t2 = this, r2 = this.$locale(); - if (!this.isValid()) - return n.bind(this)(e2); - var s = this.$utils(), a = (e2 || "YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g, function(e3) { - switch (e3) { - case "Q": - return Math.ceil((t2.$M + 1) / 3); - case "Do": - return r2.ordinal(t2.$D); - case "gggg": - return t2.weekYear(); - case "GGGG": - return t2.isoWeekYear(); - case "wo": - return r2.ordinal(t2.week(), "W"); - case "w": - case "ww": - return s.s(t2.week(), "w" === e3 ? 1 : 2, "0"); - case "W": - case "WW": - return s.s(t2.isoWeek(), "W" === e3 ? 1 : 2, "0"); - case "k": - case "kk": - return s.s(String(0 === t2.$H ? 24 : t2.$H), "k" === e3 ? 1 : 2, "0"); - case "X": - return Math.floor(t2.$d.getTime() / 1e3); - case "x": - return t2.$d.getTime(); - case "z": - return "[" + t2.offsetName() + "]"; - case "zzz": - return "[" + t2.offsetName("long") + "]"; - default: - return e3; - } - }); - return n.bind(this)(a); - }; - }; - }); - } - }); - - // ../../node_modules/dayjs/plugin/isoWeek.js - var require_isoWeek = __commonJS({ - "../../node_modules/dayjs/plugin/isoWeek.js"(exports, module) { - !function(e, t) { - "object" == typeof exports && "undefined" != typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define(t) : (e = "undefined" != typeof globalThis ? globalThis : e || self).dayjs_plugin_isoWeek = t(); - }(exports, function() { - "use strict"; - var e = "day"; - return function(t, i, s) { - var a = function(t2) { - return t2.add(4 - t2.isoWeekday(), e); - }, d = i.prototype; - d.isoWeekYear = function() { - return a(this).year(); - }, d.isoWeek = function(t2) { - if (!this.$utils().u(t2)) - return this.add(7 * (t2 - this.isoWeek()), e); - var i2, d2, n2, o, r = a(this), u = (i2 = this.isoWeekYear(), d2 = this.$u, n2 = (d2 ? s.utc : s)().year(i2).startOf("year"), o = 4 - n2.isoWeekday(), n2.isoWeekday() > 4 && (o += 7), n2.add(o, e)); - return r.diff(u, "week") + 1; - }, d.isoWeekday = function(e2) { - return this.$utils().u(e2) ? this.day() || 7 : this.day(this.day() % 7 ? e2 : e2 - 7); - }; - var n = d.startOf; - d.startOf = function(e2, t2) { - var i2 = this.$utils(), s2 = !!i2.u(t2) || t2; - return "isoweek" === i2.p(e2) ? s2 ? this.date(this.date() - (this.isoWeekday() - 1)).startOf("day") : this.date(this.date() - 1 - (this.isoWeekday() - 1) + 7).endOf("day") : n.bind(this)(e2, t2); - }; - }; - }); - } - }); - - // ../../node_modules/dayjs/plugin/weekYear.js - var require_weekYear = __commonJS({ - "../../node_modules/dayjs/plugin/weekYear.js"(exports, module) { - !function(e, t) { - "object" == typeof exports && "undefined" != typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define(t) : (e = "undefined" != typeof globalThis ? globalThis : e || self).dayjs_plugin_weekYear = t(); - }(exports, function() { - "use strict"; - return function(e, t) { - t.prototype.weekYear = function() { - var e2 = this.month(), t2 = this.week(), n = this.year(); - return 1 === t2 && 11 === e2 ? n + 1 : 0 === e2 && t2 >= 52 ? n - 1 : n; - }; - }; - }); - } - }); - - // ../../node_modules/dayjs/plugin/weekOfYear.js - var require_weekOfYear = __commonJS({ - "../../node_modules/dayjs/plugin/weekOfYear.js"(exports, module) { - !function(e, t) { - "object" == typeof exports && "undefined" != typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define(t) : (e = "undefined" != typeof globalThis ? globalThis : e || self).dayjs_plugin_weekOfYear = t(); - }(exports, function() { - "use strict"; - var e = "week", t = "year"; - return function(i, n, r) { - var f = n.prototype; - f.week = function(i2) { - if (void 0 === i2 && (i2 = null), null !== i2) - return this.add(7 * (i2 - this.week()), "day"); - var n2 = this.$locale().yearStart || 1; - if (11 === this.month() && this.date() > 25) { - var f2 = r(this).startOf(t).add(1, t).date(n2), s = r(this).endOf(e); - if (f2.isBefore(s)) - return 1; - } - var a = r(this).startOf(t).date(n2).startOf(e).subtract(1, "millisecond"), o = this.diff(a, e, true); - return o < 0 ? r(this).startOf("week").week() : Math.ceil(o); - }, f.weeks = function(e2) { - return void 0 === e2 && (e2 = null), this.week(e2); - }; - }; - }); - } - }); - - // ../../node_modules/dayjs/plugin/relativeTime.js - var require_relativeTime = __commonJS({ - "../../node_modules/dayjs/plugin/relativeTime.js"(exports, module) { - !function(r, e) { - "object" == typeof exports && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : (r = "undefined" != typeof globalThis ? globalThis : r || self).dayjs_plugin_relativeTime = e(); - }(exports, function() { - "use strict"; - return function(r, e, t) { - r = r || {}; - var n = e.prototype, o = { future: "in %s", past: "%s ago", s: "a few seconds", m: "a minute", mm: "%d minutes", h: "an hour", hh: "%d hours", d: "a day", dd: "%d days", M: "a month", MM: "%d months", y: "a year", yy: "%d years" }; - function i(r2, e2, t2, o2) { - return n.fromToBase(r2, e2, t2, o2); - } - t.en.relativeTime = o, n.fromToBase = function(e2, n2, i2, d2, u) { - for (var f, a, s, l = i2.$locale().relativeTime || o, h = r.thresholds || [{ l: "s", r: 44, d: "second" }, { l: "m", r: 89 }, { l: "mm", r: 44, d: "minute" }, { l: "h", r: 89 }, { l: "hh", r: 21, d: "hour" }, { l: "d", r: 35 }, { l: "dd", r: 25, d: "day" }, { l: "M", r: 45 }, { l: "MM", r: 10, d: "month" }, { l: "y", r: 17 }, { l: "yy", d: "year" }], m = h.length, c = 0; c < m; c += 1) { - var y = h[c]; - y.d && (f = d2 ? t(e2).diff(i2, y.d, true) : i2.diff(e2, y.d, true)); - var p = (r.rounding || Math.round)(Math.abs(f)); - if (s = f > 0, p <= y.r || !y.r) { - p <= 1 && c > 0 && (y = h[c - 1]); - var v = l[y.l]; - u && (p = u("" + p)), a = "string" == typeof v ? v.replace("%d", p) : v(p, n2, y.l, s); - break; - } - } - if (n2) - return a; - var M = s ? l.future : l.past; - return "function" == typeof M ? M(a) : M.replace("%s", a); - }, n.to = function(r2, e2) { - return i(r2, e2, this, true); - }, n.from = function(r2, e2) { - return i(r2, e2, this); - }; - var d = function(r2) { - return r2.$u ? t.utc() : t(); - }; - n.toNow = function(r2) { - return this.to(d(this), r2); - }, n.fromNow = function(r2) { - return this.from(d(this), r2); - }; - }; - }); - } - }); - - // ../../node_modules/dayjs/plugin/utc.js - var require_utc = __commonJS({ - "../../node_modules/dayjs/plugin/utc.js"(exports, module) { - !function(t, i) { - "object" == typeof exports && "undefined" != typeof module ? module.exports = i() : "function" == typeof define && define.amd ? define(i) : (t = "undefined" != typeof globalThis ? globalThis : t || self).dayjs_plugin_utc = i(); - }(exports, function() { - "use strict"; - var t = "minute", i = /[+-]\d\d(?::?\d\d)?/g, e = /([+-]|\d\d)/g; - return function(s, f, n) { - var u = f.prototype; - n.utc = function(t2) { - var i2 = { date: t2, utc: true, args: arguments }; - return new f(i2); - }, u.utc = function(i2) { - var e2 = n(this.toDate(), { locale: this.$L, utc: true }); - return i2 ? e2.add(this.utcOffset(), t) : e2; - }, u.local = function() { - return n(this.toDate(), { locale: this.$L, utc: false }); - }; - var o = u.parse; - u.parse = function(t2) { - t2.utc && (this.$u = true), this.$utils().u(t2.$offset) || (this.$offset = t2.$offset), o.call(this, t2); - }; - var r = u.init; - u.init = function() { - if (this.$u) { - var t2 = this.$d; - this.$y = t2.getUTCFullYear(), this.$M = t2.getUTCMonth(), this.$D = t2.getUTCDate(), this.$W = t2.getUTCDay(), this.$H = t2.getUTCHours(), this.$m = t2.getUTCMinutes(), this.$s = t2.getUTCSeconds(), this.$ms = t2.getUTCMilliseconds(); - } else - r.call(this); - }; - var a = u.utcOffset; - u.utcOffset = function(s2, f2) { - var n2 = this.$utils().u; - if (n2(s2)) - return this.$u ? 0 : n2(this.$offset) ? a.call(this) : this.$offset; - if ("string" == typeof s2 && (s2 = function(t2) { - void 0 === t2 && (t2 = ""); - var s3 = t2.match(i); - if (!s3) - return null; - var f3 = ("" + s3[0]).match(e) || ["-", 0, 0], n3 = f3[0], u3 = 60 * +f3[1] + +f3[2]; - return 0 === u3 ? 0 : "+" === n3 ? u3 : -u3; - }(s2), null === s2)) - return this; - var u2 = Math.abs(s2) <= 16 ? 60 * s2 : s2, o2 = this; - if (f2) - return o2.$offset = u2, o2.$u = 0 === s2, o2; - if (0 !== s2) { - var r2 = this.$u ? this.toDate().getTimezoneOffset() : -1 * this.utcOffset(); - (o2 = this.local().add(u2 + r2, t)).$offset = u2, o2.$x.$localOffset = r2; - } else - o2 = this.utc(); - return o2; - }; - var h = u.format; - u.format = function(t2) { - var i2 = t2 || (this.$u ? "YYYY-MM-DDTHH:mm:ss[Z]" : ""); - return h.call(this, i2); - }, u.valueOf = function() { - var t2 = this.$utils().u(this.$offset) ? 0 : this.$offset + (this.$x.$localOffset || this.$d.getTimezoneOffset()); - return this.$d.valueOf() - 6e4 * t2; - }, u.isUTC = function() { - return !!this.$u; - }, u.toISOString = function() { - return this.toDate().toISOString(); - }, u.toString = function() { - return this.toDate().toUTCString(); - }; - var l = u.toDate; - u.toDate = function(t2) { - return "s" === t2 && this.$offset ? n(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate() : l.call(this); - }; - var c = u.diff; - u.diff = function(t2, i2, e2) { - if (t2 && this.$u === t2.$u) - return c.call(this, t2, i2, e2); - var s2 = this.local(), f2 = n(t2).local(); - return c.call(s2, f2, i2, e2); - }; - }; - }); - } - }); - - // ../../node_modules/dayjs/plugin/timezone.js - var require_timezone = __commonJS({ - "../../node_modules/dayjs/plugin/timezone.js"(exports, module) { - !function(t, e) { - "object" == typeof exports && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : (t = "undefined" != typeof globalThis ? globalThis : t || self).dayjs_plugin_timezone = e(); - }(exports, function() { - "use strict"; - var t = { year: 0, month: 1, day: 2, hour: 3, minute: 4, second: 5 }, e = {}; - return function(n, i, o) { - var r, a = function(t2, n2, i2) { - void 0 === i2 && (i2 = {}); - var o2 = new Date(t2), r2 = function(t3, n3) { - void 0 === n3 && (n3 = {}); - var i3 = n3.timeZoneName || "short", o3 = t3 + "|" + i3, r3 = e[o3]; - return r3 || (r3 = new Intl.DateTimeFormat("en-US", { hour12: false, timeZone: t3, year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit", timeZoneName: i3 }), e[o3] = r3), r3; - }(n2, i2); - return r2.formatToParts(o2); - }, u = function(e2, n2) { - for (var i2 = a(e2, n2), r2 = [], u2 = 0; u2 < i2.length; u2 += 1) { - var f2 = i2[u2], s2 = f2.type, m = f2.value, c = t[s2]; - c >= 0 && (r2[c] = parseInt(m, 10)); - } - var d = r2[3], l = 24 === d ? 0 : d, h = r2[0] + "-" + r2[1] + "-" + r2[2] + " " + l + ":" + r2[4] + ":" + r2[5] + ":000", v = +e2; - return (o.utc(h).valueOf() - (v -= v % 1e3)) / 6e4; - }, f = i.prototype; - f.tz = function(t2, e2) { - void 0 === t2 && (t2 = r); - var n2 = this.utcOffset(), i2 = this.toDate(), a2 = i2.toLocaleString("en-US", { timeZone: t2 }), u2 = Math.round((i2 - new Date(a2)) / 1e3 / 60), f2 = o(a2, { locale: this.$L }).$set("millisecond", this.$ms).utcOffset(15 * -Math.round(i2.getTimezoneOffset() / 15) - u2, true); - if (e2) { - var s2 = f2.utcOffset(); - f2 = f2.add(n2 - s2, "minute"); - } - return f2.$x.$timezone = t2, f2; - }, f.offsetName = function(t2) { - var e2 = this.$x.$timezone || o.tz.guess(), n2 = a(this.valueOf(), e2, { timeZoneName: t2 }).find(function(t3) { - return "timezonename" === t3.type.toLowerCase(); - }); - return n2 && n2.value; - }; - var s = f.startOf; - f.startOf = function(t2, e2) { - if (!this.$x || !this.$x.$timezone) - return s.call(this, t2, e2); - var n2 = o(this.format("YYYY-MM-DD HH:mm:ss:SSS"), { locale: this.$L }); - return s.call(n2, t2, e2).tz(this.$x.$timezone, true); - }, o.tz = function(t2, e2, n2) { - var i2 = n2 && e2, a2 = n2 || e2 || r, f2 = u(+o(), a2); - if ("string" != typeof t2) - return o(t2).tz(a2); - var s2 = function(t3, e3, n3) { - var i3 = t3 - 60 * e3 * 1e3, o2 = u(i3, n3); - if (e3 === o2) - return [i3, e3]; - var r2 = u(i3 -= 60 * (o2 - e3) * 1e3, n3); - return o2 === r2 ? [i3, o2] : [t3 - 60 * Math.min(o2, r2) * 1e3, Math.max(o2, r2)]; - }(o.utc(t2, i2).valueOf(), f2, a2), m = s2[0], c = s2[1], d = o(m).utcOffset(c); - return d.$x.$timezone = a2, d; - }, o.tz.guess = function() { - return Intl.DateTimeFormat().resolvedOptions().timeZone; - }, o.tz.setDefault = function(t2) { - r = t2; - }; - }; - }); - } - }); - - // ../string-templates/src/helpers/date.js - var require_date = __commonJS({ - "../string-templates/src/helpers/date.js"(exports, module) { - var dayjs = require_dayjs_min(); - dayjs.extend(require_duration()); - dayjs.extend(require_advancedFormat()); - dayjs.extend(require_isoWeek()); - dayjs.extend(require_weekYear()); - dayjs.extend(require_weekOfYear()); - dayjs.extend(require_relativeTime()); - dayjs.extend(require_utc()); - dayjs.extend(require_timezone()); - function isOptions(val) { - return typeof val === "object" && typeof val.hash === "object"; - } - function isApp(thisArg) { - return typeof thisArg === "object" && typeof thisArg.options === "object" && typeof thisArg.app === "object"; - } - function getContext(thisArg, locals, options) { - if (isOptions(thisArg)) { - return getContext({}, locals, thisArg); - } - if (isOptions(locals)) { - return getContext(thisArg, options, locals); - } - const appContext = isApp(thisArg) ? thisArg.context : {}; - options = options || {}; - if (!isOptions(options)) { - locals = Object.assign({}, locals, options); - } - if (isOptions(options) && options.hash.root === true) { - locals = Object.assign({}, options.data.root, locals); - } - let context = Object.assign({}, appContext, locals, options.hash); - if (!isApp(thisArg)) { - context = Object.assign({}, thisArg, context); - } - if (isApp(thisArg) && thisArg.view && thisArg.view.data) { - context = Object.assign({}, context, thisArg.view.data); - } - return context; - } - function initialConfig(str, pattern, options) { - if (isOptions(pattern)) { - options = pattern; - pattern = null; - } - if (isOptions(str)) { - options = str; - pattern = null; - str = null; - } - return { str, pattern, options }; - } - function setLocale(str, pattern, options) { - const config = initialConfig(str, pattern, options); - const defaults = { lang: "en", date: new Date(config.str) }; - const opts = getContext(this, defaults, {}); - dayjs.locale(opts.lang || opts.language); - } - module.exports.date = (str, pattern, options) => { - const config = initialConfig(str, pattern, options); - if (config.str == null && config.pattern == null) { - dayjs.locale("en"); - return dayjs().format("MMMM DD, YYYY"); - } - setLocale(config.str, config.pattern, config.options); - let date = dayjs(new Date(config.str)); - if (typeof config.options === "string") { - date = config.options.toLowerCase() === "utc" ? date.utc() : date.tz(config.options); - } else { - date = date.tz(dayjs.tz.guess()); - } - if (config.pattern === "") { - return date.toISOString(); - } - return date.format(config.pattern); - }; - module.exports.duration = (str, pattern, format) => { - const config = initialConfig(str, pattern); - setLocale(config.str, config.pattern); - const duration = dayjs.duration(config.str, config.pattern); - if (format && !isOptions(format)) { - return duration.format(format); - } else { - return duration.humanize(); - } - }; - } - }); - - // ../../node_modules/is-buffer/index.js - var require_is_buffer = __commonJS({ - "../../node_modules/is-buffer/index.js"(exports, module) { - module.exports = function(obj) { - return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer); - }; - function isBuffer(obj) { - return !!obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj); - } - function isSlowBuffer(obj) { - return typeof obj.readFloatLE === "function" && typeof obj.slice === "function" && isBuffer(obj.slice(0, 0)); - } - } - }); - - // ../../node_modules/typeof-article/node_modules/kind-of/index.js - var require_kind_of = __commonJS({ - "../../node_modules/typeof-article/node_modules/kind-of/index.js"(exports, module) { - var isBuffer = require_is_buffer(); - var toString = Object.prototype.toString; - module.exports = function kindOf(val) { - if (typeof val === "undefined") { - return "undefined"; - } - if (val === null) { - return "null"; - } - if (val === true || val === false || val instanceof Boolean) { - return "boolean"; - } - if (typeof val === "string" || val instanceof String) { - return "string"; - } - if (typeof val === "number" || val instanceof Number) { - return "number"; - } - if (typeof val === "function" || val instanceof Function) { - return "function"; - } - if (typeof Array.isArray !== "undefined" && Array.isArray(val)) { - return "array"; - } - if (val instanceof RegExp) { - return "regexp"; - } - if (val instanceof Date) { - return "date"; - } - var type = toString.call(val); - if (type === "[object RegExp]") { - return "regexp"; - } - if (type === "[object Date]") { - return "date"; - } - if (type === "[object Arguments]") { - return "arguments"; - } - if (type === "[object Error]") { - return "error"; - } - if (isBuffer(val)) { - return "buffer"; - } - if (type === "[object Set]") { - return "set"; - } - if (type === "[object WeakSet]") { - return "weakset"; - } - if (type === "[object Map]") { - return "map"; - } - if (type === "[object WeakMap]") { - return "weakmap"; - } - if (type === "[object Symbol]") { - return "symbol"; - } - if (type === "[object Int8Array]") { - return "int8array"; - } - if (type === "[object Uint8Array]") { - return "uint8array"; - } - if (type === "[object Uint8ClampedArray]") { - return "uint8clampedarray"; - } - if (type === "[object Int16Array]") { - return "int16array"; - } - if (type === "[object Uint16Array]") { - return "uint16array"; - } - if (type === "[object Int32Array]") { - return "int32array"; - } - if (type === "[object Uint32Array]") { - return "uint32array"; - } - if (type === "[object Float32Array]") { - return "float32array"; - } - if (type === "[object Float64Array]") { - return "float64array"; - } - return "object"; - }; - } - }); - - // ../../node_modules/typeof-article/index.js - var require_typeof_article = __commonJS({ - "../../node_modules/typeof-article/index.js"(exports, module) { - "use strict"; - var typeOf = require_kind_of(); - var types = { - "arguments": "an arguments object", - "array": "an array", - "boolean": "a boolean", - "buffer": "a buffer", - "date": "a date", - "error": "an error", - "float32array": "a float32array", - "float64array": "a float64array", - "function": "a function", - "int16array": "an int16array", - "int32array": "an int32array", - "int8array": "an int8array", - "map": "a Map", - "null": "null", - "number": "a number", - "object": "an object", - "regexp": "a regular expression", - "set": "a Set", - "string": "a string", - "symbol": "a symbol", - "uint16array": "an uint16array", - "uint32array": "an uint32array", - "uint8array": "an uint8array", - "uint8clampedarray": "an uint8clampedarray", - "undefined": "undefined", - "weakmap": "a WeakMap", - "weakset": "a WeakSet" - }; - function type(val) { - return types[typeOf(val)]; - } - type.types = types; - type.typeOf = typeOf; - module.exports = type; - } - }); - - // ../../node_modules/kind-of/index.js - var require_kind_of2 = __commonJS({ - "../../node_modules/kind-of/index.js"(exports, module) { - var toString = Object.prototype.toString; - module.exports = function kindOf(val) { - if (val === void 0) - return "undefined"; - if (val === null) - return "null"; - var type = typeof val; - if (type === "boolean") - return "boolean"; - if (type === "string") - return "string"; - if (type === "number") - return "number"; - if (type === "symbol") - return "symbol"; - if (type === "function") { - return isGeneratorFn(val) ? "generatorfunction" : "function"; - } - if (isArray(val)) - return "array"; - if (isBuffer(val)) - return "buffer"; - if (isArguments(val)) - return "arguments"; - if (isDate(val)) - return "date"; - if (isError(val)) - return "error"; - if (isRegexp(val)) - return "regexp"; - switch (ctorName(val)) { - case "Symbol": - return "symbol"; - case "Promise": - return "promise"; - case "WeakMap": - return "weakmap"; - case "WeakSet": - return "weakset"; - case "Map": - return "map"; - case "Set": - return "set"; - case "Int8Array": - return "int8array"; - case "Uint8Array": - return "uint8array"; - case "Uint8ClampedArray": - return "uint8clampedarray"; - case "Int16Array": - return "int16array"; - case "Uint16Array": - return "uint16array"; - case "Int32Array": - return "int32array"; - case "Uint32Array": - return "uint32array"; - case "Float32Array": - return "float32array"; - case "Float64Array": - return "float64array"; - } - if (isGeneratorObj(val)) { - return "generator"; - } - type = toString.call(val); - switch (type) { - case "[object Object]": - return "object"; - case "[object Map Iterator]": - return "mapiterator"; - case "[object Set Iterator]": - return "setiterator"; - case "[object String Iterator]": - return "stringiterator"; - case "[object Array Iterator]": - return "arrayiterator"; - } - return type.slice(8, -1).toLowerCase().replace(/\s/g, ""); - }; - function ctorName(val) { - return typeof val.constructor === "function" ? val.constructor.name : null; - } - function isArray(val) { - if (Array.isArray) - return Array.isArray(val); - return val instanceof Array; - } - function isError(val) { - return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number"; - } - function isDate(val) { - if (val instanceof Date) - return true; - return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function"; - } - function isRegexp(val) { - if (val instanceof RegExp) - return true; - return typeof val.flags === "string" && typeof val.ignoreCase === "boolean" && typeof val.multiline === "boolean" && typeof val.global === "boolean"; - } - function isGeneratorFn(name, val) { - return ctorName(name) === "GeneratorFunction"; - } - function isGeneratorObj(val) { - return typeof val.throw === "function" && typeof val.return === "function" && typeof val.next === "function"; - } - function isArguments(val) { - try { - if (typeof val.length === "number" && typeof val.callee === "function") { - return true; - } - } catch (err) { - if (err.message.indexOf("callee") !== -1) { - return true; - } - } - return false; - } - function isBuffer(val) { - if (val.constructor && typeof val.constructor.isBuffer === "function") { - return val.constructor.isBuffer(val); - } - return false; - } - } - }); - - // ../../node_modules/handlebars-utils/index.js - var require_handlebars_utils = __commonJS({ - "../../node_modules/handlebars-utils/index.js"(exports, module) { - "use strict"; - var util = __require("util"); - var type = require_typeof_article(); - var typeOf = require_kind_of2(); - var utils = exports = module.exports; - utils.extend = extend; - utils.indexOf = indexOf; - utils.escapeExpression = escapeExpression; - utils.isEmpty = isEmpty; - utils.createFrame = createFrame; - utils.blockParams = blockParams; - utils.appendContextPath = appendContextPath; - var escape = { - "&": "&", - "<": "<", - ">": ">", - '"': """, - "'": "'", - "`": "`", - "=": "=" - }; - var badChars = /[&<>"'`=]/g; - var possible = /[&<>"'`=]/; - function escapeChar(chr) { - return escape[chr]; - } - function extend(obj) { - for (var i = 1; i < arguments.length; i++) { - for (var key in arguments[i]) { - if (Object.prototype.hasOwnProperty.call(arguments[i], key)) { - obj[key] = arguments[i][key]; - } - } - } - return obj; - } - var toString = Object.prototype.toString; - utils.toString = toString; - var isFunction = function isFunction2(value2) { - return typeof value2 === "function"; - }; - if (isFunction(/x/)) { - utils.isFunction = isFunction = function(value2) { - return typeof value2 === "function" && toString.call(value2) === "[object Function]"; - }; - } - utils.isFunction = isFunction; - var isArray = Array.isArray || function(value2) { - return value2 && typeof value2 === "object" ? toString.call(value2) === "[object Array]" : false; - }; - utils.isArray = isArray; - function indexOf(array, value2) { - for (var i = 0, len = array.length; i < len; i++) { - if (array[i] === value2) { - return i; - } - } - return -1; - } - function escapeExpression(string) { - if (typeof string !== "string") { - if (string && string.toHTML) { - return string.toHTML(); - } else if (string == null) { - return ""; - } else if (!string) { - return string + ""; - } - string = "" + string; - } - if (!possible.test(string)) { - return string; - } - return string.replace(badChars, escapeChar); - } - function createFrame(object) { - var frame = extend({}, object); - frame._parent = object; - return frame; - } - function blockParams(params, ids) { - params.path = ids; - return params; - } - function appendContextPath(contextPath, id) { - return (contextPath ? contextPath + "." : "") + id; - } - utils.expectedType = function(param, expected, actual) { - var exp = type.types[expected]; - var val = util.inspect(actual); - return "expected " + param + " to be " + exp + " but received " + type(actual) + ": " + val; - }; - utils.isBlock = function(options) { - return utils.isOptions(options) && typeof options.fn === "function" && typeof options.inverse === "function"; - }; - utils.fn = function(val, context, options) { - if (utils.isOptions(val)) { - return utils.fn("", val, options); - } - if (utils.isOptions(context)) { - return utils.fn(val, {}, context); - } - return utils.isBlock(options) ? options.fn(context) : val; - }; - utils.inverse = function(val, context, options) { - if (utils.isOptions(val)) { - return utils.identity("", val, options); - } - if (utils.isOptions(context)) { - return utils.inverse(val, {}, context); - } - return utils.isBlock(options) ? options.inverse(context) : val; - }; - utils.value = function(val, context, options) { - if (utils.isOptions(val)) { - return utils.value(null, val, options); - } - if (utils.isOptions(context)) { - return utils.value(val, {}, context); - } - if (utils.isBlock(options)) { - return !!val ? options.fn(context) : options.inverse(context); - } - return val; - }; - utils.isOptions = function(val) { - return utils.isObject(val) && utils.isObject(val.hash); - }; - utils.isUndefined = function(val) { - return val == null || utils.isOptions(val) && val.hash != null; - }; - utils.isApp = function(thisArg) { - return utils.isObject(thisArg) && utils.isObject(thisArg.options) && utils.isObject(thisArg.app); - }; - utils.options = function(thisArg, locals, options) { - if (utils.isOptions(thisArg)) { - return utils.options({}, locals, thisArg); - } - if (utils.isOptions(locals)) { - return utils.options(thisArg, options, locals); - } - options = options || {}; - if (!utils.isOptions(options)) { - locals = Object.assign({}, locals, options); - } - var opts = Object.assign({}, locals, options.hash); - if (utils.isObject(thisArg)) { - opts = Object.assign({}, thisArg.options, opts); - } - if (opts[options.name]) { - opts = Object.assign({}, opts[options.name], opts); - } - return opts; - }; - utils.context = function(thisArg, locals, options) { - if (utils.isOptions(thisArg)) { - return utils.context({}, locals, thisArg); - } - if (utils.isOptions(locals)) { - return utils.context(thisArg, options, locals); - } - var appContext = utils.isApp(thisArg) ? thisArg.context : {}; - options = options || {}; - if (!utils.isOptions(options)) { - locals = Object.assign({}, locals, options); - } - if (utils.isOptions(options) && options.hash.root === true) { - locals = Object.assign({}, options.data.root, locals); - } - var context = Object.assign({}, appContext, locals, options.hash); - if (!utils.isApp(thisArg)) { - context = Object.assign({}, thisArg, context); - } - if (utils.isApp(thisArg) && thisArg.view && thisArg.view.data) { - context = Object.assign({}, context, thisArg.view.data); - } - return context; - }; - utils.isObject = function(val) { - return typeOf(val) === "object"; - }; - function isEmpty(val) { - if (val === 0 || typeof val === "boolean") { - return false; - } - if (val == null) { - return true; - } - if (utils.isObject(val)) { - val = Object.keys(val); - } - if (!val.length) { - return true; - } - return false; - } - utils.result = function(val) { - if (typeof val === "function") { - return val.apply(this, [].slice.call(arguments, 1)); - } - return val; - }; - utils.identity = function(val) { - return val; - }; - utils.isString = function(val) { - return typeof val === "string" && val !== ""; - }; - utils.arrayify = function(val) { - return val != null ? Array.isArray(val) ? val : [val] : []; - }; - utils.tryParse = function(str) { - try { - return JSON.parse(str); - } catch (err) { - } - return {}; - }; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/lib/utils/index.js - var require_utils = __commonJS({ - "../../node_modules/@budibase/handlebars-helpers/lib/utils/index.js"(exports) { - "use strict"; - var util = require_handlebars_utils(); - exports.contains = function(val, obj, start) { - if (val == null || obj == null || isNaN(val.length)) { - return false; - } - return val.indexOf(obj, start) !== -1; - }; - exports.chop = function(str) { - if (typeof str !== "string") - return ""; - var re = /^[-_.\W\s]+|[-_.\W\s]+$/g; - return str.trim().replace(re, ""); - }; - exports.changecase = function(str, fn) { - if (typeof str !== "string") - return ""; - if (str.length === 1) { - return str.toLowerCase(); - } - str = exports.chop(str).toLowerCase(); - if (typeof fn !== "function") { - fn = util.identity; - } - var re = /[-_.\W\s]+(\w|$)/g; - return str.replace(re, function(_, ch) { - return fn(ch); - }); - }; - exports.random = function(min, max) { - return min + Math.floor(Math.random() * (max - min + 1)); - }; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/lib/math.js - var require_math = __commonJS({ - "../../node_modules/@budibase/handlebars-helpers/lib/math.js"(exports, module) { - "use strict"; - var utils = require_utils(); - var helpers2 = module.exports; - helpers2.abs = function(num) { - if (isNaN(num)) { - throw new TypeError("expected a number"); - } - return Math.abs(num); - }; - helpers2.add = function(a, b) { - if (!isNaN(a) && !isNaN(b)) { - return Number(a) + Number(b); - } - if (typeof a === "string" && typeof b === "string") { - return a + b; - } - return ""; - }; - helpers2.avg = function() { - const args = [].concat.apply([], arguments); - args.pop(); - return helpers2.sum(args) / args.length; - }; - helpers2.ceil = function(num) { - if (isNaN(num)) { - throw new TypeError("expected a number"); - } - return Math.ceil(num); - }; - helpers2.divide = function(a, b) { - if (isNaN(a)) { - throw new TypeError("expected the first argument to be a number"); - } - if (isNaN(b)) { - throw new TypeError("expected the second argument to be a number"); - } - return Number(a) / Number(b); - }; - helpers2.floor = function(num) { - if (isNaN(num)) { - throw new TypeError("expected a number"); - } - return Math.floor(num); - }; - helpers2.minus = function(a, b) { - if (isNaN(a)) { - throw new TypeError("expected the first argument to be a number"); - } - if (isNaN(b)) { - throw new TypeError("expected the second argument to be a number"); - } - return Number(a) - Number(b); - }; - helpers2.modulo = function(a, b) { - if (isNaN(a)) { - throw new TypeError("expected the first argument to be a number"); - } - if (isNaN(b)) { - throw new TypeError("expected the second argument to be a number"); - } - return Number(a) % Number(b); - }; - helpers2.multiply = function(a, b) { - if (isNaN(a)) { - throw new TypeError("expected the first argument to be a number"); - } - if (isNaN(b)) { - throw new TypeError("expected the second argument to be a number"); - } - return Number(a) * Number(b); - }; - helpers2.plus = function(a, b) { - if (isNaN(a)) { - throw new TypeError("expected the first argument to be a number"); - } - if (isNaN(b)) { - throw new TypeError("expected the second argument to be a number"); - } - return Number(a) + Number(b); - }; - helpers2.random = function(min, max) { - if (isNaN(min)) { - throw new TypeError("expected minimum to be a number"); - } - if (isNaN(max)) { - throw new TypeError("expected maximum to be a number"); - } - return utils.random(min, max); - }; - helpers2.remainder = function(a, b) { - return a % b; - }; - helpers2.round = function(num) { - if (isNaN(num)) { - throw new TypeError("expected a number"); - } - return Math.round(num); - }; - helpers2.subtract = function(a, b) { - if (isNaN(a)) { - throw new TypeError("expected the first argument to be a number"); - } - if (isNaN(b)) { - throw new TypeError("expected the second argument to be a number"); - } - return Number(a) - Number(b); - }; - helpers2.sum = function() { - var args = [].concat.apply([], arguments); - var len = args.length; - var sum = 0; - while (len--) { - if (!isNaN(args[len])) { - sum += Number(args[len]); - } - } - return sum; - }; - } - }); - - // ../../node_modules/isobject/index.js - var require_isobject = __commonJS({ - "../../node_modules/isobject/index.js"(exports, module) { - "use strict"; - module.exports = function isObject(val) { - return val != null && typeof val === "object" && Array.isArray(val) === false; - }; - } - }); - - // ../../node_modules/get-value/index.js - var require_get_value = __commonJS({ - "../../node_modules/get-value/index.js"(exports, module) { - var isObject = require_isobject(); - module.exports = function(target, path, options) { - if (!isObject(options)) { - options = { default: options }; - } - if (!isValidObject(target)) { - return typeof options.default !== "undefined" ? options.default : target; - } - if (typeof path === "number") { - path = String(path); - } - const isArray = Array.isArray(path); - const isString = typeof path === "string"; - const splitChar = options.separator || "."; - const joinChar = options.joinChar || (typeof splitChar === "string" ? splitChar : "."); - if (!isString && !isArray) { - return target; - } - if (isString && path in target) { - return isValid(path, target, options) ? target[path] : options.default; - } - let segs = isArray ? path : split(path, splitChar, options); - let len = segs.length; - let idx = 0; - do { - let prop = segs[idx]; - if (typeof prop === "number") { - prop = String(prop); - } - while (prop && prop.slice(-1) === "\\") { - prop = join([prop.slice(0, -1), segs[++idx] || ""], joinChar, options); - } - if (prop in target) { - if (!isValid(prop, target, options)) { - return options.default; - } - target = target[prop]; - } else { - let hasProp = false; - let n = idx + 1; - while (n < len) { - prop = join([prop, segs[n++]], joinChar, options); - if (hasProp = prop in target) { - if (!isValid(prop, target, options)) { - return options.default; - } - target = target[prop]; - idx = n - 1; - break; - } - } - if (!hasProp) { - return options.default; - } - } - } while (++idx < len && isValidObject(target)); - if (idx === len) { - return target; - } - return options.default; - }; - function join(segs, joinChar, options) { - if (typeof options.join === "function") { - return options.join(segs); - } - return segs[0] + joinChar + segs[1]; - } - function split(path, splitChar, options) { - if (typeof options.split === "function") { - return options.split(path); - } - return path.split(splitChar); - } - function isValid(key, target, options) { - if (typeof options.isValid === "function") { - return options.isValid(key, target); - } - return true; - } - function isValidObject(val) { - return isObject(val) || Array.isArray(val) || typeof val === "function"; - } - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/lib/utils/createFrame.js - var require_createFrame = __commonJS({ - "../../node_modules/@budibase/handlebars-helpers/lib/utils/createFrame.js"(exports, module) { - "use strict"; - module.exports = function createFrame(data) { - if (typeof data !== "object") { - throw new TypeError("createFrame expects data to be an object"); - } - var frame = Object.assign({}, data); - frame._parent = data; - frame.extend = function(data2) { - Object.assign(this, data2); - }; - if (arguments.length > 1) { - var args = [].slice.call(arguments, 1); - var len = args.length, i = -1; - while (++i < len) { - frame.extend(args[i] || {}); - } - } - return frame; - }; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/lib/array.js - var require_array = __commonJS({ - "../../node_modules/@budibase/handlebars-helpers/lib/array.js"(exports, module) { - "use strict"; - var util = require_handlebars_utils(); - var helpers2 = module.exports; - var getValue = require_get_value(); - var createFrame = require_createFrame(); - helpers2.after = function(array, n) { - if (util.isUndefined(array)) - return ""; - array = util.result(array); - if (Array.isArray(array)) { - return array.slice(n); - } - return ""; - }; - helpers2.arrayify = function(value2) { - if (util.isUndefined(value2)) - return []; - return value2 ? Array.isArray(value2) ? value2 : [value2] : []; - }; - helpers2.before = function(array, n) { - if (util.isUndefined(array)) - return ""; - array = util.result(array); - if (Array.isArray(array)) { - return array.slice(0, n - 1); - } - return ""; - }; - helpers2.eachIndex = function(array, options) { - var result = ""; - if (util.isUndefined(array)) - return ""; - array = util.result(array); - if (Array.isArray(array)) { - for (var i = 0; i < array.length; i++) { - result += options.fn({ item: array[i], index: i }); - } - } - return result; - }; - helpers2.filter = function(array, value2, options) { - if (util.isUndefined(array)) - return options.inverse(this); - array = util.result(array); - if (Array.isArray(array)) { - var content = ""; - var results = []; - var prop = options.hash && (options.hash.property || options.hash.prop); - if (prop) { - results = array.filter(function(val) { - return value2 === getValue(val, prop); - }); - } else { - results = array.filter(function(v) { - return value2 === v; - }); - } - if (results && results.length > 0) { - for (var i = 0; i < results.length; i++) { - content += options.fn(results[i]); - } - return content; - } - } - return options.inverse(this); - }; - helpers2.first = function(array, n) { - if (util.isUndefined(array)) - return []; - array = util.result(array); - if (Array.isArray(array)) { - if (isNaN(n)) { - return array[0]; - } - return array.slice(0, n); - } - return []; - }; - helpers2.forEach = function(array, options) { - if (util.isUndefined(array)) - return options.inverse(this); - array = util.result(array); - if (Array.isArray(array)) { - var data = createFrame(options, options.hash); - var len = array.length; - var buffer = ""; - var i = -1; - while (++i < len) { - var item = array[i]; - data.index = i; - item.index = i + 1; - item.total = len; - item.isFirst = i === 0; - item.isLast = i === len - 1; - buffer += options.fn(item, { data }); - } - return buffer; - } - return options.inverse(this); - }; - helpers2.inArray = function(array, value2, options) { - if (util.isUndefined(array)) - return ""; - array = util.result(array); - if (Array.isArray(array)) { - return util.value(util.indexOf(array, value2) > -1, this, options); - } - return ""; - }; - helpers2.isArray = function(value2) { - return Array.isArray(value2); - }; - helpers2.itemAt = function(array, idx) { - if (util.isUndefined(array)) - return null; - array = util.result(array); - if (Array.isArray(array)) { - idx = !isNaN(idx) ? +idx : 0; - if (idx < 0) { - return array[array.length + idx]; - } - if (idx < array.length) { - return array[idx]; - } - } - return null; - }; - helpers2.join = function(array, separator) { - if (util.isUndefined(array)) - return ""; - if (typeof array === "string") - return array; - array = util.result(array); - if (Array.isArray(array)) { - separator = util.isString(separator) ? separator : ", "; - return array.join(separator); - } - return ""; - }; - helpers2.equalsLength = function(value2, length, options) { - if (util.isOptions(length)) { - options = length; - length = 0; - } - var len = helpers2.length(value2); - return util.value(len === length, this, options); - }; - helpers2.last = function(array, n) { - if (util.isUndefined(array)) - return ""; - if (!Array.isArray(array) && typeof value !== "string") { - return ""; - } - if (isNaN(n)) { - return array[array.length - 1]; - } - return array.slice(-Math.abs(n)); - }; - helpers2.length = function(array) { - if (util.isUndefined(array)) - return 0; - if (util.isObject(array) && !util.isOptions(array)) { - array = Object.keys(array); - } - if (typeof array === "string" && array.startsWith("[") && array.endsWith("]")) { - return array.split(",").length; - } - if (typeof array === "string" || Array.isArray(array)) { - return array.length; - } - return 0; - }; - helpers2.lengthEqual = helpers2.equalsLength; - helpers2.map = function(array, iter) { - if (util.isUndefined(array)) - return ""; - if (!Array.isArray(array)) - return ""; - var len = array.length; - var res = new Array(len); - var i = -1; - if (typeof iter !== "function") { - return array; - } - while (++i < len) { - res[i] = iter(array[i], i, array); - } - return res; - }; - helpers2.pluck = function(array, prop) { - if (util.isUndefined(array)) - return ""; - array = util.result(array); - if (Array.isArray(array)) { - var res = []; - for (var i = 0; i < array.length; i++) { - var val = getValue(array[i], prop); - if (typeof val !== "undefined") { - res.push(val); - } - } - return res; - } - return ""; - }; - helpers2.reverse = function(array) { - if (util.isUndefined(array)) - return ""; - array = util.result(array); - if (Array.isArray(array)) { - array.reverse(); - return array; - } - if (array && typeof array === "string") { - return array.split("").reverse().join(""); - } - return ""; - }; - helpers2.some = function(array, iter, options) { - if (util.isUndefined(array)) - return options.inverse(this); - array = util.result(array); - if (Array.isArray(array)) { - for (var i = 0; i < array.length; i++) { - if (iter(array[i], i, array)) { - return options.fn(this); - } - } - } - return options.inverse(this); - }; - helpers2.sort = function(array, options) { - if (util.isUndefined(array)) - return ""; - array = util.result(array); - if (Array.isArray(array)) { - if (getValue(options, "hash.reverse")) { - return array.sort().reverse(); - } - return array.sort(); - } - return ""; - }; - helpers2.sortBy = function(array, prop, options) { - if (util.isUndefined(array)) - return ""; - array = util.result(array); - if (Array.isArray(array)) { - var args = [].slice.call(arguments); - args.pop(); - if (!util.isString(prop) && typeof prop !== "function") { - return array.sort(); - } - if (typeof prop === "function") { - return array.sort(prop); - } - return array.sort((a, b) => a[prop] > b[prop] ? 1 : -1); - } - return ""; - }; - helpers2.withAfter = function(array, idx, options) { - if (util.isUndefined(array)) - return ""; - array = util.result(array); - if (Array.isArray(array)) { - array = array.slice(idx); - var result = ""; - for (var i = 0; i < array.length; i++) { - result += options.fn(array[i]); - } - return result; - } - return ""; - }; - helpers2.withBefore = function(array, idx, options) { - if (util.isUndefined(array)) - return ""; - array = util.result(array); - if (Array.isArray(array)) { - array = array.slice(0, -idx); - var result = ""; - for (var i = 0; i < array.length; i++) { - result += options.fn(array[i]); - } - return result; - } - return ""; - }; - helpers2.withFirst = function(array, idx, options) { - if (util.isUndefined(array)) - return ""; - array = util.result(array); - if (Array.isArray(array)) { - if (!util.isUndefined(idx)) { - idx = parseFloat(util.result(idx)); - } - if (util.isUndefined(idx)) { - options = idx; - return options.fn(array[0]); - } - array = array.slice(0, idx); - var result = ""; - for (var i = 0; i < array.length; i++) { - result += options.fn(array[i]); - } - return result; - } - return ""; - }; - helpers2.withGroup = function(array, size, options) { - if (util.isUndefined(array)) - return ""; - var result = ""; - array = util.result(array); - if (Array.isArray(array) && array.length > 0) { - var subcontext = []; - for (var i = 0; i < array.length; i++) { - if (i > 0 && i % size === 0) { - result += options.fn(subcontext); - subcontext = []; - } - subcontext.push(array[i]); - } - result += options.fn(subcontext); - } - return result; - }; - helpers2.withLast = function(array, idx, options) { - if (util.isUndefined(array)) - return ""; - array = util.result(array); - if (Array.isArray(array)) { - if (!util.isUndefined(idx)) { - idx = parseFloat(util.result(idx)); - } - if (util.isUndefined(idx)) { - options = idx; - return options.fn(array[array.length - 1]); - } - array = array.slice(-idx); - var len = array.length, i = -1; - var result = ""; - while (++i < len) { - result += options.fn(array[i]); - } - return result; - } - return ""; - }; - helpers2.withSort = function(array, prop, options) { - if (util.isUndefined(array)) - return ""; - array = util.result(array); - if (Array.isArray(array)) { - var result = ""; - if (util.isUndefined(prop)) { - options = prop; - array = array.sort(); - if (getValue(options, "hash.reverse")) { - array = array.reverse(); - } - for (var i = 0, len = array.length; i < len; i++) { - result += options.fn(array[i]); - } - return result; - } - array.sort(function(a, b) { - a = getValue(a, prop); - b = getValue(b, prop); - return a > b ? 1 : a < b ? -1 : 0; - }); - if (getValue(options, "hash.reverse")) { - array = array.reverse(); - } - var alen = array.length, j = -1; - while (++j < alen) { - result += options.fn(array[j]); - } - return result; - } - return ""; - }; - helpers2.unique = function(array, options) { - if (util.isUndefined(array)) - return ""; - array = util.result(array); - if (Array.isArray(array)) { - return array.filter(function(item, index, arr) { - return arr.indexOf(item) === index; - }); - } - return ""; - }; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/lib/number.js - var require_number = __commonJS({ - "../../node_modules/@budibase/handlebars-helpers/lib/number.js"(exports, module) { - "use strict"; - var util = require_handlebars_utils(); - var helpers2 = module.exports; - helpers2.bytes = function(number, precision, options) { - if (number == null) - return "0 B"; - if (isNaN(number)) { - number = number.length; - if (!number) - return "0 B"; - } - if (isNaN(precision)) { - precision = 2; - } - var abbr = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]; - precision = Math.pow(10, precision); - number = Number(number); - var len = abbr.length - 1; - while (len-- >= 0) { - var size = Math.pow(10, len * 3); - if (size <= number + 1) { - number = Math.round(number * precision / size) / precision; - number += " " + abbr[len]; - break; - } - } - return number; - }; - helpers2.addCommas = function(num) { - return num.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,"); - }; - helpers2.phoneNumber = function(num) { - num = num.toString(); - return "(" + num.substr(0, 3) + ") " + num.substr(3, 3) + "-" + num.substr(6, 4); - }; - helpers2.toAbbr = function(number, precision) { - if (isNaN(number)) { - number = 0; - } - if (util.isUndefined(precision)) { - precision = 2; - } - number = Number(number); - precision = Math.pow(10, precision); - var abbr = ["k", "m", "b", "t", "q"]; - var len = abbr.length - 1; - while (len >= 0) { - var size = Math.pow(10, (len + 1) * 3); - if (size <= number + 1) { - number = Math.round(number * precision / size) / precision; - number += abbr[len]; - break; - } - len--; - } - return number; - }; - helpers2.toExponential = function(number, digits) { - if (isNaN(number)) { - number = 0; - } - if (util.isUndefined(digits)) { - digits = 0; - } - return Number(number).toExponential(digits); - }; - helpers2.toFixed = function(number, digits) { - if (isNaN(number)) { - number = 0; - } - if (isNaN(digits)) { - digits = 0; - } - return Number(number).toFixed(digits); - }; - helpers2.toFloat = function(number) { - return parseFloat(number); - }; - helpers2.toInt = function(number) { - return parseInt(number, 10); - }; - helpers2.toPrecision = function(number, precision) { - if (isNaN(number)) { - number = 0; - } - if (isNaN(precision)) { - precision = 1; - } - return Number(number).toPrecision(precision); - }; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/lib/url.js - var require_url = __commonJS({ - "../../node_modules/@budibase/handlebars-helpers/lib/url.js"(exports, module) { - "use strict"; - var url = __require("url"); - var util = require_handlebars_utils(); - var querystring = __require("querystring"); - var helpers2 = module.exports; - helpers2.encodeURI = function(str) { - if (util.isString(str)) { - return encodeURIComponent(str); - } - }; - helpers2.escape = function(str) { - if (util.isString(str)) { - return querystring.escape(str); - } - }; - helpers2.decodeURI = function(str) { - if (util.isString(str)) { - return decodeURIComponent(str); - } - }; - helpers2.urlResolve = function(base, href) { - return url.resolve(base, href); - }; - helpers2.urlParse = function(str) { - return url.parse(str); - }; - helpers2.stripQuerystring = function(str) { - if (util.isString(str)) { - return str.split("?")[0]; - } - }; - helpers2.stripProtocol = function(str) { - if (util.isString(str)) { - var parsed = url.parse(str); - parsed.protocol = ""; - return parsed.format(); - } - }; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/lib/string.js - var require_string = __commonJS({ - "../../node_modules/@budibase/handlebars-helpers/lib/string.js"(exports, module) { - "use strict"; - var util = require_handlebars_utils(); - var utils = require_utils(); - var helpers2 = module.exports; - helpers2.append = function(str, suffix) { - if (typeof str === "string" && typeof suffix === "string") { - return str + suffix; - } - return str; - }; - helpers2.camelcase = function(str) { - if (typeof str !== "string") - return ""; - return utils.changecase(str, function(ch) { - return ch.toUpperCase(); - }); - }; - helpers2.capitalize = function(str) { - if (typeof str !== "string") - return ""; - return str.charAt(0).toUpperCase() + str.slice(1); - }; - helpers2.capitalizeAll = function(str) { - if (typeof str !== "string") - return ""; - if (util.isString(str)) { - return str.replace(/\w\S*/g, function(word) { - return helpers2.capitalize(word); - }); - } - }; - helpers2.center = function(str, spaces) { - if (typeof str !== "string") - return ""; - var space = ""; - var i = 0; - while (i < spaces) { - space += " "; - i++; - } - return space + str + space; - }; - helpers2.chop = function(str) { - if (typeof str !== "string") - return ""; - return utils.chop(str); - }; - helpers2.dashcase = function(str) { - if (typeof str !== "string") - return ""; - return utils.changecase(str, function(ch) { - return "-" + ch; - }); - }; - helpers2.dotcase = function(str) { - if (typeof str !== "string") - return ""; - return utils.changecase(str, function(ch) { - return "." + ch; - }); - }; - helpers2.downcase = function() { - return helpers2.lowercase.apply(this, arguments); - }; - helpers2.ellipsis = function(str, limit) { - if (util.isString(str)) { - if (str.length <= limit) { - return str; - } - return helpers2.truncate(str, limit) + "\u2026"; - } - }; - helpers2.hyphenate = function(str) { - if (typeof str !== "string") - return ""; - return str.split(" ").join("-"); - }; - helpers2.isString = function(value2) { - return typeof value2 === "string"; - }; - helpers2.lowercase = function(str) { - if (util.isObject(str) && str.fn) { - return str.fn(this).toLowerCase(); - } - if (typeof str !== "string") - return ""; - return str.toLowerCase(); - }; - helpers2.occurrences = function(str, substring) { - if (typeof str !== "string") - return ""; - var len = substring.length; - var pos = 0; - var n = 0; - while ((pos = str.indexOf(substring, pos)) > -1) { - n++; - pos += len; - } - return n; - }; - helpers2.pascalcase = function(str) { - if (typeof str !== "string") - return ""; - str = utils.changecase(str, function(ch) { - return ch.toUpperCase(); - }); - return str.charAt(0).toUpperCase() + str.slice(1); - }; - helpers2.pathcase = function(str) { - if (typeof str !== "string") - return ""; - return utils.changecase(str, function(ch) { - return "/" + ch; - }); - }; - helpers2.plusify = function(str, ch) { - if (typeof str !== "string") - return ""; - if (!util.isString(ch)) - ch = " "; - return str.split(ch).join("+"); - }; - helpers2.prepend = function(str, prefix) { - return typeof str === "string" && typeof prefix === "string" ? prefix + str : str; - }; - helpers2.raw = function(options) { - var str = options.fn(); - var opts = util.options(this, options); - if (opts.escape !== false) { - var idx = 0; - while ((idx = str.indexOf("{{", idx)) !== -1) { - if (str[idx - 1] !== "\\") { - str = str.slice(0, idx) + "\\" + str.slice(idx); - } - idx += 3; - } - } - return str; - }; - helpers2.remove = function(str, ch) { - if (typeof str !== "string") - return ""; - if (!util.isString(ch)) - return str; - return str.split(ch).join(""); - }; - helpers2.removeFirst = function(str, ch) { - if (typeof str !== "string") - return ""; - if (!util.isString(ch)) - return str; - return str.replace(ch, ""); - }; - helpers2.replace = function(str, a, b) { - if (typeof str !== "string") - return ""; - if (!util.isString(a)) - return str; - if (!util.isString(b)) - b = ""; - return str.split(a).join(b); - }; - helpers2.replaceFirst = function(str, a, b) { - if (typeof str !== "string") - return ""; - if (!util.isString(a)) - return str; - if (!util.isString(b)) - b = ""; - return str.replace(a, b); - }; - helpers2.reverse = require_array().reverse; - helpers2.sentence = function(str) { - if (typeof str !== "string") - return ""; - return str.replace(/((?:\S[^\.\?\!]*)[\.\?\!]*)/g, function(txt) { - return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); - }); - }; - helpers2.snakecase = function(str) { - if (typeof str !== "string") - return ""; - return utils.changecase(str, function(ch) { - return "_" + ch; - }); - }; - helpers2.split = function(str, ch) { - if (typeof str !== "string") - return ""; - if (!util.isString(ch)) - ch = ","; - return str.split(ch); - }; - helpers2.startsWith = function(prefix, str, options) { - var args = [].slice.call(arguments); - options = args.pop(); - if (util.isString(str) && str.indexOf(prefix) === 0) { - return options.fn(this); - } - if (typeof options.inverse === "function") { - return options.inverse(this); - } - return ""; - }; - helpers2.titleize = function(str) { - if (typeof str !== "string") - return ""; - var title = str.replace(/[- _]+/g, " "); - var words = title.split(" "); - var len = words.length; - var res = []; - var i = 0; - while (len--) { - var word = words[i++]; - res.push(exports.capitalize(word)); - } - return res.join(" "); - }; - helpers2.trim = function(str) { - return typeof str === "string" ? str.trim() : ""; - }; - helpers2.trimLeft = function(str) { - if (util.isString(str)) { - return str.replace(/^\s+/, ""); - } - }; - helpers2.trimRight = function(str) { - if (util.isString(str)) { - return str.replace(/\s+$/, ""); - } - }; - helpers2.truncate = function(str, limit, suffix) { - if (util.isString(str)) { - if (typeof suffix !== "string") { - suffix = ""; - } - if (str.length > limit) { - return str.slice(0, limit - suffix.length) + suffix; - } - return str; - } - }; - helpers2.truncateWords = function(str, count, suffix) { - if (util.isString(str) && !isNaN(count)) { - if (typeof suffix !== "string") { - suffix = "\u2026"; - } - var num = Number(count); - var arr = str.split(/[ \t]/); - if (num >= arr.length) { - return str; - } - arr = arr.slice(0, num); - var val = arr.join(" ").trim(); - return val + suffix; - } - }; - helpers2.upcase = function() { - return helpers2.uppercase.apply(this, arguments); - }; - helpers2.uppercase = function(str) { - if (util.isObject(str) && str.fn) { - return str.fn(this).toUpperCase(); - } - if (typeof str !== "string") - return ""; - return str.toUpperCase(); - }; - } - }); - - // ../../node_modules/has-values/index.js - var require_has_values = __commonJS({ - "../../node_modules/has-values/index.js"(exports, module) { - "use strict"; - var typeOf = require_kind_of2(); - module.exports = function has(val) { - switch (typeOf(val)) { - case "boolean": - case "date": - case "function": - case "null": - case "number": - return true; - case "undefined": - return false; - case "regexp": - return val.source !== "(?:)" && val.source !== ""; - case "buffer": - return val.toString() !== ""; - case "error": - return val.message !== ""; - case "string": - case "arguments": - return val.length !== 0; - case "file": - case "map": - case "set": - return val.size !== 0; - case "array": - case "object": - for (const key of Object.keys(val)) { - if (has(val[key])) { - return true; - } - } - return false; - default: { - return true; - } - } - }; - } - }); - - // ../../node_modules/has-value/index.js - var require_has_value = __commonJS({ - "../../node_modules/has-value/index.js"(exports, module) { - "use strict"; - var get = require_get_value(); - var has = require_has_values(); - module.exports = function(obj, path, options) { - if (isObject(obj) && (typeof path === "string" || Array.isArray(path))) { - return has(get(obj, path, options)); - } - return false; - }; - function isObject(val) { - return val != null && (typeof val === "object" || typeof val === "function" || Array.isArray(val)); - } - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/lib/utils/falsey.js - var require_falsey = __commonJS({ - "../../node_modules/@budibase/handlebars-helpers/lib/utils/falsey.js"(exports, module) { - "use strict"; - function falsey(val, keywords) { - if (!val) - return true; - let words = keywords || falsey.keywords; - if (!Array.isArray(words)) - words = [words]; - const lower = typeof val === "string" ? val.toLowerCase() : null; - for (const word of words) { - if (word === val) { - return true; - } - if (word === lower) { - return true; - } - } - return false; - } - falsey.keywords = [ - "0", - "false", - "nada", - "nil", - "nay", - "nah", - "negative", - "no", - "none", - "nope", - "nul", - "null", - "nix", - "nyet", - "uh-uh", - "veto", - "zero" - ]; - module.exports = falsey; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/lib/utils/odd.js - var require_odd = __commonJS({ - "../../node_modules/@budibase/handlebars-helpers/lib/utils/odd.js"(exports, module) { - "use strict"; - module.exports = function isOdd(value2) { - const n = Math.abs(value2); - if (isNaN(n)) { - throw new TypeError("expected a number"); - } - if (!Number.isInteger(n)) { - throw new Error("expected an integer"); - } - if (!Number.isSafeInteger(n)) { - throw new Error("value exceeds maximum safe integer"); - } - return n % 2 === 1; - }; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/lib/comparison.js - var require_comparison = __commonJS({ - "../../node_modules/@budibase/handlebars-helpers/lib/comparison.js"(exports, module) { - "use strict"; - var has = require_has_value(); - var util = require_handlebars_utils(); - var utils = require_utils(); - var falsey = require_falsey(); - var isOdd = require_odd(); - var helpers2 = module.exports; - helpers2.and = function() { - var len = arguments.length - 1; - var options = arguments[len]; - var val = true; - for (var i = 0; i < len; i++) { - if (!arguments[i]) { - val = false; - break; - } - } - return util.value(val, this, options); - }; - helpers2.compare = function(a, operator, b, options) { - if (arguments.length < 4) { - throw new Error("handlebars Helper {{compare}} expects 4 arguments"); - } - var result; - switch (operator) { - case "==": - result = a == b; - break; - case "===": - result = a === b; - break; - case "!=": - result = a != b; - break; - case "!==": - result = a !== b; - break; - case "<": - result = a < b; - break; - case ">": - result = a > b; - break; - case "<=": - result = a <= b; - break; - case ">=": - result = a >= b; - break; - case "typeof": - result = typeof a === b; - break; - default: { - throw new Error( - "helper {{compare}}: invalid operator: `" + operator + "`" - ); - } - } - return util.value(result, this, options); - }; - helpers2.contains = function(collection, value2, startIndex, options) { - if (typeof startIndex === "object") { - options = startIndex; - startIndex = void 0; - } - var val = utils.contains(collection, value2, startIndex); - return util.value(val, this, options); - }; - helpers2.default = function() { - for (var i = 0; i < arguments.length - 1; i++) { - if (arguments[i] != null) - return arguments[i]; - } - return ""; - }; - helpers2.eq = function(a, b, options) { - if (arguments.length === 2) { - options = b; - b = options.hash.compare; - } - return util.value(a === b, this, options); - }; - helpers2.gt = function(a, b, options) { - if (arguments.length === 2) { - options = b; - b = options.hash.compare; - } - return util.value(a > b, this, options); - }; - helpers2.gte = function(a, b, options) { - if (arguments.length === 2) { - options = b; - b = options.hash.compare; - } - return util.value(a >= b, this, options); - }; - helpers2.has = function(value2, pattern, options) { - if (util.isOptions(value2)) { - options = value2; - pattern = null; - value2 = null; - } - if (util.isOptions(pattern)) { - options = pattern; - pattern = null; - } - if (value2 === null) { - return util.value(false, this, options); - } - if (arguments.length === 2) { - return util.value(has(this, value2), this, options); - } - if ((Array.isArray(value2) || util.isString(value2)) && util.isString(pattern)) { - if (value2.indexOf(pattern) > -1) { - return util.fn(true, this, options); - } - } - if (util.isObject(value2) && util.isString(pattern) && pattern in value2) { - return util.fn(true, this, options); - } - return util.inverse(false, this, options); - }; - helpers2.isFalsey = function(val, options) { - return util.value(falsey(val), this, options); - }; - helpers2.isTruthy = function(val, options) { - return util.value(!falsey(val), this, options); - }; - helpers2.ifEven = function(num, options) { - return util.value(!isOdd(num), this, options); - }; - helpers2.ifNth = function(a, b, options) { - var isNth = !isNaN(a) && !isNaN(b) && b % a === 0; - return util.value(isNth, this, options); - }; - helpers2.ifOdd = function(val, options) { - return util.value(isOdd(val), this, options); - }; - helpers2.is = function(a, b, options) { - if (arguments.length === 2) { - options = b; - b = options.hash.compare; - } - return util.value(a == b, this, options); - }; - helpers2.isnt = function(a, b, options) { - if (arguments.length === 2) { - options = b; - b = options.hash.compare; - } - return util.value(a != b, this, options); - }; - helpers2.lt = function(a, b, options) { - if (arguments.length === 2) { - options = b; - b = options.hash.compare; - } - return util.value(a < b, this, options); - }; - helpers2.lte = function(a, b, options) { - if (arguments.length === 2) { - options = b; - b = options.hash.compare; - } - return util.value(a <= b, this, options); - }; - helpers2.neither = function(a, b, options) { - return util.value(!a && !b, this, options); - }; - helpers2.not = function(val, options) { - return util.value(!val, this, options); - }; - helpers2.or = function() { - var len = arguments.length - 1; - var options = arguments[len]; - var val = false; - for (var i = 0; i < len; i++) { - if (arguments[i]) { - val = true; - break; - } - } - return util.value(val, this, options); - }; - helpers2.unlessEq = function(a, b, options) { - if (util.isOptions(b)) { - options = b; - b = options.hash.compare; - } - return util.value(a !== b, this, options); - }; - helpers2.unlessGt = function(a, b, options) { - if (util.isOptions(b)) { - options = b; - b = options.hash.compare; - } - return util.value(a <= b, this, options); - }; - helpers2.unlessLt = function(a, b, options) { - if (util.isOptions(b)) { - options = b; - b = options.hash.compare; - } - return util.value(a >= b, this, options); - }; - helpers2.unlessGteq = function(a, b, options) { - if (util.isOptions(b)) { - options = b; - b = options.hash.compare; - } - return util.value(a < b, this, options); - }; - helpers2.unlessLteq = function(a, b, options) { - if (util.isOptions(b)) { - options = b; - b = options.hash.compare; - } - return util.value(a > b, this, options); - }; - } - }); - - // ../../node_modules/is-number/node_modules/kind-of/index.js - var require_kind_of3 = __commonJS({ - "../../node_modules/is-number/node_modules/kind-of/index.js"(exports, module) { - var isBuffer = require_is_buffer(); - var toString = Object.prototype.toString; - module.exports = function kindOf(val) { - if (typeof val === "undefined") { - return "undefined"; - } - if (val === null) { - return "null"; - } - if (val === true || val === false || val instanceof Boolean) { - return "boolean"; - } - if (typeof val === "string" || val instanceof String) { - return "string"; - } - if (typeof val === "number" || val instanceof Number) { - return "number"; - } - if (typeof val === "function" || val instanceof Function) { - return "function"; - } - if (typeof Array.isArray !== "undefined" && Array.isArray(val)) { - return "array"; - } - if (val instanceof RegExp) { - return "regexp"; - } - if (val instanceof Date) { - return "date"; - } - var type = toString.call(val); - if (type === "[object RegExp]") { - return "regexp"; - } - if (type === "[object Date]") { - return "date"; - } - if (type === "[object Arguments]") { - return "arguments"; - } - if (type === "[object Error]") { - return "error"; - } - if (isBuffer(val)) { - return "buffer"; - } - if (type === "[object Set]") { - return "set"; - } - if (type === "[object WeakSet]") { - return "weakset"; - } - if (type === "[object Map]") { - return "map"; - } - if (type === "[object WeakMap]") { - return "weakmap"; - } - if (type === "[object Symbol]") { - return "symbol"; - } - if (type === "[object Int8Array]") { - return "int8array"; - } - if (type === "[object Uint8Array]") { - return "uint8array"; - } - if (type === "[object Uint8ClampedArray]") { - return "uint8clampedarray"; - } - if (type === "[object Int16Array]") { - return "int16array"; - } - if (type === "[object Uint16Array]") { - return "uint16array"; - } - if (type === "[object Int32Array]") { - return "int32array"; - } - if (type === "[object Uint32Array]") { - return "uint32array"; - } - if (type === "[object Float32Array]") { - return "float32array"; - } - if (type === "[object Float64Array]") { - return "float64array"; - } - return "object"; - }; - } - }); - - // ../../node_modules/is-number/index.js - var require_is_number = __commonJS({ - "../../node_modules/is-number/index.js"(exports, module) { - "use strict"; - var typeOf = require_kind_of3(); - module.exports = function isNumber(num) { - var type = typeOf(num); - if (type !== "number" && type !== "string") { - return false; - } - var n = +num; - return n - n + 1 >= 0 && num !== ""; - }; - } - }); - - // ../../node_modules/get-object/index.js - var require_get_object = __commonJS({ - "../../node_modules/get-object/index.js"(exports, module) { - "use strict"; - var isNumber = require_is_number(); - module.exports = function getObject(obj, prop) { - if (!prop) - return obj; - if (!obj) - return {}; - var segs = String(prop).split(/[[.\]]/).filter(Boolean); - var last = segs[segs.length - 1], res = {}; - while (prop = segs.shift()) { - obj = obj[prop]; - if (!obj) - return {}; - } - if (isNumber(last)) - return [obj]; - res[last] = obj; - return res; - }; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/lib/object.js - var require_object = __commonJS({ - "../../node_modules/@budibase/handlebars-helpers/lib/object.js"(exports, module) { - "use strict"; - var hasOwn = Object.hasOwnProperty; - var util = require_handlebars_utils(); - var array = require_array(); - var helpers2 = module.exports; - var getValue = require_get_value(); - var getObject = require_get_object(); - var createFrame = require_createFrame(); - helpers2.extend = function() { - var args = [].slice.call(arguments); - var opts = {}; - if (util.isOptions(args[args.length - 1])) { - opts = args.pop().hash; - args.push(opts); - } - var context = {}; - for (var i = 0; i < args.length; i++) { - var obj = args[i]; - if (util.isObject(obj)) { - var keys = Object.keys(obj); - for (var j = 0; j < keys.length; j++) { - var key = keys[j]; - context[key] = obj[key]; - } - } - } - return context; - }; - helpers2.forIn = function(obj, options) { - if (!util.isOptions(options)) { - return obj.inverse(this); - } - var data = createFrame(options, options.hash); - var result = ""; - for (var key in obj) { - data.key = key; - result += options.fn(obj[key], { data }); - } - return result; - }; - helpers2.forOwn = function(obj, options) { - if (!util.isOptions(options)) { - return obj.inverse(this); - } - var data = createFrame(options, options.hash); - var result = ""; - for (var key in obj) { - if (obj.hasOwnProperty(key)) { - data.key = key; - result += options.fn(obj[key], { data }); - } - } - return result; - }; - helpers2.toPath = function() { - var prop = []; - for (var i = 0; i < arguments.length; i++) { - if (typeof arguments[i] === "string" || typeof arguments[i] === "number") { - prop.push(arguments[i]); - } - } - return prop.join("."); - }; - helpers2.get = function(prop, context, options) { - var val = getValue(context, prop); - if (options && options.fn) { - return val ? options.fn(val) : options.inverse(context); - } - return val; - }; - helpers2.getObject = function(prop, context) { - return getObject(context, prop); - }; - helpers2.hasOwn = function(context, key) { - return hasOwn.call(context, key); - }; - helpers2.isObject = function(value2) { - return typeof value2 === "object"; - }; - helpers2.JSONparse = function(str, options) { - return JSON.parse(str); - }; - helpers2.JSONstringify = function(obj, indent) { - if (isNaN(indent)) { - indent = 0; - } - return JSON.stringify(obj, null, indent); - }; - helpers2.merge = function(context) { - var args = [].slice.call(arguments); - var opts = {}; - if (util.isOptions(args[args.length - 1])) { - opts = args.pop().hash; - args.push(opts); - } - return Object.assign.apply(null, args); - }; - helpers2.parseJSON = helpers2.JSONparse; - helpers2.pick = function(props, context, options) { - var keys = array.arrayify(props); - var len = keys.length, i = -1; - var result = {}; - while (++i < len) { - result = helpers2.extend({}, result, getObject(context, keys[i])); - } - if (options.fn) { - if (Object.keys(result).length) { - return options.fn(result); - } - return options.inverse(context); - } - return result; - }; - helpers2.stringify = helpers2.JSONstringify; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/lib/regex.js - var require_regex = __commonJS({ - "../../node_modules/@budibase/handlebars-helpers/lib/regex.js"(exports, module) { - "use strict"; - var util = require_handlebars_utils(); - var helpers2 = module.exports; - var kindOf = require_kind_of2(); - helpers2.toRegex = function(str, locals, options) { - var opts = util.options({}, locals, options); - return new RegExp(str, opts.flags); - }; - helpers2.test = function(str, regex) { - if (typeof str !== "string") { - return false; - } - if (kindOf(regex) !== "regexp") { - throw new TypeError("expected a regular expression"); - } - return regex.test(str); - }; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/rng.js - function rng() { - if (poolPtr > rnds8Pool.length - 16) { - import_crypto.default.randomFillSync(rnds8Pool); - poolPtr = 0; - } - return rnds8Pool.slice(poolPtr, poolPtr += 16); - } - var import_crypto, rnds8Pool, poolPtr; - var init_rng = __esm({ - "../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/rng.js"() { - import_crypto = __toESM(__require("crypto")); - rnds8Pool = new Uint8Array(256); - poolPtr = rnds8Pool.length; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/regex.js - var regex_default; - var init_regex = __esm({ - "../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/regex.js"() { - regex_default = /^(?:[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; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/validate.js - function validate(uuid) { - return typeof uuid === "string" && regex_default.test(uuid); - } - var validate_default; - var init_validate = __esm({ - "../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/validate.js"() { - init_regex(); - validate_default = validate; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/stringify.js - function unsafeStringify(arr, offset = 0) { - return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]; - } - function stringify(arr, offset = 0) { - const uuid = unsafeStringify(arr, offset); - if (!validate_default(uuid)) { - throw TypeError("Stringified UUID is invalid"); - } - return uuid; - } - var byteToHex, stringify_default; - var init_stringify = __esm({ - "../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/stringify.js"() { - init_validate(); - byteToHex = []; - for (let i = 0; i < 256; ++i) { - byteToHex.push((i + 256).toString(16).slice(1)); - } - stringify_default = stringify; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/v1.js - function v1(options, buf, offset) { - let i = buf && offset || 0; - const b = buf || new Array(16); - options = options || {}; - let node = options.node || _nodeId; - let clockseq = options.clockseq !== void 0 ? options.clockseq : _clockseq; - if (node == null || clockseq == null) { - const seedBytes = options.random || (options.rng || rng)(); - if (node == null) { - node = _nodeId = [seedBytes[0] | 1, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]]; - } - if (clockseq == null) { - clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 16383; - } - } - let msecs = options.msecs !== void 0 ? options.msecs : Date.now(); - let nsecs = options.nsecs !== void 0 ? options.nsecs : _lastNSecs + 1; - const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 1e4; - if (dt < 0 && options.clockseq === void 0) { - clockseq = clockseq + 1 & 16383; - } - if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === void 0) { - nsecs = 0; - } - if (nsecs >= 1e4) { - throw new Error("uuid.v1(): Can't create more than 10M uuids/sec"); - } - _lastMSecs = msecs; - _lastNSecs = nsecs; - _clockseq = clockseq; - msecs += 122192928e5; - const tl = ((msecs & 268435455) * 1e4 + nsecs) % 4294967296; - b[i++] = tl >>> 24 & 255; - b[i++] = tl >>> 16 & 255; - b[i++] = tl >>> 8 & 255; - b[i++] = tl & 255; - const tmh = msecs / 4294967296 * 1e4 & 268435455; - b[i++] = tmh >>> 8 & 255; - b[i++] = tmh & 255; - b[i++] = tmh >>> 24 & 15 | 16; - b[i++] = tmh >>> 16 & 255; - b[i++] = clockseq >>> 8 | 128; - b[i++] = clockseq & 255; - for (let n = 0; n < 6; ++n) { - b[i + n] = node[n]; - } - return buf || unsafeStringify(b); - } - var _nodeId, _clockseq, _lastMSecs, _lastNSecs, v1_default; - var init_v1 = __esm({ - "../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/v1.js"() { - init_rng(); - init_stringify(); - _lastMSecs = 0; - _lastNSecs = 0; - v1_default = v1; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/parse.js - function parse(uuid) { - if (!validate_default(uuid)) { - throw TypeError("Invalid UUID"); - } - let v; - const arr = new Uint8Array(16); - arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24; - arr[1] = v >>> 16 & 255; - arr[2] = v >>> 8 & 255; - arr[3] = v & 255; - arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; - arr[5] = v & 255; - arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; - arr[7] = v & 255; - arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8; - arr[9] = v & 255; - arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 1099511627776 & 255; - arr[11] = v / 4294967296 & 255; - arr[12] = v >>> 24 & 255; - arr[13] = v >>> 16 & 255; - arr[14] = v >>> 8 & 255; - arr[15] = v & 255; - return arr; - } - var parse_default; - var init_parse = __esm({ - "../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/parse.js"() { - init_validate(); - parse_default = parse; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/v35.js - function stringToBytes(str) { - str = unescape(encodeURIComponent(str)); - const bytes = []; - for (let i = 0; i < str.length; ++i) { - bytes.push(str.charCodeAt(i)); - } - return bytes; - } - function v35(name, version2, hashfunc) { - function generateUUID(value2, namespace, buf, offset) { - var _namespace; - if (typeof value2 === "string") { - value2 = stringToBytes(value2); - } - if (typeof namespace === "string") { - namespace = parse_default(namespace); - } - if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) { - throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)"); - } - let bytes = new Uint8Array(16 + value2.length); - bytes.set(namespace); - bytes.set(value2, namespace.length); - bytes = hashfunc(bytes); - bytes[6] = bytes[6] & 15 | version2; - bytes[8] = bytes[8] & 63 | 128; - if (buf) { - offset = offset || 0; - for (let i = 0; i < 16; ++i) { - buf[offset + i] = bytes[i]; - } - return buf; - } - return unsafeStringify(bytes); - } - try { - generateUUID.name = name; - } catch (err) { - } - generateUUID.DNS = DNS; - generateUUID.URL = URL; - return generateUUID; - } - var DNS, URL; - var init_v35 = __esm({ - "../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/v35.js"() { - init_stringify(); - init_parse(); - DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8"; - URL = "6ba7b811-9dad-11d1-80b4-00c04fd430c8"; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/md5.js - function md5(bytes) { - if (Array.isArray(bytes)) { - bytes = Buffer.from(bytes); - } else if (typeof bytes === "string") { - bytes = Buffer.from(bytes, "utf8"); - } - return import_crypto2.default.createHash("md5").update(bytes).digest(); - } - var import_crypto2, md5_default; - var init_md5 = __esm({ - "../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/md5.js"() { - import_crypto2 = __toESM(__require("crypto")); - md5_default = md5; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/v3.js - var v3, v3_default; - var init_v3 = __esm({ - "../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/v3.js"() { - init_v35(); - init_md5(); - v3 = v35("v3", 48, md5_default); - v3_default = v3; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/native.js - var import_crypto3, native_default; - var init_native = __esm({ - "../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/native.js"() { - import_crypto3 = __toESM(__require("crypto")); - native_default = { - randomUUID: import_crypto3.default.randomUUID - }; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/v4.js - function v4(options, buf, offset) { - if (native_default.randomUUID && !buf && !options) { - return native_default.randomUUID(); - } - options = options || {}; - const rnds = options.random || (options.rng || rng)(); - rnds[6] = rnds[6] & 15 | 64; - rnds[8] = rnds[8] & 63 | 128; - if (buf) { - offset = offset || 0; - for (let i = 0; i < 16; ++i) { - buf[offset + i] = rnds[i]; - } - return buf; - } - return unsafeStringify(rnds); - } - var v4_default; - var init_v4 = __esm({ - "../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/v4.js"() { - init_native(); - init_rng(); - init_stringify(); - v4_default = v4; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/sha1.js - function sha1(bytes) { - if (Array.isArray(bytes)) { - bytes = Buffer.from(bytes); - } else if (typeof bytes === "string") { - bytes = Buffer.from(bytes, "utf8"); - } - return import_crypto4.default.createHash("sha1").update(bytes).digest(); - } - var import_crypto4, sha1_default; - var init_sha1 = __esm({ - "../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/sha1.js"() { - import_crypto4 = __toESM(__require("crypto")); - sha1_default = sha1; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/v5.js - var v5, v5_default; - var init_v5 = __esm({ - "../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/v5.js"() { - init_v35(); - init_sha1(); - v5 = v35("v5", 80, sha1_default); - v5_default = v5; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/nil.js - var nil_default; - var init_nil = __esm({ - "../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/nil.js"() { - nil_default = "00000000-0000-0000-0000-000000000000"; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/version.js - function version(uuid) { - if (!validate_default(uuid)) { - throw TypeError("Invalid UUID"); - } - return parseInt(uuid.slice(14, 15), 16); - } - var version_default; - var init_version = __esm({ - "../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/version.js"() { - init_validate(); - version_default = version; - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/index.js - var esm_node_exports = {}; - __export(esm_node_exports, { - NIL: () => nil_default, - parse: () => parse_default, - stringify: () => stringify_default, - v1: () => v1_default, - v3: () => v3_default, - v4: () => v4_default, - v5: () => v5_default, - validate: () => validate_default, - version: () => version_default - }); - var init_esm_node = __esm({ - "../../node_modules/@budibase/handlebars-helpers/node_modules/uuid/dist/esm-node/index.js"() { - init_v1(); - init_v3(); - init_v4(); - init_v5(); - init_nil(); - init_version(); - init_validate(); - init_stringify(); - init_parse(); - } - }); - - // ../../node_modules/@budibase/handlebars-helpers/lib/uuid.js - var require_uuid = __commonJS({ - "../../node_modules/@budibase/handlebars-helpers/lib/uuid.js"(exports, module) { - var uuid = (init_esm_node(), __toCommonJS(esm_node_exports)); - var helpers2 = module.exports; - helpers2.uuid = function() { - return uuid.v4(); - }; - } - }); - - // ../string-templates/src/helpers/list.js - var require_list = __commonJS({ - "../string-templates/src/helpers/list.js"(exports, module) { - var { date, duration } = require_date(); - var externalCollections = { - math: require_math(), - array: require_array(), - number: require_number(), - url: require_url(), - string: require_string(), - comparison: require_comparison(), - object: require_object(), - regex: require_regex(), - uuid: require_uuid() - }; - var helpersToRemoveForJs = ["sortBy"]; - module.exports.helpersToRemoveForJs = helpersToRemoveForJs; - var addedHelpers = { - date, - duration - }; - var helpers2 = void 0; - module.exports.getJsHelperList = () => { - if (helpers2) { - return helpers2; - } - helpers2 = {}; - for (let collection of Object.values(externalCollections)) { - for (let [key, func] of Object.entries(collection)) { - helpers2[key] = (...props) => func(...props, {}); - } - } - for (let key of Object.keys(addedHelpers)) { - helpers2[key] = addedHelpers[key]; - } - for (const toRemove of helpersToRemoveForJs) { - delete helpers2[toRemove]; - } - Object.freeze(helpers2); - return helpers2; - }; - } - }); - - // src/jsRunner/bundles/index-helpers.ts - var index_helpers_exports = {}; - __export(index_helpers_exports, { - helpers: () => helpers - }); - var { - getJsHelperList - } = require_list(); - var helpers = { - ...getJsHelperList(), - // pointing stripProtocol to a unexisting function to be able to declare it on isolated-vm - // @ts-ignore - // eslint-disable-next-line no-undef - stripProtocol: helpersStripProtocol - }; - return __toCommonJS(index_helpers_exports); -})(); +"use strict";var helpers=(()=>{var hn=Object.create;var Se=Object.defineProperty;var pn=Object.getOwnPropertyDescriptor;var mn=Object.getOwnPropertyNames;var gn=Object.getPrototypeOf,yn=Object.prototype.hasOwnProperty;var fe=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Z=(e,t)=>()=>(e&&(t=e(e=0)),t);var U=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),yt=(e,t)=>{for(var r in t)Se(e,r,{get:t[r],enumerable:!0})},vt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of mn(t))!yn.call(e,i)&&i!==r&&Se(e,i,{get:()=>t[i],enumerable:!(n=pn(t,i))||n.enumerable});return e};var Ne=(e,t,r)=>(r=e!=null?hn(gn(e)):{},vt(t||!e||!e.__esModule?Se(r,"default",{value:e,enumerable:!0}):r,e)),$t=e=>vt(Se({},"__esModule",{value:!0}),e);var bt=U((qe,Ye)=>{(function(e,t){typeof qe=="object"&&typeof Ye<"u"?Ye.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs=t()})(qe,function(){"use strict";var e=1e3,t=6e4,r=36e5,n="millisecond",i="second",u="minute",s="hour",f="day",w="week",g="month",l="quarter",x="year",v="date",a="Invalid Date",T=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,E=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,I={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function($){var h=["th","st","nd","rd"],c=$%100;return"["+$+(h[(c-20)%10]||h[c]||h[0])+"]"}},Y=function($,h,c){var b=String($);return!b||b.length>=h?$:""+Array(h+1-b.length).join(c)+$},F={s:Y,z:function($){var h=-$.utcOffset(),c=Math.abs(h),b=Math.floor(c/60),d=c%60;return(h<=0?"+":"-")+Y(b,2,"0")+":"+Y(d,2,"0")},m:function $(h,c){if(h.date()1)return $(j[0])}else{var _=h.name;S[_]=h,d=_}return!b&&d&&(q=d),d||!b&&q},N=function($,h){if(o($))return $.clone();var c=typeof h=="object"?h:{};return c.date=$,c.args=arguments,new B(c)},O=F;O.l=D,O.i=o,O.w=function($,h){return N($,{locale:h.$L,utc:h.$u,x:h.$x,$offset:h.$offset})};var B=function(){function $(c){this.$L=D(c.locale,null,!0),this.parse(c),this.$x=this.$x||c.x||{},this[p]=!0}var h=$.prototype;return h.parse=function(c){this.$d=function(b){var d=b.date,M=b.utc;if(d===null)return new Date(NaN);if(O.u(d))return new Date;if(d instanceof Date)return new Date(d);if(typeof d=="string"&&!/Z$/i.test(d)){var j=d.match(T);if(j){var _=j[2]-1||0,H=(j[7]||"0").substring(0,3);return M?new Date(Date.UTC(j[1],_,j[3]||1,j[4]||0,j[5]||0,j[6]||0,H)):new Date(j[1],_,j[3]||1,j[4]||0,j[5]||0,j[6]||0,H)}}return new Date(d)}(c),this.init()},h.init=function(){var c=this.$d;this.$y=c.getFullYear(),this.$M=c.getMonth(),this.$D=c.getDate(),this.$W=c.getDay(),this.$H=c.getHours(),this.$m=c.getMinutes(),this.$s=c.getSeconds(),this.$ms=c.getMilliseconds()},h.$utils=function(){return O},h.isValid=function(){return this.$d.toString()!==a},h.isSame=function(c,b){var d=N(c);return this.startOf(b)<=d&&d<=this.endOf(b)},h.isAfter=function(c,b){return N(c){(function(e,t){typeof Ce=="object"&&typeof Ee<"u"?Ee.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_duration=t()})(Ce,function(){"use strict";var e,t,r=1e3,n=6e4,i=36e5,u=864e5,s=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,f=31536e6,w=2628e6,g=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,l={years:f,months:w,days:u,hours:i,minutes:n,seconds:r,milliseconds:1,weeks:6048e5},x=function(S){return S instanceof F},v=function(S,p,o){return new F(S,o,p.$l)},a=function(S){return t.p(S)+"s"},T=function(S){return S<0},E=function(S){return T(S)?Math.ceil(S):Math.floor(S)},I=function(S){return Math.abs(S)},Y=function(S,p){return S?T(S)?{negative:!0,format:""+I(S)+p}:{negative:!1,format:""+S+p}:{negative:!1,format:""}},F=function(){function S(o,D,N){var O=this;if(this.$d={},this.$l=N,o===void 0&&(this.$ms=0,this.parseFromMilliseconds()),D)return v(o*l[a(D)],this);if(typeof o=="number")return this.$ms=o,this.parseFromMilliseconds(),this;if(typeof o=="object")return Object.keys(o).forEach(function($){O.$d[a($)]=o[$]}),this.calMilliseconds(),this;if(typeof o=="string"){var B=o.match(g);if(B){var J=B.slice(2).map(function($){return $!=null?Number($):0});return this.$d.years=J[0],this.$d.months=J[1],this.$d.weeks=J[2],this.$d.days=J[3],this.$d.hours=J[4],this.$d.minutes=J[5],this.$d.seconds=J[6],this.calMilliseconds(),this}}return this}var p=S.prototype;return p.calMilliseconds=function(){var o=this;this.$ms=Object.keys(this.$d).reduce(function(D,N){return D+(o.$d[N]||0)*l[N]},0)},p.parseFromMilliseconds=function(){var o=this.$ms;this.$d.years=E(o/f),o%=f,this.$d.months=E(o/w),o%=w,this.$d.days=E(o/u),o%=u,this.$d.hours=E(o/i),o%=i,this.$d.minutes=E(o/n),o%=n,this.$d.seconds=E(o/r),o%=r,this.$d.milliseconds=o},p.toISOString=function(){var o=Y(this.$d.years,"Y"),D=Y(this.$d.months,"M"),N=+this.$d.days||0;this.$d.weeks&&(N+=7*this.$d.weeks);var O=Y(N,"D"),B=Y(this.$d.hours,"H"),J=Y(this.$d.minutes,"M"),$=this.$d.seconds||0;this.$d.milliseconds&&($+=this.$d.milliseconds/1e3,$=Math.round(1e3*$)/1e3);var h=Y($,"S"),c=o.negative||D.negative||O.negative||B.negative||J.negative||h.negative,b=B.format||J.format||h.format?"T":"",d=(c?"-":"")+"P"+o.format+D.format+O.format+b+B.format+J.format+h.format;return d==="P"||d==="-P"?"P0D":d},p.toJSON=function(){return this.toISOString()},p.format=function(o){var D=o||"YYYY-MM-DDTHH:mm:ss",N={Y:this.$d.years,YY:t.s(this.$d.years,2,"0"),YYYY:t.s(this.$d.years,4,"0"),M:this.$d.months,MM:t.s(this.$d.months,2,"0"),D:this.$d.days,DD:t.s(this.$d.days,2,"0"),H:this.$d.hours,HH:t.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:t.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:t.s(this.$d.seconds,2,"0"),SSS:t.s(this.$d.milliseconds,3,"0")};return D.replace(s,function(O,B){return B||String(N[O])})},p.as=function(o){return this.$ms/l[a(o)]},p.get=function(o){var D=this.$ms,N=a(o);return N==="milliseconds"?D%=1e3:D=N==="weeks"?E(D/l[N]):this.$d[N],D||0},p.add=function(o,D,N){var O;return O=D?o*l[a(D)]:x(o)?o.$ms:v(o,this).$ms,v(this.$ms+O*(N?-1:1),this)},p.subtract=function(o,D){return this.add(o,D,!0)},p.locale=function(o){var D=this.clone();return D.$l=o,D},p.clone=function(){return v(this.$ms,this)},p.humanize=function(o){return e().add(this.$ms,"ms").locale(this.$l).fromNow(!o)},p.valueOf=function(){return this.asMilliseconds()},p.milliseconds=function(){return this.get("milliseconds")},p.asMilliseconds=function(){return this.as("milliseconds")},p.seconds=function(){return this.get("seconds")},p.asSeconds=function(){return this.as("seconds")},p.minutes=function(){return this.get("minutes")},p.asMinutes=function(){return this.as("minutes")},p.hours=function(){return this.get("hours")},p.asHours=function(){return this.as("hours")},p.days=function(){return this.get("days")},p.asDays=function(){return this.as("days")},p.weeks=function(){return this.get("weeks")},p.asWeeks=function(){return this.as("weeks")},p.months=function(){return this.get("months")},p.asMonths=function(){return this.as("months")},p.years=function(){return this.get("years")},p.asYears=function(){return this.as("years")},S}(),q=function(S,p,o){return S.add(p.years()*o,"y").add(p.months()*o,"M").add(p.days()*o,"d").add(p.hours()*o,"h").add(p.minutes()*o,"m").add(p.seconds()*o,"s").add(p.milliseconds()*o,"ms")};return function(S,p,o){e=o,t=o().$utils(),o.duration=function(O,B){var J=o.locale();return v(O,{$l:J},B)},o.isDuration=x;var D=p.prototype.add,N=p.prototype.subtract;p.prototype.add=function(O,B){return x(O)?q(this,O,1):D.bind(this)(O,B)},p.prototype.subtract=function(O,B){return x(O)?q(this,O,-1):N.bind(this)(O,B)}}})});var Ot=U((Ie,_e)=>{(function(e,t){typeof Ie=="object"&&typeof _e<"u"?_e.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_advancedFormat=t()})(Ie,function(){"use strict";return function(e,t){var r=t.prototype,n=r.format;r.format=function(i){var u=this,s=this.$locale();if(!this.isValid())return n.bind(this)(i);var f=this.$utils(),w=(i||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,function(g){switch(g){case"Q":return Math.ceil((u.$M+1)/3);case"Do":return s.ordinal(u.$D);case"gggg":return u.weekYear();case"GGGG":return u.isoWeekYear();case"wo":return s.ordinal(u.week(),"W");case"w":case"ww":return f.s(u.week(),g==="w"?1:2,"0");case"W":case"WW":return f.s(u.isoWeek(),g==="W"?1:2,"0");case"k":case"kk":return f.s(String(u.$H===0?24:u.$H),g==="k"?1:2,"0");case"X":return Math.floor(u.$d.getTime()/1e3);case"x":return u.$d.getTime();case"z":return"["+u.offsetName()+"]";case"zzz":return"["+u.offsetName("long")+"]";default:return g}});return n.bind(this)(w)}}})});var xt=U((We,Fe)=>{(function(e,t){typeof We=="object"&&typeof Fe<"u"?Fe.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_isoWeek=t()})(We,function(){"use strict";var e="day";return function(t,r,n){var i=function(f){return f.add(4-f.isoWeekday(),e)},u=r.prototype;u.isoWeekYear=function(){return i(this).year()},u.isoWeek=function(f){if(!this.$utils().u(f))return this.add(7*(f-this.isoWeek()),e);var w,g,l,x,v=i(this),a=(w=this.isoWeekYear(),g=this.$u,l=(g?n.utc:n)().year(w).startOf("year"),x=4-l.isoWeekday(),l.isoWeekday()>4&&(x+=7),l.add(x,e));return v.diff(a,"week")+1},u.isoWeekday=function(f){return this.$utils().u(f)?this.day()||7:this.day(this.day()%7?f:f-7)};var s=u.startOf;u.startOf=function(f,w){var g=this.$utils(),l=!!g.u(w)||w;return g.p(f)==="isoweek"?l?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):s.bind(this)(f,w)}}})});var St=U((He,Be)=>{(function(e,t){typeof He=="object"&&typeof Be<"u"?Be.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_weekYear=t()})(He,function(){"use strict";return function(e,t){t.prototype.weekYear=function(){var r=this.month(),n=this.week(),i=this.year();return n===1&&r===11?i+1:r===0&&n>=52?i-1:i}}})});var Nt=U((Le,ze)=>{(function(e,t){typeof Le=="object"&&typeof ze<"u"?ze.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_weekOfYear=t()})(Le,function(){"use strict";var e="week",t="year";return function(r,n,i){var u=n.prototype;u.week=function(s){if(s===void 0&&(s=null),s!==null)return this.add(7*(s-this.week()),"day");var f=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var w=i(this).startOf(t).add(1,t).date(f),g=i(this).endOf(e);if(w.isBefore(g))return 1}var l=i(this).startOf(t).date(f).startOf(e).subtract(1,"millisecond"),x=this.diff(l,e,!0);return x<0?i(this).startOf("week").week():Math.ceil(x)},u.weeks=function(s){return s===void 0&&(s=null),this.week(s)}}})});var Mt=U((Pe,Re)=>{(function(e,t){typeof Pe=="object"&&typeof Re<"u"?Re.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_relativeTime=t()})(Pe,function(){"use strict";return function(e,t,r){e=e||{};var n=t.prototype,i={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function u(f,w,g,l){return n.fromToBase(f,w,g,l)}r.en.relativeTime=i,n.fromToBase=function(f,w,g,l,x){for(var v,a,T,E=g.$locale().relativeTime||i,I=e.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],Y=I.length,F=0;F0,S<=q.r||!q.r){S<=1&&F>0&&(q=I[F-1]);var p=E[q.l];x&&(S=x(""+S)),a=typeof p=="string"?p.replace("%d",S):p(S,w,q.l,T);break}}if(w)return a;var o=T?E.future:E.past;return typeof o=="function"?o(a):o.replace("%s",a)},n.to=function(f,w){return u(f,w,this,!0)},n.from=function(f,w){return u(f,w,this)};var s=function(f){return f.$u?r.utc():r()};n.toNow=function(f){return this.to(s(this),f)},n.fromNow=function(f){return this.from(s(this),f)}}})});var jt=U((Je,Ge)=>{(function(e,t){typeof Je=="object"&&typeof Ge<"u"?Ge.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_utc=t()})(Je,function(){"use strict";var e="minute",t=/[+-]\d\d(?::?\d\d)?/g,r=/([+-]|\d\d)/g;return function(n,i,u){var s=i.prototype;u.utc=function(a){var T={date:a,utc:!0,args:arguments};return new i(T)},s.utc=function(a){var T=u(this.toDate(),{locale:this.$L,utc:!0});return a?T.add(this.utcOffset(),e):T},s.local=function(){return u(this.toDate(),{locale:this.$L,utc:!1})};var f=s.parse;s.parse=function(a){a.utc&&(this.$u=!0),this.$utils().u(a.$offset)||(this.$offset=a.$offset),f.call(this,a)};var w=s.init;s.init=function(){if(this.$u){var a=this.$d;this.$y=a.getUTCFullYear(),this.$M=a.getUTCMonth(),this.$D=a.getUTCDate(),this.$W=a.getUTCDay(),this.$H=a.getUTCHours(),this.$m=a.getUTCMinutes(),this.$s=a.getUTCSeconds(),this.$ms=a.getUTCMilliseconds()}else w.call(this)};var g=s.utcOffset;s.utcOffset=function(a,T){var E=this.$utils().u;if(E(a))return this.$u?0:E(this.$offset)?g.call(this):this.$offset;if(typeof a=="string"&&(a=function(q){q===void 0&&(q="");var S=q.match(t);if(!S)return null;var p=(""+S[0]).match(r)||["-",0,0],o=p[0],D=60*+p[1]+ +p[2];return D===0?0:o==="+"?D:-D}(a),a===null))return this;var I=Math.abs(a)<=16?60*a:a,Y=this;if(T)return Y.$offset=I,Y.$u=a===0,Y;if(a!==0){var F=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(Y=this.local().add(I+F,e)).$offset=I,Y.$x.$localOffset=F}else Y=this.utc();return Y};var l=s.format;s.format=function(a){var T=a||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return l.call(this,T)},s.valueOf=function(){var a=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*a},s.isUTC=function(){return!!this.$u},s.toISOString=function(){return this.toDate().toISOString()},s.toString=function(){return this.toDate().toUTCString()};var x=s.toDate;s.toDate=function(a){return a==="s"&&this.$offset?u(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():x.call(this)};var v=s.diff;s.diff=function(a,T,E){if(a&&this.$u===a.$u)return v.call(this,a,T,E);var I=this.local(),Y=u(a).local();return v.call(I,Y,T,E)}}})});var At=U((Ze,Ve)=>{(function(e,t){typeof Ze=="object"&&typeof Ve<"u"?Ve.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_timezone=t()})(Ze,function(){"use strict";var e={year:0,month:1,day:2,hour:3,minute:4,second:5},t={};return function(r,n,i){var u,s=function(l,x,v){v===void 0&&(v={});var a=new Date(l),T=function(E,I){I===void 0&&(I={});var Y=I.timeZoneName||"short",F=E+"|"+Y,q=t[F];return q||(q=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:E,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:Y}),t[F]=q),q}(x,v);return T.formatToParts(a)},f=function(l,x){for(var v=s(l,x),a=[],T=0;T=0&&(a[F]=parseInt(Y,10))}var q=a[3],S=q===24?0:q,p=a[0]+"-"+a[1]+"-"+a[2]+" "+S+":"+a[4]+":"+a[5]+":000",o=+l;return(i.utc(p).valueOf()-(o-=o%1e3))/6e4},w=n.prototype;w.tz=function(l,x){l===void 0&&(l=u);var v=this.utcOffset(),a=this.toDate(),T=a.toLocaleString("en-US",{timeZone:l}),E=Math.round((a-new Date(T))/1e3/60),I=i(T,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(15*-Math.round(a.getTimezoneOffset()/15)-E,!0);if(x){var Y=I.utcOffset();I=I.add(v-Y,"minute")}return I.$x.$timezone=l,I},w.offsetName=function(l){var x=this.$x.$timezone||i.tz.guess(),v=s(this.valueOf(),x,{timeZoneName:l}).find(function(a){return a.type.toLowerCase()==="timezonename"});return v&&v.value};var g=w.startOf;w.startOf=function(l,x){if(!this.$x||!this.$x.$timezone)return g.call(this,l,x);var v=i(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return g.call(v,l,x).tz(this.$x.$timezone,!0)},i.tz=function(l,x,v){var a=v&&x,T=v||x||u,E=f(+i(),T);if(typeof l!="string")return i(l).tz(T);var I=function(S,p,o){var D=S-60*p*1e3,N=f(D,o);if(p===N)return[D,p];var O=f(D-=60*(N-p)*1e3,o);return N===O?[D,N]:[S-60*Math.min(N,O)*1e3,Math.max(N,O)]}(i.utc(l,a).valueOf(),E,T),Y=I[0],F=I[1],q=i(Y).utcOffset(F);return q.$x.$timezone=T,q},i.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},i.tz.setDefault=function(l){u=l}}})});var Dt=U((Ui,et)=>{var X=bt();X.extend(wt());X.extend(Ot());X.extend(xt());X.extend(St());X.extend(Nt());X.extend(Mt());X.extend(jt());X.extend(At());function oe(e){return typeof e=="object"&&typeof e.hash=="object"}function Qe(e){return typeof e=="object"&&typeof e.options=="object"&&typeof e.app=="object"}function Xe(e,t,r){if(oe(e))return Xe({},t,e);if(oe(t))return Xe(e,r,t);let n=Qe(e)?e.context:{};r=r||{},oe(r)||(t=Object.assign({},t,r)),oe(r)&&r.hash.root===!0&&(t=Object.assign({},r.data.root,t));let i=Object.assign({},n,t,r.hash);return Qe(e)||(i=Object.assign({},e,i)),Qe(e)&&e.view&&e.view.data&&(i=Object.assign({},i,e.view.data)),i}function Ke(e,t,r){return oe(t)&&(r=t,t=null),oe(e)&&(r=e,t=null,e=null),{str:e,pattern:t,options:r}}function kt(e,t,r){let n=Ke(e,t,r),i={lang:"en",date:new Date(n.str)},u=Xe(this,i,{});X.locale(u.lang||u.language)}et.exports.date=(e,t,r)=>{let n=Ke(e,t,r);if(n.str==null&&n.pattern==null)return X.locale("en"),X().format("MMMM DD, YYYY");kt(n.str,n.pattern,n.options);let i=X(new Date(n.str));return typeof n.options=="string"?i=n.options.toLowerCase()==="utc"?i.utc():i.tz(n.options):i=i.tz(X.tz.guess()),n.pattern===""?i.toISOString():i.format(n.pattern)};et.exports.duration=(e,t,r)=>{let n=Ke(e,t);kt(n.str,n.pattern);let i=X.duration(n.str,n.pattern);return r&&!oe(r)?i.format(r):i.humanize()}});var tt=U((Ti,Tt)=>{Tt.exports=function(e){return e!=null&&(Ut(e)||vn(e)||!!e._isBuffer)};function Ut(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function vn(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&Ut(e.slice(0,0))}});var Yt=U((qi,qt)=>{var $n=tt(),bn=Object.prototype.toString;qt.exports=function(t){if(typeof t>"u")return"undefined";if(t===null)return"null";if(t===!0||t===!1||t instanceof Boolean)return"boolean";if(typeof t=="string"||t instanceof String)return"string";if(typeof t=="number"||t instanceof Number)return"number";if(typeof t=="function"||t instanceof Function)return"function";if(typeof Array.isArray<"u"&&Array.isArray(t))return"array";if(t instanceof RegExp)return"regexp";if(t instanceof Date)return"date";var r=bn.call(t);return r==="[object RegExp]"?"regexp":r==="[object Date]"?"date":r==="[object Arguments]"?"arguments":r==="[object Error]"?"error":$n(t)?"buffer":r==="[object Set]"?"set":r==="[object WeakSet]"?"weakset":r==="[object Map]"?"map":r==="[object WeakMap]"?"weakmap":r==="[object Symbol]"?"symbol":r==="[object Int8Array]"?"int8array":r==="[object Uint8Array]"?"uint8array":r==="[object Uint8ClampedArray]"?"uint8clampedarray":r==="[object Int16Array]"?"int16array":r==="[object Uint16Array]"?"uint16array":r==="[object Int32Array]"?"int32array":r==="[object Uint32Array]"?"uint32array":r==="[object Float32Array]"?"float32array":r==="[object Float64Array]"?"float64array":"object"}});var _t=U((Yi,It)=>{"use strict";var Ct=Yt(),Et={arguments:"an arguments object",array:"an array",boolean:"a boolean",buffer:"a buffer",date:"a date",error:"an error",float32array:"a float32array",float64array:"a float64array",function:"a function",int16array:"an int16array",int32array:"an int32array",int8array:"an int8array",map:"a Map",null:"null",number:"a number",object:"an object",regexp:"a regular expression",set:"a Set",string:"a string",symbol:"a symbol",uint16array:"an uint16array",uint32array:"an uint32array",uint8array:"an uint8array",uint8clampedarray:"an uint8clampedarray",undefined:"undefined",weakmap:"a WeakMap",weakset:"a WeakSet"};function rt(e){return Et[Ct(e)]}rt.types=Et;rt.typeOf=Ct;It.exports=rt});var Me=U((Ci,Ft)=>{var wn=Object.prototype.toString;Ft.exports=function(t){if(t===void 0)return"undefined";if(t===null)return"null";var r=typeof t;if(r==="boolean")return"boolean";if(r==="string")return"string";if(r==="number")return"number";if(r==="symbol")return"symbol";if(r==="function")return Mn(t)?"generatorfunction":"function";if(On(t))return"array";if(kn(t))return"buffer";if(An(t))return"arguments";if(Sn(t))return"date";if(xn(t))return"error";if(Nn(t))return"regexp";switch(Wt(t)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(jn(t))return"generator";switch(r=wn.call(t),r){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return r.slice(8,-1).toLowerCase().replace(/\s/g,"")};function Wt(e){return typeof e.constructor=="function"?e.constructor.name:null}function On(e){return Array.isArray?Array.isArray(e):e instanceof Array}function xn(e){return e instanceof Error||typeof e.message=="string"&&e.constructor&&typeof e.constructor.stackTraceLimit=="number"}function Sn(e){return e instanceof Date?!0:typeof e.toDateString=="function"&&typeof e.getDate=="function"&&typeof e.setDate=="function"}function Nn(e){return e instanceof RegExp?!0:typeof e.flags=="string"&&typeof e.ignoreCase=="boolean"&&typeof e.multiline=="boolean"&&typeof e.global=="boolean"}function Mn(e,t){return Wt(e)==="GeneratorFunction"}function jn(e){return typeof e.throw=="function"&&typeof e.return=="function"&&typeof e.next=="function"}function An(e){try{if(typeof e.length=="number"&&typeof e.callee=="function")return!0}catch(t){if(t.message.indexOf("callee")!==-1)return!0}return!1}function kn(e){return e.constructor&&typeof e.constructor.isBuffer=="function"?e.constructor.isBuffer(e):!1}});var ee=U((Lt,zt)=>{"use strict";var Dn=fe("util"),Ht=_t(),Un=Me(),m=Lt=zt.exports;m.extend=Bt;m.indexOf=In;m.escapeExpression=_n;m.isEmpty=Bn;m.createFrame=Wn;m.blockParams=Fn;m.appendContextPath=Hn;var Tn={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`","=":"="},qn=/[&<>"'`=]/g,Yn=/[&<>"'`=]/;function Cn(e){return Tn[e]}function Bt(e){for(var t=1;t{"use strict";var Ln=ee();pe.contains=function(e,t,r){return e==null||t==null||isNaN(e.length)?!1:e.indexOf(t,r)!==-1};pe.chop=function(e){if(typeof e!="string")return"";var t=/^[-_.\W\s]+|[-_.\W\s]+$/g;return e.trim().replace(t,"")};pe.changecase=function(e,t){if(typeof e!="string")return"";if(e.length===1)return e.toLowerCase();e=pe.chop(e).toLowerCase(),typeof t!="function"&&(t=Ln.identity);var r=/[-_.\W\s]+(\w|$)/g;return e.replace(r,function(n,i){return t(i)})};pe.random=function(e,t){return e+Math.floor(Math.random()*(t-e+1))}});var Rt=U((Ii,Pt)=>{"use strict";var zn=je(),V=Pt.exports;V.abs=function(e){if(isNaN(e))throw new TypeError("expected a number");return Math.abs(e)};V.add=function(e,t){return!isNaN(e)&&!isNaN(t)?Number(e)+Number(t):typeof e=="string"&&typeof t=="string"?e+t:""};V.avg=function(){let e=[].concat.apply([],arguments);return e.pop(),V.sum(e)/e.length};V.ceil=function(e){if(isNaN(e))throw new TypeError("expected a number");return Math.ceil(e)};V.divide=function(e,t){if(isNaN(e))throw new TypeError("expected the first argument to be a number");if(isNaN(t))throw new TypeError("expected the second argument to be a number");return Number(e)/Number(t)};V.floor=function(e){if(isNaN(e))throw new TypeError("expected a number");return Math.floor(e)};V.minus=function(e,t){if(isNaN(e))throw new TypeError("expected the first argument to be a number");if(isNaN(t))throw new TypeError("expected the second argument to be a number");return Number(e)-Number(t)};V.modulo=function(e,t){if(isNaN(e))throw new TypeError("expected the first argument to be a number");if(isNaN(t))throw new TypeError("expected the second argument to be a number");return Number(e)%Number(t)};V.multiply=function(e,t){if(isNaN(e))throw new TypeError("expected the first argument to be a number");if(isNaN(t))throw new TypeError("expected the second argument to be a number");return Number(e)*Number(t)};V.plus=function(e,t){if(isNaN(e))throw new TypeError("expected the first argument to be a number");if(isNaN(t))throw new TypeError("expected the second argument to be a number");return Number(e)+Number(t)};V.random=function(e,t){if(isNaN(e))throw new TypeError("expected minimum to be a number");if(isNaN(t))throw new TypeError("expected maximum to be a number");return zn.random(e,t)};V.remainder=function(e,t){return e%t};V.round=function(e){if(isNaN(e))throw new TypeError("expected a number");return Math.round(e)};V.subtract=function(e,t){if(isNaN(e))throw new TypeError("expected the first argument to be a number");if(isNaN(t))throw new TypeError("expected the second argument to be a number");return Number(e)-Number(t)};V.sum=function(){for(var e=[].concat.apply([],arguments),t=e.length,r=0;t--;)isNaN(e[t])||(r+=Number(e[t]));return r}});var Gt=U((_i,Jt)=>{"use strict";Jt.exports=function(t){return t!=null&&typeof t=="object"&&Array.isArray(t)===!1}});var Ae=U((Wi,Xt)=>{var Qt=Gt();Xt.exports=function(e,t,r){if(Qt(r)||(r={default:r}),!Vt(e))return typeof r.default<"u"?r.default:e;typeof t=="number"&&(t=String(t));let n=Array.isArray(t),i=typeof t=="string",u=r.separator||".",s=r.joinChar||(typeof u=="string"?u:".");if(!i&&!n)return e;if(i&&t in e)return ut(t,e,r)?e[t]:r.default;let f=n?t:Pn(t,u,r),w=f.length,g=0;do{let l=f[g];for(typeof l=="number"&&(l=String(l));l&&l.slice(-1)==="\\";)l=Zt([l.slice(0,-1),f[++g]||""],s,r);if(l in e){if(!ut(l,e,r))return r.default;e=e[l]}else{let x=!1,v=g+1;for(;v{"use strict";Kt.exports=function(t){if(typeof t!="object")throw new TypeError("createFrame expects data to be an object");var r=Object.assign({},t);if(r._parent=t,r.extend=function(s){Object.assign(this,s)},arguments.length>1)for(var n=[].slice.call(arguments,1),i=n.length,u=-1;++u{"use strict";var y=ee(),C=er.exports,ae=Ae(),Rn=st();C.after=function(e,t){return y.isUndefined(e)?"":(e=y.result(e),Array.isArray(e)?e.slice(t):"")};C.arrayify=function(e){return y.isUndefined(e)?[]:e?Array.isArray(e)?e:[e]:[]};C.before=function(e,t){return y.isUndefined(e)?"":(e=y.result(e),Array.isArray(e)?e.slice(0,t-1):"")};C.eachIndex=function(e,t){var r="";if(y.isUndefined(e))return"";if(e=y.result(e),Array.isArray(e))for(var n=0;n0){for(var s=0;s-1,this,r):"")};C.isArray=function(e){return Array.isArray(e)};C.itemAt=function(e,t){if(y.isUndefined(e))return null;if(e=y.result(e),Array.isArray(e)){if(t=isNaN(t)?0:+t,t<0)return e[e.length+t];if(ti[t]>u[t]?1:-1)}return""};C.withAfter=function(e,t,r){if(y.isUndefined(e))return"";if(e=y.result(e),Array.isArray(e)){e=e.slice(t);for(var n="",i=0;i0){for(var i=[],u=0;u0&&u%t===0&&(n+=r.fn(i),i=[]),i.push(e[u]);n+=r.fn(i)}return n};C.withLast=function(e,t,r){if(y.isUndefined(e))return"";if(e=y.result(e),Array.isArray(e)){if(y.isUndefined(t)||(t=parseFloat(y.result(t))),y.isUndefined(t))return r=t,r.fn(e[e.length-1]);e=e.slice(-t);for(var n=e.length,i=-1,u="";++ig?1:w{"use strict";var tr=ee(),te=rr.exports;te.bytes=function(e,t,r){if(e==null||isNaN(e)&&(e=e.length,!e))return"0 B";isNaN(t)&&(t=2);var n=["B","kB","MB","GB","TB","PB","EB","ZB","YB"];t=Math.pow(10,t),e=Number(e);for(var i=n.length-1;i-->=0;){var u=Math.pow(10,i*3);if(u<=e+1){e=Math.round(e*t/u)/t,e+=" "+n[i];break}}return e};te.addCommas=function(e){return e.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1,")};te.phoneNumber=function(e){return e=e.toString(),"("+e.substr(0,3)+") "+e.substr(3,3)+"-"+e.substr(6,4)};te.toAbbr=function(e,t){isNaN(e)&&(e=0),tr.isUndefined(t)&&(t=2),e=Number(e),t=Math.pow(10,t);for(var r=["k","m","b","t","q"],n=r.length-1;n>=0;){var i=Math.pow(10,(n+1)*3);if(i<=e+1){e=Math.round(e*t/i)/t,e+=r[n];break}n--}return e};te.toExponential=function(e,t){return isNaN(e)&&(e=0),tr.isUndefined(t)&&(t=0),Number(e).toExponential(t)};te.toFixed=function(e,t){return isNaN(e)&&(e=0),isNaN(t)&&(t=0),Number(e).toFixed(t)};te.toFloat=function(e){return parseFloat(e)};te.toInt=function(e){return parseInt(e,10)};te.toPrecision=function(e,t){return isNaN(e)&&(e=0),isNaN(t)&&(t=1),Number(e).toPrecision(t)}});var ur=U((Li,ir)=>{"use strict";var ft=fe("url"),ye=ee(),Jn=fe("querystring"),ce=ir.exports;ce.encodeURI=function(e){if(ye.isString(e))return encodeURIComponent(e)};ce.escape=function(e){if(ye.isString(e))return Jn.escape(e)};ce.decodeURI=function(e){if(ye.isString(e))return decodeURIComponent(e)};ce.urlResolve=function(e,t){return ft.resolve(e,t)};ce.urlParse=function(e){return ft.parse(e)};ce.stripQuerystring=function(e){if(ye.isString(e))return e.split("?")[0]};ce.stripProtocol=function(e){if(ye.isString(e)){var t=ft.parse(e);return t.protocol="",t.format()}}});var or=U((sr,fr)=>{"use strict";var z=ee(),le=je(),A=fr.exports;A.append=function(e,t){return typeof e=="string"&&typeof t=="string"?e+t:e};A.camelcase=function(e){return typeof e!="string"?"":le.changecase(e,function(t){return t.toUpperCase()})};A.capitalize=function(e){return typeof e!="string"?"":e.charAt(0).toUpperCase()+e.slice(1)};A.capitalizeAll=function(e){if(typeof e!="string")return"";if(z.isString(e))return e.replace(/\w\S*/g,function(t){return A.capitalize(t)})};A.center=function(e,t){if(typeof e!="string")return"";for(var r="",n=0;n-1;)i++,n+=r;return i};A.pascalcase=function(e){return typeof e!="string"?"":(e=le.changecase(e,function(t){return t.toUpperCase()}),e.charAt(0).toUpperCase()+e.slice(1))};A.pathcase=function(e){return typeof e!="string"?"":le.changecase(e,function(t){return"/"+t})};A.plusify=function(e,t){return typeof e!="string"?"":(z.isString(t)||(t=" "),e.split(t).join("+"))};A.prepend=function(e,t){return typeof e=="string"&&typeof t=="string"?t+e:e};A.raw=function(e){var t=e.fn(),r=z.options(this,e);if(r.escape!==!1)for(var n=0;(n=t.indexOf("{{",n))!==-1;)t[n-1]!=="\\"&&(t=t.slice(0,n)+"\\"+t.slice(n)),n+=3;return t};A.remove=function(e,t){return typeof e!="string"?"":z.isString(t)?e.split(t).join(""):e};A.removeFirst=function(e,t){return typeof e!="string"?"":z.isString(t)?e.replace(t,""):e};A.replace=function(e,t,r){return typeof e!="string"?"":z.isString(t)?(z.isString(r)||(r=""),e.split(t).join(r)):e};A.replaceFirst=function(e,t,r){return typeof e!="string"?"":z.isString(t)?(z.isString(r)||(r=""),e.replace(t,r)):e};A.reverse=ke().reverse;A.sentence=function(e){return typeof e!="string"?"":e.replace(/((?:\S[^\.\?\!]*)[\.\?\!]*)/g,function(t){return t.charAt(0).toUpperCase()+t.substr(1).toLowerCase()})};A.snakecase=function(e){return typeof e!="string"?"":le.changecase(e,function(t){return"_"+t})};A.split=function(e,t){return typeof e!="string"?"":(z.isString(t)||(t=","),e.split(t))};A.startsWith=function(e,t,r){var n=[].slice.call(arguments);return r=n.pop(),z.isString(t)&&t.indexOf(e)===0?r.fn(this):typeof r.inverse=="function"?r.inverse(this):""};A.titleize=function(e){if(typeof e!="string")return"";for(var t=e.replace(/[- _]+/g," "),r=t.split(" "),n=r.length,i=[],u=0;n--;){var s=r[u++];i.push(sr.capitalize(s))}return i.join(" ")};A.trim=function(e){return typeof e=="string"?e.trim():""};A.trimLeft=function(e){if(z.isString(e))return e.replace(/^\s+/,"")};A.trimRight=function(e){if(z.isString(e))return e.replace(/\s+$/,"")};A.truncate=function(e,t,r){if(z.isString(e))return typeof r!="string"&&(r=""),e.length>t?e.slice(0,t-r.length)+r:e};A.truncateWords=function(e,t,r){if(z.isString(e)&&!isNaN(t)){typeof r!="string"&&(r="\u2026");var n=Number(t),i=e.split(/[ \t]/);if(n>=i.length)return e;i=i.slice(0,n);var u=i.join(" ").trim();return u+r}};A.upcase=function(){return A.uppercase.apply(this,arguments)};A.uppercase=function(e){return z.isObject(e)&&e.fn?e.fn(this).toUpperCase():typeof e!="string"?"":e.toUpperCase()}});var cr=U((zi,ar)=>{"use strict";var Gn=Me();ar.exports=function e(t){switch(Gn(t)){case"boolean":case"date":case"function":case"null":case"number":return!0;case"undefined":return!1;case"regexp":return t.source!=="(?:)"&&t.source!=="";case"buffer":return t.toString()!=="";case"error":return t.message!=="";case"string":case"arguments":return t.length!==0;case"file":case"map":case"set":return t.size!==0;case"array":case"object":for(let r of Object.keys(t))if(e(t[r]))return!0;return!1;default:return!0}}});var dr=U((Pi,lr)=>{"use strict";var Zn=Ae(),Vn=cr();lr.exports=function(e,t,r){return Qn(e)&&(typeof t=="string"||Array.isArray(t))?Vn(Zn(e,t,r)):!1};function Qn(e){return e!=null&&(typeof e=="object"||typeof e=="function"||Array.isArray(e))}});var pr=U((Ri,hr)=>{"use strict";function ot(e,t){if(!e)return!0;let r=t||ot.keywords;Array.isArray(r)||(r=[r]);let n=typeof e=="string"?e.toLowerCase():null;for(let i of r)if(i===e||i===n)return!0;return!1}ot.keywords=["0","false","nada","nil","nay","nah","negative","no","none","nope","nul","null","nix","nyet","uh-uh","veto","zero"];hr.exports=ot});var gr=U((Ji,mr)=>{"use strict";mr.exports=function(t){let r=Math.abs(t);if(isNaN(r))throw new TypeError("expected a number");if(!Number.isInteger(r))throw new Error("expected an integer");if(!Number.isSafeInteger(r))throw new Error("value exceeds maximum safe integer");return r%2===1}});var br=U((Gi,$r)=>{"use strict";var Xn=dr(),k=ee(),Kn=je(),yr=pr(),vr=gr(),W=$r.exports;W.and=function(){for(var e=arguments.length-1,t=arguments[e],r=!0,n=0;n":i=e>r;break;case"<=":i=e<=r;break;case">=":i=e>=r;break;case"typeof":i=typeof e===r;break;default:throw new Error("helper {{compare}}: invalid operator: `"+t+"`")}return k.value(i,this,n)};W.contains=function(e,t,r,n){typeof r=="object"&&(n=r,r=void 0);var i=Kn.contains(e,t,r);return k.value(i,this,n)};W.default=function(){for(var e=0;et,this,r)};W.gte=function(e,t,r){return arguments.length===2&&(r=t,t=r.hash.compare),k.value(e>=t,this,r)};W.has=function(e,t,r){return k.isOptions(e)&&(r=e,t=null,e=null),k.isOptions(t)&&(r=t,t=null),e===null?k.value(!1,this,r):arguments.length===2?k.value(Xn(this,e),this,r):(Array.isArray(e)||k.isString(e))&&k.isString(t)&&e.indexOf(t)>-1?k.fn(!0,this,r):k.isObject(e)&&k.isString(t)&&t in e?k.fn(!0,this,r):k.inverse(!1,this,r)};W.isFalsey=function(e,t){return k.value(yr(e),this,t)};W.isTruthy=function(e,t){return k.value(!yr(e),this,t)};W.ifEven=function(e,t){return k.value(!vr(e),this,t)};W.ifNth=function(e,t,r){var n=!isNaN(e)&&!isNaN(t)&&t%e===0;return k.value(n,this,r)};W.ifOdd=function(e,t){return k.value(vr(e),this,t)};W.is=function(e,t,r){return arguments.length===2&&(r=t,t=r.hash.compare),k.value(e==t,this,r)};W.isnt=function(e,t,r){return arguments.length===2&&(r=t,t=r.hash.compare),k.value(e!=t,this,r)};W.lt=function(e,t,r){return arguments.length===2&&(r=t,t=r.hash.compare),k.value(e=t,this,r)};W.unlessGteq=function(e,t,r){return k.isOptions(t)&&(r=t,t=r.hash.compare),k.value(et,this,r)}});var Or=U((Zi,wr)=>{var ei=tt(),ti=Object.prototype.toString;wr.exports=function(t){if(typeof t>"u")return"undefined";if(t===null)return"null";if(t===!0||t===!1||t instanceof Boolean)return"boolean";if(typeof t=="string"||t instanceof String)return"string";if(typeof t=="number"||t instanceof Number)return"number";if(typeof t=="function"||t instanceof Function)return"function";if(typeof Array.isArray<"u"&&Array.isArray(t))return"array";if(t instanceof RegExp)return"regexp";if(t instanceof Date)return"date";var r=ti.call(t);return r==="[object RegExp]"?"regexp":r==="[object Date]"?"date":r==="[object Arguments]"?"arguments":r==="[object Error]"?"error":ei(t)?"buffer":r==="[object Set]"?"set":r==="[object WeakSet]"?"weakset":r==="[object Map]"?"map":r==="[object WeakMap]"?"weakmap":r==="[object Symbol]"?"symbol":r==="[object Int8Array]"?"int8array":r==="[object Uint8Array]"?"uint8array":r==="[object Uint8ClampedArray]"?"uint8clampedarray":r==="[object Int16Array]"?"int16array":r==="[object Uint16Array]"?"uint16array":r==="[object Int32Array]"?"int32array":r==="[object Uint32Array]"?"uint32array":r==="[object Float32Array]"?"float32array":r==="[object Float64Array]"?"float64array":"object"}});var Sr=U((Vi,xr)=>{"use strict";var ri=Or();xr.exports=function(t){var r=ri(t);if(r!=="number"&&r!=="string")return!1;var n=+t;return n-n+1>=0&&t!==""}});var Mr=U((Qi,Nr)=>{"use strict";var ni=Sr();Nr.exports=function(t,r){if(!r)return t;if(!t)return{};for(var n=String(r).split(/[[.\]]/).filter(Boolean),i=n[n.length-1],u={};r=n.shift();)if(t=t[r],!t)return{};return ni(i)?[t]:(u[i]=t,u)}});var Dr=U((Xi,kr)=>{"use strict";var ii=Object.hasOwnProperty,ve=ee(),ui=ke(),P=kr.exports,si=Ae(),jr=Mr(),Ar=st();P.extend=function(){var e=[].slice.call(arguments),t={};ve.isOptions(e[e.length-1])&&(t=e.pop().hash,e.push(t));for(var r={},n=0;n{"use strict";var fi=ee(),Ur=Tr.exports,oi=Me();Ur.toRegex=function(e,t,r){var n=fi.options({},t,r);return new RegExp(e,n.flags)};Ur.test=function(e,t){if(typeof e!="string")return!1;if(oi(t)!=="regexp")throw new TypeError("expected a regular expression");return t.test(e)}});function $e(){return De>Ue.length-16&&(Yr.default.randomFillSync(Ue),De=0),Ue.slice(De,De+=16)}var Yr,Ue,De,at=Z(()=>{Yr=Ne(fe("crypto")),Ue=new Uint8Array(256),De=Ue.length});var Cr,Er=Z(()=>{Cr=/^(?:[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});function ai(e){return typeof e=="string"&&Cr.test(e)}var ne,be=Z(()=>{Er();ne=ai});function de(e,t=0){return R[e[t+0]]+R[e[t+1]]+R[e[t+2]]+R[e[t+3]]+"-"+R[e[t+4]]+R[e[t+5]]+"-"+R[e[t+6]]+R[e[t+7]]+"-"+R[e[t+8]]+R[e[t+9]]+"-"+R[e[t+10]]+R[e[t+11]]+R[e[t+12]]+R[e[t+13]]+R[e[t+14]]+R[e[t+15]]}function ci(e,t=0){let r=de(e,t);if(!ne(r))throw TypeError("Stringified UUID is invalid");return r}var R,Ir,we=Z(()=>{be();R=[];for(let e=0;e<256;++e)R.push((e+256).toString(16).slice(1));Ir=ci});function li(e,t,r){let n=t&&r||0,i=t||new Array(16);e=e||{};let u=e.node||_r,s=e.clockseq!==void 0?e.clockseq:ct;if(u==null||s==null){let v=e.random||(e.rng||$e)();u==null&&(u=_r=[v[0]|1,v[1],v[2],v[3],v[4],v[5]]),s==null&&(s=ct=(v[6]<<8|v[7])&16383)}let f=e.msecs!==void 0?e.msecs:Date.now(),w=e.nsecs!==void 0?e.nsecs:dt+1,g=f-lt+(w-dt)/1e4;if(g<0&&e.clockseq===void 0&&(s=s+1&16383),(g<0||f>lt)&&e.nsecs===void 0&&(w=0),w>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");lt=f,dt=w,ct=s,f+=122192928e5;let l=((f&268435455)*1e4+w)%4294967296;i[n++]=l>>>24&255,i[n++]=l>>>16&255,i[n++]=l>>>8&255,i[n++]=l&255;let x=f/4294967296*1e4&268435455;i[n++]=x>>>8&255,i[n++]=x&255,i[n++]=x>>>24&15|16,i[n++]=x>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(let v=0;v<6;++v)i[n+v]=u[v];return t||de(i)}var _r,ct,lt,dt,Wr,Fr=Z(()=>{at();we();lt=0,dt=0;Wr=li});function di(e){if(!ne(e))throw TypeError("Invalid UUID");let t,r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=t&255,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=t&255,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=t&255,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=t&255,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=t&255,r}var Te,ht=Z(()=>{be();Te=di});function hi(e){e=unescape(encodeURIComponent(e));let t=[];for(let r=0;r{we();ht();pi="6ba7b810-9dad-11d1-80b4-00c04fd430c8",mi="6ba7b811-9dad-11d1-80b4-00c04fd430c8"});function gi(e){return Array.isArray(e)?e=Buffer.from(e):typeof e=="string"&&(e=Buffer.from(e,"utf8")),Hr.default.createHash("md5").update(e).digest()}var Hr,Br,Lr=Z(()=>{Hr=Ne(fe("crypto"));Br=gi});var yi,zr,Pr=Z(()=>{pt();Lr();yi=Oe("v3",48,Br),zr=yi});var Rr,mt,Jr=Z(()=>{Rr=Ne(fe("crypto")),mt={randomUUID:Rr.default.randomUUID}});function vi(e,t,r){if(mt.randomUUID&&!t&&!e)return mt.randomUUID();e=e||{};let n=e.random||(e.rng||$e)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let i=0;i<16;++i)t[r+i]=n[i];return t}return de(n)}var Gr,Zr=Z(()=>{Jr();at();we();Gr=vi});function $i(e){return Array.isArray(e)?e=Buffer.from(e):typeof e=="string"&&(e=Buffer.from(e,"utf8")),Vr.default.createHash("sha1").update(e).digest()}var Vr,Qr,Xr=Z(()=>{Vr=Ne(fe("crypto"));Qr=$i});var bi,Kr,en=Z(()=>{pt();Xr();bi=Oe("v5",80,Qr),Kr=bi});var tn,rn=Z(()=>{tn="00000000-0000-0000-0000-000000000000"});function wi(e){if(!ne(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)}var nn,un=Z(()=>{be();nn=wi});var sn={};yt(sn,{NIL:()=>tn,parse:()=>Te,stringify:()=>Ir,v1:()=>Wr,v3:()=>zr,v4:()=>Gr,v5:()=>Kr,validate:()=>ne,version:()=>nn});var fn=Z(()=>{Fr();Pr();Zr();en();rn();un();be();we();ht()});var an=U((Wu,on)=>{var Oi=(fn(),$t(sn)),xi=on.exports;xi.uuid=function(){return Oi.v4()}});var dn=U((Fu,gt)=>{var{date:Si,duration:Ni}=Dt(),Mi={math:Rt(),array:ke(),number:nr(),url:ur(),string:or(),comparison:br(),object:Dr(),regex:qr(),uuid:an()},ln=["sortBy"];gt.exports.helpersToRemoveForJs=ln;var cn={date:Si,duration:Ni},ie;gt.exports.getJsHelperList=()=>{if(ie)return ie;ie={};for(let e of Object.values(Mi))for(let[t,r]of Object.entries(e))ie[t]=(...n)=>r(...n,{});for(let e of Object.keys(cn))ie[e]=cn[e];for(let e of ln)delete ie[e];return Object.freeze(ie),ie}});var ki={};yt(ki,{default:()=>Ai});var{getJsHelperList:ji}=dn(),Ai={...ji(),stripProtocol:helpersStripProtocol};return $t(ki);})(); /*! Bundled license information: is-buffer/index.js: diff --git a/packages/server/src/jsRunner/bundles/index-helpers.ts b/packages/server/src/jsRunner/bundles/index-helpers.ts index 91b9c8e821..a8992294a9 100644 --- a/packages/server/src/jsRunner/bundles/index-helpers.ts +++ b/packages/server/src/jsRunner/bundles/index-helpers.ts @@ -2,7 +2,7 @@ const { getJsHelperList, } = require("../../../../string-templates/src/helpers/list.js") -export const helpers = { +export default { ...getJsHelperList(), // pointing stripProtocol to a unexisting function to be able to declare it on isolated-vm // @ts-ignore diff --git a/packages/server/src/jsRunner/vm/index.ts b/packages/server/src/jsRunner/vm/index.ts index 1b1135e1f7..e36d5d595d 100644 --- a/packages/server/src/jsRunner/vm/index.ts +++ b/packages/server/src/jsRunner/vm/index.ts @@ -73,6 +73,10 @@ export class IsolatedVM implements VM { escape: querystring.escape, }) + const cryptoModule = this.registerCallbacks({ + randomUUID: crypto.randomUUID, + }) + this.addToContext({ helpersStripProtocol: new ivm.Callback((str: string) => { var parsed = url.parse(str) as any @@ -81,10 +85,6 @@ export class IsolatedVM implements VM { }), }) - const cryptoModule = this.registerCallbacks({ - randomUUID: crypto.randomUUID, - }) - const injectedRequire = `const require=function req(val) { switch (val) { case "url": return ${urlModule}; @@ -93,7 +93,9 @@ export class IsolatedVM implements VM { } }` const helpersSource = loadBundle(BundleType.HELPERS) - this.moduleHandler.registerModule(`${injectedRequire};${helpersSource}`) + this.moduleHandler.registerModule( + `${injectedRequire};${helpersSource};helpers=helpers.default` + ) return this }