@cbortech/cbor 0.25.5 → 0.25.7

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