document-model 1.0.51 → 1.0.52

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 (31) hide show
  1. package/dist/browser/cjs/document-model.js +1 -1
  2. package/dist/browser/cjs/document.js +1 -1
  3. package/dist/browser/cjs/index.js +1 -1
  4. package/dist/{node/cjs/internal/index-CRjFLQNR.js → browser/cjs/internal/index-BVWyYyNE.js} +1 -1
  5. package/dist/browser/cjs/internal/{index-CPJM383s.js → index-CnVGNZ9_.js} +1 -1
  6. package/dist/browser/cjs/internal/object-5l5_pTNL.js +25 -0
  7. package/dist/browser/es/document-model.js +2 -2
  8. package/dist/browser/es/document.js +2 -2
  9. package/dist/browser/es/index.js +3 -3
  10. package/dist/browser/es/internal/{index-tEH7iGUj.js → index-CF0d1_Cg.js} +1 -1
  11. package/dist/browser/es/internal/{index-BzIVYv7p.js → index-aS_vqu4O.js} +1 -1
  12. package/dist/browser/es/internal/{object-Dev4WFVH.js → object-BdaEhPk1.js} +770 -771
  13. package/dist/browser/src/document/object.d.ts +35 -0
  14. package/dist/browser/src/document/types.d.ts +2 -0
  15. package/dist/node/cjs/document-model.js +1 -1
  16. package/dist/node/cjs/document.js +1 -1
  17. package/dist/node/cjs/index.js +1 -1
  18. package/dist/{browser/cjs/internal/index-REU04m7f.js → node/cjs/internal/index-B9gc2lPN.js} +1 -1
  19. package/dist/node/cjs/internal/{index-BX95XaQ_.js → index-JtuONOcD.js} +1 -1
  20. package/dist/node/cjs/internal/object-D6wRzEDN.js +20 -0
  21. package/dist/node/es/document-model.js +2 -2
  22. package/dist/node/es/document.js +2 -2
  23. package/dist/node/es/index.js +3 -3
  24. package/dist/node/es/internal/{index-BzNCX_-9.js → index-BclkoIYP.js} +1 -1
  25. package/dist/node/es/internal/{index-DpH4_29z.js → index-EY0PPZnJ.js} +1 -1
  26. package/dist/node/es/internal/{object-BFkXGmt6.js → object-BxC3xMqY.js} +509 -510
  27. package/dist/node/src/document/object.d.ts +35 -0
  28. package/dist/node/src/document/types.d.ts +2 -0
  29. package/package.json +1 -1
  30. package/dist/browser/cjs/internal/object-DkoS83BB.js +0 -25
  31. package/dist/node/cjs/internal/object-CGt7Qacd.js +0 -20
@@ -2,24 +2,24 @@ var Gt = Object.defineProperty;
2
2
  var Qt = (e, t, i) => t in e ? Gt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
3
3
  var nt = (e, t, i) => (Qt(e, typeof t != "symbol" ? t + "" : t, i), i);
4
4
  import { produce as G, castDraft as pt, castImmutable as Xt, freeze as Yt } from "immer";
5
- import { z as u } from "zod";
5
+ import { z as m } from "zod";
6
6
  import te from "crypto";
7
7
  import ct from "fs";
8
8
  import ee from "https";
9
9
  import { join as ie } from "path";
10
- import St from "jszip";
11
- const $t = (e) => e != null, ne = u.any().refine((e) => $t(e)), Et = u.enum(["LOAD_STATE"]), vt = u.enum(["PRUNE"]), Tt = u.enum(["REDO"]), kt = u.enum(["SET_NAME"]), _t = u.enum(["UNDO"]);
10
+ import Ot from "jszip";
11
+ const $t = (e) => e != null, ne = m.any().refine((e) => $t(e)), Et = m.enum(["LOAD_STATE"]), vt = m.enum(["PRUNE"]), Tt = m.enum(["REDO"]), _t = m.enum(["SET_NAME"]), kt = m.enum(["UNDO"]);
12
12
  function oe() {
13
- return u.object({
14
- __typename: u.literal("Action").optional(),
15
- type: u.string()
13
+ return m.object({
14
+ __typename: m.literal("Action").optional(),
15
+ type: m.string()
16
16
  });
17
17
  }
18
18
  function Q() {
19
- return u.literal("global").or(u.literal("local"));
19
+ return m.literal("global").or(m.literal("local"));
20
20
  }
21
21
  function At() {
22
- return u.union([
22
+ return m.union([
23
23
  Nt(),
24
24
  Mt(),
25
25
  Pt(),
@@ -27,87 +27,87 @@ function At() {
27
27
  zt()
28
28
  ]);
29
29
  }
30
- function se() {
31
- return u.object({
32
- __typename: u.literal("DocumentFile").optional(),
33
- data: u.string(),
34
- extension: u.string().nullable(),
35
- fileName: u.string().nullable(),
36
- mimeType: u.string()
30
+ function re() {
31
+ return m.object({
32
+ __typename: m.literal("DocumentFile").optional(),
33
+ data: m.string(),
34
+ extension: m.string().nullable(),
35
+ fileName: m.string().nullable(),
36
+ mimeType: m.string()
37
37
  });
38
38
  }
39
39
  function Nt() {
40
- return u.object({
41
- input: u.lazy(() => ut()),
40
+ return m.object({
41
+ input: m.lazy(() => ut()),
42
42
  type: Et,
43
43
  scope: Q()
44
44
  });
45
45
  }
46
46
  function ut() {
47
- return u.object({
48
- operations: u.number(),
49
- state: u.lazy(() => Dt())
47
+ return m.object({
48
+ operations: m.number(),
49
+ state: m.lazy(() => Dt())
50
50
  });
51
51
  }
52
52
  function Dt() {
53
- return u.object({
54
- data: u.unknown().nullish(),
55
- name: u.string()
53
+ return m.object({
54
+ data: m.unknown().nullish(),
55
+ name: m.string()
56
56
  });
57
57
  }
58
- function re() {
59
- return u.object({
60
- __typename: u.literal("Operation").optional(),
61
- hash: u.string(),
62
- index: u.number(),
63
- timestamp: u.string().datetime(),
64
- type: u.string()
58
+ function se() {
59
+ return m.object({
60
+ __typename: m.literal("Operation").optional(),
61
+ hash: m.string(),
62
+ index: m.number(),
63
+ timestamp: m.string().datetime(),
64
+ type: m.string()
65
65
  });
66
66
  }
67
67
  function Mt() {
68
- return u.object({
69
- input: u.lazy(() => ft()),
68
+ return m.object({
69
+ input: m.lazy(() => ft()),
70
70
  type: vt,
71
71
  scope: Q()
72
72
  });
73
73
  }
74
74
  function ft() {
75
- return u.object({
76
- end: u.number().nullish(),
77
- start: u.number().nullish()
75
+ return m.object({
76
+ end: m.number().nullish(),
77
+ start: m.number().nullish()
78
78
  });
79
79
  }
80
- const dt = u.number;
80
+ const dt = m.number;
81
81
  function Pt() {
82
- return u.object({
82
+ return m.object({
83
83
  input: dt(),
84
84
  type: Tt,
85
85
  scope: Q()
86
86
  });
87
87
  }
88
- const gt = u.string;
88
+ const gt = m.string;
89
89
  function It() {
90
- return u.object({
90
+ return m.object({
91
91
  input: gt(),
92
- type: kt,
93
- scope: u.literal("global")
92
+ type: _t,
93
+ scope: m.literal("global")
94
94
  });
95
95
  }
96
96
  function ae() {
97
- return u.object({
98
- __typename: u.literal("SetNameOperation").optional(),
99
- hash: u.string(),
100
- index: u.number(),
101
- input: u.string(),
102
- timestamp: u.string().datetime(),
103
- type: u.string()
97
+ return m.object({
98
+ __typename: m.literal("SetNameOperation").optional(),
99
+ hash: m.string(),
100
+ index: m.number(),
101
+ input: m.string(),
102
+ timestamp: m.string().datetime(),
103
+ type: m.string()
104
104
  });
105
105
  }
106
- const ht = u.number;
106
+ const ht = m.number;
107
107
  function zt() {
108
- return u.object({
108
+ return m.object({
109
109
  input: ht(),
110
- type: _t,
110
+ type: kt,
111
111
  scope: Q()
112
112
  });
113
113
  }
@@ -115,12 +115,12 @@ const We = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
115
115
  __proto__: null,
116
116
  ActionSchema: oe,
117
117
  BaseActionSchema: At,
118
- DocumentFileSchema: se,
118
+ DocumentFileSchema: re,
119
119
  LoadStateActionInputSchema: ut,
120
120
  LoadStateActionSchema: Nt,
121
121
  LoadStateActionStateInputSchema: Dt,
122
122
  Load_StateSchema: Et,
123
- OperationSchema: re,
123
+ OperationSchema: se,
124
124
  OperationScopeSchema: Q,
125
125
  PruneActionInputSchema: ft,
126
126
  PruneActionSchema: Mt,
@@ -131,10 +131,10 @@ const We = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
131
131
  SetNameActionInputSchema: gt,
132
132
  SetNameActionSchema: It,
133
133
  SetNameOperationSchema: ae,
134
- Set_NameSchema: kt,
134
+ Set_NameSchema: _t,
135
135
  UndoActionInputSchema: ht,
136
136
  UndoActionSchema: zt,
137
- UndoSchema: _t,
137
+ UndoSchema: kt,
138
138
  definedNonNullAnySchema: ne,
139
139
  isDefinedNonNullAny: $t
140
140
  }, Symbol.toStringTag, { value: "Module" }));
@@ -143,23 +143,23 @@ function pe(e) {
143
143
  }
144
144
  var lt = { exports: {} };
145
145
  (function(e, t) {
146
- const { hasOwnProperty: i } = Object.prototype, n = A();
147
- n.configure = A, n.stringify = n, n.default = n, t.stringify = n, t.configure = A, e.exports = n;
146
+ const { hasOwnProperty: i } = Object.prototype, n = E();
147
+ n.configure = E, n.stringify = n, n.default = n, t.stringify = n, t.configure = E, e.exports = n;
148
148
  const a = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;
149
- function p(r) {
150
- return r.length < 5e3 && !a.test(r) ? `"${r}"` : JSON.stringify(r);
149
+ function s(c) {
150
+ return c.length < 5e3 && !a.test(c) ? `"${c}"` : JSON.stringify(c);
151
151
  }
152
- function s(r) {
153
- if (r.length > 200)
154
- return r.sort();
155
- for (let m = 1; m < r.length; m++) {
156
- const b = r[m];
157
- let D = m;
158
- for (; D !== 0 && r[D - 1] > b; )
159
- r[D] = r[D - 1], D--;
160
- r[D] = b;
152
+ function r(c) {
153
+ if (c.length > 200)
154
+ return c.sort();
155
+ for (let u = 1; u < c.length; u++) {
156
+ const y = c[u];
157
+ let P = u;
158
+ for (; P !== 0 && c[P - 1] > y; )
159
+ c[P] = c[P - 1], P--;
160
+ c[P] = y;
161
161
  }
162
- return r;
162
+ return c;
163
163
  }
164
164
  const l = Object.getOwnPropertyDescriptor(
165
165
  Object.getPrototypeOf(
@@ -169,25 +169,25 @@ var lt = { exports: {} };
169
169
  ),
170
170
  Symbol.toStringTag
171
171
  ).get;
172
- function c(r) {
173
- return l.call(r) !== void 0 && r.length !== 0;
172
+ function p(c) {
173
+ return l.call(c) !== void 0 && c.length !== 0;
174
174
  }
175
- function x(r, m, b) {
176
- r.length < b && (b = r.length);
177
- const D = m === "," ? "" : " ";
178
- let U = `"0":${D}${r[0]}`;
179
- for (let R = 1; R < b; R++)
180
- U += `${m}"${R}":${D}${r[R]}`;
181
- return U;
175
+ function x(c, u, y) {
176
+ c.length < y && (y = c.length);
177
+ const P = u === "," ? "" : " ";
178
+ let V = `"0":${P}${c[0]}`;
179
+ for (let R = 1; R < y; R++)
180
+ V += `${u}"${R}":${P}${c[R]}`;
181
+ return V;
182
182
  }
183
- function j(r) {
184
- if (i.call(r, "circularValue")) {
185
- const m = r.circularValue;
186
- if (typeof m == "string")
187
- return `"${m}"`;
188
- if (m == null)
189
- return m;
190
- if (m === Error || m === TypeError)
183
+ function b(c) {
184
+ if (i.call(c, "circularValue")) {
185
+ const u = c.circularValue;
186
+ if (typeof u == "string")
187
+ return `"${u}"`;
188
+ if (u == null)
189
+ return u;
190
+ if (u === Error || u === TypeError)
191
191
  return {
192
192
  toString() {
193
193
  throw new TypeError("Converting circular structure to JSON");
@@ -197,83 +197,83 @@ var lt = { exports: {} };
197
197
  }
198
198
  return '"[Circular]"';
199
199
  }
200
- function E(r, m) {
201
- let b;
202
- if (i.call(r, m) && (b = r[m], typeof b != "boolean"))
203
- throw new TypeError(`The "${m}" argument must be of type boolean`);
204
- return b === void 0 ? !0 : b;
200
+ function v(c, u) {
201
+ let y;
202
+ if (i.call(c, u) && (y = c[u], typeof y != "boolean"))
203
+ throw new TypeError(`The "${u}" argument must be of type boolean`);
204
+ return y === void 0 ? !0 : y;
205
205
  }
206
- function g(r, m) {
207
- let b;
208
- if (i.call(r, m)) {
209
- if (b = r[m], typeof b != "number")
210
- throw new TypeError(`The "${m}" argument must be of type number`);
211
- if (!Number.isInteger(b))
212
- throw new TypeError(`The "${m}" argument must be an integer`);
213
- if (b < 1)
214
- throw new RangeError(`The "${m}" argument must be >= 1`);
206
+ function h(c, u) {
207
+ let y;
208
+ if (i.call(c, u)) {
209
+ if (y = c[u], typeof y != "number")
210
+ throw new TypeError(`The "${u}" argument must be of type number`);
211
+ if (!Number.isInteger(y))
212
+ throw new TypeError(`The "${u}" argument must be an integer`);
213
+ if (y < 1)
214
+ throw new RangeError(`The "${u}" argument must be >= 1`);
215
215
  }
216
- return b === void 0 ? 1 / 0 : b;
216
+ return y === void 0 ? 1 / 0 : y;
217
217
  }
218
- function S(r) {
219
- return r === 1 ? "1 item" : `${r} items`;
218
+ function O(c) {
219
+ return c === 1 ? "1 item" : `${c} items`;
220
220
  }
221
- function F(r) {
222
- const m = /* @__PURE__ */ new Set();
223
- for (const b of r)
224
- (typeof b == "string" || typeof b == "number") && m.add(String(b));
225
- return m;
221
+ function $(c) {
222
+ const u = /* @__PURE__ */ new Set();
223
+ for (const y of c)
224
+ (typeof y == "string" || typeof y == "number") && u.add(String(y));
225
+ return u;
226
226
  }
227
- function _(r) {
228
- if (i.call(r, "strict")) {
229
- const m = r.strict;
230
- if (typeof m != "boolean")
227
+ function D(c) {
228
+ if (i.call(c, "strict")) {
229
+ const u = c.strict;
230
+ if (typeof u != "boolean")
231
231
  throw new TypeError('The "strict" argument must be of type boolean');
232
- if (m)
233
- return (b) => {
234
- let D = `Object can not safely be stringified. Received type ${typeof b}`;
235
- throw typeof b != "function" && (D += ` (${b.toString()})`), new Error(D);
232
+ if (u)
233
+ return (y) => {
234
+ let P = `Object can not safely be stringified. Received type ${typeof y}`;
235
+ throw typeof y != "function" && (P += ` (${y.toString()})`), new Error(P);
236
236
  };
237
237
  }
238
238
  }
239
- function A(r) {
240
- r = { ...r };
241
- const m = _(r);
242
- m && (r.bigint === void 0 && (r.bigint = !1), "circularValue" in r || (r.circularValue = Error));
243
- const b = j(r), D = E(r, "bigint"), U = E(r, "deterministic"), R = g(r, "maximumDepth"), T = g(r, "maximumBreadth");
244
- function tt(P, o, f, y, h, O) {
245
- let d = o[P];
246
- switch (typeof d == "object" && d !== null && typeof d.toJSON == "function" && (d = d.toJSON(P)), d = y.call(o, P, d), typeof d) {
239
+ function E(c) {
240
+ c = { ...c };
241
+ const u = D(c);
242
+ u && (c.bigint === void 0 && (c.bigint = !1), "circularValue" in c || (c.circularValue = Error));
243
+ const y = b(c), P = v(c, "bigint"), V = v(c, "deterministic"), R = h(c, "maximumDepth"), k = h(c, "maximumBreadth");
244
+ function tt(I, o, f, w, g, S) {
245
+ let d = o[I];
246
+ switch (typeof d == "object" && d !== null && typeof d.toJSON == "function" && (d = d.toJSON(I)), d = w.call(o, I, d), typeof d) {
247
247
  case "string":
248
- return p(d);
248
+ return s(d);
249
249
  case "object": {
250
250
  if (d === null)
251
251
  return "null";
252
252
  if (f.indexOf(d) !== -1)
253
- return b;
254
- let w = "", v = ",";
255
- const k = O;
253
+ return y;
254
+ let j = "", _ = ",";
255
+ const A = S;
256
256
  if (Array.isArray(d)) {
257
257
  if (d.length === 0)
258
258
  return "[]";
259
259
  if (R < f.length + 1)
260
260
  return '"[Array]"';
261
- f.push(d), h !== "" && (O += h, w += `
262
- ${O}`, v = `,
263
- ${O}`);
264
- const z = Math.min(d.length, T);
265
- let C = 0;
266
- for (; C < z - 1; C++) {
267
- const it = tt(String(C), d, f, y, h, O);
268
- w += it !== void 0 ? it : "null", w += v;
261
+ f.push(d), g !== "" && (S += g, j += `
262
+ ${S}`, _ = `,
263
+ ${S}`);
264
+ const F = Math.min(d.length, k);
265
+ let J = 0;
266
+ for (; J < F - 1; J++) {
267
+ const it = tt(String(J), d, f, w, g, S);
268
+ j += it !== void 0 ? it : "null", j += _;
269
269
  }
270
- const J = tt(String(C), d, f, y, h, O);
271
- if (w += J !== void 0 ? J : "null", d.length - 1 > T) {
272
- const it = d.length - T - 1;
273
- w += `${v}"... ${S(it)} not stringified"`;
270
+ const C = tt(String(J), d, f, w, g, S);
271
+ if (j += C !== void 0 ? C : "null", d.length - 1 > k) {
272
+ const it = d.length - k - 1;
273
+ j += `${_}"... ${O(it)} not stringified"`;
274
274
  }
275
- return h !== "" && (w += `
276
- ${k}`), f.pop(), `[${w}]`;
275
+ return g !== "" && (j += `
276
+ ${A}`), f.pop(), `[${j}]`;
277
277
  }
278
278
  let N = Object.keys(d);
279
279
  const M = N.length;
@@ -281,256 +281,256 @@ ${k}`), f.pop(), `[${w}]`;
281
281
  return "{}";
282
282
  if (R < f.length + 1)
283
283
  return '"[Object]"';
284
- let $ = "", I = "";
285
- h !== "" && (O += h, v = `,
286
- ${O}`, $ = " ");
287
- const q = Math.min(M, T);
288
- U && !c(d) && (N = s(N)), f.push(d);
289
- for (let z = 0; z < q; z++) {
290
- const C = N[z], J = tt(C, d, f, y, h, O);
291
- J !== void 0 && (w += `${I}${p(C)}:${$}${J}`, I = v);
284
+ let T = "", z = "";
285
+ g !== "" && (S += g, _ = `,
286
+ ${S}`, T = " ");
287
+ const q = Math.min(M, k);
288
+ V && !p(d) && (N = r(N)), f.push(d);
289
+ for (let F = 0; F < q; F++) {
290
+ const J = N[F], C = tt(J, d, f, w, g, S);
291
+ C !== void 0 && (j += `${z}${s(J)}:${T}${C}`, z = _);
292
292
  }
293
- if (M > T) {
294
- const z = M - T;
295
- w += `${I}"...":${$}"${S(z)} not stringified"`, I = v;
293
+ if (M > k) {
294
+ const F = M - k;
295
+ j += `${z}"...":${T}"${O(F)} not stringified"`, z = _;
296
296
  }
297
- return h !== "" && I.length > 1 && (w = `
298
- ${O}${w}
299
- ${k}`), f.pop(), `{${w}}`;
297
+ return g !== "" && z.length > 1 && (j = `
298
+ ${S}${j}
299
+ ${A}`), f.pop(), `{${j}}`;
300
300
  }
301
301
  case "number":
302
- return isFinite(d) ? String(d) : m ? m(d) : "null";
302
+ return isFinite(d) ? String(d) : u ? u(d) : "null";
303
303
  case "boolean":
304
304
  return d === !0 ? "true" : "false";
305
305
  case "undefined":
306
306
  return;
307
307
  case "bigint":
308
- if (D)
308
+ if (P)
309
309
  return String(d);
310
310
  default:
311
- return m ? m(d) : void 0;
311
+ return u ? u(d) : void 0;
312
312
  }
313
313
  }
314
- function et(P, o, f, y, h, O) {
315
- switch (typeof o == "object" && o !== null && typeof o.toJSON == "function" && (o = o.toJSON(P)), typeof o) {
314
+ function et(I, o, f, w, g, S) {
315
+ switch (typeof o == "object" && o !== null && typeof o.toJSON == "function" && (o = o.toJSON(I)), typeof o) {
316
316
  case "string":
317
- return p(o);
317
+ return s(o);
318
318
  case "object": {
319
319
  if (o === null)
320
320
  return "null";
321
321
  if (f.indexOf(o) !== -1)
322
- return b;
323
- const d = O;
324
- let w = "", v = ",";
322
+ return y;
323
+ const d = S;
324
+ let j = "", _ = ",";
325
325
  if (Array.isArray(o)) {
326
326
  if (o.length === 0)
327
327
  return "[]";
328
328
  if (R < f.length + 1)
329
329
  return '"[Array]"';
330
- f.push(o), h !== "" && (O += h, w += `
331
- ${O}`, v = `,
332
- ${O}`);
333
- const M = Math.min(o.length, T);
334
- let $ = 0;
335
- for (; $ < M - 1; $++) {
336
- const q = et(String($), o[$], f, y, h, O);
337
- w += q !== void 0 ? q : "null", w += v;
330
+ f.push(o), g !== "" && (S += g, j += `
331
+ ${S}`, _ = `,
332
+ ${S}`);
333
+ const M = Math.min(o.length, k);
334
+ let T = 0;
335
+ for (; T < M - 1; T++) {
336
+ const q = et(String(T), o[T], f, w, g, S);
337
+ j += q !== void 0 ? q : "null", j += _;
338
338
  }
339
- const I = et(String($), o[$], f, y, h, O);
340
- if (w += I !== void 0 ? I : "null", o.length - 1 > T) {
341
- const q = o.length - T - 1;
342
- w += `${v}"... ${S(q)} not stringified"`;
339
+ const z = et(String(T), o[T], f, w, g, S);
340
+ if (j += z !== void 0 ? z : "null", o.length - 1 > k) {
341
+ const q = o.length - k - 1;
342
+ j += `${_}"... ${O(q)} not stringified"`;
343
343
  }
344
- return h !== "" && (w += `
345
- ${d}`), f.pop(), `[${w}]`;
344
+ return g !== "" && (j += `
345
+ ${d}`), f.pop(), `[${j}]`;
346
346
  }
347
347
  f.push(o);
348
- let k = "";
349
- h !== "" && (O += h, v = `,
350
- ${O}`, k = " ");
348
+ let A = "";
349
+ g !== "" && (S += g, _ = `,
350
+ ${S}`, A = " ");
351
351
  let N = "";
352
- for (const M of y) {
353
- const $ = et(M, o[M], f, y, h, O);
354
- $ !== void 0 && (w += `${N}${p(M)}:${k}${$}`, N = v);
352
+ for (const M of w) {
353
+ const T = et(M, o[M], f, w, g, S);
354
+ T !== void 0 && (j += `${N}${s(M)}:${A}${T}`, N = _);
355
355
  }
356
- return h !== "" && N.length > 1 && (w = `
357
- ${O}${w}
358
- ${d}`), f.pop(), `{${w}}`;
356
+ return g !== "" && N.length > 1 && (j = `
357
+ ${S}${j}
358
+ ${d}`), f.pop(), `{${j}}`;
359
359
  }
360
360
  case "number":
361
- return isFinite(o) ? String(o) : m ? m(o) : "null";
361
+ return isFinite(o) ? String(o) : u ? u(o) : "null";
362
362
  case "boolean":
363
363
  return o === !0 ? "true" : "false";
364
364
  case "undefined":
365
365
  return;
366
366
  case "bigint":
367
- if (D)
367
+ if (P)
368
368
  return String(o);
369
369
  default:
370
- return m ? m(o) : void 0;
370
+ return u ? u(o) : void 0;
371
371
  }
372
372
  }
373
- function W(P, o, f, y, h) {
373
+ function W(I, o, f, w, g) {
374
374
  switch (typeof o) {
375
375
  case "string":
376
- return p(o);
376
+ return s(o);
377
377
  case "object": {
378
378
  if (o === null)
379
379
  return "null";
380
380
  if (typeof o.toJSON == "function") {
381
- if (o = o.toJSON(P), typeof o != "object")
382
- return W(P, o, f, y, h);
381
+ if (o = o.toJSON(I), typeof o != "object")
382
+ return W(I, o, f, w, g);
383
383
  if (o === null)
384
384
  return "null";
385
385
  }
386
386
  if (f.indexOf(o) !== -1)
387
- return b;
388
- const O = h;
387
+ return y;
388
+ const S = g;
389
389
  if (Array.isArray(o)) {
390
390
  if (o.length === 0)
391
391
  return "[]";
392
392
  if (R < f.length + 1)
393
393
  return '"[Array]"';
394
- f.push(o), h += y;
395
- let $ = `
396
- ${h}`;
397
- const I = `,
398
- ${h}`, q = Math.min(o.length, T);
399
- let z = 0;
400
- for (; z < q - 1; z++) {
401
- const J = W(String(z), o[z], f, y, h);
402
- $ += J !== void 0 ? J : "null", $ += I;
394
+ f.push(o), g += w;
395
+ let T = `
396
+ ${g}`;
397
+ const z = `,
398
+ ${g}`, q = Math.min(o.length, k);
399
+ let F = 0;
400
+ for (; F < q - 1; F++) {
401
+ const C = W(String(F), o[F], f, w, g);
402
+ T += C !== void 0 ? C : "null", T += z;
403
403
  }
404
- const C = W(String(z), o[z], f, y, h);
405
- if ($ += C !== void 0 ? C : "null", o.length - 1 > T) {
406
- const J = o.length - T - 1;
407
- $ += `${I}"... ${S(J)} not stringified"`;
404
+ const J = W(String(F), o[F], f, w, g);
405
+ if (T += J !== void 0 ? J : "null", o.length - 1 > k) {
406
+ const C = o.length - k - 1;
407
+ T += `${z}"... ${O(C)} not stringified"`;
408
408
  }
409
- return $ += `
410
- ${O}`, f.pop(), `[${$}]`;
409
+ return T += `
410
+ ${S}`, f.pop(), `[${T}]`;
411
411
  }
412
412
  let d = Object.keys(o);
413
- const w = d.length;
414
- if (w === 0)
413
+ const j = d.length;
414
+ if (j === 0)
415
415
  return "{}";
416
416
  if (R < f.length + 1)
417
417
  return '"[Object]"';
418
- h += y;
419
- const v = `,
420
- ${h}`;
421
- let k = "", N = "", M = Math.min(w, T);
422
- c(o) && (k += x(o, v, T), d = d.slice(o.length), M -= o.length, N = v), U && (d = s(d)), f.push(o);
423
- for (let $ = 0; $ < M; $++) {
424
- const I = d[$], q = W(I, o[I], f, y, h);
425
- q !== void 0 && (k += `${N}${p(I)}: ${q}`, N = v);
418
+ g += w;
419
+ const _ = `,
420
+ ${g}`;
421
+ let A = "", N = "", M = Math.min(j, k);
422
+ p(o) && (A += x(o, _, k), d = d.slice(o.length), M -= o.length, N = _), V && (d = r(d)), f.push(o);
423
+ for (let T = 0; T < M; T++) {
424
+ const z = d[T], q = W(z, o[z], f, w, g);
425
+ q !== void 0 && (A += `${N}${s(z)}: ${q}`, N = _);
426
426
  }
427
- if (w > T) {
428
- const $ = w - T;
429
- k += `${N}"...": "${S($)} not stringified"`, N = v;
427
+ if (j > k) {
428
+ const T = j - k;
429
+ A += `${N}"...": "${O(T)} not stringified"`, N = _;
430
430
  }
431
- return N !== "" && (k = `
432
- ${h}${k}
433
- ${O}`), f.pop(), `{${k}}`;
431
+ return N !== "" && (A = `
432
+ ${g}${A}
433
+ ${S}`), f.pop(), `{${A}}`;
434
434
  }
435
435
  case "number":
436
- return isFinite(o) ? String(o) : m ? m(o) : "null";
436
+ return isFinite(o) ? String(o) : u ? u(o) : "null";
437
437
  case "boolean":
438
438
  return o === !0 ? "true" : "false";
439
439
  case "undefined":
440
440
  return;
441
441
  case "bigint":
442
- if (D)
442
+ if (P)
443
443
  return String(o);
444
444
  default:
445
- return m ? m(o) : void 0;
445
+ return u ? u(o) : void 0;
446
446
  }
447
447
  }
448
- function B(P, o, f) {
448
+ function B(I, o, f) {
449
449
  switch (typeof o) {
450
450
  case "string":
451
- return p(o);
451
+ return s(o);
452
452
  case "object": {
453
453
  if (o === null)
454
454
  return "null";
455
455
  if (typeof o.toJSON == "function") {
456
- if (o = o.toJSON(P), typeof o != "object")
457
- return B(P, o, f);
456
+ if (o = o.toJSON(I), typeof o != "object")
457
+ return B(I, o, f);
458
458
  if (o === null)
459
459
  return "null";
460
460
  }
461
461
  if (f.indexOf(o) !== -1)
462
- return b;
463
- let y = "";
462
+ return y;
463
+ let w = "";
464
464
  if (Array.isArray(o)) {
465
465
  if (o.length === 0)
466
466
  return "[]";
467
467
  if (R < f.length + 1)
468
468
  return '"[Array]"';
469
469
  f.push(o);
470
- const v = Math.min(o.length, T);
471
- let k = 0;
472
- for (; k < v - 1; k++) {
473
- const M = B(String(k), o[k], f);
474
- y += M !== void 0 ? M : "null", y += ",";
470
+ const _ = Math.min(o.length, k);
471
+ let A = 0;
472
+ for (; A < _ - 1; A++) {
473
+ const M = B(String(A), o[A], f);
474
+ w += M !== void 0 ? M : "null", w += ",";
475
475
  }
476
- const N = B(String(k), o[k], f);
477
- if (y += N !== void 0 ? N : "null", o.length - 1 > T) {
478
- const M = o.length - T - 1;
479
- y += `,"... ${S(M)} not stringified"`;
476
+ const N = B(String(A), o[A], f);
477
+ if (w += N !== void 0 ? N : "null", o.length - 1 > k) {
478
+ const M = o.length - k - 1;
479
+ w += `,"... ${O(M)} not stringified"`;
480
480
  }
481
- return f.pop(), `[${y}]`;
481
+ return f.pop(), `[${w}]`;
482
482
  }
483
- let h = Object.keys(o);
484
- const O = h.length;
485
- if (O === 0)
483
+ let g = Object.keys(o);
484
+ const S = g.length;
485
+ if (S === 0)
486
486
  return "{}";
487
487
  if (R < f.length + 1)
488
488
  return '"[Object]"';
489
- let d = "", w = Math.min(O, T);
490
- c(o) && (y += x(o, ",", T), h = h.slice(o.length), w -= o.length, d = ","), U && (h = s(h)), f.push(o);
491
- for (let v = 0; v < w; v++) {
492
- const k = h[v], N = B(k, o[k], f);
493
- N !== void 0 && (y += `${d}${p(k)}:${N}`, d = ",");
489
+ let d = "", j = Math.min(S, k);
490
+ p(o) && (w += x(o, ",", k), g = g.slice(o.length), j -= o.length, d = ","), V && (g = r(g)), f.push(o);
491
+ for (let _ = 0; _ < j; _++) {
492
+ const A = g[_], N = B(A, o[A], f);
493
+ N !== void 0 && (w += `${d}${s(A)}:${N}`, d = ",");
494
494
  }
495
- if (O > T) {
496
- const v = O - T;
497
- y += `${d}"...":"${S(v)} not stringified"`;
495
+ if (S > k) {
496
+ const _ = S - k;
497
+ w += `${d}"...":"${O(_)} not stringified"`;
498
498
  }
499
- return f.pop(), `{${y}}`;
499
+ return f.pop(), `{${w}}`;
500
500
  }
501
501
  case "number":
502
- return isFinite(o) ? String(o) : m ? m(o) : "null";
502
+ return isFinite(o) ? String(o) : u ? u(o) : "null";
503
503
  case "boolean":
504
504
  return o === !0 ? "true" : "false";
505
505
  case "undefined":
506
506
  return;
507
507
  case "bigint":
508
- if (D)
508
+ if (P)
509
509
  return String(o);
510
510
  default:
511
- return m ? m(o) : void 0;
511
+ return u ? u(o) : void 0;
512
512
  }
513
513
  }
514
- function Zt(P, o, f) {
514
+ function Zt(I, o, f) {
515
515
  if (arguments.length > 1) {
516
- let y = "";
517
- if (typeof f == "number" ? y = " ".repeat(Math.min(f, 10)) : typeof f == "string" && (y = f.slice(0, 10)), o != null) {
516
+ let w = "";
517
+ if (typeof f == "number" ? w = " ".repeat(Math.min(f, 10)) : typeof f == "string" && (w = f.slice(0, 10)), o != null) {
518
518
  if (typeof o == "function")
519
- return tt("", { "": P }, [], o, y, "");
519
+ return tt("", { "": I }, [], o, w, "");
520
520
  if (Array.isArray(o))
521
- return et("", P, [], F(o), y, "");
521
+ return et("", I, [], $(o), w, "");
522
522
  }
523
- if (y.length !== 0)
524
- return W("", P, [], y, "");
523
+ if (w.length !== 0)
524
+ return W("", I, [], w, "");
525
525
  }
526
- return B("", P, []);
526
+ return B("", I, []);
527
527
  }
528
528
  return Zt;
529
529
  }
530
530
  })(lt, lt.exports);
531
531
  var ce = lt.exports;
532
- const st = /* @__PURE__ */ pe(ce);
533
- st.configure;
532
+ const rt = /* @__PURE__ */ pe(ce);
533
+ rt.configure;
534
534
  function le(e, t) {
535
535
  return { ...e, name: t };
536
536
  }
@@ -539,9 +539,9 @@ function me(e, t, i) {
539
539
  skip: i,
540
540
  document: e
541
541
  }, { scope: a } = t;
542
- return !a || t.skip === void 0 ? n : G(n, (p) => {
543
- const [s] = p.document.operations[a].slice(-1);
544
- t.skip && t.skip > 0 && (p.skip = t.skip), s.type === "NOOP" && t.index === s.index && p.skip > s.skip && p.document.operations[a].pop();
542
+ return !a || t.skip === void 0 ? n : G(n, (s) => {
543
+ const [r] = s.document.operations[a].slice(-1);
544
+ t.skip && t.skip > 0 && (s.skip = t.skip), r.type === "NOOP" && t.index === r.index && s.skip > r.skip && s.document.operations[a].pop();
545
545
  });
546
546
  }
547
547
  function ue(e, t, i) {
@@ -550,8 +550,8 @@ function ue(e, t, i) {
550
550
  document: e,
551
551
  action: t,
552
552
  skip: i
553
- }, (s) => {
554
- if (s.document.operations[n].length < 1)
553
+ }, (r) => {
554
+ if (r.document.operations[n].length < 1)
555
555
  throw new Error(
556
556
  `Cannot undo: no operations in history for scope "${n}"`
557
557
  );
@@ -559,31 +559,31 @@ function ue(e, t, i) {
559
559
  throw new Error(
560
560
  "Invalid UNDO action: input value must be greater than 0"
561
561
  );
562
- if (s.skip > 0)
562
+ if (r.skip > 0)
563
563
  throw new Error(
564
564
  "Cannot undo: skip value from reducer cannot be used with UNDO action"
565
565
  );
566
- const [l] = s.document.operations[n].slice(-1), c = l.type === "NOOP" && l.skip > 0;
567
- if (s.skip += a, c) {
568
- s.skip += l.skip;
569
- const g = s.document.operations[n][s.document.operations[n].length - 2];
570
- g && l.index - g.index === 1 && s.document.operations[n].pop();
566
+ const [l] = r.document.operations[n].slice(-1), p = l.type === "NOOP" && l.skip > 0;
567
+ if (r.skip += a, p) {
568
+ r.skip += l.skip;
569
+ const h = r.document.operations[n][r.document.operations[n].length - 2];
570
+ h && l.index - h.index === 1 && r.document.operations[n].pop();
571
571
  }
572
- if (s.document.operations[n].length < s.skip)
572
+ if (r.document.operations[n].length < r.skip)
573
573
  throw new Error(
574
574
  "Cannot undo: you can't undo more operations than the ones in the scope history"
575
575
  );
576
- const x = s.document.operations[n].length - 1;
577
- let j = a, E = c ? x - l.skip : x;
578
- for (; j > 0 && E >= 0; ) {
579
- const g = s.document.operations[n][E];
580
- if (!g) {
581
- j--, E--;
576
+ const x = r.document.operations[n].length - 1;
577
+ let b = a, v = p ? x - l.skip : x;
578
+ for (; b > 0 && v >= 0; ) {
579
+ const h = r.document.operations[n][v];
580
+ if (!h) {
581
+ b--, v--;
582
582
  continue;
583
583
  }
584
- g.type === "NOOP" && g.skip > 0 ? (E = E - (g.skip + 1), s.skip += g.skip + 1) : (s.document.clipboard.push({ ...g }), j--, E--);
584
+ h.type === "NOOP" && h.skip > 0 ? (v = v - (h.skip + 1), r.skip += h.skip + 1) : (r.document.clipboard.push({ ...h }), b--, v--);
585
585
  }
586
- s.action = yt(n);
586
+ r.action = yt(n);
587
587
  });
588
588
  }
589
589
  function fe(e, t, i) {
@@ -592,8 +592,8 @@ function fe(e, t, i) {
592
592
  document: e,
593
593
  action: t,
594
594
  skip: i
595
- }, (s) => {
596
- if (s.skip > 0)
595
+ }, (r) => {
596
+ if (r.skip > 0)
597
597
  throw new Error(
598
598
  "Cannot redo: skip value from reducer cannot be used with REDO action"
599
599
  );
@@ -603,55 +603,55 @@ function fe(e, t, i) {
603
603
  );
604
604
  if (a < 1)
605
605
  throw new Error("Invalid REDO action: invalid redo input value");
606
- if (s.document.clipboard.length < 1)
606
+ if (r.document.clipboard.length < 1)
607
607
  throw new Error("Cannot redo: no operations in the clipboard");
608
- const l = s.document.clipboard.findLastIndex(
608
+ const l = r.document.clipboard.findLastIndex(
609
609
  (x) => x.scope === n
610
610
  );
611
611
  if (l < 0)
612
612
  throw new Error(
613
613
  `Cannot redo: no operations in clipboard for scope "${n}"`
614
614
  );
615
- const c = s.document.clipboard.splice(l, 1)[0];
616
- s.action = pt({
617
- type: c.type,
618
- scope: c.scope,
619
- input: c.input
615
+ const p = r.document.clipboard.splice(l, 1)[0];
616
+ r.action = pt({
617
+ type: p.type,
618
+ scope: p.scope,
619
+ input: p.input
620
620
  });
621
621
  });
622
622
  }
623
623
  function de(e, t, i) {
624
624
  const { scope: n } = t, a = e.operations[n];
625
625
  let {
626
- input: { start: p, end: s }
626
+ input: { start: s, end: r }
627
627
  } = t;
628
- p = p || 0, s = s || a.length;
629
- const l = a.slice(p, s), c = a.slice(0, p), x = a.slice(s), j = mt(
628
+ s = s || 0, r = r || a.length;
629
+ const l = a.slice(s, r), p = a.slice(0, s), x = a.slice(r), b = mt(
630
630
  e.initialState,
631
631
  {
632
632
  ...e.operations,
633
- [n]: c.concat(l)
633
+ [n]: p.concat(l)
634
634
  },
635
635
  i
636
- ), { name: E, state: g } = j, S = c.length, F = c.length ? c[c.length - 1].timestamp : x.length ? x[0].timestamp : (/* @__PURE__ */ new Date()).toISOString();
636
+ ), { name: v, state: h } = b, O = p.length, $ = p.length ? p[p.length - 1].timestamp : x.length ? x[0].timestamp : (/* @__PURE__ */ new Date()).toISOString();
637
637
  return mt(
638
638
  e.initialState,
639
639
  {
640
640
  ...e.operations,
641
641
  [n]: [
642
- ...c,
642
+ ...p,
643
643
  {
644
644
  ...bt(
645
- { name: E, state: g },
645
+ { name: v, state: h },
646
646
  l.length
647
647
  ),
648
- timestamp: F,
649
- index: S,
650
- hash: xt({ state: g }, "global")
648
+ timestamp: $,
649
+ index: O,
650
+ hash: xt({ state: h }, "global")
651
651
  },
652
- ...x.map((_, A) => ({
653
- ..._,
654
- index: S + A + 1
652
+ ...x.map((D, E) => ({
653
+ ...D,
654
+ index: O + E + 1
655
655
  }))
656
656
  ]
657
657
  },
@@ -665,7 +665,7 @@ function ge(e, t) {
665
665
  state: t.state ?? { global: {}, local: {} }
666
666
  };
667
667
  }
668
- const Ft = "SET_NAME", X = "UNDO", Y = "REDO", rt = "PRUNE", Rt = "LOAD_STATE", he = "NOOP";
668
+ const Ft = "SET_NAME", X = "UNDO", Y = "REDO", st = "PRUNE", Rt = "LOAD_STATE", he = "NOOP";
669
669
  function xe(e, t) {
670
670
  let i;
671
671
  return "index" in t ? i = { ...t } : i = e.operations[t.scope].slice(-1)[0], ((i == null ? void 0 : i.index) ?? -1) + 1;
@@ -681,27 +681,28 @@ function be(e, t) {
681
681
  };
682
682
  }
683
683
  function ye(e, t, i = 0) {
684
- if ([X, Y, rt].includes(t.type))
684
+ if ([X, Y, st].includes(t.type))
685
685
  return e;
686
686
  const { scope: n } = t, a = e.operations[n].slice(
687
687
  0,
688
688
  e.revision[n]
689
- ), p = [...a].pop();
690
- let s = ((p == null ? void 0 : p.index) ?? -1) + 1;
689
+ ), s = [...a].pop();
690
+ let r = ((s == null ? void 0 : s.index) ?? -1) + 1;
691
691
  if ("index" in t) {
692
- if (t.index > s + i)
692
+ if (t.index > r + i)
693
693
  throw new Error(
694
- `Missing operations: expected ${s} with skip 0 or equivalent, got index ${t.index} with skip ${i}`
694
+ `Missing operations: expected ${r} with skip 0 or equivalent, got index ${t.index} with skip ${i}`
695
695
  );
696
- s = t.index;
696
+ r = t.index;
697
697
  }
698
698
  return a.push({
699
699
  ...t,
700
- index: s,
700
+ index: r,
701
701
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
702
702
  hash: "",
703
703
  scope: n,
704
- skip: i
704
+ skip: i,
705
+ error: void 0
705
706
  }), {
706
707
  ...e,
707
708
  operations: { ...e.operations, [n]: a }
@@ -715,7 +716,7 @@ function je(e, t, i) {
715
716
  switch (At().parse(t), t.type) {
716
717
  case Ft:
717
718
  return le(e, t.input);
718
- case rt:
719
+ case st:
719
720
  return de(e, t, i);
720
721
  case Rt:
721
722
  return ge(e, t.input.state);
@@ -723,7 +724,7 @@ function je(e, t, i) {
723
724
  return e;
724
725
  }
725
726
  }
726
- function Oe(e, t, i) {
727
+ function Se(e, t, i) {
727
728
  switch (t.type) {
728
729
  case X:
729
730
  return ue(e, t, i);
@@ -734,71 +735,79 @@ function Oe(e, t, i) {
734
735
  }
735
736
  }
736
737
  function Lt(e, t, i, n, a = {}) {
737
- const { skip: p, ignoreSkipOperations: s = !1, reuseHash: l = !1 } = a;
738
- let c = { ...t }, x = p || 0, j = e, E = [...e.clipboard];
739
- if (ve(c)) {
740
- const { document: g, skip: S } = me(j, c, x);
741
- x = S, j = g;
738
+ const { skip: s, ignoreSkipOperations: r = !1, reuseHash: l = !1 } = a;
739
+ let p = { ...t }, x = s || 0, b = e, v = [...e.clipboard];
740
+ if (ve(p)) {
741
+ const { document: h, skip: O } = me(b, p, x);
742
+ x = O, b = h;
742
743
  }
743
- if (wt(c)) {
744
+ if (wt(p)) {
744
745
  const {
745
- skip: g,
746
- action: S,
747
- document: F
748
- } = Oe(e, c, x);
749
- c = S, x = g, j = F, E = [...j.clipboard];
746
+ skip: h,
747
+ action: O,
748
+ document: $
749
+ } = Se(e, p, x);
750
+ p = O, x = h, b = $, v = [...b.clipboard];
750
751
  }
751
- if (jt(c) && (j = je(j, c, i)), x > 0 && !s) {
752
- let g = x;
753
- "index" in c && (g = Ne(
754
- j.operations[c.scope],
755
- c.index,
752
+ if (jt(p) && (b = je(b, p, i)), x > 0 && !r) {
753
+ let h = x;
754
+ "index" in p && (h = Ne(
755
+ b.operations[p.scope],
756
+ p.index,
756
757
  x
757
- )), j = mt(
758
- j.initialState,
759
- j.operations,
758
+ )), b = mt(
759
+ b.initialState,
760
+ b.operations,
760
761
  i,
761
762
  void 0,
762
763
  void 0,
763
764
  void 0,
764
- { [c.scope]: g }
765
+ { [p.scope]: h }
765
766
  // TODO reuse hash?
766
767
  );
767
768
  }
768
- return j = we(j, c, x), j = G(j, (g) => {
769
- const S = i(
770
- g.state,
771
- c,
772
- n
773
- ), F = wt(t) ? [...E] : [];
774
- if (S)
775
- return pt({
776
- ...j,
777
- clipboard: [...F],
778
- state: S
779
- });
780
- g.clipboard = pt([...F]);
781
- }), G(j, (g) => {
782
- if ([X, Y, rt].includes(c.type))
783
- return g;
784
- const S = c.scope || "global", F = l && Object.prototype.hasOwnProperty.call(c, "hash") ? c.hash : xt(g, S);
785
- g.operations[S][g.operations[S].length - 1].hash = F, !jt(c) && c.attachments && c.attachments.forEach((_) => {
786
- const { hash: A, ...r } = _;
787
- g.attachments[A] = {
788
- ...r
769
+ return b = we(b, p, x), b = G(b, (h) => {
770
+ try {
771
+ const O = i(
772
+ h.state,
773
+ p,
774
+ n
775
+ ), $ = wt(t) ? [...v] : [];
776
+ if (O)
777
+ return pt({
778
+ ...b,
779
+ clipboard: [...$],
780
+ state: O
781
+ });
782
+ h.clipboard = pt([...$]);
783
+ } catch (O) {
784
+ const $ = b.operations[p.scope].length - 1;
785
+ h.operations[p.scope][$].error = O.message, console.error(
786
+ `Error thrown in reducer. Action: ${JSON.stringify(p)}, Error:`,
787
+ O
788
+ );
789
+ }
790
+ }), G(b, (h) => {
791
+ if ([X, Y, st].includes(p.type))
792
+ return h;
793
+ const O = p.scope || "global", $ = l && Object.prototype.hasOwnProperty.call(p, "hash") ? p.hash : xt(h, O);
794
+ h.operations[O][h.operations[O].length - 1].hash = $, !jt(p) && p.attachments && p.attachments.forEach((D) => {
795
+ const { hash: E, ...c } = D;
796
+ h.attachments[E] = {
797
+ ...c
789
798
  };
790
799
  });
791
800
  });
792
801
  }
793
- function Se(e, t, i) {
802
+ function Oe(e, t, i) {
794
803
  const n = ie(e, t);
795
- return ct.mkdirSync(e, { recursive: !0 }), new Promise((a, p) => {
804
+ return ct.mkdirSync(e, { recursive: !0 }), new Promise((a, s) => {
796
805
  try {
797
- ct.writeFile(n, i, {}, (s) => {
798
- s ? p(s) : a(n);
806
+ ct.writeFile(n, i, {}, (r) => {
807
+ r ? s(r) : a(n);
799
808
  });
800
- } catch (s) {
801
- p(s);
809
+ } catch (r) {
810
+ s(r);
802
811
  }
803
812
  });
804
813
  }
@@ -808,11 +817,11 @@ function qt(e) {
808
817
  function $e(e) {
809
818
  return new Promise((t, i) => {
810
819
  ee.get(e, (n) => {
811
- const a = [], p = n.headers["content-type"];
812
- n.on("data", (s) => {
813
- a.push(s);
820
+ const a = [], s = n.headers["content-type"];
821
+ n.on("data", (r) => {
822
+ a.push(r);
814
823
  }), n.on("end", () => {
815
- t({ buffer: Buffer.concat(a), mimeType: p });
824
+ t({ buffer: Buffer.concat(a), mimeType: s });
816
825
  });
817
826
  }).on("error", (n) => {
818
827
  i(n);
@@ -827,26 +836,26 @@ function wt(e) {
827
836
  return [X, Y].includes(e.type);
828
837
  }
829
838
  function jt(e) {
830
- return [Ft, X, Y, rt, Rt].includes(e.type);
839
+ return [Ft, X, Y, st, Rt].includes(e.type);
831
840
  }
832
841
  function H(e, t, i, n, a = "global") {
833
842
  if (!e)
834
843
  throw new Error("Empty action type");
835
844
  if (typeof e != "string")
836
845
  throw new Error(`Invalid action type: ${JSON.stringify(e)}`);
837
- const p = { type: e, input: t, scope: a };
838
- i && (p.attachments = i);
846
+ const s = { type: e, input: t, scope: a };
847
+ i && (s.attachments = i);
839
848
  try {
840
- n == null || n().parse(p.input);
841
- } catch (s) {
842
- throw new Error(`Invalid action input: ${s}`);
849
+ n == null || n().parse(s.input);
850
+ } catch (r) {
851
+ throw new Error(`Invalid action input: ${r}`);
843
852
  }
844
- return p;
853
+ return s;
845
854
  }
846
855
  function Te(e, t = Lt) {
847
- return (i, n, a, p) => t(i, n, e, a, p);
856
+ return (i, n, a, s) => t(i, n, e, a, s);
848
857
  }
849
- const ke = (e, t) => ({
858
+ const _e = (e, t) => ({
850
859
  name: "",
851
860
  documentType: "",
852
861
  revision: {
@@ -858,8 +867,8 @@ const ke = (e, t) => ({
858
867
  attachments: {},
859
868
  ...e,
860
869
  state: (t == null ? void 0 : t(e == null ? void 0 : e.state)) ?? (e == null ? void 0 : e.state) ?? { global: {}, local: {} }
861
- }), _e = (e, t) => {
862
- const i = ke(
870
+ }), ke = (e, t) => {
871
+ const i = _e(
863
872
  e,
864
873
  t
865
874
  );
@@ -869,7 +878,7 @@ const ke = (e, t) => ({
869
878
  operations: { global: [], local: [] },
870
879
  clipboard: []
871
880
  };
872
- }, xt = (e, t = "global") => at(st(e.state[t] || "")), Be = (e, t = 1e3) => {
881
+ }, xt = (e, t = "global") => at(rt(e.state[t] || "")), Be = (e, t = 1e3) => {
873
882
  const i = Math.random() * t;
874
883
  return at(`${(e ?? /* @__PURE__ */ new Date()).toISOString()}${i}`);
875
884
  };
@@ -879,37 +888,37 @@ function ot(e) {
879
888
  function Ae(e, t) {
880
889
  const i = [...e];
881
890
  let n = t || 0, a = i.length > 0 ? i[i.length - 1].index : 0;
882
- const p = [];
883
- for (const s of i.reverse()) {
891
+ const s = [];
892
+ for (const r of i.reverse()) {
884
893
  if (n > 0) {
885
- const x = a - s.index;
894
+ const x = a - r.index;
886
895
  n -= x;
887
896
  }
888
897
  if (n < 0)
889
898
  throw new Error("Invalid operation index, missing operations");
890
899
  const l = {
891
900
  ignore: n > 0,
892
- operation: s
893
- }, c = s.skip > 0 ? s.skip + 1 : 0;
894
- if (c > 0 && c > n) {
895
- const x = c - n;
901
+ operation: r
902
+ }, p = r.skip > 0 ? r.skip + 1 : 0;
903
+ if (p > 0 && p > n) {
904
+ const x = p - n;
896
905
  n = n + x;
897
906
  }
898
- a = s.index, p.push(l);
907
+ a = r.index, s.push(l);
899
908
  }
900
- return p.reverse();
909
+ return s.reverse();
901
910
  }
902
911
  function Ne(e, t, i) {
903
- const n = e.slice().sort((l, c) => l.skip - c.skip).sort((l, c) => l.index - c.index);
904
- let a = i, p = 0, s = t;
912
+ const n = e.slice().sort((l, p) => l.skip - p.skip).sort((l, p) => l.index - p.index);
913
+ let a = i, s = 0, r = t;
905
914
  for (const l of n.reverse()) {
906
- const c = s - l.index;
907
- if (a = a - c, a > -1)
908
- p++, s = l.index;
915
+ const p = r - l.index;
916
+ if (a = a - p, a > -1)
917
+ s++, r = l.index;
909
918
  else
910
919
  break;
911
920
  }
912
- return p;
921
+ return s;
913
922
  }
914
923
  function Ze(e) {
915
924
  return Object.values(e).flatMap((t) => t).sort(
@@ -921,89 +930,79 @@ function De(e) {
921
930
  (t, i) => new Date(t.operation.timestamp).getTime() - new Date(i.operation.timestamp).getTime()
922
931
  );
923
932
  }
924
- function mt(e, t, i, n, a, p = Lt, s = {}, l) {
925
- const c = Te(i, p);
926
- return Ct(
933
+ function mt(e, t, i, n, a, s = Lt, r = {}, l) {
934
+ const p = Te(i, s);
935
+ return Jt(
927
936
  e,
928
937
  t,
929
- c,
938
+ p,
930
939
  n,
931
940
  a,
932
- s,
941
+ r,
933
942
  l
934
943
  );
935
944
  }
936
- function Ct(e, t, i, n, a, p = {}, s) {
937
- const l = (s == null ? void 0 : s.checkHashes) ?? !0, c = _e(e), x = Object.keys(t).reduce((_, A) => {
938
- const r = A;
945
+ function Jt(e, t, i, n, a, s = {}, r) {
946
+ const l = (r == null ? void 0 : r.checkHashes) ?? !0, p = ke(e), x = Object.keys(t).reduce(($, D) => {
947
+ const E = D;
939
948
  return {
940
- ..._,
941
- [r]: t[r].slice(0, a == null ? void 0 : a.revision[r])
949
+ ...$,
950
+ [E]: Ae(
951
+ t[E],
952
+ s[E]
953
+ )
942
954
  };
943
- }, {}), j = Object.keys(x).reduce(
944
- (_, A) => {
945
- const r = A;
946
- return {
947
- ..._,
948
- [r]: Ae(
949
- x[r],
950
- p[r]
951
- )
952
- };
953
- },
954
- {}
955
- ), E = De(j), g = E.reduce(
956
- (_, { ignore: A, operation: r }, m, b) => A ? i(_, yt(r.scope), n, {
957
- skip: r.skip,
955
+ }, {}), b = De(x), v = b.reduce(
956
+ ($, { ignore: D, operation: E }) => D ? i($, yt(E.scope), n, {
957
+ skip: E.skip,
958
958
  ignoreSkipOperations: !0
959
959
  // TODO: reuse hash?
960
- }) : i(_, r, n, {
961
- skip: r.skip,
960
+ }) : i($, E, n, {
961
+ skip: E.skip,
962
962
  ignoreSkipOperations: !0,
963
963
  reuseHash: !l
964
964
  }),
965
- c
965
+ p
966
966
  );
967
- if (!l) {
968
- for (const _ of Object.keys(g.state))
969
- for (let A = E.length - 1; A >= 0; A--)
970
- if (E[A].operation.scope === _) {
971
- if (E[A].operation.hash !== xt(g, _))
972
- throw new Error(`Hash mismatch for scope ${_}`);
967
+ if (!l)
968
+ for (const $ of Object.keys(v.state))
969
+ for (let D = b.length - 1; D >= 0; D--) {
970
+ const { ignore: E, operation: c } = b[D];
971
+ if (!(E || c.scope !== $)) {
972
+ if (c.hash !== xt(v, $))
973
+ throw new Error(`Hash mismatch for scope ${$}`);
973
974
  break;
974
975
  }
975
- }
976
- const S = Object.keys(
977
- g.operations
976
+ }
977
+ const h = Object.keys(
978
+ v.operations
978
979
  ).reduce(
979
- (_, A) => {
980
- const r = A, m = a && a.revision[r] < t[r].length ? t[r].slice(a.revision[r]) : [];
980
+ ($, D) => {
981
+ const E = D;
981
982
  return {
982
- ..._,
983
- [r]: [
984
- ...g.operations[r].map((b, D) => {
985
- var U;
983
+ ...$,
984
+ [E]: [
985
+ ...v.operations[E].map((c, u) => {
986
+ var y;
986
987
  return {
987
- ...b,
988
- timestamp: ((U = t[r][D]) == null ? void 0 : U.timestamp) ?? b.timestamp
988
+ ...c,
989
+ timestamp: ((y = t[E][u]) == null ? void 0 : y.timestamp) ?? c.timestamp
989
990
  };
990
- }),
991
- ...m
991
+ })
992
992
  ]
993
993
  };
994
994
  },
995
995
  { global: [], local: [] }
996
- ), F = Object.values(S).reduce((_, A) => {
997
- for (const r of A)
998
- r.timestamp > _ && (_ = r.timestamp);
999
- return _;
996
+ ), O = Object.values(h).reduce(($, D) => {
997
+ const E = D[D.length - 1];
998
+ return (E == null ? void 0 : E.timestamp) > $ && ($ = E.timestamp), $;
1000
999
  }, e.lastModified);
1001
- return { ...g, operations: S, lastModified: F };
1000
+ return { ...v, operations: h, lastModified: O };
1002
1001
  }
1003
1002
  function Ge(e, t) {
1004
- return st(e) === st(t);
1003
+ return rt(e) === rt(t);
1005
1004
  }
1006
- const Jt = (e) => H(
1005
+ const Ct = (e) => H(
1007
1006
  "SET_NAME",
1008
1007
  e,
1009
1008
  void 0,
@@ -1038,7 +1037,7 @@ const Jt = (e) => H(
1038
1037
  noop: yt,
1039
1038
  prune: Kt,
1040
1039
  redo: Vt,
1041
- setName: Jt,
1040
+ setName: Ct,
1042
1041
  undo: Ut
1043
1042
  }, Symbol.toStringTag, { value: "Module" })), Ht = { "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"] };
1044
1043
  Object.freeze(Ht);
@@ -1048,21 +1047,21 @@ var L = function(e, t, i, n) {
1048
1047
  if (typeof t == "function" ? e !== t || !n : !t.has(e))
1049
1048
  throw new TypeError("Cannot read private member from an object whose class did not declare it");
1050
1049
  return i === "m" ? n : i === "a" ? n.call(e) : n ? n.value : t.get(e);
1051
- }, K, Z, V;
1050
+ }, K, Z, U;
1052
1051
  class Me {
1053
1052
  constructor(...t) {
1054
- K.set(this, /* @__PURE__ */ new Map()), Z.set(this, /* @__PURE__ */ new Map()), V.set(this, /* @__PURE__ */ new Map());
1053
+ K.set(this, /* @__PURE__ */ new Map()), Z.set(this, /* @__PURE__ */ new Map()), U.set(this, /* @__PURE__ */ new Map());
1055
1054
  for (const i of t)
1056
1055
  this.define(i);
1057
1056
  }
1058
1057
  define(t, i = !1) {
1059
1058
  for (let [n, a] of Object.entries(t)) {
1060
- n = n.toLowerCase(), a = a.map((l) => l.toLowerCase()), L(this, V, "f").has(n) || L(this, V, "f").set(n, /* @__PURE__ */ new Set());
1061
- const p = L(this, V, "f").get(n);
1062
- let s = !0;
1059
+ n = n.toLowerCase(), a = a.map((l) => l.toLowerCase()), L(this, U, "f").has(n) || L(this, U, "f").set(n, /* @__PURE__ */ new Set());
1060
+ const s = L(this, U, "f").get(n);
1061
+ let r = !0;
1063
1062
  for (let l of a) {
1064
- const c = l.startsWith("*");
1065
- if (l = c ? l.slice(1) : l, p == null || p.add(l), s && L(this, Z, "f").set(n, l), s = !1, c)
1063
+ const p = l.startsWith("*");
1064
+ if (l = p ? l.slice(1) : l, s == null || s.add(l), r && L(this, Z, "f").set(n, l), r = !1, p)
1066
1065
  continue;
1067
1066
  const x = L(this, K, "f").get(l);
1068
1067
  if (x && x != n && !i)
@@ -1083,13 +1082,13 @@ class Me {
1083
1082
  return typeof t != "string" ? null : (t = (i = t == null ? void 0 : t.split) == null ? void 0 : i.call(t, ";")[0], (t && L(this, Z, "f").get(t.trim().toLowerCase())) ?? null);
1084
1083
  }
1085
1084
  getAllExtensions(t) {
1086
- return typeof t != "string" ? null : L(this, V, "f").get(t.toLowerCase()) ?? null;
1085
+ return typeof t != "string" ? null : L(this, U, "f").get(t.toLowerCase()) ?? null;
1087
1086
  }
1088
1087
  _freeze() {
1089
1088
  this.define = () => {
1090
1089
  throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances");
1091
1090
  }, Object.freeze(this);
1092
- for (const t of L(this, V, "f").values())
1091
+ for (const t of L(this, U, "f").values())
1093
1092
  Object.freeze(t);
1094
1093
  return this;
1095
1094
  }
@@ -1100,83 +1099,83 @@ class Me {
1100
1099
  };
1101
1100
  }
1102
1101
  }
1103
- K = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new WeakMap(), V = /* @__PURE__ */ new WeakMap();
1102
+ K = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new WeakMap(), U = /* @__PURE__ */ new WeakMap();
1104
1103
  const Pe = new Me(Ht)._freeze();
1105
1104
  function Ie(e) {
1106
1105
  const t = [], i = Object.keys(e);
1107
1106
  for (const n of i) {
1108
- const a = e[n].sort((p, s) => p.index - s.index);
1109
- for (let p = 0; p < a.length; p++)
1110
- a[p].index !== p && t.push({
1111
- message: `Invalid operation index ${a[p].index} at position ${p}`,
1107
+ const a = e[n].sort((s, r) => s.index - r.index);
1108
+ for (let s = 0; s < a.length; s++)
1109
+ a[s].index !== s && t.push({
1110
+ message: `Invalid operation index ${a[s].index} at position ${s}`,
1112
1111
  details: {
1113
- position: p,
1114
- operation: a[p],
1115
- scope: a[p].scope
1112
+ position: s,
1113
+ operation: a[s],
1114
+ scope: a[s].scope
1116
1115
  }
1117
1116
  });
1118
1117
  }
1119
1118
  return t;
1120
1119
  }
1121
1120
  const Wt = async (e) => {
1122
- const t = new St(), { name: i, revision: n, documentType: a, created: p, lastModified: s } = e, l = {
1121
+ const t = new Ot(), { name: i, revision: n, documentType: a, created: s, lastModified: r } = e, l = {
1123
1122
  name: i,
1124
1123
  revision: n,
1125
1124
  documentType: a,
1126
- created: p,
1127
- lastModified: s
1125
+ created: s,
1126
+ lastModified: r
1128
1127
  };
1129
1128
  return t.file("header.json", JSON.stringify(l, null, 2)), t.file(
1130
1129
  "state.json",
1131
1130
  JSON.stringify(e.initialState || {}, null, 2)
1132
1131
  ), t.file("operations.json", JSON.stringify(e.operations, null, 2)), Object.keys(e.attachments).forEach((x) => {
1133
- const { data: j, ...E } = e.attachments[x];
1134
- t.file(x, j, {
1132
+ const { data: b, ...v } = e.attachments[x];
1133
+ t.file(x, b, {
1135
1134
  base64: !0,
1136
1135
  createFolders: !0,
1137
- comment: JSON.stringify(E)
1136
+ comment: JSON.stringify(v)
1138
1137
  });
1139
1138
  }), t;
1140
1139
  }, ze = async (e, t, i, n) => {
1141
- const p = await (await Wt(e)).generateAsync({
1140
+ const s = await (await Wt(e)).generateAsync({
1142
1141
  type: "uint8array",
1143
1142
  streamFiles: !0
1144
- }), s = n ?? e.name, l = `.${i}.zip`;
1145
- return Se(
1143
+ }), r = n ?? e.name, l = `.${i}.zip`;
1144
+ return Oe(
1146
1145
  t,
1147
- s.endsWith(l) ? s : `${s}${l}`,
1148
- p
1146
+ r.endsWith(l) ? r : `${r}${l}`,
1147
+ s
1149
1148
  );
1150
1149
  }, Xe = async (e, t) => {
1151
1150
  const n = await (await Wt(e)).generateAsync({ type: "blob" }), a = await t.createWritable();
1152
1151
  await a.write(n), await a.close();
1153
- }, Ot = async (e, t, i) => {
1152
+ }, St = async (e, t, i) => {
1154
1153
  const n = qt(e);
1155
1154
  return Fe(n, t, i);
1156
1155
  }, Fe = async (e, t, i) => {
1157
- const n = new St();
1156
+ const n = new Ot();
1158
1157
  return await n.loadAsync(e), Re(n, t, i);
1159
1158
  };
1160
1159
  async function Re(e, t, i) {
1161
1160
  const n = e.file("state.json");
1162
1161
  if (!n)
1163
1162
  throw new Error("Initial state not found");
1164
- const a = await n.async("string"), p = JSON.parse(a), s = e.file("header.json");
1163
+ const a = await n.async("string"), s = JSON.parse(a), r = e.file("header.json");
1165
1164
  let l;
1166
- s && (l = JSON.parse(await s.async("string")));
1167
- const c = e.file("operations.json");
1168
- if (!c)
1165
+ r && (l = JSON.parse(await r.async("string")));
1166
+ const p = e.file("operations.json");
1167
+ if (!p)
1169
1168
  throw new Error("Operations history not found");
1170
1169
  const x = JSON.parse(
1171
- await c.async("string")
1172
- ), j = Ie(x);
1173
- if (j.length) {
1174
- const g = j.map((S) => S.message);
1175
- throw new Error(g.join(`
1170
+ await p.async("string")
1171
+ ), b = Ie(x);
1172
+ if (b.length) {
1173
+ const h = b.map((O) => O.message);
1174
+ throw new Error(h.join(`
1176
1175
  `));
1177
1176
  }
1178
- let E = Ct(
1179
- p,
1177
+ let v = Jt(
1178
+ s,
1180
1179
  x,
1181
1180
  t,
1182
1181
  void 0,
@@ -1184,10 +1183,10 @@ async function Re(e, t, i) {
1184
1183
  {},
1185
1184
  i
1186
1185
  );
1187
- return l && (E = {
1188
- ...E,
1186
+ return l && (v = {
1187
+ ...v,
1189
1188
  ...l
1190
- }), E;
1189
+ }), v;
1191
1190
  }
1192
1191
  function Bt(e) {
1193
1192
  const t = e.replace(/^.*\./, "") || void 0, i = e.replace(/^.*[/\\]/, "") || void 0;
@@ -1245,7 +1244,7 @@ class ei {
1245
1244
  * @param path - The file path where the state is stored.
1246
1245
  */
1247
1246
  async loadFromFile(t) {
1248
- this._document = await Ot(t, this._reducer);
1247
+ this._document = await St(t, this._reducer);
1249
1248
  }
1250
1249
  /**
1251
1250
  * Loads the state of the document from a file and returns it.
@@ -1254,7 +1253,7 @@ class ei {
1254
1253
  * @returns The state of the document.
1255
1254
  */
1256
1255
  static async stateFromFile(t, i) {
1257
- return await Ot(t, i);
1256
+ return await St(t, i);
1258
1257
  }
1259
1258
  /**
1260
1259
  * Gets the current state of the document.
@@ -1325,7 +1324,7 @@ class ei {
1325
1324
  * @param name - The new name of the document.
1326
1325
  */
1327
1326
  setName(t) {
1328
- return this.dispatch(Jt(t)), this;
1327
+ return this.dispatch(Ct(t)), this;
1329
1328
  }
1330
1329
  /**
1331
1330
  * Reverts a number of actions from the document.
@@ -1375,10 +1374,10 @@ export {
1375
1374
  Ie as A,
1376
1375
  ei as B,
1377
1376
  Lt as C,
1378
- Oe as D,
1377
+ Se as D,
1379
1378
  We as E,
1380
- ke as a,
1381
- _e as b,
1379
+ _e as a,
1380
+ ke as b,
1382
1381
  Te as c,
1383
1382
  Xe as d,
1384
1383
  Fe as e,
@@ -1388,7 +1387,7 @@ export {
1388
1387
  jt as i,
1389
1388
  Ne as j,
1390
1389
  Wt as k,
1391
- Ot as l,
1390
+ St as l,
1392
1391
  ti as m,
1393
1392
  Ye as n,
1394
1393
  xt as o,
@@ -1399,7 +1398,7 @@ export {
1399
1398
  wt as t,
1400
1399
  Ae as u,
1401
1400
  ot as v,
1402
- Ct as w,
1401
+ Jt as w,
1403
1402
  mt as x,
1404
1403
  De as y,
1405
1404
  Ze as z