@kgalexander/mcreate 1.0.0 → 1.0.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/dist/index.js +1610 -39
- package/dist/index.mjs +1583 -12
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -10727,24 +10727,24 @@ function autolink(options) {
|
|
|
10727
10727
|
if (!isValidLinkStructure(linksBeforeSpace)) {
|
|
10728
10728
|
return false;
|
|
10729
10729
|
}
|
|
10730
|
-
linksBeforeSpace.filter((
|
|
10731
|
-
...
|
|
10732
|
-
from: lastWordAndBlockOffset +
|
|
10733
|
-
to: lastWordAndBlockOffset +
|
|
10734
|
-
})).filter((
|
|
10730
|
+
linksBeforeSpace.filter((link2) => link2.isLink).map((link2) => ({
|
|
10731
|
+
...link2,
|
|
10732
|
+
from: lastWordAndBlockOffset + link2.start + 1,
|
|
10733
|
+
to: lastWordAndBlockOffset + link2.end + 1
|
|
10734
|
+
})).filter((link2) => {
|
|
10735
10735
|
if (!newState.schema.marks.code) {
|
|
10736
10736
|
return true;
|
|
10737
10737
|
}
|
|
10738
|
-
return !newState.doc.rangeHasMark(
|
|
10739
|
-
}).filter((
|
|
10740
|
-
if (getMarksBetween(
|
|
10738
|
+
return !newState.doc.rangeHasMark(link2.from, link2.to, newState.schema.marks.code);
|
|
10739
|
+
}).filter((link2) => options.validate(link2.value)).filter((link2) => options.shouldAutoLink(link2.value)).forEach((link2) => {
|
|
10740
|
+
if (getMarksBetween(link2.from, link2.to, newState.doc).some((item) => item.mark.type === options.type)) {
|
|
10741
10741
|
return;
|
|
10742
10742
|
}
|
|
10743
10743
|
tr2.addMark(
|
|
10744
|
-
|
|
10745
|
-
|
|
10744
|
+
link2.from,
|
|
10745
|
+
link2.to,
|
|
10746
10746
|
options.type.create({
|
|
10747
|
-
href:
|
|
10747
|
+
href: link2.href
|
|
10748
10748
|
})
|
|
10749
10749
|
);
|
|
10750
10750
|
});
|
|
@@ -10769,21 +10769,21 @@ function clickHandler(options) {
|
|
|
10769
10769
|
if (!view.editable) {
|
|
10770
10770
|
return false;
|
|
10771
10771
|
}
|
|
10772
|
-
let
|
|
10772
|
+
let link2 = null;
|
|
10773
10773
|
if (event.target instanceof HTMLAnchorElement) {
|
|
10774
|
-
|
|
10774
|
+
link2 = event.target;
|
|
10775
10775
|
} else {
|
|
10776
10776
|
const target = event.target;
|
|
10777
10777
|
if (!target) {
|
|
10778
10778
|
return false;
|
|
10779
10779
|
}
|
|
10780
10780
|
const root = options.editor.view.dom;
|
|
10781
|
-
|
|
10782
|
-
if (
|
|
10783
|
-
|
|
10781
|
+
link2 = target.closest("a");
|
|
10782
|
+
if (link2 && !root.contains(link2)) {
|
|
10783
|
+
link2 = null;
|
|
10784
10784
|
}
|
|
10785
10785
|
}
|
|
10786
|
-
if (!
|
|
10786
|
+
if (!link2) {
|
|
10787
10787
|
return false;
|
|
10788
10788
|
}
|
|
10789
10789
|
let handled = false;
|
|
@@ -10793,8 +10793,8 @@ function clickHandler(options) {
|
|
|
10793
10793
|
}
|
|
10794
10794
|
if (options.openOnClick) {
|
|
10795
10795
|
const attrs = getAttributes(view.state, options.type.name);
|
|
10796
|
-
const href = (_a =
|
|
10797
|
-
const target = (_b =
|
|
10796
|
+
const href = (_a = link2.href) != null ? _a : attrs.href;
|
|
10797
|
+
const target = (_b = link2.target) != null ? _b : attrs.target;
|
|
10798
10798
|
if (href) {
|
|
10799
10799
|
window.open(href, target);
|
|
10800
10800
|
handled = true;
|
|
@@ -10821,14 +10821,14 @@ function pasteHandler(options) {
|
|
|
10821
10821
|
slice.content.forEach((node) => {
|
|
10822
10822
|
textContent += node.textContent;
|
|
10823
10823
|
});
|
|
10824
|
-
const
|
|
10824
|
+
const link2 = find(textContent, { defaultProtocol: options.defaultProtocol }).find(
|
|
10825
10825
|
(item) => item.isLink && item.value === textContent
|
|
10826
10826
|
);
|
|
10827
|
-
if (!textContent || !
|
|
10827
|
+
if (!textContent || !link2 || shouldAutoLink !== void 0 && !shouldAutoLink(link2.value)) {
|
|
10828
10828
|
return false;
|
|
10829
10829
|
}
|
|
10830
10830
|
return options.editor.commands.setMark(options.type, {
|
|
10831
|
-
href:
|
|
10831
|
+
href: link2.href
|
|
10832
10832
|
});
|
|
10833
10833
|
}
|
|
10834
10834
|
}
|
|
@@ -11030,16 +11030,16 @@ var init_dist2 = __esm({
|
|
|
11030
11030
|
})
|
|
11031
11031
|
);
|
|
11032
11032
|
if (links.length) {
|
|
11033
|
-
links.forEach((
|
|
11034
|
-
if (!this.options.shouldAutoLink(
|
|
11033
|
+
links.forEach((link2) => {
|
|
11034
|
+
if (!this.options.shouldAutoLink(link2.value)) {
|
|
11035
11035
|
return;
|
|
11036
11036
|
}
|
|
11037
11037
|
foundLinks.push({
|
|
11038
|
-
text:
|
|
11038
|
+
text: link2.value,
|
|
11039
11039
|
data: {
|
|
11040
|
-
href:
|
|
11040
|
+
href: link2.href
|
|
11041
11041
|
},
|
|
11042
|
-
index:
|
|
11042
|
+
index: link2.start
|
|
11043
11043
|
});
|
|
11044
11044
|
});
|
|
11045
11045
|
}
|
|
@@ -19530,8 +19530,1579 @@ init_editor();
|
|
|
19530
19530
|
init_label();
|
|
19531
19531
|
init_popover();
|
|
19532
19532
|
|
|
19533
|
+
// node_modules/color-name/index.js
|
|
19534
|
+
var colors = {
|
|
19535
|
+
aliceblue: [240, 248, 255],
|
|
19536
|
+
antiquewhite: [250, 235, 215],
|
|
19537
|
+
aqua: [0, 255, 255],
|
|
19538
|
+
aquamarine: [127, 255, 212],
|
|
19539
|
+
azure: [240, 255, 255],
|
|
19540
|
+
beige: [245, 245, 220],
|
|
19541
|
+
bisque: [255, 228, 196],
|
|
19542
|
+
black: [0, 0, 0],
|
|
19543
|
+
blanchedalmond: [255, 235, 205],
|
|
19544
|
+
blue: [0, 0, 255],
|
|
19545
|
+
blueviolet: [138, 43, 226],
|
|
19546
|
+
brown: [165, 42, 42],
|
|
19547
|
+
burlywood: [222, 184, 135],
|
|
19548
|
+
cadetblue: [95, 158, 160],
|
|
19549
|
+
chartreuse: [127, 255, 0],
|
|
19550
|
+
chocolate: [210, 105, 30],
|
|
19551
|
+
coral: [255, 127, 80],
|
|
19552
|
+
cornflowerblue: [100, 149, 237],
|
|
19553
|
+
cornsilk: [255, 248, 220],
|
|
19554
|
+
crimson: [220, 20, 60],
|
|
19555
|
+
cyan: [0, 255, 255],
|
|
19556
|
+
darkblue: [0, 0, 139],
|
|
19557
|
+
darkcyan: [0, 139, 139],
|
|
19558
|
+
darkgoldenrod: [184, 134, 11],
|
|
19559
|
+
darkgray: [169, 169, 169],
|
|
19560
|
+
darkgreen: [0, 100, 0],
|
|
19561
|
+
darkgrey: [169, 169, 169],
|
|
19562
|
+
darkkhaki: [189, 183, 107],
|
|
19563
|
+
darkmagenta: [139, 0, 139],
|
|
19564
|
+
darkolivegreen: [85, 107, 47],
|
|
19565
|
+
darkorange: [255, 140, 0],
|
|
19566
|
+
darkorchid: [153, 50, 204],
|
|
19567
|
+
darkred: [139, 0, 0],
|
|
19568
|
+
darksalmon: [233, 150, 122],
|
|
19569
|
+
darkseagreen: [143, 188, 143],
|
|
19570
|
+
darkslateblue: [72, 61, 139],
|
|
19571
|
+
darkslategray: [47, 79, 79],
|
|
19572
|
+
darkslategrey: [47, 79, 79],
|
|
19573
|
+
darkturquoise: [0, 206, 209],
|
|
19574
|
+
darkviolet: [148, 0, 211],
|
|
19575
|
+
deeppink: [255, 20, 147],
|
|
19576
|
+
deepskyblue: [0, 191, 255],
|
|
19577
|
+
dimgray: [105, 105, 105],
|
|
19578
|
+
dimgrey: [105, 105, 105],
|
|
19579
|
+
dodgerblue: [30, 144, 255],
|
|
19580
|
+
firebrick: [178, 34, 34],
|
|
19581
|
+
floralwhite: [255, 250, 240],
|
|
19582
|
+
forestgreen: [34, 139, 34],
|
|
19583
|
+
fuchsia: [255, 0, 255],
|
|
19584
|
+
gainsboro: [220, 220, 220],
|
|
19585
|
+
ghostwhite: [248, 248, 255],
|
|
19586
|
+
gold: [255, 215, 0],
|
|
19587
|
+
goldenrod: [218, 165, 32],
|
|
19588
|
+
gray: [128, 128, 128],
|
|
19589
|
+
green: [0, 128, 0],
|
|
19590
|
+
greenyellow: [173, 255, 47],
|
|
19591
|
+
grey: [128, 128, 128],
|
|
19592
|
+
honeydew: [240, 255, 240],
|
|
19593
|
+
hotpink: [255, 105, 180],
|
|
19594
|
+
indianred: [205, 92, 92],
|
|
19595
|
+
indigo: [75, 0, 130],
|
|
19596
|
+
ivory: [255, 255, 240],
|
|
19597
|
+
khaki: [240, 230, 140],
|
|
19598
|
+
lavender: [230, 230, 250],
|
|
19599
|
+
lavenderblush: [255, 240, 245],
|
|
19600
|
+
lawngreen: [124, 252, 0],
|
|
19601
|
+
lemonchiffon: [255, 250, 205],
|
|
19602
|
+
lightblue: [173, 216, 230],
|
|
19603
|
+
lightcoral: [240, 128, 128],
|
|
19604
|
+
lightcyan: [224, 255, 255],
|
|
19605
|
+
lightgoldenrodyellow: [250, 250, 210],
|
|
19606
|
+
lightgray: [211, 211, 211],
|
|
19607
|
+
lightgreen: [144, 238, 144],
|
|
19608
|
+
lightgrey: [211, 211, 211],
|
|
19609
|
+
lightpink: [255, 182, 193],
|
|
19610
|
+
lightsalmon: [255, 160, 122],
|
|
19611
|
+
lightseagreen: [32, 178, 170],
|
|
19612
|
+
lightskyblue: [135, 206, 250],
|
|
19613
|
+
lightslategray: [119, 136, 153],
|
|
19614
|
+
lightslategrey: [119, 136, 153],
|
|
19615
|
+
lightsteelblue: [176, 196, 222],
|
|
19616
|
+
lightyellow: [255, 255, 224],
|
|
19617
|
+
lime: [0, 255, 0],
|
|
19618
|
+
limegreen: [50, 205, 50],
|
|
19619
|
+
linen: [250, 240, 230],
|
|
19620
|
+
magenta: [255, 0, 255],
|
|
19621
|
+
maroon: [128, 0, 0],
|
|
19622
|
+
mediumaquamarine: [102, 205, 170],
|
|
19623
|
+
mediumblue: [0, 0, 205],
|
|
19624
|
+
mediumorchid: [186, 85, 211],
|
|
19625
|
+
mediumpurple: [147, 112, 219],
|
|
19626
|
+
mediumseagreen: [60, 179, 113],
|
|
19627
|
+
mediumslateblue: [123, 104, 238],
|
|
19628
|
+
mediumspringgreen: [0, 250, 154],
|
|
19629
|
+
mediumturquoise: [72, 209, 204],
|
|
19630
|
+
mediumvioletred: [199, 21, 133],
|
|
19631
|
+
midnightblue: [25, 25, 112],
|
|
19632
|
+
mintcream: [245, 255, 250],
|
|
19633
|
+
mistyrose: [255, 228, 225],
|
|
19634
|
+
moccasin: [255, 228, 181],
|
|
19635
|
+
navajowhite: [255, 222, 173],
|
|
19636
|
+
navy: [0, 0, 128],
|
|
19637
|
+
oldlace: [253, 245, 230],
|
|
19638
|
+
olive: [128, 128, 0],
|
|
19639
|
+
olivedrab: [107, 142, 35],
|
|
19640
|
+
orange: [255, 165, 0],
|
|
19641
|
+
orangered: [255, 69, 0],
|
|
19642
|
+
orchid: [218, 112, 214],
|
|
19643
|
+
palegoldenrod: [238, 232, 170],
|
|
19644
|
+
palegreen: [152, 251, 152],
|
|
19645
|
+
paleturquoise: [175, 238, 238],
|
|
19646
|
+
palevioletred: [219, 112, 147],
|
|
19647
|
+
papayawhip: [255, 239, 213],
|
|
19648
|
+
peachpuff: [255, 218, 185],
|
|
19649
|
+
peru: [205, 133, 63],
|
|
19650
|
+
pink: [255, 192, 203],
|
|
19651
|
+
plum: [221, 160, 221],
|
|
19652
|
+
powderblue: [176, 224, 230],
|
|
19653
|
+
purple: [128, 0, 128],
|
|
19654
|
+
rebeccapurple: [102, 51, 153],
|
|
19655
|
+
red: [255, 0, 0],
|
|
19656
|
+
rosybrown: [188, 143, 143],
|
|
19657
|
+
royalblue: [65, 105, 225],
|
|
19658
|
+
saddlebrown: [139, 69, 19],
|
|
19659
|
+
salmon: [250, 128, 114],
|
|
19660
|
+
sandybrown: [244, 164, 96],
|
|
19661
|
+
seagreen: [46, 139, 87],
|
|
19662
|
+
seashell: [255, 245, 238],
|
|
19663
|
+
sienna: [160, 82, 45],
|
|
19664
|
+
silver: [192, 192, 192],
|
|
19665
|
+
skyblue: [135, 206, 235],
|
|
19666
|
+
slateblue: [106, 90, 205],
|
|
19667
|
+
slategray: [112, 128, 144],
|
|
19668
|
+
slategrey: [112, 128, 144],
|
|
19669
|
+
snow: [255, 250, 250],
|
|
19670
|
+
springgreen: [0, 255, 127],
|
|
19671
|
+
steelblue: [70, 130, 180],
|
|
19672
|
+
tan: [210, 180, 140],
|
|
19673
|
+
teal: [0, 128, 128],
|
|
19674
|
+
thistle: [216, 191, 216],
|
|
19675
|
+
tomato: [255, 99, 71],
|
|
19676
|
+
turquoise: [64, 224, 208],
|
|
19677
|
+
violet: [238, 130, 238],
|
|
19678
|
+
wheat: [245, 222, 179],
|
|
19679
|
+
white: [255, 255, 255],
|
|
19680
|
+
whitesmoke: [245, 245, 245],
|
|
19681
|
+
yellow: [255, 255, 0],
|
|
19682
|
+
yellowgreen: [154, 205, 50]
|
|
19683
|
+
};
|
|
19684
|
+
for (const key in colors) Object.freeze(colors[key]);
|
|
19685
|
+
var color_name_default = Object.freeze(colors);
|
|
19686
|
+
|
|
19687
|
+
// node_modules/color-string/index.js
|
|
19688
|
+
var reverseNames = /* @__PURE__ */ Object.create(null);
|
|
19689
|
+
for (const name in color_name_default) {
|
|
19690
|
+
if (Object.hasOwn(color_name_default, name)) {
|
|
19691
|
+
reverseNames[color_name_default[name]] = name;
|
|
19692
|
+
}
|
|
19693
|
+
}
|
|
19694
|
+
var cs = {
|
|
19695
|
+
to: {},
|
|
19696
|
+
get: {}
|
|
19697
|
+
};
|
|
19698
|
+
cs.get = function(string) {
|
|
19699
|
+
const prefix = string.slice(0, 3).toLowerCase();
|
|
19700
|
+
let value;
|
|
19701
|
+
let model;
|
|
19702
|
+
switch (prefix) {
|
|
19703
|
+
case "hsl": {
|
|
19704
|
+
value = cs.get.hsl(string);
|
|
19705
|
+
model = "hsl";
|
|
19706
|
+
break;
|
|
19707
|
+
}
|
|
19708
|
+
case "hwb": {
|
|
19709
|
+
value = cs.get.hwb(string);
|
|
19710
|
+
model = "hwb";
|
|
19711
|
+
break;
|
|
19712
|
+
}
|
|
19713
|
+
default: {
|
|
19714
|
+
value = cs.get.rgb(string);
|
|
19715
|
+
model = "rgb";
|
|
19716
|
+
break;
|
|
19717
|
+
}
|
|
19718
|
+
}
|
|
19719
|
+
if (!value) {
|
|
19720
|
+
return null;
|
|
19721
|
+
}
|
|
19722
|
+
return { model, value };
|
|
19723
|
+
};
|
|
19724
|
+
cs.get.rgb = function(string) {
|
|
19725
|
+
if (!string) {
|
|
19726
|
+
return null;
|
|
19727
|
+
}
|
|
19728
|
+
const abbr = /^#([a-f\d]{3,4})$/i;
|
|
19729
|
+
const hex = /^#([a-f\d]{6})([a-f\d]{2})?$/i;
|
|
19730
|
+
const rgba = /^rgba?\(\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)\s*(?:[\s,|/]\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(%?)\s*)?\)$/i;
|
|
19731
|
+
const per = /^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/i;
|
|
19732
|
+
const keyword = /^(\w+)$/;
|
|
19733
|
+
let rgb = [0, 0, 0, 1];
|
|
19734
|
+
let match;
|
|
19735
|
+
let i;
|
|
19736
|
+
let hexAlpha;
|
|
19737
|
+
if (match = string.match(hex)) {
|
|
19738
|
+
hexAlpha = match[2];
|
|
19739
|
+
match = match[1];
|
|
19740
|
+
for (i = 0; i < 3; i++) {
|
|
19741
|
+
const i2 = i * 2;
|
|
19742
|
+
rgb[i] = Number.parseInt(match.slice(i2, i2 + 2), 16);
|
|
19743
|
+
}
|
|
19744
|
+
if (hexAlpha) {
|
|
19745
|
+
rgb[3] = Number.parseInt(hexAlpha, 16) / 255;
|
|
19746
|
+
}
|
|
19747
|
+
} else if (match = string.match(abbr)) {
|
|
19748
|
+
match = match[1];
|
|
19749
|
+
hexAlpha = match[3];
|
|
19750
|
+
for (i = 0; i < 3; i++) {
|
|
19751
|
+
rgb[i] = Number.parseInt(match[i] + match[i], 16);
|
|
19752
|
+
}
|
|
19753
|
+
if (hexAlpha) {
|
|
19754
|
+
rgb[3] = Number.parseInt(hexAlpha + hexAlpha, 16) / 255;
|
|
19755
|
+
}
|
|
19756
|
+
} else if (match = string.match(rgba)) {
|
|
19757
|
+
for (i = 0; i < 3; i++) {
|
|
19758
|
+
rgb[i] = Number.parseFloat(match[i + 1]);
|
|
19759
|
+
}
|
|
19760
|
+
if (match[4]) {
|
|
19761
|
+
rgb[3] = match[5] ? Number.parseFloat(match[4]) * 0.01 : Number.parseFloat(match[4]);
|
|
19762
|
+
}
|
|
19763
|
+
} else if (match = string.match(per)) {
|
|
19764
|
+
for (i = 0; i < 3; i++) {
|
|
19765
|
+
rgb[i] = Math.round(Number.parseFloat(match[i + 1]) * 2.55);
|
|
19766
|
+
}
|
|
19767
|
+
if (match[4]) {
|
|
19768
|
+
rgb[3] = match[5] ? Number.parseFloat(match[4]) * 0.01 : Number.parseFloat(match[4]);
|
|
19769
|
+
}
|
|
19770
|
+
} else if (match = string.toLowerCase().match(keyword)) {
|
|
19771
|
+
if (match[1] === "transparent") {
|
|
19772
|
+
return [0, 0, 0, 0];
|
|
19773
|
+
}
|
|
19774
|
+
if (!Object.hasOwn(color_name_default, match[1])) {
|
|
19775
|
+
return null;
|
|
19776
|
+
}
|
|
19777
|
+
rgb = color_name_default[match[1]].slice();
|
|
19778
|
+
rgb[3] = 1;
|
|
19779
|
+
return rgb;
|
|
19780
|
+
} else {
|
|
19781
|
+
return null;
|
|
19782
|
+
}
|
|
19783
|
+
for (i = 0; i < 3; i++) {
|
|
19784
|
+
rgb[i] = clamp(rgb[i], 0, 255);
|
|
19785
|
+
}
|
|
19786
|
+
rgb[3] = clamp(rgb[3], 0, 1);
|
|
19787
|
+
return rgb;
|
|
19788
|
+
};
|
|
19789
|
+
cs.get.hsl = function(string) {
|
|
19790
|
+
if (!string) {
|
|
19791
|
+
return null;
|
|
19792
|
+
}
|
|
19793
|
+
const hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i;
|
|
19794
|
+
const match = string.match(hsl);
|
|
19795
|
+
if (match) {
|
|
19796
|
+
const alpha2 = Number.parseFloat(match[4]);
|
|
19797
|
+
const h = (Number.parseFloat(match[1]) % 360 + 360) % 360;
|
|
19798
|
+
const s = clamp(Number.parseFloat(match[2]), 0, 100);
|
|
19799
|
+
const l = clamp(Number.parseFloat(match[3]), 0, 100);
|
|
19800
|
+
const a = clamp(Number.isNaN(alpha2) ? 1 : alpha2, 0, 1);
|
|
19801
|
+
return [h, s, l, a];
|
|
19802
|
+
}
|
|
19803
|
+
return null;
|
|
19804
|
+
};
|
|
19805
|
+
cs.get.hwb = function(string) {
|
|
19806
|
+
if (!string) {
|
|
19807
|
+
return null;
|
|
19808
|
+
}
|
|
19809
|
+
const hwb = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*[\s,]\s*([+-]?[\d.]+)%\s*[\s,]\s*([+-]?[\d.]+)%\s*(?:[\s,]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i;
|
|
19810
|
+
const match = string.match(hwb);
|
|
19811
|
+
if (match) {
|
|
19812
|
+
const alpha2 = Number.parseFloat(match[4]);
|
|
19813
|
+
const h = (Number.parseFloat(match[1]) % 360 + 360) % 360;
|
|
19814
|
+
const w = clamp(Number.parseFloat(match[2]), 0, 100);
|
|
19815
|
+
const b = clamp(Number.parseFloat(match[3]), 0, 100);
|
|
19816
|
+
const a = clamp(Number.isNaN(alpha2) ? 1 : alpha2, 0, 1);
|
|
19817
|
+
return [h, w, b, a];
|
|
19818
|
+
}
|
|
19819
|
+
return null;
|
|
19820
|
+
};
|
|
19821
|
+
cs.to.hex = function(...rgba) {
|
|
19822
|
+
return "#" + hexDouble(rgba[0]) + hexDouble(rgba[1]) + hexDouble(rgba[2]) + (rgba[3] < 1 ? hexDouble(Math.round(rgba[3] * 255)) : "");
|
|
19823
|
+
};
|
|
19824
|
+
cs.to.rgb = function(...rgba) {
|
|
19825
|
+
return rgba.length < 4 || rgba[3] === 1 ? "rgb(" + Math.round(rgba[0]) + ", " + Math.round(rgba[1]) + ", " + Math.round(rgba[2]) + ")" : "rgba(" + Math.round(rgba[0]) + ", " + Math.round(rgba[1]) + ", " + Math.round(rgba[2]) + ", " + rgba[3] + ")";
|
|
19826
|
+
};
|
|
19827
|
+
cs.to.rgb.percent = function(...rgba) {
|
|
19828
|
+
const r = Math.round(rgba[0] / 255 * 100);
|
|
19829
|
+
const g = Math.round(rgba[1] / 255 * 100);
|
|
19830
|
+
const b = Math.round(rgba[2] / 255 * 100);
|
|
19831
|
+
return rgba.length < 4 || rgba[3] === 1 ? "rgb(" + r + "%, " + g + "%, " + b + "%)" : "rgba(" + r + "%, " + g + "%, " + b + "%, " + rgba[3] + ")";
|
|
19832
|
+
};
|
|
19833
|
+
cs.to.hsl = function(...hsla) {
|
|
19834
|
+
return hsla.length < 4 || hsla[3] === 1 ? "hsl(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%)" : "hsla(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%, " + hsla[3] + ")";
|
|
19835
|
+
};
|
|
19836
|
+
cs.to.hwb = function(...hwba) {
|
|
19837
|
+
let a = "";
|
|
19838
|
+
if (hwba.length >= 4 && hwba[3] !== 1) {
|
|
19839
|
+
a = ", " + hwba[3];
|
|
19840
|
+
}
|
|
19841
|
+
return "hwb(" + hwba[0] + ", " + hwba[1] + "%, " + hwba[2] + "%" + a + ")";
|
|
19842
|
+
};
|
|
19843
|
+
cs.to.keyword = function(...rgb) {
|
|
19844
|
+
return reverseNames[rgb.slice(0, 3)];
|
|
19845
|
+
};
|
|
19846
|
+
function clamp(number_, min, max) {
|
|
19847
|
+
return Math.min(Math.max(min, number_), max);
|
|
19848
|
+
}
|
|
19849
|
+
function hexDouble(number_) {
|
|
19850
|
+
const string_ = Math.round(number_).toString(16).toUpperCase();
|
|
19851
|
+
return string_.length < 2 ? "0" + string_ : string_;
|
|
19852
|
+
}
|
|
19853
|
+
var color_string_default = cs;
|
|
19854
|
+
|
|
19855
|
+
// node_modules/color-convert/conversions.js
|
|
19856
|
+
var reverseKeywords = {};
|
|
19857
|
+
for (const key of Object.keys(color_name_default)) {
|
|
19858
|
+
reverseKeywords[color_name_default[key]] = key;
|
|
19859
|
+
}
|
|
19860
|
+
var convert = {
|
|
19861
|
+
rgb: { channels: 3, labels: "rgb" },
|
|
19862
|
+
hsl: { channels: 3, labels: "hsl" },
|
|
19863
|
+
hsv: { channels: 3, labels: "hsv" },
|
|
19864
|
+
hwb: { channels: 3, labels: "hwb" },
|
|
19865
|
+
cmyk: { channels: 4, labels: "cmyk" },
|
|
19866
|
+
xyz: { channels: 3, labels: "xyz" },
|
|
19867
|
+
lab: { channels: 3, labels: "lab" },
|
|
19868
|
+
oklab: { channels: 3, labels: ["okl", "oka", "okb"] },
|
|
19869
|
+
lch: { channels: 3, labels: "lch" },
|
|
19870
|
+
oklch: { channels: 3, labels: ["okl", "okc", "okh"] },
|
|
19871
|
+
hex: { channels: 1, labels: ["hex"] },
|
|
19872
|
+
keyword: { channels: 1, labels: ["keyword"] },
|
|
19873
|
+
ansi16: { channels: 1, labels: ["ansi16"] },
|
|
19874
|
+
ansi256: { channels: 1, labels: ["ansi256"] },
|
|
19875
|
+
hcg: { channels: 3, labels: ["h", "c", "g"] },
|
|
19876
|
+
apple: { channels: 3, labels: ["r16", "g16", "b16"] },
|
|
19877
|
+
gray: { channels: 1, labels: ["gray"] }
|
|
19878
|
+
};
|
|
19879
|
+
var conversions_default = convert;
|
|
19880
|
+
var LAB_FT = (6 / 29) ** 3;
|
|
19881
|
+
function srgbNonlinearTransform(c) {
|
|
19882
|
+
const cc = c > 31308e-7 ? 1.055 * c ** (1 / 2.4) - 0.055 : c * 12.92;
|
|
19883
|
+
return Math.min(Math.max(0, cc), 1);
|
|
19884
|
+
}
|
|
19885
|
+
function srgbNonlinearTransformInv(c) {
|
|
19886
|
+
return c > 0.04045 ? ((c + 0.055) / 1.055) ** 2.4 : c / 12.92;
|
|
19887
|
+
}
|
|
19888
|
+
for (const model of Object.keys(convert)) {
|
|
19889
|
+
if (!("channels" in convert[model])) {
|
|
19890
|
+
throw new Error("missing channels property: " + model);
|
|
19891
|
+
}
|
|
19892
|
+
if (!("labels" in convert[model])) {
|
|
19893
|
+
throw new Error("missing channel labels property: " + model);
|
|
19894
|
+
}
|
|
19895
|
+
if (convert[model].labels.length !== convert[model].channels) {
|
|
19896
|
+
throw new Error("channel and label counts mismatch: " + model);
|
|
19897
|
+
}
|
|
19898
|
+
const { channels, labels } = convert[model];
|
|
19899
|
+
delete convert[model].channels;
|
|
19900
|
+
delete convert[model].labels;
|
|
19901
|
+
Object.defineProperty(convert[model], "channels", { value: channels });
|
|
19902
|
+
Object.defineProperty(convert[model], "labels", { value: labels });
|
|
19903
|
+
}
|
|
19904
|
+
convert.rgb.hsl = function(rgb) {
|
|
19905
|
+
const r = rgb[0] / 255;
|
|
19906
|
+
const g = rgb[1] / 255;
|
|
19907
|
+
const b = rgb[2] / 255;
|
|
19908
|
+
const min = Math.min(r, g, b);
|
|
19909
|
+
const max = Math.max(r, g, b);
|
|
19910
|
+
const delta = max - min;
|
|
19911
|
+
let h;
|
|
19912
|
+
let s;
|
|
19913
|
+
switch (max) {
|
|
19914
|
+
case min: {
|
|
19915
|
+
h = 0;
|
|
19916
|
+
break;
|
|
19917
|
+
}
|
|
19918
|
+
case r: {
|
|
19919
|
+
h = (g - b) / delta;
|
|
19920
|
+
break;
|
|
19921
|
+
}
|
|
19922
|
+
case g: {
|
|
19923
|
+
h = 2 + (b - r) / delta;
|
|
19924
|
+
break;
|
|
19925
|
+
}
|
|
19926
|
+
case b: {
|
|
19927
|
+
h = 4 + (r - g) / delta;
|
|
19928
|
+
break;
|
|
19929
|
+
}
|
|
19930
|
+
}
|
|
19931
|
+
h = Math.min(h * 60, 360);
|
|
19932
|
+
if (h < 0) {
|
|
19933
|
+
h += 360;
|
|
19934
|
+
}
|
|
19935
|
+
const l = (min + max) / 2;
|
|
19936
|
+
if (max === min) {
|
|
19937
|
+
s = 0;
|
|
19938
|
+
} else if (l <= 0.5) {
|
|
19939
|
+
s = delta / (max + min);
|
|
19940
|
+
} else {
|
|
19941
|
+
s = delta / (2 - max - min);
|
|
19942
|
+
}
|
|
19943
|
+
return [h, s * 100, l * 100];
|
|
19944
|
+
};
|
|
19945
|
+
convert.rgb.hsv = function(rgb) {
|
|
19946
|
+
let rdif;
|
|
19947
|
+
let gdif;
|
|
19948
|
+
let bdif;
|
|
19949
|
+
let h;
|
|
19950
|
+
let s;
|
|
19951
|
+
const r = rgb[0] / 255;
|
|
19952
|
+
const g = rgb[1] / 255;
|
|
19953
|
+
const b = rgb[2] / 255;
|
|
19954
|
+
const v = Math.max(r, g, b);
|
|
19955
|
+
const diff = v - Math.min(r, g, b);
|
|
19956
|
+
const diffc = function(c) {
|
|
19957
|
+
return (v - c) / 6 / diff + 1 / 2;
|
|
19958
|
+
};
|
|
19959
|
+
if (diff === 0) {
|
|
19960
|
+
h = 0;
|
|
19961
|
+
s = 0;
|
|
19962
|
+
} else {
|
|
19963
|
+
s = diff / v;
|
|
19964
|
+
rdif = diffc(r);
|
|
19965
|
+
gdif = diffc(g);
|
|
19966
|
+
bdif = diffc(b);
|
|
19967
|
+
switch (v) {
|
|
19968
|
+
case r: {
|
|
19969
|
+
h = bdif - gdif;
|
|
19970
|
+
break;
|
|
19971
|
+
}
|
|
19972
|
+
case g: {
|
|
19973
|
+
h = 1 / 3 + rdif - bdif;
|
|
19974
|
+
break;
|
|
19975
|
+
}
|
|
19976
|
+
case b: {
|
|
19977
|
+
h = 2 / 3 + gdif - rdif;
|
|
19978
|
+
break;
|
|
19979
|
+
}
|
|
19980
|
+
}
|
|
19981
|
+
if (h < 0) {
|
|
19982
|
+
h += 1;
|
|
19983
|
+
} else if (h > 1) {
|
|
19984
|
+
h -= 1;
|
|
19985
|
+
}
|
|
19986
|
+
}
|
|
19987
|
+
return [
|
|
19988
|
+
h * 360,
|
|
19989
|
+
s * 100,
|
|
19990
|
+
v * 100
|
|
19991
|
+
];
|
|
19992
|
+
};
|
|
19993
|
+
convert.rgb.hwb = function(rgb) {
|
|
19994
|
+
const r = rgb[0];
|
|
19995
|
+
const g = rgb[1];
|
|
19996
|
+
let b = rgb[2];
|
|
19997
|
+
const h = convert.rgb.hsl(rgb)[0];
|
|
19998
|
+
const w = 1 / 255 * Math.min(r, Math.min(g, b));
|
|
19999
|
+
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
|
20000
|
+
return [h, w * 100, b * 100];
|
|
20001
|
+
};
|
|
20002
|
+
convert.rgb.oklab = function(rgb) {
|
|
20003
|
+
const r = srgbNonlinearTransformInv(rgb[0] / 255);
|
|
20004
|
+
const g = srgbNonlinearTransformInv(rgb[1] / 255);
|
|
20005
|
+
const b = srgbNonlinearTransformInv(rgb[2] / 255);
|
|
20006
|
+
const lp = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
|
|
20007
|
+
const mp = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
|
|
20008
|
+
const sp = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
|
|
20009
|
+
const l = 0.2104542553 * lp + 0.793617785 * mp - 0.0040720468 * sp;
|
|
20010
|
+
const aa = 1.9779984951 * lp - 2.428592205 * mp + 0.4505937099 * sp;
|
|
20011
|
+
const bb = 0.0259040371 * lp + 0.7827717662 * mp - 0.808675766 * sp;
|
|
20012
|
+
return [l * 100, aa * 100, bb * 100];
|
|
20013
|
+
};
|
|
20014
|
+
convert.rgb.cmyk = function(rgb) {
|
|
20015
|
+
const r = rgb[0] / 255;
|
|
20016
|
+
const g = rgb[1] / 255;
|
|
20017
|
+
const b = rgb[2] / 255;
|
|
20018
|
+
const k = Math.min(1 - r, 1 - g, 1 - b);
|
|
20019
|
+
const c = (1 - r - k) / (1 - k) || 0;
|
|
20020
|
+
const m = (1 - g - k) / (1 - k) || 0;
|
|
20021
|
+
const y = (1 - b - k) / (1 - k) || 0;
|
|
20022
|
+
return [c * 100, m * 100, y * 100, k * 100];
|
|
20023
|
+
};
|
|
20024
|
+
function comparativeDistance(x, y) {
|
|
20025
|
+
return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
|
|
20026
|
+
}
|
|
20027
|
+
convert.rgb.keyword = function(rgb) {
|
|
20028
|
+
const reversed = reverseKeywords[rgb];
|
|
20029
|
+
if (reversed) {
|
|
20030
|
+
return reversed;
|
|
20031
|
+
}
|
|
20032
|
+
let currentClosestDistance = Number.POSITIVE_INFINITY;
|
|
20033
|
+
let currentClosestKeyword;
|
|
20034
|
+
for (const keyword of Object.keys(color_name_default)) {
|
|
20035
|
+
const value = color_name_default[keyword];
|
|
20036
|
+
const distance = comparativeDistance(rgb, value);
|
|
20037
|
+
if (distance < currentClosestDistance) {
|
|
20038
|
+
currentClosestDistance = distance;
|
|
20039
|
+
currentClosestKeyword = keyword;
|
|
20040
|
+
}
|
|
20041
|
+
}
|
|
20042
|
+
return currentClosestKeyword;
|
|
20043
|
+
};
|
|
20044
|
+
convert.keyword.rgb = function(keyword) {
|
|
20045
|
+
return [...color_name_default[keyword]];
|
|
20046
|
+
};
|
|
20047
|
+
convert.rgb.xyz = function(rgb) {
|
|
20048
|
+
const r = srgbNonlinearTransformInv(rgb[0] / 255);
|
|
20049
|
+
const g = srgbNonlinearTransformInv(rgb[1] / 255);
|
|
20050
|
+
const b = srgbNonlinearTransformInv(rgb[2] / 255);
|
|
20051
|
+
const x = r * 0.4124564 + g * 0.3575761 + b * 0.1804375;
|
|
20052
|
+
const y = r * 0.2126729 + g * 0.7151522 + b * 0.072175;
|
|
20053
|
+
const z = r * 0.0193339 + g * 0.119192 + b * 0.9503041;
|
|
20054
|
+
return [x * 100, y * 100, z * 100];
|
|
20055
|
+
};
|
|
20056
|
+
convert.rgb.lab = function(rgb) {
|
|
20057
|
+
const xyz = convert.rgb.xyz(rgb);
|
|
20058
|
+
let x = xyz[0];
|
|
20059
|
+
let y = xyz[1];
|
|
20060
|
+
let z = xyz[2];
|
|
20061
|
+
x /= 95.047;
|
|
20062
|
+
y /= 100;
|
|
20063
|
+
z /= 108.883;
|
|
20064
|
+
x = x > LAB_FT ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
20065
|
+
y = y > LAB_FT ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
20066
|
+
z = z > LAB_FT ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
20067
|
+
const l = 116 * y - 16;
|
|
20068
|
+
const a = 500 * (x - y);
|
|
20069
|
+
const b = 200 * (y - z);
|
|
20070
|
+
return [l, a, b];
|
|
20071
|
+
};
|
|
20072
|
+
convert.hsl.rgb = function(hsl) {
|
|
20073
|
+
const h = hsl[0] / 360;
|
|
20074
|
+
const s = hsl[1] / 100;
|
|
20075
|
+
const l = hsl[2] / 100;
|
|
20076
|
+
let t3;
|
|
20077
|
+
let value;
|
|
20078
|
+
if (s === 0) {
|
|
20079
|
+
value = l * 255;
|
|
20080
|
+
return [value, value, value];
|
|
20081
|
+
}
|
|
20082
|
+
const t2 = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
20083
|
+
const t1 = 2 * l - t2;
|
|
20084
|
+
const rgb = [0, 0, 0];
|
|
20085
|
+
for (let i = 0; i < 3; i++) {
|
|
20086
|
+
t3 = h + 1 / 3 * -(i - 1);
|
|
20087
|
+
if (t3 < 0) {
|
|
20088
|
+
t3++;
|
|
20089
|
+
}
|
|
20090
|
+
if (t3 > 1) {
|
|
20091
|
+
t3--;
|
|
20092
|
+
}
|
|
20093
|
+
if (6 * t3 < 1) {
|
|
20094
|
+
value = t1 + (t2 - t1) * 6 * t3;
|
|
20095
|
+
} else if (2 * t3 < 1) {
|
|
20096
|
+
value = t2;
|
|
20097
|
+
} else if (3 * t3 < 2) {
|
|
20098
|
+
value = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
|
20099
|
+
} else {
|
|
20100
|
+
value = t1;
|
|
20101
|
+
}
|
|
20102
|
+
rgb[i] = value * 255;
|
|
20103
|
+
}
|
|
20104
|
+
return rgb;
|
|
20105
|
+
};
|
|
20106
|
+
convert.hsl.hsv = function(hsl) {
|
|
20107
|
+
const h = hsl[0];
|
|
20108
|
+
let s = hsl[1] / 100;
|
|
20109
|
+
let l = hsl[2] / 100;
|
|
20110
|
+
let smin = s;
|
|
20111
|
+
const lmin = Math.max(l, 0.01);
|
|
20112
|
+
l *= 2;
|
|
20113
|
+
s *= l <= 1 ? l : 2 - l;
|
|
20114
|
+
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
|
20115
|
+
const v = (l + s) / 2;
|
|
20116
|
+
const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
|
|
20117
|
+
return [h, sv * 100, v * 100];
|
|
20118
|
+
};
|
|
20119
|
+
convert.hsv.rgb = function(hsv) {
|
|
20120
|
+
const h = hsv[0] / 60;
|
|
20121
|
+
const s = hsv[1] / 100;
|
|
20122
|
+
let v = hsv[2] / 100;
|
|
20123
|
+
const hi = Math.floor(h) % 6;
|
|
20124
|
+
const f = h - Math.floor(h);
|
|
20125
|
+
const p = 255 * v * (1 - s);
|
|
20126
|
+
const q = 255 * v * (1 - s * f);
|
|
20127
|
+
const t = 255 * v * (1 - s * (1 - f));
|
|
20128
|
+
v *= 255;
|
|
20129
|
+
switch (hi) {
|
|
20130
|
+
case 0: {
|
|
20131
|
+
return [v, t, p];
|
|
20132
|
+
}
|
|
20133
|
+
case 1: {
|
|
20134
|
+
return [q, v, p];
|
|
20135
|
+
}
|
|
20136
|
+
case 2: {
|
|
20137
|
+
return [p, v, t];
|
|
20138
|
+
}
|
|
20139
|
+
case 3: {
|
|
20140
|
+
return [p, q, v];
|
|
20141
|
+
}
|
|
20142
|
+
case 4: {
|
|
20143
|
+
return [t, p, v];
|
|
20144
|
+
}
|
|
20145
|
+
case 5: {
|
|
20146
|
+
return [v, p, q];
|
|
20147
|
+
}
|
|
20148
|
+
}
|
|
20149
|
+
};
|
|
20150
|
+
convert.hsv.hsl = function(hsv) {
|
|
20151
|
+
const h = hsv[0];
|
|
20152
|
+
const s = hsv[1] / 100;
|
|
20153
|
+
const v = hsv[2] / 100;
|
|
20154
|
+
const vmin = Math.max(v, 0.01);
|
|
20155
|
+
let sl;
|
|
20156
|
+
let l;
|
|
20157
|
+
l = (2 - s) * v;
|
|
20158
|
+
const lmin = (2 - s) * vmin;
|
|
20159
|
+
sl = s * vmin;
|
|
20160
|
+
sl /= lmin <= 1 ? lmin : 2 - lmin;
|
|
20161
|
+
sl = sl || 0;
|
|
20162
|
+
l /= 2;
|
|
20163
|
+
return [h, sl * 100, l * 100];
|
|
20164
|
+
};
|
|
20165
|
+
convert.hwb.rgb = function(hwb) {
|
|
20166
|
+
const h = hwb[0] / 360;
|
|
20167
|
+
let wh = hwb[1] / 100;
|
|
20168
|
+
let bl = hwb[2] / 100;
|
|
20169
|
+
const ratio = wh + bl;
|
|
20170
|
+
let f;
|
|
20171
|
+
if (ratio > 1) {
|
|
20172
|
+
wh /= ratio;
|
|
20173
|
+
bl /= ratio;
|
|
20174
|
+
}
|
|
20175
|
+
const i = Math.floor(6 * h);
|
|
20176
|
+
const v = 1 - bl;
|
|
20177
|
+
f = 6 * h - i;
|
|
20178
|
+
if ((i & 1) !== 0) {
|
|
20179
|
+
f = 1 - f;
|
|
20180
|
+
}
|
|
20181
|
+
const n = wh + f * (v - wh);
|
|
20182
|
+
let r;
|
|
20183
|
+
let g;
|
|
20184
|
+
let b;
|
|
20185
|
+
switch (i) {
|
|
20186
|
+
default:
|
|
20187
|
+
case 6:
|
|
20188
|
+
case 0: {
|
|
20189
|
+
r = v;
|
|
20190
|
+
g = n;
|
|
20191
|
+
b = wh;
|
|
20192
|
+
break;
|
|
20193
|
+
}
|
|
20194
|
+
case 1: {
|
|
20195
|
+
r = n;
|
|
20196
|
+
g = v;
|
|
20197
|
+
b = wh;
|
|
20198
|
+
break;
|
|
20199
|
+
}
|
|
20200
|
+
case 2: {
|
|
20201
|
+
r = wh;
|
|
20202
|
+
g = v;
|
|
20203
|
+
b = n;
|
|
20204
|
+
break;
|
|
20205
|
+
}
|
|
20206
|
+
case 3: {
|
|
20207
|
+
r = wh;
|
|
20208
|
+
g = n;
|
|
20209
|
+
b = v;
|
|
20210
|
+
break;
|
|
20211
|
+
}
|
|
20212
|
+
case 4: {
|
|
20213
|
+
r = n;
|
|
20214
|
+
g = wh;
|
|
20215
|
+
b = v;
|
|
20216
|
+
break;
|
|
20217
|
+
}
|
|
20218
|
+
case 5: {
|
|
20219
|
+
r = v;
|
|
20220
|
+
g = wh;
|
|
20221
|
+
b = n;
|
|
20222
|
+
break;
|
|
20223
|
+
}
|
|
20224
|
+
}
|
|
20225
|
+
return [r * 255, g * 255, b * 255];
|
|
20226
|
+
};
|
|
20227
|
+
convert.cmyk.rgb = function(cmyk) {
|
|
20228
|
+
const c = cmyk[0] / 100;
|
|
20229
|
+
const m = cmyk[1] / 100;
|
|
20230
|
+
const y = cmyk[2] / 100;
|
|
20231
|
+
const k = cmyk[3] / 100;
|
|
20232
|
+
const r = 1 - Math.min(1, c * (1 - k) + k);
|
|
20233
|
+
const g = 1 - Math.min(1, m * (1 - k) + k);
|
|
20234
|
+
const b = 1 - Math.min(1, y * (1 - k) + k);
|
|
20235
|
+
return [r * 255, g * 255, b * 255];
|
|
20236
|
+
};
|
|
20237
|
+
convert.xyz.rgb = function(xyz) {
|
|
20238
|
+
const x = xyz[0] / 100;
|
|
20239
|
+
const y = xyz[1] / 100;
|
|
20240
|
+
const z = xyz[2] / 100;
|
|
20241
|
+
let r;
|
|
20242
|
+
let g;
|
|
20243
|
+
let b;
|
|
20244
|
+
r = x * 3.2404542 + y * -1.5371385 + z * -0.4985314;
|
|
20245
|
+
g = x * -0.969266 + y * 1.8760108 + z * 0.041556;
|
|
20246
|
+
b = x * 0.0556434 + y * -0.2040259 + z * 1.0572252;
|
|
20247
|
+
r = srgbNonlinearTransform(r);
|
|
20248
|
+
g = srgbNonlinearTransform(g);
|
|
20249
|
+
b = srgbNonlinearTransform(b);
|
|
20250
|
+
return [r * 255, g * 255, b * 255];
|
|
20251
|
+
};
|
|
20252
|
+
convert.xyz.lab = function(xyz) {
|
|
20253
|
+
let x = xyz[0];
|
|
20254
|
+
let y = xyz[1];
|
|
20255
|
+
let z = xyz[2];
|
|
20256
|
+
x /= 95.047;
|
|
20257
|
+
y /= 100;
|
|
20258
|
+
z /= 108.883;
|
|
20259
|
+
x = x > LAB_FT ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
20260
|
+
y = y > LAB_FT ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
20261
|
+
z = z > LAB_FT ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
20262
|
+
const l = 116 * y - 16;
|
|
20263
|
+
const a = 500 * (x - y);
|
|
20264
|
+
const b = 200 * (y - z);
|
|
20265
|
+
return [l, a, b];
|
|
20266
|
+
};
|
|
20267
|
+
convert.xyz.oklab = function(xyz) {
|
|
20268
|
+
const x = xyz[0] / 100;
|
|
20269
|
+
const y = xyz[1] / 100;
|
|
20270
|
+
const z = xyz[2] / 100;
|
|
20271
|
+
const lp = Math.cbrt(0.8189330101 * x + 0.3618667424 * y - 0.1288597137 * z);
|
|
20272
|
+
const mp = Math.cbrt(0.0329845436 * x + 0.9293118715 * y + 0.0361456387 * z);
|
|
20273
|
+
const sp = Math.cbrt(0.0482003018 * x + 0.2643662691 * y + 0.633851707 * z);
|
|
20274
|
+
const l = 0.2104542553 * lp + 0.793617785 * mp - 0.0040720468 * sp;
|
|
20275
|
+
const a = 1.9779984951 * lp - 2.428592205 * mp + 0.4505937099 * sp;
|
|
20276
|
+
const b = 0.0259040371 * lp + 0.7827717662 * mp - 0.808675766 * sp;
|
|
20277
|
+
return [l * 100, a * 100, b * 100];
|
|
20278
|
+
};
|
|
20279
|
+
convert.oklab.oklch = function(oklab) {
|
|
20280
|
+
return convert.lab.lch(oklab);
|
|
20281
|
+
};
|
|
20282
|
+
convert.oklab.xyz = function(oklab) {
|
|
20283
|
+
const ll = oklab[0] / 100;
|
|
20284
|
+
const a = oklab[1] / 100;
|
|
20285
|
+
const b = oklab[2] / 100;
|
|
20286
|
+
const l = (0.999999998 * ll + 0.396337792 * a + 0.215803758 * b) ** 3;
|
|
20287
|
+
const m = (1.000000008 * ll - 0.105561342 * a - 0.063854175 * b) ** 3;
|
|
20288
|
+
const s = (1.000000055 * ll - 0.089484182 * a - 1.291485538 * b) ** 3;
|
|
20289
|
+
const x = 1.227013851 * l - 0.55779998 * m + 0.281256149 * s;
|
|
20290
|
+
const y = -0.040580178 * l + 1.11225687 * m - 0.071676679 * s;
|
|
20291
|
+
const z = -0.076381285 * l - 0.421481978 * m + 1.58616322 * s;
|
|
20292
|
+
return [x * 100, y * 100, z * 100];
|
|
20293
|
+
};
|
|
20294
|
+
convert.oklab.rgb = function(oklab) {
|
|
20295
|
+
const ll = oklab[0] / 100;
|
|
20296
|
+
const aa = oklab[1] / 100;
|
|
20297
|
+
const bb = oklab[2] / 100;
|
|
20298
|
+
const l = (ll + 0.3963377774 * aa + 0.2158037573 * bb) ** 3;
|
|
20299
|
+
const m = (ll - 0.1055613458 * aa - 0.0638541728 * bb) ** 3;
|
|
20300
|
+
const s = (ll - 0.0894841775 * aa - 1.291485548 * bb) ** 3;
|
|
20301
|
+
const r = srgbNonlinearTransform(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s);
|
|
20302
|
+
const g = srgbNonlinearTransform(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s);
|
|
20303
|
+
const b = srgbNonlinearTransform(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s);
|
|
20304
|
+
return [r * 255, g * 255, b * 255];
|
|
20305
|
+
};
|
|
20306
|
+
convert.oklch.oklab = function(oklch) {
|
|
20307
|
+
return convert.lch.lab(oklch);
|
|
20308
|
+
};
|
|
20309
|
+
convert.lab.xyz = function(lab) {
|
|
20310
|
+
const l = lab[0];
|
|
20311
|
+
const a = lab[1];
|
|
20312
|
+
const b = lab[2];
|
|
20313
|
+
let x;
|
|
20314
|
+
let y;
|
|
20315
|
+
let z;
|
|
20316
|
+
y = (l + 16) / 116;
|
|
20317
|
+
x = a / 500 + y;
|
|
20318
|
+
z = y - b / 200;
|
|
20319
|
+
const y2 = y ** 3;
|
|
20320
|
+
const x2 = x ** 3;
|
|
20321
|
+
const z2 = z ** 3;
|
|
20322
|
+
y = y2 > LAB_FT ? y2 : (y - 16 / 116) / 7.787;
|
|
20323
|
+
x = x2 > LAB_FT ? x2 : (x - 16 / 116) / 7.787;
|
|
20324
|
+
z = z2 > LAB_FT ? z2 : (z - 16 / 116) / 7.787;
|
|
20325
|
+
x *= 95.047;
|
|
20326
|
+
y *= 100;
|
|
20327
|
+
z *= 108.883;
|
|
20328
|
+
return [x, y, z];
|
|
20329
|
+
};
|
|
20330
|
+
convert.lab.lch = function(lab) {
|
|
20331
|
+
const l = lab[0];
|
|
20332
|
+
const a = lab[1];
|
|
20333
|
+
const b = lab[2];
|
|
20334
|
+
let h;
|
|
20335
|
+
const hr = Math.atan2(b, a);
|
|
20336
|
+
h = hr * 360 / 2 / Math.PI;
|
|
20337
|
+
if (h < 0) {
|
|
20338
|
+
h += 360;
|
|
20339
|
+
}
|
|
20340
|
+
const c = Math.sqrt(a * a + b * b);
|
|
20341
|
+
return [l, c, h];
|
|
20342
|
+
};
|
|
20343
|
+
convert.lch.lab = function(lch) {
|
|
20344
|
+
const l = lch[0];
|
|
20345
|
+
const c = lch[1];
|
|
20346
|
+
const h = lch[2];
|
|
20347
|
+
const hr = h / 360 * 2 * Math.PI;
|
|
20348
|
+
const a = c * Math.cos(hr);
|
|
20349
|
+
const b = c * Math.sin(hr);
|
|
20350
|
+
return [l, a, b];
|
|
20351
|
+
};
|
|
20352
|
+
convert.rgb.ansi16 = function(args, saturation = null) {
|
|
20353
|
+
const [r, g, b] = args;
|
|
20354
|
+
let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
|
|
20355
|
+
value = Math.round(value / 50);
|
|
20356
|
+
if (value === 0) {
|
|
20357
|
+
return 30;
|
|
20358
|
+
}
|
|
20359
|
+
let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
|
|
20360
|
+
if (value === 2) {
|
|
20361
|
+
ansi += 60;
|
|
20362
|
+
}
|
|
20363
|
+
return ansi;
|
|
20364
|
+
};
|
|
20365
|
+
convert.hsv.ansi16 = function(args) {
|
|
20366
|
+
return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
|
|
20367
|
+
};
|
|
20368
|
+
convert.rgb.ansi256 = function(args) {
|
|
20369
|
+
const r = args[0];
|
|
20370
|
+
const g = args[1];
|
|
20371
|
+
const b = args[2];
|
|
20372
|
+
if (r >> 4 === g >> 4 && g >> 4 === b >> 4) {
|
|
20373
|
+
if (r < 8) {
|
|
20374
|
+
return 16;
|
|
20375
|
+
}
|
|
20376
|
+
if (r > 248) {
|
|
20377
|
+
return 231;
|
|
20378
|
+
}
|
|
20379
|
+
return Math.round((r - 8) / 247 * 24) + 232;
|
|
20380
|
+
}
|
|
20381
|
+
const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
|
|
20382
|
+
return ansi;
|
|
20383
|
+
};
|
|
20384
|
+
convert.ansi16.rgb = function(args) {
|
|
20385
|
+
args = args[0];
|
|
20386
|
+
let color = args % 10;
|
|
20387
|
+
if (color === 0 || color === 7) {
|
|
20388
|
+
if (args > 50) {
|
|
20389
|
+
color += 3.5;
|
|
20390
|
+
}
|
|
20391
|
+
color = color / 10.5 * 255;
|
|
20392
|
+
return [color, color, color];
|
|
20393
|
+
}
|
|
20394
|
+
const mult = (Math.trunc(args > 50) + 1) * 0.5;
|
|
20395
|
+
const r = (color & 1) * mult * 255;
|
|
20396
|
+
const g = (color >> 1 & 1) * mult * 255;
|
|
20397
|
+
const b = (color >> 2 & 1) * mult * 255;
|
|
20398
|
+
return [r, g, b];
|
|
20399
|
+
};
|
|
20400
|
+
convert.ansi256.rgb = function(args) {
|
|
20401
|
+
args = args[0];
|
|
20402
|
+
if (args >= 232) {
|
|
20403
|
+
const c = (args - 232) * 10 + 8;
|
|
20404
|
+
return [c, c, c];
|
|
20405
|
+
}
|
|
20406
|
+
args -= 16;
|
|
20407
|
+
let rem;
|
|
20408
|
+
const r = Math.floor(args / 36) / 5 * 255;
|
|
20409
|
+
const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
|
20410
|
+
const b = rem % 6 / 5 * 255;
|
|
20411
|
+
return [r, g, b];
|
|
20412
|
+
};
|
|
20413
|
+
convert.rgb.hex = function(args) {
|
|
20414
|
+
const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
|
|
20415
|
+
const string = integer.toString(16).toUpperCase();
|
|
20416
|
+
return "000000".slice(string.length) + string;
|
|
20417
|
+
};
|
|
20418
|
+
convert.hex.rgb = function(args) {
|
|
20419
|
+
const match = args.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);
|
|
20420
|
+
if (!match) {
|
|
20421
|
+
return [0, 0, 0];
|
|
20422
|
+
}
|
|
20423
|
+
let colorString = match[0];
|
|
20424
|
+
if (match[0].length === 3) {
|
|
20425
|
+
colorString = [...colorString].map((char) => char + char).join("");
|
|
20426
|
+
}
|
|
20427
|
+
const integer = Number.parseInt(colorString, 16);
|
|
20428
|
+
const r = integer >> 16 & 255;
|
|
20429
|
+
const g = integer >> 8 & 255;
|
|
20430
|
+
const b = integer & 255;
|
|
20431
|
+
return [r, g, b];
|
|
20432
|
+
};
|
|
20433
|
+
convert.rgb.hcg = function(rgb) {
|
|
20434
|
+
const r = rgb[0] / 255;
|
|
20435
|
+
const g = rgb[1] / 255;
|
|
20436
|
+
const b = rgb[2] / 255;
|
|
20437
|
+
const max = Math.max(Math.max(r, g), b);
|
|
20438
|
+
const min = Math.min(Math.min(r, g), b);
|
|
20439
|
+
const chroma = max - min;
|
|
20440
|
+
let hue;
|
|
20441
|
+
const grayscale = chroma < 1 ? min / (1 - chroma) : 0;
|
|
20442
|
+
if (chroma <= 0) {
|
|
20443
|
+
hue = 0;
|
|
20444
|
+
} else if (max === r) {
|
|
20445
|
+
hue = (g - b) / chroma % 6;
|
|
20446
|
+
} else if (max === g) {
|
|
20447
|
+
hue = 2 + (b - r) / chroma;
|
|
20448
|
+
} else {
|
|
20449
|
+
hue = 4 + (r - g) / chroma;
|
|
20450
|
+
}
|
|
20451
|
+
hue /= 6;
|
|
20452
|
+
hue %= 1;
|
|
20453
|
+
return [hue * 360, chroma * 100, grayscale * 100];
|
|
20454
|
+
};
|
|
20455
|
+
convert.hsl.hcg = function(hsl) {
|
|
20456
|
+
const s = hsl[1] / 100;
|
|
20457
|
+
const l = hsl[2] / 100;
|
|
20458
|
+
const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
|
|
20459
|
+
let f = 0;
|
|
20460
|
+
if (c < 1) {
|
|
20461
|
+
f = (l - 0.5 * c) / (1 - c);
|
|
20462
|
+
}
|
|
20463
|
+
return [hsl[0], c * 100, f * 100];
|
|
20464
|
+
};
|
|
20465
|
+
convert.hsv.hcg = function(hsv) {
|
|
20466
|
+
const s = hsv[1] / 100;
|
|
20467
|
+
const v = hsv[2] / 100;
|
|
20468
|
+
const c = s * v;
|
|
20469
|
+
let f = 0;
|
|
20470
|
+
if (c < 1) {
|
|
20471
|
+
f = (v - c) / (1 - c);
|
|
20472
|
+
}
|
|
20473
|
+
return [hsv[0], c * 100, f * 100];
|
|
20474
|
+
};
|
|
20475
|
+
convert.hcg.rgb = function(hcg) {
|
|
20476
|
+
const h = hcg[0] / 360;
|
|
20477
|
+
const c = hcg[1] / 100;
|
|
20478
|
+
const g = hcg[2] / 100;
|
|
20479
|
+
if (c === 0) {
|
|
20480
|
+
return [g * 255, g * 255, g * 255];
|
|
20481
|
+
}
|
|
20482
|
+
const pure = [0, 0, 0];
|
|
20483
|
+
const hi = h % 1 * 6;
|
|
20484
|
+
const v = hi % 1;
|
|
20485
|
+
const w = 1 - v;
|
|
20486
|
+
let mg = 0;
|
|
20487
|
+
switch (Math.floor(hi)) {
|
|
20488
|
+
case 0: {
|
|
20489
|
+
pure[0] = 1;
|
|
20490
|
+
pure[1] = v;
|
|
20491
|
+
pure[2] = 0;
|
|
20492
|
+
break;
|
|
20493
|
+
}
|
|
20494
|
+
case 1: {
|
|
20495
|
+
pure[0] = w;
|
|
20496
|
+
pure[1] = 1;
|
|
20497
|
+
pure[2] = 0;
|
|
20498
|
+
break;
|
|
20499
|
+
}
|
|
20500
|
+
case 2: {
|
|
20501
|
+
pure[0] = 0;
|
|
20502
|
+
pure[1] = 1;
|
|
20503
|
+
pure[2] = v;
|
|
20504
|
+
break;
|
|
20505
|
+
}
|
|
20506
|
+
case 3: {
|
|
20507
|
+
pure[0] = 0;
|
|
20508
|
+
pure[1] = w;
|
|
20509
|
+
pure[2] = 1;
|
|
20510
|
+
break;
|
|
20511
|
+
}
|
|
20512
|
+
case 4: {
|
|
20513
|
+
pure[0] = v;
|
|
20514
|
+
pure[1] = 0;
|
|
20515
|
+
pure[2] = 1;
|
|
20516
|
+
break;
|
|
20517
|
+
}
|
|
20518
|
+
default: {
|
|
20519
|
+
pure[0] = 1;
|
|
20520
|
+
pure[1] = 0;
|
|
20521
|
+
pure[2] = w;
|
|
20522
|
+
}
|
|
20523
|
+
}
|
|
20524
|
+
mg = (1 - c) * g;
|
|
20525
|
+
return [
|
|
20526
|
+
(c * pure[0] + mg) * 255,
|
|
20527
|
+
(c * pure[1] + mg) * 255,
|
|
20528
|
+
(c * pure[2] + mg) * 255
|
|
20529
|
+
];
|
|
20530
|
+
};
|
|
20531
|
+
convert.hcg.hsv = function(hcg) {
|
|
20532
|
+
const c = hcg[1] / 100;
|
|
20533
|
+
const g = hcg[2] / 100;
|
|
20534
|
+
const v = c + g * (1 - c);
|
|
20535
|
+
let f = 0;
|
|
20536
|
+
if (v > 0) {
|
|
20537
|
+
f = c / v;
|
|
20538
|
+
}
|
|
20539
|
+
return [hcg[0], f * 100, v * 100];
|
|
20540
|
+
};
|
|
20541
|
+
convert.hcg.hsl = function(hcg) {
|
|
20542
|
+
const c = hcg[1] / 100;
|
|
20543
|
+
const g = hcg[2] / 100;
|
|
20544
|
+
const l = g * (1 - c) + 0.5 * c;
|
|
20545
|
+
let s = 0;
|
|
20546
|
+
if (l > 0 && l < 0.5) {
|
|
20547
|
+
s = c / (2 * l);
|
|
20548
|
+
} else if (l >= 0.5 && l < 1) {
|
|
20549
|
+
s = c / (2 * (1 - l));
|
|
20550
|
+
}
|
|
20551
|
+
return [hcg[0], s * 100, l * 100];
|
|
20552
|
+
};
|
|
20553
|
+
convert.hcg.hwb = function(hcg) {
|
|
20554
|
+
const c = hcg[1] / 100;
|
|
20555
|
+
const g = hcg[2] / 100;
|
|
20556
|
+
const v = c + g * (1 - c);
|
|
20557
|
+
return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
|
20558
|
+
};
|
|
20559
|
+
convert.hwb.hcg = function(hwb) {
|
|
20560
|
+
const w = hwb[1] / 100;
|
|
20561
|
+
const b = hwb[2] / 100;
|
|
20562
|
+
const v = 1 - b;
|
|
20563
|
+
const c = v - w;
|
|
20564
|
+
let g = 0;
|
|
20565
|
+
if (c < 1) {
|
|
20566
|
+
g = (v - c) / (1 - c);
|
|
20567
|
+
}
|
|
20568
|
+
return [hwb[0], c * 100, g * 100];
|
|
20569
|
+
};
|
|
20570
|
+
convert.apple.rgb = function(apple) {
|
|
20571
|
+
return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
|
|
20572
|
+
};
|
|
20573
|
+
convert.rgb.apple = function(rgb) {
|
|
20574
|
+
return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
|
|
20575
|
+
};
|
|
20576
|
+
convert.gray.rgb = function(args) {
|
|
20577
|
+
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
|
20578
|
+
};
|
|
20579
|
+
convert.gray.hsl = function(args) {
|
|
20580
|
+
return [0, 0, args[0]];
|
|
20581
|
+
};
|
|
20582
|
+
convert.gray.hsv = convert.gray.hsl;
|
|
20583
|
+
convert.gray.hwb = function(gray) {
|
|
20584
|
+
return [0, 100, gray[0]];
|
|
20585
|
+
};
|
|
20586
|
+
convert.gray.cmyk = function(gray) {
|
|
20587
|
+
return [0, 0, 0, gray[0]];
|
|
20588
|
+
};
|
|
20589
|
+
convert.gray.lab = function(gray) {
|
|
20590
|
+
return [gray[0], 0, 0];
|
|
20591
|
+
};
|
|
20592
|
+
convert.gray.hex = function(gray) {
|
|
20593
|
+
const value = Math.round(gray[0] / 100 * 255) & 255;
|
|
20594
|
+
const integer = (value << 16) + (value << 8) + value;
|
|
20595
|
+
const string = integer.toString(16).toUpperCase();
|
|
20596
|
+
return "000000".slice(string.length) + string;
|
|
20597
|
+
};
|
|
20598
|
+
convert.rgb.gray = function(rgb) {
|
|
20599
|
+
const value = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
|
20600
|
+
return [value / 255 * 100];
|
|
20601
|
+
};
|
|
20602
|
+
|
|
20603
|
+
// node_modules/color-convert/route.js
|
|
20604
|
+
function buildGraph() {
|
|
20605
|
+
const graph = {};
|
|
20606
|
+
const models2 = Object.keys(conversions_default);
|
|
20607
|
+
for (let { length } = models2, i = 0; i < length; i++) {
|
|
20608
|
+
graph[models2[i]] = {
|
|
20609
|
+
// http://jsperf.com/1-vs-infinity
|
|
20610
|
+
// micro-opt, but this is simple.
|
|
20611
|
+
distance: -1,
|
|
20612
|
+
parent: null
|
|
20613
|
+
};
|
|
20614
|
+
}
|
|
20615
|
+
return graph;
|
|
20616
|
+
}
|
|
20617
|
+
function deriveBFS(fromModel) {
|
|
20618
|
+
const graph = buildGraph();
|
|
20619
|
+
const queue = [fromModel];
|
|
20620
|
+
graph[fromModel].distance = 0;
|
|
20621
|
+
while (queue.length > 0) {
|
|
20622
|
+
const current = queue.pop();
|
|
20623
|
+
const adjacents = Object.keys(conversions_default[current]);
|
|
20624
|
+
for (let { length } = adjacents, i = 0; i < length; i++) {
|
|
20625
|
+
const adjacent = adjacents[i];
|
|
20626
|
+
const node = graph[adjacent];
|
|
20627
|
+
if (node.distance === -1) {
|
|
20628
|
+
node.distance = graph[current].distance + 1;
|
|
20629
|
+
node.parent = current;
|
|
20630
|
+
queue.unshift(adjacent);
|
|
20631
|
+
}
|
|
20632
|
+
}
|
|
20633
|
+
}
|
|
20634
|
+
return graph;
|
|
20635
|
+
}
|
|
20636
|
+
function link(from, to) {
|
|
20637
|
+
return function(args) {
|
|
20638
|
+
return to(from(args));
|
|
20639
|
+
};
|
|
20640
|
+
}
|
|
20641
|
+
function wrapConversion(toModel, graph) {
|
|
20642
|
+
const path = [graph[toModel].parent, toModel];
|
|
20643
|
+
let fn = conversions_default[graph[toModel].parent][toModel];
|
|
20644
|
+
let cur = graph[toModel].parent;
|
|
20645
|
+
while (graph[cur].parent) {
|
|
20646
|
+
path.unshift(graph[cur].parent);
|
|
20647
|
+
fn = link(conversions_default[graph[cur].parent][cur], fn);
|
|
20648
|
+
cur = graph[cur].parent;
|
|
20649
|
+
}
|
|
20650
|
+
fn.conversion = path;
|
|
20651
|
+
return fn;
|
|
20652
|
+
}
|
|
20653
|
+
function route(fromModel) {
|
|
20654
|
+
const graph = deriveBFS(fromModel);
|
|
20655
|
+
const conversion = {};
|
|
20656
|
+
const models2 = Object.keys(graph);
|
|
20657
|
+
for (let { length } = models2, i = 0; i < length; i++) {
|
|
20658
|
+
const toModel = models2[i];
|
|
20659
|
+
const node = graph[toModel];
|
|
20660
|
+
if (node.parent === null) {
|
|
20661
|
+
continue;
|
|
20662
|
+
}
|
|
20663
|
+
conversion[toModel] = wrapConversion(toModel, graph);
|
|
20664
|
+
}
|
|
20665
|
+
return conversion;
|
|
20666
|
+
}
|
|
20667
|
+
var route_default = route;
|
|
20668
|
+
|
|
20669
|
+
// node_modules/color-convert/index.js
|
|
20670
|
+
var convert2 = {};
|
|
20671
|
+
var models = Object.keys(conversions_default);
|
|
20672
|
+
function wrapRaw(fn) {
|
|
20673
|
+
const wrappedFn = function(...args) {
|
|
20674
|
+
const arg0 = args[0];
|
|
20675
|
+
if (arg0 === void 0 || arg0 === null) {
|
|
20676
|
+
return arg0;
|
|
20677
|
+
}
|
|
20678
|
+
if (arg0.length > 1) {
|
|
20679
|
+
args = arg0;
|
|
20680
|
+
}
|
|
20681
|
+
return fn(args);
|
|
20682
|
+
};
|
|
20683
|
+
if ("conversion" in fn) {
|
|
20684
|
+
wrappedFn.conversion = fn.conversion;
|
|
20685
|
+
}
|
|
20686
|
+
return wrappedFn;
|
|
20687
|
+
}
|
|
20688
|
+
function wrapRounded(fn) {
|
|
20689
|
+
const wrappedFn = function(...args) {
|
|
20690
|
+
const arg0 = args[0];
|
|
20691
|
+
if (arg0 === void 0 || arg0 === null) {
|
|
20692
|
+
return arg0;
|
|
20693
|
+
}
|
|
20694
|
+
if (arg0.length > 1) {
|
|
20695
|
+
args = arg0;
|
|
20696
|
+
}
|
|
20697
|
+
const result = fn(args);
|
|
20698
|
+
if (typeof result === "object") {
|
|
20699
|
+
for (let { length } = result, i = 0; i < length; i++) {
|
|
20700
|
+
result[i] = Math.round(result[i]);
|
|
20701
|
+
}
|
|
20702
|
+
}
|
|
20703
|
+
return result;
|
|
20704
|
+
};
|
|
20705
|
+
if ("conversion" in fn) {
|
|
20706
|
+
wrappedFn.conversion = fn.conversion;
|
|
20707
|
+
}
|
|
20708
|
+
return wrappedFn;
|
|
20709
|
+
}
|
|
20710
|
+
for (const fromModel of models) {
|
|
20711
|
+
convert2[fromModel] = {};
|
|
20712
|
+
Object.defineProperty(convert2[fromModel], "channels", { value: conversions_default[fromModel].channels });
|
|
20713
|
+
Object.defineProperty(convert2[fromModel], "labels", { value: conversions_default[fromModel].labels });
|
|
20714
|
+
const routes = route_default(fromModel);
|
|
20715
|
+
const routeModels = Object.keys(routes);
|
|
20716
|
+
for (const toModel of routeModels) {
|
|
20717
|
+
const fn = routes[toModel];
|
|
20718
|
+
convert2[fromModel][toModel] = wrapRounded(fn);
|
|
20719
|
+
convert2[fromModel][toModel].raw = wrapRaw(fn);
|
|
20720
|
+
}
|
|
20721
|
+
}
|
|
20722
|
+
var color_convert_default = convert2;
|
|
20723
|
+
|
|
20724
|
+
// node_modules/color/index.js
|
|
20725
|
+
var skippedModels = [
|
|
20726
|
+
// To be honest, I don't really feel like keyword belongs in color convert, but eh.
|
|
20727
|
+
"keyword",
|
|
20728
|
+
// Gray conflicts with some method names, and has its own method defined.
|
|
20729
|
+
"gray",
|
|
20730
|
+
// Shouldn't really be in color-convert either...
|
|
20731
|
+
"hex"
|
|
20732
|
+
];
|
|
20733
|
+
var hashedModelKeys = {};
|
|
20734
|
+
for (const model of Object.keys(color_convert_default)) {
|
|
20735
|
+
hashedModelKeys[[...color_convert_default[model].labels].sort().join("")] = model;
|
|
20736
|
+
}
|
|
20737
|
+
var limiters = {};
|
|
20738
|
+
function Color2(object, model) {
|
|
20739
|
+
if (!(this instanceof Color2)) {
|
|
20740
|
+
return new Color2(object, model);
|
|
20741
|
+
}
|
|
20742
|
+
if (model && model in skippedModels) {
|
|
20743
|
+
model = null;
|
|
20744
|
+
}
|
|
20745
|
+
if (model && !(model in color_convert_default)) {
|
|
20746
|
+
throw new Error("Unknown model: " + model);
|
|
20747
|
+
}
|
|
20748
|
+
let i;
|
|
20749
|
+
let channels;
|
|
20750
|
+
if (object == null) {
|
|
20751
|
+
this.model = "rgb";
|
|
20752
|
+
this.color = [0, 0, 0];
|
|
20753
|
+
this.valpha = 1;
|
|
20754
|
+
} else if (object instanceof Color2) {
|
|
20755
|
+
this.model = object.model;
|
|
20756
|
+
this.color = [...object.color];
|
|
20757
|
+
this.valpha = object.valpha;
|
|
20758
|
+
} else if (typeof object === "string") {
|
|
20759
|
+
const result = color_string_default.get(object);
|
|
20760
|
+
if (result === null) {
|
|
20761
|
+
throw new Error("Unable to parse color from string: " + object);
|
|
20762
|
+
}
|
|
20763
|
+
this.model = result.model;
|
|
20764
|
+
channels = color_convert_default[this.model].channels;
|
|
20765
|
+
this.color = result.value.slice(0, channels);
|
|
20766
|
+
this.valpha = typeof result.value[channels] === "number" ? result.value[channels] : 1;
|
|
20767
|
+
} else if (object.length > 0) {
|
|
20768
|
+
this.model = model || "rgb";
|
|
20769
|
+
channels = color_convert_default[this.model].channels;
|
|
20770
|
+
const newArray = Array.prototype.slice.call(object, 0, channels);
|
|
20771
|
+
this.color = zeroArray(newArray, channels);
|
|
20772
|
+
this.valpha = typeof object[channels] === "number" ? object[channels] : 1;
|
|
20773
|
+
} else if (typeof object === "number") {
|
|
20774
|
+
this.model = "rgb";
|
|
20775
|
+
this.color = [
|
|
20776
|
+
object >> 16 & 255,
|
|
20777
|
+
object >> 8 & 255,
|
|
20778
|
+
object & 255
|
|
20779
|
+
];
|
|
20780
|
+
this.valpha = 1;
|
|
20781
|
+
} else {
|
|
20782
|
+
this.valpha = 1;
|
|
20783
|
+
const keys = Object.keys(object);
|
|
20784
|
+
if ("alpha" in object) {
|
|
20785
|
+
keys.splice(keys.indexOf("alpha"), 1);
|
|
20786
|
+
this.valpha = typeof object.alpha === "number" ? object.alpha : 0;
|
|
20787
|
+
}
|
|
20788
|
+
const hashedKeys = keys.sort().join("");
|
|
20789
|
+
if (!(hashedKeys in hashedModelKeys)) {
|
|
20790
|
+
throw new Error("Unable to parse color from object: " + JSON.stringify(object));
|
|
20791
|
+
}
|
|
20792
|
+
this.model = hashedModelKeys[hashedKeys];
|
|
20793
|
+
const { labels } = color_convert_default[this.model];
|
|
20794
|
+
const color = [];
|
|
20795
|
+
for (i = 0; i < labels.length; i++) {
|
|
20796
|
+
color.push(object[labels[i]]);
|
|
20797
|
+
}
|
|
20798
|
+
this.color = zeroArray(color);
|
|
20799
|
+
}
|
|
20800
|
+
if (limiters[this.model]) {
|
|
20801
|
+
channels = color_convert_default[this.model].channels;
|
|
20802
|
+
for (i = 0; i < channels; i++) {
|
|
20803
|
+
const limit = limiters[this.model][i];
|
|
20804
|
+
if (limit) {
|
|
20805
|
+
this.color[i] = limit(this.color[i]);
|
|
20806
|
+
}
|
|
20807
|
+
}
|
|
20808
|
+
}
|
|
20809
|
+
this.valpha = Math.max(0, Math.min(1, this.valpha));
|
|
20810
|
+
if (Object.freeze) {
|
|
20811
|
+
Object.freeze(this);
|
|
20812
|
+
}
|
|
20813
|
+
}
|
|
20814
|
+
Color2.prototype = {
|
|
20815
|
+
toString() {
|
|
20816
|
+
return this.string();
|
|
20817
|
+
},
|
|
20818
|
+
toJSON() {
|
|
20819
|
+
return this[this.model]();
|
|
20820
|
+
},
|
|
20821
|
+
string(places) {
|
|
20822
|
+
let self = this.model in color_string_default.to ? this : this.rgb();
|
|
20823
|
+
self = self.round(typeof places === "number" ? places : 1);
|
|
20824
|
+
const arguments_ = self.valpha === 1 ? self.color : [...self.color, this.valpha];
|
|
20825
|
+
return color_string_default.to[self.model](...arguments_);
|
|
20826
|
+
},
|
|
20827
|
+
percentString(places) {
|
|
20828
|
+
const self = this.rgb().round(typeof places === "number" ? places : 1);
|
|
20829
|
+
const arguments_ = self.valpha === 1 ? self.color : [...self.color, this.valpha];
|
|
20830
|
+
return color_string_default.to.rgb.percent(...arguments_);
|
|
20831
|
+
},
|
|
20832
|
+
array() {
|
|
20833
|
+
return this.valpha === 1 ? [...this.color] : [...this.color, this.valpha];
|
|
20834
|
+
},
|
|
20835
|
+
object() {
|
|
20836
|
+
const result = {};
|
|
20837
|
+
const { channels } = color_convert_default[this.model];
|
|
20838
|
+
const { labels } = color_convert_default[this.model];
|
|
20839
|
+
for (let i = 0; i < channels; i++) {
|
|
20840
|
+
result[labels[i]] = this.color[i];
|
|
20841
|
+
}
|
|
20842
|
+
if (this.valpha !== 1) {
|
|
20843
|
+
result.alpha = this.valpha;
|
|
20844
|
+
}
|
|
20845
|
+
return result;
|
|
20846
|
+
},
|
|
20847
|
+
unitArray() {
|
|
20848
|
+
const rgb = this.rgb().color;
|
|
20849
|
+
rgb[0] /= 255;
|
|
20850
|
+
rgb[1] /= 255;
|
|
20851
|
+
rgb[2] /= 255;
|
|
20852
|
+
if (this.valpha !== 1) {
|
|
20853
|
+
rgb.push(this.valpha);
|
|
20854
|
+
}
|
|
20855
|
+
return rgb;
|
|
20856
|
+
},
|
|
20857
|
+
unitObject() {
|
|
20858
|
+
const rgb = this.rgb().object();
|
|
20859
|
+
rgb.r /= 255;
|
|
20860
|
+
rgb.g /= 255;
|
|
20861
|
+
rgb.b /= 255;
|
|
20862
|
+
if (this.valpha !== 1) {
|
|
20863
|
+
rgb.alpha = this.valpha;
|
|
20864
|
+
}
|
|
20865
|
+
return rgb;
|
|
20866
|
+
},
|
|
20867
|
+
round(places) {
|
|
20868
|
+
places = Math.max(places || 0, 0);
|
|
20869
|
+
return new Color2([...this.color.map(roundToPlace(places)), this.valpha], this.model);
|
|
20870
|
+
},
|
|
20871
|
+
alpha(value) {
|
|
20872
|
+
if (value !== void 0) {
|
|
20873
|
+
return new Color2([...this.color, Math.max(0, Math.min(1, value))], this.model);
|
|
20874
|
+
}
|
|
20875
|
+
return this.valpha;
|
|
20876
|
+
},
|
|
20877
|
+
// Rgb
|
|
20878
|
+
red: getset("rgb", 0, maxfn(255)),
|
|
20879
|
+
green: getset("rgb", 1, maxfn(255)),
|
|
20880
|
+
blue: getset("rgb", 2, maxfn(255)),
|
|
20881
|
+
hue: getset(["hsl", "hsv", "hsl", "hwb", "hcg"], 0, (value) => (value % 360 + 360) % 360),
|
|
20882
|
+
saturationl: getset("hsl", 1, maxfn(100)),
|
|
20883
|
+
lightness: getset("hsl", 2, maxfn(100)),
|
|
20884
|
+
saturationv: getset("hsv", 1, maxfn(100)),
|
|
20885
|
+
value: getset("hsv", 2, maxfn(100)),
|
|
20886
|
+
chroma: getset("hcg", 1, maxfn(100)),
|
|
20887
|
+
gray: getset("hcg", 2, maxfn(100)),
|
|
20888
|
+
white: getset("hwb", 1, maxfn(100)),
|
|
20889
|
+
wblack: getset("hwb", 2, maxfn(100)),
|
|
20890
|
+
cyan: getset("cmyk", 0, maxfn(100)),
|
|
20891
|
+
magenta: getset("cmyk", 1, maxfn(100)),
|
|
20892
|
+
yellow: getset("cmyk", 2, maxfn(100)),
|
|
20893
|
+
black: getset("cmyk", 3, maxfn(100)),
|
|
20894
|
+
x: getset("xyz", 0, maxfn(95.047)),
|
|
20895
|
+
y: getset("xyz", 1, maxfn(100)),
|
|
20896
|
+
z: getset("xyz", 2, maxfn(108.833)),
|
|
20897
|
+
l: getset("lab", 0, maxfn(100)),
|
|
20898
|
+
a: getset("lab", 1),
|
|
20899
|
+
b: getset("lab", 2),
|
|
20900
|
+
keyword(value) {
|
|
20901
|
+
if (value !== void 0) {
|
|
20902
|
+
return new Color2(value);
|
|
20903
|
+
}
|
|
20904
|
+
return color_convert_default[this.model].keyword(this.color);
|
|
20905
|
+
},
|
|
20906
|
+
hex(value) {
|
|
20907
|
+
if (value !== void 0) {
|
|
20908
|
+
return new Color2(value);
|
|
20909
|
+
}
|
|
20910
|
+
return color_string_default.to.hex(...this.rgb().round().color);
|
|
20911
|
+
},
|
|
20912
|
+
hexa(value) {
|
|
20913
|
+
if (value !== void 0) {
|
|
20914
|
+
return new Color2(value);
|
|
20915
|
+
}
|
|
20916
|
+
const rgbArray = this.rgb().round().color;
|
|
20917
|
+
let alphaHex = Math.round(this.valpha * 255).toString(16).toUpperCase();
|
|
20918
|
+
if (alphaHex.length === 1) {
|
|
20919
|
+
alphaHex = "0" + alphaHex;
|
|
20920
|
+
}
|
|
20921
|
+
return color_string_default.to.hex(...rgbArray) + alphaHex;
|
|
20922
|
+
},
|
|
20923
|
+
rgbNumber() {
|
|
20924
|
+
const rgb = this.rgb().color;
|
|
20925
|
+
return (rgb[0] & 255) << 16 | (rgb[1] & 255) << 8 | rgb[2] & 255;
|
|
20926
|
+
},
|
|
20927
|
+
luminosity() {
|
|
20928
|
+
const rgb = this.rgb().color;
|
|
20929
|
+
const lum = [];
|
|
20930
|
+
for (const [i, element] of rgb.entries()) {
|
|
20931
|
+
const chan = element / 255;
|
|
20932
|
+
lum[i] = chan <= 0.04045 ? chan / 12.92 : ((chan + 0.055) / 1.055) ** 2.4;
|
|
20933
|
+
}
|
|
20934
|
+
return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];
|
|
20935
|
+
},
|
|
20936
|
+
contrast(color2) {
|
|
20937
|
+
const lum1 = this.luminosity();
|
|
20938
|
+
const lum2 = color2.luminosity();
|
|
20939
|
+
if (lum1 > lum2) {
|
|
20940
|
+
return (lum1 + 0.05) / (lum2 + 0.05);
|
|
20941
|
+
}
|
|
20942
|
+
return (lum2 + 0.05) / (lum1 + 0.05);
|
|
20943
|
+
},
|
|
20944
|
+
level(color2) {
|
|
20945
|
+
const contrastRatio = this.contrast(color2);
|
|
20946
|
+
if (contrastRatio >= 7) {
|
|
20947
|
+
return "AAA";
|
|
20948
|
+
}
|
|
20949
|
+
return contrastRatio >= 4.5 ? "AA" : "";
|
|
20950
|
+
},
|
|
20951
|
+
isDark() {
|
|
20952
|
+
const rgb = this.rgb().color;
|
|
20953
|
+
const yiq = (rgb[0] * 2126 + rgb[1] * 7152 + rgb[2] * 722) / 1e4;
|
|
20954
|
+
return yiq < 128;
|
|
20955
|
+
},
|
|
20956
|
+
isLight() {
|
|
20957
|
+
return !this.isDark();
|
|
20958
|
+
},
|
|
20959
|
+
negate() {
|
|
20960
|
+
const rgb = this.rgb();
|
|
20961
|
+
for (let i = 0; i < 3; i++) {
|
|
20962
|
+
rgb.color[i] = 255 - rgb.color[i];
|
|
20963
|
+
}
|
|
20964
|
+
return rgb;
|
|
20965
|
+
},
|
|
20966
|
+
lighten(ratio) {
|
|
20967
|
+
const hsl = this.hsl();
|
|
20968
|
+
hsl.color[2] += hsl.color[2] * ratio;
|
|
20969
|
+
return hsl;
|
|
20970
|
+
},
|
|
20971
|
+
darken(ratio) {
|
|
20972
|
+
const hsl = this.hsl();
|
|
20973
|
+
hsl.color[2] -= hsl.color[2] * ratio;
|
|
20974
|
+
return hsl;
|
|
20975
|
+
},
|
|
20976
|
+
saturate(ratio) {
|
|
20977
|
+
const hsl = this.hsl();
|
|
20978
|
+
hsl.color[1] += hsl.color[1] * ratio;
|
|
20979
|
+
return hsl;
|
|
20980
|
+
},
|
|
20981
|
+
desaturate(ratio) {
|
|
20982
|
+
const hsl = this.hsl();
|
|
20983
|
+
hsl.color[1] -= hsl.color[1] * ratio;
|
|
20984
|
+
return hsl;
|
|
20985
|
+
},
|
|
20986
|
+
whiten(ratio) {
|
|
20987
|
+
const hwb = this.hwb();
|
|
20988
|
+
hwb.color[1] += hwb.color[1] * ratio;
|
|
20989
|
+
return hwb;
|
|
20990
|
+
},
|
|
20991
|
+
blacken(ratio) {
|
|
20992
|
+
const hwb = this.hwb();
|
|
20993
|
+
hwb.color[2] += hwb.color[2] * ratio;
|
|
20994
|
+
return hwb;
|
|
20995
|
+
},
|
|
20996
|
+
grayscale() {
|
|
20997
|
+
const rgb = this.rgb().color;
|
|
20998
|
+
const value = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;
|
|
20999
|
+
return Color2.rgb(value, value, value);
|
|
21000
|
+
},
|
|
21001
|
+
fade(ratio) {
|
|
21002
|
+
return this.alpha(this.valpha - this.valpha * ratio);
|
|
21003
|
+
},
|
|
21004
|
+
opaquer(ratio) {
|
|
21005
|
+
return this.alpha(this.valpha + this.valpha * ratio);
|
|
21006
|
+
},
|
|
21007
|
+
rotate(degrees) {
|
|
21008
|
+
const hsl = this.hsl();
|
|
21009
|
+
let hue = hsl.color[0];
|
|
21010
|
+
hue = (hue + degrees) % 360;
|
|
21011
|
+
hue = hue < 0 ? 360 + hue : hue;
|
|
21012
|
+
hsl.color[0] = hue;
|
|
21013
|
+
return hsl;
|
|
21014
|
+
},
|
|
21015
|
+
mix(mixinColor, weight) {
|
|
21016
|
+
if (!mixinColor || !mixinColor.rgb) {
|
|
21017
|
+
throw new Error('Argument to "mix" was not a Color instance, but rather an instance of ' + typeof mixinColor);
|
|
21018
|
+
}
|
|
21019
|
+
const color1 = mixinColor.rgb();
|
|
21020
|
+
const color2 = this.rgb();
|
|
21021
|
+
const p = weight === void 0 ? 0.5 : weight;
|
|
21022
|
+
const w = 2 * p - 1;
|
|
21023
|
+
const a = color1.alpha() - color2.alpha();
|
|
21024
|
+
const w1 = ((w * a === -1 ? w : (w + a) / (1 + w * a)) + 1) / 2;
|
|
21025
|
+
const w2 = 1 - w1;
|
|
21026
|
+
return Color2.rgb(
|
|
21027
|
+
w1 * color1.red() + w2 * color2.red(),
|
|
21028
|
+
w1 * color1.green() + w2 * color2.green(),
|
|
21029
|
+
w1 * color1.blue() + w2 * color2.blue(),
|
|
21030
|
+
color1.alpha() * p + color2.alpha() * (1 - p)
|
|
21031
|
+
);
|
|
21032
|
+
}
|
|
21033
|
+
};
|
|
21034
|
+
for (const model of Object.keys(color_convert_default)) {
|
|
21035
|
+
if (skippedModels.includes(model)) {
|
|
21036
|
+
continue;
|
|
21037
|
+
}
|
|
21038
|
+
const { channels } = color_convert_default[model];
|
|
21039
|
+
Color2.prototype[model] = function(...arguments_) {
|
|
21040
|
+
if (this.model === model) {
|
|
21041
|
+
return new Color2(this);
|
|
21042
|
+
}
|
|
21043
|
+
if (arguments_.length > 0) {
|
|
21044
|
+
return new Color2(arguments_, model);
|
|
21045
|
+
}
|
|
21046
|
+
return new Color2([...assertArray(color_convert_default[this.model][model].raw(this.color)), this.valpha], model);
|
|
21047
|
+
};
|
|
21048
|
+
Color2[model] = function(...arguments_) {
|
|
21049
|
+
let color = arguments_[0];
|
|
21050
|
+
if (typeof color === "number") {
|
|
21051
|
+
color = zeroArray(arguments_, channels);
|
|
21052
|
+
}
|
|
21053
|
+
return new Color2(color, model);
|
|
21054
|
+
};
|
|
21055
|
+
}
|
|
21056
|
+
function roundTo(number, places) {
|
|
21057
|
+
return Number(number.toFixed(places));
|
|
21058
|
+
}
|
|
21059
|
+
function roundToPlace(places) {
|
|
21060
|
+
return function(number) {
|
|
21061
|
+
return roundTo(number, places);
|
|
21062
|
+
};
|
|
21063
|
+
}
|
|
21064
|
+
function getset(model, channel, modifier) {
|
|
21065
|
+
model = Array.isArray(model) ? model : [model];
|
|
21066
|
+
for (const m of model) {
|
|
21067
|
+
(limiters[m] || (limiters[m] = []))[channel] = modifier;
|
|
21068
|
+
}
|
|
21069
|
+
model = model[0];
|
|
21070
|
+
return function(value) {
|
|
21071
|
+
let result;
|
|
21072
|
+
if (value !== void 0) {
|
|
21073
|
+
if (modifier) {
|
|
21074
|
+
value = modifier(value);
|
|
21075
|
+
}
|
|
21076
|
+
result = this[model]();
|
|
21077
|
+
result.color[channel] = value;
|
|
21078
|
+
return result;
|
|
21079
|
+
}
|
|
21080
|
+
result = this[model]().color[channel];
|
|
21081
|
+
if (modifier) {
|
|
21082
|
+
result = modifier(result);
|
|
21083
|
+
}
|
|
21084
|
+
return result;
|
|
21085
|
+
};
|
|
21086
|
+
}
|
|
21087
|
+
function maxfn(max) {
|
|
21088
|
+
return function(v) {
|
|
21089
|
+
return Math.max(0, Math.min(max, v));
|
|
21090
|
+
};
|
|
21091
|
+
}
|
|
21092
|
+
function assertArray(value) {
|
|
21093
|
+
return Array.isArray(value) ? value : [value];
|
|
21094
|
+
}
|
|
21095
|
+
function zeroArray(array, length) {
|
|
21096
|
+
for (let i = 0; i < length; i++) {
|
|
21097
|
+
if (typeof array[i] !== "number") {
|
|
21098
|
+
array[i] = 0;
|
|
21099
|
+
}
|
|
21100
|
+
}
|
|
21101
|
+
return array;
|
|
21102
|
+
}
|
|
21103
|
+
var color_default = Color2;
|
|
21104
|
+
|
|
19533
21105
|
// src/components/ui/color-picker.tsx
|
|
19534
|
-
var import_color = __toESM(require("color"));
|
|
19535
21106
|
var import_lucide_react48 = require("lucide-react");
|
|
19536
21107
|
var import_radix_ui = require("radix-ui");
|
|
19537
21108
|
var import_react56 = require("react");
|
|
@@ -19554,8 +21125,8 @@ var ColorPicker = ({
|
|
|
19554
21125
|
className,
|
|
19555
21126
|
...props
|
|
19556
21127
|
}) => {
|
|
19557
|
-
const selectedColor = (
|
|
19558
|
-
const defaultColor = (
|
|
21128
|
+
const selectedColor = color_default(value);
|
|
21129
|
+
const defaultColor = color_default(defaultValue);
|
|
19559
21130
|
const [hue, setHue] = (0, import_react56.useState)(selectedColor.hue() || defaultColor.hue() || 0);
|
|
19560
21131
|
const [saturation, setSaturation] = (0, import_react56.useState)(
|
|
19561
21132
|
selectedColor.saturationl() || defaultColor.saturationl() || 100
|
|
@@ -19575,7 +21146,7 @@ var ColorPicker = ({
|
|
|
19575
21146
|
alphaRef.current = alpha2;
|
|
19576
21147
|
(0, import_react56.useEffect)(() => {
|
|
19577
21148
|
if (value) {
|
|
19578
|
-
const color = (
|
|
21149
|
+
const color = color_default(value);
|
|
19579
21150
|
const hsl = color.hsl().object();
|
|
19580
21151
|
setHue(hsl.h);
|
|
19581
21152
|
setSaturation(hsl.s);
|
|
@@ -19609,7 +21180,7 @@ var ColorPicker = ({
|
|
|
19609
21180
|
alphaRef.current = updates.a;
|
|
19610
21181
|
}
|
|
19611
21182
|
if (onChange) {
|
|
19612
|
-
const color =
|
|
21183
|
+
const color = color_default.hsl(newH, newS, newL).alpha(newA / 100);
|
|
19613
21184
|
const rgba = color.rgb().array();
|
|
19614
21185
|
onChange([rgba[0], rgba[1], rgba[2], newA / 100]);
|
|
19615
21186
|
}
|
|
@@ -19722,7 +21293,7 @@ var ColorPickerEyeDropper = ({ className, ...props }) => {
|
|
|
19722
21293
|
try {
|
|
19723
21294
|
const eyeDropper = new EyeDropper();
|
|
19724
21295
|
const result = await eyeDropper.open();
|
|
19725
|
-
const color = (
|
|
21296
|
+
const color = color_default(result.sRGBHex);
|
|
19726
21297
|
const [h, s, l] = color.hsl().array();
|
|
19727
21298
|
updateColor({ h, s, l, a: 100 });
|
|
19728
21299
|
} catch (error) {
|
|
@@ -19761,7 +21332,7 @@ var PercentageInput = ({ className, ...props }) => {
|
|
|
19761
21332
|
};
|
|
19762
21333
|
var ColorPickerFormat = ({ className, ...props }) => {
|
|
19763
21334
|
const { hue, saturation, lightness, alpha: alpha2, mode } = useColorPicker();
|
|
19764
|
-
const color =
|
|
21335
|
+
const color = color_default.hsl(hue, saturation, lightness, alpha2 / 100);
|
|
19765
21336
|
if (mode === "hex") {
|
|
19766
21337
|
const hex = color.hex();
|
|
19767
21338
|
return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
|
|
@@ -21271,14 +22842,14 @@ init_configuration();
|
|
|
21271
22842
|
var import_react63 = require("react");
|
|
21272
22843
|
function useEditableValue(options) {
|
|
21273
22844
|
const { externalValue, onChange, toLocal, toExternal } = options;
|
|
21274
|
-
const
|
|
21275
|
-
const [localValue, setLocalValue] = (0, import_react63.useState)(
|
|
22845
|
+
const convert3 = toLocal ?? String;
|
|
22846
|
+
const [localValue, setLocalValue] = (0, import_react63.useState)(convert3(externalValue));
|
|
21276
22847
|
const [isFocused, setIsFocused] = (0, import_react63.useState)(false);
|
|
21277
|
-
const displayValue = isFocused ? localValue :
|
|
22848
|
+
const displayValue = isFocused ? localValue : convert3(externalValue);
|
|
21278
22849
|
const handleFocus = (0, import_react63.useCallback)(() => {
|
|
21279
|
-
setLocalValue(
|
|
22850
|
+
setLocalValue(convert3(externalValue));
|
|
21280
22851
|
setIsFocused(true);
|
|
21281
|
-
}, [externalValue,
|
|
22852
|
+
}, [externalValue, convert3]);
|
|
21282
22853
|
const handleBlur = (0, import_react63.useCallback)(() => {
|
|
21283
22854
|
setIsFocused(false);
|
|
21284
22855
|
if (toExternal) {
|