@visactor/vutils 0.18.2-alpha.0 → 0.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/fmin/bisect.js +11 -4
- package/cjs/fmin/bisect.js.map +1 -1
- package/cjs/fmin/blas1.d.ts +0 -1
- package/cjs/fmin/blas1.js +10 -13
- package/cjs/fmin/blas1.js.map +1 -1
- package/cjs/fmin/conjugate-gradient.js +3 -3
- package/cjs/fmin/conjugate-gradient.js.map +1 -1
- package/cjs/fmin/linesearch.js +4 -4
- package/cjs/fmin/linesearch.js.map +1 -1
- package/cjs/math.d.ts +1 -0
- package/cjs/math.js +8 -2
- package/cjs/math.js.map +1 -1
- package/dist/index.js +18 -16
- package/dist/index.min.js +1 -1
- package/es/fmin/bisect.js +6 -1
- package/es/fmin/bisect.js.map +1 -1
- package/es/fmin/blas1.d.ts +0 -1
- package/es/fmin/blas1.js +4 -8
- package/es/fmin/blas1.js.map +1 -1
- package/es/fmin/conjugate-gradient.js +4 -2
- package/es/fmin/conjugate-gradient.js.map +1 -1
- package/es/fmin/linesearch.js +6 -4
- package/es/fmin/linesearch.js.map +1 -1
- package/es/math.d.ts +1 -0
- package/es/math.js +6 -0
- package/es/math.js.map +1 -1
- package/package.json +3 -3
package/cjs/fmin/bisect.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: !0
|
|
5
|
+
}), exports.findZeroOfFunction = void 0;
|
|
6
|
+
|
|
7
|
+
const logger_1 = require("../logger");
|
|
8
|
+
|
|
3
9
|
function findZeroOfFunction(f, a, b, parameters) {
|
|
4
10
|
const maxIterations = (parameters = parameters || {}).maxIterations || 100, tolerance = parameters.tolerance || 1e-10, fA = f(a), fB = f(b);
|
|
5
11
|
let delta = b - a;
|
|
6
|
-
if (fA * fB > 0)
|
|
12
|
+
if (fA * fB > 0) {
|
|
13
|
+
return logger_1.Logger.getInstance().error("Initial bisect points must have opposite signs"),
|
|
14
|
+
NaN;
|
|
15
|
+
}
|
|
7
16
|
if (0 === fA) return a;
|
|
8
17
|
if (0 === fB) return b;
|
|
9
18
|
for (let i = 0; i < maxIterations; ++i) {
|
|
@@ -14,7 +23,5 @@ function findZeroOfFunction(f, a, b, parameters) {
|
|
|
14
23
|
return a + delta;
|
|
15
24
|
}
|
|
16
25
|
|
|
17
|
-
|
|
18
|
-
value: !0
|
|
19
|
-
}), exports.findZeroOfFunction = void 0, exports.findZeroOfFunction = findZeroOfFunction;
|
|
26
|
+
exports.findZeroOfFunction = findZeroOfFunction;
|
|
20
27
|
//# sourceMappingURL=bisect.js.map
|
package/cjs/fmin/bisect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/fmin/bisect.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../src/fmin/bisect.ts"],"names":[],"mappings":";;;AASA,sCAAmC;AAInC,SAAgB,kBAAkB,CAAC,CAAM,EAAE,CAAM,EAAE,CAAM,EAAE,UAAgB;IACzE,UAAU,GAAG,UAAU,IAAI,EAAE,CAAC;IAC9B,MAAM,aAAa,GAAG,UAAU,CAAC,aAAa,IAAI,GAAG,CAAC;IACtD,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,IAAI,KAAK,CAAC;IAChD,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAChB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAChB,IAAI,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC;IAElB,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE;QACf,MAAM,MAAM,GAAG,eAAM,CAAC,WAAW,EAAE,CAAC;QACpC,MAAM,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;QAC/D,OAAO,GAAG,CAAC;KACZ;IAED,IAAI,EAAE,KAAK,CAAC,EAAE;QACZ,OAAO,CAAC,CAAC;KACV;IACD,IAAI,EAAE,KAAK,CAAC,EAAE;QACZ,OAAO,CAAC,CAAC;KACV;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,EAAE,EAAE,CAAC,EAAE;QACtC,KAAK,IAAI,CAAC,CAAC;QACX,MAAM,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC;QACtB,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QAEpB,IAAI,IAAI,GAAG,EAAE,IAAI,CAAC,EAAE;YAClB,CAAC,GAAG,GAAG,CAAC;SACT;QAED,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,SAAS,IAAI,IAAI,KAAK,CAAC,EAAE;YAC7C,OAAO,GAAG,CAAC;SACZ;KACF;IACD,OAAO,CAAC,GAAG,KAAK,CAAC;AACnB,CAAC;AAnCD,gDAmCC","file":"bisect.js","sourcesContent":["/* Adapted from fmin by Ben Frederickson\n * https://github.com/benfred/fmin\n * Licensed under the BSD-3-Clause\n\n * url: https://github.com/benfred/fmin/blob/master/src/bisect.js\n * License: https://github.com/benfred/fmin/blob/master/LICENSE\n * @license\n */\n\nimport { Logger } from '../logger';\n\n/** finds the zeros of a function, given two starting points (which must\n * have opposite signs */\nexport function findZeroOfFunction(f: any, a: any, b: any, parameters?: any) {\n parameters = parameters || {};\n const maxIterations = parameters.maxIterations || 100;\n const tolerance = parameters.tolerance || 1e-10;\n const fA = f(a);\n const fB = f(b);\n let delta = b - a;\n\n if (fA * fB > 0) {\n const logger = Logger.getInstance();\n logger.error('Initial bisect points must have opposite signs');\n return NaN;\n }\n\n if (fA === 0) {\n return a;\n }\n if (fB === 0) {\n return b;\n }\n\n for (let i = 0; i < maxIterations; ++i) {\n delta /= 2;\n const mid = a + delta;\n const fMid = f(mid);\n\n if (fMid * fA >= 0) {\n a = mid;\n }\n\n if (Math.abs(delta) < tolerance || fMid === 0) {\n return mid;\n }\n }\n return a + delta;\n}\n"]}
|
package/cjs/fmin/blas1.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export declare function zeros(x: number): number[];
|
|
2
2
|
export declare function zerosM(x: number, y: number): number[][];
|
|
3
|
-
export declare function dot(a: number[], b: number[]): number;
|
|
4
3
|
export declare function norm2(a: number[]): number;
|
|
5
4
|
export declare function scale(ret: number[], value: number[], c: number): void;
|
|
6
5
|
export declare function weightedSum(ret: number[], w1: number, v1: number[], w2: number, v2: number[]): void;
|
package/cjs/fmin/blas1.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: !0
|
|
5
|
+
}), exports.gemv = exports.weightedSum = exports.scale = exports.norm2 = exports.zerosM = exports.zeros = void 0;
|
|
6
|
+
|
|
7
|
+
const math_1 = require("../math");
|
|
8
|
+
|
|
3
9
|
function zeros(x) {
|
|
4
10
|
const r = new Array(x);
|
|
5
11
|
for (let i = 0; i < x; ++i) r[i] = 0;
|
|
@@ -12,14 +18,8 @@ function zerosM(x, y) {
|
|
|
12
18
|
}));
|
|
13
19
|
}
|
|
14
20
|
|
|
15
|
-
function dot(a, b) {
|
|
16
|
-
let ret = 0;
|
|
17
|
-
for (let i = 0; i < a.length; ++i) ret += a[i] * b[i];
|
|
18
|
-
return ret;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
21
|
function norm2(a) {
|
|
22
|
-
return Math.sqrt(
|
|
22
|
+
return Math.sqrt((0, math_1.dotProduct)(a, a));
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
function scale(ret, value, c) {
|
|
@@ -31,12 +31,9 @@ function weightedSum(ret, w1, v1, w2, v2) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function gemv(output, A, x) {
|
|
34
|
-
for (let i = 0; i < output.length; ++i) output[i] =
|
|
34
|
+
for (let i = 0; i < output.length; ++i) output[i] = (0, math_1.dotProduct)(A[i], x);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}), exports.gemv = exports.weightedSum = exports.scale = exports.norm2 = exports.dot = exports.zerosM = exports.zeros = void 0,
|
|
40
|
-
exports.zeros = zeros, exports.zerosM = zerosM, exports.dot = dot, exports.norm2 = norm2,
|
|
41
|
-
exports.scale = scale, exports.weightedSum = weightedSum, exports.gemv = gemv;
|
|
37
|
+
exports.zeros = zeros, exports.zerosM = zerosM, exports.norm2 = norm2, exports.scale = scale,
|
|
38
|
+
exports.weightedSum = weightedSum, exports.gemv = gemv;
|
|
42
39
|
//# sourceMappingURL=blas1.js.map
|
package/cjs/fmin/blas1.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/fmin/blas1.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../src/fmin/blas1.ts"],"names":[],"mappings":";;;AASA,kCAAqC;AAIrC,SAAgB,KAAK,CAAC,CAAS;IAC7B,MAAM,CAAC,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;IACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;QAC1B,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;KACV;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAND,sBAMC;AACD,SAAgB,MAAM,CAAC,CAAS,EAAE,CAAS;IACzC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QAClB,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AAJD,wBAIC;AAED,SAAgB,KAAK,CAAC,CAAW;IAC/B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAA,iBAAU,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC;AAFD,sBAEC;AAED,SAAgB,KAAK,CAAC,GAAa,EAAE,KAAe,EAAE,CAAS;IAC7D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACrC,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;KACvB;AACH,CAAC;AAJD,sBAIC;AAED,SAAgB,WAAW,CAAC,GAAa,EAAE,EAAU,EAAE,EAAY,EAAE,EAAU,EAAE,EAAY;IAC3F,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACnC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;KAClC;AACH,CAAC;AAJD,kCAIC;AAED,SAAgB,IAAI,CAAC,MAAgB,EAAE,CAAa,EAAE,CAAW;IAC/D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACtC,MAAM,CAAC,CAAC,CAAC,GAAG,IAAA,iBAAU,EAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KACjC;AACH,CAAC;AAJD,oBAIC","file":"blas1.js","sourcesContent":["/* Adapted from fmin by Ben Frederickson\n * https://github.com/benfred/fmin\n * Licensed under the BSD-3-Clause\n\n * url: https://github.com/benfred/fmin/blob/master/src/blas1.js\n * License: https://github.com/benfred/fmin/blob/master/LICENSE\n * @license\n */\n\nimport { dotProduct } from '../math';\n\n// need some basic operations on vectors, rather than adding a dependency,\n// just define here\nexport function zeros(x: number): number[] {\n const r = new Array(x);\n for (let i = 0; i < x; ++i) {\n r[i] = 0;\n }\n return r;\n}\nexport function zerosM(x: number, y: number) {\n return zeros(x).map(function () {\n return zeros(y);\n });\n}\n\nexport function norm2(a: number[]) {\n return Math.sqrt(dotProduct(a, a));\n}\n\nexport function scale(ret: number[], value: number[], c: number) {\n for (let i = 0; i < value.length; ++i) {\n ret[i] = value[i] * c;\n }\n}\n\nexport function weightedSum(ret: number[], w1: number, v1: number[], w2: number, v2: number[]) {\n for (let j = 0; j < ret.length; ++j) {\n ret[j] = w1 * v1[j] + w2 * v2[j];\n }\n}\n\nexport function gemv(output: number[], A: number[][], x: number[]) {\n for (let i = 0; i < output.length; ++i) {\n output[i] = dotProduct(A[i], x);\n }\n}\n"]}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.conjugateGradient = void 0;
|
|
6
6
|
|
|
7
|
-
const blas1_1 = require("./blas1"), linesearch_1 = require("./linesearch");
|
|
7
|
+
const math_1 = require("../math"), blas1_1 = require("./blas1"), linesearch_1 = require("./linesearch");
|
|
8
8
|
|
|
9
9
|
function conjugateGradient(f, initial, params) {
|
|
10
10
|
let current = {
|
|
@@ -30,8 +30,8 @@ function conjugateGradient(f, initial, params) {
|
|
|
30
30
|
alpha: a
|
|
31
31
|
}), a) {
|
|
32
32
|
(0, blas1_1.weightedSum)(yk, 1, next.fxprime, -1, current.fxprime);
|
|
33
|
-
const delta_k = (0,
|
|
34
|
-
|
|
33
|
+
const delta_k = (0, math_1.dotProduct)(current.fxprime, current.fxprime), beta_k = Math.max(0, (0,
|
|
34
|
+
math_1.dotProduct)(yk, next.fxprime) / delta_k);
|
|
35
35
|
(0, blas1_1.weightedSum)(pk, beta_k, pk, -1, next.fxprime), temp = current, current = next,
|
|
36
36
|
next = temp;
|
|
37
37
|
} else (0, blas1_1.scale)(pk, current.fxprime, -1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/fmin/conjugate-gradient.ts"],"names":[],"mappings":";;;AASA,
|
|
1
|
+
{"version":3,"sources":["../src/fmin/conjugate-gradient.ts"],"names":[],"m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ient.js","sourcesContent":["/* Adapted from fmin by Ben Frederickson\n * https://github.com/benfred/fmin\n * Licensed under the BSD-3-Clause\n\n * url: https://github.com/benfred/fmin/blob/master/src/conjugateGradient.js\n * License: https://github.com/benfred/fmin/blob/master/LICENSE\n * @license\n */\n\nimport { dotProduct } from '../math';\nimport { norm2, scale, weightedSum } from './blas1';\nimport { wolfeLineSearch } from './linesearch';\n\nexport function conjugateGradient(f: any, initial: any, params: any) {\n // allocate all memory up front here, keep out of the loop for perfomance\n // reasons\n let current = { x: initial.slice(), fx: 0, fxprime: initial.slice() };\n let next = { x: initial.slice(), fx: 0, fxprime: initial.slice() };\n const yk = initial.slice();\n let temp;\n let a = 1;\n\n params = params || {};\n const maxIterations = params.maxIterations || initial.length * 20;\n\n current.fx = f(current.x, current.fxprime);\n const pk = current.fxprime.slice();\n scale(pk, current.fxprime, -1);\n\n for (let i = 0; i < maxIterations; ++i) {\n a = wolfeLineSearch(f, pk, current, next, a);\n\n // todo: history in wrong spot?\n if (params.history) {\n params.history.push({ x: current.x.slice(), fx: current.fx, fxprime: current.fxprime.slice(), alpha: a });\n }\n\n if (!a) {\n // faiiled to find point that satifies wolfe conditions.\n // reset direction for next iteration\n scale(pk, current.fxprime, -1);\n } else {\n // update direction using Polak–Ribiere CG method\n weightedSum(yk, 1, next.fxprime, -1, current.fxprime);\n\n const delta_k = dotProduct(current.fxprime, current.fxprime);\n const beta_k = Math.max(0, dotProduct(yk, next.fxprime) / delta_k);\n\n weightedSum(pk, beta_k, pk, -1, next.fxprime);\n\n temp = current;\n current = next;\n next = temp;\n }\n\n if (norm2(current.fxprime) <= 1e-5) {\n break;\n }\n }\n\n if (params.history) {\n params.history.push({ x: current.x.slice(), fx: current.fx, fxprime: current.fxprime.slice(), alpha: a });\n }\n\n return current;\n}\n"]}
|
package/cjs/fmin/linesearch.js
CHANGED
|
@@ -4,15 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.wolfeLineSearch = void 0;
|
|
6
6
|
|
|
7
|
-
const blas1_1 = require("./blas1");
|
|
7
|
+
const math_1 = require("../math"), blas1_1 = require("./blas1");
|
|
8
8
|
|
|
9
9
|
function wolfeLineSearch(f, pk, current, next, a, c1, c2) {
|
|
10
|
-
const phi0 = current.fx, phiPrime0 = (0,
|
|
10
|
+
const phi0 = current.fx, phiPrime0 = (0, math_1.dotProduct)(current.fxprime, pk);
|
|
11
11
|
let phi = phi0, phi_old = phi0, phiPrime = phiPrime0, a0 = 0;
|
|
12
12
|
function zoom(a_lo, a_high, phi_lo) {
|
|
13
13
|
for (let iteration = 0; iteration < 16; ++iteration) if (a = (a_lo + a_high) / 2,
|
|
14
14
|
(0, blas1_1.weightedSum)(next.x, 1, current.x, a, pk), phi = next.fx = f(next.x, next.fxprime),
|
|
15
|
-
phiPrime = (0,
|
|
15
|
+
phiPrime = (0, math_1.dotProduct)(next.fxprime, pk), phi > phi0 + c1 * a * phiPrime0 || phi >= phi_lo) a_high = a; else {
|
|
16
16
|
if (Math.abs(phiPrime) <= -c2 * phiPrime0) return a;
|
|
17
17
|
phiPrime * (a_high - a_lo) >= 0 && (a_high = a_lo), a_lo = a, phi_lo = phi;
|
|
18
18
|
}
|
|
@@ -21,7 +21,7 @@ function wolfeLineSearch(f, pk, current, next, a, c1, c2) {
|
|
|
21
21
|
a = a || 1, c1 = c1 || 1e-6, c2 = c2 || .1;
|
|
22
22
|
for (let iteration = 0; iteration < 10; ++iteration) {
|
|
23
23
|
if ((0, blas1_1.weightedSum)(next.x, 1, current.x, a, pk), phi = next.fx = f(next.x, next.fxprime),
|
|
24
|
-
phiPrime = (0,
|
|
24
|
+
phiPrime = (0, math_1.dotProduct)(next.fxprime, pk), phi > phi0 + c1 * a * phiPrime0 || iteration && phi >= phi_old) return zoom(a0, a, phi_old);
|
|
25
25
|
if (Math.abs(phiPrime) <= -c2 * phiPrime0) return a;
|
|
26
26
|
if (phiPrime >= 0) return zoom(a, a0, phi);
|
|
27
27
|
phi_old = phi, a0 = a, a *= 2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/fmin/linesearch.ts"],"names":[],"mappings":";;;AASA,
|
|
1
|
+
{"version":3,"sources":["../src/fmin/linesearch.ts"],"names":[],"mappings":";;;AASA,kCAAqC;AACrC,mCAAsC;AAStC,SAAgB,eAAe,CAAC,CAAM,EAAE,EAAY,EAAE,OAAY,EAAE,IAAS,EAAE,CAAS,EAAE,EAAW,EAAE,EAAW;IAChH,MAAM,IAAI,GAAG,OAAO,CAAC,EAAE,CAAC;IACxB,MAAM,SAAS,GAAG,IAAA,iBAAU,EAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAClD,IAAI,GAAG,GAAG,IAAI,CAAC;IACf,IAAI,OAAO,GAAG,IAAI,CAAC;IACnB,IAAI,QAAQ,GAAG,SAAS,CAAC;IACzB,IAAI,EAAE,GAAG,CAAC,CAAC;IAEX,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACX,EAAE,GAAG,EAAE,IAAI,IAAI,CAAC;IAChB,EAAE,GAAG,EAAE,IAAI,GAAG,CAAC;IAEf,SAAS,IAAI,CAAC,IAAY,EAAE,MAAc,EAAE,MAAc;QACxD,KAAK,IAAI,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,EAAE,EAAE,EAAE,SAAS,EAAE;YACnD,CAAC,GAAG,CAAC,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YACxB,IAAA,mBAAW,EAAC,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;YAC3C,GAAG,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YACxC,QAAQ,GAAG,IAAA,iBAAU,EAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YAExC,IA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AAE,EAAE,GAAG,CAAC,CAAC;SACzB;QAED,OAAO,GAAG,GAAG,CAAC;QACd,EAAE,GAAG,CAAC,CAAC;QACP,CAAC,IAAI,CAAC,CAAC;KACR;IAED,OAAO,CAAC,CAAC;AACX,CAAC;AA5DD,0CA4DC","file":"linesearch.js","sourcesContent":["/* Adapted from fmin by Ben Frederickson\n * https://github.com/benfred/fmin\n * Licensed under the BSD-3-Clause\n\n * url: https://github.com/benfred/fmin/blob/master/src/linesearch.js\n * License: https://github.com/benfred/fmin/blob/master/LICENSE\n * @license\n */\n\nimport { dotProduct } from '../math';\nimport { weightedSum } from './blas1';\n\n/// searches along line 'pk' for a point that satifies the wolfe conditions\n/// See 'Numerical Optimization' by Nocedal and Wright p59-60\n/// f : objective function\n/// pk : search direction\n/// current: object containing current gradient/loss\n/// next: output: contains next gradient/loss\n/// returns a: step size taken\nexport function wolfeLineSearch(f: any, pk: number[], current: any, next: any, a: number, c1?: number, c2?: number) {\n const phi0 = current.fx;\n const phiPrime0 = dotProduct(current.fxprime, pk);\n let phi = phi0;\n let phi_old = phi0;\n let phiPrime = phiPrime0;\n let a0 = 0;\n\n a = a || 1;\n c1 = c1 || 1e-6;\n c2 = c2 || 0.1;\n\n function zoom(a_lo: number, a_high: number, phi_lo: number) {\n for (let iteration = 0; iteration < 16; ++iteration) {\n a = (a_lo + a_high) / 2;\n weightedSum(next.x, 1.0, current.x, a, pk);\n phi = next.fx = f(next.x, next.fxprime);\n phiPrime = dotProduct(next.fxprime, pk);\n\n if (phi > phi0 + c1 * a * phiPrime0 || phi >= phi_lo) {\n a_high = a;\n } else {\n if (Math.abs(phiPrime) <= -c2 * phiPrime0) {\n return a;\n }\n\n if (phiPrime * (a_high - a_lo) >= 0) {\n a_high = a_lo;\n }\n\n a_lo = a;\n phi_lo = phi;\n }\n }\n\n return 0;\n }\n\n for (let iteration = 0; iteration < 10; ++iteration) {\n weightedSum(next.x, 1.0, current.x, a, pk);\n phi = next.fx = f(next.x, next.fxprime);\n phiPrime = dotProduct(next.fxprime, pk);\n if (phi > phi0 + c1 * a * phiPrime0 || (iteration && phi >= phi_old)) {\n return zoom(a0, a, phi_old);\n }\n\n if (Math.abs(phiPrime) <= -c2 * phiPrime0) {\n return a;\n }\n\n if (phiPrime >= 0) {\n return zoom(a, a0, phi);\n }\n\n phi_old = phi;\n a0 = a;\n a *= 2;\n }\n\n return a;\n}\n"]}
|
package/cjs/math.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ export declare function crossProductPoint(dir1: {
|
|
|
61
61
|
x: number;
|
|
62
62
|
y: number;
|
|
63
63
|
}): number;
|
|
64
|
+
export declare function dotProduct(a: number[] | Float32Array, b: number[] | Float32Array): number;
|
|
64
65
|
export declare function fuzzyEqualNumber(a: number, b: number): boolean;
|
|
65
66
|
export declare function fuzzyEqualVec(a: vec2, b: vec2): boolean;
|
|
66
67
|
export declare function fixPrecision(num: number, precision?: number): number;
|
package/cjs/math.js
CHANGED
|
@@ -30,6 +30,12 @@ function crossProductPoint(dir1, dir2) {
|
|
|
30
30
|
return dir1.x * dir2.y - dir1.y * dir2.x;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
function dotProduct(a, b) {
|
|
34
|
+
let ret = 0;
|
|
35
|
+
for (let i = 0; i < a.length; ++i) ret += a[i] * b[i];
|
|
36
|
+
return ret;
|
|
37
|
+
}
|
|
38
|
+
|
|
33
39
|
function fuzzyEqualNumber(a, b) {
|
|
34
40
|
return (0, exports.abs)(a - b) < exports.epsilon;
|
|
35
41
|
}
|
|
@@ -57,7 +63,7 @@ function precisionSub(a, b) {
|
|
|
57
63
|
|
|
58
64
|
Object.defineProperty(exports, "__esModule", {
|
|
59
65
|
value: !0
|
|
60
|
-
}), exports.precisionSub = exports.precisionAdd = exports.getDecimalPlaces = exports.fixPrecision = exports.fuzzyEqualVec = exports.fuzzyEqualNumber = exports.crossProductPoint = exports.crossProduct = exports.lengthFromPointToLine = exports.pointAt = exports.asin = exports.acos = exports.pow = exports.sqrt = exports.sin = exports.min = exports.max = exports.cos = exports.atan2 = exports.abs = exports.pi2 = exports.SUBDIVISION_MAX_ITERATIONS = exports.SUBDIVISION_PRECISION = exports.NEWTON_MIN_SLOPE = exports.NEWTON_ITERATIONS = exports.tau = exports.halfPi = exports.pi = exports.epsilon = void 0,
|
|
66
|
+
}), exports.precisionSub = exports.precisionAdd = exports.getDecimalPlaces = exports.fixPrecision = exports.fuzzyEqualVec = exports.fuzzyEqualNumber = exports.dotProduct = exports.crossProductPoint = exports.crossProduct = exports.lengthFromPointToLine = exports.pointAt = exports.asin = exports.acos = exports.pow = exports.sqrt = exports.sin = exports.min = exports.max = exports.cos = exports.atan2 = exports.abs = exports.pi2 = exports.SUBDIVISION_MAX_ITERATIONS = exports.SUBDIVISION_PRECISION = exports.NEWTON_MIN_SLOPE = exports.NEWTON_ITERATIONS = exports.tau = exports.halfPi = exports.pi = exports.epsilon = void 0,
|
|
61
67
|
exports.epsilon = 1e-12, exports.pi = Math.PI, exports.halfPi = exports.pi / 2,
|
|
62
68
|
exports.tau = 2 * exports.pi, exports.NEWTON_ITERATIONS = 4, exports.NEWTON_MIN_SLOPE = .001,
|
|
63
69
|
exports.SUBDIVISION_PRECISION = 1e-7, exports.SUBDIVISION_MAX_ITERATIONS = 10, exports.pi2 = 2 * Math.PI,
|
|
@@ -65,7 +71,7 @@ exports.abs = Math.abs, exports.atan2 = Math.atan2, exports.cos = Math.cos, expo
|
|
|
65
71
|
exports.min = Math.min, exports.sin = Math.sin, exports.sqrt = Math.sqrt, exports.pow = Math.pow,
|
|
66
72
|
exports.acos = acos, exports.asin = asin, exports.pointAt = pointAt, exports.lengthFromPointToLine = lengthFromPointToLine,
|
|
67
73
|
exports.crossProduct = crossProduct, exports.crossProductPoint = crossProductPoint,
|
|
68
|
-
exports.fuzzyEqualNumber = fuzzyEqualNumber, exports.fuzzyEqualVec = fuzzyEqualVec,
|
|
74
|
+
exports.dotProduct = dotProduct, exports.fuzzyEqualNumber = fuzzyEqualNumber, exports.fuzzyEqualVec = fuzzyEqualVec,
|
|
69
75
|
exports.fixPrecision = fixPrecision, exports.getDecimalPlaces = getDecimalPlaces,
|
|
70
76
|
exports.precisionAdd = precisionAdd, exports.precisionSub = precisionSub;
|
|
71
77
|
//# sourceMappingURL=math.js.map
|
package/cjs/math.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/math.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,KAAK,CAAC;AAChB,QAAA,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;AACb,QAAA,MAAM,GAAG,UAAE,GAAG,CAAC,CAAC;AAChB,QAAA,GAAG,GAAG,CAAC,GAAG,UAAE,CAAC;AACb,QAAA,iBAAiB,GAAG,CAAC,CAAC;AACtB,QAAA,gBAAgB,GAAG,KAAK,CAAC;AACzB,QAAA,qBAAqB,GAAG,SAAS,CAAC;AAClC,QAAA,0BAA0B,GAAG,EAAE,CAAC;AAChC,QAAA,GAAG,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;AA2BlB,QAAA,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AACf,QAAA,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;AACnB,QAAA,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AACf,QAAA,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AACf,QAAA,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AACf,QAAA,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AACf,QAAA,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;AACjB,QAAA,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AAE5B,SAAgB,IAAI,CAAC,CAAS;IAC5B,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,UAAE,CAAC,CAAC,CAAC,IAAI,CAAC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IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACjE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvB,CAAC;AAJD,4CAIC;AAED,SAAgB,YAAY,CAAC,CAAS,EAAE,CAAS;IAC/C,OAAO,YAAY,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvF,CAAC;AAFD,oCAEC;AAED,SAAgB,YAAY,CAAC,CAAS,EAAE,CAAS;IAC/C,OAAO,YAAY,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvF,CAAC;AAFD,oCAEC","file":"math.js","sourcesContent":["export const epsilon = 1e-12;\nexport const pi = Math.PI;\nexport const halfPi = pi / 2;\nexport const tau = 2 * pi;\nexport const NEWTON_ITERATIONS = 4;\nexport const NEWTON_MIN_SLOPE = 0.001;\nexport const SUBDIVISION_PRECISION = 0.0000001;\nexport const SUBDIVISION_MAX_ITERATIONS = 10;\nexport const pi2 = Math.PI * 2;\n\nexport type vec2 = [number, number] | Float32Array;\nexport type vec3 = [number, number, number] | Float32Array;\nexport type vec4 = [number, number, number, number] | Float32Array;\nexport type vec8 = [number, number, number, number, number, number, number, number] | Float32Array;\nexport type mat4 =\n | [\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number\n ]\n | Float32Array;\n\nexport const abs = Math.abs;\nexport const atan2 = Math.atan2;\nexport const cos = Math.cos;\nexport const max = Math.max;\nexport const min = Math.min;\nexport const sin = Math.sin;\nexport const sqrt = Math.sqrt;\nexport const pow = Math.pow;\n\nexport function acos(x: number) {\n return x > 1 ? 0 : x < -1 ? pi : Math.acos(x);\n}\n\nexport function asin(x: number) {\n return x >= 1 ? halfPi : x <= -1 ? -halfPi : Math.asin(x);\n}\n\n/**\n * 根据比例获直线上的点\n * @param {number} x1 起始点 x\n * @param {number} y1 起始点 y\n * @param {number} x2 结束点 x\n * @param {number} y2 结束点 y\n * @param {number} t 指定比例\n * @return {object} 包含 x, y 的点\n */\nexport function pointAt(\n x1: number | null | undefined,\n y1: number | null | undefined,\n x2: number | null | undefined,\n y2: number | null | undefined,\n t: number\n): {\n x: undefined | number;\n y: undefined | number;\n} {\n let x: number | undefined;\n let y: number | undefined;\n if (typeof x1 === 'number' && typeof x2 === 'number') {\n x = (1 - t) * x1 + t * x2;\n }\n if (typeof y1 === 'number' && typeof y2 === 'number') {\n y = (1 - t) * y1 + t * y2;\n }\n return {\n x,\n y\n };\n}\n\nexport function lengthFromPointToLine(\n point: { x: number; y: number },\n point1: { x: number; y: number },\n point2: { x: number; y: number }\n): number {\n // 面积\n const dir1X = point2.x - point1.x;\n const dir1Y = point2.y - point1.y;\n const dir2X = point.x - point1.x;\n const dir2Y = point.y - point1.y;\n const s = Math.abs(dir1X * dir2Y - dir2X * dir1Y);\n const length = Math.sqrt(dir1X * dir1X + dir1Y * dir1Y);\n return s / length;\n}\n\nexport function crossProduct(dir1: vec2, dir2: vec2): number {\n return dir1[0] * dir2[1] - dir1[1] * dir2[0];\n}\n\nexport function crossProductPoint(dir1: { x: number; y: number }, dir2: { x: number; y: number }): number {\n return dir1.x * dir2.y - dir1.y * dir2.x;\n}\n\nexport function fuzzyEqualNumber(a: number, b: number): boolean {\n return abs(a - b) < epsilon;\n}\n\nexport function fuzzyEqualVec(a: vec2, b: vec2): boolean {\n return abs(a[0] - b[0]) + abs(a[1] - b[1]) < epsilon;\n}\n\nexport function fixPrecision(num: number, precision = 10) {\n return Math.round(num * precision) / precision;\n}\n\nexport function getDecimalPlaces(n: number): number {\n const dStr = n.toString().split(/[eE]/);\n const s = (dStr[0].split('.')[1] || '').length - (+dStr[1] || 0);\n return s > 0 ? s : 0;\n}\n\nexport function precisionAdd(a: number, b: number) {\n return fixPrecision(a + b, 10 ** Math.max(getDecimalPlaces(a), getDecimalPlaces(b)));\n}\n\nexport function precisionSub(a: number, b: number) {\n return fixPrecision(a - b, 10 ** Math.max(getDecimalPlaces(a), getDecimalPlaces(b)));\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/math.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,KAAK,CAAC;AAChB,QAAA,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;AACb,QAAA,MAAM,GAAG,UAAE,GAAG,CAAC,CAAC;AAChB,QAAA,GAAG,GAAG,CAAC,GAAG,UAAE,CAAC;AACb,QAAA,iBAAiB,GAAG,CAAC,CAAC;AACtB,QAAA,gBAAgB,GAAG,KAAK,CAAC;AACzB,QAAA,qBAAqB,GAAG,SAAS,CAAC;AAClC,QAAA,0BAA0B,GAAG,EAAE,CAAC;AAChC,QAAA,GAAG,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;AA2BlB,QAAA,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AACf,QAAA,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;AACnB,QAAA,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AACf,QAAA,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AACf,QAAA,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AACf,QAAA,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AACf,QAAA,IAAI,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AO,YAAY,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvF,CAAC;AAFD,oCAEC","file":"math.js","sourcesContent":["export const epsilon = 1e-12;\nexport const pi = Math.PI;\nexport const halfPi = pi / 2;\nexport const tau = 2 * pi;\nexport const NEWTON_ITERATIONS = 4;\nexport const NEWTON_MIN_SLOPE = 0.001;\nexport const SUBDIVISION_PRECISION = 0.0000001;\nexport const SUBDIVISION_MAX_ITERATIONS = 10;\nexport const pi2 = Math.PI * 2;\n\nexport type vec2 = [number, number] | Float32Array;\nexport type vec3 = [number, number, number] | Float32Array;\nexport type vec4 = [number, number, number, number] | Float32Array;\nexport type vec8 = [number, number, number, number, number, number, number, number] | Float32Array;\nexport type mat4 =\n | [\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number\n ]\n | Float32Array;\n\nexport const abs = Math.abs;\nexport const atan2 = Math.atan2;\nexport const cos = Math.cos;\nexport const max = Math.max;\nexport const min = Math.min;\nexport const sin = Math.sin;\nexport const sqrt = Math.sqrt;\nexport const pow = Math.pow;\n\nexport function acos(x: number) {\n return x > 1 ? 0 : x < -1 ? pi : Math.acos(x);\n}\n\nexport function asin(x: number) {\n return x >= 1 ? halfPi : x <= -1 ? -halfPi : Math.asin(x);\n}\n\n/**\n * 根据比例获直线上的点\n * @param {number} x1 起始点 x\n * @param {number} y1 起始点 y\n * @param {number} x2 结束点 x\n * @param {number} y2 结束点 y\n * @param {number} t 指定比例\n * @return {object} 包含 x, y 的点\n */\nexport function pointAt(\n x1: number | null | undefined,\n y1: number | null | undefined,\n x2: number | null | undefined,\n y2: number | null | undefined,\n t: number\n): {\n x: undefined | number;\n y: undefined | number;\n} {\n let x: number | undefined;\n let y: number | undefined;\n if (typeof x1 === 'number' && typeof x2 === 'number') {\n x = (1 - t) * x1 + t * x2;\n }\n if (typeof y1 === 'number' && typeof y2 === 'number') {\n y = (1 - t) * y1 + t * y2;\n }\n return {\n x,\n y\n };\n}\n\nexport function lengthFromPointToLine(\n point: { x: number; y: number },\n point1: { x: number; y: number },\n point2: { x: number; y: number }\n): number {\n // 面积\n const dir1X = point2.x - point1.x;\n const dir1Y = point2.y - point1.y;\n const dir2X = point.x - point1.x;\n const dir2Y = point.y - point1.y;\n const s = Math.abs(dir1X * dir2Y - dir2X * dir1Y);\n const length = Math.sqrt(dir1X * dir1X + dir1Y * dir1Y);\n return s / length;\n}\n\nexport function crossProduct(dir1: vec2, dir2: vec2): number {\n return dir1[0] * dir2[1] - dir1[1] * dir2[0];\n}\n\nexport function crossProductPoint(dir1: { x: number; y: number }, dir2: { x: number; y: number }): number {\n return dir1.x * dir2.y - dir1.y * dir2.x;\n}\n\nexport function dotProduct(a: number[] | Float32Array, b: number[] | Float32Array): number {\n let ret = 0;\n for (let i = 0; i < a.length; ++i) {\n ret += a[i] * b[i];\n }\n return ret;\n}\n\nexport function fuzzyEqualNumber(a: number, b: number): boolean {\n return abs(a - b) < epsilon;\n}\n\nexport function fuzzyEqualVec(a: vec2, b: vec2): boolean {\n return abs(a[0] - b[0]) + abs(a[1] - b[1]) < epsilon;\n}\n\nexport function fixPrecision(num: number, precision = 10) {\n return Math.round(num * precision) / precision;\n}\n\nexport function getDecimalPlaces(n: number): number {\n const dStr = n.toString().split(/[eE]/);\n const s = (dStr[0].split('.')[1] || '').length - (+dStr[1] || 0);\n return s > 0 ? s : 0;\n}\n\nexport function precisionAdd(a: number, b: number) {\n return fixPrecision(a + b, 10 ** Math.max(getDecimalPlaces(a), getDecimalPlaces(b)));\n}\n\nexport function precisionSub(a: number, b: number) {\n return fixPrecision(a - b, 10 ** Math.max(getDecimalPlaces(a), getDecimalPlaces(b)));\n}\n"]}
|
package/dist/index.js
CHANGED
|
@@ -1664,6 +1664,13 @@
|
|
|
1664
1664
|
function crossProductPoint(dir1, dir2) {
|
|
1665
1665
|
return dir1.x * dir2.y - dir1.y * dir2.x;
|
|
1666
1666
|
}
|
|
1667
|
+
function dotProduct(a, b) {
|
|
1668
|
+
let ret = 0;
|
|
1669
|
+
for (let i = 0; i < a.length; ++i) {
|
|
1670
|
+
ret += a[i] * b[i];
|
|
1671
|
+
}
|
|
1672
|
+
return ret;
|
|
1673
|
+
}
|
|
1667
1674
|
function fuzzyEqualNumber(a, b) {
|
|
1668
1675
|
return abs(a - b) < epsilon;
|
|
1669
1676
|
}
|
|
@@ -5631,15 +5638,8 @@
|
|
|
5631
5638
|
return zeros(y);
|
|
5632
5639
|
});
|
|
5633
5640
|
}
|
|
5634
|
-
function dot(a, b) {
|
|
5635
|
-
let ret = 0;
|
|
5636
|
-
for (let i = 0; i < a.length; ++i) {
|
|
5637
|
-
ret += a[i] * b[i];
|
|
5638
|
-
}
|
|
5639
|
-
return ret;
|
|
5640
|
-
}
|
|
5641
5641
|
function norm2(a) {
|
|
5642
|
-
return Math.sqrt(
|
|
5642
|
+
return Math.sqrt(dotProduct(a, a));
|
|
5643
5643
|
}
|
|
5644
5644
|
function scale(ret, value, c) {
|
|
5645
5645
|
for (let i = 0; i < value.length; ++i) {
|
|
@@ -5653,7 +5653,7 @@
|
|
|
5653
5653
|
}
|
|
5654
5654
|
function gemv(output, A, x) {
|
|
5655
5655
|
for (let i = 0; i < output.length; ++i) {
|
|
5656
|
-
output[i] =
|
|
5656
|
+
output[i] = dotProduct(A[i], x);
|
|
5657
5657
|
}
|
|
5658
5658
|
}
|
|
5659
5659
|
|
|
@@ -5777,7 +5777,7 @@
|
|
|
5777
5777
|
|
|
5778
5778
|
function wolfeLineSearch(f, pk, current, next, a, c1, c2) {
|
|
5779
5779
|
const phi0 = current.fx;
|
|
5780
|
-
const phiPrime0 =
|
|
5780
|
+
const phiPrime0 = dotProduct(current.fxprime, pk);
|
|
5781
5781
|
let phi = phi0;
|
|
5782
5782
|
let phi_old = phi0;
|
|
5783
5783
|
let phiPrime = phiPrime0;
|
|
@@ -5790,7 +5790,7 @@
|
|
|
5790
5790
|
a = (a_lo + a_high) / 2;
|
|
5791
5791
|
weightedSum(next.x, 1.0, current.x, a, pk);
|
|
5792
5792
|
phi = next.fx = f(next.x, next.fxprime);
|
|
5793
|
-
phiPrime =
|
|
5793
|
+
phiPrime = dotProduct(next.fxprime, pk);
|
|
5794
5794
|
if (phi > phi0 + c1 * a * phiPrime0 || phi >= phi_lo) {
|
|
5795
5795
|
a_high = a;
|
|
5796
5796
|
}
|
|
@@ -5810,7 +5810,7 @@
|
|
|
5810
5810
|
for (let iteration = 0; iteration < 10; ++iteration) {
|
|
5811
5811
|
weightedSum(next.x, 1.0, current.x, a, pk);
|
|
5812
5812
|
phi = next.fx = f(next.x, next.fxprime);
|
|
5813
|
-
phiPrime =
|
|
5813
|
+
phiPrime = dotProduct(next.fxprime, pk);
|
|
5814
5814
|
if (phi > phi0 + c1 * a * phiPrime0 || (iteration && phi >= phi_old)) {
|
|
5815
5815
|
return zoom(a0, a, phi_old);
|
|
5816
5816
|
}
|
|
@@ -5848,8 +5848,8 @@
|
|
|
5848
5848
|
}
|
|
5849
5849
|
else {
|
|
5850
5850
|
weightedSum(yk, 1, next.fxprime, -1, current.fxprime);
|
|
5851
|
-
const delta_k =
|
|
5852
|
-
const beta_k = Math.max(0,
|
|
5851
|
+
const delta_k = dotProduct(current.fxprime, current.fxprime);
|
|
5852
|
+
const beta_k = Math.max(0, dotProduct(yk, next.fxprime) / delta_k);
|
|
5853
5853
|
weightedSum(pk, beta_k, pk, -1, next.fxprime);
|
|
5854
5854
|
temp = current;
|
|
5855
5855
|
current = next;
|
|
@@ -5873,7 +5873,9 @@
|
|
|
5873
5873
|
const fB = f(b);
|
|
5874
5874
|
let delta = b - a;
|
|
5875
5875
|
if (fA * fB > 0) {
|
|
5876
|
-
|
|
5876
|
+
const logger = Logger.getInstance();
|
|
5877
|
+
logger.error('Initial bisect points must have opposite signs');
|
|
5878
|
+
return NaN;
|
|
5877
5879
|
}
|
|
5878
5880
|
if (fA === 0) {
|
|
5879
5881
|
return a;
|
|
@@ -5964,7 +5966,7 @@
|
|
|
5964
5966
|
exports.degreeToRadian = degreeToRadian;
|
|
5965
5967
|
exports.destination = destination;
|
|
5966
5968
|
exports.deviation = deviation;
|
|
5967
|
-
exports.
|
|
5969
|
+
exports.dotProduct = dotProduct;
|
|
5968
5970
|
exports.eastAsianCharacterInfo = eastAsianCharacterInfo;
|
|
5969
5971
|
exports.epsilon = epsilon;
|
|
5970
5972
|
exports.exponent = exponent;
|
package/dist/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).VUtils={})}(this,(function(t){"use strict";function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var u={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,u="~";function n(){}function r(t,e,u){this.fn=t,this.context=e,this.once=u||!1}function i(t,e,n,i,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new r(n,i||t,s),D=u?u+e:e;return t._events[D]?t._events[D].fn?t._events[D]=[t._events[D],o]:t._events[D].push(o):(t._events[D]=o,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new n:delete t._events[e]}function o(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(u=!1)),o.prototype.eventNames=function(){var t,n,r=[];if(0===this._eventsCount)return r;for(n in t=this._events)e.call(t,n)&&r.push(u?n.slice(1):n);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},o.prototype.listeners=function(t){var e=u?u+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var r=0,i=n.length,s=new Array(i);r<i;r++)s[r]=n[r].fn;return s},o.prototype.listenerCount=function(t){var e=u?u+t:t,n=this._events[e];return n?n.fn?1:n.length:0},o.prototype.emit=function(t,e,n,r,i,s){var o=u?u+t:t;if(!this._events[o])return!1;var D,a,h=this._events[o],l=arguments.length;if(h.fn){switch(h.once&&this.removeListener(t,h.fn,void 0,!0),l){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,e),!0;case 3:return h.fn.call(h.context,e,n),!0;case 4:return h.fn.call(h.context,e,n,r),!0;case 5:return h.fn.call(h.context,e,n,r,i),!0;case 6:return h.fn.call(h.context,e,n,r,i,s),!0}for(a=1,D=new Array(l-1);a<l;a++)D[a-1]=arguments[a];h.fn.apply(h.context,D)}else{var c,f=h.length;for(a=0;a<f;a++)switch(h[a].once&&this.removeListener(t,h[a].fn,void 0,!0),l){case 1:h[a].fn.call(h[a].context);break;case 2:h[a].fn.call(h[a].context,e);break;case 3:h[a].fn.call(h[a].context,e,n);break;case 4:h[a].fn.call(h[a].context,e,n,r);break;default:if(!D)for(c=1,D=new Array(l-1);c<l;c++)D[c-1]=arguments[c];h[a].fn.apply(h[a].context,D)}}return!0},o.prototype.on=function(t,e,u){return i(this,t,e,u,!1)},o.prototype.once=function(t,e,u){return i(this,t,e,u,!0)},o.prototype.removeListener=function(t,e,n,r){var i=u?u+t:t;if(!this._events[i])return this;if(!e)return s(this,i),this;var o=this._events[i];if(o.fn)o.fn!==e||r&&!o.once||n&&o.context!==n||s(this,i);else{for(var D=0,a=[],h=o.length;D<h;D++)(o[D].fn!==e||r&&!o[D].once||n&&o[D].context!==n)&&a.push(o[D]);a.length?this._events[i]=1===a.length?a[0]:a:s(this,i)}return this},o.prototype.removeAllListeners=function(t){var e;return t?(e=u?u+t:t,this._events[e]&&s(this,e)):(this._events=new n,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=u,o.EventEmitter=o,t.exports=o}(u);var n=e(u.exports);const r=(t,e)=>Object.prototype.toString.call(t)===`[object ${e}]`,i=(t,e=!1)=>e?"boolean"==typeof t:!0===t||!1===t||r(t,"Boolean"),s=t=>"function"==typeof t,o=t=>null==t,D=t=>null!=t,a=t=>{const e=typeof t;return null!==t&&"object"===e||"function"===e},h=t=>"object"==typeof t&&null!==t,l=function(t){if(!h(t)||!r(t,"Object"))return!1;if(null===Object.getPrototypeOf(t))return!0;let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e},c=(t,e=!1)=>{const u=typeof t;return e?"string"===u:"string"===u||r(t,"String")},f=t=>Array.isArray?Array.isArray(t):r(t,"Array"),F=function(t){return null!==t&&"function"!=typeof t&&Number.isFinite(t.length)},d=t=>r(t,"Date"),g=(t,e=!1)=>{const u=typeof t;return e?"number"===u:"number"===u||r(t,"Number")},m=t=>g(t)&&Number.isFinite(t),C=t=>r(t,"RegExp"),p=Object.prototype,y=Object.prototype.hasOwnProperty;const x=Object.prototype.hasOwnProperty;function E(t,e,u=!1){if(e){if(t===e)return;if(D(e)&&"object"==typeof e){const n=Object(e),r=[];for(const t in n)r.push(t);let{length:i}=r,s=-1;for(;i--;){const i=r[++s];D(n[i])&&"object"==typeof n[i]?M(t,e,i,u):B(t,i,n[i])}}}}function M(t,e,u,n=!1){const r=t[u],i=e[u];let s=e[u],o=!0;if(f(i)){if(n)s=[];else if(f(r))s=r;else if(F(r)){s=new Array(r.length);let t=-1;const e=r.length;for(;++t<e;)s[t]=r[t]}}else l(i)?(s=r,"function"!=typeof r&&"object"==typeof r||(s={})):o=!1;o&&E(s,i,n),B(t,u,s)}function B(t,e,u){(void 0!==u&&!function(t,e){return t===e||Number.isNaN(t)&&Number.isNaN(e)}(t[e],u)||void 0===u&&!(e in t))&&(t[e]=u)}const b=Object.prototype.hasOwnProperty;function v(t){return Object.prototype.toString.call(t)}function A(t){return Object.keys(t)}function w(t,e){return t===e?0!==t||0!==e||1/t==1/e:t!=t&&e!=e}function S(t){return f(t)?t.length:a(t)?Object.keys(t).length:0}function T(t){if(!t)return[];if(Object.keys)return Object.keys(t);const e=[];for(const u in t)t.hasOwnProperty(u)&&e.push(u);return e}function _(t,e,u){const n=T(e);for(let r=0;r<n.length;r++){const i=n[r];(u?null!=e[i]:null==t[i])&&(t[i]=e[i])}return t}function L(t){return D(t)?f(t)?t:[t]:[]}function N(t){if(F(t)){return t[t.length-1]}}function k(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function U(t){return Number(t)}function H(t,e,u=U){const n=t.length;if(!n)return;if(e<=0||n<2)return u(t[0],0,t);if(e>=1)return u(t[n-1],n-1,t);const r=(n-1)*e,i=Math.floor(r),s=u(t[i],i,t);return s+(u(t[i+1],i+1,t)-s)*(r-i)}function O(t,e){let u,n=0,r=0,i=0;if(void 0===e)for(let e of t)null!=e&&(e=+e)>=e&&(u=e-r,r+=u/++n,i+=u*(e-r));else{let s=-1;for(let o of t)null!=(o=e(o,++s,t))&&(o=+o)>=o&&(u=o-r,r+=u/++n,i+=u*(o-r))}return n>1?i/(n-1):0}const I=Math.sqrt(50),R=Math.sqrt(10),P=Math.sqrt(2);const W=1e-10,j=1e-10;function Y(t,e,u=j,n=W){const r=n,i=u*Math.max(t,e);return Math.abs(t-e)<=Math.max(r,i)}const z=(t,e=0)=>{let u="",n=e-1;for(;n>=0;)u=`${u}${t}`,n-=1;return u},q=(t,e,u=" ",n="right")=>{const r=u,i=t+"",s=e-i.length;return s<=0?i:"left"===n?z(r,s)+i:"center"===n?z(r,Math.floor(s/2))+i+z(r,Math.ceil(s/2)):i+z(r,s)},G=function(t,e,u){return t<e?e:t>u?u:t};let V=!1;try{V="function"==typeof requestAnimationFrame&&"function"==typeof cancelAnimationFrame}catch(t){V=!1}function $(t,e,u){let n,r,i,s,o,D,h=0,l=!1,c=!1,f=!0;const F=!e&&0!==e&&V;if("function"!=typeof t)throw new TypeError("Expected a function");function d(e){const u=n,i=r;return n=r=void 0,h=e,s=t.apply(i,u),s}function g(t,e){return F?(cancelAnimationFrame(o),requestAnimationFrame(t)):setTimeout(t,e)}function C(t){const u=t-D;return void 0===D||u>=e||u<0||c&&t-h>=i}function p(){const t=Date.now();if(C(t))return y(t);o=g(p,function(t){const u=t-h,n=e-(t-D);return c?Math.min(n,i-u):n}(t))}function y(t){return o=void 0,f&&n?d(t):(n=r=void 0,s)}function x(...t){const u=Date.now(),i=C(u);if(n=t,r=this,D=u,i){if(void 0===o)return function(t){return h=t,o=g(p,e),l?d(t):s}(D);if(c)return o=g(p,e),d(D)}return void 0===o&&(o=g(p,e)),s}return e=+e||0,a(u)&&(l=!!u.leading,c="maxWait"in u,c&&(i=Math.max(m(u.maxWait)?u.maxWait:0,e)),f="trailing"in u?!!u.trailing:f),x.cancel=function(){void 0!==o&&function(t){if(F)return cancelAnimationFrame(t);clearTimeout(t)}(o),h=0,n=D=r=o=void 0},x.flush=function(){return void 0===o?s:y(Date.now())},x.pending=function(){return void 0!==o},x}function X(t,e){return u=>t*(1-u)+e*u}V=!1;const Z=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,J=new RegExp(Z.source,"g");const Q=/^(?:(\d{4})(?:[-\/](\d{1,2})(?:[-\/](\d{1,2})(?:[T ](\d{1,2})(?::(\d{1,2})(?::(\d{1,2})(?:[.,](\d+))?)?)?(Z|[\+\-]\d\d:?\d\d)?)?)?)?)?$/;function K(t){if(t instanceof Date)return t;if(c(t)){const e=Q.exec(t);if(!e)return new Date(NaN);if(!e[8])return new Date(+e[1],+(e[2]||1)-1,+e[3]||1,+e[4]||0,+(e[5]||0),+e[6]||0,e[7]?+e[7].substring(0,3):0);let u=+e[4]||0;return"Z"!==e[8].toUpperCase()&&(u-=+e[8].slice(0,3)),new Date(Date.UTC(+e[1],+(e[2]||1)-1,+e[3]||1,u,+(e[5]||0),+e[6]||0,e[7]?+e[7].substring(0,3):0))}return o(t)?new Date(NaN):new Date(Math.round(t))}class tt{}const et=1e-12,ut=Math.PI,nt=ut/2,rt=2*ut,it=2*Math.PI,st=Math.abs,ot=Math.atan2,Dt=Math.cos,at=Math.max,ht=Math.min,lt=Math.sin,ct=Math.sqrt,ft=Math.pow;function Ft(t,e,u){const n=u.x-e.x,r=u.y-e.y,i=t.x-e.x,s=t.y-e.y;return Math.abs(n*s-i*r)/Math.sqrt(n*n+r*r)}function dt(t,e){return t[0]*e[1]-t[1]*e[0]}function gt(t,e){return t.x*e.y-t.y*e.x}function mt(t,e){return st(t[0]-e[0])+st(t[1]-e[1])<et}function Ct(t,e=10){return Math.round(t*e)/e}function pt(t){const e=t.toString().split(/[eE]/),u=(e[0].split(".")[1]||"").length-(+e[1]||0);return u>0?u:0}class yt{constructor(t=0,e=0,u,n){this.x=0,this.y=0,this.x=t,this.y=e,this.x1=u,this.y1=n}clone(){return new yt(this.x,this.y)}copyFrom(t){return this.x=t.x,this.y=t.y,this.x1=t.x1,this.y1=t.y1,this.defined=t.defined,this.context=t.context,this}set(t,e){return this.x=t,this.y=e,this}add(t){return g(t)?(this.x+=t,void(this.y+=t)):(this.x+=t.x,this.y+=t.y,this)}sub(t){return g(t)?(this.x-=t,void(this.y-=t)):(this.x-=t.x,this.y-=t.y,this)}multi(t){throw new Error("暂不支持")}div(t){throw new Error("暂不支持")}}class xt{static distancePP(t,e){return ct(ft(t.x-e.x,2)+ft(t.y-e.y,2))}static distanceNN(t,e,u,n){return ct(ft(t-u,2)+ft(e-n,2))}static distancePN(t,e,u){return ct(ft(e-t.x,2)+ft(u-t.y,2))}static pointAtPP(t,e,u){return new yt((e.x-t.x)*u+t.x,(e.y-t.y)*u+t.y)}}class Et{constructor(t=0,e=0,u,n){this.r=0,this.theta=0,this.r=t,this.theta=e,this.r1=u,this.theta1=n}clone(){return new Et(this.r,this.theta)}copyFrom(t){return this.r=t.r,this.theta=t.theta,this.r1=t.r1,this.theta1=t.theta1,this.defined=t.defined,this.context=t.context,this}set(t,e){return this.r=t,this.theta=e,this}}function Mt(t,e,u){const{x1:n,y1:r,x2:i,y2:s}=e;return u.onlyTranslate()?(t!==e&&t.setValue(e.x1,e.y1,e.x2,e.y2),t.translate(u.e,u.f),e):(t.clear(),t.add(u.a*n+u.c*r+u.e,u.b*n+u.d*r+u.f),t.add(u.a*i+u.c*r+u.e,u.b*i+u.d*r+u.f),t.add(u.a*i+u.c*s+u.e,u.b*i+u.d*s+u.f),t.add(u.a*n+u.c*s+u.e,u.b*n+u.d*s+u.f),e)}class Bt{constructor(t){t?this.setValue(t.x1,t.y1,t.x2,t.y2):this.clear()}clone(){return new Bt(this)}clear(){return this.x1=+Number.MAX_VALUE,this.y1=+Number.MAX_VALUE,this.x2=-Number.MAX_VALUE,this.y2=-Number.MAX_VALUE,this}empty(){return this.x1===+Number.MAX_VALUE&&this.y1===+Number.MAX_VALUE&&this.x2===-Number.MAX_VALUE&&this.y2===-Number.MAX_VALUE}equals(t){return this.x1===t.x1&&this.y1===t.y1&&this.x2===t.x2&&this.y2===t.y2}setValue(t=0,e=0,u=0,n=0){return this.x1=t,this.y1=e,this.x2=u,this.y2=n,this}set(t=0,e=0,u=0,n=0){return u<t?(this.x2=t,this.x1=u):(this.x1=t,this.x2=u),n<e?(this.y2=e,this.y1=n):(this.y1=e,this.y2=n),this}add(t=0,e=0){return t<this.x1&&(this.x1=t),e<this.y1&&(this.y1=e),t>this.x2&&(this.x2=t),e>this.y2&&(this.y2=e),this}expand(t=0){return f(t)?(this.y1-=t[0],this.x2+=t[1],this.y2+=t[2],this.x1-=t[3]):(this.x1-=t,this.y1-=t,this.x2+=t,this.y2+=t),this}round(){return this.x1=Math.floor(this.x1),this.y1=Math.floor(this.y1),this.x2=Math.ceil(this.x2),this.y2=Math.ceil(this.y2),this}translate(t=0,e=0){return this.x1+=t,this.x2+=t,this.y1+=e,this.y2+=e,this}rotate(t=0,e=0,u=0){const n=this.rotatedPoints(t,e,u);return this.clear().add(n[0],n[1]).add(n[2],n[3]).add(n[4],n[5]).add(n[6],n[7])}scale(t=0,e=0,u=0,n=0){const r=this.scalePoints(t,e,u,n);return this.clear().add(r[0],r[1]).add(r[2],r[3])}union(t){return t.x1<this.x1&&(this.x1=t.x1),t.y1<this.y1&&(this.y1=t.y1),t.x2>this.x2&&(this.x2=t.x2),t.y2>this.y2&&(this.y2=t.y2),this}intersect(t){return t.x1>this.x1&&(this.x1=t.x1),t.y1>this.y1&&(this.y1=t.y1),t.x2<this.x2&&(this.x2=t.x2),t.y2<this.y2&&(this.y2=t.y2),this}encloses(t){return t&&this.x1<=t.x1&&this.x2>=t.x2&&this.y1<=t.y1&&this.y2>=t.y2}alignsWith(t){return t&&(this.x1===t.x1||this.x2===t.x2||this.y1===t.y1||this.y2===t.y2)}intersects(t){return t&&!(this.x2<t.x1||this.x1>t.x2||this.y2<t.y1||this.y1>t.y2)}contains(t=0,e=0){return!(t<this.x1||t>this.x2||e<this.y1||e>this.y2)}containsPoint(t){return!(t.x<this.x1||t.x>this.x2||t.y<this.y1||t.y>this.y2)}width(){return this.empty()?0:this.x2-this.x1}height(){return this.empty()?0:this.y2-this.y1}scaleX(t=0){return this.x1*=t,this.x2*=t,this}scaleY(t=0){return this.y1*=t,this.y2*=t,this}transformWithMatrix(t){return Mt(this,this,t),this}copy(t){return this.x1=t.x1,this.y1=t.y1,this.x2=t.x2,this.y2=t.y2,this}rotatedPoints(t,e,u){const{x1:n,y1:r,x2:i,y2:s}=this,o=Math.cos(t),D=Math.sin(t),a=e-e*o+u*D,h=u-e*D-u*o;return[o*n-D*r+a,D*n+o*r+h,o*n-D*s+a,D*n+o*s+h,o*i-D*r+a,D*i+o*r+h,o*i-D*s+a,D*i+o*s+h]}scalePoints(t,e,u,n){const{x1:r,y1:i,x2:s,y2:o}=this;return[t*r+(1-t)*u,e*i+(1-e)*n,t*s+(1-t)*u,e*o+(1-e)*n]}}function bt(t){return t*(Math.PI/180)}function vt(t){return 180*t/Math.PI}const At=(t=0)=>{if(t<0)for(;t<-rt;)t+=rt;else if(t>0)for(;t>rt;)t-=rt;return t},wt=At,St=(t=0)=>t>360||t<-360?t%360:t,Tt=St;class _t{constructor(t=1,e=0,u=0,n=1,r=0,i=0){this.a=t,this.b=e,this.c=u,this.d=n,this.e=r,this.f=i}equalToMatrix(t){return!(this.e!==t.e||this.f!==t.f||this.a!==t.a||this.d!==t.d||this.b!==t.b||this.c!==t.c)}equalTo(t,e,u,n,r,i){return!(this.e!==r||this.f!==i||this.a!==t||this.d!==n||this.b!==e||this.c!==u)}setValue(t,e,u,n,r,i){return this.a=t,this.b=e,this.c=u,this.d=n,this.e=r,this.f=i,this}reset(){return this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,this}getInverse(){const t=this.a,e=this.b,u=this.c,n=this.d,r=this.e,i=this.f,s=new _t,o=t*n-e*u;return s.a=n/o,s.b=-e/o,s.c=-u/o,s.d=t/o,s.e=(u*i-n*r)/o,s.f=-(t*i-e*r)/o,s}rotate(t){const e=Math.cos(t),u=Math.sin(t),n=this.a*e+this.c*u,r=this.b*e+this.d*u,i=this.a*-u+this.c*e,s=this.b*-u+this.d*e;return this.a=n,this.b=r,this.c=i,this.d=s,this}rotateByCenter(t,e,u){const n=Math.cos(t),r=Math.sin(t),i=(1-n)*e+r*u,s=(1-n)*u-r*e,o=n*this.a-r*this.b,D=r*this.a+n*this.b,a=n*this.c-r*this.d,h=r*this.c+n*this.d,l=n*this.e-r*this.f+i,c=r*this.e+n*this.f+s;return this.a=o,this.b=D,this.c=a,this.d=h,this.e=l,this.f=c,this}scale(t,e){return this.a*=t,this.b*=t,this.c*=e,this.d*=e,this}setScale(t,e){return this.b=this.b/this.a*t,this.c=this.c/this.d*e,this.a=t,this.d=e,this}transform(t,e,u,n,r,i){return this.multiply(t,e,u,n,r,i),this}translate(t,e){return this.e+=this.a*t+this.c*e,this.f+=this.b*t+this.d*e,this}transpose(){const{a:t,b:e,c:u,d:n,e:r,f:i}=this;return this.a=e,this.b=t,this.c=n,this.d=u,this.e=i,this.f=r,this}multiply(t,e,u,n,r,i){const s=this.a,o=this.b,D=this.c,a=this.d,h=s*t+D*e,l=o*t+a*e,c=s*u+D*n,f=o*u+a*n,F=s*r+D*i+this.e,d=o*r+a*i+this.f;return this.a=h,this.b=l,this.c=c,this.d=f,this.e=F,this.f=d,this}interpolate(t,e){const u=new _t;return u.a=this.a+(t.a-this.a)*e,u.b=this.b+(t.b-this.b)*e,u.c=this.c+(t.c-this.c)*e,u.d=this.d+(t.d-this.d)*e,u.e=this.e+(t.e-this.e)*e,u.f=this.f+(t.f-this.f)*e,u}transformPoint(t,e){const{a:u,b:n,c:r,d:i,e:s,f:o}=this,D=u*i-n*r,a=i/D,h=-n/D,l=-r/D,c=u/D,f=(r*o-i*s)/D,F=-(u*o-n*s)/D,{x:d,y:g}=t;e.x=d*a+g*l+f,e.y=d*h+g*c+F}onlyTranslate(t=1){return this.a===t&&0===this.b&&0===this.c&&this.d===t}clone(){return new _t(this.a,this.b,this.c,this.d,this.e,this.f)}toTransformAttrs(){const t=this.a,e=this.b,u=this.c,n=this.d,r=t*n-e*u,i={x:this.e,y:this.f,rotateDeg:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!==t||0!==e){const s=Math.sqrt(t*t+e*e);i.rotateDeg=e>0?Math.acos(t/s):-Math.acos(t/s),i.scaleX=s,i.scaleY=r/s,i.skewX=(t*u+e*n)/r,i.skewY=0}else if(0!==u||0!==n){const s=Math.sqrt(u*u+n*n);i.rotateDeg=Math.PI/2-(n>0?Math.acos(-u/s):-Math.acos(u/s)),i.scaleX=r/s,i.scaleY=s,i.skewX=0,i.skewY=(t*u+e*n)/r}return i.rotateDeg=vt(i.rotateDeg),i}}function Lt(t,e,u){e/=100,u/=100;const n=(1-Math.abs(2*u-1))*e,r=n*(1-Math.abs(t/60%2-1)),i=u-n/2;let s=0,o=0,D=0;return 0<=t&&t<60?(s=n,o=r,D=0):60<=t&&t<120?(s=r,o=n,D=0):120<=t&&t<180?(s=0,o=n,D=r):180<=t&&t<240?(s=0,o=r,D=n):240<=t&&t<300?(s=r,o=0,D=n):300<=t&&t<360&&(s=n,o=0,D=r),s=Math.round(255*(s+i)),o=Math.round(255*(o+i)),D=Math.round(255*(D+i)),{r:s,g:o,b:D}}function Nt(t,e,u){t/=255,e/=255,u/=255;const n=Math.min(t,e,u),r=Math.max(t,e,u),i=r-n;let s=0,o=0,D=0;return s=0===i?0:r===t?(e-u)/i%6:r===e?(u-t)/i+2:(t-e)/i+4,s=Math.round(60*s),s<0&&(s+=360),D=(r+n)/2,o=0===i?0:i/(1-Math.abs(2*D-1)),o=+(100*o).toFixed(1),D=+(100*D).toFixed(1),{h:s,s:o,l:D}}const kt=/^#([0-9a-f]{3,8})$/,Ut={transparent:4294967040},Ht={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function Ot(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function It(t){return g(t)?new jt(t>>16,t>>8&255,255&t,1):f(t)?new jt(t[0],t[1],t[2]):new jt(255,255,255)}function Rt(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Pt(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}class Wt{static Brighter(t,e=1){return 1===e?t:new Wt(t).brighter(e).toRGBA()}static SetOpacity(t,e=1){return 1===e?t:new Wt(t).setOpacity(e).toRGBA()}static getColorBrightness(t,e="hsl"){const u=t instanceof Wt?t:new Wt(t);switch(e){case"hsv":default:return u.getHSVBrightness();case"hsl":return u.getHSLBrightness();case"lum":return u.getLuminance();case"lum2":return u.getLuminance2();case"lum3":return u.getLuminance3()}}static parseColorString(t){if(D(Ut[t]))return function(t){return g(t)?new jt(t>>>24,t>>>16&255,t>>>8&255,255&t):f(t)?new jt(t[0],t[1],t[2],t[3]):new jt(255,255,255,1)}(Ut[t]);if(D(Ht[t]))return It(Ht[t]);const e=`${t}`.trim().toLowerCase(),u=kt.exec(e);if(u){const t=parseInt(u[1],16),e=u[1].length;return 3===e?new jt((t>>8&15)+((t>>8&15)<<4),(t>>4&15)+((t>>4&15)<<4),(15&t)+((15&t)<<4),1):6===e?It(t):8===e?new jt(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):void 0}if(/^(rgb|RGB|rgba|RGBA)/.test(e)){const t=e.replace(/(?:\(|\)|rgba|RGBA|rgb|RGB)*/g,"").split(",");return new jt(parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10),parseFloat(t[3]))}if(/^(hsl|HSL|hsla|HSLA)/.test(e)){const t=e.replace(/(?:\(|\)|hsla|HSLA|hsl|HSL)*/g,"").split(","),u=Lt(parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10));return new jt(u.r,u.g,u.b,parseFloat(t[3]))}}constructor(t){const e=Wt.parseColorString(t);e?this.color=e:(console.warn(`Warn: 传入${t}无法解析为Color`),this.color=new jt(255,255,255))}toRGBA(){return this.color.formatRgb()}toString(){return this.color.formatRgb()}toHex(){return this.color.formatHex()}toHsl(){return this.color.formatHsl()}brighter(t){const{r:e,g:u,b:n}=this.color;return this.color.r=Math.max(0,Math.min(255,Math.floor(e*t))),this.color.g=Math.max(0,Math.min(255,Math.floor(u*t))),this.color.b=Math.max(0,Math.min(255,Math.floor(n*t))),this}add(t){const{r:e,g:u,b:n}=this.color;return this.color.r+=Math.min(255,e+t.color.r),this.color.g+=Math.min(255,u+t.color.g),this.color.b+=Math.min(255,n+t.color.b),this}sub(t){return this.color.r=Math.max(0,this.color.r-t.color.r),this.color.g=Math.max(0,this.color.g-t.color.g),this.color.b=Math.max(0,this.color.b-t.color.b),this}multiply(t){const{r:e,g:u,b:n}=this.color;return this.color.r=Math.max(0,Math.min(255,Math.floor(e*t.color.r))),this.color.g=Math.max(0,Math.min(255,Math.floor(u*t.color.g))),this.color.b=Math.max(0,Math.min(255,Math.floor(n*t.color.b))),this}getHSVBrightness(){return Math.max(this.color.r,this.color.g,this.color.b)/255}getHSLBrightness(){return.5*(Math.max(this.color.r,this.color.g,this.color.b)/255+Math.min(this.color.r,this.color.g,this.color.b)/255)}setHsl(t,e,u){const n=this.color.opacity,r=Nt(this.color.r,this.color.g,this.color.b),i=Lt(o(t)?r.h:G(t,0,360),o(e)?r.s:e>=0&&e<=1?100*e:e,o(u)?r.l:u<=1&&u>=0?100*u:u);return this.color=new jt(i.r,i.g,i.b,n),this}setRGB(t,e,u){return!o(t)&&(this.color.r=t),!o(e)&&(this.color.g=e),!o(u)&&(this.color.b=u),this}setHex(t){const e=`${t}`.trim().toLowerCase(),u=kt.exec(e),n=parseInt(u[1],16),r=u[1].length;return 3===r?new jt((n>>8&15)+((n>>8&15)<<4),(n>>4&15)+((n>>4&15)<<4),(15&n)+((15&n)<<4),1):6===r?It(n):8===r?new jt(n>>24&255,n>>16&255,n>>8&255,(255&n)/255):this}setColorName(t){const e=Ht[t.toLowerCase()];return void 0!==e?this.setHex(e):console.warn("THREE.Color: Unknown color "+t),this}setScalar(t){return this.color.r=t,this.color.g=t,this.color.b=t,this}setOpacity(t=1){return this.color.opacity=t,this}getLuminance(){return(.2126*this.color.r+.7152*this.color.g+.0722*this.color.b)/255}getLuminance2(){return(.2627*this.color.r+.678*this.color.g+.0593*this.color.b)/255}getLuminance3(){return(.299*this.color.r+.587*this.color.g+.114*this.color.b)/255}clone(){return new Wt(this.color.toString())}copyGammaToLinear(t,e=2){return this.color.r=Math.pow(t.color.r,e),this.color.g=Math.pow(t.color.g,e),this.color.b=Math.pow(t.color.b,e),this}copyLinearToGamma(t,e=2){const u=e>0?1/e:1;return this.color.r=Math.pow(t.color.r,u),this.color.g=Math.pow(t.color.g,u),this.color.b=Math.pow(t.color.b,u),this}convertGammaToLinear(t){return this.copyGammaToLinear(this,t),this}convertLinearToGamma(t){return this.copyLinearToGamma(this,t),this}copySRGBToLinear(t){return this.color.r=Rt(t.color.r),this.color.g=Rt(t.color.g),this.color.b=Rt(t.color.b),this}copyLinearToSRGB(t){return this.color.r=Pt(t.color.r),this.color.g=Pt(t.color.g),this.color.b=Pt(t.color.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}}class jt{constructor(t,e,u,n){this.r=isNaN(+t)?255:Math.max(0,Math.min(255,+t)),this.g=isNaN(+e)?255:Math.max(0,Math.min(255,+e)),this.b=isNaN(+u)?255:Math.max(0,Math.min(255,+u)),D(n)?this.opacity=isNaN(+n)?1:Math.max(0,Math.min(1,+n)):this.opacity=1}formatHex(){return`#${Ot(this.r)+Ot(this.g)+Ot(this.b)+(1===this.opacity?"":Ot(255*this.opacity))}`}formatRgb(){const t=this.opacity;return`${1===t?"rgb(":"rgba("}${this.r},${this.g},${this.b}${1===t?")":`,${t})`}`}formatHsl(){const t=this.opacity,{h:e,s:u,l:n}=Nt(this.r,this.g,this.b);return`${1===t?"hsl(":"hsla("}${e},${u}%,${n}%${1===t?")":`,${t})`}`}toString(){return this.formatHex()}}function Yt(t){let e="",u="",n="";const r="#"===t[0]?1:0;for(let i=r;i<t.length;i++)"#"!==t[i]&&(i<r+2?e+=t[i]:i<r+4?u+=t[i]:i<r+6&&(n+=t[i]));return[parseInt(e,16),parseInt(u,16),parseInt(n,16)]}function zt(t,e,u){return Number((1<<24)+(t<<16)+(e<<8)+u).toString(16).slice(1)}function qt(t,e){const u=t.r,n=e.r,r=t.g,i=e.g,s=t.b,o=e.b,D=t.opacity,a=e.opacity;return t=>{const e=Math.round(u*(1-t)+n*t),h=Math.round(r*(1-t)+i*t),l=Math.round(s*(1-t)+o*t);return new jt(e,h,l,D*(1-t)+a*t)}}var Gt=Object.freeze({__proto__:null,Color:Wt,DEFAULT_COLORS:Ht,RGB:jt,hexToRgb:Yt,hslToRgb:Lt,interpolateRgb:qt,rgbToHex:zt,rgbToHsl:Nt});function Vt(t,e,u){t[0]=e[0]-u[0],t[1]=e[1]-u[1]}let $t,Xt,Zt,Jt,Qt,Kt,te,ee;function ue(t,e,u,n){let r,i=t[0],s=e[0],o=u[0],D=n[0];return s<i&&(r=s,s=i,i=r),D<o&&(r=D,D=o,o=r),!(s<o||D<i)&&(i=t[1],s=e[1],o=u[1],D=n[1],s<i&&(r=s,s=i,i=r),D<o&&(r=D,D=o,o=r),!(s<o||D<i))}var ne;function re(t,e,u){return!e||(u?($t=e.x1,Xt=e.x2,Zt=e.y1,Jt=e.y2,$t>Xt&&([$t,Xt]=[Xt,$t]),Zt>Jt&&([Zt,Jt]=[Jt,Zt]),t.x>=$t&&t.x<=Xt&&t.y>=Zt&&t.y<=Jt):t.x>=e.x1&&t.x<=e.x2&&t.y>=e.y1&&t.y<=e.y2)}function ie(t,e){return Math.abs(e[0]*t[0]+e[1]*t[1])}function se({x:t,y:e},u,n={x:0,y:0}){return{x:(t-n.x)*Math.cos(u)+(e-n.y)*Math.sin(u)+n.x,y:(t-n.x)*Math.sin(u)+(n.y-e)*Math.cos(u)+n.y}}function oe(t){return t/180*Math.PI}function De(t){return{x:(t.x1+t.x2)/2,y:(t.y1+t.y2)/2}}function ae(t,e){const u=e?t.angle:oe(t.angle),n=De(t);return[se({x:t.x1,y:t.y1},u,n),se({x:t.x2,y:t.y1},u,n),se({x:t.x2,y:t.y2},u,n),se({x:t.x1,y:t.y2},u,n)]}let he,le,ce,fe,Fe,de,ge,me,Ce,pe,ye,xe;function Ee(t,e,u=3,n=!1){let r=t.x1,i=t.x2,s=t.y1,o=t.y2,D=e.x1,a=e.x2,h=e.y1,l=e.y2;if(n){let t;r>i&&(t=r,r=i,i=t),s>o&&(t=s,s=o,o=t),D>a&&(t=D,D=a,a=t),h>l&&(t=h,h=l,l=t)}if(r>=a||i<=D||s>=l||o<=h)return[t,e];const c=(i-r+2*u)*(o-s+2*u),f=(a-D+2*u)*(l-h+2*u),F=Math.min(r,D),d=Math.min(s,h),g=Math.max(i,a),m=Math.max(o,l);return c+f>(g-F)*(m-d)?[{x1:F,x2:g,y1:d,y2:m}]:[t,e]}t.InnerBBox=void 0,(ne=t.InnerBBox||(t.InnerBBox={}))[ne.NONE=0]="NONE",ne[ne.BBOX1=1]="BBOX1",ne[ne.BBOX2=2]="BBOX2";const Me={x:0,y:0},Be={x:0,y:0};function be(t,e,u,n){return Ft(t,e,u)<=n/2&&Se(t,e,u)}const ve={x:0,y:0},Ae={x:0,y:0},we={x:0,y:0};function Se(t,e,u){return ve.x=e.x-t.x,ve.y=e.y-t.y,Ae.x=u.x-t.x,Ae.y=u.y-t.y,we.x=e.y-u.y,we.y=u.x-e.x,gt(ve,we)*gt(Ae,we)<0}class Te{constructor(t){this.canvas=t,t&&(this.ctx=t.getContext("2d"))}setCanvas(t){this.canvas=t,t&&(this.ctx=t.getContext("2d"))}measureText(t){return this.canvas?this.measureTextByCanvas(t):(console.warn("[warn] no canvas, measureText might be not accurate"),this.estimate(t))}measureTextByCanvas(t){return this.ctx?(this.ctx.font=function({fontStyle:t,fontVariant:e,fontWeight:u,fontSize:n,fontFamily:r}){return(t?t+" ":"")+(e?e+" ":"")+(u?u+" ":"")+(n||12)+"px "+(r||"sans-serif")}(t),{width:this.ctx.measureText(t.text).width,height:t.fontSize}):(console.error("[error!!!]measureTextByCanvas can not be called without canvas"),{width:-1,height:t.fontSize})}estimate({text:t,fontSize:e}){let u=0,n=0;for(let e=0;e<t.length;e++)t.charCodeAt(e)<128?u++:n++;return{width:~~(.8*u*e+n*e),height:e}}static getDefaultUtils(t){return Te.instance||(Te.instance=new Te(t)),Te.instance}}const _e=1e-8;function Le(t,e,u,n,r){for(let i=0,s=r[r.length-1];i<r.length;i++){const o=r[i];if(ue([t,e],[u,n],[o.x,o.y],[s.x,s.y]))return!0;s=o}return!1}function Ne(t,e,u){let n=0,r=t[0];if(!r)return!1;for(let i=1;i<t.length;i++){const s=t[i];n+=ke(r.x,r.y,s.x,s.y,e,u),r=s}const i=t[0];return Ue(r.x,i.x)&&Ue(r.y,i.y)||(n+=ke(r.x,r.y,i.x,i.y,e,u)),0!==n}function ke(t,e,u,n,r,i){if(i>e&&i>n||i<e&&i<n)return 0;if(n===e)return 0;const s=(i-e)/(n-e);let o=n<e?1:-1;1!==s&&0!==s||(o=n<e?.5:-.5);const D=s*(u-t)+t;return D===r?1/0:D>r?o:0}function Ue(t,e){return Math.abs(t-e)<_e}const He=t=>{if("string"!=typeof t)throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(Oe(),"")},Oe=({onlyFirst:t=!1}={})=>{const e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(e,t?void 0:"g")},Ie=t=>{let e=t.charCodeAt(0),u=2===t.length?t.charCodeAt(1):0,n=e;return 55296<=e&&e<=56319&&56320<=u&&u<=57343&&(e&=1023,u&=1023,n=e<<10|u,n+=65536),12288===n||65281<=n&&n<=65376||65504<=n&&n<=65510?"F":8361===n||65377<=n&&n<=65470||65474<=n&&n<=65479||65482<=n&&n<=65487||65490<=n&&n<=65495||65498<=n&&n<=65500||65512<=n&&n<=65518?"H":4352<=n&&n<=4447||4515<=n&&n<=4519||4602<=n&&n<=4607||9001<=n&&n<=9002||11904<=n&&n<=11929||11931<=n&&n<=12019||12032<=n&&n<=12245||12272<=n&&n<=12283||12289<=n&&n<=12350||12353<=n&&n<=12438||12441<=n&&n<=12543||12549<=n&&n<=12589||12593<=n&&n<=12686||12688<=n&&n<=12730||12736<=n&&n<=12771||12784<=n&&n<=12830||12832<=n&&n<=12871||12880<=n&&n<=13054||13056<=n&&n<=19903||19968<=n&&n<=42124||42128<=n&&n<=42182||43360<=n&&n<=43388||44032<=n&&n<=55203||55216<=n&&n<=55238||55243<=n&&n<=55291||63744<=n&&n<=64255||65040<=n&&n<=65049||65072<=n&&n<=65106||65108<=n&&n<=65126||65128<=n&&n<=65131||110592<=n&&n<=110593||127488<=n&&n<=127490||127504<=n&&n<=127546||127552<=n&&n<=127560||127568<=n&&n<=127569||131072<=n&&n<=194367||177984<=n&&n<=196605||196608<=n&&n<=262141?"W":32<=n&&n<=126||162<=n&&n<=163||165<=n&&n<=166||172===n||175===n||10214<=n&&n<=10221||10629<=n&&n<=10630?"Na":161===n||164===n||167<=n&&n<=168||170===n||173<=n&&n<=174||176<=n&&n<=180||182<=n&&n<=186||188<=n&&n<=191||198===n||208===n||215<=n&&n<=216||222<=n&&n<=225||230===n||232<=n&&n<=234||236<=n&&n<=237||240===n||242<=n&&n<=243||247<=n&&n<=250||252===n||254===n||257===n||273===n||275===n||283===n||294<=n&&n<=295||299===n||305<=n&&n<=307||312===n||319<=n&&n<=322||324===n||328<=n&&n<=331||333===n||338<=n&&n<=339||358<=n&&n<=359||363===n||462===n||464===n||466===n||468===n||470===n||472===n||474===n||476===n||593===n||609===n||708===n||711===n||713<=n&&n<=715||717===n||720===n||728<=n&&n<=731||733===n||735===n||768<=n&&n<=879||913<=n&&n<=929||931<=n&&n<=937||945<=n&&n<=961||963<=n&&n<=969||1025===n||1040<=n&&n<=1103||1105===n||8208===n||8211<=n&&n<=8214||8216<=n&&n<=8217||8220<=n&&n<=8221||8224<=n&&n<=8226||8228<=n&&n<=8231||8240===n||8242<=n&&n<=8243||8245===n||8251===n||8254===n||8308===n||8319===n||8321<=n&&n<=8324||8364===n||8451===n||8453===n||8457===n||8467===n||8470===n||8481<=n&&n<=8482||8486===n||8491===n||8531<=n&&n<=8532||8539<=n&&n<=8542||8544<=n&&n<=8555||8560<=n&&n<=8569||8585===n||8592<=n&&n<=8601||8632<=n&&n<=8633||8658===n||8660===n||8679===n||8704===n||8706<=n&&n<=8707||8711<=n&&n<=8712||8715===n||8719===n||8721===n||8725===n||8730===n||8733<=n&&n<=8736||8739===n||8741===n||8743<=n&&n<=8748||8750===n||8756<=n&&n<=8759||8764<=n&&n<=8765||8776===n||8780===n||8786===n||8800<=n&&n<=8801||8804<=n&&n<=8807||8810<=n&&n<=8811||8814<=n&&n<=8815||8834<=n&&n<=8835||8838<=n&&n<=8839||8853===n||8857===n||8869===n||8895===n||8978===n||9312<=n&&n<=9449||9451<=n&&n<=9547||9552<=n&&n<=9587||9600<=n&&n<=9615||9618<=n&&n<=9621||9632<=n&&n<=9633||9635<=n&&n<=9641||9650<=n&&n<=9651||9654<=n&&n<=9655||9660<=n&&n<=9661||9664<=n&&n<=9665||9670<=n&&n<=9672||9675===n||9678<=n&&n<=9681||9698<=n&&n<=9701||9711===n||9733<=n&&n<=9734||9737===n||9742<=n&&n<=9743||9748<=n&&n<=9749||9756===n||9758===n||9792===n||9794===n||9824<=n&&n<=9825||9827<=n&&n<=9829||9831<=n&&n<=9834||9836<=n&&n<=9837||9839===n||9886<=n&&n<=9887||9918<=n&&n<=9919||9924<=n&&n<=9933||9935<=n&&n<=9953||9955===n||9960<=n&&n<=9983||10045===n||10071===n||10102<=n&&n<=10111||11093<=n&&n<=11097||12872<=n&&n<=12879||57344<=n&&n<=63743||65024<=n&&n<=65039||65533===n||127232<=n&&n<=127242||127248<=n&&n<=127277||127280<=n&&n<=127337||127344<=n&&n<=127386||917760<=n&&n<=917999||983040<=n&&n<=1048573||1048576<=n&&n<=1114109?"A":"N"},Re=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26F9(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC3\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A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0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC2\uDECE-\uDEDB\uDEE0-\uDEE8]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;function Pe(t,e={}){const{fontStyle:u=e.fontStyle,fontVariant:n=e.fontVariant,fontWeight:r=e.fontWeight,fontSize:i=e.fontSize,fontFamily:s=e.fontFamily}=t;return(u?u+" ":"")+(n?n+" ":"")+(r?r+" ":"")+i+"px "+(s||"sans-serif")}class We{constructor(t,e){this._numberCharSize=null,this._fullCharSize=null,this._letterCharSize=null,this._specialCharSizeMap={},this._canvas=null,this._context=null,this._contextSaved=!1,this._notSupportCanvas=!1,this._notSupportVRender=!1,this._userSpec={},this.specialCharSet="-/: .,@%'\"~",this._option=t,this._userSpec=null!=e?e:{},this.textSpec=this._initSpec(),D(t.specialCharSet)&&(this.specialCharSet=t.specialCharSet),this._standardMethod=D(t.getTextBounds)?this.fullMeasure.bind(this):this.measureWithNaiveCanvas.bind(this)}initContext(){if(this._notSupportCanvas)return!1;if(o(this._canvas)&&(D(this._option.getCanvasForMeasure)&&(this._canvas=this._option.getCanvasForMeasure()),o(this._canvas)&&"undefined"!=typeof window&&void 0!==window.document&&globalThis&&D(globalThis.document)&&(this._canvas=globalThis.document.createElement("canvas"))),o(this._context)&&D(this._canvas)){const t=this._canvas.getContext("2d");D(t)&&(t.save(),t.font=Pe(this.textSpec),this._contextSaved=!0,this._context=t)}return!o(this._context)||(this._notSupportCanvas=!0,!1)}_initSpec(){var t,e,u;const{defaultFontParams:n={}}=this._option,{fontStyle:r=n.fontStyle,fontVariant:i=n.fontVariant,fontWeight:s=(null!==(t=n.fontWeight)&&void 0!==t?t:"normal"),fontSize:o=(null!==(e=n.fontSize)&&void 0!==e?e:12),fontFamily:D=(null!==(u=n.fontFamily)&&void 0!==u?u:"sans-serif"),align:a,textAlign:h=(null!=a?a:"center"),baseline:l,textBaseline:f=(null!=l?l:"middle"),ellipsis:F,limit:d}=this._userSpec;let{lineHeight:g=o}=this._userSpec;if(c(g)&&"%"===g[g.length-1]){const t=Number.parseFloat(g.substring(0,g.length-1))/100;g=o*t}return{fontStyle:r,fontVariant:i,fontFamily:D,fontSize:o,fontWeight:s,textAlign:h,textBaseline:f,ellipsis:F,limit:d,lineHeight:g}}measure(t,e){switch(e){case"vrender":case"canopus":return this.fullMeasure(t);case"canvas":return this.measureWithNaiveCanvas(t);case"simple":return this.quickMeasureWithoutCanvas(t);default:return this.quickMeasure(t)}}fullMeasure(t){if(o(t))return{width:0,height:0};if(o(this._option.getTextBounds)||!this._notSupportVRender)return this.measureWithNaiveCanvas(t);const{fontFamily:e,fontSize:u,fontWeight:n,textAlign:r,textBaseline:i,ellipsis:s,limit:D,lineHeight:a}=this.textSpec;let h;try{const o=this._option.getTextBounds({text:t,fontFamily:e,fontSize:u,fontWeight:n,textAlign:r,textBaseline:i,ellipsis:!!s,maxLineWidth:D||1/0,lineHeight:a});h={width:o.width(),height:o.height()}}catch(e){this._notSupportVRender=!0,h=this.measureWithNaiveCanvas(t)}return h}measureWithNaiveCanvas(t){return this._measureReduce(t,this._measureWithNaiveCanvas.bind(this))}_measureWithNaiveCanvas(t){var e;if(!this.initContext())return this._quickMeasureWithoutCanvas(t);const u=this._context.measureText(t),{fontSize:n,lineHeight:r}=this.textSpec;return{width:u.width,height:null!==(e=r)&&void 0!==e?e:n}}quickMeasure(t){return this._measureReduce(t,this._quickMeasure.bind(this))}_quickMeasure(t){const e={width:0,height:0};for(let u=0;u<t.length;u++){const n=t[u];let r=this._measureSpecialChar(n);o(r)&&We.NUMBERS_CHAR_SET.includes(n)&&(r=this._measureNumberChar()),o(r)&&["F","W"].includes(Ie(n))&&(r=this._measureFullSizeChar()),o(r)&&(r=this._measureLetterChar()),e.width+=r.width,e.height=Math.max(e.height,r.height)}return e}quickMeasureWithoutCanvas(t){return this._measureReduce(t,this._quickMeasureWithoutCanvas.bind(this))}_quickMeasureWithoutCanvas(t){var e;const u={width:0,height:0},{fontSize:n,lineHeight:r}=this.textSpec;for(let e=0;e<t.length;e++){const r=t[e],i=["F","W"].includes(Ie(r))?1:.53;u.width+=i*n}return u.height=null!==(e=r)&&void 0!==e?e:n,u}_measureReduce(t,e){var u;const{fontSize:n,lineHeight:r}=this.textSpec,i={width:0,height:0};if(o(t))return i;if(f(t)){const s=t.filter(D).map((t=>t.toString()));return 0===s.length?i:1===s.length?e(s[0]):{width:s.reduce(((t,u)=>Math.max(t,e(u).width)),0),height:s.length*((null!==(u=r)&&void 0!==u?u:n)+1)+1}}return e(t.toString())}_measureNumberChar(){if(o(this._numberCharSize)){const t=this._standardMethod(We.NUMBERS_CHAR_SET);this._numberCharSize={width:t.width/We.NUMBERS_CHAR_SET.length,height:t.height}}return this._numberCharSize}_measureFullSizeChar(){return o(this._fullCharSize)&&(this._fullCharSize=this._standardMethod(We.FULL_SIZE_CHAR)),this._fullCharSize}_measureLetterChar(){if(o(this._letterCharSize)){const t=this._standardMethod(We.ALPHABET_CHAR_SET);this._letterCharSize={width:t.width/We.ALPHABET_CHAR_SET.length,height:t.height}}return this._letterCharSize}_measureSpecialChar(t){return D(this._specialCharSizeMap[t])?this._specialCharSizeMap[t]:this.specialCharSet.includes(t)?(this._specialCharSizeMap[t]=this._standardMethod(t),this._specialCharSizeMap[t]):null}release(){D(this._canvas)&&(this._canvas=null),D(this._context)&&(this._contextSaved&&(this._context.restore(),this._contextSaved=!1),this._context=null)}}We.ALPHABET_CHAR_SET="abcdefghijklmnopqrstuvwxyz",We.NUMBERS_CHAR_SET="0123456789",We.FULL_SIZE_CHAR="字";const je="undefined"!=typeof console;function Ye(t,e,u){const n=[e].concat([].slice.call(u));je&&console[t].apply(console,n)}var ze;t.LoggerLevel=void 0,(ze=t.LoggerLevel||(t.LoggerLevel={}))[ze.None=0]="None",ze[ze.Error=1]="Error",ze[ze.Warn=2]="Warn",ze[ze.Info=3]="Info",ze[ze.Debug=4]="Debug";class qe{static getInstance(t,e){return qe._instance&&g(t)?qe._instance.level(t):qe._instance||(qe._instance=new qe(t,e)),qe._instance}static setInstance(t){return qe._instance=t}static setInstanceLevel(t){qe._instance?qe._instance.level(t):qe._instance=new qe(t)}static clearInstance(){qe._instance=null}constructor(e=t.LoggerLevel.None,u){this._onErrorHandler=[],this._level=e,this._method=u}addErrorHandler(t){this._onErrorHandler.find((e=>e===t))||this._onErrorHandler.push(t)}removeErrorHandler(t){const e=this._onErrorHandler.findIndex((e=>e===t));e<0||this._onErrorHandler.splice(e,1)}callErrorHandler(...t){this._onErrorHandler.forEach((e=>e(...t)))}canLogInfo(){return this._level>=t.LoggerLevel.Info}canLogDebug(){return this._level>=t.LoggerLevel.Debug}canLogError(){return this._level>=t.LoggerLevel.Error}canLogWarn(){return this._level>=t.LoggerLevel.Warn}level(t){return arguments.length?(this._level=+t,this):this._level}error(...e){var u;return this._level>=t.LoggerLevel.Error&&(this._onErrorHandler.length?this.callErrorHandler(...e):Ye(null!==(u=this._method)&&void 0!==u?u:"error","ERROR",e)),this}warn(...e){return this._level>=t.LoggerLevel.Warn&&Ye(this._method||"warn","WARN",e),this}info(...e){return this._level>=t.LoggerLevel.Info&&Ye(this._method||"log","INFO",e),this}debug(...e){return this._level>=t.LoggerLevel.Debug&&Ye(this._method||"log","DEBUG",e),this}}function Ge(t){return t?"getUTCFullYear":"getFullYear"}function Ve(t){return t?"getUTCMonth":"getMonth"}function $e(t){return t?"getUTCDate":"getDate"}function Xe(t){return t?"getUTCHours":"getHours"}function Ze(t){return t?"getUTCMinutes":"getMinutes"}function Je(t){return t?"getUTCSeconds":"getSeconds"}function Qe(t){return t?"getUTCMilliseconds":"getMilliseconds"}qe._instance=null;const Ke=1e3,tu=6e4,eu=36e5,uu=24*eu,nu=t=>(t.setMonth(0,1),t.setHours(0,0,0,0),t),ru=(t,e)=>(t.setFullYear(t.getFullYear()+e),t),iu=(t,e)=>e.getFullYear()-t.getFullYear(),su=t=>t.getFullYear(),ou=t=>(t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0),t),Du=(t,e)=>(t.setUTCFullYear(t.getUTCFullYear()+e),t),au=(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),hu=t=>t.getUTCFullYear(),lu=t=>(t.setDate(1),t.setHours(0,0,0,0),t),cu=(t,e)=>(t.setMonth(t.getMonth()+e),t),fu=(t,e)=>e.getMonth()-t.getMonth()+12*(e.getFullYear()-t.getFullYear()),Fu=t=>t.getMonth(),du=t=>(t.setUTCDate(1),t.setUTCHours(0,0,0,0),t),gu=(t,e)=>(t.setUTCMonth(t.getUTCMonth()+e),t),mu=(t,e)=>e.getUTCMonth()-t.getUTCMonth()+12*(e.getUTCFullYear()-t.getUTCFullYear()),Cu=t=>t.getUTCMonth(),pu=t=>(t.setHours(0,0,0,0),t),yu=(t,e)=>(t.setDate(t.getDate()+e),t),xu=(t,e)=>(+e-+t-(e.getTimezoneOffset()-t.getTimezoneOffset())*tu)/uu,Eu=t=>t.getDate()-1,Mu=t=>(t.setUTCHours(0,0,0,0),t),Bu=(t,e)=>(t.setUTCDate(t.getUTCDate()+e),t),bu=(t,e)=>(+e-+t)/uu,vu=t=>t.getUTCDate()-1,Au=t=>(t.setTime(+t-t.getMilliseconds()-t.getSeconds()*Ke-t.getMinutes()*tu),t),wu=(t,e)=>(t.setHours(t.getHours()+e),t),Su=(t,e)=>(+e-+t)/eu,Tu=t=>t.getHours(),_u=t=>(t.setTime(+t-t.getUTCMilliseconds()-t.getUTCSeconds()*Ke-t.getUTCMinutes()*tu),t),Lu=(t,e)=>(t.setUTCHours(t.getUTCHours()+e),t),Nu=t=>t.getUTCHours(),ku=t=>(t.setTime(+t-t.getMilliseconds()-t.getSeconds()*Ke),t),Uu=(t,e)=>(t.setMinutes(t.getMinutes()+e),t),Hu=(t,e)=>(+e-+t)/tu,Ou=t=>t.getMinutes(),Iu=t=>(t.setTime(+t-t.getUTCMilliseconds()-t.getUTCSeconds()*Ke),t),Ru=(t,e)=>(t.setUTCMinutes(t.getUTCMinutes()+e),t),Pu=t=>t.getUTCMinutes(),Wu=t=>(t.setTime(+t-t.getMilliseconds()),t),ju=(t,e)=>(t.setSeconds(t.getSeconds()+e),t),Yu=(t,e)=>(+e-+t)/Ke,zu=t=>t.getSeconds(),qu=t=>(t.setTime(+t-t.getUTCMilliseconds()),t),Gu=(t,e)=>(t.setUTCSeconds(t.getUTCSeconds()+e),t),Vu=t=>t.getUTCSeconds(),$u=t=>t,Xu=(t,e)=>(t.setTime(+t+e),t),Zu=(t,e)=>+e-+t,Ju=(t,e)=>u=>{const n=new Date(+u-1);return e(n,1),t(n),n},Qu=(t,e)=>(u,n)=>{const r=new Date,i=new Date;return r.setTime(+u),i.setTime(+n),t(r),t(i),Math.floor(e(r,i))};function Ku(t){const{x:e,y:u}=t.getBoundingClientRect();return{x:e,y:u}}const tn=t=>t.getBoundingClientRect().width/t.offsetWidth,en=t=>t.getBoundingClientRect().height/t.offsetHeight;var un=6371008.8,nn={centimeters:637100880,centimetres:637100880,degrees:57.22891354143274,feet:20902260.511392,inches:39.37*un,kilometers:6371.0088,kilometres:6371.0088,meters:un,metres:un,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:un/1852,radians:1,yards:6967335.223679999};const rn=1e-10;function sn(t,e){for(let u=0;u<e.length;++u)if(xt.distancePP(t,e[u])>e[u].radius+rn)return!1;return!0}function on(t,e){return t*t*Math.acos(1-e/t)-(t-e)*Math.sqrt(e*(2*t-e))}function Dn(t,e){const u=xt.distancePP(t,e),n=t.radius,r=e.radius;if(u>=n+r||u<=Math.abs(n-r))return[];const i=(n*n-r*r+u*u)/(2*u),s=Math.sqrt(n*n-i*i),o=t.x+i*(e.x-t.x)/u,D=t.y+i*(e.y-t.y)/u,a=-(e.y-t.y)*(s/u),h=-(e.x-t.x)*(s/u);return[{x:o+a,y:D-h},{x:o-a,y:D+h}]}function an(t){const e={x:0,y:0};for(let u=0;u<t.length;++u)e.x+=t[u].x,e.y+=t[u].y;return e.x/=t.length,e.y/=t.length,e}class hn{static getInstance(){return hn.instance||(hn.instance=new hn),hn.instance}constructor(){this.locale_shortWeekdays=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],this.locale_periods=["AM","PM"],this.locale_weekdays=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],this.locale_shortMonths=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],this.numberRe=/^\s*\d+/,this.pads={"-":"",_:" ",0:"0"},this.requoteRe=/[\\^$*+?|[\]().{}]/g,this.locale_months=["January","February","March","April","May","June","July","August","September","October","November","December"],this.formatShortWeekday=t=>this.locale_shortWeekdays[t.getDay()],this.formatWeekday=t=>this.locale_weekdays[t.getDay()],this.formatShortMonth=t=>this.locale_shortMonths[t.getMonth()],this.formatMonth=t=>this.locale_months[t.getMonth()],this.formatDayOfMonth=(t,e)=>this.pad(t.getDate(),e,2),this.formatHour24=(t,e)=>this.pad(t.getHours(),e,2),this.formatHour12=(t,e)=>this.pad(t.getHours()%12||12,e,2),this.formatMilliseconds=(t,e)=>this.pad(t.getMilliseconds(),e,3),this.formatMonthNumber=(t,e)=>this.pad(t.getMonth()+1,e,2),this.formatMinutes=(t,e)=>this.pad(t.getMinutes(),e,2),this.formatPeriod=t=>this.locale_periods[+(t.getHours()>=12)],this.formatSeconds=(t,e)=>this.pad(t.getSeconds(),e,2),this.formatFullYear=(t,e)=>this.pad(t.getFullYear()%1e4,e,4),this.formatUTCShortWeekday=t=>this.locale_shortWeekdays[t.getUTCDay()],this.formatUTCWeekday=t=>this.locale_weekdays[t.getUTCDay()],this.formatUTCShortMonth=t=>this.locale_shortMonths[t.getUTCMonth()],this.formatUTCMonth=t=>this.locale_months[t.getUTCMonth()],this.formatUTCDayOfMonth=(t,e)=>this.pad(t.getUTCDate(),e,2),this.formatUTCHour24=(t,e)=>this.pad(t.getUTCHours(),e,2),this.formatUTCHour12=(t,e)=>this.pad(t.getUTCHours()%12||12,e,2),this.formatUTCMilliseconds=(t,e)=>this.pad(t.getUTCMilliseconds(),e,3),this.formatUTCMonthNumber=(t,e)=>this.pad(t.getUTCMonth()+1,e,2),this.formatUTCMinutes=(t,e)=>this.pad(t.getUTCMinutes(),e,2),this.formatUTCPeriod=t=>this.locale_periods[+(t.getUTCHours()>=12)],this.formatUTCSeconds=(t,e)=>this.pad(t.getUTCSeconds(),e,2),this.formatUTCFullYear=(t,e)=>this.pad(t.getUTCFullYear()%1e4,e,4),this.formats={a:this.formatShortWeekday,A:this.formatWeekday,b:this.formatShortMonth,B:this.formatMonth,d:this.formatDayOfMonth,e:this.formatDayOfMonth,H:this.formatHour24,I:this.formatHour12,L:this.formatMilliseconds,m:this.formatMonthNumber,M:this.formatMinutes,p:this.formatPeriod,S:this.formatSeconds,Y:this.formatFullYear},this.utcFormats={a:this.formatUTCShortWeekday,A:this.formatUTCWeekday,b:this.formatUTCShortMonth,B:this.formatUTCMonth,d:this.formatUTCDayOfMonth,e:this.formatUTCDayOfMonth,H:this.formatUTCHour24,I:this.formatUTCHour12,L:this.formatUTCMilliseconds,m:this.formatUTCMonthNumber,M:this.formatUTCMinutes,p:this.formatUTCPeriod,S:this.formatUTCSeconds,Y:this.formatUTCFullYear},this.parseShortWeekday=(t,e,u)=>{const n=this.shortWeekdayRe.exec(e.slice(u));return n?(t.w=this.shortWeekdayLookup.get(n[0].toLowerCase()),u+n[0].length):-1},this.parseWeekday=(t,e,u)=>{const n=this.weekdayRe.exec(e.slice(u));return n?(t.w=this.weekdayLookup.get(n[0].toLowerCase()),u+n[0].length):-1},this.parseShortMonth=(t,e,u)=>{const n=this.shortMonthRe.exec(e.slice(u));return n?(t.m=this.shortMonthLookup.get(n[0].toLowerCase()),u+n[0].length):-1},this.parseMonth=(t,e,u)=>{const n=this.monthRe.exec(e.slice(u));return n?(t.m=this.monthLookup.get(n[0].toLowerCase()),u+n[0].length):-1},this.parseDayOfMonth=(t,e,u)=>{const n=this.numberRe.exec(e.slice(u,u+2));return n?(t.d=+n[0],u+n[0].length):-1},this.parseHour24=(t,e,u)=>{const n=this.numberRe.exec(e.slice(u,u+2));return n?(t.H=+n[0],u+n[0].length):-1},this.parseMilliseconds=(t,e,u)=>{const n=this.numberRe.exec(e.slice(u,u+3));return n?(t.L=+n[0],u+n[0].length):-1},this.parseMonthNumber=(t,e,u)=>{const n=this.numberRe.exec(e.slice(u,u+2));return n?(t.m=n-1,u+n[0].length):-1},this.parseMinutes=(t,e,u)=>{const n=this.numberRe.exec(e.slice(u,u+2));return n?(t.M=+n[0],u+n[0].length):-1},this.parsePeriod=(t,e,u)=>{const n=this.periodRe.exec(e.slice(u));return n?(t.p=this.periodLookup.get(n[0].toLowerCase()),u+n[0].length):-1},this.parseSeconds=(t,e,u)=>{const n=this.numberRe.exec(e.slice(u,u+2));return n?(t.S=+n[0],u+n[0].length):-1},this.parseFullYear=(t,e,u)=>{const n=this.numberRe.exec(e.slice(u,u+4));return n?(t.y=+n[0],u+n[0].length):-1},this.parses={a:this.parseShortWeekday,A:this.parseWeekday,b:this.parseShortMonth,B:this.parseMonth,d:this.parseDayOfMonth,e:this.parseDayOfMonth,H:this.parseHour24,I:this.parseHour24,L:this.parseMilliseconds,m:this.parseMonthNumber,M:this.parseMinutes,p:this.parsePeriod,S:this.parseSeconds,Y:this.parseFullYear},this.timeFormat=(t,e)=>this.newFormat(t,this.formats)(new Date(this.getFullTimeStamp(e))),this.timeUTCFormat=(t,e)=>this.newFormat(t,this.utcFormats)(new Date(this.getFullTimeStamp(e))),this.timeParse=(t,e)=>this.newParse(t,!1)(e+""),this.requoteF=this.requote.bind(this),this.periodRe=this.formatRe(this.locale_periods),this.periodLookup=this.formatLookup(this.locale_periods),this.weekdayRe=this.formatRe(this.locale_weekdays),this.weekdayLookup=this.formatLookup(this.locale_weekdays),this.shortWeekdayRe=this.formatRe(this.locale_shortWeekdays),this.shortWeekdayLookup=this.formatLookup(this.locale_shortWeekdays),this.monthRe=this.formatRe(this.locale_months),this.monthLookup=this.formatLookup(this.locale_months),this.shortMonthRe=this.formatRe(this.locale_shortMonths),this.shortMonthLookup=this.formatLookup(this.locale_shortMonths)}requote(t){return t.replace(this.requoteRe,"\\$&")}localDate(t){if(0<=t.y&&t.y<100){const e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}utcDate(t){if(0<=t.y&&t.y<100){const e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}newDate(t,e,u){return{y:t,m:e,d:u,H:0,M:0,S:0,L:0}}formatRe(t){return new RegExp("^(?:"+t.map(this.requoteF).join("|")+")","i")}formatLookup(t){return new Map(t.map(((t,e)=>[t.toLowerCase(),e])))}pad(t,e,u){const n=t<0?"-":"",r=(n?-t:t)+"",i=r.length;return n+(i<u?new Array(u-i+1).join(e)+r:r)}parseSpecifier(t,e,u,n){let r=0;const i=e.length,s=u.length;let o,D;for(;r<i;){if(n>=s)return-1;if(o=e.charCodeAt(r++),37===o){if(o=e.charAt(r++),D=this.parses[o in this.pads?e.charAt(r++):o],!D||(n=D(t,u,n))<0)return-1}else if(o!==u.charCodeAt(n++))return-1}return n}newParse(t,e){const u=this;return function(n){const r=u.newDate(1900,void 0,1);return u.parseSpecifier(r,t,n+="",0)!==n.length?null:"Q"in r?new Date(r.Q):"s"in r?new Date(1e3*r.s+("L"in r?r.L:0)):(e&&!("Z"in r)&&(r.Z=0),"p"in r&&(r.H=r.H%12+12*r.p),void 0===r.m&&(r.m="q"in r?r.q:0),"Z"in r?(r.H+=r.Z/100|0,r.M+=r.Z%100,u.utcDate(r)):u.localDate(r))}}newFormat(t,e){const u=this;return function(n){const r=[];let i=-1,s=0;const o=t.length;let D,a,h;for(n instanceof Date||(n=new Date(+n));++i<o;)37===t.charCodeAt(i)&&(r.push(t.slice(s,i)),(a=u.pads[D=t.charAt(++i)])?D=t.charAt(++i):a="e"===D?" ":"0",h=e[D],D=h(n,a),r.push(D),s=i+1);return r.push(t.slice(s,i)),r.join("")}}getFullTimeStamp(t){const e=parseInt(t+"",10);return 10===String(e).length?1e3*e:e}}function ln(t,e){const u=e?t.toExponential(e-1):t.toExponential(),n=u.indexOf("e");if(n<0)return null;const r=u.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+u.slice(n+1)]}let cn;function fn(t,e){const u=ln(t,e);if(!u)return t+"";const n=u[0],r=u[1];return r<0?"0."+new Array(-r).join("0")+n:n.length>r+1?n.slice(0,r+1)+"."+n.slice(r+1):n+new Array(r-n.length+2).join("0")}class Fn{constructor(t={}){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}toString(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type}}const dn=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function gn(t){let e;if(e=dn.exec(t))return new Fn({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]});qe.getInstance().error("invalid format: "+t)}const mn=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];class Cn{constructor(){var t,e;this.locale={thousands:",",grouping:[3],currency:["$",""]},this.group=void 0===this.locale.grouping||void 0===this.locale.thousands?t=>t:(t=[...this.locale.grouping].map(Number),e=`${this.locale.thousands}`,function(u,n){let r=u.length;const i=[];let s=0,o=t[0],D=0;for(;r>0&&o>0&&(D+o+1>n&&(o=Math.max(1,n-D)),i.push(u.substring(r-=o,r+o)),!((D+=o+1)>n));)o=t[s=(s+1)%t.length];return i.reverse().join(e)}),this.currencyPrefix=void 0===this.locale.currency?"":this.locale.currency[0]+"",this.currencySuffix=void 0===this.locale.currency?"":this.locale.currency[1]+"",this.decimal=void 0===this.locale.decimal?".":this.locale.decimal+"",this.numerals=void 0===this.locale.numerals?t=>t:xn([...this.locale.numerals].map(String)),this.percent=void 0===this.locale.percent?"%":this.locale.percent+"",this.minus=void 0===this.locale.minus?"−":this.locale.minus+"",this.nan=void 0===this.locale.nan?"NaN":this.locale.nan+"",this.formatter=t=>this.newFormat(t),this.format=(t,e)=>this.formatter(t)(e),this.formatPrefix=(t,e)=>this._formatPrefix(t,e)}static getInstance(){return Cn.instance||(Cn.instance=new Cn),Cn.instance}newFormat(t){const e=gn(t);let u=e.fill,n=e.align;const r=e.sign,i=e.symbol;let s=e.zero;const o=e.width;let D=e.comma,a=e.precision,h=e.trim,l=e.type;"n"===l?(D=!0,l="g"):pn[l]||(void 0===a&&(a=12),h=!0,l="g"),(s||"0"===u&&"="===n)&&(s=!0,u="0",n="=");const c="$"===i?this.currencyPrefix:"#"===i&&/[boxX]/.test(l)?"0"+l.toLowerCase():"",f="$"===i?this.currencySuffix:/[%p]/.test(l)?this.percent:"",F=pn[l],d=/[defgprstz%]/.test(l);a=void 0===a?6:/[gprs]/.test(l)?Math.max(1,Math.min(21,a)):Math.max(0,Math.min(20,a));const{nan:g,minus:m,decimal:C,group:p,numerals:y}=this;function x(t){let e,i,x,E=c,M=f,B=t;if("c"===l)M=F(B)+M,B="";else{B=+B;let t=B<0||1/B<0;if(B=isNaN(B)?g:F(Math.abs(B),a),h&&(B=function(t){const e=t.length;let u,n=-1;t:for(let r=1;r<e;++r)switch(t[r]){case".":n=u=r;break;case"0":0===n&&(n=r),u=r;break;default:if(!+t[r])break t;n>0&&(n=0)}return n>0?t.slice(0,n)+t.slice(u+1):t}(B)),t&&0==+B&&"+"!==r&&(t=!1),E=(t?"("===r?r:m:"-"===r||"("===r?"":r)+E,M=("s"===l?mn[8+cn/3]:"")+M+(t&&"("===r?")":""),d)for(e=-1,i=B.length;++e<i;)if(x=B.charCodeAt(e),48>x||x>57){M=(46===x?C+B.slice(e+1):B.slice(e))+M,B=B.slice(0,e);break}}D&&!s&&(B=p(B,1/0));let b=E.length+B.length+M.length,v=b<o?new Array(o-b+1).join(u):"";switch(D&&s&&(B=p(v+B,v.length?o-M.length:1/0),v=""),n){case"<":B=E+B+M+v;break;case"=":B=E+v+B+M;break;case"^":B=v.slice(0,b=v.length>>1)+E+B+M+v.slice(b);break;default:B=v+E+B+M}return y(B)}return x.toString=function(){return t+""},x}_formatPrefix(t,e){const u=gn(t);u.type="f";const n=this.newFormat(u.toString()),r=3*Math.max(-8,Math.min(8,Math.floor(yn(e)/3))),i=Math.pow(10,-r),s=mn[8+r/3];return function(t){return n(i*t)+s}}}const pn={"%":(t,e)=>(100*t).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},f:(t,e)=>t.toFixed(e),e:(t,e)=>t.toExponential(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>fn(100*t,e),r:fn,s:function(t,e){const u=ln(t,e);if(!u)return t+"";const n=u[0],r=u[1],i=r-(cn=3*Math.max(-8,Math.min(8,Math.floor(r/3))))+1,s=n.length;return i===s?n:i>s?n+new Array(i-s+1).join("0"):i>0?n.slice(0,i)+"."+n.slice(i):"0."+new Array(1-i).join("0")+ln(t,Math.max(0,e+i-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16),t:(t,e)=>Number.isInteger(t)?t.toFixed(2):Math.floor(t*Math.pow(10,e))/Math.pow(10,e)+"",z:(t,e)=>t%1==0?t+"":t.toFixed(e)};function yn(t){const e=ln(Math.abs(t));return e?e[1]:NaN}function xn(t){return function(e){return e.replace(/[0-9]/g,(e=>t[+e]))}}function En(t){const e=new Array(t);for(let u=0;u<t;++u)e[u]=0;return e}function Mn(t,e){let u=0;for(let n=0;n<t.length;++n)u+=t[n]*e[n];return u}function Bn(t){return Math.sqrt(Mn(t,t))}function bn(t,e,u){for(let n=0;n<e.length;++n)t[n]=e[n]*u}function vn(t,e,u,n,r){for(let i=0;i<t.length;++i)t[i]=e*u[i]+n*r[i]}function An(t,e,u,n,r,i,s){const o=u.fx,D=Mn(u.fxprime,e);let a=o,h=o,l=D,c=0;function f(h,c,f){for(let F=0;F<16;++F)if(r=(h+c)/2,vn(n.x,1,u.x,r,e),a=n.fx=t(n.x,n.fxprime),l=Mn(n.fxprime,e),a>o+i*r*D||a>=f)c=r;else{if(Math.abs(l)<=-s*D)return r;l*(c-h)>=0&&(c=h),h=r,f=a}return 0}r=r||1,i=i||1e-6,s=s||.1;for(let F=0;F<10;++F){if(vn(n.x,1,u.x,r,e),a=n.fx=t(n.x,n.fxprime),l=Mn(n.fxprime,e),a>o+i*r*D||F&&a>=h)return f(c,r,h);if(Math.abs(l)<=-s*D)return r;if(l>=0)return f(r,c,a);h=a,c=r,r*=2}return r}t.AABBBounds=class extends Bt{},t.Bounds=Bt,t.Color=Wt,t.ColorUtil=Gt,t.DAY=uu,t.DEFAULT_COLORS=Ht,t.EventEmitter=n,t.FormatSpecifier=Fn,t.GraphicUtil=Te,t.HOUR=eu,t.HashTable=class{constructor(){this.items={},this.itemList=[]}get type(){return"xhHashTable"}set(t,e){const u=new tt;u.key=t,u.value=e;let n=this.itemList.length;return this.has(t)&&(n=this.items[t].index),u.index=n,this.itemList[n]=u,this.items[t]=u,u}clear(){this.items={},this.itemList=[]}del(t){if(this.has(t)){const e=this.items[t].index;e>-1&&this.itemList.splice(e,1),delete this.items[t],this.resetIndex()}}delFrom(t){for(let e=t+1;e<this.count();e++){const t=this.itemList[e].key;delete this.items[t]}this.itemList.splice(t+1,this.count()-t),this.resetIndex()}resetIndex(){this.foreachHashv(((t,e)=>{const u=this.itemList.indexOf(e);this.items[t].index=u}))}has(t){return t in this.items}get(t){return this.has(t)?this.items[t].value:null}count(){return this.itemList.length}all(){return this.itemList.map((t=>t.value))}first(){return this.itemList[0].value}last(){return this.itemList[this.itemList.length-1].value}getByIndex(t){return this.itemList[t].value}getKeyByIndex(t){return this.itemList[t].key}foreach(t){for(const e in this.items){if(!1===t(e,this.items[e].value))return!1}return!0}foreachHashv(t){for(const e in this.items){if(!1===t(e,this.items[e]))return!1}return!0}hasValue(t){for(const e in this.items)if(this.items[e].value===t)return!0;return!1}indexOf(t){return this.has(t)?this.items[t].index:-1}insertAt(t,e,u){const n=new tt;n.index=t,n.key=u,n.value=e,this.itemList.splice(t,0,n),this.items[u]=n,this.resetIndex()}sort(t){return this.itemList.sort(((e,u)=>t(e.value,u.value)))}toArray(){return this.itemList.slice(0,this.itemList.length).map((t=>t.value))}push(t){t.foreach(((t,e)=>{this.set(t,e)}))}mapKey(){const t=[];for(const e in this.items)t.push(e);return t}toImmutableMap(){}},t.HashValue=tt,t.LRU=class{constructor(){this.CLEAN_THRESHOLD=1e3,this.L_TIME=1e3,this.R_COUNT=1,this.R_TIMESTAMP_MAX_SIZE=20}clearCache(t,e){const{CLEAN_THRESHOLD:u=this.CLEAN_THRESHOLD,L_TIME:n=this.L_TIME,R_COUNT:r=this.R_COUNT}=e;if(t.size<u)return 0;let i=0;const s=e=>{i++,t.delete(e)},o=Date.now();return t.forEach(((t,e)=>{if(t.timestamp.length<r)return s(e);let u=0;for(;o-t.timestamp[t.timestamp.length-1-u]<n&&(u++,!(u>=r)););if(u<r)return s(e);for(;o-t.timestamp[0]>n;)t.timestamp.shift()})),i}addLimitedTimestamp(t,e,u){const{R_TIMESTAMP_MAX_SIZE:n=this.R_TIMESTAMP_MAX_SIZE}=u;t.timestamp.length>n&&t.timestamp.shift(),t.timestamp.push(e)}clearTimeStamp(t,e){const{L_TIME:u=this.L_TIME}=e,n=Date.now();t.forEach((t=>{for(;n-t.timestamp[0]>u;)t.timestamp.shift()}))}clearItemTimestamp(t,e){const{L_TIME:u=this.L_TIME}=e,n=Date.now();for(;n-t.timestamp[0]>u;)t.timestamp.shift()}},t.Logger=qe,t.MINUTE=tu,t.MONTH=26784e5,t.Matrix=_t,t.NEWTON_ITERATIONS=4,t.NEWTON_MIN_SLOPE=.001,t.NumberUtil=Cn,t.OBBBounds=class extends Bt{},t.Point=yt,t.PointService=xt,t.PolarPoint=Et,t.RGB=jt,t.SECOND=Ke,t.SMALL=rn,t.SUBDIVISION_MAX_ITERATIONS=10,t.SUBDIVISION_PRECISION=1e-7,t.TextMeasure=We,t.TimeUtil=hn,t.YEAR=31536e6,t.abs=st,t.acos=function(t){return t>1?0:t<-1?ut:Math.acos(t)},t.array=L,t.arrayEqual=function(t,e){if(!f(t)||!f(e))return!1;if(t.length!==e.length)return!1;for(let u=0;u<t.length;u++)if(t[u]!==e[u])return!1;return!0},t.ascending=k,t.asin=function(t){return t>=1?nt:t<=-1?-nt:Math.asin(t)},t.atan2=ot,t.bisect=function(t,e,u=0,n){for(o(n)&&(n=t.length);u<n;){const r=u+n>>>1;k(t[r],e)>0?n=r:u=r+1}return u},t.circleArea=on,t.circleCircleIntersection=Dn,t.circleOverlap=function(t,e,u){if(u>=t+e)return 0;if(u<=Math.abs(t-e))return Math.PI*Math.min(t,e)*Math.min(t,e);const n=e-(u*u-t*t+e*e)/(2*u);return on(t,t-(u*u-e*e+t*t)/(2*u))+on(e,n)},t.clamp=G,t.clampAngleByDegree=Tt,t.clampAngleByRadian=wt,t.clampDegree=St,t.clampRadian=At,t.clampRange=(t,e,u)=>{let[n,r]=t;r<n&&(n=t[1],r=t[0]);const i=r-n;return i>=u-e?[e,u]:(n=Math.min(Math.max(n,e),u-i),[n,n+i])},t.clamper=function(t,e){let u;return t>e&&(u=t,t=e,e=u),u=>Math.max(t,Math.min(e,u))},t.clone=function(t,e=!1,u=0,n=void 0){const r=[],i=[];return void 0===e&&(e=!0),void 0===u&&(u=1/0),function t(u,s){if(null===u)return null;if(0===s)return u;let o;if("object"!=typeof u)return u;if(f(u)?o=[]:C(u)?(o=new RegExp(u.source,function(t){let e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),e}(u)),u.lastIndex&&(o.lastIndex=u.lastIndex)):o=d(u)?new Date(u.getTime()):void 0===n?Object.create(Object.getPrototypeOf(u)):Object.create(n),e){const t=r.indexOf(u);if(-1!==t)return i[t];r.push(u),i.push(o)}for(const e in u)o[e]=t(u[e],s-1);return o}(t,u)},t.cloneDeep=function t(e){let u;if(!D(e)||"object"!=typeof e)return e;const n=f(e),r=e.length;u=n?new Array(r):"object"==typeof e?{}:i(e)||g(e)||c(e)?e:d(e)?new Date(+e):void 0;const s=n?void 0:Object.keys(Object(e));let o=-1;if(u)for(;++o<(s||e).length;){const n=s?s[o]:o,r=e[n];u[n]=t(r)}return u},t.conjugateGradient=function(t,e,u){let n={x:e.slice(),fx:0,fxprime:e.slice()},r={x:e.slice(),fx:0,fxprime:e.slice()};const i=e.slice();let s,o=1;const D=(u=u||{}).maxIterations||20*e.length;n.fx=t(n.x,n.fxprime);const a=n.fxprime.slice();bn(a,n.fxprime,-1);for(let e=0;e<D;++e){if(o=An(t,a,n,r,o),u.history&&u.history.push({x:n.x.slice(),fx:n.fx,fxprime:n.fxprime.slice(),alpha:o}),o){vn(i,1,r.fxprime,-1,n.fxprime);const t=Mn(n.fxprime,n.fxprime);vn(a,Math.max(0,Mn(i,r.fxprime)/t),a,-1,r.fxprime),s=n,n=r,r=s}else bn(a,n.fxprime,-1);if(Bn(n.fxprime)<=1e-5)break}return u.history&&u.history.push({x:n.x.slice(),fx:n.fx,fxprime:n.fxprime.slice(),alpha:o}),n},t.constant=t=>s(t)?t:()=>t,t.containedInCircles=sn,t.cos=Dt,t.crossProduct=dt,t.crossProductPoint=gt,t.dateGetterName=$e,t.dateSetterName=function(t){return t?"setUTCDate":"setDate"},t.dayCount=xu,t.dayField=Eu,t.dayFloor=pu,t.dayOffset=yu,t.debounce=$,t.defaults=_,t.degreeToRadian=bt,t.destination=function(t,e,u,n={}){const r=bt(t[0]),i=bt(t[1]),s=bt(u),o=function(t,e){void 0===e&&(e="kilometers");var u=nn[e];if(!u)throw new Error(e+" units is invalid");return t/u}(e,n.units),D=Math.asin(Math.sin(i)*Math.cos(o)+Math.cos(i)*Math.sin(o)*Math.cos(s));return{x:vt(r+Math.atan2(Math.sin(s)*Math.sin(o)*Math.cos(i),Math.cos(o)-Math.sin(i)*Math.sin(D))),y:vt(D)}},t.deviation=function(t,e){const u=O(t,e);return u?Math.sqrt(u):u},t.dot=Mn,t.eastAsianCharacterInfo=Ie,t.epsilon=et,t.exponent=yn,t.findZeroOfFunction=function(t,e,u,n){const r=(n=n||{}).maxIterations||100,i=n.tolerance||1e-10,s=t(e),o=t(u);let D=u-e;if(s*o>0)throw"Initial bisect points must have opposite signs";if(0===s)return e;if(0===o)return u;for(let u=0;u<r;++u){D/=2;const u=e+D,n=t(u);if(n*s>=0&&(e=u),Math.abs(D)<i||0===n)return u}return e+D},t.fixPrecision=Ct,t.flattenArray=function t(e){if(!f(e))return[e];const u=[];for(const n of e)u.push(...t(n));return u},t.formatNumerals=xn,t.formatSpecifier=gn,t.formatTypes=pn,t.fullYearGetterName=Ge,t.fullYearSetterName=function(t){return t?"setUTCFullYear":"setFullYear"},t.fuzzyEqualNumber=function(t,e){return st(t-e)<et},t.fuzzyEqualVec=mt,t.gemv=function(t,e,u){for(let n=0;n<t.length;++n)t[n]=Mn(e[n],u)},t.generateCeil=Ju,t.generateCount=Qu,t.generateStepInterval=(t,{floor:e,offset:u,field:n,count:r})=>{const i=Math.floor(t);if(!Number.isFinite(i)||i<=0)return null;if(i<=1)return{floor:e,offset:u,ceil:Ju(e,u)};const s=Qu(e,r),o=n?t=>n(t)%i==0:t=>s(0,t)%i==0,D=t=>{if(!Number.isNaN(+t))for(e(t);!o(t);)t.setTime(+t-1),e(t);return t},a=(t,e)=>{if(!Number.isNaN(+t))if(i<0)for(;++e<=0;)for(u(t,-1);!o(t);)u(t,-1);else for(;--e>=0;)for(u(t,1);!o(t);)u(t,1);return t};return{floor:D,offset:a,ceil:Ju(D,a)}},t.get=(t,e,u)=>{const n=c(e)?e.split("."):e;for(let e=0;e<n.length;e++)t=t?t[n[e]]:void 0;return void 0===t?u:t},t.getAABBFromPoints=function(t){return he=1/0,le=1/0,ce=-1/0,fe=-1/0,t.forEach((t=>{he>t.x&&(he=t.x),ce<t.x&&(ce=t.x),le>t.y&&(le=t.y),fe<t.y&&(fe=t.y)})),{x1:he,y1:le,x2:ce,y2:fe}},t.getAngleByPoint=function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)},t.getCenter=an,t.getContainerSize=function(t,e=0,u=0){if(!t)return{width:e,height:u};let n;try{n=null===window||void 0===window?void 0:window.getComputedStyle}catch(t){n=()=>({})}const r=n(t);if(/^(\d*\.?\d+)(px)$/.exec(r.width)){const n=parseFloat(r.width)-parseFloat(r.paddingLeft)-parseFloat(r.paddingRight)||t.clientWidth-1,i=parseFloat(r.height)-parseFloat(r.paddingTop)-parseFloat(r.paddingBottom)||t.clientHeight-1;return{width:n<=0?e:n,height:i<=0?u:i}}return{width:e,height:u}},t.getContextFont=Pe,t.getDecimalPlaces=pt,t.getElementAbsolutePosition=Ku,t.getElementRelativePosition=function(t,e){const u=Ku(t),n=Ku(e);return{x:u.x-n.x,y:u.y-n.y}},t.getFormatFromValue=function(t,e){const u=K(t),n=u[Ve(e)]()+1,r=u[$e(e)](),i=u[Xe(e)](),s=u[Ze(e)](),o=u[Je(e)](),D=0===u[Qe(e)](),a=D&&0===o,h=a&&0===s,l=h&&0===i,c=l&&1===r;return c&&1===n?"YYYY":c?"YYYY-MM":l?"YYYY-MM-DD":h?"HH":a?"HH:mm":D?"HH:mm:ss":"HH:mm:ss SSS"},t.getIntersectPoint=function(t,e,u,n){if(!ue(t,e,u,n))return!1;const r=[0,0],i=[0,0],s=[0,0];if(Vt(r,e,t),Vt(i,n,u),mt(r,i))return!0;Vt(s,u,t);const o=dt(s,i)/dt(r,i);return o>=0&&o<=1&&[t[0]+r[0]*o,t[1]+r[1]*o]},t.getIntervalOptions=(t,e)=>"year"===t&&e?{floor:ou,offset:Du,count:au,field:hu}:"month"===t&&e?{floor:du,offset:gu,count:mu,field:Cu}:"day"===t&&e?{floor:Mu,offset:Bu,count:bu,field:vu}:"hour"===t&&e?{floor:_u,offset:Lu,count:Su,field:Nu}:"minute"===t&&e?{floor:Iu,offset:Ru,count:Hu,field:Pu}:"second"===t&&e?{floor:qu,offset:Gu,count:Yu,field:Vu}:"year"===t?{floor:nu,offset:ru,count:iu,field:su}:"month"===t?{floor:lu,offset:cu,count:fu,field:Fu}:"day"===t?{floor:pu,offset:yu,count:xu,field:Eu}:"hour"===t?{floor:Au,offset:wu,count:Su,field:Tu}:"minute"===t?{floor:ku,offset:Uu,count:Hu,field:Ou}:"second"===t?{floor:Wu,offset:ju,count:Yu,field:zu}:{floor:$u,offset:Xu,count:Zu},t.getOBBFromLine=function(t,e,u){return Fe=e.x-t.x,de=e.y-t.y,ge=de,me=-Fe,ye=Ce=Math.sqrt(ge*ge+me*me),xe=u,ge/=Ce,me/=Ce,pe=u/2,Fe=pe*ge,de=pe*me,{point1:{x:t.x+Fe,y:t.y+de},point2:{x:t.x-Fe,y:t.y-de},point3:{x:e.x+Fe,y:e.y+de},point4:{x:e.x-Fe,y:e.y-de},width:ye,height:xe,left:Math.min(t.x,e.x)-Math.abs(Fe),top:Math.min(t.y,e.y)-Math.abs(de)}},t.getRectIntersect=function(t,e,u){return null===t?e:null===e?t:($t=t.x1,Xt=t.x2,Zt=t.y1,Jt=t.y2,Qt=e.x1,Kt=e.x2,te=e.y1,ee=e.y2,u&&($t>Xt&&([$t,Xt]=[Xt,$t]),Zt>Jt&&([Zt,Jt]=[Jt,Zt]),Qt>Kt&&([Qt,Kt]=[Kt,Qt]),te>ee&&([te,ee]=[ee,te])),$t>=Kt||Xt<=Qt||Zt>=ee||Jt<=te?{x1:0,y1:0,x2:0,y2:0}:{x1:Math.max($t,Qt),y1:Math.max(Zt,te),x2:Math.min(Xt,Kt),y2:Math.min(Jt,ee)})},t.getScale=t=>t.offsetWidth>0?tn(t):en(t),t.getScaleX=tn,t.getScaleY=en,t.getScrollLeft=t=>{var e,u,n;return t===(null===(e=null===globalThis||void 0===globalThis?void 0:globalThis.document)||void 0===e?void 0:e.body)?(null===(n=null===(u=null===globalThis||void 0===globalThis?void 0:globalThis.document)||void 0===u?void 0:u.documentElement)||void 0===n?void 0:n.scrollLeft)||t.scrollLeft:"html"===t.tagName.toLowerCase()?0:t.scrollLeft},t.getScrollTop=t=>{var e,u,n;return t===(null===(e=null===globalThis||void 0===globalThis?void 0:globalThis.document)||void 0===e?void 0:e.body)?(null===(n=null===(u=null===globalThis||void 0===globalThis?void 0:globalThis.document)||void 0===u?void 0:u.documentElement)||void 0===n?void 0:n.scrollTop)||t.scrollTop:"html"===t.tagName.toLowerCase()?0:t.scrollTop},t.getTimeFormatter=function(t,e){return u=>{const n=K(u),r=n[Ge(e)](),i=n[Ve(e)]()+1,s=Math.floor((i-1)/3)+1,o=n[$e(e)](),D=n["get"+(e?"UTC":"")+"Day"](),a=n[Xe(e)](),h=(a-1)%12+1,l=n[Ze(e)](),c=n[Je(e)](),f=n[Qe(e)]();return(t||"").replace(/YYYY/g,q(r+"",4,"0","left")).replace(/yyyy/g,r+"").replace(/yy/g,r%100+"").replace(/Q/g,s+"").replace(/MM/g,q(i,2,"0","left")).replace(/M/g,i+"").replace(/dd/g,q(o,2,"0","left")).replace(/d/g,o+"").replace(/e/g,D+"").replace(/HH/g,q(a,2,"0","left")).replace(/H/g,a+"").replace(/hh/g,q(h+"",2,"0","left")).replace(/h/g,h+"").replace(/mm/g,q(l,2,"0","left")).replace(/m/g,l+"").replace(/ss/g,q(c,2,"0","left")).replace(/s/g,c+"").replace(/SSS/g,q(f,3,"0","left")).replace(/S/g,f+"")}},t.halfPi=nt,t.has=(t,e)=>null!=t&&x.call(t,e),t.hasParentElement=function(t,e){let u=t.parentNode;for(;null!==u;){if(u===e)return!0;u=u.parentNode}return!1},t.hexToRgb=Yt,t.hourCount=Su,t.hourField=Tu,t.hourFloor=Au,t.hourOffset=wu,t.hoursGetterName=Xe,t.hoursSetterName=function(t){return t?"setUTCHours":"setHours"},t.hslToRgb=Lt,t.interpolateDate=function(t,e){const u=t.valueOf(),n=e.valueOf(),r=new Date;return t=>(r.setTime(u*(1-t)+n*t),r)},t.interpolateNumber=X,t.interpolateNumberRound=function(t,e){return function(u){return Math.round(t*(1-u)+e*u)}},t.interpolateRgb=qt,t.interpolateString=function(t,e){let u,n,r,i=Z.lastIndex=J.lastIndex=0,s=-1;const o=[],D=[];for(t+="",e+="";(u=Z.exec(t))&&(n=J.exec(e));)(r=n.index)>i&&(r=e.slice(i,r),o[s]?o[s]+=r:o[++s]=r),(u=u[0])===(n=n[0])?o[s]?o[s]+=n:o[++s]=n:(o[++s]=null,D.push({i:s,x:X(u,n)})),i=J.lastIndex;return i<e.length&&(r=e.slice(i),o[s]?o[s]+=r:o[++s]=r),o.length<2?D[0]?function(t){return function(e){return t(e)+""}}(D[0].x):function(t){return function(){return t}}(e):(e=D.length,function(t){for(let u,n=0;n<e;++n)o[(u=D[n]).i]=u.x(t);return o.join("")})},t.intersectionArea=function(t,e){const u=function(t){const e=[];for(let u=0;u<t.length;++u)for(let n=u+1;n<t.length;++n){const r=Dn(t[u],t[n]);for(let t=0;t<r.length;++t){const i=r[t];i.parentIndex=[u,n],e.push(i)}}return e}(t),n=u.filter((function(e){return sn(e,t)}));let r=0,i=0;const s=[];if(n.length>1){const e=an(n);for(let t=0;t<n.length;++t){const u=n[t];u.angle=Math.atan2(u.x-e.x,u.y-e.y)}n.sort((function(t,e){return e.angle-t.angle}));let u=n[n.length-1];for(let e=0;e<n.length;++e){const o=n[e];i+=(u.x+o.x)*(o.y-u.y);const D={x:(o.x+u.x)/2,y:(o.y+u.y)/2};let a=null;for(let e=0;e<o.parentIndex.length;++e)if(u.parentIndex.indexOf(o.parentIndex[e])>-1){const n=t[o.parentIndex[e]],r=Math.atan2(o.x-n.x,o.y-n.y),i=Math.atan2(u.x-n.x,u.y-n.y);let s=i-r;s<0&&(s+=2*Math.PI);const h=i-s/2;let l=xt.distancePP(D,{x:n.x+n.radius*Math.sin(h),y:n.y+n.radius*Math.cos(h)});l>2*n.radius&&(l=2*n.radius),(null===a||a.width>l)&&(a={circle:n,width:l,p1:o,p2:u})}null!==a&&(s.push(a),r+=on(a.circle.radius,a.width),u=o)}}else{let e=t[0];for(let u=1;u<t.length;++u)t[u].radius<e.radius&&(e=t[u]);let u=!1;for(let n=0;n<t.length;++n)if(xt.distancePP(t[n],e)>Math.abs(e.radius-t[n].radius)){u=!0;break}u?r=i=0:(r=e.radius*e.radius*Math.PI,s.push({circle:e,p1:{x:e.x,y:e.y+e.radius},p2:{x:e.x-rn,y:e.y+e.radius},width:2*e.radius}))}return i/=2,e&&(e.area=r+i,e.arcArea=r,e.polygonArea=i,e.arcs=s,e.innerPoints=n,e.intersectionPoints=u),r+i},t.isArray=f,t.isArrayLike=F,t.isBase64=t=>new RegExp(/^data:image\/(?:gif|png|jpeg|bmp|webp|svg\+xml)(?:;charset=utf-8)?;base64,(?:[A-Za-z0-9]|[+/])+={0,2}/g).test(t),t.isBoolean=i,t.isDate=d,t.isEmpty=function(t){if(o(t))return!0;if(F(t))return!t.length;const e=(t=>({}.toString.call(t).replace(/^\[object /,"").replace(/]$/,"")))(t);if("Map"===e||"Set"===e)return!t.size;if(function(t){const e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||p)}(t))return!Object.keys(t).length;for(const e in t)if(y.call(t,e))return!1;return!0},t.isEqual=function t(e,u,n){if(e===u)return!0;if(typeof e!=typeof u)return!1;if(null==e||null==u)return!1;if(Number.isNaN(e)&&Number.isNaN(u))return!0;if(v(e)!==v(u))return!1;if(s(e))return!!(null==n?void 0:n.skipFunction);if("object"!=typeof e)return!1;if(f(e)){if(e.length!==u.length)return!1;for(let r=e.length-1;r>=0;r--)if(!t(e[r],u[r],n))return!1;return!0}if(!l(e))return!1;const r=A(e),i=A(u);if(r.length!==i.length)return!1;r.sort(),i.sort();for(let t=r.length-1;t>=0;t--)if(r[t]!=i[t])return!1;for(let i=r.length-1;i>=0;i--){const s=r[i];if(!t(e[s],u[s],n))return!1}return!0},t.isFunction=s,t.isGreater=function(t,e,u,n){return t>e&&!Y(t,e,u,n)},t.isIntersect=ue,t.isLess=function(t,e,u,n){return t<e&&!Y(t,e,u,n)},t.isNil=o,t.isNull=t=>null===t,t.isNumber=g,t.isNumberClose=Y,t.isNumeric=t=>"string"==typeof t&&(!isNaN(Number(t))&&!isNaN(parseFloat(t))),t.isObject=a,t.isObjectLike=h,t.isPlainObject=l,t.isPointInLine=ke,t.isPointInPolygon=function(t,e){if(!t)return!1;if(!e)return!1;const u="Feature"===(n=e).type?n.geometry:n;var n;const r=u.type,i=e.bbox;let s=u.coordinates;if(i&&!0===re(t,{x1:i[0],x2:i[1],y1:i[1],y2:i[3]},!0))return!1;"Polygon"===r&&(s=[s]);let o=!1;for(let e=0;e<s.length;++e)for(let u=0;u<s[e].length;++u){if(Ne(s[e][u].map((t=>({x:t[0],y:t[1]}))),t.x,t.y))return o=!0,o}return o},t.isRectIntersect=function(t,e,u){return!t||!e||(u?($t=t.x1,Xt=t.x2,Zt=t.y1,Jt=t.y2,Qt=e.x1,Kt=e.x2,te=e.y1,ee=e.y2,$t>Xt&&([$t,Xt]=[Xt,$t]),Zt>Jt&&([Zt,Jt]=[Jt,Zt]),Qt>Kt&&([Qt,Kt]=[Kt,Qt]),te>ee&&([te,ee]=[ee,te]),!($t>Kt||Xt<Qt||Zt>ee||Jt<te)):!(t.x1>e.x2||t.x2<e.x1||t.y1>e.y2||t.y2<e.y1))},t.isRegExp=C,t.isRotateAABBIntersect=function(t,e,u=!1,n){const r=ae(t,u),i=ae(e,u),s=(t,e)=>[e.x-t.x,e.y-t.y];n&&(n.save(),n.fillStyle="red",n.globalAlpha=.6,r.forEach(((t,e)=>{0===e?n.moveTo(t.x,t.y):n.lineTo(t.x,t.y)})),n.fill(),n.restore(),n.save(),n.fillStyle="green",n.globalAlpha=.6,i.forEach(((t,e)=>{0===e?n.moveTo(t.x,t.y):n.lineTo(t.x,t.y)})),n.fill(),n.restore());const o=De(t),D=De(e);n&&n.fillRect(o.x,o.y,2,2),n&&n.fillRect(D.x,D.y,2,2);const a=s(o,D),h=s(r[0],r[1]),l=s(r[1],r[2]),c=s(i[0],i[1]),f=s(i[1],i[2]),F=u?t.angle:oe(t.angle);let d=u?t.angle+nt:oe(90-t.angle);const g=u?e.angle:oe(e.angle);let m=u?e.angle+nt:oe(90-e.angle);d>it&&(d-=it),m>it&&(m-=it);const C=(t,e,u,n)=>{const r=[Math.cos(e),Math.sin(e)];return t+(ie(r,u)+ie(r,n))/2>ie(r,a)};return C((t.x2-t.x1)/2,F,c,f)&&C((t.y2-t.y1)/2,d,c,f)&&C((e.x2-e.x1)/2,g,h,l)&&C((e.y2-e.y1)/2,m,h,l)},t.isShallowEqual=function(t,e){if(w(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;if(f(t)!==f(e))return!1;if(S(t)!==S(e))return!1;let u=!0;return Object.keys(t).forEach((n=>!!w(t[n],e[n])||(u=!1,u))),u},t.isString=c,t.isType=r,t.isUndefined=t=>void 0===t,t.isValid=D,t.isValidNumber=m,t.isValidUrl=t=>new RegExp(/^(http(s)?:\/\/)\w+[^\s]+(\.[^\s]+){1,}$/).test(t),t.keys=T,t.last=N,t.lengthFromPointToLine=Ft,t.lineIntersectPolygon=Le,t.lowerFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)},t.max=at,t.maxInArray=(t,e)=>{var u;if(0===t.length)return;let n=t[0];for(let r=1;r<t.length;r++){const i=t[r];(null!==(u=null==e?void 0:e(i,n))&&void 0!==u?u:i-n>0)&&(n=i)}return n},t.median=(t,e)=>{let u=t;return!0!==e&&(u=t.sort(k)),H(u,.5)},t.memoize=t=>{let e=null,u=null;return(...n)=>(e&&n.every(((t,u)=>t===e[u]))||(e=n,u=t(...n)),u)},t.merge=function(t,...e){let u=-1;const n=e.length;for(;++u<n;){E(t,e[u],!0)}return t},t.mergeAABB=function(t){const e=[];return function t(u,n){const r=[];n.forEach((t=>{let e;(e=Ee(u,t)).length>1?r.push(t):u=e[0]})),e.push(u),r.length&&t(r[0],r.slice(1))}(t[0],t.slice(1)),e},t.millisecondsCount=Zu,t.millisecondsFloor=$u,t.millisecondsGetterName=Qe,t.millisecondsOffset=Xu,t.millisecondsSetterName=function(t){return t?"setUTCMilliseconds":"setMilliseconds"},t.min=ht,t.minInArray=(t,e)=>{var u;if(0===t.length)return;let n=t[0];for(let r=1;r<t.length;r++){const i=t[r];(null!==(u=null==e?void 0:e(i,n))&&void 0!==u?u:i-n<0)&&(n=i)}return n},t.minuteCount=Hu,t.minuteField=Ou,t.minuteFloor=ku,t.minuteOffset=Uu,t.minutesGetterName=Ze,t.minutesSetterName=function(t){return t?"setUTCMinutes":"setMinutes"},t.mixin=function(t,e,u=!0){if(t="prototype"in t?t.prototype:t,e="prototype"in e?e.prototype:e,Object.getOwnPropertyNames){const n=Object.getOwnPropertyNames(e);for(let r=0;r<n.length;r++){const i=n[r];"constructor"!==i&&(u?null!=e[i]:null==t[i])&&(t[i]=e[i])}}else _(t,e,u)},t.monthCount=fu,t.monthField=Fu,t.monthFloor=lu,t.monthGetterName=Ve,t.monthOffset=cu,t.monthSetterName=function(t){return t?"setUTCMonth":"setMonth"},t.nelderMead=function(t,e,u){const n=(u=u||{}).maxIterations||200*e.length,r=u.nonZeroDelta||1.05,i=u.zeroDelta||.001,s=u.minErrorDelta||1e-6,o=u.minErrorDelta||1e-5,D=void 0!==u.rho?u.rho:1,a=void 0!==u.chi?u.chi:2,h=void 0!==u.psi?u.psi:-.5,l=void 0!==u.sigma?u.sigma:.5;let c;const f=e.length,F=new Array(f+1);F[0]=e,F[0].fx=t(e),F[0].id=0;for(let u=0;u<f;++u){const n=e.slice();n[u]=n[u]?n[u]*r:i,F[u+1]=n,F[u+1].fx=t(n),F[u+1].id=u+1}function d(t){for(let e=0;e<t.length;e++)F[f][e]=t[e];F[f].fx=t.fx}const g=function(t,e){return t.fx-e.fx},m=e.slice(),C=e.slice(),p=e.slice(),y=e.slice();for(let e=0;e<n;++e){if(F.sort(g),u.history){const t=F.map((function(t){const e=t.slice();return e.fx=t.fx,e.id=t.id,e}));t.sort((function(t,e){return t.id-e.id})),u.history.push({x:F[0].slice(),fx:F[0].fx,simplex:t})}c=0;for(let t=0;t<f;++t)c=Math.max(c,Math.abs(F[0][t]-F[1][t]));if(Math.abs(F[0].fx-F[f].fx)<s&&c<o)break;for(let t=0;t<f;++t){m[t]=0;for(let e=0;e<f;++e)m[t]+=F[e][t];m[t]/=f}const e=F[f];if(vn(C,1+D,m,-D,e),C.fx=t(C),C.fx<F[0].fx)vn(y,1+a,m,-a,e),y.fx=t(y),y.fx<C.fx?d(y):d(C);else if(C.fx>=F[f-1].fx){let u=!1;if(C.fx>e.fx?(vn(p,1+h,m,-h,e),p.fx=t(p),p.fx<e.fx?d(p):u=!0):(vn(p,1-h*D,m,h*D,e),p.fx=t(p),p.fx<C.fx?d(p):u=!0),u){if(l>=1)break;for(let e=1;e<F.length;++e)vn(F[e],1-l,F[0],l,F[e]),F[e].fx=t(F[e])}}else d(C)}return F.sort(g),{fx:F[0].fx,x:F[0]}},t.norm2=Bn,t.normalTransform=function(t,e,u,n,r,i,s,o){const D=e.a,a=e.b,h=e.c,l=e.d,c=e.e,f=e.f,F=Dt(s),d=lt(s);let g,m;o?(g=o[0],m=o[1]):(g=u,m=n);const C=g-u,p=m-n,y=D*F+h*d,x=a*F+l*d,E=h*F-D*d,M=l*F-a*d;t.a=r*y,t.b=r*x,t.c=i*E,t.d=i*M,t.e=c+D*g+h*m-y*C-E*p,t.f=f+a*g+l*m-x*C-M*p},t.normalizePadding=function(t){if(m(t))return[t,t,t,t];if(f(t)){const e=t.length;if(1===e){const e=t[0];return[e,e,e,e]}if(2===e){const[e,u]=t;return[e,u,e,u]}if(3===e){const[e,u,n]=t;return[e,u,n,u]}if(4===e)return t}if(a(t)){const{top:e=0,right:u=0,bottom:n=0,left:r=0}=t;return[e,u,n,r]}return[0,0,0,0]},t.numberSpecifierReg=dn,t.pad=q,t.parseUint8ToImageData=(t,e,u)=>{const n=new Uint8ClampedArray(t),r=new Uint8ClampedArray(t.length);for(let t=u-1;t>=0;t--)for(let i=0;i<e;i++){const s=t*e*4+4*i,o=(u-t)*e*4+4*i;r[o]=n[s],r[o+1]=n[s+1],r[o+2]=n[s+2],r[o+3]=n[s+3]}return new ImageData(r,e,u)},t.pi=ut,t.pi2=it,t.pick=function(t,e){if(!t||!l(t))return t;const u={};return e.forEach((e=>{b.call(t,e)&&(u[e]=t[e])})),u},t.pickWithout=function(t,e){if(!t||!l(t))return t;const u={};return Object.keys(t).forEach((n=>{const r=t[n];let i=!1;e.forEach((t=>{(c(t)&&t===n||t instanceof RegExp&&n.match(t))&&(i=!0)})),i||(u[n]=r)})),u},t.pointAt=function(t,e,u,n,r){let i,s;return"number"==typeof t&&"number"==typeof u&&(i=(1-r)*t+r*u),"number"==typeof e&&"number"==typeof n&&(s=(1-r)*e+r*n),{x:i,y:s}},t.pointBetweenLine=Se,t.pointInAABB=function(t,e){return re(t,e,!1)},t.pointInLine=be,t.pointInOBB=function(t,e){return Me.x=(e.point1.x+e.point2.x)/2,Me.y=(e.point1.y+e.point2.y)/2,Be.x=(e.point3.x+e.point4.x)/2,Be.y=(e.point3.y+e.point4.y)/2,be(t,Me,Be,e.height)},t.pointInRect=re,t.polarToCartesian=function(t,e,u){return{x:t.x+e*Math.cos(u),y:t.y+e*Math.sin(u)}},t.polygonContainPoint=Ne,t.polygonIntersectPolygon=function(t,e){for(let u=0;u<e.length;u++){if(Ne(t,e[u].x,e[u].y))return!0;if(u>0&&Le(e[u-1].x,e[u-1].y,e[u].x,e[u].y,t))return!0}return!1},t.pow=ft,t.precisionAdd=function(t,e){return Ct(t+e,10**Math.max(pt(t),pt(e)))},t.precisionSub=function(t,e){return Ct(t-e,10**Math.max(pt(t),pt(e)))},t.quantileSorted=H,t.radianToDegree=vt,t.range=function(t,e,u){D(e)||(e=t,t=0),D(u)||(u=1);let n=-1;const r=0|Math.max(0,Math.ceil((e-t)/u)),i=new Array(r);for(;++n<r;)i[n]=t+n*u;return i},t.rectInsideAnotherRect=function(e,u,n){return e&&u?($t=e.x1,Xt=e.x2,Zt=e.y1,Jt=e.y2,Qt=u.x1,Kt=u.x2,te=u.y1,ee=u.y2,n&&($t>Xt&&([$t,Xt]=[Xt,$t]),Zt>Jt&&([Zt,Jt]=[Jt,Zt]),Qt>Kt&&([Qt,Kt]=[Kt,Qt]),te>ee&&([te,ee]=[ee,te])),$t>Qt&&Xt<Kt&&Zt>te&&Jt<ee?t.InnerBBox.BBOX1:Qt>$t&&Kt<Xt&&te>Zt&&ee<Jt?t.InnerBBox.BBOX2:t.InnerBBox.NONE):t.InnerBBox.NONE},t.rgbToHex=zt,t.rgbToHsl=Nt,t.scale=bn,t.secondCount=Yu,t.secondField=zu,t.secondFloor=Wu,t.secondOffset=ju,t.secondsGetterName=Je,t.secondsSetterName=function(t){return t?"setUTCSeconds":"setSeconds"},t.shuffleArray=function(t,e=Math.random){let u,n,r=t.length;for(;r;)u=Math.floor(e()*r),n=t[--r],t[r]=t[u],t[u]=n;return t},t.sin=lt,t.span=t=>t.length<=1?0:N(t)-t[0],t.sqrt=ct,t.stringWidth=function(t,e=!0){if("string"!=typeof t||0===t.length)return 0;if(0===(t=He(t)).length)return 0;t=t.replace(Re()," ");const u=e?1:2;let n=0;for(const e of t){const t=e.codePointAt(0);if(t<=31||t>=127&&t<=159)continue;if(t>=768&&t<=879)continue;switch(Ie(e)){case"F":case"W":n+=2;break;case"A":n+=u;break;default:n+=1}}return n},t.substitute=function(t,e){return t&&e?t.replace(/\\?\{([^{}]+)\}/g,((t,u)=>"\\"===t.charAt(0)?t.slice(1):void 0===e[u]?"":e[u])):t},t.tau=rt,t.throttle=function(t,e,u){let n=!0,r=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return a(u)&&(n="leading"in u?!!u.leading:n,r="trailing"in u?!!u.trailing:r),$(t,e,{leading:n,trailing:r,maxWait:e})},t.tickStep=function(t,e,u){const n=Math.abs(e-t)/Math.max(0,u);let r=Math.pow(10,Math.floor(Math.log(n)/Math.LN10));const i=n/r;return i>=I?r*=10:i>=R?r*=5:i>=P&&(r*=2),e<t?-r:r},t.toDate=K,t.toNumber=U,t.toValidNumber=function(t){if(m(t))return t;const e=+t;return m(e)?e:0},t.transformBounds=function(t,e,u,n,r,i,s){if(!(st(n)<=et||st(r)<=et)){if(1!==n&&t.scaleX(n),1!==r&&t.scaleY(r),isFinite(i)&&Math.abs(i)>et){let e=0,u=0;void 0!==s&&(e=s[0],u=s[1]),t.rotate(i,e,u)}t.translate(e,u)}},t.transformBoundsWithMatrix=Mt,t.truncate=(t,e,u="right",n)=>{const r=o(n)?"…":n,i=t+"",s=i.length,D=Math.max(0,e-r.length);return s<=e?i:"left"===u?r+i.slice(s-D):"center"===u?i.slice(0,Math.ceil(D/2))+r+i.slice(s-Math.floor(D/2)):i.slice(0,D)+r},t.unionAABB=Ee,t.uniqArray=function(t){return t&&f(t)?Array.from(new Set(L(t))):t},t.upperFirst=function(t){return t.charAt(0).toUpperCase()+t.substring(1)},t.utcDayCount=bu,t.utcDayField=vu,t.utcDayFloor=Mu,t.utcDayOffset=Bu,t.utcHourField=Nu,t.utcHourFloor=_u,t.utcHourOffset=Lu,t.utcMinuteField=Pu,t.utcMinuteFloor=Iu,t.utcMinuteOffset=Ru,t.utcMonthCount=mu,t.utcMonthField=Cu,t.utcMonthFloor=du,t.utcMonthOffset=gu,t.utcSecondField=Vu,t.utcSecondFloor=qu,t.utcSecondOffset=Gu,t.utcYearCount=au,t.utcYearField=hu,t.utcYearFloor=ou,t.utcYearOffset=Du,t.uuid=(t,e)=>{const u="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),n=[];let r;if(e=e||u.length,t)for(r=0;r<t;r++)n[r]=u[0|Math.random()*e];else{let t;for(n[8]=n[13]=n[18]=n[23]="-",n[14]="4",r=0;r<36;r++)n[r]||(t=0|16*Math.random(),n[r]=u[19===r?3&t|8:t])}return n.join("")},t.variance=O,t.weightedSum=vn,t.yearCount=iu,t.yearField=su,t.yearFloor=nu,t.yearOffset=ru,t.zeros=En,t.zerosM=function(t,e){return En(t).map((function(){return En(e)}))}}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).VUtils={})}(this,(function(t){"use strict";function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var u={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,u="~";function n(){}function r(t,e,u){this.fn=t,this.context=e,this.once=u||!1}function i(t,e,n,i,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new r(n,i||t,s),D=u?u+e:e;return t._events[D]?t._events[D].fn?t._events[D]=[t._events[D],o]:t._events[D].push(o):(t._events[D]=o,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new n:delete t._events[e]}function o(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(u=!1)),o.prototype.eventNames=function(){var t,n,r=[];if(0===this._eventsCount)return r;for(n in t=this._events)e.call(t,n)&&r.push(u?n.slice(1):n);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},o.prototype.listeners=function(t){var e=u?u+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var r=0,i=n.length,s=new Array(i);r<i;r++)s[r]=n[r].fn;return s},o.prototype.listenerCount=function(t){var e=u?u+t:t,n=this._events[e];return n?n.fn?1:n.length:0},o.prototype.emit=function(t,e,n,r,i,s){var o=u?u+t:t;if(!this._events[o])return!1;var D,a,h=this._events[o],l=arguments.length;if(h.fn){switch(h.once&&this.removeListener(t,h.fn,void 0,!0),l){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,e),!0;case 3:return h.fn.call(h.context,e,n),!0;case 4:return h.fn.call(h.context,e,n,r),!0;case 5:return h.fn.call(h.context,e,n,r,i),!0;case 6:return h.fn.call(h.context,e,n,r,i,s),!0}for(a=1,D=new Array(l-1);a<l;a++)D[a-1]=arguments[a];h.fn.apply(h.context,D)}else{var c,f=h.length;for(a=0;a<f;a++)switch(h[a].once&&this.removeListener(t,h[a].fn,void 0,!0),l){case 1:h[a].fn.call(h[a].context);break;case 2:h[a].fn.call(h[a].context,e);break;case 3:h[a].fn.call(h[a].context,e,n);break;case 4:h[a].fn.call(h[a].context,e,n,r);break;default:if(!D)for(c=1,D=new Array(l-1);c<l;c++)D[c-1]=arguments[c];h[a].fn.apply(h[a].context,D)}}return!0},o.prototype.on=function(t,e,u){return i(this,t,e,u,!1)},o.prototype.once=function(t,e,u){return i(this,t,e,u,!0)},o.prototype.removeListener=function(t,e,n,r){var i=u?u+t:t;if(!this._events[i])return this;if(!e)return s(this,i),this;var o=this._events[i];if(o.fn)o.fn!==e||r&&!o.once||n&&o.context!==n||s(this,i);else{for(var D=0,a=[],h=o.length;D<h;D++)(o[D].fn!==e||r&&!o[D].once||n&&o[D].context!==n)&&a.push(o[D]);a.length?this._events[i]=1===a.length?a[0]:a:s(this,i)}return this},o.prototype.removeAllListeners=function(t){var e;return t?(e=u?u+t:t,this._events[e]&&s(this,e)):(this._events=new n,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=u,o.EventEmitter=o,t.exports=o}(u);var n=e(u.exports);const r=(t,e)=>Object.prototype.toString.call(t)===`[object ${e}]`,i=(t,e=!1)=>e?"boolean"==typeof t:!0===t||!1===t||r(t,"Boolean"),s=t=>"function"==typeof t,o=t=>null==t,D=t=>null!=t,a=t=>{const e=typeof t;return null!==t&&"object"===e||"function"===e},h=t=>"object"==typeof t&&null!==t,l=function(t){if(!h(t)||!r(t,"Object"))return!1;if(null===Object.getPrototypeOf(t))return!0;let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e},c=(t,e=!1)=>{const u=typeof t;return e?"string"===u:"string"===u||r(t,"String")},f=t=>Array.isArray?Array.isArray(t):r(t,"Array"),F=function(t){return null!==t&&"function"!=typeof t&&Number.isFinite(t.length)},d=t=>r(t,"Date"),g=(t,e=!1)=>{const u=typeof t;return e?"number"===u:"number"===u||r(t,"Number")},m=t=>g(t)&&Number.isFinite(t),C=t=>r(t,"RegExp"),p=Object.prototype,y=Object.prototype.hasOwnProperty;const x=Object.prototype.hasOwnProperty;function E(t,e,u=!1){if(e){if(t===e)return;if(D(e)&&"object"==typeof e){const n=Object(e),r=[];for(const t in n)r.push(t);let{length:i}=r,s=-1;for(;i--;){const i=r[++s];D(n[i])&&"object"==typeof n[i]?M(t,e,i,u):B(t,i,n[i])}}}}function M(t,e,u,n=!1){const r=t[u],i=e[u];let s=e[u],o=!0;if(f(i)){if(n)s=[];else if(f(r))s=r;else if(F(r)){s=new Array(r.length);let t=-1;const e=r.length;for(;++t<e;)s[t]=r[t]}}else l(i)?(s=r,"function"!=typeof r&&"object"==typeof r||(s={})):o=!1;o&&E(s,i,n),B(t,u,s)}function B(t,e,u){(void 0!==u&&!function(t,e){return t===e||Number.isNaN(t)&&Number.isNaN(e)}(t[e],u)||void 0===u&&!(e in t))&&(t[e]=u)}const b=Object.prototype.hasOwnProperty;function v(t){return Object.prototype.toString.call(t)}function A(t){return Object.keys(t)}function w(t,e){return t===e?0!==t||0!==e||1/t==1/e:t!=t&&e!=e}function S(t){return f(t)?t.length:a(t)?Object.keys(t).length:0}function T(t){if(!t)return[];if(Object.keys)return Object.keys(t);const e=[];for(const u in t)t.hasOwnProperty(u)&&e.push(u);return e}function _(t,e,u){const n=T(e);for(let r=0;r<n.length;r++){const i=n[r];(u?null!=e[i]:null==t[i])&&(t[i]=e[i])}return t}function L(t){return D(t)?f(t)?t:[t]:[]}function N(t){if(F(t)){return t[t.length-1]}}function k(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function U(t){return Number(t)}function H(t,e,u=U){const n=t.length;if(!n)return;if(e<=0||n<2)return u(t[0],0,t);if(e>=1)return u(t[n-1],n-1,t);const r=(n-1)*e,i=Math.floor(r),s=u(t[i],i,t);return s+(u(t[i+1],i+1,t)-s)*(r-i)}function O(t,e){let u,n=0,r=0,i=0;if(void 0===e)for(let e of t)null!=e&&(e=+e)>=e&&(u=e-r,r+=u/++n,i+=u*(e-r));else{let s=-1;for(let o of t)null!=(o=e(o,++s,t))&&(o=+o)>=o&&(u=o-r,r+=u/++n,i+=u*(o-r))}return n>1?i/(n-1):0}const I=Math.sqrt(50),R=Math.sqrt(10),P=Math.sqrt(2);const W=1e-10,j=1e-10;function Y(t,e,u=j,n=W){const r=n,i=u*Math.max(t,e);return Math.abs(t-e)<=Math.max(r,i)}const z=(t,e=0)=>{let u="",n=e-1;for(;n>=0;)u=`${u}${t}`,n-=1;return u},q=(t,e,u=" ",n="right")=>{const r=u,i=t+"",s=e-i.length;return s<=0?i:"left"===n?z(r,s)+i:"center"===n?z(r,Math.floor(s/2))+i+z(r,Math.ceil(s/2)):i+z(r,s)},G=function(t,e,u){return t<e?e:t>u?u:t};let V=!1;try{V="function"==typeof requestAnimationFrame&&"function"==typeof cancelAnimationFrame}catch(t){V=!1}function $(t,e,u){let n,r,i,s,o,D,h=0,l=!1,c=!1,f=!0;const F=!e&&0!==e&&V;if("function"!=typeof t)throw new TypeError("Expected a function");function d(e){const u=n,i=r;return n=r=void 0,h=e,s=t.apply(i,u),s}function g(t,e){return F?(cancelAnimationFrame(o),requestAnimationFrame(t)):setTimeout(t,e)}function C(t){const u=t-D;return void 0===D||u>=e||u<0||c&&t-h>=i}function p(){const t=Date.now();if(C(t))return y(t);o=g(p,function(t){const u=t-h,n=e-(t-D);return c?Math.min(n,i-u):n}(t))}function y(t){return o=void 0,f&&n?d(t):(n=r=void 0,s)}function x(...t){const u=Date.now(),i=C(u);if(n=t,r=this,D=u,i){if(void 0===o)return function(t){return h=t,o=g(p,e),l?d(t):s}(D);if(c)return o=g(p,e),d(D)}return void 0===o&&(o=g(p,e)),s}return e=+e||0,a(u)&&(l=!!u.leading,c="maxWait"in u,c&&(i=Math.max(m(u.maxWait)?u.maxWait:0,e)),f="trailing"in u?!!u.trailing:f),x.cancel=function(){void 0!==o&&function(t){if(F)return cancelAnimationFrame(t);clearTimeout(t)}(o),h=0,n=D=r=o=void 0},x.flush=function(){return void 0===o?s:y(Date.now())},x.pending=function(){return void 0!==o},x}function X(t,e){return u=>t*(1-u)+e*u}V=!1;const Z=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,J=new RegExp(Z.source,"g");const Q=/^(?:(\d{4})(?:[-\/](\d{1,2})(?:[-\/](\d{1,2})(?:[T ](\d{1,2})(?::(\d{1,2})(?::(\d{1,2})(?:[.,](\d+))?)?)?(Z|[\+\-]\d\d:?\d\d)?)?)?)?)?$/;function K(t){if(t instanceof Date)return t;if(c(t)){const e=Q.exec(t);if(!e)return new Date(NaN);if(!e[8])return new Date(+e[1],+(e[2]||1)-1,+e[3]||1,+e[4]||0,+(e[5]||0),+e[6]||0,e[7]?+e[7].substring(0,3):0);let u=+e[4]||0;return"Z"!==e[8].toUpperCase()&&(u-=+e[8].slice(0,3)),new Date(Date.UTC(+e[1],+(e[2]||1)-1,+e[3]||1,u,+(e[5]||0),+e[6]||0,e[7]?+e[7].substring(0,3):0))}return o(t)?new Date(NaN):new Date(Math.round(t))}class tt{}const et=1e-12,ut=Math.PI,nt=ut/2,rt=2*ut,it=2*Math.PI,st=Math.abs,ot=Math.atan2,Dt=Math.cos,at=Math.max,ht=Math.min,lt=Math.sin,ct=Math.sqrt,ft=Math.pow;function Ft(t,e,u){const n=u.x-e.x,r=u.y-e.y,i=t.x-e.x,s=t.y-e.y;return Math.abs(n*s-i*r)/Math.sqrt(n*n+r*r)}function dt(t,e){return t[0]*e[1]-t[1]*e[0]}function gt(t,e){return t.x*e.y-t.y*e.x}function mt(t,e){let u=0;for(let n=0;n<t.length;++n)u+=t[n]*e[n];return u}function Ct(t,e){return st(t[0]-e[0])+st(t[1]-e[1])<et}function pt(t,e=10){return Math.round(t*e)/e}function yt(t){const e=t.toString().split(/[eE]/),u=(e[0].split(".")[1]||"").length-(+e[1]||0);return u>0?u:0}class xt{constructor(t=0,e=0,u,n){this.x=0,this.y=0,this.x=t,this.y=e,this.x1=u,this.y1=n}clone(){return new xt(this.x,this.y)}copyFrom(t){return this.x=t.x,this.y=t.y,this.x1=t.x1,this.y1=t.y1,this.defined=t.defined,this.context=t.context,this}set(t,e){return this.x=t,this.y=e,this}add(t){return g(t)?(this.x+=t,void(this.y+=t)):(this.x+=t.x,this.y+=t.y,this)}sub(t){return g(t)?(this.x-=t,void(this.y-=t)):(this.x-=t.x,this.y-=t.y,this)}multi(t){throw new Error("暂不支持")}div(t){throw new Error("暂不支持")}}class Et{static distancePP(t,e){return ct(ft(t.x-e.x,2)+ft(t.y-e.y,2))}static distanceNN(t,e,u,n){return ct(ft(t-u,2)+ft(e-n,2))}static distancePN(t,e,u){return ct(ft(e-t.x,2)+ft(u-t.y,2))}static pointAtPP(t,e,u){return new xt((e.x-t.x)*u+t.x,(e.y-t.y)*u+t.y)}}class Mt{constructor(t=0,e=0,u,n){this.r=0,this.theta=0,this.r=t,this.theta=e,this.r1=u,this.theta1=n}clone(){return new Mt(this.r,this.theta)}copyFrom(t){return this.r=t.r,this.theta=t.theta,this.r1=t.r1,this.theta1=t.theta1,this.defined=t.defined,this.context=t.context,this}set(t,e){return this.r=t,this.theta=e,this}}function Bt(t,e,u){const{x1:n,y1:r,x2:i,y2:s}=e;return u.onlyTranslate()?(t!==e&&t.setValue(e.x1,e.y1,e.x2,e.y2),t.translate(u.e,u.f),e):(t.clear(),t.add(u.a*n+u.c*r+u.e,u.b*n+u.d*r+u.f),t.add(u.a*i+u.c*r+u.e,u.b*i+u.d*r+u.f),t.add(u.a*i+u.c*s+u.e,u.b*i+u.d*s+u.f),t.add(u.a*n+u.c*s+u.e,u.b*n+u.d*s+u.f),e)}class bt{constructor(t){t?this.setValue(t.x1,t.y1,t.x2,t.y2):this.clear()}clone(){return new bt(this)}clear(){return this.x1=+Number.MAX_VALUE,this.y1=+Number.MAX_VALUE,this.x2=-Number.MAX_VALUE,this.y2=-Number.MAX_VALUE,this}empty(){return this.x1===+Number.MAX_VALUE&&this.y1===+Number.MAX_VALUE&&this.x2===-Number.MAX_VALUE&&this.y2===-Number.MAX_VALUE}equals(t){return this.x1===t.x1&&this.y1===t.y1&&this.x2===t.x2&&this.y2===t.y2}setValue(t=0,e=0,u=0,n=0){return this.x1=t,this.y1=e,this.x2=u,this.y2=n,this}set(t=0,e=0,u=0,n=0){return u<t?(this.x2=t,this.x1=u):(this.x1=t,this.x2=u),n<e?(this.y2=e,this.y1=n):(this.y1=e,this.y2=n),this}add(t=0,e=0){return t<this.x1&&(this.x1=t),e<this.y1&&(this.y1=e),t>this.x2&&(this.x2=t),e>this.y2&&(this.y2=e),this}expand(t=0){return f(t)?(this.y1-=t[0],this.x2+=t[1],this.y2+=t[2],this.x1-=t[3]):(this.x1-=t,this.y1-=t,this.x2+=t,this.y2+=t),this}round(){return this.x1=Math.floor(this.x1),this.y1=Math.floor(this.y1),this.x2=Math.ceil(this.x2),this.y2=Math.ceil(this.y2),this}translate(t=0,e=0){return this.x1+=t,this.x2+=t,this.y1+=e,this.y2+=e,this}rotate(t=0,e=0,u=0){const n=this.rotatedPoints(t,e,u);return this.clear().add(n[0],n[1]).add(n[2],n[3]).add(n[4],n[5]).add(n[6],n[7])}scale(t=0,e=0,u=0,n=0){const r=this.scalePoints(t,e,u,n);return this.clear().add(r[0],r[1]).add(r[2],r[3])}union(t){return t.x1<this.x1&&(this.x1=t.x1),t.y1<this.y1&&(this.y1=t.y1),t.x2>this.x2&&(this.x2=t.x2),t.y2>this.y2&&(this.y2=t.y2),this}intersect(t){return t.x1>this.x1&&(this.x1=t.x1),t.y1>this.y1&&(this.y1=t.y1),t.x2<this.x2&&(this.x2=t.x2),t.y2<this.y2&&(this.y2=t.y2),this}encloses(t){return t&&this.x1<=t.x1&&this.x2>=t.x2&&this.y1<=t.y1&&this.y2>=t.y2}alignsWith(t){return t&&(this.x1===t.x1||this.x2===t.x2||this.y1===t.y1||this.y2===t.y2)}intersects(t){return t&&!(this.x2<t.x1||this.x1>t.x2||this.y2<t.y1||this.y1>t.y2)}contains(t=0,e=0){return!(t<this.x1||t>this.x2||e<this.y1||e>this.y2)}containsPoint(t){return!(t.x<this.x1||t.x>this.x2||t.y<this.y1||t.y>this.y2)}width(){return this.empty()?0:this.x2-this.x1}height(){return this.empty()?0:this.y2-this.y1}scaleX(t=0){return this.x1*=t,this.x2*=t,this}scaleY(t=0){return this.y1*=t,this.y2*=t,this}transformWithMatrix(t){return Bt(this,this,t),this}copy(t){return this.x1=t.x1,this.y1=t.y1,this.x2=t.x2,this.y2=t.y2,this}rotatedPoints(t,e,u){const{x1:n,y1:r,x2:i,y2:s}=this,o=Math.cos(t),D=Math.sin(t),a=e-e*o+u*D,h=u-e*D-u*o;return[o*n-D*r+a,D*n+o*r+h,o*n-D*s+a,D*n+o*s+h,o*i-D*r+a,D*i+o*r+h,o*i-D*s+a,D*i+o*s+h]}scalePoints(t,e,u,n){const{x1:r,y1:i,x2:s,y2:o}=this;return[t*r+(1-t)*u,e*i+(1-e)*n,t*s+(1-t)*u,e*o+(1-e)*n]}}function vt(t){return t*(Math.PI/180)}function At(t){return 180*t/Math.PI}const wt=(t=0)=>{if(t<0)for(;t<-rt;)t+=rt;else if(t>0)for(;t>rt;)t-=rt;return t},St=wt,Tt=(t=0)=>t>360||t<-360?t%360:t,_t=Tt;class Lt{constructor(t=1,e=0,u=0,n=1,r=0,i=0){this.a=t,this.b=e,this.c=u,this.d=n,this.e=r,this.f=i}equalToMatrix(t){return!(this.e!==t.e||this.f!==t.f||this.a!==t.a||this.d!==t.d||this.b!==t.b||this.c!==t.c)}equalTo(t,e,u,n,r,i){return!(this.e!==r||this.f!==i||this.a!==t||this.d!==n||this.b!==e||this.c!==u)}setValue(t,e,u,n,r,i){return this.a=t,this.b=e,this.c=u,this.d=n,this.e=r,this.f=i,this}reset(){return this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,this}getInverse(){const t=this.a,e=this.b,u=this.c,n=this.d,r=this.e,i=this.f,s=new Lt,o=t*n-e*u;return s.a=n/o,s.b=-e/o,s.c=-u/o,s.d=t/o,s.e=(u*i-n*r)/o,s.f=-(t*i-e*r)/o,s}rotate(t){const e=Math.cos(t),u=Math.sin(t),n=this.a*e+this.c*u,r=this.b*e+this.d*u,i=this.a*-u+this.c*e,s=this.b*-u+this.d*e;return this.a=n,this.b=r,this.c=i,this.d=s,this}rotateByCenter(t,e,u){const n=Math.cos(t),r=Math.sin(t),i=(1-n)*e+r*u,s=(1-n)*u-r*e,o=n*this.a-r*this.b,D=r*this.a+n*this.b,a=n*this.c-r*this.d,h=r*this.c+n*this.d,l=n*this.e-r*this.f+i,c=r*this.e+n*this.f+s;return this.a=o,this.b=D,this.c=a,this.d=h,this.e=l,this.f=c,this}scale(t,e){return this.a*=t,this.b*=t,this.c*=e,this.d*=e,this}setScale(t,e){return this.b=this.b/this.a*t,this.c=this.c/this.d*e,this.a=t,this.d=e,this}transform(t,e,u,n,r,i){return this.multiply(t,e,u,n,r,i),this}translate(t,e){return this.e+=this.a*t+this.c*e,this.f+=this.b*t+this.d*e,this}transpose(){const{a:t,b:e,c:u,d:n,e:r,f:i}=this;return this.a=e,this.b=t,this.c=n,this.d=u,this.e=i,this.f=r,this}multiply(t,e,u,n,r,i){const s=this.a,o=this.b,D=this.c,a=this.d,h=s*t+D*e,l=o*t+a*e,c=s*u+D*n,f=o*u+a*n,F=s*r+D*i+this.e,d=o*r+a*i+this.f;return this.a=h,this.b=l,this.c=c,this.d=f,this.e=F,this.f=d,this}interpolate(t,e){const u=new Lt;return u.a=this.a+(t.a-this.a)*e,u.b=this.b+(t.b-this.b)*e,u.c=this.c+(t.c-this.c)*e,u.d=this.d+(t.d-this.d)*e,u.e=this.e+(t.e-this.e)*e,u.f=this.f+(t.f-this.f)*e,u}transformPoint(t,e){const{a:u,b:n,c:r,d:i,e:s,f:o}=this,D=u*i-n*r,a=i/D,h=-n/D,l=-r/D,c=u/D,f=(r*o-i*s)/D,F=-(u*o-n*s)/D,{x:d,y:g}=t;e.x=d*a+g*l+f,e.y=d*h+g*c+F}onlyTranslate(t=1){return this.a===t&&0===this.b&&0===this.c&&this.d===t}clone(){return new Lt(this.a,this.b,this.c,this.d,this.e,this.f)}toTransformAttrs(){const t=this.a,e=this.b,u=this.c,n=this.d,r=t*n-e*u,i={x:this.e,y:this.f,rotateDeg:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!==t||0!==e){const s=Math.sqrt(t*t+e*e);i.rotateDeg=e>0?Math.acos(t/s):-Math.acos(t/s),i.scaleX=s,i.scaleY=r/s,i.skewX=(t*u+e*n)/r,i.skewY=0}else if(0!==u||0!==n){const s=Math.sqrt(u*u+n*n);i.rotateDeg=Math.PI/2-(n>0?Math.acos(-u/s):-Math.acos(u/s)),i.scaleX=r/s,i.scaleY=s,i.skewX=0,i.skewY=(t*u+e*n)/r}return i.rotateDeg=At(i.rotateDeg),i}}function Nt(t,e,u){e/=100,u/=100;const n=(1-Math.abs(2*u-1))*e,r=n*(1-Math.abs(t/60%2-1)),i=u-n/2;let s=0,o=0,D=0;return 0<=t&&t<60?(s=n,o=r,D=0):60<=t&&t<120?(s=r,o=n,D=0):120<=t&&t<180?(s=0,o=n,D=r):180<=t&&t<240?(s=0,o=r,D=n):240<=t&&t<300?(s=r,o=0,D=n):300<=t&&t<360&&(s=n,o=0,D=r),s=Math.round(255*(s+i)),o=Math.round(255*(o+i)),D=Math.round(255*(D+i)),{r:s,g:o,b:D}}function kt(t,e,u){t/=255,e/=255,u/=255;const n=Math.min(t,e,u),r=Math.max(t,e,u),i=r-n;let s=0,o=0,D=0;return s=0===i?0:r===t?(e-u)/i%6:r===e?(u-t)/i+2:(t-e)/i+4,s=Math.round(60*s),s<0&&(s+=360),D=(r+n)/2,o=0===i?0:i/(1-Math.abs(2*D-1)),o=+(100*o).toFixed(1),D=+(100*D).toFixed(1),{h:s,s:o,l:D}}const Ut=/^#([0-9a-f]{3,8})$/,Ht={transparent:4294967040},Ot={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function It(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function Rt(t){return g(t)?new Yt(t>>16,t>>8&255,255&t,1):f(t)?new Yt(t[0],t[1],t[2]):new Yt(255,255,255)}function Pt(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Wt(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}class jt{static Brighter(t,e=1){return 1===e?t:new jt(t).brighter(e).toRGBA()}static SetOpacity(t,e=1){return 1===e?t:new jt(t).setOpacity(e).toRGBA()}static getColorBrightness(t,e="hsl"){const u=t instanceof jt?t:new jt(t);switch(e){case"hsv":default:return u.getHSVBrightness();case"hsl":return u.getHSLBrightness();case"lum":return u.getLuminance();case"lum2":return u.getLuminance2();case"lum3":return u.getLuminance3()}}static parseColorString(t){if(D(Ht[t]))return function(t){return g(t)?new Yt(t>>>24,t>>>16&255,t>>>8&255,255&t):f(t)?new Yt(t[0],t[1],t[2],t[3]):new Yt(255,255,255,1)}(Ht[t]);if(D(Ot[t]))return Rt(Ot[t]);const e=`${t}`.trim().toLowerCase(),u=Ut.exec(e);if(u){const t=parseInt(u[1],16),e=u[1].length;return 3===e?new Yt((t>>8&15)+((t>>8&15)<<4),(t>>4&15)+((t>>4&15)<<4),(15&t)+((15&t)<<4),1):6===e?Rt(t):8===e?new Yt(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):void 0}if(/^(rgb|RGB|rgba|RGBA)/.test(e)){const t=e.replace(/(?:\(|\)|rgba|RGBA|rgb|RGB)*/g,"").split(",");return new Yt(parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10),parseFloat(t[3]))}if(/^(hsl|HSL|hsla|HSLA)/.test(e)){const t=e.replace(/(?:\(|\)|hsla|HSLA|hsl|HSL)*/g,"").split(","),u=Nt(parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10));return new Yt(u.r,u.g,u.b,parseFloat(t[3]))}}constructor(t){const e=jt.parseColorString(t);e?this.color=e:(console.warn(`Warn: 传入${t}无法解析为Color`),this.color=new Yt(255,255,255))}toRGBA(){return this.color.formatRgb()}toString(){return this.color.formatRgb()}toHex(){return this.color.formatHex()}toHsl(){return this.color.formatHsl()}brighter(t){const{r:e,g:u,b:n}=this.color;return this.color.r=Math.max(0,Math.min(255,Math.floor(e*t))),this.color.g=Math.max(0,Math.min(255,Math.floor(u*t))),this.color.b=Math.max(0,Math.min(255,Math.floor(n*t))),this}add(t){const{r:e,g:u,b:n}=this.color;return this.color.r+=Math.min(255,e+t.color.r),this.color.g+=Math.min(255,u+t.color.g),this.color.b+=Math.min(255,n+t.color.b),this}sub(t){return this.color.r=Math.max(0,this.color.r-t.color.r),this.color.g=Math.max(0,this.color.g-t.color.g),this.color.b=Math.max(0,this.color.b-t.color.b),this}multiply(t){const{r:e,g:u,b:n}=this.color;return this.color.r=Math.max(0,Math.min(255,Math.floor(e*t.color.r))),this.color.g=Math.max(0,Math.min(255,Math.floor(u*t.color.g))),this.color.b=Math.max(0,Math.min(255,Math.floor(n*t.color.b))),this}getHSVBrightness(){return Math.max(this.color.r,this.color.g,this.color.b)/255}getHSLBrightness(){return.5*(Math.max(this.color.r,this.color.g,this.color.b)/255+Math.min(this.color.r,this.color.g,this.color.b)/255)}setHsl(t,e,u){const n=this.color.opacity,r=kt(this.color.r,this.color.g,this.color.b),i=Nt(o(t)?r.h:G(t,0,360),o(e)?r.s:e>=0&&e<=1?100*e:e,o(u)?r.l:u<=1&&u>=0?100*u:u);return this.color=new Yt(i.r,i.g,i.b,n),this}setRGB(t,e,u){return!o(t)&&(this.color.r=t),!o(e)&&(this.color.g=e),!o(u)&&(this.color.b=u),this}setHex(t){const e=`${t}`.trim().toLowerCase(),u=Ut.exec(e),n=parseInt(u[1],16),r=u[1].length;return 3===r?new Yt((n>>8&15)+((n>>8&15)<<4),(n>>4&15)+((n>>4&15)<<4),(15&n)+((15&n)<<4),1):6===r?Rt(n):8===r?new Yt(n>>24&255,n>>16&255,n>>8&255,(255&n)/255):this}setColorName(t){const e=Ot[t.toLowerCase()];return void 0!==e?this.setHex(e):console.warn("THREE.Color: Unknown color "+t),this}setScalar(t){return this.color.r=t,this.color.g=t,this.color.b=t,this}setOpacity(t=1){return this.color.opacity=t,this}getLuminance(){return(.2126*this.color.r+.7152*this.color.g+.0722*this.color.b)/255}getLuminance2(){return(.2627*this.color.r+.678*this.color.g+.0593*this.color.b)/255}getLuminance3(){return(.299*this.color.r+.587*this.color.g+.114*this.color.b)/255}clone(){return new jt(this.color.toString())}copyGammaToLinear(t,e=2){return this.color.r=Math.pow(t.color.r,e),this.color.g=Math.pow(t.color.g,e),this.color.b=Math.pow(t.color.b,e),this}copyLinearToGamma(t,e=2){const u=e>0?1/e:1;return this.color.r=Math.pow(t.color.r,u),this.color.g=Math.pow(t.color.g,u),this.color.b=Math.pow(t.color.b,u),this}convertGammaToLinear(t){return this.copyGammaToLinear(this,t),this}convertLinearToGamma(t){return this.copyLinearToGamma(this,t),this}copySRGBToLinear(t){return this.color.r=Pt(t.color.r),this.color.g=Pt(t.color.g),this.color.b=Pt(t.color.b),this}copyLinearToSRGB(t){return this.color.r=Wt(t.color.r),this.color.g=Wt(t.color.g),this.color.b=Wt(t.color.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}}class Yt{constructor(t,e,u,n){this.r=isNaN(+t)?255:Math.max(0,Math.min(255,+t)),this.g=isNaN(+e)?255:Math.max(0,Math.min(255,+e)),this.b=isNaN(+u)?255:Math.max(0,Math.min(255,+u)),D(n)?this.opacity=isNaN(+n)?1:Math.max(0,Math.min(1,+n)):this.opacity=1}formatHex(){return`#${It(this.r)+It(this.g)+It(this.b)+(1===this.opacity?"":It(255*this.opacity))}`}formatRgb(){const t=this.opacity;return`${1===t?"rgb(":"rgba("}${this.r},${this.g},${this.b}${1===t?")":`,${t})`}`}formatHsl(){const t=this.opacity,{h:e,s:u,l:n}=kt(this.r,this.g,this.b);return`${1===t?"hsl(":"hsla("}${e},${u}%,${n}%${1===t?")":`,${t})`}`}toString(){return this.formatHex()}}function zt(t){let e="",u="",n="";const r="#"===t[0]?1:0;for(let i=r;i<t.length;i++)"#"!==t[i]&&(i<r+2?e+=t[i]:i<r+4?u+=t[i]:i<r+6&&(n+=t[i]));return[parseInt(e,16),parseInt(u,16),parseInt(n,16)]}function qt(t,e,u){return Number((1<<24)+(t<<16)+(e<<8)+u).toString(16).slice(1)}function Gt(t,e){const u=t.r,n=e.r,r=t.g,i=e.g,s=t.b,o=e.b,D=t.opacity,a=e.opacity;return t=>{const e=Math.round(u*(1-t)+n*t),h=Math.round(r*(1-t)+i*t),l=Math.round(s*(1-t)+o*t);return new Yt(e,h,l,D*(1-t)+a*t)}}var Vt=Object.freeze({__proto__:null,Color:jt,DEFAULT_COLORS:Ot,RGB:Yt,hexToRgb:zt,hslToRgb:Nt,interpolateRgb:Gt,rgbToHex:qt,rgbToHsl:kt});function $t(t,e,u){t[0]=e[0]-u[0],t[1]=e[1]-u[1]}let Xt,Zt,Jt,Qt,Kt,te,ee,ue;function ne(t,e,u,n){let r,i=t[0],s=e[0],o=u[0],D=n[0];return s<i&&(r=s,s=i,i=r),D<o&&(r=D,D=o,o=r),!(s<o||D<i)&&(i=t[1],s=e[1],o=u[1],D=n[1],s<i&&(r=s,s=i,i=r),D<o&&(r=D,D=o,o=r),!(s<o||D<i))}var re;function ie(t,e,u){return!e||(u?(Xt=e.x1,Zt=e.x2,Jt=e.y1,Qt=e.y2,Xt>Zt&&([Xt,Zt]=[Zt,Xt]),Jt>Qt&&([Jt,Qt]=[Qt,Jt]),t.x>=Xt&&t.x<=Zt&&t.y>=Jt&&t.y<=Qt):t.x>=e.x1&&t.x<=e.x2&&t.y>=e.y1&&t.y<=e.y2)}function se(t,e){return Math.abs(e[0]*t[0]+e[1]*t[1])}function oe({x:t,y:e},u,n={x:0,y:0}){return{x:(t-n.x)*Math.cos(u)+(e-n.y)*Math.sin(u)+n.x,y:(t-n.x)*Math.sin(u)+(n.y-e)*Math.cos(u)+n.y}}function De(t){return t/180*Math.PI}function ae(t){return{x:(t.x1+t.x2)/2,y:(t.y1+t.y2)/2}}function he(t,e){const u=e?t.angle:De(t.angle),n=ae(t);return[oe({x:t.x1,y:t.y1},u,n),oe({x:t.x2,y:t.y1},u,n),oe({x:t.x2,y:t.y2},u,n),oe({x:t.x1,y:t.y2},u,n)]}let le,ce,fe,Fe,de,ge,me,Ce,pe,ye,xe,Ee;function Me(t,e,u=3,n=!1){let r=t.x1,i=t.x2,s=t.y1,o=t.y2,D=e.x1,a=e.x2,h=e.y1,l=e.y2;if(n){let t;r>i&&(t=r,r=i,i=t),s>o&&(t=s,s=o,o=t),D>a&&(t=D,D=a,a=t),h>l&&(t=h,h=l,l=t)}if(r>=a||i<=D||s>=l||o<=h)return[t,e];const c=(i-r+2*u)*(o-s+2*u),f=(a-D+2*u)*(l-h+2*u),F=Math.min(r,D),d=Math.min(s,h),g=Math.max(i,a),m=Math.max(o,l);return c+f>(g-F)*(m-d)?[{x1:F,x2:g,y1:d,y2:m}]:[t,e]}t.InnerBBox=void 0,(re=t.InnerBBox||(t.InnerBBox={}))[re.NONE=0]="NONE",re[re.BBOX1=1]="BBOX1",re[re.BBOX2=2]="BBOX2";const Be={x:0,y:0},be={x:0,y:0};function ve(t,e,u,n){return Ft(t,e,u)<=n/2&&Te(t,e,u)}const Ae={x:0,y:0},we={x:0,y:0},Se={x:0,y:0};function Te(t,e,u){return Ae.x=e.x-t.x,Ae.y=e.y-t.y,we.x=u.x-t.x,we.y=u.y-t.y,Se.x=e.y-u.y,Se.y=u.x-e.x,gt(Ae,Se)*gt(we,Se)<0}class _e{constructor(t){this.canvas=t,t&&(this.ctx=t.getContext("2d"))}setCanvas(t){this.canvas=t,t&&(this.ctx=t.getContext("2d"))}measureText(t){return this.canvas?this.measureTextByCanvas(t):(console.warn("[warn] no canvas, measureText might be not accurate"),this.estimate(t))}measureTextByCanvas(t){return this.ctx?(this.ctx.font=function({fontStyle:t,fontVariant:e,fontWeight:u,fontSize:n,fontFamily:r}){return(t?t+" ":"")+(e?e+" ":"")+(u?u+" ":"")+(n||12)+"px "+(r||"sans-serif")}(t),{width:this.ctx.measureText(t.text).width,height:t.fontSize}):(console.error("[error!!!]measureTextByCanvas can not be called without canvas"),{width:-1,height:t.fontSize})}estimate({text:t,fontSize:e}){let u=0,n=0;for(let e=0;e<t.length;e++)t.charCodeAt(e)<128?u++:n++;return{width:~~(.8*u*e+n*e),height:e}}static getDefaultUtils(t){return _e.instance||(_e.instance=new _e(t)),_e.instance}}const Le=1e-8;function Ne(t,e,u,n,r){for(let i=0,s=r[r.length-1];i<r.length;i++){const o=r[i];if(ne([t,e],[u,n],[o.x,o.y],[s.x,s.y]))return!0;s=o}return!1}function ke(t,e,u){let n=0,r=t[0];if(!r)return!1;for(let i=1;i<t.length;i++){const s=t[i];n+=Ue(r.x,r.y,s.x,s.y,e,u),r=s}const i=t[0];return He(r.x,i.x)&&He(r.y,i.y)||(n+=Ue(r.x,r.y,i.x,i.y,e,u)),0!==n}function Ue(t,e,u,n,r,i){if(i>e&&i>n||i<e&&i<n)return 0;if(n===e)return 0;const s=(i-e)/(n-e);let o=n<e?1:-1;1!==s&&0!==s||(o=n<e?.5:-.5);const D=s*(u-t)+t;return D===r?1/0:D>r?o:0}function He(t,e){return Math.abs(t-e)<Le}const Oe=t=>{if("string"!=typeof t)throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(Ie(),"")},Ie=({onlyFirst:t=!1}={})=>{const e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(e,t?void 0:"g")},Re=t=>{let e=t.charCodeAt(0),u=2===t.length?t.charCodeAt(1):0,n=e;return 55296<=e&&e<=56319&&56320<=u&&u<=57343&&(e&=1023,u&=1023,n=e<<10|u,n+=65536),12288===n||65281<=n&&n<=65376||65504<=n&&n<=65510?"F":8361===n||65377<=n&&n<=65470||65474<=n&&n<=65479||65482<=n&&n<=65487||65490<=n&&n<=65495||65498<=n&&n<=65500||65512<=n&&n<=65518?"H":4352<=n&&n<=4447||4515<=n&&n<=4519||4602<=n&&n<=4607||9001<=n&&n<=9002||11904<=n&&n<=11929||11931<=n&&n<=12019||12032<=n&&n<=12245||12272<=n&&n<=12283||12289<=n&&n<=12350||12353<=n&&n<=12438||12441<=n&&n<=12543||12549<=n&&n<=12589||12593<=n&&n<=12686||12688<=n&&n<=12730||12736<=n&&n<=12771||12784<=n&&n<=12830||12832<=n&&n<=12871||12880<=n&&n<=13054||13056<=n&&n<=19903||19968<=n&&n<=42124||42128<=n&&n<=42182||43360<=n&&n<=43388||44032<=n&&n<=55203||55216<=n&&n<=55238||55243<=n&&n<=55291||63744<=n&&n<=64255||65040<=n&&n<=65049||65072<=n&&n<=65106||65108<=n&&n<=65126||65128<=n&&n<=65131||110592<=n&&n<=110593||127488<=n&&n<=127490||127504<=n&&n<=127546||127552<=n&&n<=127560||127568<=n&&n<=127569||131072<=n&&n<=194367||177984<=n&&n<=196605||196608<=n&&n<=262141?"W":32<=n&&n<=126||162<=n&&n<=163||165<=n&&n<=166||172===n||175===n||10214<=n&&n<=10221||10629<=n&&n<=10630?"Na":161===n||164===n||167<=n&&n<=168||170===n||173<=n&&n<=174||176<=n&&n<=180||182<=n&&n<=186||188<=n&&n<=191||198===n||208===n||215<=n&&n<=216||222<=n&&n<=225||230===n||232<=n&&n<=234||236<=n&&n<=237||240===n||242<=n&&n<=243||247<=n&&n<=250||252===n||254===n||257===n||273===n||275===n||283===n||294<=n&&n<=295||299===n||305<=n&&n<=307||312===n||319<=n&&n<=322||324===n||328<=n&&n<=331||333===n||338<=n&&n<=339||358<=n&&n<=359||363===n||462===n||464===n||466===n||468===n||470===n||472===n||474===n||476===n||593===n||609===n||708===n||711===n||713<=n&&n<=715||717===n||720===n||728<=n&&n<=731||733===n||735===n||768<=n&&n<=879||913<=n&&n<=929||931<=n&&n<=937||945<=n&&n<=961||963<=n&&n<=969||1025===n||1040<=n&&n<=1103||1105===n||8208===n||8211<=n&&n<=8214||8216<=n&&n<=8217||8220<=n&&n<=8221||8224<=n&&n<=8226||8228<=n&&n<=8231||8240===n||8242<=n&&n<=8243||8245===n||8251===n||8254===n||8308===n||8319===n||8321<=n&&n<=8324||8364===n||8451===n||8453===n||8457===n||8467===n||8470===n||8481<=n&&n<=8482||8486===n||8491===n||8531<=n&&n<=8532||8539<=n&&n<=8542||8544<=n&&n<=8555||8560<=n&&n<=8569||8585===n||8592<=n&&n<=8601||8632<=n&&n<=8633||8658===n||8660===n||8679===n||8704===n||8706<=n&&n<=8707||8711<=n&&n<=8712||8715===n||8719===n||8721===n||8725===n||8730===n||8733<=n&&n<=8736||8739===n||8741===n||8743<=n&&n<=8748||8750===n||8756<=n&&n<=8759||8764<=n&&n<=8765||8776===n||8780===n||8786===n||8800<=n&&n<=8801||8804<=n&&n<=8807||8810<=n&&n<=8811||8814<=n&&n<=8815||8834<=n&&n<=8835||8838<=n&&n<=8839||8853===n||8857===n||8869===n||8895===n||8978===n||9312<=n&&n<=9449||9451<=n&&n<=9547||9552<=n&&n<=9587||9600<=n&&n<=9615||9618<=n&&n<=9621||9632<=n&&n<=9633||9635<=n&&n<=9641||9650<=n&&n<=9651||9654<=n&&n<=9655||9660<=n&&n<=9661||9664<=n&&n<=9665||9670<=n&&n<=9672||9675===n||9678<=n&&n<=9681||9698<=n&&n<=9701||9711===n||9733<=n&&n<=9734||9737===n||9742<=n&&n<=9743||9748<=n&&n<=9749||9756===n||9758===n||9792===n||9794===n||9824<=n&&n<=9825||9827<=n&&n<=9829||9831<=n&&n<=9834||9836<=n&&n<=9837||9839===n||9886<=n&&n<=9887||9918<=n&&n<=9919||9924<=n&&n<=9933||9935<=n&&n<=9953||9955===n||9960<=n&&n<=9983||10045===n||10071===n||10102<=n&&n<=10111||11093<=n&&n<=11097||12872<=n&&n<=12879||57344<=n&&n<=63743||65024<=n&&n<=65039||65533===n||127232<=n&&n<=127242||127248<=n&&n<=127277||127280<=n&&n<=127337||127344<=n&&n<=127386||917760<=n&&n<=917999||983040<=n&&n<=1048573||1048576<=n&&n<=1114109?"A":"N"},Pe=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26F9(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC3\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\u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C43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC2\uDECE-\uDEDB\uDEE0-\uDEE8]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;function We(t,e={}){const{fontStyle:u=e.fontStyle,fontVariant:n=e.fontVariant,fontWeight:r=e.fontWeight,fontSize:i=e.fontSize,fontFamily:s=e.fontFamily}=t;return(u?u+" ":"")+(n?n+" ":"")+(r?r+" ":"")+i+"px "+(s||"sans-serif")}class je{constructor(t,e){this._numberCharSize=null,this._fullCharSize=null,this._letterCharSize=null,this._specialCharSizeMap={},this._canvas=null,this._context=null,this._contextSaved=!1,this._notSupportCanvas=!1,this._notSupportVRender=!1,this._userSpec={},this.specialCharSet="-/: .,@%'\"~",this._option=t,this._userSpec=null!=e?e:{},this.textSpec=this._initSpec(),D(t.specialCharSet)&&(this.specialCharSet=t.specialCharSet),this._standardMethod=D(t.getTextBounds)?this.fullMeasure.bind(this):this.measureWithNaiveCanvas.bind(this)}initContext(){if(this._notSupportCanvas)return!1;if(o(this._canvas)&&(D(this._option.getCanvasForMeasure)&&(this._canvas=this._option.getCanvasForMeasure()),o(this._canvas)&&"undefined"!=typeof window&&void 0!==window.document&&globalThis&&D(globalThis.document)&&(this._canvas=globalThis.document.createElement("canvas"))),o(this._context)&&D(this._canvas)){const t=this._canvas.getContext("2d");D(t)&&(t.save(),t.font=We(this.textSpec),this._contextSaved=!0,this._context=t)}return!o(this._context)||(this._notSupportCanvas=!0,!1)}_initSpec(){var t,e,u;const{defaultFontParams:n={}}=this._option,{fontStyle:r=n.fontStyle,fontVariant:i=n.fontVariant,fontWeight:s=(null!==(t=n.fontWeight)&&void 0!==t?t:"normal"),fontSize:o=(null!==(e=n.fontSize)&&void 0!==e?e:12),fontFamily:D=(null!==(u=n.fontFamily)&&void 0!==u?u:"sans-serif"),align:a,textAlign:h=(null!=a?a:"center"),baseline:l,textBaseline:f=(null!=l?l:"middle"),ellipsis:F,limit:d}=this._userSpec;let{lineHeight:g=o}=this._userSpec;if(c(g)&&"%"===g[g.length-1]){const t=Number.parseFloat(g.substring(0,g.length-1))/100;g=o*t}return{fontStyle:r,fontVariant:i,fontFamily:D,fontSize:o,fontWeight:s,textAlign:h,textBaseline:f,ellipsis:F,limit:d,lineHeight:g}}measure(t,e){switch(e){case"vrender":case"canopus":return this.fullMeasure(t);case"canvas":return this.measureWithNaiveCanvas(t);case"simple":return this.quickMeasureWithoutCanvas(t);default:return this.quickMeasure(t)}}fullMeasure(t){if(o(t))return{width:0,height:0};if(o(this._option.getTextBounds)||!this._notSupportVRender)return this.measureWithNaiveCanvas(t);const{fontFamily:e,fontSize:u,fontWeight:n,textAlign:r,textBaseline:i,ellipsis:s,limit:D,lineHeight:a}=this.textSpec;let h;try{const o=this._option.getTextBounds({text:t,fontFamily:e,fontSize:u,fontWeight:n,textAlign:r,textBaseline:i,ellipsis:!!s,maxLineWidth:D||1/0,lineHeight:a});h={width:o.width(),height:o.height()}}catch(e){this._notSupportVRender=!0,h=this.measureWithNaiveCanvas(t)}return h}measureWithNaiveCanvas(t){return this._measureReduce(t,this._measureWithNaiveCanvas.bind(this))}_measureWithNaiveCanvas(t){var e;if(!this.initContext())return this._quickMeasureWithoutCanvas(t);const u=this._context.measureText(t),{fontSize:n,lineHeight:r}=this.textSpec;return{width:u.width,height:null!==(e=r)&&void 0!==e?e:n}}quickMeasure(t){return this._measureReduce(t,this._quickMeasure.bind(this))}_quickMeasure(t){const e={width:0,height:0};for(let u=0;u<t.length;u++){const n=t[u];let r=this._measureSpecialChar(n);o(r)&&je.NUMBERS_CHAR_SET.includes(n)&&(r=this._measureNumberChar()),o(r)&&["F","W"].includes(Re(n))&&(r=this._measureFullSizeChar()),o(r)&&(r=this._measureLetterChar()),e.width+=r.width,e.height=Math.max(e.height,r.height)}return e}quickMeasureWithoutCanvas(t){return this._measureReduce(t,this._quickMeasureWithoutCanvas.bind(this))}_quickMeasureWithoutCanvas(t){var e;const u={width:0,height:0},{fontSize:n,lineHeight:r}=this.textSpec;for(let e=0;e<t.length;e++){const r=t[e],i=["F","W"].includes(Re(r))?1:.53;u.width+=i*n}return u.height=null!==(e=r)&&void 0!==e?e:n,u}_measureReduce(t,e){var u;const{fontSize:n,lineHeight:r}=this.textSpec,i={width:0,height:0};if(o(t))return i;if(f(t)){const s=t.filter(D).map((t=>t.toString()));return 0===s.length?i:1===s.length?e(s[0]):{width:s.reduce(((t,u)=>Math.max(t,e(u).width)),0),height:s.length*((null!==(u=r)&&void 0!==u?u:n)+1)+1}}return e(t.toString())}_measureNumberChar(){if(o(this._numberCharSize)){const t=this._standardMethod(je.NUMBERS_CHAR_SET);this._numberCharSize={width:t.width/je.NUMBERS_CHAR_SET.length,height:t.height}}return this._numberCharSize}_measureFullSizeChar(){return o(this._fullCharSize)&&(this._fullCharSize=this._standardMethod(je.FULL_SIZE_CHAR)),this._fullCharSize}_measureLetterChar(){if(o(this._letterCharSize)){const t=this._standardMethod(je.ALPHABET_CHAR_SET);this._letterCharSize={width:t.width/je.ALPHABET_CHAR_SET.length,height:t.height}}return this._letterCharSize}_measureSpecialChar(t){return D(this._specialCharSizeMap[t])?this._specialCharSizeMap[t]:this.specialCharSet.includes(t)?(this._specialCharSizeMap[t]=this._standardMethod(t),this._specialCharSizeMap[t]):null}release(){D(this._canvas)&&(this._canvas=null),D(this._context)&&(this._contextSaved&&(this._context.restore(),this._contextSaved=!1),this._context=null)}}je.ALPHABET_CHAR_SET="abcdefghijklmnopqrstuvwxyz",je.NUMBERS_CHAR_SET="0123456789",je.FULL_SIZE_CHAR="字";const Ye="undefined"!=typeof console;function ze(t,e,u){const n=[e].concat([].slice.call(u));Ye&&console[t].apply(console,n)}var qe;t.LoggerLevel=void 0,(qe=t.LoggerLevel||(t.LoggerLevel={}))[qe.None=0]="None",qe[qe.Error=1]="Error",qe[qe.Warn=2]="Warn",qe[qe.Info=3]="Info",qe[qe.Debug=4]="Debug";class Ge{static getInstance(t,e){return Ge._instance&&g(t)?Ge._instance.level(t):Ge._instance||(Ge._instance=new Ge(t,e)),Ge._instance}static setInstance(t){return Ge._instance=t}static setInstanceLevel(t){Ge._instance?Ge._instance.level(t):Ge._instance=new Ge(t)}static clearInstance(){Ge._instance=null}constructor(e=t.LoggerLevel.None,u){this._onErrorHandler=[],this._level=e,this._method=u}addErrorHandler(t){this._onErrorHandler.find((e=>e===t))||this._onErrorHandler.push(t)}removeErrorHandler(t){const e=this._onErrorHandler.findIndex((e=>e===t));e<0||this._onErrorHandler.splice(e,1)}callErrorHandler(...t){this._onErrorHandler.forEach((e=>e(...t)))}canLogInfo(){return this._level>=t.LoggerLevel.Info}canLogDebug(){return this._level>=t.LoggerLevel.Debug}canLogError(){return this._level>=t.LoggerLevel.Error}canLogWarn(){return this._level>=t.LoggerLevel.Warn}level(t){return arguments.length?(this._level=+t,this):this._level}error(...e){var u;return this._level>=t.LoggerLevel.Error&&(this._onErrorHandler.length?this.callErrorHandler(...e):ze(null!==(u=this._method)&&void 0!==u?u:"error","ERROR",e)),this}warn(...e){return this._level>=t.LoggerLevel.Warn&&ze(this._method||"warn","WARN",e),this}info(...e){return this._level>=t.LoggerLevel.Info&&ze(this._method||"log","INFO",e),this}debug(...e){return this._level>=t.LoggerLevel.Debug&&ze(this._method||"log","DEBUG",e),this}}function Ve(t){return t?"getUTCFullYear":"getFullYear"}function $e(t){return t?"getUTCMonth":"getMonth"}function Xe(t){return t?"getUTCDate":"getDate"}function Ze(t){return t?"getUTCHours":"getHours"}function Je(t){return t?"getUTCMinutes":"getMinutes"}function Qe(t){return t?"getUTCSeconds":"getSeconds"}function Ke(t){return t?"getUTCMilliseconds":"getMilliseconds"}Ge._instance=null;const tu=1e3,eu=6e4,uu=36e5,nu=24*uu,ru=t=>(t.setMonth(0,1),t.setHours(0,0,0,0),t),iu=(t,e)=>(t.setFullYear(t.getFullYear()+e),t),su=(t,e)=>e.getFullYear()-t.getFullYear(),ou=t=>t.getFullYear(),Du=t=>(t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0),t),au=(t,e)=>(t.setUTCFullYear(t.getUTCFullYear()+e),t),hu=(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),lu=t=>t.getUTCFullYear(),cu=t=>(t.setDate(1),t.setHours(0,0,0,0),t),fu=(t,e)=>(t.setMonth(t.getMonth()+e),t),Fu=(t,e)=>e.getMonth()-t.getMonth()+12*(e.getFullYear()-t.getFullYear()),du=t=>t.getMonth(),gu=t=>(t.setUTCDate(1),t.setUTCHours(0,0,0,0),t),mu=(t,e)=>(t.setUTCMonth(t.getUTCMonth()+e),t),Cu=(t,e)=>e.getUTCMonth()-t.getUTCMonth()+12*(e.getUTCFullYear()-t.getUTCFullYear()),pu=t=>t.getUTCMonth(),yu=t=>(t.setHours(0,0,0,0),t),xu=(t,e)=>(t.setDate(t.getDate()+e),t),Eu=(t,e)=>(+e-+t-(e.getTimezoneOffset()-t.getTimezoneOffset())*eu)/nu,Mu=t=>t.getDate()-1,Bu=t=>(t.setUTCHours(0,0,0,0),t),bu=(t,e)=>(t.setUTCDate(t.getUTCDate()+e),t),vu=(t,e)=>(+e-+t)/nu,Au=t=>t.getUTCDate()-1,wu=t=>(t.setTime(+t-t.getMilliseconds()-t.getSeconds()*tu-t.getMinutes()*eu),t),Su=(t,e)=>(t.setHours(t.getHours()+e),t),Tu=(t,e)=>(+e-+t)/uu,_u=t=>t.getHours(),Lu=t=>(t.setTime(+t-t.getUTCMilliseconds()-t.getUTCSeconds()*tu-t.getUTCMinutes()*eu),t),Nu=(t,e)=>(t.setUTCHours(t.getUTCHours()+e),t),ku=t=>t.getUTCHours(),Uu=t=>(t.setTime(+t-t.getMilliseconds()-t.getSeconds()*tu),t),Hu=(t,e)=>(t.setMinutes(t.getMinutes()+e),t),Ou=(t,e)=>(+e-+t)/eu,Iu=t=>t.getMinutes(),Ru=t=>(t.setTime(+t-t.getUTCMilliseconds()-t.getUTCSeconds()*tu),t),Pu=(t,e)=>(t.setUTCMinutes(t.getUTCMinutes()+e),t),Wu=t=>t.getUTCMinutes(),ju=t=>(t.setTime(+t-t.getMilliseconds()),t),Yu=(t,e)=>(t.setSeconds(t.getSeconds()+e),t),zu=(t,e)=>(+e-+t)/tu,qu=t=>t.getSeconds(),Gu=t=>(t.setTime(+t-t.getUTCMilliseconds()),t),Vu=(t,e)=>(t.setUTCSeconds(t.getUTCSeconds()+e),t),$u=t=>t.getUTCSeconds(),Xu=t=>t,Zu=(t,e)=>(t.setTime(+t+e),t),Ju=(t,e)=>+e-+t,Qu=(t,e)=>u=>{const n=new Date(+u-1);return e(n,1),t(n),n},Ku=(t,e)=>(u,n)=>{const r=new Date,i=new Date;return r.setTime(+u),i.setTime(+n),t(r),t(i),Math.floor(e(r,i))};function tn(t){const{x:e,y:u}=t.getBoundingClientRect();return{x:e,y:u}}const en=t=>t.getBoundingClientRect().width/t.offsetWidth,un=t=>t.getBoundingClientRect().height/t.offsetHeight;var nn=6371008.8,rn={centimeters:637100880,centimetres:637100880,degrees:57.22891354143274,feet:20902260.511392,inches:39.37*nn,kilometers:6371.0088,kilometres:6371.0088,meters:nn,metres:nn,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:nn/1852,radians:1,yards:6967335.223679999};const sn=1e-10;function on(t,e){for(let u=0;u<e.length;++u)if(Et.distancePP(t,e[u])>e[u].radius+sn)return!1;return!0}function Dn(t,e){return t*t*Math.acos(1-e/t)-(t-e)*Math.sqrt(e*(2*t-e))}function an(t,e){const u=Et.distancePP(t,e),n=t.radius,r=e.radius;if(u>=n+r||u<=Math.abs(n-r))return[];const i=(n*n-r*r+u*u)/(2*u),s=Math.sqrt(n*n-i*i),o=t.x+i*(e.x-t.x)/u,D=t.y+i*(e.y-t.y)/u,a=-(e.y-t.y)*(s/u),h=-(e.x-t.x)*(s/u);return[{x:o+a,y:D-h},{x:o-a,y:D+h}]}function hn(t){const e={x:0,y:0};for(let u=0;u<t.length;++u)e.x+=t[u].x,e.y+=t[u].y;return e.x/=t.length,e.y/=t.length,e}class ln{static getInstance(){return ln.instance||(ln.instance=new ln),ln.instance}constructor(){this.locale_shortWeekdays=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],this.locale_periods=["AM","PM"],this.locale_weekdays=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],this.locale_shortMonths=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],this.numberRe=/^\s*\d+/,this.pads={"-":"",_:" ",0:"0"},this.requoteRe=/[\\^$*+?|[\]().{}]/g,this.locale_months=["January","February","March","April","May","June","July","August","September","October","November","December"],this.formatShortWeekday=t=>this.locale_shortWeekdays[t.getDay()],this.formatWeekday=t=>this.locale_weekdays[t.getDay()],this.formatShortMonth=t=>this.locale_shortMonths[t.getMonth()],this.formatMonth=t=>this.locale_months[t.getMonth()],this.formatDayOfMonth=(t,e)=>this.pad(t.getDate(),e,2),this.formatHour24=(t,e)=>this.pad(t.getHours(),e,2),this.formatHour12=(t,e)=>this.pad(t.getHours()%12||12,e,2),this.formatMilliseconds=(t,e)=>this.pad(t.getMilliseconds(),e,3),this.formatMonthNumber=(t,e)=>this.pad(t.getMonth()+1,e,2),this.formatMinutes=(t,e)=>this.pad(t.getMinutes(),e,2),this.formatPeriod=t=>this.locale_periods[+(t.getHours()>=12)],this.formatSeconds=(t,e)=>this.pad(t.getSeconds(),e,2),this.formatFullYear=(t,e)=>this.pad(t.getFullYear()%1e4,e,4),this.formatUTCShortWeekday=t=>this.locale_shortWeekdays[t.getUTCDay()],this.formatUTCWeekday=t=>this.locale_weekdays[t.getUTCDay()],this.formatUTCShortMonth=t=>this.locale_shortMonths[t.getUTCMonth()],this.formatUTCMonth=t=>this.locale_months[t.getUTCMonth()],this.formatUTCDayOfMonth=(t,e)=>this.pad(t.getUTCDate(),e,2),this.formatUTCHour24=(t,e)=>this.pad(t.getUTCHours(),e,2),this.formatUTCHour12=(t,e)=>this.pad(t.getUTCHours()%12||12,e,2),this.formatUTCMilliseconds=(t,e)=>this.pad(t.getUTCMilliseconds(),e,3),this.formatUTCMonthNumber=(t,e)=>this.pad(t.getUTCMonth()+1,e,2),this.formatUTCMinutes=(t,e)=>this.pad(t.getUTCMinutes(),e,2),this.formatUTCPeriod=t=>this.locale_periods[+(t.getUTCHours()>=12)],this.formatUTCSeconds=(t,e)=>this.pad(t.getUTCSeconds(),e,2),this.formatUTCFullYear=(t,e)=>this.pad(t.getUTCFullYear()%1e4,e,4),this.formats={a:this.formatShortWeekday,A:this.formatWeekday,b:this.formatShortMonth,B:this.formatMonth,d:this.formatDayOfMonth,e:this.formatDayOfMonth,H:this.formatHour24,I:this.formatHour12,L:this.formatMilliseconds,m:this.formatMonthNumber,M:this.formatMinutes,p:this.formatPeriod,S:this.formatSeconds,Y:this.formatFullYear},this.utcFormats={a:this.formatUTCShortWeekday,A:this.formatUTCWeekday,b:this.formatUTCShortMonth,B:this.formatUTCMonth,d:this.formatUTCDayOfMonth,e:this.formatUTCDayOfMonth,H:this.formatUTCHour24,I:this.formatUTCHour12,L:this.formatUTCMilliseconds,m:this.formatUTCMonthNumber,M:this.formatUTCMinutes,p:this.formatUTCPeriod,S:this.formatUTCSeconds,Y:this.formatUTCFullYear},this.parseShortWeekday=(t,e,u)=>{const n=this.shortWeekdayRe.exec(e.slice(u));return n?(t.w=this.shortWeekdayLookup.get(n[0].toLowerCase()),u+n[0].length):-1},this.parseWeekday=(t,e,u)=>{const n=this.weekdayRe.exec(e.slice(u));return n?(t.w=this.weekdayLookup.get(n[0].toLowerCase()),u+n[0].length):-1},this.parseShortMonth=(t,e,u)=>{const n=this.shortMonthRe.exec(e.slice(u));return n?(t.m=this.shortMonthLookup.get(n[0].toLowerCase()),u+n[0].length):-1},this.parseMonth=(t,e,u)=>{const n=this.monthRe.exec(e.slice(u));return n?(t.m=this.monthLookup.get(n[0].toLowerCase()),u+n[0].length):-1},this.parseDayOfMonth=(t,e,u)=>{const n=this.numberRe.exec(e.slice(u,u+2));return n?(t.d=+n[0],u+n[0].length):-1},this.parseHour24=(t,e,u)=>{const n=this.numberRe.exec(e.slice(u,u+2));return n?(t.H=+n[0],u+n[0].length):-1},this.parseMilliseconds=(t,e,u)=>{const n=this.numberRe.exec(e.slice(u,u+3));return n?(t.L=+n[0],u+n[0].length):-1},this.parseMonthNumber=(t,e,u)=>{const n=this.numberRe.exec(e.slice(u,u+2));return n?(t.m=n-1,u+n[0].length):-1},this.parseMinutes=(t,e,u)=>{const n=this.numberRe.exec(e.slice(u,u+2));return n?(t.M=+n[0],u+n[0].length):-1},this.parsePeriod=(t,e,u)=>{const n=this.periodRe.exec(e.slice(u));return n?(t.p=this.periodLookup.get(n[0].toLowerCase()),u+n[0].length):-1},this.parseSeconds=(t,e,u)=>{const n=this.numberRe.exec(e.slice(u,u+2));return n?(t.S=+n[0],u+n[0].length):-1},this.parseFullYear=(t,e,u)=>{const n=this.numberRe.exec(e.slice(u,u+4));return n?(t.y=+n[0],u+n[0].length):-1},this.parses={a:this.parseShortWeekday,A:this.parseWeekday,b:this.parseShortMonth,B:this.parseMonth,d:this.parseDayOfMonth,e:this.parseDayOfMonth,H:this.parseHour24,I:this.parseHour24,L:this.parseMilliseconds,m:this.parseMonthNumber,M:this.parseMinutes,p:this.parsePeriod,S:this.parseSeconds,Y:this.parseFullYear},this.timeFormat=(t,e)=>this.newFormat(t,this.formats)(new Date(this.getFullTimeStamp(e))),this.timeUTCFormat=(t,e)=>this.newFormat(t,this.utcFormats)(new Date(this.getFullTimeStamp(e))),this.timeParse=(t,e)=>this.newParse(t,!1)(e+""),this.requoteF=this.requote.bind(this),this.periodRe=this.formatRe(this.locale_periods),this.periodLookup=this.formatLookup(this.locale_periods),this.weekdayRe=this.formatRe(this.locale_weekdays),this.weekdayLookup=this.formatLookup(this.locale_weekdays),this.shortWeekdayRe=this.formatRe(this.locale_shortWeekdays),this.shortWeekdayLookup=this.formatLookup(this.locale_shortWeekdays),this.monthRe=this.formatRe(this.locale_months),this.monthLookup=this.formatLookup(this.locale_months),this.shortMonthRe=this.formatRe(this.locale_shortMonths),this.shortMonthLookup=this.formatLookup(this.locale_shortMonths)}requote(t){return t.replace(this.requoteRe,"\\$&")}localDate(t){if(0<=t.y&&t.y<100){const e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}utcDate(t){if(0<=t.y&&t.y<100){const e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}newDate(t,e,u){return{y:t,m:e,d:u,H:0,M:0,S:0,L:0}}formatRe(t){return new RegExp("^(?:"+t.map(this.requoteF).join("|")+")","i")}formatLookup(t){return new Map(t.map(((t,e)=>[t.toLowerCase(),e])))}pad(t,e,u){const n=t<0?"-":"",r=(n?-t:t)+"",i=r.length;return n+(i<u?new Array(u-i+1).join(e)+r:r)}parseSpecifier(t,e,u,n){let r=0;const i=e.length,s=u.length;let o,D;for(;r<i;){if(n>=s)return-1;if(o=e.charCodeAt(r++),37===o){if(o=e.charAt(r++),D=this.parses[o in this.pads?e.charAt(r++):o],!D||(n=D(t,u,n))<0)return-1}else if(o!==u.charCodeAt(n++))return-1}return n}newParse(t,e){const u=this;return function(n){const r=u.newDate(1900,void 0,1);return u.parseSpecifier(r,t,n+="",0)!==n.length?null:"Q"in r?new Date(r.Q):"s"in r?new Date(1e3*r.s+("L"in r?r.L:0)):(e&&!("Z"in r)&&(r.Z=0),"p"in r&&(r.H=r.H%12+12*r.p),void 0===r.m&&(r.m="q"in r?r.q:0),"Z"in r?(r.H+=r.Z/100|0,r.M+=r.Z%100,u.utcDate(r)):u.localDate(r))}}newFormat(t,e){const u=this;return function(n){const r=[];let i=-1,s=0;const o=t.length;let D,a,h;for(n instanceof Date||(n=new Date(+n));++i<o;)37===t.charCodeAt(i)&&(r.push(t.slice(s,i)),(a=u.pads[D=t.charAt(++i)])?D=t.charAt(++i):a="e"===D?" ":"0",h=e[D],D=h(n,a),r.push(D),s=i+1);return r.push(t.slice(s,i)),r.join("")}}getFullTimeStamp(t){const e=parseInt(t+"",10);return 10===String(e).length?1e3*e:e}}function cn(t,e){const u=e?t.toExponential(e-1):t.toExponential(),n=u.indexOf("e");if(n<0)return null;const r=u.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+u.slice(n+1)]}let fn;function Fn(t,e){const u=cn(t,e);if(!u)return t+"";const n=u[0],r=u[1];return r<0?"0."+new Array(-r).join("0")+n:n.length>r+1?n.slice(0,r+1)+"."+n.slice(r+1):n+new Array(r-n.length+2).join("0")}class dn{constructor(t={}){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}toString(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type}}const gn=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function mn(t){let e;if(e=gn.exec(t))return new dn({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]});Ge.getInstance().error("invalid format: "+t)}const Cn=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];class pn{constructor(){var t,e;this.locale={thousands:",",grouping:[3],currency:["$",""]},this.group=void 0===this.locale.grouping||void 0===this.locale.thousands?t=>t:(t=[...this.locale.grouping].map(Number),e=`${this.locale.thousands}`,function(u,n){let r=u.length;const i=[];let s=0,o=t[0],D=0;for(;r>0&&o>0&&(D+o+1>n&&(o=Math.max(1,n-D)),i.push(u.substring(r-=o,r+o)),!((D+=o+1)>n));)o=t[s=(s+1)%t.length];return i.reverse().join(e)}),this.currencyPrefix=void 0===this.locale.currency?"":this.locale.currency[0]+"",this.currencySuffix=void 0===this.locale.currency?"":this.locale.currency[1]+"",this.decimal=void 0===this.locale.decimal?".":this.locale.decimal+"",this.numerals=void 0===this.locale.numerals?t=>t:En([...this.locale.numerals].map(String)),this.percent=void 0===this.locale.percent?"%":this.locale.percent+"",this.minus=void 0===this.locale.minus?"−":this.locale.minus+"",this.nan=void 0===this.locale.nan?"NaN":this.locale.nan+"",this.formatter=t=>this.newFormat(t),this.format=(t,e)=>this.formatter(t)(e),this.formatPrefix=(t,e)=>this._formatPrefix(t,e)}static getInstance(){return pn.instance||(pn.instance=new pn),pn.instance}newFormat(t){const e=mn(t);let u=e.fill,n=e.align;const r=e.sign,i=e.symbol;let s=e.zero;const o=e.width;let D=e.comma,a=e.precision,h=e.trim,l=e.type;"n"===l?(D=!0,l="g"):yn[l]||(void 0===a&&(a=12),h=!0,l="g"),(s||"0"===u&&"="===n)&&(s=!0,u="0",n="=");const c="$"===i?this.currencyPrefix:"#"===i&&/[boxX]/.test(l)?"0"+l.toLowerCase():"",f="$"===i?this.currencySuffix:/[%p]/.test(l)?this.percent:"",F=yn[l],d=/[defgprstz%]/.test(l);a=void 0===a?6:/[gprs]/.test(l)?Math.max(1,Math.min(21,a)):Math.max(0,Math.min(20,a));const{nan:g,minus:m,decimal:C,group:p,numerals:y}=this;function x(t){let e,i,x,E=c,M=f,B=t;if("c"===l)M=F(B)+M,B="";else{B=+B;let t=B<0||1/B<0;if(B=isNaN(B)?g:F(Math.abs(B),a),h&&(B=function(t){const e=t.length;let u,n=-1;t:for(let r=1;r<e;++r)switch(t[r]){case".":n=u=r;break;case"0":0===n&&(n=r),u=r;break;default:if(!+t[r])break t;n>0&&(n=0)}return n>0?t.slice(0,n)+t.slice(u+1):t}(B)),t&&0==+B&&"+"!==r&&(t=!1),E=(t?"("===r?r:m:"-"===r||"("===r?"":r)+E,M=("s"===l?Cn[8+fn/3]:"")+M+(t&&"("===r?")":""),d)for(e=-1,i=B.length;++e<i;)if(x=B.charCodeAt(e),48>x||x>57){M=(46===x?C+B.slice(e+1):B.slice(e))+M,B=B.slice(0,e);break}}D&&!s&&(B=p(B,1/0));let b=E.length+B.length+M.length,v=b<o?new Array(o-b+1).join(u):"";switch(D&&s&&(B=p(v+B,v.length?o-M.length:1/0),v=""),n){case"<":B=E+B+M+v;break;case"=":B=E+v+B+M;break;case"^":B=v.slice(0,b=v.length>>1)+E+B+M+v.slice(b);break;default:B=v+E+B+M}return y(B)}return x.toString=function(){return t+""},x}_formatPrefix(t,e){const u=mn(t);u.type="f";const n=this.newFormat(u.toString()),r=3*Math.max(-8,Math.min(8,Math.floor(xn(e)/3))),i=Math.pow(10,-r),s=Cn[8+r/3];return function(t){return n(i*t)+s}}}const yn={"%":(t,e)=>(100*t).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},f:(t,e)=>t.toFixed(e),e:(t,e)=>t.toExponential(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>Fn(100*t,e),r:Fn,s:function(t,e){const u=cn(t,e);if(!u)return t+"";const n=u[0],r=u[1],i=r-(fn=3*Math.max(-8,Math.min(8,Math.floor(r/3))))+1,s=n.length;return i===s?n:i>s?n+new Array(i-s+1).join("0"):i>0?n.slice(0,i)+"."+n.slice(i):"0."+new Array(1-i).join("0")+cn(t,Math.max(0,e+i-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16),t:(t,e)=>Number.isInteger(t)?t.toFixed(2):Math.floor(t*Math.pow(10,e))/Math.pow(10,e)+"",z:(t,e)=>t%1==0?t+"":t.toFixed(e)};function xn(t){const e=cn(Math.abs(t));return e?e[1]:NaN}function En(t){return function(e){return e.replace(/[0-9]/g,(e=>t[+e]))}}function Mn(t){const e=new Array(t);for(let u=0;u<t;++u)e[u]=0;return e}function Bn(t){return Math.sqrt(mt(t,t))}function bn(t,e,u){for(let n=0;n<e.length;++n)t[n]=e[n]*u}function vn(t,e,u,n,r){for(let i=0;i<t.length;++i)t[i]=e*u[i]+n*r[i]}function An(t,e,u,n,r,i,s){const o=u.fx,D=mt(u.fxprime,e);let a=o,h=o,l=D,c=0;function f(h,c,f){for(let F=0;F<16;++F)if(r=(h+c)/2,vn(n.x,1,u.x,r,e),a=n.fx=t(n.x,n.fxprime),l=mt(n.fxprime,e),a>o+i*r*D||a>=f)c=r;else{if(Math.abs(l)<=-s*D)return r;l*(c-h)>=0&&(c=h),h=r,f=a}return 0}r=r||1,i=i||1e-6,s=s||.1;for(let F=0;F<10;++F){if(vn(n.x,1,u.x,r,e),a=n.fx=t(n.x,n.fxprime),l=mt(n.fxprime,e),a>o+i*r*D||F&&a>=h)return f(c,r,h);if(Math.abs(l)<=-s*D)return r;if(l>=0)return f(r,c,a);h=a,c=r,r*=2}return r}t.AABBBounds=class extends bt{},t.Bounds=bt,t.Color=jt,t.ColorUtil=Vt,t.DAY=nu,t.DEFAULT_COLORS=Ot,t.EventEmitter=n,t.FormatSpecifier=dn,t.GraphicUtil=_e,t.HOUR=uu,t.HashTable=class{constructor(){this.items={},this.itemList=[]}get type(){return"xhHashTable"}set(t,e){const u=new tt;u.key=t,u.value=e;let n=this.itemList.length;return this.has(t)&&(n=this.items[t].index),u.index=n,this.itemList[n]=u,this.items[t]=u,u}clear(){this.items={},this.itemList=[]}del(t){if(this.has(t)){const e=this.items[t].index;e>-1&&this.itemList.splice(e,1),delete this.items[t],this.resetIndex()}}delFrom(t){for(let e=t+1;e<this.count();e++){const t=this.itemList[e].key;delete this.items[t]}this.itemList.splice(t+1,this.count()-t),this.resetIndex()}resetIndex(){this.foreachHashv(((t,e)=>{const u=this.itemList.indexOf(e);this.items[t].index=u}))}has(t){return t in this.items}get(t){return this.has(t)?this.items[t].value:null}count(){return this.itemList.length}all(){return this.itemList.map((t=>t.value))}first(){return this.itemList[0].value}last(){return this.itemList[this.itemList.length-1].value}getByIndex(t){return this.itemList[t].value}getKeyByIndex(t){return this.itemList[t].key}foreach(t){for(const e in this.items){if(!1===t(e,this.items[e].value))return!1}return!0}foreachHashv(t){for(const e in this.items){if(!1===t(e,this.items[e]))return!1}return!0}hasValue(t){for(const e in this.items)if(this.items[e].value===t)return!0;return!1}indexOf(t){return this.has(t)?this.items[t].index:-1}insertAt(t,e,u){const n=new tt;n.index=t,n.key=u,n.value=e,this.itemList.splice(t,0,n),this.items[u]=n,this.resetIndex()}sort(t){return this.itemList.sort(((e,u)=>t(e.value,u.value)))}toArray(){return this.itemList.slice(0,this.itemList.length).map((t=>t.value))}push(t){t.foreach(((t,e)=>{this.set(t,e)}))}mapKey(){const t=[];for(const e in this.items)t.push(e);return t}toImmutableMap(){}},t.HashValue=tt,t.LRU=class{constructor(){this.CLEAN_THRESHOLD=1e3,this.L_TIME=1e3,this.R_COUNT=1,this.R_TIMESTAMP_MAX_SIZE=20}clearCache(t,e){const{CLEAN_THRESHOLD:u=this.CLEAN_THRESHOLD,L_TIME:n=this.L_TIME,R_COUNT:r=this.R_COUNT}=e;if(t.size<u)return 0;let i=0;const s=e=>{i++,t.delete(e)},o=Date.now();return t.forEach(((t,e)=>{if(t.timestamp.length<r)return s(e);let u=0;for(;o-t.timestamp[t.timestamp.length-1-u]<n&&(u++,!(u>=r)););if(u<r)return s(e);for(;o-t.timestamp[0]>n;)t.timestamp.shift()})),i}addLimitedTimestamp(t,e,u){const{R_TIMESTAMP_MAX_SIZE:n=this.R_TIMESTAMP_MAX_SIZE}=u;t.timestamp.length>n&&t.timestamp.shift(),t.timestamp.push(e)}clearTimeStamp(t,e){const{L_TIME:u=this.L_TIME}=e,n=Date.now();t.forEach((t=>{for(;n-t.timestamp[0]>u;)t.timestamp.shift()}))}clearItemTimestamp(t,e){const{L_TIME:u=this.L_TIME}=e,n=Date.now();for(;n-t.timestamp[0]>u;)t.timestamp.shift()}},t.Logger=Ge,t.MINUTE=eu,t.MONTH=26784e5,t.Matrix=Lt,t.NEWTON_ITERATIONS=4,t.NEWTON_MIN_SLOPE=.001,t.NumberUtil=pn,t.OBBBounds=class extends bt{},t.Point=xt,t.PointService=Et,t.PolarPoint=Mt,t.RGB=Yt,t.SECOND=tu,t.SMALL=sn,t.SUBDIVISION_MAX_ITERATIONS=10,t.SUBDIVISION_PRECISION=1e-7,t.TextMeasure=je,t.TimeUtil=ln,t.YEAR=31536e6,t.abs=st,t.acos=function(t){return t>1?0:t<-1?ut:Math.acos(t)},t.array=L,t.arrayEqual=function(t,e){if(!f(t)||!f(e))return!1;if(t.length!==e.length)return!1;for(let u=0;u<t.length;u++)if(t[u]!==e[u])return!1;return!0},t.ascending=k,t.asin=function(t){return t>=1?nt:t<=-1?-nt:Math.asin(t)},t.atan2=ot,t.bisect=function(t,e,u=0,n){for(o(n)&&(n=t.length);u<n;){const r=u+n>>>1;k(t[r],e)>0?n=r:u=r+1}return u},t.circleArea=Dn,t.circleCircleIntersection=an,t.circleOverlap=function(t,e,u){if(u>=t+e)return 0;if(u<=Math.abs(t-e))return Math.PI*Math.min(t,e)*Math.min(t,e);const n=e-(u*u-t*t+e*e)/(2*u);return Dn(t,t-(u*u-e*e+t*t)/(2*u))+Dn(e,n)},t.clamp=G,t.clampAngleByDegree=_t,t.clampAngleByRadian=St,t.clampDegree=Tt,t.clampRadian=wt,t.clampRange=(t,e,u)=>{let[n,r]=t;r<n&&(n=t[1],r=t[0]);const i=r-n;return i>=u-e?[e,u]:(n=Math.min(Math.max(n,e),u-i),[n,n+i])},t.clamper=function(t,e){let u;return t>e&&(u=t,t=e,e=u),u=>Math.max(t,Math.min(e,u))},t.clone=function(t,e=!1,u=0,n=void 0){const r=[],i=[];return void 0===e&&(e=!0),void 0===u&&(u=1/0),function t(u,s){if(null===u)return null;if(0===s)return u;let o;if("object"!=typeof u)return u;if(f(u)?o=[]:C(u)?(o=new RegExp(u.source,function(t){let e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),e}(u)),u.lastIndex&&(o.lastIndex=u.lastIndex)):o=d(u)?new Date(u.getTime()):void 0===n?Object.create(Object.getPrototypeOf(u)):Object.create(n),e){const t=r.indexOf(u);if(-1!==t)return i[t];r.push(u),i.push(o)}for(const e in u)o[e]=t(u[e],s-1);return o}(t,u)},t.cloneDeep=function t(e){let u;if(!D(e)||"object"!=typeof e)return e;const n=f(e),r=e.length;u=n?new Array(r):"object"==typeof e?{}:i(e)||g(e)||c(e)?e:d(e)?new Date(+e):void 0;const s=n?void 0:Object.keys(Object(e));let o=-1;if(u)for(;++o<(s||e).length;){const n=s?s[o]:o,r=e[n];u[n]=t(r)}return u},t.conjugateGradient=function(t,e,u){let n={x:e.slice(),fx:0,fxprime:e.slice()},r={x:e.slice(),fx:0,fxprime:e.slice()};const i=e.slice();let s,o=1;const D=(u=u||{}).maxIterations||20*e.length;n.fx=t(n.x,n.fxprime);const a=n.fxprime.slice();bn(a,n.fxprime,-1);for(let e=0;e<D;++e){if(o=An(t,a,n,r,o),u.history&&u.history.push({x:n.x.slice(),fx:n.fx,fxprime:n.fxprime.slice(),alpha:o}),o){vn(i,1,r.fxprime,-1,n.fxprime);const t=mt(n.fxprime,n.fxprime);vn(a,Math.max(0,mt(i,r.fxprime)/t),a,-1,r.fxprime),s=n,n=r,r=s}else bn(a,n.fxprime,-1);if(Bn(n.fxprime)<=1e-5)break}return u.history&&u.history.push({x:n.x.slice(),fx:n.fx,fxprime:n.fxprime.slice(),alpha:o}),n},t.constant=t=>s(t)?t:()=>t,t.containedInCircles=on,t.cos=Dt,t.crossProduct=dt,t.crossProductPoint=gt,t.dateGetterName=Xe,t.dateSetterName=function(t){return t?"setUTCDate":"setDate"},t.dayCount=Eu,t.dayField=Mu,t.dayFloor=yu,t.dayOffset=xu,t.debounce=$,t.defaults=_,t.degreeToRadian=vt,t.destination=function(t,e,u,n={}){const r=vt(t[0]),i=vt(t[1]),s=vt(u),o=function(t,e){void 0===e&&(e="kilometers");var u=rn[e];if(!u)throw new Error(e+" units is invalid");return t/u}(e,n.units),D=Math.asin(Math.sin(i)*Math.cos(o)+Math.cos(i)*Math.sin(o)*Math.cos(s));return{x:At(r+Math.atan2(Math.sin(s)*Math.sin(o)*Math.cos(i),Math.cos(o)-Math.sin(i)*Math.sin(D))),y:At(D)}},t.deviation=function(t,e){const u=O(t,e);return u?Math.sqrt(u):u},t.dotProduct=mt,t.eastAsianCharacterInfo=Re,t.epsilon=et,t.exponent=xn,t.findZeroOfFunction=function(t,e,u,n){const r=(n=n||{}).maxIterations||100,i=n.tolerance||1e-10,s=t(e),o=t(u);let D=u-e;if(s*o>0){return Ge.getInstance().error("Initial bisect points must have opposite signs"),NaN}if(0===s)return e;if(0===o)return u;for(let u=0;u<r;++u){D/=2;const u=e+D,n=t(u);if(n*s>=0&&(e=u),Math.abs(D)<i||0===n)return u}return e+D},t.fixPrecision=pt,t.flattenArray=function t(e){if(!f(e))return[e];const u=[];for(const n of e)u.push(...t(n));return u},t.formatNumerals=En,t.formatSpecifier=mn,t.formatTypes=yn,t.fullYearGetterName=Ve,t.fullYearSetterName=function(t){return t?"setUTCFullYear":"setFullYear"},t.fuzzyEqualNumber=function(t,e){return st(t-e)<et},t.fuzzyEqualVec=Ct,t.gemv=function(t,e,u){for(let n=0;n<t.length;++n)t[n]=mt(e[n],u)},t.generateCeil=Qu,t.generateCount=Ku,t.generateStepInterval=(t,{floor:e,offset:u,field:n,count:r})=>{const i=Math.floor(t);if(!Number.isFinite(i)||i<=0)return null;if(i<=1)return{floor:e,offset:u,ceil:Qu(e,u)};const s=Ku(e,r),o=n?t=>n(t)%i==0:t=>s(0,t)%i==0,D=t=>{if(!Number.isNaN(+t))for(e(t);!o(t);)t.setTime(+t-1),e(t);return t},a=(t,e)=>{if(!Number.isNaN(+t))if(i<0)for(;++e<=0;)for(u(t,-1);!o(t);)u(t,-1);else for(;--e>=0;)for(u(t,1);!o(t);)u(t,1);return t};return{floor:D,offset:a,ceil:Qu(D,a)}},t.get=(t,e,u)=>{const n=c(e)?e.split("."):e;for(let e=0;e<n.length;e++)t=t?t[n[e]]:void 0;return void 0===t?u:t},t.getAABBFromPoints=function(t){return le=1/0,ce=1/0,fe=-1/0,Fe=-1/0,t.forEach((t=>{le>t.x&&(le=t.x),fe<t.x&&(fe=t.x),ce>t.y&&(ce=t.y),Fe<t.y&&(Fe=t.y)})),{x1:le,y1:ce,x2:fe,y2:Fe}},t.getAngleByPoint=function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)},t.getCenter=hn,t.getContainerSize=function(t,e=0,u=0){if(!t)return{width:e,height:u};let n;try{n=null===window||void 0===window?void 0:window.getComputedStyle}catch(t){n=()=>({})}const r=n(t);if(/^(\d*\.?\d+)(px)$/.exec(r.width)){const n=parseFloat(r.width)-parseFloat(r.paddingLeft)-parseFloat(r.paddingRight)||t.clientWidth-1,i=parseFloat(r.height)-parseFloat(r.paddingTop)-parseFloat(r.paddingBottom)||t.clientHeight-1;return{width:n<=0?e:n,height:i<=0?u:i}}return{width:e,height:u}},t.getContextFont=We,t.getDecimalPlaces=yt,t.getElementAbsolutePosition=tn,t.getElementRelativePosition=function(t,e){const u=tn(t),n=tn(e);return{x:u.x-n.x,y:u.y-n.y}},t.getFormatFromValue=function(t,e){const u=K(t),n=u[$e(e)]()+1,r=u[Xe(e)](),i=u[Ze(e)](),s=u[Je(e)](),o=u[Qe(e)](),D=0===u[Ke(e)](),a=D&&0===o,h=a&&0===s,l=h&&0===i,c=l&&1===r;return c&&1===n?"YYYY":c?"YYYY-MM":l?"YYYY-MM-DD":h?"HH":a?"HH:mm":D?"HH:mm:ss":"HH:mm:ss SSS"},t.getIntersectPoint=function(t,e,u,n){if(!ne(t,e,u,n))return!1;const r=[0,0],i=[0,0],s=[0,0];if($t(r,e,t),$t(i,n,u),Ct(r,i))return!0;$t(s,u,t);const o=dt(s,i)/dt(r,i);return o>=0&&o<=1&&[t[0]+r[0]*o,t[1]+r[1]*o]},t.getIntervalOptions=(t,e)=>"year"===t&&e?{floor:Du,offset:au,count:hu,field:lu}:"month"===t&&e?{floor:gu,offset:mu,count:Cu,field:pu}:"day"===t&&e?{floor:Bu,offset:bu,count:vu,field:Au}:"hour"===t&&e?{floor:Lu,offset:Nu,count:Tu,field:ku}:"minute"===t&&e?{floor:Ru,offset:Pu,count:Ou,field:Wu}:"second"===t&&e?{floor:Gu,offset:Vu,count:zu,field:$u}:"year"===t?{floor:ru,offset:iu,count:su,field:ou}:"month"===t?{floor:cu,offset:fu,count:Fu,field:du}:"day"===t?{floor:yu,offset:xu,count:Eu,field:Mu}:"hour"===t?{floor:wu,offset:Su,count:Tu,field:_u}:"minute"===t?{floor:Uu,offset:Hu,count:Ou,field:Iu}:"second"===t?{floor:ju,offset:Yu,count:zu,field:qu}:{floor:Xu,offset:Zu,count:Ju},t.getOBBFromLine=function(t,e,u){return de=e.x-t.x,ge=e.y-t.y,me=ge,Ce=-de,xe=pe=Math.sqrt(me*me+Ce*Ce),Ee=u,me/=pe,Ce/=pe,ye=u/2,de=ye*me,ge=ye*Ce,{point1:{x:t.x+de,y:t.y+ge},point2:{x:t.x-de,y:t.y-ge},point3:{x:e.x+de,y:e.y+ge},point4:{x:e.x-de,y:e.y-ge},width:xe,height:Ee,left:Math.min(t.x,e.x)-Math.abs(de),top:Math.min(t.y,e.y)-Math.abs(ge)}},t.getRectIntersect=function(t,e,u){return null===t?e:null===e?t:(Xt=t.x1,Zt=t.x2,Jt=t.y1,Qt=t.y2,Kt=e.x1,te=e.x2,ee=e.y1,ue=e.y2,u&&(Xt>Zt&&([Xt,Zt]=[Zt,Xt]),Jt>Qt&&([Jt,Qt]=[Qt,Jt]),Kt>te&&([Kt,te]=[te,Kt]),ee>ue&&([ee,ue]=[ue,ee])),Xt>=te||Zt<=Kt||Jt>=ue||Qt<=ee?{x1:0,y1:0,x2:0,y2:0}:{x1:Math.max(Xt,Kt),y1:Math.max(Jt,ee),x2:Math.min(Zt,te),y2:Math.min(Qt,ue)})},t.getScale=t=>t.offsetWidth>0?en(t):un(t),t.getScaleX=en,t.getScaleY=un,t.getScrollLeft=t=>{var e,u,n;return t===(null===(e=null===globalThis||void 0===globalThis?void 0:globalThis.document)||void 0===e?void 0:e.body)?(null===(n=null===(u=null===globalThis||void 0===globalThis?void 0:globalThis.document)||void 0===u?void 0:u.documentElement)||void 0===n?void 0:n.scrollLeft)||t.scrollLeft:"html"===t.tagName.toLowerCase()?0:t.scrollLeft},t.getScrollTop=t=>{var e,u,n;return t===(null===(e=null===globalThis||void 0===globalThis?void 0:globalThis.document)||void 0===e?void 0:e.body)?(null===(n=null===(u=null===globalThis||void 0===globalThis?void 0:globalThis.document)||void 0===u?void 0:u.documentElement)||void 0===n?void 0:n.scrollTop)||t.scrollTop:"html"===t.tagName.toLowerCase()?0:t.scrollTop},t.getTimeFormatter=function(t,e){return u=>{const n=K(u),r=n[Ve(e)](),i=n[$e(e)]()+1,s=Math.floor((i-1)/3)+1,o=n[Xe(e)](),D=n["get"+(e?"UTC":"")+"Day"](),a=n[Ze(e)](),h=(a-1)%12+1,l=n[Je(e)](),c=n[Qe(e)](),f=n[Ke(e)]();return(t||"").replace(/YYYY/g,q(r+"",4,"0","left")).replace(/yyyy/g,r+"").replace(/yy/g,r%100+"").replace(/Q/g,s+"").replace(/MM/g,q(i,2,"0","left")).replace(/M/g,i+"").replace(/dd/g,q(o,2,"0","left")).replace(/d/g,o+"").replace(/e/g,D+"").replace(/HH/g,q(a,2,"0","left")).replace(/H/g,a+"").replace(/hh/g,q(h+"",2,"0","left")).replace(/h/g,h+"").replace(/mm/g,q(l,2,"0","left")).replace(/m/g,l+"").replace(/ss/g,q(c,2,"0","left")).replace(/s/g,c+"").replace(/SSS/g,q(f,3,"0","left")).replace(/S/g,f+"")}},t.halfPi=nt,t.has=(t,e)=>null!=t&&x.call(t,e),t.hasParentElement=function(t,e){let u=t.parentNode;for(;null!==u;){if(u===e)return!0;u=u.parentNode}return!1},t.hexToRgb=zt,t.hourCount=Tu,t.hourField=_u,t.hourFloor=wu,t.hourOffset=Su,t.hoursGetterName=Ze,t.hoursSetterName=function(t){return t?"setUTCHours":"setHours"},t.hslToRgb=Nt,t.interpolateDate=function(t,e){const u=t.valueOf(),n=e.valueOf(),r=new Date;return t=>(r.setTime(u*(1-t)+n*t),r)},t.interpolateNumber=X,t.interpolateNumberRound=function(t,e){return function(u){return Math.round(t*(1-u)+e*u)}},t.interpolateRgb=Gt,t.interpolateString=function(t,e){let u,n,r,i=Z.lastIndex=J.lastIndex=0,s=-1;const o=[],D=[];for(t+="",e+="";(u=Z.exec(t))&&(n=J.exec(e));)(r=n.index)>i&&(r=e.slice(i,r),o[s]?o[s]+=r:o[++s]=r),(u=u[0])===(n=n[0])?o[s]?o[s]+=n:o[++s]=n:(o[++s]=null,D.push({i:s,x:X(u,n)})),i=J.lastIndex;return i<e.length&&(r=e.slice(i),o[s]?o[s]+=r:o[++s]=r),o.length<2?D[0]?function(t){return function(e){return t(e)+""}}(D[0].x):function(t){return function(){return t}}(e):(e=D.length,function(t){for(let u,n=0;n<e;++n)o[(u=D[n]).i]=u.x(t);return o.join("")})},t.intersectionArea=function(t,e){const u=function(t){const e=[];for(let u=0;u<t.length;++u)for(let n=u+1;n<t.length;++n){const r=an(t[u],t[n]);for(let t=0;t<r.length;++t){const i=r[t];i.parentIndex=[u,n],e.push(i)}}return e}(t),n=u.filter((function(e){return on(e,t)}));let r=0,i=0;const s=[];if(n.length>1){const e=hn(n);for(let t=0;t<n.length;++t){const u=n[t];u.angle=Math.atan2(u.x-e.x,u.y-e.y)}n.sort((function(t,e){return e.angle-t.angle}));let u=n[n.length-1];for(let e=0;e<n.length;++e){const o=n[e];i+=(u.x+o.x)*(o.y-u.y);const D={x:(o.x+u.x)/2,y:(o.y+u.y)/2};let a=null;for(let e=0;e<o.parentIndex.length;++e)if(u.parentIndex.indexOf(o.parentIndex[e])>-1){const n=t[o.parentIndex[e]],r=Math.atan2(o.x-n.x,o.y-n.y),i=Math.atan2(u.x-n.x,u.y-n.y);let s=i-r;s<0&&(s+=2*Math.PI);const h=i-s/2;let l=Et.distancePP(D,{x:n.x+n.radius*Math.sin(h),y:n.y+n.radius*Math.cos(h)});l>2*n.radius&&(l=2*n.radius),(null===a||a.width>l)&&(a={circle:n,width:l,p1:o,p2:u})}null!==a&&(s.push(a),r+=Dn(a.circle.radius,a.width),u=o)}}else{let e=t[0];for(let u=1;u<t.length;++u)t[u].radius<e.radius&&(e=t[u]);let u=!1;for(let n=0;n<t.length;++n)if(Et.distancePP(t[n],e)>Math.abs(e.radius-t[n].radius)){u=!0;break}u?r=i=0:(r=e.radius*e.radius*Math.PI,s.push({circle:e,p1:{x:e.x,y:e.y+e.radius},p2:{x:e.x-sn,y:e.y+e.radius},width:2*e.radius}))}return i/=2,e&&(e.area=r+i,e.arcArea=r,e.polygonArea=i,e.arcs=s,e.innerPoints=n,e.intersectionPoints=u),r+i},t.isArray=f,t.isArrayLike=F,t.isBase64=t=>new RegExp(/^data:image\/(?:gif|png|jpeg|bmp|webp|svg\+xml)(?:;charset=utf-8)?;base64,(?:[A-Za-z0-9]|[+/])+={0,2}/g).test(t),t.isBoolean=i,t.isDate=d,t.isEmpty=function(t){if(o(t))return!0;if(F(t))return!t.length;const e=(t=>({}.toString.call(t).replace(/^\[object /,"").replace(/]$/,"")))(t);if("Map"===e||"Set"===e)return!t.size;if(function(t){const e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||p)}(t))return!Object.keys(t).length;for(const e in t)if(y.call(t,e))return!1;return!0},t.isEqual=function t(e,u,n){if(e===u)return!0;if(typeof e!=typeof u)return!1;if(null==e||null==u)return!1;if(Number.isNaN(e)&&Number.isNaN(u))return!0;if(v(e)!==v(u))return!1;if(s(e))return!!(null==n?void 0:n.skipFunction);if("object"!=typeof e)return!1;if(f(e)){if(e.length!==u.length)return!1;for(let r=e.length-1;r>=0;r--)if(!t(e[r],u[r],n))return!1;return!0}if(!l(e))return!1;const r=A(e),i=A(u);if(r.length!==i.length)return!1;r.sort(),i.sort();for(let t=r.length-1;t>=0;t--)if(r[t]!=i[t])return!1;for(let i=r.length-1;i>=0;i--){const s=r[i];if(!t(e[s],u[s],n))return!1}return!0},t.isFunction=s,t.isGreater=function(t,e,u,n){return t>e&&!Y(t,e,u,n)},t.isIntersect=ne,t.isLess=function(t,e,u,n){return t<e&&!Y(t,e,u,n)},t.isNil=o,t.isNull=t=>null===t,t.isNumber=g,t.isNumberClose=Y,t.isNumeric=t=>"string"==typeof t&&(!isNaN(Number(t))&&!isNaN(parseFloat(t))),t.isObject=a,t.isObjectLike=h,t.isPlainObject=l,t.isPointInLine=Ue,t.isPointInPolygon=function(t,e){if(!t)return!1;if(!e)return!1;const u="Feature"===(n=e).type?n.geometry:n;var n;const r=u.type,i=e.bbox;let s=u.coordinates;if(i&&!0===ie(t,{x1:i[0],x2:i[1],y1:i[1],y2:i[3]},!0))return!1;"Polygon"===r&&(s=[s]);let o=!1;for(let e=0;e<s.length;++e)for(let u=0;u<s[e].length;++u){if(ke(s[e][u].map((t=>({x:t[0],y:t[1]}))),t.x,t.y))return o=!0,o}return o},t.isRectIntersect=function(t,e,u){return!t||!e||(u?(Xt=t.x1,Zt=t.x2,Jt=t.y1,Qt=t.y2,Kt=e.x1,te=e.x2,ee=e.y1,ue=e.y2,Xt>Zt&&([Xt,Zt]=[Zt,Xt]),Jt>Qt&&([Jt,Qt]=[Qt,Jt]),Kt>te&&([Kt,te]=[te,Kt]),ee>ue&&([ee,ue]=[ue,ee]),!(Xt>te||Zt<Kt||Jt>ue||Qt<ee)):!(t.x1>e.x2||t.x2<e.x1||t.y1>e.y2||t.y2<e.y1))},t.isRegExp=C,t.isRotateAABBIntersect=function(t,e,u=!1,n){const r=he(t,u),i=he(e,u),s=(t,e)=>[e.x-t.x,e.y-t.y];n&&(n.save(),n.fillStyle="red",n.globalAlpha=.6,r.forEach(((t,e)=>{0===e?n.moveTo(t.x,t.y):n.lineTo(t.x,t.y)})),n.fill(),n.restore(),n.save(),n.fillStyle="green",n.globalAlpha=.6,i.forEach(((t,e)=>{0===e?n.moveTo(t.x,t.y):n.lineTo(t.x,t.y)})),n.fill(),n.restore());const o=ae(t),D=ae(e);n&&n.fillRect(o.x,o.y,2,2),n&&n.fillRect(D.x,D.y,2,2);const a=s(o,D),h=s(r[0],r[1]),l=s(r[1],r[2]),c=s(i[0],i[1]),f=s(i[1],i[2]),F=u?t.angle:De(t.angle);let d=u?t.angle+nt:De(90-t.angle);const g=u?e.angle:De(e.angle);let m=u?e.angle+nt:De(90-e.angle);d>it&&(d-=it),m>it&&(m-=it);const C=(t,e,u,n)=>{const r=[Math.cos(e),Math.sin(e)];return t+(se(r,u)+se(r,n))/2>se(r,a)};return C((t.x2-t.x1)/2,F,c,f)&&C((t.y2-t.y1)/2,d,c,f)&&C((e.x2-e.x1)/2,g,h,l)&&C((e.y2-e.y1)/2,m,h,l)},t.isShallowEqual=function(t,e){if(w(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;if(f(t)!==f(e))return!1;if(S(t)!==S(e))return!1;let u=!0;return Object.keys(t).forEach((n=>!!w(t[n],e[n])||(u=!1,u))),u},t.isString=c,t.isType=r,t.isUndefined=t=>void 0===t,t.isValid=D,t.isValidNumber=m,t.isValidUrl=t=>new RegExp(/^(http(s)?:\/\/)\w+[^\s]+(\.[^\s]+){1,}$/).test(t),t.keys=T,t.last=N,t.lengthFromPointToLine=Ft,t.lineIntersectPolygon=Ne,t.lowerFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)},t.max=at,t.maxInArray=(t,e)=>{var u;if(0===t.length)return;let n=t[0];for(let r=1;r<t.length;r++){const i=t[r];(null!==(u=null==e?void 0:e(i,n))&&void 0!==u?u:i-n>0)&&(n=i)}return n},t.median=(t,e)=>{let u=t;return!0!==e&&(u=t.sort(k)),H(u,.5)},t.memoize=t=>{let e=null,u=null;return(...n)=>(e&&n.every(((t,u)=>t===e[u]))||(e=n,u=t(...n)),u)},t.merge=function(t,...e){let u=-1;const n=e.length;for(;++u<n;){E(t,e[u],!0)}return t},t.mergeAABB=function(t){const e=[];return function t(u,n){const r=[];n.forEach((t=>{let e;(e=Me(u,t)).length>1?r.push(t):u=e[0]})),e.push(u),r.length&&t(r[0],r.slice(1))}(t[0],t.slice(1)),e},t.millisecondsCount=Ju,t.millisecondsFloor=Xu,t.millisecondsGetterName=Ke,t.millisecondsOffset=Zu,t.millisecondsSetterName=function(t){return t?"setUTCMilliseconds":"setMilliseconds"},t.min=ht,t.minInArray=(t,e)=>{var u;if(0===t.length)return;let n=t[0];for(let r=1;r<t.length;r++){const i=t[r];(null!==(u=null==e?void 0:e(i,n))&&void 0!==u?u:i-n<0)&&(n=i)}return n},t.minuteCount=Ou,t.minuteField=Iu,t.minuteFloor=Uu,t.minuteOffset=Hu,t.minutesGetterName=Je,t.minutesSetterName=function(t){return t?"setUTCMinutes":"setMinutes"},t.mixin=function(t,e,u=!0){if(t="prototype"in t?t.prototype:t,e="prototype"in e?e.prototype:e,Object.getOwnPropertyNames){const n=Object.getOwnPropertyNames(e);for(let r=0;r<n.length;r++){const i=n[r];"constructor"!==i&&(u?null!=e[i]:null==t[i])&&(t[i]=e[i])}}else _(t,e,u)},t.monthCount=Fu,t.monthField=du,t.monthFloor=cu,t.monthGetterName=$e,t.monthOffset=fu,t.monthSetterName=function(t){return t?"setUTCMonth":"setMonth"},t.nelderMead=function(t,e,u){const n=(u=u||{}).maxIterations||200*e.length,r=u.nonZeroDelta||1.05,i=u.zeroDelta||.001,s=u.minErrorDelta||1e-6,o=u.minErrorDelta||1e-5,D=void 0!==u.rho?u.rho:1,a=void 0!==u.chi?u.chi:2,h=void 0!==u.psi?u.psi:-.5,l=void 0!==u.sigma?u.sigma:.5;let c;const f=e.length,F=new Array(f+1);F[0]=e,F[0].fx=t(e),F[0].id=0;for(let u=0;u<f;++u){const n=e.slice();n[u]=n[u]?n[u]*r:i,F[u+1]=n,F[u+1].fx=t(n),F[u+1].id=u+1}function d(t){for(let e=0;e<t.length;e++)F[f][e]=t[e];F[f].fx=t.fx}const g=function(t,e){return t.fx-e.fx},m=e.slice(),C=e.slice(),p=e.slice(),y=e.slice();for(let e=0;e<n;++e){if(F.sort(g),u.history){const t=F.map((function(t){const e=t.slice();return e.fx=t.fx,e.id=t.id,e}));t.sort((function(t,e){return t.id-e.id})),u.history.push({x:F[0].slice(),fx:F[0].fx,simplex:t})}c=0;for(let t=0;t<f;++t)c=Math.max(c,Math.abs(F[0][t]-F[1][t]));if(Math.abs(F[0].fx-F[f].fx)<s&&c<o)break;for(let t=0;t<f;++t){m[t]=0;for(let e=0;e<f;++e)m[t]+=F[e][t];m[t]/=f}const e=F[f];if(vn(C,1+D,m,-D,e),C.fx=t(C),C.fx<F[0].fx)vn(y,1+a,m,-a,e),y.fx=t(y),y.fx<C.fx?d(y):d(C);else if(C.fx>=F[f-1].fx){let u=!1;if(C.fx>e.fx?(vn(p,1+h,m,-h,e),p.fx=t(p),p.fx<e.fx?d(p):u=!0):(vn(p,1-h*D,m,h*D,e),p.fx=t(p),p.fx<C.fx?d(p):u=!0),u){if(l>=1)break;for(let e=1;e<F.length;++e)vn(F[e],1-l,F[0],l,F[e]),F[e].fx=t(F[e])}}else d(C)}return F.sort(g),{fx:F[0].fx,x:F[0]}},t.norm2=Bn,t.normalTransform=function(t,e,u,n,r,i,s,o){const D=e.a,a=e.b,h=e.c,l=e.d,c=e.e,f=e.f,F=Dt(s),d=lt(s);let g,m;o?(g=o[0],m=o[1]):(g=u,m=n);const C=g-u,p=m-n,y=D*F+h*d,x=a*F+l*d,E=h*F-D*d,M=l*F-a*d;t.a=r*y,t.b=r*x,t.c=i*E,t.d=i*M,t.e=c+D*g+h*m-y*C-E*p,t.f=f+a*g+l*m-x*C-M*p},t.normalizePadding=function(t){if(m(t))return[t,t,t,t];if(f(t)){const e=t.length;if(1===e){const e=t[0];return[e,e,e,e]}if(2===e){const[e,u]=t;return[e,u,e,u]}if(3===e){const[e,u,n]=t;return[e,u,n,u]}if(4===e)return t}if(a(t)){const{top:e=0,right:u=0,bottom:n=0,left:r=0}=t;return[e,u,n,r]}return[0,0,0,0]},t.numberSpecifierReg=gn,t.pad=q,t.parseUint8ToImageData=(t,e,u)=>{const n=new Uint8ClampedArray(t),r=new Uint8ClampedArray(t.length);for(let t=u-1;t>=0;t--)for(let i=0;i<e;i++){const s=t*e*4+4*i,o=(u-t)*e*4+4*i;r[o]=n[s],r[o+1]=n[s+1],r[o+2]=n[s+2],r[o+3]=n[s+3]}return new ImageData(r,e,u)},t.pi=ut,t.pi2=it,t.pick=function(t,e){if(!t||!l(t))return t;const u={};return e.forEach((e=>{b.call(t,e)&&(u[e]=t[e])})),u},t.pickWithout=function(t,e){if(!t||!l(t))return t;const u={};return Object.keys(t).forEach((n=>{const r=t[n];let i=!1;e.forEach((t=>{(c(t)&&t===n||t instanceof RegExp&&n.match(t))&&(i=!0)})),i||(u[n]=r)})),u},t.pointAt=function(t,e,u,n,r){let i,s;return"number"==typeof t&&"number"==typeof u&&(i=(1-r)*t+r*u),"number"==typeof e&&"number"==typeof n&&(s=(1-r)*e+r*n),{x:i,y:s}},t.pointBetweenLine=Te,t.pointInAABB=function(t,e){return ie(t,e,!1)},t.pointInLine=ve,t.pointInOBB=function(t,e){return Be.x=(e.point1.x+e.point2.x)/2,Be.y=(e.point1.y+e.point2.y)/2,be.x=(e.point3.x+e.point4.x)/2,be.y=(e.point3.y+e.point4.y)/2,ve(t,Be,be,e.height)},t.pointInRect=ie,t.polarToCartesian=function(t,e,u){return{x:t.x+e*Math.cos(u),y:t.y+e*Math.sin(u)}},t.polygonContainPoint=ke,t.polygonIntersectPolygon=function(t,e){for(let u=0;u<e.length;u++){if(ke(t,e[u].x,e[u].y))return!0;if(u>0&&Ne(e[u-1].x,e[u-1].y,e[u].x,e[u].y,t))return!0}return!1},t.pow=ft,t.precisionAdd=function(t,e){return pt(t+e,10**Math.max(yt(t),yt(e)))},t.precisionSub=function(t,e){return pt(t-e,10**Math.max(yt(t),yt(e)))},t.quantileSorted=H,t.radianToDegree=At,t.range=function(t,e,u){D(e)||(e=t,t=0),D(u)||(u=1);let n=-1;const r=0|Math.max(0,Math.ceil((e-t)/u)),i=new Array(r);for(;++n<r;)i[n]=t+n*u;return i},t.rectInsideAnotherRect=function(e,u,n){return e&&u?(Xt=e.x1,Zt=e.x2,Jt=e.y1,Qt=e.y2,Kt=u.x1,te=u.x2,ee=u.y1,ue=u.y2,n&&(Xt>Zt&&([Xt,Zt]=[Zt,Xt]),Jt>Qt&&([Jt,Qt]=[Qt,Jt]),Kt>te&&([Kt,te]=[te,Kt]),ee>ue&&([ee,ue]=[ue,ee])),Xt>Kt&&Zt<te&&Jt>ee&&Qt<ue?t.InnerBBox.BBOX1:Kt>Xt&&te<Zt&&ee>Jt&&ue<Qt?t.InnerBBox.BBOX2:t.InnerBBox.NONE):t.InnerBBox.NONE},t.rgbToHex=qt,t.rgbToHsl=kt,t.scale=bn,t.secondCount=zu,t.secondField=qu,t.secondFloor=ju,t.secondOffset=Yu,t.secondsGetterName=Qe,t.secondsSetterName=function(t){return t?"setUTCSeconds":"setSeconds"},t.shuffleArray=function(t,e=Math.random){let u,n,r=t.length;for(;r;)u=Math.floor(e()*r),n=t[--r],t[r]=t[u],t[u]=n;return t},t.sin=lt,t.span=t=>t.length<=1?0:N(t)-t[0],t.sqrt=ct,t.stringWidth=function(t,e=!0){if("string"!=typeof t||0===t.length)return 0;if(0===(t=Oe(t)).length)return 0;t=t.replace(Pe()," ");const u=e?1:2;let n=0;for(const e of t){const t=e.codePointAt(0);if(t<=31||t>=127&&t<=159)continue;if(t>=768&&t<=879)continue;switch(Re(e)){case"F":case"W":n+=2;break;case"A":n+=u;break;default:n+=1}}return n},t.substitute=function(t,e){return t&&e?t.replace(/\\?\{([^{}]+)\}/g,((t,u)=>"\\"===t.charAt(0)?t.slice(1):void 0===e[u]?"":e[u])):t},t.tau=rt,t.throttle=function(t,e,u){let n=!0,r=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return a(u)&&(n="leading"in u?!!u.leading:n,r="trailing"in u?!!u.trailing:r),$(t,e,{leading:n,trailing:r,maxWait:e})},t.tickStep=function(t,e,u){const n=Math.abs(e-t)/Math.max(0,u);let r=Math.pow(10,Math.floor(Math.log(n)/Math.LN10));const i=n/r;return i>=I?r*=10:i>=R?r*=5:i>=P&&(r*=2),e<t?-r:r},t.toDate=K,t.toNumber=U,t.toValidNumber=function(t){if(m(t))return t;const e=+t;return m(e)?e:0},t.transformBounds=function(t,e,u,n,r,i,s){if(!(st(n)<=et||st(r)<=et)){if(1!==n&&t.scaleX(n),1!==r&&t.scaleY(r),isFinite(i)&&Math.abs(i)>et){let e=0,u=0;void 0!==s&&(e=s[0],u=s[1]),t.rotate(i,e,u)}t.translate(e,u)}},t.transformBoundsWithMatrix=Bt,t.truncate=(t,e,u="right",n)=>{const r=o(n)?"…":n,i=t+"",s=i.length,D=Math.max(0,e-r.length);return s<=e?i:"left"===u?r+i.slice(s-D):"center"===u?i.slice(0,Math.ceil(D/2))+r+i.slice(s-Math.floor(D/2)):i.slice(0,D)+r},t.unionAABB=Me,t.uniqArray=function(t){return t&&f(t)?Array.from(new Set(L(t))):t},t.upperFirst=function(t){return t.charAt(0).toUpperCase()+t.substring(1)},t.utcDayCount=vu,t.utcDayField=Au,t.utcDayFloor=Bu,t.utcDayOffset=bu,t.utcHourField=ku,t.utcHourFloor=Lu,t.utcHourOffset=Nu,t.utcMinuteField=Wu,t.utcMinuteFloor=Ru,t.utcMinuteOffset=Pu,t.utcMonthCount=Cu,t.utcMonthField=pu,t.utcMonthFloor=gu,t.utcMonthOffset=mu,t.utcSecondField=$u,t.utcSecondFloor=Gu,t.utcSecondOffset=Vu,t.utcYearCount=hu,t.utcYearField=lu,t.utcYearFloor=Du,t.utcYearOffset=au,t.uuid=(t,e)=>{const u="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),n=[];let r;if(e=e||u.length,t)for(r=0;r<t;r++)n[r]=u[0|Math.random()*e];else{let t;for(n[8]=n[13]=n[18]=n[23]="-",n[14]="4",r=0;r<36;r++)n[r]||(t=0|16*Math.random(),n[r]=u[19===r?3&t|8:t])}return n.join("")},t.variance=O,t.weightedSum=vn,t.yearCount=su,t.yearField=ou,t.yearFloor=ru,t.yearOffset=iu,t.zeros=Mn,t.zerosM=function(t,e){return Mn(t).map((function(){return Mn(e)}))}}));
|
package/es/fmin/bisect.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { Logger } from "../logger";
|
|
2
|
+
|
|
1
3
|
export function findZeroOfFunction(f, a, b, parameters) {
|
|
2
4
|
const maxIterations = (parameters = parameters || {}).maxIterations || 100, tolerance = parameters.tolerance || 1e-10, fA = f(a), fB = f(b);
|
|
3
5
|
let delta = b - a;
|
|
4
|
-
if (fA * fB > 0)
|
|
6
|
+
if (fA * fB > 0) {
|
|
7
|
+
return Logger.getInstance().error("Initial bisect points must have opposite signs"),
|
|
8
|
+
NaN;
|
|
9
|
+
}
|
|
5
10
|
if (0 === fA) return a;
|
|
6
11
|
if (0 === fB) return b;
|
|
7
12
|
for (let i = 0; i < maxIterations; ++i) {
|
package/es/fmin/bisect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/fmin/bisect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/fmin/bisect.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAInC,MAAM,UAAU,kBAAkB,CAAC,CAAM,EAAE,CAAM,EAAE,CAAM,EAAE,UAAgB;IACzE,UAAU,GAAG,UAAU,IAAI,EAAE,CAAC;IAC9B,MAAM,aAAa,GAAG,UAAU,CAAC,aAAa,IAAI,GAAG,CAAC;IACtD,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,IAAI,KAAK,CAAC;IAChD,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAChB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAChB,IAAI,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC;IAElB,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE;QACf,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;QACpC,MAAM,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;QAC/D,OAAO,GAAG,CAAC;KACZ;IAED,IAAI,EAAE,KAAK,CAAC,EAAE;QACZ,OAAO,CAAC,CAAC;KACV;IACD,IAAI,EAAE,KAAK,CAAC,EAAE;QACZ,OAAO,CAAC,CAAC;KACV;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,EAAE,EAAE,CAAC,EAAE;QACtC,KAAK,IAAI,CAAC,CAAC;QACX,MAAM,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC;QACtB,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QAEpB,IAAI,IAAI,GAAG,EAAE,IAAI,CAAC,EAAE;YAClB,CAAC,GAAG,GAAG,CAAC;SACT;QAED,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,SAAS,IAAI,IAAI,KAAK,CAAC,EAAE;YAC7C,OAAO,GAAG,CAAC;SACZ;KACF;IACD,OAAO,CAAC,GAAG,KAAK,CAAC;AACnB,CAAC","file":"bisect.js","sourcesContent":["/* Adapted from fmin by Ben Frederickson\n * https://github.com/benfred/fmin\n * Licensed under the BSD-3-Clause\n\n * url: https://github.com/benfred/fmin/blob/master/src/bisect.js\n * License: https://github.com/benfred/fmin/blob/master/LICENSE\n * @license\n */\n\nimport { Logger } from '../logger';\n\n/** finds the zeros of a function, given two starting points (which must\n * have opposite signs */\nexport function findZeroOfFunction(f: any, a: any, b: any, parameters?: any) {\n parameters = parameters || {};\n const maxIterations = parameters.maxIterations || 100;\n const tolerance = parameters.tolerance || 1e-10;\n const fA = f(a);\n const fB = f(b);\n let delta = b - a;\n\n if (fA * fB > 0) {\n const logger = Logger.getInstance();\n logger.error('Initial bisect points must have opposite signs');\n return NaN;\n }\n\n if (fA === 0) {\n return a;\n }\n if (fB === 0) {\n return b;\n }\n\n for (let i = 0; i < maxIterations; ++i) {\n delta /= 2;\n const mid = a + delta;\n const fMid = f(mid);\n\n if (fMid * fA >= 0) {\n a = mid;\n }\n\n if (Math.abs(delta) < tolerance || fMid === 0) {\n return mid;\n }\n }\n return a + delta;\n}\n"]}
|
package/es/fmin/blas1.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export declare function zeros(x: number): number[];
|
|
2
2
|
export declare function zerosM(x: number, y: number): number[][];
|
|
3
|
-
export declare function dot(a: number[], b: number[]): number;
|
|
4
3
|
export declare function norm2(a: number[]): number;
|
|
5
4
|
export declare function scale(ret: number[], value: number[], c: number): void;
|
|
6
5
|
export declare function weightedSum(ret: number[], w1: number, v1: number[], w2: number, v2: number[]): void;
|
package/es/fmin/blas1.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { dotProduct } from "../math";
|
|
2
|
+
|
|
1
3
|
export function zeros(x) {
|
|
2
4
|
const r = new Array(x);
|
|
3
5
|
for (let i = 0; i < x; ++i) r[i] = 0;
|
|
@@ -10,14 +12,8 @@ export function zerosM(x, y) {
|
|
|
10
12
|
}));
|
|
11
13
|
}
|
|
12
14
|
|
|
13
|
-
export function dot(a, b) {
|
|
14
|
-
let ret = 0;
|
|
15
|
-
for (let i = 0; i < a.length; ++i) ret += a[i] * b[i];
|
|
16
|
-
return ret;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
15
|
export function norm2(a) {
|
|
20
|
-
return Math.sqrt(
|
|
16
|
+
return Math.sqrt(dotProduct(a, a));
|
|
21
17
|
}
|
|
22
18
|
|
|
23
19
|
export function scale(ret, value, c) {
|
|
@@ -29,6 +25,6 @@ export function weightedSum(ret, w1, v1, w2, v2) {
|
|
|
29
25
|
}
|
|
30
26
|
|
|
31
27
|
export function gemv(output, A, x) {
|
|
32
|
-
for (let i = 0; i < output.length; ++i) output[i] =
|
|
28
|
+
for (let i = 0; i < output.length; ++i) output[i] = dotProduct(A[i], x);
|
|
33
29
|
}
|
|
34
30
|
//# sourceMappingURL=blas1.js.map
|
package/es/fmin/blas1.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/fmin/blas1.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/fmin/blas1.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAIrC,MAAM,UAAU,KAAK,CAAC,CAAS;IAC7B,MAAM,CAAC,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;IACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;QAC1B,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;KACV;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AACD,MAAM,UAAU,MAAM,CAAC,CAAS,EAAE,CAAS;IACzC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QAClB,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,CAAW;IAC/B,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,GAAa,EAAE,KAAe,EAAE,CAAS;IAC7D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACrC,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;KACvB;AACH,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAa,EAAE,EAAU,EAAE,EAAY,EAAE,EAAU,EAAE,EAAY;IAC3F,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACnC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;KAClC;AACH,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,MAAgB,EAAE,CAAa,EAAE,CAAW;IAC/D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACtC,MAAM,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KACjC;AACH,CAAC","file":"blas1.js","sourcesContent":["/* Adapted from fmin by Ben Frederickson\n * https://github.com/benfred/fmin\n * Licensed under the BSD-3-Clause\n\n * url: https://github.com/benfred/fmin/blob/master/src/blas1.js\n * License: https://github.com/benfred/fmin/blob/master/LICENSE\n * @license\n */\n\nimport { dotProduct } from '../math';\n\n// need some basic operations on vectors, rather than adding a dependency,\n// just define here\nexport function zeros(x: number): number[] {\n const r = new Array(x);\n for (let i = 0; i < x; ++i) {\n r[i] = 0;\n }\n return r;\n}\nexport function zerosM(x: number, y: number) {\n return zeros(x).map(function () {\n return zeros(y);\n });\n}\n\nexport function norm2(a: number[]) {\n return Math.sqrt(dotProduct(a, a));\n}\n\nexport function scale(ret: number[], value: number[], c: number) {\n for (let i = 0; i < value.length; ++i) {\n ret[i] = value[i] * c;\n }\n}\n\nexport function weightedSum(ret: number[], w1: number, v1: number[], w2: number, v2: number[]) {\n for (let j = 0; j < ret.length; ++j) {\n ret[j] = w1 * v1[j] + w2 * v2[j];\n }\n}\n\nexport function gemv(output: number[], A: number[][], x: number[]) {\n for (let i = 0; i < output.length; ++i) {\n output[i] = dotProduct(A[i], x);\n }\n}\n"]}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dotProduct } from "../math";
|
|
2
|
+
|
|
3
|
+
import { norm2, scale, weightedSum } from "./blas1";
|
|
2
4
|
|
|
3
5
|
import { wolfeLineSearch } from "./linesearch";
|
|
4
6
|
|
|
@@ -26,7 +28,7 @@ export function conjugateGradient(f, initial, params) {
|
|
|
26
28
|
alpha: a
|
|
27
29
|
}), a) {
|
|
28
30
|
weightedSum(yk, 1, next.fxprime, -1, current.fxprime);
|
|
29
|
-
const delta_k =
|
|
31
|
+
const delta_k = dotProduct(current.fxprime, current.fxprime), beta_k = Math.max(0, dotProduct(yk, next.fxprime) / delta_k);
|
|
30
32
|
weightedSum(pk, beta_k, pk, -1, next.fxprime), temp = current, current = next, next = temp;
|
|
31
33
|
} else scale(pk, current.fxprime, -1);
|
|
32
34
|
if (norm2(current.fxprime) <= 1e-5) break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/fmin/conjugate-gradient.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"sources":["../src/fmin/conjugate-gradient.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,UAAU,iBAAiB,CAAC,CAAM,EAAE,OAAY,EAAE,MAAW;IAGjE,IAAI,OAAO,GAAG,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;IACtE,IAAI,IAAI,GAAG,EAAE,CAAC,EAAE,OAAO,CAAC,KA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O,CAAC,OAAO,CAAC,CAAC;YAEtD,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;YAC7D,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC;YAEnE,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YAE9C,IAAI,GAAG,OAAO,CAAC;YACf,OAAO,GAAG,IAAI,CAAC;YACf,IAAI,GAAG,IAAI,CAAC;SACb;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE;YAClC,MAAM;SACP;KACF;IAED,IAAI,MAAM,CAAC,OAAO,EAAE;QAClB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;KAC3G;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","file":"conjugate-gradient.js","sourcesContent":["/* Adapted from fmin by Ben Frederickson\n * https://github.com/benfred/fmin\n * Licensed under the BSD-3-Clause\n\n * url: https://github.com/benfred/fmin/blob/master/src/conjugateGradient.js\n * License: https://github.com/benfred/fmin/blob/master/LICENSE\n * @license\n */\n\nimport { dotProduct } from '../math';\nimport { norm2, scale, weightedSum } from './blas1';\nimport { wolfeLineSearch } from './linesearch';\n\nexport function conjugateGradient(f: any, initial: any, params: any) {\n // allocate all memory up front here, keep out of the loop for perfomance\n // reasons\n let current = { x: initial.slice(), fx: 0, fxprime: initial.slice() };\n let next = { x: initial.slice(), fx: 0, fxprime: initial.slice() };\n const yk = initial.slice();\n let temp;\n let a = 1;\n\n params = params || {};\n const maxIterations = params.maxIterations || initial.length * 20;\n\n current.fx = f(current.x, current.fxprime);\n const pk = current.fxprime.slice();\n scale(pk, current.fxprime, -1);\n\n for (let i = 0; i < maxIterations; ++i) {\n a = wolfeLineSearch(f, pk, current, next, a);\n\n // todo: history in wrong spot?\n if (params.history) {\n params.history.push({ x: current.x.slice(), fx: current.fx, fxprime: current.fxprime.slice(), alpha: a });\n }\n\n if (!a) {\n // faiiled to find point that satifies wolfe conditions.\n // reset direction for next iteration\n scale(pk, current.fxprime, -1);\n } else {\n // update direction using Polak–Ribiere CG method\n weightedSum(yk, 1, next.fxprime, -1, current.fxprime);\n\n const delta_k = dotProduct(current.fxprime, current.fxprime);\n const beta_k = Math.max(0, dotProduct(yk, next.fxprime) / delta_k);\n\n weightedSum(pk, beta_k, pk, -1, next.fxprime);\n\n temp = current;\n current = next;\n next = temp;\n }\n\n if (norm2(current.fxprime) <= 1e-5) {\n break;\n }\n }\n\n if (params.history) {\n params.history.push({ x: current.x.slice(), fx: current.fx, fxprime: current.fxprime.slice(), alpha: a });\n }\n\n return current;\n}\n"]}
|
package/es/fmin/linesearch.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dotProduct } from "../math";
|
|
2
|
+
|
|
3
|
+
import { weightedSum } from "./blas1";
|
|
2
4
|
|
|
3
5
|
export function wolfeLineSearch(f, pk, current, next, a, c1, c2) {
|
|
4
|
-
const phi0 = current.fx, phiPrime0 =
|
|
6
|
+
const phi0 = current.fx, phiPrime0 = dotProduct(current.fxprime, pk);
|
|
5
7
|
let phi = phi0, phi_old = phi0, phiPrime = phiPrime0, a0 = 0;
|
|
6
8
|
function zoom(a_lo, a_high, phi_lo) {
|
|
7
9
|
for (let iteration = 0; iteration < 16; ++iteration) if (a = (a_lo + a_high) / 2,
|
|
8
10
|
weightedSum(next.x, 1, current.x, a, pk), phi = next.fx = f(next.x, next.fxprime),
|
|
9
|
-
phiPrime =
|
|
11
|
+
phiPrime = dotProduct(next.fxprime, pk), phi > phi0 + c1 * a * phiPrime0 || phi >= phi_lo) a_high = a; else {
|
|
10
12
|
if (Math.abs(phiPrime) <= -c2 * phiPrime0) return a;
|
|
11
13
|
phiPrime * (a_high - a_lo) >= 0 && (a_high = a_lo), a_lo = a, phi_lo = phi;
|
|
12
14
|
}
|
|
@@ -15,7 +17,7 @@ export function wolfeLineSearch(f, pk, current, next, a, c1, c2) {
|
|
|
15
17
|
a = a || 1, c1 = c1 || 1e-6, c2 = c2 || .1;
|
|
16
18
|
for (let iteration = 0; iteration < 10; ++iteration) {
|
|
17
19
|
if (weightedSum(next.x, 1, current.x, a, pk), phi = next.fx = f(next.x, next.fxprime),
|
|
18
|
-
phiPrime =
|
|
20
|
+
phiPrime = dotProduct(next.fxprime, pk), phi > phi0 + c1 * a * phiPrime0 || iteration && phi >= phi_old) return zoom(a0, a, phi_old);
|
|
19
21
|
if (Math.abs(phiPrime) <= -c2 * phiPrime0) return a;
|
|
20
22
|
if (phiPrime >= 0) return zoom(a, a0, phi);
|
|
21
23
|
phi_old = phi, a0 = a, a *= 2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/fmin/linesearch.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"sources":["../src/fmin/linesearch.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAStC,MAAM,UAAU,eAAe,CAAC,CAAM,EAAE,EAAY,EAAE,OAAY,EAAE,IAAS,EAAE,CAAS,EAAE,EAAW,EAAE,EAAW;IAChH,MAAM,IAAI,GAAG,OAAO,CAAC,EAAE,CAAC;IACxB,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAClD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IAED,KAAK,IAAI,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,EAAE,EAAE,EAAE,SAAS,EAAE;QACnD,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAC3C,GAAG,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACxC,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACxC,IAAI,GAAG,GAAG,IAAI,GAAG,EAAE,GAAG,CAAC,GAAG,SAAS,IAAI,CAAC,SAAS,IAAI,GAAG,IAAI,OAAO,CAAC,EAAE;YACpE,OAAO,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;SAC7B;QAED,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,GAAG,SAAS,EAAE;YACzC,OAAO,CAAC,CAAC;SACV;QAED,IAAI,QAAQ,IAAI,CAAC,EAAE;YACjB,OAAO,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;SACzB;QAED,OAAO,GAAG,GAAG,CAAC;QACd,EAAE,GAAG,CAAC,CAAC;QACP,CAAC,IAAI,CAAC,CAAC;KACR;IAED,OAAO,CAAC,CAAC;AACX,CAAC","file":"linesearch.js","sourcesContent":["/* Adapted from fmin by Ben Frederickson\n * https://github.com/benfred/fmin\n * Licensed under the BSD-3-Clause\n\n * url: https://github.com/benfred/fmin/blob/master/src/linesearch.js\n * License: https://github.com/benfred/fmin/blob/master/LICENSE\n * @license\n */\n\nimport { dotProduct } from '../math';\nimport { weightedSum } from './blas1';\n\n/// searches along line 'pk' for a point that satifies the wolfe conditions\n/// See 'Numerical Optimization' by Nocedal and Wright p59-60\n/// f : objective function\n/// pk : search direction\n/// current: object containing current gradient/loss\n/// next: output: contains next gradient/loss\n/// returns a: step size taken\nexport function wolfeLineSearch(f: any, pk: number[], current: any, next: any, a: number, c1?: number, c2?: number) {\n const phi0 = current.fx;\n const phiPrime0 = dotProduct(current.fxprime, pk);\n let phi = phi0;\n let phi_old = phi0;\n let phiPrime = phiPrime0;\n let a0 = 0;\n\n a = a || 1;\n c1 = c1 || 1e-6;\n c2 = c2 || 0.1;\n\n function zoom(a_lo: number, a_high: number, phi_lo: number) {\n for (let iteration = 0; iteration < 16; ++iteration) {\n a = (a_lo + a_high) / 2;\n weightedSum(next.x, 1.0, current.x, a, pk);\n phi = next.fx = f(next.x, next.fxprime);\n phiPrime = dotProduct(next.fxprime, pk);\n\n if (phi > phi0 + c1 * a * phiPrime0 || phi >= phi_lo) {\n a_high = a;\n } else {\n if (Math.abs(phiPrime) <= -c2 * phiPrime0) {\n return a;\n }\n\n if (phiPrime * (a_high - a_lo) >= 0) {\n a_high = a_lo;\n }\n\n a_lo = a;\n phi_lo = phi;\n }\n }\n\n return 0;\n }\n\n for (let iteration = 0; iteration < 10; ++iteration) {\n weightedSum(next.x, 1.0, current.x, a, pk);\n phi = next.fx = f(next.x, next.fxprime);\n phiPrime = dotProduct(next.fxprime, pk);\n if (phi > phi0 + c1 * a * phiPrime0 || (iteration && phi >= phi_old)) {\n return zoom(a0, a, phi_old);\n }\n\n if (Math.abs(phiPrime) <= -c2 * phiPrime0) {\n return a;\n }\n\n if (phiPrime >= 0) {\n return zoom(a, a0, phi);\n }\n\n phi_old = phi;\n a0 = a;\n a *= 2;\n }\n\n return a;\n}\n"]}
|
package/es/math.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ export declare function crossProductPoint(dir1: {
|
|
|
61
61
|
x: number;
|
|
62
62
|
y: number;
|
|
63
63
|
}): number;
|
|
64
|
+
export declare function dotProduct(a: number[] | Float32Array, b: number[] | Float32Array): number;
|
|
64
65
|
export declare function fuzzyEqualNumber(a: number, b: number): boolean;
|
|
65
66
|
export declare function fuzzyEqualVec(a: vec2, b: vec2): boolean;
|
|
66
67
|
export declare function fixPrecision(num: number, precision?: number): number;
|
package/es/math.js
CHANGED
|
@@ -62,6 +62,12 @@ export function crossProductPoint(dir1, dir2) {
|
|
|
62
62
|
return dir1.x * dir2.y - dir1.y * dir2.x;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
export function dotProduct(a, b) {
|
|
66
|
+
let ret = 0;
|
|
67
|
+
for (let i = 0; i < a.length; ++i) ret += a[i] * b[i];
|
|
68
|
+
return ret;
|
|
69
|
+
}
|
|
70
|
+
|
|
65
71
|
export function fuzzyEqualNumber(a, b) {
|
|
66
72
|
return abs(a - b) < 1e-12;
|
|
67
73
|
}
|
package/es/math.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/math.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,CAAC;AAC7B,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;AAC1B,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,GAAG,CAAC,CAAC;AAC7B,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;AAC1B,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AACnC,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC;AACtC,MAAM,CAAC,MAAM,qBAAqB,GAAG,SAAS,CAAC;AAC/C,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,CAAC;AAC7C,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;AA2B/B,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AAC5B,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;AAChC,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AAC5B,M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12;\nexport const pi = Math.PI;\nexport const halfPi = pi / 2;\nexport const tau = 2 * pi;\nexport const NEWTON_ITERATIONS = 4;\nexport const NEWTON_MIN_SLOPE = 0.001;\nexport const SUBDIVISION_PRECISION = 0.0000001;\nexport const SUBDIVISION_MAX_ITERATIONS = 10;\nexport const pi2 = Math.PI * 2;\n\nexport type vec2 = [number, number] | Float32Array;\nexport type vec3 = [number, number, number] | Float32Array;\nexport type vec4 = [number, number, number, number] | Float32Array;\nexport type vec8 = [number, number, number, number, number, number, number, number] | Float32Array;\nexport type mat4 =\n | [\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number\n ]\n | Float32Array;\n\nexport const abs = Math.abs;\nexport const atan2 = Math.atan2;\nexport const cos = Math.cos;\nexport const max = Math.max;\nexport const min = Math.min;\nexport const sin = Math.sin;\nexport const sqrt = Math.sqrt;\nexport const pow = Math.pow;\n\nexport function acos(x: number) {\n return x > 1 ? 0 : x < -1 ? pi : Math.acos(x);\n}\n\nexport function asin(x: number) {\n return x >= 1 ? halfPi : x <= -1 ? -halfPi : Math.asin(x);\n}\n\n/**\n * 根据比例获直线上的点\n * @param {number} x1 起始点 x\n * @param {number} y1 起始点 y\n * @param {number} x2 结束点 x\n * @param {number} y2 结束点 y\n * @param {number} t 指定比例\n * @return {object} 包含 x, y 的点\n */\nexport function pointAt(\n x1: number | null | undefined,\n y1: number | null | undefined,\n x2: number | null | undefined,\n y2: number | null | undefined,\n t: number\n): {\n x: undefined | number;\n y: undefined | number;\n} {\n let x: number | undefined;\n let y: number | undefined;\n if (typeof x1 === 'number' && typeof x2 === 'number') {\n x = (1 - t) * x1 + t * x2;\n }\n if (typeof y1 === 'number' && typeof y2 === 'number') {\n y = (1 - t) * y1 + t * y2;\n }\n return {\n x,\n y\n };\n}\n\nexport function lengthFromPointToLine(\n point: { x: number; y: number },\n point1: { x: number; y: number },\n point2: { x: number; y: number }\n): number {\n // 面积\n const dir1X = point2.x - point1.x;\n const dir1Y = point2.y - point1.y;\n const dir2X = point.x - point1.x;\n const dir2Y = point.y - point1.y;\n const s = Math.abs(dir1X * dir2Y - dir2X * dir1Y);\n const length = Math.sqrt(dir1X * dir1X + dir1Y * dir1Y);\n return s / length;\n}\n\nexport function crossProduct(dir1: vec2, dir2: vec2): number {\n return dir1[0] * dir2[1] - dir1[1] * dir2[0];\n}\n\nexport function crossProductPoint(dir1: { x: number; y: number }, dir2: { x: number; y: number }): number {\n return dir1.x * dir2.y - dir1.y * dir2.x;\n}\n\nexport function fuzzyEqualNumber(a: number, b: number): boolean {\n return abs(a - b) < epsilon;\n}\n\nexport function fuzzyEqualVec(a: vec2, b: vec2): boolean {\n return abs(a[0] - b[0]) + abs(a[1] - b[1]) < epsilon;\n}\n\nexport function fixPrecision(num: number, precision = 10) {\n return Math.round(num * precision) / precision;\n}\n\nexport function getDecimalPlaces(n: number): number {\n const dStr = n.toString().split(/[eE]/);\n const s = (dStr[0].split('.')[1] || '').length - (+dStr[1] || 0);\n return s > 0 ? s : 0;\n}\n\nexport function precisionAdd(a: number, b: number) {\n return fixPrecision(a + b, 10 ** Math.max(getDecimalPlaces(a), getDecimalPlaces(b)));\n}\n\nexport function precisionSub(a: number, b: number) {\n return fixPrecision(a - b, 10 ** Math.max(getDecimalPlaces(a), getDecimalPlaces(b)));\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/math.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,CAAC;AAC7B,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;AAC1B,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,GAAG,CAAC,CAAC;AAC7B,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;AAC1B,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AACnC,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC;AACt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AAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACjE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,CAAS,EAAE,CAAS;IAC/C,OAAO,YAAY,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvF,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,CAAS,EAAE,CAAS;IAC/C,OAAO,YAAY,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvF,CAAC","file":"math.js","sourcesContent":["export const epsilon = 1e-12;\nexport const pi = Math.PI;\nexport const halfPi = pi / 2;\nexport const tau = 2 * pi;\nexport const NEWTON_ITERATIONS = 4;\nexport const NEWTON_MIN_SLOPE = 0.001;\nexport const SUBDIVISION_PRECISION = 0.0000001;\nexport const SUBDIVISION_MAX_ITERATIONS = 10;\nexport const pi2 = Math.PI * 2;\n\nexport type vec2 = [number, number] | Float32Array;\nexport type vec3 = [number, number, number] | Float32Array;\nexport type vec4 = [number, number, number, number] | Float32Array;\nexport type vec8 = [number, number, number, number, number, number, number, number] | Float32Array;\nexport type mat4 =\n | [\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number\n ]\n | Float32Array;\n\nexport const abs = Math.abs;\nexport const atan2 = Math.atan2;\nexport const cos = Math.cos;\nexport const max = Math.max;\nexport const min = Math.min;\nexport const sin = Math.sin;\nexport const sqrt = Math.sqrt;\nexport const pow = Math.pow;\n\nexport function acos(x: number) {\n return x > 1 ? 0 : x < -1 ? pi : Math.acos(x);\n}\n\nexport function asin(x: number) {\n return x >= 1 ? halfPi : x <= -1 ? -halfPi : Math.asin(x);\n}\n\n/**\n * 根据比例获直线上的点\n * @param {number} x1 起始点 x\n * @param {number} y1 起始点 y\n * @param {number} x2 结束点 x\n * @param {number} y2 结束点 y\n * @param {number} t 指定比例\n * @return {object} 包含 x, y 的点\n */\nexport function pointAt(\n x1: number | null | undefined,\n y1: number | null | undefined,\n x2: number | null | undefined,\n y2: number | null | undefined,\n t: number\n): {\n x: undefined | number;\n y: undefined | number;\n} {\n let x: number | undefined;\n let y: number | undefined;\n if (typeof x1 === 'number' && typeof x2 === 'number') {\n x = (1 - t) * x1 + t * x2;\n }\n if (typeof y1 === 'number' && typeof y2 === 'number') {\n y = (1 - t) * y1 + t * y2;\n }\n return {\n x,\n y\n };\n}\n\nexport function lengthFromPointToLine(\n point: { x: number; y: number },\n point1: { x: number; y: number },\n point2: { x: number; y: number }\n): number {\n // 面积\n const dir1X = point2.x - point1.x;\n const dir1Y = point2.y - point1.y;\n const dir2X = point.x - point1.x;\n const dir2Y = point.y - point1.y;\n const s = Math.abs(dir1X * dir2Y - dir2X * dir1Y);\n const length = Math.sqrt(dir1X * dir1X + dir1Y * dir1Y);\n return s / length;\n}\n\nexport function crossProduct(dir1: vec2, dir2: vec2): number {\n return dir1[0] * dir2[1] - dir1[1] * dir2[0];\n}\n\nexport function crossProductPoint(dir1: { x: number; y: number }, dir2: { x: number; y: number }): number {\n return dir1.x * dir2.y - dir1.y * dir2.x;\n}\n\nexport function dotProduct(a: number[] | Float32Array, b: number[] | Float32Array): number {\n let ret = 0;\n for (let i = 0; i < a.length; ++i) {\n ret += a[i] * b[i];\n }\n return ret;\n}\n\nexport function fuzzyEqualNumber(a: number, b: number): boolean {\n return abs(a - b) < epsilon;\n}\n\nexport function fuzzyEqualVec(a: vec2, b: vec2): boolean {\n return abs(a[0] - b[0]) + abs(a[1] - b[1]) < epsilon;\n}\n\nexport function fixPrecision(num: number, precision = 10) {\n return Math.round(num * precision) / precision;\n}\n\nexport function getDecimalPlaces(n: number): number {\n const dStr = n.toString().split(/[eE]/);\n const s = (dStr[0].split('.')[1] || '').length - (+dStr[1] || 0);\n return s > 0 ? s : 0;\n}\n\nexport function precisionAdd(a: number, b: number) {\n return fixPrecision(a + b, 10 ** Math.max(getDecimalPlaces(a), getDecimalPlaces(b)));\n}\n\nexport function precisionSub(a: number, b: number) {\n return fixPrecision(a - b, 10 ** Math.max(getDecimalPlaces(a), getDecimalPlaces(b)));\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visactor/vutils",
|
|
3
|
-
"version": "0.18.2
|
|
3
|
+
"version": "0.18.2",
|
|
4
4
|
"main": "cjs/index.js",
|
|
5
5
|
"module": "es/index.js",
|
|
6
6
|
"types": "es/index.d.ts",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"@types/jest": "~29.5.0",
|
|
28
28
|
"typescript": "4.9.5",
|
|
29
29
|
"@types/node": "*",
|
|
30
|
-
"@internal/eslint-config": "0.0.1",
|
|
31
30
|
"@internal/bundler": "0.0.1",
|
|
32
31
|
"@internal/ts-config": "0.0.1",
|
|
33
|
-
"@internal/jest-config": "0.0.1"
|
|
32
|
+
"@internal/jest-config": "0.0.1",
|
|
33
|
+
"@internal/eslint-config": "0.0.1"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"eventemitter3": "^4.0.7",
|