document-model 1.0.19 → 1.0.20

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 (45) hide show
  1. package/dist/browser/document/actions/creators.d.ts +4 -4
  2. package/dist/browser/document/actions/index.d.ts +4 -4
  3. package/dist/browser/document/object.d.ts +119 -13
  4. package/dist/browser/document/schema/types.d.ts +5 -4
  5. package/dist/browser/document/schema/zod.d.ts +14 -12
  6. package/dist/browser/document/types.d.ts +2 -5
  7. package/dist/browser/document-model/gen/schema/zod.d.ts +5 -3
  8. package/dist/browser/document-model/index.d.ts +3 -3
  9. package/dist/browser/document-model.cjs +1 -1
  10. package/dist/browser/document-model.js +2 -2
  11. package/dist/browser/document.cjs +1 -1
  12. package/dist/browser/document.js +2 -2
  13. package/dist/browser/index.cjs +1 -1
  14. package/dist/browser/index.js +3 -3
  15. package/dist/browser/internal/{index-46b68530.js → index-22f88bf2.js} +361 -357
  16. package/dist/{node/internal/index-f235f9be.js → browser/internal/index-3607fd07.js} +1 -1
  17. package/dist/{node/internal/index-6477ee0a.js → browser/internal/index-79fde5f3.js} +1 -1
  18. package/dist/browser/internal/index-dda5d688.js +22 -0
  19. package/dist/browser/internal/object-32802eed.js +6 -0
  20. package/dist/browser/internal/{object-d50f7d2f.js → object-d03c84c9.js} +857 -819
  21. package/dist/node/document/actions/creators.d.ts +4 -4
  22. package/dist/node/document/actions/index.d.ts +4 -4
  23. package/dist/node/document/object.d.ts +119 -13
  24. package/dist/node/document/schema/types.d.ts +5 -4
  25. package/dist/node/document/schema/zod.d.ts +14 -12
  26. package/dist/node/document/types.d.ts +2 -5
  27. package/dist/node/document-model/gen/schema/zod.d.ts +5 -3
  28. package/dist/node/document-model/index.d.ts +3 -3
  29. package/dist/node/document-model.cjs +1 -1
  30. package/dist/node/document-model.js +2 -2
  31. package/dist/node/document.cjs +1 -1
  32. package/dist/node/document.js +2 -2
  33. package/dist/node/index.cjs +1 -1
  34. package/dist/node/index.js +3 -3
  35. package/dist/node/internal/{index-8d582c48.js → index-14279b3a.js} +361 -357
  36. package/dist/{browser/internal/index-869c5d0d.js → node/internal/index-4b25c8a5.js} +1 -1
  37. package/dist/node/internal/index-bfc402ef.js +22 -0
  38. package/dist/{browser/internal/index-2551382e.js → node/internal/index-e02d7854.js} +1 -1
  39. package/dist/node/internal/object-ac706c4a.js +1 -0
  40. package/dist/node/internal/{object-773231ca.js → object-b97efc1b.js} +399 -361
  41. package/package.json +1 -1
  42. package/dist/browser/internal/index-1ad32a2e.js +0 -22
  43. package/dist/browser/internal/object-1fdba77d.js +0 -6
  44. package/dist/node/internal/index-631ba7bf.js +0 -22
  45. package/dist/node/internal/object-08bd169a.js +0 -1
@@ -1,31 +1,34 @@
1
- var pt = Object.defineProperty;
2
- var lt = (t, i, e) => i in t ? pt(t, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[i] = e;
3
- var h = (t, i, e) => (lt(t, typeof i != "symbol" ? i + "" : i, e), e);
4
- import ct from "json-stringify-deterministic";
5
- import { produce as T, castDraft as rt, castImmutable as mt, freeze as ut } from "immer";
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";
6
6
  import { z as o } from "zod";
7
- import P from "jszip";
8
- import dt from "crypto";
9
- import O from "fs";
10
- import xt from "https";
11
- import { join as gt } from "path";
12
- const q = (t) => t != null, ft = o.any().refine((t) => q(t)), I = o.enum(["LOAD_STATE"]), M = o.enum(["PRUNE"]), R = o.enum(["REDO"]), L = o.enum(["SET_NAME"]), U = o.enum(["UNDO"]);
13
- function ht() {
7
+ import M from "jszip";
8
+ import ft from "crypto";
9
+ import k from "fs";
10
+ import ht from "https";
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() {
14
14
  return o.object({
15
15
  __typename: o.literal("Action").optional(),
16
16
  type: o.string()
17
17
  });
18
18
  }
19
- function J() {
19
+ function x() {
20
+ return o.literal("global").or(o.literal("local"));
21
+ }
22
+ function B() {
20
23
  return o.union([
21
- $(),
22
- B(),
23
24
  Z(),
24
- H(),
25
- K()
25
+ K(),
26
+ W(),
27
+ G(),
28
+ Q()
26
29
  ]);
27
30
  }
28
- function bt() {
31
+ function jt() {
29
32
  return o.object({
30
33
  __typename: o.literal("DocumentFile").optional(),
31
34
  data: o.string(),
@@ -34,26 +37,26 @@ function bt() {
34
37
  mimeType: o.string()
35
38
  });
36
39
  }
37
- function $() {
40
+ function Z() {
38
41
  return o.object({
39
- input: o.lazy(() => _()),
40
- type: I,
41
- scope: o.literal("global")
42
+ input: o.lazy(() => E()),
43
+ type: L,
44
+ scope: x()
42
45
  });
43
46
  }
44
- function _() {
47
+ function E() {
45
48
  return o.object({
46
49
  operations: o.number(),
47
- state: o.lazy(() => C())
50
+ state: o.lazy(() => H())
48
51
  });
49
52
  }
50
- function C() {
53
+ function H() {
51
54
  return o.object({
52
55
  data: o.unknown().nullish(),
53
56
  name: o.string()
54
57
  });
55
58
  }
56
- function vt() {
59
+ function wt() {
57
60
  return o.object({
58
61
  __typename: o.literal("Operation").optional(),
59
62
  hash: o.string(),
@@ -62,36 +65,36 @@ function vt() {
62
65
  type: o.string()
63
66
  });
64
67
  }
65
- function B() {
68
+ function K() {
66
69
  return o.object({
67
- input: o.lazy(() => D()),
68
- type: M,
69
- scope: o.literal("global")
70
+ input: o.lazy(() => N()),
71
+ type: U,
72
+ scope: x()
70
73
  });
71
74
  }
72
- function D() {
75
+ function N() {
73
76
  return o.object({
74
77
  end: o.number().nullish(),
75
78
  start: o.number().nullish()
76
79
  });
77
80
  }
78
- const k = o.number;
79
- function Z() {
81
+ const A = o.number;
82
+ function W() {
80
83
  return o.object({
81
- input: k(),
82
- type: R,
83
- scope: o.literal("global")
84
+ input: A(),
85
+ type: J,
86
+ scope: x()
84
87
  });
85
88
  }
86
- const E = o.string;
87
- function H() {
89
+ const T = o.string;
90
+ function G() {
88
91
  return o.object({
89
- input: E(),
90
- type: L,
92
+ input: T(),
93
+ type: $,
91
94
  scope: o.literal("global")
92
95
  });
93
96
  }
94
- function yt() {
97
+ function St() {
95
98
  return o.object({
96
99
  __typename: o.literal("SetNameOperation").optional(),
97
100
  hash: o.string(),
@@ -101,240 +104,251 @@ function yt() {
101
104
  type: o.string()
102
105
  });
103
106
  }
104
- const N = o.number;
105
- function K() {
107
+ const z = o.number;
108
+ function Q() {
106
109
  return o.object({
107
- input: N(),
108
- type: U,
109
- scope: o.literal("global")
110
+ input: z(),
111
+ type: C,
112
+ scope: x()
110
113
  });
111
114
  }
112
- const ei = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
115
+ const oe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
113
116
  __proto__: null,
114
- ActionSchema: ht,
115
- BaseActionSchema: J,
116
- DocumentFileSchema: bt,
117
- LoadStateActionInputSchema: _,
118
- LoadStateActionSchema: $,
119
- LoadStateActionStateInputSchema: C,
120
- Load_StateSchema: I,
121
- OperationSchema: vt,
122
- PruneActionInputSchema: D,
123
- PruneActionSchema: B,
124
- PruneSchema: M,
125
- RedoActionInputSchema: k,
126
- RedoActionSchema: Z,
127
- RedoSchema: R,
128
- SetNameActionInputSchema: E,
129
- SetNameActionSchema: H,
130
- SetNameOperationSchema: yt,
131
- Set_NameSchema: L,
132
- UndoActionInputSchema: N,
133
- UndoActionSchema: K,
134
- UndoSchema: U,
135
- definedNonNullAnySchema: ft,
136
- isDefinedNonNullAny: q
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,
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
137
141
  }, Symbol.toStringTag, { value: "Module" }));
138
- function jt(t, i) {
139
- return { ...t, name: i };
142
+ function Ot(t, e) {
143
+ return { ...t, name: e };
140
144
  }
141
- function wt(t, i, e) {
142
- const n = Math.min(i, t.revision), a = t.operations.global.slice(
145
+ function _t(t, e, i) {
146
+ const { scope: a, input: n } = e, s = t.revision[e.scope], p = Math.min(n, s), l = t.operations[a].slice(
143
147
  0,
144
- t.revision - n
148
+ s - p
145
149
  );
146
150
  return {
147
- ...v(
151
+ ...S(
148
152
  t.initialState,
149
153
  {
150
- global: a,
151
- local: t.operations.local
154
+ ...t.operations,
155
+ [a]: l
152
156
  },
153
- e
157
+ i
154
158
  ),
155
159
  operations: t.operations,
156
- revision: t.revision - n
160
+ revision: {
161
+ ...t.revision,
162
+ [a]: t.revision[a] - p
163
+ }
157
164
  };
158
165
  }
159
- function St(t, i, e) {
160
- const n = t.operations.global.length - t.revision;
161
- if (!n)
166
+ function Dt(t, e, i) {
167
+ const { scope: a, input: n } = e, s = t.operations[a].length - t.revision[a];
168
+ if (!s)
162
169
  throw new Error("There is no UNDO operation to REDO");
163
- const a = i < n ? i : n, s = t.operations.global.slice(
170
+ const p = n < s ? n : s, l = t.operations[a].slice(
164
171
  0,
165
- t.revision + a
172
+ t.revision[a] + p
166
173
  );
167
174
  return {
168
- ...v(
175
+ ...S(
169
176
  t.initialState,
170
177
  {
171
- global: s,
172
- local: t.operations.local
178
+ ...t.operations,
179
+ [a]: l
173
180
  },
174
- e
181
+ i
175
182
  ),
176
183
  operations: t.operations,
177
- revision: t.revision + a
184
+ revision: {
185
+ ...t.revision,
186
+ [a]: t.revision[a] + p
187
+ }
178
188
  };
179
189
  }
180
- function Ot(t, i, e, n) {
181
- i = i || 0, e = e || t.operations.global.length;
182
- const a = t.operations.global.slice(i, e), s = t.operations.global.slice(0, i), p = t.operations.global.slice(e), l = v(
190
+ function kt(t, e, i) {
191
+ const { scope: a } = e, n = t.operations[a];
192
+ let {
193
+ input: { start: s, end: p }
194
+ } = e;
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(
183
197
  t.initialState,
184
198
  {
185
- global: s.concat(a),
186
- local: t.operations.local
199
+ ...t.operations,
200
+ [a]: r.concat(l)
187
201
  },
188
- n
189
- ), { name: r, state: c } = l, m = s.length, u = s.length ? s[s.length - 1].timestamp : p.length ? p[0].timestamp : (/* @__PURE__ */ new Date()).toISOString();
190
- return v(
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(
191
205
  t.initialState,
192
206
  {
193
- global: [
194
- ...s,
207
+ ...t.operations,
208
+ [a]: [
209
+ ...r,
195
210
  {
196
- ...A(
197
- { name: r, state: c },
198
- a.length
211
+ ...F(
212
+ { name: m, state: v },
213
+ l.length
199
214
  ),
200
- timestamp: u,
201
- index: m,
202
- hash: tt({ state: c }, "global")
215
+ timestamp: D,
216
+ index: d,
217
+ hash: at({ state: v }, "global")
203
218
  },
204
- ...p.map((w, S) => ({
205
- ...w,
206
- index: m + S + 1
219
+ ...c.map((y, ct) => ({
220
+ ...y,
221
+ index: d + ct + 1
207
222
  }))
208
- ],
209
- local: t.operations.local
223
+ ]
210
224
  },
211
- n
225
+ i
212
226
  );
213
227
  }
214
- function _t(t, i) {
228
+ function Et(t, e) {
215
229
  return {
216
230
  ...t,
217
- name: i.name,
218
- state: i.state ?? { global: {}, local: {} }
231
+ name: e.name,
232
+ state: e.state ?? { global: {}, local: {} }
219
233
  };
220
234
  }
221
- const W = "SET_NAME", d = "UNDO", x = "REDO", g = "PRUNE", G = "LOAD_STATE";
222
- function Dt(t) {
235
+ const V = "SET_NAME", g = "UNDO", f = "REDO", h = "PRUNE", X = "LOAD_STATE";
236
+ function Nt(t) {
223
237
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
224
238
  }
225
- function y() {
239
+ function O() {
226
240
  this._types = /* @__PURE__ */ Object.create(null), this._extensions = /* @__PURE__ */ Object.create(null);
227
241
  for (let t = 0; t < arguments.length; t++)
228
242
  this.define(arguments[t]);
229
243
  this.define = this.define.bind(this), this.getType = this.getType.bind(this), this.getExtension = this.getExtension.bind(this);
230
244
  }
231
- y.prototype.define = function(t, i) {
232
- for (let e in t) {
233
- let n = t[e].map(function(a) {
234
- return a.toLowerCase();
245
+ O.prototype.define = function(t, e) {
246
+ for (let i in t) {
247
+ let a = t[i].map(function(n) {
248
+ return n.toLowerCase();
235
249
  });
236
- e = e.toLowerCase();
237
- for (let a = 0; a < n.length; a++) {
238
- const s = n[a];
250
+ i = i.toLowerCase();
251
+ for (let n = 0; n < a.length; n++) {
252
+ const s = a[n];
239
253
  if (s[0] !== "*") {
240
- if (!i && s in this._types)
254
+ if (!e && s in this._types)
241
255
  throw new Error(
242
- 'Attempt to change mapping for "' + s + '" extension from "' + this._types[s] + '" to "' + e + '". Pass `force=true` to allow this, otherwise remove "' + s + '" from the list of extensions for "' + e + '".'
256
+ 'Attempt to change mapping for "' + s + '" extension from "' + this._types[s] + '" to "' + i + '". Pass `force=true` to allow this, otherwise remove "' + s + '" from the list of extensions for "' + i + '".'
243
257
  );
244
- this._types[s] = e;
258
+ this._types[s] = i;
245
259
  }
246
260
  }
247
- if (i || !this._extensions[e]) {
248
- const a = n[0];
249
- this._extensions[e] = a[0] !== "*" ? a : a.substr(1);
261
+ if (e || !this._extensions[i]) {
262
+ const n = a[0];
263
+ this._extensions[i] = n[0] !== "*" ? n : n.substr(1);
250
264
  }
251
265
  }
252
266
  };
253
- y.prototype.getType = function(t) {
267
+ O.prototype.getType = function(t) {
254
268
  t = String(t);
255
- let i = t.replace(/^.*[/\\]/, "").toLowerCase(), e = i.replace(/^.*\./, "").toLowerCase(), n = i.length < t.length;
256
- return (e.length < i.length - 1 || !n) && this._types[e] || null;
269
+ let e = t.replace(/^.*[/\\]/, "").toLowerCase(), i = e.replace(/^.*\./, "").toLowerCase(), a = e.length < t.length;
270
+ return (i.length < e.length - 1 || !a) && this._types[i] || null;
257
271
  };
258
- y.prototype.getExtension = function(t) {
272
+ O.prototype.getExtension = function(t) {
259
273
  return t = /^\s*([^;\s]*)/.test(t) && RegExp.$1, t && this._extensions[t.toLowerCase()] || null;
260
274
  };
261
- var kt = y, Et = { "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"] };
262
- let Nt = kt;
263
- var At = new Nt(Et);
264
- const Tt = /* @__PURE__ */ Dt(At);
265
- function zt(t, i, e) {
266
- const n = gt(t, i);
267
- return O.mkdirSync(t, { recursive: !0 }), new Promise((a, s) => {
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) {
280
+ const a = bt(t, e);
281
+ return k.mkdirSync(t, { recursive: !0 }), new Promise((n, s) => {
268
282
  try {
269
- O.writeFile(n, e, {}, (p) => {
270
- p ? s(p) : a(n);
283
+ k.writeFile(a, i, {}, (p) => {
284
+ p ? s(p) : n(a);
271
285
  });
272
286
  } catch (p) {
273
287
  s(p);
274
288
  }
275
289
  });
276
290
  }
277
- function Q(t) {
278
- return O.readFileSync(t);
279
- }
280
- function Ft(t) {
281
- return new Promise((i, e) => {
282
- xt.get(t, (n) => {
283
- const a = [], s = n.headers["content-type"];
284
- n.on("data", (p) => {
285
- a.push(p);
286
- }), n.on("end", () => {
287
- i({ buffer: Buffer.concat(a), mimeType: s });
291
+ function Y(t) {
292
+ return k.readFileSync(t);
293
+ }
294
+ function It(t) {
295
+ return new Promise((e, i) => {
296
+ ht.get(t, (a) => {
297
+ const n = [], s = a.headers["content-type"];
298
+ a.on("data", (p) => {
299
+ n.push(p);
300
+ }), a.on("end", () => {
301
+ e({ buffer: Buffer.concat(n), mimeType: s });
288
302
  });
289
- }).on("error", (n) => {
290
- e(n);
303
+ }).on("error", (a) => {
304
+ i(a);
291
305
  });
292
306
  });
293
307
  }
294
- const Pt = async (t) => Q(t), j = (t, i = "sha1") => dt.createHash(i).update(t).digest("base64"), V = async (t) => {
295
- const i = new P(), { name: e, revision: n, documentType: a, created: s, lastModified: p } = t, l = {
296
- name: e,
297
- revision: n,
298
- documentType: a,
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 = {
310
+ name: i,
311
+ revision: a,
312
+ documentType: n,
299
313
  created: s,
300
314
  lastModified: p
301
315
  };
302
- return i.file("header.json", JSON.stringify(l, null, 2)), i.file(
316
+ return e.file("header.json", JSON.stringify(l, null, 2)), e.file(
303
317
  "state.json",
304
318
  JSON.stringify(t.initialState || {}, null, 2)
305
- ), i.file("operations.json", JSON.stringify(t.operations, null, 2)), Object.keys(t.attachments).forEach((c) => {
306
- const { data: m, ...u } = t.attachments[c];
307
- i.file(c, m, {
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, {
308
322
  base64: !0,
309
323
  createFolders: !0,
310
- comment: JSON.stringify(u)
324
+ comment: JSON.stringify(m)
311
325
  });
312
- }), i;
313
- }, qt = async (t, i, e, n) => {
314
- const s = await (await V(t)).generateAsync({
326
+ }), e;
327
+ }, Rt = async (t, e, i, a) => {
328
+ const s = await (await tt(t)).generateAsync({
315
329
  type: "uint8array",
316
330
  streamFiles: !0
317
- }), p = n ?? t.name, l = `.${e}.zip`;
318
- return zt(
319
- i,
331
+ }), p = a ?? t.name, l = `.${i}.zip`;
332
+ return qt(
333
+ e,
320
334
  p.endsWith(l) ? p : `${p}${l}`,
321
335
  s
322
336
  );
323
- }, ai = async (t, i) => {
324
- const n = await (await V(t)).generateAsync({ type: "blob" }), a = await i.createWritable();
325
- await a.write(n), await a.close();
326
- }, z = async (t, i) => {
327
- const e = Q(t);
328
- return It(e, i);
329
- }, It = async (t, i) => {
330
- const e = new P();
331
- return await e.loadAsync(t), Mt(e, i);
337
+ }, se = async (t, e) => {
338
+ const a = await (await tt(t)).generateAsync({ type: "blob" }), n = await e.createWritable();
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);
332
346
  };
333
- async function Mt(t, i) {
334
- const e = t.file("state.json");
335
- if (!e)
347
+ async function Ut(t, e) {
348
+ const i = t.file("state.json");
349
+ if (!i)
336
350
  throw new Error("Initial state not found");
337
- const n = await e.async("string"), a = JSON.parse(n), s = t.file("header.json");
351
+ const a = await i.async("string"), n = JSON.parse(a), s = t.file("header.json");
338
352
  let p;
339
353
  s && (p = JSON.parse(await s.async("string")));
340
354
  const l = t.file("operations.json");
@@ -343,10 +357,10 @@ async function Mt(t, i) {
343
357
  const r = JSON.parse(
344
358
  await l.async("string")
345
359
  );
346
- let c = it(
347
- a,
360
+ let c = nt(
361
+ n,
348
362
  r,
349
- i,
363
+ e,
350
364
  void 0,
351
365
  p
352
366
  );
@@ -355,90 +369,89 @@ async function Mt(t, i) {
355
369
  ...p
356
370
  }), c;
357
371
  }
358
- function X(t) {
359
- const i = t.replace(/^.*\./, "") || void 0, e = t.replace(/^.*[/\\]/, "") || void 0;
360
- return { extension: i, fileName: e };
372
+ function et(t) {
373
+ const e = t.replace(/^.*\./, "") || void 0, i = t.replace(/^.*[/\\]/, "") || void 0;
374
+ return { extension: e, fileName: i };
361
375
  }
362
- async function ni(t) {
363
- const { buffer: i, mimeType: e = "application/octet-stream" } = await Ft(t), n = X(t), a = i.toString("base64");
376
+ async function pe(t) {
377
+ const { buffer: e, mimeType: i = "application/octet-stream" } = await It(t), a = et(t), n = e.toString("base64");
364
378
  return {
365
- data: a,
366
- hash: j(a),
367
- mimeType: e,
368
- ...n
379
+ data: n,
380
+ hash: _(n),
381
+ mimeType: i,
382
+ ...a
369
383
  };
370
384
  }
371
- async function oi(t) {
372
- const i = await Pt(t), e = Tt.getType(t) || "application/octet-stream", n = X(t), a = i.toString("base64");
373
- return { data: a, hash: j(a), mimeType: e, ...n };
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 };
374
388
  }
375
- function Rt(t, i) {
376
- return [d, x, g].includes(i.type) ? t.revision : t.revision + 1;
389
+ function Jt(t, e) {
390
+ const i = t.revision[e.scope];
391
+ return [g, f, h].includes(e.type) ? i : i + 1;
377
392
  }
378
- function Lt(t, i) {
393
+ function $t(t, e) {
379
394
  return {
380
395
  ...t,
381
- revision: Rt(t, i),
396
+ revision: {
397
+ ...t.revision,
398
+ [e.scope]: Jt(t, e)
399
+ },
382
400
  lastModified: (/* @__PURE__ */ new Date()).toISOString()
383
401
  };
384
402
  }
385
- function Ut(t, i) {
386
- if ([d, x, g].includes(i.type))
403
+ function Ct(t, e) {
404
+ if ([g, f, h].includes(e.type))
387
405
  return t;
388
- const e = t.operations.global.slice(
406
+ const { scope: i } = e, a = t.operations[i].slice(
389
407
  0,
390
- t.revision
391
- ), n = i.scope || "global", a = n === "global" ? e : t.operations[n];
408
+ t.revision[i]
409
+ );
392
410
  return a.push({
393
- ...i,
411
+ ...e,
394
412
  index: a.length,
395
413
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
396
414
  hash: "",
397
- scope: n
415
+ scope: i
398
416
  }), {
399
417
  ...t,
400
- operations: { ...t.operations, [n]: a }
418
+ operations: { ...t.operations, [i]: a }
401
419
  };
402
420
  }
403
- function Jt(t, i) {
404
- let e = Ut(t, i);
405
- return (!i.scope || i.scope === "global") && (e = Lt(e, i)), e;
406
- }
407
- function $t(t, i, e) {
408
- switch (J().parse(i), i.type) {
409
- case W:
410
- return jt(t, i.input);
411
- case d:
412
- return wt(t, i.input, e);
413
- case x:
414
- return St(t, i.input, e);
421
+ function Bt(t, e) {
422
+ let i = Ct(t, e);
423
+ return i = $t(i, e), i;
424
+ }
425
+ function Zt(t, e, i) {
426
+ switch (B().parse(e), e.type) {
427
+ case V:
428
+ return Ot(t, e.input);
415
429
  case g:
416
- return Ot(
417
- t,
418
- i.input.start,
419
- i.input.end,
420
- e
421
- );
422
- case G:
423
- return _t(t, i.input.state);
430
+ return _t(t, e, i);
431
+ case f:
432
+ return Dt(t, e, i);
433
+ case h:
434
+ return kt(t, e, i);
435
+ case X:
436
+ return Et(t, e.input.state);
424
437
  default:
425
438
  return t;
426
439
  }
427
440
  }
428
- function Y(t, i, e, n) {
429
- let a = t;
430
- return F(i) && (a = $t(a, i, e)), a = Jt(a, i), a = T(a, (s) => {
431
- const p = e(s.state, i, n);
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);
432
445
  if (p)
433
- return rt({
434
- ...a,
446
+ return dt({
447
+ ...n,
435
448
  state: p
436
449
  });
437
- }), T(a, (s) => {
438
- if ([d, x, g].includes(i.type))
450
+ }), P(n, (s) => {
451
+ if ([g, f, h].includes(e.type))
439
452
  return s;
440
- const p = i.scope || "global";
441
- s.operations[p][s.operations[p].length - 1].hash = tt(s, p), !F(i) && i.attachments && i.attachments.forEach((l) => {
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) => {
442
455
  const { hash: r, ...c } = l;
443
456
  s.attachments[r] = {
444
457
  ...c
@@ -446,87 +459,96 @@ function Y(t, i, e, n) {
446
459
  });
447
460
  });
448
461
  }
449
- function F(t) {
450
- return [W, d, x, g, G].includes(t.type);
462
+ function I(t) {
463
+ return [V, g, f, h, X].includes(t.type);
451
464
  }
452
- function f(t, i, e, n, a = "global") {
465
+ function b(t, e, i, a, n = "global") {
453
466
  if (!t)
454
467
  throw new Error("Empty action type");
455
468
  if (typeof t != "string")
456
469
  throw new Error(`Invalid action type: ${t}`);
457
- const s = { type: t, input: i, scope: a };
458
- e && (s.attachments = e);
470
+ const s = { type: t, input: e, scope: n };
471
+ i && (s.attachments = i);
459
472
  try {
460
- n == null || n().parse(s.input);
473
+ a == null || a().parse(s.input);
461
474
  } catch (p) {
462
475
  throw new Error(`Invalid action input: ${p}`);
463
476
  }
464
477
  return s;
465
478
  }
466
- function Ct(t, i = Y) {
467
- return (e, n, a) => i(e, n, t, a);
479
+ function Ht(t, e = it) {
480
+ return (i, a, n) => e(i, a, t, n);
468
481
  }
469
- const Bt = (t, i) => ({
482
+ const Kt = (t, e) => ({
470
483
  name: "",
471
484
  documentType: "",
472
- revision: 0,
485
+ revision: {
486
+ global: 0,
487
+ local: 0
488
+ },
473
489
  created: (/* @__PURE__ */ new Date()).toISOString(),
474
490
  lastModified: (/* @__PURE__ */ new Date()).toISOString(),
475
491
  attachments: {},
476
492
  ...t,
477
- state: (i == null ? void 0 : i(t == null ? void 0 : t.state)) ?? (t == null ? void 0 : t.state) ?? { global: {}, local: {} }
478
- }), Zt = (t, i) => {
479
- const e = Bt(
493
+ 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(
480
496
  t,
481
- i
497
+ e
482
498
  );
483
499
  return {
484
- ...e,
485
- initialState: e,
500
+ ...i,
501
+ initialState: i,
486
502
  operations: { global: [], local: [] }
487
503
  };
488
- }, tt = (t, i = "global") => j(ct(t.state[i])), si = (t, i = 1e3) => {
489
- const e = Math.random() * i;
490
- return j(`${(t ?? /* @__PURE__ */ new Date()).toISOString()}${e}`);
504
+ }, at = (t, e = "global") => _(ut(t.state[e])), ce = (t, e = 1e3) => {
505
+ const i = Math.random() * e;
506
+ return _(`${(t ?? /* @__PURE__ */ new Date()).toISOString()}${i}`);
491
507
  };
492
- function b(t) {
493
- return mt(ut(t, !0));
508
+ function w(t) {
509
+ return xt(gt(t, !0));
494
510
  }
495
- function Ht(t) {
496
- return Object.values(t).flatMap((i) => i).sort(
497
- (i, e) => new Date(i.timestamp).getTime() - new Date(e.timestamp).getTime()
511
+ function Gt(t) {
512
+ return Object.values(t).flatMap((e) => e).sort(
513
+ (e, i) => new Date(e.timestamp).getTime() - new Date(i.timestamp).getTime()
498
514
  );
499
515
  }
500
- function v(t, i, e, n, a, s = Y) {
501
- const p = Ct(e, s);
502
- return it(
516
+ function S(t, e, i, a, n, s = it) {
517
+ const p = Ht(i, s);
518
+ return nt(
503
519
  t,
504
- i,
520
+ e,
505
521
  p,
506
- n,
507
- a
522
+ a,
523
+ n
508
524
  );
509
525
  }
510
- function it(t, i, e, n, a) {
511
- const s = Zt(t), p = {
512
- ...i,
513
- global: i.global.slice(0, a == null ? void 0 : a.revision)
514
- }, l = Ht(p).reduce(
515
- (c, m) => e(c, m, n),
526
+ function nt(t, e, i, a, n) {
527
+ const s = Wt(t), p = Object.keys(e).reduce((c, u) => {
528
+ const m = u;
529
+ return {
530
+ ...c,
531
+ [m]: e[m].slice(0, n == null ? void 0 : n.revision[m])
532
+ };
533
+ }, {}), l = Gt(p).reduce(
534
+ (c, u) => i(c, u, a),
516
535
  s
517
536
  ), r = Object.keys(
518
537
  l.operations
519
538
  ).reduce(
520
- (c, m) => {
521
- const u = m, w = u === "global" && a && a.revision < i.global.length ? i.global.slice(a == null ? void 0 : a.revision) : [];
539
+ (c, u) => {
540
+ const m = u, v = n && n.revision[m] < e[m].length ? e[m].slice(n.revision[m]) : [];
522
541
  return {
523
542
  ...c,
524
- [u]: [
525
- ...l.operations[u].map((S, st) => ({
526
- ...S,
527
- timestamp: i[u][st].timestamp
528
- })),
529
- ...w
543
+ [m]: [
544
+ ...l.operations[m].map((d, D) => {
545
+ var y;
546
+ return {
547
+ ...d,
548
+ timestamp: ((y = e[m][D]) == null ? void 0 : y.timestamp) ?? d.timestamp
549
+ };
550
+ }),
551
+ ...v
530
552
  ]
531
553
  };
532
554
  },
@@ -534,50 +556,63 @@ function it(t, i, e, n, a) {
534
556
  );
535
557
  return { ...l, operations: r };
536
558
  }
537
- const et = (t) => f(
559
+ const ot = (t) => b(
538
560
  "SET_NAME",
539
561
  t,
540
562
  void 0,
541
- E
542
- ), at = (t = 1) => f("UNDO", t, void 0, N), nt = (t = 1) => f("REDO", t, void 0, k), ot = (t, i) => f(
563
+ T
564
+ ), st = (t = 1, e = "global") => b(
565
+ "UNDO",
566
+ t,
567
+ void 0,
568
+ z,
569
+ e
570
+ ), pt = (t = 1, e = "global") => b(
571
+ "REDO",
572
+ t,
573
+ void 0,
574
+ A,
575
+ e
576
+ ), lt = (t, e, i = "global") => b(
543
577
  "PRUNE",
544
- { start: t, end: i },
578
+ { start: t, end: e },
545
579
  void 0,
546
- D
547
- ), A = (t, i) => f(
580
+ N,
581
+ i
582
+ ), F = (t, e) => b(
548
583
  "LOAD_STATE",
549
- { state: t, operations: i },
584
+ { state: t, operations: e },
550
585
  void 0,
551
- _
552
- ), pi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
586
+ E
587
+ ), re = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
553
588
  __proto__: null,
554
- loadState: A,
555
- prune: ot,
556
- redo: nt,
557
- setName: et,
558
- undo: at
589
+ loadState: F,
590
+ prune: lt,
591
+ redo: pt,
592
+ setName: ot,
593
+ undo: st
559
594
  }, Symbol.toStringTag, { value: "Module" }));
560
- class li {
595
+ class me {
561
596
  /**
562
597
  * Constructs a BaseDocument instance with an initial state.
563
598
  * @param reducer - The reducer function that updates the state.
564
599
  * @param document - The initial state of the document.
565
600
  */
566
- constructor(i, e, n) {
567
- h(this, "_document");
568
- h(this, "_reducer");
569
- h(this, "_signalDispatch");
570
- this._reducer = i, this._document = e, this._signalDispatch = n;
601
+ constructor(e, i, a) {
602
+ j(this, "_document");
603
+ j(this, "_reducer");
604
+ j(this, "_signalDispatch");
605
+ this._reducer = e, this._document = i, this._signalDispatch = a;
571
606
  }
572
607
  /**
573
608
  * Dispatches an action to update the state of the document.
574
609
  * @param action - The action to dispatch.
575
610
  * @returns The Document instance.
576
611
  */
577
- dispatch(i) {
612
+ dispatch(e) {
578
613
  return this._document = this._reducer(
579
614
  this._document,
580
- i,
615
+ e,
581
616
  this._signalDispatch
582
617
  ), this;
583
618
  }
@@ -587,15 +622,15 @@ class li {
587
622
  * @param extension - The file extension to use when saving the state.
588
623
  * @returns The file path where the state was saved.
589
624
  */
590
- saveToFile(i, e, n) {
591
- return qt(this._document, i, e, n);
625
+ saveToFile(e, i, a) {
626
+ return Rt(this._document, e, i, a);
592
627
  }
593
628
  /**
594
629
  * Loads the state of the document from a file.
595
630
  * @param path - The file path where the state is stored.
596
631
  */
597
- async loadFromFile(i) {
598
- this._document = await z(i, this._reducer);
632
+ async loadFromFile(e) {
633
+ this._document = await q(e, this._reducer);
599
634
  }
600
635
  /**
601
636
  * Loads the state of the document from a file and returns it.
@@ -603,20 +638,20 @@ class li {
603
638
  * @param reducer - The reducer function that updates the state.
604
639
  * @returns The state of the document.
605
640
  */
606
- static async stateFromFile(i, e) {
607
- return await z(i, e);
641
+ static async stateFromFile(e, i) {
642
+ return await q(e, i);
608
643
  }
609
644
  /**
610
645
  * Gets the current state of the document.
611
646
  */
612
647
  get state() {
613
- return b(this._document.state);
648
+ return w(this._document.state);
614
649
  }
615
650
  /**
616
651
  * Gets the list of operations performed on the document.
617
652
  */
618
653
  get operations() {
619
- return b(this._document.operations);
654
+ return w(this._document.operations);
620
655
  }
621
656
  /**
622
657
  * Gets the name of the document.
@@ -643,101 +678,104 @@ class li {
643
678
  return this._document.lastModified;
644
679
  }
645
680
  /**
646
- * Gets the revision number of the document.
681
+ * Gets the global revision number of the document.
647
682
  */
648
683
  get revision() {
649
- return this._document.revision;
684
+ return this._document.revision.global;
685
+ }
686
+ getRevision(e) {
687
+ return this._document.revision[e];
650
688
  }
651
689
  /**
652
690
  * Gets the initial state of the document.
653
691
  */
654
692
  get initialState() {
655
- return b(this._document.initialState);
693
+ return w(this._document.initialState);
656
694
  }
657
695
  /**
658
696
  * Returns the current document as an object
659
697
  */
660
698
  toDocument() {
661
- return b(this._document);
699
+ return w(this._document);
662
700
  }
663
701
  /**
664
702
  * Gets the attachment associated with the given key.
665
703
  * @param attachment - The key of the attachment to retrieve.
666
704
  */
667
- getAttachment(i) {
668
- return this._document.attachments[i];
705
+ getAttachment(e) {
706
+ return this._document.attachments[e];
669
707
  }
670
708
  /**
671
709
  * Sets the name of the document.
672
710
  * @param name - The new name of the document.
673
711
  */
674
- setName(i) {
675
- return this.dispatch(et(i)), this;
712
+ setName(e) {
713
+ return this.dispatch(ot(e)), this;
676
714
  }
677
715
  /**
678
716
  * Reverts a number of actions from the document.
679
717
  * @param count - The number of actions to revert.
680
718
  */
681
- undo(i) {
682
- return this.dispatch(at(i)), this;
719
+ undo(e) {
720
+ return this.dispatch(st(e)), this;
683
721
  }
684
722
  /**
685
723
  * Reapplies a number of actions to the document.
686
724
  * @param count - The number of actions to reapply.
687
725
  */
688
- redo(i) {
689
- return this.dispatch(nt(i)), this;
726
+ redo(e) {
727
+ return this.dispatch(pt(e)), this;
690
728
  }
691
729
  /**
692
730
  * Removes a range of operations from the document.
693
731
  * @param start - The starting index of the range to remove.
694
732
  * @param end - The ending index of the range to remove.
695
733
  */
696
- prune(i, e) {
697
- return this.dispatch(ot(i, e)), this;
734
+ prune(e, i) {
735
+ return this.dispatch(lt(e, i)), this;
698
736
  }
699
737
  /**
700
738
  * Loads a document state and a set of operations.
701
739
  * @param state - The state to load.
702
740
  * @param operations - The operations to apply to the document.
703
741
  */
704
- loadState(i, e) {
705
- return this.dispatch(A(i, e)), this;
742
+ loadState(e, i) {
743
+ return this.dispatch(F(e, i)), this;
706
744
  }
707
745
  }
708
- function ci(t, i) {
709
- i.forEach((e) => {
710
- Object.getOwnPropertyNames(e.prototype).forEach((n) => {
746
+ function ue(t, e) {
747
+ e.forEach((i) => {
748
+ Object.getOwnPropertyNames(i.prototype).forEach((a) => {
711
749
  Object.defineProperty(
712
750
  t.prototype,
713
- n,
714
- Object.getOwnPropertyDescriptor(e.prototype, n) || /* @__PURE__ */ Object.create(null)
751
+ a,
752
+ Object.getOwnPropertyDescriptor(i.prototype, a) || /* @__PURE__ */ Object.create(null)
715
753
  );
716
754
  });
717
755
  });
718
756
  }
719
757
  export {
720
- li as B,
721
- Bt as a,
722
- Zt as b,
723
- Ct as c,
724
- ai as d,
725
- It as e,
726
- f,
727
- ci as g,
728
- pi as h,
729
- F as i,
730
- V as j,
731
- oi as k,
732
- z as l,
733
- ni as m,
734
- tt as n,
735
- si as o,
736
- it as p,
737
- v as q,
738
- b as r,
739
- qt as s,
740
- Ht as t,
741
- Y as u,
742
- ei as z
758
+ me as B,
759
+ Kt as a,
760
+ Wt as b,
761
+ Ht as c,
762
+ se as d,
763
+ Lt as e,
764
+ b as f,
765
+ ue as g,
766
+ re as h,
767
+ I as i,
768
+ tt as j,
769
+ le as k,
770
+ q as l,
771
+ pe as m,
772
+ at as n,
773
+ ce as o,
774
+ nt as p,
775
+ S as q,
776
+ w as r,
777
+ Rt as s,
778
+ Gt as t,
779
+ it as u,
780
+ oe as z
743
781
  };