document-model 1.0.22 → 1.0.23

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 (73) hide show
  1. package/dist/browser/document-model.cjs +1 -1
  2. package/dist/browser/document-model.js +2 -2
  3. package/dist/browser/document.cjs +1 -1
  4. package/dist/browser/document.js +4 -4
  5. package/dist/browser/index.cjs +1 -1
  6. package/dist/browser/index.js +3 -3
  7. package/dist/browser/internal/{index-k0_xGFJa.js → index-8aac3662.js} +400 -398
  8. package/dist/browser/internal/index-8fceb2dc.js +1 -0
  9. package/dist/browser/internal/index-cd28e4ab.js +22 -0
  10. package/dist/browser/internal/index-e127ba7e.js +36 -0
  11. package/dist/browser/internal/{object-wtPuW7QY.js → object-67d1240b.js} +409 -359
  12. package/dist/browser/internal/object-ba4e810d.js +6 -0
  13. package/dist/browser/src/document/actions/creators.d.ts +3 -2
  14. package/dist/browser/src/document/actions/types.d.ts +1 -1
  15. package/dist/browser/src/document/object.d.ts +58 -2
  16. package/dist/browser/src/document/reducer.d.ts +2 -2
  17. package/dist/browser/src/document/schema/types.d.ts +9 -3
  18. package/dist/browser/src/document/signal.d.ts +7 -1
  19. package/dist/browser/src/document/types.d.ts +12 -1
  20. package/dist/browser/src/document/utils/base.d.ts +15 -2
  21. package/dist/browser/src/document-model/gen/header/object.d.ts +7 -6
  22. package/dist/browser/src/document-model/gen/module/object.d.ts +6 -5
  23. package/dist/browser/src/document-model/gen/operation/object.d.ts +11 -10
  24. package/dist/browser/src/document-model/gen/operation-error/object.d.ts +8 -7
  25. package/dist/browser/src/document-model/gen/operation-example/object.d.ts +5 -4
  26. package/dist/browser/src/document-model/gen/reducer.d.ts +2 -0
  27. package/dist/browser/src/document-model/gen/state/object.d.ts +7 -6
  28. package/dist/browser/src/document-model/gen/versioning/object.d.ts +6 -5
  29. package/dist/browser/src/document-model/index.d.ts +2 -1
  30. package/dist/browser/test/document/skip-operations.test.d.ts +1 -0
  31. package/dist/browser/test/document-model/skip-operations.test.d.ts +1 -0
  32. package/dist/browser/test/helpers.d.ts +5 -2
  33. package/dist/node/document-model.cjs +1 -1
  34. package/dist/node/document-model.js +2 -2
  35. package/dist/node/document.cjs +1 -1
  36. package/dist/node/document.js +4 -4
  37. package/dist/node/index.cjs +1 -1
  38. package/dist/node/index.js +3 -3
  39. package/dist/node/internal/index-ac24dd92.js +36 -0
  40. package/dist/node/internal/index-c75a9c7a.js +1 -0
  41. package/dist/node/internal/{index-vqhz-N10.js → index-e9f12d45.js} +400 -398
  42. package/dist/node/internal/index-f04f94a6.js +22 -0
  43. package/dist/node/internal/object-10b89c54.js +1 -0
  44. package/dist/node/internal/{object-yzJ3jRpE.js → object-cb276649.js} +317 -267
  45. package/dist/node/src/document/actions/creators.d.ts +3 -2
  46. package/dist/node/src/document/actions/types.d.ts +1 -1
  47. package/dist/node/src/document/object.d.ts +58 -2
  48. package/dist/node/src/document/reducer.d.ts +2 -2
  49. package/dist/node/src/document/schema/types.d.ts +9 -3
  50. package/dist/node/src/document/signal.d.ts +7 -1
  51. package/dist/node/src/document/types.d.ts +12 -1
  52. package/dist/node/src/document/utils/base.d.ts +15 -2
  53. package/dist/node/src/document-model/gen/header/object.d.ts +7 -6
  54. package/dist/node/src/document-model/gen/module/object.d.ts +6 -5
  55. package/dist/node/src/document-model/gen/operation/object.d.ts +11 -10
  56. package/dist/node/src/document-model/gen/operation-error/object.d.ts +8 -7
  57. package/dist/node/src/document-model/gen/operation-example/object.d.ts +5 -4
  58. package/dist/node/src/document-model/gen/reducer.d.ts +2 -0
  59. package/dist/node/src/document-model/gen/state/object.d.ts +7 -6
  60. package/dist/node/src/document-model/gen/versioning/object.d.ts +6 -5
  61. package/dist/node/src/document-model/index.d.ts +2 -1
  62. package/dist/node/test/document/skip-operations.test.d.ts +1 -0
  63. package/dist/node/test/document-model/skip-operations.test.d.ts +1 -0
  64. package/dist/node/test/helpers.d.ts +5 -2
  65. package/package.json +1 -1
  66. package/dist/browser/internal/index-BGvdUwMj.js +0 -1
  67. package/dist/browser/internal/index-ZaSXpgfR.js +0 -22
  68. package/dist/browser/internal/index-vHDbgY8i.js +0 -34
  69. package/dist/browser/internal/object-fIfH8K9b.js +0 -6
  70. package/dist/node/internal/index-3_D7m254.js +0 -34
  71. package/dist/node/internal/index-ffEJwj4v.js +0 -22
  72. package/dist/node/internal/index-frYzO4l6.js +0 -1
  73. package/dist/node/internal/object-Vf10stKL.js +0 -1
@@ -1,34 +1,34 @@
1
- var rt = Object.defineProperty;
2
- var mt = (t, e, i) => e in t ? rt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
3
- var j = (t, e, i) => (mt(t, typeof e != "symbol" ? e + "" : e, i), i);
4
- import ut from "json-stringify-deterministic";
5
- import { produce as P, castDraft as dt, castImmutable as xt, freeze as gt } from "immer";
1
+ var mt = Object.defineProperty;
2
+ var ut = (t, e, i) => e in t ? mt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
3
+ var w = (t, e, i) => (ut(t, typeof e != "symbol" ? e + "" : e, i), i);
4
+ import dt from "json-stringify-deterministic";
5
+ import { produce as M, castDraft as xt, castImmutable as gt, freeze as ft } from "immer";
6
6
  import { z as o } from "zod";
7
- import M from "jszip";
8
- import ft from "crypto";
9
- import k from "fs";
10
- import ht from "https";
7
+ import R from "jszip";
8
+ import ht from "crypto";
9
+ import E from "fs";
10
+ import vt from "https";
11
11
  import { join as bt } from "path";
12
- const R = (t) => t != null, vt = o.any().refine((t) => R(t)), L = o.enum(["LOAD_STATE"]), U = o.enum(["PRUNE"]), J = o.enum(["REDO"]), $ = o.enum(["SET_NAME"]), C = o.enum(["UNDO"]);
13
- function yt() {
12
+ const L = (t) => t != null, yt = o.any().refine((t) => L(t)), U = o.enum(["LOAD_STATE"]), J = o.enum(["PRUNE"]), $ = o.enum(["REDO"]), C = o.enum(["SET_NAME"]), B = o.enum(["UNDO"]);
13
+ function jt() {
14
14
  return o.object({
15
15
  __typename: o.literal("Action").optional(),
16
16
  type: o.string()
17
17
  });
18
18
  }
19
- function x() {
19
+ function g() {
20
20
  return o.literal("global").or(o.literal("local"));
21
21
  }
22
- function B() {
22
+ function Z() {
23
23
  return o.union([
24
- Z(),
25
- K(),
24
+ H(),
26
25
  W(),
27
26
  G(),
28
- Q()
27
+ Q(),
28
+ V()
29
29
  ]);
30
30
  }
31
- function jt() {
31
+ function wt() {
32
32
  return o.object({
33
33
  __typename: o.literal("DocumentFile").optional(),
34
34
  data: o.string(),
@@ -37,26 +37,26 @@ function jt() {
37
37
  mimeType: o.string()
38
38
  });
39
39
  }
40
- function Z() {
40
+ function H() {
41
41
  return o.object({
42
- input: o.lazy(() => E()),
43
- type: L,
44
- scope: x()
42
+ input: o.lazy(() => N()),
43
+ type: U,
44
+ scope: g()
45
45
  });
46
46
  }
47
- function E() {
47
+ function N() {
48
48
  return o.object({
49
49
  operations: o.number(),
50
- state: o.lazy(() => H())
50
+ state: o.lazy(() => K())
51
51
  });
52
52
  }
53
- function H() {
53
+ function K() {
54
54
  return o.object({
55
55
  data: o.unknown().nullish(),
56
56
  name: o.string()
57
57
  });
58
58
  }
59
- function wt() {
59
+ function St() {
60
60
  return o.object({
61
61
  __typename: o.literal("Operation").optional(),
62
62
  hash: o.string(),
@@ -65,36 +65,36 @@ function wt() {
65
65
  type: o.string()
66
66
  });
67
67
  }
68
- function K() {
68
+ function W() {
69
69
  return o.object({
70
- input: o.lazy(() => N()),
71
- type: U,
72
- scope: x()
70
+ input: o.lazy(() => T()),
71
+ type: J,
72
+ scope: g()
73
73
  });
74
74
  }
75
- function N() {
75
+ function T() {
76
76
  return o.object({
77
77
  end: o.number().nullish(),
78
78
  start: o.number().nullish()
79
79
  });
80
80
  }
81
81
  const A = o.number;
82
- function W() {
82
+ function G() {
83
83
  return o.object({
84
84
  input: A(),
85
- type: J,
86
- scope: x()
85
+ type: $,
86
+ scope: g()
87
87
  });
88
88
  }
89
- const T = o.string;
90
- function G() {
89
+ const z = o.string;
90
+ function Q() {
91
91
  return o.object({
92
- input: T(),
93
- type: $,
92
+ input: z(),
93
+ type: C,
94
94
  scope: o.literal("global")
95
95
  });
96
96
  }
97
- function St() {
97
+ function Ot() {
98
98
  return o.object({
99
99
  __typename: o.literal("SetNameOperation").optional(),
100
100
  hash: o.string(),
@@ -104,51 +104,51 @@ function St() {
104
104
  type: o.string()
105
105
  });
106
106
  }
107
- const z = o.number;
108
- function Q() {
107
+ const F = o.number;
108
+ function V() {
109
109
  return o.object({
110
- input: z(),
111
- type: C,
112
- scope: x()
110
+ input: F(),
111
+ type: B,
112
+ scope: g()
113
113
  });
114
114
  }
115
- const oe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
115
+ const pe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
116
116
  __proto__: null,
117
- ActionSchema: yt,
118
- BaseActionSchema: B,
119
- DocumentFileSchema: jt,
120
- LoadStateActionInputSchema: E,
121
- LoadStateActionSchema: Z,
122
- LoadStateActionStateInputSchema: H,
123
- Load_StateSchema: L,
124
- OperationSchema: wt,
125
- OperationScopeSchema: x,
126
- PruneActionInputSchema: N,
127
- PruneActionSchema: K,
128
- PruneSchema: U,
117
+ ActionSchema: jt,
118
+ BaseActionSchema: Z,
119
+ DocumentFileSchema: wt,
120
+ LoadStateActionInputSchema: N,
121
+ LoadStateActionSchema: H,
122
+ LoadStateActionStateInputSchema: K,
123
+ Load_StateSchema: U,
124
+ OperationSchema: St,
125
+ OperationScopeSchema: g,
126
+ PruneActionInputSchema: T,
127
+ PruneActionSchema: W,
128
+ PruneSchema: J,
129
129
  RedoActionInputSchema: A,
130
- RedoActionSchema: W,
131
- RedoSchema: J,
132
- SetNameActionInputSchema: T,
133
- SetNameActionSchema: G,
134
- SetNameOperationSchema: St,
135
- Set_NameSchema: $,
136
- UndoActionInputSchema: z,
137
- UndoActionSchema: Q,
138
- UndoSchema: C,
139
- definedNonNullAnySchema: vt,
140
- isDefinedNonNullAny: R
130
+ RedoActionSchema: G,
131
+ RedoSchema: $,
132
+ SetNameActionInputSchema: z,
133
+ SetNameActionSchema: Q,
134
+ SetNameOperationSchema: Ot,
135
+ Set_NameSchema: C,
136
+ UndoActionInputSchema: F,
137
+ UndoActionSchema: V,
138
+ UndoSchema: B,
139
+ definedNonNullAnySchema: yt,
140
+ isDefinedNonNullAny: L
141
141
  }, Symbol.toStringTag, { value: "Module" }));
142
- function Ot(t, e) {
142
+ function _t(t, e) {
143
143
  return { ...t, name: e };
144
144
  }
145
- function _t(t, e, i) {
145
+ function kt(t, e, i) {
146
146
  const { scope: a, input: n } = e, s = t.revision[e.scope], p = Math.min(n, s), l = t.operations[a].slice(
147
147
  0,
148
148
  s - p
149
149
  );
150
150
  return {
151
- ...S(
151
+ ...O(
152
152
  t.initialState,
153
153
  {
154
154
  ...t.operations,
@@ -172,7 +172,7 @@ function Dt(t, e, i) {
172
172
  t.revision[a] + p
173
173
  );
174
174
  return {
175
- ...S(
175
+ ...O(
176
176
  t.initialState,
177
177
  {
178
178
  ...t.operations,
@@ -187,62 +187,62 @@ function Dt(t, e, i) {
187
187
  }
188
188
  };
189
189
  }
190
- function kt(t, e, i) {
190
+ function Et(t, e, i) {
191
191
  const { scope: a } = e, n = t.operations[a];
192
192
  let {
193
193
  input: { start: s, end: p }
194
194
  } = e;
195
195
  s = s || 0, p = p || n.length;
196
- const l = n.slice(s, p), r = n.slice(0, s), c = n.slice(p), u = S(
196
+ const l = n.slice(s, p), c = n.slice(0, s), m = n.slice(p), u = O(
197
197
  t.initialState,
198
198
  {
199
199
  ...t.operations,
200
- [a]: r.concat(l)
200
+ [a]: c.concat(l)
201
201
  },
202
202
  i
203
- ), { name: m, state: v } = u, d = r.length, D = r.length ? r[r.length - 1].timestamp : c.length ? c[0].timestamp : (/* @__PURE__ */ new Date()).toISOString();
204
- return S(
203
+ ), { name: d, state: r } = u, b = c.length, y = c.length ? c[c.length - 1].timestamp : m.length ? m[0].timestamp : (/* @__PURE__ */ new Date()).toISOString();
204
+ return O(
205
205
  t.initialState,
206
206
  {
207
207
  ...t.operations,
208
208
  [a]: [
209
- ...r,
209
+ ...c,
210
210
  {
211
- ...F(
212
- { name: m, state: v },
211
+ ...I(
212
+ { name: d, state: r },
213
213
  l.length
214
214
  ),
215
- timestamp: D,
216
- index: d,
217
- hash: at({ state: v }, "global")
215
+ timestamp: y,
216
+ index: b,
217
+ hash: nt({ state: r }, "global")
218
218
  },
219
- ...c.map((y, ct) => ({
220
- ...y,
221
- index: d + ct + 1
219
+ ...m.map((D, j) => ({
220
+ ...D,
221
+ index: b + j + 1
222
222
  }))
223
223
  ]
224
224
  },
225
225
  i
226
226
  );
227
227
  }
228
- function Et(t, e) {
228
+ function Nt(t, e) {
229
229
  return {
230
230
  ...t,
231
231
  name: e.name,
232
232
  state: e.state ?? { global: {}, local: {} }
233
233
  };
234
234
  }
235
- const V = "SET_NAME", g = "UNDO", f = "REDO", h = "PRUNE", X = "LOAD_STATE";
236
- function Nt(t) {
235
+ const X = "SET_NAME", f = "UNDO", h = "REDO", v = "PRUNE", Y = "LOAD_STATE";
236
+ function Tt(t) {
237
237
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
238
238
  }
239
- function O() {
239
+ function _() {
240
240
  this._types = /* @__PURE__ */ Object.create(null), this._extensions = /* @__PURE__ */ Object.create(null);
241
241
  for (let t = 0; t < arguments.length; t++)
242
242
  this.define(arguments[t]);
243
243
  this.define = this.define.bind(this), this.getType = this.getType.bind(this), this.getExtension = this.getExtension.bind(this);
244
244
  }
245
- O.prototype.define = function(t, e) {
245
+ _.prototype.define = function(t, e) {
246
246
  for (let i in t) {
247
247
  let a = t[i].map(function(n) {
248
248
  return n.toLowerCase();
@@ -264,23 +264,23 @@ O.prototype.define = function(t, e) {
264
264
  }
265
265
  }
266
266
  };
267
- O.prototype.getType = function(t) {
267
+ _.prototype.getType = function(t) {
268
268
  t = String(t);
269
269
  let e = t.replace(/^.*[/\\]/, "").toLowerCase(), i = e.replace(/^.*\./, "").toLowerCase(), a = e.length < t.length;
270
270
  return (i.length < e.length - 1 || !a) && this._types[i] || null;
271
271
  };
272
- O.prototype.getExtension = function(t) {
272
+ _.prototype.getExtension = function(t) {
273
273
  return t = /^\s*([^;\s]*)/.test(t) && RegExp.$1, t && this._extensions[t.toLowerCase()] || null;
274
274
  };
275
- var At = O, Tt = { "application/andrew-inset": ["ez"], "application/applixware": ["aw"], "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/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/cu-seeme": ["cu"], "application/dash+xml": ["mpd"], "application/davmount+xml": ["davmount"], "application/docbook+xml": ["dbk"], "application/dssc+der": ["dssc"], "application/dssc+xml": ["xdssc"], "application/ecmascript": ["es", "ecma"], "application/emma+xml": ["emma"], "application/emotionml+xml": ["emotionml"], "application/epub+zip": ["epub"], "application/exi": ["exi"], "application/express": ["exp"], "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", "mjs"], "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/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": ["mp4s", "m4p"], "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-signature": ["asc", "sig"], "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/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/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/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/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/avif": ["avif"], "image/bmp": ["bmp"], "image/cgm": ["cgm"], "image/dicom-rle": ["drle"], "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"], "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/mesh": ["msh", "mesh", "silo"], "model/mtl": ["mtl"], "model/obj": ["obj"], "model/step+xml": ["stpx"], "model/step+zip": ["stpz"], "model/step-xml+zip": ["stpxz"], "model/stl": ["stl"], "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/jsx": ["jsx"], "text/less": ["less"], "text/markdown": ["markdown", "md"], "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/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"] };
276
- let zt = At;
277
- var Ft = new zt(Tt);
278
- const Pt = /* @__PURE__ */ Nt(Ft);
279
- function qt(t, e, i) {
275
+ var At = _, zt = { "application/andrew-inset": ["ez"], "application/applixware": ["aw"], "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/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/cu-seeme": ["cu"], "application/dash+xml": ["mpd"], "application/davmount+xml": ["davmount"], "application/docbook+xml": ["dbk"], "application/dssc+der": ["dssc"], "application/dssc+xml": ["xdssc"], "application/ecmascript": ["es", "ecma"], "application/emma+xml": ["emma"], "application/emotionml+xml": ["emotionml"], "application/epub+zip": ["epub"], "application/exi": ["exi"], "application/express": ["exp"], "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", "mjs"], "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/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": ["mp4s", "m4p"], "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-signature": ["asc", "sig"], "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/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/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/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/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/avif": ["avif"], "image/bmp": ["bmp"], "image/cgm": ["cgm"], "image/dicom-rle": ["drle"], "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"], "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/mesh": ["msh", "mesh", "silo"], "model/mtl": ["mtl"], "model/obj": ["obj"], "model/step+xml": ["stpx"], "model/step+zip": ["stpz"], "model/step-xml+zip": ["stpxz"], "model/stl": ["stl"], "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/jsx": ["jsx"], "text/less": ["less"], "text/markdown": ["markdown", "md"], "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/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"] };
276
+ let Ft = At;
277
+ var It = new Ft(zt);
278
+ const Mt = /* @__PURE__ */ Tt(It);
279
+ function Pt(t, e, i) {
280
280
  const a = bt(t, e);
281
- return k.mkdirSync(t, { recursive: !0 }), new Promise((n, s) => {
281
+ return E.mkdirSync(t, { recursive: !0 }), new Promise((n, s) => {
282
282
  try {
283
- k.writeFile(a, i, {}, (p) => {
283
+ E.writeFile(a, i, {}, (p) => {
284
284
  p ? s(p) : n(a);
285
285
  });
286
286
  } catch (p) {
@@ -288,12 +288,12 @@ function qt(t, e, i) {
288
288
  }
289
289
  });
290
290
  }
291
- function Y(t) {
292
- return k.readFileSync(t);
291
+ function tt(t) {
292
+ return E.readFileSync(t);
293
293
  }
294
- function It(t) {
294
+ function qt(t) {
295
295
  return new Promise((e, i) => {
296
- ht.get(t, (a) => {
296
+ vt.get(t, (a) => {
297
297
  const n = [], s = a.headers["content-type"];
298
298
  a.on("data", (p) => {
299
299
  n.push(p);
@@ -305,8 +305,8 @@ function It(t) {
305
305
  });
306
306
  });
307
307
  }
308
- const Mt = async (t) => Y(t), _ = (t, e = "sha1") => ft.createHash(e).update(t).digest("base64"), tt = async (t) => {
309
- const e = new M(), { name: i, revision: a, documentType: n, created: s, lastModified: p } = t, l = {
308
+ const Rt = async (t) => tt(t), k = (t, e = "sha1") => ht.createHash(e).update(t).digest("base64"), et = async (t) => {
309
+ const e = new R(), { name: i, revision: a, documentType: n, created: s, lastModified: p } = t, l = {
310
310
  name: i,
311
311
  revision: a,
312
312
  documentType: n,
@@ -316,35 +316,35 @@ const Mt = async (t) => Y(t), _ = (t, e = "sha1") => ft.createHash(e).update(t).
316
316
  return e.file("header.json", JSON.stringify(l, null, 2)), e.file(
317
317
  "state.json",
318
318
  JSON.stringify(t.initialState || {}, null, 2)
319
- ), e.file("operations.json", JSON.stringify(t.operations, null, 2)), Object.keys(t.attachments).forEach((c) => {
320
- const { data: u, ...m } = t.attachments[c];
321
- e.file(c, u, {
319
+ ), e.file("operations.json", JSON.stringify(t.operations, null, 2)), Object.keys(t.attachments).forEach((m) => {
320
+ const { data: u, ...d } = t.attachments[m];
321
+ e.file(m, u, {
322
322
  base64: !0,
323
323
  createFolders: !0,
324
- comment: JSON.stringify(m)
324
+ comment: JSON.stringify(d)
325
325
  });
326
326
  }), e;
327
- }, Rt = async (t, e, i, a) => {
328
- const s = await (await tt(t)).generateAsync({
327
+ }, Lt = async (t, e, i, a) => {
328
+ const s = await (await et(t)).generateAsync({
329
329
  type: "uint8array",
330
330
  streamFiles: !0
331
331
  }), p = a ?? t.name, l = `.${i}.zip`;
332
- return qt(
332
+ return Pt(
333
333
  e,
334
334
  p.endsWith(l) ? p : `${p}${l}`,
335
335
  s
336
336
  );
337
- }, se = async (t, e) => {
338
- const a = await (await tt(t)).generateAsync({ type: "blob" }), n = await e.createWritable();
337
+ }, le = async (t, e) => {
338
+ const a = await (await et(t)).generateAsync({ type: "blob" }), n = await e.createWritable();
339
339
  await n.write(a), await n.close();
340
- }, q = async (t, e) => {
341
- const i = Y(t);
342
- return Lt(i, e);
343
- }, Lt = async (t, e) => {
344
- const i = new M();
345
- return await i.loadAsync(t), Ut(i, e);
340
+ }, P = async (t, e) => {
341
+ const i = tt(t);
342
+ return Ut(i, e);
343
+ }, Ut = async (t, e) => {
344
+ const i = new R();
345
+ return await i.loadAsync(t), Jt(i, e);
346
346
  };
347
- async function Ut(t, e) {
347
+ async function Jt(t, e) {
348
348
  const i = t.file("state.json");
349
349
  if (!i)
350
350
  throw new Error("Initial state not found");
@@ -354,115 +354,119 @@ async function Ut(t, e) {
354
354
  const l = t.file("operations.json");
355
355
  if (!l)
356
356
  throw new Error("Operations history not found");
357
- const r = JSON.parse(
357
+ const c = JSON.parse(
358
358
  await l.async("string")
359
359
  );
360
- let c = nt(
360
+ let m = ot(
361
361
  n,
362
- r,
362
+ c,
363
363
  e,
364
364
  void 0,
365
365
  p
366
366
  );
367
- return p && (c = {
368
- ...c,
367
+ return p && (m = {
368
+ ...m,
369
369
  ...p
370
- }), c;
370
+ }), m;
371
371
  }
372
- function et(t) {
372
+ function it(t) {
373
373
  const e = t.replace(/^.*\./, "") || void 0, i = t.replace(/^.*[/\\]/, "") || void 0;
374
374
  return { extension: e, fileName: i };
375
375
  }
376
- async function pe(t) {
377
- const { buffer: e, mimeType: i = "application/octet-stream" } = await It(t), a = et(t), n = e.toString("base64");
376
+ async function ce(t) {
377
+ const { buffer: e, mimeType: i = "application/octet-stream" } = await qt(t), a = it(t), n = e.toString("base64");
378
378
  return {
379
379
  data: n,
380
- hash: _(n),
380
+ hash: k(n),
381
381
  mimeType: i,
382
382
  ...a
383
383
  };
384
384
  }
385
- async function le(t) {
386
- const e = await Mt(t), i = Pt.getType(t) || "application/octet-stream", a = et(t), n = e.toString("base64");
387
- return { data: n, hash: _(n), mimeType: i, ...a };
385
+ async function re(t) {
386
+ const e = await Rt(t), i = Mt.getType(t) || "application/octet-stream", a = it(t), n = e.toString("base64");
387
+ return { data: n, hash: k(n), mimeType: i, ...a };
388
388
  }
389
- function Jt(t, e) {
389
+ function $t(t, e) {
390
390
  const i = t.revision[e.scope];
391
- return [g, f, h].includes(e.type) ? i : i + 1;
391
+ return [f, h, v].includes(e.type) ? i : i + 1;
392
392
  }
393
- function $t(t, e) {
393
+ function Ct(t, e) {
394
394
  return {
395
395
  ...t,
396
396
  revision: {
397
397
  ...t.revision,
398
- [e.scope]: Jt(t, e)
398
+ [e.scope]: $t(t, e)
399
399
  },
400
400
  lastModified: (/* @__PURE__ */ new Date()).toISOString()
401
401
  };
402
402
  }
403
- function Ct(t, e) {
404
- if ([g, f, h].includes(e.type))
403
+ function Bt(t, e, i = 0) {
404
+ if ([f, h, v].includes(e.type))
405
405
  return t;
406
- const { scope: i } = e, a = t.operations[i].slice(
406
+ const { scope: a } = e, n = t.operations[a].slice(
407
407
  0,
408
- t.revision[i]
408
+ t.revision[a]
409
409
  );
410
- return a.push({
410
+ return n.push({
411
411
  ...e,
412
- index: a.length,
412
+ index: n.length,
413
413
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
414
414
  hash: "",
415
- scope: i
415
+ scope: a,
416
+ skip: i
416
417
  }), {
417
418
  ...t,
418
- operations: { ...t.operations, [i]: a }
419
+ operations: { ...t.operations, [a]: n }
419
420
  };
420
421
  }
421
- function Bt(t, e) {
422
- let i = Ct(t, e);
423
- return i = $t(i, e), i;
422
+ function Zt(t, e, i = 0) {
423
+ let a = Bt(t, e, i);
424
+ return a = Ct(a, e), a;
424
425
  }
425
- function Zt(t, e, i) {
426
- switch (B().parse(e), e.type) {
427
- case V:
428
- return Ot(t, e.input);
429
- case g:
430
- return _t(t, e, i);
426
+ function Ht(t, e, i) {
427
+ switch (Z().parse(e), e.type) {
428
+ case X:
429
+ return _t(t, e.input);
431
430
  case f:
432
- return Dt(t, e, i);
433
- case h:
434
431
  return kt(t, e, i);
435
- case X:
436
- return Et(t, e.input.state);
432
+ case h:
433
+ return Dt(t, e, i);
434
+ case v:
435
+ return Et(t, e, i);
436
+ case Y:
437
+ return Nt(t, e.input.state);
437
438
  default:
438
439
  return t;
439
440
  }
440
441
  }
441
- function it(t, e, i, a) {
442
- let n = t;
443
- return I(e) && (n = Zt(n, e, i)), n = Bt(n, e), n = P(n, (s) => {
444
- const p = i(s.state, e, a);
445
- if (p)
446
- return dt({
447
- ...n,
448
- state: p
442
+ function at(t, e, i, a, n = {}) {
443
+ const {
444
+ skip: s = 0
445
+ } = n;
446
+ let p = t;
447
+ return q(e) && (p = Ht(p, e, i)), p = Zt(p, e, s), p = M(p, (l) => {
448
+ const c = i(l.state, e, a);
449
+ if (c)
450
+ return xt({
451
+ ...p,
452
+ state: c
449
453
  });
450
- }), P(n, (s) => {
451
- if ([g, f, h].includes(e.type))
452
- return s;
453
- const p = e.scope || "global";
454
- s.operations[p][s.operations[p].length - 1].hash = at(s, p), !I(e) && e.attachments && e.attachments.forEach((l) => {
455
- const { hash: r, ...c } = l;
456
- s.attachments[r] = {
457
- ...c
454
+ }), M(p, (l) => {
455
+ if ([f, h, v].includes(e.type))
456
+ return l;
457
+ const c = e.scope || "global";
458
+ l.operations[c][l.operations[c].length - 1].hash = nt(l, c), !q(e) && e.attachments && e.attachments.forEach((m) => {
459
+ const { hash: u, ...d } = m;
460
+ l.attachments[u] = {
461
+ ...d
458
462
  };
459
463
  });
460
464
  });
461
465
  }
462
- function I(t) {
463
- return [V, g, f, h, X].includes(t.type);
466
+ function q(t) {
467
+ return [X, f, h, v, Y].includes(t.type);
464
468
  }
465
- function b(t, e, i, a, n = "global") {
469
+ function x(t, e, i, a, n = "global") {
466
470
  if (!t)
467
471
  throw new Error("Empty action type");
468
472
  if (typeof t != "string")
@@ -476,10 +480,10 @@ function b(t, e, i, a, n = "global") {
476
480
  }
477
481
  return s;
478
482
  }
479
- function Ht(t, e = it) {
480
- return (i, a, n) => e(i, a, t, n);
483
+ function Kt(t, e = at) {
484
+ return (i, a, n, s) => e(i, a, t, n, s);
481
485
  }
482
- const Kt = (t, e) => ({
486
+ const Wt = (t, e) => ({
483
487
  name: "",
484
488
  documentType: "",
485
489
  revision: {
@@ -491,8 +495,8 @@ const Kt = (t, e) => ({
491
495
  attachments: {},
492
496
  ...t,
493
497
  state: (e == null ? void 0 : e(t == null ? void 0 : t.state)) ?? (t == null ? void 0 : t.state) ?? { global: {}, local: {} }
494
- }), Wt = (t, e) => {
495
- const i = Kt(
498
+ }), Gt = (t, e) => {
499
+ const i = Wt(
496
500
  t,
497
501
  e
498
502
  );
@@ -501,21 +505,45 @@ const Kt = (t, e) => ({
501
505
  initialState: i,
502
506
  operations: { global: [], local: [] }
503
507
  };
504
- }, at = (t, e = "global") => _(ut(t.state[e])), ce = (t, e = 1e3) => {
508
+ }, nt = (t, e = "global") => k(dt(t.state[e])), me = (t, e = 1e3) => {
505
509
  const i = Math.random() * e;
506
- return _(`${(t ?? /* @__PURE__ */ new Date()).toISOString()}${i}`);
510
+ return k(`${(t ?? /* @__PURE__ */ new Date()).toISOString()}${i}`);
507
511
  };
508
- function w(t) {
509
- return xt(gt(t, !0));
512
+ function S(t) {
513
+ return gt(ft(t, !0));
514
+ }
515
+ function Qt(t) {
516
+ const e = [...t];
517
+ let i = 0, a = e.length > 0 ? e[e.length - 1].index : 0;
518
+ const n = [];
519
+ for (const s of e.reverse()) {
520
+ if (i > 0) {
521
+ const l = a - s.index;
522
+ i -= l;
523
+ }
524
+ if (i < 0)
525
+ throw new Error("Invalid operation index, missing operations");
526
+ const p = {
527
+ ignore: i > 0,
528
+ operation: s
529
+ };
530
+ s.skip > 0 && (i = i + (s.skip + 1)), a = s.index, n.push(p);
531
+ }
532
+ return n.reverse();
510
533
  }
511
- function Gt(t) {
534
+ function ue(t) {
512
535
  return Object.values(t).flatMap((e) => e).sort(
513
536
  (e, i) => new Date(e.timestamp).getTime() - new Date(i.timestamp).getTime()
514
537
  );
515
538
  }
516
- function S(t, e, i, a, n, s = it) {
517
- const p = Ht(i, s);
518
- return nt(
539
+ function Vt(t) {
540
+ return Object.values(t).flatMap((e) => e).sort(
541
+ (e, i) => new Date(e.operation.timestamp).getTime() - new Date(i.operation.timestamp).getTime()
542
+ );
543
+ }
544
+ function O(t, e, i, a, n, s = at) {
545
+ const p = Kt(i, s);
546
+ return ot(
519
547
  t,
520
548
  e,
521
549
  p,
@@ -523,85 +551,104 @@ function S(t, e, i, a, n, s = it) {
523
551
  n
524
552
  );
525
553
  }
526
- function nt(t, e, i, a, n) {
527
- const s = Wt(t), p = Object.keys(e).reduce((c, u) => {
528
- const m = u;
554
+ function ot(t, e, i, a, n) {
555
+ const s = Gt(t), p = Object.keys(e).reduce((u, d) => {
556
+ const r = d;
557
+ return {
558
+ ...u,
559
+ [r]: e[r].slice(0, n == null ? void 0 : n.revision[r])
560
+ };
561
+ }, {}), l = Object.keys(p).reduce((u, d) => {
562
+ const r = d;
529
563
  return {
530
- ...c,
531
- [m]: e[m].slice(0, n == null ? void 0 : n.revision[m])
564
+ ...u,
565
+ [r]: Qt(p[r])
532
566
  };
533
- }, {}), l = Gt(p).reduce(
534
- (c, u) => i(c, u, a),
567
+ }, {}), c = Vt(l).reduce(
568
+ (u, { ignore: d, operation: r }) => d ? i(
569
+ u,
570
+ rt(r.scope),
571
+ a,
572
+ { skip: r.skip }
573
+ ) : i(u, r, a),
535
574
  s
536
- ), r = Object.keys(
537
- l.operations
575
+ ), m = Object.keys(
576
+ c.operations
538
577
  ).reduce(
539
- (c, u) => {
540
- const m = u, v = n && n.revision[m] < e[m].length ? e[m].slice(n.revision[m]) : [];
578
+ (u, d) => {
579
+ const r = d, b = n && n.revision[r] < e[r].length ? e[r].slice(n.revision[r]) : [];
541
580
  return {
542
- ...c,
543
- [m]: [
544
- ...l.operations[m].map((d, D) => {
545
- var y;
581
+ ...u,
582
+ [r]: [
583
+ ...c.operations[r].map((y, D) => {
584
+ var j;
546
585
  return {
547
- ...d,
548
- timestamp: ((y = e[m][D]) == null ? void 0 : y.timestamp) ?? d.timestamp
586
+ ...y,
587
+ timestamp: ((j = e[r][D]) == null ? void 0 : j.timestamp) ?? y.timestamp
549
588
  };
550
589
  }),
551
- ...v
590
+ ...b
552
591
  ]
553
592
  };
554
593
  },
555
594
  { global: [], local: [] }
556
595
  );
557
- return { ...l, operations: r };
596
+ return { ...c, operations: m };
558
597
  }
559
- const ot = (t) => b(
598
+ const st = (t) => x(
560
599
  "SET_NAME",
561
600
  t,
562
601
  void 0,
563
- T
564
- ), st = (t = 1, e = "global") => b(
602
+ z,
603
+ void 0
604
+ ), pt = (t = 1, e = "global") => x(
565
605
  "UNDO",
566
606
  t,
567
607
  void 0,
568
- z,
608
+ F,
569
609
  e
570
- ), pt = (t = 1, e = "global") => b(
610
+ ), lt = (t = 1, e = "global") => x(
571
611
  "REDO",
572
612
  t,
573
613
  void 0,
574
614
  A,
575
615
  e
576
- ), lt = (t, e, i = "global") => b(
616
+ ), ct = (t, e, i = "global") => x(
577
617
  "PRUNE",
578
618
  { start: t, end: e },
579
619
  void 0,
580
- N,
620
+ T,
581
621
  i
582
- ), F = (t, e) => b(
622
+ ), I = (t, e) => x(
583
623
  "LOAD_STATE",
584
624
  { state: t, operations: e },
585
625
  void 0,
586
- E
587
- ), re = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
626
+ N
627
+ ), rt = (t = "global") => x(
628
+ "NOOP",
629
+ {},
630
+ void 0,
631
+ void 0,
632
+ t
633
+ ), de = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
588
634
  __proto__: null,
589
- loadState: F,
590
- prune: lt,
591
- redo: pt,
592
- setName: ot,
593
- undo: st
635
+ loadState: I,
636
+ noop: rt,
637
+ prune: ct,
638
+ redo: lt,
639
+ setName: st,
640
+ undo: pt
594
641
  }, Symbol.toStringTag, { value: "Module" }));
595
- class me {
642
+ class xe {
596
643
  /**
597
644
  * Constructs a BaseDocument instance with an initial state.
598
645
  * @param reducer - The reducer function that updates the state.
599
646
  * @param document - The initial state of the document.
600
647
  */
601
648
  constructor(e, i, a) {
602
- j(this, "_document");
603
- j(this, "_reducer");
604
- j(this, "_signalDispatch");
649
+ w(this, "_document");
650
+ w(this, "_reducer");
651
+ w(this, "_signalDispatch");
605
652
  this._reducer = e, this._document = i, this._signalDispatch = a;
606
653
  }
607
654
  /**
@@ -609,11 +656,12 @@ class me {
609
656
  * @param action - The action to dispatch.
610
657
  * @returns The Document instance.
611
658
  */
612
- dispatch(e) {
659
+ dispatch(e, i) {
613
660
  return this._document = this._reducer(
614
661
  this._document,
615
662
  e,
616
- this._signalDispatch
663
+ this._signalDispatch,
664
+ i
617
665
  ), this;
618
666
  }
619
667
  /**
@@ -623,14 +671,14 @@ class me {
623
671
  * @returns The file path where the state was saved.
624
672
  */
625
673
  saveToFile(e, i, a) {
626
- return Rt(this._document, e, i, a);
674
+ return Lt(this._document, e, i, a);
627
675
  }
628
676
  /**
629
677
  * Loads the state of the document from a file.
630
678
  * @param path - The file path where the state is stored.
631
679
  */
632
680
  async loadFromFile(e) {
633
- this._document = await q(e, this._reducer);
681
+ this._document = await P(e, this._reducer);
634
682
  }
635
683
  /**
636
684
  * Loads the state of the document from a file and returns it.
@@ -639,19 +687,19 @@ class me {
639
687
  * @returns The state of the document.
640
688
  */
641
689
  static async stateFromFile(e, i) {
642
- return await q(e, i);
690
+ return await P(e, i);
643
691
  }
644
692
  /**
645
693
  * Gets the current state of the document.
646
694
  */
647
695
  get state() {
648
- return w(this._document.state);
696
+ return S(this._document.state);
649
697
  }
650
698
  /**
651
699
  * Gets the list of operations performed on the document.
652
700
  */
653
701
  get operations() {
654
- return w(this._document.operations);
702
+ return S(this._document.operations);
655
703
  }
656
704
  /**
657
705
  * Gets the name of the document.
@@ -690,13 +738,13 @@ class me {
690
738
  * Gets the initial state of the document.
691
739
  */
692
740
  get initialState() {
693
- return w(this._document.initialState);
741
+ return S(this._document.initialState);
694
742
  }
695
743
  /**
696
744
  * Returns the current document as an object
697
745
  */
698
746
  toDocument() {
699
- return w(this._document);
747
+ return S(this._document);
700
748
  }
701
749
  /**
702
750
  * Gets the attachment associated with the given key.
@@ -710,21 +758,21 @@ class me {
710
758
  * @param name - The new name of the document.
711
759
  */
712
760
  setName(e) {
713
- return this.dispatch(ot(e)), this;
761
+ return this.dispatch(st(e)), this;
714
762
  }
715
763
  /**
716
764
  * Reverts a number of actions from the document.
717
765
  * @param count - The number of actions to revert.
718
766
  */
719
767
  undo(e) {
720
- return this.dispatch(st(e)), this;
768
+ return this.dispatch(pt(e)), this;
721
769
  }
722
770
  /**
723
771
  * Reapplies a number of actions to the document.
724
772
  * @param count - The number of actions to reapply.
725
773
  */
726
774
  redo(e) {
727
- return this.dispatch(pt(e)), this;
775
+ return this.dispatch(lt(e)), this;
728
776
  }
729
777
  /**
730
778
  * Removes a range of operations from the document.
@@ -732,7 +780,7 @@ class me {
732
780
  * @param end - The ending index of the range to remove.
733
781
  */
734
782
  prune(e, i) {
735
- return this.dispatch(lt(e, i)), this;
783
+ return this.dispatch(ct(e, i)), this;
736
784
  }
737
785
  /**
738
786
  * Loads a document state and a set of operations.
@@ -740,10 +788,10 @@ class me {
740
788
  * @param operations - The operations to apply to the document.
741
789
  */
742
790
  loadState(e, i) {
743
- return this.dispatch(F(e, i)), this;
791
+ return this.dispatch(I(e, i)), this;
744
792
  }
745
793
  }
746
- function ue(t, e) {
794
+ function ge(t, e) {
747
795
  e.forEach((i) => {
748
796
  Object.getOwnPropertyNames(i.prototype).forEach((a) => {
749
797
  Object.defineProperty(
@@ -757,27 +805,29 @@ function ue(t, e) {
757
805
  });
758
806
  }
759
807
  export {
760
- me as B,
761
- Kt as a,
762
- Wt as b,
763
- Ht as c,
764
- se as d,
765
- Lt as e,
766
- b as f,
767
- ue as g,
768
- re as h,
769
- I as i,
770
- tt as j,
771
- le as k,
772
- q as l,
773
- pe as m,
774
- at as n,
775
- ce as o,
776
- nt as p,
777
- S as q,
778
- w as r,
779
- Rt as s,
780
- Gt as t,
781
- it as u,
782
- oe as z
808
+ xe as B,
809
+ Wt as a,
810
+ Gt as b,
811
+ Kt as c,
812
+ le as d,
813
+ Ut as e,
814
+ x as f,
815
+ ge as g,
816
+ de as h,
817
+ q as i,
818
+ et as j,
819
+ re as k,
820
+ P as l,
821
+ ce as m,
822
+ nt as n,
823
+ me as o,
824
+ Qt as p,
825
+ ot as q,
826
+ S as r,
827
+ Lt as s,
828
+ O as t,
829
+ Vt as u,
830
+ ue as v,
831
+ at as w,
832
+ pe as z
783
833
  };