@a_ng_d/utils-ui-color-palette 1.7.8 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- var f = Object.defineProperty;
2
- var T = (b, t, h) => t in b ? f(b, t, { enumerable: !0, configurable: !0, writable: !0, value: h }) : b[t] = h;
3
- var l = (b, t, h) => T(b, typeof t != "symbol" ? t + "" : t, h);
1
+ var A = Object.defineProperty;
2
+ var R = (b, t, h) => t in b ? A(b, t, { enumerable: !0, configurable: !0, writable: !0, value: h }) : b[t] = h;
3
+ var a = (b, t, h) => R(b, typeof t != "symbol" ? t + "" : t, h);
4
4
  import { c as n } from "./index-Beb8qoyd.js";
5
5
  class s {
6
6
  constructor() {
@@ -19,22 +19,22 @@ class s {
19
19
  return t <= 8 ? s.refY * t / s.kappa : s.refY * Math.pow((t + 16) / 116, 3);
20
20
  }
21
21
  static rgbChannelToHex(t) {
22
- const h = Math.round(t * 255), r = h % 16, o = (h - r) / 16 | 0;
23
- return s.hexChars.charAt(o) + s.hexChars.charAt(r);
22
+ const h = Math.round(t * 255), i = h % 16, e = (h - i) / 16 | 0;
23
+ return s.hexChars.charAt(e) + s.hexChars.charAt(i);
24
24
  }
25
25
  static hexToRgbChannel(t, h) {
26
- const r = s.hexChars.indexOf(t.charAt(h)), o = s.hexChars.indexOf(t.charAt(h + 1));
27
- return (r * 16 + o) / 255;
26
+ const i = s.hexChars.indexOf(t.charAt(h)), e = s.hexChars.indexOf(t.charAt(h + 1));
27
+ return (i * 16 + e) / 255;
28
28
  }
29
- static distanceFromOriginAngle(t, h, r) {
30
- const o = h / (Math.sin(r) - t * Math.cos(r));
31
- return o < 0 ? 1 / 0 : o;
29
+ static distanceFromOriginAngle(t, h, i) {
30
+ const e = h / (Math.sin(i) - t * Math.cos(i));
31
+ return e < 0 ? 1 / 0 : e;
32
32
  }
33
33
  static distanceFromOrigin(t, h) {
34
34
  return Math.abs(h) / Math.sqrt(Math.pow(t, 2) + 1);
35
35
  }
36
- static min6(t, h, r, o, i, e) {
37
- return Math.min(t, Math.min(h, Math.min(r, Math.min(o, Math.min(i, e)))));
36
+ static min6(t, h, i, e, r, o) {
37
+ return Math.min(t, Math.min(h, Math.min(i, Math.min(e, Math.min(r, o)))));
38
38
  }
39
39
  rgbToHex() {
40
40
  this.hex = "#", this.hex += s.rgbChannelToHex(this.rgb_r), this.hex += s.rgbChannelToHex(this.rgb_g), this.hex += s.rgbChannelToHex(this.rgb_b);
@@ -46,13 +46,13 @@ class s {
46
46
  this.rgb_r = s.fromLinear(s.m_r0 * this.xyz_x + s.m_r1 * this.xyz_y + s.m_r2 * this.xyz_z), this.rgb_g = s.fromLinear(s.m_g0 * this.xyz_x + s.m_g1 * this.xyz_y + s.m_g2 * this.xyz_z), this.rgb_b = s.fromLinear(s.m_b0 * this.xyz_x + s.m_b1 * this.xyz_y + s.m_b2 * this.xyz_z);
47
47
  }
48
48
  rgbToXyz() {
49
- const t = s.toLinear(this.rgb_r), h = s.toLinear(this.rgb_g), r = s.toLinear(this.rgb_b);
50
- this.xyz_x = 0.41239079926595 * t + 0.35758433938387 * h + 0.18048078840183 * r, this.xyz_y = 0.21263900587151 * t + 0.71516867876775 * h + 0.072192315360733 * r, this.xyz_z = 0.019330818715591 * t + 0.11919477979462 * h + 0.95053215224966 * r;
49
+ const t = s.toLinear(this.rgb_r), h = s.toLinear(this.rgb_g), i = s.toLinear(this.rgb_b);
50
+ this.xyz_x = 0.41239079926595 * t + 0.35758433938387 * h + 0.18048078840183 * i, this.xyz_y = 0.21263900587151 * t + 0.71516867876775 * h + 0.072192315360733 * i, this.xyz_z = 0.019330818715591 * t + 0.11919477979462 * h + 0.95053215224966 * i;
51
51
  }
52
52
  xyzToLuv() {
53
53
  const t = this.xyz_x + 15 * this.xyz_y + 3 * this.xyz_z;
54
- let h = 4 * this.xyz_x, r = 9 * this.xyz_y;
55
- t !== 0 ? (h /= t, r /= t) : (h = NaN, r = NaN), this.luv_l = s.yToL(this.xyz_y), this.luv_l === 0 ? (this.luv_u = 0, this.luv_v = 0) : (this.luv_u = 13 * this.luv_l * (h - s.refU), this.luv_v = 13 * this.luv_l * (r - s.refV));
54
+ let h = 4 * this.xyz_x, i = 9 * this.xyz_y;
55
+ t !== 0 ? (h /= t, i /= t) : (h = NaN, i = NaN), this.luv_l = s.yToL(this.xyz_y), this.luv_l === 0 ? (this.luv_u = 0, this.luv_v = 0) : (this.luv_u = 13 * this.luv_l * (h - s.refU), this.luv_v = 13 * this.luv_l * (i - s.refV));
56
56
  }
57
57
  luvToXyz() {
58
58
  if (this.luv_l === 0) {
@@ -75,16 +75,16 @@ class s {
75
75
  this.luv_l = this.lch_l, this.luv_u = Math.cos(t) * this.lch_c, this.luv_v = Math.sin(t) * this.lch_c;
76
76
  }
77
77
  calculateBoundingLines(t) {
78
- const h = Math.pow(t + 16, 3) / 1560896, r = h > s.epsilon ? h : t / s.kappa, o = r * (284517 * s.m_r0 - 94839 * s.m_r2), i = r * (838422 * s.m_r2 + 769860 * s.m_r1 + 731718 * s.m_r0), e = r * (632260 * s.m_r2 - 126452 * s.m_r1), a = r * (284517 * s.m_g0 - 94839 * s.m_g2), g = r * (838422 * s.m_g2 + 769860 * s.m_g1 + 731718 * s.m_g0), m = r * (632260 * s.m_g2 - 126452 * s.m_g1), _ = r * (284517 * s.m_b0 - 94839 * s.m_b2), M = r * (838422 * s.m_b2 + 769860 * s.m_b1 + 731718 * s.m_b0), C = r * (632260 * s.m_b2 - 126452 * s.m_b1);
79
- this.r0s = o / e, this.r0i = i * t / e, this.r1s = o / (e + 126452), this.r1i = (i - 769860) * t / (e + 126452), this.g0s = a / m, this.g0i = g * t / m, this.g1s = a / (m + 126452), this.g1i = (g - 769860) * t / (m + 126452), this.b0s = _ / C, this.b0i = M * t / C, this.b1s = _ / (C + 126452), this.b1i = (M - 769860) * t / (C + 126452);
78
+ const h = Math.pow(t + 16, 3) / 1560896, i = h > s.epsilon ? h : t / s.kappa, e = i * (284517 * s.m_r0 - 94839 * s.m_r2), r = i * (838422 * s.m_r2 + 769860 * s.m_r1 + 731718 * s.m_r0), o = i * (632260 * s.m_r2 - 126452 * s.m_r1), l = i * (284517 * s.m_g0 - 94839 * s.m_g2), u = i * (838422 * s.m_g2 + 769860 * s.m_g1 + 731718 * s.m_g0), d = i * (632260 * s.m_g2 - 126452 * s.m_g1), C = i * (284517 * s.m_b0 - 94839 * s.m_b2), M = i * (838422 * s.m_b2 + 769860 * s.m_b1 + 731718 * s.m_b0), m = i * (632260 * s.m_b2 - 126452 * s.m_b1);
79
+ this.r0s = e / o, this.r0i = r * t / o, this.r1s = e / (o + 126452), this.r1i = (r - 769860) * t / (o + 126452), this.g0s = l / d, this.g0i = u * t / d, this.g1s = l / (d + 126452), this.g1i = (u - 769860) * t / (d + 126452), this.b0s = C / m, this.b0i = M * t / m, this.b1s = C / (m + 126452), this.b1i = (M - 769860) * t / (m + 126452);
80
80
  }
81
81
  calcMaxChromaHpluv() {
82
- const t = s.distanceFromOrigin(this.r0s, this.r0i), h = s.distanceFromOrigin(this.r1s, this.r1i), r = s.distanceFromOrigin(this.g0s, this.g0i), o = s.distanceFromOrigin(this.g1s, this.g1i), i = s.distanceFromOrigin(this.b0s, this.b0i), e = s.distanceFromOrigin(this.b1s, this.b1i);
83
- return s.min6(t, h, r, o, i, e);
82
+ const t = s.distanceFromOrigin(this.r0s, this.r0i), h = s.distanceFromOrigin(this.r1s, this.r1i), i = s.distanceFromOrigin(this.g0s, this.g0i), e = s.distanceFromOrigin(this.g1s, this.g1i), r = s.distanceFromOrigin(this.b0s, this.b0i), o = s.distanceFromOrigin(this.b1s, this.b1i);
83
+ return s.min6(t, h, i, e, r, o);
84
84
  }
85
85
  calcMaxChromaHsluv(t) {
86
- const h = t / 360 * Math.PI * 2, r = s.distanceFromOriginAngle(this.r0s, this.r0i, h), o = s.distanceFromOriginAngle(this.r1s, this.r1i, h), i = s.distanceFromOriginAngle(this.g0s, this.g0i, h), e = s.distanceFromOriginAngle(this.g1s, this.g1i, h), a = s.distanceFromOriginAngle(this.b0s, this.b0i, h), g = s.distanceFromOriginAngle(this.b1s, this.b1i, h);
87
- return s.min6(r, o, i, e, a, g);
86
+ const h = t / 360 * Math.PI * 2, i = s.distanceFromOriginAngle(this.r0s, this.r0i, h), e = s.distanceFromOriginAngle(this.r1s, this.r1i, h), r = s.distanceFromOriginAngle(this.g0s, this.g0i, h), o = s.distanceFromOriginAngle(this.g1s, this.g1i, h), l = s.distanceFromOriginAngle(this.b0s, this.b0i, h), u = s.distanceFromOriginAngle(this.b1s, this.b1i, h);
87
+ return s.min6(i, e, r, o, l, u);
88
88
  }
89
89
  hsluvToLch() {
90
90
  if (this.hsluv_l > 99.9999999)
@@ -174,7 +174,7 @@ s.m_g2 = 0.041555057407175;
174
174
  s.m_b0 = 0.055630079696993;
175
175
  s.m_b1 = -0.20397695888897;
176
176
  s.m_b2 = 1.056971514242878;
177
- const u = {
177
+ const c = {
178
178
  PROTANOPIA: [
179
179
  [0.567, 0.433, 0],
180
180
  [0.558, 0.442, 0],
@@ -215,47 +215,59 @@ const u = {
215
215
  [0.163, 0.775, 0.062],
216
216
  [0.163, 0.32, 0.516]
217
217
  ]
218
- }, c = (b, t) => {
219
- const [h, r, o] = b, [i, e, a] = t;
218
+ }, g = (b, t) => {
219
+ const [h, i, e] = b, [r, o, l] = t;
220
220
  return [
221
- Math.round(h * i[0] + r * i[1] + o * i[2]),
222
- Math.round(h * e[0] + r * e[1] + o * e[2]),
223
- Math.round(h * a[0] + r * a[1] + o * a[2])
221
+ Math.round(h * r[0] + i * r[1] + e * r[2]),
222
+ Math.round(h * o[0] + i * o[1] + e * o[2]),
223
+ Math.round(h * l[0] + i * l[1] + e * l[2])
224
224
  ];
225
- };
226
- class p {
225
+ }, _ = (b, t, h) => {
226
+ const i = b / 255, e = t / 255, r = h / 255, o = 1 - Math.max(i, e, r);
227
+ return o === 1 ? [0, 0, 0, 1] : [
228
+ (1 - i - o) / (1 - o),
229
+ (1 - e - o) / (1 - o),
230
+ (1 - r - o) / (1 - o),
231
+ o
232
+ ];
233
+ }, x = (b, t, h, i) => [
234
+ Math.round(255 * (1 - b) * (1 - i)),
235
+ Math.round(255 * (1 - t) * (1 - i)),
236
+ Math.round(255 * (1 - h) * (1 - i))
237
+ ];
238
+ class O {
227
239
  constructor({
228
240
  render: t = "HEX",
229
241
  sourceColor: h = [0, 0, 0],
230
- lightness: r = parseFloat((n(h).luminance() * 100).toFixed(1)),
231
- alpha: o = 1,
232
- hueShifting: i = 0,
233
- chromaShifting: e = 100,
234
- algorithmVersion: a = "v3",
235
- visionSimulationMode: g = "NONE"
242
+ lightness: i = parseFloat((n(h).luminance() * 100).toFixed(1)),
243
+ alpha: e = 1,
244
+ hueShifting: r = 0,
245
+ chromaShifting: o = 100,
246
+ algorithmVersion: l = "v3",
247
+ visionSimulationMode: u = "NONE"
236
248
  }) {
237
- l(this, "render");
238
- l(this, "sourceColor");
239
- l(this, "lightness");
240
- l(this, "alpha");
241
- l(this, "hueShifting");
242
- l(this, "chromaShifting");
243
- l(this, "algorithmVersion");
244
- l(this, "visionSimulationMode");
245
- l(this, "adjustHue", (t) => t + this.hueShifting < 0 ? t + this.hueShifting + 360 : t + this.hueShifting > 360 ? t + this.hueShifting - 360 : t + this.hueShifting);
246
- l(this, "adjustChroma", (t) => {
249
+ a(this, "render");
250
+ a(this, "sourceColor");
251
+ a(this, "lightness");
252
+ a(this, "alpha");
253
+ a(this, "hueShifting");
254
+ a(this, "chromaShifting");
255
+ a(this, "algorithmVersion");
256
+ a(this, "visionSimulationMode");
257
+ a(this, "adjustHue", (t) => t + this.hueShifting < 0 ? t + this.hueShifting + 360 : t + this.hueShifting > 360 ? t + this.hueShifting - 360 : t + this.hueShifting);
258
+ a(this, "adjustChroma", (t) => {
247
259
  if (this.algorithmVersion === "v1") return t;
248
260
  if (this.algorithmVersion === "v2")
249
261
  return Math.sin(this.lightness / 100 * Math.PI) * t;
250
262
  if (this.algorithmVersion === "v3") {
251
- const h = this.lightness / 100, r = Math.sin(h * Math.PI), o = Math.tanh(h * Math.PI), i = r * 0.5 + o * 0.5;
252
- return Math.pow(i, 0.5) * t;
263
+ const h = this.lightness / 100, i = Math.sin(h * Math.PI), e = Math.tanh(h * Math.PI), r = i * 0.5 + e * 0.5;
264
+ return Math.pow(r, 0.5) * t;
253
265
  }
254
266
  return t;
255
267
  });
256
- l(this, "setColor", () => this.render === "HEX" ? this.simulateColorBlindHex(this.sourceColor) : this.simulateColorBlindRgb(this.sourceColor));
257
- l(this, "setColorWithAlpha", () => this.render === "HEX" ? n.rgb(...this.simulateColorBlindRgb(this.sourceColor), this.alpha).hex() : [...this.simulateColorBlindRgb(this.sourceColor), this.alpha]);
258
- l(this, "lch", () => {
268
+ a(this, "setColor", () => this.render === "HEX" ? this.simulateColorBlindHex(this.sourceColor) : this.simulateColorBlindRgb(this.sourceColor));
269
+ a(this, "setColorWithAlpha", () => this.render === "HEX" ? n.rgb(...this.simulateColorBlindRgb(this.sourceColor), this.alpha).hex() : [...this.simulateColorBlindRgb(this.sourceColor), this.alpha]);
270
+ a(this, "lch", () => {
259
271
  const t = n(this.sourceColor).lch(), h = n.lch(
260
272
  this.lightness,
261
273
  this.adjustChroma(t[1] * (this.chromaShifting / 100)),
@@ -263,7 +275,7 @@ class p {
263
275
  ).rgb();
264
276
  return this.render === "HEX" ? this.simulateColorBlindHex(h) : this.simulateColorBlindRgb(h);
265
277
  });
266
- l(this, "lcha", () => {
278
+ a(this, "lcha", () => {
267
279
  const t = n(this.sourceColor).lch(), h = n.lch(
268
280
  t[0],
269
281
  this.adjustChroma(t[1] * (this.chromaShifting / 100)),
@@ -271,7 +283,7 @@ class p {
271
283
  ).rgb();
272
284
  return this.render === "HEX" ? n.rgb(...this.simulateColorBlindRgb(h), this.alpha).hex() : [...this.simulateColorBlindRgb(h), this.alpha];
273
285
  });
274
- l(this, "oklch", () => {
286
+ a(this, "oklch", () => {
275
287
  const t = n(this.sourceColor).oklch(), h = n.oklch(
276
288
  this.lightness / 100,
277
289
  this.adjustChroma(t[1] * (this.chromaShifting / 100)),
@@ -279,7 +291,7 @@ class p {
279
291
  ).rgb();
280
292
  return this.render === "HEX" ? this.simulateColorBlindHex(h) : this.simulateColorBlindRgb(h);
281
293
  });
282
- l(this, "oklcha", () => {
294
+ a(this, "oklcha", () => {
283
295
  const t = n(this.sourceColor).oklch(), h = n.oklch(
284
296
  t[0],
285
297
  this.adjustChroma(t[1] * (this.chromaShifting / 100)),
@@ -287,51 +299,51 @@ class p {
287
299
  ).rgb();
288
300
  return this.render === "HEX" ? n.rgb(...this.simulateColorBlindRgb(h), this.alpha).hex() : [...this.simulateColorBlindRgb(h), this.alpha];
289
301
  });
290
- l(this, "lab", () => {
291
- const t = n(this.sourceColor).get("lab.a"), h = n(this.sourceColor).get("lab.b"), r = Math.sqrt(t ** 2 + h ** 2) * (this.chromaShifting / 100);
292
- let o = Math.atan(h / t) + this.hueShifting * (Math.PI / 180);
293
- (o > Math.PI || o < -Math.PI) && (o = Math.PI);
294
- let i = r * Math.cos(o), e = r * Math.sin(o);
295
- Math.sign(t) === -1 && Math.sign(h) === 1 && (i *= -1, e *= -1), Math.sign(t) === -1 && Math.sign(h) === -1 && (i *= -1, e *= -1);
296
- const a = n.lab(
302
+ a(this, "lab", () => {
303
+ const t = n(this.sourceColor).get("lab.a"), h = n(this.sourceColor).get("lab.b"), i = Math.sqrt(t ** 2 + h ** 2) * (this.chromaShifting / 100);
304
+ let e = Math.atan(h / t) + this.hueShifting * (Math.PI / 180);
305
+ (e > Math.PI || e < -Math.PI) && (e = Math.PI);
306
+ let r = i * Math.cos(e), o = i * Math.sin(e);
307
+ Math.sign(t) === -1 && Math.sign(h) === 1 && (r *= -1, o *= -1), Math.sign(t) === -1 && Math.sign(h) === -1 && (r *= -1, o *= -1);
308
+ const l = n.lab(
297
309
  this.lightness,
298
- this.adjustChroma(i),
299
- this.adjustChroma(e)
310
+ this.adjustChroma(r),
311
+ this.adjustChroma(o)
300
312
  ).rgb();
301
- return this.render === "HEX" ? this.simulateColorBlindHex(a) : this.simulateColorBlindRgb(a);
313
+ return this.render === "HEX" ? this.simulateColorBlindHex(l) : this.simulateColorBlindRgb(l);
302
314
  });
303
- l(this, "laba", () => {
304
- const t = n(this.sourceColor).get("lab.a"), h = n(this.sourceColor).get("lab.b"), r = n(this.sourceColor).get("lab.l"), o = Math.sqrt(t ** 2 + h ** 2) * (this.chromaShifting / 100);
305
- let i = Math.atan(h / t) + this.hueShifting * (Math.PI / 180);
306
- (i > Math.PI || i < -Math.PI) && (i = Math.PI);
307
- let e = o * Math.cos(i), a = o * Math.sin(i);
308
- Math.sign(t) === -1 && Math.sign(h) === 1 && (e *= -1, a *= -1), Math.sign(t) === -1 && Math.sign(h) === -1 && (e *= -1, a *= -1);
309
- const g = n.lab(r, this.adjustChroma(e), this.adjustChroma(a)).rgb();
310
- return this.render === "HEX" ? n.rgb(...this.simulateColorBlindRgb(g), this.alpha).hex() : [...this.simulateColorBlindRgb(g), this.alpha];
315
+ a(this, "laba", () => {
316
+ const t = n(this.sourceColor).get("lab.a"), h = n(this.sourceColor).get("lab.b"), i = n(this.sourceColor).get("lab.l"), e = Math.sqrt(t ** 2 + h ** 2) * (this.chromaShifting / 100);
317
+ let r = Math.atan(h / t) + this.hueShifting * (Math.PI / 180);
318
+ (r > Math.PI || r < -Math.PI) && (r = Math.PI);
319
+ let o = e * Math.cos(r), l = e * Math.sin(r);
320
+ Math.sign(t) === -1 && Math.sign(h) === 1 && (o *= -1, l *= -1), Math.sign(t) === -1 && Math.sign(h) === -1 && (o *= -1, l *= -1);
321
+ const u = n.lab(i, this.adjustChroma(o), this.adjustChroma(l)).rgb();
322
+ return this.render === "HEX" ? n.rgb(...this.simulateColorBlindRgb(u), this.alpha).hex() : [...this.simulateColorBlindRgb(u), this.alpha];
311
323
  });
312
- l(this, "oklab", () => {
313
- const t = n(this.sourceColor).get("oklab.a"), h = n(this.sourceColor).get("oklab.b"), r = Math.sqrt(t ** 2 + h ** 2) * (this.chromaShifting / 100);
314
- let o = Math.atan(h / t) + this.hueShifting * (Math.PI / 180);
315
- (o > Math.PI || o < -Math.PI) && (o = Math.PI);
316
- let i = r * Math.cos(o), e = r * Math.sin(o);
317
- Math.sign(t) === -1 && Math.sign(h) === 1 && (i *= -1, e *= -1), Math.sign(t) === -1 && Math.sign(h) === -1 && (i *= -1, e *= -1), Number.isNaN(i) && (i = 0), Number.isNaN(e) && (e = 0);
318
- const a = n.oklab(
324
+ a(this, "oklab", () => {
325
+ const t = n(this.sourceColor).get("oklab.a"), h = n(this.sourceColor).get("oklab.b"), i = Math.sqrt(t ** 2 + h ** 2) * (this.chromaShifting / 100);
326
+ let e = Math.atan(h / t) + this.hueShifting * (Math.PI / 180);
327
+ (e > Math.PI || e < -Math.PI) && (e = Math.PI);
328
+ let r = i * Math.cos(e), o = i * Math.sin(e);
329
+ Math.sign(t) === -1 && Math.sign(h) === 1 && (r *= -1, o *= -1), Math.sign(t) === -1 && Math.sign(h) === -1 && (r *= -1, o *= -1), Number.isNaN(r) && (r = 0), Number.isNaN(o) && (o = 0);
330
+ const l = n.oklab(
319
331
  this.lightness / 100,
320
- this.adjustChroma(i),
321
- this.adjustChroma(e)
332
+ this.adjustChroma(r),
333
+ this.adjustChroma(o)
322
334
  ).rgb();
323
- return this.render === "HEX" ? this.simulateColorBlindHex(a) : this.simulateColorBlindRgb(a);
335
+ return this.render === "HEX" ? this.simulateColorBlindHex(l) : this.simulateColorBlindRgb(l);
324
336
  });
325
- l(this, "oklaba", () => {
326
- const t = n(this.sourceColor).get("oklab.a"), h = n(this.sourceColor).get("oklab.b"), r = n(this.sourceColor).get("oklab.l"), o = Math.sqrt(t ** 2 + h ** 2) * (this.chromaShifting / 100);
327
- let i = Math.atan(h / t) + this.hueShifting * (Math.PI / 180);
328
- (i > Math.PI || i < -Math.PI) && (i = Math.PI);
329
- let e = o * Math.cos(i), a = o * Math.sin(i);
330
- Math.sign(t) === -1 && Math.sign(h) === 1 && (e *= -1, a *= -1), Math.sign(t) === -1 && Math.sign(h) === -1 && (e *= -1, a *= -1), Number.isNaN(e) && (e = 0), Number.isNaN(a) && (a = 0);
331
- const g = n.oklab(r, this.adjustChroma(e), this.adjustChroma(a)).rgb();
332
- return this.render === "HEX" ? n.rgb(...this.simulateColorBlindRgb(g), this.alpha).hex() : [...this.simulateColorBlindRgb(g), this.alpha];
337
+ a(this, "oklaba", () => {
338
+ const t = n(this.sourceColor).get("oklab.a"), h = n(this.sourceColor).get("oklab.b"), i = n(this.sourceColor).get("oklab.l"), e = Math.sqrt(t ** 2 + h ** 2) * (this.chromaShifting / 100);
339
+ let r = Math.atan(h / t) + this.hueShifting * (Math.PI / 180);
340
+ (r > Math.PI || r < -Math.PI) && (r = Math.PI);
341
+ let o = e * Math.cos(r), l = e * Math.sin(r);
342
+ Math.sign(t) === -1 && Math.sign(h) === 1 && (o *= -1, l *= -1), Math.sign(t) === -1 && Math.sign(h) === -1 && (o *= -1, l *= -1), Number.isNaN(o) && (o = 0), Number.isNaN(l) && (l = 0);
343
+ const u = n.oklab(i, this.adjustChroma(o), this.adjustChroma(l)).rgb();
344
+ return this.render === "HEX" ? n.rgb(...this.simulateColorBlindRgb(u), this.alpha).hex() : [...this.simulateColorBlindRgb(u), this.alpha];
333
345
  });
334
- l(this, "hsl", () => {
346
+ a(this, "hsl", () => {
335
347
  const t = n(this.sourceColor).hsl(), h = n.hsl(
336
348
  this.adjustHue(t[0]),
337
349
  this.adjustChroma(t[1] * (this.chromaShifting / 100)),
@@ -339,7 +351,7 @@ class p {
339
351
  ).rgb();
340
352
  return this.render === "HEX" ? this.simulateColorBlindHex(h) : this.simulateColorBlindRgb(h);
341
353
  });
342
- l(this, "hsla", () => {
354
+ a(this, "hsla", () => {
343
355
  const t = n(this.sourceColor).hsl(), h = n.hsl(
344
356
  this.adjustHue(t[0]),
345
357
  this.adjustChroma(t[1] * (this.chromaShifting / 100)),
@@ -347,7 +359,7 @@ class p {
347
359
  ).rgb();
348
360
  return this.render === "HEX" ? n.rgb(...this.simulateColorBlindRgb(h), this.alpha).hex() : [...this.simulateColorBlindRgb(h), this.alpha];
349
361
  });
350
- l(this, "hsluv", () => {
362
+ a(this, "hsluv", () => {
351
363
  const t = new s();
352
364
  t.rgb_r = this.sourceColor[0] / 255, t.rgb_g = this.sourceColor[1] / 255, t.rgb_b = this.sourceColor[2] / 255, t.rgbToHsluv(), t.hsluv_l = this.lightness, t.hsluv_s = this.adjustChroma(
353
365
  t.hsluv_s * (this.chromaShifting / 100)
@@ -359,7 +371,7 @@ class p {
359
371
  ];
360
372
  return this.render === "HEX" ? this.simulateColorBlindHex(h) : this.simulateColorBlindRgb(h);
361
373
  });
362
- l(this, "hsluva", () => {
374
+ a(this, "hsluva", () => {
363
375
  const t = new s();
364
376
  t.rgb_r = this.sourceColor[0] / 255, t.rgb_g = this.sourceColor[1] / 255, t.rgb_b = this.sourceColor[2] / 255, t.rgbToHsluv(), t.hsluv_s = this.adjustChroma(
365
377
  t.hsluv_s * (this.chromaShifting / 100)
@@ -371,116 +383,166 @@ class p {
371
383
  ];
372
384
  return this.render === "HEX" ? n.rgb(...this.simulateColorBlindRgb(h), this.alpha).hex() : [...this.simulateColorBlindRgb(h), this.alpha];
373
385
  });
374
- l(this, "getHsluv", () => {
386
+ a(this, "hsv", () => {
387
+ const t = n(this.sourceColor).hsv(), h = n.hsv(
388
+ this.adjustHue(Number.isNaN(t[0]) ? 0 : t[0]),
389
+ this.adjustChroma(t[1] * (this.chromaShifting / 100)),
390
+ this.lightness / 100
391
+ ).rgb();
392
+ return this.render === "HEX" ? this.simulateColorBlindHex(h) : this.simulateColorBlindRgb(h);
393
+ });
394
+ a(this, "hsva", () => {
395
+ const t = n(this.sourceColor).hsv(), h = n.hsv(
396
+ this.adjustHue(Number.isNaN(t[0]) ? 0 : t[0]),
397
+ this.adjustChroma(t[1] * (this.chromaShifting / 100)),
398
+ t[2]
399
+ ).rgb();
400
+ return this.render === "HEX" ? n.rgb(...this.simulateColorBlindRgb(h), this.alpha).hex() : [...this.simulateColorBlindRgb(h), this.alpha];
401
+ });
402
+ a(this, "cmyk", () => {
403
+ const t = n(this.sourceColor).hsl(), [h, i, e] = n.hsl(
404
+ this.adjustHue(Number.isNaN(t[0]) ? 0 : t[0]),
405
+ t[1],
406
+ t[2]
407
+ ).rgb(), [r, o, l] = _(h, i, e), u = Math.min(
408
+ 1,
409
+ Math.max(0, this.adjustChroma(r * (this.chromaShifting / 100)))
410
+ ), d = Math.min(
411
+ 1,
412
+ Math.max(0, this.adjustChroma(o * (this.chromaShifting / 100)))
413
+ ), C = Math.min(
414
+ 1,
415
+ Math.max(0, this.adjustChroma(l * (this.chromaShifting / 100)))
416
+ ), M = Math.min(1, Math.max(0, 1 - this.lightness / 100)), m = x(u, d, C, M);
417
+ return this.render === "HEX" ? this.simulateColorBlindHex(m) : this.simulateColorBlindRgb(m);
418
+ });
419
+ a(this, "cmyka", () => {
420
+ const t = n(this.sourceColor).hsl(), [h, i, e] = n.hsl(
421
+ this.adjustHue(Number.isNaN(t[0]) ? 0 : t[0]),
422
+ t[1],
423
+ t[2]
424
+ ).rgb(), [r, o, l, u] = _(h, i, e), d = Math.min(
425
+ 1,
426
+ Math.max(0, this.adjustChroma(r * (this.chromaShifting / 100)))
427
+ ), C = Math.min(
428
+ 1,
429
+ Math.max(0, this.adjustChroma(o * (this.chromaShifting / 100)))
430
+ ), M = Math.min(
431
+ 1,
432
+ Math.max(0, this.adjustChroma(l * (this.chromaShifting / 100)))
433
+ ), m = x(d, C, M, u);
434
+ return this.render === "HEX" ? n.rgb(...this.simulateColorBlindRgb(m), this.alpha).hex() : [...this.simulateColorBlindRgb(m), this.alpha];
435
+ });
436
+ a(this, "getHsluv", () => {
375
437
  const t = new s();
376
438
  return t.rgb_r = this.sourceColor[0] / 255, t.rgb_g = this.sourceColor[1] / 255, t.rgb_b = this.sourceColor[2] / 255, t.rgbToHsluv(), [t.hsluv_h, t.hsluv_s, t.hsluv_l];
377
439
  });
378
- l(this, "simulateColorBlindHex", (t) => {
379
- var o;
440
+ a(this, "simulateColorBlindHex", (t) => {
441
+ var e;
380
442
  const h = {
381
443
  NONE: () => n(t).hex(),
382
444
  PROTANOMALY: () => {
383
- const i = c(
445
+ const r = g(
384
446
  t,
385
- u.PROTANOMALY
447
+ c.PROTANOMALY
386
448
  );
387
- return n(i).hex();
449
+ return n(r).hex();
388
450
  },
389
451
  PROTANOPIA: () => {
390
- const i = c(
452
+ const r = g(
391
453
  t,
392
- u.PROTANOPIA
454
+ c.PROTANOPIA
393
455
  );
394
- return n(i).hex();
456
+ return n(r).hex();
395
457
  },
396
458
  DEUTERANOMALY: () => {
397
- const i = c(
459
+ const r = g(
398
460
  t,
399
- u.DEUTERANOMALY
461
+ c.DEUTERANOMALY
400
462
  );
401
- return n(i).hex();
463
+ return n(r).hex();
402
464
  },
403
465
  DEUTERANOPIA: () => {
404
- const i = c(
466
+ const r = g(
405
467
  t,
406
- u.DEUTERANOPIA
468
+ c.DEUTERANOPIA
407
469
  );
408
- return n(i).hex();
470
+ return n(r).hex();
409
471
  },
410
472
  TRITANOMALY: () => {
411
- const i = c(
473
+ const r = g(
412
474
  t,
413
- u.TRITANOMALY
475
+ c.TRITANOMALY
414
476
  );
415
- return n(i).hex();
477
+ return n(r).hex();
416
478
  },
417
479
  TRITANOPIA: () => {
418
- const i = c(
480
+ const r = g(
419
481
  t,
420
- u.TRITANOPIA
482
+ c.TRITANOPIA
421
483
  );
422
- return n(i).hex();
484
+ return n(r).hex();
423
485
  },
424
486
  ACHROMATOMALY: () => {
425
- const i = c(
487
+ const r = g(
426
488
  t,
427
- u.ACHROMATOMALY
489
+ c.ACHROMATOMALY
428
490
  );
429
- return n(i).hex();
491
+ return n(r).hex();
430
492
  },
431
493
  ACHROMATOPSIA: () => {
432
- const i = c(
494
+ const r = g(
433
495
  t,
434
- u.ACHROMATOPSIA
496
+ c.ACHROMATOPSIA
435
497
  );
436
- return n(i).hex();
498
+ return n(r).hex();
437
499
  }
438
- }, r = (o = h[this.visionSimulationMode]) == null ? void 0 : o.call(h);
439
- return r !== void 0 ? r : "#000000";
500
+ }, i = (e = h[this.visionSimulationMode]) == null ? void 0 : e.call(h);
501
+ return i !== void 0 ? i : "#000000";
440
502
  });
441
- l(this, "simulateColorBlindRgb", (t) => {
442
- var o;
503
+ a(this, "simulateColorBlindRgb", (t) => {
504
+ var e;
443
505
  const h = {
444
506
  NONE: () => n(t).rgb(),
445
- PROTANOMALY: () => c(t, u.PROTANOMALY),
446
- PROTANOPIA: () => c(t, u.PROTANOPIA),
447
- DEUTERANOMALY: () => c(t, u.DEUTERANOMALY),
448
- DEUTERANOPIA: () => c(t, u.DEUTERANOPIA),
449
- TRITANOMALY: () => c(t, u.TRITANOMALY),
450
- TRITANOPIA: () => c(t, u.TRITANOPIA),
451
- ACHROMATOMALY: () => c(t, u.ACHROMATOMALY),
452
- ACHROMATOPSIA: () => c(t, u.ACHROMATOPSIA)
453
- }, r = (o = h[this.visionSimulationMode]) == null ? void 0 : o.call(h);
454
- return r !== void 0 ? r : [0, 0, 0];
507
+ PROTANOMALY: () => g(t, c.PROTANOMALY),
508
+ PROTANOPIA: () => g(t, c.PROTANOPIA),
509
+ DEUTERANOMALY: () => g(t, c.DEUTERANOMALY),
510
+ DEUTERANOPIA: () => g(t, c.DEUTERANOPIA),
511
+ TRITANOMALY: () => g(t, c.TRITANOMALY),
512
+ TRITANOPIA: () => g(t, c.TRITANOPIA),
513
+ ACHROMATOMALY: () => g(t, c.ACHROMATOMALY),
514
+ ACHROMATOPSIA: () => g(t, c.ACHROMATOPSIA)
515
+ }, i = (e = h[this.visionSimulationMode]) == null ? void 0 : e.call(h);
516
+ return i !== void 0 ? i : [0, 0, 0];
455
517
  });
456
- l(this, "mixColorsRgb", (t, h) => {
457
- const [r, o, i, e] = t, [a, g, m, _] = h;
458
- if (e === 1) return [r, o, i];
459
- if (e === 0) return [a, g, m];
460
- const M = e + _ * (1 - e), C = Math.min(
518
+ a(this, "mixColorsRgb", (t, h) => {
519
+ const [i, e, r, o] = t, [l, u, d, C] = h;
520
+ if (o === 1) return [i, e, r];
521
+ if (o === 0) return [l, u, d];
522
+ const M = o + C * (1 - o), m = Math.min(
461
523
  255,
462
- Math.max(0, Math.round((r * e + a * _ * (1 - e)) / M))
463
- ), d = Math.min(
524
+ Math.max(0, Math.round((i * o + l * C * (1 - o)) / M))
525
+ ), f = Math.min(
464
526
  255,
465
- Math.max(0, Math.round((o * e + g * _ * (1 - e)) / M))
466
- ), x = Math.min(
527
+ Math.max(0, Math.round((e * o + u * C * (1 - o)) / M))
528
+ ), T = Math.min(
467
529
  255,
468
- Math.max(0, Math.round((i * e + m * _ * (1 - e)) / M))
530
+ Math.max(0, Math.round((r * o + d * C * (1 - o)) / M))
469
531
  );
470
- return this.simulateColorBlindRgb([C, d, x]);
532
+ return this.simulateColorBlindRgb([m, f, T]);
471
533
  });
472
- l(this, "mixColorsHex", (t, h) => {
473
- const r = /^#([0-9A-Fa-f]{3}){1,2}([0-9A-Fa-f]{2})?$/;
474
- if (!r.test(t)) return t;
475
- if (!r.test(h)) return h;
476
- const o = n(t).rgba(), i = n(h).rgba(), e = this.mixColorsRgb(o, i);
477
- return n(e).hex();
534
+ a(this, "mixColorsHex", (t, h) => {
535
+ const i = /^#([0-9A-Fa-f]{3}){1,2}([0-9A-Fa-f]{2})?$/;
536
+ if (!i.test(t)) return t;
537
+ if (!i.test(h)) return h;
538
+ const e = n(t).rgba(), r = n(h).rgba(), o = this.mixColorsRgb(e, r);
539
+ return n(o).hex();
478
540
  });
479
- this.render = t, this.sourceColor = h, this.lightness = r, this.alpha = o, this.hueShifting = i, this.chromaShifting = e, this.algorithmVersion = a, this.visionSimulationMode = g;
541
+ this.render = t, this.sourceColor = h, this.lightness = i, this.alpha = e, this.hueShifting = r, this.chromaShifting = o, this.algorithmVersion = l, this.visionSimulationMode = u;
480
542
  }
481
543
  }
482
544
  export {
483
- p as C,
545
+ O as C,
484
546
  s as H
485
547
  };
486
- //# sourceMappingURL=color-1CXTuV84.js.map
548
+ //# sourceMappingURL=color-S7JZ1G0L.js.map