openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
5,105 lines • 148 kB
JavaScript
import { n as __esmMin, o as __toCommonJS, r as __exportAll, t as __commonJSMin } from "./rolldown-runtime-C_OpTf0N.mjs";
//#region node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs
var tslib_es6_exports = /* @__PURE__ */ __exportAll({
__addDisposableResource: () => __addDisposableResource,
__assign: () => __assign,
__asyncDelegator: () => __asyncDelegator,
__asyncGenerator: () => __asyncGenerator,
__asyncValues: () => __asyncValues,
__await: () => __await,
__awaiter: () => __awaiter,
__classPrivateFieldGet: () => __classPrivateFieldGet,
__classPrivateFieldIn: () => __classPrivateFieldIn,
__classPrivateFieldSet: () => __classPrivateFieldSet,
__createBinding: () => __createBinding,
__decorate: () => __decorate,
__disposeResources: () => __disposeResources,
__esDecorate: () => __esDecorate,
__exportStar: () => __exportStar,
__extends: () => __extends,
__generator: () => __generator,
__importDefault: () => __importDefault,
__importStar: () => __importStar,
__makeTemplateObject: () => __makeTemplateObject,
__metadata: () => __metadata,
__param: () => __param,
__propKey: () => __propKey,
__read: () => __read,
__rest: () => __rest,
__rewriteRelativeImportExtension: () => __rewriteRelativeImportExtension,
__runInitializers: () => __runInitializers,
__setFunctionName: () => __setFunctionName,
__spread: () => __spread,
__spreadArray: () => __spreadArray,
__spreadArrays: () => __spreadArrays,
__values: () => __values,
default: () => tslib_es6_default
});
function __extends(e, t) {
if (typeof t !== "function" && t !== null) throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
extendStatics(e, t);
function __() {
this.constructor = e;
}
e.prototype = t === null ? Object.create(t) : (__.prototype = t.prototype, new __());
}
function __rest(e, t) {
var n = {};
for (var r in e) if (Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0) n[r] = e[r];
if (e != null && typeof Object.getOwnPropertySymbols === "function") {
for (var i = 0, r = Object.getOwnPropertySymbols(e); i < r.length; i++) if (t.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[i])) n[r[i]] = e[r[i]];
}
return n;
}
function __decorate(e, t, n, r) {
var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") a = Reflect.decorate(e, t, n, r);
else for (var s = e.length - 1; s >= 0; s--) if (o = e[s]) a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a;
return i > 3 && a && Object.defineProperty(t, n, a), a;
}
function __param(e, t) {
return function(n, r) {
t(n, r, e);
};
}
function __esDecorate(e, t, n, r, i, a) {
function accept(e) {
if (e !== void 0 && typeof e !== "function") throw new TypeError("Function expected");
return e;
}
var o = r.kind, s = o === "getter" ? "get" : o === "setter" ? "set" : "value";
var c = !t && e ? r["static"] ? e : e.prototype : null;
var l = t || (c ? Object.getOwnPropertyDescriptor(c, r.name) : {});
var u, d = false;
for (var f = n.length - 1; f >= 0; f--) {
var p = {};
for (var m in r) p[m] = m === "access" ? {} : r[m];
for (var m in r.access) p.access[m] = r.access[m];
p.addInitializer = function(e) {
if (d) throw new TypeError("Cannot add initializers after decoration has completed");
a.push(accept(e || null));
};
var h = (0, n[f])(o === "accessor" ? {
get: l.get,
set: l.set
} : l[s], p);
if (o === "accessor") {
if (h === void 0) continue;
if (h === null || typeof h !== "object") throw new TypeError("Object expected");
if (u = accept(h.get)) l.get = u;
if (u = accept(h.set)) l.set = u;
if (u = accept(h.init)) i.unshift(u);
} else if (u = accept(h)) {
if (o === "field") i.unshift(u);
else l[s] = u;
}
}
if (c) Object.defineProperty(c, r.name, l);
d = true;
}
function __runInitializers(e, t, n) {
var r = arguments.length > 2;
for (var i = 0; i < t.length; i++) n = r ? t[i].call(e, n) : t[i].call(e);
return r ? n : void 0;
}
function __propKey(e) {
return typeof e === "symbol" ? e : "".concat(e);
}
function __setFunctionName(e, t, n) {
if (typeof t === "symbol") t = t.description ? "[".concat(t.description, "]") : "";
return Object.defineProperty(e, "name", {
configurable: true,
value: n ? "".concat(n, " ", t) : t
});
}
function __metadata(e, t) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(e, t);
}
function __awaiter(e, t, n, r) {
function adopt(e) {
return e instanceof n ? e : new n(function(t) {
t(e);
});
}
return new (n || (n = Promise))(function(n, i) {
function fulfilled(e) {
try {
step(r.next(e));
} catch (e) {
i(e);
}
}
function rejected(e) {
try {
step(r["throw"](e));
} catch (e) {
i(e);
}
}
function step(e) {
e.done ? n(e.value) : adopt(e.value).then(fulfilled, rejected);
}
step((r = r.apply(e, t || [])).next());
});
}
function __generator(e, t) {
var n = {
label: 0,
sent: function() {
if (a[0] & 1) throw a[1];
return a[1];
},
trys: [],
ops: []
}, r, i, a, o = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
return o.next = verb(0), o["throw"] = verb(1), o["return"] = verb(2), typeof Symbol === "function" && (o[Symbol.iterator] = function() {
return this;
}), o;
function verb(e) {
return function(t) {
return step([e, t]);
};
}
function step(s) {
if (r) throw new TypeError("Generator is already executing.");
while (o && (o = 0, s[0] && (n = 0)), n) try {
if (r = 1, i && (a = s[0] & 2 ? i["return"] : s[0] ? i["throw"] || ((a = i["return"]) && a.call(i), 0) : i.next) && !(a = a.call(i, s[1])).done) return a;
if (i = 0, a) s = [s[0] & 2, a.value];
switch (s[0]) {
case 0:
case 1:
a = s;
break;
case 4:
n.label++;
return {
value: s[1],
done: false
};
case 5:
n.label++;
i = s[1];
s = [0];
continue;
case 7:
s = n.ops.pop();
n.trys.pop();
continue;
default:
if (!(a = n.trys, a = a.length > 0 && a[a.length - 1]) && (s[0] === 6 || s[0] === 2)) {
n = 0;
continue;
}
if (s[0] === 3 && (!a || s[1] > a[0] && s[1] < a[3])) {
n.label = s[1];
break;
}
if (s[0] === 6 && n.label < a[1]) {
n.label = a[1];
a = s;
break;
}
if (a && n.label < a[2]) {
n.label = a[2];
n.ops.push(s);
break;
}
if (a[2]) n.ops.pop();
n.trys.pop();
continue;
}
s = t.call(e, n);
} catch (e) {
s = [6, e];
i = 0;
} finally {
r = a = 0;
}
if (s[0] & 5) throw s[1];
return {
value: s[0] ? s[1] : void 0,
done: true
};
}
}
function __exportStar(e, t) {
for (var n in e) if (n !== "default" && !Object.prototype.hasOwnProperty.call(t, n)) __createBinding(t, e, n);
}
function __values(e) {
var t = typeof Symbol === "function" && Symbol.iterator, n = t && e[t], r = 0;
if (n) return n.call(e);
if (e && typeof e.length === "number") return { next: function() {
if (e && r >= e.length) e = void 0;
return {
value: e && e[r++],
done: !e
};
} };
throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function __read(e, t) {
var n = typeof Symbol === "function" && e[Symbol.iterator];
if (!n) return e;
var r = n.call(e), i, a = [], o;
try {
while ((t === void 0 || t-- > 0) && !(i = r.next()).done) a.push(i.value);
} catch (e) {
o = { error: e };
} finally {
try {
if (i && !i.done && (n = r["return"])) n.call(r);
} finally {
if (o) throw o.error;
}
}
return a;
}
/** @deprecated */
function __spread() {
for (var e = [], t = 0; t < arguments.length; t++) e = e.concat(__read(arguments[t]));
return e;
}
/** @deprecated */
function __spreadArrays() {
for (var e = 0, t = 0, n = arguments.length; t < n; t++) e += arguments[t].length;
for (var r = Array(e), i = 0, t = 0; t < n; t++) for (var a = arguments[t], o = 0, s = a.length; o < s; o++, i++) r[i] = a[o];
return r;
}
function __spreadArray(e, t, n) {
if (n || arguments.length === 2) {
for (var r = 0, i = t.length, a; r < i; r++) if (a || !(r in t)) {
if (!a) a = Array.prototype.slice.call(t, 0, r);
a[r] = t[r];
}
}
return e.concat(a || Array.prototype.slice.call(t));
}
function __await(e) {
return this instanceof __await ? (this.v = e, this) : new __await(e);
}
function __asyncGenerator(e, t, n) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var r = n.apply(e, t || []), i, a = [];
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function() {
return this;
}, i;
function awaitReturn(e) {
return function(t) {
return Promise.resolve(t).then(e, reject);
};
}
function verb(e, t) {
if (r[e]) {
i[e] = function(t) {
return new Promise(function(n, r) {
a.push([
e,
t,
n,
r
]) > 1 || resume(e, t);
});
};
if (t) i[e] = t(i[e]);
}
}
function resume(e, t) {
try {
step(r[e](t));
} catch (e) {
settle(a[0][3], e);
}
}
function step(e) {
e.value instanceof __await ? Promise.resolve(e.value.v).then(fulfill, reject) : settle(a[0][2], e);
}
function fulfill(e) {
resume("next", e);
}
function reject(e) {
resume("throw", e);
}
function settle(e, t) {
if (e(t), a.shift(), a.length) resume(a[0][0], a[0][1]);
}
}
function __asyncDelegator(e) {
var t = {}, n;
return verb("next"), verb("throw", function(e) {
throw e;
}), verb("return"), t[Symbol.iterator] = function() {
return this;
}, t;
function verb(r, i) {
t[r] = e[r] ? function(t) {
return (n = !n) ? {
value: __await(e[r](t)),
done: false
} : i ? i(t) : t;
} : i;
}
}
function __asyncValues(e) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var t = e[Symbol.asyncIterator], n;
return t ? t.call(e) : (e = typeof __values === "function" ? __values(e) : e[Symbol.iterator](), n = {}, verb("next"), verb("throw"), verb("return"), n[Symbol.asyncIterator] = function() {
return this;
}, n);
function verb(t) {
n[t] = e[t] && function(n) {
return new Promise(function(r, i) {
n = e[t](n), settle(r, i, n.done, n.value);
});
};
}
function settle(e, t, n, r) {
Promise.resolve(r).then(function(t) {
e({
value: t,
done: n
});
}, t);
}
}
function __makeTemplateObject(e, t) {
if (Object.defineProperty) Object.defineProperty(e, "raw", { value: t });
else e.raw = t;
return e;
}
function __importStar(e) {
if (e && e.__esModule) return e;
var t = {};
if (e != null) {
for (var n = ownKeys(e), r = 0; r < n.length; r++) if (n[r] !== "default") __createBinding(t, e, n[r]);
}
__setModuleDefault(t, e);
return t;
}
function __importDefault(e) {
return e && e.__esModule ? e : { default: e };
}
function __classPrivateFieldGet(e, t, n, r) {
if (n === "a" && !r) throw new TypeError("Private accessor was defined without a getter");
if (typeof t === "function" ? e !== t || !r : !t.has(e)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return n === "m" ? r : n === "a" ? r.call(e) : r ? r.value : t.get(e);
}
function __classPrivateFieldSet(e, t, n, r, i) {
if (r === "m") throw new TypeError("Private method is not writable");
if (r === "a" && !i) throw new TypeError("Private accessor was defined without a setter");
if (typeof t === "function" ? e !== t || !i : !t.has(e)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return r === "a" ? i.call(e, n) : i ? i.value = n : t.set(e, n), n;
}
function __classPrivateFieldIn(e, t) {
if (t === null || typeof t !== "object" && typeof t !== "function") throw new TypeError("Cannot use 'in' operator on non-object");
return typeof e === "function" ? t === e : e.has(t);
}
function __addDisposableResource(e, t, n) {
if (t !== null && t !== void 0) {
if (typeof t !== "object" && typeof t !== "function") throw new TypeError("Object expected.");
var dispose, r;
if (n) {
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
dispose = t[Symbol.asyncDispose];
}
if (dispose === void 0) {
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
dispose = t[Symbol.dispose];
if (n) r = dispose;
}
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
if (r) dispose = function() {
try {
r.call(this);
} catch (e) {
return Promise.reject(e);
}
};
e.stack.push({
value: t,
dispose,
async: n
});
} else if (n) e.stack.push({ async: true });
return t;
}
function __disposeResources(e) {
function fail(t) {
e.error = e.hasError ? new _SuppressedError(t, e.error, "An error was suppressed during disposal.") : t;
e.hasError = true;
}
var t, n = 0;
function next() {
while (t = e.stack.pop()) try {
if (!t.async && n === 1) return n = 0, e.stack.push(t), Promise.resolve().then(next);
if (t.dispose) {
var r = t.dispose.call(t.value);
if (t.async) return n |= 2, Promise.resolve(r).then(next, function(e) {
fail(e);
return next();
});
} else n |= 1;
} catch (e) {
fail(e);
}
if (n === 1) return e.hasError ? Promise.reject(e.error) : Promise.resolve();
if (e.hasError) throw e.error;
}
return next();
}
function __rewriteRelativeImportExtension(e, t) {
if (typeof e === "string" && /^\.\.?\//.test(e)) return e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(e, n, r, i, a) {
return n ? t ? ".jsx" : ".js" : r && (!i || !a) ? e : r + i + "." + a.toLowerCase() + "js";
});
return e;
}
var extendStatics, __assign, __createBinding, __setModuleDefault, ownKeys, _SuppressedError, tslib_es6_default;
var init_tslib_es6 = __esmMin((() => {
extendStatics = function(e, t) {
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, t) {
e.__proto__ = t;
} || function(e, t) {
for (var n in t) if (Object.prototype.hasOwnProperty.call(t, n)) e[n] = t[n];
};
return extendStatics(e, t);
};
__assign = function() {
__assign = Object.assign || function __assign(e) {
for (var t, n = 1, r = arguments.length; n < r; n++) {
t = arguments[n];
for (var i in t) if (Object.prototype.hasOwnProperty.call(t, i)) e[i] = t[i];
}
return e;
};
return __assign.apply(this, arguments);
};
__createBinding = Object.create ? (function(e, t, n, r) {
if (r === void 0) r = n;
var i = Object.getOwnPropertyDescriptor(t, n);
if (!i || ("get" in i ? !t.__esModule : i.writable || i.configurable)) i = {
enumerable: true,
get: function() {
return t[n];
}
};
Object.defineProperty(e, r, i);
}) : (function(e, t, n, r) {
if (r === void 0) r = n;
e[r] = t[n];
});
__setModuleDefault = Object.create ? (function(e, t) {
Object.defineProperty(e, "default", {
enumerable: true,
value: t
});
}) : function(e, t) {
e["default"] = t;
};
ownKeys = function(e) {
ownKeys = Object.getOwnPropertyNames || function(e) {
var t = [];
for (var n in e) if (Object.prototype.hasOwnProperty.call(e, n)) t[t.length] = n;
return t;
};
return ownKeys(e);
};
_SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(e, t, n) {
var r = new Error(n);
return r.name = "SuppressedError", r.error = e, r.suppressed = t, r;
};
tslib_es6_default = {
__extends,
__assign,
__rest,
__decorate,
__param,
__esDecorate,
__runInitializers,
__propKey,
__setFunctionName,
__metadata,
__awaiter,
__generator,
__createBinding,
__exportStar,
__values,
__read,
__spread,
__spreadArrays,
__spreadArray,
__await,
__asyncGenerator,
__asyncDelegator,
__asyncValues,
__makeTemplateObject,
__importStar,
__importDefault,
__classPrivateFieldGet,
__classPrivateFieldSet,
__classPrivateFieldIn,
__addDisposableResource,
__disposeResources,
__rewriteRelativeImportExtension
};
}));
//#endregion
//#region node_modules/.pnpm/pvtsutils@1.3.6/node_modules/pvtsutils/build/index.js
/*!
* MIT License
*
* Copyright (c) 2017-2024 Peculiar Ventures, LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
var require_build$1 = /* @__PURE__ */ __commonJSMin(((e) => {
const t = "[object ArrayBuffer]";
var n = class BufferSourceConverter {
static isArrayBuffer(e) {
return Object.prototype.toString.call(e) === t;
}
static toArrayBuffer(e) {
if (this.isArrayBuffer(e)) return e;
if (e.byteLength === e.buffer.byteLength) return e.buffer;
if (e.byteOffset === 0 && e.byteLength === e.buffer.byteLength) return e.buffer;
return this.toUint8Array(e.buffer).slice(e.byteOffset, e.byteOffset + e.byteLength).buffer;
}
static toUint8Array(e) {
return this.toView(e, Uint8Array);
}
static toView(e, t) {
if (e.constructor === t) return e;
if (this.isArrayBuffer(e)) return new t(e);
if (this.isArrayBufferView(e)) return new t(e.buffer, e.byteOffset, e.byteLength);
throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");
}
static isBufferSource(e) {
return this.isArrayBufferView(e) || this.isArrayBuffer(e);
}
static isArrayBufferView(e) {
return ArrayBuffer.isView(e) || e && this.isArrayBuffer(e.buffer);
}
static isEqual(e, t) {
const n = BufferSourceConverter.toUint8Array(e);
const r = BufferSourceConverter.toUint8Array(t);
if (n.length !== r.byteLength) return false;
for (let e = 0; e < n.length; e++) if (n[e] !== r[e]) return false;
return true;
}
static concat(...e) {
let t;
if (Array.isArray(e[0]) && !(e[1] instanceof Function)) t = e[0];
else if (Array.isArray(e[0]) && e[1] instanceof Function) t = e[0];
else if (e[e.length - 1] instanceof Function) t = e.slice(0, e.length - 1);
else t = e;
let n = 0;
for (const e of t) n += e.byteLength;
const r = new Uint8Array(n);
let i = 0;
for (const e of t) {
const t = this.toUint8Array(e);
r.set(t, i);
i += t.length;
}
if (e[e.length - 1] instanceof Function) return this.toView(r, e[e.length - 1]);
return r.buffer;
}
};
const r = "string";
const i = /^[0-9a-f\s]+$/i;
const a = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
const o = /^[a-zA-Z0-9-_]+$/;
var Utf8Converter = class {
static fromString(e) {
const t = unescape(encodeURIComponent(e));
const n = new Uint8Array(t.length);
for (let e = 0; e < t.length; e++) n[e] = t.charCodeAt(e);
return n.buffer;
}
static toString(e) {
const t = n.toUint8Array(e);
let r = "";
for (let e = 0; e < t.length; e++) r += String.fromCharCode(t[e]);
return decodeURIComponent(escape(r));
}
};
var Utf16Converter = class {
static toString(e, t = false) {
const r = n.toArrayBuffer(e);
const i = new DataView(r);
let a = "";
for (let e = 0; e < r.byteLength; e += 2) {
const n = i.getUint16(e, t);
a += String.fromCharCode(n);
}
return a;
}
static fromString(e, t = false) {
const n = /* @__PURE__ */ new ArrayBuffer(e.length * 2);
const r = new DataView(n);
for (let n = 0; n < e.length; n++) r.setUint16(n * 2, e.charCodeAt(n), t);
return n;
}
};
var s = class Convert {
static isHex(e) {
return typeof e === r && i.test(e);
}
static isBase64(e) {
return typeof e === r && a.test(e);
}
static isBase64Url(e) {
return typeof e === r && o.test(e);
}
static ToString(e, t = "utf8") {
const r = n.toUint8Array(e);
switch (t.toLowerCase()) {
case "utf8": return this.ToUtf8String(r);
case "binary": return this.ToBinary(r);
case "hex": return this.ToHex(r);
case "base64": return this.ToBase64(r);
case "base64url": return this.ToBase64Url(r);
case "utf16le": return Utf16Converter.toString(r, true);
case "utf16":
case "utf16be": return Utf16Converter.toString(r);
default: throw new Error(`Unknown type of encoding '${t}'`);
}
}
static FromString(e, t = "utf8") {
if (!e) return /* @__PURE__ */ new ArrayBuffer(0);
switch (t.toLowerCase()) {
case "utf8": return this.FromUtf8String(e);
case "binary": return this.FromBinary(e);
case "hex": return this.FromHex(e);
case "base64": return this.FromBase64(e);
case "base64url": return this.FromBase64Url(e);
case "utf16le": return Utf16Converter.fromString(e, true);
case "utf16":
case "utf16be": return Utf16Converter.fromString(e);
default: throw new Error(`Unknown type of encoding '${t}'`);
}
}
static ToBase64(e) {
const t = n.toUint8Array(e);
if (typeof btoa !== "undefined") {
const e = this.ToString(t, "binary");
return btoa(e);
} else return Buffer.from(t).toString("base64");
}
static FromBase64(e) {
const t = this.formatString(e);
if (!t) return /* @__PURE__ */ new ArrayBuffer(0);
if (!Convert.isBase64(t)) throw new TypeError("Argument 'base64Text' is not Base64 encoded");
if (typeof atob !== "undefined") return this.FromBinary(atob(t));
else return new Uint8Array(Buffer.from(t, "base64")).buffer;
}
static FromBase64Url(e) {
const t = this.formatString(e);
if (!t) return /* @__PURE__ */ new ArrayBuffer(0);
if (!Convert.isBase64Url(t)) throw new TypeError("Argument 'base64url' is not Base64Url encoded");
return this.FromBase64(this.Base64Padding(t.replace(/\-/g, "+").replace(/\_/g, "/")));
}
static ToBase64Url(e) {
return this.ToBase64(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/\=/g, "");
}
static FromUtf8String(e, t = Convert.DEFAULT_UTF8_ENCODING) {
switch (t) {
case "ascii": return this.FromBinary(e);
case "utf8": return Utf8Converter.fromString(e);
case "utf16":
case "utf16be": return Utf16Converter.fromString(e);
case "utf16le":
case "usc2": return Utf16Converter.fromString(e, true);
default: throw new Error(`Unknown type of encoding '${t}'`);
}
}
static ToUtf8String(e, t = Convert.DEFAULT_UTF8_ENCODING) {
switch (t) {
case "ascii": return this.ToBinary(e);
case "utf8": return Utf8Converter.toString(e);
case "utf16":
case "utf16be": return Utf16Converter.toString(e);
case "utf16le":
case "usc2": return Utf16Converter.toString(e, true);
default: throw new Error(`Unknown type of encoding '${t}'`);
}
}
static FromBinary(e) {
const t = e.length;
const n = new Uint8Array(t);
for (let r = 0; r < t; r++) n[r] = e.charCodeAt(r);
return n.buffer;
}
static ToBinary(e) {
const t = n.toUint8Array(e);
let r = "";
for (let e = 0; e < t.length; e++) r += String.fromCharCode(t[e]);
return r;
}
static ToHex(e) {
const t = n.toUint8Array(e);
let r = "";
const i = t.length;
for (let e = 0; e < i; e++) {
const n = t[e];
if (n < 16) r += "0";
r += n.toString(16);
}
return r;
}
static FromHex(e) {
let t = this.formatString(e);
if (!t) return /* @__PURE__ */ new ArrayBuffer(0);
if (!Convert.isHex(t)) throw new TypeError("Argument 'hexString' is not HEX encoded");
if (t.length % 2) t = `0${t}`;
const n = new Uint8Array(t.length / 2);
for (let e = 0; e < t.length; e = e + 2) {
const r = t.slice(e, e + 2);
n[e / 2] = parseInt(r, 16);
}
return n.buffer;
}
static ToUtf16String(e, t = false) {
return Utf16Converter.toString(e, t);
}
static FromUtf16String(e, t = false) {
return Utf16Converter.fromString(e, t);
}
static Base64Padding(e) {
const t = 4 - e.length % 4;
if (t < 4) for (let n = 0; n < t; n++) e += "=";
return e;
}
static formatString(e) {
return (e === null || e === void 0 ? void 0 : e.replace(/[\n\r\t ]/g, "")) || "";
}
};
s.DEFAULT_UTF8_ENCODING = "utf8";
function assign(e, ...t) {
const n = arguments[0];
for (let e = 1; e < arguments.length; e++) {
const t = arguments[e];
for (const e in t) n[e] = t[e];
}
return n;
}
function combine(...e) {
const t = e.map((e) => e.byteLength).reduce((e, t) => e + t);
const n = new Uint8Array(t);
let r = 0;
e.map((e) => new Uint8Array(e)).forEach((e) => {
for (const t of e) n[r++] = t;
});
return n.buffer;
}
function isEqual(e, t) {
if (!(e && t)) return false;
if (e.byteLength !== t.byteLength) return false;
const n = new Uint8Array(e);
const r = new Uint8Array(t);
for (let t = 0; t < e.byteLength; t++) if (n[t] !== r[t]) return false;
return true;
}
e.BufferSourceConverter = n;
e.Convert = s;
e.assign = assign;
e.combine = combine;
e.isEqual = isEqual;
}));
//#endregion
//#region node_modules/.pnpm/pvutils@1.2.0/node_modules/pvutils/build/utils.js
/*!
Copyright (c) Peculiar Ventures, LLC
*/
var require_utils = /* @__PURE__ */ __commonJSMin(((e) => {
Object.defineProperty(e, "__esModule", { value: true });
function getUTCDate(e) {
return new Date(e.getTime() + e.getTimezoneOffset() * 6e4);
}
function getParametersValue(e, t, n) {
var r;
if (e instanceof Object === false) return n;
return (r = e[t]) !== null && r !== void 0 ? r : n;
}
function bufferToHexCodes(e, t = 0, n = e.byteLength - t, r = false) {
let i = "";
for (const a of new Uint8Array(e, t, n)) {
const e = a.toString(16).toUpperCase();
if (e.length === 1) i += "0";
i += e;
if (r) i += " ";
}
return i.trim();
}
function checkBufferParams(e, t, n, r) {
if (!(t instanceof ArrayBuffer)) {
e.error = "Wrong parameter: inputBuffer must be \"ArrayBuffer\"";
return false;
}
if (!t.byteLength) {
e.error = "Wrong parameter: inputBuffer has zero length";
return false;
}
if (n < 0) {
e.error = "Wrong parameter: inputOffset less than zero";
return false;
}
if (r < 0) {
e.error = "Wrong parameter: inputLength less than zero";
return false;
}
if (t.byteLength - n - r < 0) {
e.error = "End of input reached before message was fully decoded (inconsistent offset and length values)";
return false;
}
return true;
}
function utilFromBase(e, t) {
let n = 0;
if (e.length === 1) return e[0];
for (let r = e.length - 1; r >= 0; r--) n += e[e.length - 1 - r] * Math.pow(2, t * r);
return n;
}
function utilToBase(e, t, n = -1) {
const r = n;
let i = e;
let a = 0;
let o = Math.pow(2, t);
for (let n = 1; n < 8; n++) {
if (e < o) {
let e;
if (r < 0) {
e = new ArrayBuffer(n);
a = n;
} else {
if (r < n) return /* @__PURE__ */ new ArrayBuffer(0);
e = new ArrayBuffer(r);
a = r;
}
const o = new Uint8Array(e);
for (let e = n - 1; e >= 0; e--) {
const n = Math.pow(2, e * t);
o[a - e - 1] = Math.floor(i / n);
i -= o[a - e - 1] * n;
}
return e;
}
o *= Math.pow(2, t);
}
return /* @__PURE__ */ new ArrayBuffer(0);
}
function utilConcatBuf(...e) {
let t = 0;
let n = 0;
for (const n of e) t += n.byteLength;
const r = new ArrayBuffer(t);
const i = new Uint8Array(r);
for (const t of e) {
i.set(new Uint8Array(t), n);
n += t.byteLength;
}
return r;
}
function utilConcatView(...e) {
let t = 0;
let n = 0;
for (const n of e) t += n.length;
const r = new ArrayBuffer(t);
const i = new Uint8Array(r);
for (const t of e) {
i.set(t, n);
n += t.length;
}
return i;
}
function utilDecodeTC() {
const e = new Uint8Array(this.valueHex);
if (this.valueHex.byteLength >= 2) {
const t = e[0] === 255 && e[1] & 128;
const n = e[0] === 0 && (e[1] & 128) === 0;
if (t || n) this.warnings.push("Needlessly long format");
}
const t = new ArrayBuffer(this.valueHex.byteLength);
const n = new Uint8Array(t);
for (let e = 0; e < this.valueHex.byteLength; e++) n[e] = 0;
n[0] = e[0] & 128;
const r = utilFromBase(n, 8);
const i = new ArrayBuffer(this.valueHex.byteLength);
const a = new Uint8Array(i);
for (let t = 0; t < this.valueHex.byteLength; t++) a[t] = e[t];
a[0] &= 127;
return utilFromBase(a, 8) - r;
}
function utilEncodeTC(e) {
const t = e < 0 ? e * -1 : e;
let n = 128;
for (let r = 1; r < 8; r++) {
if (t <= n) {
if (e < 0) {
const e = utilToBase(n - t, 8, r);
const i = new Uint8Array(e);
i[0] |= 128;
return e;
}
let i = utilToBase(t, 8, r);
let a = new Uint8Array(i);
if (a[0] & 128) {
const e = i.slice(0);
const t = new Uint8Array(e);
i = new ArrayBuffer(i.byteLength + 1);
a = new Uint8Array(i);
for (let n = 0; n < e.byteLength; n++) a[n + 1] = t[n];
a[0] = 0;
}
return i;
}
n *= Math.pow(2, 8);
}
return /* @__PURE__ */ new ArrayBuffer(0);
}
function isEqualBuffer(e, t) {
if (e.byteLength !== t.byteLength) return false;
const n = new Uint8Array(e);
const r = new Uint8Array(t);
for (let e = 0; e < n.length; e++) if (n[e] !== r[e]) return false;
return true;
}
function padNumber(e, t) {
const n = e.toString(10);
if (t < n.length) return "";
const r = t - n.length;
const i = Array.from({ length: r });
for (let e = 0; e < r; e++) i[e] = "0";
return i.join("").concat(n);
}
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
const n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=";
function toBase64(e, r = false, i = false, a = false) {
let o = 0;
let s = 0;
let c = 0;
let l = "";
const u = r ? n : t;
if (a) {
let t = 0;
for (let n = 0; n < e.length; n++) if (e.charCodeAt(n) !== 0) {
t = n;
break;
}
e = e.slice(t);
}
while (o < e.length) {
const t = e.charCodeAt(o++);
if (o >= e.length) s = 1;
const n = e.charCodeAt(o++);
if (o >= e.length) c = 1;
const r = e.charCodeAt(o++);
const a = t >> 2;
const d = (t & 3) << 4 | n >> 4;
let f = (n & 15) << 2 | r >> 6;
let p = r & 63;
if (s === 1) f = p = 64;
else if (c === 1) p = 64;
if (i) {
if (f === 64) l += `${u.charAt(a)}${u.charAt(d)}`;
else if (p === 64) l += `${u.charAt(a)}${u.charAt(d)}${u.charAt(f)}`;
else l += `${u.charAt(a)}${u.charAt(d)}${u.charAt(f)}${u.charAt(p)}`;
} else l += `${u.charAt(a)}${u.charAt(d)}${u.charAt(f)}${u.charAt(p)}`;
}
return l;
}
function fromBase64(e, r = false, i = false) {
const a = r ? n : t;
function indexOf(e) {
for (let t = 0; t < 64; t++) if (a.charAt(t) === e) return t;
return 64;
}
function test(e) {
return e === 64 ? 0 : e;
}
let o = 0;
let s = "";
while (o < e.length) {
const t = indexOf(e.charAt(o++));
const n = o >= e.length ? 0 : indexOf(e.charAt(o++));
const r = o >= e.length ? 0 : indexOf(e.charAt(o++));
const i = o >= e.length ? 0 : indexOf(e.charAt(o++));
const a = test(t) << 2 | test(n) >> 4;
const c = (test(n) & 15) << 4 | test(r) >> 2;
const l = (test(r) & 3) << 6 | test(i);
s += String.fromCharCode(a);
if (r !== 64) s += String.fromCharCode(c);
if (i !== 64) s += String.fromCharCode(l);
}
if (i) {
const e = s.length;
let t = -1;
for (let n = e - 1; n >= 0; n--) if (s.charCodeAt(n) !== 0) {
t = n;
break;
}
if (t !== -1) s = s.slice(0, t + 1);
else s = "";
}
return s;
}
function arrayBufferToString(e) {
let t = "";
const n = new Uint8Array(e);
for (const e of n) t += String.fromCharCode(e);
return t;
}
function stringToArrayBuffer(e) {
const t = e.length;
const n = new ArrayBuffer(t);
const r = new Uint8Array(n);
for (let n = 0; n < t; n++) r[n] = e.charCodeAt(n);
return n;
}
const r = Math.log(2);
function nearestPowerOf2(e) {
const t = Math.log(e) / r;
const n = Math.floor(t);
const i = Math.round(t);
return n === i ? n : i;
}
function clearProps(e, t) {
for (const n of t) delete e[n];
}
e.arrayBufferToString = arrayBufferToString;
e.bufferToHexCodes = bufferToHexCodes;
e.checkBufferParams = checkBufferParams;
e.clearProps = clearProps;
e.fromBase64 = fromBase64;
e.getParametersValue = getParametersValue;
e.getUTCDate = getUTCDate;
e.isEqualBuffer = isEqualBuffer;
e.nearestPowerOf2 = nearestPowerOf2;
e.padNumber = padNumber;
e.stringToArrayBuffer = stringToArrayBuffer;
e.toBase64 = toBase64;
e.utilConcatBuf = utilConcatBuf;
e.utilConcatView = utilConcatView;
e.utilDecodeTC = utilDecodeTC;
e.utilEncodeTC = utilEncodeTC;
e.utilFromBase = utilFromBase;
e.utilToBase = utilToBase;
}));
//#endregion
//#region node_modules/.pnpm/asn1js@3.1.0/node_modules/asn1js/build/index.js
/*!
* Copyright (c) 2014, GMO GlobalSign
* Copyright (c) 2015-2022, Peculiar Ventures
* All rights reserved.
*
* Author 2014-2019, Yury Strozhevsky
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
var require_build = /* @__PURE__ */ __commonJSMin(((e) => {
var t = require_build$1();
var n = require_utils();
function _interopNamespaceDefault(e) {
var t = Object.create(null);
if (e) Object.keys(e).forEach(function(n) {
if (n !== "default") {
var r = Object.getOwnPropertyDescriptor(e, n);
Object.defineProperty(t, n, r.get ? r : {
enumerable: true,
get: function() {
return e[n];
}
});
}
});
t.default = e;
return Object.freeze(t);
}
var r = /*#__PURE__*/ _interopNamespaceDefault(t);
var i = /*#__PURE__*/ _interopNamespaceDefault(n);
function assertBigInt() {
if (typeof BigInt === "undefined") throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.");
}
function concat(e) {
let t = 0;
let n = 0;
for (let n = 0; n < e.length; n++) {
const r = e[n];
t += r.byteLength;
}
const r = new Uint8Array(t);
for (let t = 0; t < e.length; t++) {
const i = e[t];
r.set(i instanceof Uint8Array ? i : new Uint8Array(i), n);
n += i.byteLength;
}
return r.buffer;
}
function checkBufferParams(e, t, n, r) {
if (!(t instanceof Uint8Array)) {
e.error = "Wrong parameter: inputBuffer must be 'Uint8Array'";
return false;
}
if (!t.byteLength) {
e.error = "Wrong parameter: inputBuffer has zero length";
return false;
}
if (n < 0) {
e.error = "Wrong parameter: inputOffset less than zero";
return false;
}
if (r < 0) {
e.error = "Wrong parameter: inputLength less than zero";
return false;
}
if (t.byteLength - n - r < 0) {
e.error = "End of input reached before message was fully decoded (inconsistent offset and length values)";
return false;
}
return true;
}
var ViewWriter = class {
constructor() {
this.items = [];
}
write(e) {
this.items.push(e instanceof ArrayBuffer ? e : concat([e]));
}
final() {
return concat(this.items);
}
};
const a = ViewWriter.prototype.write;
const o = ViewWriter.prototype.final;
const s = "name";
const c = "valueHexView";
const l = "isHexOnly";
const u = "idBlock";
const d = "tagClass";
const f = "tagNumber";
const p = "isConstructed";
const m = "fromBER";
const h = "toBER";
const ee = "local";
const g = "";
const _ = /* @__PURE__ */ new ArrayBuffer(0);
const v = /* @__PURE__ */ new Uint8Array(0);
const y = "EndOfContent";
const te = "OCTET STRING";
const b = "BIT STRING";
function HexBlock(e) {
var t = class Some extends e {
get valueHex() {
return this.valueHexView.slice().buffer;
}
set valueHex(e) {
this.valueHexView = new Uint8Array(e);
}
constructor(...e) {
var t;
super(...e);
const n = e[0] || {};
this.isHexOnly = (t = n.isHexOnly) !== null && t !== void 0 ? t : false;
this.valueHexView = n.valueHex ? r.BufferSourceConverter.toUint8Array(n.valueHex) : v;
}
fromBER(e, t, n, r) {
const i = e instanceof ArrayBuffer ? new Uint8Array(e) : e;
if (!checkBufferParams(this, i, t, n)) return -1;
const a = t + n;
this.valueHexView = i.subarray(t, a);
if (!this.valueHexView.length) {
this.warnings.push("Zero buffer length");
return t;
}
this.blockLength = n;
return a;
}
toBER(e = false) {
if (!this.isHexOnly) {
this.error = "Flag 'isHexOnly' is not set, abort";
return _;
}
if (e) return new ArrayBuffer(this.valueHexView.byteLength);
if (this.valueHexView.buffer instanceof ArrayBuffer && this.valueHexView.byteLength === this.valueHexView.buffer.byteLength) return this.valueHexView.buffer;
return r.BufferSourceConverter.toArrayBuffer(this.valueHexView);
}
toJSON() {
return {
...super.toJSON(),
isHexOnly: this.isHexOnly,
valueHex: r.Convert.ToHex(this.valueHexView)
};
}
};
return t.NAME = "hexBlock", t;
}
var LocalBaseBlock = class {
static blockName() {
return this.NAME;
}
get valueBeforeDecode() {
return this.valueBeforeDecodeView.slice().buffer;
}
set valueBeforeDecode(e) {
this.valueBeforeDecodeView = new Uint8Array(e);
}
constructor({ blockLength: e = 0, error: t = g, warnings: n = [], valueBeforeDecode: i = v } = {}) {
this.blockLength = e;
this.error = t;
this.warnings = n;
this.valueBeforeDecodeView = r.BufferSourceConverter.toUint8Array(i);
}
toJSON() {
return {
blockName: this.constructor.NAME,
blockLength: this.blockLength,
error: this.error,
warnings: this.warnings,
valueBeforeDecode: r.Convert.ToHex(this.valueBeforeDecodeView)
};
}
};
LocalBaseBlock.NAME = "baseBlock";
var ValueBlock = class extends LocalBaseBlock {
fromBER(e, t, n, r) {
throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'");
}
toBER(e, t) {
throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'");
}
};
ValueBlock.NAME = "valueBlock";
var LocalIdentificationBlock = class extends HexBlock(LocalBaseBlock) {
constructor({ idBlock: e = {} } = {}) {
var t, n, i, a;
super();
if (e) {
this.isHexOnly = (t = e.isHexOnly) !== null && t !== void 0 ? t : false;
this.valueHexView = e.valueHex ? r.BufferSourceConverter.toUint8Array(e.valueHex) : v;
this.tagClass = (n = e.tagClass) !== null && n !== void 0 ? n : -1;
this.tagNumber = (i = e.tagNumber) !== null && i !== void 0 ? i : -1;
this.isConstructed = (a = e.isConstructed) !== null && a !== void 0 ? a : false;
} else {
this.tagClass = -1;
this.tagNumber = -1;
this.isConstructed = false;
}
}
toBER(e = false) {
let t = 0;
switch (this.tagClass) {
case 1:
t |= 0;
break;
case 2:
t |= 64;
break;
case 3:
t |= 128;
break;
case 4:
t |= 192;
break;
default:
this.error = "Unknown tag class";
return _;
}
if (this.isConstructed) t |= 32;
if (this.tagNumber < 31 && !this.isHexOnly) {
const n = /* @__PURE__ */ new Uint8Array(1);
if (!e) {
let e = this.tagNumber;
e &= 31;
t |= e;
n[0] = t;
}
return n.buffer;
}
if (!this.isHexOnly) {
const n = i.utilToBase(this.tagNumber, 7);
const r = new Uint8Array(n);
const a = n.byteLength;
const o = new Uint8Array(a + 1);
o[0] = t | 31;
if (!e) {
for (let e = 0; e < a - 1; e++) o[e + 1] = r[e] | 128;
o[a] = r[a - 1];
}
return o.buffer;
}
const n = new Uint8Array(this.valueHexView.byteLength + 1);
n[0] = t | 31;
if (!e) {
const e = this.valueHexView;
for (let t = 0; t < e.length - 1; t++) n[t + 1] = e[t] | 128;
n[this.valueHexView.byteLength] = e[e.length - 1];
}
return n.buffer;
}
fromBER(e, t, n) {
const a = r.BufferSourceConverter.toUint8Array(e);
if (!checkBufferParams(this, a, t, n)) return -1;
const o = Number.isInteger(t) && Number.isInteger(n);
const s = o ? a : a.subarray(t, t + n);
const c = o ? t : 0;
const l = o ? n : s.length;
if (l === 0) {
this.error = "Zero buffer length";
return -1;
}
switch (s[c] & 192) {
case 0:
this.tagClass = 1;
break;
case 64:
this.tagClass = 2;
break;
case 128:
this.tagClass = 3;
break;
case 192:
this.tagClass = 4;
break;
default:
this.error = "Unknown tag class";
return -1;
}
this.isConstructed = (s[c] & 32) === 32;
this.isHexOnly = false;
const u = s[c] & 31;
if (u !== 31) {
this.tagNumber = u;
this.blockLength = 1;
} else {
let e = 0;
while (true) {
const t = e + 1;
if (t >= l) {
this.error = "End of input reached before message was fully decoded";
return -1;
}
e++;
if ((s[c + t] & 128) === 0) break;
}
this.blockLength = e + 1;
const t = this.valueHexView = new Uint8Array(e);
for (let n = 0; n < e; n++) t[n] = s[c + n + 1] & 127;
if (this.blockLength <= 9) this.tagNumber = i.utilFromBase(t, 7);
else {
this.isHexOnly = true;
this.warnings.push("Tag too long, represented as hex-coded");
}
}
if (this.tagClass === 1 && this.isConstructed) switch (this.tagNumber) {
case 1:
case 2:
case 5:
case 6:
case 9:
case 13:
case 14:
case 23:
case 24:
case 31:
case 32:
case 33:
case 34:
this.error = "Constructed encoding used for primitive type";
return -1;
}
return t + this.blockLength;
}
toJSON() {
return {
...super.toJSON(),
tagClass: this.tagClass,
tagNumber: this.tagNumber,
isConstructed: this.isConstructed
};
}
};
LocalIdentificationBlock.NAME = "identificationBlock";
const ne = LocalIdentificationBlock.prototype.toBER;
const re = LocalIdentificationBlock.prototype.fromBER;
var LocalLengthBlock = class extends LocalBaseBlock {
constructor({ lenBlock: e = {} } = {}) {
var t, n, r;
super();
this.isIndefiniteForm = (t = e.isIndefiniteForm) !== null && t !== void 0 ? t : false;
this.longFormUsed = (n = e.longFormUsed) !== null && n !== void 0 ? n : false;
this.length = (r = e.length) !== null && r !== void 0 ? r : 0;
}
fromBER(e, t, n) {
const a = r.BufferSourceConverter.toUint8Array(e);
if (!checkBufferParams(this, a, t, n)) return -1;
const o = Number.isInteger(t) && Number.isInteger(n);
const s = o ? a : a.subarray(t, t + n);
const c = o ? t : 0;
const l = o ? n : s.length;
if (l === 0) {
this.error = "Zero buffer length";
return -1;
}
if (s[c] === 255) {
this.error = "Length block 0xFF is reserved by standard";
return -1;
}
this.isIndefiniteForm = s[c] === 128;
if (this.isIndefiniteForm) {
this.blockLength = 1;
return t + this.blockLength;
}
this.longFormUsed = !!(s[c] & 128);
if (this.longFormUsed === false) {
this.length = s[c];
this.blockLength = 1;
return t + this.blockLength;
}
const u = s[c] & 127;
if (u > 8) {
this.error = "Too big integer";
return -1;
}
if (u + 1 > l) {
this.error = "End of input reached before message was fully decoded";
return -1;
}
const d = t + 1;
const f = a.subarray(d, d + u);
if (f[u - 1] === 0) this.warnings.push("Needlessly long encoded length");
this.length = i.utilFromBase(f, 8);
if (this.longFormUsed && this.length <= 127) this.warnings.push("Unnecessary usage of long length form");
this.blockLength = u + 1;
return t + this.blockLength;
}
toBER(e = false) {
let t;
let n;
if (this.length > 127) this.longFormUsed = true;
if (this.isIndefiniteForm) {
t = /* @__PURE__ */ new ArrayBuffer(1);
if (e === false) {
n = new Uint8Array(t);
n[0] = 128;
}
return t;
}
if (this.longFormUsed) {
const r = i.utilToBase(this.length, 8);
if (r.byteLength > 127) {
this.error = "Too big length";
return _;
}
t = new ArrayBuffer(r.byteLength + 1);
if (e) return t;
const a = new Uint8Array(r);
n = new Uint8Array(t);
n[0] = r.byteLength | 128;
for (let e = 0; e < r.byteLength; e++) n[e + 1] = a[e];
return t;
}
t = /* @__PURE__ */ new ArrayBuffer(1);
if (e === false) {
n = new Uint8Array(t);
n[0] = this.length;
}
return t;
}
toJSON() {
return {
...super.toJSON(),
isIndefiniteForm: this.isIndefiniteForm,
longFormUsed: this.longFormUsed,
length: this.length
};
}
};
LocalLengthBlock.NAME = "lengthBlock";
const ie = LocalLengthBlock.prototype.toBER;
const ae = LocalLengthBlock.prototype.fromBER;
const x = {};
var S;
var C;
var w;
const oe = findMethod(Uint8Array.prototype, "slice");
const se = (S = Object.getOwnPropertyDescriptor(Uint8Array.prototype, "constructor")) === null || S === void 0 ? void 0 : S.value;
const ce = (C = Object.getOwnPropertyDescriptor(Array.prototype, Symbol.iterator)) === null || C === void 0 ? void 0 : C.value;
const T = (w = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), "byteLength")) === null || w === void 0 ? void 0 : w.get;
const le = 16384;
const E = 64;
let D;
function registerBuiltinEncoder(e, t) {
const n = t || D;
if (!n) {
D = void 0;
return;
}
D = {
...n,
...e
};
}
function dataProperty(e, t) {
const n = Object.getOwnPropertyDescriptor(e, t);
if (!n || !("value" in n)) return void 0;
return n.value;
}
function intrinsicPayloadByteLength(e) {
if (!T || !e || typeof e !== "object") return void 0;
try {
const t = T.call(e);
return typeof t === "number" ? t : void 0;
} catch {
return;
}
}
function largePayloadOrChain(e, t) {
if (t > E || !e || typeof e !== "object") return false;
const n = Object.getOwnPropertyDescriptor(e, "valueBlock");
if (!n || !("value" in n)) return false;
const r = n.value;
if (!r || typeof r !== "object") return false;
const i = Object.getOwnPropertyDescriptor(r, "valueHexView");
if (i) {
if (!("value" in i)) return false;
const e = intrinsicPayloadByteLength(i.value);
return e !== void 0 && e >= le;
}
const a = Object.getOwnPropertyDescriptor(r, "value");
if (!a || !("value" in a) || !Array.isArray(a.value)) return false;
const o = a.value;
const s = Object.getOwnPropertyDescriptor(o, "length");
if (!s || !("value" in s) || s.value !== 1) return false;
const c = Object.getOwnPropertyDescriptor(o, "0");
if (!c || !("value" in c)) return false;
return largePayloadOrChain(c.value, t + 1);
}
function shouldUseBuiltinEncoder(e) {
try {
return largePayloadOrChain(e, 0);
} catch {
return false;
}
}
function sameDataMethod(e, t) {
return !!e && "value" in e && e.value === t && e.writable === true && e.enumerable === false && e.configurable === true;
}
function writerMethodsStable(e) {
return sameDataMethod(Object.getOwnPropertyDescriptor(e.ViewWriter.prototype, "write"), e.originalWriterWrite) && sameDataMethod(Object.getOwnPropertyDescriptor(e.ViewWriter.prototype, "final"), e.originalWriterFinal);
}
function findMethod(e, t) {
let n = e;
while (n) {
const e = Object.getOwnPropertyDescriptor(n, t);
if (e) {
if ("value" in e && typeof e.value === "function") return {
declaringPrototype: n,
method: e.value
};
return;
}
n = Object.getPrototypeOf(n);
}
}
function stableInheritedMethod(e, t, n) {
if (!n) return false;
let r = e;
while (r) {
const e = Object.getOwnPropertyDescriptor(r, t);
if (r === n.declaringPrototype) return !!e && "value" in e && e.value === n.method;
if (e) return false;
r = Object.getPrototypeOf(r);
}
return false;
}
function prototypeMethod(e, t, n, r) {
if (Object.prototype.hasOwnProperty.call(e, n)) return false;
if (Object.getPrototypeOf(e) !== t) return false;
const i = Object.getOwnPropertyDescriptor(t, n);
return !!i && "value" in i && i.value === r;
}
function inheritedMethod(e, t, n, r) {
if (Object.prototype.hasOwnProperty.call(e, t)) return false;
const i = Object.getPrototypeOf(e);
const a = Object.getPrototypeOf(r.prototype);
if (i !== r.prototype || Object.getPrototypeOf(i) !== a) return false;
if (i && Object.getOwnPropertyDescriptor(i, t)) return false;
const o = Object.getOwnPropertyDescriptor(a, t);
return !!o && "value" in o && o.value === n;
}
function plainPayload(e, t = false) {
if (!(e instanceof Uint8Array) || Object.getPrototypeOf(e) !== Uint8Array.prototype) return void 0;
for (const t of [
"buffer",
"byteOffset",
"byteLength",
"length",
"slice",
"constructor"
]) if (Object.prototype.hasOwnProperty.call(e, t)) return void 0;
const n = Object.getOwnPropertyDescriptor(Uint8Array.prototype, "constructor");
if (!n || !("value" in n) || n.value !== se) return void 0;
if (!stableInheritedMethod(Uint8Array.prototype, "slice", oe)) return void 0;
try {
const n = e.buffer;
if (!(n instanceof ArrayBuffer) || Object.getPrototypeOf(n) !== ArrayBuffer.prototype) return void 0;
if (Object.prototype.hasOwnProperty.call(n, "byteLength")) return void 0;
if (e.byteLength !== e.length || !t && e.byteLength === 0) return void 0;
if (e.byteOffset < 0 || e.byteOffset + e.byteLength > n.byteLength) return void 0;
} catch {
return;
}
return e;
}
function validIdBlock(e, t, n) {
if (Object.getPrototypeOf(e) !== n.LocalIdentificationBlock.prototype) return false;
if (!prototypeMethod(e, n.LocalIdentificationBlock.prototype, "toBER", n.originalIdentificationToBER)) return false;
const r = dataProperty(e, "tagClass");
const i = dataProperty(e, "tagNumber");
const a = dataProperty(e, "isConstructed");
const o = dataProperty(e, "isHexOnly");
const s = dataProperty(e, "valueHexView");
if (typeof r !== "number" || !Number.isInteger(r) || r < 1 || r > 4) return false;
if (typeof i !== "number" || !Number.isInteger(i) || i < 0) return false;
if (a !== t || typeof o !== "boolean") return false;
if (o) return !!plainPayload(s);
return Number.isSafeInteger(i);
}
function validLengthBlock(e, t, n) {
if (Object.getPrototypeOf(e) !== n.LocalLengthBlock.prototype) return false;
if (!prototypeMethod(e, n.LocalLengthBlock.prototype, "toBER", n.originalLengthToBER)) return false;
const r = dataProperty(e, "isIndefiniteForm");
const i = dataProperty(e, "longFormUsed");
const a = Object.getOwnPropertyDescriptor(e, "length");
const o = a && "value" in a ? a.value : void 0;
const s = Object.getOwnPropertyDescriptor(e, "longFormUsed");
return typeof r === "boolean" && (r === false || t) && typeof i === "boolean" && !!s && "value" in s && s.writable === true && !!a && "value" in a && a.writable === true && typeof o === "number" && Number.isSafeInteger(o) && o >= 0;
}
function validBaseBlock(e, t, n) {
const r = dataProperty(e, "idBlock");
const i = dataProperty(e, "lenBlock");
return !!r && !!i && validIdBlock(r, t, n) && validLengthBlock(i, t, n);
}
function constructedChild(e, t) {
const n = dataProperty(e, "valueBlock");
if (!n || Object.getPrototypeOf(n) !== t.LocalConstructedValueBlock.prototype) return void 0;
if (!prototypeMethod(n, t.LocalConstructedValueBlock.prototype, "toBER", t.originalConstructedToBER)) return void 0;
const r = dataProperty(n, "value");
if (!Array.isArray(r) || Object.getPrototypeOf(r) !== Array.prototype) return void 0;
const i = Object.getOwnPropertyDescriptor(r, "length");
if (!i || !("value" in i) || i.value !== 1) return void 0;
if (Object.prototype.hasOwnProperty.call(r, Symbol.iterator)) return void 0;
const a = Object.getOwnPropertyDescriptor(Array.prototype, Symbol.iterator);
if (!a || !("value" in a) || a.value !== ce) return void 0;
const o = Object.getOwnPropertyDescriptor(r, "0");
if (!o || !("value" in o)) return void 0;
if (Object.getOwnPropertyNames(r).length !== 2) return void 0;
return o.value;
}
function bitPayload(e, t) {
const n = dataProperty(e, "valueBlock");
if (!n || Object.getPrototypeOf(n) !== t.LocalBitStringValueBlock.prototype) return void 0;
if (!prototypeMethod(n, t.LocalBitStringValueBlock.prototype, "toBER", t.originalBitStringToBER)) return void 0;
if (dataProperty(n, "isConstructed") !== false) return void 0;
const r = dataProperty(n, "unusedBits");
if (typeof r !== "number" || !Number.isInteger(r) || r < 0 || r > 7) return void 0;
const i = plainPayload(dataProperty(n, "valueHexView"), true);
if (!i) return void 0;
return {
payload: i,
prefix: Uint8Array.of(i.byteLength ? r : 0)
};
}
function primitivePayload(e, t, n) {
const r = dataProperty(e, "valueBlock");
if (!r) return void 0;
if (t === "integer") {
if (Object.getPrototypeOf(r) !== n.LocalIntegerValueBlock.prototype) return void 0;
if (!prototypeMethod(r, n.LocalIntegerValueBlock.prototype, "toBER", n.originalIntegerToBER)) return void 0;
} else if (t === "octet") {
if (Object.getPrototypeOf(r) !== n.LocalOctetStringValueBlock.prototype) return void 0;
if (!prototypeMethod(r, n.LocalOctetStringValueBlock.prototype, "toBER", n.originalOctetStringToBER)) return void 0;
if (dataProperty(r, "isConstructed") !== false) return void 0;
} else {
if (Object.getPrototypeOf(r) !== n.LocalPrimitiveValueBlock.prototype) return void 0;
if (!inheritedMethod(r, "toBER", n.originalPrimitiveToBER, n.LocalPrimitiveValueBlock)) return void 0;
}
if (t === "primitive" && dataProperty(r, "isHexOnly") !== true) return void 0;
if (typeof dataProperty(r, "isHexOnly") !== "boolean") return void 0;
return plainPayload(dataProperty(r, "valueHexView"));
}
function validOuterMethod(e, t) {
if (Object.prototype.hasOwnProperty.call(e, "toBER")) return false;
let n = e;
while (n) {
const e = Object.getOwnPropertyDescriptor(n, "toBER");
if (e) return "value" in e && e.value === t.originalBaseBlockToBER;
n = Object.getPrototypeOf(n);
}
return false;
}
function isPrimitive(e, t, n) {
const r = n[t];
return !!r && Object.getPrototypeOf(e) === r.prototype;
}
function isConstructed(e, t) {
return Object.getPrototypeOf(e) === t.Sequence.prototype || Object.getPrototypeOf(e) === t.Set.prototype || Object.getPrototypeOf(e) === t.Constructed.prototype;
}
function inspectNode(e, t, n) {
if (t > E || !e || typeof e !== "object") return void 0;
try {
if (!validOuterMethod(e, n)) return void 0;
const r = isPrimitive(e, "BitString", n) ? "bit" : isPrimitive(e, "Integer", n) ? "integer" : isPrimitive(e, "OctetString", n) ? "octet" : isPrimitive(e, "Primitive", n) ? "primitive" : void 0;
const i = r === void 0 && isConstructed(e, n);
if (!r && !i) return void 0;
if (!validBaseBlock(e, i, n)) return void 0;
const a = dataProperty(e, "idBlock");
const o = dataProperty(e, "lenBlock");
if (!a || !o) return void 0;
if (r) {
const t = r === "bit" ? bitPayload(e, n) : void 0;
const i = r === "bit" ? t === null || t === void 0 ? void 0 : t.payload : primitivePayload(e, r, n);
return i ? {
block: e,
kind: r,
idBlock: a,
lenBlock: o,
indefinite: false,
payload: i,
prefix: t === null || t === void 0 ? void 0 : t.prefix
} : void 0;
}
const s = constructedChild(e, n);
const c = s && inspectNode(s, t + 1, n);
const l = dataProperty(o, "isIndefiniteForm");
return c ? {
block: e,
kind: "constructed",
idBlock: a,
lenBlock: o,
indefinite: l === true,
child: c
} : void 0;
} catch {
return;
}
}
function buildNode(e, t, n) {
var r, i;
const a = Reflect.apply(n.originalIdentificationToBER, e.idBlock, [t]);
if (!(a instanceof ArrayBuffer) || a.byteLength === 0) throw TypeError("Built-in identifier encoding failed");
let o;
if (e.kind === "constructed") o = buildNode(e.child, t, n);
else o = e.payload;
const s = (o instanceof Uint8Array ? o.byteLength : o.total) + ((i = (r = e.prefix) === null || r === void 0 ? void 0 : r.byteLength) !== null && i !== void 0 ? i : 0);
let c;
if (e.indefinite) c = Uint8Array.of(128).buffer;
else {
e.lenBlock.length = s;
c = Reflect.apply(n.originalLengthToBER, e.lenBlock, [t]);
if (!(c instanceof ArrayBuffer) || c.byteLength === 0) throw TypeError("Built-in length encoding failed");
}
const l = a.byteLength + c.byteLength + s + (e.indefinite ? 2 : 0);
if (!Number.isSafeInteger(l)) throw RangeError("Built-in encoding is too large");
return {
id: a,
len: c,
payload: o,
length: s,
total: l,
indefinite: e.indefinite,
prefix: e.prefix
};
}
function flatten(e, t, n, r) {
t.set(new Uint8Array(e.id), n);
n += e.id.byteLength;
t.set(new Uint8Array(e.len), n);
n += e.len.byteLength;
if (e.prefix) {
if (!r) t.set(e.prefix, n);
n += e.prefix.byteLength;
}
if (e.payload instanceof Uint8Array) {
if (!r) t.set(e.payload, n);
n += e.payload.byteLength;
} else n = flatten(e.payload, t, n, r);
if (e.indefinite) n += 2;
return n;
}
function tryEncodeBuiltin(e, t = false) {
const n = D;
if (!n || !writerMethodsStable(n)) return void 0;
const r = inspectNode(e, 0, n);
if (!r) return void 0;
const i = buildNode(r, t, n);
const a = new Uint8Array(i.total);
flatten(i, a, 0, t);
return a.buffer;
}
var BaseBlock = class extends LocalBaseBlock {
constructor({ name: e = g, optional: t = false, primitiveSchema: n, ...r } = {}, i) {
super(r);
this.name = e;
this.optional = t;
if (n) this.primitiveSchema = n;
this.idBlock = new LocalIdentificationBlock(r);
this.lenBlock = new LocalLengthBlock(r);
this.valueBlock = i ? new i(r) : new ValueBlock(r);
}
fromBER(e, t, n, r) {
const i = this.valueBlock.fromBER(e, t, this.lenBlock.isIndefiniteForm ? n : this.lenBlock.length, r);
if (i === -1) {
this.error = this.valueBlock.error;
return i;
}
if (!this.idBlock.error.length) this.blockLength += this.idBlock.blockLength;
if (!this.lenBlock.error.length) this.blockLength += this.lenBlock.blockLength;
if (!this.valueBlock.error.length) this.blockLength += this.valueBlock.blockLength;
return i;
}
toBER(e, t) {
const n = t || new ViewWriter();
if (!t) {
prepareIndefiniteForm(this);
if (e === true || e === false || e === void 0) {
if (shouldUseBuiltinEncoder(this)) {
const t = tryEncodeBuiltin(this, e === true);
if (t) return t;
}
}
}
const r = this.idBlock.toBER(e);
n.write(r);
if (this.lenBlock.isIndefiniteForm) {
n.write(new Uint8Array([128]).buffer);
this.valueBlock.toBER(e, n);
n.write(/* @__PURE__ */ new ArrayBuffer(2));
} else {
const t = this.valueBlock.toBER(e);
this.lenBlock.length = t.byteLength;
const r = this.lenBlock.toBER(e);
n.write(r);
n.write(t);
}
if (!t) return n.final();
return _;
}
toJSON() {
const e = {
...super.toJSON(),
idBlock: this.idBlock.toJSON(),
lenBlock: this.lenBlock.toJSON(),
valueBlock: this.valueBlock.toJSON(),
name: this.name,
optional: this.optional
};
if (this.primitiveSchema) e.primitiveSchema = this.primitiveSchema.toJSON();
return e;
}
toString(e = "ascii") {
if (e === "ascii") return this.onAsciiEncoding();
return r.Convert.ToHex(this.toBER());
}
onAsciiEncoding() {
return `${this.constructor.NAME} : ${r.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`;
}
isEqual(e) {
if (this === e) return true;
if (!(e instanceof this.constructor)) return false;
const t = this.toBER();
const n = e.toBER();
return i.isEqualBuffer(t, n);
}
};
BaseBlock.NAME = "BaseBlock";
const ue = BaseBlock.prototype.toBER;
function prepareIndefiniteForm(e) {
var t;
if (e instanceof x.Constructed) {
for (const t of e.valueBlock.value) if (prepareIndefiniteForm(t)) e.lenBlock.isIndefiniteForm = true;
}
return !!((t = e.lenBlock) === null || t === void 0 ? void 0 : t.isIndefiniteForm);
}
var BaseStringBlock = class extends BaseBlock {
getValue() {
return this.valueBlock.value;
}
setValue(e) {
this.valueBlock.value = e;
}
constructor({ value: e = g, ...t } = {}, n) {
super(t, n);
if (e) this.fromString(e);
}
fromBER(e, t, n) {
const r = this.valueBlock.fromBER(e, t, this.lenBlock.isIndefiniteForm ? n : this.lenBlock.length);
if (r === -1) {
this.error = this.valueBlock.error;
return r;
}
this.fromBuffer(this.valueBlock.valueHexView);
if (!this.idBlock.error.length) this.blockLength += this.idBlock.blockLength;
if (!this.lenBlock.error.length) this.blockLength += this.lenBlock.blockLength;
if (!this.valueBlock.error.length) this.blockLength += this.valueBlock.blockLength;
return r;
}
onAsciiEncoding() {
return `${this.constructor.NAME} : '${this.valueBlock.value}'`;
}
};
BaseStringBlock.NAME = "BaseStringBlock";
var O;
var LocalPrimitiveValueBlock = class extends HexBlock(ValueBlock) {
constructor({ isHexOnly: e = true, ...t } = {}) {
super(t);
this.isHexOnly = e;
}
};
LocalPrimitiveValueBlock.NAME = "PrimitiveValueBlock";
const de = (O = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(LocalPrimitiveValueBlock.prototype), "toBER")) === null || O === void 0 ? void 0 : O.value;
var k;
var Primitive = class extends BaseBlock {
constructor(e = {}) {
super(e, LocalPrimitiveValueBlock);
this.idBlock.isConstructed = false;
}
};
k = Primitive;
(() => {
x.Primitive = k;
})();
Primitive.NAME = "PRIMITIVE";
let A;
function registerFastParser(e) {
A = {
Integer: e.Integer,
Null: e.Null,
Sequence: e.Sequence
};
}
function fastParserContext(e) {
const t = Object.getOwnPropertyDescriptor(e, "nodesCount");
const n = Object.getOwnPropertyDescriptor(e, "maxNodes");
const r = Object.getOwnPropertyDescriptor(e, "maxContentLength");
if (!t || !("value" in t) || t.writable !== true) return false;
if (!n || !("value" in n) || !r || !("value" in r)) return false;
return typeof t.value === "number" && Number.isSafeInteger(t.value) && t.value >= 0 && typeof n.value === "number" && Number.isSafeInteger(n.value) && n.value >= 0 && typeof r.value === "number" && Number.isSafeInteger(r.value) && r.value >= 0 && t.value < n.value;
}
function fastParserType(e, t, n) {
const r = Object.getOwnPropertyDescriptor(e, t);
return !!r && "value" in r && r.value === n;
}
function tryFastFromBER(e, t, n, r) {
const i = A;
if (!i) return void 0;
let a;
let o = 0;
try {
if (Object.getPrototypeOf(e) !== Uint8Array.prototype) return void 0;
if (!Number.isSafeInteger(t) || t < 0 || !Number.isSafeInteger(n) || n < 2) return;
if (t > e.byteLength || n > e.byteLength - t) return void 0;
const s = e[t];
if (s !== 2 && s !== 5 && s !== 48) return void 0;
o = e[t + 1];
if (o >= 128 || o > n - 2) return void 0;
if (s === 5 && o !== 0) return void 0;
if (!fastParserContext(r)) return void 0;
if (o > Object.getOwnPropertyDescriptor(r, "maxContentLength").value) return;
const c = s === 2 ? "Integer" : s === 5 ? "Null" : "Sequence";
a = i[c];
if (!fastParserType(x, c, a)) return void 0;
const l = Object.getOwnPropertyDescriptor(LocalIdentificationBlock.prototype, "fromBER");
const u = Object.getOwnPropertyDescriptor(LocalLengthBlock.prototype, "fromBER");
if (!l || !("value" in l) || l.value !== re || !u || !("value" in u) || u.value !== ae) return void 0;
} catch {
return;
}
if (!a) return void 0;
const s = new a();
s.idBlock.tagClass = 1;
s.idBlock.tagNumber = e[t] & 31;
s.idBlock.isConstructed = e[t] === 48;
s.idBlock.isHexOnly = false;
s.idBlock.blockLength = 1;
s.lenBlock.isIndefiniteForm = false;
s.lenBlock.longFormUsed = false;
s.lenBlock.length = o;
s.lenBlock.blockLength = 1;
r.nodesCount += 1;
const c = s.fromBER(e, t + 2, o, r);
s.valueBeforeDecodeView = e.subarray(t, t + s.blockLength);
return {
offset: c,
result: s
};
}
const j = 100;
const M = 1e4;
const N = 16777216;
const fe = "Maximum ASN.1 nesting depth exceeded";
const pe = "Maximum ASN.1 node count exceeded";
const me = "Maximum ASN.1 content length exceeded";
function createFromBerContext(e = {}) {
var t, n, r, i;
return {
depth: 0,
maxDepth: (t = e.maxDepth) !== null && t !== void 0 ? t : j,
nodesCount: 0,
maxNodes: (n = e.maxNodes) !== null && n !== void 0 ? n : M,
maxContentLength: (r = e.maxContentLength) !== null && r !== void 0 ? r : N,
parseEmbedded: (i = e.parseEmbedded) !== null && i !== void 0 ? i : true
};
}
function createErrorResult(e) {
const t = new BaseBlock({}, ValueBlock);
t.error = e;
return {
offset: -1,
result: t
};
}
function checkNodesLimit(e) {
e.nodesCount += 1;
if (e.nodesCount > e.maxNodes) return pe;
}
function checkContentLengthLimit(e, t) {
if (e > t.maxContentLength) return me;
}
function localFromBERWithChildContext(e, t, n, r) {
const i = r.depth + 1;
if (i > r.maxDepth) return createErrorResult(fe);
r.depth = i;
try {
return localFromBER(e, t, n, r);
} finally {
r.depth -= 1;
}
}
function localChangeType(e, t) {
if (e instanceof t) return e;
const n = new t();
n.idBlock = e.idBlock;
n.lenBlock = e.lenBlock;
n.warnings = e.warnings;
n.valueBeforeDecodeView = e.valueBeforeDecodeView;
return n;
}
function localFromBER(e, t = 0, n = e.length, r = createFromBerContext()) {
const i = tryFastFromBER(e, t, n, r);
if (i) return i;
const a = t;
let o = new BaseBlock({}, ValueBlock);
if (!checkBufferParams(o, e, t, n)) return {
offset: -1,
result: o
};
if (Number.isInteger(t) && Number.isInteger(n) ? n === 0 : e.subarray(t, t + n).length === 0) {
o.error = "Zero buffer length";
return {
offset: -1,
result: o
};
}
const s = checkNodesLimit(r);
if (s) {
o.error = s;
return {
offset: -1,
result: o
};
}
let c = o.idBlock.fromBER(e, t, n);
if (o.idBlock.warnings.length) o.warnings.concat(o.idBlock.warnings);
if (c === -1) {
o.error = o.idBlock.error;
return {
offset: -1,
result: o
};
}
t = c;
n -= o.idBlock.blockLength;
c = o.lenBlock.fromBER(e, t, n);
if (o.lenBlock.warnings.length) o.warnings.concat(o.lenBlock.warnings);
if (c === -1) {
o.error = o.lenBlock.error;
return {
offset: -1,
result: o
};
}
t = c;
n -= o.lenBlock.blockLength;
const l = o.lenBlock.isIndefiniteForm ? n : o.lenBlock.length;
const u = checkContentLengthLimit(l, r);
if (u) {
o.error = u;
return {
offset: -1,
result: o
};
}
if (!o.idBlock.isConstructed && o.lenBlock.isIndefiniteForm) {
o.error = "Indefinite length form used for primitive encoding form";
return {
offset: -1,
result: o
};
}
let d = BaseBlock;
switch (o.idBlock.tagClass) {
case 1:
if (o.idBlock.tagNumber >= 37 && o.idBlock.isHexOnly === false) {
o.error = "UNIVERSAL 37 and upper tags are reserved by ASN.1 standard";
return {
offset: -1,
result: o
};
}
switch (o.idBlock.tagNumber) {
case 0:
if (o.idBlock.isConstructed && o.lenBlock.length > 0) {
o.error = "Type [UNIVERSAL 0] is reserved";
return {
offset: -1,
result: o
};
}
d = x.EndOfContent;
break;
case 1:
d = x.Boolean;
break;
case 2:
d = x.Integer;
break;
case 3:
d = x.BitString;
break;
case 4:
d = x.OctetString;
break;
case 5:
d = x.Null;
break;
case 6:
d = x.ObjectIdentifier;
break;
case 10:
d = x.Enumerated;
break;
case 12:
d = x.Utf8String;
break;
case 13:
d = x.RelativeObjectIdentifier;
break;
case 14:
d = x.TIME;
break;
case 15:
o.error = "[UNIVERSAL 15] is reserved by ASN.1 standard";
return {
offset: -1,
result: o
};
case 16:
d = x.Sequence;
break;
case 17:
d = x.Set;
break;
case 18:
d = x.NumericString;
break;
case 19:
d = x.PrintableString;
break;
case 20:
d = x.TeletexString;
break;
case 21:
d = x.VideotexString;
break;
case 22:
d = x.IA5String;
break;
case 23:
d = x.UTCTime;
break;
case 24:
d = x.GeneralizedTime;
break;
case 25:
d = x.GraphicString;
break;
case 26:
d = x.VisibleString;
break;
case 27:
d = x.GeneralString;
break;
case 28:
d = x.UniversalString;
break;
case 29:
d = x.CharacterString;
break;
case 30:
d = x.BmpString;
break;
case 31:
d = x.DATE;
break;
case 32:
d = x.TimeOfDay;
break;
case 33:
d = x.DateTime;
break;
case 34:
d = x.Duration;
break;
default: {
const e = o.idBlock.isConstructed ? new x.Constructed() : new x.Primitive();
e.idBlock = o.idBlock;
e.lenBlock = o.lenBlock;
e.warnings = o.warnings;
o = e;
}
}
break;
default: d = o.idBlock.isConstructed ? x.Constructed : x.Primitive;
}
o = localChangeType(o, d);
c = o.fromBER(e, t, l, r);
o.valueBeforeDecodeView = e.subarray(a, a + o.blockLength);
return {
offset: c,
result: o
};
}
function fromBER(e, t = {}) {
if (!e.byteLength) {
const e = new BaseBlock({}, ValueBlock);
e.error = "Input buffer has zero length";
return {
offset: -1,
result: e
};
}
const n = r.BufferSourceConverter.toUint8Array(e);
return localFromBER(t.copyInput === false ? n : n.slice(), 0, e.byteLength, createFromBerContext(t));
}
function checkLen(e, t) {
if (e) return 1;
return t;
}
var LocalConstructedValueBlock = class extends ValueBlock {
constructor({ value: e = [], isIndefiniteForm: t = false, ...n } = {}) {
super(n);
this.value = e;
this.isIndefiniteForm = t;
}
fromBER(e, t, n, i) {
const a = r.BufferSourceConverter.toUint8Array(e);
const o = i !== null && i !== void 0 ? i : createFromBerContext();
if (!checkBufferParams(this, a, t, n)) return -1;
this.valueBeforeDecodeView = a.subarray(t, t + n);
if (this.valueBeforeDecodeView.length === 0) {
this.warnings.push("Zero buffer length");
return t;
}
let s = t;
while (checkLen(this.isIndefiniteForm, n) > 0) {
const e = localFromBERWithChildContext(a, s, n, o);
if (e.offset === -1) {
this.error = e.result.error;
this.warnings.concat(e.result.warnings);
return -1;
}
s = e.offset;
this.blockLength += e.result.blockLength;
n -= e.result.blockLength;
this.value.push(e.result);
if (this.isIndefiniteForm && e.result.constructor.NAME === y) break;
}
if (this.isIndefiniteForm) {
if (this.value[this.value.length - 1].constructor.NAME === y) this.value.pop();
else this.warnings.push("No EndOfContent block encoded");
}
return s;
}
toBER(e, t) {
const n = t || new ViewWriter();
for (let t = 0; t < this.value.length; t++) this.value[t].toBER(e, n);
if (!t) return n.final();
return _;
}
toJSON() {
const e = {
...super.toJSON(),
isIndefiniteForm: this.isIndefiniteForm,
value: []
};
for (const t of this.value) e.value.push(t.toJSON());
return e;
}
};
LocalConstructedValueBlock.NAME = "ConstructedValueBlock";
const he = LocalConstructedValueBlock.prototype.toBER;
var P;
var Constructed = class extends BaseBlock {
constructor(e = {}) {
super(e, LocalConstructedValueBlock);
this.idBlock.isConstructed = true;
}
fromBER(e, t, n, r) {
this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm;
const i = this.valueBlock.fromBER(e, t, this.lenBlock.isIndefiniteForm ? n : this.lenBlock.length, r);
if (i === -1) {
this.error = this.valueBlock.error;
return i;
}
if (!this.idBlock.error.length) this.blockLength += this.idBlock.blockLength;
if (!this.lenBlock.error.length) this.blockLength += this.lenBlock.blockLength;
if (!this.valueBlock.error.length) this.blockLength += this.valueBlock.blockLength;
return i;
}
onAsciiEncoding() {
const e = [];
for (const t of this.valueBlock.value) e.push(t.toString("ascii").split("\n").map((e) => ` ${e}`).join("\n"));
const t = this.idBlock.tagClass === 3 ? `[${this.idBlock.tagNumber}]` : this.constructor.NAME;
return e.length ? `${t} :\n${e.join("\n")}` : `${t} :`;
}
};
P = Constructed;
(() => {
x.Constructed = P;
})();
Constructed.NAME = "CONSTRUCTED";
var LocalEndOfContentValueBlock = class extends ValueBlock {
fromBER(e, t, n) {
return t;
}
toBER(e) {
return _;
}
};
LocalEndOfContentValueBlock.override = "EndOfContentValueBlock";
var F;
var EndOfContent = class extends BaseBlock {
constructor(e = {}) {
super(e, LocalEndOfContentValueBlock);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 0;
}
};
F = EndOfContent;
(() => {
x.EndOfContent = F;
})();
EndOfContent.NAME = y;
var I;
var Null = class extends BaseBlock {
constructor(e = {}) {
super(e, ValueBlock);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 5;
}
fromBER(e, t, n) {
if (this.lenBlock.length > 0) this.warnings.push("Non-zero length of value block for Null type");
if (!this.idBlock.error.length) this.blockLength += this.idBlock.blockLength;
if (!this.lenBlock.error.length) this.blockLength += this.lenBlock.blockLength;
this.blockLength += n;
if (t + n > e.byteLength) {
this.error = "End of input reached before message was fully decoded (inconsistent offset and length values)";
return -1;
}
return t + n;
}
toBER(e, t) {
const n = /* @__PURE__ */ new ArrayBuffer(2);
if (!e) {
const e = new Uint8Array(n);
e[0] = 5;
e[1] = 0;
}
if (t) t.write(n);
return n;
}
onAsciiEncoding() {
return `${this.constructor.NAME}`;
}
};
I = Null;
(() => {
x.Null = I;
})();
Null.NAME = "NULL";
var LocalBooleanValueBlock = class extends HexBlock(ValueBlock) {
get value() {
for (const e of this.valueHexView) if (e > 0) return true;
return false;
}
set value(e) {
this.valueHexView[0] = e ? 255 : 0;
}
constructor({ value: e, ...t } = {}) {
super(t);
if (t.valueHex) this.valueHexView = r.BufferSourceConverter.toUint8Array(t.valueHex);
else this.valueHexView = /* @__PURE__ */ new Uint8Array(1);
if (e) this.value = e;
}
fromBER(e, t, n) {
const a = r.BufferSourceConverter.toUint8Array(e);
if (!checkBufferParams(this, a, t, n)) return -1;
this.valueHexView = a.subarray(t, t + n);
if (n > 1) this.warnings.push("Boolean value encoded in more then 1 octet");
this.isHexOnly = true;
i.utilDecodeTC.call(this);
this.blockLength = n;
return t + n;
}
toBER() {
return this.valueHexView.slice().buffer;
}
toJSON() {
return {
...super.toJSON(),
value: this.value
};
}
};
LocalBooleanValueBlock.NAME = "BooleanValueBlock";
var L;
var Boolean = class extends BaseBlock {
getValue() {
return this.valueBlock.value;
}
setValue(e) {
this.valueBlock.value = e;
}
constructor(e = {}) {
super(e, LocalBooleanValueBlock);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 1;
}
onAsciiEncoding() {
return `${this.constructor.NAME} : ${this.getValue}`;
}
};
L = Boolean;
(() => {
x.Boolean = L;
})();
Boolean.NAME = "BOOLEAN";
var LocalOctetStringValueBlock = class extends HexBlock(LocalConstructedValueBlock) {
constructor({ isConstructed: e = false, ...t } = {}) {
super(t);
this.isConstructed = e;
}
fromBER(e, t, n, r) {
let i = 0;
if (this.isConstructed) {
this.isHexOnly = false;
i = LocalConstructedValueBlock.prototype.fromBER.call(this, e, t, n, r);
if (i === -1) return i;
for (let e = 0; e < this.value.length; e++) {
const t = this.value[e].constructor.NAME;
if (t === y) {
if (this.isIndefiniteForm) break;
else {
this.error = "EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only";
return -1;
}
}
if (t !== te) {
this.error = "OCTET STRING may consists of OCTET STRINGs only";
return -1;
}
}
} else {
this.isHexOnly = true;
i = super.fromBER(e, t, n);
this.blockLength = n;
}
return i;
}
toBER(e, t) {
if (this.isConstructed) return LocalConstructedValueBlock.prototype.toBER.call(this, e, t);
return e ? new ArrayBuffer(this.valueHexView.byteLength) : this.valueHexView.slice().buffer;
}
toJSON() {
return {
...super.toJSON(),
isConstructed: this.isConstructed
};
}
};
LocalOctetStringValueBlock.NAME = "OctetStringValueBlock";
const ge = LocalOctetStringValueBlock.prototype.toBER;
var R;
var OctetString = class extends BaseBlock {
constructor({ idBlock: e = {}, lenBlock: t = {}, ...n } = {}) {
var r, i;
(r = n.isConstructed) !== null && r !== void 0 || (n.isConstructed = !!((i = n.value) === null || i === void 0 ? void 0 : i.length));
super({
idBlock: {
isConstructed: n.isConstructed,
...e
},
lenBlock: {
...t,
isIndefiniteForm: !!n.isIndefiniteForm
},
...n
}, LocalOctetStringValueBlock);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 4;
}
fromBER(e, t, n, r) {
this.valueBlock.isConstructed = this.idBlock.isConstructed;
this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm;
if (n === 0) {
if (this.idBlock.error.length === 0) this.blockLength += this.idBlock.blockLength;
if (this.lenBlock.error.length === 0) this.blockLength += this.lenBlock.blockLength;
return t;
}
if (!this.valueBlock.isConstructed && (r === null || r === void 0 ? void 0 : r.parseEmbedded) !== false) {
const i = (e instanceof ArrayBuffer ? new Uint8Array(e) : e).subarray(t, t + n);
try {
if (i.byteLength) {
const e = r !== null && r !== void 0 ? r : createFromBerContext();
const t = localFromBERWithChildContext(i, 0, i.byteLength, e);
if (t.offset !== -1 && t.offset === n) this.valueBlock.value = [t.result];
}
} catch {}
}
return super.fromBER(e, t, n, r);
}
onAsciiEncoding() {
if (this.valueBlock.isConstructed || this.valueBlock.value && this.valueBlock.value.length) return Constructed.prototype.onAsciiEncoding.call(this);
return `${this.constructor.NAME} : ${r.Convert.ToHex(this.valueBlock.valueHexView)}`;
}
getValue() {
if (!this.idBlock.isConstructed) return this.valueBlock.valueHexView.slice().buffer;
const e = [];
for (const t of this.valueBlock.value) if (t instanceof R) e.push(t.valueBlock.valueHexView);
return r.BufferSourceConverter.concat(e);
}
};
R = OctetString;
(() => {
x.OctetString = R;
})();
OctetString.NAME = te;
var LocalBitStringValueBlock = class extends HexBlock(LocalConstructedValueBlock) {
constructor({ unusedBits: e = 0, isConstructed: t = false, ...n } = {}) {
super(n);
this.unusedBits = e;
this.isConstructed = t;
this.blockLength = this.valueHexView.byteLength;
}
fromBER(e, t, n, i) {
if (!n) return t;
let a = -1;
if (this.isConstructed) {
a = LocalConstructedValueBlock.prototype.fromBER.call(this, e, t, n, i);
if (a === -1) return a;
for (const e of this.value) {
const t = e.constructor.NAME;
if (t === y) {
if (this.isIndefiniteForm) break;
else {
this.error = "EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only";
return -1;
}
}
if (t !== b) {
this.error = "BIT STRING may consists of BIT STRINGs only";
return -1;
}
const n = e.valueBlock;
if (this.unusedBits > 0 && n.unusedBits > 0) {
this.error = "Using of \"unused bits\" inside constructive BIT STRING allowed for least one only";
return -1;
}
this.unusedBits = n.unusedBits;
}
return a;
}
const o = r.BufferSourceConverter.toUint8Array(e);
if (!checkBufferParams(this, o, t, n)) return -1;
const s = o.subarray(t, t + n);
this.unusedBits = s[0];
if (this.unusedBits > 7) {
this.error = "Unused bits for BitString must be in range 0-7";
return -1;
}
if (!this.unusedBits && (i === null || i === void 0 ? void 0 : i.parseEmbedded) !== false) {
const e = s.subarray(1);
try {
if (e.byteLength) {
const t = i !== null && i !== void 0 ? i : createFromBerContext();
const r = localFromBERWithChildContext(e, 0, e.byteLength, t);
if (r.offset !== -1 && r.offset === n - 1) this.value = [r.result];
}
} catch {}
}
this.valueHexView = s.subarray(1);
this.blockLength = s.length;
return t + n;
}
toBER(e, t) {
if (this.isConstructed) return LocalConstructedValueBlock.prototype.toBER.call(this, e, t);
if (e) return new ArrayBuffer(this.valueHexView.byteLength + 1);
if (!this.valueHexView.byteLength) {
const e = /* @__PURE__ */ new Uint8Array(1);
e[0] = 0;
return e.buffer;
}
const n = new Uint8Array(this.valueHexView.length + 1);
n[0] = this.unusedBits;
n.set(this.valueHexView, 1);
return n.buffer;
}
toJSON() {
return {
...super.toJSON(),
unusedBits: this.unusedBits,
isConstructed: this.isConstructed
};
}
};
LocalBitStringValueBlock.NAME = "BitStringValueBlock";
const _e = LocalBitStringValueBlock.prototype.toBER;
var ve;
var BitString = class extends BaseBlock {
constructor({ idBlock: e = {}, lenBlock: t = {}, ...n } = {}) {
var r, i;
(r = n.isConstructed) !== null && r !== void 0 || (n.isConstructed = !!((i = n.value) === null || i === void 0 ? void 0 : i.length));
super({
idBlock: {
isConstructed: n.isConstructed,
...e
},
lenBlock: {
...t,
isIndefiniteForm: !!n.isIndefiniteForm
},
...n
}, LocalBitStringValueBlock);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 3;
}
fromBER(e, t, n, r) {
this.valueBlock.isConstructed = this.idBlock.isConstructed;
this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm;
return super.fromBER(e, t, n, r);
}
onAsciiEncoding() {
if (this.valueBlock.isConstructed || this.valueBlock.value && this.valueBlock.value.length) return Constructed.prototype.onAsciiEncoding.call(this);
else {
const e = [];
const t = this.valueBlock.valueHexView;
for (const n of t) e.push(n.toString(2).padStart(8, "0"));
const n = e.join("");
return `${this.constructor.NAME} : ${n.substring(0, n.length - this.valueBlock.unusedBits)}`;
}
}
};
ve = BitString;
(() => {
x.BitString = ve;
})();
BitString.NAME = b;
function bytesToSignedBigInt(e) {
if (!e.byteLength) return BigInt(0);
const t = BigInt(`0x${r.Convert.ToHex(e)}`);
if (e[0] & 128) return t - (BigInt(1) << BigInt(e.byteLength * 8));
return t;
}
function bytesToSignedDecimal(e) {
if (typeof BigInt !== "undefined") return bytesToSignedBigInt(e).toString(10);
const t = 1e7;
const n = 7;
if (!e.byteLength) return "0";
const r = !!(e[0] & 128);
let i = e;
if (r) {
i = new Uint8Array(e.length);
let t = 1;
for (let n = e.length - 1; n >= 0; n--) {
const r = (e[n] ^ 255) + t;
i[n] = r & 255;
t = r >> 8;
}
}
const a = [0];
for (let e = 0; e < i.length; e++) {
let n = i[e];
for (let e = 0; e < a.length; e++) {
const r = a[e] * 256 + n;
a[e] = r % t;
n = Math.floor(r / t);
}
if (n) a.push(n);
}
let o = a.length - 1;
while (o > 0 && a[o] === 0) o--;
let s = String(a[o]);
for (let e = o - 1; e >= 0; e--) s += String(a[e]).padStart(n, "0");
return r && s !== "0" ? `-${s}` : s;
}
var z;
var LocalIntegerValueBlock = class extends HexBlock(ValueBlock) {
setValueHex() {
if (this.valueHexView.length >= 4) {
this.warnings.push("Too big Integer for decoding, hex only");
this.isHexOnly = true;
this._valueDec = 0;
} else {
this.isHexOnly = false;
if (this.valueHexView.length > 0) this._valueDec = i.utilDecodeTC.call(this);
}
}
constructor({ value: e, ...t } = {}) {
super(t);
this._valueDec = 0;
if (t.valueHex) this.setValueHex();
if (e !== void 0) this.valueDec = e;
}
set valueDec(e) {
this._valueDec = e;
this.isHexOnly = false;
this.valueHexView = new Uint8Array(i.utilEncodeTC(e));
}
get valueDec() {
return this._valueDec;
}
fromDER(e, t, n, r = 0) {
const i = this.fromBER(e, t, n);
if (i === -1) return i;
const a = this.valueHexView;
if (a[0] === 0 && (a[1] & 128) !== 0) this.valueHexView = a.subarray(1);
else if (r !== 0) {
if (a.length < r) {
if (r - a.length > 1) r = a.length + 1;
this.valueHexView = a.subarray(r - a.length);
}
}
return i;
}
toDER(e = false) {
const t = this.valueHexView;
switch (true) {
case (t[0] & 128) !== 0:
{
const e = new Uint8Array(this.valueHexView.length + 1);
e[0] = 0;
e.set(t, 1);
this.valueHexView = e;
}
break;
case t[0] === 0 && (t[1] & 128) === 0: this.valueHexView = this.valueHexView.subarray(1);
}
return this.toBER(e);
}
fromBER(e, t, n) {
const r = super.fromBER(e, t, n);
if (r === -1) return r;
this.setValueHex();
return r;
}
toBER(e) {
return e ? new ArrayBuffer(this.valueHexView.length) : this.valueHexView.slice().buffer;
}
toJSON() {
return {
...super.toJSON(),
valueDec: this.valueDec
};
}
toString() {
return bytesToSignedDecimal(this.valueHexView);
}
};
z = LocalIntegerValueBlock;
LocalIntegerValueBlock.NAME = "IntegerValueBlock";
(() => {
Object.defineProperty(z.prototype, "valueHex", {
set: function(e) {
this.valueHexView = new Uint8Array(e);
this.setValueHex();
},
get: function() {
return this.valueHexView.slice().buffer;
}
});
})();
const ye = LocalIntegerValueBlock.prototype.toBER;
const be = LocalIntegerValueBlock.prototype.toString;
var B;
var Integer = class extends BaseBlock {
constructor(e = {}) {
super(e, LocalIntegerValueBlock);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 2;
}
toBigInt() {
assertBigInt();
const e = this.valueBlock;
const t = e.toString;
if (t === be) return bytesToSignedBigInt(e.valueHexView);
return BigInt(Reflect.apply(t, e, []));
}
static fromBigInt(e) {
assertBigInt();
const t = BigInt(e);
const n = new ViewWriter();
const i = t.toString(16).replace(/^-/, "");
const a = new Uint8Array(r.Convert.FromHex(i));
if (t < 0) {
const e = new Uint8Array(a.length + (a[0] & 128 ? 1 : 0));
e[0] |= 128;
const i = BigInt(`0x${r.Convert.ToHex(e)}`) + t;
const o = r.BufferSourceConverter.toUint8Array(r.Convert.FromHex(i.toString(16)));
o[0] |= 128;
n.write(o);
} else {
if (a[0] & 128) n.write(new Uint8Array([0]));
n.write(a);
}
return new B({ valueHex: n.final() });
}
convertToDER() {
const e = new B({ valueHex: this.valueBlock.valueHexView });
e.valueBlock.toDER();
return e;
}
convertFromDER() {
return new B({ valueHex: this.valueBlock.valueHexView[0] === 0 ? this.valueBlock.valueHexView.subarray(1) : this.valueBlock.valueHexView });
}
onAsciiEncoding() {
return `${this.constructor.NAME} : ${this.valueBlock.toString()}`;
}
};
B = Integer;
(() => {
x.Integer = B;
})();
Integer.NAME = "INTEGER";
var V;
var Enumerated = class extends Integer {
constructor(e = {}) {
super(e);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 10;
}
};
V = Enumerated;
(() => {
x.Enumerated = V;
})();
Enumerated.NAME = "ENUMERATED";
var LocalSidValueBlock = class extends HexBlock(ValueBlock) {
constructor({ valueDec: e = -1, isFirstSid: t = false, ...n } = {}) {
super(n);
this.valueDec = e;
this.isFirstSid = t;
}
fromBER(e, t, n) {
if (!n) return t;
const a = r.BufferSourceConverter.toUint8Array(e);
if (!checkBufferParams(this, a, t, n)) return -1;
const o = a.subarray(t, t + n);
if (this.blockLength === 0 && Number.isInteger(t) && Number.isInteger(n)) {
let e = 0;
while (e < n) {
const t = o[e];
e++;
if ((t & 128) === 0) break;
}
this.blockLength = e;
this.valueHexView = new Uint8Array(e);
for (let t = 0; t < e; t++) this.valueHexView[t] = o[t] & 127;
} else {
this.valueHexView = new Uint8Array(n);
for (let e = 0; e < n; e++) {
this.valueHexView[e] = o[e] & 127;
this.blockLength++;
if ((o[e] & 128) === 0) break;
}
const e = new Uint8Array(this.blockLength);
for (let t = 0; t < this.blockLength; t++) e[t] = this.valueHexView[t];
this.valueHexView = e;
}
if ((o[this.blockLength - 1] & 128) !== 0) {
this.error = "End of input reached before message was fully decoded";
return -1;
}
if (this.valueHexView[0] === 0) this.warnings.push("Needlessly long format of SID encoding");
if (this.blockLength <= 8) this.valueDec = i.utilFromBase(this.valueHexView, 7);
else {
this.isHexOnly = true;
this.warnings.push("Too big SID for decoding, hex only");
}
return t + this.blockLength;
}
set valueBigInt(e) {
assertBigInt();
let t = BigInt(e).toString(2);
while (t.length % 7) t = "0" + t;
const n = new Uint8Array(t.length / 7);
for (let e = 0; e < n.length; e++) n[e] = parseInt(t.slice(e * 7, e * 7 + 7), 2) + (e + 1 < n.length ? 128 : 0);
this.fromBER(n.buffer, 0, n.length);
}
toBER(e) {
if (this.isHexOnly) {
if (e) return new ArrayBuffer(this.valueHexView.byteLength);
const t = this.valueHexView;
const n = new Uint8Array(this.blockLength);
for (let e = 0; e < this.blockLength - 1; e++) n[e] = t[e] | 128;
n[this.blockLength - 1] = t[this.blockLength - 1];
return r.BufferSourceConverter.toArrayBuffer(n);
}
const t = i.utilToBase(this.valueDec, 7);
if (t.byteLength === 0) {
this.error = "Error during encoding SID value";
return _;
}
const n = new Uint8Array(t.byteLength);
if (!e) {
const e = new Uint8Array(t);
const r = t.byteLength - 1;
for (let t = 0; t < r; t++) n[t] = e[t] | 128;
n[r] = e[r];
}
return r.BufferSourceConverter.toArrayBuffer(n);
}
toString() {
let e = "";
if (this.isHexOnly) e = r.Convert.ToHex(this.valueHexView);
else if (this.isFirstSid) {
let t = this.valueDec;
if (this.valueDec <= 39) e = "0.";
else if (this.valueDec <= 79) {
e = "1.";
t -= 40;
} else {
e = "2.";
t -= 80;
}
e += t.toString();
} else e = this.valueDec.toString();
return e;
}
toJSON() {
return {
...super.toJSON(),
valueDec: this.valueDec,
isFirstSid: this.isFirstSid
};
}
};
LocalSidValueBlock.NAME = "sidBlock";
var LocalObjectIdentifierValueBlock = class extends ValueBlock {
constructor({ value: e = g, ...t } = {}) {
super(t);
this.value = [];
if (e) this.fromString(e);
}
fromBER(e, t, n) {
let r = t;
while (n > 0) {
const t = new LocalSidValueBlock();
r = t.fromBER(e, r, n);
if (r === -1) {
this.blockLength = 0;
this.error = t.error;
return r;
}
if (this.value.length === 0) t.isFirstSid = true;
this.blockLength += t.blockLength;
n -= t.blockLength;
this.value.push(t);
}
return r;
}
toBER(e) {
const t = [];
for (let n = 0; n < this.value.length; n++) {
const r = this.value[n].toBER(e);
if (r.byteLength === 0) {
this.error = this.value[n].error;
return _;
}
t.push(r);
}
return concat(t);
}
fromString(e) {
this.value = [];
let t = 0;
let n = 0;
let r = "";
let i = false;
do {
n = e.indexOf(".", t);
if (n === -1) r = e.substring(t);
else r = e.substring(t, n);
t = n + 1;
if (i) {
const e = this.value[0];
let t = 0;
switch (e.valueDec) {
case 0: break;
case 1:
t = 40;
break;
case 2:
t = 80;
break;
default:
this.value = [];
return;
}
const n = parseInt(r, 10);
if (isNaN(n)) return;
e.valueDec = n + t;
i = false;
} else {
const e = new LocalSidValueBlock();
if (r > Number.MAX_SAFE_INTEGER) {
assertBigInt();
e.valueBigInt = BigInt(r);
} else {
e.valueDec = parseInt(r, 10);
if (isNaN(e.valueDec)) return;
}
if (!this.value.length) {
e.isFirstSid = true;
i = true;
}
this.value.push(e);
}
} while (n !== -1);
}
toString() {
let e = "";
let t = false;
for (let n = 0; n < this.value.length; n++) {
t = this.value[n].isHexOnly;
let r = this.value[n].toString();
if (n !== 0) e = `${e}.`;
if (t) {
r = `{${r}}`;
if (this.value[n].isFirstSid) e = `2.{${r} - 80}`;
else e += r;
} else e += r;
}
return e;
}
toJSON() {
const e = {
...super.toJSON(),
value: this.toString(),
sidArray: []
};
for (let t = 0; t < this.value.length; t++) e.sidArray.push(this.value[t].toJSON());
return e;
}
};
LocalObjectIdentifierValueBlock.NAME = "ObjectIdentifierValueBlock";
var H;
var ObjectIdentifier = class extends BaseBlock {
getValue() {
return this.valueBlock.toString();
}
setValue(e) {
this.valueBlock.fromString(e);
}
constructor(e = {}) {
super(e, LocalObjectIdentifierValueBlock);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 6;
}
onAsciiEncoding() {
return `${this.constructor.NAME} : ${this.valueBlock.toString() || "empty"}`;
}
toJSON() {
return {
...super.toJSON(),
value: this.getValue()
};
}
};
H = ObjectIdentifier;
(() => {
x.ObjectIdentifier = H;
})();
ObjectIdentifier.NAME = "OBJECT IDENTIFIER";
var LocalRelativeSidValueBlock = class extends HexBlock(LocalBaseBlock) {
constructor({ valueDec: e = 0, ...t } = {}) {
super(t);
this.valueDec = e;
}
fromBER(e, t, n) {
if (n === 0) return t;
const a = r.BufferSourceConverter.toUint8Array(e);
if (!checkBufferParams(this, a, t, n)) return -1;
const o = a.subarray(t, t + n);
if (this.blockLength === 0 && Number.isInteger(t) && Number.isInteger(n)) {
let e = 0;
while (e < n) {
const t = o[e];
e++;
if ((t & 128) === 0) break;
}
this.blockLength = e;
this.valueHexView = new Uint8Array(e);
for (let t = 0; t < e; t++) this.valueHexView[t] = o[t] & 127;
} else {
this.valueHexView = new Uint8Array(n);
for (let e = 0; e < n; e++) {
this.valueHexView[e] = o[e] & 127;
this.blockLength++;
if ((o[e] & 128) === 0) break;
}
const e = new Uint8Array(this.blockLength);
for (let t = 0; t < this.blockLength; t++) e[t] = this.valueHexView[t];
this.valueHexView = e;
}
if ((o[this.blockLength - 1] & 128) !== 0) {
this.error = "End of input reached before message was fully decoded";
return -1;
}
if (this.valueHexView[0] === 0) this.warnings.push("Needlessly long format of SID encoding");
if (this.blockLength <= 8) this.valueDec = i.utilFromBase(this.valueHexView, 7);
else {
this.isHexOnly = true;
this.warnings.push("Too big SID for decoding, hex only");
}
return t + this.blockLength;
}
toBER(e) {
if (this.isHexOnly) {
if (e) return new ArrayBuffer(this.valueHexView.byteLength);
const t = this.valueHexView;
const n = new Uint8Array(this.blockLength);
for (let e = 0; e < this.blockLength - 1; e++) n[e] = t[e] | 128;
n[this.blockLength - 1] = t[this.blockLength - 1];
return n.buffer;
}
const t = i.utilToBase(this.valueDec, 7);
if (t.byteLength === 0) {
this.error = "Error during encoding SID value";
return _;
}
const n = new Uint8Array(t.byteLength);
if (!e) {
const e = new Uint8Array(t);
const r = t.byteLength - 1;
for (let t = 0; t < r; t++) n[t] = e[t] | 128;
n[r] = e[r];
}
return n.buffer;
}
toString() {
let e = "";
if (this.isHexOnly) e = r.Convert.ToHex(this.valueHexView);
else e = this.valueDec.toString();
return e;
}
toJSON() {
return {
...super.toJSON(),
valueDec: this.valueDec
};
}
};
LocalRelativeSidValueBlock.NAME = "relativeSidBlock";
var LocalRelativeObjectIdentifierValueBlock = class extends ValueBlock {
constructor({ value: e = g, ...t } = {}) {
super(t);
this.value = [];
if (e) this.fromString(e);
}
fromBER(e, t, n) {
let r = t;
while (n > 0) {
const t = new LocalRelativeSidValueBlock();
r = t.fromBER(e, r, n);
if (r === -1) {
this.blockLength = 0;
this.error = t.error;
return r;
}
this.blockLength += t.blockLength;
n -= t.blockLength;
this.value.push(t);
}
return r;
}
toBER(e, t) {
const n = [];
for (let t = 0; t < this.value.length; t++) {
const r = this.value[t].toBER(e);
if (r.byteLength === 0) {
this.error = this.value[t].error;
return _;
}
n.push(r);
}
return concat(n);
}
fromString(e) {
this.value = [];
let t = 0;
let n = 0;
let r = "";
do {
n = e.indexOf(".", t);
if (n === -1) r = e.substring(t);
else r = e.substring(t, n);
t = n + 1;
const i = new LocalRelativeSidValueBlock();
i.valueDec = parseInt(r, 10);
if (isNaN(i.valueDec)) return true;
this.value.push(i);
} while (n !== -1);
return true;
}
toString() {
let e = "";
let t = false;
for (let n = 0; n < this.value.length; n++) {
t = this.value[n].isHexOnly;
let r = this.value[n].toString();
if (n !== 0) e = `${e}.`;
if (t) {
r = `{${r}}`;
e += r;
} else e += r;
}
return e;
}
toJSON() {
const e = {
...super.toJSON(),
value: this.toString(),
sidArray: []
};
for (let t = 0; t < this.value.length; t++) e.sidArray.push(this.value[t].toJSON());
return e;
}
};
LocalRelativeObjectIdentifierValueBlock.NAME = "RelativeObjectIdentifierValueBlock";
var U;
var RelativeObjectIdentifier = class extends BaseBlock {
getValue() {
return this.valueBlock.toString();
}
setValue(e) {
this.valueBlock.fromString(e);
}
constructor(e = {}) {
super(e, LocalRelativeObjectIdentifierValueBlock);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 13;
}
onAsciiEncoding() {
return `${this.constructor.NAME} : ${this.valueBlock.toString() || "empty"}`;
}
toJSON() {
return {
...super.toJSON(),
value: this.getValue()
};
}
};
U = RelativeObjectIdentifier;
(() => {
x.RelativeObjectIdentifier = U;
})();
RelativeObjectIdentifier.NAME = "RelativeObjectIdentifier";
var W;
var Sequence = class extends Constructed {
constructor(e = {}) {
super(e);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 16;
}
};
W = Sequence;
(() => {
x.Sequence = W;
})();
Sequence.NAME = "SEQUENCE";
var G;
var Set = class extends Constructed {
constructor(e = {}) {
super(e);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 17;
}
};
G = Set;
(() => {
x.Set = G;
})();
Set.NAME = "SET";
var LocalStringValueBlock = class extends HexBlock(ValueBlock) {
constructor({ ...e } = {}) {
super(e);
this.isHexOnly = true;
this.value = g;
}
toJSON() {
return {
...super.toJSON(),
value: this.value
};
}
};
LocalStringValueBlock.NAME = "StringValueBlock";
var LocalSimpleStringValueBlock = class extends LocalStringValueBlock {};
LocalSimpleStringValueBlock.NAME = "SimpleStringValueBlock";
var LocalSimpleStringBlock = class extends BaseStringBlock {
constructor({ ...e } = {}) {
super(e, LocalSimpleStringValueBlock);
}
fromBuffer(e) {
this.valueBlock.value = String.fromCharCode.apply(null, r.BufferSourceConverter.toUint8Array(e));
}
fromString(e) {
const t = e.length;
const n = this.valueBlock.valueHexView = new Uint8Array(t);
for (let r = 0; r < t; r++) n[r] = e.charCodeAt(r);
this.valueBlock.value = e;
}
};
LocalSimpleStringBlock.NAME = "SIMPLE STRING";
var LocalUtf8StringValueBlock = class extends LocalSimpleStringBlock {
fromBuffer(e) {
this.valueBlock.valueHexView = r.BufferSourceConverter.toUint8Array(e);
try {
this.valueBlock.value = r.Convert.ToUtf8String(e);
} catch (t) {
this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`);
this.valueBlock.value = r.Convert.ToBinary(e);
}
}
fromString(e) {
this.valueBlock.valueHexView = new Uint8Array(r.Convert.FromUtf8String(e));
this.valueBlock.value = e;
}
};
LocalUtf8StringValueBlock.NAME = "Utf8StringValueBlock";
var K;
var Utf8String = class extends LocalUtf8StringValueBlock {
constructor(e = {}) {
super(e);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 12;
}
};
K = Utf8String;
(() => {
x.Utf8String = K;
})();
Utf8String.NAME = "UTF8String";
var LocalBmpStringValueBlock = class extends LocalSimpleStringBlock {
fromBuffer(e) {
this.valueBlock.value = r.Convert.ToUtf16String(e);
this.valueBlock.valueHexView = r.BufferSourceConverter.toUint8Array(e);
}
fromString(e) {
this.valueBlock.value = e;
this.valueBlock.valueHexView = new Uint8Array(r.Convert.FromUtf16String(e));
}
};
LocalBmpStringValueBlock.NAME = "BmpStringValueBlock";
var q;
var BmpString = class extends LocalBmpStringValueBlock {
constructor({ ...e } = {}) {
super(e);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 30;
}
};
q = BmpString;
(() => {
x.BmpString = q;
})();
BmpString.NAME = "BMPString";
var LocalUniversalStringValueBlock = class extends LocalSimpleStringBlock {
fromBuffer(e) {
const t = ArrayBuffer.isView(e) ? e.slice().buffer : e.slice(0);
const n = new Uint8Array(t);
for (let e = 0; e < n.length; e += 4) {
n[e] = n[e + 3];
n[e + 1] = n[e + 2];
n[e + 2] = 0;
n[e + 3] = 0;
}
this.valueBlock.value = String.fromCharCode.apply(null, new Uint32Array(t));
}
fromString(e) {
const t = e.length;
const n = this.valueBlock.valueHexView = new Uint8Array(t * 4);
for (let r = 0; r < t; r++) {
const t = i.utilToBase(e.charCodeAt(r), 8);
const a = new Uint8Array(t);
if (a.length > 4) continue;
const o = 4 - a.length;
for (let e = a.length - 1; e >= 0; e--) n[r * 4 + e + o] = a[e];
}
this.valueBlock.value = e;
}
};
LocalUniversalStringValueBlock.NAME = "UniversalStringValueBlock";
var J;
var UniversalString = class extends LocalUniversalStringValueBlock {
constructor({ ...e } = {}) {
super(e);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 28;
}
};
J = UniversalString;
(() => {
x.UniversalString = J;
})();
UniversalString.NAME = "UniversalString";
var Y;
var NumericString = class extends LocalSimpleStringBlock {
constructor(e = {}) {
super(e);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 18;
}
};
Y = NumericString;
(() => {
x.NumericString = Y;
})();
NumericString.NAME = "NumericString";
var X;
var PrintableString = class extends LocalSimpleStringBlock {
constructor(e = {}) {
super(e);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 19;
}
};
X = PrintableString;
(() => {
x.PrintableString = X;
})();
PrintableString.NAME = "PrintableString";
var Z;
var TeletexString = class extends LocalSimpleStringBlock {
constructor(e = {}) {
super(e);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 20;
}
};
Z = TeletexString;
(() => {
x.TeletexString = Z;
})();
TeletexString.NAME = "TeletexString";
var xe;
var VideotexString = class extends LocalSimpleStringBlock {
constructor(e = {}) {
super(e);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 21;
}
};
xe = VideotexString;
(() => {
x.VideotexString = xe;
})();
VideotexString.NAME = "VideotexString";
var Q;
var IA5String = class extends LocalSimpleStringBlock {
constructor(e = {}) {
super(e);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 22;
}
};
Q = IA5String;
(() => {
x.IA5String = Q;
})();
IA5String.NAME = "IA5String";
var Se;
var GraphicString = class extends LocalSimpleStringBlock {
constructor(e = {}) {
super(e);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 25;
}
};
Se = GraphicString;
(() => {
x.GraphicString = Se;
})();
GraphicString.NAME = "GraphicString";
var Ce;
var VisibleString = class extends LocalSimpleStringBlock {
constructor(e = {}) {
super(e);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 26;
}
};
Ce = VisibleString;
(() => {
x.VisibleString = Ce;
})();
VisibleString.NAME = "VisibleString";
var we;
var GeneralString = class extends LocalSimpleStringBlock {
constructor(e = {}) {
super(e);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 27;
}
};
we = GeneralString;
(() => {
x.GeneralString = we;
})();
GeneralString.NAME = "GeneralString";
var Te;
var CharacterString = class extends LocalSimpleStringBlock {
constructor(e = {}) {
super(e);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 29;
}
};
Te = CharacterString;
(() => {
x.CharacterString = Te;
})();
CharacterString.NAME = "CharacterString";
var Ee;
var UTCTime = class extends VisibleString {
constructor({ value: e, valueDate: t, ...n } = {}) {
super(n);
this.year = 0;
this.month = 0;
this.day = 0;
this.hour = 0;
this.minute = 0;
this.second = 0;
if (e) {
this.fromString(e);
this.valueBlock.valueHexView = new Uint8Array(e.length);
for (let t = 0; t < e.length; t++) this.valueBlock.valueHexView[t] = e.charCodeAt(t);
}
if (t) {
this.fromDate(t);
this.valueBlock.valueHexView = new Uint8Array(this.toBuffer());
}
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 23;
}
fromBuffer(e) {
this.fromString(String.fromCharCode.apply(null, r.BufferSourceConverter.toUint8Array(e)));
}
toBuffer() {
const e = this.toString();
const t = new ArrayBuffer(e.length);
const n = new Uint8Array(t);
for (let t = 0; t < e.length; t++) n[t] = e.charCodeAt(t);
return t;
}
fromDate(e) {
this.year = e.getUTCFullYear();
this.month = e.getUTCMonth() + 1;
this.day = e.getUTCDate();
this.hour = e.getUTCHours();
this.minute = e.getUTCMinutes();
this.second = e.getUTCSeconds();
}
toDate() {
return new Date(Date.UTC(this.year, this.month - 1, this.day, this.hour, this.minute, this.second));
}
fromString(e) {
const t = /(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/gi.exec(e);
if (t === null) {
this.error = "Wrong input string for conversion";
return;
}
const n = parseInt(t[1], 10);
if (n >= 50) this.year = 1900 + n;
else this.year = 2e3 + n;
this.month = parseInt(t[2], 10);
this.day = parseInt(t[3], 10);
this.hour = parseInt(t[4], 10);
this.minute = parseInt(t[5], 10);
this.second = parseInt(t[6], 10);
}
toString(e = "iso") {
if (e === "iso") {
const e = Array.from({ length: 7 });
e[0] = i.padNumber(this.year < 2e3 ? this.year - 1900 : this.year - 2e3, 2);
e[1] = i.padNumber(this.month, 2);
e[2] = i.padNumber(this.day, 2);
e[3] = i.padNumber(this.hour, 2);
e[4] = i.padNumber(this.minute, 2);
e[5] = i.padNumber(this.second, 2);
e[6] = "Z";
return e.join("");
}
return super.toString(e);
}
onAsciiEncoding() {
return `${this.constructor.NAME} : ${this.toDate().toISOString()}`;
}
toJSON() {
return {
...super.toJSON(),
year: this.year,
month: this.month,
day: this.day,
hour: this.hour,
minute: this.minute,
second: this.second
};
}
};
Ee = UTCTime;
(() => {
x.UTCTime = Ee;
})();
UTCTime.NAME = "UTCTime";
var De;
var GeneralizedTime = class extends UTCTime {
constructor(e = {}) {
var t;
super(e);
(t = this.millisecond) !== null && t !== void 0 || (this.millisecond = 0);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 24;
}
fromDate(e) {
super.fromDate(e);
this.millisecond = e.getUTCMilliseconds();
}
toDate() {
const e = Date.UTC(this.year, this.month - 1, this.day, this.hour, this.minute, this.second, this.millisecond);
return new Date(e);
}
fromString(e) {
let t = false;
let n = "";
let r = "";
let i = 0;
let a;
let o = 0;
let s = 0;
if (e[e.length - 1] === "Z") {
n = e.substring(0, e.length - 1);
t = true;
} else {
const t = new Number(e[e.length - 1]);
if (isNaN(t.valueOf())) throw new Error("Wrong input string for conversion");
n = e;
}
if (t) {
if (n.indexOf("+") !== -1) throw new Error("Wrong input string for conversion");
if (n.indexOf("-") !== -1) throw new Error("Wrong input string for conversion");
} else {
let e = 1;
let t = n.indexOf("+");
let r = "";
if (t === -1) {
t = n.indexOf("-");
e = -1;
}
if (t !== -1) {
r = n.substring(t + 1);
n = n.substring(0, t);
if (r.length !== 2 && r.length !== 4) throw new Error("Wrong input string for conversion");
let i = parseInt(r.substring(0, 2), 10);
if (isNaN(i.valueOf())) throw new Error("Wrong input string for conversion");
o = e * i;
if (r.length === 4) {
i = parseInt(r.substring(2, 4), 10);
if (isNaN(i.valueOf())) throw new Error("Wrong input string for conversion");
s = e * i;
}
}
}
let c = n.indexOf(".");
if (c === -1) c = n.indexOf(",");
if (c !== -1) {
const e = /* @__PURE__ */ new Number(`0${n.substring(c)}`);
if (isNaN(e.valueOf())) throw new Error("Wrong input string for conversion");
i = e.valueOf();
r = n.substring(0, c);
} else r = n;
switch (true) {
case r.length === 8:
a = /(\d{4})(\d{2})(\d{2})/gi;
if (c !== -1) throw new Error("Wrong input string for conversion");
break;
case r.length === 10:
a = /(\d{4})(\d{2})(\d{2})(\d{2})/gi;
if (c !== -1) {
let e = 60 * i;
this.minute = Math.floor(e);
e = 60 * (e - this.minute);
this.second = Math.floor(e);
e = 1e3 * (e - this.second);
this.millisecond = Math.floor(e);
}
break;
case r.length === 12:
a = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/gi;
if (c !== -1) {
let e = 60 * i;
this.second = Math.floor(e);
e = 1e3 * (e - this.second);
this.millisecond = Math.floor(e);
}
break;
case r.length === 14:
a = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/gi;
if (c !== -1) {
const e = 1e3 * i;
this.millisecond = Math.floor(e);
}
break;
default: throw new Error("Wrong input string for conversion");
}
const l = a.exec(r);
if (l === null) throw new Error("Wrong input string for conversion");
for (let e = 1; e < l.length; e++) switch (e) {
case 1:
this.year = parseInt(l[e], 10);
break;
case 2:
this.month = parseInt(l[e], 10);
break;
case 3:
this.day = parseInt(l[e], 10);
break;
case 4:
this.hour = parseInt(l[e], 10) + o;
break;
case 5:
this.minute = parseInt(l[e], 10) + s;
break;
case 6:
this.second = parseInt(l[e], 10);
break;
default: throw new Error("Wrong input string for conversion");
}
if (t === false) {
const e = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond);
this.year = e.getUTCFullYear();
this.month = e.getUTCMonth();
this.day = e.getUTCDay();
this.hour = e.getUTCHours();
this.minute = e.getUTCMinutes();
this.second = e.getUTCSeconds();
this.millisecond = e.getUTCMilliseconds();
}
}
toString(e = "iso") {
if (e === "iso") {
const e = [];
e.push(i.padNumber(this.year, 4));
e.push(i.padNumber(this.month, 2));
e.push(i.padNumber(this.day, 2));
e.push(i.padNumber(this.hour, 2));
e.push(i.padNumber(this.minute, 2));
e.push(i.padNumber(this.second, 2));
if (this.millisecond !== 0) {
e.push(".");
e.push(i.padNumber(this.millisecond, 3).replace(/0+$/, ""));
}
e.push("Z");
return e.join("");
}
return super.toString(e);
}
toJSON() {
return {
...super.toJSON(),
millisecond: this.millisecond
};
}
};
De = GeneralizedTime;
(() => {
x.GeneralizedTime = De;
})();
GeneralizedTime.NAME = "GeneralizedTime";
var Oe;
var DATE = class extends Utf8String {
constructor(e = {}) {
super(e);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 31;
}
};
Oe = DATE;
(() => {
x.DATE = Oe;
})();
DATE.NAME = "DATE";
var ke;
var TimeOfDay = class extends Utf8String {
constructor(e = {}) {
super(e);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 32;
}
};
ke = TimeOfDay;
(() => {
x.TimeOfDay = ke;
})();
TimeOfDay.NAME = "TimeOfDay";
var Ae;
var DateTime = class extends Utf8String {
constructor(e = {}) {
super(e);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 33;
}
};
Ae = DateTime;
(() => {
x.DateTime = Ae;
})();
DateTime.NAME = "DateTime";
var je;
var Duration = class extends Utf8String {
constructor(e = {}) {
super(e);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 34;
}
};
je = Duration;
(() => {
x.Duration = je;
})();
Duration.NAME = "Duration";
var $;
var TIME = class extends Utf8String {
constructor(e = {}) {
super(e);
this.idBlock.tagClass = 1;
this.idBlock.tagNumber = 14;
}
};
$ = TIME;
(() => {
x.TIME = $;
})();
TIME.NAME = "TIME";
var Any = class {
constructor({ name: e = g, optional: t = false } = {}) {
this.name = e;
this.optional = t;
}
};
var Choice = class extends Any {
constructor({ value: e = [], ...t } = {}) {
super(t);
this.value = e;
}
};
var Repeated = class extends Any {
constructor({ value: e = new Any(), local: t = false, ...n } = {}) {
super(n);
this.value = e;
this.local = t;
}
};
var RawData = class {
get data() {
return this.dataView.slice().buffer;
}
set data(e) {
this.dataView = r.BufferSourceConverter.toUint8Array(e);
}
constructor({ data: e = v } = {}) {
this.dataView = r.BufferSourceConverter.toUint8Array(e);
}
fromBER(e, t, n) {
const i = t + n;
this.dataView = r.BufferSourceConverter.toUint8Array(e).subarray(t, i);
return i;
}
toBER(e) {
return this.dataView.slice().buffer;
}
};
function compareSchema(e, t, n) {
if (n instanceof Choice) {
for (const r of n.value) if (compareSchema(e, t, r).verified) return {
verified: true,
result: e
};
{
const e = {
verified: false,
result: { error: "Wrong values for Choice type" }
};
if (n.hasOwnProperty(s)) e.name = n.name;
return e;
}
}
if (n instanceof Any) {
if (n.hasOwnProperty(s)) e[n.name] = t;
return {
verified: true,
result: e
};
}
if (e instanceof Object === false) return {
verified: false,
result: { error: "Wrong root object" }
};
if (t instanceof Object === false) return {
verified: false,
result: { error: "Wrong ASN.1 data" }
};
if (n instanceof Object === false) return {
verified: false,
result: { error: "Wrong ASN.1 schema" }
};
if (u in n === false) return {
verified: false,
result: { error: "Wrong ASN.1 schema" }
};
if (m in n.idBlock === false) return {
verified: false,
result: { error: "Wrong ASN.1 schema" }
};
if (h in n.idBlock === false) return {
verified: false,
result: { error: "Wrong ASN.1 schema" }
};
const r = n.idBlock.toBER(false);
if (r.byteLength === 0) return {
verified: false,
result: { error: "Error encoding idBlock for ASN.1 schema" }
};
if (n.idBlock.fromBER(r, 0, r.byteLength) === -1) return {
verified: false,
result: { error: "Error decoding idBlock for ASN.1 schema" }
};
if (n.idBlock.hasOwnProperty(d) === false) return {
verified: false,
result: { error: "Wrong ASN.1 schema" }
};
if (n.idBlock.tagClass !== t.idBlock.tagClass) return {
verified: false,
result: e
};
if (n.idBlock.hasOwnProperty(f) === false) return {
verified: false,
result: { error: "Wrong ASN.1 schema" }
};
if (n.idBlock.tagNumber !== t.idBlock.tagNumber) return {
verified: false,
result: e
};
if (n.idBlock.hasOwnProperty(p) === false) return {
verified: false,
result: { error: "Wrong ASN.1 schema" }
};
if (n.idBlock.isConstructed !== t.idBlock.isConstructed) return {
verified: false,
result: e
};
if (!(l in n.idBlock)) return {
verified: false,
result: { error: "Wrong ASN.1 schema" }
};
if (n.idBlock.isHexOnly !== t.idBlock.isHexOnly) return {
verified: false,
result: e
};
if (n.idBlock.isHexOnly) {
if (c in n.idBlock === false) return {
verified: false,
result: { error: "Wrong ASN.1 schema" }
};
const r = n.idBlock.valueHexView;
const i = t.idBlock.valueHexView;
if (r.length !== i.length) return {
verified: false,
result: e
};
for (let t = 0; t < r.length; t++) if (r[t] !== i[1]) return {
verified: false,
result: e
};
}
if (n.name) {
n.name = n.name.replace(/^\s+|\s+$/g, g);
if (n.name) e[n.name] = t;
}
if (n instanceof x.Constructed) {
let r = 0;
let i = {
verified: false,
result: { error: "Unknown error" }
};
let a = n.valueBlock.value.length;
if (a > 0) {
if (n.valueBlock.value[0] instanceof Repeated) a = t.valueBlock.value.length;
}
if (a === 0) return {
verified: true,
result: e
};
if (t.valueBlock.value.length === 0 && n.valueBlock.value.length !== 0) {
let t = true;
for (let e = 0; e < n.valueBlock.value.length; e++) t = t && (n.valueBlock.value[e].optional || false);
if (t) return {
verified: true,
result: e
};
if (n.name) {
n.name = n.name.replace(/^\s+|\s+$/g, g);
if (n.name) delete e[n.name];
}
e.error = "Inconsistent object length";
return {
verified: false,
result: e
};
}
for (let o = 0; o < a; o++) if (o - r >= t.valueBlock.value.length) {
if (n.valueBlock.value[o].optional === false) {
const t = {
verified: false,
result: e
};
e.error = "Inconsistent length between ASN.1 data and schema";
if (n.name) {
n.name = n.name.replace(/^\s+|\s+$/g, g);
if (n.name) {
delete e[n.name];
t.name = n.name;
}
}
return t;
}
} else if (n.valueBlock.value[0] instanceof Repeated) {
i = compareSchema(e, t.valueBlock.value[o], n.valueBlock.value[0].value);
if (i.verified === false) {
if (n.valueBlock.value[0].optional) r++;
else {
if (n.name) {
n.name = n.name.replace(/^\s+|\s+$/g, g);
if (n.name) delete e[n.name];
}
return i;
}
}
if (s in n.valueBlock.value[0] && n.valueBlock.value[0].name.length > 0) {
let r = {};
if (ee in n.valueBlock.value[0] && n.valueBlock.value[0].local) r = t;
else r = e;
if (typeof r[n.valueBlock.value[0].name] === "undefined") r[n.valueBlock.value[0].name] = [];
r[n.valueBlock.value[0].name].push(t.valueBlock.value[o]);
}
} else {
i = compareSchema(e, t.valueBlock.value[o - r], n.valueBlock.value[o]);
if (i.verified === false) {
if (n.valueBlock.value[o].optional) r++;
else {
if (n.name) {
n.name = n.name.replace(/^\s+|\s+$/g, g);
if (n.name) delete e[n.name];
}
return i;
}
}
}
if (i.verified === false) {
const t = {
verified: false,
result: e
};
if (n.name) {
n.name = n.name.replace(/^\s+|\s+$/g, g);
if (n.name) {
delete e[n.name];
t.name = n.name;
}
}
return t;
}
return {
verified: true,
result: e
};
}
if (n.primitiveSchema && c in t.valueBlock) {
const r = localFromBER(t.valueBlock.valueHexView);
if (r.offset === -1) {
const t = {
verified: false,
result: r.result
};
if (n.name) {
n.name = n.name.replace(/^\s+|\s+$/g, g);
if (n.name) {
delete e[n.name];
t.name = n.name;
}
}
return t;
}
return compareSchema(e, r.result, n.primitiveSchema);
}
return {
verified: true,
result: e
};
}
function verifySchema(e, t) {
if (t instanceof Object === false) return {
verified: false,
result: { error: "Wrong ASN.1 schema type" }
};
const n = localFromBER(r.BufferSourceConverter.toUint8Array(e));
if (n.offset === -1) return {
verified: false,
result: n.result
};
return compareSchema(n.result, n.result, t);
}
registerBuiltinEncoder({
BitString,
Integer,
OctetString,
Primitive,
Constructed,
Sequence,
Set
}, {
BaseBlock,
ViewWriter,
LocalIdentificationBlock,
LocalLengthBlock,
LocalIntegerValueBlock,
LocalOctetStringValueBlock,
LocalConstructedValueBlock,
LocalBitStringValueBlock,
LocalPrimitiveValueBlock,
originalBaseBlockToBER: ue,
originalWriterWrite: a,
originalWriterFinal: o,
originalIdentificationToBER: ne,
originalLengthToBER: ie,
originalIntegerToBER: ye,
originalOctetStringToBER: ge,
originalBitStringToBER: _e,
originalConstructedToBER: he,
originalPrimitiveToBER: de
});
registerFastParser({
Integer,
Null,
Sequence
});
e.Any = Any;
e.BaseBlock = BaseBlock;
e.BaseStringBlock = BaseStringBlock;
e.BitString = BitString;
e.BmpString = BmpString;
e.Boolean = Boolean;
e.CharacterString = CharacterString;
e.Choice = Choice;
e.Constructed = Constructed;
e.DATE = DATE;
e.DEFAULT_MAX_CONTENT_LENGTH = N;
e.DEFAULT_MAX_DEPTH = j;
e.DEFAULT_MAX_NODES = M;
e.DateTime = DateTime;
e.Duration = Duration;
e.EndOfContent = EndOfContent;
e.Enumerated = Enumerated;
e.GeneralString = GeneralString;
e.GeneralizedTime = GeneralizedTime;
e.GraphicString = GraphicString;
e.HexBlock = HexBlock;
e.IA5String = IA5String;
e.Integer = Integer;
e.Null = Null;
e.NumericString = NumericString;
e.ObjectIdentifier = ObjectIdentifier;
e.OctetString = OctetString;
e.Primitive = Primitive;
e.PrintableString = PrintableString;
e.RawData = RawData;
e.RelativeObjectIdentifier = RelativeObjectIdentifier;
e.Repeated = Repeated;
e.Sequence = Sequence;
e.Set = Set;
e.TIME = TIME;
e.TeletexString = TeletexString;
e.TimeOfDay = TimeOfDay;
e.UTCTime = UTCTime;
e.UniversalString = UniversalString;
e.Utf8String = Utf8String;
e.ValueBlock = ValueBlock;
e.VideotexString = VideotexString;
e.ViewWriter = ViewWriter;
e.VisibleString = VisibleString;
e.compareSchema = compareSchema;
e.fromBER = fromBER;
e.verifySchema = verifySchema;
}));
//#endregion
//#region node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/cjs/bytes/buffer-source.js
var require_buffer_source = /* @__PURE__ */ __commonJSMin(((e) => {
Object.defineProperty(e, "__esModule", { value: true });
e.isArrayBuffer = isArrayBuffer;
e.isSharedArrayBuffer = isSharedArrayBuffer;
e.isArrayBufferLike = isArrayBufferLike;
e.isArrayBufferView = isArrayBufferView;
e.isBufferSource = isBufferSource;
e.assertBufferSource = assertBufferSource;
e.toUint8Array = toUint8Array;
e.toUint8ArrayCopy = toUint8ArrayCopy;
e.toArrayBuffer = toArrayBuffer;
e.toArrayBufferLike = toArrayBufferLike;
e.toView = toView;
e.toViewCopy = toViewCopy;
const t = "[object ArrayBuffer]";
const n = "[object SharedArrayBuffer]";
function tagOf(e) {
return Object.prototype.toString.call(e);
}
function isDataViewConstructor(e) {
return e === DataView || e.prototype instanceof DataView;
}
function bytesPerElement(e) {
if (isDataViewConstructor(e)) return 1;
return e.BYTES_PER_ELEMENT ?? 1;
}
function isArrayBufferViewLike(e) {
if (ArrayBuffer.isView(e)) return true;
if (!e || typeof e !== "object") return false;
const t = e;
return typeof t.byteOffset === "number" && typeof t.byteLength === "number" && isArrayBufferLike(t.buffer);
}
function copyBytes(e) {
const t = toUint8Array(e);
const n = new Uint8Array(t.byteLength);
n.set(t);
return n;
}
function isArrayBuffer(e) {
return tagOf(e) === t;
}
function isSharedArrayBuffer(e) {
return typeof SharedArrayBuffer !== "undefined" && tagOf(e) === n;
}
function isArrayBufferLike(e) {
return isArrayBuffer(e) || isSharedArrayBuffer(e);
}
function isArrayBufferView(e) {
return isArrayBufferViewLike(e);
}
function isBufferSource(e) {
return isArrayBufferLike(e) || isArrayBufferView(e);
}
function assertBufferSource(e) {
if (!isBufferSource(e)) throw new TypeError("Expected ArrayBuffer, SharedArrayBuffer, or ArrayBufferView");
}
function toUint8Array(e) {
assertBufferSource(e);
if (isArrayBufferLike(e)) return new Uint8Array(e);
return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
}
function toUint8ArrayCopy(e) {
return copyBytes(e);
}
function toArrayBuffer(e) {
assertBufferSource(e);
if (isArrayBuffer(e)) return e;
const t = new ArrayBuffer(e.byteLength);
new Uint8Array(t).set(toUint8Array(e));
return t;
}
function toArrayBufferLike(e) {
assertBufferSource(e);
if (isArrayBufferLike(e)) return e;
if (e.byteOffset === 0 && e.byteLength === e.buffer.byteLength) return e.buffer;
return copyBytes(e).buffer;
}
function toView(e, t) {
assertBufferSource(e);
if (ArrayBuffer.isView(e) && e.constructor === t) return e;
const n = toUint8Array(e);
const r = bytesPerElement(t);
if (n.byteOffset % r !== 0 || n.byteLength % r !== 0) throw new RangeError(`Cannot create ${t.name} over unaligned byte range`);
if (isDataViewConstructor(t)) return new t(n.buffer, n.byteOffset, n.byteLength);
return new t(n.buffer, n.byteOffset, n.byteLength / r);
}
function toViewCopy(e, t) {
return toView(toUint8ArrayCopy(e), t);
}
}));
//#endregion
//#region node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/cjs/bytes/concat.js
var require_concat = /* @__PURE__ */ __commonJSMin(((e) => {
Object.defineProperty(e, "__esModule", { value: true });
e.concatToUint8Array = concatToUint8Array;
e.concat = concat;
const t = require_buffer_source();
function concatToUint8Array(e) {
const n = [];
let r = 0;
for (const i of e) {
const e = (0, t.toUint8Array)(i);
n.push(e);
r += e.byteLength;
}
const i = new Uint8Array(r);
let a = 0;
for (const e of n) {
i.set(e, a);
a += e.byteLength;
}
return i;
}
function concat(e, n, ...r) {
let i;
let a;
if (typeof n === "function") {
i = Array.from(e);
a = n;
} else if ((0, t.isBufferSource)(e)) i = [
e,
n,
...r
].filter(t.isBufferSource);
else {
i = Array.from(e);
if (n) i.push(n);
i.push(...r);
}
const o = concatToUint8Array(i);
return a ? (0, t.toView)(o, a) : o.buffer;
}
}));
//#endregion
//#region node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/cjs/bytes/equal.js
var require_equal = /* @__PURE__ */ __commonJSMin(((e) => {
Object.defineProperty(e, "__esModule", { value: true });
e.equal = equal;
const t = require_buffer_source();
function equal(e, n, r = {}) {
const i = (0, t.toUint8Array)(e);
const a = (0, t.toUint8Array)(n);
if (!r.constantTime && i.byteLength !== a.byteLength) return false;
const o = Math.max(i.byteLength, a.byteLength);
let s = i.byteLength ^ a.byteLength;
for (let e = 0; e < o; e++) s |= (i[e] ?? 0) ^ (a[e] ?? 0);
return s === 0;
}
}));
//#endregion
//#region node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/cjs/bytes/sequence.js
var require_sequence = /* @__PURE__ */ __commonJSMin(((e) => {
Object.defineProperty(e, "__esModule", { value: true });
e.indexOf = indexOf;
e.lastIndexOf = lastIndexOf;
e.includes = includes;
e.startsWith = startsWith;
e.endsWith = endsWith;
e.slice = slice;
e.tail = tail;
e.copy = copy;
e.compare = compare;
const t = require_buffer_source();
function clampIndex(e, t, n) {
const r = Number.isFinite(e) ? Math.trunc(e) : t;
if (r <= 0) return 0;
if (r >= n) return n;
return r;
}
function normalizeForwardRange(e, t) {
const n = clampIndex(t?.start, 0, e);
const r = clampIndex(t?.end, e, e);
return r >= n ? [n, r] : [n, n];
}
function normalizeReverseRange(e, t) {
const n = clampIndex(t?.start, e, e);
const r = clampIndex(t?.end, 0, e);
return n >= r ? [r, n] : [n, n];
}
function normalizeSliceIndex(e, t, n) {
const r = Number.isFinite(e) ? Math.trunc(e) : t;
if (r < 0) return Math.max(n + r, 0);
if (r > n) return n;
return r;
}
function encodeAscii(e) {
const t = new Uint8Array(e.length);
for (let n = 0; n < e.length; n++) t[n] = e.charCodeAt(n) & 255;
return t;
}
function encodeUtf8(e) {
return new TextEncoder().encode(e);
}
function toPatternBytes(e, n) {
if (typeof e === "string") return n?.encoding === "utf8" ? encodeUtf8(e) : encodeAscii(e);
return (0, t.toUint8Array)(e);
}
function bytesEqualAt(e, t, n) {
for (let r = 0; r < t.byteLength; r++) if (e[n + r] !== t[r]) return false;
return true;
}
function indexOf(e, n, r) {
const i = (0, t.toUint8Array)(e);
const a = toPatternBytes(n, r);
const [o, s] = normalizeForwardRange(i.byteLength, r);
if (a.byteLength === 0) return o;
const c = s - a.byteLength;
if (c < o) return -1;
for (let e = o; e <= c; e++) if (bytesEqualAt(i, a, e)) return e;
return -1;
}
function lastIndexOf(e, n, r) {
const i = (0, t.toUint8Array)(e);
const a = toPatternBytes(n, r);
const [o, s] = normalizeReverseRange(i.byteLength, r);
if (a.byteLength === 0) return s;
const c = s - a.byteLength;
if (c < o) return -1;
for (let e = c; e >= o; e--) if (bytesEqualAt(i, a, e)) return e;
return -1;
}
function includes(e, t, n) {
return indexOf(e, t, n) !== -1;
}
function startsWith(e, n, r) {
const i = (0, t.toUint8Array)(e);
const a = toPatternBytes(n, r);
if (a.byteLength > i.byteLength) return false;
return bytesEqualAt(i, a, 0);
}
function endsWith(e, n, r) {
const i = (0, t.toUint8Array)(e);
const a = toPatternBytes(n, r);
if (a.byteLength > i.byteLength) return false;
return bytesEqualAt(i, a, i.byteLength - a.byteLength);
}
function slice(e, n, r) {
const i = (0, t.toUint8Array)(e);
const a = normalizeSliceIndex(n, 0, i.byteLength);
const o = normalizeSliceIndex(r, i.byteLength, i.byteLength);
if (o <= a) return i.subarray(a, a);
return i.subarray(a, o);
}
function tail(e, n) {
const r = (0, t.toUint8Array)(e);
const i = Number.isFinite(n) ? Math.max(0, Math.trunc(n)) : 0;
if (i >= r.byteLength) return r;
return r.subarray(r.byteLength - i);
}
function copy(e) {
return (0, t.toUint8ArrayCopy)(e);
}
function compare(e, n) {
const r = (0, t.toUint8Array)(e);
const i = (0, t.toUint8Array)(n);
const a = Math.min(r.byteLength, i.byteLength);
for (let e = 0; e < a; e++) {
if (r[e] < i[e]) return -1;
if (r[e] > i[e]) return 1;
}
if (r.byteLength < i.byteLength) return -1;
if (r.byteLength > i.byteLength) return 1;
return 0;
}
}));
//#endregion
//#region node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/cjs/bytes/index.js
var require_bytes = /* @__PURE__ */ __commonJSMin(((e) => {
Object.defineProperty(e, "__esModule", { value: true });
e.tail = e.startsWith = e.slice = e.lastIndexOf = e.indexOf = e.includes = e.endsWith = e.copy = e.compare = e.equal = e.concatToUint8Array = e.concat = e.toViewCopy = e.toView = e.toUint8ArrayCopy = e.toUint8Array = e.toArrayBufferLike = e.toArrayBuffer = e.isSharedArrayBuffer = e.isBufferSource = e.isArrayBufferView = e.isArrayBufferLike = e.isArrayBuffer = e.assertBufferSource = void 0;
var t = require_buffer_source();
Object.defineProperty(e, "assertBufferSource", {
enumerable: true,
get: function() {
return t.assertBufferSource;
}
});
Object.defineProperty(e, "isArrayBuffer", {
enumerable: true,
get: function() {
return t.isArrayBuffer;
}
});
Object.defineProperty(e, "isArrayBufferLike", {
enumerable: true,
get: function() {
return t.isArrayBufferLike;
}
});
Object.defineProperty(e, "isArrayBufferView", {
enumerable: true,
get: function() {
return t.isArrayBufferView;
}
});
Object.defineProperty(e, "isBufferSource", {
enumerable: true,
get: function() {
return t.isBufferSource;
}
});
Object.defineProperty(e, "isSharedArrayBuffer", {
enumerable: true,
get: function() {
return t.isSharedArrayBuffer;
}
});
Object.defineProperty(e, "toArrayBuffer", {
enumerable: true,
get: function() {
return t.toArrayBuffer;
}
});
Object.defineProperty(e, "toArrayBufferLike", {
enumerable: true,
get: function() {
return t.toArrayBufferLike;
}
});
Object.defineProperty(e, "toUint8Array", {
enumerable: true,
get: function() {
return t.toUint8Array;
}
});
Object.defineProperty(e, "toUint8ArrayCopy", {
enumerable: true,
get: function() {
return t.toUint8ArrayCopy;
}
});
Object.defineProperty(e, "toView", {
enumerable: true,
get: function() {
return t.toView;
}
});
Object.defineProperty(e, "toViewCopy", {
enumerable: true,
get: function() {
return t.toViewCopy;
}
});
var n = require_concat();
Object.defineProperty(e, "concat", {
enumerable: true,
get: function() {
return n.concat;
}
});
Object.defineProperty(e, "concatToUint8Array", {
enumerable: true,
get: function() {
return n.concatToUint8Array;
}
});
var r = require_equal();
Object.defineProperty(e, "equal", {
enumerable: true,
get: function() {
return r.equal;
}
});
var i = require_sequence();
Object.defineProperty(e, "compare", {
enumerable: true,
get: function() {
return i.compare;
}
});
Object.defineProperty(e, "copy", {
enumerable: true,
get: function() {
return i.copy;
}
});
Object.defineProperty(e, "endsWith", {
enumerable: true,
get: function() {
return i.endsWith;
}
});
Object.defineProperty(e, "includes", {
enumerable: true,
get: function() {
return i.includes;
}
});
Object.defineProperty(e, "indexOf", {
enumerable: true,
get: function() {
return i.indexOf;
}
});
Object.defineProperty(e, "lastIndexOf", {
enumerable: true,
get: function() {
return i.lastIndexOf;
}
});
Object.defineProperty(e, "slice", {
enumerable: true,
get: function() {
return i.slice;
}
});
Object.defineProperty(e, "startsWith", {
enumerable: true,
get: function() {
return i.startsWith;
}
});
Object.defineProperty(e, "tail", {
enumerable: true,
get: function() {
return i.tail;
}
});
}));
//#endregion
//#region node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/cjs/encoding/binary.js
var require_binary = /* @__PURE__ */ __commonJSMin(((e) => {
Object.defineProperty(e, "__esModule", { value: true });
e.binary = void 0;
e.encode = encode;
e.decode = decode;
e.is = is;
const t = require_bytes();
function encode(e) {
const n = (0, t.toUint8Array)(e);
let r = "";
for (const e of n) r += String.fromCharCode(e);
return r;
}
function decode(e) {
const t = new Uint8Array(e.length);
for (let n = 0; n < e.length; n++) t[n] = e.charCodeAt(n) & 255;
return t;
}
function is(e) {
return typeof e === "string";
}
e.binary = {
encode,
decode,
is
};
}));
//#endregion
//#region node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/cjs/encoding/hex.js
var require_hex = /* @__PURE__ */ __commonJSMin(((e) => {
Object.defineProperty(e, "__esModule", { value: true });
e.hex = e.formats = void 0;
e.normalize = normalize;
e.is = is;
e.encode = encode;
e.decode = decode;
e.parse = parse;
e.format = format;
const t = require_bytes();
const n = /^[0-9a-f]$/i;
const r = [
" ",
" ",
"\n",
"\r",
":",
"-",
"."
];
function resolveSeparators(e) {
if (e.separators === "none") return [];
if (!e.separators || e.separators === "common") return r;
return e.separators;
}
function validateSeparator(e) {
if (!e) throw new TypeError("Hex separators must be non-empty strings");
}
function matchSeparator(e, t, n) {
for (const r of n) if (e.startsWith(r, t)) return r;
}
function detectCase(e) {
const t = /[A-F]/.test(e);
const n = /[a-f]/.test(e);
return t && !n ? "upper" : "lower";
}
function detectLineSeparator(e) {
const t = /\r\n|\n/.exec(e);
if (!t) return;
return t[0] === "\r\n" ? "\r\n" : "\n";
}
function compactForDetection(e) {
return e.replace(/[^0-9a-f]/gi, "");
}
function detectGroup(e) {
const t = e.match(/[0-9A-Fa-f]+|[^0-9A-Fa-f]+/g) ?? [];
if (t.length < 3) return;
const n = t.filter((e, t) => t % 2 === 0);
const r = t.filter((e, t) => t % 2 === 1);
const i = r[0];
if (!i || r.some((e) => e !== i)) return;
if (n.some((e) => e.length === 0 || e.length % 2 !== 0)) return;
const a = n[0]?.length ?? 0;
if (!a) return;
if (n.slice(0, -1).some((e) => e.length !== a)) return;
if ((n[n.length - 1]?.length ?? 0) > a) return;
return {
size: a / 2,
separator: i
};
}
function detectFormat(e) {
const t = e.trim();
const n = /^0x/i.test(t) ? "0x" : "";
const r = n ? t.slice(2) : t;
const i = detectLineSeparator(r);
const a = r.split(/\r\n|\n/).filter((e) => e.length > 0);
const o = detectGroup(a[0]?.trim() ?? "");
const s = {
case: detectCase(t),
prefix: n
};
if (o) s.group = o;
if (i && a.length > 1) {
const e = compactForDetection(a[0] ?? "").length / 2;
if (e > 0 && a.slice(0, -1).every((t) => compactForDetection(t).length / 2 === e)) s.line = {
bytesPerLine: e,
separator: i
};
}
return s;
}
function normalizeText(e, t) {
const r = t.allowPrefix ?? true;
const i = [...resolveSeparators(t)].sort((e, t) => t.length - e.length);
for (const e of i) validateSeparator(e);
let a = e.trim();
if (/^0x/i.test(a)) {
if (!r) throw new TypeError("Hexadecimal text must not include a 0x prefix");
a = a.slice(2);
}
let o = "";
let s = false;
for (let e = 0; e < a.length;) {
const r = a[e] ?? "";
if (n.test(r)) {
o += r;
s = false;
e += 1;
continue;
}
const c = matchSeparator(a, e, i);
if (!c) throw new TypeError("Input is not valid hexadecimal text");
if (t.strict && (s || o.length === 0)) throw new TypeError("Hexadecimal text contains misplaced separators");
s = true;
e += c.length;
}
if (t.strict && s && o.length > 0) throw new TypeError("Hexadecimal text must not end with a separator");
if (o.length % 2 !== 0) {
if (!t.allowOddLength) throw new TypeError("Hexadecimal text must contain an even number of characters");
o = `0${o}`;
}
return o.toLowerCase();
}
function groupPairs(e, t) {
if (!t) return e.join("");
if (!Number.isInteger(t.size) || t.size < 1) throw new RangeError("Hex group size must be a positive integer");
const n = [];
for (let r = 0; r < e.length; r += t.size) n.push(e.slice(r, r + t.size).join(""));
return n.join(t.separator);
}
function normalize(e, t = {}) {
return normalizeText(e, t);
}
function is(e, t = {}) {
if (typeof e !== "string") return false;
try {
normalize(e, t);
return true;
} catch {
return false;
}
}
function encode(e, n = {}) {
const r = (0, t.toUint8Array)(e);
const i = n.case ?? "lower";
const a = Array.from(r, (e) => {
const t = e.toString(16).padStart(2, "0");
return i === "upper" ? t.toUpperCase() : t;
});
let o = "";
if (n.line) {
const e = n.line.bytesPerLine;
if (!Number.isInteger(e) || e < 1) throw new RangeError("Hex bytesPerLine must be a positive integer");
const t = n.line.separator ?? "\n";
const r = [];
for (let t = 0; t < a.length; t += e) r.push(groupPairs(a.slice(t, t + e), n.group));
o = r.join(t);
} else o = groupPairs(a, n.group);
return `${n.prefix ?? ""}${o}`;
}
function decode(e, t = {}) {
const n = normalize(e, t);
const r = new Uint8Array(n.length / 2);
for (let e = 0; e < n.length; e += 2) r[e / 2] = Number.parseInt(n.slice(e, e + 2), 16);
return r;
}
function parse(e, t = {}) {
const n = normalize(e, t);
return {
bytes: decode(n),
format: detectFormat(e),
normalized: n
};
}
function format(e, t) {
return encode(e, t);
}
e.formats = {
compact: Object.freeze({}),
upper: Object.freeze({ case: "upper" }),
colon: Object.freeze({ group: {
size: 1,
separator: ":"
} }),
colonUpper: Object.freeze({
case: "upper",
group: {
size: 1,
separator: ":"
}
}),
groupsOf4: Object.freeze({ group: {
size: 4,
separator: " "
} }),
prefixed: Object.freeze({ prefix: "0x" })
};
e.hex = {
encode,
decode,
format,
formats: e.formats,
is,
normalize,
parse
};
}));
//#endregion
//#region node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/cjs/encoding/utf8.js
var require_utf8 = /* @__PURE__ */ __commonJSMin(((e) => {
Object.defineProperty(e, "__esModule", { value: true });
e.utf8 = void 0;
e.encode = encode;
e.decode = decode;
const t = require_bytes();
function encode(e) {
return new TextEncoder().encode(e);
}
function decode(e) {
return new TextDecoder("utf-8", { fatal: false }).decode((0, t.toUint8Array)(e));
}
e.utf8 = {
encode,
decode
};
}));
//#endregion
//#region node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/cjs/encoding/utf16.js
var require_utf16 = /* @__PURE__ */ __commonJSMin(((e) => {
Object.defineProperty(e, "__esModule", { value: true });
e.utf16 = void 0;
e.encode = encode;
e.decode = decode;
const t = require_bytes();
function encode(e, t = {}) {
const n = /* @__PURE__ */ new ArrayBuffer(e.length * 2);
const r = new DataView(n);
for (let n = 0; n < e.length; n++) r.setUint16(n * 2, e.charCodeAt(n), t.littleEndian ?? false);
return new Uint8Array(n);
}
function decode(e, n = {}) {
const r = (0, t.toArrayBuffer)(e);
const i = new DataView(r);
let a = "";
for (let e = 0; e < r.byteLength; e += 2) a += String.fromCharCode(i.getUint16(e, n.littleEndian ?? false));
return a;
}
e.utf16 = {
encode,
decode
};
}));
//#endregion
//#region node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/cjs/encoding/base64.js
var require_base64 = /* @__PURE__ */ __commonJSMin(((e) => {
Object.defineProperty(e, "__esModule", { value: true });
e.base64 = void 0;
e.normalize = normalize;
e.pad = pad;
e.is = is;
e.encode = encode;
e.decode = decode;
const t = require_bytes();
const n = require_binary();
const r = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
function nodeBuffer() {
return globalThis.Buffer;
}
function normalize(e) {
return e.replace(/[\n\r\t ]/g, "");
}
function pad(e) {
const t = e.length % 4;
return t ? e + "=".repeat(4 - t) : e;
}
function is(e) {
if (typeof e !== "string") return false;
const t = normalize(e);
return t === "" || r.test(t);
}
function encode(e, r) {
const i = (0, t.toUint8Array)(e);
const a = nodeBuffer();
if (a) return a.from(i).toString("base64");
return btoa((0, n.encode)(i));
}
function decode(e, t) {
const r = normalize(e);
if (!is(r)) throw new TypeError("Input is not valid Base64 text");
const i = nodeBuffer();
if (i) return new Uint8Array(i.from(r, "base64"));
return (0, n.decode)(atob(r));
}
e.base64 = {
encode,
decode,
is,
normalize,
pad
};
}));
//#endregion
//#region node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/cjs/encoding/base64url.js
var require_base64url = /* @__PURE__ */ __commonJSMin(((e) => {
Object.defineProperty(e, "__esModule", { value: true });
e.base64url = void 0;
e.normalize = normalize;
e.is = is;
e.encode = encode;
e.decode = decode;
const t = require_base64();
const n = /^[A-Za-z0-9_-]*$/;
function normalize(e) {
return e.replace(/[\n\r\t ]/g, "");
}
function is(e) {
return typeof e === "string" && n.test(normalize(e));
}
function encode(e, n) {
return t.base64.encode(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
}
function decode(e, n) {
const r = normalize(e);
if (!is(r)) throw new TypeError("Input is not valid Base64Url text");
return t.base64.decode(t.base64.pad(r.replace(/-/g, "+").replace(/_/g, "/")));
}
e.base64url = {
encode,
decode,
is,
normalize
};
}));
//#endregion
//#region node_modules/.pnpm/@peculiar+utils@2.0.3/node_modules/@peculiar/utils/build/cjs/encoding/index.js
var require_encoding = /* @__PURE__ */ __commonJSMin(((e) => {
Object.defineProperty(e, "__esModule", { value: true });
e.base64url = e.base64 = e.utf16 = e.utf8 = e.hex = e.binary = void 0;
const t = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
e.binary = t.__importStar(require_binary());
e.hex = t.__importStar(require_hex());
e.utf8 = t.__importStar(require_utf8());
e.utf16 = t.__importStar(require_utf16());
e.base64 = t.__importStar(require_base64());
e.base64url = t.__importStar(require_base64url());
}));
//#endregion
export { require_build$1 as a, require_build as i, require_base64 as n, init_tslib_es6 as o, require_bytes as r, tslib_es6_exports as s, require_encoding as t };