@tspro/web-music-score 5.4.2 → 5.5.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 +15 -0
- package/LICENSE +24 -0
- package/README.md +8 -546
- package/dist/audio/index.d.ts +1 -1
- package/dist/audio/index.js +1748 -5
- package/dist/audio/index.mjs +9 -6
- package/dist/audio-cg/index.js +17487 -46
- package/dist/audio-cg/index.mjs +7 -5
- package/dist/audio-synth/index.js +18434 -32
- package/dist/audio-synth/index.mjs +12 -7
- package/dist/chunk-7GVRGM3N.mjs +101 -0
- package/dist/chunk-AUOH7S2E.mjs +3877 -0
- package/dist/{chunk-MMWSQGVR.mjs → chunk-BZE5UGTJ.mjs} +3 -3
- package/dist/{chunk-CVYTUTL6.mjs → chunk-FLBNOYUN.mjs} +2 -2
- package/dist/{chunk-42IBAVOC.mjs → chunk-KKIFSIFK.mjs} +18 -13
- package/dist/chunk-L7VPSGMT.mjs +18381 -0
- package/dist/core/index.js +2 -2
- package/dist/core/index.mjs +4 -4
- package/dist/{guitar-CNOxM4ZK.d.ts → guitar-CarHGDAt.d.ts} +1 -1
- package/dist/iife/audio-cg.global.js +1 -1
- package/dist/iife/index.global.js +13 -13
- package/dist/{music-objects-DqoO-Sfv.d.mts → music-objects-CcJvZxS6.d.mts} +123 -96
- package/dist/{music-objects-T8u8bnNP.d.ts → music-objects-l5Ai97QA.d.ts} +125 -98
- package/dist/{note-RVXvpfyV.d.ts → note-CJuq5aBy.d.ts} +1 -1
- package/dist/pieces/index.d.mts +12 -6
- package/dist/pieces/index.d.ts +14 -8
- package/dist/pieces/index.js +25 -13
- package/dist/pieces/index.mjs +25 -14
- package/dist/react-ui/index.d.mts +1 -1
- package/dist/react-ui/index.d.ts +5 -5
- package/dist/react-ui/index.js +2274 -22
- package/dist/react-ui/index.mjs +18 -15
- package/dist/{scale-CUYFBo-8.d.ts → scale-DulPFco_.d.ts} +2 -2
- package/dist/score/index.d.mts +51 -3
- package/dist/score/index.d.ts +54 -6
- package/dist/score/index.js +4941 -872
- package/dist/score/index.mjs +1282 -729
- package/dist/{tempo-DwuZsv2T.d.ts → tempo-BnUjm25M.d.ts} +1 -1
- package/dist/theory/index.d.ts +6 -6
- package/dist/theory/index.js +2687 -136
- package/dist/theory/index.mjs +41 -49
- package/package.json +4 -5
- package/dist/chunk-ROBXPR34.mjs +0 -9
package/dist/theory/index.js
CHANGED
|
@@ -1,87 +1,2641 @@
|
|
|
1
|
-
/* WebMusicScore v5.
|
|
1
|
+
/* WebMusicScore v5.5.1 | (c) 2023-2025 PahkaSoft | MIT License | Includes: Tone.js (MIT License), Color Name to Code (MIT License) */
|
|
2
2
|
"use strict";
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
8
|
+
var __typeError = (msg) => {
|
|
9
|
+
throw TypeError(msg);
|
|
10
|
+
};
|
|
7
11
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
12
|
var __export = (target, all) => {
|
|
9
13
|
for (var name in all)
|
|
10
14
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
15
|
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toCommonJS = (mod3) => __copyProps(__defProp({}, "__esModule", { value: true }), mod3);
|
|
25
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
26
|
+
var __await = function(promise, isYieldStar) {
|
|
27
|
+
this[0] = promise;
|
|
28
|
+
this[1] = isYieldStar;
|
|
29
|
+
};
|
|
30
|
+
var __yieldStar = (value) => {
|
|
31
|
+
var obj = value[__knownSymbol("asyncIterator")], isAwait = false, method, it = {};
|
|
32
|
+
if (obj == null) {
|
|
33
|
+
obj = value[__knownSymbol("iterator")]();
|
|
34
|
+
method = (k) => it[k] = (x) => obj[k](x);
|
|
35
|
+
} else {
|
|
36
|
+
obj = obj.call(value);
|
|
37
|
+
method = (k) => it[k] = (v) => {
|
|
38
|
+
if (isAwait) {
|
|
39
|
+
isAwait = false;
|
|
40
|
+
if (k === "throw") throw v;
|
|
41
|
+
return v;
|
|
42
|
+
}
|
|
43
|
+
isAwait = true;
|
|
44
|
+
return {
|
|
45
|
+
done: false,
|
|
46
|
+
value: new __await(new Promise((resolve) => {
|
|
47
|
+
var x = obj[k](v);
|
|
48
|
+
if (!(x instanceof Object)) __typeError("Object expected");
|
|
49
|
+
resolve(x);
|
|
50
|
+
}), 1)
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x) => {
|
|
55
|
+
throw x;
|
|
56
|
+
}, "return" in obj && method("return"), it;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// src/theory/index.ts
|
|
60
|
+
var theory_exports = {};
|
|
61
|
+
__export(theory_exports, {
|
|
62
|
+
AccidentalType: () => AccidentalType,
|
|
63
|
+
BeamGrouping: () => BeamGrouping,
|
|
64
|
+
Chord: () => Chord,
|
|
65
|
+
DefaultGuitarNoteLabel: () => DefaultGuitarNoteLabel,
|
|
66
|
+
DefaultHandedness: () => DefaultHandedness,
|
|
67
|
+
DefaultPitchNotation: () => DefaultPitchNotation,
|
|
68
|
+
DefaultTuningName: () => DefaultTuningName,
|
|
69
|
+
GuitarNoteLabel: () => GuitarNoteLabel,
|
|
70
|
+
GuitarNoteLabelList: () => GuitarNoteLabelList,
|
|
71
|
+
Handedness: () => Handedness,
|
|
72
|
+
Interval: () => Interval,
|
|
73
|
+
KeySignature: () => KeySignature,
|
|
74
|
+
Mode: () => Mode,
|
|
75
|
+
Note: () => Note,
|
|
76
|
+
NoteLength: () => NoteLength,
|
|
77
|
+
NoteLengthProps: () => NoteLengthProps,
|
|
78
|
+
PitchNotation: () => PitchNotation,
|
|
79
|
+
PitchNotationList: () => PitchNotationList,
|
|
80
|
+
RhythmProps: () => RhythmProps,
|
|
81
|
+
Scale: () => Scale,
|
|
82
|
+
ScaleFactory: () => ScaleFactory,
|
|
83
|
+
ScaleType: () => ScaleType,
|
|
84
|
+
SymbolSet: () => SymbolSet,
|
|
85
|
+
TimeSignature: () => TimeSignature,
|
|
86
|
+
TimeSignatures: () => TimeSignatures,
|
|
87
|
+
TuningNameList: () => TuningNameList,
|
|
88
|
+
Tuplet: () => Tuplet,
|
|
89
|
+
alterTempoSpeed: () => alterTempoSpeed,
|
|
90
|
+
getDefaultKeySignature: () => getDefaultKeySignature,
|
|
91
|
+
getDefaultScale: () => getDefaultScale,
|
|
92
|
+
getDefaultTempo: () => getDefaultTempo,
|
|
93
|
+
getDefaultTimeSignature: () => getDefaultTimeSignature,
|
|
94
|
+
getPitchNotationName: () => getPitchNotationName,
|
|
95
|
+
getScale: () => getScale,
|
|
96
|
+
getScaleFactory: () => getScaleFactory,
|
|
97
|
+
getScaleFactoryList: () => getScaleFactoryList,
|
|
98
|
+
getTempoString: () => getTempoString,
|
|
99
|
+
getTuningStrings: () => getTuningStrings,
|
|
100
|
+
isNoteLength: () => isNoteLength,
|
|
101
|
+
isTupletRatio: () => isTupletRatio,
|
|
102
|
+
validateGuitarNoteLabel: () => validateGuitarNoteLabel,
|
|
103
|
+
validateHandedness: () => validateHandedness,
|
|
104
|
+
validateIntervalQuality: () => validateIntervalQuality,
|
|
105
|
+
validateNoteLength: () => validateNoteLength,
|
|
106
|
+
validatePitchNotation: () => validatePitchNotation,
|
|
107
|
+
validateScaleType: () => validateScaleType,
|
|
108
|
+
validateTuningName: () => validateTuningName,
|
|
109
|
+
validateTupletRatio: () => validateTupletRatio
|
|
110
|
+
});
|
|
111
|
+
module.exports = __toCommonJS(theory_exports);
|
|
112
|
+
|
|
113
|
+
// node_modules/@tspro/ts-utils-lib/dist/index.mjs
|
|
114
|
+
var __defProp2 = Object.defineProperty;
|
|
115
|
+
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
116
|
+
var __export2 = (target, all) => {
|
|
117
|
+
for (var name in all)
|
|
118
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
119
|
+
};
|
|
120
|
+
var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
121
|
+
var assert_exports = {};
|
|
122
|
+
__export2(assert_exports, {
|
|
123
|
+
assert: () => assert,
|
|
124
|
+
doesNotThrow: () => doesNotThrow2,
|
|
125
|
+
doesThrow: () => doesThrow2,
|
|
126
|
+
fail: () => fail,
|
|
127
|
+
isArray: () => isArray2,
|
|
128
|
+
isArrayOrUndefined: () => isArrayOrUndefined2,
|
|
129
|
+
isBigInt: () => isBigInt2,
|
|
130
|
+
isBoolean: () => isBoolean2,
|
|
131
|
+
isBooleanOrUndefined: () => isBooleanOrUndefined2,
|
|
132
|
+
isDeepEqual: () => isDeepEqual2,
|
|
133
|
+
isDefined: () => isDefined2,
|
|
134
|
+
isEmptyArray: () => isEmptyArray2,
|
|
135
|
+
isEmptyArrayOrUndefined: () => isEmptyArrayOrUndefined2,
|
|
136
|
+
isEmptyObject: () => isEmptyObject2,
|
|
137
|
+
isEmptyString: () => isEmptyString2,
|
|
138
|
+
isEmptyStringOrUndefined: () => isEmptyStringOrUndefined2,
|
|
139
|
+
isEnumValue: () => isEnumValue2,
|
|
140
|
+
isEnumValueOrUndefined: () => isEnumValueOrUndefined2,
|
|
141
|
+
isEven: () => isEven2,
|
|
142
|
+
isFalse: () => isFalse2,
|
|
143
|
+
isFalseOrUndefined: () => isFalseOrUndefined2,
|
|
144
|
+
isFinite: () => isFinite3,
|
|
145
|
+
isFloat: () => isFloat2,
|
|
146
|
+
isFunction: () => isFunction2,
|
|
147
|
+
isFunctionOrUndefined: () => isFunctionOrUndefined2,
|
|
148
|
+
isIncluded: () => isIncluded2,
|
|
149
|
+
isIndex: () => isIndex2,
|
|
150
|
+
isInfinity: () => isInfinity2,
|
|
151
|
+
isInteger: () => isInteger2,
|
|
152
|
+
isIntegerBetween: () => isIntegerBetween2,
|
|
153
|
+
isIntegerBetweenExclusive: () => isIntegerBetweenExclusive2,
|
|
154
|
+
isIntegerEq: () => isIntegerEq2,
|
|
155
|
+
isIntegerGt: () => isIntegerGt2,
|
|
156
|
+
isIntegerGte: () => isIntegerGte2,
|
|
157
|
+
isIntegerLt: () => isIntegerLt2,
|
|
158
|
+
isIntegerLte: () => isIntegerLte2,
|
|
159
|
+
isIntegerOrUndefined: () => isIntegerOrUndefined2,
|
|
160
|
+
isMultipleOf: () => isMultipleOf2,
|
|
161
|
+
isNaNValue: () => isNaNValue2,
|
|
162
|
+
isNeg: () => isNeg2,
|
|
163
|
+
isNegInfinity: () => isNegInfinity2,
|
|
164
|
+
isNegZero: () => isNegZero2,
|
|
165
|
+
isNonEmptyArray: () => isNonEmptyArray2,
|
|
166
|
+
isNonEmptyArrayOrUndefined: () => isNonEmptyArrayOrUndefined2,
|
|
167
|
+
isNonEmptyString: () => isNonEmptyString2,
|
|
168
|
+
isNonEmptyStringOrUndefined: () => isNonEmptyStringOrUndefined2,
|
|
169
|
+
isNonNeg: () => isNonNeg2,
|
|
170
|
+
isNonNull: () => isNonNull2,
|
|
171
|
+
isNonPos: () => isNonPos2,
|
|
172
|
+
isNull: () => isNull2,
|
|
173
|
+
isNullish: () => isNullish2,
|
|
174
|
+
isNumber: () => isNumber2,
|
|
175
|
+
isNumberBetween: () => isNumberBetween2,
|
|
176
|
+
isNumberBetweenExclusive: () => isNumberBetweenExclusive2,
|
|
177
|
+
isNumberEq: () => isNumberEq2,
|
|
178
|
+
isNumberGt: () => isNumberGt2,
|
|
179
|
+
isNumberGte: () => isNumberGte2,
|
|
180
|
+
isNumberLt: () => isNumberLt2,
|
|
181
|
+
isNumberLte: () => isNumberLte2,
|
|
182
|
+
isNumberOrUndefined: () => isNumberOrUndefined2,
|
|
183
|
+
isNumericString: () => isNumericString2,
|
|
184
|
+
isObject: () => isObject2,
|
|
185
|
+
isObjectOrUndefined: () => isObjectOrUndefined2,
|
|
186
|
+
isOdd: () => isOdd2,
|
|
187
|
+
isPlainObject: () => isPlainObject2,
|
|
188
|
+
isPos: () => isPos2,
|
|
189
|
+
isPosInfinity: () => isPosInfinity2,
|
|
190
|
+
isPosZero: () => isPosZero2,
|
|
191
|
+
isPowerOfTwo: () => isPowerOfTwo2,
|
|
192
|
+
isSafeInteger: () => isSafeInteger2,
|
|
193
|
+
isSafeNumber: () => isSafeNumber2,
|
|
194
|
+
isStrictEqual: () => isStrictEqual2,
|
|
195
|
+
isString: () => isString2,
|
|
196
|
+
isStringOrUndefined: () => isStringOrUndefined2,
|
|
197
|
+
isTrue: () => isTrue2,
|
|
198
|
+
isTrueOrUndefined: () => isTrueOrUndefined2,
|
|
199
|
+
isTypedObject: () => isTypedObject2,
|
|
200
|
+
isUndefined: () => isUndefined2,
|
|
201
|
+
isZero: () => isZero2,
|
|
202
|
+
require: () => require2,
|
|
203
|
+
requireDefined: () => requireDefined,
|
|
204
|
+
requireElement: () => requireElement,
|
|
205
|
+
setErrorClass: () => setErrorClass
|
|
206
|
+
});
|
|
207
|
+
var str_exports = {};
|
|
208
|
+
__export2(str_exports, {
|
|
209
|
+
charCount: () => charCount,
|
|
210
|
+
chunkString: () => chunkString,
|
|
211
|
+
insertAt: () => insertAt,
|
|
212
|
+
isString: () => isString,
|
|
213
|
+
makeSentenceFromPascal: () => makeSentenceFromPascal,
|
|
214
|
+
removeAt: () => removeAt,
|
|
215
|
+
repeatString: () => repeatString,
|
|
216
|
+
replaceAt: () => replaceAt,
|
|
217
|
+
splitByCaps: () => splitByCaps,
|
|
218
|
+
splitByChars: () => splitByChars,
|
|
219
|
+
splitByStrings: () => splitByStrings,
|
|
220
|
+
stringify: () => stringify,
|
|
221
|
+
toCharArray: () => toCharArray
|
|
222
|
+
});
|
|
223
|
+
var obj_exports = {};
|
|
224
|
+
__export2(obj_exports, {
|
|
225
|
+
deepEqual: () => deepEqual,
|
|
226
|
+
getCtorName: () => getCtorName,
|
|
227
|
+
hasProperties: () => hasProperties,
|
|
228
|
+
isObject: () => isObject
|
|
229
|
+
});
|
|
230
|
+
var guard_exports = {};
|
|
231
|
+
__export2(guard_exports, {
|
|
232
|
+
doesNotThrow: () => doesNotThrow,
|
|
233
|
+
doesThrow: () => doesThrow,
|
|
234
|
+
isArray: () => isArray,
|
|
235
|
+
isArrayOrUndefined: () => isArrayOrUndefined,
|
|
236
|
+
isBigInt: () => isBigInt,
|
|
237
|
+
isBoolean: () => isBoolean,
|
|
238
|
+
isBooleanOrUndefined: () => isBooleanOrUndefined,
|
|
239
|
+
isDeepEqual: () => isDeepEqual,
|
|
240
|
+
isDefined: () => isDefined,
|
|
241
|
+
isEmptyArray: () => isEmptyArray,
|
|
242
|
+
isEmptyArrayOrUndefined: () => isEmptyArrayOrUndefined,
|
|
243
|
+
isEmptyObject: () => isEmptyObject,
|
|
244
|
+
isEmptyString: () => isEmptyString,
|
|
245
|
+
isEmptyStringOrUndefined: () => isEmptyStringOrUndefined,
|
|
246
|
+
isEnumValue: () => isEnumValue,
|
|
247
|
+
isEnumValueOrUndefined: () => isEnumValueOrUndefined,
|
|
248
|
+
isEven: () => isEven,
|
|
249
|
+
isFalse: () => isFalse,
|
|
250
|
+
isFalseOrUndefined: () => isFalseOrUndefined,
|
|
251
|
+
isFinite: () => isFinite2,
|
|
252
|
+
isFloat: () => isFloat,
|
|
253
|
+
isFunction: () => isFunction,
|
|
254
|
+
isFunctionOrUndefined: () => isFunctionOrUndefined,
|
|
255
|
+
isIncluded: () => isIncluded,
|
|
256
|
+
isIndex: () => isIndex,
|
|
257
|
+
isInfinity: () => isInfinity,
|
|
258
|
+
isInteger: () => isInteger,
|
|
259
|
+
isIntegerBetween: () => isIntegerBetween,
|
|
260
|
+
isIntegerBetweenExclusive: () => isIntegerBetweenExclusive,
|
|
261
|
+
isIntegerEq: () => isIntegerEq,
|
|
262
|
+
isIntegerGt: () => isIntegerGt,
|
|
263
|
+
isIntegerGte: () => isIntegerGte,
|
|
264
|
+
isIntegerLt: () => isIntegerLt,
|
|
265
|
+
isIntegerLte: () => isIntegerLte,
|
|
266
|
+
isIntegerOrUndefined: () => isIntegerOrUndefined,
|
|
267
|
+
isMultipleOf: () => isMultipleOf,
|
|
268
|
+
isNaNValue: () => isNaNValue,
|
|
269
|
+
isNeg: () => isNeg,
|
|
270
|
+
isNegInfinity: () => isNegInfinity,
|
|
271
|
+
isNegZero: () => isNegZero,
|
|
272
|
+
isNonEmptyArray: () => isNonEmptyArray,
|
|
273
|
+
isNonEmptyArrayOrUndefined: () => isNonEmptyArrayOrUndefined,
|
|
274
|
+
isNonEmptyString: () => isNonEmptyString,
|
|
275
|
+
isNonEmptyStringOrUndefined: () => isNonEmptyStringOrUndefined,
|
|
276
|
+
isNonNeg: () => isNonNeg,
|
|
277
|
+
isNonNull: () => isNonNull,
|
|
278
|
+
isNonPos: () => isNonPos,
|
|
279
|
+
isNull: () => isNull,
|
|
280
|
+
isNullish: () => isNullish,
|
|
281
|
+
isNumber: () => isNumber,
|
|
282
|
+
isNumberBetween: () => isNumberBetween,
|
|
283
|
+
isNumberBetweenExclusive: () => isNumberBetweenExclusive,
|
|
284
|
+
isNumberEq: () => isNumberEq,
|
|
285
|
+
isNumberGt: () => isNumberGt,
|
|
286
|
+
isNumberGte: () => isNumberGte,
|
|
287
|
+
isNumberLt: () => isNumberLt,
|
|
288
|
+
isNumberLte: () => isNumberLte,
|
|
289
|
+
isNumberOrUndefined: () => isNumberOrUndefined,
|
|
290
|
+
isNumericString: () => isNumericString,
|
|
291
|
+
isObject: () => isObject,
|
|
292
|
+
isObjectOrUndefined: () => isObjectOrUndefined,
|
|
293
|
+
isOdd: () => isOdd,
|
|
294
|
+
isPlainObject: () => isPlainObject,
|
|
295
|
+
isPos: () => isPos,
|
|
296
|
+
isPosInfinity: () => isPosInfinity,
|
|
297
|
+
isPosZero: () => isPosZero,
|
|
298
|
+
isPowerOfTwo: () => isPowerOfTwo,
|
|
299
|
+
isSafeInteger: () => isSafeInteger,
|
|
300
|
+
isSafeNumber: () => isSafeNumber,
|
|
301
|
+
isStrictEqual: () => isStrictEqual,
|
|
302
|
+
isString: () => isString,
|
|
303
|
+
isStringOrUndefined: () => isStringOrUndefined,
|
|
304
|
+
isTrue: () => isTrue,
|
|
305
|
+
isTrueOrUndefined: () => isTrueOrUndefined,
|
|
306
|
+
isTypedObject: () => isTypedObject,
|
|
307
|
+
isUndefined: () => isUndefined,
|
|
308
|
+
isZero: () => isZero,
|
|
309
|
+
tryOr: () => tryOr
|
|
310
|
+
});
|
|
311
|
+
var enum_exports = {};
|
|
312
|
+
__export2(enum_exports, {
|
|
313
|
+
forEachEnum: () => forEachEnum,
|
|
314
|
+
getEnumEntries: () => getEnumEntries,
|
|
315
|
+
getEnumKey: () => getEnumKey,
|
|
316
|
+
getEnumKeys: () => getEnumKeys,
|
|
317
|
+
getEnumValues: () => getEnumValues
|
|
318
|
+
});
|
|
319
|
+
function getEnumKeys(e) {
|
|
320
|
+
return Object.keys(e).filter((k) => isNaN(Number(k)));
|
|
321
|
+
}
|
|
322
|
+
function getEnumValues(e) {
|
|
323
|
+
return getEnumKeys(e).map((k) => e[k]);
|
|
324
|
+
}
|
|
325
|
+
function getEnumEntries(e) {
|
|
326
|
+
return getEnumKeys(e).map((k) => [k, e[k]]);
|
|
327
|
+
}
|
|
328
|
+
function getEnumKey(e, value) {
|
|
329
|
+
return getEnumKeys(e).find((k) => e[k] === value);
|
|
330
|
+
}
|
|
331
|
+
function forEachEnum(e, callback) {
|
|
332
|
+
for (const [k, v] of getEnumEntries(e)) callback(k, v);
|
|
333
|
+
}
|
|
334
|
+
function isStrictEqual(val1, val2) {
|
|
335
|
+
return val1 === val2;
|
|
336
|
+
}
|
|
337
|
+
function isDeepEqual(val1, val2) {
|
|
338
|
+
return deepEqual(val1, val2);
|
|
339
|
+
}
|
|
340
|
+
function isUndefined(val) {
|
|
341
|
+
return val === void 0;
|
|
342
|
+
}
|
|
343
|
+
function isNull(val) {
|
|
344
|
+
return val === null;
|
|
345
|
+
}
|
|
346
|
+
function isNullish(val) {
|
|
347
|
+
return val === void 0 || val === null;
|
|
348
|
+
}
|
|
349
|
+
function isDefined(val) {
|
|
350
|
+
return val !== void 0;
|
|
351
|
+
}
|
|
352
|
+
function isNonNull(val) {
|
|
353
|
+
return val !== null;
|
|
354
|
+
}
|
|
355
|
+
function isObject(val) {
|
|
356
|
+
return typeof val === "object" && val !== null && !isArray(val);
|
|
357
|
+
}
|
|
358
|
+
function isEmptyObject(val) {
|
|
359
|
+
return isObject(val) && Object.keys(val).length === 0;
|
|
360
|
+
}
|
|
361
|
+
function isObjectOrUndefined(val) {
|
|
362
|
+
return val === void 0 || isObject(val);
|
|
363
|
+
}
|
|
364
|
+
function isPlainObject(val) {
|
|
365
|
+
if (!isObject(val)) return false;
|
|
366
|
+
const proto = Object.getPrototypeOf(val);
|
|
367
|
+
return proto === Object.prototype || proto === null;
|
|
368
|
+
}
|
|
369
|
+
function isTypedObject(val, keys) {
|
|
370
|
+
return isObject(val) && keys.every((k) => k in val);
|
|
371
|
+
}
|
|
372
|
+
function isSet(val) {
|
|
373
|
+
return val instanceof Set;
|
|
374
|
+
}
|
|
375
|
+
function isArray(arr) {
|
|
376
|
+
return !!arr && Object.prototype.toString.call(arr) === "[object Array]";
|
|
377
|
+
}
|
|
378
|
+
function isArrayOrUndefined(arr) {
|
|
379
|
+
return arr === void 0 || isArray(arr);
|
|
380
|
+
}
|
|
381
|
+
function isEmptyArray(arr) {
|
|
382
|
+
return isArray(arr) && arr.length === 0;
|
|
383
|
+
}
|
|
384
|
+
function isNonEmptyArray(arr) {
|
|
385
|
+
return isArray(arr) && arr.length > 0;
|
|
386
|
+
}
|
|
387
|
+
function isEmptyArrayOrUndefined(arr) {
|
|
388
|
+
return isArray(arr) && arr.length === 0 || arr === void 0;
|
|
389
|
+
}
|
|
390
|
+
function isNonEmptyArrayOrUndefined(arr) {
|
|
391
|
+
return isArray(arr) && arr.length > 0 || arr === void 0;
|
|
392
|
+
}
|
|
393
|
+
function isString(val) {
|
|
394
|
+
return typeof val === "string";
|
|
395
|
+
}
|
|
396
|
+
function isEmptyString(val) {
|
|
397
|
+
return typeof val === "string" && val.length === 0;
|
|
398
|
+
}
|
|
399
|
+
function isNonEmptyString(val) {
|
|
400
|
+
return typeof val === "string" && val.length > 0;
|
|
401
|
+
}
|
|
402
|
+
function isStringOrUndefined(val) {
|
|
403
|
+
return val === void 0 || typeof val === "string";
|
|
404
|
+
}
|
|
405
|
+
function isEmptyStringOrUndefined(val) {
|
|
406
|
+
return typeof val === "string" && val.length === 0 || val === void 0;
|
|
407
|
+
}
|
|
408
|
+
function isNonEmptyStringOrUndefined(val) {
|
|
409
|
+
return typeof val === "string" && val.length > 0 || val === void 0;
|
|
410
|
+
}
|
|
411
|
+
function isBoolean(val) {
|
|
412
|
+
return typeof val === "boolean";
|
|
413
|
+
}
|
|
414
|
+
function isBooleanOrUndefined(val) {
|
|
415
|
+
return val === void 0 || typeof val === "boolean";
|
|
416
|
+
}
|
|
417
|
+
function isTrue(val) {
|
|
418
|
+
return val === true;
|
|
419
|
+
}
|
|
420
|
+
function isTrueOrUndefined(val) {
|
|
421
|
+
return val === true || val === void 0;
|
|
422
|
+
}
|
|
423
|
+
function isFalse(val) {
|
|
424
|
+
return val === false;
|
|
425
|
+
}
|
|
426
|
+
function isFalseOrUndefined(val) {
|
|
427
|
+
return val === false || val === void 0;
|
|
428
|
+
}
|
|
429
|
+
function isFunction(val) {
|
|
430
|
+
return typeof val === "function";
|
|
431
|
+
}
|
|
432
|
+
function isFunctionOrUndefined(val) {
|
|
433
|
+
return val === void 0 || typeof val === "function";
|
|
434
|
+
}
|
|
435
|
+
function isEnumValue(val, enumObj) {
|
|
436
|
+
return getEnumValues(enumObj).some((v) => v === val);
|
|
437
|
+
}
|
|
438
|
+
function isEnumValueOrUndefined(val, enumObj) {
|
|
439
|
+
return val === void 0 || getEnumValues(enumObj).some((v) => v === val);
|
|
440
|
+
}
|
|
441
|
+
function isNumericString(val) {
|
|
442
|
+
if (typeof val !== "string" || val.trim() === "") return false;
|
|
443
|
+
const n = +val;
|
|
444
|
+
return Number.isFinite(n);
|
|
445
|
+
}
|
|
446
|
+
function isBigInt(val) {
|
|
447
|
+
return typeof val === "bigint";
|
|
448
|
+
}
|
|
449
|
+
function isNumber(val) {
|
|
450
|
+
return typeof val === "number";
|
|
451
|
+
}
|
|
452
|
+
function isSafeNumber(val) {
|
|
453
|
+
return isNumber(val) && Number.isSafeInteger(val);
|
|
454
|
+
}
|
|
455
|
+
function isNumberOrUndefined(val) {
|
|
456
|
+
return typeof val === "number" || val === void 0;
|
|
457
|
+
}
|
|
458
|
+
function isNumberEq(val, ref) {
|
|
459
|
+
return isNumber(val) && val === ref;
|
|
460
|
+
}
|
|
461
|
+
function isNumberGt(val, ref) {
|
|
462
|
+
return isNumber(val) && isNumber(ref) && val > ref;
|
|
463
|
+
}
|
|
464
|
+
function isNumberGte(val, ref) {
|
|
465
|
+
return isNumber(val) && isNumber(ref) && val >= ref;
|
|
466
|
+
}
|
|
467
|
+
function isNumberLt(val, ref) {
|
|
468
|
+
return isNumber(val) && isNumber(ref) && val < ref;
|
|
469
|
+
}
|
|
470
|
+
function isNumberLte(val, ref) {
|
|
471
|
+
return isNumber(val) && isNumber(ref) && val <= ref;
|
|
472
|
+
}
|
|
473
|
+
function isNumberBetween(val, min, max) {
|
|
474
|
+
return isNumber(val) && isNumber(min) && isNumber(max) && val >= min && val <= max;
|
|
475
|
+
}
|
|
476
|
+
function isNumberBetweenExclusive(val, min, max) {
|
|
477
|
+
return isNumber(val) && isNumber(min) && isNumber(max) && val > min && val < max;
|
|
478
|
+
}
|
|
479
|
+
function isFinite2(val) {
|
|
480
|
+
return typeof val === "number" && Number.isFinite(val);
|
|
481
|
+
}
|
|
482
|
+
function isFloat(val) {
|
|
483
|
+
return isFinite2(val) && !isInteger(val);
|
|
484
|
+
}
|
|
485
|
+
function isInteger(val) {
|
|
486
|
+
return typeof val === "number" && isFinite2(val) && val === Math.trunc(val);
|
|
487
|
+
}
|
|
488
|
+
function isSafeInteger(val) {
|
|
489
|
+
return isInteger(val) && Number.isSafeInteger(val);
|
|
490
|
+
}
|
|
491
|
+
function isIntegerOrUndefined(val) {
|
|
492
|
+
return typeof val === "number" && isFinite2(val) && val === Math.trunc(val) || val === void 0;
|
|
493
|
+
}
|
|
494
|
+
function isIntegerEq(val, ref) {
|
|
495
|
+
return isInteger(val) && val === ref;
|
|
496
|
+
}
|
|
497
|
+
function isIntegerGt(val, ref) {
|
|
498
|
+
return isInteger(val) && isNumber(ref) && val > ref;
|
|
499
|
+
}
|
|
500
|
+
function isIntegerGte(val, ref) {
|
|
501
|
+
return isInteger(val) && isNumber(ref) && val >= ref;
|
|
502
|
+
}
|
|
503
|
+
function isIntegerLt(val, ref) {
|
|
504
|
+
return isInteger(val) && isNumber(ref) && val < ref;
|
|
505
|
+
}
|
|
506
|
+
function isIntegerLte(val, ref) {
|
|
507
|
+
return isInteger(val) && isNumber(ref) && val <= ref;
|
|
508
|
+
}
|
|
509
|
+
function isIntegerBetween(val, min, max) {
|
|
510
|
+
return isInteger(val) && isNumber(min) && isNumber(max) && val >= min && val <= max;
|
|
511
|
+
}
|
|
512
|
+
function isIntegerBetweenExclusive(val, min, max) {
|
|
513
|
+
return isInteger(val) && isNumber(min) && isNumber(max) && val > min && val < max;
|
|
514
|
+
}
|
|
515
|
+
function isNaNValue(val) {
|
|
516
|
+
return typeof val === "number" && Number.isNaN(val);
|
|
517
|
+
}
|
|
518
|
+
function isInfinity(val) {
|
|
519
|
+
return val === Infinity || val === -Infinity;
|
|
520
|
+
}
|
|
521
|
+
function isPosInfinity(val) {
|
|
522
|
+
return val === Infinity;
|
|
523
|
+
}
|
|
524
|
+
function isNegInfinity(val) {
|
|
525
|
+
return val === -Infinity;
|
|
526
|
+
}
|
|
527
|
+
function isPos(val) {
|
|
528
|
+
return typeof val === "number" && val > 0;
|
|
529
|
+
}
|
|
530
|
+
function isNeg(val) {
|
|
531
|
+
return typeof val === "number" && val < 0;
|
|
532
|
+
}
|
|
533
|
+
function isNonPos(val) {
|
|
534
|
+
return typeof val === "number" && val <= 0;
|
|
535
|
+
}
|
|
536
|
+
function isNonNeg(val) {
|
|
537
|
+
return typeof val === "number" && val >= 0;
|
|
538
|
+
}
|
|
539
|
+
function isZero(val) {
|
|
540
|
+
return typeof val === "number" && val === 0;
|
|
541
|
+
}
|
|
542
|
+
function isPosZero(val) {
|
|
543
|
+
return typeof val === "number" && val === 0 && 1 / val === Infinity;
|
|
544
|
+
}
|
|
545
|
+
function isNegZero(val) {
|
|
546
|
+
return typeof val === "number" && val === 0 && 1 / val === -Infinity;
|
|
547
|
+
}
|
|
548
|
+
function isOdd(val) {
|
|
549
|
+
return isInteger(val) && Math.abs(val) % 2 === 1;
|
|
550
|
+
}
|
|
551
|
+
function isEven(val) {
|
|
552
|
+
return isInteger(val) && val % 2 === 0;
|
|
553
|
+
}
|
|
554
|
+
function isMultipleOf(val, base) {
|
|
555
|
+
return typeof val === "number" && typeof base === "number" && val % base === 0;
|
|
556
|
+
}
|
|
557
|
+
function isPowerOfTwo(val) {
|
|
558
|
+
return isInteger(val) && val > 0 && (val & val - 1) === 0;
|
|
559
|
+
}
|
|
560
|
+
function isIncluded(val, container) {
|
|
561
|
+
if (isArray(container)) {
|
|
562
|
+
return container.includes(val);
|
|
563
|
+
}
|
|
564
|
+
if (isSet(container)) {
|
|
565
|
+
return container.has(val);
|
|
566
|
+
}
|
|
567
|
+
return false;
|
|
568
|
+
}
|
|
569
|
+
function isIndex(index, array) {
|
|
570
|
+
return isArray(array) ? isIntegerBetween(index, 0, array.length - 1) : isIntegerGte(index, 0);
|
|
571
|
+
}
|
|
572
|
+
function doesThrow(throwTestFn) {
|
|
573
|
+
try {
|
|
574
|
+
throwTestFn();
|
|
575
|
+
return false;
|
|
576
|
+
} catch (err) {
|
|
577
|
+
return true;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
function doesNotThrow(throwTestFn) {
|
|
581
|
+
try {
|
|
582
|
+
throwTestFn();
|
|
583
|
+
return true;
|
|
584
|
+
} catch (err) {
|
|
585
|
+
return false;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
function tryOr(tryFn, orVal) {
|
|
589
|
+
try {
|
|
590
|
+
return tryFn();
|
|
591
|
+
} catch (err) {
|
|
592
|
+
return isFunction(orVal) ? orVal() : orVal;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
function hasProperties(obj, props) {
|
|
596
|
+
return isObject(obj) && props.every((p) => p in obj);
|
|
597
|
+
}
|
|
598
|
+
function deepEqual(a, b) {
|
|
599
|
+
if (a === b) return true;
|
|
600
|
+
if (a === null || b === null) return false;
|
|
601
|
+
if (typeof a !== "object" || typeof b !== "object") return false;
|
|
602
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
603
|
+
if (a.length !== b.length) return false;
|
|
604
|
+
return a.every((val, i) => deepEqual(val, b[i]));
|
|
605
|
+
}
|
|
606
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
607
|
+
const keysA = Object.keys(a);
|
|
608
|
+
const keysB = Object.keys(b);
|
|
609
|
+
if (keysA.length !== keysB.length) return false;
|
|
610
|
+
for (const key of keysA) {
|
|
611
|
+
if (!Object.prototype.hasOwnProperty.call(b, key)) return false;
|
|
612
|
+
if (!deepEqual(a[key], b[key])) return false;
|
|
613
|
+
}
|
|
614
|
+
return true;
|
|
615
|
+
}
|
|
616
|
+
function getCtorName(obj) {
|
|
617
|
+
if (obj === null) return "null";
|
|
618
|
+
if (isArray(obj)) return "Array";
|
|
619
|
+
if (typeof obj !== "object") return typeof obj;
|
|
620
|
+
const tag = Object.prototype.toString.call(obj).slice(8, -1);
|
|
621
|
+
return tag || "Object";
|
|
622
|
+
}
|
|
623
|
+
function toCharArray(str2) {
|
|
624
|
+
return str2.split("");
|
|
625
|
+
}
|
|
626
|
+
function repeatString(repeatString2, repeatCount) {
|
|
627
|
+
if (!isInteger(repeatCount) || repeatCount < 0) {
|
|
628
|
+
throw new Error("repeatStr: Invalid repeatCount = " + repeatCount);
|
|
629
|
+
}
|
|
630
|
+
return new Array(repeatCount + 1).join(repeatString2);
|
|
631
|
+
}
|
|
632
|
+
function chunkString(str2, chunkSize) {
|
|
633
|
+
if (!isInteger(chunkSize) || chunkSize < 1) {
|
|
634
|
+
throw new Error("chunckString: Invalid chuckSize = " + chunkSize);
|
|
635
|
+
}
|
|
636
|
+
let result = [];
|
|
637
|
+
for (let i = 0; i < str2.length; i += chunkSize) {
|
|
638
|
+
result.push(str2.slice(i, i + chunkSize));
|
|
639
|
+
}
|
|
640
|
+
return result;
|
|
641
|
+
}
|
|
642
|
+
function replaceAt(str2, pos, removeCount, insert) {
|
|
643
|
+
if (!isInteger(removeCount) || removeCount < 0) {
|
|
644
|
+
throw new Error("replaceAt: Invalid removeCount = " + removeCount);
|
|
645
|
+
} else if (!isInteger(pos) || pos < 0 || pos + removeCount > str2.length) {
|
|
646
|
+
throw new Error("replaceAt: Invalid pos = " + pos + ", removeCount = " + removeCount + ", str.length = " + str2.length);
|
|
647
|
+
} else {
|
|
648
|
+
return str2.substring(0, pos) + insert + str2.substring(pos + removeCount);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
function insertAt(str2, pos, insertStr) {
|
|
652
|
+
return replaceAt(str2, pos, 0, insertStr);
|
|
653
|
+
}
|
|
654
|
+
function removeAt(str2, pos, removeCount) {
|
|
655
|
+
return replaceAt(str2, pos, removeCount, "");
|
|
656
|
+
}
|
|
657
|
+
function charCount(str2, ch) {
|
|
658
|
+
if (ch.length !== 1 || str2.length === 0) return 0;
|
|
659
|
+
let count = 0;
|
|
660
|
+
for (let i = 0; i < str2.length; i++) {
|
|
661
|
+
if (str2[i] === ch) count++;
|
|
662
|
+
}
|
|
663
|
+
return count;
|
|
664
|
+
}
|
|
665
|
+
function makeSentenceFromPascal(PascalString) {
|
|
666
|
+
if (PascalString === "") {
|
|
667
|
+
return "";
|
|
668
|
+
}
|
|
669
|
+
let word = PascalString.charAt(0);
|
|
670
|
+
let sentence = "";
|
|
671
|
+
const addWord = () => {
|
|
672
|
+
if (word !== "") {
|
|
673
|
+
if (sentence === "") {
|
|
674
|
+
sentence += word.charAt(0).toUpperCase() + word.substring(1);
|
|
675
|
+
} else {
|
|
676
|
+
sentence += " " + word;
|
|
677
|
+
}
|
|
678
|
+
word = "";
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
const isLetterAndCapital = (c) => {
|
|
682
|
+
return c.toUpperCase() !== c.toLowerCase() && c === c.toUpperCase();
|
|
683
|
+
};
|
|
684
|
+
for (let i = 1; i < PascalString.length; i++) {
|
|
685
|
+
let c = PascalString.charAt(i);
|
|
686
|
+
if (isLetterAndCapital(c)) {
|
|
687
|
+
addWord();
|
|
688
|
+
}
|
|
689
|
+
word += c.toLowerCase();
|
|
690
|
+
}
|
|
691
|
+
addWord();
|
|
692
|
+
return sentence;
|
|
693
|
+
}
|
|
694
|
+
function stringify(value, maxDepth = 5, seen = /* @__PURE__ */ new WeakSet()) {
|
|
695
|
+
if (value === null) return "null";
|
|
696
|
+
if (value === void 0) return "undefined";
|
|
697
|
+
const t = typeof value;
|
|
698
|
+
switch (t) {
|
|
699
|
+
case "boolean":
|
|
700
|
+
return value ? "true" : "false";
|
|
701
|
+
case "number":
|
|
702
|
+
if (isNaNValue(value)) return "NaN";
|
|
703
|
+
if (!isFinite2(value))
|
|
704
|
+
return value < 0 ? "-Infinity" : "Infinity";
|
|
705
|
+
return value.toString();
|
|
706
|
+
case "bigint":
|
|
707
|
+
return `${value}n`;
|
|
708
|
+
case "string":
|
|
709
|
+
return `"${value}"`;
|
|
710
|
+
case "symbol":
|
|
711
|
+
return value.description ? `Symbol(${value.description})` : "Symbol()";
|
|
712
|
+
case "function":
|
|
713
|
+
return `[Function${value.name ? ` ${value.name}` : ""}]`;
|
|
714
|
+
}
|
|
715
|
+
if (seen.has(value))
|
|
716
|
+
return "[Circular]";
|
|
717
|
+
if (maxDepth <= 0)
|
|
718
|
+
return "[Depth limit]";
|
|
719
|
+
maxDepth--;
|
|
720
|
+
seen.add(value);
|
|
721
|
+
const strfy = (v) => stringify(v, maxDepth, seen);
|
|
722
|
+
if (isArray(value)) {
|
|
723
|
+
const inner = value.map((v) => strfy(v)).join(", ");
|
|
724
|
+
return inner.length === 0 ? "[ ]" : `[ ${inner} ]`;
|
|
725
|
+
}
|
|
726
|
+
if (ArrayBuffer.isView(value)) {
|
|
727
|
+
if (value instanceof DataView)
|
|
728
|
+
return `DataView(${value.byteLength})`;
|
|
729
|
+
const inner = Array.from(value).map((v) => strfy(v)).join(", ");
|
|
730
|
+
return `${value.constructor.name}[ ${inner} ]`;
|
|
731
|
+
}
|
|
732
|
+
if (value instanceof ArrayBuffer)
|
|
733
|
+
return `ArrayBuffer(${value.byteLength})`;
|
|
734
|
+
if (value instanceof Map) {
|
|
735
|
+
const entries = Array.from(value.entries()).map(([k, v]) => `${strfy(k)} => ${strfy(v)}`).join(", ");
|
|
736
|
+
return entries.length === 0 ? `Map(${value.size}){ }` : `Map(${value.size}){ ${entries} }`;
|
|
737
|
+
}
|
|
738
|
+
if (value instanceof Set) {
|
|
739
|
+
const entries = Array.from(value.values()).map((v) => strfy(v)).join(", ");
|
|
740
|
+
return entries.length === 0 ? `Set(${value.size}){ }` : `Set(${value.size}){ ${entries} }`;
|
|
741
|
+
}
|
|
742
|
+
if (value instanceof WeakMap)
|
|
743
|
+
return "WeakMap{ ? }";
|
|
744
|
+
if (value instanceof WeakSet)
|
|
745
|
+
return "WeakSet{ ? }";
|
|
746
|
+
if (value instanceof Date)
|
|
747
|
+
return `Date("${value.toISOString()}")`;
|
|
748
|
+
if (value instanceof RegExp)
|
|
749
|
+
return value.toString();
|
|
750
|
+
if (value instanceof Error)
|
|
751
|
+
return `${value.name}("${value.message}")`;
|
|
752
|
+
if (value instanceof Promise)
|
|
753
|
+
return "Promise{ ? }";
|
|
754
|
+
if (value instanceof URL)
|
|
755
|
+
return `URL("${value.href}")`;
|
|
756
|
+
if (value instanceof URLSearchParams)
|
|
757
|
+
return `URLSearchParams("${value.toString()}")`;
|
|
758
|
+
if (value === Math) return "Math";
|
|
759
|
+
if (value === JSON) return "JSON";
|
|
760
|
+
if (value === Reflect) return "Reflect";
|
|
761
|
+
if (value === Intl) return "Intl";
|
|
762
|
+
const hasCustomToString = typeof (value == null ? void 0 : value.toString) === "function" && value.toString !== Object.prototype.toString;
|
|
763
|
+
if (hasCustomToString) {
|
|
764
|
+
try {
|
|
765
|
+
const str2 = value.toString();
|
|
766
|
+
if (!/^\[object .+\]$/.test(str2)) return str2;
|
|
767
|
+
} catch (e) {
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
if (t === "object") {
|
|
771
|
+
const ctorName = getCtorName(value);
|
|
772
|
+
const entries = Object.entries(value).map(
|
|
773
|
+
([key, val]) => `${strfy(key)}: ${strfy(val)}`
|
|
774
|
+
);
|
|
775
|
+
if (entries.length === 0) return `${ctorName}{ }`;
|
|
776
|
+
return `${ctorName}{ ${entries.join(", ")} }`;
|
|
777
|
+
}
|
|
778
|
+
return String(value);
|
|
779
|
+
}
|
|
780
|
+
function splitByCaps(str2) {
|
|
781
|
+
return str2.split(/(?=[A-Z])/).filter((x) => !!x);
|
|
782
|
+
}
|
|
783
|
+
function splitByStrings(str2, ...splitters) {
|
|
784
|
+
if (splitters.length === 0) return [str2];
|
|
785
|
+
const escaped = splitters.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
|
|
786
|
+
const regex = new RegExp(escaped.join("|"), "g");
|
|
787
|
+
return str2.split(regex);
|
|
788
|
+
}
|
|
789
|
+
function splitByChars(str2, splitters) {
|
|
790
|
+
return splitByStrings(str2, ...splitters.split(""));
|
|
791
|
+
}
|
|
792
|
+
var fmt = stringify;
|
|
793
|
+
var errorConstructor = Error;
|
|
794
|
+
function setErrorClass(errorClass) {
|
|
795
|
+
errorConstructor = errorClass != null ? errorClass : Error;
|
|
796
|
+
}
|
|
797
|
+
function _fail(...msgs) {
|
|
798
|
+
let msg = msgs.join(", ");
|
|
799
|
+
throw new errorConstructor("Assertion Failed!" + (msg === "" ? "" : " " + msg));
|
|
800
|
+
}
|
|
801
|
+
function assert(condition, msg) {
|
|
802
|
+
if (!condition) {
|
|
803
|
+
_fail(msg);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
function require2(val, msg) {
|
|
807
|
+
if (val == null) {
|
|
808
|
+
_fail(`Expected ${fmt(val)} not to be nullish`, msg);
|
|
809
|
+
}
|
|
810
|
+
return val;
|
|
811
|
+
}
|
|
812
|
+
function requireDefined(val, msg) {
|
|
813
|
+
if (val === void 0) {
|
|
814
|
+
_fail(`Expected ${fmt(val)} not to be undefined`, msg);
|
|
815
|
+
}
|
|
816
|
+
return val;
|
|
817
|
+
}
|
|
818
|
+
function requireElement(index, array, msg) {
|
|
819
|
+
if (!guard_exports.isIndex(index, array))
|
|
820
|
+
_fail(`Expected ${index} to be index for array ${fmt(array)}`, msg);
|
|
821
|
+
return array[index];
|
|
822
|
+
}
|
|
823
|
+
function fail(msg) {
|
|
824
|
+
_fail(msg);
|
|
825
|
+
}
|
|
826
|
+
function isStrictEqual2(val1, val2, msg) {
|
|
827
|
+
if (!guard_exports.isStrictEqual(val1, val2))
|
|
828
|
+
_fail(`Expected ${fmt(val1)} to ne strict equal to ${val2}`, msg);
|
|
829
|
+
return val1;
|
|
830
|
+
}
|
|
831
|
+
function isDeepEqual2(val1, val2, msg) {
|
|
832
|
+
if (!guard_exports.isDeepEqual(val1, val2))
|
|
833
|
+
_fail(`Expected ${fmt(val1)} to deep equal with ${fmt(val2)}`, msg);
|
|
834
|
+
return val1;
|
|
835
|
+
}
|
|
836
|
+
function isUndefined2(val, msg) {
|
|
837
|
+
if (!guard_exports.isUndefined(val))
|
|
838
|
+
_fail(`Expected ${fmt(val)} to be undefined`, msg);
|
|
839
|
+
return val;
|
|
840
|
+
}
|
|
841
|
+
function isNull2(val, msg) {
|
|
842
|
+
if (!guard_exports.isNull(val))
|
|
843
|
+
_fail(`Expected ${fmt(val)} to be null`, msg);
|
|
844
|
+
return val;
|
|
845
|
+
}
|
|
846
|
+
function isNullish2(val, msg) {
|
|
847
|
+
if (!guard_exports.isNullish(val))
|
|
848
|
+
_fail(`Expected ${fmt(val)} to be null or undefined`, msg);
|
|
849
|
+
return val;
|
|
850
|
+
}
|
|
851
|
+
function isDefined2(val, msg) {
|
|
852
|
+
if (!guard_exports.isDefined(val)) {
|
|
853
|
+
_fail(`Expected ${fmt(val)} to be defined`, msg);
|
|
854
|
+
}
|
|
855
|
+
return val;
|
|
856
|
+
}
|
|
857
|
+
function isNonNull2(val, msg) {
|
|
858
|
+
if (!guard_exports.isNonNull(val)) {
|
|
859
|
+
_fail(`Expected ${fmt(val)} to be defined`, msg);
|
|
860
|
+
}
|
|
861
|
+
return val;
|
|
862
|
+
}
|
|
863
|
+
function isObject2(val, msg) {
|
|
864
|
+
if (!guard_exports.isObject(val))
|
|
865
|
+
_fail(`Expected ${fmt(val)} to be object`, msg);
|
|
866
|
+
return val;
|
|
867
|
+
}
|
|
868
|
+
function isEmptyObject2(val, msg) {
|
|
869
|
+
if (!guard_exports.isEmptyObject(val))
|
|
870
|
+
_fail(`Expected ${fmt(val)} to be empty object`, msg);
|
|
871
|
+
return val;
|
|
872
|
+
}
|
|
873
|
+
function isPlainObject2(val, msg) {
|
|
874
|
+
if (!guard_exports.isPlainObject(val))
|
|
875
|
+
_fail(`Expected ${fmt(val)} to be plain object`, msg);
|
|
876
|
+
return val;
|
|
877
|
+
}
|
|
878
|
+
function isObjectOrUndefined2(val, msg) {
|
|
879
|
+
if (!guard_exports.isObjectOrUndefined(val))
|
|
880
|
+
_fail(`Expected ${fmt(val)} to be object or undefined`, msg);
|
|
881
|
+
return val;
|
|
882
|
+
}
|
|
883
|
+
function isTypedObject2(val, keys, msg) {
|
|
884
|
+
if (!guard_exports.isTypedObject(val, keys))
|
|
885
|
+
_fail(`Expected ${fmt(val)} to have keys ${fmt(keys)}`, msg);
|
|
886
|
+
return val;
|
|
887
|
+
}
|
|
888
|
+
function isArray2(val, msg) {
|
|
889
|
+
if (!guard_exports.isArray(val))
|
|
890
|
+
_fail(`Expected ${fmt(val)} to be array`, msg);
|
|
891
|
+
return val;
|
|
892
|
+
}
|
|
893
|
+
function isArrayOrUndefined2(val, msg) {
|
|
894
|
+
if (!guard_exports.isArrayOrUndefined(val))
|
|
895
|
+
_fail(`Expected ${fmt(val)} to be array or undefined`, msg);
|
|
896
|
+
return true;
|
|
897
|
+
}
|
|
898
|
+
function isEmptyArray2(val, msg) {
|
|
899
|
+
if (!guard_exports.isEmptyArray(val))
|
|
900
|
+
_fail(`Expected ${fmt(val)} to be empty array`, msg);
|
|
901
|
+
}
|
|
902
|
+
function isNonEmptyArray2(val, msg) {
|
|
903
|
+
if (!guard_exports.isNonEmptyArray(val))
|
|
904
|
+
_fail(`Expected ${fmt(val)} to be non-empty array`, msg);
|
|
905
|
+
}
|
|
906
|
+
function isEmptyArrayOrUndefined2(val, msg) {
|
|
907
|
+
if (!guard_exports.isEmptyArrayOrUndefined(val))
|
|
908
|
+
_fail(`Expected ${fmt(val)} to be empty array or undefined`, msg);
|
|
909
|
+
}
|
|
910
|
+
function isNonEmptyArrayOrUndefined2(val, msg) {
|
|
911
|
+
if (!guard_exports.isNonEmptyArrayOrUndefined(val))
|
|
912
|
+
_fail(`Expected ${fmt(val)} to be non-empty array or undefined`, msg);
|
|
913
|
+
}
|
|
914
|
+
function isString2(val, msg) {
|
|
915
|
+
if (!guard_exports.isString(val))
|
|
916
|
+
_fail(`Expected ${fmt(val)} to be string`, msg);
|
|
917
|
+
return val;
|
|
918
|
+
}
|
|
919
|
+
function isEmptyString2(val, msg) {
|
|
920
|
+
if (!guard_exports.isEmptyString(val))
|
|
921
|
+
_fail(`Expected ${fmt(val)} to be empty string`, msg);
|
|
922
|
+
return val;
|
|
923
|
+
}
|
|
924
|
+
function isNonEmptyString2(val, msg) {
|
|
925
|
+
if (!guard_exports.isNonEmptyString(val))
|
|
926
|
+
_fail(`Expected ${fmt(val)} to be non-empty string`, msg);
|
|
927
|
+
return val;
|
|
928
|
+
}
|
|
929
|
+
function isStringOrUndefined2(val, msg) {
|
|
930
|
+
if (!guard_exports.isStringOrUndefined(val))
|
|
931
|
+
_fail(`Expected ${fmt(val)} to be string or undefined`, msg);
|
|
932
|
+
return val;
|
|
933
|
+
}
|
|
934
|
+
function isEmptyStringOrUndefined2(val, msg) {
|
|
935
|
+
if (!guard_exports.isEmptyStringOrUndefined(val))
|
|
936
|
+
_fail(`Expected ${fmt(val)} to be empty string or undefined`, msg);
|
|
937
|
+
return val;
|
|
938
|
+
}
|
|
939
|
+
function isNonEmptyStringOrUndefined2(val, msg) {
|
|
940
|
+
if (!guard_exports.isNonEmptyStringOrUndefined(val))
|
|
941
|
+
_fail(`Expected ${fmt(val)} to be non-empty string or undefined`, msg);
|
|
942
|
+
return val;
|
|
943
|
+
}
|
|
944
|
+
function isBoolean2(val, msg) {
|
|
945
|
+
if (!guard_exports.isBoolean(val))
|
|
946
|
+
_fail(`Expected ${fmt(val)} to be boolean`, msg);
|
|
947
|
+
return val;
|
|
948
|
+
}
|
|
949
|
+
function isBooleanOrUndefined2(val, msg) {
|
|
950
|
+
if (!guard_exports.isBooleanOrUndefined(val))
|
|
951
|
+
_fail(`Expected ${fmt(val)} to be boolean or undefined`, msg);
|
|
952
|
+
return val;
|
|
953
|
+
}
|
|
954
|
+
function isTrue2(val, msg) {
|
|
955
|
+
if (!guard_exports.isTrue(val))
|
|
956
|
+
_fail(`Expected ${fmt(val)} to be true`, msg);
|
|
957
|
+
return val;
|
|
958
|
+
}
|
|
959
|
+
function isTrueOrUndefined2(val, msg) {
|
|
960
|
+
if (!guard_exports.isTrueOrUndefined(val))
|
|
961
|
+
_fail(`Expected ${fmt(val)} to be true or undefined`, msg);
|
|
962
|
+
return val;
|
|
963
|
+
}
|
|
964
|
+
function isFalse2(val, msg) {
|
|
965
|
+
if (!guard_exports.isFalse(val))
|
|
966
|
+
_fail(`Expected ${fmt(val)} to be false`, msg);
|
|
967
|
+
return val;
|
|
968
|
+
}
|
|
969
|
+
function isFalseOrUndefined2(val, msg) {
|
|
970
|
+
if (!guard_exports.isFalseOrUndefined(val))
|
|
971
|
+
_fail(`Expected ${fmt(val)} to be false or undefined`, msg);
|
|
972
|
+
return val;
|
|
973
|
+
}
|
|
974
|
+
function isFunction2(val, msg) {
|
|
975
|
+
if (!guard_exports.isFunction(val))
|
|
976
|
+
_fail(`Expected ${fmt(val)} to be function`, msg);
|
|
977
|
+
return val;
|
|
978
|
+
}
|
|
979
|
+
function isFunctionOrUndefined2(val, msg) {
|
|
980
|
+
if (!guard_exports.isFunctionOrUndefined(val))
|
|
981
|
+
_fail(`Expected ${fmt(val)} to be function or undefined`, msg);
|
|
982
|
+
return val;
|
|
983
|
+
}
|
|
984
|
+
function isEnumValue2(val, enumObject, msg) {
|
|
985
|
+
if (!guard_exports.isEnumValue(val, enumObject))
|
|
986
|
+
_fail(`Expected ${fmt(val)} to be enum val`, msg);
|
|
987
|
+
return val;
|
|
988
|
+
}
|
|
989
|
+
function isEnumValueOrUndefined2(val, enumObject, msg) {
|
|
990
|
+
if (!guard_exports.isEnumValueOrUndefined(val, enumObject))
|
|
991
|
+
_fail(`Expected ${fmt(val)} to be enum val or undefined`, msg);
|
|
992
|
+
return val;
|
|
993
|
+
}
|
|
994
|
+
function isNumericString2(val, msg) {
|
|
995
|
+
if (!guard_exports.isNumericString(val))
|
|
996
|
+
_fail(`Expected ${fmt(val)} to be numeric string`, msg);
|
|
997
|
+
return val;
|
|
998
|
+
}
|
|
999
|
+
function isBigInt2(val, msg) {
|
|
1000
|
+
if (!guard_exports.isBigInt(val))
|
|
1001
|
+
_fail(`Expected ${fmt(val)} to be BigInt`, msg);
|
|
1002
|
+
return val;
|
|
1003
|
+
}
|
|
1004
|
+
function isNumber2(val, msg) {
|
|
1005
|
+
if (!guard_exports.isNumber(val))
|
|
1006
|
+
_fail(`Expected ${fmt(val)} to be number`, msg);
|
|
1007
|
+
return val;
|
|
1008
|
+
}
|
|
1009
|
+
function isSafeNumber2(val, msg) {
|
|
1010
|
+
if (!guard_exports.isSafeNumber(val))
|
|
1011
|
+
_fail(`Expected ${fmt(val)} to be safe number`, msg);
|
|
1012
|
+
return val;
|
|
1013
|
+
}
|
|
1014
|
+
function isNumberOrUndefined2(val, msg) {
|
|
1015
|
+
if (!guard_exports.isNumberOrUndefined(val))
|
|
1016
|
+
_fail(`Expected ${fmt(val)} to be number or undefined`, msg);
|
|
1017
|
+
return val;
|
|
1018
|
+
}
|
|
1019
|
+
function isNumberEq2(val, ref, msg) {
|
|
1020
|
+
if (!guard_exports.isNumberEq(val, ref))
|
|
1021
|
+
_fail(`Expected ${fmt(val)} to be number equal to ${fmt(ref)}`, msg);
|
|
1022
|
+
return val;
|
|
1023
|
+
}
|
|
1024
|
+
function isNumberGt2(val, ref, msg) {
|
|
1025
|
+
if (!guard_exports.isNumberGt(val, ref))
|
|
1026
|
+
_fail(`Expected ${fmt(val)} to be number > ${fmt(ref)}`, msg);
|
|
1027
|
+
return val;
|
|
1028
|
+
}
|
|
1029
|
+
function isNumberGte2(val, ref, msg) {
|
|
1030
|
+
if (!guard_exports.isNumberGte(val, ref))
|
|
1031
|
+
_fail(`Expected ${fmt(val)} to be number >= ${fmt(ref)}`, msg);
|
|
1032
|
+
return val;
|
|
1033
|
+
}
|
|
1034
|
+
function isNumberLt2(val, ref, msg) {
|
|
1035
|
+
if (!guard_exports.isNumberLt(val, ref))
|
|
1036
|
+
_fail(`Expected ${fmt(val)} to be number < ${fmt(ref)}`, msg);
|
|
1037
|
+
return val;
|
|
1038
|
+
}
|
|
1039
|
+
function isNumberLte2(val, ref, msg) {
|
|
1040
|
+
if (!guard_exports.isNumberLte(val, ref))
|
|
1041
|
+
_fail(`Expected ${fmt(val)} to be number <= ${fmt(ref)}`, msg);
|
|
1042
|
+
return val;
|
|
1043
|
+
}
|
|
1044
|
+
function isNumberBetween2(val, min, max, msg) {
|
|
1045
|
+
if (!guard_exports.isNumberBetween(val, min, max))
|
|
1046
|
+
_fail(`Expected number ${fmt(min)} <= ${fmt(val)} <= ${fmt(max)}`, msg);
|
|
1047
|
+
return val;
|
|
1048
|
+
}
|
|
1049
|
+
function isNumberBetweenExclusive2(val, min, max, msg) {
|
|
1050
|
+
if (!guard_exports.isNumberBetweenExclusive(val, min, max))
|
|
1051
|
+
_fail(`Expected number ${fmt(min)} < ${fmt(val)} < ${fmt(max)}`, msg);
|
|
1052
|
+
return val;
|
|
1053
|
+
}
|
|
1054
|
+
function isFinite3(val, msg) {
|
|
1055
|
+
if (!guard_exports.isFinite(val))
|
|
1056
|
+
_fail(`Expected ${fmt(val)} to be finite`, msg);
|
|
1057
|
+
return val;
|
|
1058
|
+
}
|
|
1059
|
+
function isFloat2(val, msg) {
|
|
1060
|
+
if (!guard_exports.isFloat(val))
|
|
1061
|
+
_fail(`Expected ${fmt(val)} to be float`, msg);
|
|
1062
|
+
return val;
|
|
1063
|
+
}
|
|
1064
|
+
function isInteger2(val, msg) {
|
|
1065
|
+
if (!guard_exports.isInteger(val))
|
|
1066
|
+
_fail(`Expected ${fmt(val)} to be integer`, msg);
|
|
1067
|
+
return val;
|
|
1068
|
+
}
|
|
1069
|
+
function isSafeInteger2(val, msg) {
|
|
1070
|
+
if (!guard_exports.isSafeInteger(val))
|
|
1071
|
+
_fail(`Expected ${fmt(val)} to be safe integer`, msg);
|
|
1072
|
+
return val;
|
|
1073
|
+
}
|
|
1074
|
+
function isIntegerOrUndefined2(val, msg) {
|
|
1075
|
+
if (!guard_exports.isIntegerOrUndefined(val))
|
|
1076
|
+
_fail(`Expected ${fmt(val)} to be integer or undefined`, msg);
|
|
1077
|
+
return val;
|
|
1078
|
+
}
|
|
1079
|
+
function isIntegerEq2(val, ref, msg) {
|
|
1080
|
+
if (!guard_exports.isIntegerEq(val, ref))
|
|
1081
|
+
_fail(`Expected ${fmt(val)} to be integer equal to ${fmt(ref)}`, msg);
|
|
1082
|
+
return val;
|
|
1083
|
+
}
|
|
1084
|
+
function isIntegerGt2(val, ref, msg) {
|
|
1085
|
+
if (!guard_exports.isIntegerGt(val, ref))
|
|
1086
|
+
_fail(`Expected ${fmt(val)} to be integer > ${fmt(ref)}`, msg);
|
|
1087
|
+
return val;
|
|
1088
|
+
}
|
|
1089
|
+
function isIntegerGte2(val, ref, msg) {
|
|
1090
|
+
if (!guard_exports.isIntegerGte(val, ref))
|
|
1091
|
+
_fail(`Expected ${fmt(val)} to be integer >= ${fmt(ref)}`, msg);
|
|
1092
|
+
return val;
|
|
1093
|
+
}
|
|
1094
|
+
function isIntegerLt2(val, ref, msg) {
|
|
1095
|
+
if (!guard_exports.isIntegerLt(val, ref))
|
|
1096
|
+
_fail(`Expected ${fmt(val)} to be integer < ${fmt(ref)}`, msg);
|
|
1097
|
+
return val;
|
|
1098
|
+
}
|
|
1099
|
+
function isIntegerLte2(val, ref, msg) {
|
|
1100
|
+
if (!guard_exports.isIntegerLte(val, ref))
|
|
1101
|
+
_fail(`Expected ${fmt(val)} to be integer <= ${fmt(ref)}`, msg);
|
|
1102
|
+
return val;
|
|
1103
|
+
}
|
|
1104
|
+
function isIntegerBetween2(val, min, max, msg) {
|
|
1105
|
+
if (!guard_exports.isIntegerBetween(val, min, max))
|
|
1106
|
+
_fail(`Expected integer ${fmt(min)} <= ${fmt(val)} <= ${fmt(max)}`, msg);
|
|
1107
|
+
return val;
|
|
1108
|
+
}
|
|
1109
|
+
function isIntegerBetweenExclusive2(val, min, max, msg) {
|
|
1110
|
+
if (!guard_exports.isIntegerBetweenExclusive(val, min, max))
|
|
1111
|
+
_fail(`Expected integer ${fmt(min)} < ${fmt(val)} < ${fmt(max)}`, msg);
|
|
1112
|
+
return val;
|
|
1113
|
+
}
|
|
1114
|
+
function isNaNValue2(val, msg) {
|
|
1115
|
+
if (!guard_exports.isNaNValue(val))
|
|
1116
|
+
_fail(`Expected ${fmt(val)} to be NaN`, msg);
|
|
1117
|
+
return NaN;
|
|
1118
|
+
}
|
|
1119
|
+
function isInfinity2(val, msg) {
|
|
1120
|
+
if (!guard_exports.isInfinity(val))
|
|
1121
|
+
_fail(`Expected ${fmt(val)} to be +-Infinity`, msg);
|
|
1122
|
+
return val;
|
|
1123
|
+
}
|
|
1124
|
+
function isPosInfinity2(val, msg) {
|
|
1125
|
+
if (!guard_exports.isPosInfinity(val))
|
|
1126
|
+
_fail(`Expected ${fmt(val)} to be +Infinity`, msg);
|
|
1127
|
+
return val;
|
|
1128
|
+
}
|
|
1129
|
+
function isNegInfinity2(val, msg) {
|
|
1130
|
+
if (!guard_exports.isNegInfinity(val))
|
|
1131
|
+
_fail(`Expected ${fmt(val)} to be -Infinity`, msg);
|
|
1132
|
+
return val;
|
|
1133
|
+
}
|
|
1134
|
+
function isPos2(val, msg) {
|
|
1135
|
+
if (!guard_exports.isPos(val))
|
|
1136
|
+
_fail(`Expected ${fmt(val)} to be positive (> 0)`, msg);
|
|
1137
|
+
return val;
|
|
1138
|
+
}
|
|
1139
|
+
function isNeg2(val, msg) {
|
|
1140
|
+
if (!guard_exports.isNeg(val))
|
|
1141
|
+
_fail(`Expected ${fmt(val)} to be negative (< 0)`, msg);
|
|
1142
|
+
return val;
|
|
1143
|
+
}
|
|
1144
|
+
function isNonPos2(val, msg) {
|
|
1145
|
+
if (!guard_exports.isNonPos(val))
|
|
1146
|
+
_fail(`Expected ${fmt(val)} to be non-positive (<= 0)`, msg);
|
|
1147
|
+
return val;
|
|
1148
|
+
}
|
|
1149
|
+
function isNonNeg2(val, msg) {
|
|
1150
|
+
if (!guard_exports.isNonNeg(val))
|
|
1151
|
+
_fail(`Expected ${fmt(val)} to be non-negative (>= 0)`, msg);
|
|
1152
|
+
return val;
|
|
1153
|
+
}
|
|
1154
|
+
function isZero2(val, msg) {
|
|
1155
|
+
if (!guard_exports.isZero(val))
|
|
1156
|
+
_fail(`Expected ${fmt(val)} to be 0`, msg);
|
|
1157
|
+
return val;
|
|
1158
|
+
}
|
|
1159
|
+
function isPosZero2(val, msg) {
|
|
1160
|
+
if (!guard_exports.isPosZero(val))
|
|
1161
|
+
_fail(`Expected ${fmt(val)} to be +0`, msg);
|
|
1162
|
+
return val;
|
|
1163
|
+
}
|
|
1164
|
+
function isNegZero2(val, msg) {
|
|
1165
|
+
if (!guard_exports.isNegZero(val))
|
|
1166
|
+
_fail(`Expected ${fmt(val)} to be -0`, msg);
|
|
1167
|
+
return val;
|
|
1168
|
+
}
|
|
1169
|
+
function isOdd2(val, msg) {
|
|
1170
|
+
if (!guard_exports.isOdd(val))
|
|
1171
|
+
_fail(`Expected ${fmt(val)} to odd`, msg);
|
|
1172
|
+
return val;
|
|
1173
|
+
}
|
|
1174
|
+
function isEven2(val, msg) {
|
|
1175
|
+
if (!guard_exports.isEven(val))
|
|
1176
|
+
_fail(`Expected ${fmt(val)} to even`, msg);
|
|
1177
|
+
return val;
|
|
1178
|
+
}
|
|
1179
|
+
function isMultipleOf2(val, base, msg) {
|
|
1180
|
+
if (!guard_exports.isMultipleOf(val, base))
|
|
1181
|
+
_fail(`Expected ${fmt(val)} to be divisble bu ${fmt(base)}`, msg);
|
|
1182
|
+
return val;
|
|
1183
|
+
}
|
|
1184
|
+
function isPowerOfTwo2(val, msg) {
|
|
1185
|
+
if (!guard_exports.isPowerOfTwo(val))
|
|
1186
|
+
_fail(`Expected ${fmt(val)} to be power of two`, msg);
|
|
1187
|
+
return val;
|
|
1188
|
+
}
|
|
1189
|
+
function isIncluded2(val, arr, msg) {
|
|
1190
|
+
if (!guard_exports.isIncluded(val, arr))
|
|
1191
|
+
_fail(`Expected ${fmt(val)} to be included in ${fmt(arr)}`, msg);
|
|
1192
|
+
return val;
|
|
1193
|
+
}
|
|
1194
|
+
function isIndex2(...args) {
|
|
1195
|
+
const index = args.shift();
|
|
1196
|
+
const msg = guard_exports.isString(args[args.length - 1]) ? args.pop() : void 0;
|
|
1197
|
+
const arr = guard_exports.isArray(args[0]) ? args.shift() : void 0;
|
|
1198
|
+
if (!guard_exports.isIndex(index, arr)) {
|
|
1199
|
+
if (arr === void 0)
|
|
1200
|
+
_fail(`Expected ${index} to be index`, msg);
|
|
1201
|
+
else
|
|
1202
|
+
_fail(`Expected ${index} to be index for ${fmt(arr)}`, msg);
|
|
1203
|
+
}
|
|
1204
|
+
return index;
|
|
1205
|
+
}
|
|
1206
|
+
function doesThrow2(throwTestFn, msg) {
|
|
1207
|
+
if (!guard_exports.doesThrow(throwTestFn))
|
|
1208
|
+
_fail(`Expected to throw`, msg);
|
|
1209
|
+
return true;
|
|
1210
|
+
}
|
|
1211
|
+
function doesNotThrow2(throwTestFn, msg) {
|
|
1212
|
+
if (!guard_exports.doesNotThrow(throwTestFn))
|
|
1213
|
+
_fail(`Expected to throw`, msg);
|
|
1214
|
+
return true;
|
|
1215
|
+
}
|
|
1216
|
+
var cookies_exports = {};
|
|
1217
|
+
__export2(cookies_exports, {
|
|
1218
|
+
accept: () => accept,
|
|
1219
|
+
decline: () => decline,
|
|
1220
|
+
erase: () => erase,
|
|
1221
|
+
eraseAll: () => eraseAll,
|
|
1222
|
+
isConsentPending: () => isConsentPending,
|
|
1223
|
+
read: () => read,
|
|
1224
|
+
readBool: () => readBool,
|
|
1225
|
+
readInt: () => readInt,
|
|
1226
|
+
save: () => save,
|
|
1227
|
+
setExpireDays: () => setExpireDays
|
|
1228
|
+
});
|
|
1229
|
+
var ConsentCookieName = "ConsentCookie";
|
|
1230
|
+
var _consent;
|
|
1231
|
+
var _expires;
|
|
1232
|
+
var str = _read(ConsentCookieName);
|
|
1233
|
+
_consent = str === "accept" || str === "decline" ? str : void 0;
|
|
1234
|
+
function _getCookieList() {
|
|
1235
|
+
if (typeof document === "undefined")
|
|
1236
|
+
return [];
|
|
1237
|
+
let s = document.cookie;
|
|
1238
|
+
return s.split(";").map((c) => c.trim());
|
|
1239
|
+
}
|
|
1240
|
+
function _save(name, value) {
|
|
1241
|
+
let cookie = name + "=" + value.toString() + ";sameSite=Lax;";
|
|
1242
|
+
if (_expires) {
|
|
1243
|
+
cookie += "expires=" + _expires.toUTCString() + ";";
|
|
1244
|
+
}
|
|
1245
|
+
if (typeof document !== "undefined")
|
|
1246
|
+
document.cookie = cookie;
|
|
1247
|
+
return value;
|
|
1248
|
+
}
|
|
1249
|
+
function _read(name, defaultValue) {
|
|
1250
|
+
let str2 = _getCookieList().find((c) => c.startsWith(name + "="));
|
|
1251
|
+
return str2 === void 0 ? defaultValue : str2.substring(name.length + 1);
|
|
1252
|
+
}
|
|
1253
|
+
function _erase(name) {
|
|
1254
|
+
if (typeof document !== "undefined")
|
|
1255
|
+
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;";
|
|
1256
|
+
}
|
|
1257
|
+
function setExpireDays(days) {
|
|
1258
|
+
_expires = /* @__PURE__ */ new Date();
|
|
1259
|
+
_expires.setDate(_expires.getDate() + days);
|
|
1260
|
+
}
|
|
1261
|
+
function isConsentPending() {
|
|
1262
|
+
return _consent === void 0;
|
|
1263
|
+
}
|
|
1264
|
+
function accept() {
|
|
1265
|
+
_consent = "accept";
|
|
1266
|
+
_save(ConsentCookieName, _consent);
|
|
1267
|
+
}
|
|
1268
|
+
function decline() {
|
|
1269
|
+
_consent = "decline";
|
|
1270
|
+
_save(ConsentCookieName, _consent);
|
|
1271
|
+
}
|
|
1272
|
+
function save(name, value) {
|
|
1273
|
+
if (_consent === "accept")
|
|
1274
|
+
_save(name, value);
|
|
1275
|
+
return value;
|
|
1276
|
+
}
|
|
1277
|
+
function read(name, defaultValue) {
|
|
1278
|
+
var _a;
|
|
1279
|
+
if (_consent === "accept")
|
|
1280
|
+
return (_a = _read(name, defaultValue)) != null ? _a : defaultValue;
|
|
1281
|
+
else
|
|
1282
|
+
return defaultValue;
|
|
1283
|
+
}
|
|
1284
|
+
function readInt(name, defaultValue) {
|
|
1285
|
+
if (_consent === "accept") {
|
|
1286
|
+
let str2 = _read(name);
|
|
1287
|
+
return str2 === void 0 ? defaultValue : parseInt(str2);
|
|
1288
|
+
} else {
|
|
1289
|
+
return defaultValue;
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
function readBool(name, defaultValue) {
|
|
1293
|
+
if (_consent === "accept") {
|
|
1294
|
+
let str2 = _read(name);
|
|
1295
|
+
return str2 === void 0 ? defaultValue : /true|1/i.test(str2);
|
|
1296
|
+
} else {
|
|
1297
|
+
return defaultValue;
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
function erase(name) {
|
|
1301
|
+
if (_consent === "accept" || name === ConsentCookieName)
|
|
1302
|
+
_erase(name);
|
|
1303
|
+
}
|
|
1304
|
+
function eraseAll() {
|
|
1305
|
+
if (typeof document !== "undefined")
|
|
1306
|
+
document.cookie.split(";").forEach((c) => erase(c.trim().split("=")[0]));
|
|
1307
|
+
}
|
|
1308
|
+
var device_exports = {};
|
|
1309
|
+
__export2(device_exports, {
|
|
1310
|
+
DPI: () => DPI,
|
|
1311
|
+
FontSize: () => FontSize,
|
|
1312
|
+
HostAddress: () => HostAddress,
|
|
1313
|
+
IsMobileDevice: () => IsMobileDevice,
|
|
1314
|
+
IsTouchDevice: () => IsTouchDevice,
|
|
1315
|
+
PxPerMm: () => PxPerMm,
|
|
1316
|
+
ScrollbarWidth: () => ScrollbarWidth,
|
|
1317
|
+
mmToPx: () => mmToPx,
|
|
1318
|
+
pxToMm: () => pxToMm,
|
|
1319
|
+
toPx: () => toPx
|
|
1320
|
+
});
|
|
1321
|
+
function getDPI() {
|
|
1322
|
+
try {
|
|
1323
|
+
let el = document.createElement("div");
|
|
1324
|
+
el.style.width = "1in";
|
|
1325
|
+
document.body.appendChild(el);
|
|
1326
|
+
let dpi = el.offsetWidth;
|
|
1327
|
+
el.remove();
|
|
1328
|
+
return dpi || 96;
|
|
1329
|
+
} catch (e) {
|
|
1330
|
+
return 96;
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
function getScrollBarWidth() {
|
|
1334
|
+
try {
|
|
1335
|
+
let outer = document.createElement("div");
|
|
1336
|
+
outer.style.visibility = "hidden";
|
|
1337
|
+
outer.style.width = "100px";
|
|
1338
|
+
document.body.appendChild(outer);
|
|
1339
|
+
let widthNoScroll = outer.offsetWidth;
|
|
1340
|
+
outer.style.overflow = "scroll";
|
|
1341
|
+
let inner = document.createElement("div");
|
|
1342
|
+
inner.style.width = "100%";
|
|
1343
|
+
outer.appendChild(inner);
|
|
1344
|
+
let widthWithScroll = inner.offsetWidth;
|
|
1345
|
+
if (outer.parentNode) {
|
|
1346
|
+
outer.parentNode.removeChild(outer);
|
|
1347
|
+
}
|
|
1348
|
+
return widthNoScroll - widthWithScroll;
|
|
1349
|
+
} catch (e) {
|
|
1350
|
+
return 0;
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
function getSystemFontSize() {
|
|
1354
|
+
try {
|
|
1355
|
+
let tmpDiv = document.createElement("div");
|
|
1356
|
+
tmpDiv.style.cssText = "display:inline-block; padding:0; line-height:1; position:absolute; visibility:hidden; font-size:1em";
|
|
1357
|
+
tmpDiv.appendChild(document.createTextNode("M"));
|
|
1358
|
+
document.body.appendChild(tmpDiv);
|
|
1359
|
+
let fontsize = tmpDiv.offsetHeight;
|
|
1360
|
+
document.body.removeChild(tmpDiv);
|
|
1361
|
+
return fontsize;
|
|
1362
|
+
} catch (e) {
|
|
1363
|
+
return 16;
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
function getIsTouchDevice() {
|
|
1367
|
+
if (typeof window === "undefined")
|
|
1368
|
+
return false;
|
|
1369
|
+
if ("ontouchstart" in window || "DocumentTouch" in window || "createTouch" in document && "createTouchList" in document)
|
|
1370
|
+
return true;
|
|
1371
|
+
var prefixes = " -webkit- -moz- -o- -ms- ".split(" ");
|
|
1372
|
+
var mq = function(query2) {
|
|
1373
|
+
return window.matchMedia(query2).matches;
|
|
1374
|
+
};
|
|
1375
|
+
var query = ["(", prefixes.join("touch-enabled),("), "heartz", ")"].join("");
|
|
1376
|
+
return mq(query);
|
|
1377
|
+
}
|
|
1378
|
+
function getIsMobileDevice() {
|
|
1379
|
+
let a = navigator.userAgent || navigator.vendor || window.opera;
|
|
1380
|
+
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));
|
|
1381
|
+
}
|
|
1382
|
+
function getHostAddress() {
|
|
1383
|
+
if (typeof location === "undefined" || !location.host) {
|
|
1384
|
+
return "localhost";
|
|
1385
|
+
}
|
|
1386
|
+
return `${location.protocol}//${location.host}`;
|
|
1387
|
+
}
|
|
1388
|
+
var UnitRegExp = /^(mm|cm|in|inch|px|em)$/;
|
|
1389
|
+
var ValueUnitRegExp = /^([0-9\\.]+)(.*)$/;
|
|
1390
|
+
var DPI = getDPI();
|
|
1391
|
+
var PxPerMm = DPI / 25.4;
|
|
1392
|
+
var ScrollbarWidth = getScrollBarWidth();
|
|
1393
|
+
var FontSize = getSystemFontSize();
|
|
1394
|
+
var IsTouchDevice = getIsTouchDevice();
|
|
1395
|
+
var IsMobileDevice = getIsMobileDevice();
|
|
1396
|
+
var HostAddress = getHostAddress();
|
|
1397
|
+
function pxToMm(px) {
|
|
1398
|
+
return px / PxPerMm;
|
|
1399
|
+
}
|
|
1400
|
+
function mmToPx(mm) {
|
|
1401
|
+
return mm * PxPerMm;
|
|
1402
|
+
}
|
|
1403
|
+
function toPx(input) {
|
|
1404
|
+
if (typeof input === "number") {
|
|
1405
|
+
return input;
|
|
1406
|
+
}
|
|
1407
|
+
let value = NaN;
|
|
1408
|
+
let unit = void 0;
|
|
1409
|
+
let match = input.toString().match(ValueUnitRegExp);
|
|
1410
|
+
if (match && match[1]) {
|
|
1411
|
+
value = parseFloat(match[1]);
|
|
1412
|
+
let unitStr = match[2] ? match[2].toLowerCase() : "undefined";
|
|
1413
|
+
let unitStrOk = UnitRegExp.test(unitStr);
|
|
1414
|
+
unit = unitStrOk ? unitStr : void 0;
|
|
1415
|
+
if (!unit) {
|
|
1416
|
+
console.log("Unknown unit '" + unitStr + "' => using 'px'.");
|
|
1417
|
+
}
|
|
1418
|
+
} else {
|
|
1419
|
+
value = parseFloat(input);
|
|
1420
|
+
}
|
|
1421
|
+
assert_exports.isFinite(value, "value in function toPx");
|
|
1422
|
+
switch (unit) {
|
|
1423
|
+
case "mm":
|
|
1424
|
+
return mmToPx(value);
|
|
1425
|
+
case "cm":
|
|
1426
|
+
return mmToPx(value) * 10;
|
|
1427
|
+
case "in":
|
|
1428
|
+
case "inch":
|
|
1429
|
+
return mmToPx(value) * 25.4;
|
|
1430
|
+
case "em":
|
|
1431
|
+
return FontSize * value;
|
|
1432
|
+
default:
|
|
1433
|
+
case "px":
|
|
1434
|
+
return value;
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
var utils_exports = {};
|
|
1438
|
+
__export2(utils_exports, {
|
|
1439
|
+
Arr: () => arr_exports,
|
|
1440
|
+
Dom: () => dom_exports,
|
|
1441
|
+
Enum: () => enum_exports,
|
|
1442
|
+
Math: () => math_exports,
|
|
1443
|
+
Obj: () => obj_exports,
|
|
1444
|
+
Str: () => str_exports
|
|
1445
|
+
});
|
|
1446
|
+
var arr_exports = {};
|
|
1447
|
+
__export2(arr_exports, {
|
|
1448
|
+
arrayContains: () => arrayContains,
|
|
1449
|
+
chunckArray: () => chunckArray,
|
|
1450
|
+
duplicate: () => duplicate,
|
|
1451
|
+
fillArray: () => fillArray,
|
|
1452
|
+
getRangeArray: () => getRangeArray,
|
|
1453
|
+
getSequenceArray: () => getSequenceArray,
|
|
1454
|
+
isArray: () => isArray,
|
|
1455
|
+
mapRangeArray: () => mapRangeArray,
|
|
1456
|
+
mapSequenceArray: () => mapSequenceArray,
|
|
1457
|
+
removeDuplicates: () => removeDuplicates,
|
|
1458
|
+
toArray: () => toArray
|
|
1459
|
+
});
|
|
1460
|
+
function toArray(a) {
|
|
1461
|
+
return isArray(a) ? a : [a];
|
|
1462
|
+
}
|
|
1463
|
+
function duplicate(a) {
|
|
1464
|
+
var _a;
|
|
1465
|
+
return (_a = a == null ? void 0 : a.slice()) != null ? _a : [];
|
|
1466
|
+
}
|
|
1467
|
+
function removeDuplicates(arr, compareFn) {
|
|
1468
|
+
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));
|
|
1469
|
+
}
|
|
1470
|
+
function fillArray(fillValue, fillCount) {
|
|
1471
|
+
if (!isInteger(fillCount) || fillCount < 0) {
|
|
1472
|
+
throw new Error("fillArray: Invalid fillCount = " + fillCount);
|
|
1473
|
+
}
|
|
1474
|
+
return new Array(fillCount).fill(fillValue);
|
|
1475
|
+
}
|
|
1476
|
+
function mapSequenceArray(len, fn) {
|
|
1477
|
+
if (!isInteger(len) || len < 0) {
|
|
1478
|
+
throw new Error("mapSequenceArray: Invalid len = " + len);
|
|
1479
|
+
}
|
|
1480
|
+
let arr = new Array(len);
|
|
1481
|
+
for (let i = 0; i < len; i++) {
|
|
1482
|
+
arr[i] = fn(i);
|
|
1483
|
+
}
|
|
1484
|
+
return arr;
|
|
1485
|
+
}
|
|
1486
|
+
function getSequenceArray(len) {
|
|
1487
|
+
return mapSequenceArray(len, (i) => i);
|
|
1488
|
+
}
|
|
1489
|
+
function mapRangeArray(start, end, fn) {
|
|
1490
|
+
if (!isInteger(start)) {
|
|
1491
|
+
throw new Error("mapRangeArray: Invalid start = " + end);
|
|
1492
|
+
}
|
|
1493
|
+
if (!isInteger(end)) {
|
|
1494
|
+
throw new Error("mapRangeArray: Invalid end = " + end);
|
|
1495
|
+
}
|
|
1496
|
+
let len = Math.abs(end - start) + 1;
|
|
1497
|
+
let arr = new Array(len);
|
|
1498
|
+
for (let i = 0, s = start, inc = Math.sign(end - start); i < len; s += inc, i++) {
|
|
1499
|
+
arr[i] = fn(s);
|
|
1500
|
+
}
|
|
1501
|
+
return arr;
|
|
1502
|
+
}
|
|
1503
|
+
function getRangeArray(start, end) {
|
|
1504
|
+
return mapRangeArray(start, end, (i) => i);
|
|
1505
|
+
}
|
|
1506
|
+
function arrayContains(arg, item) {
|
|
1507
|
+
return arg.indexOf(item) >= 0;
|
|
1508
|
+
}
|
|
1509
|
+
function chunckArray(arr, chunckSize) {
|
|
1510
|
+
if (!isInteger(chunckSize) || chunckSize < 1) {
|
|
1511
|
+
throw new Error("chunckArray: Invalid chunckSize = " + chunckSize);
|
|
1512
|
+
}
|
|
1513
|
+
let result = [];
|
|
1514
|
+
for (let i = 0; i < arr.length; i += chunckSize) {
|
|
1515
|
+
result.push(arr.slice(i, i + chunckSize));
|
|
1516
|
+
}
|
|
1517
|
+
return result;
|
|
1518
|
+
}
|
|
1519
|
+
var dom_exports = {};
|
|
1520
|
+
__export2(dom_exports, {
|
|
1521
|
+
addClass: () => addClass,
|
|
1522
|
+
appendTo: () => appendTo,
|
|
1523
|
+
getButton: () => getButton,
|
|
1524
|
+
getCanvas: () => getCanvas,
|
|
1525
|
+
getCanvasTextWidth: () => getCanvasTextWidth,
|
|
1526
|
+
getDimension: () => getDimension,
|
|
1527
|
+
getHeight: () => getHeight,
|
|
1528
|
+
getOffset: () => getOffset,
|
|
1529
|
+
getPadding: () => getPadding,
|
|
1530
|
+
getWidth: () => getWidth,
|
|
1531
|
+
hasClass: () => hasClass,
|
|
1532
|
+
injectCss: () => injectCss,
|
|
1533
|
+
removeClass: () => removeClass,
|
|
1534
|
+
removeFromParent: () => removeFromParent,
|
|
1535
|
+
setHeight: () => setHeight,
|
|
1536
|
+
setOffset: () => setOffset,
|
|
1537
|
+
setRect: () => setRect,
|
|
1538
|
+
setVisibility: () => setVisibility,
|
|
1539
|
+
setWidth: () => setWidth,
|
|
1540
|
+
styleLayoutChanged: () => styleLayoutChanged
|
|
1541
|
+
});
|
|
1542
|
+
function _getElemById(id) {
|
|
1543
|
+
var _a;
|
|
1544
|
+
return typeof document === "undefined" ? void 0 : (_a = document.getElementById(id)) != null ? _a : void 0;
|
|
1545
|
+
}
|
|
1546
|
+
function toPx2(value) {
|
|
1547
|
+
return value === void 0 ? void 0 : device_exports.toPx(value);
|
|
1548
|
+
}
|
|
1549
|
+
function hasClass(el, className) {
|
|
1550
|
+
if (className.length === 0) {
|
|
1551
|
+
return false;
|
|
1552
|
+
} else if (el.classList) {
|
|
1553
|
+
return el.classList.contains(className);
|
|
1554
|
+
} else {
|
|
1555
|
+
return !!el.className.match(new RegExp("(\\s|^)" + className + "(\\s|$)"));
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
function addClass(el, className) {
|
|
1559
|
+
if (className.length === 0) {
|
|
1560
|
+
return;
|
|
1561
|
+
} else if (el.classList) {
|
|
1562
|
+
el.classList.add(className);
|
|
1563
|
+
} else if (!hasClass(el, className)) {
|
|
1564
|
+
el.className += " " + className;
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
function removeClass(el, className) {
|
|
1568
|
+
if (className.length === 0) {
|
|
1569
|
+
return;
|
|
1570
|
+
} else if (el.classList) {
|
|
1571
|
+
el.classList.remove(className);
|
|
1572
|
+
} else if (hasClass(el, className)) {
|
|
1573
|
+
var reg = new RegExp("(\\s|^)" + className + "(\\s|$)");
|
|
1574
|
+
el.className = el.className.replace(reg, " ");
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
function setOffset(el, left, top, unit = "px") {
|
|
1578
|
+
el.style.left = left + unit;
|
|
1579
|
+
el.style.top = top + unit;
|
|
1580
|
+
}
|
|
1581
|
+
function getOffset(el) {
|
|
1582
|
+
let { left, top } = el.getBoundingClientRect();
|
|
1583
|
+
if (typeof window !== "undefined") {
|
|
1584
|
+
left += window.pageXOffset;
|
|
1585
|
+
top += window.pageYOffset;
|
|
1586
|
+
}
|
|
1587
|
+
if (typeof document !== "undefined") {
|
|
1588
|
+
let de = document.documentElement;
|
|
1589
|
+
left -= de.clientLeft;
|
|
1590
|
+
top -= de.clientTop;
|
|
1591
|
+
}
|
|
1592
|
+
return { left, top };
|
|
1593
|
+
}
|
|
1594
|
+
function getWidth(el) {
|
|
1595
|
+
if (el instanceof Window) {
|
|
1596
|
+
return el.innerWidth;
|
|
1597
|
+
} else {
|
|
1598
|
+
let w = parseFloat(getComputedStyle(el, null).width.replace("px", ""));
|
|
1599
|
+
return isNaN(w) ? 0 : w;
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
function setWidth(el, val) {
|
|
1603
|
+
el.style.width = val + "px";
|
|
1604
|
+
}
|
|
1605
|
+
function getHeight(el) {
|
|
1606
|
+
if (el instanceof Window) {
|
|
1607
|
+
return el.innerHeight;
|
|
1608
|
+
} else {
|
|
1609
|
+
let h = parseFloat(getComputedStyle(el, null).height.replace("px", ""));
|
|
1610
|
+
return isNaN(h) ? 0 : h;
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
function setHeight(el, val) {
|
|
1614
|
+
el.style.height = val + "px";
|
|
1615
|
+
}
|
|
1616
|
+
function appendTo(el, to) {
|
|
1617
|
+
to.appendChild(el);
|
|
1618
|
+
}
|
|
1619
|
+
function removeFromParent(el) {
|
|
1620
|
+
el.remove();
|
|
1621
|
+
}
|
|
1622
|
+
function setVisibility(el, visible) {
|
|
1623
|
+
el.style.display = visible ? "block" : "none";
|
|
1624
|
+
}
|
|
1625
|
+
function setRect(el, left, top, width, height, unit = "px") {
|
|
1626
|
+
el.style.left = left + unit;
|
|
1627
|
+
el.style.top = top + unit;
|
|
1628
|
+
el.style.width = width + unit;
|
|
1629
|
+
el.style.height = height + unit;
|
|
1630
|
+
}
|
|
1631
|
+
function getButton(btn) {
|
|
1632
|
+
let el = typeof btn === "string" ? _getElemById(btn) : btn;
|
|
1633
|
+
return el instanceof HTMLButtonElement ? el : void 0;
|
|
1634
|
+
}
|
|
1635
|
+
function getCanvas(canvas2) {
|
|
1636
|
+
let el = typeof canvas2 === "string" ? _getElemById(canvas2) : canvas2;
|
|
1637
|
+
return el instanceof HTMLCanvasElement ? el : void 0;
|
|
1638
|
+
}
|
|
1639
|
+
function getPadding(style) {
|
|
1640
|
+
var _a;
|
|
1641
|
+
if (!style) {
|
|
1642
|
+
return { top: 0, right: 0, bottom: 0, left: 0 };
|
|
1643
|
+
}
|
|
1644
|
+
let top = toPx2(style.paddingTop);
|
|
1645
|
+
let right = toPx2(style.paddingRight);
|
|
1646
|
+
let bottom = toPx2(style.paddingBottom);
|
|
1647
|
+
let left = toPx2(style.paddingLeft);
|
|
1648
|
+
let padding = ((_a = style.padding) != null ? _a : "").toString().split(" ").filter((s) => s.length > 0);
|
|
1649
|
+
switch (padding.length) {
|
|
1650
|
+
case 0:
|
|
1651
|
+
break;
|
|
1652
|
+
case 1:
|
|
1653
|
+
top != null ? top : top = toPx2(padding[0]);
|
|
1654
|
+
right != null ? right : right = toPx2(padding[0]);
|
|
1655
|
+
bottom != null ? bottom : bottom = toPx2(padding[0]);
|
|
1656
|
+
left != null ? left : left = toPx2(padding[0]);
|
|
1657
|
+
break;
|
|
1658
|
+
case 2:
|
|
1659
|
+
top != null ? top : top = toPx2(padding[0]);
|
|
1660
|
+
right != null ? right : right = toPx2(padding[1]);
|
|
1661
|
+
bottom != null ? bottom : bottom = toPx2(padding[0]);
|
|
1662
|
+
left != null ? left : left = toPx2(padding[1]);
|
|
1663
|
+
break;
|
|
1664
|
+
case 3:
|
|
1665
|
+
top != null ? top : top = toPx2(padding[0]);
|
|
1666
|
+
right != null ? right : right = toPx2(padding[1]);
|
|
1667
|
+
bottom != null ? bottom : bottom = toPx2(padding[2]);
|
|
1668
|
+
left != null ? left : left = toPx2(padding[1]);
|
|
1669
|
+
break;
|
|
1670
|
+
case 4:
|
|
1671
|
+
default:
|
|
1672
|
+
top != null ? top : top = toPx2(padding[0]);
|
|
1673
|
+
right != null ? right : right = toPx2(padding[1]);
|
|
1674
|
+
bottom != null ? bottom : bottom = toPx2(padding[2]);
|
|
1675
|
+
left != null ? left : left = toPx2(padding[3]);
|
|
1676
|
+
break;
|
|
1677
|
+
}
|
|
1678
|
+
top != null ? top : top = 0;
|
|
1679
|
+
right != null ? right : right = 0;
|
|
1680
|
+
bottom != null ? bottom : bottom = 0;
|
|
1681
|
+
left != null ? left : left = 0;
|
|
1682
|
+
return { top, right, bottom, left };
|
|
1683
|
+
}
|
|
1684
|
+
function getDimension(style) {
|
|
1685
|
+
let left = toPx2(style == null ? void 0 : style.left);
|
|
1686
|
+
let right = toPx2(style == null ? void 0 : style.right);
|
|
1687
|
+
let top = toPx2(style == null ? void 0 : style.top);
|
|
1688
|
+
let bottom = toPx2(style == null ? void 0 : style.bottom);
|
|
1689
|
+
let width = toPx2(style == null ? void 0 : style.width);
|
|
1690
|
+
let height = toPx2(style == null ? void 0 : style.height);
|
|
1691
|
+
if (width === void 0 && left !== void 0 && right !== void 0) {
|
|
1692
|
+
width = right - left;
|
|
1693
|
+
}
|
|
1694
|
+
if (height === void 0 && top !== void 0 && bottom !== void 0) {
|
|
1695
|
+
height = bottom - top;
|
|
1696
|
+
}
|
|
1697
|
+
return { left, top, width, height };
|
|
1698
|
+
}
|
|
1699
|
+
function styleLayoutChanged(style1, style2) {
|
|
1700
|
+
if (!style1 && !style2) {
|
|
1701
|
+
return false;
|
|
1702
|
+
} else if (!style1 || !style2) {
|
|
1703
|
+
return true;
|
|
1704
|
+
} else {
|
|
1705
|
+
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;
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
var canvas;
|
|
1709
|
+
function getCanvasTextWidth(text, font) {
|
|
1710
|
+
if (!canvas && typeof document !== "undefined")
|
|
1711
|
+
canvas = document.createElement("canvas");
|
|
1712
|
+
let ctx = canvas == null ? void 0 : canvas.getContext("2d");
|
|
1713
|
+
if (!ctx)
|
|
1714
|
+
return 0;
|
|
1715
|
+
ctx.font = font;
|
|
1716
|
+
return ctx.measureText(text).width;
|
|
1717
|
+
}
|
|
1718
|
+
function injectCss(styleId, styleCss) {
|
|
1719
|
+
if (styleId === "" || styleCss === "") return;
|
|
1720
|
+
if (typeof document === "undefined") return;
|
|
1721
|
+
if (document.getElementById(styleId)) return;
|
|
1722
|
+
const style = document.createElement("style");
|
|
1723
|
+
style.id = styleId;
|
|
1724
|
+
style.textContent = styleCss;
|
|
1725
|
+
document.head.appendChild(style);
|
|
1726
|
+
}
|
|
1727
|
+
var math_exports = {};
|
|
1728
|
+
__export2(math_exports, {
|
|
1729
|
+
avg: () => avg,
|
|
1730
|
+
calcNormal: () => calcNormal,
|
|
1731
|
+
clamp: () => clamp,
|
|
1732
|
+
cmp: () => cmp,
|
|
1733
|
+
interpolateCoord: () => interpolateCoord,
|
|
1734
|
+
interpolateY: () => interpolateY,
|
|
1735
|
+
isInteger: () => isInteger,
|
|
1736
|
+
isNumber: () => isNumber,
|
|
1737
|
+
linearToDecibels: () => linearToDecibels,
|
|
1738
|
+
mod: () => mod,
|
|
1739
|
+
romanize: () => romanize,
|
|
1740
|
+
sum: () => sum,
|
|
1741
|
+
toOrdinalNumber: () => toOrdinalNumber
|
|
1742
|
+
});
|
|
1743
|
+
function linearToDecibels(linearVolume) {
|
|
1744
|
+
if (!isFinite(linearVolume)) {
|
|
1745
|
+
throw new Error("linearToDecibel: Invalid linearVolume = " + linearVolume);
|
|
1746
|
+
} else if (linearVolume <= 0) {
|
|
1747
|
+
return -Infinity;
|
|
1748
|
+
} else {
|
|
1749
|
+
return 20 * Math.log10(linearVolume);
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
function mod(m, n) {
|
|
1753
|
+
return (m % n + n) % n;
|
|
1754
|
+
}
|
|
1755
|
+
function romanize(n) {
|
|
1756
|
+
if (!isInteger(n) || n < 0) {
|
|
1757
|
+
throw new Error("romanize: Invalid n = " + n);
|
|
1758
|
+
}
|
|
1759
|
+
var digits = String(+n).split("");
|
|
1760
|
+
var key = [
|
|
1761
|
+
"",
|
|
1762
|
+
"C",
|
|
1763
|
+
"CC",
|
|
1764
|
+
"CCC",
|
|
1765
|
+
"CD",
|
|
1766
|
+
"D",
|
|
1767
|
+
"DC",
|
|
1768
|
+
"DCC",
|
|
1769
|
+
"DCCC",
|
|
1770
|
+
"CM",
|
|
1771
|
+
"",
|
|
1772
|
+
"X",
|
|
1773
|
+
"XX",
|
|
1774
|
+
"XXX",
|
|
1775
|
+
"XL",
|
|
1776
|
+
"L",
|
|
1777
|
+
"LX",
|
|
1778
|
+
"LXX",
|
|
1779
|
+
"LXXX",
|
|
1780
|
+
"XC",
|
|
1781
|
+
"",
|
|
1782
|
+
"I",
|
|
1783
|
+
"II",
|
|
1784
|
+
"III",
|
|
1785
|
+
"IV",
|
|
1786
|
+
"V",
|
|
1787
|
+
"VI",
|
|
1788
|
+
"VII",
|
|
1789
|
+
"VIII",
|
|
1790
|
+
"IX"
|
|
1791
|
+
];
|
|
1792
|
+
var roman = "", i = 3;
|
|
1793
|
+
while (i--) roman = (key[+digits.pop() + i * 10] || "") + roman;
|
|
1794
|
+
return Array(+digits.join("") + 1).join("M") + roman;
|
|
1795
|
+
}
|
|
1796
|
+
function toOrdinalNumber(n) {
|
|
1797
|
+
if (!isInteger(n)) {
|
|
1798
|
+
throw new Error("toOrdinalNumber: Invalid n = " + n);
|
|
1799
|
+
}
|
|
1800
|
+
const nStr = n.toString();
|
|
1801
|
+
const lastDigit = Number(nStr.charAt(nStr.length - 1));
|
|
1802
|
+
if (n === 1 || n >= 20 && lastDigit === 1) {
|
|
1803
|
+
return nStr + "st";
|
|
1804
|
+
} else if (n === 2 || n >= 20 && lastDigit === 2) {
|
|
1805
|
+
return nStr + "nd";
|
|
1806
|
+
} else if (n === 3 || n >= 20 && lastDigit === 3) {
|
|
1807
|
+
return nStr + "rd";
|
|
1808
|
+
} else {
|
|
1809
|
+
return nStr + "th";
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
function interpolateCoord(startX, startY, endX, endY, t) {
|
|
1813
|
+
return {
|
|
1814
|
+
x: startX + (endX - startX) * t,
|
|
1815
|
+
y: startY + (endY - startY) * t
|
|
1816
|
+
};
|
|
1817
|
+
}
|
|
1818
|
+
function interpolateY(startX, startY, endX, endY, x) {
|
|
1819
|
+
let t = (x - startX) / (endX - startX);
|
|
1820
|
+
return startY + (endY - startY) * t;
|
|
1821
|
+
}
|
|
1822
|
+
function clamp(num, min, max) {
|
|
1823
|
+
return Math.min(Math.max(num, min), max);
|
|
1824
|
+
}
|
|
1825
|
+
function calcNormal(x1, y1, x2, y2) {
|
|
1826
|
+
let dx = x2 - x1;
|
|
1827
|
+
let dy = y2 - y1;
|
|
1828
|
+
let nx = -dy;
|
|
1829
|
+
let ny = dx;
|
|
1830
|
+
let len = Math.sqrt(nx * nx + ny * ny);
|
|
1831
|
+
if (len > 0) {
|
|
1832
|
+
nx /= len;
|
|
1833
|
+
ny /= len;
|
|
1834
|
+
} else {
|
|
1835
|
+
nx = 0;
|
|
1836
|
+
ny = 1;
|
|
1837
|
+
}
|
|
1838
|
+
return { nx, ny };
|
|
1839
|
+
}
|
|
1840
|
+
function sum(arr) {
|
|
1841
|
+
return arr.reduce((prev, cur) => cur + prev, 0);
|
|
1842
|
+
}
|
|
1843
|
+
function avg(...values) {
|
|
1844
|
+
return sum(values) / values.length;
|
|
1845
|
+
}
|
|
1846
|
+
function cmp(a, b) {
|
|
1847
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
1848
|
+
}
|
|
1849
|
+
var DefaultEqualityFn = (a, b) => a === b;
|
|
1850
|
+
var BaseContainer = class {
|
|
1851
|
+
};
|
|
1852
|
+
var LRUCache = class extends BaseContainer {
|
|
1853
|
+
// Maximum key length.
|
|
1854
|
+
constructor(maxSize, maxKeyLength = Infinity) {
|
|
1855
|
+
super();
|
|
1856
|
+
__publicField2(this, "cache");
|
|
1857
|
+
__publicField2(this, "next");
|
|
1858
|
+
__publicField2(this, "prev");
|
|
1859
|
+
__publicField2(this, "head");
|
|
1860
|
+
__publicField2(this, "tail");
|
|
1861
|
+
__publicField2(this, "capacity");
|
|
1862
|
+
__publicField2(this, "size");
|
|
1863
|
+
__publicField2(this, "maxKeyLength");
|
|
1864
|
+
this.cache = /* @__PURE__ */ Object.create(null);
|
|
1865
|
+
this.next = /* @__PURE__ */ Object.create(null);
|
|
1866
|
+
this.prev = /* @__PURE__ */ Object.create(null);
|
|
1867
|
+
this.head = null;
|
|
1868
|
+
this.tail = null;
|
|
1869
|
+
this.capacity = maxSize;
|
|
1870
|
+
this.size = 0;
|
|
1871
|
+
this.maxKeyLength = maxKeyLength;
|
|
1872
|
+
}
|
|
1873
|
+
// Retrieves a value from the cache
|
|
1874
|
+
get(key) {
|
|
1875
|
+
if (key.length > this.maxKeyLength) return void 0;
|
|
1876
|
+
if (this.cache[key] !== void 0) {
|
|
1877
|
+
this.touch(key);
|
|
1878
|
+
return this.cache[key];
|
|
1879
|
+
}
|
|
1880
|
+
return void 0;
|
|
1881
|
+
}
|
|
1882
|
+
set(key, value) {
|
|
1883
|
+
if (key.length > this.maxKeyLength) {
|
|
1884
|
+
return;
|
|
1885
|
+
}
|
|
1886
|
+
if (this.cache[key] !== void 0) {
|
|
1887
|
+
this.cache[key] = value;
|
|
1888
|
+
this.touch(key);
|
|
1889
|
+
return;
|
|
1890
|
+
}
|
|
1891
|
+
if (this.size >= this.capacity) {
|
|
1892
|
+
this.evict();
|
|
1893
|
+
}
|
|
1894
|
+
this.cache[key] = value;
|
|
1895
|
+
this.addToTail(key);
|
|
1896
|
+
this.size++;
|
|
1897
|
+
}
|
|
1898
|
+
// Marks a key as most recently used
|
|
1899
|
+
touch(key) {
|
|
1900
|
+
if (this.tail === key) return;
|
|
1901
|
+
this.removeKey(key);
|
|
1902
|
+
this.addToTail(key);
|
|
1903
|
+
}
|
|
1904
|
+
// Evicts the least recently used item (at the head)
|
|
1905
|
+
evict() {
|
|
1906
|
+
if (this.head !== null) {
|
|
1907
|
+
const oldestKey = this.head;
|
|
1908
|
+
this.removeKey(oldestKey);
|
|
1909
|
+
delete this.cache[oldestKey];
|
|
1910
|
+
this.size--;
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
// Removes a key from the linked list
|
|
1914
|
+
removeKey(key) {
|
|
1915
|
+
const prevKey = this.prev[key];
|
|
1916
|
+
const nextKey = this.next[key];
|
|
1917
|
+
if (prevKey !== void 0) {
|
|
1918
|
+
this.next[prevKey] = nextKey;
|
|
1919
|
+
} else {
|
|
1920
|
+
this.head = nextKey != null ? nextKey : null;
|
|
1921
|
+
}
|
|
1922
|
+
if (nextKey !== void 0) {
|
|
1923
|
+
this.prev[nextKey] = prevKey;
|
|
1924
|
+
} else {
|
|
1925
|
+
this.tail = prevKey != null ? prevKey : null;
|
|
1926
|
+
}
|
|
1927
|
+
delete this.prev[key];
|
|
1928
|
+
delete this.next[key];
|
|
1929
|
+
}
|
|
1930
|
+
// Adds a key to the tail (most recently used position)
|
|
1931
|
+
addToTail(key) {
|
|
1932
|
+
if (this.tail !== null) {
|
|
1933
|
+
this.next[this.tail] = key;
|
|
1934
|
+
this.prev[key] = this.tail;
|
|
1935
|
+
} else {
|
|
1936
|
+
this.head = key;
|
|
1937
|
+
}
|
|
1938
|
+
this.tail = key;
|
|
1939
|
+
}
|
|
1940
|
+
*keys() {
|
|
1941
|
+
for (let key = this.head; key != null; key = this.next[key])
|
|
1942
|
+
yield key;
|
|
1943
|
+
}
|
|
1944
|
+
*values() {
|
|
1945
|
+
for (let key = this.head; key != null; key = this.next[key])
|
|
1946
|
+
yield this.cache[key];
|
|
1947
|
+
}
|
|
1948
|
+
*entries() {
|
|
1949
|
+
for (let key = this.head; key != null; key = this.next[key])
|
|
1950
|
+
yield [key, this.cache[key]];
|
|
1951
|
+
}
|
|
1952
|
+
*[Symbol.iterator]() {
|
|
1953
|
+
yield* __yieldStar(this.entries());
|
|
1954
|
+
}
|
|
1955
|
+
toString() {
|
|
1956
|
+
const entries = [...this.entries()];
|
|
1957
|
+
return entries.length === 0 ? `LRUCache(0){ }` : `LRUCache(${entries.length}){ ${entries.map((e) => `${stringify(e[0])}: ${stringify(e[1])}`).join(", ")} }`;
|
|
1958
|
+
}
|
|
1959
|
+
};
|
|
1960
|
+
var IndexArray = class _IndexArray extends BaseContainer {
|
|
1961
|
+
constructor(entries) {
|
|
1962
|
+
super();
|
|
1963
|
+
__publicField2(this, "posVal");
|
|
1964
|
+
__publicField2(this, "hasPos");
|
|
1965
|
+
__publicField2(this, "valCount");
|
|
1966
|
+
if (entries instanceof _IndexArray) {
|
|
1967
|
+
this.posVal = entries.posVal.slice();
|
|
1968
|
+
this.hasPos = entries.hasPos.slice();
|
|
1969
|
+
this.valCount = entries.valCount;
|
|
1970
|
+
} else {
|
|
1971
|
+
this.posVal = [];
|
|
1972
|
+
this.hasPos = [];
|
|
1973
|
+
this.valCount = 0;
|
|
1974
|
+
if (entries) {
|
|
1975
|
+
for (const [id, value] of entries) {
|
|
1976
|
+
this.set(id, value);
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
static validateIndex(id) {
|
|
1982
|
+
if (!isIntegerGte(id, 0)) throw new Error(`Invalid index ${id} - must be an integer >= 0!`);
|
|
1983
|
+
return id;
|
|
1984
|
+
}
|
|
1985
|
+
get posLen() {
|
|
1986
|
+
return this.hasPos.length;
|
|
1987
|
+
}
|
|
1988
|
+
get size() {
|
|
1989
|
+
return this.valCount;
|
|
1990
|
+
}
|
|
1991
|
+
get length() {
|
|
1992
|
+
return this.hasPos.length;
|
|
1993
|
+
}
|
|
1994
|
+
trimRight() {
|
|
1995
|
+
let newLength = this.length;
|
|
1996
|
+
while (newLength > 0 && this.hasPos[newLength - 1] !== true) newLength--;
|
|
1997
|
+
if (newLength < this.length) this.posVal.length = this.hasPos.length = newLength;
|
|
1998
|
+
}
|
|
1999
|
+
isEmpty() {
|
|
2000
|
+
return this.size === 0;
|
|
2001
|
+
}
|
|
2002
|
+
has(id) {
|
|
2003
|
+
_IndexArray.validateIndex(id);
|
|
2004
|
+
return this.hasPos[id] === true;
|
|
2005
|
+
}
|
|
2006
|
+
set(id, value) {
|
|
2007
|
+
_IndexArray.validateIndex(id);
|
|
2008
|
+
if (this.hasPos[id] !== true) this.valCount++;
|
|
2009
|
+
this.posVal[id] = value;
|
|
2010
|
+
this.hasPos[id] = true;
|
|
2011
|
+
}
|
|
2012
|
+
get(id) {
|
|
2013
|
+
_IndexArray.validateIndex(id);
|
|
2014
|
+
return this.hasPos[id] ? this.posVal[id] : void 0;
|
|
2015
|
+
}
|
|
2016
|
+
getOrDefault(id, defaultValue) {
|
|
2017
|
+
var _a;
|
|
2018
|
+
return (_a = this.get(id)) != null ? _a : defaultValue;
|
|
2019
|
+
}
|
|
2020
|
+
getOrCreate(id, creatorOrValue) {
|
|
2021
|
+
if (!this.has(id)) {
|
|
2022
|
+
const value = isFunction(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
2023
|
+
this.set(id, value);
|
|
2024
|
+
return value;
|
|
2025
|
+
}
|
|
2026
|
+
return this.get(id);
|
|
2027
|
+
}
|
|
2028
|
+
delete(id) {
|
|
2029
|
+
_IndexArray.validateIndex(id);
|
|
2030
|
+
if (!this.hasPos[id]) return false;
|
|
2031
|
+
this.posVal[id] = void 0;
|
|
2032
|
+
this.hasPos[id] = false;
|
|
2033
|
+
this.valCount--;
|
|
2034
|
+
this.trimRight();
|
|
2035
|
+
return true;
|
|
2036
|
+
}
|
|
2037
|
+
clear() {
|
|
2038
|
+
this.posVal = [];
|
|
2039
|
+
this.hasPos = [];
|
|
2040
|
+
this.valCount = 0;
|
|
2041
|
+
}
|
|
2042
|
+
forEach(callbackfn, thisArg) {
|
|
2043
|
+
for (const [id, value] of this.entries()) {
|
|
2044
|
+
callbackfn.call(thisArg, value, id, this);
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
*indices() {
|
|
2048
|
+
for (let id = 0; id < this.posLen; id++) {
|
|
2049
|
+
if (this.hasPos[id]) yield id;
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
*values() {
|
|
2053
|
+
for (let id = 0; id < this.posLen; id++) {
|
|
2054
|
+
if (this.hasPos[id]) yield this.posVal[id];
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
*entries() {
|
|
2058
|
+
for (let id = 0; id < this.posLen; id++) {
|
|
2059
|
+
if (this.hasPos[id]) yield [id, this.posVal[id]];
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
indicesArray() {
|
|
2063
|
+
return [...this.indices()];
|
|
2064
|
+
}
|
|
2065
|
+
valuesArray() {
|
|
2066
|
+
return [...this.values()];
|
|
2067
|
+
}
|
|
2068
|
+
entriesArray() {
|
|
2069
|
+
return [...this.entries()];
|
|
2070
|
+
}
|
|
2071
|
+
*kvKeys() {
|
|
2072
|
+
for (const id of this.indices()) {
|
|
2073
|
+
yield [id];
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
*kvValues() {
|
|
2077
|
+
for (const value of this.values()) {
|
|
2078
|
+
yield value;
|
|
2079
|
+
}
|
|
2080
|
+
}
|
|
2081
|
+
*kvEntries() {
|
|
2082
|
+
for (const [id, value] of this.entries()) {
|
|
2083
|
+
yield [[id], value];
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
*[Symbol.iterator]() {
|
|
2087
|
+
yield* __yieldStar(this.entries());
|
|
2088
|
+
}
|
|
2089
|
+
clone() {
|
|
2090
|
+
return new _IndexArray(this);
|
|
2091
|
+
}
|
|
2092
|
+
merge(other, conflictResolver) {
|
|
2093
|
+
for (const [id, value] of other.entries()) {
|
|
2094
|
+
if (this.has(id) && conflictResolver) {
|
|
2095
|
+
this.set(id, conflictResolver(this.get(id), value, id));
|
|
2096
|
+
} else {
|
|
2097
|
+
this.set(id, value);
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
return this;
|
|
2101
|
+
}
|
|
2102
|
+
some(fn) {
|
|
2103
|
+
for (const [id, value] of this.entries()) {
|
|
2104
|
+
if (fn(value, id)) return true;
|
|
2105
|
+
}
|
|
2106
|
+
return false;
|
|
2107
|
+
}
|
|
2108
|
+
every(fn) {
|
|
2109
|
+
for (const [id, value] of this.entries()) {
|
|
2110
|
+
if (!fn(value, id)) return false;
|
|
2111
|
+
}
|
|
2112
|
+
return true;
|
|
2113
|
+
}
|
|
2114
|
+
filter(predicate) {
|
|
2115
|
+
const result = new this.constructor();
|
|
2116
|
+
for (const [id, value] of this.entries()) {
|
|
2117
|
+
if (predicate(value, id, this)) result.set(id, value);
|
|
2118
|
+
}
|
|
2119
|
+
return result;
|
|
2120
|
+
}
|
|
2121
|
+
reduce(fn, init) {
|
|
2122
|
+
let iterator = this.entries();
|
|
2123
|
+
let first = iterator.next();
|
|
2124
|
+
if (first.done) {
|
|
2125
|
+
if (arguments.length < 2) {
|
|
2126
|
+
throw new TypeError("Reduce of empty IndexArray with no initial value!");
|
|
2127
|
+
}
|
|
2128
|
+
return init;
|
|
2129
|
+
}
|
|
2130
|
+
let acc;
|
|
2131
|
+
let start;
|
|
2132
|
+
if (arguments.length < 2) {
|
|
2133
|
+
acc = first.value[1];
|
|
2134
|
+
start = iterator.next();
|
|
2135
|
+
} else {
|
|
2136
|
+
acc = init;
|
|
2137
|
+
start = first;
|
|
2138
|
+
}
|
|
2139
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
2140
|
+
const [id, value] = current.value;
|
|
2141
|
+
acc = fn(acc, value, id);
|
|
2142
|
+
}
|
|
2143
|
+
return acc;
|
|
2144
|
+
}
|
|
2145
|
+
mapToArray(fn) {
|
|
2146
|
+
let result = [];
|
|
2147
|
+
for (const [id, value] of this.entries()) {
|
|
2148
|
+
result.push(fn(value, id));
|
|
2149
|
+
}
|
|
2150
|
+
return result;
|
|
2151
|
+
}
|
|
2152
|
+
map(fn) {
|
|
2153
|
+
let result = new _IndexArray();
|
|
2154
|
+
for (const [id, value] of this.entries()) {
|
|
2155
|
+
result.set(id, fn(value, id));
|
|
2156
|
+
}
|
|
2157
|
+
return result;
|
|
2158
|
+
}
|
|
2159
|
+
equals(other, eq) {
|
|
2160
|
+
if (this.size !== other.size) return false;
|
|
2161
|
+
eq != null ? eq : eq = (a, b) => a === b;
|
|
2162
|
+
const posLen = Math.max(this.posLen, other.posLen);
|
|
2163
|
+
for (let i = 0; i < posLen; ++i) {
|
|
2164
|
+
const hasA = this.hasPos[i];
|
|
2165
|
+
const hasB = other.hasPos[i];
|
|
2166
|
+
if (hasA !== hasB) return false;
|
|
2167
|
+
if (hasA && !eq(this.posVal[i], other.posVal[i])) return false;
|
|
2168
|
+
}
|
|
2169
|
+
return true;
|
|
2170
|
+
}
|
|
2171
|
+
toArray() {
|
|
2172
|
+
return this.valuesArray();
|
|
2173
|
+
}
|
|
2174
|
+
toString() {
|
|
2175
|
+
let isRegularArray = true;
|
|
2176
|
+
for (let i = 0; i < this.hasPos.length && isRegularArray; i++)
|
|
2177
|
+
if (!this.hasPos[i]) isRegularArray = false;
|
|
2178
|
+
if (isRegularArray)
|
|
2179
|
+
return stringify(this.posVal.slice(0, this.hasPos.length));
|
|
2180
|
+
const entries = this.entriesArray().map(([id, v]) => `${stringify(id)}: ${stringify(v)}`).join(", ");
|
|
2181
|
+
return entries.length === 0 ? `[ ]` : `[ ${entries} ]`;
|
|
2182
|
+
}
|
|
2183
|
+
};
|
|
2184
|
+
var SignedIndexArray = class _SignedIndexArray extends BaseContainer {
|
|
2185
|
+
constructor(entries) {
|
|
2186
|
+
super();
|
|
2187
|
+
__publicField2(this, "posVal");
|
|
2188
|
+
__publicField2(this, "hasPos");
|
|
2189
|
+
__publicField2(this, "negVal");
|
|
2190
|
+
__publicField2(this, "hasNeg");
|
|
2191
|
+
__publicField2(this, "valCount");
|
|
2192
|
+
if (entries instanceof _SignedIndexArray) {
|
|
2193
|
+
this.negVal = entries.negVal.slice();
|
|
2194
|
+
this.hasNeg = entries.hasNeg.slice();
|
|
2195
|
+
this.posVal = entries.posVal.slice();
|
|
2196
|
+
this.hasPos = entries.hasPos.slice();
|
|
2197
|
+
this.valCount = entries.valCount;
|
|
2198
|
+
} else {
|
|
2199
|
+
this.negVal = [];
|
|
2200
|
+
this.hasNeg = [];
|
|
2201
|
+
this.posVal = [];
|
|
2202
|
+
this.hasPos = [];
|
|
2203
|
+
this.valCount = 0;
|
|
2204
|
+
if (entries) {
|
|
2205
|
+
for (const [id, value] of entries) {
|
|
2206
|
+
this.set(id, value);
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
}
|
|
2211
|
+
static toNegIndex(id) {
|
|
2212
|
+
return -id - 1;
|
|
2213
|
+
}
|
|
2214
|
+
static validateIndex(id) {
|
|
2215
|
+
if (!isInteger(id)) throw new Error(`Invalid index ${id} - must be an integer!`);
|
|
2216
|
+
return id;
|
|
2217
|
+
}
|
|
2218
|
+
get size() {
|
|
2219
|
+
return this.valCount;
|
|
2220
|
+
}
|
|
2221
|
+
isEmpty() {
|
|
2222
|
+
return this.size === 0;
|
|
2223
|
+
}
|
|
2224
|
+
get posLen() {
|
|
2225
|
+
return this.hasPos.length;
|
|
2226
|
+
}
|
|
2227
|
+
get negLen() {
|
|
2228
|
+
return this.hasNeg.length;
|
|
2229
|
+
}
|
|
2230
|
+
has(id) {
|
|
2231
|
+
_SignedIndexArray.validateIndex(id);
|
|
2232
|
+
if (id >= 0) {
|
|
2233
|
+
return this.hasPos[id] === true;
|
|
2234
|
+
} else {
|
|
2235
|
+
return this.hasNeg[_SignedIndexArray.toNegIndex(id)] === true;
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
set(id, value) {
|
|
2239
|
+
_SignedIndexArray.validateIndex(id);
|
|
2240
|
+
if (id >= 0) {
|
|
2241
|
+
if (this.hasPos[id] !== true) this.valCount++;
|
|
2242
|
+
this.posVal[id] = value;
|
|
2243
|
+
this.hasPos[id] = true;
|
|
2244
|
+
} else {
|
|
2245
|
+
let negId = _SignedIndexArray.toNegIndex(id);
|
|
2246
|
+
if (this.hasNeg[negId] !== true) this.valCount++;
|
|
2247
|
+
this.negVal[negId] = value;
|
|
2248
|
+
this.hasNeg[negId] = true;
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
get(id) {
|
|
2252
|
+
_SignedIndexArray.validateIndex(id);
|
|
2253
|
+
if (id >= 0) {
|
|
2254
|
+
return this.hasPos[id] ? this.posVal[id] : void 0;
|
|
2255
|
+
} else {
|
|
2256
|
+
let negId = _SignedIndexArray.toNegIndex(id);
|
|
2257
|
+
return this.hasNeg[negId] ? this.negVal[negId] : void 0;
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
getOrDefault(id, defaultValue) {
|
|
2261
|
+
var _a;
|
|
2262
|
+
return (_a = this.get(id)) != null ? _a : defaultValue;
|
|
2263
|
+
}
|
|
2264
|
+
getOrCreate(id, creatorOrValue) {
|
|
2265
|
+
if (!this.has(id)) {
|
|
2266
|
+
const value = isFunction(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
2267
|
+
this.set(id, value);
|
|
2268
|
+
return value;
|
|
2269
|
+
}
|
|
2270
|
+
return this.get(id);
|
|
2271
|
+
}
|
|
2272
|
+
delete(id) {
|
|
2273
|
+
_SignedIndexArray.validateIndex(id);
|
|
2274
|
+
const isPos3 = id >= 0;
|
|
2275
|
+
const arr = isPos3 ? this.posVal : this.negVal;
|
|
2276
|
+
const has = isPos3 ? this.hasPos : this.hasNeg;
|
|
2277
|
+
const idx = isPos3 ? id : _SignedIndexArray.toNegIndex(id);
|
|
2278
|
+
if (!has[idx]) return false;
|
|
2279
|
+
arr[idx] = void 0;
|
|
2280
|
+
has[idx] = false;
|
|
2281
|
+
this.valCount--;
|
|
2282
|
+
return true;
|
|
2283
|
+
}
|
|
2284
|
+
clear() {
|
|
2285
|
+
this.negVal = [];
|
|
2286
|
+
this.hasNeg = [];
|
|
2287
|
+
this.posVal = [];
|
|
2288
|
+
this.hasPos = [];
|
|
2289
|
+
this.valCount = 0;
|
|
2290
|
+
}
|
|
2291
|
+
forEach(callbackfn, thisArg) {
|
|
2292
|
+
for (const [id, value] of this.entries()) {
|
|
2293
|
+
callbackfn.call(thisArg, value, id, this);
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
*indices() {
|
|
2297
|
+
for (let id = this.negLen - 1; id >= 0; id--) {
|
|
2298
|
+
if (this.hasNeg[id]) yield _SignedIndexArray.toNegIndex(id);
|
|
2299
|
+
}
|
|
2300
|
+
for (let id = 0; id < this.posLen; id++) {
|
|
2301
|
+
if (this.hasPos[id]) yield id;
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
*values() {
|
|
2305
|
+
for (let id = this.negLen - 1; id >= 0; id--) {
|
|
2306
|
+
if (this.hasNeg[id]) yield this.negVal[id];
|
|
2307
|
+
}
|
|
2308
|
+
for (let id = 0; id < this.posLen; id++) {
|
|
2309
|
+
if (this.hasPos[id]) yield this.posVal[id];
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
*entries() {
|
|
2313
|
+
for (let id = this.negLen - 1; id >= 0; id--) {
|
|
2314
|
+
if (this.hasNeg[id]) yield [_SignedIndexArray.toNegIndex(id), this.negVal[id]];
|
|
2315
|
+
}
|
|
2316
|
+
for (let id = 0; id < this.posLen; id++) {
|
|
2317
|
+
if (this.hasPos[id]) yield [id, this.posVal[id]];
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2320
|
+
indicesArray() {
|
|
2321
|
+
return [...this.indices()];
|
|
2322
|
+
}
|
|
2323
|
+
valuesArray() {
|
|
2324
|
+
return [...this.values()];
|
|
2325
|
+
}
|
|
2326
|
+
entriesArray() {
|
|
2327
|
+
return [...this.entries()];
|
|
2328
|
+
}
|
|
2329
|
+
*kvKeys() {
|
|
2330
|
+
for (const id of this.indices()) {
|
|
2331
|
+
yield [id];
|
|
2332
|
+
}
|
|
2333
|
+
}
|
|
2334
|
+
*kvValues() {
|
|
2335
|
+
for (const value of this.values()) {
|
|
2336
|
+
yield value;
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
*kvEntries() {
|
|
2340
|
+
for (const [id, value] of this.entries()) {
|
|
2341
|
+
yield [[id], value];
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2344
|
+
*[Symbol.iterator]() {
|
|
2345
|
+
yield* __yieldStar(this.entries());
|
|
2346
|
+
}
|
|
2347
|
+
clone() {
|
|
2348
|
+
return new _SignedIndexArray(this);
|
|
2349
|
+
}
|
|
2350
|
+
merge(other, conflictResolver) {
|
|
2351
|
+
for (const [id, value] of other.entries()) {
|
|
2352
|
+
if (this.has(id) && conflictResolver) {
|
|
2353
|
+
this.set(id, conflictResolver(this.get(id), value, id));
|
|
2354
|
+
} else {
|
|
2355
|
+
this.set(id, value);
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
return this;
|
|
2359
|
+
}
|
|
2360
|
+
some(fn) {
|
|
2361
|
+
for (const [id, value] of this.entries()) {
|
|
2362
|
+
if (fn(value, id)) return true;
|
|
2363
|
+
}
|
|
2364
|
+
return false;
|
|
2365
|
+
}
|
|
2366
|
+
every(fn) {
|
|
2367
|
+
for (const [id, value] of this.entries()) {
|
|
2368
|
+
if (!fn(value, id)) return false;
|
|
2369
|
+
}
|
|
2370
|
+
return true;
|
|
2371
|
+
}
|
|
2372
|
+
filter(predicate) {
|
|
2373
|
+
const result = new this.constructor();
|
|
2374
|
+
for (const [id, value] of this.entries()) {
|
|
2375
|
+
if (predicate(value, id, this)) result.set(id, value);
|
|
2376
|
+
}
|
|
2377
|
+
return result;
|
|
2378
|
+
}
|
|
2379
|
+
reduce(fn, init) {
|
|
2380
|
+
let iterator = this.entries();
|
|
2381
|
+
let first = iterator.next();
|
|
2382
|
+
if (first.done) {
|
|
2383
|
+
if (arguments.length < 2) {
|
|
2384
|
+
throw new TypeError("Reduce of empty SignedIndexArray with no initial value!");
|
|
2385
|
+
}
|
|
2386
|
+
return init;
|
|
2387
|
+
}
|
|
2388
|
+
let acc;
|
|
2389
|
+
let start;
|
|
2390
|
+
if (arguments.length < 2) {
|
|
2391
|
+
acc = first.value[1];
|
|
2392
|
+
start = iterator.next();
|
|
2393
|
+
} else {
|
|
2394
|
+
acc = init;
|
|
2395
|
+
start = first;
|
|
2396
|
+
}
|
|
2397
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
2398
|
+
const [id, value] = current.value;
|
|
2399
|
+
acc = fn(acc, value, id);
|
|
2400
|
+
}
|
|
2401
|
+
return acc;
|
|
2402
|
+
}
|
|
2403
|
+
mapToArray(fn) {
|
|
2404
|
+
let result = [];
|
|
2405
|
+
for (const [id, value] of this.entries()) {
|
|
2406
|
+
result.push(fn(value, id));
|
|
2407
|
+
}
|
|
2408
|
+
return result;
|
|
2409
|
+
}
|
|
2410
|
+
map(fn) {
|
|
2411
|
+
let result = new _SignedIndexArray();
|
|
2412
|
+
for (const [id, value] of this.entries()) {
|
|
2413
|
+
result.set(id, fn(value, id));
|
|
2414
|
+
}
|
|
2415
|
+
return result;
|
|
2416
|
+
}
|
|
2417
|
+
equals(other, eq) {
|
|
2418
|
+
if (this.size !== other.size) return false;
|
|
2419
|
+
eq != null ? eq : eq = (a, b) => a === b;
|
|
2420
|
+
const posLen = Math.max(this.posLen, other.posLen);
|
|
2421
|
+
for (let i = 0; i < posLen; ++i) {
|
|
2422
|
+
const hasA = this.hasPos[i];
|
|
2423
|
+
const hasB = other.hasPos[i];
|
|
2424
|
+
if (hasA !== hasB) return false;
|
|
2425
|
+
if (hasA && !eq(this.posVal[i], other.posVal[i])) return false;
|
|
2426
|
+
}
|
|
2427
|
+
const negLen = Math.max(this.negLen, other.negLen);
|
|
2428
|
+
for (let i = 0; i < negLen; ++i) {
|
|
2429
|
+
const hasA = this.hasNeg[i];
|
|
2430
|
+
const hasB = other.hasNeg[i];
|
|
2431
|
+
if (hasA !== hasB) return false;
|
|
2432
|
+
if (hasA && !eq(this.negVal[i], other.negVal[i])) return false;
|
|
2433
|
+
}
|
|
2434
|
+
return true;
|
|
2435
|
+
}
|
|
2436
|
+
toArray() {
|
|
2437
|
+
return this.valuesArray();
|
|
2438
|
+
}
|
|
2439
|
+
toString() {
|
|
2440
|
+
let isRegularArray = this.hasNeg.length === 0;
|
|
2441
|
+
for (let i = 0; i < this.hasPos.length && isRegularArray; i++)
|
|
2442
|
+
if (!this.hasPos[i]) isRegularArray = false;
|
|
2443
|
+
if (isRegularArray)
|
|
2444
|
+
return stringify(this.posVal.slice(0, this.hasPos.length));
|
|
2445
|
+
const entries = this.entriesArray().map(([id, v]) => `${stringify(id)}: ${stringify(v)}`).join(", ");
|
|
2446
|
+
return entries.length === 0 ? `[ ]` : `[ ${entries} ]`;
|
|
2447
|
+
}
|
|
2448
|
+
};
|
|
2449
|
+
var UniMap = class _UniMap extends BaseContainer {
|
|
2450
|
+
constructor(...args) {
|
|
2451
|
+
super();
|
|
2452
|
+
__publicField2(this, "map");
|
|
2453
|
+
__publicField2(this, "keyEquals");
|
|
2454
|
+
const maybeEquals = args.at(-1);
|
|
2455
|
+
this.keyEquals = isFunction(maybeEquals) ? args.pop() : DefaultEqualityFn;
|
|
2456
|
+
const entries = args[0];
|
|
2457
|
+
this.map = new Map(entries);
|
|
2458
|
+
}
|
|
2459
|
+
static createDeep(arg) {
|
|
2460
|
+
return arg ? new _UniMap(arg, isDeepEqual) : new _UniMap(isDeepEqual);
|
|
2461
|
+
}
|
|
2462
|
+
has(key) {
|
|
2463
|
+
if (this.keyEquals === DefaultEqualityFn || this.map.has(key))
|
|
2464
|
+
return this.map.has(key);
|
|
2465
|
+
for (const [k, v] of this.map)
|
|
2466
|
+
if (this.keyEquals(k, key))
|
|
2467
|
+
return true;
|
|
2468
|
+
return false;
|
|
2469
|
+
}
|
|
2470
|
+
set(key, value) {
|
|
2471
|
+
if (this.keyEquals === DefaultEqualityFn || this.map.has(key)) {
|
|
2472
|
+
this.map.set(key, value);
|
|
2473
|
+
return value;
|
|
2474
|
+
}
|
|
2475
|
+
for (const key2 of this.map.keys())
|
|
2476
|
+
if (this.keyEquals(key2, key)) {
|
|
2477
|
+
this.map.set(key2, value);
|
|
2478
|
+
return value;
|
|
2479
|
+
}
|
|
2480
|
+
this.map.set(key, value);
|
|
2481
|
+
return value;
|
|
2482
|
+
}
|
|
2483
|
+
get(key) {
|
|
2484
|
+
if (this.keyEquals === DefaultEqualityFn || this.map.has(key))
|
|
2485
|
+
return this.map.get(key);
|
|
2486
|
+
for (const [k, v] of this.map)
|
|
2487
|
+
if (this.keyEquals(k, key))
|
|
2488
|
+
return v;
|
|
2489
|
+
return void 0;
|
|
2490
|
+
}
|
|
2491
|
+
delete(key) {
|
|
2492
|
+
if (this.keyEquals === DefaultEqualityFn || this.map.has(key))
|
|
2493
|
+
return this.map.delete(key);
|
|
2494
|
+
for (const k of this.map.keys())
|
|
2495
|
+
if (this.keyEquals(k, key))
|
|
2496
|
+
return this.map.delete(k);
|
|
2497
|
+
return this.map.delete(key);
|
|
2498
|
+
}
|
|
2499
|
+
getOrDefault(key, defaultValue) {
|
|
2500
|
+
var _a;
|
|
2501
|
+
return (_a = this.get(key)) != null ? _a : defaultValue;
|
|
2502
|
+
}
|
|
2503
|
+
getOrCreate(key, creatorOrValue) {
|
|
2504
|
+
if (!this.has(key)) {
|
|
2505
|
+
const value = isFunction(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
2506
|
+
return this.set(key, value);
|
|
2507
|
+
}
|
|
2508
|
+
return this.get(key);
|
|
2509
|
+
}
|
|
2510
|
+
clear() {
|
|
2511
|
+
this.map.clear();
|
|
2512
|
+
}
|
|
2513
|
+
get size() {
|
|
2514
|
+
return this.map.size;
|
|
2515
|
+
}
|
|
2516
|
+
isEmpty() {
|
|
2517
|
+
return this.size === 0;
|
|
2518
|
+
}
|
|
2519
|
+
forEach(callbackfn, thisArg) {
|
|
2520
|
+
this.map.forEach((value, key) => callbackfn.call(thisArg, value, key, this));
|
|
2521
|
+
}
|
|
2522
|
+
*keys() {
|
|
2523
|
+
yield* __yieldStar(this.map.keys());
|
|
2524
|
+
}
|
|
2525
|
+
*values() {
|
|
2526
|
+
yield* __yieldStar(this.map.values());
|
|
2527
|
+
}
|
|
2528
|
+
*entries() {
|
|
2529
|
+
for (const [key, value] of this.map)
|
|
2530
|
+
yield [key, value];
|
|
2531
|
+
}
|
|
2532
|
+
keysArray() {
|
|
2533
|
+
return [...this.keys()];
|
|
2534
|
+
}
|
|
2535
|
+
valuesArray() {
|
|
2536
|
+
return [...this.values()];
|
|
2537
|
+
}
|
|
2538
|
+
entriesArray() {
|
|
2539
|
+
return [...this.entries()];
|
|
2540
|
+
}
|
|
2541
|
+
*kvKeys() {
|
|
2542
|
+
for (const key of this.keys()) {
|
|
2543
|
+
yield [key];
|
|
2544
|
+
}
|
|
2545
|
+
}
|
|
2546
|
+
*kvValues() {
|
|
2547
|
+
for (const el of this.values()) {
|
|
2548
|
+
yield el;
|
|
2549
|
+
}
|
|
2550
|
+
}
|
|
2551
|
+
*kvEntries() {
|
|
2552
|
+
for (const [key, el] of this.entries()) {
|
|
2553
|
+
yield [[key], el];
|
|
2554
|
+
}
|
|
2555
|
+
}
|
|
2556
|
+
*[Symbol.iterator]() {
|
|
2557
|
+
yield* __yieldStar(this.entries());
|
|
2558
|
+
}
|
|
2559
|
+
clone() {
|
|
2560
|
+
return new _UniMap(this, this.keyEquals);
|
|
2561
|
+
}
|
|
2562
|
+
merge(other, conflictResolver) {
|
|
2563
|
+
for (const [key, value] of other.entries()) {
|
|
2564
|
+
if (this.has(key) && conflictResolver) {
|
|
2565
|
+
this.set(key, conflictResolver(this.get(key), value, key));
|
|
2566
|
+
} else {
|
|
2567
|
+
this.set(key, value);
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
return this;
|
|
2571
|
+
}
|
|
2572
|
+
some(fn) {
|
|
2573
|
+
for (const [key, value] of this.map) {
|
|
2574
|
+
if (fn(value, key)) return true;
|
|
2575
|
+
}
|
|
2576
|
+
return false;
|
|
2577
|
+
}
|
|
2578
|
+
every(fn) {
|
|
2579
|
+
for (const [key, value] of this.map) {
|
|
2580
|
+
if (!fn(value, key)) return false;
|
|
2581
|
+
}
|
|
2582
|
+
return true;
|
|
2583
|
+
}
|
|
2584
|
+
filter(predicate) {
|
|
2585
|
+
const result = new this.constructor();
|
|
2586
|
+
for (const [key, value] of this.map) {
|
|
2587
|
+
if (predicate(value, key, this)) result.set(key, value);
|
|
2588
|
+
}
|
|
2589
|
+
return result;
|
|
2590
|
+
}
|
|
2591
|
+
reduce(fn, init) {
|
|
2592
|
+
let iterator = this.entries();
|
|
2593
|
+
let first = iterator.next();
|
|
2594
|
+
if (first.done) {
|
|
2595
|
+
if (arguments.length < 2) {
|
|
2596
|
+
throw new TypeError("Reduce of empty UniMap with no initial value!");
|
|
2597
|
+
}
|
|
2598
|
+
return init;
|
|
2599
|
+
}
|
|
2600
|
+
let acc;
|
|
2601
|
+
let start;
|
|
2602
|
+
if (arguments.length < 2) {
|
|
2603
|
+
acc = first.value[1];
|
|
2604
|
+
start = iterator.next();
|
|
2605
|
+
} else {
|
|
2606
|
+
acc = init;
|
|
2607
|
+
start = first;
|
|
2608
|
+
}
|
|
2609
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
2610
|
+
const [key, value] = current.value;
|
|
2611
|
+
acc = fn(acc, value, key);
|
|
2612
|
+
}
|
|
2613
|
+
return acc;
|
|
2614
|
+
}
|
|
2615
|
+
mapEntries(fn) {
|
|
2616
|
+
let result = [];
|
|
2617
|
+
for (const [key, value] of this.map) {
|
|
2618
|
+
result.push(fn(value, key));
|
|
2619
|
+
}
|
|
2620
|
+
return result;
|
|
2621
|
+
}
|
|
2622
|
+
mapValues(fn) {
|
|
2623
|
+
let result = new _UniMap();
|
|
2624
|
+
for (const [key, value] of this.map) {
|
|
2625
|
+
result.set(key, fn(value, key));
|
|
2626
|
+
}
|
|
2627
|
+
return result;
|
|
2628
|
+
}
|
|
2629
|
+
toMap() {
|
|
2630
|
+
return new Map(this.map);
|
|
2631
|
+
}
|
|
2632
|
+
toString() {
|
|
2633
|
+
const entries = [...this.map].map(([k, v]) => `${stringify(k)} => ${stringify(v)}`).join(", ");
|
|
2634
|
+
return entries.length === 0 ? `Map(${this.size}){ }` : `Map(${this.size}){ ${entries} }`;
|
|
17
2635
|
}
|
|
18
|
-
return to;
|
|
19
2636
|
};
|
|
20
|
-
var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2);
|
|
21
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
|
-
|
|
23
|
-
// src/theory/index.ts
|
|
24
|
-
var theory_exports = {};
|
|
25
|
-
__export(theory_exports, {
|
|
26
|
-
AccidentalType: () => AccidentalType,
|
|
27
|
-
BeamGrouping: () => BeamGrouping,
|
|
28
|
-
Chord: () => Chord,
|
|
29
|
-
DefaultGuitarNoteLabel: () => DefaultGuitarNoteLabel,
|
|
30
|
-
DefaultHandedness: () => DefaultHandedness,
|
|
31
|
-
DefaultPitchNotation: () => DefaultPitchNotation,
|
|
32
|
-
DefaultTuningName: () => DefaultTuningName,
|
|
33
|
-
GuitarNoteLabel: () => GuitarNoteLabel,
|
|
34
|
-
GuitarNoteLabelList: () => GuitarNoteLabelList,
|
|
35
|
-
Handedness: () => Handedness,
|
|
36
|
-
Interval: () => Interval,
|
|
37
|
-
KeySignature: () => KeySignature,
|
|
38
|
-
Mode: () => Mode,
|
|
39
|
-
Note: () => Note,
|
|
40
|
-
NoteLength: () => NoteLength,
|
|
41
|
-
NoteLengthProps: () => NoteLengthProps,
|
|
42
|
-
PitchNotation: () => PitchNotation,
|
|
43
|
-
PitchNotationList: () => PitchNotationList,
|
|
44
|
-
RhythmProps: () => RhythmProps,
|
|
45
|
-
Scale: () => Scale,
|
|
46
|
-
ScaleFactory: () => ScaleFactory,
|
|
47
|
-
ScaleType: () => ScaleType,
|
|
48
|
-
SymbolSet: () => SymbolSet,
|
|
49
|
-
TimeSignature: () => TimeSignature,
|
|
50
|
-
TimeSignatures: () => TimeSignatures,
|
|
51
|
-
TuningNameList: () => TuningNameList,
|
|
52
|
-
Tuplet: () => Tuplet,
|
|
53
|
-
alterTempoSpeed: () => alterTempoSpeed,
|
|
54
|
-
getDefaultKeySignature: () => getDefaultKeySignature,
|
|
55
|
-
getDefaultScale: () => getDefaultScale,
|
|
56
|
-
getDefaultTempo: () => getDefaultTempo,
|
|
57
|
-
getDefaultTimeSignature: () => getDefaultTimeSignature,
|
|
58
|
-
getPitchNotationName: () => getPitchNotationName,
|
|
59
|
-
getScale: () => getScale,
|
|
60
|
-
getScaleFactory: () => getScaleFactory,
|
|
61
|
-
getScaleFactoryList: () => getScaleFactoryList,
|
|
62
|
-
getTempoString: () => getTempoString,
|
|
63
|
-
getTuningStrings: () => getTuningStrings,
|
|
64
|
-
isNoteLength: () => isNoteLength,
|
|
65
|
-
isTupletRatio: () => isTupletRatio,
|
|
66
|
-
validateGuitarNoteLabel: () => validateGuitarNoteLabel,
|
|
67
|
-
validateHandedness: () => validateHandedness,
|
|
68
|
-
validateIntervalQuality: () => validateIntervalQuality,
|
|
69
|
-
validateNoteLength: () => validateNoteLength,
|
|
70
|
-
validatePitchNotation: () => validatePitchNotation,
|
|
71
|
-
validateScaleType: () => validateScaleType,
|
|
72
|
-
validateTuningName: () => validateTuningName,
|
|
73
|
-
validateTupletRatio: () => validateTupletRatio
|
|
74
|
-
});
|
|
75
|
-
module.exports = __toCommonJS(theory_exports);
|
|
76
|
-
|
|
77
|
-
// src/theory/chord.ts
|
|
78
|
-
var import_ts_utils_lib6 = require("@tspro/ts-utils-lib");
|
|
79
|
-
|
|
80
|
-
// src/theory/note.ts
|
|
81
|
-
var import_ts_utils_lib2 = require("@tspro/ts-utils-lib");
|
|
82
2637
|
|
|
83
2638
|
// src/theory/types.ts
|
|
84
|
-
var import_ts_utils_lib = require("@tspro/ts-utils-lib");
|
|
85
2639
|
var import_core = require("@tspro/web-music-score/core");
|
|
86
2640
|
var SymbolSet = /* @__PURE__ */ ((SymbolSet2) => {
|
|
87
2641
|
SymbolSet2[SymbolSet2["Ascii"] = 0] = "Ascii";
|
|
@@ -93,10 +2647,10 @@ var PitchNotation = /* @__PURE__ */ ((PitchNotation2) => {
|
|
|
93
2647
|
PitchNotation2[PitchNotation2["Helmholtz"] = 1] = "Helmholtz";
|
|
94
2648
|
return PitchNotation2;
|
|
95
2649
|
})(PitchNotation || {});
|
|
96
|
-
var PitchNotationList =
|
|
2650
|
+
var PitchNotationList = utils_exports.Enum.getEnumValues(PitchNotation);
|
|
97
2651
|
var DefaultPitchNotation = 0 /* Scientific */;
|
|
98
2652
|
function validatePitchNotation(pn) {
|
|
99
|
-
if (
|
|
2653
|
+
if (guard_exports.isEnumValue(pn, PitchNotation)) {
|
|
100
2654
|
return pn;
|
|
101
2655
|
} else {
|
|
102
2656
|
throw new import_core.MusicError(import_core.MusicErrorType.InvalidArg, `Invalid pitchNotation: ${pn}`);
|
|
@@ -112,9 +2666,9 @@ var GuitarNoteLabel = /* @__PURE__ */ ((GuitarNoteLabel2) => {
|
|
|
112
2666
|
return GuitarNoteLabel2;
|
|
113
2667
|
})(GuitarNoteLabel || {});
|
|
114
2668
|
var DefaultGuitarNoteLabel = "Default" /* Default */;
|
|
115
|
-
var GuitarNoteLabelList =
|
|
2669
|
+
var GuitarNoteLabelList = utils_exports.Enum.getEnumValues(GuitarNoteLabel);
|
|
116
2670
|
function validateGuitarNoteLabel(label) {
|
|
117
|
-
if (
|
|
2671
|
+
if (guard_exports.isEnumValue(label, GuitarNoteLabel)) {
|
|
118
2672
|
return label;
|
|
119
2673
|
} else {
|
|
120
2674
|
throw new import_core.MusicError(import_core.MusicErrorType.Timesignature, `Invalid guitarNoteLabel: ${label}`);
|
|
@@ -123,7 +2677,7 @@ function validateGuitarNoteLabel(label) {
|
|
|
123
2677
|
|
|
124
2678
|
// src/theory/note.ts
|
|
125
2679
|
var import_core2 = require("@tspro/web-music-score/core");
|
|
126
|
-
function
|
|
2680
|
+
function mod2(n, m) {
|
|
127
2681
|
return (n % m + m) % m;
|
|
128
2682
|
}
|
|
129
2683
|
var C0_chromaticId = 12;
|
|
@@ -255,7 +2809,7 @@ var _Note = class _Note {
|
|
|
255
2809
|
}
|
|
256
2810
|
static getDiatonicClass(arg) {
|
|
257
2811
|
if (typeof arg === "number") {
|
|
258
|
-
return
|
|
2812
|
+
return mod2(arg, 7);
|
|
259
2813
|
} else if (typeof arg === "string" && arg.length > 0) {
|
|
260
2814
|
return NoteLetters.indexOf(_Note.validateNoteLetter(arg[0]));
|
|
261
2815
|
} else {
|
|
@@ -285,7 +2839,7 @@ var _Note = class _Note {
|
|
|
285
2839
|
* @returns - Chromatic class.
|
|
286
2840
|
*/
|
|
287
2841
|
static getChromaticClass(chromaticId) {
|
|
288
|
-
return
|
|
2842
|
+
return mod2(chromaticId, 12);
|
|
289
2843
|
}
|
|
290
2844
|
/**
|
|
291
2845
|
* Get octave from chromatic id.
|
|
@@ -325,11 +2879,11 @@ var _Note = class _Note {
|
|
|
325
2879
|
* @param symbolSet - Symbol set.
|
|
326
2880
|
* @returns - String with updated accidental symbols.
|
|
327
2881
|
*/
|
|
328
|
-
static replaceAccidentalSymbols(
|
|
2882
|
+
static replaceAccidentalSymbols(str2, symbolSet) {
|
|
329
2883
|
if (symbolSet === 1 /* Unicode */) {
|
|
330
|
-
return
|
|
2884
|
+
return str2.replace("bb", "\u{1D12B}").replace("b", "\u266D").replace("#", "\u266F").replace("x", "\u{1D12A}");
|
|
331
2885
|
} else {
|
|
332
|
-
return
|
|
2886
|
+
return str2.replace("\u{1D12B}", "bb").replace("\u266D", "b").replace("\u266F", "#").replace("\u{1D12A}", "x");
|
|
333
2887
|
}
|
|
334
2888
|
}
|
|
335
2889
|
/**
|
|
@@ -420,7 +2974,7 @@ var _Note = class _Note {
|
|
|
420
2974
|
* @returns - Valid diatonic id or throws.
|
|
421
2975
|
*/
|
|
422
2976
|
static validateDiatonicId(diatonicId) {
|
|
423
|
-
if (
|
|
2977
|
+
if (guard_exports.isInteger(diatonicId)) {
|
|
424
2978
|
return diatonicId;
|
|
425
2979
|
} else {
|
|
426
2980
|
throw new import_core2.MusicError(import_core2.MusicErrorType.Note, `Invalid diatonicId: ${diatonicId}`);
|
|
@@ -432,7 +2986,7 @@ var _Note = class _Note {
|
|
|
432
2986
|
* @returns - Valid diatonic class or throws.
|
|
433
2987
|
*/
|
|
434
2988
|
static validateDiatonicClass(diatonicClass) {
|
|
435
|
-
if (
|
|
2989
|
+
if (guard_exports.isIntegerBetween(diatonicClass, 0, 6)) {
|
|
436
2990
|
return diatonicClass;
|
|
437
2991
|
} else {
|
|
438
2992
|
throw new import_core2.MusicError(import_core2.MusicErrorType.Note, `Invalid diatonicClass: ${diatonicClass}`);
|
|
@@ -444,7 +2998,7 @@ var _Note = class _Note {
|
|
|
444
2998
|
* @returns - Valid chromatic id, or throws.
|
|
445
2999
|
*/
|
|
446
3000
|
static validateChromaticId(chromaticId) {
|
|
447
|
-
if (
|
|
3001
|
+
if (guard_exports.isInteger(chromaticId)) {
|
|
448
3002
|
return chromaticId;
|
|
449
3003
|
} else {
|
|
450
3004
|
throw new import_core2.MusicError(import_core2.MusicErrorType.Note, `Invalid chromaticId: ${chromaticId}`);
|
|
@@ -456,7 +3010,7 @@ var _Note = class _Note {
|
|
|
456
3010
|
* @returns - Valid chromatic class, or throws.
|
|
457
3011
|
*/
|
|
458
3012
|
static validatechromaticClass(chromaticClass) {
|
|
459
|
-
if (
|
|
3013
|
+
if (guard_exports.isIntegerBetween(chromaticClass, 0, 11)) {
|
|
460
3014
|
return chromaticClass;
|
|
461
3015
|
} else {
|
|
462
3016
|
throw new import_core2.MusicError(import_core2.MusicErrorType.Note, `Invalid chromaticClass: ${chromaticClass}`);
|
|
@@ -480,7 +3034,7 @@ var _Note = class _Note {
|
|
|
480
3034
|
* @returns - Valid octave or throws.
|
|
481
3035
|
*/
|
|
482
3036
|
static validateOctave(octave) {
|
|
483
|
-
if (
|
|
3037
|
+
if (guard_exports.isInteger(octave)) {
|
|
484
3038
|
return octave;
|
|
485
3039
|
} else {
|
|
486
3040
|
throw new import_core2.MusicError(import_core2.MusicErrorType.Note, `Invalid octave: ${octave}`);
|
|
@@ -492,7 +3046,7 @@ var _Note = class _Note {
|
|
|
492
3046
|
* @returns - Valid accidental or thorws.
|
|
493
3047
|
*/
|
|
494
3048
|
static validateAccidental(acc) {
|
|
495
|
-
if (
|
|
3049
|
+
if (guard_exports.isIntegerBetween(acc, -2, 2)) {
|
|
496
3050
|
return acc;
|
|
497
3051
|
} else {
|
|
498
3052
|
throw new import_core2.MusicError(import_core2.MusicErrorType.Note, `Invalid accidental: ${acc}`);
|
|
@@ -542,15 +3096,11 @@ var _Note = class _Note {
|
|
|
542
3096
|
}
|
|
543
3097
|
}
|
|
544
3098
|
};
|
|
545
|
-
__publicField(_Note, "noteCache", new
|
|
546
|
-
__publicField(_Note, "chromaticNoteCache", new
|
|
3099
|
+
__publicField(_Note, "noteCache", new UniMap());
|
|
3100
|
+
__publicField(_Note, "chromaticNoteCache", new UniMap());
|
|
547
3101
|
var Note = _Note;
|
|
548
3102
|
|
|
549
|
-
// src/theory/scale.ts
|
|
550
|
-
var import_ts_utils_lib5 = require("@tspro/ts-utils-lib");
|
|
551
|
-
|
|
552
3103
|
// src/theory/key-signature.ts
|
|
553
|
-
var import_ts_utils_lib3 = require("@tspro/ts-utils-lib");
|
|
554
3104
|
var import_core3 = require("@tspro/web-music-score/core");
|
|
555
3105
|
function getAccidental(chromaticId, diatonicId) {
|
|
556
3106
|
let a = Note.getChromaticClass(chromaticId) - new Note(diatonicId, 0).chromaticClass;
|
|
@@ -571,7 +3121,7 @@ function parseDegree(degree) {
|
|
|
571
3121
|
}
|
|
572
3122
|
let acc = (_b = Note.getAccidental((_a = m[1]) != null ? _a : "")) != null ? _b : 0;
|
|
573
3123
|
let deg = +m[2];
|
|
574
|
-
if (!
|
|
3124
|
+
if (!guard_exports.isInteger(acc) || acc < -2 || acc > 2 || !guard_exports.isInteger(deg) || deg < 1) {
|
|
575
3125
|
throw new import_core3.MusicError(import_core3.MusicErrorType.KeySignature, `Invalid degree: ${degree}`);
|
|
576
3126
|
} else {
|
|
577
3127
|
return { deg, acc };
|
|
@@ -607,7 +3157,7 @@ var _KeySignature = class _KeySignature {
|
|
|
607
3157
|
__publicField(this, "naturalScaleNotes");
|
|
608
3158
|
__publicField(this, "accidentalByDiatonicClass");
|
|
609
3159
|
__publicField(this, "orderedAccidentedNotes");
|
|
610
|
-
if (!
|
|
3160
|
+
if (!guard_exports.isEnumValue(mode, Mode)) {
|
|
611
3161
|
throw new import_core3.MusicError(import_core3.MusicErrorType.KeySignature, `Invalid mode: ${mode}`);
|
|
612
3162
|
}
|
|
613
3163
|
let intervals = [2, 2, 1, 2, 2, 2, 1];
|
|
@@ -725,9 +3275,8 @@ __publicField(_KeySignature, "OrderOfFlats", "BEADGCF");
|
|
|
725
3275
|
var KeySignature = _KeySignature;
|
|
726
3276
|
|
|
727
3277
|
// src/theory/interval.ts
|
|
728
|
-
var import_ts_utils_lib4 = require("@tspro/ts-utils-lib");
|
|
729
3278
|
var import_core4 = require("@tspro/web-music-score/core");
|
|
730
|
-
var IntervalQualityAbbrMap = new
|
|
3279
|
+
var IntervalQualityAbbrMap = new UniMap([
|
|
731
3280
|
["Major", "M"],
|
|
732
3281
|
["minor", "m"],
|
|
733
3282
|
["Perfect", "P"],
|
|
@@ -830,10 +3379,10 @@ function validateIntervalQuality(q) {
|
|
|
830
3379
|
}
|
|
831
3380
|
}
|
|
832
3381
|
function formatQuantity(q) {
|
|
833
|
-
if (!
|
|
3382
|
+
if (!guard_exports.isIntegerGte(q, 1)) {
|
|
834
3383
|
throw new import_core4.MusicError(import_core4.MusicErrorType.InvalidArg, `Invalid interval quantity: ${q}`);
|
|
835
3384
|
} else {
|
|
836
|
-
return
|
|
3385
|
+
return utils_exports.Math.toOrdinalNumber(q);
|
|
837
3386
|
}
|
|
838
3387
|
}
|
|
839
3388
|
var InvalidIntervalException = class extends Error {
|
|
@@ -1010,7 +3559,7 @@ var Scale = class extends KeySignature {
|
|
|
1010
3559
|
__publicField(this, "scaleNotes");
|
|
1011
3560
|
/** Degrees (or undefined) of chromatic classes. */
|
|
1012
3561
|
__publicField(this, "chromaticClassDegree");
|
|
1013
|
-
__publicField(this, "preferredChromaticIdNoteCache", new
|
|
3562
|
+
__publicField(this, "preferredChromaticIdNoteCache", new SignedIndexArray());
|
|
1014
3563
|
switch (scaleType) {
|
|
1015
3564
|
case "Harmonic Minor" /* HarmonicMinor */:
|
|
1016
3565
|
this.scaleDegrees = [1, 2, 3, 4, 5, 6, "#7"];
|
|
@@ -1075,7 +3624,7 @@ var Scale = class extends KeySignature {
|
|
|
1075
3624
|
* @returns - Array of scale notes.
|
|
1076
3625
|
*/
|
|
1077
3626
|
getScaleNotes(bottomNote, numOctaves) {
|
|
1078
|
-
if (!
|
|
3627
|
+
if (!guard_exports.isIntegerGte(numOctaves, 1)) {
|
|
1079
3628
|
throw new import_core5.MusicError(import_core5.MusicErrorType.Scale, `Invalid numOctaves: ${numOctaves}`);
|
|
1080
3629
|
}
|
|
1081
3630
|
let scaleNoteList = [];
|
|
@@ -1104,7 +3653,7 @@ var Scale = class extends KeySignature {
|
|
|
1104
3653
|
let chromaticIds = this.getScaleNotes("C4", 1).map((note) => note.chromaticId);
|
|
1105
3654
|
let steps = [];
|
|
1106
3655
|
for (let i = 0; i < chromaticIds.length - 1; i++) {
|
|
1107
|
-
steps.push(
|
|
3656
|
+
steps.push(utils_exports.Math.mod(chromaticIds[i + 1] - chromaticIds[i], 12));
|
|
1108
3657
|
}
|
|
1109
3658
|
return steps;
|
|
1110
3659
|
}
|
|
@@ -1314,7 +3863,7 @@ var ScaleFactoryList = [
|
|
|
1314
3863
|
function getScaleFactoryList() {
|
|
1315
3864
|
return ScaleFactoryList;
|
|
1316
3865
|
}
|
|
1317
|
-
var ScaleFactoryMap = new
|
|
3866
|
+
var ScaleFactoryMap = new UniMap();
|
|
1318
3867
|
ScaleFactoryList.forEach((factory) => {
|
|
1319
3868
|
if (factory instanceof ScaleFactory) {
|
|
1320
3869
|
ScaleFactoryMap.set(factory.getType(), factory);
|
|
@@ -1329,7 +3878,7 @@ function getScaleFactory(scaleType) {
|
|
|
1329
3878
|
}
|
|
1330
3879
|
}
|
|
1331
3880
|
function validateScaleType(scaleType) {
|
|
1332
|
-
if (
|
|
3881
|
+
if (guard_exports.isEnumValue(scaleType, ScaleType)) {
|
|
1333
3882
|
return scaleType;
|
|
1334
3883
|
} else {
|
|
1335
3884
|
throw new import_core5.MusicError(import_core5.MusicErrorType.Scale, `Invalid scaleType: "${scaleType}"`);
|
|
@@ -1373,7 +3922,7 @@ var OkayRootNoteList = [
|
|
|
1373
3922
|
"B",
|
|
1374
3923
|
"Cb"
|
|
1375
3924
|
].map((noteName) => Note.getNote(noteName + "0"));
|
|
1376
|
-
var okayRootNoteCache = new
|
|
3925
|
+
var okayRootNoteCache = new IndexArray();
|
|
1377
3926
|
function getOkayRootNote(wantedRootNote) {
|
|
1378
3927
|
return okayRootNoteCache.getOrCreate(wantedRootNote.chromaticClass, () => {
|
|
1379
3928
|
let rootNote = OkayRootNoteList.find((note) => isEqualNote(note, wantedRootNote));
|
|
@@ -1389,7 +3938,7 @@ function getChordNoteByDegree(chordRootNote, degree) {
|
|
|
1389
3938
|
return ks.getNoteByDegree(degree);
|
|
1390
3939
|
}
|
|
1391
3940
|
function removeNoteDuplicates(notes) {
|
|
1392
|
-
return
|
|
3941
|
+
return utils_exports.Arr.removeDuplicates(notes, isEqualNote);
|
|
1393
3942
|
}
|
|
1394
3943
|
var ChordInfoList = [
|
|
1395
3944
|
// Power chord
|
|
@@ -1565,7 +4114,7 @@ var Chord = class _Chord {
|
|
|
1565
4114
|
getOmittedDegreesString() {
|
|
1566
4115
|
let omittedStrList = this.omitNotes.map((omit, i) => {
|
|
1567
4116
|
return omit ? this.getDegreeStr(i) + "(" + this.getNoteStr(i) + ")" : void 0;
|
|
1568
|
-
}).filter((
|
|
4117
|
+
}).filter((str2) => str2 !== void 0);
|
|
1569
4118
|
return omittedStrList.length > 0 ? "Omits " + omittedStrList.join(", ") : "";
|
|
1570
4119
|
}
|
|
1571
4120
|
/**
|
|
@@ -1586,9 +4135,6 @@ var Chord = class _Chord {
|
|
|
1586
4135
|
}
|
|
1587
4136
|
};
|
|
1588
4137
|
|
|
1589
|
-
// src/theory/guitar.ts
|
|
1590
|
-
var import_ts_utils_lib7 = require("@tspro/ts-utils-lib");
|
|
1591
|
-
|
|
1592
4138
|
// src/theory/assets/tunings.json
|
|
1593
4139
|
var tunings_default = {
|
|
1594
4140
|
list: [
|
|
@@ -1846,7 +4392,7 @@ var Handedness = /* @__PURE__ */ ((Handedness2) => {
|
|
|
1846
4392
|
})(Handedness || {});
|
|
1847
4393
|
var DefaultHandedness = 0 /* RightHanded */;
|
|
1848
4394
|
function validateHandedness(h) {
|
|
1849
|
-
if (
|
|
4395
|
+
if (guard_exports.isEnumValue(h, Handedness)) {
|
|
1850
4396
|
return h;
|
|
1851
4397
|
} else {
|
|
1852
4398
|
throw new import_core7.MusicError(import_core7.MusicErrorType.InvalidArg, `Invalid handedness: ${h}`);
|
|
@@ -1861,7 +4407,7 @@ function validateTuningName(tuningName) {
|
|
|
1861
4407
|
return tuningName;
|
|
1862
4408
|
}
|
|
1863
4409
|
}
|
|
1864
|
-
var TuningStringsCache = new
|
|
4410
|
+
var TuningStringsCache = new LRUCache(100);
|
|
1865
4411
|
function getTuningStrings(tuningName) {
|
|
1866
4412
|
let tuningStrings = TuningStringsCache.get(tuningName);
|
|
1867
4413
|
if (!tuningStrings) {
|
|
@@ -1870,7 +4416,7 @@ function getTuningStrings(tuningName) {
|
|
|
1870
4416
|
throw new import_core7.MusicError(import_core7.MusicErrorType.InvalidArg, `Invalid tuningName: ${tuningName}`);
|
|
1871
4417
|
}
|
|
1872
4418
|
tuningStrings = tuningData.strings.slice().reverse().map((noteName) => Note.getNote(noteName));
|
|
1873
|
-
if (!
|
|
4419
|
+
if (!guard_exports.isIntegerEq(tuningStrings.length, 6)) {
|
|
1874
4420
|
throw new import_core7.MusicError(import_core7.MusicErrorType.Unknown, `Tuning has ${tuningStrings.length} strings.`);
|
|
1875
4421
|
}
|
|
1876
4422
|
TuningStringsCache.set(tuningName, tuningStrings);
|
|
@@ -1878,11 +4424,7 @@ function getTuningStrings(tuningName) {
|
|
|
1878
4424
|
return tuningStrings;
|
|
1879
4425
|
}
|
|
1880
4426
|
|
|
1881
|
-
// src/theory/time-signature.ts
|
|
1882
|
-
var import_ts_utils_lib9 = require("@tspro/ts-utils-lib");
|
|
1883
|
-
|
|
1884
4427
|
// src/theory/rhythm.ts
|
|
1885
|
-
var import_ts_utils_lib8 = require("@tspro/ts-utils-lib");
|
|
1886
4428
|
var import_core8 = require("@tspro/web-music-score/core");
|
|
1887
4429
|
var MaxTupletRatioValue = 12;
|
|
1888
4430
|
var TicksMultiplier = 12 * 11 * 9 * 7 * 5;
|
|
@@ -1926,7 +4468,7 @@ var NoteLength = /* @__PURE__ */ ((NoteLength3) => {
|
|
|
1926
4468
|
return NoteLength3;
|
|
1927
4469
|
})(NoteLength || {});
|
|
1928
4470
|
function isNoteLength(noteLength) {
|
|
1929
|
-
return
|
|
4471
|
+
return guard_exports.isEnumValue(noteLength, NoteLength);
|
|
1930
4472
|
}
|
|
1931
4473
|
function validateNoteLength(noteLength) {
|
|
1932
4474
|
if (isNoteLength(noteLength)) {
|
|
@@ -1959,7 +4501,7 @@ var _NoteLengthProps = class _NoteLengthProps {
|
|
|
1959
4501
|
this.noteSize = parseInt(noteLength);
|
|
1960
4502
|
this.isTriplet = noteLength.endsWith("t");
|
|
1961
4503
|
this.maxDotCount = this.isTriplet ? 0 : Math.floor(Math.log2(_NoteLengthProps.ShortestNoteSize / this.noteSize));
|
|
1962
|
-
this.dotCount =
|
|
4504
|
+
this.dotCount = utils_exports.Str.charCount(noteLength, ".");
|
|
1963
4505
|
this.flagCount = this.noteSize > 4 ? Math.floor(Math.log2(this.noteSize / 4)) : 0;
|
|
1964
4506
|
this.ticks = TicksMultiplier * _NoteLengthProps.ShortestNoteSize / this.noteSize;
|
|
1965
4507
|
this.hasStem = this.noteSize > 1;
|
|
@@ -1986,7 +4528,7 @@ var _NoteLengthProps = class _NoteLengthProps {
|
|
|
1986
4528
|
*/
|
|
1987
4529
|
static create(noteLength, dotCount = 0) {
|
|
1988
4530
|
let noteSize = typeof noteLength === "number" ? noteLength : this.get(noteLength).noteSize;
|
|
1989
|
-
return this.get(noteSize + (
|
|
4531
|
+
return this.get(noteSize + (guard_exports.isIntegerGte(dotCount, 1) ? ".".repeat(dotCount) : "n"));
|
|
1990
4532
|
}
|
|
1991
4533
|
/**
|
|
1992
4534
|
* Compare note lengths/sizes. Whole (1) > half (2) > quarter (4), etc.
|
|
@@ -1998,7 +4540,7 @@ var _NoteLengthProps = class _NoteLengthProps {
|
|
|
1998
4540
|
static cmp(a, b) {
|
|
1999
4541
|
let aNoteSize = a instanceof _NoteLengthProps ? a.noteSize : typeof a === "number" ? a : _NoteLengthProps.get(a).noteSize;
|
|
2000
4542
|
let bNoteSize = b instanceof _NoteLengthProps ? b.noteSize : typeof b === "number" ? b : _NoteLengthProps.get(b).noteSize;
|
|
2001
|
-
return
|
|
4543
|
+
return utils_exports.Math.cmp(bNoteSize, aNoteSize);
|
|
2002
4544
|
}
|
|
2003
4545
|
/**
|
|
2004
4546
|
* Compare note lengths/sizes for equality.
|
|
@@ -2014,13 +4556,13 @@ var _NoteLengthProps = class _NoteLengthProps {
|
|
|
2014
4556
|
}
|
|
2015
4557
|
};
|
|
2016
4558
|
/** Longest note size (e.g. 1 = whole note). */
|
|
2017
|
-
__publicField(_NoteLengthProps, "LongestNoteSize", Math.min(...
|
|
4559
|
+
__publicField(_NoteLengthProps, "LongestNoteSize", Math.min(...utils_exports.Enum.getEnumValues(NoteLength).map((noteLength) => parseInt(noteLength))));
|
|
2018
4560
|
/** Shortest note size (e.g. 64 = sixtyfourth note). */
|
|
2019
|
-
__publicField(_NoteLengthProps, "ShortestNoteSize", Math.max(...
|
|
2020
|
-
__publicField(_NoteLengthProps, "cache", new
|
|
4561
|
+
__publicField(_NoteLengthProps, "ShortestNoteSize", Math.max(...utils_exports.Enum.getEnumValues(NoteLength).map((noteLength) => parseInt(noteLength))));
|
|
4562
|
+
__publicField(_NoteLengthProps, "cache", new UniMap());
|
|
2021
4563
|
var NoteLengthProps = _NoteLengthProps;
|
|
2022
4564
|
function isTupletRatio(tupletRatio) {
|
|
2023
|
-
return
|
|
4565
|
+
return guard_exports.isObject(tupletRatio) && guard_exports.isIntegerBetween(tupletRatio.parts, 2, MaxTupletRatioValue) && guard_exports.isIntegerBetween(tupletRatio.inTimeOf, 2, MaxTupletRatioValue);
|
|
2024
4566
|
}
|
|
2025
4567
|
function validateTupletRatio(tupletRatio) {
|
|
2026
4568
|
if (isTupletRatio(tupletRatio)) {
|
|
@@ -2063,7 +4605,7 @@ var _RhythmProps = class _RhythmProps {
|
|
|
2063
4605
|
this.dotCount = dotCount != null ? dotCount : p.dotCount;
|
|
2064
4606
|
this.hasStem = p.hasStem;
|
|
2065
4607
|
this.isSolidNoteHead = p.isSolid;
|
|
2066
|
-
if (
|
|
4608
|
+
if (guard_exports.isObject(tupletRatio)) {
|
|
2067
4609
|
this.tupletRatio = validateTupletRatio(tupletRatio);
|
|
2068
4610
|
} else if (p.isTriplet) {
|
|
2069
4611
|
this.tupletRatio = Tuplet.Triplet;
|
|
@@ -2112,7 +4654,7 @@ var _RhythmProps = class _RhythmProps {
|
|
|
2112
4654
|
* @returns - -1: a < b, 0: a === b, +1: a > b (duration comparisons)
|
|
2113
4655
|
*/
|
|
2114
4656
|
static cmp(a, b) {
|
|
2115
|
-
return
|
|
4657
|
+
return utils_exports.Math.cmp(a.ticks, b.ticks);
|
|
2116
4658
|
}
|
|
2117
4659
|
/**
|
|
2118
4660
|
* Compare duration equality of rhythm props.
|
|
@@ -2124,8 +4666,8 @@ var _RhythmProps = class _RhythmProps {
|
|
|
2124
4666
|
return a.ticks === b.ticks;
|
|
2125
4667
|
}
|
|
2126
4668
|
};
|
|
2127
|
-
__publicField(_RhythmProps, "NoteSymbolMap", new
|
|
2128
|
-
__publicField(_RhythmProps, "cache", new
|
|
4669
|
+
__publicField(_RhythmProps, "NoteSymbolMap", new IndexArray([[1, "\u{1D15D}"], [2, "\u{1D15E}"], [4, "\u{1D15F}"], [8, "\u{1D160}"], [16, "\u{1D161}"], [32, "\u{1D162}"], [64, "\u{1D163}"], [128, "\u{1D164}"]]));
|
|
4670
|
+
__publicField(_RhythmProps, "cache", new UniMap());
|
|
2129
4671
|
var RhythmProps = _RhythmProps;
|
|
2130
4672
|
|
|
2131
4673
|
// src/theory/time-signature.ts
|
|
@@ -2162,25 +4704,25 @@ var TimeSignature = class {
|
|
|
2162
4704
|
/** Beam groups (e.g. [[2], [2]] or [[2, 2], [2, 2]] (first try as [[4], [4]])). */
|
|
2163
4705
|
__publicField(this, "beamGroupSizes", []);
|
|
2164
4706
|
let beamGrouping;
|
|
2165
|
-
if (
|
|
4707
|
+
if (guard_exports.isEnumValue(args[0], TimeSignatures)) {
|
|
2166
4708
|
let parts = args[0].split("/");
|
|
2167
4709
|
this.beatCount = +parts[0];
|
|
2168
4710
|
this.beatSize = +parts[1];
|
|
2169
|
-
if (
|
|
4711
|
+
if (guard_exports.isEnumValue(args[1], BeamGrouping)) {
|
|
2170
4712
|
beamGrouping = args[1];
|
|
2171
4713
|
}
|
|
2172
|
-
} else if (
|
|
4714
|
+
} else if (guard_exports.isIntegerGte(args[0], 2) && guard_exports.isIntegerGte(args[1], 2)) {
|
|
2173
4715
|
this.beatCount = args[0];
|
|
2174
4716
|
this.beatSize = args[1];
|
|
2175
|
-
if (
|
|
4717
|
+
if (guard_exports.isEnumValue(args[2], BeamGrouping)) {
|
|
2176
4718
|
beamGrouping = args[2];
|
|
2177
4719
|
}
|
|
2178
4720
|
} else {
|
|
2179
4721
|
throw new import_core9.MusicError(import_core9.MusicErrorType.Timesignature, `Invalid args: ${args}`);
|
|
2180
4722
|
}
|
|
2181
|
-
if (!
|
|
4723
|
+
if (!guard_exports.isIntegerGte(this.beatCount, 1)) {
|
|
2182
4724
|
throw new import_core9.MusicError(import_core9.MusicErrorType.Timesignature, `Invalid beatCount: ${this.beatCount}`);
|
|
2183
|
-
} else if (!
|
|
4725
|
+
} else if (!guard_exports.isIntegerGte(this.beatSize, 1)) {
|
|
2184
4726
|
throw new import_core9.MusicError(import_core9.MusicErrorType.Timesignature, `Invalid beatSize: ${this.beatSize}`);
|
|
2185
4727
|
}
|
|
2186
4728
|
let { noteLength, ticks } = NoteLengthProps.create(this.beatSize);
|
|
@@ -2195,7 +4737,7 @@ var TimeSignature = class {
|
|
|
2195
4737
|
} else if (this.is(3, 8)) {
|
|
2196
4738
|
this.beamGroupSizes = [[3]];
|
|
2197
4739
|
} else if (this.is(5, 8)) {
|
|
2198
|
-
if (!
|
|
4740
|
+
if (!guard_exports.isUndefined(beamGrouping) && beamGrouping !== "2-3" /* _2_3 */ && beamGrouping !== "3-2" /* _3_2 */) {
|
|
2199
4741
|
throw new import_core9.MusicError(import_core9.MusicErrorType.Timesignature, `Invalid beam grouping "${beamGrouping}" for time signature "${this.toString()}".`);
|
|
2200
4742
|
} else {
|
|
2201
4743
|
this.beamGroupSizes = beamGrouping === "3-2" /* _3_2 */ ? [[3], [2]] : [[2], [3]];
|
|
@@ -2204,7 +4746,7 @@ var TimeSignature = class {
|
|
|
2204
4746
|
} else if (this.is(6, 8)) {
|
|
2205
4747
|
this.beamGroupSizes = [[3], [3]];
|
|
2206
4748
|
} else if (this.is(7, 8)) {
|
|
2207
|
-
if (!
|
|
4749
|
+
if (!guard_exports.isUndefined(beamGrouping) && beamGrouping !== "2-2-3" /* _2_2_3 */ && beamGrouping !== "3-2-2" /* _3_2_2 */) {
|
|
2208
4750
|
throw new import_core9.MusicError(import_core9.MusicErrorType.Timesignature, `Invalid beam grouping "${beamGrouping}" for time signature "${this.toString()}".`);
|
|
2209
4751
|
} else {
|
|
2210
4752
|
this.beamGroupSizes = beamGrouping === "3-2-2" /* _3_2_2 */ ? [[3], [2], [2]] : [[2], [2], [3]];
|
|
@@ -2318,4 +4860,13 @@ var import_core10 = require("@tspro/web-music-score/core");
|
|
|
2318
4860
|
validateTuningName,
|
|
2319
4861
|
validateTupletRatio
|
|
2320
4862
|
});
|
|
4863
|
+
/*! Bundled license information:
|
|
4864
|
+
|
|
4865
|
+
@tspro/ts-utils-lib/dist/index.mjs:
|
|
4866
|
+
(*!
|
|
4867
|
+
* TsUtilsLib v2.3.0 (esm)
|
|
4868
|
+
* (c) 2023-2025 PahkaSoft
|
|
4869
|
+
* Licensed under the MIT License
|
|
4870
|
+
*)
|
|
4871
|
+
*/
|
|
2321
4872
|
//# sourceMappingURL=index.js.map
|