web-music-score 0.0.1 → 6.0.0-pre.1
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/CHANGELOG.md +200 -0
- package/LICENSE +62 -1
- package/README.md +46 -2
- package/dist/audio/index.d.ts +50 -0
- package/dist/audio/index.js +1858 -0
- package/dist/audio/index.mjs +92 -0
- package/dist/audio-cg/index.d.ts +21 -0
- package/dist/audio-cg/index.js +17568 -0
- package/dist/audio-cg/index.mjs +90 -0
- package/dist/audio-synth/index.d.ts +15 -0
- package/dist/audio-synth/index.js +18497 -0
- package/dist/audio-synth/index.mjs +63 -0
- package/dist/chunk-A7C2G7OG.mjs +101 -0
- package/dist/chunk-GNT3ECDB.mjs +267 -0
- package/dist/chunk-LO4NI4AU.mjs +18381 -0
- package/dist/chunk-PW2SO6EZ.mjs +37 -0
- package/dist/chunk-VHB57TXT.mjs +11 -0
- package/dist/chunk-X7BMJX7E.mjs +3867 -0
- package/dist/core/index.d.ts +31 -0
- package/dist/core/index.js +74 -0
- package/dist/core/index.mjs +22 -0
- package/dist/iife/audio-cg.global.js +220 -0
- package/dist/iife/index.global.js +228 -0
- package/dist/instrument-DS-9C6_8.d.ts +44 -0
- package/dist/music-objects-DLmp5uL6.d.ts +2398 -0
- package/dist/note-RVXvpfyV.d.ts +306 -0
- package/dist/pieces/index.d.ts +46 -0
- package/dist/pieces/index.js +79 -0
- package/dist/pieces/index.mjs +50 -0
- package/dist/react-ui/index.d.ts +86 -0
- package/dist/react-ui/index.js +132 -0
- package/dist/react-ui/index.mjs +96 -0
- package/dist/scale-B1M10_fu.d.ts +230 -0
- package/dist/score/index.d.ts +466 -0
- package/dist/score/index.js +13964 -0
- package/dist/score/index.mjs +10092 -0
- package/dist/tempo-D-JF-8b_.d.ts +409 -0
- package/dist/theory/index.d.ts +78 -0
- package/dist/theory/index.js +4842 -0
- package/dist/theory/index.mjs +1986 -0
- package/package.json +131 -3
- package/workspace.code-workspace +0 -9
|
@@ -0,0 +1,3867 @@
|
|
|
1
|
+
/* WebMusicScore v6.0.0-pre.1 | (c) 2023-2025 Stefan Brockmann | MIT License | Includes: Tone.js (MIT License), Color Name to Code (MIT License) */
|
|
2
|
+
import {
|
|
3
|
+
__yieldStar
|
|
4
|
+
} from "./chunk-A7C2G7OG.mjs";
|
|
5
|
+
|
|
6
|
+
// node_modules/@tspro/ts-utils-lib/dist/index.mjs
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
14
|
+
var assert_exports = {};
|
|
15
|
+
__export(assert_exports, {
|
|
16
|
+
assert: () => assert,
|
|
17
|
+
doesNotThrow: () => doesNotThrow2,
|
|
18
|
+
doesThrow: () => doesThrow2,
|
|
19
|
+
fail: () => fail,
|
|
20
|
+
isArray: () => isArray2,
|
|
21
|
+
isArrayOrUndefined: () => isArrayOrUndefined2,
|
|
22
|
+
isBigInt: () => isBigInt2,
|
|
23
|
+
isBoolean: () => isBoolean2,
|
|
24
|
+
isBooleanOrUndefined: () => isBooleanOrUndefined2,
|
|
25
|
+
isDeepEqual: () => isDeepEqual2,
|
|
26
|
+
isDefined: () => isDefined2,
|
|
27
|
+
isEmptyArray: () => isEmptyArray2,
|
|
28
|
+
isEmptyArrayOrUndefined: () => isEmptyArrayOrUndefined2,
|
|
29
|
+
isEmptyObject: () => isEmptyObject2,
|
|
30
|
+
isEmptyString: () => isEmptyString2,
|
|
31
|
+
isEmptyStringOrUndefined: () => isEmptyStringOrUndefined2,
|
|
32
|
+
isEnumValue: () => isEnumValue2,
|
|
33
|
+
isEnumValueOrUndefined: () => isEnumValueOrUndefined2,
|
|
34
|
+
isEven: () => isEven2,
|
|
35
|
+
isFalse: () => isFalse2,
|
|
36
|
+
isFalseOrUndefined: () => isFalseOrUndefined2,
|
|
37
|
+
isFinite: () => isFinite3,
|
|
38
|
+
isFloat: () => isFloat2,
|
|
39
|
+
isFunction: () => isFunction2,
|
|
40
|
+
isFunctionOrUndefined: () => isFunctionOrUndefined2,
|
|
41
|
+
isIncluded: () => isIncluded2,
|
|
42
|
+
isIndex: () => isIndex2,
|
|
43
|
+
isInfinity: () => isInfinity2,
|
|
44
|
+
isInteger: () => isInteger2,
|
|
45
|
+
isIntegerBetween: () => isIntegerBetween2,
|
|
46
|
+
isIntegerBetweenExclusive: () => isIntegerBetweenExclusive2,
|
|
47
|
+
isIntegerEq: () => isIntegerEq2,
|
|
48
|
+
isIntegerGt: () => isIntegerGt2,
|
|
49
|
+
isIntegerGte: () => isIntegerGte2,
|
|
50
|
+
isIntegerLt: () => isIntegerLt2,
|
|
51
|
+
isIntegerLte: () => isIntegerLte2,
|
|
52
|
+
isIntegerOrUndefined: () => isIntegerOrUndefined2,
|
|
53
|
+
isMultipleOf: () => isMultipleOf2,
|
|
54
|
+
isNaNValue: () => isNaNValue2,
|
|
55
|
+
isNeg: () => isNeg2,
|
|
56
|
+
isNegInfinity: () => isNegInfinity2,
|
|
57
|
+
isNegZero: () => isNegZero2,
|
|
58
|
+
isNonEmptyArray: () => isNonEmptyArray2,
|
|
59
|
+
isNonEmptyArrayOrUndefined: () => isNonEmptyArrayOrUndefined2,
|
|
60
|
+
isNonEmptyString: () => isNonEmptyString2,
|
|
61
|
+
isNonEmptyStringOrUndefined: () => isNonEmptyStringOrUndefined2,
|
|
62
|
+
isNonNeg: () => isNonNeg2,
|
|
63
|
+
isNonNull: () => isNonNull2,
|
|
64
|
+
isNonPos: () => isNonPos2,
|
|
65
|
+
isNull: () => isNull2,
|
|
66
|
+
isNullish: () => isNullish2,
|
|
67
|
+
isNumber: () => isNumber2,
|
|
68
|
+
isNumberBetween: () => isNumberBetween2,
|
|
69
|
+
isNumberBetweenExclusive: () => isNumberBetweenExclusive2,
|
|
70
|
+
isNumberEq: () => isNumberEq2,
|
|
71
|
+
isNumberGt: () => isNumberGt2,
|
|
72
|
+
isNumberGte: () => isNumberGte2,
|
|
73
|
+
isNumberLt: () => isNumberLt2,
|
|
74
|
+
isNumberLte: () => isNumberLte2,
|
|
75
|
+
isNumberOrUndefined: () => isNumberOrUndefined2,
|
|
76
|
+
isNumericString: () => isNumericString2,
|
|
77
|
+
isObject: () => isObject2,
|
|
78
|
+
isObjectOrUndefined: () => isObjectOrUndefined2,
|
|
79
|
+
isOdd: () => isOdd2,
|
|
80
|
+
isPlainObject: () => isPlainObject2,
|
|
81
|
+
isPos: () => isPos2,
|
|
82
|
+
isPosInfinity: () => isPosInfinity2,
|
|
83
|
+
isPosZero: () => isPosZero2,
|
|
84
|
+
isPowerOfTwo: () => isPowerOfTwo2,
|
|
85
|
+
isSafeInteger: () => isSafeInteger2,
|
|
86
|
+
isSafeNumber: () => isSafeNumber2,
|
|
87
|
+
isStrictEqual: () => isStrictEqual2,
|
|
88
|
+
isString: () => isString2,
|
|
89
|
+
isStringOrUndefined: () => isStringOrUndefined2,
|
|
90
|
+
isTrue: () => isTrue2,
|
|
91
|
+
isTrueOrUndefined: () => isTrueOrUndefined2,
|
|
92
|
+
isTypedObject: () => isTypedObject2,
|
|
93
|
+
isUndefined: () => isUndefined2,
|
|
94
|
+
isZero: () => isZero2,
|
|
95
|
+
require: () => require2,
|
|
96
|
+
requireDefined: () => requireDefined,
|
|
97
|
+
requireElement: () => requireElement,
|
|
98
|
+
setErrorClass: () => setErrorClass
|
|
99
|
+
});
|
|
100
|
+
var str_exports = {};
|
|
101
|
+
__export(str_exports, {
|
|
102
|
+
charCount: () => charCount,
|
|
103
|
+
chunkString: () => chunkString,
|
|
104
|
+
insertAt: () => insertAt,
|
|
105
|
+
isString: () => isString,
|
|
106
|
+
makeSentenceFromPascal: () => makeSentenceFromPascal,
|
|
107
|
+
removeAt: () => removeAt,
|
|
108
|
+
repeatString: () => repeatString,
|
|
109
|
+
replaceAt: () => replaceAt,
|
|
110
|
+
splitByCaps: () => splitByCaps,
|
|
111
|
+
splitByChars: () => splitByChars,
|
|
112
|
+
splitByStrings: () => splitByStrings,
|
|
113
|
+
stringify: () => stringify,
|
|
114
|
+
toCharArray: () => toCharArray
|
|
115
|
+
});
|
|
116
|
+
var obj_exports = {};
|
|
117
|
+
__export(obj_exports, {
|
|
118
|
+
deepEqual: () => deepEqual,
|
|
119
|
+
getCtorName: () => getCtorName,
|
|
120
|
+
hasProperties: () => hasProperties,
|
|
121
|
+
isObject: () => isObject
|
|
122
|
+
});
|
|
123
|
+
var guard_exports = {};
|
|
124
|
+
__export(guard_exports, {
|
|
125
|
+
doesNotThrow: () => doesNotThrow,
|
|
126
|
+
doesThrow: () => doesThrow,
|
|
127
|
+
isArray: () => isArray,
|
|
128
|
+
isArrayOrUndefined: () => isArrayOrUndefined,
|
|
129
|
+
isBigInt: () => isBigInt,
|
|
130
|
+
isBoolean: () => isBoolean,
|
|
131
|
+
isBooleanOrUndefined: () => isBooleanOrUndefined,
|
|
132
|
+
isDeepEqual: () => isDeepEqual,
|
|
133
|
+
isDefined: () => isDefined,
|
|
134
|
+
isEmptyArray: () => isEmptyArray,
|
|
135
|
+
isEmptyArrayOrUndefined: () => isEmptyArrayOrUndefined,
|
|
136
|
+
isEmptyObject: () => isEmptyObject,
|
|
137
|
+
isEmptyString: () => isEmptyString,
|
|
138
|
+
isEmptyStringOrUndefined: () => isEmptyStringOrUndefined,
|
|
139
|
+
isEnumValue: () => isEnumValue,
|
|
140
|
+
isEnumValueOrUndefined: () => isEnumValueOrUndefined,
|
|
141
|
+
isEven: () => isEven,
|
|
142
|
+
isFalse: () => isFalse,
|
|
143
|
+
isFalseOrUndefined: () => isFalseOrUndefined,
|
|
144
|
+
isFinite: () => isFinite2,
|
|
145
|
+
isFloat: () => isFloat,
|
|
146
|
+
isFunction: () => isFunction,
|
|
147
|
+
isFunctionOrUndefined: () => isFunctionOrUndefined,
|
|
148
|
+
isIncluded: () => isIncluded,
|
|
149
|
+
isIndex: () => isIndex,
|
|
150
|
+
isInfinity: () => isInfinity,
|
|
151
|
+
isInteger: () => isInteger,
|
|
152
|
+
isIntegerBetween: () => isIntegerBetween,
|
|
153
|
+
isIntegerBetweenExclusive: () => isIntegerBetweenExclusive,
|
|
154
|
+
isIntegerEq: () => isIntegerEq,
|
|
155
|
+
isIntegerGt: () => isIntegerGt,
|
|
156
|
+
isIntegerGte: () => isIntegerGte,
|
|
157
|
+
isIntegerLt: () => isIntegerLt,
|
|
158
|
+
isIntegerLte: () => isIntegerLte,
|
|
159
|
+
isIntegerOrUndefined: () => isIntegerOrUndefined,
|
|
160
|
+
isMultipleOf: () => isMultipleOf,
|
|
161
|
+
isNaNValue: () => isNaNValue,
|
|
162
|
+
isNeg: () => isNeg,
|
|
163
|
+
isNegInfinity: () => isNegInfinity,
|
|
164
|
+
isNegZero: () => isNegZero,
|
|
165
|
+
isNonEmptyArray: () => isNonEmptyArray,
|
|
166
|
+
isNonEmptyArrayOrUndefined: () => isNonEmptyArrayOrUndefined,
|
|
167
|
+
isNonEmptyString: () => isNonEmptyString,
|
|
168
|
+
isNonEmptyStringOrUndefined: () => isNonEmptyStringOrUndefined,
|
|
169
|
+
isNonNeg: () => isNonNeg,
|
|
170
|
+
isNonNull: () => isNonNull,
|
|
171
|
+
isNonPos: () => isNonPos,
|
|
172
|
+
isNull: () => isNull,
|
|
173
|
+
isNullish: () => isNullish,
|
|
174
|
+
isNumber: () => isNumber,
|
|
175
|
+
isNumberBetween: () => isNumberBetween,
|
|
176
|
+
isNumberBetweenExclusive: () => isNumberBetweenExclusive,
|
|
177
|
+
isNumberEq: () => isNumberEq,
|
|
178
|
+
isNumberGt: () => isNumberGt,
|
|
179
|
+
isNumberGte: () => isNumberGte,
|
|
180
|
+
isNumberLt: () => isNumberLt,
|
|
181
|
+
isNumberLte: () => isNumberLte,
|
|
182
|
+
isNumberOrUndefined: () => isNumberOrUndefined,
|
|
183
|
+
isNumericString: () => isNumericString,
|
|
184
|
+
isObject: () => isObject,
|
|
185
|
+
isObjectOrUndefined: () => isObjectOrUndefined,
|
|
186
|
+
isOdd: () => isOdd,
|
|
187
|
+
isPlainObject: () => isPlainObject,
|
|
188
|
+
isPos: () => isPos,
|
|
189
|
+
isPosInfinity: () => isPosInfinity,
|
|
190
|
+
isPosZero: () => isPosZero,
|
|
191
|
+
isPowerOfTwo: () => isPowerOfTwo,
|
|
192
|
+
isSafeInteger: () => isSafeInteger,
|
|
193
|
+
isSafeNumber: () => isSafeNumber,
|
|
194
|
+
isStrictEqual: () => isStrictEqual,
|
|
195
|
+
isString: () => isString,
|
|
196
|
+
isStringOrUndefined: () => isStringOrUndefined,
|
|
197
|
+
isTrue: () => isTrue,
|
|
198
|
+
isTrueOrUndefined: () => isTrueOrUndefined,
|
|
199
|
+
isTypedObject: () => isTypedObject,
|
|
200
|
+
isUndefined: () => isUndefined,
|
|
201
|
+
isZero: () => isZero,
|
|
202
|
+
tryOr: () => tryOr
|
|
203
|
+
});
|
|
204
|
+
var enum_exports = {};
|
|
205
|
+
__export(enum_exports, {
|
|
206
|
+
forEachEnum: () => forEachEnum,
|
|
207
|
+
getEnumEntries: () => getEnumEntries,
|
|
208
|
+
getEnumKey: () => getEnumKey,
|
|
209
|
+
getEnumKeys: () => getEnumKeys,
|
|
210
|
+
getEnumValues: () => getEnumValues
|
|
211
|
+
});
|
|
212
|
+
function getEnumKeys(e) {
|
|
213
|
+
return Object.keys(e).filter((k) => isNaN(Number(k)));
|
|
214
|
+
}
|
|
215
|
+
function getEnumValues(e) {
|
|
216
|
+
return getEnumKeys(e).map((k) => e[k]);
|
|
217
|
+
}
|
|
218
|
+
function getEnumEntries(e) {
|
|
219
|
+
return getEnumKeys(e).map((k) => [k, e[k]]);
|
|
220
|
+
}
|
|
221
|
+
function getEnumKey(e, value) {
|
|
222
|
+
return getEnumKeys(e).find((k) => e[k] === value);
|
|
223
|
+
}
|
|
224
|
+
function forEachEnum(e, callback) {
|
|
225
|
+
for (const [k, v] of getEnumEntries(e)) callback(k, v);
|
|
226
|
+
}
|
|
227
|
+
function isStrictEqual(val1, val2) {
|
|
228
|
+
return val1 === val2;
|
|
229
|
+
}
|
|
230
|
+
function isDeepEqual(val1, val2) {
|
|
231
|
+
return deepEqual(val1, val2);
|
|
232
|
+
}
|
|
233
|
+
function isUndefined(val) {
|
|
234
|
+
return val === void 0;
|
|
235
|
+
}
|
|
236
|
+
function isNull(val) {
|
|
237
|
+
return val === null;
|
|
238
|
+
}
|
|
239
|
+
function isNullish(val) {
|
|
240
|
+
return val === void 0 || val === null;
|
|
241
|
+
}
|
|
242
|
+
function isDefined(val) {
|
|
243
|
+
return val !== void 0;
|
|
244
|
+
}
|
|
245
|
+
function isNonNull(val) {
|
|
246
|
+
return val !== null;
|
|
247
|
+
}
|
|
248
|
+
function isObject(val) {
|
|
249
|
+
return typeof val === "object" && val !== null && !isArray(val);
|
|
250
|
+
}
|
|
251
|
+
function isEmptyObject(val) {
|
|
252
|
+
return isObject(val) && Object.keys(val).length === 0;
|
|
253
|
+
}
|
|
254
|
+
function isObjectOrUndefined(val) {
|
|
255
|
+
return val === void 0 || isObject(val);
|
|
256
|
+
}
|
|
257
|
+
function isPlainObject(val) {
|
|
258
|
+
if (!isObject(val)) return false;
|
|
259
|
+
const proto = Object.getPrototypeOf(val);
|
|
260
|
+
return proto === Object.prototype || proto === null;
|
|
261
|
+
}
|
|
262
|
+
function isTypedObject(val, keys) {
|
|
263
|
+
return isObject(val) && keys.every((k) => k in val);
|
|
264
|
+
}
|
|
265
|
+
function isSet(val) {
|
|
266
|
+
return val instanceof Set;
|
|
267
|
+
}
|
|
268
|
+
function isArray(arr) {
|
|
269
|
+
return !!arr && Object.prototype.toString.call(arr) === "[object Array]";
|
|
270
|
+
}
|
|
271
|
+
function isArrayOrUndefined(arr) {
|
|
272
|
+
return arr === void 0 || isArray(arr);
|
|
273
|
+
}
|
|
274
|
+
function isEmptyArray(arr) {
|
|
275
|
+
return isArray(arr) && arr.length === 0;
|
|
276
|
+
}
|
|
277
|
+
function isNonEmptyArray(arr) {
|
|
278
|
+
return isArray(arr) && arr.length > 0;
|
|
279
|
+
}
|
|
280
|
+
function isEmptyArrayOrUndefined(arr) {
|
|
281
|
+
return isArray(arr) && arr.length === 0 || arr === void 0;
|
|
282
|
+
}
|
|
283
|
+
function isNonEmptyArrayOrUndefined(arr) {
|
|
284
|
+
return isArray(arr) && arr.length > 0 || arr === void 0;
|
|
285
|
+
}
|
|
286
|
+
function isString(val) {
|
|
287
|
+
return typeof val === "string";
|
|
288
|
+
}
|
|
289
|
+
function isEmptyString(val) {
|
|
290
|
+
return typeof val === "string" && val.length === 0;
|
|
291
|
+
}
|
|
292
|
+
function isNonEmptyString(val) {
|
|
293
|
+
return typeof val === "string" && val.length > 0;
|
|
294
|
+
}
|
|
295
|
+
function isStringOrUndefined(val) {
|
|
296
|
+
return val === void 0 || typeof val === "string";
|
|
297
|
+
}
|
|
298
|
+
function isEmptyStringOrUndefined(val) {
|
|
299
|
+
return typeof val === "string" && val.length === 0 || val === void 0;
|
|
300
|
+
}
|
|
301
|
+
function isNonEmptyStringOrUndefined(val) {
|
|
302
|
+
return typeof val === "string" && val.length > 0 || val === void 0;
|
|
303
|
+
}
|
|
304
|
+
function isBoolean(val) {
|
|
305
|
+
return typeof val === "boolean";
|
|
306
|
+
}
|
|
307
|
+
function isBooleanOrUndefined(val) {
|
|
308
|
+
return val === void 0 || typeof val === "boolean";
|
|
309
|
+
}
|
|
310
|
+
function isTrue(val) {
|
|
311
|
+
return val === true;
|
|
312
|
+
}
|
|
313
|
+
function isTrueOrUndefined(val) {
|
|
314
|
+
return val === true || val === void 0;
|
|
315
|
+
}
|
|
316
|
+
function isFalse(val) {
|
|
317
|
+
return val === false;
|
|
318
|
+
}
|
|
319
|
+
function isFalseOrUndefined(val) {
|
|
320
|
+
return val === false || val === void 0;
|
|
321
|
+
}
|
|
322
|
+
function isFunction(val) {
|
|
323
|
+
return typeof val === "function";
|
|
324
|
+
}
|
|
325
|
+
function isFunctionOrUndefined(val) {
|
|
326
|
+
return val === void 0 || typeof val === "function";
|
|
327
|
+
}
|
|
328
|
+
function isEnumValue(val, enumObj) {
|
|
329
|
+
return getEnumValues(enumObj).some((v) => v === val);
|
|
330
|
+
}
|
|
331
|
+
function isEnumValueOrUndefined(val, enumObj) {
|
|
332
|
+
return val === void 0 || getEnumValues(enumObj).some((v) => v === val);
|
|
333
|
+
}
|
|
334
|
+
function isNumericString(val) {
|
|
335
|
+
if (typeof val !== "string" || val.trim() === "") return false;
|
|
336
|
+
const n = +val;
|
|
337
|
+
return Number.isFinite(n);
|
|
338
|
+
}
|
|
339
|
+
function isBigInt(val) {
|
|
340
|
+
return typeof val === "bigint";
|
|
341
|
+
}
|
|
342
|
+
function isNumber(val) {
|
|
343
|
+
return typeof val === "number";
|
|
344
|
+
}
|
|
345
|
+
function isSafeNumber(val) {
|
|
346
|
+
return isNumber(val) && Number.isSafeInteger(val);
|
|
347
|
+
}
|
|
348
|
+
function isNumberOrUndefined(val) {
|
|
349
|
+
return typeof val === "number" || val === void 0;
|
|
350
|
+
}
|
|
351
|
+
function isNumberEq(val, ref) {
|
|
352
|
+
return isNumber(val) && val === ref;
|
|
353
|
+
}
|
|
354
|
+
function isNumberGt(val, ref) {
|
|
355
|
+
return isNumber(val) && isNumber(ref) && val > ref;
|
|
356
|
+
}
|
|
357
|
+
function isNumberGte(val, ref) {
|
|
358
|
+
return isNumber(val) && isNumber(ref) && val >= ref;
|
|
359
|
+
}
|
|
360
|
+
function isNumberLt(val, ref) {
|
|
361
|
+
return isNumber(val) && isNumber(ref) && val < ref;
|
|
362
|
+
}
|
|
363
|
+
function isNumberLte(val, ref) {
|
|
364
|
+
return isNumber(val) && isNumber(ref) && val <= ref;
|
|
365
|
+
}
|
|
366
|
+
function isNumberBetween(val, min, max) {
|
|
367
|
+
return isNumber(val) && isNumber(min) && isNumber(max) && val >= min && val <= max;
|
|
368
|
+
}
|
|
369
|
+
function isNumberBetweenExclusive(val, min, max) {
|
|
370
|
+
return isNumber(val) && isNumber(min) && isNumber(max) && val > min && val < max;
|
|
371
|
+
}
|
|
372
|
+
function isFinite2(val) {
|
|
373
|
+
return typeof val === "number" && Number.isFinite(val);
|
|
374
|
+
}
|
|
375
|
+
function isFloat(val) {
|
|
376
|
+
return isFinite2(val) && !isInteger(val);
|
|
377
|
+
}
|
|
378
|
+
function isInteger(val) {
|
|
379
|
+
return typeof val === "number" && isFinite2(val) && val === Math.trunc(val);
|
|
380
|
+
}
|
|
381
|
+
function isSafeInteger(val) {
|
|
382
|
+
return isInteger(val) && Number.isSafeInteger(val);
|
|
383
|
+
}
|
|
384
|
+
function isIntegerOrUndefined(val) {
|
|
385
|
+
return typeof val === "number" && isFinite2(val) && val === Math.trunc(val) || val === void 0;
|
|
386
|
+
}
|
|
387
|
+
function isIntegerEq(val, ref) {
|
|
388
|
+
return isInteger(val) && val === ref;
|
|
389
|
+
}
|
|
390
|
+
function isIntegerGt(val, ref) {
|
|
391
|
+
return isInteger(val) && isNumber(ref) && val > ref;
|
|
392
|
+
}
|
|
393
|
+
function isIntegerGte(val, ref) {
|
|
394
|
+
return isInteger(val) && isNumber(ref) && val >= ref;
|
|
395
|
+
}
|
|
396
|
+
function isIntegerLt(val, ref) {
|
|
397
|
+
return isInteger(val) && isNumber(ref) && val < ref;
|
|
398
|
+
}
|
|
399
|
+
function isIntegerLte(val, ref) {
|
|
400
|
+
return isInteger(val) && isNumber(ref) && val <= ref;
|
|
401
|
+
}
|
|
402
|
+
function isIntegerBetween(val, min, max) {
|
|
403
|
+
return isInteger(val) && isNumber(min) && isNumber(max) && val >= min && val <= max;
|
|
404
|
+
}
|
|
405
|
+
function isIntegerBetweenExclusive(val, min, max) {
|
|
406
|
+
return isInteger(val) && isNumber(min) && isNumber(max) && val > min && val < max;
|
|
407
|
+
}
|
|
408
|
+
function isNaNValue(val) {
|
|
409
|
+
return typeof val === "number" && Number.isNaN(val);
|
|
410
|
+
}
|
|
411
|
+
function isInfinity(val) {
|
|
412
|
+
return val === Infinity || val === -Infinity;
|
|
413
|
+
}
|
|
414
|
+
function isPosInfinity(val) {
|
|
415
|
+
return val === Infinity;
|
|
416
|
+
}
|
|
417
|
+
function isNegInfinity(val) {
|
|
418
|
+
return val === -Infinity;
|
|
419
|
+
}
|
|
420
|
+
function isPos(val) {
|
|
421
|
+
return typeof val === "number" && val > 0;
|
|
422
|
+
}
|
|
423
|
+
function isNeg(val) {
|
|
424
|
+
return typeof val === "number" && val < 0;
|
|
425
|
+
}
|
|
426
|
+
function isNonPos(val) {
|
|
427
|
+
return typeof val === "number" && val <= 0;
|
|
428
|
+
}
|
|
429
|
+
function isNonNeg(val) {
|
|
430
|
+
return typeof val === "number" && val >= 0;
|
|
431
|
+
}
|
|
432
|
+
function isZero(val) {
|
|
433
|
+
return typeof val === "number" && val === 0;
|
|
434
|
+
}
|
|
435
|
+
function isPosZero(val) {
|
|
436
|
+
return typeof val === "number" && val === 0 && 1 / val === Infinity;
|
|
437
|
+
}
|
|
438
|
+
function isNegZero(val) {
|
|
439
|
+
return typeof val === "number" && val === 0 && 1 / val === -Infinity;
|
|
440
|
+
}
|
|
441
|
+
function isOdd(val) {
|
|
442
|
+
return isInteger(val) && Math.abs(val) % 2 === 1;
|
|
443
|
+
}
|
|
444
|
+
function isEven(val) {
|
|
445
|
+
return isInteger(val) && val % 2 === 0;
|
|
446
|
+
}
|
|
447
|
+
function isMultipleOf(val, base) {
|
|
448
|
+
return typeof val === "number" && typeof base === "number" && val % base === 0;
|
|
449
|
+
}
|
|
450
|
+
function isPowerOfTwo(val) {
|
|
451
|
+
return isInteger(val) && val > 0 && (val & val - 1) === 0;
|
|
452
|
+
}
|
|
453
|
+
function isIncluded(val, container) {
|
|
454
|
+
if (isArray(container)) {
|
|
455
|
+
return container.includes(val);
|
|
456
|
+
}
|
|
457
|
+
if (isSet(container)) {
|
|
458
|
+
return container.has(val);
|
|
459
|
+
}
|
|
460
|
+
return false;
|
|
461
|
+
}
|
|
462
|
+
function isIndex(index, array) {
|
|
463
|
+
return isArray(array) ? isIntegerBetween(index, 0, array.length - 1) : isIntegerGte(index, 0);
|
|
464
|
+
}
|
|
465
|
+
function doesThrow(throwTestFn) {
|
|
466
|
+
try {
|
|
467
|
+
throwTestFn();
|
|
468
|
+
return false;
|
|
469
|
+
} catch (err) {
|
|
470
|
+
return true;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
function doesNotThrow(throwTestFn) {
|
|
474
|
+
try {
|
|
475
|
+
throwTestFn();
|
|
476
|
+
return true;
|
|
477
|
+
} catch (err) {
|
|
478
|
+
return false;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
function tryOr(tryFn, orVal) {
|
|
482
|
+
try {
|
|
483
|
+
return tryFn();
|
|
484
|
+
} catch (err) {
|
|
485
|
+
return isFunction(orVal) ? orVal() : orVal;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
function hasProperties(obj, props) {
|
|
489
|
+
return isObject(obj) && props.every((p) => p in obj);
|
|
490
|
+
}
|
|
491
|
+
function deepEqual(a, b) {
|
|
492
|
+
if (a === b) return true;
|
|
493
|
+
if (a === null || b === null) return false;
|
|
494
|
+
if (typeof a !== "object" || typeof b !== "object") return false;
|
|
495
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
496
|
+
if (a.length !== b.length) return false;
|
|
497
|
+
return a.every((val, i) => deepEqual(val, b[i]));
|
|
498
|
+
}
|
|
499
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
500
|
+
const keysA = Object.keys(a);
|
|
501
|
+
const keysB = Object.keys(b);
|
|
502
|
+
if (keysA.length !== keysB.length) return false;
|
|
503
|
+
for (const key of keysA) {
|
|
504
|
+
if (!Object.prototype.hasOwnProperty.call(b, key)) return false;
|
|
505
|
+
if (!deepEqual(a[key], b[key])) return false;
|
|
506
|
+
}
|
|
507
|
+
return true;
|
|
508
|
+
}
|
|
509
|
+
function getCtorName(obj) {
|
|
510
|
+
if (obj === null) return "null";
|
|
511
|
+
if (isArray(obj)) return "Array";
|
|
512
|
+
if (typeof obj !== "object") return typeof obj;
|
|
513
|
+
const tag = Object.prototype.toString.call(obj).slice(8, -1);
|
|
514
|
+
return tag || "Object";
|
|
515
|
+
}
|
|
516
|
+
function toCharArray(str2) {
|
|
517
|
+
return str2.split("");
|
|
518
|
+
}
|
|
519
|
+
function repeatString(repeatString2, repeatCount) {
|
|
520
|
+
if (!isInteger(repeatCount) || repeatCount < 0) {
|
|
521
|
+
throw new Error("repeatStr: Invalid repeatCount = " + repeatCount);
|
|
522
|
+
}
|
|
523
|
+
return new Array(repeatCount + 1).join(repeatString2);
|
|
524
|
+
}
|
|
525
|
+
function chunkString(str2, chunkSize) {
|
|
526
|
+
if (!isInteger(chunkSize) || chunkSize < 1) {
|
|
527
|
+
throw new Error("chunckString: Invalid chuckSize = " + chunkSize);
|
|
528
|
+
}
|
|
529
|
+
let result = [];
|
|
530
|
+
for (let i = 0; i < str2.length; i += chunkSize) {
|
|
531
|
+
result.push(str2.slice(i, i + chunkSize));
|
|
532
|
+
}
|
|
533
|
+
return result;
|
|
534
|
+
}
|
|
535
|
+
function replaceAt(str2, pos, removeCount, insert) {
|
|
536
|
+
if (!isInteger(removeCount) || removeCount < 0) {
|
|
537
|
+
throw new Error("replaceAt: Invalid removeCount = " + removeCount);
|
|
538
|
+
} else if (!isInteger(pos) || pos < 0 || pos + removeCount > str2.length) {
|
|
539
|
+
throw new Error("replaceAt: Invalid pos = " + pos + ", removeCount = " + removeCount + ", str.length = " + str2.length);
|
|
540
|
+
} else {
|
|
541
|
+
return str2.substring(0, pos) + insert + str2.substring(pos + removeCount);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
function insertAt(str2, pos, insertStr) {
|
|
545
|
+
return replaceAt(str2, pos, 0, insertStr);
|
|
546
|
+
}
|
|
547
|
+
function removeAt(str2, pos, removeCount) {
|
|
548
|
+
return replaceAt(str2, pos, removeCount, "");
|
|
549
|
+
}
|
|
550
|
+
function charCount(str2, ch) {
|
|
551
|
+
if (ch.length !== 1 || str2.length === 0) return 0;
|
|
552
|
+
let count = 0;
|
|
553
|
+
for (let i = 0; i < str2.length; i++) {
|
|
554
|
+
if (str2[i] === ch) count++;
|
|
555
|
+
}
|
|
556
|
+
return count;
|
|
557
|
+
}
|
|
558
|
+
function makeSentenceFromPascal(PascalString) {
|
|
559
|
+
if (PascalString === "") {
|
|
560
|
+
return "";
|
|
561
|
+
}
|
|
562
|
+
let word = PascalString.charAt(0);
|
|
563
|
+
let sentence = "";
|
|
564
|
+
const addWord = () => {
|
|
565
|
+
if (word !== "") {
|
|
566
|
+
if (sentence === "") {
|
|
567
|
+
sentence += word.charAt(0).toUpperCase() + word.substring(1);
|
|
568
|
+
} else {
|
|
569
|
+
sentence += " " + word;
|
|
570
|
+
}
|
|
571
|
+
word = "";
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
const isLetterAndCapital = (c) => {
|
|
575
|
+
return c.toUpperCase() !== c.toLowerCase() && c === c.toUpperCase();
|
|
576
|
+
};
|
|
577
|
+
for (let i = 1; i < PascalString.length; i++) {
|
|
578
|
+
let c = PascalString.charAt(i);
|
|
579
|
+
if (isLetterAndCapital(c)) {
|
|
580
|
+
addWord();
|
|
581
|
+
}
|
|
582
|
+
word += c.toLowerCase();
|
|
583
|
+
}
|
|
584
|
+
addWord();
|
|
585
|
+
return sentence;
|
|
586
|
+
}
|
|
587
|
+
function stringify(value, maxDepth = 5, seen = /* @__PURE__ */ new WeakSet()) {
|
|
588
|
+
if (value === null) return "null";
|
|
589
|
+
if (value === void 0) return "undefined";
|
|
590
|
+
const t = typeof value;
|
|
591
|
+
switch (t) {
|
|
592
|
+
case "boolean":
|
|
593
|
+
return value ? "true" : "false";
|
|
594
|
+
case "number":
|
|
595
|
+
if (isNaNValue(value)) return "NaN";
|
|
596
|
+
if (!isFinite2(value))
|
|
597
|
+
return value < 0 ? "-Infinity" : "Infinity";
|
|
598
|
+
return value.toString();
|
|
599
|
+
case "bigint":
|
|
600
|
+
return `${value}n`;
|
|
601
|
+
case "string":
|
|
602
|
+
return `"${value}"`;
|
|
603
|
+
case "symbol":
|
|
604
|
+
return value.description ? `Symbol(${value.description})` : "Symbol()";
|
|
605
|
+
case "function":
|
|
606
|
+
return `[Function${value.name ? ` ${value.name}` : ""}]`;
|
|
607
|
+
}
|
|
608
|
+
if (seen.has(value))
|
|
609
|
+
return "[Circular]";
|
|
610
|
+
if (maxDepth <= 0)
|
|
611
|
+
return "[Depth limit]";
|
|
612
|
+
maxDepth--;
|
|
613
|
+
seen.add(value);
|
|
614
|
+
const strfy = (v) => stringify(v, maxDepth, seen);
|
|
615
|
+
if (isArray(value)) {
|
|
616
|
+
const inner = value.map((v) => strfy(v)).join(", ");
|
|
617
|
+
return inner.length === 0 ? "[ ]" : `[ ${inner} ]`;
|
|
618
|
+
}
|
|
619
|
+
if (ArrayBuffer.isView(value)) {
|
|
620
|
+
if (value instanceof DataView)
|
|
621
|
+
return `DataView(${value.byteLength})`;
|
|
622
|
+
const inner = Array.from(value).map((v) => strfy(v)).join(", ");
|
|
623
|
+
return `${value.constructor.name}[ ${inner} ]`;
|
|
624
|
+
}
|
|
625
|
+
if (value instanceof ArrayBuffer)
|
|
626
|
+
return `ArrayBuffer(${value.byteLength})`;
|
|
627
|
+
if (value instanceof Map) {
|
|
628
|
+
const entries = Array.from(value.entries()).map(([k, v]) => `${strfy(k)} => ${strfy(v)}`).join(", ");
|
|
629
|
+
return entries.length === 0 ? `Map(${value.size}){ }` : `Map(${value.size}){ ${entries} }`;
|
|
630
|
+
}
|
|
631
|
+
if (value instanceof Set) {
|
|
632
|
+
const entries = Array.from(value.values()).map((v) => strfy(v)).join(", ");
|
|
633
|
+
return entries.length === 0 ? `Set(${value.size}){ }` : `Set(${value.size}){ ${entries} }`;
|
|
634
|
+
}
|
|
635
|
+
if (value instanceof WeakMap)
|
|
636
|
+
return "WeakMap{ ? }";
|
|
637
|
+
if (value instanceof WeakSet)
|
|
638
|
+
return "WeakSet{ ? }";
|
|
639
|
+
if (value instanceof Date)
|
|
640
|
+
return `Date("${value.toISOString()}")`;
|
|
641
|
+
if (value instanceof RegExp)
|
|
642
|
+
return value.toString();
|
|
643
|
+
if (value instanceof Error)
|
|
644
|
+
return `${value.name}("${value.message}")`;
|
|
645
|
+
if (value instanceof Promise)
|
|
646
|
+
return "Promise{ ? }";
|
|
647
|
+
if (value instanceof URL)
|
|
648
|
+
return `URL("${value.href}")`;
|
|
649
|
+
if (value instanceof URLSearchParams)
|
|
650
|
+
return `URLSearchParams("${value.toString()}")`;
|
|
651
|
+
if (value === Math) return "Math";
|
|
652
|
+
if (value === JSON) return "JSON";
|
|
653
|
+
if (value === Reflect) return "Reflect";
|
|
654
|
+
if (value === Intl) return "Intl";
|
|
655
|
+
const hasCustomToString = typeof (value == null ? void 0 : value.toString) === "function" && value.toString !== Object.prototype.toString;
|
|
656
|
+
if (hasCustomToString) {
|
|
657
|
+
try {
|
|
658
|
+
const str2 = value.toString();
|
|
659
|
+
if (!/^\[object .+\]$/.test(str2)) return str2;
|
|
660
|
+
} catch (e) {
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
if (t === "object") {
|
|
664
|
+
const ctorName = getCtorName(value);
|
|
665
|
+
const entries = Object.entries(value).map(
|
|
666
|
+
([key, val]) => `${strfy(key)}: ${strfy(val)}`
|
|
667
|
+
);
|
|
668
|
+
if (entries.length === 0) return `${ctorName}{ }`;
|
|
669
|
+
return `${ctorName}{ ${entries.join(", ")} }`;
|
|
670
|
+
}
|
|
671
|
+
return String(value);
|
|
672
|
+
}
|
|
673
|
+
function splitByCaps(str2) {
|
|
674
|
+
return str2.split(/(?=[A-Z])/).filter((x) => !!x);
|
|
675
|
+
}
|
|
676
|
+
function splitByStrings(str2, ...splitters) {
|
|
677
|
+
if (splitters.length === 0) return [str2];
|
|
678
|
+
const escaped = splitters.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
|
|
679
|
+
const regex = new RegExp(escaped.join("|"), "g");
|
|
680
|
+
return str2.split(regex);
|
|
681
|
+
}
|
|
682
|
+
function splitByChars(str2, splitters) {
|
|
683
|
+
return splitByStrings(str2, ...splitters.split(""));
|
|
684
|
+
}
|
|
685
|
+
var fmt = stringify;
|
|
686
|
+
var errorConstructor = Error;
|
|
687
|
+
function setErrorClass(errorClass) {
|
|
688
|
+
errorConstructor = errorClass != null ? errorClass : Error;
|
|
689
|
+
}
|
|
690
|
+
function _fail(...msgs) {
|
|
691
|
+
let msg = msgs.join(", ");
|
|
692
|
+
throw new errorConstructor("Assertion Failed!" + (msg === "" ? "" : " " + msg));
|
|
693
|
+
}
|
|
694
|
+
function assert(condition, msg) {
|
|
695
|
+
if (!condition) {
|
|
696
|
+
_fail(msg);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
function require2(val, msg) {
|
|
700
|
+
if (val == null) {
|
|
701
|
+
_fail(`Expected ${fmt(val)} not to be nullish`, msg);
|
|
702
|
+
}
|
|
703
|
+
return val;
|
|
704
|
+
}
|
|
705
|
+
function requireDefined(val, msg) {
|
|
706
|
+
if (val === void 0) {
|
|
707
|
+
_fail(`Expected ${fmt(val)} not to be undefined`, msg);
|
|
708
|
+
}
|
|
709
|
+
return val;
|
|
710
|
+
}
|
|
711
|
+
function requireElement(index, array, msg) {
|
|
712
|
+
if (!guard_exports.isIndex(index, array))
|
|
713
|
+
_fail(`Expected ${index} to be index for array ${fmt(array)}`, msg);
|
|
714
|
+
return array[index];
|
|
715
|
+
}
|
|
716
|
+
function fail(msg) {
|
|
717
|
+
_fail(msg);
|
|
718
|
+
}
|
|
719
|
+
function isStrictEqual2(val1, val2, msg) {
|
|
720
|
+
if (!guard_exports.isStrictEqual(val1, val2))
|
|
721
|
+
_fail(`Expected ${fmt(val1)} to ne strict equal to ${val2}`, msg);
|
|
722
|
+
return val1;
|
|
723
|
+
}
|
|
724
|
+
function isDeepEqual2(val1, val2, msg) {
|
|
725
|
+
if (!guard_exports.isDeepEqual(val1, val2))
|
|
726
|
+
_fail(`Expected ${fmt(val1)} to deep equal with ${fmt(val2)}`, msg);
|
|
727
|
+
return val1;
|
|
728
|
+
}
|
|
729
|
+
function isUndefined2(val, msg) {
|
|
730
|
+
if (!guard_exports.isUndefined(val))
|
|
731
|
+
_fail(`Expected ${fmt(val)} to be undefined`, msg);
|
|
732
|
+
return val;
|
|
733
|
+
}
|
|
734
|
+
function isNull2(val, msg) {
|
|
735
|
+
if (!guard_exports.isNull(val))
|
|
736
|
+
_fail(`Expected ${fmt(val)} to be null`, msg);
|
|
737
|
+
return val;
|
|
738
|
+
}
|
|
739
|
+
function isNullish2(val, msg) {
|
|
740
|
+
if (!guard_exports.isNullish(val))
|
|
741
|
+
_fail(`Expected ${fmt(val)} to be null or undefined`, msg);
|
|
742
|
+
return val;
|
|
743
|
+
}
|
|
744
|
+
function isDefined2(val, msg) {
|
|
745
|
+
if (!guard_exports.isDefined(val)) {
|
|
746
|
+
_fail(`Expected ${fmt(val)} to be defined`, msg);
|
|
747
|
+
}
|
|
748
|
+
return val;
|
|
749
|
+
}
|
|
750
|
+
function isNonNull2(val, msg) {
|
|
751
|
+
if (!guard_exports.isNonNull(val)) {
|
|
752
|
+
_fail(`Expected ${fmt(val)} to be defined`, msg);
|
|
753
|
+
}
|
|
754
|
+
return val;
|
|
755
|
+
}
|
|
756
|
+
function isObject2(val, msg) {
|
|
757
|
+
if (!guard_exports.isObject(val))
|
|
758
|
+
_fail(`Expected ${fmt(val)} to be object`, msg);
|
|
759
|
+
return val;
|
|
760
|
+
}
|
|
761
|
+
function isEmptyObject2(val, msg) {
|
|
762
|
+
if (!guard_exports.isEmptyObject(val))
|
|
763
|
+
_fail(`Expected ${fmt(val)} to be empty object`, msg);
|
|
764
|
+
return val;
|
|
765
|
+
}
|
|
766
|
+
function isPlainObject2(val, msg) {
|
|
767
|
+
if (!guard_exports.isPlainObject(val))
|
|
768
|
+
_fail(`Expected ${fmt(val)} to be plain object`, msg);
|
|
769
|
+
return val;
|
|
770
|
+
}
|
|
771
|
+
function isObjectOrUndefined2(val, msg) {
|
|
772
|
+
if (!guard_exports.isObjectOrUndefined(val))
|
|
773
|
+
_fail(`Expected ${fmt(val)} to be object or undefined`, msg);
|
|
774
|
+
return val;
|
|
775
|
+
}
|
|
776
|
+
function isTypedObject2(val, keys, msg) {
|
|
777
|
+
if (!guard_exports.isTypedObject(val, keys))
|
|
778
|
+
_fail(`Expected ${fmt(val)} to have keys ${fmt(keys)}`, msg);
|
|
779
|
+
return val;
|
|
780
|
+
}
|
|
781
|
+
function isArray2(val, msg) {
|
|
782
|
+
if (!guard_exports.isArray(val))
|
|
783
|
+
_fail(`Expected ${fmt(val)} to be array`, msg);
|
|
784
|
+
return val;
|
|
785
|
+
}
|
|
786
|
+
function isArrayOrUndefined2(val, msg) {
|
|
787
|
+
if (!guard_exports.isArrayOrUndefined(val))
|
|
788
|
+
_fail(`Expected ${fmt(val)} to be array or undefined`, msg);
|
|
789
|
+
return true;
|
|
790
|
+
}
|
|
791
|
+
function isEmptyArray2(val, msg) {
|
|
792
|
+
if (!guard_exports.isEmptyArray(val))
|
|
793
|
+
_fail(`Expected ${fmt(val)} to be empty array`, msg);
|
|
794
|
+
}
|
|
795
|
+
function isNonEmptyArray2(val, msg) {
|
|
796
|
+
if (!guard_exports.isNonEmptyArray(val))
|
|
797
|
+
_fail(`Expected ${fmt(val)} to be non-empty array`, msg);
|
|
798
|
+
}
|
|
799
|
+
function isEmptyArrayOrUndefined2(val, msg) {
|
|
800
|
+
if (!guard_exports.isEmptyArrayOrUndefined(val))
|
|
801
|
+
_fail(`Expected ${fmt(val)} to be empty array or undefined`, msg);
|
|
802
|
+
}
|
|
803
|
+
function isNonEmptyArrayOrUndefined2(val, msg) {
|
|
804
|
+
if (!guard_exports.isNonEmptyArrayOrUndefined(val))
|
|
805
|
+
_fail(`Expected ${fmt(val)} to be non-empty array or undefined`, msg);
|
|
806
|
+
}
|
|
807
|
+
function isString2(val, msg) {
|
|
808
|
+
if (!guard_exports.isString(val))
|
|
809
|
+
_fail(`Expected ${fmt(val)} to be string`, msg);
|
|
810
|
+
return val;
|
|
811
|
+
}
|
|
812
|
+
function isEmptyString2(val, msg) {
|
|
813
|
+
if (!guard_exports.isEmptyString(val))
|
|
814
|
+
_fail(`Expected ${fmt(val)} to be empty string`, msg);
|
|
815
|
+
return val;
|
|
816
|
+
}
|
|
817
|
+
function isNonEmptyString2(val, msg) {
|
|
818
|
+
if (!guard_exports.isNonEmptyString(val))
|
|
819
|
+
_fail(`Expected ${fmt(val)} to be non-empty string`, msg);
|
|
820
|
+
return val;
|
|
821
|
+
}
|
|
822
|
+
function isStringOrUndefined2(val, msg) {
|
|
823
|
+
if (!guard_exports.isStringOrUndefined(val))
|
|
824
|
+
_fail(`Expected ${fmt(val)} to be string or undefined`, msg);
|
|
825
|
+
return val;
|
|
826
|
+
}
|
|
827
|
+
function isEmptyStringOrUndefined2(val, msg) {
|
|
828
|
+
if (!guard_exports.isEmptyStringOrUndefined(val))
|
|
829
|
+
_fail(`Expected ${fmt(val)} to be empty string or undefined`, msg);
|
|
830
|
+
return val;
|
|
831
|
+
}
|
|
832
|
+
function isNonEmptyStringOrUndefined2(val, msg) {
|
|
833
|
+
if (!guard_exports.isNonEmptyStringOrUndefined(val))
|
|
834
|
+
_fail(`Expected ${fmt(val)} to be non-empty string or undefined`, msg);
|
|
835
|
+
return val;
|
|
836
|
+
}
|
|
837
|
+
function isBoolean2(val, msg) {
|
|
838
|
+
if (!guard_exports.isBoolean(val))
|
|
839
|
+
_fail(`Expected ${fmt(val)} to be boolean`, msg);
|
|
840
|
+
return val;
|
|
841
|
+
}
|
|
842
|
+
function isBooleanOrUndefined2(val, msg) {
|
|
843
|
+
if (!guard_exports.isBooleanOrUndefined(val))
|
|
844
|
+
_fail(`Expected ${fmt(val)} to be boolean or undefined`, msg);
|
|
845
|
+
return val;
|
|
846
|
+
}
|
|
847
|
+
function isTrue2(val, msg) {
|
|
848
|
+
if (!guard_exports.isTrue(val))
|
|
849
|
+
_fail(`Expected ${fmt(val)} to be true`, msg);
|
|
850
|
+
return val;
|
|
851
|
+
}
|
|
852
|
+
function isTrueOrUndefined2(val, msg) {
|
|
853
|
+
if (!guard_exports.isTrueOrUndefined(val))
|
|
854
|
+
_fail(`Expected ${fmt(val)} to be true or undefined`, msg);
|
|
855
|
+
return val;
|
|
856
|
+
}
|
|
857
|
+
function isFalse2(val, msg) {
|
|
858
|
+
if (!guard_exports.isFalse(val))
|
|
859
|
+
_fail(`Expected ${fmt(val)} to be false`, msg);
|
|
860
|
+
return val;
|
|
861
|
+
}
|
|
862
|
+
function isFalseOrUndefined2(val, msg) {
|
|
863
|
+
if (!guard_exports.isFalseOrUndefined(val))
|
|
864
|
+
_fail(`Expected ${fmt(val)} to be false or undefined`, msg);
|
|
865
|
+
return val;
|
|
866
|
+
}
|
|
867
|
+
function isFunction2(val, msg) {
|
|
868
|
+
if (!guard_exports.isFunction(val))
|
|
869
|
+
_fail(`Expected ${fmt(val)} to be function`, msg);
|
|
870
|
+
return val;
|
|
871
|
+
}
|
|
872
|
+
function isFunctionOrUndefined2(val, msg) {
|
|
873
|
+
if (!guard_exports.isFunctionOrUndefined(val))
|
|
874
|
+
_fail(`Expected ${fmt(val)} to be function or undefined`, msg);
|
|
875
|
+
return val;
|
|
876
|
+
}
|
|
877
|
+
function isEnumValue2(val, enumObject, msg) {
|
|
878
|
+
if (!guard_exports.isEnumValue(val, enumObject))
|
|
879
|
+
_fail(`Expected ${fmt(val)} to be enum val`, msg);
|
|
880
|
+
return val;
|
|
881
|
+
}
|
|
882
|
+
function isEnumValueOrUndefined2(val, enumObject, msg) {
|
|
883
|
+
if (!guard_exports.isEnumValueOrUndefined(val, enumObject))
|
|
884
|
+
_fail(`Expected ${fmt(val)} to be enum val or undefined`, msg);
|
|
885
|
+
return val;
|
|
886
|
+
}
|
|
887
|
+
function isNumericString2(val, msg) {
|
|
888
|
+
if (!guard_exports.isNumericString(val))
|
|
889
|
+
_fail(`Expected ${fmt(val)} to be numeric string`, msg);
|
|
890
|
+
return val;
|
|
891
|
+
}
|
|
892
|
+
function isBigInt2(val, msg) {
|
|
893
|
+
if (!guard_exports.isBigInt(val))
|
|
894
|
+
_fail(`Expected ${fmt(val)} to be BigInt`, msg);
|
|
895
|
+
return val;
|
|
896
|
+
}
|
|
897
|
+
function isNumber2(val, msg) {
|
|
898
|
+
if (!guard_exports.isNumber(val))
|
|
899
|
+
_fail(`Expected ${fmt(val)} to be number`, msg);
|
|
900
|
+
return val;
|
|
901
|
+
}
|
|
902
|
+
function isSafeNumber2(val, msg) {
|
|
903
|
+
if (!guard_exports.isSafeNumber(val))
|
|
904
|
+
_fail(`Expected ${fmt(val)} to be safe number`, msg);
|
|
905
|
+
return val;
|
|
906
|
+
}
|
|
907
|
+
function isNumberOrUndefined2(val, msg) {
|
|
908
|
+
if (!guard_exports.isNumberOrUndefined(val))
|
|
909
|
+
_fail(`Expected ${fmt(val)} to be number or undefined`, msg);
|
|
910
|
+
return val;
|
|
911
|
+
}
|
|
912
|
+
function isNumberEq2(val, ref, msg) {
|
|
913
|
+
if (!guard_exports.isNumberEq(val, ref))
|
|
914
|
+
_fail(`Expected ${fmt(val)} to be number equal to ${fmt(ref)}`, msg);
|
|
915
|
+
return val;
|
|
916
|
+
}
|
|
917
|
+
function isNumberGt2(val, ref, msg) {
|
|
918
|
+
if (!guard_exports.isNumberGt(val, ref))
|
|
919
|
+
_fail(`Expected ${fmt(val)} to be number > ${fmt(ref)}`, msg);
|
|
920
|
+
return val;
|
|
921
|
+
}
|
|
922
|
+
function isNumberGte2(val, ref, msg) {
|
|
923
|
+
if (!guard_exports.isNumberGte(val, ref))
|
|
924
|
+
_fail(`Expected ${fmt(val)} to be number >= ${fmt(ref)}`, msg);
|
|
925
|
+
return val;
|
|
926
|
+
}
|
|
927
|
+
function isNumberLt2(val, ref, msg) {
|
|
928
|
+
if (!guard_exports.isNumberLt(val, ref))
|
|
929
|
+
_fail(`Expected ${fmt(val)} to be number < ${fmt(ref)}`, msg);
|
|
930
|
+
return val;
|
|
931
|
+
}
|
|
932
|
+
function isNumberLte2(val, ref, msg) {
|
|
933
|
+
if (!guard_exports.isNumberLte(val, ref))
|
|
934
|
+
_fail(`Expected ${fmt(val)} to be number <= ${fmt(ref)}`, msg);
|
|
935
|
+
return val;
|
|
936
|
+
}
|
|
937
|
+
function isNumberBetween2(val, min, max, msg) {
|
|
938
|
+
if (!guard_exports.isNumberBetween(val, min, max))
|
|
939
|
+
_fail(`Expected number ${fmt(min)} <= ${fmt(val)} <= ${fmt(max)}`, msg);
|
|
940
|
+
return val;
|
|
941
|
+
}
|
|
942
|
+
function isNumberBetweenExclusive2(val, min, max, msg) {
|
|
943
|
+
if (!guard_exports.isNumberBetweenExclusive(val, min, max))
|
|
944
|
+
_fail(`Expected number ${fmt(min)} < ${fmt(val)} < ${fmt(max)}`, msg);
|
|
945
|
+
return val;
|
|
946
|
+
}
|
|
947
|
+
function isFinite3(val, msg) {
|
|
948
|
+
if (!guard_exports.isFinite(val))
|
|
949
|
+
_fail(`Expected ${fmt(val)} to be finite`, msg);
|
|
950
|
+
return val;
|
|
951
|
+
}
|
|
952
|
+
function isFloat2(val, msg) {
|
|
953
|
+
if (!guard_exports.isFloat(val))
|
|
954
|
+
_fail(`Expected ${fmt(val)} to be float`, msg);
|
|
955
|
+
return val;
|
|
956
|
+
}
|
|
957
|
+
function isInteger2(val, msg) {
|
|
958
|
+
if (!guard_exports.isInteger(val))
|
|
959
|
+
_fail(`Expected ${fmt(val)} to be integer`, msg);
|
|
960
|
+
return val;
|
|
961
|
+
}
|
|
962
|
+
function isSafeInteger2(val, msg) {
|
|
963
|
+
if (!guard_exports.isSafeInteger(val))
|
|
964
|
+
_fail(`Expected ${fmt(val)} to be safe integer`, msg);
|
|
965
|
+
return val;
|
|
966
|
+
}
|
|
967
|
+
function isIntegerOrUndefined2(val, msg) {
|
|
968
|
+
if (!guard_exports.isIntegerOrUndefined(val))
|
|
969
|
+
_fail(`Expected ${fmt(val)} to be integer or undefined`, msg);
|
|
970
|
+
return val;
|
|
971
|
+
}
|
|
972
|
+
function isIntegerEq2(val, ref, msg) {
|
|
973
|
+
if (!guard_exports.isIntegerEq(val, ref))
|
|
974
|
+
_fail(`Expected ${fmt(val)} to be integer equal to ${fmt(ref)}`, msg);
|
|
975
|
+
return val;
|
|
976
|
+
}
|
|
977
|
+
function isIntegerGt2(val, ref, msg) {
|
|
978
|
+
if (!guard_exports.isIntegerGt(val, ref))
|
|
979
|
+
_fail(`Expected ${fmt(val)} to be integer > ${fmt(ref)}`, msg);
|
|
980
|
+
return val;
|
|
981
|
+
}
|
|
982
|
+
function isIntegerGte2(val, ref, msg) {
|
|
983
|
+
if (!guard_exports.isIntegerGte(val, ref))
|
|
984
|
+
_fail(`Expected ${fmt(val)} to be integer >= ${fmt(ref)}`, msg);
|
|
985
|
+
return val;
|
|
986
|
+
}
|
|
987
|
+
function isIntegerLt2(val, ref, msg) {
|
|
988
|
+
if (!guard_exports.isIntegerLt(val, ref))
|
|
989
|
+
_fail(`Expected ${fmt(val)} to be integer < ${fmt(ref)}`, msg);
|
|
990
|
+
return val;
|
|
991
|
+
}
|
|
992
|
+
function isIntegerLte2(val, ref, msg) {
|
|
993
|
+
if (!guard_exports.isIntegerLte(val, ref))
|
|
994
|
+
_fail(`Expected ${fmt(val)} to be integer <= ${fmt(ref)}`, msg);
|
|
995
|
+
return val;
|
|
996
|
+
}
|
|
997
|
+
function isIntegerBetween2(val, min, max, msg) {
|
|
998
|
+
if (!guard_exports.isIntegerBetween(val, min, max))
|
|
999
|
+
_fail(`Expected integer ${fmt(min)} <= ${fmt(val)} <= ${fmt(max)}`, msg);
|
|
1000
|
+
return val;
|
|
1001
|
+
}
|
|
1002
|
+
function isIntegerBetweenExclusive2(val, min, max, msg) {
|
|
1003
|
+
if (!guard_exports.isIntegerBetweenExclusive(val, min, max))
|
|
1004
|
+
_fail(`Expected integer ${fmt(min)} < ${fmt(val)} < ${fmt(max)}`, msg);
|
|
1005
|
+
return val;
|
|
1006
|
+
}
|
|
1007
|
+
function isNaNValue2(val, msg) {
|
|
1008
|
+
if (!guard_exports.isNaNValue(val))
|
|
1009
|
+
_fail(`Expected ${fmt(val)} to be NaN`, msg);
|
|
1010
|
+
return NaN;
|
|
1011
|
+
}
|
|
1012
|
+
function isInfinity2(val, msg) {
|
|
1013
|
+
if (!guard_exports.isInfinity(val))
|
|
1014
|
+
_fail(`Expected ${fmt(val)} to be +-Infinity`, msg);
|
|
1015
|
+
return val;
|
|
1016
|
+
}
|
|
1017
|
+
function isPosInfinity2(val, msg) {
|
|
1018
|
+
if (!guard_exports.isPosInfinity(val))
|
|
1019
|
+
_fail(`Expected ${fmt(val)} to be +Infinity`, msg);
|
|
1020
|
+
return val;
|
|
1021
|
+
}
|
|
1022
|
+
function isNegInfinity2(val, msg) {
|
|
1023
|
+
if (!guard_exports.isNegInfinity(val))
|
|
1024
|
+
_fail(`Expected ${fmt(val)} to be -Infinity`, msg);
|
|
1025
|
+
return val;
|
|
1026
|
+
}
|
|
1027
|
+
function isPos2(val, msg) {
|
|
1028
|
+
if (!guard_exports.isPos(val))
|
|
1029
|
+
_fail(`Expected ${fmt(val)} to be positive (> 0)`, msg);
|
|
1030
|
+
return val;
|
|
1031
|
+
}
|
|
1032
|
+
function isNeg2(val, msg) {
|
|
1033
|
+
if (!guard_exports.isNeg(val))
|
|
1034
|
+
_fail(`Expected ${fmt(val)} to be negative (< 0)`, msg);
|
|
1035
|
+
return val;
|
|
1036
|
+
}
|
|
1037
|
+
function isNonPos2(val, msg) {
|
|
1038
|
+
if (!guard_exports.isNonPos(val))
|
|
1039
|
+
_fail(`Expected ${fmt(val)} to be non-positive (<= 0)`, msg);
|
|
1040
|
+
return val;
|
|
1041
|
+
}
|
|
1042
|
+
function isNonNeg2(val, msg) {
|
|
1043
|
+
if (!guard_exports.isNonNeg(val))
|
|
1044
|
+
_fail(`Expected ${fmt(val)} to be non-negative (>= 0)`, msg);
|
|
1045
|
+
return val;
|
|
1046
|
+
}
|
|
1047
|
+
function isZero2(val, msg) {
|
|
1048
|
+
if (!guard_exports.isZero(val))
|
|
1049
|
+
_fail(`Expected ${fmt(val)} to be 0`, msg);
|
|
1050
|
+
return val;
|
|
1051
|
+
}
|
|
1052
|
+
function isPosZero2(val, msg) {
|
|
1053
|
+
if (!guard_exports.isPosZero(val))
|
|
1054
|
+
_fail(`Expected ${fmt(val)} to be +0`, msg);
|
|
1055
|
+
return val;
|
|
1056
|
+
}
|
|
1057
|
+
function isNegZero2(val, msg) {
|
|
1058
|
+
if (!guard_exports.isNegZero(val))
|
|
1059
|
+
_fail(`Expected ${fmt(val)} to be -0`, msg);
|
|
1060
|
+
return val;
|
|
1061
|
+
}
|
|
1062
|
+
function isOdd2(val, msg) {
|
|
1063
|
+
if (!guard_exports.isOdd(val))
|
|
1064
|
+
_fail(`Expected ${fmt(val)} to odd`, msg);
|
|
1065
|
+
return val;
|
|
1066
|
+
}
|
|
1067
|
+
function isEven2(val, msg) {
|
|
1068
|
+
if (!guard_exports.isEven(val))
|
|
1069
|
+
_fail(`Expected ${fmt(val)} to even`, msg);
|
|
1070
|
+
return val;
|
|
1071
|
+
}
|
|
1072
|
+
function isMultipleOf2(val, base, msg) {
|
|
1073
|
+
if (!guard_exports.isMultipleOf(val, base))
|
|
1074
|
+
_fail(`Expected ${fmt(val)} to be divisble bu ${fmt(base)}`, msg);
|
|
1075
|
+
return val;
|
|
1076
|
+
}
|
|
1077
|
+
function isPowerOfTwo2(val, msg) {
|
|
1078
|
+
if (!guard_exports.isPowerOfTwo(val))
|
|
1079
|
+
_fail(`Expected ${fmt(val)} to be power of two`, msg);
|
|
1080
|
+
return val;
|
|
1081
|
+
}
|
|
1082
|
+
function isIncluded2(val, arr, msg) {
|
|
1083
|
+
if (!guard_exports.isIncluded(val, arr))
|
|
1084
|
+
_fail(`Expected ${fmt(val)} to be included in ${fmt(arr)}`, msg);
|
|
1085
|
+
return val;
|
|
1086
|
+
}
|
|
1087
|
+
function isIndex2(...args) {
|
|
1088
|
+
const index = args.shift();
|
|
1089
|
+
const msg = guard_exports.isString(args[args.length - 1]) ? args.pop() : void 0;
|
|
1090
|
+
const arr = guard_exports.isArray(args[0]) ? args.shift() : void 0;
|
|
1091
|
+
if (!guard_exports.isIndex(index, arr)) {
|
|
1092
|
+
if (arr === void 0)
|
|
1093
|
+
_fail(`Expected ${index} to be index`, msg);
|
|
1094
|
+
else
|
|
1095
|
+
_fail(`Expected ${index} to be index for ${fmt(arr)}`, msg);
|
|
1096
|
+
}
|
|
1097
|
+
return index;
|
|
1098
|
+
}
|
|
1099
|
+
function doesThrow2(throwTestFn, msg) {
|
|
1100
|
+
if (!guard_exports.doesThrow(throwTestFn))
|
|
1101
|
+
_fail(`Expected to throw`, msg);
|
|
1102
|
+
return true;
|
|
1103
|
+
}
|
|
1104
|
+
function doesNotThrow2(throwTestFn, msg) {
|
|
1105
|
+
if (!guard_exports.doesNotThrow(throwTestFn))
|
|
1106
|
+
_fail(`Expected to throw`, msg);
|
|
1107
|
+
return true;
|
|
1108
|
+
}
|
|
1109
|
+
var cookies_exports = {};
|
|
1110
|
+
__export(cookies_exports, {
|
|
1111
|
+
accept: () => accept,
|
|
1112
|
+
decline: () => decline,
|
|
1113
|
+
erase: () => erase,
|
|
1114
|
+
eraseAll: () => eraseAll,
|
|
1115
|
+
isConsentPending: () => isConsentPending,
|
|
1116
|
+
read: () => read,
|
|
1117
|
+
readBool: () => readBool,
|
|
1118
|
+
readInt: () => readInt,
|
|
1119
|
+
save: () => save,
|
|
1120
|
+
setExpireDays: () => setExpireDays
|
|
1121
|
+
});
|
|
1122
|
+
var ConsentCookieName = "ConsentCookie";
|
|
1123
|
+
var _consent;
|
|
1124
|
+
var _expires;
|
|
1125
|
+
var str = _read(ConsentCookieName);
|
|
1126
|
+
_consent = str === "accept" || str === "decline" ? str : void 0;
|
|
1127
|
+
function _getCookieList() {
|
|
1128
|
+
if (typeof document === "undefined")
|
|
1129
|
+
return [];
|
|
1130
|
+
let s = document.cookie;
|
|
1131
|
+
return s.split(";").map((c) => c.trim());
|
|
1132
|
+
}
|
|
1133
|
+
function _save(name, value) {
|
|
1134
|
+
let cookie = name + "=" + value.toString() + ";sameSite=Lax;";
|
|
1135
|
+
if (_expires) {
|
|
1136
|
+
cookie += "expires=" + _expires.toUTCString() + ";";
|
|
1137
|
+
}
|
|
1138
|
+
if (typeof document !== "undefined")
|
|
1139
|
+
document.cookie = cookie;
|
|
1140
|
+
return value;
|
|
1141
|
+
}
|
|
1142
|
+
function _read(name, defaultValue) {
|
|
1143
|
+
let str2 = _getCookieList().find((c) => c.startsWith(name + "="));
|
|
1144
|
+
return str2 === void 0 ? defaultValue : str2.substring(name.length + 1);
|
|
1145
|
+
}
|
|
1146
|
+
function _erase(name) {
|
|
1147
|
+
if (typeof document !== "undefined")
|
|
1148
|
+
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;";
|
|
1149
|
+
}
|
|
1150
|
+
function setExpireDays(days) {
|
|
1151
|
+
_expires = /* @__PURE__ */ new Date();
|
|
1152
|
+
_expires.setDate(_expires.getDate() + days);
|
|
1153
|
+
}
|
|
1154
|
+
function isConsentPending() {
|
|
1155
|
+
return _consent === void 0;
|
|
1156
|
+
}
|
|
1157
|
+
function accept() {
|
|
1158
|
+
_consent = "accept";
|
|
1159
|
+
_save(ConsentCookieName, _consent);
|
|
1160
|
+
}
|
|
1161
|
+
function decline() {
|
|
1162
|
+
_consent = "decline";
|
|
1163
|
+
_save(ConsentCookieName, _consent);
|
|
1164
|
+
}
|
|
1165
|
+
function save(name, value) {
|
|
1166
|
+
if (_consent === "accept")
|
|
1167
|
+
_save(name, value);
|
|
1168
|
+
return value;
|
|
1169
|
+
}
|
|
1170
|
+
function read(name, defaultValue) {
|
|
1171
|
+
var _a;
|
|
1172
|
+
if (_consent === "accept")
|
|
1173
|
+
return (_a = _read(name, defaultValue)) != null ? _a : defaultValue;
|
|
1174
|
+
else
|
|
1175
|
+
return defaultValue;
|
|
1176
|
+
}
|
|
1177
|
+
function readInt(name, defaultValue) {
|
|
1178
|
+
if (_consent === "accept") {
|
|
1179
|
+
let str2 = _read(name);
|
|
1180
|
+
return str2 === void 0 ? defaultValue : parseInt(str2);
|
|
1181
|
+
} else {
|
|
1182
|
+
return defaultValue;
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
function readBool(name, defaultValue) {
|
|
1186
|
+
if (_consent === "accept") {
|
|
1187
|
+
let str2 = _read(name);
|
|
1188
|
+
return str2 === void 0 ? defaultValue : /true|1/i.test(str2);
|
|
1189
|
+
} else {
|
|
1190
|
+
return defaultValue;
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
function erase(name) {
|
|
1194
|
+
if (_consent === "accept" || name === ConsentCookieName)
|
|
1195
|
+
_erase(name);
|
|
1196
|
+
}
|
|
1197
|
+
function eraseAll() {
|
|
1198
|
+
if (typeof document !== "undefined")
|
|
1199
|
+
document.cookie.split(";").forEach((c) => erase(c.trim().split("=")[0]));
|
|
1200
|
+
}
|
|
1201
|
+
var device_exports = {};
|
|
1202
|
+
__export(device_exports, {
|
|
1203
|
+
DPI: () => DPI,
|
|
1204
|
+
FontSize: () => FontSize,
|
|
1205
|
+
HostAddress: () => HostAddress,
|
|
1206
|
+
IsMobileDevice: () => IsMobileDevice,
|
|
1207
|
+
IsTouchDevice: () => IsTouchDevice,
|
|
1208
|
+
PxPerMm: () => PxPerMm,
|
|
1209
|
+
ScrollbarWidth: () => ScrollbarWidth,
|
|
1210
|
+
mmToPx: () => mmToPx,
|
|
1211
|
+
pxToMm: () => pxToMm,
|
|
1212
|
+
toPx: () => toPx
|
|
1213
|
+
});
|
|
1214
|
+
function getDPI() {
|
|
1215
|
+
try {
|
|
1216
|
+
let el = document.createElement("div");
|
|
1217
|
+
el.style.width = "1in";
|
|
1218
|
+
document.body.appendChild(el);
|
|
1219
|
+
let dpi = el.offsetWidth;
|
|
1220
|
+
el.remove();
|
|
1221
|
+
return dpi || 96;
|
|
1222
|
+
} catch (e) {
|
|
1223
|
+
return 96;
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
function getScrollBarWidth() {
|
|
1227
|
+
try {
|
|
1228
|
+
let outer = document.createElement("div");
|
|
1229
|
+
outer.style.visibility = "hidden";
|
|
1230
|
+
outer.style.width = "100px";
|
|
1231
|
+
document.body.appendChild(outer);
|
|
1232
|
+
let widthNoScroll = outer.offsetWidth;
|
|
1233
|
+
outer.style.overflow = "scroll";
|
|
1234
|
+
let inner = document.createElement("div");
|
|
1235
|
+
inner.style.width = "100%";
|
|
1236
|
+
outer.appendChild(inner);
|
|
1237
|
+
let widthWithScroll = inner.offsetWidth;
|
|
1238
|
+
if (outer.parentNode) {
|
|
1239
|
+
outer.parentNode.removeChild(outer);
|
|
1240
|
+
}
|
|
1241
|
+
return widthNoScroll - widthWithScroll;
|
|
1242
|
+
} catch (e) {
|
|
1243
|
+
return 0;
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
function getSystemFontSize() {
|
|
1247
|
+
try {
|
|
1248
|
+
let tmpDiv = document.createElement("div");
|
|
1249
|
+
tmpDiv.style.cssText = "display:inline-block; padding:0; line-height:1; position:absolute; visibility:hidden; font-size:1em";
|
|
1250
|
+
tmpDiv.appendChild(document.createTextNode("M"));
|
|
1251
|
+
document.body.appendChild(tmpDiv);
|
|
1252
|
+
let fontsize = tmpDiv.offsetHeight;
|
|
1253
|
+
document.body.removeChild(tmpDiv);
|
|
1254
|
+
return fontsize;
|
|
1255
|
+
} catch (e) {
|
|
1256
|
+
return 16;
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
function getIsTouchDevice() {
|
|
1260
|
+
if (typeof window === "undefined")
|
|
1261
|
+
return false;
|
|
1262
|
+
if ("ontouchstart" in window || "DocumentTouch" in window || "createTouch" in document && "createTouchList" in document)
|
|
1263
|
+
return true;
|
|
1264
|
+
var prefixes = " -webkit- -moz- -o- -ms- ".split(" ");
|
|
1265
|
+
var mq = function(query2) {
|
|
1266
|
+
return window.matchMedia(query2).matches;
|
|
1267
|
+
};
|
|
1268
|
+
var query = ["(", prefixes.join("touch-enabled),("), "heartz", ")"].join("");
|
|
1269
|
+
return mq(query);
|
|
1270
|
+
}
|
|
1271
|
+
function getIsMobileDevice() {
|
|
1272
|
+
let a = navigator.userAgent || navigator.vendor || window.opera;
|
|
1273
|
+
return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4));
|
|
1274
|
+
}
|
|
1275
|
+
function getHostAddress() {
|
|
1276
|
+
if (typeof location === "undefined" || !location.host) {
|
|
1277
|
+
return "localhost";
|
|
1278
|
+
}
|
|
1279
|
+
return `${location.protocol}//${location.host}`;
|
|
1280
|
+
}
|
|
1281
|
+
var UnitRegExp = /^(mm|cm|in|inch|px|em)$/;
|
|
1282
|
+
var ValueUnitRegExp = /^([0-9\\.]+)(.*)$/;
|
|
1283
|
+
var DPI = getDPI();
|
|
1284
|
+
var PxPerMm = DPI / 25.4;
|
|
1285
|
+
var ScrollbarWidth = getScrollBarWidth();
|
|
1286
|
+
var FontSize = getSystemFontSize();
|
|
1287
|
+
var IsTouchDevice = getIsTouchDevice();
|
|
1288
|
+
var IsMobileDevice = getIsMobileDevice();
|
|
1289
|
+
var HostAddress = getHostAddress();
|
|
1290
|
+
function pxToMm(px) {
|
|
1291
|
+
return px / PxPerMm;
|
|
1292
|
+
}
|
|
1293
|
+
function mmToPx(mm) {
|
|
1294
|
+
return mm * PxPerMm;
|
|
1295
|
+
}
|
|
1296
|
+
function toPx(input) {
|
|
1297
|
+
if (typeof input === "number") {
|
|
1298
|
+
return input;
|
|
1299
|
+
}
|
|
1300
|
+
let value = NaN;
|
|
1301
|
+
let unit = void 0;
|
|
1302
|
+
let match = input.toString().match(ValueUnitRegExp);
|
|
1303
|
+
if (match && match[1]) {
|
|
1304
|
+
value = parseFloat(match[1]);
|
|
1305
|
+
let unitStr = match[2] ? match[2].toLowerCase() : "undefined";
|
|
1306
|
+
let unitStrOk = UnitRegExp.test(unitStr);
|
|
1307
|
+
unit = unitStrOk ? unitStr : void 0;
|
|
1308
|
+
if (!unit) {
|
|
1309
|
+
console.log("Unknown unit '" + unitStr + "' => using 'px'.");
|
|
1310
|
+
}
|
|
1311
|
+
} else {
|
|
1312
|
+
value = parseFloat(input);
|
|
1313
|
+
}
|
|
1314
|
+
assert_exports.isFinite(value, "value in function toPx");
|
|
1315
|
+
switch (unit) {
|
|
1316
|
+
case "mm":
|
|
1317
|
+
return mmToPx(value);
|
|
1318
|
+
case "cm":
|
|
1319
|
+
return mmToPx(value) * 10;
|
|
1320
|
+
case "in":
|
|
1321
|
+
case "inch":
|
|
1322
|
+
return mmToPx(value) * 25.4;
|
|
1323
|
+
case "em":
|
|
1324
|
+
return FontSize * value;
|
|
1325
|
+
default:
|
|
1326
|
+
case "px":
|
|
1327
|
+
return value;
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
var utils_exports = {};
|
|
1331
|
+
__export(utils_exports, {
|
|
1332
|
+
Arr: () => arr_exports,
|
|
1333
|
+
Dom: () => dom_exports,
|
|
1334
|
+
Enum: () => enum_exports,
|
|
1335
|
+
Math: () => math_exports,
|
|
1336
|
+
Obj: () => obj_exports,
|
|
1337
|
+
Str: () => str_exports
|
|
1338
|
+
});
|
|
1339
|
+
var arr_exports = {};
|
|
1340
|
+
__export(arr_exports, {
|
|
1341
|
+
arrayContains: () => arrayContains,
|
|
1342
|
+
chunckArray: () => chunckArray,
|
|
1343
|
+
duplicate: () => duplicate,
|
|
1344
|
+
fillArray: () => fillArray,
|
|
1345
|
+
getRangeArray: () => getRangeArray,
|
|
1346
|
+
getSequenceArray: () => getSequenceArray,
|
|
1347
|
+
isArray: () => isArray,
|
|
1348
|
+
mapRangeArray: () => mapRangeArray,
|
|
1349
|
+
mapSequenceArray: () => mapSequenceArray,
|
|
1350
|
+
removeDuplicates: () => removeDuplicates,
|
|
1351
|
+
toArray: () => toArray
|
|
1352
|
+
});
|
|
1353
|
+
function toArray(a) {
|
|
1354
|
+
return isArray(a) ? a : [a];
|
|
1355
|
+
}
|
|
1356
|
+
function duplicate(a) {
|
|
1357
|
+
var _a;
|
|
1358
|
+
return (_a = a == null ? void 0 : a.slice()) != null ? _a : [];
|
|
1359
|
+
}
|
|
1360
|
+
function removeDuplicates(arr, compareFn) {
|
|
1361
|
+
return compareFn !== void 0 ? arr.filter((a, id, self) => id === self.findIndex((b) => compareFn(a, b))) : arr.filter((a, id, self) => id === self.indexOf(a));
|
|
1362
|
+
}
|
|
1363
|
+
function fillArray(fillValue, fillCount) {
|
|
1364
|
+
if (!isInteger(fillCount) || fillCount < 0) {
|
|
1365
|
+
throw new Error("fillArray: Invalid fillCount = " + fillCount);
|
|
1366
|
+
}
|
|
1367
|
+
return new Array(fillCount).fill(fillValue);
|
|
1368
|
+
}
|
|
1369
|
+
function mapSequenceArray(len, fn) {
|
|
1370
|
+
if (!isInteger(len) || len < 0) {
|
|
1371
|
+
throw new Error("mapSequenceArray: Invalid len = " + len);
|
|
1372
|
+
}
|
|
1373
|
+
let arr = new Array(len);
|
|
1374
|
+
for (let i = 0; i < len; i++) {
|
|
1375
|
+
arr[i] = fn(i);
|
|
1376
|
+
}
|
|
1377
|
+
return arr;
|
|
1378
|
+
}
|
|
1379
|
+
function getSequenceArray(len) {
|
|
1380
|
+
return mapSequenceArray(len, (i) => i);
|
|
1381
|
+
}
|
|
1382
|
+
function mapRangeArray(start, end, fn) {
|
|
1383
|
+
if (!isInteger(start)) {
|
|
1384
|
+
throw new Error("mapRangeArray: Invalid start = " + end);
|
|
1385
|
+
}
|
|
1386
|
+
if (!isInteger(end)) {
|
|
1387
|
+
throw new Error("mapRangeArray: Invalid end = " + end);
|
|
1388
|
+
}
|
|
1389
|
+
let len = Math.abs(end - start) + 1;
|
|
1390
|
+
let arr = new Array(len);
|
|
1391
|
+
for (let i = 0, s = start, inc = Math.sign(end - start); i < len; s += inc, i++) {
|
|
1392
|
+
arr[i] = fn(s);
|
|
1393
|
+
}
|
|
1394
|
+
return arr;
|
|
1395
|
+
}
|
|
1396
|
+
function getRangeArray(start, end) {
|
|
1397
|
+
return mapRangeArray(start, end, (i) => i);
|
|
1398
|
+
}
|
|
1399
|
+
function arrayContains(arg, item) {
|
|
1400
|
+
return arg.indexOf(item) >= 0;
|
|
1401
|
+
}
|
|
1402
|
+
function chunckArray(arr, chunckSize) {
|
|
1403
|
+
if (!isInteger(chunckSize) || chunckSize < 1) {
|
|
1404
|
+
throw new Error("chunckArray: Invalid chunckSize = " + chunckSize);
|
|
1405
|
+
}
|
|
1406
|
+
let result = [];
|
|
1407
|
+
for (let i = 0; i < arr.length; i += chunckSize) {
|
|
1408
|
+
result.push(arr.slice(i, i + chunckSize));
|
|
1409
|
+
}
|
|
1410
|
+
return result;
|
|
1411
|
+
}
|
|
1412
|
+
var dom_exports = {};
|
|
1413
|
+
__export(dom_exports, {
|
|
1414
|
+
addClass: () => addClass,
|
|
1415
|
+
appendTo: () => appendTo,
|
|
1416
|
+
getButton: () => getButton,
|
|
1417
|
+
getCanvas: () => getCanvas,
|
|
1418
|
+
getCanvasTextWidth: () => getCanvasTextWidth,
|
|
1419
|
+
getDimension: () => getDimension,
|
|
1420
|
+
getHeight: () => getHeight,
|
|
1421
|
+
getOffset: () => getOffset,
|
|
1422
|
+
getPadding: () => getPadding,
|
|
1423
|
+
getWidth: () => getWidth,
|
|
1424
|
+
hasClass: () => hasClass,
|
|
1425
|
+
removeClass: () => removeClass,
|
|
1426
|
+
removeFromParent: () => removeFromParent,
|
|
1427
|
+
setHeight: () => setHeight,
|
|
1428
|
+
setOffset: () => setOffset,
|
|
1429
|
+
setRect: () => setRect,
|
|
1430
|
+
setVisibility: () => setVisibility,
|
|
1431
|
+
setWidth: () => setWidth,
|
|
1432
|
+
styleLayoutChanged: () => styleLayoutChanged
|
|
1433
|
+
});
|
|
1434
|
+
function _getElemById(id) {
|
|
1435
|
+
var _a;
|
|
1436
|
+
return typeof document === "undefined" ? void 0 : (_a = document.getElementById(id)) != null ? _a : void 0;
|
|
1437
|
+
}
|
|
1438
|
+
function toPx2(value) {
|
|
1439
|
+
return value === void 0 ? void 0 : device_exports.toPx(value);
|
|
1440
|
+
}
|
|
1441
|
+
function hasClass(el, className) {
|
|
1442
|
+
if (className.length === 0) {
|
|
1443
|
+
return false;
|
|
1444
|
+
} else if (el.classList) {
|
|
1445
|
+
return el.classList.contains(className);
|
|
1446
|
+
} else {
|
|
1447
|
+
return !!el.className.match(new RegExp("(\\s|^)" + className + "(\\s|$)"));
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
function addClass(el, className) {
|
|
1451
|
+
if (className.length === 0) {
|
|
1452
|
+
return;
|
|
1453
|
+
} else if (el.classList) {
|
|
1454
|
+
el.classList.add(className);
|
|
1455
|
+
} else if (!hasClass(el, className)) {
|
|
1456
|
+
el.className += " " + className;
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
function removeClass(el, className) {
|
|
1460
|
+
if (className.length === 0) {
|
|
1461
|
+
return;
|
|
1462
|
+
} else if (el.classList) {
|
|
1463
|
+
el.classList.remove(className);
|
|
1464
|
+
} else if (hasClass(el, className)) {
|
|
1465
|
+
var reg = new RegExp("(\\s|^)" + className + "(\\s|$)");
|
|
1466
|
+
el.className = el.className.replace(reg, " ");
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
function setOffset(el, left, top, unit = "px") {
|
|
1470
|
+
el.style.left = left + unit;
|
|
1471
|
+
el.style.top = top + unit;
|
|
1472
|
+
}
|
|
1473
|
+
function getOffset(el) {
|
|
1474
|
+
let { left, top } = el.getBoundingClientRect();
|
|
1475
|
+
if (typeof window !== "undefined") {
|
|
1476
|
+
left += window.pageXOffset;
|
|
1477
|
+
top += window.pageYOffset;
|
|
1478
|
+
}
|
|
1479
|
+
if (typeof document !== "undefined") {
|
|
1480
|
+
let de = document.documentElement;
|
|
1481
|
+
left -= de.clientLeft;
|
|
1482
|
+
top -= de.clientTop;
|
|
1483
|
+
}
|
|
1484
|
+
return { left, top };
|
|
1485
|
+
}
|
|
1486
|
+
function getWidth(el) {
|
|
1487
|
+
if (el instanceof Window) {
|
|
1488
|
+
return el.innerWidth;
|
|
1489
|
+
} else {
|
|
1490
|
+
let w = parseFloat(getComputedStyle(el, null).width.replace("px", ""));
|
|
1491
|
+
return isNaN(w) ? 0 : w;
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
function setWidth(el, val) {
|
|
1495
|
+
el.style.width = val + "px";
|
|
1496
|
+
}
|
|
1497
|
+
function getHeight(el) {
|
|
1498
|
+
if (el instanceof Window) {
|
|
1499
|
+
return el.innerHeight;
|
|
1500
|
+
} else {
|
|
1501
|
+
let h = parseFloat(getComputedStyle(el, null).height.replace("px", ""));
|
|
1502
|
+
return isNaN(h) ? 0 : h;
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
function setHeight(el, val) {
|
|
1506
|
+
el.style.height = val + "px";
|
|
1507
|
+
}
|
|
1508
|
+
function appendTo(el, to) {
|
|
1509
|
+
to.appendChild(el);
|
|
1510
|
+
}
|
|
1511
|
+
function removeFromParent(el) {
|
|
1512
|
+
el.remove();
|
|
1513
|
+
}
|
|
1514
|
+
function setVisibility(el, visible) {
|
|
1515
|
+
el.style.display = visible ? "block" : "none";
|
|
1516
|
+
}
|
|
1517
|
+
function setRect(el, left, top, width, height, unit = "px") {
|
|
1518
|
+
el.style.left = left + unit;
|
|
1519
|
+
el.style.top = top + unit;
|
|
1520
|
+
el.style.width = width + unit;
|
|
1521
|
+
el.style.height = height + unit;
|
|
1522
|
+
}
|
|
1523
|
+
function getButton(btn) {
|
|
1524
|
+
let el = typeof btn === "string" ? _getElemById(btn) : btn;
|
|
1525
|
+
return el instanceof HTMLButtonElement ? el : void 0;
|
|
1526
|
+
}
|
|
1527
|
+
function getCanvas(canvas2) {
|
|
1528
|
+
let el = typeof canvas2 === "string" ? _getElemById(canvas2) : canvas2;
|
|
1529
|
+
return el instanceof HTMLCanvasElement ? el : void 0;
|
|
1530
|
+
}
|
|
1531
|
+
function getPadding(style) {
|
|
1532
|
+
var _a;
|
|
1533
|
+
if (!style) {
|
|
1534
|
+
return { top: 0, right: 0, bottom: 0, left: 0 };
|
|
1535
|
+
}
|
|
1536
|
+
let top = toPx2(style.paddingTop);
|
|
1537
|
+
let right = toPx2(style.paddingRight);
|
|
1538
|
+
let bottom = toPx2(style.paddingBottom);
|
|
1539
|
+
let left = toPx2(style.paddingLeft);
|
|
1540
|
+
let padding = ((_a = style.padding) != null ? _a : "").toString().split(" ").filter((s) => s.length > 0);
|
|
1541
|
+
switch (padding.length) {
|
|
1542
|
+
case 0:
|
|
1543
|
+
break;
|
|
1544
|
+
case 1:
|
|
1545
|
+
top != null ? top : top = toPx2(padding[0]);
|
|
1546
|
+
right != null ? right : right = toPx2(padding[0]);
|
|
1547
|
+
bottom != null ? bottom : bottom = toPx2(padding[0]);
|
|
1548
|
+
left != null ? left : left = toPx2(padding[0]);
|
|
1549
|
+
break;
|
|
1550
|
+
case 2:
|
|
1551
|
+
top != null ? top : top = toPx2(padding[0]);
|
|
1552
|
+
right != null ? right : right = toPx2(padding[1]);
|
|
1553
|
+
bottom != null ? bottom : bottom = toPx2(padding[0]);
|
|
1554
|
+
left != null ? left : left = toPx2(padding[1]);
|
|
1555
|
+
break;
|
|
1556
|
+
case 3:
|
|
1557
|
+
top != null ? top : top = toPx2(padding[0]);
|
|
1558
|
+
right != null ? right : right = toPx2(padding[1]);
|
|
1559
|
+
bottom != null ? bottom : bottom = toPx2(padding[2]);
|
|
1560
|
+
left != null ? left : left = toPx2(padding[1]);
|
|
1561
|
+
break;
|
|
1562
|
+
case 4:
|
|
1563
|
+
default:
|
|
1564
|
+
top != null ? top : top = toPx2(padding[0]);
|
|
1565
|
+
right != null ? right : right = toPx2(padding[1]);
|
|
1566
|
+
bottom != null ? bottom : bottom = toPx2(padding[2]);
|
|
1567
|
+
left != null ? left : left = toPx2(padding[3]);
|
|
1568
|
+
break;
|
|
1569
|
+
}
|
|
1570
|
+
top != null ? top : top = 0;
|
|
1571
|
+
right != null ? right : right = 0;
|
|
1572
|
+
bottom != null ? bottom : bottom = 0;
|
|
1573
|
+
left != null ? left : left = 0;
|
|
1574
|
+
return { top, right, bottom, left };
|
|
1575
|
+
}
|
|
1576
|
+
function getDimension(style) {
|
|
1577
|
+
let left = toPx2(style == null ? void 0 : style.left);
|
|
1578
|
+
let right = toPx2(style == null ? void 0 : style.right);
|
|
1579
|
+
let top = toPx2(style == null ? void 0 : style.top);
|
|
1580
|
+
let bottom = toPx2(style == null ? void 0 : style.bottom);
|
|
1581
|
+
let width = toPx2(style == null ? void 0 : style.width);
|
|
1582
|
+
let height = toPx2(style == null ? void 0 : style.height);
|
|
1583
|
+
if (width === void 0 && left !== void 0 && right !== void 0) {
|
|
1584
|
+
width = right - left;
|
|
1585
|
+
}
|
|
1586
|
+
if (height === void 0 && top !== void 0 && bottom !== void 0) {
|
|
1587
|
+
height = bottom - top;
|
|
1588
|
+
}
|
|
1589
|
+
return { left, top, width, height };
|
|
1590
|
+
}
|
|
1591
|
+
function styleLayoutChanged(style1, style2) {
|
|
1592
|
+
if (!style1 && !style2) {
|
|
1593
|
+
return false;
|
|
1594
|
+
} else if (!style1 || !style2) {
|
|
1595
|
+
return true;
|
|
1596
|
+
} else {
|
|
1597
|
+
return style1.left !== style2.left || style1.top !== style2.top || style1.right !== style2.right || style1.bottom !== style2.bottom || style1.width !== style2.width || style1.height !== style2.height;
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
var canvas;
|
|
1601
|
+
function getCanvasTextWidth(text, font) {
|
|
1602
|
+
if (!canvas && typeof document !== "undefined")
|
|
1603
|
+
canvas = document.createElement("canvas");
|
|
1604
|
+
let ctx = canvas == null ? void 0 : canvas.getContext("2d");
|
|
1605
|
+
if (!ctx)
|
|
1606
|
+
return 0;
|
|
1607
|
+
ctx.font = font;
|
|
1608
|
+
return ctx.measureText(text).width;
|
|
1609
|
+
}
|
|
1610
|
+
var math_exports = {};
|
|
1611
|
+
__export(math_exports, {
|
|
1612
|
+
avg: () => avg,
|
|
1613
|
+
calcNormal: () => calcNormal,
|
|
1614
|
+
clamp: () => clamp,
|
|
1615
|
+
cmp: () => cmp,
|
|
1616
|
+
interpolateCoord: () => interpolateCoord,
|
|
1617
|
+
interpolateY: () => interpolateY,
|
|
1618
|
+
isInteger: () => isInteger,
|
|
1619
|
+
isNumber: () => isNumber,
|
|
1620
|
+
linearToDecibels: () => linearToDecibels,
|
|
1621
|
+
mod: () => mod,
|
|
1622
|
+
romanize: () => romanize,
|
|
1623
|
+
sum: () => sum,
|
|
1624
|
+
toOrdinalNumber: () => toOrdinalNumber
|
|
1625
|
+
});
|
|
1626
|
+
function linearToDecibels(linearVolume) {
|
|
1627
|
+
if (!isFinite(linearVolume)) {
|
|
1628
|
+
throw new Error("linearToDecibel: Invalid linearVolume = " + linearVolume);
|
|
1629
|
+
} else if (linearVolume <= 0) {
|
|
1630
|
+
return -Infinity;
|
|
1631
|
+
} else {
|
|
1632
|
+
return 20 * Math.log10(linearVolume);
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
function mod(m, n) {
|
|
1636
|
+
return (m % n + n) % n;
|
|
1637
|
+
}
|
|
1638
|
+
function romanize(n) {
|
|
1639
|
+
if (!isInteger(n) || n < 0) {
|
|
1640
|
+
throw new Error("romanize: Invalid n = " + n);
|
|
1641
|
+
}
|
|
1642
|
+
var digits = String(+n).split("");
|
|
1643
|
+
var key = [
|
|
1644
|
+
"",
|
|
1645
|
+
"C",
|
|
1646
|
+
"CC",
|
|
1647
|
+
"CCC",
|
|
1648
|
+
"CD",
|
|
1649
|
+
"D",
|
|
1650
|
+
"DC",
|
|
1651
|
+
"DCC",
|
|
1652
|
+
"DCCC",
|
|
1653
|
+
"CM",
|
|
1654
|
+
"",
|
|
1655
|
+
"X",
|
|
1656
|
+
"XX",
|
|
1657
|
+
"XXX",
|
|
1658
|
+
"XL",
|
|
1659
|
+
"L",
|
|
1660
|
+
"LX",
|
|
1661
|
+
"LXX",
|
|
1662
|
+
"LXXX",
|
|
1663
|
+
"XC",
|
|
1664
|
+
"",
|
|
1665
|
+
"I",
|
|
1666
|
+
"II",
|
|
1667
|
+
"III",
|
|
1668
|
+
"IV",
|
|
1669
|
+
"V",
|
|
1670
|
+
"VI",
|
|
1671
|
+
"VII",
|
|
1672
|
+
"VIII",
|
|
1673
|
+
"IX"
|
|
1674
|
+
];
|
|
1675
|
+
var roman = "", i = 3;
|
|
1676
|
+
while (i--) roman = (key[+digits.pop() + i * 10] || "") + roman;
|
|
1677
|
+
return Array(+digits.join("") + 1).join("M") + roman;
|
|
1678
|
+
}
|
|
1679
|
+
function toOrdinalNumber(n) {
|
|
1680
|
+
if (!isInteger(n)) {
|
|
1681
|
+
throw new Error("toOrdinalNumber: Invalid n = " + n);
|
|
1682
|
+
}
|
|
1683
|
+
const nStr = n.toString();
|
|
1684
|
+
const lastDigit = Number(nStr.charAt(nStr.length - 1));
|
|
1685
|
+
if (n === 1 || n >= 20 && lastDigit === 1) {
|
|
1686
|
+
return nStr + "st";
|
|
1687
|
+
} else if (n === 2 || n >= 20 && lastDigit === 2) {
|
|
1688
|
+
return nStr + "nd";
|
|
1689
|
+
} else if (n === 3 || n >= 20 && lastDigit === 3) {
|
|
1690
|
+
return nStr + "rd";
|
|
1691
|
+
} else {
|
|
1692
|
+
return nStr + "th";
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
function interpolateCoord(startX, startY, endX, endY, t) {
|
|
1696
|
+
return {
|
|
1697
|
+
x: startX + (endX - startX) * t,
|
|
1698
|
+
y: startY + (endY - startY) * t
|
|
1699
|
+
};
|
|
1700
|
+
}
|
|
1701
|
+
function interpolateY(startX, startY, endX, endY, x) {
|
|
1702
|
+
let t = (x - startX) / (endX - startX);
|
|
1703
|
+
return startY + (endY - startY) * t;
|
|
1704
|
+
}
|
|
1705
|
+
function clamp(num, min, max) {
|
|
1706
|
+
return Math.min(Math.max(num, min), max);
|
|
1707
|
+
}
|
|
1708
|
+
function calcNormal(x1, y1, x2, y2) {
|
|
1709
|
+
let dx = x2 - x1;
|
|
1710
|
+
let dy = y2 - y1;
|
|
1711
|
+
let nx = -dy;
|
|
1712
|
+
let ny = dx;
|
|
1713
|
+
let len = Math.sqrt(nx * nx + ny * ny);
|
|
1714
|
+
if (len > 0) {
|
|
1715
|
+
nx /= len;
|
|
1716
|
+
ny /= len;
|
|
1717
|
+
} else {
|
|
1718
|
+
nx = 0;
|
|
1719
|
+
ny = 1;
|
|
1720
|
+
}
|
|
1721
|
+
return { nx, ny };
|
|
1722
|
+
}
|
|
1723
|
+
function sum(arr) {
|
|
1724
|
+
return arr.reduce((prev, cur) => cur + prev, 0);
|
|
1725
|
+
}
|
|
1726
|
+
function avg(...values) {
|
|
1727
|
+
return sum(values) / values.length;
|
|
1728
|
+
}
|
|
1729
|
+
function cmp(a, b) {
|
|
1730
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
1731
|
+
}
|
|
1732
|
+
var DefaultEqualityFn = (a, b) => a === b;
|
|
1733
|
+
var BaseContainer = class {
|
|
1734
|
+
};
|
|
1735
|
+
var Vec = class _Vec extends BaseContainer {
|
|
1736
|
+
constructor(...coords) {
|
|
1737
|
+
super();
|
|
1738
|
+
__publicField(this, "coords");
|
|
1739
|
+
if (coords.length < 2) {
|
|
1740
|
+
throw new TypeError("Vec needs minumum two coords!");
|
|
1741
|
+
}
|
|
1742
|
+
this.coords = coords;
|
|
1743
|
+
}
|
|
1744
|
+
static vec2(x, y) {
|
|
1745
|
+
return new _Vec(x, y);
|
|
1746
|
+
}
|
|
1747
|
+
static vec3(x, y, z) {
|
|
1748
|
+
return new _Vec(x, y, z);
|
|
1749
|
+
}
|
|
1750
|
+
static zero(dim) {
|
|
1751
|
+
if (dim < 2) {
|
|
1752
|
+
throw new TypeError("Vec.zero requires dimension >= 2");
|
|
1753
|
+
}
|
|
1754
|
+
return new _Vec(...Array(dim).fill(0));
|
|
1755
|
+
}
|
|
1756
|
+
get dim() {
|
|
1757
|
+
return this.coords.length;
|
|
1758
|
+
}
|
|
1759
|
+
get length() {
|
|
1760
|
+
return Math.hypot(...this.coords);
|
|
1761
|
+
}
|
|
1762
|
+
magnitude() {
|
|
1763
|
+
return this.length;
|
|
1764
|
+
}
|
|
1765
|
+
get x() {
|
|
1766
|
+
return this.coords[0];
|
|
1767
|
+
}
|
|
1768
|
+
get y() {
|
|
1769
|
+
return this.coords[1];
|
|
1770
|
+
}
|
|
1771
|
+
get z() {
|
|
1772
|
+
if (this.coords[2] === void 0) {
|
|
1773
|
+
throw new TypeError("Vec z-coord not available!");
|
|
1774
|
+
}
|
|
1775
|
+
return this.coords[2];
|
|
1776
|
+
}
|
|
1777
|
+
add(...args) {
|
|
1778
|
+
const otherCoords = args[0] instanceof _Vec ? args[0].coords : args;
|
|
1779
|
+
if (this.coords.length !== otherCoords.length) {
|
|
1780
|
+
throw new TypeError("Coordinate length mismatch!");
|
|
1781
|
+
}
|
|
1782
|
+
return new _Vec(...this.coords.map((coord, i) => coord + otherCoords[i]));
|
|
1783
|
+
}
|
|
1784
|
+
sub(...args) {
|
|
1785
|
+
const otherCoords = args[0] instanceof _Vec ? args[0].coords : args;
|
|
1786
|
+
if (this.coords.length !== otherCoords.length) {
|
|
1787
|
+
throw new TypeError("Coordinate length mismatch!");
|
|
1788
|
+
}
|
|
1789
|
+
return new _Vec(...this.coords.map((coord, i) => coord - otherCoords[i]));
|
|
1790
|
+
}
|
|
1791
|
+
mul(scalar) {
|
|
1792
|
+
return new _Vec(...this.coords.map((coord) => coord * scalar));
|
|
1793
|
+
}
|
|
1794
|
+
div(scalar) {
|
|
1795
|
+
return new _Vec(...this.coords.map((coord) => coord / scalar));
|
|
1796
|
+
}
|
|
1797
|
+
dot(other) {
|
|
1798
|
+
if (this.coords.length !== other.coords.length) {
|
|
1799
|
+
throw new TypeError("Coordinate length mismatch!");
|
|
1800
|
+
}
|
|
1801
|
+
return this.coords.reduce((sum2, c, i) => sum2 + c * other.coords[i], 0);
|
|
1802
|
+
}
|
|
1803
|
+
distance(other) {
|
|
1804
|
+
if (this.coords.length !== other.coords.length) {
|
|
1805
|
+
throw new TypeError("Coordinate length mismatch!");
|
|
1806
|
+
}
|
|
1807
|
+
return Math.hypot(...this.coords.map((c, i) => c - other.coords[i]));
|
|
1808
|
+
}
|
|
1809
|
+
normalize() {
|
|
1810
|
+
const len = this.length;
|
|
1811
|
+
if (len === 0) {
|
|
1812
|
+
throw new TypeError("Cannot normalize zero-length vector!");
|
|
1813
|
+
}
|
|
1814
|
+
return this.div(len);
|
|
1815
|
+
}
|
|
1816
|
+
static lerp(a, b, t) {
|
|
1817
|
+
if (a.coords.length !== b.coords.length) {
|
|
1818
|
+
throw new TypeError("Coordinate length mismatch!");
|
|
1819
|
+
}
|
|
1820
|
+
if (!isFinite2(t)) {
|
|
1821
|
+
throw new TypeError("Lerp t is not finite!");
|
|
1822
|
+
}
|
|
1823
|
+
return a.add(b.sub(a).mul(t));
|
|
1824
|
+
}
|
|
1825
|
+
toLength(len) {
|
|
1826
|
+
const mag = this.length;
|
|
1827
|
+
return mag === 0 ? this : this.mul(len / mag);
|
|
1828
|
+
}
|
|
1829
|
+
clamp(minLength, maxLength, defaultDir) {
|
|
1830
|
+
const mag = this.length;
|
|
1831
|
+
if (mag === 0) {
|
|
1832
|
+
if (minLength !== void 0) {
|
|
1833
|
+
if (defaultDir && defaultDir.coords.length !== this.coords.length)
|
|
1834
|
+
throw new TypeError("Coordinate length mismatch!");
|
|
1835
|
+
const dir = defaultDir && defaultDir.length !== 0 ? defaultDir.normalize() : new _Vec(1, ...Array(this.coords.length - 1).fill(0));
|
|
1836
|
+
return dir.mul(minLength);
|
|
1837
|
+
}
|
|
1838
|
+
return this;
|
|
1839
|
+
}
|
|
1840
|
+
if (maxLength !== void 0 && mag > maxLength) {
|
|
1841
|
+
return this.normalize().mul(maxLength);
|
|
1842
|
+
}
|
|
1843
|
+
if (minLength !== void 0 && mag < minLength) {
|
|
1844
|
+
return this.normalize().mul(minLength);
|
|
1845
|
+
}
|
|
1846
|
+
return this;
|
|
1847
|
+
}
|
|
1848
|
+
equals(other) {
|
|
1849
|
+
return this.coords.length === other.coords.length && this.coords.every((v, i) => v === other.coords[i]);
|
|
1850
|
+
}
|
|
1851
|
+
clone() {
|
|
1852
|
+
return new _Vec(...this.coords);
|
|
1853
|
+
}
|
|
1854
|
+
toObject() {
|
|
1855
|
+
return { x: this.x, y: this.y, z: this.z };
|
|
1856
|
+
}
|
|
1857
|
+
[Symbol.iterator]() {
|
|
1858
|
+
return this.coords[Symbol.iterator]();
|
|
1859
|
+
}
|
|
1860
|
+
toString() {
|
|
1861
|
+
return `Vec(${this.coords.join(", ")})`;
|
|
1862
|
+
}
|
|
1863
|
+
};
|
|
1864
|
+
var Rect = class _Rect {
|
|
1865
|
+
constructor(...args) {
|
|
1866
|
+
__publicField(this, "x");
|
|
1867
|
+
__publicField(this, "y");
|
|
1868
|
+
__publicField(this, "width");
|
|
1869
|
+
__publicField(this, "height");
|
|
1870
|
+
if (args.length === 0) {
|
|
1871
|
+
this.x = this.y = this.width = this.height = 0;
|
|
1872
|
+
} else if (args.length === 2) {
|
|
1873
|
+
this.x = this.y = 0;
|
|
1874
|
+
this.width = args[0];
|
|
1875
|
+
this.height = args[1];
|
|
1876
|
+
} else {
|
|
1877
|
+
this.x = args[0];
|
|
1878
|
+
this.y = args[1];
|
|
1879
|
+
this.width = args[2];
|
|
1880
|
+
this.height = args[3];
|
|
1881
|
+
}
|
|
1882
|
+
if (this.width < 0 || this.height < 0)
|
|
1883
|
+
throw new Error("Rect width and height must be non-negative.");
|
|
1884
|
+
}
|
|
1885
|
+
set(...args) {
|
|
1886
|
+
if (args.length === 0) {
|
|
1887
|
+
this.x = this.y = this.width = this.height = 0;
|
|
1888
|
+
} else if (args.length === 2) {
|
|
1889
|
+
this.x = this.y = 0;
|
|
1890
|
+
this.width = args[0];
|
|
1891
|
+
this.height = args[1];
|
|
1892
|
+
} else {
|
|
1893
|
+
this.x = args[0];
|
|
1894
|
+
this.y = args[1];
|
|
1895
|
+
this.width = args[2];
|
|
1896
|
+
this.height = args[3];
|
|
1897
|
+
}
|
|
1898
|
+
if (this.width < 0 || this.height < 0)
|
|
1899
|
+
throw new Error("Rect width and height must be non-negative.");
|
|
1900
|
+
return this;
|
|
1901
|
+
}
|
|
1902
|
+
// --- Static Constructors ---
|
|
1903
|
+
static fromPoints(p1, p2) {
|
|
1904
|
+
const x = Math.min(p1.x, p2.x);
|
|
1905
|
+
const y = Math.min(p1.y, p2.y);
|
|
1906
|
+
const w = Math.abs(p1.x - p2.x);
|
|
1907
|
+
const h = Math.abs(p1.y - p2.y);
|
|
1908
|
+
return new _Rect(x, y, w, h);
|
|
1909
|
+
}
|
|
1910
|
+
static fromCenter(cx, cy, width, height) {
|
|
1911
|
+
return new _Rect(cx - width / 2, cy - height / 2, width, height);
|
|
1912
|
+
}
|
|
1913
|
+
// --- Derived Properties ---
|
|
1914
|
+
get left() {
|
|
1915
|
+
return this.x;
|
|
1916
|
+
}
|
|
1917
|
+
get top() {
|
|
1918
|
+
return this.y;
|
|
1919
|
+
}
|
|
1920
|
+
get right() {
|
|
1921
|
+
return this.x + this.width;
|
|
1922
|
+
}
|
|
1923
|
+
get bottom() {
|
|
1924
|
+
return this.y + this.height;
|
|
1925
|
+
}
|
|
1926
|
+
get centerX() {
|
|
1927
|
+
return this.x + this.width / 2;
|
|
1928
|
+
}
|
|
1929
|
+
get centerY() {
|
|
1930
|
+
return this.y + this.height / 2;
|
|
1931
|
+
}
|
|
1932
|
+
get center() {
|
|
1933
|
+
return { x: this.centerX, y: this.centerY };
|
|
1934
|
+
}
|
|
1935
|
+
get area() {
|
|
1936
|
+
return this.width * this.height;
|
|
1937
|
+
}
|
|
1938
|
+
get isEmpty() {
|
|
1939
|
+
return this.width <= 0 || this.height <= 0;
|
|
1940
|
+
}
|
|
1941
|
+
// --- Geometric Tests ---
|
|
1942
|
+
containsPoint(px, py) {
|
|
1943
|
+
return px >= this.left && px <= this.right && py >= this.top && py <= this.bottom;
|
|
1944
|
+
}
|
|
1945
|
+
containsRect(other) {
|
|
1946
|
+
return other.left >= this.left && other.right <= this.right && other.top >= this.top && other.bottom <= this.bottom;
|
|
1947
|
+
}
|
|
1948
|
+
intersects(other) {
|
|
1949
|
+
return !(other.right < this.left || other.left > this.right || other.bottom < this.top || other.top > this.bottom);
|
|
1950
|
+
}
|
|
1951
|
+
// --- Operations ---
|
|
1952
|
+
intersectionCopy(other) {
|
|
1953
|
+
const x1 = Math.max(this.left, other.left);
|
|
1954
|
+
const y1 = Math.max(this.top, other.top);
|
|
1955
|
+
const x2 = Math.min(this.right, other.right);
|
|
1956
|
+
const y2 = Math.min(this.bottom, other.bottom);
|
|
1957
|
+
if (x2 <= x1 || y2 <= y1) return new _Rect();
|
|
1958
|
+
return new _Rect(x1, y1, x2 - x1, y2 - y1);
|
|
1959
|
+
}
|
|
1960
|
+
unionCopy(other) {
|
|
1961
|
+
const x1 = Math.min(this.left, other.left);
|
|
1962
|
+
const y1 = Math.min(this.top, other.top);
|
|
1963
|
+
const x2 = Math.max(this.right, other.right);
|
|
1964
|
+
const y2 = Math.max(this.bottom, other.bottom);
|
|
1965
|
+
return new _Rect(x1, y1, x2 - x1, y2 - y1);
|
|
1966
|
+
}
|
|
1967
|
+
insetCopy(dx, dy) {
|
|
1968
|
+
return new _Rect(this.x + dx, this.y + dy, this.width - 2 * dx, this.height - 2 * dy);
|
|
1969
|
+
}
|
|
1970
|
+
inflateCopy(dx, dy) {
|
|
1971
|
+
return new _Rect(this.x - dx, this.y - dy, this.width + 2 * dx, this.height + 2 * dy);
|
|
1972
|
+
}
|
|
1973
|
+
offsetInPlace(dx, dy) {
|
|
1974
|
+
this.x += dx;
|
|
1975
|
+
this.y += dy;
|
|
1976
|
+
return this;
|
|
1977
|
+
}
|
|
1978
|
+
offsetCopy(dx, dy) {
|
|
1979
|
+
return new _Rect(this.x + dx, this.y + dy, this.width, this.height);
|
|
1980
|
+
}
|
|
1981
|
+
scaleInPlace(scaleX, scaleY = scaleX) {
|
|
1982
|
+
this.x = this.centerX - this.width * scaleX / 2;
|
|
1983
|
+
this.width *= scaleX;
|
|
1984
|
+
this.y = this.centerY - this.height * scaleY / 2;
|
|
1985
|
+
this.height *= scaleY;
|
|
1986
|
+
return this;
|
|
1987
|
+
}
|
|
1988
|
+
scaleCopy(scaleX, scaleY = scaleX) {
|
|
1989
|
+
return this.clone().scaleInPlace(scaleX, scaleY);
|
|
1990
|
+
}
|
|
1991
|
+
roundCopy() {
|
|
1992
|
+
const left = Math.round(this.left);
|
|
1993
|
+
const top = Math.round(this.top);
|
|
1994
|
+
const right = Math.round(this.right);
|
|
1995
|
+
const bottom = Math.round(this.bottom);
|
|
1996
|
+
return new _Rect(left, top, right - left, bottom - top);
|
|
1997
|
+
}
|
|
1998
|
+
floorCopy() {
|
|
1999
|
+
const left = Math.floor(this.left);
|
|
2000
|
+
const top = Math.floor(this.top);
|
|
2001
|
+
const right = Math.floor(this.right);
|
|
2002
|
+
const bottom = Math.floor(this.bottom);
|
|
2003
|
+
return new _Rect(left, top, right - left, bottom - top);
|
|
2004
|
+
}
|
|
2005
|
+
ceilCopy() {
|
|
2006
|
+
const left = Math.ceil(this.left);
|
|
2007
|
+
const top = Math.ceil(this.top);
|
|
2008
|
+
const right = Math.ceil(this.right);
|
|
2009
|
+
const bottom = Math.ceil(this.bottom);
|
|
2010
|
+
return new _Rect(left, top, right - left, bottom - top);
|
|
2011
|
+
}
|
|
2012
|
+
expandCopy(px, py) {
|
|
2013
|
+
const left = Math.min(this.left, px);
|
|
2014
|
+
const top = Math.min(this.top, py);
|
|
2015
|
+
const right = Math.max(this.right, px);
|
|
2016
|
+
const bottom = Math.max(this.bottom, py);
|
|
2017
|
+
return new _Rect(left, top, right - left, bottom - top);
|
|
2018
|
+
}
|
|
2019
|
+
// --- Utilities ---
|
|
2020
|
+
equals(other) {
|
|
2021
|
+
return this.x === other.x && this.y === other.y && this.width === other.width && this.height === other.height;
|
|
2022
|
+
}
|
|
2023
|
+
clone() {
|
|
2024
|
+
return new _Rect(this.x, this.y, this.width, this.height);
|
|
2025
|
+
}
|
|
2026
|
+
toString() {
|
|
2027
|
+
return `Rect(x=${this.x}, y=${this.y}, w=${this.width}, h=${this.height})`;
|
|
2028
|
+
}
|
|
2029
|
+
toAnchoredRect() {
|
|
2030
|
+
return new AnchoredRect(this.left, this.right, this.top, this.bottom);
|
|
2031
|
+
}
|
|
2032
|
+
};
|
|
2033
|
+
var AnchoredRect = class _AnchoredRect {
|
|
2034
|
+
constructor(...args) {
|
|
2035
|
+
__publicField(this, "left");
|
|
2036
|
+
__publicField(this, "anchorX");
|
|
2037
|
+
__publicField(this, "right");
|
|
2038
|
+
__publicField(this, "top");
|
|
2039
|
+
__publicField(this, "anchorY");
|
|
2040
|
+
__publicField(this, "bottom");
|
|
2041
|
+
if (args.length === 6) {
|
|
2042
|
+
this.left = args[0];
|
|
2043
|
+
this.anchorX = args[1];
|
|
2044
|
+
this.right = args[2];
|
|
2045
|
+
this.top = args[3];
|
|
2046
|
+
this.anchorY = args[4];
|
|
2047
|
+
this.bottom = args[5];
|
|
2048
|
+
} else if (args.length === 4) {
|
|
2049
|
+
this.left = args[0];
|
|
2050
|
+
this.right = args[1];
|
|
2051
|
+
this.anchorX = (this.left + this.right) / 2;
|
|
2052
|
+
this.top = args[2];
|
|
2053
|
+
this.bottom = args[3];
|
|
2054
|
+
this.anchorY = (this.top + this.bottom) / 2;
|
|
2055
|
+
} else if (args.length === 0) {
|
|
2056
|
+
this.left = this.anchorX = this.right = 0;
|
|
2057
|
+
this.top = this.anchorY = this.bottom = 0;
|
|
2058
|
+
} else {
|
|
2059
|
+
throw new TypeError(`Invalid AnchoredRect args: ${args}`);
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
set(...args) {
|
|
2063
|
+
if (args.length === 6) {
|
|
2064
|
+
this.left = args[0];
|
|
2065
|
+
this.anchorX = args[1];
|
|
2066
|
+
this.right = args[2];
|
|
2067
|
+
this.top = args[3];
|
|
2068
|
+
this.anchorY = args[4];
|
|
2069
|
+
this.bottom = args[5];
|
|
2070
|
+
} else if (args.length === 4) {
|
|
2071
|
+
this.left = args[0];
|
|
2072
|
+
this.right = args[1];
|
|
2073
|
+
this.anchorX = (this.left + this.right) / 2;
|
|
2074
|
+
this.top = args[2];
|
|
2075
|
+
this.bottom = args[3];
|
|
2076
|
+
this.anchorY = (this.top + this.bottom) / 2;
|
|
2077
|
+
} else if (args.length === 0) {
|
|
2078
|
+
this.left = this.anchorX = this.right = 0;
|
|
2079
|
+
this.top = this.anchorY = this.bottom = 0;
|
|
2080
|
+
} else {
|
|
2081
|
+
throw new TypeError(`Invalid AnchoredRect args: ${args}`);
|
|
2082
|
+
}
|
|
2083
|
+
return this;
|
|
2084
|
+
}
|
|
2085
|
+
/**
|
|
2086
|
+
* Create rect from basic left, top, width and height arguments.
|
|
2087
|
+
*
|
|
2088
|
+
* @param left - Left coordinate.
|
|
2089
|
+
* @param top - Top coordinate.
|
|
2090
|
+
* @param width - Width.
|
|
2091
|
+
* @param height - Height.
|
|
2092
|
+
* @returns - AnchoredRect.
|
|
2093
|
+
*/
|
|
2094
|
+
static create(left, top, width, height) {
|
|
2095
|
+
return new _AnchoredRect(left, left + width, top, top + height);
|
|
2096
|
+
}
|
|
2097
|
+
/**
|
|
2098
|
+
* Create rect from anchorX, anchorY, width, height arguments.
|
|
2099
|
+
*
|
|
2100
|
+
* @param centerX - Center x-coordinate.
|
|
2101
|
+
* @param centerY - Center y-coordinate.
|
|
2102
|
+
* @param width - Width.
|
|
2103
|
+
* @param height - Height.
|
|
2104
|
+
* @returns - AnchoredRect.
|
|
2105
|
+
*/
|
|
2106
|
+
static createCentered(centerX, centerY, width, height) {
|
|
2107
|
+
return new _AnchoredRect(
|
|
2108
|
+
centerX - width / 2,
|
|
2109
|
+
centerX,
|
|
2110
|
+
centerX + width / 2,
|
|
2111
|
+
centerY - height / 2,
|
|
2112
|
+
centerY,
|
|
2113
|
+
centerY + height / 2
|
|
2114
|
+
);
|
|
2115
|
+
}
|
|
2116
|
+
/**
|
|
2117
|
+
* Create rect from sections.
|
|
2118
|
+
*
|
|
2119
|
+
* @param leftw - Left section width.
|
|
2120
|
+
* @param rightw - Right section width.
|
|
2121
|
+
* @param toph - Top section height.
|
|
2122
|
+
* @param bottomh - Bottomsection height.
|
|
2123
|
+
* @returns - AnchoredRect.
|
|
2124
|
+
*/
|
|
2125
|
+
static createSections(leftw, rightw, toph, bottomh) {
|
|
2126
|
+
return new _AnchoredRect(-leftw, 0, rightw, -toph, 0, bottomh);
|
|
2127
|
+
}
|
|
2128
|
+
/**
|
|
2129
|
+
* Get center x-coordinate.
|
|
2130
|
+
*/
|
|
2131
|
+
get centerX() {
|
|
2132
|
+
return this.left + this.width / 2;
|
|
2133
|
+
}
|
|
2134
|
+
/**
|
|
2135
|
+
* Get center ycoordinate.
|
|
2136
|
+
*/
|
|
2137
|
+
get centerY() {
|
|
2138
|
+
return this.top + this.height / 2;
|
|
2139
|
+
}
|
|
2140
|
+
/**
|
|
2141
|
+
* Width getter.
|
|
2142
|
+
*/
|
|
2143
|
+
get width() {
|
|
2144
|
+
return this.right - this.left;
|
|
2145
|
+
}
|
|
2146
|
+
/**
|
|
2147
|
+
* Height getter.
|
|
2148
|
+
*/
|
|
2149
|
+
get height() {
|
|
2150
|
+
return this.bottom - this.top;
|
|
2151
|
+
}
|
|
2152
|
+
/**
|
|
2153
|
+
* Left section width getter.
|
|
2154
|
+
*/
|
|
2155
|
+
get leftw() {
|
|
2156
|
+
return this.anchorX - this.left;
|
|
2157
|
+
}
|
|
2158
|
+
/**
|
|
2159
|
+
* Right section width getter.
|
|
2160
|
+
*/
|
|
2161
|
+
get rightw() {
|
|
2162
|
+
return this.right - this.anchorX;
|
|
2163
|
+
}
|
|
2164
|
+
/**
|
|
2165
|
+
* Top section height getter.
|
|
2166
|
+
*/
|
|
2167
|
+
get toph() {
|
|
2168
|
+
return this.anchorY - this.top;
|
|
2169
|
+
}
|
|
2170
|
+
/**
|
|
2171
|
+
* Bottom section height getter.
|
|
2172
|
+
*/
|
|
2173
|
+
get bottomh() {
|
|
2174
|
+
return this.bottom - this.anchorY;
|
|
2175
|
+
}
|
|
2176
|
+
/**
|
|
2177
|
+
* Does this Rect contain given (x, y)-point?
|
|
2178
|
+
*
|
|
2179
|
+
* @param x - X-coordinate.
|
|
2180
|
+
* @param y - Y-coordinate.
|
|
2181
|
+
* @returns - True/false.
|
|
2182
|
+
*/
|
|
2183
|
+
contains(x, y) {
|
|
2184
|
+
return x >= this.left && x <= this.right && y >= this.top && y <= this.bottom;
|
|
2185
|
+
}
|
|
2186
|
+
/**
|
|
2187
|
+
* Do a and b rects overlap?
|
|
2188
|
+
*
|
|
2189
|
+
* @param a - AnchoredRect a.
|
|
2190
|
+
* @param b - AnchoredRect b.
|
|
2191
|
+
* @returns - True/false.
|
|
2192
|
+
*/
|
|
2193
|
+
static overlap(a, b) {
|
|
2194
|
+
return a.right > b.left && a.left < b.right && a.bottom > b.top && a.top < b.bottom;
|
|
2195
|
+
}
|
|
2196
|
+
/**
|
|
2197
|
+
* Do horizontal measures of a and b rects overlap?
|
|
2198
|
+
*
|
|
2199
|
+
* @param a - AnchoredRect a.
|
|
2200
|
+
* @param b - AnchoredRect b.
|
|
2201
|
+
* @returns - True/false.
|
|
2202
|
+
*/
|
|
2203
|
+
static overlapX(a, b) {
|
|
2204
|
+
return a.right > b.left && a.left < b.right;
|
|
2205
|
+
}
|
|
2206
|
+
/**
|
|
2207
|
+
* Check if given rects are equal.
|
|
2208
|
+
* @param a - AnchoredRect a.
|
|
2209
|
+
* @param b - AnchoredRect b.
|
|
2210
|
+
* @returns - True/false.
|
|
2211
|
+
*/
|
|
2212
|
+
static equals(a, b) {
|
|
2213
|
+
if (a == null && b == null) {
|
|
2214
|
+
return true;
|
|
2215
|
+
} else if (a == null || b == null) {
|
|
2216
|
+
return false;
|
|
2217
|
+
} else {
|
|
2218
|
+
return a === b || a.left === b.left && a.anchorX === b.anchorX && a.right === b.right && a.top === b.top && a.anchorY === b.anchorY && a.bottom === b.bottom;
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
/**
|
|
2222
|
+
* Check if this rect equals with another rect.
|
|
2223
|
+
* @param other - The other rect.
|
|
2224
|
+
* @returns - True/false.
|
|
2225
|
+
*/
|
|
2226
|
+
equals(other) {
|
|
2227
|
+
return _AnchoredRect.equals(this, other);
|
|
2228
|
+
}
|
|
2229
|
+
/**
|
|
2230
|
+
* Check if edges of given rects are equal, ignoring anchorX and anchorY.
|
|
2231
|
+
*
|
|
2232
|
+
* @param a - AnchoredRect a.
|
|
2233
|
+
* @param b - AnchoredRect b.
|
|
2234
|
+
* @returns - True/false.
|
|
2235
|
+
*/
|
|
2236
|
+
static equalsEdges(a, b) {
|
|
2237
|
+
if (a == null && b == null) {
|
|
2238
|
+
return true;
|
|
2239
|
+
} else if (a == null || b == null) {
|
|
2240
|
+
return false;
|
|
2241
|
+
} else {
|
|
2242
|
+
return a === b || a.left === b.left && a.right === b.right && a.top === b.top && a.bottom === b.bottom;
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
/**
|
|
2246
|
+
* Check if edges of this Rect equals with given Rect, ignoring anchorX and anchorY.
|
|
2247
|
+
*
|
|
2248
|
+
* @param other - The other AnchoredRect.
|
|
2249
|
+
* @returns - True/false.
|
|
2250
|
+
*/
|
|
2251
|
+
equalsEdges(other) {
|
|
2252
|
+
return _AnchoredRect.equalsEdges(this, other);
|
|
2253
|
+
}
|
|
2254
|
+
/**
|
|
2255
|
+
* Created duplicate of this Rect.
|
|
2256
|
+
* @returns - Duplicate.
|
|
2257
|
+
*/
|
|
2258
|
+
clone() {
|
|
2259
|
+
return new _AnchoredRect(this.left, this.anchorX, this.right, this.top, this.anchorY, this.bottom);
|
|
2260
|
+
}
|
|
2261
|
+
/**
|
|
2262
|
+
* Move this rect by (dx, dy). Modifies this Rect.
|
|
2263
|
+
*
|
|
2264
|
+
* @param dx - Offset amount in x-direction.
|
|
2265
|
+
* @param dy - Offset amount in y-direction.
|
|
2266
|
+
* @returns - This AnchoredRect instance.
|
|
2267
|
+
*/
|
|
2268
|
+
offsetInPlace(dx, dy) {
|
|
2269
|
+
this.left += dx;
|
|
2270
|
+
this.anchorX += dx;
|
|
2271
|
+
this.right += dx;
|
|
2272
|
+
this.top += dy;
|
|
2273
|
+
this.anchorY += dy;
|
|
2274
|
+
this.bottom += dy;
|
|
2275
|
+
return this;
|
|
2276
|
+
}
|
|
2277
|
+
/**
|
|
2278
|
+
* Move this rect by (dx, dy). Immutable, returns modified copy.
|
|
2279
|
+
*
|
|
2280
|
+
* @param dx - Offset amount in x-direction.
|
|
2281
|
+
* @param dy - Offset amount in y-direction.
|
|
2282
|
+
* @returns - AnchoredRect copy with applied offset.
|
|
2283
|
+
*/
|
|
2284
|
+
offsetCopy(dx, dy) {
|
|
2285
|
+
return this.clone().offsetInPlace(dx, dy);
|
|
2286
|
+
}
|
|
2287
|
+
/**
|
|
2288
|
+
* Expand this Rect by given Rect. Modifies this Rect.
|
|
2289
|
+
*
|
|
2290
|
+
* @param rect - AnchoredRect to expand this instance with.
|
|
2291
|
+
* @returns - This AnchoredRect instance.
|
|
2292
|
+
*/
|
|
2293
|
+
expandInPlace(rect) {
|
|
2294
|
+
this.left = Math.min(this.left, rect.left);
|
|
2295
|
+
this.right = Math.max(this.right, rect.right);
|
|
2296
|
+
this.top = Math.min(this.top, rect.top);
|
|
2297
|
+
this.bottom = Math.max(this.bottom, rect.bottom);
|
|
2298
|
+
return this;
|
|
2299
|
+
}
|
|
2300
|
+
/**
|
|
2301
|
+
* Expand this Rect by given Rect. Immutable, returns modified copy.
|
|
2302
|
+
*
|
|
2303
|
+
* @param rect - AnchoredRect to expand this instance with.
|
|
2304
|
+
* @returns - Expanded copy of this AnchoredRect.
|
|
2305
|
+
*/
|
|
2306
|
+
expandCopy(rect) {
|
|
2307
|
+
return this.clone().expandInPlace(rect);
|
|
2308
|
+
}
|
|
2309
|
+
/**
|
|
2310
|
+
* Clip this Rect by given Rect. Mmodifies this Rect.
|
|
2311
|
+
*
|
|
2312
|
+
* @param clipRect - AnchoredRect to clip this instance with.
|
|
2313
|
+
* @returns - This AnchoredRect instance.
|
|
2314
|
+
*/
|
|
2315
|
+
clipInPlace(clipRect) {
|
|
2316
|
+
this.left = Math.max(this.left, clipRect.left);
|
|
2317
|
+
this.right = Math.min(this.right, clipRect.right);
|
|
2318
|
+
this.anchorX = clamp(this.anchorX, this.left, this.right);
|
|
2319
|
+
this.top = Math.max(this.top, clipRect.top);
|
|
2320
|
+
this.bottom = Math.min(this.bottom, clipRect.bottom);
|
|
2321
|
+
this.anchorY = clamp(this.anchorY, this.top, this.bottom);
|
|
2322
|
+
return this;
|
|
2323
|
+
}
|
|
2324
|
+
/**
|
|
2325
|
+
* Clip this Rect by given Rect. Immutable, return modified copy.
|
|
2326
|
+
*
|
|
2327
|
+
* @param clipRect - AnchoredRecto to clip this instance with.
|
|
2328
|
+
* @returns - Clipped AnchoredRect copy.
|
|
2329
|
+
*/
|
|
2330
|
+
clipCopy(clipRect) {
|
|
2331
|
+
return this.clone().clipInPlace(clipRect);
|
|
2332
|
+
}
|
|
2333
|
+
/**
|
|
2334
|
+
* Scale Rect. Anchor pos is (anchorX, anchorY). Modifies this Rect.
|
|
2335
|
+
*
|
|
2336
|
+
* @param scaleX - Scale x-amount.
|
|
2337
|
+
* @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
|
|
2338
|
+
* @returns This AnchoredRect instance.
|
|
2339
|
+
*/
|
|
2340
|
+
scaleInPlace(scaleX, scaleY = scaleX) {
|
|
2341
|
+
this.left = this.anchorX - this.leftw * scaleX;
|
|
2342
|
+
this.right = this.anchorX + this.rightw * scaleX;
|
|
2343
|
+
this.top = this.anchorY - this.toph * scaleY;
|
|
2344
|
+
this.bottom = this.anchorY + this.bottomh * scaleY;
|
|
2345
|
+
return this;
|
|
2346
|
+
}
|
|
2347
|
+
/**
|
|
2348
|
+
* Scale Rect. Anchor pos is (anchorX, anchorY). Immutable, returns modified copy.
|
|
2349
|
+
*
|
|
2350
|
+
* @param scaleX - Scale x-amount.
|
|
2351
|
+
* @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
|
|
2352
|
+
* @returns Scaled copy of this AnchoredRect.
|
|
2353
|
+
*/
|
|
2354
|
+
scaleCopy(scaleX, scaleY = scaleX) {
|
|
2355
|
+
return this.clone().scaleInPlace(scaleX, scaleY);
|
|
2356
|
+
}
|
|
2357
|
+
/**
|
|
2358
|
+
* Get this AnchoredRect instance.
|
|
2359
|
+
* @returns - This AnchoredRect instance.
|
|
2360
|
+
*/
|
|
2361
|
+
getRect() {
|
|
2362
|
+
return this;
|
|
2363
|
+
}
|
|
2364
|
+
toRect() {
|
|
2365
|
+
return new Rect(this.left, this.right, this.width, this.height);
|
|
2366
|
+
}
|
|
2367
|
+
toString() {
|
|
2368
|
+
return `Rect(left=${this.left}, anchorX=${this.anchorX}, right=${this.right}, top=${this.top}, anchorY=${this.anchorY}, bottom=${this.bottom})`;
|
|
2369
|
+
}
|
|
2370
|
+
};
|
|
2371
|
+
var LRUCache = class extends BaseContainer {
|
|
2372
|
+
// Maximum key length.
|
|
2373
|
+
constructor(maxSize, maxKeyLength = Infinity) {
|
|
2374
|
+
super();
|
|
2375
|
+
__publicField(this, "cache");
|
|
2376
|
+
__publicField(this, "next");
|
|
2377
|
+
__publicField(this, "prev");
|
|
2378
|
+
__publicField(this, "head");
|
|
2379
|
+
__publicField(this, "tail");
|
|
2380
|
+
__publicField(this, "capacity");
|
|
2381
|
+
__publicField(this, "size");
|
|
2382
|
+
__publicField(this, "maxKeyLength");
|
|
2383
|
+
this.cache = /* @__PURE__ */ Object.create(null);
|
|
2384
|
+
this.next = /* @__PURE__ */ Object.create(null);
|
|
2385
|
+
this.prev = /* @__PURE__ */ Object.create(null);
|
|
2386
|
+
this.head = null;
|
|
2387
|
+
this.tail = null;
|
|
2388
|
+
this.capacity = maxSize;
|
|
2389
|
+
this.size = 0;
|
|
2390
|
+
this.maxKeyLength = maxKeyLength;
|
|
2391
|
+
}
|
|
2392
|
+
// Retrieves a value from the cache
|
|
2393
|
+
get(key) {
|
|
2394
|
+
if (key.length > this.maxKeyLength) return void 0;
|
|
2395
|
+
if (this.cache[key] !== void 0) {
|
|
2396
|
+
this.touch(key);
|
|
2397
|
+
return this.cache[key];
|
|
2398
|
+
}
|
|
2399
|
+
return void 0;
|
|
2400
|
+
}
|
|
2401
|
+
set(key, value) {
|
|
2402
|
+
if (key.length > this.maxKeyLength) {
|
|
2403
|
+
return;
|
|
2404
|
+
}
|
|
2405
|
+
if (this.cache[key] !== void 0) {
|
|
2406
|
+
this.cache[key] = value;
|
|
2407
|
+
this.touch(key);
|
|
2408
|
+
return;
|
|
2409
|
+
}
|
|
2410
|
+
if (this.size >= this.capacity) {
|
|
2411
|
+
this.evict();
|
|
2412
|
+
}
|
|
2413
|
+
this.cache[key] = value;
|
|
2414
|
+
this.addToTail(key);
|
|
2415
|
+
this.size++;
|
|
2416
|
+
}
|
|
2417
|
+
// Marks a key as most recently used
|
|
2418
|
+
touch(key) {
|
|
2419
|
+
if (this.tail === key) return;
|
|
2420
|
+
this.removeKey(key);
|
|
2421
|
+
this.addToTail(key);
|
|
2422
|
+
}
|
|
2423
|
+
// Evicts the least recently used item (at the head)
|
|
2424
|
+
evict() {
|
|
2425
|
+
if (this.head !== null) {
|
|
2426
|
+
const oldestKey = this.head;
|
|
2427
|
+
this.removeKey(oldestKey);
|
|
2428
|
+
delete this.cache[oldestKey];
|
|
2429
|
+
this.size--;
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2432
|
+
// Removes a key from the linked list
|
|
2433
|
+
removeKey(key) {
|
|
2434
|
+
const prevKey = this.prev[key];
|
|
2435
|
+
const nextKey = this.next[key];
|
|
2436
|
+
if (prevKey !== void 0) {
|
|
2437
|
+
this.next[prevKey] = nextKey;
|
|
2438
|
+
} else {
|
|
2439
|
+
this.head = nextKey != null ? nextKey : null;
|
|
2440
|
+
}
|
|
2441
|
+
if (nextKey !== void 0) {
|
|
2442
|
+
this.prev[nextKey] = prevKey;
|
|
2443
|
+
} else {
|
|
2444
|
+
this.tail = prevKey != null ? prevKey : null;
|
|
2445
|
+
}
|
|
2446
|
+
delete this.prev[key];
|
|
2447
|
+
delete this.next[key];
|
|
2448
|
+
}
|
|
2449
|
+
// Adds a key to the tail (most recently used position)
|
|
2450
|
+
addToTail(key) {
|
|
2451
|
+
if (this.tail !== null) {
|
|
2452
|
+
this.next[this.tail] = key;
|
|
2453
|
+
this.prev[key] = this.tail;
|
|
2454
|
+
} else {
|
|
2455
|
+
this.head = key;
|
|
2456
|
+
}
|
|
2457
|
+
this.tail = key;
|
|
2458
|
+
}
|
|
2459
|
+
*keys() {
|
|
2460
|
+
for (let key = this.head; key != null; key = this.next[key])
|
|
2461
|
+
yield key;
|
|
2462
|
+
}
|
|
2463
|
+
*values() {
|
|
2464
|
+
for (let key = this.head; key != null; key = this.next[key])
|
|
2465
|
+
yield this.cache[key];
|
|
2466
|
+
}
|
|
2467
|
+
*entries() {
|
|
2468
|
+
for (let key = this.head; key != null; key = this.next[key])
|
|
2469
|
+
yield [key, this.cache[key]];
|
|
2470
|
+
}
|
|
2471
|
+
*[Symbol.iterator]() {
|
|
2472
|
+
yield* __yieldStar(this.entries());
|
|
2473
|
+
}
|
|
2474
|
+
toString() {
|
|
2475
|
+
const entries = [...this.entries()];
|
|
2476
|
+
return entries.length === 0 ? `LRUCache(0){ }` : `LRUCache(${entries.length}){ ${entries.map((e) => `${stringify(e[0])}: ${stringify(e[1])}`).join(", ")} }`;
|
|
2477
|
+
}
|
|
2478
|
+
};
|
|
2479
|
+
var IndexArray = class _IndexArray extends BaseContainer {
|
|
2480
|
+
constructor(entries) {
|
|
2481
|
+
super();
|
|
2482
|
+
__publicField(this, "posVal");
|
|
2483
|
+
__publicField(this, "hasPos");
|
|
2484
|
+
__publicField(this, "valCount");
|
|
2485
|
+
if (entries instanceof _IndexArray) {
|
|
2486
|
+
this.posVal = entries.posVal.slice();
|
|
2487
|
+
this.hasPos = entries.hasPos.slice();
|
|
2488
|
+
this.valCount = entries.valCount;
|
|
2489
|
+
} else {
|
|
2490
|
+
this.posVal = [];
|
|
2491
|
+
this.hasPos = [];
|
|
2492
|
+
this.valCount = 0;
|
|
2493
|
+
if (entries) {
|
|
2494
|
+
for (const [id, value] of entries) {
|
|
2495
|
+
this.set(id, value);
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2500
|
+
static validateIndex(id) {
|
|
2501
|
+
if (!isIntegerGte(id, 0)) throw new Error(`Invalid index ${id} - must be an integer >= 0!`);
|
|
2502
|
+
return id;
|
|
2503
|
+
}
|
|
2504
|
+
get posLen() {
|
|
2505
|
+
return this.hasPos.length;
|
|
2506
|
+
}
|
|
2507
|
+
get size() {
|
|
2508
|
+
return this.valCount;
|
|
2509
|
+
}
|
|
2510
|
+
get length() {
|
|
2511
|
+
return this.hasPos.length;
|
|
2512
|
+
}
|
|
2513
|
+
trimRight() {
|
|
2514
|
+
let newLength = this.length;
|
|
2515
|
+
while (newLength > 0 && this.hasPos[newLength - 1] !== true) newLength--;
|
|
2516
|
+
if (newLength < this.length) this.posVal.length = this.hasPos.length = newLength;
|
|
2517
|
+
}
|
|
2518
|
+
isEmpty() {
|
|
2519
|
+
return this.size === 0;
|
|
2520
|
+
}
|
|
2521
|
+
has(id) {
|
|
2522
|
+
_IndexArray.validateIndex(id);
|
|
2523
|
+
return this.hasPos[id] === true;
|
|
2524
|
+
}
|
|
2525
|
+
set(id, value) {
|
|
2526
|
+
_IndexArray.validateIndex(id);
|
|
2527
|
+
if (this.hasPos[id] !== true) this.valCount++;
|
|
2528
|
+
this.posVal[id] = value;
|
|
2529
|
+
this.hasPos[id] = true;
|
|
2530
|
+
}
|
|
2531
|
+
get(id) {
|
|
2532
|
+
_IndexArray.validateIndex(id);
|
|
2533
|
+
return this.hasPos[id] ? this.posVal[id] : void 0;
|
|
2534
|
+
}
|
|
2535
|
+
getOrDefault(id, defaultValue) {
|
|
2536
|
+
var _a;
|
|
2537
|
+
return (_a = this.get(id)) != null ? _a : defaultValue;
|
|
2538
|
+
}
|
|
2539
|
+
getOrCreate(id, creatorOrValue) {
|
|
2540
|
+
if (!this.has(id)) {
|
|
2541
|
+
const value = isFunction(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
2542
|
+
this.set(id, value);
|
|
2543
|
+
return value;
|
|
2544
|
+
}
|
|
2545
|
+
return this.get(id);
|
|
2546
|
+
}
|
|
2547
|
+
delete(id) {
|
|
2548
|
+
_IndexArray.validateIndex(id);
|
|
2549
|
+
if (!this.hasPos[id]) return false;
|
|
2550
|
+
this.posVal[id] = void 0;
|
|
2551
|
+
this.hasPos[id] = false;
|
|
2552
|
+
this.valCount--;
|
|
2553
|
+
this.trimRight();
|
|
2554
|
+
return true;
|
|
2555
|
+
}
|
|
2556
|
+
clear() {
|
|
2557
|
+
this.posVal = [];
|
|
2558
|
+
this.hasPos = [];
|
|
2559
|
+
this.valCount = 0;
|
|
2560
|
+
}
|
|
2561
|
+
forEach(callbackfn, thisArg) {
|
|
2562
|
+
for (const [id, value] of this.entries()) {
|
|
2563
|
+
callbackfn.call(thisArg, value, id, this);
|
|
2564
|
+
}
|
|
2565
|
+
}
|
|
2566
|
+
*indices() {
|
|
2567
|
+
for (let id = 0; id < this.posLen; id++) {
|
|
2568
|
+
if (this.hasPos[id]) yield id;
|
|
2569
|
+
}
|
|
2570
|
+
}
|
|
2571
|
+
*values() {
|
|
2572
|
+
for (let id = 0; id < this.posLen; id++) {
|
|
2573
|
+
if (this.hasPos[id]) yield this.posVal[id];
|
|
2574
|
+
}
|
|
2575
|
+
}
|
|
2576
|
+
*entries() {
|
|
2577
|
+
for (let id = 0; id < this.posLen; id++) {
|
|
2578
|
+
if (this.hasPos[id]) yield [id, this.posVal[id]];
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
indicesArray() {
|
|
2582
|
+
return [...this.indices()];
|
|
2583
|
+
}
|
|
2584
|
+
valuesArray() {
|
|
2585
|
+
return [...this.values()];
|
|
2586
|
+
}
|
|
2587
|
+
entriesArray() {
|
|
2588
|
+
return [...this.entries()];
|
|
2589
|
+
}
|
|
2590
|
+
*kvKeys() {
|
|
2591
|
+
for (const id of this.indices()) {
|
|
2592
|
+
yield [id];
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
*kvValues() {
|
|
2596
|
+
for (const value of this.values()) {
|
|
2597
|
+
yield value;
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
*kvEntries() {
|
|
2601
|
+
for (const [id, value] of this.entries()) {
|
|
2602
|
+
yield [[id], value];
|
|
2603
|
+
}
|
|
2604
|
+
}
|
|
2605
|
+
*[Symbol.iterator]() {
|
|
2606
|
+
yield* __yieldStar(this.entries());
|
|
2607
|
+
}
|
|
2608
|
+
clone() {
|
|
2609
|
+
return new _IndexArray(this);
|
|
2610
|
+
}
|
|
2611
|
+
merge(other, conflictResolver) {
|
|
2612
|
+
for (const [id, value] of other.entries()) {
|
|
2613
|
+
if (this.has(id) && conflictResolver) {
|
|
2614
|
+
this.set(id, conflictResolver(this.get(id), value, id));
|
|
2615
|
+
} else {
|
|
2616
|
+
this.set(id, value);
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2619
|
+
return this;
|
|
2620
|
+
}
|
|
2621
|
+
some(fn) {
|
|
2622
|
+
for (const [id, value] of this.entries()) {
|
|
2623
|
+
if (fn(value, id)) return true;
|
|
2624
|
+
}
|
|
2625
|
+
return false;
|
|
2626
|
+
}
|
|
2627
|
+
every(fn) {
|
|
2628
|
+
for (const [id, value] of this.entries()) {
|
|
2629
|
+
if (!fn(value, id)) return false;
|
|
2630
|
+
}
|
|
2631
|
+
return true;
|
|
2632
|
+
}
|
|
2633
|
+
filter(predicate) {
|
|
2634
|
+
const result = new this.constructor();
|
|
2635
|
+
for (const [id, value] of this.entries()) {
|
|
2636
|
+
if (predicate(value, id, this)) result.set(id, value);
|
|
2637
|
+
}
|
|
2638
|
+
return result;
|
|
2639
|
+
}
|
|
2640
|
+
reduce(fn, init) {
|
|
2641
|
+
let iterator = this.entries();
|
|
2642
|
+
let first = iterator.next();
|
|
2643
|
+
if (first.done) {
|
|
2644
|
+
if (arguments.length < 2) {
|
|
2645
|
+
throw new TypeError("Reduce of empty IndexArray with no initial value!");
|
|
2646
|
+
}
|
|
2647
|
+
return init;
|
|
2648
|
+
}
|
|
2649
|
+
let acc;
|
|
2650
|
+
let start;
|
|
2651
|
+
if (arguments.length < 2) {
|
|
2652
|
+
acc = first.value[1];
|
|
2653
|
+
start = iterator.next();
|
|
2654
|
+
} else {
|
|
2655
|
+
acc = init;
|
|
2656
|
+
start = first;
|
|
2657
|
+
}
|
|
2658
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
2659
|
+
const [id, value] = current.value;
|
|
2660
|
+
acc = fn(acc, value, id);
|
|
2661
|
+
}
|
|
2662
|
+
return acc;
|
|
2663
|
+
}
|
|
2664
|
+
mapToArray(fn) {
|
|
2665
|
+
let result = [];
|
|
2666
|
+
for (const [id, value] of this.entries()) {
|
|
2667
|
+
result.push(fn(value, id));
|
|
2668
|
+
}
|
|
2669
|
+
return result;
|
|
2670
|
+
}
|
|
2671
|
+
map(fn) {
|
|
2672
|
+
let result = new _IndexArray();
|
|
2673
|
+
for (const [id, value] of this.entries()) {
|
|
2674
|
+
result.set(id, fn(value, id));
|
|
2675
|
+
}
|
|
2676
|
+
return result;
|
|
2677
|
+
}
|
|
2678
|
+
equals(other, eq) {
|
|
2679
|
+
if (this.size !== other.size) return false;
|
|
2680
|
+
eq != null ? eq : eq = (a, b) => a === b;
|
|
2681
|
+
const posLen = Math.max(this.posLen, other.posLen);
|
|
2682
|
+
for (let i = 0; i < posLen; ++i) {
|
|
2683
|
+
const hasA = this.hasPos[i];
|
|
2684
|
+
const hasB = other.hasPos[i];
|
|
2685
|
+
if (hasA !== hasB) return false;
|
|
2686
|
+
if (hasA && !eq(this.posVal[i], other.posVal[i])) return false;
|
|
2687
|
+
}
|
|
2688
|
+
return true;
|
|
2689
|
+
}
|
|
2690
|
+
toArray() {
|
|
2691
|
+
return this.valuesArray();
|
|
2692
|
+
}
|
|
2693
|
+
toString() {
|
|
2694
|
+
let isRegularArray = true;
|
|
2695
|
+
for (let i = 0; i < this.hasPos.length && isRegularArray; i++)
|
|
2696
|
+
if (!this.hasPos[i]) isRegularArray = false;
|
|
2697
|
+
if (isRegularArray)
|
|
2698
|
+
return stringify(this.posVal.slice(0, this.hasPos.length));
|
|
2699
|
+
const entries = this.entriesArray().map(([id, v]) => `${stringify(id)}: ${stringify(v)}`).join(", ");
|
|
2700
|
+
return entries.length === 0 ? `[ ]` : `[ ${entries} ]`;
|
|
2701
|
+
}
|
|
2702
|
+
};
|
|
2703
|
+
var SignedIndexArray = class _SignedIndexArray extends BaseContainer {
|
|
2704
|
+
constructor(entries) {
|
|
2705
|
+
super();
|
|
2706
|
+
__publicField(this, "posVal");
|
|
2707
|
+
__publicField(this, "hasPos");
|
|
2708
|
+
__publicField(this, "negVal");
|
|
2709
|
+
__publicField(this, "hasNeg");
|
|
2710
|
+
__publicField(this, "valCount");
|
|
2711
|
+
if (entries instanceof _SignedIndexArray) {
|
|
2712
|
+
this.negVal = entries.negVal.slice();
|
|
2713
|
+
this.hasNeg = entries.hasNeg.slice();
|
|
2714
|
+
this.posVal = entries.posVal.slice();
|
|
2715
|
+
this.hasPos = entries.hasPos.slice();
|
|
2716
|
+
this.valCount = entries.valCount;
|
|
2717
|
+
} else {
|
|
2718
|
+
this.negVal = [];
|
|
2719
|
+
this.hasNeg = [];
|
|
2720
|
+
this.posVal = [];
|
|
2721
|
+
this.hasPos = [];
|
|
2722
|
+
this.valCount = 0;
|
|
2723
|
+
if (entries) {
|
|
2724
|
+
for (const [id, value] of entries) {
|
|
2725
|
+
this.set(id, value);
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
static toNegIndex(id) {
|
|
2731
|
+
return -id - 1;
|
|
2732
|
+
}
|
|
2733
|
+
static validateIndex(id) {
|
|
2734
|
+
if (!isInteger(id)) throw new Error(`Invalid index ${id} - must be an integer!`);
|
|
2735
|
+
return id;
|
|
2736
|
+
}
|
|
2737
|
+
get size() {
|
|
2738
|
+
return this.valCount;
|
|
2739
|
+
}
|
|
2740
|
+
isEmpty() {
|
|
2741
|
+
return this.size === 0;
|
|
2742
|
+
}
|
|
2743
|
+
get posLen() {
|
|
2744
|
+
return this.hasPos.length;
|
|
2745
|
+
}
|
|
2746
|
+
get negLen() {
|
|
2747
|
+
return this.hasNeg.length;
|
|
2748
|
+
}
|
|
2749
|
+
has(id) {
|
|
2750
|
+
_SignedIndexArray.validateIndex(id);
|
|
2751
|
+
if (id >= 0) {
|
|
2752
|
+
return this.hasPos[id] === true;
|
|
2753
|
+
} else {
|
|
2754
|
+
return this.hasNeg[_SignedIndexArray.toNegIndex(id)] === true;
|
|
2755
|
+
}
|
|
2756
|
+
}
|
|
2757
|
+
set(id, value) {
|
|
2758
|
+
_SignedIndexArray.validateIndex(id);
|
|
2759
|
+
if (id >= 0) {
|
|
2760
|
+
if (this.hasPos[id] !== true) this.valCount++;
|
|
2761
|
+
this.posVal[id] = value;
|
|
2762
|
+
this.hasPos[id] = true;
|
|
2763
|
+
} else {
|
|
2764
|
+
let negId = _SignedIndexArray.toNegIndex(id);
|
|
2765
|
+
if (this.hasNeg[negId] !== true) this.valCount++;
|
|
2766
|
+
this.negVal[negId] = value;
|
|
2767
|
+
this.hasNeg[negId] = true;
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
get(id) {
|
|
2771
|
+
_SignedIndexArray.validateIndex(id);
|
|
2772
|
+
if (id >= 0) {
|
|
2773
|
+
return this.hasPos[id] ? this.posVal[id] : void 0;
|
|
2774
|
+
} else {
|
|
2775
|
+
let negId = _SignedIndexArray.toNegIndex(id);
|
|
2776
|
+
return this.hasNeg[negId] ? this.negVal[negId] : void 0;
|
|
2777
|
+
}
|
|
2778
|
+
}
|
|
2779
|
+
getOrDefault(id, defaultValue) {
|
|
2780
|
+
var _a;
|
|
2781
|
+
return (_a = this.get(id)) != null ? _a : defaultValue;
|
|
2782
|
+
}
|
|
2783
|
+
getOrCreate(id, creatorOrValue) {
|
|
2784
|
+
if (!this.has(id)) {
|
|
2785
|
+
const value = isFunction(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
2786
|
+
this.set(id, value);
|
|
2787
|
+
return value;
|
|
2788
|
+
}
|
|
2789
|
+
return this.get(id);
|
|
2790
|
+
}
|
|
2791
|
+
delete(id) {
|
|
2792
|
+
_SignedIndexArray.validateIndex(id);
|
|
2793
|
+
const isPos3 = id >= 0;
|
|
2794
|
+
const arr = isPos3 ? this.posVal : this.negVal;
|
|
2795
|
+
const has = isPos3 ? this.hasPos : this.hasNeg;
|
|
2796
|
+
const idx = isPos3 ? id : _SignedIndexArray.toNegIndex(id);
|
|
2797
|
+
if (!has[idx]) return false;
|
|
2798
|
+
arr[idx] = void 0;
|
|
2799
|
+
has[idx] = false;
|
|
2800
|
+
this.valCount--;
|
|
2801
|
+
return true;
|
|
2802
|
+
}
|
|
2803
|
+
clear() {
|
|
2804
|
+
this.negVal = [];
|
|
2805
|
+
this.hasNeg = [];
|
|
2806
|
+
this.posVal = [];
|
|
2807
|
+
this.hasPos = [];
|
|
2808
|
+
this.valCount = 0;
|
|
2809
|
+
}
|
|
2810
|
+
forEach(callbackfn, thisArg) {
|
|
2811
|
+
for (const [id, value] of this.entries()) {
|
|
2812
|
+
callbackfn.call(thisArg, value, id, this);
|
|
2813
|
+
}
|
|
2814
|
+
}
|
|
2815
|
+
*indices() {
|
|
2816
|
+
for (let id = this.negLen - 1; id >= 0; id--) {
|
|
2817
|
+
if (this.hasNeg[id]) yield _SignedIndexArray.toNegIndex(id);
|
|
2818
|
+
}
|
|
2819
|
+
for (let id = 0; id < this.posLen; id++) {
|
|
2820
|
+
if (this.hasPos[id]) yield id;
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
*values() {
|
|
2824
|
+
for (let id = this.negLen - 1; id >= 0; id--) {
|
|
2825
|
+
if (this.hasNeg[id]) yield this.negVal[id];
|
|
2826
|
+
}
|
|
2827
|
+
for (let id = 0; id < this.posLen; id++) {
|
|
2828
|
+
if (this.hasPos[id]) yield this.posVal[id];
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
*entries() {
|
|
2832
|
+
for (let id = this.negLen - 1; id >= 0; id--) {
|
|
2833
|
+
if (this.hasNeg[id]) yield [_SignedIndexArray.toNegIndex(id), this.negVal[id]];
|
|
2834
|
+
}
|
|
2835
|
+
for (let id = 0; id < this.posLen; id++) {
|
|
2836
|
+
if (this.hasPos[id]) yield [id, this.posVal[id]];
|
|
2837
|
+
}
|
|
2838
|
+
}
|
|
2839
|
+
indicesArray() {
|
|
2840
|
+
return [...this.indices()];
|
|
2841
|
+
}
|
|
2842
|
+
valuesArray() {
|
|
2843
|
+
return [...this.values()];
|
|
2844
|
+
}
|
|
2845
|
+
entriesArray() {
|
|
2846
|
+
return [...this.entries()];
|
|
2847
|
+
}
|
|
2848
|
+
*kvKeys() {
|
|
2849
|
+
for (const id of this.indices()) {
|
|
2850
|
+
yield [id];
|
|
2851
|
+
}
|
|
2852
|
+
}
|
|
2853
|
+
*kvValues() {
|
|
2854
|
+
for (const value of this.values()) {
|
|
2855
|
+
yield value;
|
|
2856
|
+
}
|
|
2857
|
+
}
|
|
2858
|
+
*kvEntries() {
|
|
2859
|
+
for (const [id, value] of this.entries()) {
|
|
2860
|
+
yield [[id], value];
|
|
2861
|
+
}
|
|
2862
|
+
}
|
|
2863
|
+
*[Symbol.iterator]() {
|
|
2864
|
+
yield* __yieldStar(this.entries());
|
|
2865
|
+
}
|
|
2866
|
+
clone() {
|
|
2867
|
+
return new _SignedIndexArray(this);
|
|
2868
|
+
}
|
|
2869
|
+
merge(other, conflictResolver) {
|
|
2870
|
+
for (const [id, value] of other.entries()) {
|
|
2871
|
+
if (this.has(id) && conflictResolver) {
|
|
2872
|
+
this.set(id, conflictResolver(this.get(id), value, id));
|
|
2873
|
+
} else {
|
|
2874
|
+
this.set(id, value);
|
|
2875
|
+
}
|
|
2876
|
+
}
|
|
2877
|
+
return this;
|
|
2878
|
+
}
|
|
2879
|
+
some(fn) {
|
|
2880
|
+
for (const [id, value] of this.entries()) {
|
|
2881
|
+
if (fn(value, id)) return true;
|
|
2882
|
+
}
|
|
2883
|
+
return false;
|
|
2884
|
+
}
|
|
2885
|
+
every(fn) {
|
|
2886
|
+
for (const [id, value] of this.entries()) {
|
|
2887
|
+
if (!fn(value, id)) return false;
|
|
2888
|
+
}
|
|
2889
|
+
return true;
|
|
2890
|
+
}
|
|
2891
|
+
filter(predicate) {
|
|
2892
|
+
const result = new this.constructor();
|
|
2893
|
+
for (const [id, value] of this.entries()) {
|
|
2894
|
+
if (predicate(value, id, this)) result.set(id, value);
|
|
2895
|
+
}
|
|
2896
|
+
return result;
|
|
2897
|
+
}
|
|
2898
|
+
reduce(fn, init) {
|
|
2899
|
+
let iterator = this.entries();
|
|
2900
|
+
let first = iterator.next();
|
|
2901
|
+
if (first.done) {
|
|
2902
|
+
if (arguments.length < 2) {
|
|
2903
|
+
throw new TypeError("Reduce of empty SignedIndexArray with no initial value!");
|
|
2904
|
+
}
|
|
2905
|
+
return init;
|
|
2906
|
+
}
|
|
2907
|
+
let acc;
|
|
2908
|
+
let start;
|
|
2909
|
+
if (arguments.length < 2) {
|
|
2910
|
+
acc = first.value[1];
|
|
2911
|
+
start = iterator.next();
|
|
2912
|
+
} else {
|
|
2913
|
+
acc = init;
|
|
2914
|
+
start = first;
|
|
2915
|
+
}
|
|
2916
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
2917
|
+
const [id, value] = current.value;
|
|
2918
|
+
acc = fn(acc, value, id);
|
|
2919
|
+
}
|
|
2920
|
+
return acc;
|
|
2921
|
+
}
|
|
2922
|
+
mapToArray(fn) {
|
|
2923
|
+
let result = [];
|
|
2924
|
+
for (const [id, value] of this.entries()) {
|
|
2925
|
+
result.push(fn(value, id));
|
|
2926
|
+
}
|
|
2927
|
+
return result;
|
|
2928
|
+
}
|
|
2929
|
+
map(fn) {
|
|
2930
|
+
let result = new _SignedIndexArray();
|
|
2931
|
+
for (const [id, value] of this.entries()) {
|
|
2932
|
+
result.set(id, fn(value, id));
|
|
2933
|
+
}
|
|
2934
|
+
return result;
|
|
2935
|
+
}
|
|
2936
|
+
equals(other, eq) {
|
|
2937
|
+
if (this.size !== other.size) return false;
|
|
2938
|
+
eq != null ? eq : eq = (a, b) => a === b;
|
|
2939
|
+
const posLen = Math.max(this.posLen, other.posLen);
|
|
2940
|
+
for (let i = 0; i < posLen; ++i) {
|
|
2941
|
+
const hasA = this.hasPos[i];
|
|
2942
|
+
const hasB = other.hasPos[i];
|
|
2943
|
+
if (hasA !== hasB) return false;
|
|
2944
|
+
if (hasA && !eq(this.posVal[i], other.posVal[i])) return false;
|
|
2945
|
+
}
|
|
2946
|
+
const negLen = Math.max(this.negLen, other.negLen);
|
|
2947
|
+
for (let i = 0; i < negLen; ++i) {
|
|
2948
|
+
const hasA = this.hasNeg[i];
|
|
2949
|
+
const hasB = other.hasNeg[i];
|
|
2950
|
+
if (hasA !== hasB) return false;
|
|
2951
|
+
if (hasA && !eq(this.negVal[i], other.negVal[i])) return false;
|
|
2952
|
+
}
|
|
2953
|
+
return true;
|
|
2954
|
+
}
|
|
2955
|
+
toArray() {
|
|
2956
|
+
return this.valuesArray();
|
|
2957
|
+
}
|
|
2958
|
+
toString() {
|
|
2959
|
+
let isRegularArray = this.hasNeg.length === 0;
|
|
2960
|
+
for (let i = 0; i < this.hasPos.length && isRegularArray; i++)
|
|
2961
|
+
if (!this.hasPos[i]) isRegularArray = false;
|
|
2962
|
+
if (isRegularArray)
|
|
2963
|
+
return stringify(this.posVal.slice(0, this.hasPos.length));
|
|
2964
|
+
const entries = this.entriesArray().map(([id, v]) => `${stringify(id)}: ${stringify(v)}`).join(", ");
|
|
2965
|
+
return entries.length === 0 ? `[ ]` : `[ ${entries} ]`;
|
|
2966
|
+
}
|
|
2967
|
+
};
|
|
2968
|
+
var UniMap = class _UniMap extends BaseContainer {
|
|
2969
|
+
constructor(...args) {
|
|
2970
|
+
super();
|
|
2971
|
+
__publicField(this, "map");
|
|
2972
|
+
__publicField(this, "keyEquals");
|
|
2973
|
+
const maybeEquals = args.at(-1);
|
|
2974
|
+
this.keyEquals = isFunction(maybeEquals) ? args.pop() : DefaultEqualityFn;
|
|
2975
|
+
const entries = args[0];
|
|
2976
|
+
this.map = new Map(entries);
|
|
2977
|
+
}
|
|
2978
|
+
static createDeep(arg) {
|
|
2979
|
+
return arg ? new _UniMap(arg, isDeepEqual) : new _UniMap(isDeepEqual);
|
|
2980
|
+
}
|
|
2981
|
+
has(key) {
|
|
2982
|
+
if (this.keyEquals === DefaultEqualityFn || this.map.has(key))
|
|
2983
|
+
return this.map.has(key);
|
|
2984
|
+
for (const [k, v] of this.map)
|
|
2985
|
+
if (this.keyEquals(k, key))
|
|
2986
|
+
return true;
|
|
2987
|
+
return false;
|
|
2988
|
+
}
|
|
2989
|
+
set(key, value) {
|
|
2990
|
+
if (this.keyEquals === DefaultEqualityFn || this.map.has(key)) {
|
|
2991
|
+
this.map.set(key, value);
|
|
2992
|
+
return value;
|
|
2993
|
+
}
|
|
2994
|
+
for (const key2 of this.map.keys())
|
|
2995
|
+
if (this.keyEquals(key2, key)) {
|
|
2996
|
+
this.map.set(key2, value);
|
|
2997
|
+
return value;
|
|
2998
|
+
}
|
|
2999
|
+
this.map.set(key, value);
|
|
3000
|
+
return value;
|
|
3001
|
+
}
|
|
3002
|
+
get(key) {
|
|
3003
|
+
if (this.keyEquals === DefaultEqualityFn || this.map.has(key))
|
|
3004
|
+
return this.map.get(key);
|
|
3005
|
+
for (const [k, v] of this.map)
|
|
3006
|
+
if (this.keyEquals(k, key))
|
|
3007
|
+
return v;
|
|
3008
|
+
return void 0;
|
|
3009
|
+
}
|
|
3010
|
+
delete(key) {
|
|
3011
|
+
if (this.keyEquals === DefaultEqualityFn || this.map.has(key))
|
|
3012
|
+
return this.map.delete(key);
|
|
3013
|
+
for (const k of this.map.keys())
|
|
3014
|
+
if (this.keyEquals(k, key))
|
|
3015
|
+
return this.map.delete(k);
|
|
3016
|
+
return this.map.delete(key);
|
|
3017
|
+
}
|
|
3018
|
+
getOrDefault(key, defaultValue) {
|
|
3019
|
+
var _a;
|
|
3020
|
+
return (_a = this.get(key)) != null ? _a : defaultValue;
|
|
3021
|
+
}
|
|
3022
|
+
getOrCreate(key, creatorOrValue) {
|
|
3023
|
+
if (!this.has(key)) {
|
|
3024
|
+
const value = isFunction(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
3025
|
+
return this.set(key, value);
|
|
3026
|
+
}
|
|
3027
|
+
return this.get(key);
|
|
3028
|
+
}
|
|
3029
|
+
clear() {
|
|
3030
|
+
this.map.clear();
|
|
3031
|
+
}
|
|
3032
|
+
get size() {
|
|
3033
|
+
return this.map.size;
|
|
3034
|
+
}
|
|
3035
|
+
isEmpty() {
|
|
3036
|
+
return this.size === 0;
|
|
3037
|
+
}
|
|
3038
|
+
forEach(callbackfn, thisArg) {
|
|
3039
|
+
this.map.forEach((value, key) => callbackfn.call(thisArg, value, key, this));
|
|
3040
|
+
}
|
|
3041
|
+
*keys() {
|
|
3042
|
+
yield* __yieldStar(this.map.keys());
|
|
3043
|
+
}
|
|
3044
|
+
*values() {
|
|
3045
|
+
yield* __yieldStar(this.map.values());
|
|
3046
|
+
}
|
|
3047
|
+
*entries() {
|
|
3048
|
+
for (const [key, value] of this.map)
|
|
3049
|
+
yield [key, value];
|
|
3050
|
+
}
|
|
3051
|
+
keysArray() {
|
|
3052
|
+
return [...this.keys()];
|
|
3053
|
+
}
|
|
3054
|
+
valuesArray() {
|
|
3055
|
+
return [...this.values()];
|
|
3056
|
+
}
|
|
3057
|
+
entriesArray() {
|
|
3058
|
+
return [...this.entries()];
|
|
3059
|
+
}
|
|
3060
|
+
*kvKeys() {
|
|
3061
|
+
for (const key of this.keys()) {
|
|
3062
|
+
yield [key];
|
|
3063
|
+
}
|
|
3064
|
+
}
|
|
3065
|
+
*kvValues() {
|
|
3066
|
+
for (const el of this.values()) {
|
|
3067
|
+
yield el;
|
|
3068
|
+
}
|
|
3069
|
+
}
|
|
3070
|
+
*kvEntries() {
|
|
3071
|
+
for (const [key, el] of this.entries()) {
|
|
3072
|
+
yield [[key], el];
|
|
3073
|
+
}
|
|
3074
|
+
}
|
|
3075
|
+
*[Symbol.iterator]() {
|
|
3076
|
+
yield* __yieldStar(this.entries());
|
|
3077
|
+
}
|
|
3078
|
+
clone() {
|
|
3079
|
+
return new _UniMap(this, this.keyEquals);
|
|
3080
|
+
}
|
|
3081
|
+
merge(other, conflictResolver) {
|
|
3082
|
+
for (const [key, value] of other.entries()) {
|
|
3083
|
+
if (this.has(key) && conflictResolver) {
|
|
3084
|
+
this.set(key, conflictResolver(this.get(key), value, key));
|
|
3085
|
+
} else {
|
|
3086
|
+
this.set(key, value);
|
|
3087
|
+
}
|
|
3088
|
+
}
|
|
3089
|
+
return this;
|
|
3090
|
+
}
|
|
3091
|
+
some(fn) {
|
|
3092
|
+
for (const [key, value] of this.map) {
|
|
3093
|
+
if (fn(value, key)) return true;
|
|
3094
|
+
}
|
|
3095
|
+
return false;
|
|
3096
|
+
}
|
|
3097
|
+
every(fn) {
|
|
3098
|
+
for (const [key, value] of this.map) {
|
|
3099
|
+
if (!fn(value, key)) return false;
|
|
3100
|
+
}
|
|
3101
|
+
return true;
|
|
3102
|
+
}
|
|
3103
|
+
filter(predicate) {
|
|
3104
|
+
const result = new this.constructor();
|
|
3105
|
+
for (const [key, value] of this.map) {
|
|
3106
|
+
if (predicate(value, key, this)) result.set(key, value);
|
|
3107
|
+
}
|
|
3108
|
+
return result;
|
|
3109
|
+
}
|
|
3110
|
+
reduce(fn, init) {
|
|
3111
|
+
let iterator = this.entries();
|
|
3112
|
+
let first = iterator.next();
|
|
3113
|
+
if (first.done) {
|
|
3114
|
+
if (arguments.length < 2) {
|
|
3115
|
+
throw new TypeError("Reduce of empty UniMap with no initial value!");
|
|
3116
|
+
}
|
|
3117
|
+
return init;
|
|
3118
|
+
}
|
|
3119
|
+
let acc;
|
|
3120
|
+
let start;
|
|
3121
|
+
if (arguments.length < 2) {
|
|
3122
|
+
acc = first.value[1];
|
|
3123
|
+
start = iterator.next();
|
|
3124
|
+
} else {
|
|
3125
|
+
acc = init;
|
|
3126
|
+
start = first;
|
|
3127
|
+
}
|
|
3128
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
3129
|
+
const [key, value] = current.value;
|
|
3130
|
+
acc = fn(acc, value, key);
|
|
3131
|
+
}
|
|
3132
|
+
return acc;
|
|
3133
|
+
}
|
|
3134
|
+
mapEntries(fn) {
|
|
3135
|
+
let result = [];
|
|
3136
|
+
for (const [key, value] of this.map) {
|
|
3137
|
+
result.push(fn(value, key));
|
|
3138
|
+
}
|
|
3139
|
+
return result;
|
|
3140
|
+
}
|
|
3141
|
+
mapValues(fn) {
|
|
3142
|
+
let result = new _UniMap();
|
|
3143
|
+
for (const [key, value] of this.map) {
|
|
3144
|
+
result.set(key, fn(value, key));
|
|
3145
|
+
}
|
|
3146
|
+
return result;
|
|
3147
|
+
}
|
|
3148
|
+
toMap() {
|
|
3149
|
+
return new Map(this.map);
|
|
3150
|
+
}
|
|
3151
|
+
toString() {
|
|
3152
|
+
const entries = [...this.map].map(([k, v]) => `${stringify(k)} => ${stringify(v)}`).join(", ");
|
|
3153
|
+
return entries.length === 0 ? `Map(${this.size}){ }` : `Map(${this.size}){ ${entries} }`;
|
|
3154
|
+
}
|
|
3155
|
+
};
|
|
3156
|
+
var BiMap = class _BiMap extends BaseContainer {
|
|
3157
|
+
constructor(entries) {
|
|
3158
|
+
super();
|
|
3159
|
+
__publicField(this, "map1");
|
|
3160
|
+
__publicField(this, "key1Equals", DefaultEqualityFn);
|
|
3161
|
+
__publicField(this, "key2Equals", DefaultEqualityFn);
|
|
3162
|
+
this.map1 = new UniMap(this.key1Equals);
|
|
3163
|
+
if (entries instanceof _BiMap) {
|
|
3164
|
+
for (const [key1, map2] of entries.map1) {
|
|
3165
|
+
const newMap2 = this.map1.set(key1, new UniMap(this.key2Equals));
|
|
3166
|
+
for (const [key2, value] of map2) {
|
|
3167
|
+
newMap2.set(key2, value);
|
|
3168
|
+
}
|
|
3169
|
+
}
|
|
3170
|
+
} else if (entries) {
|
|
3171
|
+
for (const [key1, key2, value] of entries) {
|
|
3172
|
+
this.set(key1, key2, value);
|
|
3173
|
+
}
|
|
3174
|
+
}
|
|
3175
|
+
}
|
|
3176
|
+
has(key1, key2) {
|
|
3177
|
+
var _a, _b;
|
|
3178
|
+
return (_b = (_a = this.map1.get(key1)) == null ? void 0 : _a.has(key2)) != null ? _b : false;
|
|
3179
|
+
}
|
|
3180
|
+
set(key1, key2, value) {
|
|
3181
|
+
return this.map1.getOrCreate(key1, () => new UniMap(this.key2Equals)).set(key2, value);
|
|
3182
|
+
}
|
|
3183
|
+
get(key1, key2) {
|
|
3184
|
+
var _a;
|
|
3185
|
+
return (_a = this.map1.get(key1)) == null ? void 0 : _a.get(key2);
|
|
3186
|
+
}
|
|
3187
|
+
getOrDefault(key1, key2, defaultValue) {
|
|
3188
|
+
var _a;
|
|
3189
|
+
return (_a = this.get(key1, key2)) != null ? _a : defaultValue;
|
|
3190
|
+
}
|
|
3191
|
+
getOrCreate(key1, key2, creatorOrValue) {
|
|
3192
|
+
if (!this.has(key1, key2)) {
|
|
3193
|
+
const value = isFunction(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
3194
|
+
this.set(key1, key2, value);
|
|
3195
|
+
return value;
|
|
3196
|
+
}
|
|
3197
|
+
return this.get(key1, key2);
|
|
3198
|
+
}
|
|
3199
|
+
delete(key1, key2) {
|
|
3200
|
+
if (key2 === void 0) return this.map1.delete(key1);
|
|
3201
|
+
const map2 = this.map1.get(key1);
|
|
3202
|
+
if (!map2) return false;
|
|
3203
|
+
return map2.delete(key2);
|
|
3204
|
+
}
|
|
3205
|
+
clear() {
|
|
3206
|
+
this.map1.clear();
|
|
3207
|
+
}
|
|
3208
|
+
get size() {
|
|
3209
|
+
let count = 0;
|
|
3210
|
+
for (const map2 of this.map1.values()) {
|
|
3211
|
+
count += map2.size;
|
|
3212
|
+
}
|
|
3213
|
+
return count;
|
|
3214
|
+
}
|
|
3215
|
+
isEmpty() {
|
|
3216
|
+
return this.size === 0;
|
|
3217
|
+
}
|
|
3218
|
+
forEach(callbackfn, thisArg) {
|
|
3219
|
+
this.map1.forEach((map2, key1) => map2.forEach((value, key2) => callbackfn.call(thisArg, value, key1, key2, this)));
|
|
3220
|
+
}
|
|
3221
|
+
*keys() {
|
|
3222
|
+
for (const [key1, map2] of this.map1)
|
|
3223
|
+
for (const key2 of map2.keys())
|
|
3224
|
+
yield [key1, key2];
|
|
3225
|
+
}
|
|
3226
|
+
*values() {
|
|
3227
|
+
for (const map2 of this.map1.values())
|
|
3228
|
+
for (const value of map2.values())
|
|
3229
|
+
yield value;
|
|
3230
|
+
}
|
|
3231
|
+
*entries() {
|
|
3232
|
+
for (const [key1, map2] of this.map1)
|
|
3233
|
+
for (const [key2, value] of map2)
|
|
3234
|
+
yield [key1, key2, value];
|
|
3235
|
+
}
|
|
3236
|
+
keysArray() {
|
|
3237
|
+
return [...this.keys()];
|
|
3238
|
+
}
|
|
3239
|
+
valuesArray() {
|
|
3240
|
+
return [...this.values()];
|
|
3241
|
+
}
|
|
3242
|
+
entriesArray() {
|
|
3243
|
+
return [...this.entries()];
|
|
3244
|
+
}
|
|
3245
|
+
*kvKeys() {
|
|
3246
|
+
for (const [key1, key2] of this.keys())
|
|
3247
|
+
yield [key1, key2];
|
|
3248
|
+
}
|
|
3249
|
+
*kvValues() {
|
|
3250
|
+
for (const el of this.values())
|
|
3251
|
+
yield el;
|
|
3252
|
+
}
|
|
3253
|
+
*kvEntries() {
|
|
3254
|
+
for (const [key1, key2, el] of this.entries())
|
|
3255
|
+
yield [[key1, key2], el];
|
|
3256
|
+
}
|
|
3257
|
+
*[Symbol.iterator]() {
|
|
3258
|
+
yield* __yieldStar(this.entries());
|
|
3259
|
+
}
|
|
3260
|
+
clone() {
|
|
3261
|
+
return new _BiMap(this);
|
|
3262
|
+
}
|
|
3263
|
+
merge(other, conflictResolver) {
|
|
3264
|
+
for (const [key1, key2, value] of other.entries()) {
|
|
3265
|
+
if (this.has(key1, key2) && conflictResolver) {
|
|
3266
|
+
this.set(key1, key2, conflictResolver(this.get(key1, key2), value, key1, key2));
|
|
3267
|
+
} else {
|
|
3268
|
+
this.set(key1, key2, value);
|
|
3269
|
+
}
|
|
3270
|
+
}
|
|
3271
|
+
return this;
|
|
3272
|
+
}
|
|
3273
|
+
some(fn) {
|
|
3274
|
+
for (const [key1, map2] of this.map1) {
|
|
3275
|
+
for (const [key2, value] of map2) {
|
|
3276
|
+
if (fn(value, key1, key2)) return true;
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3279
|
+
return false;
|
|
3280
|
+
}
|
|
3281
|
+
every(fn) {
|
|
3282
|
+
for (const [key1, map2] of this.map1) {
|
|
3283
|
+
for (const [key2, value] of map2) {
|
|
3284
|
+
if (!fn(value, key1, key2)) return false;
|
|
3285
|
+
}
|
|
3286
|
+
}
|
|
3287
|
+
return true;
|
|
3288
|
+
}
|
|
3289
|
+
filter(predicate) {
|
|
3290
|
+
const result = new this.constructor();
|
|
3291
|
+
for (const [key1, map2] of this.map1) {
|
|
3292
|
+
for (const [key2, value] of map2) {
|
|
3293
|
+
if (predicate(value, key1, key2, this)) result.set(key1, key2, value);
|
|
3294
|
+
}
|
|
3295
|
+
}
|
|
3296
|
+
return result;
|
|
3297
|
+
}
|
|
3298
|
+
reduce(fn, init) {
|
|
3299
|
+
let iterator = this.entries();
|
|
3300
|
+
let first = iterator.next();
|
|
3301
|
+
if (first.done) {
|
|
3302
|
+
if (arguments.length < 2) {
|
|
3303
|
+
throw new TypeError("Reduce of empty BiMap with no initial value!");
|
|
3304
|
+
}
|
|
3305
|
+
return init;
|
|
3306
|
+
}
|
|
3307
|
+
let acc;
|
|
3308
|
+
let start;
|
|
3309
|
+
if (arguments.length < 2) {
|
|
3310
|
+
acc = first.value[2];
|
|
3311
|
+
start = iterator.next();
|
|
3312
|
+
} else {
|
|
3313
|
+
acc = init;
|
|
3314
|
+
start = first;
|
|
3315
|
+
}
|
|
3316
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
3317
|
+
const [key1, key2, value] = current.value;
|
|
3318
|
+
acc = fn(acc, value, key1, key2);
|
|
3319
|
+
}
|
|
3320
|
+
return acc;
|
|
3321
|
+
}
|
|
3322
|
+
mapEntries(fn) {
|
|
3323
|
+
let result = [];
|
|
3324
|
+
for (const [key1, map2] of this.map1) {
|
|
3325
|
+
for (const [key2, value] of map2) {
|
|
3326
|
+
result.push(fn(value, key1, key2));
|
|
3327
|
+
}
|
|
3328
|
+
}
|
|
3329
|
+
return result;
|
|
3330
|
+
}
|
|
3331
|
+
mapValues(fn) {
|
|
3332
|
+
let result = new _BiMap();
|
|
3333
|
+
for (const [key1, map2] of this.map1) {
|
|
3334
|
+
for (const [key2, value] of map2) {
|
|
3335
|
+
result.set(key1, key2, fn(value, key1, key2));
|
|
3336
|
+
}
|
|
3337
|
+
}
|
|
3338
|
+
return result;
|
|
3339
|
+
}
|
|
3340
|
+
toMap() {
|
|
3341
|
+
let result = /* @__PURE__ */ new Map();
|
|
3342
|
+
for (const [key1, map2] of this.map1) {
|
|
3343
|
+
for (const [key2, value] of map2) {
|
|
3344
|
+
result.set([key1, key2], value);
|
|
3345
|
+
}
|
|
3346
|
+
}
|
|
3347
|
+
return result;
|
|
3348
|
+
}
|
|
3349
|
+
toString() {
|
|
3350
|
+
const entries = [];
|
|
3351
|
+
for (const [key1, map2] of this.map1) {
|
|
3352
|
+
const inner = [...map2].map(([key2, v]) => `${stringify(key2)} => ${stringify(v)}`).join(", ");
|
|
3353
|
+
entries.push(`${stringify(key1)} => { ${inner} }`);
|
|
3354
|
+
}
|
|
3355
|
+
return entries.length === 0 ? `Map(${this.size}){ }` : `Map(${this.size}){ ${entries} }`;
|
|
3356
|
+
}
|
|
3357
|
+
};
|
|
3358
|
+
var TriMap = class _TriMap extends BaseContainer {
|
|
3359
|
+
constructor(entries) {
|
|
3360
|
+
super();
|
|
3361
|
+
__publicField(this, "map1");
|
|
3362
|
+
__publicField(this, "key1Equals", DefaultEqualityFn);
|
|
3363
|
+
__publicField(this, "key2Equals", DefaultEqualityFn);
|
|
3364
|
+
__publicField(this, "key3Equals", DefaultEqualityFn);
|
|
3365
|
+
this.map1 = new UniMap(this.key1Equals);
|
|
3366
|
+
if (entries instanceof _TriMap) {
|
|
3367
|
+
for (const [key1, map2] of entries.map1) {
|
|
3368
|
+
const newMap2 = this.map1.set(key1, new UniMap(this.key2Equals));
|
|
3369
|
+
for (const [key2, map3] of map2) {
|
|
3370
|
+
newMap2.set(key2, new UniMap(map3, this.key3Equals));
|
|
3371
|
+
}
|
|
3372
|
+
}
|
|
3373
|
+
} else if (entries) {
|
|
3374
|
+
for (const [key1, key2, key3, value] of entries) {
|
|
3375
|
+
this.set(key1, key2, key3, value);
|
|
3376
|
+
}
|
|
3377
|
+
}
|
|
3378
|
+
}
|
|
3379
|
+
has(key1, key2, key3) {
|
|
3380
|
+
var _a, _b, _c;
|
|
3381
|
+
return (_c = (_b = (_a = this.map1.get(key1)) == null ? void 0 : _a.get(key2)) == null ? void 0 : _b.has(key3)) != null ? _c : false;
|
|
3382
|
+
}
|
|
3383
|
+
set(key1, key2, key3, value) {
|
|
3384
|
+
let map2 = this.map1.getOrCreate(key1, () => new UniMap(this.key2Equals));
|
|
3385
|
+
let map3 = map2.getOrCreate(key2, () => new UniMap(this.key3Equals));
|
|
3386
|
+
map3.set(key3, value);
|
|
3387
|
+
return value;
|
|
3388
|
+
}
|
|
3389
|
+
get(key1, key2, key3) {
|
|
3390
|
+
var _a, _b;
|
|
3391
|
+
return (_b = (_a = this.map1.get(key1)) == null ? void 0 : _a.get(key2)) == null ? void 0 : _b.get(key3);
|
|
3392
|
+
}
|
|
3393
|
+
getOrDefault(key1, key2, key3, defaultValue) {
|
|
3394
|
+
var _a;
|
|
3395
|
+
return (_a = this.get(key1, key2, key3)) != null ? _a : defaultValue;
|
|
3396
|
+
}
|
|
3397
|
+
getOrCreate(key1, key2, key3, creatorOrValue) {
|
|
3398
|
+
if (!this.has(key1, key2, key3)) {
|
|
3399
|
+
const value = isFunction(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
3400
|
+
this.set(key1, key2, key3, value);
|
|
3401
|
+
return value;
|
|
3402
|
+
}
|
|
3403
|
+
return this.get(key1, key2, key3);
|
|
3404
|
+
}
|
|
3405
|
+
delete(key1, key2, key3) {
|
|
3406
|
+
var _a;
|
|
3407
|
+
if (key3 === void 0) {
|
|
3408
|
+
if (key2 === void 0) return this.map1.delete(key1);
|
|
3409
|
+
const map2 = this.map1.get(key1);
|
|
3410
|
+
if (!map2) return false;
|
|
3411
|
+
return map2.delete(key2);
|
|
3412
|
+
} else {
|
|
3413
|
+
if (key2 === void 0) return this.map1.delete(key1);
|
|
3414
|
+
const map3 = (_a = this.map1.get(key1)) == null ? void 0 : _a.get(key2);
|
|
3415
|
+
if (!map3) return false;
|
|
3416
|
+
return map3.delete(key3);
|
|
3417
|
+
}
|
|
3418
|
+
}
|
|
3419
|
+
clear() {
|
|
3420
|
+
this.map1.clear();
|
|
3421
|
+
}
|
|
3422
|
+
get size() {
|
|
3423
|
+
let count = 0;
|
|
3424
|
+
for (const map2 of this.map1.values()) {
|
|
3425
|
+
for (const map3 of map2.values()) {
|
|
3426
|
+
count += map3.size;
|
|
3427
|
+
}
|
|
3428
|
+
}
|
|
3429
|
+
return count;
|
|
3430
|
+
}
|
|
3431
|
+
isEmpty() {
|
|
3432
|
+
return this.size === 0;
|
|
3433
|
+
}
|
|
3434
|
+
forEach(callbackfn, thisArg) {
|
|
3435
|
+
this.map1.forEach((map2, key1) => map2.forEach((map3, key2) => map3.forEach((value, key3) => callbackfn.call(thisArg, value, key1, key2, key3, this))));
|
|
3436
|
+
}
|
|
3437
|
+
*keys() {
|
|
3438
|
+
for (const [key1, map2] of this.map1)
|
|
3439
|
+
for (const [key2, map3] of map2)
|
|
3440
|
+
for (const key3 of map3.keys())
|
|
3441
|
+
yield [key1, key2, key3];
|
|
3442
|
+
}
|
|
3443
|
+
*values() {
|
|
3444
|
+
for (const map2 of this.map1.values())
|
|
3445
|
+
for (const map3 of map2.values())
|
|
3446
|
+
for (const value of map3.values())
|
|
3447
|
+
yield value;
|
|
3448
|
+
}
|
|
3449
|
+
*entries() {
|
|
3450
|
+
for (const [key1, map2] of this.map1)
|
|
3451
|
+
for (const [key2, map3] of map2)
|
|
3452
|
+
for (const [key3, value] of map3)
|
|
3453
|
+
yield [key1, key2, key3, value];
|
|
3454
|
+
}
|
|
3455
|
+
keysArray() {
|
|
3456
|
+
return [...this.keys()];
|
|
3457
|
+
}
|
|
3458
|
+
valuesArray() {
|
|
3459
|
+
return [...this.values()];
|
|
3460
|
+
}
|
|
3461
|
+
entriesArray() {
|
|
3462
|
+
return [...this.entries()];
|
|
3463
|
+
}
|
|
3464
|
+
*kvKeys() {
|
|
3465
|
+
for (const [key1, key2, key3] of this.keys())
|
|
3466
|
+
yield [key1, key2, key3];
|
|
3467
|
+
}
|
|
3468
|
+
*kvValues() {
|
|
3469
|
+
for (const el of this.values())
|
|
3470
|
+
yield el;
|
|
3471
|
+
}
|
|
3472
|
+
*kvEntries() {
|
|
3473
|
+
for (const [key1, key2, key3, el] of this.entries())
|
|
3474
|
+
yield [[key1, key2, key3], el];
|
|
3475
|
+
}
|
|
3476
|
+
*[Symbol.iterator]() {
|
|
3477
|
+
yield* __yieldStar(this.entries());
|
|
3478
|
+
}
|
|
3479
|
+
clone() {
|
|
3480
|
+
return new _TriMap(this);
|
|
3481
|
+
}
|
|
3482
|
+
merge(other, conflictResolver) {
|
|
3483
|
+
for (const [key1, key2, key3, value] of other.entries()) {
|
|
3484
|
+
if (this.has(key1, key2, key3) && conflictResolver) {
|
|
3485
|
+
this.set(key1, key2, key3, conflictResolver(this.get(key1, key2, key3), value, key1, key2, key3));
|
|
3486
|
+
} else {
|
|
3487
|
+
this.set(key1, key2, key3, value);
|
|
3488
|
+
}
|
|
3489
|
+
}
|
|
3490
|
+
return this;
|
|
3491
|
+
}
|
|
3492
|
+
some(fn) {
|
|
3493
|
+
for (const [key1, map2] of this.map1) {
|
|
3494
|
+
for (const [key2, map3] of map2) {
|
|
3495
|
+
for (const [key3, value] of map3) {
|
|
3496
|
+
if (fn(value, key1, key2, key3)) return true;
|
|
3497
|
+
}
|
|
3498
|
+
}
|
|
3499
|
+
}
|
|
3500
|
+
return false;
|
|
3501
|
+
}
|
|
3502
|
+
every(fn) {
|
|
3503
|
+
for (const [key1, map2] of this.map1) {
|
|
3504
|
+
for (const [key2, map3] of map2) {
|
|
3505
|
+
for (const [key3, value] of map3) {
|
|
3506
|
+
if (!fn(value, key1, key2, key3)) return false;
|
|
3507
|
+
}
|
|
3508
|
+
}
|
|
3509
|
+
}
|
|
3510
|
+
return true;
|
|
3511
|
+
}
|
|
3512
|
+
filter(predicate) {
|
|
3513
|
+
const result = new this.constructor();
|
|
3514
|
+
for (const [key1, map2] of this.map1) {
|
|
3515
|
+
for (const [key2, map3] of map2) {
|
|
3516
|
+
for (const [key3, value] of map3) {
|
|
3517
|
+
if (predicate(value, key1, key2, key3, this)) result.set(key1, key2, key3, value);
|
|
3518
|
+
}
|
|
3519
|
+
}
|
|
3520
|
+
}
|
|
3521
|
+
return result;
|
|
3522
|
+
}
|
|
3523
|
+
reduce(fn, init) {
|
|
3524
|
+
let iterator = this.entries();
|
|
3525
|
+
let first = iterator.next();
|
|
3526
|
+
if (first.done) {
|
|
3527
|
+
if (arguments.length < 2) {
|
|
3528
|
+
throw new TypeError("Reduce of empty TriMap with no initial value!");
|
|
3529
|
+
}
|
|
3530
|
+
return init;
|
|
3531
|
+
}
|
|
3532
|
+
let acc;
|
|
3533
|
+
let start;
|
|
3534
|
+
if (arguments.length < 2) {
|
|
3535
|
+
acc = first.value[3];
|
|
3536
|
+
start = iterator.next();
|
|
3537
|
+
} else {
|
|
3538
|
+
acc = init;
|
|
3539
|
+
start = first;
|
|
3540
|
+
}
|
|
3541
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
3542
|
+
const [key1, key2, key3, value] = current.value;
|
|
3543
|
+
acc = fn(acc, value, key1, key2, key3);
|
|
3544
|
+
}
|
|
3545
|
+
return acc;
|
|
3546
|
+
}
|
|
3547
|
+
mapEntries(fn) {
|
|
3548
|
+
let result = [];
|
|
3549
|
+
for (const [key1, map2] of this.map1) {
|
|
3550
|
+
for (const [key2, map3] of map2) {
|
|
3551
|
+
for (const [key3, value] of map3) {
|
|
3552
|
+
result.push(fn(value, key1, key2, key3));
|
|
3553
|
+
}
|
|
3554
|
+
}
|
|
3555
|
+
}
|
|
3556
|
+
return result;
|
|
3557
|
+
}
|
|
3558
|
+
mapValues(fn) {
|
|
3559
|
+
let result = new _TriMap();
|
|
3560
|
+
for (const [key1, map2] of this.map1) {
|
|
3561
|
+
for (const [key2, map3] of map2) {
|
|
3562
|
+
for (const [key3, value] of map3) {
|
|
3563
|
+
result.set(key1, key2, key3, fn(value, key1, key2, key3));
|
|
3564
|
+
}
|
|
3565
|
+
}
|
|
3566
|
+
}
|
|
3567
|
+
return result;
|
|
3568
|
+
}
|
|
3569
|
+
toMap() {
|
|
3570
|
+
let result = /* @__PURE__ */ new Map();
|
|
3571
|
+
for (const [key1, map2] of this.map1) {
|
|
3572
|
+
for (const [key2, map3] of map2) {
|
|
3573
|
+
for (const [key3, value] of map3) {
|
|
3574
|
+
result.set([key1, key2, key3], value);
|
|
3575
|
+
}
|
|
3576
|
+
}
|
|
3577
|
+
}
|
|
3578
|
+
return result;
|
|
3579
|
+
}
|
|
3580
|
+
toString() {
|
|
3581
|
+
const entries = [];
|
|
3582
|
+
for (const [key1, map2] of this.map1) {
|
|
3583
|
+
for (const [key2, map3] of map2) {
|
|
3584
|
+
const inner = [...map3].map(([key3, v]) => `${stringify(key3)} => ${stringify(v)}`).join(", ");
|
|
3585
|
+
entries.push(`${stringify(key1)} => ${stringify(key2)} => { ${inner} }`);
|
|
3586
|
+
}
|
|
3587
|
+
}
|
|
3588
|
+
return entries.length === 0 ? `Map(${this.size}){ }` : `Map(${this.size}){ ${entries.join(", ")} }`;
|
|
3589
|
+
}
|
|
3590
|
+
};
|
|
3591
|
+
var ValueSet = class _ValueSet extends BaseContainer {
|
|
3592
|
+
constructor(...args) {
|
|
3593
|
+
super();
|
|
3594
|
+
__publicField(this, "data");
|
|
3595
|
+
__publicField(this, "equals");
|
|
3596
|
+
const maybeEquals = args.at(-1);
|
|
3597
|
+
this.equals = isFunction(maybeEquals) ? args.pop() : DefaultEqualityFn;
|
|
3598
|
+
const entries = args[0];
|
|
3599
|
+
this.data = new Set(entries);
|
|
3600
|
+
}
|
|
3601
|
+
static createDeep(arg) {
|
|
3602
|
+
return arg ? new _ValueSet(arg, isDeepEqual) : new _ValueSet(isDeepEqual);
|
|
3603
|
+
}
|
|
3604
|
+
has(value) {
|
|
3605
|
+
if (this.equals === DefaultEqualityFn)
|
|
3606
|
+
return this.data.has(value);
|
|
3607
|
+
return this.some((v) => this.equals(v, value));
|
|
3608
|
+
}
|
|
3609
|
+
add(value) {
|
|
3610
|
+
if (!this.has(value))
|
|
3611
|
+
this.data.add(value);
|
|
3612
|
+
return value;
|
|
3613
|
+
}
|
|
3614
|
+
/** @internal - This method exists only for interface `KVComponent` compatibility.*/
|
|
3615
|
+
set(key, value) {
|
|
3616
|
+
if (!this.equals(key, value))
|
|
3617
|
+
throw new TypeError("ValueSet.set() requires key === value.");
|
|
3618
|
+
this.add(value);
|
|
3619
|
+
}
|
|
3620
|
+
/** @internal - This method exists only for interface `KVComponent` compatibility.*/
|
|
3621
|
+
get(key) {
|
|
3622
|
+
return this.has(key) ? key : void 0;
|
|
3623
|
+
}
|
|
3624
|
+
/** @internal - This method exists only for interface `KVComponent` compatibility.*/
|
|
3625
|
+
getOrDefault(key, defaultValue) {
|
|
3626
|
+
var _a;
|
|
3627
|
+
return (_a = this.get(key)) != null ? _a : defaultValue;
|
|
3628
|
+
}
|
|
3629
|
+
getOrCreate(key, creatorOrValue) {
|
|
3630
|
+
if (!this.has(key)) {
|
|
3631
|
+
const value = isFunction(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
3632
|
+
this.set(key, value);
|
|
3633
|
+
return value;
|
|
3634
|
+
}
|
|
3635
|
+
return this.get(key);
|
|
3636
|
+
}
|
|
3637
|
+
delete(value) {
|
|
3638
|
+
if (this.equals === DefaultEqualityFn || this.data.has(value))
|
|
3639
|
+
return this.data.delete(value);
|
|
3640
|
+
for (const v of this.values()) {
|
|
3641
|
+
if (this.equals(v, value)) {
|
|
3642
|
+
this.data.delete(v);
|
|
3643
|
+
return true;
|
|
3644
|
+
}
|
|
3645
|
+
}
|
|
3646
|
+
return false;
|
|
3647
|
+
}
|
|
3648
|
+
clear() {
|
|
3649
|
+
this.data.clear();
|
|
3650
|
+
}
|
|
3651
|
+
get size() {
|
|
3652
|
+
return this.data.size;
|
|
3653
|
+
}
|
|
3654
|
+
isEmpty() {
|
|
3655
|
+
return this.size === 0;
|
|
3656
|
+
}
|
|
3657
|
+
forEach(callbackfn, thisArg) {
|
|
3658
|
+
this.data.forEach((value) => callbackfn.call(thisArg, value, this));
|
|
3659
|
+
}
|
|
3660
|
+
*keys() {
|
|
3661
|
+
yield* __yieldStar(this.data.keys());
|
|
3662
|
+
}
|
|
3663
|
+
*values() {
|
|
3664
|
+
yield* __yieldStar(this.data.values());
|
|
3665
|
+
}
|
|
3666
|
+
*entries() {
|
|
3667
|
+
yield* __yieldStar(this.data.entries());
|
|
3668
|
+
}
|
|
3669
|
+
*kvKeys() {
|
|
3670
|
+
for (const key of this.keys()) {
|
|
3671
|
+
yield [key];
|
|
3672
|
+
}
|
|
3673
|
+
}
|
|
3674
|
+
*kvValues() {
|
|
3675
|
+
for (const el of this.values()) {
|
|
3676
|
+
yield el;
|
|
3677
|
+
}
|
|
3678
|
+
}
|
|
3679
|
+
*kvEntries() {
|
|
3680
|
+
for (const [key, el] of this.entries()) {
|
|
3681
|
+
yield [[key], el];
|
|
3682
|
+
}
|
|
3683
|
+
}
|
|
3684
|
+
*[Symbol.iterator]() {
|
|
3685
|
+
yield* __yieldStar(this.values());
|
|
3686
|
+
}
|
|
3687
|
+
clone() {
|
|
3688
|
+
const result = new _ValueSet();
|
|
3689
|
+
for (const v of this.values()) result.add(v);
|
|
3690
|
+
return result;
|
|
3691
|
+
}
|
|
3692
|
+
merge(other) {
|
|
3693
|
+
for (const value of other.values()) {
|
|
3694
|
+
this.add(value);
|
|
3695
|
+
}
|
|
3696
|
+
return this;
|
|
3697
|
+
}
|
|
3698
|
+
some(fn) {
|
|
3699
|
+
for (const value of this.data) {
|
|
3700
|
+
if (fn(value)) return true;
|
|
3701
|
+
}
|
|
3702
|
+
return false;
|
|
3703
|
+
}
|
|
3704
|
+
every(fn) {
|
|
3705
|
+
for (const value of this.data) {
|
|
3706
|
+
if (!fn(value)) return false;
|
|
3707
|
+
}
|
|
3708
|
+
return true;
|
|
3709
|
+
}
|
|
3710
|
+
filter(predicate) {
|
|
3711
|
+
const result = new _ValueSet();
|
|
3712
|
+
for (const value of this.data)
|
|
3713
|
+
if (predicate(value, this)) result.add(value);
|
|
3714
|
+
return result;
|
|
3715
|
+
}
|
|
3716
|
+
reduce(fn, init) {
|
|
3717
|
+
let iterator = this.values();
|
|
3718
|
+
let first = iterator.next();
|
|
3719
|
+
if (first.done) {
|
|
3720
|
+
if (arguments.length < 2) {
|
|
3721
|
+
throw new TypeError("Reduce of empty ValueSet with no initial value!");
|
|
3722
|
+
}
|
|
3723
|
+
return init;
|
|
3724
|
+
}
|
|
3725
|
+
let acc;
|
|
3726
|
+
let start;
|
|
3727
|
+
if (arguments.length < 2) {
|
|
3728
|
+
acc = first.value;
|
|
3729
|
+
start = iterator.next();
|
|
3730
|
+
} else {
|
|
3731
|
+
acc = init;
|
|
3732
|
+
start = first;
|
|
3733
|
+
}
|
|
3734
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
3735
|
+
const value = current.value;
|
|
3736
|
+
acc = fn(acc, value);
|
|
3737
|
+
}
|
|
3738
|
+
return acc;
|
|
3739
|
+
}
|
|
3740
|
+
mapValues(fn) {
|
|
3741
|
+
let result = new _ValueSet();
|
|
3742
|
+
for (const value of this.data) {
|
|
3743
|
+
result.add(fn(value));
|
|
3744
|
+
}
|
|
3745
|
+
return result;
|
|
3746
|
+
}
|
|
3747
|
+
mapToArray(fn) {
|
|
3748
|
+
let result = [];
|
|
3749
|
+
for (const value of this.values()) {
|
|
3750
|
+
result.push(fn(value));
|
|
3751
|
+
}
|
|
3752
|
+
return result;
|
|
3753
|
+
}
|
|
3754
|
+
map(fn) {
|
|
3755
|
+
let result = new _ValueSet();
|
|
3756
|
+
for (const value of this.values()) {
|
|
3757
|
+
result.add(fn(value));
|
|
3758
|
+
}
|
|
3759
|
+
return result;
|
|
3760
|
+
}
|
|
3761
|
+
toSet() {
|
|
3762
|
+
return new Set(this.data);
|
|
3763
|
+
}
|
|
3764
|
+
toArray() {
|
|
3765
|
+
return [...this.values()];
|
|
3766
|
+
}
|
|
3767
|
+
toString() {
|
|
3768
|
+
return stringify(this.data);
|
|
3769
|
+
}
|
|
3770
|
+
};
|
|
3771
|
+
var MultiContainer = class extends BaseContainer {
|
|
3772
|
+
constructor(base) {
|
|
3773
|
+
super();
|
|
3774
|
+
this.base = base;
|
|
3775
|
+
}
|
|
3776
|
+
isEmpty() {
|
|
3777
|
+
return this.base.isEmpty();
|
|
3778
|
+
}
|
|
3779
|
+
clear() {
|
|
3780
|
+
var _a, _b;
|
|
3781
|
+
(_b = (_a = this.base).clear) == null ? void 0 : _b.call(_a);
|
|
3782
|
+
}
|
|
3783
|
+
add(...keysAndValue) {
|
|
3784
|
+
const keys = keysAndValue.slice(0, -1);
|
|
3785
|
+
const value = keysAndValue[keysAndValue.length - 1];
|
|
3786
|
+
const arr = this.base.get(...keys);
|
|
3787
|
+
this.base.set(...[...keys, arr ? [...arr, value] : [value]]);
|
|
3788
|
+
return value;
|
|
3789
|
+
}
|
|
3790
|
+
remove(...keysAndValue) {
|
|
3791
|
+
const keys = keysAndValue.slice(0, -1);
|
|
3792
|
+
const value = keysAndValue[keysAndValue.length - 1];
|
|
3793
|
+
const arr = this.base.get(...keys);
|
|
3794
|
+
if (!arr) return false;
|
|
3795
|
+
const i = arr.indexOf(value);
|
|
3796
|
+
if (i === -1) return false;
|
|
3797
|
+
arr.splice(i, 1);
|
|
3798
|
+
if (arr.length === 0) this.base.delete(...keys);
|
|
3799
|
+
return true;
|
|
3800
|
+
}
|
|
3801
|
+
getAll(...keys) {
|
|
3802
|
+
var _a;
|
|
3803
|
+
return (_a = this.base.get(...keys)) != null ? _a : [];
|
|
3804
|
+
}
|
|
3805
|
+
*iterAll(...keys) {
|
|
3806
|
+
yield* __yieldStar(this.getAll(...keys));
|
|
3807
|
+
}
|
|
3808
|
+
*values() {
|
|
3809
|
+
for (const keys of this.keys()) {
|
|
3810
|
+
yield* __yieldStar(this.getAll(...keys));
|
|
3811
|
+
}
|
|
3812
|
+
}
|
|
3813
|
+
*keys() {
|
|
3814
|
+
for (const keys of this.base.kvKeys()) {
|
|
3815
|
+
yield keys;
|
|
3816
|
+
}
|
|
3817
|
+
}
|
|
3818
|
+
*entries() {
|
|
3819
|
+
for (const keys of this.keys()) {
|
|
3820
|
+
const arr = this.getAll(...keys);
|
|
3821
|
+
if (arr.length > 0) yield [keys, arr];
|
|
3822
|
+
}
|
|
3823
|
+
}
|
|
3824
|
+
[Symbol.iterator]() {
|
|
3825
|
+
return this.entries();
|
|
3826
|
+
}
|
|
3827
|
+
toString() {
|
|
3828
|
+
const entries = [];
|
|
3829
|
+
for (const keys of this.keys()) {
|
|
3830
|
+
const arr = this.getAll(...keys);
|
|
3831
|
+
const keyStr = Array.isArray(keys) ? stringify(keys) : "[ ]";
|
|
3832
|
+
const valuesStr = Array.isArray(arr) ? stringify(arr) : "[ ]";
|
|
3833
|
+
entries.push(`${keyStr} => ${valuesStr}`);
|
|
3834
|
+
}
|
|
3835
|
+
return entries.length === 0 ? `MultiContainer{ }` : `MultiContainer{ ${entries.join(", ")} }`;
|
|
3836
|
+
}
|
|
3837
|
+
};
|
|
3838
|
+
function asMulti(base) {
|
|
3839
|
+
return new MultiContainer(base);
|
|
3840
|
+
}
|
|
3841
|
+
|
|
3842
|
+
export {
|
|
3843
|
+
guard_exports,
|
|
3844
|
+
device_exports,
|
|
3845
|
+
utils_exports,
|
|
3846
|
+
Vec,
|
|
3847
|
+
Rect,
|
|
3848
|
+
AnchoredRect,
|
|
3849
|
+
LRUCache,
|
|
3850
|
+
IndexArray,
|
|
3851
|
+
SignedIndexArray,
|
|
3852
|
+
UniMap,
|
|
3853
|
+
BiMap,
|
|
3854
|
+
TriMap,
|
|
3855
|
+
ValueSet,
|
|
3856
|
+
asMulti
|
|
3857
|
+
};
|
|
3858
|
+
/*! Bundled license information:
|
|
3859
|
+
|
|
3860
|
+
@tspro/ts-utils-lib/dist/index.mjs:
|
|
3861
|
+
(*!
|
|
3862
|
+
* TsUtilsLib v2.2.1 (esm)
|
|
3863
|
+
* (c) 2023-2025 PahkaSoft
|
|
3864
|
+
* Licensed under the MIT License
|
|
3865
|
+
*)
|
|
3866
|
+
*/
|
|
3867
|
+
//# sourceMappingURL=chunk-X7BMJX7E.mjs.map
|