toolbox-x 1.0.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 (190) hide show
  1. package/LICENSE +201 -0
  2. package/dist/Color-B3mgF9Dh.d.cts +486 -0
  3. package/dist/Color-D38Xrw65.d.mts +486 -0
  4. package/dist/Stylog-Df7eq3-j.d.cts +519 -0
  5. package/dist/Stylog-jvlLcMQq.d.mts +519 -0
  6. package/dist/array-DvW0zIu6.d.mts +130 -0
  7. package/dist/array-rUnEVisO.d.cts +130 -0
  8. package/dist/basics-D_eSv0cu.cjs +132 -0
  9. package/dist/basics-Dp_aEK81.mjs +115 -0
  10. package/dist/basics-WEYWlnRO.d.cts +95 -0
  11. package/dist/basics-uBSfkBEI.d.mts +95 -0
  12. package/dist/case-BWIt8Ash.mjs +449 -0
  13. package/dist/case-C-S-b5YP.d.cts +327 -0
  14. package/dist/case-CS8Ii3A7.cjs +526 -0
  15. package/dist/case-CybASFPD.d.mts +327 -0
  16. package/dist/change-case.cjs +32 -0
  17. package/dist/change-case.d.cts +18 -0
  18. package/dist/change-case.d.mts +18 -0
  19. package/dist/change-case.mjs +19 -0
  20. package/dist/colors.cjs +574 -0
  21. package/dist/colors.d.cts +355 -0
  22. package/dist/colors.d.mts +355 -0
  23. package/dist/colors.mjs +547 -0
  24. package/dist/constants-2gAw23_7.mjs +144 -0
  25. package/dist/constants-B34K0QPi.d.cts +21 -0
  26. package/dist/constants-BIBDKY1u.cjs +924 -0
  27. package/dist/constants-BWT-810U.cjs +158 -0
  28. package/dist/constants-BwbHnXlM.mjs +662 -0
  29. package/dist/constants-BxN9l5el.cjs +74 -0
  30. package/dist/constants-CLS_bgKD.d.mts +847 -0
  31. package/dist/constants-D73iFu8g.mjs +171 -0
  32. package/dist/constants-DAfRxaa8.mjs +62 -0
  33. package/dist/constants-DQYeCjlx.cjs +207 -0
  34. package/dist/constants-Deeie-iH.d.mts +21 -0
  35. package/dist/constants-DpTG9RP6.d.mts +29 -0
  36. package/dist/constants-DqwnkJ_d.cjs +740 -0
  37. package/dist/constants-DvRUY_FY.cjs +150 -0
  38. package/dist/constants-VcRtQu0K.d.cts +29 -0
  39. package/dist/constants-X5hm1UtB.mjs +912 -0
  40. package/dist/constants-eNd-iYsV.mjs +134 -0
  41. package/dist/constants-qm8FafmD.d.cts +847 -0
  42. package/dist/constants.cjs +415 -0
  43. package/dist/constants.d.cts +184 -0
  44. package/dist/constants.d.mts +184 -0
  45. package/dist/constants.mjs +378 -0
  46. package/dist/convert-BOCgUv2D.cjs +252 -0
  47. package/dist/convert-Bn4jFomQ.mjs +169 -0
  48. package/dist/convert-BrzlG-m_.cjs +475 -0
  49. package/dist/convert-DhaUoPVU.mjs +368 -0
  50. package/dist/converter-1P90_RcP.d.mts +402 -0
  51. package/dist/converter-CmkcAppi.d.cts +402 -0
  52. package/dist/converter.cjs +780 -0
  53. package/dist/converter.d.cts +29 -0
  54. package/dist/converter.d.mts +29 -0
  55. package/dist/converter.mjs +771 -0
  56. package/dist/countries-CIpmtEzV.cjs +1469 -0
  57. package/dist/countries-Cy0xiqS3.mjs +1463 -0
  58. package/dist/css-colors-Bx947Ng3.d.cts +179 -0
  59. package/dist/css-colors-CXCDqQbG.cjs +186 -0
  60. package/dist/css-colors-CXTp1vvy.d.mts +179 -0
  61. package/dist/css-colors-DfUW3nTR.mjs +180 -0
  62. package/dist/date.cjs +332 -0
  63. package/dist/date.d.cts +213 -0
  64. package/dist/date.d.mts +213 -0
  65. package/dist/date.mjs +298 -0
  66. package/dist/dom.cjs +461 -0
  67. package/dist/dom.d.cts +228 -0
  68. package/dist/dom.d.mts +228 -0
  69. package/dist/dom.mjs +429 -0
  70. package/dist/form-BMFVGUrN.d.mts +118 -0
  71. package/dist/form-DRFbryvK.d.cts +118 -0
  72. package/dist/guards-3kaUX66g.mjs +157 -0
  73. package/dist/guards-C8gkvIHb.cjs +240 -0
  74. package/dist/guards-DdyU4h4o.mjs +110 -0
  75. package/dist/guards-Efhp1mNy.cjs +151 -0
  76. package/dist/guards.cjs +172 -0
  77. package/dist/guards.d.cts +399 -0
  78. package/dist/guards.d.mts +399 -0
  79. package/dist/guards.mjs +75 -0
  80. package/dist/hash-B6JPEyAz.d.mts +131 -0
  81. package/dist/hash-NTpeKYB_.d.cts +131 -0
  82. package/dist/hash.cjs +2126 -0
  83. package/dist/hash.d.cts +1239 -0
  84. package/dist/hash.d.mts +1239 -0
  85. package/dist/hash.mjs +2095 -0
  86. package/dist/http-status-BAZdtr7-.d.mts +65 -0
  87. package/dist/http-status-U_3MtoGb.d.cts +65 -0
  88. package/dist/http-status.cjs +173 -0
  89. package/dist/http-status.d.cts +142 -0
  90. package/dist/http-status.d.mts +142 -0
  91. package/dist/http-status.mjs +171 -0
  92. package/dist/index.cjs +2551 -0
  93. package/dist/index.d.cts +1493 -0
  94. package/dist/index.d.mts +1493 -0
  95. package/dist/index.mjs +2357 -0
  96. package/dist/object-B0TV3eHx.d.mts +8052 -0
  97. package/dist/object-Blq0Amdv.d.cts +8052 -0
  98. package/dist/objectify-CDs0Fbr1.mjs +417 -0
  99. package/dist/objectify-DIJ-OBmo.cjs +524 -0
  100. package/dist/paginator.cjs +245 -0
  101. package/dist/paginator.d.cts +144 -0
  102. package/dist/paginator.d.mts +144 -0
  103. package/dist/paginator.mjs +243 -0
  104. package/dist/parse-2ubxXZRp.cjs +211 -0
  105. package/dist/parse-N7g942uy.mjs +164 -0
  106. package/dist/pluralizer-BjMIc6uT.d.mts +42 -0
  107. package/dist/pluralizer-Cb6ZmrDl.d.cts +42 -0
  108. package/dist/pluralizer.cjs +678 -0
  109. package/dist/pluralizer.d.cts +152 -0
  110. package/dist/pluralizer.d.mts +152 -0
  111. package/dist/pluralizer.mjs +676 -0
  112. package/dist/primitives-B26uZolQ.cjs +228 -0
  113. package/dist/primitives-KsFUp3kQ.mjs +144 -0
  114. package/dist/specials-D48_IZbd.d.mts +108 -0
  115. package/dist/specials-DzLr1ZgU.cjs +477 -0
  116. package/dist/specials-LVONlKbQ.d.cts +108 -0
  117. package/dist/specials-uhDuRg8H.mjs +292 -0
  118. package/dist/string-CBAbxaG1.d.mts +258 -0
  119. package/dist/string-CsNsm_65.d.cts +258 -0
  120. package/dist/stylog.cjs +621 -0
  121. package/dist/stylog.d.cts +49 -0
  122. package/dist/stylog.d.mts +49 -0
  123. package/dist/stylog.mjs +614 -0
  124. package/dist/timezone-B2OYK6Fh.mjs +5589 -0
  125. package/dist/timezone-Beh9IGpw.cjs +5625 -0
  126. package/dist/types/array.cjs +16 -0
  127. package/dist/types/array.d.cts +18 -0
  128. package/dist/types/array.d.mts +18 -0
  129. package/dist/types/array.mjs +17 -0
  130. package/dist/types/colors.cjs +16 -0
  131. package/dist/types/colors.d.cts +18 -0
  132. package/dist/types/colors.d.mts +18 -0
  133. package/dist/types/colors.mjs +17 -0
  134. package/dist/types/converter.cjs +16 -0
  135. package/dist/types/converter.d.cts +18 -0
  136. package/dist/types/converter.d.mts +18 -0
  137. package/dist/types/converter.mjs +17 -0
  138. package/dist/types/form.cjs +16 -0
  139. package/dist/types/form.d.cts +18 -0
  140. package/dist/types/form.d.mts +18 -0
  141. package/dist/types/form.mjs +17 -0
  142. package/dist/types/hash.cjs +16 -0
  143. package/dist/types/hash.d.cts +18 -0
  144. package/dist/types/hash.d.mts +18 -0
  145. package/dist/types/hash.mjs +17 -0
  146. package/dist/types/http-status.cjs +16 -0
  147. package/dist/types/http-status.d.cts +18 -0
  148. package/dist/types/http-status.d.mts +18 -0
  149. package/dist/types/http-status.mjs +17 -0
  150. package/dist/types/index.cjs +16 -0
  151. package/dist/types/index.d.cts +18 -0
  152. package/dist/types/index.d.mts +18 -0
  153. package/dist/types/index.mjs +17 -0
  154. package/dist/types/number.cjs +16 -0
  155. package/dist/types/number.d.cts +18 -0
  156. package/dist/types/number.d.mts +18 -0
  157. package/dist/types/number.mjs +17 -0
  158. package/dist/types/object.cjs +16 -0
  159. package/dist/types/object.d.cts +18 -0
  160. package/dist/types/object.d.mts +18 -0
  161. package/dist/types/object.mjs +17 -0
  162. package/dist/types/pluralizer.cjs +16 -0
  163. package/dist/types/pluralizer.d.cts +18 -0
  164. package/dist/types/pluralizer.d.mts +18 -0
  165. package/dist/types/pluralizer.mjs +17 -0
  166. package/dist/types/string.cjs +16 -0
  167. package/dist/types/string.d.cts +18 -0
  168. package/dist/types/string.d.mts +18 -0
  169. package/dist/types/string.mjs +17 -0
  170. package/dist/types/stylog.cjs +16 -0
  171. package/dist/types/stylog.d.cts +18 -0
  172. package/dist/types/stylog.d.mts +18 -0
  173. package/dist/types/stylog.mjs +17 -0
  174. package/dist/types/utils.cjs +16 -0
  175. package/dist/types/utils.d.cts +18 -0
  176. package/dist/types/utils.d.mts +18 -0
  177. package/dist/types/utils.mjs +17 -0
  178. package/dist/types/verbalizer.cjs +16 -0
  179. package/dist/types/verbalizer.d.cts +30 -0
  180. package/dist/types/verbalizer.d.mts +30 -0
  181. package/dist/types/verbalizer.mjs +17 -0
  182. package/dist/utilities-CLUmdQeV.cjs +140 -0
  183. package/dist/utilities-m5yFKqLd.mjs +105 -0
  184. package/dist/utils-ClW9LA6f.mjs +449 -0
  185. package/dist/utils-DLFRgXUC.cjs +568 -0
  186. package/dist/verbalizer.cjs +998 -0
  187. package/dist/verbalizer.d.cts +148 -0
  188. package/dist/verbalizer.d.mts +148 -0
  189. package/dist/verbalizer.mjs +996 -0
  190. package/package.json +249 -0
@@ -0,0 +1,486 @@
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { $ as Maybe, V as Branded, rn as Percent } from "./object-B0TV3eHx.mjs";
18
+ import { t as CSS_COLORS } from "./css-colors-CXTp1vvy.mjs";
19
+
20
+ //#region src/types/colors.d.ts
21
+ /** - A string, number for generating color. */
22
+ type ColorInput = string | number;
23
+ /** - An array of strings/numbers or nested arrays of strings/numbers for generating colors. */
24
+ type ColorInputArray = Array<ColorInput | ColorInputArray>;
25
+ /**
26
+ * * Represents a hexadecimal color code.
27
+ * * Format: `#3C6945`
28
+ */
29
+ type Hex = `#${string}`;
30
+ /**
31
+ * * Represents a hexadecimal color code.
32
+ * * Format: `#3C6945`
33
+ */
34
+ type Hex6 = Branded<Hex, 'Hex6'>;
35
+ /**
36
+ * * Represents an RGB color string.
37
+ * * Format: `rgb(R, G, B)`
38
+ *
39
+ * - R (Red): 0-255
40
+ * - G (Green): 0-255
41
+ * - B (Blue): 0-255
42
+ */
43
+ type RGB = `rgb(${number}, ${number}, ${number})` | `rgb(${number},${number},${number})`;
44
+ /**
45
+ * * Represents an HSL color string.
46
+ * * Format: `hsl(H, S%, L%)`
47
+ *
48
+ * - H (Hue): 0-360
49
+ * - S (Saturation): 0-100%
50
+ * - L (Lightness): 0-100%
51
+ */
52
+ type HSL = `hsl(${number}, ${number}%, ${number}%)` | `hsl(${number},${number}%,${number}%)`;
53
+ /**
54
+ * * Represents a hexadecimal color code with optional alpha channel.
55
+ * * Format: `#3C6945FF`
56
+ */
57
+ type Hex8 = Branded<Hex, 'Hex8'>;
58
+ /**
59
+ * * Represents an RGBA color string, now includes optional alpha (opacity).
60
+ * * Format: `rgba(R, G, B, A)`
61
+ */
62
+ type RGBA = `rgba(${number}, ${number}, ${number}, ${number})` | `rgba(${number},${number},${number},${number})`;
63
+ /**
64
+ * * Represents an HSLA color string with optional alpha channel.
65
+ * * Format: `hsla(H, S%, L%, A)`
66
+ */
67
+ type HSLA = `hsla(${number}, ${number}%, ${number}%, ${number})` | `hsla(${number},${number}%,${number}%,${number})`;
68
+ /** Represents an object with `hex` (`hex6`) and `rgb` color */
69
+ type RandomHexRGB = {
70
+ /** Represents a hexadecimal color code. */hex: Hex6; /** Represents an RGB color string. */
71
+ rgb: RGB;
72
+ };
73
+ /** Basic color type: `hex`, `rgb` or `hsl`. */
74
+ type $ColorType = 'hex' | 'rgb' | 'hsl';
75
+ /** Options for random color generation. */
76
+ interface RandomColorOptions<C extends $ColorType> {
77
+ /** The type of expected return type of color: `hex`, `rgb` or `hsl`. Default is `'hex'`. */
78
+ colorType?: C | $ColorType;
79
+ /** The maximum number of recent colors to store in memory. Default is `16`. */
80
+ maxColors?: number;
81
+ }
82
+ /** Infers random color type (`Hex6`, `RGB`, or `HSL`) based on the provided color type `C`. */
83
+ type RandomColor<C extends Maybe<$ColorType> = undefined> = C extends undefined | 'hex' ? Hex6 : C extends 'hsl' ? HSL : C extends 'rgb' ? RGB : Hex6;
84
+ /** * Union type representing a color in Hex6, RGB, or HSL format. */
85
+ type ColorTypeSolid = Hex6 | RGB | HSL;
86
+ /** * Union type representing a color in Hex8, RGBA, or HSLA format. */
87
+ type ColorTypeAlpha = Hex8 | RGBA | HSLA;
88
+ /** * Union of Alpha & Solid `Hex`, `RGB` and `HSL` */
89
+ type ColorType = Hex | Hex6 | RGB | HSL | Hex8 | RGBA | HSLA;
90
+ /** - Colors Object that includes `Hex8`, `RGBA` and `HSLA` formats of the same color. */
91
+ interface SolidColors {
92
+ /** Represents a normal Hex color */
93
+ hex: Hex6;
94
+ /** Represents a normal RGB color */
95
+ rgb: RGB;
96
+ /** Represents a normal HSL color */
97
+ hsl: HSL;
98
+ }
99
+ /** - Colors Object that includes `Hex`, `RGB` and `HSL` formats of the same color. */
100
+ interface AlphaColors {
101
+ /** Represents a Hex color with alpha channel */
102
+ hex8: Hex8;
103
+ /** Represents a RGBA color with alpha channel */
104
+ rgba: RGBA;
105
+ /** Represents a HSLA color with alpha channel */
106
+ hsla: HSLA;
107
+ }
108
+ /** * Represents a tuple of three numerical values corresponding to RGB or HSL color components. */
109
+ type SolidValues = [number, number, number];
110
+ /** * Represents a tuple of four numerical values corresponding to RGBA or HSLA color components. */
111
+ type AlphaValues = [number, number, number, number];
112
+ /**
113
+ * * Represents the converted color formats for a given color type.
114
+ *
115
+ * - If the input is `Hex`, the output includes `RGB` and `HSL`.
116
+ * - If the input is `RGB`, the output includes `Hex` and `HSL`.
117
+ * - If the input is `HSL`, the output includes `Hex` and `RGB`.
118
+ */
119
+ interface ConvertedColors<T extends ColorType> extends Record<string, ColorType> {
120
+ /** - The Hex representation (excluded if the input is already Hex). */
121
+ hex: T extends Hex6 | ColorTypeAlpha ? never : Hex6;
122
+ /** - The RGB representation (excluded if the input is already RGB). */
123
+ rgb: T extends RGB | ColorTypeAlpha ? never : RGB;
124
+ /** - The HSL representation (excluded if the input is already HSL). */
125
+ hsl: T extends HSL | ColorTypeAlpha ? never : HSL;
126
+ /** - The Hex8 representation with opacity (excluded if the input is already Hex8). */
127
+ hex8: T extends Hex8 | ColorTypeSolid ? never : Hex8;
128
+ /** - The RGBA representation (excluded if the input is already RGBA). */
129
+ rgba: T extends RGBA | ColorTypeSolid ? never : RGBA;
130
+ /** - The HSLA representation (excluded if the input is already HSLA). */
131
+ hsla: T extends HSLA | ColorTypeSolid ? never : HSLA;
132
+ }
133
+ /** Represents an alpha value between 0 and 1 */
134
+ type AlphaValue = Branded<number, 'AlphaValue'>;
135
+ /** An Object representing all the colors from `Color` constructor. */
136
+ interface Colors {
137
+ /** - `Hex` color (e.g., `#ff5733`) */
138
+ hex: Hex6;
139
+ /** - `Hex8` color (Hex with opacity, e.g., `#ff573380`) */
140
+ hex8: Hex8;
141
+ /** - `RGB` color (e.g., `rgb(255, 87, 51)`) */
142
+ rgb: RGB;
143
+ /** - `RGBA` color (e.g., `rgba(255, 87, 51, 1)`) */
144
+ rgba: RGBA;
145
+ /** - `HSL` color (e.g., `hsl(14, 100%, 60%)`) */
146
+ hsl: HSL;
147
+ /** - `HSLA` color (e.g., `hsla(14, 100%, 60%, 1)`) */
148
+ hsla: HSLA;
149
+ }
150
+ /** Analogous colors */
151
+ type Analogous = [Color, Color, Color];
152
+ /** Triad color */
153
+ type Triad = [Color, Color, Color];
154
+ /** Tetrad color */
155
+ type Tetrad = [Color, Color, Color, Color];
156
+ /** CSS named color, also includes different response colors */
157
+ type CSSColor = keyof typeof CSS_COLORS;
158
+ //#endregion
159
+ //#region src/colors/Color.d.ts
160
+ /**
161
+ * @class Represents a color in {@link Hex6 Hex}, {@link Hex8}, {@link RGB}, {@link RGBA}, {@link HSL}, and {@link HSLA} formats.
162
+ *
163
+ * @remarks
164
+ * - Instance methods allow transforming, adjusting, and deriving new colors.
165
+ * - Static methods provide format validation and type-guard–style checks for supported color representations.
166
+ *
167
+ * @property `hex` - {@link Hex6 Hex} color representation (without alpha).
168
+ * @property `hex8` - {@link Hex8} color representation including alpha.
169
+ * @property `rgb` - {@link RGB} color representation (without alpha).
170
+ * @property `rgba` - {@link RGBA} color representation including alpha.
171
+ * @property `hsl` - {@link HSL} color representation (without alpha).
172
+ * @property `hsla` - {@link HSLA} color representation including alpha.
173
+ */
174
+ declare class Color {
175
+ #private;
176
+ readonly hex: Hex6;
177
+ readonly hex8: Hex8;
178
+ readonly rgb: RGB;
179
+ readonly rgba: RGBA;
180
+ readonly hsl: HSL;
181
+ readonly hsla: HSLA;
182
+ /**
183
+ * * Creates a new `Color` instance with a random color and automatically converts the generated color to all other supported formats: {@link Hex6 Hex}, {@link Hex8}, {@link RGB}, {@link RGBA}, {@link HSL}, and {@link HSLA}.
184
+ *
185
+ * @description
186
+ * The `Color` class generates a random color in six common color representations:
187
+ * - {@link Hex6 Hex} (e.g., `#ff5733`)
188
+ * - {@link Hex8} (Hex with opacity, e.g., `#ff573380`)
189
+ * - {@link RGB} (e.g., `rgb(255, 87, 51)`)
190
+ * - {@link RGBA} (e.g., `rgba(255, 87, 51, 1)`)
191
+ * - {@link HSL} (e.g., `hsl(14, 100%, 60%)`)
192
+ * - {@link HSLA} (e.g., `hsla(14, 100%, 60%, 1)`)
193
+ *
194
+ * @remarks
195
+ * - Instance methods allow transforming, adjusting, and deriving new colors.
196
+ * - Static methods provide format validation and type-guard–style checks for supported color representations.
197
+ *
198
+ * @example
199
+ * // Generate a random color
200
+ * const randomColor = new Color();
201
+ * console.log(randomColor.hex, randomColor.rgb, randomColor.hsl);
202
+ *
203
+ * @returns Instance of `Color`.
204
+ */
205
+ constructor();
206
+ /**
207
+ * * Creates a new `Color` instance with the input color and automatically converts it to all other supported formats: {@link Hex6 Hex}, {@link Hex8}, {@link RGB}, {@link RGBA}, {@link HSL}, and {@link HSLA}.
208
+ *
209
+ * @description
210
+ * The `Color` class allows seamless transformation between six common color representations:
211
+ * - {@link Hex6 Hex} (e.g., `#ff5733`)
212
+ * - {@link Hex8} (Hex with opacity, e.g., `#ff573380`)
213
+ * - {@link RGB} (e.g., `rgb(255, 87, 51)`)
214
+ * - {@link RGBA} (e.g., `rgba(255, 87, 51, 1)`)
215
+ * - {@link HSL} (e.g., `hsl(14, 100%, 60%)`)
216
+ * - {@link HSLA} (e.g., `hsla(14, 100%, 60%, 1)`)
217
+ *
218
+ * You can create a color from any of these formats, and the class will populate the rest.
219
+ *
220
+ * @remarks
221
+ * - Instance methods allow transforming, adjusting, and deriving new colors.
222
+ * - Static methods provide format validation and type-guard–style checks for supported color representations.
223
+ *
224
+ * @param color - A color string in any supported format (`Hex`, `Hex8`, `RGB`, `RGBA`, `HSL`, or `HSLA`) to convert in all other formats (includes the current format).
225
+ *
226
+ * @example
227
+ * // Convert an existing Hex color to all other formats
228
+ * const color = new Color("#ff5733");
229
+ * console.log(color.rgb); // 'rgb(255, 87, 51)'
230
+ * console.log(color.hsl); // 'hsl(14, 100%, 60%)'
231
+ * console.log(color.rgba); // 'rgba(255, 87, 51, 1)'
232
+ * console.log(color.hsla); // 'hsla(14, 100%, 60%, 1)'
233
+ * console.log(color.hex8); // '#FF5733FF'
234
+ *
235
+ * @example
236
+ * // Handle a color with alpha
237
+ * const alphaColor = new Color("rgba(255, 0, 0, 0.5)");
238
+ * console.log(alphaColor.hex8); // '#FF000080'
239
+ * console.log(alphaColor.hsla); // 'hsla(0, 100%, 50%, 0.5)'
240
+ *
241
+ * @returns Instance of `Color`.
242
+ */
243
+ constructor(color: ColorType);
244
+ /**
245
+ * * Creates a new `Color` instance using a standard (CSS) named color and automatically converts it to all other supported formats: {@link Hex6 Hex}, {@link Hex8}, {@link RGB}, {@link RGBA}, {@link HSL}, and {@link HSLA}.
246
+ *
247
+ * @description
248
+ * This allows you to use any valid named color from standard `150+` CSS color names (e.g., `"red"`, `"blue"`, `"rebeccapurple"`)
249
+ *
250
+ * @param color - A named color string from standard `150+` CSS color names ({@link CSSColor}).
251
+ *
252
+ * @remarks
253
+ * - Instance methods allow transforming, adjusting, and deriving new colors.
254
+ * - Static methods provide format validation and type-guard–style checks for supported color representations.
255
+ *
256
+ * @example
257
+ * // Using a CSS named color
258
+ * const sky = new Color("skyblue");
259
+ * console.log(sky.hex); // '#87CEEB'
260
+ * console.log(sky.rgba); // 'rgba(135, 206, 235, 1)'
261
+ *
262
+ * @returns Instance of `Color`.
263
+ */
264
+ constructor(color: CSSColor);
265
+ /**
266
+ * * Creates a new `Color` instance and automatically converts the input color to all other supported formats: {@link Hex6 Hex}, {@link Hex8}, {@link RGB}, {@link RGBA}, {@link HSL}, and {@link HSLA}.
267
+ *
268
+ * @description
269
+ * The `Color` class allows seamless transformation between six common color representations:
270
+ * - {@link Hex6 Hex} (e.g., `#ff5733`)
271
+ * - {@link Hex8} (Hex with opacity, e.g., `#ff573380`)
272
+ * - {@link RGB} (e.g., `rgb(255, 87, 51)`)
273
+ * - {@link RGBA} (e.g., `rgba(255, 87, 51, 1)`)
274
+ * - {@link HSL} (e.g., `hsl(14, 100%, 60%)`)
275
+ * - {@link HSLA} (e.g., `hsla(14, 100%, 60%, 1)`)
276
+ *
277
+ * You can create a color from any of these formats, and the class will populate the rest.
278
+ * If no color is passed, a random color will be generated.
279
+ *
280
+ * @remarks
281
+ * - Instance methods allow transforming, adjusting, and deriving new colors.
282
+ * - Static methods provide format validation and type-guard–style checks for supported color representations.
283
+ *
284
+ * @param color - An optional input color string in any supported format (`Hex`, `Hex8`, `RGB`, `RGBA`, `HSL`, or `HSLA`) or a named color string from standard `150+` CSS color names ({@link CSSColor}) to convert in all other (includes the current format) formats.
285
+ *
286
+ * @example
287
+ * // Convert an existing Hex color to all other formats
288
+ * const color = new Color("#ff5733");
289
+ * console.log(color.rgb); // 'rgb(255, 87, 51)'
290
+ * console.log(color.hsl); // 'hsl(14, 100%, 60%)'
291
+ * console.log(color.rgba); // 'rgba(255, 87, 51, 1)'
292
+ * console.log(color.hsla); // 'hsla(14, 100%, 60%, 1)'
293
+ * console.log(color.hex8); // '#FF5733FF'
294
+ *
295
+ * @example
296
+ * // Handle a color with alpha
297
+ * const alphaColor = new Color("rgba(255, 0, 0, 0.5)");
298
+ * console.log(alphaColor.hex8); // '#FF000080'
299
+ * console.log(alphaColor.hsla); // 'hsla(0, 100%, 50%, 0.5)'
300
+ *
301
+ * @example
302
+ * // Generate a random color
303
+ * const randomColor = new Color();
304
+ * console.log(randomColor.hex, randomColor.rgb, randomColor.hsl);
305
+ *
306
+ * @example
307
+ * // Using a CSS named color
308
+ * const sky = new Color("skyblue");
309
+ * console.log(sky.hex); // '#87CEEB'
310
+ * console.log(sky.rgba); // 'rgba(135, 206, 235, 1)'
311
+ *
312
+ * @returns Instance of `Color`.
313
+ */
314
+ constructor(color?: ColorType | CSSColor);
315
+ /** Iterates over the color representations (`Hex`, `RGB`, `HSL`). */
316
+ [Symbol.iterator](): Generator<Hex6 | Hex8 | RGB | RGBA | HSL | HSLA, void, unknown>;
317
+ /**
318
+ * @instance Applies or modifies the opacity of a color and returns a new instance.
319
+ *
320
+ * @remarks
321
+ * - For solid colors ({@link Hex6}/{@link RGB}/{@link HSL}): Adds an alpha channel with the specified opacity.
322
+ * - For alpha colors ({@link Hex8}/{@link RGBA}/{@link HSLA}): Updates the existing alpha channel.
323
+ *
324
+ * @param opacity - A number between `0-100` representing the opacity percentage.
325
+ * @returns A new instance of `Color` containing all color formats with the applied opacity.
326
+ *
327
+ * @example
328
+ * const color = new Color("#ff0000");
329
+ * const alpha50 = color.applyOpacity(50); // 50% opacity
330
+ * console.log(alpha50.rgba); // rgba(255, 0, 0, 0.5)
331
+ *
332
+ * @example
333
+ * const alphaColor = new Color("#ff000080"); // Color with 50% opacity
334
+ * const alpha75 = alphaColor.applyOpacity(75); // Change to 75% opacity
335
+ * console.log(alpha75.hex8); // #FF0000BF
336
+ */
337
+ applyOpacity(opacity: Percent): Color;
338
+ /**
339
+ * @instance Darkens the color by reducing the lightness by the given percentage.
340
+ * @param percent - The percentage to darken (`0–100`).
341
+ * @returns A new `Color` instance with the modified darkness.
342
+ */
343
+ applyDarkness(percent: Percent): Color;
344
+ /**
345
+ * @instance Lightens the color by increasing the lightness by the given percentage.
346
+ * @param percent - The percentage to brighten (`0–100`).
347
+ * @returns A new `Color` instance with the modified lightness.
348
+ */
349
+ applyBrightness(percent: Percent): Color;
350
+ /**
351
+ * @instance Reduces the saturation of the color to make it appear duller.
352
+ * @param percent - The percentage to reduce saturation (`0–100`).
353
+ * @returns A new `Color` instance with the modified saturation.
354
+ */
355
+ applyDullness(percent: Percent): Color;
356
+ /**
357
+ * @instance Softens the color toward white by reducing saturation and increasing lightness based on a percentage.
358
+ *
359
+ * @remarks
360
+ * This creates a soft UI-like white shade effect (similar to some UI libraries' light color scale).
361
+ *
362
+ * @param percent - Value from `0` to `100` representing how far to push the color toward white.
363
+ * @returns A new `Color` instance shifted toward white.
364
+ */
365
+ applyWhiteShade(percent: Percent): Color;
366
+ /**
367
+ * @instance Blends the current color with another color based on the given weight.
368
+ *
369
+ * @remarks
370
+ * If any of the input colors has opacity (alpha channel), it might be lost or distorted from the generated alpha variants of the respective color formats.
371
+ *
372
+ * @param other - The color in any of 6 ({@link Hex6 Hex}, {@link Hex8}, {@link RGB}, {@link RGBA}, {@link HSL} or {@link HSLA}) formats or a {@link CSSColor} to blend with.
373
+ * @param weight - A number from `0` to `1` indicating the weight of the other color. Defaults to `0.5`.
374
+ * - `weight = 0` → only the original color.
375
+ * - `weight = 1` → only the other color.
376
+ * - `weight = 0.5` → equal blend between the two.
377
+ * @returns A new `Color` instance representing the blended result, with proper alpha blending.
378
+ */
379
+ blendWith(other: ColorType | CSSColor, weight?: number): Color;
380
+ /**
381
+ * @instance Calculates the contrast ratio between this color and another color (WCAG).
382
+ * @param other - The other color to compare against.
383
+ * @returns A number representing the contrast ratio (rounded to 2 decimal places).
384
+ */
385
+ contrastRatio(other: ColorType | CSSColor): number;
386
+ /**
387
+ * @instance Returns the complementary color by rotating the hue 180 degrees.
388
+ * @returns A new `Color` that is the complement of the current color.
389
+ */
390
+ getComplementaryColor(): Color;
391
+ /**
392
+ * @instance Generates a color scheme of analogous colors, including the base color.
393
+ *
394
+ * @remarks
395
+ * Analogous colors are next to each other on the color wheel (±30°).
396
+ *
397
+ * @returns An array of three `Color` instances: `[base, left, right]`.
398
+ */
399
+ getAnalogousColors(): Analogous;
400
+ /**
401
+ * @instance Generates a color triad scheme including the base color.
402
+ *
403
+ * @remarks
404
+ * Triadic colors are evenly spaced (120° apart) on the color wheel.
405
+ *
406
+ * @returns An array of three `Color` instances: `[base, triad1, triad2]`.
407
+ */
408
+ getTriadColors(): Triad;
409
+ /**
410
+ * @instance Generates a tetradic color scheme including the base color.
411
+ *
412
+ * @remarks
413
+ * Tetradic colors form a rectangle on the color wheel (90° apart).
414
+ *
415
+ * @returns An array of four `Color` instances: `[base, tetrad1, tetrad2, tetrad3]`.
416
+ */
417
+ getTetradColors(): Tetrad;
418
+ /**
419
+ * @instance Gets the `WCAG` accessibility rating between this and another color.
420
+ * @param other - The other color to test contrast against.
421
+ * @returns `'Fail'`, `'AA'`, or `'AAA'` based on `WCAG 2.1` contrast standards.
422
+ */
423
+ getWCAGRating(other: ColorType | CSSColor): 'Fail' | 'AA' | 'AAA';
424
+ /**
425
+ * @instance Determines if the color is light based on its perceived brightness.
426
+ * @param threshold Optional brightness threshold (`0–255`). Defaults to `127.5`.
427
+ * @remarks The brightness {@link threshold} is clamped to the valid *RGB range* (`0–255`) to prevent invalid comparisons.
428
+ * @returns `true` if light, `false` if dark.
429
+ */
430
+ isLightColor(threshold?: number): boolean;
431
+ /**
432
+ * @static Checks if a color is in {@link Hex6} format.
433
+ *
434
+ * @param color Color to check.
435
+ * @returns Boolean: `true` if it's a {@link Hex6} color, `false` if not.
436
+ */
437
+ static isHex6(color: string): color is Hex6;
438
+ /**
439
+ * @static Checks if a color is in {@link Hex8} format.
440
+ *
441
+ * @param color Color to check.
442
+ * @returns Boolean: `true` if it's a {@link Hex8} color, `false` if not.
443
+ */
444
+ static isHex8(color: string): color is Hex8;
445
+ /**
446
+ * @static Checks if a color is in {@link RGB} format and within valid ranges.
447
+ *
448
+ * @param color Color to check.
449
+ * @returns `true` if it's a {@link RGB} color, `false` if not.
450
+ */
451
+ static isRGB(color: string): color is RGB;
452
+ /**
453
+ * @static Checks if a color is in {@link RGBA} format and within valid ranges.
454
+ *
455
+ * @param color Color to check.
456
+ * @returns `true` if it's a {@link RGBA} color, `false` if not.
457
+ */
458
+ static isRGBA(color: string): color is RGBA;
459
+ /**
460
+ * @static Checks if a color is in {@link HSL} format and within valid ranges.
461
+ *
462
+ * @param color Color to check.
463
+ * @returns `true` if it's a {@link HSL} color, `false` if not.
464
+ */
465
+ static isHSL(color: string): color is HSL;
466
+ /**
467
+ * @static Checks if a color is in {@link HSLA} format and within valid ranges.
468
+ *
469
+ * @param color Color to check.
470
+ * @returns `true` if it's a {@link HSLA} color, `false` if not.
471
+ */
472
+ static isHSLA(color: string): color is HSLA;
473
+ /**
474
+ * @static Checks if a color is a valid CSS color name ({@link CSSColor}).
475
+ *
476
+ * @remarks
477
+ * - This method checks against a predefined list of CSS color names.
478
+ * - It does not validate format types like `Hex`, `RGB`, or `HSL` or their alpha channels.
479
+ *
480
+ * @param color - The color to check.
481
+ * @returns `true` if the color is a valid CSS color name, `false` otherwise.
482
+ */
483
+ static isCSSColor(color: string): color is CSSColor;
484
+ }
485
+ //#endregion
486
+ export { RandomColorOptions as C, Tetrad as D, SolidValues as E, Triad as O, RandomColor as S, SolidColors as T, Hex as _, AlphaValues as a, RGB as b, ColorInput as c, ColorTypeAlpha as d, ColorTypeSolid as f, HSLA as g, HSL as h, AlphaValue as i, ColorInputArray as l, ConvertedColors as m, $ColorType as n, Analogous as o, Colors as p, AlphaColors as r, CSSColor as s, Color as t, ColorType as u, Hex6 as v, RandomHexRGB as w, RGBA as x, Hex8 as y };