document-model 1.0.14 → 1.0.16

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