document-model 1.0.25 → 1.0.26

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