@ylzcc/editor 0.8.4 → 0.10.0
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/README.md +26 -26
- package/dist/editor.es.js +414 -416
- package/dist/editor.umd.js +11 -9
- package/package.json +99 -99
package/dist/editor.es.js
CHANGED
|
@@ -12434,7 +12434,7 @@ const applyStyles$1 = {
|
|
|
12434
12434
|
function getBasePlacement$1(Ff) {
|
|
12435
12435
|
return Ff.split("-")[0];
|
|
12436
12436
|
}
|
|
12437
|
-
var max = Math.max, min = Math.min, round = Math.round;
|
|
12437
|
+
var max = Math.max, min = Math.min, round$1 = Math.round;
|
|
12438
12438
|
function getUAString() {
|
|
12439
12439
|
var Ff = navigator.userAgentData;
|
|
12440
12440
|
return Ff != null && Ff.brands && Array.isArray(Ff.brands) ? Ff.brands.map(function(kh) {
|
|
@@ -12447,7 +12447,7 @@ function isLayoutViewport() {
|
|
|
12447
12447
|
function getBoundingClientRect(Ff, kh, x_) {
|
|
12448
12448
|
kh === void 0 && (kh = !1), x_ === void 0 && (x_ = !1);
|
|
12449
12449
|
var B_ = Ff.getBoundingClientRect(), $_ = 1, $P = 1;
|
|
12450
|
-
kh && isHTMLElement(Ff) && ($_ = Ff.offsetWidth > 0 && round(B_.width) / Ff.offsetWidth || 1, $P = Ff.offsetHeight > 0 && round(B_.height) / Ff.offsetHeight || 1);
|
|
12450
|
+
kh && isHTMLElement(Ff) && ($_ = Ff.offsetWidth > 0 && round$1(B_.width) / Ff.offsetWidth || 1, $P = Ff.offsetHeight > 0 && round$1(B_.height) / Ff.offsetHeight || 1);
|
|
12451
12451
|
var zP = isElement$1(Ff) ? getWindow(Ff) : window, eme = zP.visualViewport, tme = !isLayoutViewport() && x_, nme = (B_.left + (tme && eme ? eme.offsetLeft : 0)) / $_, rme = (B_.top + (tme && eme ? eme.offsetTop : 0)) / $P, ime = B_.width / $_, ame = B_.height / $P;
|
|
12452
12452
|
return {
|
|
12453
12453
|
width: ime,
|
|
@@ -12595,8 +12595,8 @@ var unsetSides = {
|
|
|
12595
12595
|
function roundOffsetsByDPR(Ff, kh) {
|
|
12596
12596
|
var x_ = Ff.x, B_ = Ff.y, $_ = kh.devicePixelRatio || 1;
|
|
12597
12597
|
return {
|
|
12598
|
-
x: round(x_ * $_) / $_ || 0,
|
|
12599
|
-
y: round(B_ * $_) / $_ || 0
|
|
12598
|
+
x: round$1(x_ * $_) / $_ || 0,
|
|
12599
|
+
y: round$1(B_ * $_) / $_ || 0
|
|
12600
12600
|
};
|
|
12601
12601
|
}
|
|
12602
12602
|
function mapToStyles(Ff) {
|
|
@@ -13079,7 +13079,7 @@ function getNodeScroll(Ff) {
|
|
|
13079
13079
|
return Ff === getWindow(Ff) || !isHTMLElement(Ff) ? getWindowScroll(Ff) : getHTMLElementScroll(Ff);
|
|
13080
13080
|
}
|
|
13081
13081
|
function isElementScaled(Ff) {
|
|
13082
|
-
var kh = Ff.getBoundingClientRect(), x_ = round(kh.width) / Ff.offsetWidth || 1, B_ = round(kh.height) / Ff.offsetHeight || 1;
|
|
13082
|
+
var kh = Ff.getBoundingClientRect(), x_ = round$1(kh.width) / Ff.offsetWidth || 1, B_ = round$1(kh.height) / Ff.offsetHeight || 1;
|
|
13083
13083
|
return x_ !== 1 || B_ !== 1;
|
|
13084
13084
|
}
|
|
13085
13085
|
function getCompositeRect(Ff, kh, x_) {
|
|
@@ -28233,7 +28233,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`), Ame = Pme, Vme = Dme)
|
|
|
28233
28233
|
var highlight$2 = HLJS$1({}), core$1 = highlight$2;
|
|
28234
28234
|
highlight$2.HighlightJS = highlight$2;
|
|
28235
28235
|
highlight$2.default = highlight$2;
|
|
28236
|
-
const HighlightJS$
|
|
28236
|
+
const HighlightJS$1 = /* @__PURE__ */ getDefaultExportFromCjs(core$1);
|
|
28237
28237
|
var format = { exports: {} };
|
|
28238
28238
|
(function(Ff) {
|
|
28239
28239
|
(function() {
|
|
@@ -28313,21 +28313,21 @@ function highlight$1(Ff, kh, x_ = {}) {
|
|
|
28313
28313
|
let B_ = x_.prefix;
|
|
28314
28314
|
if (typeof Ff != "string")
|
|
28315
28315
|
throw fault("Expected `string` for name, got `%s`", Ff);
|
|
28316
|
-
if (!HighlightJS$
|
|
28316
|
+
if (!HighlightJS$1.getLanguage(Ff))
|
|
28317
28317
|
throw fault("Unknown language: `%s` is not registered", Ff);
|
|
28318
28318
|
if (typeof kh != "string")
|
|
28319
28319
|
throw fault("Expected `string` for value, got `%s`", kh);
|
|
28320
|
-
B_ == null && (B_ = defaultPrefix), HighlightJS$
|
|
28320
|
+
B_ == null && (B_ = defaultPrefix), HighlightJS$1.configure({ __emitter: HastEmitter, classPrefix: B_ });
|
|
28321
28321
|
const $_ = (
|
|
28322
28322
|
/** @type {HighlightResult & {_emitter: HastEmitter}} */
|
|
28323
|
-
HighlightJS$
|
|
28323
|
+
HighlightJS$1.highlight(kh, { language: Ff, ignoreIllegals: !0 })
|
|
28324
28324
|
);
|
|
28325
|
-
if (HighlightJS$
|
|
28325
|
+
if (HighlightJS$1.configure({}), $_.errorRaised)
|
|
28326
28326
|
throw $_.errorRaised;
|
|
28327
28327
|
return $_._emitter.root.data.language = $_.language, $_._emitter.root.data.relevance = $_.relevance, $_._emitter.root;
|
|
28328
28328
|
}
|
|
28329
28329
|
function highlightAuto(Ff, kh = {}) {
|
|
28330
|
-
const x_ = kh.subset || HighlightJS$
|
|
28330
|
+
const x_ = kh.subset || HighlightJS$1.listLanguages();
|
|
28331
28331
|
kh.prefix;
|
|
28332
28332
|
let B_ = -1, $_ = {
|
|
28333
28333
|
type: "root",
|
|
@@ -28338,7 +28338,7 @@ function highlightAuto(Ff, kh = {}) {
|
|
|
28338
28338
|
throw fault("Expected `string` for value, got `%s`", Ff);
|
|
28339
28339
|
for (; ++B_ < x_.length; ) {
|
|
28340
28340
|
const $P = x_[B_];
|
|
28341
|
-
if (!HighlightJS$
|
|
28341
|
+
if (!HighlightJS$1.getLanguage($P))
|
|
28342
28342
|
continue;
|
|
28343
28343
|
const zP = highlight$1($P, Ff, kh);
|
|
28344
28344
|
zP.data.relevance > $_.data.relevance && ($_ = zP);
|
|
@@ -28346,7 +28346,7 @@ function highlightAuto(Ff, kh = {}) {
|
|
|
28346
28346
|
return $_;
|
|
28347
28347
|
}
|
|
28348
28348
|
function registerLanguage(Ff, kh) {
|
|
28349
|
-
HighlightJS$
|
|
28349
|
+
HighlightJS$1.registerLanguage(Ff, kh);
|
|
28350
28350
|
}
|
|
28351
28351
|
const registerAlias = (
|
|
28352
28352
|
/**
|
|
@@ -28362,19 +28362,19 @@ const registerAlias = (
|
|
|
28362
28362
|
*/
|
|
28363
28363
|
function(Ff, kh) {
|
|
28364
28364
|
if (typeof Ff == "string")
|
|
28365
|
-
HighlightJS$
|
|
28365
|
+
HighlightJS$1.registerAliases(kh, { languageName: Ff });
|
|
28366
28366
|
else {
|
|
28367
28367
|
let x_;
|
|
28368
28368
|
for (x_ in Ff)
|
|
28369
|
-
own$4.call(Ff, x_) && HighlightJS$
|
|
28369
|
+
own$4.call(Ff, x_) && HighlightJS$1.registerAliases(Ff[x_], { languageName: x_ });
|
|
28370
28370
|
}
|
|
28371
28371
|
}
|
|
28372
28372
|
);
|
|
28373
|
-
function registered
|
|
28374
|
-
return !!HighlightJS$
|
|
28373
|
+
function registered(Ff) {
|
|
28374
|
+
return !!HighlightJS$1.getLanguage(Ff);
|
|
28375
28375
|
}
|
|
28376
28376
|
function listLanguages() {
|
|
28377
|
-
return HighlightJS$
|
|
28377
|
+
return HighlightJS$1.listLanguages();
|
|
28378
28378
|
}
|
|
28379
28379
|
class HastEmitter {
|
|
28380
28380
|
/**
|
|
@@ -28451,7 +28451,7 @@ const lowlight = {
|
|
|
28451
28451
|
highlight: highlight$1,
|
|
28452
28452
|
highlightAuto,
|
|
28453
28453
|
registerLanguage,
|
|
28454
|
-
registered
|
|
28454
|
+
registered,
|
|
28455
28455
|
listLanguages,
|
|
28456
28456
|
registerAlias
|
|
28457
28457
|
};
|
|
@@ -30657,7 +30657,6 @@ highlight.newInstance = () => HLJS({});
|
|
|
30657
30657
|
var core = highlight;
|
|
30658
30658
|
highlight.HighlightJS = highlight;
|
|
30659
30659
|
highlight.default = highlight;
|
|
30660
|
-
const HighlightJS$1 = /* @__PURE__ */ getDefaultExportFromCjs(core);
|
|
30661
30660
|
function parseNodes(Ff, kh = []) {
|
|
30662
30661
|
return Ff.map((x_) => {
|
|
30663
30662
|
const B_ = [...kh, ...x_.properties ? x_.properties.className : []];
|
|
@@ -30670,9 +30669,6 @@ function parseNodes(Ff, kh = []) {
|
|
|
30670
30669
|
function getHighlightNodes(Ff) {
|
|
30671
30670
|
return Ff.value || Ff.children || [];
|
|
30672
30671
|
}
|
|
30673
|
-
function registered(Ff) {
|
|
30674
|
-
return !!HighlightJS$1.getLanguage(Ff);
|
|
30675
|
-
}
|
|
30676
30672
|
function getDecorations({
|
|
30677
30673
|
doc: Ff,
|
|
30678
30674
|
name: kh,
|
|
@@ -30682,7 +30678,7 @@ function getDecorations({
|
|
|
30682
30678
|
const $_ = [], $P = x_.listLanguages();
|
|
30683
30679
|
return findChildren(Ff, (zP) => zP.type.name === kh).forEach((zP) => {
|
|
30684
30680
|
let eme = zP.pos + 1;
|
|
30685
|
-
const tme = zP.node.attrs.language || B_, nme = tme &&
|
|
30681
|
+
const tme = zP.node.attrs.language || B_, nme = tme && $P.includes(tme) ? getHighlightNodes(x_.highlight(tme, zP.node.textContent)) : getHighlightNodes(x_.highlightAuto(zP.node.textContent));
|
|
30686
30682
|
parseNodes(nme).forEach((rme) => {
|
|
30687
30683
|
const ime = eme + rme.text.length;
|
|
30688
30684
|
if (rme.classes.length) {
|
|
@@ -57437,10 +57433,10 @@ function _extends() {
|
|
|
57437
57433
|
for (var kh = 1; kh < arguments.length; kh++) {
|
|
57438
57434
|
var x_ = arguments[kh];
|
|
57439
57435
|
for (var B_ in x_)
|
|
57440
|
-
|
|
57436
|
+
({}).hasOwnProperty.call(x_, B_) && (Ff[B_] = x_[B_]);
|
|
57441
57437
|
}
|
|
57442
57438
|
return Ff;
|
|
57443
|
-
}, _extends.apply(
|
|
57439
|
+
}, _extends.apply(null, arguments);
|
|
57444
57440
|
}
|
|
57445
57441
|
function _arrayWithHoles(Ff) {
|
|
57446
57442
|
if (Array.isArray(Ff))
|
|
@@ -57474,7 +57470,7 @@ function _iterableToArrayLimit(Ff, kh) {
|
|
|
57474
57470
|
}
|
|
57475
57471
|
function _arrayLikeToArray(Ff, kh) {
|
|
57476
57472
|
(kh == null || kh > Ff.length) && (kh = Ff.length);
|
|
57477
|
-
for (var x_ = 0, B_ =
|
|
57473
|
+
for (var x_ = 0, B_ = Array(kh); x_ < kh; x_++)
|
|
57478
57474
|
B_[x_] = Ff[x_];
|
|
57479
57475
|
return B_;
|
|
57480
57476
|
}
|
|
@@ -57482,11 +57478,8 @@ function _unsupportedIterableToArray(Ff, kh) {
|
|
|
57482
57478
|
if (Ff) {
|
|
57483
57479
|
if (typeof Ff == "string")
|
|
57484
57480
|
return _arrayLikeToArray(Ff, kh);
|
|
57485
|
-
var x_ =
|
|
57486
|
-
|
|
57487
|
-
return Array.from(Ff);
|
|
57488
|
-
if (x_ === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(x_))
|
|
57489
|
-
return _arrayLikeToArray(Ff, kh);
|
|
57481
|
+
var x_ = {}.toString.call(Ff).slice(8, -1);
|
|
57482
|
+
return x_ === "Object" && Ff.constructor && (x_ = Ff.constructor.name), x_ === "Map" || x_ === "Set" ? Array.from(Ff) : x_ === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(x_) ? _arrayLikeToArray(Ff, kh) : void 0;
|
|
57490
57483
|
}
|
|
57491
57484
|
}
|
|
57492
57485
|
function _nonIterableRest() {
|
|
@@ -57518,10 +57511,10 @@ function toPrimitive(Ff, kh) {
|
|
|
57518
57511
|
}
|
|
57519
57512
|
function toPropertyKey(Ff) {
|
|
57520
57513
|
var kh = toPrimitive(Ff, "string");
|
|
57521
|
-
return _typeof(kh) == "symbol" ? kh :
|
|
57514
|
+
return _typeof(kh) == "symbol" ? kh : kh + "";
|
|
57522
57515
|
}
|
|
57523
57516
|
function _defineProperty(Ff, kh, x_) {
|
|
57524
|
-
return kh = toPropertyKey(kh)
|
|
57517
|
+
return (kh = toPropertyKey(kh)) in Ff ? Object.defineProperty(Ff, kh, {
|
|
57525
57518
|
value: x_,
|
|
57526
57519
|
enumerable: !0,
|
|
57527
57520
|
configurable: !0,
|
|
@@ -57531,21 +57524,25 @@ function _defineProperty(Ff, kh, x_) {
|
|
|
57531
57524
|
function _objectWithoutPropertiesLoose(Ff, kh) {
|
|
57532
57525
|
if (Ff == null)
|
|
57533
57526
|
return {};
|
|
57534
|
-
var x_ = {}
|
|
57535
|
-
for (
|
|
57536
|
-
|
|
57527
|
+
var x_ = {};
|
|
57528
|
+
for (var B_ in Ff)
|
|
57529
|
+
if ({}.hasOwnProperty.call(Ff, B_)) {
|
|
57530
|
+
if (kh.indexOf(B_) !== -1)
|
|
57531
|
+
continue;
|
|
57532
|
+
x_[B_] = Ff[B_];
|
|
57533
|
+
}
|
|
57537
57534
|
return x_;
|
|
57538
57535
|
}
|
|
57539
57536
|
function _objectWithoutProperties(Ff, kh) {
|
|
57540
57537
|
if (Ff == null)
|
|
57541
57538
|
return {};
|
|
57542
|
-
var x_ = _objectWithoutPropertiesLoose(Ff, kh)
|
|
57539
|
+
var x_, B_, $_ = _objectWithoutPropertiesLoose(Ff, kh);
|
|
57543
57540
|
if (Object.getOwnPropertySymbols) {
|
|
57544
57541
|
var $P = Object.getOwnPropertySymbols(Ff);
|
|
57545
|
-
for (
|
|
57546
|
-
|
|
57542
|
+
for (B_ = 0; B_ < $P.length; B_++)
|
|
57543
|
+
x_ = $P[B_], kh.indexOf(x_) === -1 && {}.propertyIsEnumerable.call(Ff, x_) && ($_[x_] = Ff[x_]);
|
|
57547
57544
|
}
|
|
57548
|
-
return
|
|
57545
|
+
return $_;
|
|
57549
57546
|
}
|
|
57550
57547
|
var classnames = { exports: {} };
|
|
57551
57548
|
/*!
|
|
@@ -57584,348 +57581,360 @@ var classnames = { exports: {} };
|
|
|
57584
57581
|
})();
|
|
57585
57582
|
})(classnames);
|
|
57586
57583
|
var classnamesExports = classnames.exports;
|
|
57587
|
-
const classNames = /* @__PURE__ */ getDefaultExportFromCjs(classnamesExports);
|
|
57588
|
-
function
|
|
57589
|
-
|
|
57590
|
-
|
|
57591
|
-
|
|
57592
|
-
|
|
57593
|
-
|
|
57594
|
-
|
|
57595
|
-
|
|
57596
|
-
|
|
57597
|
-
return
|
|
57598
|
-
}
|
|
57599
|
-
|
|
57600
|
-
|
|
57601
|
-
|
|
57602
|
-
function
|
|
57603
|
-
|
|
57604
|
-
}
|
|
57605
|
-
|
|
57606
|
-
|
|
57607
|
-
|
|
57608
|
-
|
|
57609
|
-
|
|
57610
|
-
|
|
57611
|
-
|
|
57612
|
-
|
|
57613
|
-
|
|
57614
|
-
|
|
57615
|
-
|
|
57616
|
-
|
|
57617
|
-
|
|
57618
|
-
|
|
57619
|
-
|
|
57620
|
-
|
|
57621
|
-
|
|
57622
|
-
else {
|
|
57623
|
-
var zP = x_ < 0.5 ? x_ * (1 + kh) : x_ + kh - x_ * kh, eme = 2 * x_ - zP;
|
|
57624
|
-
B_ = hue2rgb(eme, zP, Ff + 1 / 3), $_ = hue2rgb(eme, zP, Ff), $P = hue2rgb(eme, zP, Ff - 1 / 3);
|
|
57584
|
+
const classNames = /* @__PURE__ */ getDefaultExportFromCjs(classnamesExports), round = Math.round;
|
|
57585
|
+
function splitColorStr(Ff, kh) {
|
|
57586
|
+
const x_ = Ff.replace(/^[^(]*\((.*)/, "$1").replace(/\).*/, "").match(/\d*\.?\d+%?/g) || [], B_ = x_.map(($_) => parseFloat($_));
|
|
57587
|
+
for (let $_ = 0; $_ < 3; $_ += 1)
|
|
57588
|
+
B_[$_] = kh(B_[$_] || 0, x_[$_] || "", $_);
|
|
57589
|
+
return x_[3] ? B_[3] = x_[3].includes("%") ? B_[3] / 100 : B_[3] : B_[3] = 1, B_;
|
|
57590
|
+
}
|
|
57591
|
+
const parseHSVorHSL = (Ff, kh, x_) => x_ === 0 ? Ff : Ff / 100;
|
|
57592
|
+
function limitRange(Ff, kh) {
|
|
57593
|
+
const x_ = kh || 255;
|
|
57594
|
+
return Ff > x_ ? x_ : Ff < 0 ? 0 : Ff;
|
|
57595
|
+
}
|
|
57596
|
+
class FastColor {
|
|
57597
|
+
constructor(kh) {
|
|
57598
|
+
_defineProperty(this, "isValid", !0), _defineProperty(this, "r", 0), _defineProperty(this, "g", 0), _defineProperty(this, "b", 0), _defineProperty(this, "a", 1), _defineProperty(this, "_h", void 0), _defineProperty(this, "_s", void 0), _defineProperty(this, "_l", void 0), _defineProperty(this, "_v", void 0), _defineProperty(this, "_max", void 0), _defineProperty(this, "_min", void 0), _defineProperty(this, "_brightness", void 0);
|
|
57599
|
+
function x_(B_) {
|
|
57600
|
+
return B_[0] in kh && B_[1] in kh && B_[2] in kh;
|
|
57601
|
+
}
|
|
57602
|
+
if (kh)
|
|
57603
|
+
if (typeof kh == "string") {
|
|
57604
|
+
let $_ = function($P) {
|
|
57605
|
+
return B_.startsWith($P);
|
|
57606
|
+
};
|
|
57607
|
+
const B_ = kh.trim();
|
|
57608
|
+
/^#?[A-F\d]{3,8}$/i.test(B_) ? this.fromHexString(B_) : $_("rgb") ? this.fromRgbString(B_) : $_("hsl") ? this.fromHslString(B_) : ($_("hsv") || $_("hsb")) && this.fromHsvString(B_);
|
|
57609
|
+
} else if (kh instanceof FastColor)
|
|
57610
|
+
this.r = kh.r, this.g = kh.g, this.b = kh.b, this.a = kh.a, this._h = kh._h, this._s = kh._s, this._l = kh._l, this._v = kh._v;
|
|
57611
|
+
else if (x_("rgb"))
|
|
57612
|
+
this.r = limitRange(kh.r), this.g = limitRange(kh.g), this.b = limitRange(kh.b), this.a = typeof kh.a == "number" ? limitRange(kh.a, 1) : 1;
|
|
57613
|
+
else if (x_("hsl"))
|
|
57614
|
+
this.fromHsl(kh);
|
|
57615
|
+
else if (x_("hsv"))
|
|
57616
|
+
this.fromHsv(kh);
|
|
57617
|
+
else
|
|
57618
|
+
throw new Error("@ant-design/fast-color: unsupported input " + JSON.stringify(kh));
|
|
57625
57619
|
}
|
|
57626
|
-
|
|
57627
|
-
|
|
57628
|
-
|
|
57629
|
-
|
|
57630
|
-
|
|
57631
|
-
|
|
57632
|
-
|
|
57633
|
-
|
|
57634
|
-
|
|
57635
|
-
|
|
57636
|
-
|
|
57620
|
+
// ======================= Setter =======================
|
|
57621
|
+
setR(kh) {
|
|
57622
|
+
return this._sc("r", kh);
|
|
57623
|
+
}
|
|
57624
|
+
setG(kh) {
|
|
57625
|
+
return this._sc("g", kh);
|
|
57626
|
+
}
|
|
57627
|
+
setB(kh) {
|
|
57628
|
+
return this._sc("b", kh);
|
|
57629
|
+
}
|
|
57630
|
+
setA(kh) {
|
|
57631
|
+
return this._sc("a", kh, 1);
|
|
57632
|
+
}
|
|
57633
|
+
setHue(kh) {
|
|
57634
|
+
const x_ = this.toHsv();
|
|
57635
|
+
return x_.h = kh, this._c(x_);
|
|
57636
|
+
}
|
|
57637
|
+
// ======================= Getter =======================
|
|
57638
|
+
/**
|
|
57639
|
+
* Returns the perceived luminance of a color, from 0-1.
|
|
57640
|
+
* @see http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
|
|
57641
|
+
*/
|
|
57642
|
+
getLuminance() {
|
|
57643
|
+
function kh($P) {
|
|
57644
|
+
const zP = $P / 255;
|
|
57645
|
+
return zP <= 0.03928 ? zP / 12.92 : Math.pow((zP + 0.055) / 1.055, 2.4);
|
|
57646
|
+
}
|
|
57647
|
+
const x_ = kh(this.r), B_ = kh(this.g), $_ = kh(this.b);
|
|
57648
|
+
return 0.2126 * x_ + 0.7152 * B_ + 0.0722 * $_;
|
|
57649
|
+
}
|
|
57650
|
+
getHue() {
|
|
57651
|
+
if (typeof this._h > "u") {
|
|
57652
|
+
const kh = this.getMax() - this.getMin();
|
|
57653
|
+
kh === 0 ? this._h = 0 : this._h = round(60 * (this.r === this.getMax() ? (this.g - this.b) / kh + (this.g < this.b ? 6 : 0) : this.g === this.getMax() ? (this.b - this.r) / kh + 2 : (this.r - this.g) / kh + 4));
|
|
57654
|
+
}
|
|
57655
|
+
return this._h;
|
|
57656
|
+
}
|
|
57657
|
+
getSaturation() {
|
|
57658
|
+
if (typeof this._s > "u") {
|
|
57659
|
+
const kh = this.getMax() - this.getMin();
|
|
57660
|
+
kh === 0 ? this._s = 0 : this._s = kh / this.getMax();
|
|
57661
|
+
}
|
|
57662
|
+
return this._s;
|
|
57663
|
+
}
|
|
57664
|
+
getLightness() {
|
|
57665
|
+
return typeof this._l > "u" && (this._l = (this.getMax() + this.getMin()) / 510), this._l;
|
|
57666
|
+
}
|
|
57667
|
+
getValue() {
|
|
57668
|
+
return typeof this._v > "u" && (this._v = this.getMax() / 255), this._v;
|
|
57669
|
+
}
|
|
57670
|
+
/**
|
|
57671
|
+
* Returns the perceived brightness of the color, from 0-255.
|
|
57672
|
+
* Note: this is not the b of HSB
|
|
57673
|
+
* @see http://www.w3.org/TR/AERT#color-contrast
|
|
57674
|
+
*/
|
|
57675
|
+
getBrightness() {
|
|
57676
|
+
return typeof this._brightness > "u" && (this._brightness = (this.r * 299 + this.g * 587 + this.b * 114) / 1e3), this._brightness;
|
|
57677
|
+
}
|
|
57678
|
+
// ======================== Func ========================
|
|
57679
|
+
darken(kh = 10) {
|
|
57680
|
+
const x_ = this.getHue(), B_ = this.getSaturation();
|
|
57681
|
+
let $_ = this.getLightness() - kh / 100;
|
|
57682
|
+
return $_ < 0 && ($_ = 0), this._c({
|
|
57683
|
+
h: x_,
|
|
57684
|
+
s: B_,
|
|
57685
|
+
l: $_,
|
|
57686
|
+
a: this.a
|
|
57687
|
+
});
|
|
57688
|
+
}
|
|
57689
|
+
lighten(kh = 10) {
|
|
57690
|
+
const x_ = this.getHue(), B_ = this.getSaturation();
|
|
57691
|
+
let $_ = this.getLightness() + kh / 100;
|
|
57692
|
+
return $_ > 1 && ($_ = 1), this._c({
|
|
57693
|
+
h: x_,
|
|
57694
|
+
s: B_,
|
|
57695
|
+
l: $_,
|
|
57696
|
+
a: this.a
|
|
57697
|
+
});
|
|
57698
|
+
}
|
|
57699
|
+
/**
|
|
57700
|
+
* Mix the current color a given amount with another color, from 0 to 100.
|
|
57701
|
+
* 0 means no mixing (return current color).
|
|
57702
|
+
*/
|
|
57703
|
+
mix(kh, x_ = 50) {
|
|
57704
|
+
const B_ = this._c(kh), $_ = x_ / 100, $P = (eme) => (B_[eme] - this[eme]) * $_ + this[eme], zP = {
|
|
57705
|
+
r: round($P("r")),
|
|
57706
|
+
g: round($P("g")),
|
|
57707
|
+
b: round($P("b")),
|
|
57708
|
+
a: round($P("a") * 100) / 100
|
|
57709
|
+
};
|
|
57710
|
+
return this._c(zP);
|
|
57711
|
+
}
|
|
57712
|
+
/**
|
|
57713
|
+
* Mix the color with pure white, from 0 to 100.
|
|
57714
|
+
* Providing 0 will do nothing, providing 100 will always return white.
|
|
57715
|
+
*/
|
|
57716
|
+
tint(kh = 10) {
|
|
57717
|
+
return this.mix({
|
|
57718
|
+
r: 255,
|
|
57719
|
+
g: 255,
|
|
57720
|
+
b: 255,
|
|
57721
|
+
a: 1
|
|
57722
|
+
}, kh);
|
|
57723
|
+
}
|
|
57724
|
+
/**
|
|
57725
|
+
* Mix the color with pure black, from 0 to 100.
|
|
57726
|
+
* Providing 0 will do nothing, providing 100 will always return black.
|
|
57727
|
+
*/
|
|
57728
|
+
shade(kh = 10) {
|
|
57729
|
+
return this.mix({
|
|
57730
|
+
r: 0,
|
|
57731
|
+
g: 0,
|
|
57732
|
+
b: 0,
|
|
57733
|
+
a: 1
|
|
57734
|
+
}, kh);
|
|
57735
|
+
}
|
|
57736
|
+
onBackground(kh) {
|
|
57737
|
+
const x_ = this._c(kh), B_ = this.a + x_.a * (1 - this.a), $_ = ($P) => round((this[$P] * this.a + x_[$P] * x_.a * (1 - this.a)) / B_);
|
|
57738
|
+
return this._c({
|
|
57739
|
+
r: $_("r"),
|
|
57740
|
+
g: $_("g"),
|
|
57741
|
+
b: $_("b"),
|
|
57742
|
+
a: B_
|
|
57743
|
+
});
|
|
57744
|
+
}
|
|
57745
|
+
// ======================= Status =======================
|
|
57746
|
+
isDark() {
|
|
57747
|
+
return this.getBrightness() < 128;
|
|
57748
|
+
}
|
|
57749
|
+
isLight() {
|
|
57750
|
+
return this.getBrightness() >= 128;
|
|
57751
|
+
}
|
|
57752
|
+
// ======================== MISC ========================
|
|
57753
|
+
equals(kh) {
|
|
57754
|
+
return this.r === kh.r && this.g === kh.g && this.b === kh.b && this.a === kh.a;
|
|
57755
|
+
}
|
|
57756
|
+
clone() {
|
|
57757
|
+
return this._c(this);
|
|
57758
|
+
}
|
|
57759
|
+
// ======================= Format =======================
|
|
57760
|
+
toHexString() {
|
|
57761
|
+
let kh = "#";
|
|
57762
|
+
const x_ = (this.r || 0).toString(16);
|
|
57763
|
+
kh += x_.length === 2 ? x_ : "0" + x_;
|
|
57764
|
+
const B_ = (this.g || 0).toString(16);
|
|
57765
|
+
kh += B_.length === 2 ? B_ : "0" + B_;
|
|
57766
|
+
const $_ = (this.b || 0).toString(16);
|
|
57767
|
+
if (kh += $_.length === 2 ? $_ : "0" + $_, typeof this.a == "number" && this.a >= 0 && this.a < 1) {
|
|
57768
|
+
const $P = round(this.a * 255).toString(16);
|
|
57769
|
+
kh += $P.length === 2 ? $P : "0" + $P;
|
|
57770
|
+
}
|
|
57771
|
+
return kh;
|
|
57772
|
+
}
|
|
57773
|
+
/** CSS support color pattern */
|
|
57774
|
+
toHsl() {
|
|
57775
|
+
return {
|
|
57776
|
+
h: this.getHue(),
|
|
57777
|
+
s: this.getSaturation(),
|
|
57778
|
+
l: this.getLightness(),
|
|
57779
|
+
a: this.a
|
|
57780
|
+
};
|
|
57781
|
+
}
|
|
57782
|
+
/** CSS support color pattern */
|
|
57783
|
+
toHslString() {
|
|
57784
|
+
const kh = this.getHue(), x_ = round(this.getSaturation() * 100), B_ = round(this.getLightness() * 100);
|
|
57785
|
+
return this.a !== 1 ? `hsla(${kh},${x_}%,${B_}%,${this.a})` : `hsl(${kh},${x_}%,${B_}%)`;
|
|
57786
|
+
}
|
|
57787
|
+
/** Same as toHsb */
|
|
57788
|
+
toHsv() {
|
|
57789
|
+
return {
|
|
57790
|
+
h: this.getHue(),
|
|
57791
|
+
s: this.getSaturation(),
|
|
57792
|
+
v: this.getValue(),
|
|
57793
|
+
a: this.a
|
|
57794
|
+
};
|
|
57795
|
+
}
|
|
57796
|
+
toRgb() {
|
|
57797
|
+
return {
|
|
57798
|
+
r: this.r,
|
|
57799
|
+
g: this.g,
|
|
57800
|
+
b: this.b,
|
|
57801
|
+
a: this.a
|
|
57802
|
+
};
|
|
57803
|
+
}
|
|
57804
|
+
toRgbString() {
|
|
57805
|
+
return this.a !== 1 ? `rgba(${this.r},${this.g},${this.b},${this.a})` : `rgb(${this.r},${this.g},${this.b})`;
|
|
57806
|
+
}
|
|
57807
|
+
toString() {
|
|
57808
|
+
return this.toRgbString();
|
|
57809
|
+
}
|
|
57810
|
+
// ====================== Privates ======================
|
|
57811
|
+
/** Return a new FastColor object with one channel changed */
|
|
57812
|
+
_sc(kh, x_, B_) {
|
|
57813
|
+
const $_ = this.clone();
|
|
57814
|
+
return $_[kh] = limitRange(x_, B_), $_;
|
|
57815
|
+
}
|
|
57816
|
+
_c(kh) {
|
|
57817
|
+
return new this.constructor(kh);
|
|
57818
|
+
}
|
|
57819
|
+
getMax() {
|
|
57820
|
+
return typeof this._max > "u" && (this._max = Math.max(this.r, this.g, this.b)), this._max;
|
|
57821
|
+
}
|
|
57822
|
+
getMin() {
|
|
57823
|
+
return typeof this._min > "u" && (this._min = Math.min(this.r, this.g, this.b)), this._min;
|
|
57824
|
+
}
|
|
57825
|
+
fromHexString(kh) {
|
|
57826
|
+
const x_ = kh.replace("#", "");
|
|
57827
|
+
function B_($_, $P) {
|
|
57828
|
+
return parseInt(x_[$_] + x_[$P || $_], 16);
|
|
57829
|
+
}
|
|
57830
|
+
x_.length < 6 ? (this.r = B_(0), this.g = B_(1), this.b = B_(2), this.a = x_[3] ? B_(3) / 255 : 1) : (this.r = B_(0, 1), this.g = B_(2, 3), this.b = B_(4, 5), this.a = x_[6] ? B_(6, 7) / 255 : 1);
|
|
57831
|
+
}
|
|
57832
|
+
fromHsl({
|
|
57833
|
+
h: kh,
|
|
57834
|
+
s: x_,
|
|
57835
|
+
l: B_,
|
|
57836
|
+
a: $_
|
|
57837
|
+
}) {
|
|
57838
|
+
if (this._h = kh % 360, this._s = x_, this._l = B_, this.a = typeof $_ == "number" ? $_ : 1, x_ <= 0) {
|
|
57839
|
+
const ame = round(B_ * 255);
|
|
57840
|
+
this.r = ame, this.g = ame, this.b = ame;
|
|
57841
|
+
}
|
|
57842
|
+
let $P = 0, zP = 0, eme = 0;
|
|
57843
|
+
const tme = kh / 60, nme = (1 - Math.abs(2 * B_ - 1)) * x_, rme = nme * (1 - Math.abs(tme % 2 - 1));
|
|
57844
|
+
tme >= 0 && tme < 1 ? ($P = nme, zP = rme) : tme >= 1 && tme < 2 ? ($P = rme, zP = nme) : tme >= 2 && tme < 3 ? (zP = nme, eme = rme) : tme >= 3 && tme < 4 ? (zP = rme, eme = nme) : tme >= 4 && tme < 5 ? ($P = rme, eme = nme) : tme >= 5 && tme < 6 && ($P = nme, eme = rme);
|
|
57845
|
+
const ime = B_ - nme / 2;
|
|
57846
|
+
this.r = round(($P + ime) * 255), this.g = round((zP + ime) * 255), this.b = round((eme + ime) * 255);
|
|
57847
|
+
}
|
|
57848
|
+
fromHsv({
|
|
57849
|
+
h: kh,
|
|
57850
|
+
s: x_,
|
|
57851
|
+
v: B_,
|
|
57852
|
+
a: $_
|
|
57853
|
+
}) {
|
|
57854
|
+
this._h = kh % 360, this._s = x_, this._v = B_, this.a = typeof $_ == "number" ? $_ : 1;
|
|
57855
|
+
const $P = round(B_ * 255);
|
|
57856
|
+
if (this.r = $P, this.g = $P, this.b = $P, x_ <= 0)
|
|
57857
|
+
return;
|
|
57858
|
+
const zP = kh / 60, eme = Math.floor(zP), tme = zP - eme, nme = round(B_ * (1 - x_) * 255), rme = round(B_ * (1 - x_ * tme) * 255), ime = round(B_ * (1 - x_ * (1 - tme)) * 255);
|
|
57859
|
+
switch (eme) {
|
|
57860
|
+
case 0:
|
|
57861
|
+
this.g = ime, this.b = nme;
|
|
57637
57862
|
break;
|
|
57638
|
-
case
|
|
57639
|
-
|
|
57863
|
+
case 1:
|
|
57864
|
+
this.r = rme, this.b = nme;
|
|
57865
|
+
break;
|
|
57866
|
+
case 2:
|
|
57867
|
+
this.r = nme, this.b = ime;
|
|
57640
57868
|
break;
|
|
57641
|
-
case
|
|
57642
|
-
|
|
57869
|
+
case 3:
|
|
57870
|
+
this.r = nme, this.g = rme;
|
|
57871
|
+
break;
|
|
57872
|
+
case 4:
|
|
57873
|
+
this.r = ime, this.g = nme;
|
|
57874
|
+
break;
|
|
57875
|
+
case 5:
|
|
57876
|
+
default:
|
|
57877
|
+
this.g = nme, this.b = rme;
|
|
57643
57878
|
break;
|
|
57644
57879
|
}
|
|
57645
|
-
$P /= 6;
|
|
57646
57880
|
}
|
|
57647
|
-
|
|
57648
|
-
|
|
57649
|
-
|
|
57650
|
-
|
|
57651
|
-
|
|
57652
|
-
|
|
57653
|
-
|
|
57654
|
-
|
|
57655
|
-
|
|
57656
|
-
|
|
57657
|
-
|
|
57658
|
-
|
|
57659
|
-
|
|
57660
|
-
|
|
57661
|
-
|
|
57662
|
-
|
|
57663
|
-
|
|
57664
|
-
}
|
|
57665
|
-
|
|
57666
|
-
|
|
57667
|
-
|
|
57668
|
-
|
|
57669
|
-
|
|
57670
|
-
|
|
57671
|
-
|
|
57672
|
-
aquamarine: "#7fffd4",
|
|
57673
|
-
azure: "#f0ffff",
|
|
57674
|
-
beige: "#f5f5dc",
|
|
57675
|
-
bisque: "#ffe4c4",
|
|
57676
|
-
black: "#000000",
|
|
57677
|
-
blanchedalmond: "#ffebcd",
|
|
57678
|
-
blue: "#0000ff",
|
|
57679
|
-
blueviolet: "#8a2be2",
|
|
57680
|
-
brown: "#a52a2a",
|
|
57681
|
-
burlywood: "#deb887",
|
|
57682
|
-
cadetblue: "#5f9ea0",
|
|
57683
|
-
chartreuse: "#7fff00",
|
|
57684
|
-
chocolate: "#d2691e",
|
|
57685
|
-
coral: "#ff7f50",
|
|
57686
|
-
cornflowerblue: "#6495ed",
|
|
57687
|
-
cornsilk: "#fff8dc",
|
|
57688
|
-
crimson: "#dc143c",
|
|
57689
|
-
cyan: "#00ffff",
|
|
57690
|
-
darkblue: "#00008b",
|
|
57691
|
-
darkcyan: "#008b8b",
|
|
57692
|
-
darkgoldenrod: "#b8860b",
|
|
57693
|
-
darkgray: "#a9a9a9",
|
|
57694
|
-
darkgreen: "#006400",
|
|
57695
|
-
darkgrey: "#a9a9a9",
|
|
57696
|
-
darkkhaki: "#bdb76b",
|
|
57697
|
-
darkmagenta: "#8b008b",
|
|
57698
|
-
darkolivegreen: "#556b2f",
|
|
57699
|
-
darkorange: "#ff8c00",
|
|
57700
|
-
darkorchid: "#9932cc",
|
|
57701
|
-
darkred: "#8b0000",
|
|
57702
|
-
darksalmon: "#e9967a",
|
|
57703
|
-
darkseagreen: "#8fbc8f",
|
|
57704
|
-
darkslateblue: "#483d8b",
|
|
57705
|
-
darkslategray: "#2f4f4f",
|
|
57706
|
-
darkslategrey: "#2f4f4f",
|
|
57707
|
-
darkturquoise: "#00ced1",
|
|
57708
|
-
darkviolet: "#9400d3",
|
|
57709
|
-
deeppink: "#ff1493",
|
|
57710
|
-
deepskyblue: "#00bfff",
|
|
57711
|
-
dimgray: "#696969",
|
|
57712
|
-
dimgrey: "#696969",
|
|
57713
|
-
dodgerblue: "#1e90ff",
|
|
57714
|
-
firebrick: "#b22222",
|
|
57715
|
-
floralwhite: "#fffaf0",
|
|
57716
|
-
forestgreen: "#228b22",
|
|
57717
|
-
fuchsia: "#ff00ff",
|
|
57718
|
-
gainsboro: "#dcdcdc",
|
|
57719
|
-
ghostwhite: "#f8f8ff",
|
|
57720
|
-
goldenrod: "#daa520",
|
|
57721
|
-
gold: "#ffd700",
|
|
57722
|
-
gray: "#808080",
|
|
57723
|
-
green: "#008000",
|
|
57724
|
-
greenyellow: "#adff2f",
|
|
57725
|
-
grey: "#808080",
|
|
57726
|
-
honeydew: "#f0fff0",
|
|
57727
|
-
hotpink: "#ff69b4",
|
|
57728
|
-
indianred: "#cd5c5c",
|
|
57729
|
-
indigo: "#4b0082",
|
|
57730
|
-
ivory: "#fffff0",
|
|
57731
|
-
khaki: "#f0e68c",
|
|
57732
|
-
lavenderblush: "#fff0f5",
|
|
57733
|
-
lavender: "#e6e6fa",
|
|
57734
|
-
lawngreen: "#7cfc00",
|
|
57735
|
-
lemonchiffon: "#fffacd",
|
|
57736
|
-
lightblue: "#add8e6",
|
|
57737
|
-
lightcoral: "#f08080",
|
|
57738
|
-
lightcyan: "#e0ffff",
|
|
57739
|
-
lightgoldenrodyellow: "#fafad2",
|
|
57740
|
-
lightgray: "#d3d3d3",
|
|
57741
|
-
lightgreen: "#90ee90",
|
|
57742
|
-
lightgrey: "#d3d3d3",
|
|
57743
|
-
lightpink: "#ffb6c1",
|
|
57744
|
-
lightsalmon: "#ffa07a",
|
|
57745
|
-
lightseagreen: "#20b2aa",
|
|
57746
|
-
lightskyblue: "#87cefa",
|
|
57747
|
-
lightslategray: "#778899",
|
|
57748
|
-
lightslategrey: "#778899",
|
|
57749
|
-
lightsteelblue: "#b0c4de",
|
|
57750
|
-
lightyellow: "#ffffe0",
|
|
57751
|
-
lime: "#00ff00",
|
|
57752
|
-
limegreen: "#32cd32",
|
|
57753
|
-
linen: "#faf0e6",
|
|
57754
|
-
magenta: "#ff00ff",
|
|
57755
|
-
maroon: "#800000",
|
|
57756
|
-
mediumaquamarine: "#66cdaa",
|
|
57757
|
-
mediumblue: "#0000cd",
|
|
57758
|
-
mediumorchid: "#ba55d3",
|
|
57759
|
-
mediumpurple: "#9370db",
|
|
57760
|
-
mediumseagreen: "#3cb371",
|
|
57761
|
-
mediumslateblue: "#7b68ee",
|
|
57762
|
-
mediumspringgreen: "#00fa9a",
|
|
57763
|
-
mediumturquoise: "#48d1cc",
|
|
57764
|
-
mediumvioletred: "#c71585",
|
|
57765
|
-
midnightblue: "#191970",
|
|
57766
|
-
mintcream: "#f5fffa",
|
|
57767
|
-
mistyrose: "#ffe4e1",
|
|
57768
|
-
moccasin: "#ffe4b5",
|
|
57769
|
-
navajowhite: "#ffdead",
|
|
57770
|
-
navy: "#000080",
|
|
57771
|
-
oldlace: "#fdf5e6",
|
|
57772
|
-
olive: "#808000",
|
|
57773
|
-
olivedrab: "#6b8e23",
|
|
57774
|
-
orange: "#ffa500",
|
|
57775
|
-
orangered: "#ff4500",
|
|
57776
|
-
orchid: "#da70d6",
|
|
57777
|
-
palegoldenrod: "#eee8aa",
|
|
57778
|
-
palegreen: "#98fb98",
|
|
57779
|
-
paleturquoise: "#afeeee",
|
|
57780
|
-
palevioletred: "#db7093",
|
|
57781
|
-
papayawhip: "#ffefd5",
|
|
57782
|
-
peachpuff: "#ffdab9",
|
|
57783
|
-
peru: "#cd853f",
|
|
57784
|
-
pink: "#ffc0cb",
|
|
57785
|
-
plum: "#dda0dd",
|
|
57786
|
-
powderblue: "#b0e0e6",
|
|
57787
|
-
purple: "#800080",
|
|
57788
|
-
rebeccapurple: "#663399",
|
|
57789
|
-
red: "#ff0000",
|
|
57790
|
-
rosybrown: "#bc8f8f",
|
|
57791
|
-
royalblue: "#4169e1",
|
|
57792
|
-
saddlebrown: "#8b4513",
|
|
57793
|
-
salmon: "#fa8072",
|
|
57794
|
-
sandybrown: "#f4a460",
|
|
57795
|
-
seagreen: "#2e8b57",
|
|
57796
|
-
seashell: "#fff5ee",
|
|
57797
|
-
sienna: "#a0522d",
|
|
57798
|
-
silver: "#c0c0c0",
|
|
57799
|
-
skyblue: "#87ceeb",
|
|
57800
|
-
slateblue: "#6a5acd",
|
|
57801
|
-
slategray: "#708090",
|
|
57802
|
-
slategrey: "#708090",
|
|
57803
|
-
snow: "#fffafa",
|
|
57804
|
-
springgreen: "#00ff7f",
|
|
57805
|
-
steelblue: "#4682b4",
|
|
57806
|
-
tan: "#d2b48c",
|
|
57807
|
-
teal: "#008080",
|
|
57808
|
-
thistle: "#d8bfd8",
|
|
57809
|
-
tomato: "#ff6347",
|
|
57810
|
-
turquoise: "#40e0d0",
|
|
57811
|
-
violet: "#ee82ee",
|
|
57812
|
-
wheat: "#f5deb3",
|
|
57813
|
-
white: "#ffffff",
|
|
57814
|
-
whitesmoke: "#f5f5f5",
|
|
57815
|
-
yellow: "#ffff00",
|
|
57816
|
-
yellowgreen: "#9acd32"
|
|
57817
|
-
};
|
|
57818
|
-
function inputToRGB(Ff) {
|
|
57819
|
-
var kh = { r: 0, g: 0, b: 0 }, x_ = 1, B_ = null, $_ = null, $P = null, zP = !1, eme = !1;
|
|
57820
|
-
return typeof Ff == "string" && (Ff = stringInputToObject(Ff)), typeof Ff == "object" && (isValidCSSUnit(Ff.r) && isValidCSSUnit(Ff.g) && isValidCSSUnit(Ff.b) ? (kh = rgbToRgb(Ff.r, Ff.g, Ff.b), zP = !0, eme = String(Ff.r).substr(-1) === "%" ? "prgb" : "rgb") : isValidCSSUnit(Ff.h) && isValidCSSUnit(Ff.s) && isValidCSSUnit(Ff.v) ? (B_ = convertToPercentage(Ff.s), $_ = convertToPercentage(Ff.v), kh = hsvToRgb(Ff.h, B_, $_), zP = !0, eme = "hsv") : isValidCSSUnit(Ff.h) && isValidCSSUnit(Ff.s) && isValidCSSUnit(Ff.l) && (B_ = convertToPercentage(Ff.s), $P = convertToPercentage(Ff.l), kh = hslToRgb(Ff.h, B_, $P), zP = !0, eme = "hsl"), Object.prototype.hasOwnProperty.call(Ff, "a") && (x_ = Ff.a)), x_ = boundAlpha(x_), {
|
|
57821
|
-
ok: zP,
|
|
57822
|
-
format: Ff.format || eme,
|
|
57823
|
-
r: Math.min(255, Math.max(kh.r, 0)),
|
|
57824
|
-
g: Math.min(255, Math.max(kh.g, 0)),
|
|
57825
|
-
b: Math.min(255, Math.max(kh.b, 0)),
|
|
57826
|
-
a: x_
|
|
57827
|
-
};
|
|
57828
|
-
}
|
|
57829
|
-
var CSS_INTEGER = "[-\\+]?\\d+%?", CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?", CSS_UNIT = "(?:".concat(CSS_NUMBER, ")|(?:").concat(CSS_INTEGER, ")"), PERMISSIVE_MATCH3 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?"), PERMISSIVE_MATCH4 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?"), matchers = {
|
|
57830
|
-
CSS_UNIT: new RegExp(CSS_UNIT),
|
|
57831
|
-
rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
|
|
57832
|
-
rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
|
|
57833
|
-
hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
|
|
57834
|
-
hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
|
|
57835
|
-
hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
|
|
57836
|
-
hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
|
|
57837
|
-
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
57838
|
-
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
|
57839
|
-
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
57840
|
-
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
|
|
57841
|
-
};
|
|
57842
|
-
function stringInputToObject(Ff) {
|
|
57843
|
-
if (Ff = Ff.trim().toLowerCase(), Ff.length === 0)
|
|
57844
|
-
return !1;
|
|
57845
|
-
var kh = !1;
|
|
57846
|
-
if (names[Ff])
|
|
57847
|
-
Ff = names[Ff], kh = !0;
|
|
57848
|
-
else if (Ff === "transparent")
|
|
57849
|
-
return { r: 0, g: 0, b: 0, a: 0, format: "name" };
|
|
57850
|
-
var x_ = matchers.rgb.exec(Ff);
|
|
57851
|
-
return x_ ? { r: x_[1], g: x_[2], b: x_[3] } : (x_ = matchers.rgba.exec(Ff), x_ ? { r: x_[1], g: x_[2], b: x_[3], a: x_[4] } : (x_ = matchers.hsl.exec(Ff), x_ ? { h: x_[1], s: x_[2], l: x_[3] } : (x_ = matchers.hsla.exec(Ff), x_ ? { h: x_[1], s: x_[2], l: x_[3], a: x_[4] } : (x_ = matchers.hsv.exec(Ff), x_ ? { h: x_[1], s: x_[2], v: x_[3] } : (x_ = matchers.hsva.exec(Ff), x_ ? { h: x_[1], s: x_[2], v: x_[3], a: x_[4] } : (x_ = matchers.hex8.exec(Ff), x_ ? {
|
|
57852
|
-
r: parseIntFromHex(x_[1]),
|
|
57853
|
-
g: parseIntFromHex(x_[2]),
|
|
57854
|
-
b: parseIntFromHex(x_[3]),
|
|
57855
|
-
a: convertHexToDecimal(x_[4]),
|
|
57856
|
-
format: kh ? "name" : "hex8"
|
|
57857
|
-
} : (x_ = matchers.hex6.exec(Ff), x_ ? {
|
|
57858
|
-
r: parseIntFromHex(x_[1]),
|
|
57859
|
-
g: parseIntFromHex(x_[2]),
|
|
57860
|
-
b: parseIntFromHex(x_[3]),
|
|
57861
|
-
format: kh ? "name" : "hex"
|
|
57862
|
-
} : (x_ = matchers.hex4.exec(Ff), x_ ? {
|
|
57863
|
-
r: parseIntFromHex(x_[1] + x_[1]),
|
|
57864
|
-
g: parseIntFromHex(x_[2] + x_[2]),
|
|
57865
|
-
b: parseIntFromHex(x_[3] + x_[3]),
|
|
57866
|
-
a: convertHexToDecimal(x_[4] + x_[4]),
|
|
57867
|
-
format: kh ? "name" : "hex8"
|
|
57868
|
-
} : (x_ = matchers.hex3.exec(Ff), x_ ? {
|
|
57869
|
-
r: parseIntFromHex(x_[1] + x_[1]),
|
|
57870
|
-
g: parseIntFromHex(x_[2] + x_[2]),
|
|
57871
|
-
b: parseIntFromHex(x_[3] + x_[3]),
|
|
57872
|
-
format: kh ? "name" : "hex"
|
|
57873
|
-
} : !1)))))))));
|
|
57874
|
-
}
|
|
57875
|
-
function isValidCSSUnit(Ff) {
|
|
57876
|
-
return !!matchers.CSS_UNIT.exec(String(Ff));
|
|
57881
|
+
fromHsvString(kh) {
|
|
57882
|
+
const x_ = splitColorStr(kh, parseHSVorHSL);
|
|
57883
|
+
this.fromHsv({
|
|
57884
|
+
h: x_[0],
|
|
57885
|
+
s: x_[1],
|
|
57886
|
+
v: x_[2],
|
|
57887
|
+
a: x_[3]
|
|
57888
|
+
});
|
|
57889
|
+
}
|
|
57890
|
+
fromHslString(kh) {
|
|
57891
|
+
const x_ = splitColorStr(kh, parseHSVorHSL);
|
|
57892
|
+
this.fromHsl({
|
|
57893
|
+
h: x_[0],
|
|
57894
|
+
s: x_[1],
|
|
57895
|
+
l: x_[2],
|
|
57896
|
+
a: x_[3]
|
|
57897
|
+
});
|
|
57898
|
+
}
|
|
57899
|
+
fromRgbString(kh) {
|
|
57900
|
+
const x_ = splitColorStr(kh, (B_, $_) => (
|
|
57901
|
+
// Convert percentage to number. e.g. 50% -> 128
|
|
57902
|
+
$_.includes("%") ? round(B_ / 100 * 255) : B_
|
|
57903
|
+
));
|
|
57904
|
+
this.r = x_[0], this.g = x_[1], this.b = x_[2], this.a = x_[3];
|
|
57905
|
+
}
|
|
57877
57906
|
}
|
|
57878
57907
|
var hueStep = 2, saturationStep = 0.16, saturationStep2 = 0.05, brightnessStep1 = 0.05, brightnessStep2 = 0.15, lightColorCount = 5, darkColorCount = 4, darkColorMap = [{
|
|
57879
57908
|
index: 7,
|
|
57880
|
-
|
|
57909
|
+
amount: 15
|
|
57881
57910
|
}, {
|
|
57882
57911
|
index: 6,
|
|
57883
|
-
|
|
57912
|
+
amount: 25
|
|
57884
57913
|
}, {
|
|
57885
57914
|
index: 5,
|
|
57886
|
-
|
|
57915
|
+
amount: 30
|
|
57887
57916
|
}, {
|
|
57888
57917
|
index: 5,
|
|
57889
|
-
|
|
57918
|
+
amount: 45
|
|
57890
57919
|
}, {
|
|
57891
57920
|
index: 5,
|
|
57892
|
-
|
|
57921
|
+
amount: 65
|
|
57893
57922
|
}, {
|
|
57894
57923
|
index: 5,
|
|
57895
|
-
|
|
57924
|
+
amount: 85
|
|
57896
57925
|
}, {
|
|
57897
57926
|
index: 4,
|
|
57898
|
-
|
|
57927
|
+
amount: 90
|
|
57899
57928
|
}, {
|
|
57900
57929
|
index: 3,
|
|
57901
|
-
|
|
57930
|
+
amount: 95
|
|
57902
57931
|
}, {
|
|
57903
57932
|
index: 2,
|
|
57904
|
-
|
|
57933
|
+
amount: 97
|
|
57905
57934
|
}, {
|
|
57906
57935
|
index: 1,
|
|
57907
|
-
|
|
57936
|
+
amount: 98
|
|
57908
57937
|
}];
|
|
57909
|
-
function toHsv(Ff) {
|
|
57910
|
-
var kh = Ff.r, x_ = Ff.g, B_ = Ff.b, $_ = rgbToHsv(kh, x_, B_);
|
|
57911
|
-
return {
|
|
57912
|
-
h: $_.h * 360,
|
|
57913
|
-
s: $_.s,
|
|
57914
|
-
v: $_.v
|
|
57915
|
-
};
|
|
57916
|
-
}
|
|
57917
|
-
function toHex(Ff) {
|
|
57918
|
-
var kh = Ff.r, x_ = Ff.g, B_ = Ff.b;
|
|
57919
|
-
return "#".concat(rgbToHex(kh, x_, B_, !1));
|
|
57920
|
-
}
|
|
57921
|
-
function mix(Ff, kh, x_) {
|
|
57922
|
-
var B_ = x_ / 100, $_ = {
|
|
57923
|
-
r: (kh.r - Ff.r) * B_ + Ff.r,
|
|
57924
|
-
g: (kh.g - Ff.g) * B_ + Ff.g,
|
|
57925
|
-
b: (kh.b - Ff.b) * B_ + Ff.b
|
|
57926
|
-
};
|
|
57927
|
-
return $_;
|
|
57928
|
-
}
|
|
57929
57938
|
function getHue(Ff, kh, x_) {
|
|
57930
57939
|
var B_;
|
|
57931
57940
|
return Math.round(Ff.h) >= 60 && Math.round(Ff.h) <= 240 ? B_ = x_ ? Math.round(Ff.h) - hueStep * kh : Math.round(Ff.h) + hueStep * kh : B_ = x_ ? Math.round(Ff.h) + hueStep * kh : Math.round(Ff.h) - hueStep * kh, B_ < 0 ? B_ += 360 : B_ >= 360 && (B_ -= 360), B_;
|
|
@@ -57934,57 +57943,39 @@ function getSaturation(Ff, kh, x_) {
|
|
|
57934
57943
|
if (Ff.h === 0 && Ff.s === 0)
|
|
57935
57944
|
return Ff.s;
|
|
57936
57945
|
var B_;
|
|
57937
|
-
return x_ ? B_ = Ff.s - saturationStep * kh : kh === darkColorCount ? B_ = Ff.s + saturationStep : B_ = Ff.s + saturationStep2 * kh, B_ > 1 && (B_ = 1), x_ && kh === lightColorCount && B_ > 0.1 && (B_ = 0.1), B_ < 0.06 && (B_ = 0.06),
|
|
57946
|
+
return x_ ? B_ = Ff.s - saturationStep * kh : kh === darkColorCount ? B_ = Ff.s + saturationStep : B_ = Ff.s + saturationStep2 * kh, B_ > 1 && (B_ = 1), x_ && kh === lightColorCount && B_ > 0.1 && (B_ = 0.1), B_ < 0.06 && (B_ = 0.06), Math.round(B_ * 100) / 100;
|
|
57938
57947
|
}
|
|
57939
57948
|
function getValue(Ff, kh, x_) {
|
|
57940
57949
|
var B_;
|
|
57941
|
-
return x_ ? B_ = Ff.v + brightnessStep1 * kh : B_ = Ff.v - brightnessStep2 * kh, B_
|
|
57950
|
+
return x_ ? B_ = Ff.v + brightnessStep1 * kh : B_ = Ff.v - brightnessStep2 * kh, B_ = Math.max(0, Math.min(1, B_)), Math.round(B_ * 100) / 100;
|
|
57942
57951
|
}
|
|
57943
57952
|
function generate$1(Ff) {
|
|
57944
|
-
for (var kh = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, x_ = [], B_ =
|
|
57945
|
-
var
|
|
57946
|
-
h: getHue($
|
|
57947
|
-
s: getSaturation($
|
|
57948
|
-
v: getValue($
|
|
57949
|
-
})
|
|
57953
|
+
for (var kh = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, x_ = [], B_ = new FastColor(Ff), $_ = B_.toHsv(), $P = lightColorCount; $P > 0; $P -= 1) {
|
|
57954
|
+
var zP = new FastColor({
|
|
57955
|
+
h: getHue($_, $P, !0),
|
|
57956
|
+
s: getSaturation($_, $P, !0),
|
|
57957
|
+
v: getValue($_, $P, !0)
|
|
57958
|
+
});
|
|
57950
57959
|
x_.push(zP);
|
|
57951
57960
|
}
|
|
57952
|
-
x_.push(
|
|
57961
|
+
x_.push(B_);
|
|
57953
57962
|
for (var eme = 1; eme <= darkColorCount; eme += 1) {
|
|
57954
|
-
var tme =
|
|
57955
|
-
h: getHue(
|
|
57956
|
-
s: getSaturation(
|
|
57957
|
-
v: getValue(
|
|
57958
|
-
})
|
|
57959
|
-
x_.push(
|
|
57963
|
+
var tme = new FastColor({
|
|
57964
|
+
h: getHue($_, eme),
|
|
57965
|
+
s: getSaturation($_, eme),
|
|
57966
|
+
v: getValue($_, eme)
|
|
57967
|
+
});
|
|
57968
|
+
x_.push(tme);
|
|
57960
57969
|
}
|
|
57961
|
-
return kh.theme === "dark" ? darkColorMap.map(function(
|
|
57962
|
-
var
|
|
57963
|
-
return
|
|
57964
|
-
}) : x_
|
|
57965
|
-
|
|
57966
|
-
|
|
57967
|
-
|
|
57968
|
-
|
|
57969
|
-
|
|
57970
|
-
gold: "#FAAD14",
|
|
57971
|
-
yellow: "#FADB14",
|
|
57972
|
-
lime: "#A0D911",
|
|
57973
|
-
green: "#52C41A",
|
|
57974
|
-
cyan: "#13C2C2",
|
|
57975
|
-
blue: "#1677FF",
|
|
57976
|
-
geekblue: "#2F54EB",
|
|
57977
|
-
purple: "#722ED1",
|
|
57978
|
-
magenta: "#EB2F96",
|
|
57979
|
-
grey: "#666666"
|
|
57980
|
-
}, presetPalettes = {}, presetDarkPalettes = {};
|
|
57981
|
-
Object.keys(presetPrimaryColors).forEach(function(Ff) {
|
|
57982
|
-
presetPalettes[Ff] = generate$1(presetPrimaryColors[Ff]), presetPalettes[Ff].primary = presetPalettes[Ff][5], presetDarkPalettes[Ff] = generate$1(presetPrimaryColors[Ff], {
|
|
57983
|
-
theme: "dark",
|
|
57984
|
-
backgroundColor: "#141414"
|
|
57985
|
-
}), presetDarkPalettes[Ff].primary = presetDarkPalettes[Ff][5];
|
|
57986
|
-
});
|
|
57987
|
-
var blue = presetPalettes.blue;
|
|
57970
|
+
return kh.theme === "dark" ? darkColorMap.map(function(nme) {
|
|
57971
|
+
var rme = nme.index, ime = nme.amount;
|
|
57972
|
+
return new FastColor(kh.backgroundColor || "#141414").mix(x_[rme], ime).toHexString();
|
|
57973
|
+
}) : x_.map(function(nme) {
|
|
57974
|
+
return nme.toHexString();
|
|
57975
|
+
});
|
|
57976
|
+
}
|
|
57977
|
+
var blue = ["#e6f4ff", "#bae0ff", "#91caff", "#69b1ff", "#4096ff", "#1677ff", "#0958d9", "#003eb3", "#002c8c", "#001d66"];
|
|
57978
|
+
blue.primary = blue[5];
|
|
57988
57979
|
function ownKeys(Ff, kh) {
|
|
57989
57980
|
var x_ = Object.keys(Ff);
|
|
57990
57981
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -58182,7 +58173,7 @@ function normalizeTwoToneColors(Ff) {
|
|
|
58182
58173
|
var iconStyles = `
|
|
58183
58174
|
.anticon {
|
|
58184
58175
|
display: inline-flex;
|
|
58185
|
-
|
|
58176
|
+
align-items: center;
|
|
58186
58177
|
color: inherit;
|
|
58187
58178
|
font-style: normal;
|
|
58188
58179
|
line-height: 0;
|
|
@@ -58235,13 +58226,15 @@ var iconStyles = `
|
|
|
58235
58226
|
}
|
|
58236
58227
|
}
|
|
58237
58228
|
`, useInsertStyles = function Ff(kh) {
|
|
58238
|
-
var x_ = useContext(Context), B_ = x_.csp, $_ = x_.prefixCls, $P = iconStyles;
|
|
58239
|
-
$_ && (
|
|
58240
|
-
|
|
58241
|
-
|
|
58242
|
-
|
|
58229
|
+
var x_ = useContext(Context), B_ = x_.csp, $_ = x_.prefixCls, $P = x_.layer, zP = iconStyles;
|
|
58230
|
+
$_ && (zP = zP.replace(/anticon/g, $_)), $P && (zP = "@layer ".concat($P, ` {
|
|
58231
|
+
`).concat(zP, `
|
|
58232
|
+
}`)), useEffect(function() {
|
|
58233
|
+
var eme = kh.current, tme = getShadowRoot(eme);
|
|
58234
|
+
updateCSS(zP, "@ant-design-icons", {
|
|
58235
|
+
prepend: !$P,
|
|
58243
58236
|
csp: B_,
|
|
58244
|
-
attachTo:
|
|
58237
|
+
attachTo: tme
|
|
58245
58238
|
});
|
|
58246
58239
|
}, []);
|
|
58247
58240
|
}, _excluded$1 = ["icon", "className", "onClick", "style", "primaryColor", "secondaryColor"], twoToneColorPalette = {
|
|
@@ -127409,17 +127402,22 @@ const HighlightJS = /* @__PURE__ */ getDefaultExportFromCjs(lib), CodeHighlight
|
|
|
127409
127402
|
const { data: kh = {}, report: x_, codePlayerConnect: B_, submitActivity: $_ } = Ff, { title: $P = "", topic: zP = "", buttonName: eme = "" } = kh, [tme, nme] = useState(""), [rme, ime] = useState(), [ame, ome] = useState(), sme = () => {
|
|
127410
127403
|
x_(), cme();
|
|
127411
127404
|
}, cme = async () => {
|
|
127412
|
-
|
|
127413
|
-
|
|
127414
|
-
|
|
127415
|
-
|
|
127416
|
-
|
|
127417
|
-
|
|
127418
|
-
|
|
127419
|
-
|
|
127420
|
-
|
|
127421
|
-
|
|
127422
|
-
|
|
127405
|
+
B_ && B_(
|
|
127406
|
+
{
|
|
127407
|
+
...kh,
|
|
127408
|
+
code: rme ?? (kh == null ? void 0 : kh.code)
|
|
127409
|
+
},
|
|
127410
|
+
// 当前数据
|
|
127411
|
+
() => {
|
|
127412
|
+
kh.verifyMode && kh.verifyMode != "INPUT_OUTPUT" && tme !== "finish" && nme("finish");
|
|
127413
|
+
},
|
|
127414
|
+
(lme) => {
|
|
127415
|
+
ime(lme), tme || nme("finish");
|
|
127416
|
+
},
|
|
127417
|
+
(lme) => {
|
|
127418
|
+
nme(lme ? "success" : "error");
|
|
127419
|
+
}
|
|
127420
|
+
);
|
|
127423
127421
|
};
|
|
127424
127422
|
return useEffect(() => {
|
|
127425
127423
|
if (!(kh != null && kh.id))
|
|
@@ -127434,7 +127432,7 @@ const HighlightJS = /* @__PURE__ */ getDefaultExportFromCjs(lib), CodeHighlight
|
|
|
127434
127432
|
}, 2e3);
|
|
127435
127433
|
ome(lme);
|
|
127436
127434
|
}, [rme, tme]), useEffect(() => {
|
|
127437
|
-
kh
|
|
127435
|
+
(kh == null ? void 0 : kh.topicResult) != null ? (nme("finish"), ime(kh == null ? void 0 : kh.topicResult)) : nme(""), kh != null && kh.topicStatus && nme((kh == null ? void 0 : kh.topicStatus) === "1" ? "success" : "error");
|
|
127438
127436
|
}, [kh]), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "codetest", contentEditable: !1, children: [
|
|
127439
127437
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "title", children: "编码测验" }),
|
|
127440
127438
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "codetest-topic", children: zP }),
|