document-model 1.3.0 → 1.5.0

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 (183) hide show
  1. package/dist/browser/cjs/document-model.js +20 -1
  2. package/dist/browser/cjs/document-model.js.map +1 -0
  3. package/dist/browser/cjs/document.js +15 -1
  4. package/dist/browser/cjs/document.js.map +1 -0
  5. package/dist/browser/cjs/index.js +14 -1
  6. package/dist/browser/cjs/index.js.map +1 -0
  7. package/dist/browser/cjs/internal/index-BoiSedJ2.js +2336 -0
  8. package/dist/browser/cjs/internal/index-BoiSedJ2.js.map +1 -0
  9. package/dist/browser/cjs/internal/index-frw-qprx.js +49 -0
  10. package/dist/browser/cjs/internal/index-frw-qprx.js.map +1 -0
  11. package/dist/browser/cjs/internal/object-DldjPOTT.js +4336 -0
  12. package/dist/browser/cjs/internal/object-DldjPOTT.js.map +1 -0
  13. package/dist/browser/es/document-model.js +17 -17
  14. package/dist/browser/es/document-model.js.map +1 -0
  15. package/dist/browser/es/document.js +13 -14
  16. package/dist/browser/es/document.js.map +1 -0
  17. package/dist/browser/es/index.js +12 -14
  18. package/dist/browser/es/index.js.map +1 -0
  19. package/dist/browser/es/internal/index-B7idSyw8.js +2337 -0
  20. package/dist/browser/es/internal/index-B7idSyw8.js.map +1 -0
  21. package/dist/browser/es/internal/index-D2kKzCXD.js +50 -0
  22. package/dist/browser/es/internal/index-D2kKzCXD.js.map +1 -0
  23. package/dist/browser/es/internal/object-I6vKsK3r.js +4337 -0
  24. package/dist/browser/es/internal/object-I6vKsK3r.js.map +1 -0
  25. package/dist/browser/src/document/actions/creators.d.ts +2 -1
  26. package/dist/browser/src/document/actions/index.d.ts +1 -0
  27. package/dist/browser/src/document/actions/types.d.ts +3 -2
  28. package/dist/browser/src/document/object.d.ts +9 -1128
  29. package/dist/browser/src/document/reducer.d.ts +16 -13
  30. package/dist/browser/src/document/schema/types.d.ts +1 -0
  31. package/dist/browser/src/document/schema/zod.d.ts +12 -8
  32. package/dist/browser/src/document/signal.d.ts +1 -0
  33. package/dist/browser/src/document/types.d.ts +9 -6
  34. package/dist/browser/src/document/utils/base.d.ts +7 -5
  35. package/dist/browser/src/document/utils/document-helpers.d.ts +1 -0
  36. package/dist/browser/src/document/utils/file.d.ts +3 -2
  37. package/dist/browser/src/document/utils/validation.d.ts +1 -0
  38. package/dist/browser/src/document-model/custom/reducers/header.d.ts +1 -0
  39. package/dist/browser/src/document-model/custom/reducers/module.d.ts +1 -0
  40. package/dist/browser/src/document-model/custom/reducers/operation-error.d.ts +1 -0
  41. package/dist/browser/src/document-model/custom/reducers/operation-example.d.ts +1 -0
  42. package/dist/browser/src/document-model/custom/reducers/operation.d.ts +1 -0
  43. package/dist/browser/src/document-model/custom/reducers/state.d.ts +1 -0
  44. package/dist/browser/src/document-model/custom/reducers/versioning.d.ts +1 -5
  45. package/dist/browser/src/document-model/custom/utils.d.ts +1 -0
  46. package/dist/browser/src/document-model/gen/actions.d.ts +1 -0
  47. package/dist/browser/src/document-model/gen/document-model.d.ts +2 -1
  48. package/dist/browser/src/document-model/gen/header/actions.d.ts +1 -0
  49. package/dist/browser/src/document-model/gen/header/creators.d.ts +1 -0
  50. package/dist/browser/src/document-model/gen/header/object.d.ts +1 -0
  51. package/dist/browser/src/document-model/gen/header/operations.d.ts +1 -0
  52. package/dist/browser/src/document-model/gen/module/actions.d.ts +1 -0
  53. package/dist/browser/src/document-model/gen/module/creators.d.ts +1 -0
  54. package/dist/browser/src/document-model/gen/module/object.d.ts +1 -0
  55. package/dist/browser/src/document-model/gen/module/operations.d.ts +1 -0
  56. package/dist/browser/src/document-model/gen/object.d.ts +8 -7
  57. package/dist/browser/src/document-model/gen/operation/actions.d.ts +1 -0
  58. package/dist/browser/src/document-model/gen/operation/creators.d.ts +1 -0
  59. package/dist/browser/src/document-model/gen/operation/object.d.ts +1 -0
  60. package/dist/browser/src/document-model/gen/operation/operations.d.ts +1 -0
  61. package/dist/browser/src/document-model/gen/operation-error/actions.d.ts +1 -0
  62. package/dist/browser/src/document-model/gen/operation-error/creators.d.ts +1 -0
  63. package/dist/browser/src/document-model/gen/operation-error/object.d.ts +1 -0
  64. package/dist/browser/src/document-model/gen/operation-error/operations.d.ts +1 -0
  65. package/dist/browser/src/document-model/gen/operation-example/actions.d.ts +1 -0
  66. package/dist/browser/src/document-model/gen/operation-example/creators.d.ts +1 -0
  67. package/dist/browser/src/document-model/gen/operation-example/object.d.ts +1 -0
  68. package/dist/browser/src/document-model/gen/operation-example/operations.d.ts +1 -0
  69. package/dist/browser/src/document-model/gen/reducer.d.ts +2 -1
  70. package/dist/browser/src/document-model/gen/schema/index.d.ts +2 -2
  71. package/dist/browser/src/document-model/gen/schema/types.d.ts +1 -0
  72. package/dist/browser/src/document-model/gen/schema/zod.d.ts +70 -69
  73. package/dist/browser/src/document-model/gen/state/actions.d.ts +1 -0
  74. package/dist/browser/src/document-model/gen/state/creators.d.ts +1 -0
  75. package/dist/browser/src/document-model/gen/state/object.d.ts +1 -0
  76. package/dist/browser/src/document-model/gen/state/operations.d.ts +1 -0
  77. package/dist/browser/src/document-model/gen/types.d.ts +4 -3
  78. package/dist/browser/src/document-model/gen/utils.d.ts +1 -0
  79. package/dist/browser/src/document-model/gen/versioning/actions.d.ts +1 -0
  80. package/dist/browser/src/document-model/gen/versioning/creators.d.ts +1 -0
  81. package/dist/browser/src/document-model/gen/versioning/object.d.ts +1 -0
  82. package/dist/browser/src/document-model/gen/versioning/operations.d.ts +1 -0
  83. package/dist/browser/src/document-model/index.d.ts +62 -65
  84. package/dist/browser/vite.config.d.ts +1 -1
  85. package/dist/browser/vitest.config.d.ts +1 -1
  86. package/dist/node/cjs/document-model.js +24 -1
  87. package/dist/node/cjs/document-model.js.map +1 -0
  88. package/dist/node/cjs/document.js +15 -1
  89. package/dist/node/cjs/document.js.map +1 -0
  90. package/dist/node/cjs/index.js +14 -1
  91. package/dist/node/cjs/index.js.map +1 -0
  92. package/dist/node/cjs/internal/index-RX6RcsNg.js +49 -0
  93. package/dist/node/cjs/internal/index-RX6RcsNg.js.map +1 -0
  94. package/dist/node/cjs/internal/index-WVYoLyly.js +2340 -0
  95. package/dist/node/cjs/internal/index-WVYoLyly.js.map +1 -0
  96. package/dist/node/cjs/internal/object-7GplcYr4.js +2338 -0
  97. package/dist/node/cjs/internal/object-7GplcYr4.js.map +1 -0
  98. package/dist/node/es/document-model.js +16 -16
  99. package/dist/node/es/document-model.js.map +1 -0
  100. package/dist/node/es/document.js +13 -18
  101. package/dist/node/es/document.js.map +1 -0
  102. package/dist/node/es/index.js +12 -18
  103. package/dist/node/es/index.js.map +1 -0
  104. package/dist/node/es/internal/index-BFRJ-0Rp.js +2341 -0
  105. package/dist/node/es/internal/index-BFRJ-0Rp.js.map +1 -0
  106. package/dist/node/es/internal/index-NWZKlhKu.js +50 -0
  107. package/dist/node/es/internal/index-NWZKlhKu.js.map +1 -0
  108. package/dist/node/es/internal/object-Cu2Dz-iF.js +2339 -0
  109. package/dist/node/es/internal/object-Cu2Dz-iF.js.map +1 -0
  110. package/dist/node/src/document/actions/creators.d.ts +2 -1
  111. package/dist/node/src/document/actions/index.d.ts +1 -0
  112. package/dist/node/src/document/actions/types.d.ts +3 -2
  113. package/dist/node/src/document/object.d.ts +9 -1128
  114. package/dist/node/src/document/reducer.d.ts +16 -13
  115. package/dist/node/src/document/schema/types.d.ts +1 -0
  116. package/dist/node/src/document/schema/zod.d.ts +12 -8
  117. package/dist/node/src/document/signal.d.ts +1 -0
  118. package/dist/node/src/document/types.d.ts +9 -6
  119. package/dist/node/src/document/utils/base.d.ts +7 -5
  120. package/dist/node/src/document/utils/document-helpers.d.ts +1 -0
  121. package/dist/node/src/document/utils/file.d.ts +3 -2
  122. package/dist/node/src/document/utils/validation.d.ts +1 -0
  123. package/dist/node/src/document-model/custom/reducers/header.d.ts +1 -0
  124. package/dist/node/src/document-model/custom/reducers/module.d.ts +1 -0
  125. package/dist/node/src/document-model/custom/reducers/operation-error.d.ts +1 -0
  126. package/dist/node/src/document-model/custom/reducers/operation-example.d.ts +1 -0
  127. package/dist/node/src/document-model/custom/reducers/operation.d.ts +1 -0
  128. package/dist/node/src/document-model/custom/reducers/state.d.ts +1 -0
  129. package/dist/node/src/document-model/custom/reducers/versioning.d.ts +1 -5
  130. package/dist/node/src/document-model/custom/utils.d.ts +1 -0
  131. package/dist/node/src/document-model/gen/actions.d.ts +1 -0
  132. package/dist/node/src/document-model/gen/document-model.d.ts +2 -1
  133. package/dist/node/src/document-model/gen/header/actions.d.ts +1 -0
  134. package/dist/node/src/document-model/gen/header/creators.d.ts +1 -0
  135. package/dist/node/src/document-model/gen/header/object.d.ts +1 -0
  136. package/dist/node/src/document-model/gen/header/operations.d.ts +1 -0
  137. package/dist/node/src/document-model/gen/module/actions.d.ts +1 -0
  138. package/dist/node/src/document-model/gen/module/creators.d.ts +1 -0
  139. package/dist/node/src/document-model/gen/module/object.d.ts +1 -0
  140. package/dist/node/src/document-model/gen/module/operations.d.ts +1 -0
  141. package/dist/node/src/document-model/gen/object.d.ts +8 -7
  142. package/dist/node/src/document-model/gen/operation/actions.d.ts +1 -0
  143. package/dist/node/src/document-model/gen/operation/creators.d.ts +1 -0
  144. package/dist/node/src/document-model/gen/operation/object.d.ts +1 -0
  145. package/dist/node/src/document-model/gen/operation/operations.d.ts +1 -0
  146. package/dist/node/src/document-model/gen/operation-error/actions.d.ts +1 -0
  147. package/dist/node/src/document-model/gen/operation-error/creators.d.ts +1 -0
  148. package/dist/node/src/document-model/gen/operation-error/object.d.ts +1 -0
  149. package/dist/node/src/document-model/gen/operation-error/operations.d.ts +1 -0
  150. package/dist/node/src/document-model/gen/operation-example/actions.d.ts +1 -0
  151. package/dist/node/src/document-model/gen/operation-example/creators.d.ts +1 -0
  152. package/dist/node/src/document-model/gen/operation-example/object.d.ts +1 -0
  153. package/dist/node/src/document-model/gen/operation-example/operations.d.ts +1 -0
  154. package/dist/node/src/document-model/gen/reducer.d.ts +2 -1
  155. package/dist/node/src/document-model/gen/schema/index.d.ts +2 -2
  156. package/dist/node/src/document-model/gen/schema/types.d.ts +1 -0
  157. package/dist/node/src/document-model/gen/schema/zod.d.ts +70 -69
  158. package/dist/node/src/document-model/gen/state/actions.d.ts +1 -0
  159. package/dist/node/src/document-model/gen/state/creators.d.ts +1 -0
  160. package/dist/node/src/document-model/gen/state/object.d.ts +1 -0
  161. package/dist/node/src/document-model/gen/state/operations.d.ts +1 -0
  162. package/dist/node/src/document-model/gen/types.d.ts +4 -3
  163. package/dist/node/src/document-model/gen/utils.d.ts +1 -0
  164. package/dist/node/src/document-model/gen/versioning/actions.d.ts +1 -0
  165. package/dist/node/src/document-model/gen/versioning/creators.d.ts +1 -0
  166. package/dist/node/src/document-model/gen/versioning/object.d.ts +1 -0
  167. package/dist/node/src/document-model/gen/versioning/operations.d.ts +1 -0
  168. package/dist/node/src/document-model/index.d.ts +62 -65
  169. package/dist/node/vite.config.d.ts +1 -1
  170. package/dist/node/vitest.config.d.ts +1 -1
  171. package/package.json +5 -4
  172. package/dist/browser/cjs/internal/index-BtACFrMg.js +0 -22
  173. package/dist/browser/cjs/internal/index-BtOQeyI_.js +0 -1
  174. package/dist/browser/cjs/internal/object-eLa06mce.js +0 -25
  175. package/dist/browser/es/internal/index-CZutz9-u.js +0 -2104
  176. package/dist/browser/es/internal/index-DPuk-_bv.js +0 -46
  177. package/dist/browser/es/internal/object-Cxp6e1kN.js +0 -2838
  178. package/dist/node/cjs/internal/index-C2-dv_r8.js +0 -1
  179. package/dist/node/cjs/internal/index-DPBQS8BC.js +0 -22
  180. package/dist/node/cjs/internal/object-_P8Ctu09.js +0 -20
  181. package/dist/node/es/internal/index-CpzdJD_a.js +0 -2108
  182. package/dist/node/es/internal/index-O3hyddph.js +0 -46
  183. package/dist/node/es/internal/object-BegIqJta.js +0 -1736
@@ -1,1736 +0,0 @@
1
- var fe = Object.defineProperty;
2
- var de = (t, e, n) => e in t ? fe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var rt = (t, e, n) => (de(t, typeof e != "symbol" ? e + "" : e, n), n);
4
- import { produce as lt, castDraft as ct, castImmutable as ge, freeze as he } from "immer";
5
- import { z as d } from "zod";
6
- import vt from "jszip";
7
- import xe from "crypto";
8
- import dt from "fs";
9
- import ye from "https";
10
- import { join as be } from "path";
11
- const It = (t) => t != null, we = d.any().refine((t) => It(t)), Nt = d.enum(["LOAD_STATE"]), At = d.enum(["PRUNE"]), Pt = d.enum(["REDO"]), Mt = d.enum(["SET_NAME"]), Rt = d.enum(["UNDO"]);
12
- function Oe() {
13
- return d.object({
14
- __typename: d.literal("Action").optional(),
15
- type: d.string()
16
- });
17
- }
18
- function tt() {
19
- return d.literal("global").or(d.literal("local"));
20
- }
21
- function zt() {
22
- return d.union([
23
- Ut(),
24
- Ft(),
25
- Lt(),
26
- qt(),
27
- Jt()
28
- ]);
29
- }
30
- function Se() {
31
- return d.object({
32
- __typename: d.literal("DocumentFile").optional(),
33
- data: d.string(),
34
- extension: d.string().nullable(),
35
- fileName: d.string().nullable(),
36
- mimeType: d.string()
37
- });
38
- }
39
- function Ut() {
40
- return d.object({
41
- input: d.lazy(() => yt()),
42
- type: Nt,
43
- scope: tt()
44
- });
45
- }
46
- function yt() {
47
- return d.object({
48
- operations: d.number(),
49
- state: d.lazy(() => Ct())
50
- });
51
- }
52
- function Ct() {
53
- return d.object({
54
- data: d.unknown().nullish(),
55
- name: d.string()
56
- });
57
- }
58
- function je() {
59
- return d.object({
60
- __typename: d.literal("Operation").optional(),
61
- hash: d.string(),
62
- index: d.number(),
63
- timestamp: d.string().datetime(),
64
- type: d.string()
65
- });
66
- }
67
- function Ft() {
68
- return d.object({
69
- input: d.lazy(() => bt()),
70
- type: At,
71
- scope: tt()
72
- });
73
- }
74
- function bt() {
75
- return d.object({
76
- end: d.number().nullish(),
77
- start: d.number().nullish()
78
- });
79
- }
80
- const wt = d.number;
81
- function Lt() {
82
- return d.object({
83
- input: wt(),
84
- type: Pt,
85
- scope: tt()
86
- });
87
- }
88
- const Ot = d.string;
89
- function qt() {
90
- return d.object({
91
- input: Ot(),
92
- type: Mt,
93
- scope: d.literal("global")
94
- });
95
- }
96
- function Ee() {
97
- return d.object({
98
- __typename: d.literal("SetNameOperation").optional(),
99
- hash: d.string(),
100
- index: d.number(),
101
- input: d.string(),
102
- timestamp: d.string().datetime(),
103
- type: d.string()
104
- });
105
- }
106
- const St = d.number;
107
- function Jt() {
108
- return d.object({
109
- input: St(),
110
- type: Rt,
111
- scope: tt()
112
- });
113
- }
114
- const bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
115
- __proto__: null,
116
- ActionSchema: Oe,
117
- BaseActionSchema: zt,
118
- DocumentFileSchema: Se,
119
- LoadStateActionInputSchema: yt,
120
- LoadStateActionSchema: Ut,
121
- LoadStateActionStateInputSchema: Ct,
122
- Load_StateSchema: Nt,
123
- OperationSchema: je,
124
- OperationScopeSchema: tt,
125
- PruneActionInputSchema: bt,
126
- PruneActionSchema: Ft,
127
- PruneSchema: At,
128
- RedoActionInputSchema: wt,
129
- RedoActionSchema: Lt,
130
- RedoSchema: Pt,
131
- SetNameActionInputSchema: Ot,
132
- SetNameActionSchema: qt,
133
- SetNameOperationSchema: Ee,
134
- Set_NameSchema: Mt,
135
- UndoActionInputSchema: St,
136
- UndoActionSchema: Jt,
137
- UndoSchema: Rt,
138
- definedNonNullAnySchema: we,
139
- isDefinedNonNullAny: It
140
- }, Symbol.toStringTag, { value: "Module" }));
141
- function $e(t) {
142
- return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
143
- }
144
- var gt = { exports: {} };
145
- (function(t, e) {
146
- const { hasOwnProperty: n } = Object.prototype, i = C();
147
- i.configure = C, i.stringify = i, i.default = i, e.stringify = i, e.configure = C, t.exports = i;
148
- const o = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;
149
- function a(c) {
150
- return c.length < 5e3 && !o.test(c) ? `"${c}"` : JSON.stringify(c);
151
- }
152
- function r(c) {
153
- if (c.length > 200)
154
- return c.sort();
155
- for (let l = 1; l < c.length; l++) {
156
- const f = c[l];
157
- let k = l;
158
- for (; k !== 0 && c[k - 1] > f; )
159
- c[k] = c[k - 1], k--;
160
- c[k] = f;
161
- }
162
- return c;
163
- }
164
- const p = Object.getOwnPropertyDescriptor(
165
- Object.getPrototypeOf(
166
- Object.getPrototypeOf(
167
- new Int8Array()
168
- )
169
- ),
170
- Symbol.toStringTag
171
- ).get;
172
- function m(c) {
173
- return p.call(c) !== void 0 && c.length !== 0;
174
- }
175
- function u(c, l, f) {
176
- c.length < f && (f = c.length);
177
- const k = l === "," ? "" : " ";
178
- let F = `"0":${k}${c[0]}`;
179
- for (let R = 1; R < f; R++)
180
- F += `${l}"${R}":${k}${c[R]}`;
181
- return F;
182
- }
183
- function h(c) {
184
- if (n.call(c, "circularValue")) {
185
- const l = c.circularValue;
186
- if (typeof l == "string")
187
- return `"${l}"`;
188
- if (l == null)
189
- return l;
190
- if (l === Error || l === TypeError)
191
- return {
192
- toString() {
193
- throw new TypeError("Converting circular structure to JSON");
194
- }
195
- };
196
- throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined');
197
- }
198
- return '"[Circular]"';
199
- }
200
- function b(c, l) {
201
- let f;
202
- if (n.call(c, l) && (f = c[l], typeof f != "boolean"))
203
- throw new TypeError(`The "${l}" argument must be of type boolean`);
204
- return f === void 0 ? !0 : f;
205
- }
206
- function w(c, l) {
207
- let f;
208
- if (n.call(c, l)) {
209
- if (f = c[l], typeof f != "number")
210
- throw new TypeError(`The "${l}" argument must be of type number`);
211
- if (!Number.isInteger(f))
212
- throw new TypeError(`The "${l}" argument must be an integer`);
213
- if (f < 1)
214
- throw new RangeError(`The "${l}" argument must be >= 1`);
215
- }
216
- return f === void 0 ? 1 / 0 : f;
217
- }
218
- function I(c) {
219
- return c === 1 ? "1 item" : `${c} items`;
220
- }
221
- function $(c) {
222
- const l = /* @__PURE__ */ new Set();
223
- for (const f of c)
224
- (typeof f == "string" || typeof f == "number") && l.add(String(f));
225
- return l;
226
- }
227
- function M(c) {
228
- if (n.call(c, "strict")) {
229
- const l = c.strict;
230
- if (typeof l != "boolean")
231
- throw new TypeError('The "strict" argument must be of type boolean');
232
- if (l)
233
- return (f) => {
234
- let k = `Object can not safely be stringified. Received type ${typeof f}`;
235
- throw typeof f != "function" && (k += ` (${f.toString()})`), new Error(k);
236
- };
237
- }
238
- }
239
- function C(c) {
240
- c = { ...c };
241
- const l = M(c);
242
- l && (c.bigint === void 0 && (c.bigint = !1), "circularValue" in c || (c.circularValue = Error));
243
- const f = h(c), k = b(c, "bigint"), F = b(c, "deterministic"), R = w(c, "maximumDepth"), T = w(c, "maximumBreadth");
244
- function it(P, s, g, O, y, j) {
245
- let x = s[P];
246
- switch (typeof x == "object" && x !== null && typeof x.toJSON == "function" && (x = x.toJSON(P)), x = O.call(s, P, x), typeof x) {
247
- case "string":
248
- return a(x);
249
- case "object": {
250
- if (x === null)
251
- return "null";
252
- if (g.indexOf(x) !== -1)
253
- return f;
254
- let S = "", D = ",";
255
- const _ = j;
256
- if (Array.isArray(x)) {
257
- if (x.length === 0)
258
- return "[]";
259
- if (R < g.length + 1)
260
- return '"[Array]"';
261
- g.push(x), y !== "" && (j += y, S += `
262
- ${j}`, D = `,
263
- ${j}`);
264
- const U = Math.min(x.length, T);
265
- let J = 0;
266
- for (; J < U - 1; J++) {
267
- const st = it(String(J), x, g, O, y, j);
268
- S += st !== void 0 ? st : "null", S += D;
269
- }
270
- const V = it(String(J), x, g, O, y, j);
271
- if (S += V !== void 0 ? V : "null", x.length - 1 > T) {
272
- const st = x.length - T - 1;
273
- S += `${D}"... ${I(st)} not stringified"`;
274
- }
275
- return y !== "" && (S += `
276
- ${_}`), g.pop(), `[${S}]`;
277
- }
278
- let v = Object.keys(x);
279
- const N = v.length;
280
- if (N === 0)
281
- return "{}";
282
- if (R < g.length + 1)
283
- return '"[Object]"';
284
- let E = "", z = "";
285
- y !== "" && (j += y, D = `,
286
- ${j}`, E = " ");
287
- const q = Math.min(N, T);
288
- F && !m(x) && (v = r(v)), g.push(x);
289
- for (let U = 0; U < q; U++) {
290
- const J = v[U], V = it(J, x, g, O, y, j);
291
- V !== void 0 && (S += `${z}${a(J)}:${E}${V}`, z = D);
292
- }
293
- if (N > T) {
294
- const U = N - T;
295
- S += `${z}"...":${E}"${I(U)} not stringified"`, z = D;
296
- }
297
- return y !== "" && z.length > 1 && (S = `
298
- ${j}${S}
299
- ${_}`), g.pop(), `{${S}}`;
300
- }
301
- case "number":
302
- return isFinite(x) ? String(x) : l ? l(x) : "null";
303
- case "boolean":
304
- return x === !0 ? "true" : "false";
305
- case "undefined":
306
- return;
307
- case "bigint":
308
- if (k)
309
- return String(x);
310
- default:
311
- return l ? l(x) : void 0;
312
- }
313
- }
314
- function ot(P, s, g, O, y, j) {
315
- switch (typeof s == "object" && s !== null && typeof s.toJSON == "function" && (s = s.toJSON(P)), typeof s) {
316
- case "string":
317
- return a(s);
318
- case "object": {
319
- if (s === null)
320
- return "null";
321
- if (g.indexOf(s) !== -1)
322
- return f;
323
- const x = j;
324
- let S = "", D = ",";
325
- if (Array.isArray(s)) {
326
- if (s.length === 0)
327
- return "[]";
328
- if (R < g.length + 1)
329
- return '"[Array]"';
330
- g.push(s), y !== "" && (j += y, S += `
331
- ${j}`, D = `,
332
- ${j}`);
333
- const N = Math.min(s.length, T);
334
- let E = 0;
335
- for (; E < N - 1; E++) {
336
- const q = ot(String(E), s[E], g, O, y, j);
337
- S += q !== void 0 ? q : "null", S += D;
338
- }
339
- const z = ot(String(E), s[E], g, O, y, j);
340
- if (S += z !== void 0 ? z : "null", s.length - 1 > T) {
341
- const q = s.length - T - 1;
342
- S += `${D}"... ${I(q)} not stringified"`;
343
- }
344
- return y !== "" && (S += `
345
- ${x}`), g.pop(), `[${S}]`;
346
- }
347
- g.push(s);
348
- let _ = "";
349
- y !== "" && (j += y, D = `,
350
- ${j}`, _ = " ");
351
- let v = "";
352
- for (const N of O) {
353
- const E = ot(N, s[N], g, O, y, j);
354
- E !== void 0 && (S += `${v}${a(N)}:${_}${E}`, v = D);
355
- }
356
- return y !== "" && v.length > 1 && (S = `
357
- ${j}${S}
358
- ${x}`), g.pop(), `{${S}}`;
359
- }
360
- case "number":
361
- return isFinite(s) ? String(s) : l ? l(s) : "null";
362
- case "boolean":
363
- return s === !0 ? "true" : "false";
364
- case "undefined":
365
- return;
366
- case "bigint":
367
- if (k)
368
- return String(s);
369
- default:
370
- return l ? l(s) : void 0;
371
- }
372
- }
373
- function Z(P, s, g, O, y) {
374
- switch (typeof s) {
375
- case "string":
376
- return a(s);
377
- case "object": {
378
- if (s === null)
379
- return "null";
380
- if (typeof s.toJSON == "function") {
381
- if (s = s.toJSON(P), typeof s != "object")
382
- return Z(P, s, g, O, y);
383
- if (s === null)
384
- return "null";
385
- }
386
- if (g.indexOf(s) !== -1)
387
- return f;
388
- const j = y;
389
- if (Array.isArray(s)) {
390
- if (s.length === 0)
391
- return "[]";
392
- if (R < g.length + 1)
393
- return '"[Array]"';
394
- g.push(s), y += O;
395
- let E = `
396
- ${y}`;
397
- const z = `,
398
- ${y}`, q = Math.min(s.length, T);
399
- let U = 0;
400
- for (; U < q - 1; U++) {
401
- const V = Z(String(U), s[U], g, O, y);
402
- E += V !== void 0 ? V : "null", E += z;
403
- }
404
- const J = Z(String(U), s[U], g, O, y);
405
- if (E += J !== void 0 ? J : "null", s.length - 1 > T) {
406
- const V = s.length - T - 1;
407
- E += `${z}"... ${I(V)} not stringified"`;
408
- }
409
- return E += `
410
- ${j}`, g.pop(), `[${E}]`;
411
- }
412
- let x = Object.keys(s);
413
- const S = x.length;
414
- if (S === 0)
415
- return "{}";
416
- if (R < g.length + 1)
417
- return '"[Object]"';
418
- y += O;
419
- const D = `,
420
- ${y}`;
421
- let _ = "", v = "", N = Math.min(S, T);
422
- m(s) && (_ += u(s, D, T), x = x.slice(s.length), N -= s.length, v = D), F && (x = r(x)), g.push(s);
423
- for (let E = 0; E < N; E++) {
424
- const z = x[E], q = Z(z, s[z], g, O, y);
425
- q !== void 0 && (_ += `${v}${a(z)}: ${q}`, v = D);
426
- }
427
- if (S > T) {
428
- const E = S - T;
429
- _ += `${v}"...": "${I(E)} not stringified"`, v = D;
430
- }
431
- return v !== "" && (_ = `
432
- ${y}${_}
433
- ${j}`), g.pop(), `{${_}}`;
434
- }
435
- case "number":
436
- return isFinite(s) ? String(s) : l ? l(s) : "null";
437
- case "boolean":
438
- return s === !0 ? "true" : "false";
439
- case "undefined":
440
- return;
441
- case "bigint":
442
- if (k)
443
- return String(s);
444
- default:
445
- return l ? l(s) : void 0;
446
- }
447
- }
448
- function Q(P, s, g) {
449
- switch (typeof s) {
450
- case "string":
451
- return a(s);
452
- case "object": {
453
- if (s === null)
454
- return "null";
455
- if (typeof s.toJSON == "function") {
456
- if (s = s.toJSON(P), typeof s != "object")
457
- return Q(P, s, g);
458
- if (s === null)
459
- return "null";
460
- }
461
- if (g.indexOf(s) !== -1)
462
- return f;
463
- let O = "";
464
- if (Array.isArray(s)) {
465
- if (s.length === 0)
466
- return "[]";
467
- if (R < g.length + 1)
468
- return '"[Array]"';
469
- g.push(s);
470
- const D = Math.min(s.length, T);
471
- let _ = 0;
472
- for (; _ < D - 1; _++) {
473
- const N = Q(String(_), s[_], g);
474
- O += N !== void 0 ? N : "null", O += ",";
475
- }
476
- const v = Q(String(_), s[_], g);
477
- if (O += v !== void 0 ? v : "null", s.length - 1 > T) {
478
- const N = s.length - T - 1;
479
- O += `,"... ${I(N)} not stringified"`;
480
- }
481
- return g.pop(), `[${O}]`;
482
- }
483
- let y = Object.keys(s);
484
- const j = y.length;
485
- if (j === 0)
486
- return "{}";
487
- if (R < g.length + 1)
488
- return '"[Object]"';
489
- let x = "", S = Math.min(j, T);
490
- m(s) && (O += u(s, ",", T), y = y.slice(s.length), S -= s.length, x = ","), F && (y = r(y)), g.push(s);
491
- for (let D = 0; D < S; D++) {
492
- const _ = y[D], v = Q(_, s[_], g);
493
- v !== void 0 && (O += `${x}${a(_)}:${v}`, x = ",");
494
- }
495
- if (j > T) {
496
- const D = j - T;
497
- O += `${x}"...":"${I(D)} not stringified"`;
498
- }
499
- return g.pop(), `{${O}}`;
500
- }
501
- case "number":
502
- return isFinite(s) ? String(s) : l ? l(s) : "null";
503
- case "boolean":
504
- return s === !0 ? "true" : "false";
505
- case "undefined":
506
- return;
507
- case "bigint":
508
- if (k)
509
- return String(s);
510
- default:
511
- return l ? l(s) : void 0;
512
- }
513
- }
514
- function ue(P, s, g) {
515
- if (arguments.length > 1) {
516
- let O = "";
517
- if (typeof g == "number" ? O = " ".repeat(Math.min(g, 10)) : typeof g == "string" && (O = g.slice(0, 10)), s != null) {
518
- if (typeof s == "function")
519
- return it("", { "": P }, [], s, O, "");
520
- if (Array.isArray(s))
521
- return ot("", P, [], $(s), O, "");
522
- }
523
- if (O.length !== 0)
524
- return Z("", P, [], O, "");
525
- }
526
- return Q("", P, []);
527
- }
528
- return ue;
529
- }
530
- })(gt, gt.exports);
531
- var De = gt.exports;
532
- const W = /* @__PURE__ */ $e(De);
533
- W.configure;
534
- let at;
535
- const ke = new Uint8Array(16);
536
- function Te() {
537
- if (!at && (at = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !at))
538
- throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
539
- return at(ke);
540
- }
541
- const A = [];
542
- for (let t = 0; t < 256; ++t)
543
- A.push((t + 256).toString(16).slice(1));
544
- function _e(t, e = 0) {
545
- return A[t[e + 0]] + A[t[e + 1]] + A[t[e + 2]] + A[t[e + 3]] + "-" + A[t[e + 4]] + A[t[e + 5]] + "-" + A[t[e + 6]] + A[t[e + 7]] + "-" + A[t[e + 8]] + A[t[e + 9]] + "-" + A[t[e + 10]] + A[t[e + 11]] + A[t[e + 12]] + A[t[e + 13]] + A[t[e + 14]] + A[t[e + 15]];
546
- }
547
- const ve = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), kt = {
548
- randomUUID: ve
549
- };
550
- function Ie(t, e, n) {
551
- if (kt.randomUUID && !e && !t)
552
- return kt.randomUUID();
553
- t = t || {};
554
- const i = t.random || (t.rng || Te)();
555
- if (i[6] = i[6] & 15 | 64, i[8] = i[8] & 63 | 128, e) {
556
- n = n || 0;
557
- for (let o = 0; o < 16; ++o)
558
- e[n + o] = i[o];
559
- return e;
560
- }
561
- return _e(i);
562
- }
563
- function Ne(t, e) {
564
- return { ...t, name: e };
565
- }
566
- function Ae(t, e, n) {
567
- const { scope: i, input: o } = e;
568
- return lt({
569
- document: t,
570
- action: e,
571
- skip: n
572
- }, (r) => {
573
- if (r.document.operations[i].length < 1)
574
- throw new Error(
575
- `Cannot undo: no operations in history for scope "${i}"`
576
- );
577
- if (o < 1)
578
- throw new Error(
579
- "Invalid UNDO action: input value must be greater than 0"
580
- );
581
- if (r.skip > 0)
582
- throw new Error(
583
- "Cannot undo: skip value from reducer cannot be used with UNDO action"
584
- );
585
- const p = r.document.operations[i].at(-1), m = p && p.type === "NOOP" && p.skip > 0;
586
- if (r.skip += o, m) {
587
- r.skip += p.skip;
588
- const w = r.document.operations[i][r.document.operations[i].length - 2];
589
- w && p.index - w.index === 1 && r.document.operations[i].pop();
590
- }
591
- if (r.document.operations[i].length < r.skip)
592
- throw new Error(
593
- "Cannot undo: you can't undo more operations than the ones in the scope history"
594
- );
595
- const u = r.document.operations[i].length - 1;
596
- let h = o, b = m ? u - p.skip : u;
597
- for (; h > 0 && b >= 0; ) {
598
- const w = r.document.operations[i][b];
599
- if (!w) {
600
- h--, b--;
601
- continue;
602
- }
603
- w.type === "NOOP" && w.skip > 0 ? (b = b - (w.skip + 1), r.skip += w.skip + 1) : (r.document.clipboard.push({ ...w }), h--, b--);
604
- }
605
- r.action = me(i);
606
- });
607
- }
608
- function Pe(t, e, n) {
609
- const { scope: i, input: o } = e;
610
- return lt({
611
- document: t,
612
- action: e,
613
- skip: n
614
- }, (r) => {
615
- if (r.skip > 0)
616
- throw new Error(
617
- "Cannot redo: skip value from reducer cannot be used with REDO action"
618
- );
619
- if (o > 1)
620
- throw new Error(
621
- "Cannot redo: you can only redo one operation at a time"
622
- );
623
- if (o < 1)
624
- throw new Error("Invalid REDO action: invalid redo input value");
625
- if (r.document.clipboard.length < 1)
626
- throw new Error("Cannot redo: no operations in the clipboard");
627
- const p = r.document.clipboard.findLastIndex(
628
- (u) => u.scope === i
629
- );
630
- if (p < 0)
631
- throw new Error(
632
- `Cannot redo: no operations in clipboard for scope "${i}"`
633
- );
634
- const m = r.document.clipboard.splice(p, 1)[0];
635
- r.action = ct({
636
- type: m.type,
637
- scope: m.scope,
638
- input: m.input
639
- });
640
- });
641
- }
642
- function Me(t, e, n) {
643
- const { scope: i } = e, o = t.operations[i];
644
- let {
645
- input: { start: a, end: r }
646
- } = e;
647
- a = a || 0, r = r || o.length;
648
- const p = o.slice(a, r), m = o.slice(0, a), u = o.slice(r), h = xt(
649
- t.initialState,
650
- {
651
- ...t.operations,
652
- [i]: m.concat(p)
653
- },
654
- n
655
- ), { name: b, state: w } = h, I = m.length, $ = m.length ? m[m.length - 1].timestamp : u.length ? u[0].timestamp : (/* @__PURE__ */ new Date()).toISOString();
656
- return xt(
657
- t.initialState,
658
- {
659
- ...t.operations,
660
- [i]: [
661
- ...m,
662
- {
663
- ...Dt(
664
- { name: b, state: w },
665
- p.length
666
- ),
667
- timestamp: $,
668
- index: I,
669
- hash: $t({ state: w }, "global")
670
- },
671
- ...u.map((M, C) => ({
672
- ...M,
673
- index: I + C + 1
674
- }))
675
- ]
676
- },
677
- n
678
- );
679
- }
680
- function Re(t, e) {
681
- return {
682
- ...t,
683
- name: e.name,
684
- state: e.state ?? { global: {}, local: {} }
685
- };
686
- }
687
- const Vt = "SET_NAME", et = "UNDO", nt = "REDO", mt = "PRUNE", Ht = "LOAD_STATE", ze = "NOOP", Xt = { "application/andrew-inset": ["ez"], "application/appinstaller": ["appinstaller"], "application/applixware": ["aw"], "application/appx": ["appx"], "application/appxbundle": ["appxbundle"], "application/atom+xml": ["atom"], "application/atomcat+xml": ["atomcat"], "application/atomdeleted+xml": ["atomdeleted"], "application/atomsvc+xml": ["atomsvc"], "application/atsc-dwd+xml": ["dwd"], "application/atsc-held+xml": ["held"], "application/atsc-rsat+xml": ["rsat"], "application/automationml-aml+xml": ["aml"], "application/automationml-amlx+zip": ["amlx"], "application/bdoc": ["bdoc"], "application/calendar+xml": ["xcs"], "application/ccxml+xml": ["ccxml"], "application/cdfx+xml": ["cdfx"], "application/cdmi-capability": ["cdmia"], "application/cdmi-container": ["cdmic"], "application/cdmi-domain": ["cdmid"], "application/cdmi-object": ["cdmio"], "application/cdmi-queue": ["cdmiq"], "application/cpl+xml": ["cpl"], "application/cu-seeme": ["cu"], "application/cwl": ["cwl"], "application/dash+xml": ["mpd"], "application/dash-patch+xml": ["mpp"], "application/davmount+xml": ["davmount"], "application/docbook+xml": ["dbk"], "application/dssc+der": ["dssc"], "application/dssc+xml": ["xdssc"], "application/ecmascript": ["ecma"], "application/emma+xml": ["emma"], "application/emotionml+xml": ["emotionml"], "application/epub+zip": ["epub"], "application/exi": ["exi"], "application/express": ["exp"], "application/fdf": ["fdf"], "application/fdt+xml": ["fdt"], "application/font-tdpfr": ["pfr"], "application/geo+json": ["geojson"], "application/gml+xml": ["gml"], "application/gpx+xml": ["gpx"], "application/gxf": ["gxf"], "application/gzip": ["gz"], "application/hjson": ["hjson"], "application/hyperstudio": ["stk"], "application/inkml+xml": ["ink", "inkml"], "application/ipfix": ["ipfix"], "application/its+xml": ["its"], "application/java-archive": ["jar", "war", "ear"], "application/java-serialized-object": ["ser"], "application/java-vm": ["class"], "application/javascript": ["*js"], "application/json": ["json", "map"], "application/json5": ["json5"], "application/jsonml+json": ["jsonml"], "application/ld+json": ["jsonld"], "application/lgr+xml": ["lgr"], "application/lost+xml": ["lostxml"], "application/mac-binhex40": ["hqx"], "application/mac-compactpro": ["cpt"], "application/mads+xml": ["mads"], "application/manifest+json": ["webmanifest"], "application/marc": ["mrc"], "application/marcxml+xml": ["mrcx"], "application/mathematica": ["ma", "nb", "mb"], "application/mathml+xml": ["mathml"], "application/mbox": ["mbox"], "application/media-policy-dataset+xml": ["mpf"], "application/mediaservercontrol+xml": ["mscml"], "application/metalink+xml": ["metalink"], "application/metalink4+xml": ["meta4"], "application/mets+xml": ["mets"], "application/mmt-aei+xml": ["maei"], "application/mmt-usd+xml": ["musd"], "application/mods+xml": ["mods"], "application/mp21": ["m21", "mp21"], "application/mp4": ["*mp4", "*mpg4", "mp4s", "m4p"], "application/msix": ["msix"], "application/msixbundle": ["msixbundle"], "application/msword": ["doc", "dot"], "application/mxf": ["mxf"], "application/n-quads": ["nq"], "application/n-triples": ["nt"], "application/node": ["cjs"], "application/octet-stream": ["bin", "dms", "lrf", "mar", "so", "dist", "distz", "pkg", "bpk", "dump", "elc", "deploy", "exe", "dll", "deb", "dmg", "iso", "img", "msi", "msp", "msm", "buffer"], "application/oda": ["oda"], "application/oebps-package+xml": ["opf"], "application/ogg": ["ogx"], "application/omdoc+xml": ["omdoc"], "application/onenote": ["onetoc", "onetoc2", "onetmp", "onepkg"], "application/oxps": ["oxps"], "application/p2p-overlay+xml": ["relo"], "application/patch-ops-error+xml": ["xer"], "application/pdf": ["pdf"], "application/pgp-encrypted": ["pgp"], "application/pgp-keys": ["asc"], "application/pgp-signature": ["sig", "*asc"], "application/pics-rules": ["prf"], "application/pkcs10": ["p10"], "application/pkcs7-mime": ["p7m", "p7c"], "application/pkcs7-signature": ["p7s"], "application/pkcs8": ["p8"], "application/pkix-attr-cert": ["ac"], "application/pkix-cert": ["cer"], "application/pkix-crl": ["crl"], "application/pkix-pkipath": ["pkipath"], "application/pkixcmp": ["pki"], "application/pls+xml": ["pls"], "application/postscript": ["ai", "eps", "ps"], "application/provenance+xml": ["provx"], "application/pskc+xml": ["pskcxml"], "application/raml+yaml": ["raml"], "application/rdf+xml": ["rdf", "owl"], "application/reginfo+xml": ["rif"], "application/relax-ng-compact-syntax": ["rnc"], "application/resource-lists+xml": ["rl"], "application/resource-lists-diff+xml": ["rld"], "application/rls-services+xml": ["rs"], "application/route-apd+xml": ["rapd"], "application/route-s-tsid+xml": ["sls"], "application/route-usd+xml": ["rusd"], "application/rpki-ghostbusters": ["gbr"], "application/rpki-manifest": ["mft"], "application/rpki-roa": ["roa"], "application/rsd+xml": ["rsd"], "application/rss+xml": ["rss"], "application/rtf": ["rtf"], "application/sbml+xml": ["sbml"], "application/scvp-cv-request": ["scq"], "application/scvp-cv-response": ["scs"], "application/scvp-vp-request": ["spq"], "application/scvp-vp-response": ["spp"], "application/sdp": ["sdp"], "application/senml+xml": ["senmlx"], "application/sensml+xml": ["sensmlx"], "application/set-payment-initiation": ["setpay"], "application/set-registration-initiation": ["setreg"], "application/shf+xml": ["shf"], "application/sieve": ["siv", "sieve"], "application/smil+xml": ["smi", "smil"], "application/sparql-query": ["rq"], "application/sparql-results+xml": ["srx"], "application/sql": ["sql"], "application/srgs": ["gram"], "application/srgs+xml": ["grxml"], "application/sru+xml": ["sru"], "application/ssdl+xml": ["ssdl"], "application/ssml+xml": ["ssml"], "application/swid+xml": ["swidtag"], "application/tei+xml": ["tei", "teicorpus"], "application/thraud+xml": ["tfi"], "application/timestamped-data": ["tsd"], "application/toml": ["toml"], "application/trig": ["trig"], "application/ttml+xml": ["ttml"], "application/ubjson": ["ubj"], "application/urc-ressheet+xml": ["rsheet"], "application/urc-targetdesc+xml": ["td"], "application/voicexml+xml": ["vxml"], "application/wasm": ["wasm"], "application/watcherinfo+xml": ["wif"], "application/widget": ["wgt"], "application/winhlp": ["hlp"], "application/wsdl+xml": ["wsdl"], "application/wspolicy+xml": ["wspolicy"], "application/xaml+xml": ["xaml"], "application/xcap-att+xml": ["xav"], "application/xcap-caps+xml": ["xca"], "application/xcap-diff+xml": ["xdf"], "application/xcap-el+xml": ["xel"], "application/xcap-ns+xml": ["xns"], "application/xenc+xml": ["xenc"], "application/xfdf": ["xfdf"], "application/xhtml+xml": ["xhtml", "xht"], "application/xliff+xml": ["xlf"], "application/xml": ["xml", "xsl", "xsd", "rng"], "application/xml-dtd": ["dtd"], "application/xop+xml": ["xop"], "application/xproc+xml": ["xpl"], "application/xslt+xml": ["*xsl", "xslt"], "application/xspf+xml": ["xspf"], "application/xv+xml": ["mxml", "xhvml", "xvml", "xvm"], "application/yang": ["yang"], "application/yin+xml": ["yin"], "application/zip": ["zip"], "audio/3gpp": ["*3gpp"], "audio/aac": ["adts", "aac"], "audio/adpcm": ["adp"], "audio/amr": ["amr"], "audio/basic": ["au", "snd"], "audio/midi": ["mid", "midi", "kar", "rmi"], "audio/mobile-xmf": ["mxmf"], "audio/mp3": ["*mp3"], "audio/mp4": ["m4a", "mp4a"], "audio/mpeg": ["mpga", "mp2", "mp2a", "mp3", "m2a", "m3a"], "audio/ogg": ["oga", "ogg", "spx", "opus"], "audio/s3m": ["s3m"], "audio/silk": ["sil"], "audio/wav": ["wav"], "audio/wave": ["*wav"], "audio/webm": ["weba"], "audio/xm": ["xm"], "font/collection": ["ttc"], "font/otf": ["otf"], "font/ttf": ["ttf"], "font/woff": ["woff"], "font/woff2": ["woff2"], "image/aces": ["exr"], "image/apng": ["apng"], "image/avci": ["avci"], "image/avcs": ["avcs"], "image/avif": ["avif"], "image/bmp": ["bmp", "dib"], "image/cgm": ["cgm"], "image/dicom-rle": ["drle"], "image/dpx": ["dpx"], "image/emf": ["emf"], "image/fits": ["fits"], "image/g3fax": ["g3"], "image/gif": ["gif"], "image/heic": ["heic"], "image/heic-sequence": ["heics"], "image/heif": ["heif"], "image/heif-sequence": ["heifs"], "image/hej2k": ["hej2"], "image/hsj2": ["hsj2"], "image/ief": ["ief"], "image/jls": ["jls"], "image/jp2": ["jp2", "jpg2"], "image/jpeg": ["jpeg", "jpg", "jpe"], "image/jph": ["jph"], "image/jphc": ["jhc"], "image/jpm": ["jpm", "jpgm"], "image/jpx": ["jpx", "jpf"], "image/jxr": ["jxr"], "image/jxra": ["jxra"], "image/jxrs": ["jxrs"], "image/jxs": ["jxs"], "image/jxsc": ["jxsc"], "image/jxsi": ["jxsi"], "image/jxss": ["jxss"], "image/ktx": ["ktx"], "image/ktx2": ["ktx2"], "image/png": ["png"], "image/sgi": ["sgi"], "image/svg+xml": ["svg", "svgz"], "image/t38": ["t38"], "image/tiff": ["tif", "tiff"], "image/tiff-fx": ["tfx"], "image/webp": ["webp"], "image/wmf": ["wmf"], "message/disposition-notification": ["disposition-notification"], "message/global": ["u8msg"], "message/global-delivery-status": ["u8dsn"], "message/global-disposition-notification": ["u8mdn"], "message/global-headers": ["u8hdr"], "message/rfc822": ["eml", "mime"], "model/3mf": ["3mf"], "model/gltf+json": ["gltf"], "model/gltf-binary": ["glb"], "model/iges": ["igs", "iges"], "model/jt": ["jt"], "model/mesh": ["msh", "mesh", "silo"], "model/mtl": ["mtl"], "model/obj": ["obj"], "model/prc": ["prc"], "model/step+xml": ["stpx"], "model/step+zip": ["stpz"], "model/step-xml+zip": ["stpxz"], "model/stl": ["stl"], "model/u3d": ["u3d"], "model/vrml": ["wrl", "vrml"], "model/x3d+binary": ["*x3db", "x3dbz"], "model/x3d+fastinfoset": ["x3db"], "model/x3d+vrml": ["*x3dv", "x3dvz"], "model/x3d+xml": ["x3d", "x3dz"], "model/x3d-vrml": ["x3dv"], "text/cache-manifest": ["appcache", "manifest"], "text/calendar": ["ics", "ifb"], "text/coffeescript": ["coffee", "litcoffee"], "text/css": ["css"], "text/csv": ["csv"], "text/html": ["html", "htm", "shtml"], "text/jade": ["jade"], "text/javascript": ["js", "mjs"], "text/jsx": ["jsx"], "text/less": ["less"], "text/markdown": ["md", "markdown"], "text/mathml": ["mml"], "text/mdx": ["mdx"], "text/n3": ["n3"], "text/plain": ["txt", "text", "conf", "def", "list", "log", "in", "ini"], "text/richtext": ["rtx"], "text/rtf": ["*rtf"], "text/sgml": ["sgml", "sgm"], "text/shex": ["shex"], "text/slim": ["slim", "slm"], "text/spdx": ["spdx"], "text/stylus": ["stylus", "styl"], "text/tab-separated-values": ["tsv"], "text/troff": ["t", "tr", "roff", "man", "me", "ms"], "text/turtle": ["ttl"], "text/uri-list": ["uri", "uris", "urls"], "text/vcard": ["vcard"], "text/vtt": ["vtt"], "text/wgsl": ["wgsl"], "text/xml": ["*xml"], "text/yaml": ["yaml", "yml"], "video/3gpp": ["3gp", "3gpp"], "video/3gpp2": ["3g2"], "video/h261": ["h261"], "video/h263": ["h263"], "video/h264": ["h264"], "video/iso.segment": ["m4s"], "video/jpeg": ["jpgv"], "video/jpm": ["*jpm", "*jpgm"], "video/mj2": ["mj2", "mjp2"], "video/mp2t": ["ts"], "video/mp4": ["mp4", "mp4v", "mpg4"], "video/mpeg": ["mpeg", "mpg", "mpe", "m1v", "m2v"], "video/ogg": ["ogv"], "video/quicktime": ["qt", "mov"], "video/webm": ["webm"] };
688
- Object.freeze(Xt);
689
- var L = function(t, e, n, i) {
690
- if (n === "a" && !i)
691
- throw new TypeError("Private accessor was defined without a getter");
692
- if (typeof e == "function" ? t !== e || !i : !e.has(t))
693
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
694
- return n === "m" ? i : n === "a" ? i.call(t) : i ? i.value : e.get(t);
695
- }, K, Y, B;
696
- class Ue {
697
- constructor(...e) {
698
- K.set(this, /* @__PURE__ */ new Map()), Y.set(this, /* @__PURE__ */ new Map()), B.set(this, /* @__PURE__ */ new Map());
699
- for (const n of e)
700
- this.define(n);
701
- }
702
- define(e, n = !1) {
703
- for (let [i, o] of Object.entries(e)) {
704
- i = i.toLowerCase(), o = o.map((p) => p.toLowerCase()), L(this, B, "f").has(i) || L(this, B, "f").set(i, /* @__PURE__ */ new Set());
705
- const a = L(this, B, "f").get(i);
706
- let r = !0;
707
- for (let p of o) {
708
- const m = p.startsWith("*");
709
- if (p = m ? p.slice(1) : p, a == null || a.add(p), r && L(this, Y, "f").set(i, p), r = !1, m)
710
- continue;
711
- const u = L(this, K, "f").get(p);
712
- if (u && u != i && !n)
713
- throw new Error(`"${i} -> ${p}" conflicts with "${u} -> ${p}". Pass \`force=true\` to override this definition.`);
714
- L(this, K, "f").set(p, i);
715
- }
716
- }
717
- return this;
718
- }
719
- getType(e) {
720
- if (typeof e != "string")
721
- return null;
722
- const n = e.replace(/^.*[/\\]/, "").toLowerCase(), i = n.replace(/^.*\./, "").toLowerCase(), o = n.length < e.length;
723
- return !(i.length < n.length - 1) && o ? null : L(this, K, "f").get(i) ?? null;
724
- }
725
- getExtension(e) {
726
- var n;
727
- return typeof e != "string" ? null : (e = (n = e == null ? void 0 : e.split) == null ? void 0 : n.call(e, ";")[0], (e && L(this, Y, "f").get(e.trim().toLowerCase())) ?? null);
728
- }
729
- getAllExtensions(e) {
730
- return typeof e != "string" ? null : L(this, B, "f").get(e.toLowerCase()) ?? null;
731
- }
732
- _freeze() {
733
- this.define = () => {
734
- throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances");
735
- }, Object.freeze(this);
736
- for (const e of L(this, B, "f").values())
737
- Object.freeze(e);
738
- return this;
739
- }
740
- _getTestState() {
741
- return {
742
- types: L(this, K, "f"),
743
- extensions: L(this, Y, "f")
744
- };
745
- }
746
- }
747
- K = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new WeakMap(), B = /* @__PURE__ */ new WeakMap();
748
- const Ce = new Ue(Xt)._freeze();
749
- function Fe(t, e, n) {
750
- const i = be(t, e);
751
- return dt.mkdirSync(t, { recursive: !0 }), new Promise((o, a) => {
752
- try {
753
- dt.writeFile(i, n, {}, (r) => {
754
- r ? a(r) : o(i);
755
- });
756
- } catch (r) {
757
- a(r);
758
- }
759
- });
760
- }
761
- function Bt(t) {
762
- return dt.readFileSync(t);
763
- }
764
- function Le(t) {
765
- return new Promise((e, n) => {
766
- ye.get(t, (i) => {
767
- const o = [], a = i.headers["content-type"];
768
- i.on("data", (r) => {
769
- o.push(r);
770
- }), i.on("end", () => {
771
- e({ buffer: Buffer.concat(o), mimeType: a });
772
- });
773
- }).on("error", (i) => {
774
- n(i);
775
- });
776
- });
777
- }
778
- const qe = async (t) => Bt(t), ut = (t, e = "sha1") => xe.createHash(e).update(t).digest("base64");
779
- function Je(t) {
780
- const e = [], n = Object.keys(t);
781
- for (const i of n) {
782
- const o = t[i].sort((a, r) => a.index - r.index);
783
- for (let a = 0; a < o.length; a++)
784
- o[a].index !== a && e.push({
785
- message: `Invalid operation index ${o[a].index} at position ${a}`,
786
- details: {
787
- position: a,
788
- operation: o[a],
789
- scope: o[a].scope
790
- }
791
- });
792
- }
793
- return e;
794
- }
795
- const Kt = async (t) => {
796
- const e = new vt(), { name: n, revision: i, documentType: o, created: a, lastModified: r } = t, p = {
797
- name: n,
798
- revision: i,
799
- documentType: o,
800
- created: a,
801
- lastModified: r
802
- };
803
- return e.file("header.json", JSON.stringify(p, null, 2)), e.file(
804
- "state.json",
805
- JSON.stringify(t.initialState || {}, null, 2)
806
- ), e.file("operations.json", JSON.stringify(t.operations, null, 2)), t.attachments && Object.keys(t.attachments).forEach((u) => {
807
- const { data: h, ...b } = t.attachments[u];
808
- e.file(u, h, {
809
- base64: !0,
810
- createFolders: !0,
811
- comment: JSON.stringify(b)
812
- });
813
- }), e;
814
- }, Ve = async (t, e, n, i) => {
815
- const a = await (await Kt(t)).generateAsync({
816
- type: "uint8array",
817
- streamFiles: !0
818
- }), r = i ?? t.name, p = `.${n}.zip`;
819
- return Fe(
820
- e,
821
- r.endsWith(p) ? r : `${r}${p}`,
822
- a
823
- );
824
- }, wn = async (t, e) => {
825
- const i = await (await Kt(t)).generateAsync({ type: "blob" }), o = await e.createWritable();
826
- await o.write(i), await o.close();
827
- }, Tt = async (t, e, n) => {
828
- const i = Bt(t);
829
- return He(i, e, n);
830
- }, He = async (t, e, n) => {
831
- const i = new vt();
832
- return await i.loadAsync(t), Xe(i, e, n);
833
- };
834
- async function Xe(t, e, n) {
835
- const i = t.file("state.json");
836
- if (!i)
837
- throw new Error("Initial state not found");
838
- const o = await i.async("string"), a = JSON.parse(o), r = t.file("header.json");
839
- let p;
840
- r && (p = JSON.parse(await r.async("string")));
841
- const m = t.file("operations.json");
842
- if (!m)
843
- throw new Error("Operations history not found");
844
- const u = JSON.parse(
845
- await m.async("string")
846
- ), h = Je(u);
847
- if (h.length) {
848
- const w = h.map((I) => I.message);
849
- throw new Error(w.join(`
850
- `));
851
- }
852
- let b = se(
853
- a,
854
- u,
855
- e,
856
- void 0,
857
- p,
858
- {},
859
- n
860
- );
861
- return p && (b = {
862
- ...b,
863
- ...p
864
- }), b;
865
- }
866
- function Wt(t) {
867
- const e = t.replace(/^.*\./, "") || void 0, n = t.replace(/^.*[/\\]/, "") || void 0;
868
- return { extension: e, fileName: n };
869
- }
870
- async function On(t) {
871
- const { buffer: e, mimeType: n = "application/octet-stream" } = await Le(t), i = Wt(t), o = e.toString("base64");
872
- return {
873
- data: o,
874
- hash: ut(o),
875
- mimeType: n,
876
- ...i
877
- };
878
- }
879
- async function Sn(t) {
880
- const e = await qe(t), n = Ce.getType(t) || "application/octet-stream", i = Wt(t), o = e.toString("base64");
881
- return { data: o, hash: ut(o), mimeType: n, ...i };
882
- }
883
- var Gt = /* @__PURE__ */ ((t) => (t.UNEXPECTED_INDEX = "UNEXPECTED_INDEX", t))(Gt || {}), Zt = /* @__PURE__ */ ((t) => (t.DUPLICATED_INDEX = "DUPLICATED_INDEX", t.MISSING_INDEX = "MISSING_INDEX", t))(Zt || {});
884
- function jt(t) {
885
- const e = [];
886
- let n = -1;
887
- for (const i of t) {
888
- const o = i.index - i.skip;
889
- o !== n + 1 && e.push({
890
- operation: {
891
- index: i.index,
892
- skip: i.skip
893
- },
894
- issue: "UNEXPECTED_INDEX",
895
- category: o > n + 1 ? "MISSING_INDEX" : "DUPLICATED_INDEX",
896
- message: `Expected index ${n + 1} with skip 0 or equivalent, got index ${i.index} with skip ${i.skip}`
897
- }), n = i.index;
898
- }
899
- return e;
900
- }
901
- function H(t) {
902
- var i, o, a;
903
- const e = [];
904
- let n = t.length - 1;
905
- for (; n > -1; ) {
906
- e.unshift(t[n]);
907
- const r = (((i = t[n]) == null ? void 0 : i.index) || 0) - (((o = t[n]) == null ? void 0 : o.skip) || 0) - 1;
908
- let p = n - 1;
909
- for (; p > -1 && (((a = t[p]) == null ? void 0 : a.index) || 0) > r; )
910
- p--;
911
- n = p;
912
- }
913
- return e;
914
- }
915
- function Be(t) {
916
- const e = [...t], n = e[e.length - 1];
917
- return n && (n.type === "NOOP" ? e.push({
918
- ...n,
919
- index: n.index,
920
- type: "NOOP",
921
- skip: te(t)
922
- }) : e.push({
923
- type: "NOOP",
924
- index: n.index + 1,
925
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
926
- input: {},
927
- skip: 1,
928
- scope: n.scope,
929
- hash: n.hash
930
- })), e;
931
- }
932
- function X(t) {
933
- return t.slice().sort((e, n) => e.skip - n.skip).sort((e, n) => e.index - n.index);
934
- }
935
- const Ke = (t, e, n) => [...e, ...n].sort(
936
- (i, o) => new Date(i.timestamp).getTime() - new Date(o.timestamp).getTime()
937
- ).map((i, o) => ({
938
- ...i,
939
- index: t.index + o,
940
- skip: o === 0 ? t.skip : 0
941
- })), We = (t, e, n) => [...e, ...n].sort(
942
- (i, o) => new Date(i.timestamp).getTime() - new Date(o.timestamp).getTime()
943
- ).sort((i, o) => i.index - o.index).map((i, o) => ({
944
- ...i,
945
- index: t.index + o,
946
- skip: o === 0 ? t.skip : 0
947
- }));
948
- function Et(t, e) {
949
- return W(t) === W(e);
950
- }
951
- function Ge(t, e) {
952
- const n = H(X(t.slice())), i = H(X(e.slice()));
953
- if (n.length < 1)
954
- return [i, []];
955
- const o = [];
956
- let a = !1;
957
- for (; i.length > 0; ) {
958
- const r = i[0];
959
- let p = n.shift();
960
- for (; p && Qt(p, r); )
961
- o.push(p), p = n.shift();
962
- if (p ? a || (Et(p, r) ? (i.shift(), o.push(p)) : (n.unshift(p), a = !0)) : a = !0, a) {
963
- let m = i.shift();
964
- for (; m; )
965
- o.push(m), m = i.shift();
966
- }
967
- }
968
- if (!a) {
969
- let r = n.shift();
970
- for (; r; )
971
- o.push(r), r = n.shift();
972
- }
973
- return [H(o), n];
974
- }
975
- function Qt(t, e) {
976
- return t.index < e.index || t.index === e.index && t.id === e.id && t.skip < e.skip;
977
- }
978
- function Yt(t, e) {
979
- const n = [], i = [], o = [], a = Math.max(
980
- t.length,
981
- e.length
982
- );
983
- let r = !1;
984
- for (let p = 0; p < a; p++) {
985
- const m = t[p], u = e[p];
986
- m && u ? !r && Et(m, u) ? n.push(m) : (r = !0, i.push(m), o.push(u)) : m ? i.push(m) : u && o.push(u);
987
- }
988
- return [n, i, o];
989
- }
990
- function Ze(t, e, n) {
991
- const [i, o, a] = Yt(
992
- H(t),
993
- H(e)
994
- ), r = ft(i), p = 1 + Math.max(
995
- r,
996
- ft(o),
997
- ft(a)
998
- ), m = ne(
999
- a,
1000
- o
1001
- ), u = n(
1002
- {
1003
- index: p,
1004
- skip: p - (r + 1)
1005
- },
1006
- o,
1007
- m
1008
- );
1009
- return i.concat(u);
1010
- }
1011
- function ft(t) {
1012
- const e = t[t.length - 1];
1013
- return e ? e.index : -1;
1014
- }
1015
- function te(t) {
1016
- var i, o, a;
1017
- if (t.length < 1)
1018
- return -1;
1019
- const e = H(t);
1020
- let n = (((i = e[e.length - 1]) == null ? void 0 : i.skip) || 0) + 1;
1021
- return e.length > 1 && (n += ((o = e[e.length - 2]) == null ? void 0 : o.skip) || 0), (((a = e[e.length - 1]) == null ? void 0 : a.index) || -1) < n ? -1 : n;
1022
- }
1023
- const Qe = (t) => jt(
1024
- H(X(t))
1025
- ), Ye = (t) => t.reduce((n, i) => {
1026
- var o;
1027
- return n[i.scope] || (n[i.scope] = []), (o = n[i.scope]) == null || o.push(i), n;
1028
- }, {}), tn = (t, e) => {
1029
- var m;
1030
- const n = {
1031
- integrityIssues: [],
1032
- validOperations: [],
1033
- invalidOperations: [],
1034
- duplicatedOperations: []
1035
- }, i = X(t), o = X(e), a = jt([
1036
- ...i,
1037
- ...o
1038
- ]), p = (m = [...a.filter(
1039
- (u) => u.category === "MISSING_INDEX"
1040
- /* MISSING_INDEX */
1041
- )].sort((u, h) => h.operation.index - u.operation.index).pop()) == null ? void 0 : m.operation;
1042
- for (const u of o) {
1043
- if (p && u.index >= p.index) {
1044
- n.invalidOperations.push(u);
1045
- continue;
1046
- }
1047
- if (a.some((b) => b.operation.index === u.index && b.operation.skip === u.skip && b.category === "DUPLICATED_INDEX")) {
1048
- n.duplicatedOperations.push(u);
1049
- continue;
1050
- }
1051
- n.validOperations.push(u);
1052
- }
1053
- return n.integrityIssues.push(...a), n;
1054
- };
1055
- function en(t, e) {
1056
- return t.filter((n) => !e.some((i) => n.type === "NOOP" && n.skip === 0 && n.index === i.index || n.index === i.index && n.skip === i.skip && n.scope === i.scope && n.hash === i.hash && n.type === i.type));
1057
- }
1058
- function ee(t, e) {
1059
- const [n] = X(t).slice(-1), i = (n == null ? void 0 : n.index) ?? -1, o = i + 1, a = {
1060
- ...e,
1061
- index: e.index ?? o
1062
- };
1063
- if (a.index < i)
1064
- throw new Error(
1065
- `The skip header operation index must be greater than or equal to ${i}`
1066
- );
1067
- return (H(
1068
- X([...t, a])
1069
- ) || []).slice(0, -1);
1070
- }
1071
- function ht(t) {
1072
- return {
1073
- ...Object.entries(t).reduce(
1074
- (n, i) => {
1075
- const [o, a] = i;
1076
- return {
1077
- ...n,
1078
- [o]: H(X(a))
1079
- };
1080
- },
1081
- {}
1082
- )
1083
- };
1084
- }
1085
- function ne(t, e) {
1086
- return t.filter((n) => n.id ? !e.some((i) => i.id === n.id) : !0);
1087
- }
1088
- const jn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1089
- __proto__: null,
1090
- IntegrityIssueSubType: Zt,
1091
- IntegrityIssueType: Gt,
1092
- addUndo: Be,
1093
- attachBranch: Ge,
1094
- checkCleanedOperationsIntegrity: jt,
1095
- checkOperationsIntegrity: Qe,
1096
- filterDuplicatedOperations: ne,
1097
- garbageCollect: H,
1098
- garbageCollectDocumentOperations: ht,
1099
- groupOperationsByScope: Ye,
1100
- merge: Ze,
1101
- nextSkipNumber: te,
1102
- operationsAreEqual: Et,
1103
- precedes: Qt,
1104
- prepareOperations: tn,
1105
- removeExistingOperations: en,
1106
- reshuffleByTimestamp: Ke,
1107
- reshuffleByTimestampAndIndex: We,
1108
- skipHeaderOperations: ee,
1109
- sortOperations: X,
1110
- split: Yt
1111
- }, Symbol.toStringTag, { value: "Module" }));
1112
- function nn(t, e) {
1113
- let n;
1114
- return "index" in e ? n = { ...e } : n = t.operations[e.scope].at(-1), ((n == null ? void 0 : n.index) ?? -1) + 1;
1115
- }
1116
- function ie(t, e) {
1117
- return {
1118
- ...t,
1119
- revision: {
1120
- ...t.revision,
1121
- [e.scope]: nn(t, e)
1122
- },
1123
- lastModified: (/* @__PURE__ */ new Date()).toISOString()
1124
- };
1125
- }
1126
- function on(t, e, n = 0) {
1127
- if ([et, nt, mt].includes(e.type))
1128
- return t;
1129
- const { scope: i } = e, o = t.operations[i].slice();
1130
- let a;
1131
- const r = o.at(-1);
1132
- let p = ((r == null ? void 0 : r.index) ?? -1) + 1;
1133
- if ("index" in e) {
1134
- if (e.index - n > p)
1135
- throw new Error(
1136
- `Missing operations: expected ${p} with skip 0 or equivalent, got index ${e.index} with skip ${n}`
1137
- );
1138
- p = e.index, a = e.id;
1139
- } else
1140
- a = Ie();
1141
- return o.push({
1142
- ...e,
1143
- id: a,
1144
- index: p,
1145
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1146
- hash: "",
1147
- scope: i,
1148
- skip: n,
1149
- error: void 0
1150
- }), {
1151
- ...t,
1152
- operations: { ...t.operations, [i]: o }
1153
- };
1154
- }
1155
- function sn(t, e, n = 0) {
1156
- let i = on(t, e, n);
1157
- return i = ie(i, e), i;
1158
- }
1159
- function rn(t, e, n) {
1160
- switch (zt().parse(e), e.type) {
1161
- case Vt:
1162
- return Ne(t, e.input);
1163
- case mt:
1164
- return Me(t, e, n);
1165
- case Ht:
1166
- return Re(t, e.input.state);
1167
- default:
1168
- return t;
1169
- }
1170
- }
1171
- function En(t, e, n) {
1172
- switch (e.type) {
1173
- case et:
1174
- return Ae(t, e, n);
1175
- case nt:
1176
- return Pe(t, e, n);
1177
- default:
1178
- return { document: t, action: e, skip: n };
1179
- }
1180
- }
1181
- function an(t, e, n, i, o = !1, a = re) {
1182
- const r = e.scope, p = t.operations[r].at(-1);
1183
- if (!p)
1184
- return t;
1185
- const m = ht(
1186
- {
1187
- ...t.operations,
1188
- [r]: ee(
1189
- t.operations[r],
1190
- p
1191
- )
1192
- }
1193
- );
1194
- let u;
1195
- const h = m[r].at(-1);
1196
- if (o && (h != null && h.resultingState))
1197
- u = a(
1198
- h.resultingState
1199
- );
1200
- else {
1201
- const { state: b } = xt(
1202
- t.initialState,
1203
- m,
1204
- n,
1205
- void 0,
1206
- void 0,
1207
- void 0,
1208
- void 0,
1209
- {
1210
- reuseHash: !0,
1211
- reuseOperationResultingState: o,
1212
- operationResultingStateParser: a
1213
- }
1214
- );
1215
- u = b[r];
1216
- }
1217
- return {
1218
- ...t,
1219
- state: {
1220
- ...t.state,
1221
- [r]: u
1222
- },
1223
- operations: ht({
1224
- ...t.operations
1225
- })
1226
- };
1227
- }
1228
- function oe(t, e, n, i, o = {}) {
1229
- const {
1230
- skip: a,
1231
- ignoreSkipOperations: r = !1,
1232
- reuseHash: p = !1,
1233
- reuseOperationResultingState: m = !1,
1234
- operationResultingStateParser: u
1235
- } = o, h = { ...e }, b = a || 0;
1236
- let w = { ...t };
1237
- const I = !r && (b > 0 || "index" in h && h.skip > 0);
1238
- return _t(h) && (w = rn(w, h, n)), w = sn(w, h, b), I && (w = an(
1239
- w,
1240
- h,
1241
- n,
1242
- b,
1243
- m,
1244
- u
1245
- )), w = lt(w, ($) => {
1246
- try {
1247
- const M = n(
1248
- $.state,
1249
- h,
1250
- i
1251
- );
1252
- if (M)
1253
- return ct({
1254
- ...w,
1255
- // clipboard: [...clipboardValue],
1256
- state: M
1257
- });
1258
- } catch (M) {
1259
- const C = w.operations[h.scope].length - 1;
1260
- $.operations[h.scope][C].error = M.message, $.operations[h.scope][C].skip = 0, I && ($.state = ct({ ...t.state }), $.operations = ct({
1261
- ...t.operations,
1262
- [h.scope]: [
1263
- ...t.operations[h.scope],
1264
- {
1265
- ...$.operations[h.scope][C]
1266
- }
1267
- ]
1268
- }));
1269
- }
1270
- }), lt(w, ($) => {
1271
- if ([et, nt, mt].includes(h.type))
1272
- return $;
1273
- const M = h.scope || "global", C = p && Object.prototype.hasOwnProperty.call(h, "hash") ? h.hash : $t($, M), c = $.operations[M].at(-1);
1274
- c && (c.hash = C, m && (c.resultingState = $.state[M]), !_t(h) && h.attachments && h.attachments.forEach((l) => {
1275
- const { hash: f, ...k } = l;
1276
- $.attachments[f] = {
1277
- ...k
1278
- };
1279
- }));
1280
- });
1281
- }
1282
- function $n(t) {
1283
- return t.type === ze && t.skip !== void 0 && t.skip > 0 && t.hash !== void 0;
1284
- }
1285
- function Dn(t) {
1286
- return [et, nt].includes(t.type);
1287
- }
1288
- function _t(t) {
1289
- return [Vt, et, nt, mt, Ht].includes(t.type);
1290
- }
1291
- function G(t, e, n, i, o = "global") {
1292
- if (!t)
1293
- throw new Error("Empty action type");
1294
- if (typeof t != "string")
1295
- throw new Error(`Invalid action type: ${JSON.stringify(t)}`);
1296
- const a = { type: t, input: e, scope: o };
1297
- n && (a.attachments = n);
1298
- try {
1299
- i == null || i().parse(a.input);
1300
- } catch (r) {
1301
- throw new Error(`Invalid action input: ${r}`);
1302
- }
1303
- return a;
1304
- }
1305
- function pn(t, e = oe) {
1306
- return (n, i, o, a) => e(n, i, t, o, a);
1307
- }
1308
- const cn = (t, e) => ({
1309
- name: "",
1310
- documentType: "",
1311
- revision: {
1312
- global: 0,
1313
- local: 0
1314
- },
1315
- created: (/* @__PURE__ */ new Date()).toISOString(),
1316
- lastModified: (/* @__PURE__ */ new Date()).toISOString(),
1317
- attachments: {},
1318
- ...t,
1319
- state: (e == null ? void 0 : e(t == null ? void 0 : t.state)) ?? (t == null ? void 0 : t.state) ?? { global: {}, local: {} }
1320
- }), ln = (t, e) => {
1321
- const n = cn(
1322
- t,
1323
- e
1324
- );
1325
- return {
1326
- ...n,
1327
- initialState: n,
1328
- operations: { global: [], local: [] },
1329
- clipboard: []
1330
- };
1331
- }, $t = (t, e = "global") => ut(W(t.state[e] || "")), kn = (t, e = 1e3) => {
1332
- const n = Math.random() * e;
1333
- return ut(`${(t ?? /* @__PURE__ */ new Date()).toISOString()}${n}`);
1334
- };
1335
- function pt(t) {
1336
- return ge(he(t, !0));
1337
- }
1338
- function Tn(t, e) {
1339
- const n = [...t];
1340
- let i = e || 0, o = n.length > 0 ? n[n.length - 1].index : 0;
1341
- const a = [];
1342
- for (const r of n.reverse()) {
1343
- if (i > 0) {
1344
- const u = o - r.index;
1345
- i -= u;
1346
- }
1347
- if (i < 0)
1348
- throw new Error("Invalid operation index, missing operations");
1349
- const p = {
1350
- ignore: i > 0,
1351
- operation: r
1352
- }, m = r.skip > 0 ? r.skip + 1 : 0;
1353
- if (m > 0 && m > i) {
1354
- const u = m - i;
1355
- i = i + u;
1356
- }
1357
- o = r.index, a.push(p);
1358
- }
1359
- return a.reverse();
1360
- }
1361
- function _n(t, e, n) {
1362
- const i = t.slice().sort((p, m) => p.skip - m.skip).sort((p, m) => p.index - m.index);
1363
- let o = n, a = 0, r = e;
1364
- for (const p of i.reverse()) {
1365
- const m = r - p.index;
1366
- if (o = o - m, o > -1)
1367
- a++, r = p.index;
1368
- else
1369
- break;
1370
- }
1371
- return a;
1372
- }
1373
- function vn(t) {
1374
- return Object.values(t).flatMap((e) => e).sort(
1375
- (e, n) => new Date(e.timestamp).getTime() - new Date(n.timestamp).getTime()
1376
- );
1377
- }
1378
- function In(t) {
1379
- return Object.values(t).flatMap((e) => e).sort(
1380
- (e, n) => new Date(e.operation.timestamp).getTime() - new Date(n.operation.timestamp).getTime()
1381
- );
1382
- }
1383
- function xt(t, e, n, i, o, a = oe, r = {}, p) {
1384
- const m = pn(n, a);
1385
- return se(
1386
- t,
1387
- e,
1388
- m,
1389
- i,
1390
- o,
1391
- r,
1392
- p
1393
- );
1394
- }
1395
- function se(t, e, n, i, o, a = {}, r) {
1396
- const {
1397
- checkHashes: p = !0,
1398
- reuseOperationResultingState: m,
1399
- operationResultingStateParser: u = re
1400
- } = r || {};
1401
- let h = t;
1402
- const b = [], w = {
1403
- global: [],
1404
- local: []
1405
- };
1406
- if (m)
1407
- for (const [c, l] of Object.entries(e)) {
1408
- const f = l.findLastIndex(
1409
- (F) => !!F.resultingState
1410
- );
1411
- if (f < 0) {
1412
- b.push(...l);
1413
- continue;
1414
- }
1415
- const k = l[f];
1416
- try {
1417
- const F = u(
1418
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unnecessary-type-assertion
1419
- k.resultingState
1420
- );
1421
- h = {
1422
- ...h,
1423
- state: {
1424
- ...h.state,
1425
- // TODO how to deal with attachments?
1426
- [c]: F
1427
- }
1428
- }, w[c].push(
1429
- ...l.slice(0, f + 1)
1430
- ), b.push(...l.slice(f + 1));
1431
- } catch {
1432
- b.push(...l);
1433
- }
1434
- }
1435
- else
1436
- b.push(...Object.values(e).flat());
1437
- const I = ln(h);
1438
- I.initialState = t, I.operations = w;
1439
- let $ = I;
1440
- if (b.length)
1441
- $ = b.reduce((c, l) => n(c, l, i, {
1442
- skip: l.skip,
1443
- ignoreSkipOperations: !0,
1444
- reuseHash: !p
1445
- }), I);
1446
- else
1447
- for (const c of Object.values(w)) {
1448
- const l = c.at(-1);
1449
- l && ($ = ie($, l));
1450
- }
1451
- if (!p)
1452
- for (const c of Object.keys($.state))
1453
- for (let l = b.length - 1; l >= 0; l--) {
1454
- const f = b[l];
1455
- if (f.scope === c) {
1456
- if (f.hash !== $t($, c))
1457
- throw new Error(`Hash mismatch for scope ${c}`);
1458
- break;
1459
- }
1460
- }
1461
- const M = Object.keys(
1462
- $.operations
1463
- ).reduce(
1464
- (c, l) => {
1465
- const f = l;
1466
- return {
1467
- ...c,
1468
- [f]: [
1469
- ...$.operations[f].map((k, F) => {
1470
- var R;
1471
- return {
1472
- ...k,
1473
- timestamp: ((R = e[f][F]) == null ? void 0 : R.timestamp) ?? k.timestamp
1474
- };
1475
- })
1476
- ]
1477
- };
1478
- },
1479
- { global: [], local: [] }
1480
- ), C = Object.values(M).reduce((c, l) => {
1481
- const f = l[l.length - 1];
1482
- return (f == null ? void 0 : f.timestamp) > c && (c = f.timestamp), c;
1483
- }, t.lastModified);
1484
- return { ...$, operations: M, lastModified: C };
1485
- }
1486
- function Nn(t, e) {
1487
- return W(t) === W(e);
1488
- }
1489
- function re(t) {
1490
- const e = typeof t;
1491
- if (e === "string")
1492
- return JSON.parse(t);
1493
- if (e === "object")
1494
- return t;
1495
- throw new Error(`Providing resulting state is of type: ${e}`);
1496
- }
1497
- const ae = (t) => G(
1498
- "SET_NAME",
1499
- t,
1500
- void 0,
1501
- Ot,
1502
- void 0
1503
- ), pe = (t = 1, e = "global") => G(
1504
- "UNDO",
1505
- t,
1506
- void 0,
1507
- St,
1508
- e
1509
- ), ce = (t = 1, e = "global") => G(
1510
- "REDO",
1511
- t,
1512
- void 0,
1513
- wt,
1514
- e
1515
- ), le = (t, e, n = "global") => G(
1516
- "PRUNE",
1517
- { start: t, end: e },
1518
- void 0,
1519
- bt,
1520
- n
1521
- ), Dt = (t, e) => G(
1522
- "LOAD_STATE",
1523
- { state: t, operations: e },
1524
- void 0,
1525
- yt
1526
- ), me = (t = "global") => G("NOOP", {}, void 0, void 0, t), An = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1527
- __proto__: null,
1528
- loadState: Dt,
1529
- noop: me,
1530
- prune: le,
1531
- redo: ce,
1532
- setName: ae,
1533
- undo: pe
1534
- }, Symbol.toStringTag, { value: "Module" }));
1535
- class Pn {
1536
- /**
1537
- * Constructs a BaseDocument instance with an initial state.
1538
- * @param reducer - The reducer function that updates the state.
1539
- * @param document - The initial state of the document.
1540
- */
1541
- constructor(e, n, i) {
1542
- rt(this, "_document");
1543
- rt(this, "_reducer");
1544
- rt(this, "_signalDispatch");
1545
- this._reducer = e, this._document = n, this._signalDispatch = i;
1546
- }
1547
- /**
1548
- * Dispatches an action to update the state of the document.
1549
- * @param action - The action to dispatch.
1550
- * @returns The Document instance.
1551
- */
1552
- dispatch(e, n) {
1553
- return this._document = this._reducer(
1554
- this._document,
1555
- e,
1556
- this._signalDispatch,
1557
- n
1558
- ), this;
1559
- }
1560
- /**
1561
- * Saves the state of the document to a file.
1562
- * @param path - The file path where the state should be saved.
1563
- * @param extension - The file extension to use when saving the state.
1564
- * @returns The file path where the state was saved.
1565
- */
1566
- saveToFile(e, n, i) {
1567
- return Ve(this._document, e, n, i);
1568
- }
1569
- /**
1570
- * Loads the state of the document from a file.
1571
- * @param path - The file path where the state is stored.
1572
- */
1573
- async loadFromFile(e) {
1574
- this._document = await Tt(e, this._reducer);
1575
- }
1576
- /**
1577
- * Loads the state of the document from a file and returns it.
1578
- * @param path - The file path where the state is stored.
1579
- * @param reducer - The reducer function that updates the state.
1580
- * @returns The state of the document.
1581
- */
1582
- static async stateFromFile(e, n) {
1583
- return await Tt(e, n);
1584
- }
1585
- /**
1586
- * Gets the current state of the document.
1587
- */
1588
- get state() {
1589
- return pt(this._document.state);
1590
- }
1591
- /**
1592
- * Gets the list of operations performed on the document.
1593
- */
1594
- get operations() {
1595
- return pt(this._document.operations);
1596
- }
1597
- /**
1598
- * Gets the name of the document.
1599
- */
1600
- get name() {
1601
- return this._document.name;
1602
- }
1603
- /**
1604
- * Gets the type of document.
1605
- */
1606
- get documentType() {
1607
- return this._document.documentType;
1608
- }
1609
- /**
1610
- * Gets the timestamp of the date the document was created.
1611
- */
1612
- get created() {
1613
- return this._document.created;
1614
- }
1615
- /**
1616
- * Gets the timestamp of the date the document was last modified.
1617
- */
1618
- get lastModified() {
1619
- return this._document.lastModified;
1620
- }
1621
- /**
1622
- * Gets the global revision number of the document.
1623
- */
1624
- get revision() {
1625
- return this._document.revision.global;
1626
- }
1627
- getRevision(e) {
1628
- return this._document.revision[e];
1629
- }
1630
- /**
1631
- * Gets the initial state of the document.
1632
- */
1633
- get initialState() {
1634
- return pt(this._document.initialState);
1635
- }
1636
- /**
1637
- * Returns the current document as an object
1638
- */
1639
- toDocument() {
1640
- return pt(this._document);
1641
- }
1642
- /**
1643
- * Gets the attachment associated with the given key.
1644
- * @param attachment - The key of the attachment to retrieve.
1645
- */
1646
- getAttachment(e) {
1647
- return this._document.attachments[e];
1648
- }
1649
- /**
1650
- * Sets the name of the document.
1651
- * @param name - The new name of the document.
1652
- */
1653
- setName(e) {
1654
- return this.dispatch(ae(e)), this;
1655
- }
1656
- /**
1657
- * Reverts a number of actions from the document.
1658
- * @param count - The number of actions to revert.
1659
- */
1660
- undo(e) {
1661
- return this.dispatch(pe(e)), this;
1662
- }
1663
- /**
1664
- * Reapplies a number of actions to the document.
1665
- * @param count - The number of actions to reapply.
1666
- */
1667
- redo(e) {
1668
- return this.dispatch(ce(e)), this;
1669
- }
1670
- /**
1671
- * Removes a range of operations from the document.
1672
- * @param start - The starting index of the range to remove.
1673
- * @param end - The ending index of the range to remove.
1674
- */
1675
- prune(e, n) {
1676
- return this.dispatch(le(e, n)), this;
1677
- }
1678
- /**
1679
- * Loads a document state and a set of operations.
1680
- * @param state - The state to load.
1681
- * @param operations - The operations to apply to the document.
1682
- */
1683
- loadState(e, n) {
1684
- return this.dispatch(Dt(e, n)), this;
1685
- }
1686
- }
1687
- function Mn(t, e) {
1688
- e.forEach((n) => {
1689
- Object.getOwnPropertyNames(n.prototype).forEach((i) => {
1690
- Object.defineProperty(
1691
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1692
- t.prototype,
1693
- i,
1694
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
1695
- Object.getOwnPropertyDescriptor(n.prototype, i) || /* @__PURE__ */ Object.create(null)
1696
- );
1697
- });
1698
- });
1699
- }
1700
- export {
1701
- In as A,
1702
- Pn as B,
1703
- vn as C,
1704
- Je as D,
1705
- oe as E,
1706
- En as F,
1707
- sn as G,
1708
- ie as H,
1709
- bn as I,
1710
- cn as a,
1711
- ln as b,
1712
- pn as c,
1713
- wn as d,
1714
- He as e,
1715
- G as f,
1716
- Mn as g,
1717
- An as h,
1718
- _t as i,
1719
- _n as j,
1720
- Kt as k,
1721
- Tt as l,
1722
- jn as m,
1723
- Sn as n,
1724
- On as o,
1725
- $t as p,
1726
- kn as q,
1727
- $n as r,
1728
- Ve as s,
1729
- Nn as t,
1730
- Dn as u,
1731
- Tn as v,
1732
- re as w,
1733
- pt as x,
1734
- se as y,
1735
- xt as z
1736
- };