UNPKG

@mochabug/adapt-web

Version:

Browser client library for Adapt automation platform

1,595 lines (1,580 loc) 621 kB
var __MbAdapt_prev = typeof MbAdapt !== 'undefined' ? MbAdapt : undefined; "use strict"; var MbAdapt = (() => { var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; 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); // src/umd-entry.ts var umd_entry_exports = {}; __export(umd_entry_exports, { AdaptAutomationElement: () => AdaptAutomationElement, FloatingToolbar: () => FloatingToolbar, ForkGroupActions: () => ForkGroupActions, IframePanelComponent: () => IframePanelComponent, MinimizeManager: () => MinimizeManager, PanelManager: () => PanelManager, WebClient: () => AdaptWebClient, clearPersistedState: () => clearPersistedState, configure: () => configure, createConnectClient: () => createConnectClient, resetConfig: () => resetConfig, resolveTheme: () => resolveTheme }); // ../node_modules/@bufbuild/protobuf/dist/esm/is-message.js function isMessage(arg, schema) { const isMessage2 = arg !== null && typeof arg == "object" && "$typeName" in arg && typeof arg.$typeName == "string"; if (!isMessage2) { return false; } if (schema === void 0) { return true; } return schema.typeName === arg.$typeName; } // ../node_modules/@bufbuild/protobuf/dist/esm/descriptors.js var ScalarType; (function(ScalarType2) { ScalarType2[ScalarType2["DOUBLE"] = 1] = "DOUBLE"; ScalarType2[ScalarType2["FLOAT"] = 2] = "FLOAT"; ScalarType2[ScalarType2["INT64"] = 3] = "INT64"; ScalarType2[ScalarType2["UINT64"] = 4] = "UINT64"; ScalarType2[ScalarType2["INT32"] = 5] = "INT32"; ScalarType2[ScalarType2["FIXED64"] = 6] = "FIXED64"; ScalarType2[ScalarType2["FIXED32"] = 7] = "FIXED32"; ScalarType2[ScalarType2["BOOL"] = 8] = "BOOL"; ScalarType2[ScalarType2["STRING"] = 9] = "STRING"; ScalarType2[ScalarType2["BYTES"] = 12] = "BYTES"; ScalarType2[ScalarType2["UINT32"] = 13] = "UINT32"; ScalarType2[ScalarType2["SFIXED32"] = 15] = "SFIXED32"; ScalarType2[ScalarType2["SFIXED64"] = 16] = "SFIXED64"; ScalarType2[ScalarType2["SINT32"] = 17] = "SINT32"; ScalarType2[ScalarType2["SINT64"] = 18] = "SINT64"; })(ScalarType || (ScalarType = {})); // ../node_modules/@bufbuild/protobuf/dist/esm/wire/varint.js function varint64read() { let lowBits = 0; let highBits = 0; for (let shift = 0; shift < 28; shift += 7) { let b = this.buf[this.pos++]; lowBits |= (b & 127) << shift; if ((b & 128) == 0) { this.assertBounds(); return [lowBits, highBits]; } } let middleByte = this.buf[this.pos++]; lowBits |= (middleByte & 15) << 28; highBits = (middleByte & 112) >> 4; if ((middleByte & 128) == 0) { this.assertBounds(); return [lowBits, highBits]; } for (let shift = 3; shift <= 31; shift += 7) { let b = this.buf[this.pos++]; highBits |= (b & 127) << shift; if ((b & 128) == 0) { this.assertBounds(); return [lowBits, highBits]; } } throw new Error("invalid varint"); } function varint64write(lo, hi, bytes) { for (let i = 0; i < 28; i = i + 7) { const shift = lo >>> i; const hasNext = !(shift >>> 7 == 0 && hi == 0); const byte = (hasNext ? shift | 128 : shift) & 255; bytes.push(byte); if (!hasNext) { return; } } const splitBits = lo >>> 28 & 15 | (hi & 7) << 4; const hasMoreBits = !(hi >> 3 == 0); bytes.push((hasMoreBits ? splitBits | 128 : splitBits) & 255); if (!hasMoreBits) { return; } for (let i = 3; i < 31; i = i + 7) { const shift = hi >>> i; const hasNext = !(shift >>> 7 == 0); const byte = (hasNext ? shift | 128 : shift) & 255; bytes.push(byte); if (!hasNext) { return; } } bytes.push(hi >>> 31 & 1); } var TWO_PWR_32_DBL = 4294967296; function int64FromString(dec) { const minus = dec[0] === "-"; if (minus) { dec = dec.slice(1); } const base = 1e6; let lowBits = 0; let highBits = 0; function add1e6digit(begin, end) { const digit1e6 = Number(dec.slice(begin, end)); highBits *= base; lowBits = lowBits * base + digit1e6; if (lowBits >= TWO_PWR_32_DBL) { highBits = highBits + (lowBits / TWO_PWR_32_DBL | 0); lowBits = lowBits % TWO_PWR_32_DBL; } } add1e6digit(-24, -18); add1e6digit(-18, -12); add1e6digit(-12, -6); add1e6digit(-6); return minus ? negate(lowBits, highBits) : newBits(lowBits, highBits); } function int64ToString(lo, hi) { let bits = newBits(lo, hi); const negative = bits.hi & 2147483648; if (negative) { bits = negate(bits.lo, bits.hi); } const result = uInt64ToString(bits.lo, bits.hi); return negative ? "-" + result : result; } function uInt64ToString(lo, hi) { ({ lo, hi } = toUnsigned(lo, hi)); if (hi <= 2097151) { return String(TWO_PWR_32_DBL * hi + lo); } const low = lo & 16777215; const mid = (lo >>> 24 | hi << 8) & 16777215; const high = hi >> 16 & 65535; let digitA = low + mid * 6777216 + high * 6710656; let digitB = mid + high * 8147497; let digitC = high * 2; const base = 1e7; if (digitA >= base) { digitB += Math.floor(digitA / base); digitA %= base; } if (digitB >= base) { digitC += Math.floor(digitB / base); digitB %= base; } return digitC.toString() + decimalFrom1e7WithLeadingZeros(digitB) + decimalFrom1e7WithLeadingZeros(digitA); } function toUnsigned(lo, hi) { return { lo: lo >>> 0, hi: hi >>> 0 }; } function newBits(lo, hi) { return { lo: lo | 0, hi: hi | 0 }; } function negate(lowBits, highBits) { highBits = ~highBits; if (lowBits) { lowBits = ~lowBits + 1; } else { highBits += 1; } return newBits(lowBits, highBits); } var decimalFrom1e7WithLeadingZeros = (digit1e7) => { const partial = String(digit1e7); return "0000000".slice(partial.length) + partial; }; function varint32write(value, bytes) { if (value >= 0) { while (value > 127) { bytes.push(value & 127 | 128); value = value >>> 7; } bytes.push(value); } else { for (let i = 0; i < 9; i++) { bytes.push(value & 127 | 128); value = value >> 7; } bytes.push(1); } } function varint32read() { let b = this.buf[this.pos++]; let result = b & 127; if ((b & 128) == 0) { this.assertBounds(); return result; } b = this.buf[this.pos++]; result |= (b & 127) << 7; if ((b & 128) == 0) { this.assertBounds(); return result; } b = this.buf[this.pos++]; result |= (b & 127) << 14; if ((b & 128) == 0) { this.assertBounds(); return result; } b = this.buf[this.pos++]; result |= (b & 127) << 21; if ((b & 128) == 0) { this.assertBounds(); return result; } b = this.buf[this.pos++]; result |= (b & 15) << 28; for (let readBytes = 5; (b & 128) !== 0 && readBytes < 10; readBytes++) b = this.buf[this.pos++]; if ((b & 128) != 0) throw new Error("invalid varint"); this.assertBounds(); return result >>> 0; } // ../node_modules/@bufbuild/protobuf/dist/esm/proto-int64.js var protoInt64 = makeInt64Support(); function makeInt64Support() { const dv = new DataView(new ArrayBuffer(8)); const ok = typeof BigInt === "function" && typeof dv.getBigInt64 === "function" && typeof dv.getBigUint64 === "function" && typeof dv.setBigInt64 === "function" && typeof dv.setBigUint64 === "function" && (!!globalThis.Deno || !!globalThis.Bun || typeof process != "object" || typeof process.env != "object" || process.env.BUF_BIGINT_DISABLE !== "1"); if (ok) { const MIN = BigInt("-9223372036854775808"); const MAX = BigInt("9223372036854775807"); const UMIN = BigInt("0"); const UMAX = BigInt("18446744073709551615"); return { zero: BigInt(0), supported: true, parse(value) { const bi = typeof value == "bigint" ? value : BigInt(value); if (bi > MAX || bi < MIN) { throw new Error(`invalid int64: ${value}`); } return bi; }, uParse(value) { const bi = typeof value == "bigint" ? value : BigInt(value); if (bi > UMAX || bi < UMIN) { throw new Error(`invalid uint64: ${value}`); } return bi; }, enc(value) { dv.setBigInt64(0, this.parse(value), true); return { lo: dv.getInt32(0, true), hi: dv.getInt32(4, true) }; }, uEnc(value) { dv.setBigInt64(0, this.uParse(value), true); return { lo: dv.getInt32(0, true), hi: dv.getInt32(4, true) }; }, dec(lo, hi) { dv.setInt32(0, lo, true); dv.setInt32(4, hi, true); return dv.getBigInt64(0, true); }, uDec(lo, hi) { dv.setInt32(0, lo, true); dv.setInt32(4, hi, true); return dv.getBigUint64(0, true); } }; } return { zero: "0", supported: false, parse(value) { if (typeof value != "string") { value = value.toString(); } assertInt64String(value); return value; }, uParse(value) { if (typeof value != "string") { value = value.toString(); } assertUInt64String(value); return value; }, enc(value) { if (typeof value != "string") { value = value.toString(); } assertInt64String(value); return int64FromString(value); }, uEnc(value) { if (typeof value != "string") { value = value.toString(); } assertUInt64String(value); return int64FromString(value); }, dec(lo, hi) { return int64ToString(lo, hi); }, uDec(lo, hi) { return uInt64ToString(lo, hi); } }; } function assertInt64String(value) { if (!/^-?[0-9]+$/.test(value)) { throw new Error("invalid int64: " + value); } } function assertUInt64String(value) { if (!/^[0-9]+$/.test(value)) { throw new Error("invalid uint64: " + value); } } // ../node_modules/@bufbuild/protobuf/dist/esm/reflect/scalar.js function scalarZeroValue(type, longAsString) { switch (type) { case ScalarType.STRING: return ""; case ScalarType.BOOL: return false; case ScalarType.DOUBLE: case ScalarType.FLOAT: return 0; case ScalarType.INT64: case ScalarType.UINT64: case ScalarType.SFIXED64: case ScalarType.FIXED64: case ScalarType.SINT64: return longAsString ? "0" : protoInt64.zero; case ScalarType.BYTES: return new Uint8Array(0); default: return 0; } } function isScalarZeroValue(type, value) { switch (type) { case ScalarType.BOOL: return value === false; case ScalarType.STRING: return value === ""; case ScalarType.BYTES: return value instanceof Uint8Array && !value.byteLength; case ScalarType.DOUBLE: case ScalarType.FLOAT: return Object.is(value, 0); default: return value == 0; } } // ../node_modules/@bufbuild/protobuf/dist/esm/reflect/unsafe.js var IMPLICIT = 2; var unsafeLocal = /* @__PURE__ */ Symbol.for("reflect unsafe local"); function unsafeOneofCase(target, oneof2) { const c = target[oneof2.localName].case; if (c === void 0) { return c; } return oneof2.fields.find((f) => f.localName === c); } function unsafeIsSet(target, field2) { const name = field2.localName; if (field2.oneof) { return target[field2.oneof.localName].case === name; } if (field2.presence != IMPLICIT) { return target[name] !== void 0 && Object.prototype.hasOwnProperty.call(target, name); } switch (field2.fieldKind) { case "list": return target[name].length > 0; case "map": return Object.keys(target[name]).length > 0; case "scalar": return !isScalarZeroValue(field2.scalar, target[name]); case "enum": return target[name] !== field2.enum.values[0].number; } throw new Error("message field with implicit presence"); } function unsafeIsSetExplicit(target, localName) { return Object.prototype.hasOwnProperty.call(target, localName) && target[localName] !== void 0; } function unsafeGet(target, field2) { if (field2.oneof) { const oneof2 = target[field2.oneof.localName]; if (oneof2.case === field2.localName) { return oneof2.value; } return void 0; } return target[field2.localName]; } function unsafeSet(target, field2, value) { if (field2.oneof) { target[field2.oneof.localName] = { case: field2.localName, value }; } else { target[field2.localName] = value; } } function unsafeClear(target, field2) { const name = field2.localName; if (field2.oneof) { const oneofLocalName = field2.oneof.localName; if (target[oneofLocalName].case === name) { target[oneofLocalName] = { case: void 0 }; } } else if (field2.presence != IMPLICIT) { delete target[name]; } else { switch (field2.fieldKind) { case "map": target[name] = {}; break; case "list": target[name] = []; break; case "enum": target[name] = field2.enum.values[0].number; break; case "scalar": target[name] = scalarZeroValue(field2.scalar, field2.longAsString); break; } } } // ../node_modules/@bufbuild/protobuf/dist/esm/reflect/guard.js function isObject(arg) { return arg !== null && typeof arg == "object" && !Array.isArray(arg); } function isReflectList(arg, field2) { var _a, _b, _c, _d; if (isObject(arg) && unsafeLocal in arg && "add" in arg && "field" in arg && typeof arg.field == "function") { if (field2 !== void 0) { const a = field2; const b = arg.field(); return a.listKind == b.listKind && a.scalar === b.scalar && ((_a = a.message) === null || _a === void 0 ? void 0 : _a.typeName) === ((_b = b.message) === null || _b === void 0 ? void 0 : _b.typeName) && ((_c = a.enum) === null || _c === void 0 ? void 0 : _c.typeName) === ((_d = b.enum) === null || _d === void 0 ? void 0 : _d.typeName); } return true; } return false; } function isReflectMap(arg, field2) { var _a, _b, _c, _d; if (isObject(arg) && unsafeLocal in arg && "has" in arg && "field" in arg && typeof arg.field == "function") { if (field2 !== void 0) { const a = field2, b = arg.field(); return a.mapKey === b.mapKey && a.mapKind == b.mapKind && a.scalar === b.scalar && ((_a = a.message) === null || _a === void 0 ? void 0 : _a.typeName) === ((_b = b.message) === null || _b === void 0 ? void 0 : _b.typeName) && ((_c = a.enum) === null || _c === void 0 ? void 0 : _c.typeName) === ((_d = b.enum) === null || _d === void 0 ? void 0 : _d.typeName); } return true; } return false; } function isReflectMessage(arg, messageDesc2) { return isObject(arg) && unsafeLocal in arg && "desc" in arg && isObject(arg.desc) && arg.desc.kind === "message" && (messageDesc2 === void 0 || arg.desc.typeName == messageDesc2.typeName); } // ../node_modules/@bufbuild/protobuf/dist/esm/wkt/wrappers.js function isWrapper(arg) { return isWrapperTypeName(arg.$typeName); } function isWrapperDesc(messageDesc2) { const f = messageDesc2.fields[0]; return isWrapperTypeName(messageDesc2.typeName) && f !== void 0 && f.fieldKind == "scalar" && f.name == "value" && f.number == 1; } function hasCustomJsonRepresentation(desc) { switch (desc.typeName) { case "google.protobuf.Any": case "google.protobuf.Timestamp": case "google.protobuf.Duration": case "google.protobuf.FieldMask": case "google.protobuf.Struct": case "google.protobuf.Value": case "google.protobuf.ListValue": return true; default: return isWrapperDesc(desc); } } function isWrapperTypeName(name) { return name.startsWith("google.protobuf.") && [ "DoubleValue", "FloatValue", "Int64Value", "UInt64Value", "Int32Value", "UInt32Value", "BoolValue", "StringValue", "BytesValue" ].includes(name.substring(16)); } // ../node_modules/@bufbuild/protobuf/dist/esm/create.js var EDITION_PROTO3 = 999; var EDITION_PROTO2 = 998; var IMPLICIT2 = 2; function create(schema, init) { if (isMessage(init, schema)) { return init; } const message2 = createZeroMessage(schema); if (init !== void 0) { initMessage(schema, message2, init); } return message2; } function initMessage(messageDesc2, message2, init) { for (const member of messageDesc2.members) { let value = init[member.localName]; if (value == null) { continue; } let field2; if (member.kind == "oneof") { const oneofField = unsafeOneofCase(init, member); if (!oneofField) { continue; } field2 = oneofField; value = unsafeGet(init, oneofField); } else { field2 = member; } switch (field2.fieldKind) { case "message": value = toMessage(field2, value); break; case "scalar": value = initScalar(field2, value); break; case "list": value = initList(field2, value); break; case "map": value = initMap(field2, value); break; } unsafeSet(message2, field2, value); } return message2; } function initScalar(field2, value) { if (field2.scalar == ScalarType.BYTES) { return toU8Arr(value); } return value; } function initMap(field2, value) { if (isObject(value)) { if (field2.scalar == ScalarType.BYTES) { return convertObjectValues(value, toU8Arr); } if (field2.mapKind == "message") { return convertObjectValues(value, (val) => toMessage(field2, val)); } } return value; } function initList(field2, value) { if (Array.isArray(value)) { if (field2.scalar == ScalarType.BYTES) { return value.map(toU8Arr); } if (field2.listKind == "message") { return value.map((item) => toMessage(field2, item)); } } return value; } function toMessage(field2, value) { if (field2.fieldKind == "message" && !field2.oneof && isWrapperDesc(field2.message)) { return initScalar(field2.message.fields[0], value); } if (isObject(value)) { if (field2.message.typeName == "google.protobuf.Struct" && field2.parent.typeName !== "google.protobuf.Value") { return value; } if (!isMessage(value, field2.message)) { return create(field2.message, value); } } return value; } function toU8Arr(value) { return Array.isArray(value) ? new Uint8Array(value) : value; } function convertObjectValues(obj, fn) { const ret = {}; for (const entry of Object.entries(obj)) { ret[entry[0]] = fn(entry[1]); } return ret; } var tokenZeroMessageField = /* @__PURE__ */ Symbol(); var messagePrototypes = /* @__PURE__ */ new WeakMap(); function createZeroMessage(desc) { let msg; if (!needsPrototypeChain(desc)) { msg = { $typeName: desc.typeName }; for (const member of desc.members) { if (member.kind == "oneof" || member.presence == IMPLICIT2) { msg[member.localName] = createZeroField(member); } } } else { const cached = messagePrototypes.get(desc); let prototype; let members; if (cached) { ({ prototype, members } = cached); } else { prototype = {}; members = /* @__PURE__ */ new Set(); for (const member of desc.members) { if (member.kind == "oneof") { continue; } if (member.fieldKind != "scalar" && member.fieldKind != "enum") { continue; } if (member.presence == IMPLICIT2) { continue; } members.add(member); prototype[member.localName] = createZeroField(member); } messagePrototypes.set(desc, { prototype, members }); } msg = Object.create(prototype); msg.$typeName = desc.typeName; for (const member of desc.members) { if (members.has(member)) { continue; } if (member.kind == "field") { if (member.fieldKind == "message") { continue; } if (member.fieldKind == "scalar" || member.fieldKind == "enum") { if (member.presence != IMPLICIT2) { continue; } } } msg[member.localName] = createZeroField(member); } } return msg; } function needsPrototypeChain(desc) { switch (desc.file.edition) { case EDITION_PROTO3: return false; case EDITION_PROTO2: return true; default: return desc.fields.some((f) => f.presence != IMPLICIT2 && f.fieldKind != "message" && !f.oneof); } } function createZeroField(field2) { if (field2.kind == "oneof") { return { case: void 0 }; } if (field2.fieldKind == "list") { return []; } if (field2.fieldKind == "map") { return {}; } if (field2.fieldKind == "message") { return tokenZeroMessageField; } const defaultValue = field2.getDefaultValue(); if (defaultValue !== void 0) { return field2.fieldKind == "scalar" && field2.longAsString ? defaultValue.toString() : defaultValue; } return field2.fieldKind == "scalar" ? scalarZeroValue(field2.scalar, field2.longAsString) : field2.enum.values[0].number; } // ../node_modules/@bufbuild/protobuf/dist/esm/reflect/error.js var errorNames = [ "FieldValueInvalidError", "FieldListRangeError", "ForeignFieldError" ]; var FieldError = class extends Error { constructor(fieldOrOneof, message2, name = "FieldValueInvalidError") { super(message2); this.name = name; this.field = () => fieldOrOneof; } }; function isFieldError(arg) { return arg instanceof Error && errorNames.includes(arg.name) && "field" in arg && typeof arg.field == "function"; } // ../node_modules/@bufbuild/protobuf/dist/esm/wire/text-encoding.js var symbol = /* @__PURE__ */ Symbol.for("@bufbuild/protobuf/text-encoding"); function getTextEncoding() { if (globalThis[symbol] == void 0) { const te = new globalThis.TextEncoder(); const td = new globalThis.TextDecoder(); let tdStrict; globalThis[symbol] = { encodeUtf8(text) { return te.encode(text); }, decodeUtf8(bytes, strict) { if (strict) { if (tdStrict === void 0) { tdStrict = new globalThis.TextDecoder("utf-8", { fatal: true }); } return tdStrict.decode(bytes); } return td.decode(bytes); }, checkUtf8(text) { try { encodeURIComponent(text); return true; } catch (_) { return false; } } }; } return globalThis[symbol]; } // ../node_modules/@bufbuild/protobuf/dist/esm/wire/binary-encoding.js var WireType; (function(WireType2) { WireType2[WireType2["Varint"] = 0] = "Varint"; WireType2[WireType2["Bit64"] = 1] = "Bit64"; WireType2[WireType2["LengthDelimited"] = 2] = "LengthDelimited"; WireType2[WireType2["StartGroup"] = 3] = "StartGroup"; WireType2[WireType2["EndGroup"] = 4] = "EndGroup"; WireType2[WireType2["Bit32"] = 5] = "Bit32"; })(WireType || (WireType = {})); var FLOAT32_MAX = 34028234663852886e22; var FLOAT32_MIN = -34028234663852886e22; var UINT32_MAX = 4294967295; var INT32_MAX = 2147483647; var INT32_MIN = -2147483648; var BinaryWriter = class { constructor(encodeUtf8 = getTextEncoding().encodeUtf8) { this.encodeUtf8 = encodeUtf8; this.stack = []; this.chunks = []; this.buf = []; } /** * Return all bytes written and reset this writer. */ finish() { if (this.buf.length) { this.chunks.push(new Uint8Array(this.buf)); this.buf = []; } let len = 0; for (let i = 0; i < this.chunks.length; i++) len += this.chunks[i].length; let bytes = new Uint8Array(len); let offset = 0; for (let i = 0; i < this.chunks.length; i++) { bytes.set(this.chunks[i], offset); offset += this.chunks[i].length; } this.chunks = []; return bytes; } /** * Start a new fork for length-delimited data like a message * or a packed repeated field. * * Must be joined later with `join()`. */ fork() { this.stack.push({ chunks: this.chunks, buf: this.buf }); this.chunks = []; this.buf = []; return this; } /** * Join the last fork. Write its length and bytes, then * return to the previous state. */ join() { let chunk = this.finish(); let prev = this.stack.pop(); if (!prev) throw new Error("invalid state, fork stack empty"); this.chunks = prev.chunks; this.buf = prev.buf; this.uint32(chunk.byteLength); return this.raw(chunk); } /** * Writes a tag (field number and wire type). * * Equivalent to `uint32( (fieldNo << 3 | type) >>> 0 )`. * * Generated code should compute the tag ahead of time and call `uint32()`. */ tag(fieldNo, type) { return this.uint32((fieldNo << 3 | type) >>> 0); } /** * Write a chunk of raw bytes. */ raw(chunk) { if (this.buf.length) { this.chunks.push(new Uint8Array(this.buf)); this.buf = []; } this.chunks.push(chunk); return this; } /** * Write a `uint32` value, an unsigned 32 bit varint. */ uint32(value) { assertUInt32(value); while (value > 127) { this.buf.push(value & 127 | 128); value = value >>> 7; } this.buf.push(value); return this; } /** * Write a `int32` value, a signed 32 bit varint. */ int32(value) { assertInt32(value); varint32write(value, this.buf); return this; } /** * Write a `bool` value, a varint. */ bool(value) { this.buf.push(value ? 1 : 0); return this; } /** * Write a `bytes` value, length-delimited arbitrary data. */ bytes(value) { this.uint32(value.byteLength); return this.raw(value); } /** * Write a `string` value, length-delimited data converted to UTF-8 text. */ string(value) { let chunk = this.encodeUtf8(value); this.uint32(chunk.byteLength); return this.raw(chunk); } /** * Write a `float` value, 32-bit floating point number. */ float(value) { assertFloat32(value); let chunk = new Uint8Array(4); new DataView(chunk.buffer).setFloat32(0, value, true); return this.raw(chunk); } /** * Write a `double` value, a 64-bit floating point number. */ double(value) { let chunk = new Uint8Array(8); new DataView(chunk.buffer).setFloat64(0, value, true); return this.raw(chunk); } /** * Write a `fixed32` value, an unsigned, fixed-length 32-bit integer. */ fixed32(value) { assertUInt32(value); let chunk = new Uint8Array(4); new DataView(chunk.buffer).setUint32(0, value, true); return this.raw(chunk); } /** * Write a `sfixed32` value, a signed, fixed-length 32-bit integer. */ sfixed32(value) { assertInt32(value); let chunk = new Uint8Array(4); new DataView(chunk.buffer).setInt32(0, value, true); return this.raw(chunk); } /** * Write a `sint32` value, a signed, zigzag-encoded 32-bit varint. */ sint32(value) { assertInt32(value); value = (value << 1 ^ value >> 31) >>> 0; varint32write(value, this.buf); return this; } /** * Write a `sfixed64` value, a signed, fixed-length 64-bit integer. */ sfixed64(value) { let chunk = new Uint8Array(8), view = new DataView(chunk.buffer), tc = protoInt64.enc(value); view.setInt32(0, tc.lo, true); view.setInt32(4, tc.hi, true); return this.raw(chunk); } /** * Write a `fixed64` value, an unsigned, fixed-length 64 bit integer. */ fixed64(value) { let chunk = new Uint8Array(8), view = new DataView(chunk.buffer), tc = protoInt64.uEnc(value); view.setInt32(0, tc.lo, true); view.setInt32(4, tc.hi, true); return this.raw(chunk); } /** * Write a `int64` value, a signed 64-bit varint. */ int64(value) { let tc = protoInt64.enc(value); varint64write(tc.lo, tc.hi, this.buf); return this; } /** * Write a `sint64` value, a signed, zig-zag-encoded 64-bit varint. */ sint64(value) { const tc = protoInt64.enc(value), sign = tc.hi >> 31, lo = tc.lo << 1 ^ sign, hi = (tc.hi << 1 | tc.lo >>> 31) ^ sign; varint64write(lo, hi, this.buf); return this; } /** * Write a `uint64` value, an unsigned 64-bit varint. */ uint64(value) { const tc = protoInt64.uEnc(value); varint64write(tc.lo, tc.hi, this.buf); return this; } }; var BinaryReader = class { constructor(buf, decodeUtf8 = getTextEncoding().decodeUtf8) { this.decodeUtf8 = decodeUtf8; this.varint64 = varint64read; this.uint32 = varint32read; this.buf = buf; this.len = buf.length; this.pos = 0; this.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength); } /** * Reads a tag - field number and wire type. Tags are uint32 varints; values * that do not fit in uint32 are rejected. */ tag() { const start = this.pos; const tag = this.uint32(); const bytesRead = this.pos - start; if (bytesRead > 5 || bytesRead == 5 && this.buf[this.pos - 1] > 15) { throw new Error("illegal tag: varint overflows uint32"); } const fieldNo = tag >>> 3; const wireType = tag & 7; if (fieldNo <= 0 || wireType > 5) { throw new Error("illegal tag: field no " + fieldNo + " wire type " + wireType); } return [fieldNo, wireType]; } /** * Skip one element and return the skipped data. * * When skipping StartGroup, provide the tags field number to check for * matching field number in the EndGroup tag. Recursion into nested groups * is guarded by the `recursionLimit` argument: When the limit is reached, * this method throws. */ skip(wireType, fieldNo, recursionLimit = 100) { let start = this.pos; switch (wireType) { case WireType.Varint: while (this.buf[this.pos++] & 128) { } break; // @ts-ignore TS7029: Fallthrough case in switch -- ignore instead of expect-error for compiler settings without noFallthroughCasesInSwitch: true case WireType.Bit64: this.pos += 4; case WireType.Bit32: this.pos += 4; break; case WireType.LengthDelimited: let len = this.uint32(); this.pos += len; break; case WireType.StartGroup: if (recursionLimit <= 0) { throw new Error("maximum recursion depth reached"); } for (; ; ) { const [fn, wt] = this.tag(); if (wt === WireType.EndGroup) { if (fieldNo !== void 0 && fn !== fieldNo) { throw new Error("invalid end group tag"); } break; } this.skip(wt, fn, recursionLimit - 1); } break; default: throw new Error("cant skip wire type " + wireType); } this.assertBounds(); return this.buf.subarray(start, this.pos); } /** * Throws error if position in byte array is out of range. */ assertBounds() { if (this.pos > this.len) throw new RangeError("premature EOF"); } /** * Read a `int32` field, a signed 32 bit varint. */ int32() { return this.uint32() | 0; } /** * Read a `sint32` field, a signed, zigzag-encoded 32-bit varint. */ sint32() { let zze = this.uint32(); return zze >>> 1 ^ -(zze & 1); } /** * Read a `int64` field, a signed 64-bit varint. */ int64() { return protoInt64.dec(...this.varint64()); } /** * Read a `uint64` field, an unsigned 64-bit varint. */ uint64() { return protoInt64.uDec(...this.varint64()); } /** * Read a `sint64` field, a signed, zig-zag-encoded 64-bit varint. */ sint64() { let [lo, hi] = this.varint64(); let s = -(lo & 1); lo = (lo >>> 1 | (hi & 1) << 31) ^ s; hi = hi >>> 1 ^ s; return protoInt64.dec(lo, hi); } /** * Read a `bool` field, a variant. */ bool() { let [lo, hi] = this.varint64(); return lo !== 0 || hi !== 0; } /** * Read a `fixed32` field, an unsigned, fixed-length 32-bit integer. */ fixed32() { return this.view.getUint32((this.pos += 4) - 4, true); } /** * Read a `sfixed32` field, a signed, fixed-length 32-bit integer. */ sfixed32() { return this.view.getInt32((this.pos += 4) - 4, true); } /** * Read a `fixed64` field, an unsigned, fixed-length 64 bit integer. */ fixed64() { return protoInt64.uDec(this.sfixed32(), this.sfixed32()); } /** * Read a `fixed64` field, a signed, fixed-length 64-bit integer. */ sfixed64() { return protoInt64.dec(this.sfixed32(), this.sfixed32()); } /** * Read a `float` field, 32-bit floating point number. */ float() { return this.view.getFloat32((this.pos += 4) - 4, true); } /** * Read a `double` field, a 64-bit floating point number. */ double() { return this.view.getFloat64((this.pos += 8) - 8, true); } /** * Read a `bytes` field, length-delimited arbitrary data. */ bytes() { let len = this.uint32(), start = this.pos; this.pos += len; this.assertBounds(); return this.buf.subarray(start, start + len); } /** * Read a `string` field, length-delimited data converted to UTF-8 text. If * `strict` is true, throw on invalid UTF-8 instead of substituting U+FFFD. */ string(strict) { return this.decodeUtf8(this.bytes(), strict); } }; function assertInt32(arg) { if (typeof arg == "string") { arg = Number(arg); } else if (typeof arg != "number") { throw new Error("invalid int32: " + typeof arg); } if (!Number.isInteger(arg) || arg > INT32_MAX || arg < INT32_MIN) throw new Error("invalid int32: " + arg); } function assertUInt32(arg) { if (typeof arg == "string") { arg = Number(arg); } else if (typeof arg != "number") { throw new Error("invalid uint32: " + typeof arg); } if (!Number.isInteger(arg) || arg > UINT32_MAX || arg < 0) throw new Error("invalid uint32: " + arg); } function assertFloat32(arg) { if (typeof arg == "string") { const o = arg; arg = Number(arg); if (Number.isNaN(arg) && o !== "NaN") { throw new Error("invalid float32: " + o); } } else if (typeof arg != "number") { throw new Error("invalid float32: " + typeof arg); } if (Number.isFinite(arg) && (arg > FLOAT32_MAX || arg < FLOAT32_MIN)) throw new Error("invalid float32: " + arg); } // ../node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect-check.js function checkField(field2, value) { const check = field2.fieldKind == "list" ? isReflectList(value, field2) : field2.fieldKind == "map" ? isReflectMap(value, field2) : checkSingular(field2, value); if (check === true) { return void 0; } let reason; switch (field2.fieldKind) { case "list": reason = `expected ${formatReflectList(field2)}, got ${formatVal(value)}`; break; case "map": reason = `expected ${formatReflectMap(field2)}, got ${formatVal(value)}`; break; default: { reason = reasonSingular(field2, value, check); } } return new FieldError(field2, reason); } function checkListItem(field2, index, value) { const check = checkSingular(field2, value); if (check !== true) { return new FieldError(field2, `list item #${index + 1}: ${reasonSingular(field2, value, check)}`); } return void 0; } function checkMapEntry(field2, key, value) { const checkKey = checkScalarValue(key, field2.mapKey); if (checkKey !== true) { return new FieldError(field2, `invalid map key: ${reasonSingular({ scalar: field2.mapKey }, key, checkKey)}`); } const checkVal = checkSingular(field2, value); if (checkVal !== true) { return new FieldError(field2, `map entry ${formatVal(key)}: ${reasonSingular(field2, value, checkVal)}`); } return void 0; } function checkSingular(field2, value) { if (field2.scalar !== void 0) { return checkScalarValue(value, field2.scalar); } if (field2.enum !== void 0) { if (field2.enum.open) { return checkScalarValue(value, ScalarType.INT32); } return field2.enum.values.some((v) => v.number === value); } return isReflectMessage(value, field2.message); } function checkScalarValue(value, scalar) { switch (scalar) { case ScalarType.DOUBLE: return typeof value == "number"; case ScalarType.FLOAT: if (typeof value != "number") { return false; } if (Number.isNaN(value) || !Number.isFinite(value)) { return true; } if (value > FLOAT32_MAX || value < FLOAT32_MIN) { return `${value.toFixed()} out of range`; } return true; case ScalarType.INT32: case ScalarType.SFIXED32: case ScalarType.SINT32: if (typeof value !== "number" || !Number.isInteger(value)) { return false; } if (value > INT32_MAX || value < INT32_MIN) { return `${value.toFixed()} out of range`; } return true; case ScalarType.FIXED32: case ScalarType.UINT32: if (typeof value !== "number" || !Number.isInteger(value)) { return false; } if (value > UINT32_MAX || value < 0) { return `${value.toFixed()} out of range`; } return true; case ScalarType.BOOL: return typeof value == "boolean"; case ScalarType.STRING: if (typeof value != "string") { return false; } return getTextEncoding().checkUtf8(value) || "invalid UTF8"; case ScalarType.BYTES: return value instanceof Uint8Array; case ScalarType.INT64: case ScalarType.SFIXED64: case ScalarType.SINT64: if (typeof value == "bigint" || typeof value == "number" || typeof value == "string" && value.length > 0) { try { protoInt64.parse(value); return true; } catch (_) { return `${value} out of range`; } } return false; case ScalarType.FIXED64: case ScalarType.UINT64: if (typeof value == "bigint" || typeof value == "number" || typeof value == "string" && value.length > 0) { try { protoInt64.uParse(value); return true; } catch (_) { return `${value} out of range`; } } return false; } } function reasonSingular(field2, val, details) { details = typeof details == "string" ? `: ${details}` : `, got ${formatVal(val)}`; if (field2.scalar !== void 0) { return `expected ${scalarTypeDescription(field2.scalar)}` + details; } if (field2.enum !== void 0) { return `expected ${field2.enum.toString()}` + details; } return `expected ${formatReflectMessage(field2.message)}` + details; } function formatVal(val) { switch (typeof val) { case "object": if (val === null) { return "null"; } if (val instanceof Uint8Array) { return `Uint8Array(${val.length})`; } if (Array.isArray(val)) { return `Array(${val.length})`; } if (isReflectList(val)) { return formatReflectList(val.field()); } if (isReflectMap(val)) { return formatReflectMap(val.field()); } if (isReflectMessage(val)) { return formatReflectMessage(val.desc); } if (isMessage(val)) { return `message ${val.$typeName}`; } return "object"; case "string": return val.length > 30 ? "string" : `"${val.split('"').join('\\"')}"`; case "boolean": return String(val); case "number": return String(val); case "bigint": return String(val) + "n"; default: return typeof val; } } function formatReflectMessage(desc) { return `ReflectMessage (${desc.typeName})`; } function formatReflectList(field2) { switch (field2.listKind) { case "message": return `ReflectList (${field2.message.toString()})`; case "enum": return `ReflectList (${field2.enum.toString()})`; case "scalar": return `ReflectList (${ScalarType[field2.scalar]})`; } } function formatReflectMap(field2) { switch (field2.mapKind) { case "message": return `ReflectMap (${ScalarType[field2.mapKey]}, ${field2.message.toString()})`; case "enum": return `ReflectMap (${ScalarType[field2.mapKey]}, ${field2.enum.toString()})`; case "scalar": return `ReflectMap (${ScalarType[field2.mapKey]}, ${ScalarType[field2.scalar]})`; } } function scalarTypeDescription(scalar) { switch (scalar) { case ScalarType.STRING: return "string"; case ScalarType.BOOL: return "boolean"; case ScalarType.INT64: case ScalarType.SINT64: case ScalarType.SFIXED64: return "bigint (int64)"; case ScalarType.UINT64: case ScalarType.FIXED64: return "bigint (uint64)"; case ScalarType.BYTES: return "Uint8Array"; case ScalarType.DOUBLE: return "number (float64)"; case ScalarType.FLOAT: return "number (float32)"; case ScalarType.FIXED32: case ScalarType.UINT32: return "number (uint32)"; case ScalarType.INT32: case ScalarType.SFIXED32: case ScalarType.SINT32: return "number (int32)"; } } // ../node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect.js function reflect(messageDesc2, message2, check = true) { return new ReflectMessageImpl(messageDesc2, message2, check); } var messageSortedFields = /* @__PURE__ */ new WeakMap(); var ReflectMessageImpl = class { get sortedFields() { const cached = messageSortedFields.get(this.desc); if (cached) { return cached; } const sortedFields = this.desc.fields.concat().sort((a, b) => a.number - b.number); messageSortedFields.set(this.desc, sortedFields); return sortedFields; } constructor(messageDesc2, message2, check = true) { this.lists = /* @__PURE__ */ new Map(); this.maps = /* @__PURE__ */ new Map(); this.check = check; this.desc = messageDesc2; this.message = this[unsafeLocal] = message2 !== null && message2 !== void 0 ? message2 : create(messageDesc2); this.fields = messageDesc2.fields; this.oneofs = messageDesc2.oneofs; this.members = messageDesc2.members; } findNumber(number) { if (!this._fieldsByNumber) { this._fieldsByNumber = new Map(this.desc.fields.map((f) => [f.number, f])); } return this._fieldsByNumber.get(number); } oneofCase(oneof2) { assertOwn(this.message, oneof2); return unsafeOneofCase(this.message, oneof2); } isSet(field2) { assertOwn(this.message, field2); return unsafeIsSet(this.message, field2); } clear(field2) { assertOwn(this.message, field2); unsafeClear(this.message, field2); } get(field2) { assertOwn(this.message, field2); const value = unsafeGet(this.message, field2); switch (field2.fieldKind) { case "list": let list = this.lists.get(field2); if (!list || list[unsafeLocal] !== value) { this.lists.set( field2, // biome-ignore lint/suspicious/noAssignInExpressions: no list = new ReflectListImpl(field2, value, this.check) ); } return list; case "map": let map = this.maps.get(field2); if (!map || map[unsafeLocal] !== value) { this.maps.set( field2, // biome-ignore lint/suspicious/noAssignInExpressions: no map = new ReflectMapImpl(field2, value, this.check) ); } return map; case "message": return messageToReflect(field2, value, this.check); case "scalar": return value === void 0 ? scalarZeroValue(field2.scalar, false) : longToReflect(field2, value); case "enum": return value !== null && value !== void 0 ? value : field2.enum.values[0].number; } } set(field2, value) { assertOwn(this.message, field2); if (this.check) { const err = checkField(field2, value); if (err) { throw err; } } let local; if (field2.fieldKind == "message") { local = messageToLocal(field2, value); } else if (isReflectMap(value) || isReflectList(value)) { local = value[unsafeLocal]; } else { local = longToLocal(field2, value); } unsafeSet(this.message, field2, local); } getUnknown() { return this.message.$unknown; } setUnknown(value) { this.message.$unknown = value; } }; function assertOwn(owner, member) { if (member.parent.typeName !== owner.$typeName) { throw new FieldError(member, `cannot use ${member.toString()} with message ${owner.$typeName}`, "ForeignFieldError"); } } var ReflectListImpl = class { field() { return this._field; } get size() { return this._arr.length; } constructor(field2, unsafeInput, check) { this._field = field2; this._arr = this[unsafeLocal] = unsafeInput; this.check = check; } get(index) { const item = this._arr[index]; return item === void 0 ? void 0 : listItemToReflect(this._field, item, this.check); } set(index, item) { if (index < 0 || index >= this._arr.length) { throw new FieldError(this._field, `list item #${index + 1}: out of range`); } if (this.check) { const err = checkListItem(this._field, index, item); if (err) { throw err; } } this._arr[index] = listItemToLocal(this._field, item); } add(item) { if (this.check) { const err = checkListItem(this._field, this._arr.length, item); if (err) { throw err; } } this._arr.push(listItemToLocal(this._field, item)); return void 0; } clear() { this._arr.splice(0, this._arr.length); } [Symbol.iterator]() { return this.values(); } keys() { return this._arr.keys(); } *values() { for (const item of this._arr) { yield listItemToReflect(this._field, item, this.check); } } *entries() { for (let i = 0; i < this._arr.length; i++) { yield [i, listItemToReflect(this._field, this._arr[i], this.check)]; } } }; var ReflectMapImpl = class { constructor(field2, unsafeInput, check = true) { this.obj = this[unsafeLocal] = unsafeInput !== null && unsafeInput !== void 0 ? unsafeInput : {}; this.check = check; this._field = field2; } field() { return this._field; } set(key, value) { if (this.check) { const err = checkMapEntry(this._field,