document-model 1.1.0-experimental.1 → 1.1.0-experimental.2

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 (40) 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/browser/cjs/internal/{index-DypcJuba.js → index-DLodkpOq.js} +1 -1
  5. package/dist/browser/cjs/internal/index-azT4DEce.js +1 -0
  6. package/dist/browser/cjs/internal/{object-BU2CI8g7.js → object-CMr-_AP8.js} +21 -21
  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-BzNpRs2a.js +44 -0
  11. package/dist/browser/es/internal/{index-CyBZ1dJQ.js → index-CL_1ivGq.js} +1 -1
  12. package/dist/browser/es/internal/{object-CPDHmXxz.js → object-FFc9n_3I.js} +917 -840
  13. package/dist/browser/src/document/object.d.ts +35 -0
  14. package/dist/browser/src/document/types.d.ts +6 -0
  15. package/dist/browser/src/document/utils/base.d.ts +5 -4
  16. package/dist/browser/src/document/utils/document-helpers.d.ts +1 -1
  17. package/dist/browser/src/document/utils/index.d.ts +1 -1
  18. package/dist/node/cjs/document-model.js +1 -1
  19. package/dist/node/cjs/document.js +1 -1
  20. package/dist/node/cjs/index.js +1 -1
  21. package/dist/node/cjs/internal/{index-Bt4KwBzM.js → index-CPeTtUsk.js} +1 -1
  22. package/dist/node/cjs/internal/index-CTavCc1t.js +1 -0
  23. package/dist/node/cjs/internal/object-DhI24-1e.js +20 -0
  24. package/dist/node/es/document-model.js +2 -2
  25. package/dist/node/es/document.js +2 -2
  26. package/dist/node/es/index.js +3 -3
  27. package/dist/node/es/internal/index-8lUz8qED.js +44 -0
  28. package/dist/node/es/internal/{index-6nUwJlFL.js → index-A880In4b.js} +1 -1
  29. package/dist/node/es/internal/{object-DofGWMf1.js → object-C9n9Ijnt.js} +675 -598
  30. package/dist/node/src/document/object.d.ts +35 -0
  31. package/dist/node/src/document/types.d.ts +6 -0
  32. package/dist/node/src/document/utils/base.d.ts +5 -4
  33. package/dist/node/src/document/utils/document-helpers.d.ts +1 -1
  34. package/dist/node/src/document/utils/index.d.ts +1 -1
  35. package/package.json +1 -1
  36. package/dist/browser/cjs/internal/index-DZx9eknf.js +0 -1
  37. package/dist/browser/es/internal/index-BP3Z2ZVF.js +0 -43
  38. package/dist/node/cjs/internal/index-CwTTSCCW.js +0 -1
  39. package/dist/node/cjs/internal/object-Bc_eSRcx.js +0 -20
  40. package/dist/node/es/internal/index-CLgAZiia.js +0 -43
@@ -1,165 +1,165 @@
1
- var ae = Object.defineProperty;
2
- var pe = (t, e, n) => e in t ? ae(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var st = (t, e, n) => (pe(t, typeof e != "symbol" ? e + "" : e, n), n);
4
- import { produce as pt, castDraft as at, castImmutable as ce, freeze as le } from "immer";
5
- import { z as u } from "zod";
1
+ var pe = Object.defineProperty;
2
+ var ce = (t, e, n) => e in t ? pe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var st = (t, e, n) => (ce(t, typeof e != "symbol" ? e + "" : e, n), n);
4
+ import { produce as pt, castDraft as at, castImmutable as le, freeze as me } from "immer";
5
+ import { z as f } from "zod";
6
6
  import Dt from "jszip";
7
- import me from "crypto";
7
+ import ue from "crypto";
8
8
  import ut from "fs";
9
- import ue from "https";
10
- import { join as fe } from "path";
11
- const _t = (t) => t != null, de = u.any().refine((t) => _t(t)), Tt = u.enum(["LOAD_STATE"]), Nt = u.enum(["PRUNE"]), vt = u.enum(["REDO"]), It = u.enum(["SET_NAME"]), At = u.enum(["UNDO"]);
12
- function ge() {
13
- return u.object({
14
- __typename: u.literal("Action").optional(),
15
- type: u.string()
9
+ import fe from "https";
10
+ import { join as de } from "path";
11
+ const Tt = (t) => t != null, ge = f.any().refine((t) => Tt(t)), _t = f.enum(["LOAD_STATE"]), Nt = f.enum(["PRUNE"]), vt = f.enum(["REDO"]), It = f.enum(["SET_NAME"]), At = f.enum(["UNDO"]);
12
+ function he() {
13
+ return f.object({
14
+ __typename: f.literal("Action").optional(),
15
+ type: f.string()
16
16
  });
17
17
  }
18
18
  function Y() {
19
- return u.literal("global").or(u.literal("local"));
19
+ return f.literal("global").or(f.literal("local"));
20
20
  }
21
21
  function Pt() {
22
- return u.union([
22
+ return f.union([
23
23
  Mt(),
24
+ Rt(),
24
25
  Ct(),
25
26
  Ft(),
26
- Lt(),
27
- Rt()
27
+ Lt()
28
28
  ]);
29
29
  }
30
- function he() {
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 xe() {
31
+ return f.object({
32
+ __typename: f.literal("DocumentFile").optional(),
33
+ data: f.string(),
34
+ extension: f.string().nullable(),
35
+ fileName: f.string().nullable(),
36
+ mimeType: f.string()
37
37
  });
38
38
  }
39
39
  function Mt() {
40
- return u.object({
41
- input: u.lazy(() => ht()),
42
- type: Tt,
40
+ return f.object({
41
+ input: f.lazy(() => ht()),
42
+ type: _t,
43
43
  scope: Y()
44
44
  });
45
45
  }
46
46
  function ht() {
47
- return u.object({
48
- operations: u.number(),
49
- state: u.lazy(() => zt())
47
+ return f.object({
48
+ operations: f.number(),
49
+ state: f.lazy(() => zt())
50
50
  });
51
51
  }
52
52
  function zt() {
53
- return u.object({
54
- data: u.unknown().nullish(),
55
- name: u.string()
53
+ return f.object({
54
+ data: f.unknown().nullish(),
55
+ name: f.string()
56
56
  });
57
57
  }
58
- function xe() {
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 ye() {
59
+ return f.object({
60
+ __typename: f.literal("Operation").optional(),
61
+ hash: f.string(),
62
+ index: f.number(),
63
+ timestamp: f.string().datetime(),
64
+ type: f.string()
65
65
  });
66
66
  }
67
- function Ct() {
68
- return u.object({
69
- input: u.lazy(() => xt()),
67
+ function Rt() {
68
+ return f.object({
69
+ input: f.lazy(() => xt()),
70
70
  type: Nt,
71
71
  scope: Y()
72
72
  });
73
73
  }
74
74
  function xt() {
75
- return u.object({
76
- end: u.number().nullish(),
77
- start: u.number().nullish()
75
+ return f.object({
76
+ end: f.number().nullish(),
77
+ start: f.number().nullish()
78
78
  });
79
79
  }
80
- const yt = u.number;
81
- function Ft() {
82
- return u.object({
80
+ const yt = f.number;
81
+ function Ct() {
82
+ return f.object({
83
83
  input: yt(),
84
84
  type: vt,
85
85
  scope: Y()
86
86
  });
87
87
  }
88
- const bt = u.string;
89
- function Lt() {
90
- return u.object({
88
+ const bt = f.string;
89
+ function Ft() {
90
+ return f.object({
91
91
  input: bt(),
92
92
  type: It,
93
- scope: u.literal("global")
93
+ scope: f.literal("global")
94
94
  });
95
95
  }
96
- function ye() {
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()
96
+ function be() {
97
+ return f.object({
98
+ __typename: f.literal("SetNameOperation").optional(),
99
+ hash: f.string(),
100
+ index: f.number(),
101
+ input: f.string(),
102
+ timestamp: f.string().datetime(),
103
+ type: f.string()
104
104
  });
105
105
  }
106
- const wt = u.number;
107
- function Rt() {
108
- return u.object({
106
+ const wt = f.number;
107
+ function Lt() {
108
+ return f.object({
109
109
  input: wt(),
110
110
  type: At,
111
111
  scope: Y()
112
112
  });
113
113
  }
114
- const cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
114
+ const ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
115
115
  __proto__: null,
116
- ActionSchema: ge,
116
+ ActionSchema: he,
117
117
  BaseActionSchema: Pt,
118
- DocumentFileSchema: he,
118
+ DocumentFileSchema: xe,
119
119
  LoadStateActionInputSchema: ht,
120
120
  LoadStateActionSchema: Mt,
121
121
  LoadStateActionStateInputSchema: zt,
122
- Load_StateSchema: Tt,
123
- OperationSchema: xe,
122
+ Load_StateSchema: _t,
123
+ OperationSchema: ye,
124
124
  OperationScopeSchema: Y,
125
125
  PruneActionInputSchema: xt,
126
- PruneActionSchema: Ct,
126
+ PruneActionSchema: Rt,
127
127
  PruneSchema: Nt,
128
128
  RedoActionInputSchema: yt,
129
- RedoActionSchema: Ft,
129
+ RedoActionSchema: Ct,
130
130
  RedoSchema: vt,
131
131
  SetNameActionInputSchema: bt,
132
- SetNameActionSchema: Lt,
133
- SetNameOperationSchema: ye,
132
+ SetNameActionSchema: Ft,
133
+ SetNameOperationSchema: be,
134
134
  Set_NameSchema: It,
135
135
  UndoActionInputSchema: wt,
136
- UndoActionSchema: Rt,
136
+ UndoActionSchema: Lt,
137
137
  UndoSchema: At,
138
- definedNonNullAnySchema: de,
139
- isDefinedNonNullAny: _t
138
+ definedNonNullAnySchema: ge,
139
+ isDefinedNonNullAny: Tt
140
140
  }, Symbol.toStringTag, { value: "Module" }));
141
- function be(t) {
141
+ function we(t) {
142
142
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
143
143
  }
144
144
  var ft = { exports: {} };
145
145
  (function(t, e) {
146
- const { hasOwnProperty: n } = Object.prototype, i = R();
147
- i.configure = R, i.stringify = i, i.default = i, e.stringify = i, e.configure = R, t.exports = i;
146
+ const { hasOwnProperty: n } = Object.prototype, i = C();
147
+ i.configure = C, i.stringify = i, i.default = i, e.stringify = i, e.configure = C, t.exports = i;
148
148
  const o = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;
149
- function a(l) {
150
- return l.length < 5e3 && !o.test(l) ? `"${l}"` : JSON.stringify(l);
149
+ function a(c) {
150
+ return c.length < 5e3 && !o.test(c) ? `"${c}"` : JSON.stringify(c);
151
151
  }
152
- function r(l) {
153
- if (l.length > 200)
154
- return l.sort();
155
- for (let m = 1; m < l.length; m++) {
156
- const j = l[m];
157
- let A = m;
158
- for (; A !== 0 && l[A - 1] > j; )
159
- l[A] = l[A - 1], A--;
160
- l[A] = j;
152
+ function r(c) {
153
+ if (c.length > 200)
154
+ return c.sort();
155
+ for (let l = 1; l < c.length; l++) {
156
+ const u = c[l];
157
+ let _ = l;
158
+ for (; _ !== 0 && c[_ - 1] > u; )
159
+ c[_] = c[_ - 1], _--;
160
+ c[_] = u;
161
161
  }
162
- return l;
162
+ return c;
163
163
  }
164
164
  const p = Object.getOwnPropertyDescriptor(
165
165
  Object.getPrototypeOf(
@@ -169,25 +169,25 @@ var ft = { exports: {} };
169
169
  ),
170
170
  Symbol.toStringTag
171
171
  ).get;
172
- function c(l) {
173
- return p.call(l) !== void 0 && l.length !== 0;
172
+ function m(c) {
173
+ return p.call(c) !== void 0 && c.length !== 0;
174
174
  }
175
- function f(l, m, j) {
176
- l.length < j && (j = l.length);
177
- const A = m === "," ? "" : " ";
178
- let H = `"0":${A}${l[0]}`;
179
- for (let C = 1; C < j; C++)
180
- H += `${m}"${C}":${A}${l[C]}`;
181
- return H;
175
+ function d(c, l, u) {
176
+ c.length < u && (u = c.length);
177
+ const _ = l === "," ? "" : " ";
178
+ let F = `"0":${_}${c[0]}`;
179
+ for (let M = 1; M < u; M++)
180
+ F += `${l}"${M}":${_}${c[M]}`;
181
+ return F;
182
182
  }
183
- function x(l) {
184
- if (n.call(l, "circularValue")) {
185
- const m = l.circularValue;
186
- if (typeof m == "string")
187
- return `"${m}"`;
188
- if (m == null)
189
- return m;
190
- if (m === Error || m === TypeError)
183
+ function h(c) {
184
+ if (n.call(c, "circularValue")) {
185
+ const l = c.circularValue;
186
+ if (typeof l == "string")
187
+ return `"${l}"`;
188
+ if (l == null)
189
+ return l;
190
+ if (l === Error || l === TypeError)
191
191
  return {
192
192
  toString() {
193
193
  throw new TypeError("Converting circular structure to JSON");
@@ -197,180 +197,180 @@ var ft = { exports: {} };
197
197
  }
198
198
  return '"[Circular]"';
199
199
  }
200
- function E(l, m) {
201
- let j;
202
- if (n.call(l, m) && (j = l[m], typeof j != "boolean"))
203
- throw new TypeError(`The "${m}" argument must be of type boolean`);
204
- return j === void 0 ? !0 : j;
200
+ function b(c, l) {
201
+ let u;
202
+ if (n.call(c, l) && (u = c[l], typeof u != "boolean"))
203
+ throw new TypeError(`The "${l}" argument must be of type boolean`);
204
+ return u === void 0 ? !0 : u;
205
205
  }
206
- function w(l, m) {
207
- let j;
208
- if (n.call(l, m)) {
209
- if (j = l[m], typeof j != "number")
210
- throw new TypeError(`The "${m}" argument must be of type number`);
211
- if (!Number.isInteger(j))
212
- throw new TypeError(`The "${m}" argument must be an integer`);
213
- if (j < 1)
214
- throw new RangeError(`The "${m}" argument must be >= 1`);
206
+ function O(c, l) {
207
+ let u;
208
+ if (n.call(c, l)) {
209
+ if (u = c[l], typeof u != "number")
210
+ throw new TypeError(`The "${l}" argument must be of type number`);
211
+ if (!Number.isInteger(u))
212
+ throw new TypeError(`The "${l}" argument must be an integer`);
213
+ if (u < 1)
214
+ throw new RangeError(`The "${l}" argument must be >= 1`);
215
215
  }
216
- return j === void 0 ? 1 / 0 : j;
216
+ return u === void 0 ? 1 / 0 : u;
217
217
  }
218
- function y(l) {
219
- return l === 1 ? "1 item" : `${l} items`;
218
+ function v(c) {
219
+ return c === 1 ? "1 item" : `${c} items`;
220
220
  }
221
- function T(l) {
222
- const m = /* @__PURE__ */ new Set();
223
- for (const j of l)
224
- (typeof j == "string" || typeof j == "number") && m.add(String(j));
225
- return m;
221
+ function T(c) {
222
+ const l = /* @__PURE__ */ new Set();
223
+ for (const u of c)
224
+ (typeof u == "string" || typeof u == "number") && l.add(String(u));
225
+ return l;
226
226
  }
227
- function v(l) {
228
- if (n.call(l, "strict")) {
229
- const m = l.strict;
230
- if (typeof m != "boolean")
227
+ function P(c) {
228
+ if (n.call(c, "strict")) {
229
+ const l = c.strict;
230
+ if (typeof l != "boolean")
231
231
  throw new TypeError('The "strict" argument must be of type boolean');
232
- if (m)
233
- return (j) => {
234
- let A = `Object can not safely be stringified. Received type ${typeof j}`;
235
- throw typeof j != "function" && (A += ` (${j.toString()})`), new Error(A);
232
+ if (l)
233
+ return (u) => {
234
+ let _ = `Object can not safely be stringified. Received type ${typeof u}`;
235
+ throw typeof u != "function" && (_ += ` (${u.toString()})`), new Error(_);
236
236
  };
237
237
  }
238
238
  }
239
- function R(l) {
240
- l = { ...l };
241
- const m = v(l);
242
- m && (l.bigint === void 0 && (l.bigint = !1), "circularValue" in l || (l.circularValue = Error));
243
- const j = x(l), A = E(l, "bigint"), H = E(l, "deterministic"), C = w(l, "maximumDepth"), D = w(l, "maximumBreadth");
244
- function nt(P, s, d, b, h, S) {
245
- let g = s[P];
246
- switch (typeof g == "object" && g !== null && typeof g.toJSON == "function" && (g = g.toJSON(P)), g = b.call(s, P, g), typeof g) {
239
+ function C(c) {
240
+ c = { ...c };
241
+ const l = P(c);
242
+ l && (c.bigint === void 0 && (c.bigint = !1), "circularValue" in c || (c.circularValue = Error));
243
+ const u = h(c), _ = b(c, "bigint"), F = b(c, "deterministic"), M = O(c, "maximumDepth"), k = O(c, "maximumBreadth");
244
+ function nt(A, s, g, w, y, j) {
245
+ let x = s[A];
246
+ switch (typeof x == "object" && x !== null && typeof x.toJSON == "function" && (x = x.toJSON(A)), x = w.call(s, A, x), typeof x) {
247
247
  case "string":
248
- return a(g);
248
+ return a(x);
249
249
  case "object": {
250
- if (g === null)
250
+ if (x === null)
251
251
  return "null";
252
- if (d.indexOf(g) !== -1)
253
- return j;
254
- let O = "", k = ",";
255
- const _ = S;
256
- if (Array.isArray(g)) {
257
- if (g.length === 0)
252
+ if (g.indexOf(x) !== -1)
253
+ return u;
254
+ let S = "", $ = ",";
255
+ const D = j;
256
+ if (Array.isArray(x)) {
257
+ if (x.length === 0)
258
258
  return "[]";
259
- if (C < d.length + 1)
259
+ if (M < g.length + 1)
260
260
  return '"[Array]"';
261
- d.push(g), h !== "" && (S += h, O += `
262
- ${S}`, k = `,
263
- ${S}`);
264
- const z = Math.min(g.length, D);
265
- let q = 0;
266
- for (; q < z - 1; q++) {
267
- const ot = nt(String(q), g, d, b, h, S);
268
- O += ot !== void 0 ? ot : "null", O += k;
261
+ g.push(x), y !== "" && (j += y, S += `
262
+ ${j}`, $ = `,
263
+ ${j}`);
264
+ const R = Math.min(x.length, k);
265
+ let U = 0;
266
+ for (; U < R - 1; U++) {
267
+ const ot = nt(String(U), x, g, w, y, j);
268
+ S += ot !== void 0 ? ot : "null", S += $;
269
269
  }
270
- const U = nt(String(q), g, d, b, h, S);
271
- if (O += U !== void 0 ? U : "null", g.length - 1 > D) {
272
- const ot = g.length - D - 1;
273
- O += `${k}"... ${y(ot)} not stringified"`;
270
+ const J = nt(String(U), x, g, w, y, j);
271
+ if (S += J !== void 0 ? J : "null", x.length - 1 > k) {
272
+ const ot = x.length - k - 1;
273
+ S += `${$}"... ${v(ot)} not stringified"`;
274
274
  }
275
- return h !== "" && (O += `
276
- ${_}`), d.pop(), `[${O}]`;
275
+ return y !== "" && (S += `
276
+ ${D}`), g.pop(), `[${S}]`;
277
277
  }
278
- let N = Object.keys(g);
278
+ let N = Object.keys(x);
279
279
  const I = N.length;
280
280
  if (I === 0)
281
281
  return "{}";
282
- if (C < d.length + 1)
282
+ if (M < g.length + 1)
283
283
  return '"[Object]"';
284
- let $ = "", M = "";
285
- h !== "" && (S += h, k = `,
286
- ${S}`, $ = " ");
287
- const L = Math.min(I, D);
288
- H && !c(g) && (N = r(N)), d.push(g);
289
- for (let z = 0; z < L; z++) {
290
- const q = N[z], U = nt(q, g, d, b, h, S);
291
- U !== void 0 && (O += `${M}${a(q)}:${$}${U}`, M = k);
284
+ let E = "", z = "";
285
+ y !== "" && (j += y, $ = `,
286
+ ${j}`, E = " ");
287
+ const q = Math.min(I, k);
288
+ F && !m(x) && (N = r(N)), g.push(x);
289
+ for (let R = 0; R < q; R++) {
290
+ const U = N[R], J = nt(U, x, g, w, y, j);
291
+ J !== void 0 && (S += `${z}${a(U)}:${E}${J}`, z = $);
292
292
  }
293
- if (I > D) {
294
- const z = I - D;
295
- O += `${M}"...":${$}"${y(z)} not stringified"`, M = k;
293
+ if (I > k) {
294
+ const R = I - k;
295
+ S += `${z}"...":${E}"${v(R)} not stringified"`, z = $;
296
296
  }
297
- return h !== "" && M.length > 1 && (O = `
298
- ${S}${O}
299
- ${_}`), d.pop(), `{${O}}`;
297
+ return y !== "" && z.length > 1 && (S = `
298
+ ${j}${S}
299
+ ${D}`), g.pop(), `{${S}}`;
300
300
  }
301
301
  case "number":
302
- return isFinite(g) ? String(g) : m ? m(g) : "null";
302
+ return isFinite(x) ? String(x) : l ? l(x) : "null";
303
303
  case "boolean":
304
- return g === !0 ? "true" : "false";
304
+ return x === !0 ? "true" : "false";
305
305
  case "undefined":
306
306
  return;
307
307
  case "bigint":
308
- if (A)
309
- return String(g);
308
+ if (_)
309
+ return String(x);
310
310
  default:
311
- return m ? m(g) : void 0;
311
+ return l ? l(x) : void 0;
312
312
  }
313
313
  }
314
- function it(P, s, d, b, h, S) {
315
- switch (typeof s == "object" && s !== null && typeof s.toJSON == "function" && (s = s.toJSON(P)), typeof s) {
314
+ function it(A, s, g, w, y, j) {
315
+ switch (typeof s == "object" && s !== null && typeof s.toJSON == "function" && (s = s.toJSON(A)), typeof s) {
316
316
  case "string":
317
317
  return a(s);
318
318
  case "object": {
319
319
  if (s === null)
320
320
  return "null";
321
- if (d.indexOf(s) !== -1)
322
- return j;
323
- const g = S;
324
- let O = "", k = ",";
321
+ if (g.indexOf(s) !== -1)
322
+ return u;
323
+ const x = j;
324
+ let S = "", $ = ",";
325
325
  if (Array.isArray(s)) {
326
326
  if (s.length === 0)
327
327
  return "[]";
328
- if (C < d.length + 1)
328
+ if (M < g.length + 1)
329
329
  return '"[Array]"';
330
- d.push(s), h !== "" && (S += h, O += `
331
- ${S}`, k = `,
332
- ${S}`);
333
- const I = Math.min(s.length, D);
334
- let $ = 0;
335
- for (; $ < I - 1; $++) {
336
- const L = it(String($), s[$], d, b, h, S);
337
- O += L !== void 0 ? L : "null", O += k;
330
+ g.push(s), y !== "" && (j += y, S += `
331
+ ${j}`, $ = `,
332
+ ${j}`);
333
+ const I = Math.min(s.length, k);
334
+ let E = 0;
335
+ for (; E < I - 1; E++) {
336
+ const q = it(String(E), s[E], g, w, y, j);
337
+ S += q !== void 0 ? q : "null", S += $;
338
338
  }
339
- const M = it(String($), s[$], d, b, h, S);
340
- if (O += M !== void 0 ? M : "null", s.length - 1 > D) {
341
- const L = s.length - D - 1;
342
- O += `${k}"... ${y(L)} not stringified"`;
339
+ const z = it(String(E), s[E], g, w, y, j);
340
+ if (S += z !== void 0 ? z : "null", s.length - 1 > k) {
341
+ const q = s.length - k - 1;
342
+ S += `${$}"... ${v(q)} not stringified"`;
343
343
  }
344
- return h !== "" && (O += `
345
- ${g}`), d.pop(), `[${O}]`;
344
+ return y !== "" && (S += `
345
+ ${x}`), g.pop(), `[${S}]`;
346
346
  }
347
- d.push(s);
348
- let _ = "";
349
- h !== "" && (S += h, k = `,
350
- ${S}`, _ = " ");
347
+ g.push(s);
348
+ let D = "";
349
+ y !== "" && (j += y, $ = `,
350
+ ${j}`, D = " ");
351
351
  let N = "";
352
- for (const I of b) {
353
- const $ = it(I, s[I], d, b, h, S);
354
- $ !== void 0 && (O += `${N}${a(I)}:${_}${$}`, N = k);
352
+ for (const I of w) {
353
+ const E = it(I, s[I], g, w, y, j);
354
+ E !== void 0 && (S += `${N}${a(I)}:${D}${E}`, N = $);
355
355
  }
356
- return h !== "" && N.length > 1 && (O = `
357
- ${S}${O}
358
- ${g}`), d.pop(), `{${O}}`;
356
+ return y !== "" && N.length > 1 && (S = `
357
+ ${j}${S}
358
+ ${x}`), g.pop(), `{${S}}`;
359
359
  }
360
360
  case "number":
361
- return isFinite(s) ? String(s) : m ? m(s) : "null";
361
+ return isFinite(s) ? String(s) : l ? l(s) : "null";
362
362
  case "boolean":
363
363
  return s === !0 ? "true" : "false";
364
364
  case "undefined":
365
365
  return;
366
366
  case "bigint":
367
- if (A)
367
+ if (_)
368
368
  return String(s);
369
369
  default:
370
- return m ? m(s) : void 0;
370
+ return l ? l(s) : void 0;
371
371
  }
372
372
  }
373
- function G(P, s, d, b, h) {
373
+ function G(A, s, g, w, y) {
374
374
  switch (typeof s) {
375
375
  case "string":
376
376
  return a(s);
@@ -378,74 +378,74 @@ ${g}`), d.pop(), `{${O}}`;
378
378
  if (s === null)
379
379
  return "null";
380
380
  if (typeof s.toJSON == "function") {
381
- if (s = s.toJSON(P), typeof s != "object")
382
- return G(P, s, d, b, h);
381
+ if (s = s.toJSON(A), typeof s != "object")
382
+ return G(A, s, g, w, y);
383
383
  if (s === null)
384
384
  return "null";
385
385
  }
386
- if (d.indexOf(s) !== -1)
387
- return j;
388
- const S = h;
386
+ if (g.indexOf(s) !== -1)
387
+ return u;
388
+ const j = y;
389
389
  if (Array.isArray(s)) {
390
390
  if (s.length === 0)
391
391
  return "[]";
392
- if (C < d.length + 1)
392
+ if (M < g.length + 1)
393
393
  return '"[Array]"';
394
- d.push(s), h += b;
395
- let $ = `
396
- ${h}`;
397
- const M = `,
398
- ${h}`, L = Math.min(s.length, D);
399
- let z = 0;
400
- for (; z < L - 1; z++) {
401
- const U = G(String(z), s[z], d, b, h);
402
- $ += U !== void 0 ? U : "null", $ += M;
394
+ g.push(s), y += w;
395
+ let E = `
396
+ ${y}`;
397
+ const z = `,
398
+ ${y}`, q = Math.min(s.length, k);
399
+ let R = 0;
400
+ for (; R < q - 1; R++) {
401
+ const J = G(String(R), s[R], g, w, y);
402
+ E += J !== void 0 ? J : "null", E += z;
403
403
  }
404
- const q = G(String(z), s[z], d, b, h);
405
- if ($ += q !== void 0 ? q : "null", s.length - 1 > D) {
406
- const U = s.length - D - 1;
407
- $ += `${M}"... ${y(U)} not stringified"`;
404
+ const U = G(String(R), s[R], g, w, y);
405
+ if (E += U !== void 0 ? U : "null", s.length - 1 > k) {
406
+ const J = s.length - k - 1;
407
+ E += `${z}"... ${v(J)} not stringified"`;
408
408
  }
409
- return $ += `
410
- ${S}`, d.pop(), `[${$}]`;
409
+ return E += `
410
+ ${j}`, g.pop(), `[${E}]`;
411
411
  }
412
- let g = Object.keys(s);
413
- const O = g.length;
414
- if (O === 0)
412
+ let x = Object.keys(s);
413
+ const S = x.length;
414
+ if (S === 0)
415
415
  return "{}";
416
- if (C < d.length + 1)
416
+ if (M < g.length + 1)
417
417
  return '"[Object]"';
418
- h += b;
419
- const k = `,
420
- ${h}`;
421
- let _ = "", N = "", I = Math.min(O, D);
422
- c(s) && (_ += f(s, k, D), g = g.slice(s.length), I -= s.length, N = k), H && (g = r(g)), d.push(s);
423
- for (let $ = 0; $ < I; $++) {
424
- const M = g[$], L = G(M, s[M], d, b, h);
425
- L !== void 0 && (_ += `${N}${a(M)}: ${L}`, N = k);
418
+ y += w;
419
+ const $ = `,
420
+ ${y}`;
421
+ let D = "", N = "", I = Math.min(S, k);
422
+ m(s) && (D += d(s, $, k), x = x.slice(s.length), I -= s.length, N = $), F && (x = r(x)), g.push(s);
423
+ for (let E = 0; E < I; E++) {
424
+ const z = x[E], q = G(z, s[z], g, w, y);
425
+ q !== void 0 && (D += `${N}${a(z)}: ${q}`, N = $);
426
426
  }
427
- if (O > D) {
428
- const $ = O - D;
429
- _ += `${N}"...": "${y($)} not stringified"`, N = k;
427
+ if (S > k) {
428
+ const E = S - k;
429
+ D += `${N}"...": "${v(E)} not stringified"`, N = $;
430
430
  }
431
- return N !== "" && (_ = `
432
- ${h}${_}
433
- ${S}`), d.pop(), `{${_}}`;
431
+ return N !== "" && (D = `
432
+ ${y}${D}
433
+ ${j}`), g.pop(), `{${D}}`;
434
434
  }
435
435
  case "number":
436
- return isFinite(s) ? String(s) : m ? m(s) : "null";
436
+ return isFinite(s) ? String(s) : l ? l(s) : "null";
437
437
  case "boolean":
438
438
  return s === !0 ? "true" : "false";
439
439
  case "undefined":
440
440
  return;
441
441
  case "bigint":
442
- if (A)
442
+ if (_)
443
443
  return String(s);
444
444
  default:
445
- return m ? m(s) : void 0;
445
+ return l ? l(s) : void 0;
446
446
  }
447
447
  }
448
- function Z(P, s, d) {
448
+ function Z(A, s, g) {
449
449
  switch (typeof s) {
450
450
  case "string":
451
451
  return a(s);
@@ -453,85 +453,85 @@ ${S}`), d.pop(), `{${_}}`;
453
453
  if (s === null)
454
454
  return "null";
455
455
  if (typeof s.toJSON == "function") {
456
- if (s = s.toJSON(P), typeof s != "object")
457
- return Z(P, s, d);
456
+ if (s = s.toJSON(A), typeof s != "object")
457
+ return Z(A, s, g);
458
458
  if (s === null)
459
459
  return "null";
460
460
  }
461
- if (d.indexOf(s) !== -1)
462
- return j;
463
- let b = "";
461
+ if (g.indexOf(s) !== -1)
462
+ return u;
463
+ let w = "";
464
464
  if (Array.isArray(s)) {
465
465
  if (s.length === 0)
466
466
  return "[]";
467
- if (C < d.length + 1)
467
+ if (M < g.length + 1)
468
468
  return '"[Array]"';
469
- d.push(s);
470
- const k = Math.min(s.length, D);
471
- let _ = 0;
472
- for (; _ < k - 1; _++) {
473
- const I = Z(String(_), s[_], d);
474
- b += I !== void 0 ? I : "null", b += ",";
469
+ g.push(s);
470
+ const $ = Math.min(s.length, k);
471
+ let D = 0;
472
+ for (; D < $ - 1; D++) {
473
+ const I = Z(String(D), s[D], g);
474
+ w += I !== void 0 ? I : "null", w += ",";
475
475
  }
476
- const N = Z(String(_), s[_], d);
477
- if (b += N !== void 0 ? N : "null", s.length - 1 > D) {
478
- const I = s.length - D - 1;
479
- b += `,"... ${y(I)} not stringified"`;
476
+ const N = Z(String(D), s[D], g);
477
+ if (w += N !== void 0 ? N : "null", s.length - 1 > k) {
478
+ const I = s.length - k - 1;
479
+ w += `,"... ${v(I)} not stringified"`;
480
480
  }
481
- return d.pop(), `[${b}]`;
481
+ return g.pop(), `[${w}]`;
482
482
  }
483
- let h = Object.keys(s);
484
- const S = h.length;
485
- if (S === 0)
483
+ let y = Object.keys(s);
484
+ const j = y.length;
485
+ if (j === 0)
486
486
  return "{}";
487
- if (C < d.length + 1)
487
+ if (M < g.length + 1)
488
488
  return '"[Object]"';
489
- let g = "", O = Math.min(S, D);
490
- c(s) && (b += f(s, ",", D), h = h.slice(s.length), O -= s.length, g = ","), H && (h = r(h)), d.push(s);
491
- for (let k = 0; k < O; k++) {
492
- const _ = h[k], N = Z(_, s[_], d);
493
- N !== void 0 && (b += `${g}${a(_)}:${N}`, g = ",");
489
+ let x = "", S = Math.min(j, k);
490
+ m(s) && (w += d(s, ",", k), y = y.slice(s.length), S -= s.length, x = ","), F && (y = r(y)), g.push(s);
491
+ for (let $ = 0; $ < S; $++) {
492
+ const D = y[$], N = Z(D, s[D], g);
493
+ N !== void 0 && (w += `${x}${a(D)}:${N}`, x = ",");
494
494
  }
495
- if (S > D) {
496
- const k = S - D;
497
- b += `${g}"...":"${y(k)} not stringified"`;
495
+ if (j > k) {
496
+ const $ = j - k;
497
+ w += `${x}"...":"${v($)} not stringified"`;
498
498
  }
499
- return d.pop(), `{${b}}`;
499
+ return g.pop(), `{${w}}`;
500
500
  }
501
501
  case "number":
502
- return isFinite(s) ? String(s) : m ? m(s) : "null";
502
+ return isFinite(s) ? String(s) : l ? l(s) : "null";
503
503
  case "boolean":
504
504
  return s === !0 ? "true" : "false";
505
505
  case "undefined":
506
506
  return;
507
507
  case "bigint":
508
- if (A)
508
+ if (_)
509
509
  return String(s);
510
510
  default:
511
- return m ? m(s) : void 0;
511
+ return l ? l(s) : void 0;
512
512
  }
513
513
  }
514
- function re(P, s, d) {
514
+ function ae(A, s, g) {
515
515
  if (arguments.length > 1) {
516
- let b = "";
517
- if (typeof d == "number" ? b = " ".repeat(Math.min(d, 10)) : typeof d == "string" && (b = d.slice(0, 10)), s != null) {
516
+ let w = "";
517
+ if (typeof g == "number" ? w = " ".repeat(Math.min(g, 10)) : typeof g == "string" && (w = g.slice(0, 10)), s != null) {
518
518
  if (typeof s == "function")
519
- return nt("", { "": P }, [], s, b, "");
519
+ return nt("", { "": A }, [], s, w, "");
520
520
  if (Array.isArray(s))
521
- return it("", P, [], T(s), b, "");
521
+ return it("", A, [], T(s), w, "");
522
522
  }
523
- if (b.length !== 0)
524
- return G("", P, [], b, "");
523
+ if (w.length !== 0)
524
+ return G("", A, [], w, "");
525
525
  }
526
- return Z("", P, []);
526
+ return Z("", A, []);
527
527
  }
528
- return re;
528
+ return ae;
529
529
  }
530
530
  })(ft, ft.exports);
531
- var we = ft.exports;
532
- const K = /* @__PURE__ */ be(we);
531
+ var Oe = ft.exports;
532
+ const K = /* @__PURE__ */ we(Oe);
533
533
  K.configure;
534
- function Oe(t, e) {
534
+ function Se(t, e) {
535
535
  return { ...t, name: e };
536
536
  }
537
537
  function je(t, e, n) {
@@ -553,30 +553,30 @@ function je(t, e, n) {
553
553
  throw new Error(
554
554
  "Cannot undo: skip value from reducer cannot be used with UNDO action"
555
555
  );
556
- const p = r.document.operations[i].at(-1), c = p && p.type === "NOOP" && p.skip > 0;
557
- if (r.skip += o, c) {
556
+ const p = r.document.operations[i].at(-1), m = p && p.type === "NOOP" && p.skip > 0;
557
+ if (r.skip += o, m) {
558
558
  r.skip += p.skip;
559
- const w = r.document.operations[i][r.document.operations[i].length - 2];
560
- w && p.index - w.index === 1 && r.document.operations[i].pop();
559
+ const O = r.document.operations[i][r.document.operations[i].length - 2];
560
+ O && p.index - O.index === 1 && r.document.operations[i].pop();
561
561
  }
562
562
  if (r.document.operations[i].length < r.skip)
563
563
  throw new Error(
564
564
  "Cannot undo: you can't undo more operations than the ones in the scope history"
565
565
  );
566
- const f = r.document.operations[i].length - 1;
567
- let x = o, E = c ? f - p.skip : f;
568
- for (; x > 0 && E >= 0; ) {
569
- const w = r.document.operations[i][E];
570
- if (!w) {
571
- x--, E--;
566
+ const d = r.document.operations[i].length - 1;
567
+ let h = o, b = m ? d - p.skip : d;
568
+ for (; h > 0 && b >= 0; ) {
569
+ const O = r.document.operations[i][b];
570
+ if (!O) {
571
+ h--, b--;
572
572
  continue;
573
573
  }
574
- w.type === "NOOP" && w.skip > 0 ? (E = E - (w.skip + 1), r.skip += w.skip + 1) : (r.document.clipboard.push({ ...w }), x--, E--);
574
+ O.type === "NOOP" && O.skip > 0 ? (b = b - (O.skip + 1), r.skip += O.skip + 1) : (r.document.clipboard.push({ ...O }), h--, b--);
575
575
  }
576
- r.action = se(i);
576
+ r.action = re(i);
577
577
  });
578
578
  }
579
- function Se(t, e, n) {
579
+ function Ee(t, e, n) {
580
580
  const { scope: i, input: o } = e;
581
581
  return pt({
582
582
  document: t,
@@ -596,93 +596,93 @@ function Se(t, e, n) {
596
596
  if (r.document.clipboard.length < 1)
597
597
  throw new Error("Cannot redo: no operations in the clipboard");
598
598
  const p = r.document.clipboard.findLastIndex(
599
- (f) => f.scope === i
599
+ (d) => d.scope === i
600
600
  );
601
601
  if (p < 0)
602
602
  throw new Error(
603
603
  `Cannot redo: no operations in clipboard for scope "${i}"`
604
604
  );
605
- const c = r.document.clipboard.splice(p, 1)[0];
605
+ const m = r.document.clipboard.splice(p, 1)[0];
606
606
  r.action = at({
607
- type: c.type,
608
- scope: c.scope,
609
- input: c.input
607
+ type: m.type,
608
+ scope: m.scope,
609
+ input: m.input
610
610
  });
611
611
  });
612
612
  }
613
- function Ee(t, e, n) {
613
+ function $e(t, e, n) {
614
614
  const { scope: i } = e, o = t.operations[i];
615
615
  let {
616
616
  input: { start: a, end: r }
617
617
  } = e;
618
618
  a = a || 0, r = r || o.length;
619
- const p = o.slice(a, r), c = o.slice(0, a), f = o.slice(r), x = gt(
619
+ const p = o.slice(a, r), m = o.slice(0, a), d = o.slice(r), h = gt(
620
620
  t.initialState,
621
621
  {
622
622
  ...t.operations,
623
- [i]: c.concat(p)
623
+ [i]: m.concat(p)
624
624
  },
625
625
  n
626
- ), { name: E, state: w } = x, y = c.length, T = c.length ? c[c.length - 1].timestamp : f.length ? f[0].timestamp : (/* @__PURE__ */ new Date()).toISOString();
626
+ ), { name: b, state: O } = h, v = m.length, T = m.length ? m[m.length - 1].timestamp : d.length ? d[0].timestamp : (/* @__PURE__ */ new Date()).toISOString();
627
627
  return gt(
628
628
  t.initialState,
629
629
  {
630
630
  ...t.operations,
631
631
  [i]: [
632
- ...c,
632
+ ...m,
633
633
  {
634
634
  ...Et(
635
- { name: E, state: w },
635
+ { name: b, state: O },
636
636
  p.length
637
637
  ),
638
638
  timestamp: T,
639
- index: y,
640
- hash: St({ state: w }, "global")
639
+ index: v,
640
+ hash: jt({ state: O }, "global")
641
641
  },
642
- ...f.map((v, R) => ({
643
- ...v,
644
- index: y + R + 1
642
+ ...d.map((P, C) => ({
643
+ ...P,
644
+ index: v + C + 1
645
645
  }))
646
646
  ]
647
647
  },
648
648
  n
649
649
  );
650
650
  }
651
- function $e(t, e) {
651
+ function ke(t, e) {
652
652
  return {
653
653
  ...t,
654
654
  name: e.name,
655
655
  state: e.state ?? { global: {}, local: {} }
656
656
  };
657
657
  }
658
- const qt = "SET_NAME", tt = "UNDO", et = "REDO", ct = "PRUNE", Ut = "LOAD_STATE", ke = "NOOP", Jt = { "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"] };
658
+ const qt = "SET_NAME", tt = "UNDO", et = "REDO", ct = "PRUNE", Ut = "LOAD_STATE", De = "NOOP", Jt = { "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"] };
659
659
  Object.freeze(Jt);
660
- var F = function(t, e, n, i) {
660
+ var L = function(t, e, n, i) {
661
661
  if (n === "a" && !i)
662
662
  throw new TypeError("Private accessor was defined without a getter");
663
663
  if (typeof e == "function" ? t !== e || !i : !e.has(t))
664
664
  throw new TypeError("Cannot read private member from an object whose class did not declare it");
665
665
  return n === "m" ? i : n === "a" ? i.call(t) : i ? i.value : e.get(t);
666
- }, B, Q, X;
667
- class De {
666
+ }, B, Q, H;
667
+ class Te {
668
668
  constructor(...e) {
669
- B.set(this, /* @__PURE__ */ new Map()), Q.set(this, /* @__PURE__ */ new Map()), X.set(this, /* @__PURE__ */ new Map());
669
+ B.set(this, /* @__PURE__ */ new Map()), Q.set(this, /* @__PURE__ */ new Map()), H.set(this, /* @__PURE__ */ new Map());
670
670
  for (const n of e)
671
671
  this.define(n);
672
672
  }
673
673
  define(e, n = !1) {
674
674
  for (let [i, o] of Object.entries(e)) {
675
- i = i.toLowerCase(), o = o.map((p) => p.toLowerCase()), F(this, X, "f").has(i) || F(this, X, "f").set(i, /* @__PURE__ */ new Set());
676
- const a = F(this, X, "f").get(i);
675
+ i = i.toLowerCase(), o = o.map((p) => p.toLowerCase()), L(this, H, "f").has(i) || L(this, H, "f").set(i, /* @__PURE__ */ new Set());
676
+ const a = L(this, H, "f").get(i);
677
677
  let r = !0;
678
678
  for (let p of o) {
679
- const c = p.startsWith("*");
680
- if (p = c ? p.slice(1) : p, a == null || a.add(p), r && F(this, Q, "f").set(i, p), r = !1, c)
679
+ const m = p.startsWith("*");
680
+ if (p = m ? p.slice(1) : p, a == null || a.add(p), r && L(this, Q, "f").set(i, p), r = !1, m)
681
681
  continue;
682
- const f = F(this, B, "f").get(p);
683
- if (f && f != i && !n)
684
- throw new Error(`"${i} -> ${p}" conflicts with "${f} -> ${p}". Pass \`force=true\` to override this definition.`);
685
- F(this, B, "f").set(p, i);
682
+ const d = L(this, B, "f").get(p);
683
+ if (d && d != i && !n)
684
+ throw new Error(`"${i} -> ${p}" conflicts with "${d} -> ${p}". Pass \`force=true\` to override this definition.`);
685
+ L(this, B, "f").set(p, i);
686
686
  }
687
687
  }
688
688
  return this;
@@ -691,34 +691,34 @@ class De {
691
691
  if (typeof e != "string")
692
692
  return null;
693
693
  const n = e.replace(/^.*[/\\]/, "").toLowerCase(), i = n.replace(/^.*\./, "").toLowerCase(), o = n.length < e.length;
694
- return !(i.length < n.length - 1) && o ? null : F(this, B, "f").get(i) ?? null;
694
+ return !(i.length < n.length - 1) && o ? null : L(this, B, "f").get(i) ?? null;
695
695
  }
696
696
  getExtension(e) {
697
697
  var n;
698
- return typeof e != "string" ? null : (e = (n = e == null ? void 0 : e.split) == null ? void 0 : n.call(e, ";")[0], (e && F(this, Q, "f").get(e.trim().toLowerCase())) ?? null);
698
+ return typeof e != "string" ? null : (e = (n = e == null ? void 0 : e.split) == null ? void 0 : n.call(e, ";")[0], (e && L(this, Q, "f").get(e.trim().toLowerCase())) ?? null);
699
699
  }
700
700
  getAllExtensions(e) {
701
- return typeof e != "string" ? null : F(this, X, "f").get(e.toLowerCase()) ?? null;
701
+ return typeof e != "string" ? null : L(this, H, "f").get(e.toLowerCase()) ?? null;
702
702
  }
703
703
  _freeze() {
704
704
  this.define = () => {
705
705
  throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances");
706
706
  }, Object.freeze(this);
707
- for (const e of F(this, X, "f").values())
707
+ for (const e of L(this, H, "f").values())
708
708
  Object.freeze(e);
709
709
  return this;
710
710
  }
711
711
  _getTestState() {
712
712
  return {
713
- types: F(this, B, "f"),
714
- extensions: F(this, Q, "f")
713
+ types: L(this, B, "f"),
714
+ extensions: L(this, Q, "f")
715
715
  };
716
716
  }
717
717
  }
718
- B = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new WeakMap(), X = /* @__PURE__ */ new WeakMap();
719
- const _e = new De(Jt)._freeze();
720
- function Te(t, e, n) {
721
- const i = fe(t, e);
718
+ B = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new WeakMap(), H = /* @__PURE__ */ new WeakMap();
719
+ const _e = new Te(Jt)._freeze();
720
+ function Ne(t, e, n) {
721
+ const i = de(t, e);
722
722
  return ut.mkdirSync(t, { recursive: !0 }), new Promise((o, a) => {
723
723
  try {
724
724
  ut.writeFile(i, n, {}, (r) => {
@@ -732,9 +732,9 @@ function Te(t, e, n) {
732
732
  function Vt(t) {
733
733
  return ut.readFileSync(t);
734
734
  }
735
- function Ne(t) {
735
+ function ve(t) {
736
736
  return new Promise((e, n) => {
737
- ue.get(t, (i) => {
737
+ fe.get(t, (i) => {
738
738
  const o = [], a = i.headers["content-type"];
739
739
  i.on("data", (r) => {
740
740
  o.push(r);
@@ -746,8 +746,8 @@ function Ne(t) {
746
746
  });
747
747
  });
748
748
  }
749
- const ve = async (t) => Vt(t), lt = (t, e = "sha1") => me.createHash(e).update(t).digest("base64");
750
- function Ie(t) {
749
+ const Ie = async (t) => Vt(t), lt = (t, e = "sha1") => ue.createHash(e).update(t).digest("base64");
750
+ function Ae(t) {
751
751
  const e = [], n = Object.keys(t);
752
752
  for (const i of n) {
753
753
  const o = t[i].sort((a, r) => a.index - r.index);
@@ -774,72 +774,72 @@ const Xt = async (t) => {
774
774
  return e.file("header.json", JSON.stringify(p, null, 2)), e.file(
775
775
  "state.json",
776
776
  JSON.stringify(t.initialState || {}, null, 2)
777
- ), e.file("operations.json", JSON.stringify(t.operations, null, 2)), Object.keys(t.attachments).forEach((f) => {
778
- const { data: x, ...E } = t.attachments[f];
779
- e.file(f, x, {
777
+ ), e.file("operations.json", JSON.stringify(t.operations, null, 2)), Object.keys(t.attachments).forEach((d) => {
778
+ const { data: h, ...b } = t.attachments[d];
779
+ e.file(d, h, {
780
780
  base64: !0,
781
781
  createFolders: !0,
782
- comment: JSON.stringify(E)
782
+ comment: JSON.stringify(b)
783
783
  });
784
784
  }), e;
785
- }, Ae = async (t, e, n, i) => {
785
+ }, Pe = async (t, e, n, i) => {
786
786
  const a = await (await Xt(t)).generateAsync({
787
787
  type: "uint8array",
788
788
  streamFiles: !0
789
789
  }), r = i ?? t.name, p = `.${n}.zip`;
790
- return Te(
790
+ return Ne(
791
791
  e,
792
792
  r.endsWith(p) ? r : `${r}${p}`,
793
793
  a
794
794
  );
795
- }, ln = async (t, e) => {
795
+ }, mn = async (t, e) => {
796
796
  const i = await (await Xt(t)).generateAsync({ type: "blob" }), o = await e.createWritable();
797
797
  await o.write(i), await o.close();
798
798
  }, $t = async (t, e, n) => {
799
799
  const i = Vt(t);
800
- return Pe(i, e, n);
801
- }, Pe = async (t, e, n) => {
800
+ return Me(i, e, n);
801
+ }, Me = async (t, e, n) => {
802
802
  const i = new Dt();
803
- return await i.loadAsync(t), Me(i, e, n);
803
+ return await i.loadAsync(t), ze(i, e, n);
804
804
  };
805
- async function Me(t, e, n) {
805
+ async function ze(t, e, n) {
806
806
  const i = t.file("state.json");
807
807
  if (!i)
808
808
  throw new Error("Initial state not found");
809
809
  const o = await i.async("string"), a = JSON.parse(o), r = t.file("header.json");
810
810
  let p;
811
811
  r && (p = JSON.parse(await r.async("string")));
812
- const c = t.file("operations.json");
813
- if (!c)
812
+ const m = t.file("operations.json");
813
+ if (!m)
814
814
  throw new Error("Operations history not found");
815
- const f = JSON.parse(
816
- await c.async("string")
817
- ), x = Ie(f);
818
- if (x.length) {
819
- const w = x.map((y) => y.message);
820
- throw new Error(w.join(`
815
+ const d = JSON.parse(
816
+ await m.async("string")
817
+ ), h = Ae(d);
818
+ if (h.length) {
819
+ const O = h.map((v) => v.message);
820
+ throw new Error(O.join(`
821
821
  `));
822
822
  }
823
- let E = te(
823
+ let b = te(
824
824
  a,
825
- f,
825
+ d,
826
826
  e,
827
827
  void 0,
828
828
  p,
829
829
  {},
830
830
  n
831
831
  );
832
- return p && (E = {
833
- ...E,
832
+ return p && (b = {
833
+ ...b,
834
834
  ...p
835
- }), E;
835
+ }), b;
836
836
  }
837
837
  function Ht(t) {
838
838
  const e = t.replace(/^.*\./, "") || void 0, n = t.replace(/^.*[/\\]/, "") || void 0;
839
839
  return { extension: e, fileName: n };
840
840
  }
841
- async function mn(t) {
842
- const { buffer: e, mimeType: n = "application/octet-stream" } = await Ne(t), i = Ht(t), o = e.toString("base64");
841
+ async function un(t) {
842
+ const { buffer: e, mimeType: n = "application/octet-stream" } = await ve(t), i = Ht(t), o = e.toString("base64");
843
843
  return {
844
844
  data: o,
845
845
  hash: lt(o),
@@ -847,8 +847,8 @@ async function mn(t) {
847
847
  ...i
848
848
  };
849
849
  }
850
- async function un(t) {
851
- const e = await ve(t), n = _e.getType(t) || "application/octet-stream", i = Ht(t), o = e.toString("base64");
850
+ async function fn(t) {
851
+ const e = await Ie(t), n = _e.getType(t) || "application/octet-stream", i = Ht(t), o = e.toString("base64");
852
852
  return { data: o, hash: lt(o), mimeType: n, ...i };
853
853
  }
854
854
  var Bt = /* @__PURE__ */ ((t) => (t.UNEXPECTED_INDEX = "UNEXPECTED_INDEX", t))(Bt || {}), Kt = /* @__PURE__ */ ((t) => (t.DUPLICATED_INDEX = "DUPLICATED_INDEX", t.MISSING_INDEX = "MISSING_INDEX", t))(Kt || {});
@@ -869,7 +869,7 @@ function Ot(t) {
869
869
  }
870
870
  return e;
871
871
  }
872
- function J(t) {
872
+ function V(t) {
873
873
  var i, o, a;
874
874
  const e = [];
875
875
  let n = t.length - 1;
@@ -883,7 +883,7 @@ function J(t) {
883
883
  }
884
884
  return e;
885
885
  }
886
- function ze(t) {
886
+ function Re(t) {
887
887
  const e = [...t], n = e[e.length - 1];
888
888
  return n && (n.type === "NOOP" ? e.push({
889
889
  ...n,
@@ -900,7 +900,7 @@ function ze(t) {
900
900
  hash: n.hash
901
901
  })), e;
902
902
  }
903
- function V(t) {
903
+ function X(t) {
904
904
  return t.slice().sort((e, n) => e.skip - n.skip).sort((e, n) => e.index - n.index);
905
905
  }
906
906
  const Ce = (t, e, n) => [...e, ...n].sort(
@@ -916,11 +916,11 @@ const Ce = (t, e, n) => [...e, ...n].sort(
916
916
  index: t.index + o,
917
917
  skip: o === 0 ? t.skip : 0
918
918
  }));
919
- function jt(t, e) {
919
+ function St(t, e) {
920
920
  return K(t) === K(e);
921
921
  }
922
922
  function Le(t, e) {
923
- const n = J(V(t.slice())), i = J(V(e.slice()));
923
+ const n = V(X(t.slice())), i = V(X(e.slice()));
924
924
  if (n.length < 1)
925
925
  return [i, []];
926
926
  const o = [];
@@ -930,10 +930,10 @@ function Le(t, e) {
930
930
  let p = n.shift();
931
931
  for (; p && Wt(p, r); )
932
932
  o.push(p), p = n.shift();
933
- if (p ? a || (jt(p, r) ? (i.shift(), o.push(p)) : (n.unshift(p), a = !0)) : a = !0, a) {
934
- let c = i.shift();
935
- for (; c; )
936
- o.push(c), c = i.shift();
933
+ if (p ? a || (St(p, r) ? (i.shift(), o.push(p)) : (n.unshift(p), a = !0)) : a = !0, a) {
934
+ let m = i.shift();
935
+ for (; m; )
936
+ o.push(m), m = i.shift();
937
937
  }
938
938
  }
939
939
  if (!a) {
@@ -941,7 +941,7 @@ function Le(t, e) {
941
941
  for (; r; )
942
942
  o.push(r), r = n.shift();
943
943
  }
944
- return [J(o), n];
944
+ return [V(o), n];
945
945
  }
946
946
  function Wt(t, e) {
947
947
  return t.index < e.index || t.index === e.index && t.skip < e.skip;
@@ -953,20 +953,20 @@ function Gt(t, e) {
953
953
  );
954
954
  let r = !1;
955
955
  for (let p = 0; p < a; p++) {
956
- const c = t[p], f = e[p];
957
- c && f ? !r && jt(c, f) ? n.push(c) : (r = !0, i.push(c), o.push(f)) : c ? i.push(c) : f && o.push(f);
956
+ const m = t[p], d = e[p];
957
+ m && d ? !r && St(m, d) ? n.push(m) : (r = !0, i.push(m), o.push(d)) : m ? i.push(m) : d && o.push(d);
958
958
  }
959
959
  return [n, i, o];
960
960
  }
961
- function Re(t, e, n) {
961
+ function qe(t, e, n) {
962
962
  const [i, o, a] = Gt(
963
- J(t),
964
- J(e)
963
+ V(t),
964
+ V(e)
965
965
  ), r = mt(i), p = 1 + Math.max(
966
966
  r,
967
967
  mt(o),
968
968
  mt(a)
969
- ), c = n(
969
+ ), m = n(
970
970
  {
971
971
  index: p,
972
972
  skip: p - (r + 1)
@@ -974,7 +974,7 @@ function Re(t, e, n) {
974
974
  o,
975
975
  a
976
976
  );
977
- return i.concat(c);
977
+ return i.concat(m);
978
978
  }
979
979
  function mt(t) {
980
980
  const e = t[t.length - 1];
@@ -984,47 +984,47 @@ function Zt(t) {
984
984
  var i, o, a;
985
985
  if (t.length < 1)
986
986
  return -1;
987
- const e = J(t);
987
+ const e = V(t);
988
988
  let n = (((i = e[e.length - 1]) == null ? void 0 : i.skip) || 0) + 1;
989
989
  return e.length > 1 && (n += ((o = e[e.length - 2]) == null ? void 0 : o.skip) || 0), (((a = e[e.length - 1]) == null ? void 0 : a.index) || -1) < n ? -1 : n;
990
990
  }
991
- const qe = (t) => Ot(
992
- J(V(t))
993
- ), Ue = (t) => t.reduce((n, i) => {
991
+ const Ue = (t) => Ot(
992
+ V(X(t))
993
+ ), Je = (t) => t.reduce((n, i) => {
994
994
  var o;
995
995
  return n[i.scope] || (n[i.scope] = []), (o = n[i.scope]) == null || o.push(i), n;
996
- }, {}), Je = (t, e) => {
997
- var c;
996
+ }, {}), Ve = (t, e) => {
997
+ var m;
998
998
  const n = {
999
999
  integrityIssues: [],
1000
1000
  validOperations: [],
1001
1001
  invalidOperations: [],
1002
1002
  duplicatedOperations: []
1003
- }, i = V(t), o = V(e), a = Ot([
1003
+ }, i = X(t), o = X(e), a = Ot([
1004
1004
  ...i,
1005
1005
  ...o
1006
- ]), p = (c = [...a.filter(
1007
- (f) => f.category === "MISSING_INDEX"
1006
+ ]), p = (m = [...a.filter(
1007
+ (d) => d.category === "MISSING_INDEX"
1008
1008
  /* MISSING_INDEX */
1009
- )].sort((f, x) => x.operation.index - f.operation.index).pop()) == null ? void 0 : c.operation;
1010
- for (const f of o) {
1011
- if (p && f.index >= p.index) {
1012
- n.invalidOperations.push(f);
1009
+ )].sort((d, h) => h.operation.index - d.operation.index).pop()) == null ? void 0 : m.operation;
1010
+ for (const d of o) {
1011
+ if (p && d.index >= p.index) {
1012
+ n.invalidOperations.push(d);
1013
1013
  continue;
1014
1014
  }
1015
- if (a.some((E) => E.operation.index === f.index && E.operation.skip === f.skip && E.category === "DUPLICATED_INDEX")) {
1016
- n.duplicatedOperations.push(f);
1015
+ if (a.some((b) => b.operation.index === d.index && b.operation.skip === d.skip && b.category === "DUPLICATED_INDEX")) {
1016
+ n.duplicatedOperations.push(d);
1017
1017
  continue;
1018
1018
  }
1019
- n.validOperations.push(f);
1019
+ n.validOperations.push(d);
1020
1020
  }
1021
1021
  return n.integrityIssues.push(...a), n;
1022
1022
  };
1023
- function Ve(t, e) {
1023
+ function Xe(t, e) {
1024
1024
  return t.filter((n) => !e.some((i) => n.type === "NOOP" && n.skip === 0 && n.index === i.index || n.index === i.index && n.skip === i.skip && n.scope === i.scope && n.hash === i.hash && n.type === i.type));
1025
1025
  }
1026
1026
  function Qt(t, e) {
1027
- const [n] = V(t).slice(-1), i = (n == null ? void 0 : n.index) ?? -1, o = i + 1, a = {
1027
+ const [n] = X(t).slice(-1), i = (n == null ? void 0 : n.index) ?? -1, o = i + 1, a = {
1028
1028
  ...e,
1029
1029
  index: e.index ?? o
1030
1030
  };
@@ -1032,8 +1032,8 @@ function Qt(t, e) {
1032
1032
  throw new Error(
1033
1033
  `The skip header operation index must be greater than or equal to ${i}`
1034
1034
  );
1035
- return (J(
1036
- V([...t, a])
1035
+ return (V(
1036
+ X([...t, a])
1037
1037
  ) || []).slice(0, -1);
1038
1038
  }
1039
1039
  function dt(t) {
@@ -1043,57 +1043,54 @@ function dt(t) {
1043
1043
  const [o, a] = i;
1044
1044
  return {
1045
1045
  ...n,
1046
- [o]: J(V(a))
1046
+ [o]: V(X(a))
1047
1047
  };
1048
1048
  },
1049
1049
  {}
1050
1050
  )
1051
1051
  };
1052
1052
  }
1053
- const fn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1053
+ const dn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1054
1054
  __proto__: null,
1055
1055
  IntegrityIssueSubType: Kt,
1056
1056
  IntegrityIssueType: Bt,
1057
- addUndo: ze,
1057
+ addUndo: Re,
1058
1058
  attachBranch: Le,
1059
1059
  checkCleanedOperationsIntegrity: Ot,
1060
- checkOperationsIntegrity: qe,
1061
- garbageCollect: J,
1062
- grabageCollectDocumentOperations: dt,
1063
- groupOperationsByScope: Ue,
1064
- merge: Re,
1060
+ checkOperationsIntegrity: Ue,
1061
+ garbageCollect: V,
1062
+ garbageCollectDocumentOperations: dt,
1063
+ groupOperationsByScope: Je,
1064
+ merge: qe,
1065
1065
  nextSkipNumber: Zt,
1066
- operationsAreEqual: jt,
1066
+ operationsAreEqual: St,
1067
1067
  precedes: Wt,
1068
- prepareOperations: Je,
1069
- removeExistingOperations: Ve,
1068
+ prepareOperations: Ve,
1069
+ removeExistingOperations: Xe,
1070
1070
  reshuffleByTimestamp: Ce,
1071
1071
  reshuffleByTimestampAndIndex: Fe,
1072
1072
  skipHeaderOperations: Qt,
1073
- sortOperations: V,
1073
+ sortOperations: X,
1074
1074
  split: Gt
1075
1075
  }, Symbol.toStringTag, { value: "Module" }));
1076
- function Xe(t, e) {
1076
+ function He(t, e) {
1077
1077
  let n;
1078
1078
  return "index" in e ? n = { ...e } : n = t.operations[e.scope].at(-1), ((n == null ? void 0 : n.index) ?? -1) + 1;
1079
1079
  }
1080
- function He(t, e) {
1080
+ function Be(t, e) {
1081
1081
  return {
1082
1082
  ...t,
1083
1083
  revision: {
1084
1084
  ...t.revision,
1085
- [e.scope]: Xe(t, e)
1085
+ [e.scope]: He(t, e)
1086
1086
  },
1087
1087
  lastModified: (/* @__PURE__ */ new Date()).toISOString()
1088
1088
  };
1089
1089
  }
1090
- function Be(t, e, n = 0) {
1090
+ function Ke(t, e, n = 0) {
1091
1091
  if ([tt, et, ct].includes(e.type))
1092
1092
  return t;
1093
- const { scope: i } = e, o = t.operations[i].slice(
1094
- 0,
1095
- t.revision[i]
1096
- ), a = [...o].pop();
1093
+ const { scope: i } = e, o = t.operations[i].slice(), a = o.at(-1);
1097
1094
  let r = ((a == null ? void 0 : a.index) ?? -1) + 1;
1098
1095
  if ("index" in e) {
1099
1096
  if (e.index - n > r)
@@ -1115,109 +1112,137 @@ function Be(t, e, n = 0) {
1115
1112
  operations: { ...t.operations, [i]: o }
1116
1113
  };
1117
1114
  }
1118
- function Ke(t, e, n = 0) {
1119
- let i = Be(t, e, n);
1120
- return i = He(i, e), i;
1115
+ function We(t, e, n = 0) {
1116
+ let i = Ke(t, e, n);
1117
+ return i = Be(i, e), i;
1121
1118
  }
1122
- function We(t, e, n) {
1119
+ function Ge(t, e, n) {
1123
1120
  switch (Pt().parse(e), e.type) {
1124
1121
  case qt:
1125
- return Oe(t, e.input);
1122
+ return Se(t, e.input);
1126
1123
  case ct:
1127
- return Ee(t, e, n);
1124
+ return $e(t, e, n);
1128
1125
  case Ut:
1129
- return $e(t, e.input.state);
1126
+ return ke(t, e.input.state);
1130
1127
  default:
1131
1128
  return t;
1132
1129
  }
1133
1130
  }
1134
- function dn(t, e, n) {
1131
+ function gn(t, e, n) {
1135
1132
  switch (e.type) {
1136
1133
  case tt:
1137
1134
  return je(t, e, n);
1138
1135
  case et:
1139
- return Se(t, e, n);
1136
+ return Ee(t, e, n);
1140
1137
  default:
1141
1138
  return { document: t, action: e, skip: n };
1142
1139
  }
1143
1140
  }
1144
- function Ge(t, e, n, i) {
1145
- const o = e.scope, a = t.operations[o].at(-1);
1146
- if (!a)
1141
+ function Ze(t, e, n, i, o = !1, a = ee) {
1142
+ const r = e.scope, p = t.operations[r].at(-1);
1143
+ if (!p)
1147
1144
  return t;
1148
- const r = dt(
1145
+ const m = dt(
1149
1146
  {
1150
1147
  ...t.operations,
1151
- [o]: Qt(
1152
- t.operations[o],
1153
- a
1148
+ [r]: Qt(
1149
+ t.operations[r],
1150
+ p
1154
1151
  )
1155
1152
  }
1156
- ), { state: p } = gt(
1157
- t.initialState,
1158
- r,
1159
- n,
1160
- void 0,
1161
- void 0,
1162
- void 0
1163
1153
  );
1154
+ let d;
1155
+ const h = m[r].at(-1);
1156
+ if (o && (h != null && h.resultingState))
1157
+ d = a(
1158
+ h.resultingState
1159
+ );
1160
+ else {
1161
+ const { state: b } = gt(
1162
+ t.initialState,
1163
+ m,
1164
+ n,
1165
+ void 0,
1166
+ void 0,
1167
+ void 0,
1168
+ void 0,
1169
+ {
1170
+ reuseHash: !0,
1171
+ reuseOperationResultingState: o,
1172
+ operationResultingStateParser: a
1173
+ }
1174
+ );
1175
+ d = b[r];
1176
+ }
1164
1177
  return {
1165
1178
  ...t,
1166
- state: p,
1179
+ state: {
1180
+ ...t.state,
1181
+ [r]: d
1182
+ },
1167
1183
  operations: dt({
1168
1184
  ...t.operations
1169
1185
  })
1170
1186
  };
1171
1187
  }
1172
1188
  function Yt(t, e, n, i, o = {}) {
1173
- const { skip: a, ignoreSkipOperations: r = !1, reuseHash: p = !1 } = o, c = { ...e }, f = a || 0;
1174
- let x = { ...t };
1175
- const E = !r && (f > 0 || "index" in c && c.skip > 0);
1176
- return kt(c) && (x = We(x, c, n)), x = Ke(x, c, f), E && (x = Ge(
1177
- x,
1178
- c,
1179
- n
1180
- )), x = pt(x, (w) => {
1189
+ const {
1190
+ skip: a,
1191
+ ignoreSkipOperations: r = !1,
1192
+ reuseHash: p = !1,
1193
+ reuseOperationResultingState: m = !1,
1194
+ operationResultingStateParser: d
1195
+ } = o, h = { ...e }, b = a || 0;
1196
+ let O = { ...t };
1197
+ const v = !r && (b > 0 || "index" in h && h.skip > 0);
1198
+ return kt(h) && (O = Ge(O, h, n)), O = We(O, h, b), v && (O = Ze(
1199
+ O,
1200
+ h,
1201
+ n,
1202
+ b,
1203
+ m,
1204
+ d
1205
+ )), O = pt(O, (T) => {
1181
1206
  try {
1182
- const y = n(
1183
- w.state,
1184
- c,
1207
+ const P = n(
1208
+ T.state,
1209
+ h,
1185
1210
  i
1186
1211
  );
1187
- if (y)
1212
+ if (P)
1188
1213
  return at({
1189
- ...x,
1214
+ ...O,
1190
1215
  // clipboard: [...clipboardValue],
1191
- state: y
1216
+ state: P
1192
1217
  });
1193
- } catch (y) {
1194
- const T = x.operations[c.scope].length - 1;
1195
- w.operations[c.scope][T].error = y.message, w.operations[c.scope][T].skip = 0, E && (w.state = at({ ...t.state }), w.operations = at({
1218
+ } catch (P) {
1219
+ const C = O.operations[h.scope].length - 1;
1220
+ T.operations[h.scope][C].error = P.message, T.operations[h.scope][C].skip = 0, v && (T.state = at({ ...t.state }), T.operations = at({
1196
1221
  ...t.operations,
1197
- [c.scope]: [
1198
- ...t.operations[c.scope],
1222
+ [h.scope]: [
1223
+ ...t.operations[h.scope],
1199
1224
  {
1200
- ...w.operations[c.scope][T]
1225
+ ...T.operations[h.scope][C]
1201
1226
  }
1202
1227
  ]
1203
1228
  }));
1204
1229
  }
1205
- }), pt(x, (w) => {
1206
- if ([tt, et, ct].includes(c.type))
1207
- return w;
1208
- const y = c.scope || "global", T = p && Object.prototype.hasOwnProperty.call(c, "hash") ? c.hash : St(w, y);
1209
- w.operations[y][w.operations[y].length - 1].hash = T, !kt(c) && c.attachments && c.attachments.forEach((v) => {
1210
- const { hash: R, ...l } = v;
1211
- w.attachments[R] = {
1212
- ...l
1230
+ }), pt(O, (T) => {
1231
+ if ([tt, et, ct].includes(h.type))
1232
+ return T;
1233
+ const P = h.scope || "global", C = p && Object.prototype.hasOwnProperty.call(h, "hash") ? h.hash : jt(T, P);
1234
+ T.operations[P][T.operations[P].length - 1].hash = C, !kt(h) && h.attachments && h.attachments.forEach((c) => {
1235
+ const { hash: l, ...u } = c;
1236
+ T.attachments[l] = {
1237
+ ...u
1213
1238
  };
1214
1239
  });
1215
1240
  });
1216
1241
  }
1217
- function gn(t) {
1218
- return t.type === ke && t.skip !== void 0 && t.skip > 0 && t.hash !== void 0;
1219
- }
1220
1242
  function hn(t) {
1243
+ return t.type === De && t.skip !== void 0 && t.skip > 0 && t.hash !== void 0;
1244
+ }
1245
+ function xn(t) {
1221
1246
  return [tt, et].includes(t.type);
1222
1247
  }
1223
1248
  function kt(t) {
@@ -1237,10 +1262,10 @@ function W(t, e, n, i, o = "global") {
1237
1262
  }
1238
1263
  return a;
1239
1264
  }
1240
- function Ze(t, e = Yt) {
1265
+ function Qe(t, e = Yt) {
1241
1266
  return (n, i, o, a) => e(n, i, t, o, a);
1242
1267
  }
1243
- const Qe = (t, e) => ({
1268
+ const Ye = (t, e) => ({
1244
1269
  name: "",
1245
1270
  documentType: "",
1246
1271
  revision: {
@@ -1252,8 +1277,8 @@ const Qe = (t, e) => ({
1252
1277
  attachments: {},
1253
1278
  ...t,
1254
1279
  state: (e == null ? void 0 : e(t == null ? void 0 : t.state)) ?? (t == null ? void 0 : t.state) ?? { global: {}, local: {} }
1255
- }), Ye = (t, e) => {
1256
- const n = Qe(
1280
+ }), tn = (t, e) => {
1281
+ const n = Ye(
1257
1282
  t,
1258
1283
  e
1259
1284
  );
@@ -1263,64 +1288,64 @@ const Qe = (t, e) => ({
1263
1288
  operations: { global: [], local: [] },
1264
1289
  clipboard: []
1265
1290
  };
1266
- }, St = (t, e = "global") => lt(K(t.state[e] || "")), xn = (t, e = 1e3) => {
1291
+ }, jt = (t, e = "global") => lt(K(t.state[e] || "")), yn = (t, e = 1e3) => {
1267
1292
  const n = Math.random() * e;
1268
1293
  return lt(`${(t ?? /* @__PURE__ */ new Date()).toISOString()}${n}`);
1269
1294
  };
1270
1295
  function rt(t) {
1271
- return ce(le(t, !0));
1296
+ return le(me(t, !0));
1272
1297
  }
1273
- function yn(t, e) {
1298
+ function bn(t, e) {
1274
1299
  const n = [...t];
1275
1300
  let i = e || 0, o = n.length > 0 ? n[n.length - 1].index : 0;
1276
1301
  const a = [];
1277
1302
  for (const r of n.reverse()) {
1278
1303
  if (i > 0) {
1279
- const f = o - r.index;
1280
- i -= f;
1304
+ const d = o - r.index;
1305
+ i -= d;
1281
1306
  }
1282
1307
  if (i < 0)
1283
1308
  throw new Error("Invalid operation index, missing operations");
1284
1309
  const p = {
1285
1310
  ignore: i > 0,
1286
1311
  operation: r
1287
- }, c = r.skip > 0 ? r.skip + 1 : 0;
1288
- if (c > 0 && c > i) {
1289
- const f = c - i;
1290
- i = i + f;
1312
+ }, m = r.skip > 0 ? r.skip + 1 : 0;
1313
+ if (m > 0 && m > i) {
1314
+ const d = m - i;
1315
+ i = i + d;
1291
1316
  }
1292
1317
  o = r.index, a.push(p);
1293
1318
  }
1294
1319
  return a.reverse();
1295
1320
  }
1296
- function bn(t, e, n) {
1297
- const i = t.slice().sort((p, c) => p.skip - c.skip).sort((p, c) => p.index - c.index);
1321
+ function wn(t, e, n) {
1322
+ const i = t.slice().sort((p, m) => p.skip - m.skip).sort((p, m) => p.index - m.index);
1298
1323
  let o = n, a = 0, r = e;
1299
1324
  for (const p of i.reverse()) {
1300
- const c = r - p.index;
1301
- if (o = o - c, o > -1)
1325
+ const m = r - p.index;
1326
+ if (o = o - m, o > -1)
1302
1327
  a++, r = p.index;
1303
1328
  else
1304
1329
  break;
1305
1330
  }
1306
1331
  return a;
1307
1332
  }
1308
- function wn(t) {
1333
+ function On(t) {
1309
1334
  return Object.values(t).flatMap((e) => e).sort(
1310
1335
  (e, n) => new Date(e.timestamp).getTime() - new Date(n.timestamp).getTime()
1311
1336
  );
1312
1337
  }
1313
- function On(t) {
1338
+ function Sn(t) {
1314
1339
  return Object.values(t).flatMap((e) => e).sort(
1315
1340
  (e, n) => new Date(e.operation.timestamp).getTime() - new Date(n.operation.timestamp).getTime()
1316
1341
  );
1317
1342
  }
1318
1343
  function gt(t, e, n, i, o, a = Yt, r = {}, p) {
1319
- const c = Ze(n, a);
1344
+ const m = Qe(n, a);
1320
1345
  return te(
1321
1346
  t,
1322
1347
  e,
1323
- c,
1348
+ m,
1324
1349
  i,
1325
1350
  o,
1326
1351
  r,
@@ -1328,68 +1353,119 @@ function gt(t, e, n, i, o, a = Yt, r = {}, p) {
1328
1353
  );
1329
1354
  }
1330
1355
  function te(t, e, n, i, o, a = {}, r) {
1331
- const p = (r == null ? void 0 : r.checkHashes) ?? !0, c = Ye(t), f = Object.values(e).flat(), x = f.reduce((y, T) => n(y, T, i, {
1332
- skip: T.skip,
1356
+ const {
1357
+ checkHashes: p = !0,
1358
+ reuseOperationResultingState: m,
1359
+ operationResultingStateParser: d = ee
1360
+ } = r || {};
1361
+ let h = t;
1362
+ const b = [], O = {
1363
+ global: [],
1364
+ local: []
1365
+ };
1366
+ if (m)
1367
+ for (const [c, l] of Object.entries(e)) {
1368
+ const u = l.findLastIndex(
1369
+ (F) => !!F.resultingState
1370
+ );
1371
+ if (u < 0) {
1372
+ b.push(...l);
1373
+ continue;
1374
+ }
1375
+ const _ = l[u];
1376
+ try {
1377
+ const F = d(
1378
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unnecessary-type-assertion
1379
+ _.resultingState
1380
+ );
1381
+ h = {
1382
+ ...h,
1383
+ state: {
1384
+ ...h.state,
1385
+ // TODO how to deal with attachments?
1386
+ [c]: F
1387
+ }
1388
+ }, O[c].push(
1389
+ ...l.slice(0, u + 1)
1390
+ ), b.push(...l.slice(u + 1));
1391
+ } catch {
1392
+ b.push(...l);
1393
+ }
1394
+ }
1395
+ else
1396
+ b.push(...Object.values(e).flat());
1397
+ const v = tn(h);
1398
+ v.initialState = t, v.operations = O;
1399
+ const T = b.reduce((c, l) => n(c, l, i, {
1400
+ skip: l.skip,
1333
1401
  ignoreSkipOperations: !0,
1334
1402
  reuseHash: !p
1335
- }), c);
1403
+ }), v);
1336
1404
  if (!p)
1337
- for (const y of Object.keys(x.state))
1338
- for (let T = f.length - 1; T >= 0; T--) {
1339
- const v = f[T];
1340
- if (v.scope === y) {
1341
- if (v.hash !== St(x, y))
1342
- throw new Error(`Hash mismatch for scope ${y}`);
1405
+ for (const c of Object.keys(T.state))
1406
+ for (let l = b.length - 1; l >= 0; l--) {
1407
+ const u = b[l];
1408
+ if (u.scope === c) {
1409
+ if (u.hash !== jt(T, c))
1410
+ throw new Error(`Hash mismatch for scope ${c}`);
1343
1411
  break;
1344
1412
  }
1345
1413
  }
1346
- const E = Object.keys(
1347
- x.operations
1414
+ const P = Object.keys(
1415
+ T.operations
1348
1416
  ).reduce(
1349
- (y, T) => {
1350
- const v = T;
1417
+ (c, l) => {
1418
+ const u = l;
1351
1419
  return {
1352
- ...y,
1353
- [v]: [
1354
- ...x.operations[v].map((R, l) => {
1355
- var m;
1420
+ ...c,
1421
+ [u]: [
1422
+ ...T.operations[u].map((_, F) => {
1423
+ var M;
1356
1424
  return {
1357
- ...R,
1358
- timestamp: ((m = e[v][l]) == null ? void 0 : m.timestamp) ?? R.timestamp
1425
+ ..._,
1426
+ timestamp: ((M = e[u][F]) == null ? void 0 : M.timestamp) ?? _.timestamp
1359
1427
  };
1360
1428
  })
1361
1429
  ]
1362
1430
  };
1363
1431
  },
1364
1432
  { global: [], local: [] }
1365
- ), w = Object.values(E).reduce((y, T) => {
1366
- const v = T[T.length - 1];
1367
- return (v == null ? void 0 : v.timestamp) > y && (y = v.timestamp), y;
1433
+ ), C = Object.values(P).reduce((c, l) => {
1434
+ const u = l[l.length - 1];
1435
+ return (u == null ? void 0 : u.timestamp) > c && (c = u.timestamp), c;
1368
1436
  }, t.lastModified);
1369
- return { ...x, operations: E, lastModified: w };
1437
+ return { ...T, operations: P, lastModified: C };
1370
1438
  }
1371
1439
  function jn(t, e) {
1372
1440
  return K(t) === K(e);
1373
1441
  }
1374
- const ee = (t) => W(
1442
+ function ee(t) {
1443
+ const e = typeof t;
1444
+ if (e === "string")
1445
+ return JSON.parse(t);
1446
+ if (e === "object")
1447
+ return t;
1448
+ throw new Error(`Providing resulting state is of type: ${e}`);
1449
+ }
1450
+ const ne = (t) => W(
1375
1451
  "SET_NAME",
1376
1452
  t,
1377
1453
  void 0,
1378
1454
  bt,
1379
1455
  void 0
1380
- ), ne = (t = 1, e = "global") => W(
1456
+ ), ie = (t = 1, e = "global") => W(
1381
1457
  "UNDO",
1382
1458
  t,
1383
1459
  void 0,
1384
1460
  wt,
1385
1461
  e
1386
- ), ie = (t = 1, e = "global") => W(
1462
+ ), oe = (t = 1, e = "global") => W(
1387
1463
  "REDO",
1388
1464
  t,
1389
1465
  void 0,
1390
1466
  yt,
1391
1467
  e
1392
- ), oe = (t, e, n = "global") => W(
1468
+ ), se = (t, e, n = "global") => W(
1393
1469
  "PRUNE",
1394
1470
  { start: t, end: e },
1395
1471
  void 0,
@@ -1400,16 +1476,16 @@ const ee = (t) => W(
1400
1476
  { state: t, operations: e },
1401
1477
  void 0,
1402
1478
  ht
1403
- ), se = (t = "global") => W("NOOP", {}, void 0, void 0, t), Sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1479
+ ), re = (t = "global") => W("NOOP", {}, void 0, void 0, t), En = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1404
1480
  __proto__: null,
1405
1481
  loadState: Et,
1406
- noop: se,
1407
- prune: oe,
1408
- redo: ie,
1409
- setName: ee,
1410
- undo: ne
1482
+ noop: re,
1483
+ prune: se,
1484
+ redo: oe,
1485
+ setName: ne,
1486
+ undo: ie
1411
1487
  }, Symbol.toStringTag, { value: "Module" }));
1412
- class En {
1488
+ class $n {
1413
1489
  /**
1414
1490
  * Constructs a BaseDocument instance with an initial state.
1415
1491
  * @param reducer - The reducer function that updates the state.
@@ -1441,7 +1517,7 @@ class En {
1441
1517
  * @returns The file path where the state was saved.
1442
1518
  */
1443
1519
  saveToFile(e, n, i) {
1444
- return Ae(this._document, e, n, i);
1520
+ return Pe(this._document, e, n, i);
1445
1521
  }
1446
1522
  /**
1447
1523
  * Loads the state of the document from a file.
@@ -1528,21 +1604,21 @@ class En {
1528
1604
  * @param name - The new name of the document.
1529
1605
  */
1530
1606
  setName(e) {
1531
- return this.dispatch(ee(e)), this;
1607
+ return this.dispatch(ne(e)), this;
1532
1608
  }
1533
1609
  /**
1534
1610
  * Reverts a number of actions from the document.
1535
1611
  * @param count - The number of actions to revert.
1536
1612
  */
1537
1613
  undo(e) {
1538
- return this.dispatch(ne(e)), this;
1614
+ return this.dispatch(ie(e)), this;
1539
1615
  }
1540
1616
  /**
1541
1617
  * Reapplies a number of actions to the document.
1542
1618
  * @param count - The number of actions to reapply.
1543
1619
  */
1544
1620
  redo(e) {
1545
- return this.dispatch(ie(e)), this;
1621
+ return this.dispatch(oe(e)), this;
1546
1622
  }
1547
1623
  /**
1548
1624
  * Removes a range of operations from the document.
@@ -1550,7 +1626,7 @@ class En {
1550
1626
  * @param end - The ending index of the range to remove.
1551
1627
  */
1552
1628
  prune(e, n) {
1553
- return this.dispatch(oe(e, n)), this;
1629
+ return this.dispatch(se(e, n)), this;
1554
1630
  }
1555
1631
  /**
1556
1632
  * Loads a document state and a set of operations.
@@ -1561,7 +1637,7 @@ class En {
1561
1637
  return this.dispatch(Et(e, n)), this;
1562
1638
  }
1563
1639
  }
1564
- function $n(t, e) {
1640
+ function kn(t, e) {
1565
1641
  e.forEach((n) => {
1566
1642
  Object.getOwnPropertyNames(n.prototype).forEach((i) => {
1567
1643
  Object.defineProperty(
@@ -1575,36 +1651,37 @@ function $n(t, e) {
1575
1651
  });
1576
1652
  }
1577
1653
  export {
1578
- wn as A,
1579
- En as B,
1580
- Ie as C,
1581
- Yt as D,
1582
- dn as E,
1583
- cn as F,
1584
- Qe as a,
1585
- Ye as b,
1586
- Ze as c,
1587
- ln as d,
1588
- Pe as e,
1654
+ Sn as A,
1655
+ $n as B,
1656
+ On as C,
1657
+ Ae as D,
1658
+ Yt as E,
1659
+ gn as F,
1660
+ ln as G,
1661
+ Ye as a,
1662
+ tn as b,
1663
+ Qe as c,
1664
+ mn as d,
1665
+ Me as e,
1589
1666
  W as f,
1590
- $n as g,
1591
- Sn as h,
1667
+ kn as g,
1668
+ En as h,
1592
1669
  kt as i,
1593
- bn as j,
1670
+ wn as j,
1594
1671
  Xt as k,
1595
1672
  $t as l,
1596
- fn as m,
1597
- un as n,
1598
- mn as o,
1599
- St as p,
1600
- xn as q,
1601
- gn as r,
1602
- Ae as s,
1673
+ dn as m,
1674
+ fn as n,
1675
+ un as o,
1676
+ jt as p,
1677
+ yn as q,
1678
+ hn as r,
1679
+ Pe as s,
1603
1680
  jn as t,
1604
- hn as u,
1605
- yn as v,
1606
- rt as w,
1607
- te as x,
1608
- gt as y,
1609
- On as z
1681
+ xn as u,
1682
+ bn as v,
1683
+ ee as w,
1684
+ rt as x,
1685
+ te as y,
1686
+ gt as z
1610
1687
  };