@nebula.js/stardust 4.6.0 → 4.6.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/core/esm/dev.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * @nebula.js/stardust v4.6.0
2
+ * @nebula.js/stardust v4.6.2
3
3
  * Copyright (c) 2023 QlikTech International AB
4
4
  * Released under the MIT license.
5
5
  */
@@ -2306,7 +2306,7 @@ function extend$3(parent, definition) {
2306
2306
  return prototype;
2307
2307
  }
2308
2308
 
2309
- function Color() {}
2309
+ function Color$1() {}
2310
2310
 
2311
2311
  var darker = 0.7;
2312
2312
  var brighter = 1 / darker;
@@ -2473,7 +2473,7 @@ var named = {
2473
2473
  yellowgreen: 0x9acd32
2474
2474
  };
2475
2475
 
2476
- define(Color, color$3, {
2476
+ define(Color$1, color$3, {
2477
2477
  copy(channels) {
2478
2478
  return Object.assign(new this.constructor, this, channels);
2479
2479
  },
@@ -2509,15 +2509,15 @@ function color$3(format) {
2509
2509
  format = (format + "").trim().toLowerCase();
2510
2510
  return (m = reHex.exec(format)) ? (l = m[1].length, m = parseInt(m[1], 16), l === 6 ? rgbn(m) // #ff0000
2511
2511
  : l === 3 ? new Rgb((m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), ((m & 0xf) << 4) | (m & 0xf), 1) // #f00
2512
- : l === 8 ? rgba(m >> 24 & 0xff, m >> 16 & 0xff, m >> 8 & 0xff, (m & 0xff) / 0xff) // #ff000000
2513
- : l === 4 ? rgba((m >> 12 & 0xf) | (m >> 8 & 0xf0), (m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), (((m & 0xf) << 4) | (m & 0xf)) / 0xff) // #f000
2512
+ : l === 8 ? rgba$1(m >> 24 & 0xff, m >> 16 & 0xff, m >> 8 & 0xff, (m & 0xff) / 0xff) // #ff000000
2513
+ : l === 4 ? rgba$1((m >> 12 & 0xf) | (m >> 8 & 0xf0), (m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), (((m & 0xf) << 4) | (m & 0xf)) / 0xff) // #f000
2514
2514
  : null) // invalid hex
2515
2515
  : (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0)
2516
2516
  : (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%)
2517
- : (m = reRgbaInteger.exec(format)) ? rgba(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1)
2518
- : (m = reRgbaPercent.exec(format)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1)
2519
- : (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%)
2520
- : (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1)
2517
+ : (m = reRgbaInteger.exec(format)) ? rgba$1(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1)
2518
+ : (m = reRgbaPercent.exec(format)) ? rgba$1(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1)
2519
+ : (m = reHslPercent.exec(format)) ? hsla$1(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%)
2520
+ : (m = reHslaPercent.exec(format)) ? hsla$1(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1)
2521
2521
  : named.hasOwnProperty(format) ? rgbn(named[format]) // eslint-disable-line no-prototype-builtins
2522
2522
  : format === "transparent" ? new Rgb(NaN, NaN, NaN, 0)
2523
2523
  : null;
@@ -2527,19 +2527,19 @@ function rgbn(n) {
2527
2527
  return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1);
2528
2528
  }
2529
2529
 
2530
- function rgba(r, g, b, a) {
2530
+ function rgba$1(r, g, b, a) {
2531
2531
  if (a <= 0) r = g = b = NaN;
2532
2532
  return new Rgb(r, g, b, a);
2533
2533
  }
2534
2534
 
2535
2535
  function rgbConvert(o) {
2536
- if (!(o instanceof Color)) o = color$3(o);
2536
+ if (!(o instanceof Color$1)) o = color$3(o);
2537
2537
  if (!o) return new Rgb;
2538
2538
  o = o.rgb();
2539
2539
  return new Rgb(o.r, o.g, o.b, o.opacity);
2540
2540
  }
2541
2541
 
2542
- function rgb(r, g, b, opacity) {
2542
+ function rgb$1(r, g, b, opacity) {
2543
2543
  return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity);
2544
2544
  }
2545
2545
 
@@ -2550,7 +2550,7 @@ function Rgb(r, g, b, opacity) {
2550
2550
  this.opacity = +opacity;
2551
2551
  }
2552
2552
 
2553
- define(Rgb, rgb, extend$3(Color, {
2553
+ define(Rgb, rgb$1, extend$3(Color$1, {
2554
2554
  brighter(k) {
2555
2555
  k = k == null ? brighter : Math.pow(brighter, k);
2556
2556
  return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
@@ -2579,11 +2579,11 @@ define(Rgb, rgb, extend$3(Color, {
2579
2579
  }));
2580
2580
 
2581
2581
  function rgb_formatHex() {
2582
- return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}`;
2582
+ return `#${hex$1(this.r)}${hex$1(this.g)}${hex$1(this.b)}`;
2583
2583
  }
2584
2584
 
2585
2585
  function rgb_formatHex8() {
2586
- return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}${hex((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
2586
+ return `#${hex$1(this.r)}${hex$1(this.g)}${hex$1(this.b)}${hex$1((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
2587
2587
  }
2588
2588
 
2589
2589
  function rgb_formatRgb() {
@@ -2599,12 +2599,12 @@ function clampi(value) {
2599
2599
  return Math.max(0, Math.min(255, Math.round(value) || 0));
2600
2600
  }
2601
2601
 
2602
- function hex(value) {
2602
+ function hex$1(value) {
2603
2603
  value = clampi(value);
2604
2604
  return (value < 16 ? "0" : "") + value.toString(16);
2605
2605
  }
2606
2606
 
2607
- function hsla(h, s, l, a) {
2607
+ function hsla$1(h, s, l, a) {
2608
2608
  if (a <= 0) h = s = l = NaN;
2609
2609
  else if (l <= 0 || l >= 1) h = s = NaN;
2610
2610
  else if (s <= 0) h = NaN;
@@ -2613,7 +2613,7 @@ function hsla(h, s, l, a) {
2613
2613
 
2614
2614
  function hslConvert(o) {
2615
2615
  if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity);
2616
- if (!(o instanceof Color)) o = color$3(o);
2616
+ if (!(o instanceof Color$1)) o = color$3(o);
2617
2617
  if (!o) return new Hsl;
2618
2618
  if (o instanceof Hsl) return o;
2619
2619
  o = o.rgb();
@@ -2637,7 +2637,7 @@ function hslConvert(o) {
2637
2637
  return new Hsl(h, s, l, o.opacity);
2638
2638
  }
2639
2639
 
2640
- function hsl(h, s, l, opacity) {
2640
+ function hsl$1(h, s, l, opacity) {
2641
2641
  return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity);
2642
2642
  }
2643
2643
 
@@ -2648,7 +2648,7 @@ function Hsl(h, s, l, opacity) {
2648
2648
  this.opacity = +opacity;
2649
2649
  }
2650
2650
 
2651
- define(Hsl, hsl, extend$3(Color, {
2651
+ define(Hsl, hsl$1, extend$3(Color$1, {
2652
2652
  brighter(k) {
2653
2653
  k = k == null ? brighter : Math.pow(brighter, k);
2654
2654
  return new Hsl(this.h, this.s, this.l * k, this.opacity);
@@ -3241,7 +3241,7 @@ function blend(c1, c2, t) {
3241
3241
  const g = Math.floor(c1.g + (c2.g - c1.g) * t);
3242
3242
  const b = Math.floor(c1.b + (c2.b - c1.b) * t);
3243
3243
  const a = Math.floor(c1.opacity + (c2.opacity - c1.opacity) * t);
3244
- return rgb(r, g, b, a);
3244
+ return rgb$1(r, g, b, a);
3245
3245
  }
3246
3246
  class ColorScale {
3247
3247
  constructor(nanColor) {
@@ -4073,10 +4073,10 @@ function useEventCallback(fn) {
4073
4073
  useEnhancedEffect$1(() => {
4074
4074
  ref.current = fn;
4075
4075
  });
4076
- return React.useCallback((...args) =>
4076
+ return React.useRef((...args) =>
4077
4077
  // @ts-expect-error hide `this`
4078
4078
  // tslint:disable-next-line:ban-comma-operator
4079
- (0, ref.current)(...args), []);
4079
+ (0, ref.current)(...args)).current;
4080
4080
  }
4081
4081
 
4082
4082
  function useForkRef(...refs) {
@@ -5670,7 +5670,7 @@ function StyledEngineProvider(props) {
5670
5670
  }
5671
5671
 
5672
5672
  /**
5673
- * @mui/styled-engine v5.14.13
5673
+ * @mui/styled-engine v5.14.16
5674
5674
  *
5675
5675
  * @license MIT
5676
5676
  * This source code is licensed under the MIT license found in the
@@ -7934,7 +7934,7 @@ function createPalette(palette) {
7934
7934
  }
7935
7935
 
7936
7936
  const _excluded$9 = ["fontFamily", "fontSize", "fontWeightLight", "fontWeightRegular", "fontWeightMedium", "fontWeightBold", "htmlFontSize", "allVariants", "pxToRem"];
7937
- function round(value) {
7937
+ function round$1(value) {
7938
7938
  return Math.round(value * 1e5) / 1e5;
7939
7939
  }
7940
7940
  const caseAllCaps = {
@@ -7974,7 +7974,7 @@ function createTypography(palette, typography) {
7974
7974
  // Unitless following https://meyerweb.com/eric/thoughts/2006/02/08/unitless-line-heights/
7975
7975
  lineHeight
7976
7976
  }, fontFamily === defaultFontFamily ? {
7977
- letterSpacing: `${round(letterSpacing / size)}em`
7977
+ letterSpacing: `${round$1(letterSpacing / size)}em`
7978
7978
  } : {}, casing, allVariants);
7979
7979
  const variants = {
7980
7980
  h1: buildVariant(fontWeightLight, 96, 1.167, -1.5),
@@ -8330,6 +8330,7 @@ const light = {
8330
8330
  excluded: '#BEBEBE',
8331
8331
  selectedExcluded: '#BEBEBE',
8332
8332
  possible: colors.grey100,
8333
+ selectedContrastText: colors.grey100,
8333
8334
  mainContrastText: colors.grey100,
8334
8335
  alternativeContrastText: colors.grey25,
8335
8336
  excludedContrastText: colors.grey25,
@@ -8397,6 +8398,7 @@ const dark = {
8397
8398
  excluded: colors.grey10,
8398
8399
  selectedExcluded: colors.grey10,
8399
8400
  possible: colors.grey80,
8401
+ selectedContrastText: colors.grey100,
8400
8402
  mainContrastText: colors.grey100,
8401
8403
  alternativeContrastText: colors.grey100,
8402
8404
  excludedContrastText: colors.grey100,
@@ -8549,7 +8551,7 @@ function create$3(definition) {
8549
8551
  return cache[key];
8550
8552
  }
8551
8553
 
8552
- const NEBULA_VERSION_HASH = "ba42" ;
8554
+ const NEBULA_VERSION_HASH = "ca95" ;
8553
8555
  ClassNameGenerator$1.configure(componentName => {
8554
8556
  return "njs-".concat(NEBULA_VERSION_HASH, "-").concat(componentName.replace('Mui', ''));
8555
8557
  });
@@ -8810,7 +8812,7 @@ function boot(_ref2) {
8810
8812
  const appRef = React__default.createRef();
8811
8813
  const element = document.createElement('div');
8812
8814
  element.style.display = 'none';
8813
- element.setAttribute('data-nebulajs-version', "4.6.0" );
8815
+ element.setAttribute('data-nebulajs-version', "4.6.2" );
8814
8816
  element.setAttribute('data-app-id', app.id);
8815
8817
  document.body.appendChild(element);
8816
8818
  if (context) {
@@ -15539,18 +15541,1614 @@ function hasSelections(layout) {
15539
15541
  return totalCounts > 0;
15540
15542
  }
15541
15543
 
15544
+ const colorStruct = {
15545
+ aliceblue: {
15546
+ r: 240,
15547
+ g: 248,
15548
+ b: 255
15549
+ },
15550
+ antiquewhite: {
15551
+ r: 250,
15552
+ g: 235,
15553
+ b: 215
15554
+ },
15555
+ aqua: {
15556
+ r: 0,
15557
+ g: 255,
15558
+ b: 255
15559
+ },
15560
+ aquamarine: {
15561
+ r: 127,
15562
+ g: 255,
15563
+ b: 212
15564
+ },
15565
+ azure: {
15566
+ r: 240,
15567
+ g: 255,
15568
+ b: 255
15569
+ },
15570
+ beige: {
15571
+ r: 245,
15572
+ g: 245,
15573
+ b: 220
15574
+ },
15575
+ bisque: {
15576
+ r: 255,
15577
+ g: 228,
15578
+ b: 196
15579
+ },
15580
+ black: {
15581
+ r: 0,
15582
+ g: 0,
15583
+ b: 0
15584
+ },
15585
+ blanchedalmond: {
15586
+ r: 255,
15587
+ g: 235,
15588
+ b: 205
15589
+ },
15590
+ blue: {
15591
+ r: 0,
15592
+ g: 0,
15593
+ b: 255
15594
+ },
15595
+ blueviolet: {
15596
+ r: 138,
15597
+ g: 43,
15598
+ b: 226
15599
+ },
15600
+ brown: {
15601
+ r: 165,
15602
+ g: 42,
15603
+ b: 42
15604
+ },
15605
+ burlywood: {
15606
+ r: 222,
15607
+ g: 184,
15608
+ b: 135
15609
+ },
15610
+ cadetblue: {
15611
+ r: 95,
15612
+ g: 158,
15613
+ b: 160
15614
+ },
15615
+ chartreuse: {
15616
+ r: 127,
15617
+ g: 255,
15618
+ b: 0
15619
+ },
15620
+ chocolate: {
15621
+ r: 210,
15622
+ g: 105,
15623
+ b: 30
15624
+ },
15625
+ coral: {
15626
+ r: 255,
15627
+ g: 127,
15628
+ b: 80
15629
+ },
15630
+ cornflowerblue: {
15631
+ r: 100,
15632
+ g: 149,
15633
+ b: 237
15634
+ },
15635
+ cornsilk: {
15636
+ r: 255,
15637
+ g: 248,
15638
+ b: 220
15639
+ },
15640
+ crimson: {
15641
+ r: 220,
15642
+ g: 20,
15643
+ b: 60
15644
+ },
15645
+ cyan: {
15646
+ r: 0,
15647
+ g: 255,
15648
+ b: 255
15649
+ },
15650
+ darkblue: {
15651
+ r: 0,
15652
+ g: 0,
15653
+ b: 139
15654
+ },
15655
+ darkcyan: {
15656
+ r: 0,
15657
+ g: 139,
15658
+ b: 139
15659
+ },
15660
+ darkgoldenrod: {
15661
+ r: 184,
15662
+ g: 134,
15663
+ b: 11
15664
+ },
15665
+ darkgray: {
15666
+ r: 169,
15667
+ g: 169,
15668
+ b: 169
15669
+ },
15670
+ darkgreen: {
15671
+ r: 0,
15672
+ g: 100,
15673
+ b: 0
15674
+ },
15675
+ darkgrey: {
15676
+ r: 169,
15677
+ g: 169,
15678
+ b: 169
15679
+ },
15680
+ darkkhaki: {
15681
+ r: 189,
15682
+ g: 183,
15683
+ b: 107
15684
+ },
15685
+ darkmagenta: {
15686
+ r: 139,
15687
+ g: 0,
15688
+ b: 139
15689
+ },
15690
+ darkolivegreen: {
15691
+ r: 85,
15692
+ g: 107,
15693
+ b: 47
15694
+ },
15695
+ darkorange: {
15696
+ r: 255,
15697
+ g: 140,
15698
+ b: 0
15699
+ },
15700
+ darkorchid: {
15701
+ r: 153,
15702
+ g: 50,
15703
+ b: 204
15704
+ },
15705
+ darkred: {
15706
+ r: 139,
15707
+ g: 0,
15708
+ b: 0
15709
+ },
15710
+ darksalmon: {
15711
+ r: 233,
15712
+ g: 150,
15713
+ b: 122
15714
+ },
15715
+ darkseagreen: {
15716
+ r: 143,
15717
+ g: 188,
15718
+ b: 143
15719
+ },
15720
+ darkslateblue: {
15721
+ r: 72,
15722
+ g: 61,
15723
+ b: 139
15724
+ },
15725
+ darkslategray: {
15726
+ r: 47,
15727
+ g: 79,
15728
+ b: 79
15729
+ },
15730
+ darkslategrey: {
15731
+ r: 47,
15732
+ g: 79,
15733
+ b: 79
15734
+ },
15735
+ darkturquoise: {
15736
+ r: 0,
15737
+ g: 206,
15738
+ b: 209
15739
+ },
15740
+ darkviolet: {
15741
+ r: 148,
15742
+ g: 0,
15743
+ b: 211
15744
+ },
15745
+ deeppink: {
15746
+ r: 255,
15747
+ g: 20,
15748
+ b: 147
15749
+ },
15750
+ deepskyblue: {
15751
+ r: 0,
15752
+ g: 191,
15753
+ b: 255
15754
+ },
15755
+ dimgray: {
15756
+ r: 105,
15757
+ g: 105,
15758
+ b: 105
15759
+ },
15760
+ dimgrey: {
15761
+ r: 105,
15762
+ g: 105,
15763
+ b: 105
15764
+ },
15765
+ dodgerblue: {
15766
+ r: 30,
15767
+ g: 144,
15768
+ b: 255
15769
+ },
15770
+ firebrick: {
15771
+ r: 178,
15772
+ g: 34,
15773
+ b: 34
15774
+ },
15775
+ floralwhite: {
15776
+ r: 255,
15777
+ g: 250,
15778
+ b: 240
15779
+ },
15780
+ forestgreen: {
15781
+ r: 34,
15782
+ g: 139,
15783
+ b: 34
15784
+ },
15785
+ fuchsia: {
15786
+ r: 255,
15787
+ g: 0,
15788
+ b: 255
15789
+ },
15790
+ gainsboro: {
15791
+ r: 220,
15792
+ g: 220,
15793
+ b: 220
15794
+ },
15795
+ ghostwhite: {
15796
+ r: 248,
15797
+ g: 248,
15798
+ b: 255
15799
+ },
15800
+ gold: {
15801
+ r: 255,
15802
+ g: 215,
15803
+ b: 0
15804
+ },
15805
+ goldenrod: {
15806
+ r: 218,
15807
+ g: 165,
15808
+ b: 32
15809
+ },
15810
+ gray: {
15811
+ r: 128,
15812
+ g: 128,
15813
+ b: 128
15814
+ },
15815
+ green: {
15816
+ r: 0,
15817
+ g: 128,
15818
+ b: 0
15819
+ },
15820
+ greenyellow: {
15821
+ r: 173,
15822
+ g: 255,
15823
+ b: 47
15824
+ },
15825
+ grey: {
15826
+ r: 128,
15827
+ g: 128,
15828
+ b: 128
15829
+ },
15830
+ honeydew: {
15831
+ r: 240,
15832
+ g: 255,
15833
+ b: 240
15834
+ },
15835
+ hotpink: {
15836
+ r: 255,
15837
+ g: 105,
15838
+ b: 180
15839
+ },
15840
+ indianred: {
15841
+ r: 205,
15842
+ g: 92,
15843
+ b: 92
15844
+ },
15845
+ indigo: {
15846
+ r: 75,
15847
+ g: 0,
15848
+ b: 130
15849
+ },
15850
+ ivory: {
15851
+ r: 255,
15852
+ g: 255,
15853
+ b: 240
15854
+ },
15855
+ khaki: {
15856
+ r: 240,
15857
+ g: 230,
15858
+ b: 140
15859
+ },
15860
+ lavender: {
15861
+ r: 230,
15862
+ g: 230,
15863
+ b: 250
15864
+ },
15865
+ lavenderblush: {
15866
+ r: 255,
15867
+ g: 240,
15868
+ b: 245
15869
+ },
15870
+ lawngreen: {
15871
+ r: 124,
15872
+ g: 252,
15873
+ b: 0
15874
+ },
15875
+ lemonchiffon: {
15876
+ r: 255,
15877
+ g: 250,
15878
+ b: 205
15879
+ },
15880
+ lightblue: {
15881
+ r: 173,
15882
+ g: 216,
15883
+ b: 230
15884
+ },
15885
+ lightcoral: {
15886
+ r: 240,
15887
+ g: 128,
15888
+ b: 128
15889
+ },
15890
+ lightcyan: {
15891
+ r: 224,
15892
+ g: 255,
15893
+ b: 255
15894
+ },
15895
+ lightgoldenrodyellow: {
15896
+ r: 250,
15897
+ g: 250,
15898
+ b: 210
15899
+ },
15900
+ lightgray: {
15901
+ r: 211,
15902
+ g: 211,
15903
+ b: 211
15904
+ },
15905
+ lightgreen: {
15906
+ r: 144,
15907
+ g: 238,
15908
+ b: 144
15909
+ },
15910
+ lightgrey: {
15911
+ r: 211,
15912
+ g: 211,
15913
+ b: 211
15914
+ },
15915
+ lightpink: {
15916
+ r: 255,
15917
+ g: 182,
15918
+ b: 193
15919
+ },
15920
+ lightsalmon: {
15921
+ r: 255,
15922
+ g: 160,
15923
+ b: 122
15924
+ },
15925
+ lightseagreen: {
15926
+ r: 32,
15927
+ g: 178,
15928
+ b: 170
15929
+ },
15930
+ lightskyblue: {
15931
+ r: 135,
15932
+ g: 206,
15933
+ b: 250
15934
+ },
15935
+ lightslategray: {
15936
+ r: 119,
15937
+ g: 136,
15938
+ b: 153
15939
+ },
15940
+ lightslategrey: {
15941
+ r: 119,
15942
+ g: 136,
15943
+ b: 153
15944
+ },
15945
+ lightsteelblue: {
15946
+ r: 176,
15947
+ g: 196,
15948
+ b: 222
15949
+ },
15950
+ lightyellow: {
15951
+ r: 255,
15952
+ g: 255,
15953
+ b: 224
15954
+ },
15955
+ lime: {
15956
+ r: 0,
15957
+ g: 255,
15958
+ b: 0
15959
+ },
15960
+ limegreen: {
15961
+ r: 50,
15962
+ g: 205,
15963
+ b: 50
15964
+ },
15965
+ linen: {
15966
+ r: 250,
15967
+ g: 240,
15968
+ b: 230
15969
+ },
15970
+ magenta: {
15971
+ r: 255,
15972
+ g: 0,
15973
+ b: 255
15974
+ },
15975
+ maroon: {
15976
+ r: 128,
15977
+ g: 0,
15978
+ b: 0
15979
+ },
15980
+ mediumaquamarine: {
15981
+ r: 102,
15982
+ g: 205,
15983
+ b: 170
15984
+ },
15985
+ mediumblue: {
15986
+ r: 0,
15987
+ g: 0,
15988
+ b: 205
15989
+ },
15990
+ mediumorchid: {
15991
+ r: 186,
15992
+ g: 85,
15993
+ b: 211
15994
+ },
15995
+ mediumpurple: {
15996
+ r: 147,
15997
+ g: 112,
15998
+ b: 219
15999
+ },
16000
+ mediumseagreen: {
16001
+ r: 60,
16002
+ g: 179,
16003
+ b: 113
16004
+ },
16005
+ mediumslateblue: {
16006
+ r: 123,
16007
+ g: 104,
16008
+ b: 238
16009
+ },
16010
+ mediumspringgreen: {
16011
+ r: 0,
16012
+ g: 250,
16013
+ b: 154
16014
+ },
16015
+ mediumturquoise: {
16016
+ r: 72,
16017
+ g: 209,
16018
+ b: 204
16019
+ },
16020
+ mediumvioletred: {
16021
+ r: 199,
16022
+ g: 21,
16023
+ b: 133
16024
+ },
16025
+ midnightblue: {
16026
+ r: 25,
16027
+ g: 25,
16028
+ b: 112
16029
+ },
16030
+ mintcream: {
16031
+ r: 245,
16032
+ g: 255,
16033
+ b: 250
16034
+ },
16035
+ mistyrose: {
16036
+ r: 255,
16037
+ g: 228,
16038
+ b: 225
16039
+ },
16040
+ moccasin: {
16041
+ r: 255,
16042
+ g: 228,
16043
+ b: 181
16044
+ },
16045
+ navajowhite: {
16046
+ r: 255,
16047
+ g: 222,
16048
+ b: 173
16049
+ },
16050
+ navy: {
16051
+ r: 0,
16052
+ g: 0,
16053
+ b: 128
16054
+ },
16055
+ oldlace: {
16056
+ r: 253,
16057
+ g: 245,
16058
+ b: 230
16059
+ },
16060
+ olive: {
16061
+ r: 128,
16062
+ g: 128,
16063
+ b: 0
16064
+ },
16065
+ olivedrab: {
16066
+ r: 107,
16067
+ g: 142,
16068
+ b: 35
16069
+ },
16070
+ orange: {
16071
+ r: 255,
16072
+ g: 165,
16073
+ b: 0
16074
+ },
16075
+ orangered: {
16076
+ r: 255,
16077
+ g: 69,
16078
+ b: 0
16079
+ },
16080
+ orchid: {
16081
+ r: 218,
16082
+ g: 112,
16083
+ b: 214
16084
+ },
16085
+ palegoldenrod: {
16086
+ r: 238,
16087
+ g: 232,
16088
+ b: 170
16089
+ },
16090
+ palegreen: {
16091
+ r: 152,
16092
+ g: 251,
16093
+ b: 152
16094
+ },
16095
+ paleturquoise: {
16096
+ r: 175,
16097
+ g: 238,
16098
+ b: 238
16099
+ },
16100
+ palevioletred: {
16101
+ r: 219,
16102
+ g: 112,
16103
+ b: 147
16104
+ },
16105
+ papayawhip: {
16106
+ r: 255,
16107
+ g: 239,
16108
+ b: 213
16109
+ },
16110
+ peachpuff: {
16111
+ r: 255,
16112
+ g: 218,
16113
+ b: 185
16114
+ },
16115
+ peru: {
16116
+ r: 205,
16117
+ g: 133,
16118
+ b: 63
16119
+ },
16120
+ pink: {
16121
+ r: 255,
16122
+ g: 192,
16123
+ b: 203
16124
+ },
16125
+ plum: {
16126
+ r: 221,
16127
+ g: 160,
16128
+ b: 221
16129
+ },
16130
+ powderblue: {
16131
+ r: 176,
16132
+ g: 224,
16133
+ b: 230
16134
+ },
16135
+ purple: {
16136
+ r: 128,
16137
+ g: 0,
16138
+ b: 128
16139
+ },
16140
+ red: {
16141
+ r: 255,
16142
+ g: 0,
16143
+ b: 0
16144
+ },
16145
+ rosybrown: {
16146
+ r: 188,
16147
+ g: 143,
16148
+ b: 143
16149
+ },
16150
+ royalblue: {
16151
+ r: 65,
16152
+ g: 105,
16153
+ b: 225
16154
+ },
16155
+ saddlebrown: {
16156
+ r: 139,
16157
+ g: 69,
16158
+ b: 19
16159
+ },
16160
+ salmon: {
16161
+ r: 250,
16162
+ g: 128,
16163
+ b: 114
16164
+ },
16165
+ sandybrown: {
16166
+ r: 244,
16167
+ g: 164,
16168
+ b: 96
16169
+ },
16170
+ seagreen: {
16171
+ r: 46,
16172
+ g: 139,
16173
+ b: 87
16174
+ },
16175
+ seashell: {
16176
+ r: 255,
16177
+ g: 245,
16178
+ b: 238
16179
+ },
16180
+ sienna: {
16181
+ r: 160,
16182
+ g: 82,
16183
+ b: 45
16184
+ },
16185
+ silver: {
16186
+ r: 192,
16187
+ g: 192,
16188
+ b: 192
16189
+ },
16190
+ skyblue: {
16191
+ r: 135,
16192
+ g: 206,
16193
+ b: 235
16194
+ },
16195
+ slateblue: {
16196
+ r: 106,
16197
+ g: 90,
16198
+ b: 205
16199
+ },
16200
+ slategray: {
16201
+ r: 112,
16202
+ g: 128,
16203
+ b: 144
16204
+ },
16205
+ slategrey: {
16206
+ r: 112,
16207
+ g: 128,
16208
+ b: 144
16209
+ },
16210
+ snow: {
16211
+ r: 255,
16212
+ g: 250,
16213
+ b: 250
16214
+ },
16215
+ springgreen: {
16216
+ r: 0,
16217
+ g: 255,
16218
+ b: 127
16219
+ },
16220
+ steelblue: {
16221
+ r: 70,
16222
+ g: 130,
16223
+ b: 180
16224
+ },
16225
+ tan: {
16226
+ r: 210,
16227
+ g: 180,
16228
+ b: 140
16229
+ },
16230
+ teal: {
16231
+ r: 0,
16232
+ g: 128,
16233
+ b: 128
16234
+ },
16235
+ thistle: {
16236
+ r: 216,
16237
+ g: 191,
16238
+ b: 216
16239
+ },
16240
+ tomato: {
16241
+ r: 255,
16242
+ g: 99,
16243
+ b: 71
16244
+ },
16245
+ transparent: {
16246
+ r: 255,
16247
+ g: 255,
16248
+ b: 255,
16249
+ a: 0
16250
+ },
16251
+ turquoise: {
16252
+ r: 64,
16253
+ g: 224,
16254
+ b: 208
16255
+ },
16256
+ violet: {
16257
+ r: 238,
16258
+ g: 130,
16259
+ b: 238
16260
+ },
16261
+ wheat: {
16262
+ r: 245,
16263
+ g: 222,
16264
+ b: 179
16265
+ },
16266
+ white: {
16267
+ r: 255,
16268
+ g: 255,
16269
+ b: 255
16270
+ },
16271
+ whitesmoke: {
16272
+ r: 245,
16273
+ g: 245,
16274
+ b: 245
16275
+ },
16276
+ yellow: {
16277
+ r: 255,
16278
+ g: 255,
16279
+ b: 0
16280
+ },
16281
+ yellowgreen: {
16282
+ r: 154,
16283
+ g: 205,
16284
+ b: 50
16285
+ }
16286
+ };
16287
+
16288
+ /* eslint-disable no-param-reassign */
16289
+ /* eslint-disable camelcase */
16290
+ /* eslint-disable no-nested-ternary */
16291
+ /* eslint-disable no-cond-assign */
16292
+ /* eslint-disable prefer-destructuring */
16293
+ /* eslint-disable no-underscore-dangle */
16294
+
16295
+
16296
+ /**
16297
+ * Module which defines a color object
16298
+ * @private
16299
+ * @exports objects.views/charts/representation/color
16300
+ * @expose module:objects.views/charts/representation/color~Color
16301
+ */
16302
+
16303
+ // color formats
16304
+ const rgb = /^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/i;
16305
+ const rgba = /^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),(\d(\.\d+)?)\)$/i;
16306
+ const hex = /^#([A-f0-9]{2})([A-f0-9]{2})([A-f0-9]{2})$/i;
16307
+ const hexShort = /^#([A-f0-9])([A-f0-9])([A-f0-9])$/i;
16308
+ const hsl = /^hsl\(\s*(\d+(\.\d+)?)\s*,\s*(\d+(\.\d+)?%?)\s*,\s*(\d+(\.\d+)?%?)\s*\)$/i;
16309
+ const hsla = /^hsla\(\s*(\d+(\.\d+)?)\s*,\s*(\d+(\.\d+)?%?)\s*,\s*(\d+(\.\d+)?%?)\s*,(\d(\.\d+)?)\)$/i;
16310
+ const {
16311
+ floor
16312
+ } = Math;
16313
+ const {
16314
+ round
16315
+ } = Math;
16316
+
16317
+ /**
16318
+ * @class
16319
+ * @classdesc Class which provides color transformation functionality
16320
+ * @description This is a constructor.
16321
+ * @private This is a constructor.
16322
+ * @param {object} - Parameters to create a color from different notations
16323
+ * @example
16324
+ * // a few ways of instantiating a red color
16325
+ * var red;
16326
+ * red = new Color(255, 0, 0, 1); // rgba as parameters
16327
+ * red = new Color('#ff0000'); // hex
16328
+ * red = new Color('rgb(255,0,0)');//rgb as string
16329
+ * red = new Color('hsl(0, 100, 50)');// hsl as string
16330
+ * red = new Color(16711680);// uint
16331
+ */
16332
+ class Color {
16333
+ constructor() {
16334
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
16335
+ args[_key] = arguments[_key];
16336
+ }
16337
+ let r = 0;
16338
+ let g = 0;
16339
+ let b = 0;
16340
+ let a = 1;
16341
+ let h;
16342
+ let s;
16343
+ let lcs;
16344
+ let l;
16345
+ let v;
16346
+ let c;
16347
+ let h_;
16348
+ let x;
16349
+ let rgb_;
16350
+ let m;
16351
+ let matches;
16352
+ let colorString;
16353
+ this._invalid = false;
16354
+ if (args[0] instanceof Color) {
16355
+ r = args[0]._r;
16356
+ g = args[0]._g;
16357
+ b = args[0]._b;
16358
+ a = args[0]._a;
16359
+ this._invalid = args[0]._invalid;
16360
+ } else if (args.length < 3) {
16361
+ if (typeof args[0] === 'string') {
16362
+ colorString = args[0];
16363
+ if (matches = /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i.exec(colorString)) {
16364
+ r = parseInt(matches[1], 10);
16365
+ g = parseInt(matches[2], 10);
16366
+ b = parseInt(matches[3], 10);
16367
+ } else if (matches = /^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d(\.\d+)?)\s*\)$/i.exec(colorString)) {
16368
+ // rgba(1, 2, 3, 0.4)
16369
+ r = parseInt(matches[1], 10);
16370
+ g = parseInt(matches[2], 10);
16371
+ b = parseInt(matches[3], 10);
16372
+ a = parseFloat(matches[4]);
16373
+ } else if (matches = /^ARGB\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i.exec(colorString)) {
16374
+ // ARGB(255,255,255,255)
16375
+ a = parseInt(matches[1], 10) / 255;
16376
+ r = parseInt(matches[2], 10);
16377
+ g = parseInt(matches[3], 10);
16378
+ b = parseInt(matches[4], 10);
16379
+ } else if (matches = /^#([A-f0-9]{2})([A-f0-9]{2})([A-f0-9]{2})$/i.exec(colorString)) {
16380
+ // #aBc123
16381
+ r = parseInt(matches[1], 16);
16382
+ g = parseInt(matches[2], 16);
16383
+ b = parseInt(matches[3], 16);
16384
+ a = 1;
16385
+ } else if (matches = /^#([A-f0-9])([A-f0-9])([A-f0-9])$/i.exec(colorString)) {
16386
+ // #a5F
16387
+ r = parseInt(matches[1] + matches[1], 16);
16388
+ g = parseInt(matches[2] + matches[2], 16);
16389
+ b = parseInt(matches[3] + matches[3], 16);
16390
+ a = 1;
16391
+ } else if (matches = /^hsl\(\s*(\d+(\.\d+)?)\s*,\s*(\d+(\.\d+)?%?)\s*,\s*(\d+(\.\d+)?%?)\s*\)$/i.exec(colorString)) {
16392
+ // hsl(1, 2, 3)
16393
+ h = parseFloat(matches[1]);
16394
+ s = parseFloat(matches[3]);
16395
+ l = parseFloat(matches[5]);
16396
+ h %= 360;
16397
+ s /= 100;
16398
+ l /= 100;
16399
+ h = h < 0 ? 0 : h > 360 ? 360 : h;
16400
+ s = s < 0 ? 0 : s > 1 ? 1 : s;
16401
+ l = l < 0 ? 0 : l > 1 ? 1 : l;
16402
+ c = l <= 0.5 ? 2 * l * s : (2 - 2 * l) * s;
16403
+ h_ = h / 60;
16404
+ x = c * (1 - Math.abs(h_ % 2 - 1));
16405
+ rgb_ = [];
16406
+ h_ = Math.floor(h_);
16407
+ switch (h_) {
16408
+ case 0:
16409
+ rgb_ = [c, x, 0];
16410
+ break;
16411
+ case 1:
16412
+ rgb_ = [x, c, 0];
16413
+ break;
16414
+ case 2:
16415
+ rgb_ = [0, c, x];
16416
+ break;
16417
+ case 3:
16418
+ rgb_ = [0, x, c];
16419
+ break;
16420
+ case 4:
16421
+ rgb_ = [x, 0, c];
16422
+ break;
16423
+ case 5:
16424
+ rgb_ = [c, 0, x];
16425
+ break;
16426
+ default:
16427
+ rgb_ = [0, 0, 0];
16428
+ }
16429
+ m = l - 0.5 * c;
16430
+ r = rgb_[0] + m;
16431
+ g = rgb_[1] + m;
16432
+ b = rgb_[2] + m;
16433
+ r = round(255 * r);
16434
+ g = round(255 * g);
16435
+ b = round(255 * b);
16436
+ a = 1.0;
16437
+ } else if (matches = /^hsla\(\s*(\d+(\.\d+)?)\s*,\s*(\d+(\.\d+)?%?)\s*,\s*(\d+(\.\d+)?%?)\s*,(\d(\.\d+)?)\)$/i.exec(colorString)) {
16438
+ // hsla(1,2,3,0.4)
16439
+ h = parseFloat(matches[1]);
16440
+ s = parseFloat(matches[3]);
16441
+ l = parseFloat(matches[5]);
16442
+ a = parseFloat(matches[7]);
16443
+ h %= 360;
16444
+ s /= 100;
16445
+ l /= 100;
16446
+ h = h < 0 ? 0 : h > 360 ? 360 : h;
16447
+ s = s < 0 ? 0 : s > 1 ? 1 : s;
16448
+ l = l < 0 ? 0 : l > 1 ? 1 : l;
16449
+ c = l <= 0.5 ? 2 * l * s : (2 - 2 * l) * s;
16450
+ h_ = h / 60;
16451
+ x = c * (1 - Math.abs(h_ % 2 - 1));
16452
+ rgb_ = [];
16453
+ h_ = Math.floor(h_);
16454
+ switch (h_) {
16455
+ case 0:
16456
+ rgb_ = [c, x, 0];
16457
+ break;
16458
+ case 1:
16459
+ rgb_ = [x, c, 0];
16460
+ break;
16461
+ case 2:
16462
+ rgb_ = [0, c, x];
16463
+ break;
16464
+ case 3:
16465
+ rgb_ = [0, x, c];
16466
+ break;
16467
+ case 4:
16468
+ rgb_ = [x, 0, c];
16469
+ break;
16470
+ case 5:
16471
+ rgb_ = [c, 0, x];
16472
+ break;
16473
+ default:
16474
+ rgb_ = [0, 0, 0];
16475
+ }
16476
+ m = l - 0.5 * c;
16477
+ r = rgb_[0] + m;
16478
+ g = rgb_[1] + m;
16479
+ b = rgb_[2] + m;
16480
+ r = round(255 * r);
16481
+ g = round(255 * g);
16482
+ b = round(255 * b);
16483
+ } else if (matches = /^hsv\(\s*(\d+(\.\d+)?)\s*,\s*(\d+(\.\d+)?%?)\s*,\s*(\d+(\.\d+)?%?)\s*\)$/i.exec(colorString)) {
16484
+ // hsv(1, 2, 3) {
16485
+ h = parseFloat(matches[1]);
16486
+ s = parseFloat(matches[3]);
16487
+ v = parseFloat(matches[5]);
16488
+ h %= 360;
16489
+ s /= 100;
16490
+ v /= 100;
16491
+ h = h < 0 ? 0 : h > 360 ? 360 : h;
16492
+ s = s < 0 ? 0 : s > 1 ? 1 : s;
16493
+ v = v < 0 ? 0 : v > 1 ? 1 : v;
16494
+ c = v * s;
16495
+ h_ = h / 60;
16496
+ x = c * (1 - Math.abs(h_ % 2 - 1));
16497
+ rgb_ = [];
16498
+ h_ = Math.floor(h_);
16499
+ switch (h_) {
16500
+ case 0:
16501
+ rgb_ = [c, x, 0];
16502
+ break;
16503
+ case 1:
16504
+ rgb_ = [x, c, 0];
16505
+ break;
16506
+ case 2:
16507
+ rgb_ = [0, c, x];
16508
+ break;
16509
+ case 3:
16510
+ rgb_ = [0, x, c];
16511
+ break;
16512
+ case 4:
16513
+ rgb_ = [x, 0, c];
16514
+ break;
16515
+ case 5:
16516
+ rgb_ = [c, 0, x];
16517
+ break;
16518
+ default:
16519
+ rgb_ = [0, 0, 0];
16520
+ }
16521
+ m = v - c;
16522
+ r = rgb_[0] + m;
16523
+ g = rgb_[1] + m;
16524
+ b = rgb_[2] + m;
16525
+ r = round(255 * r);
16526
+ g = round(255 * g);
16527
+ b = round(255 * b);
16528
+ a = 1.0;
16529
+ } else if (colorStruct[colorString.toLowerCase()]) {
16530
+ lcs = colorString.toLowerCase();
16531
+ r = colorStruct[lcs].r;
16532
+ g = colorStruct[lcs].g;
16533
+ b = colorStruct[lcs].b;
16534
+ a = typeof colorStruct[lcs].a === 'number' ? colorStruct[lcs].a : 1.0;
16535
+ } else {
16536
+ this._invalid = true;
16537
+ }
16538
+ } else if (typeof args[0] === 'number' && args[0] >= 0 && args[1] === 'argb') {
16539
+ a = (0xff000000 & args[0]) >>> 24;
16540
+ a /= 255;
16541
+ r = (0xff0000 & args[0]) >> 16;
16542
+ g = (0x00ff00 & args[0]) >> 8;
16543
+ b = 0x0000ff & args[0];
16544
+ } else if (typeof args[0] === 'number' && args[0] >= 0) {
16545
+ r = (0xff0000 & args[0]) >> 16;
16546
+ g = (0x00ff00 & args[0]) >> 8;
16547
+ b = 0x0000ff & args[0];
16548
+ } else {
16549
+ this._invalid = true;
16550
+ }
16551
+ } else if (args.length >= 3) {
16552
+ r = args[0];
16553
+ g = args[1];
16554
+ b = args[2];
16555
+ a = arguments.length >= 4 ? args[3] : 1;
16556
+ } else {
16557
+ this._invalid = true;
16558
+ }
16559
+ if (Number.isNaN(+r + g + b + a)) {
16560
+ this._invalid = true;
16561
+ }
16562
+ this._r = floor(r);
16563
+ this._g = floor(g);
16564
+ this._b = floor(b);
16565
+ this._a = a;
16566
+
16567
+ // object to cache string representations in various color spaces
16568
+ this._spaces = {};
16569
+ }
16570
+ isInvalid() {
16571
+ return this._invalid;
16572
+ }
16573
+
16574
+ /**
16575
+ * Sets alpha value of color
16576
+ * @private
16577
+ * @param {number} a - Alpha value of the color
16578
+ */
16579
+ setAlpha(a) {
16580
+ this._a = a;
16581
+ this._spaces = {};
16582
+ }
16583
+
16584
+ /**
16585
+ * Gets the alpha value of this color
16586
+ * @private
16587
+ * @returns {number}
16588
+ */
16589
+ getAlpha() {
16590
+ return this._a;
16591
+ }
16592
+
16593
+ /**
16594
+ * Returns an rgb string representation of this color.
16595
+ * @private
16596
+ * @return {string} An rgb string representation of this color
16597
+ */
16598
+ toRGB() {
16599
+ if (!this._spaces.rgb) {
16600
+ this._spaces.rgb = Color.toRGB(this);
16601
+ }
16602
+ return this._spaces.rgb;
16603
+ }
16604
+
16605
+ /**
16606
+ * Returns an rgba string representation of this color.
16607
+ * @private
16608
+ * @return {string} An rgba string representation of this color.
16609
+ */
16610
+ toRGBA() {
16611
+ if (!this._spaces.rgba) {
16612
+ this._spaces.rgba = Color.toRGBA(this);
16613
+ }
16614
+ return this._spaces.rgba;
16615
+ }
16616
+ toString() {
16617
+ if (!this._spaces.rgb) {
16618
+ this._spaces.rgb = Color.toRGB(this);
16619
+ }
16620
+ return this._spaces.rgb;
16621
+ }
16622
+
16623
+ /**
16624
+ * Returns a hex string representation of this color.
16625
+ * @private
16626
+ * @return {string}
16627
+ */
16628
+ toHex() {
16629
+ if (!this._spaces.hex) {
16630
+ this._spaces.hex = Color.toHex(this);
16631
+ }
16632
+ return this._spaces.hex;
16633
+ }
16634
+
16635
+ /**
16636
+ * Returns a hsl string representation of this color using "bi-hexcone" model for lightness
16637
+ * @private
16638
+ * @param {boolean} luma - Whether to use luma calculation
16639
+ * @return {string} In format hsl(0,0,0)
16640
+ */
16641
+ toHSL(luma) {
16642
+ if (!this._spaces.hsl) {
16643
+ this._spaces.hsl = Color.toHSL(this, luma);
16644
+ }
16645
+ return this._spaces.hsl;
16646
+ }
16647
+
16648
+ /**
16649
+ * Returns a hsla string representation of this color using "bi-hexcone" model for lightness
16650
+ * @private
16651
+ * @param {boolean} luma - Whether to use luma calculation
16652
+ * @return {string} In format hsla(0,0,0,0)
16653
+ */
16654
+ toHSLA(luma) {
16655
+ if (!this._spaces.hsla) {
16656
+ this._spaces.hsla = Color.toHSLA(this, luma);
16657
+ }
16658
+ return this._spaces.hsla;
16659
+ }
16660
+
16661
+ /**
16662
+ * Return the color components in hsv space using "hexcone" model for value (lightness)
16663
+ * @private
16664
+ * @param {Color|string} c
16665
+ * @returns {object} The color components in hsv space {h:0-360, s:0-100, v:0-100}
16666
+ */
16667
+ toHSV() {
16668
+ const hsvComp = this.toHSVComponents();
16669
+ return "hsv(".concat(hsvComp.h, ",").concat(hsvComp.s, ",").concat(hsvComp.v, ")");
16670
+ }
16671
+
16672
+ /**
16673
+ * Return the color components in hsv space using "hexcone" model for value (lightness)
16674
+ * @private
16675
+ * @param {Color|string} c
16676
+ * @returns {object} The color components in hsv space {h:0-360, s:0-100, v:0-100}
16677
+ */
16678
+ toHSVComponents() {
16679
+ if (!this._spaces.hsvComp) {
16680
+ this._spaces.hsvComp = Color.toHSVComponents(this);
16681
+ }
16682
+ return this._spaces.hsvComp;
16683
+ }
16684
+
16685
+ /**
16686
+ * Returns a uint representation of this color
16687
+ * @private
16688
+ * @return {number}
16689
+ */
16690
+ toNumber() {
16691
+ if (!this._spaces.num) {
16692
+ this._spaces.num = Color.toNumber(this);
16693
+ }
16694
+ return this._spaces.num;
16695
+ }
16696
+
16697
+ /**
16698
+ * Checks if this color is perceived as dark.
16699
+ * @private
16700
+ * @return {string} True if the luminance is below 160, false otherwise.
16701
+ */
16702
+ isDark() {
16703
+ return this.isInvalid() || this.getLuminance() < 125; // luminace calc option #2
16704
+ // return this.getLuminance() < 160; //luminace calc option #3
16705
+ }
16706
+
16707
+ /**
16708
+ * Calculates the perceived luminance of the color.
16709
+ * @private
16710
+ * @return {number} A value in the range 0-255 where a low value is considered dark and vice versa.
16711
+ */
16712
+ getLuminance() {
16713
+ // alpha channel is not considered
16714
+ if (typeof this._lumi === 'undefined') {
16715
+ // calculate luminance
16716
+ // this._lumi = 0.2126 * this._r + 0.7152 * this._g + 0.0722 * this._b; // option 1
16717
+ this._lumi = 0.299 * this._r + 0.587 * this._g + 0.114 * this._b; // option 2
16718
+ // this._lumi = Math.sqrt( 0.241 * this._r * this._r + 0.691 * this._g * this._g + 0.068 * this._b * this._b ); // option 3
16719
+ }
16720
+
16721
+ return this._lumi;
16722
+ }
16723
+
16724
+ /**
16725
+ * Shifts the color towards a lighter or darker shade
16726
+ * @private
16727
+ * @param {number} value - A value in the range -100-100 to shift the color with along the HSL lightness.
16728
+ * @return {string} The shifted color as hsla string.
16729
+ */
16730
+ shiftLuminance(value) {
16731
+ const chsla = this.toHSLA();
16732
+ const matches = /^hsla\(\s*(\d+(\.\d+)?)\s*,\s*(\d+(\.\d+)?%?)\s*,\s*(\d+(\.\d+)?%?)\s*,(\d(\.\d+)?)\)$/i.exec(chsla);
16733
+ const h = parseFloat(matches[1]);
16734
+ const s = parseFloat(matches[3]);
16735
+ let l = parseFloat(matches[5]);
16736
+ const a = parseFloat(matches[7]);
16737
+ // l *= 1 + value / 100;
16738
+ // l = Math.max( 0, l % 100 );
16739
+ l += value;
16740
+ l = Math.max(0, Math.min(l, 100));
16741
+
16742
+ // if( value > 0 ){
16743
+ // s = s*0.2; //removing saturation to avoid the border from being too light
16744
+ // }
16745
+
16746
+ return "hsla(".concat(h, ",").concat(s, ",").concat(l, ",").concat(a, ")");
16747
+ }
16748
+
16749
+ /**
16750
+ * Compares two colors.
16751
+ * @private
16752
+ * @param {Color} c The color to compare with.
16753
+ * @return {boolean} True if the rgba channels are the same, false otherwise
16754
+ */
16755
+ isEqual(c) {
16756
+ if (c instanceof Color) {
16757
+ return this._r === c._r && this._g === c._g && this._b === c._b && this._a === c._a;
16758
+ }
16759
+ c = new Color(c);
16760
+ return this._r === c._r && this._g === c._g && this._b === c._b && this._a === c._a;
16761
+ }
16762
+
16763
+ /**
16764
+ * Linearly interpolates each channel of two colors.
16765
+ * @private
16766
+ * @param {Color} c2 The other color.
16767
+ * @param {number} t The interpolation value in the range (0-1).
16768
+ * @return {string} The blend as an rgb string.
16769
+ */
16770
+ blend(c2, t) {
16771
+ const r = floor(this._r + (c2._r - this._r) * t);
16772
+ const g = floor(this._g + (c2._g - this._g) * t);
16773
+ const b = floor(this._b + (c2._b - this._b) * t);
16774
+ const a = floor(this._a + (c2._a - this._a) * t);
16775
+ return "rgba(".concat([r, g, b, a].join(','), ")");
16776
+ }
16777
+ createShiftedColor(v) {
16778
+ if (v === undefined || Number.isNaN(+v)) {
16779
+ v = 1;
16780
+ }
16781
+ const lumi = this.getLuminance();
16782
+ const greenMultiplier = this._g < 126 ? 1 : 1 + this._g / 512;
16783
+ const hsla_string = this.shiftLuminance((lumi * greenMultiplier < 220 ? 0.8 + 4 * (1 / (lumi + 1)) : -(0.8 + 1 * (lumi / 255))) * 20 * v);
16784
+ return new Color(hsla_string);
16785
+ }
16786
+
16787
+ /**
16788
+ * Returns an rgb string representation of this color
16789
+ * @private
16790
+ * @param {Color|string} c
16791
+ * @returns {string} An rgb string with channel values within range 0-255.
16792
+ */
16793
+ static toRGB(c) {
16794
+ if (c instanceof Color) {
16795
+ return "rgb(".concat([c._r, c._g, c._b].join(','), ")");
16796
+ }
16797
+ if (typeof c === 'string') {
16798
+ c = Color.toNumber(c);
16799
+ }
16800
+ const r = (c & 0xff0000) >> 16;
16801
+ const g = (c & 0x00ff00) >> 8;
16802
+ const b = c & 0x0000ff;
16803
+ return "rgb(".concat(r, ",").concat(g, ",").concat(b, ")");
16804
+ }
16805
+
16806
+ /**
16807
+ *
16808
+ * @private
16809
+ * @param c
16810
+ * @param a
16811
+ * @returns {string} The color rgb format.
16812
+ */
16813
+ static toRGBA(c, a) {
16814
+ if (c instanceof Color) {
16815
+ return "rgba(".concat([c._r, c._g, c._b, typeof a !== 'undefined' ? a : c._a].join(','), ")");
16816
+ }
16817
+ if (typeof c === 'string') {
16818
+ c = Color.toNumber(c);
16819
+ }
16820
+ const r = (c & 0xff0000) >> 16;
16821
+ const g = (c & 0x00ff00) >> 8;
16822
+ const b = c & 0x0000ff;
16823
+ return "rgba(".concat(r, ",").concat(g, ",").concat(b, ",").concat(typeof a !== 'undefined' ? a : c._a, ")");
16824
+ }
16825
+
16826
+ /**
16827
+ *
16828
+ * @private
16829
+ * @param {Color|string} c
16830
+ * @returns {string} The color in hexadecimal space.
16831
+ */
16832
+ static toHex(c) {
16833
+ let r;
16834
+ let g;
16835
+ let b;
16836
+ if (c instanceof Color) {
16837
+ r = c._r.toString(16);
16838
+ g = c._g.toString(16);
16839
+ b = c._b.toString(16);
16840
+ if (r.length === 1) {
16841
+ r = "0".concat(r);
16842
+ }
16843
+ if (g.length === 1) {
16844
+ g = "0".concat(g);
16845
+ }
16846
+ if (b.length === 1) {
16847
+ b = "0".concat(b);
16848
+ }
16849
+ return "#".concat([r, g, b].join(''));
16850
+ }
16851
+ if (typeof c === 'string') {
16852
+ c = Color.toNumber(c);
16853
+ }
16854
+ r = ((c & 0xff0000) >> 16).toString(16);
16855
+ g = ((c & 0x00ff00) >> 8).toString(16);
16856
+ b = (c & 0x0000ff).toString(16);
16857
+ if (r.length === 1) {
16858
+ r = "0".concat(r);
16859
+ }
16860
+ if (g.length === 1) {
16861
+ g = "0".concat(g);
16862
+ }
16863
+ if (b.length === 1) {
16864
+ b = "0".concat(b);
16865
+ }
16866
+ return "#".concat(r).concat(g).concat(b);
16867
+ }
16868
+
16869
+ /**
16870
+ * Return the color in hsl space using "bi-hexcone" model for lightness
16871
+ * @private
16872
+ * @param {Color|string} c
16873
+ * @param {boolean} luma - Whether to use luma calculation
16874
+ * @returns {string} The color in hsl space.
16875
+ */
16876
+ static toHSL(c, luma) {
16877
+ let h = 0;
16878
+ let s;
16879
+ let l;
16880
+ let ch;
16881
+ if (typeof c === 'string') {
16882
+ c = new Color(c);
16883
+ }
16884
+
16885
+ // red, green, blue, hue, saturation, lightness/luma, max, min, chroma
16886
+ const r = c._r / 255;
16887
+ const g = c._g / 255;
16888
+ const b = c._b / 255;
16889
+ const max = Math.max(r, g, b);
16890
+ const min = Math.min(r, g, b);
16891
+ if (luma) {
16892
+ // Y'709 http://en.wikipedia.org/wiki/Rec._709
16893
+ // Y′709 = 0.21R + 0.72G + 0.07B
16894
+ l = 0.21 * r + 0.72 * g + 0.07 * b;
16895
+ } else {
16896
+ l = (max + min) / 2;
16897
+ }
16898
+ if (max === min) {
16899
+ // greyscale
16900
+ s = 0;
16901
+ h = 0;
16902
+ } else {
16903
+ ch = max - min;
16904
+ s = l > 0.5 ? ch / (2 - max - min) : ch / (max + min);
16905
+ switch (max) {
16906
+ case r:
16907
+ h = (g - b) / ch + (g < b ? 6 : 0);
16908
+ break;
16909
+ case g:
16910
+ h = (b - r) / ch + 2;
16911
+ break;
16912
+ case b:
16913
+ h = (r - g) / ch + 4;
16914
+ break;
16915
+ }
16916
+ h /= 6;
16917
+ }
16918
+ return "hsl(".concat(h * 360, ",").concat(s * 100, ",").concat(l * 100, ")");
16919
+ }
16920
+
16921
+ /**
16922
+ * Return the color in hsla space using "bi-hexcone" model for lightness
16923
+ * @private
16924
+ * @param {Color|string} c
16925
+ * @param {boolean} luma - Whether to use luma calculation
16926
+ * @returns {string} The color in hsla space.
16927
+ */
16928
+ static toHSLA(c, luma) {
16929
+ let h = 0;
16930
+ let s;
16931
+ let l;
16932
+ let ch;
16933
+ if (typeof c === 'string') {
16934
+ c = new Color(c);
16935
+ }
16936
+
16937
+ // red, green, blue, hue, saturation, lightness/luma, max, min, chroma
16938
+ const r = c._r / 255;
16939
+ const g = c._g / 255;
16940
+ const b = c._b / 255;
16941
+ const a = c._a;
16942
+ const max = Math.max(r, g, b);
16943
+ const min = Math.min(r, g, b);
16944
+ if (luma) {
16945
+ // Y'709 http://en.wikipedia.org/wiki/Rec._709
16946
+ // Y′709 = 0.21R + 0.72G + 0.07B
16947
+ l = 0.21 * r + 0.72 * g + 0.07 * b;
16948
+ } else {
16949
+ l = (max + min) / 2;
16950
+ }
16951
+ if (max === min) {
16952
+ // greyscale
16953
+ s = 0;
16954
+ h = 0;
16955
+ } else {
16956
+ ch = max - min;
16957
+ s = l > 0.5 ? ch / (2 - max - min) : ch / (max + min);
16958
+ switch (max) {
16959
+ case r:
16960
+ h = (g - b) / ch + (g < b ? 6 : 0);
16961
+ break;
16962
+ case g:
16963
+ h = (b - r) / ch + 2;
16964
+ break;
16965
+ case b:
16966
+ h = (r - g) / ch + 4;
16967
+ break;
16968
+ }
16969
+ h /= 6;
16970
+ }
16971
+ return "hsla(".concat(h * 360, ",").concat(s * 100, ",").concat(l * 100, ",").concat(a, ")");
16972
+ }
16973
+
16974
+ /**
16975
+ * Return the color components in hsv space using "hexcone" model for value (lightness)
16976
+ * @private
16977
+ * @param {Color|string} c
16978
+ * @returns {object} The color components in hsv space {h:0-360, s:0-100, v:0-100}
16979
+ */
16980
+ static toHSVComponents(c) {
16981
+ let h = 0;
16982
+ let s;
16983
+ let ch;
16984
+ if (typeof c === 'string') {
16985
+ c = new Color(c);
16986
+ }
16987
+
16988
+ // red, green, blue, hue, saturation, value/luma, max, min, chroma
16989
+ const r = c._r / 255;
16990
+ const g = c._g / 255;
16991
+ const b = c._b / 255;
16992
+ const max = Math.max(r, g, b);
16993
+ const min = Math.min(r, g, b);
16994
+ const v = max;
16995
+ if (max === min) {
16996
+ // greyscale
16997
+ s = 0;
16998
+ h = 0;
16999
+ } else {
17000
+ ch = max - min;
17001
+ s = ch === 0 ? 0 : ch / v;
17002
+ switch (max) {
17003
+ case r:
17004
+ h = (g - b) / ch + (g < b ? 6 : 0);
17005
+ break;
17006
+ case g:
17007
+ h = (b - r) / ch + 2;
17008
+ break;
17009
+ case b:
17010
+ h = (r - g) / ch + 4;
17011
+ break;
17012
+ }
17013
+ h /= 6;
17014
+ }
17015
+ return {
17016
+ h: h * 360 % 360,
17017
+ s: s * 100,
17018
+ v: v * 100
17019
+ };
17020
+ }
17021
+
17022
+ /**
17023
+ * Returns an number representation of the color
17024
+ * @private
17025
+ * @param {Color|string} c
17026
+ * @returns {Number} Unsigned integer in the range 0-16 777 216
17027
+ */
17028
+ static toNumber() {
17029
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
17030
+ args[_key2] = arguments[_key2];
17031
+ }
17032
+ if (args.length === 1 && args[0] instanceof Color) {
17033
+ return (args[0]._r << 16) + (args[0]._g << 8) + args[0]._b;
17034
+ }
17035
+ let r = 0;
17036
+ let g = 0;
17037
+ let b = 0;
17038
+ let matches;
17039
+ let colorString;
17040
+ if (args.length === 1) {
17041
+ if (typeof args[0] === 'string') {
17042
+ colorString = args[0];
17043
+ if (matches = /^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/i.exec(colorString)) {
17044
+ r = parseInt(matches[1], 10);
17045
+ g = parseInt(matches[2], 10);
17046
+ b = parseInt(matches[3], 10);
17047
+ } else if (matches = /^#([A-f0-9]{2})([A-f0-9]{2})([A-f0-9]{2})$/i.exec(colorString)) {
17048
+ r = parseInt(matches[1], 16);
17049
+ g = parseInt(matches[2], 16);
17050
+ b = parseInt(matches[3], 16);
17051
+ } else if (matches = /^#([A-f0-9])([A-f0-9])([A-f0-9])$/i.exec(colorString)) {
17052
+ r = parseInt(matches[1] + matches[1], 16);
17053
+ g = parseInt(matches[2] + matches[2], 16);
17054
+ b = parseInt(matches[3] + matches[3], 16);
17055
+ }
17056
+ }
17057
+ }
17058
+ return (r << 16) + (g << 8) + b;
17059
+ }
17060
+ static blend(c1, c2, t) {
17061
+ c1 = Color.toNumber(c1);
17062
+ c2 = Color.toNumber(c2);
17063
+ const r1 = (c1 & 0xff0000) >> 16;
17064
+ const g1 = (c1 & 0x00ff00) >> 8;
17065
+ const b1 = c1 & 0x0000ff;
17066
+ const r2 = (c2 & 0xff0000) >> 16;
17067
+ const g2 = (c2 & 0x00ff00) >> 8;
17068
+ const b2 = c2 & 0x0000ff;
17069
+ const r = r1 + (r2 - r1) * t;
17070
+ const g = g1 + (g2 - g1) * t;
17071
+ const b = b1 + (b2 - b1) * t;
17072
+ return (r << 16) + (g << 8) + b;
17073
+ }
17074
+ static getBlend(c1, c2, t) {
17075
+ const r = c1._r + (c2._r - c1._r) * t;
17076
+ const g = c1._g + (c2._g - c1._g) * t;
17077
+ const b = c1._b + (c2._b - c1._b) * t;
17078
+ const a = c1._a + (c2._a - c1._a) * t;
17079
+ return new Color(r, g, b, a);
17080
+ }
17081
+ static isCSSColor(color) {
17082
+ if (arguments.length > 1 || typeof color !== 'string') {
17083
+ return false;
17084
+ }
17085
+ return rgb.test(color) || rgba.test(color) || hex.test(color) || hexShort.test(color) || hsl.test(color) || hsla.test(color) || colorStruct[color.toLowerCase()];
17086
+ }
17087
+ static getBestContrast(color, cl, cd) {
17088
+ const lum = color.getLuminance();
17089
+ return Math.abs(lum - cl.getLuminance()) > Math.abs(lum - cd.getLuminance()) ? cl : cd;
17090
+ }
17091
+ static getContrast(color1, color2) {
17092
+ if (!color1 || !color2) {
17093
+ return undefined;
17094
+ }
17095
+ const l1 = color1.getLuminance() / 100;
17096
+ const l2 = color2.getLuminance() / 100;
17097
+ if (l1 > l2) {
17098
+ return (l1 + 0.05) / (l2 + 0.05);
17099
+ }
17100
+ return (l2 + 0.05) / (l1 + 0.05);
17101
+ }
17102
+ static isDark() {
17103
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
17104
+ args[_key3] = arguments[_key3];
17105
+ }
17106
+ const C = new Color(...args);
17107
+ return C.isDark(...args);
17108
+ }
17109
+ static useDarkLabel(areaColor, bgIsDark) {
17110
+ return areaColor._a > 0.5 ? !areaColor.isDark() : !bgIsDark;
17111
+ }
17112
+ }
17113
+
15542
17114
  const LIGHT = '#FFF';
15543
17115
  const DARK = '#000';
17116
+ const CONTRAST_THRESHOLD = 1.5;
17117
+ const LIGHT_PREFERRED_THRESHOLD = 3;
17118
+ const getContrast = (desired, background) => {
17119
+ let contrast = false;
17120
+ const des = new Color(desired);
17121
+ const bg = new Color(background);
17122
+ if (bg.isInvalid() || des.isInvalid() || bg.getAlpha() < 1 || des.getAlpha() < 1) {
17123
+ return undefined;
17124
+ }
17125
+ try {
17126
+ contrast = Color.getContrast(des, bg);
17127
+ } catch (err) {
17128
+ contrast = undefined;
17129
+ }
17130
+ return contrast;
17131
+ };
15544
17132
  function getContrastingColor(backgroundColor) {
15545
17133
  let desiredTextColor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
15546
17134
  let dark = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DARK;
15547
17135
  let light = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : LIGHT;
15548
- const CONTRAST_THRESHOLD = 3.0;
17136
+ const lightColor = new Color(light);
17137
+ const bg = new Color(backgroundColor);
17138
+ const des = new Color(desiredTextColor);
17139
+ if (bg.isInvalid() || des.isInvalid() || bg.getAlpha() < 1 || des.getAlpha() < 1) {
17140
+ return desiredTextColor;
17141
+ }
17142
+
17143
+ // Always prioritise light color if it gives better contrast than desired color's.
17144
+ const lightColorContrast = getContrast(lightColor, bg);
17145
+ const desiredColorContrast = getContrast(des, bg);
17146
+ const useLightColor = lightColorContrast > desiredColorContrast || lightColorContrast > LIGHT_PREFERRED_THRESHOLD;
15549
17147
  let contrastingColor;
15550
- if (desiredTextColor && getContrastRatio(desiredTextColor, backgroundColor) > CONTRAST_THRESHOLD) {
17148
+ if (desiredTextColor && desiredColorContrast > CONTRAST_THRESHOLD && !useLightColor) {
15551
17149
  contrastingColor = desiredTextColor;
15552
17150
  } else {
15553
- contrastingColor = getContrastRatio(light, backgroundColor) > CONTRAST_THRESHOLD ? light : dark;
17151
+ contrastingColor = useLightColor ? light : dark;
15554
17152
  }
15555
17153
  return contrastingColor;
15556
17154
  }
@@ -15569,7 +17167,8 @@ function getOverridesAsObject() {
15569
17167
  }
15570
17168
  function getSelectionColors(theme, getListboxStyle, overrides) {
15571
17169
  var _overrides$theme, _theme$palette, _overrides$theme$cont, _overrides$theme2, _overrides$selections, _selectionColors$sele, _theme$palette2, _selectionColors$alte, _theme$palette3, _selectionColors$excl, _theme$palette4, _selectionColors$sele2, _theme$palette5, _selectionColors$poss, _theme$palette6, _theme$palette7, _theme$palette8, _theme$palette9, _theme$palette10, _theme$palette11;
15572
- const desiredTextColor = ((_overrides$theme = overrides.theme) === null || _overrides$theme === void 0 || (_overrides$theme = _overrides$theme.content) === null || _overrides$theme === void 0 || (_overrides$theme = _overrides$theme.fontColor) === null || _overrides$theme === void 0 ? void 0 : _overrides$theme.color) || getListboxStyle('content', 'color') || ((_theme$palette = theme.palette) === null || _theme$palette === void 0 ? void 0 : _theme$palette.text.primary);
17170
+ const componentContentTextColor = (_overrides$theme = overrides.theme) === null || _overrides$theme === void 0 || (_overrides$theme = _overrides$theme.content) === null || _overrides$theme === void 0 || (_overrides$theme = _overrides$theme.fontColor) === null || _overrides$theme === void 0 ? void 0 : _overrides$theme.color;
17171
+ const desiredTextColor = componentContentTextColor || getListboxStyle('content', 'color') || ((_theme$palette = theme.palette) === null || _theme$palette === void 0 ? void 0 : _theme$palette.text.primary);
15573
17172
  const useContrastTextColor = (_overrides$theme$cont = (_overrides$theme2 = overrides.theme) === null || _overrides$theme2 === void 0 || (_overrides$theme2 = _overrides$theme2.content) === null || _overrides$theme2 === void 0 ? void 0 : _overrides$theme2.useContrastColor) !== null && _overrides$theme$cont !== void 0 ? _overrides$theme$cont : true;
15574
17173
 
15575
17174
  // Background colors
@@ -15581,7 +17180,7 @@ function getSelectionColors(theme, getListboxStyle, overrides) {
15581
17180
  const possible = ((_selectionColors$poss = selectionColors.possible) === null || _selectionColors$poss === void 0 ? void 0 : _selectionColors$poss.color) || getListboxStyle('', 'backgroundColor') || ((_theme$palette6 = theme.palette) === null || _theme$palette6 === void 0 ? void 0 : _theme$palette6.selected.possible) || '#FFFFFF';
15582
17181
 
15583
17182
  // Font colors
15584
- let selectedContrast = desiredTextColor || ((_theme$palette7 = theme.palette) === null || _theme$palette7 === void 0 ? void 0 : _theme$palette7.selected.main);
17183
+ let selectedContrast = desiredTextColor || ((_theme$palette7 = theme.palette) === null || _theme$palette7 === void 0 ? void 0 : _theme$palette7.selected.selectedContrastText);
15585
17184
  let alternativeContrast = desiredTextColor || ((_theme$palette8 = theme.palette) === null || _theme$palette8 === void 0 ? void 0 : _theme$palette8.selected.alternativeContrastText);
15586
17185
  let excludedContrast = desiredTextColor || ((_theme$palette9 = theme.palette) === null || _theme$palette9 === void 0 ? void 0 : _theme$palette9.selected.excludedContrastText);
15587
17186
  let selectedExcludedContrast = desiredTextColor || ((_theme$palette10 = theme.palette) === null || _theme$palette10 === void 0 ? void 0 : _theme$palette10.selected.selectedExcludedContrastText);