@react-stately/color 3.0.0-alpha.0 → 3.0.0-beta.10

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/module.js CHANGED
@@ -1,928 +1,1125 @@
1
- import { useState, useMemo, useEffect } from "react";
2
- import { useControlledState } from "@react-stately/utils";
3
- import { useSliderState } from "@react-stately/slider";
4
- import _babelRuntimeHelpersEsmObjectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
- import _babelRuntimeHelpersEsmExtends from "@babel/runtime/helpers/esm/extends";
6
- import { NumberFormatter } from "@internationalized/number";
7
- import { MessageDictionary } from "@internationalized/message";
8
- import { clamp } from "@react-aria/utils";
9
- import _babelRuntimeHelpersEsmInteropRequireDefault from "@babel/runtime/helpers/esm/interopRequireDefault";
10
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/ar-AE.json
11
- var $b2cd9264f0b716f5f6077988ebeb8d5$exports = {};
12
- $b2cd9264f0b716f5f6077988ebeb8d5$exports = JSON.parse("{\"hue\":\"تدرج اللون\",\"saturation\":\"‏‏الإشباع\",\"lightness\":\"الإضاءة\",\"brightness\":\"والقيمة\",\"red\":\"أحمر\",\"green\":\"أخضر\",\"blue\":\"أزرق\",\"alpha\":\"أولي\"}");
13
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/bg-BG.json
14
- var $cdad99d1d4c78a097fa29797f20e3ec$exports = {};
15
- $cdad99d1d4c78a097fa29797f20e3ec$exports = JSON.parse("{\"hue\":\"Нюанс\",\"saturation\":\"Наситеност\",\"lightness\":\"Осветеност\",\"brightness\":\"Яркост\",\"red\":\"Червено\",\"green\":\"Зелено\",\"blue\":\"Синьо\",\"alpha\":\"Алфа\"}");
16
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/cs-CZ.json
17
- var $f9cd6479f5235258a90316a784221e3b$exports = {};
18
- $f9cd6479f5235258a90316a784221e3b$exports = JSON.parse("{\"hue\":\"Odstín\",\"saturation\":\"Sytost\",\"lightness\":\"Světlost\",\"brightness\":\"Jas\",\"red\":\"Červená\",\"green\":\"Zelená\",\"blue\":\"Modrá\",\"alpha\":\"Alfa\"}");
19
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/da-DK.json
20
- var $d9a48d423b3cf4f2d44abe3c990b$exports = {};
21
- $d9a48d423b3cf4f2d44abe3c990b$exports = JSON.parse("{\"hue\":\"Nuance\",\"saturation\":\"Mætning\",\"lightness\":\"Lysstyrke\",\"brightness\":\"Værdi\",\"red\":\"Rød\",\"green\":\"Grøn\",\"blue\":\"Blå\",\"alpha\":\"Alfa\"}");
22
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/de-DE.json
23
- var $c98aec81a0d1f104658866432f$exports = {};
24
- $c98aec81a0d1f104658866432f$exports = JSON.parse("{\"hue\":\"Farbton\",\"saturation\":\"Sättigung\",\"lightness\":\"Leuchtkraft\",\"brightness\":\"Helligkeit\",\"red\":\"Rot\",\"green\":\"Grün\",\"blue\":\"Blau\",\"alpha\":\"Alpha\"}");
25
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/el-GR.json
26
- var $d448bd8618b5533ccc4a8cc128b5f05a$exports = {};
27
- $d448bd8618b5533ccc4a8cc128b5f05a$exports = JSON.parse("{\"hue\":\"Απόχρωση\",\"saturation\":\"Κορεσμού\",\"lightness\":\"Φωτεινότητα\",\"brightness\":\"Τιμή\",\"red\":\"Κόκκινο\",\"green\":\"Πράσινο\",\"blue\":\"Μπλε\",\"alpha\":\"Αλφα\"}");
28
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/en-US.json
29
- var $eaffba4fd6d2bfdbccc895c90029fc1b$exports = {};
30
- $eaffba4fd6d2bfdbccc895c90029fc1b$exports = JSON.parse("{\"hue\":\"Hue\",\"saturation\":\"Saturation\",\"lightness\":\"Lightness\",\"brightness\":\"Brightness\",\"red\":\"Red\",\"green\":\"Green\",\"blue\":\"Blue\",\"alpha\":\"Alpha\"}");
31
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/es-ES.json
32
- var $ba4a9d986c77d6b793c00d1e2392bade$exports = {};
33
- $ba4a9d986c77d6b793c00d1e2392bade$exports = JSON.parse("{\"hue\":\"Matiz\",\"saturation\":\"Saturación\",\"lightness\":\"Claridad\",\"brightness\":\"Brillo\",\"red\":\"Rojo\",\"green\":\"Verde\",\"blue\":\"Azul\",\"alpha\":\"Alfa\"}");
34
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/et-EE.json
35
- var $eea6c1402487c18ea84576423346b15$exports = {};
36
- $eea6c1402487c18ea84576423346b15$exports = JSON.parse("{\"hue\":\"Toon\",\"saturation\":\"Küllastus\",\"lightness\":\"Helendus\",\"brightness\":\"Väärtus\",\"red\":\"Punane\",\"green\":\"Roheline\",\"blue\":\"Sinine\",\"alpha\":\"Alfa\"}");
37
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/fi-FI.json
38
- var $a74db7b52c67c25bc7440950d823b$exports = {};
39
- $a74db7b52c67c25bc7440950d823b$exports = JSON.parse("{\"hue\":\"Värisävy\",\"saturation\":\"Kylläisyys\",\"lightness\":\"Valoisuus\",\"brightness\":\"Kirkkaus\",\"red\":\"Punainen\",\"green\":\"Vihreä\",\"blue\":\"Sininen\",\"alpha\":\"Alpha\"}");
40
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/fr-FR.json
41
- var $fe5ec5953266844aed13956bf74a814$exports = {};
42
- $fe5ec5953266844aed13956bf74a814$exports = JSON.parse("{\"hue\":\"Teinte\",\"saturation\":\"Saturation\",\"lightness\":\"Clarté\",\"brightness\":\"Luminosité\",\"red\":\"Rouge\",\"green\":\"Vert\",\"blue\":\"Bleu\",\"alpha\":\"Alpha\"}");
43
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/he-IL.json
44
- var $c8b18e3105ca2bd3791c8ba8d5c080e9$exports = {};
45
- $c8b18e3105ca2bd3791c8ba8d5c080e9$exports = JSON.parse("{\"hue\":\"גוון\",\"saturation\":\"רוויה\",\"lightness\":\"‏‏בהירות\",\"brightness\":\"וערך\",\"red\":\"אדום\",\"green\":\"ירוק\",\"blue\":\"כחול\",\"alpha\":\"אלפא\"}");
46
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/hr-HR.json
47
- var $b91aba8d136e0d182ab14d$exports = {};
48
- $b91aba8d136e0d182ab14d$exports = JSON.parse("{\"hue\":\"Nijansa\",\"saturation\":\"Zasićenje\",\"lightness\":\"Svjetlina\",\"brightness\":\"Vrijednost\",\"red\":\"Crvena\",\"green\":\"Zelena\",\"blue\":\"Plava\",\"alpha\":\"Alfa\"}");
49
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/hu-HU.json
50
- var $e4a95e1cff41940abe4abd86d$exports = {};
51
- $e4a95e1cff41940abe4abd86d$exports = JSON.parse("{\"hue\":\"Árnyalat\",\"saturation\":\"Telítettség\",\"lightness\":\"Fényerő\",\"brightness\":\"Értéke\",\"red\":\"Vörös\",\"green\":\"Zöld\",\"blue\":\"Kék\",\"alpha\":\"Alfa\"}");
52
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/it-IT.json
53
- var $cc9b471008e063931f187b9f17ea84$exports = {};
54
- $cc9b471008e063931f187b9f17ea84$exports = JSON.parse("{\"hue\":\"Tonalità\",\"saturation\":\"Saturazione\",\"lightness\":\"Luminosità\",\"brightness\":\"Lucentezza\",\"red\":\"Rosso\",\"green\":\"Verde\",\"blue\":\"Blu\",\"alpha\":\"Alfa\"}");
55
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/ja-JP.json
56
- var $b3ba4812949b99f64ae9c5343cef182$exports = {};
57
- $b3ba4812949b99f64ae9c5343cef182$exports = JSON.parse("{\"hue\":\"色合い\",\"saturation\":\"鮮やかさ\",\"lightness\":\"輝度\",\"brightness\":\"明るさ\",\"red\":\"赤\",\"green\":\"緑\",\"blue\":\"青\",\"alpha\":\"アルファ\"}");
58
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/ko-KR.json
59
- var $a0635388d1896feed826078018e61cc3$exports = {};
60
- $a0635388d1896feed826078018e61cc3$exports = JSON.parse("{\"hue\":\"색상\",\"saturation\":\"채도\",\"lightness\":\"명도\",\"brightness\":\"값\",\"red\":\"빨강\",\"green\":\"녹색\",\"blue\":\"파랑\",\"alpha\":\"알파\"}");
61
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/lt-LT.json
62
- var $b723c6ed4b6433c464915f350d7b37d$exports = {};
63
- $b723c6ed4b6433c464915f350d7b37d$exports = JSON.parse("{\"hue\":\"Atspalvis\",\"saturation\":\"Grynis\",\"lightness\":\"Skaistis\",\"brightness\":\"Ryškumas\",\"red\":\"Raudona\",\"green\":\"Žalia\",\"blue\":\"Mėlyna\",\"alpha\":\"Alfa\"}");
64
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/lv-LV.json
65
- var $de160269d06dd11d79a46ad67519$exports = {};
66
- $de160269d06dd11d79a46ad67519$exports = JSON.parse("{\"hue\":\"Nokrāsa\",\"saturation\":\"Piesātinājums\",\"lightness\":\"Vieglums\",\"brightness\":\"Spilgtums\",\"red\":\"Sarkana\",\"green\":\"Zaļa\",\"blue\":\"Zila\",\"alpha\":\"Alfa\"}");
67
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/nb-NO.json
68
- var $df7f70de921632c10878ba1ec274be$exports = {};
69
- $df7f70de921632c10878ba1ec274be$exports = JSON.parse("{\"hue\":\"Fargetone\",\"saturation\":\"Metning\",\"lightness\":\"Lyshet\",\"brightness\":\"Lysstyrke\",\"red\":\"Rød\",\"green\":\"Grønn\",\"blue\":\"Blå\",\"alpha\":\"Alfa\"}");
70
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/nl-NL.json
71
- var $f815b3f638134acc513a2b0c77d8dce0$exports = {};
72
- $f815b3f638134acc513a2b0c77d8dce0$exports = JSON.parse("{\"hue\":\"Tint\",\"saturation\":\"Verzadiging\",\"lightness\":\"Lichtheid\",\"brightness\":\"Helderheid\",\"red\":\"Rood\",\"green\":\"Groen\",\"blue\":\"Blauw\",\"alpha\":\"Alfa\"}");
73
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/pl-PL.json
74
- var $aee27b855fc838cae4ebd8dfbbb95e33$exports = {};
75
- $aee27b855fc838cae4ebd8dfbbb95e33$exports = JSON.parse("{\"hue\":\"Odcień\",\"saturation\":\"Nasycenie\",\"lightness\":\"Jasność\",\"brightness\":\"Jasność\",\"red\":\"Czerwony\",\"green\":\"Zielony\",\"blue\":\"Niebieski\",\"alpha\":\"Alfa\"}");
76
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/pt-BR.json
77
- var $b361c9c44348e09361feb2ebb7e33$exports = {};
78
- $b361c9c44348e09361feb2ebb7e33$exports = JSON.parse("{\"hue\":\"Matiz\",\"saturation\":\"Saturação\",\"lightness\":\"Luminosidade\",\"brightness\":\"Brilho\",\"red\":\"Vermelho\",\"green\":\"Verde\",\"blue\":\"Azul\",\"alpha\":\"Alfa\"}");
79
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/ro-RO.json
80
- var $b8d88afd8f44c22874b7fe6f22d03d1$exports = {};
81
- $b8d88afd8f44c22874b7fe6f22d03d1$exports = JSON.parse("{\"hue\":\"Nuanță\",\"saturation\":\"Saturație\",\"lightness\":\"Luminozitate\",\"brightness\":\"Valoare\",\"red\":\"Roșu\",\"green\":\"Verde\",\"blue\":\"Albastru\",\"alpha\":\"Alfa\"}");
82
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/ru-RU.json
83
- var $c188a27cabc6e80207754236eb1fec$exports = {};
84
- $c188a27cabc6e80207754236eb1fec$exports = JSON.parse("{\"hue\":\"Оттенок\",\"saturation\":\"Насыщенность\",\"lightness\":\"Освещенность\",\"brightness\":\"Яркость\",\"red\":\"Красный\",\"green\":\"Зеленый\",\"blue\":\"Синий\",\"alpha\":\"Альфа\"}");
85
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/sk-SK.json
86
- var $c40950a3513f1cbbb70121cc402a156f$exports = {};
87
- $c40950a3513f1cbbb70121cc402a156f$exports = JSON.parse("{\"hue\":\"Odtieň\",\"saturation\":\"Sýtosť\",\"lightness\":\"Svetlosť\",\"brightness\":\"Jas\",\"red\":\"Červená\",\"green\":\"Zelená\",\"blue\":\"Modrá\",\"alpha\":\"Alfa\"}");
88
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/sl-SI.json
89
- var $d6ba833b474990359bcaf23ae4062a5a$exports = {};
90
- $d6ba833b474990359bcaf23ae4062a5a$exports = JSON.parse("{\"hue\":\"Odtenek\",\"saturation\":\"Nasičenost\",\"lightness\":\"Svetilnost\",\"brightness\":\"Svetlost\",\"red\":\"Rdeča\",\"green\":\"Zelena\",\"blue\":\"Modra\",\"alpha\":\"Alfa\"}");
91
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/sr-SP.json
92
- var $b540c0afbb8586393249300b9d058750$exports = {};
93
- $b540c0afbb8586393249300b9d058750$exports = JSON.parse("{\"hue\":\"Нијанса\",\"saturation\":\"Засићење\",\"lightness\":\"Осветљење\",\"brightness\":\"Светлина\",\"red\":\"Црвена\",\"green\":\"Зелена\",\"blue\":\"Плава\",\"alpha\":\"Алфа\"}");
94
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/sv-SE.json
95
- var $f6f532bfe6495593ae520210aedcf6ee$exports = {};
96
- $f6f532bfe6495593ae520210aedcf6ee$exports = JSON.parse("{\"hue\":\"Nyans\",\"saturation\":\"Mättnad\",\"lightness\":\"Lätthet\",\"brightness\":\"Ljusstyrka\",\"red\":\"Röd\",\"green\":\"Grön\",\"blue\":\"Blå\",\"alpha\":\"Alfa\"}");
97
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/tr-TR.json
98
- var $b002567dfed5d0563037184fe514$exports = {};
99
- $b002567dfed5d0563037184fe514$exports = JSON.parse("{\"hue\":\"Ton\",\"saturation\":\"Doygunluk\",\"lightness\":\"Hafiflik\",\"brightness\":\"Parlaklık\",\"red\":\"Kırmızı\",\"green\":\"Yeşil\",\"blue\":\"Mavi\",\"alpha\":\"Alfa\"}");
100
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/uk-UA.json
101
- var $e3caa848bb758a1d3e6ca0f18ece7f4$exports = {};
102
- $e3caa848bb758a1d3e6ca0f18ece7f4$exports = JSON.parse("{\"hue\":\"Відтінок\",\"saturation\":\"Насиченість\",\"lightness\":\"Яскравість\",\"brightness\":\"Інтенсивність\",\"red\":\"Червоний\",\"green\":\"Зелений\",\"blue\":\"Синій\",\"alpha\":\"Альфа\"}");
103
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/zh-CN.json
104
- var $d24ec9fef3a39ede5b3f154080d42$exports = {};
105
- $d24ec9fef3a39ede5b3f154080d42$exports = JSON.parse("{\"hue\":\"色调\",\"saturation\":\"饱和度\",\"lightness\":\"光度\",\"brightness\":\"Brightness\",\"red\":\"红\",\"green\":\"绿\",\"blue\":\"蓝\",\"alpha\":\"Alpha\"}");
106
- // ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/zh-TW.json
107
- var $a1e968ea81ccd941358c63d78a093ff0$exports = {};
108
- $a1e968ea81ccd941358c63d78a093ff0$exports = JSON.parse("{\"hue\":\"色調\",\"saturation\":\"飽和\",\"lightness\":\"光度\",\"brightness\":\"亮度\",\"red\":\"紅\",\"green\":\"綠\",\"blue\":\"藍\",\"alpha\":\"Alpha\"}");
109
- // @ts-ignore
110
- const $db5f3c2f048bca5be854d051d3f2729$var$intlMessages = {
111
- "ar-AE": _babelRuntimeHelpersEsmInteropRequireDefault($b2cd9264f0b716f5f6077988ebeb8d5$exports).default,
112
- "bg-BG": _babelRuntimeHelpersEsmInteropRequireDefault($cdad99d1d4c78a097fa29797f20e3ec$exports).default,
113
- "cs-CZ": _babelRuntimeHelpersEsmInteropRequireDefault($f9cd6479f5235258a90316a784221e3b$exports).default,
114
- "da-DK": _babelRuntimeHelpersEsmInteropRequireDefault($d9a48d423b3cf4f2d44abe3c990b$exports).default,
115
- "de-DE": _babelRuntimeHelpersEsmInteropRequireDefault($c98aec81a0d1f104658866432f$exports).default,
116
- "el-GR": _babelRuntimeHelpersEsmInteropRequireDefault($d448bd8618b5533ccc4a8cc128b5f05a$exports).default,
117
- "en-US": _babelRuntimeHelpersEsmInteropRequireDefault($eaffba4fd6d2bfdbccc895c90029fc1b$exports).default,
118
- "es-ES": _babelRuntimeHelpersEsmInteropRequireDefault($ba4a9d986c77d6b793c00d1e2392bade$exports).default,
119
- "et-EE": _babelRuntimeHelpersEsmInteropRequireDefault($eea6c1402487c18ea84576423346b15$exports).default,
120
- "fi-FI": _babelRuntimeHelpersEsmInteropRequireDefault($a74db7b52c67c25bc7440950d823b$exports).default,
121
- "fr-FR": _babelRuntimeHelpersEsmInteropRequireDefault($fe5ec5953266844aed13956bf74a814$exports).default,
122
- "he-IL": _babelRuntimeHelpersEsmInteropRequireDefault($c8b18e3105ca2bd3791c8ba8d5c080e9$exports).default,
123
- "hr-HR": _babelRuntimeHelpersEsmInteropRequireDefault($b91aba8d136e0d182ab14d$exports).default,
124
- "hu-HU": _babelRuntimeHelpersEsmInteropRequireDefault($e4a95e1cff41940abe4abd86d$exports).default,
125
- "it-IT": _babelRuntimeHelpersEsmInteropRequireDefault($cc9b471008e063931f187b9f17ea84$exports).default,
126
- "ja-JP": _babelRuntimeHelpersEsmInteropRequireDefault($b3ba4812949b99f64ae9c5343cef182$exports).default,
127
- "ko-KR": _babelRuntimeHelpersEsmInteropRequireDefault($a0635388d1896feed826078018e61cc3$exports).default,
128
- "lt-LT": _babelRuntimeHelpersEsmInteropRequireDefault($b723c6ed4b6433c464915f350d7b37d$exports).default,
129
- "lv-LV": _babelRuntimeHelpersEsmInteropRequireDefault($de160269d06dd11d79a46ad67519$exports).default,
130
- "nb-NO": _babelRuntimeHelpersEsmInteropRequireDefault($df7f70de921632c10878ba1ec274be$exports).default,
131
- "nl-NL": _babelRuntimeHelpersEsmInteropRequireDefault($f815b3f638134acc513a2b0c77d8dce0$exports).default,
132
- "pl-PL": _babelRuntimeHelpersEsmInteropRequireDefault($aee27b855fc838cae4ebd8dfbbb95e33$exports).default,
133
- "pt-BR": _babelRuntimeHelpersEsmInteropRequireDefault($b361c9c44348e09361feb2ebb7e33$exports).default,
134
- "ro-RO": _babelRuntimeHelpersEsmInteropRequireDefault($b8d88afd8f44c22874b7fe6f22d03d1$exports).default,
135
- "ru-RU": _babelRuntimeHelpersEsmInteropRequireDefault($c188a27cabc6e80207754236eb1fec$exports).default,
136
- "sk-SK": _babelRuntimeHelpersEsmInteropRequireDefault($c40950a3513f1cbbb70121cc402a156f$exports).default,
137
- "sl-SI": _babelRuntimeHelpersEsmInteropRequireDefault($d6ba833b474990359bcaf23ae4062a5a$exports).default,
138
- "sr-SP": _babelRuntimeHelpersEsmInteropRequireDefault($b540c0afbb8586393249300b9d058750$exports).default,
139
- "sv-SE": _babelRuntimeHelpersEsmInteropRequireDefault($f6f532bfe6495593ae520210aedcf6ee$exports).default,
140
- "tr-TR": _babelRuntimeHelpersEsmInteropRequireDefault($b002567dfed5d0563037184fe514$exports).default,
141
- "uk-UA": _babelRuntimeHelpersEsmInteropRequireDefault($e3caa848bb758a1d3e6ca0f18ece7f4$exports).default,
142
- "zh-CN": _babelRuntimeHelpersEsmInteropRequireDefault($d24ec9fef3a39ede5b3f154080d42$exports).default,
143
- "zh-TW": _babelRuntimeHelpersEsmInteropRequireDefault($a1e968ea81ccd941358c63d78a093ff0$exports).default
144
- };
145
- const $db5f3c2f048bca5be854d051d3f2729$var$messages = new MessageDictionary($db5f3c2f048bca5be854d051d3f2729$var$intlMessages);
146
- export function parseColor(value) {
147
- let res = $db5f3c2f048bca5be854d051d3f2729$var$RGBColor.parse(value) || $db5f3c2f048bca5be854d051d3f2729$var$HSBColor.parse(value) || $db5f3c2f048bca5be854d051d3f2729$var$HSLColor.parse(value);
148
-
149
- if (res) {
150
- return res;
151
- }
152
-
153
- throw new Error('Invalid color value: ' + value);
1
+ import {clamp as $cBgAy$clamp, toFixedNumber as $cBgAy$toFixedNumber, useControlledState as $cBgAy$useControlledState, snapValueToStep as $cBgAy$snapValueToStep} from "@react-stately/utils";
2
+ import {MessageDictionary as $cBgAy$MessageDictionary} from "@internationalized/message";
3
+ import {NumberFormatter as $cBgAy$NumberFormatter} from "@internationalized/number";
4
+ import {useRef as $cBgAy$useRef, useMemo as $cBgAy$useMemo, useState as $cBgAy$useState} from "react";
5
+ import {useSliderState as $cBgAy$useSliderState} from "@react-stately/slider";
6
+
7
+ function $parcel$interopDefault(a) {
8
+ return a && a.__esModule ? a.default : a;
9
+ }
10
+ function $parcel$export(e, n, v, s) {
11
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
154
12
  }
155
13
 
156
- class $db5f3c2f048bca5be854d051d3f2729$var$Color {
157
- toHexInt() {
158
- return this.toFormat('rgb').toHexInt();
159
- }
14
+ var $7a451c0c6841e6b9$exports = {};
15
+ var $2d805fd52bb48883$exports = {};
16
+ $2d805fd52bb48883$exports = JSON.parse("{\"alpha\":\"ألفا\",\"blue\":\"أزرق\",\"brightness\":\"السطوع\",\"green\":\"أخضر\",\"hue\":\"درجة اللون\",\"lightness\":\"الإضاءة\",\"red\":\"أحمر\",\"saturation\":\"التشبع\"}");
160
17
 
161
- getChannelValue(channel) {
162
- if (channel in this) {
163
- return this[channel];
164
- }
165
18
 
166
- throw new Error('Unsupported color channel: ' + channel);
167
- }
19
+ var $6c28468dc1df643c$exports = {};
20
+ $6c28468dc1df643c$exports = JSON.parse("{\"alpha\":\"Алфа\",\"blue\":\"Синьо\",\"brightness\":\"Яркост\",\"green\":\"Зелено\",\"hue\":\"Оттенък\",\"lightness\":\"Лекота\",\"red\":\"Червено\",\"saturation\":\"Наситеност\"}");
168
21
 
169
- withChannelValue(channel, value) {
170
- if (channel in this) {
171
- let x = this.clone();
172
- x[channel] = value;
173
- return x;
174
- }
175
22
 
176
- throw new Error('Unsupported color channel: ' + channel);
177
- }
23
+ var $807554f8230db0ed$exports = {};
24
+ $807554f8230db0ed$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Modrá\",\"brightness\":\"Jas\",\"green\":\"Zelená\",\"hue\":\"Odstín\",\"lightness\":\"Světlost\",\"red\":\"Červená\",\"saturation\":\"Sytost\"}");
178
25
 
179
- getChannelName(channel, locale) {
180
- return $db5f3c2f048bca5be854d051d3f2729$var$messages.getStringForLocale(channel, locale);
181
- }
182
26
 
183
- }
27
+ var $7097f64386f1761c$exports = {};
28
+ $7097f64386f1761c$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Blå\",\"brightness\":\"Lysstyrke\",\"green\":\"Grøn\",\"hue\":\"Tone\",\"lightness\":\"Lyshed\",\"red\":\"Rød\",\"saturation\":\"Farvemætning\"}");
184
29
 
185
- const $db5f3c2f048bca5be854d051d3f2729$var$HEX_REGEX = /^#(?:([0-9a-f]{3})|([0-9a-f]{6}))$/i; // X = <negative/positive number with/without decimal places>
186
- // before/after a comma, 0 or more whitespaces are allowed
187
- // - rgb(X, X, X)
188
- // - rgba(X, X, X, X)
189
30
 
190
- const $db5f3c2f048bca5be854d051d3f2729$var$RGB_REGEX = /rgb\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?)\)|rgba\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d(.\d+)?)\)/;
31
+ var $bdd847d8beb08799$exports = {};
32
+ $bdd847d8beb08799$exports = JSON.parse("{\"alpha\":\"Alpha\",\"blue\":\"Blau\",\"brightness\":\"Helligkeit\",\"green\":\"Grün\",\"hue\":\"Farbton\",\"lightness\":\"Leuchtkraft\",\"red\":\"Rot\",\"saturation\":\"Sättigung\"}");
191
33
 
192
- class $db5f3c2f048bca5be854d051d3f2729$var$RGBColor extends $db5f3c2f048bca5be854d051d3f2729$var$Color {
193
- constructor(red, green, blue, alpha) {
194
- super();
195
- this.red = red;
196
- this.green = green;
197
- this.blue = blue;
198
- this.alpha = alpha;
199
- }
200
34
 
201
- static parse(value) {
202
- let m;
35
+ var $a53e00b683950971$exports = {};
36
+ $a53e00b683950971$exports = JSON.parse("{\"alpha\":\"Άλφα\",\"blue\":\"Μπλε\",\"brightness\":\"Φωτεινότητα\",\"green\":\"Πράσινο\",\"hue\":\"Τόνος\",\"lightness\":\"Φωτεινότητα\",\"red\":\"Κόκκινο\",\"saturation\":\"Κορεσμός\"}");
203
37
 
204
- if (m = value.match($db5f3c2f048bca5be854d051d3f2729$var$HEX_REGEX)) {
205
- if (m[1]) {
206
- let r = parseInt(m[1][0] + m[1][0], 16);
207
- let g = parseInt(m[1][1] + m[1][1], 16);
208
- let b = parseInt(m[1][2] + m[1][2], 16);
209
- return new $db5f3c2f048bca5be854d051d3f2729$var$RGBColor(r, g, b, 1);
210
- } else if (m[2]) {
211
- let r = parseInt(m[2][0] + m[2][1], 16);
212
- let g = parseInt(m[2][2] + m[2][3], 16);
213
- let b = parseInt(m[2][4] + m[2][5], 16);
214
- return new $db5f3c2f048bca5be854d051d3f2729$var$RGBColor(r, g, b, 1);
215
- }
216
- }
217
38
 
218
- if (m = value.match($db5f3c2f048bca5be854d051d3f2729$var$RGB_REGEX)) {
219
- var _m$;
39
+ var $21cdd87e84f28d89$exports = {};
40
+ $21cdd87e84f28d89$exports = JSON.parse("{\"hue\":\"Hue\",\"saturation\":\"Saturation\",\"lightness\":\"Lightness\",\"brightness\":\"Brightness\",\"red\":\"Red\",\"green\":\"Green\",\"blue\":\"Blue\",\"alpha\":\"Alpha\"}");
220
41
 
221
- const [r, g, b, a] = ((_m$ = m[1]) != null ? _m$ : m[2]).split(',').map(n => Number(n.trim()));
222
- return new $db5f3c2f048bca5be854d051d3f2729$var$RGBColor(clamp(r, 0, 255), clamp(g, 0, 255), clamp(b, 0, 255), clamp(a != null ? a : 1, 0, 1));
223
- }
224
- }
225
42
 
226
- toString(format) {
227
- switch (format) {
228
- case 'hex':
229
- return '#' + (this.red.toString(16).padStart(2, '0') + this.green.toString(16).padStart(2, '0') + this.blue.toString(16).padStart(2, '0')).toUpperCase();
43
+ var $92fee9698e4d675a$exports = {};
44
+ $92fee9698e4d675a$exports = JSON.parse("{\"alpha\":\"Alpha\",\"blue\":\"Azul\",\"brightness\":\"Brillo\",\"green\":\"Verde\",\"hue\":\"Tono\",\"lightness\":\"Luminosidad\",\"red\":\"Rojo\",\"saturation\":\"Saturación\"}");
230
45
 
231
- case 'hexa':
232
- 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();
233
46
 
234
- case 'rgb':
235
- return "rgb(" + this.red + ", " + this.green + ", " + this.blue + ")";
47
+ var $7ea012e91a5ad3ee$exports = {};
48
+ $7ea012e91a5ad3ee$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Sinine\",\"brightness\":\"Heledus\",\"green\":\"Roheline\",\"hue\":\"Värv\",\"lightness\":\"Valgus\",\"red\":\"Punane\",\"saturation\":\"Küllastus\"}");
236
49
 
237
- case 'css':
238
- case 'rgba':
239
- return "rgba(" + this.red + ", " + this.green + ", " + this.blue + ", " + this.alpha + ")";
240
50
 
241
- default:
242
- return this.toFormat(format).toString(format);
243
- }
244
- }
51
+ var $8460c13bb2d75345$exports = {};
52
+ $8460c13bb2d75345$exports = JSON.parse("{\"alpha\":\"Alpha\",\"blue\":\"Sininen\",\"brightness\":\"Kirkkaus\",\"green\":\"Vihreä\",\"hue\":\"Sävy\",\"lightness\":\"Valomäärä\",\"red\":\"Punainen\",\"saturation\":\"Värikylläisyys\"}");
245
53
 
246
- toFormat(format) {
247
- switch (format) {
248
- case 'hex':
249
- case 'hexa':
250
- case 'rgb':
251
- case 'rgba':
252
- return this;
253
54
 
254
- default:
255
- throw new Error('Unsupported color conversion: rgb -> ' + format);
256
- }
257
- }
55
+ var $2a2d5dc14e680587$exports = {};
56
+ $2a2d5dc14e680587$exports = JSON.parse("{\"alpha\":\"Alpha\",\"blue\":\"Bleu\",\"brightness\":\"Luminosité\",\"green\":\"Vert\",\"hue\":\"Teinte\",\"lightness\":\"Luminosité\",\"red\":\"Rouge\",\"saturation\":\"Saturation\"}");
258
57
 
259
- toHexInt() {
260
- return this.red << 16 | this.green << 8 | this.blue;
261
- }
262
58
 
263
- clone() {
264
- return new $db5f3c2f048bca5be854d051d3f2729$var$RGBColor(this.red, this.green, this.blue, this.alpha);
265
- }
59
+ var $9a3f292371bb0589$exports = {};
60
+ $9a3f292371bb0589$exports = JSON.parse("{\"alpha\":\"אלפא\",\"blue\":\"כחול\",\"brightness\":\"בהירות\",\"green\":\"ירוק\",\"hue\":\"גוון\",\"lightness\":\"כמות אור\",\"red\":\"אדום\",\"saturation\":\"רוויה\"}");
266
61
 
267
- getChannelRange(channel) {
268
- switch (channel) {
269
- case 'red':
270
- case 'green':
271
- case 'blue':
272
- return {
273
- minValue: 0,
274
- maxValue: 255,
275
- step: 1
276
- };
277
62
 
278
- case 'alpha':
279
- return {
280
- minValue: 0,
281
- maxValue: 1,
282
- step: 0.01
283
- };
63
+ var $4742231a685fa068$exports = {};
64
+ $4742231a685fa068$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Plava\",\"brightness\":\"Svjetlina\",\"green\":\"Zelena\",\"hue\":\"Nijansa\",\"lightness\":\"Osvijetljenost\",\"red\":\"Crvena\",\"saturation\":\"Zasićenost\"}");
284
65
 
285
- default:
286
- throw new Error('Unknown color channel: ' + channel);
287
- }
288
- }
289
66
 
290
- formatChannelValue(channel, locale) {
291
- let options;
292
- let value = this.getChannelValue(channel);
67
+ var $05e247fd2960981e$exports = {};
68
+ $05e247fd2960981e$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Kék\",\"brightness\":\"Fényesség\",\"green\":\"Zöld\",\"hue\":\"Színárnyalat\",\"lightness\":\"Világosság\",\"red\":\"Piros\",\"saturation\":\"Telítettség\"}");
293
69
 
294
- switch (channel) {
295
- case 'red':
296
- case 'green':
297
- case 'blue':
298
- options = {
299
- style: 'decimal'
300
- };
301
- break;
302
70
 
303
- case 'alpha':
304
- options = {
305
- style: 'percent'
306
- };
307
- break;
71
+ var $a67524a79ccbe190$exports = {};
72
+ $a67524a79ccbe190$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Blu\",\"brightness\":\"Luminosità\",\"green\":\"Verde\",\"hue\":\"Tonalità\",\"lightness\":\"Luminosità\",\"red\":\"Rosso\",\"saturation\":\"Saturazione\"}");
308
73
 
309
- default:
310
- throw new Error('Unknown color channel: ' + channel);
311
- }
312
74
 
313
- return new NumberFormatter(locale, options).format(value);
314
- }
75
+ var $a9eefe9d6c8cb7d5$exports = {};
76
+ $a9eefe9d6c8cb7d5$exports = JSON.parse("{\"alpha\":\"アルファ\",\"blue\":\"青\",\"brightness\":\"明るさ\",\"green\":\"緑\",\"hue\":\"色相\",\"lightness\":\"明度\",\"red\":\"赤\",\"saturation\":\"彩度\"}");
315
77
 
316
- } // X = <negative/positive number with/without decimal places>
317
- // before/after a comma, 0 or more whitespaces are allowed
318
- // - hsb(X, X%, X%)
319
- // - hsba(X, X%, X%, X)
320
78
 
79
+ var $4a6b836d4f1bfaba$exports = {};
80
+ $4a6b836d4f1bfaba$exports = JSON.parse("{\"alpha\":\"알파\",\"blue\":\"파랑\",\"brightness\":\"명도\",\"green\":\"초록\",\"hue\":\"색조\",\"lightness\":\"밝기\",\"red\":\"빨강\",\"saturation\":\"채도\"}");
321
81
 
322
- const $db5f3c2f048bca5be854d051d3f2729$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+)?)\)/;
323
82
 
324
- class $db5f3c2f048bca5be854d051d3f2729$var$HSBColor extends $db5f3c2f048bca5be854d051d3f2729$var$Color {
325
- constructor(hue, saturation, brightness, alpha) {
326
- super();
327
- this.hue = hue;
328
- this.saturation = saturation;
329
- this.brightness = brightness;
330
- this.alpha = alpha;
331
- }
83
+ var $c950e4b1c482abde$exports = {};
84
+ $c950e4b1c482abde$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Mėlyna\",\"brightness\":\"Ryškumas\",\"green\":\"Žalia\",\"hue\":\"Atspalvis\",\"lightness\":\"Šviesumas\",\"red\":\"Raudona\",\"saturation\":\"Įsotinimas\"}");
332
85
 
333
- static parse(value) {
334
- let m;
335
86
 
336
- if (m = value.match($db5f3c2f048bca5be854d051d3f2729$var$HSB_REGEX)) {
337
- var _m$2;
87
+ var $d10d6b60dc50b438$exports = {};
88
+ $d10d6b60dc50b438$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Zila\",\"brightness\":\"Spilgtums\",\"green\":\"Zaļa\",\"hue\":\"Nokrāsa\",\"lightness\":\"Gaišums\",\"red\":\"Sarkana\",\"saturation\":\"Piesātinājums\"}");
338
89
 
339
- const [h, s, b, a] = ((_m$2 = m[1]) != null ? _m$2 : m[2]).split(',').map(n => Number(n.trim().replace('%', '')));
340
- return new $db5f3c2f048bca5be854d051d3f2729$var$HSBColor($db5f3c2f048bca5be854d051d3f2729$var$mod(h, 360), clamp(s, 0, 100), clamp(b, 0, 100), clamp(a != null ? a : 1, 0, 1));
341
- }
342
- }
343
90
 
344
- toString(format) {
345
- switch (format) {
346
- case 'css':
347
- return this.toHSL().toString('css');
91
+ var $371a732b2494f452$exports = {};
92
+ $371a732b2494f452$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Blå\",\"brightness\":\"Lysstyrke\",\"green\":\"Grønn\",\"hue\":\"Fargetone\",\"lightness\":\"Lyshet\",\"red\":\"Rød\",\"saturation\":\"Metning\"}");
348
93
 
349
- case 'hsb':
350
- return "hsb(" + this.hue + ", " + this.saturation + "%, " + this.brightness + "%)";
351
94
 
352
- case 'hsba':
353
- return "hsba(" + this.hue + ", " + this.saturation + "%, " + this.brightness + "%, " + this.alpha + ")";
95
+ var $6d042cae6243464b$exports = {};
96
+ $6d042cae6243464b$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Blauw\",\"brightness\":\"Helderheid\",\"green\":\"Groen\",\"hue\":\"Kleurtoon\",\"lightness\":\"Lichtsterkte\",\"red\":\"Rood\",\"saturation\":\"Verzadiging\"}");
354
97
 
355
- default:
356
- return this.toFormat(format).toString(format);
357
- }
358
- }
359
98
 
360
- toFormat(format) {
361
- switch (format) {
362
- case 'hsb':
363
- case 'hsba':
364
- return this;
99
+ var $d9ab5c2611e0bcd3$exports = {};
100
+ $d9ab5c2611e0bcd3$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Niebieski\",\"brightness\":\"Jasność\",\"green\":\"Zielony\",\"hue\":\"Odcień\",\"lightness\":\"Jaskrawość\",\"red\":\"Czerwony\",\"saturation\":\"Nasycenie\"}");
365
101
 
366
- case 'hsl':
367
- case 'hsla':
368
- return this.toHSL();
369
102
 
370
- default:
371
- throw new Error('Unsupported color conversion: hsb -> ' + format);
372
- }
373
- }
103
+ var $73f77c9902e29ca6$exports = {};
104
+ $73f77c9902e29ca6$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Azul\",\"brightness\":\"Brilho\",\"green\":\"Verde\",\"hue\":\"Matiz\",\"lightness\":\"Luminosidade\",\"red\":\"Vermelho\",\"saturation\":\"Saturação\"}");
374
105
 
375
- toHSL() {
376
- // determine the lightness in the range [0,100]
377
- var l = (2 - this.saturation / 100) * this.brightness / 2; // store the HSL components
378
106
 
379
- let hue = this.hue;
380
- let saturation = this.saturation * this.brightness / (l < 50 ? l * 2 : 200 - l * 2);
381
- let lightness = l; // correct a division-by-zero error
107
+ var $4f461eb266a95c10$exports = {};
108
+ $4f461eb266a95c10$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Azul\",\"brightness\":\"Luminosidade\",\"green\":\"Verde\",\"hue\":\"Tonalidade\",\"lightness\":\"Claridade\",\"red\":\"Vermelho\",\"saturation\":\"Saturação\"}");
382
109
 
383
- if (isNaN(saturation)) {
384
- saturation = 0;
385
- }
386
110
 
387
- return new $db5f3c2f048bca5be854d051d3f2729$var$HSLColor(hue, saturation, lightness, this.alpha);
388
- }
111
+ var $dc46bea2f2597899$exports = {};
112
+ $dc46bea2f2597899$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Albastru\",\"brightness\":\"Luminozitate\",\"green\":\"Verde\",\"hue\":\"Nuanță\",\"lightness\":\"Luminozitate\",\"red\":\"Roșu\",\"saturation\":\"Saturație\"}");
389
113
 
390
- clone() {
391
- return new $db5f3c2f048bca5be854d051d3f2729$var$HSBColor(this.hue, this.saturation, this.brightness, this.alpha);
392
- }
393
114
 
394
- getChannelRange(channel) {
395
- switch (channel) {
396
- case 'hue':
397
- return {
398
- minValue: 0,
399
- maxValue: 360,
400
- step: 1
401
- };
115
+ var $622bbd6719cc95af$exports = {};
116
+ $622bbd6719cc95af$exports = JSON.parse("{\"alpha\":\"Альфа\",\"blue\":\"Синий\",\"brightness\":\"Яркость\",\"green\":\"Зеленый\",\"hue\":\"Оттенок\",\"lightness\":\"Освещенность\",\"red\":\"Красный\",\"saturation\":\"Насыщенность\"}");
402
117
 
403
- case 'saturation':
404
- case 'brightness':
405
- return {
406
- minValue: 0,
407
- maxValue: 100,
408
- step: 1
409
- };
410
118
 
411
- case 'alpha':
412
- return {
413
- minValue: 0,
414
- maxValue: 1,
415
- step: 0.01
416
- };
119
+ var $4da03c1ecd9a9c7d$exports = {};
120
+ $4da03c1ecd9a9c7d$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Modrá\",\"brightness\":\"Jas\",\"green\":\"Zelená\",\"hue\":\"Odtieň\",\"lightness\":\"Svetlosť\",\"red\":\"Červená\",\"saturation\":\"Sýtosť\"}");
417
121
 
418
- default:
419
- throw new Error('Unknown color channel: ' + channel);
420
- }
421
- }
422
122
 
423
- formatChannelValue(channel, locale) {
424
- let options;
425
- let value = this.getChannelValue(channel);
123
+ var $edb6b2fe456ed4e8$exports = {};
124
+ $edb6b2fe456ed4e8$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Modra\",\"brightness\":\"Svetlost\",\"green\":\"Zelena\",\"hue\":\"Barva\",\"lightness\":\"Lahkost\",\"red\":\"Rdeča\",\"saturation\":\"Nasičenost\"}");
426
125
 
427
- switch (channel) {
428
- case 'hue':
429
- options = {
430
- style: 'unit',
431
- unit: 'degree',
432
- unitDisplay: 'narrow'
433
- };
434
- break;
435
126
 
436
- case 'saturation':
437
- case 'brightness':
438
- options = {
439
- style: 'percent'
440
- };
441
- value /= 100;
442
- break;
127
+ var $264cd81c52b30815$exports = {};
128
+ $264cd81c52b30815$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Plava\",\"brightness\":\"Osvetljenost\",\"green\":\"Zelena\",\"hue\":\"Nijansa\",\"lightness\":\"Osvetljenje\",\"red\":\"Crvena\",\"saturation\":\"Zasićenje\"}");
443
129
 
444
- case 'alpha':
445
- options = {
446
- style: 'percent'
447
- };
448
- break;
449
130
 
450
- default:
451
- throw new Error('Unknown color channel: ' + channel);
452
- }
131
+ var $6f80afde0270dda7$exports = {};
132
+ $6f80afde0270dda7$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Blått\",\"brightness\":\"Ljusstyrka\",\"green\":\"Grönt\",\"hue\":\"Nyans\",\"lightness\":\"Ljushet\",\"red\":\"Rött\",\"saturation\":\"Mättnad\"}");
453
133
 
454
- return new NumberFormatter(locale, options).format(value);
455
- }
456
134
 
457
- } // X = <negative/positive number with/without decimal places>
458
- // before/after a comma, 0 or more whitespaces are allowed
459
- // - hsl(X, X%, X%)
460
- // - hsla(X, X%, X%, X)
135
+ var $23a92651c6957668$exports = {};
136
+ $23a92651c6957668$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Mavi\",\"brightness\":\"Parlaklık\",\"green\":\"Yeşil\",\"hue\":\"Ton\",\"lightness\":\"Canlılık\",\"red\":\"Kırmızı\",\"saturation\":\"Doygunluk\"}");
461
137
 
462
138
 
463
- const $db5f3c2f048bca5be854d051d3f2729$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+)?)\)/;
139
+ var $0f9b1074d04f4954$exports = {};
140
+ $0f9b1074d04f4954$exports = JSON.parse("{\"alpha\":\"Альфа\",\"blue\":\"Синій\",\"brightness\":\"Яскравість\",\"green\":\"Зелений\",\"hue\":\"Тон\",\"lightness\":\"Освітленість\",\"red\":\"Червоний\",\"saturation\":\"Насиченість\"}");
464
141
 
465
- function $db5f3c2f048bca5be854d051d3f2729$var$mod(n, m) {
466
- return (n % m + m) % m;
467
- } // eslint-disable-next-line @typescript-eslint/no-unused-vars
468
142
 
143
+ var $a9cedf75b94e4916$exports = {};
144
+ $a9cedf75b94e4916$exports = JSON.parse("{\"alpha\":\"Alpha\",\"blue\":\"蓝色\",\"brightness\":\"亮度\",\"green\":\"绿色\",\"hue\":\"色相\",\"lightness\":\"明亮度\",\"red\":\"红色\",\"saturation\":\"饱和度\"}");
469
145
 
470
- class $db5f3c2f048bca5be854d051d3f2729$var$HSLColor extends $db5f3c2f048bca5be854d051d3f2729$var$Color {
471
- constructor(hue, saturation, lightness, alpha) {
472
- super();
473
- this.hue = hue;
474
- this.saturation = saturation;
475
- this.lightness = lightness;
476
- this.alpha = alpha;
477
- } // eslint-disable-next-line @typescript-eslint/no-unused-vars
478
146
 
147
+ var $37cff576474bc8d4$exports = {};
148
+ $37cff576474bc8d4$exports = JSON.parse("{\"alpha\":\"Alpha\",\"blue\":\"藍色\",\"brightness\":\"亮度\",\"green\":\"綠色\",\"hue\":\"色相\",\"lightness\":\"明亮\",\"red\":\"紅色\",\"saturation\":\"飽和度\"}");
479
149
 
480
- static parse(value) {
481
- let m;
482
150
 
483
- if (m = value.match($db5f3c2f048bca5be854d051d3f2729$var$HSL_REGEX)) {
484
- var _m$3;
151
+ $7a451c0c6841e6b9$exports = {
152
+ "ar-AE": $2d805fd52bb48883$exports,
153
+ "bg-BG": $6c28468dc1df643c$exports,
154
+ "cs-CZ": $807554f8230db0ed$exports,
155
+ "da-DK": $7097f64386f1761c$exports,
156
+ "de-DE": $bdd847d8beb08799$exports,
157
+ "el-GR": $a53e00b683950971$exports,
158
+ "en-US": $21cdd87e84f28d89$exports,
159
+ "es-ES": $92fee9698e4d675a$exports,
160
+ "et-EE": $7ea012e91a5ad3ee$exports,
161
+ "fi-FI": $8460c13bb2d75345$exports,
162
+ "fr-FR": $2a2d5dc14e680587$exports,
163
+ "he-IL": $9a3f292371bb0589$exports,
164
+ "hr-HR": $4742231a685fa068$exports,
165
+ "hu-HU": $05e247fd2960981e$exports,
166
+ "it-IT": $a67524a79ccbe190$exports,
167
+ "ja-JP": $a9eefe9d6c8cb7d5$exports,
168
+ "ko-KR": $4a6b836d4f1bfaba$exports,
169
+ "lt-LT": $c950e4b1c482abde$exports,
170
+ "lv-LV": $d10d6b60dc50b438$exports,
171
+ "nb-NO": $371a732b2494f452$exports,
172
+ "nl-NL": $6d042cae6243464b$exports,
173
+ "pl-PL": $d9ab5c2611e0bcd3$exports,
174
+ "pt-BR": $73f77c9902e29ca6$exports,
175
+ "pt-PT": $4f461eb266a95c10$exports,
176
+ "ro-RO": $dc46bea2f2597899$exports,
177
+ "ru-RU": $622bbd6719cc95af$exports,
178
+ "sk-SK": $4da03c1ecd9a9c7d$exports,
179
+ "sl-SI": $edb6b2fe456ed4e8$exports,
180
+ "sr-SP": $264cd81c52b30815$exports,
181
+ "sv-SE": $6f80afde0270dda7$exports,
182
+ "tr-TR": $23a92651c6957668$exports,
183
+ "uk-UA": $0f9b1074d04f4954$exports,
184
+ "zh-CN": $a9cedf75b94e4916$exports,
185
+ "zh-TW": $37cff576474bc8d4$exports
186
+ };
485
187
 
486
- const [h, s, l, a] = ((_m$3 = m[1]) != null ? _m$3 : m[2]).split(',').map(n => Number(n.trim().replace('%', '')));
487
- return new $db5f3c2f048bca5be854d051d3f2729$var$HSLColor($db5f3c2f048bca5be854d051d3f2729$var$mod(h, 360), clamp(s, 0, 100), clamp(l, 0, 100), clamp(a != null ? a : 1, 0, 1));
488
- }
489
- }
490
188
 
491
- toString(format) {
492
- switch (format) {
493
- case 'hsl':
494
- return "hsl(" + this.hue + ", " + this.saturation + "%, " + this.lightness + "%)";
495
189
 
496
- case 'css':
497
- case 'hsla':
498
- return "hsla(" + this.hue + ", " + this.saturation + "%, " + this.lightness + "%, " + this.alpha + ")";
499
190
 
500
- default:
501
- return this.toFormat(format).toString(format);
191
+ const $799cddbef784668f$var$messages = new $cBgAy$MessageDictionary((/*@__PURE__*/$parcel$interopDefault($7a451c0c6841e6b9$exports)));
192
+ function $799cddbef784668f$export$6e865ea70d7724f(value) {
193
+ let res = $799cddbef784668f$var$RGBColor.parse(value) || $799cddbef784668f$var$HSBColor.parse(value) || $799cddbef784668f$var$HSLColor.parse(value);
194
+ if (res) return res;
195
+ throw new Error('Invalid color value: ' + value);
196
+ }
197
+ function $799cddbef784668f$export$4cde5df63f53f473(v) {
198
+ if (typeof v === 'string') return $799cddbef784668f$export$6e865ea70d7724f(v);
199
+ else return v;
200
+ }
201
+ class $799cddbef784668f$var$Color {
202
+ toHexInt() {
203
+ return this.toFormat('rgb').toHexInt();
502
204
  }
503
- }
504
-
505
- toFormat(format) {
506
- switch (format) {
507
- case 'hsl':
508
- case 'hsla':
509
- return this;
510
-
511
- default:
512
- throw new Error('Unsupported color conversion: hsl -> ' + format);
205
+ getChannelValue(channel) {
206
+ if (channel in this) return this[channel];
207
+ throw new Error('Unsupported color channel: ' + channel);
513
208
  }
514
- }
515
-
516
- clone() {
517
- return new $db5f3c2f048bca5be854d051d3f2729$var$HSLColor(this.hue, this.saturation, this.lightness, this.alpha);
518
- }
519
-
520
- getChannelRange(channel) {
521
- switch (channel) {
522
- case 'hue':
523
- return {
524
- minValue: 0,
525
- maxValue: 360,
526
- step: 1
527
- };
528
-
529
- case 'saturation':
530
- case 'lightness':
531
- return {
532
- minValue: 0,
533
- maxValue: 100,
534
- step: 1
535
- };
536
-
537
- case 'alpha':
538
- return {
539
- minValue: 0,
540
- maxValue: 1,
541
- step: 0.01
542
- };
543
-
544
- default:
545
- throw new Error('Unknown color channel: ' + channel);
209
+ withChannelValue(channel, value) {
210
+ if (channel in this) {
211
+ let x = this.clone();
212
+ x[channel] = value;
213
+ return x;
214
+ }
215
+ throw new Error('Unsupported color channel: ' + channel);
546
216
  }
547
- }
548
-
549
- formatChannelValue(channel, locale) {
550
- let options;
551
- let value = this.getChannelValue(channel);
552
-
553
- switch (channel) {
554
- case 'hue':
555
- options = {
556
- style: 'unit',
557
- unit: 'degree',
558
- unitDisplay: 'narrow'
559
- };
560
- break;
561
-
562
- case 'saturation':
563
- case 'lightness':
564
- options = {
565
- style: 'percent'
566
- };
567
- value /= 100;
568
- break;
569
-
570
- case 'alpha':
571
- options = {
572
- style: 'percent'
217
+ getChannelName(channel, locale) {
218
+ return $799cddbef784668f$var$messages.getStringForLocale(channel, locale);
219
+ }
220
+ getColorSpaceAxes(xyChannels) {
221
+ let { xChannel: xChannel , yChannel: yChannel } = xyChannels;
222
+ let xCh = xChannel || this.getColorChannels().find((c)=>c !== yChannel
223
+ );
224
+ let yCh = yChannel || this.getColorChannels().find((c)=>c !== xCh
225
+ );
226
+ let zCh = this.getColorChannels().find((c)=>c !== xCh && c !== yCh
227
+ );
228
+ return {
229
+ xChannel: xCh,
230
+ yChannel: yCh,
231
+ zChannel: zCh
573
232
  };
574
- break;
575
-
576
- default:
577
- throw new Error('Unknown color channel: ' + channel);
578
233
  }
579
-
580
- return new NumberFormatter(locale, options).format(value);
581
- }
582
-
583
234
  }
584
-
585
- function $dfa319d4be3239bcd232b84e0e071$var$normalizeColor(v) {
586
- if (typeof v === 'string') {
587
- return parseColor(v);
588
- } else {
589
- return v;
590
- }
235
+ const $799cddbef784668f$var$HEX_REGEX = /^#(?:([0-9a-f]{3})|([0-9a-f]{6}))$/i;
236
+ // X = <negative/positive number with/without decimal places>
237
+ // before/after a comma, 0 or more whitespaces are allowed
238
+ // - rgb(X, X, X)
239
+ // - rgba(X, X, X, X)
240
+ const $799cddbef784668f$var$RGB_REGEX = /rgb\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?)\)|rgba\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d(.\d+)?)\)/;
241
+ class $799cddbef784668f$var$RGBColor extends $799cddbef784668f$var$Color {
242
+ static parse(value) {
243
+ let m;
244
+ if (m = value.match($799cddbef784668f$var$HEX_REGEX)) {
245
+ if (m[1]) {
246
+ let r = parseInt(m[1][0] + m[1][0], 16);
247
+ let g = parseInt(m[1][1] + m[1][1], 16);
248
+ let b = parseInt(m[1][2] + m[1][2], 16);
249
+ return new $799cddbef784668f$var$RGBColor(r, g, b, 1);
250
+ } else if (m[2]) {
251
+ let r = parseInt(m[2][0] + m[2][1], 16);
252
+ let g = parseInt(m[2][2] + m[2][3], 16);
253
+ let b = parseInt(m[2][4] + m[2][5], 16);
254
+ return new $799cddbef784668f$var$RGBColor(r, g, b, 1);
255
+ }
256
+ }
257
+ if (m = value.match($799cddbef784668f$var$RGB_REGEX)) {
258
+ var ref;
259
+ const [r, g, b, a] = ((ref = m[1]) !== null && ref !== void 0 ? ref : m[2]).split(',').map((n)=>Number(n.trim())
260
+ );
261
+ return new $799cddbef784668f$var$RGBColor($cBgAy$clamp(r, 0, 255), $cBgAy$clamp(g, 0, 255), $cBgAy$clamp(b, 0, 255), $cBgAy$clamp(a !== null && a !== void 0 ? a : 1, 0, 1));
262
+ }
263
+ }
264
+ toString(format) {
265
+ switch(format){
266
+ case 'hex':
267
+ return '#' + (this.red.toString(16).padStart(2, '0') + this.green.toString(16).padStart(2, '0') + this.blue.toString(16).padStart(2, '0')).toUpperCase();
268
+ case 'hexa':
269
+ 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();
270
+ case 'rgb':
271
+ return `rgb(${this.red}, ${this.green}, ${this.blue})`;
272
+ case 'css':
273
+ case 'rgba':
274
+ return `rgba(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`;
275
+ default:
276
+ return this.toFormat(format).toString(format);
277
+ }
278
+ }
279
+ toFormat(format) {
280
+ switch(format){
281
+ case 'hex':
282
+ case 'hexa':
283
+ case 'rgb':
284
+ case 'rgba':
285
+ return this;
286
+ case 'hsb':
287
+ case 'hsba':
288
+ return this.toHSB();
289
+ case 'hsl':
290
+ case 'hsla':
291
+ return this.toHSL();
292
+ default:
293
+ throw new Error('Unsupported color conversion: rgb -> ' + format);
294
+ }
295
+ }
296
+ toHexInt() {
297
+ return this.red << 16 | this.green << 8 | this.blue;
298
+ }
299
+ /**
300
+ * Converts an RGB color value to HSB.
301
+ * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.
302
+ * @returns An HSBColor object.
303
+ */ toHSB() {
304
+ const red = this.red / 255;
305
+ const green = this.green / 255;
306
+ const blue = this.blue / 255;
307
+ const min = Math.min(red, green, blue);
308
+ const brightness = Math.max(red, green, blue);
309
+ const chroma = brightness - min;
310
+ const saturation = brightness === 0 ? 0 : chroma / brightness;
311
+ let hue = 0; // achromatic
312
+ if (chroma !== 0) {
313
+ switch(brightness){
314
+ case red:
315
+ hue = (green - blue) / chroma + (green < blue ? 6 : 0);
316
+ break;
317
+ case green:
318
+ hue = (blue - red) / chroma + 2;
319
+ break;
320
+ case blue:
321
+ hue = (red - green) / chroma + 4;
322
+ break;
323
+ }
324
+ hue /= 6;
325
+ }
326
+ return new $799cddbef784668f$var$HSBColor($cBgAy$toFixedNumber(hue * 360, 2), $cBgAy$toFixedNumber(saturation * 100, 2), $cBgAy$toFixedNumber(brightness * 100, 2), this.alpha);
327
+ }
328
+ /**
329
+ * Converts an RGB color value to HSL.
330
+ * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.
331
+ * @returns An HSLColor object.
332
+ */ toHSL() {
333
+ const red = this.red / 255;
334
+ const green = this.green / 255;
335
+ const blue = this.blue / 255;
336
+ const min = Math.min(red, green, blue);
337
+ const max = Math.max(red, green, blue);
338
+ const lightness = (max + min) / 2;
339
+ const chroma = max - min;
340
+ let hue;
341
+ let saturation;
342
+ if (chroma === 0) hue = saturation = 0; // achromatic
343
+ else {
344
+ saturation = chroma / (lightness < 0.5 ? max + min : 2 - max - min);
345
+ switch(max){
346
+ case red:
347
+ hue = (green - blue) / chroma + (green < blue ? 6 : 0);
348
+ break;
349
+ case green:
350
+ hue = (blue - red) / chroma + 2;
351
+ break;
352
+ case blue:
353
+ hue = (red - green) / chroma + 4;
354
+ break;
355
+ }
356
+ hue /= 6;
357
+ }
358
+ return new $799cddbef784668f$var$HSLColor($cBgAy$toFixedNumber(hue * 360, 2), $cBgAy$toFixedNumber(saturation * 100, 2), $cBgAy$toFixedNumber(lightness * 100, 2), this.alpha);
359
+ }
360
+ clone() {
361
+ return new $799cddbef784668f$var$RGBColor(this.red, this.green, this.blue, this.alpha);
362
+ }
363
+ getChannelRange(channel) {
364
+ switch(channel){
365
+ case 'red':
366
+ case 'green':
367
+ case 'blue':
368
+ return {
369
+ minValue: 0,
370
+ maxValue: 255,
371
+ step: 1,
372
+ pageSize: 17
373
+ };
374
+ case 'alpha':
375
+ return {
376
+ minValue: 0,
377
+ maxValue: 1,
378
+ step: 0.01,
379
+ pageSize: 0.1
380
+ };
381
+ default:
382
+ throw new Error('Unknown color channel: ' + channel);
383
+ }
384
+ }
385
+ formatChannelValue(channel, locale) {
386
+ let options;
387
+ let value = this.getChannelValue(channel);
388
+ switch(channel){
389
+ case 'red':
390
+ case 'green':
391
+ case 'blue':
392
+ options = {
393
+ style: 'decimal'
394
+ };
395
+ break;
396
+ case 'alpha':
397
+ options = {
398
+ style: 'percent'
399
+ };
400
+ break;
401
+ default:
402
+ throw new Error('Unknown color channel: ' + channel);
403
+ }
404
+ return new $cBgAy$NumberFormatter(locale, options).format(value);
405
+ }
406
+ getColorSpace() {
407
+ return 'rgb';
408
+ }
409
+ getColorChannels() {
410
+ return $799cddbef784668f$var$RGBColor.colorChannels;
411
+ }
412
+ constructor(red, green, blue, alpha){
413
+ super();
414
+ this.red = red;
415
+ this.green = green;
416
+ this.blue = blue;
417
+ this.alpha = alpha;
418
+ }
591
419
  }
592
- /**
593
- * Provides state management for a color slider component.
594
- * Color sliders allow users to adjust an individual channel of a color value.
595
- */
596
-
597
-
598
- export function useColorSliderState(props) {
599
- let {
600
- channel,
601
- value,
602
- defaultValue,
603
- onChange,
604
- locale
605
- } = props,
606
- otherProps = _babelRuntimeHelpersEsmObjectWithoutPropertiesLoose(props, ["channel", "value", "defaultValue", "onChange", "locale"]);
607
-
608
- if (value == null && defaultValue == null) {
609
- throw new Error('useColorSliderState requires a value or defaultValue');
610
- }
611
-
612
- let [color, setColor] = useControlledState(value && $dfa319d4be3239bcd232b84e0e071$var$normalizeColor(value), defaultValue && $dfa319d4be3239bcd232b84e0e071$var$normalizeColor(defaultValue), onChange);
613
- let sliderState = useSliderState(_babelRuntimeHelpersEsmExtends({}, color.getChannelRange(channel), otherProps, {
614
- // Unused except in getThumbValueLabel, which is overridden below. null to appease TypeScript.
615
- numberFormatter: null,
616
- value: [color.getChannelValue(channel)],
617
-
618
- onChange(_ref) {
619
- let [v] = _ref;
620
- setColor(color.withChannelValue(channel, v));
621
- },
622
-
623
- onChangeEnd(_ref2) {
624
- let [v] = _ref2;
625
-
626
- // onChange will have already been called with the right value, this is just to trigger onChangEnd
627
- if (props.onChangeEnd) {
628
- props.onChangeEnd(color.withChannelValue(channel, v));
629
- }
630
- }
631
-
632
- }));
633
- return _babelRuntimeHelpersEsmExtends({}, sliderState, {
634
- value: color,
635
-
636
- setValue(value) {
637
- setColor($dfa319d4be3239bcd232b84e0e071$var$normalizeColor(value));
638
- },
639
-
640
- getDisplayColor() {
641
- switch (channel) {
642
- case 'hue':
643
- return parseColor("hsl(" + color.getChannelValue('hue') + ", 100%, 50%)");
644
-
645
- case 'lightness':
646
- case 'brightness':
647
- case 'saturation':
648
- case 'red':
649
- case 'green':
650
- case 'blue':
651
- return color.withChannelValue('alpha', 1);
652
-
653
- case 'alpha':
654
- {
655
- return color;
656
- }
657
-
658
- default:
659
- throw new Error('Unknown color channel: ' + channel);
660
- }
661
- },
662
-
663
- getThumbValueLabel() {
664
- return color.formatChannelValue(channel, locale);
665
- }
666
-
667
- });
420
+ $799cddbef784668f$var$RGBColor.colorChannels = [
421
+ 'red',
422
+ 'green',
423
+ 'blue'
424
+ ];
425
+ // X = <negative/positive number with/without decimal places>
426
+ // before/after a comma, 0 or more whitespaces are allowed
427
+ // - hsb(X, X%, X%)
428
+ // - hsba(X, X%, X%, X)
429
+ const $799cddbef784668f$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+)?)\)/;
430
+ class $799cddbef784668f$var$HSBColor extends $799cddbef784668f$var$Color {
431
+ static parse(value) {
432
+ let m;
433
+ if (m = value.match($799cddbef784668f$var$HSB_REGEX)) {
434
+ var ref;
435
+ const [h, s, b, a] = ((ref = m[1]) !== null && ref !== void 0 ? ref : m[2]).split(',').map((n)=>Number(n.trim().replace('%', ''))
436
+ );
437
+ return new $799cddbef784668f$var$HSBColor($799cddbef784668f$var$mod(h, 360), $cBgAy$clamp(s, 0, 100), $cBgAy$clamp(b, 0, 100), $cBgAy$clamp(a !== null && a !== void 0 ? a : 1, 0, 1));
438
+ }
439
+ }
440
+ toString(format) {
441
+ switch(format){
442
+ case 'css':
443
+ return this.toHSL().toString('css');
444
+ case 'hex':
445
+ return this.toRGB().toString('hex');
446
+ case 'hexa':
447
+ return this.toRGB().toString('hexa');
448
+ case 'hsb':
449
+ return `hsb(${this.hue}, ${$cBgAy$toFixedNumber(this.saturation, 2)}%, ${$cBgAy$toFixedNumber(this.brightness, 2)}%)`;
450
+ case 'hsba':
451
+ return `hsba(${this.hue}, ${$cBgAy$toFixedNumber(this.saturation, 2)}%, ${$cBgAy$toFixedNumber(this.brightness, 2)}%, ${this.alpha})`;
452
+ default:
453
+ return this.toFormat(format).toString(format);
454
+ }
455
+ }
456
+ toFormat(format) {
457
+ switch(format){
458
+ case 'hsb':
459
+ case 'hsba':
460
+ return this;
461
+ case 'hsl':
462
+ case 'hsla':
463
+ return this.toHSL();
464
+ case 'rgb':
465
+ case 'rgba':
466
+ return this.toRGB();
467
+ default:
468
+ throw new Error('Unsupported color conversion: hsb -> ' + format);
469
+ }
470
+ }
471
+ /**
472
+ * Converts a HSB color to HSL.
473
+ * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_HSL.
474
+ * @returns An HSLColor object.
475
+ */ toHSL() {
476
+ let saturation = this.saturation / 100;
477
+ let brightness = this.brightness / 100;
478
+ let lightness = brightness * (1 - saturation / 2);
479
+ saturation = lightness === 0 || lightness === 1 ? 0 : (brightness - lightness) / Math.min(lightness, 1 - lightness);
480
+ return new $799cddbef784668f$var$HSLColor($cBgAy$toFixedNumber(this.hue, 2), $cBgAy$toFixedNumber(saturation * 100, 2), $cBgAy$toFixedNumber(lightness * 100, 2), this.alpha);
481
+ }
482
+ /**
483
+ * Converts a HSV color value to RGB.
484
+ * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_RGB_alternative.
485
+ * @returns An RGBColor object.
486
+ */ toRGB() {
487
+ let hue = this.hue;
488
+ let saturation = this.saturation / 100;
489
+ let brightness = this.brightness / 100;
490
+ let fn = (n, k = (n + hue / 60) % 6)=>brightness - saturation * brightness * Math.max(Math.min(k, 4 - k, 1), 0)
491
+ ;
492
+ return new $799cddbef784668f$var$RGBColor(Math.round(fn(5) * 255), Math.round(fn(3) * 255), Math.round(fn(1) * 255), this.alpha);
493
+ }
494
+ clone() {
495
+ return new $799cddbef784668f$var$HSBColor(this.hue, this.saturation, this.brightness, this.alpha);
496
+ }
497
+ getChannelRange(channel) {
498
+ switch(channel){
499
+ case 'hue':
500
+ return {
501
+ minValue: 0,
502
+ maxValue: 360,
503
+ step: 1,
504
+ pageSize: 15
505
+ };
506
+ case 'saturation':
507
+ case 'brightness':
508
+ return {
509
+ minValue: 0,
510
+ maxValue: 100,
511
+ step: 1,
512
+ pageSize: 10
513
+ };
514
+ case 'alpha':
515
+ return {
516
+ minValue: 0,
517
+ maxValue: 1,
518
+ step: 0.01,
519
+ pageSize: 0.1
520
+ };
521
+ default:
522
+ throw new Error('Unknown color channel: ' + channel);
523
+ }
524
+ }
525
+ formatChannelValue(channel, locale) {
526
+ let options;
527
+ let value = this.getChannelValue(channel);
528
+ switch(channel){
529
+ case 'hue':
530
+ options = {
531
+ style: 'unit',
532
+ unit: 'degree',
533
+ unitDisplay: 'narrow'
534
+ };
535
+ break;
536
+ case 'saturation':
537
+ case 'brightness':
538
+ options = {
539
+ style: 'percent'
540
+ };
541
+ value /= 100;
542
+ break;
543
+ case 'alpha':
544
+ options = {
545
+ style: 'percent'
546
+ };
547
+ break;
548
+ default:
549
+ throw new Error('Unknown color channel: ' + channel);
550
+ }
551
+ return new $cBgAy$NumberFormatter(locale, options).format(value);
552
+ }
553
+ getColorSpace() {
554
+ return 'hsb';
555
+ }
556
+ getColorChannels() {
557
+ return $799cddbef784668f$var$HSBColor.colorChannels;
558
+ }
559
+ constructor(hue, saturation, brightness, alpha){
560
+ super();
561
+ this.hue = hue;
562
+ this.saturation = saturation;
563
+ this.brightness = brightness;
564
+ this.alpha = alpha;
565
+ }
668
566
  }
669
-
670
- function $a54bad0097d5f20f12ac194ac13764$var$normalizeColor(v) {
671
- if (typeof v === 'string') {
672
- return parseColor(v);
673
- } else {
674
- return v;
675
- }
567
+ $799cddbef784668f$var$HSBColor.colorChannels = [
568
+ 'hue',
569
+ 'saturation',
570
+ 'brightness'
571
+ ];
572
+ // X = <negative/positive number with/without decimal places>
573
+ // before/after a comma, 0 or more whitespaces are allowed
574
+ // - hsl(X, X%, X%)
575
+ // - hsla(X, X%, X%, X)
576
+ const $799cddbef784668f$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+)?)\)/;
577
+ function $799cddbef784668f$var$mod(n, m) {
578
+ return (n % m + m) % m;
676
579
  }
677
-
678
- const $a54bad0097d5f20f12ac194ac13764$var$DEFAULT_COLOR = parseColor('hsl(0, 100%, 50%)');
679
-
680
- function $a54bad0097d5f20f12ac194ac13764$var$roundToStep(value, step) {
681
- return Math.round(value / step) * step;
580
+ class $799cddbef784668f$var$HSLColor extends $799cddbef784668f$var$Color {
581
+ static parse(value) {
582
+ let m;
583
+ if (m = value.match($799cddbef784668f$var$HSL_REGEX)) {
584
+ var ref;
585
+ const [h, s, l, a] = ((ref = m[1]) !== null && ref !== void 0 ? ref : m[2]).split(',').map((n)=>Number(n.trim().replace('%', ''))
586
+ );
587
+ return new $799cddbef784668f$var$HSLColor($799cddbef784668f$var$mod(h, 360), $cBgAy$clamp(s, 0, 100), $cBgAy$clamp(l, 0, 100), $cBgAy$clamp(a !== null && a !== void 0 ? a : 1, 0, 1));
588
+ }
589
+ }
590
+ toString(format) {
591
+ switch(format){
592
+ case 'hex':
593
+ return this.toRGB().toString('hex');
594
+ case 'hexa':
595
+ return this.toRGB().toString('hexa');
596
+ case 'hsl':
597
+ return `hsl(${this.hue}, ${$cBgAy$toFixedNumber(this.saturation, 2)}%, ${$cBgAy$toFixedNumber(this.lightness, 2)}%)`;
598
+ case 'css':
599
+ case 'hsla':
600
+ return `hsla(${this.hue}, ${$cBgAy$toFixedNumber(this.saturation, 2)}%, ${$cBgAy$toFixedNumber(this.lightness, 2)}%, ${this.alpha})`;
601
+ default:
602
+ return this.toFormat(format).toString(format);
603
+ }
604
+ }
605
+ toFormat(format) {
606
+ switch(format){
607
+ case 'hsl':
608
+ case 'hsla':
609
+ return this;
610
+ case 'hsb':
611
+ case 'hsba':
612
+ return this.toHSB();
613
+ case 'rgb':
614
+ case 'rgba':
615
+ return this.toRGB();
616
+ default:
617
+ throw new Error('Unsupported color conversion: hsl -> ' + format);
618
+ }
619
+ }
620
+ /**
621
+ * Converts a HSL color to HSB.
622
+ * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_HSV.
623
+ * @returns An HSBColor object.
624
+ */ toHSB() {
625
+ let saturation = this.saturation / 100;
626
+ let lightness = this.lightness / 100;
627
+ let brightness = lightness + saturation * Math.min(lightness, 1 - lightness);
628
+ saturation = brightness === 0 ? 0 : 2 * (1 - lightness / brightness);
629
+ return new $799cddbef784668f$var$HSBColor($cBgAy$toFixedNumber(this.hue, 2), $cBgAy$toFixedNumber(saturation * 100, 2), $cBgAy$toFixedNumber(brightness * 100, 2), this.alpha);
630
+ }
631
+ /**
632
+ * Converts a HSL color to RGB.
633
+ * Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB_alternative.
634
+ * @returns An RGBColor object.
635
+ */ toRGB() {
636
+ let hue = this.hue;
637
+ let saturation = this.saturation / 100;
638
+ let lightness = this.lightness / 100;
639
+ let a = saturation * Math.min(lightness, 1 - lightness);
640
+ let fn = (n, k = (n + hue / 30) % 12)=>lightness - a * Math.max(Math.min(k - 3, 9 - k, 1), -1)
641
+ ;
642
+ return new $799cddbef784668f$var$RGBColor(Math.round(fn(0) * 255), Math.round(fn(8) * 255), Math.round(fn(4) * 255), this.alpha);
643
+ }
644
+ clone() {
645
+ return new $799cddbef784668f$var$HSLColor(this.hue, this.saturation, this.lightness, this.alpha);
646
+ }
647
+ getChannelRange(channel) {
648
+ switch(channel){
649
+ case 'hue':
650
+ return {
651
+ minValue: 0,
652
+ maxValue: 360,
653
+ step: 1,
654
+ pageSize: 15
655
+ };
656
+ case 'saturation':
657
+ case 'lightness':
658
+ return {
659
+ minValue: 0,
660
+ maxValue: 100,
661
+ step: 1,
662
+ pageSize: 10
663
+ };
664
+ case 'alpha':
665
+ return {
666
+ minValue: 0,
667
+ maxValue: 1,
668
+ step: 0.01,
669
+ pageSize: 0.1
670
+ };
671
+ default:
672
+ throw new Error('Unknown color channel: ' + channel);
673
+ }
674
+ }
675
+ formatChannelValue(channel, locale) {
676
+ let options;
677
+ let value = this.getChannelValue(channel);
678
+ switch(channel){
679
+ case 'hue':
680
+ options = {
681
+ style: 'unit',
682
+ unit: 'degree',
683
+ unitDisplay: 'narrow'
684
+ };
685
+ break;
686
+ case 'saturation':
687
+ case 'lightness':
688
+ options = {
689
+ style: 'percent'
690
+ };
691
+ value /= 100;
692
+ break;
693
+ case 'alpha':
694
+ options = {
695
+ style: 'percent'
696
+ };
697
+ break;
698
+ default:
699
+ throw new Error('Unknown color channel: ' + channel);
700
+ }
701
+ return new $cBgAy$NumberFormatter(locale, options).format(value);
702
+ }
703
+ getColorSpace() {
704
+ return 'hsl';
705
+ }
706
+ getColorChannels() {
707
+ return $799cddbef784668f$var$HSLColor.colorChannels;
708
+ }
709
+ constructor(hue, saturation, lightness, alpha){
710
+ super();
711
+ this.hue = hue;
712
+ this.saturation = saturation;
713
+ this.lightness = lightness;
714
+ this.alpha = alpha;
715
+ }
682
716
  }
683
-
684
- function $a54bad0097d5f20f12ac194ac13764$var$mod(n, m) {
685
- return (n % m + m) % m;
717
+ $799cddbef784668f$var$HSLColor.colorChannels = [
718
+ 'hue',
719
+ 'saturation',
720
+ 'lightness'
721
+ ];
722
+
723
+
724
+ var $6e14a98a7f67141d$exports = {};
725
+
726
+ $parcel$export($6e14a98a7f67141d$exports, "useColorAreaState", () => $6e14a98a7f67141d$export$6df7f0e2cabc7eef);
727
+
728
+
729
+
730
+ const $6e14a98a7f67141d$var$DEFAULT_COLOR = $799cddbef784668f$export$6e865ea70d7724f('#ffffff');
731
+ function $6e14a98a7f67141d$export$6df7f0e2cabc7eef(props) {
732
+ let { value: value1 , defaultValue: defaultValue , xChannel: xChannel , yChannel: yChannel , onChange: onChange , onChangeEnd: onChangeEnd } = props;
733
+ if (!value1 && !defaultValue) defaultValue = $6e14a98a7f67141d$var$DEFAULT_COLOR;
734
+ let [color, setColor] = $cBgAy$useControlledState(value1 && $799cddbef784668f$export$4cde5df63f53f473(value1), defaultValue && $799cddbef784668f$export$4cde5df63f53f473(defaultValue), onChange);
735
+ let valueRef = $cBgAy$useRef(color);
736
+ valueRef.current = color;
737
+ let channels = $cBgAy$useMemo(()=>valueRef.current.getColorSpaceAxes({
738
+ xChannel: xChannel,
739
+ yChannel: yChannel
740
+ })
741
+ , [
742
+ xChannel,
743
+ yChannel
744
+ ]);
745
+ let xChannelRange = color.getChannelRange(channels.xChannel);
746
+ let yChannelRange = color.getChannelRange(channels.yChannel);
747
+ let { minValue: minValueX , maxValue: maxValueX , step: stepX , pageSize: pageSizeX } = xChannelRange;
748
+ let { minValue: minValueY , maxValue: maxValueY , step: stepY , pageSize: pageSizeY } = yChannelRange;
749
+ let [isDragging1, setDragging] = $cBgAy$useState(false);
750
+ let isDraggingRef = $cBgAy$useRef(false).current;
751
+ let xValue = color.getChannelValue(channels.xChannel);
752
+ let yValue = color.getChannelValue(channels.yChannel);
753
+ let setXValue = (v)=>{
754
+ if (v === xValue) return;
755
+ valueRef.current = color.withChannelValue(channels.xChannel, v);
756
+ setColor(valueRef.current);
757
+ };
758
+ let setYValue = (v)=>{
759
+ if (v === yValue) return;
760
+ valueRef.current = color.withChannelValue(channels.yChannel, v);
761
+ setColor(valueRef.current);
762
+ };
763
+ return {
764
+ channels: channels,
765
+ xChannelStep: stepX,
766
+ yChannelStep: stepY,
767
+ xChannelPageStep: pageSizeX,
768
+ yChannelPageStep: pageSizeY,
769
+ value: color,
770
+ setValue (value) {
771
+ let c = $799cddbef784668f$export$4cde5df63f53f473(value);
772
+ valueRef.current = c;
773
+ setColor(c);
774
+ },
775
+ xValue: xValue,
776
+ setXValue: setXValue,
777
+ yValue: yValue,
778
+ setYValue: setYValue,
779
+ setColorFromPoint (x, y) {
780
+ let newXValue = minValueX + $cBgAy$clamp(x, 0, 1) * (maxValueX - minValueX);
781
+ let newYValue = minValueY + (1 - $cBgAy$clamp(y, 0, 1)) * (maxValueY - minValueY);
782
+ let newColor;
783
+ if (newXValue !== xValue) {
784
+ // Round new value to multiple of step, clamp value between min and max
785
+ newXValue = $cBgAy$snapValueToStep(newXValue, minValueX, maxValueX, stepX);
786
+ newColor = color.withChannelValue(channels.xChannel, newXValue);
787
+ }
788
+ if (newYValue !== yValue) {
789
+ // Round new value to multiple of step, clamp value between min and max
790
+ newYValue = $cBgAy$snapValueToStep(newYValue, minValueY, maxValueY, stepY);
791
+ newColor = (newColor || color).withChannelValue(channels.yChannel, newYValue);
792
+ }
793
+ if (newColor) setColor(newColor);
794
+ },
795
+ getThumbPosition () {
796
+ let x = (xValue - minValueX) / (maxValueX - minValueX);
797
+ let y = 1 - (yValue - minValueY) / (maxValueY - minValueY);
798
+ return {
799
+ x: x,
800
+ y: y
801
+ };
802
+ },
803
+ incrementX (stepSize) {
804
+ setXValue(xValue + stepSize > maxValueX ? maxValueX : $cBgAy$snapValueToStep(xValue + stepSize, minValueX, maxValueX, stepX));
805
+ },
806
+ incrementY (stepSize) {
807
+ setYValue(yValue + stepSize > maxValueY ? maxValueY : $cBgAy$snapValueToStep(yValue + stepSize, minValueY, maxValueY, stepY));
808
+ },
809
+ decrementX (stepSize) {
810
+ setXValue($cBgAy$snapValueToStep(xValue - stepSize, minValueX, maxValueX, stepX));
811
+ },
812
+ decrementY (stepSize) {
813
+ setYValue($cBgAy$snapValueToStep(yValue - stepSize, minValueY, maxValueY, stepY));
814
+ },
815
+ setDragging (isDragging) {
816
+ let wasDragging = isDraggingRef;
817
+ isDraggingRef = isDragging;
818
+ if (onChangeEnd && !isDragging && wasDragging) onChangeEnd(valueRef.current);
819
+ setDragging(isDragging);
820
+ },
821
+ isDragging: isDragging1,
822
+ getDisplayColor () {
823
+ return color.withChannelValue('alpha', 1);
824
+ }
825
+ };
686
826
  }
687
827
 
688
- function $a54bad0097d5f20f12ac194ac13764$var$roundDown(v) {
689
- let r = Math.floor(v);
690
828
 
691
- if (r === v) {
692
- return v - 1;
693
- } else {
694
- return r;
695
- }
696
- }
829
+ var $25a25ac0d1624665$exports = {};
697
830
 
698
- function $a54bad0097d5f20f12ac194ac13764$var$degToRad(deg) {
699
- return deg * Math.PI / 180;
700
- }
831
+ $parcel$export($25a25ac0d1624665$exports, "useColorSliderState", () => $25a25ac0d1624665$export$57bc203e1c9c6d44);
701
832
 
702
- function $a54bad0097d5f20f12ac194ac13764$var$radToDeg(rad) {
703
- return rad * 180 / Math.PI;
704
- } // 0deg = 3 o'clock. increases clockwise
705
833
 
706
834
 
707
- function $a54bad0097d5f20f12ac194ac13764$var$angleToCartesian(angle, radius) {
708
- let rad = $a54bad0097d5f20f12ac194ac13764$var$degToRad(360 - angle + 90);
709
- let x = Math.sin(rad) * radius;
710
- let y = Math.cos(rad) * radius;
711
- return {
712
- x,
713
- y
714
- };
715
- }
716
-
717
- function $a54bad0097d5f20f12ac194ac13764$var$cartesianToAngle(x, y, radius) {
718
- let deg = $a54bad0097d5f20f12ac194ac13764$var$radToDeg(Math.atan2(y / radius, x / radius));
719
- return (deg + 360) % 360;
835
+ function $25a25ac0d1624665$export$57bc203e1c9c6d44(props) {
836
+ let { channel: channel , value: value1 , defaultValue: defaultValue , onChange: onChange , locale: locale , ...otherProps } = props;
837
+ if (value1 == null && defaultValue == null) throw new Error('useColorSliderState requires a value or defaultValue');
838
+ let [color, setColor] = $cBgAy$useControlledState(value1 && $799cddbef784668f$export$4cde5df63f53f473(value1), defaultValue && $799cddbef784668f$export$4cde5df63f53f473(defaultValue), onChange);
839
+ let sliderState = $cBgAy$useSliderState({
840
+ ...color.getChannelRange(channel),
841
+ ...otherProps,
842
+ // Unused except in getThumbValueLabel, which is overridden below. null to appease TypeScript.
843
+ numberFormatter: null,
844
+ value: [
845
+ color.getChannelValue(channel)
846
+ ],
847
+ onChange ([v]) {
848
+ setColor(color.withChannelValue(channel, v));
849
+ },
850
+ onChangeEnd ([v]) {
851
+ // onChange will have already been called with the right value, this is just to trigger onChangeEnd
852
+ if (props.onChangeEnd) props.onChangeEnd(color.withChannelValue(channel, v));
853
+ }
854
+ });
855
+ let { step: step , pageSize: pageSize } = color.getChannelRange(channel);
856
+ return {
857
+ ...sliderState,
858
+ value: color,
859
+ setValue (value) {
860
+ setColor($799cddbef784668f$export$4cde5df63f53f473(value));
861
+ },
862
+ getDisplayColor () {
863
+ switch(channel){
864
+ case 'hue':
865
+ return $799cddbef784668f$export$6e865ea70d7724f(`hsl(${color.getChannelValue('hue')}, 100%, 50%)`);
866
+ case 'lightness':
867
+ case 'brightness':
868
+ case 'saturation':
869
+ case 'red':
870
+ case 'green':
871
+ case 'blue':
872
+ return color.withChannelValue('alpha', 1);
873
+ case 'alpha':
874
+ return color;
875
+ default:
876
+ throw new Error('Unknown color channel: ' + channel);
877
+ }
878
+ },
879
+ getThumbValueLabel () {
880
+ return color.formatChannelValue(channel, locale);
881
+ },
882
+ step: step,
883
+ pageSize: pageSize
884
+ };
720
885
  }
721
- /**
722
- * Provides state management for a color wheel component.
723
- * Color wheels allow users to adjust the hue of an HSL or HSB color value on a circular track.
724
- */
725
-
726
-
727
- export function useColorWheelState(props) {
728
- let {
729
- defaultValue,
730
- onChange,
731
- step = 1
732
- } = props;
733
886
 
734
- if (!props.value && !defaultValue) {
735
- defaultValue = $a54bad0097d5f20f12ac194ac13764$var$DEFAULT_COLOR;
736
- }
737
-
738
- let [value, setValue] = useControlledState($a54bad0097d5f20f12ac194ac13764$var$normalizeColor(props.value), $a54bad0097d5f20f12ac194ac13764$var$normalizeColor(defaultValue), onChange);
739
- let [isDragging, setDragging] = useState(false);
740
- let hue = value.getChannelValue('hue');
741
-
742
- function setHue(v) {
743
- if (v > 360) {
744
- // Make sure you can always get back to 0.
745
- v = 0;
746
- }
747
-
748
- v = $a54bad0097d5f20f12ac194ac13764$var$roundToStep($a54bad0097d5f20f12ac194ac13764$var$mod(v, 360), step);
749
-
750
- if (hue !== v) {
751
- setValue(value.withChannelValue('hue', v));
752
- }
753
- }
754
887
 
755
- return {
756
- value,
888
+ var $ee4262c74a467b07$exports = {};
757
889
 
758
- setValue(v) {
759
- setValue($a54bad0097d5f20f12ac194ac13764$var$normalizeColor(v));
760
- },
890
+ $parcel$export($ee4262c74a467b07$exports, "useColorWheelState", () => $ee4262c74a467b07$export$f4301076d9336137);
761
891
 
762
- hue,
763
- setHue,
764
892
 
765
- setHueFromPoint(x, y, radius) {
766
- setHue($a54bad0097d5f20f12ac194ac13764$var$cartesianToAngle(x, y, radius));
767
- },
768
893
 
769
- getThumbPosition(radius) {
770
- return $a54bad0097d5f20f12ac194ac13764$var$angleToCartesian(value.getChannelValue('hue'), radius);
771
- },
772
-
773
- increment(minStepSize) {
774
- if (minStepSize === void 0) {
775
- minStepSize = 0;
776
- }
777
-
778
- let newValue = hue + Math.max(minStepSize, step);
779
-
780
- if (newValue > 360) {
781
- // Make sure you can always get back to 0.
782
- newValue = 0;
783
- }
784
-
785
- setHue(newValue);
786
- },
787
-
788
- decrement(minStepSize) {
789
- if (minStepSize === void 0) {
790
- minStepSize = 0;
791
- }
792
-
793
- let s = Math.max(minStepSize, step);
794
-
795
- if (hue === 0) {
796
- // We can't just subtract step because this might be the case:
797
- // |(previous step) - 0| < step size
798
- setHue($a54bad0097d5f20f12ac194ac13764$var$roundDown(360 / s) * s);
799
- } else {
800
- setHue(hue - s);
801
- }
802
- },
803
-
804
- setDragging(value) {
805
- setDragging(value);
806
- },
807
-
808
- isDragging
809
- };
894
+ const $ee4262c74a467b07$var$DEFAULT_COLOR = $799cddbef784668f$export$6e865ea70d7724f('hsl(0, 100%, 50%)');
895
+ function $ee4262c74a467b07$var$roundToStep(value, step) {
896
+ return Math.round(value / step) * step;
810
897
  }
811
-
812
- function $a8b4ca293b41af7f07c8a5216dae5f3$export$useColor(value) {
813
- return useMemo(() => {
814
- if (typeof value === 'string') {
815
- try {
816
- return parseColor(value);
817
- } catch (err) {
818
- return undefined;
819
- }
898
+ function $ee4262c74a467b07$var$mod(n, m) {
899
+ return (n % m + m) % m;
900
+ }
901
+ function $ee4262c74a467b07$var$roundDown(v) {
902
+ let r = Math.floor(v);
903
+ if (r === v) return v - 1;
904
+ else return r;
905
+ }
906
+ function $ee4262c74a467b07$var$degToRad(deg) {
907
+ return deg * Math.PI / 180;
908
+ }
909
+ function $ee4262c74a467b07$var$radToDeg(rad) {
910
+ return rad * 180 / Math.PI;
911
+ }
912
+ // 0deg = 3 o'clock. increases clockwise
913
+ function $ee4262c74a467b07$var$angleToCartesian(angle, radius) {
914
+ let rad = $ee4262c74a467b07$var$degToRad(360 - angle + 90);
915
+ let x = Math.sin(rad) * radius;
916
+ let y = Math.cos(rad) * radius;
917
+ return {
918
+ x: x,
919
+ y: y
920
+ };
921
+ }
922
+ function $ee4262c74a467b07$var$cartesianToAngle(x, y, radius) {
923
+ let deg = $ee4262c74a467b07$var$radToDeg(Math.atan2(y / radius, x / radius));
924
+ return (deg + 360) % 360;
925
+ }
926
+ function $ee4262c74a467b07$export$f4301076d9336137(props) {
927
+ let { defaultValue: defaultValue , onChange: onChange , onChangeEnd: onChangeEnd } = props;
928
+ if (!props.value && !defaultValue) defaultValue = $ee4262c74a467b07$var$DEFAULT_COLOR;
929
+ let [value, setValue] = $cBgAy$useControlledState($799cddbef784668f$export$4cde5df63f53f473(props.value), $799cddbef784668f$export$4cde5df63f53f473(defaultValue), onChange);
930
+ let valueRef = $cBgAy$useRef(value);
931
+ valueRef.current = value;
932
+ let channelRange = value.getChannelRange('hue');
933
+ let { minValue: minValueX , maxValue: maxValueX , step: step , pageSize: pageStep } = channelRange;
934
+ let [isDragging1, setDragging] = $cBgAy$useState(false);
935
+ let isDraggingRef = $cBgAy$useRef(false).current;
936
+ let hue = value.getChannelValue('hue');
937
+ function setHue(v) {
938
+ if (v > 360) // Make sure you can always get back to 0.
939
+ v = 0;
940
+ v = $ee4262c74a467b07$var$roundToStep($ee4262c74a467b07$var$mod(v, 360), step);
941
+ if (hue !== v) {
942
+ let color = value.withChannelValue('hue', v);
943
+ valueRef.current = color;
944
+ setValue(color);
945
+ }
820
946
  }
821
-
822
- return value;
823
- }, [value]);
947
+ return {
948
+ value: value,
949
+ step: step,
950
+ pageStep: pageStep,
951
+ setValue (v) {
952
+ let color = $799cddbef784668f$export$4cde5df63f53f473(v);
953
+ valueRef.current = color;
954
+ setValue(color);
955
+ },
956
+ hue: hue,
957
+ setHue: setHue,
958
+ setHueFromPoint (x, y, radius) {
959
+ setHue($ee4262c74a467b07$var$cartesianToAngle(x, y, radius));
960
+ },
961
+ getThumbPosition (radius) {
962
+ return $ee4262c74a467b07$var$angleToCartesian(value.getChannelValue('hue'), radius);
963
+ },
964
+ increment (stepSize = 1) {
965
+ let s = Math.max(stepSize, step);
966
+ let newValue = hue + s;
967
+ if (newValue >= maxValueX) // Make sure you can always get back to 0.
968
+ newValue = minValueX;
969
+ setHue($ee4262c74a467b07$var$roundToStep($ee4262c74a467b07$var$mod(newValue, 360), s));
970
+ },
971
+ decrement (stepSize = 1) {
972
+ let s = Math.max(stepSize, step);
973
+ if (hue === 0) // We can't just subtract step because this might be the case:
974
+ // |(previous step) - 0| < step size
975
+ setHue($ee4262c74a467b07$var$roundDown(360 / s) * s);
976
+ else setHue($ee4262c74a467b07$var$roundToStep($ee4262c74a467b07$var$mod(hue - s, 360), s));
977
+ },
978
+ setDragging (isDragging) {
979
+ let wasDragging = isDraggingRef;
980
+ isDraggingRef = isDragging;
981
+ if (onChangeEnd && !isDragging && wasDragging) onChangeEnd(valueRef.current);
982
+ setDragging(isDragging);
983
+ },
984
+ isDragging: isDragging1,
985
+ getDisplayColor () {
986
+ return value.toFormat('hsl').withChannelValue('saturation', 100).withChannelValue('lightness', 50);
987
+ }
988
+ };
824
989
  }
825
990
 
826
- const $f1bad1ec575cba40fc263dc06b9eb3a9$var$MIN_COLOR = parseColor('#000000');
827
- const $f1bad1ec575cba40fc263dc06b9eb3a9$var$MAX_COLOR = parseColor('#FFFFFF');
828
- const $f1bad1ec575cba40fc263dc06b9eb3a9$var$MIN_COLOR_INT = $f1bad1ec575cba40fc263dc06b9eb3a9$var$MIN_COLOR.toHexInt();
829
- const $f1bad1ec575cba40fc263dc06b9eb3a9$var$MAX_COLOR_INT = $f1bad1ec575cba40fc263dc06b9eb3a9$var$MAX_COLOR.toHexInt();
830
- /**
831
- * Provides state management for a color field component. Color fields allow
832
- * users to enter and adjust a hex color value.
833
- */
834
-
835
- export function useColorFieldState(props) {
836
- let {
837
- step = 1,
838
- value,
839
- defaultValue,
840
- onChange
841
- } = props;
842
- let initialValue = $a8b4ca293b41af7f07c8a5216dae5f3$export$useColor(value);
843
- let initialDefaultValue = $a8b4ca293b41af7f07c8a5216dae5f3$export$useColor(defaultValue);
844
- let [colorValue, setColorValue] = useControlledState(initialValue, initialDefaultValue, onChange);
845
- let initialInputValue = (value || defaultValue) && colorValue ? colorValue.toString('hex') : '';
846
- let [inputValue, setInputValue] = useState(initialInputValue);
847
- useEffect(() => {
848
- setInputValue(inputValue => {
849
- // Parse color from current inputValue.
850
- // Only update the input value if the parseColorValue is not equivalent.
851
- if (!inputValue.length && colorValue) {
852
- return colorValue.toString('hex');
853
- }
854
-
855
- try {
856
- let currentColor = parseColor(inputValue.startsWith('#') ? inputValue : "#" + inputValue);
857
-
858
- if (currentColor.toHexInt() !== (colorValue == null ? void 0 : colorValue.toHexInt())) {
859
- return colorValue ? colorValue.toString('hex') : '';
860
- }
861
- } catch (err) {// ignore
862
- }
863
991
 
864
- return inputValue;
865
- });
866
- }, [inputValue, colorValue, setInputValue]);
992
+ var $b335ada08155d9c0$exports = {};
867
993
 
868
- let increment = () => setColorValue(prevColor => $f1bad1ec575cba40fc263dc06b9eb3a9$var$addColorValue(prevColor, step));
994
+ $parcel$export($b335ada08155d9c0$exports, "useColorFieldState", () => $b335ada08155d9c0$export$d52a01683abdfcd6);
869
995
 
870
- let decrement = () => setColorValue(prevColor => $f1bad1ec575cba40fc263dc06b9eb3a9$var$addColorValue(prevColor, -step));
871
996
 
872
- let incrementToMax = () => setColorValue(prevColor => $f1bad1ec575cba40fc263dc06b9eb3a9$var$addColorValue(prevColor, $f1bad1ec575cba40fc263dc06b9eb3a9$var$MAX_COLOR_INT));
873
997
 
874
- let decrementToMin = () => setColorValue(prevColor => $f1bad1ec575cba40fc263dc06b9eb3a9$var$addColorValue(prevColor, -$f1bad1ec575cba40fc263dc06b9eb3a9$var$MAX_COLOR_INT));
998
+ function $aa90ad8b2b1d015f$export$5aadd9c0606af5c2(value) {
999
+ return $cBgAy$useMemo(()=>{
1000
+ if (typeof value === 'string') try {
1001
+ return $799cddbef784668f$export$6e865ea70d7724f(value);
1002
+ } catch (err) {
1003
+ return undefined;
1004
+ }
1005
+ return value;
1006
+ }, [
1007
+ value
1008
+ ]);
1009
+ }
875
1010
 
876
- let setFieldInputValue = value => {
877
- var _value$match;
878
1011
 
879
- value = (_value$match = value.match(/^#?[0-9a-f]{0,6}$/i)) == null ? void 0 : _value$match[0];
880
1012
 
881
- if (value !== undefined) {
882
- if (!value.length && colorValue) {
883
- setColorValue(null);
884
- return;
885
- }
886
1013
 
887
- try {
888
- let newColor = parseColor(value.startsWith('#') ? value : "#" + value);
889
- setColorValue(prevColor => {
890
- setInputValue(value);
891
- return prevColor && prevColor.toHexInt() === newColor.toHexInt() ? prevColor : newColor;
892
- });
893
- } catch (err) {
894
- setInputValue(value);
895
- }
1014
+ const $b335ada08155d9c0$var$MIN_COLOR = $799cddbef784668f$export$6e865ea70d7724f('#000000');
1015
+ const $b335ada08155d9c0$var$MAX_COLOR = $799cddbef784668f$export$6e865ea70d7724f('#FFFFFF');
1016
+ const $b335ada08155d9c0$var$MIN_COLOR_INT = $b335ada08155d9c0$var$MIN_COLOR.toHexInt();
1017
+ const $b335ada08155d9c0$var$MAX_COLOR_INT = $b335ada08155d9c0$var$MAX_COLOR.toHexInt();
1018
+ function $b335ada08155d9c0$export$d52a01683abdfcd6(props) {
1019
+ let { value: value1 , defaultValue: defaultValue , onChange: onChange } = props;
1020
+ let { step: step } = $b335ada08155d9c0$var$MIN_COLOR.getChannelRange('red');
1021
+ let initialValue = $aa90ad8b2b1d015f$export$5aadd9c0606af5c2(value1);
1022
+ let initialDefaultValue = $aa90ad8b2b1d015f$export$5aadd9c0606af5c2(defaultValue);
1023
+ let [colorValue, setColorValue] = $cBgAy$useControlledState(initialValue, initialDefaultValue, onChange);
1024
+ let [inputValue, setInputValue] = $cBgAy$useState(()=>(value1 || defaultValue) && colorValue ? colorValue.toString('hex') : ''
1025
+ );
1026
+ let safelySetColorValue = (newColor)=>{
1027
+ if (!colorValue || !newColor) {
1028
+ setColorValue(newColor);
1029
+ return;
1030
+ }
1031
+ if (newColor.toHexInt() !== colorValue.toHexInt()) {
1032
+ setColorValue(newColor);
1033
+ return;
1034
+ }
1035
+ };
1036
+ let prevValue = $cBgAy$useRef(colorValue);
1037
+ if (prevValue.current !== colorValue) {
1038
+ setInputValue(colorValue ? colorValue.toString('hex') : '');
1039
+ prevValue.current = colorValue;
896
1040
  }
897
- };
898
-
899
- let commit = () => {
900
- setInputValue(colorValue ? colorValue.toString('hex') : '');
901
- };
902
-
903
- return {
904
- colorValue,
905
- inputValue,
906
- setInputValue: setFieldInputValue,
907
- commit,
908
- increment,
909
- incrementToMax,
910
- decrement,
911
- decrementToMin
912
- };
1041
+ let parsedValue = $cBgAy$useMemo(()=>{
1042
+ let color;
1043
+ try {
1044
+ color = $799cddbef784668f$export$6e865ea70d7724f(inputValue.startsWith('#') ? inputValue : `#${inputValue}`);
1045
+ } catch (err) {
1046
+ color = null;
1047
+ }
1048
+ return color;
1049
+ }, [
1050
+ inputValue
1051
+ ]);
1052
+ let parsed = $cBgAy$useRef(null);
1053
+ parsed.current = parsedValue;
1054
+ let commit = ()=>{
1055
+ // Set to empty state if input value is empty
1056
+ if (!inputValue.length) {
1057
+ safelySetColorValue(null);
1058
+ setInputValue(value1 === undefined ? '' : colorValue.toString('hex'));
1059
+ return;
1060
+ }
1061
+ // if it failed to parse, then reset input to formatted version of current number
1062
+ if (parsed.current == null) {
1063
+ setInputValue(colorValue ? colorValue.toString('hex') : '');
1064
+ return;
1065
+ }
1066
+ safelySetColorValue(parsed.current);
1067
+ // in a controlled state, the numberValue won't change, so we won't go back to our old input without help
1068
+ let newColorValue = '';
1069
+ if (colorValue) newColorValue = colorValue.toString('hex');
1070
+ setInputValue(newColorValue);
1071
+ };
1072
+ let increment = ()=>{
1073
+ let newValue = $b335ada08155d9c0$var$addColorValue(parsed.current, step);
1074
+ // if we've arrived at the same value that was previously in the state, the
1075
+ // input value should be updated to match
1076
+ // ex type 4, press increment, highlight the number in the input, type 4 again, press increment
1077
+ // you'd be at 5, then incrementing to 5 again, so no re-render would happen and 4 would be left in the input
1078
+ if (newValue === colorValue) setInputValue(newValue.toString('hex'));
1079
+ safelySetColorValue(newValue);
1080
+ };
1081
+ let decrement = ()=>{
1082
+ let newValue = $b335ada08155d9c0$var$addColorValue(parsed.current, -step);
1083
+ // if we've arrived at the same value that was previously in the state, the
1084
+ // input value should be updated to match
1085
+ // ex type 4, press increment, highlight the number in the input, type 4 again, press increment
1086
+ // you'd be at 5, then incrementing to 5 again, so no re-render would happen and 4 would be left in the input
1087
+ if (newValue === colorValue) setInputValue(newValue.toString('hex'));
1088
+ safelySetColorValue(newValue);
1089
+ };
1090
+ let incrementToMax = ()=>safelySetColorValue($b335ada08155d9c0$var$MAX_COLOR)
1091
+ ;
1092
+ let decrementToMin = ()=>safelySetColorValue($b335ada08155d9c0$var$MIN_COLOR)
1093
+ ;
1094
+ let validate = (value)=>{
1095
+ var ref;
1096
+ return value === '' || !!((ref = value.match(/^#?[0-9a-f]{0,6}$/i)) === null || ref === void 0 ? void 0 : ref[0]);
1097
+ };
1098
+ return {
1099
+ validate: validate,
1100
+ colorValue: colorValue,
1101
+ inputValue: inputValue,
1102
+ setInputValue: setInputValue,
1103
+ commit: commit,
1104
+ increment: increment,
1105
+ incrementToMax: incrementToMax,
1106
+ decrement: decrement,
1107
+ decrementToMin: decrementToMin
1108
+ };
1109
+ }
1110
+ function $b335ada08155d9c0$var$addColorValue(color, step) {
1111
+ let newColor = color ? color : $b335ada08155d9c0$var$MIN_COLOR;
1112
+ let colorInt = newColor.toHexInt();
1113
+ let clampInt = Math.min(Math.max(colorInt + step, $b335ada08155d9c0$var$MIN_COLOR_INT), $b335ada08155d9c0$var$MAX_COLOR_INT);
1114
+ if (clampInt !== colorInt) {
1115
+ let newColorString = `#${clampInt.toString(16).padStart(6, '0').toUpperCase()}`;
1116
+ newColor = $799cddbef784668f$export$6e865ea70d7724f(newColorString);
1117
+ }
1118
+ return newColor;
913
1119
  }
914
1120
 
915
- function $f1bad1ec575cba40fc263dc06b9eb3a9$var$addColorValue(color, step) {
916
- let newColor = color ? color : $f1bad1ec575cba40fc263dc06b9eb3a9$var$MIN_COLOR;
917
- let colorInt = newColor.toHexInt();
918
- let newColorString = color ? color.toString('hex') : '';
919
- let clampInt = Math.min(Math.max(colorInt + step, $f1bad1ec575cba40fc263dc06b9eb3a9$var$MIN_COLOR_INT), $f1bad1ec575cba40fc263dc06b9eb3a9$var$MAX_COLOR_INT);
920
1121
 
921
- if (clampInt !== colorInt) {
922
- newColorString = "#" + clampInt.toString(16).padStart(6, '0').toUpperCase();
923
- newColor = parseColor(newColorString);
924
- }
925
1122
 
926
- return newColor;
927
- }
1123
+
1124
+ export {$799cddbef784668f$export$6e865ea70d7724f as parseColor, $6e14a98a7f67141d$export$6df7f0e2cabc7eef as useColorAreaState, $25a25ac0d1624665$export$57bc203e1c9c6d44 as useColorSliderState, $ee4262c74a467b07$export$f4301076d9336137 as useColorWheelState, $b335ada08155d9c0$export$d52a01683abdfcd6 as useColorFieldState};
928
1125
  //# sourceMappingURL=module.js.map