@bitrix24/b24jssdk
Version:
Bitrix24 REST API JavaScript SDK
1,278 lines (1,275 loc) • 186 kB
JavaScript
/**
* @package @bitrix24/b24jssdk
* @version 1.0.1
* @copyright (c) 2026 Bitrix24
* @license MIT
* @see https://github.com/bitrix24/b24jssdk
* @see https://bitrix24.github.io/b24jssdk/
*/
import { commonjsGlobal } from '../../_virtual/_commonjsHelpers.mjs';
import { __module as protobuf } from '../../_virtual/protobuf2.mjs';
var hasRequiredProtobuf;
function requireProtobuf () {
if (hasRequiredProtobuf) return protobuf.exports;
hasRequiredProtobuf = 1;
(function (module) {
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
(function(undefined$1) {
(/* @__PURE__ */ __name((function prelude(modules, cache, entries) {
function $require(name) {
var $module = cache[name];
if (!$module)
modules[name][0].call($module = cache[name] = { exports: {} }, $require, $module, $module.exports);
return $module.exports;
}
__name($require, "$require");
var protobuf = $require(entries[0]);
if (module && module.exports)
module.exports = protobuf;
}), "prelude"))({ 1: [function(require2, module2, exports$1) {
module2.exports = asPromise;
function asPromise(fn, ctx) {
var params = new Array(arguments.length - 1), offset = 0, index = 2, pending = true;
while (index < arguments.length)
params[offset++] = arguments[index++];
return new Promise(/* @__PURE__ */ __name(function executor(resolve, reject) {
params[offset] = /* @__PURE__ */ __name(function callback(err) {
if (pending) {
pending = false;
if (err)
reject(err);
else {
var params2 = new Array(arguments.length - 1), offset2 = 0;
while (offset2 < params2.length)
params2[offset2++] = arguments[offset2];
resolve.apply(null, params2);
}
}
}, "callback");
try {
fn.apply(ctx || null, params);
} catch (err) {
if (pending) {
pending = false;
reject(err);
}
}
}, "executor"));
}
__name(asPromise, "asPromise");
}, {}], 2: [function(require2, module2, exports$1) {
var base64 = exports$1;
base64.length = /* @__PURE__ */ __name(function length(string) {
var p = string.length;
if (!p)
return 0;
var n = 0;
while (--p % 4 > 1 && string.charAt(p) === "=")
++n;
return Math.ceil(string.length * 3) / 4 - n;
}, "length");
var b64 = new Array(64);
var s64 = new Array(123);
for (var i = 0; i < 64; )
s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++;
base64.encode = /* @__PURE__ */ __name(function encode(buffer, start, end) {
var parts = null, chunk = [];
var i2 = 0, j = 0, t;
while (start < end) {
var b = buffer[start++];
switch (j) {
case 0:
chunk[i2++] = b64[b >> 2];
t = (b & 3) << 4;
j = 1;
break;
case 1:
chunk[i2++] = b64[t | b >> 4];
t = (b & 15) << 2;
j = 2;
break;
case 2:
chunk[i2++] = b64[t | b >> 6];
chunk[i2++] = b64[b & 63];
j = 0;
break;
}
if (i2 > 8191) {
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
i2 = 0;
}
}
if (j) {
chunk[i2++] = b64[t];
chunk[i2++] = 61;
if (j === 1)
chunk[i2++] = 61;
}
if (parts) {
if (i2)
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i2)));
return parts.join("");
}
return String.fromCharCode.apply(String, chunk.slice(0, i2));
}, "encode");
var invalidEncoding = "invalid encoding";
base64.decode = /* @__PURE__ */ __name(function decode(string, buffer, offset) {
var start = offset;
var j = 0, t;
for (var i2 = 0; i2 < string.length; ) {
var c = string.charCodeAt(i2++);
if (c === 61 && j > 1)
break;
if ((c = s64[c]) === undefined$1)
throw Error(invalidEncoding);
switch (j) {
case 0:
t = c;
j = 1;
break;
case 1:
buffer[offset++] = t << 2 | (c & 48) >> 4;
t = c;
j = 2;
break;
case 2:
buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2;
t = c;
j = 3;
break;
case 3:
buffer[offset++] = (t & 3) << 6 | c;
j = 0;
break;
}
}
if (j === 1)
throw Error(invalidEncoding);
return offset - start;
}, "decode");
base64.test = /* @__PURE__ */ __name(function test(string) {
return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string);
}, "test");
}, {}], 3: [function(require2, module2, exports$1) {
module2.exports = codegen;
function codegen(functionParams, functionName) {
if (typeof functionParams === "string") {
functionName = functionParams;
functionParams = undefined$1;
}
var body = [];
function Codegen(formatStringOrScope) {
if (typeof formatStringOrScope !== "string") {
var source = toString();
if (codegen.verbose)
console.log("codegen: " + source);
source = "return " + source;
if (formatStringOrScope) {
var scopeKeys = Object.keys(formatStringOrScope), scopeParams = new Array(scopeKeys.length + 1), scopeValues = new Array(scopeKeys.length), scopeOffset = 0;
while (scopeOffset < scopeKeys.length) {
scopeParams[scopeOffset] = scopeKeys[scopeOffset];
scopeValues[scopeOffset] = formatStringOrScope[scopeKeys[scopeOffset++]];
}
scopeParams[scopeOffset] = source;
return Function.apply(null, scopeParams).apply(null, scopeValues);
}
return Function(source)();
}
var formatParams = new Array(arguments.length - 1), formatOffset = 0;
while (formatOffset < formatParams.length)
formatParams[formatOffset] = arguments[++formatOffset];
formatOffset = 0;
formatStringOrScope = formatStringOrScope.replace(/%([%dfijs])/g, /* @__PURE__ */ __name(function replace($0, $1) {
var value = formatParams[formatOffset++];
switch ($1) {
case "d":
case "f":
return String(Number(value));
case "i":
return String(Math.floor(value));
case "j":
return JSON.stringify(value);
case "s":
return String(value);
}
return "%";
}, "replace"));
if (formatOffset !== formatParams.length)
throw Error("parameter count mismatch");
body.push(formatStringOrScope);
return Codegen;
}
__name(Codegen, "Codegen");
function toString(functionNameOverride) {
return "function " + (functionNameOverride || functionName || "") + "(" + (functionParams && functionParams.join(",") || "") + "){\n " + body.join("\n ") + "\n}";
}
__name(toString, "toString");
Codegen.toString = toString;
return Codegen;
}
__name(codegen, "codegen");
codegen.verbose = false;
}, {}], 4: [function(require2, module2, exports$1) {
module2.exports = EventEmitter;
function EventEmitter() {
this._listeners = {};
}
__name(EventEmitter, "EventEmitter");
EventEmitter.prototype.on = /* @__PURE__ */ __name(function on(evt, fn, ctx) {
(this._listeners[evt] || (this._listeners[evt] = [])).push({
fn,
ctx: ctx || this
});
return this;
}, "on");
EventEmitter.prototype.off = /* @__PURE__ */ __name(function off(evt, fn) {
if (evt === undefined$1)
this._listeners = {};
else {
if (fn === undefined$1)
this._listeners[evt] = [];
else {
var listeners = this._listeners[evt];
for (var i = 0; i < listeners.length; )
if (listeners[i].fn === fn)
listeners.splice(i, 1);
else
++i;
}
}
return this;
}, "off");
EventEmitter.prototype.emit = /* @__PURE__ */ __name(function emit(evt) {
var listeners = this._listeners[evt];
if (listeners) {
var args = [], i = 1;
for (; i < arguments.length; )
args.push(arguments[i++]);
for (i = 0; i < listeners.length; )
listeners[i].fn.apply(listeners[i++].ctx, args);
}
return this;
}, "emit");
}, {}], 5: [function(require2, module2, exports$1) {
module2.exports = fetch;
var asPromise = require2(1), inquire = require2(7);
var fs = inquire("fs");
function fetch(filename, options, callback) {
if (typeof options === "function") {
callback = options;
options = {};
} else if (!options)
options = {};
if (!callback)
return asPromise(fetch, this, filename, options);
if (!options.xhr && fs && fs.readFile)
return fs.readFile(filename, /* @__PURE__ */ __name(function fetchReadFileCallback(err, contents) {
return err && typeof XMLHttpRequest !== "undefined" ? fetch.xhr(filename, options, callback) : err ? callback(err) : callback(null, options.binary ? contents : contents.toString("utf8"));
}, "fetchReadFileCallback"));
return fetch.xhr(filename, options, callback);
}
__name(fetch, "fetch");
fetch.xhr = /* @__PURE__ */ __name(function fetch_xhr(filename, options, callback) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = /* @__PURE__ */ __name(function fetchOnReadyStateChange() {
if (xhr.readyState !== 4)
return undefined$1;
if (xhr.status !== 0 && xhr.status !== 200)
return callback(Error("status " + xhr.status));
if (options.binary) {
var buffer = xhr.response;
if (!buffer) {
buffer = [];
for (var i = 0; i < xhr.responseText.length; ++i)
buffer.push(xhr.responseText.charCodeAt(i) & 255);
}
return callback(null, typeof Uint8Array !== "undefined" ? new Uint8Array(buffer) : buffer);
}
return callback(null, xhr.responseText);
}, "fetchOnReadyStateChange");
if (options.binary) {
if ("overrideMimeType" in xhr)
xhr.overrideMimeType("text/plain; charset=x-user-defined");
xhr.responseType = "arraybuffer";
}
xhr.open("GET", filename);
xhr.send();
}, "fetch_xhr");
}, { "1": 1, "7": 7 }], 6: [function(require2, module2, exports$1) {
module2.exports = factory(factory);
function factory(exports2) {
if (typeof Float32Array !== "undefined") (function() {
var f32 = new Float32Array([-0]), f8b = new Uint8Array(f32.buffer), le = f8b[3] === 128;
function writeFloat_f32_cpy(val, buf, pos) {
f32[0] = val;
buf[pos] = f8b[0];
buf[pos + 1] = f8b[1];
buf[pos + 2] = f8b[2];
buf[pos + 3] = f8b[3];
}
__name(writeFloat_f32_cpy, "writeFloat_f32_cpy");
function writeFloat_f32_rev(val, buf, pos) {
f32[0] = val;
buf[pos] = f8b[3];
buf[pos + 1] = f8b[2];
buf[pos + 2] = f8b[1];
buf[pos + 3] = f8b[0];
}
__name(writeFloat_f32_rev, "writeFloat_f32_rev");
exports2.writeFloatLE = le ? writeFloat_f32_cpy : writeFloat_f32_rev;
exports2.writeFloatBE = le ? writeFloat_f32_rev : writeFloat_f32_cpy;
function readFloat_f32_cpy(buf, pos) {
f8b[0] = buf[pos];
f8b[1] = buf[pos + 1];
f8b[2] = buf[pos + 2];
f8b[3] = buf[pos + 3];
return f32[0];
}
__name(readFloat_f32_cpy, "readFloat_f32_cpy");
function readFloat_f32_rev(buf, pos) {
f8b[3] = buf[pos];
f8b[2] = buf[pos + 1];
f8b[1] = buf[pos + 2];
f8b[0] = buf[pos + 3];
return f32[0];
}
__name(readFloat_f32_rev, "readFloat_f32_rev");
exports2.readFloatLE = le ? readFloat_f32_cpy : readFloat_f32_rev;
exports2.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy;
})();
else (function() {
function writeFloat_ieee754(writeUint, val, buf, pos) {
var sign = val < 0 ? 1 : 0;
if (sign)
val = -val;
if (val === 0)
writeUint(1 / val > 0 ? (
/* positive */
0
) : (
/* negative 0 */
2147483648
), buf, pos);
else if (isNaN(val))
writeUint(2143289344, buf, pos);
else if (val > 34028234663852886e22)
writeUint((sign << 31 | 2139095040) >>> 0, buf, pos);
else if (val < 11754943508222875e-54)
writeUint((sign << 31 | Math.round(val / 1401298464324817e-60)) >>> 0, buf, pos);
else {
var exponent = Math.floor(Math.log(val) / Math.LN2), mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607;
writeUint((sign << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos);
}
}
__name(writeFloat_ieee754, "writeFloat_ieee754");
exports2.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE);
exports2.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE);
function readFloat_ieee754(readUint, buf, pos) {
var uint = readUint(buf, pos), sign = (uint >> 31) * 2 + 1, exponent = uint >>> 23 & 255, mantissa = uint & 8388607;
return exponent === 255 ? mantissa ? NaN : sign * Infinity : exponent === 0 ? sign * 1401298464324817e-60 * mantissa : sign * Math.pow(2, exponent - 150) * (mantissa + 8388608);
}
__name(readFloat_ieee754, "readFloat_ieee754");
exports2.readFloatLE = readFloat_ieee754.bind(null, readUintLE);
exports2.readFloatBE = readFloat_ieee754.bind(null, readUintBE);
})();
if (typeof Float64Array !== "undefined") (function() {
var f64 = new Float64Array([-0]), f8b = new Uint8Array(f64.buffer), le = f8b[7] === 128;
function writeDouble_f64_cpy(val, buf, pos) {
f64[0] = val;
buf[pos] = f8b[0];
buf[pos + 1] = f8b[1];
buf[pos + 2] = f8b[2];
buf[pos + 3] = f8b[3];
buf[pos + 4] = f8b[4];
buf[pos + 5] = f8b[5];
buf[pos + 6] = f8b[6];
buf[pos + 7] = f8b[7];
}
__name(writeDouble_f64_cpy, "writeDouble_f64_cpy");
function writeDouble_f64_rev(val, buf, pos) {
f64[0] = val;
buf[pos] = f8b[7];
buf[pos + 1] = f8b[6];
buf[pos + 2] = f8b[5];
buf[pos + 3] = f8b[4];
buf[pos + 4] = f8b[3];
buf[pos + 5] = f8b[2];
buf[pos + 6] = f8b[1];
buf[pos + 7] = f8b[0];
}
__name(writeDouble_f64_rev, "writeDouble_f64_rev");
exports2.writeDoubleLE = le ? writeDouble_f64_cpy : writeDouble_f64_rev;
exports2.writeDoubleBE = le ? writeDouble_f64_rev : writeDouble_f64_cpy;
function readDouble_f64_cpy(buf, pos) {
f8b[0] = buf[pos];
f8b[1] = buf[pos + 1];
f8b[2] = buf[pos + 2];
f8b[3] = buf[pos + 3];
f8b[4] = buf[pos + 4];
f8b[5] = buf[pos + 5];
f8b[6] = buf[pos + 6];
f8b[7] = buf[pos + 7];
return f64[0];
}
__name(readDouble_f64_cpy, "readDouble_f64_cpy");
function readDouble_f64_rev(buf, pos) {
f8b[7] = buf[pos];
f8b[6] = buf[pos + 1];
f8b[5] = buf[pos + 2];
f8b[4] = buf[pos + 3];
f8b[3] = buf[pos + 4];
f8b[2] = buf[pos + 5];
f8b[1] = buf[pos + 6];
f8b[0] = buf[pos + 7];
return f64[0];
}
__name(readDouble_f64_rev, "readDouble_f64_rev");
exports2.readDoubleLE = le ? readDouble_f64_cpy : readDouble_f64_rev;
exports2.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy;
})();
else (function() {
function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) {
var sign = val < 0 ? 1 : 0;
if (sign)
val = -val;
if (val === 0) {
writeUint(0, buf, pos + off0);
writeUint(1 / val > 0 ? (
/* positive */
0
) : (
/* negative 0 */
2147483648
), buf, pos + off1);
} else if (isNaN(val)) {
writeUint(0, buf, pos + off0);
writeUint(2146959360, buf, pos + off1);
} else if (val > 17976931348623157e292) {
writeUint(0, buf, pos + off0);
writeUint((sign << 31 | 2146435072) >>> 0, buf, pos + off1);
} else {
var mantissa;
if (val < 22250738585072014e-324) {
mantissa = val / 5e-324;
writeUint(mantissa >>> 0, buf, pos + off0);
writeUint((sign << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1);
} else {
var exponent = Math.floor(Math.log(val) / Math.LN2);
if (exponent === 1024)
exponent = 1023;
mantissa = val * Math.pow(2, -exponent);
writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0);
writeUint((sign << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1);
}
}
}
__name(writeDouble_ieee754, "writeDouble_ieee754");
exports2.writeDoubleLE = writeDouble_ieee754.bind(null, writeUintLE, 0, 4);
exports2.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0);
function readDouble_ieee754(readUint, off0, off1, buf, pos) {
var lo = readUint(buf, pos + off0), hi = readUint(buf, pos + off1);
var sign = (hi >> 31) * 2 + 1, exponent = hi >>> 20 & 2047, mantissa = 4294967296 * (hi & 1048575) + lo;
return exponent === 2047 ? mantissa ? NaN : sign * Infinity : exponent === 0 ? sign * 5e-324 * mantissa : sign * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496);
}
__name(readDouble_ieee754, "readDouble_ieee754");
exports2.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4);
exports2.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0);
})();
return exports2;
}
__name(factory, "factory");
function writeUintLE(val, buf, pos) {
buf[pos] = val & 255;
buf[pos + 1] = val >>> 8 & 255;
buf[pos + 2] = val >>> 16 & 255;
buf[pos + 3] = val >>> 24;
}
__name(writeUintLE, "writeUintLE");
function writeUintBE(val, buf, pos) {
buf[pos] = val >>> 24;
buf[pos + 1] = val >>> 16 & 255;
buf[pos + 2] = val >>> 8 & 255;
buf[pos + 3] = val & 255;
}
__name(writeUintBE, "writeUintBE");
function readUintLE(buf, pos) {
return (buf[pos] | buf[pos + 1] << 8 | buf[pos + 2] << 16 | buf[pos + 3] << 24) >>> 0;
}
__name(readUintLE, "readUintLE");
function readUintBE(buf, pos) {
return (buf[pos] << 24 | buf[pos + 1] << 16 | buf[pos + 2] << 8 | buf[pos + 3]) >>> 0;
}
__name(readUintBE, "readUintBE");
}, {}], 7: [function(require2, module2, exports$1) {
module2.exports = inquire;
function inquire(moduleName) {
try {
var mod = require2(moduleName);
if (mod && (mod.length || Object.keys(mod).length))
return mod;
} catch (e) {
}
return null;
}
__name(inquire, "inquire");
}, {}], 8: [function(require2, module2, exports$1) {
var path = exports$1;
var isAbsolute = (
/**
* Tests if the specified path is absolute.
* @param {string} path Path to test
* @returns {boolean} `true` if path is absolute
*/
path.isAbsolute = /* @__PURE__ */ __name(function isAbsolute2(path2) {
return /^(?:\/|\w+:)/.test(path2);
}, "isAbsolute")
);
var normalize = (
/**
* Normalizes the specified path.
* @param {string} path Path to normalize
* @returns {string} Normalized path
*/
path.normalize = /* @__PURE__ */ __name(function normalize2(path2) {
path2 = path2.replace(/\\/g, "/").replace(/\/{2,}/g, "/");
var parts = path2.split("/"), absolute = isAbsolute(path2), prefix = "";
if (absolute)
prefix = parts.shift() + "/";
for (var i = 0; i < parts.length; ) {
if (parts[i] === "..") {
if (i > 0 && parts[i - 1] !== "..")
parts.splice(--i, 2);
else if (absolute)
parts.splice(i, 1);
else
++i;
} else if (parts[i] === ".")
parts.splice(i, 1);
else
++i;
}
return prefix + parts.join("/");
}, "normalize")
);
path.resolve = /* @__PURE__ */ __name(function resolve(originPath, includePath, alreadyNormalized) {
if (!alreadyNormalized)
includePath = normalize(includePath);
if (isAbsolute(includePath))
return includePath;
if (!alreadyNormalized)
originPath = normalize(originPath);
return (originPath = originPath.replace(/(?:\/|^)[^/]+$/, "")).length ? normalize(originPath + "/" + includePath) : includePath;
}, "resolve");
}, {}], 9: [function(require2, module2, exports$1) {
module2.exports = pool;
function pool(alloc, slice, size) {
var SIZE = size || 8192;
var MAX = SIZE >>> 1;
var slab = null;
var offset = SIZE;
return /* @__PURE__ */ __name(function pool_alloc(size2) {
if (size2 < 1 || size2 > MAX)
return alloc(size2);
if (offset + size2 > SIZE) {
slab = alloc(SIZE);
offset = 0;
}
var buf = slice.call(slab, offset, offset += size2);
if (offset & 7)
offset = (offset | 7) + 1;
return buf;
}, "pool_alloc");
}
__name(pool, "pool");
}, {}], 10: [function(require2, module2, exports$1) {
var utf8 = exports$1;
utf8.length = /* @__PURE__ */ __name(function utf8_length(string) {
var len = 0, c = 0;
for (var i = 0; i < string.length; ++i) {
c = string.charCodeAt(i);
if (c < 128)
len += 1;
else if (c < 2048)
len += 2;
else if ((c & 64512) === 55296 && (string.charCodeAt(i + 1) & 64512) === 56320) {
++i;
len += 4;
} else
len += 3;
}
return len;
}, "utf8_length");
utf8.read = /* @__PURE__ */ __name(function utf8_read(buffer, start, end) {
var len = end - start;
if (len < 1)
return "";
var parts = null, chunk = [], i = 0, t;
while (start < end) {
t = buffer[start++];
if (t < 128)
chunk[i++] = t;
else if (t > 191 && t < 224)
chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
else if (t > 239 && t < 365) {
t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 65536;
chunk[i++] = 55296 + (t >> 10);
chunk[i++] = 56320 + (t & 1023);
} else
chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
if (i > 8191) {
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
i = 0;
}
}
if (parts) {
if (i)
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
return parts.join("");
}
return String.fromCharCode.apply(String, chunk.slice(0, i));
}, "utf8_read");
utf8.write = /* @__PURE__ */ __name(function utf8_write(string, buffer, offset) {
var start = offset, c1, c2;
for (var i = 0; i < string.length; ++i) {
c1 = string.charCodeAt(i);
if (c1 < 128) {
buffer[offset++] = c1;
} else if (c1 < 2048) {
buffer[offset++] = c1 >> 6 | 192;
buffer[offset++] = c1 & 63 | 128;
} else if ((c1 & 64512) === 55296 && ((c2 = string.charCodeAt(i + 1)) & 64512) === 56320) {
c1 = 65536 + ((c1 & 1023) << 10) + (c2 & 1023);
++i;
buffer[offset++] = c1 >> 18 | 240;
buffer[offset++] = c1 >> 12 & 63 | 128;
buffer[offset++] = c1 >> 6 & 63 | 128;
buffer[offset++] = c1 & 63 | 128;
} else {
buffer[offset++] = c1 >> 12 | 224;
buffer[offset++] = c1 >> 6 & 63 | 128;
buffer[offset++] = c1 & 63 | 128;
}
}
return offset - start;
}, "utf8_write");
}, {}], 11: [function(require2, module2, exports$1) {
module2.exports = common;
var commonRe = /\/|\./;
function common(name, json) {
if (!commonRe.test(name)) {
name = "google/protobuf/" + name + ".proto";
json = { nested: { google: { nested: { protobuf: { nested: json } } } } };
}
common[name] = json;
}
__name(common, "common");
common("any", {
/**
* Properties of a google.protobuf.Any message.
* @interface IAny
* @type {Object}
* @property {string} [typeUrl]
* @property {Uint8Array} [bytes]
* @memberof common
*/
Any: {
fields: {
type_url: {
type: "string",
id: 1
},
value: {
type: "bytes",
id: 2
}
}
}
});
var timeType;
common("duration", {
/**
* Properties of a google.protobuf.Duration message.
* @interface IDuration
* @type {Object}
* @property {number|Long} [seconds]
* @property {number} [nanos]
* @memberof common
*/
Duration: timeType = {
fields: {
seconds: {
type: "int64",
id: 1
},
nanos: {
type: "int32",
id: 2
}
}
}
});
common("timestamp", {
/**
* Properties of a google.protobuf.Timestamp message.
* @interface ITimestamp
* @type {Object}
* @property {number|Long} [seconds]
* @property {number} [nanos]
* @memberof common
*/
Timestamp: timeType
});
common("empty", {
/**
* Properties of a google.protobuf.Empty message.
* @interface IEmpty
* @memberof common
*/
Empty: {
fields: {}
}
});
common("struct", {
/**
* Properties of a google.protobuf.Struct message.
* @interface IStruct
* @type {Object}
* @property {Object.<string,IValue>} [fields]
* @memberof common
*/
Struct: {
fields: {
fields: {
keyType: "string",
type: "Value",
id: 1
}
}
},
/**
* Properties of a google.protobuf.Value message.
* @interface IValue
* @type {Object}
* @property {string} [kind]
* @property {0} [nullValue]
* @property {number} [numberValue]
* @property {string} [stringValue]
* @property {boolean} [boolValue]
* @property {IStruct} [structValue]
* @property {IListValue} [listValue]
* @memberof common
*/
Value: {
oneofs: {
kind: {
oneof: [
"nullValue",
"numberValue",
"stringValue",
"boolValue",
"structValue",
"listValue"
]
}
},
fields: {
nullValue: {
type: "NullValue",
id: 1
},
numberValue: {
type: "double",
id: 2
},
stringValue: {
type: "string",
id: 3
},
boolValue: {
type: "bool",
id: 4
},
structValue: {
type: "Struct",
id: 5
},
listValue: {
type: "ListValue",
id: 6
}
}
},
NullValue: {
values: {
NULL_VALUE: 0
}
},
/**
* Properties of a google.protobuf.ListValue message.
* @interface IListValue
* @type {Object}
* @property {Array.<IValue>} [values]
* @memberof common
*/
ListValue: {
fields: {
values: {
rule: "repeated",
type: "Value",
id: 1
}
}
}
});
common("wrappers", {
/**
* Properties of a google.protobuf.DoubleValue message.
* @interface IDoubleValue
* @type {Object}
* @property {number} [value]
* @memberof common
*/
DoubleValue: {
fields: {
value: {
type: "double",
id: 1
}
}
},
/**
* Properties of a google.protobuf.FloatValue message.
* @interface IFloatValue
* @type {Object}
* @property {number} [value]
* @memberof common
*/
FloatValue: {
fields: {
value: {
type: "float",
id: 1
}
}
},
/**
* Properties of a google.protobuf.Int64Value message.
* @interface IInt64Value
* @type {Object}
* @property {number|Long} [value]
* @memberof common
*/
Int64Value: {
fields: {
value: {
type: "int64",
id: 1
}
}
},
/**
* Properties of a google.protobuf.UInt64Value message.
* @interface IUInt64Value
* @type {Object}
* @property {number|Long} [value]
* @memberof common
*/
UInt64Value: {
fields: {
value: {
type: "uint64",
id: 1
}
}
},
/**
* Properties of a google.protobuf.Int32Value message.
* @interface IInt32Value
* @type {Object}
* @property {number} [value]
* @memberof common
*/
Int32Value: {
fields: {
value: {
type: "int32",
id: 1
}
}
},
/**
* Properties of a google.protobuf.UInt32Value message.
* @interface IUInt32Value
* @type {Object}
* @property {number} [value]
* @memberof common
*/
UInt32Value: {
fields: {
value: {
type: "uint32",
id: 1
}
}
},
/**
* Properties of a google.protobuf.BoolValue message.
* @interface IBoolValue
* @type {Object}
* @property {boolean} [value]
* @memberof common
*/
BoolValue: {
fields: {
value: {
type: "bool",
id: 1
}
}
},
/**
* Properties of a google.protobuf.StringValue message.
* @interface IStringValue
* @type {Object}
* @property {string} [value]
* @memberof common
*/
StringValue: {
fields: {
value: {
type: "string",
id: 1
}
}
},
/**
* Properties of a google.protobuf.BytesValue message.
* @interface IBytesValue
* @type {Object}
* @property {Uint8Array} [value]
* @memberof common
*/
BytesValue: {
fields: {
value: {
type: "bytes",
id: 1
}
}
}
});
common("field_mask", {
/**
* Properties of a google.protobuf.FieldMask message.
* @interface IDoubleValue
* @type {Object}
* @property {number} [value]
* @memberof common
*/
FieldMask: {
fields: {
paths: {
rule: "repeated",
type: "string",
id: 1
}
}
}
});
common.get = /* @__PURE__ */ __name(function get(file) {
return common[file] || null;
}, "get");
}, {}], 12: [function(require2, module2, exports$1) {
var converter = exports$1;
var Enum = require2(15), util = require2(37);
function genValuePartial_fromObject(gen, field, fieldIndex, prop) {
if (field.resolvedType) {
if (field.resolvedType instanceof Enum) {
gen("switch(d%s){", prop);
for (var values = field.resolvedType.values, keys = Object.keys(values), i = 0; i < keys.length; ++i) {
if (field.repeated && values[keys[i]] === field.typeDefault) gen("default:");
gen("case%j:", keys[i])("case %i:", values[keys[i]])("m%s=%j", prop, values[keys[i]])("break");
}
gen("}");
} else gen('if(typeof d%s!=="object")', prop)("throw TypeError(%j)", field.fullName + ": object expected")("m%s=types[%i].fromObject(d%s)", prop, fieldIndex, prop);
} else {
var isUnsigned = false;
switch (field.type) {
case "double":
case "float":
gen("m%s=Number(d%s)", prop, prop);
break;
case "uint32":
case "fixed32":
gen("m%s=d%s>>>0", prop, prop);
break;
case "int32":
case "sint32":
case "sfixed32":
gen("m%s=d%s|0", prop, prop);
break;
case "uint64":
isUnsigned = true;
// eslint-disable-line no-fallthrough
case "int64":
case "sint64":
case "fixed64":
case "sfixed64":
gen("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j", prop, prop, isUnsigned)('else if(typeof d%s==="string")', prop)("m%s=parseInt(d%s,10)", prop, prop)('else if(typeof d%s==="number")', prop)("m%s=d%s", prop, prop)('else if(typeof d%s==="object")', prop)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)", prop, prop, prop, isUnsigned ? "true" : "");
break;
case "bytes":
gen('if(typeof d%s==="string")', prop)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)", prop, prop, prop)("else if(d%s.length)", prop)("m%s=d%s", prop, prop);
break;
case "string":
gen("m%s=String(d%s)", prop, prop);
break;
case "bool":
gen("m%s=Boolean(d%s)", prop, prop);
break;
}
}
return gen;
}
__name(genValuePartial_fromObject, "genValuePartial_fromObject");
converter.fromObject = /* @__PURE__ */ __name(function fromObject(mtype) {
var fields = mtype.fieldsArray;
var gen = util.codegen(["d"], mtype.name + "$fromObject")("if(d instanceof this.ctor)")("return d");
if (!fields.length) return gen("return new this.ctor");
gen("var m=new this.ctor");
for (var i = 0; i < fields.length; ++i) {
var field = fields[i].resolve(), prop = util.safeProp(field.name);
if (field.map) {
gen("if(d%s){", prop)('if(typeof d%s!=="object")', prop)("throw TypeError(%j)", field.fullName + ": object expected")("m%s={}", prop)("for(var ks=Object.keys(d%s),i=0;i<ks.length;++i){", prop);
genValuePartial_fromObject(
gen,
field,
/* not sorted */
i,
prop + "[ks[i]]"
)("}")("}");
} else if (field.repeated) {
gen("if(d%s){", prop)("if(!Array.isArray(d%s))", prop)("throw TypeError(%j)", field.fullName + ": array expected")("m%s=[]", prop)("for(var i=0;i<d%s.length;++i){", prop);
genValuePartial_fromObject(
gen,
field,
/* not sorted */
i,
prop + "[i]"
)("}")("}");
} else {
if (!(field.resolvedType instanceof Enum)) gen("if(d%s!=null){", prop);
genValuePartial_fromObject(
gen,
field,
/* not sorted */
i,
prop
);
if (!(field.resolvedType instanceof Enum)) gen("}");
}
}
return gen("return m");
}, "fromObject");
function genValuePartial_toObject(gen, field, fieldIndex, prop) {
if (field.resolvedType) {
if (field.resolvedType instanceof Enum) gen("d%s=o.enums===String?types[%i].values[m%s]:m%s", prop, fieldIndex, prop, prop);
else gen("d%s=types[%i].toObject(m%s,o)", prop, fieldIndex, prop);
} else {
var isUnsigned = false;
switch (field.type) {
case "double":
case "float":
gen("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s", prop, prop, prop, prop);
break;
case "uint64":
isUnsigned = true;
// eslint-disable-line no-fallthrough
case "int64":
case "sint64":
case "fixed64":
case "sfixed64":
gen('if(typeof m%s==="number")', prop)("d%s=o.longs===String?String(m%s):m%s", prop, prop, prop)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s", prop, prop, prop, prop, isUnsigned ? "true" : "", prop);
break;
case "bytes":
gen("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s", prop, prop, prop, prop, prop);
break;
default:
gen("d%s=m%s", prop, prop);
break;
}
}
return gen;
}
__name(genValuePartial_toObject, "genValuePartial_toObject");
converter.toObject = /* @__PURE__ */ __name(function toObject(mtype) {
var fields = mtype.fieldsArray.slice().sort(util.compareFieldsById);
if (!fields.length)
return util.codegen()("return {}");
var gen = util.codegen(["m", "o"], mtype.name + "$toObject")("if(!o)")("o={}")("var d={}");
var repeatedFields = [], mapFields = [], normalFields = [], i = 0;
for (; i < fields.length; ++i)
if (!fields[i].partOf)
(fields[i].resolve().repeated ? repeatedFields : fields[i].map ? mapFields : normalFields).push(fields[i]);
if (repeatedFields.length) {
gen("if(o.arrays||o.defaults){");
for (i = 0; i < repeatedFields.length; ++i) gen("d%s=[]", util.safeProp(repeatedFields[i].name));
gen("}");
}
if (mapFields.length) {
gen("if(o.objects||o.defaults){");
for (i = 0; i < mapFields.length; ++i) gen("d%s={}", util.safeProp(mapFields[i].name));
gen("}");
}
if (normalFields.length) {
gen("if(o.defaults){");
for (i = 0; i < normalFields.length; ++i) {
var field = normalFields[i], prop = util.safeProp(field.name);
if (field.resolvedType instanceof Enum) gen("d%s=o.enums===String?%j:%j", prop, field.resolvedType.valuesById[field.typeDefault], field.typeDefault);
else if (field.long) gen("if(util.Long){")("var n=new util.Long(%i,%i,%j)", field.typeDefault.low, field.typeDefault.high, field.typeDefault.unsigned)("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n", prop)("}else")("d%s=o.longs===String?%j:%i", prop, field.typeDefault.toString(), field.typeDefault.toNumber());
else if (field.bytes) gen("d%s=o.bytes===String?%j:%s", prop, String.fromCharCode.apply(String, field.typeDefault), "[" + Array.prototype.slice.call(field.typeDefault).join(",") + "]");
else gen("d%s=%j", prop, field.typeDefault);
}
gen("}");
}
var hasKs2 = false;
for (i = 0; i < fields.length; ++i) {
var field = fields[i], index = mtype._fieldsArray.indexOf(field), prop = util.safeProp(field.name);
if (field.map) {
if (!hasKs2) {
hasKs2 = true;
gen("var ks2");
}
gen("if(m%s&&(ks2=Object.keys(m%s)).length){", prop, prop)("d%s={}", prop)("for(var j=0;j<ks2.length;++j){");
genValuePartial_toObject(
gen,
field,
/* sorted */
index,
prop + "[ks2[j]]"
)("}");
} else if (field.repeated) {
gen("if(m%s&&m%s.length){", prop, prop)("d%s=[]", prop)("for(var j=0;j<m%s.length;++j){", prop);
genValuePartial_toObject(
gen,
field,
/* sorted */
index,
prop + "[j]"
)("}");
} else {
gen("if(m%s!=null&&m.hasOwnProperty(%j)){", prop, field.name);
genValuePartial_toObject(
gen,
field,
/* sorted */
index,
prop
);
if (field.partOf) gen("if(o.oneofs)")("d%s=%j", util.safeProp(field.partOf.name), field.name);
}
gen("}");
}
return gen("return d");
}, "toObject");
}, { "15": 15, "37": 37 }], 13: [function(require2, module2, exports$1) {
module2.exports = decoder;
var Enum = require2(15), types = require2(36), util = require2(37);
function missing(field) {
return "missing required '" + field.name + "'";
}
__name(missing, "missing");
function decoder(mtype) {
var gen = util.codegen(["r", "l"], mtype.name + "$decode")("if(!(r instanceof Reader))")("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor" + (mtype.fieldsArray.filter(function(field2) {
return field2.map;
}).length ? ",k" : ""))("while(r.pos<c){")("var t=r.uint32()");
if (mtype.group) gen("if((t&7)===4)")("break");
gen("switch(t>>>3){");
var i = 0;
for (; i < /* initializes */
mtype.fieldsArray.length; ++i) {
var field = mtype._fieldsArray[i].resolve(), type = field.resolvedType instanceof Enum ? "int32" : field.type, ref = "m" + util.safeProp(field.name);
gen("case %i:", field.id);
if (field.map) {
gen("r.skip().pos++")("if(%s===util.emptyObject)", ref)("%s={}", ref)("k=r.%s()", field.keyType)("r.pos++");
if (types.long[field.keyType] !== undefined$1) {
if (types.basic[type] === undefined$1) gen('%s[typeof k==="object"?util.longToHash(k):k]=types[%i].decode(r,r.uint32())', ref, i);
else gen('%s[typeof k==="object"?util.longToHash(k):k]=r.%s()', ref, type);
} else {
if (types.basic[type] === undefined$1) gen("%s[k]=types[%i].decode(r,r.uint32())", ref, i);
else gen("%s[k]=r.%s()", ref, type);
}
} else if (field.repeated) {
gen("if(!(%s&&%s.length))", ref, ref)("%s=[]", ref);
if (types.packed[type] !== undefined$1) gen("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos<c2)")("%s.push(r.%s())", ref, type)("}else");
if (types.basic[type] === undefined$1) gen(field.resolvedType.group ? "%s.push(types[%i].decode(r))" : "%s.push(types[%i].decode(r,r.uint32()))", ref, i);
else gen("%s.push(r.%s())", ref, type);
} else if (types.basic[type] === undefined$1) gen(field.resolvedType.group ? "%s=types[%i].decode(r)" : "%s=types[%i].decode(r,r.uint32())", ref, i);
else gen("%s=r.%s()", ref, type);
gen("break");
}
gen("default:")("r.skipType(t&7)")("break")("}")("}");
for (i = 0; i < mtype._fieldsArray.length; ++i) {
var rfield = mtype._fieldsArray[i];
if (rfield.required) gen("if(!m.hasOwnProperty(%j))", rfield.name)("throw util.ProtocolError(%j,{instance:m})", missing(rfield));
}
return gen("return m");
}
__name(decoder, "decoder");
}, { "15": 15, "36": 36, "37": 37 }], 14: [function(require2, module2, exports$1) {
module2.exports = encoder;
var Enum = require2(15), types = require2(36), util = require2(37);
function genTypePartial(gen, field, fieldIndex, ref) {
return field.resolvedType.group ? gen("types[%i].encode(%s,w.uint32(%i)).uint32(%i)", fieldIndex, ref, (field.id << 3 | 3) >>> 0, (field.id << 3 | 4) >>> 0) : gen("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()", fieldIndex, ref, (field.id << 3 | 2) >>> 0);
}
__name(genTypePartial, "genTypePartial");
function encoder(mtype) {
var gen = util.codegen(["m", "w"], mtype.name + "$encode")("if(!w)")("w=Writer.create()");
var i, ref;
var fields = (
/* initializes */
mtype.fieldsArray.slice().sort(util.compareFieldsById)
);
for (var i = 0; i < fields.length; ++i) {
var field = fields[i].resolve(), index = mtype._fieldsArray.indexOf(field), type = field.resolvedType instanceof Enum ? "int32" : field.type, wireType = types.basic[type];
ref = "m" + util.safeProp(field.name);
if (field.map) {
gen("if(%s!=null&&m.hasOwnProperty(%j)){", ref, field.name)("for(var ks=Object.keys(%s),i=0;i<ks.length;++i){", ref)("w.uint32(%i).fork().uint32(%i).%s(ks[i])", (field.id << 3 | 2) >>> 0, 8 | types.mapKey[field.keyType], field.keyType);
if (wireType === undefined$1) gen("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()", index, ref);
else gen(".uint32(%i).%s(%s[ks[i]]).ldelim()", 16 | wireType, type, ref);
gen("}")("}");
} else if (field.repeated) {
gen("if(%s!=null&&%s.length){", ref, ref);
if (field.packed && types.packed[type] !== undefined$1) {
gen("w.uint32(%i).fork()", (field.id << 3 | 2) >>> 0)("for(var i=0;i<%s.length;++i)", ref)("w.%s(%s[i])", type, ref)("w.ldelim()");
} else {
gen("for(var i=0;i<%s.length;++i)", ref);
if (wireType === undefined$1)
genTypePartial(gen, field, index, ref + "[i]");
else gen("w.uint32(%i).%s(%s[i])", (field.id << 3 | wireType) >>> 0, type, ref);
}
gen("}");
} else {
if (field.optional) gen("if(%s!=null&&m.hasOwnProperty(%j))", ref, field.name);
if (wireType === undefined$1)
genTypePartial(gen, field, index, ref);
else gen("w.uint32(%i).%s(%s)", (field.id << 3 | wireType) >>> 0, type, ref);
}
}
return gen("return w");
}
__name(encoder, "encoder");
}, { "15": 15, "36": 36, "37": 37 }], 15: [function(require2, module2, exports$1) {
module2.exports = Enum;
var ReflectionObject = require2(24);
((Enum.prototype = Object.create(ReflectionObject.prototype)).constructor = Enum).className = "Enum";
var Namespace = require2(23), util = require2(37);
function Enum(name, values, options, comment, comments) {
ReflectionObject.call(this, name, options);
if (values && typeof values !== "object")
throw TypeError("values must be an object");
this.valuesById = {};
this.values = Object.create(this.valuesById);
this.comment = comment;
this.comments = comments || {};
this.reserved = undefined$1;