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,475 @@
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
+ const require_primitives = require('./primitives-B26uZolQ.cjs');
18
+ const require_guards = require('./guards-C8gkvIHb.cjs');
19
+
20
+ //#region src/colors/utils.ts
21
+ /**
22
+ * * Extracts numbers from a color string like `rgb(66, 103, 69)` or `hsl(120, 42.86%, 41.18%)`.
23
+ * * Converts percentage values to decimal (e.g., `42.86%` → `42.86`).
24
+ *
25
+ * @param color The color string in RGB or HSL format.
26
+ * @returns A tuple of 3 extracted numbers. `[number, number, number]`
27
+ *
28
+ * @remarks If the input color is not in `HSL` or `RGB` format, it will return `[0, 0, 0]`
29
+ */
30
+ function extractSolidColorValues(color) {
31
+ if (require_guards.isHSL(color) || require_guards.isRGB(color)) return (color?.trim()?.match(/[\d.]+%?/g) || [])?.map((value) => parseFloat(value));
32
+ return [
33
+ 0,
34
+ 0,
35
+ 0
36
+ ];
37
+ }
38
+ /**
39
+ * * Extracts numbers from a color string like `rgba(66, 103, 69, 0.6)` or `hsla(120, 42.86%, 41.18%, 0.9)`.
40
+ * * Converts percentage values to decimal (e.g., `42.86%` → `42.86`).
41
+ *
42
+ * @param color The color string in RGBA or HSLA format.
43
+ * @returns A tuple of 4 extracted numbers. `[number, number, number, number]`
44
+ *
45
+ * @remarks If the input color is not in `HSLA` or `RGBA` format, it will return `[0, 0, 0, 0]`
46
+ */
47
+ function extractAlphaColorValues(color) {
48
+ if (require_guards.isHSLA(color) || require_guards.isRGBA(color)) return (color?.trim()?.match(/[\d.]+%?/g) || [])?.map((value) => parseFloat(value));
49
+ return [
50
+ 0,
51
+ 0,
52
+ 0,
53
+ 0
54
+ ];
55
+ }
56
+ /**
57
+ * * Converts percentage (0-100) to a 2-digit hex string.
58
+ *
59
+ * @param percent - The percentage (0-100) value.
60
+ * @returns A 2-digit hex string representing the percentage (0-100) value.
61
+ *
62
+ * @remarks
63
+ * - This function ensures that the percentage value is clamped between 0 and 100, converts it to a value between 0 and 255, and then formats it as a 2-digit hexadecimal string.
64
+ * - The resulting hex string is in uppercase for consistency with common hex color formats.
65
+ *
66
+ * @example
67
+ * percentToHex(0); // Returns "00"
68
+ * percentToHex(50); // Returns "7F"
69
+ * percentToHex(100); // Returns "FF"
70
+ * percentToHex(150); // Returns "FF" (ts compiler error and clamped to 100)
71
+ * percentToHex(-20); // Returns "00" (ts compiler error and clamped to 0)
72
+ */
73
+ function percentToHex(percent) {
74
+ return Math.round(Math.min(100, Math.max(0, percent)) / 100 * 255).toString(16).padStart(2, "0").toUpperCase();
75
+ }
76
+ /**
77
+ * * Applies an opacity value to a hex color string.
78
+ *
79
+ * @param color - The hex color string in the format `#RRGGBB` or `#RRGGBBAA`.
80
+ * @param opacity - The opacity value as a percentage (0-100) or a 2-digit hex string.
81
+ * @returns The hex color string with the applied opacity in `#RRGGBBAA` format.
82
+ */
83
+ function applyOpacityToHex(color, opacity) {
84
+ if (require_guards.isHex6(color) || require_guards.isHex8(color)) {
85
+ const upperColor = color.toUpperCase();
86
+ if (require_primitives.isNumber(opacity)) return require_guards._applyOpacity(upperColor, percentToHex(opacity));
87
+ else if (require_primitives.isNonEmptyString(opacity) && /^[0-9A-Fa-f]{2}$/.test(opacity)) return require_guards._applyOpacity(upperColor, opacity.toUpperCase());
88
+ else return require_guards._applyOpacity(upperColor, percentToHex(100));
89
+ } else throw new TypeError("Invalid color value!", { cause: "Value must be a hex color string in the format #RRGGBB or #RRGGBBAA." });
90
+ }
91
+
92
+ //#endregion
93
+ //#region src/colors/convert.ts
94
+ /**
95
+ * * Converts HSL to RGB color format.
96
+ *
97
+ * @param h - The hue component of the HSL color, in degrees (0 to 360).
98
+ * @param s - The saturation component of the HSL color, as a percentage (0 to 100).
99
+ * @param l - The lightness component of the HSL color, as a percentage (0 to 100).
100
+ * @returns A string representing the color in RGB format (e.g., `rgb(255, 0, 0)`).
101
+ */
102
+ const convertHslToRgb = (h, s, l) => {
103
+ s /= 100;
104
+ l /= 100;
105
+ const c = (1 - Math.abs(2 * l - 1)) * s;
106
+ const x = c * (1 - Math.abs(h / 60 % 2 - 1));
107
+ const m = l - c / 2;
108
+ let r = 0, g = 0, b = 0;
109
+ if (h >= 0 && h < 60) [r, g] = [c, x];
110
+ else if (h >= 60 && h < 120) [r, g] = [x, c];
111
+ else if (h >= 120 && h < 180) [g, b] = [c, x];
112
+ else if (h >= 180 && h < 240) [g, b] = [x, c];
113
+ else if (h >= 240 && h < 300) [r, b] = [x, c];
114
+ else if (h >= 300 && h < 360) [r, b] = [c, x];
115
+ r = Math.round((r + m) * 255);
116
+ g = Math.round((g + m) * 255);
117
+ b = Math.round((b + m) * 255);
118
+ return `rgb(${r}, ${g}, ${b})`;
119
+ };
120
+ /**
121
+ * * Converts RGB to HSL color format.
122
+ *
123
+ * @param r - The red component of the RGB color, in the range 0 to 255.
124
+ * @param g - The green component of the RGB color, in the range 0 to 255.
125
+ * @param b - The blue component of the RGB color, in the range 0 to 255.
126
+ * @returns A string representing the color in HSL format (e.g., `hsl(0, 100%, 50%)`).
127
+ */
128
+ const convertRgbToHsl = (r, g, b) => {
129
+ r /= 255;
130
+ g /= 255;
131
+ b /= 255;
132
+ const max = Math.max(r, g, b);
133
+ const min = Math.min(r, g, b);
134
+ let h = 0, s = 0;
135
+ const l = (max + min) / 2;
136
+ if (max !== min) {
137
+ const diff = max - min;
138
+ s = l > .5 ? diff / (2 - max - min) : diff / (max + min);
139
+ switch (max) {
140
+ case r:
141
+ h = (g - b) / diff + (g < b ? 6 : 0);
142
+ break;
143
+ case g:
144
+ h = (b - r) / diff + 2;
145
+ break;
146
+ case b:
147
+ h = (r - g) / diff + 4;
148
+ break;
149
+ }
150
+ h *= 60;
151
+ }
152
+ return `hsl(${Math.round(h)}, ${Number((s * 100).toFixed(2))}%, ${Number((l * 100).toFixed(2))}%)`;
153
+ };
154
+ /**
155
+ * * Converts HSL to Hex color format.
156
+ *
157
+ * @param h - The hue component of the HSL color, in degrees (0 to 360).
158
+ * @param s - The saturation component of the HSL color, as a percentage (0 to 100).
159
+ * @param l - The lightness component of the HSL color, as a percentage (0 to 100).
160
+ * @returns A string representing the color in Hex format (e.g., `#FF0000`).
161
+ */
162
+ const convertHslToHex = (h, s, l) => {
163
+ const rgb = convertHslToRgb(h, s, l).match(/\d+/g).map(Number);
164
+ return convertRgbToHex(rgb[0], rgb[1], rgb[2]);
165
+ };
166
+ /**
167
+ * * Converts Hex to HSL color format.
168
+ *
169
+ * @param hex - A string representing the color in Hex format (e.g., `#FF0000`).
170
+ * @returns A string representing the color in HSL format (e.g., `hsl(0, 100%, 50%)`).
171
+ */
172
+ const convertHexToHsl = (hex) => {
173
+ let newHex = hex?.trim()?.replace("#", "");
174
+ if (newHex?.length === 3) newHex = newHex?.split("")?.map((char) => char + char)?.join("");
175
+ return convertRgbToHsl(parseInt(newHex.slice(0, 2), 16), parseInt(newHex.slice(2, 4), 16), parseInt(newHex.slice(4, 6), 16));
176
+ };
177
+ /**
178
+ * * Converts RGB to Hex color format.
179
+ *
180
+ * @param r - The red component of the RGB color, in the range 0 to 255.
181
+ * @param g - The green component of the RGB color, in the range 0 to 255.
182
+ * @param b - The blue component of the RGB color, in the range 0 to 255.
183
+ * @returns A string representing the color in Hex format (e.g., `#FF0000`).
184
+ */
185
+ const convertRgbToHex = (r, g, b) => {
186
+ return `#${[
187
+ r,
188
+ g,
189
+ b
190
+ ]?.map((v) => v.toString(16).padStart(2, "0"))?.join("")?.toUpperCase()}`;
191
+ };
192
+ /**
193
+ * * Converts Hex to RGB color format.
194
+ *
195
+ * @param hex - A string representing the color in Hex format (e.g., `#FF0000`).
196
+ * @returns A string representing the color in RGB format (e.g., `rgb(255, 0, 0)`).
197
+ */
198
+ const convertHexToRgb = (hex) => {
199
+ let newHex = hex?.trim()?.replace("#", "");
200
+ if (newHex?.length === 3) newHex = newHex?.split("")?.map((char) => char + char)?.join("");
201
+ return `rgb(${parseInt(newHex.slice(0, 2), 16)}, ${parseInt(newHex.slice(2, 4), 16)}, ${parseInt(newHex.slice(4, 6), 16)})`;
202
+ };
203
+ /**
204
+ * * Converts RGB to RGBA format, adding alpha (opacity).
205
+ *
206
+ * @param r - The red component of the RGB color, in the range 0 to 255.
207
+ * @param g - The green component of the RGB color, in the range 0 to 255.
208
+ * @param b - The blue component of the RGB color, in the range 0 to 255.
209
+ * @param a - The alpha (opacity) value, in the range 0 to 1.
210
+ * @returns A string representing the color in RGBA format (e.g., `rgba(255, 0, 0, 0.5)`).
211
+ */
212
+ const convertRgbToRgba = (r, g, b, a = 1) => {
213
+ let newAlpha = a;
214
+ if (!require_guards._isValidAlpha(a)) {
215
+ newAlpha = 1;
216
+ console.warn(`Alpha value must be between 0-1, ${a} converted to 1!`);
217
+ }
218
+ return `rgba(${r}, ${g}, ${b}, ${parseFloat(newAlpha.toFixed(1))})`;
219
+ };
220
+ /**
221
+ * * Converts RGBA to Hex format, including alpha channel as part of Hex8.
222
+ *
223
+ * @param r - The red component of the RGB color, in the range 0 to 255.
224
+ * @param g - The green component of the RGB color, in the range 0 to 255.
225
+ * @param b - The blue component of the RGB color, in the range 0 to 255.
226
+ * @param a - The alpha (opacity) value, in the range 0 to 1.
227
+ * @returns A string representing the color in Hex8 format (e.g., `#FF000080`).
228
+ */
229
+ const convertRgbaToHex8 = (r, g, b, a = 1) => {
230
+ let newAlpha = a;
231
+ if (!require_guards._isValidAlpha(a)) {
232
+ newAlpha = 1;
233
+ console.warn(`Alpha value must be between 0-1, ${a} converted to 1!`);
234
+ }
235
+ const alphaHex = percentToHex(Math.round(newAlpha * 100));
236
+ return `${convertRgbToHex(r, g, b)}${alphaHex}`;
237
+ };
238
+ /**
239
+ * * Converts HSLA to RGBA color format, including alpha channel.
240
+ *
241
+ * @param h - The hue component of the HSL color, in degrees (0 to 360).
242
+ * @param s - The saturation component of the HSL color, as a percentage (0 to 100).
243
+ * @param l - The lightness component of the HSL color, as a percentage (0 to 100).
244
+ * @param a - The alpha (opacity) value, in the range 0 to 1.
245
+ * @returns A string representing the color in RGBA format (e.g., `rgba(255, 0, 0, 0.5)`).
246
+ */
247
+ const convertHslaToRgba = (h, s, l, a = 1) => {
248
+ let newAlpha = a;
249
+ if (!require_guards._isValidAlpha(a)) {
250
+ newAlpha = 1;
251
+ console.warn(`Alpha value must be between 0-1, ${a} converted to 1!`);
252
+ }
253
+ const [r, g, b] = extractSolidColorValues(convertHslToRgb(h, s, l));
254
+ return convertRgbToRgba(r, g, b, parseFloat(newAlpha.toFixed(1)));
255
+ };
256
+ /**
257
+ * * Converts RGBA to HSLA color format, including alpha channel.
258
+ *
259
+ * @param r - The red component of the RGB color, in the range 0 to 255.
260
+ * @param g - The green component of the RGB color, in the range 0 to 255.
261
+ * @param b - The blue component of the RGB color, in the range 0 to 255.
262
+ * @param a - The alpha (opacity) value, in the range 0 to 1.
263
+ * @returns A string representing the color in HSLA format (e.g., `hsla(0, 100%, 50%, 0.5)`).
264
+ */
265
+ const convertRgbaToHsla = (r, g, b, a = 1) => {
266
+ let newAlpha = a;
267
+ if (!require_guards._isValidAlpha(a)) {
268
+ newAlpha = 1;
269
+ console.warn(`Alpha value must be between 0-1, ${a} converted to 1!`);
270
+ }
271
+ const [h, s, l] = extractSolidColorValues(convertRgbToHsl(r, g, b));
272
+ return `hsla(${h}, ${s}%, ${l}%, ${parseFloat(newAlpha.toFixed(1))})`;
273
+ };
274
+ /**
275
+ * * Converts Hex8 to RGBA color format, including alpha channel.
276
+ * - `Special Note:` Cast the parameter to `Hex8` before converting to `RGBA`.
277
+ * @example convertHex8ToRgba('#FFF122DE' as Hex8)
278
+ *
279
+ * @param hex8 - A string representing the color in Hex8 format (e.g., `#FF000080`).
280
+ * @returns A string representing the color in RGBA format (e.g., `rgba(255, 0, 0, 0.5)`).
281
+ */
282
+ const convertHex8ToRgba = (hex8) => {
283
+ const hex = hex8?.trim()?.replace("#", "");
284
+ const r = parseInt(hex.slice(0, 2), 16);
285
+ const g = parseInt(hex.slice(2, 4), 16);
286
+ const b = parseInt(hex.slice(4, 6), 16);
287
+ const a = parseInt(hex.slice(6, 8), 16) / 255;
288
+ return `rgba(${r}, ${g}, ${b}, ${parseFloat(a.toFixed(1))})`;
289
+ };
290
+ /**
291
+ * * Converts HSLA to Hex8 color format, including alpha channel.
292
+ *
293
+ * @param h - The hue component of the HSL color, in degrees (0 to 360).
294
+ * @param s - The saturation component of the HSL color, as a percentage (0 to 100).
295
+ * @param l - The lightness component of the HSL color, as a percentage (0 to 100).
296
+ * @param a - The alpha (opacity) value, in the range 0 to 1.
297
+ * @returns A string representing the color in Hex8 format (e.g., `#658789DF`).
298
+ */
299
+ const convertHslaToHex8 = (h, s, l, a = 1) => {
300
+ let newAlpha = a;
301
+ if (!require_guards._isValidAlpha(a)) {
302
+ newAlpha = 1;
303
+ console.warn(`Alpha value must be between 0-1, ${a} converted to 1!`);
304
+ }
305
+ const alphaHex = percentToHex(Math.round(newAlpha * 100));
306
+ return `${convertHslToHex(h, s, l)}${alphaHex}`;
307
+ };
308
+ /**
309
+ * * Converts Hex8 to HSLA color format.
310
+ * - `Special Note:` Cast the parameter to `Hex8` before converting to `HSLA`.
311
+ * @example convertHex8ToHsla('#FFF122DE' as Hex8)
312
+ *
313
+ * @param hex - A string representing the color in Hex format (e.g., `#FF0000DE`).
314
+ * @returns A string representing the color in HSLA format..
315
+ */
316
+ const convertHex8ToHsla = (hex8) => {
317
+ return convertRgbaToHsla(...extractAlphaColorValues(convertHex8ToRgba(hex8)));
318
+ };
319
+ /**
320
+ * * Converts a color from `Hex`, `RGB`, or `HSL` format to its equivalent representations.
321
+ *
322
+ * @param color The color string in `Hex`, `RGB`, or `HSL` format.
323
+ * @returns The converted color representations excluding the input format.
324
+ * @throws If the color format is unrecognized throws `Error`.
325
+ */
326
+ function convertColorCode(color) {
327
+ const trimmedColor = color?.trim();
328
+ if (require_guards.isHex6(trimmedColor)) return {
329
+ rgb: convertHexToRgb(trimmedColor),
330
+ hsl: convertHexToHsl(trimmedColor)
331
+ };
332
+ if (require_guards.isRGB(trimmedColor)) {
333
+ const rgbValues = extractSolidColorValues(trimmedColor);
334
+ return {
335
+ hex: convertRgbToHex(...rgbValues),
336
+ hsl: convertRgbToHsl(...rgbValues)
337
+ };
338
+ }
339
+ if (require_guards.isHSL(trimmedColor)) {
340
+ const hslValues = extractSolidColorValues(trimmedColor);
341
+ return {
342
+ hex: convertHslToHex(...hslValues),
343
+ rgb: convertHslToRgb(...hslValues)
344
+ };
345
+ }
346
+ if (require_guards.isHex8(trimmedColor)) return {
347
+ rgba: convertHex8ToRgba(trimmedColor),
348
+ hsla: convertHex8ToHsla(trimmedColor)
349
+ };
350
+ if (require_guards.isRGBA(trimmedColor)) {
351
+ const rgbaValues = extractAlphaColorValues(trimmedColor);
352
+ return {
353
+ hex8: convertRgbaToHex8(...rgbaValues),
354
+ hsla: convertRgbaToHsla(...rgbaValues)
355
+ };
356
+ }
357
+ if (require_guards.isHSLA(trimmedColor)) {
358
+ const hslaValues = extractAlphaColorValues(trimmedColor);
359
+ return {
360
+ hex8: convertHslaToHex8(...hslaValues),
361
+ rgba: convertHslaToRgba(...hslaValues)
362
+ };
363
+ }
364
+ throw new TypeError(`${color} is not a valid color!`, { cause: "Unrecognized Color Format" });
365
+ }
366
+
367
+ //#endregion
368
+ Object.defineProperty(exports, 'applyOpacityToHex', {
369
+ enumerable: true,
370
+ get: function () {
371
+ return applyOpacityToHex;
372
+ }
373
+ });
374
+ Object.defineProperty(exports, 'convertColorCode', {
375
+ enumerable: true,
376
+ get: function () {
377
+ return convertColorCode;
378
+ }
379
+ });
380
+ Object.defineProperty(exports, 'convertHex8ToHsla', {
381
+ enumerable: true,
382
+ get: function () {
383
+ return convertHex8ToHsla;
384
+ }
385
+ });
386
+ Object.defineProperty(exports, 'convertHex8ToRgba', {
387
+ enumerable: true,
388
+ get: function () {
389
+ return convertHex8ToRgba;
390
+ }
391
+ });
392
+ Object.defineProperty(exports, 'convertHexToHsl', {
393
+ enumerable: true,
394
+ get: function () {
395
+ return convertHexToHsl;
396
+ }
397
+ });
398
+ Object.defineProperty(exports, 'convertHexToRgb', {
399
+ enumerable: true,
400
+ get: function () {
401
+ return convertHexToRgb;
402
+ }
403
+ });
404
+ Object.defineProperty(exports, 'convertHslToHex', {
405
+ enumerable: true,
406
+ get: function () {
407
+ return convertHslToHex;
408
+ }
409
+ });
410
+ Object.defineProperty(exports, 'convertHslToRgb', {
411
+ enumerable: true,
412
+ get: function () {
413
+ return convertHslToRgb;
414
+ }
415
+ });
416
+ Object.defineProperty(exports, 'convertHslaToHex8', {
417
+ enumerable: true,
418
+ get: function () {
419
+ return convertHslaToHex8;
420
+ }
421
+ });
422
+ Object.defineProperty(exports, 'convertHslaToRgba', {
423
+ enumerable: true,
424
+ get: function () {
425
+ return convertHslaToRgba;
426
+ }
427
+ });
428
+ Object.defineProperty(exports, 'convertRgbToHex', {
429
+ enumerable: true,
430
+ get: function () {
431
+ return convertRgbToHex;
432
+ }
433
+ });
434
+ Object.defineProperty(exports, 'convertRgbToHsl', {
435
+ enumerable: true,
436
+ get: function () {
437
+ return convertRgbToHsl;
438
+ }
439
+ });
440
+ Object.defineProperty(exports, 'convertRgbToRgba', {
441
+ enumerable: true,
442
+ get: function () {
443
+ return convertRgbToRgba;
444
+ }
445
+ });
446
+ Object.defineProperty(exports, 'convertRgbaToHex8', {
447
+ enumerable: true,
448
+ get: function () {
449
+ return convertRgbaToHex8;
450
+ }
451
+ });
452
+ Object.defineProperty(exports, 'convertRgbaToHsla', {
453
+ enumerable: true,
454
+ get: function () {
455
+ return convertRgbaToHsla;
456
+ }
457
+ });
458
+ Object.defineProperty(exports, 'extractAlphaColorValues', {
459
+ enumerable: true,
460
+ get: function () {
461
+ return extractAlphaColorValues;
462
+ }
463
+ });
464
+ Object.defineProperty(exports, 'extractSolidColorValues', {
465
+ enumerable: true,
466
+ get: function () {
467
+ return extractSolidColorValues;
468
+ }
469
+ });
470
+ Object.defineProperty(exports, 'percentToHex', {
471
+ enumerable: true,
472
+ get: function () {
473
+ return percentToHex;
474
+ }
475
+ });