@ahmedrowaihi/8n 0.2.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.
@@ -0,0 +1,672 @@
1
+ import { i as N } from "./index.mjs";
2
+
3
+ //#region ../../node_modules/.pnpm/confbox@0.1.8/node_modules/confbox/dist/toml.mjs
4
+ var F = Object.defineProperty;
5
+ var V = (e, n, t) => n in e ? F(e, n, {
6
+ enumerable: !0,
7
+ configurable: !0,
8
+ writable: !0,
9
+ value: t
10
+ }) : e[n] = t;
11
+ var O = (e, n, t) => (V(e, typeof n != "symbol" ? n + "" : n, t), t), L = (e, n, t) => {
12
+ if (!n.has(e)) throw TypeError("Cannot " + t);
13
+ };
14
+ var d = (e, n, t) => (L(e, n, "read from private field"), t ? t.call(e) : n.get(e)), T = (e, n, t) => {
15
+ if (n.has(e)) throw TypeError("Cannot add the same private member more than once");
16
+ n instanceof WeakSet ? n.add(e) : n.set(e, t);
17
+ }, w = (e, n, t, i) => (L(e, n, "write to private field"), i ? i.call(e, t) : n.set(e, t), t);
18
+ var h, m, s;
19
+ /*!
20
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
21
+ * SPDX-License-Identifier: BSD-3-Clause
22
+ *
23
+ * Redistribution and use in source and binary forms, with or without
24
+ * modification, are permitted provided that the following conditions are met:
25
+ *
26
+ * 1. Redistributions of source code must retain the above copyright notice, this
27
+ * list of conditions and the following disclaimer.
28
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
29
+ * this list of conditions and the following disclaimer in the
30
+ * documentation and/or other materials provided with the distribution.
31
+ * 3. Neither the name of the copyright holder nor the names of its contributors
32
+ * may be used to endorse or promote products derived from this software without
33
+ * specific prior written permission.
34
+ *
35
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
36
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
37
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
39
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
40
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
41
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
42
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
43
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
44
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45
+ */ function U(e, n) {
46
+ let t = e.slice(0, n).split(/\r\n|\n|\r/g);
47
+ return [t.length, t.pop().length + 1];
48
+ }
49
+ function X(e, n, t) {
50
+ let i = e.split(/\r\n|\n|\r/g), l = "", r = (Math.log10(n + 1) | 0) + 1;
51
+ for (let f = n - 1; f <= n + 1; f++) {
52
+ let o = i[f - 1];
53
+ o && (l += f.toString().padEnd(r, " "), l += ": ", l += o, l += `
54
+ `, f === n && (l += " ".repeat(r + t + 2), l += `^
55
+ `));
56
+ }
57
+ return l;
58
+ }
59
+ var u = class extends Error {
60
+ constructor(t, i) {
61
+ const [l, r] = U(i.toml, i.ptr), f = X(i.toml, l, r);
62
+ super(`Invalid TOML document: ${t}
63
+
64
+ ${f}`, i);
65
+ O(this, "line");
66
+ O(this, "column");
67
+ O(this, "codeblock");
68
+ this.line = l, this.column = r, this.codeblock = f;
69
+ }
70
+ };
71
+ /*!
72
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
73
+ * SPDX-License-Identifier: BSD-3-Clause
74
+ *
75
+ * Redistribution and use in source and binary forms, with or without
76
+ * modification, are permitted provided that the following conditions are met:
77
+ *
78
+ * 1. Redistributions of source code must retain the above copyright notice, this
79
+ * list of conditions and the following disclaimer.
80
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
81
+ * this list of conditions and the following disclaimer in the
82
+ * documentation and/or other materials provided with the distribution.
83
+ * 3. Neither the name of the copyright holder nor the names of its contributors
84
+ * may be used to endorse or promote products derived from this software without
85
+ * specific prior written permission.
86
+ *
87
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
88
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
89
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
90
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
91
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
92
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
93
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
94
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
95
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
96
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
97
+ */ function x(e, n = 0, t = e.length) {
98
+ let i = e.indexOf(`
99
+ `, n);
100
+ return e[i - 1] === "\r" && i--, i <= t ? i : -1;
101
+ }
102
+ function A(e, n) {
103
+ for (let t = n; t < e.length; t++) {
104
+ let i = e[t];
105
+ if (i === `
106
+ `) return t;
107
+ if (i === "\r" && e[t + 1] === `
108
+ `) return t + 1;
109
+ if (i < " " && i !== " " || i === "") throw new u("control characters are not allowed in comments", {
110
+ toml: e,
111
+ ptr: n
112
+ });
113
+ }
114
+ return e.length;
115
+ }
116
+ function g(e, n, t, i) {
117
+ let l;
118
+ for (; (l = e[n]) === " " || l === " " || !t && (l === `
119
+ ` || l === "\r" && e[n + 1] === `
120
+ `);) n++;
121
+ return i || l !== "#" ? n : g(e, A(e, n), t);
122
+ }
123
+ function P(e, n, t, i, l = !1) {
124
+ if (!i) return n = x(e, n), n < 0 ? e.length : n;
125
+ for (let r = n; r < e.length; r++) {
126
+ let f = e[r];
127
+ if (f === "#") r = x(e, r);
128
+ else {
129
+ if (f === t) return r + 1;
130
+ if (f === i) return r;
131
+ if (l && (f === `
132
+ ` || f === "\r" && e[r + 1] === `
133
+ `)) return r;
134
+ }
135
+ }
136
+ throw new u("cannot find end of structure", {
137
+ toml: e,
138
+ ptr: n
139
+ });
140
+ }
141
+ function v(e, n) {
142
+ let t = e[n], i = t === e[n + 1] && e[n + 1] === e[n + 2] ? e.slice(n, n + 3) : t;
143
+ n += i.length - 1;
144
+ do
145
+ n = e.indexOf(i, ++n);
146
+ while (n > -1 && t !== "'" && e[n - 1] === "\\" && e[n - 2] !== "\\");
147
+ return n > -1 && (n += i.length, i.length > 1 && (e[n] === t && n++, e[n] === t && n++)), n;
148
+ }
149
+ /*!
150
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
151
+ * SPDX-License-Identifier: BSD-3-Clause
152
+ *
153
+ * Redistribution and use in source and binary forms, with or without
154
+ * modification, are permitted provided that the following conditions are met:
155
+ *
156
+ * 1. Redistributions of source code must retain the above copyright notice, this
157
+ * list of conditions and the following disclaimer.
158
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
159
+ * this list of conditions and the following disclaimer in the
160
+ * documentation and/or other materials provided with the distribution.
161
+ * 3. Neither the name of the copyright holder nor the names of its contributors
162
+ * may be used to endorse or promote products derived from this software without
163
+ * specific prior written permission.
164
+ *
165
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
166
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
167
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
168
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
169
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
170
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
171
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
172
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
173
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
174
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
175
+ */ let B = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}:\d{2}(?:\.\d+)?)?(Z|[-+]\d{2}:\d{2})?$/i;
176
+ const b = class b extends Date {
177
+ constructor(t) {
178
+ let i = !0, l = !0, r = "Z";
179
+ if (typeof t == "string") {
180
+ let f = t.match(B);
181
+ f ? (f[1] || (i = !1, t = `0000-01-01T${t}`), l = !!f[2], f[2] && +f[2] > 23 ? t = "" : (r = f[3] || null, t = t.toUpperCase(), !r && l && (t += "Z"))) : t = "";
182
+ }
183
+ super(t);
184
+ T(this, h, !1);
185
+ T(this, m, !1);
186
+ T(this, s, null);
187
+ isNaN(this.getTime()) || (w(this, h, i), w(this, m, l), w(this, s, r));
188
+ }
189
+ isDateTime() {
190
+ return d(this, h) && d(this, m);
191
+ }
192
+ isLocal() {
193
+ return !d(this, h) || !d(this, m) || !d(this, s);
194
+ }
195
+ isDate() {
196
+ return d(this, h) && !d(this, m);
197
+ }
198
+ isTime() {
199
+ return d(this, m) && !d(this, h);
200
+ }
201
+ isValid() {
202
+ return d(this, h) || d(this, m);
203
+ }
204
+ toISOString() {
205
+ let t = super.toISOString();
206
+ if (this.isDate()) return t.slice(0, 10);
207
+ if (this.isTime()) return t.slice(11, 23);
208
+ if (d(this, s) === null) return t.slice(0, -1);
209
+ if (d(this, s) === "Z") return t;
210
+ let i = +d(this, s).slice(1, 3) * 60 + +d(this, s).slice(4, 6);
211
+ return i = d(this, s)[0] === "-" ? i : -i, (/* @__PURE__ */ new Date(this.getTime() - i * 6e4)).toISOString().slice(0, -1) + d(this, s);
212
+ }
213
+ static wrapAsOffsetDateTime(t, i = "Z") {
214
+ let l = new b(t);
215
+ return w(l, s, i), l;
216
+ }
217
+ static wrapAsLocalDateTime(t) {
218
+ let i = new b(t);
219
+ return w(i, s, null), i;
220
+ }
221
+ static wrapAsLocalDate(t) {
222
+ let i = new b(t);
223
+ return w(i, m, !1), w(i, s, null), i;
224
+ }
225
+ static wrapAsLocalTime(t) {
226
+ let i = new b(t);
227
+ return w(i, h, !1), w(i, s, null), i;
228
+ }
229
+ };
230
+ h = /* @__PURE__ */ new WeakMap(), m = /* @__PURE__ */ new WeakMap(), s = /* @__PURE__ */ new WeakMap();
231
+ let S = b;
232
+ /*!
233
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
234
+ * SPDX-License-Identifier: BSD-3-Clause
235
+ *
236
+ * Redistribution and use in source and binary forms, with or without
237
+ * modification, are permitted provided that the following conditions are met:
238
+ *
239
+ * 1. Redistributions of source code must retain the above copyright notice, this
240
+ * list of conditions and the following disclaimer.
241
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
242
+ * this list of conditions and the following disclaimer in the
243
+ * documentation and/or other materials provided with the distribution.
244
+ * 3. Neither the name of the copyright holder nor the names of its contributors
245
+ * may be used to endorse or promote products derived from this software without
246
+ * specific prior written permission.
247
+ *
248
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
249
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
250
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
251
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
252
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
253
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
254
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
255
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
256
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
257
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
258
+ */ let Y = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/, j = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/, q = /^[+-]?0[0-9_]/, J = /^[0-9a-f]{4,8}$/i, R = {
259
+ b: "\b",
260
+ t: " ",
261
+ n: `
262
+ `,
263
+ f: "\f",
264
+ r: "\r",
265
+ "\"": "\"",
266
+ "\\": "\\"
267
+ };
268
+ function C(e, n = 0, t = e.length) {
269
+ let i = e[n] === "'", l = e[n++] === e[n] && e[n] === e[n + 1];
270
+ l && (t -= 2, e[n += 2] === "\r" && n++, e[n] === `
271
+ ` && n++);
272
+ let r = 0, f, o = "", a = n;
273
+ for (; n < t - 1;) {
274
+ let c = e[n++];
275
+ if (c === `
276
+ ` || c === "\r" && e[n] === `
277
+ `) {
278
+ if (!l) throw new u("newlines are not allowed in strings", {
279
+ toml: e,
280
+ ptr: n - 1
281
+ });
282
+ } else if (c < " " && c !== " " || c === "") throw new u("control characters are not allowed in strings", {
283
+ toml: e,
284
+ ptr: n - 1
285
+ });
286
+ if (f) {
287
+ if (f = !1, c === "u" || c === "U") {
288
+ let y = e.slice(n, n += c === "u" ? 4 : 8);
289
+ if (!J.test(y)) throw new u("invalid unicode escape", {
290
+ toml: e,
291
+ ptr: r
292
+ });
293
+ try {
294
+ o += String.fromCodePoint(parseInt(y, 16));
295
+ } catch {
296
+ throw new u("invalid unicode escape", {
297
+ toml: e,
298
+ ptr: r
299
+ });
300
+ }
301
+ } else if (l && (c === `
302
+ ` || c === " " || c === " " || c === "\r")) {
303
+ if (n = g(e, n - 1, !0), e[n] !== `
304
+ ` && e[n] !== "\r") throw new u("invalid escape: only line-ending whitespace may be escaped", {
305
+ toml: e,
306
+ ptr: r
307
+ });
308
+ n = g(e, n);
309
+ } else if (c in R) o += R[c];
310
+ else throw new u("unrecognized escape sequence", {
311
+ toml: e,
312
+ ptr: r
313
+ });
314
+ a = n;
315
+ } else !i && c === "\\" && (r = n - 1, f = !0, o += e.slice(a, r));
316
+ }
317
+ return o + e.slice(a, t - 1);
318
+ }
319
+ function H(e, n, t) {
320
+ if (e === "true") return !0;
321
+ if (e === "false") return !1;
322
+ if (e === "-inf") return -Infinity;
323
+ if (e === "inf" || e === "+inf") return Infinity;
324
+ if (e === "nan" || e === "+nan" || e === "-nan") return NaN;
325
+ if (e === "-0") return 0;
326
+ let i;
327
+ if ((i = Y.test(e)) || j.test(e)) {
328
+ if (q.test(e)) throw new u("leading zeroes are not allowed", {
329
+ toml: n,
330
+ ptr: t
331
+ });
332
+ let r = +e.replace(/_/g, "");
333
+ if (isNaN(r)) throw new u("invalid number", {
334
+ toml: n,
335
+ ptr: t
336
+ });
337
+ if (i && !Number.isSafeInteger(r)) throw new u("integer value cannot be represented losslessly", {
338
+ toml: n,
339
+ ptr: t
340
+ });
341
+ return r;
342
+ }
343
+ let l = new S(e);
344
+ if (!l.isValid()) throw new u("invalid value", {
345
+ toml: n,
346
+ ptr: t
347
+ });
348
+ return l;
349
+ }
350
+ /*!
351
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
352
+ * SPDX-License-Identifier: BSD-3-Clause
353
+ *
354
+ * Redistribution and use in source and binary forms, with or without
355
+ * modification, are permitted provided that the following conditions are met:
356
+ *
357
+ * 1. Redistributions of source code must retain the above copyright notice, this
358
+ * list of conditions and the following disclaimer.
359
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
360
+ * this list of conditions and the following disclaimer in the
361
+ * documentation and/or other materials provided with the distribution.
362
+ * 3. Neither the name of the copyright holder nor the names of its contributors
363
+ * may be used to endorse or promote products derived from this software without
364
+ * specific prior written permission.
365
+ *
366
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
367
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
368
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
369
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
370
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
371
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
372
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
373
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
374
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
375
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
376
+ */ function Q(e, n, t, i) {
377
+ let l = e.slice(n, t), r = l.indexOf("#");
378
+ r > -1 && (A(e, r), l = l.slice(0, r));
379
+ let f = l.trimEnd();
380
+ if (!i) {
381
+ let o = l.indexOf(`
382
+ `, f.length);
383
+ if (o > -1) throw new u("newlines are not allowed in inline tables", {
384
+ toml: e,
385
+ ptr: n + o
386
+ });
387
+ }
388
+ return [f, r];
389
+ }
390
+ function I(e, n, t) {
391
+ let i = e[n];
392
+ if (i === "[" || i === "{") {
393
+ let [f, o] = i === "[" ? ne(e, n) : ee(e, n), a = P(e, o, ",", t);
394
+ if (t === "}") {
395
+ let c = x(e, o, a);
396
+ if (c > -1) throw new u("newlines are not allowed in inline tables", {
397
+ toml: e,
398
+ ptr: c
399
+ });
400
+ }
401
+ return [f, a];
402
+ }
403
+ let l;
404
+ if (i === "\"" || i === "'") {
405
+ l = v(e, n);
406
+ let f = C(e, n, l);
407
+ if (t) {
408
+ if (l = g(e, l, t !== "]"), e[l] && e[l] !== "," && e[l] !== t && e[l] !== `
409
+ ` && e[l] !== "\r") throw new u("unexpected character encountered", {
410
+ toml: e,
411
+ ptr: l
412
+ });
413
+ l += +(e[l] === ",");
414
+ }
415
+ return [f, l];
416
+ }
417
+ l = P(e, n, ",", t);
418
+ let r = Q(e, n, l - +(e[l - 1] === ","), t === "]");
419
+ if (!r[0]) throw new u("incomplete key-value declaration: no value specified", {
420
+ toml: e,
421
+ ptr: n
422
+ });
423
+ return t && r[1] > -1 && (l = g(e, n + r[1]), l += +(e[l] === ",")), [H(r[0], e, n), l];
424
+ }
425
+ /*!
426
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
427
+ * SPDX-License-Identifier: BSD-3-Clause
428
+ *
429
+ * Redistribution and use in source and binary forms, with or without
430
+ * modification, are permitted provided that the following conditions are met:
431
+ *
432
+ * 1. Redistributions of source code must retain the above copyright notice, this
433
+ * list of conditions and the following disclaimer.
434
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
435
+ * this list of conditions and the following disclaimer in the
436
+ * documentation and/or other materials provided with the distribution.
437
+ * 3. Neither the name of the copyright holder nor the names of its contributors
438
+ * may be used to endorse or promote products derived from this software without
439
+ * specific prior written permission.
440
+ *
441
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
442
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
443
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
444
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
445
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
446
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
447
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
448
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
449
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
450
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
451
+ */ let W = /^[a-zA-Z0-9-_]+[ \t]*$/;
452
+ function p(e, n, t = "=") {
453
+ let i = n - 1, l = [], r = e.indexOf(t, n);
454
+ if (r < 0) throw new u("incomplete key-value: cannot find end of key", {
455
+ toml: e,
456
+ ptr: n
457
+ });
458
+ do {
459
+ let f = e[n = ++i];
460
+ if (f !== " " && f !== " ") if (f === "\"" || f === "'") {
461
+ if (f === e[n + 1] && f === e[n + 2]) throw new u("multiline strings are not allowed in keys", {
462
+ toml: e,
463
+ ptr: n
464
+ });
465
+ let o = v(e, n);
466
+ if (o < 0) throw new u("unfinished string encountered", {
467
+ toml: e,
468
+ ptr: n
469
+ });
470
+ i = e.indexOf(".", o);
471
+ let a = e.slice(o, i < 0 || i > r ? r : i), c = x(a);
472
+ if (c > -1) throw new u("newlines are not allowed in keys", {
473
+ toml: e,
474
+ ptr: n + i + c
475
+ });
476
+ if (a.trimStart()) throw new u("found extra tokens after the string part", {
477
+ toml: e,
478
+ ptr: o
479
+ });
480
+ if (r < o && (r = e.indexOf(t, o), r < 0)) throw new u("incomplete key-value: cannot find end of key", {
481
+ toml: e,
482
+ ptr: n
483
+ });
484
+ l.push(C(e, n, o));
485
+ } else {
486
+ i = e.indexOf(".", n);
487
+ let o = e.slice(n, i < 0 || i > r ? r : i);
488
+ if (!W.test(o)) throw new u("only letter, numbers, dashes and underscores are allowed in keys", {
489
+ toml: e,
490
+ ptr: n
491
+ });
492
+ l.push(o.trimEnd());
493
+ }
494
+ } while (i + 1 && i < r);
495
+ return [l, g(e, r + 1, !0, !0)];
496
+ }
497
+ function ee(e, n) {
498
+ let t = {}, i = /* @__PURE__ */ new Set(), l, r = 0;
499
+ for (n++; (l = e[n++]) !== "}" && l;) {
500
+ if (l === `
501
+ `) throw new u("newlines are not allowed in inline tables", {
502
+ toml: e,
503
+ ptr: n - 1
504
+ });
505
+ if (l === "#") throw new u("inline tables cannot contain comments", {
506
+ toml: e,
507
+ ptr: n - 1
508
+ });
509
+ if (l === ",") throw new u("expected key-value, found comma", {
510
+ toml: e,
511
+ ptr: n - 1
512
+ });
513
+ if (l !== " " && l !== " ") {
514
+ let f, o = t, a = !1, [c, y] = p(e, n - 1);
515
+ for (let E = 0; E < c.length; E++) {
516
+ if (E && (o = a ? o[f] : o[f] = {}), f = c[E], (a = Object.hasOwn(o, f)) && (typeof o[f] != "object" || i.has(o[f]))) throw new u("trying to redefine an already defined value", {
517
+ toml: e,
518
+ ptr: n
519
+ });
520
+ !a && f === "__proto__" && Object.defineProperty(o, f, {
521
+ enumerable: !0,
522
+ configurable: !0,
523
+ writable: !0
524
+ });
525
+ }
526
+ if (a) throw new u("trying to redefine an already defined value", {
527
+ toml: e,
528
+ ptr: n
529
+ });
530
+ let [k, z] = I(e, y, "}");
531
+ i.add(k), o[f] = k, n = z, r = e[n - 1] === "," ? n - 1 : 0;
532
+ }
533
+ }
534
+ if (r) throw new u("trailing commas are not allowed in inline tables", {
535
+ toml: e,
536
+ ptr: r
537
+ });
538
+ if (!l) throw new u("unfinished table encountered", {
539
+ toml: e,
540
+ ptr: n
541
+ });
542
+ return [t, n];
543
+ }
544
+ function ne(e, n) {
545
+ let t = [], i;
546
+ for (n++; (i = e[n++]) !== "]" && i;) {
547
+ if (i === ",") throw new u("expected value, found comma", {
548
+ toml: e,
549
+ ptr: n - 1
550
+ });
551
+ if (i === "#") n = A(e, n);
552
+ else if (i !== " " && i !== " " && i !== `
553
+ ` && i !== "\r") {
554
+ let l = I(e, n - 1, "]");
555
+ t.push(l[0]), n = l[1];
556
+ }
557
+ }
558
+ if (!i) throw new u("unfinished array encountered", {
559
+ toml: e,
560
+ ptr: n
561
+ });
562
+ return [t, n];
563
+ }
564
+ /*!
565
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
566
+ * SPDX-License-Identifier: BSD-3-Clause
567
+ *
568
+ * Redistribution and use in source and binary forms, with or without
569
+ * modification, are permitted provided that the following conditions are met:
570
+ *
571
+ * 1. Redistributions of source code must retain the above copyright notice, this
572
+ * list of conditions and the following disclaimer.
573
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
574
+ * this list of conditions and the following disclaimer in the
575
+ * documentation and/or other materials provided with the distribution.
576
+ * 3. Neither the name of the copyright holder nor the names of its contributors
577
+ * may be used to endorse or promote products derived from this software without
578
+ * specific prior written permission.
579
+ *
580
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
581
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
582
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
583
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
584
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
585
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
586
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
587
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
588
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
589
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
590
+ */ function M(e, n, t, i) {
591
+ let l = n, r = t, f, o = !1, a;
592
+ for (let c = 0; c < e.length; c++) {
593
+ if (c) {
594
+ if (l = o ? l[f] : l[f] = {}, r = (a = r[f]).c, i === 0 && (a.t === 1 || a.t === 2)) return null;
595
+ if (a.t === 2) {
596
+ let y = l.length - 1;
597
+ l = l[y], r = r[y].c;
598
+ }
599
+ }
600
+ if (f = e[c], (o = Object.hasOwn(l, f)) && r[f]?.t === 0 && r[f]?.d) return null;
601
+ o || (f === "__proto__" && (Object.defineProperty(l, f, {
602
+ enumerable: !0,
603
+ configurable: !0,
604
+ writable: !0
605
+ }), Object.defineProperty(r, f, {
606
+ enumerable: !0,
607
+ configurable: !0,
608
+ writable: !0
609
+ })), r[f] = {
610
+ t: c < e.length - 1 && i === 2 ? 3 : i,
611
+ d: !1,
612
+ i: 0,
613
+ c: {}
614
+ });
615
+ }
616
+ if (a = r[f], a.t !== i && !(i === 1 && a.t === 3) || (i === 2 && (a.d || (a.d = !0, l[f] = []), l[f].push(l = {}), a.c[a.i++] = a = {
617
+ t: 1,
618
+ d: !1,
619
+ i: 0,
620
+ c: {}
621
+ }), a.d)) return null;
622
+ if (a.d = !0, i === 1) l = o ? l[f] : l[f] = {};
623
+ else if (i === 0 && o) return null;
624
+ return [
625
+ f,
626
+ l,
627
+ a.c
628
+ ];
629
+ }
630
+ function te(e) {
631
+ let n = {}, t = {}, i = n, l = t;
632
+ for (let r = g(e, 0); r < e.length;) {
633
+ if (e[r] === "[") {
634
+ let f = e[++r] === "[", o = p(e, r += +f, "]");
635
+ if (f) {
636
+ if (e[o[1] - 1] !== "]") throw new u("expected end of table declaration", {
637
+ toml: e,
638
+ ptr: o[1] - 1
639
+ });
640
+ o[1]++;
641
+ }
642
+ let a = M(o[0], n, t, f ? 2 : 1);
643
+ if (!a) throw new u("trying to redefine an already defined table or value", {
644
+ toml: e,
645
+ ptr: r
646
+ });
647
+ l = a[2], i = a[1], r = o[1];
648
+ } else {
649
+ let f = p(e, r), o = M(f[0], i, l, 0);
650
+ if (!o) throw new u("trying to redefine an already defined table or value", {
651
+ toml: e,
652
+ ptr: r
653
+ });
654
+ let a = I(e, f[1]);
655
+ o[1][o[0]] = a[0], r = a[1];
656
+ }
657
+ if (r = g(e, r, !0), e[r] && e[r] !== `
658
+ ` && e[r] !== "\r") throw new u("each key-value declaration must be followed by an end-of-line", {
659
+ toml: e,
660
+ ptr: r
661
+ });
662
+ r = g(e, r);
663
+ }
664
+ return n;
665
+ }
666
+ function ae(e) {
667
+ const n = te(e);
668
+ return N(e, n, { preserveIndentation: !1 }), n;
669
+ }
670
+
671
+ //#endregion
672
+ export { ae as parseTOML };