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