@cbortech/cbor 0.25.10 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,49 +1,14 @@
1
- import { a as e, o as t } from "./tokenizer-DkLlZ1gc.js";
2
- import { C as n, D as r, E as i, O as a, S as o, T as s, a as c, g as l, i as u, k as d, n as f, r as p, s as m, t as h, v as g, w as _ } from "./mapEntries-B8riGPMD.js";
3
- //#region src/utils/strip-comments.ts
4
- function v(e) {
5
- let t = "", n = 0;
6
- for (; n < e.length;) {
7
- let r = e[n];
8
- if (r === " " || r === "\n" || r === "\r") {
9
- n++;
10
- continue;
11
- }
12
- if (r === "#") {
13
- for (; n < e.length && e[n] !== "\n";) n++;
14
- continue;
15
- }
16
- if (r === "/") {
17
- let t = e[n + 1] ?? "";
18
- if (t === "/") {
19
- for (; n < e.length && e[n] !== "\n";) n++;
20
- continue;
21
- }
22
- if (t === "*") {
23
- for (n += 2; n < e.length && !(e[n] === "*" && (e[n + 1] ?? "") === "/");) n++;
24
- if (n >= e.length) throw SyntaxError("unterminated block comment");
25
- n += 2;
26
- continue;
27
- }
28
- for (n++; n < e.length && e[n] !== "/";) n++;
29
- if (n >= e.length) throw SyntaxError("unterminated block comment");
30
- n++;
31
- continue;
32
- }
33
- t += r, n++;
34
- }
35
- return t;
36
- }
37
- //#endregion
1
+ import { o as e } from "./tokenizer-CeuixxXi.js";
2
+ import { A as t, M as n, N as r, O as i, S as a, a as o, c as s, d as c, i as l, j as u, k as d, l as f, n as p, o as m, p as h, r as g, s as _, t as v, u as y } from "./mapEntries-BdzS6bFp.js";
38
3
  //#region src/extensions/b32.ts
39
- var y = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", b = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
40
- function x(e) {
4
+ var b = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", x = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
5
+ function S(e) {
41
6
  let t = e.length;
42
7
  for (; t > 0 && e.charCodeAt(t - 1) === 61;) t--;
43
8
  return e.slice(0, t);
44
9
  }
45
- function S(e, t, n) {
46
- let r = x(e).toUpperCase(), i = r.length % 8;
10
+ function C(e, t, n) {
11
+ let r = S(e).toUpperCase(), i = r.length % 8;
47
12
  if (i === 1 || i === 3 || i === 6) throw SyntaxError(`invalid base32 length: ${r.length} characters`);
48
13
  let a = (/* @__PURE__ */ new Uint8Array(128)).fill(255);
49
14
  for (let e = 0; e < t.length; e++) a[t.charCodeAt(e)] = e;
@@ -60,169 +25,43 @@ function S(e, t, n) {
60
25
  }
61
26
  return o;
62
27
  }
63
- var C = {
28
+ var w = {
64
29
  appStringPrefixes: ["b32"],
65
30
  parseAppString(e, t, n) {
66
- return new l(S(v(t), y, n), { ednEncoding: "base32" });
31
+ return new a(C(o(t), b, n), { ednEncoding: "base32" });
67
32
  }
68
- }, w = {
33
+ }, T = {
69
34
  appStringPrefixes: ["h32"],
70
35
  parseAppString(e, t, n) {
71
- return new l(S(v(t), b, n), { ednEncoding: "base32hex" });
72
- }
73
- }, T = class extends g {
74
- _bits;
75
- constructor(e) {
76
- super(o(e), { precision: "half" }), this._bits = e & 65535;
77
- }
78
- _toCBOR() {
79
- return new Uint8Array([
80
- 249,
81
- this._bits >> 8 & 255,
82
- this._bits & 255
83
- ]);
84
- }
85
- }, E = class extends g {
86
- _raw;
87
- constructor(e) {
88
- super(new DataView(e.buffer, e.byteOffset).getFloat32(0, !1), { precision: "single" }), this._raw = e.slice();
89
- }
90
- _toCBOR() {
91
- let e = /* @__PURE__ */ new Uint8Array(5);
92
- return e[0] = 250, e.set(this._raw, 1), e;
93
- }
94
- }, D = class extends g {
95
- _raw;
96
- constructor(e) {
97
- super(new DataView(e.buffer, e.byteOffset).getFloat64(0, !1), { precision: "double" }), this._raw = e.slice();
98
- }
99
- _toCBOR() {
100
- let e = /* @__PURE__ */ new Uint8Array(9);
101
- return e[0] = 251, e.set(this._raw, 1), e;
102
- }
103
- };
104
- function O(e) {
105
- if (e.length === 2) return new T(e[0] << 8 | e[1]);
106
- if (e.length === 4) return new E(e);
107
- if (e.length === 8) return new D(e);
108
- throw SyntaxError(`float'...' requires 4, 8, or 16 hex digits (2, 4, or 8 bytes); got ${e.length} bytes`);
109
- }
110
- function k(e) {
111
- let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023, i;
112
- if (n === 31) i = t << 31 | 2139095040 | r << 13;
113
- else if (n === 0 && r === 0) i = t << 31;
114
- else if (n === 0) {
115
- let e = r, n = 0;
116
- for (; !(e & 512);) e <<= 1, n++;
117
- i = t << 31 | 112 - n << 23 | (e & 511) << 14;
118
- } else i = t << 31 | n + 112 << 23 | r << 13;
119
- let a = /* @__PURE__ */ new Uint8Array(4);
120
- return new DataView(a.buffer).setUint32(0, i >>> 0, !1), a;
121
- }
122
- function A(e) {
123
- let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023, i = /* @__PURE__ */ new Uint8Array(8), a = new DataView(i.buffer);
124
- if (n === 31) a.setUint32(0, (t << 31 | 2146435072 | r << 10) >>> 0, !1), a.setUint32(4, 0, !1);
125
- else if (n === 0 && r === 0) a.setUint32(0, t << 31 >>> 0, !1), a.setUint32(4, 0, !1);
126
- else if (n === 0) {
127
- let e = r, n = 0;
128
- for (; !(e & 512);) e <<= 1, n++;
129
- a.setUint32(0, (t << 31 | 1008 - n << 20 | (e & 511) << 11) >>> 0, !1), a.setUint32(4, 0, !1);
130
- } else a.setUint32(0, (t << 31 | n + 1008 << 20 | r << 10) >>> 0, !1), a.setUint32(4, 0, !1);
131
- return i;
132
- }
133
- function j(e) {
134
- let t = new DataView(e.buffer, e.byteOffset).getUint32(0, !1), n = t >>> 31 & 1, r = t >>> 23 & 255, i = t & 8388607, a = /* @__PURE__ */ new Uint8Array(8), o = new DataView(a.buffer);
135
- if (r === 255) o.setUint32(0, (n << 31 | 2146435072 | i >>> 3) >>> 0, !1), o.setUint32(4, (i & 7) << 29, !1);
136
- else if (r === 0 && i === 0) o.setUint32(0, n << 31 >>> 0, !1), o.setUint32(4, 0, !1);
137
- else {
138
- let t = new DataView(e.buffer, e.byteOffset).getFloat32(0, !1);
139
- o.setFloat64(0, t, !1);
140
- }
141
- return a;
142
- }
143
- function M(e, t, r) {
144
- let i = e.length === 2 ? 1 : e.length === 4 ? 2 : 3;
145
- if (i === 1) {
146
- let n = e[0] << 8 | e[1];
147
- if (t === 2) return new E(k(n));
148
- if (t === 3) return new D(A(n));
149
- }
150
- if (i === 2) {
151
- if (t === 3) return new D(j(e));
152
- if (t === 1) {
153
- let t = new DataView(e.buffer, e.byteOffset).getFloat32(0, !1), i = n(t);
154
- return !Object.is(o(i), t) && !isNaN(t) && r("float'...' value cannot be exactly represented as float16 (_1)"), new T(i);
155
- }
156
- }
157
- if (i === 3) {
158
- let i = new DataView(e.buffer, e.byteOffset).getFloat64(0, !1);
159
- if (t === 1) {
160
- let e = n(i);
161
- return !Object.is(o(e), i) && !isNaN(i) && r("float'...' value cannot be exactly represented as float16 (_1)"), new T(e);
162
- }
163
- if (t === 2) {
164
- let e = Math.fround(i);
165
- !Object.is(e, i) && !isNaN(i) && r("float'...' value cannot be exactly represented as float32 (_2)");
166
- let t = /* @__PURE__ */ new Uint8Array(4);
167
- return new DataView(t.buffer).setFloat32(0, e, !1), new E(t);
168
- }
169
- }
170
- return O(e);
171
- }
172
- var N = {
173
- appStringPrefixes: ["float"],
174
- parseAppString(t, n, r, i) {
175
- let a = v(n);
176
- if (!/^[0-9a-fA-F]*$/.test(a)) throw SyntaxError("float'...' contains non-hex characters");
177
- if (a.length % 2 != 0) throw SyntaxError(`float'...' hex content has odd length (${a.length} digits)`);
178
- let o = e(a), s = i?.encodingWidth;
179
- if (s === void 0) return O(o);
180
- if (s !== 1 && s !== 2 && s !== 3) {
181
- let e = `float'...' encoding indicator _${s} is not valid; use _1, _2, or _3`;
182
- if (r) return r(e), O(o);
183
- throw SyntaxError(e);
184
- }
185
- return s === (o.length === 2 ? 1 : o.length === 4 ? 2 : 3) ? O(o) : M(o, s, r ?? ((e) => {
186
- throw SyntaxError(e);
187
- }));
188
- },
189
- parseAppSequence(e, t, n) {
190
- if (t.length === 0) throw SyntaxError("float<<...>> requires exactly one byte-string item");
191
- if (t.length > 1) {
192
- let e = `float<<...>> expects 1 item; got ${t.length} — using first`;
193
- if (n) n(e);
194
- else throw SyntaxError(e);
195
- }
196
- if (!(t[0] instanceof l)) throw SyntaxError("float<<...>> item must be a byte string");
197
- return O(t[0].value);
36
+ return new a(C(o(t), x, n), { ednEncoding: "base32hex" });
198
37
  }
199
38
  };
200
39
  //#endregion
201
40
  //#region src/extensions/same.ts
202
- function P(e, t) {
41
+ function E(e, t) {
203
42
  if (e.length !== t.length) return !1;
204
43
  for (let n = 0; n < e.length; n++) if (e[n] !== t[n]) return !1;
205
44
  return !0;
206
45
  }
207
- var F = {
46
+ var D = {
208
47
  appStringPrefixes: ["same"],
209
48
  preserveAppSeqSource: !0,
210
49
  parseAppSequence(e, t, n) {
211
50
  if (t.length === 0) throw SyntaxError("same<<...>> requires at least one item");
212
51
  let r = t[0], i = r.toCBOR();
213
- for (let e = 1; e < t.length; e++) if (!P(i, t[e].toCBOR())) {
52
+ for (let e = 1; e < t.length; e++) if (!E(i, t[e].toCBOR())) {
214
53
  let t = `same<<...>>: item ${e} produces different CBOR bytes than item 0`;
215
54
  if (n) n(t);
216
55
  else throw SyntaxError(t);
217
56
  }
218
57
  return r;
219
58
  }
220
- }, I = class e {
221
- static OMIT = s;
222
- static TAG = i;
223
- static Tag = a;
224
- static Simple = _;
225
- static MapEntries = h;
59
+ }, O = class r {
60
+ static OMIT = d;
61
+ static TAG = t;
62
+ static Tag = n;
63
+ static Simple = i;
64
+ static MapEntries = v;
226
65
  static dt_as_Date = c;
227
66
  #e;
228
67
  constructor(e) {
@@ -234,110 +73,110 @@ var F = {
234
73
  ...e ?? {}
235
74
  };
236
75
  }
237
- fromCBOR(t, n) {
238
- let r = e.fromCBOR(t, this.#t(n));
239
- return r._defaults = this.#e, r;
76
+ fromCBOR(e, t) {
77
+ let n = r.fromCBOR(e, this.#t(t));
78
+ return n._defaults = this.#e, n;
240
79
  }
241
- fromCDN(t, n) {
242
- let r = e.fromCDN(t, this.#t(n));
243
- return r._defaults = this.#e, r;
80
+ fromCDN(e, t) {
81
+ let n = r.fromCDN(e, this.#t(t));
82
+ return n._defaults = this.#e, n;
244
83
  }
245
84
  fromEDN(e, t) {
246
85
  return this.fromCDN(e, t);
247
86
  }
248
- fromJS(t, n) {
249
- let r = e.fromJS(t, this.#t(n));
250
- return r._defaults = this.#e, r;
87
+ fromJS(e, t) {
88
+ let n = r.fromJS(e, this.#t(t));
89
+ return n._defaults = this.#e, n;
251
90
  }
252
- fromHexDump(t, n) {
253
- let r = e.fromHexDump(t, this.#t(n));
254
- return r._defaults = this.#e, r;
91
+ fromHexDump(e, t) {
92
+ let n = r.fromHexDump(e, this.#t(t));
93
+ return n._defaults = this.#e, n;
255
94
  }
256
- *fromCBORSeq(t, n) {
257
- for (let r of e.fromCBORSeq(t, this.#t(n))) r._defaults = this.#e, yield r;
95
+ *fromCBORSeq(e, t) {
96
+ for (let n of r.fromCBORSeq(e, this.#t(t))) n._defaults = this.#e, yield n;
258
97
  }
259
- *fromCDNSeq(t, n) {
260
- for (let r of e.fromCDNSeq(t, this.#t(n))) r._defaults = this.#e, yield r;
98
+ *fromCDNSeq(e, t) {
99
+ for (let n of r.fromCDNSeq(e, this.#t(t))) n._defaults = this.#e, yield n;
261
100
  }
262
- *fromHexDumpSeq(t, n) {
263
- for (let r of e.fromHexDumpSeq(t, this.#t(n))) r._defaults = this.#e, yield r;
101
+ *fromHexDumpSeq(e, t) {
102
+ for (let n of r.fromHexDumpSeq(e, this.#t(t))) n._defaults = this.#e, yield n;
264
103
  }
265
- decode(t, n) {
266
- return e.decode(t, this.#t(n));
104
+ decode(e, t) {
105
+ return r.decode(e, this.#t(t));
267
106
  }
268
- *decodeSeq(t, n) {
269
- yield* e.decodeSeq(t, this.#t(n));
107
+ *decodeSeq(e, t) {
108
+ yield* r.decodeSeq(e, this.#t(t));
270
109
  }
271
- *parseSeq(t, n) {
272
- yield* e.parseSeq(t, this.#t(n));
110
+ *parseSeq(e, t) {
111
+ yield* r.parseSeq(e, this.#t(t));
273
112
  }
274
- encode(t, n) {
275
- return e.encode(t, this.#t(n));
113
+ encode(e, t) {
114
+ return r.encode(e, this.#t(t));
276
115
  }
277
- compile(t, n) {
278
- return e.compile(t, this.#t(n));
116
+ compile(e, t) {
117
+ return r.compile(e, this.#t(t));
279
118
  }
280
- decompile(t, n) {
281
- return e.decompile(t, this.#t(n));
119
+ decompile(e, t) {
120
+ return r.decompile(e, this.#t(t));
282
121
  }
283
- toHex(t, n) {
284
- return e.toHex(t, this.#t(n));
122
+ toHex(e, t) {
123
+ return r.toHex(e, this.#t(t));
285
124
  }
286
- fromHex(t, n) {
287
- return e.fromHex(t, this.#t(n));
125
+ fromHex(e, t) {
126
+ return r.fromHex(e, this.#t(t));
288
127
  }
289
128
  cborToCborEdn(e, t) {
290
129
  return this.cborToCdn(e, t);
291
130
  }
292
- cborToCdn(t, n) {
293
- let r = this.#t(n), i = e.fromCBOR(t, r);
294
- return i._defaults = this.#e, i.toCDN(r);
131
+ cborToCdn(e, t) {
132
+ let n = this.#t(t), i = r.fromCBOR(e, n);
133
+ return i._defaults = this.#e, i.toCDN(n);
295
134
  }
296
135
  cborEdnToCbor(e, t) {
297
136
  return this.cdnToCbor(e, t);
298
137
  }
299
- cdnToCbor(t, n) {
300
- let r = this.#t(n);
301
- return e.fromCDN(t, r).toCBOR(r);
138
+ cdnToCbor(e, t) {
139
+ let n = this.#t(t);
140
+ return r.fromCDN(e, n).toCBOR(n);
302
141
  }
303
- parse(t, n) {
304
- if (typeof n == "function") {
305
- let r = this.#t({ reviver: n });
306
- return e.fromCDN(t, r).toJS(r);
142
+ parse(e, t) {
143
+ if (typeof t == "function") {
144
+ let n = this.#t({ reviver: t });
145
+ return r.fromCDN(e, n).toJS(n);
307
146
  }
308
- let r = this.#t(n);
309
- return e.fromCDN(t, r).toJS(r);
147
+ let n = this.#t(t);
148
+ return r.fromCDN(e, n).toJS(n);
310
149
  }
311
- stringify(t, n, r) {
312
- if (typeof n == "function" || Array.isArray(n) || n === null || n === void 0 && r !== void 0) {
150
+ stringify(e, t, n) {
151
+ if (typeof t == "function" || Array.isArray(t) || t === null || t === void 0 && n !== void 0) {
313
152
  let i = { ...this.#e };
314
- return n === null ? i.replacer = void 0 : (typeof n == "function" || Array.isArray(n)) && (i.replacer = n), r !== void 0 && (i.indent = U(r)), e.stringify(t, i);
153
+ return t === null ? i.replacer = void 0 : (typeof t == "function" || Array.isArray(t)) && (i.replacer = t), n !== void 0 && (i.indent = F(n)), r.stringify(e, i);
315
154
  }
316
- return e.stringify(t, this.#t(n ?? void 0));
155
+ return r.stringify(e, this.#t(t ?? void 0));
317
156
  }
318
- format(t, n) {
319
- return e.format(t, this.#t(n));
157
+ format(e, t) {
158
+ return r.format(e, this.#t(t));
320
159
  }
321
160
  static fromCBOR(e, t) {
322
- return u(e, t);
161
+ return y(e, t);
323
162
  }
324
163
  static fromCDN(e, t) {
325
- return m(e, t);
164
+ return h(e, t);
326
165
  }
327
- static fromEDN(t, n) {
328
- return e.fromCDN(t, n);
166
+ static fromEDN(e, t) {
167
+ return r.fromCDN(e, t);
329
168
  }
330
- static *fromHexDumpSeq(t, n) {
331
- let r = [], i = L(t).trim().split(/\s+/).filter(Boolean);
332
- for (let e of i) if (/^[0-9A-Fa-f]{2}$/.test(e)) r.push(parseInt(e, 16));
333
- else if (/^[0-9A-Fa-f]+$/.test(e) && e.length % 2 == 0) for (let t = 0; t < e.length; t += 2) r.push(parseInt(e.slice(t, t + 2), 16));
169
+ static *fromHexDumpSeq(e, t) {
170
+ let n = [], i = k(e).trim().split(/\s+/).filter(Boolean);
171
+ for (let e of i) if (/^[0-9A-Fa-f]{2}$/.test(e)) n.push(parseInt(e, 16));
172
+ else if (/^[0-9A-Fa-f]+$/.test(e) && e.length % 2 == 0) for (let t = 0; t < e.length; t += 2) n.push(parseInt(e.slice(t, t + 2), 16));
334
173
  else throw SyntaxError(`Invalid hex token in dump: ${JSON.stringify(e)}`);
335
- yield* e.fromCBORSeq(new Uint8Array(r), n);
174
+ yield* r.fromCBORSeq(new Uint8Array(n), t);
336
175
  }
337
176
  static *fromCBORSeq(e, t) {
338
177
  let n = e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer ? new Uint8Array(e) : new Uint8Array(e.buffer, e.byteOffset, e.byteLength), r = 0;
339
178
  for (; r < n.byteLength;) {
340
- let e = u(n, {
179
+ let e = y(n, {
341
180
  ...t,
342
181
  offset: r,
343
182
  allowTrailing: !0
@@ -345,168 +184,168 @@ var F = {
345
184
  yield e, r = e.end;
346
185
  }
347
186
  }
348
- static *fromCDNSeq(e, n) {
187
+ static *fromCDNSeq(t, n) {
349
188
  let r = !!n?.preserveComments, i = 0, a = !0;
350
189
  for (;;) {
351
- let { offset: o, hadSeparator: s, commaOffset: c } = H(e, i, n, r ? a ? "all" : "after-newline" : "none");
190
+ let { offset: o, hadSeparator: s, commaOffset: c } = P(t, i, n, r ? a ? "all" : "after-newline" : "none");
352
191
  if (a && c >= 0) {
353
192
  let e = "leading comma in CDN sequence";
354
193
  if (n?.strict !== !1) throw SyntaxError(e);
355
- B(e, c, n);
194
+ M(e, c, n);
356
195
  }
357
- if (o >= e.length || r && V(e, o) && H(e, o, n).offset >= e.length) break;
196
+ if (o >= t.length || r && N(t, o) && P(t, o, n).offset >= t.length) break;
358
197
  if (!a && !s) {
359
198
  let e = "CDN sequence items must be separated by whitespace, comma, or comment";
360
199
  if (n?.strict !== !1) throw SyntaxError(e);
361
- B(e, o, n);
200
+ M(e, o, n);
362
201
  }
363
202
  i = o;
364
203
  let l;
365
204
  try {
366
- l = m(e, {
205
+ l = h(t, {
367
206
  ...n,
368
207
  offset: i,
369
208
  allowTrailing: !0,
370
209
  _skipRS: !0
371
210
  });
372
- } catch (e) {
373
- if (n?.strict !== !1) throw e;
374
- B(e instanceof Error ? e.message : String(e), i, n, !0, e instanceof t ? e : void 0);
211
+ } catch (t) {
212
+ if (n?.strict !== !1) throw t;
213
+ M(t instanceof Error ? t.message : String(t), i, n, !0, t instanceof e ? t : void 0);
375
214
  break;
376
215
  }
377
216
  yield l, i = l.end, a = !1;
378
217
  }
379
218
  }
380
219
  static fromJS(e, t) {
381
- return p(e, t);
220
+ return g(e, t);
382
221
  }
383
222
  static fromHexDump(e, t) {
384
- let n = [], r = L(e).trim().split(/\s+/).filter(Boolean);
223
+ let n = [], r = k(e).trim().split(/\s+/).filter(Boolean);
385
224
  for (let e of r) if (/^[0-9A-Fa-f]{2}$/.test(e)) n.push(parseInt(e, 16));
386
225
  else if (/^[0-9A-Fa-f]+$/.test(e) && e.length % 2 == 0) for (let t = 0; t < e.length; t += 2) n.push(parseInt(e.slice(t, t + 2), 16));
387
226
  else throw SyntaxError(`Invalid hex token in dump: ${JSON.stringify(e)}`);
388
- return u(new Uint8Array(n), t);
227
+ return y(new Uint8Array(n), t);
389
228
  }
390
- static decode(t, n) {
391
- return e.fromCBOR(t, n).toJS(n);
229
+ static decode(e, t) {
230
+ return r.fromCBOR(e, t).toJS(t);
392
231
  }
393
- static *decodeSeq(t, n) {
394
- for (let r of e.fromCBORSeq(t, n)) yield r.toJS(n);
232
+ static *decodeSeq(e, t) {
233
+ for (let n of r.fromCBORSeq(e, t)) yield n.toJS(t);
395
234
  }
396
- static *parseSeq(t, n) {
397
- for (let r of e.fromCDNSeq(t, n)) yield r.toJS(n);
235
+ static *parseSeq(e, t) {
236
+ for (let n of r.fromCDNSeq(e, t)) yield n.toJS(t);
398
237
  }
399
- static encode(t, n) {
400
- return e.fromJS(t, n).toCBOR(n);
238
+ static encode(e, t) {
239
+ return r.fromJS(e, t).toCBOR(t);
401
240
  }
402
- static compile(t, n) {
403
- let r = [...e.fromCDNSeq(t, n)].map((e) => e.toCBOR(n)), i = r.reduce((e, t) => e + t.length, 0), a = new Uint8Array(i), o = 0;
404
- for (let e of r) a.set(e, o), o += e.length;
241
+ static compile(e, t) {
242
+ let n = [...r.fromCDNSeq(e, t)].map((e) => e.toCBOR(t)), i = n.reduce((e, t) => e + t.length, 0), a = new Uint8Array(i), o = 0;
243
+ for (let e of n) a.set(e, o), o += e.length;
405
244
  return a;
406
245
  }
407
- static decompile(t, n) {
408
- return [...e.fromCBORSeq(t, n)].map((e) => e.toCDN(n)).join("\n");
246
+ static decompile(e, t) {
247
+ return [...r.fromCBORSeq(e, t)].map((e) => e.toCDN(t)).join("\n");
409
248
  }
410
- static toHex(t, n) {
411
- return [...e.fromCBORSeq(t, n)].map((e) => e.toHexDump(n)).join("\n");
249
+ static toHex(e, t) {
250
+ return [...r.fromCBORSeq(e, t)].map((e) => e.toHexDump(t)).join("\n");
412
251
  }
413
- static fromHex(t, n) {
414
- let r = [...e.fromHexDumpSeq(t, n)].map((e) => e.toCBOR(n)), i = r.reduce((e, t) => e + t.length, 0), a = new Uint8Array(i), o = 0;
415
- for (let e of r) a.set(e, o), o += e.length;
252
+ static fromHex(e, t) {
253
+ let n = [...r.fromHexDumpSeq(e, t)].map((e) => e.toCBOR(t)), i = n.reduce((e, t) => e + t.length, 0), a = new Uint8Array(i), o = 0;
254
+ for (let e of n) a.set(e, o), o += e.length;
416
255
  return a;
417
256
  }
418
- static cborToCdn(t, n) {
419
- return e.fromCBOR(t, n).toCDN(n);
257
+ static cborToCdn(e, t) {
258
+ return r.fromCBOR(e, t).toCDN(t);
420
259
  }
421
- static cborToCborEdn(t, n) {
422
- return e.fromCBOR(t, n).toCDN(n);
260
+ static cborToCborEdn(e, t) {
261
+ return r.fromCBOR(e, t).toCDN(t);
423
262
  }
424
- static cdnToCbor(t, n) {
425
- return e.fromCDN(t, n).toCBOR(n);
263
+ static cdnToCbor(e, t) {
264
+ return r.fromCDN(e, t).toCBOR(t);
426
265
  }
427
- static cborEdnToCbor(t, n) {
428
- return e.fromCDN(t, n).toCBOR(n);
266
+ static cborEdnToCbor(e, t) {
267
+ return r.fromCDN(e, t).toCBOR(t);
429
268
  }
430
- static parse(t, n) {
431
- return typeof n == "function" ? e.fromCDN(t).toJS({ reviver: n }) : e.fromCDN(t, n).toJS(n);
269
+ static parse(e, t) {
270
+ return typeof t == "function" ? r.fromCDN(e).toJS({ reviver: t }) : r.fromCDN(e, t).toJS(t);
432
271
  }
433
272
  static stringify(e, t, n) {
434
273
  if (typeof t == "function" || Array.isArray(t) || t === null || t === void 0 && n !== void 0) {
435
- let r = typeof t == "function" || Array.isArray(t) ? t : void 0, i = U(n);
274
+ let r = typeof t == "function" || Array.isArray(t) ? t : void 0, i = F(n);
436
275
  if (r) {
437
- let t = f(e, r);
438
- return t === void 0 || t === s ? void 0 : p(t).toCDN(i === void 0 ? void 0 : { indent: i });
276
+ let t = p(e, r);
277
+ return t === void 0 || t === d ? void 0 : g(t).toCDN(i === void 0 ? void 0 : { indent: i });
439
278
  }
440
- return p(e).toCDN(i === void 0 ? void 0 : { indent: i });
279
+ return g(e).toCDN(i === void 0 ? void 0 : { indent: i });
441
280
  }
442
281
  let r = t;
443
282
  if (r?.replacer) {
444
- let t = f(e, r.replacer, r.extensions, r.undefinedOmits);
445
- if (t === void 0 || t === s) return;
283
+ let t = p(e, r.replacer, r.extensions, r.undefinedOmits);
284
+ if (t === void 0 || t === d) return;
446
285
  let { replacer: n, ...i } = r;
447
- return p(t, Object.keys(i).length > 0 ? i : void 0).toCDN(r);
286
+ return g(t, Object.keys(i).length > 0 ? i : void 0).toCDN(r);
448
287
  }
449
- return p(e, r).toCDN(r);
288
+ return g(e, r).toCDN(r);
450
289
  }
451
- static format(t, n) {
452
- return e.fromCDN(t, n).toCDN(n);
290
+ static format(e, t) {
291
+ return r.fromCDN(e, t).toCDN(t);
453
292
  }
454
293
  };
455
- function L(e) {
294
+ function k(e) {
456
295
  let t = "", n = 0;
457
296
  for (; n < e.length;) {
458
297
  let r = e[n], i = e[n + 1] ?? "";
459
298
  if (r === "-" && i === "-") {
460
- n = R(e, n + 2), t += " ";
299
+ n = A(e, n + 2), t += " ";
461
300
  continue;
462
301
  }
463
302
  if (r === "—") {
464
- n = R(e, n + 1), t += " ";
303
+ n = A(e, n + 1), t += " ";
465
304
  continue;
466
305
  }
467
306
  if (r === "#") {
468
- n = R(e, n + 1), t += " ";
307
+ n = A(e, n + 1), t += " ";
469
308
  continue;
470
309
  }
471
310
  if (r === "/" && i === "/") {
472
- n = R(e, n + 2), t += " ";
311
+ n = A(e, n + 2), t += " ";
473
312
  continue;
474
313
  }
475
314
  if (r === "/" && i === "*") {
476
315
  let r = e.indexOf("*/", n + 2);
477
316
  if (r < 0) throw SyntaxError("Unterminated comment in hex dump");
478
- t += z(e.slice(n, r + 2)), n = r + 2;
317
+ t += j(e.slice(n, r + 2)), n = r + 2;
479
318
  continue;
480
319
  }
481
320
  if (r === "/") {
482
321
  let r = e.indexOf("/", n + 1);
483
322
  if (r < 0) throw SyntaxError("Unterminated comment in hex dump");
484
- t += z(e.slice(n, r + 1)), n = r + 1;
323
+ t += j(e.slice(n, r + 1)), n = r + 1;
485
324
  continue;
486
325
  }
487
326
  t += r, n++;
488
327
  }
489
328
  return t;
490
329
  }
491
- function R(e, t) {
330
+ function A(e, t) {
492
331
  let n = e.indexOf("\n", t);
493
332
  return n < 0 ? e.length : n;
494
333
  }
495
- function z(e) {
334
+ function j(e) {
496
335
  return e.replace(/[^\r\n]/g, " ");
497
336
  }
498
- function B(e, t, n, r, i) {
337
+ function M(e, t, n, r, i) {
499
338
  let a = i?.offset ?? t, o = {
500
339
  message: e,
501
340
  offset: a
502
341
  };
503
342
  r && (o.fatal = !0), i?.offset !== void 0 && (o.line = i.line, o.column = i.column, o.endOffset = i.endOffset), n?.onWarning ? n.onWarning(o) : n?.silent || console.warn(`CDN sequence warning at offset ${a}: ${e}`);
504
343
  }
505
- function V(e, t) {
344
+ function N(e, t) {
506
345
  let n = e[t];
507
346
  return n === "#" || n === "/";
508
347
  }
509
- function H(e, t, n, r = "none") {
348
+ function P(e, t, n, r = "none") {
510
349
  let i = t, a = !1, o = !1, s = !1, c = -1, l = () => r === "all" || r === "after-newline" && s;
511
350
  for (; i < e.length;) {
512
351
  let t = e[i];
@@ -536,7 +375,7 @@ function H(e, t, n, r = "none") {
536
375
  if (t < 0) {
537
376
  let t = "unterminated /* comment in CDN sequence";
538
377
  if (n?.strict !== !1) throw SyntaxError(t);
539
- B(t, i, n, !0), i = e.length;
378
+ M(t, i, n, !0), i = e.length;
540
379
  } else e.slice(i, t).includes("\n") && (s = !0), i = t + 2;
541
380
  continue;
542
381
  }
@@ -546,7 +385,7 @@ function H(e, t, n, r = "none") {
546
385
  if (t < 0) {
547
386
  let t = "unterminated / comment in CDN sequence";
548
387
  if (n?.strict !== !1) throw SyntaxError(t);
549
- B(t, i, n, !0), i = e.length;
388
+ M(t, i, n, !0), i = e.length;
550
389
  } else e.slice(i, t).includes("\n") && (s = !0), i = t + 1;
551
390
  continue;
552
391
  }
@@ -562,7 +401,7 @@ function H(e, t, n, r = "none") {
562
401
  commaOffset: c
563
402
  };
564
403
  }
565
- function U(e) {
404
+ function F(e) {
566
405
  if (typeof e == "number") {
567
406
  let t = Math.floor(Math.min(10, Math.max(0, e)));
568
407
  return t === 0 ? void 0 : t;
@@ -570,6 +409,6 @@ function U(e) {
570
409
  if (typeof e == "string") return e.slice(0, 10) || void 0;
571
410
  }
572
411
  //#endregion
573
- export { I as CBOR, I as default, s as CBOR_OMIT, i as CBOR_TAG, t as CdnSyntaxError, h as MapEntries, r as Null, _ as Simple, a as Tag, d as Undefined, C as b32, c as dt_as_Date, N as float, w as h32, F as same };
412
+ export { O as CBOR, O as default, d as CBOR_OMIT, t as CBOR_TAG, e as CdnSyntaxError, v as MapEntries, u as Null, i as Simple, n as Tag, r as Undefined, s as b1, w as b32, c as dt_as_Date, l as float, T as h32, m as ilbs, _ as ilts, D as same, f as t1 };
574
413
 
575
414
  //# sourceMappingURL=index.js.map