document-model 1.0.21 → 1.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/dist/browser/document-model.cjs +1 -0
  2. package/dist/browser/document-model.d.ts +1 -0
  3. package/dist/browser/document-model.js +16 -0
  4. package/dist/browser/document.cjs +1 -0
  5. package/dist/browser/document.d.ts +1 -0
  6. package/dist/browser/document.js +14 -0
  7. package/dist/browser/index.cjs +1 -0
  8. package/dist/browser/index.d.ts +3 -0
  9. package/dist/browser/index.js +17 -0
  10. package/dist/browser/internal/index-8aac3662.js +1928 -0
  11. package/dist/browser/internal/index-8fceb2dc.js +1 -0
  12. package/dist/browser/internal/index-cd28e4ab.js +22 -0
  13. package/dist/browser/internal/index-e127ba7e.js +36 -0
  14. package/dist/browser/internal/object-67d1240b.js +1831 -0
  15. package/dist/browser/internal/object-ba4e810d.js +6 -0
  16. package/dist/browser/jest.config.d.ts +8 -0
  17. package/dist/browser/src/document/actions/creators.d.ts +47 -0
  18. package/dist/browser/src/document/actions/index.d.ts +10 -0
  19. package/dist/browser/src/document/actions/types.d.ts +8 -0
  20. package/dist/browser/src/document/index.d.ts +6 -0
  21. package/dist/browser/src/document/object.d.ts +447 -0
  22. package/dist/browser/src/document/reducer.d.ts +16 -0
  23. package/dist/browser/src/document/schema/index.d.ts +2 -0
  24. package/dist/browser/src/document/schema/types.d.ts +180 -0
  25. package/dist/browser/src/document/schema/zod.d.ts +113 -0
  26. package/dist/browser/src/document/signal.d.ts +28 -0
  27. package/dist/browser/src/document/types.d.ts +201 -0
  28. package/dist/browser/src/document/utils/base.d.ts +74 -0
  29. package/dist/browser/src/document/utils/file.d.ts +47 -0
  30. package/dist/browser/src/document/utils/index.d.ts +2 -0
  31. package/dist/browser/src/document/utils/node.d.ts +9 -0
  32. package/dist/browser/src/document-model/custom/reducers/header.d.ts +2 -0
  33. package/dist/browser/src/document-model/custom/reducers/module.d.ts +2 -0
  34. package/dist/browser/src/document-model/custom/reducers/operation-error.d.ts +2 -0
  35. package/dist/browser/src/document-model/custom/reducers/operation-example.d.ts +2 -0
  36. package/dist/browser/src/document-model/custom/reducers/operation.d.ts +2 -0
  37. package/dist/browser/src/document-model/custom/reducers/state.d.ts +2 -0
  38. package/dist/browser/src/document-model/custom/reducers/versioning.d.ts +7 -0
  39. package/dist/browser/src/document-model/custom/utils.d.ts +1 -0
  40. package/dist/browser/src/document-model/gen/actions.d.ts +15 -0
  41. package/dist/browser/src/document-model/gen/creators.d.ts +7 -0
  42. package/dist/browser/src/document-model/gen/document-model.d.ts +2 -0
  43. package/dist/browser/src/document-model/gen/header/actions.d.ts +9 -0
  44. package/dist/browser/src/document-model/gen/header/creators.d.ts +8 -0
  45. package/dist/browser/src/document-model/gen/header/object.d.ts +12 -0
  46. package/dist/browser/src/document-model/gen/header/operations.d.ts +10 -0
  47. package/dist/browser/src/document-model/gen/index.d.ts +5 -0
  48. package/dist/browser/src/document-model/gen/module/actions.d.ts +8 -0
  49. package/dist/browser/src/document-model/gen/module/creators.d.ts +7 -0
  50. package/dist/browser/src/document-model/gen/module/object.d.ts +11 -0
  51. package/dist/browser/src/document-model/gen/module/operations.d.ts +9 -0
  52. package/dist/browser/src/document-model/gen/object.d.ts +28 -0
  53. package/dist/browser/src/document-model/gen/operation/actions.d.ts +13 -0
  54. package/dist/browser/src/document-model/gen/operation/creators.d.ts +12 -0
  55. package/dist/browser/src/document-model/gen/operation/object.d.ts +16 -0
  56. package/dist/browser/src/document-model/gen/operation/operations.d.ts +14 -0
  57. package/dist/browser/src/document-model/gen/operation-error/actions.d.ts +10 -0
  58. package/dist/browser/src/document-model/gen/operation-error/creators.d.ts +9 -0
  59. package/dist/browser/src/document-model/gen/operation-error/object.d.ts +13 -0
  60. package/dist/browser/src/document-model/gen/operation-error/operations.d.ts +11 -0
  61. package/dist/browser/src/document-model/gen/operation-example/actions.d.ts +7 -0
  62. package/dist/browser/src/document-model/gen/operation-example/creators.d.ts +6 -0
  63. package/dist/browser/src/document-model/gen/operation-example/object.d.ts +10 -0
  64. package/dist/browser/src/document-model/gen/operation-example/operations.d.ts +8 -0
  65. package/dist/browser/src/document-model/gen/reducer.d.ts +5 -0
  66. package/dist/browser/src/document-model/gen/schema/index.d.ts +2 -0
  67. package/dist/browser/src/document-model/gen/schema/types.d.ts +453 -0
  68. package/dist/browser/src/document-model/gen/schema/zod.d.ts +453 -0
  69. package/dist/browser/src/document-model/gen/state/actions.d.ts +9 -0
  70. package/dist/browser/src/document-model/gen/state/creators.d.ts +8 -0
  71. package/dist/browser/src/document-model/gen/state/object.d.ts +12 -0
  72. package/dist/browser/src/document-model/gen/state/operations.d.ts +10 -0
  73. package/dist/browser/src/document-model/gen/types.d.ts +8 -0
  74. package/dist/browser/src/document-model/gen/utils.d.ts +6 -0
  75. package/dist/browser/src/document-model/gen/versioning/actions.d.ts +8 -0
  76. package/dist/browser/src/document-model/gen/versioning/creators.d.ts +7 -0
  77. package/dist/browser/src/document-model/gen/versioning/object.d.ts +11 -0
  78. package/dist/browser/src/document-model/gen/versioning/operations.d.ts +9 -0
  79. package/dist/browser/src/document-model/index.d.ts +75 -0
  80. package/dist/browser/src/index.d.ts +25 -0
  81. package/dist/browser/test/document/local.test.d.ts +1 -0
  82. package/dist/browser/test/document/object.test.d.ts +1 -0
  83. package/dist/browser/test/document/prune.test.d.ts +1 -0
  84. package/dist/browser/test/document/redo.test.d.ts +1 -0
  85. package/dist/browser/test/document/reducer.test.d.ts +1 -0
  86. package/dist/browser/test/document/skip-operations.test.d.ts +1 -0
  87. package/dist/browser/test/document/undo.test.d.ts +1 -0
  88. package/dist/browser/test/document/utils.test.d.ts +1 -0
  89. package/dist/browser/test/document-model/object.test.d.ts +1 -0
  90. package/dist/browser/test/document-model/skip-operations.test.d.ts +1 -0
  91. package/dist/browser/test/document-model/zip.test.d.ts +1 -0
  92. package/dist/browser/test/helpers.d.ts +32 -0
  93. package/dist/browser/vite.config.d.ts +2 -0
  94. package/dist/node/document-model.cjs +1 -0
  95. package/dist/node/document-model.d.ts +1 -0
  96. package/dist/node/document-model.js +20 -0
  97. package/dist/node/document.cjs +1 -0
  98. package/dist/node/document.d.ts +1 -0
  99. package/dist/node/document.js +18 -0
  100. package/dist/node/index.cjs +1 -0
  101. package/dist/node/index.d.ts +3 -0
  102. package/dist/node/index.js +21 -0
  103. package/dist/node/internal/index-ac24dd92.js +36 -0
  104. package/dist/node/internal/index-c75a9c7a.js +1 -0
  105. package/dist/node/internal/index-e9f12d45.js +1932 -0
  106. package/dist/node/internal/index-f04f94a6.js +22 -0
  107. package/dist/node/internal/object-10b89c54.js +1 -0
  108. package/dist/node/internal/object-cb276649.js +833 -0
  109. package/dist/node/jest.config.d.ts +8 -0
  110. package/dist/node/src/document/actions/creators.d.ts +47 -0
  111. package/dist/node/src/document/actions/index.d.ts +10 -0
  112. package/dist/node/src/document/actions/types.d.ts +8 -0
  113. package/dist/node/src/document/index.d.ts +6 -0
  114. package/dist/node/src/document/object.d.ts +447 -0
  115. package/dist/node/src/document/reducer.d.ts +16 -0
  116. package/dist/node/src/document/schema/index.d.ts +2 -0
  117. package/dist/node/src/document/schema/types.d.ts +180 -0
  118. package/dist/node/src/document/schema/zod.d.ts +113 -0
  119. package/dist/node/src/document/signal.d.ts +28 -0
  120. package/dist/node/src/document/types.d.ts +201 -0
  121. package/dist/node/src/document/utils/base.d.ts +74 -0
  122. package/dist/node/src/document/utils/file.d.ts +47 -0
  123. package/dist/node/src/document/utils/index.d.ts +2 -0
  124. package/dist/node/src/document/utils/node.d.ts +9 -0
  125. package/dist/node/src/document-model/custom/reducers/header.d.ts +2 -0
  126. package/dist/node/src/document-model/custom/reducers/module.d.ts +2 -0
  127. package/dist/node/src/document-model/custom/reducers/operation-error.d.ts +2 -0
  128. package/dist/node/src/document-model/custom/reducers/operation-example.d.ts +2 -0
  129. package/dist/node/src/document-model/custom/reducers/operation.d.ts +2 -0
  130. package/dist/node/src/document-model/custom/reducers/state.d.ts +2 -0
  131. package/dist/node/src/document-model/custom/reducers/versioning.d.ts +7 -0
  132. package/dist/node/src/document-model/custom/utils.d.ts +1 -0
  133. package/dist/node/src/document-model/gen/actions.d.ts +15 -0
  134. package/dist/node/src/document-model/gen/creators.d.ts +7 -0
  135. package/dist/node/src/document-model/gen/document-model.d.ts +2 -0
  136. package/dist/node/src/document-model/gen/header/actions.d.ts +9 -0
  137. package/dist/node/src/document-model/gen/header/creators.d.ts +8 -0
  138. package/dist/node/src/document-model/gen/header/object.d.ts +12 -0
  139. package/dist/node/src/document-model/gen/header/operations.d.ts +10 -0
  140. package/dist/node/src/document-model/gen/index.d.ts +5 -0
  141. package/dist/node/src/document-model/gen/module/actions.d.ts +8 -0
  142. package/dist/node/src/document-model/gen/module/creators.d.ts +7 -0
  143. package/dist/node/src/document-model/gen/module/object.d.ts +11 -0
  144. package/dist/node/src/document-model/gen/module/operations.d.ts +9 -0
  145. package/dist/node/src/document-model/gen/object.d.ts +28 -0
  146. package/dist/node/src/document-model/gen/operation/actions.d.ts +13 -0
  147. package/dist/node/src/document-model/gen/operation/creators.d.ts +12 -0
  148. package/dist/node/src/document-model/gen/operation/object.d.ts +16 -0
  149. package/dist/node/src/document-model/gen/operation/operations.d.ts +14 -0
  150. package/dist/node/src/document-model/gen/operation-error/actions.d.ts +10 -0
  151. package/dist/node/src/document-model/gen/operation-error/creators.d.ts +9 -0
  152. package/dist/node/src/document-model/gen/operation-error/object.d.ts +13 -0
  153. package/dist/node/src/document-model/gen/operation-error/operations.d.ts +11 -0
  154. package/dist/node/src/document-model/gen/operation-example/actions.d.ts +7 -0
  155. package/dist/node/src/document-model/gen/operation-example/creators.d.ts +6 -0
  156. package/dist/node/src/document-model/gen/operation-example/object.d.ts +10 -0
  157. package/dist/node/src/document-model/gen/operation-example/operations.d.ts +8 -0
  158. package/dist/node/src/document-model/gen/reducer.d.ts +5 -0
  159. package/dist/node/src/document-model/gen/schema/index.d.ts +2 -0
  160. package/dist/node/src/document-model/gen/schema/types.d.ts +453 -0
  161. package/dist/node/src/document-model/gen/schema/zod.d.ts +453 -0
  162. package/dist/node/src/document-model/gen/state/actions.d.ts +9 -0
  163. package/dist/node/src/document-model/gen/state/creators.d.ts +8 -0
  164. package/dist/node/src/document-model/gen/state/object.d.ts +12 -0
  165. package/dist/node/src/document-model/gen/state/operations.d.ts +10 -0
  166. package/dist/node/src/document-model/gen/types.d.ts +8 -0
  167. package/dist/node/src/document-model/gen/utils.d.ts +6 -0
  168. package/dist/node/src/document-model/gen/versioning/actions.d.ts +8 -0
  169. package/dist/node/src/document-model/gen/versioning/creators.d.ts +7 -0
  170. package/dist/node/src/document-model/gen/versioning/object.d.ts +11 -0
  171. package/dist/node/src/document-model/gen/versioning/operations.d.ts +9 -0
  172. package/dist/node/src/document-model/index.d.ts +75 -0
  173. package/dist/node/src/index.d.ts +25 -0
  174. package/dist/node/test/document/local.test.d.ts +1 -0
  175. package/dist/node/test/document/object.test.d.ts +1 -0
  176. package/dist/node/test/document/prune.test.d.ts +1 -0
  177. package/dist/node/test/document/redo.test.d.ts +1 -0
  178. package/dist/node/test/document/reducer.test.d.ts +1 -0
  179. package/dist/node/test/document/skip-operations.test.d.ts +1 -0
  180. package/dist/node/test/document/undo.test.d.ts +1 -0
  181. package/dist/node/test/document/utils.test.d.ts +1 -0
  182. package/dist/node/test/document-model/object.test.d.ts +1 -0
  183. package/dist/node/test/document-model/skip-operations.test.d.ts +1 -0
  184. package/dist/node/test/document-model/zip.test.d.ts +1 -0
  185. package/dist/node/test/helpers.d.ts +32 -0
  186. package/dist/node/vite.config.d.ts +2 -0
  187. package/package.json +1 -1
@@ -0,0 +1,1831 @@
1
+ var _r = Object.defineProperty;
2
+ var Fr = (i, a, p) => a in i ? _r(i, a, { enumerable: !0, configurable: !0, writable: !0, value: p }) : i[a] = p;
3
+ var W = (i, a, p) => (Fr(i, typeof a != "symbol" ? a + "" : a, p), p);
4
+ import Ar from "json-stringify-deterministic";
5
+ import { produce as _t, castDraft as Sr, castImmutable as Br, freeze as jr } from "immer";
6
+ import { z as d } from "zod";
7
+ import St from "jszip";
8
+ const Bt = (i) => i != null, Ir = d.any().refine((i) => Bt(i)), jt = d.enum(["LOAD_STATE"]), It = d.enum(["PRUNE"]), Ut = d.enum(["REDO"]), kt = d.enum(["SET_NAME"]), Tt = d.enum(["UNDO"]);
9
+ function Ur() {
10
+ return d.object({
11
+ __typename: d.literal("Action").optional(),
12
+ type: d.string()
13
+ });
14
+ }
15
+ function C() {
16
+ return d.literal("global").or(d.literal("local"));
17
+ }
18
+ function Ot() {
19
+ return d.union([
20
+ Dt(),
21
+ Mt(),
22
+ Rt(),
23
+ Ct(),
24
+ Lt()
25
+ ]);
26
+ }
27
+ function kr() {
28
+ return d.object({
29
+ __typename: d.literal("DocumentFile").optional(),
30
+ data: d.string(),
31
+ extension: d.string().nullable(),
32
+ fileName: d.string().nullable(),
33
+ mimeType: d.string()
34
+ });
35
+ }
36
+ function Dt() {
37
+ return d.object({
38
+ input: d.lazy(() => nt()),
39
+ type: jt,
40
+ scope: C()
41
+ });
42
+ }
43
+ function nt() {
44
+ return d.object({
45
+ operations: d.number(),
46
+ state: d.lazy(() => Nt())
47
+ });
48
+ }
49
+ function Nt() {
50
+ return d.object({
51
+ data: d.unknown().nullish(),
52
+ name: d.string()
53
+ });
54
+ }
55
+ function Tr() {
56
+ return d.object({
57
+ __typename: d.literal("Operation").optional(),
58
+ hash: d.string(),
59
+ index: d.number(),
60
+ timestamp: d.string().datetime(),
61
+ type: d.string()
62
+ });
63
+ }
64
+ function Mt() {
65
+ return d.object({
66
+ input: d.lazy(() => at()),
67
+ type: It,
68
+ scope: C()
69
+ });
70
+ }
71
+ function at() {
72
+ return d.object({
73
+ end: d.number().nullish(),
74
+ start: d.number().nullish()
75
+ });
76
+ }
77
+ const ot = d.number;
78
+ function Rt() {
79
+ return d.object({
80
+ input: ot(),
81
+ type: Ut,
82
+ scope: C()
83
+ });
84
+ }
85
+ const pt = d.string;
86
+ function Ct() {
87
+ return d.object({
88
+ input: pt(),
89
+ type: kt,
90
+ scope: d.literal("global")
91
+ });
92
+ }
93
+ function Or() {
94
+ return d.object({
95
+ __typename: d.literal("SetNameOperation").optional(),
96
+ hash: d.string(),
97
+ index: d.number(),
98
+ input: d.string(),
99
+ timestamp: d.string().datetime(),
100
+ type: d.string()
101
+ });
102
+ }
103
+ const st = d.number;
104
+ function Lt() {
105
+ return d.object({
106
+ input: st(),
107
+ type: Tt,
108
+ scope: C()
109
+ });
110
+ }
111
+ const Te = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
112
+ __proto__: null,
113
+ ActionSchema: Ur,
114
+ BaseActionSchema: Ot,
115
+ DocumentFileSchema: kr,
116
+ LoadStateActionInputSchema: nt,
117
+ LoadStateActionSchema: Dt,
118
+ LoadStateActionStateInputSchema: Nt,
119
+ Load_StateSchema: jt,
120
+ OperationSchema: Tr,
121
+ OperationScopeSchema: C,
122
+ PruneActionInputSchema: at,
123
+ PruneActionSchema: Mt,
124
+ PruneSchema: It,
125
+ RedoActionInputSchema: ot,
126
+ RedoActionSchema: Rt,
127
+ RedoSchema: Ut,
128
+ SetNameActionInputSchema: pt,
129
+ SetNameActionSchema: Ct,
130
+ SetNameOperationSchema: Or,
131
+ Set_NameSchema: kt,
132
+ UndoActionInputSchema: st,
133
+ UndoActionSchema: Lt,
134
+ UndoSchema: Tt,
135
+ definedNonNullAnySchema: Ir,
136
+ isDefinedNonNullAny: Bt
137
+ }, Symbol.toStringTag, { value: "Module" }));
138
+ function Dr(i, a) {
139
+ return { ...i, name: a };
140
+ }
141
+ function Nr(i, a, p) {
142
+ const { scope: c, input: u } = a, f = i.revision[a.scope], l = Math.min(u, f), o = i.operations[c].slice(
143
+ 0,
144
+ f - l
145
+ );
146
+ return {
147
+ ...Z(
148
+ i.initialState,
149
+ {
150
+ ...i.operations,
151
+ [c]: o
152
+ },
153
+ p
154
+ ),
155
+ operations: i.operations,
156
+ revision: {
157
+ ...i.revision,
158
+ [c]: i.revision[c] - l
159
+ }
160
+ };
161
+ }
162
+ function Mr(i, a, p) {
163
+ const { scope: c, input: u } = a, f = i.operations[c].length - i.revision[c];
164
+ if (!f)
165
+ throw new Error("There is no UNDO operation to REDO");
166
+ const l = u < f ? u : f, o = i.operations[c].slice(
167
+ 0,
168
+ i.revision[c] + l
169
+ );
170
+ return {
171
+ ...Z(
172
+ i.initialState,
173
+ {
174
+ ...i.operations,
175
+ [c]: o
176
+ },
177
+ p
178
+ ),
179
+ operations: i.operations,
180
+ revision: {
181
+ ...i.revision,
182
+ [c]: i.revision[c] + l
183
+ }
184
+ };
185
+ }
186
+ function Rr(i, a, p) {
187
+ const { scope: c } = a, u = i.operations[c];
188
+ let {
189
+ input: { start: f, end: l }
190
+ } = a;
191
+ f = f || 0, l = l || u.length;
192
+ const o = u.slice(f, l), x = u.slice(0, f), g = u.slice(l), w = Z(
193
+ i.initialState,
194
+ {
195
+ ...i.operations,
196
+ [c]: x.concat(o)
197
+ },
198
+ p
199
+ ), { name: v, state: E } = w, A = x.length, U = x.length ? x[x.length - 1].timestamp : g.length ? g[0].timestamp : (/* @__PURE__ */ new Date()).toISOString();
200
+ return Z(
201
+ i.initialState,
202
+ {
203
+ ...i.operations,
204
+ [c]: [
205
+ ...x,
206
+ {
207
+ ...ut(
208
+ { name: v, state: E },
209
+ o.length
210
+ ),
211
+ timestamp: U,
212
+ index: A,
213
+ hash: Vt({ state: E }, "global")
214
+ },
215
+ ...g.map((O, N) => ({
216
+ ...O,
217
+ index: A + N + 1
218
+ }))
219
+ ]
220
+ },
221
+ p
222
+ );
223
+ }
224
+ function Cr(i, a) {
225
+ return {
226
+ ...i,
227
+ name: a.name,
228
+ state: a.state ?? { global: {}, local: {} }
229
+ };
230
+ }
231
+ const zt = "SET_NAME", L = "UNDO", z = "REDO", q = "PRUNE", qt = "LOAD_STATE";
232
+ function $t(i) {
233
+ return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
234
+ }
235
+ function Y() {
236
+ this._types = /* @__PURE__ */ Object.create(null), this._extensions = /* @__PURE__ */ Object.create(null);
237
+ for (let i = 0; i < arguments.length; i++)
238
+ this.define(arguments[i]);
239
+ this.define = this.define.bind(this), this.getType = this.getType.bind(this), this.getExtension = this.getExtension.bind(this);
240
+ }
241
+ Y.prototype.define = function(i, a) {
242
+ for (let p in i) {
243
+ let c = i[p].map(function(u) {
244
+ return u.toLowerCase();
245
+ });
246
+ p = p.toLowerCase();
247
+ for (let u = 0; u < c.length; u++) {
248
+ const f = c[u];
249
+ if (f[0] !== "*") {
250
+ if (!a && f in this._types)
251
+ throw new Error(
252
+ 'Attempt to change mapping for "' + f + '" extension from "' + this._types[f] + '" to "' + p + '". Pass `force=true` to allow this, otherwise remove "' + f + '" from the list of extensions for "' + p + '".'
253
+ );
254
+ this._types[f] = p;
255
+ }
256
+ }
257
+ if (a || !this._extensions[p]) {
258
+ const u = c[0];
259
+ this._extensions[p] = u[0] !== "*" ? u : u.substr(1);
260
+ }
261
+ }
262
+ };
263
+ Y.prototype.getType = function(i) {
264
+ i = String(i);
265
+ let a = i.replace(/^.*[/\\]/, "").toLowerCase(), p = a.replace(/^.*\./, "").toLowerCase(), c = a.length < i.length;
266
+ return (p.length < a.length - 1 || !c) && this._types[p] || null;
267
+ };
268
+ Y.prototype.getExtension = function(i) {
269
+ return i = /^\s*([^;\s]*)/.test(i) && RegExp.$1, i && this._extensions[i.toLowerCase()] || null;
270
+ };
271
+ var Lr = Y, zr = { "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"] };
272
+ let qr = Lr;
273
+ var $r = new qr(zr);
274
+ const Pr = /* @__PURE__ */ $t($r);
275
+ var et = { exports: {} };
276
+ typeof Object.create == "function" ? et.exports = function(a, p) {
277
+ p && (a.super_ = p, a.prototype = Object.create(p.prototype, {
278
+ constructor: {
279
+ value: a,
280
+ enumerable: !1,
281
+ writable: !0,
282
+ configurable: !0
283
+ }
284
+ }));
285
+ } : et.exports = function(a, p) {
286
+ if (p) {
287
+ a.super_ = p;
288
+ var c = function() {
289
+ };
290
+ c.prototype = p.prototype, a.prototype = new c(), a.prototype.constructor = a;
291
+ }
292
+ };
293
+ var Jr = et.exports, it = { exports: {} }, Pt = {}, K = {};
294
+ K.byteLength = Zr;
295
+ K.toByteArray = Kr;
296
+ K.fromByteArray = Vr;
297
+ var T = [], I = [], Wr = typeof Uint8Array < "u" ? Uint8Array : Array, rt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
298
+ for (var M = 0, Hr = rt.length; M < Hr; ++M)
299
+ T[M] = rt[M], I[rt.charCodeAt(M)] = M;
300
+ I["-".charCodeAt(0)] = 62;
301
+ I["_".charCodeAt(0)] = 63;
302
+ function Jt(i) {
303
+ var a = i.length;
304
+ if (a % 4 > 0)
305
+ throw new Error("Invalid string. Length must be a multiple of 4");
306
+ var p = i.indexOf("=");
307
+ p === -1 && (p = a);
308
+ var c = p === a ? 0 : 4 - p % 4;
309
+ return [p, c];
310
+ }
311
+ function Zr(i) {
312
+ var a = Jt(i), p = a[0], c = a[1];
313
+ return (p + c) * 3 / 4 - c;
314
+ }
315
+ function Yr(i, a, p) {
316
+ return (a + p) * 3 / 4 - p;
317
+ }
318
+ function Kr(i) {
319
+ var a, p = Jt(i), c = p[0], u = p[1], f = new Wr(Yr(i, c, u)), l = 0, o = u > 0 ? c - 4 : c, x;
320
+ for (x = 0; x < o; x += 4)
321
+ a = I[i.charCodeAt(x)] << 18 | I[i.charCodeAt(x + 1)] << 12 | I[i.charCodeAt(x + 2)] << 6 | I[i.charCodeAt(x + 3)], f[l++] = a >> 16 & 255, f[l++] = a >> 8 & 255, f[l++] = a & 255;
322
+ return u === 2 && (a = I[i.charCodeAt(x)] << 2 | I[i.charCodeAt(x + 1)] >> 4, f[l++] = a & 255), u === 1 && (a = I[i.charCodeAt(x)] << 10 | I[i.charCodeAt(x + 1)] << 4 | I[i.charCodeAt(x + 2)] >> 2, f[l++] = a >> 8 & 255, f[l++] = a & 255), f;
323
+ }
324
+ function Xr(i) {
325
+ return T[i >> 18 & 63] + T[i >> 12 & 63] + T[i >> 6 & 63] + T[i & 63];
326
+ }
327
+ function Gr(i, a, p) {
328
+ for (var c, u = [], f = a; f < p; f += 3)
329
+ c = (i[f] << 16 & 16711680) + (i[f + 1] << 8 & 65280) + (i[f + 2] & 255), u.push(Xr(c));
330
+ return u.join("");
331
+ }
332
+ function Vr(i) {
333
+ for (var a, p = i.length, c = p % 3, u = [], f = 16383, l = 0, o = p - c; l < o; l += f)
334
+ u.push(Gr(i, l, l + f > o ? o : l + f));
335
+ return c === 1 ? (a = i[p - 1], u.push(
336
+ T[a >> 2] + T[a << 4 & 63] + "=="
337
+ )) : c === 2 && (a = (i[p - 2] << 8) + i[p - 1], u.push(
338
+ T[a >> 10] + T[a >> 4 & 63] + T[a << 2 & 63] + "="
339
+ )), u.join("");
340
+ }
341
+ var ct = {};
342
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
343
+ ct.read = function(i, a, p, c, u) {
344
+ var f, l, o = u * 8 - c - 1, x = (1 << o) - 1, g = x >> 1, w = -7, v = p ? u - 1 : 0, E = p ? -1 : 1, A = i[a + v];
345
+ for (v += E, f = A & (1 << -w) - 1, A >>= -w, w += o; w > 0; f = f * 256 + i[a + v], v += E, w -= 8)
346
+ ;
347
+ for (l = f & (1 << -w) - 1, f >>= -w, w += c; w > 0; l = l * 256 + i[a + v], v += E, w -= 8)
348
+ ;
349
+ if (f === 0)
350
+ f = 1 - g;
351
+ else {
352
+ if (f === x)
353
+ return l ? NaN : (A ? -1 : 1) * (1 / 0);
354
+ l = l + Math.pow(2, c), f = f - g;
355
+ }
356
+ return (A ? -1 : 1) * l * Math.pow(2, f - c);
357
+ };
358
+ ct.write = function(i, a, p, c, u, f) {
359
+ var l, o, x, g = f * 8 - u - 1, w = (1 << g) - 1, v = w >> 1, E = u === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, A = c ? 0 : f - 1, U = c ? 1 : -1, O = a < 0 || a === 0 && 1 / a < 0 ? 1 : 0;
360
+ for (a = Math.abs(a), isNaN(a) || a === 1 / 0 ? (o = isNaN(a) ? 1 : 0, l = w) : (l = Math.floor(Math.log(a) / Math.LN2), a * (x = Math.pow(2, -l)) < 1 && (l--, x *= 2), l + v >= 1 ? a += E / x : a += E * Math.pow(2, 1 - v), a * x >= 2 && (l++, x /= 2), l + v >= w ? (o = 0, l = w) : l + v >= 1 ? (o = (a * x - 1) * Math.pow(2, u), l = l + v) : (o = a * Math.pow(2, v - 1) * Math.pow(2, u), l = 0)); u >= 8; i[p + A] = o & 255, A += U, o /= 256, u -= 8)
361
+ ;
362
+ for (l = l << u | o, g += u; g > 0; i[p + A] = l & 255, A += U, l /= 256, g -= 8)
363
+ ;
364
+ i[p + A - U] |= O * 128;
365
+ };
366
+ /*!
367
+ * The buffer module from node.js, for the browser.
368
+ *
369
+ * @author Feross Aboukhadijeh <https://feross.org>
370
+ * @license MIT
371
+ */
372
+ (function(i) {
373
+ var a = K, p = ct, c = typeof Symbol == "function" && typeof Symbol.for == "function" ? Symbol.for("nodejs.util.inspect.custom") : null;
374
+ i.Buffer = o, i.SlowBuffer = ar, i.INSPECT_MAX_BYTES = 50;
375
+ var u = 2147483647;
376
+ i.kMaxLength = u, o.TYPED_ARRAY_SUPPORT = f(), !o.TYPED_ARRAY_SUPPORT && typeof console < "u" && typeof console.error == "function" && console.error(
377
+ "This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."
378
+ );
379
+ function f() {
380
+ try {
381
+ var e = new Uint8Array(1), t = { foo: function() {
382
+ return 42;
383
+ } };
384
+ return Object.setPrototypeOf(t, Uint8Array.prototype), Object.setPrototypeOf(e, t), e.foo() === 42;
385
+ } catch {
386
+ return !1;
387
+ }
388
+ }
389
+ Object.defineProperty(o.prototype, "parent", {
390
+ enumerable: !0,
391
+ get: function() {
392
+ if (o.isBuffer(this))
393
+ return this.buffer;
394
+ }
395
+ }), Object.defineProperty(o.prototype, "offset", {
396
+ enumerable: !0,
397
+ get: function() {
398
+ if (o.isBuffer(this))
399
+ return this.byteOffset;
400
+ }
401
+ });
402
+ function l(e) {
403
+ if (e > u)
404
+ throw new RangeError('The value "' + e + '" is invalid for option "size"');
405
+ var t = new Uint8Array(e);
406
+ return Object.setPrototypeOf(t, o.prototype), t;
407
+ }
408
+ function o(e, t, r) {
409
+ if (typeof e == "number") {
410
+ if (typeof t == "string")
411
+ throw new TypeError(
412
+ 'The "string" argument must be of type string. Received type number'
413
+ );
414
+ return v(e);
415
+ }
416
+ return x(e, t, r);
417
+ }
418
+ o.poolSize = 8192;
419
+ function x(e, t, r) {
420
+ if (typeof e == "string")
421
+ return E(e, t);
422
+ if (ArrayBuffer.isView(e))
423
+ return U(e);
424
+ if (e == null)
425
+ throw new TypeError(
426
+ "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof e
427
+ );
428
+ if (k(e, ArrayBuffer) || e && k(e.buffer, ArrayBuffer) || typeof SharedArrayBuffer < "u" && (k(e, SharedArrayBuffer) || e && k(e.buffer, SharedArrayBuffer)))
429
+ return O(e, t, r);
430
+ if (typeof e == "number")
431
+ throw new TypeError(
432
+ 'The "value" argument must not be of type number. Received type number'
433
+ );
434
+ var n = e.valueOf && e.valueOf();
435
+ if (n != null && n !== e)
436
+ return o.from(n, t, r);
437
+ var s = N(e);
438
+ if (s)
439
+ return s;
440
+ if (typeof Symbol < "u" && Symbol.toPrimitive != null && typeof e[Symbol.toPrimitive] == "function")
441
+ return o.from(
442
+ e[Symbol.toPrimitive]("string"),
443
+ t,
444
+ r
445
+ );
446
+ throw new TypeError(
447
+ "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof e
448
+ );
449
+ }
450
+ o.from = function(e, t, r) {
451
+ return x(e, t, r);
452
+ }, Object.setPrototypeOf(o.prototype, Uint8Array.prototype), Object.setPrototypeOf(o, Uint8Array);
453
+ function g(e) {
454
+ if (typeof e != "number")
455
+ throw new TypeError('"size" argument must be of type number');
456
+ if (e < 0)
457
+ throw new RangeError('The value "' + e + '" is invalid for option "size"');
458
+ }
459
+ function w(e, t, r) {
460
+ return g(e), e <= 0 ? l(e) : t !== void 0 ? typeof r == "string" ? l(e).fill(t, r) : l(e).fill(t) : l(e);
461
+ }
462
+ o.alloc = function(e, t, r) {
463
+ return w(e, t, r);
464
+ };
465
+ function v(e) {
466
+ return g(e), l(e < 0 ? 0 : V(e) | 0);
467
+ }
468
+ o.allocUnsafe = function(e) {
469
+ return v(e);
470
+ }, o.allocUnsafeSlow = function(e) {
471
+ return v(e);
472
+ };
473
+ function E(e, t) {
474
+ if ((typeof t != "string" || t === "") && (t = "utf8"), !o.isEncoding(t))
475
+ throw new TypeError("Unknown encoding: " + t);
476
+ var r = ft(e, t) | 0, n = l(r), s = n.write(e, t);
477
+ return s !== r && (n = n.slice(0, s)), n;
478
+ }
479
+ function A(e) {
480
+ for (var t = e.length < 0 ? 0 : V(e.length) | 0, r = l(t), n = 0; n < t; n += 1)
481
+ r[n] = e[n] & 255;
482
+ return r;
483
+ }
484
+ function U(e) {
485
+ if (k(e, Uint8Array)) {
486
+ var t = new Uint8Array(e);
487
+ return O(t.buffer, t.byteOffset, t.byteLength);
488
+ }
489
+ return A(e);
490
+ }
491
+ function O(e, t, r) {
492
+ if (t < 0 || e.byteLength < t)
493
+ throw new RangeError('"offset" is outside of buffer bounds');
494
+ if (e.byteLength < t + (r || 0))
495
+ throw new RangeError('"length" is outside of buffer bounds');
496
+ var n;
497
+ return t === void 0 && r === void 0 ? n = new Uint8Array(e) : r === void 0 ? n = new Uint8Array(e, t) : n = new Uint8Array(e, t, r), Object.setPrototypeOf(n, o.prototype), n;
498
+ }
499
+ function N(e) {
500
+ if (o.isBuffer(e)) {
501
+ var t = V(e.length) | 0, r = l(t);
502
+ return r.length === 0 || e.copy(r, 0, 0, t), r;
503
+ }
504
+ if (e.length !== void 0)
505
+ return typeof e.length != "number" || tt(e.length) ? l(0) : A(e);
506
+ if (e.type === "Buffer" && Array.isArray(e.data))
507
+ return A(e.data);
508
+ }
509
+ function V(e) {
510
+ if (e >= u)
511
+ throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + u.toString(16) + " bytes");
512
+ return e | 0;
513
+ }
514
+ function ar(e) {
515
+ return +e != e && (e = 0), o.alloc(+e);
516
+ }
517
+ o.isBuffer = function(t) {
518
+ return t != null && t._isBuffer === !0 && t !== o.prototype;
519
+ }, o.compare = function(t, r) {
520
+ if (k(t, Uint8Array) && (t = o.from(t, t.offset, t.byteLength)), k(r, Uint8Array) && (r = o.from(r, r.offset, r.byteLength)), !o.isBuffer(t) || !o.isBuffer(r))
521
+ throw new TypeError(
522
+ 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
523
+ );
524
+ if (t === r)
525
+ return 0;
526
+ for (var n = t.length, s = r.length, h = 0, m = Math.min(n, s); h < m; ++h)
527
+ if (t[h] !== r[h]) {
528
+ n = t[h], s = r[h];
529
+ break;
530
+ }
531
+ return n < s ? -1 : s < n ? 1 : 0;
532
+ }, o.isEncoding = function(t) {
533
+ switch (String(t).toLowerCase()) {
534
+ case "hex":
535
+ case "utf8":
536
+ case "utf-8":
537
+ case "ascii":
538
+ case "latin1":
539
+ case "binary":
540
+ case "base64":
541
+ case "ucs2":
542
+ case "ucs-2":
543
+ case "utf16le":
544
+ case "utf-16le":
545
+ return !0;
546
+ default:
547
+ return !1;
548
+ }
549
+ }, o.concat = function(t, r) {
550
+ if (!Array.isArray(t))
551
+ throw new TypeError('"list" argument must be an Array of Buffers');
552
+ if (t.length === 0)
553
+ return o.alloc(0);
554
+ var n;
555
+ if (r === void 0)
556
+ for (r = 0, n = 0; n < t.length; ++n)
557
+ r += t[n].length;
558
+ var s = o.allocUnsafe(r), h = 0;
559
+ for (n = 0; n < t.length; ++n) {
560
+ var m = t[n];
561
+ if (k(m, Uint8Array))
562
+ h + m.length > s.length ? o.from(m).copy(s, h) : Uint8Array.prototype.set.call(
563
+ s,
564
+ m,
565
+ h
566
+ );
567
+ else if (o.isBuffer(m))
568
+ m.copy(s, h);
569
+ else
570
+ throw new TypeError('"list" argument must be an Array of Buffers');
571
+ h += m.length;
572
+ }
573
+ return s;
574
+ };
575
+ function ft(e, t) {
576
+ if (o.isBuffer(e))
577
+ return e.length;
578
+ if (ArrayBuffer.isView(e) || k(e, ArrayBuffer))
579
+ return e.byteLength;
580
+ if (typeof e != "string")
581
+ throw new TypeError(
582
+ 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof e
583
+ );
584
+ var r = e.length, n = arguments.length > 2 && arguments[2] === !0;
585
+ if (!n && r === 0)
586
+ return 0;
587
+ for (var s = !1; ; )
588
+ switch (t) {
589
+ case "ascii":
590
+ case "latin1":
591
+ case "binary":
592
+ return r;
593
+ case "utf8":
594
+ case "utf-8":
595
+ return Q(e).length;
596
+ case "ucs2":
597
+ case "ucs-2":
598
+ case "utf16le":
599
+ case "utf-16le":
600
+ return r * 2;
601
+ case "hex":
602
+ return r >>> 1;
603
+ case "base64":
604
+ return vt(e).length;
605
+ default:
606
+ if (s)
607
+ return n ? -1 : Q(e).length;
608
+ t = ("" + t).toLowerCase(), s = !0;
609
+ }
610
+ }
611
+ o.byteLength = ft;
612
+ function or(e, t, r) {
613
+ var n = !1;
614
+ if ((t === void 0 || t < 0) && (t = 0), t > this.length || ((r === void 0 || r > this.length) && (r = this.length), r <= 0) || (r >>>= 0, t >>>= 0, r <= t))
615
+ return "";
616
+ for (e || (e = "utf8"); ; )
617
+ switch (e) {
618
+ case "hex":
619
+ return dr(this, t, r);
620
+ case "utf8":
621
+ case "utf-8":
622
+ return xt(this, t, r);
623
+ case "ascii":
624
+ return mr(this, t, r);
625
+ case "latin1":
626
+ case "binary":
627
+ return xr(this, t, r);
628
+ case "base64":
629
+ return fr(this, t, r);
630
+ case "ucs2":
631
+ case "ucs-2":
632
+ case "utf16le":
633
+ case "utf-16le":
634
+ return gr(this, t, r);
635
+ default:
636
+ if (n)
637
+ throw new TypeError("Unknown encoding: " + e);
638
+ e = (e + "").toLowerCase(), n = !0;
639
+ }
640
+ }
641
+ o.prototype._isBuffer = !0;
642
+ function D(e, t, r) {
643
+ var n = e[t];
644
+ e[t] = e[r], e[r] = n;
645
+ }
646
+ o.prototype.swap16 = function() {
647
+ var t = this.length;
648
+ if (t % 2 !== 0)
649
+ throw new RangeError("Buffer size must be a multiple of 16-bits");
650
+ for (var r = 0; r < t; r += 2)
651
+ D(this, r, r + 1);
652
+ return this;
653
+ }, o.prototype.swap32 = function() {
654
+ var t = this.length;
655
+ if (t % 4 !== 0)
656
+ throw new RangeError("Buffer size must be a multiple of 32-bits");
657
+ for (var r = 0; r < t; r += 4)
658
+ D(this, r, r + 3), D(this, r + 1, r + 2);
659
+ return this;
660
+ }, o.prototype.swap64 = function() {
661
+ var t = this.length;
662
+ if (t % 8 !== 0)
663
+ throw new RangeError("Buffer size must be a multiple of 64-bits");
664
+ for (var r = 0; r < t; r += 8)
665
+ D(this, r, r + 7), D(this, r + 1, r + 6), D(this, r + 2, r + 5), D(this, r + 3, r + 4);
666
+ return this;
667
+ }, o.prototype.toString = function() {
668
+ var t = this.length;
669
+ return t === 0 ? "" : arguments.length === 0 ? xt(this, 0, t) : or.apply(this, arguments);
670
+ }, o.prototype.toLocaleString = o.prototype.toString, o.prototype.equals = function(t) {
671
+ if (!o.isBuffer(t))
672
+ throw new TypeError("Argument must be a Buffer");
673
+ return this === t ? !0 : o.compare(this, t) === 0;
674
+ }, o.prototype.inspect = function() {
675
+ var t = "", r = i.INSPECT_MAX_BYTES;
676
+ return t = this.toString("hex", 0, r).replace(/(.{2})/g, "$1 ").trim(), this.length > r && (t += " ... "), "<Buffer " + t + ">";
677
+ }, c && (o.prototype[c] = o.prototype.inspect), o.prototype.compare = function(t, r, n, s, h) {
678
+ if (k(t, Uint8Array) && (t = o.from(t, t.offset, t.byteLength)), !o.isBuffer(t))
679
+ throw new TypeError(
680
+ 'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof t
681
+ );
682
+ if (r === void 0 && (r = 0), n === void 0 && (n = t ? t.length : 0), s === void 0 && (s = 0), h === void 0 && (h = this.length), r < 0 || n > t.length || s < 0 || h > this.length)
683
+ throw new RangeError("out of range index");
684
+ if (s >= h && r >= n)
685
+ return 0;
686
+ if (s >= h)
687
+ return -1;
688
+ if (r >= n)
689
+ return 1;
690
+ if (r >>>= 0, n >>>= 0, s >>>= 0, h >>>= 0, this === t)
691
+ return 0;
692
+ for (var m = h - s, y = n - r, b = Math.min(m, y), _ = this.slice(s, h), B = t.slice(r, n), F = 0; F < b; ++F)
693
+ if (_[F] !== B[F]) {
694
+ m = _[F], y = B[F];
695
+ break;
696
+ }
697
+ return m < y ? -1 : y < m ? 1 : 0;
698
+ };
699
+ function ht(e, t, r, n, s) {
700
+ if (e.length === 0)
701
+ return -1;
702
+ if (typeof r == "string" ? (n = r, r = 0) : r > 2147483647 ? r = 2147483647 : r < -2147483648 && (r = -2147483648), r = +r, tt(r) && (r = s ? 0 : e.length - 1), r < 0 && (r = e.length + r), r >= e.length) {
703
+ if (s)
704
+ return -1;
705
+ r = e.length - 1;
706
+ } else if (r < 0)
707
+ if (s)
708
+ r = 0;
709
+ else
710
+ return -1;
711
+ if (typeof t == "string" && (t = o.from(t, n)), o.isBuffer(t))
712
+ return t.length === 0 ? -1 : mt(e, t, r, n, s);
713
+ if (typeof t == "number")
714
+ return t = t & 255, typeof Uint8Array.prototype.indexOf == "function" ? s ? Uint8Array.prototype.indexOf.call(e, t, r) : Uint8Array.prototype.lastIndexOf.call(e, t, r) : mt(e, [t], r, n, s);
715
+ throw new TypeError("val must be string, number or Buffer");
716
+ }
717
+ function mt(e, t, r, n, s) {
718
+ var h = 1, m = e.length, y = t.length;
719
+ if (n !== void 0 && (n = String(n).toLowerCase(), n === "ucs2" || n === "ucs-2" || n === "utf16le" || n === "utf-16le")) {
720
+ if (e.length < 2 || t.length < 2)
721
+ return -1;
722
+ h = 2, m /= 2, y /= 2, r /= 2;
723
+ }
724
+ function b(Et, bt) {
725
+ return h === 1 ? Et[bt] : Et.readUInt16BE(bt * h);
726
+ }
727
+ var _;
728
+ if (s) {
729
+ var B = -1;
730
+ for (_ = r; _ < m; _++)
731
+ if (b(e, _) === b(t, B === -1 ? 0 : _ - B)) {
732
+ if (B === -1 && (B = _), _ - B + 1 === y)
733
+ return B * h;
734
+ } else
735
+ B !== -1 && (_ -= _ - B), B = -1;
736
+ } else
737
+ for (r + y > m && (r = m - y), _ = r; _ >= 0; _--) {
738
+ for (var F = !0, J = 0; J < y; J++)
739
+ if (b(e, _ + J) !== b(t, J)) {
740
+ F = !1;
741
+ break;
742
+ }
743
+ if (F)
744
+ return _;
745
+ }
746
+ return -1;
747
+ }
748
+ o.prototype.includes = function(t, r, n) {
749
+ return this.indexOf(t, r, n) !== -1;
750
+ }, o.prototype.indexOf = function(t, r, n) {
751
+ return ht(this, t, r, n, !0);
752
+ }, o.prototype.lastIndexOf = function(t, r, n) {
753
+ return ht(this, t, r, n, !1);
754
+ };
755
+ function pr(e, t, r, n) {
756
+ r = Number(r) || 0;
757
+ var s = e.length - r;
758
+ n ? (n = Number(n), n > s && (n = s)) : n = s;
759
+ var h = t.length;
760
+ n > h / 2 && (n = h / 2);
761
+ for (var m = 0; m < n; ++m) {
762
+ var y = parseInt(t.substr(m * 2, 2), 16);
763
+ if (tt(y))
764
+ return m;
765
+ e[r + m] = y;
766
+ }
767
+ return m;
768
+ }
769
+ function sr(e, t, r, n) {
770
+ return P(Q(t, e.length - r), e, r, n);
771
+ }
772
+ function cr(e, t, r, n) {
773
+ return P(vr(t), e, r, n);
774
+ }
775
+ function lr(e, t, r, n) {
776
+ return P(vt(t), e, r, n);
777
+ }
778
+ function ur(e, t, r, n) {
779
+ return P(Er(t, e.length - r), e, r, n);
780
+ }
781
+ o.prototype.write = function(t, r, n, s) {
782
+ if (r === void 0)
783
+ s = "utf8", n = this.length, r = 0;
784
+ else if (n === void 0 && typeof r == "string")
785
+ s = r, n = this.length, r = 0;
786
+ else if (isFinite(r))
787
+ r = r >>> 0, isFinite(n) ? (n = n >>> 0, s === void 0 && (s = "utf8")) : (s = n, n = void 0);
788
+ else
789
+ throw new Error(
790
+ "Buffer.write(string, encoding, offset[, length]) is no longer supported"
791
+ );
792
+ var h = this.length - r;
793
+ if ((n === void 0 || n > h) && (n = h), t.length > 0 && (n < 0 || r < 0) || r > this.length)
794
+ throw new RangeError("Attempt to write outside buffer bounds");
795
+ s || (s = "utf8");
796
+ for (var m = !1; ; )
797
+ switch (s) {
798
+ case "hex":
799
+ return pr(this, t, r, n);
800
+ case "utf8":
801
+ case "utf-8":
802
+ return sr(this, t, r, n);
803
+ case "ascii":
804
+ case "latin1":
805
+ case "binary":
806
+ return cr(this, t, r, n);
807
+ case "base64":
808
+ return lr(this, t, r, n);
809
+ case "ucs2":
810
+ case "ucs-2":
811
+ case "utf16le":
812
+ case "utf-16le":
813
+ return ur(this, t, r, n);
814
+ default:
815
+ if (m)
816
+ throw new TypeError("Unknown encoding: " + s);
817
+ s = ("" + s).toLowerCase(), m = !0;
818
+ }
819
+ }, o.prototype.toJSON = function() {
820
+ return {
821
+ type: "Buffer",
822
+ data: Array.prototype.slice.call(this._arr || this, 0)
823
+ };
824
+ };
825
+ function fr(e, t, r) {
826
+ return t === 0 && r === e.length ? a.fromByteArray(e) : a.fromByteArray(e.slice(t, r));
827
+ }
828
+ function xt(e, t, r) {
829
+ r = Math.min(e.length, r);
830
+ for (var n = [], s = t; s < r; ) {
831
+ var h = e[s], m = null, y = h > 239 ? 4 : h > 223 ? 3 : h > 191 ? 2 : 1;
832
+ if (s + y <= r) {
833
+ var b, _, B, F;
834
+ switch (y) {
835
+ case 1:
836
+ h < 128 && (m = h);
837
+ break;
838
+ case 2:
839
+ b = e[s + 1], (b & 192) === 128 && (F = (h & 31) << 6 | b & 63, F > 127 && (m = F));
840
+ break;
841
+ case 3:
842
+ b = e[s + 1], _ = e[s + 2], (b & 192) === 128 && (_ & 192) === 128 && (F = (h & 15) << 12 | (b & 63) << 6 | _ & 63, F > 2047 && (F < 55296 || F > 57343) && (m = F));
843
+ break;
844
+ case 4:
845
+ b = e[s + 1], _ = e[s + 2], B = e[s + 3], (b & 192) === 128 && (_ & 192) === 128 && (B & 192) === 128 && (F = (h & 15) << 18 | (b & 63) << 12 | (_ & 63) << 6 | B & 63, F > 65535 && F < 1114112 && (m = F));
846
+ }
847
+ }
848
+ m === null ? (m = 65533, y = 1) : m > 65535 && (m -= 65536, n.push(m >>> 10 & 1023 | 55296), m = 56320 | m & 1023), n.push(m), s += y;
849
+ }
850
+ return hr(n);
851
+ }
852
+ var dt = 4096;
853
+ function hr(e) {
854
+ var t = e.length;
855
+ if (t <= dt)
856
+ return String.fromCharCode.apply(String, e);
857
+ for (var r = "", n = 0; n < t; )
858
+ r += String.fromCharCode.apply(
859
+ String,
860
+ e.slice(n, n += dt)
861
+ );
862
+ return r;
863
+ }
864
+ function mr(e, t, r) {
865
+ var n = "";
866
+ r = Math.min(e.length, r);
867
+ for (var s = t; s < r; ++s)
868
+ n += String.fromCharCode(e[s] & 127);
869
+ return n;
870
+ }
871
+ function xr(e, t, r) {
872
+ var n = "";
873
+ r = Math.min(e.length, r);
874
+ for (var s = t; s < r; ++s)
875
+ n += String.fromCharCode(e[s]);
876
+ return n;
877
+ }
878
+ function dr(e, t, r) {
879
+ var n = e.length;
880
+ (!t || t < 0) && (t = 0), (!r || r < 0 || r > n) && (r = n);
881
+ for (var s = "", h = t; h < r; ++h)
882
+ s += br[e[h]];
883
+ return s;
884
+ }
885
+ function gr(e, t, r) {
886
+ for (var n = e.slice(t, r), s = "", h = 0; h < n.length - 1; h += 2)
887
+ s += String.fromCharCode(n[h] + n[h + 1] * 256);
888
+ return s;
889
+ }
890
+ o.prototype.slice = function(t, r) {
891
+ var n = this.length;
892
+ t = ~~t, r = r === void 0 ? n : ~~r, t < 0 ? (t += n, t < 0 && (t = 0)) : t > n && (t = n), r < 0 ? (r += n, r < 0 && (r = 0)) : r > n && (r = n), r < t && (r = t);
893
+ var s = this.subarray(t, r);
894
+ return Object.setPrototypeOf(s, o.prototype), s;
895
+ };
896
+ function S(e, t, r) {
897
+ if (e % 1 !== 0 || e < 0)
898
+ throw new RangeError("offset is not uint");
899
+ if (e + t > r)
900
+ throw new RangeError("Trying to access beyond buffer length");
901
+ }
902
+ o.prototype.readUintLE = o.prototype.readUIntLE = function(t, r, n) {
903
+ t = t >>> 0, r = r >>> 0, n || S(t, r, this.length);
904
+ for (var s = this[t], h = 1, m = 0; ++m < r && (h *= 256); )
905
+ s += this[t + m] * h;
906
+ return s;
907
+ }, o.prototype.readUintBE = o.prototype.readUIntBE = function(t, r, n) {
908
+ t = t >>> 0, r = r >>> 0, n || S(t, r, this.length);
909
+ for (var s = this[t + --r], h = 1; r > 0 && (h *= 256); )
910
+ s += this[t + --r] * h;
911
+ return s;
912
+ }, o.prototype.readUint8 = o.prototype.readUInt8 = function(t, r) {
913
+ return t = t >>> 0, r || S(t, 1, this.length), this[t];
914
+ }, o.prototype.readUint16LE = o.prototype.readUInt16LE = function(t, r) {
915
+ return t = t >>> 0, r || S(t, 2, this.length), this[t] | this[t + 1] << 8;
916
+ }, o.prototype.readUint16BE = o.prototype.readUInt16BE = function(t, r) {
917
+ return t = t >>> 0, r || S(t, 2, this.length), this[t] << 8 | this[t + 1];
918
+ }, o.prototype.readUint32LE = o.prototype.readUInt32LE = function(t, r) {
919
+ return t = t >>> 0, r || S(t, 4, this.length), (this[t] | this[t + 1] << 8 | this[t + 2] << 16) + this[t + 3] * 16777216;
920
+ }, o.prototype.readUint32BE = o.prototype.readUInt32BE = function(t, r) {
921
+ return t = t >>> 0, r || S(t, 4, this.length), this[t] * 16777216 + (this[t + 1] << 16 | this[t + 2] << 8 | this[t + 3]);
922
+ }, o.prototype.readIntLE = function(t, r, n) {
923
+ t = t >>> 0, r = r >>> 0, n || S(t, r, this.length);
924
+ for (var s = this[t], h = 1, m = 0; ++m < r && (h *= 256); )
925
+ s += this[t + m] * h;
926
+ return h *= 128, s >= h && (s -= Math.pow(2, 8 * r)), s;
927
+ }, o.prototype.readIntBE = function(t, r, n) {
928
+ t = t >>> 0, r = r >>> 0, n || S(t, r, this.length);
929
+ for (var s = r, h = 1, m = this[t + --s]; s > 0 && (h *= 256); )
930
+ m += this[t + --s] * h;
931
+ return h *= 128, m >= h && (m -= Math.pow(2, 8 * r)), m;
932
+ }, o.prototype.readInt8 = function(t, r) {
933
+ return t = t >>> 0, r || S(t, 1, this.length), this[t] & 128 ? (255 - this[t] + 1) * -1 : this[t];
934
+ }, o.prototype.readInt16LE = function(t, r) {
935
+ t = t >>> 0, r || S(t, 2, this.length);
936
+ var n = this[t] | this[t + 1] << 8;
937
+ return n & 32768 ? n | 4294901760 : n;
938
+ }, o.prototype.readInt16BE = function(t, r) {
939
+ t = t >>> 0, r || S(t, 2, this.length);
940
+ var n = this[t + 1] | this[t] << 8;
941
+ return n & 32768 ? n | 4294901760 : n;
942
+ }, o.prototype.readInt32LE = function(t, r) {
943
+ return t = t >>> 0, r || S(t, 4, this.length), this[t] | this[t + 1] << 8 | this[t + 2] << 16 | this[t + 3] << 24;
944
+ }, o.prototype.readInt32BE = function(t, r) {
945
+ return t = t >>> 0, r || S(t, 4, this.length), this[t] << 24 | this[t + 1] << 16 | this[t + 2] << 8 | this[t + 3];
946
+ }, o.prototype.readFloatLE = function(t, r) {
947
+ return t = t >>> 0, r || S(t, 4, this.length), p.read(this, t, !0, 23, 4);
948
+ }, o.prototype.readFloatBE = function(t, r) {
949
+ return t = t >>> 0, r || S(t, 4, this.length), p.read(this, t, !1, 23, 4);
950
+ }, o.prototype.readDoubleLE = function(t, r) {
951
+ return t = t >>> 0, r || S(t, 8, this.length), p.read(this, t, !0, 52, 8);
952
+ }, o.prototype.readDoubleBE = function(t, r) {
953
+ return t = t >>> 0, r || S(t, 8, this.length), p.read(this, t, !1, 52, 8);
954
+ };
955
+ function j(e, t, r, n, s, h) {
956
+ if (!o.isBuffer(e))
957
+ throw new TypeError('"buffer" argument must be a Buffer instance');
958
+ if (t > s || t < h)
959
+ throw new RangeError('"value" argument is out of bounds');
960
+ if (r + n > e.length)
961
+ throw new RangeError("Index out of range");
962
+ }
963
+ o.prototype.writeUintLE = o.prototype.writeUIntLE = function(t, r, n, s) {
964
+ if (t = +t, r = r >>> 0, n = n >>> 0, !s) {
965
+ var h = Math.pow(2, 8 * n) - 1;
966
+ j(this, t, r, n, h, 0);
967
+ }
968
+ var m = 1, y = 0;
969
+ for (this[r] = t & 255; ++y < n && (m *= 256); )
970
+ this[r + y] = t / m & 255;
971
+ return r + n;
972
+ }, o.prototype.writeUintBE = o.prototype.writeUIntBE = function(t, r, n, s) {
973
+ if (t = +t, r = r >>> 0, n = n >>> 0, !s) {
974
+ var h = Math.pow(2, 8 * n) - 1;
975
+ j(this, t, r, n, h, 0);
976
+ }
977
+ var m = n - 1, y = 1;
978
+ for (this[r + m] = t & 255; --m >= 0 && (y *= 256); )
979
+ this[r + m] = t / y & 255;
980
+ return r + n;
981
+ }, o.prototype.writeUint8 = o.prototype.writeUInt8 = function(t, r, n) {
982
+ return t = +t, r = r >>> 0, n || j(this, t, r, 1, 255, 0), this[r] = t & 255, r + 1;
983
+ }, o.prototype.writeUint16LE = o.prototype.writeUInt16LE = function(t, r, n) {
984
+ return t = +t, r = r >>> 0, n || j(this, t, r, 2, 65535, 0), this[r] = t & 255, this[r + 1] = t >>> 8, r + 2;
985
+ }, o.prototype.writeUint16BE = o.prototype.writeUInt16BE = function(t, r, n) {
986
+ return t = +t, r = r >>> 0, n || j(this, t, r, 2, 65535, 0), this[r] = t >>> 8, this[r + 1] = t & 255, r + 2;
987
+ }, o.prototype.writeUint32LE = o.prototype.writeUInt32LE = function(t, r, n) {
988
+ return t = +t, r = r >>> 0, n || j(this, t, r, 4, 4294967295, 0), this[r + 3] = t >>> 24, this[r + 2] = t >>> 16, this[r + 1] = t >>> 8, this[r] = t & 255, r + 4;
989
+ }, o.prototype.writeUint32BE = o.prototype.writeUInt32BE = function(t, r, n) {
990
+ return t = +t, r = r >>> 0, n || j(this, t, r, 4, 4294967295, 0), this[r] = t >>> 24, this[r + 1] = t >>> 16, this[r + 2] = t >>> 8, this[r + 3] = t & 255, r + 4;
991
+ }, o.prototype.writeIntLE = function(t, r, n, s) {
992
+ if (t = +t, r = r >>> 0, !s) {
993
+ var h = Math.pow(2, 8 * n - 1);
994
+ j(this, t, r, n, h - 1, -h);
995
+ }
996
+ var m = 0, y = 1, b = 0;
997
+ for (this[r] = t & 255; ++m < n && (y *= 256); )
998
+ t < 0 && b === 0 && this[r + m - 1] !== 0 && (b = 1), this[r + m] = (t / y >> 0) - b & 255;
999
+ return r + n;
1000
+ }, o.prototype.writeIntBE = function(t, r, n, s) {
1001
+ if (t = +t, r = r >>> 0, !s) {
1002
+ var h = Math.pow(2, 8 * n - 1);
1003
+ j(this, t, r, n, h - 1, -h);
1004
+ }
1005
+ var m = n - 1, y = 1, b = 0;
1006
+ for (this[r + m] = t & 255; --m >= 0 && (y *= 256); )
1007
+ t < 0 && b === 0 && this[r + m + 1] !== 0 && (b = 1), this[r + m] = (t / y >> 0) - b & 255;
1008
+ return r + n;
1009
+ }, o.prototype.writeInt8 = function(t, r, n) {
1010
+ return t = +t, r = r >>> 0, n || j(this, t, r, 1, 127, -128), t < 0 && (t = 255 + t + 1), this[r] = t & 255, r + 1;
1011
+ }, o.prototype.writeInt16LE = function(t, r, n) {
1012
+ return t = +t, r = r >>> 0, n || j(this, t, r, 2, 32767, -32768), this[r] = t & 255, this[r + 1] = t >>> 8, r + 2;
1013
+ }, o.prototype.writeInt16BE = function(t, r, n) {
1014
+ return t = +t, r = r >>> 0, n || j(this, t, r, 2, 32767, -32768), this[r] = t >>> 8, this[r + 1] = t & 255, r + 2;
1015
+ }, o.prototype.writeInt32LE = function(t, r, n) {
1016
+ return t = +t, r = r >>> 0, n || j(this, t, r, 4, 2147483647, -2147483648), this[r] = t & 255, this[r + 1] = t >>> 8, this[r + 2] = t >>> 16, this[r + 3] = t >>> 24, r + 4;
1017
+ }, o.prototype.writeInt32BE = function(t, r, n) {
1018
+ return t = +t, r = r >>> 0, n || j(this, t, r, 4, 2147483647, -2147483648), t < 0 && (t = 4294967295 + t + 1), this[r] = t >>> 24, this[r + 1] = t >>> 16, this[r + 2] = t >>> 8, this[r + 3] = t & 255, r + 4;
1019
+ };
1020
+ function gt(e, t, r, n, s, h) {
1021
+ if (r + n > e.length)
1022
+ throw new RangeError("Index out of range");
1023
+ if (r < 0)
1024
+ throw new RangeError("Index out of range");
1025
+ }
1026
+ function wt(e, t, r, n, s) {
1027
+ return t = +t, r = r >>> 0, s || gt(e, t, r, 4), p.write(e, t, r, n, 23, 4), r + 4;
1028
+ }
1029
+ o.prototype.writeFloatLE = function(t, r, n) {
1030
+ return wt(this, t, r, !0, n);
1031
+ }, o.prototype.writeFloatBE = function(t, r, n) {
1032
+ return wt(this, t, r, !1, n);
1033
+ };
1034
+ function yt(e, t, r, n, s) {
1035
+ return t = +t, r = r >>> 0, s || gt(e, t, r, 8), p.write(e, t, r, n, 52, 8), r + 8;
1036
+ }
1037
+ o.prototype.writeDoubleLE = function(t, r, n) {
1038
+ return yt(this, t, r, !0, n);
1039
+ }, o.prototype.writeDoubleBE = function(t, r, n) {
1040
+ return yt(this, t, r, !1, n);
1041
+ }, o.prototype.copy = function(t, r, n, s) {
1042
+ if (!o.isBuffer(t))
1043
+ throw new TypeError("argument should be a Buffer");
1044
+ if (n || (n = 0), !s && s !== 0 && (s = this.length), r >= t.length && (r = t.length), r || (r = 0), s > 0 && s < n && (s = n), s === n || t.length === 0 || this.length === 0)
1045
+ return 0;
1046
+ if (r < 0)
1047
+ throw new RangeError("targetStart out of bounds");
1048
+ if (n < 0 || n >= this.length)
1049
+ throw new RangeError("Index out of range");
1050
+ if (s < 0)
1051
+ throw new RangeError("sourceEnd out of bounds");
1052
+ s > this.length && (s = this.length), t.length - r < s - n && (s = t.length - r + n);
1053
+ var h = s - n;
1054
+ return this === t && typeof Uint8Array.prototype.copyWithin == "function" ? this.copyWithin(r, n, s) : Uint8Array.prototype.set.call(
1055
+ t,
1056
+ this.subarray(n, s),
1057
+ r
1058
+ ), h;
1059
+ }, o.prototype.fill = function(t, r, n, s) {
1060
+ if (typeof t == "string") {
1061
+ if (typeof r == "string" ? (s = r, r = 0, n = this.length) : typeof n == "string" && (s = n, n = this.length), s !== void 0 && typeof s != "string")
1062
+ throw new TypeError("encoding must be a string");
1063
+ if (typeof s == "string" && !o.isEncoding(s))
1064
+ throw new TypeError("Unknown encoding: " + s);
1065
+ if (t.length === 1) {
1066
+ var h = t.charCodeAt(0);
1067
+ (s === "utf8" && h < 128 || s === "latin1") && (t = h);
1068
+ }
1069
+ } else
1070
+ typeof t == "number" ? t = t & 255 : typeof t == "boolean" && (t = Number(t));
1071
+ if (r < 0 || this.length < r || this.length < n)
1072
+ throw new RangeError("Out of range index");
1073
+ if (n <= r)
1074
+ return this;
1075
+ r = r >>> 0, n = n === void 0 ? this.length : n >>> 0, t || (t = 0);
1076
+ var m;
1077
+ if (typeof t == "number")
1078
+ for (m = r; m < n; ++m)
1079
+ this[m] = t;
1080
+ else {
1081
+ var y = o.isBuffer(t) ? t : o.from(t, s), b = y.length;
1082
+ if (b === 0)
1083
+ throw new TypeError('The value "' + t + '" is invalid for argument "value"');
1084
+ for (m = 0; m < n - r; ++m)
1085
+ this[m + r] = y[m % b];
1086
+ }
1087
+ return this;
1088
+ };
1089
+ var wr = /[^+/0-9A-Za-z-_]/g;
1090
+ function yr(e) {
1091
+ if (e = e.split("=")[0], e = e.trim().replace(wr, ""), e.length < 2)
1092
+ return "";
1093
+ for (; e.length % 4 !== 0; )
1094
+ e = e + "=";
1095
+ return e;
1096
+ }
1097
+ function Q(e, t) {
1098
+ t = t || 1 / 0;
1099
+ for (var r, n = e.length, s = null, h = [], m = 0; m < n; ++m) {
1100
+ if (r = e.charCodeAt(m), r > 55295 && r < 57344) {
1101
+ if (!s) {
1102
+ if (r > 56319) {
1103
+ (t -= 3) > -1 && h.push(239, 191, 189);
1104
+ continue;
1105
+ } else if (m + 1 === n) {
1106
+ (t -= 3) > -1 && h.push(239, 191, 189);
1107
+ continue;
1108
+ }
1109
+ s = r;
1110
+ continue;
1111
+ }
1112
+ if (r < 56320) {
1113
+ (t -= 3) > -1 && h.push(239, 191, 189), s = r;
1114
+ continue;
1115
+ }
1116
+ r = (s - 55296 << 10 | r - 56320) + 65536;
1117
+ } else
1118
+ s && (t -= 3) > -1 && h.push(239, 191, 189);
1119
+ if (s = null, r < 128) {
1120
+ if ((t -= 1) < 0)
1121
+ break;
1122
+ h.push(r);
1123
+ } else if (r < 2048) {
1124
+ if ((t -= 2) < 0)
1125
+ break;
1126
+ h.push(
1127
+ r >> 6 | 192,
1128
+ r & 63 | 128
1129
+ );
1130
+ } else if (r < 65536) {
1131
+ if ((t -= 3) < 0)
1132
+ break;
1133
+ h.push(
1134
+ r >> 12 | 224,
1135
+ r >> 6 & 63 | 128,
1136
+ r & 63 | 128
1137
+ );
1138
+ } else if (r < 1114112) {
1139
+ if ((t -= 4) < 0)
1140
+ break;
1141
+ h.push(
1142
+ r >> 18 | 240,
1143
+ r >> 12 & 63 | 128,
1144
+ r >> 6 & 63 | 128,
1145
+ r & 63 | 128
1146
+ );
1147
+ } else
1148
+ throw new Error("Invalid code point");
1149
+ }
1150
+ return h;
1151
+ }
1152
+ function vr(e) {
1153
+ for (var t = [], r = 0; r < e.length; ++r)
1154
+ t.push(e.charCodeAt(r) & 255);
1155
+ return t;
1156
+ }
1157
+ function Er(e, t) {
1158
+ for (var r, n, s, h = [], m = 0; m < e.length && !((t -= 2) < 0); ++m)
1159
+ r = e.charCodeAt(m), n = r >> 8, s = r % 256, h.push(s), h.push(n);
1160
+ return h;
1161
+ }
1162
+ function vt(e) {
1163
+ return a.toByteArray(yr(e));
1164
+ }
1165
+ function P(e, t, r, n) {
1166
+ for (var s = 0; s < n && !(s + r >= t.length || s >= e.length); ++s)
1167
+ t[s + r] = e[s];
1168
+ return s;
1169
+ }
1170
+ function k(e, t) {
1171
+ return e instanceof t || e != null && e.constructor != null && e.constructor.name != null && e.constructor.name === t.name;
1172
+ }
1173
+ function tt(e) {
1174
+ return e !== e;
1175
+ }
1176
+ var br = function() {
1177
+ for (var e = "0123456789abcdef", t = new Array(256), r = 0; r < 16; ++r)
1178
+ for (var n = r * 16, s = 0; s < 16; ++s)
1179
+ t[n + s] = e[r] + e[s];
1180
+ return t;
1181
+ }();
1182
+ })(Pt);
1183
+ /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
1184
+ (function(i, a) {
1185
+ var p = Pt, c = p.Buffer;
1186
+ function u(l, o) {
1187
+ for (var x in l)
1188
+ o[x] = l[x];
1189
+ }
1190
+ c.from && c.alloc && c.allocUnsafe && c.allocUnsafeSlow ? i.exports = p : (u(p, a), a.Buffer = f);
1191
+ function f(l, o, x) {
1192
+ return c(l, o, x);
1193
+ }
1194
+ f.prototype = Object.create(c.prototype), u(c, f), f.from = function(l, o, x) {
1195
+ if (typeof l == "number")
1196
+ throw new TypeError("Argument must not be a number");
1197
+ return c(l, o, x);
1198
+ }, f.alloc = function(l, o, x) {
1199
+ if (typeof l != "number")
1200
+ throw new TypeError("Argument must be a number");
1201
+ var g = c(l);
1202
+ return o !== void 0 ? typeof x == "string" ? g.fill(o, x) : g.fill(o) : g.fill(0), g;
1203
+ }, f.allocUnsafe = function(l) {
1204
+ if (typeof l != "number")
1205
+ throw new TypeError("Argument must be a number");
1206
+ return c(l);
1207
+ }, f.allocUnsafeSlow = function(l) {
1208
+ if (typeof l != "number")
1209
+ throw new TypeError("Argument must be a number");
1210
+ return p.SlowBuffer(l);
1211
+ };
1212
+ })(it, it.exports);
1213
+ var Wt = it.exports, Ht = Wt.Buffer;
1214
+ function X(i, a) {
1215
+ this._block = Ht.alloc(i), this._finalSize = a, this._blockSize = i, this._len = 0;
1216
+ }
1217
+ X.prototype.update = function(i, a) {
1218
+ typeof i == "string" && (a = a || "utf8", i = Ht.from(i, a));
1219
+ for (var p = this._block, c = this._blockSize, u = i.length, f = this._len, l = 0; l < u; ) {
1220
+ for (var o = f % c, x = Math.min(u - l, c - o), g = 0; g < x; g++)
1221
+ p[o + g] = i[l + g];
1222
+ f += x, l += x, f % c === 0 && this._update(p);
1223
+ }
1224
+ return this._len += u, this;
1225
+ };
1226
+ X.prototype.digest = function(i) {
1227
+ var a = this._len % this._blockSize;
1228
+ this._block[a] = 128, this._block.fill(0, a + 1), a >= this._finalSize && (this._update(this._block), this._block.fill(0));
1229
+ var p = this._len * 8;
1230
+ if (p <= 4294967295)
1231
+ this._block.writeUInt32BE(p, this._blockSize - 4);
1232
+ else {
1233
+ var c = (p & 4294967295) >>> 0, u = (p - c) / 4294967296;
1234
+ this._block.writeUInt32BE(u, this._blockSize - 8), this._block.writeUInt32BE(c, this._blockSize - 4);
1235
+ }
1236
+ this._update(this._block);
1237
+ var f = this._hash();
1238
+ return i ? f.toString(i) : f;
1239
+ };
1240
+ X.prototype._update = function() {
1241
+ throw new Error("_update must be implemented by subclass");
1242
+ };
1243
+ var Qr = X, te = Jr, Zt = Qr, re = Wt.Buffer, ee = [
1244
+ 1518500249,
1245
+ 1859775393,
1246
+ -1894007588,
1247
+ -899497514
1248
+ ], ie = new Array(80);
1249
+ function $() {
1250
+ this.init(), this._w = ie, Zt.call(this, 64, 56);
1251
+ }
1252
+ te($, Zt);
1253
+ $.prototype.init = function() {
1254
+ return this._a = 1732584193, this._b = 4023233417, this._c = 2562383102, this._d = 271733878, this._e = 3285377520, this;
1255
+ };
1256
+ function ne(i) {
1257
+ return i << 1 | i >>> 31;
1258
+ }
1259
+ function ae(i) {
1260
+ return i << 5 | i >>> 27;
1261
+ }
1262
+ function oe(i) {
1263
+ return i << 30 | i >>> 2;
1264
+ }
1265
+ function pe(i, a, p, c) {
1266
+ return i === 0 ? a & p | ~a & c : i === 2 ? a & p | a & c | p & c : a ^ p ^ c;
1267
+ }
1268
+ $.prototype._update = function(i) {
1269
+ for (var a = this._w, p = this._a | 0, c = this._b | 0, u = this._c | 0, f = this._d | 0, l = this._e | 0, o = 0; o < 16; ++o)
1270
+ a[o] = i.readInt32BE(o * 4);
1271
+ for (; o < 80; ++o)
1272
+ a[o] = ne(a[o - 3] ^ a[o - 8] ^ a[o - 14] ^ a[o - 16]);
1273
+ for (var x = 0; x < 80; ++x) {
1274
+ var g = ~~(x / 20), w = ae(p) + pe(g, c, u, f) + l + a[x] + ee[g] | 0;
1275
+ l = f, f = u, u = oe(c), c = p, p = w;
1276
+ }
1277
+ this._a = p + this._a | 0, this._b = c + this._b | 0, this._c = u + this._c | 0, this._d = f + this._d | 0, this._e = l + this._e | 0;
1278
+ };
1279
+ $.prototype._hash = function() {
1280
+ var i = re.allocUnsafe(20);
1281
+ return i.writeInt32BE(this._a | 0, 0), i.writeInt32BE(this._b | 0, 4), i.writeInt32BE(this._c | 0, 8), i.writeInt32BE(this._d | 0, 12), i.writeInt32BE(this._e | 0, 16), i;
1282
+ };
1283
+ var se = $;
1284
+ const ce = /* @__PURE__ */ $t(se), lt = new Error("File system not available.");
1285
+ function le(i, a, p) {
1286
+ throw lt;
1287
+ }
1288
+ function Yt(i) {
1289
+ throw lt;
1290
+ }
1291
+ function ue(i) {
1292
+ throw lt;
1293
+ }
1294
+ const fe = async (i) => Yt();
1295
+ function he(i) {
1296
+ let a = "";
1297
+ for (let p = 0; p < i.length; p += 2)
1298
+ a += String.fromCharCode(parseInt(i.substr(p, 2), 16));
1299
+ return btoa(a);
1300
+ }
1301
+ const G = (i, a = "sha1") => {
1302
+ if (a !== "sha1")
1303
+ throw new Error("Only sha1 algorithm is available.");
1304
+ const p = new ce();
1305
+ return he(p.update(i).digest("hex"));
1306
+ }, Kt = async (i) => {
1307
+ const a = new St(), { name: p, revision: c, documentType: u, created: f, lastModified: l } = i, o = {
1308
+ name: p,
1309
+ revision: c,
1310
+ documentType: u,
1311
+ created: f,
1312
+ lastModified: l
1313
+ };
1314
+ return a.file("header.json", JSON.stringify(o, null, 2)), a.file(
1315
+ "state.json",
1316
+ JSON.stringify(i.initialState || {}, null, 2)
1317
+ ), a.file("operations.json", JSON.stringify(i.operations, null, 2)), Object.keys(i.attachments).forEach((g) => {
1318
+ const { data: w, ...v } = i.attachments[g];
1319
+ a.file(g, w, {
1320
+ base64: !0,
1321
+ createFolders: !0,
1322
+ comment: JSON.stringify(v)
1323
+ });
1324
+ }), a;
1325
+ }, me = async (i, a, p, c) => {
1326
+ await (await Kt(i)).generateAsync({
1327
+ type: "uint8array",
1328
+ streamFiles: !0
1329
+ });
1330
+ const f = c ?? i.name, l = `.${p}.zip`;
1331
+ return le(
1332
+ a,
1333
+ f.endsWith(l) ? f : `${f}${l}`
1334
+ );
1335
+ }, Oe = async (i, a) => {
1336
+ const c = await (await Kt(i)).generateAsync({ type: "blob" }), u = await a.createWritable();
1337
+ await u.write(c), await u.close();
1338
+ }, Ft = async (i, a) => {
1339
+ const p = Yt();
1340
+ return xe(p, a);
1341
+ }, xe = async (i, a) => {
1342
+ const p = new St();
1343
+ return await p.loadAsync(i), de(p, a);
1344
+ };
1345
+ async function de(i, a) {
1346
+ const p = i.file("state.json");
1347
+ if (!p)
1348
+ throw new Error("Initial state not found");
1349
+ const c = await p.async("string"), u = JSON.parse(c), f = i.file("header.json");
1350
+ let l;
1351
+ f && (l = JSON.parse(await f.async("string")));
1352
+ const o = i.file("operations.json");
1353
+ if (!o)
1354
+ throw new Error("Operations history not found");
1355
+ const x = JSON.parse(
1356
+ await o.async("string")
1357
+ );
1358
+ let g = Qt(
1359
+ u,
1360
+ x,
1361
+ a,
1362
+ void 0,
1363
+ l
1364
+ );
1365
+ return l && (g = {
1366
+ ...g,
1367
+ ...l
1368
+ }), g;
1369
+ }
1370
+ function Xt(i) {
1371
+ const a = i.replace(/^.*\./, "") || void 0, p = i.replace(/^.*[/\\]/, "") || void 0;
1372
+ return { extension: a, fileName: p };
1373
+ }
1374
+ async function De(i) {
1375
+ const { buffer: a, mimeType: p = "application/octet-stream" } = await ue(), c = Xt(i), u = a.toString("base64");
1376
+ return {
1377
+ data: u,
1378
+ hash: G(u),
1379
+ mimeType: p,
1380
+ ...c
1381
+ };
1382
+ }
1383
+ async function Ne(i) {
1384
+ const a = await fe(), p = Pr.getType(i) || "application/octet-stream", c = Xt(i), u = a.toString("base64");
1385
+ return { data: u, hash: G(u), mimeType: p, ...c };
1386
+ }
1387
+ function ge(i, a) {
1388
+ const p = i.revision[a.scope];
1389
+ return [L, z, q].includes(a.type) ? p : p + 1;
1390
+ }
1391
+ function we(i, a) {
1392
+ return {
1393
+ ...i,
1394
+ revision: {
1395
+ ...i.revision,
1396
+ [a.scope]: ge(i, a)
1397
+ },
1398
+ lastModified: (/* @__PURE__ */ new Date()).toISOString()
1399
+ };
1400
+ }
1401
+ function ye(i, a, p = 0) {
1402
+ if ([L, z, q].includes(a.type))
1403
+ return i;
1404
+ const { scope: c } = a, u = i.operations[c].slice(
1405
+ 0,
1406
+ i.revision[c]
1407
+ );
1408
+ return u.push({
1409
+ ...a,
1410
+ index: u.length,
1411
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1412
+ hash: "",
1413
+ scope: c,
1414
+ skip: p
1415
+ }), {
1416
+ ...i,
1417
+ operations: { ...i.operations, [c]: u }
1418
+ };
1419
+ }
1420
+ function ve(i, a, p = 0) {
1421
+ let c = ye(i, a, p);
1422
+ return c = we(c, a), c;
1423
+ }
1424
+ function Ee(i, a, p) {
1425
+ switch (Ot().parse(a), a.type) {
1426
+ case zt:
1427
+ return Dr(i, a.input);
1428
+ case L:
1429
+ return Nr(i, a, p);
1430
+ case z:
1431
+ return Mr(i, a, p);
1432
+ case q:
1433
+ return Rr(i, a, p);
1434
+ case qt:
1435
+ return Cr(i, a.input.state);
1436
+ default:
1437
+ return i;
1438
+ }
1439
+ }
1440
+ function Gt(i, a, p, c, u = {}) {
1441
+ const {
1442
+ skip: f = 0
1443
+ } = u;
1444
+ let l = i;
1445
+ return At(a) && (l = Ee(l, a, p)), l = ve(l, a, f), l = _t(l, (o) => {
1446
+ const x = p(o.state, a, c);
1447
+ if (x)
1448
+ return Sr({
1449
+ ...l,
1450
+ state: x
1451
+ });
1452
+ }), _t(l, (o) => {
1453
+ if ([L, z, q].includes(a.type))
1454
+ return o;
1455
+ const x = a.scope || "global";
1456
+ o.operations[x][o.operations[x].length - 1].hash = Vt(o, x), !At(a) && a.attachments && a.attachments.forEach((g) => {
1457
+ const { hash: w, ...v } = g;
1458
+ o.attachments[w] = {
1459
+ ...v
1460
+ };
1461
+ });
1462
+ });
1463
+ }
1464
+ function At(i) {
1465
+ return [zt, L, z, q, qt].includes(i.type);
1466
+ }
1467
+ function R(i, a, p, c, u = "global") {
1468
+ if (!i)
1469
+ throw new Error("Empty action type");
1470
+ if (typeof i != "string")
1471
+ throw new Error(`Invalid action type: ${i}`);
1472
+ const f = { type: i, input: a, scope: u };
1473
+ p && (f.attachments = p);
1474
+ try {
1475
+ c == null || c().parse(f.input);
1476
+ } catch (l) {
1477
+ throw new Error(`Invalid action input: ${l}`);
1478
+ }
1479
+ return f;
1480
+ }
1481
+ function be(i, a = Gt) {
1482
+ return (p, c, u, f) => a(p, c, i, u, f);
1483
+ }
1484
+ const _e = (i, a) => ({
1485
+ name: "",
1486
+ documentType: "",
1487
+ revision: {
1488
+ global: 0,
1489
+ local: 0
1490
+ },
1491
+ created: (/* @__PURE__ */ new Date()).toISOString(),
1492
+ lastModified: (/* @__PURE__ */ new Date()).toISOString(),
1493
+ attachments: {},
1494
+ ...i,
1495
+ state: (a == null ? void 0 : a(i == null ? void 0 : i.state)) ?? (i == null ? void 0 : i.state) ?? { global: {}, local: {} }
1496
+ }), Fe = (i, a) => {
1497
+ const p = _e(
1498
+ i,
1499
+ a
1500
+ );
1501
+ return {
1502
+ ...p,
1503
+ initialState: p,
1504
+ operations: { global: [], local: [] }
1505
+ };
1506
+ }, Vt = (i, a = "global") => G(Ar(i.state[a])), Me = (i, a = 1e3) => {
1507
+ const p = Math.random() * a;
1508
+ return G(`${(i ?? /* @__PURE__ */ new Date()).toISOString()}${p}`);
1509
+ };
1510
+ function H(i) {
1511
+ return Br(jr(i, !0));
1512
+ }
1513
+ function Ae(i) {
1514
+ const a = [...i];
1515
+ let p = 0, c = a.length > 0 ? a[a.length - 1].index : 0;
1516
+ const u = [];
1517
+ for (const f of a.reverse()) {
1518
+ if (p > 0) {
1519
+ const o = c - f.index;
1520
+ p -= o;
1521
+ }
1522
+ if (p < 0)
1523
+ throw new Error("Invalid operation index, missing operations");
1524
+ const l = {
1525
+ ignore: p > 0,
1526
+ operation: f
1527
+ };
1528
+ f.skip > 0 && (p = p + (f.skip + 1)), c = f.index, u.push(l);
1529
+ }
1530
+ return u.reverse();
1531
+ }
1532
+ function Re(i) {
1533
+ return Object.values(i).flatMap((a) => a).sort(
1534
+ (a, p) => new Date(a.timestamp).getTime() - new Date(p.timestamp).getTime()
1535
+ );
1536
+ }
1537
+ function Se(i) {
1538
+ return Object.values(i).flatMap((a) => a).sort(
1539
+ (a, p) => new Date(a.operation.timestamp).getTime() - new Date(p.operation.timestamp).getTime()
1540
+ );
1541
+ }
1542
+ function Z(i, a, p, c, u, f = Gt) {
1543
+ const l = be(p, f);
1544
+ return Qt(
1545
+ i,
1546
+ a,
1547
+ l,
1548
+ c,
1549
+ u
1550
+ );
1551
+ }
1552
+ function Qt(i, a, p, c, u) {
1553
+ const f = Fe(i), l = Object.keys(a).reduce((w, v) => {
1554
+ const E = v;
1555
+ return {
1556
+ ...w,
1557
+ [E]: a[E].slice(0, u == null ? void 0 : u.revision[E])
1558
+ };
1559
+ }, {}), o = Object.keys(l).reduce((w, v) => {
1560
+ const E = v;
1561
+ return {
1562
+ ...w,
1563
+ [E]: Ae(l[E])
1564
+ };
1565
+ }, {}), x = Se(o).reduce(
1566
+ (w, { ignore: v, operation: E }) => v ? p(
1567
+ w,
1568
+ nr(E.scope),
1569
+ c,
1570
+ { skip: E.skip }
1571
+ ) : p(w, E, c),
1572
+ f
1573
+ ), g = Object.keys(
1574
+ x.operations
1575
+ ).reduce(
1576
+ (w, v) => {
1577
+ const E = v, A = u && u.revision[E] < a[E].length ? a[E].slice(u.revision[E]) : [];
1578
+ return {
1579
+ ...w,
1580
+ [E]: [
1581
+ ...x.operations[E].map((U, O) => {
1582
+ var N;
1583
+ return {
1584
+ ...U,
1585
+ timestamp: ((N = a[E][O]) == null ? void 0 : N.timestamp) ?? U.timestamp
1586
+ };
1587
+ }),
1588
+ ...A
1589
+ ]
1590
+ };
1591
+ },
1592
+ { global: [], local: [] }
1593
+ );
1594
+ return { ...x, operations: g };
1595
+ }
1596
+ const tr = (i) => R(
1597
+ "SET_NAME",
1598
+ i,
1599
+ void 0,
1600
+ pt,
1601
+ void 0
1602
+ ), rr = (i = 1, a = "global") => R(
1603
+ "UNDO",
1604
+ i,
1605
+ void 0,
1606
+ st,
1607
+ a
1608
+ ), er = (i = 1, a = "global") => R(
1609
+ "REDO",
1610
+ i,
1611
+ void 0,
1612
+ ot,
1613
+ a
1614
+ ), ir = (i, a, p = "global") => R(
1615
+ "PRUNE",
1616
+ { start: i, end: a },
1617
+ void 0,
1618
+ at,
1619
+ p
1620
+ ), ut = (i, a) => R(
1621
+ "LOAD_STATE",
1622
+ { state: i, operations: a },
1623
+ void 0,
1624
+ nt
1625
+ ), nr = (i = "global") => R(
1626
+ "NOOP",
1627
+ {},
1628
+ void 0,
1629
+ void 0,
1630
+ i
1631
+ ), Ce = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1632
+ __proto__: null,
1633
+ loadState: ut,
1634
+ noop: nr,
1635
+ prune: ir,
1636
+ redo: er,
1637
+ setName: tr,
1638
+ undo: rr
1639
+ }, Symbol.toStringTag, { value: "Module" }));
1640
+ class Le {
1641
+ /**
1642
+ * Constructs a BaseDocument instance with an initial state.
1643
+ * @param reducer - The reducer function that updates the state.
1644
+ * @param document - The initial state of the document.
1645
+ */
1646
+ constructor(a, p, c) {
1647
+ W(this, "_document");
1648
+ W(this, "_reducer");
1649
+ W(this, "_signalDispatch");
1650
+ this._reducer = a, this._document = p, this._signalDispatch = c;
1651
+ }
1652
+ /**
1653
+ * Dispatches an action to update the state of the document.
1654
+ * @param action - The action to dispatch.
1655
+ * @returns The Document instance.
1656
+ */
1657
+ dispatch(a, p) {
1658
+ return this._document = this._reducer(
1659
+ this._document,
1660
+ a,
1661
+ this._signalDispatch,
1662
+ p
1663
+ ), this;
1664
+ }
1665
+ /**
1666
+ * Saves the state of the document to a file.
1667
+ * @param path - The file path where the state should be saved.
1668
+ * @param extension - The file extension to use when saving the state.
1669
+ * @returns The file path where the state was saved.
1670
+ */
1671
+ saveToFile(a, p, c) {
1672
+ return me(this._document, a, p, c);
1673
+ }
1674
+ /**
1675
+ * Loads the state of the document from a file.
1676
+ * @param path - The file path where the state is stored.
1677
+ */
1678
+ async loadFromFile(a) {
1679
+ this._document = await Ft(a, this._reducer);
1680
+ }
1681
+ /**
1682
+ * Loads the state of the document from a file and returns it.
1683
+ * @param path - The file path where the state is stored.
1684
+ * @param reducer - The reducer function that updates the state.
1685
+ * @returns The state of the document.
1686
+ */
1687
+ static async stateFromFile(a, p) {
1688
+ return await Ft(a, p);
1689
+ }
1690
+ /**
1691
+ * Gets the current state of the document.
1692
+ */
1693
+ get state() {
1694
+ return H(this._document.state);
1695
+ }
1696
+ /**
1697
+ * Gets the list of operations performed on the document.
1698
+ */
1699
+ get operations() {
1700
+ return H(this._document.operations);
1701
+ }
1702
+ /**
1703
+ * Gets the name of the document.
1704
+ */
1705
+ get name() {
1706
+ return this._document.name;
1707
+ }
1708
+ /**
1709
+ * Gets the type of document.
1710
+ */
1711
+ get documentType() {
1712
+ return this._document.documentType;
1713
+ }
1714
+ /**
1715
+ * Gets the timestamp of the date the document was created.
1716
+ */
1717
+ get created() {
1718
+ return this._document.created;
1719
+ }
1720
+ /**
1721
+ * Gets the timestamp of the date the document was last modified.
1722
+ */
1723
+ get lastModified() {
1724
+ return this._document.lastModified;
1725
+ }
1726
+ /**
1727
+ * Gets the global revision number of the document.
1728
+ */
1729
+ get revision() {
1730
+ return this._document.revision.global;
1731
+ }
1732
+ getRevision(a) {
1733
+ return this._document.revision[a];
1734
+ }
1735
+ /**
1736
+ * Gets the initial state of the document.
1737
+ */
1738
+ get initialState() {
1739
+ return H(this._document.initialState);
1740
+ }
1741
+ /**
1742
+ * Returns the current document as an object
1743
+ */
1744
+ toDocument() {
1745
+ return H(this._document);
1746
+ }
1747
+ /**
1748
+ * Gets the attachment associated with the given key.
1749
+ * @param attachment - The key of the attachment to retrieve.
1750
+ */
1751
+ getAttachment(a) {
1752
+ return this._document.attachments[a];
1753
+ }
1754
+ /**
1755
+ * Sets the name of the document.
1756
+ * @param name - The new name of the document.
1757
+ */
1758
+ setName(a) {
1759
+ return this.dispatch(tr(a)), this;
1760
+ }
1761
+ /**
1762
+ * Reverts a number of actions from the document.
1763
+ * @param count - The number of actions to revert.
1764
+ */
1765
+ undo(a) {
1766
+ return this.dispatch(rr(a)), this;
1767
+ }
1768
+ /**
1769
+ * Reapplies a number of actions to the document.
1770
+ * @param count - The number of actions to reapply.
1771
+ */
1772
+ redo(a) {
1773
+ return this.dispatch(er(a)), this;
1774
+ }
1775
+ /**
1776
+ * Removes a range of operations from the document.
1777
+ * @param start - The starting index of the range to remove.
1778
+ * @param end - The ending index of the range to remove.
1779
+ */
1780
+ prune(a, p) {
1781
+ return this.dispatch(ir(a, p)), this;
1782
+ }
1783
+ /**
1784
+ * Loads a document state and a set of operations.
1785
+ * @param state - The state to load.
1786
+ * @param operations - The operations to apply to the document.
1787
+ */
1788
+ loadState(a, p) {
1789
+ return this.dispatch(ut(a, p)), this;
1790
+ }
1791
+ }
1792
+ function ze(i, a) {
1793
+ a.forEach((p) => {
1794
+ Object.getOwnPropertyNames(p.prototype).forEach((c) => {
1795
+ Object.defineProperty(
1796
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1797
+ i.prototype,
1798
+ c,
1799
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
1800
+ Object.getOwnPropertyDescriptor(p.prototype, c) || /* @__PURE__ */ Object.create(null)
1801
+ );
1802
+ });
1803
+ });
1804
+ }
1805
+ export {
1806
+ Le as B,
1807
+ _e as a,
1808
+ Fe as b,
1809
+ be as c,
1810
+ Oe as d,
1811
+ xe as e,
1812
+ R as f,
1813
+ ze as g,
1814
+ Ce as h,
1815
+ At as i,
1816
+ Kt as j,
1817
+ Ne as k,
1818
+ Ft as l,
1819
+ De as m,
1820
+ Vt as n,
1821
+ Me as o,
1822
+ Ae as p,
1823
+ Qt as q,
1824
+ H as r,
1825
+ me as s,
1826
+ Z as t,
1827
+ Se as u,
1828
+ Re as v,
1829
+ Gt as w,
1830
+ Te as z
1831
+ };