document-model 1.0.15 → 1.0.17

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