@cbortech/cbor 0.25.8 → 0.25.10

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.
@@ -1,81 +1,81 @@
1
- import { n as e, t } from "./tokenizer-IDqJN0Dw.js";
1
+ import { a as e, i as t, n, o as r, r as i, t as a } from "./tokenizer-DkLlZ1gc.js";
2
2
  //#region src/tag.ts
3
- var n = Symbol.for("cbor.tag"), r = class {
3
+ var o = Symbol.for("cbor.tag"), s = class {
4
4
  valueOf() {
5
5
  return null;
6
6
  }
7
7
  toJSON() {
8
8
  return null;
9
9
  }
10
- }, i = class {
10
+ }, c = class {
11
11
  valueOf() {}
12
12
  toJSON() {}
13
13
  };
14
- function a(e) {
15
- if (!l(e)) return;
16
- let t = e[n];
14
+ function l(e) {
15
+ if (!p(e)) return;
16
+ let t = e[o];
17
17
  return typeof t == "bigint" ? t : void 0;
18
18
  }
19
- function o(e, t) {
20
- let a;
19
+ function u(e, t) {
20
+ let n;
21
21
  switch (typeof e) {
22
22
  case "number":
23
- a = new Number(e);
23
+ n = new Number(e);
24
24
  break;
25
25
  case "string":
26
- a = new String(e);
26
+ n = new String(e);
27
27
  break;
28
28
  case "boolean":
29
- a = new Boolean(e);
29
+ n = new Boolean(e);
30
30
  break;
31
31
  case "bigint":
32
- a = Object(e);
32
+ n = Object(e);
33
33
  break;
34
34
  case "undefined":
35
- a = new i();
35
+ n = new c();
36
36
  break;
37
37
  case "object":
38
38
  if (e === null) {
39
- a = new r();
39
+ n = new s();
40
40
  break;
41
41
  }
42
- a = e;
42
+ n = e;
43
43
  break;
44
44
  default: throw TypeError(`setCborTag: cannot tag value of type ${typeof e}`);
45
45
  }
46
- return a[n] = t, a;
46
+ return n[o] = t, n;
47
47
  }
48
- function s(e) {
48
+ function d(e) {
49
49
  if (e instanceof Number || e instanceof String || e instanceof Boolean || Object.prototype.toString.call(e) === "[object BigInt]") return e.valueOf();
50
- if (e instanceof r) return null;
51
- if (!(e instanceof i)) return typeof e == "object" && e && delete e[n], e;
50
+ if (e instanceof s) return null;
51
+ if (!(e instanceof c)) return typeof e == "object" && e && delete e[o], e;
52
52
  }
53
- function c(e) {
53
+ function f(e) {
54
54
  if (e instanceof Number || e instanceof String || e instanceof Boolean || Object.prototype.toString.call(e) === "[object BigInt]") return e.valueOf();
55
- if (e instanceof r) return null;
56
- if (!(e instanceof i)) return e;
55
+ if (e instanceof s) return null;
56
+ if (!(e instanceof c)) return e;
57
57
  }
58
- function l(e) {
58
+ function p(e) {
59
59
  return typeof e == "object" && !!e;
60
60
  }
61
- var u = class {
61
+ var m = class {
62
62
  constructor() {}
63
- static symbol = n;
64
- static Null = r;
65
- static Undefined = i;
63
+ static symbol = o;
64
+ static Null = s;
65
+ static Undefined = c;
66
66
  static get(e) {
67
- return a(e);
67
+ return l(e);
68
68
  }
69
69
  static set(e, t) {
70
- return o(e, t);
70
+ return u(e, t);
71
71
  }
72
72
  static remove(e) {
73
- return s(e);
73
+ return d(e);
74
74
  }
75
75
  static getValue(e) {
76
- return c(e);
76
+ return f(e);
77
77
  }
78
- }, d = Symbol("cbor.omit"), f = class e {
78
+ }, h = Symbol("cbor.omit"), g = class e {
79
79
  value;
80
80
  constructor(e) {
81
81
  if (!Number.isInteger(e) || e < 0 || e > 255) throw RangeError("Simple value must be an integer in 0–255");
@@ -93,45 +93,26 @@ var u = class {
93
93
  static get(t) {
94
94
  return t instanceof e ? t.value : void 0;
95
95
  }
96
- }, p = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0")), m = (/* @__PURE__ */ new Int8Array(128)).fill(-1);
97
- for (let e = 0; e < 16; e++) m["0123456789abcdef".charCodeAt(e)] = e, m["0123456789ABCDEF".charCodeAt(e)] = e;
98
- var h = typeof Uint8Array.prototype.toHex == "function", g = typeof Uint8Array.fromHex == "function", ee = 256;
99
- function te(e) {
100
- if (h) return e.toHex();
101
- let t = "";
102
- for (let n = 0; n < e.length; n++) t += p[e[n]];
103
- return t;
104
- }
105
- function ne(e) {
106
- if (e.length % 2 != 0) throw SyntaxError(`hex string has odd length: ${e.length}`);
107
- if (g && e.length >= ee) return Uint8Array.fromHex(e);
108
- let t = new Uint8Array(e.length / 2);
109
- for (let n = 0, r = 0; n < e.length; n += 2, r++) {
110
- let i = e.charCodeAt(n), a = e.charCodeAt(n + 1), o = i < 128 ? m[i] : -1, s = a < 128 ? m[a] : -1;
111
- if ((o | s) < 0) {
112
- let t = o < 0 ? e[n] : e[n + 1];
113
- throw SyntaxError(`invalid character ${JSON.stringify(t)} in hex string`);
114
- }
115
- t[r] = o << 4 | s;
116
- }
117
- return t;
118
- }
96
+ };
119
97
  //#endregion
120
98
  //#region src/cdn/serialize-utils.ts
121
- function re(e) {
99
+ function _(e) {
122
100
  let t = e?.indent;
123
101
  return t === void 0 ? null : typeof t == "number" ? " ".repeat(t) : t;
124
102
  }
125
- function _(e, t) {
103
+ function v(e, t) {
126
104
  return e.repeat(t);
127
105
  }
128
- function ie(e) {
106
+ function ee(e, t, n) {
107
+ return t === null ? e.join(" + ") : e.join(` +\n${v(t, n + 1)}`);
108
+ }
109
+ function te(e) {
129
110
  return !!(e.comments?.leading?.length || e.comments?.trailing?.length || e.comments?.dangling?.length);
130
111
  }
131
- function ae(e) {
112
+ function ne(e) {
132
113
  return !!(e.comments?.trailing?.length || e.comments?.dangling?.length);
133
114
  }
134
- function v(e, t) {
115
+ function y(e, t) {
135
116
  if (!t) return e.text;
136
117
  let { marker: n, text: r } = e;
137
118
  if (t === "c-style") return n === "#" ? "//" + r.slice(1) : n === "/" ? "/*" + r.slice(1, -1) + "*/" : r;
@@ -142,17 +123,17 @@ function v(e, t) {
142
123
  }
143
124
  return r;
144
125
  }
145
- function oe(e, t, n) {
146
- return (e.comments?.leading ?? []).map((e) => t + v(e, n));
126
+ function re(e, t, n) {
127
+ return (e.comments?.leading ?? []).map((e) => t + y(e, n));
147
128
  }
148
- function se(e, t) {
129
+ function b(e, t) {
149
130
  let n = e.comments?.trailing ?? [];
150
- return n.length === 0 ? "" : " " + n.map((e) => v(e, t)).join(" ");
131
+ return n.length === 0 ? "" : " " + n.map((e) => y(e, t)).join(" ");
151
132
  }
152
- function ce(e, t, n) {
153
- return (e.comments?.dangling ?? []).map((e) => t + v(e, n));
133
+ function ie(e, t, n) {
134
+ return (e.comments?.dangling ?? []).map((e) => t + y(e, n));
154
135
  }
155
- function le(e, t = !1) {
136
+ function ae(e, t = !1) {
156
137
  let n = e?.commas ?? "comma", r = n !== "none";
157
138
  return {
158
139
  inlineSep: r ? t ? "," : ", " : " ",
@@ -161,15 +142,32 @@ function le(e, t = !1) {
161
142
  colSep: t ? ":" : ": "
162
143
  };
163
144
  }
164
- var ue = typeof (/* @__PURE__ */ new Uint8Array()).toBase64 == "function";
165
- function de(e) {
166
- if (ue) return e.toBase64({ omitPadding: !0 });
145
+ function oe(e) {
146
+ let { options: t, depth: n, openChar: r, closeChar: i, count: a } = e, o = _(t), s = t?.preserveComments, c = typeof s == "string" ? s : void 0, l = s && (ne(e.node) || e.hasEntryComments());
147
+ o === null && l && (o = " ");
148
+ let { inlineSep: u, multilineSep: d, trailSep: f, colSep: p } = ae(t, o === null), m = e.indefiniteLength ? "" : S(t, e.encodingWidth, () => x(BigInt(a))), h = m ? m + " " : "", g = e.indefiniteLength && (t?.encodingIndicators ?? "auto") !== "never";
149
+ if (o === null || a === 0 && !l) {
150
+ let t = "";
151
+ for (let n = 0; n < a; n++) n > 0 && (t += u), t += e.renderEntry(n, p);
152
+ return e.indefiniteLength ? g ? a === 0 ? `${r}_ ${i}` : `${r}_ ${t}${i}` : `${r}${t}${i}` : `${r}${h}${t}${i}`;
153
+ }
154
+ let ee = v(o, n + 1), te = v(o, n), y = e.indefiniteLength ? g ? `${r}_ ` : r : `${r}${h}`, b = [];
155
+ for (let t = 0; t < a; t++) {
156
+ s && b.push(...re(e.entryLeadingNode(t), ee, c));
157
+ let n = t < a - 1 ? d : f;
158
+ b.push(`${ee}${e.renderEntry(t, p)}${n}${s ? e.entryTrailing(t, c) : ""}`);
159
+ }
160
+ return s && b.push(...ie(e.node, ee, c)), `${y}\n${b.join("\n")}\n${te}${i}`;
161
+ }
162
+ var se = typeof (/* @__PURE__ */ new Uint8Array()).toBase64 == "function";
163
+ function ce(e) {
164
+ if (se) return e.toBase64({ omitPadding: !0 });
167
165
  let t = "";
168
166
  for (let n of e) t += String.fromCharCode(n);
169
167
  return btoa(t).replace(/=/g, "");
170
168
  }
171
- function fe(e) {
172
- if (ue) return e.toBase64({
169
+ function le(e) {
170
+ if (se) return e.toBase64({
173
171
  alphabet: "base64url",
174
172
  omitPadding: !0
175
173
  });
@@ -177,54 +175,54 @@ function fe(e) {
177
175
  for (let n of e) t += String.fromCharCode(n);
178
176
  return btoa(t).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
179
177
  }
180
- var pe = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", me = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
181
- function he(e, t) {
178
+ var ue = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", de = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
179
+ function fe(e, t) {
182
180
  let n = "", r = 0, i = 0;
183
181
  for (let a of e) for (r = r << 8 | a, i += 8; i >= 5;) i -= 5, n += t[r >> i & 31];
184
182
  return i > 0 && (n += t[r << 5 - i & 31]), n;
185
183
  }
186
- function ge(e) {
184
+ function pe(e) {
187
185
  for (let t of e) {
188
186
  let e = t.codePointAt(0);
189
187
  if (e < 32 || e === 127) return !0;
190
188
  }
191
189
  return !1;
192
190
  }
193
- function _e(e, t, n) {
191
+ function me(e, t, n) {
194
192
  if (n === "string") {
195
- let t = ye(e);
196
- if (t != null) return Se(t);
193
+ let t = ge(e);
194
+ if (t != null) return ye(t);
197
195
  }
198
196
  if (n === "printable-string" || n === void 0) {
199
- let t = ye(e);
200
- if (t != null && !ge(t)) return Se(t);
197
+ let t = ge(e);
198
+ if (t != null && !pe(t)) return ye(t);
201
199
  }
202
200
  switch (t) {
203
- case "base64": return `b64'${de(e)}'`;
204
- case "base64url": return `b64'${fe(e)}'`;
205
- case "base32": return `b32'${he(e, pe)}'`;
206
- case "base32hex": return `h32'${he(e, me)}'`;
207
- default: return `h'${te(e)}'`;
201
+ case "base64": return `b64'${ce(e)}'`;
202
+ case "base64url": return `b64'${le(e)}'`;
203
+ case "base32": return `b32'${fe(e, ue)}'`;
204
+ case "base32hex": return `h32'${fe(e, de)}'`;
205
+ default: return `h'${i(e)}'`;
208
206
  }
209
207
  }
210
- var ve = new TextDecoder("utf-8", { fatal: !0 });
211
- function ye(e) {
208
+ var he = new TextDecoder("utf-8", { fatal: !0 });
209
+ function ge(e) {
212
210
  try {
213
- return ve.decode(e);
211
+ return he.decode(e);
214
212
  } catch {
215
213
  return null;
216
214
  }
217
215
  }
218
- function be(e, t) {
216
+ function _e(e, t) {
219
217
  for (let n = 0; n < e.length; n++) {
220
218
  let r = e.charCodeAt(n);
221
219
  if (r === t || r === 92 || r < 32 || r === 127 || r >= 8192 && (r === 8232 || r === 8233 || r >= 8203 && r <= 8205 || r === 65279)) return !0;
222
220
  }
223
221
  return !1;
224
222
  }
225
- function xe(e, t) {
223
+ function ve(e, t) {
226
224
  let n = t.codePointAt(0);
227
- if (!be(e, n)) return t + e + t;
225
+ if (!_e(e, n)) return t + e + t;
228
226
  let r = t;
229
227
  for (let i of e) {
230
228
  let e = i.codePointAt(0);
@@ -249,40 +247,40 @@ function xe(e, t) {
249
247
  }
250
248
  return r + t;
251
249
  }
252
- function Se(e) {
253
- return xe(e, "'");
250
+ function ye(e) {
251
+ return ve(e, "'");
254
252
  }
255
- function Ce(e) {
256
- return xe(e, "'");
253
+ function be(e) {
254
+ return ve(e, "'");
257
255
  }
258
- function we(e) {
259
- return xe(e, "\"");
256
+ function xe(e) {
257
+ return ve(e, "\"");
260
258
  }
261
- function Te(e) {
259
+ function Se(e) {
262
260
  if (isNaN(e)) return "NaN";
263
261
  if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
264
262
  if (Object.is(e, -0)) return "-0.0";
265
263
  let t = e.toString();
266
264
  return t.includes(".") || t.includes("e") ? t : t + ".0";
267
265
  }
268
- function Ee(e, t, n, r) {
266
+ function Ce(e, t, n, r) {
269
267
  if (r === "never") return "";
270
268
  let i = t ?? n;
271
269
  return r === "always" ? i === "half" ? "_1" : i === "single" ? "_2" : "_3" : t === void 0 || t === n ? "" : t === "half" ? "_1" : t === "single" ? "_2" : "_3";
272
270
  }
273
- function y(e) {
271
+ function x(e) {
274
272
  return e <= 23n ? "i" : e <= 255n ? 0 : e <= 65535n ? 1 : e <= 4294967295n ? 2 : 3;
275
273
  }
276
- function b(e, t, n) {
274
+ function S(e, t, n) {
277
275
  let r = e?.encodingIndicators ?? "auto";
278
276
  return r === "never" ? "" : r === "always" ? `_${t ?? n()}` : t === void 0 ? "" : `_${t}`;
279
277
  }
280
278
  //#endregion
281
279
  //#region src/utils/float16.ts
282
- var De = "getFloat16" in DataView.prototype && "setFloat16" in DataView.prototype, Oe = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
283
- function x(e) {
284
- Oe.setFloat64(0, e, !1);
285
- let t = Oe.getUint32(0, !1), n = Oe.getUint32(4, !1), r = t >>> 31 & 1, i = t >>> 20 & 2047, a = t & 1048575;
280
+ var we = "getFloat16" in DataView.prototype && "setFloat16" in DataView.prototype, Te = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
281
+ function C(e) {
282
+ Te.setFloat64(0, e, !1);
283
+ let t = Te.getUint32(0, !1), n = Te.getUint32(4, !1), r = t >>> 31 & 1, i = t >>> 20 & 2047, a = t & 1048575;
286
284
  if (i === 2047) {
287
285
  if (a === 0 && n === 0) return r << 15 | 31744;
288
286
  let e = a >> 10 | (n === 0 ? 0 : 1) || 1;
@@ -303,15 +301,27 @@ function x(e) {
303
301
  let u = o <= 0 ? 0 : o;
304
302
  return r << 15 | u << 10 | s;
305
303
  }
306
- function S(e) {
304
+ function w(e) {
307
305
  let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023;
308
306
  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);
309
307
  }
310
- var ke = De ? (e, t, n, r) => {
308
+ var Ee = we ? (e, t, n, r) => {
311
309
  e.setFloat16(t, n, r);
312
310
  } : (e, t, n, r) => {
313
- e.setUint16(t, x(n), r);
314
- }, C = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8)), w = new Uint8Array(C.buffer), Ae = class {
311
+ e.setUint16(t, C(n), r);
312
+ }, T = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8)), E = new Uint8Array(T.buffer), De = new TextEncoder(), Oe = typeof De.encodeInto == "function";
313
+ function ke(e) {
314
+ return e <= 23 ? 1 : e <= 255 ? 2 : e <= 65535 ? 3 : e <= 4294967295 ? 5 : 9;
315
+ }
316
+ function Ae(e) {
317
+ return e === "i" ? 1 : [
318
+ 2,
319
+ 3,
320
+ 5,
321
+ 9
322
+ ][e];
323
+ }
324
+ var je = class {
315
325
  buf;
316
326
  len = 0;
317
327
  constructor(e = 256) {
@@ -342,34 +352,45 @@ var ke = De ? (e, t, n, r) => {
342
352
  t[this.len++] = e >>> 24 & 255, t[this.len++] = e >>> 16 & 255, t[this.len++] = e >>> 8 & 255, t[this.len++] = e & 255;
343
353
  }
344
354
  writeBigUint64(e) {
345
- C.setBigUint64(0, e, !1), this._ensure(8), this.buf.set(w, this.len), this.len += 8;
355
+ T.setBigUint64(0, e, !1), this._ensure(8), this.buf.set(E, this.len), this.len += 8;
346
356
  }
347
357
  writeFloat16(e) {
348
- ke(C, 0, e, !1), this._ensure(2);
358
+ Ee(T, 0, e, !1), this._ensure(2);
349
359
  let t = this.buf;
350
- t[this.len++] = w[0], t[this.len++] = w[1];
360
+ t[this.len++] = E[0], t[this.len++] = E[1];
351
361
  }
352
362
  writeFloat32(e) {
353
- C.setFloat32(0, e, !1), this._ensure(4);
363
+ T.setFloat32(0, e, !1), this._ensure(4);
354
364
  let t = this.buf;
355
- t[this.len++] = w[0], t[this.len++] = w[1], t[this.len++] = w[2], t[this.len++] = w[3];
365
+ t[this.len++] = E[0], t[this.len++] = E[1], t[this.len++] = E[2], t[this.len++] = E[3];
356
366
  }
357
367
  writeFloat64(e) {
358
- C.setFloat64(0, e, !1), this._ensure(8), this.buf.set(w, this.len), this.len += 8;
368
+ T.setFloat64(0, e, !1), this._ensure(8), this.buf.set(E, this.len), this.len += 8;
369
+ }
370
+ writeTextString(e, t, n) {
371
+ if (!Oe) {
372
+ let r = De.encode(t);
373
+ D(this, e, r.length, n), this.writeBytes(r);
374
+ return;
375
+ }
376
+ let r = n === void 0 ? ke(t.length) : Ae(n);
377
+ this._ensure(9 + 3 * t.length);
378
+ let { written: i } = De.encodeInto(t, this.buf.subarray(this.len + r)), a = n === void 0 ? ke(i) : r;
379
+ a !== r && this.buf.copyWithin(this.len + a, this.len + r, this.len + r + i), D(this, e, i, n), this.len += i;
359
380
  }
360
381
  finish() {
361
382
  return this.buf.slice(0, this.len);
362
383
  }
363
- }, je = [
384
+ }, Me = [
364
385
  255n,
365
386
  65535n,
366
387
  4294967295n,
367
388
  18446744073709551615n
368
389
  ];
369
- function Me(e) {
370
- return e === "i" ? 23n : je[e];
390
+ function Ne(e) {
391
+ return e === "i" ? 23n : Me[e];
371
392
  }
372
- function T(e, t, n, r) {
393
+ function D(e, t, n, r) {
373
394
  if (r === void 0 && typeof n == "number" && n < 4294967296) {
374
395
  n <= 23 ? e.writeByte(t << 5 | n) : n <= 255 ? (e.writeByte(t << 5 | 24), e.writeByte(n)) : n <= 65535 ? (e.writeByte(t << 5 | 25), e.writeUint16(n)) : (e.writeByte(t << 5 | 26), e.writeUint32(n));
375
396
  return;
@@ -381,30 +402,30 @@ function T(e, t, n, r) {
381
402
  e.writeByte(t << 5 | Number(i));
382
403
  return;
383
404
  }
384
- if (i > je[r]) throw RangeError(`value ${i} does not fit in encodingWidth _${r} (max ${je[r]})`);
405
+ if (i > Me[r]) throw RangeError(`value ${i} does not fit in encodingWidth _${r} (max ${Me[r]})`);
385
406
  let n = 24 + r;
386
407
  e.writeByte(t << 5 | n), n === 24 ? e.writeByte(Number(i)) : n === 25 ? e.writeUint16(Number(i)) : n === 26 ? e.writeUint32(Number(i)) : e.writeBigUint64(i);
387
408
  return;
388
409
  }
389
410
  i <= 23n ? e.writeByte(t << 5 | Number(i)) : i <= 255n ? (e.writeByte(t << 5 | 24), e.writeByte(Number(i))) : i <= 65535n ? (e.writeByte(t << 5 | 25), e.writeUint16(Number(i))) : i <= 4294967295n ? (e.writeByte(t << 5 | 26), e.writeUint32(Number(i))) : (e.writeByte(t << 5 | 27), e.writeBigUint64(i));
390
411
  }
391
- function Ne(e, t, n) {
392
- let r = new Ae(9);
393
- return T(r, e, t, n), r.finish();
394
- }
395
- var Pe = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(4));
396
- function Fe(e) {
397
- return Object.is(S(x(e)), e);
412
+ function Pe(e, t, n) {
413
+ let r = new je(9);
414
+ return D(r, e, t, n), r.finish();
398
415
  }
416
+ var Fe = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(4));
399
417
  function Ie(e) {
400
- return Pe.setFloat32(0, e, !1), Object.is(Pe.getFloat32(0, !1), e);
418
+ return Object.is(w(C(e)), e);
419
+ }
420
+ function Le(e) {
421
+ return Fe.setFloat32(0, e, !1), Object.is(Fe.getFloat32(0, !1), e);
401
422
  }
402
- function E(e) {
403
- return Fe(e) ? "half" : Ie(e) ? "single" : "double";
423
+ function O(e) {
424
+ return Ie(e) ? "half" : Le(e) ? "single" : "double";
404
425
  }
405
426
  //#endregion
406
427
  //#region src/ast/CborItem.ts
407
- var D = class e {
428
+ var k = class e {
408
429
  start;
409
430
  end;
410
431
  comments;
@@ -414,7 +435,7 @@ var D = class e {
414
435
  let t = this._defaults ? {
415
436
  ...this._defaults,
416
437
  ...e
417
- } : e, n = new Ae();
438
+ } : e, n = new je();
418
439
  return this._encode(n, t), n.finish();
419
440
  }
420
441
  toCDN(e) {
@@ -423,7 +444,7 @@ var D = class e {
423
444
  ...e
424
445
  } : e, n = this._toCDN(t, 0), r = t?.preserveComments;
425
446
  if (!r) return n;
426
- let i = typeof r == "string" ? r : void 0, a = this.comments?.leading?.map((e) => v(e, i)) ?? [], o = this.comments?.trailing ?? [], s = o.length === 0 ? n : `${n} ${o.map((e) => v(e, i).trimEnd()).join(" ")}`;
447
+ let i = typeof r == "string" ? r : void 0, a = this.comments?.leading?.map((e) => y(e, i)) ?? [], o = this.comments?.trailing ?? [], s = o.length === 0 ? n : `${n} ${o.map((e) => y(e, i).trimEnd()).join(" ")}`;
427
448
  return [...a, s].join("\n");
428
449
  }
429
450
  toEDN(e) {
@@ -436,14 +457,19 @@ var D = class e {
436
457
  } : e, n = this._toJS(t);
437
458
  if (!t?.reviver) return n;
438
459
  let r = t.reviver.call({ "": n }, "", n);
439
- return r === d ? void 0 : r;
460
+ return r === h ? void 0 : r;
440
461
  }
441
462
  toHexDump(e) {
442
463
  let t = this._defaults ? {
443
464
  ...this._defaults,
444
465
  ...e
445
- } : 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;
446
- return a.map((e) => (r.repeat(e.depth) + e.hex).padEnd(o) + i + e.comment).join("\n");
466
+ } : e, n = t?.indent ?? 3, r = typeof n == "string" ? n : " ".repeat(n), i = (t?.commentStyle ?? "--") + " ", a = this._toHexDump(0, t), o = 0;
467
+ for (let e of a) {
468
+ let t = e.depth * r.length + e.hex.length;
469
+ t > o && (o = t);
470
+ }
471
+ let s = o + 2;
472
+ return a.map((e) => (r.repeat(e.depth) + e.hex).padEnd(s) + i + e.comment).join("\n");
447
473
  }
448
474
  _encode(t, n) {
449
475
  if (this._toCBOR !== e.prototype._toCBOR) {
@@ -457,17 +483,17 @@ var D = class e {
457
483
  t.writeBytes(this._toCBOR(n));
458
484
  }
459
485
  _toCBOR(e) {
460
- let t = new Ae();
486
+ let t = new je();
461
487
  return this._encodeTo(t, e), t.finish();
462
488
  }
463
- _toHexDump(e, t) {
489
+ _toHexDump(e, n) {
464
490
  return [{
465
491
  depth: e,
466
- hex: Array.from(this._toCBOR(), (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" "),
467
- comment: this._toCDN(t, 0)
492
+ hex: t(this._toCBOR()),
493
+ comment: this._toCDN(n, 0)
468
494
  }];
469
495
  }
470
- }, O = class extends D {
496
+ }, A = class extends k {
471
497
  value;
472
498
  encodingWidth;
473
499
  constructor(e, t) {
@@ -476,10 +502,10 @@ var D = class e {
476
502
  this.encodingWidth = t?.encodingWidth;
477
503
  }
478
504
  _encodeTo(e, t) {
479
- T(e, 0, this.value, this.encodingWidth);
505
+ D(e, 0, this.value, this.encodingWidth);
480
506
  }
481
507
  _toCDN(e, t) {
482
- let n = b(e, this.encodingWidth, () => y(this.value)), r = this.value;
508
+ let n = S(e, this.encodingWidth, () => x(this.value)), r = this.value;
483
509
  switch (e?.intFormat) {
484
510
  case "hex": return `0x${r.toString(16)}${n}`;
485
511
  case "octal": return `0o${r.toString(8)}${n}`;
@@ -491,7 +517,7 @@ var D = class e {
491
517
  let t = e?.integerAs ?? "auto";
492
518
  return t === "bigint" ? this.value : t === "number" || this.value <= BigInt(2 ** 53 - 1) ? Number(this.value) : this.value;
493
519
  }
494
- }, k = class extends D {
520
+ }, j = class extends k {
495
521
  argument;
496
522
  encodingWidth;
497
523
  constructor(e, t) {
@@ -505,10 +531,10 @@ var D = class e {
505
531
  return -1n - this.argument;
506
532
  }
507
533
  _encodeTo(e, t) {
508
- T(e, 1, this.argument, this.encodingWidth);
534
+ D(e, 1, this.argument, this.encodingWidth);
509
535
  }
510
536
  _toCDN(e, t) {
511
- let n = b(e, this.encodingWidth, () => y(this.argument)), r = this.argument + 1n;
537
+ let n = S(e, this.encodingWidth, () => x(this.argument)), r = this.argument + 1n;
512
538
  switch (e?.intFormat) {
513
539
  case "hex": return `-0x${r.toString(16)}${n}`;
514
540
  case "octal": return `-0o${r.toString(8)}${n}`;
@@ -520,8 +546,8 @@ var D = class e {
520
546
  let t = this.value, n = e?.integerAs ?? "auto";
521
547
  return n === "bigint" ? t : n === "number" || t >= BigInt(-(2 ** 53 - 1)) ? Number(t) : t;
522
548
  }
523
- }, Le = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
524
- function Re(e) {
549
+ }, Re = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
550
+ function ze(e) {
525
551
  let t = e.startsWith("-"), n = e.slice(t ? 3 : 2), r = n.search(/[pP]/);
526
552
  if (r === -1) throw SyntaxError(`EDN parse error: hex float missing 'p' exponent: ${e}`);
527
553
  let i = n.slice(0, r), a = n.slice(r + 1);
@@ -539,29 +565,30 @@ function Re(e) {
539
565
  let l = c * 2 ** o;
540
566
  return t ? -l : l;
541
567
  }
542
- function ze(e) {
568
+ function Be(e) {
543
569
  if (isNaN(e)) return "NaN";
544
570
  if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
545
571
  let t = Object.is(e, -0) || e < 0, n = Math.abs(e);
546
572
  if (n === 0) return t ? "-0x0p+0" : "0x0p+0";
547
- Le.setFloat64(0, n, !1);
548
- let r = Le.getUint32(0, !1), i = Le.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;
573
+ Re.setFloat64(0, n, !1);
574
+ let r = Re.getUint32(0, !1), i = Re.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;
549
575
  a === 0 ? (u = "0", d = -1022) : (u = "1", d = a - 1023);
550
576
  let f = d >= 0 ? `+${d}` : `${d}`, p = `0x${u}${l}p${f}`;
551
577
  return t ? `-${p}` : p;
552
578
  }
553
579
  //#endregion
554
580
  //#region src/ast/CborFloat.ts
555
- var A = class extends D {
581
+ var M = class extends k {
556
582
  value;
557
583
  precision;
558
584
  ednSource;
585
+ rawBits;
559
586
  constructor(e, t) {
560
- super(), this.value = e, this.precision = t?.precision;
587
+ super(), this.value = e, this.precision = t?.precision, this.rawBits = t?.rawBits;
561
588
  }
562
589
  _encodeTo(e, t) {
563
- let n = this.precision ?? E(this.value);
564
- n === "half" ? (e.writeByte(249), e.writeFloat16(this.value)) : n === "single" ? (e.writeByte(250), e.writeFloat32(this.value)) : (e.writeByte(251), e.writeFloat64(this.value));
590
+ let n = this.precision ?? O(this.value), r = Number.isNaN(this.value) ? this.rawBits : void 0;
591
+ n === "half" ? (e.writeByte(249), r?.length === 2 ? e.writeBytes(r) : e.writeFloat16(this.value)) : n === "single" ? (e.writeByte(250), r?.length === 4 ? e.writeBytes(r) : e.writeFloat32(this.value)) : (e.writeByte(251), r?.length === 8 ? e.writeBytes(r) : e.writeFloat64(this.value));
565
592
  }
566
593
  _toCDN(e, t) {
567
594
  let n = e?.encodingIndicators ?? "auto";
@@ -569,18 +596,18 @@ var A = class extends D {
569
596
  if (n === "never") return this.ednSource.replace(/_[0-3i]$/, "");
570
597
  if (n === "always") {
571
598
  if (/_[0-3i]$/.test(this.ednSource)) return this.ednSource;
572
- let e = this.precision ?? E(this.value), t = e === "half" ? "_1" : e === "single" ? "_2" : "_3";
599
+ let e = this.precision ?? O(this.value), t = e === "half" ? "_1" : e === "single" ? "_2" : "_3";
573
600
  return this.ednSource + t;
574
601
  }
575
602
  return this.ednSource;
576
603
  }
577
- let r = E(this.value);
578
- return (e?.floatFormat === "hex" ? ze(this.value) : Te(this.value)) + Ee(this.value, this.precision, r, n);
604
+ let r = O(this.value);
605
+ return (e?.floatFormat === "hex" ? Be(this.value) : Se(this.value)) + Ce(this.value, this.precision, r, n);
579
606
  }
580
607
  _toJS(e) {
581
608
  return this.value;
582
609
  }
583
- }, j = class extends D {
610
+ }, N = class extends k {
584
611
  tag;
585
612
  content;
586
613
  encodingWidth;
@@ -589,52 +616,59 @@ var A = class extends D {
589
616
  this.content = t, this.encodingWidth = n?.encodingWidth;
590
617
  }
591
618
  _encodeTo(e, t) {
592
- T(e, 6, this.tag, this.encodingWidth), this.content._encode(e, t);
619
+ D(e, 6, this.tag, this.encodingWidth), this.content._encode(e, t);
593
620
  }
594
621
  _toCDN(e, t) {
595
- let n = b(e, this.encodingWidth, () => y(this.tag));
622
+ let n = S(e, this.encodingWidth, () => x(this.tag));
596
623
  return `${this.tag}${n}(${this.content._toCDN(e, t)})`;
597
624
  }
598
- _toHexDump(e, t) {
599
- let n = [{
625
+ _toHexDump(e, n) {
626
+ let r = [{
600
627
  depth: e,
601
- hex: ((e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" "))(Ne(6, this.tag, this.encodingWidth)),
628
+ hex: t(Pe(6, this.tag, this.encodingWidth)),
602
629
  comment: `Tag ${this.tag}`
603
630
  }];
604
- return n.push(...this.content._toHexDump(e + 1, {
605
- ...t,
631
+ return r.push(...this.content._toHexDump(e + 1, {
632
+ ...n,
606
633
  appStrings: !1
607
- })), n;
634
+ })), r;
608
635
  }
609
636
  _toJS(e) {
610
637
  let t = this.content._toJS(e);
611
- return e?.stripTags ? t : u.set(t, this.tag);
638
+ return e?.stripTags ? t : m.set(t, this.tag);
612
639
  }
613
- }, M = class extends D {
640
+ }, P = class extends k {
614
641
  indefiniteLength = !1;
615
642
  value;
616
643
  ednEncoding;
617
644
  encodingWidth;
618
645
  ednSource;
646
+ ednParts;
619
647
  constructor(e, t) {
620
- super(), this.value = e, this.ednEncoding = t?.ednEncoding ?? "hex", this.encodingWidth = t?.encodingWidth, this.ednSource = t?.ednSource;
648
+ super(), this.value = e, this.ednEncoding = t?.ednEncoding ?? "hex", this.encodingWidth = t?.encodingWidth, this.ednSource = t?.ednSource, this.ednParts = t?.ednParts;
621
649
  }
622
650
  _encodeTo(e, t) {
623
- T(e, 2, this.value.length, this.encodingWidth), e.writeBytes(this.value);
651
+ D(e, 2, this.value.length, this.encodingWidth), e.writeBytes(this.value);
624
652
  }
625
653
  _toCDN(e, t) {
654
+ if (e?.preserveConcatenation && this.ednParts !== void 0 && this.ednParts.length > 1) {
655
+ let n = S(e, this.encodingWidth, () => x(BigInt(this.value.length))), r = e?.bstrEncoding ?? this.ednEncoding;
656
+ e?.appStrings === !1 && r !== "hex" && (r = "hex");
657
+ let i = this.ednParts.map((t) => e?.preserveByteString && t.source !== void 0 ? t.source : me(t.bytes, r, e?.sqstr));
658
+ return i[i.length - 1] += n, ee(i, _(e), t);
659
+ }
626
660
  if (e?.preserveByteString && this.ednSource !== void 0) {
627
661
  if (/_[0-3i]$/.test(this.ednSource)) return (e?.encodingIndicators ?? "auto") === "never" ? this.ednSource.replace(/_[0-3i]$/, "") : this.ednSource;
628
- let t = b(e, this.encodingWidth, () => y(BigInt(this.value.length)));
662
+ let t = S(e, this.encodingWidth, () => x(BigInt(this.value.length)));
629
663
  return this.ednSource + t;
630
664
  }
631
- let n = b(e, this.encodingWidth, () => y(BigInt(this.value.length))), r = e?.bstrEncoding ?? this.ednEncoding;
632
- return e?.appStrings === !1 && r !== "hex" && (r = "hex"), _e(this.value, r, e?.sqstr) + n;
665
+ let n = S(e, this.encodingWidth, () => x(BigInt(this.value.length))), r = e?.bstrEncoding ?? this.ednEncoding;
666
+ return e?.appStrings === !1 && r !== "hex" && (r = "hex"), me(this.value, r, e?.sqstr) + n;
633
667
  }
634
668
  _toJS(e) {
635
669
  return this.value;
636
670
  }
637
- }, N = class extends D {
671
+ }, F = class extends k {
638
672
  indefiniteLength = !0;
639
673
  chunks;
640
674
  constructor(e) {
@@ -649,12 +683,12 @@ var A = class extends D {
649
683
  if ((e?.encodingIndicators ?? "auto") === "never") {
650
684
  let t = this.chunks.reduce((e, t) => e + t.value.length, 0), n = new Uint8Array(t), r = 0;
651
685
  for (let e of this.chunks) n.set(e.value, r), r += e.value.length;
652
- return new M(n)._toCDN(e, 0);
686
+ return new P(n)._toCDN(e, 0);
653
687
  }
654
688
  return this.chunks.length === 0 ? "''_" : `(_ ${this.chunks.map((t) => t._toCDN(e, 0)).join(", ")})`;
655
689
  }
656
690
  _toHexDump(e, t) {
657
- let n = (e) => e.toString(16).toUpperCase().padStart(2, "0"), r = [{
691
+ let r = [{
658
692
  depth: e,
659
693
  hex: n(95),
660
694
  comment: "Start indefinite-length byte string"
@@ -671,7 +705,7 @@ var A = class extends D {
671
705
  for (let e of this.chunks) n.set(e.value, r), r += e.value.length;
672
706
  return n;
673
707
  }
674
- }, P = class extends D {
708
+ }, I = class extends k {
675
709
  indefiniteLength = !0;
676
710
  chunks;
677
711
  constructor(e) {
@@ -683,10 +717,10 @@ var A = class extends D {
683
717
  e.writeByte(255);
684
718
  }
685
719
  _toCDN(e, t) {
686
- return (e?.encodingIndicators ?? "auto") === "never" ? new z(this.chunks.map((e) => e.value).join(""))._toCDN(e, t) : this.chunks.length === 0 ? "\"\"_" : `(_ ${this.chunks.map((t) => t._toCDN(e, 0)).join(", ")})`;
720
+ return (e?.encodingIndicators ?? "auto") === "never" ? new V(this.chunks.map((e) => e.value).join(""))._toCDN(e, t) : this.chunks.length === 0 ? "\"\"_" : `(_ ${this.chunks.map((t) => t._toCDN(e, 0)).join(", ")})`;
687
721
  }
688
722
  _toHexDump(e, t) {
689
- let n = (e) => e.toString(16).toUpperCase().padStart(2, "0"), r = [{
723
+ let r = [{
690
724
  depth: e,
691
725
  hex: n(127),
692
726
  comment: "Start indefinite-length text string"
@@ -701,7 +735,7 @@ var A = class extends D {
701
735
  _toJS(e) {
702
736
  return this.chunks.map((e) => e.value).join("");
703
737
  }
704
- }, F = class extends D {
738
+ }, L = class extends k {
705
739
  items;
706
740
  indefiniteLength;
707
741
  encodingWidth;
@@ -715,47 +749,45 @@ var A = class extends D {
715
749
  e.writeByte(255);
716
750
  return;
717
751
  }
718
- T(e, 4, this.items.length, this.encodingWidth);
752
+ D(e, 4, this.items.length, this.encodingWidth);
719
753
  for (let n of this.items) n._encode(e, t);
720
754
  }
721
755
  _toCDN(e, t) {
722
- let n = re(e), r = e?.preserveComments, i = typeof r == "string" ? r : void 0, a = r && (ae(this) || this.items.some(ie));
723
- n === null && a && (n = " ");
724
- let { inlineSep: o, multilineSep: s, trailSep: c } = le(e, n === null), l = this.indefiniteLength ? "" : b(e, this.encodingWidth, () => y(BigInt(this.items.length))), u = l ? l + " " : "", d = this.indefiniteLength && (e?.encodingIndicators ?? "auto") !== "never";
725
- if (n === null || this.items.length === 0 && !a) {
726
- let n = this.items.map((n) => n._toCDN(e, t + 1)).join(o);
727
- return this.indefiniteLength ? d ? this.items.length === 0 ? "[_ ]" : `[_ ${n}]` : `[${n}]` : `[${u}${n}]`;
728
- }
729
- let f = _(n, t + 1), p = _(n, t), m = this.indefiniteLength ? d ? "[_ " : "[" : `[${u}`, h = [];
730
- for (let n = 0; n < this.items.length; n++) {
731
- let a = this.items[n];
732
- r && h.push(...oe(a, f, i));
733
- let o = n < this.items.length - 1 ? s : c;
734
- h.push(`${f}${a._toCDN(e, t + 1)}${o}${r ? se(a, i) : ""}`);
735
- }
736
- return r && h.push(...ce(this, f, i)), `${m}\n${h.join("\n")}\n${p}]`;
756
+ return oe({
757
+ node: this,
758
+ options: e,
759
+ depth: t,
760
+ openChar: "[",
761
+ closeChar: "]",
762
+ count: this.items.length,
763
+ indefiniteLength: this.indefiniteLength,
764
+ encodingWidth: this.encodingWidth,
765
+ hasEntryComments: () => this.items.some(te),
766
+ renderEntry: (n) => this.items[n]._toCDN(e, t + 1),
767
+ entryLeadingNode: (e) => this.items[e],
768
+ entryTrailing: (e, t) => b(this.items[e], t)
769
+ });
737
770
  }
738
- _toHexDump(e, t) {
739
- let n = (e) => e.toString(16).toUpperCase().padStart(2, "0"), r = (e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" ");
771
+ _toHexDump(e, r) {
740
772
  if (this.indefiniteLength) {
741
- let r = [{
773
+ let t = [{
742
774
  depth: e,
743
775
  hex: n(159),
744
776
  comment: "Start indefinite-length array"
745
777
  }];
746
- for (let n of this.items) r.push(...n._toHexDump(e + 1, t));
747
- return r.push({
778
+ for (let n of this.items) t.push(...n._toHexDump(e + 1, r));
779
+ return t.push({
748
780
  depth: e,
749
781
  hex: n(255),
750
782
  comment: "\"break\""
751
- }), r;
783
+ }), t;
752
784
  }
753
785
  let i = [{
754
786
  depth: e,
755
- hex: r(Ne(4, BigInt(this.items.length), this.encodingWidth)),
787
+ hex: t(Pe(4, BigInt(this.items.length), this.encodingWidth)),
756
788
  comment: `Array of length ${this.items.length}`
757
789
  }];
758
- for (let n of this.items) i.push(...n._toHexDump(e + 1, t));
790
+ for (let t of this.items) i.push(...t._toHexDump(e + 1, r));
759
791
  return i;
760
792
  }
761
793
  _toJS(e) {
@@ -767,11 +799,11 @@ var A = class extends D {
767
799
  } : void 0, r = this.items.map((e) => e._toJS(n)), i = 0;
768
800
  for (let n = 0; n < this.items.length; n++) {
769
801
  let a = n - i, o = this.items[n]._toJS(e), s = t.call(r, String(n), o);
770
- s === d || e?.undefinedOmits && s === void 0 ? (r.splice(a, 1), i++) : r[a] = s;
802
+ s === h || e?.undefinedOmits && s === void 0 ? (r.splice(a, 1), i++) : r[a] = s;
771
803
  }
772
804
  return r;
773
805
  }
774
- }, I = class extends D {
806
+ }, R = class extends k {
775
807
  entries;
776
808
  indefiniteLength;
777
809
  encodingWidth;
@@ -785,51 +817,55 @@ var A = class extends D {
785
817
  e.writeByte(255);
786
818
  return;
787
819
  }
788
- T(e, 5, this.entries.length, this.encodingWidth);
820
+ D(e, 5, this.entries.length, this.encodingWidth);
789
821
  for (let [n, r] of this.entries) n._encode(e, t), r._encode(e, t);
790
822
  }
791
823
  _toCDN(e, t) {
792
- let n = re(e), r = e?.preserveComments, i = typeof r == "string" ? r : void 0, a = r && (ae(this) || this.entries.some(([e, t]) => ie(e) || ie(t)));
793
- n === null && a && (n = " ");
794
- let { inlineSep: o, multilineSep: s, trailSep: c, colSep: l } = le(e, n === null), u = this.indefiniteLength ? "" : b(e, this.encodingWidth, () => y(BigInt(this.entries.length))), d = u ? u + " " : "", f = this.indefiniteLength && (e?.encodingIndicators ?? "auto") !== "never", p = this.indefiniteLength ? f ? "{_ " : "{" : `{${d}`;
795
- if (n === null || this.entries.length === 0 && !a) {
796
- let n = this.entries.map(([n, r]) => `${n._toCDN(e, t + 1)}${l}${r._toCDN(e, t + 1)}`).join(o);
797
- return this.indefiniteLength ? f ? this.entries.length === 0 ? "{_ }" : `{_ ${n}}` : `{${n}}` : `{${d}${n}}`;
798
- }
799
- let m = _(n, t + 1), h = _(n, t), g = [];
800
- for (let n = 0; n < this.entries.length; n++) {
801
- let [a, o] = this.entries[n];
802
- r && g.push(...oe(a, m, i));
803
- let u = n < this.entries.length - 1 ? s : c, d = r ? Be([
804
- ...a.comments?.trailing ?? [],
805
- ...o.comments?.leading ?? [],
806
- ...o.comments?.trailing ?? []
807
- ], i) : "";
808
- g.push(`${m}${a._toCDN(e, t + 1)}${l}${o._toCDN(e, t + 1)}${u}${d}`);
809
- }
810
- return r && g.push(...ce(this, m, i)), `${p}\n${g.join("\n")}\n${h}}`;
824
+ return oe({
825
+ node: this,
826
+ options: e,
827
+ depth: t,
828
+ openChar: "{",
829
+ closeChar: "}",
830
+ count: this.entries.length,
831
+ indefiniteLength: this.indefiniteLength,
832
+ encodingWidth: this.encodingWidth,
833
+ hasEntryComments: () => this.entries.some(([e, t]) => te(e) || te(t)),
834
+ renderEntry: (n, r) => {
835
+ let [i, a] = this.entries[n];
836
+ return `${i._toCDN(e, t + 1)}${r}${a._toCDN(e, t + 1)}`;
837
+ },
838
+ entryLeadingNode: (e) => this.entries[e][0],
839
+ entryTrailing: (e, t) => {
840
+ let [n, r] = this.entries[e];
841
+ return Ve([
842
+ ...n.comments?.trailing ?? [],
843
+ ...r.comments?.leading ?? [],
844
+ ...r.comments?.trailing ?? []
845
+ ], t);
846
+ }
847
+ });
811
848
  }
812
- _toHexDump(e, t) {
813
- let n = (e) => e.toString(16).toUpperCase().padStart(2, "0"), r = (e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" ");
849
+ _toHexDump(e, r) {
814
850
  if (this.indefiniteLength) {
815
- let r = [{
851
+ let t = [{
816
852
  depth: e,
817
853
  hex: n(191),
818
854
  comment: "Start indefinite-length map"
819
855
  }];
820
- for (let [n, i] of this.entries) r.push(...n._toHexDump(e + 1, t)), r.push(...i._toHexDump(e + 1, t));
821
- return r.push({
856
+ for (let [n, i] of this.entries) t.push(...n._toHexDump(e + 1, r)), t.push(...i._toHexDump(e + 1, r));
857
+ return t.push({
822
858
  depth: e,
823
859
  hex: n(255),
824
860
  comment: "\"break\""
825
- }), r;
861
+ }), t;
826
862
  }
827
863
  let i = [{
828
864
  depth: e,
829
- hex: r(Ne(5, BigInt(this.entries.length), this.encodingWidth)),
865
+ hex: t(Pe(5, BigInt(this.entries.length), this.encodingWidth)),
830
866
  comment: `Map of length ${this.entries.length}`
831
867
  }];
832
- for (let [n, r] of this.entries) i.push(...n._toHexDump(e + 1, t)), i.push(...r._toHexDump(e + 1, t));
868
+ for (let [t, n] of this.entries) i.push(...t._toHexDump(e + 1, r)), i.push(...n._toHexDump(e + 1, r));
833
869
  return i;
834
870
  }
835
871
  _toJS(e) {
@@ -839,17 +875,17 @@ var A = class extends D {
839
875
  let r = e?.undefinedOmits;
840
876
  for (let e = 0; e < n.length; e++) {
841
877
  let [i, a] = n[e], o = t.call(n, i, a);
842
- o === d || r && o === void 0 ? n.splice(e--, 1) : n[e] = [i, o];
878
+ o === h || r && o === void 0 ? n.splice(e--, 1) : n[e] = [i, o];
843
879
  }
844
880
  return n;
845
881
  };
846
- return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof z) ? (() => {
882
+ return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof V) ? (() => {
847
883
  let n = e ? {
848
884
  ...e,
849
885
  reviver: void 0
850
886
  } : void 0, r = {};
851
887
  for (let [e, t] of this.entries) {
852
- let i = e instanceof z ? e.value : e.toCDN(), a = t._toJS(n);
888
+ let i = e instanceof V ? e.value : e.toCDN(), a = t._toJS(n);
853
889
  i === "__proto__" ? Object.defineProperty(r, i, {
854
890
  value: a,
855
891
  writable: !0,
@@ -861,13 +897,13 @@ var A = class extends D {
861
897
  let i = /* @__PURE__ */ new Map();
862
898
  for (let e = 0; e < this.entries.length; e++) {
863
899
  let [t] = this.entries[e];
864
- i.set(t instanceof z ? t.value : t.toCDN(), e);
900
+ i.set(t instanceof V ? t.value : t.toCDN(), e);
865
901
  }
866
902
  for (let n = 0; n < this.entries.length; n++) {
867
- let [a, o] = this.entries[n], s = a instanceof z ? a.value : a.toCDN();
903
+ let [a, o] = this.entries[n], s = a instanceof V ? a.value : a.toCDN();
868
904
  if (i.get(s) !== n) continue;
869
905
  let c = o._toJS(e), l = t.call(r, s, c);
870
- l === d || e?.undefinedOmits && l === void 0 ? delete r[s] : s === "__proto__" ? Object.defineProperty(r, s, {
906
+ l === h || e?.undefinedOmits && l === void 0 ? delete r[s] : s === "__proto__" ? Object.defineProperty(r, s, {
871
907
  value: l,
872
908
  writable: !0,
873
909
  enumerable: !0,
@@ -878,12 +914,12 @@ var A = class extends D {
878
914
  })() : n();
879
915
  }
880
916
  };
881
- function Be(e, t) {
882
- return e.length === 0 ? "" : " " + e.map((e) => v(e, t).trimEnd()).join(" ");
917
+ function Ve(e, t) {
918
+ return e.length === 0 ? "" : " " + e.map((e) => y(e, t).trimEnd()).join(" ");
883
919
  }
884
920
  //#endregion
885
921
  //#region src/ast/CborSimple.ts
886
- var L = class e extends D {
922
+ var z = class e extends k {
887
923
  value;
888
924
  constructor(e) {
889
925
  if (super(), !Number.isInteger(e) || e < 0 || e > 255) throw RangeError("CborSimple value must be an integer in 0–255");
@@ -915,55 +951,55 @@ var L = class e extends D {
915
951
  case 21: return !0;
916
952
  case 22: return null;
917
953
  case 23: return;
918
- default: return new f(this.value);
954
+ default: return new g(this.value);
919
955
  }
920
956
  }
921
- }, Ve = class extends D {
957
+ }, He = class extends k {
922
958
  items;
923
959
  encodingWidth;
924
960
  constructor(e, t) {
925
961
  super(), this.items = e, this.encodingWidth = t?.encodingWidth;
926
962
  }
927
963
  _content(e) {
928
- let t = new Ae();
964
+ let t = new je();
929
965
  for (let n of this.items) n._encode(t, e);
930
966
  return t.finish();
931
967
  }
932
968
  _encodeTo(e, t) {
933
969
  let n = this._content(t);
934
- T(e, 2, n.length, this.encodingWidth), e.writeBytes(n);
970
+ D(e, 2, n.length, this.encodingWidth), e.writeBytes(n);
935
971
  }
936
972
  _toCDN(e, t) {
937
- let n = b(e, this.encodingWidth, () => y(BigInt(this._content(e).length)));
973
+ let n = S(e, this.encodingWidth, () => x(BigInt(this._content(e).length)));
938
974
  if (this.items.length === 0) return `<<>>${n}`;
939
- let r = re(e), { inlineSep: i, multilineSep: a, trailSep: o } = le(e, r === null);
975
+ let r = _(e), { inlineSep: i, multilineSep: a, trailSep: o } = ae(e, r === null);
940
976
  if (r === null) return `<<${this.items.map((n) => n._toCDN(e, t + 1)).join(i)}>>${n}`;
941
- let s = _(r, t + 1), c = _(r, t), l = this.items.map((n) => `${s}${n._toCDN(e, t + 1)}`), u = l.length - 1;
977
+ let s = v(r, t + 1), c = v(r, t), l = this.items.map((n) => `${s}${n._toCDN(e, t + 1)}`), u = l.length - 1;
942
978
  return `<<\n${l.map((e, t) => t < u ? `${e}${a}` : `${e}${o}`).join("\n")}\n${c}>>${n}`;
943
979
  }
944
- _toHexDump(e, t) {
945
- let n = (e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" "), r = this._content().length, i = [{
980
+ _toHexDump(e, n) {
981
+ let r = this._content().length, i = [{
946
982
  depth: e,
947
- hex: n(Ne(2, BigInt(r), this.encodingWidth)),
983
+ hex: t(Pe(2, BigInt(r), this.encodingWidth)),
948
984
  comment: `Embedded CBOR sequence, ${r} byte${r === 1 ? "" : "s"}`
949
985
  }];
950
- for (let n of this.items) i.push(...n._toHexDump(e + 1, t));
986
+ for (let t of this.items) i.push(...t._toHexDump(e + 1, n));
951
987
  return i;
952
988
  }
953
989
  _toJS(e) {
954
990
  return this._content();
955
991
  }
956
- }, He = 999n, Ue = class extends j {
992
+ }, Ue = 999n, We = class extends N {
957
993
  constructor(e, t) {
958
- let n = t.length === 1 && t[0] instanceof z ? t[0] : new F(t);
959
- super(He, new F([new z(e), n]));
994
+ let n = t.length === 1 && t[0] instanceof V ? t[0] : new L(t);
995
+ super(Ue, new L([new V(e), n]));
960
996
  }
961
997
  _toCDN(e, t) {
962
998
  if (e?.appStrings === !1) return super._toCDN(e, t);
963
999
  let n = this.content, r = n.items[0].value, i = n.items[1];
964
- return i instanceof z ? `${r}${Ce(i.value)}` : `${r}<<${i.items.map((n) => n._toCDN(e, t)).join(", ")}>>`;
1000
+ return i instanceof V ? `${r}${be(i.value)}` : `${r}<<${i.items.map((n) => n._toCDN(e, t)).join(", ")}>>`;
965
1001
  }
966
- }, We = class extends D {
1002
+ }, Ge = class extends k {
967
1003
  inner;
968
1004
  ednSource;
969
1005
  constructor(e, t) {
@@ -979,15 +1015,15 @@ var L = class e extends D {
979
1015
  _toJS(e) {
980
1016
  return this.inner._toJS(e);
981
1017
  }
982
- }, Ge = 888n, R = class extends j {
1018
+ }, Ke = 888n, B = class extends N {
983
1019
  constructor(e) {
984
- e === void 0 ? super(Ge, L.NULL) : super(Ge, new F(e));
1020
+ e === void 0 ? super(Ke, z.NULL) : super(Ke, new L(e));
985
1021
  }
986
1022
  _toCDN(e, t) {
987
- return this.content instanceof L ? "..." : this.content instanceof F ? this.content.items.map((n) => n._toCDN(e, t)).join(" + ") : super._toCDN(e, t);
1023
+ return this.content instanceof z ? "..." : this.content instanceof L ? this.content.items.map((n) => n._toCDN(e, t)).join(" + ") : super._toCDN(e, t);
988
1024
  }
989
- }, Ke = 2n, qe = 3n, Je = 18446744073709551615n, Ye = -18446744073709551616n;
990
- function Xe(e) {
1025
+ }, qe = 2n, Je = 3n, Ye = 18446744073709551615n, Xe = -18446744073709551616n;
1026
+ function Ze(e) {
991
1027
  if (e < 0n) throw RangeError("bigintToBytes requires a non-negative value");
992
1028
  if (e === 0n) return /* @__PURE__ */ new Uint8Array();
993
1029
  let t = e.toString(16);
@@ -996,16 +1032,16 @@ function Xe(e) {
996
1032
  for (let e = 0; e < n.length; e++) n[e] = parseInt(t.slice(e * 2, e * 2 + 2), 16);
997
1033
  return n;
998
1034
  }
999
- function Ze(e) {
1035
+ function Qe(e) {
1000
1036
  let t = 0n;
1001
1037
  for (let n of e) t = t << 8n | BigInt(n);
1002
1038
  return t;
1003
1039
  }
1004
- var Qe = class extends j {
1040
+ var $e = class extends N {
1005
1041
  bigValue;
1006
1042
  constructor(e) {
1007
- if (e <= Je) throw RangeError(`CborBigUint value ${e} fits in CborUint; use CborUint instead`);
1008
- super(Ke, new M(Xe(e))), this.bigValue = e;
1043
+ if (e <= Ye) throw RangeError(`CborBigUint value ${e} fits in CborUint; use CborUint instead`);
1044
+ super(qe, new P(Ze(e))), this.bigValue = e;
1009
1045
  }
1010
1046
  _toCDN(e, t) {
1011
1047
  return this.bigValue.toString();
@@ -1013,11 +1049,11 @@ var Qe = class extends j {
1013
1049
  _toJS(e) {
1014
1050
  return this.bigValue;
1015
1051
  }
1016
- }, $e = class extends j {
1052
+ }, et = class extends N {
1017
1053
  bigValue;
1018
1054
  constructor(e) {
1019
- if (e >= Ye) throw RangeError(`CborBigNint value ${e} fits in CborNint; use CborNint instead`);
1020
- super(qe, new M(Xe(-1n - e))), this.bigValue = e;
1055
+ if (e >= Xe) throw RangeError(`CborBigNint value ${e} fits in CborNint; use CborNint instead`);
1056
+ super(Je, new P(Ze(-1n - e))), this.bigValue = e;
1021
1057
  }
1022
1058
  _toCDN(e, t) {
1023
1059
  return this.bigValue.toString();
@@ -1025,25 +1061,25 @@ var Qe = class extends j {
1025
1061
  _toJS(e) {
1026
1062
  return this.bigValue;
1027
1063
  }
1028
- }, et = new TextEncoder(), tt = new TextDecoder("utf-8", { fatal: !0 }), nt = new TextDecoder("utf-8", { fatal: !1 });
1029
- function rt(e, n) {
1030
- let r = new t(e, {
1031
- offset: n?.offset,
1032
- skipRS: n?._skipRS
1033
- }), i = new ht(r, n ?? {}).parse();
1034
- return n?.preserveComments && ct(i, r.comments, e), i;
1064
+ }, tt = new TextEncoder(), nt = new TextDecoder("utf-8", { fatal: !0 }), rt = new TextDecoder("utf-8", { fatal: !1 });
1065
+ function it(e, t) {
1066
+ let n = new a(e, {
1067
+ offset: t?.offset,
1068
+ skipRS: t?._skipRS
1069
+ }), r = new gt(n, t ?? {}).parse();
1070
+ return t?.preserveComments && lt(r, n.comments, e), r;
1035
1071
  }
1036
- function it(e) {
1072
+ function at(e) {
1037
1073
  let t = e, n;
1038
1074
  return /[_][0-7i]$/.test(e) && (n = e[e.length - 1], t = e.slice(0, -2)), {
1039
1075
  numStr: t,
1040
1076
  rawSuffix: n
1041
1077
  };
1042
1078
  }
1043
- function at(e) {
1079
+ function ot(e) {
1044
1080
  return e.startsWith("-") ? -BigInt(e.slice(1)) : BigInt(e);
1045
1081
  }
1046
- function ot(e, t) {
1082
+ function st(e, t) {
1047
1083
  if (e.endsWith("_i") || e.endsWith("_0")) {
1048
1084
  let n = "_0 and _i encoding indicators are not valid for floating-point values";
1049
1085
  if (t) t(n), e = e.slice(0, -2);
@@ -1067,14 +1103,14 @@ function ot(e, t) {
1067
1103
  };
1068
1104
  let n = e, r;
1069
1105
  return e.endsWith("_1") ? (r = "half", n = e.slice(0, -2)) : e.endsWith("_2") ? (r = "single", n = e.slice(0, -2)) : e.endsWith("_3") && (r = "double", n = e.slice(0, -2)), /^-?0[xX]/.test(n) ? {
1070
- value: Re(n),
1106
+ value: ze(n),
1071
1107
  precision: r
1072
1108
  } : {
1073
1109
  value: parseFloat(n),
1074
1110
  precision: r
1075
1111
  };
1076
1112
  }
1077
- function st(e, t) {
1113
+ function ct(e, t) {
1078
1114
  let n = e.indexOf("="), r = n >= 0 ? e.slice(0, n) : e, i = n >= 0 ? e.slice(n) : "";
1079
1115
  if (/[^A-Za-z0-9+/\-_]/.test(r)) {
1080
1116
  let e = [...r].find((e) => !/[A-Za-z0-9+/\-_]/.test(e)) ?? "";
@@ -1111,49 +1147,65 @@ function st(e, t) {
1111
1147
  for (let e = 0; e < c.length; e++) l[e] = c.charCodeAt(e);
1112
1148
  return l;
1113
1149
  }
1114
- function ct(e, t, n) {
1150
+ function lt(e, t, n) {
1115
1151
  if (t.length === 0) return;
1116
- let r = lt(e), i = dt(n);
1117
- for (let a of t) {
1118
- 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) : "";
1119
- if (o && i(o.end) === a.line && !s.includes(":")) {
1120
- ut(o.node, "trailing", t);
1152
+ let r = ut(e), i = ft(n), a = [...r].sort((e, t) => e.start - t.start || t.end - e.end), o = [...r].sort((e, t) => e.end - t.end || e.start - t.start), s = [...t].sort((e, t) => e.start - t.start), c = [], l = 0;
1153
+ for (let t of s) {
1154
+ let r = { ...t }, s = 0, u = o.length;
1155
+ for (; s < u;) {
1156
+ let e = s + u >> 1;
1157
+ o[e].end <= t.start ? s = e + 1 : u = e;
1158
+ }
1159
+ let d = s > 0 ? o[s - 1] : void 0, f = d ? n.slice(d.end, t.start) : "";
1160
+ if (d && i(d.end) === t.line && !f.includes(":")) {
1161
+ dt(d.node, "trailing", r);
1121
1162
  continue;
1122
1163
  }
1123
- 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];
1124
- if ((!c || l && l.end <= c.end) && l) {
1125
- ut(l.node, "leading", t);
1164
+ for (; l < a.length && a[l].start < t.start;) {
1165
+ let e = a[l++];
1166
+ for (; c.length > 0 && c[c.length - 1].end <= e.start;) c.pop();
1167
+ c.push(e);
1168
+ }
1169
+ for (; c.length > 0 && c[c.length - 1].end <= t.start;) c.pop();
1170
+ let p = c.length > 0 ? c[c.length - 1] : void 0;
1171
+ for (s = 0, u = a.length; s < u;) {
1172
+ let e = s + u >> 1;
1173
+ a[e].start < t.end ? s = e + 1 : u = e;
1174
+ }
1175
+ let m = s < a.length ? a[s] : void 0;
1176
+ if ((!p || m && m.end <= p.end) && m) {
1177
+ dt(m.node, "leading", r);
1126
1178
  continue;
1127
1179
  }
1128
- ut(c?.node ?? e, "dangling", t);
1180
+ dt(p?.node ?? e, "dangling", r);
1129
1181
  }
1130
1182
  }
1131
- function lt(e) {
1183
+ function ut(e) {
1132
1184
  let t = [], n = (e) => {
1133
1185
  if (e.start !== void 0 && e.end !== void 0 && t.push({
1134
1186
  node: e,
1135
1187
  start: e.start,
1136
1188
  end: e.end
1137
- }), e instanceof F || e instanceof Ve) {
1189
+ }), e instanceof L || e instanceof He) {
1138
1190
  for (let t of e.items) n(t);
1139
1191
  return;
1140
1192
  }
1141
- if (e instanceof I) {
1193
+ if (e instanceof R) {
1142
1194
  for (let [t, r] of e.entries) n(t), n(r);
1143
1195
  return;
1144
1196
  }
1145
- if (e instanceof N || e instanceof P) {
1197
+ if (e instanceof F || e instanceof I) {
1146
1198
  for (let t of e.chunks) n(t);
1147
1199
  return;
1148
1200
  }
1149
- e instanceof j && n(e.content);
1201
+ e instanceof N && n(e.content);
1150
1202
  };
1151
1203
  return n(e), t;
1152
1204
  }
1153
- function ut(e, t, n) {
1205
+ function dt(e, t, n) {
1154
1206
  e.comments ??= {}, e.comments[t] ??= [], e.comments[t].push(n);
1155
1207
  }
1156
- function dt(e) {
1208
+ function ft(e) {
1157
1209
  let t = [0];
1158
1210
  for (let n = 0; n < e.length; n++) e[n] === "\n" && t.push(n + 1);
1159
1211
  return (n) => {
@@ -1167,15 +1219,15 @@ function dt(e) {
1167
1219
  return a + 1;
1168
1220
  };
1169
1221
  }
1170
- var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'extensions' option (extensions: [${e}])`, pt = (e, t) => `install ${t}, import { ${e} } from '${t}', and pass it via the 'extensions' option (extensions: [${e}])`, mt = /* @__PURE__ */ new Map([
1171
- ["b32", ft("b32")],
1172
- ["h32", ft("h32")],
1173
- ["float", ft("float")],
1174
- ["same", ft("same")],
1175
- ["hash", pt("hash", "@cbortech/hash-extension")],
1176
- ["uuid", pt("uuid", "@cbortech/uuid-extension")],
1177
- ["UUID", pt("uuid", "@cbortech/uuid-extension")]
1178
- ]), ht = class {
1222
+ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'extensions' option (extensions: [${e}])`, mt = (e, t) => `install ${t}, import { ${e} } from '${t}', and pass it via the 'extensions' option (extensions: [${e}])`, ht = /* @__PURE__ */ new Map([
1223
+ ["b32", pt("b32")],
1224
+ ["h32", pt("h32")],
1225
+ ["float", pt("float")],
1226
+ ["same", pt("same")],
1227
+ ["hash", mt("hash", "@cbortech/hash-extension")],
1228
+ ["uuid", mt("uuid", "@cbortech/uuid-extension")],
1229
+ ["UUID", mt("uuid", "@cbortech/uuid-extension")]
1230
+ ]), gt = class {
1179
1231
  t;
1180
1232
  _options;
1181
1233
  extByPrefix;
@@ -1183,23 +1235,25 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1183
1235
  unresolvedExtension;
1184
1236
  _pendingWarnings = [];
1185
1237
  _hintedPrefixes = /* @__PURE__ */ new Set();
1186
- constructor(t, n) {
1187
- this.t = t, this._options = n, this.extByPrefix = /* @__PURE__ */ new Map(), this.extByTag = /* @__PURE__ */ new Map(), this.unresolvedExtension = n.unresolvedExtension ?? "cpa999";
1188
- for (let e of [...qn, ...n.extensions ?? []]) {
1238
+ constructor(e, t) {
1239
+ this.t = e, this._options = t, this.extByPrefix = /* @__PURE__ */ new Map(), this.extByTag = /* @__PURE__ */ new Map(), this.unresolvedExtension = t.unresolvedExtension ?? "cpa999";
1240
+ for (let e of [...Z, ...t.extensions ?? []]) {
1189
1241
  for (let t of e.appStringPrefixes ?? []) this.extByPrefix.set(t, e);
1190
1242
  for (let t of e.tagNumbers ?? []) this.extByTag.set(t, e);
1191
1243
  }
1192
- this.t.onEscapeWarning = (t, n, r, i) => {
1193
- let a = {
1194
- message: t,
1195
- offset: n,
1196
- line: r,
1197
- column: i
1244
+ this.t.onEscapeWarning = (e, t, n, i, a) => {
1245
+ let o = {
1246
+ message: e,
1247
+ offset: t,
1248
+ line: n,
1249
+ column: i,
1250
+ endOffset: a
1198
1251
  };
1199
- if (this._pendingWarnings.push(a), this._options.onWarning ? this._options.onWarning(a) : this._options.silent || console.warn(`CDN strict violation at line ${r}, column ${i}: ${t}`), this._options.strict !== !1) throw new e(t, {
1200
- offset: n,
1201
- line: r,
1202
- column: i
1252
+ if (this._pendingWarnings.push(o), this._options.onWarning ? this._options.onWarning(o) : this._options.silent || console.warn(`CDN strict violation at line ${n}, column ${i}: ${e}`), this._options.strict !== !1) throw new r(e, {
1253
+ offset: t,
1254
+ line: n,
1255
+ column: i,
1256
+ endOffset: a
1203
1257
  });
1204
1258
  };
1205
1259
  }
@@ -1233,12 +1287,12 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1233
1287
  case "BYTES_HEX":
1234
1288
  case "SQSTR":
1235
1289
  case "BYTES_B64": return this.t.consume(), this._parseBytesConcat(this._decodeBytesToken(e), e.type, e.raw);
1236
- case "EMPTY_INDEF_BYTES": return this.t.consume(), new N([]);
1237
- case "EMPTY_INDEF_TEXT": return this.t.consume(), new P([]);
1238
- case "TRUE": return this.t.consume(), new L(21);
1239
- case "FALSE": return this.t.consume(), new L(20);
1240
- case "NULL": return this.t.consume(), new L(22);
1241
- case "UNDEFINED": return this.t.consume(), new L(23);
1290
+ case "EMPTY_INDEF_BYTES": return this.t.consume(), new F([]);
1291
+ case "EMPTY_INDEF_TEXT": return this.t.consume(), new I([]);
1292
+ case "TRUE": return this.t.consume(), new z(21);
1293
+ case "FALSE": return this.t.consume(), new z(20);
1294
+ case "NULL": return this.t.consume(), new z(22);
1295
+ case "UNDEFINED": return this.t.consume(), new z(23);
1242
1296
  case "SIMPLE": return this.parseSimple();
1243
1297
  case "LBRACKET": return this.parseArray();
1244
1298
  case "LBRACE": return this.parseMap();
@@ -1253,21 +1307,21 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1253
1307
  }
1254
1308
  let r = this.extByPrefix.get(e.appPrefix);
1255
1309
  if (!r?.parseAppString) {
1256
- if (r || this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new Ue(e.appPrefix, [new z(e.value)]);
1310
+ if (r || this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new We(e.appPrefix, [new V(e.value)]);
1257
1311
  this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
1258
1312
  }
1259
1313
  {
1260
1314
  let i = this._pendingWarnings.length;
1261
1315
  try {
1262
1316
  let i = r.parseAppString(e.appPrefix, e.value, this._extOnError(e), t === void 0 ? void 0 : { encodingWidth: t });
1263
- return t !== void 0 && this._applyEiToResult(i, t, e), i instanceof M && Object.getPrototypeOf(i) === M.prototype && i.ednSource === void 0 ? new M(i.value, {
1317
+ return t !== void 0 && this._applyEiToResult(i, t, e), i instanceof P && Object.getPrototypeOf(i) === P.prototype && i.ednSource === void 0 ? new P(i.value, {
1264
1318
  ednEncoding: i.ednEncoding,
1265
1319
  encodingWidth: i.encodingWidth,
1266
1320
  ednSource: e.raw + n
1267
- }) : (i instanceof A && i.ednSource === void 0 && (i.ednSource = e.raw + n), i);
1321
+ }) : (i instanceof M && i.ednSource === void 0 && (i.ednSource = e.raw + n), i);
1268
1322
  } catch (t) {
1269
1323
  if (this._options.strict !== !1) throw t;
1270
- return this._pendingWarnings.length === i && this._warn(t instanceof Error ? t.message : String(t), e), new Ue(e.appPrefix, [new z(e.value)]);
1324
+ return this._pendingWarnings.length === i && this._warn(t instanceof Error ? t.message : String(t), e), new We(e.appPrefix, [new V(e.value)]);
1271
1325
  }
1272
1326
  }
1273
1327
  }
@@ -1285,7 +1339,7 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1285
1339
  this.t.peek().type === "ENCODING_INDICATOR" && (r = this.t.consume(), n = this._resolveEncodingWidth(r.value, r));
1286
1340
  let i = this.extByPrefix.get(e.appPrefix);
1287
1341
  if (!i) {
1288
- if (this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new Ue(e.appPrefix, t);
1342
+ if (this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new We(e.appPrefix, t);
1289
1343
  this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
1290
1344
  }
1291
1345
  i.parseAppSequence || this._fail(`app-string extension ${JSON.stringify(e.appPrefix)} does not support <<...>> form`, e);
@@ -1295,61 +1349,61 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1295
1349
  let a = i.parseAppSequence(e.appPrefix, t, this._extOnError(e));
1296
1350
  n !== void 0 && this._applyEiToResult(a, n, r ?? e);
1297
1351
  let o = this.t.source.slice(e.offset, this.t.lastEndOffset);
1298
- if (a instanceof A) a.ednSource === void 0 && (a.ednSource = o);
1299
- else if (i.preserveAppSeqSource) return new We(a, o);
1352
+ if (a instanceof M) a.ednSource === void 0 && (a.ednSource = o);
1353
+ else if (i.preserveAppSeqSource) return new Ge(a, o);
1300
1354
  return a;
1301
1355
  } catch (n) {
1302
1356
  if (this._options.strict !== !1) throw n;
1303
- return this._pendingWarnings.length === a && this._warn(n instanceof Error ? n.message : String(n), e), new Ue(e.appPrefix, t);
1357
+ return this._pendingWarnings.length === a && this._warn(n instanceof Error ? n.message : String(n), e), new We(e.appPrefix, t);
1304
1358
  }
1305
1359
  }
1306
1360
  }
1307
1361
  case "ELLIPSIS": {
1308
- if (this.t.consume(), this.t.peek().type !== "PLUS") return new R();
1309
- let e = [new R()];
1362
+ if (this.t.consume(), this.t.peek().type !== "PLUS") return new B();
1363
+ let e = [new B()];
1310
1364
  for (; this.t.peek().type === "PLUS";) this.t.consume(), e.push(this.parseValue());
1311
- return new R(e);
1365
+ return new B(e);
1312
1366
  }
1313
1367
  case "BYTES_HEX_ELIDED": return this.t.consume(), this._parseHexElidedConcat(e);
1314
1368
  default: this._fail(`unexpected token: ${JSON.stringify(e.value)}`, e);
1315
1369
  }
1316
1370
  }
1317
1371
  parseIntegerOrTag() {
1318
- let e = this.t.consume(), { numStr: t, rawSuffix: n } = it(e.value), r = n === void 0 ? this.consumeEncodingIndicator() : this._resolveEncodingWidth(n, e), i = at(t);
1319
- if (i > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", e), new Qe(i);
1320
- if (i < -18446744073709551616n) return new $e(i);
1372
+ let e = this.t.consume(), { numStr: t, rawSuffix: n } = at(e.value), r = n === void 0 ? this.consumeEncodingIndicator() : this._resolveEncodingWidth(n, e), i = ot(t);
1373
+ if (i > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", e), new $e(i);
1374
+ if (i < -18446744073709551616n) return new et(i);
1321
1375
  if (r !== void 0) {
1322
1376
  let t = i >= 0n ? i : -(i + 1n);
1323
1377
  r = this._validateEncodingFit(t, r, e);
1324
1378
  }
1325
- let a = i >= 0n ? new O(i, r === void 0 ? void 0 : { encodingWidth: r }) : new k(i, r === void 0 ? void 0 : { encodingWidth: r });
1379
+ let a = i >= 0n ? new A(i, r === void 0 ? void 0 : { encodingWidth: r }) : new j(i, r === void 0 ? void 0 : { encodingWidth: r });
1326
1380
  if (this.t.peek().type === "LPAREN") {
1327
- a instanceof O || this._fail("tag number must be non-negative", e), this.t.consume();
1381
+ a instanceof A || this._fail("tag number must be non-negative", e), this.t.consume();
1328
1382
  let t = this._pendingWarnings.splice(0), n = this.parseValue();
1329
1383
  this.expect("RPAREN");
1330
1384
  let i = a.value, o = this.extByTag.get(i);
1331
1385
  if (o?.parseTag) {
1332
1386
  let e = o.parseTag(i, n);
1333
- if (e !== void 0) return e instanceof j && r !== void 0 && e.encodingWidth === void 0 && (e.encodingWidth = r), t.length > 0 && (e.warnings ??= [], e.warnings.push(...t)), e;
1387
+ if (e !== void 0) return e instanceof N && r !== void 0 && e.encodingWidth === void 0 && (e.encodingWidth = r), t.length > 0 && (e.warnings ??= [], e.warnings.push(...t)), e;
1334
1388
  }
1335
- let s = new j(i, n, r === void 0 ? void 0 : { encodingWidth: r });
1389
+ let s = new N(i, n, r === void 0 ? void 0 : { encodingWidth: r });
1336
1390
  return t.length > 0 && (s.warnings ??= [], s.warnings.push(...t)), s;
1337
1391
  }
1338
1392
  return a;
1339
1393
  }
1340
1394
  parseFloat() {
1341
- let e = this.t.consume(), t = (t) => this._warnOrFail(t, e), { value: n, precision: r } = ot(e.value, t);
1395
+ let e = this.t.consume(), t = (t) => this._warnOrFail(t, e), { value: n, precision: r } = st(e.value, t);
1342
1396
  if (r === "half" || r === "single") {
1343
- let e = r === "half" ? S(x(n)) : Math.fround(n);
1397
+ let e = r === "half" ? w(C(n)) : Math.fround(n);
1344
1398
  Object.is(n, e) || isNaN(n) && isNaN(e) || t(`${n} cannot be exactly represented as ${r === "half" ? "f16 (_1)" : "f32 (_2)"}; use _3 or remove the indicator`);
1345
1399
  }
1346
- return new A(n, r === void 0 ? void 0 : { precision: r });
1400
+ return new M(n, r === void 0 ? void 0 : { precision: r });
1347
1401
  }
1348
1402
  parseString() {
1349
1403
  let e = this.t.consume();
1350
1404
  if (this.t.peek().type !== "PLUS") {
1351
- let t = this.consumeEncodingIndicator(() => BigInt(et.encode(e.value).length));
1352
- return new z(e.value, t === void 0 ? void 0 : { encodingWidth: t });
1405
+ let t = this.consumeEncodingIndicator(() => BigInt(tt.encode(e.value).length));
1406
+ return new V(e.value, t === void 0 ? void 0 : { encodingWidth: t });
1353
1407
  }
1354
1408
  let t = !1, n = [{ text: e.value }];
1355
1409
  for (; this.t.peek().type === "PLUS";) {
@@ -1358,36 +1412,50 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1358
1412
  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);
1359
1413
  }
1360
1414
  if (!t) {
1361
- let e = n.map((e) => "text" in e ? e.text : "").join(""), t = this.consumeEncodingIndicator(() => BigInt(et.encode(e).length));
1362
- return new z(e, t === void 0 ? void 0 : { encodingWidth: t });
1415
+ let e = n.map((e) => "text" in e ? e.text : ""), t = e.join(""), r = this.consumeEncodingIndicator(() => BigInt(tt.encode(t).length));
1416
+ return new V(t, {
1417
+ ednParts: e,
1418
+ ...r === void 0 ? {} : { encodingWidth: r }
1419
+ });
1363
1420
  }
1364
1421
  let r = [], i = "";
1365
- for (let e of n) "ellipsis" in e ? (i !== "" && (r.push(new z(i)), i = ""), r.push(new R())) : i += e.text;
1366
- return i !== "" && r.push(new z(i)), new R(r);
1422
+ for (let e of n) "ellipsis" in e ? (i !== "" && (r.push(new V(i)), i = ""), r.push(new B())) : i += e.text;
1423
+ return i !== "" && r.push(new V(i)), new B(r);
1367
1424
  }
1368
1425
  _isBytesToken(e) {
1369
1426
  return e === "BYTES_HEX" || e === "SQSTR" || e === "BYTES_B64";
1370
1427
  }
1371
- _decodeBytesToken(t) {
1372
- let n = (e) => this._warnOrFail(e, t);
1373
- switch (t.type) {
1374
- case "BYTES_HEX":
1375
- case "SQSTR": return ne(t.value);
1428
+ _hexToBytes(t, n) {
1429
+ try {
1430
+ return e(t);
1431
+ } catch (e) {
1432
+ if (e instanceof r || !(e instanceof SyntaxError)) throw e;
1433
+ this._fail(e.message, n);
1434
+ }
1435
+ }
1436
+ _decodeBytesToken(e) {
1437
+ let t = (t) => this._warnOrFail(t, e);
1438
+ switch (e.type) {
1439
+ case "SQSTR": {
1440
+ let t = e._sqstrBytes;
1441
+ return t === void 0 ? this._hexToBytes(e.value, e) : t;
1442
+ }
1443
+ case "BYTES_HEX": return this._hexToBytes(e.value, e);
1376
1444
  case "BYTES_B64": try {
1377
- return st(t.value, n);
1378
- } catch (n) {
1379
- if (n instanceof e || !(n instanceof SyntaxError)) throw n;
1380
- this._fail(n.message, t);
1445
+ return ct(e.value, t);
1446
+ } catch (t) {
1447
+ if (t instanceof r || !(t instanceof SyntaxError)) throw t;
1448
+ this._fail(t.message, e);
1381
1449
  }
1382
- default: this._fail("expected byte string token", t);
1450
+ default: this._fail("expected byte string token", e);
1383
1451
  }
1384
1452
  }
1385
1453
  _decodeUtf8(e, t) {
1386
- if (this._options.allowInvalidUtf8) return nt.decode(e);
1454
+ if (this._options.allowInvalidUtf8) return rt.decode(e);
1387
1455
  try {
1388
- return tt.decode(e);
1456
+ return nt.decode(e);
1389
1457
  } catch {
1390
- return this._warnOrFail("byte string in text concatenation is not valid UTF-8", t), nt.decode(e);
1458
+ return this._warnOrFail("byte string in text concatenation is not valid UTF-8", t), rt.decode(e);
1391
1459
  }
1392
1460
  }
1393
1461
  _tokenTypeToCdnEncoding(e) {
@@ -1396,60 +1464,70 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1396
1464
  _parseBytesConcat(e, t, n) {
1397
1465
  if (this.t.peek().type !== "PLUS") {
1398
1466
  let r = this.consumeEncodingIndicator(() => BigInt(e.length));
1399
- return new M(e, {
1467
+ return new P(e, {
1400
1468
  ednEncoding: this._tokenTypeToCdnEncoding(t),
1401
1469
  ednSource: n,
1402
1470
  ...r === void 0 ? {} : { encodingWidth: r }
1403
1471
  });
1404
1472
  }
1405
- let r = !1, i = [{ bytes: e }];
1473
+ let r = !1, i = [{
1474
+ bytes: e,
1475
+ source: n
1476
+ }];
1406
1477
  for (; this.t.peek().type === "PLUS";) {
1407
1478
  this.t.consume();
1408
1479
  let e = this.t.peek();
1409
1480
  if (e.type === "ELLIPSIS") this.t.consume(), i.push({ ellipsis: !0 }), r = !0;
1410
1481
  else if (e.type === "BYTES_HEX_ELIDED") {
1411
1482
  this.t.consume();
1412
- let t = this._buildBytesElidedItems(e.value);
1413
- for (let e of t) e instanceof R ? (i.push({ ellipsis: !0 }), r = !0) : e instanceof M && i.push({ bytes: e.value });
1414
- } else this._isBytesToken(e.type) ? (this.t.consume(), i.push({ bytes: this._decodeBytesToken(e) })) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), this._warnOrFail("text string in a byte-string concatenation is not allowed; use a byte string literal (h'...', b64'...', or '...') instead", e), i.push({ bytes: et.encode(e.value) })) : this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
1483
+ let t = this._buildBytesElidedItems(e.value, e);
1484
+ for (let e of t) e instanceof B ? (i.push({ ellipsis: !0 }), r = !0) : e instanceof P && i.push({ bytes: e.value });
1485
+ } else this._isBytesToken(e.type) ? (this.t.consume(), i.push({
1486
+ bytes: this._decodeBytesToken(e),
1487
+ source: e.raw
1488
+ })) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), this._warnOrFail("text string in a byte-string concatenation is not allowed; use a byte string literal (h'...', b64'...', or '...') instead", e), i.push({ bytes: tt.encode(e.value) })) : this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
1415
1489
  }
1416
1490
  if (!r) {
1417
- let e = i.map((e) => "bytes" in e ? e.bytes : /* @__PURE__ */ new Uint8Array()), t = this._concatBytes(e), n = this.consumeEncodingIndicator(() => BigInt(t.length));
1418
- return new M(t, n === void 0 ? void 0 : { encodingWidth: n });
1491
+ let e = i.map((e) => "bytes" in e ? e : { bytes: /* @__PURE__ */ new Uint8Array() }), n = this._concatBytes(e.map((e) => e.bytes)), r = this.consumeEncodingIndicator(() => BigInt(n.length));
1492
+ return new P(n, {
1493
+ ednEncoding: this._tokenTypeToCdnEncoding(t),
1494
+ ednParts: e,
1495
+ ...r === void 0 ? {} : { encodingWidth: r }
1496
+ });
1419
1497
  }
1420
1498
  let a = [], o = [], s = () => {
1421
- o.length > 0 && (a.push(new M(this._concatBytes([...o]))), o.length = 0);
1499
+ o.length > 0 && (a.push(new P(this._concatBytes([...o]))), o.length = 0);
1422
1500
  };
1423
- for (let e of i) "ellipsis" in e ? (s(), a.push(new R())) : o.push(e.bytes);
1424
- return s(), new R(a);
1501
+ for (let e of i) "ellipsis" in e ? (s(), a.push(new B())) : o.push(e.bytes);
1502
+ return s(), new B(a);
1425
1503
  }
1426
1504
  _parseHexElidedConcat(e) {
1427
- let t = this._buildBytesElidedItems(e.value);
1505
+ let t = this._buildBytesElidedItems(e.value, e);
1428
1506
  for (; this.t.peek().type === "PLUS";) {
1429
1507
  this.t.consume();
1430
1508
  let e = this.t.peek();
1431
- if (e.type === "ELLIPSIS") this.t.consume(), t.push(new R());
1509
+ if (e.type === "ELLIPSIS") this.t.consume(), t.push(new B());
1432
1510
  else if (e.type === "BYTES_HEX_ELIDED") {
1433
1511
  this.t.consume();
1434
- let n = this._buildBytesElidedItems(e.value);
1512
+ let n = this._buildBytesElidedItems(e.value, e);
1435
1513
  this._mergeFirstBytesItem(t, n);
1436
1514
  } else if (this._isBytesToken(e.type)) {
1437
1515
  this.t.consume();
1438
1516
  let n = this._decodeBytesToken(e), r = t[t.length - 1];
1439
- r instanceof M ? t[t.length - 1] = new M(this._concatBytes([r.value, n])) : t.push(new M(n));
1517
+ r instanceof P ? t[t.length - 1] = new P(this._concatBytes([r.value, n])) : t.push(new P(n));
1440
1518
  } else this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
1441
1519
  }
1442
- return new R(t);
1520
+ return new B(t);
1443
1521
  }
1444
- _buildBytesElidedItems(e) {
1445
- let t = e.split("..."), n = [];
1446
- for (let e = 0; e < t.length; e++) e > 0 && n.push(new R()), t[e].length > 0 && n.push(new M(ne(t[e])));
1447
- return n;
1522
+ _buildBytesElidedItems(e, t) {
1523
+ let n = e.split("..."), r = [];
1524
+ for (let e = 0; e < n.length; e++) e > 0 && r.push(new B()), n[e].length > 0 && r.push(new P(this._hexToBytes(n[e], t)));
1525
+ return r;
1448
1526
  }
1449
1527
  _mergeFirstBytesItem(e, t) {
1450
1528
  if (t.length === 0) return;
1451
1529
  let n = e[e.length - 1], r = t[0];
1452
- n instanceof M && r instanceof M ? (e[e.length - 1] = new M(this._concatBytes([n.value, r.value])), e.push(...t.slice(1))) : e.push(...t);
1530
+ n instanceof P && r instanceof P ? (e[e.length - 1] = new P(this._concatBytes([n.value, r.value])), e.push(...t.slice(1))) : e.push(...t);
1453
1531
  }
1454
1532
  _concatBytes(e) {
1455
1533
  let t = e.reduce((e, t) => e + t.byteLength, 0), n = new Uint8Array(t), r = 0;
@@ -1460,8 +1538,8 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1460
1538
  this.t.consume(), this.expect("LPAREN");
1461
1539
  let e = this.t.peek();
1462
1540
  e.type !== "INTEGER" && this._fail(`expected integer inside simple(), got ${JSON.stringify(e.value)}`, e), this.t.consume();
1463
- let { numStr: t } = it(e.value), n = Number(at(t));
1464
- return this.expect("RPAREN"), new L(n);
1541
+ let { numStr: t } = at(e.value), n = Number(ot(t));
1542
+ return this.expect("RPAREN"), new z(n);
1465
1543
  }
1466
1544
  parseEmbeddedCBOR() {
1467
1545
  this.t.consume();
@@ -1478,7 +1556,7 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1478
1556
  let e = this.t.consume();
1479
1557
  t = this._resolveEncodingWidth(e.value, e);
1480
1558
  }
1481
- return new Ve(e, { encodingWidth: t });
1559
+ return new He(e, { encodingWidth: t });
1482
1560
  }
1483
1561
  parseArray() {
1484
1562
  this.t.consume();
@@ -1492,7 +1570,7 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1492
1570
  i.push(this.parseValue());
1493
1571
  }
1494
1572
  this.expect("RBRACKET"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
1495
- let a = new F(i, {
1573
+ let a = new L(i, {
1496
1574
  indefiniteLength: e,
1497
1575
  encodingWidth: t
1498
1576
  });
@@ -1513,7 +1591,7 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1513
1591
  i.push([e, t]);
1514
1592
  }
1515
1593
  this.expect("RBRACE"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
1516
- let a = new I(i, {
1594
+ let a = new R(i, {
1517
1595
  indefiniteLength: e,
1518
1596
  encodingWidth: t
1519
1597
  });
@@ -1537,16 +1615,16 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1537
1615
  }
1538
1616
  this.expect("RPAREN"), n.length === 0 && this._fail("empty indefinite group (_ ) is ambiguous; use ''_ for bytes or \"\"_ for text");
1539
1617
  let r = n[0];
1540
- if (r instanceof M) {
1541
- let e = new N(n.map((e, t) => {
1542
- if (e instanceof M) return e;
1618
+ if (r instanceof P) {
1619
+ let e = new F(n.map((e, t) => {
1620
+ if (e instanceof P) return e;
1543
1621
  this._fail(`indefinite byte string chunk ${t} must be a byte string, not a text string`);
1544
1622
  }));
1545
1623
  return t.length > 0 && (e.warnings = t), e;
1546
1624
  }
1547
- if (r instanceof z) {
1548
- let e = new P(n.map((e, t) => {
1549
- if (e instanceof z) return e;
1625
+ if (r instanceof V) {
1626
+ let e = new I(n.map((e, t) => {
1627
+ if (e instanceof V) return e;
1550
1628
  this._fail(`indefinite text string chunk ${t} must be a text string, not a byte string`);
1551
1629
  }));
1552
1630
  return t.length > 0 && (e.warnings = t), e;
@@ -1564,47 +1642,47 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1564
1642
  return t.type !== e && this._fail(`expected ${e}, got ${t.type} (${JSON.stringify(t.value)})`, t), t;
1565
1643
  }
1566
1644
  _applyEiToResult(e, t, n) {
1567
- if (e instanceof A) {
1645
+ if (e instanceof M) {
1568
1646
  let r = t === 1 ? "half" : t === 2 ? "single" : t === 3 ? "double" : void 0;
1569
1647
  if (r === void 0) this._warnOrFail(`encoding indicator _${t} is not valid for a float; use _1, _2, or _3`, n);
1570
1648
  else if (e.precision !== r) {
1571
1649
  if (r !== "double") {
1572
- let t = r === "half" ? S(x(e.value)) : Math.fround(e.value);
1650
+ let t = r === "half" ? w(C(e.value)) : Math.fround(e.value);
1573
1651
  !Object.is(t, e.value) && !isNaN(e.value) && this._warnOrFail(`${e.value} cannot be exactly represented as ${r === "half" ? "float16 (_1)" : "float32 (_2)"}`, n);
1574
1652
  }
1575
1653
  e.precision = r;
1576
1654
  }
1577
- } else if (e instanceof O) {
1655
+ } else if (e instanceof A) {
1578
1656
  if (e.encodingWidth === void 0) {
1579
1657
  let r = this._validateEncodingFit(e.value, t, n);
1580
1658
  r !== void 0 && (e.encodingWidth = r);
1581
1659
  }
1582
- } else if (e instanceof k) {
1660
+ } else if (e instanceof j) {
1583
1661
  if (e.encodingWidth === void 0) {
1584
1662
  let r = this._validateEncodingFit(e.argument, t, n);
1585
1663
  r !== void 0 && (e.encodingWidth = r);
1586
1664
  }
1587
- } else if (e instanceof M) {
1665
+ } else if (e instanceof P) {
1588
1666
  if (e.encodingWidth === void 0) {
1589
1667
  let r = this._validateEncodingFit(BigInt(e.value.length), t, n);
1590
1668
  r !== void 0 && (e.encodingWidth = r);
1591
1669
  }
1592
- } else if (e instanceof z) {
1670
+ } else if (e instanceof V) {
1593
1671
  if (e.encodingWidth === void 0) {
1594
- let r = this._validateEncodingFit(BigInt(et.encode(e.value).length), t, n);
1672
+ let r = this._validateEncodingFit(BigInt(tt.encode(e.value).length), t, n);
1595
1673
  r !== void 0 && (e.encodingWidth = r);
1596
1674
  }
1597
- } else if (e instanceof F) {
1675
+ } else if (e instanceof L) {
1598
1676
  if (e.encodingWidth === void 0) {
1599
1677
  let r = this._validateEncodingFit(BigInt(e.items.length), t, n);
1600
1678
  r !== void 0 && (e.encodingWidth = r);
1601
1679
  }
1602
- } else if (e instanceof I) {
1680
+ } else if (e instanceof R) {
1603
1681
  if (e.encodingWidth === void 0) {
1604
1682
  let r = this._validateEncodingFit(BigInt(e.entries.length), t, n);
1605
1683
  r !== void 0 && (e.encodingWidth = r);
1606
1684
  }
1607
- } else if (e instanceof j) {
1685
+ } else if (e instanceof N) {
1608
1686
  if (e.encodingWidth === void 0) {
1609
1687
  let r = this._validateEncodingFit(e.tag, t, n);
1610
1688
  r !== void 0 && (e.encodingWidth = r);
@@ -1612,7 +1690,7 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1612
1690
  } else this._warnOrFail(`encoding indicator _${t} is not applicable to this app-string result type`, n);
1613
1691
  }
1614
1692
  _validateEncodingFit(e, t, n) {
1615
- let r = Me(t);
1693
+ let r = Ne(t);
1616
1694
  if (e <= r) return t;
1617
1695
  let i = `value ${e} does not fit in encoding indicator ${t === "i" ? "_i (max 23)" : `_${t} (max ${r})`}`;
1618
1696
  this._warnOrFail(i, n);
@@ -1636,77 +1714,94 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1636
1714
  this._warn(e, t), this._options.strict !== !1 && this._fail(e, t);
1637
1715
  }
1638
1716
  _hintMissingExtension(e, t) {
1639
- let n = mt.get(e);
1717
+ let n = ht.get(e);
1640
1718
  if (n === void 0 || this._hintedPrefixes.has(e)) return;
1641
1719
  this._hintedPrefixes.add(e);
1642
1720
  let r = `app-string prefix '${e}' requires an extension that is not enabled; ${n}`;
1643
1721
  this._options.onWarning ? this._options.onWarning({
1644
1722
  message: r,
1645
- offset: t.offset,
1646
- line: t.line,
1647
- column: t.col
1723
+ ..._t(t)
1648
1724
  }) : this._options.silent || console.warn(`CDN: ${r}`);
1649
1725
  }
1650
1726
  _warn(e, t) {
1651
1727
  let n = { message: e };
1652
- if (t !== void 0 && (n.offset = t.offset, n.line = t.line, n.column = t.col), this._pendingWarnings.push(n), this._options.onWarning) this._options.onWarning(n);
1728
+ if (t !== void 0 && Object.assign(n, _t(t)), this._pendingWarnings.push(n), this._options.onWarning) this._options.onWarning(n);
1653
1729
  else if (!this._options.silent) {
1654
1730
  let n = t ? ` at line ${t.line}, column ${t.col}` : "";
1655
1731
  console.warn(`CDN strict violation${n}: ${e}`);
1656
1732
  }
1657
1733
  }
1658
- _fail(t, n) {
1659
- throw new e(t, n ? {
1660
- offset: n.offset,
1661
- line: n.line,
1662
- column: n.col,
1663
- endOffset: n.endOffset
1664
- } : void 0);
1734
+ _fail(e, t) {
1735
+ throw new r(e, t ? _t(t) : void 0);
1665
1736
  }
1666
- }, gt = new TextEncoder(), _t = !1, z = class extends D {
1737
+ };
1738
+ function _t(e) {
1739
+ return {
1740
+ offset: e.offset,
1741
+ line: e.line,
1742
+ column: e.col,
1743
+ endOffset: e.endOffset
1744
+ };
1745
+ }
1746
+ //#endregion
1747
+ //#region src/ast/CborTextString.ts
1748
+ var vt = new TextEncoder(), yt = !1, V = class extends k {
1667
1749
  indefiniteLength = !1;
1668
1750
  value;
1669
1751
  encodingWidth;
1752
+ ednParts;
1670
1753
  constructor(e, t) {
1671
- super(), this.value = e, this.encodingWidth = t?.encodingWidth;
1754
+ super(), this.value = e, this.encodingWidth = t?.encodingWidth, this.ednParts = t?.ednParts;
1672
1755
  }
1673
1756
  _encodeTo(e, t) {
1674
- let n = gt.encode(this.value);
1675
- T(e, 3, n.length, this.encodingWidth), e.writeBytes(n);
1757
+ e.writeTextString(3, this.value, this.encodingWidth);
1676
1758
  }
1677
1759
  _toCDN(e, t) {
1678
- let n = b(e, this.encodingWidth, () => y(BigInt(gt.encode(this.value).length)));
1679
- return vt(this.value, n, e, t);
1760
+ let n = S(e, this.encodingWidth, () => x(BigInt(vt.encode(this.value).length)));
1761
+ if (e?.preserveConcatenation && this.ednParts !== void 0 && this.ednParts.length > 1) {
1762
+ let r = this.ednParts.map((e) => xe(e));
1763
+ return r[r.length - 1] += n, ee(r, _(e), t);
1764
+ }
1765
+ return bt(this.value, n, e, t);
1680
1766
  }
1681
1767
  _toJS(e) {
1682
1768
  return this.value;
1683
1769
  }
1684
1770
  };
1685
- function vt(e, t, n, r) {
1686
- let i = yt(n?.textStringFormat ?? []), a = re(n);
1687
- if (i.length === 0 || a === null) return we(e) + t;
1771
+ function bt(e, t, n, r) {
1772
+ let i = xt(n), a = _(n);
1773
+ if (i.length === 0 || a === null) return xe(e) + t;
1688
1774
  let o = /* @__PURE__ */ new Map(), s = null;
1689
- if (i.includes("cdn") && (s = xt(e), s !== null)) for (let { point: e, contentDepth: t } of s) o.set(e, t);
1775
+ if (i.includes("cdn") && (s = wt(e), s !== null)) for (let { point: e, contentDepth: t } of s) o.set(e, t);
1690
1776
  if (i.includes("newline")) {
1691
- let t = s === null ? bt(e, 0) : St(e);
1777
+ let t = s === null ? Ct(e, 0) : Tt(e);
1692
1778
  for (let { point: e, contentDepth: n } of t) o.has(e) || o.set(e, n);
1693
1779
  }
1694
- let c = kt(e, o);
1695
- if (c.length <= 1) return we(e) + t;
1780
+ let c = Mt(e, o);
1781
+ if (c.length <= 1) return xe(e) + t;
1696
1782
  let l = c.map(({ text: e }, n) => {
1697
- let r = we(e);
1783
+ let r = xe(e);
1698
1784
  return n === c.length - 1 ? r + t : r;
1699
1785
  }), u = l[0];
1700
1786
  for (let e = 1; e < l.length; e++) {
1701
- let t = _(a, r + 1 + c[e].contentDepth);
1787
+ let t = v(a, r + 1 + c[e].contentDepth);
1702
1788
  u += ` +\n${t}${l[e]}`;
1703
1789
  }
1704
1790
  return u;
1705
1791
  }
1706
- function yt(e) {
1707
- return e.map((e) => e === "cboredn" ? (_t || (_t = !0, console.warn("`textStringFormat: ['cboredn']` is deprecated; use `textStringFormat: ['cdn']` instead.")), "cdn") : e);
1792
+ function xt(e) {
1793
+ switch (e?.textStringSplit) {
1794
+ case "none": return [];
1795
+ case "newline": return ["newline"];
1796
+ case "cdn": return ["cdn"];
1797
+ case "cdn+newline": return ["cdn", "newline"];
1798
+ case void 0: return St(e?.textStringFormat ?? []);
1799
+ }
1800
+ }
1801
+ function St(e) {
1802
+ return e.map((e) => e === "cboredn" ? (yt || (yt = !0, console.warn("`textStringFormat: ['cboredn']` is deprecated; use `textStringFormat: ['cdn']` instead.")), "cdn") : e);
1708
1803
  }
1709
- function bt(e, t) {
1804
+ function Ct(e, t) {
1710
1805
  let n = [];
1711
1806
  for (let r = 0; r < e.length; r++) {
1712
1807
  let i = e[r];
@@ -1723,75 +1818,75 @@ function bt(e, t) {
1723
1818
  }
1724
1819
  return n;
1725
1820
  }
1726
- function xt(e) {
1821
+ function wt(e) {
1727
1822
  try {
1728
- rt(e);
1823
+ it(e);
1729
1824
  } catch {
1730
1825
  return null;
1731
1826
  }
1732
- let n = [], r = new t(e), i = 0, a = null, o = !1, s = 0;
1827
+ let t = [], n = new a(e), r = 0, i = null, o = !1, s = 0;
1733
1828
  for (;;) {
1734
- let t = r.consume();
1735
- if (t.type === "EOF") break;
1829
+ let a = n.consume();
1830
+ if (a.type === "EOF") break;
1736
1831
  let c = !1;
1737
- if (o || (o = !0, t.offset > 0 && Dt(r.comments, 0, t.offset) && n.push({
1738
- point: t.offset,
1739
- contentDepth: i
1740
- })), a !== null) {
1741
- if (a.kind === "opener" && wt.has(t.type)) {
1742
- a.point = t.endOffset, s = t.endOffset;
1832
+ if (o || (o = !0, a.offset > 0 && At(n.comments, 0, a.offset) && t.push({
1833
+ point: a.offset,
1834
+ contentDepth: r
1835
+ })), i !== null) {
1836
+ if (i.kind === "opener" && Dt.has(a.type)) {
1837
+ i.point = a.endOffset, s = a.endOffset;
1743
1838
  continue;
1744
- } else a.kind === "opener" && Et.has(t.type) && Ot(e, a.point, t.offset) ? c = !0 : n.push({
1745
- point: t.offset,
1746
- contentDepth: a.contentDepth
1839
+ } else i.kind === "opener" && kt.has(a.type) && jt(e, i.point, a.offset) ? c = !0 : t.push({
1840
+ point: a.offset,
1841
+ contentDepth: i.contentDepth
1747
1842
  });
1748
- a = null;
1843
+ i = null;
1749
1844
  }
1750
- Tt.has(t.type) ? (i++, a = {
1751
- point: t.endOffset,
1752
- contentDepth: i,
1845
+ Ot.has(a.type) ? (r++, i = {
1846
+ point: a.endOffset,
1847
+ contentDepth: r,
1753
1848
  kind: "opener"
1754
- }) : Et.has(t.type) ? (i = Math.max(0, i - 1), c || n.push({
1755
- point: t.offset,
1756
- contentDepth: i
1757
- })) : t.type === "COMMA" && (a = {
1758
- point: t.endOffset,
1759
- contentDepth: i,
1849
+ }) : kt.has(a.type) ? (r = Math.max(0, r - 1), c || t.push({
1850
+ point: a.offset,
1851
+ contentDepth: r
1852
+ })) : a.type === "COMMA" && (i = {
1853
+ point: a.endOffset,
1854
+ contentDepth: r,
1760
1855
  kind: "comma"
1761
- }), s = t.endOffset;
1856
+ }), s = a.endOffset;
1762
1857
  }
1763
- let c = r.comments.find((e) => e.start >= s);
1764
- return c !== void 0 && n.push({
1858
+ let c = n.comments.find((e) => e.start >= s);
1859
+ return c !== void 0 && t.push({
1765
1860
  point: c.start,
1766
- contentDepth: i
1767
- }), n;
1861
+ contentDepth: r
1862
+ }), t;
1768
1863
  }
1769
- function St(e) {
1770
- let n = [], r = new t(e), i = 0;
1864
+ function Tt(e) {
1865
+ let t = [], n = new a(e), r = 0;
1771
1866
  for (;;) {
1772
- let t = r.consume();
1773
- if (t.type === "EOF") break;
1774
- if (Tt.has(t.type)) i++;
1775
- else if (Et.has(t.type)) i = Math.max(0, i - 1);
1776
- else if (t.type !== "COMMA") {
1777
- if (t.type === "TSTR") {
1778
- let r = e.slice(t.offset, t.endOffset);
1779
- for (let e of Ct(r)) n.push({
1780
- point: t.offset + e,
1781
- contentDepth: i + 1
1867
+ let i = n.consume();
1868
+ if (i.type === "EOF") break;
1869
+ if (Ot.has(i.type)) r++;
1870
+ else if (kt.has(i.type)) r = Math.max(0, r - 1);
1871
+ else if (i.type !== "COMMA") {
1872
+ if (i.type === "TSTR") {
1873
+ let n = e.slice(i.offset, i.endOffset);
1874
+ for (let e of Et(n)) t.push({
1875
+ point: i.offset + e,
1876
+ contentDepth: r + 1
1782
1877
  });
1783
- } else if (t.type === "RAWSTRING") {
1784
- let r = e.slice(t.offset, t.endOffset);
1785
- for (let { point: e } of bt(r, 0)) n.push({
1786
- point: t.offset + e,
1787
- contentDepth: i + 1
1878
+ } else if (i.type === "RAWSTRING") {
1879
+ let n = e.slice(i.offset, i.endOffset);
1880
+ for (let { point: e } of Ct(n, 0)) t.push({
1881
+ point: i.offset + e,
1882
+ contentDepth: r + 1
1788
1883
  });
1789
1884
  }
1790
1885
  }
1791
1886
  }
1792
- return n;
1887
+ return t;
1793
1888
  }
1794
- function Ct(e) {
1889
+ function Et(e) {
1795
1890
  let t = [], n = 1, r = e.length - 1;
1796
1891
  for (; n < r;) {
1797
1892
  let r = e[n];
@@ -1807,24 +1902,24 @@ function Ct(e) {
1807
1902
  }
1808
1903
  return t;
1809
1904
  }
1810
- var wt = /* @__PURE__ */ new Set(["ENCODING_INDICATOR", "UNDERSCORE"]), Tt = /* @__PURE__ */ new Set([
1905
+ var Dt = /* @__PURE__ */ new Set(["ENCODING_INDICATOR", "UNDERSCORE"]), Ot = /* @__PURE__ */ new Set([
1811
1906
  "LBRACKET",
1812
1907
  "LBRACE",
1813
1908
  "LPAREN",
1814
1909
  "LT_LT"
1815
- ]), Et = /* @__PURE__ */ new Set([
1910
+ ]), kt = /* @__PURE__ */ new Set([
1816
1911
  "RBRACKET",
1817
1912
  "RBRACE",
1818
1913
  "RPAREN",
1819
1914
  "GT_GT"
1820
1915
  ]);
1821
- function Dt(e, t, n) {
1916
+ function At(e, t, n) {
1822
1917
  return e.some((e) => e.start >= t && e.end <= n);
1823
1918
  }
1824
- function Ot(e, t, n) {
1919
+ function jt(e, t, n) {
1825
1920
  return /^[\t\n\r ]*$/.test(e.slice(t, n));
1826
1921
  }
1827
- function kt(e, t) {
1922
+ function Mt(e, t) {
1828
1923
  let n = [...t].filter(([t]) => t > 0 && t < e.length).sort(([e], [t]) => e - t);
1829
1924
  if (n.length === 0) return [{
1830
1925
  text: e,
@@ -1842,7 +1937,7 @@ function kt(e, t) {
1842
1937
  }
1843
1938
  //#endregion
1844
1939
  //#region src/extensions/dt.ts
1845
- function B(e) {
1940
+ function Nt(e) {
1846
1941
  if (Number.isInteger(e)) return (/* @__PURE__ */ new Date(e * 1e3)).toISOString().replace(/\.000Z$/, "Z");
1847
1942
  let t = Math.round(e * 1e3);
1848
1943
  if (t / 1e3 === e) return new Date(t).toISOString().replace(/\.000Z$/, "Z");
@@ -1850,17 +1945,17 @@ function B(e) {
1850
1945
  for (; s.length < 3;) s += "0";
1851
1946
  return `${i}.${s}Z`;
1852
1947
  }
1853
- var At = new TextDecoder("utf-8", { fatal: !0 });
1854
- function jt(e) {
1948
+ var Pt = new TextDecoder("utf-8", { fatal: !0 });
1949
+ function Ft(e) {
1855
1950
  if (e.length !== 1) throw SyntaxError("dt<<...>>: expected exactly one item");
1856
1951
  let t = e[0];
1857
- if (t instanceof z) return t.value;
1858
- if (t instanceof M) return At.decode(t.value);
1952
+ if (t instanceof V) return t.value;
1953
+ if (t instanceof P) return Pt.decode(t.value);
1859
1954
  throw SyntaxError("dt<<...>>: expected a text string or byte string");
1860
1955
  }
1861
- var Mt = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/i;
1862
- function Nt(e, t) {
1863
- if (!Mt.test(e)) {
1956
+ var It = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/i;
1957
+ function Lt(e, t) {
1958
+ if (!It.test(e)) {
1864
1959
  let n = `dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`;
1865
1960
  if (t) t(n);
1866
1961
  else throw SyntaxError(n);
@@ -1871,93 +1966,93 @@ function Nt(e, t) {
1871
1966
  if (isNaN(a)) throw SyntaxError(`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`);
1872
1967
  if (i === void 0) {
1873
1968
  let e = a / 1e3;
1874
- return e >= 0 ? new Ft(BigInt(e)) : new It(BigInt(e));
1969
+ return e >= 0 ? new zt(BigInt(e)) : new Bt(BigInt(e));
1875
1970
  }
1876
- return new Lt(a / 1e3 + i);
1971
+ return new Vt(a / 1e3 + i);
1877
1972
  }
1878
- var Pt = 1n, Ft = class extends O {
1973
+ var Rt = 1n, zt = class extends A {
1879
1974
  constructor(e, t) {
1880
1975
  super(e, t);
1881
1976
  }
1882
1977
  _toCDN(e, t) {
1883
1978
  if (e?.appStrings === !1) return super._toCDN(e, t);
1884
- let n = b(e, this.encodingWidth, () => y(this.value));
1885
- return `dt'${B(Number(this.value))}'${n}`;
1979
+ let n = S(e, this.encodingWidth, () => x(this.value));
1980
+ return `dt'${Nt(Number(this.value))}'${n}`;
1886
1981
  }
1887
- }, It = class extends k {
1982
+ }, Bt = class extends j {
1888
1983
  constructor(e, t) {
1889
1984
  super(e, t);
1890
1985
  }
1891
1986
  _toCDN(e, t) {
1892
1987
  if (e?.appStrings === !1) return super._toCDN(e, t);
1893
- let n = b(e, this.encodingWidth, () => y(this.argument));
1894
- return `dt'${B(Number(this.value))}'${n}`;
1988
+ let n = S(e, this.encodingWidth, () => x(this.argument));
1989
+ return `dt'${Nt(Number(this.value))}'${n}`;
1895
1990
  }
1896
- }, Lt = class extends A {
1991
+ }, Vt = class extends M {
1897
1992
  constructor(e, t) {
1898
1993
  super(e, t);
1899
1994
  }
1900
1995
  _toCDN(e, t) {
1901
1996
  if (e?.appStrings === !1) return super._toCDN(e, t);
1902
- let n = E(this.value), r = Ee(this.value, this.precision, n, e?.encodingIndicators ?? "auto");
1903
- return `dt'${B(this.value)}'${r}`;
1997
+ let n = O(this.value), r = Ce(this.value, this.precision, n, e?.encodingIndicators ?? "auto");
1998
+ return `dt'${Nt(this.value)}'${r}`;
1904
1999
  }
1905
- }, Rt = class extends j {
2000
+ }, Ht = class extends N {
1906
2001
  constructor(e, t) {
1907
- super(Pt, typeof e == "string" ? Nt(e) : e, t);
2002
+ super(Rt, typeof e == "string" ? Lt(e) : e, t);
1908
2003
  }
1909
2004
  _toCDN(e, t) {
1910
2005
  if (e?.appStrings === !1) return super._toCDN(e, t);
1911
2006
  let n = this.content;
1912
- if (n instanceof A ? n.precision !== void 0 && n.precision !== E(n.value) : n.encodingWidth !== void 0) return super._toCDN({
2007
+ if (n instanceof M ? n.precision !== void 0 && n.precision !== O(n.value) : n.encodingWidth !== void 0) return super._toCDN({
1913
2008
  ...e,
1914
2009
  appStrings: !1
1915
2010
  }, t);
1916
- let r = n instanceof A ? n.value : Number(n.value), i = b(e, this.encodingWidth, () => y(Pt));
1917
- return `DT'${B(r)}'${i}`;
2011
+ let r = n instanceof M ? n.value : Number(n.value), i = S(e, this.encodingWidth, () => x(Rt));
2012
+ return `DT'${Nt(r)}'${i}`;
1918
2013
  }
1919
- }, zt = class extends Rt {
2014
+ }, Ut = class extends Ht {
1920
2015
  constructor(e, t) {
1921
2016
  super(e, t);
1922
2017
  }
1923
2018
  _toJS(e) {
1924
- let t = this.content, n = t instanceof A ? t.value * 1e3 : Number(t.value) * 1e3;
2019
+ let t = this.content, n = t instanceof M ? t.value * 1e3 : Number(t.value) * 1e3;
1925
2020
  return new Date(n);
1926
2021
  }
1927
2022
  };
1928
- function Bt(e) {
2023
+ function Wt(e) {
1929
2024
  let t = e?.jsDate ?? !1;
1930
2025
  function n(e) {
1931
- return t ? new zt(e) : new Rt(e);
2026
+ return t ? new Ut(e) : new Ht(e);
1932
2027
  }
1933
2028
  let r = {
1934
2029
  appStringPrefixes: ["dt", "DT"],
1935
- tagNumbers: [Pt],
2030
+ tagNumbers: [Rt],
1936
2031
  parseAppString(e, t, r) {
1937
- return e === "DT" ? n(t) : Nt(t, r);
2032
+ return e === "DT" ? n(t) : Lt(t, r);
1938
2033
  },
1939
2034
  parseAppSequence(e, t, r) {
1940
- let i = jt(t);
1941
- return e === "DT" ? n(i) : Nt(i, r);
2035
+ let i = Ft(t);
2036
+ return e === "DT" ? n(i) : Lt(i, r);
1942
2037
  },
1943
2038
  parseTag(e, n) {
1944
2039
  if (e !== 1n) return;
1945
2040
  let r;
1946
- if (n instanceof O) r = new Ft(n.value, { encodingWidth: n.encodingWidth });
1947
- else if (n instanceof k) r = new It(n.value, { encodingWidth: n.encodingWidth });
1948
- else if (n instanceof A) r = new Lt(n.value), n.precision !== void 0 && (r.precision = n.precision);
2041
+ if (n instanceof A) r = new zt(n.value, { encodingWidth: n.encodingWidth });
2042
+ else if (n instanceof j) r = new Bt(n.value, { encodingWidth: n.encodingWidth });
2043
+ else if (n instanceof M) r = new Vt(n.value), n.precision !== void 0 && (r.precision = n.precision);
1949
2044
  else return;
1950
- return r.start = n.start, r.end = n.end, t ? new zt(r) : new Rt(r);
2045
+ return r.start = n.start, r.end = n.end, t ? new Ut(r) : new Ht(r);
1951
2046
  }
1952
2047
  };
1953
2048
  return t && (r.fromJS = (e, t) => {
1954
- if (e instanceof Date) return new zt(B(e.getTime() / 1e3));
2049
+ if (e instanceof Date) return new Ut(Nt(e.getTime() / 1e3));
1955
2050
  }, r.isJSType = (e) => e instanceof Date), r;
1956
2051
  }
1957
- var Vt = Bt(), Ht = Bt({ jsDate: !0 });
2052
+ var Gt = Wt(), Kt = Wt({ jsDate: !0 });
1958
2053
  //#endregion
1959
2054
  //#region src/utils/ip.ts
1960
- function Ut(e) {
2055
+ function qt(e) {
1961
2056
  let t = e.split(".");
1962
2057
  if (t.length !== 4) throw SyntaxError(`ip: invalid IPv4 address: ${JSON.stringify(e)}`);
1963
2058
  let n = /* @__PURE__ */ new Uint8Array(4);
@@ -1970,11 +2065,11 @@ function Ut(e) {
1970
2065
  }
1971
2066
  return n;
1972
2067
  }
1973
- function Wt(e) {
2068
+ function Jt(e) {
1974
2069
  let t = /* @__PURE__ */ new Uint8Array(16);
1975
2070
  if (e === "::") return t;
1976
2071
  let n = e, r = null, i = e.match(/^(.*):(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
1977
- i && (n = i[1], n.endsWith(":") && (n += ":"), r = Ut(i[2]));
2072
+ i && (n = i[1], n.endsWith(":") && (n += ":"), r = qt(i[2]));
1978
2073
  let a = n.split("::");
1979
2074
  if (a.length > 2) throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);
1980
2075
  let o = a.length === 2, s = a[0] ? a[0].split(":") : [], c = o && a[1] ? a[1].split(":") : [], l = r ? 6 : 8;
@@ -1991,11 +2086,11 @@ function Wt(e) {
1991
2086
  }
1992
2087
  return r && t.set(r, 12), t;
1993
2088
  }
1994
- function Gt(e) {
2089
+ function Yt(e) {
1995
2090
  return Array.from(e).join(".");
1996
2091
  }
1997
- function Kt(e) {
1998
- let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ? Gt(e.slice(12)) : null, n = t ? 6 : 8, r = [];
2092
+ function Xt(e) {
2093
+ let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ? Yt(e.slice(12)) : null, n = t ? 6 : 8, r = [];
1999
2094
  for (let t = 0; t < n * 2; t += 2) r.push(e[t] << 8 | e[t + 1]);
2000
2095
  let i = -1, a = 0, o = 0;
2001
2096
  for (; o < n;) if (r[o] === 0) {
@@ -2009,29 +2104,29 @@ function Kt(e) {
2009
2104
  }
2010
2105
  //#endregion
2011
2106
  //#region src/extensions/ip.ts
2012
- var qt = "ip", V = "IP", H = 52n, Jt = 54n, Yt = new TextDecoder("utf-8", { fatal: !0 });
2013
- function Xt(e) {
2107
+ var Zt = "ip", H = "IP", U = 52n, Qt = 54n, $t = new TextDecoder("utf-8", { fatal: !0 });
2108
+ function en(e) {
2014
2109
  if (e.length !== 1) throw SyntaxError("ip<<...>>: expected exactly one item");
2015
2110
  let t = e[0];
2016
- if (t instanceof z) return t.value;
2017
- if (t instanceof M) return Yt.decode(t.value);
2111
+ if (t instanceof V) return t.value;
2112
+ if (t instanceof P) return $t.decode(t.value);
2018
2113
  throw SyntaxError("ip<<...>>: expected a text string or byte string");
2019
2114
  }
2020
- function Zt(e) {
2115
+ function tn(e) {
2021
2116
  return /^\d/.test(e) && e.includes(".") && !e.includes(":") ? {
2022
- bytes: Ut(e),
2117
+ bytes: qt(e),
2023
2118
  isV4: !0
2024
2119
  } : {
2025
- bytes: Wt(e),
2120
+ bytes: Jt(e),
2026
2121
  isV4: !1
2027
2122
  };
2028
2123
  }
2029
- function Qt(e) {
2030
- if (e.length === 4) return Gt(e);
2031
- if (e.length === 16) return Kt(e);
2124
+ function nn(e) {
2125
+ if (e.length === 4) return Yt(e);
2126
+ if (e.length === 16) return Xt(e);
2032
2127
  throw SyntaxError(`ip: unexpected byte length: ${e.length}`);
2033
2128
  }
2034
- function $t(e, t) {
2129
+ function rn(e, t) {
2035
2130
  let n = new Uint8Array(e.length);
2036
2131
  n.set(e);
2037
2132
  let r = Math.floor(t / 8), i = t % 8;
@@ -2041,86 +2136,86 @@ function $t(e, t) {
2041
2136
  for (; a > 0 && n[a - 1] === 0;) a--;
2042
2137
  return n.slice(0, a);
2043
2138
  }
2044
- function en(e, t) {
2139
+ function an(e, t) {
2045
2140
  let n = new Uint8Array(t);
2046
2141
  return n.set(e), n;
2047
2142
  }
2048
- var tn = class extends M {
2143
+ var on = class extends P {
2049
2144
  _toCDN(e, t) {
2050
2145
  if (e?.appStrings === !1) return super._toCDN(e, t);
2051
- let n = b(e, this.encodingWidth, () => y(BigInt(this.value.length)));
2052
- return `${qt}'${Qt(this.value)}'${n}`;
2146
+ let n = S(e, this.encodingWidth, () => x(BigInt(this.value.length)));
2147
+ return `${Zt}'${nn(this.value)}'${n}`;
2053
2148
  }
2054
- }, nn = class extends F {
2149
+ }, sn = class extends L {
2055
2150
  _isV4;
2056
2151
  constructor(e, t, n) {
2057
- super([new O(BigInt(e)), new M(t)]), this._isV4 = n;
2152
+ super([new A(BigInt(e)), new P(t)]), this._isV4 = n;
2058
2153
  }
2059
2154
  _toCDN(e, t) {
2060
2155
  if (e?.appStrings === !1) return super._toCDN(e, t);
2061
2156
  let n = Number(this.items[0].value), r = this.items[1].value;
2062
- return `${qt}'${Qt(en(r, this._isV4 ? 4 : 16))}/${n}'`;
2157
+ return `${Zt}'${nn(an(r, this._isV4 ? 4 : 16))}/${n}'`;
2063
2158
  }
2064
- }, rn = class extends j {
2159
+ }, cn = class extends N {
2065
2160
  constructor(e, t) {
2066
2161
  super(e, t);
2067
2162
  }
2068
2163
  _toCDN(e, t) {
2069
2164
  if (e?.appStrings === !1) return super._toCDN(e, t);
2070
- let n = this.tag === H ? 4 : 16, r = this.content;
2071
- if (r instanceof M) {
2165
+ let n = this.tag === U ? 4 : 16, r = this.content;
2166
+ if (r instanceof P) {
2072
2167
  if (r.encodingWidth !== void 0) return super._toCDN(e, t);
2073
- let n = b(e, this.encodingWidth, () => y(this.tag));
2074
- return `${V}'${Qt(r.value)}'${n}`;
2168
+ let n = S(e, this.encodingWidth, () => x(this.tag));
2169
+ return `${H}'${nn(r.value)}'${n}`;
2075
2170
  }
2076
- if (r instanceof F && r.items.length === 2 && r.items[0] instanceof O && r.items[1] instanceof M) {
2171
+ if (r instanceof L && r.items.length === 2 && r.items[0] instanceof A && r.items[1] instanceof P) {
2077
2172
  if (r.encodingWidth !== void 0 || r.items[0].encodingWidth !== void 0 || r.items[1].encodingWidth !== void 0) return super._toCDN(e, t);
2078
- let i = Number(r.items[0].value), a = en(r.items[1].value, n), o = b(e, this.encodingWidth, () => y(this.tag));
2079
- return `${V}'${Qt(a)}/${i}'${o}`;
2173
+ let i = Number(r.items[0].value), a = an(r.items[1].value, n), o = S(e, this.encodingWidth, () => x(this.tag));
2174
+ return `${H}'${nn(a)}/${i}'${o}`;
2080
2175
  }
2081
2176
  return super._toCDN(e, t);
2082
2177
  }
2083
2178
  };
2084
- function an(e, t) {
2179
+ function ln(e, t) {
2085
2180
  let n = t.indexOf("/");
2086
2181
  if (n === -1) {
2087
- let { bytes: n, isV4: r } = Zt(t);
2088
- return e === V ? new rn(r ? H : Jt, new M(n)) : new tn(n);
2182
+ let { bytes: n, isV4: r } = tn(t);
2183
+ return e === H ? new cn(r ? U : Qt, new P(n)) : new on(n);
2089
2184
  }
2090
2185
  let r = t.slice(0, n), i = t.slice(n + 1);
2091
2186
  if (!/^\d+$/.test(i)) throw SyntaxError(`ip: invalid prefix length: ${JSON.stringify(i)}`);
2092
- let a = parseInt(i, 10), { bytes: o, isV4: s } = Zt(r), c = s ? 32 : 128;
2187
+ let a = parseInt(i, 10), { bytes: o, isV4: s } = tn(r), c = s ? 32 : 128;
2093
2188
  if (a > c) throw SyntaxError(`ip: prefix length ${a} exceeds maximum ${c} for ${s ? "IPv4" : "IPv6"}`);
2094
- let l = $t(o, a);
2095
- return e === V ? new rn(s ? H : Jt, new F([new O(BigInt(a)), new M(l)])) : new nn(a, l, s);
2189
+ let l = rn(o, a);
2190
+ return e === H ? new cn(s ? U : Qt, new L([new A(BigInt(a)), new P(l)])) : new sn(a, l, s);
2096
2191
  }
2097
- var on = {
2098
- appStringPrefixes: [qt, V],
2099
- tagNumbers: [H, Jt],
2192
+ var un = {
2193
+ appStringPrefixes: [Zt, H],
2194
+ tagNumbers: [U, Qt],
2100
2195
  parseAppString(e, t) {
2101
- return an(e, t);
2196
+ return ln(e, t);
2102
2197
  },
2103
2198
  parseAppSequence(e, t) {
2104
- return an(e, Xt(t));
2199
+ return ln(e, en(t));
2105
2200
  },
2106
2201
  parseTag(e, t) {
2107
- if (!(e !== H && e !== Jt) && (t instanceof M || t instanceof F)) return new rn(e, t);
2202
+ if (!(e !== U && e !== Qt) && (t instanceof P || t instanceof L)) return new cn(e, t);
2108
2203
  }
2109
- }, sn = 18446744073709551615n, cn = -18446744073709551616n, ln = {
2110
- tagNumbers: [Ke, qe],
2204
+ }, dn = 18446744073709551615n, fn = -18446744073709551616n, pn = {
2205
+ tagNumbers: [qe, Je],
2111
2206
  parseTag(e, t) {
2112
- if (t instanceof M) {
2207
+ if (t instanceof P) {
2113
2208
  if (e === 2n) {
2114
- let e = Ze(t.value);
2115
- return e > sn ? new Qe(e) : void 0;
2209
+ let e = Qe(t.value);
2210
+ return e > dn ? new $e(e) : void 0;
2116
2211
  }
2117
2212
  if (e === 3n) {
2118
- let e = -1n - Ze(t.value);
2119
- return e < cn ? new $e(e) : void 0;
2213
+ let e = -1n - Qe(t.value);
2214
+ return e < fn ? new et(e) : void 0;
2120
2215
  }
2121
2216
  }
2122
2217
  }
2123
- }, un = "cri", dn = "CRI", fn = 99n, pn = /* @__PURE__ */ new Map([
2218
+ }, mn = "cri", hn = "CRI", gn = 99n, _n = /* @__PURE__ */ new Map([
2124
2219
  ["coap", -1n],
2125
2220
  ["coaps", -2n],
2126
2221
  ["http", -3n],
@@ -2131,47 +2226,47 @@ var on = {
2131
2226
  ["coaps+tcp", -8n],
2132
2227
  ["coap+ws", -25n],
2133
2228
  ["coaps+ws", -26n]
2134
- ]), mn = new Map([...pn.entries()].map(([e, t]) => [t, e]));
2135
- function U(e) {
2229
+ ]), vn = new Map([..._n.entries()].map(([e, t]) => [t, e]));
2230
+ function W(e) {
2136
2231
  try {
2137
2232
  return decodeURIComponent(e);
2138
2233
  } catch {
2139
2234
  return e;
2140
2235
  }
2141
2236
  }
2142
- var hn = new TextEncoder(), gn = new TextDecoder("utf-8", { fatal: !0 });
2143
- function _n(e) {
2144
- return Array.from(hn.encode(e), (e) => `%${e.toString(16).toUpperCase().padStart(2, "0")}`).join("");
2237
+ var yn = new TextEncoder(), bn = new TextDecoder("utf-8", { fatal: !0 });
2238
+ function xn(e) {
2239
+ return Array.from(yn.encode(e), (e) => `%${e.toString(16).toUpperCase().padStart(2, "0")}`).join("");
2145
2240
  }
2146
- function W(e, t) {
2241
+ function G(e, t) {
2147
2242
  let n = "";
2148
- for (let r of e) n += t(r) ? r : _n(r);
2243
+ for (let r of e) n += t(r) ? r : xn(r);
2149
2244
  return n;
2150
2245
  }
2151
- function vn(e) {
2246
+ function Sn(e) {
2152
2247
  return /[A-Za-z0-9\-._~]/.test(e);
2153
2248
  }
2154
- function yn(e) {
2249
+ function Cn(e) {
2155
2250
  return /[!$&'()*+,;=]/.test(e);
2156
2251
  }
2157
- function bn(e) {
2158
- return vn(e) || yn(e) || e === ":" || e === "@";
2252
+ function wn(e) {
2253
+ return Sn(e) || Cn(e) || e === ":" || e === "@";
2159
2254
  }
2160
- function xn(e) {
2161
- return (bn(e) || e === "/" || e === "?") && e !== "&";
2255
+ function Tn(e) {
2256
+ return (wn(e) || e === "/" || e === "?") && e !== "&";
2162
2257
  }
2163
- function Sn(e) {
2164
- return bn(e) || e === "/" || e === "?";
2258
+ function En(e) {
2259
+ return wn(e) || e === "/" || e === "?";
2165
2260
  }
2166
- function Cn(e) {
2167
- return vn(e) || yn(e) || e === ":";
2261
+ function Dn(e) {
2262
+ return Sn(e) || Cn(e) || e === ":";
2168
2263
  }
2169
- function wn(e) {
2170
- return vn(e) || yn(e);
2264
+ function On(e) {
2265
+ return Sn(e) || Cn(e);
2171
2266
  }
2172
- function Tn(e) {
2267
+ function kn(e) {
2173
2268
  let t = [], n = e, r = n.indexOf("@");
2174
- r >= 0 && (t.push(L.FALSE), t.push(new z(U(n.slice(0, r)))), n = n.slice(r + 1));
2269
+ r >= 0 && (t.push(z.FALSE), t.push(new V(W(n.slice(0, r)))), n = n.slice(r + 1));
2175
2270
  let i, a = null;
2176
2271
  if (n.startsWith("[")) {
2177
2272
  let e = n.indexOf("]");
@@ -2180,243 +2275,249 @@ function Tn(e) {
2180
2275
  let r = n.slice(e + 1);
2181
2276
  if (r.startsWith(":")) a = r.slice(1);
2182
2277
  else if (r.length > 0) throw SyntaxError("cri: unexpected characters after ']' in authority");
2183
- t.push(new M(Wt(i)));
2278
+ t.push(new P(Jt(i)));
2184
2279
  } else {
2185
2280
  let e = n.lastIndexOf(":");
2186
- 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 M(Ut(i)));
2187
- else for (let e of i.toLowerCase().split(".")) t.push(new z(e));
2281
+ 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 P(qt(i)));
2282
+ else for (let e of i.toLowerCase().split(".")) t.push(new V(e));
2188
2283
  }
2189
2284
  if (a !== null && a !== "") {
2190
2285
  if (!/^\d+$/.test(a)) throw SyntaxError(`cri: invalid port: ${JSON.stringify(a)}`);
2191
2286
  let e = parseInt(a, 10);
2192
2287
  if (e > 65535) throw SyntaxError(`cri: port ${e} out of range`);
2193
- t.push(new O(BigInt(e)));
2288
+ t.push(new A(BigInt(e)));
2194
2289
  }
2195
- return new F(t);
2290
+ return new L(t);
2196
2291
  }
2197
- function En(e) {
2292
+ function An(e) {
2198
2293
  let t = e.items, n = 0, r = "";
2199
- if (n < t.length && t[n] instanceof L && t[n].value === 20) {
2294
+ if (n < t.length && t[n] instanceof z && t[n].value === 20) {
2200
2295
  n++;
2201
2296
  let e = t[n++];
2202
- r += W(e.value, Cn) + "@";
2297
+ r += G(e.value, Dn) + "@";
2203
2298
  }
2204
2299
  if (n >= t.length) return r;
2205
2300
  let i = t[n];
2206
- if (i instanceof M) {
2301
+ if (i instanceof P) {
2207
2302
  n++;
2208
2303
  let { length: e } = i.value;
2209
- if (e === 4) r += Gt(i.value);
2210
- else if (e === 16) r += "[" + Kt(i.value) + "]";
2304
+ if (e === 4) r += Yt(i.value);
2305
+ else if (e === 16) r += "[" + Xt(i.value) + "]";
2211
2306
  else throw Error(`cri: unexpected host-ip byte length: ${e}`);
2212
- n < t.length && t[n] instanceof z && (r += `%25${W(t[n++].value, wn)}`);
2307
+ n < t.length && t[n] instanceof V && (r += `%25${G(t[n++].value, On)}`);
2213
2308
  } else {
2214
2309
  let e = [];
2215
- for (; n < t.length && t[n] instanceof z;) e.push(W(t[n++].value, wn));
2310
+ for (; n < t.length && t[n] instanceof V;) e.push(G(t[n++].value, On));
2216
2311
  r += e.join(".");
2217
2312
  }
2218
- return n < t.length && t[n] instanceof O && (r += ":" + t[n].value.toString()), r;
2313
+ return n < t.length && t[n] instanceof A && (r += ":" + t[n].value.toString()), r;
2219
2314
  }
2220
- function Dn(e) {
2315
+ function jn(e) {
2221
2316
  let t = e.slice(2), n = t.indexOf("/"), r, i;
2222
- return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new z(U(e)))) : (r = t, i = []), {
2223
- authority: Tn(r),
2317
+ return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new V(W(e)))) : (r = t, i = []), {
2318
+ authority: kn(r),
2224
2319
  pathSegments: i
2225
2320
  };
2226
2321
  }
2227
- function On(e) {
2322
+ function Mn(e) {
2228
2323
  let t = e, n = null, r = t.indexOf("#");
2229
- r >= 0 && (n = U(t.slice(r + 1)), t = t.slice(0, r));
2324
+ r >= 0 && (n = W(t.slice(r + 1)), t = t.slice(0, r));
2230
2325
  let i = null, a = t.indexOf("?");
2231
2326
  if (a >= 0) {
2232
2327
  let e = t.slice(a + 1);
2233
- t = t.slice(0, a), i = e.split("&").map((e) => new z(U(e)));
2328
+ t = t.slice(0, a), i = e.split("&").map((e) => new V(W(e)));
2234
2329
  }
2235
2330
  let o = [], s = /^([a-zA-Z][a-zA-Z0-9+.\-]*):([\s\S]*)$/.exec(t);
2236
2331
  if (s) {
2237
- let e = s[1].toLowerCase(), t = s[2], n = pn.get(e);
2238
- if (o.push(n === void 0 ? new z(e) : new k(n)), t.startsWith("//")) {
2239
- let { authority: e, pathSegments: n } = Dn(t);
2240
- o.push(e, new F(n));
2332
+ let e = s[1].toLowerCase(), t = s[2], n = _n.get(e);
2333
+ if (o.push(n === void 0 ? new V(e) : new j(n)), t.startsWith("//")) {
2334
+ let { authority: e, pathSegments: n } = jn(t);
2335
+ o.push(e, new L(n));
2241
2336
  } else if (t.startsWith("/")) {
2242
- let e = t.slice(1).split("/").map((e) => new z(U(e)));
2243
- o.push(L.NULL, new F(e));
2337
+ let e = t.slice(1).split("/").map((e) => new V(W(e)));
2338
+ o.push(z.NULL, new L(e));
2244
2339
  } else {
2245
- let e = t.split("/").map((e) => new z(U(e)));
2246
- o.push(L.TRUE, new F(e));
2340
+ let e = t.split("/").map((e) => new V(W(e)));
2341
+ o.push(z.TRUE, new L(e));
2247
2342
  }
2248
2343
  } else if (t.startsWith("//")) {
2249
- let { authority: e, pathSegments: n } = Dn(t);
2250
- o.push(L.FALSE, e, new F(n));
2344
+ let { authority: e, pathSegments: n } = jn(t);
2345
+ o.push(z.FALSE, e, new L(n));
2251
2346
  } else if (t.startsWith("/")) {
2252
- let e = t.slice(1).split("/").map((e) => new z(U(e)));
2253
- o.push(L.TRUE, new F(e));
2254
- } else if (t === "") o.push(new O(0n));
2347
+ let e = t.slice(1).split("/").map((e) => new V(W(e)));
2348
+ o.push(z.TRUE, new L(e));
2349
+ } else if (t === "") o.push(new A(0n));
2255
2350
  else {
2256
2351
  let n = 1n, r = t, i = !1;
2257
2352
  for (r.startsWith("./") && (i = !0, r = r.slice(2)); r.startsWith("../");) n++, r = r.slice(3);
2258
2353
  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)}`);
2259
- let a = r === "" ? [] : r.split("/").map((e) => new z(U(e)));
2260
- o.push(new O(n), new F(a));
2354
+ let a = r === "" ? [] : r.split("/").map((e) => new V(W(e)));
2355
+ o.push(new A(n), new L(a));
2261
2356
  }
2262
- if (i !== null && o.push(new F(i)), n !== null && (i === null && o.push(L.NULL), o.push(new z(n))), n !== null && i === null && o.splice(o.length - 2, 1), i === null && n === null) {
2357
+ if (i !== null && o.push(new L(i)), n !== null && (i === null && o.push(z.NULL), o.push(new V(n))), n !== null && i === null && o.splice(o.length - 2, 1), i === null && n === null) {
2263
2358
  let e = o[o.length - 1];
2264
- e instanceof F && e.items.length === 0 && o.pop();
2359
+ e instanceof L && e.items.length === 0 && o.pop();
2265
2360
  }
2266
- return o.length === 1 && o[0] instanceof O && o[0].value === 0n ? [] : o;
2361
+ return o.length === 1 && o[0] instanceof A && o[0].value === 0n ? [] : o;
2267
2362
  }
2268
- function G(e, t) {
2363
+ function K(e, t) {
2269
2364
  let n = t, r = "";
2270
2365
  if (n < e.length) {
2271
2366
  let t = e[n];
2272
- if (t instanceof F) {
2367
+ if (t instanceof L) {
2273
2368
  if (n++, t.items.length > 0) {
2274
2369
  let e = t.items.map((e) => {
2275
- if (!(e instanceof z)) throw Error("cri: query item must be a text string");
2276
- return W(e.value, xn);
2370
+ if (!(e instanceof V)) throw Error("cri: query item must be a text string");
2371
+ return G(e.value, Tn);
2277
2372
  });
2278
2373
  r += "?" + e.join("&");
2279
2374
  }
2280
- } else t instanceof L && t.value === 22 && n++;
2375
+ } else t instanceof z && t.value === 22 && n++;
2281
2376
  }
2282
- return n < e.length && e[n] instanceof z && (r += "#" + W(e[n].value, Sn)), r;
2377
+ return n < e.length && e[n] instanceof V && (r += "#" + G(e[n].value, En)), r;
2283
2378
  }
2284
- function kn(e) {
2379
+ function Nn(e) {
2285
2380
  return e.items.map((e) => {
2286
- if (!(e instanceof z)) throw Error("cri: path segment must be a text string");
2287
- return W(e.value, bn);
2381
+ if (!(e instanceof V)) throw Error("cri: path segment must be a text string");
2382
+ return G(e.value, wn);
2288
2383
  });
2289
2384
  }
2290
- function An(e) {
2385
+ function Pn(e) {
2291
2386
  if (e.length === 0) return "";
2292
2387
  let t = 0, n = e[t++];
2293
- if (n instanceof k || n instanceof z) {
2388
+ if (n instanceof j || n instanceof V) {
2294
2389
  let r;
2295
- if (n instanceof k) {
2296
- let e = mn.get(n.value);
2390
+ if (n instanceof j) {
2391
+ let e = vn.get(n.value);
2297
2392
  if (e === void 0) throw Error(`cri: unrecognised scheme-id ${n.value}`);
2298
2393
  r = e + ":";
2299
2394
  } else r = n.value + ":";
2300
2395
  if (t >= e.length) return r;
2301
2396
  let i = e[t++], a = "", o = !1;
2302
- if (i instanceof F) a = "//" + En(i), o = !0;
2303
- else if (i instanceof L) if (i.value === 22) o = !0;
2397
+ if (i instanceof L) a = "//" + An(i), o = !0;
2398
+ else if (i instanceof z) if (i.value === 22) o = !0;
2304
2399
  else if (i.value === 21) o = !1;
2305
2400
  else throw Error(`cri: unexpected no-authority value: simple(${i.value})`);
2306
2401
  else throw Error("cri: unexpected type for authority element");
2307
2402
  let s = "";
2308
- if (t < e.length && e[t] instanceof F) {
2403
+ if (t < e.length && e[t] instanceof L) {
2309
2404
  let n = e[t++];
2310
- n.items.length > 0 && (s = (o ? "/" : "") + kn(n).join("/"));
2405
+ n.items.length > 0 && (s = (o ? "/" : "") + Nn(n).join("/"));
2311
2406
  }
2312
- return r + a + s + G(e, t);
2407
+ return r + a + s + K(e, t);
2313
2408
  }
2314
- if (n instanceof L && n.value === 20) {
2315
- if (t >= e.length || !(e[t] instanceof F)) throw Error("cri: network-path reference requires an authority array");
2316
- let n = En(e[t++]), r = "";
2317
- if (t < e.length && e[t] instanceof F) {
2409
+ if (n instanceof z && n.value === 20) {
2410
+ if (t >= e.length || !(e[t] instanceof L)) throw Error("cri: network-path reference requires an authority array");
2411
+ let n = An(e[t++]), r = "";
2412
+ if (t < e.length && e[t] instanceof L) {
2318
2413
  let n = e[t++];
2319
- n.items.length > 0 && (r = "/" + kn(n).join("/"));
2414
+ n.items.length > 0 && (r = "/" + Nn(n).join("/"));
2320
2415
  }
2321
- return "//" + n + r + G(e, t);
2416
+ return "//" + n + r + K(e, t);
2322
2417
  }
2323
- if (n instanceof L && n.value === 21) {
2418
+ if (n instanceof z && n.value === 21) {
2324
2419
  let n = "/";
2325
- if (t < e.length && e[t] instanceof F) {
2420
+ if (t < e.length && e[t] instanceof L) {
2326
2421
  let r = e[t++];
2327
- n = "/" + kn(r).join("/");
2422
+ n = "/" + Nn(r).join("/");
2328
2423
  }
2329
- return n + G(e, t);
2424
+ return n + K(e, t);
2330
2425
  }
2331
- if (n instanceof O) {
2426
+ if (n instanceof A) {
2332
2427
  let r = n.value;
2333
- if (r === 0n) return G(e, t);
2428
+ if (r === 0n) return K(e, t);
2334
2429
  let i = r === 1n ? "" : "../".repeat(Number(r) - 1), a;
2335
- if (t < e.length && e[t] instanceof F) {
2430
+ if (t < e.length && e[t] instanceof L) {
2336
2431
  let n = e[t++];
2337
2432
  if (n.items.length > 0) {
2338
- let e = kn(n);
2433
+ let e = Nn(n);
2339
2434
  a = (r === 1n && e[0].includes(":") ? "./" : i) + e.join("/");
2340
2435
  } else a = i === "" ? "./" : i;
2341
2436
  } else a = i === "" ? "./" : i;
2342
- return a + G(e, t);
2437
+ return a + K(e, t);
2343
2438
  }
2344
2439
  throw Error("cri: unrecognised first element type in CRI array");
2345
2440
  }
2346
- var jn = class extends F {
2441
+ var Fn = class extends L {
2347
2442
  _toCDN(e, t) {
2348
2443
  if (e?.appStrings === !1) return super._toCDN(e, t);
2349
2444
  try {
2350
- let t = b(e, this.encodingWidth, () => y(BigInt(this.items.length)));
2351
- return `${un}'${An(this.items)}'${t}`;
2445
+ let t = S(e, this.encodingWidth, () => x(BigInt(this.items.length)));
2446
+ return `${mn}'${Pn(this.items)}'${t}`;
2352
2447
  } catch {
2353
2448
  return super._toCDN(e, t);
2354
2449
  }
2355
2450
  }
2356
- }, Mn = class extends j {
2451
+ }, In = class extends N {
2357
2452
  constructor(e) {
2358
- super(fn, e);
2453
+ super(gn, e);
2359
2454
  }
2360
2455
  _toCDN(e, t) {
2361
2456
  if (e?.appStrings === !1) return super._toCDN(e, t);
2362
2457
  try {
2363
2458
  let n = this.content;
2364
2459
  if (n.encodingWidth !== void 0) return super._toCDN(e, t);
2365
- let r = b(e, this.encodingWidth, () => y(fn));
2366
- return `${dn}'${An(n.items)}'${r}`;
2460
+ let r = S(e, this.encodingWidth, () => x(gn));
2461
+ return `${hn}'${Pn(n.items)}'${r}`;
2367
2462
  } catch {
2368
2463
  return super._toCDN(e, t);
2369
2464
  }
2370
2465
  }
2371
2466
  };
2372
- function Nn(e) {
2467
+ function Ln(e) {
2373
2468
  if (e.length !== 1) throw SyntaxError("cri<<...>>: expected exactly one item");
2374
2469
  let t = e[0];
2375
- if (t instanceof z) return t.value;
2376
- if (t instanceof M) return gn.decode(t.value);
2470
+ if (t instanceof V) return t.value;
2471
+ if (t instanceof P) return bn.decode(t.value);
2377
2472
  throw SyntaxError("cri<<...>>: expected a text string or byte string");
2378
2473
  }
2379
- function Pn(e, t) {
2380
- let n = new jn(On(t));
2381
- return e === dn ? new Mn(n) : n;
2474
+ function Rn(e, t) {
2475
+ let n = new Fn(Mn(t));
2476
+ return e === hn ? new In(n) : n;
2382
2477
  }
2383
- var Fn = {
2384
- appStringPrefixes: [un, dn],
2385
- tagNumbers: [fn],
2478
+ var zn = {
2479
+ appStringPrefixes: [mn, hn],
2480
+ tagNumbers: [gn],
2386
2481
  parseAppString(e, t) {
2387
- return Pn(e, t);
2482
+ return Rn(e, t);
2388
2483
  },
2389
2484
  parseAppSequence(e, t) {
2390
- return Pn(e, Nn(t));
2485
+ return Rn(e, Ln(t));
2391
2486
  },
2392
2487
  parseTag(e, t) {
2393
- if (e !== 99n || !(t instanceof F)) return;
2394
- let n = new jn(t.items, {
2488
+ if (e !== 99n || !(t instanceof L)) return;
2489
+ let n = new Fn(t.items, {
2395
2490
  indefiniteLength: t.indefiniteLength,
2396
2491
  encodingWidth: t.encodingWidth
2397
2492
  });
2398
- return n.start = t.start, n.end = t.end, new Mn(n);
2493
+ return n.start = t.start, n.end = t.end, new In(n);
2399
2494
  }
2400
2495
  };
2401
2496
  //#endregion
2402
2497
  //#region src/cbor/decoder.ts
2403
- function K(e, t) {
2498
+ function Bn(e, t) {
2404
2499
  if (e === 24 && t <= 23n) return 0;
2405
2500
  if (e === 25 && t <= 255n) return 1;
2406
2501
  if (e === 26 && t <= 65535n) return 2;
2407
2502
  if (e === 27 && t <= 4294967295n) return 3;
2408
2503
  }
2409
- var In = new TextDecoder("utf-8", {
2504
+ function Vn(e, t) {
2505
+ if (e === 24 && t <= 23) return 0;
2506
+ if (e === 25 && t <= 255) return 1;
2507
+ if (e === 26 && t <= 65535) return 2;
2508
+ if (e === 27 && t <= 4294967295) return 3;
2509
+ }
2510
+ var Hn = new TextDecoder("utf-8", {
2410
2511
  fatal: !0,
2411
2512
  ignoreBOM: !0
2412
- }), Ln = new TextDecoder("utf-8", {
2513
+ }), Un = new TextDecoder("utf-8", {
2413
2514
  fatal: !1,
2414
2515
  ignoreBOM: !0
2415
2516
  });
2416
2517
  function q(e) {
2417
2518
  throw Error(`CBOR decode error: ${e}`);
2418
2519
  }
2419
- function Rn(e, t, n) {
2520
+ function Wn(e, t, n) {
2420
2521
  let r = {
2421
2522
  message: e,
2422
2523
  offset: t
@@ -2427,60 +2528,60 @@ function Rn(e, t, n) {
2427
2528
  function J(e, t) {
2428
2529
  e.warnings ??= [], e.warnings.push(t);
2429
2530
  }
2430
- function zn(e) {
2431
- let t = "";
2432
- for (let n of e) t += n.toString(16).padStart(2, "0");
2433
- return t;
2434
- }
2435
2531
  function Y(e) {
2436
- if (e instanceof O) return ["u", String(e.value)];
2437
- if (e instanceof k) return ["n", String(e.value)];
2438
- if (e instanceof z) return ["t", e.value];
2439
- if (e instanceof P) return ["t", e.chunks.map((e) => e.value).join("")];
2440
- if (e instanceof M) return ["b", zn(e.value)];
2441
- if (e instanceof N) {
2532
+ if (e instanceof A) return ["u", String(e.value)];
2533
+ if (e instanceof j) return ["n", String(e.value)];
2534
+ if (e instanceof V) return ["t", e.value];
2535
+ if (e instanceof I) return ["t", e.chunks.map((e) => e.value).join("")];
2536
+ if (e instanceof P) return ["b", i(e.value)];
2537
+ if (e instanceof F) {
2442
2538
  let t = "";
2443
- for (let n of e.chunks) t += zn(n.value);
2539
+ for (let n of e.chunks) t += i(n.value);
2444
2540
  return ["b", t];
2445
2541
  }
2446
- if (e instanceof A) return isNaN(e.value) ? ["f", "NaN"] : Object.is(e.value, -0) ? ["f", "-0"] : ["f", String(e.value)];
2447
- if (e instanceof L) return ["s", e.value];
2448
- if (e instanceof F) return ["A", e.items.map(Y)];
2449
- if (e instanceof I) {
2542
+ if (e instanceof M) return isNaN(e.value) ? ["f", "NaN"] : Object.is(e.value, -0) ? ["f", "-0"] : ["f", String(e.value)];
2543
+ if (e instanceof z) return ["s", e.value];
2544
+ if (e instanceof L) return ["A", e.items.map(Y)];
2545
+ if (e instanceof R) {
2450
2546
  let t = e.entries.map(([e, t]) => [Y(e), Y(t)]);
2451
2547
  if (t.length <= 1) return ["M", t];
2452
2548
  let n = t.map((e) => [JSON.stringify(e[0]), e]);
2453
2549
  return n.sort((e, t) => e[0] < t[0] ? -1 : +(e[0] > t[0])), ["M", n.map((e) => e[1])];
2454
2550
  }
2455
- if (e instanceof j) return [
2551
+ return e instanceof N ? [
2456
2552
  "G",
2457
2553
  String(e.tag),
2458
2554
  Y(e.content)
2459
- ];
2460
- let t = e.toCBOR(), n = "";
2461
- for (let e of t) n += e.toString(16).padStart(2, "0");
2462
- return ["c", n];
2463
- }
2464
- function Bn(e) {
2465
- if (e instanceof O) return "u" + e.value;
2466
- if (e instanceof k) return "n" + e.value;
2467
- if (e instanceof z) return "t" + e.value;
2468
- if (e instanceof P) {
2555
+ ] : ["c", i(e.toCBOR())];
2556
+ }
2557
+ function Gn(e) {
2558
+ if (e instanceof A) return "u" + e.value;
2559
+ if (e instanceof j) return "n" + e.value;
2560
+ if (e instanceof V) return "t" + e.value;
2561
+ if (e instanceof I) {
2469
2562
  let t = "t";
2470
2563
  for (let n of e.chunks) t += n.value;
2471
2564
  return t;
2472
2565
  }
2473
- if (e instanceof M) return "b" + zn(e.value);
2474
- if (e instanceof N) {
2566
+ if (e instanceof P) return "b" + i(e.value);
2567
+ if (e instanceof F) {
2475
2568
  let t = "b";
2476
- for (let n of e.chunks) t += zn(n.value);
2569
+ for (let n of e.chunks) t += i(n.value);
2477
2570
  return t;
2478
2571
  }
2479
- return e instanceof A ? isNaN(e.value) ? "fNaN" : Object.is(e.value, -0) ? "f-0" : "f" + e.value : e instanceof L ? "s" + e.value : JSON.stringify(Y(e));
2572
+ return e instanceof M ? isNaN(e.value) ? "fNaN" : Object.is(e.value, -0) ? "f-0" : "f" + e.value : e instanceof z ? "s" + e.value : JSON.stringify(Y(e));
2573
+ }
2574
+ var Kn = Array.from({ length: 24 }, (e, t) => BigInt(t)), qn;
2575
+ function Jn() {
2576
+ return qn ??= Z.filter((e) => e.parseTag !== void 0);
2577
+ }
2578
+ function Yn(e, t) {
2579
+ for (let n = 0; n < t; n++) if (e[n] >= 128) return;
2580
+ return String.fromCharCode.apply(null, e);
2480
2581
  }
2481
- function X(e, t, n) {
2582
+ function Xn(e, t, n) {
2482
2583
  if (n <= 23) return {
2483
- value: BigInt(n),
2584
+ value: Kn[n],
2484
2585
  nextOffset: t
2485
2586
  };
2486
2587
  switch (n) {
@@ -2503,14 +2604,43 @@ function X(e, t, n) {
2503
2604
  default: q(`reserved additional info value: ${n}`);
2504
2605
  }
2505
2606
  }
2506
- function Vn(e, t, n, r, i, a) {
2607
+ function Zn(e, t, n) {
2608
+ if (n <= 23) return {
2609
+ value: n,
2610
+ nextOffset: t
2611
+ };
2612
+ switch (n) {
2613
+ case 24: return t + 1 > e.byteLength && q("unexpected end of input"), {
2614
+ value: e.getUint8(t),
2615
+ nextOffset: t + 1
2616
+ };
2617
+ case 25: return t + 2 > e.byteLength && q("unexpected end of input"), {
2618
+ value: e.getUint16(t, !1),
2619
+ nextOffset: t + 2
2620
+ };
2621
+ case 26: return t + 4 > e.byteLength && q("unexpected end of input"), {
2622
+ value: e.getUint32(t, !1),
2623
+ nextOffset: t + 4
2624
+ };
2625
+ case 27: {
2626
+ t + 8 > e.byteLength && q("unexpected end of input");
2627
+ let n = e.getUint32(t, !1), r = e.getUint32(t + 4, !1);
2628
+ return {
2629
+ value: n * 4294967296 + r,
2630
+ nextOffset: t + 8
2631
+ };
2632
+ }
2633
+ default: q(`reserved additional info value: ${n}`);
2634
+ }
2635
+ }
2636
+ function Qn(e, t, n, r, i, a) {
2507
2637
  let o = [], s = t;
2508
2638
  for (;;) {
2509
2639
  if (s >= e.byteLength && q(`unexpected end of indefinite ${i}`), e.getUint8(s) === 255) {
2510
2640
  s++;
2511
2641
  break;
2512
2642
  }
2513
- let t = Z(e, s, n, r);
2643
+ let t = X(e, s, n, r);
2514
2644
  a(t.value) || q(`indefinite-length ${i} chunk must be a definite ${i}`), o.push(t.value), s = t.nextOffset;
2515
2645
  }
2516
2646
  return {
@@ -2518,66 +2648,70 @@ function Vn(e, t, n, r, i, a) {
2518
2648
  nextOffset: s
2519
2649
  };
2520
2650
  }
2521
- function Hn(e, t, n, r) {
2522
- let i = Bn(e);
2523
- t.has(i) && n.push(Rn(`duplicate map key at offset ${e.start}`, e.start, r)), t.add(i);
2651
+ function $n(e, t, n, r) {
2652
+ let i = Gn(e);
2653
+ t.has(i) && n.push(Wn(`duplicate map key at offset ${e.start}`, e.start, r)), t.add(i);
2524
2654
  }
2525
- function Z(e, t, n, r) {
2526
- let i = t, a = Un(e, t, n, r);
2655
+ function X(e, t, n, r) {
2656
+ let i = t, a = tr(e, t, n, r);
2527
2657
  return a.value.start = i, a.value.end = a.nextOffset, a;
2528
2658
  }
2529
- function Un(e, t, n, r) {
2659
+ function er(e, t, n) {
2660
+ return new Uint8Array(e.buffer, e.byteOffset + t, n).slice();
2661
+ }
2662
+ function tr(e, t, n, r) {
2530
2663
  t >= e.byteLength && q("unexpected end of input");
2531
2664
  let i = e.getUint8(t++), a = i >> 5, o = i & 31;
2532
2665
  switch (a) {
2533
2666
  case 0: {
2534
- let { value: n, nextOffset: r } = X(e, t, o);
2667
+ let { value: n, nextOffset: r } = Xn(e, t, o);
2535
2668
  return {
2536
- value: new O(n, { encodingWidth: K(o, n) }),
2669
+ value: new A(n, { encodingWidth: Bn(o, n) }),
2537
2670
  nextOffset: r
2538
2671
  };
2539
2672
  }
2540
2673
  case 1: {
2541
- let { value: n, nextOffset: r } = X(e, t, o), i = K(o, n);
2674
+ let { value: n, nextOffset: r } = Xn(e, t, o), i = Bn(o, n);
2542
2675
  return {
2543
- value: new k(-1n - n, { encodingWidth: i }),
2676
+ value: new j(-1n - n, { encodingWidth: i }),
2544
2677
  nextOffset: r
2545
2678
  };
2546
2679
  }
2547
2680
  case 2: {
2548
2681
  if (o === 31) {
2549
- let { chunks: i, nextOffset: a } = Vn(e, t, n, r, "byte string", (e) => e instanceof M);
2682
+ let { chunks: i, nextOffset: a } = Qn(e, t, n, r, "byte string", (e) => e instanceof P);
2550
2683
  return {
2551
- value: new N(i),
2684
+ value: new F(i),
2552
2685
  nextOffset: a
2553
2686
  };
2554
2687
  }
2555
- let { value: i, nextOffset: a } = X(e, t, o), s = Number(i), c = K(o, i);
2556
- return a + s > e.byteLength && q("byte string extends beyond input"), {
2557
- value: new M(new Uint8Array(e.buffer, e.byteOffset + a, s).slice(), { encodingWidth: c }),
2558
- nextOffset: a + s
2688
+ let { value: i, nextOffset: a } = Zn(e, t, o), s = Vn(o, i);
2689
+ return a + i > e.byteLength && q("byte string extends beyond input"), {
2690
+ value: new P(new Uint8Array(e.buffer, e.byteOffset + a, i).slice(), { encodingWidth: s }),
2691
+ nextOffset: a + i
2559
2692
  };
2560
2693
  }
2561
2694
  case 3: {
2562
2695
  if (o === 31) {
2563
- let { chunks: i, nextOffset: a } = Vn(e, t, n, r, "text string", (e) => e instanceof z);
2696
+ let { chunks: i, nextOffset: a } = Qn(e, t, n, r, "text string", (e) => e instanceof V);
2564
2697
  return {
2565
- value: new P(i),
2698
+ value: new I(i),
2566
2699
  nextOffset: a
2567
2700
  };
2568
2701
  }
2569
- let { value: i, nextOffset: a } = X(e, t, o), s = Number(i), c = K(o, i);
2570
- a + s > e.byteLength && q("text string extends beyond input");
2571
- let l = new Uint8Array(e.buffer, e.byteOffset + a, s), u, d;
2572
- try {
2573
- u = In.decode(l);
2702
+ let { value: i, nextOffset: a } = Zn(e, t, o), s = Vn(o, i);
2703
+ a + i > e.byteLength && q("text string extends beyond input");
2704
+ let c = new Uint8Array(e.buffer, e.byteOffset + a, i), l, u, d = i < 64 ? Yn(c, i) : void 0;
2705
+ if (d !== void 0) l = d;
2706
+ else try {
2707
+ l = Hn.decode(c);
2574
2708
  } catch {
2575
- d = Rn("invalid UTF-8 sequence in text string", a, n), u = Ln.decode(l);
2709
+ u = Wn("invalid UTF-8 sequence in text string", a, n), l = Un.decode(c);
2576
2710
  }
2577
- let f = new z(u, { encodingWidth: c });
2578
- return d && J(f, d), {
2711
+ let f = new V(l, { encodingWidth: s });
2712
+ return u && J(f, u), {
2579
2713
  value: f,
2580
- nextOffset: a + s
2714
+ nextOffset: a + i
2581
2715
  };
2582
2716
  }
2583
2717
  case 4: {
@@ -2588,22 +2722,22 @@ function Un(e, t, n, r) {
2588
2722
  a++;
2589
2723
  break;
2590
2724
  }
2591
- let t = Z(e, a, n, r);
2725
+ let t = X(e, a, n, r);
2592
2726
  i.push(t.value), a = t.nextOffset;
2593
2727
  }
2594
2728
  return {
2595
- value: new F(i, { indefiniteLength: !0 }),
2729
+ value: new L(i, { indefiniteLength: !0 }),
2596
2730
  nextOffset: a
2597
2731
  };
2598
2732
  }
2599
- let { value: i, nextOffset: a } = X(e, t, o), s = Number(i), c = K(o, i), l = [], u = a;
2600
- for (let t = 0; t < s; t++) {
2601
- let t = Z(e, u, n, r);
2602
- l.push(t.value), u = t.nextOffset;
2733
+ let { value: i, nextOffset: a } = Zn(e, t, o), s = Vn(o, i), c = [], l = a;
2734
+ for (let t = 0; t < i; t++) {
2735
+ let t = X(e, l, n, r);
2736
+ c.push(t.value), l = t.nextOffset;
2603
2737
  }
2604
2738
  return {
2605
- value: new F(l, { encodingWidth: c }),
2606
- nextOffset: u
2739
+ value: new L(c, { encodingWidth: s }),
2740
+ nextOffset: l
2607
2741
  };
2608
2742
  }
2609
2743
  case 5: {
@@ -2614,126 +2748,150 @@ function Un(e, t, n, r) {
2614
2748
  s++;
2615
2749
  break;
2616
2750
  }
2617
- let t = Z(e, s, n, r);
2618
- Hn(t.value, a, o, n), s = t.nextOffset;
2619
- let c = Z(e, s, n, r);
2751
+ let t = X(e, s, n, r);
2752
+ $n(t.value, a, o, n), s = t.nextOffset;
2753
+ let c = X(e, s, n, r);
2620
2754
  s = c.nextOffset, i.push([t.value, c.value]);
2621
2755
  }
2622
- let c = new I(i, { indefiniteLength: !0 });
2756
+ let c = new R(i, { indefiniteLength: !0 });
2623
2757
  for (let e of o) J(c, e);
2624
2758
  return {
2625
2759
  value: c,
2626
2760
  nextOffset: s
2627
2761
  };
2628
2762
  }
2629
- let { value: i, nextOffset: a } = X(e, t, o), s = Number(i), c = K(o, i), l = [], u = /* @__PURE__ */ new Set(), d = [], f = a;
2630
- for (let t = 0; t < s; t++) {
2631
- let t = Z(e, f, n, r);
2632
- Hn(t.value, u, d, n), f = t.nextOffset;
2633
- let i = Z(e, f, n, r);
2634
- f = i.nextOffset, l.push([t.value, i.value]);
2763
+ let { value: i, nextOffset: a } = Zn(e, t, o), s = Vn(o, i), c = [], l = /* @__PURE__ */ new Set(), u = [], d = a;
2764
+ for (let t = 0; t < i; t++) {
2765
+ let t = X(e, d, n, r);
2766
+ $n(t.value, l, u, n), d = t.nextOffset;
2767
+ let i = X(e, d, n, r);
2768
+ d = i.nextOffset, c.push([t.value, i.value]);
2635
2769
  }
2636
- let p = new I(l, { encodingWidth: c });
2637
- for (let e of d) J(p, e);
2770
+ let f = new R(c, { encodingWidth: s });
2771
+ for (let e of u) J(f, e);
2638
2772
  return {
2639
- value: p,
2640
- nextOffset: f
2773
+ value: f,
2774
+ nextOffset: d
2641
2775
  };
2642
2776
  }
2643
2777
  case 6: {
2644
2778
  o === 31 && q("tags cannot use indefinite-length encoding");
2645
- let { value: i, nextOffset: a } = X(e, t, o), s = K(o, i), c = Z(e, a, n, r);
2779
+ let { value: i, nextOffset: a } = Xn(e, t, o), s = Bn(o, i), c = X(e, a, n, r);
2646
2780
  for (let e of r) {
2647
2781
  let t = e.parseTag(i, c.value, n);
2648
- if (t !== void 0) return t instanceof j && s !== void 0 && (t.encodingWidth = s), {
2782
+ if (t !== void 0) return t instanceof N && s !== void 0 && (t.encodingWidth = s), {
2649
2783
  value: t,
2650
2784
  nextOffset: c.nextOffset
2651
2785
  };
2652
2786
  }
2653
2787
  return {
2654
- value: new j(i, c.value, { encodingWidth: s }),
2788
+ value: new N(i, c.value, { encodingWidth: s }),
2655
2789
  nextOffset: c.nextOffset
2656
2790
  };
2657
2791
  }
2658
2792
  case 7:
2659
2793
  if (o <= 19) return {
2660
- value: new L(o),
2794
+ value: new z(o),
2661
2795
  nextOffset: t
2662
2796
  };
2663
2797
  if (o === 20) return {
2664
- value: new L(20),
2798
+ value: new z(20),
2665
2799
  nextOffset: t
2666
2800
  };
2667
2801
  if (o === 21) return {
2668
- value: new L(21),
2802
+ value: new z(21),
2669
2803
  nextOffset: t
2670
2804
  };
2671
2805
  if (o === 22) return {
2672
- value: new L(22),
2806
+ value: new z(22),
2673
2807
  nextOffset: t
2674
2808
  };
2675
2809
  if (o === 23) return {
2676
- value: new L(23),
2810
+ value: new z(23),
2677
2811
  nextOffset: t
2678
2812
  };
2679
2813
  if (o === 24) {
2680
2814
  t + 1 > e.byteLength && q("unexpected end of input");
2681
2815
  let r = e.getUint8(t);
2682
2816
  if (r < 32) {
2683
- let e = Rn(`simple value ${r} must be encoded in initial byte (0–31 reserved for extended encoding)`, t - 1, n), i = new L(r);
2817
+ let e = Wn(`simple value ${r} must be encoded in initial byte (0–31 reserved for extended encoding)`, t - 1, n), i = new z(r);
2684
2818
  return J(i, e), {
2685
2819
  value: i,
2686
2820
  nextOffset: t + 1
2687
2821
  };
2688
2822
  }
2689
2823
  return {
2690
- value: new L(r),
2824
+ value: new z(r),
2691
2825
  nextOffset: t + 1
2692
2826
  };
2693
2827
  }
2694
- return o === 25 ? (t + 2 > e.byteLength && q("unexpected end of input"), {
2695
- value: new A(S(e.getUint16(t, !1)), { precision: "half" }),
2696
- nextOffset: t + 2
2697
- }) : o === 26 ? (t + 4 > e.byteLength && q("unexpected end of input"), {
2698
- value: new A(e.getFloat32(t, !1), { precision: "single" }),
2699
- nextOffset: t + 4
2700
- }) : o === 27 ? (t + 8 > e.byteLength && q("unexpected end of input"), {
2701
- value: new A(e.getFloat64(t, !1), { precision: "double" }),
2702
- nextOffset: t + 8
2703
- }) : (o < 31 && q(`reserved additional info value in major type 7: ${o}`), q("unexpected break code outside indefinite-length item"));
2828
+ if (o === 25) {
2829
+ t + 2 > e.byteLength && q("unexpected end of input");
2830
+ let n = w(e.getUint16(t, !1));
2831
+ return {
2832
+ value: new M(n, {
2833
+ precision: "half",
2834
+ rawBits: Number.isNaN(n) ? er(e, t, 2) : void 0
2835
+ }),
2836
+ nextOffset: t + 2
2837
+ };
2838
+ }
2839
+ if (o === 26) {
2840
+ t + 4 > e.byteLength && q("unexpected end of input");
2841
+ let n = e.getFloat32(t, !1);
2842
+ return {
2843
+ value: new M(n, {
2844
+ precision: "single",
2845
+ rawBits: Number.isNaN(n) ? er(e, t, 4) : void 0
2846
+ }),
2847
+ nextOffset: t + 4
2848
+ };
2849
+ }
2850
+ if (o === 27) {
2851
+ t + 8 > e.byteLength && q("unexpected end of input");
2852
+ let n = e.getFloat64(t, !1);
2853
+ return {
2854
+ value: new M(n, {
2855
+ precision: "double",
2856
+ rawBits: Number.isNaN(n) ? er(e, t, 8) : void 0
2857
+ }),
2858
+ nextOffset: t + 8
2859
+ };
2860
+ }
2861
+ return o < 31 && q(`reserved additional info value in major type 7: ${o}`), q("unexpected break code outside indefinite-length item");
2704
2862
  }
2705
2863
  return q(`unknown major type: ${a}`);
2706
2864
  }
2707
- function Wn(e) {
2865
+ function nr(e) {
2708
2866
  if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new Uint8Array(e);
2709
2867
  if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
2710
2868
  throw TypeError("expected ArrayBufferView or ArrayBufferLike");
2711
2869
  }
2712
- function Gn(e, t) {
2713
- let n = Wn(e), r = new DataView(n.buffer, n.byteOffset, n.byteLength), i = t?.offset ?? 0;
2870
+ function rr(e, t) {
2871
+ let n = nr(e), r = new DataView(n.buffer, n.byteOffset, n.byteLength), i = t?.offset ?? 0;
2714
2872
  if (!Number.isInteger(i) || i < 0 || i > r.byteLength) throw RangeError(`CBOR decode offset must be an integer between 0 and ${r.byteLength}`);
2715
- let a = [...t?.extensions ?? [], ...qn].filter((e) => e.parseTag !== void 0), { value: o, nextOffset: s } = Z(r, i, t, a);
2873
+ let a = t?.extensions?.length ? [...t.extensions.filter((e) => e.parseTag !== void 0), ...Jn()] : Jn(), { value: o, nextOffset: s } = X(r, i, t, a);
2716
2874
  if (!t?.allowTrailing && s !== r.byteLength) {
2717
- J(o, Rn(`${r.byteLength - s} trailing byte(s) after end of CBOR item`, s, t));
2875
+ J(o, Wn(`${r.byteLength - s} trailing byte(s) after end of CBOR item`, s, t));
2718
2876
  let e = {
2719
2877
  strict: !1,
2720
2878
  silent: !0
2721
2879
  }, n = s;
2722
- for (; n < r.byteLength;) ({nextOffset: n} = Z(r, n, e, a));
2880
+ for (; n < r.byteLength;) ({nextOffset: n} = X(r, n, e, a));
2723
2881
  }
2724
2882
  return o;
2725
2883
  }
2726
2884
  //#endregion
2727
2885
  //#region src/extensions/cbordata.ts
2728
- var Kn = 24n, qn = [
2729
- Vt,
2730
- on,
2731
- ln,
2732
- Fn,
2886
+ var ir = 24n, Z = [
2887
+ Gt,
2888
+ un,
2889
+ pn,
2890
+ zn,
2733
2891
  {
2734
- tagNumbers: [Kn],
2892
+ tagNumbers: [ir],
2735
2893
  parseTag(e, t, n) {
2736
- if (e !== 24n || !(t instanceof M)) return;
2894
+ if (e !== 24n || !(t instanceof P)) return;
2737
2895
  let r = n ? {
2738
2896
  extensions: n.extensions,
2739
2897
  strict: n.strict,
@@ -2741,65 +2899,76 @@ var Kn = 24n, qn = [
2741
2899
  silent: n.silent
2742
2900
  } : void 0;
2743
2901
  try {
2744
- return new j(Kn, new Ve([Gn(t.value, r)], { encodingWidth: t.encodingWidth }));
2902
+ return new N(ir, new He([rr(t.value, r)], { encodingWidth: t.encodingWidth }));
2745
2903
  } catch (e) {
2746
2904
  if (r?.strict !== !1) throw e;
2747
2905
  return;
2748
2906
  }
2749
2907
  }
2750
2908
  }
2751
- ];
2752
- //#endregion
2753
- //#region src/js/fromJS.ts
2754
- function Q(e, t) {
2909
+ ], ar;
2910
+ function or() {
2911
+ return ar ??= {
2912
+ fromJS: Z.filter((e) => e.fromJS !== void 0),
2913
+ parseTag: Z.filter((e) => e.parseTag !== void 0)
2914
+ };
2915
+ }
2916
+ function sr(e) {
2917
+ let t = e?.extensions, n = or();
2918
+ return t?.length ? {
2919
+ fromJS: [...t.filter((e) => e.fromJS !== void 0), ...n.fromJS],
2920
+ parseTag: [...t.filter((e) => e.parseTag !== void 0), ...n.parseTag]
2921
+ } : n;
2922
+ }
2923
+ function cr(e, t) {
2755
2924
  if (t?.replacer) {
2756
- let { replacer: n, ...r } = t, i = Xn(e, n, r.extensions, r.undefinedOmits);
2757
- return i === d ? L.UNDEFINED : Q(i, Object.keys(r).length > 0 ? r : void 0);
2925
+ let { replacer: n, ...r } = t, i = ur(e, n, r.extensions, r.undefinedOmits);
2926
+ return i === h ? z.UNDEFINED : cr(i, Object.keys(r).length > 0 ? r : void 0);
2758
2927
  }
2759
- return Jn(e, t, !0);
2928
+ return Q(e, t, !0, sr(t));
2760
2929
  }
2761
- function Jn(e, t, n) {
2762
- for (let n of [...t?.extensions ?? [], ...qn]) if (n.fromJS) {
2930
+ function Q(e, t, n, r) {
2931
+ for (let n of r.fromJS) {
2763
2932
  let r = n.fromJS(e, t ?? {});
2764
2933
  if (r !== void 0) return r;
2765
2934
  }
2766
- if (n && typeof e == "object" && e && u.symbol in e) {
2767
- let n = e[u.symbol], r = Jn(e, t, !1);
2768
- for (let e of [...t?.extensions ?? [], ...qn]) if (e.parseTag) {
2769
- let t = e.parseTag(n, r);
2935
+ if (n && typeof e == "object" && e && m.symbol in e) {
2936
+ let n = e[m.symbol], i = Q(e, t, !1, r);
2937
+ for (let e of r.parseTag) {
2938
+ let t = e.parseTag(n, i);
2770
2939
  if (t !== void 0) return t;
2771
2940
  }
2772
- return new j(n, r);
2773
- }
2774
- if (e instanceof u.Null) return L.NULL;
2775
- if (e instanceof u.Undefined) return L.UNDEFINED;
2776
- if (e instanceof f) return new L(e.value);
2777
- if (e === null) return L.NULL;
2778
- if (e === void 0) return L.UNDEFINED;
2779
- if (e === !0) return L.TRUE;
2780
- if (e === !1) return L.FALSE;
2781
- if (typeof e == "bigint") return e > 18446744073709551615n ? new Qe(e) : e < -18446744073709551616n ? new $e(e) : e >= 0n ? new O(e) : new k(e);
2782
- if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new O(BigInt(e)) : new k(BigInt(e)) : new A(e);
2783
- if (typeof e == "string") return new z(e);
2784
- if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return Jn(e.valueOf(), t, !1);
2785
- if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new M(new Uint8Array(e));
2786
- if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new F(Array.from(e, (e) => new O(BigInt(e)))) : new M(new Uint8Array(e.buffer, e.byteOffset, e.byteLength));
2787
- if (e instanceof $) return new I([...e].map(([e, n]) => [Q(e, t), Q(n, t)]));
2788
- if (Array.isArray(e)) return new F(e.map((e) => Q(e, t)));
2941
+ return new N(n, i);
2942
+ }
2943
+ if (e instanceof m.Null) return z.NULL;
2944
+ if (e instanceof m.Undefined) return z.UNDEFINED;
2945
+ if (e instanceof g) return new z(e.value);
2946
+ if (e === null) return z.NULL;
2947
+ if (e === void 0) return z.UNDEFINED;
2948
+ if (e === !0) return z.TRUE;
2949
+ if (e === !1) return z.FALSE;
2950
+ if (typeof e == "bigint") return e > 18446744073709551615n ? new $e(e) : e < -18446744073709551616n ? new et(e) : e >= 0n ? new A(e) : new j(e);
2951
+ if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new A(BigInt(e)) : new j(BigInt(e)) : new M(e);
2952
+ if (typeof e == "string") return new V(e);
2953
+ if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return Q(e.valueOf(), t, !1, r);
2954
+ if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new P(new Uint8Array(e));
2955
+ if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new L(Array.from(e, (e) => new A(BigInt(e)))) : new P(new Uint8Array(e.buffer, e.byteOffset, e.byteLength));
2956
+ if (e instanceof $) return new R([...e].map(([e, n]) => [Q(e, t, !0, r), Q(n, t, !0, r)]));
2957
+ if (Array.isArray(e)) return new L(e.map((e) => Q(e, t, !0, r)));
2789
2958
  if (typeof e == "object") {
2790
2959
  let n = [];
2791
- for (let [r, i] of Object.entries(e)) n.push([new z(r), Q(i, t)]);
2792
- return new I(n);
2960
+ for (let [i, a] of Object.entries(e)) n.push([new V(i), Q(a, t, !0, r)]);
2961
+ return new R(n);
2793
2962
  }
2794
2963
  throw TypeError(`fromJS: unsupported value type: ${typeof e}`);
2795
2964
  }
2796
- function Yn(e) {
2797
- 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 u.Null || e instanceof u.Undefined || e instanceof f;
2965
+ function lr(e) {
2966
+ 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 m.Null || e instanceof m.Undefined || e instanceof g;
2798
2967
  }
2799
- function Xn(e, t, n, r) {
2800
- let i = [...n ?? [], ...qn];
2968
+ function ur(e, t, n, r) {
2969
+ let i = [...n ?? [], ...Z].filter((e) => e.isJSType !== void 0);
2801
2970
  function a(e) {
2802
- return e === d || r === !0 && e === void 0;
2971
+ return e === h || r === !0 && e === void 0;
2803
2972
  }
2804
2973
  if (Array.isArray(t)) {
2805
2974
  let n = t.map(String);
@@ -2807,7 +2976,7 @@ function Xn(e, t, n, r) {
2807
2976
  if (typeof e != "object" || !e) return e;
2808
2977
  if (e instanceof $) return $.from(e, ([e, t]) => [e, r(t)]);
2809
2978
  if (Array.isArray(e)) return e.map(r);
2810
- if (u.symbol in e || Yn(e) || i.some((t) => t.isJSType?.(e))) return e;
2979
+ if (m.symbol in e || lr(e) || i.some((t) => t.isJSType(e))) return e;
2811
2980
  let t = Object.getPrototypeOf(e);
2812
2981
  if (t === Object.prototype || t === null) {
2813
2982
  let t = e.toJSON;
@@ -2829,7 +2998,7 @@ function Xn(e, t, n, r) {
2829
2998
  }
2830
2999
  }
2831
3000
  if (e = o.call(n, t, e), typeof e == "object" && e) {
2832
- if (u.symbol in e) return e;
3001
+ if (m.symbol in e) return e;
2833
3002
  if (e instanceof $) {
2834
3003
  let t = new $();
2835
3004
  for (let [n, r] of e) {
@@ -2842,7 +3011,7 @@ function Xn(e, t, n, r) {
2842
3011
  let r = s(t, String(n), e);
2843
3012
  return a(r) ? null : r;
2844
3013
  });
2845
- if (Yn(e) || i.some((t) => t.isJSType?.(e))) return e;
3014
+ if (lr(e) || i.some((t) => t.isJSType(e))) return e;
2846
3015
  let t = {};
2847
3016
  for (let n of Object.keys(e)) {
2848
3017
  let r = s(e[n], n, e);
@@ -2860,7 +3029,7 @@ var $ = class extends Array {
2860
3029
  toJSON() {
2861
3030
  let e = {};
2862
3031
  for (let [t, n] of this) {
2863
- let r = typeof t == "string" ? t : Q(t).toCDN();
3032
+ let r = typeof t == "string" ? t : cr(t).toCDN();
2864
3033
  r === "__proto__" ? Object.defineProperty(e, r, {
2865
3034
  value: n,
2866
3035
  writable: !0,
@@ -2872,6 +3041,6 @@ var $ = class extends Array {
2872
3041
  }
2873
3042
  };
2874
3043
  //#endregion
2875
- export { i as A, x as C, n as D, d as E, r as O, S, f as T, j as _, Ht as a, O as b, $e as c, L as d, I as f, M as g, N as h, Gn as i, u as k, Qe as l, P as m, Xn as n, z as o, F as p, Q as r, rt as s, $ as t, Ve as u, A as v, ne as w, D as x, k as y };
3044
+ export { C, s as D, o as E, m as O, w as S, h as T, N as _, Kt as a, A as b, et as c, z as d, R as f, P as g, F as h, rr as i, c as k, $e as l, I as m, ur as n, V as o, L as p, cr as r, it as s, $ as t, He as u, M as v, g as w, k as x, j as y };
2876
3045
 
2877
- //# sourceMappingURL=mapEntries-Cc4If3gy.js.map
3046
+ //# sourceMappingURL=mapEntries-B8riGPMD.js.map