@cbortech/cbor 0.23.0 → 0.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +6 -3
- package/README.md +7 -4
- package/dist/ast/CborArray.d.ts +17 -0
- package/dist/ast/CborBignum.d.ts +36 -0
- package/dist/ast/CborByteString.d.ts +20 -0
- package/dist/ast/CborEllipsis.d.ts +11 -0
- package/dist/ast/CborEmbeddedCBOR.d.ts +22 -0
- package/dist/ast/CborFloat.d.ts +27 -0
- package/dist/ast/CborIndefiniteByteString.d.ts +13 -0
- package/dist/ast/CborIndefiniteTextString.d.ts +13 -0
- package/dist/ast/CborItem.d.ts +91 -0
- package/dist/ast/CborMap.d.ts +17 -0
- package/dist/ast/CborNint.d.ts +27 -0
- package/dist/ast/CborSimple.d.ts +22 -0
- package/dist/ast/CborTag.d.ts +16 -0
- package/dist/ast/CborTextString.d.ts +15 -0
- package/dist/ast/CborUint.d.ts +14 -0
- package/dist/ast/CborUnresolvedAppExt.d.ts +16 -0
- package/dist/ast/index.cjs +1 -0
- package/dist/ast/index.d.ts +15 -0
- package/dist/ast/index.js +2 -0
- package/dist/cbor/constants.d.ts +14 -0
- package/dist/cbor/decoder.d.ts +11 -0
- package/dist/cbor/encode.d.ts +35 -0
- package/dist/cbor/encoder.d.ts +7 -0
- package/dist/cbor.d.ts +129 -0
- package/dist/edn/parser.d.ts +7 -0
- package/dist/edn/serialize-utils.d.ts +48 -0
- package/dist/edn/serializer.d.ts +7 -0
- package/dist/edn/tokenizer.d.ts +176 -0
- package/dist/extensions/bignum.d.ts +3 -0
- package/dist/extensions/builtins.d.ts +2 -0
- package/dist/extensions/cbordata.d.ts +4 -0
- package/dist/extensions/cri.d.ts +32 -0
- package/dist/extensions/dt.d.ts +109 -0
- package/dist/extensions/hash.d.ts +17 -0
- package/dist/extensions/ip.d.ts +41 -0
- package/dist/extensions/types.d.ts +70 -0
- package/dist/index.cjs +2 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -695
- package/dist/index.js +30 -3913
- package/dist/index.js.map +1 -1
- package/dist/js/fromJS.d.ts +25 -0
- package/dist/js/toJS.d.ts +6 -0
- package/dist/mapEntries-C73nWM8o.cjs +31 -0
- package/dist/mapEntries-C73nWM8o.cjs.map +1 -0
- package/dist/mapEntries-CSjvgq1X.js +3887 -0
- package/dist/mapEntries-CSjvgq1X.js.map +1 -0
- package/dist/mapEntries.d.ts +3 -0
- package/dist/simple.d.ts +25 -0
- package/dist/tag.d.ts +45 -0
- package/dist/types.d.ts +352 -0
- package/dist/utils/float16.d.ts +38 -0
- package/dist/utils/hexfloat.d.ts +27 -0
- package/dist/utils/ip.d.ts +9 -0
- package/package.json +12 -1
|
@@ -0,0 +1,3887 @@
|
|
|
1
|
+
//#region src/tag.ts
|
|
2
|
+
var e = Symbol.for("cbor.tag"), t = class {
|
|
3
|
+
valueOf() {
|
|
4
|
+
return null;
|
|
5
|
+
}
|
|
6
|
+
toJSON() {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
}, n = class {
|
|
10
|
+
valueOf() {}
|
|
11
|
+
toJSON() {}
|
|
12
|
+
};
|
|
13
|
+
function r(t) {
|
|
14
|
+
if (!s(t)) return;
|
|
15
|
+
let n = t[e];
|
|
16
|
+
return typeof n == "bigint" ? n : void 0;
|
|
17
|
+
}
|
|
18
|
+
function i(r, i) {
|
|
19
|
+
let a;
|
|
20
|
+
switch (typeof r) {
|
|
21
|
+
case "number":
|
|
22
|
+
a = new Number(r);
|
|
23
|
+
break;
|
|
24
|
+
case "string":
|
|
25
|
+
a = new String(r);
|
|
26
|
+
break;
|
|
27
|
+
case "boolean":
|
|
28
|
+
a = new Boolean(r);
|
|
29
|
+
break;
|
|
30
|
+
case "bigint":
|
|
31
|
+
a = Object(r);
|
|
32
|
+
break;
|
|
33
|
+
case "undefined":
|
|
34
|
+
a = new n();
|
|
35
|
+
break;
|
|
36
|
+
case "object":
|
|
37
|
+
if (r === null) {
|
|
38
|
+
a = new t();
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
a = r;
|
|
42
|
+
break;
|
|
43
|
+
default: throw TypeError(`setCborTag: cannot tag value of type ${typeof r}`);
|
|
44
|
+
}
|
|
45
|
+
return a[e] = i, a;
|
|
46
|
+
}
|
|
47
|
+
function a(r) {
|
|
48
|
+
if (r instanceof Number || r instanceof String || r instanceof Boolean || Object.prototype.toString.call(r) === "[object BigInt]") return r.valueOf();
|
|
49
|
+
if (r instanceof t) return null;
|
|
50
|
+
if (!(r instanceof n)) return typeof r == "object" && r && delete r[e], r;
|
|
51
|
+
}
|
|
52
|
+
function o(e) {
|
|
53
|
+
if (e instanceof Number || e instanceof String || e instanceof Boolean || Object.prototype.toString.call(e) === "[object BigInt]") return e.valueOf();
|
|
54
|
+
if (e instanceof t) return null;
|
|
55
|
+
if (!(e instanceof n)) return e;
|
|
56
|
+
}
|
|
57
|
+
function s(e) {
|
|
58
|
+
return typeof e == "object" && !!e;
|
|
59
|
+
}
|
|
60
|
+
var c = class {
|
|
61
|
+
constructor() {}
|
|
62
|
+
static symbol = e;
|
|
63
|
+
static Null = t;
|
|
64
|
+
static Undefined = n;
|
|
65
|
+
static get(e) {
|
|
66
|
+
return r(e);
|
|
67
|
+
}
|
|
68
|
+
static set(e, t) {
|
|
69
|
+
return i(e, t);
|
|
70
|
+
}
|
|
71
|
+
static remove(e) {
|
|
72
|
+
return a(e);
|
|
73
|
+
}
|
|
74
|
+
static getValue(e) {
|
|
75
|
+
return o(e);
|
|
76
|
+
}
|
|
77
|
+
}, l = Symbol("cbor.omit"), u = class e {
|
|
78
|
+
value;
|
|
79
|
+
constructor(e) {
|
|
80
|
+
if (!Number.isInteger(e) || e < 0 || e > 255) throw RangeError("Simple value must be an integer in 0–255");
|
|
81
|
+
this.value = e;
|
|
82
|
+
}
|
|
83
|
+
valueOf() {
|
|
84
|
+
return this.value;
|
|
85
|
+
}
|
|
86
|
+
toJSON() {
|
|
87
|
+
throw TypeError(`simple(${this.value}) cannot be serialized to JSON`);
|
|
88
|
+
}
|
|
89
|
+
static is(t) {
|
|
90
|
+
return t instanceof e;
|
|
91
|
+
}
|
|
92
|
+
static get(t) {
|
|
93
|
+
return t instanceof e ? t.value : void 0;
|
|
94
|
+
}
|
|
95
|
+
}, d = class {
|
|
96
|
+
start;
|
|
97
|
+
end;
|
|
98
|
+
comments;
|
|
99
|
+
_defaults;
|
|
100
|
+
toCBOR(e) {
|
|
101
|
+
let t = this._defaults ? {
|
|
102
|
+
...this._defaults,
|
|
103
|
+
...e
|
|
104
|
+
} : e;
|
|
105
|
+
return this._toCBOR(t);
|
|
106
|
+
}
|
|
107
|
+
toEDN(e) {
|
|
108
|
+
let t = this._defaults ? {
|
|
109
|
+
...this._defaults,
|
|
110
|
+
...e
|
|
111
|
+
} : e, n = this._toEDN(t, 0);
|
|
112
|
+
if (!t?.preserveComments) return n;
|
|
113
|
+
let r = this.comments?.leading?.map((e) => e.text) ?? [], i = this.comments?.trailing ?? [], a = i.length === 0 ? n : `${n} ${i.map((e) => e.text.trimEnd()).join(" ")}`;
|
|
114
|
+
return [...r, a].join("\n");
|
|
115
|
+
}
|
|
116
|
+
toJS(e) {
|
|
117
|
+
let t = this._defaults ? {
|
|
118
|
+
...this._defaults,
|
|
119
|
+
...e
|
|
120
|
+
} : e, n = this._toJS(t);
|
|
121
|
+
if (!t?.reviver) return n;
|
|
122
|
+
let r = t.reviver.call({ "": n }, "", n);
|
|
123
|
+
return r === l ? void 0 : r;
|
|
124
|
+
}
|
|
125
|
+
toHexDump(e) {
|
|
126
|
+
let t = this._defaults ? {
|
|
127
|
+
...this._defaults,
|
|
128
|
+
...e
|
|
129
|
+
} : e, n = t?.indent ?? 3, r = typeof n == "string" ? n : " ".repeat(n), i = (t?.commentStyle ?? "--") + " ", a = this._toHexDump(0, t), o = Math.max(...a.map((e) => e.depth * r.length + e.hex.length)) + 2;
|
|
130
|
+
return a.map((e) => (r.repeat(e.depth) + e.hex).padEnd(o) + i + e.comment).join("\n");
|
|
131
|
+
}
|
|
132
|
+
_toHexDump(e, t) {
|
|
133
|
+
return [{
|
|
134
|
+
depth: e,
|
|
135
|
+
hex: Array.from(this._toCBOR(), (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" "),
|
|
136
|
+
comment: this._toEDN(t, 0)
|
|
137
|
+
}];
|
|
138
|
+
}
|
|
139
|
+
}, f = "getFloat16" in DataView.prototype && "setFloat16" in DataView.prototype, p = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
140
|
+
function m(e) {
|
|
141
|
+
p.setFloat64(0, e, !1);
|
|
142
|
+
let t = p.getUint32(0, !1), n = p.getUint32(4, !1), r = t >>> 31 & 1, i = t >>> 20 & 2047, a = t & 1048575;
|
|
143
|
+
if (i === 2047) {
|
|
144
|
+
if (a === 0 && n === 0) return r << 15 | 31744;
|
|
145
|
+
let e = a >> 10 | (n === 0 ? 0 : 1) || 1;
|
|
146
|
+
return r << 15 | 31744 | e & 1023;
|
|
147
|
+
}
|
|
148
|
+
let o = i - 1023 + 15;
|
|
149
|
+
if (o >= 31) return r << 15 | 31744;
|
|
150
|
+
let s, c, l;
|
|
151
|
+
if (o <= 0) {
|
|
152
|
+
if (o < -10) return r << 15;
|
|
153
|
+
let e = 1 << 20 | a, t = 11 - o;
|
|
154
|
+
t <= 20 ? (s = e >> t & 1023, c = e >> t - 1 & 1, l = (e & (1 << t - 1) - 1) != 0 || n !== 0) : (s = 0, c = 1, l = a !== 0 || n !== 0);
|
|
155
|
+
} else s = a >> 10, c = a >> 9 & 1, l = (a & 511) != 0 || n !== 0;
|
|
156
|
+
if (c !== 0 && (l || s & 1) && s++, s >= 1024) {
|
|
157
|
+
let e = o <= 0 ? 1 : o + 1;
|
|
158
|
+
return e >= 31 ? r << 15 | 31744 : r << 15 | e << 10;
|
|
159
|
+
}
|
|
160
|
+
let u = o <= 0 ? 0 : o;
|
|
161
|
+
return r << 15 | u << 10 | s;
|
|
162
|
+
}
|
|
163
|
+
function h(e) {
|
|
164
|
+
let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023;
|
|
165
|
+
return n === 31 ? r === 0 ? t ? -Infinity : Infinity : NaN : n === 0 ? r === 0 ? t ? -0 : 0 : (t ? -1 : 1) * 2 ** -14 * (r / 1024) : (t ? -1 : 1) * 2 ** (n - 15) * (1 + r / 1024);
|
|
166
|
+
}
|
|
167
|
+
var g = f ? (e, t, n, r) => {
|
|
168
|
+
e.setFloat16(t, n, r);
|
|
169
|
+
} : (e, t, n, r) => {
|
|
170
|
+
e.setUint16(t, m(n), r);
|
|
171
|
+
};
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region src/cbor/encode.ts
|
|
174
|
+
function _(e, t, n) {
|
|
175
|
+
if (n !== void 0) {
|
|
176
|
+
if (n === "i") {
|
|
177
|
+
if (t > 23n) throw RangeError(`value ${t} does not fit in immediate encoding _i (max 23)`);
|
|
178
|
+
return new Uint8Array([e << 5 | Number(t)]);
|
|
179
|
+
}
|
|
180
|
+
let r = [
|
|
181
|
+
255n,
|
|
182
|
+
65535n,
|
|
183
|
+
4294967295n,
|
|
184
|
+
18446744073709551615n
|
|
185
|
+
];
|
|
186
|
+
if (t > r[n]) throw RangeError(`value ${t} does not fit in encodingWidth _${n} (max ${r[n]})`);
|
|
187
|
+
let i = 24 + n;
|
|
188
|
+
if (i === 24) return new Uint8Array([e << 5 | 24, Number(t)]);
|
|
189
|
+
if (i === 25) {
|
|
190
|
+
let n = new Uint8Array(3);
|
|
191
|
+
return n[0] = e << 5 | 25, n[1] = Number(t >> 8n), n[2] = Number(t & 255n), n;
|
|
192
|
+
}
|
|
193
|
+
if (i === 26) {
|
|
194
|
+
let n = new Uint8Array(5);
|
|
195
|
+
return n[0] = e << 5 | 26, new DataView(n.buffer).setUint32(1, Number(t), !1), n;
|
|
196
|
+
}
|
|
197
|
+
let a = new Uint8Array(9);
|
|
198
|
+
return a[0] = e << 5 | 27, new DataView(a.buffer).setBigUint64(1, t, !1), a;
|
|
199
|
+
}
|
|
200
|
+
if (t <= 23n) return new Uint8Array([e << 5 | Number(t)]);
|
|
201
|
+
if (t <= 255n) return new Uint8Array([e << 5 | 24, Number(t)]);
|
|
202
|
+
if (t <= 65535n) {
|
|
203
|
+
let n = new Uint8Array(3);
|
|
204
|
+
return n[0] = e << 5 | 25, n[1] = Number(t >> 8n), n[2] = Number(t & 255n), n;
|
|
205
|
+
}
|
|
206
|
+
if (t <= 4294967295n) {
|
|
207
|
+
let n = new Uint8Array(5);
|
|
208
|
+
return n[0] = e << 5 | 26, new DataView(n.buffer).setUint32(1, Number(t), !1), n;
|
|
209
|
+
}
|
|
210
|
+
let r = new Uint8Array(9);
|
|
211
|
+
return r[0] = e << 5 | 27, new DataView(r.buffer).setBigUint64(1, t, !1), r;
|
|
212
|
+
}
|
|
213
|
+
function v(e) {
|
|
214
|
+
let t = e.reduce((e, t) => e + t.length, 0), n = new Uint8Array(t), r = 0;
|
|
215
|
+
for (let t of e) n.set(t, r), r += t.length;
|
|
216
|
+
return n;
|
|
217
|
+
}
|
|
218
|
+
var ee = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(4));
|
|
219
|
+
function te(e) {
|
|
220
|
+
return Object.is(h(m(e)), e);
|
|
221
|
+
}
|
|
222
|
+
function ne(e) {
|
|
223
|
+
return ee.setFloat32(0, e, !1), Object.is(ee.getFloat32(0, !1), e);
|
|
224
|
+
}
|
|
225
|
+
function re(e) {
|
|
226
|
+
return te(e) ? "half" : ne(e) ? "single" : "double";
|
|
227
|
+
}
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region src/ast/CborUint.ts
|
|
230
|
+
var y = class extends d {
|
|
231
|
+
value;
|
|
232
|
+
encodingWidth;
|
|
233
|
+
constructor(e, t) {
|
|
234
|
+
if (super(), this.value = BigInt(e), this.value < 0n) throw RangeError("CborUint value must be non-negative");
|
|
235
|
+
if (this.value > 18446744073709551615n) throw RangeError("CborUint value exceeds maximum uint64");
|
|
236
|
+
this.encodingWidth = t?.encodingWidth;
|
|
237
|
+
}
|
|
238
|
+
_toCBOR(e) {
|
|
239
|
+
return _(0, this.value, this.encodingWidth);
|
|
240
|
+
}
|
|
241
|
+
_toEDN(e, t) {
|
|
242
|
+
let n = this.encodingWidth === void 0 ? "" : `_${this.encodingWidth}`, r = this.value;
|
|
243
|
+
switch (e?.intFormat) {
|
|
244
|
+
case "hex": return `0x${r.toString(16)}${n}`;
|
|
245
|
+
case "octal": return `0o${r.toString(8)}${n}`;
|
|
246
|
+
case "binary": return `0b${r.toString(2)}${n}`;
|
|
247
|
+
default: return r.toString() + n;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
_toJS(e) {
|
|
251
|
+
let t = e?.integerAs ?? "auto";
|
|
252
|
+
return t === "bigint" ? this.value : t === "number" || this.value <= BigInt(2 ** 53 - 1) ? Number(this.value) : this.value;
|
|
253
|
+
}
|
|
254
|
+
}, b = class extends d {
|
|
255
|
+
argument;
|
|
256
|
+
encodingWidth;
|
|
257
|
+
constructor(e, t) {
|
|
258
|
+
super();
|
|
259
|
+
let n = BigInt(e);
|
|
260
|
+
if (n >= 0n) throw RangeError("CborNint value must be negative");
|
|
261
|
+
if (n < -18446744073709551616n) throw RangeError("CborNint value exceeds minimum int64");
|
|
262
|
+
this.argument = -1n - n, this.encodingWidth = t?.encodingWidth;
|
|
263
|
+
}
|
|
264
|
+
get value() {
|
|
265
|
+
return -1n - this.argument;
|
|
266
|
+
}
|
|
267
|
+
_toCBOR(e) {
|
|
268
|
+
return _(1, this.argument, this.encodingWidth);
|
|
269
|
+
}
|
|
270
|
+
_toEDN(e, t) {
|
|
271
|
+
let n = this.encodingWidth === void 0 ? "" : `_${this.encodingWidth}`, r = this.argument + 1n;
|
|
272
|
+
switch (e?.intFormat) {
|
|
273
|
+
case "hex": return `-0x${r.toString(16)}${n}`;
|
|
274
|
+
case "octal": return `-0o${r.toString(8)}${n}`;
|
|
275
|
+
case "binary": return `-0b${r.toString(2)}${n}`;
|
|
276
|
+
default: return this.value.toString() + n;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
_toJS(e) {
|
|
280
|
+
let t = this.value, n = e?.integerAs ?? "auto";
|
|
281
|
+
return n === "bigint" ? t : n === "number" || t >= BigInt(-(2 ** 53 - 1)) ? Number(t) : t;
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
//#endregion
|
|
285
|
+
//#region src/edn/serialize-utils.ts
|
|
286
|
+
function ie(e) {
|
|
287
|
+
let t = e?.indent;
|
|
288
|
+
return t === void 0 ? null : typeof t == "number" ? " ".repeat(t) : t;
|
|
289
|
+
}
|
|
290
|
+
function x(e, t) {
|
|
291
|
+
return e.repeat(t);
|
|
292
|
+
}
|
|
293
|
+
function ae(e) {
|
|
294
|
+
return !!(e.comments?.leading?.length || e.comments?.trailing?.length || e.comments?.dangling?.length);
|
|
295
|
+
}
|
|
296
|
+
function oe(e) {
|
|
297
|
+
return !!(e.comments?.trailing?.length || e.comments?.dangling?.length);
|
|
298
|
+
}
|
|
299
|
+
function se(e, t) {
|
|
300
|
+
return (e.comments?.leading ?? []).map((e) => t + e.text);
|
|
301
|
+
}
|
|
302
|
+
function ce(e) {
|
|
303
|
+
let t = e.comments?.trailing ?? [];
|
|
304
|
+
return t.length === 0 ? "" : " " + t.map((e) => e.text).join(" ");
|
|
305
|
+
}
|
|
306
|
+
function le(e, t) {
|
|
307
|
+
return (e.comments?.dangling ?? []).map((e) => t + e.text);
|
|
308
|
+
}
|
|
309
|
+
function ue(e, t = !1) {
|
|
310
|
+
let n = e?.commas ?? "comma", r = n !== "none";
|
|
311
|
+
return {
|
|
312
|
+
inlineSep: r ? t ? "," : ", " : " ",
|
|
313
|
+
multilineSep: r ? "," : "",
|
|
314
|
+
trailSep: n === "trailing" ? "," : "",
|
|
315
|
+
colSep: t ? ":" : ": "
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
function de(e) {
|
|
319
|
+
return typeof e.toHex == "function" ? e.toHex() : Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
320
|
+
}
|
|
321
|
+
var fe = typeof new Uint8Array().toBase64 == "function";
|
|
322
|
+
function pe(e) {
|
|
323
|
+
if (fe) return e.toBase64({ omitPadding: !0 });
|
|
324
|
+
let t = "";
|
|
325
|
+
for (let n of e) t += String.fromCharCode(n);
|
|
326
|
+
return btoa(t).replace(/=/g, "");
|
|
327
|
+
}
|
|
328
|
+
function me(e) {
|
|
329
|
+
if (fe) return e.toBase64({
|
|
330
|
+
alphabet: "base64url",
|
|
331
|
+
omitPadding: !0
|
|
332
|
+
});
|
|
333
|
+
let t = "";
|
|
334
|
+
for (let n of e) t += String.fromCharCode(n);
|
|
335
|
+
return btoa(t).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
336
|
+
}
|
|
337
|
+
var he = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", ge = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
|
|
338
|
+
function _e(e, t) {
|
|
339
|
+
let n = "", r = 0, i = 0;
|
|
340
|
+
for (let a of e) for (r = r << 8 | a, i += 8; i >= 5;) i -= 5, n += t[r >> i & 31];
|
|
341
|
+
return i > 0 && (n += t[r << 5 - i & 31]), n;
|
|
342
|
+
}
|
|
343
|
+
function ve(e) {
|
|
344
|
+
for (let t of e) {
|
|
345
|
+
let e = t.codePointAt(0);
|
|
346
|
+
if (e < 32 || e === 127) return !0;
|
|
347
|
+
}
|
|
348
|
+
return !1;
|
|
349
|
+
}
|
|
350
|
+
function ye(e, t, n) {
|
|
351
|
+
if (n === "string") {
|
|
352
|
+
let t = be(e);
|
|
353
|
+
if (t != null) return Se(t);
|
|
354
|
+
}
|
|
355
|
+
if (n === "printable-string" || n === void 0) {
|
|
356
|
+
let t = be(e);
|
|
357
|
+
if (t != null && !ve(t)) return Se(t);
|
|
358
|
+
}
|
|
359
|
+
switch (t) {
|
|
360
|
+
case "base64": return `b64'${pe(e)}'`;
|
|
361
|
+
case "base64url": return `b64'${me(e)}'`;
|
|
362
|
+
case "base32": return `b32'${_e(e, he)}'`;
|
|
363
|
+
case "base32hex": return `h32'${_e(e, ge)}'`;
|
|
364
|
+
default: return `h'${de(e)}'`;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
function be(e) {
|
|
368
|
+
try {
|
|
369
|
+
return new TextDecoder("utf-8", { fatal: !0 }).decode(e);
|
|
370
|
+
} catch {
|
|
371
|
+
return null;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
function xe(e, t) {
|
|
375
|
+
let n = t.codePointAt(0), r = t;
|
|
376
|
+
for (let i of e) {
|
|
377
|
+
let e = i.codePointAt(0);
|
|
378
|
+
switch (e) {
|
|
379
|
+
case n:
|
|
380
|
+
r += `\\${t}`;
|
|
381
|
+
break;
|
|
382
|
+
case 92:
|
|
383
|
+
r += "\\\\";
|
|
384
|
+
break;
|
|
385
|
+
case 10:
|
|
386
|
+
r += "\\n";
|
|
387
|
+
break;
|
|
388
|
+
case 13:
|
|
389
|
+
r += "\\r";
|
|
390
|
+
break;
|
|
391
|
+
case 9:
|
|
392
|
+
r += "\\t";
|
|
393
|
+
break;
|
|
394
|
+
default: e < 32 || e === 127 || e === 8232 || e === 8233 || e === 8203 || e === 8204 || e === 8205 || e === 65279 ? r += `\\u${e.toString(16).padStart(4, "0")}` : r += i;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return r + t;
|
|
398
|
+
}
|
|
399
|
+
function Se(e) {
|
|
400
|
+
return xe(e, "'");
|
|
401
|
+
}
|
|
402
|
+
function Ce(e) {
|
|
403
|
+
return xe(e, "'");
|
|
404
|
+
}
|
|
405
|
+
function we(e) {
|
|
406
|
+
return xe(e, "\"");
|
|
407
|
+
}
|
|
408
|
+
function Te(e) {
|
|
409
|
+
if (isNaN(e)) return "NaN";
|
|
410
|
+
if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
|
|
411
|
+
if (Object.is(e, -0)) return "-0.0";
|
|
412
|
+
let t = e.toString();
|
|
413
|
+
return t.includes(".") || t.includes("e") ? t : t + ".0";
|
|
414
|
+
}
|
|
415
|
+
function Ee(e, t, n) {
|
|
416
|
+
return t === void 0 || t === n ? "" : t === "half" ? "_1" : t === "single" ? "_2" : "_3";
|
|
417
|
+
}
|
|
418
|
+
//#endregion
|
|
419
|
+
//#region src/utils/hexfloat.ts
|
|
420
|
+
var De = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
421
|
+
function Oe(e) {
|
|
422
|
+
let t = e.startsWith("-"), n = e.slice(t ? 3 : 2), r = n.search(/[pP]/);
|
|
423
|
+
if (r === -1) throw SyntaxError(`EDN parse error: hex float missing 'p' exponent: ${e}`);
|
|
424
|
+
let i = n.slice(0, r), a = n.slice(r + 1);
|
|
425
|
+
if (!/^[+-]?\d+$/.test(a)) throw SyntaxError(`EDN parse error: hex float has invalid or missing exponent: ${e}`);
|
|
426
|
+
let o = parseInt(a, 10), s = i.indexOf("."), c;
|
|
427
|
+
if (s === -1) {
|
|
428
|
+
if (!/^[0-9a-fA-F]+$/.test(i)) throw SyntaxError(`EDN parse error: hex float has no mantissa digits: ${e}`);
|
|
429
|
+
c = parseInt(i, 16);
|
|
430
|
+
} else {
|
|
431
|
+
let t = i.slice(0, s), n = i.slice(s + 1);
|
|
432
|
+
if (t === "" && n === "") throw SyntaxError(`EDN parse error: hex float has no mantissa digits: ${e}`);
|
|
433
|
+
if (t !== "" && !/^[0-9a-fA-F]+$/.test(t) || n !== "" && !/^[0-9a-fA-F]+$/.test(n)) throw SyntaxError(`EDN parse error: hex float has invalid mantissa: ${e}`);
|
|
434
|
+
c = (t === "" ? 0 : parseInt(t, 16)) + (n === "" ? 0 : parseInt(n, 16) / 16 ** n.length);
|
|
435
|
+
}
|
|
436
|
+
let l = c * 2 ** o;
|
|
437
|
+
return t ? -l : l;
|
|
438
|
+
}
|
|
439
|
+
function ke(e) {
|
|
440
|
+
if (isNaN(e)) return "NaN";
|
|
441
|
+
if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
|
|
442
|
+
let t = Object.is(e, -0) || e < 0, n = Math.abs(e);
|
|
443
|
+
if (n === 0) return t ? "-0x0p+0" : "0x0p+0";
|
|
444
|
+
De.setFloat64(0, n, !1);
|
|
445
|
+
let r = De.getUint32(0, !1), i = De.getUint32(4, !1), a = r >>> 20 & 2047, o = r & 1048575, s = i, c = (o.toString(16).padStart(5, "0") + s.toString(16).padStart(8, "0")).replace(/0+$/, ""), l = c === "" ? "" : `.${c}`, u, d;
|
|
446
|
+
a === 0 ? (u = "0", d = -1022) : (u = "1", d = a - 1023);
|
|
447
|
+
let f = d >= 0 ? `+${d}` : `${d}`, p = `0x${u}${l}p${f}`;
|
|
448
|
+
return t ? `-${p}` : p;
|
|
449
|
+
}
|
|
450
|
+
//#endregion
|
|
451
|
+
//#region src/ast/CborFloat.ts
|
|
452
|
+
var S = class extends d {
|
|
453
|
+
value;
|
|
454
|
+
precision;
|
|
455
|
+
constructor(e, t) {
|
|
456
|
+
super(), this.value = e, this.precision = t?.precision;
|
|
457
|
+
}
|
|
458
|
+
_toCBOR(e) {
|
|
459
|
+
let t = this.precision ?? re(this.value);
|
|
460
|
+
if (t === "half") {
|
|
461
|
+
let e = new Uint8Array(3);
|
|
462
|
+
return e[0] = 249, g(new DataView(e.buffer), 1, this.value, !1), e;
|
|
463
|
+
}
|
|
464
|
+
if (t === "single") {
|
|
465
|
+
let e = new Uint8Array(5);
|
|
466
|
+
return e[0] = 250, new DataView(e.buffer).setFloat32(1, this.value, !1), e;
|
|
467
|
+
}
|
|
468
|
+
let n = new Uint8Array(9);
|
|
469
|
+
return n[0] = 251, new DataView(n.buffer).setFloat64(1, this.value, !1), n;
|
|
470
|
+
}
|
|
471
|
+
_toEDN(e, t) {
|
|
472
|
+
let n = re(this.value);
|
|
473
|
+
return (e?.floatFormat === "hex" ? ke(this.value) : Te(this.value)) + Ee(this.value, this.precision, n);
|
|
474
|
+
}
|
|
475
|
+
_toJS(e) {
|
|
476
|
+
return this.value;
|
|
477
|
+
}
|
|
478
|
+
}, C = class extends d {
|
|
479
|
+
tag;
|
|
480
|
+
content;
|
|
481
|
+
encodingWidth;
|
|
482
|
+
constructor(e, t, n) {
|
|
483
|
+
if (super(), this.tag = BigInt(e), this.tag < 0n) throw RangeError("CborTag tag number must be non-negative");
|
|
484
|
+
this.content = t, this.encodingWidth = n?.encodingWidth;
|
|
485
|
+
}
|
|
486
|
+
_toCBOR(e) {
|
|
487
|
+
return v([_(6, this.tag, this.encodingWidth), this.content._toCBOR(e)]);
|
|
488
|
+
}
|
|
489
|
+
_toEDN(e, t) {
|
|
490
|
+
let n = this.encodingWidth === void 0 ? "" : `_${this.encodingWidth}`;
|
|
491
|
+
return `${this.tag}${n}(${this.content._toEDN(e, t)})`;
|
|
492
|
+
}
|
|
493
|
+
_toHexDump(e, t) {
|
|
494
|
+
let n = [{
|
|
495
|
+
depth: e,
|
|
496
|
+
hex: ((e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" "))(_(6, this.tag, this.encodingWidth)),
|
|
497
|
+
comment: `Tag ${this.tag}`
|
|
498
|
+
}];
|
|
499
|
+
return n.push(...this.content._toHexDump(e + 1, t)), n;
|
|
500
|
+
}
|
|
501
|
+
_toJS(e) {
|
|
502
|
+
return c.set(this.content._toJS(e), this.tag);
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
//#endregion
|
|
506
|
+
//#region src/edn/tokenizer.ts
|
|
507
|
+
function Ae(e, t) {
|
|
508
|
+
let n = 1, r = 1;
|
|
509
|
+
for (let i = 0; i < t; i++) e[i] === "\n" ? (n++, r = 1) : r++;
|
|
510
|
+
return {
|
|
511
|
+
line: n,
|
|
512
|
+
col: r
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
var je = class {
|
|
516
|
+
pos;
|
|
517
|
+
line;
|
|
518
|
+
col;
|
|
519
|
+
_peeked = null;
|
|
520
|
+
_lastConsumedEndOffset;
|
|
521
|
+
comments = [];
|
|
522
|
+
constructor(e, t) {
|
|
523
|
+
this.input = e;
|
|
524
|
+
let n = t?.offset ?? 0;
|
|
525
|
+
if (!Number.isInteger(n) || n < 0 || n > e.length) throw RangeError(`EDN parse offset must be an integer between 0 and ${e.length}`);
|
|
526
|
+
let r = Ae(e, n);
|
|
527
|
+
this.pos = n, this.line = r.line, this.col = r.col, this._lastConsumedEndOffset = n;
|
|
528
|
+
}
|
|
529
|
+
peek() {
|
|
530
|
+
return this._peeked === null && (this._peeked = this._readNext()), this._peeked;
|
|
531
|
+
}
|
|
532
|
+
consume() {
|
|
533
|
+
let e = this._peeked === null ? this._readNext() : this._peeked;
|
|
534
|
+
return this._peeked = null, this._lastConsumedEndOffset = e.endOffset, e;
|
|
535
|
+
}
|
|
536
|
+
get lastEndOffset() {
|
|
537
|
+
return this._lastConsumedEndOffset;
|
|
538
|
+
}
|
|
539
|
+
_ch() {
|
|
540
|
+
return this.input[this.pos] ?? "";
|
|
541
|
+
}
|
|
542
|
+
_eof() {
|
|
543
|
+
return this.pos >= this.input.length;
|
|
544
|
+
}
|
|
545
|
+
_advance() {
|
|
546
|
+
let e = this.input[this.pos++] ?? "";
|
|
547
|
+
return e === "\n" ? (this.line++, this.col = 1) : this.col++, e;
|
|
548
|
+
}
|
|
549
|
+
_fail(e, t = this.line, n = this.col) {
|
|
550
|
+
throw SyntaxError(`EDN parse error at line ${t}, column ${n}: ${e}`);
|
|
551
|
+
}
|
|
552
|
+
_skipWS() {
|
|
553
|
+
for (;;) {
|
|
554
|
+
for (; !this._eof() && /\s/.test(this._ch());) this._advance();
|
|
555
|
+
if (this._eof()) return;
|
|
556
|
+
let e = this._ch();
|
|
557
|
+
if (e === "#") {
|
|
558
|
+
let e = this.pos, t = this.line, n = this.col;
|
|
559
|
+
for (; !this._eof() && this._ch() !== "\n";) this._advance();
|
|
560
|
+
this.comments.push({
|
|
561
|
+
kind: "line",
|
|
562
|
+
marker: "#",
|
|
563
|
+
text: this.input.slice(e, this.pos),
|
|
564
|
+
start: e,
|
|
565
|
+
end: this.pos,
|
|
566
|
+
line: t,
|
|
567
|
+
col: n
|
|
568
|
+
});
|
|
569
|
+
continue;
|
|
570
|
+
}
|
|
571
|
+
if (e === "/") {
|
|
572
|
+
let e = this.input[this.pos + 1] ?? "";
|
|
573
|
+
if (e === "/") {
|
|
574
|
+
let e = this.pos, t = this.line, n = this.col;
|
|
575
|
+
for (this._advance(), this._advance(); !this._eof() && this._ch() !== "\n";) this._advance();
|
|
576
|
+
this.comments.push({
|
|
577
|
+
kind: "line",
|
|
578
|
+
marker: "//",
|
|
579
|
+
text: this.input.slice(e, this.pos),
|
|
580
|
+
start: e,
|
|
581
|
+
end: this.pos,
|
|
582
|
+
line: t,
|
|
583
|
+
col: n
|
|
584
|
+
});
|
|
585
|
+
continue;
|
|
586
|
+
}
|
|
587
|
+
if (e === "*") {
|
|
588
|
+
let e = this.pos, t = this.line, n = this.col;
|
|
589
|
+
this._advance(), this._advance(), this._skipBlockCommentStar(), this.comments.push({
|
|
590
|
+
kind: "block",
|
|
591
|
+
marker: "/*",
|
|
592
|
+
text: this.input.slice(e, this.pos),
|
|
593
|
+
start: e,
|
|
594
|
+
end: this.pos,
|
|
595
|
+
line: t,
|
|
596
|
+
col: n
|
|
597
|
+
});
|
|
598
|
+
continue;
|
|
599
|
+
}
|
|
600
|
+
let t = this.pos, n = this.line, r = this.col;
|
|
601
|
+
this._advance(), this._skipBlockCommentSlash(), this.comments.push({
|
|
602
|
+
kind: "block",
|
|
603
|
+
marker: "/",
|
|
604
|
+
text: this.input.slice(t, this.pos),
|
|
605
|
+
start: t,
|
|
606
|
+
end: this.pos,
|
|
607
|
+
line: n,
|
|
608
|
+
col: r
|
|
609
|
+
});
|
|
610
|
+
continue;
|
|
611
|
+
}
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
_skipByteStringComment(e) {
|
|
616
|
+
let t = this._ch();
|
|
617
|
+
if (t === "/") {
|
|
618
|
+
let t = this.input[this.pos + 1] ?? "";
|
|
619
|
+
if (t === "/") {
|
|
620
|
+
for (this._advance(), this._advance(); !this._eof() && this._ch() !== "\n";) {
|
|
621
|
+
if (this._ch() === "\\") {
|
|
622
|
+
this._advance(), !this._eof() && this._ch() !== "\n" && this._advance();
|
|
623
|
+
continue;
|
|
624
|
+
}
|
|
625
|
+
if (this._ch() === e) break;
|
|
626
|
+
this._advance();
|
|
627
|
+
}
|
|
628
|
+
return !0;
|
|
629
|
+
}
|
|
630
|
+
return t === "*" ? (this._advance(), this._advance(), this._skipBlockCommentStar(), !0) : (this._advance(), this._skipBlockCommentSlash(), !0);
|
|
631
|
+
}
|
|
632
|
+
if (t === "#") {
|
|
633
|
+
for (; !this._eof() && this._ch() !== "\n";) {
|
|
634
|
+
if (this._ch() === "\\") {
|
|
635
|
+
this._advance(), !this._eof() && this._ch() !== "\n" && this._advance();
|
|
636
|
+
continue;
|
|
637
|
+
}
|
|
638
|
+
if (this._ch() === e) break;
|
|
639
|
+
this._advance();
|
|
640
|
+
}
|
|
641
|
+
return !0;
|
|
642
|
+
}
|
|
643
|
+
return !1;
|
|
644
|
+
}
|
|
645
|
+
_skipRawComment(e, t, n, r, i) {
|
|
646
|
+
let a = e[t];
|
|
647
|
+
if (a === "/") {
|
|
648
|
+
if (t++, e[t] === "/") {
|
|
649
|
+
for (t++; t < e.length && e[t] !== "\n";) t++;
|
|
650
|
+
return t;
|
|
651
|
+
}
|
|
652
|
+
if (e[t] === "*") {
|
|
653
|
+
for (t++; t < e.length;) {
|
|
654
|
+
if (e[t] === "*" && e[t + 1] === "/") return t + 2;
|
|
655
|
+
t++;
|
|
656
|
+
}
|
|
657
|
+
return t;
|
|
658
|
+
}
|
|
659
|
+
for (; t < e.length && e[t] !== "/";) t++;
|
|
660
|
+
if (t >= e.length) throw SyntaxError(`EDN parse error at line ${r}, column ${i}: unterminated block comment in ${n}`);
|
|
661
|
+
return t + 1;
|
|
662
|
+
}
|
|
663
|
+
if (a === "#") {
|
|
664
|
+
for (; t < e.length && e[t] !== "\n";) t++;
|
|
665
|
+
return t;
|
|
666
|
+
}
|
|
667
|
+
return -1;
|
|
668
|
+
}
|
|
669
|
+
_skipBlockCommentSlash() {
|
|
670
|
+
let e = this.line, t = this.col;
|
|
671
|
+
for (; !this._eof();) {
|
|
672
|
+
if (this._ch() === "\\") {
|
|
673
|
+
this._advance(), this._eof() || this._advance();
|
|
674
|
+
continue;
|
|
675
|
+
}
|
|
676
|
+
if (this._ch() === "/") break;
|
|
677
|
+
this._advance();
|
|
678
|
+
}
|
|
679
|
+
this._eof() && this._fail("unterminated block comment", e, t), this._advance();
|
|
680
|
+
}
|
|
681
|
+
_skipBlockCommentStar() {
|
|
682
|
+
let e = this.line, t = this.col;
|
|
683
|
+
for (; !this._eof();) {
|
|
684
|
+
if (this._ch() === "*" && (this.input[this.pos + 1] ?? "") === "/") {
|
|
685
|
+
this._advance(), this._advance();
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
this._advance();
|
|
689
|
+
}
|
|
690
|
+
this._fail("unterminated block comment", e, t);
|
|
691
|
+
}
|
|
692
|
+
_readStringContent(e) {
|
|
693
|
+
this._advance();
|
|
694
|
+
let t = "";
|
|
695
|
+
for (; !this._eof() && this._ch() !== e;) {
|
|
696
|
+
let n = this._ch();
|
|
697
|
+
if (n === "\r") {
|
|
698
|
+
this._advance();
|
|
699
|
+
continue;
|
|
700
|
+
}
|
|
701
|
+
let r = n.codePointAt(0);
|
|
702
|
+
if ((r < 32 && r !== 10 || r === 127) && this._fail(`unescaped control character U+${r.toString(16).padStart(4, "0")} is not allowed in string literals`), n === "\\") {
|
|
703
|
+
this._advance();
|
|
704
|
+
let n = this.line, r = this.col, i = this._advance();
|
|
705
|
+
switch (i) {
|
|
706
|
+
case "n":
|
|
707
|
+
t += "\n";
|
|
708
|
+
break;
|
|
709
|
+
case "r":
|
|
710
|
+
t += "\r";
|
|
711
|
+
break;
|
|
712
|
+
case "t":
|
|
713
|
+
t += " ";
|
|
714
|
+
break;
|
|
715
|
+
case "b":
|
|
716
|
+
t += "\b";
|
|
717
|
+
break;
|
|
718
|
+
case "f":
|
|
719
|
+
t += "\f";
|
|
720
|
+
break;
|
|
721
|
+
case "\\":
|
|
722
|
+
t += "\\";
|
|
723
|
+
break;
|
|
724
|
+
case "u":
|
|
725
|
+
t += this._readUnicodeEscape(e);
|
|
726
|
+
break;
|
|
727
|
+
default:
|
|
728
|
+
if (i === e) {
|
|
729
|
+
t += i;
|
|
730
|
+
break;
|
|
731
|
+
}
|
|
732
|
+
if (i === "/") {
|
|
733
|
+
t += "/";
|
|
734
|
+
break;
|
|
735
|
+
}
|
|
736
|
+
this._fail(`invalid escape sequence \\${i} in ${e === "\"" ? "double" : "single"}-quoted string`, n, r);
|
|
737
|
+
}
|
|
738
|
+
} else t += this._advance();
|
|
739
|
+
}
|
|
740
|
+
return this._eof() && this._fail("unterminated string literal"), this._advance(), t;
|
|
741
|
+
}
|
|
742
|
+
_readUnicodeEscape(e) {
|
|
743
|
+
let t = this.line, n = this.col, r = (r) => {
|
|
744
|
+
e === "'" && r >= 32 && r <= 126 && r !== 92 && r !== 39 && this._fail(`\\u escape for printable ASCII U+${r.toString(16).padStart(4, "0")} is not allowed in single-quoted strings; write the character literally`, t, n);
|
|
745
|
+
};
|
|
746
|
+
if (!this._eof() && this._ch() === "{") {
|
|
747
|
+
this._advance();
|
|
748
|
+
let e = "";
|
|
749
|
+
for (; !this._eof() && this._ch() !== "}";) {
|
|
750
|
+
let r = this._ch();
|
|
751
|
+
/[0-9a-fA-F]/.test(r) || this._fail(`invalid character in \\u{} escape: ${JSON.stringify(r)}`, t, n), e += this._advance();
|
|
752
|
+
}
|
|
753
|
+
this._eof() && this._fail("unterminated \\u{} escape", t, n), this._advance(), e.length === 0 && this._fail("empty \\u{} escape", t, n);
|
|
754
|
+
let i = parseInt(e, 16);
|
|
755
|
+
return i > 1114111 && this._fail(`\\u{${e}} exceeds maximum Unicode code point U+10FFFF`, t, n), i >= 55296 && i <= 57343 && this._fail(`\\u{${e}} is a surrogate code point, which is not a valid Unicode scalar value`, t, n), r(i), String.fromCodePoint(i);
|
|
756
|
+
}
|
|
757
|
+
let i = "";
|
|
758
|
+
for (let e = 0; e < 4; e++) {
|
|
759
|
+
this._eof() && this._fail("truncated \\uXXXX escape", t, n);
|
|
760
|
+
let e = this._ch();
|
|
761
|
+
/[0-9a-fA-F]/.test(e) || this._fail(`invalid hex digit in \\uXXXX escape: ${JSON.stringify(e)}`, t, n), i += this._advance();
|
|
762
|
+
}
|
|
763
|
+
let a = parseInt(i, 16);
|
|
764
|
+
if (a >= 55296 && a <= 56319) {
|
|
765
|
+
(this._ch() !== "\\" || (this.input[this.pos + 1] ?? "") !== "u") && this._fail(`lone high surrogate \\u${i} must be followed by \\uDC00–\\uDFFF`, t, n), this._advance(), this._advance();
|
|
766
|
+
let e = this.line, r = this.col, o = "";
|
|
767
|
+
for (let t = 0; t < 4; t++) this._eof() && this._fail("truncated low-surrogate escape", e, r), o += this._advance();
|
|
768
|
+
let s = parseInt(o, 16);
|
|
769
|
+
return (s < 56320 || s > 57343) && this._fail(`\\u${i} (high surrogate) not followed by a valid low surrogate (got \\u${o})`, t, n), String.fromCodePoint(65536 + (a - 55296) * 1024 + (s - 56320));
|
|
770
|
+
}
|
|
771
|
+
return a >= 56320 && a <= 57343 && this._fail(`lone low surrogate \\u${i} is not valid`, t, n), r(a), String.fromCharCode(a);
|
|
772
|
+
}
|
|
773
|
+
_readRawStringContent() {
|
|
774
|
+
let e = this.line, t = this.col, n = 0;
|
|
775
|
+
for (; !this._eof() && this._ch() === "`";) this._advance(), n++;
|
|
776
|
+
!this._eof() && this._ch() === "\r" && this._advance(), !this._eof() && this._ch() === "\n" && this._advance();
|
|
777
|
+
let r = "";
|
|
778
|
+
for (; !this._eof();) {
|
|
779
|
+
let i = this._ch();
|
|
780
|
+
if (i === "\r") {
|
|
781
|
+
this._advance();
|
|
782
|
+
continue;
|
|
783
|
+
}
|
|
784
|
+
if (i === "`") {
|
|
785
|
+
let i = 0;
|
|
786
|
+
for (; !this._eof() && this._ch() === "`";) this._advance(), i++;
|
|
787
|
+
if (i >= n) return r += "`".repeat(i - n), r === "" && this._fail("raw string must not be empty (§2.5.3)", e, t), r;
|
|
788
|
+
r += "`".repeat(i);
|
|
789
|
+
} else {
|
|
790
|
+
let e = i.codePointAt(0);
|
|
791
|
+
e < 32 && e !== 10 && e !== 13 && this._fail(`raw string content must not contain control character U+${e.toString(16).toUpperCase().padStart(4, "0")} (§2.5.3)`, this.line, this.col), e === 127 && this._fail("raw string content must not contain DEL (U+007F) (§2.5.3)", this.line, this.col), r += this._advance();
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
this._fail("unterminated raw string literal", e, t);
|
|
795
|
+
}
|
|
796
|
+
_processRawHexContent(e, t, n) {
|
|
797
|
+
let r = "", i = !1, a = 0;
|
|
798
|
+
for (; a < e.length;) {
|
|
799
|
+
let o = e[a];
|
|
800
|
+
if (o === "\n" || o === " " || o === "\r") {
|
|
801
|
+
a++;
|
|
802
|
+
continue;
|
|
803
|
+
}
|
|
804
|
+
if (o === " ") throw SyntaxError(`EDN parse error at line ${t}, column ${n}: horizontal tab (HT) is not allowed inside h\`\` raw byte string literals (§5.3.3)`);
|
|
805
|
+
let s = this._skipRawComment(e, a, "h`` raw byte string", t, n);
|
|
806
|
+
if (s !== -1) {
|
|
807
|
+
a = s;
|
|
808
|
+
continue;
|
|
809
|
+
}
|
|
810
|
+
if (o === "." && e[a + 1] === "." && e[a + 2] === ".") {
|
|
811
|
+
for (a += 3; a < e.length && e[a] === ".";) a++;
|
|
812
|
+
r += "...", i = !0;
|
|
813
|
+
continue;
|
|
814
|
+
}
|
|
815
|
+
if (/[0-9a-fA-F]/.test(o)) {
|
|
816
|
+
r += o, a++;
|
|
817
|
+
continue;
|
|
818
|
+
}
|
|
819
|
+
throw SyntaxError(`EDN parse error at line ${t}, column ${n}: unexpected character ${JSON.stringify(o)} in h\`\` raw byte string`);
|
|
820
|
+
}
|
|
821
|
+
return {
|
|
822
|
+
value: r,
|
|
823
|
+
elided: i
|
|
824
|
+
};
|
|
825
|
+
}
|
|
826
|
+
_processRawB64Content(e, t, n) {
|
|
827
|
+
let r = "", i = 0;
|
|
828
|
+
for (; i < e.length;) {
|
|
829
|
+
let a = e[i];
|
|
830
|
+
if (a === "\n" || a === " " || a === "\r") {
|
|
831
|
+
i++;
|
|
832
|
+
continue;
|
|
833
|
+
}
|
|
834
|
+
if (a === " ") throw SyntaxError(`EDN parse error at line ${t}, column ${n}: horizontal tab (HT) is not allowed inside b64\`\` raw byte string literals (§5.3.4)`);
|
|
835
|
+
if (a === "#") {
|
|
836
|
+
for (; i < e.length && e[i] !== "\n";) i++;
|
|
837
|
+
continue;
|
|
838
|
+
}
|
|
839
|
+
r += a, i++;
|
|
840
|
+
}
|
|
841
|
+
return r;
|
|
842
|
+
}
|
|
843
|
+
_processRawB32Content(e, t, n) {
|
|
844
|
+
let r = "", i = 0;
|
|
845
|
+
for (; i < e.length;) {
|
|
846
|
+
let a = e[i];
|
|
847
|
+
if (a === "\n" || a === " " || a === "\r") {
|
|
848
|
+
i++;
|
|
849
|
+
continue;
|
|
850
|
+
}
|
|
851
|
+
if (a === " ") throw SyntaxError(`EDN parse error at line ${t}, column ${n}: horizontal tab (HT) is not allowed inside b32\`\`/h32\`\` raw byte string literals (§5.2)`);
|
|
852
|
+
let o = this._skipRawComment(e, i, "b32``/h32`` raw byte string", t, n);
|
|
853
|
+
if (o !== -1) {
|
|
854
|
+
i = o;
|
|
855
|
+
continue;
|
|
856
|
+
}
|
|
857
|
+
r += a, i++;
|
|
858
|
+
}
|
|
859
|
+
return r;
|
|
860
|
+
}
|
|
861
|
+
_readByteContent(e) {
|
|
862
|
+
this._advance();
|
|
863
|
+
let t = "";
|
|
864
|
+
for (; !this._eof() && this._ch() !== e;) {
|
|
865
|
+
let n = this._ch();
|
|
866
|
+
if (n === "\n" || n === " ") {
|
|
867
|
+
this._advance();
|
|
868
|
+
continue;
|
|
869
|
+
}
|
|
870
|
+
if (n === "\r") {
|
|
871
|
+
this._advance();
|
|
872
|
+
continue;
|
|
873
|
+
}
|
|
874
|
+
if (n === " " && this._fail("horizontal tab (HT) is not allowed inside byte string literals (§5.2.2)", this.line, this.col), n === "#") {
|
|
875
|
+
for (; !this._eof() && this._ch() !== "\n";) {
|
|
876
|
+
if (this._ch() === "\\") {
|
|
877
|
+
this._advance(), !this._eof() && this._ch() !== "\n" && this._advance();
|
|
878
|
+
continue;
|
|
879
|
+
}
|
|
880
|
+
if (this._ch() === e) break;
|
|
881
|
+
this._advance();
|
|
882
|
+
}
|
|
883
|
+
continue;
|
|
884
|
+
}
|
|
885
|
+
t += this._advance();
|
|
886
|
+
}
|
|
887
|
+
return this._eof() && this._fail("unterminated byte string literal"), this._advance(), t;
|
|
888
|
+
}
|
|
889
|
+
_readB32Content(e) {
|
|
890
|
+
this._advance();
|
|
891
|
+
let t = "";
|
|
892
|
+
for (; !this._eof() && this._ch() !== e;) {
|
|
893
|
+
let n = this._ch();
|
|
894
|
+
if (n === "\n" || n === " " || n === "\r") {
|
|
895
|
+
this._advance();
|
|
896
|
+
continue;
|
|
897
|
+
}
|
|
898
|
+
n === " " && this._fail("horizontal tab (HT) is not allowed inside byte string literals (§5.2)", this.line, this.col), !this._skipByteStringComment(e) && (t += this._advance());
|
|
899
|
+
}
|
|
900
|
+
return this._eof() && this._fail("unterminated byte string literal"), this._advance(), t;
|
|
901
|
+
}
|
|
902
|
+
_readHexByteContentElisionAware(e) {
|
|
903
|
+
this._advance();
|
|
904
|
+
let t = "", n = !1;
|
|
905
|
+
for (; !this._eof() && this._ch() !== e;) {
|
|
906
|
+
let r = this._ch();
|
|
907
|
+
if (r === "\n" || r === " " || r === "\r") {
|
|
908
|
+
this._advance();
|
|
909
|
+
continue;
|
|
910
|
+
}
|
|
911
|
+
if (r === " " && this._fail("horizontal tab (HT) is not allowed inside hex byte string literals (§5.2.1)", this.line, this.col), !this._skipByteStringComment(e)) {
|
|
912
|
+
if (r === "." && (this.input[this.pos + 1] ?? "") === "." && (this.input[this.pos + 2] ?? "") === ".") {
|
|
913
|
+
for (this._advance(), this._advance(), this._advance(); !this._eof() && this._ch() === ".";) this._advance();
|
|
914
|
+
t.endsWith("...") || (t += "..."), n = !0;
|
|
915
|
+
continue;
|
|
916
|
+
}
|
|
917
|
+
if (/[0-9a-fA-F]/.test(r)) {
|
|
918
|
+
t += this._advance();
|
|
919
|
+
continue;
|
|
920
|
+
}
|
|
921
|
+
this._fail(`unexpected character ${JSON.stringify(r)} in hex byte string`);
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
return this._eof() && this._fail("unterminated hex byte string literal"), this._advance(), {
|
|
925
|
+
value: t,
|
|
926
|
+
elided: n
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
_readNext() {
|
|
930
|
+
this._skipWS();
|
|
931
|
+
let e = this.pos;
|
|
932
|
+
return {
|
|
933
|
+
...this._readNextCore(),
|
|
934
|
+
raw: this.input.slice(e, this.pos),
|
|
935
|
+
offset: e,
|
|
936
|
+
endOffset: this.pos
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
_readNextCore() {
|
|
940
|
+
let e = this.line, t = this.col;
|
|
941
|
+
if (this._eof()) return {
|
|
942
|
+
type: "EOF",
|
|
943
|
+
value: "",
|
|
944
|
+
line: e,
|
|
945
|
+
col: t
|
|
946
|
+
};
|
|
947
|
+
let n = this._ch();
|
|
948
|
+
switch (n) {
|
|
949
|
+
case "[": return this._advance(), {
|
|
950
|
+
type: "LBRACKET",
|
|
951
|
+
value: "[",
|
|
952
|
+
line: e,
|
|
953
|
+
col: t
|
|
954
|
+
};
|
|
955
|
+
case "]": return this._advance(), {
|
|
956
|
+
type: "RBRACKET",
|
|
957
|
+
value: "]",
|
|
958
|
+
line: e,
|
|
959
|
+
col: t
|
|
960
|
+
};
|
|
961
|
+
case "{": return this._advance(), {
|
|
962
|
+
type: "LBRACE",
|
|
963
|
+
value: "{",
|
|
964
|
+
line: e,
|
|
965
|
+
col: t
|
|
966
|
+
};
|
|
967
|
+
case "}": return this._advance(), {
|
|
968
|
+
type: "RBRACE",
|
|
969
|
+
value: "}",
|
|
970
|
+
line: e,
|
|
971
|
+
col: t
|
|
972
|
+
};
|
|
973
|
+
case "(": return this._advance(), {
|
|
974
|
+
type: "LPAREN",
|
|
975
|
+
value: "(",
|
|
976
|
+
line: e,
|
|
977
|
+
col: t
|
|
978
|
+
};
|
|
979
|
+
case ")": return this._advance(), {
|
|
980
|
+
type: "RPAREN",
|
|
981
|
+
value: ")",
|
|
982
|
+
line: e,
|
|
983
|
+
col: t
|
|
984
|
+
};
|
|
985
|
+
case ":": return this._advance(), {
|
|
986
|
+
type: "COLON",
|
|
987
|
+
value: ":",
|
|
988
|
+
line: e,
|
|
989
|
+
col: t
|
|
990
|
+
};
|
|
991
|
+
case ",": return this._advance(), {
|
|
992
|
+
type: "COMMA",
|
|
993
|
+
value: ",",
|
|
994
|
+
line: e,
|
|
995
|
+
col: t
|
|
996
|
+
};
|
|
997
|
+
case "<":
|
|
998
|
+
if ((this.input[this.pos + 1] ?? "") === "<") return this._advance(), this._advance(), {
|
|
999
|
+
type: "LT_LT",
|
|
1000
|
+
value: "<<",
|
|
1001
|
+
line: e,
|
|
1002
|
+
col: t
|
|
1003
|
+
};
|
|
1004
|
+
this._fail("unexpected character '<'", e, t);
|
|
1005
|
+
case ">":
|
|
1006
|
+
if ((this.input[this.pos + 1] ?? "") === ">") return this._advance(), this._advance(), {
|
|
1007
|
+
type: "GT_GT",
|
|
1008
|
+
value: ">>",
|
|
1009
|
+
line: e,
|
|
1010
|
+
col: t
|
|
1011
|
+
};
|
|
1012
|
+
this._fail("unexpected character '>'", e, t);
|
|
1013
|
+
case "+": {
|
|
1014
|
+
let n = this.input.slice(this.pos + 1);
|
|
1015
|
+
if (n.startsWith("Infinity")) {
|
|
1016
|
+
let r = n[8] ?? "", i = r === "_" && /[0-3i]/.test(n[9] ?? "") && !/[a-zA-Z0-9_]/.test(n[10] ?? "");
|
|
1017
|
+
if (!/[a-zA-Z0-9_]/.test(r) || i) {
|
|
1018
|
+
this._advance();
|
|
1019
|
+
for (let e = 0; e < 8; e++) this._advance();
|
|
1020
|
+
let n = "Infinity";
|
|
1021
|
+
return i && (n += this._advance() + this._advance()), {
|
|
1022
|
+
type: "FLOAT",
|
|
1023
|
+
value: n,
|
|
1024
|
+
line: e,
|
|
1025
|
+
col: t
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
let r = n[0] ?? "";
|
|
1030
|
+
return r >= "0" && r <= "9" || r === "." ? (this._advance(), this._readNumber(e, t)) : (this._advance(), {
|
|
1031
|
+
type: "PLUS",
|
|
1032
|
+
value: "+",
|
|
1033
|
+
line: e,
|
|
1034
|
+
col: t
|
|
1035
|
+
});
|
|
1036
|
+
}
|
|
1037
|
+
case "`": return {
|
|
1038
|
+
type: "RAWSTRING",
|
|
1039
|
+
value: this._readRawStringContent(),
|
|
1040
|
+
line: e,
|
|
1041
|
+
col: t
|
|
1042
|
+
};
|
|
1043
|
+
case "\"": {
|
|
1044
|
+
let n = this._readStringContent("\"");
|
|
1045
|
+
return n === "" && this._ch() === "_" ? (this._advance(), {
|
|
1046
|
+
type: "EMPTY_INDEF_TEXT",
|
|
1047
|
+
value: "",
|
|
1048
|
+
line: e,
|
|
1049
|
+
col: t
|
|
1050
|
+
}) : {
|
|
1051
|
+
type: "TSTR",
|
|
1052
|
+
value: n,
|
|
1053
|
+
line: e,
|
|
1054
|
+
col: t
|
|
1055
|
+
};
|
|
1056
|
+
}
|
|
1057
|
+
case "'": {
|
|
1058
|
+
if ((this.input[this.pos + 1] ?? "") === "'" && (this.input[this.pos + 2] ?? "") === "_") return this._advance(), this._advance(), this._advance(), {
|
|
1059
|
+
type: "EMPTY_INDEF_BYTES",
|
|
1060
|
+
value: "",
|
|
1061
|
+
line: e,
|
|
1062
|
+
col: t
|
|
1063
|
+
};
|
|
1064
|
+
let n = this._readStringContent("'"), r = new TextEncoder().encode(n);
|
|
1065
|
+
return {
|
|
1066
|
+
type: "SQSTR",
|
|
1067
|
+
value: Array.from(r, (e) => e.toString(16).padStart(2, "0")).join(""),
|
|
1068
|
+
line: e,
|
|
1069
|
+
col: t
|
|
1070
|
+
};
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
if (n === "-") {
|
|
1074
|
+
let n = this.input.slice(this.pos + 1);
|
|
1075
|
+
if (n.startsWith("Infinity")) {
|
|
1076
|
+
let r = n[8] ?? "", i = r === "_" && /[0-3i]/.test(n[9] ?? "") && !/[a-zA-Z0-9_]/.test(n[10] ?? "");
|
|
1077
|
+
if (!/[a-zA-Z0-9_]/.test(r) || i) {
|
|
1078
|
+
this._advance();
|
|
1079
|
+
for (let e = 0; e < 8; e++) this._advance();
|
|
1080
|
+
let n = "-Infinity";
|
|
1081
|
+
return i && (n += this._advance() + this._advance()), {
|
|
1082
|
+
type: "FLOAT",
|
|
1083
|
+
value: n,
|
|
1084
|
+
line: e,
|
|
1085
|
+
col: t
|
|
1086
|
+
};
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
return this._readNumber(e, t);
|
|
1090
|
+
}
|
|
1091
|
+
if (n === "+") {
|
|
1092
|
+
let n = this.input.slice(this.pos + 1);
|
|
1093
|
+
if (n.startsWith("Infinity")) {
|
|
1094
|
+
let r = n[8] ?? "", i = r === "_" && /[0-3i]/.test(n[9] ?? "") && !/[a-zA-Z0-9_]/.test(n[10] ?? "");
|
|
1095
|
+
if (!/[a-zA-Z0-9_]/.test(r) || i) {
|
|
1096
|
+
this._advance();
|
|
1097
|
+
for (let e = 0; e < 8; e++) this._advance();
|
|
1098
|
+
let n = "Infinity";
|
|
1099
|
+
return i && (n += this._advance() + this._advance()), {
|
|
1100
|
+
type: "FLOAT",
|
|
1101
|
+
value: n,
|
|
1102
|
+
line: e,
|
|
1103
|
+
col: t
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
return this._advance(), this._readNumber(e, t);
|
|
1108
|
+
}
|
|
1109
|
+
if (n >= "0" && n <= "9" || n === "." && /[0-9]/.test(this.input[this.pos + 1] ?? "")) return this._readNumber(e, t);
|
|
1110
|
+
if (/[a-zA-Z_]/.test(n)) return this._readIdent(e, t);
|
|
1111
|
+
if (n === ".") {
|
|
1112
|
+
if ((this.input[this.pos + 1] ?? "") === "." && (this.input[this.pos + 2] ?? "") === ".") {
|
|
1113
|
+
for (this._advance(), this._advance(), this._advance(); !this._eof() && this._ch() === ".";) this._advance();
|
|
1114
|
+
return {
|
|
1115
|
+
type: "ELLIPSIS",
|
|
1116
|
+
value: "...",
|
|
1117
|
+
line: e,
|
|
1118
|
+
col: t
|
|
1119
|
+
};
|
|
1120
|
+
}
|
|
1121
|
+
this._fail("unexpected character '.'", e, t);
|
|
1122
|
+
}
|
|
1123
|
+
this._fail(`unexpected character ${JSON.stringify(n)}`, e, t);
|
|
1124
|
+
}
|
|
1125
|
+
_readNumber(e, t) {
|
|
1126
|
+
let n = "";
|
|
1127
|
+
if (this._ch() === "-" && (n += this._advance()), this._ch() === "0") {
|
|
1128
|
+
let r = this.input[this.pos + 1] ?? "";
|
|
1129
|
+
if (r === "x" || r === "X") {
|
|
1130
|
+
n += this._advance() + this._advance();
|
|
1131
|
+
let r = n.length;
|
|
1132
|
+
for (; !this._eof() && /[0-9a-fA-F]/.test(this._ch());) n += this._advance();
|
|
1133
|
+
let i = n.length > r, a = !1, o = !1;
|
|
1134
|
+
if (!this._eof() && this._ch() === ".") {
|
|
1135
|
+
a = !0, n += this._advance();
|
|
1136
|
+
let e = n.length;
|
|
1137
|
+
for (; !this._eof() && /[0-9a-fA-F]/.test(this._ch());) n += this._advance();
|
|
1138
|
+
o = n.length > e;
|
|
1139
|
+
}
|
|
1140
|
+
if (!this._eof() && (this._ch() === "p" || this._ch() === "P")) {
|
|
1141
|
+
a = !0, !i && !o && this._fail(`hex float has no mantissa digits: ${n}`, e, t), n += this._advance(), !this._eof() && (this._ch() === "+" || this._ch() === "-") && (n += this._advance());
|
|
1142
|
+
let r = n.length;
|
|
1143
|
+
for (; !this._eof() && this._ch() >= "0" && this._ch() <= "9";) n += this._advance();
|
|
1144
|
+
n.length === r && this._fail(`hex float missing exponent digits: ${n}`, e, t);
|
|
1145
|
+
} else a && this._fail(`hex float missing 'p' exponent: ${n}`, e, t);
|
|
1146
|
+
if (a) {
|
|
1147
|
+
if (this._ch() === "_") {
|
|
1148
|
+
let e = this.input[this.pos + 1] ?? "", t = this.input[this.pos + 2] ?? "";
|
|
1149
|
+
(e === "0" || e === "1" || e === "2" || e === "3" || e === "i") && !/[0-9a-zA-Z_]/.test(t) && (n += this._advance() + this._advance());
|
|
1150
|
+
}
|
|
1151
|
+
return {
|
|
1152
|
+
type: "FLOAT",
|
|
1153
|
+
value: n,
|
|
1154
|
+
line: e,
|
|
1155
|
+
col: t
|
|
1156
|
+
};
|
|
1157
|
+
}
|
|
1158
|
+
return {
|
|
1159
|
+
type: "INTEGER",
|
|
1160
|
+
value: n,
|
|
1161
|
+
line: e,
|
|
1162
|
+
col: t
|
|
1163
|
+
};
|
|
1164
|
+
}
|
|
1165
|
+
if (r === "o" || r === "O") {
|
|
1166
|
+
for (n += this._advance() + this._advance(); !this._eof() && this._ch() >= "0" && this._ch() <= "7";) n += this._advance();
|
|
1167
|
+
return {
|
|
1168
|
+
type: "INTEGER",
|
|
1169
|
+
value: n,
|
|
1170
|
+
line: e,
|
|
1171
|
+
col: t
|
|
1172
|
+
};
|
|
1173
|
+
}
|
|
1174
|
+
if (r === "b" || r === "B") {
|
|
1175
|
+
for (n += this._advance() + this._advance(); !this._eof() && (this._ch() === "0" || this._ch() === "1");) n += this._advance();
|
|
1176
|
+
return {
|
|
1177
|
+
type: "INTEGER",
|
|
1178
|
+
value: n,
|
|
1179
|
+
line: e,
|
|
1180
|
+
col: t
|
|
1181
|
+
};
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
for (; !this._eof() && this._ch() >= "0" && this._ch() <= "9";) n += this._advance();
|
|
1185
|
+
let r = !1;
|
|
1186
|
+
if (!this._eof() && this._ch() === ".") for (r = !0, n += this._advance(); !this._eof() && this._ch() >= "0" && this._ch() <= "9";) n += this._advance();
|
|
1187
|
+
if (!this._eof() && (this._ch() === "e" || this._ch() === "E")) {
|
|
1188
|
+
r = !0, n += this._advance(), !this._eof() && (this._ch() === "+" || this._ch() === "-") && (n += this._advance());
|
|
1189
|
+
let i = n.length;
|
|
1190
|
+
for (; !this._eof() && this._ch() >= "0" && this._ch() <= "9";) n += this._advance();
|
|
1191
|
+
n.length === i && this._fail(`float exponent has no digits: ${JSON.stringify(n)}`, e, t);
|
|
1192
|
+
}
|
|
1193
|
+
if (this._ch() === "_") {
|
|
1194
|
+
let e = this.input[this.pos + 1] ?? "", t = this.input[this.pos + 2] ?? "";
|
|
1195
|
+
(e === "0" || e === "1" || e === "2" || e === "3" || e === "i") && !/[0-9a-zA-Z_]/.test(t) && (n += this._advance() + this._advance());
|
|
1196
|
+
}
|
|
1197
|
+
return {
|
|
1198
|
+
type: r ? "FLOAT" : "INTEGER",
|
|
1199
|
+
value: n,
|
|
1200
|
+
line: e,
|
|
1201
|
+
col: t
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
_readIdent(e, t) {
|
|
1205
|
+
let n = "";
|
|
1206
|
+
for (; !this._eof() && /[a-zA-Z0-9_]/.test(this._ch());) n += this._advance();
|
|
1207
|
+
switch (n) {
|
|
1208
|
+
case "true": return {
|
|
1209
|
+
type: "TRUE",
|
|
1210
|
+
value: n,
|
|
1211
|
+
line: e,
|
|
1212
|
+
col: t
|
|
1213
|
+
};
|
|
1214
|
+
case "false": return {
|
|
1215
|
+
type: "FALSE",
|
|
1216
|
+
value: n,
|
|
1217
|
+
line: e,
|
|
1218
|
+
col: t
|
|
1219
|
+
};
|
|
1220
|
+
case "null": return {
|
|
1221
|
+
type: "NULL",
|
|
1222
|
+
value: n,
|
|
1223
|
+
line: e,
|
|
1224
|
+
col: t
|
|
1225
|
+
};
|
|
1226
|
+
case "undefined": return {
|
|
1227
|
+
type: "UNDEFINED",
|
|
1228
|
+
value: n,
|
|
1229
|
+
line: e,
|
|
1230
|
+
col: t
|
|
1231
|
+
};
|
|
1232
|
+
case "NaN":
|
|
1233
|
+
case "NaN_0":
|
|
1234
|
+
case "NaN_1":
|
|
1235
|
+
case "NaN_2":
|
|
1236
|
+
case "NaN_3":
|
|
1237
|
+
case "NaN_i":
|
|
1238
|
+
case "Infinity":
|
|
1239
|
+
case "Infinity_0":
|
|
1240
|
+
case "Infinity_1":
|
|
1241
|
+
case "Infinity_2":
|
|
1242
|
+
case "Infinity_3":
|
|
1243
|
+
case "Infinity_i": return {
|
|
1244
|
+
type: "FLOAT",
|
|
1245
|
+
value: n,
|
|
1246
|
+
line: e,
|
|
1247
|
+
col: t
|
|
1248
|
+
};
|
|
1249
|
+
case "simple": return {
|
|
1250
|
+
type: "SIMPLE",
|
|
1251
|
+
value: n,
|
|
1252
|
+
line: e,
|
|
1253
|
+
col: t
|
|
1254
|
+
};
|
|
1255
|
+
case "_": return {
|
|
1256
|
+
type: "UNDERSCORE",
|
|
1257
|
+
value: "_",
|
|
1258
|
+
line: e,
|
|
1259
|
+
col: t
|
|
1260
|
+
};
|
|
1261
|
+
case "_0": return {
|
|
1262
|
+
type: "ENCODING_INDICATOR",
|
|
1263
|
+
value: "0",
|
|
1264
|
+
line: e,
|
|
1265
|
+
col: t
|
|
1266
|
+
};
|
|
1267
|
+
case "_1": return {
|
|
1268
|
+
type: "ENCODING_INDICATOR",
|
|
1269
|
+
value: "1",
|
|
1270
|
+
line: e,
|
|
1271
|
+
col: t
|
|
1272
|
+
};
|
|
1273
|
+
case "_2": return {
|
|
1274
|
+
type: "ENCODING_INDICATOR",
|
|
1275
|
+
value: "2",
|
|
1276
|
+
line: e,
|
|
1277
|
+
col: t
|
|
1278
|
+
};
|
|
1279
|
+
case "_3": return {
|
|
1280
|
+
type: "ENCODING_INDICATOR",
|
|
1281
|
+
value: "3",
|
|
1282
|
+
line: e,
|
|
1283
|
+
col: t
|
|
1284
|
+
};
|
|
1285
|
+
case "_i": return {
|
|
1286
|
+
type: "ENCODING_INDICATOR",
|
|
1287
|
+
value: "i",
|
|
1288
|
+
line: e,
|
|
1289
|
+
col: t
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
let r = n[0] ?? "", i = r >= "a" && r <= "z";
|
|
1293
|
+
if (i || r >= "A" && r <= "Z") {
|
|
1294
|
+
let r = n.slice(1);
|
|
1295
|
+
if (i ? /^[a-z0-9]*$/.test(r) : /^[A-Z0-9]*$/.test(r)) {
|
|
1296
|
+
for (; !this._eof();) {
|
|
1297
|
+
let e = this._ch();
|
|
1298
|
+
if (!(i ? e >= "a" && e <= "z" || e >= "0" && e <= "9" || e === "-" : e >= "A" && e <= "Z" || e >= "0" && e <= "9" || e === "-")) break;
|
|
1299
|
+
n += this._advance();
|
|
1300
|
+
}
|
|
1301
|
+
let r = this._ch();
|
|
1302
|
+
if (r === "\"" && this._fail(`"${n}" prefix requires single quotes or backticks, not double quotes`, e, t), r === "'") switch (n) {
|
|
1303
|
+
case "h": {
|
|
1304
|
+
let { value: n, elided: i } = this._readHexByteContentElisionAware(r);
|
|
1305
|
+
return {
|
|
1306
|
+
type: i ? "BYTES_HEX_ELIDED" : "BYTES_HEX",
|
|
1307
|
+
value: n,
|
|
1308
|
+
line: e,
|
|
1309
|
+
col: t
|
|
1310
|
+
};
|
|
1311
|
+
}
|
|
1312
|
+
case "b64": return {
|
|
1313
|
+
type: "BYTES_B64",
|
|
1314
|
+
value: this._readByteContent(r),
|
|
1315
|
+
line: e,
|
|
1316
|
+
col: t
|
|
1317
|
+
};
|
|
1318
|
+
case "b32": return {
|
|
1319
|
+
type: "BYTES_B32",
|
|
1320
|
+
value: this._readB32Content(r),
|
|
1321
|
+
line: e,
|
|
1322
|
+
col: t
|
|
1323
|
+
};
|
|
1324
|
+
case "h32": return {
|
|
1325
|
+
type: "BYTES_H32",
|
|
1326
|
+
value: this._readB32Content(r),
|
|
1327
|
+
line: e,
|
|
1328
|
+
col: t
|
|
1329
|
+
};
|
|
1330
|
+
default: return {
|
|
1331
|
+
type: "APP_STRING",
|
|
1332
|
+
appPrefix: n,
|
|
1333
|
+
value: this._readStringContent(r),
|
|
1334
|
+
line: e,
|
|
1335
|
+
col: t
|
|
1336
|
+
};
|
|
1337
|
+
}
|
|
1338
|
+
if (r === "`") {
|
|
1339
|
+
let r = this._readRawStringContent();
|
|
1340
|
+
switch (n) {
|
|
1341
|
+
case "h": {
|
|
1342
|
+
let { value: n, elided: i } = this._processRawHexContent(r, e, t);
|
|
1343
|
+
return {
|
|
1344
|
+
type: i ? "BYTES_HEX_ELIDED" : "BYTES_HEX",
|
|
1345
|
+
value: n,
|
|
1346
|
+
line: e,
|
|
1347
|
+
col: t
|
|
1348
|
+
};
|
|
1349
|
+
}
|
|
1350
|
+
case "b64": return {
|
|
1351
|
+
type: "BYTES_B64",
|
|
1352
|
+
value: this._processRawB64Content(r, e, t),
|
|
1353
|
+
line: e,
|
|
1354
|
+
col: t
|
|
1355
|
+
};
|
|
1356
|
+
case "b32": return {
|
|
1357
|
+
type: "BYTES_B32",
|
|
1358
|
+
value: this._processRawB32Content(r, e, t),
|
|
1359
|
+
line: e,
|
|
1360
|
+
col: t
|
|
1361
|
+
};
|
|
1362
|
+
case "h32": return {
|
|
1363
|
+
type: "BYTES_H32",
|
|
1364
|
+
value: this._processRawB32Content(r, e, t),
|
|
1365
|
+
line: e,
|
|
1366
|
+
col: t
|
|
1367
|
+
};
|
|
1368
|
+
default: return {
|
|
1369
|
+
type: "APP_STRING",
|
|
1370
|
+
appPrefix: n,
|
|
1371
|
+
value: r,
|
|
1372
|
+
line: e,
|
|
1373
|
+
col: t
|
|
1374
|
+
};
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
if (r === "<" && (this.input[this.pos + 1] ?? "") === "<") return this._advance(), this._advance(), {
|
|
1378
|
+
type: "APP_SEQUENCE",
|
|
1379
|
+
appPrefix: n,
|
|
1380
|
+
value: "",
|
|
1381
|
+
line: e,
|
|
1382
|
+
col: t
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
this._fail(`unknown identifier ${JSON.stringify(n)}`, e, t);
|
|
1387
|
+
}
|
|
1388
|
+
}, w = class extends d {
|
|
1389
|
+
indefiniteLength = !1;
|
|
1390
|
+
value;
|
|
1391
|
+
ednEncoding;
|
|
1392
|
+
encodingWidth;
|
|
1393
|
+
ednSource;
|
|
1394
|
+
constructor(e, t) {
|
|
1395
|
+
super(), this.value = e, this.ednEncoding = t?.ednEncoding ?? "hex", this.encodingWidth = t?.encodingWidth, this.ednSource = t?.ednSource;
|
|
1396
|
+
}
|
|
1397
|
+
_toCBOR(e) {
|
|
1398
|
+
return v([_(2, BigInt(this.value.length), this.encodingWidth), this.value]);
|
|
1399
|
+
}
|
|
1400
|
+
_toEDN(e, t) {
|
|
1401
|
+
let n = this.encodingWidth === void 0 ? "" : `_${this.encodingWidth}`;
|
|
1402
|
+
if (e?.preserveByteString && this.ednSource !== void 0) return this.ednSource + n;
|
|
1403
|
+
let r = e?.bstrEncoding ?? this.ednEncoding;
|
|
1404
|
+
return ye(this.value, r, e?.sqstr) + n;
|
|
1405
|
+
}
|
|
1406
|
+
_toJS(e) {
|
|
1407
|
+
return this.value;
|
|
1408
|
+
}
|
|
1409
|
+
}, Me = class extends d {
|
|
1410
|
+
indefiniteLength = !0;
|
|
1411
|
+
chunks;
|
|
1412
|
+
constructor(e) {
|
|
1413
|
+
super(), this.chunks = e;
|
|
1414
|
+
}
|
|
1415
|
+
_toCBOR(e) {
|
|
1416
|
+
let t = [new Uint8Array([95])];
|
|
1417
|
+
for (let n of this.chunks) t.push(n._toCBOR(e));
|
|
1418
|
+
return t.push(new Uint8Array([255])), v(t);
|
|
1419
|
+
}
|
|
1420
|
+
_toEDN(e, t) {
|
|
1421
|
+
return this.chunks.length === 0 ? "''_" : `(_ ${this.chunks.map((t) => t._toEDN(e, 0)).join(", ")})`;
|
|
1422
|
+
}
|
|
1423
|
+
_toHexDump(e, t) {
|
|
1424
|
+
let n = (e) => e.toString(16).toUpperCase().padStart(2, "0"), r = [{
|
|
1425
|
+
depth: e,
|
|
1426
|
+
hex: n(95),
|
|
1427
|
+
comment: "Start indefinite-length byte string"
|
|
1428
|
+
}];
|
|
1429
|
+
for (let n of this.chunks) r.push(...n._toHexDump(e + 1, t));
|
|
1430
|
+
return r.push({
|
|
1431
|
+
depth: e,
|
|
1432
|
+
hex: n(255),
|
|
1433
|
+
comment: "\"break\""
|
|
1434
|
+
}), r;
|
|
1435
|
+
}
|
|
1436
|
+
_toJS(e) {
|
|
1437
|
+
let t = this.chunks.reduce((e, t) => e + t.value.length, 0), n = new Uint8Array(t), r = 0;
|
|
1438
|
+
for (let e of this.chunks) n.set(e.value, r), r += e.value.length;
|
|
1439
|
+
return n;
|
|
1440
|
+
}
|
|
1441
|
+
}, T = class extends d {
|
|
1442
|
+
indefiniteLength = !0;
|
|
1443
|
+
chunks;
|
|
1444
|
+
constructor(e) {
|
|
1445
|
+
super(), this.chunks = e;
|
|
1446
|
+
}
|
|
1447
|
+
_toCBOR(e) {
|
|
1448
|
+
let t = [new Uint8Array([127])];
|
|
1449
|
+
for (let n of this.chunks) t.push(n._toCBOR(e));
|
|
1450
|
+
return t.push(new Uint8Array([255])), v(t);
|
|
1451
|
+
}
|
|
1452
|
+
_toEDN(e, t) {
|
|
1453
|
+
return this.chunks.length === 0 ? "\"\"_" : `(_ ${this.chunks.map((t) => t._toEDN(e, 0)).join(", ")})`;
|
|
1454
|
+
}
|
|
1455
|
+
_toHexDump(e, t) {
|
|
1456
|
+
let n = (e) => e.toString(16).toUpperCase().padStart(2, "0"), r = [{
|
|
1457
|
+
depth: e,
|
|
1458
|
+
hex: n(127),
|
|
1459
|
+
comment: "Start indefinite-length text string"
|
|
1460
|
+
}];
|
|
1461
|
+
for (let n of this.chunks) r.push(...n._toHexDump(e + 1, t));
|
|
1462
|
+
return r.push({
|
|
1463
|
+
depth: e,
|
|
1464
|
+
hex: n(255),
|
|
1465
|
+
comment: "\"break\""
|
|
1466
|
+
}), r;
|
|
1467
|
+
}
|
|
1468
|
+
_toJS(e) {
|
|
1469
|
+
return this.chunks.map((e) => e.value).join("");
|
|
1470
|
+
}
|
|
1471
|
+
}, E = class extends d {
|
|
1472
|
+
items;
|
|
1473
|
+
indefiniteLength;
|
|
1474
|
+
encodingWidth;
|
|
1475
|
+
constructor(e, t) {
|
|
1476
|
+
super(), this.items = e, this.indefiniteLength = t?.indefiniteLength ?? !1, this.encodingWidth = t?.encodingWidth;
|
|
1477
|
+
}
|
|
1478
|
+
_toCBOR(e) {
|
|
1479
|
+
if (this.indefiniteLength) {
|
|
1480
|
+
let t = [new Uint8Array([159])];
|
|
1481
|
+
for (let n of this.items) t.push(n._toCBOR(e));
|
|
1482
|
+
return t.push(new Uint8Array([255])), v(t);
|
|
1483
|
+
}
|
|
1484
|
+
let t = [_(4, BigInt(this.items.length), this.encodingWidth)];
|
|
1485
|
+
for (let n of this.items) t.push(n._toCBOR(e));
|
|
1486
|
+
return v(t);
|
|
1487
|
+
}
|
|
1488
|
+
_toEDN(e, t) {
|
|
1489
|
+
let n = ie(e), r = e?.preserveComments, i = r && (oe(this) || this.items.some(ae));
|
|
1490
|
+
n === null && i && (n = " ");
|
|
1491
|
+
let { inlineSep: a, multilineSep: o, trailSep: s } = ue(e, n === null), c = !this.indefiniteLength && this.encodingWidth !== void 0 ? `_${this.encodingWidth} ` : "";
|
|
1492
|
+
if (n === null || this.items.length === 0 && !i) {
|
|
1493
|
+
let n = this.items.map((n) => n._toEDN(e, t + 1)).join(a);
|
|
1494
|
+
return this.indefiniteLength ? this.items.length === 0 ? "[_ ]" : `[_ ${n}]` : `[${c}${n}]`;
|
|
1495
|
+
}
|
|
1496
|
+
let l = x(n, t + 1), u = x(n, t), d = this.indefiniteLength ? "[_ " : `[${c}`, f = [];
|
|
1497
|
+
for (let n = 0; n < this.items.length; n++) {
|
|
1498
|
+
let i = this.items[n];
|
|
1499
|
+
r && f.push(...se(i, l));
|
|
1500
|
+
let a = n < this.items.length - 1 ? o : s;
|
|
1501
|
+
f.push(`${l}${i._toEDN(e, t + 1)}${a}${r ? ce(i) : ""}`);
|
|
1502
|
+
}
|
|
1503
|
+
return r && f.push(...le(this, l)), `${d}\n${f.join("\n")}\n${u}]`;
|
|
1504
|
+
}
|
|
1505
|
+
_toHexDump(e, t) {
|
|
1506
|
+
let n = (e) => e.toString(16).toUpperCase().padStart(2, "0"), r = (e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" ");
|
|
1507
|
+
if (this.indefiniteLength) {
|
|
1508
|
+
let r = [{
|
|
1509
|
+
depth: e,
|
|
1510
|
+
hex: n(159),
|
|
1511
|
+
comment: "Start indefinite-length array"
|
|
1512
|
+
}];
|
|
1513
|
+
for (let n of this.items) r.push(...n._toHexDump(e + 1, t));
|
|
1514
|
+
return r.push({
|
|
1515
|
+
depth: e,
|
|
1516
|
+
hex: n(255),
|
|
1517
|
+
comment: "\"break\""
|
|
1518
|
+
}), r;
|
|
1519
|
+
}
|
|
1520
|
+
let i = [{
|
|
1521
|
+
depth: e,
|
|
1522
|
+
hex: r(_(4, BigInt(this.items.length), this.encodingWidth)),
|
|
1523
|
+
comment: `Array of length ${this.items.length}`
|
|
1524
|
+
}];
|
|
1525
|
+
for (let n of this.items) i.push(...n._toHexDump(e + 1, t));
|
|
1526
|
+
return i;
|
|
1527
|
+
}
|
|
1528
|
+
_toJS(e) {
|
|
1529
|
+
let t = e?.reviver;
|
|
1530
|
+
if (!t) return this.items.map((t) => t._toJS(e));
|
|
1531
|
+
let n = e ? {
|
|
1532
|
+
...e,
|
|
1533
|
+
reviver: void 0
|
|
1534
|
+
} : void 0, r = this.items.map((e) => e._toJS(n)), i = 0;
|
|
1535
|
+
for (let n = 0; n < this.items.length; n++) {
|
|
1536
|
+
let a = n - i, o = this.items[n]._toJS(e), s = t.call(r, String(n), o);
|
|
1537
|
+
s === l || e?.undefinedOmits && s === void 0 ? (r.splice(a, 1), i++) : r[a] = s;
|
|
1538
|
+
}
|
|
1539
|
+
return r;
|
|
1540
|
+
}
|
|
1541
|
+
}, D = class extends d {
|
|
1542
|
+
entries;
|
|
1543
|
+
indefiniteLength;
|
|
1544
|
+
encodingWidth;
|
|
1545
|
+
constructor(e, t) {
|
|
1546
|
+
super(), this.entries = e, this.indefiniteLength = t?.indefiniteLength ?? !1, this.encodingWidth = t?.encodingWidth;
|
|
1547
|
+
}
|
|
1548
|
+
_toCBOR(e) {
|
|
1549
|
+
if (this.indefiniteLength) {
|
|
1550
|
+
let t = [new Uint8Array([191])];
|
|
1551
|
+
for (let [n, r] of this.entries) t.push(n._toCBOR(e), r._toCBOR(e));
|
|
1552
|
+
return t.push(new Uint8Array([255])), v(t);
|
|
1553
|
+
}
|
|
1554
|
+
let t = [_(5, BigInt(this.entries.length), this.encodingWidth)];
|
|
1555
|
+
for (let [n, r] of this.entries) t.push(n._toCBOR(e), r._toCBOR(e));
|
|
1556
|
+
return v(t);
|
|
1557
|
+
}
|
|
1558
|
+
_toEDN(e, t) {
|
|
1559
|
+
let n = ie(e), r = e?.preserveComments, i = r && (oe(this) || this.entries.some(([e, t]) => ae(e) || ae(t)));
|
|
1560
|
+
n === null && i && (n = " ");
|
|
1561
|
+
let { inlineSep: a, multilineSep: o, trailSep: s, colSep: c } = ue(e, n === null), l = !this.indefiniteLength && this.encodingWidth !== void 0 ? `_${this.encodingWidth} ` : "", u = this.indefiniteLength ? "{_ " : `{${l}`;
|
|
1562
|
+
if (n === null || this.entries.length === 0 && !i) {
|
|
1563
|
+
let n = this.entries.map(([n, r]) => `${n._toEDN(e, t + 1)}${c}${r._toEDN(e, t + 1)}`).join(a);
|
|
1564
|
+
return this.indefiniteLength ? this.entries.length === 0 ? "{_ }" : `{_ ${n}}` : `{${l}${n}}`;
|
|
1565
|
+
}
|
|
1566
|
+
let d = x(n, t + 1), f = x(n, t), p = [];
|
|
1567
|
+
for (let n = 0; n < this.entries.length; n++) {
|
|
1568
|
+
let [i, a] = this.entries[n];
|
|
1569
|
+
r && p.push(...se(i, d));
|
|
1570
|
+
let l = n < this.entries.length - 1 ? o : s, u = r ? Ne([
|
|
1571
|
+
...i.comments?.trailing ?? [],
|
|
1572
|
+
...a.comments?.leading ?? [],
|
|
1573
|
+
...a.comments?.trailing ?? []
|
|
1574
|
+
]) : "";
|
|
1575
|
+
p.push(`${d}${i._toEDN(e, t + 1)}${c}${a._toEDN(e, t + 1)}${l}${u}`);
|
|
1576
|
+
}
|
|
1577
|
+
return r && p.push(...le(this, d)), `${u}\n${p.join("\n")}\n${f}}`;
|
|
1578
|
+
}
|
|
1579
|
+
_toHexDump(e, t) {
|
|
1580
|
+
let n = (e) => e.toString(16).toUpperCase().padStart(2, "0"), r = (e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" ");
|
|
1581
|
+
if (this.indefiniteLength) {
|
|
1582
|
+
let r = [{
|
|
1583
|
+
depth: e,
|
|
1584
|
+
hex: n(191),
|
|
1585
|
+
comment: "Start indefinite-length map"
|
|
1586
|
+
}];
|
|
1587
|
+
for (let [n, i] of this.entries) r.push(...n._toHexDump(e + 1, t)), r.push(...i._toHexDump(e + 1, t));
|
|
1588
|
+
return r.push({
|
|
1589
|
+
depth: e,
|
|
1590
|
+
hex: n(255),
|
|
1591
|
+
comment: "\"break\""
|
|
1592
|
+
}), r;
|
|
1593
|
+
}
|
|
1594
|
+
let i = [{
|
|
1595
|
+
depth: e,
|
|
1596
|
+
hex: r(_(5, BigInt(this.entries.length), this.encodingWidth)),
|
|
1597
|
+
comment: `Map of length ${this.entries.length}`
|
|
1598
|
+
}];
|
|
1599
|
+
for (let [n, r] of this.entries) i.push(...n._toHexDump(e + 1, t)), i.push(...r._toHexDump(e + 1, t));
|
|
1600
|
+
return i;
|
|
1601
|
+
}
|
|
1602
|
+
_toJS(e) {
|
|
1603
|
+
let t = e?.reviver, n = () => {
|
|
1604
|
+
let n = $.from(this.entries, ([t, n]) => [t._toJS(e), n._toJS(e)]);
|
|
1605
|
+
if (!t) return n;
|
|
1606
|
+
let r = e?.undefinedOmits;
|
|
1607
|
+
for (let e = 0; e < n.length; e++) {
|
|
1608
|
+
let [i, a] = n[e], o = t.call(n, i, a);
|
|
1609
|
+
o === l || r && o === void 0 ? n.splice(e--, 1) : n[e] = [i, o];
|
|
1610
|
+
}
|
|
1611
|
+
return n;
|
|
1612
|
+
};
|
|
1613
|
+
return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof A) ? (() => {
|
|
1614
|
+
let n = e ? {
|
|
1615
|
+
...e,
|
|
1616
|
+
reviver: void 0
|
|
1617
|
+
} : void 0, r = {};
|
|
1618
|
+
for (let [e, t] of this.entries) {
|
|
1619
|
+
let i = e instanceof A ? e.value : e.toEDN(), a = t._toJS(n);
|
|
1620
|
+
i === "__proto__" ? Object.defineProperty(r, i, {
|
|
1621
|
+
value: a,
|
|
1622
|
+
writable: !0,
|
|
1623
|
+
enumerable: !0,
|
|
1624
|
+
configurable: !0
|
|
1625
|
+
}) : r[i] = a;
|
|
1626
|
+
}
|
|
1627
|
+
if (!t) return r;
|
|
1628
|
+
let i = /* @__PURE__ */ new Map();
|
|
1629
|
+
for (let e = 0; e < this.entries.length; e++) {
|
|
1630
|
+
let [t] = this.entries[e];
|
|
1631
|
+
i.set(t instanceof A ? t.value : t.toEDN(), e);
|
|
1632
|
+
}
|
|
1633
|
+
for (let n = 0; n < this.entries.length; n++) {
|
|
1634
|
+
let [a, o] = this.entries[n], s = a instanceof A ? a.value : a.toEDN();
|
|
1635
|
+
if (i.get(s) !== n) continue;
|
|
1636
|
+
let c = o._toJS(e), u = t.call(r, s, c);
|
|
1637
|
+
u === l || e?.undefinedOmits && u === void 0 ? delete r[s] : s === "__proto__" ? Object.defineProperty(r, s, {
|
|
1638
|
+
value: u,
|
|
1639
|
+
writable: !0,
|
|
1640
|
+
enumerable: !0,
|
|
1641
|
+
configurable: !0
|
|
1642
|
+
}) : r[s] = u;
|
|
1643
|
+
}
|
|
1644
|
+
return r;
|
|
1645
|
+
})() : n();
|
|
1646
|
+
}
|
|
1647
|
+
};
|
|
1648
|
+
function Ne(e) {
|
|
1649
|
+
return e.length === 0 ? "" : " " + e.map((e) => e.text.trimEnd()).join(" ");
|
|
1650
|
+
}
|
|
1651
|
+
//#endregion
|
|
1652
|
+
//#region src/ast/CborSimple.ts
|
|
1653
|
+
var O = class e extends d {
|
|
1654
|
+
value;
|
|
1655
|
+
constructor(e) {
|
|
1656
|
+
if (super(), !Number.isInteger(e) || e < 0 || e > 255) throw RangeError("CborSimple value must be an integer in 0–255");
|
|
1657
|
+
this.value = e;
|
|
1658
|
+
}
|
|
1659
|
+
static FALSE = new e(20);
|
|
1660
|
+
static TRUE = new e(21);
|
|
1661
|
+
static NULL = new e(22);
|
|
1662
|
+
static UNDEFINED = new e(23);
|
|
1663
|
+
_toCBOR(e) {
|
|
1664
|
+
return this.value <= 23 ? new Uint8Array([224 | this.value]) : new Uint8Array([248, this.value]);
|
|
1665
|
+
}
|
|
1666
|
+
_toEDN(e, t) {
|
|
1667
|
+
switch (this.value) {
|
|
1668
|
+
case 20: return "false";
|
|
1669
|
+
case 21: return "true";
|
|
1670
|
+
case 22: return "null";
|
|
1671
|
+
case 23: return "undefined";
|
|
1672
|
+
default: return `simple(${this.value})`;
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
_toJS(e) {
|
|
1676
|
+
switch (this.value) {
|
|
1677
|
+
case 20: return !1;
|
|
1678
|
+
case 21: return !0;
|
|
1679
|
+
case 22: return null;
|
|
1680
|
+
case 23: return;
|
|
1681
|
+
default: return new u(this.value);
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
}, Pe = class extends d {
|
|
1685
|
+
items;
|
|
1686
|
+
constructor(e) {
|
|
1687
|
+
super(), this.items = e;
|
|
1688
|
+
}
|
|
1689
|
+
_content(e) {
|
|
1690
|
+
return v(this.items.map((t) => t._toCBOR(e)));
|
|
1691
|
+
}
|
|
1692
|
+
_toCBOR(e) {
|
|
1693
|
+
let t = this._content(e);
|
|
1694
|
+
return v([_(2, BigInt(t.length)), t]);
|
|
1695
|
+
}
|
|
1696
|
+
_toEDN(e, t) {
|
|
1697
|
+
if (this.items.length === 0) return "<<>>";
|
|
1698
|
+
let n = ie(e), { inlineSep: r, multilineSep: i, trailSep: a } = ue(e, n === null);
|
|
1699
|
+
if (n === null) return `<<${this.items.map((n) => n._toEDN(e, t + 1)).join(r)}>>`;
|
|
1700
|
+
let o = x(n, t + 1), s = x(n, t), c = this.items.map((n) => `${o}${n._toEDN(e, t + 1)}`), l = c.length - 1;
|
|
1701
|
+
return `<<\n${c.map((e, t) => t < l ? `${e}${i}` : `${e}${a}`).join("\n")}\n${s}>>`;
|
|
1702
|
+
}
|
|
1703
|
+
_toHexDump(e, t) {
|
|
1704
|
+
let n = (e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" "), r = this._content().length, i = [{
|
|
1705
|
+
depth: e,
|
|
1706
|
+
hex: n(_(2, BigInt(r))),
|
|
1707
|
+
comment: `Embedded CBOR sequence, ${r} byte${r === 1 ? "" : "s"}`
|
|
1708
|
+
}];
|
|
1709
|
+
for (let n of this.items) i.push(...n._toHexDump(e + 1, t));
|
|
1710
|
+
return i;
|
|
1711
|
+
}
|
|
1712
|
+
_toJS(e) {
|
|
1713
|
+
return this._content();
|
|
1714
|
+
}
|
|
1715
|
+
}, Fe = 999n, Ie = class extends C {
|
|
1716
|
+
constructor(e, t) {
|
|
1717
|
+
let n = t.length === 1 && t[0] instanceof A ? t[0] : new E(t);
|
|
1718
|
+
super(Fe, new E([new A(e), n]));
|
|
1719
|
+
}
|
|
1720
|
+
_toEDN(e, t) {
|
|
1721
|
+
let n = this.content, r = n.items[0].value, i = n.items[1];
|
|
1722
|
+
return i instanceof A ? `${r}${Ce(i.value)}` : `${r}<<${i.items.map((n) => n._toEDN(e, t)).join(", ")}>>`;
|
|
1723
|
+
}
|
|
1724
|
+
}, Le = 888n, k = class extends C {
|
|
1725
|
+
constructor(e) {
|
|
1726
|
+
e === void 0 ? super(Le, O.NULL) : super(Le, new E(e));
|
|
1727
|
+
}
|
|
1728
|
+
_toEDN(e, t) {
|
|
1729
|
+
return this.content instanceof O ? "..." : this.content instanceof E ? this.content.items.map((n) => n._toEDN(e, t)).join(" + ") : super._toEDN(e, t);
|
|
1730
|
+
}
|
|
1731
|
+
}, Re = 2n, ze = 3n, Be = 18446744073709551615n, Ve = -(Be + 1n);
|
|
1732
|
+
function He(e) {
|
|
1733
|
+
if (e < 0n) throw RangeError("bigintToBytes requires a non-negative value");
|
|
1734
|
+
if (e === 0n) return new Uint8Array();
|
|
1735
|
+
let t = e.toString(16);
|
|
1736
|
+
t.length % 2 != 0 && (t = "0" + t);
|
|
1737
|
+
let n = new Uint8Array(t.length / 2);
|
|
1738
|
+
for (let e = 0; e < n.length; e++) n[e] = parseInt(t.slice(e * 2, e * 2 + 2), 16);
|
|
1739
|
+
return n;
|
|
1740
|
+
}
|
|
1741
|
+
function Ue(e) {
|
|
1742
|
+
let t = 0n;
|
|
1743
|
+
for (let n of e) t = t << 8n | BigInt(n);
|
|
1744
|
+
return t;
|
|
1745
|
+
}
|
|
1746
|
+
var We = class extends C {
|
|
1747
|
+
bigValue;
|
|
1748
|
+
constructor(e) {
|
|
1749
|
+
if (e <= Be) throw RangeError(`CborBigUint value ${e} fits in CborUint; use CborUint instead`);
|
|
1750
|
+
super(Re, new w(He(e))), this.bigValue = e;
|
|
1751
|
+
}
|
|
1752
|
+
_toEDN(e, t) {
|
|
1753
|
+
return this.bigValue.toString();
|
|
1754
|
+
}
|
|
1755
|
+
_toJS(e) {
|
|
1756
|
+
return this.bigValue;
|
|
1757
|
+
}
|
|
1758
|
+
}, Ge = class extends C {
|
|
1759
|
+
bigValue;
|
|
1760
|
+
constructor(e) {
|
|
1761
|
+
if (e >= Ve) throw RangeError(`CborBigNint value ${e} fits in CborNint; use CborNint instead`);
|
|
1762
|
+
super(ze, new w(He(-1n - e))), this.bigValue = e;
|
|
1763
|
+
}
|
|
1764
|
+
_toEDN(e, t) {
|
|
1765
|
+
return this.bigValue.toString();
|
|
1766
|
+
}
|
|
1767
|
+
_toJS(e) {
|
|
1768
|
+
return this.bigValue;
|
|
1769
|
+
}
|
|
1770
|
+
};
|
|
1771
|
+
//#endregion
|
|
1772
|
+
//#region src/edn/parser.ts
|
|
1773
|
+
function Ke(e, t) {
|
|
1774
|
+
let n = new je(e, { offset: t?.offset }), r = new at(n, t?.extensions, t?.unresolvedExtension, t?.allowInvalidUtf8, t?.allowTrailing).parse();
|
|
1775
|
+
return t?.preserveComments && tt(r, n.comments, e), r;
|
|
1776
|
+
}
|
|
1777
|
+
function qe(e) {
|
|
1778
|
+
let t = e, n;
|
|
1779
|
+
if (/[_][0-3i]$/.test(e)) {
|
|
1780
|
+
let r = e[e.length - 1];
|
|
1781
|
+
n = r === "i" ? "i" : Number(r), t = e.slice(0, -2);
|
|
1782
|
+
}
|
|
1783
|
+
return {
|
|
1784
|
+
numStr: t,
|
|
1785
|
+
encodingWidth: n
|
|
1786
|
+
};
|
|
1787
|
+
}
|
|
1788
|
+
function Je(e) {
|
|
1789
|
+
return e.startsWith("-") ? -BigInt(e.slice(1)) : BigInt(e);
|
|
1790
|
+
}
|
|
1791
|
+
function Ye(e) {
|
|
1792
|
+
if (e === "NaN") return {
|
|
1793
|
+
value: NaN,
|
|
1794
|
+
precision: void 0
|
|
1795
|
+
};
|
|
1796
|
+
if (e === "Infinity") return {
|
|
1797
|
+
value: Infinity,
|
|
1798
|
+
precision: void 0
|
|
1799
|
+
};
|
|
1800
|
+
if (e === "-Infinity") return {
|
|
1801
|
+
value: -Infinity,
|
|
1802
|
+
precision: void 0
|
|
1803
|
+
};
|
|
1804
|
+
if (e.endsWith("_i") || e.endsWith("_0")) throw SyntaxError("EDN parse error: _0 and _i encoding indicators are not valid for floating-point values");
|
|
1805
|
+
let t = e, n;
|
|
1806
|
+
return e.endsWith("_1") ? (n = "half", t = e.slice(0, -2)) : e.endsWith("_2") ? (n = "single", t = e.slice(0, -2)) : e.endsWith("_3") && (n = "double", t = e.slice(0, -2)), /^-?0[xX]/.test(t) ? {
|
|
1807
|
+
value: Oe(t),
|
|
1808
|
+
precision: n
|
|
1809
|
+
} : {
|
|
1810
|
+
value: parseFloat(t),
|
|
1811
|
+
precision: n
|
|
1812
|
+
};
|
|
1813
|
+
}
|
|
1814
|
+
function Xe(e) {
|
|
1815
|
+
if (typeof Uint8Array.fromHex == "function") return Uint8Array.fromHex(e);
|
|
1816
|
+
if (e.length % 2 != 0) throw SyntaxError(`hex string has odd length: ${e.length}`);
|
|
1817
|
+
let t = new Uint8Array(e.length / 2);
|
|
1818
|
+
for (let n = 0; n < e.length; n += 2) t[n / 2] = parseInt(e.slice(n, n + 2), 16);
|
|
1819
|
+
return t;
|
|
1820
|
+
}
|
|
1821
|
+
var Ze = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", Qe = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
|
|
1822
|
+
function $e(e, t) {
|
|
1823
|
+
let n = e.replace(/=+$/, "").toUpperCase(), r = n.length % 8;
|
|
1824
|
+
if (r === 1 || r === 3 || r === 6) throw SyntaxError(`invalid base32 length: ${n.length} characters`);
|
|
1825
|
+
let i = new Uint8Array(128).fill(255);
|
|
1826
|
+
for (let e = 0; e < t.length; e++) i[t.charCodeAt(e)] = e;
|
|
1827
|
+
let a = new Uint8Array(Math.floor(n.length * 5 / 8)), o = 0, s = 0, c = 0;
|
|
1828
|
+
for (let e of n) {
|
|
1829
|
+
let t = e.charCodeAt(0), n = t < 128 ? i[t] : 255;
|
|
1830
|
+
if (n === 255) throw SyntaxError(`invalid character in byte string: ${JSON.stringify(e)}`);
|
|
1831
|
+
o = o << 5 | n, s += 5, s >= 8 && (s -= 8, a[c++] = o >> s & 255);
|
|
1832
|
+
}
|
|
1833
|
+
if (s > 0 && o & (1 << s) - 1) throw SyntaxError("non-zero trailing bits in base32 input");
|
|
1834
|
+
return a;
|
|
1835
|
+
}
|
|
1836
|
+
function et(e) {
|
|
1837
|
+
if (typeof Uint8Array.fromBase64 == "function") {
|
|
1838
|
+
let t = /[-_]/.test(e) ? "base64url" : "base64";
|
|
1839
|
+
return Uint8Array.fromBase64(e, {
|
|
1840
|
+
alphabet: t,
|
|
1841
|
+
lastChunkHandling: "loose"
|
|
1842
|
+
});
|
|
1843
|
+
}
|
|
1844
|
+
let t = e.replace(/-/g, "+").replace(/_/g, "/"), n = t + "=".repeat((4 - t.length % 4) % 4), r = atob(n), i = new Uint8Array(r.length);
|
|
1845
|
+
for (let e = 0; e < r.length; e++) i[e] = r.charCodeAt(e);
|
|
1846
|
+
return i;
|
|
1847
|
+
}
|
|
1848
|
+
function tt(e, t, n) {
|
|
1849
|
+
if (t.length === 0) return;
|
|
1850
|
+
let r = nt(e), i = it(n);
|
|
1851
|
+
for (let a of t) {
|
|
1852
|
+
let t = { ...a }, o = [...r].filter((e) => e.end <= a.start).sort((e, t) => t.end - e.end || t.start - e.start)[0], s = o ? n.slice(o.end, a.start) : "";
|
|
1853
|
+
if (o && i(o.end) === a.line && !s.includes(":")) {
|
|
1854
|
+
rt(o.node, "trailing", t);
|
|
1855
|
+
continue;
|
|
1856
|
+
}
|
|
1857
|
+
let c = [...r].filter((e) => e.start < a.start && a.end < e.end).sort((e, t) => t.start - e.start || e.end - t.end)[0], l = [...r].filter((e) => e.start >= a.end).sort((e, t) => e.start - t.start || t.end - e.end)[0];
|
|
1858
|
+
if ((!c || l && l.end <= c.end) && l) {
|
|
1859
|
+
rt(l.node, "leading", t);
|
|
1860
|
+
continue;
|
|
1861
|
+
}
|
|
1862
|
+
rt(c?.node ?? e, "dangling", t);
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
function nt(e) {
|
|
1866
|
+
let t = [], n = (e) => {
|
|
1867
|
+
if (e.start !== void 0 && e.end !== void 0 && t.push({
|
|
1868
|
+
node: e,
|
|
1869
|
+
start: e.start,
|
|
1870
|
+
end: e.end
|
|
1871
|
+
}), e instanceof E || e instanceof Pe) {
|
|
1872
|
+
for (let t of e.items) n(t);
|
|
1873
|
+
return;
|
|
1874
|
+
}
|
|
1875
|
+
if (e instanceof D) {
|
|
1876
|
+
for (let [t, r] of e.entries) n(t), n(r);
|
|
1877
|
+
return;
|
|
1878
|
+
}
|
|
1879
|
+
if (e instanceof Me || e instanceof T) {
|
|
1880
|
+
for (let t of e.chunks) n(t);
|
|
1881
|
+
return;
|
|
1882
|
+
}
|
|
1883
|
+
e instanceof C && n(e.content);
|
|
1884
|
+
};
|
|
1885
|
+
return n(e), t;
|
|
1886
|
+
}
|
|
1887
|
+
function rt(e, t, n) {
|
|
1888
|
+
e.comments ??= {}, e.comments[t] ??= [], e.comments[t].push(n);
|
|
1889
|
+
}
|
|
1890
|
+
function it(e) {
|
|
1891
|
+
let t = [0];
|
|
1892
|
+
for (let n = 0; n < e.length; n++) e[n] === "\n" && t.push(n + 1);
|
|
1893
|
+
return (n) => {
|
|
1894
|
+
let r = Math.max(0, Math.min(e.length, n));
|
|
1895
|
+
r > 0 && r === e.length && r--;
|
|
1896
|
+
let i = 0, a = t.length - 1;
|
|
1897
|
+
for (; i <= a;) {
|
|
1898
|
+
let e = i + a >> 1;
|
|
1899
|
+
t[e] <= r ? i = e + 1 : a = e - 1;
|
|
1900
|
+
}
|
|
1901
|
+
return a + 1;
|
|
1902
|
+
};
|
|
1903
|
+
}
|
|
1904
|
+
var at = class {
|
|
1905
|
+
extByPrefix;
|
|
1906
|
+
extByTag;
|
|
1907
|
+
unresolvedExtension;
|
|
1908
|
+
constructor(e, t, n, r, i) {
|
|
1909
|
+
this.t = e, this.allowInvalidUtf8 = r, this.allowTrailing = i, this.extByPrefix = /* @__PURE__ */ new Map(), this.extByTag = /* @__PURE__ */ new Map(), this.unresolvedExtension = n ?? "cpa999";
|
|
1910
|
+
for (let e of [...Yr, ...t ?? []]) {
|
|
1911
|
+
for (let t of e.appStringPrefixes ?? []) this.extByPrefix.set(t, e);
|
|
1912
|
+
for (let t of e.tagNumbers ?? []) this.extByTag.set(t, e);
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
parse() {
|
|
1916
|
+
let e = this.parseValue();
|
|
1917
|
+
if (this.allowTrailing) return e;
|
|
1918
|
+
let t = this.t.peek();
|
|
1919
|
+
return t.type !== "EOF" && this._fail(`unexpected token after value: ${JSON.stringify(t.value)}`, t), e;
|
|
1920
|
+
}
|
|
1921
|
+
parseValue() {
|
|
1922
|
+
let e = this.t.peek().offset, t = this._parseValueNode();
|
|
1923
|
+
return t.start = e, t.end = this.t.lastEndOffset, t;
|
|
1924
|
+
}
|
|
1925
|
+
_parseValueNode() {
|
|
1926
|
+
let e = this.t.peek();
|
|
1927
|
+
switch (e.type) {
|
|
1928
|
+
case "INTEGER": return this.parseIntegerOrTag();
|
|
1929
|
+
case "FLOAT": return this.parseFloat();
|
|
1930
|
+
case "TSTR":
|
|
1931
|
+
case "RAWSTRING": return this.parseString();
|
|
1932
|
+
case "BYTES_HEX":
|
|
1933
|
+
case "SQSTR":
|
|
1934
|
+
case "BYTES_B64":
|
|
1935
|
+
case "BYTES_B32":
|
|
1936
|
+
case "BYTES_H32": return this.t.consume(), this._parseBytesConcat(this._decodeBytesToken(e), e.type, e.raw);
|
|
1937
|
+
case "EMPTY_INDEF_BYTES": return this.t.consume(), new Me([]);
|
|
1938
|
+
case "EMPTY_INDEF_TEXT": return this.t.consume(), new T([]);
|
|
1939
|
+
case "TRUE": return this.t.consume(), O.TRUE;
|
|
1940
|
+
case "FALSE": return this.t.consume(), O.FALSE;
|
|
1941
|
+
case "NULL": return this.t.consume(), O.NULL;
|
|
1942
|
+
case "UNDEFINED": return this.t.consume(), O.UNDEFINED;
|
|
1943
|
+
case "SIMPLE": return this.parseSimple();
|
|
1944
|
+
case "LBRACKET": return this.parseArray();
|
|
1945
|
+
case "LBRACE": return this.parseMap();
|
|
1946
|
+
case "LPAREN": return this.parseIndefGroup();
|
|
1947
|
+
case "LT_LT": return this.parseEmbeddedCBOR();
|
|
1948
|
+
case "APP_STRING": {
|
|
1949
|
+
this.t.consume();
|
|
1950
|
+
let t = this.extByPrefix.get(e.appPrefix);
|
|
1951
|
+
if (!t?.parseAppString) {
|
|
1952
|
+
if (this.unresolvedExtension === "cpa999") return new Ie(e.appPrefix, [new A(e.value)]);
|
|
1953
|
+
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
1954
|
+
}
|
|
1955
|
+
return t.parseAppString(e.appPrefix, e.value);
|
|
1956
|
+
}
|
|
1957
|
+
case "APP_SEQUENCE": {
|
|
1958
|
+
this.t.consume();
|
|
1959
|
+
let t = [];
|
|
1960
|
+
for (; this.t.peek().type !== "GT_GT" && (this.t.peek().type === "EOF" && this._fail(`unterminated ${e.appPrefix}<<...>>`, e), !(t.length > 0 && this.t.peek().type === "COMMA" && (this.t.consume(), this.t.peek().type === "GT_GT")));) t.push(this.parseValue());
|
|
1961
|
+
this.expect("GT_GT");
|
|
1962
|
+
let n = this.extByPrefix.get(e.appPrefix);
|
|
1963
|
+
if (!n) {
|
|
1964
|
+
if (this.unresolvedExtension === "cpa999") return new Ie(e.appPrefix, t);
|
|
1965
|
+
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
1966
|
+
}
|
|
1967
|
+
return n.parseAppSequence || this._fail(`app-string extension ${JSON.stringify(e.appPrefix)} does not support <<...>> form`, e), n.parseAppSequence(e.appPrefix, t);
|
|
1968
|
+
}
|
|
1969
|
+
case "ELLIPSIS": {
|
|
1970
|
+
if (this.t.consume(), this.t.peek().type !== "PLUS") return new k();
|
|
1971
|
+
let e = [new k()];
|
|
1972
|
+
for (; this.t.peek().type === "PLUS";) this.t.consume(), e.push(this.parseValue());
|
|
1973
|
+
return new k(e);
|
|
1974
|
+
}
|
|
1975
|
+
case "BYTES_HEX_ELIDED": return this.t.consume(), this._parseHexElidedConcat(e);
|
|
1976
|
+
default: this._fail(`unexpected token: ${JSON.stringify(e.value)}`, e);
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
parseIntegerOrTag() {
|
|
1980
|
+
let e = this.t.consume(), { numStr: t, encodingWidth: n } = qe(e.value), r = n === void 0 ? this.consumeEncodingIndicator() : n, i = Je(t);
|
|
1981
|
+
if (i > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", e), new We(i);
|
|
1982
|
+
if (i < -18446744073709551616n) return new Ge(i);
|
|
1983
|
+
let a = i >= 0n ? new y(i, r === void 0 ? void 0 : { encodingWidth: r }) : new b(i, r === void 0 ? void 0 : { encodingWidth: r });
|
|
1984
|
+
if (this.t.peek().type === "LPAREN") {
|
|
1985
|
+
a instanceof y || this._fail("tag number must be non-negative", e), this.t.consume();
|
|
1986
|
+
let t = this.parseValue();
|
|
1987
|
+
this.expect("RPAREN");
|
|
1988
|
+
let n = a.value, i = this.extByTag.get(n);
|
|
1989
|
+
if (i?.parseTag) {
|
|
1990
|
+
let e = i.parseTag(n, t);
|
|
1991
|
+
if (e !== void 0) return e;
|
|
1992
|
+
}
|
|
1993
|
+
return new C(n, t, r === void 0 ? void 0 : { encodingWidth: r });
|
|
1994
|
+
}
|
|
1995
|
+
return a;
|
|
1996
|
+
}
|
|
1997
|
+
parseFloat() {
|
|
1998
|
+
let { value: e, precision: t } = Ye(this.t.consume().value);
|
|
1999
|
+
return new S(e, t === void 0 ? void 0 : { precision: t });
|
|
2000
|
+
}
|
|
2001
|
+
parseString() {
|
|
2002
|
+
let e = this.t.consume();
|
|
2003
|
+
if (this.t.peek().type !== "PLUS") {
|
|
2004
|
+
let t = this.consumeEncodingIndicator();
|
|
2005
|
+
return new A(e.value, t === void 0 ? void 0 : { encodingWidth: t });
|
|
2006
|
+
}
|
|
2007
|
+
let t = !1, n = [{ text: e.value }];
|
|
2008
|
+
for (; this.t.peek().type === "PLUS";) {
|
|
2009
|
+
this.t.consume();
|
|
2010
|
+
let e = this.t.peek();
|
|
2011
|
+
e.type === "ELLIPSIS" ? (this.t.consume(), n.push({ ellipsis: !0 }), t = !0) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), n.push({ text: e.value })) : this._isBytesToken(e.type) ? (this.t.consume(), n.push({ text: this._decodeUtf8(this._decodeBytesToken(e), e) })) : this._fail(`expected string or byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
2012
|
+
}
|
|
2013
|
+
if (!t) {
|
|
2014
|
+
let e = this.consumeEncodingIndicator();
|
|
2015
|
+
return new A(n.map((e) => "text" in e ? e.text : "").join(""), e === void 0 ? void 0 : { encodingWidth: e });
|
|
2016
|
+
}
|
|
2017
|
+
let r = [], i = "";
|
|
2018
|
+
for (let e of n) "ellipsis" in e ? (i !== "" && (r.push(new A(i)), i = ""), r.push(new k())) : i += e.text;
|
|
2019
|
+
return i !== "" && r.push(new A(i)), new k(r);
|
|
2020
|
+
}
|
|
2021
|
+
_isBytesToken(e) {
|
|
2022
|
+
return e === "BYTES_HEX" || e === "SQSTR" || e === "BYTES_B64" || e === "BYTES_B32" || e === "BYTES_H32";
|
|
2023
|
+
}
|
|
2024
|
+
_decodeBytesToken(e) {
|
|
2025
|
+
switch (e.type) {
|
|
2026
|
+
case "BYTES_HEX":
|
|
2027
|
+
case "SQSTR": return Xe(e.value);
|
|
2028
|
+
case "BYTES_B64": return et(e.value);
|
|
2029
|
+
case "BYTES_B32": return $e(e.value, Ze);
|
|
2030
|
+
case "BYTES_H32": return $e(e.value, Qe);
|
|
2031
|
+
default: this._fail("expected byte string token", e);
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
_decodeUtf8(e, t) {
|
|
2035
|
+
if (this.allowInvalidUtf8) return new TextDecoder("utf-8", { fatal: !1 }).decode(e);
|
|
2036
|
+
try {
|
|
2037
|
+
return new TextDecoder("utf-8", { fatal: !0 }).decode(e);
|
|
2038
|
+
} catch {
|
|
2039
|
+
this._fail("byte string in text concatenation is not valid UTF-8", t);
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
_tokenTypeToEdnEncoding(e) {
|
|
2043
|
+
switch (e) {
|
|
2044
|
+
case "BYTES_B64": return "base64";
|
|
2045
|
+
case "BYTES_B32": return "base32";
|
|
2046
|
+
case "BYTES_H32": return "base32hex";
|
|
2047
|
+
default: return "hex";
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
_parseBytesConcat(e, t, n) {
|
|
2051
|
+
if (this.t.peek().type !== "PLUS") {
|
|
2052
|
+
let r = this.consumeEncodingIndicator();
|
|
2053
|
+
return new w(e, {
|
|
2054
|
+
ednEncoding: this._tokenTypeToEdnEncoding(t),
|
|
2055
|
+
ednSource: n,
|
|
2056
|
+
...r === void 0 ? {} : { encodingWidth: r }
|
|
2057
|
+
});
|
|
2058
|
+
}
|
|
2059
|
+
let r = !1, i = [{ bytes: e }];
|
|
2060
|
+
for (; this.t.peek().type === "PLUS";) {
|
|
2061
|
+
this.t.consume();
|
|
2062
|
+
let e = this.t.peek();
|
|
2063
|
+
if (e.type === "ELLIPSIS") this.t.consume(), i.push({ ellipsis: !0 }), r = !0;
|
|
2064
|
+
else if (e.type === "BYTES_HEX_ELIDED") {
|
|
2065
|
+
this.t.consume();
|
|
2066
|
+
let t = this._buildBytesElidedItems(e.value);
|
|
2067
|
+
for (let e of t) e instanceof k ? (i.push({ ellipsis: !0 }), r = !0) : e instanceof w && i.push({ bytes: e.value });
|
|
2068
|
+
} else this._isBytesToken(e.type) ? (this.t.consume(), i.push({ bytes: this._decodeBytesToken(e) })) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), i.push({ bytes: new TextEncoder().encode(e.value) })) : this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
2069
|
+
}
|
|
2070
|
+
if (!r) {
|
|
2071
|
+
let e = this.consumeEncodingIndicator(), t = i.map((e) => "bytes" in e ? e.bytes : new Uint8Array());
|
|
2072
|
+
return new w(this._concatBytes(t), e === void 0 ? void 0 : { encodingWidth: e });
|
|
2073
|
+
}
|
|
2074
|
+
let a = [], o = [], s = () => {
|
|
2075
|
+
o.length > 0 && (a.push(new w(this._concatBytes([...o]))), o.length = 0);
|
|
2076
|
+
};
|
|
2077
|
+
for (let e of i) "ellipsis" in e ? (s(), a.push(new k())) : o.push(e.bytes);
|
|
2078
|
+
return s(), new k(a);
|
|
2079
|
+
}
|
|
2080
|
+
_parseHexElidedConcat(e) {
|
|
2081
|
+
let t = this._buildBytesElidedItems(e.value);
|
|
2082
|
+
for (; this.t.peek().type === "PLUS";) {
|
|
2083
|
+
this.t.consume();
|
|
2084
|
+
let e = this.t.peek();
|
|
2085
|
+
if (e.type === "ELLIPSIS") this.t.consume(), t.push(new k());
|
|
2086
|
+
else if (e.type === "BYTES_HEX_ELIDED") {
|
|
2087
|
+
this.t.consume();
|
|
2088
|
+
let n = this._buildBytesElidedItems(e.value);
|
|
2089
|
+
this._mergeFirstBytesItem(t, n);
|
|
2090
|
+
} else if (this._isBytesToken(e.type)) {
|
|
2091
|
+
this.t.consume();
|
|
2092
|
+
let n = this._decodeBytesToken(e), r = t[t.length - 1];
|
|
2093
|
+
r instanceof w ? t[t.length - 1] = new w(this._concatBytes([r.value, n])) : t.push(new w(n));
|
|
2094
|
+
} else this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
2095
|
+
}
|
|
2096
|
+
return new k(t);
|
|
2097
|
+
}
|
|
2098
|
+
_buildBytesElidedItems(e) {
|
|
2099
|
+
let t = e.split("..."), n = [];
|
|
2100
|
+
for (let e = 0; e < t.length; e++) e > 0 && n.push(new k()), t[e].length > 0 && n.push(new w(Xe(t[e])));
|
|
2101
|
+
return n;
|
|
2102
|
+
}
|
|
2103
|
+
_mergeFirstBytesItem(e, t) {
|
|
2104
|
+
if (t.length === 0) return;
|
|
2105
|
+
let n = e[e.length - 1], r = t[0];
|
|
2106
|
+
n instanceof w && r instanceof w ? (e[e.length - 1] = new w(this._concatBytes([n.value, r.value])), e.push(...t.slice(1))) : e.push(...t);
|
|
2107
|
+
}
|
|
2108
|
+
_concatBytes(e) {
|
|
2109
|
+
let t = e.reduce((e, t) => e + t.byteLength, 0), n = new Uint8Array(t), r = 0;
|
|
2110
|
+
for (let t of e) n.set(t, r), r += t.byteLength;
|
|
2111
|
+
return n;
|
|
2112
|
+
}
|
|
2113
|
+
parseSimple() {
|
|
2114
|
+
this.t.consume(), this.expect("LPAREN");
|
|
2115
|
+
let e = this.t.peek();
|
|
2116
|
+
e.type !== "INTEGER" && this._fail(`expected integer inside simple(), got ${JSON.stringify(e.value)}`, e), this.t.consume();
|
|
2117
|
+
let { numStr: t } = qe(e.value), n = Number(Je(t));
|
|
2118
|
+
return this.expect("RPAREN"), new O(n);
|
|
2119
|
+
}
|
|
2120
|
+
parseEmbeddedCBOR() {
|
|
2121
|
+
this.t.consume();
|
|
2122
|
+
let e = [];
|
|
2123
|
+
for (; this.t.peek().type !== "GT_GT" && !(e.length > 0 && this.t.peek().type === "COMMA" && (this.t.consume(), this.t.peek().type === "GT_GT"));) e.push(this.parseValue());
|
|
2124
|
+
return this.expect("GT_GT"), new Pe(e);
|
|
2125
|
+
}
|
|
2126
|
+
parseArray() {
|
|
2127
|
+
this.t.consume();
|
|
2128
|
+
let e = !1, t;
|
|
2129
|
+
if (this.t.peek().type === "UNDERSCORE") this.t.consume(), e = !0;
|
|
2130
|
+
else if (this.t.peek().type === "ENCODING_INDICATOR") {
|
|
2131
|
+
let e = this.t.consume().value;
|
|
2132
|
+
t = e === "i" ? "i" : Number(e);
|
|
2133
|
+
}
|
|
2134
|
+
let n = [];
|
|
2135
|
+
for (; this.t.peek().type !== "RBRACKET" && !(n.length > 0 && this.t.peek().type === "COMMA" && (this.t.consume(), this.t.peek().type === "RBRACKET"));) n.push(this.parseValue());
|
|
2136
|
+
return this.expect("RBRACKET"), new E(n, {
|
|
2137
|
+
indefiniteLength: e,
|
|
2138
|
+
encodingWidth: t
|
|
2139
|
+
});
|
|
2140
|
+
}
|
|
2141
|
+
parseMap() {
|
|
2142
|
+
this.t.consume();
|
|
2143
|
+
let e = !1, t;
|
|
2144
|
+
if (this.t.peek().type === "UNDERSCORE") this.t.consume(), e = !0;
|
|
2145
|
+
else if (this.t.peek().type === "ENCODING_INDICATOR") {
|
|
2146
|
+
let e = this.t.consume().value;
|
|
2147
|
+
t = e === "i" ? "i" : Number(e);
|
|
2148
|
+
}
|
|
2149
|
+
let n = [];
|
|
2150
|
+
for (; this.t.peek().type !== "RBRACE" && !(n.length > 0 && this.t.peek().type === "COMMA" && (this.t.consume(), this.t.peek().type === "RBRACE"));) {
|
|
2151
|
+
let e = this.parseValue();
|
|
2152
|
+
this.expect("COLON");
|
|
2153
|
+
let t = this.parseValue();
|
|
2154
|
+
n.push([e, t]);
|
|
2155
|
+
}
|
|
2156
|
+
return this.expect("RBRACE"), new D(n, {
|
|
2157
|
+
indefiniteLength: e,
|
|
2158
|
+
encodingWidth: t
|
|
2159
|
+
});
|
|
2160
|
+
}
|
|
2161
|
+
parseIndefGroup() {
|
|
2162
|
+
this.t.consume();
|
|
2163
|
+
let e = this.t.peek();
|
|
2164
|
+
e.type !== "UNDERSCORE" && this._fail(`expected _ after (, got ${JSON.stringify(e.value)}`, e), this.t.consume();
|
|
2165
|
+
let t = [];
|
|
2166
|
+
for (; this.t.peek().type !== "RPAREN" && !(t.length > 0 && this.t.peek().type === "COMMA" && (this.t.consume(), this.t.peek().type === "RPAREN"));) t.push(this.parseValue());
|
|
2167
|
+
this.expect("RPAREN"), t.length === 0 && this._fail("empty indefinite group (_ ) is ambiguous; use ''_ for bytes or \"\"_ for text");
|
|
2168
|
+
let n = t[0];
|
|
2169
|
+
if (n instanceof w) return new Me(t.map((e, t) => {
|
|
2170
|
+
if (e instanceof w) return e;
|
|
2171
|
+
this._fail(`indefinite byte string chunk ${t} must be a byte string, not a text string`);
|
|
2172
|
+
}));
|
|
2173
|
+
if (n instanceof A) return new T(t.map((e, t) => {
|
|
2174
|
+
if (e instanceof A) return e;
|
|
2175
|
+
this._fail(`indefinite text string chunk ${t} must be a text string, not a byte string`);
|
|
2176
|
+
}));
|
|
2177
|
+
this._fail("indefinite group chunks must be byte strings or text strings");
|
|
2178
|
+
}
|
|
2179
|
+
consumeEncodingIndicator() {
|
|
2180
|
+
if (this.t.peek().type === "ENCODING_INDICATOR") {
|
|
2181
|
+
let e = this.t.consume().value;
|
|
2182
|
+
return e === "i" ? "i" : Number(e);
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
expect(e) {
|
|
2186
|
+
let t = this.t.consume();
|
|
2187
|
+
return t.type !== e && this._fail(`expected ${e}, got ${t.type} (${JSON.stringify(t.value)})`, t), t;
|
|
2188
|
+
}
|
|
2189
|
+
_fail(e, t) {
|
|
2190
|
+
let n = t ? ` at line ${t.line}, column ${t.col}` : "";
|
|
2191
|
+
throw SyntaxError(`EDN parse error${n}: ${e}`);
|
|
2192
|
+
}
|
|
2193
|
+
}, ot = new TextEncoder(), A = class extends d {
|
|
2194
|
+
indefiniteLength = !1;
|
|
2195
|
+
value;
|
|
2196
|
+
encodingWidth;
|
|
2197
|
+
constructor(e, t) {
|
|
2198
|
+
super(), this.value = e, this.encodingWidth = t?.encodingWidth;
|
|
2199
|
+
}
|
|
2200
|
+
_toCBOR(e) {
|
|
2201
|
+
let t = ot.encode(this.value);
|
|
2202
|
+
return v([_(3, BigInt(t.length), this.encodingWidth), t]);
|
|
2203
|
+
}
|
|
2204
|
+
_toEDN(e, t) {
|
|
2205
|
+
let n = this.encodingWidth === void 0 ? "" : `_${this.encodingWidth}`;
|
|
2206
|
+
return st(this.value, n, e, t);
|
|
2207
|
+
}
|
|
2208
|
+
_toJS(e) {
|
|
2209
|
+
return this.value;
|
|
2210
|
+
}
|
|
2211
|
+
};
|
|
2212
|
+
function st(e, t, n, r) {
|
|
2213
|
+
let i = n?.textStringFormat ?? [], a = ie(n);
|
|
2214
|
+
if (i.length === 0 || a === null) return we(e) + t;
|
|
2215
|
+
let o = /* @__PURE__ */ new Map();
|
|
2216
|
+
if (i.includes("cboredn")) {
|
|
2217
|
+
let t = lt(e);
|
|
2218
|
+
if (t !== null) for (let { point: e, contentDepth: n } of t) o.set(e, n);
|
|
2219
|
+
}
|
|
2220
|
+
if (i.includes("newline") && o.size === 0) for (let { point: t, contentDepth: n } of ct(e, 0)) o.set(t, n);
|
|
2221
|
+
let s = pt(e, o);
|
|
2222
|
+
if (s.length <= 1) return we(e) + t;
|
|
2223
|
+
let c = s.map(({ text: e }, n) => {
|
|
2224
|
+
let r = we(e);
|
|
2225
|
+
return n === s.length - 1 ? r + t : r;
|
|
2226
|
+
}), l = c[0];
|
|
2227
|
+
for (let e = 1; e < c.length; e++) {
|
|
2228
|
+
let t = x(a, r + 1 + s[e].contentDepth);
|
|
2229
|
+
l += ` +\n${t}${c[e]}`;
|
|
2230
|
+
}
|
|
2231
|
+
return l;
|
|
2232
|
+
}
|
|
2233
|
+
function ct(e, t) {
|
|
2234
|
+
let n = [];
|
|
2235
|
+
for (let r = 0; r < e.length; r++) {
|
|
2236
|
+
let i = e[r];
|
|
2237
|
+
i === "\r" ? e[r + 1] === "\n" ? (n.push({
|
|
2238
|
+
point: r + 2,
|
|
2239
|
+
contentDepth: t
|
|
2240
|
+
}), r++) : n.push({
|
|
2241
|
+
point: r + 1,
|
|
2242
|
+
contentDepth: t
|
|
2243
|
+
}) : i === "\n" && n.push({
|
|
2244
|
+
point: r + 1,
|
|
2245
|
+
contentDepth: t
|
|
2246
|
+
});
|
|
2247
|
+
}
|
|
2248
|
+
return n;
|
|
2249
|
+
}
|
|
2250
|
+
function lt(e) {
|
|
2251
|
+
try {
|
|
2252
|
+
Ke(e);
|
|
2253
|
+
} catch {
|
|
2254
|
+
return null;
|
|
2255
|
+
}
|
|
2256
|
+
let t = [], n = new je(e), r = 0, i = null, a = !1, o = 0;
|
|
2257
|
+
for (;;) {
|
|
2258
|
+
let e = n.consume();
|
|
2259
|
+
if (e.type === "EOF") break;
|
|
2260
|
+
let s = !1;
|
|
2261
|
+
a || (a = !0, e.offset > 0 && ft(n.comments, 0, e.offset) && t.push({
|
|
2262
|
+
point: e.offset,
|
|
2263
|
+
contentDepth: r
|
|
2264
|
+
})), i !== null && (dt.has(e.type) && e.offset === i.point ? s = !0 : t.push({
|
|
2265
|
+
point: e.offset,
|
|
2266
|
+
contentDepth: i.contentDepth
|
|
2267
|
+
}), i = null), ut.has(e.type) ? (r++, i = {
|
|
2268
|
+
point: e.endOffset,
|
|
2269
|
+
contentDepth: r
|
|
2270
|
+
}) : dt.has(e.type) ? (r = Math.max(0, r - 1), s || t.push({
|
|
2271
|
+
point: e.offset,
|
|
2272
|
+
contentDepth: r
|
|
2273
|
+
})) : e.type === "COMMA" && (i = {
|
|
2274
|
+
point: e.endOffset,
|
|
2275
|
+
contentDepth: r
|
|
2276
|
+
}), o = e.endOffset;
|
|
2277
|
+
}
|
|
2278
|
+
let s = n.comments.find((e) => e.start >= o);
|
|
2279
|
+
return s !== void 0 && t.push({
|
|
2280
|
+
point: s.start,
|
|
2281
|
+
contentDepth: r
|
|
2282
|
+
}), t;
|
|
2283
|
+
}
|
|
2284
|
+
var ut = new Set([
|
|
2285
|
+
"LBRACKET",
|
|
2286
|
+
"LBRACE",
|
|
2287
|
+
"LPAREN",
|
|
2288
|
+
"LT_LT"
|
|
2289
|
+
]), dt = new Set([
|
|
2290
|
+
"RBRACKET",
|
|
2291
|
+
"RBRACE",
|
|
2292
|
+
"RPAREN",
|
|
2293
|
+
"GT_GT"
|
|
2294
|
+
]);
|
|
2295
|
+
function ft(e, t, n) {
|
|
2296
|
+
return e.some((e) => e.start >= t && e.end <= n);
|
|
2297
|
+
}
|
|
2298
|
+
function pt(e, t) {
|
|
2299
|
+
let n = [...t].filter(([t]) => t > 0 && t < e.length).sort(([e], [t]) => e - t);
|
|
2300
|
+
if (n.length === 0) return [{
|
|
2301
|
+
text: e,
|
|
2302
|
+
contentDepth: 0
|
|
2303
|
+
}];
|
|
2304
|
+
let r = [], i = 0, a = 0;
|
|
2305
|
+
for (let [t, o] of n) t !== i && (r.push({
|
|
2306
|
+
text: e.slice(i, t),
|
|
2307
|
+
contentDepth: a
|
|
2308
|
+
}), i = t, a = o);
|
|
2309
|
+
return i < e.length && r.push({
|
|
2310
|
+
text: e.slice(i),
|
|
2311
|
+
contentDepth: a
|
|
2312
|
+
}), r;
|
|
2313
|
+
}
|
|
2314
|
+
//#endregion
|
|
2315
|
+
//#region src/extensions/dt.ts
|
|
2316
|
+
function j(e) {
|
|
2317
|
+
if (Number.isInteger(e)) return (/* @__PURE__ */ new Date(e * 1e3)).toISOString().replace(/\.000Z$/, "Z");
|
|
2318
|
+
let t = Math.round(e * 1e3);
|
|
2319
|
+
if (t / 1e3 === e) return new Date(t).toISOString().replace(/\.000Z$/, "Z");
|
|
2320
|
+
let n = Math.floor(e), r = e - n, i = (/* @__PURE__ */ new Date(n * 1e3)).toISOString().replace(/\.\d+Z$/, ""), a = r.toString(), o = a.indexOf("."), s = o >= 0 ? a.slice(o + 1) : "0";
|
|
2321
|
+
for (; s.length < 3;) s += "0";
|
|
2322
|
+
return `${i}.${s}Z`;
|
|
2323
|
+
}
|
|
2324
|
+
function mt(e) {
|
|
2325
|
+
if (e.length !== 1) throw SyntaxError("dt<<...>>: expected exactly one item");
|
|
2326
|
+
let t = e[0];
|
|
2327
|
+
if (t instanceof A) return t.value;
|
|
2328
|
+
if (t instanceof w) return new TextDecoder("utf-8", { fatal: !0 }).decode(t.value);
|
|
2329
|
+
throw SyntaxError("dt<<...>>: expected a text string or byte string");
|
|
2330
|
+
}
|
|
2331
|
+
function ht(e) {
|
|
2332
|
+
let t = e.match(/^(.+T\d{2}:\d{2}:\d{2})(\.\d+)(Z|[+-]\d{2}:\d{2})$/i), n, r;
|
|
2333
|
+
t ? (n = t[1] + t[3], r = parseFloat("0" + t[2])) : (n = e, r = void 0);
|
|
2334
|
+
let i = Date.parse(n);
|
|
2335
|
+
if (isNaN(i)) throw SyntaxError(`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`);
|
|
2336
|
+
if (r === void 0) {
|
|
2337
|
+
let e = i / 1e3;
|
|
2338
|
+
return e >= 0 ? new _t(BigInt(e)) : new vt(BigInt(e));
|
|
2339
|
+
}
|
|
2340
|
+
return new yt(i / 1e3 + r);
|
|
2341
|
+
}
|
|
2342
|
+
var gt = 1n, _t = class extends y {
|
|
2343
|
+
constructor(e, t) {
|
|
2344
|
+
super(e, t);
|
|
2345
|
+
}
|
|
2346
|
+
_toEDN(e, t) {
|
|
2347
|
+
return e?.appStrings === !1 ? super._toEDN(e, t) : `dt'${j(Number(this.value))}'`;
|
|
2348
|
+
}
|
|
2349
|
+
}, vt = class extends b {
|
|
2350
|
+
constructor(e, t) {
|
|
2351
|
+
super(e, t);
|
|
2352
|
+
}
|
|
2353
|
+
_toEDN(e, t) {
|
|
2354
|
+
return e?.appStrings === !1 ? super._toEDN(e, t) : `dt'${j(Number(this.value))}'`;
|
|
2355
|
+
}
|
|
2356
|
+
}, yt = class extends S {
|
|
2357
|
+
constructor(e, t) {
|
|
2358
|
+
super(e, t);
|
|
2359
|
+
}
|
|
2360
|
+
_toEDN(e, t) {
|
|
2361
|
+
return e?.appStrings === !1 ? super._toEDN(e, t) : `dt'${j(this.value)}'`;
|
|
2362
|
+
}
|
|
2363
|
+
}, bt = class extends C {
|
|
2364
|
+
constructor(e, t) {
|
|
2365
|
+
super(gt, ht(e), t);
|
|
2366
|
+
}
|
|
2367
|
+
_toEDN(e, t) {
|
|
2368
|
+
if (e?.appStrings === !1) return super._toEDN(e, t);
|
|
2369
|
+
let n = this.content;
|
|
2370
|
+
return `DT'${j(n instanceof S ? n.value : Number(n.value))}'`;
|
|
2371
|
+
}
|
|
2372
|
+
}, xt = class extends bt {
|
|
2373
|
+
constructor(e, t) {
|
|
2374
|
+
super(e, t);
|
|
2375
|
+
}
|
|
2376
|
+
_toJS(e) {
|
|
2377
|
+
let t = this.content, n = t instanceof S ? t.value * 1e3 : Number(t.value) * 1e3;
|
|
2378
|
+
return new Date(n);
|
|
2379
|
+
}
|
|
2380
|
+
};
|
|
2381
|
+
function St(e) {
|
|
2382
|
+
let t = e?.jsDate ?? !1;
|
|
2383
|
+
function n(e) {
|
|
2384
|
+
return t ? new xt(e) : new bt(e);
|
|
2385
|
+
}
|
|
2386
|
+
let r = {
|
|
2387
|
+
appStringPrefixes: ["dt", "DT"],
|
|
2388
|
+
tagNumbers: [gt],
|
|
2389
|
+
parseAppString(e, t) {
|
|
2390
|
+
return e === "DT" ? n(t) : ht(t);
|
|
2391
|
+
},
|
|
2392
|
+
parseAppSequence(e, t) {
|
|
2393
|
+
let r = mt(t);
|
|
2394
|
+
return e === "DT" ? n(r) : ht(r);
|
|
2395
|
+
},
|
|
2396
|
+
parseTag(e, t) {
|
|
2397
|
+
if (e !== 1n) return;
|
|
2398
|
+
let r;
|
|
2399
|
+
if (t instanceof y) r = Number(t.value);
|
|
2400
|
+
else if (t instanceof b) r = Number(t.value);
|
|
2401
|
+
else if (t instanceof S) r = t.value;
|
|
2402
|
+
else return;
|
|
2403
|
+
return n(j(r));
|
|
2404
|
+
}
|
|
2405
|
+
};
|
|
2406
|
+
return t && (r.fromJS = (e, t) => {
|
|
2407
|
+
if (e instanceof Date) return new xt(j(e.getTime() / 1e3));
|
|
2408
|
+
}, r.isJSType = (e) => e instanceof Date), r;
|
|
2409
|
+
}
|
|
2410
|
+
var Ct = St(), wt = St({ jsDate: !0 });
|
|
2411
|
+
//#endregion
|
|
2412
|
+
//#region src/utils/ip.ts
|
|
2413
|
+
function Tt(e) {
|
|
2414
|
+
let t = e.split(".");
|
|
2415
|
+
if (t.length !== 4) throw SyntaxError(`ip: invalid IPv4 address: ${JSON.stringify(e)}`);
|
|
2416
|
+
let n = new Uint8Array(4);
|
|
2417
|
+
for (let e = 0; e < 4; e++) {
|
|
2418
|
+
let r = t[e];
|
|
2419
|
+
if (!/^\d+$/.test(r) || r.length > 1 && r[0] === "0") throw SyntaxError(`ip: invalid IPv4 octet: ${JSON.stringify(r)}`);
|
|
2420
|
+
let i = parseInt(r, 10);
|
|
2421
|
+
if (i > 255) throw SyntaxError(`ip: IPv4 octet out of range: ${i}`);
|
|
2422
|
+
n[e] = i;
|
|
2423
|
+
}
|
|
2424
|
+
return n;
|
|
2425
|
+
}
|
|
2426
|
+
function Et(e) {
|
|
2427
|
+
let t = new Uint8Array(16);
|
|
2428
|
+
if (e === "::") return t;
|
|
2429
|
+
let n = e, r = null, i = e.match(/^(.*):(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
|
|
2430
|
+
i && (n = i[1], n.endsWith(":") && (n += ":"), r = Tt(i[2]));
|
|
2431
|
+
let a = n.split("::");
|
|
2432
|
+
if (a.length > 2) throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);
|
|
2433
|
+
let o = a.length === 2, s = a[0] ? a[0].split(":") : [], c = o && a[1] ? a[1].split(":") : [], l = r ? 6 : 8;
|
|
2434
|
+
if (!o && s.length !== l || o && s.length + c.length >= l) throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);
|
|
2435
|
+
let u = l - s.length - c.length, d = [
|
|
2436
|
+
...s,
|
|
2437
|
+
...Array(u).fill("0"),
|
|
2438
|
+
...c
|
|
2439
|
+
], f = 0;
|
|
2440
|
+
for (let e of d) {
|
|
2441
|
+
if (!/^[0-9a-fA-F]{1,4}$/.test(e)) throw SyntaxError(`ip: invalid IPv6 group: ${JSON.stringify(e)}`);
|
|
2442
|
+
let n = parseInt(e, 16);
|
|
2443
|
+
t[f++] = n >> 8 & 255, t[f++] = n & 255;
|
|
2444
|
+
}
|
|
2445
|
+
return r && t.set(r, 12), t;
|
|
2446
|
+
}
|
|
2447
|
+
function Dt(e) {
|
|
2448
|
+
return Array.from(e).join(".");
|
|
2449
|
+
}
|
|
2450
|
+
function Ot(e) {
|
|
2451
|
+
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ? Dt(e.slice(12)) : null, n = t ? 6 : 8, r = [];
|
|
2452
|
+
for (let t = 0; t < n * 2; t += 2) r.push(e[t] << 8 | e[t + 1]);
|
|
2453
|
+
let i = -1, a = 0, o = 0;
|
|
2454
|
+
for (; o < n;) if (r[o] === 0) {
|
|
2455
|
+
let e = o + 1;
|
|
2456
|
+
for (; e < n && r[e] === 0;) e++;
|
|
2457
|
+
e - o > a && (i = o, a = e - o), o = e;
|
|
2458
|
+
} else o++;
|
|
2459
|
+
a < 2 && (i = -1);
|
|
2460
|
+
let s = (e) => e.toString(16), c;
|
|
2461
|
+
return c = i === -1 ? r.map(s).join(":") : `${r.slice(0, i).map(s).join(":")}::${r.slice(i + a).map(s).join(":")}`, t ? `${c}:${t}` : c;
|
|
2462
|
+
}
|
|
2463
|
+
//#endregion
|
|
2464
|
+
//#region src/extensions/ip.ts
|
|
2465
|
+
var kt = "ip", At = "IP", jt = 52n, Mt = 54n;
|
|
2466
|
+
function Nt(e) {
|
|
2467
|
+
if (e.length !== 1) throw SyntaxError("ip<<...>>: expected exactly one item");
|
|
2468
|
+
let t = e[0];
|
|
2469
|
+
if (t instanceof A) return t.value;
|
|
2470
|
+
if (t instanceof w) return new TextDecoder("utf-8", { fatal: !0 }).decode(t.value);
|
|
2471
|
+
throw SyntaxError("ip<<...>>: expected a text string or byte string");
|
|
2472
|
+
}
|
|
2473
|
+
function Pt(e) {
|
|
2474
|
+
return /^\d/.test(e) && e.includes(".") && !e.includes(":") ? {
|
|
2475
|
+
bytes: Tt(e),
|
|
2476
|
+
isV4: !0
|
|
2477
|
+
} : {
|
|
2478
|
+
bytes: Et(e),
|
|
2479
|
+
isV4: !1
|
|
2480
|
+
};
|
|
2481
|
+
}
|
|
2482
|
+
function Ft(e) {
|
|
2483
|
+
if (e.length === 4) return Dt(e);
|
|
2484
|
+
if (e.length === 16) return Ot(e);
|
|
2485
|
+
throw SyntaxError(`ip: unexpected byte length: ${e.length}`);
|
|
2486
|
+
}
|
|
2487
|
+
function It(e, t) {
|
|
2488
|
+
let n = new Uint8Array(e.length);
|
|
2489
|
+
n.set(e);
|
|
2490
|
+
let r = Math.floor(t / 8), i = t % 8;
|
|
2491
|
+
i > 0 && r < e.length && (n[r] &= 255 << 8 - i & 255);
|
|
2492
|
+
for (let t = r + +(i > 0); t < e.length; t++) n[t] = 0;
|
|
2493
|
+
let a = Math.ceil(t / 8);
|
|
2494
|
+
for (; a > 0 && n[a - 1] === 0;) a--;
|
|
2495
|
+
return n.slice(0, a);
|
|
2496
|
+
}
|
|
2497
|
+
function Lt(e, t) {
|
|
2498
|
+
let n = new Uint8Array(t);
|
|
2499
|
+
return n.set(e), n;
|
|
2500
|
+
}
|
|
2501
|
+
var Rt = class extends w {
|
|
2502
|
+
_toEDN(e, t) {
|
|
2503
|
+
return e?.appStrings === !1 ? super._toEDN(e, t) : `${kt}'${Ft(this.value)}'`;
|
|
2504
|
+
}
|
|
2505
|
+
}, zt = class extends E {
|
|
2506
|
+
_isV4;
|
|
2507
|
+
constructor(e, t, n) {
|
|
2508
|
+
super([new y(BigInt(e)), new w(t)]), this._isV4 = n;
|
|
2509
|
+
}
|
|
2510
|
+
_toEDN(e, t) {
|
|
2511
|
+
if (e?.appStrings === !1) return super._toEDN(e, t);
|
|
2512
|
+
let n = Number(this.items[0].value), r = this.items[1].value;
|
|
2513
|
+
return `${kt}'${Ft(Lt(r, this._isV4 ? 4 : 16))}/${n}'`;
|
|
2514
|
+
}
|
|
2515
|
+
}, Bt = class extends C {
|
|
2516
|
+
constructor(e, t) {
|
|
2517
|
+
super(e, t);
|
|
2518
|
+
}
|
|
2519
|
+
_toEDN(e, t) {
|
|
2520
|
+
if (e?.appStrings === !1) return super._toEDN(e, t);
|
|
2521
|
+
let n = this.tag === jt ? 4 : 16, r = this.content;
|
|
2522
|
+
if (r instanceof w) return `${At}'${Ft(r.value)}'`;
|
|
2523
|
+
if (r instanceof E && r.items.length === 2 && r.items[0] instanceof y && r.items[1] instanceof w) {
|
|
2524
|
+
let e = Number(r.items[0].value);
|
|
2525
|
+
return `${At}'${Ft(Lt(r.items[1].value, n))}/${e}'`;
|
|
2526
|
+
}
|
|
2527
|
+
return super._toEDN(e, t);
|
|
2528
|
+
}
|
|
2529
|
+
};
|
|
2530
|
+
function Vt(e, t) {
|
|
2531
|
+
let n = t.indexOf("/");
|
|
2532
|
+
if (n === -1) {
|
|
2533
|
+
let { bytes: n, isV4: r } = Pt(t);
|
|
2534
|
+
return e === At ? new Bt(r ? jt : Mt, new w(n)) : new Rt(n);
|
|
2535
|
+
}
|
|
2536
|
+
let r = t.slice(0, n), i = t.slice(n + 1);
|
|
2537
|
+
if (!/^\d+$/.test(i)) throw SyntaxError(`ip: invalid prefix length: ${JSON.stringify(i)}`);
|
|
2538
|
+
let a = parseInt(i, 10), { bytes: o, isV4: s } = Pt(r), c = s ? 32 : 128;
|
|
2539
|
+
if (a > c) throw SyntaxError(`ip: prefix length ${a} exceeds maximum ${c} for ${s ? "IPv4" : "IPv6"}`);
|
|
2540
|
+
let l = It(o, a);
|
|
2541
|
+
return e === At ? new Bt(s ? jt : Mt, new E([new y(BigInt(a)), new w(l)])) : new zt(a, l, s);
|
|
2542
|
+
}
|
|
2543
|
+
var Ht = {
|
|
2544
|
+
appStringPrefixes: [kt, At],
|
|
2545
|
+
tagNumbers: [jt, Mt],
|
|
2546
|
+
parseAppString(e, t) {
|
|
2547
|
+
return Vt(e, t);
|
|
2548
|
+
},
|
|
2549
|
+
parseAppSequence(e, t) {
|
|
2550
|
+
return Vt(e, Nt(t));
|
|
2551
|
+
},
|
|
2552
|
+
parseTag(e, t) {
|
|
2553
|
+
if (!(e !== jt && e !== Mt) && (t instanceof w || t instanceof E)) return new Bt(e, t);
|
|
2554
|
+
}
|
|
2555
|
+
}, Ut = 18446744073709551615n, Wt = -(Ut + 1n), Gt = {
|
|
2556
|
+
tagNumbers: [Re, ze],
|
|
2557
|
+
parseTag(e, t) {
|
|
2558
|
+
if (t instanceof w) {
|
|
2559
|
+
if (e === 2n) {
|
|
2560
|
+
let e = Ue(t.value);
|
|
2561
|
+
return e > Ut ? new We(e) : void 0;
|
|
2562
|
+
}
|
|
2563
|
+
if (e === 3n) {
|
|
2564
|
+
let e = -1n - Ue(t.value);
|
|
2565
|
+
return e < Wt ? new Ge(e) : void 0;
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
}, Kt = "cri", qt = "CRI", Jt = 99n, Yt = new Map([
|
|
2570
|
+
["coap", -1n],
|
|
2571
|
+
["coaps", -2n],
|
|
2572
|
+
["http", -3n],
|
|
2573
|
+
["https", -4n],
|
|
2574
|
+
["urn", -5n],
|
|
2575
|
+
["did", -6n],
|
|
2576
|
+
["coap+tcp", -7n],
|
|
2577
|
+
["coaps+tcp", -8n],
|
|
2578
|
+
["coap+ws", -25n],
|
|
2579
|
+
["coaps+ws", -26n]
|
|
2580
|
+
]), Xt = new Map([...Yt.entries()].map(([e, t]) => [t, e]));
|
|
2581
|
+
function M(e) {
|
|
2582
|
+
try {
|
|
2583
|
+
return decodeURIComponent(e);
|
|
2584
|
+
} catch {
|
|
2585
|
+
return e;
|
|
2586
|
+
}
|
|
2587
|
+
}
|
|
2588
|
+
function Zt(e) {
|
|
2589
|
+
return Array.from(new TextEncoder().encode(e), (e) => `%${e.toString(16).toUpperCase().padStart(2, "0")}`).join("");
|
|
2590
|
+
}
|
|
2591
|
+
function N(e, t) {
|
|
2592
|
+
let n = "";
|
|
2593
|
+
for (let r of e) n += t(r) ? r : Zt(r);
|
|
2594
|
+
return n;
|
|
2595
|
+
}
|
|
2596
|
+
function Qt(e) {
|
|
2597
|
+
return /[A-Za-z0-9\-._~]/.test(e);
|
|
2598
|
+
}
|
|
2599
|
+
function $t(e) {
|
|
2600
|
+
return /[!$&'()*+,;=]/.test(e);
|
|
2601
|
+
}
|
|
2602
|
+
function en(e) {
|
|
2603
|
+
return Qt(e) || $t(e) || e === ":" || e === "@";
|
|
2604
|
+
}
|
|
2605
|
+
function tn(e) {
|
|
2606
|
+
return (en(e) || e === "/" || e === "?") && e !== "&";
|
|
2607
|
+
}
|
|
2608
|
+
function nn(e) {
|
|
2609
|
+
return en(e) || e === "/" || e === "?";
|
|
2610
|
+
}
|
|
2611
|
+
function rn(e) {
|
|
2612
|
+
return Qt(e) || $t(e) || e === ":";
|
|
2613
|
+
}
|
|
2614
|
+
function an(e) {
|
|
2615
|
+
return Qt(e) || $t(e);
|
|
2616
|
+
}
|
|
2617
|
+
function on(e) {
|
|
2618
|
+
let t = [], n = e, r = n.indexOf("@");
|
|
2619
|
+
r >= 0 && (t.push(O.FALSE), t.push(new A(M(n.slice(0, r)))), n = n.slice(r + 1));
|
|
2620
|
+
let i, a = null;
|
|
2621
|
+
if (n.startsWith("[")) {
|
|
2622
|
+
let e = n.indexOf("]");
|
|
2623
|
+
if (e < 0) throw SyntaxError("cri: unterminated IPv6 bracket in authority");
|
|
2624
|
+
i = n.slice(1, e);
|
|
2625
|
+
let r = n.slice(e + 1);
|
|
2626
|
+
if (r.startsWith(":")) a = r.slice(1);
|
|
2627
|
+
else if (r.length > 0) throw SyntaxError("cri: unexpected characters after ']' in authority");
|
|
2628
|
+
t.push(new w(Et(i)));
|
|
2629
|
+
} else {
|
|
2630
|
+
let e = n.lastIndexOf(":");
|
|
2631
|
+
if (e >= 0 ? (i = n.slice(0, e), a = n.slice(e + 1)) : i = n, i !== "") if (/^\d{1,3}(\.\d{1,3}){3}$/.test(i)) t.push(new w(Tt(i)));
|
|
2632
|
+
else for (let e of i.toLowerCase().split(".")) t.push(new A(e));
|
|
2633
|
+
}
|
|
2634
|
+
if (a !== null && a !== "") {
|
|
2635
|
+
if (!/^\d+$/.test(a)) throw SyntaxError(`cri: invalid port: ${JSON.stringify(a)}`);
|
|
2636
|
+
let e = parseInt(a, 10);
|
|
2637
|
+
if (e > 65535) throw SyntaxError(`cri: port ${e} out of range`);
|
|
2638
|
+
t.push(new y(BigInt(e)));
|
|
2639
|
+
}
|
|
2640
|
+
return new E(t);
|
|
2641
|
+
}
|
|
2642
|
+
function sn(e) {
|
|
2643
|
+
let t = e.items, n = 0, r = "";
|
|
2644
|
+
if (n < t.length && t[n] instanceof O && t[n].value === 20) {
|
|
2645
|
+
n++;
|
|
2646
|
+
let e = t[n++];
|
|
2647
|
+
r += N(e.value, rn) + "@";
|
|
2648
|
+
}
|
|
2649
|
+
if (n >= t.length) return r;
|
|
2650
|
+
let i = t[n];
|
|
2651
|
+
if (i instanceof w) {
|
|
2652
|
+
n++;
|
|
2653
|
+
let { length: e } = i.value;
|
|
2654
|
+
if (e === 4) r += Dt(i.value);
|
|
2655
|
+
else if (e === 16) r += "[" + Ot(i.value) + "]";
|
|
2656
|
+
else throw Error(`cri: unexpected host-ip byte length: ${e}`);
|
|
2657
|
+
n < t.length && t[n] instanceof A && (r += `%25${N(t[n++].value, an)}`);
|
|
2658
|
+
} else {
|
|
2659
|
+
let e = [];
|
|
2660
|
+
for (; n < t.length && t[n] instanceof A;) e.push(N(t[n++].value, an));
|
|
2661
|
+
r += e.join(".");
|
|
2662
|
+
}
|
|
2663
|
+
return n < t.length && t[n] instanceof y && (r += ":" + t[n].value.toString()), r;
|
|
2664
|
+
}
|
|
2665
|
+
function cn(e) {
|
|
2666
|
+
let t = e.slice(2), n = t.indexOf("/"), r, i;
|
|
2667
|
+
return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new A(M(e)))) : (r = t, i = []), {
|
|
2668
|
+
authority: on(r),
|
|
2669
|
+
pathSegments: i
|
|
2670
|
+
};
|
|
2671
|
+
}
|
|
2672
|
+
function ln(e) {
|
|
2673
|
+
let t = e, n = null, r = t.indexOf("#");
|
|
2674
|
+
r >= 0 && (n = M(t.slice(r + 1)), t = t.slice(0, r));
|
|
2675
|
+
let i = null, a = t.indexOf("?");
|
|
2676
|
+
if (a >= 0) {
|
|
2677
|
+
let e = t.slice(a + 1);
|
|
2678
|
+
t = t.slice(0, a), i = e.split("&").map((e) => new A(M(e)));
|
|
2679
|
+
}
|
|
2680
|
+
let o = [], s = /^([a-zA-Z][a-zA-Z0-9+.\-]*):([\s\S]*)$/.exec(t);
|
|
2681
|
+
if (s) {
|
|
2682
|
+
let e = s[1].toLowerCase(), t = s[2], n = Yt.get(e);
|
|
2683
|
+
if (o.push(n === void 0 ? new A(e) : new b(n)), t.startsWith("//")) {
|
|
2684
|
+
let { authority: e, pathSegments: n } = cn(t);
|
|
2685
|
+
o.push(e, new E(n));
|
|
2686
|
+
} else if (t.startsWith("/")) {
|
|
2687
|
+
let e = t.slice(1).split("/").map((e) => new A(M(e)));
|
|
2688
|
+
o.push(O.NULL, new E(e));
|
|
2689
|
+
} else {
|
|
2690
|
+
let e = t.split("/").map((e) => new A(M(e)));
|
|
2691
|
+
o.push(O.TRUE, new E(e));
|
|
2692
|
+
}
|
|
2693
|
+
} else if (t.startsWith("//")) {
|
|
2694
|
+
let { authority: e, pathSegments: n } = cn(t);
|
|
2695
|
+
o.push(O.FALSE, e, new E(n));
|
|
2696
|
+
} else if (t.startsWith("/")) {
|
|
2697
|
+
let e = t.slice(1).split("/").map((e) => new A(M(e)));
|
|
2698
|
+
o.push(O.TRUE, new E(e));
|
|
2699
|
+
} else if (t === "") o.push(new y(0n));
|
|
2700
|
+
else {
|
|
2701
|
+
let n = 1n, r = t, i = !1;
|
|
2702
|
+
for (r.startsWith("./") && (i = !0, r = r.slice(2)); r.startsWith("../");) n++, r = r.slice(3);
|
|
2703
|
+
if (r === ".." ? (n++, r = "") : r === "." && (r = ""), n === 1n && !i && r !== "" && r.split("/")[0].includes(":")) throw SyntaxError(`cri: invalid relative-path reference — first segment must not contain ':' without a './' prefix (RFC 3986 §3.3): ${JSON.stringify(e)}`);
|
|
2704
|
+
let a = r === "" ? [] : r.split("/").map((e) => new A(M(e)));
|
|
2705
|
+
o.push(new y(n), new E(a));
|
|
2706
|
+
}
|
|
2707
|
+
if (i !== null && o.push(new E(i)), n !== null && (i === null && o.push(O.NULL), o.push(new A(n))), n !== null && i === null && o.splice(o.length - 2, 1), i === null && n === null) {
|
|
2708
|
+
let e = o[o.length - 1];
|
|
2709
|
+
e instanceof E && e.items.length === 0 && o.pop();
|
|
2710
|
+
}
|
|
2711
|
+
return o.length === 1 && o[0] instanceof y && o[0].value === 0n ? [] : o;
|
|
2712
|
+
}
|
|
2713
|
+
function un(e, t) {
|
|
2714
|
+
let n = t, r = "";
|
|
2715
|
+
if (n < e.length) {
|
|
2716
|
+
let t = e[n];
|
|
2717
|
+
if (t instanceof E) {
|
|
2718
|
+
if (n++, t.items.length > 0) {
|
|
2719
|
+
let e = t.items.map((e) => {
|
|
2720
|
+
if (!(e instanceof A)) throw Error("cri: query item must be a text string");
|
|
2721
|
+
return N(e.value, tn);
|
|
2722
|
+
});
|
|
2723
|
+
r += "?" + e.join("&");
|
|
2724
|
+
}
|
|
2725
|
+
} else t instanceof O && t.value === 22 && n++;
|
|
2726
|
+
}
|
|
2727
|
+
return n < e.length && e[n] instanceof A && (r += "#" + N(e[n].value, nn)), r;
|
|
2728
|
+
}
|
|
2729
|
+
function dn(e) {
|
|
2730
|
+
return e.items.map((e) => {
|
|
2731
|
+
if (!(e instanceof A)) throw Error("cri: path segment must be a text string");
|
|
2732
|
+
return N(e.value, en);
|
|
2733
|
+
});
|
|
2734
|
+
}
|
|
2735
|
+
function fn(e) {
|
|
2736
|
+
if (e.length === 0) return "";
|
|
2737
|
+
let t = 0, n = e[t++];
|
|
2738
|
+
if (n instanceof b || n instanceof A) {
|
|
2739
|
+
let r;
|
|
2740
|
+
if (n instanceof b) {
|
|
2741
|
+
let e = Xt.get(n.value);
|
|
2742
|
+
if (e === void 0) throw Error(`cri: unrecognised scheme-id ${n.value}`);
|
|
2743
|
+
r = e + ":";
|
|
2744
|
+
} else r = n.value + ":";
|
|
2745
|
+
if (t >= e.length) return r;
|
|
2746
|
+
let i = e[t++], a = "", o = !1;
|
|
2747
|
+
if (i instanceof E) a = "//" + sn(i), o = !0;
|
|
2748
|
+
else if (i instanceof O) if (i.value === 22) o = !0;
|
|
2749
|
+
else if (i.value === 21) o = !1;
|
|
2750
|
+
else throw Error(`cri: unexpected no-authority value: simple(${i.value})`);
|
|
2751
|
+
else throw Error("cri: unexpected type for authority element");
|
|
2752
|
+
let s = "";
|
|
2753
|
+
if (t < e.length && e[t] instanceof E) {
|
|
2754
|
+
let n = e[t++];
|
|
2755
|
+
n.items.length > 0 && (s = (o ? "/" : "") + dn(n).join("/"));
|
|
2756
|
+
}
|
|
2757
|
+
return r + a + s + un(e, t);
|
|
2758
|
+
}
|
|
2759
|
+
if (n instanceof O && n.value === 20) {
|
|
2760
|
+
if (t >= e.length || !(e[t] instanceof E)) throw Error("cri: network-path reference requires an authority array");
|
|
2761
|
+
let n = sn(e[t++]), r = "";
|
|
2762
|
+
if (t < e.length && e[t] instanceof E) {
|
|
2763
|
+
let n = e[t++];
|
|
2764
|
+
n.items.length > 0 && (r = "/" + dn(n).join("/"));
|
|
2765
|
+
}
|
|
2766
|
+
return "//" + n + r + un(e, t);
|
|
2767
|
+
}
|
|
2768
|
+
if (n instanceof O && n.value === 21) {
|
|
2769
|
+
let n = "/";
|
|
2770
|
+
if (t < e.length && e[t] instanceof E) {
|
|
2771
|
+
let r = e[t++];
|
|
2772
|
+
n = "/" + dn(r).join("/");
|
|
2773
|
+
}
|
|
2774
|
+
return n + un(e, t);
|
|
2775
|
+
}
|
|
2776
|
+
if (n instanceof y) {
|
|
2777
|
+
let r = n.value;
|
|
2778
|
+
if (r === 0n) return un(e, t);
|
|
2779
|
+
let i = r === 1n ? "" : "../".repeat(Number(r) - 1), a;
|
|
2780
|
+
if (t < e.length && e[t] instanceof E) {
|
|
2781
|
+
let n = e[t++];
|
|
2782
|
+
if (n.items.length > 0) {
|
|
2783
|
+
let e = dn(n);
|
|
2784
|
+
a = (r === 1n && e[0].includes(":") ? "./" : i) + e.join("/");
|
|
2785
|
+
} else a = i === "" ? "./" : i;
|
|
2786
|
+
} else a = i === "" ? "./" : i;
|
|
2787
|
+
return a + un(e, t);
|
|
2788
|
+
}
|
|
2789
|
+
throw Error("cri: unrecognised first element type in CRI array");
|
|
2790
|
+
}
|
|
2791
|
+
var pn = class extends E {
|
|
2792
|
+
_toEDN(e, t) {
|
|
2793
|
+
if (e?.appStrings === !1) return super._toEDN(e, t);
|
|
2794
|
+
try {
|
|
2795
|
+
return `${Kt}'${fn(this.items)}'`;
|
|
2796
|
+
} catch {
|
|
2797
|
+
return super._toEDN(e, t);
|
|
2798
|
+
}
|
|
2799
|
+
}
|
|
2800
|
+
}, mn = class extends C {
|
|
2801
|
+
constructor(e) {
|
|
2802
|
+
super(Jt, e);
|
|
2803
|
+
}
|
|
2804
|
+
_toEDN(e, t) {
|
|
2805
|
+
if (e?.appStrings === !1) return super._toEDN(e, t);
|
|
2806
|
+
try {
|
|
2807
|
+
return `${qt}'${fn(this.content.items)}'`;
|
|
2808
|
+
} catch {
|
|
2809
|
+
return super._toEDN(e, t);
|
|
2810
|
+
}
|
|
2811
|
+
}
|
|
2812
|
+
};
|
|
2813
|
+
function hn(e) {
|
|
2814
|
+
if (e.length !== 1) throw SyntaxError("cri<<...>>: expected exactly one item");
|
|
2815
|
+
let t = e[0];
|
|
2816
|
+
if (t instanceof A) return t.value;
|
|
2817
|
+
if (t instanceof w) return new TextDecoder("utf-8", { fatal: !0 }).decode(t.value);
|
|
2818
|
+
throw SyntaxError("cri<<...>>: expected a text string or byte string");
|
|
2819
|
+
}
|
|
2820
|
+
function gn(e, t) {
|
|
2821
|
+
let n = new pn(ln(t));
|
|
2822
|
+
return e === qt ? new mn(n) : n;
|
|
2823
|
+
}
|
|
2824
|
+
var _n = {
|
|
2825
|
+
appStringPrefixes: [Kt, qt],
|
|
2826
|
+
tagNumbers: [Jt],
|
|
2827
|
+
parseAppString(e, t) {
|
|
2828
|
+
return gn(e, t);
|
|
2829
|
+
},
|
|
2830
|
+
parseAppSequence(e, t) {
|
|
2831
|
+
return gn(e, hn(t));
|
|
2832
|
+
},
|
|
2833
|
+
parseTag(e, t) {
|
|
2834
|
+
if (e === 99n && t instanceof E) return new mn(new pn(t.items, {
|
|
2835
|
+
indefiniteLength: t.indefiniteLength,
|
|
2836
|
+
encodingWidth: t.encodingWidth
|
|
2837
|
+
}));
|
|
2838
|
+
}
|
|
2839
|
+
};
|
|
2840
|
+
//#endregion
|
|
2841
|
+
//#region node_modules/@noble/hashes/utils.js
|
|
2842
|
+
function vn(e) {
|
|
2843
|
+
return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in e && e.BYTES_PER_ELEMENT === 1;
|
|
2844
|
+
}
|
|
2845
|
+
function yn(e, t = "") {
|
|
2846
|
+
if (typeof e != "number") {
|
|
2847
|
+
let n = t && `"${t}" `;
|
|
2848
|
+
throw TypeError(`${n}expected number, got ${typeof e}`);
|
|
2849
|
+
}
|
|
2850
|
+
if (!Number.isSafeInteger(e) || e < 0) {
|
|
2851
|
+
let n = t && `"${t}" `;
|
|
2852
|
+
throw RangeError(`${n}expected integer >= 0, got ${e}`);
|
|
2853
|
+
}
|
|
2854
|
+
}
|
|
2855
|
+
function bn(e, t, n = "") {
|
|
2856
|
+
let r = vn(e), i = e?.length, a = t !== void 0;
|
|
2857
|
+
if (!r || a && i !== t) {
|
|
2858
|
+
let o = n && `"${n}" `, s = a ? ` of length ${t}` : "", c = r ? `length=${i}` : `type=${typeof e}`, l = o + "expected Uint8Array" + s + ", got " + c;
|
|
2859
|
+
throw r ? RangeError(l) : TypeError(l);
|
|
2860
|
+
}
|
|
2861
|
+
return e;
|
|
2862
|
+
}
|
|
2863
|
+
function xn(e, t = !0) {
|
|
2864
|
+
if (e.destroyed) throw Error("Hash instance has been destroyed");
|
|
2865
|
+
if (t && e.finished) throw Error("Hash#digest() has already been called");
|
|
2866
|
+
}
|
|
2867
|
+
function Sn(e, t) {
|
|
2868
|
+
bn(e, void 0, "digestInto() output");
|
|
2869
|
+
let n = t.outputLen;
|
|
2870
|
+
if (e.length < n) throw RangeError("\"digestInto() output\" expected to be of length >=" + n);
|
|
2871
|
+
}
|
|
2872
|
+
function Cn(e) {
|
|
2873
|
+
return new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4));
|
|
2874
|
+
}
|
|
2875
|
+
function P(...e) {
|
|
2876
|
+
for (let t = 0; t < e.length; t++) e[t].fill(0);
|
|
2877
|
+
}
|
|
2878
|
+
function wn(e) {
|
|
2879
|
+
return new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
2880
|
+
}
|
|
2881
|
+
function F(e, t) {
|
|
2882
|
+
return e << 32 - t | e >>> t;
|
|
2883
|
+
}
|
|
2884
|
+
function Tn(e, t) {
|
|
2885
|
+
return e << t | e >>> 32 - t >>> 0;
|
|
2886
|
+
}
|
|
2887
|
+
var En = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
2888
|
+
function Dn(e) {
|
|
2889
|
+
return e << 24 & 4278190080 | e << 8 & 16711680 | e >>> 8 & 65280 | e >>> 24 & 255;
|
|
2890
|
+
}
|
|
2891
|
+
function On(e) {
|
|
2892
|
+
for (let t = 0; t < e.length; t++) e[t] = Dn(e[t]);
|
|
2893
|
+
return e;
|
|
2894
|
+
}
|
|
2895
|
+
var kn = En ? (e) => e : On;
|
|
2896
|
+
typeof Uint8Array.from([]).toHex == "function" && Uint8Array.fromHex;
|
|
2897
|
+
function I(e, t = {}) {
|
|
2898
|
+
let n = (t, n) => e(n).update(t).digest(), r = e(void 0);
|
|
2899
|
+
return n.outputLen = r.outputLen, n.blockLen = r.blockLen, n.canXOF = r.canXOF, n.create = (t) => e(t), Object.assign(n, t), Object.freeze(n);
|
|
2900
|
+
}
|
|
2901
|
+
var L = (e) => ({ oid: Uint8Array.from([
|
|
2902
|
+
6,
|
|
2903
|
+
9,
|
|
2904
|
+
96,
|
|
2905
|
+
134,
|
|
2906
|
+
72,
|
|
2907
|
+
1,
|
|
2908
|
+
101,
|
|
2909
|
+
3,
|
|
2910
|
+
4,
|
|
2911
|
+
2,
|
|
2912
|
+
e
|
|
2913
|
+
]) });
|
|
2914
|
+
//#endregion
|
|
2915
|
+
//#region node_modules/@noble/hashes/_md.js
|
|
2916
|
+
function An(e, t, n) {
|
|
2917
|
+
return e & t ^ ~e & n;
|
|
2918
|
+
}
|
|
2919
|
+
function jn(e, t, n) {
|
|
2920
|
+
return e & t ^ e & n ^ t & n;
|
|
2921
|
+
}
|
|
2922
|
+
var Mn = class {
|
|
2923
|
+
blockLen;
|
|
2924
|
+
outputLen;
|
|
2925
|
+
canXOF = !1;
|
|
2926
|
+
padOffset;
|
|
2927
|
+
isLE;
|
|
2928
|
+
buffer;
|
|
2929
|
+
view;
|
|
2930
|
+
finished = !1;
|
|
2931
|
+
length = 0;
|
|
2932
|
+
pos = 0;
|
|
2933
|
+
destroyed = !1;
|
|
2934
|
+
constructor(e, t, n, r) {
|
|
2935
|
+
this.blockLen = e, this.outputLen = t, this.padOffset = n, this.isLE = r, this.buffer = new Uint8Array(e), this.view = wn(this.buffer);
|
|
2936
|
+
}
|
|
2937
|
+
update(e) {
|
|
2938
|
+
xn(this), bn(e);
|
|
2939
|
+
let { view: t, buffer: n, blockLen: r } = this, i = e.length;
|
|
2940
|
+
for (let a = 0; a < i;) {
|
|
2941
|
+
let o = Math.min(r - this.pos, i - a);
|
|
2942
|
+
if (o === r) {
|
|
2943
|
+
let t = wn(e);
|
|
2944
|
+
for (; r <= i - a; a += r) this.process(t, a);
|
|
2945
|
+
continue;
|
|
2946
|
+
}
|
|
2947
|
+
n.set(e.subarray(a, a + o), this.pos), this.pos += o, a += o, this.pos === r && (this.process(t, 0), this.pos = 0);
|
|
2948
|
+
}
|
|
2949
|
+
return this.length += e.length, this.roundClean(), this;
|
|
2950
|
+
}
|
|
2951
|
+
digestInto(e) {
|
|
2952
|
+
xn(this), Sn(e, this), this.finished = !0;
|
|
2953
|
+
let { buffer: t, view: n, blockLen: r, isLE: i } = this, { pos: a } = this;
|
|
2954
|
+
t[a++] = 128, P(this.buffer.subarray(a)), this.padOffset > r - a && (this.process(n, 0), a = 0);
|
|
2955
|
+
for (let e = a; e < r; e++) t[e] = 0;
|
|
2956
|
+
n.setBigUint64(r - 8, BigInt(this.length * 8), i), this.process(n, 0);
|
|
2957
|
+
let o = wn(e), s = this.outputLen;
|
|
2958
|
+
if (s % 4) throw Error("_sha2: outputLen must be aligned to 32bit");
|
|
2959
|
+
let c = s / 4, l = this.get();
|
|
2960
|
+
if (c > l.length) throw Error("_sha2: outputLen bigger than state");
|
|
2961
|
+
for (let e = 0; e < c; e++) o.setUint32(4 * e, l[e], i);
|
|
2962
|
+
}
|
|
2963
|
+
digest() {
|
|
2964
|
+
let { buffer: e, outputLen: t } = this;
|
|
2965
|
+
this.digestInto(e);
|
|
2966
|
+
let n = e.slice(0, t);
|
|
2967
|
+
return this.destroy(), n;
|
|
2968
|
+
}
|
|
2969
|
+
_cloneInto(e) {
|
|
2970
|
+
e ||= new this.constructor(), e.set(...this.get());
|
|
2971
|
+
let { blockLen: t, buffer: n, length: r, finished: i, destroyed: a, pos: o } = this;
|
|
2972
|
+
return e.destroyed = a, e.finished = i, e.length = r, e.pos = o, r % t && e.buffer.set(n), e;
|
|
2973
|
+
}
|
|
2974
|
+
clone() {
|
|
2975
|
+
return this._cloneInto();
|
|
2976
|
+
}
|
|
2977
|
+
}, R = /* @__PURE__ */ Uint32Array.from([
|
|
2978
|
+
1779033703,
|
|
2979
|
+
3144134277,
|
|
2980
|
+
1013904242,
|
|
2981
|
+
2773480762,
|
|
2982
|
+
1359893119,
|
|
2983
|
+
2600822924,
|
|
2984
|
+
528734635,
|
|
2985
|
+
1541459225
|
|
2986
|
+
]), z = /* @__PURE__ */ Uint32Array.from([
|
|
2987
|
+
3418070365,
|
|
2988
|
+
3238371032,
|
|
2989
|
+
1654270250,
|
|
2990
|
+
914150663,
|
|
2991
|
+
2438529370,
|
|
2992
|
+
812702999,
|
|
2993
|
+
355462360,
|
|
2994
|
+
4144912697,
|
|
2995
|
+
1731405415,
|
|
2996
|
+
4290775857,
|
|
2997
|
+
2394180231,
|
|
2998
|
+
1750603025,
|
|
2999
|
+
3675008525,
|
|
3000
|
+
1694076839,
|
|
3001
|
+
1203062813,
|
|
3002
|
+
3204075428
|
|
3003
|
+
]), B = /* @__PURE__ */ Uint32Array.from([
|
|
3004
|
+
1779033703,
|
|
3005
|
+
4089235720,
|
|
3006
|
+
3144134277,
|
|
3007
|
+
2227873595,
|
|
3008
|
+
1013904242,
|
|
3009
|
+
4271175723,
|
|
3010
|
+
2773480762,
|
|
3011
|
+
1595750129,
|
|
3012
|
+
1359893119,
|
|
3013
|
+
2917565137,
|
|
3014
|
+
2600822924,
|
|
3015
|
+
725511199,
|
|
3016
|
+
528734635,
|
|
3017
|
+
4215389547,
|
|
3018
|
+
1541459225,
|
|
3019
|
+
327033209
|
|
3020
|
+
]), Nn = /* @__PURE__ */ BigInt(2 ** 32 - 1), Pn = /* @__PURE__ */ BigInt(32);
|
|
3021
|
+
function Fn(e, t = !1) {
|
|
3022
|
+
return t ? {
|
|
3023
|
+
h: Number(e & Nn),
|
|
3024
|
+
l: Number(e >> Pn & Nn)
|
|
3025
|
+
} : {
|
|
3026
|
+
h: Number(e >> Pn & Nn) | 0,
|
|
3027
|
+
l: Number(e & Nn) | 0
|
|
3028
|
+
};
|
|
3029
|
+
}
|
|
3030
|
+
function In(e, t = !1) {
|
|
3031
|
+
let n = e.length, r = new Uint32Array(n), i = new Uint32Array(n);
|
|
3032
|
+
for (let a = 0; a < n; a++) {
|
|
3033
|
+
let { h: n, l: o } = Fn(e[a], t);
|
|
3034
|
+
[r[a], i[a]] = [n, o];
|
|
3035
|
+
}
|
|
3036
|
+
return [r, i];
|
|
3037
|
+
}
|
|
3038
|
+
var Ln = (e, t, n) => e >>> n, Rn = (e, t, n) => e << 32 - n | t >>> n, V = (e, t, n) => e >>> n | t << 32 - n, H = (e, t, n) => e << 32 - n | t >>> n, zn = (e, t, n) => e << 64 - n | t >>> n - 32, Bn = (e, t, n) => e >>> n - 32 | t << 64 - n, Vn = (e, t, n) => e << n | t >>> 32 - n, Hn = (e, t, n) => t << n | e >>> 32 - n, Un = (e, t, n) => t << n - 32 | e >>> 64 - n, Wn = (e, t, n) => e << n - 32 | t >>> 64 - n;
|
|
3039
|
+
function U(e, t, n, r) {
|
|
3040
|
+
let i = (t >>> 0) + (r >>> 0);
|
|
3041
|
+
return {
|
|
3042
|
+
h: e + n + (i / 2 ** 32 | 0) | 0,
|
|
3043
|
+
l: i | 0
|
|
3044
|
+
};
|
|
3045
|
+
}
|
|
3046
|
+
var Gn = (e, t, n) => (e >>> 0) + (t >>> 0) + (n >>> 0), Kn = (e, t, n, r) => t + n + r + (e / 2 ** 32 | 0) | 0, qn = (e, t, n, r) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (r >>> 0), Jn = (e, t, n, r, i) => t + n + r + i + (e / 2 ** 32 | 0) | 0, Yn = (e, t, n, r, i) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (r >>> 0) + (i >>> 0), Xn = (e, t, n, r, i, a) => t + n + r + i + a + (e / 2 ** 32 | 0) | 0, Zn = /* @__PURE__ */ Uint32Array.from([
|
|
3047
|
+
1116352408,
|
|
3048
|
+
1899447441,
|
|
3049
|
+
3049323471,
|
|
3050
|
+
3921009573,
|
|
3051
|
+
961987163,
|
|
3052
|
+
1508970993,
|
|
3053
|
+
2453635748,
|
|
3054
|
+
2870763221,
|
|
3055
|
+
3624381080,
|
|
3056
|
+
310598401,
|
|
3057
|
+
607225278,
|
|
3058
|
+
1426881987,
|
|
3059
|
+
1925078388,
|
|
3060
|
+
2162078206,
|
|
3061
|
+
2614888103,
|
|
3062
|
+
3248222580,
|
|
3063
|
+
3835390401,
|
|
3064
|
+
4022224774,
|
|
3065
|
+
264347078,
|
|
3066
|
+
604807628,
|
|
3067
|
+
770255983,
|
|
3068
|
+
1249150122,
|
|
3069
|
+
1555081692,
|
|
3070
|
+
1996064986,
|
|
3071
|
+
2554220882,
|
|
3072
|
+
2821834349,
|
|
3073
|
+
2952996808,
|
|
3074
|
+
3210313671,
|
|
3075
|
+
3336571891,
|
|
3076
|
+
3584528711,
|
|
3077
|
+
113926993,
|
|
3078
|
+
338241895,
|
|
3079
|
+
666307205,
|
|
3080
|
+
773529912,
|
|
3081
|
+
1294757372,
|
|
3082
|
+
1396182291,
|
|
3083
|
+
1695183700,
|
|
3084
|
+
1986661051,
|
|
3085
|
+
2177026350,
|
|
3086
|
+
2456956037,
|
|
3087
|
+
2730485921,
|
|
3088
|
+
2820302411,
|
|
3089
|
+
3259730800,
|
|
3090
|
+
3345764771,
|
|
3091
|
+
3516065817,
|
|
3092
|
+
3600352804,
|
|
3093
|
+
4094571909,
|
|
3094
|
+
275423344,
|
|
3095
|
+
430227734,
|
|
3096
|
+
506948616,
|
|
3097
|
+
659060556,
|
|
3098
|
+
883997877,
|
|
3099
|
+
958139571,
|
|
3100
|
+
1322822218,
|
|
3101
|
+
1537002063,
|
|
3102
|
+
1747873779,
|
|
3103
|
+
1955562222,
|
|
3104
|
+
2024104815,
|
|
3105
|
+
2227730452,
|
|
3106
|
+
2361852424,
|
|
3107
|
+
2428436474,
|
|
3108
|
+
2756734187,
|
|
3109
|
+
3204031479,
|
|
3110
|
+
3329325298
|
|
3111
|
+
]), W = /* @__PURE__ */ new Uint32Array(64), Qn = class extends Mn {
|
|
3112
|
+
constructor(e) {
|
|
3113
|
+
super(64, e, 8, !1);
|
|
3114
|
+
}
|
|
3115
|
+
get() {
|
|
3116
|
+
let { A: e, B: t, C: n, D: r, E: i, F: a, G: o, H: s } = this;
|
|
3117
|
+
return [
|
|
3118
|
+
e,
|
|
3119
|
+
t,
|
|
3120
|
+
n,
|
|
3121
|
+
r,
|
|
3122
|
+
i,
|
|
3123
|
+
a,
|
|
3124
|
+
o,
|
|
3125
|
+
s
|
|
3126
|
+
];
|
|
3127
|
+
}
|
|
3128
|
+
set(e, t, n, r, i, a, o, s) {
|
|
3129
|
+
this.A = e | 0, this.B = t | 0, this.C = n | 0, this.D = r | 0, this.E = i | 0, this.F = a | 0, this.G = o | 0, this.H = s | 0;
|
|
3130
|
+
}
|
|
3131
|
+
process(e, t) {
|
|
3132
|
+
for (let n = 0; n < 16; n++, t += 4) W[n] = e.getUint32(t, !1);
|
|
3133
|
+
for (let e = 16; e < 64; e++) {
|
|
3134
|
+
let t = W[e - 15], n = W[e - 2], r = F(t, 7) ^ F(t, 18) ^ t >>> 3;
|
|
3135
|
+
W[e] = (F(n, 17) ^ F(n, 19) ^ n >>> 10) + W[e - 7] + r + W[e - 16] | 0;
|
|
3136
|
+
}
|
|
3137
|
+
let { A: n, B: r, C: i, D: a, E: o, F: s, G: c, H: l } = this;
|
|
3138
|
+
for (let e = 0; e < 64; e++) {
|
|
3139
|
+
let t = F(o, 6) ^ F(o, 11) ^ F(o, 25), u = l + t + An(o, s, c) + Zn[e] + W[e] | 0, d = (F(n, 2) ^ F(n, 13) ^ F(n, 22)) + jn(n, r, i) | 0;
|
|
3140
|
+
l = c, c = s, s = o, o = a + u | 0, a = i, i = r, r = n, n = u + d | 0;
|
|
3141
|
+
}
|
|
3142
|
+
n = n + this.A | 0, r = r + this.B | 0, i = i + this.C | 0, a = a + this.D | 0, o = o + this.E | 0, s = s + this.F | 0, c = c + this.G | 0, l = l + this.H | 0, this.set(n, r, i, a, o, s, c, l);
|
|
3143
|
+
}
|
|
3144
|
+
roundClean() {
|
|
3145
|
+
P(W);
|
|
3146
|
+
}
|
|
3147
|
+
destroy() {
|
|
3148
|
+
this.destroyed = !0, this.set(0, 0, 0, 0, 0, 0, 0, 0), P(this.buffer);
|
|
3149
|
+
}
|
|
3150
|
+
}, $n = class extends Qn {
|
|
3151
|
+
A = R[0] | 0;
|
|
3152
|
+
B = R[1] | 0;
|
|
3153
|
+
C = R[2] | 0;
|
|
3154
|
+
D = R[3] | 0;
|
|
3155
|
+
E = R[4] | 0;
|
|
3156
|
+
F = R[5] | 0;
|
|
3157
|
+
G = R[6] | 0;
|
|
3158
|
+
H = R[7] | 0;
|
|
3159
|
+
constructor() {
|
|
3160
|
+
super(32);
|
|
3161
|
+
}
|
|
3162
|
+
}, er = In((/* @__PURE__ */ "0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817".split(".")).map((e) => BigInt(e))), tr = er[0], nr = er[1], G = /* @__PURE__ */ new Uint32Array(80), K = /* @__PURE__ */ new Uint32Array(80), rr = class extends Mn {
|
|
3163
|
+
constructor(e) {
|
|
3164
|
+
super(128, e, 16, !1);
|
|
3165
|
+
}
|
|
3166
|
+
get() {
|
|
3167
|
+
let { Ah: e, Al: t, Bh: n, Bl: r, Ch: i, Cl: a, Dh: o, Dl: s, Eh: c, El: l, Fh: u, Fl: d, Gh: f, Gl: p, Hh: m, Hl: h } = this;
|
|
3168
|
+
return [
|
|
3169
|
+
e,
|
|
3170
|
+
t,
|
|
3171
|
+
n,
|
|
3172
|
+
r,
|
|
3173
|
+
i,
|
|
3174
|
+
a,
|
|
3175
|
+
o,
|
|
3176
|
+
s,
|
|
3177
|
+
c,
|
|
3178
|
+
l,
|
|
3179
|
+
u,
|
|
3180
|
+
d,
|
|
3181
|
+
f,
|
|
3182
|
+
p,
|
|
3183
|
+
m,
|
|
3184
|
+
h
|
|
3185
|
+
];
|
|
3186
|
+
}
|
|
3187
|
+
set(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h) {
|
|
3188
|
+
this.Ah = e | 0, this.Al = t | 0, this.Bh = n | 0, this.Bl = r | 0, this.Ch = i | 0, this.Cl = a | 0, this.Dh = o | 0, this.Dl = s | 0, this.Eh = c | 0, this.El = l | 0, this.Fh = u | 0, this.Fl = d | 0, this.Gh = f | 0, this.Gl = p | 0, this.Hh = m | 0, this.Hl = h | 0;
|
|
3189
|
+
}
|
|
3190
|
+
process(e, t) {
|
|
3191
|
+
for (let n = 0; n < 16; n++, t += 4) G[n] = e.getUint32(t), K[n] = e.getUint32(t += 4);
|
|
3192
|
+
for (let e = 16; e < 80; e++) {
|
|
3193
|
+
let t = G[e - 15] | 0, n = K[e - 15] | 0, r = V(t, n, 1) ^ V(t, n, 8) ^ Ln(t, n, 7), i = H(t, n, 1) ^ H(t, n, 8) ^ Rn(t, n, 7), a = G[e - 2] | 0, o = K[e - 2] | 0, s = V(a, o, 19) ^ zn(a, o, 61) ^ Ln(a, o, 6), c = qn(i, H(a, o, 19) ^ Bn(a, o, 61) ^ Rn(a, o, 6), K[e - 7], K[e - 16]);
|
|
3194
|
+
G[e] = Jn(c, r, s, G[e - 7], G[e - 16]) | 0, K[e] = c | 0;
|
|
3195
|
+
}
|
|
3196
|
+
let { Ah: n, Al: r, Bh: i, Bl: a, Ch: o, Cl: s, Dh: c, Dl: l, Eh: u, El: d, Fh: f, Fl: p, Gh: m, Gl: h, Hh: g, Hl: _ } = this;
|
|
3197
|
+
for (let e = 0; e < 80; e++) {
|
|
3198
|
+
let t = V(u, d, 14) ^ V(u, d, 18) ^ zn(u, d, 41), v = H(u, d, 14) ^ H(u, d, 18) ^ Bn(u, d, 41), ee = u & f ^ ~u & m, te = d & p ^ ~d & h, ne = Yn(_, v, te, nr[e], K[e]), re = Xn(ne, g, t, ee, tr[e], G[e]), y = ne | 0, b = V(n, r, 28) ^ zn(n, r, 34) ^ zn(n, r, 39), ie = H(n, r, 28) ^ Bn(n, r, 34) ^ Bn(n, r, 39), x = n & i ^ n & o ^ i & o, ae = r & a ^ r & s ^ a & s;
|
|
3199
|
+
g = m | 0, _ = h | 0, m = f | 0, h = p | 0, f = u | 0, p = d | 0, {h: u, l: d} = U(c | 0, l | 0, re | 0, y | 0), c = o | 0, l = s | 0, o = i | 0, s = a | 0, i = n | 0, a = r | 0;
|
|
3200
|
+
let oe = Gn(y, ie, ae);
|
|
3201
|
+
n = Kn(oe, re, b, x), r = oe | 0;
|
|
3202
|
+
}
|
|
3203
|
+
({h: n, l: r} = U(this.Ah | 0, this.Al | 0, n | 0, r | 0)), {h: i, l: a} = U(this.Bh | 0, this.Bl | 0, i | 0, a | 0), {h: o, l: s} = U(this.Ch | 0, this.Cl | 0, o | 0, s | 0), {h: c, l: l} = U(this.Dh | 0, this.Dl | 0, c | 0, l | 0), {h: u, l: d} = U(this.Eh | 0, this.El | 0, u | 0, d | 0), {h: f, l: p} = U(this.Fh | 0, this.Fl | 0, f | 0, p | 0), {h: m, l: h} = U(this.Gh | 0, this.Gl | 0, m | 0, h | 0), {h: g, l: _} = U(this.Hh | 0, this.Hl | 0, g | 0, _ | 0), this.set(n, r, i, a, o, s, c, l, u, d, f, p, m, h, g, _);
|
|
3204
|
+
}
|
|
3205
|
+
roundClean() {
|
|
3206
|
+
P(G, K);
|
|
3207
|
+
}
|
|
3208
|
+
destroy() {
|
|
3209
|
+
this.destroyed = !0, P(this.buffer), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
3210
|
+
}
|
|
3211
|
+
}, ir = class extends rr {
|
|
3212
|
+
Ah = B[0] | 0;
|
|
3213
|
+
Al = B[1] | 0;
|
|
3214
|
+
Bh = B[2] | 0;
|
|
3215
|
+
Bl = B[3] | 0;
|
|
3216
|
+
Ch = B[4] | 0;
|
|
3217
|
+
Cl = B[5] | 0;
|
|
3218
|
+
Dh = B[6] | 0;
|
|
3219
|
+
Dl = B[7] | 0;
|
|
3220
|
+
Eh = B[8] | 0;
|
|
3221
|
+
El = B[9] | 0;
|
|
3222
|
+
Fh = B[10] | 0;
|
|
3223
|
+
Fl = B[11] | 0;
|
|
3224
|
+
Gh = B[12] | 0;
|
|
3225
|
+
Gl = B[13] | 0;
|
|
3226
|
+
Hh = B[14] | 0;
|
|
3227
|
+
Hl = B[15] | 0;
|
|
3228
|
+
constructor() {
|
|
3229
|
+
super(64);
|
|
3230
|
+
}
|
|
3231
|
+
}, ar = class extends rr {
|
|
3232
|
+
Ah = z[0] | 0;
|
|
3233
|
+
Al = z[1] | 0;
|
|
3234
|
+
Bh = z[2] | 0;
|
|
3235
|
+
Bl = z[3] | 0;
|
|
3236
|
+
Ch = z[4] | 0;
|
|
3237
|
+
Cl = z[5] | 0;
|
|
3238
|
+
Dh = z[6] | 0;
|
|
3239
|
+
Dl = z[7] | 0;
|
|
3240
|
+
Eh = z[8] | 0;
|
|
3241
|
+
El = z[9] | 0;
|
|
3242
|
+
Fh = z[10] | 0;
|
|
3243
|
+
Fl = z[11] | 0;
|
|
3244
|
+
Gh = z[12] | 0;
|
|
3245
|
+
Gl = z[13] | 0;
|
|
3246
|
+
Hh = z[14] | 0;
|
|
3247
|
+
Hl = z[15] | 0;
|
|
3248
|
+
constructor() {
|
|
3249
|
+
super(48);
|
|
3250
|
+
}
|
|
3251
|
+
}, q = /* @__PURE__ */ Uint32Array.from([
|
|
3252
|
+
573645204,
|
|
3253
|
+
4230739756,
|
|
3254
|
+
2673172387,
|
|
3255
|
+
3360449730,
|
|
3256
|
+
596883563,
|
|
3257
|
+
1867755857,
|
|
3258
|
+
2520282905,
|
|
3259
|
+
1497426621,
|
|
3260
|
+
2519219938,
|
|
3261
|
+
2827943907,
|
|
3262
|
+
3193839141,
|
|
3263
|
+
1401305490,
|
|
3264
|
+
721525244,
|
|
3265
|
+
746961066,
|
|
3266
|
+
246885852,
|
|
3267
|
+
2177182882
|
|
3268
|
+
]), or = class extends rr {
|
|
3269
|
+
Ah = q[0] | 0;
|
|
3270
|
+
Al = q[1] | 0;
|
|
3271
|
+
Bh = q[2] | 0;
|
|
3272
|
+
Bl = q[3] | 0;
|
|
3273
|
+
Ch = q[4] | 0;
|
|
3274
|
+
Cl = q[5] | 0;
|
|
3275
|
+
Dh = q[6] | 0;
|
|
3276
|
+
Dl = q[7] | 0;
|
|
3277
|
+
Eh = q[8] | 0;
|
|
3278
|
+
El = q[9] | 0;
|
|
3279
|
+
Fh = q[10] | 0;
|
|
3280
|
+
Fl = q[11] | 0;
|
|
3281
|
+
Gh = q[12] | 0;
|
|
3282
|
+
Gl = q[13] | 0;
|
|
3283
|
+
Hh = q[14] | 0;
|
|
3284
|
+
Hl = q[15] | 0;
|
|
3285
|
+
constructor() {
|
|
3286
|
+
super(32);
|
|
3287
|
+
}
|
|
3288
|
+
}, sr = /* @__PURE__ */ I(() => new $n(), /* @__PURE__ */ L(1)), cr = /* @__PURE__ */ I(() => new ir(), /* @__PURE__ */ L(3)), lr = /* @__PURE__ */ I(() => new ar(), /* @__PURE__ */ L(2)), ur = /* @__PURE__ */ I(() => new or(), /* @__PURE__ */ L(6)), dr = BigInt(0), fr = BigInt(1), pr = BigInt(2), mr = BigInt(7), hr = BigInt(256), gr = BigInt(113), _r = [], vr = [], yr = [];
|
|
3289
|
+
for (let e = 0, t = fr, n = 1, r = 0; e < 24; e++) {
|
|
3290
|
+
[n, r] = [r, (2 * n + 3 * r) % 5], _r.push(2 * (5 * r + n)), vr.push((e + 1) * (e + 2) / 2 % 64);
|
|
3291
|
+
let i = dr;
|
|
3292
|
+
for (let e = 0; e < 7; e++) t = (t << fr ^ (t >> mr) * gr) % hr, t & pr && (i ^= fr << (fr << BigInt(e)) - fr);
|
|
3293
|
+
yr.push(i);
|
|
3294
|
+
}
|
|
3295
|
+
var br = In(yr, !0), xr = br[0], Sr = br[1], Cr = (e, t, n) => n > 32 ? Un(e, t, n) : Vn(e, t, n), wr = (e, t, n) => n > 32 ? Wn(e, t, n) : Hn(e, t, n);
|
|
3296
|
+
function Tr(e, t = 24) {
|
|
3297
|
+
if (yn(t, "rounds"), t < 1 || t > 24) throw Error("\"rounds\" expected integer 1..24");
|
|
3298
|
+
let n = new Uint32Array(10);
|
|
3299
|
+
for (let r = 24 - t; r < 24; r++) {
|
|
3300
|
+
for (let t = 0; t < 10; t++) n[t] = e[t] ^ e[t + 10] ^ e[t + 20] ^ e[t + 30] ^ e[t + 40];
|
|
3301
|
+
for (let t = 0; t < 10; t += 2) {
|
|
3302
|
+
let r = (t + 8) % 10, i = (t + 2) % 10, a = n[i], o = n[i + 1], s = Cr(a, o, 1) ^ n[r], c = wr(a, o, 1) ^ n[r + 1];
|
|
3303
|
+
for (let n = 0; n < 50; n += 10) e[t + n] ^= s, e[t + n + 1] ^= c;
|
|
3304
|
+
}
|
|
3305
|
+
let t = e[2], i = e[3];
|
|
3306
|
+
for (let n = 0; n < 24; n++) {
|
|
3307
|
+
let r = vr[n], a = Cr(t, i, r), o = wr(t, i, r), s = _r[n];
|
|
3308
|
+
t = e[s], i = e[s + 1], e[s] = a, e[s + 1] = o;
|
|
3309
|
+
}
|
|
3310
|
+
for (let t = 0; t < 50; t += 10) {
|
|
3311
|
+
let n = e[t], r = e[t + 1], i = e[t + 2], a = e[t + 3];
|
|
3312
|
+
e[t] ^= ~e[t + 2] & e[t + 4], e[t + 1] ^= ~e[t + 3] & e[t + 5], e[t + 2] ^= ~e[t + 4] & e[t + 6], e[t + 3] ^= ~e[t + 5] & e[t + 7], e[t + 4] ^= ~e[t + 6] & e[t + 8], e[t + 5] ^= ~e[t + 7] & e[t + 9], e[t + 6] ^= ~e[t + 8] & n, e[t + 7] ^= ~e[t + 9] & r, e[t + 8] ^= ~n & i, e[t + 9] ^= ~r & a;
|
|
3313
|
+
}
|
|
3314
|
+
e[0] ^= xr[r], e[1] ^= Sr[r];
|
|
3315
|
+
}
|
|
3316
|
+
P(n);
|
|
3317
|
+
}
|
|
3318
|
+
var Er = class e {
|
|
3319
|
+
state;
|
|
3320
|
+
pos = 0;
|
|
3321
|
+
posOut = 0;
|
|
3322
|
+
finished = !1;
|
|
3323
|
+
state32;
|
|
3324
|
+
destroyed = !1;
|
|
3325
|
+
blockLen;
|
|
3326
|
+
suffix;
|
|
3327
|
+
outputLen;
|
|
3328
|
+
canXOF;
|
|
3329
|
+
enableXOF = !1;
|
|
3330
|
+
rounds;
|
|
3331
|
+
constructor(e, t, n, r = !1, i = 24) {
|
|
3332
|
+
if (this.blockLen = e, this.suffix = t, this.outputLen = n, this.enableXOF = r, this.canXOF = r, this.rounds = i, yn(n, "outputLen"), !(0 < e && e < 200)) throw Error("only keccak-f1600 function is supported");
|
|
3333
|
+
this.state = new Uint8Array(200), this.state32 = Cn(this.state);
|
|
3334
|
+
}
|
|
3335
|
+
clone() {
|
|
3336
|
+
return this._cloneInto();
|
|
3337
|
+
}
|
|
3338
|
+
keccak() {
|
|
3339
|
+
kn(this.state32), Tr(this.state32, this.rounds), kn(this.state32), this.posOut = 0, this.pos = 0;
|
|
3340
|
+
}
|
|
3341
|
+
update(e) {
|
|
3342
|
+
xn(this), bn(e);
|
|
3343
|
+
let { blockLen: t, state: n } = this, r = e.length;
|
|
3344
|
+
for (let i = 0; i < r;) {
|
|
3345
|
+
let a = Math.min(t - this.pos, r - i);
|
|
3346
|
+
for (let t = 0; t < a; t++) n[this.pos++] ^= e[i++];
|
|
3347
|
+
this.pos === t && this.keccak();
|
|
3348
|
+
}
|
|
3349
|
+
return this;
|
|
3350
|
+
}
|
|
3351
|
+
finish() {
|
|
3352
|
+
if (this.finished) return;
|
|
3353
|
+
this.finished = !0;
|
|
3354
|
+
let { state: e, suffix: t, pos: n, blockLen: r } = this;
|
|
3355
|
+
e[n] ^= t, t & 128 && n === r - 1 && this.keccak(), e[r - 1] ^= 128, this.keccak();
|
|
3356
|
+
}
|
|
3357
|
+
writeInto(e) {
|
|
3358
|
+
xn(this, !1), bn(e), this.finish();
|
|
3359
|
+
let t = this.state, { blockLen: n } = this;
|
|
3360
|
+
for (let r = 0, i = e.length; r < i;) {
|
|
3361
|
+
this.posOut >= n && this.keccak();
|
|
3362
|
+
let a = Math.min(n - this.posOut, i - r);
|
|
3363
|
+
e.set(t.subarray(this.posOut, this.posOut + a), r), this.posOut += a, r += a;
|
|
3364
|
+
}
|
|
3365
|
+
return e;
|
|
3366
|
+
}
|
|
3367
|
+
xofInto(e) {
|
|
3368
|
+
if (!this.enableXOF) throw Error("XOF is not possible for this instance");
|
|
3369
|
+
return this.writeInto(e);
|
|
3370
|
+
}
|
|
3371
|
+
xof(e) {
|
|
3372
|
+
return yn(e), this.xofInto(new Uint8Array(e));
|
|
3373
|
+
}
|
|
3374
|
+
digestInto(e) {
|
|
3375
|
+
if (Sn(e, this), this.finished) throw Error("digest() was already called");
|
|
3376
|
+
this.writeInto(e.subarray(0, this.outputLen)), this.destroy();
|
|
3377
|
+
}
|
|
3378
|
+
digest() {
|
|
3379
|
+
let e = new Uint8Array(this.outputLen);
|
|
3380
|
+
return this.digestInto(e), e;
|
|
3381
|
+
}
|
|
3382
|
+
destroy() {
|
|
3383
|
+
this.destroyed = !0, P(this.state);
|
|
3384
|
+
}
|
|
3385
|
+
_cloneInto(t) {
|
|
3386
|
+
let { blockLen: n, suffix: r, outputLen: i, rounds: a, enableXOF: o } = this;
|
|
3387
|
+
return t ||= new e(n, r, i, o, a), t.blockLen = n, t.state32.set(this.state32), t.pos = this.pos, t.posOut = this.posOut, t.finished = this.finished, t.rounds = a, t.suffix = r, t.outputLen = i, t.enableXOF = o, t.canXOF = this.canXOF, t.destroyed = this.destroyed, t;
|
|
3388
|
+
}
|
|
3389
|
+
}, Dr = (e, t, n, r = {}) => I((r = {}) => new Er(t, e, r.dkLen === void 0 ? n : r.dkLen, !0), r), Or = /* @__PURE__ */ Dr(31, 168, 32, /* @__PURE__ */ L(11)), kr = /* @__PURE__ */ Dr(31, 136, 64, /* @__PURE__ */ L(12)), Ar = /* @__PURE__ */ Uint32Array.from([
|
|
3390
|
+
1732584193,
|
|
3391
|
+
4023233417,
|
|
3392
|
+
2562383102,
|
|
3393
|
+
271733878,
|
|
3394
|
+
3285377520
|
|
3395
|
+
]), J = /* @__PURE__ */ new Uint32Array(80), jr = class extends Mn {
|
|
3396
|
+
A = Ar[0] | 0;
|
|
3397
|
+
B = Ar[1] | 0;
|
|
3398
|
+
C = Ar[2] | 0;
|
|
3399
|
+
D = Ar[3] | 0;
|
|
3400
|
+
E = Ar[4] | 0;
|
|
3401
|
+
constructor() {
|
|
3402
|
+
super(64, 20, 8, !1);
|
|
3403
|
+
}
|
|
3404
|
+
get() {
|
|
3405
|
+
let { A: e, B: t, C: n, D: r, E: i } = this;
|
|
3406
|
+
return [
|
|
3407
|
+
e,
|
|
3408
|
+
t,
|
|
3409
|
+
n,
|
|
3410
|
+
r,
|
|
3411
|
+
i
|
|
3412
|
+
];
|
|
3413
|
+
}
|
|
3414
|
+
set(e, t, n, r, i) {
|
|
3415
|
+
this.A = e | 0, this.B = t | 0, this.C = n | 0, this.D = r | 0, this.E = i | 0;
|
|
3416
|
+
}
|
|
3417
|
+
process(e, t) {
|
|
3418
|
+
for (let n = 0; n < 16; n++, t += 4) J[n] = e.getUint32(t, !1);
|
|
3419
|
+
for (let e = 16; e < 80; e++) J[e] = Tn(J[e - 3] ^ J[e - 8] ^ J[e - 14] ^ J[e - 16], 1);
|
|
3420
|
+
let { A: n, B: r, C: i, D: a, E: o } = this;
|
|
3421
|
+
for (let e = 0; e < 80; e++) {
|
|
3422
|
+
let t, s;
|
|
3423
|
+
e < 20 ? (t = An(r, i, a), s = 1518500249) : e < 40 ? (t = r ^ i ^ a, s = 1859775393) : e < 60 ? (t = jn(r, i, a), s = 2400959708) : (t = r ^ i ^ a, s = 3395469782);
|
|
3424
|
+
let c = Tn(n, 5) + t + o + s + J[e] | 0;
|
|
3425
|
+
o = a, a = i, i = Tn(r, 30), r = n, n = c;
|
|
3426
|
+
}
|
|
3427
|
+
n = n + this.A | 0, r = r + this.B | 0, i = i + this.C | 0, a = a + this.D | 0, o = o + this.E | 0, this.set(n, r, i, a, o);
|
|
3428
|
+
}
|
|
3429
|
+
roundClean() {
|
|
3430
|
+
P(J);
|
|
3431
|
+
}
|
|
3432
|
+
destroy() {
|
|
3433
|
+
this.destroyed = !0, this.set(0, 0, 0, 0, 0), P(this.buffer);
|
|
3434
|
+
}
|
|
3435
|
+
}, Mr = /* @__PURE__ */ I(() => new jr()), Nr = /* @__PURE__ */ Uint8Array.from([
|
|
3436
|
+
7,
|
|
3437
|
+
4,
|
|
3438
|
+
13,
|
|
3439
|
+
1,
|
|
3440
|
+
10,
|
|
3441
|
+
6,
|
|
3442
|
+
15,
|
|
3443
|
+
3,
|
|
3444
|
+
12,
|
|
3445
|
+
0,
|
|
3446
|
+
9,
|
|
3447
|
+
5,
|
|
3448
|
+
2,
|
|
3449
|
+
14,
|
|
3450
|
+
11,
|
|
3451
|
+
8
|
|
3452
|
+
]), Pr = Uint8Array.from(Array(16).fill(0).map((e, t) => t)), Fr = Pr.map((e) => (9 * e + 5) % 16), Ir = /* @__PURE__ */ (() => {
|
|
3453
|
+
let e = [[Pr], [Fr]];
|
|
3454
|
+
for (let t = 0; t < 4; t++) for (let n of e) n.push(n[t].map((e) => Nr[e]));
|
|
3455
|
+
return e;
|
|
3456
|
+
})();
|
|
3457
|
+
Ir[0], Ir[1];
|
|
3458
|
+
//#endregion
|
|
3459
|
+
//#region src/extensions/hash.ts
|
|
3460
|
+
var Lr = new Map([
|
|
3461
|
+
[-14, Mr],
|
|
3462
|
+
[-15, (e) => sr(e).slice(0, 8)],
|
|
3463
|
+
[-16, sr],
|
|
3464
|
+
[-17, ur],
|
|
3465
|
+
[-18, Or],
|
|
3466
|
+
[-43, lr],
|
|
3467
|
+
[-44, cr],
|
|
3468
|
+
[-45, kr]
|
|
3469
|
+
]), Rr = new Map([
|
|
3470
|
+
["SHA-1", -14],
|
|
3471
|
+
["SHA-256/64", -15],
|
|
3472
|
+
["SHA-256", -16],
|
|
3473
|
+
["SHA-512/256", -17],
|
|
3474
|
+
["SHAKE128", -18],
|
|
3475
|
+
["SHA-384", -43],
|
|
3476
|
+
["SHA-512", -44],
|
|
3477
|
+
["SHAKE256", -45]
|
|
3478
|
+
]), zr = new Map([...Rr.entries()].map(([e, t]) => [t, e])), Br = class extends w {
|
|
3479
|
+
_input;
|
|
3480
|
+
_algorithmId;
|
|
3481
|
+
constructor(e, t, n) {
|
|
3482
|
+
super(e), this._input = t, this._algorithmId = n;
|
|
3483
|
+
}
|
|
3484
|
+
_toEDN(e, t) {
|
|
3485
|
+
if (e?.appStrings === !1) return super._toEDN(e, t);
|
|
3486
|
+
let n = this._algorithmId === -16;
|
|
3487
|
+
if (this._input instanceof A && n) return `hash${Ce(this._input.value)}`;
|
|
3488
|
+
let r = this._input instanceof A ? Ce(this._input.value) : ye(this._input.value, e?.bstrEncoding ?? "hex", e?.sqstr);
|
|
3489
|
+
return n ? `hash<<${r}>>` : `hash<<${r}, ${zr.has(this._algorithmId) ? `"${zr.get(this._algorithmId)}"` : String(this._algorithmId)}>>`;
|
|
3490
|
+
}
|
|
3491
|
+
};
|
|
3492
|
+
function Vr(e) {
|
|
3493
|
+
if (e instanceof y || e instanceof b) return Number(e.value);
|
|
3494
|
+
if (e instanceof A) {
|
|
3495
|
+
let t = Rr.get(e.value);
|
|
3496
|
+
if (t === void 0) throw SyntaxError(`hash: unknown algorithm name: ${JSON.stringify(e.value)}`);
|
|
3497
|
+
return t;
|
|
3498
|
+
}
|
|
3499
|
+
throw SyntaxError("hash: algorithm must be an integer or text string");
|
|
3500
|
+
}
|
|
3501
|
+
function Hr(e, t) {
|
|
3502
|
+
let n = e instanceof A ? new TextEncoder().encode(e.value) : e.value, r = Lr.get(t);
|
|
3503
|
+
if (!r) throw SyntaxError(`hash: unsupported COSE algorithm ID ${t}`);
|
|
3504
|
+
return new Br(r(n), e, t);
|
|
3505
|
+
}
|
|
3506
|
+
var Ur = {
|
|
3507
|
+
appStringPrefixes: ["hash"],
|
|
3508
|
+
parseAppString(e, t) {
|
|
3509
|
+
return Hr(new A(t), -16);
|
|
3510
|
+
},
|
|
3511
|
+
parseAppSequence(e, t) {
|
|
3512
|
+
if (t.length === 0 || t.length > 2) throw SyntaxError(`hash<<...>>: expected 1 or 2 items, got ${t.length}`);
|
|
3513
|
+
let n = t[0];
|
|
3514
|
+
if (!(n instanceof A) && !(n instanceof w)) throw SyntaxError("hash: first argument must be a text or byte string");
|
|
3515
|
+
return Hr(n, t.length === 2 ? Vr(t[1]) : -16);
|
|
3516
|
+
}
|
|
3517
|
+
}, Wr = new TextDecoder("utf-8", { fatal: !0 });
|
|
3518
|
+
function Y(e) {
|
|
3519
|
+
throw Error(`CBOR decode error: ${e}`);
|
|
3520
|
+
}
|
|
3521
|
+
function X(e, t, n) {
|
|
3522
|
+
if (n <= 23) return {
|
|
3523
|
+
value: BigInt(n),
|
|
3524
|
+
nextOffset: t
|
|
3525
|
+
};
|
|
3526
|
+
switch (n) {
|
|
3527
|
+
case 24: return t + 1 > e.byteLength && Y("unexpected end of input"), {
|
|
3528
|
+
value: BigInt(e.getUint8(t)),
|
|
3529
|
+
nextOffset: t + 1
|
|
3530
|
+
};
|
|
3531
|
+
case 25: return t + 2 > e.byteLength && Y("unexpected end of input"), {
|
|
3532
|
+
value: BigInt(e.getUint16(t, !1)),
|
|
3533
|
+
nextOffset: t + 2
|
|
3534
|
+
};
|
|
3535
|
+
case 26: return t + 4 > e.byteLength && Y("unexpected end of input"), {
|
|
3536
|
+
value: BigInt(e.getUint32(t, !1)),
|
|
3537
|
+
nextOffset: t + 4
|
|
3538
|
+
};
|
|
3539
|
+
case 27: return t + 8 > e.byteLength && Y("unexpected end of input"), {
|
|
3540
|
+
value: e.getBigUint64(t, !1),
|
|
3541
|
+
nextOffset: t + 8
|
|
3542
|
+
};
|
|
3543
|
+
default: Y(`reserved additional info value: ${n}`);
|
|
3544
|
+
}
|
|
3545
|
+
}
|
|
3546
|
+
function Z(e, t, n) {
|
|
3547
|
+
let r = t, i = Gr(e, t, n);
|
|
3548
|
+
return i.value.start = r, i.value.end = i.nextOffset, i;
|
|
3549
|
+
}
|
|
3550
|
+
function Gr(e, t, n) {
|
|
3551
|
+
t >= e.byteLength && Y("unexpected end of input");
|
|
3552
|
+
let r = e.getUint8(t++), i = r >> 5, a = r & 31;
|
|
3553
|
+
switch (i) {
|
|
3554
|
+
case 0: {
|
|
3555
|
+
let { value: n, nextOffset: r } = X(e, t, a);
|
|
3556
|
+
return {
|
|
3557
|
+
value: new y(n),
|
|
3558
|
+
nextOffset: r
|
|
3559
|
+
};
|
|
3560
|
+
}
|
|
3561
|
+
case 1: {
|
|
3562
|
+
let { value: n, nextOffset: r } = X(e, t, a);
|
|
3563
|
+
return {
|
|
3564
|
+
value: new b(-1n - n),
|
|
3565
|
+
nextOffset: r
|
|
3566
|
+
};
|
|
3567
|
+
}
|
|
3568
|
+
case 2: {
|
|
3569
|
+
if (a === 31) {
|
|
3570
|
+
let r = [], i = t;
|
|
3571
|
+
for (;;) {
|
|
3572
|
+
if (i >= e.byteLength && Y("unexpected end of indefinite byte string"), e.getUint8(i) === 255) {
|
|
3573
|
+
i++;
|
|
3574
|
+
break;
|
|
3575
|
+
}
|
|
3576
|
+
let t = Z(e, i, n);
|
|
3577
|
+
t.value instanceof w || Y("indefinite-length byte string chunk must be a definite byte string"), r.push(t.value), i = t.nextOffset;
|
|
3578
|
+
}
|
|
3579
|
+
return {
|
|
3580
|
+
value: new Me(r),
|
|
3581
|
+
nextOffset: i
|
|
3582
|
+
};
|
|
3583
|
+
}
|
|
3584
|
+
let { value: r, nextOffset: i } = X(e, t, a), o = Number(r);
|
|
3585
|
+
return i + o > e.byteLength && Y("byte string extends beyond input"), {
|
|
3586
|
+
value: new w(new Uint8Array(e.buffer, e.byteOffset + i, o).slice()),
|
|
3587
|
+
nextOffset: i + o
|
|
3588
|
+
};
|
|
3589
|
+
}
|
|
3590
|
+
case 3: {
|
|
3591
|
+
if (a === 31) {
|
|
3592
|
+
let r = [], i = t;
|
|
3593
|
+
for (;;) {
|
|
3594
|
+
if (i >= e.byteLength && Y("unexpected end of indefinite text string"), e.getUint8(i) === 255) {
|
|
3595
|
+
i++;
|
|
3596
|
+
break;
|
|
3597
|
+
}
|
|
3598
|
+
let t = Z(e, i, n);
|
|
3599
|
+
t.value instanceof A || Y("indefinite-length text string chunk must be a definite text string"), r.push(t.value), i = t.nextOffset;
|
|
3600
|
+
}
|
|
3601
|
+
return {
|
|
3602
|
+
value: new T(r),
|
|
3603
|
+
nextOffset: i
|
|
3604
|
+
};
|
|
3605
|
+
}
|
|
3606
|
+
let { value: r, nextOffset: i } = X(e, t, a), o = Number(r);
|
|
3607
|
+
i + o > e.byteLength && Y("text string extends beyond input");
|
|
3608
|
+
let s = new Uint8Array(e.buffer, e.byteOffset + i, o), c;
|
|
3609
|
+
try {
|
|
3610
|
+
c = Wr.decode(s);
|
|
3611
|
+
} catch {
|
|
3612
|
+
Y("invalid UTF-8 sequence in text string");
|
|
3613
|
+
}
|
|
3614
|
+
return {
|
|
3615
|
+
value: new A(c),
|
|
3616
|
+
nextOffset: i + o
|
|
3617
|
+
};
|
|
3618
|
+
}
|
|
3619
|
+
case 4: {
|
|
3620
|
+
if (a === 31) {
|
|
3621
|
+
let r = [], i = t;
|
|
3622
|
+
for (;;) {
|
|
3623
|
+
if (i >= e.byteLength && Y("unexpected end of indefinite array"), e.getUint8(i) === 255) {
|
|
3624
|
+
i++;
|
|
3625
|
+
break;
|
|
3626
|
+
}
|
|
3627
|
+
let t = Z(e, i, n);
|
|
3628
|
+
r.push(t.value), i = t.nextOffset;
|
|
3629
|
+
}
|
|
3630
|
+
return {
|
|
3631
|
+
value: new E(r, { indefiniteLength: !0 }),
|
|
3632
|
+
nextOffset: i
|
|
3633
|
+
};
|
|
3634
|
+
}
|
|
3635
|
+
let { value: r, nextOffset: i } = X(e, t, a), o = Number(r), s = [], c = i;
|
|
3636
|
+
for (let t = 0; t < o; t++) {
|
|
3637
|
+
let t = Z(e, c, n);
|
|
3638
|
+
s.push(t.value), c = t.nextOffset;
|
|
3639
|
+
}
|
|
3640
|
+
return {
|
|
3641
|
+
value: new E(s),
|
|
3642
|
+
nextOffset: c
|
|
3643
|
+
};
|
|
3644
|
+
}
|
|
3645
|
+
case 5: {
|
|
3646
|
+
if (a === 31) {
|
|
3647
|
+
let r = [], i = t;
|
|
3648
|
+
for (;;) {
|
|
3649
|
+
if (i >= e.byteLength && Y("unexpected end of indefinite map"), e.getUint8(i) === 255) {
|
|
3650
|
+
i++;
|
|
3651
|
+
break;
|
|
3652
|
+
}
|
|
3653
|
+
let t = Z(e, i, n);
|
|
3654
|
+
i = t.nextOffset;
|
|
3655
|
+
let a = Z(e, i, n);
|
|
3656
|
+
i = a.nextOffset, r.push([t.value, a.value]);
|
|
3657
|
+
}
|
|
3658
|
+
return {
|
|
3659
|
+
value: new D(r, { indefiniteLength: !0 }),
|
|
3660
|
+
nextOffset: i
|
|
3661
|
+
};
|
|
3662
|
+
}
|
|
3663
|
+
let { value: r, nextOffset: i } = X(e, t, a), o = Number(r), s = [], c = i;
|
|
3664
|
+
for (let t = 0; t < o; t++) {
|
|
3665
|
+
let t = Z(e, c, n);
|
|
3666
|
+
c = t.nextOffset;
|
|
3667
|
+
let r = Z(e, c, n);
|
|
3668
|
+
c = r.nextOffset, s.push([t.value, r.value]);
|
|
3669
|
+
}
|
|
3670
|
+
return {
|
|
3671
|
+
value: new D(s),
|
|
3672
|
+
nextOffset: c
|
|
3673
|
+
};
|
|
3674
|
+
}
|
|
3675
|
+
case 6: {
|
|
3676
|
+
a === 31 && Y("tags cannot use indefinite-length encoding");
|
|
3677
|
+
let { value: r, nextOffset: i } = X(e, t, a), o = Z(e, i, n);
|
|
3678
|
+
for (let e of [...n?.extensions ?? [], ...Yr]) if (e.parseTag) {
|
|
3679
|
+
let t = e.parseTag(r, o.value);
|
|
3680
|
+
if (t !== void 0) return {
|
|
3681
|
+
value: t,
|
|
3682
|
+
nextOffset: o.nextOffset
|
|
3683
|
+
};
|
|
3684
|
+
}
|
|
3685
|
+
return {
|
|
3686
|
+
value: new C(r, o.value),
|
|
3687
|
+
nextOffset: o.nextOffset
|
|
3688
|
+
};
|
|
3689
|
+
}
|
|
3690
|
+
case 7:
|
|
3691
|
+
if (a <= 19) return {
|
|
3692
|
+
value: new O(a),
|
|
3693
|
+
nextOffset: t
|
|
3694
|
+
};
|
|
3695
|
+
if (a === 20) return {
|
|
3696
|
+
value: O.FALSE,
|
|
3697
|
+
nextOffset: t
|
|
3698
|
+
};
|
|
3699
|
+
if (a === 21) return {
|
|
3700
|
+
value: O.TRUE,
|
|
3701
|
+
nextOffset: t
|
|
3702
|
+
};
|
|
3703
|
+
if (a === 22) return {
|
|
3704
|
+
value: O.NULL,
|
|
3705
|
+
nextOffset: t
|
|
3706
|
+
};
|
|
3707
|
+
if (a === 23) return {
|
|
3708
|
+
value: O.UNDEFINED,
|
|
3709
|
+
nextOffset: t
|
|
3710
|
+
};
|
|
3711
|
+
if (a === 24) {
|
|
3712
|
+
t + 1 > e.byteLength && Y("unexpected end of input");
|
|
3713
|
+
let n = e.getUint8(t);
|
|
3714
|
+
return n < 32 && Y(`simple value ${n} must be encoded in initial byte (0–31 reserved for extended encoding)`), {
|
|
3715
|
+
value: new O(n),
|
|
3716
|
+
nextOffset: t + 1
|
|
3717
|
+
};
|
|
3718
|
+
}
|
|
3719
|
+
return a === 25 ? (t + 2 > e.byteLength && Y("unexpected end of input"), {
|
|
3720
|
+
value: new S(h(e.getUint16(t, !1)), { precision: "half" }),
|
|
3721
|
+
nextOffset: t + 2
|
|
3722
|
+
}) : a === 26 ? (t + 4 > e.byteLength && Y("unexpected end of input"), {
|
|
3723
|
+
value: new S(e.getFloat32(t, !1), { precision: "single" }),
|
|
3724
|
+
nextOffset: t + 4
|
|
3725
|
+
}) : a === 27 ? (t + 8 > e.byteLength && Y("unexpected end of input"), {
|
|
3726
|
+
value: new S(e.getFloat64(t, !1), { precision: "double" }),
|
|
3727
|
+
nextOffset: t + 8
|
|
3728
|
+
}) : (a < 31 && Y(`reserved additional info value in major type 7: ${a}`), Y("unexpected break code outside indefinite-length item"));
|
|
3729
|
+
}
|
|
3730
|
+
return Y(`unknown major type: ${i}`);
|
|
3731
|
+
}
|
|
3732
|
+
function Kr(e) {
|
|
3733
|
+
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new Uint8Array(e);
|
|
3734
|
+
if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
3735
|
+
throw TypeError("expected ArrayBufferView or ArrayBufferLike");
|
|
3736
|
+
}
|
|
3737
|
+
function qr(e, t) {
|
|
3738
|
+
let n = Kr(e), r = new DataView(n.buffer, n.byteOffset, n.byteLength), i = t?.offset ?? 0;
|
|
3739
|
+
if (!Number.isInteger(i) || i < 0 || i > r.byteLength) throw RangeError(`CBOR decode offset must be an integer between 0 and ${r.byteLength}`);
|
|
3740
|
+
let { value: a, nextOffset: o } = Z(r, i, t);
|
|
3741
|
+
return !t?.allowTrailing && o !== r.byteLength && Y(`${r.byteLength - o} trailing byte(s) after end of CBOR item`), a;
|
|
3742
|
+
}
|
|
3743
|
+
//#endregion
|
|
3744
|
+
//#region src/extensions/cbordata.ts
|
|
3745
|
+
var Jr = 24n, Yr = [
|
|
3746
|
+
Ct,
|
|
3747
|
+
Ht,
|
|
3748
|
+
Gt,
|
|
3749
|
+
_n,
|
|
3750
|
+
Ur,
|
|
3751
|
+
{
|
|
3752
|
+
tagNumbers: [Jr],
|
|
3753
|
+
parseTag(e, t) {
|
|
3754
|
+
if (e === 24n && t instanceof w) try {
|
|
3755
|
+
return new C(Jr, new Pe([qr(t.value)]));
|
|
3756
|
+
} catch {
|
|
3757
|
+
return;
|
|
3758
|
+
}
|
|
3759
|
+
}
|
|
3760
|
+
}
|
|
3761
|
+
];
|
|
3762
|
+
//#endregion
|
|
3763
|
+
//#region src/js/fromJS.ts
|
|
3764
|
+
function Q(e, t) {
|
|
3765
|
+
if (t?.replacer) {
|
|
3766
|
+
let { replacer: n, ...r } = t, i = Qr(e, n, r.extensions, r.undefinedOmits);
|
|
3767
|
+
return i === l ? O.UNDEFINED : Q(i, Object.keys(r).length > 0 ? r : void 0);
|
|
3768
|
+
}
|
|
3769
|
+
return Xr(e, t, !0);
|
|
3770
|
+
}
|
|
3771
|
+
function Xr(e, t, n) {
|
|
3772
|
+
for (let n of [...t?.extensions ?? [], ...Yr]) if (n.fromJS) {
|
|
3773
|
+
let r = n.fromJS(e, t ?? {});
|
|
3774
|
+
if (r !== void 0) return r;
|
|
3775
|
+
}
|
|
3776
|
+
if (n && typeof e == "object" && e && c.symbol in e) {
|
|
3777
|
+
let n = e[c.symbol], r = Xr(e, t, !1);
|
|
3778
|
+
for (let e of [...t?.extensions ?? [], ...Yr]) if (e.parseTag) {
|
|
3779
|
+
let t = e.parseTag(n, r);
|
|
3780
|
+
if (t !== void 0) return t;
|
|
3781
|
+
}
|
|
3782
|
+
return new C(n, r);
|
|
3783
|
+
}
|
|
3784
|
+
if (e instanceof c.Null) return O.NULL;
|
|
3785
|
+
if (e instanceof c.Undefined) return O.UNDEFINED;
|
|
3786
|
+
if (e instanceof u) return new O(e.value);
|
|
3787
|
+
if (e === null) return O.NULL;
|
|
3788
|
+
if (e === void 0) return O.UNDEFINED;
|
|
3789
|
+
if (e === !0) return O.TRUE;
|
|
3790
|
+
if (e === !1) return O.FALSE;
|
|
3791
|
+
if (typeof e == "bigint") return e > 18446744073709551615n ? new We(e) : e < -18446744073709551616n ? new Ge(e) : e >= 0n ? new y(e) : new b(e);
|
|
3792
|
+
if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new y(BigInt(e)) : new b(BigInt(e)) : new S(e);
|
|
3793
|
+
if (typeof e == "string") return new A(e);
|
|
3794
|
+
if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return Xr(e.valueOf(), t, !1);
|
|
3795
|
+
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new w(new Uint8Array(e));
|
|
3796
|
+
if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new E(Array.from(e, (e) => new y(BigInt(e)))) : new w(new Uint8Array(e.buffer, e.byteOffset, e.byteLength));
|
|
3797
|
+
if (e instanceof $) return new D([...e].map(([e, n]) => [Q(e, t), Q(n, t)]));
|
|
3798
|
+
if (Array.isArray(e)) return new E(e.map((e) => Q(e, t)));
|
|
3799
|
+
if (typeof e == "object") {
|
|
3800
|
+
let n = [];
|
|
3801
|
+
for (let [r, i] of Object.entries(e)) n.push([new A(r), Q(i, t)]);
|
|
3802
|
+
return new D(n);
|
|
3803
|
+
}
|
|
3804
|
+
throw TypeError(`fromJS: unsupported value type: ${typeof e}`);
|
|
3805
|
+
}
|
|
3806
|
+
function Zr(e) {
|
|
3807
|
+
return ArrayBuffer.isView(e) || e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer || e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]" || e instanceof c.Null || e instanceof c.Undefined || e instanceof u;
|
|
3808
|
+
}
|
|
3809
|
+
function Qr(e, t, n, r) {
|
|
3810
|
+
let i = [...n ?? [], ...Yr];
|
|
3811
|
+
function a(e) {
|
|
3812
|
+
return e === l || r === !0 && e === void 0;
|
|
3813
|
+
}
|
|
3814
|
+
if (Array.isArray(t)) {
|
|
3815
|
+
let n = t.map(String);
|
|
3816
|
+
function r(e) {
|
|
3817
|
+
if (typeof e != "object" || !e) return e;
|
|
3818
|
+
if (e instanceof $) return $.from(e, ([e, t]) => [e, r(t)]);
|
|
3819
|
+
if (Array.isArray(e)) return e.map(r);
|
|
3820
|
+
if (c.symbol in e || Zr(e) || i.some((t) => t.isJSType?.(e))) return e;
|
|
3821
|
+
let t = Object.getPrototypeOf(e);
|
|
3822
|
+
if (t === Object.prototype || t === null) {
|
|
3823
|
+
let t = e.toJSON;
|
|
3824
|
+
if (typeof t == "function") return r(t.call(e));
|
|
3825
|
+
}
|
|
3826
|
+
let a = {};
|
|
3827
|
+
for (let t of n) Object.prototype.hasOwnProperty.call(e, t) && (a[t] = r(e[t]));
|
|
3828
|
+
return a;
|
|
3829
|
+
}
|
|
3830
|
+
return r(e);
|
|
3831
|
+
}
|
|
3832
|
+
let o = t;
|
|
3833
|
+
function s(e, t, n) {
|
|
3834
|
+
if (typeof e == "object" && e && !(e instanceof $)) {
|
|
3835
|
+
let n = Object.getPrototypeOf(e);
|
|
3836
|
+
if (n === Object.prototype || n === null) {
|
|
3837
|
+
let n = e.toJSON;
|
|
3838
|
+
typeof n == "function" && (e = n.call(e, t));
|
|
3839
|
+
}
|
|
3840
|
+
}
|
|
3841
|
+
if (e = o.call(n, t, e), typeof e == "object" && e) {
|
|
3842
|
+
if (c.symbol in e) return e;
|
|
3843
|
+
if (e instanceof $) {
|
|
3844
|
+
let t = new $();
|
|
3845
|
+
for (let [n, r] of e) {
|
|
3846
|
+
let i = s(r, n, e);
|
|
3847
|
+
a(i) || t.push([n, i]);
|
|
3848
|
+
}
|
|
3849
|
+
return t;
|
|
3850
|
+
}
|
|
3851
|
+
if (Array.isArray(e)) return e.map((t, n) => {
|
|
3852
|
+
let r = s(t, String(n), e);
|
|
3853
|
+
return a(r) ? null : r;
|
|
3854
|
+
});
|
|
3855
|
+
if (Zr(e) || i.some((t) => t.isJSType?.(e))) return e;
|
|
3856
|
+
let t = {};
|
|
3857
|
+
for (let n of Object.keys(e)) {
|
|
3858
|
+
let r = s(e[n], n, e);
|
|
3859
|
+
a(r) || (t[n] = r);
|
|
3860
|
+
}
|
|
3861
|
+
return t;
|
|
3862
|
+
}
|
|
3863
|
+
return e;
|
|
3864
|
+
}
|
|
3865
|
+
return s(e, "", { "": e });
|
|
3866
|
+
}
|
|
3867
|
+
//#endregion
|
|
3868
|
+
//#region src/mapEntries.ts
|
|
3869
|
+
var $ = class extends Array {
|
|
3870
|
+
toJSON() {
|
|
3871
|
+
let e = {};
|
|
3872
|
+
for (let [t, n] of this) {
|
|
3873
|
+
let r = typeof t == "string" ? t : Q(t).toEDN();
|
|
3874
|
+
r === "__proto__" ? Object.defineProperty(e, r, {
|
|
3875
|
+
value: n,
|
|
3876
|
+
writable: !0,
|
|
3877
|
+
enumerable: !0,
|
|
3878
|
+
configurable: !0
|
|
3879
|
+
}) : e[r] = n;
|
|
3880
|
+
}
|
|
3881
|
+
return e;
|
|
3882
|
+
}
|
|
3883
|
+
};
|
|
3884
|
+
//#endregion
|
|
3885
|
+
export { l as C, n as D, c as E, u as S, t as T, C as _, wt as a, y as b, Ge as c, O as d, D as f, w as g, Me as h, qr as i, We as l, T as m, Qr as n, A as o, E as p, Q as r, Ke as s, $ as t, Pe as u, S as v, e as w, d as x, b as y };
|
|
3886
|
+
|
|
3887
|
+
//# sourceMappingURL=mapEntries-CSjvgq1X.js.map
|