@graffiti-garden/wrapper-synchronize 0.2.4 → 1.0.2
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/{ajv-L3T2Y2ZC.js → ajv-UZKI6BMI.js} +2 -2
- package/dist/browser/chunk-YB7WCAZH.js +7 -0
- package/dist/browser/{chunk-ZOOM6B5R.js.map → chunk-YB7WCAZH.js.map} +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/cjs/index.js +81 -131
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/index.js +82 -132
- package/dist/esm/index.js.map +2 -2
- package/dist/index.d.ts +31 -45
- package/dist/index.d.ts.map +1 -1
- package/package.json +7 -8
- package/src/index.spec.ts +110 -277
- package/src/index.ts +109 -161
- package/dist/browser/chunk-ZOOM6B5R.js +0 -7
- package/dist/browser/fast-json-patch-5UD2BOZL.js +0 -19
- package/dist/browser/fast-json-patch-5UD2BOZL.js.map +0 -7
- /package/dist/browser/{ajv-L3T2Y2ZC.js.map → ajv-UZKI6BMI.js.map} +0 -0
package/src/index.ts
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
import type Ajv from "ajv";
|
|
2
|
-
import { Graffiti } from "@graffiti-garden/api";
|
|
3
2
|
import type {
|
|
3
|
+
Graffiti,
|
|
4
4
|
GraffitiSession,
|
|
5
5
|
JSONSchema,
|
|
6
|
+
GraffitiObjectBase,
|
|
6
7
|
GraffitiObjectStream,
|
|
7
8
|
GraffitiObjectStreamContinueEntry,
|
|
8
9
|
GraffitiObjectStreamContinue,
|
|
9
|
-
|
|
10
|
+
GraffitiObjectUrl,
|
|
10
11
|
} from "@graffiti-garden/api";
|
|
11
|
-
import type { GraffitiObjectBase } from "@graffiti-garden/api";
|
|
12
|
-
import { Repeater } from "@repeaterjs/repeater";
|
|
13
|
-
import type { applyPatch } from "fast-json-patch";
|
|
14
12
|
import {
|
|
15
|
-
|
|
13
|
+
GraffitiErrorNotFound,
|
|
16
14
|
compileGraffitiObjectSchema,
|
|
17
15
|
isActorAllowedGraffitiObject,
|
|
18
16
|
maskGraffitiObject,
|
|
19
17
|
unpackObjectUrl,
|
|
20
|
-
} from "@graffiti-garden/
|
|
18
|
+
} from "@graffiti-garden/api";
|
|
19
|
+
import { Repeater } from "@repeaterjs/repeater";
|
|
21
20
|
export type * from "@graffiti-garden/api";
|
|
22
21
|
|
|
23
22
|
export type GraffitiSynchronizeCallback = (
|
|
24
|
-
|
|
25
|
-
newObject?: GraffitiObjectStreamContinueEntry<{}>,
|
|
23
|
+
object: GraffitiObjectStreamContinueEntry<{}>,
|
|
26
24
|
) => void;
|
|
27
25
|
|
|
28
26
|
export interface GraffitiSynchronizeOptions {
|
|
@@ -57,16 +55,15 @@ export interface GraffitiSynchronizeOptions {
|
|
|
57
55
|
* |------------|--------------------|
|
|
58
56
|
* | {@link get} | {@link synchronizeGet} |
|
|
59
57
|
* | {@link discover} | {@link synchronizeDiscover} |
|
|
60
|
-
* | {@link recoverOrphans} | {@link synchronizeRecoverOrphans} |
|
|
61
58
|
*
|
|
62
|
-
* Whenever a change is made via {@link
|
|
63
|
-
* received from {@link get}, {@link discover}, and {@link
|
|
59
|
+
* Whenever a change is made via {@link post} and {@link delete} or
|
|
60
|
+
* received from {@link get}, {@link discover}, and {@link continueDiscover},
|
|
64
61
|
* those changes are forwarded to the appropriate synchronize method.
|
|
65
62
|
* Each synchronize method returns an iterator that streams these changes
|
|
66
63
|
* continually until the user calls `return` on the iterator or `break`s out of the loop,
|
|
67
64
|
* allowing for live updates without additional polling.
|
|
68
65
|
*
|
|
69
|
-
* Example 1: Suppose a user publishes a post using {@link
|
|
66
|
+
* Example 1: Suppose a user publishes a post using {@link post}. If the feed
|
|
70
67
|
* displaying that user's posts is using {@link synchronizeDiscover} to listen for changes,
|
|
71
68
|
* then the user's new post will instantly appear in their feed, giving the UI a
|
|
72
69
|
* responsive feel.
|
|
@@ -77,25 +74,32 @@ export interface GraffitiSynchronizeOptions {
|
|
|
77
74
|
* all instance's of that friend's name in the user's application instantly,
|
|
78
75
|
* providing a consistent user experience.
|
|
79
76
|
*
|
|
77
|
+
* Additionally, the library supplies a {@link synchronizeAll} method that can be used
|
|
78
|
+
* to stream all the Graffiti changes that an application is aware of, which can be used
|
|
79
|
+
* for caching or history building.
|
|
80
|
+
*
|
|
80
81
|
* The source code for this library is [available on GitHub](https://github.com/graffiti-garden/wrapper-synchronize/).
|
|
81
82
|
*
|
|
82
|
-
* @groupDescription Synchronize Methods
|
|
83
|
+
* @groupDescription 0 - Synchronize Methods
|
|
83
84
|
* This group contains methods that listen for changes made via
|
|
84
|
-
* {@link
|
|
85
|
-
* {@link get}, {@link discover},
|
|
85
|
+
* {@link post}, and {@link delete} or fetched from
|
|
86
|
+
* {@link get}, {@link discover}, or {@link continueDiscover} and then
|
|
86
87
|
* streams appropriate changes to provide a responsive and consistent user experience.
|
|
87
88
|
*/
|
|
88
|
-
export class GraffitiSynchronize
|
|
89
|
+
export class GraffitiSynchronize implements Graffiti {
|
|
89
90
|
protected ajv_: Promise<Ajv> | undefined;
|
|
90
|
-
protected applyPatch_: Promise<typeof applyPatch> | undefined;
|
|
91
91
|
protected readonly graffiti: Graffiti;
|
|
92
92
|
protected readonly callbacks = new Set<GraffitiSynchronizeCallback>();
|
|
93
93
|
protected readonly options: GraffitiSynchronizeOptions;
|
|
94
94
|
|
|
95
|
-
channelStats: Graffiti["channelStats"];
|
|
96
95
|
login: Graffiti["login"];
|
|
97
96
|
logout: Graffiti["logout"];
|
|
98
97
|
sessionEvents: Graffiti["sessionEvents"];
|
|
98
|
+
postMedia: Graffiti["postMedia"];
|
|
99
|
+
getMedia: Graffiti["getMedia"];
|
|
100
|
+
deleteMedia: Graffiti["deleteMedia"];
|
|
101
|
+
actorToHandle: Graffiti["actorToHandle"];
|
|
102
|
+
handleToActor: Graffiti["handleToActor"];
|
|
99
103
|
|
|
100
104
|
protected get ajv() {
|
|
101
105
|
if (!this.ajv_) {
|
|
@@ -107,16 +111,6 @@ export class GraffitiSynchronize extends Graffiti {
|
|
|
107
111
|
return this.ajv_;
|
|
108
112
|
}
|
|
109
113
|
|
|
110
|
-
protected get applyPatch() {
|
|
111
|
-
if (!this.applyPatch_) {
|
|
112
|
-
this.applyPatch_ = (async () => {
|
|
113
|
-
const { applyPatch } = await import("fast-json-patch");
|
|
114
|
-
return applyPatch;
|
|
115
|
-
})();
|
|
116
|
-
}
|
|
117
|
-
return this.applyPatch_;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
114
|
/**
|
|
121
115
|
* Wraps a Graffiti API instance to provide the synchronize methods.
|
|
122
116
|
* The GraffitiSyncrhonize class rather than the Graffiti class
|
|
@@ -130,13 +124,16 @@ export class GraffitiSynchronize extends Graffiti {
|
|
|
130
124
|
graffiti: Graffiti,
|
|
131
125
|
options?: GraffitiSynchronizeOptions,
|
|
132
126
|
) {
|
|
133
|
-
super();
|
|
134
127
|
this.options = options ?? {};
|
|
135
128
|
this.graffiti = graffiti;
|
|
136
|
-
this.channelStats = graffiti.channelStats.bind(graffiti);
|
|
137
129
|
this.login = graffiti.login.bind(graffiti);
|
|
138
130
|
this.logout = graffiti.logout.bind(graffiti);
|
|
139
131
|
this.sessionEvents = graffiti.sessionEvents;
|
|
132
|
+
this.postMedia = graffiti.postMedia.bind(graffiti);
|
|
133
|
+
this.getMedia = graffiti.getMedia.bind(graffiti);
|
|
134
|
+
this.deleteMedia = graffiti.deleteMedia.bind(graffiti);
|
|
135
|
+
this.actorToHandle = graffiti.actorToHandle.bind(graffiti);
|
|
136
|
+
this.handleToActor = graffiti.handleToActor.bind(graffiti);
|
|
140
137
|
}
|
|
141
138
|
|
|
142
139
|
protected synchronize<Schema extends JSONSchema>(
|
|
@@ -144,39 +141,32 @@ export class GraffitiSynchronize extends Graffiti {
|
|
|
144
141
|
channels: string[],
|
|
145
142
|
schema: Schema,
|
|
146
143
|
session?: GraffitiSession | null,
|
|
144
|
+
seenUrls: Set<string> = new Set<string>(),
|
|
147
145
|
): AsyncGenerator<GraffitiObjectStreamContinueEntry<Schema>> {
|
|
148
|
-
const seenUrls = new Set<string>();
|
|
149
|
-
|
|
150
146
|
const repeater = new Repeater<GraffitiObjectStreamContinueEntry<Schema>>(
|
|
151
147
|
async (push, stop) => {
|
|
152
148
|
const validate = compileGraffitiObjectSchema(await this.ajv, schema);
|
|
153
|
-
const callback: GraffitiSynchronizeCallback = (
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
)
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
if (validate(object)) {
|
|
176
|
-
push({ object });
|
|
177
|
-
seenUrls.add(object.url);
|
|
178
|
-
break;
|
|
179
|
-
}
|
|
149
|
+
const callback: GraffitiSynchronizeCallback = (objectUpdate) => {
|
|
150
|
+
if (objectUpdate?.tombstone) {
|
|
151
|
+
if (seenUrls.has(objectUpdate.object.url)) {
|
|
152
|
+
push(objectUpdate);
|
|
153
|
+
}
|
|
154
|
+
} else if (
|
|
155
|
+
objectUpdate &&
|
|
156
|
+
matchObject(objectUpdate.object) &&
|
|
157
|
+
(this.options.omniscient ||
|
|
158
|
+
isActorAllowedGraffitiObject(objectUpdate.object, session))
|
|
159
|
+
) {
|
|
160
|
+
// Deep clone the object to prevent mutation
|
|
161
|
+
const object = JSON.parse(
|
|
162
|
+
JSON.stringify(objectUpdate.object),
|
|
163
|
+
) as GraffitiObjectBase;
|
|
164
|
+
if (!this.options.omniscient) {
|
|
165
|
+
maskGraffitiObject(object, channels, session);
|
|
166
|
+
}
|
|
167
|
+
if (validate(object)) {
|
|
168
|
+
push({ object });
|
|
169
|
+
seenUrls.add(object.url);
|
|
180
170
|
}
|
|
181
171
|
}
|
|
182
172
|
};
|
|
@@ -194,8 +184,8 @@ export class GraffitiSynchronize extends Graffiti {
|
|
|
194
184
|
|
|
195
185
|
/**
|
|
196
186
|
* This method has the same signature as {@link discover} but listens for
|
|
197
|
-
* changes made via {@link
|
|
198
|
-
* fetched from {@link get}, {@link discover}, and {@link
|
|
187
|
+
* changes made via {@link post} and {@link delete} or
|
|
188
|
+
* fetched from {@link get}, {@link discover}, and {@link continueDiscover}
|
|
199
189
|
* and then streams appropriate changes to provide a responsive and
|
|
200
190
|
* consistent user experience.
|
|
201
191
|
*
|
|
@@ -203,12 +193,13 @@ export class GraffitiSynchronize extends Graffiti {
|
|
|
203
193
|
* and will not terminate unless the user calls the `return` method on the iterator
|
|
204
194
|
* or `break`s out of the loop.
|
|
205
195
|
*
|
|
206
|
-
* @group Synchronize Methods
|
|
196
|
+
* @group 0 - Synchronize Methods
|
|
207
197
|
*/
|
|
208
198
|
synchronizeDiscover<Schema extends JSONSchema>(
|
|
209
|
-
|
|
199
|
+
channels: string[],
|
|
200
|
+
schema: Schema,
|
|
201
|
+
session?: GraffitiSession | null,
|
|
210
202
|
): AsyncGenerator<GraffitiObjectStreamContinueEntry<Schema>> {
|
|
211
|
-
const [channels, schema, session] = args;
|
|
212
203
|
function matchObject(object: GraffitiObjectBase) {
|
|
213
204
|
return object.channels.some((channel) => channels.includes(channel));
|
|
214
205
|
}
|
|
@@ -217,48 +208,32 @@ export class GraffitiSynchronize extends Graffiti {
|
|
|
217
208
|
|
|
218
209
|
/**
|
|
219
210
|
* This method has the same signature as {@link get} but
|
|
220
|
-
* listens for changes made via {@link
|
|
221
|
-
* fetched from {@link get}, {@link discover}, and {@link
|
|
211
|
+
* listens for changes made via {@link post}, and {@link delete} or
|
|
212
|
+
* fetched from {@link get}, {@link discover}, and {@link continueDiscover} and then
|
|
222
213
|
* streams appropriate changes to provide a responsive and consistent user experience.
|
|
223
214
|
*
|
|
224
215
|
* Unlike {@link get}, which returns a single result, this method continuously
|
|
225
216
|
* listens for changes which are output as an asynchronous stream, similar
|
|
226
217
|
* to {@link discover}.
|
|
227
218
|
*
|
|
228
|
-
* @group Synchronize Methods
|
|
219
|
+
* @group 0 - Synchronize Methods
|
|
229
220
|
*/
|
|
230
221
|
synchronizeGet<Schema extends JSONSchema>(
|
|
231
|
-
|
|
222
|
+
objectUrl: string | GraffitiObjectUrl,
|
|
223
|
+
schema: Schema,
|
|
224
|
+
session?: GraffitiSession | null | undefined,
|
|
232
225
|
): AsyncGenerator<GraffitiObjectStreamContinueEntry<Schema>> {
|
|
233
|
-
const [objectUrl, schema, session] = args;
|
|
234
226
|
const url = unpackObjectUrl(objectUrl);
|
|
235
227
|
function matchObject(object: GraffitiObjectBase) {
|
|
236
228
|
return object.url === url;
|
|
237
229
|
}
|
|
238
|
-
return this.synchronize<Schema>(
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
* {@link get}, {@link discover}, and {@link recoverOrphans} and then
|
|
246
|
-
* streams appropriate changes to provide a responsive and consistent user experience.
|
|
247
|
-
*
|
|
248
|
-
* Unlike {@link recoverOrphans}, this method continuously listens for changes
|
|
249
|
-
* and will not terminate unless the user calls the `return` method on the iterator
|
|
250
|
-
* or `break`s out of the loop.
|
|
251
|
-
*
|
|
252
|
-
* @group Synchronize Methods
|
|
253
|
-
*/
|
|
254
|
-
synchronizeRecoverOrphans<Schema extends JSONSchema>(
|
|
255
|
-
...args: Parameters<typeof Graffiti.prototype.recoverOrphans<Schema>>
|
|
256
|
-
): AsyncGenerator<GraffitiObjectStreamContinueEntry<Schema>> {
|
|
257
|
-
const [schema, session] = args;
|
|
258
|
-
function matchObject(object: GraffitiObjectBase) {
|
|
259
|
-
return object.actor === session.actor && object.channels.length === 0;
|
|
260
|
-
}
|
|
261
|
-
return this.synchronize<Schema>(matchObject, [], schema, session);
|
|
230
|
+
return this.synchronize<Schema>(
|
|
231
|
+
matchObject,
|
|
232
|
+
[],
|
|
233
|
+
schema,
|
|
234
|
+
session,
|
|
235
|
+
new Set<string>([url]),
|
|
236
|
+
);
|
|
262
237
|
}
|
|
263
238
|
|
|
264
239
|
/**
|
|
@@ -271,7 +246,7 @@ export class GraffitiSynchronize extends Graffiti {
|
|
|
271
246
|
* Be careful using this method. Without additional filters it can
|
|
272
247
|
* expose the user to content out of context.
|
|
273
248
|
*
|
|
274
|
-
* @group Synchronize Methods
|
|
249
|
+
* @group 0 - Synchronize Methods
|
|
275
250
|
*/
|
|
276
251
|
synchronizeAll<Schema extends JSONSchema>(
|
|
277
252
|
schema: Schema,
|
|
@@ -281,12 +256,11 @@ export class GraffitiSynchronize extends Graffiti {
|
|
|
281
256
|
}
|
|
282
257
|
|
|
283
258
|
protected async synchronizeDispatch(
|
|
284
|
-
|
|
285
|
-
newObject?: GraffitiObjectStreamContinueEntry<{}>,
|
|
259
|
+
objectUpdate: GraffitiObjectStreamContinueEntry<{}>,
|
|
286
260
|
waitForListeners = false,
|
|
287
261
|
) {
|
|
288
262
|
for (const callback of this.callbacks) {
|
|
289
|
-
callback(
|
|
263
|
+
callback(objectUpdate);
|
|
290
264
|
}
|
|
291
265
|
if (waitForListeners) {
|
|
292
266
|
// Wait for the listeners to receive
|
|
@@ -314,63 +288,43 @@ export class GraffitiSynchronize extends Graffiti {
|
|
|
314
288
|
}
|
|
315
289
|
|
|
316
290
|
get: Graffiti["get"] = async (...args) => {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
};
|
|
331
|
-
await this.synchronizeDispatch(
|
|
332
|
-
{
|
|
333
|
-
tombstone: true,
|
|
334
|
-
object: oldObject,
|
|
335
|
-
},
|
|
336
|
-
{
|
|
337
|
-
object: newObject,
|
|
338
|
-
},
|
|
339
|
-
true,
|
|
340
|
-
);
|
|
341
|
-
return oldObject;
|
|
291
|
+
try {
|
|
292
|
+
const object = await this.graffiti.get(...args);
|
|
293
|
+
this.synchronizeDispatch({ object });
|
|
294
|
+
return object;
|
|
295
|
+
} catch (error) {
|
|
296
|
+
if (error instanceof GraffitiErrorNotFound) {
|
|
297
|
+
this.synchronizeDispatch({
|
|
298
|
+
tombstone: true,
|
|
299
|
+
object: { url: unpackObjectUrl(args[0]) },
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
throw error;
|
|
303
|
+
}
|
|
342
304
|
};
|
|
343
305
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
const
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
}
|
|
350
|
-
await this.synchronizeDispatch(
|
|
351
|
-
{
|
|
352
|
-
tombstone: true,
|
|
353
|
-
object: oldObject,
|
|
354
|
-
},
|
|
355
|
-
{
|
|
356
|
-
object: newObject,
|
|
357
|
-
},
|
|
358
|
-
true,
|
|
359
|
-
);
|
|
360
|
-
return oldObject;
|
|
306
|
+
post: Graffiti["post"] = async (...args) => {
|
|
307
|
+
// @ts-ignore
|
|
308
|
+
const object = await this.graffiti.post(...args);
|
|
309
|
+
await this.synchronizeDispatch({ object }, true);
|
|
310
|
+
return object;
|
|
361
311
|
};
|
|
362
312
|
|
|
363
313
|
delete: Graffiti["delete"] = async (...args) => {
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
{
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
)
|
|
373
|
-
|
|
314
|
+
const update = {
|
|
315
|
+
tombstone: true,
|
|
316
|
+
object: { url: unpackObjectUrl(args[0]) },
|
|
317
|
+
} as const;
|
|
318
|
+
try {
|
|
319
|
+
const oldObject = await this.graffiti.delete(...args);
|
|
320
|
+
await this.synchronizeDispatch(update, true);
|
|
321
|
+
return oldObject;
|
|
322
|
+
} catch (error) {
|
|
323
|
+
if (error instanceof GraffitiErrorNotFound) {
|
|
324
|
+
await this.synchronizeDispatch(update, true);
|
|
325
|
+
}
|
|
326
|
+
throw error;
|
|
327
|
+
}
|
|
374
328
|
};
|
|
375
329
|
|
|
376
330
|
protected objectStreamContinue<Schema extends JSONSchema>(
|
|
@@ -383,14 +337,13 @@ export class GraffitiSynchronize extends Graffiti {
|
|
|
383
337
|
if (result.done) {
|
|
384
338
|
const { continue: continue_, cursor } = result.value;
|
|
385
339
|
return {
|
|
386
|
-
continue: () =>
|
|
340
|
+
continue: (session?: GraffitiSession | null) =>
|
|
341
|
+
this_.objectStreamContinue<Schema>(continue_(session)),
|
|
387
342
|
cursor,
|
|
388
343
|
};
|
|
389
344
|
}
|
|
390
345
|
if (!result.value.error) {
|
|
391
|
-
this_.synchronizeDispatch(
|
|
392
|
-
result.value as GraffitiObjectStreamContinueEntry<{}>,
|
|
393
|
-
);
|
|
346
|
+
this_.synchronizeDispatch(result.value);
|
|
394
347
|
}
|
|
395
348
|
yield result.value;
|
|
396
349
|
}
|
|
@@ -416,13 +369,8 @@ export class GraffitiSynchronize extends Graffiti {
|
|
|
416
369
|
return this.objectStream<(typeof args)[1]>(iterator);
|
|
417
370
|
};
|
|
418
371
|
|
|
419
|
-
|
|
420
|
-
const iterator = this.graffiti.
|
|
421
|
-
return this.objectStream<(typeof args)[0]>(iterator);
|
|
422
|
-
};
|
|
423
|
-
|
|
424
|
-
continueObjectStream: Graffiti["continueObjectStream"] = (...args) => {
|
|
425
|
-
const iterator = this.graffiti.continueObjectStream(...args);
|
|
372
|
+
continueDiscover: Graffiti["continueDiscover"] = (...args) => {
|
|
373
|
+
const iterator = this.graffiti.continueDiscover(...args);
|
|
426
374
|
return this.objectStreamContinue<{}>(iterator);
|
|
427
375
|
};
|
|
428
376
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
var Gr=Object.defineProperty;var H=(s,a)=>()=>(s&&(a=s(s=0)),a);var Hr=(s,a)=>()=>(a||s((a={exports:{}}).exports,a),a.exports),Xr=(s,a)=>{for(var x in a)Gr(s,x,{get:a[x],enumerable:!0})};var F=H(()=>{});function Wr(){if(yr)return V;yr=!0,V.byteLength=R,V.toByteArray=P,V.fromByteArray=N;for(var s=[],a=[],x=typeof Uint8Array<"u"?Uint8Array:Array,E="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",w=0,y=E.length;w<y;++w)s[w]=E[w],a[E.charCodeAt(w)]=w;a[45]=62,a[95]=63;function o(h){var l=h.length;if(l%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var d=h.indexOf("=");d===-1&&(d=l);var U=d===l?0:4-d%4;return[d,U]}function R(h){var l=o(h),d=l[0],U=l[1];return(d+U)*3/4-U}function b(h,l,d){return(l+d)*3/4-d}function P(h){var l,d=o(h),U=d[0],L=d[1],A=new x(b(h,U,L)),C=0,M=L>0?U-4:U,S;for(S=0;S<M;S+=4)l=a[h.charCodeAt(S)]<<18|a[h.charCodeAt(S+1)]<<12|a[h.charCodeAt(S+2)]<<6|a[h.charCodeAt(S+3)],A[C++]=l>>16&255,A[C++]=l>>8&255,A[C++]=l&255;return L===2&&(l=a[h.charCodeAt(S)]<<2|a[h.charCodeAt(S+1)]>>4,A[C++]=l&255),L===1&&(l=a[h.charCodeAt(S)]<<10|a[h.charCodeAt(S+1)]<<4|a[h.charCodeAt(S+2)]>>2,A[C++]=l>>8&255,A[C++]=l&255),A}function I(h){return s[h>>18&63]+s[h>>12&63]+s[h>>6&63]+s[h&63]}function T(h,l,d){for(var U,L=[],A=l;A<d;A+=3)U=(h[A]<<16&16711680)+(h[A+1]<<8&65280)+(h[A+2]&255),L.push(I(U));return L.join("")}function N(h){for(var l,d=h.length,U=d%3,L=[],A=16383,C=0,M=d-U;C<M;C+=A)L.push(T(h,C,C+A>M?M:C+A));return U===1?(l=h[d-1],L.push(s[l>>2]+s[l<<4&63]+"==")):U===2&&(l=(h[d-2]<<8)+h[d-1],L.push(s[l>>10]+s[l>>4&63]+s[l<<2&63]+"=")),L.join("")}return V}function qr(){if(dr)return z;dr=!0;return z.read=function(s,a,x,E,w){var y,o,R=w*8-E-1,b=(1<<R)-1,P=b>>1,I=-7,T=x?w-1:0,N=x?-1:1,h=s[a+T];for(T+=N,y=h&(1<<-I)-1,h>>=-I,I+=R;I>0;y=y*256+s[a+T],T+=N,I-=8);for(o=y&(1<<-I)-1,y>>=-I,I+=E;I>0;o=o*256+s[a+T],T+=N,I-=8);if(y===0)y=1-P;else{if(y===b)return o?NaN:(h?-1:1)*(1/0);o=o+Math.pow(2,E),y=y-P}return(h?-1:1)*o*Math.pow(2,y-E)},z.write=function(s,a,x,E,w,y){var o,R,b,P=y*8-w-1,I=(1<<P)-1,T=I>>1,N=w===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=E?0:y-1,l=E?1:-1,d=a<0||a===0&&1/a<0?1:0;for(a=Math.abs(a),isNaN(a)||a===1/0?(R=isNaN(a)?1:0,o=I):(o=Math.floor(Math.log(a)/Math.LN2),a*(b=Math.pow(2,-o))<1&&(o--,b*=2),o+T>=1?a+=N/b:a+=N*Math.pow(2,1-T),a*b>=2&&(o++,b/=2),o+T>=I?(R=0,o=I):o+T>=1?(R=(a*b-1)*Math.pow(2,w),o=o+T):(R=a*Math.pow(2,T-1)*Math.pow(2,w),o=0));w>=8;s[x+h]=R&255,h+=l,R/=256,w-=8);for(o=o<<w|R,P+=w;P>0;s[x+h]=o&255,h+=l,o/=256,P-=8);s[x+h-l]|=d*128},z}function mr(){if(gr)return D;gr=!0;let s=Wr(),a=qr(),x=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;D.Buffer=o,D.SlowBuffer=L,D.INSPECT_MAX_BYTES=50;let E=2147483647;D.kMaxLength=E,o.TYPED_ARRAY_SUPPORT=w(),!o.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function w(){try{let e=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(e,r),e.foo()===42}catch{return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function y(e){if(e>E)throw new RangeError('The value "'+e+'" is invalid for option "size"');let r=new Uint8Array(e);return Object.setPrototypeOf(r,o.prototype),r}function o(e,r,t){if(typeof e=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return I(e)}return R(e,r,t)}o.poolSize=8192;function R(e,r,t){if(typeof e=="string")return T(e,r);if(ArrayBuffer.isView(e))return h(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(v(e,ArrayBuffer)||e&&v(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(v(e,SharedArrayBuffer)||e&&v(e.buffer,SharedArrayBuffer)))return l(e,r,t);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return o.from(n,r,t);let i=d(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return o.from(e[Symbol.toPrimitive]("string"),r,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}o.from=function(e,r,t){return R(e,r,t)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function b(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function P(e,r,t){return b(e),e<=0?y(e):r!==void 0?typeof t=="string"?y(e).fill(r,t):y(e).fill(r):y(e)}o.alloc=function(e,r,t){return P(e,r,t)};function I(e){return b(e),y(e<0?0:U(e)|0)}o.allocUnsafe=function(e){return I(e)},o.allocUnsafeSlow=function(e){return I(e)};function T(e,r){if((typeof r!="string"||r==="")&&(r="utf8"),!o.isEncoding(r))throw new TypeError("Unknown encoding: "+r);let t=A(e,r)|0,n=y(t),i=n.write(e,r);return i!==t&&(n=n.slice(0,i)),n}function N(e){let r=e.length<0?0:U(e.length)|0,t=y(r);for(let n=0;n<r;n+=1)t[n]=e[n]&255;return t}function h(e){if(v(e,Uint8Array)){let r=new Uint8Array(e);return l(r.buffer,r.byteOffset,r.byteLength)}return N(e)}function l(e,r,t){if(r<0||e.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<r+(t||0))throw new RangeError('"length" is outside of buffer bounds');let n;return r===void 0&&t===void 0?n=new Uint8Array(e):t===void 0?n=new Uint8Array(e,r):n=new Uint8Array(e,r,t),Object.setPrototypeOf(n,o.prototype),n}function d(e){if(o.isBuffer(e)){let r=U(e.length)|0,t=y(r);return t.length===0||e.copy(t,0,0,r),t}if(e.length!==void 0)return typeof e.length!="number"||Z(e.length)?y(0):N(e);if(e.type==="Buffer"&&Array.isArray(e.data))return N(e.data)}function U(e){if(e>=E)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+E.toString(16)+" bytes");return e|0}function L(e){return+e!=e&&(e=0),o.alloc(+e)}o.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==o.prototype},o.compare=function(r,t){if(v(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),v(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(r)||!o.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===t)return 0;let n=r.length,i=t.length;for(let u=0,c=Math.min(n,i);u<c;++u)if(r[u]!==t[u]){n=r[u],i=t[u];break}return n<i?-1:i<n?1:0},o.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(r,t){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return o.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<r.length;++n)t+=r[n].length;let i=o.allocUnsafe(t),u=0;for(n=0;n<r.length;++n){let c=r[n];if(v(c,Uint8Array))u+c.length>i.length?(o.isBuffer(c)||(c=o.from(c)),c.copy(i,u)):Uint8Array.prototype.set.call(i,c,u);else if(o.isBuffer(c))c.copy(i,u);else throw new TypeError('"list" argument must be an Array of Buffers');u+=c.length}return i};function A(e,r){if(o.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||v(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let t=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let i=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return K(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return wr(e).length;default:if(i)return n?-1:K(e).length;r=(""+r).toLowerCase(),i=!0}}o.byteLength=A;function C(e,r,t){let n=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,r>>>=0,t<=r))return"";for(e||(e="utf8");;)switch(e){case"hex":return Mr(this,r,t);case"utf8":case"utf-8":return or(this,r,t);case"ascii":return Cr(this,r,t);case"latin1":case"binary":return kr(this,r,t);case"base64":return br(this,r,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Nr(this,r,t);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}o.prototype._isBuffer=!0;function M(e,r,t){let n=e[r];e[r]=e[t],e[t]=n}o.prototype.swap16=function(){let r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<r;t+=2)M(this,t,t+1);return this},o.prototype.swap32=function(){let r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<r;t+=4)M(this,t,t+3),M(this,t+1,t+2);return this},o.prototype.swap64=function(){let r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<r;t+=8)M(this,t,t+7),M(this,t+1,t+6),M(this,t+2,t+5),M(this,t+3,t+4);return this},o.prototype.toString=function(){let r=this.length;return r===0?"":arguments.length===0?or(this,0,r):C.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(r){if(!o.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:o.compare(this,r)===0},o.prototype.inspect=function(){let r="",t=D.INSPECT_MAX_BYTES;return r=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(r+=" ... "),"<Buffer "+r+">"},x&&(o.prototype[x]=o.prototype.inspect),o.prototype.compare=function(r,t,n,i,u){if(v(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),!o.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(t===void 0&&(t=0),n===void 0&&(n=r?r.length:0),i===void 0&&(i=0),u===void 0&&(u=this.length),t<0||n>r.length||i<0||u>this.length)throw new RangeError("out of range index");if(i>=u&&t>=n)return 0;if(i>=u)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,i>>>=0,u>>>=0,this===r)return 0;let c=u-i,p=n-t,B=Math.min(c,p),g=this.slice(i,u),m=r.slice(t,n);for(let f=0;f<B;++f)if(g[f]!==m[f]){c=g[f],p=m[f];break}return c<p?-1:p<c?1:0};function S(e,r,t,n,i){if(e.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,Z(t)&&(t=i?0:e.length-1),t<0&&(t=e.length+t),t>=e.length){if(i)return-1;t=e.length-1}else if(t<0)if(i)t=0;else return-1;if(typeof r=="string"&&(r=o.from(r,n)),o.isBuffer(r))return r.length===0?-1:ir(e,r,t,n,i);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,r,t):Uint8Array.prototype.lastIndexOf.call(e,r,t):ir(e,[r],t,n,i);throw new TypeError("val must be string, number or Buffer")}function ir(e,r,t,n,i){let u=1,c=e.length,p=r.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||r.length<2)return-1;u=2,c/=2,p/=2,t/=2}function B(m,f){return u===1?m[f]:m.readUInt16BE(f*u)}let g;if(i){let m=-1;for(g=t;g<c;g++)if(B(e,g)===B(r,m===-1?0:g-m)){if(m===-1&&(m=g),g-m+1===p)return m*u}else m!==-1&&(g-=g-m),m=-1}else for(t+p>c&&(t=c-p),g=t;g>=0;g--){let m=!0;for(let f=0;f<p;f++)if(B(e,g+f)!==B(r,f)){m=!1;break}if(m)return g}return-1}o.prototype.includes=function(r,t,n){return this.indexOf(r,t,n)!==-1},o.prototype.indexOf=function(r,t,n){return S(this,r,t,n,!0)},o.prototype.lastIndexOf=function(r,t,n){return S(this,r,t,n,!1)};function _r(e,r,t,n){t=Number(t)||0;let i=e.length-t;n?(n=Number(n),n>i&&(n=i)):n=i;let u=r.length;n>u/2&&(n=u/2);let c;for(c=0;c<n;++c){let p=parseInt(r.substr(c*2,2),16);if(Z(p))return c;e[t+c]=p}return c}function xr(e,r,t,n){return J(K(r,e.length-t),e,t,n)}function Tr(e,r,t,n){return J(Fr(r),e,t,n)}function Rr(e,r,t,n){return J(wr(r),e,t,n)}function Sr(e,r,t,n){return J(Dr(r,e.length-t),e,t,n)}o.prototype.write=function(r,t,n,i){if(t===void 0)i="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")i=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let u=this.length-t;if((n===void 0||n>u)&&(n=u),r.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let c=!1;for(;;)switch(i){case"hex":return _r(this,r,t,n);case"utf8":case"utf-8":return xr(this,r,t,n);case"ascii":case"latin1":case"binary":return Tr(this,r,t,n);case"base64":return Rr(this,r,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Sr(this,r,t,n);default:if(c)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),c=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function br(e,r,t){return r===0&&t===e.length?s.fromByteArray(e):s.fromByteArray(e.slice(r,t))}function or(e,r,t){t=Math.min(e.length,t);let n=[],i=r;for(;i<t;){let u=e[i],c=null,p=u>239?4:u>223?3:u>191?2:1;if(i+p<=t){let B,g,m,f;switch(p){case 1:u<128&&(c=u);break;case 2:B=e[i+1],(B&192)===128&&(f=(u&31)<<6|B&63,f>127&&(c=f));break;case 3:B=e[i+1],g=e[i+2],(B&192)===128&&(g&192)===128&&(f=(u&15)<<12|(B&63)<<6|g&63,f>2047&&(f<55296||f>57343)&&(c=f));break;case 4:B=e[i+1],g=e[i+2],m=e[i+3],(B&192)===128&&(g&192)===128&&(m&192)===128&&(f=(u&15)<<18|(B&63)<<12|(g&63)<<6|m&63,f>65535&&f<1114112&&(c=f))}}c===null?(c=65533,p=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|c&1023),n.push(c),i+=p}return Lr(n)}let ur=4096;function Lr(e){let r=e.length;if(r<=ur)return String.fromCharCode.apply(String,e);let t="",n=0;for(;n<r;)t+=String.fromCharCode.apply(String,e.slice(n,n+=ur));return t}function Cr(e,r,t){let n="";t=Math.min(e.length,t);for(let i=r;i<t;++i)n+=String.fromCharCode(e[i]&127);return n}function kr(e,r,t){let n="";t=Math.min(e.length,t);for(let i=r;i<t;++i)n+=String.fromCharCode(e[i]);return n}function Mr(e,r,t){let n=e.length;(!r||r<0)&&(r=0),(!t||t<0||t>n)&&(t=n);let i="";for(let u=r;u<t;++u)i+=Or[e[u]];return i}function Nr(e,r,t){let n=e.slice(r,t),i="";for(let u=0;u<n.length-1;u+=2)i+=String.fromCharCode(n[u]+n[u+1]*256);return i}o.prototype.slice=function(r,t){let n=this.length;r=~~r,t=t===void 0?n:~~t,r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<r&&(t=r);let i=this.subarray(r,t);return Object.setPrototypeOf(i,o.prototype),i};function _(e,r,t){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+r>t)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(r,t,n){r=r>>>0,t=t>>>0,n||_(r,t,this.length);let i=this[r],u=1,c=0;for(;++c<t&&(u*=256);)i+=this[r+c]*u;return i},o.prototype.readUintBE=o.prototype.readUIntBE=function(r,t,n){r=r>>>0,t=t>>>0,n||_(r,t,this.length);let i=this[r+--t],u=1;for(;t>0&&(u*=256);)i+=this[r+--t]*u;return i},o.prototype.readUint8=o.prototype.readUInt8=function(r,t){return r=r>>>0,t||_(r,1,this.length),this[r]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(r,t){return r=r>>>0,t||_(r,2,this.length),this[r]|this[r+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(r,t){return r=r>>>0,t||_(r,2,this.length),this[r]<<8|this[r+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(r,t){return r=r>>>0,t||_(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(r,t){return r=r>>>0,t||_(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},o.prototype.readBigUInt64LE=$(function(r){r=r>>>0,j(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&X(r,this.length-8);let i=t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,u=this[++r]+this[++r]*2**8+this[++r]*2**16+n*2**24;return BigInt(i)+(BigInt(u)<<BigInt(32))}),o.prototype.readBigUInt64BE=$(function(r){r=r>>>0,j(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&X(r,this.length-8);let i=t*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],u=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(u)}),o.prototype.readIntLE=function(r,t,n){r=r>>>0,t=t>>>0,n||_(r,t,this.length);let i=this[r],u=1,c=0;for(;++c<t&&(u*=256);)i+=this[r+c]*u;return u*=128,i>=u&&(i-=Math.pow(2,8*t)),i},o.prototype.readIntBE=function(r,t,n){r=r>>>0,t=t>>>0,n||_(r,t,this.length);let i=t,u=1,c=this[r+--i];for(;i>0&&(u*=256);)c+=this[r+--i]*u;return u*=128,c>=u&&(c-=Math.pow(2,8*t)),c},o.prototype.readInt8=function(r,t){return r=r>>>0,t||_(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},o.prototype.readInt16LE=function(r,t){r=r>>>0,t||_(r,2,this.length);let n=this[r]|this[r+1]<<8;return n&32768?n|4294901760:n},o.prototype.readInt16BE=function(r,t){r=r>>>0,t||_(r,2,this.length);let n=this[r+1]|this[r]<<8;return n&32768?n|4294901760:n},o.prototype.readInt32LE=function(r,t){return r=r>>>0,t||_(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},o.prototype.readInt32BE=function(r,t){return r=r>>>0,t||_(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},o.prototype.readBigInt64LE=$(function(r){r=r>>>0,j(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&X(r,this.length-8);let i=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)}),o.prototype.readBigInt64BE=$(function(r){r=r>>>0,j(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&X(r,this.length-8);let i=(t<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(i)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+n)}),o.prototype.readFloatLE=function(r,t){return r=r>>>0,t||_(r,4,this.length),a.read(this,r,!0,23,4)},o.prototype.readFloatBE=function(r,t){return r=r>>>0,t||_(r,4,this.length),a.read(this,r,!1,23,4)},o.prototype.readDoubleLE=function(r,t){return r=r>>>0,t||_(r,8,this.length),a.read(this,r,!0,52,8)},o.prototype.readDoubleBE=function(r,t){return r=r>>>0,t||_(r,8,this.length),a.read(this,r,!1,52,8)};function k(e,r,t,n,i,u){if(!o.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>i||r<u)throw new RangeError('"value" argument is out of bounds');if(t+n>e.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(r,t,n,i){if(r=+r,t=t>>>0,n=n>>>0,!i){let p=Math.pow(2,8*n)-1;k(this,r,t,n,p,0)}let u=1,c=0;for(this[t]=r&255;++c<n&&(u*=256);)this[t+c]=r/u&255;return t+n},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(r,t,n,i){if(r=+r,t=t>>>0,n=n>>>0,!i){let p=Math.pow(2,8*n)-1;k(this,r,t,n,p,0)}let u=n-1,c=1;for(this[t+u]=r&255;--u>=0&&(c*=256);)this[t+u]=r/c&255;return t+n},o.prototype.writeUint8=o.prototype.writeUInt8=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,1,255,0),this[t]=r&255,t+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,2,65535,0),this[t]=r&255,this[t+1]=r>>>8,t+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,2,65535,0),this[t]=r>>>8,this[t+1]=r&255,t+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,4,4294967295,0),this[t+3]=r>>>24,this[t+2]=r>>>16,this[t+1]=r>>>8,this[t]=r&255,t+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,4,4294967295,0),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4};function cr(e,r,t,n,i){fr(r,n,i,e,t,7);let u=Number(r&BigInt(4294967295));e[t++]=u,u=u>>8,e[t++]=u,u=u>>8,e[t++]=u,u=u>>8,e[t++]=u;let c=Number(r>>BigInt(32)&BigInt(4294967295));return e[t++]=c,c=c>>8,e[t++]=c,c=c>>8,e[t++]=c,c=c>>8,e[t++]=c,t}function ar(e,r,t,n,i){fr(r,n,i,e,t,7);let u=Number(r&BigInt(4294967295));e[t+7]=u,u=u>>8,e[t+6]=u,u=u>>8,e[t+5]=u,u=u>>8,e[t+4]=u;let c=Number(r>>BigInt(32)&BigInt(4294967295));return e[t+3]=c,c=c>>8,e[t+2]=c,c=c>>8,e[t+1]=c,c=c>>8,e[t]=c,t+8}o.prototype.writeBigUInt64LE=$(function(r,t=0){return cr(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=$(function(r,t=0){return ar(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(r,t,n,i){if(r=+r,t=t>>>0,!i){let B=Math.pow(2,8*n-1);k(this,r,t,n,B-1,-B)}let u=0,c=1,p=0;for(this[t]=r&255;++u<n&&(c*=256);)r<0&&p===0&&this[t+u-1]!==0&&(p=1),this[t+u]=(r/c>>0)-p&255;return t+n},o.prototype.writeIntBE=function(r,t,n,i){if(r=+r,t=t>>>0,!i){let B=Math.pow(2,8*n-1);k(this,r,t,n,B-1,-B)}let u=n-1,c=1,p=0;for(this[t+u]=r&255;--u>=0&&(c*=256);)r<0&&p===0&&this[t+u+1]!==0&&(p=1),this[t+u]=(r/c>>0)-p&255;return t+n},o.prototype.writeInt8=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,1,127,-128),r<0&&(r=255+r+1),this[t]=r&255,t+1},o.prototype.writeInt16LE=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,2,32767,-32768),this[t]=r&255,this[t+1]=r>>>8,t+2},o.prototype.writeInt16BE=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,2,32767,-32768),this[t]=r>>>8,this[t+1]=r&255,t+2},o.prototype.writeInt32LE=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,4,2147483647,-2147483648),this[t]=r&255,this[t+1]=r>>>8,this[t+2]=r>>>16,this[t+3]=r>>>24,t+4},o.prototype.writeInt32BE=function(r,t,n){return r=+r,t=t>>>0,n||k(this,r,t,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4},o.prototype.writeBigInt64LE=$(function(r,t=0){return cr(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=$(function(r,t=0){return ar(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function hr(e,r,t,n,i,u){if(t+n>e.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function sr(e,r,t,n,i){return r=+r,t=t>>>0,i||hr(e,r,t,4),a.write(e,r,t,n,23,4),t+4}o.prototype.writeFloatLE=function(r,t,n){return sr(this,r,t,!0,n)},o.prototype.writeFloatBE=function(r,t,n){return sr(this,r,t,!1,n)};function pr(e,r,t,n,i){return r=+r,t=t>>>0,i||hr(e,r,t,8),a.write(e,r,t,n,52,8),t+8}o.prototype.writeDoubleLE=function(r,t,n){return pr(this,r,t,!0,n)},o.prototype.writeDoubleBE=function(r,t,n){return pr(this,r,t,!1,n)},o.prototype.copy=function(r,t,n,i){if(!o.isBuffer(r))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),t>=r.length&&(t=r.length),t||(t=0),i>0&&i<n&&(i=n),i===n||r.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),r.length-t<i-n&&(i=r.length-t+n);let u=i-n;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,i):Uint8Array.prototype.set.call(r,this.subarray(n,i),t),u},o.prototype.fill=function(r,t,n,i){if(typeof r=="string"){if(typeof t=="string"?(i=t,t=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!o.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(r.length===1){let c=r.charCodeAt(0);(i==="utf8"&&c<128||i==="latin1")&&(r=c)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,r||(r=0);let u;if(typeof r=="number")for(u=t;u<n;++u)this[u]=r;else{let c=o.isBuffer(r)?r:o.from(r,i),p=c.length;if(p===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(u=0;u<n-t;++u)this[u+t]=c[u%p]}return this};let q={};function Q(e,r,t){q[e]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}Q("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Q("ERR_INVALID_ARG_TYPE",function(e,r){return`The "${e}" argument must be of type number. Received type ${typeof r}`},TypeError),Q("ERR_OUT_OF_RANGE",function(e,r,t){let n=`The value of "${e}" is out of range.`,i=t;return Number.isInteger(t)&&Math.abs(t)>2**32?i=lr(String(t)):typeof t=="bigint"&&(i=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(i=lr(i)),i+="n"),n+=` It must be ${r}. Received ${i}`,n},RangeError);function lr(e){let r="",t=e.length,n=e[0]==="-"?1:0;for(;t>=n+4;t-=3)r=`_${e.slice(t-3,t)}${r}`;return`${e.slice(0,t)}${r}`}function Pr(e,r,t){j(r,"offset"),(e[r]===void 0||e[r+t]===void 0)&&X(r,e.length-(t+1))}function fr(e,r,t,n,i,u){if(e>t||e<r){let c=typeof r=="bigint"?"n":"",p;throw r===0||r===BigInt(0)?p=`>= 0${c} and < 2${c} ** ${(u+1)*8}${c}`:p=`>= -(2${c} ** ${(u+1)*8-1}${c}) and < 2 ** ${(u+1)*8-1}${c}`,new q.ERR_OUT_OF_RANGE("value",p,e)}Pr(n,i,u)}function j(e,r){if(typeof e!="number")throw new q.ERR_INVALID_ARG_TYPE(r,"number",e)}function X(e,r,t){throw Math.floor(e)!==e?(j(e,t),new q.ERR_OUT_OF_RANGE("offset","an integer",e)):r<0?new q.ERR_BUFFER_OUT_OF_BOUNDS:new q.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,e)}let vr=/[^+/0-9A-Za-z-_]/g;function $r(e){if(e=e.split("=")[0],e=e.trim().replace(vr,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function K(e,r){r=r||1/0;let t,n=e.length,i=null,u=[];for(let c=0;c<n;++c){if(t=e.charCodeAt(c),t>55295&&t<57344){if(!i){if(t>56319){(r-=3)>-1&&u.push(239,191,189);continue}else if(c+1===n){(r-=3)>-1&&u.push(239,191,189);continue}i=t;continue}if(t<56320){(r-=3)>-1&&u.push(239,191,189),i=t;continue}t=(i-55296<<10|t-56320)+65536}else i&&(r-=3)>-1&&u.push(239,191,189);if(i=null,t<128){if((r-=1)<0)break;u.push(t)}else if(t<2048){if((r-=2)<0)break;u.push(t>>6|192,t&63|128)}else if(t<65536){if((r-=3)<0)break;u.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((r-=4)<0)break;u.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return u}function Fr(e){let r=[];for(let t=0;t<e.length;++t)r.push(e.charCodeAt(t)&255);return r}function Dr(e,r){let t,n,i,u=[];for(let c=0;c<e.length&&!((r-=2)<0);++c)t=e.charCodeAt(c),n=t>>8,i=t%256,u.push(i),u.push(n);return u}function wr(e){return s.toByteArray($r(e))}function J(e,r,t,n){let i;for(i=0;i<n&&!(i+t>=r.length||i>=e.length);++i)r[i+t]=e[i];return i}function v(e,r){return e instanceof r||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===r.name}function Z(e){return e!==e}let Or=(function(){let e="0123456789abcdef",r=new Array(256);for(let t=0;t<16;++t){let n=t*16;for(let i=0;i<16;++i)r[n+i]=e[t]+e[i]}return r})();function $(e){return typeof BigInt>"u"?Yr:e}function Yr(){throw new Error("BigInt not supported")}return D}var V,yr,z,dr,D,gr,Er=H(()=>{F();Y();O();V={},yr=!1;z={},dr=!1;D={},gr=!1});var G,tr,et,nt,Ir=H(()=>{F();Y();O();Er();G=mr();G.Buffer;G.SlowBuffer;G.INSPECT_MAX_BYTES;G.kMaxLength;tr=G.Buffer,et=G.INSPECT_MAX_BYTES,nt=G.kMaxLength});var Y=H(()=>{Ir()});function jr(s,a){this.fun=s,this.array=a}function Ar(s){var a=Math.floor((Date.now()-W.now())*.001),x=W.now()*.001,E=Math.floor(x)+a,w=Math.floor(x%1*1e9);return s&&(E=E-s[0],w=w-s[1],w<0&&(E--,w+=nr)),[E,w]}var st,W,er,nr,Ur=H(()=>{F();Y();O();jr.prototype.run=function(){this.fun.apply(null,this.array)};st={PATH:"/usr/bin",LANG:typeof navigator<"u"?navigator.language+".UTF-8":void 0,PWD:"/",HOME:"/home",TMP:"/tmp"},W={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};W.now===void 0&&(er=Date.now(),W.timing&&W.timing.navigationStart&&(er=W.timing.navigationStart),W.now=()=>Date.now()-er);nr=1e9;Ar.bigint=function(s){var a=Ar(s);return typeof BigInt>"u"?a[0]*nr+a[1]:BigInt(a[0]*nr)+BigInt(a[1])}});var O=H(()=>{Ur()});export{Hr as a,Xr as b,F as c,O as d,Y as e};
|
|
2
|
-
/*! Bundled license information:
|
|
3
|
-
|
|
4
|
-
@jspm/core/nodelibs/browser/chunk-DtuTasat.js:
|
|
5
|
-
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
6
|
-
*/
|
|
7
|
-
//# sourceMappingURL=chunk-ZOOM6B5R.js.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import{b as K,c as _,d as A,e as d}from"./chunk-ZOOM6B5R.js";_();d();A();var M={};K(M,{JsonPatchError:()=>p,_areEquals:()=>P,applyOperation:()=>E,applyPatch:()=>C,applyReducer:()=>Z,deepClone:()=>X,getValueByPointer:()=>D,validate:()=>z,validator:()=>L});_();d();A();_();d();A();var G=(function(){var e=function(r,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,f){n.__proto__=f}||function(n,f){for(var o in f)f.hasOwnProperty(o)&&(n[o]=f[o])},e(r,t)};return function(r,t){e(r,t);function n(){this.constructor=r}r.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),W=Object.prototype.hasOwnProperty;function g(e,r){return W.call(e,r)}function R(e){if(Array.isArray(e)){for(var r=new Array(e.length),t=0;t<r.length;t++)r[t]=""+t;return r}if(Object.keys)return Object.keys(e);var n=[];for(var f in e)g(e,f)&&n.push(f);return n}function h(e){switch(typeof e){case"object":return JSON.parse(JSON.stringify(e));case"undefined":return null;default:return e}}function I(e){for(var r=0,t=e.length,n;r<t;){if(n=e.charCodeAt(r),n>=48&&n<=57){r++;continue}return!1}return!0}function O(e){return e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function T(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function m(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(var r=0,t=e.length;r<t;r++)if(m(e[r]))return!0}else if(typeof e=="object"){for(var n=R(e),f=n.length,o=0;o<f;o++)if(m(e[n[o]]))return!0}}return!1}function Y(e,r){var t=[e];for(var n in r){var f=typeof r[n]=="object"?JSON.stringify(r[n],null,2):r[n];typeof f<"u"&&t.push(n+": "+f)}return t.join(`
|
|
2
|
-
`)}var N=(function(e){G(r,e);function r(t,n,f,o,s){var i=this.constructor,l=e.call(this,Y(t,{name:n,index:f,operation:o,tree:s}))||this;return l.name=n,l.index=f,l.operation=o,l.tree=s,Object.setPrototypeOf(l,i.prototype),l.message=Y(t,{name:n,index:f,operation:o,tree:s}),l}return r})(Error);var p=N,X=h,y={add:function(e,r,t){return e[r]=this.value,{newDocument:t}},remove:function(e,r,t){var n=e[r];return delete e[r],{newDocument:t,removed:n}},replace:function(e,r,t){var n=e[r];return e[r]=this.value,{newDocument:t,removed:n}},move:function(e,r,t){var n=D(t,this.path);n&&(n=h(n));var f=E(t,{op:"remove",path:this.from}).removed;return E(t,{op:"add",path:this.path,value:f}),{newDocument:t,removed:n}},copy:function(e,r,t){var n=D(t,this.from);return E(t,{op:"add",path:this.path,value:h(n)}),{newDocument:t}},test:function(e,r,t){return{newDocument:t,test:P(e[r],this.value)}},_get:function(e,r,t){return this.value=e[r],{newDocument:t}}},q={add:function(e,r,t){return I(r)?e.splice(r,0,this.value):e[r]=this.value,{newDocument:t,index:r}},remove:function(e,r,t){var n=e.splice(r,1);return{newDocument:t,removed:n[0]}},replace:function(e,r,t){var n=e[r];return e[r]=this.value,{newDocument:t,removed:n}},move:y.move,copy:y.copy,test:y.test,_get:y._get};function D(e,r){if(r=="")return e;var t={op:"_get",path:r};return E(e,t),t.value}function E(e,r,t,n,f,o){if(t===void 0&&(t=!1),n===void 0&&(n=!0),f===void 0&&(f=!0),o===void 0&&(o=0),t&&(typeof t=="function"?t(r,0,e,r.path):L(r,0)),r.path===""){var s={newDocument:e};if(r.op==="add")return s.newDocument=r.value,s;if(r.op==="replace")return s.newDocument=r.value,s.removed=e,s;if(r.op==="move"||r.op==="copy")return s.newDocument=D(e,r.from),r.op==="move"&&(s.removed=e),s;if(r.op==="test"){if(s.test=P(e,r.value),s.test===!1)throw new p("Test operation failed","TEST_OPERATION_FAILED",o,r,e);return s.newDocument=e,s}else{if(r.op==="remove")return s.removed=e,s.newDocument=null,s;if(r.op==="_get")return r.value=e,s;if(t)throw new p("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",o,r,e);return s}}else{n||(e=h(e));var i=r.path||"",l=i.split("/"),u=e,a=1,c=l.length,w=void 0,v=void 0,x=void 0;for(typeof t=="function"?x=t:x=L;;){if(v=l[a],v&&v.indexOf("~")!=-1&&(v=T(v)),f&&(v=="__proto__"||v=="prototype"&&a>0&&l[a-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(t&&w===void 0&&(u[v]===void 0?w=l.slice(0,a).join("/"):a==c-1&&(w=r.path),w!==void 0&&x(r,0,e,w)),a++,Array.isArray(u)){if(v==="-")v=u.length;else{if(t&&!I(v))throw new p("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",o,r,e);I(v)&&(v=~~v)}if(a>=c){if(t&&r.op==="add"&&v>u.length)throw new p("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",o,r,e);var s=q[r.op].call(r,u,v,e);if(s.test===!1)throw new p("Test operation failed","TEST_OPERATION_FAILED",o,r,e);return s}}else if(a>=c){var s=y[r.op].call(r,u,v,e);if(s.test===!1)throw new p("Test operation failed","TEST_OPERATION_FAILED",o,r,e);return s}if(u=u[v],t&&a<c&&(!u||typeof u!="object"))throw new p("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",o,r,e)}}}function C(e,r,t,n,f){if(n===void 0&&(n=!0),f===void 0&&(f=!0),t&&!Array.isArray(r))throw new p("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");n||(e=h(e));for(var o=new Array(r.length),s=0,i=r.length;s<i;s++)o[s]=E(e,r[s],t,!0,f,s),e=o[s].newDocument;return o.newDocument=e,o}function Z(e,r,t){var n=E(e,r);if(n.test===!1)throw new p("Test operation failed","TEST_OPERATION_FAILED",t,r,e);return n.newDocument}function L(e,r,t,n){if(typeof e!="object"||e===null||Array.isArray(e))throw new p("Operation is not an object","OPERATION_NOT_AN_OBJECT",r,e,t);if(y[e.op]){if(typeof e.path!="string")throw new p("Operation `path` property is not a string","OPERATION_PATH_INVALID",r,e,t);if(e.path.indexOf("/")!==0&&e.path.length>0)throw new p('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",r,e,t);if((e.op==="move"||e.op==="copy")&&typeof e.from!="string")throw new p("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",r,e,t);if((e.op==="add"||e.op==="replace"||e.op==="test")&&e.value===void 0)throw new p("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",r,e,t);if((e.op==="add"||e.op==="replace"||e.op==="test")&&m(e.value))throw new p("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",r,e,t);if(t){if(e.op=="add"){var f=e.path.split("/").length,o=n.split("/").length;if(f!==o+1&&f!==o)throw new p("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",r,e,t)}else if(e.op==="replace"||e.op==="remove"||e.op==="_get"){if(e.path!==n)throw new p("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",r,e,t)}else if(e.op==="move"||e.op==="copy"){var s={op:"_get",path:e.from,value:void 0},i=z([s],t);if(i&&i.name==="OPERATION_PATH_UNRESOLVABLE")throw new p("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",r,e,t)}}}else throw new p("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",r,e,t)}function z(e,r,t){try{if(!Array.isArray(e))throw new p("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(r)C(h(r),h(e),t||!0);else{t=t||L;for(var n=0;n<e.length;n++)t(e[n],n,r,void 0)}}catch(f){if(f instanceof p)return f;throw f}}function P(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){var t=Array.isArray(e),n=Array.isArray(r),f,o,s;if(t&&n){if(o=e.length,o!=r.length)return!1;for(f=o;f--!==0;)if(!P(e[f],r[f]))return!1;return!0}if(t!=n)return!1;var i=Object.keys(e);if(o=i.length,o!==Object.keys(r).length)return!1;for(f=o;f--!==0;)if(!r.hasOwnProperty(i[f]))return!1;for(f=o;f--!==0;)if(s=i[f],!P(e[s],r[s]))return!1;return!0}return e!==e&&r!==r}var Q={};K(Q,{compare:()=>te,generate:()=>H,observe:()=>re,unobserve:()=>ee});_();d();A();var B=new WeakMap,$=(function(){function e(r){this.observers=new Map,this.obj=r}return e})(),j=(function(){function e(r,t){this.callback=r,this.observer=t}return e})();function V(e){return B.get(e)}function b(e,r){return e.observers.get(r)}function k(e,r){e.observers.delete(r.callback)}function ee(e,r){r.unobserve()}function re(e,r){var t=[],n,f=V(e);if(!f)f=new $(e),B.set(e,f);else{var o=b(f,r);n=o&&o.observer}if(n)return n;if(n={},f.value=h(e),r){n.callback=r,n.next=null;var s=function(){H(n)},i=function(){clearTimeout(n.next),n.next=setTimeout(s)};typeof window<"u"&&(window.addEventListener("mouseup",i),window.addEventListener("keyup",i),window.addEventListener("mousedown",i),window.addEventListener("keydown",i),window.addEventListener("change",i))}return n.patches=t,n.object=e,n.unobserve=function(){H(n),clearTimeout(n.next),k(f,n),typeof window<"u"&&(window.removeEventListener("mouseup",i),window.removeEventListener("keyup",i),window.removeEventListener("mousedown",i),window.removeEventListener("keydown",i),window.removeEventListener("change",i))},f.observers.set(r,new j(r,n)),n}function H(e,r){r===void 0&&(r=!1);var t=B.get(e.object);F(t.value,e.object,e.patches,"",r),e.patches.length&&C(t.value,e.patches);var n=e.patches;return n.length>0&&(e.patches=[],e.callback&&e.callback(n)),n}function F(e,r,t,n,f){if(r!==e){typeof r.toJSON=="function"&&(r=r.toJSON());for(var o=R(r),s=R(e),i=!1,l=!1,u=s.length-1;u>=0;u--){var a=s[u],c=e[a];if(g(r,a)&&!(r[a]===void 0&&c!==void 0&&Array.isArray(r)===!1)){var w=r[a];typeof c=="object"&&c!=null&&typeof w=="object"&&w!=null&&Array.isArray(c)===Array.isArray(w)?F(c,w,t,n+"/"+O(a),f):c!==w&&(i=!0,f&&t.push({op:"test",path:n+"/"+O(a),value:h(c)}),t.push({op:"replace",path:n+"/"+O(a),value:h(w)}))}else Array.isArray(e)===Array.isArray(r)?(f&&t.push({op:"test",path:n+"/"+O(a),value:h(c)}),t.push({op:"remove",path:n+"/"+O(a)}),l=!0):(f&&t.push({op:"test",path:n,value:e}),t.push({op:"replace",path:n,value:r}),i=!0)}if(!(!l&&o.length==s.length))for(var u=0;u<o.length;u++){var a=o[u];!g(e,a)&&r[a]!==void 0&&t.push({op:"add",path:n+"/"+O(a),value:h(r[a])})}}}function te(e,r,t){t===void 0&&(t=!1);var n=[];return F(e,r,n,"",t),n}var _e=Object.assign({},M,Q,{JsonPatchError:N,deepClone:h,escapePathComponent:O,unescapePathComponent:T});export{N as JsonPatchError,P as _areEquals,E as applyOperation,C as applyPatch,Z as applyReducer,te as compare,h as deepClone,_e as default,O as escapePathComponent,H as generate,D as getValueByPointer,re as observe,T as unescapePathComponent,ee as unobserve,z as validate,L as validator};
|
|
3
|
-
/*! Bundled license information:
|
|
4
|
-
|
|
5
|
-
fast-json-patch/module/helpers.mjs:
|
|
6
|
-
(*!
|
|
7
|
-
* https://github.com/Starcounter-Jack/JSON-Patch
|
|
8
|
-
* (c) 2017-2022 Joachim Wester
|
|
9
|
-
* MIT licensed
|
|
10
|
-
*)
|
|
11
|
-
|
|
12
|
-
fast-json-patch/module/duplex.mjs:
|
|
13
|
-
(*!
|
|
14
|
-
* https://github.com/Starcounter-Jack/JSON-Patch
|
|
15
|
-
* (c) 2017-2021 Joachim Wester
|
|
16
|
-
* MIT license
|
|
17
|
-
*)
|
|
18
|
-
*/
|
|
19
|
-
//# sourceMappingURL=fast-json-patch-5UD2BOZL.js.map
|