@zag-js/color-utils 0.50.0 → 0.51.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -705
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -677
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,706 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod3) => __copyProps(__defProp({}, "__esModule", { value: true }), mod3);
|
|
20
|
-
var __publicField = (obj, key, value) => {
|
|
21
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
|
-
return value;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
// src/index.ts
|
|
26
|
-
var src_exports = {};
|
|
27
|
-
__export(src_exports, {
|
|
28
|
-
Color: () => Color,
|
|
29
|
-
getColorAreaGradient: () => getColorAreaGradient,
|
|
30
|
-
normalizeColor: () => normalizeColor,
|
|
31
|
-
parseColor: () => parseColor
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(src_exports);
|
|
34
|
-
|
|
35
|
-
// src/color-format-gradient.ts
|
|
36
|
-
var generateRGB_R = (orientation, dir, zValue) => {
|
|
37
|
-
const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
38
|
-
const result = {
|
|
39
|
-
areaStyles: {
|
|
40
|
-
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,0),rgb(${zValue},255,0))`
|
|
41
|
-
},
|
|
42
|
-
areaGradientStyles: {
|
|
43
|
-
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,255),rgb(${zValue},255,255))`,
|
|
44
|
-
WebkitMaskImage: maskImage,
|
|
45
|
-
maskImage
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
return result;
|
|
49
|
-
};
|
|
50
|
-
var generateRGB_G = (orientation, dir, zValue) => {
|
|
51
|
-
const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
52
|
-
const result = {
|
|
53
|
-
areaStyles: {
|
|
54
|
-
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},0),rgb(255,${zValue},0))`
|
|
55
|
-
},
|
|
56
|
-
areaGradientStyles: {
|
|
57
|
-
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},255),rgb(255,${zValue},255))`,
|
|
58
|
-
WebkitMaskImage: maskImage,
|
|
59
|
-
maskImage
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
return result;
|
|
63
|
-
};
|
|
64
|
-
var generateRGB_B = (orientation, dir, zValue) => {
|
|
65
|
-
const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
66
|
-
const result = {
|
|
67
|
-
areaStyles: {
|
|
68
|
-
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,0,${zValue}),rgb(255,0,${zValue}))`
|
|
69
|
-
},
|
|
70
|
-
areaGradientStyles: {
|
|
71
|
-
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,255,${zValue}),rgb(255,255,${zValue}))`,
|
|
72
|
-
WebkitMaskImage: maskImage,
|
|
73
|
-
maskImage
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
return result;
|
|
77
|
-
};
|
|
78
|
-
var generateHSL_H = (orientation, dir, zValue) => {
|
|
79
|
-
const result = {
|
|
80
|
-
areaStyles: {},
|
|
81
|
-
areaGradientStyles: {
|
|
82
|
-
background: [
|
|
83
|
-
`linear-gradient(to ${orientation[Number(dir)]}, hsla(0,0%,0%,1) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,1) 100%)`,
|
|
84
|
-
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,50%),hsla(0,0%,50%,0))`,
|
|
85
|
-
`hsl(${zValue}, 100%, 50%)`
|
|
86
|
-
].join(",")
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
return result;
|
|
90
|
-
};
|
|
91
|
-
var generateHSL_S = (orientation, dir, alphaValue) => {
|
|
92
|
-
const result = {
|
|
93
|
-
areaStyles: {},
|
|
94
|
-
areaGradientStyles: {
|
|
95
|
-
background: [
|
|
96
|
-
`linear-gradient(to ${orientation[Number(!dir)]}, hsla(0,0%,0%,${alphaValue}) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,${alphaValue}) 100%)`,
|
|
97
|
-
`linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
|
|
98
|
-
"hsl(0, 0%, 50%)"
|
|
99
|
-
].join(",")
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
return result;
|
|
103
|
-
};
|
|
104
|
-
var generateHSL_L = (orientation, dir, zValue) => {
|
|
105
|
-
const result = {
|
|
106
|
-
areaStyles: {},
|
|
107
|
-
areaGradientStyles: {
|
|
108
|
-
backgroundImage: [
|
|
109
|
-
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,${zValue}%),hsla(0,0%,${zValue}%,0))`,
|
|
110
|
-
`linear-gradient(to ${orientation[Number(dir)]},hsl(0,100%,${zValue}%),hsl(60,100%,${zValue}%),hsl(120,100%,${zValue}%),hsl(180,100%,${zValue}%),hsl(240,100%,${zValue}%),hsl(300,100%,${zValue}%),hsl(360,100%,${zValue}%))`
|
|
111
|
-
].join(",")
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
return result;
|
|
115
|
-
};
|
|
116
|
-
var generateHSB_H = (orientation, dir, zValue) => {
|
|
117
|
-
const result = {
|
|
118
|
-
areaStyles: {},
|
|
119
|
-
areaGradientStyles: {
|
|
120
|
-
background: [
|
|
121
|
-
`linear-gradient(to ${orientation[Number(dir)]},hsl(0,0%,0%),hsla(0,0%,0%,0))`,
|
|
122
|
-
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,100%),hsla(0,0%,100%,0))`,
|
|
123
|
-
`hsl(${zValue}, 100%, 50%)`
|
|
124
|
-
].join(",")
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
return result;
|
|
128
|
-
};
|
|
129
|
-
var generateHSB_S = (orientation, dir, alphaValue) => {
|
|
130
|
-
const result = {
|
|
131
|
-
areaStyles: {},
|
|
132
|
-
areaGradientStyles: {
|
|
133
|
-
background: [
|
|
134
|
-
`linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,0%,${alphaValue}),hsla(0,0%,0%,0))`,
|
|
135
|
-
`linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
|
|
136
|
-
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,0%),hsl(0,0%,100%))`
|
|
137
|
-
].join(",")
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
return result;
|
|
141
|
-
};
|
|
142
|
-
var generateHSB_B = (orientation, dir, alphaValue) => {
|
|
143
|
-
const result = {
|
|
144
|
-
areaStyles: {},
|
|
145
|
-
areaGradientStyles: {
|
|
146
|
-
background: [
|
|
147
|
-
`linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,100%,${alphaValue}),hsla(0,0%,100%,0))`,
|
|
148
|
-
`linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
|
|
149
|
-
"#000"
|
|
150
|
-
].join(",")
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
return result;
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
// src/area-gradient.ts
|
|
157
|
-
function getColorAreaGradient(color, options) {
|
|
158
|
-
const { xChannel, yChannel, dir: dirProp = "ltr" } = options;
|
|
159
|
-
const { zChannel } = color.getColorAxes({ xChannel, yChannel });
|
|
160
|
-
const zValue = color.getChannelValue(zChannel);
|
|
161
|
-
const { minValue: zMin, maxValue: zMax } = color.getChannelRange(zChannel);
|
|
162
|
-
const orientation = ["top", dirProp === "rtl" ? "left" : "right"];
|
|
163
|
-
let dir = false;
|
|
164
|
-
let background = { areaStyles: {}, areaGradientStyles: {} };
|
|
165
|
-
let alphaValue = (zValue - zMin) / (zMax - zMin);
|
|
166
|
-
let isHSL = color.getFormat() === "hsla";
|
|
167
|
-
switch (zChannel) {
|
|
168
|
-
case "red": {
|
|
169
|
-
dir = xChannel === "green";
|
|
170
|
-
background = generateRGB_R(orientation, dir, zValue);
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
173
|
-
case "green": {
|
|
174
|
-
dir = xChannel === "red";
|
|
175
|
-
background = generateRGB_G(orientation, dir, zValue);
|
|
176
|
-
break;
|
|
177
|
-
}
|
|
178
|
-
case "blue": {
|
|
179
|
-
dir = xChannel === "red";
|
|
180
|
-
background = generateRGB_B(orientation, dir, zValue);
|
|
181
|
-
break;
|
|
182
|
-
}
|
|
183
|
-
case "hue": {
|
|
184
|
-
dir = xChannel !== "saturation";
|
|
185
|
-
if (isHSL) {
|
|
186
|
-
background = generateHSL_H(orientation, dir, zValue);
|
|
187
|
-
} else {
|
|
188
|
-
background = generateHSB_H(orientation, dir, zValue);
|
|
189
|
-
}
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
192
|
-
case "saturation": {
|
|
193
|
-
dir = xChannel === "hue";
|
|
194
|
-
if (isHSL) {
|
|
195
|
-
background = generateHSL_S(orientation, dir, alphaValue);
|
|
196
|
-
} else {
|
|
197
|
-
background = generateHSB_S(orientation, dir, alphaValue);
|
|
198
|
-
}
|
|
199
|
-
break;
|
|
200
|
-
}
|
|
201
|
-
case "brightness": {
|
|
202
|
-
dir = xChannel === "hue";
|
|
203
|
-
background = generateHSB_B(orientation, dir, alphaValue);
|
|
204
|
-
break;
|
|
205
|
-
}
|
|
206
|
-
case "lightness": {
|
|
207
|
-
dir = xChannel === "hue";
|
|
208
|
-
background = generateHSL_L(orientation, dir, zValue);
|
|
209
|
-
break;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
return background;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// src/color.ts
|
|
216
|
-
var import_numeric_range = require("@zag-js/numeric-range");
|
|
217
|
-
var isEqualObject = (a, b) => {
|
|
218
|
-
if (Object.keys(a).length !== Object.keys(b).length)
|
|
219
|
-
return false;
|
|
220
|
-
for (let key in a)
|
|
221
|
-
if (a[key] !== b[key])
|
|
222
|
-
return false;
|
|
223
|
-
return true;
|
|
224
|
-
};
|
|
225
|
-
var Color = class {
|
|
226
|
-
toHexInt() {
|
|
227
|
-
return this.toFormat("rgba").toHexInt();
|
|
228
|
-
}
|
|
229
|
-
getChannelValue(channel) {
|
|
230
|
-
if (channel in this)
|
|
231
|
-
return this[channel];
|
|
232
|
-
throw new Error("Unsupported color channel: " + channel);
|
|
233
|
-
}
|
|
234
|
-
getChannelValuePercent(channel, valueToCheck) {
|
|
235
|
-
const value = valueToCheck ?? this.getChannelValue(channel);
|
|
236
|
-
const { minValue, maxValue } = this.getChannelRange(channel);
|
|
237
|
-
return (0, import_numeric_range.getValuePercent)(value, minValue, maxValue);
|
|
238
|
-
}
|
|
239
|
-
getChannelPercentValue(channel, percentToCheck) {
|
|
240
|
-
const { minValue, maxValue, step } = this.getChannelRange(channel);
|
|
241
|
-
const percentValue = (0, import_numeric_range.getPercentValue)(percentToCheck, minValue, maxValue, step);
|
|
242
|
-
return (0, import_numeric_range.snapValueToStep)(percentValue, minValue, maxValue, step);
|
|
243
|
-
}
|
|
244
|
-
withChannelValue(channel, value) {
|
|
245
|
-
const { minValue, maxValue } = this.getChannelRange(channel);
|
|
246
|
-
if (channel in this) {
|
|
247
|
-
let clone = this.clone();
|
|
248
|
-
clone[channel] = (0, import_numeric_range.clampValue)(value, minValue, maxValue);
|
|
249
|
-
return clone;
|
|
250
|
-
}
|
|
251
|
-
throw new Error("Unsupported color channel: " + channel);
|
|
252
|
-
}
|
|
253
|
-
getColorAxes(xyChannels) {
|
|
254
|
-
let { xChannel, yChannel } = xyChannels;
|
|
255
|
-
let xCh = xChannel || this.getChannels().find((c) => c !== yChannel);
|
|
256
|
-
let yCh = yChannel || this.getChannels().find((c) => c !== xCh);
|
|
257
|
-
let zCh = this.getChannels().find((c) => c !== xCh && c !== yCh);
|
|
258
|
-
return { xChannel: xCh, yChannel: yCh, zChannel: zCh };
|
|
259
|
-
}
|
|
260
|
-
incrementChannel(channel, stepSize) {
|
|
261
|
-
const { minValue, maxValue, step } = this.getChannelRange(channel);
|
|
262
|
-
const value = (0, import_numeric_range.snapValueToStep)(
|
|
263
|
-
(0, import_numeric_range.clampValue)(this.getChannelValue(channel) + stepSize, minValue, maxValue),
|
|
264
|
-
minValue,
|
|
265
|
-
maxValue,
|
|
266
|
-
step
|
|
267
|
-
);
|
|
268
|
-
return this.withChannelValue(channel, value);
|
|
269
|
-
}
|
|
270
|
-
decrementChannel(channel, stepSize) {
|
|
271
|
-
return this.incrementChannel(channel, -stepSize);
|
|
272
|
-
}
|
|
273
|
-
isEqual(color) {
|
|
274
|
-
const isSame = isEqualObject(this.toJSON(), color.toJSON());
|
|
275
|
-
return isSame && this.getChannelValue("alpha") === color.getChannelValue("alpha");
|
|
276
|
-
}
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
// src/hsb-color.ts
|
|
280
|
-
var import_numeric_range4 = require("@zag-js/numeric-range");
|
|
281
|
-
|
|
282
|
-
// src/hsl-color.ts
|
|
283
|
-
var import_numeric_range3 = require("@zag-js/numeric-range");
|
|
284
|
-
|
|
285
|
-
// src/rgb-color.ts
|
|
286
|
-
var import_numeric_range2 = require("@zag-js/numeric-range");
|
|
287
|
-
var _RGBColor = class _RGBColor extends Color {
|
|
288
|
-
constructor(red, green, blue, alpha) {
|
|
289
|
-
super();
|
|
290
|
-
this.red = red;
|
|
291
|
-
this.green = green;
|
|
292
|
-
this.blue = blue;
|
|
293
|
-
this.alpha = alpha;
|
|
294
|
-
}
|
|
295
|
-
static parse(value) {
|
|
296
|
-
let colors = [];
|
|
297
|
-
if (/^#[\da-f]+$/i.test(value) && [4, 5, 7, 9].includes(value.length)) {
|
|
298
|
-
const values = (value.length < 6 ? value.replace(/[^#]/gi, "$&$&") : value).slice(1).split("");
|
|
299
|
-
while (values.length > 0) {
|
|
300
|
-
colors.push(parseInt(values.splice(0, 2).join(""), 16));
|
|
301
|
-
}
|
|
302
|
-
colors[3] = colors[3] !== void 0 ? colors[3] / 255 : void 0;
|
|
303
|
-
}
|
|
304
|
-
const match = value.match(/^rgba?\((.*)\)$/);
|
|
305
|
-
if (match?.[1]) {
|
|
306
|
-
colors = match[1].split(",").map((value2) => Number(value2.trim())).map((num, i) => (0, import_numeric_range2.clampValue)(num, 0, i < 3 ? 255 : 1));
|
|
307
|
-
}
|
|
308
|
-
return colors.length < 3 ? void 0 : new _RGBColor(colors[0], colors[1], colors[2], colors[3] ?? 1);
|
|
309
|
-
}
|
|
310
|
-
toString(format) {
|
|
311
|
-
switch (format) {
|
|
312
|
-
case "hex":
|
|
313
|
-
return "#" + (this.red.toString(16).padStart(2, "0") + this.green.toString(16).padStart(2, "0") + this.blue.toString(16).padStart(2, "0")).toUpperCase();
|
|
314
|
-
case "hexa":
|
|
315
|
-
return "#" + (this.red.toString(16).padStart(2, "0") + this.green.toString(16).padStart(2, "0") + this.blue.toString(16).padStart(2, "0") + Math.round(this.alpha * 255).toString(16).padStart(2, "0")).toUpperCase();
|
|
316
|
-
case "rgb":
|
|
317
|
-
return `rgb(${this.red}, ${this.green}, ${this.blue})`;
|
|
318
|
-
case "css":
|
|
319
|
-
case "rgba":
|
|
320
|
-
return `rgba(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`;
|
|
321
|
-
case "hsl":
|
|
322
|
-
return this.toHSL().toString("hsl");
|
|
323
|
-
case "hsb":
|
|
324
|
-
return this.toHSB().toString("hsb");
|
|
325
|
-
default:
|
|
326
|
-
return this.toFormat(format).toString(format);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
toFormat(format) {
|
|
330
|
-
switch (format) {
|
|
331
|
-
case "rgba":
|
|
332
|
-
return this;
|
|
333
|
-
case "hsba":
|
|
334
|
-
return this.toHSB();
|
|
335
|
-
case "hsla":
|
|
336
|
-
return this.toHSL();
|
|
337
|
-
default:
|
|
338
|
-
throw new Error("Unsupported color conversion: rgb -> " + format);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
toHexInt() {
|
|
342
|
-
return this.red << 16 | this.green << 8 | this.blue;
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* Converts an RGB color value to HSB.
|
|
346
|
-
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.
|
|
347
|
-
* @returns An HSBColor object.
|
|
348
|
-
*/
|
|
349
|
-
toHSB() {
|
|
350
|
-
const red = this.red / 255;
|
|
351
|
-
const green = this.green / 255;
|
|
352
|
-
const blue = this.blue / 255;
|
|
353
|
-
const min = Math.min(red, green, blue);
|
|
354
|
-
const brightness = Math.max(red, green, blue);
|
|
355
|
-
const chroma = brightness - min;
|
|
356
|
-
const saturation = brightness === 0 ? 0 : chroma / brightness;
|
|
357
|
-
let hue = 0;
|
|
358
|
-
if (chroma !== 0) {
|
|
359
|
-
switch (brightness) {
|
|
360
|
-
case red:
|
|
361
|
-
hue = (green - blue) / chroma + (green < blue ? 6 : 0);
|
|
362
|
-
break;
|
|
363
|
-
case green:
|
|
364
|
-
hue = (blue - red) / chroma + 2;
|
|
365
|
-
break;
|
|
366
|
-
case blue:
|
|
367
|
-
hue = (red - green) / chroma + 4;
|
|
368
|
-
break;
|
|
369
|
-
}
|
|
370
|
-
hue /= 6;
|
|
371
|
-
}
|
|
372
|
-
return new HSBColor(
|
|
373
|
-
(0, import_numeric_range2.toFixedNumber)(hue * 360, 2),
|
|
374
|
-
(0, import_numeric_range2.toFixedNumber)(saturation * 100, 2),
|
|
375
|
-
(0, import_numeric_range2.toFixedNumber)(brightness * 100, 2),
|
|
376
|
-
(0, import_numeric_range2.toFixedNumber)(this.alpha, 2)
|
|
377
|
-
);
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* Converts an RGB color value to HSL.
|
|
381
|
-
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.
|
|
382
|
-
* @returns An HSLColor object.
|
|
383
|
-
*/
|
|
384
|
-
toHSL() {
|
|
385
|
-
const red = this.red / 255;
|
|
386
|
-
const green = this.green / 255;
|
|
387
|
-
const blue = this.blue / 255;
|
|
388
|
-
const min = Math.min(red, green, blue);
|
|
389
|
-
const max = Math.max(red, green, blue);
|
|
390
|
-
const lightness = (max + min) / 2;
|
|
391
|
-
const chroma = max - min;
|
|
392
|
-
let hue = -1;
|
|
393
|
-
let saturation = -1;
|
|
394
|
-
if (chroma === 0) {
|
|
395
|
-
hue = saturation = 0;
|
|
396
|
-
} else {
|
|
397
|
-
saturation = chroma / (lightness < 0.5 ? max + min : 2 - max - min);
|
|
398
|
-
switch (max) {
|
|
399
|
-
case red:
|
|
400
|
-
hue = (green - blue) / chroma + (green < blue ? 6 : 0);
|
|
401
|
-
break;
|
|
402
|
-
case green:
|
|
403
|
-
hue = (blue - red) / chroma + 2;
|
|
404
|
-
break;
|
|
405
|
-
case blue:
|
|
406
|
-
hue = (red - green) / chroma + 4;
|
|
407
|
-
break;
|
|
408
|
-
}
|
|
409
|
-
hue /= 6;
|
|
410
|
-
}
|
|
411
|
-
return new HSLColor(
|
|
412
|
-
(0, import_numeric_range2.toFixedNumber)(hue * 360, 2),
|
|
413
|
-
(0, import_numeric_range2.toFixedNumber)(saturation * 100, 2),
|
|
414
|
-
(0, import_numeric_range2.toFixedNumber)(lightness * 100, 2),
|
|
415
|
-
(0, import_numeric_range2.toFixedNumber)(this.alpha, 2)
|
|
416
|
-
);
|
|
417
|
-
}
|
|
418
|
-
clone() {
|
|
419
|
-
return new _RGBColor(this.red, this.green, this.blue, this.alpha);
|
|
420
|
-
}
|
|
421
|
-
getChannelRange(channel) {
|
|
422
|
-
switch (channel) {
|
|
423
|
-
case "red":
|
|
424
|
-
case "green":
|
|
425
|
-
case "blue":
|
|
426
|
-
return { minValue: 0, maxValue: 255, step: 1, pageSize: 17 };
|
|
427
|
-
case "alpha":
|
|
428
|
-
return { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 };
|
|
429
|
-
default:
|
|
430
|
-
throw new Error("Unknown color channel: " + channel);
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
toJSON() {
|
|
434
|
-
return { r: this.red, g: this.green, b: this.blue, a: this.alpha };
|
|
435
|
-
}
|
|
436
|
-
getFormat() {
|
|
437
|
-
return "rgba";
|
|
438
|
-
}
|
|
439
|
-
getChannels() {
|
|
440
|
-
return _RGBColor.colorChannels;
|
|
441
|
-
}
|
|
442
|
-
};
|
|
443
|
-
__publicField(_RGBColor, "colorChannels", ["red", "green", "blue"]);
|
|
444
|
-
var RGBColor = _RGBColor;
|
|
445
|
-
|
|
446
|
-
// src/hsl-color.ts
|
|
447
|
-
var HSL_REGEX = /hsl\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%)\)|hsla\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d(.\d+)?)\)/;
|
|
448
|
-
var _HSLColor = class _HSLColor extends Color {
|
|
449
|
-
constructor(hue, saturation, lightness, alpha) {
|
|
450
|
-
super();
|
|
451
|
-
this.hue = hue;
|
|
452
|
-
this.saturation = saturation;
|
|
453
|
-
this.lightness = lightness;
|
|
454
|
-
this.alpha = alpha;
|
|
455
|
-
}
|
|
456
|
-
static parse(value) {
|
|
457
|
-
let m;
|
|
458
|
-
if (m = value.match(HSL_REGEX)) {
|
|
459
|
-
const [h, s, l, a] = (m[1] ?? m[2]).split(",").map((n) => Number(n.trim().replace("%", "")));
|
|
460
|
-
return new _HSLColor((0, import_numeric_range3.mod)(h, 360), (0, import_numeric_range3.clampValue)(s, 0, 100), (0, import_numeric_range3.clampValue)(l, 0, 100), (0, import_numeric_range3.clampValue)(a ?? 1, 0, 1));
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
toString(format) {
|
|
464
|
-
switch (format) {
|
|
465
|
-
case "hex":
|
|
466
|
-
return this.toRGB().toString("hex");
|
|
467
|
-
case "hexa":
|
|
468
|
-
return this.toRGB().toString("hexa");
|
|
469
|
-
case "hsl":
|
|
470
|
-
return `hsl(${this.hue}, ${(0, import_numeric_range3.toFixedNumber)(this.saturation, 2)}%, ${(0, import_numeric_range3.toFixedNumber)(this.lightness, 2)}%)`;
|
|
471
|
-
case "css":
|
|
472
|
-
case "hsla":
|
|
473
|
-
return `hsla(${this.hue}, ${(0, import_numeric_range3.toFixedNumber)(this.saturation, 2)}%, ${(0, import_numeric_range3.toFixedNumber)(this.lightness, 2)}%, ${this.alpha})`;
|
|
474
|
-
case "hsb":
|
|
475
|
-
return this.toHSB().toString("hsb");
|
|
476
|
-
case "rgb":
|
|
477
|
-
return this.toRGB().toString("rgb");
|
|
478
|
-
default:
|
|
479
|
-
return this.toFormat(format).toString(format);
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
toFormat(format) {
|
|
483
|
-
switch (format) {
|
|
484
|
-
case "hsla":
|
|
485
|
-
return this;
|
|
486
|
-
case "hsba":
|
|
487
|
-
return this.toHSB();
|
|
488
|
-
case "rgba":
|
|
489
|
-
return this.toRGB();
|
|
490
|
-
default:
|
|
491
|
-
throw new Error("Unsupported color conversion: hsl -> " + format);
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
/**
|
|
495
|
-
* Converts a HSL color to HSB.
|
|
496
|
-
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_HSV.
|
|
497
|
-
* @returns An HSBColor object.
|
|
498
|
-
*/
|
|
499
|
-
toHSB() {
|
|
500
|
-
let saturation = this.saturation / 100;
|
|
501
|
-
let lightness = this.lightness / 100;
|
|
502
|
-
let brightness = lightness + saturation * Math.min(lightness, 1 - lightness);
|
|
503
|
-
saturation = brightness === 0 ? 0 : 2 * (1 - lightness / brightness);
|
|
504
|
-
return new HSBColor(
|
|
505
|
-
(0, import_numeric_range3.toFixedNumber)(this.hue, 2),
|
|
506
|
-
(0, import_numeric_range3.toFixedNumber)(saturation * 100, 2),
|
|
507
|
-
(0, import_numeric_range3.toFixedNumber)(brightness * 100, 2),
|
|
508
|
-
(0, import_numeric_range3.toFixedNumber)(this.alpha, 2)
|
|
509
|
-
);
|
|
510
|
-
}
|
|
511
|
-
/**
|
|
512
|
-
* Converts a HSL color to RGB.
|
|
513
|
-
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB_alternative.
|
|
514
|
-
* @returns An RGBColor object.
|
|
515
|
-
*/
|
|
516
|
-
toRGB() {
|
|
517
|
-
let hue = this.hue;
|
|
518
|
-
let saturation = this.saturation / 100;
|
|
519
|
-
let lightness = this.lightness / 100;
|
|
520
|
-
let a = saturation * Math.min(lightness, 1 - lightness);
|
|
521
|
-
let fn = (n, k = (n + hue / 30) % 12) => lightness - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
|
522
|
-
return new RGBColor(
|
|
523
|
-
Math.round(fn(0) * 255),
|
|
524
|
-
Math.round(fn(8) * 255),
|
|
525
|
-
Math.round(fn(4) * 255),
|
|
526
|
-
(0, import_numeric_range3.toFixedNumber)(this.alpha, 2)
|
|
527
|
-
);
|
|
528
|
-
}
|
|
529
|
-
clone() {
|
|
530
|
-
return new _HSLColor(this.hue, this.saturation, this.lightness, this.alpha);
|
|
531
|
-
}
|
|
532
|
-
getChannelRange(channel) {
|
|
533
|
-
switch (channel) {
|
|
534
|
-
case "hue":
|
|
535
|
-
return { minValue: 0, maxValue: 360, step: 1, pageSize: 15 };
|
|
536
|
-
case "saturation":
|
|
537
|
-
case "lightness":
|
|
538
|
-
return { minValue: 0, maxValue: 100, step: 1, pageSize: 10 };
|
|
539
|
-
case "alpha":
|
|
540
|
-
return { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 };
|
|
541
|
-
default:
|
|
542
|
-
throw new Error("Unknown color channel: " + channel);
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
toJSON() {
|
|
546
|
-
return { h: this.hue, s: this.saturation, l: this.lightness, a: this.alpha };
|
|
547
|
-
}
|
|
548
|
-
getFormat() {
|
|
549
|
-
return "hsla";
|
|
550
|
-
}
|
|
551
|
-
getChannels() {
|
|
552
|
-
return _HSLColor.colorChannels;
|
|
553
|
-
}
|
|
554
|
-
};
|
|
555
|
-
__publicField(_HSLColor, "colorChannels", ["hue", "saturation", "lightness"]);
|
|
556
|
-
var HSLColor = _HSLColor;
|
|
557
|
-
|
|
558
|
-
// src/hsb-color.ts
|
|
559
|
-
var HSB_REGEX = /hsb\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%)\)|hsba\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d(.\d+)?)\)/;
|
|
560
|
-
var _HSBColor = class _HSBColor extends Color {
|
|
561
|
-
constructor(hue, saturation, brightness, alpha) {
|
|
562
|
-
super();
|
|
563
|
-
this.hue = hue;
|
|
564
|
-
this.saturation = saturation;
|
|
565
|
-
this.brightness = brightness;
|
|
566
|
-
this.alpha = alpha;
|
|
567
|
-
}
|
|
568
|
-
static parse(value) {
|
|
569
|
-
let m;
|
|
570
|
-
if (m = value.match(HSB_REGEX)) {
|
|
571
|
-
const [h, s, b, a] = (m[1] ?? m[2]).split(",").map((n) => Number(n.trim().replace("%", "")));
|
|
572
|
-
return new _HSBColor((0, import_numeric_range4.mod)(h, 360), (0, import_numeric_range4.clampValue)(s, 0, 100), (0, import_numeric_range4.clampValue)(b, 0, 100), (0, import_numeric_range4.clampValue)(a ?? 1, 0, 1));
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
toString(format) {
|
|
576
|
-
switch (format) {
|
|
577
|
-
case "css":
|
|
578
|
-
return this.toHSL().toString("css");
|
|
579
|
-
case "hex":
|
|
580
|
-
return this.toRGB().toString("hex");
|
|
581
|
-
case "hexa":
|
|
582
|
-
return this.toRGB().toString("hexa");
|
|
583
|
-
case "hsb":
|
|
584
|
-
return `hsb(${this.hue}, ${(0, import_numeric_range4.toFixedNumber)(this.saturation, 2)}%, ${(0, import_numeric_range4.toFixedNumber)(this.brightness, 2)}%)`;
|
|
585
|
-
case "hsba":
|
|
586
|
-
return `hsba(${this.hue}, ${(0, import_numeric_range4.toFixedNumber)(this.saturation, 2)}%, ${(0, import_numeric_range4.toFixedNumber)(this.brightness, 2)}%, ${this.alpha})`;
|
|
587
|
-
case "hsl":
|
|
588
|
-
return this.toHSL().toString("hsl");
|
|
589
|
-
case "rgb":
|
|
590
|
-
return this.toRGB().toString("rgb");
|
|
591
|
-
default:
|
|
592
|
-
return this.toFormat(format).toString(format);
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
toFormat(format) {
|
|
596
|
-
switch (format) {
|
|
597
|
-
case "hsba":
|
|
598
|
-
return this;
|
|
599
|
-
case "hsla":
|
|
600
|
-
return this.toHSL();
|
|
601
|
-
case "rgba":
|
|
602
|
-
return this.toRGB();
|
|
603
|
-
default:
|
|
604
|
-
throw new Error("Unsupported color conversion: hsb -> " + format);
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
/**
|
|
608
|
-
* Converts a HSB color to HSL.
|
|
609
|
-
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_HSL.
|
|
610
|
-
* @returns An HSLColor object.
|
|
611
|
-
*/
|
|
612
|
-
toHSL() {
|
|
613
|
-
let saturation = this.saturation / 100;
|
|
614
|
-
let brightness = this.brightness / 100;
|
|
615
|
-
let lightness = brightness * (1 - saturation / 2);
|
|
616
|
-
saturation = lightness === 0 || lightness === 1 ? 0 : (brightness - lightness) / Math.min(lightness, 1 - lightness);
|
|
617
|
-
return new HSLColor(
|
|
618
|
-
(0, import_numeric_range4.toFixedNumber)(this.hue, 2),
|
|
619
|
-
(0, import_numeric_range4.toFixedNumber)(saturation * 100, 2),
|
|
620
|
-
(0, import_numeric_range4.toFixedNumber)(lightness * 100, 2),
|
|
621
|
-
(0, import_numeric_range4.toFixedNumber)(this.alpha, 2)
|
|
622
|
-
);
|
|
623
|
-
}
|
|
624
|
-
/**
|
|
625
|
-
* Converts a HSV color value to RGB.
|
|
626
|
-
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_RGB_alternative.
|
|
627
|
-
* @returns An RGBColor object.
|
|
628
|
-
*/
|
|
629
|
-
toRGB() {
|
|
630
|
-
let hue = this.hue;
|
|
631
|
-
let saturation = this.saturation / 100;
|
|
632
|
-
let brightness = this.brightness / 100;
|
|
633
|
-
let fn = (n, k = (n + hue / 60) % 6) => brightness - saturation * brightness * Math.max(Math.min(k, 4 - k, 1), 0);
|
|
634
|
-
return new RGBColor(
|
|
635
|
-
Math.round(fn(5) * 255),
|
|
636
|
-
Math.round(fn(3) * 255),
|
|
637
|
-
Math.round(fn(1) * 255),
|
|
638
|
-
(0, import_numeric_range4.toFixedNumber)(this.alpha, 2)
|
|
639
|
-
);
|
|
640
|
-
}
|
|
641
|
-
clone() {
|
|
642
|
-
return new _HSBColor(this.hue, this.saturation, this.brightness, this.alpha);
|
|
643
|
-
}
|
|
644
|
-
getChannelRange(channel) {
|
|
645
|
-
switch (channel) {
|
|
646
|
-
case "hue":
|
|
647
|
-
return { minValue: 0, maxValue: 360, step: 1, pageSize: 15 };
|
|
648
|
-
case "saturation":
|
|
649
|
-
case "brightness":
|
|
650
|
-
return { minValue: 0, maxValue: 100, step: 1, pageSize: 10 };
|
|
651
|
-
case "alpha":
|
|
652
|
-
return { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 };
|
|
653
|
-
default:
|
|
654
|
-
throw new Error("Unknown color channel: " + channel);
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
toJSON() {
|
|
658
|
-
return { h: this.hue, s: this.saturation, b: this.brightness, a: this.alpha };
|
|
659
|
-
}
|
|
660
|
-
getFormat() {
|
|
661
|
-
return "hsba";
|
|
662
|
-
}
|
|
663
|
-
getChannels() {
|
|
664
|
-
return _HSBColor.colorChannels;
|
|
665
|
-
}
|
|
666
|
-
};
|
|
667
|
-
__publicField(_HSBColor, "colorChannels", ["hue", "saturation", "brightness"]);
|
|
668
|
-
var HSBColor = _HSBColor;
|
|
669
|
-
|
|
670
|
-
// src/native-color.ts
|
|
671
|
-
var nativeColors = "aliceblue:f0f8ff,antiquewhite:faebd7,aqua:00ffff,aquamarine:7fffd4,azure:f0ffff,beige:f5f5dc,bisque:ffe4c4,black:000000,blanchedalmond:ffebcd,blue:0000ff,blueviolet:8a2be2,brown:a52a2a,burlywood:deb887,cadetblue:5f9ea0,chartreuse:7fff00,chocolate:d2691e,coral:ff7f50,cornflowerblue:6495ed,cornsilk:fff8dc,crimson:dc143c,cyan:00ffff,darkblue:00008b,darkcyan:008b8b,darkgoldenrod:b8860b,darkgray:a9a9a9,darkgreen:006400,darkkhaki:bdb76b,darkmagenta:8b008b,darkolivegreen:556b2f,darkorange:ff8c00,darkorchid:9932cc,darkred:8b0000,darksalmon:e9967a,darkseagreen:8fbc8f,darkslateblue:483d8b,darkslategray:2f4f4f,darkturquoise:00ced1,darkviolet:9400d3,deeppink:ff1493,deepskyblue:00bfff,dimgray:696969,dodgerblue:1e90ff,firebrick:b22222,floralwhite:fffaf0,forestgreen:228b22,fuchsia:ff00ff,gainsboro:dcdcdc,ghostwhite:f8f8ff,gold:ffd700,goldenrod:daa520,gray:808080,green:008000,greenyellow:adff2f,honeydew:f0fff0,hotpink:ff69b4,indianred:cd5c5c,indigo:4b0082,ivory:fffff0,khaki:f0e68c,lavender:e6e6fa,lavenderblush:fff0f5,lawngreen:7cfc00,lemonchiffon:fffacd,lightblue:add8e6,lightcoral:f08080,lightcyan:e0ffff,lightgoldenrodyellow:fafad2,lightgrey:d3d3d3,lightgreen:90ee90,lightpink:ffb6c1,lightsalmon:ffa07a,lightseagreen:20b2aa,lightskyblue:87cefa,lightslategray:778899,lightsteelblue:b0c4de,lightyellow:ffffe0,lime:00ff00,limegreen:32cd32,linen:faf0e6,magenta:ff00ff,maroon:800000,mediumaquamarine:66cdaa,mediumblue:0000cd,mediumorchid:ba55d3,mediumpurple:9370d8,mediumseagreen:3cb371,mediumslateblue:7b68ee,mediumspringgreen:00fa9a,mediumturquoise:48d1cc,mediumvioletred:c71585,midnightblue:191970,mintcream:f5fffa,mistyrose:ffe4e1,moccasin:ffe4b5,navajowhite:ffdead,navy:000080,oldlace:fdf5e6,olive:808000,olivedrab:6b8e23,orange:ffa500,orangered:ff4500,orchid:da70d6,palegoldenrod:eee8aa,palegreen:98fb98,paleturquoise:afeeee,palevioletred:d87093,papayawhip:ffefd5,peachpuff:ffdab9,peru:cd853f,pink:ffc0cb,plum:dda0dd,powderblue:b0e0e6,purple:800080,red:ff0000,rosybrown:bc8f8f,royalblue:4169e1,saddlebrown:8b4513,salmon:fa8072,sandybrown:f4a460,seagreen:2e8b57,seashell:fff5ee,sienna:a0522d,silver:c0c0c0,skyblue:87ceeb,slateblue:6a5acd,slategray:708090,snow:fffafa,springgreen:00ff7f,steelblue:4682b4,tan:d2b48c,teal:008080,thistle:d8bfd8,tomato:ff6347,turquoise:40e0d0,violet:ee82ee,wheat:f5deb3,white:ffffff,whitesmoke:f5f5f5,yellow:ffff00,yellowgreen:9acd32";
|
|
672
|
-
var makeMap = (str) => {
|
|
673
|
-
const map = /* @__PURE__ */ new Map();
|
|
674
|
-
const list = str.split(",");
|
|
675
|
-
for (let i = 0; i < list.length; i++) {
|
|
676
|
-
const [key, val] = list[i].split(":");
|
|
677
|
-
map.set(key, `#${val}`);
|
|
678
|
-
}
|
|
679
|
-
return map;
|
|
680
|
-
};
|
|
681
|
-
var nativeColorMap = makeMap(nativeColors);
|
|
682
|
-
|
|
683
|
-
// src/parse-color.ts
|
|
684
|
-
var parseColor = (value) => {
|
|
685
|
-
if (nativeColorMap.has(value)) {
|
|
686
|
-
return parseColor(nativeColorMap.get(value));
|
|
687
|
-
}
|
|
688
|
-
const result = RGBColor.parse(value) || HSBColor.parse(value) || HSLColor.parse(value);
|
|
689
|
-
if (!result) {
|
|
690
|
-
const error = new Error("Invalid color value: " + value);
|
|
691
|
-
Error.captureStackTrace?.(error, parseColor);
|
|
692
|
-
throw error;
|
|
693
|
-
}
|
|
694
|
-
return result;
|
|
695
|
-
};
|
|
696
|
-
var normalizeColor = (v) => {
|
|
697
|
-
return typeof v === "string" ? parseColor(v) : v;
|
|
698
|
-
};
|
|
699
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
700
|
-
0 && (module.exports = {
|
|
701
|
-
Color,
|
|
702
|
-
getColorAreaGradient,
|
|
703
|
-
normalizeColor,
|
|
704
|
-
parseColor
|
|
705
|
-
});
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:true,configurable:true,writable:true,value}):obj[key]=value;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from==="object"||typeof from==="function"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toCommonJS=mod3=>__copyProps(__defProp({},"__esModule",{value:true}),mod3);var __publicField=(obj,key,value)=>{__defNormalProp(obj,typeof key!=="symbol"?key+"":key,value);return value};var src_exports={};__export(src_exports,{Color:()=>Color,getColorAreaGradient:()=>getColorAreaGradient,normalizeColor:()=>normalizeColor,parseColor:()=>parseColor});module.exports=__toCommonJS(src_exports);var generateRGB_R=(orientation,dir,zValue)=>{const maskImage=`linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;const result={areaStyles:{backgroundImage:`linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,0),rgb(${zValue},255,0))`},areaGradientStyles:{backgroundImage:`linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,255),rgb(${zValue},255,255))`,WebkitMaskImage:maskImage,maskImage}};return result};var generateRGB_G=(orientation,dir,zValue)=>{const maskImage=`linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;const result={areaStyles:{backgroundImage:`linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},0),rgb(255,${zValue},0))`},areaGradientStyles:{backgroundImage:`linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},255),rgb(255,${zValue},255))`,WebkitMaskImage:maskImage,maskImage}};return result};var generateRGB_B=(orientation,dir,zValue)=>{const maskImage=`linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;const result={areaStyles:{backgroundImage:`linear-gradient(to ${orientation[Number(dir)]},rgb(0,0,${zValue}),rgb(255,0,${zValue}))`},areaGradientStyles:{backgroundImage:`linear-gradient(to ${orientation[Number(dir)]},rgb(0,255,${zValue}),rgb(255,255,${zValue}))`,WebkitMaskImage:maskImage,maskImage}};return result};var generateHSL_H=(orientation,dir,zValue)=>{const result={areaStyles:{},areaGradientStyles:{background:[`linear-gradient(to ${orientation[Number(dir)]}, hsla(0,0%,0%,1) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,1) 100%)`,`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,50%),hsla(0,0%,50%,0))`,`hsl(${zValue}, 100%, 50%)`].join(",")}};return result};var generateHSL_S=(orientation,dir,alphaValue)=>{const result={areaStyles:{},areaGradientStyles:{background:[`linear-gradient(to ${orientation[Number(!dir)]}, hsla(0,0%,0%,${alphaValue}) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,${alphaValue}) 100%)`,`linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,"hsl(0, 0%, 50%)"].join(",")}};return result};var generateHSL_L=(orientation,dir,zValue)=>{const result={areaStyles:{},areaGradientStyles:{backgroundImage:[`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,${zValue}%),hsla(0,0%,${zValue}%,0))`,`linear-gradient(to ${orientation[Number(dir)]},hsl(0,100%,${zValue}%),hsl(60,100%,${zValue}%),hsl(120,100%,${zValue}%),hsl(180,100%,${zValue}%),hsl(240,100%,${zValue}%),hsl(300,100%,${zValue}%),hsl(360,100%,${zValue}%))`].join(",")}};return result};var generateHSB_H=(orientation,dir,zValue)=>{const result={areaStyles:{},areaGradientStyles:{background:[`linear-gradient(to ${orientation[Number(dir)]},hsl(0,0%,0%),hsla(0,0%,0%,0))`,`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,100%),hsla(0,0%,100%,0))`,`hsl(${zValue}, 100%, 50%)`].join(",")}};return result};var generateHSB_S=(orientation,dir,alphaValue)=>{const result={areaStyles:{},areaGradientStyles:{background:[`linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,0%,${alphaValue}),hsla(0,0%,0%,0))`,`linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,0%),hsl(0,0%,100%))`].join(",")}};return result};var generateHSB_B=(orientation,dir,alphaValue)=>{const result={areaStyles:{},areaGradientStyles:{background:[`linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,100%,${alphaValue}),hsla(0,0%,100%,0))`,`linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,"#000"].join(",")}};return result};function getColorAreaGradient(color,options){const{xChannel,yChannel,dir:dirProp="ltr"}=options;const{zChannel}=color.getColorAxes({xChannel,yChannel});const zValue=color.getChannelValue(zChannel);const{minValue:zMin,maxValue:zMax}=color.getChannelRange(zChannel);const orientation=["top",dirProp==="rtl"?"left":"right"];let dir=false;let background={areaStyles:{},areaGradientStyles:{}};let alphaValue=(zValue-zMin)/(zMax-zMin);let isHSL=color.getFormat()==="hsla";switch(zChannel){case"red":{dir=xChannel==="green";background=generateRGB_R(orientation,dir,zValue);break}case"green":{dir=xChannel==="red";background=generateRGB_G(orientation,dir,zValue);break}case"blue":{dir=xChannel==="red";background=generateRGB_B(orientation,dir,zValue);break}case"hue":{dir=xChannel!=="saturation";if(isHSL){background=generateHSL_H(orientation,dir,zValue)}else{background=generateHSB_H(orientation,dir,zValue)}break}case"saturation":{dir=xChannel==="hue";if(isHSL){background=generateHSL_S(orientation,dir,alphaValue)}else{background=generateHSB_S(orientation,dir,alphaValue)}break}case"brightness":{dir=xChannel==="hue";background=generateHSB_B(orientation,dir,alphaValue);break}case"lightness":{dir=xChannel==="hue";background=generateHSL_L(orientation,dir,zValue);break}}return background}var import_numeric_range=require("@zag-js/numeric-range");var isEqualObject=(a,b)=>{if(Object.keys(a).length!==Object.keys(b).length)return false;for(let key in a)if(a[key]!==b[key])return false;return true};var Color=class{toHexInt(){return this.toFormat("rgba").toHexInt()}getChannelValue(channel){if(channel in this)return this[channel];throw new Error("Unsupported color channel: "+channel)}getChannelValuePercent(channel,valueToCheck){const value=valueToCheck??this.getChannelValue(channel);const{minValue,maxValue}=this.getChannelRange(channel);return(0,import_numeric_range.getValuePercent)(value,minValue,maxValue)}getChannelPercentValue(channel,percentToCheck){const{minValue,maxValue,step}=this.getChannelRange(channel);const percentValue=(0,import_numeric_range.getPercentValue)(percentToCheck,minValue,maxValue,step);return(0,import_numeric_range.snapValueToStep)(percentValue,minValue,maxValue,step)}withChannelValue(channel,value){const{minValue,maxValue}=this.getChannelRange(channel);if(channel in this){let clone=this.clone();clone[channel]=(0,import_numeric_range.clampValue)(value,minValue,maxValue);return clone}throw new Error("Unsupported color channel: "+channel)}getColorAxes(xyChannels){let{xChannel,yChannel}=xyChannels;let xCh=xChannel||this.getChannels().find(c=>c!==yChannel);let yCh=yChannel||this.getChannels().find(c=>c!==xCh);let zCh=this.getChannels().find(c=>c!==xCh&&c!==yCh);return{xChannel:xCh,yChannel:yCh,zChannel:zCh}}incrementChannel(channel,stepSize){const{minValue,maxValue,step}=this.getChannelRange(channel);const value=(0,import_numeric_range.snapValueToStep)((0,import_numeric_range.clampValue)(this.getChannelValue(channel)+stepSize,minValue,maxValue),minValue,maxValue,step);return this.withChannelValue(channel,value)}decrementChannel(channel,stepSize){return this.incrementChannel(channel,-stepSize)}isEqual(color){const isSame=isEqualObject(this.toJSON(),color.toJSON());return isSame&&this.getChannelValue("alpha")===color.getChannelValue("alpha")}};var import_numeric_range4=require("@zag-js/numeric-range");var import_numeric_range3=require("@zag-js/numeric-range");var import_numeric_range2=require("@zag-js/numeric-range");var _RGBColor=class _RGBColor extends Color{constructor(red,green,blue,alpha){super();this.red=red;this.green=green;this.blue=blue;this.alpha=alpha}static parse(value){let colors=[];if(/^#[\da-f]+$/i.test(value)&&[4,5,7,9].includes(value.length)){const values=(value.length<6?value.replace(/[^#]/gi,"$&$&"):value).slice(1).split("");while(values.length>0){colors.push(parseInt(values.splice(0,2).join(""),16))}colors[3]=colors[3]!==void 0?colors[3]/255:void 0}const match=value.match(/^rgba?\((.*)\)$/);if(match?.[1]){colors=match[1].split(",").map(value2=>Number(value2.trim())).map((num,i)=>(0,import_numeric_range2.clampValue)(num,0,i<3?255:1))}return colors.length<3?void 0:new _RGBColor(colors[0],colors[1],colors[2],colors[3]??1)}toString(format){switch(format){case"hex":return"#"+(this.red.toString(16).padStart(2,"0")+this.green.toString(16).padStart(2,"0")+this.blue.toString(16).padStart(2,"0")).toUpperCase();case"hexa":return"#"+(this.red.toString(16).padStart(2,"0")+this.green.toString(16).padStart(2,"0")+this.blue.toString(16).padStart(2,"0")+Math.round(this.alpha*255).toString(16).padStart(2,"0")).toUpperCase();case"rgb":return`rgb(${this.red}, ${this.green}, ${this.blue})`;case"css":case"rgba":return`rgba(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`;case"hsl":return this.toHSL().toString("hsl");case"hsb":return this.toHSB().toString("hsb");default:return this.toFormat(format).toString(format)}}toFormat(format){switch(format){case"rgba":return this;case"hsba":return this.toHSB();case"hsla":return this.toHSL();default:throw new Error("Unsupported color conversion: rgb -> "+format)}}toHexInt(){return this.red<<16|this.green<<8|this.blue}toHSB(){const red=this.red/255;const green=this.green/255;const blue=this.blue/255;const min=Math.min(red,green,blue);const brightness=Math.max(red,green,blue);const chroma=brightness-min;const saturation=brightness===0?0:chroma/brightness;let hue=0;if(chroma!==0){switch(brightness){case red:hue=(green-blue)/chroma+(green<blue?6:0);break;case green:hue=(blue-red)/chroma+2;break;case blue:hue=(red-green)/chroma+4;break}hue/=6}return new HSBColor((0,import_numeric_range2.toFixedNumber)(hue*360,2),(0,import_numeric_range2.toFixedNumber)(saturation*100,2),(0,import_numeric_range2.toFixedNumber)(brightness*100,2),(0,import_numeric_range2.toFixedNumber)(this.alpha,2))}toHSL(){const red=this.red/255;const green=this.green/255;const blue=this.blue/255;const min=Math.min(red,green,blue);const max=Math.max(red,green,blue);const lightness=(max+min)/2;const chroma=max-min;let hue=-1;let saturation=-1;if(chroma===0){hue=saturation=0}else{saturation=chroma/(lightness<.5?max+min:2-max-min);switch(max){case red:hue=(green-blue)/chroma+(green<blue?6:0);break;case green:hue=(blue-red)/chroma+2;break;case blue:hue=(red-green)/chroma+4;break}hue/=6}return new HSLColor((0,import_numeric_range2.toFixedNumber)(hue*360,2),(0,import_numeric_range2.toFixedNumber)(saturation*100,2),(0,import_numeric_range2.toFixedNumber)(lightness*100,2),(0,import_numeric_range2.toFixedNumber)(this.alpha,2))}clone(){return new _RGBColor(this.red,this.green,this.blue,this.alpha)}getChannelRange(channel){switch(channel){case"red":case"green":case"blue":return{minValue:0,maxValue:255,step:1,pageSize:17};case"alpha":return{minValue:0,maxValue:1,step:.01,pageSize:.1};default:throw new Error("Unknown color channel: "+channel)}}toJSON(){return{r:this.red,g:this.green,b:this.blue,a:this.alpha}}getFormat(){return"rgba"}getChannels(){return _RGBColor.colorChannels}};__publicField(_RGBColor,"colorChannels",["red","green","blue"]);var RGBColor=_RGBColor;var HSL_REGEX=/hsl\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%)\)|hsla\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d(.\d+)?)\)/;var _HSLColor=class _HSLColor extends Color{constructor(hue,saturation,lightness,alpha){super();this.hue=hue;this.saturation=saturation;this.lightness=lightness;this.alpha=alpha}static parse(value){let m;if(m=value.match(HSL_REGEX)){const[h,s,l,a]=(m[1]??m[2]).split(",").map(n=>Number(n.trim().replace("%","")));return new _HSLColor((0,import_numeric_range3.mod)(h,360),(0,import_numeric_range3.clampValue)(s,0,100),(0,import_numeric_range3.clampValue)(l,0,100),(0,import_numeric_range3.clampValue)(a??1,0,1))}}toString(format){switch(format){case"hex":return this.toRGB().toString("hex");case"hexa":return this.toRGB().toString("hexa");case"hsl":return`hsl(${this.hue}, ${(0,import_numeric_range3.toFixedNumber)(this.saturation,2)}%, ${(0,import_numeric_range3.toFixedNumber)(this.lightness,2)}%)`;case"css":case"hsla":return`hsla(${this.hue}, ${(0,import_numeric_range3.toFixedNumber)(this.saturation,2)}%, ${(0,import_numeric_range3.toFixedNumber)(this.lightness,2)}%, ${this.alpha})`;case"hsb":return this.toHSB().toString("hsb");case"rgb":return this.toRGB().toString("rgb");default:return this.toFormat(format).toString(format)}}toFormat(format){switch(format){case"hsla":return this;case"hsba":return this.toHSB();case"rgba":return this.toRGB();default:throw new Error("Unsupported color conversion: hsl -> "+format)}}toHSB(){let saturation=this.saturation/100;let lightness=this.lightness/100;let brightness=lightness+saturation*Math.min(lightness,1-lightness);saturation=brightness===0?0:2*(1-lightness/brightness);return new HSBColor((0,import_numeric_range3.toFixedNumber)(this.hue,2),(0,import_numeric_range3.toFixedNumber)(saturation*100,2),(0,import_numeric_range3.toFixedNumber)(brightness*100,2),(0,import_numeric_range3.toFixedNumber)(this.alpha,2))}toRGB(){let hue=this.hue;let saturation=this.saturation/100;let lightness=this.lightness/100;let a=saturation*Math.min(lightness,1-lightness);let fn=(n,k=(n+hue/30)%12)=>lightness-a*Math.max(Math.min(k-3,9-k,1),-1);return new RGBColor(Math.round(fn(0)*255),Math.round(fn(8)*255),Math.round(fn(4)*255),(0,import_numeric_range3.toFixedNumber)(this.alpha,2))}clone(){return new _HSLColor(this.hue,this.saturation,this.lightness,this.alpha)}getChannelRange(channel){switch(channel){case"hue":return{minValue:0,maxValue:360,step:1,pageSize:15};case"saturation":case"lightness":return{minValue:0,maxValue:100,step:1,pageSize:10};case"alpha":return{minValue:0,maxValue:1,step:.01,pageSize:.1};default:throw new Error("Unknown color channel: "+channel)}}toJSON(){return{h:this.hue,s:this.saturation,l:this.lightness,a:this.alpha}}getFormat(){return"hsla"}getChannels(){return _HSLColor.colorChannels}};__publicField(_HSLColor,"colorChannels",["hue","saturation","lightness"]);var HSLColor=_HSLColor;var HSB_REGEX=/hsb\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%)\)|hsba\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d(.\d+)?)\)/;var _HSBColor=class _HSBColor extends Color{constructor(hue,saturation,brightness,alpha){super();this.hue=hue;this.saturation=saturation;this.brightness=brightness;this.alpha=alpha}static parse(value){let m;if(m=value.match(HSB_REGEX)){const[h,s,b,a]=(m[1]??m[2]).split(",").map(n=>Number(n.trim().replace("%","")));return new _HSBColor((0,import_numeric_range4.mod)(h,360),(0,import_numeric_range4.clampValue)(s,0,100),(0,import_numeric_range4.clampValue)(b,0,100),(0,import_numeric_range4.clampValue)(a??1,0,1))}}toString(format){switch(format){case"css":return this.toHSL().toString("css");case"hex":return this.toRGB().toString("hex");case"hexa":return this.toRGB().toString("hexa");case"hsb":return`hsb(${this.hue}, ${(0,import_numeric_range4.toFixedNumber)(this.saturation,2)}%, ${(0,import_numeric_range4.toFixedNumber)(this.brightness,2)}%)`;case"hsba":return`hsba(${this.hue}, ${(0,import_numeric_range4.toFixedNumber)(this.saturation,2)}%, ${(0,import_numeric_range4.toFixedNumber)(this.brightness,2)}%, ${this.alpha})`;case"hsl":return this.toHSL().toString("hsl");case"rgb":return this.toRGB().toString("rgb");default:return this.toFormat(format).toString(format)}}toFormat(format){switch(format){case"hsba":return this;case"hsla":return this.toHSL();case"rgba":return this.toRGB();default:throw new Error("Unsupported color conversion: hsb -> "+format)}}toHSL(){let saturation=this.saturation/100;let brightness=this.brightness/100;let lightness=brightness*(1-saturation/2);saturation=lightness===0||lightness===1?0:(brightness-lightness)/Math.min(lightness,1-lightness);return new HSLColor((0,import_numeric_range4.toFixedNumber)(this.hue,2),(0,import_numeric_range4.toFixedNumber)(saturation*100,2),(0,import_numeric_range4.toFixedNumber)(lightness*100,2),(0,import_numeric_range4.toFixedNumber)(this.alpha,2))}toRGB(){let hue=this.hue;let saturation=this.saturation/100;let brightness=this.brightness/100;let fn=(n,k=(n+hue/60)%6)=>brightness-saturation*brightness*Math.max(Math.min(k,4-k,1),0);return new RGBColor(Math.round(fn(5)*255),Math.round(fn(3)*255),Math.round(fn(1)*255),(0,import_numeric_range4.toFixedNumber)(this.alpha,2))}clone(){return new _HSBColor(this.hue,this.saturation,this.brightness,this.alpha)}getChannelRange(channel){switch(channel){case"hue":return{minValue:0,maxValue:360,step:1,pageSize:15};case"saturation":case"brightness":return{minValue:0,maxValue:100,step:1,pageSize:10};case"alpha":return{minValue:0,maxValue:1,step:.01,pageSize:.1};default:throw new Error("Unknown color channel: "+channel)}}toJSON(){return{h:this.hue,s:this.saturation,b:this.brightness,a:this.alpha}}getFormat(){return"hsba"}getChannels(){return _HSBColor.colorChannels}};__publicField(_HSBColor,"colorChannels",["hue","saturation","brightness"]);var HSBColor=_HSBColor;var nativeColors="aliceblue:f0f8ff,antiquewhite:faebd7,aqua:00ffff,aquamarine:7fffd4,azure:f0ffff,beige:f5f5dc,bisque:ffe4c4,black:000000,blanchedalmond:ffebcd,blue:0000ff,blueviolet:8a2be2,brown:a52a2a,burlywood:deb887,cadetblue:5f9ea0,chartreuse:7fff00,chocolate:d2691e,coral:ff7f50,cornflowerblue:6495ed,cornsilk:fff8dc,crimson:dc143c,cyan:00ffff,darkblue:00008b,darkcyan:008b8b,darkgoldenrod:b8860b,darkgray:a9a9a9,darkgreen:006400,darkkhaki:bdb76b,darkmagenta:8b008b,darkolivegreen:556b2f,darkorange:ff8c00,darkorchid:9932cc,darkred:8b0000,darksalmon:e9967a,darkseagreen:8fbc8f,darkslateblue:483d8b,darkslategray:2f4f4f,darkturquoise:00ced1,darkviolet:9400d3,deeppink:ff1493,deepskyblue:00bfff,dimgray:696969,dodgerblue:1e90ff,firebrick:b22222,floralwhite:fffaf0,forestgreen:228b22,fuchsia:ff00ff,gainsboro:dcdcdc,ghostwhite:f8f8ff,gold:ffd700,goldenrod:daa520,gray:808080,green:008000,greenyellow:adff2f,honeydew:f0fff0,hotpink:ff69b4,indianred:cd5c5c,indigo:4b0082,ivory:fffff0,khaki:f0e68c,lavender:e6e6fa,lavenderblush:fff0f5,lawngreen:7cfc00,lemonchiffon:fffacd,lightblue:add8e6,lightcoral:f08080,lightcyan:e0ffff,lightgoldenrodyellow:fafad2,lightgrey:d3d3d3,lightgreen:90ee90,lightpink:ffb6c1,lightsalmon:ffa07a,lightseagreen:20b2aa,lightskyblue:87cefa,lightslategray:778899,lightsteelblue:b0c4de,lightyellow:ffffe0,lime:00ff00,limegreen:32cd32,linen:faf0e6,magenta:ff00ff,maroon:800000,mediumaquamarine:66cdaa,mediumblue:0000cd,mediumorchid:ba55d3,mediumpurple:9370d8,mediumseagreen:3cb371,mediumslateblue:7b68ee,mediumspringgreen:00fa9a,mediumturquoise:48d1cc,mediumvioletred:c71585,midnightblue:191970,mintcream:f5fffa,mistyrose:ffe4e1,moccasin:ffe4b5,navajowhite:ffdead,navy:000080,oldlace:fdf5e6,olive:808000,olivedrab:6b8e23,orange:ffa500,orangered:ff4500,orchid:da70d6,palegoldenrod:eee8aa,palegreen:98fb98,paleturquoise:afeeee,palevioletred:d87093,papayawhip:ffefd5,peachpuff:ffdab9,peru:cd853f,pink:ffc0cb,plum:dda0dd,powderblue:b0e0e6,purple:800080,red:ff0000,rosybrown:bc8f8f,royalblue:4169e1,saddlebrown:8b4513,salmon:fa8072,sandybrown:f4a460,seagreen:2e8b57,seashell:fff5ee,sienna:a0522d,silver:c0c0c0,skyblue:87ceeb,slateblue:6a5acd,slategray:708090,snow:fffafa,springgreen:00ff7f,steelblue:4682b4,tan:d2b48c,teal:008080,thistle:d8bfd8,tomato:ff6347,turquoise:40e0d0,violet:ee82ee,wheat:f5deb3,white:ffffff,whitesmoke:f5f5f5,yellow:ffff00,yellowgreen:9acd32";var makeMap=str=>{const map=new Map;const list=str.split(",");for(let i=0;i<list.length;i++){const[key,val]=list[i].split(":");map.set(key,`#${val}`)}return map};var nativeColorMap=makeMap(nativeColors);var parseColor=value=>{if(nativeColorMap.has(value)){return parseColor(nativeColorMap.get(value))}const result=RGBColor.parse(value)||HSBColor.parse(value)||HSLColor.parse(value);if(!result){const error=new Error("Invalid color value: "+value);Error.captureStackTrace?.(error,parseColor);throw error}return result};var normalizeColor=v=>{return typeof v==="string"?parseColor(v):v};0&&(module.exports={Color,getColorAreaGradient,normalizeColor,parseColor});
|
|
706
2
|
//# sourceMappingURL=index.js.map
|