document-model 1.0.41 → 1.0.42

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 (110) hide show
  1. package/dist/browser/document-model.cjs +1 -1
  2. package/dist/browser/document-model.js +14 -15
  3. package/dist/browser/document.cjs +1 -1
  4. package/dist/browser/document.js +9 -10
  5. package/dist/browser/index.cjs +1 -1
  6. package/dist/browser/index.js +6 -7
  7. package/dist/browser/internal/{index-BWV1Osza.js → index-CDcO7NCS.js} +3 -4
  8. package/dist/browser/internal/{index-BD_7XeO5.js → index-CfgX2mMt.js} +1 -1
  9. package/dist/browser/internal/{index-BxGRRPwY.js → index-DhzefrNj.js} +1 -1
  10. package/dist/{node/internal/index-LEexvgqj.js → browser/internal/index-EdTViyyq.js} +1 -1
  11. package/dist/browser/internal/object-BkewFVld.js +25 -0
  12. package/dist/browser/internal/object-CrDRbO7a.js +2492 -0
  13. package/dist/node/document-model.cjs +1 -1
  14. package/dist/node/document-model.js +15 -16
  15. package/dist/node/document.cjs +1 -1
  16. package/dist/node/document.js +9 -10
  17. package/dist/node/index.cjs +1 -1
  18. package/dist/node/index.js +7 -8
  19. package/dist/node/internal/{index-Dh0vfIdX.js → index-BWW7KbVk.js} +2 -2
  20. package/dist/node/internal/{index-DeKx7EaE.js → index-Cz8HaIxu.js} +3 -4
  21. package/dist/{browser/internal/index-BNBYVtaF.js → node/internal/index-D_LMFQg7.js} +1 -1
  22. package/dist/node/internal/{index-LD_vrQff.js → index-fctxJxHD.js} +1 -1
  23. package/dist/node/internal/object-BDRv-l-h.js +1390 -0
  24. package/dist/node/internal/object-Br6jYeW0.js +20 -0
  25. package/dist/src/document/actions/creators.d.ts +47 -0
  26. package/dist/src/document/actions/index.d.ts +14 -0
  27. package/dist/src/document/actions/types.d.ts +15 -0
  28. package/dist/src/document/index.d.ts +6 -0
  29. package/dist/src/document/object.d.ts +1140 -0
  30. package/dist/src/document/reducer.d.ts +32 -0
  31. package/dist/src/document/schema/index.d.ts +2 -0
  32. package/dist/src/document/schema/types.d.ts +176 -0
  33. package/dist/src/document/schema/zod.d.ts +113 -0
  34. package/dist/src/document/signal.d.ts +29 -0
  35. package/dist/src/document/types.d.ts +245 -0
  36. package/dist/src/document/utils/base.d.ts +80 -0
  37. package/dist/src/document/utils/browser.d.ts +10 -0
  38. package/dist/src/document/utils/file.d.ts +47 -0
  39. package/dist/src/document/utils/index.d.ts +4 -0
  40. package/dist/src/document/utils/node.d.ts +9 -0
  41. package/dist/src/document/utils/validation.d.ts +2 -0
  42. package/dist/src/document-model/custom/reducers/header.d.ts +2 -0
  43. package/dist/src/document-model/custom/reducers/module.d.ts +2 -0
  44. package/dist/src/document-model/custom/reducers/operation-error.d.ts +2 -0
  45. package/dist/src/document-model/custom/reducers/operation-example.d.ts +2 -0
  46. package/dist/src/document-model/custom/reducers/operation.d.ts +2 -0
  47. package/dist/src/document-model/custom/reducers/state.d.ts +2 -0
  48. package/dist/src/document-model/custom/reducers/versioning.d.ts +7 -0
  49. package/dist/src/document-model/custom/utils.d.ts +7 -0
  50. package/dist/src/document-model/gen/actions.d.ts +15 -0
  51. package/dist/src/document-model/gen/creators.d.ts +7 -0
  52. package/dist/src/document-model/gen/document-model.d.ts +2 -0
  53. package/dist/src/document-model/gen/header/actions.d.ts +9 -0
  54. package/dist/src/document-model/gen/header/creators.d.ts +8 -0
  55. package/dist/src/document-model/gen/header/object.d.ts +12 -0
  56. package/dist/src/document-model/gen/header/operations.d.ts +10 -0
  57. package/dist/src/document-model/gen/index.d.ts +5 -0
  58. package/dist/src/document-model/gen/module/actions.d.ts +8 -0
  59. package/dist/src/document-model/gen/module/creators.d.ts +7 -0
  60. package/dist/src/document-model/gen/module/object.d.ts +11 -0
  61. package/dist/src/document-model/gen/module/operations.d.ts +9 -0
  62. package/dist/src/document-model/gen/object.d.ts +28 -0
  63. package/dist/src/document-model/gen/operation/actions.d.ts +13 -0
  64. package/dist/src/document-model/gen/operation/creators.d.ts +12 -0
  65. package/dist/src/document-model/gen/operation/object.d.ts +16 -0
  66. package/dist/src/document-model/gen/operation/operations.d.ts +14 -0
  67. package/dist/src/document-model/gen/operation-error/actions.d.ts +10 -0
  68. package/dist/src/document-model/gen/operation-error/creators.d.ts +9 -0
  69. package/dist/src/document-model/gen/operation-error/object.d.ts +13 -0
  70. package/dist/src/document-model/gen/operation-error/operations.d.ts +11 -0
  71. package/dist/src/document-model/gen/operation-example/actions.d.ts +7 -0
  72. package/dist/src/document-model/gen/operation-example/creators.d.ts +6 -0
  73. package/dist/src/document-model/gen/operation-example/object.d.ts +10 -0
  74. package/dist/src/document-model/gen/operation-example/operations.d.ts +8 -0
  75. package/dist/src/document-model/gen/reducer.d.ts +5 -0
  76. package/dist/src/document-model/gen/schema/index.d.ts +2 -0
  77. package/dist/src/document-model/gen/schema/types.d.ts +453 -0
  78. package/dist/src/document-model/gen/schema/zod.d.ts +453 -0
  79. package/dist/src/document-model/gen/state/actions.d.ts +9 -0
  80. package/dist/src/document-model/gen/state/creators.d.ts +8 -0
  81. package/dist/src/document-model/gen/state/object.d.ts +12 -0
  82. package/dist/src/document-model/gen/state/operations.d.ts +10 -0
  83. package/dist/src/document-model/gen/types.d.ts +8 -0
  84. package/dist/src/document-model/gen/utils.d.ts +6 -0
  85. package/dist/src/document-model/gen/versioning/actions.d.ts +8 -0
  86. package/dist/src/document-model/gen/versioning/creators.d.ts +7 -0
  87. package/dist/src/document-model/gen/versioning/object.d.ts +11 -0
  88. package/dist/src/document-model/gen/versioning/operations.d.ts +9 -0
  89. package/dist/src/document-model/index.d.ts +80 -0
  90. package/dist/src/index.d.ts +25 -0
  91. package/dist/test/document/event-vs-command.test.d.ts +1 -0
  92. package/dist/test/document/local.test.d.ts +1 -0
  93. package/dist/test/document/object.test.d.ts +1 -0
  94. package/dist/test/document/prune.test.d.ts +1 -0
  95. package/dist/test/document/reducer.test.d.ts +1 -0
  96. package/dist/test/document/skip-operations.test.d.ts +1 -0
  97. package/dist/test/document/undo-redo.test.d.ts +1 -0
  98. package/dist/test/document/utils.test.d.ts +1 -0
  99. package/dist/test/document-model/object.test.d.ts +1 -0
  100. package/dist/test/document-model/skip-operations.test.d.ts +1 -0
  101. package/dist/test/document-model/validation.test.d.ts +1 -0
  102. package/dist/test/document-model/zip.test.d.ts +1 -0
  103. package/dist/test/helpers.d.ts +34 -0
  104. package/dist/vite.config.d.ts +2 -0
  105. package/dist/vitest.config.d.ts +2 -0
  106. package/package.json +2 -2
  107. package/dist/browser/internal/object-DHqlosWD.js +0 -7
  108. package/dist/browser/internal/object-StihF423.js +0 -1999
  109. package/dist/node/internal/object-CKxJA706.js +0 -2
  110. package/dist/node/internal/object-CudRLU4J.js +0 -998
@@ -0,0 +1,2492 @@
1
+ var $e = Object.defineProperty;
2
+ var Ce = (i, r, s) => r in i ? $e(i, r, { enumerable: !0, configurable: !0, writable: !0, value: s }) : i[r] = s;
3
+ var At = (i, r, s) => (Ce(i, typeof r != "symbol" ? r + "" : r, s), s);
4
+ import { produce as xt, castDraft as Ut, castImmutable as Me, freeze as Ne } from "immer";
5
+ import { z as _ } from "zod";
6
+ import te from "jszip";
7
+ const ee = (i) => i != null, Re = _.any().refine((i) => ee(i)), re = _.enum(["LOAD_STATE"]), ie = _.enum(["PRUNE"]), ne = _.enum(["REDO"]), oe = _.enum(["SET_NAME"]), ae = _.enum(["UNDO"]);
8
+ function Le() {
9
+ return _.object({
10
+ __typename: _.literal("Action").optional(),
11
+ type: _.string()
12
+ });
13
+ }
14
+ function dt() {
15
+ return _.literal("global").or(_.literal("local"));
16
+ }
17
+ function se() {
18
+ return _.union([
19
+ pe(),
20
+ le(),
21
+ ue(),
22
+ fe(),
23
+ he()
24
+ ]);
25
+ }
26
+ function ze() {
27
+ return _.object({
28
+ __typename: _.literal("DocumentFile").optional(),
29
+ data: _.string(),
30
+ extension: _.string().nullable(),
31
+ fileName: _.string().nullable(),
32
+ mimeType: _.string()
33
+ });
34
+ }
35
+ function pe() {
36
+ return _.object({
37
+ input: _.lazy(() => Nt()),
38
+ type: re,
39
+ scope: dt()
40
+ });
41
+ }
42
+ function Nt() {
43
+ return _.object({
44
+ operations: _.number(),
45
+ state: _.lazy(() => ce())
46
+ });
47
+ }
48
+ function ce() {
49
+ return _.object({
50
+ data: _.unknown().nullish(),
51
+ name: _.string()
52
+ });
53
+ }
54
+ function Pe() {
55
+ return _.object({
56
+ __typename: _.literal("Operation").optional(),
57
+ hash: _.string(),
58
+ index: _.number(),
59
+ timestamp: _.string().datetime(),
60
+ type: _.string()
61
+ });
62
+ }
63
+ function le() {
64
+ return _.object({
65
+ input: _.lazy(() => Rt()),
66
+ type: ie,
67
+ scope: dt()
68
+ });
69
+ }
70
+ function Rt() {
71
+ return _.object({
72
+ end: _.number().nullish(),
73
+ start: _.number().nullish()
74
+ });
75
+ }
76
+ const Lt = _.number;
77
+ function ue() {
78
+ return _.object({
79
+ input: Lt(),
80
+ type: ne,
81
+ scope: dt()
82
+ });
83
+ }
84
+ const zt = _.string;
85
+ function fe() {
86
+ return _.object({
87
+ input: zt(),
88
+ type: oe,
89
+ scope: _.literal("global")
90
+ });
91
+ }
92
+ function qe() {
93
+ return _.object({
94
+ __typename: _.literal("SetNameOperation").optional(),
95
+ hash: _.string(),
96
+ index: _.number(),
97
+ input: _.string(),
98
+ timestamp: _.string().datetime(),
99
+ type: _.string()
100
+ });
101
+ }
102
+ const Pt = _.number;
103
+ function he() {
104
+ return _.object({
105
+ input: Pt(),
106
+ type: ae,
107
+ scope: dt()
108
+ });
109
+ }
110
+ const ei = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
111
+ __proto__: null,
112
+ ActionSchema: Le,
113
+ BaseActionSchema: se,
114
+ DocumentFileSchema: ze,
115
+ LoadStateActionInputSchema: Nt,
116
+ LoadStateActionSchema: pe,
117
+ LoadStateActionStateInputSchema: ce,
118
+ Load_StateSchema: re,
119
+ OperationSchema: Pe,
120
+ OperationScopeSchema: dt,
121
+ PruneActionInputSchema: Rt,
122
+ PruneActionSchema: le,
123
+ PruneSchema: ie,
124
+ RedoActionInputSchema: Lt,
125
+ RedoActionSchema: ue,
126
+ RedoSchema: ne,
127
+ SetNameActionInputSchema: zt,
128
+ SetNameActionSchema: fe,
129
+ SetNameOperationSchema: qe,
130
+ Set_NameSchema: oe,
131
+ UndoActionInputSchema: Pt,
132
+ UndoActionSchema: he,
133
+ UndoSchema: ae,
134
+ definedNonNullAnySchema: Re,
135
+ isDefinedNonNullAny: ee
136
+ }, Symbol.toStringTag, { value: "Module" }));
137
+ function qt(i) {
138
+ return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
139
+ }
140
+ var Dt = { exports: {} };
141
+ (function(i, r) {
142
+ const { hasOwnProperty: s } = Object.prototype, p = rt();
143
+ p.configure = rt, p.stringify = p, p.default = p, r.stringify = p, r.configure = rt, i.exports = p;
144
+ const f = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;
145
+ function u(y) {
146
+ return y.length < 5e3 && !f.test(y) ? `"${y}"` : JSON.stringify(y);
147
+ }
148
+ function l(y) {
149
+ if (y.length > 200)
150
+ return y.sort();
151
+ for (let E = 1; E < y.length; E++) {
152
+ const k = y[E];
153
+ let q = E;
154
+ for (; q !== 0 && y[q - 1] > k; )
155
+ y[q] = y[q - 1], q--;
156
+ y[q] = k;
157
+ }
158
+ return y;
159
+ }
160
+ const a = Object.getOwnPropertyDescriptor(
161
+ Object.getPrototypeOf(
162
+ Object.getPrototypeOf(
163
+ new Int8Array()
164
+ )
165
+ ),
166
+ Symbol.toStringTag
167
+ ).get;
168
+ function x(y) {
169
+ return a.call(y) !== void 0 && y.length !== 0;
170
+ }
171
+ function g(y, E, k) {
172
+ y.length < k && (k = y.length);
173
+ const q = E === "," ? "" : " ";
174
+ let Z = `"0":${q}${y[0]}`;
175
+ for (let H = 1; H < k; H++)
176
+ Z += `${E}"${H}":${q}${y[H]}`;
177
+ return Z;
178
+ }
179
+ function A(y) {
180
+ if (s.call(y, "circularValue")) {
181
+ const E = y.circularValue;
182
+ if (typeof E == "string")
183
+ return `"${E}"`;
184
+ if (E == null)
185
+ return E;
186
+ if (E === Error || E === TypeError)
187
+ return {
188
+ toString() {
189
+ throw new TypeError("Converting circular structure to JSON");
190
+ }
191
+ };
192
+ throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined');
193
+ }
194
+ return '"[Circular]"';
195
+ }
196
+ function w(y, E) {
197
+ let k;
198
+ if (s.call(y, E) && (k = y[E], typeof k != "boolean"))
199
+ throw new TypeError(`The "${E}" argument must be of type boolean`);
200
+ return k === void 0 ? !0 : k;
201
+ }
202
+ function b(y, E) {
203
+ let k;
204
+ if (s.call(y, E)) {
205
+ if (k = y[E], typeof k != "number")
206
+ throw new TypeError(`The "${E}" argument must be of type number`);
207
+ if (!Number.isInteger(k))
208
+ throw new TypeError(`The "${E}" argument must be an integer`);
209
+ if (k < 1)
210
+ throw new RangeError(`The "${E}" argument must be >= 1`);
211
+ }
212
+ return k === void 0 ? 1 / 0 : k;
213
+ }
214
+ function F(y) {
215
+ return y === 1 ? "1 item" : `${y} items`;
216
+ }
217
+ function I(y) {
218
+ const E = /* @__PURE__ */ new Set();
219
+ for (const k of y)
220
+ (typeof k == "string" || typeof k == "number") && E.add(String(k));
221
+ return E;
222
+ }
223
+ function G(y) {
224
+ if (s.call(y, "strict")) {
225
+ const E = y.strict;
226
+ if (typeof E != "boolean")
227
+ throw new TypeError('The "strict" argument must be of type boolean');
228
+ if (E)
229
+ return (k) => {
230
+ let q = `Object can not safely be stringified. Received type ${typeof k}`;
231
+ throw typeof k != "function" && (q += ` (${k.toString()})`), new Error(q);
232
+ };
233
+ }
234
+ }
235
+ function rt(y) {
236
+ y = { ...y };
237
+ const E = G(y);
238
+ E && (y.bigint === void 0 && (y.bigint = !1), "circularValue" in y || (y.circularValue = Error));
239
+ const k = A(y), q = w(y, "bigint"), Z = w(y, "deterministic"), H = b(y, "maximumDepth"), N = b(y, "maximumBreadth");
240
+ function ct(J, h, v, T, j, $) {
241
+ let S = h[J];
242
+ switch (typeof S == "object" && S !== null && typeof S.toJSON == "function" && (S = S.toJSON(J)), S = T.call(h, J, S), typeof S) {
243
+ case "string":
244
+ return u(S);
245
+ case "object": {
246
+ if (S === null)
247
+ return "null";
248
+ if (v.indexOf(S) !== -1)
249
+ return k;
250
+ let U = "", B = ",";
251
+ const O = $;
252
+ if (Array.isArray(S)) {
253
+ if (S.length === 0)
254
+ return "[]";
255
+ if (H < v.length + 1)
256
+ return '"[Array]"';
257
+ v.push(S), j !== "" && ($ += j, U += `
258
+ ${$}`, B = `,
259
+ ${$}`);
260
+ const W = Math.min(S.length, N);
261
+ let X = 0;
262
+ for (; X < W - 1; X++) {
263
+ const st = ct(String(X), S, v, T, j, $);
264
+ U += st !== void 0 ? st : "null", U += B;
265
+ }
266
+ const Q = ct(String(X), S, v, T, j, $);
267
+ if (U += Q !== void 0 ? Q : "null", S.length - 1 > N) {
268
+ const st = S.length - N - 1;
269
+ U += `${B}"... ${F(st)} not stringified"`;
270
+ }
271
+ return j !== "" && (U += `
272
+ ${O}`), v.pop(), `[${U}]`;
273
+ }
274
+ let R = Object.keys(S);
275
+ const P = R.length;
276
+ if (P === 0)
277
+ return "{}";
278
+ if (H < v.length + 1)
279
+ return '"[Object]"';
280
+ let C = "", V = "";
281
+ j !== "" && ($ += j, B = `,
282
+ ${$}`, C = " ");
283
+ const Y = Math.min(P, N);
284
+ Z && !x(S) && (R = l(R)), v.push(S);
285
+ for (let W = 0; W < Y; W++) {
286
+ const X = R[W], Q = ct(X, S, v, T, j, $);
287
+ Q !== void 0 && (U += `${V}${u(X)}:${C}${Q}`, V = B);
288
+ }
289
+ if (P > N) {
290
+ const W = P - N;
291
+ U += `${V}"...":${C}"${F(W)} not stringified"`, V = B;
292
+ }
293
+ return j !== "" && V.length > 1 && (U = `
294
+ ${$}${U}
295
+ ${O}`), v.pop(), `{${U}}`;
296
+ }
297
+ case "number":
298
+ return isFinite(S) ? String(S) : E ? E(S) : "null";
299
+ case "boolean":
300
+ return S === !0 ? "true" : "false";
301
+ case "undefined":
302
+ return;
303
+ case "bigint":
304
+ if (q)
305
+ return String(S);
306
+ default:
307
+ return E ? E(S) : void 0;
308
+ }
309
+ }
310
+ function lt(J, h, v, T, j, $) {
311
+ switch (typeof h == "object" && h !== null && typeof h.toJSON == "function" && (h = h.toJSON(J)), typeof h) {
312
+ case "string":
313
+ return u(h);
314
+ case "object": {
315
+ if (h === null)
316
+ return "null";
317
+ if (v.indexOf(h) !== -1)
318
+ return k;
319
+ const S = $;
320
+ let U = "", B = ",";
321
+ if (Array.isArray(h)) {
322
+ if (h.length === 0)
323
+ return "[]";
324
+ if (H < v.length + 1)
325
+ return '"[Array]"';
326
+ v.push(h), j !== "" && ($ += j, U += `
327
+ ${$}`, B = `,
328
+ ${$}`);
329
+ const P = Math.min(h.length, N);
330
+ let C = 0;
331
+ for (; C < P - 1; C++) {
332
+ const Y = lt(String(C), h[C], v, T, j, $);
333
+ U += Y !== void 0 ? Y : "null", U += B;
334
+ }
335
+ const V = lt(String(C), h[C], v, T, j, $);
336
+ if (U += V !== void 0 ? V : "null", h.length - 1 > N) {
337
+ const Y = h.length - N - 1;
338
+ U += `${B}"... ${F(Y)} not stringified"`;
339
+ }
340
+ return j !== "" && (U += `
341
+ ${S}`), v.pop(), `[${U}]`;
342
+ }
343
+ v.push(h);
344
+ let O = "";
345
+ j !== "" && ($ += j, B = `,
346
+ ${$}`, O = " ");
347
+ let R = "";
348
+ for (const P of T) {
349
+ const C = lt(P, h[P], v, T, j, $);
350
+ C !== void 0 && (U += `${R}${u(P)}:${O}${C}`, R = B);
351
+ }
352
+ return j !== "" && R.length > 1 && (U = `
353
+ ${$}${U}
354
+ ${S}`), v.pop(), `{${U}}`;
355
+ }
356
+ case "number":
357
+ return isFinite(h) ? String(h) : E ? E(h) : "null";
358
+ case "boolean":
359
+ return h === !0 ? "true" : "false";
360
+ case "undefined":
361
+ return;
362
+ case "bigint":
363
+ if (q)
364
+ return String(h);
365
+ default:
366
+ return E ? E(h) : void 0;
367
+ }
368
+ }
369
+ function ot(J, h, v, T, j) {
370
+ switch (typeof h) {
371
+ case "string":
372
+ return u(h);
373
+ case "object": {
374
+ if (h === null)
375
+ return "null";
376
+ if (typeof h.toJSON == "function") {
377
+ if (h = h.toJSON(J), typeof h != "object")
378
+ return ot(J, h, v, T, j);
379
+ if (h === null)
380
+ return "null";
381
+ }
382
+ if (v.indexOf(h) !== -1)
383
+ return k;
384
+ const $ = j;
385
+ if (Array.isArray(h)) {
386
+ if (h.length === 0)
387
+ return "[]";
388
+ if (H < v.length + 1)
389
+ return '"[Array]"';
390
+ v.push(h), j += T;
391
+ let C = `
392
+ ${j}`;
393
+ const V = `,
394
+ ${j}`, Y = Math.min(h.length, N);
395
+ let W = 0;
396
+ for (; W < Y - 1; W++) {
397
+ const Q = ot(String(W), h[W], v, T, j);
398
+ C += Q !== void 0 ? Q : "null", C += V;
399
+ }
400
+ const X = ot(String(W), h[W], v, T, j);
401
+ if (C += X !== void 0 ? X : "null", h.length - 1 > N) {
402
+ const Q = h.length - N - 1;
403
+ C += `${V}"... ${F(Q)} not stringified"`;
404
+ }
405
+ return C += `
406
+ ${$}`, v.pop(), `[${C}]`;
407
+ }
408
+ let S = Object.keys(h);
409
+ const U = S.length;
410
+ if (U === 0)
411
+ return "{}";
412
+ if (H < v.length + 1)
413
+ return '"[Object]"';
414
+ j += T;
415
+ const B = `,
416
+ ${j}`;
417
+ let O = "", R = "", P = Math.min(U, N);
418
+ x(h) && (O += g(h, B, N), S = S.slice(h.length), P -= h.length, R = B), Z && (S = l(S)), v.push(h);
419
+ for (let C = 0; C < P; C++) {
420
+ const V = S[C], Y = ot(V, h[V], v, T, j);
421
+ Y !== void 0 && (O += `${R}${u(V)}: ${Y}`, R = B);
422
+ }
423
+ if (U > N) {
424
+ const C = U - N;
425
+ O += `${R}"...": "${F(C)} not stringified"`, R = B;
426
+ }
427
+ return R !== "" && (O = `
428
+ ${j}${O}
429
+ ${$}`), v.pop(), `{${O}}`;
430
+ }
431
+ case "number":
432
+ return isFinite(h) ? String(h) : E ? E(h) : "null";
433
+ case "boolean":
434
+ return h === !0 ? "true" : "false";
435
+ case "undefined":
436
+ return;
437
+ case "bigint":
438
+ if (q)
439
+ return String(h);
440
+ default:
441
+ return E ? E(h) : void 0;
442
+ }
443
+ }
444
+ function at(J, h, v) {
445
+ switch (typeof h) {
446
+ case "string":
447
+ return u(h);
448
+ case "object": {
449
+ if (h === null)
450
+ return "null";
451
+ if (typeof h.toJSON == "function") {
452
+ if (h = h.toJSON(J), typeof h != "object")
453
+ return at(J, h, v);
454
+ if (h === null)
455
+ return "null";
456
+ }
457
+ if (v.indexOf(h) !== -1)
458
+ return k;
459
+ let T = "";
460
+ if (Array.isArray(h)) {
461
+ if (h.length === 0)
462
+ return "[]";
463
+ if (H < v.length + 1)
464
+ return '"[Array]"';
465
+ v.push(h);
466
+ const B = Math.min(h.length, N);
467
+ let O = 0;
468
+ for (; O < B - 1; O++) {
469
+ const P = at(String(O), h[O], v);
470
+ T += P !== void 0 ? P : "null", T += ",";
471
+ }
472
+ const R = at(String(O), h[O], v);
473
+ if (T += R !== void 0 ? R : "null", h.length - 1 > N) {
474
+ const P = h.length - N - 1;
475
+ T += `,"... ${F(P)} not stringified"`;
476
+ }
477
+ return v.pop(), `[${T}]`;
478
+ }
479
+ let j = Object.keys(h);
480
+ const $ = j.length;
481
+ if ($ === 0)
482
+ return "{}";
483
+ if (H < v.length + 1)
484
+ return '"[Object]"';
485
+ let S = "", U = Math.min($, N);
486
+ x(h) && (T += g(h, ",", N), j = j.slice(h.length), U -= h.length, S = ","), Z && (j = l(j)), v.push(h);
487
+ for (let B = 0; B < U; B++) {
488
+ const O = j[B], R = at(O, h[O], v);
489
+ R !== void 0 && (T += `${S}${u(O)}:${R}`, S = ",");
490
+ }
491
+ if ($ > N) {
492
+ const B = $ - N;
493
+ T += `${S}"...":"${F(B)} not stringified"`;
494
+ }
495
+ return v.pop(), `{${T}}`;
496
+ }
497
+ case "number":
498
+ return isFinite(h) ? String(h) : E ? E(h) : "null";
499
+ case "boolean":
500
+ return h === !0 ? "true" : "false";
501
+ case "undefined":
502
+ return;
503
+ case "bigint":
504
+ if (q)
505
+ return String(h);
506
+ default:
507
+ return E ? E(h) : void 0;
508
+ }
509
+ }
510
+ function It(J, h, v) {
511
+ if (arguments.length > 1) {
512
+ let T = "";
513
+ if (typeof v == "number" ? T = " ".repeat(Math.min(v, 10)) : typeof v == "string" && (T = v.slice(0, 10)), h != null) {
514
+ if (typeof h == "function")
515
+ return ct("", { "": J }, [], h, T, "");
516
+ if (Array.isArray(h))
517
+ return lt("", J, [], I(h), T, "");
518
+ }
519
+ if (T.length !== 0)
520
+ return ot("", J, [], T, "");
521
+ }
522
+ return at("", J, []);
523
+ }
524
+ return It;
525
+ }
526
+ })(Dt, Dt.exports);
527
+ var Je = Dt.exports;
528
+ const St = /* @__PURE__ */ qt(Je);
529
+ St.configure;
530
+ function We(i, r) {
531
+ return { ...i, name: r };
532
+ }
533
+ function Ve(i, r, s) {
534
+ const p = {
535
+ skip: s,
536
+ document: i
537
+ }, { scope: f } = r;
538
+ return !f || r.skip === void 0 ? p : xt(p, (u) => {
539
+ const [l] = u.document.operations[f].slice(-1);
540
+ r.skip && r.skip > 0 && (u.skip = r.skip), l.type === "NOOP" && r.index === l.index && u.skip > l.skip && u.document.operations[f].pop();
541
+ });
542
+ }
543
+ function Ke(i, r, s) {
544
+ const { scope: p, input: f } = r;
545
+ return xt({
546
+ document: i,
547
+ action: r,
548
+ skip: s
549
+ }, (l) => {
550
+ if (l.document.operations[p].length < 1)
551
+ throw new Error(
552
+ `Cannot undo: no operations in history for scope "${p}"`
553
+ );
554
+ if (f < 1)
555
+ throw new Error(
556
+ "Invalid UNDO action: input value must be greater than 0"
557
+ );
558
+ if (l.skip > 0)
559
+ throw new Error(
560
+ "Cannot undo: skip value from reducer cannot be used with UNDO action"
561
+ );
562
+ const [a] = l.document.operations[p].slice(-1), x = a.type === "NOOP" && a.skip > 0;
563
+ if (l.skip += f, x) {
564
+ l.skip += a.skip;
565
+ const b = l.document.operations[p][l.document.operations[p].length - 2];
566
+ b && a.index - b.index === 1 && l.document.operations[p].pop();
567
+ }
568
+ if (l.document.operations[p].length < l.skip)
569
+ throw new Error(
570
+ "Cannot undo: you can't undo more operations than the ones in the scope history"
571
+ );
572
+ const g = l.document.operations[p].length - 1;
573
+ let A = f, w = x ? g - a.skip : g;
574
+ for (; A > 0 && w >= 0; ) {
575
+ const b = l.document.operations[p][w];
576
+ if (!b) {
577
+ A--, w--;
578
+ continue;
579
+ }
580
+ b.type === "NOOP" && b.skip > 0 ? (w = w - (b.skip + 1), l.skip += b.skip + 1) : (l.document.clipboard.push({ ...b }), A--, w--);
581
+ }
582
+ l.action = Ht(p);
583
+ });
584
+ }
585
+ function He(i, r, s) {
586
+ const { scope: p, input: f } = r;
587
+ return xt({
588
+ document: i,
589
+ action: r,
590
+ skip: s
591
+ }, (l) => {
592
+ if (l.skip > 0)
593
+ throw new Error(
594
+ "Cannot redo: skip value from reducer cannot be used with REDO action"
595
+ );
596
+ if (f > 1)
597
+ throw new Error(
598
+ "Cannot redo: you can only redo one operation at a time"
599
+ );
600
+ if (f < 1)
601
+ throw new Error("Invalid REDO action: invalid redo input value");
602
+ if (l.document.clipboard.length < 1)
603
+ throw new Error("Cannot redo: no operations in the clipboard");
604
+ const a = l.document.clipboard.findLastIndex(
605
+ (g) => g.scope === p
606
+ );
607
+ if (a < 0)
608
+ throw new Error(
609
+ `Cannot redo: no operations in clipboard for scope "${p}"`
610
+ );
611
+ const x = l.document.clipboard.splice(a, 1)[0];
612
+ l.action = Ut({
613
+ type: x.type,
614
+ scope: x.scope,
615
+ input: x.input
616
+ });
617
+ });
618
+ }
619
+ function Ze(i, r, s) {
620
+ const { scope: p } = r, f = i.operations[p];
621
+ let {
622
+ input: { start: u, end: l }
623
+ } = r;
624
+ u = u || 0, l = l || f.length;
625
+ const a = f.slice(u, l), x = f.slice(0, u), g = f.slice(l), A = Mt(
626
+ i.initialState,
627
+ {
628
+ ...i.operations,
629
+ [p]: x.concat(a)
630
+ },
631
+ s
632
+ ), { name: w, state: b } = A, F = x.length, I = x.length ? x[x.length - 1].timestamp : g.length ? g[0].timestamp : (/* @__PURE__ */ new Date()).toISOString();
633
+ return Mt(
634
+ i.initialState,
635
+ {
636
+ ...i.operations,
637
+ [p]: [
638
+ ...x,
639
+ {
640
+ ...Kt(
641
+ { name: w, state: b },
642
+ a.length
643
+ ),
644
+ timestamp: I,
645
+ index: F,
646
+ hash: Se({ state: b }, "global")
647
+ },
648
+ ...g.map((G, rt) => ({
649
+ ...G,
650
+ index: F + rt + 1
651
+ }))
652
+ ]
653
+ },
654
+ s
655
+ );
656
+ }
657
+ function Ge(i, r) {
658
+ return {
659
+ ...i,
660
+ name: r.name,
661
+ state: r.state ?? { global: {}, local: {} }
662
+ };
663
+ }
664
+ const me = "SET_NAME", gt = "UNDO", yt = "REDO", Ft = "PRUNE", xe = "LOAD_STATE", Ye = "NOOP";
665
+ function Xe(i, r) {
666
+ let s;
667
+ return "index" in r ? s = { ...r } : s = i.operations[r.scope].slice(-1)[0], ((s == null ? void 0 : s.index) ?? -1) + 1;
668
+ }
669
+ function Qe(i, r) {
670
+ return {
671
+ ...i,
672
+ revision: {
673
+ ...i.revision,
674
+ [r.scope]: Xe(i, r)
675
+ },
676
+ lastModified: (/* @__PURE__ */ new Date()).toISOString()
677
+ };
678
+ }
679
+ function tr(i, r, s = 0) {
680
+ if ([gt, yt, Ft].includes(r.type))
681
+ return i;
682
+ const { scope: p } = r, f = i.operations[p].slice(
683
+ 0,
684
+ i.revision[p]
685
+ ), u = [...f].pop();
686
+ let l = ((u == null ? void 0 : u.index) ?? -1) + 1;
687
+ if ("index" in r) {
688
+ if (r.index > l + s)
689
+ throw new Error(
690
+ `Missing operations: expected ${l} with skip 0 or equivalent, got index ${r.index} with skip ${s}`
691
+ );
692
+ l = r.index;
693
+ }
694
+ return f.push({
695
+ ...r,
696
+ index: l,
697
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
698
+ hash: "",
699
+ scope: p,
700
+ skip: s
701
+ }), {
702
+ ...i,
703
+ operations: { ...i.operations, [p]: f }
704
+ };
705
+ }
706
+ function er(i, r, s = 0) {
707
+ let p = tr(i, r, s);
708
+ return p = Qe(p, r), p;
709
+ }
710
+ function rr(i, r, s) {
711
+ switch (se().parse(r), r.type) {
712
+ case me:
713
+ return We(i, r.input);
714
+ case Ft:
715
+ return Ze(i, r, s);
716
+ case xe:
717
+ return Ge(i, r.input.state);
718
+ default:
719
+ return i;
720
+ }
721
+ }
722
+ function ir(i, r, s) {
723
+ switch (r.type) {
724
+ case gt:
725
+ return Ke(i, r, s);
726
+ case yt:
727
+ return He(i, r, s);
728
+ default:
729
+ return { document: i, action: r, skip: s };
730
+ }
731
+ }
732
+ function de(i, r, s, p, f = {}) {
733
+ const { skip: u, ignoreSkipOperations: l = !1 } = f;
734
+ let a = { ...r }, x = u || 0, g = i, A = [...i.clipboard];
735
+ if (Nr(a)) {
736
+ const { document: w, skip: b } = Ve(g, a, x);
737
+ x = b, g = w;
738
+ }
739
+ if (Yt(a)) {
740
+ const {
741
+ skip: w,
742
+ action: b,
743
+ document: F
744
+ } = ir(i, a, x);
745
+ a = b, x = w, g = F, A = [...g.clipboard];
746
+ }
747
+ if (Xt(a) && (g = rr(g, a, s)), x > 0 && !l) {
748
+ let w = x;
749
+ "index" in a && (w = qr(
750
+ g.operations[a.scope],
751
+ a.index,
752
+ x
753
+ )), g = Mt(
754
+ g.initialState,
755
+ g.operations,
756
+ s,
757
+ void 0,
758
+ void 0,
759
+ void 0,
760
+ { [a.scope]: w }
761
+ );
762
+ }
763
+ return g = er(g, a, x), g = xt(g, (w) => {
764
+ const b = s(
765
+ w.state,
766
+ a,
767
+ p
768
+ ), F = Yt(r) ? [...A] : [];
769
+ if (b)
770
+ return Ut({
771
+ ...g,
772
+ clipboard: [...F],
773
+ state: b
774
+ });
775
+ w.clipboard = Ut([...F]);
776
+ }), xt(g, (w) => {
777
+ if ([gt, yt, Ft].includes(a.type))
778
+ return w;
779
+ const b = a.scope || "global";
780
+ w.operations[b][w.operations[b].length - 1].hash = Se(w, b), !Xt(a) && a.attachments && a.attachments.forEach((F) => {
781
+ const { hash: I, ...G } = F;
782
+ w.attachments[I] = {
783
+ ...G
784
+ };
785
+ });
786
+ });
787
+ }
788
+ var $t = { exports: {} };
789
+ typeof Object.create == "function" ? $t.exports = function(r, s) {
790
+ s && (r.super_ = s, r.prototype = Object.create(s.prototype, {
791
+ constructor: {
792
+ value: r,
793
+ enumerable: !1,
794
+ writable: !0,
795
+ configurable: !0
796
+ }
797
+ }));
798
+ } : $t.exports = function(r, s) {
799
+ if (s) {
800
+ r.super_ = s;
801
+ var p = function() {
802
+ };
803
+ p.prototype = s.prototype, r.prototype = new p(), r.prototype.constructor = r;
804
+ }
805
+ };
806
+ var ge = $t.exports, Ct = { exports: {} }, ye = {}, Bt = {};
807
+ Bt.byteLength = ar;
808
+ Bt.toByteArray = pr;
809
+ Bt.fromByteArray = ur;
810
+ var nt = [], et = [], nr = typeof Uint8Array < "u" ? Uint8Array : Array, kt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
811
+ for (var ut = 0, or = kt.length; ut < or; ++ut)
812
+ nt[ut] = kt[ut], et[kt.charCodeAt(ut)] = ut;
813
+ et[45] = 62;
814
+ et[95] = 63;
815
+ function we(i) {
816
+ var r = i.length;
817
+ if (r % 4 > 0)
818
+ throw new Error("Invalid string. Length must be a multiple of 4");
819
+ var s = i.indexOf("=");
820
+ s === -1 && (s = r);
821
+ var p = s === r ? 0 : 4 - s % 4;
822
+ return [s, p];
823
+ }
824
+ function ar(i) {
825
+ var r = we(i), s = r[0], p = r[1];
826
+ return (s + p) * 3 / 4 - p;
827
+ }
828
+ function sr(i, r, s) {
829
+ return (r + s) * 3 / 4 - s;
830
+ }
831
+ function pr(i) {
832
+ var r, s = we(i), p = s[0], f = s[1], u = new nr(sr(i, p, f)), l = 0, a = f > 0 ? p - 4 : p, x;
833
+ for (x = 0; x < a; x += 4)
834
+ r = et[i.charCodeAt(x)] << 18 | et[i.charCodeAt(x + 1)] << 12 | et[i.charCodeAt(x + 2)] << 6 | et[i.charCodeAt(x + 3)], u[l++] = r >> 16 & 255, u[l++] = r >> 8 & 255, u[l++] = r & 255;
835
+ return f === 2 && (r = et[i.charCodeAt(x)] << 2 | et[i.charCodeAt(x + 1)] >> 4, u[l++] = r & 255), f === 1 && (r = et[i.charCodeAt(x)] << 10 | et[i.charCodeAt(x + 1)] << 4 | et[i.charCodeAt(x + 2)] >> 2, u[l++] = r >> 8 & 255, u[l++] = r & 255), u;
836
+ }
837
+ function cr(i) {
838
+ return nt[i >> 18 & 63] + nt[i >> 12 & 63] + nt[i >> 6 & 63] + nt[i & 63];
839
+ }
840
+ function lr(i, r, s) {
841
+ for (var p, f = [], u = r; u < s; u += 3)
842
+ p = (i[u] << 16 & 16711680) + (i[u + 1] << 8 & 65280) + (i[u + 2] & 255), f.push(cr(p));
843
+ return f.join("");
844
+ }
845
+ function ur(i) {
846
+ for (var r, s = i.length, p = s % 3, f = [], u = 16383, l = 0, a = s - p; l < a; l += u)
847
+ f.push(lr(i, l, l + u > a ? a : l + u));
848
+ return p === 1 ? (r = i[s - 1], f.push(
849
+ nt[r >> 2] + nt[r << 4 & 63] + "=="
850
+ )) : p === 2 && (r = (i[s - 2] << 8) + i[s - 1], f.push(
851
+ nt[r >> 10] + nt[r >> 4 & 63] + nt[r << 2 & 63] + "="
852
+ )), f.join("");
853
+ }
854
+ var Jt = {};
855
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
856
+ Jt.read = function(i, r, s, p, f) {
857
+ var u, l, a = f * 8 - p - 1, x = (1 << a) - 1, g = x >> 1, A = -7, w = s ? f - 1 : 0, b = s ? -1 : 1, F = i[r + w];
858
+ for (w += b, u = F & (1 << -A) - 1, F >>= -A, A += a; A > 0; u = u * 256 + i[r + w], w += b, A -= 8)
859
+ ;
860
+ for (l = u & (1 << -A) - 1, u >>= -A, A += p; A > 0; l = l * 256 + i[r + w], w += b, A -= 8)
861
+ ;
862
+ if (u === 0)
863
+ u = 1 - g;
864
+ else {
865
+ if (u === x)
866
+ return l ? NaN : (F ? -1 : 1) * (1 / 0);
867
+ l = l + Math.pow(2, p), u = u - g;
868
+ }
869
+ return (F ? -1 : 1) * l * Math.pow(2, u - p);
870
+ };
871
+ Jt.write = function(i, r, s, p, f, u) {
872
+ var l, a, x, g = u * 8 - f - 1, A = (1 << g) - 1, w = A >> 1, b = f === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, F = p ? 0 : u - 1, I = p ? 1 : -1, G = r < 0 || r === 0 && 1 / r < 0 ? 1 : 0;
873
+ for (r = Math.abs(r), isNaN(r) || r === 1 / 0 ? (a = isNaN(r) ? 1 : 0, l = A) : (l = Math.floor(Math.log(r) / Math.LN2), r * (x = Math.pow(2, -l)) < 1 && (l--, x *= 2), l + w >= 1 ? r += b / x : r += b * Math.pow(2, 1 - w), r * x >= 2 && (l++, x /= 2), l + w >= A ? (a = 0, l = A) : l + w >= 1 ? (a = (r * x - 1) * Math.pow(2, f), l = l + w) : (a = r * Math.pow(2, w - 1) * Math.pow(2, f), l = 0)); f >= 8; i[s + F] = a & 255, F += I, a /= 256, f -= 8)
874
+ ;
875
+ for (l = l << f | a, g += f; g > 0; i[s + F] = l & 255, F += I, l /= 256, g -= 8)
876
+ ;
877
+ i[s + F - I] |= G * 128;
878
+ };
879
+ /*!
880
+ * The buffer module from node.js, for the browser.
881
+ *
882
+ * @author Feross Aboukhadijeh <https://feross.org>
883
+ * @license MIT
884
+ */
885
+ (function(i) {
886
+ var r = Bt, s = Jt, p = typeof Symbol == "function" && typeof Symbol.for == "function" ? Symbol.for("nodejs.util.inspect.custom") : null;
887
+ i.Buffer = a, i.SlowBuffer = E, i.INSPECT_MAX_BYTES = 50;
888
+ var f = 2147483647;
889
+ i.kMaxLength = f, a.TYPED_ARRAY_SUPPORT = u(), !a.TYPED_ARRAY_SUPPORT && typeof console < "u" && typeof console.error == "function" && console.error(
890
+ "This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."
891
+ );
892
+ function u() {
893
+ try {
894
+ var n = new Uint8Array(1), t = { foo: function() {
895
+ return 42;
896
+ } };
897
+ return Object.setPrototypeOf(t, Uint8Array.prototype), Object.setPrototypeOf(n, t), n.foo() === 42;
898
+ } catch {
899
+ return !1;
900
+ }
901
+ }
902
+ Object.defineProperty(a.prototype, "parent", {
903
+ enumerable: !0,
904
+ get: function() {
905
+ if (a.isBuffer(this))
906
+ return this.buffer;
907
+ }
908
+ }), Object.defineProperty(a.prototype, "offset", {
909
+ enumerable: !0,
910
+ get: function() {
911
+ if (a.isBuffer(this))
912
+ return this.byteOffset;
913
+ }
914
+ });
915
+ function l(n) {
916
+ if (n > f)
917
+ throw new RangeError('The value "' + n + '" is invalid for option "size"');
918
+ var t = new Uint8Array(n);
919
+ return Object.setPrototypeOf(t, a.prototype), t;
920
+ }
921
+ function a(n, t, e) {
922
+ if (typeof n == "number") {
923
+ if (typeof t == "string")
924
+ throw new TypeError(
925
+ 'The "string" argument must be of type string. Received type number'
926
+ );
927
+ return w(n);
928
+ }
929
+ return x(n, t, e);
930
+ }
931
+ a.poolSize = 8192;
932
+ function x(n, t, e) {
933
+ if (typeof n == "string")
934
+ return b(n, t);
935
+ if (ArrayBuffer.isView(n))
936
+ return I(n);
937
+ if (n == null)
938
+ throw new TypeError(
939
+ "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof n
940
+ );
941
+ if (it(n, ArrayBuffer) || n && it(n.buffer, ArrayBuffer) || typeof SharedArrayBuffer < "u" && (it(n, SharedArrayBuffer) || n && it(n.buffer, SharedArrayBuffer)))
942
+ return G(n, t, e);
943
+ if (typeof n == "number")
944
+ throw new TypeError(
945
+ 'The "value" argument must not be of type number. Received type number'
946
+ );
947
+ var o = n.valueOf && n.valueOf();
948
+ if (o != null && o !== n)
949
+ return a.from(o, t, e);
950
+ var c = rt(n);
951
+ if (c)
952
+ return c;
953
+ if (typeof Symbol < "u" && Symbol.toPrimitive != null && typeof n[Symbol.toPrimitive] == "function")
954
+ return a.from(
955
+ n[Symbol.toPrimitive]("string"),
956
+ t,
957
+ e
958
+ );
959
+ throw new TypeError(
960
+ "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof n
961
+ );
962
+ }
963
+ a.from = function(n, t, e) {
964
+ return x(n, t, e);
965
+ }, Object.setPrototypeOf(a.prototype, Uint8Array.prototype), Object.setPrototypeOf(a, Uint8Array);
966
+ function g(n) {
967
+ if (typeof n != "number")
968
+ throw new TypeError('"size" argument must be of type number');
969
+ if (n < 0)
970
+ throw new RangeError('The value "' + n + '" is invalid for option "size"');
971
+ }
972
+ function A(n, t, e) {
973
+ return g(n), n <= 0 ? l(n) : t !== void 0 ? typeof e == "string" ? l(n).fill(t, e) : l(n).fill(t) : l(n);
974
+ }
975
+ a.alloc = function(n, t, e) {
976
+ return A(n, t, e);
977
+ };
978
+ function w(n) {
979
+ return g(n), l(n < 0 ? 0 : y(n) | 0);
980
+ }
981
+ a.allocUnsafe = function(n) {
982
+ return w(n);
983
+ }, a.allocUnsafeSlow = function(n) {
984
+ return w(n);
985
+ };
986
+ function b(n, t) {
987
+ if ((typeof t != "string" || t === "") && (t = "utf8"), !a.isEncoding(t))
988
+ throw new TypeError("Unknown encoding: " + t);
989
+ var e = k(n, t) | 0, o = l(e), c = o.write(n, t);
990
+ return c !== e && (o = o.slice(0, c)), o;
991
+ }
992
+ function F(n) {
993
+ for (var t = n.length < 0 ? 0 : y(n.length) | 0, e = l(t), o = 0; o < t; o += 1)
994
+ e[o] = n[o] & 255;
995
+ return e;
996
+ }
997
+ function I(n) {
998
+ if (it(n, Uint8Array)) {
999
+ var t = new Uint8Array(n);
1000
+ return G(t.buffer, t.byteOffset, t.byteLength);
1001
+ }
1002
+ return F(n);
1003
+ }
1004
+ function G(n, t, e) {
1005
+ if (t < 0 || n.byteLength < t)
1006
+ throw new RangeError('"offset" is outside of buffer bounds');
1007
+ if (n.byteLength < t + (e || 0))
1008
+ throw new RangeError('"length" is outside of buffer bounds');
1009
+ var o;
1010
+ return t === void 0 && e === void 0 ? o = new Uint8Array(n) : e === void 0 ? o = new Uint8Array(n, t) : o = new Uint8Array(n, t, e), Object.setPrototypeOf(o, a.prototype), o;
1011
+ }
1012
+ function rt(n) {
1013
+ if (a.isBuffer(n)) {
1014
+ var t = y(n.length) | 0, e = l(t);
1015
+ return e.length === 0 || n.copy(e, 0, 0, t), e;
1016
+ }
1017
+ if (n.length !== void 0)
1018
+ return typeof n.length != "number" || Tt(n.length) ? l(0) : F(n);
1019
+ if (n.type === "Buffer" && Array.isArray(n.data))
1020
+ return F(n.data);
1021
+ }
1022
+ function y(n) {
1023
+ if (n >= f)
1024
+ throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + f.toString(16) + " bytes");
1025
+ return n | 0;
1026
+ }
1027
+ function E(n) {
1028
+ return +n != n && (n = 0), a.alloc(+n);
1029
+ }
1030
+ a.isBuffer = function(t) {
1031
+ return t != null && t._isBuffer === !0 && t !== a.prototype;
1032
+ }, a.compare = function(t, e) {
1033
+ if (it(t, Uint8Array) && (t = a.from(t, t.offset, t.byteLength)), it(e, Uint8Array) && (e = a.from(e, e.offset, e.byteLength)), !a.isBuffer(t) || !a.isBuffer(e))
1034
+ throw new TypeError(
1035
+ 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
1036
+ );
1037
+ if (t === e)
1038
+ return 0;
1039
+ for (var o = t.length, c = e.length, m = 0, d = Math.min(o, c); m < d; ++m)
1040
+ if (t[m] !== e[m]) {
1041
+ o = t[m], c = e[m];
1042
+ break;
1043
+ }
1044
+ return o < c ? -1 : c < o ? 1 : 0;
1045
+ }, a.isEncoding = function(t) {
1046
+ switch (String(t).toLowerCase()) {
1047
+ case "hex":
1048
+ case "utf8":
1049
+ case "utf-8":
1050
+ case "ascii":
1051
+ case "latin1":
1052
+ case "binary":
1053
+ case "base64":
1054
+ case "ucs2":
1055
+ case "ucs-2":
1056
+ case "utf16le":
1057
+ case "utf-16le":
1058
+ return !0;
1059
+ default:
1060
+ return !1;
1061
+ }
1062
+ }, a.concat = function(t, e) {
1063
+ if (!Array.isArray(t))
1064
+ throw new TypeError('"list" argument must be an Array of Buffers');
1065
+ if (t.length === 0)
1066
+ return a.alloc(0);
1067
+ var o;
1068
+ if (e === void 0)
1069
+ for (e = 0, o = 0; o < t.length; ++o)
1070
+ e += t[o].length;
1071
+ var c = a.allocUnsafe(e), m = 0;
1072
+ for (o = 0; o < t.length; ++o) {
1073
+ var d = t[o];
1074
+ if (it(d, Uint8Array))
1075
+ m + d.length > c.length ? a.from(d).copy(c, m) : Uint8Array.prototype.set.call(
1076
+ c,
1077
+ d,
1078
+ m
1079
+ );
1080
+ else if (a.isBuffer(d))
1081
+ d.copy(c, m);
1082
+ else
1083
+ throw new TypeError('"list" argument must be an Array of Buffers');
1084
+ m += d.length;
1085
+ }
1086
+ return c;
1087
+ };
1088
+ function k(n, t) {
1089
+ if (a.isBuffer(n))
1090
+ return n.length;
1091
+ if (ArrayBuffer.isView(n) || it(n, ArrayBuffer))
1092
+ return n.byteLength;
1093
+ if (typeof n != "string")
1094
+ throw new TypeError(
1095
+ 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof n
1096
+ );
1097
+ var e = n.length, o = arguments.length > 2 && arguments[2] === !0;
1098
+ if (!o && e === 0)
1099
+ return 0;
1100
+ for (var c = !1; ; )
1101
+ switch (t) {
1102
+ case "ascii":
1103
+ case "latin1":
1104
+ case "binary":
1105
+ return e;
1106
+ case "utf8":
1107
+ case "utf-8":
1108
+ return W(n).length;
1109
+ case "ucs2":
1110
+ case "ucs-2":
1111
+ case "utf16le":
1112
+ case "utf-16le":
1113
+ return e * 2;
1114
+ case "hex":
1115
+ return e >>> 1;
1116
+ case "base64":
1117
+ return st(n).length;
1118
+ default:
1119
+ if (c)
1120
+ return o ? -1 : W(n).length;
1121
+ t = ("" + t).toLowerCase(), c = !0;
1122
+ }
1123
+ }
1124
+ a.byteLength = k;
1125
+ function q(n, t, e) {
1126
+ var o = !1;
1127
+ if ((t === void 0 || t < 0) && (t = 0), t > this.length || ((e === void 0 || e > this.length) && (e = this.length), e <= 0) || (e >>>= 0, t >>>= 0, e <= t))
1128
+ return "";
1129
+ for (n || (n = "utf8"); ; )
1130
+ switch (n) {
1131
+ case "hex":
1132
+ return S(this, t, e);
1133
+ case "utf8":
1134
+ case "utf-8":
1135
+ return h(this, t, e);
1136
+ case "ascii":
1137
+ return j(this, t, e);
1138
+ case "latin1":
1139
+ case "binary":
1140
+ return $(this, t, e);
1141
+ case "base64":
1142
+ return J(this, t, e);
1143
+ case "ucs2":
1144
+ case "ucs-2":
1145
+ case "utf16le":
1146
+ case "utf-16le":
1147
+ return U(this, t, e);
1148
+ default:
1149
+ if (o)
1150
+ throw new TypeError("Unknown encoding: " + n);
1151
+ n = (n + "").toLowerCase(), o = !0;
1152
+ }
1153
+ }
1154
+ a.prototype._isBuffer = !0;
1155
+ function Z(n, t, e) {
1156
+ var o = n[t];
1157
+ n[t] = n[e], n[e] = o;
1158
+ }
1159
+ a.prototype.swap16 = function() {
1160
+ var t = this.length;
1161
+ if (t % 2 !== 0)
1162
+ throw new RangeError("Buffer size must be a multiple of 16-bits");
1163
+ for (var e = 0; e < t; e += 2)
1164
+ Z(this, e, e + 1);
1165
+ return this;
1166
+ }, a.prototype.swap32 = function() {
1167
+ var t = this.length;
1168
+ if (t % 4 !== 0)
1169
+ throw new RangeError("Buffer size must be a multiple of 32-bits");
1170
+ for (var e = 0; e < t; e += 4)
1171
+ Z(this, e, e + 3), Z(this, e + 1, e + 2);
1172
+ return this;
1173
+ }, a.prototype.swap64 = function() {
1174
+ var t = this.length;
1175
+ if (t % 8 !== 0)
1176
+ throw new RangeError("Buffer size must be a multiple of 64-bits");
1177
+ for (var e = 0; e < t; e += 8)
1178
+ Z(this, e, e + 7), Z(this, e + 1, e + 6), Z(this, e + 2, e + 5), Z(this, e + 3, e + 4);
1179
+ return this;
1180
+ }, a.prototype.toString = function() {
1181
+ var t = this.length;
1182
+ return t === 0 ? "" : arguments.length === 0 ? h(this, 0, t) : q.apply(this, arguments);
1183
+ }, a.prototype.toLocaleString = a.prototype.toString, a.prototype.equals = function(t) {
1184
+ if (!a.isBuffer(t))
1185
+ throw new TypeError("Argument must be a Buffer");
1186
+ return this === t ? !0 : a.compare(this, t) === 0;
1187
+ }, a.prototype.inspect = function() {
1188
+ var t = "", e = i.INSPECT_MAX_BYTES;
1189
+ return t = this.toString("hex", 0, e).replace(/(.{2})/g, "$1 ").trim(), this.length > e && (t += " ... "), "<Buffer " + t + ">";
1190
+ }, p && (a.prototype[p] = a.prototype.inspect), a.prototype.compare = function(t, e, o, c, m) {
1191
+ if (it(t, Uint8Array) && (t = a.from(t, t.offset, t.byteLength)), !a.isBuffer(t))
1192
+ throw new TypeError(
1193
+ 'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof t
1194
+ );
1195
+ if (e === void 0 && (e = 0), o === void 0 && (o = t ? t.length : 0), c === void 0 && (c = 0), m === void 0 && (m = this.length), e < 0 || o > t.length || c < 0 || m > this.length)
1196
+ throw new RangeError("out of range index");
1197
+ if (c >= m && e >= o)
1198
+ return 0;
1199
+ if (c >= m)
1200
+ return -1;
1201
+ if (e >= o)
1202
+ return 1;
1203
+ if (e >>>= 0, o >>>= 0, c >>>= 0, m >>>= 0, this === t)
1204
+ return 0;
1205
+ for (var d = m - c, D = o - e, M = Math.min(d, D), L = this.slice(c, m), K = t.slice(e, o), z = 0; z < M; ++z)
1206
+ if (L[z] !== K[z]) {
1207
+ d = L[z], D = K[z];
1208
+ break;
1209
+ }
1210
+ return d < D ? -1 : D < d ? 1 : 0;
1211
+ };
1212
+ function H(n, t, e, o, c) {
1213
+ if (n.length === 0)
1214
+ return -1;
1215
+ if (typeof e == "string" ? (o = e, e = 0) : e > 2147483647 ? e = 2147483647 : e < -2147483648 && (e = -2147483648), e = +e, Tt(e) && (e = c ? 0 : n.length - 1), e < 0 && (e = n.length + e), e >= n.length) {
1216
+ if (c)
1217
+ return -1;
1218
+ e = n.length - 1;
1219
+ } else if (e < 0)
1220
+ if (c)
1221
+ e = 0;
1222
+ else
1223
+ return -1;
1224
+ if (typeof t == "string" && (t = a.from(t, o)), a.isBuffer(t))
1225
+ return t.length === 0 ? -1 : N(n, t, e, o, c);
1226
+ if (typeof t == "number")
1227
+ return t = t & 255, typeof Uint8Array.prototype.indexOf == "function" ? c ? Uint8Array.prototype.indexOf.call(n, t, e) : Uint8Array.prototype.lastIndexOf.call(n, t, e) : N(n, [t], e, o, c);
1228
+ throw new TypeError("val must be string, number or Buffer");
1229
+ }
1230
+ function N(n, t, e, o, c) {
1231
+ var m = 1, d = n.length, D = t.length;
1232
+ if (o !== void 0 && (o = String(o).toLowerCase(), o === "ucs2" || o === "ucs-2" || o === "utf16le" || o === "utf-16le")) {
1233
+ if (n.length < 2 || t.length < 2)
1234
+ return -1;
1235
+ m = 2, d /= 2, D /= 2, e /= 2;
1236
+ }
1237
+ function M(Zt, Gt) {
1238
+ return m === 1 ? Zt[Gt] : Zt.readUInt16BE(Gt * m);
1239
+ }
1240
+ var L;
1241
+ if (c) {
1242
+ var K = -1;
1243
+ for (L = e; L < d; L++)
1244
+ if (M(n, L) === M(t, K === -1 ? 0 : L - K)) {
1245
+ if (K === -1 && (K = L), L - K + 1 === D)
1246
+ return K * m;
1247
+ } else
1248
+ K !== -1 && (L -= L - K), K = -1;
1249
+ } else
1250
+ for (e + D > d && (e = d - D), L = e; L >= 0; L--) {
1251
+ for (var z = !0, vt = 0; vt < D; vt++)
1252
+ if (M(n, L + vt) !== M(t, vt)) {
1253
+ z = !1;
1254
+ break;
1255
+ }
1256
+ if (z)
1257
+ return L;
1258
+ }
1259
+ return -1;
1260
+ }
1261
+ a.prototype.includes = function(t, e, o) {
1262
+ return this.indexOf(t, e, o) !== -1;
1263
+ }, a.prototype.indexOf = function(t, e, o) {
1264
+ return H(this, t, e, o, !0);
1265
+ }, a.prototype.lastIndexOf = function(t, e, o) {
1266
+ return H(this, t, e, o, !1);
1267
+ };
1268
+ function ct(n, t, e, o) {
1269
+ e = Number(e) || 0;
1270
+ var c = n.length - e;
1271
+ o ? (o = Number(o), o > c && (o = c)) : o = c;
1272
+ var m = t.length;
1273
+ o > m / 2 && (o = m / 2);
1274
+ for (var d = 0; d < o; ++d) {
1275
+ var D = parseInt(t.substr(d * 2, 2), 16);
1276
+ if (Tt(D))
1277
+ return d;
1278
+ n[e + d] = D;
1279
+ }
1280
+ return d;
1281
+ }
1282
+ function lt(n, t, e, o) {
1283
+ return Et(W(t, n.length - e), n, e, o);
1284
+ }
1285
+ function ot(n, t, e, o) {
1286
+ return Et(X(t), n, e, o);
1287
+ }
1288
+ function at(n, t, e, o) {
1289
+ return Et(st(t), n, e, o);
1290
+ }
1291
+ function It(n, t, e, o) {
1292
+ return Et(Q(t, n.length - e), n, e, o);
1293
+ }
1294
+ a.prototype.write = function(t, e, o, c) {
1295
+ if (e === void 0)
1296
+ c = "utf8", o = this.length, e = 0;
1297
+ else if (o === void 0 && typeof e == "string")
1298
+ c = e, o = this.length, e = 0;
1299
+ else if (isFinite(e))
1300
+ e = e >>> 0, isFinite(o) ? (o = o >>> 0, c === void 0 && (c = "utf8")) : (c = o, o = void 0);
1301
+ else
1302
+ throw new Error(
1303
+ "Buffer.write(string, encoding, offset[, length]) is no longer supported"
1304
+ );
1305
+ var m = this.length - e;
1306
+ if ((o === void 0 || o > m) && (o = m), t.length > 0 && (o < 0 || e < 0) || e > this.length)
1307
+ throw new RangeError("Attempt to write outside buffer bounds");
1308
+ c || (c = "utf8");
1309
+ for (var d = !1; ; )
1310
+ switch (c) {
1311
+ case "hex":
1312
+ return ct(this, t, e, o);
1313
+ case "utf8":
1314
+ case "utf-8":
1315
+ return lt(this, t, e, o);
1316
+ case "ascii":
1317
+ case "latin1":
1318
+ case "binary":
1319
+ return ot(this, t, e, o);
1320
+ case "base64":
1321
+ return at(this, t, e, o);
1322
+ case "ucs2":
1323
+ case "ucs-2":
1324
+ case "utf16le":
1325
+ case "utf-16le":
1326
+ return It(this, t, e, o);
1327
+ default:
1328
+ if (d)
1329
+ throw new TypeError("Unknown encoding: " + c);
1330
+ c = ("" + c).toLowerCase(), d = !0;
1331
+ }
1332
+ }, a.prototype.toJSON = function() {
1333
+ return {
1334
+ type: "Buffer",
1335
+ data: Array.prototype.slice.call(this._arr || this, 0)
1336
+ };
1337
+ };
1338
+ function J(n, t, e) {
1339
+ return t === 0 && e === n.length ? r.fromByteArray(n) : r.fromByteArray(n.slice(t, e));
1340
+ }
1341
+ function h(n, t, e) {
1342
+ e = Math.min(n.length, e);
1343
+ for (var o = [], c = t; c < e; ) {
1344
+ var m = n[c], d = null, D = m > 239 ? 4 : m > 223 ? 3 : m > 191 ? 2 : 1;
1345
+ if (c + D <= e) {
1346
+ var M, L, K, z;
1347
+ switch (D) {
1348
+ case 1:
1349
+ m < 128 && (d = m);
1350
+ break;
1351
+ case 2:
1352
+ M = n[c + 1], (M & 192) === 128 && (z = (m & 31) << 6 | M & 63, z > 127 && (d = z));
1353
+ break;
1354
+ case 3:
1355
+ M = n[c + 1], L = n[c + 2], (M & 192) === 128 && (L & 192) === 128 && (z = (m & 15) << 12 | (M & 63) << 6 | L & 63, z > 2047 && (z < 55296 || z > 57343) && (d = z));
1356
+ break;
1357
+ case 4:
1358
+ M = n[c + 1], L = n[c + 2], K = n[c + 3], (M & 192) === 128 && (L & 192) === 128 && (K & 192) === 128 && (z = (m & 15) << 18 | (M & 63) << 12 | (L & 63) << 6 | K & 63, z > 65535 && z < 1114112 && (d = z));
1359
+ }
1360
+ }
1361
+ d === null ? (d = 65533, D = 1) : d > 65535 && (d -= 65536, o.push(d >>> 10 & 1023 | 55296), d = 56320 | d & 1023), o.push(d), c += D;
1362
+ }
1363
+ return T(o);
1364
+ }
1365
+ var v = 4096;
1366
+ function T(n) {
1367
+ var t = n.length;
1368
+ if (t <= v)
1369
+ return String.fromCharCode.apply(String, n);
1370
+ for (var e = "", o = 0; o < t; )
1371
+ e += String.fromCharCode.apply(
1372
+ String,
1373
+ n.slice(o, o += v)
1374
+ );
1375
+ return e;
1376
+ }
1377
+ function j(n, t, e) {
1378
+ var o = "";
1379
+ e = Math.min(n.length, e);
1380
+ for (var c = t; c < e; ++c)
1381
+ o += String.fromCharCode(n[c] & 127);
1382
+ return o;
1383
+ }
1384
+ function $(n, t, e) {
1385
+ var o = "";
1386
+ e = Math.min(n.length, e);
1387
+ for (var c = t; c < e; ++c)
1388
+ o += String.fromCharCode(n[c]);
1389
+ return o;
1390
+ }
1391
+ function S(n, t, e) {
1392
+ var o = n.length;
1393
+ (!t || t < 0) && (t = 0), (!e || e < 0 || e > o) && (e = o);
1394
+ for (var c = "", m = t; m < e; ++m)
1395
+ c += De[n[m]];
1396
+ return c;
1397
+ }
1398
+ function U(n, t, e) {
1399
+ for (var o = n.slice(t, e), c = "", m = 0; m < o.length - 1; m += 2)
1400
+ c += String.fromCharCode(o[m] + o[m + 1] * 256);
1401
+ return c;
1402
+ }
1403
+ a.prototype.slice = function(t, e) {
1404
+ var o = this.length;
1405
+ t = ~~t, e = e === void 0 ? o : ~~e, t < 0 ? (t += o, t < 0 && (t = 0)) : t > o && (t = o), e < 0 ? (e += o, e < 0 && (e = 0)) : e > o && (e = o), e < t && (e = t);
1406
+ var c = this.subarray(t, e);
1407
+ return Object.setPrototypeOf(c, a.prototype), c;
1408
+ };
1409
+ function B(n, t, e) {
1410
+ if (n % 1 !== 0 || n < 0)
1411
+ throw new RangeError("offset is not uint");
1412
+ if (n + t > e)
1413
+ throw new RangeError("Trying to access beyond buffer length");
1414
+ }
1415
+ a.prototype.readUintLE = a.prototype.readUIntLE = function(t, e, o) {
1416
+ t = t >>> 0, e = e >>> 0, o || B(t, e, this.length);
1417
+ for (var c = this[t], m = 1, d = 0; ++d < e && (m *= 256); )
1418
+ c += this[t + d] * m;
1419
+ return c;
1420
+ }, a.prototype.readUintBE = a.prototype.readUIntBE = function(t, e, o) {
1421
+ t = t >>> 0, e = e >>> 0, o || B(t, e, this.length);
1422
+ for (var c = this[t + --e], m = 1; e > 0 && (m *= 256); )
1423
+ c += this[t + --e] * m;
1424
+ return c;
1425
+ }, a.prototype.readUint8 = a.prototype.readUInt8 = function(t, e) {
1426
+ return t = t >>> 0, e || B(t, 1, this.length), this[t];
1427
+ }, a.prototype.readUint16LE = a.prototype.readUInt16LE = function(t, e) {
1428
+ return t = t >>> 0, e || B(t, 2, this.length), this[t] | this[t + 1] << 8;
1429
+ }, a.prototype.readUint16BE = a.prototype.readUInt16BE = function(t, e) {
1430
+ return t = t >>> 0, e || B(t, 2, this.length), this[t] << 8 | this[t + 1];
1431
+ }, a.prototype.readUint32LE = a.prototype.readUInt32LE = function(t, e) {
1432
+ return t = t >>> 0, e || B(t, 4, this.length), (this[t] | this[t + 1] << 8 | this[t + 2] << 16) + this[t + 3] * 16777216;
1433
+ }, a.prototype.readUint32BE = a.prototype.readUInt32BE = function(t, e) {
1434
+ return t = t >>> 0, e || B(t, 4, this.length), this[t] * 16777216 + (this[t + 1] << 16 | this[t + 2] << 8 | this[t + 3]);
1435
+ }, a.prototype.readIntLE = function(t, e, o) {
1436
+ t = t >>> 0, e = e >>> 0, o || B(t, e, this.length);
1437
+ for (var c = this[t], m = 1, d = 0; ++d < e && (m *= 256); )
1438
+ c += this[t + d] * m;
1439
+ return m *= 128, c >= m && (c -= Math.pow(2, 8 * e)), c;
1440
+ }, a.prototype.readIntBE = function(t, e, o) {
1441
+ t = t >>> 0, e = e >>> 0, o || B(t, e, this.length);
1442
+ for (var c = e, m = 1, d = this[t + --c]; c > 0 && (m *= 256); )
1443
+ d += this[t + --c] * m;
1444
+ return m *= 128, d >= m && (d -= Math.pow(2, 8 * e)), d;
1445
+ }, a.prototype.readInt8 = function(t, e) {
1446
+ return t = t >>> 0, e || B(t, 1, this.length), this[t] & 128 ? (255 - this[t] + 1) * -1 : this[t];
1447
+ }, a.prototype.readInt16LE = function(t, e) {
1448
+ t = t >>> 0, e || B(t, 2, this.length);
1449
+ var o = this[t] | this[t + 1] << 8;
1450
+ return o & 32768 ? o | 4294901760 : o;
1451
+ }, a.prototype.readInt16BE = function(t, e) {
1452
+ t = t >>> 0, e || B(t, 2, this.length);
1453
+ var o = this[t + 1] | this[t] << 8;
1454
+ return o & 32768 ? o | 4294901760 : o;
1455
+ }, a.prototype.readInt32LE = function(t, e) {
1456
+ return t = t >>> 0, e || B(t, 4, this.length), this[t] | this[t + 1] << 8 | this[t + 2] << 16 | this[t + 3] << 24;
1457
+ }, a.prototype.readInt32BE = function(t, e) {
1458
+ return t = t >>> 0, e || B(t, 4, this.length), this[t] << 24 | this[t + 1] << 16 | this[t + 2] << 8 | this[t + 3];
1459
+ }, a.prototype.readFloatLE = function(t, e) {
1460
+ return t = t >>> 0, e || B(t, 4, this.length), s.read(this, t, !0, 23, 4);
1461
+ }, a.prototype.readFloatBE = function(t, e) {
1462
+ return t = t >>> 0, e || B(t, 4, this.length), s.read(this, t, !1, 23, 4);
1463
+ }, a.prototype.readDoubleLE = function(t, e) {
1464
+ return t = t >>> 0, e || B(t, 8, this.length), s.read(this, t, !0, 52, 8);
1465
+ }, a.prototype.readDoubleBE = function(t, e) {
1466
+ return t = t >>> 0, e || B(t, 8, this.length), s.read(this, t, !1, 52, 8);
1467
+ };
1468
+ function O(n, t, e, o, c, m) {
1469
+ if (!a.isBuffer(n))
1470
+ throw new TypeError('"buffer" argument must be a Buffer instance');
1471
+ if (t > c || t < m)
1472
+ throw new RangeError('"value" argument is out of bounds');
1473
+ if (e + o > n.length)
1474
+ throw new RangeError("Index out of range");
1475
+ }
1476
+ a.prototype.writeUintLE = a.prototype.writeUIntLE = function(t, e, o, c) {
1477
+ if (t = +t, e = e >>> 0, o = o >>> 0, !c) {
1478
+ var m = Math.pow(2, 8 * o) - 1;
1479
+ O(this, t, e, o, m, 0);
1480
+ }
1481
+ var d = 1, D = 0;
1482
+ for (this[e] = t & 255; ++D < o && (d *= 256); )
1483
+ this[e + D] = t / d & 255;
1484
+ return e + o;
1485
+ }, a.prototype.writeUintBE = a.prototype.writeUIntBE = function(t, e, o, c) {
1486
+ if (t = +t, e = e >>> 0, o = o >>> 0, !c) {
1487
+ var m = Math.pow(2, 8 * o) - 1;
1488
+ O(this, t, e, o, m, 0);
1489
+ }
1490
+ var d = o - 1, D = 1;
1491
+ for (this[e + d] = t & 255; --d >= 0 && (D *= 256); )
1492
+ this[e + d] = t / D & 255;
1493
+ return e + o;
1494
+ }, a.prototype.writeUint8 = a.prototype.writeUInt8 = function(t, e, o) {
1495
+ return t = +t, e = e >>> 0, o || O(this, t, e, 1, 255, 0), this[e] = t & 255, e + 1;
1496
+ }, a.prototype.writeUint16LE = a.prototype.writeUInt16LE = function(t, e, o) {
1497
+ return t = +t, e = e >>> 0, o || O(this, t, e, 2, 65535, 0), this[e] = t & 255, this[e + 1] = t >>> 8, e + 2;
1498
+ }, a.prototype.writeUint16BE = a.prototype.writeUInt16BE = function(t, e, o) {
1499
+ return t = +t, e = e >>> 0, o || O(this, t, e, 2, 65535, 0), this[e] = t >>> 8, this[e + 1] = t & 255, e + 2;
1500
+ }, a.prototype.writeUint32LE = a.prototype.writeUInt32LE = function(t, e, o) {
1501
+ return t = +t, e = e >>> 0, o || O(this, t, e, 4, 4294967295, 0), this[e + 3] = t >>> 24, this[e + 2] = t >>> 16, this[e + 1] = t >>> 8, this[e] = t & 255, e + 4;
1502
+ }, a.prototype.writeUint32BE = a.prototype.writeUInt32BE = function(t, e, o) {
1503
+ return t = +t, e = e >>> 0, o || O(this, t, e, 4, 4294967295, 0), this[e] = t >>> 24, this[e + 1] = t >>> 16, this[e + 2] = t >>> 8, this[e + 3] = t & 255, e + 4;
1504
+ }, a.prototype.writeIntLE = function(t, e, o, c) {
1505
+ if (t = +t, e = e >>> 0, !c) {
1506
+ var m = Math.pow(2, 8 * o - 1);
1507
+ O(this, t, e, o, m - 1, -m);
1508
+ }
1509
+ var d = 0, D = 1, M = 0;
1510
+ for (this[e] = t & 255; ++d < o && (D *= 256); )
1511
+ t < 0 && M === 0 && this[e + d - 1] !== 0 && (M = 1), this[e + d] = (t / D >> 0) - M & 255;
1512
+ return e + o;
1513
+ }, a.prototype.writeIntBE = function(t, e, o, c) {
1514
+ if (t = +t, e = e >>> 0, !c) {
1515
+ var m = Math.pow(2, 8 * o - 1);
1516
+ O(this, t, e, o, m - 1, -m);
1517
+ }
1518
+ var d = o - 1, D = 1, M = 0;
1519
+ for (this[e + d] = t & 255; --d >= 0 && (D *= 256); )
1520
+ t < 0 && M === 0 && this[e + d + 1] !== 0 && (M = 1), this[e + d] = (t / D >> 0) - M & 255;
1521
+ return e + o;
1522
+ }, a.prototype.writeInt8 = function(t, e, o) {
1523
+ return t = +t, e = e >>> 0, o || O(this, t, e, 1, 127, -128), t < 0 && (t = 255 + t + 1), this[e] = t & 255, e + 1;
1524
+ }, a.prototype.writeInt16LE = function(t, e, o) {
1525
+ return t = +t, e = e >>> 0, o || O(this, t, e, 2, 32767, -32768), this[e] = t & 255, this[e + 1] = t >>> 8, e + 2;
1526
+ }, a.prototype.writeInt16BE = function(t, e, o) {
1527
+ return t = +t, e = e >>> 0, o || O(this, t, e, 2, 32767, -32768), this[e] = t >>> 8, this[e + 1] = t & 255, e + 2;
1528
+ }, a.prototype.writeInt32LE = function(t, e, o) {
1529
+ return t = +t, e = e >>> 0, o || O(this, t, e, 4, 2147483647, -2147483648), this[e] = t & 255, this[e + 1] = t >>> 8, this[e + 2] = t >>> 16, this[e + 3] = t >>> 24, e + 4;
1530
+ }, a.prototype.writeInt32BE = function(t, e, o) {
1531
+ return t = +t, e = e >>> 0, o || O(this, t, e, 4, 2147483647, -2147483648), t < 0 && (t = 4294967295 + t + 1), this[e] = t >>> 24, this[e + 1] = t >>> 16, this[e + 2] = t >>> 8, this[e + 3] = t & 255, e + 4;
1532
+ };
1533
+ function R(n, t, e, o, c, m) {
1534
+ if (e + o > n.length)
1535
+ throw new RangeError("Index out of range");
1536
+ if (e < 0)
1537
+ throw new RangeError("Index out of range");
1538
+ }
1539
+ function P(n, t, e, o, c) {
1540
+ return t = +t, e = e >>> 0, c || R(n, t, e, 4), s.write(n, t, e, o, 23, 4), e + 4;
1541
+ }
1542
+ a.prototype.writeFloatLE = function(t, e, o) {
1543
+ return P(this, t, e, !0, o);
1544
+ }, a.prototype.writeFloatBE = function(t, e, o) {
1545
+ return P(this, t, e, !1, o);
1546
+ };
1547
+ function C(n, t, e, o, c) {
1548
+ return t = +t, e = e >>> 0, c || R(n, t, e, 8), s.write(n, t, e, o, 52, 8), e + 8;
1549
+ }
1550
+ a.prototype.writeDoubleLE = function(t, e, o) {
1551
+ return C(this, t, e, !0, o);
1552
+ }, a.prototype.writeDoubleBE = function(t, e, o) {
1553
+ return C(this, t, e, !1, o);
1554
+ }, a.prototype.copy = function(t, e, o, c) {
1555
+ if (!a.isBuffer(t))
1556
+ throw new TypeError("argument should be a Buffer");
1557
+ if (o || (o = 0), !c && c !== 0 && (c = this.length), e >= t.length && (e = t.length), e || (e = 0), c > 0 && c < o && (c = o), c === o || t.length === 0 || this.length === 0)
1558
+ return 0;
1559
+ if (e < 0)
1560
+ throw new RangeError("targetStart out of bounds");
1561
+ if (o < 0 || o >= this.length)
1562
+ throw new RangeError("Index out of range");
1563
+ if (c < 0)
1564
+ throw new RangeError("sourceEnd out of bounds");
1565
+ c > this.length && (c = this.length), t.length - e < c - o && (c = t.length - e + o);
1566
+ var m = c - o;
1567
+ return this === t && typeof Uint8Array.prototype.copyWithin == "function" ? this.copyWithin(e, o, c) : Uint8Array.prototype.set.call(
1568
+ t,
1569
+ this.subarray(o, c),
1570
+ e
1571
+ ), m;
1572
+ }, a.prototype.fill = function(t, e, o, c) {
1573
+ if (typeof t == "string") {
1574
+ if (typeof e == "string" ? (c = e, e = 0, o = this.length) : typeof o == "string" && (c = o, o = this.length), c !== void 0 && typeof c != "string")
1575
+ throw new TypeError("encoding must be a string");
1576
+ if (typeof c == "string" && !a.isEncoding(c))
1577
+ throw new TypeError("Unknown encoding: " + c);
1578
+ if (t.length === 1) {
1579
+ var m = t.charCodeAt(0);
1580
+ (c === "utf8" && m < 128 || c === "latin1") && (t = m);
1581
+ }
1582
+ } else
1583
+ typeof t == "number" ? t = t & 255 : typeof t == "boolean" && (t = Number(t));
1584
+ if (e < 0 || this.length < e || this.length < o)
1585
+ throw new RangeError("Out of range index");
1586
+ if (o <= e)
1587
+ return this;
1588
+ e = e >>> 0, o = o === void 0 ? this.length : o >>> 0, t || (t = 0);
1589
+ var d;
1590
+ if (typeof t == "number")
1591
+ for (d = e; d < o; ++d)
1592
+ this[d] = t;
1593
+ else {
1594
+ var D = a.isBuffer(t) ? t : a.from(t, c), M = D.length;
1595
+ if (M === 0)
1596
+ throw new TypeError('The value "' + t + '" is invalid for argument "value"');
1597
+ for (d = 0; d < o - e; ++d)
1598
+ this[d + e] = D[d % M];
1599
+ }
1600
+ return this;
1601
+ };
1602
+ var V = /[^+/0-9A-Za-z-_]/g;
1603
+ function Y(n) {
1604
+ if (n = n.split("=")[0], n = n.trim().replace(V, ""), n.length < 2)
1605
+ return "";
1606
+ for (; n.length % 4 !== 0; )
1607
+ n = n + "=";
1608
+ return n;
1609
+ }
1610
+ function W(n, t) {
1611
+ t = t || 1 / 0;
1612
+ for (var e, o = n.length, c = null, m = [], d = 0; d < o; ++d) {
1613
+ if (e = n.charCodeAt(d), e > 55295 && e < 57344) {
1614
+ if (!c) {
1615
+ if (e > 56319) {
1616
+ (t -= 3) > -1 && m.push(239, 191, 189);
1617
+ continue;
1618
+ } else if (d + 1 === o) {
1619
+ (t -= 3) > -1 && m.push(239, 191, 189);
1620
+ continue;
1621
+ }
1622
+ c = e;
1623
+ continue;
1624
+ }
1625
+ if (e < 56320) {
1626
+ (t -= 3) > -1 && m.push(239, 191, 189), c = e;
1627
+ continue;
1628
+ }
1629
+ e = (c - 55296 << 10 | e - 56320) + 65536;
1630
+ } else
1631
+ c && (t -= 3) > -1 && m.push(239, 191, 189);
1632
+ if (c = null, e < 128) {
1633
+ if ((t -= 1) < 0)
1634
+ break;
1635
+ m.push(e);
1636
+ } else if (e < 2048) {
1637
+ if ((t -= 2) < 0)
1638
+ break;
1639
+ m.push(
1640
+ e >> 6 | 192,
1641
+ e & 63 | 128
1642
+ );
1643
+ } else if (e < 65536) {
1644
+ if ((t -= 3) < 0)
1645
+ break;
1646
+ m.push(
1647
+ e >> 12 | 224,
1648
+ e >> 6 & 63 | 128,
1649
+ e & 63 | 128
1650
+ );
1651
+ } else if (e < 1114112) {
1652
+ if ((t -= 4) < 0)
1653
+ break;
1654
+ m.push(
1655
+ e >> 18 | 240,
1656
+ e >> 12 & 63 | 128,
1657
+ e >> 6 & 63 | 128,
1658
+ e & 63 | 128
1659
+ );
1660
+ } else
1661
+ throw new Error("Invalid code point");
1662
+ }
1663
+ return m;
1664
+ }
1665
+ function X(n) {
1666
+ for (var t = [], e = 0; e < n.length; ++e)
1667
+ t.push(n.charCodeAt(e) & 255);
1668
+ return t;
1669
+ }
1670
+ function Q(n, t) {
1671
+ for (var e, o, c, m = [], d = 0; d < n.length && !((t -= 2) < 0); ++d)
1672
+ e = n.charCodeAt(d), o = e >> 8, c = e % 256, m.push(c), m.push(o);
1673
+ return m;
1674
+ }
1675
+ function st(n) {
1676
+ return r.toByteArray(Y(n));
1677
+ }
1678
+ function Et(n, t, e, o) {
1679
+ for (var c = 0; c < o && !(c + e >= t.length || c >= n.length); ++c)
1680
+ t[c + e] = n[c];
1681
+ return c;
1682
+ }
1683
+ function it(n, t) {
1684
+ return n instanceof t || n != null && n.constructor != null && n.constructor.name != null && n.constructor.name === t.name;
1685
+ }
1686
+ function Tt(n) {
1687
+ return n !== n;
1688
+ }
1689
+ var De = function() {
1690
+ for (var n = "0123456789abcdef", t = new Array(256), e = 0; e < 16; ++e)
1691
+ for (var o = e * 16, c = 0; c < 16; ++c)
1692
+ t[o + c] = n[e] + n[c];
1693
+ return t;
1694
+ }();
1695
+ })(ye);
1696
+ /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
1697
+ (function(i, r) {
1698
+ var s = ye, p = s.Buffer;
1699
+ function f(l, a) {
1700
+ for (var x in l)
1701
+ a[x] = l[x];
1702
+ }
1703
+ p.from && p.alloc && p.allocUnsafe && p.allocUnsafeSlow ? i.exports = s : (f(s, r), r.Buffer = u);
1704
+ function u(l, a, x) {
1705
+ return p(l, a, x);
1706
+ }
1707
+ u.prototype = Object.create(p.prototype), f(p, u), u.from = function(l, a, x) {
1708
+ if (typeof l == "number")
1709
+ throw new TypeError("Argument must not be a number");
1710
+ return p(l, a, x);
1711
+ }, u.alloc = function(l, a, x) {
1712
+ if (typeof l != "number")
1713
+ throw new TypeError("Argument must be a number");
1714
+ var g = p(l);
1715
+ return a !== void 0 ? typeof x == "string" ? g.fill(a, x) : g.fill(a) : g.fill(0), g;
1716
+ }, u.allocUnsafe = function(l) {
1717
+ if (typeof l != "number")
1718
+ throw new TypeError("Argument must be a number");
1719
+ return p(l);
1720
+ }, u.allocUnsafeSlow = function(l) {
1721
+ if (typeof l != "number")
1722
+ throw new TypeError("Argument must be a number");
1723
+ return s.SlowBuffer(l);
1724
+ };
1725
+ })(Ct, Ct.exports);
1726
+ var Wt = Ct.exports, be = Wt.Buffer;
1727
+ function jt(i, r) {
1728
+ this._block = be.alloc(i), this._finalSize = r, this._blockSize = i, this._len = 0;
1729
+ }
1730
+ jt.prototype.update = function(i, r) {
1731
+ typeof i == "string" && (r = r || "utf8", i = be.from(i, r));
1732
+ for (var s = this._block, p = this._blockSize, f = i.length, u = this._len, l = 0; l < f; ) {
1733
+ for (var a = u % p, x = Math.min(f - l, p - a), g = 0; g < x; g++)
1734
+ s[a + g] = i[l + g];
1735
+ u += x, l += x, u % p === 0 && this._update(s);
1736
+ }
1737
+ return this._len += f, this;
1738
+ };
1739
+ jt.prototype.digest = function(i) {
1740
+ var r = this._len % this._blockSize;
1741
+ this._block[r] = 128, this._block.fill(0, r + 1), r >= this._finalSize && (this._update(this._block), this._block.fill(0));
1742
+ var s = this._len * 8;
1743
+ if (s <= 4294967295)
1744
+ this._block.writeUInt32BE(s, this._blockSize - 4);
1745
+ else {
1746
+ var p = (s & 4294967295) >>> 0, f = (s - p) / 4294967296;
1747
+ this._block.writeUInt32BE(f, this._blockSize - 8), this._block.writeUInt32BE(p, this._blockSize - 4);
1748
+ }
1749
+ this._update(this._block);
1750
+ var u = this._hash();
1751
+ return i ? u.toString(i) : u;
1752
+ };
1753
+ jt.prototype._update = function() {
1754
+ throw new Error("_update must be implemented by subclass");
1755
+ };
1756
+ var Ee = jt, fr = ge, ve = Ee, hr = Wt.Buffer, mr = [
1757
+ 1518500249,
1758
+ 1859775393,
1759
+ -1894007588,
1760
+ -899497514
1761
+ ], xr = new Array(80);
1762
+ function wt() {
1763
+ this.init(), this._w = xr, ve.call(this, 64, 56);
1764
+ }
1765
+ fr(wt, ve);
1766
+ wt.prototype.init = function() {
1767
+ return this._a = 1732584193, this._b = 4023233417, this._c = 2562383102, this._d = 271733878, this._e = 3285377520, this;
1768
+ };
1769
+ function dr(i) {
1770
+ return i << 1 | i >>> 31;
1771
+ }
1772
+ function gr(i) {
1773
+ return i << 5 | i >>> 27;
1774
+ }
1775
+ function yr(i) {
1776
+ return i << 30 | i >>> 2;
1777
+ }
1778
+ function wr(i, r, s, p) {
1779
+ return i === 0 ? r & s | ~r & p : i === 2 ? r & s | r & p | s & p : r ^ s ^ p;
1780
+ }
1781
+ wt.prototype._update = function(i) {
1782
+ for (var r = this._w, s = this._a | 0, p = this._b | 0, f = this._c | 0, u = this._d | 0, l = this._e | 0, a = 0; a < 16; ++a)
1783
+ r[a] = i.readInt32BE(a * 4);
1784
+ for (; a < 80; ++a)
1785
+ r[a] = dr(r[a - 3] ^ r[a - 8] ^ r[a - 14] ^ r[a - 16]);
1786
+ for (var x = 0; x < 80; ++x) {
1787
+ var g = ~~(x / 20), A = gr(s) + wr(g, p, f, u) + l + r[x] + mr[g] | 0;
1788
+ l = u, u = f, f = yr(p), p = s, s = A;
1789
+ }
1790
+ this._a = s + this._a | 0, this._b = p + this._b | 0, this._c = f + this._c | 0, this._d = u + this._d | 0, this._e = l + this._e | 0;
1791
+ };
1792
+ wt.prototype._hash = function() {
1793
+ var i = hr.allocUnsafe(20);
1794
+ return i.writeInt32BE(this._a | 0, 0), i.writeInt32BE(this._b | 0, 4), i.writeInt32BE(this._c | 0, 8), i.writeInt32BE(this._d | 0, 12), i.writeInt32BE(this._e | 0, 16), i;
1795
+ };
1796
+ var br = wt;
1797
+ const Er = /* @__PURE__ */ qt(br);
1798
+ var vr = ge, Ae = Ee, Ar = Wt.Buffer, _r = [
1799
+ 1116352408,
1800
+ 1899447441,
1801
+ 3049323471,
1802
+ 3921009573,
1803
+ 961987163,
1804
+ 1508970993,
1805
+ 2453635748,
1806
+ 2870763221,
1807
+ 3624381080,
1808
+ 310598401,
1809
+ 607225278,
1810
+ 1426881987,
1811
+ 1925078388,
1812
+ 2162078206,
1813
+ 2614888103,
1814
+ 3248222580,
1815
+ 3835390401,
1816
+ 4022224774,
1817
+ 264347078,
1818
+ 604807628,
1819
+ 770255983,
1820
+ 1249150122,
1821
+ 1555081692,
1822
+ 1996064986,
1823
+ 2554220882,
1824
+ 2821834349,
1825
+ 2952996808,
1826
+ 3210313671,
1827
+ 3336571891,
1828
+ 3584528711,
1829
+ 113926993,
1830
+ 338241895,
1831
+ 666307205,
1832
+ 773529912,
1833
+ 1294757372,
1834
+ 1396182291,
1835
+ 1695183700,
1836
+ 1986661051,
1837
+ 2177026350,
1838
+ 2456956037,
1839
+ 2730485921,
1840
+ 2820302411,
1841
+ 3259730800,
1842
+ 3345764771,
1843
+ 3516065817,
1844
+ 3600352804,
1845
+ 4094571909,
1846
+ 275423344,
1847
+ 430227734,
1848
+ 506948616,
1849
+ 659060556,
1850
+ 883997877,
1851
+ 958139571,
1852
+ 1322822218,
1853
+ 1537002063,
1854
+ 1747873779,
1855
+ 1955562222,
1856
+ 2024104815,
1857
+ 2227730452,
1858
+ 2361852424,
1859
+ 2428436474,
1860
+ 2756734187,
1861
+ 3204031479,
1862
+ 3329325298
1863
+ ], Sr = new Array(64);
1864
+ function bt() {
1865
+ this.init(), this._w = Sr, Ae.call(this, 64, 56);
1866
+ }
1867
+ vr(bt, Ae);
1868
+ bt.prototype.init = function() {
1869
+ return this._a = 1779033703, this._b = 3144134277, this._c = 1013904242, this._d = 2773480762, this._e = 1359893119, this._f = 2600822924, this._g = 528734635, this._h = 1541459225, this;
1870
+ };
1871
+ function Fr(i, r, s) {
1872
+ return s ^ i & (r ^ s);
1873
+ }
1874
+ function Br(i, r, s) {
1875
+ return i & r | s & (i | r);
1876
+ }
1877
+ function jr(i) {
1878
+ return (i >>> 2 | i << 30) ^ (i >>> 13 | i << 19) ^ (i >>> 22 | i << 10);
1879
+ }
1880
+ function Or(i) {
1881
+ return (i >>> 6 | i << 26) ^ (i >>> 11 | i << 21) ^ (i >>> 25 | i << 7);
1882
+ }
1883
+ function Ir(i) {
1884
+ return (i >>> 7 | i << 25) ^ (i >>> 18 | i << 14) ^ i >>> 3;
1885
+ }
1886
+ function Tr(i) {
1887
+ return (i >>> 17 | i << 15) ^ (i >>> 19 | i << 13) ^ i >>> 10;
1888
+ }
1889
+ bt.prototype._update = function(i) {
1890
+ for (var r = this._w, s = this._a | 0, p = this._b | 0, f = this._c | 0, u = this._d | 0, l = this._e | 0, a = this._f | 0, x = this._g | 0, g = this._h | 0, A = 0; A < 16; ++A)
1891
+ r[A] = i.readInt32BE(A * 4);
1892
+ for (; A < 64; ++A)
1893
+ r[A] = Tr(r[A - 2]) + r[A - 7] + Ir(r[A - 15]) + r[A - 16] | 0;
1894
+ for (var w = 0; w < 64; ++w) {
1895
+ var b = g + Or(l) + Fr(l, a, x) + _r[w] + r[w] | 0, F = jr(s) + Br(s, p, f) | 0;
1896
+ g = x, x = a, a = l, l = u + b | 0, u = f, f = p, p = s, s = b + F | 0;
1897
+ }
1898
+ this._a = s + this._a | 0, this._b = p + this._b | 0, this._c = f + this._c | 0, this._d = u + this._d | 0, this._e = l + this._e | 0, this._f = a + this._f | 0, this._g = x + this._g | 0, this._h = g + this._h | 0;
1899
+ };
1900
+ bt.prototype._hash = function() {
1901
+ var i = Ar.allocUnsafe(32);
1902
+ return i.writeInt32BE(this._a, 0), i.writeInt32BE(this._b, 4), i.writeInt32BE(this._c, 8), i.writeInt32BE(this._d, 12), i.writeInt32BE(this._e, 16), i.writeInt32BE(this._f, 20), i.writeInt32BE(this._g, 24), i.writeInt32BE(this._h, 28), i;
1903
+ };
1904
+ var kr = bt;
1905
+ const Ur = /* @__PURE__ */ qt(kr), Vt = new Error("File system not available.");
1906
+ function Dr(i, r, s) {
1907
+ throw Vt;
1908
+ }
1909
+ function _e(i) {
1910
+ throw Vt;
1911
+ }
1912
+ function $r(i) {
1913
+ throw Vt;
1914
+ }
1915
+ const Cr = async (i) => _e(), Mr = {
1916
+ sha1: Er,
1917
+ sha256: Ur
1918
+ }, Ot = (i, r = "sha1") => {
1919
+ if (!["sha1", "sha256"].includes(r))
1920
+ throw new Error("Hashing algorithm not supported: Available: sha1, sha256");
1921
+ const s = Mr[r];
1922
+ return new s().update(i).digest("base64");
1923
+ };
1924
+ function Nr(i) {
1925
+ return i.type === Ye && i.skip !== void 0 && i.skip > 0 && i.hash !== void 0;
1926
+ }
1927
+ function Yt(i) {
1928
+ return [gt, yt].includes(i.type);
1929
+ }
1930
+ function Xt(i) {
1931
+ return [me, gt, yt, Ft, xe].includes(i.type);
1932
+ }
1933
+ function ht(i, r, s, p, f = "global") {
1934
+ if (!i)
1935
+ throw new Error("Empty action type");
1936
+ if (typeof i != "string")
1937
+ throw new Error(`Invalid action type: ${i}`);
1938
+ const u = { type: i, input: r, scope: f };
1939
+ s && (u.attachments = s);
1940
+ try {
1941
+ p == null || p().parse(u.input);
1942
+ } catch (l) {
1943
+ throw new Error(`Invalid action input: ${l}`);
1944
+ }
1945
+ return u;
1946
+ }
1947
+ function Rr(i, r = de) {
1948
+ return (s, p, f, u) => r(s, p, i, f, u);
1949
+ }
1950
+ const Lr = (i, r) => ({
1951
+ name: "",
1952
+ documentType: "",
1953
+ revision: {
1954
+ global: 0,
1955
+ local: 0
1956
+ },
1957
+ created: (/* @__PURE__ */ new Date()).toISOString(),
1958
+ lastModified: (/* @__PURE__ */ new Date()).toISOString(),
1959
+ attachments: {},
1960
+ ...i,
1961
+ state: (r == null ? void 0 : r(i == null ? void 0 : i.state)) ?? (i == null ? void 0 : i.state) ?? { global: {}, local: {} }
1962
+ }), zr = (i, r) => {
1963
+ const s = Lr(
1964
+ i,
1965
+ r
1966
+ );
1967
+ return {
1968
+ ...s,
1969
+ initialState: s,
1970
+ operations: { global: [], local: [] },
1971
+ clipboard: []
1972
+ };
1973
+ }, Se = (i, r = "global") => Ot(St(i.state[r] || "")), ri = (i, r = 1e3) => {
1974
+ const s = Math.random() * r;
1975
+ return Ot(`${(i ?? /* @__PURE__ */ new Date()).toISOString()}${s}`);
1976
+ };
1977
+ function _t(i) {
1978
+ return Me(Ne(i, !0));
1979
+ }
1980
+ function Pr(i, r) {
1981
+ const s = [...i];
1982
+ let p = r || 0, f = s.length > 0 ? s[s.length - 1].index : 0;
1983
+ const u = [];
1984
+ for (const l of s.reverse()) {
1985
+ if (p > 0) {
1986
+ const g = f - l.index;
1987
+ p -= g;
1988
+ }
1989
+ if (p < 0)
1990
+ throw new Error("Invalid operation index, missing operations");
1991
+ const a = {
1992
+ ignore: p > 0,
1993
+ operation: l
1994
+ }, x = l.skip > 0 ? l.skip + 1 : 0;
1995
+ if (x > 0 && x > p) {
1996
+ const g = x - p;
1997
+ p = p + g;
1998
+ }
1999
+ f = l.index, u.push(a);
2000
+ }
2001
+ return u.reverse();
2002
+ }
2003
+ function qr(i, r, s) {
2004
+ const p = i.slice().sort((a, x) => a.skip - x.skip).sort((a, x) => a.index - x.index);
2005
+ let f = s, u = 0, l = r;
2006
+ for (const a of p.reverse()) {
2007
+ const x = l - a.index;
2008
+ if (f = f - x, f > -1)
2009
+ u++, l = a.index;
2010
+ else
2011
+ break;
2012
+ }
2013
+ return u;
2014
+ }
2015
+ function ii(i) {
2016
+ return Object.values(i).flatMap((r) => r).sort(
2017
+ (r, s) => new Date(r.timestamp).getTime() - new Date(s.timestamp).getTime()
2018
+ );
2019
+ }
2020
+ function Jr(i) {
2021
+ return Object.values(i).flatMap((r) => r).sort(
2022
+ (r, s) => new Date(r.operation.timestamp).getTime() - new Date(s.operation.timestamp).getTime()
2023
+ );
2024
+ }
2025
+ function Mt(i, r, s, p, f, u = de, l = {}) {
2026
+ const a = Rr(s, u);
2027
+ return Fe(
2028
+ i,
2029
+ r,
2030
+ a,
2031
+ p,
2032
+ f,
2033
+ l
2034
+ );
2035
+ }
2036
+ function Fe(i, r, s, p, f, u = {}) {
2037
+ const l = zr(i), a = Object.keys(r).reduce((b, F) => {
2038
+ const I = F;
2039
+ return {
2040
+ ...b,
2041
+ [I]: r[I].slice(0, f == null ? void 0 : f.revision[I])
2042
+ };
2043
+ }, {}), x = Object.keys(a).reduce(
2044
+ (b, F) => {
2045
+ const I = F;
2046
+ return {
2047
+ ...b,
2048
+ [I]: Pr(
2049
+ a[I],
2050
+ u[I]
2051
+ )
2052
+ };
2053
+ },
2054
+ {}
2055
+ ), g = Jr(x).reduce(
2056
+ (b, { ignore: F, operation: I }) => F ? s(b, Ht(I.scope), p, {
2057
+ skip: I.skip,
2058
+ ignoreSkipOperations: !0
2059
+ }) : s(b, I, p, {
2060
+ skip: I.skip,
2061
+ ignoreSkipOperations: !0
2062
+ }),
2063
+ l
2064
+ ), A = Object.keys(
2065
+ g.operations
2066
+ ).reduce(
2067
+ (b, F) => {
2068
+ const I = F, G = f && f.revision[I] < r[I].length ? r[I].slice(f.revision[I]) : [];
2069
+ return {
2070
+ ...b,
2071
+ [I]: [
2072
+ ...g.operations[I].map((rt, y) => {
2073
+ var E;
2074
+ return {
2075
+ ...rt,
2076
+ timestamp: ((E = r[I][y]) == null ? void 0 : E.timestamp) ?? rt.timestamp
2077
+ };
2078
+ }),
2079
+ ...G
2080
+ ]
2081
+ };
2082
+ },
2083
+ { global: [], local: [] }
2084
+ ), w = Object.values(A).reduce((b, F) => {
2085
+ for (const I of F)
2086
+ I.timestamp > b && (b = I.timestamp);
2087
+ return b;
2088
+ }, i.lastModified);
2089
+ return { ...g, operations: A, lastModified: w };
2090
+ }
2091
+ function ni(i, r) {
2092
+ return St(i) === St(r);
2093
+ }
2094
+ const Be = (i) => ht(
2095
+ "SET_NAME",
2096
+ i,
2097
+ void 0,
2098
+ zt,
2099
+ void 0
2100
+ ), je = (i = 1, r = "global") => ht(
2101
+ "UNDO",
2102
+ i,
2103
+ void 0,
2104
+ Pt,
2105
+ r
2106
+ ), Oe = (i = 1, r = "global") => ht(
2107
+ "REDO",
2108
+ i,
2109
+ void 0,
2110
+ Lt,
2111
+ r
2112
+ ), Ie = (i, r, s = "global") => ht(
2113
+ "PRUNE",
2114
+ { start: i, end: r },
2115
+ void 0,
2116
+ Rt,
2117
+ s
2118
+ ), Kt = (i, r) => ht(
2119
+ "LOAD_STATE",
2120
+ { state: i, operations: r },
2121
+ void 0,
2122
+ Nt
2123
+ ), Ht = (i = "global") => ht("NOOP", {}, void 0, void 0, i), oi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2124
+ __proto__: null,
2125
+ loadState: Kt,
2126
+ noop: Ht,
2127
+ prune: Ie,
2128
+ redo: Oe,
2129
+ setName: Be,
2130
+ undo: je
2131
+ }, Symbol.toStringTag, { value: "Module" })), Te = { "application/andrew-inset": ["ez"], "application/appinstaller": ["appinstaller"], "application/applixware": ["aw"], "application/appx": ["appx"], "application/appxbundle": ["appxbundle"], "application/atom+xml": ["atom"], "application/atomcat+xml": ["atomcat"], "application/atomdeleted+xml": ["atomdeleted"], "application/atomsvc+xml": ["atomsvc"], "application/atsc-dwd+xml": ["dwd"], "application/atsc-held+xml": ["held"], "application/atsc-rsat+xml": ["rsat"], "application/automationml-aml+xml": ["aml"], "application/automationml-amlx+zip": ["amlx"], "application/bdoc": ["bdoc"], "application/calendar+xml": ["xcs"], "application/ccxml+xml": ["ccxml"], "application/cdfx+xml": ["cdfx"], "application/cdmi-capability": ["cdmia"], "application/cdmi-container": ["cdmic"], "application/cdmi-domain": ["cdmid"], "application/cdmi-object": ["cdmio"], "application/cdmi-queue": ["cdmiq"], "application/cpl+xml": ["cpl"], "application/cu-seeme": ["cu"], "application/cwl": ["cwl"], "application/dash+xml": ["mpd"], "application/dash-patch+xml": ["mpp"], "application/davmount+xml": ["davmount"], "application/docbook+xml": ["dbk"], "application/dssc+der": ["dssc"], "application/dssc+xml": ["xdssc"], "application/ecmascript": ["ecma"], "application/emma+xml": ["emma"], "application/emotionml+xml": ["emotionml"], "application/epub+zip": ["epub"], "application/exi": ["exi"], "application/express": ["exp"], "application/fdf": ["fdf"], "application/fdt+xml": ["fdt"], "application/font-tdpfr": ["pfr"], "application/geo+json": ["geojson"], "application/gml+xml": ["gml"], "application/gpx+xml": ["gpx"], "application/gxf": ["gxf"], "application/gzip": ["gz"], "application/hjson": ["hjson"], "application/hyperstudio": ["stk"], "application/inkml+xml": ["ink", "inkml"], "application/ipfix": ["ipfix"], "application/its+xml": ["its"], "application/java-archive": ["jar", "war", "ear"], "application/java-serialized-object": ["ser"], "application/java-vm": ["class"], "application/javascript": ["*js"], "application/json": ["json", "map"], "application/json5": ["json5"], "application/jsonml+json": ["jsonml"], "application/ld+json": ["jsonld"], "application/lgr+xml": ["lgr"], "application/lost+xml": ["lostxml"], "application/mac-binhex40": ["hqx"], "application/mac-compactpro": ["cpt"], "application/mads+xml": ["mads"], "application/manifest+json": ["webmanifest"], "application/marc": ["mrc"], "application/marcxml+xml": ["mrcx"], "application/mathematica": ["ma", "nb", "mb"], "application/mathml+xml": ["mathml"], "application/mbox": ["mbox"], "application/media-policy-dataset+xml": ["mpf"], "application/mediaservercontrol+xml": ["mscml"], "application/metalink+xml": ["metalink"], "application/metalink4+xml": ["meta4"], "application/mets+xml": ["mets"], "application/mmt-aei+xml": ["maei"], "application/mmt-usd+xml": ["musd"], "application/mods+xml": ["mods"], "application/mp21": ["m21", "mp21"], "application/mp4": ["*mp4", "*mpg4", "mp4s", "m4p"], "application/msix": ["msix"], "application/msixbundle": ["msixbundle"], "application/msword": ["doc", "dot"], "application/mxf": ["mxf"], "application/n-quads": ["nq"], "application/n-triples": ["nt"], "application/node": ["cjs"], "application/octet-stream": ["bin", "dms", "lrf", "mar", "so", "dist", "distz", "pkg", "bpk", "dump", "elc", "deploy", "exe", "dll", "deb", "dmg", "iso", "img", "msi", "msp", "msm", "buffer"], "application/oda": ["oda"], "application/oebps-package+xml": ["opf"], "application/ogg": ["ogx"], "application/omdoc+xml": ["omdoc"], "application/onenote": ["onetoc", "onetoc2", "onetmp", "onepkg"], "application/oxps": ["oxps"], "application/p2p-overlay+xml": ["relo"], "application/patch-ops-error+xml": ["xer"], "application/pdf": ["pdf"], "application/pgp-encrypted": ["pgp"], "application/pgp-keys": ["asc"], "application/pgp-signature": ["sig", "*asc"], "application/pics-rules": ["prf"], "application/pkcs10": ["p10"], "application/pkcs7-mime": ["p7m", "p7c"], "application/pkcs7-signature": ["p7s"], "application/pkcs8": ["p8"], "application/pkix-attr-cert": ["ac"], "application/pkix-cert": ["cer"], "application/pkix-crl": ["crl"], "application/pkix-pkipath": ["pkipath"], "application/pkixcmp": ["pki"], "application/pls+xml": ["pls"], "application/postscript": ["ai", "eps", "ps"], "application/provenance+xml": ["provx"], "application/pskc+xml": ["pskcxml"], "application/raml+yaml": ["raml"], "application/rdf+xml": ["rdf", "owl"], "application/reginfo+xml": ["rif"], "application/relax-ng-compact-syntax": ["rnc"], "application/resource-lists+xml": ["rl"], "application/resource-lists-diff+xml": ["rld"], "application/rls-services+xml": ["rs"], "application/route-apd+xml": ["rapd"], "application/route-s-tsid+xml": ["sls"], "application/route-usd+xml": ["rusd"], "application/rpki-ghostbusters": ["gbr"], "application/rpki-manifest": ["mft"], "application/rpki-roa": ["roa"], "application/rsd+xml": ["rsd"], "application/rss+xml": ["rss"], "application/rtf": ["rtf"], "application/sbml+xml": ["sbml"], "application/scvp-cv-request": ["scq"], "application/scvp-cv-response": ["scs"], "application/scvp-vp-request": ["spq"], "application/scvp-vp-response": ["spp"], "application/sdp": ["sdp"], "application/senml+xml": ["senmlx"], "application/sensml+xml": ["sensmlx"], "application/set-payment-initiation": ["setpay"], "application/set-registration-initiation": ["setreg"], "application/shf+xml": ["shf"], "application/sieve": ["siv", "sieve"], "application/smil+xml": ["smi", "smil"], "application/sparql-query": ["rq"], "application/sparql-results+xml": ["srx"], "application/sql": ["sql"], "application/srgs": ["gram"], "application/srgs+xml": ["grxml"], "application/sru+xml": ["sru"], "application/ssdl+xml": ["ssdl"], "application/ssml+xml": ["ssml"], "application/swid+xml": ["swidtag"], "application/tei+xml": ["tei", "teicorpus"], "application/thraud+xml": ["tfi"], "application/timestamped-data": ["tsd"], "application/toml": ["toml"], "application/trig": ["trig"], "application/ttml+xml": ["ttml"], "application/ubjson": ["ubj"], "application/urc-ressheet+xml": ["rsheet"], "application/urc-targetdesc+xml": ["td"], "application/voicexml+xml": ["vxml"], "application/wasm": ["wasm"], "application/watcherinfo+xml": ["wif"], "application/widget": ["wgt"], "application/winhlp": ["hlp"], "application/wsdl+xml": ["wsdl"], "application/wspolicy+xml": ["wspolicy"], "application/xaml+xml": ["xaml"], "application/xcap-att+xml": ["xav"], "application/xcap-caps+xml": ["xca"], "application/xcap-diff+xml": ["xdf"], "application/xcap-el+xml": ["xel"], "application/xcap-ns+xml": ["xns"], "application/xenc+xml": ["xenc"], "application/xfdf": ["xfdf"], "application/xhtml+xml": ["xhtml", "xht"], "application/xliff+xml": ["xlf"], "application/xml": ["xml", "xsl", "xsd", "rng"], "application/xml-dtd": ["dtd"], "application/xop+xml": ["xop"], "application/xproc+xml": ["xpl"], "application/xslt+xml": ["*xsl", "xslt"], "application/xspf+xml": ["xspf"], "application/xv+xml": ["mxml", "xhvml", "xvml", "xvm"], "application/yang": ["yang"], "application/yin+xml": ["yin"], "application/zip": ["zip"], "audio/3gpp": ["*3gpp"], "audio/aac": ["adts", "aac"], "audio/adpcm": ["adp"], "audio/amr": ["amr"], "audio/basic": ["au", "snd"], "audio/midi": ["mid", "midi", "kar", "rmi"], "audio/mobile-xmf": ["mxmf"], "audio/mp3": ["*mp3"], "audio/mp4": ["m4a", "mp4a"], "audio/mpeg": ["mpga", "mp2", "mp2a", "mp3", "m2a", "m3a"], "audio/ogg": ["oga", "ogg", "spx", "opus"], "audio/s3m": ["s3m"], "audio/silk": ["sil"], "audio/wav": ["wav"], "audio/wave": ["*wav"], "audio/webm": ["weba"], "audio/xm": ["xm"], "font/collection": ["ttc"], "font/otf": ["otf"], "font/ttf": ["ttf"], "font/woff": ["woff"], "font/woff2": ["woff2"], "image/aces": ["exr"], "image/apng": ["apng"], "image/avci": ["avci"], "image/avcs": ["avcs"], "image/avif": ["avif"], "image/bmp": ["bmp", "dib"], "image/cgm": ["cgm"], "image/dicom-rle": ["drle"], "image/dpx": ["dpx"], "image/emf": ["emf"], "image/fits": ["fits"], "image/g3fax": ["g3"], "image/gif": ["gif"], "image/heic": ["heic"], "image/heic-sequence": ["heics"], "image/heif": ["heif"], "image/heif-sequence": ["heifs"], "image/hej2k": ["hej2"], "image/hsj2": ["hsj2"], "image/ief": ["ief"], "image/jls": ["jls"], "image/jp2": ["jp2", "jpg2"], "image/jpeg": ["jpeg", "jpg", "jpe"], "image/jph": ["jph"], "image/jphc": ["jhc"], "image/jpm": ["jpm", "jpgm"], "image/jpx": ["jpx", "jpf"], "image/jxr": ["jxr"], "image/jxra": ["jxra"], "image/jxrs": ["jxrs"], "image/jxs": ["jxs"], "image/jxsc": ["jxsc"], "image/jxsi": ["jxsi"], "image/jxss": ["jxss"], "image/ktx": ["ktx"], "image/ktx2": ["ktx2"], "image/png": ["png"], "image/sgi": ["sgi"], "image/svg+xml": ["svg", "svgz"], "image/t38": ["t38"], "image/tiff": ["tif", "tiff"], "image/tiff-fx": ["tfx"], "image/webp": ["webp"], "image/wmf": ["wmf"], "message/disposition-notification": ["disposition-notification"], "message/global": ["u8msg"], "message/global-delivery-status": ["u8dsn"], "message/global-disposition-notification": ["u8mdn"], "message/global-headers": ["u8hdr"], "message/rfc822": ["eml", "mime"], "model/3mf": ["3mf"], "model/gltf+json": ["gltf"], "model/gltf-binary": ["glb"], "model/iges": ["igs", "iges"], "model/jt": ["jt"], "model/mesh": ["msh", "mesh", "silo"], "model/mtl": ["mtl"], "model/obj": ["obj"], "model/prc": ["prc"], "model/step+xml": ["stpx"], "model/step+zip": ["stpz"], "model/step-xml+zip": ["stpxz"], "model/stl": ["stl"], "model/u3d": ["u3d"], "model/vrml": ["wrl", "vrml"], "model/x3d+binary": ["*x3db", "x3dbz"], "model/x3d+fastinfoset": ["x3db"], "model/x3d+vrml": ["*x3dv", "x3dvz"], "model/x3d+xml": ["x3d", "x3dz"], "model/x3d-vrml": ["x3dv"], "text/cache-manifest": ["appcache", "manifest"], "text/calendar": ["ics", "ifb"], "text/coffeescript": ["coffee", "litcoffee"], "text/css": ["css"], "text/csv": ["csv"], "text/html": ["html", "htm", "shtml"], "text/jade": ["jade"], "text/javascript": ["js", "mjs"], "text/jsx": ["jsx"], "text/less": ["less"], "text/markdown": ["md", "markdown"], "text/mathml": ["mml"], "text/mdx": ["mdx"], "text/n3": ["n3"], "text/plain": ["txt", "text", "conf", "def", "list", "log", "in", "ini"], "text/richtext": ["rtx"], "text/rtf": ["*rtf"], "text/sgml": ["sgml", "sgm"], "text/shex": ["shex"], "text/slim": ["slim", "slm"], "text/spdx": ["spdx"], "text/stylus": ["stylus", "styl"], "text/tab-separated-values": ["tsv"], "text/troff": ["t", "tr", "roff", "man", "me", "ms"], "text/turtle": ["ttl"], "text/uri-list": ["uri", "uris", "urls"], "text/vcard": ["vcard"], "text/vtt": ["vtt"], "text/wgsl": ["wgsl"], "text/xml": ["*xml"], "text/yaml": ["yaml", "yml"], "video/3gpp": ["3gp", "3gpp"], "video/3gpp2": ["3g2"], "video/h261": ["h261"], "video/h263": ["h263"], "video/h264": ["h264"], "video/iso.segment": ["m4s"], "video/jpeg": ["jpgv"], "video/jpm": ["*jpm", "*jpgm"], "video/mj2": ["mj2", "mjp2"], "video/mp2t": ["ts"], "video/mp4": ["mp4", "mp4v", "mpg4"], "video/mpeg": ["mpeg", "mpg", "mpe", "m1v", "m2v"], "video/ogg": ["ogv"], "video/quicktime": ["qt", "mov"], "video/webm": ["webm"] };
2132
+ Object.freeze(Te);
2133
+ var tt = function(i, r, s, p) {
2134
+ if (s === "a" && !p)
2135
+ throw new TypeError("Private accessor was defined without a getter");
2136
+ if (typeof r == "function" ? i !== r || !p : !r.has(i))
2137
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
2138
+ return s === "m" ? p : s === "a" ? p.call(i) : p ? p.value : r.get(i);
2139
+ }, ft, mt, pt;
2140
+ class Wr {
2141
+ constructor(...r) {
2142
+ ft.set(this, /* @__PURE__ */ new Map()), mt.set(this, /* @__PURE__ */ new Map()), pt.set(this, /* @__PURE__ */ new Map());
2143
+ for (const s of r)
2144
+ this.define(s);
2145
+ }
2146
+ define(r, s = !1) {
2147
+ for (let [p, f] of Object.entries(r)) {
2148
+ p = p.toLowerCase(), f = f.map((a) => a.toLowerCase()), tt(this, pt, "f").has(p) || tt(this, pt, "f").set(p, /* @__PURE__ */ new Set());
2149
+ const u = tt(this, pt, "f").get(p);
2150
+ let l = !0;
2151
+ for (let a of f) {
2152
+ const x = a.startsWith("*");
2153
+ if (a = x ? a.slice(1) : a, u == null || u.add(a), l && tt(this, mt, "f").set(p, a), l = !1, x)
2154
+ continue;
2155
+ const g = tt(this, ft, "f").get(a);
2156
+ if (g && g != p && !s)
2157
+ throw new Error(`"${p} -> ${a}" conflicts with "${g} -> ${a}". Pass \`force=true\` to override this definition.`);
2158
+ tt(this, ft, "f").set(a, p);
2159
+ }
2160
+ }
2161
+ return this;
2162
+ }
2163
+ getType(r) {
2164
+ if (typeof r != "string")
2165
+ return null;
2166
+ const s = r.replace(/^.*[/\\]/, "").toLowerCase(), p = s.replace(/^.*\./, "").toLowerCase(), f = s.length < r.length;
2167
+ return !(p.length < s.length - 1) && f ? null : tt(this, ft, "f").get(p) ?? null;
2168
+ }
2169
+ getExtension(r) {
2170
+ var s;
2171
+ return typeof r != "string" ? null : (r = (s = r == null ? void 0 : r.split) == null ? void 0 : s.call(r, ";")[0], (r && tt(this, mt, "f").get(r.trim().toLowerCase())) ?? null);
2172
+ }
2173
+ getAllExtensions(r) {
2174
+ return typeof r != "string" ? null : tt(this, pt, "f").get(r.toLowerCase()) ?? null;
2175
+ }
2176
+ _freeze() {
2177
+ this.define = () => {
2178
+ throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances");
2179
+ }, Object.freeze(this);
2180
+ for (const r of tt(this, pt, "f").values())
2181
+ Object.freeze(r);
2182
+ return this;
2183
+ }
2184
+ _getTestState() {
2185
+ return {
2186
+ types: tt(this, ft, "f"),
2187
+ extensions: tt(this, mt, "f")
2188
+ };
2189
+ }
2190
+ }
2191
+ ft = /* @__PURE__ */ new WeakMap(), mt = /* @__PURE__ */ new WeakMap(), pt = /* @__PURE__ */ new WeakMap();
2192
+ const Vr = new Wr(Te)._freeze();
2193
+ function Kr(i) {
2194
+ const r = [], s = Object.keys(i);
2195
+ for (const p of s) {
2196
+ const f = i[p].sort((u, l) => u.index - l.index);
2197
+ for (let u = 0; u < f.length; u++)
2198
+ f[u].index !== u && r.push({
2199
+ message: `Invalid operation index ${f[u].index} at position ${u}`,
2200
+ details: {
2201
+ position: u,
2202
+ operation: f[u],
2203
+ scope: f[u].scope
2204
+ }
2205
+ });
2206
+ }
2207
+ return r;
2208
+ }
2209
+ const ke = async (i) => {
2210
+ const r = new te(), { name: s, revision: p, documentType: f, created: u, lastModified: l } = i, a = {
2211
+ name: s,
2212
+ revision: p,
2213
+ documentType: f,
2214
+ created: u,
2215
+ lastModified: l
2216
+ };
2217
+ return r.file("header.json", JSON.stringify(a, null, 2)), r.file(
2218
+ "state.json",
2219
+ JSON.stringify(i.initialState || {}, null, 2)
2220
+ ), r.file("operations.json", JSON.stringify(i.operations, null, 2)), Object.keys(i.attachments).forEach((g) => {
2221
+ const { data: A, ...w } = i.attachments[g];
2222
+ r.file(g, A, {
2223
+ base64: !0,
2224
+ createFolders: !0,
2225
+ comment: JSON.stringify(w)
2226
+ });
2227
+ }), r;
2228
+ }, Hr = async (i, r, s, p) => {
2229
+ await (await ke(i)).generateAsync({
2230
+ type: "uint8array",
2231
+ streamFiles: !0
2232
+ });
2233
+ const u = p ?? i.name, l = `.${s}.zip`;
2234
+ return Dr(
2235
+ r,
2236
+ u.endsWith(l) ? u : `${u}${l}`
2237
+ );
2238
+ }, ai = async (i, r) => {
2239
+ const p = await (await ke(i)).generateAsync({ type: "blob" }), f = await r.createWritable();
2240
+ await f.write(p), await f.close();
2241
+ }, Qt = async (i, r) => {
2242
+ const s = _e();
2243
+ return Zr(s, r);
2244
+ }, Zr = async (i, r) => {
2245
+ const s = new te();
2246
+ return await s.loadAsync(i), Gr(s, r);
2247
+ };
2248
+ async function Gr(i, r) {
2249
+ const s = i.file("state.json");
2250
+ if (!s)
2251
+ throw new Error("Initial state not found");
2252
+ const p = await s.async("string"), f = JSON.parse(p), u = i.file("header.json");
2253
+ let l;
2254
+ u && (l = JSON.parse(await u.async("string")));
2255
+ const a = i.file("operations.json");
2256
+ if (!a)
2257
+ throw new Error("Operations history not found");
2258
+ const x = JSON.parse(
2259
+ await a.async("string")
2260
+ ), g = Kr(x);
2261
+ if (g.length) {
2262
+ const w = g.map((b) => b.message);
2263
+ throw new Error(w.join(`
2264
+ `));
2265
+ }
2266
+ let A = Fe(
2267
+ f,
2268
+ x,
2269
+ r,
2270
+ void 0,
2271
+ l
2272
+ );
2273
+ return l && (A = {
2274
+ ...A,
2275
+ ...l
2276
+ }), A;
2277
+ }
2278
+ function Ue(i) {
2279
+ const r = i.replace(/^.*\./, "") || void 0, s = i.replace(/^.*[/\\]/, "") || void 0;
2280
+ return { extension: r, fileName: s };
2281
+ }
2282
+ async function si(i) {
2283
+ const { buffer: r, mimeType: s = "application/octet-stream" } = await $r(), p = Ue(i), f = r.toString("base64");
2284
+ return {
2285
+ data: f,
2286
+ hash: Ot(f),
2287
+ mimeType: s,
2288
+ ...p
2289
+ };
2290
+ }
2291
+ async function pi(i) {
2292
+ const r = await Cr(), s = Vr.getType(i) || "application/octet-stream", p = Ue(i), f = r.toString("base64");
2293
+ return { data: f, hash: Ot(f), mimeType: s, ...p };
2294
+ }
2295
+ class ci {
2296
+ /**
2297
+ * Constructs a BaseDocument instance with an initial state.
2298
+ * @param reducer - The reducer function that updates the state.
2299
+ * @param document - The initial state of the document.
2300
+ */
2301
+ constructor(r, s, p) {
2302
+ At(this, "_document");
2303
+ At(this, "_reducer");
2304
+ At(this, "_signalDispatch");
2305
+ this._reducer = r, this._document = s, this._signalDispatch = p;
2306
+ }
2307
+ /**
2308
+ * Dispatches an action to update the state of the document.
2309
+ * @param action - The action to dispatch.
2310
+ * @returns The Document instance.
2311
+ */
2312
+ dispatch(r, s) {
2313
+ return this._document = this._reducer(
2314
+ this._document,
2315
+ r,
2316
+ this._signalDispatch,
2317
+ s
2318
+ ), this;
2319
+ }
2320
+ /**
2321
+ * Saves the state of the document to a file.
2322
+ * @param path - The file path where the state should be saved.
2323
+ * @param extension - The file extension to use when saving the state.
2324
+ * @returns The file path where the state was saved.
2325
+ */
2326
+ saveToFile(r, s, p) {
2327
+ return Hr(this._document, r, s, p);
2328
+ }
2329
+ /**
2330
+ * Loads the state of the document from a file.
2331
+ * @param path - The file path where the state is stored.
2332
+ */
2333
+ async loadFromFile(r) {
2334
+ this._document = await Qt(r, this._reducer);
2335
+ }
2336
+ /**
2337
+ * Loads the state of the document from a file and returns it.
2338
+ * @param path - The file path where the state is stored.
2339
+ * @param reducer - The reducer function that updates the state.
2340
+ * @returns The state of the document.
2341
+ */
2342
+ static async stateFromFile(r, s) {
2343
+ return await Qt(r, s);
2344
+ }
2345
+ /**
2346
+ * Gets the current state of the document.
2347
+ */
2348
+ get state() {
2349
+ return _t(this._document.state);
2350
+ }
2351
+ /**
2352
+ * Gets the list of operations performed on the document.
2353
+ */
2354
+ get operations() {
2355
+ return _t(this._document.operations);
2356
+ }
2357
+ /**
2358
+ * Gets the name of the document.
2359
+ */
2360
+ get name() {
2361
+ return this._document.name;
2362
+ }
2363
+ /**
2364
+ * Gets the type of document.
2365
+ */
2366
+ get documentType() {
2367
+ return this._document.documentType;
2368
+ }
2369
+ /**
2370
+ * Gets the timestamp of the date the document was created.
2371
+ */
2372
+ get created() {
2373
+ return this._document.created;
2374
+ }
2375
+ /**
2376
+ * Gets the timestamp of the date the document was last modified.
2377
+ */
2378
+ get lastModified() {
2379
+ return this._document.lastModified;
2380
+ }
2381
+ /**
2382
+ * Gets the global revision number of the document.
2383
+ */
2384
+ get revision() {
2385
+ return this._document.revision.global;
2386
+ }
2387
+ getRevision(r) {
2388
+ return this._document.revision[r];
2389
+ }
2390
+ /**
2391
+ * Gets the initial state of the document.
2392
+ */
2393
+ get initialState() {
2394
+ return _t(this._document.initialState);
2395
+ }
2396
+ /**
2397
+ * Returns the current document as an object
2398
+ */
2399
+ toDocument() {
2400
+ return _t(this._document);
2401
+ }
2402
+ /**
2403
+ * Gets the attachment associated with the given key.
2404
+ * @param attachment - The key of the attachment to retrieve.
2405
+ */
2406
+ getAttachment(r) {
2407
+ return this._document.attachments[r];
2408
+ }
2409
+ /**
2410
+ * Sets the name of the document.
2411
+ * @param name - The new name of the document.
2412
+ */
2413
+ setName(r) {
2414
+ return this.dispatch(Be(r)), this;
2415
+ }
2416
+ /**
2417
+ * Reverts a number of actions from the document.
2418
+ * @param count - The number of actions to revert.
2419
+ */
2420
+ undo(r) {
2421
+ return this.dispatch(je(r)), this;
2422
+ }
2423
+ /**
2424
+ * Reapplies a number of actions to the document.
2425
+ * @param count - The number of actions to reapply.
2426
+ */
2427
+ redo(r) {
2428
+ return this.dispatch(Oe(r)), this;
2429
+ }
2430
+ /**
2431
+ * Removes a range of operations from the document.
2432
+ * @param start - The starting index of the range to remove.
2433
+ * @param end - The ending index of the range to remove.
2434
+ */
2435
+ prune(r, s) {
2436
+ return this.dispatch(Ie(r, s)), this;
2437
+ }
2438
+ /**
2439
+ * Loads a document state and a set of operations.
2440
+ * @param state - The state to load.
2441
+ * @param operations - The operations to apply to the document.
2442
+ */
2443
+ loadState(r, s) {
2444
+ return this.dispatch(Kt(r, s)), this;
2445
+ }
2446
+ }
2447
+ function li(i, r) {
2448
+ r.forEach((s) => {
2449
+ Object.getOwnPropertyNames(s.prototype).forEach((p) => {
2450
+ Object.defineProperty(
2451
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
2452
+ i.prototype,
2453
+ p,
2454
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
2455
+ Object.getOwnPropertyDescriptor(s.prototype, p) || /* @__PURE__ */ Object.create(null)
2456
+ );
2457
+ });
2458
+ });
2459
+ }
2460
+ export {
2461
+ Kr as A,
2462
+ ci as B,
2463
+ de as C,
2464
+ ir as D,
2465
+ ei as E,
2466
+ Lr as a,
2467
+ zr as b,
2468
+ Rr as c,
2469
+ ai as d,
2470
+ Zr as e,
2471
+ ht as f,
2472
+ li as g,
2473
+ oi as h,
2474
+ Xt as i,
2475
+ qr as j,
2476
+ ke as k,
2477
+ Qt as l,
2478
+ pi as m,
2479
+ si as n,
2480
+ Se as o,
2481
+ ri as p,
2482
+ Nr as q,
2483
+ ni as r,
2484
+ Hr as s,
2485
+ Yt as t,
2486
+ Pr as u,
2487
+ _t as v,
2488
+ Fe as w,
2489
+ Mt as x,
2490
+ Jr as y,
2491
+ ii as z
2492
+ };