document-model 1.1.0-experimental.1 → 1.1.0-experimental.3
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/cjs/document-model.js +1 -1
- package/dist/browser/cjs/document.js +1 -1
- package/dist/browser/cjs/index.js +1 -1
- package/dist/browser/cjs/internal/index-DMRH7zDy.js +1 -0
- package/dist/browser/cjs/internal/{index-DypcJuba.js → index-dwAOfmBp.js} +1 -1
- package/dist/browser/cjs/internal/object-C-PazS9q.js +25 -0
- package/dist/browser/es/document-model.js +2 -2
- package/dist/browser/es/document.js +2 -2
- package/dist/browser/es/index.js +3 -3
- package/dist/browser/es/internal/index-BVJxzkIs.js +44 -0
- package/dist/browser/es/internal/{index-CyBZ1dJQ.js → index-DQztOVJu.js} +1 -1
- package/dist/browser/es/internal/{object-CPDHmXxz.js → object-iTBekDVP.js} +1211 -1123
- package/dist/browser/src/document/object.d.ts +35 -0
- package/dist/browser/src/document/types.d.ts +6 -0
- package/dist/browser/src/document/utils/base.d.ts +5 -4
- package/dist/browser/src/document/utils/document-helpers.d.ts +1 -1
- package/dist/browser/src/document/utils/index.d.ts +1 -1
- package/dist/node/cjs/document-model.js +1 -1
- package/dist/node/cjs/document.js +1 -1
- package/dist/node/cjs/index.js +1 -1
- package/dist/node/cjs/internal/{index-Bt4KwBzM.js → index-BNFVmPew.js} +1 -1
- package/dist/node/cjs/internal/index-FvRO8SnG.js +1 -0
- package/dist/node/cjs/internal/object-Xvr4kDQj.js +20 -0
- package/dist/node/es/document-model.js +2 -2
- package/dist/node/es/document.js +2 -2
- package/dist/node/es/index.js +3 -3
- package/dist/node/es/internal/index-BIrQOTP_.js +44 -0
- package/dist/node/es/internal/{index-6nUwJlFL.js → index-DOpbr_uw.js} +1 -1
- package/dist/node/es/internal/{object-DofGWMf1.js → object-C2s2eZ08.js} +695 -607
- package/dist/node/src/document/object.d.ts +35 -0
- package/dist/node/src/document/types.d.ts +6 -0
- package/dist/node/src/document/utils/base.d.ts +5 -4
- package/dist/node/src/document/utils/document-helpers.d.ts +1 -1
- package/dist/node/src/document/utils/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/browser/cjs/internal/index-DZx9eknf.js +0 -1
- package/dist/browser/cjs/internal/object-BU2CI8g7.js +0 -25
- package/dist/browser/es/internal/index-BP3Z2ZVF.js +0 -43
- package/dist/node/cjs/internal/index-CwTTSCCW.js +0 -1
- package/dist/node/cjs/internal/object-Bc_eSRcx.js +0 -20
- package/dist/node/es/internal/index-CLgAZiia.js +0 -43
|
@@ -89,6 +89,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
89
89
|
readonly hash: string;
|
|
90
90
|
readonly skip: number;
|
|
91
91
|
readonly error?: string | undefined;
|
|
92
|
+
readonly resultingState?: unknown;
|
|
92
93
|
} | {
|
|
93
94
|
readonly type: "PRUNE";
|
|
94
95
|
readonly input: {
|
|
@@ -122,6 +123,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
122
123
|
readonly hash: string;
|
|
123
124
|
readonly skip: number;
|
|
124
125
|
readonly error?: string | undefined;
|
|
126
|
+
readonly resultingState?: unknown;
|
|
125
127
|
} | {
|
|
126
128
|
readonly type: "REDO";
|
|
127
129
|
readonly input: number;
|
|
@@ -152,6 +154,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
152
154
|
readonly hash: string;
|
|
153
155
|
readonly skip: number;
|
|
154
156
|
readonly error?: string | undefined;
|
|
157
|
+
readonly resultingState?: unknown;
|
|
155
158
|
} | {
|
|
156
159
|
readonly type: "SET_NAME";
|
|
157
160
|
readonly input: string;
|
|
@@ -182,6 +185,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
182
185
|
readonly hash: string;
|
|
183
186
|
readonly skip: number;
|
|
184
187
|
readonly error?: string | undefined;
|
|
188
|
+
readonly resultingState?: unknown;
|
|
185
189
|
} | {
|
|
186
190
|
readonly type: "UNDO";
|
|
187
191
|
readonly input: number;
|
|
@@ -212,6 +216,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
212
216
|
readonly hash: string;
|
|
213
217
|
readonly skip: number;
|
|
214
218
|
readonly error?: string | undefined;
|
|
219
|
+
readonly resultingState?: unknown;
|
|
215
220
|
} | {
|
|
216
221
|
readonly type: "NOOP";
|
|
217
222
|
readonly input: unknown;
|
|
@@ -242,12 +247,14 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
242
247
|
readonly hash: string;
|
|
243
248
|
readonly skip: number;
|
|
244
249
|
readonly error?: string | undefined;
|
|
250
|
+
readonly resultingState?: unknown;
|
|
245
251
|
} | import("immer").Immutable<A & {
|
|
246
252
|
index: number;
|
|
247
253
|
timestamp: string;
|
|
248
254
|
hash: string;
|
|
249
255
|
skip: number;
|
|
250
256
|
error?: string | undefined;
|
|
257
|
+
resultingState?: unknown;
|
|
251
258
|
}>)[];
|
|
252
259
|
readonly local: readonly ({
|
|
253
260
|
readonly type: "LOAD_STATE";
|
|
@@ -285,6 +292,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
285
292
|
readonly hash: string;
|
|
286
293
|
readonly skip: number;
|
|
287
294
|
readonly error?: string | undefined;
|
|
295
|
+
readonly resultingState?: unknown;
|
|
288
296
|
} | {
|
|
289
297
|
readonly type: "PRUNE";
|
|
290
298
|
readonly input: {
|
|
@@ -318,6 +326,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
318
326
|
readonly hash: string;
|
|
319
327
|
readonly skip: number;
|
|
320
328
|
readonly error?: string | undefined;
|
|
329
|
+
readonly resultingState?: unknown;
|
|
321
330
|
} | {
|
|
322
331
|
readonly type: "REDO";
|
|
323
332
|
readonly input: number;
|
|
@@ -348,6 +357,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
348
357
|
readonly hash: string;
|
|
349
358
|
readonly skip: number;
|
|
350
359
|
readonly error?: string | undefined;
|
|
360
|
+
readonly resultingState?: unknown;
|
|
351
361
|
} | {
|
|
352
362
|
readonly type: "SET_NAME";
|
|
353
363
|
readonly input: string;
|
|
@@ -378,6 +388,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
378
388
|
readonly hash: string;
|
|
379
389
|
readonly skip: number;
|
|
380
390
|
readonly error?: string | undefined;
|
|
391
|
+
readonly resultingState?: unknown;
|
|
381
392
|
} | {
|
|
382
393
|
readonly type: "UNDO";
|
|
383
394
|
readonly input: number;
|
|
@@ -408,6 +419,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
408
419
|
readonly hash: string;
|
|
409
420
|
readonly skip: number;
|
|
410
421
|
readonly error?: string | undefined;
|
|
422
|
+
readonly resultingState?: unknown;
|
|
411
423
|
} | {
|
|
412
424
|
readonly type: "NOOP";
|
|
413
425
|
readonly input: unknown;
|
|
@@ -438,12 +450,14 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
438
450
|
readonly hash: string;
|
|
439
451
|
readonly skip: number;
|
|
440
452
|
readonly error?: string | undefined;
|
|
453
|
+
readonly resultingState?: unknown;
|
|
441
454
|
} | import("immer").Immutable<A & {
|
|
442
455
|
index: number;
|
|
443
456
|
timestamp: string;
|
|
444
457
|
hash: string;
|
|
445
458
|
skip: number;
|
|
446
459
|
error?: string | undefined;
|
|
460
|
+
resultingState?: unknown;
|
|
447
461
|
}>)[];
|
|
448
462
|
};
|
|
449
463
|
/**
|
|
@@ -553,6 +567,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
553
567
|
readonly hash: string;
|
|
554
568
|
readonly skip: number;
|
|
555
569
|
readonly error?: string | undefined;
|
|
570
|
+
readonly resultingState?: unknown;
|
|
556
571
|
} | {
|
|
557
572
|
readonly type: "PRUNE";
|
|
558
573
|
readonly input: {
|
|
@@ -586,6 +601,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
586
601
|
readonly hash: string;
|
|
587
602
|
readonly skip: number;
|
|
588
603
|
readonly error?: string | undefined;
|
|
604
|
+
readonly resultingState?: unknown;
|
|
589
605
|
} | {
|
|
590
606
|
readonly type: "REDO";
|
|
591
607
|
readonly input: number;
|
|
@@ -616,6 +632,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
616
632
|
readonly hash: string;
|
|
617
633
|
readonly skip: number;
|
|
618
634
|
readonly error?: string | undefined;
|
|
635
|
+
readonly resultingState?: unknown;
|
|
619
636
|
} | {
|
|
620
637
|
readonly type: "SET_NAME";
|
|
621
638
|
readonly input: string;
|
|
@@ -646,6 +663,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
646
663
|
readonly hash: string;
|
|
647
664
|
readonly skip: number;
|
|
648
665
|
readonly error?: string | undefined;
|
|
666
|
+
readonly resultingState?: unknown;
|
|
649
667
|
} | {
|
|
650
668
|
readonly type: "UNDO";
|
|
651
669
|
readonly input: number;
|
|
@@ -676,6 +694,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
676
694
|
readonly hash: string;
|
|
677
695
|
readonly skip: number;
|
|
678
696
|
readonly error?: string | undefined;
|
|
697
|
+
readonly resultingState?: unknown;
|
|
679
698
|
} | {
|
|
680
699
|
readonly type: "NOOP";
|
|
681
700
|
readonly input: unknown;
|
|
@@ -706,12 +725,14 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
706
725
|
readonly hash: string;
|
|
707
726
|
readonly skip: number;
|
|
708
727
|
readonly error?: string | undefined;
|
|
728
|
+
readonly resultingState?: unknown;
|
|
709
729
|
} | import("immer").Immutable<A & {
|
|
710
730
|
index: number;
|
|
711
731
|
timestamp: string;
|
|
712
732
|
hash: string;
|
|
713
733
|
skip: number;
|
|
714
734
|
error?: string | undefined;
|
|
735
|
+
resultingState?: unknown;
|
|
715
736
|
}>)[];
|
|
716
737
|
readonly local: readonly ({
|
|
717
738
|
readonly type: "LOAD_STATE";
|
|
@@ -749,6 +770,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
749
770
|
readonly hash: string;
|
|
750
771
|
readonly skip: number;
|
|
751
772
|
readonly error?: string | undefined;
|
|
773
|
+
readonly resultingState?: unknown;
|
|
752
774
|
} | {
|
|
753
775
|
readonly type: "PRUNE";
|
|
754
776
|
readonly input: {
|
|
@@ -782,6 +804,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
782
804
|
readonly hash: string;
|
|
783
805
|
readonly skip: number;
|
|
784
806
|
readonly error?: string | undefined;
|
|
807
|
+
readonly resultingState?: unknown;
|
|
785
808
|
} | {
|
|
786
809
|
readonly type: "REDO";
|
|
787
810
|
readonly input: number;
|
|
@@ -812,6 +835,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
812
835
|
readonly hash: string;
|
|
813
836
|
readonly skip: number;
|
|
814
837
|
readonly error?: string | undefined;
|
|
838
|
+
readonly resultingState?: unknown;
|
|
815
839
|
} | {
|
|
816
840
|
readonly type: "SET_NAME";
|
|
817
841
|
readonly input: string;
|
|
@@ -842,6 +866,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
842
866
|
readonly hash: string;
|
|
843
867
|
readonly skip: number;
|
|
844
868
|
readonly error?: string | undefined;
|
|
869
|
+
readonly resultingState?: unknown;
|
|
845
870
|
} | {
|
|
846
871
|
readonly type: "UNDO";
|
|
847
872
|
readonly input: number;
|
|
@@ -872,6 +897,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
872
897
|
readonly hash: string;
|
|
873
898
|
readonly skip: number;
|
|
874
899
|
readonly error?: string | undefined;
|
|
900
|
+
readonly resultingState?: unknown;
|
|
875
901
|
} | {
|
|
876
902
|
readonly type: "NOOP";
|
|
877
903
|
readonly input: unknown;
|
|
@@ -902,12 +928,14 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
902
928
|
readonly hash: string;
|
|
903
929
|
readonly skip: number;
|
|
904
930
|
readonly error?: string | undefined;
|
|
931
|
+
readonly resultingState?: unknown;
|
|
905
932
|
} | import("immer").Immutable<A & {
|
|
906
933
|
index: number;
|
|
907
934
|
timestamp: string;
|
|
908
935
|
hash: string;
|
|
909
936
|
skip: number;
|
|
910
937
|
error?: string | undefined;
|
|
938
|
+
resultingState?: unknown;
|
|
911
939
|
}>)[];
|
|
912
940
|
};
|
|
913
941
|
readonly initialState: {
|
|
@@ -968,6 +996,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
968
996
|
readonly hash: string;
|
|
969
997
|
readonly skip: number;
|
|
970
998
|
readonly error?: string | undefined;
|
|
999
|
+
readonly resultingState?: unknown;
|
|
971
1000
|
} | {
|
|
972
1001
|
readonly type: "PRUNE";
|
|
973
1002
|
readonly input: {
|
|
@@ -1001,6 +1030,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
1001
1030
|
readonly hash: string;
|
|
1002
1031
|
readonly skip: number;
|
|
1003
1032
|
readonly error?: string | undefined;
|
|
1033
|
+
readonly resultingState?: unknown;
|
|
1004
1034
|
} | {
|
|
1005
1035
|
readonly type: "REDO";
|
|
1006
1036
|
readonly input: number;
|
|
@@ -1031,6 +1061,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
1031
1061
|
readonly hash: string;
|
|
1032
1062
|
readonly skip: number;
|
|
1033
1063
|
readonly error?: string | undefined;
|
|
1064
|
+
readonly resultingState?: unknown;
|
|
1034
1065
|
} | {
|
|
1035
1066
|
readonly type: "SET_NAME";
|
|
1036
1067
|
readonly input: string;
|
|
@@ -1061,6 +1092,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
1061
1092
|
readonly hash: string;
|
|
1062
1093
|
readonly skip: number;
|
|
1063
1094
|
readonly error?: string | undefined;
|
|
1095
|
+
readonly resultingState?: unknown;
|
|
1064
1096
|
} | {
|
|
1065
1097
|
readonly type: "UNDO";
|
|
1066
1098
|
readonly input: number;
|
|
@@ -1091,6 +1123,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
1091
1123
|
readonly hash: string;
|
|
1092
1124
|
readonly skip: number;
|
|
1093
1125
|
readonly error?: string | undefined;
|
|
1126
|
+
readonly resultingState?: unknown;
|
|
1094
1127
|
} | {
|
|
1095
1128
|
readonly type: "NOOP";
|
|
1096
1129
|
readonly input: unknown;
|
|
@@ -1121,12 +1154,14 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
1121
1154
|
readonly hash: string;
|
|
1122
1155
|
readonly skip: number;
|
|
1123
1156
|
readonly error?: string | undefined;
|
|
1157
|
+
readonly resultingState?: unknown;
|
|
1124
1158
|
} | import("immer").Immutable<A & {
|
|
1125
1159
|
index: number;
|
|
1126
1160
|
timestamp: string;
|
|
1127
1161
|
hash: string;
|
|
1128
1162
|
skip: number;
|
|
1129
1163
|
error?: string | undefined;
|
|
1164
|
+
resultingState?: unknown;
|
|
1130
1165
|
}>)[];
|
|
1131
1166
|
};
|
|
1132
1167
|
/**
|
|
@@ -52,6 +52,10 @@ export type ReducerOptions = {
|
|
|
52
52
|
ignoreSkipOperations?: boolean;
|
|
53
53
|
/** if true reuses the provided action hash */
|
|
54
54
|
reuseHash?: boolean;
|
|
55
|
+
/** if true reuses the provided action resulting state instead of replaying it */
|
|
56
|
+
reuseOperationResultingState?: boolean;
|
|
57
|
+
/** Optional parser for the operation resulting state, uses JSON.parse by default */
|
|
58
|
+
operationResultingStateParser?: (state: unknown) => object;
|
|
55
59
|
};
|
|
56
60
|
/**
|
|
57
61
|
* A pure function that takes an action and the previous state
|
|
@@ -102,6 +106,8 @@ export type Operation<A extends Action = Action> = A & {
|
|
|
102
106
|
skip: number;
|
|
103
107
|
/** Error message for a failed action */
|
|
104
108
|
error?: string;
|
|
109
|
+
/** The resulting state after the operation */
|
|
110
|
+
resultingState?: unknown;
|
|
105
111
|
};
|
|
106
112
|
/**
|
|
107
113
|
* The base attributes of a {@link Document}.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { baseReducer } from '../reducer';
|
|
2
|
-
import { Action, BaseAction, UndoRedoAction, Document, ExtendedState, ImmutableStateReducer, Reducer, Immutable, OperationScope, State, CreateState, PartialState, DocumentOperations, DocumentHeader, DocumentOperationsIgnoreMap, Operation, MappedOperation } from '../types';
|
|
2
|
+
import { Action, BaseAction, UndoRedoAction, Document, ExtendedState, ImmutableStateReducer, Reducer, Immutable, OperationScope, State, CreateState, PartialState, DocumentOperations, DocumentHeader, DocumentOperationsIgnoreMap, Operation, MappedOperation, ReducerOptions } from '../types';
|
|
3
3
|
import { SignalDispatch } from '../signal';
|
|
4
4
|
export declare function isNoopOperation(op: Partial<Operation>): boolean;
|
|
5
5
|
export declare function isUndoRedo(action: Action): action is UndoRedoAction;
|
|
@@ -74,12 +74,13 @@ export declare function mapSkippedOperations<A extends Action>(operations: Opera
|
|
|
74
74
|
export declare function calculateSkipsLeft<A extends Action>(operations: Operation<BaseAction | A>[], currentIndex: number, skip: number): number;
|
|
75
75
|
export declare function sortOperations<A extends Action>(operations: DocumentOperations<A>): Operation<BaseAction | A>[];
|
|
76
76
|
export declare function sortMappedOperations<A extends Action>(operations: DocumentOperationsIgnoreMap<A>): MappedOperation<A>[];
|
|
77
|
-
export declare function replayOperations<T, A extends Action, L>(initialState: ExtendedState<T, L>, clearedOperations: DocumentOperations<A>, reducer: ImmutableStateReducer<T, A, L>, dispatch?: SignalDispatch, header?: DocumentHeader, documentReducer?: typeof baseReducer, skipHeaderOperations?: SkipHeaderOperations, options?:
|
|
78
|
-
checkHashes?: boolean;
|
|
79
|
-
}): Document<T, A, L>;
|
|
77
|
+
export declare function replayOperations<T, A extends Action, L>(initialState: ExtendedState<T, L>, clearedOperations: DocumentOperations<A>, reducer: ImmutableStateReducer<T, A, L>, dispatch?: SignalDispatch, header?: DocumentHeader, documentReducer?: typeof baseReducer, skipHeaderOperations?: SkipHeaderOperations, options?: ReducerOptions): Document<T, A, L>;
|
|
80
78
|
export type SkipHeaderOperations = Partial<Record<OperationScope, number>>;
|
|
81
79
|
export type ReplayDocumentOptions = {
|
|
82
80
|
checkHashes?: boolean;
|
|
81
|
+
reuseOperationResultingState?: boolean;
|
|
82
|
+
operationResultingStateParser?: (state: unknown) => object;
|
|
83
83
|
};
|
|
84
84
|
export declare function replayDocument<T, A extends Action, L>(initialState: ExtendedState<T, L>, operations: DocumentOperations<A>, reducer: Reducer<T, A, L>, dispatch?: SignalDispatch, header?: DocumentHeader, skipHeaderOperations?: SkipHeaderOperations, options?: ReplayDocumentOptions): Document<T, A, L>;
|
|
85
85
|
export declare function isSameDocument(documentA: Document, documentB: Document): boolean;
|
|
86
|
+
export declare function parseResultingState(state: unknown): object;
|
|
@@ -49,5 +49,5 @@ export type SkipHeaderOperationIndex = Partial<Pick<OperationIndex, 'index'>> &
|
|
|
49
49
|
* @returns The remaining operations after skipping header operations.
|
|
50
50
|
*/
|
|
51
51
|
export declare function skipHeaderOperations<A extends OperationIndex>(operations: A[], skipHeaderOperation: SkipHeaderOperationIndex): A[];
|
|
52
|
-
export declare function
|
|
52
|
+
export declare function garbageCollectDocumentOperations<A extends Action>(documentOperations: DocumentOperations<A>): DocumentOperations<A>;
|
|
53
53
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from './base';
|
|
2
|
-
export { createAction, createDocument, createExtendedState, createReducer, hashDocument, hashKey, isBaseAction, mapSkippedOperations, readOnly, replayDocument, replayOperations, sortMappedOperations, sortOperations, } from './base';
|
|
2
|
+
export { createAction, createDocument, createExtendedState, createReducer, hashDocument, hashKey, isBaseAction, mapSkippedOperations, parseResultingState, readOnly, replayDocument, replayOperations, sortMappedOperations, sortOperations, } from './base';
|
|
3
3
|
export * from './file';
|
|
4
4
|
export * from './validation';
|
|
5
5
|
export * as documentHelpers from './document-helpers';
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("./object-BU2CI8g7.js"),t=Object.freeze(Object.defineProperty({__proto__:null,calculateSkipsLeft:e.calculateSkipsLeft,createAction:e.createAction,createDocument:e.createDocument,createExtendedState:e.createExtendedState,createReducer:e.createReducer,createZip:e.createZip,documentHelpers:e.documentHelpers,getLocalFile:e.getLocalFile,getRemoteFile:e.getRemoteFile,hashDocument:e.hashDocument,hashKey:e.hashKey,isBaseAction:e.isBaseAction,isNoopOperation:e.isNoopOperation,isSameDocument:e.isSameDocument,isUndoRedo:e.isUndoRedo,loadFromFile:e.loadFromFile,loadFromInput:e.loadFromInput,mapSkippedOperations:e.mapSkippedOperations,readOnly:e.readOnly,replayDocument:e.replayDocument,replayOperations:e.replayOperations,saveToFile:e.saveToFile,saveToFileHandle:e.saveToFileHandle,sortMappedOperations:e.sortMappedOperations,sortOperations:e.sortOperations,validateOperations:e.validateOperations},Symbol.toStringTag,{value:"Module"})),o=Object.freeze(Object.defineProperty({__proto__:null,BaseDocument:e.BaseDocument,actions:e.BaseActions,applyMixins:e.applyMixins,baseReducer:e.baseReducer,processUndoRedo:e.processUndoRedo,utils:t,z:e.zod},Symbol.toStringTag,{value:"Module"}));exports.Document=o;exports.index=t;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";var Ze=Object.defineProperty;var Ye=(r,i,o)=>i in r?Ze(r,i,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[i]=o;var Bt=(r,i,o)=>(Ye(r,typeof i!="symbol"?i+"":i,o),o);const nt=require("immer"),v=require("zod"),se=require("jszip"),pe=r=>r!=null,Qe=v.z.any().refine(r=>pe(r)),ce=v.z.enum(["LOAD_STATE"]),le=v.z.enum(["PRUNE"]),ue=v.z.enum(["REDO"]),fe=v.z.enum(["SET_NAME"]),he=v.z.enum(["UNDO"]);function tr(){return v.z.object({__typename:v.z.literal("Action").optional(),type:v.z.string()})}function Et(){return v.z.literal("global").or(v.z.literal("local"))}function me(){return v.z.union([xe(),ge(),ye(),we(),Ee()])}function er(){return v.z.object({__typename:v.z.literal("DocumentFile").optional(),data:v.z.string(),extension:v.z.string().nullable(),fileName:v.z.string().nullable(),mimeType:v.z.string()})}function xe(){return v.z.object({input:v.z.lazy(()=>Ht()),type:ce,scope:Et()})}function Ht(){return v.z.object({operations:v.z.number(),state:v.z.lazy(()=>de())})}function de(){return v.z.object({data:v.z.unknown().nullish(),name:v.z.string()})}function rr(){return v.z.object({__typename:v.z.literal("Operation").optional(),hash:v.z.string(),index:v.z.number(),timestamp:v.z.string().datetime(),type:v.z.string()})}function ge(){return v.z.object({input:v.z.lazy(()=>Jt()),type:le,scope:Et()})}function Jt(){return v.z.object({end:v.z.number().nullish(),start:v.z.number().nullish()})}const Wt=v.z.number;function ye(){return v.z.object({input:Wt(),type:ue,scope:Et()})}const Xt=v.z.string;function we(){return v.z.object({input:Xt(),type:fe,scope:v.z.literal("global")})}function ir(){return v.z.object({__typename:v.z.literal("SetNameOperation").optional(),hash:v.z.string(),index:v.z.number(),input:v.z.string(),timestamp:v.z.string().datetime(),type:v.z.string()})}const Vt=v.z.number;function Ee(){return v.z.object({input:Vt(),type:he,scope:Et()})}const nr=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:tr,BaseActionSchema:me,DocumentFileSchema:er,LoadStateActionInputSchema:Ht,LoadStateActionSchema:xe,LoadStateActionStateInputSchema:de,Load_StateSchema:ce,OperationSchema:rr,OperationScopeSchema:Et,PruneActionInputSchema:Jt,PruneActionSchema:ge,PruneSchema:le,RedoActionInputSchema:Wt,RedoActionSchema:ye,RedoSchema:ue,SetNameActionInputSchema:Xt,SetNameActionSchema:we,SetNameOperationSchema:ir,Set_NameSchema:fe,UndoActionInputSchema:Vt,UndoActionSchema:Ee,UndoSchema:he,definedNonNullAnySchema:Qe,isDefinedNonNullAny:pe},Symbol.toStringTag,{value:"Module"}));function Kt(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var zt={exports:{}};(function(r,i){const{hasOwnProperty:o}=Object.prototype,p=Y();p.configure=Y,p.stringify=p,p.default=p,i.stringify=p,i.configure=Y,r.exports=p;const u=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;function f(w){return w.length<5e3&&!u.test(w)?`"${w}"`:JSON.stringify(w)}function c(w){if(w.length>200)return w.sort();for(let E=1;E<w.length;E++){const D=w[E];let H=E;for(;H!==0&&w[H-1]>D;)w[H]=w[H-1],H--;w[H]=D}return w}const s=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function h(w){return s.call(w)!==void 0&&w.length!==0}function g(w,E,D){w.length<D&&(D=w.length);const H=E===","?"":" ";let G=`"0":${H}${w[0]}`;for(let K=1;K<D;K++)G+=`${E}"${K}":${H}${w[K]}`;return G}function y(w){if(o.call(w,"circularValue")){const E=w.circularValue;if(typeof E=="string")return`"${E}"`;if(E==null)return E;if(E===Error||E===TypeError)return{toString(){throw new TypeError("Converting circular structure to JSON")}};throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined')}return'"[Circular]"'}function _(w,E){let D;if(o.call(w,E)&&(D=w[E],typeof D!="boolean"))throw new TypeError(`The "${E}" argument must be of type boolean`);return D===void 0?!0:D}function F(w,E){let D;if(o.call(w,E)){if(D=w[E],typeof D!="number")throw new TypeError(`The "${E}" argument must be of type number`);if(!Number.isInteger(D))throw new TypeError(`The "${E}" argument must be an integer`);if(D<1)throw new RangeError(`The "${E}" argument must be >= 1`)}return D===void 0?1/0:D}function A(w){return w===1?"1 item":`${w} items`}function $(w){const E=new Set;for(const D of w)(typeof D=="string"||typeof D=="number")&&E.add(String(D));return E}function M(w){if(o.call(w,"strict")){const E=w.strict;if(typeof E!="boolean")throw new TypeError('The "strict" argument must be of type boolean');if(E)return D=>{let H=`Object can not safely be stringified. Received type ${typeof D}`;throw typeof D!="function"&&(H+=` (${D.toString()})`),new Error(H)}}}function Y(w){w={...w};const E=M(w);E&&(w.bigint===void 0&&(w.bigint=!1),"circularValue"in w||(w.circularValue=Error));const D=y(w),H=_(w,"bigint"),G=_(w,"deterministic"),K=F(w,"maximumDepth"),z=F(w,"maximumBreadth");function ht(J,m,b,j,O,U){let S=m[J];switch(typeof S=="object"&&S!==null&&typeof S.toJSON=="function"&&(S=S.toJSON(J)),S=j.call(m,J,S),typeof S){case"string":return f(S);case"object":{if(S===null)return"null";if(b.indexOf(S)!==-1)return D;let k="",B=",";const I=U;if(Array.isArray(S)){if(S.length===0)return"[]";if(K<b.length+1)return'"[Array]"';b.push(S),O!==""&&(U+=O,k+=`
|
|
2
|
-
${U}`,B=`,
|
|
3
|
-
${U}`);const W=Math.min(S.length,z);let Q=0;for(;Q<W-1;Q++){const lt=ht(String(Q),S,b,j,O,U);k+=lt!==void 0?lt:"null",k+=B}const tt=ht(String(Q),S,b,j,O,U);if(k+=tt!==void 0?tt:"null",S.length-1>z){const lt=S.length-z-1;k+=`${B}"... ${A(lt)} not stringified"`}return O!==""&&(k+=`
|
|
4
|
-
${I}`),b.pop(),`[${k}]`}let R=Object.keys(S);const q=R.length;if(q===0)return"{}";if(K<b.length+1)return'"[Object]"';let C="",X="";O!==""&&(U+=O,B=`,
|
|
5
|
-
${U}`,C=" ");const Z=Math.min(q,z);G&&!h(S)&&(R=c(R)),b.push(S);for(let W=0;W<Z;W++){const Q=R[W],tt=ht(Q,S,b,j,O,U);tt!==void 0&&(k+=`${X}${f(Q)}:${C}${tt}`,X=B)}if(q>z){const W=q-z;k+=`${X}"...":${C}"${A(W)} not stringified"`,X=B}return O!==""&&X.length>1&&(k=`
|
|
6
|
-
${U}${k}
|
|
7
|
-
${I}`),b.pop(),`{${k}}`}case"number":return isFinite(S)?String(S):E?E(S):"null";case"boolean":return S===!0?"true":"false";case"undefined":return;case"bigint":if(H)return String(S);default:return E?E(S):void 0}}function mt(J,m,b,j,O,U){switch(typeof m=="object"&&m!==null&&typeof m.toJSON=="function"&&(m=m.toJSON(J)),typeof m){case"string":return f(m);case"object":{if(m===null)return"null";if(b.indexOf(m)!==-1)return D;const S=U;let k="",B=",";if(Array.isArray(m)){if(m.length===0)return"[]";if(K<b.length+1)return'"[Array]"';b.push(m),O!==""&&(U+=O,k+=`
|
|
8
|
-
${U}`,B=`,
|
|
9
|
-
${U}`);const q=Math.min(m.length,z);let C=0;for(;C<q-1;C++){const Z=mt(String(C),m[C],b,j,O,U);k+=Z!==void 0?Z:"null",k+=B}const X=mt(String(C),m[C],b,j,O,U);if(k+=X!==void 0?X:"null",m.length-1>z){const Z=m.length-z-1;k+=`${B}"... ${A(Z)} not stringified"`}return O!==""&&(k+=`
|
|
10
|
-
${S}`),b.pop(),`[${k}]`}b.push(m);let I="";O!==""&&(U+=O,B=`,
|
|
11
|
-
${U}`,I=" ");let R="";for(const q of j){const C=mt(q,m[q],b,j,O,U);C!==void 0&&(k+=`${R}${f(q)}:${I}${C}`,R=B)}return O!==""&&R.length>1&&(k=`
|
|
12
|
-
${U}${k}
|
|
13
|
-
${S}`),b.pop(),`{${k}}`}case"number":return isFinite(m)?String(m):E?E(m):"null";case"boolean":return m===!0?"true":"false";case"undefined":return;case"bigint":if(H)return String(m);default:return E?E(m):void 0}}function pt(J,m,b,j,O){switch(typeof m){case"string":return f(m);case"object":{if(m===null)return"null";if(typeof m.toJSON=="function"){if(m=m.toJSON(J),typeof m!="object")return pt(J,m,b,j,O);if(m===null)return"null"}if(b.indexOf(m)!==-1)return D;const U=O;if(Array.isArray(m)){if(m.length===0)return"[]";if(K<b.length+1)return'"[Array]"';b.push(m),O+=j;let C=`
|
|
14
|
-
${O}`;const X=`,
|
|
15
|
-
${O}`,Z=Math.min(m.length,z);let W=0;for(;W<Z-1;W++){const tt=pt(String(W),m[W],b,j,O);C+=tt!==void 0?tt:"null",C+=X}const Q=pt(String(W),m[W],b,j,O);if(C+=Q!==void 0?Q:"null",m.length-1>z){const tt=m.length-z-1;C+=`${X}"... ${A(tt)} not stringified"`}return C+=`
|
|
16
|
-
${U}`,b.pop(),`[${C}]`}let S=Object.keys(m);const k=S.length;if(k===0)return"{}";if(K<b.length+1)return'"[Object]"';O+=j;const B=`,
|
|
17
|
-
${O}`;let I="",R="",q=Math.min(k,z);h(m)&&(I+=g(m,B,z),S=S.slice(m.length),q-=m.length,R=B),G&&(S=c(S)),b.push(m);for(let C=0;C<q;C++){const X=S[C],Z=pt(X,m[X],b,j,O);Z!==void 0&&(I+=`${R}${f(X)}: ${Z}`,R=B)}if(k>z){const C=k-z;I+=`${R}"...": "${A(C)} not stringified"`,R=B}return R!==""&&(I=`
|
|
18
|
-
${O}${I}
|
|
19
|
-
${U}`),b.pop(),`{${I}}`}case"number":return isFinite(m)?String(m):E?E(m):"null";case"boolean":return m===!0?"true":"false";case"undefined":return;case"bigint":if(H)return String(m);default:return E?E(m):void 0}}function ct(J,m,b){switch(typeof m){case"string":return f(m);case"object":{if(m===null)return"null";if(typeof m.toJSON=="function"){if(m=m.toJSON(J),typeof m!="object")return ct(J,m,b);if(m===null)return"null"}if(b.indexOf(m)!==-1)return D;let j="";if(Array.isArray(m)){if(m.length===0)return"[]";if(K<b.length+1)return'"[Array]"';b.push(m);const B=Math.min(m.length,z);let I=0;for(;I<B-1;I++){const q=ct(String(I),m[I],b);j+=q!==void 0?q:"null",j+=","}const R=ct(String(I),m[I],b);if(j+=R!==void 0?R:"null",m.length-1>z){const q=m.length-z-1;j+=`,"... ${A(q)} not stringified"`}return b.pop(),`[${j}]`}let O=Object.keys(m);const U=O.length;if(U===0)return"{}";if(K<b.length+1)return'"[Object]"';let S="",k=Math.min(U,z);h(m)&&(j+=g(m,",",z),O=O.slice(m.length),k-=m.length,S=","),G&&(O=c(O)),b.push(m);for(let B=0;B<k;B++){const I=O[B],R=ct(I,m[I],b);R!==void 0&&(j+=`${S}${f(I)}:${R}`,S=",")}if(U>z){const B=U-z;j+=`${S}"...":"${A(B)} not stringified"`}return b.pop(),`{${j}}`}case"number":return isFinite(m)?String(m):E?E(m):"null";case"boolean":return m===!0?"true":"false";case"undefined":return;case"bigint":if(H)return String(m);default:return E?E(m):void 0}}function Ut(J,m,b){if(arguments.length>1){let j="";if(typeof b=="number"?j=" ".repeat(Math.min(b,10)):typeof b=="string"&&(j=b.slice(0,10)),m!=null){if(typeof m=="function")return ht("",{"":J},[],m,j,"");if(Array.isArray(m))return mt("",J,[],$(m),j,"")}if(j.length!==0)return pt("",J,[],j,"")}return ct("",J,[])}return Ut}})(zt,zt.exports);var or=zt.exports;const gt=Kt(or);gt.configure;function ar(r,i){return{...r,name:i}}function sr(r,i,o){const{scope:p,input:u}=i,f={document:r,action:i,skip:o};return nt.produce(f,c=>{if(c.document.operations[p].length<1)throw new Error(`Cannot undo: no operations in history for scope "${p}"`);if(u<1)throw new Error("Invalid UNDO action: input value must be greater than 0");if(c.skip>0)throw new Error("Cannot undo: skip value from reducer cannot be used with UNDO action");const s=c.document.operations[p].at(-1),h=s&&s.type==="NOOP"&&s.skip>0;if(c.skip+=u,h){c.skip+=s.skip;const F=c.document.operations[p][c.document.operations[p].length-2];F&&s.index-F.index===1&&c.document.operations[p].pop()}if(c.document.operations[p].length<c.skip)throw new Error("Cannot undo: you can't undo more operations than the ones in the scope history");const g=c.document.operations[p].length-1;let y=u,_=h?g-s.skip:g;for(;y>0&&_>=0;){const F=c.document.operations[p][_];if(!F){y--,_--;continue}F.type==="NOOP"&&F.skip>0?(_=_-(F.skip+1),c.skip+=F.skip+1):(c.document.clipboard.push({...F}),y--,_--)}c.action=Ke(p)})}function pr(r,i,o){const{scope:p,input:u}=i,f={document:r,action:i,skip:o};return nt.produce(f,c=>{if(c.skip>0)throw new Error("Cannot redo: skip value from reducer cannot be used with REDO action");if(u>1)throw new Error("Cannot redo: you can only redo one operation at a time");if(u<1)throw new Error("Invalid REDO action: invalid redo input value");if(c.document.clipboard.length<1)throw new Error("Cannot redo: no operations in the clipboard");const s=c.document.clipboard.findLastIndex(g=>g.scope===p);if(s<0)throw new Error(`Cannot redo: no operations in clipboard for scope "${p}"`);const h=c.document.clipboard.splice(s,1)[0];c.action=nt.castDraft({type:h.type,scope:h.scope,input:h.input})})}function cr(r,i,o){const{scope:p}=i,u=r.operations[p];let{input:{start:f,end:c}}=i;f=f||0,c=c||u.length;const s=u.slice(f,c),h=u.slice(0,f),g=u.slice(c),y=Ot(r.initialState,{...r.operations,[p]:h.concat(s)},o),{name:_,state:F}=y,A=h.length,$=h.length?h[h.length-1].timestamp:g.length?g[0].timestamp:new Date().toISOString();return Ot(r.initialState,{...r.operations,[p]:[...h,{...ne({name:_,state:F},s.length),timestamp:$,index:A,hash:Tt({state:F},"global")},...g.map((M,Y)=>({...M,index:A+Y+1}))]},o)}function lr(r,i){return{...r,name:i.name,state:i.state??{global:{},local:{}}}}const be="SET_NAME",bt="UNDO",vt="REDO",It="PRUNE",ve="LOAD_STATE",ur="NOOP",_e={"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"]};Object.freeze(_e);var et=function(r,i,o,p){if(o==="a"&&!p)throw new TypeError("Private accessor was defined without a getter");if(typeof i=="function"?r!==i||!p:!i.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return o==="m"?p:o==="a"?p.call(r):p?p.value:i.get(r)},dt,yt,ut;class fr{constructor(...i){dt.set(this,new Map),yt.set(this,new Map),ut.set(this,new Map);for(const o of i)this.define(o)}define(i,o=!1){for(let[p,u]of Object.entries(i)){p=p.toLowerCase(),u=u.map(s=>s.toLowerCase()),et(this,ut,"f").has(p)||et(this,ut,"f").set(p,new Set);const f=et(this,ut,"f").get(p);let c=!0;for(let s of u){const h=s.startsWith("*");if(s=h?s.slice(1):s,f==null||f.add(s),c&&et(this,yt,"f").set(p,s),c=!1,h)continue;const g=et(this,dt,"f").get(s);if(g&&g!=p&&!o)throw new Error(`"${p} -> ${s}" conflicts with "${g} -> ${s}". Pass \`force=true\` to override this definition.`);et(this,dt,"f").set(s,p)}}return this}getType(i){if(typeof i!="string")return null;const o=i.replace(/^.*[/\\]/,"").toLowerCase(),p=o.replace(/^.*\./,"").toLowerCase(),u=o.length<i.length;return!(p.length<o.length-1)&&u?null:et(this,dt,"f").get(p)??null}getExtension(i){var o;return typeof i!="string"?null:(i=(o=i==null?void 0:i.split)==null?void 0:o.call(i,";")[0],(i&&et(this,yt,"f").get(i.trim().toLowerCase()))??null)}getAllExtensions(i){return typeof i!="string"?null:et(this,ut,"f").get(i.toLowerCase())??null}_freeze(){this.define=()=>{throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances")},Object.freeze(this);for(const i of et(this,ut,"f").values())Object.freeze(i);return this}_getTestState(){return{types:et(this,dt,"f"),extensions:et(this,yt,"f")}}}dt=new WeakMap,yt=new WeakMap,ut=new WeakMap;const hr=new fr(_e)._freeze();var Mt={exports:{}};typeof Object.create=="function"?Mt.exports=function(i,o){o&&(i.super_=o,i.prototype=Object.create(o.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}))}:Mt.exports=function(i,o){if(o){i.super_=o;var p=function(){};p.prototype=o.prototype,i.prototype=new p,i.prototype.constructor=i}};var Ae=Mt.exports,Rt={exports:{}},Se={},jt={};jt.byteLength=dr;jt.toByteArray=yr;jt.fromByteArray=br;var ot=[],rt=[],mr=typeof Uint8Array<"u"?Uint8Array:Array,$t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var xt=0,xr=$t.length;xt<xr;++xt)ot[xt]=$t[xt],rt[$t.charCodeAt(xt)]=xt;rt[45]=62;rt[95]=63;function Fe(r){var i=r.length;if(i%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var o=r.indexOf("=");o===-1&&(o=i);var p=o===i?0:4-o%4;return[o,p]}function dr(r){var i=Fe(r),o=i[0],p=i[1];return(o+p)*3/4-p}function gr(r,i,o){return(i+o)*3/4-o}function yr(r){var i,o=Fe(r),p=o[0],u=o[1],f=new mr(gr(r,p,u)),c=0,s=u>0?p-4:p,h;for(h=0;h<s;h+=4)i=rt[r.charCodeAt(h)]<<18|rt[r.charCodeAt(h+1)]<<12|rt[r.charCodeAt(h+2)]<<6|rt[r.charCodeAt(h+3)],f[c++]=i>>16&255,f[c++]=i>>8&255,f[c++]=i&255;return u===2&&(i=rt[r.charCodeAt(h)]<<2|rt[r.charCodeAt(h+1)]>>4,f[c++]=i&255),u===1&&(i=rt[r.charCodeAt(h)]<<10|rt[r.charCodeAt(h+1)]<<4|rt[r.charCodeAt(h+2)]>>2,f[c++]=i>>8&255,f[c++]=i&255),f}function wr(r){return ot[r>>18&63]+ot[r>>12&63]+ot[r>>6&63]+ot[r&63]}function Er(r,i,o){for(var p,u=[],f=i;f<o;f+=3)p=(r[f]<<16&16711680)+(r[f+1]<<8&65280)+(r[f+2]&255),u.push(wr(p));return u.join("")}function br(r){for(var i,o=r.length,p=o%3,u=[],f=16383,c=0,s=o-p;c<s;c+=f)u.push(Er(r,c,c+f>s?s:c+f));return p===1?(i=r[o-1],u.push(ot[i>>2]+ot[i<<4&63]+"==")):p===2&&(i=(r[o-2]<<8)+r[o-1],u.push(ot[i>>10]+ot[i>>4&63]+ot[i<<2&63]+"=")),u.join("")}var Gt={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Gt.read=function(r,i,o,p,u){var f,c,s=u*8-p-1,h=(1<<s)-1,g=h>>1,y=-7,_=o?u-1:0,F=o?-1:1,A=r[i+_];for(_+=F,f=A&(1<<-y)-1,A>>=-y,y+=s;y>0;f=f*256+r[i+_],_+=F,y-=8);for(c=f&(1<<-y)-1,f>>=-y,y+=p;y>0;c=c*256+r[i+_],_+=F,y-=8);if(f===0)f=1-g;else{if(f===h)return c?NaN:(A?-1:1)*(1/0);c=c+Math.pow(2,p),f=f-g}return(A?-1:1)*c*Math.pow(2,f-p)};Gt.write=function(r,i,o,p,u,f){var c,s,h,g=f*8-u-1,y=(1<<g)-1,_=y>>1,F=u===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=p?0:f-1,$=p?1:-1,M=i<0||i===0&&1/i<0?1:0;for(i=Math.abs(i),isNaN(i)||i===1/0?(s=isNaN(i)?1:0,c=y):(c=Math.floor(Math.log(i)/Math.LN2),i*(h=Math.pow(2,-c))<1&&(c--,h*=2),c+_>=1?i+=F/h:i+=F*Math.pow(2,1-_),i*h>=2&&(c++,h/=2),c+_>=y?(s=0,c=y):c+_>=1?(s=(i*h-1)*Math.pow(2,u),c=c+_):(s=i*Math.pow(2,_-1)*Math.pow(2,u),c=0));u>=8;r[o+A]=s&255,A+=$,s/=256,u-=8);for(c=c<<u|s,g+=u;g>0;r[o+A]=c&255,A+=$,c/=256,g-=8);r[o+A-$]|=M*128};/*!
|
|
20
|
-
* The buffer module from node.js, for the browser.
|
|
21
|
-
*
|
|
22
|
-
* @author Feross Aboukhadijeh <https://feross.org>
|
|
23
|
-
* @license MIT
|
|
24
|
-
*/(function(r){var i=jt,o=Gt,p=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;r.Buffer=s,r.SlowBuffer=E,r.INSPECT_MAX_BYTES=50;var u=2147483647;r.kMaxLength=u,s.TYPED_ARRAY_SUPPORT=f(),!s.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 f(){try{var n=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(n,t),n.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function c(n){if(n>u)throw new RangeError('The value "'+n+'" is invalid for option "size"');var t=new Uint8Array(n);return Object.setPrototypeOf(t,s.prototype),t}function s(n,t,e){if(typeof n=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return _(n)}return h(n,t,e)}s.poolSize=8192;function h(n,t,e){if(typeof n=="string")return F(n,t);if(ArrayBuffer.isView(n))return $(n);if(n==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n);if(it(n,ArrayBuffer)||n&&it(n.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(it(n,SharedArrayBuffer)||n&&it(n.buffer,SharedArrayBuffer)))return M(n,t,e);if(typeof n=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var a=n.valueOf&&n.valueOf();if(a!=null&&a!==n)return s.from(a,t,e);var l=Y(n);if(l)return l;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof n[Symbol.toPrimitive]=="function")return s.from(n[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n)}s.from=function(n,t,e){return h(n,t,e)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function g(n){if(typeof n!="number")throw new TypeError('"size" argument must be of type number');if(n<0)throw new RangeError('The value "'+n+'" is invalid for option "size"')}function y(n,t,e){return g(n),n<=0?c(n):t!==void 0?typeof e=="string"?c(n).fill(t,e):c(n).fill(t):c(n)}s.alloc=function(n,t,e){return y(n,t,e)};function _(n){return g(n),c(n<0?0:w(n)|0)}s.allocUnsafe=function(n){return _(n)},s.allocUnsafeSlow=function(n){return _(n)};function F(n,t){if((typeof t!="string"||t==="")&&(t="utf8"),!s.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var e=D(n,t)|0,a=c(e),l=a.write(n,t);return l!==e&&(a=a.slice(0,l)),a}function A(n){for(var t=n.length<0?0:w(n.length)|0,e=c(t),a=0;a<t;a+=1)e[a]=n[a]&255;return e}function $(n){if(it(n,Uint8Array)){var t=new Uint8Array(n);return M(t.buffer,t.byteOffset,t.byteLength)}return A(n)}function M(n,t,e){if(t<0||n.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(n.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');var a;return t===void 0&&e===void 0?a=new Uint8Array(n):e===void 0?a=new Uint8Array(n,t):a=new Uint8Array(n,t,e),Object.setPrototypeOf(a,s.prototype),a}function Y(n){if(s.isBuffer(n)){var t=w(n.length)|0,e=c(t);return e.length===0||n.copy(e,0,0,t),e}if(n.length!==void 0)return typeof n.length!="number"||Ct(n.length)?c(0):A(n);if(n.type==="Buffer"&&Array.isArray(n.data))return A(n.data)}function w(n){if(n>=u)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u.toString(16)+" bytes");return n|0}function E(n){return+n!=n&&(n=0),s.alloc(+n)}s.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==s.prototype},s.compare=function(t,e){if(it(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),it(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(t)||!s.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var a=t.length,l=e.length,x=0,d=Math.min(a,l);x<d;++x)if(t[x]!==e[x]){a=t[x],l=e[x];break}return a<l?-1:l<a?1:0},s.isEncoding=function(t){switch(String(t).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}},s.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return s.alloc(0);var a;if(e===void 0)for(e=0,a=0;a<t.length;++a)e+=t[a].length;var l=s.allocUnsafe(e),x=0;for(a=0;a<t.length;++a){var d=t[a];if(it(d,Uint8Array))x+d.length>l.length?s.from(d).copy(l,x):Uint8Array.prototype.set.call(l,d,x);else if(s.isBuffer(d))d.copy(l,x);else throw new TypeError('"list" argument must be an Array of Buffers');x+=d.length}return l};function D(n,t){if(s.isBuffer(n))return n.length;if(ArrayBuffer.isView(n)||it(n,ArrayBuffer))return n.byteLength;if(typeof n!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof n);var e=n.length,a=arguments.length>2&&arguments[2]===!0;if(!a&&e===0)return 0;for(var l=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return W(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return lt(n).length;default:if(l)return a?-1:W(n).length;t=(""+t).toLowerCase(),l=!0}}s.byteLength=D;function H(n,t,e){var a=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(n||(n="utf8");;)switch(n){case"hex":return S(this,t,e);case"utf8":case"utf-8":return m(this,t,e);case"ascii":return O(this,t,e);case"latin1":case"binary":return U(this,t,e);case"base64":return J(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),a=!0}}s.prototype._isBuffer=!0;function G(n,t,e){var a=n[t];n[t]=n[e],n[e]=a}s.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)G(this,e,e+1);return this},s.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)G(this,e,e+3),G(this,e+1,e+2);return this},s.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)G(this,e,e+7),G(this,e+1,e+6),G(this,e+2,e+5),G(this,e+3,e+4);return this},s.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?m(this,0,t):H.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:s.compare(this,t)===0},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"},p&&(s.prototype[p]=s.prototype.inspect),s.prototype.compare=function(t,e,a,l,x){if(it(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),a===void 0&&(a=t?t.length:0),l===void 0&&(l=0),x===void 0&&(x=this.length),e<0||a>t.length||l<0||x>this.length)throw new RangeError("out of range index");if(l>=x&&e>=a)return 0;if(l>=x)return-1;if(e>=a)return 1;if(e>>>=0,a>>>=0,l>>>=0,x>>>=0,this===t)return 0;for(var d=x-l,T=a-e,N=Math.min(d,T),L=this.slice(l,x),V=t.slice(e,a),P=0;P<N;++P)if(L[P]!==V[P]){d=L[P],T=V[P];break}return d<T?-1:T<d?1:0};function K(n,t,e,a,l){if(n.length===0)return-1;if(typeof e=="string"?(a=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,Ct(e)&&(e=l?0:n.length-1),e<0&&(e=n.length+e),e>=n.length){if(l)return-1;e=n.length-1}else if(e<0)if(l)e=0;else return-1;if(typeof t=="string"&&(t=s.from(t,a)),s.isBuffer(t))return t.length===0?-1:z(n,t,e,a,l);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?l?Uint8Array.prototype.indexOf.call(n,t,e):Uint8Array.prototype.lastIndexOf.call(n,t,e):z(n,[t],e,a,l);throw new TypeError("val must be string, number or Buffer")}function z(n,t,e,a,l){var x=1,d=n.length,T=t.length;if(a!==void 0&&(a=String(a).toLowerCase(),a==="ucs2"||a==="ucs-2"||a==="utf16le"||a==="utf-16le")){if(n.length<2||t.length<2)return-1;x=2,d/=2,T/=2,e/=2}function N(oe,ae){return x===1?oe[ae]:oe.readUInt16BE(ae*x)}var L;if(l){var V=-1;for(L=e;L<d;L++)if(N(n,L)===N(t,V===-1?0:L-V)){if(V===-1&&(V=L),L-V+1===T)return V*x}else V!==-1&&(L-=L-V),V=-1}else for(e+T>d&&(e=d-T),L=e;L>=0;L--){for(var P=!0,Ft=0;Ft<T;Ft++)if(N(n,L+Ft)!==N(t,Ft)){P=!1;break}if(P)return L}return-1}s.prototype.includes=function(t,e,a){return this.indexOf(t,e,a)!==-1},s.prototype.indexOf=function(t,e,a){return K(this,t,e,a,!0)},s.prototype.lastIndexOf=function(t,e,a){return K(this,t,e,a,!1)};function ht(n,t,e,a){e=Number(e)||0;var l=n.length-e;a?(a=Number(a),a>l&&(a=l)):a=l;var x=t.length;a>x/2&&(a=x/2);for(var d=0;d<a;++d){var T=parseInt(t.substr(d*2,2),16);if(Ct(T))return d;n[e+d]=T}return d}function mt(n,t,e,a){return St(W(t,n.length-e),n,e,a)}function pt(n,t,e,a){return St(Q(t),n,e,a)}function ct(n,t,e,a){return St(lt(t),n,e,a)}function Ut(n,t,e,a){return St(tt(t,n.length-e),n,e,a)}s.prototype.write=function(t,e,a,l){if(e===void 0)l="utf8",a=this.length,e=0;else if(a===void 0&&typeof e=="string")l=e,a=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(a)?(a=a>>>0,l===void 0&&(l="utf8")):(l=a,a=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var x=this.length-e;if((a===void 0||a>x)&&(a=x),t.length>0&&(a<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");l||(l="utf8");for(var d=!1;;)switch(l){case"hex":return ht(this,t,e,a);case"utf8":case"utf-8":return mt(this,t,e,a);case"ascii":case"latin1":case"binary":return pt(this,t,e,a);case"base64":return ct(this,t,e,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ut(this,t,e,a);default:if(d)throw new TypeError("Unknown encoding: "+l);l=(""+l).toLowerCase(),d=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function J(n,t,e){return t===0&&e===n.length?i.fromByteArray(n):i.fromByteArray(n.slice(t,e))}function m(n,t,e){e=Math.min(n.length,e);for(var a=[],l=t;l<e;){var x=n[l],d=null,T=x>239?4:x>223?3:x>191?2:1;if(l+T<=e){var N,L,V,P;switch(T){case 1:x<128&&(d=x);break;case 2:N=n[l+1],(N&192)===128&&(P=(x&31)<<6|N&63,P>127&&(d=P));break;case 3:N=n[l+1],L=n[l+2],(N&192)===128&&(L&192)===128&&(P=(x&15)<<12|(N&63)<<6|L&63,P>2047&&(P<55296||P>57343)&&(d=P));break;case 4:N=n[l+1],L=n[l+2],V=n[l+3],(N&192)===128&&(L&192)===128&&(V&192)===128&&(P=(x&15)<<18|(N&63)<<12|(L&63)<<6|V&63,P>65535&&P<1114112&&(d=P))}}d===null?(d=65533,T=1):d>65535&&(d-=65536,a.push(d>>>10&1023|55296),d=56320|d&1023),a.push(d),l+=T}return j(a)}var b=4096;function j(n){var t=n.length;if(t<=b)return String.fromCharCode.apply(String,n);for(var e="",a=0;a<t;)e+=String.fromCharCode.apply(String,n.slice(a,a+=b));return e}function O(n,t,e){var a="";e=Math.min(n.length,e);for(var l=t;l<e;++l)a+=String.fromCharCode(n[l]&127);return a}function U(n,t,e){var a="";e=Math.min(n.length,e);for(var l=t;l<e;++l)a+=String.fromCharCode(n[l]);return a}function S(n,t,e){var a=n.length;(!t||t<0)&&(t=0),(!e||e<0||e>a)&&(e=a);for(var l="",x=t;x<e;++x)l+=Ge[n[x]];return l}function k(n,t,e){for(var a=n.slice(t,e),l="",x=0;x<a.length-1;x+=2)l+=String.fromCharCode(a[x]+a[x+1]*256);return l}s.prototype.slice=function(t,e){var a=this.length;t=~~t,e=e===void 0?a:~~e,t<0?(t+=a,t<0&&(t=0)):t>a&&(t=a),e<0?(e+=a,e<0&&(e=0)):e>a&&(e=a),e<t&&(e=t);var l=this.subarray(t,e);return Object.setPrototypeOf(l,s.prototype),l};function B(n,t,e){if(n%1!==0||n<0)throw new RangeError("offset is not uint");if(n+t>e)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(t,e,a){t=t>>>0,e=e>>>0,a||B(t,e,this.length);for(var l=this[t],x=1,d=0;++d<e&&(x*=256);)l+=this[t+d]*x;return l},s.prototype.readUintBE=s.prototype.readUIntBE=function(t,e,a){t=t>>>0,e=e>>>0,a||B(t,e,this.length);for(var l=this[t+--e],x=1;e>0&&(x*=256);)l+=this[t+--e]*x;return l},s.prototype.readUint8=s.prototype.readUInt8=function(t,e){return t=t>>>0,e||B(t,1,this.length),this[t]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||B(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||B(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||B(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||B(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,a){t=t>>>0,e=e>>>0,a||B(t,e,this.length);for(var l=this[t],x=1,d=0;++d<e&&(x*=256);)l+=this[t+d]*x;return x*=128,l>=x&&(l-=Math.pow(2,8*e)),l},s.prototype.readIntBE=function(t,e,a){t=t>>>0,e=e>>>0,a||B(t,e,this.length);for(var l=e,x=1,d=this[t+--l];l>0&&(x*=256);)d+=this[t+--l]*x;return x*=128,d>=x&&(d-=Math.pow(2,8*e)),d},s.prototype.readInt8=function(t,e){return t=t>>>0,e||B(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},s.prototype.readInt16LE=function(t,e){t=t>>>0,e||B(t,2,this.length);var a=this[t]|this[t+1]<<8;return a&32768?a|4294901760:a},s.prototype.readInt16BE=function(t,e){t=t>>>0,e||B(t,2,this.length);var a=this[t+1]|this[t]<<8;return a&32768?a|4294901760:a},s.prototype.readInt32LE=function(t,e){return t=t>>>0,e||B(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t=t>>>0,e||B(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t=t>>>0,e||B(t,4,this.length),o.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t=t>>>0,e||B(t,4,this.length),o.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||B(t,8,this.length),o.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||B(t,8,this.length),o.read(this,t,!1,52,8)};function I(n,t,e,a,l,x){if(!s.isBuffer(n))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>l||t<x)throw new RangeError('"value" argument is out of bounds');if(e+a>n.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(t,e,a,l){if(t=+t,e=e>>>0,a=a>>>0,!l){var x=Math.pow(2,8*a)-1;I(this,t,e,a,x,0)}var d=1,T=0;for(this[e]=t&255;++T<a&&(d*=256);)this[e+T]=t/d&255;return e+a},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(t,e,a,l){if(t=+t,e=e>>>0,a=a>>>0,!l){var x=Math.pow(2,8*a)-1;I(this,t,e,a,x,0)}var d=a-1,T=1;for(this[e+d]=t&255;--d>=0&&(T*=256);)this[e+d]=t/T&255;return e+a},s.prototype.writeUint8=s.prototype.writeUInt8=function(t,e,a){return t=+t,e=e>>>0,a||I(this,t,e,1,255,0),this[e]=t&255,e+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(t,e,a){return t=+t,e=e>>>0,a||I(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(t,e,a){return t=+t,e=e>>>0,a||I(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(t,e,a){return t=+t,e=e>>>0,a||I(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(t,e,a){return t=+t,e=e>>>0,a||I(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4},s.prototype.writeIntLE=function(t,e,a,l){if(t=+t,e=e>>>0,!l){var x=Math.pow(2,8*a-1);I(this,t,e,a,x-1,-x)}var d=0,T=1,N=0;for(this[e]=t&255;++d<a&&(T*=256);)t<0&&N===0&&this[e+d-1]!==0&&(N=1),this[e+d]=(t/T>>0)-N&255;return e+a},s.prototype.writeIntBE=function(t,e,a,l){if(t=+t,e=e>>>0,!l){var x=Math.pow(2,8*a-1);I(this,t,e,a,x-1,-x)}var d=a-1,T=1,N=0;for(this[e+d]=t&255;--d>=0&&(T*=256);)t<0&&N===0&&this[e+d+1]!==0&&(N=1),this[e+d]=(t/T>>0)-N&255;return e+a},s.prototype.writeInt8=function(t,e,a){return t=+t,e=e>>>0,a||I(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1},s.prototype.writeInt16LE=function(t,e,a){return t=+t,e=e>>>0,a||I(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,a){return t=+t,e=e>>>0,a||I(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2},s.prototype.writeInt32LE=function(t,e,a){return t=+t,e=e>>>0,a||I(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,a){return t=+t,e=e>>>0,a||I(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function R(n,t,e,a,l,x){if(e+a>n.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function q(n,t,e,a,l){return t=+t,e=e>>>0,l||R(n,t,e,4),o.write(n,t,e,a,23,4),e+4}s.prototype.writeFloatLE=function(t,e,a){return q(this,t,e,!0,a)},s.prototype.writeFloatBE=function(t,e,a){return q(this,t,e,!1,a)};function C(n,t,e,a,l){return t=+t,e=e>>>0,l||R(n,t,e,8),o.write(n,t,e,a,52,8),e+8}s.prototype.writeDoubleLE=function(t,e,a){return C(this,t,e,!0,a)},s.prototype.writeDoubleBE=function(t,e,a){return C(this,t,e,!1,a)},s.prototype.copy=function(t,e,a,l){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(a||(a=0),!l&&l!==0&&(l=this.length),e>=t.length&&(e=t.length),e||(e=0),l>0&&l<a&&(l=a),l===a||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(a<0||a>=this.length)throw new RangeError("Index out of range");if(l<0)throw new RangeError("sourceEnd out of bounds");l>this.length&&(l=this.length),t.length-e<l-a&&(l=t.length-e+a);var x=l-a;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,a,l):Uint8Array.prototype.set.call(t,this.subarray(a,l),e),x},s.prototype.fill=function(t,e,a,l){if(typeof t=="string"){if(typeof e=="string"?(l=e,e=0,a=this.length):typeof a=="string"&&(l=a,a=this.length),l!==void 0&&typeof l!="string")throw new TypeError("encoding must be a string");if(typeof l=="string"&&!s.isEncoding(l))throw new TypeError("Unknown encoding: "+l);if(t.length===1){var x=t.charCodeAt(0);(l==="utf8"&&x<128||l==="latin1")&&(t=x)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<a)throw new RangeError("Out of range index");if(a<=e)return this;e=e>>>0,a=a===void 0?this.length:a>>>0,t||(t=0);var d;if(typeof t=="number")for(d=e;d<a;++d)this[d]=t;else{var T=s.isBuffer(t)?t:s.from(t,l),N=T.length;if(N===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(d=0;d<a-e;++d)this[d+e]=T[d%N]}return this};var X=/[^+/0-9A-Za-z-_]/g;function Z(n){if(n=n.split("=")[0],n=n.trim().replace(X,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function W(n,t){t=t||1/0;for(var e,a=n.length,l=null,x=[],d=0;d<a;++d){if(e=n.charCodeAt(d),e>55295&&e<57344){if(!l){if(e>56319){(t-=3)>-1&&x.push(239,191,189);continue}else if(d+1===a){(t-=3)>-1&&x.push(239,191,189);continue}l=e;continue}if(e<56320){(t-=3)>-1&&x.push(239,191,189),l=e;continue}e=(l-55296<<10|e-56320)+65536}else l&&(t-=3)>-1&&x.push(239,191,189);if(l=null,e<128){if((t-=1)<0)break;x.push(e)}else if(e<2048){if((t-=2)<0)break;x.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;x.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;x.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return x}function Q(n){for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function tt(n,t){for(var e,a,l,x=[],d=0;d<n.length&&!((t-=2)<0);++d)e=n.charCodeAt(d),a=e>>8,l=e%256,x.push(l),x.push(a);return x}function lt(n){return i.toByteArray(Z(n))}function St(n,t,e,a){for(var l=0;l<a&&!(l+e>=t.length||l>=n.length);++l)t[l+e]=n[l];return l}function it(n,t){return n instanceof t||n!=null&&n.constructor!=null&&n.constructor.name!=null&&n.constructor.name===t.name}function Ct(n){return n!==n}var Ge=function(){for(var n="0123456789abcdef",t=new Array(256),e=0;e<16;++e)for(var a=e*16,l=0;l<16;++l)t[a+l]=n[e]+n[l];return t}()})(Se);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(r,i){var o=Se,p=o.Buffer;function u(c,s){for(var h in c)s[h]=c[h]}p.from&&p.alloc&&p.allocUnsafe&&p.allocUnsafeSlow?r.exports=o:(u(o,i),i.Buffer=f);function f(c,s,h){return p(c,s,h)}f.prototype=Object.create(p.prototype),u(p,f),f.from=function(c,s,h){if(typeof c=="number")throw new TypeError("Argument must not be a number");return p(c,s,h)},f.alloc=function(c,s,h){if(typeof c!="number")throw new TypeError("Argument must be a number");var g=p(c);return s!==void 0?typeof h=="string"?g.fill(s,h):g.fill(s):g.fill(0),g},f.allocUnsafe=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return p(c)},f.allocUnsafeSlow=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return o.SlowBuffer(c)}})(Rt,Rt.exports);var Zt=Rt.exports,Be=Zt.Buffer;function Dt(r,i){this._block=Be.alloc(r),this._finalSize=i,this._blockSize=r,this._len=0}Dt.prototype.update=function(r,i){typeof r=="string"&&(i=i||"utf8",r=Be.from(r,i));for(var o=this._block,p=this._blockSize,u=r.length,f=this._len,c=0;c<u;){for(var s=f%p,h=Math.min(u-c,p-s),g=0;g<h;g++)o[s+g]=r[c+g];f+=h,c+=h,f%p===0&&this._update(o)}return this._len+=u,this};Dt.prototype.digest=function(r){var i=this._len%this._blockSize;this._block[i]=128,this._block.fill(0,i+1),i>=this._finalSize&&(this._update(this._block),this._block.fill(0));var o=this._len*8;if(o<=4294967295)this._block.writeUInt32BE(o,this._blockSize-4);else{var p=(o&4294967295)>>>0,u=(o-p)/4294967296;this._block.writeUInt32BE(u,this._blockSize-8),this._block.writeUInt32BE(p,this._blockSize-4)}this._update(this._block);var f=this._hash();return r?f.toString(r):f};Dt.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var Oe=Dt,vr=Ae,Ie=Oe,_r=Zt.Buffer,Ar=[1518500249,1859775393,-1894007588,-899497514],Sr=new Array(80);function _t(){this.init(),this._w=Sr,Ie.call(this,64,56)}vr(_t,Ie);_t.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Fr(r){return r<<1|r>>>31}function Br(r){return r<<5|r>>>27}function Or(r){return r<<30|r>>>2}function Ir(r,i,o,p){return r===0?i&o|~i&p:r===2?i&o|i&p|o&p:i^o^p}_t.prototype._update=function(r){for(var i=this._w,o=this._a|0,p=this._b|0,u=this._c|0,f=this._d|0,c=this._e|0,s=0;s<16;++s)i[s]=r.readInt32BE(s*4);for(;s<80;++s)i[s]=Fr(i[s-3]^i[s-8]^i[s-14]^i[s-16]);for(var h=0;h<80;++h){var g=~~(h/20),y=Br(o)+Ir(g,p,u,f)+c+i[h]+Ar[g]|0;c=f,f=u,u=Or(p),p=o,o=y}this._a=o+this._a|0,this._b=p+this._b|0,this._c=u+this._c|0,this._d=f+this._d|0,this._e=c+this._e|0};_t.prototype._hash=function(){var r=_r.allocUnsafe(20);return r.writeInt32BE(this._a|0,0),r.writeInt32BE(this._b|0,4),r.writeInt32BE(this._c|0,8),r.writeInt32BE(this._d|0,12),r.writeInt32BE(this._e|0,16),r};var jr=_t;const Dr=Kt(jr);var kr=Ae,je=Oe,Tr=Zt.Buffer,Ur=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Cr=new Array(64);function At(){this.init(),this._w=Cr,je.call(this,64,56)}kr(At,je);At.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function $r(r,i,o){return o^r&(i^o)}function Nr(r,i,o){return r&i|o&(r|i)}function zr(r){return(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10)}function Mr(r){return(r>>>6|r<<26)^(r>>>11|r<<21)^(r>>>25|r<<7)}function Rr(r){return(r>>>7|r<<25)^(r>>>18|r<<14)^r>>>3}function Lr(r){return(r>>>17|r<<15)^(r>>>19|r<<13)^r>>>10}At.prototype._update=function(r){for(var i=this._w,o=this._a|0,p=this._b|0,u=this._c|0,f=this._d|0,c=this._e|0,s=this._f|0,h=this._g|0,g=this._h|0,y=0;y<16;++y)i[y]=r.readInt32BE(y*4);for(;y<64;++y)i[y]=Lr(i[y-2])+i[y-7]+Rr(i[y-15])+i[y-16]|0;for(var _=0;_<64;++_){var F=g+Mr(c)+$r(c,s,h)+Ur[_]+i[_]|0,A=zr(o)+Nr(o,p,u)|0;g=h,h=s,s=c,c=f+F|0,f=u,u=p,p=o,o=F+A|0}this._a=o+this._a|0,this._b=p+this._b|0,this._c=u+this._c|0,this._d=f+this._d|0,this._e=c+this._e|0,this._f=s+this._f|0,this._g=h+this._g|0,this._h=g+this._h|0};At.prototype._hash=function(){var r=Tr.allocUnsafe(32);return r.writeInt32BE(this._a,0),r.writeInt32BE(this._b,4),r.writeInt32BE(this._c,8),r.writeInt32BE(this._d,12),r.writeInt32BE(this._e,16),r.writeInt32BE(this._f,20),r.writeInt32BE(this._g,24),r.writeInt32BE(this._h,28),r};var Pr=At;const qr=Kt(Pr),Yt=new Error("File system not available.");function Hr(r,i,o){throw Yt}function De(r){throw Yt}function Jr(r){throw Yt}const Wr=async r=>De(),Xr={sha1:Dr,sha256:qr},kt=(r,i="sha1")=>{if(!["sha1","sha256"].includes(i))throw new Error("Hashing algorithm not supported: Available: sha1, sha256");const o=Xr[i];return new o().update(r).digest("base64")};function ke(r){const i=[],o=Object.keys(r);for(const p of o){const u=r[p].sort((f,c)=>f.index-c.index);for(let f=0;f<u.length;f++)u[f].index!==f&&i.push({message:`Invalid operation index ${u[f].index} at position ${f}`,details:{position:f,operation:u[f],scope:u[f].scope}})}return i}const Qt=async r=>{const i=new se,{name:o,revision:p,documentType:u,created:f,lastModified:c}=r,s={name:o,revision:p,documentType:u,created:f,lastModified:c};return i.file("header.json",JSON.stringify(s,null,2)),i.file("state.json",JSON.stringify(r.initialState||{},null,2)),i.file("operations.json",JSON.stringify(r.operations,null,2)),Object.keys(r.attachments).forEach(g=>{const{data:y,..._}=r.attachments[g];i.file(g,y,{base64:!0,createFolders:!0,comment:JSON.stringify(_)})}),i},Te=async(r,i,o,p)=>{await(await Qt(r)).generateAsync({type:"uint8array",streamFiles:!0});const f=p??r.name,c=`.${o}.zip`;return Hr(i,f.endsWith(c)?f:`${f}${c}`)},Vr=async(r,i)=>{const p=await(await Qt(r)).generateAsync({type:"blob"}),u=await i.createWritable();await u.write(p),await u.close()},Lt=async(r,i,o)=>{const p=De();return Ue(p,i,o)},Ue=async(r,i,o)=>{const p=new se;return await p.loadAsync(r),Kr(p,i,o)};async function Kr(r,i,o){const p=r.file("state.json");if(!p)throw new Error("Initial state not found");const u=await p.async("string"),f=JSON.parse(u),c=r.file("header.json");let s;c&&(s=JSON.parse(await c.async("string")));const h=r.file("operations.json");if(!h)throw new Error("Operations history not found");const g=JSON.parse(await h.async("string")),y=ke(g);if(y.length){const F=y.map(A=>A.message);throw new Error(F.join(`
|
|
25
|
-
`))}let _=ie(f,g,i,void 0,s,{},o);return s&&(_={..._,...s}),_}function Ce(r){const i=r.replace(/^.*\./,"")||void 0,o=r.replace(/^.*[/\\]/,"")||void 0;return{extension:i,fileName:o}}async function Gr(r){const{buffer:i,mimeType:o="application/octet-stream"}=await Jr(),p=Ce(r),u=i.toString("base64");return{data:u,hash:kt(u),mimeType:o,...p}}async function Zr(r){const i=await Wr(),o=hr.getType(r)||"application/octet-stream",p=Ce(r),u=i.toString("base64");return{data:u,hash:kt(u),mimeType:o,...p}}var $e=(r=>(r.UNEXPECTED_INDEX="UNEXPECTED_INDEX",r))($e||{}),Ne=(r=>(r.DUPLICATED_INDEX="DUPLICATED_INDEX",r.MISSING_INDEX="MISSING_INDEX",r))(Ne||{});function te(r){const i=[];let o=-1;for(const p of r){const u=p.index-p.skip;u!==o+1&&i.push({operation:{index:p.index,skip:p.skip},issue:"UNEXPECTED_INDEX",category:u>o+1?"MISSING_INDEX":"DUPLICATED_INDEX",message:`Expected index ${o+1} with skip 0 or equivalent, got index ${p.index} with skip ${p.skip}`}),o=p.index}return i}function at(r){var p,u,f;const i=[];let o=r.length-1;for(;o>-1;){i.unshift(r[o]);const c=(((p=r[o])==null?void 0:p.index)||0)-(((u=r[o])==null?void 0:u.skip)||0)-1;let s=o-1;for(;s>-1&&(((f=r[s])==null?void 0:f.index)||0)>c;)s--;o=s}return i}function Yr(r){const i=[...r],o=i[i.length-1];return o&&(o.type==="NOOP"?i.push({...o,index:o.index,type:"NOOP",skip:Re(r)}):i.push({type:"NOOP",index:o.index+1,timestamp:new Date().toISOString(),input:{},skip:1,scope:o.scope,hash:o.hash})),i}function st(r){return r.slice().sort((i,o)=>i.skip-o.skip).sort((i,o)=>i.index-o.index)}const Qr=(r,i,o)=>[...i,...o].sort((p,u)=>new Date(p.timestamp).getTime()-new Date(u.timestamp).getTime()).map((p,u)=>({...p,index:r.index+u,skip:u===0?r.skip:0})),ti=(r,i,o)=>[...i,...o].sort((p,u)=>new Date(p.timestamp).getTime()-new Date(u.timestamp).getTime()).sort((p,u)=>p.index-u.index).map((p,u)=>({...p,index:r.index+u,skip:u===0?r.skip:0}));function ee(r,i){return gt(r)===gt(i)}function ei(r,i){const o=at(st(r.slice())),p=at(st(i.slice()));if(o.length<1)return[p,[]];const u=[];let f=!1;for(;p.length>0;){const c=p[0];let s=o.shift();for(;s&&ze(s,c);)u.push(s),s=o.shift();if(s?f||(ee(s,c)?(p.shift(),u.push(s)):(o.unshift(s),f=!0)):f=!0,f){let h=p.shift();for(;h;)u.push(h),h=p.shift()}}if(!f){let c=o.shift();for(;c;)u.push(c),c=o.shift()}return[at(u),o]}function ze(r,i){return r.index<i.index||r.index===i.index&&r.skip<i.skip}function Me(r,i){const o=[],p=[],u=[],f=Math.max(r.length,i.length);let c=!1;for(let s=0;s<f;s++){const h=r[s],g=i[s];h&&g?!c&&ee(h,g)?o.push(h):(c=!0,p.push(h),u.push(g)):h?p.push(h):g&&u.push(g)}return[o,p,u]}function ri(r,i,o){const[p,u,f]=Me(at(r),at(i)),c=Nt(p),s=1+Math.max(c,Nt(u),Nt(f)),h=o({index:s,skip:s-(c+1)},u,f);return p.concat(h)}function Nt(r){const i=r[r.length-1];return i?i.index:-1}function Re(r){var p,u,f;if(r.length<1)return-1;const i=at(r);let o=(((p=i[i.length-1])==null?void 0:p.skip)||0)+1;return i.length>1&&(o+=((u=i[i.length-2])==null?void 0:u.skip)||0),(((f=i[i.length-1])==null?void 0:f.index)||-1)<o?-1:o}const ii=r=>te(at(st(r))),ni=r=>r.reduce((o,p)=>{var u;return o[p.scope]||(o[p.scope]=[]),(u=o[p.scope])==null||u.push(p),o},{}),oi=(r,i)=>{var h;const o={integrityIssues:[],validOperations:[],invalidOperations:[],duplicatedOperations:[]},p=st(r),u=st(i),f=te([...p,...u]),s=(h=[...f.filter(g=>g.category==="MISSING_INDEX")].sort((g,y)=>y.operation.index-g.operation.index).pop())==null?void 0:h.operation;for(const g of u){if(s&&g.index>=s.index){o.invalidOperations.push(g);continue}if(f.some(_=>_.operation.index===g.index&&_.operation.skip===g.skip&&_.category==="DUPLICATED_INDEX")){o.duplicatedOperations.push(g);continue}o.validOperations.push(g)}return o.integrityIssues.push(...f),o};function ai(r,i){return r.filter(o=>!i.some(p=>o.type==="NOOP"&&o.skip===0&&o.index===p.index||o.index===p.index&&o.skip===p.skip&&o.scope===p.scope&&o.hash===p.hash&&o.type===p.type))}function Le(r,i){const[o]=st(r).slice(-1),p=(o==null?void 0:o.index)??-1,u=p+1,f={...i,index:i.index??u};if(f.index<p)throw new Error(`The skip header operation index must be greater than or equal to ${p}`);return(at(st([...r,f]))||[]).slice(0,-1)}function Pt(r){return{...Object.entries(r).reduce((o,p)=>{const[u,f]=p;return{...o,[u]:at(st(f))}},{})}}const si=Object.freeze(Object.defineProperty({__proto__:null,IntegrityIssueSubType:Ne,IntegrityIssueType:$e,addUndo:Yr,attachBranch:ei,checkCleanedOperationsIntegrity:te,checkOperationsIntegrity:ii,garbageCollect:at,grabageCollectDocumentOperations:Pt,groupOperationsByScope:ni,merge:ri,nextSkipNumber:Re,operationsAreEqual:ee,precedes:ze,prepareOperations:oi,removeExistingOperations:ai,reshuffleByTimestamp:Qr,reshuffleByTimestampAndIndex:ti,skipHeaderOperations:Le,sortOperations:st,split:Me},Symbol.toStringTag,{value:"Module"}));function pi(r,i){let o;return"index"in i?o={...i}:o=r.operations[i.scope].at(-1),((o==null?void 0:o.index)??-1)+1}function ci(r,i){return{...r,revision:{...r.revision,[i.scope]:pi(r,i)},lastModified:new Date().toISOString()}}function li(r,i,o=0){if([bt,vt,It].includes(i.type))return r;const{scope:p}=i,u=r.operations[p].slice(0,r.revision[p]),f=[...u].pop();let c=((f==null?void 0:f.index)??-1)+1;if("index"in i){if(i.index-o>c)throw new Error(`Missing operations: expected ${c} with skip 0 or equivalent, got index ${i.index} with skip ${o}`);c=i.index}return u.push({...i,index:c,timestamp:new Date().toISOString(),hash:"",scope:p,skip:o,error:void 0}),{...r,operations:{...r.operations,[p]:u}}}function ui(r,i,o=0){let p=li(r,i,o);return p=ci(p,i),p}function fi(r,i,o){switch(me().parse(i),i.type){case be:return ar(r,i.input);case It:return cr(r,i,o);case ve:return lr(r,i.input.state);default:return r}}function hi(r,i,o){switch(i.type){case bt:return sr(r,i,o);case vt:return pr(r,i,o);default:return{document:r,action:i,skip:o}}}function mi(r,i,o,p){const u=i.scope,f=r.operations[u].at(-1);if(!f)return r;const c=Pt({...r.operations,[u]:Le(r.operations[u],f)}),{state:s}=Ot(r.initialState,c,o,void 0,void 0,void 0);return{...r,state:s,operations:Pt({...r.operations})}}function re(r,i,o,p,u={}){const{skip:f,ignoreSkipOperations:c=!1,reuseHash:s=!1}=u,h={...i},g=f||0;let y={...r};const _=!c&&(g>0||"index"in h&&h.skip>0);return qt(h)&&(y=fi(y,h,o)),y=ui(y,h,g),_&&(y=mi(y,h,o)),y=nt.produce(y,F=>{try{const A=o(F.state,h,p);if(A)return nt.castDraft({...y,state:A})}catch(A){const $=y.operations[h.scope].length-1;F.operations[h.scope][$].error=A.message,F.operations[h.scope][$].skip=0,_&&(F.state=nt.castDraft({...r.state}),F.operations=nt.castDraft({...r.operations,[h.scope]:[...r.operations[h.scope],{...F.operations[h.scope][$]}]}))}}),nt.produce(y,F=>{if([bt,vt,It].includes(h.type))return F;const A=h.scope||"global",$=s&&Object.prototype.hasOwnProperty.call(h,"hash")?h.hash:Tt(F,A);F.operations[A][F.operations[A].length-1].hash=$,!qt(h)&&h.attachments&&h.attachments.forEach(M=>{const{hash:Y,...w}=M;F.attachments[Y]={...w}})})}function xi(r){return r.type===ur&&r.skip!==void 0&&r.skip>0&&r.hash!==void 0}function di(r){return[bt,vt].includes(r.type)}function qt(r){return[be,bt,vt,It,ve].includes(r.type)}function ft(r,i,o,p,u="global"){if(!r)throw new Error("Empty action type");if(typeof r!="string")throw new Error(`Invalid action type: ${JSON.stringify(r)}`);const f={type:r,input:i,scope:u};o&&(f.attachments=o);try{p==null||p().parse(f.input)}catch(c){throw new Error(`Invalid action input: ${c}`)}return f}function Pe(r,i=re){return(o,p,u,f)=>i(o,p,r,u,f)}const qe=(r,i)=>({name:"",documentType:"",revision:{global:0,local:0},created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...r,state:(i==null?void 0:i(r==null?void 0:r.state))??(r==null?void 0:r.state)??{global:{},local:{}}}),He=(r,i)=>{const o=qe(r,i);return{...o,initialState:o,operations:{global:[],local:[]},clipboard:[]}},Tt=(r,i="global")=>kt(gt(r.state[i]||"")),gi=(r,i=1e3)=>{const o=Math.random()*i;return kt(`${(r??new Date).toISOString()}${o}`)};function wt(r){return nt.castImmutable(nt.freeze(r,!0))}function yi(r,i){const o=[...r];let p=i||0,u=o.length>0?o[o.length-1].index:0;const f=[];for(const c of o.reverse()){if(p>0){const g=u-c.index;p-=g}if(p<0)throw new Error("Invalid operation index, missing operations");const s={ignore:p>0,operation:c},h=c.skip>0?c.skip+1:0;if(h>0&&h>p){const g=h-p;p=p+g}u=c.index,f.push(s)}return f.reverse()}function wi(r,i,o){const p=r.slice().sort((s,h)=>s.skip-h.skip).sort((s,h)=>s.index-h.index);let u=o,f=0,c=i;for(const s of p.reverse()){const h=c-s.index;if(u=u-h,u>-1)f++,c=s.index;else break}return f}function Ei(r){return Object.values(r).flatMap(i=>i).sort((i,o)=>new Date(i.timestamp).getTime()-new Date(o.timestamp).getTime())}function bi(r){return Object.values(r).flatMap(i=>i).sort((i,o)=>new Date(i.operation.timestamp).getTime()-new Date(o.operation.timestamp).getTime())}function Ot(r,i,o,p,u,f=re,c={},s){const h=Pe(o,f);return ie(r,i,h,p,u,c,s)}function ie(r,i,o,p,u,f={},c){const s=(c==null?void 0:c.checkHashes)??!0,h=He(r),g=Object.values(i).flat(),y=g.reduce((A,$)=>o(A,$,p,{skip:$.skip,ignoreSkipOperations:!0,reuseHash:!s}),h);if(!s)for(const A of Object.keys(y.state))for(let $=g.length-1;$>=0;$--){const M=g[$];if(M.scope===A){if(M.hash!==Tt(y,A))throw new Error(`Hash mismatch for scope ${A}`);break}}const _=Object.keys(y.operations).reduce((A,$)=>{const M=$;return{...A,[M]:[...y.operations[M].map((Y,w)=>{var E;return{...Y,timestamp:((E=i[M][w])==null?void 0:E.timestamp)??Y.timestamp}})]}},{global:[],local:[]}),F=Object.values(_).reduce((A,$)=>{const M=$[$.length-1];return(M==null?void 0:M.timestamp)>A&&(A=M.timestamp),A},r.lastModified);return{...y,operations:_,lastModified:F}}function vi(r,i){return gt(r)===gt(i)}const Je=r=>ft("SET_NAME",r,void 0,Xt,void 0),We=(r=1,i="global")=>ft("UNDO",r,void 0,Vt,i),Xe=(r=1,i="global")=>ft("REDO",r,void 0,Wt,i),Ve=(r,i,o="global")=>ft("PRUNE",{start:r,end:i},void 0,Jt,o),ne=(r,i)=>ft("LOAD_STATE",{state:r,operations:i},void 0,Ht),Ke=(r="global")=>ft("NOOP",{},void 0,void 0,r),_i=Object.freeze(Object.defineProperty({__proto__:null,loadState:ne,noop:Ke,prune:Ve,redo:Xe,setName:Je,undo:We},Symbol.toStringTag,{value:"Module"}));class Ai{constructor(i,o,p){Bt(this,"_document");Bt(this,"_reducer");Bt(this,"_signalDispatch");this._reducer=i,this._document=o,this._signalDispatch=p}dispatch(i,o){return this._document=this._reducer(this._document,i,this._signalDispatch,o),this}saveToFile(i,o,p){return Te(this._document,i,o,p)}async loadFromFile(i){this._document=await Lt(i,this._reducer)}static async stateFromFile(i,o){return await Lt(i,o)}get state(){return wt(this._document.state)}get operations(){return wt(this._document.operations)}get name(){return this._document.name}get documentType(){return this._document.documentType}get created(){return this._document.created}get lastModified(){return this._document.lastModified}get revision(){return this._document.revision.global}getRevision(i){return this._document.revision[i]}get initialState(){return wt(this._document.initialState)}toDocument(){return wt(this._document)}getAttachment(i){return this._document.attachments[i]}setName(i){return this.dispatch(Je(i)),this}undo(i){return this.dispatch(We(i)),this}redo(i){return this.dispatch(Xe(i)),this}prune(i,o){return this.dispatch(Ve(i,o)),this}loadState(i,o){return this.dispatch(ne(i,o)),this}}function Si(r,i){i.forEach(o=>{Object.getOwnPropertyNames(o.prototype).forEach(p=>{Object.defineProperty(r.prototype,p,Object.getOwnPropertyDescriptor(o.prototype,p)||Object.create(null))})})}exports.BaseActions=_i;exports.BaseDocument=Ai;exports.applyMixins=Si;exports.baseReducer=re;exports.calculateSkipsLeft=wi;exports.createAction=ft;exports.createDocument=He;exports.createExtendedState=qe;exports.createReducer=Pe;exports.createZip=Qt;exports.documentHelpers=si;exports.getLocalFile=Zr;exports.getRemoteFile=Gr;exports.hashDocument=Tt;exports.hashKey=gi;exports.isBaseAction=qt;exports.isNoopOperation=xi;exports.isSameDocument=vi;exports.isUndoRedo=di;exports.loadFromFile=Lt;exports.loadFromInput=Ue;exports.mapSkippedOperations=yi;exports.processUndoRedo=hi;exports.readOnly=wt;exports.replayDocument=ie;exports.replayOperations=Ot;exports.saveToFile=Te;exports.saveToFileHandle=Vr;exports.sortMappedOperations=bi;exports.sortOperations=Ei;exports.validateOperations=ke;exports.zod=nr;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { j as e, f as a, b as s, a as o, c as t, k as r, m as i, n, o as c, p as l, q as p, i as d, r as u, t as m, u as O, l as y, e as b, v as D, w as F, x as S, y as _, s as f, d as g, z as v, A as h, C as j, B as x, h as z, g as R, D as A, E as B, F as M } from "./object-CPDHmXxz.js";
|
|
2
|
-
const T = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3
|
-
__proto__: null,
|
|
4
|
-
calculateSkipsLeft: e,
|
|
5
|
-
createAction: a,
|
|
6
|
-
createDocument: s,
|
|
7
|
-
createExtendedState: o,
|
|
8
|
-
createReducer: t,
|
|
9
|
-
createZip: r,
|
|
10
|
-
documentHelpers: i,
|
|
11
|
-
getLocalFile: n,
|
|
12
|
-
getRemoteFile: c,
|
|
13
|
-
hashDocument: l,
|
|
14
|
-
hashKey: p,
|
|
15
|
-
isBaseAction: d,
|
|
16
|
-
isNoopOperation: u,
|
|
17
|
-
isSameDocument: m,
|
|
18
|
-
isUndoRedo: O,
|
|
19
|
-
loadFromFile: y,
|
|
20
|
-
loadFromInput: b,
|
|
21
|
-
mapSkippedOperations: D,
|
|
22
|
-
readOnly: F,
|
|
23
|
-
replayDocument: S,
|
|
24
|
-
replayOperations: _,
|
|
25
|
-
saveToFile: f,
|
|
26
|
-
saveToFileHandle: g,
|
|
27
|
-
sortMappedOperations: v,
|
|
28
|
-
sortOperations: h,
|
|
29
|
-
validateOperations: j
|
|
30
|
-
}, Symbol.toStringTag, { value: "Module" })), E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
31
|
-
__proto__: null,
|
|
32
|
-
BaseDocument: x,
|
|
33
|
-
actions: z,
|
|
34
|
-
applyMixins: R,
|
|
35
|
-
baseReducer: A,
|
|
36
|
-
processUndoRedo: B,
|
|
37
|
-
utils: T,
|
|
38
|
-
z: M
|
|
39
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
40
|
-
export {
|
|
41
|
-
E as D,
|
|
42
|
-
T as i
|
|
43
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("./object-Bc_eSRcx.js"),t=Object.freeze(Object.defineProperty({__proto__:null,calculateSkipsLeft:e.calculateSkipsLeft,createAction:e.createAction,createDocument:e.createDocument,createExtendedState:e.createExtendedState,createReducer:e.createReducer,createZip:e.createZip,documentHelpers:e.documentHelpers,getLocalFile:e.getLocalFile,getRemoteFile:e.getRemoteFile,hashDocument:e.hashDocument,hashKey:e.hashKey,isBaseAction:e.isBaseAction,isNoopOperation:e.isNoopOperation,isSameDocument:e.isSameDocument,isUndoRedo:e.isUndoRedo,loadFromFile:e.loadFromFile,loadFromInput:e.loadFromInput,mapSkippedOperations:e.mapSkippedOperations,readOnly:e.readOnly,replayDocument:e.replayDocument,replayOperations:e.replayOperations,saveToFile:e.saveToFile,saveToFileHandle:e.saveToFileHandle,sortMappedOperations:e.sortMappedOperations,sortOperations:e.sortOperations,validateOperations:e.validateOperations},Symbol.toStringTag,{value:"Module"})),o=Object.freeze(Object.defineProperty({__proto__:null,BaseDocument:e.BaseDocument,actions:e.BaseActions,applyMixins:e.applyMixins,baseReducer:e.baseReducer,processUndoRedo:e.processUndoRedo,utils:t,z:e.zod},Symbol.toStringTag,{value:"Module"}));exports.Document=o;exports.index=t;
|