@luzmo/lucero 0.0.39 → 1.0.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/components/accordion/index.cjs +4 -4
  2. package/components/accordion/index.js +5 -5
  3. package/components/action-bar/index.cjs +1 -1
  4. package/components/action-bar/index.js +1 -1
  5. package/components/action-button/index.cjs +2 -2
  6. package/components/action-button/index.js +1 -1
  7. package/components/action-menu/index.cjs +1 -1
  8. package/components/action-menu/index.js +2 -2
  9. package/components/button/index.cjs +1 -1
  10. package/components/button/index.js +2 -2
  11. package/components/calendar/index.cjs +1 -1
  12. package/components/calendar/index.js +1 -1
  13. package/components/checkbox/index.cjs +1 -1
  14. package/components/checkbox/index.js +1 -1
  15. package/components/{clear-button-DoeRUWQ3.js → clear-button-BbVqNU-g.js} +1 -1
  16. package/components/{clear-button-Qi1pMA5S.cjs → clear-button-DYdeFsS8.cjs} +1 -1
  17. package/components/{close-button-BFMBEw3q.cjs → close-button-CpfKibqg.cjs} +1 -1
  18. package/components/{close-button-BWXdHSx3.js → close-button-DzOZZmkY.js} +1 -1
  19. package/components/color-area/color-area.d.ts +44 -6
  20. package/components/color-area/index.cjs +5 -5
  21. package/components/color-area/index.js +70 -62
  22. package/components/color-controller-DTp1juRz.js +3198 -0
  23. package/components/color-controller-_ZwyhvaU.cjs +18 -0
  24. package/components/color-field/color-field.d.ts +3 -3
  25. package/components/color-field/index.cjs +5 -5
  26. package/components/color-field/index.js +25 -28
  27. package/components/color-menu/index.cjs +3 -3
  28. package/components/color-menu/index.js +2 -3
  29. package/components/color-slider/index.cjs +1 -40
  30. package/components/color-slider/index.js +6 -296
  31. package/components/date-time-picker/index.cjs +3 -3
  32. package/components/date-time-picker/index.js +2 -2
  33. package/components/icon/index.cjs +1 -1
  34. package/components/icon/index.js +1 -1
  35. package/components/{index-BLWuwZXx.cjs → index-BQoI8AD3.cjs} +3 -3
  36. package/components/index-BwxgAdzi.cjs +57 -0
  37. package/components/{index-A-yOTB_d.js → index-Cb9zsiz6.js} +1 -1
  38. package/components/index-HjQa8tew.js +1174 -0
  39. package/components/index.cjs +1 -1
  40. package/components/index.js +7 -7
  41. package/components/{luzmo-icons-DletXGWU.cjs → luzmo-icons-D47EGj-3.cjs} +2 -2
  42. package/components/{luzmo-icons-DbwDQtuO.js → luzmo-icons-NEyaMpEM.js} +24 -24
  43. package/components/menu/index.cjs +5 -5
  44. package/components/menu/index.js +2 -2
  45. package/components/number-field/index.cjs +3 -3
  46. package/components/number-field/index.js +5 -5
  47. package/components/options/index.cjs +4 -4
  48. package/components/options/index.js +15 -15
  49. package/components/overlay/index.cjs +1 -1
  50. package/components/overlay/index.js +2 -2
  51. package/components/{overlay-DaOKAKMl.js → overlay-BtZCJ2M0.js} +1 -2
  52. package/components/{overlay-lzq2PziH.cjs → overlay-DTCm3y_-.cjs} +1 -1
  53. package/components/picker/index.cjs +1 -1
  54. package/components/picker/index.js +2 -2
  55. package/components/{picker-BmoXv1jt.js → picker-CAYj4hBD.js} +1 -1
  56. package/components/{picker-DWsBWdPN.cjs → picker-apS0Zrly.cjs} +5 -5
  57. package/components/picker-button/index.cjs +1 -1
  58. package/components/picker-button/index.js +1 -1
  59. package/components/search/index.cjs +4 -4
  60. package/components/search/index.js +2 -2
  61. package/components/select/index.cjs +9 -9
  62. package/components/select/index.js +1 -1
  63. package/components/swatch/index.cjs +2 -2
  64. package/components/swatch/index.js +3 -3
  65. package/components/tabs/index.cjs +3 -3
  66. package/components/tabs/index.js +1 -1
  67. package/components/tags/index.cjs +1 -1
  68. package/components/tags/index.js +1 -1
  69. package/components/text-field/index.cjs +2 -2
  70. package/components/text-field/index.js +5 -5
  71. package/components/{text-field-BIADXoLC.js → text-field-B9IkRRxO.js} +1 -1
  72. package/components/{text-field-D5d_Gt0t.cjs → text-field-BSIXGkFs.cjs} +3 -3
  73. package/components/toast/index.cjs +3 -3
  74. package/components/toast/index.js +2 -2
  75. package/components/unit-input/index.cjs +3 -3
  76. package/components/unit-input/index.js +1 -1
  77. package/custom-elements.json +1 -1
  78. package/package.json +1 -1
  79. package/utils/reactive-controllers/color-controller.d.ts +224 -0
  80. package/components/color-Bg3tYsAQ.js +0 -178
  81. package/components/color-DphK4hwx.cjs +0 -18
  82. package/components/index-C1chwzNp.js +0 -727
  83. package/components/index-DCKCHDTt.cjs +0 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luzmo/lucero",
3
- "version": "0.0.39",
3
+ "version": "1.0.1-alpha.0",
4
4
  "homepage": "https://luzmo.com",
5
5
  "description": "Lucero - The design system for Luzmo",
6
6
  "type": "module",
@@ -0,0 +1,224 @@
1
+ import Color, { type ColorObject, type ColorTypes as DefaultColorTypes } from 'colorjs.io';
2
+ import ColorSpace from 'colorjs.io';
3
+ import type { ReactiveElement } from 'lit';
4
+ /**
5
+ * Represents various color types that can be used in the application.
6
+ *
7
+ * This type can be one of the following:
8
+ * - `DefaultColorTypes`: A predefined set of color types.
9
+ * - An object representing an RGBA color with properties:
10
+ *
11
+ * - `r`: Red component, can be a number or string.
12
+ * - `g`: Green component, can be a number or string.
13
+ * - `b`: Blue component, can be a number or string.
14
+ * - `a` (optional): Alpha component, can be a number or string.
15
+ *
16
+ * - An object representing an HSLA color with properties:
17
+ *
18
+ * - `h`: Hue component, can be a number or string.
19
+ * - `s`: Saturation component, can be a number or string.
20
+ * - `l`: Lightness component, can be a number or string.
21
+ * - `a` (optional): Alpha component, can be a number or string.
22
+ *
23
+ * - An object representing an HSVA color with properties:
24
+ *
25
+ * - `h`: Hue component, can be a number or string.
26
+ * - `s`: Saturation component, can be a number or string.
27
+ * - `v`: Value component, can be a number or string.
28
+ * - `a` (optional): Alpha component, can be a number or string.
29
+ */
30
+ type ColorTypes = DefaultColorTypes | {
31
+ r: number | string;
32
+ g: number | string;
33
+ b: number | string;
34
+ a?: number | string;
35
+ } | {
36
+ h: number | string;
37
+ s: number | string;
38
+ l: number | string;
39
+ a?: number | string;
40
+ } | {
41
+ h: number | string;
42
+ s: number | string;
43
+ v: number | string;
44
+ a?: number | string;
45
+ };
46
+ export type { ColorTypes };
47
+ type ColorValidationResult = {
48
+ spaceId: string | null;
49
+ coords: number[];
50
+ isValid: boolean;
51
+ alpha: number;
52
+ };
53
+ /**
54
+ * The `ColorController` class is responsible for managing and validating color values
55
+ * in various color spaces (RGB, HSL, HSV, Hex). It provides methods to set, get, and
56
+ * validate colors, as well as convert between different color formats.
57
+ *
58
+ * @class
59
+ * @property {Color} color - Gets or sets the current color value.
60
+ * @property {ColorTypes} colorValue - Gets the color value in various formats based on the original color input.
61
+ * @property {number} hue - Gets or sets the hue value of the current color.
62
+ *
63
+ * @method validateColorString(color: string): ColorValidationResult - Validates a color string and returns the validation result.
64
+ * @method getColor(format: string | ColorSpace): ColorObject - Converts the current color to the specified format.
65
+ * @method getHslString(): string - Returns the current color in HSL string format.
66
+ * @method savePreviousColor(): void - Saves the current color as the previous color.
67
+ * @method restorePreviousColor(): void - Restores the previous color.
68
+ *
69
+ * @constructor
70
+ * @param {ReactiveElement} host - The host element that uses this controller.
71
+ * @param {Object} [options] - Optional configuration options.
72
+ * @param {string} [options.manageAs] - Specifies the color space to manage the color as.
73
+ */
74
+ export declare class ColorController {
75
+ get color(): Color;
76
+ /**
77
+ * Validates a color string and returns a result indicating the color space,
78
+ * coordinates, alpha value, and whether the color is valid.
79
+ *
80
+ * @param color - The color string to validate. Supported formats include:
81
+ * - RGB: `rgb(r, g, b)`, `rgba(r, g, b, a)`, `rgb r g b`, `rgba r g b a`
82
+ * - HSL: `hsl(h, s, l)`, `hsla(h, s, l, a)`, `hsl h s l`, `hsla h s l a`
83
+ * - HSV: `hsv(h, s, v)`, `hsva(h, s, v, a)`, `hsv h s v`, `hsva h s v a`
84
+ * - HEX: `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`
85
+ *
86
+ * @returns An object containing the following properties:
87
+ * - `spaceId`: The color space identifier (`'srgb'`, `'hsl'`, or `'hsv'`).
88
+ * - `coords`: An array of numeric values representing the color coordinates.
89
+ * - `alpha`: The alpha value of the color (0 to 1).
90
+ * - `isValid`: A boolean indicating whether the color string is valid.
91
+ */
92
+ validateColorString(color: string): ColorValidationResult;
93
+ /**
94
+ * Represents the color state of the component.
95
+ * Initialized with an HSV color model with hue 0, saturation 100, and value 100, and an alpha value of 1.
96
+ *
97
+ * @private
98
+ * @type {Color}
99
+ */
100
+ private _color;
101
+ /**
102
+ * Represents the original color value provided by the user.
103
+ *
104
+ * @private
105
+ * @type {ColorTypes}
106
+ */
107
+ private _colorOrigin;
108
+ /**
109
+ * Gets the original color value provided by the user.
110
+ *
111
+ * @returns The original color value.
112
+ */
113
+ get colorOrigin(): ColorTypes;
114
+ /**
115
+ * Sets the original color value provided by the user.
116
+ *
117
+ * @param colorOrigin - The original color value to set.
118
+ */
119
+ set colorOrigin(colorOrigin: ColorTypes);
120
+ /**
121
+ * An optional string property that specifies how the color should be managed(its value is the name of color space in which color object will be managed).
122
+ * This property can be used to define a specific management strategy or identifier.
123
+ */
124
+ private manageAs?;
125
+ /**
126
+ * Stores the previous color value.
127
+ * This is used to keep track of the color before any changes are made.
128
+ *
129
+ * @private
130
+ */
131
+ private _previousColor;
132
+ /**
133
+ * Sets the color value for the controller. The color can be provided in various formats:
134
+ * - A string representing a color name, hex code, or other color format.
135
+ * - An instance of the `Color` class.
136
+ * - An object containing color properties such as `h`, `s`, `l`, `v`, `r`, `g`, `b`, and optionally `a`.
137
+ *
138
+ * The method validates and parses the input color, converting it to a `Color` instance.
139
+ * If the color is invalid, it attempts to parse it as a hex code or returns without setting a new color.
140
+ *
141
+ * @param color - The color value to set. It can be a string, an instance of `Color`, or an object with color properties.
142
+ */
143
+ set color(color: ColorTypes);
144
+ /**
145
+ * Gets the color value in various formats based on the original color input.
146
+ *
147
+ * The method determines the color space of the original color input and converts
148
+ * the color to the appropriate format. The supported color spaces are:
149
+ * - HSV (Hue, Saturation, Value)
150
+ * - HSL (Hue, Saturation, Lightness)
151
+ * - Hexadecimal (with or without alpha)
152
+ * - RGB (Red, Green, Blue) with optional alpha
153
+ *
154
+ * @returns The color value in the appropriate format.
155
+ *
156
+ * The method handles the following cases:
157
+ * - If the original color input is a string, it checks the prefix to determine the color space.
158
+ * - If the original color input is an object, it checks the properties to determine the color space.
159
+ * - If the original color input is not provided, it defaults to the current color space of the color object.
160
+ *
161
+ * The returned color value can be in one of the following formats:
162
+ * - `hsv(h, s%, v%)` or `hsva(h, s%, v%, a)`
163
+ * - `hsl(h, s%, l%)` or `hsla(h, s%, l%, a)`
164
+ * - `#rrggbb` or `#rrggbbaa`
165
+ * - `rgb(r, g, b)` or `rgba(r, g, b, a)`
166
+ * - `{ h, s, v, a }` for HSV object
167
+ * - `{ h, s, l, a }` for HSL object
168
+ * - `{ r, g, b, a }` for RGB object
169
+ */
170
+ get colorValue(): ColorTypes;
171
+ protected host: ReactiveElement;
172
+ /**
173
+ * Gets the hue value of the current color in HSL format.
174
+ *
175
+ * @returns The hue value as a number.
176
+ */
177
+ get hue(): number;
178
+ /**
179
+ * Sets the hue value of the color and requests an update from the host.
180
+ *
181
+ * @param hue - The hue value to set, represented as a number.
182
+ */
183
+ set hue(hue: number);
184
+ /**
185
+ * Creates an instance of ColorController.
186
+ *
187
+ * @param host - The ReactiveElement that this controller is associated with.
188
+ * @param options - An object containing optional parameters.
189
+ * @param options.manageAs - A string to manage the controller as a specific type.
190
+ */
191
+ constructor(host: ReactiveElement, { manageAs }?: {
192
+ manageAs?: string;
193
+ });
194
+ /**
195
+ * Converts the current color to the specified format.
196
+ *
197
+ * @param format - The desired color format. It can be a string representing one of the valid formats
198
+ * ('srgb', 'hsva', 'hsv', 'hsl', 'hsla') or a ColorSpace object.
199
+ * @returns The color object in the specified format.
200
+ * @throws Will throw an error if the provided format is not a valid string format.
201
+ */
202
+ getColor(format: string | ColorSpace): ColorObject;
203
+ /**
204
+ * Converts the current color to an HSL string representation.
205
+ *
206
+ * @returns The HSL string representation of the current color.
207
+ */
208
+ getHslString(): string;
209
+ /**
210
+ * Saves the current color state by cloning the current color and storing it
211
+ * as the previous color. This allows for the ability to revert to the previous
212
+ * color state if needed.
213
+ *
214
+ * @returns
215
+ */
216
+ savePreviousColor(): void;
217
+ /**
218
+ * Restores the color to the previously saved color value.
219
+ *
220
+ * This method sets the current color (`_color`) to the previously stored color (`_previousColor`).
221
+ */
222
+ restorePreviousColor(): void;
223
+ }
224
+ export { type default as Color } from 'colorjs.io';
@@ -1,178 +0,0 @@
1
- /*! * Lucero - The design system for Luzmo.
2
- *
3
- * Copyright © 2025 Luzmo
4
- * All rights reserved.
5
- * Lucero (“Luzmo Design System”) must be used according to the Luzmo Terms of Service.
6
- * This license allows users with a current active Luzmo account to use Lucero.
7
- * This license terminates automatically if a user no longer has an active Luzmo account.
8
- * Please view the Luzmo Terms of Service at: https://www.luzmo.com/information-pages/terms-of-use.
9
- *
10
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
11
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
15
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
16
- * SOFTWARE.
17
- * */
18
- import { T as c } from "./index-C1chwzNp.js";
19
- const _ = /^hs[v|l]a?\s?\((\d{1,3}\.?\d*?),?\s?(\d{1,3})/, f = /(^hs[v|l]a?\s?\()\d{1,3}\.?\d*?(,?\s?)\d{1,3}/, S = /(^hs[v|l]a?\()\d{1,3}/, g = (p, s) => s ? p.toHexString() : p.toHex();
20
- class C {
21
- constructor(s, {
22
- applyColorToState: i,
23
- extractColorFromState: e,
24
- maintains: h
25
- }) {
26
- this.maintains = "hue", this._hue = 0, this._opacity = 1, this.getColorProcesses = {
27
- rgb: (t, o) => o ? t.toRgbString() : t.toRgb(),
28
- prgb: (t, o) => o ? t.toPercentageRgbString() : t.toPercentageRgb(),
29
- hex8: (t, o) => o ? t.toHex8String() : t.toHex8(),
30
- name: (t) => t.toName() || t.toRgbString(),
31
- hsl: (t, o) => {
32
- if (this.maintains === "hue") {
33
- if (o)
34
- return t.toHslString().replace(S, `$1${this.hue}`);
35
- const { s: a, l: u, a: v } = t.toHsl();
36
- return { h: this.hue, s: a, l: u, a: v };
37
- }
38
- if (o)
39
- return t.toHslString().replace(
40
- f,
41
- `$1${this.hue}$2${this.saturation}`
42
- );
43
- const { s: r, l: n, a: l } = t.toHsl();
44
- return { h: this.hue, s: r, l: n, a: l };
45
- },
46
- hsv: (t, o) => {
47
- if (this.maintains === "hue") {
48
- if (o)
49
- return t.toHsvString().replace(S, `$1${this.hue}`);
50
- const { s: a, v: u, a: v } = t.toHsv();
51
- return { h: this.hue, s: a, v: u, a: v };
52
- }
53
- if (o)
54
- return t.toHsvString().replace(
55
- f,
56
- `$1${this.hue}$2${this.saturation}`
57
- );
58
- const { s: r, v: n, a: l } = t.toHsv();
59
- return { h: this.hue, s: r, v: n, a: l };
60
- },
61
- hex: g,
62
- hex3: g,
63
- hex4: g,
64
- hex6: g
65
- }, this._color = new c({ h: 0, s: 1, v: 1 }), this._previousColor = new c({ h: 0, s: 1, v: 1 }), this._format = {
66
- format: "",
67
- isString: !1
68
- }, this.host = s, this.applyColorToState = i, this.extractColorFromState = e, this.maintains = h || this.maintains;
69
- }
70
- setColorProcess(s, i, e, h) {
71
- this.maintains === "hue" ? this.setColorMaintainHue(s, i, e, h) : this.maintains === "saturation" && this.setColorMaintainSaturation(
72
- s,
73
- i,
74
- e,
75
- h
76
- );
77
- }
78
- setColorMaintainHue(s, i, e, h) {
79
- const { h: t, s: o, v: r, a: n } = this._color.toHsv();
80
- let l;
81
- if (h && e.startsWith("hs")) {
82
- const a = _.exec(i);
83
- if (a !== null) {
84
- const [, u] = a;
85
- l = Number(u);
86
- }
87
- } else if (!h && e.startsWith("hs")) {
88
- const a = s.originalInput;
89
- l = Object.values(a)[0];
90
- }
91
- this.hue = l || t, this.opacity = n ?? 1, this.applyColorToState({ h: t, s: o, v: r, a: n });
92
- }
93
- setColorMaintainSaturation(s, i, e, h) {
94
- const { a: t } = this._color.toHsv();
95
- if (h && e.startsWith("hs")) {
96
- const o = _.exec(i);
97
- if (o !== null) {
98
- const [, r, n] = o;
99
- this.hue = Number(r), this.saturation = Number(n);
100
- }
101
- } else if (!h && e.startsWith("hs")) {
102
- const o = s.originalInput, r = Object.values(o);
103
- this.hue = r[0], this.saturation = r[1];
104
- } else {
105
- const { h: o } = s.toHsv();
106
- this.hue = o;
107
- }
108
- this.opacity = t ?? 1, this.applyColorToState(s.toHsv());
109
- }
110
- applyColorFromState() {
111
- this._color = new c(this.extractColorFromState(this));
112
- }
113
- get hue() {
114
- return this._hue;
115
- }
116
- set hue(s) {
117
- const i = Math.min(360, Math.max(0, s));
118
- if (i === this.hue)
119
- return;
120
- const e = this.hue, { s: h, v: t, a: o } = this._color.toHsv();
121
- this._color = new c({ h: i, s: h, v: t, a: o }), this._hue = i, this.host.requestUpdate("hue", e);
122
- }
123
- get opacity() {
124
- return this._opacity;
125
- }
126
- set opacity(s) {
127
- const i = Math.min(1, Math.max(0, s));
128
- if (i === this.opacity)
129
- return;
130
- const e = this.opacity, { h, s: t, v: o } = this._color.toHsv();
131
- this._color = new c({ h, s: t, v: o, a: i }), this._opacity = i, this.host.requestUpdate("opacity", e);
132
- }
133
- /* c8 ignore next 3 */
134
- get value() {
135
- return this.color;
136
- }
137
- get color() {
138
- return this.getColorProcesses[this._format.format || "hex"](
139
- this._color,
140
- this._format.isString
141
- );
142
- }
143
- set color(s) {
144
- if (s === this.color)
145
- return;
146
- const i = this._color;
147
- this._color = new c(s);
148
- const e = this._color.format;
149
- let h = typeof s == "string" || s instanceof String;
150
- e.startsWith("hex") && (h = s.startsWith("#")), this._format = {
151
- format: e,
152
- isString: h
153
- }, this.setColorProcess(this._color, s, e, h), this.host.requestUpdate("color", i);
154
- }
155
- getColor(s) {
156
- const i = {
157
- hsl: "toHsl"
158
- };
159
- return this._color[i[s]]();
160
- }
161
- setColor(s) {
162
- this._color = s;
163
- const i = typeof this._color.originalInput == "string" || this._color.originalInput instanceof String;
164
- this.setColorProcess(this._color, s, this._color.format, i);
165
- }
166
- getHslString() {
167
- return this._color.toHslString();
168
- }
169
- savePreviousColor() {
170
- this._previousColor = this._color.clone();
171
- }
172
- restorePreviousColor() {
173
- this.setColor(this._previousColor);
174
- }
175
- }
176
- export {
177
- C
178
- };
@@ -1,18 +0,0 @@
1
- /*! * Lucero - The design system for Luzmo.
2
- *
3
- * Copyright © 2025 Luzmo
4
- * All rights reserved.
5
- * Lucero (“Luzmo Design System”) must be used according to the Luzmo Terms of Service.
6
- * This license allows users with a current active Luzmo account to use Lucero.
7
- * This license terminates automatically if a user no longer has an active Luzmo account.
8
- * Please view the Luzmo Terms of Service at: https://www.luzmo.com/information-pages/terms-of-use.
9
- *
10
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
11
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
15
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
16
- * SOFTWARE.
17
- * */
18
- "use strict";const c=require("./index-DCKCHDTt.cjs"),_=/^hs[v|l]a?\s?\((\d{1,3}\.?\d*?),?\s?(\d{1,3})/,f=/(^hs[v|l]a?\s?\()\d{1,3}\.?\d*?(,?\s?)\d{1,3}/,S=/(^hs[v|l]a?\()\d{1,3}/,g=(p,s)=>s?p.toHexString():p.toHex();class H{constructor(s,{applyColorToState:i,extractColorFromState:e,maintains:r}){this.maintains="hue",this._hue=0,this._opacity=1,this.getColorProcesses={rgb:(t,o)=>o?t.toRgbString():t.toRgb(),prgb:(t,o)=>o?t.toPercentageRgbString():t.toPercentageRgb(),hex8:(t,o)=>o?t.toHex8String():t.toHex8(),name:t=>t.toName()||t.toRgbString(),hsl:(t,o)=>{if(this.maintains==="hue"){if(o)return t.toHslString().replace(S,`$1${this.hue}`);const{s:n,l:u,a:v}=t.toHsl();return{h:this.hue,s:n,l:u,a:v}}if(o)return t.toHslString().replace(f,`$1${this.hue}$2${this.saturation}`);const{s:h,l:a,a:l}=t.toHsl();return{h:this.hue,s:h,l:a,a:l}},hsv:(t,o)=>{if(this.maintains==="hue"){if(o)return t.toHsvString().replace(S,`$1${this.hue}`);const{s:n,v:u,a:v}=t.toHsv();return{h:this.hue,s:n,v:u,a:v}}if(o)return t.toHsvString().replace(f,`$1${this.hue}$2${this.saturation}`);const{s:h,v:a,a:l}=t.toHsv();return{h:this.hue,s:h,v:a,a:l}},hex:g,hex3:g,hex4:g,hex6:g},this._color=new c.TinyColor({h:0,s:1,v:1}),this._previousColor=new c.TinyColor({h:0,s:1,v:1}),this._format={format:"",isString:!1},this.host=s,this.applyColorToState=i,this.extractColorFromState=e,this.maintains=r||this.maintains}setColorProcess(s,i,e,r){this.maintains==="hue"?this.setColorMaintainHue(s,i,e,r):this.maintains==="saturation"&&this.setColorMaintainSaturation(s,i,e,r)}setColorMaintainHue(s,i,e,r){const{h:t,s:o,v:h,a}=this._color.toHsv();let l;if(r&&e.startsWith("hs")){const n=_.exec(i);if(n!==null){const[,u]=n;l=Number(u)}}else if(!r&&e.startsWith("hs")){const n=s.originalInput;l=Object.values(n)[0]}this.hue=l||t,this.opacity=a??1,this.applyColorToState({h:t,s:o,v:h,a})}setColorMaintainSaturation(s,i,e,r){const{a:t}=this._color.toHsv();if(r&&e.startsWith("hs")){const o=_.exec(i);if(o!==null){const[,h,a]=o;this.hue=Number(h),this.saturation=Number(a)}}else if(!r&&e.startsWith("hs")){const o=s.originalInput,h=Object.values(o);this.hue=h[0],this.saturation=h[1]}else{const{h:o}=s.toHsv();this.hue=o}this.opacity=t??1,this.applyColorToState(s.toHsv())}applyColorFromState(){this._color=new c.TinyColor(this.extractColorFromState(this))}get hue(){return this._hue}set hue(s){const i=Math.min(360,Math.max(0,s));if(i===this.hue)return;const e=this.hue,{s:r,v:t,a:o}=this._color.toHsv();this._color=new c.TinyColor({h:i,s:r,v:t,a:o}),this._hue=i,this.host.requestUpdate("hue",e)}get opacity(){return this._opacity}set opacity(s){const i=Math.min(1,Math.max(0,s));if(i===this.opacity)return;const e=this.opacity,{h:r,s:t,v:o}=this._color.toHsv();this._color=new c.TinyColor({h:r,s:t,v:o,a:i}),this._opacity=i,this.host.requestUpdate("opacity",e)}get value(){return this.color}get color(){return this.getColorProcesses[this._format.format||"hex"](this._color,this._format.isString)}set color(s){if(s===this.color)return;const i=this._color;this._color=new c.TinyColor(s);const e=this._color.format;let r=typeof s=="string"||s instanceof String;e.startsWith("hex")&&(r=s.startsWith("#")),this._format={format:e,isString:r},this.setColorProcess(this._color,s,e,r),this.host.requestUpdate("color",i)}getColor(s){const i={hsl:"toHsl"};return this._color[i[s]]()}setColor(s){this._color=s;const i=typeof this._color.originalInput=="string"||this._color.originalInput instanceof String;this.setColorProcess(this._color,s,this._color.format,i)}getHslString(){return this._color.toHslString()}savePreviousColor(){this._previousColor=this._color.clone()}restorePreviousColor(){this.setColor(this._previousColor)}}exports.ColorController=H;