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,180 @@
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
+ //#region src/colors/css-colors.ts
18
+ /** List of CSS Colors as Object with color name as key and hex code as value */
19
+ const CSS_COLORS = /* @__PURE__ */ Object.freeze({
20
+ black: "#000000",
21
+ silver: "#C0C0C0",
22
+ gray: "#808080",
23
+ white: "#FFFFFF",
24
+ maroon: "#800000",
25
+ red: "#FF0000",
26
+ purple: "#800080",
27
+ fuchsia: "#FF00FF",
28
+ green: "#008000",
29
+ lime: "#00FF00",
30
+ olive: "#808000",
31
+ yellow: "#FFFF00",
32
+ navy: "#000080",
33
+ blue: "#0000FF",
34
+ teal: "#008080",
35
+ aqua: "#00FFFF",
36
+ aliceblue: "#F0F8FF",
37
+ antiquewhite: "#FAEBD7",
38
+ aquamarine: "#7FFFD4",
39
+ azure: "#F0FFFF",
40
+ beige: "#F5F5DC",
41
+ bisque: "#FFE4C4",
42
+ blanchedalmond: "#FFEBCD",
43
+ blueviolet: "#8A2BE2",
44
+ brown: "#A52A2A",
45
+ burlywood: "#DEB887",
46
+ cadetblue: "#5F9EA0",
47
+ chartreuse: "#7FFF00",
48
+ chocolate: "#D2691E",
49
+ coral: "#FF7F50",
50
+ cornflowerblue: "#6495ED",
51
+ cornsilk: "#FFF8DC",
52
+ crimson: "#DC143C",
53
+ cyan: "#00FFFF",
54
+ darkblue: "#00008B",
55
+ darkcyan: "#008B8B",
56
+ darkgoldenrod: "#B8860B",
57
+ darkgray: "#A9A9A9",
58
+ darkgreen: "#006400",
59
+ darkgrey: "#A9A9A9",
60
+ darkkhaki: "#BDB76B",
61
+ darkmagenta: "#8B008B",
62
+ darkolivegreen: "#556B2F",
63
+ darkorange: "#FF8C00",
64
+ darkorchid: "#9932CC",
65
+ darkred: "#8B0000",
66
+ darksalmon: "#E9967A",
67
+ darkseagreen: "#8FBC8F",
68
+ darkslateblue: "#483D8B",
69
+ darkslategray: "#2F4F4F",
70
+ darkslategrey: "#2F4F4F",
71
+ darkturquoise: "#00CED1",
72
+ darkviolet: "#9400D3",
73
+ deeppink: "#FF1493",
74
+ deepskyblue: "#00BFFF",
75
+ dimgray: "#696969",
76
+ dimgrey: "#696969",
77
+ dodgerblue: "#1E90FF",
78
+ firebrick: "#B22222",
79
+ floralwhite: "#FFFAF0",
80
+ forestgreen: "#228B22",
81
+ gainsboro: "#DCDCDC",
82
+ ghostwhite: "#F8F8FF",
83
+ gold: "#FFD700",
84
+ goldenrod: "#DAA520",
85
+ greenyellow: "#ADFF2F",
86
+ grey: "#808080",
87
+ honeydew: "#F0FFF0",
88
+ hotpink: "#FF69B4",
89
+ indianred: "#CD5C5C",
90
+ indigo: "#4B0082",
91
+ ivory: "#FFFFF0",
92
+ khaki: "#F0E68C",
93
+ lavender: "#E6E6FA",
94
+ lavenderblush: "#FFF0F5",
95
+ lawngreen: "#7CFC00",
96
+ lemonchiffon: "#FFFACD",
97
+ lightblue: "#ADD8E6",
98
+ lightcoral: "#F08080",
99
+ lightcyan: "#E0FFFF",
100
+ lightgoldenrodyellow: "#FAFAD2",
101
+ lightgray: "#D3D3D3",
102
+ lightgreen: "#90EE90",
103
+ lightgrey: "#D3D3D3",
104
+ lightpink: "#FFB6C1",
105
+ lightsalmon: "#FFA07A",
106
+ lightseagreen: "#20B2AA",
107
+ lightskyblue: "#87CEFA",
108
+ lightslategray: "#778899",
109
+ lightslategrey: "#778899",
110
+ lightsteelblue: "#B0C4DE",
111
+ lightyellow: "#FFFFE0",
112
+ limegreen: "#32CD32",
113
+ linen: "#FAF0E6",
114
+ magenta: "#FF00FF",
115
+ mediumaquamarine: "#66CDAA",
116
+ mediumblue: "#0000CD",
117
+ mediumorchid: "#BA55D3",
118
+ mediumpurple: "#9370DB",
119
+ mediumseagreen: "#3CB371",
120
+ mediumslateblue: "#7B68EE",
121
+ mediumspringgreen: "#00FA9A",
122
+ mediumturquoise: "#48D1CC",
123
+ mediumvioletred: "#C71585",
124
+ midnightblue: "#191970",
125
+ mintcream: "#F5FFFA",
126
+ mistyrose: "#FFE4E1",
127
+ moccasin: "#FFE4B5",
128
+ navajowhite: "#FFDEAD",
129
+ oldlace: "#FDF5E6",
130
+ olivedrab: "#6B8E23",
131
+ orange: "#FFA500",
132
+ orangered: "#FF4500",
133
+ orchid: "#DA70D6",
134
+ palegoldenrod: "#EEE8AA",
135
+ palegreen: "#98FB98",
136
+ paleturquoise: "#AFEEEE",
137
+ palevioletred: "#DB7093",
138
+ papayawhip: "#FFEFD5",
139
+ peachpuff: "#FFDAB9",
140
+ peru: "#CD853F",
141
+ pink: "#FFC0CB",
142
+ plum: "#DDA0DD",
143
+ powderblue: "#B0E0E6",
144
+ rebeccapurple: "#663399",
145
+ rosybrown: "#BC8F8F",
146
+ royalblue: "#4169E1",
147
+ saddlebrown: "#8B4513",
148
+ salmon: "#FA8072",
149
+ sandybrown: "#F4A460",
150
+ seagreen: "#2E8B57",
151
+ seashell: "#FFF5EE",
152
+ sienna: "#A0522D",
153
+ skyblue: "#87CEEB",
154
+ slateblue: "#6A5ACD",
155
+ slategray: "#708090",
156
+ slategrey: "#708090",
157
+ snow: "#FFFAFA",
158
+ springgreen: "#00FF7F",
159
+ steelblue: "#4682B4",
160
+ tan: "#D2B48C",
161
+ thistle: "#D8BFD8",
162
+ tomato: "#FF6347",
163
+ transparent: "#00000000",
164
+ turquoise: "#40E0D0",
165
+ violet: "#EE82EE",
166
+ wheat: "#F5DEB3",
167
+ whitesmoke: "#F5F5F5",
168
+ yellowgreen: "#9ACD32",
169
+ grape: "#CC5DE8",
170
+ dark: "#3B3B3B",
171
+ volcano: "#FA541C",
172
+ geekblue: "#2F54EB",
173
+ success: "#4CAF50",
174
+ info: "#2196F3",
175
+ warning: "#FF9800",
176
+ error: "#F44336"
177
+ });
178
+
179
+ //#endregion
180
+ export { CSS_COLORS as t };
package/dist/date.cjs ADDED
@@ -0,0 +1,332 @@
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
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
18
+ const require_primitives = require('./primitives-B26uZolQ.cjs');
19
+ const require_timezone = require('./timezone-Beh9IGpw.cjs');
20
+ const require_specials = require('./specials-DzLr1ZgU.cjs');
21
+ const require_utilities = require('./utilities-CLUmdQeV.cjs');
22
+ const require_guards = require('./guards-Efhp1mNy.cjs');
23
+ const require_parse = require('./parse-2ubxXZRp.cjs');
24
+
25
+ //#region src/date/utils.ts
26
+ /**
27
+ * * Extracts the hour and minute from a time string in `HH:MM` or `-HH:MM` format.
28
+ *
29
+ * @param time - The time string to extract from.
30
+ * @return The extracted hour and minute as number tuple.
31
+ */
32
+ function extractHourMinute(time) {
33
+ const [hour, minute] = time.split(":").map(Number);
34
+ return [hour, minute];
35
+ }
36
+ /**
37
+ * * Converts a time string `HH:MM` or `-HH:MM` into total minutes from `00:00`.
38
+ *
39
+ * @param time - The time in `HH:MM` or `-HH:MM` format.
40
+ * @returns The total minutes elapsed since `00:00`.
41
+ */
42
+ function getTotalMinutes(time) {
43
+ const isNegative = time.startsWith("-");
44
+ const [h, m] = extractHourMinute(isNegative ? time.slice(1) : time);
45
+ const total = h * 60 + m;
46
+ return isNegative ? -total : total;
47
+ }
48
+ /**
49
+ * * Returns the current date and time as `Date` object.
50
+ * - All the methods and properties of `new Date()` are accessible.
51
+ *
52
+ * @remarks This function is a simple wrapper around `new Date()` and is provided for consistency and potential future enhancements.
53
+ *
54
+ * @returns The current date and time as a `Date` object.
55
+ */
56
+ function getCurrentDateTime() {
57
+ return /* @__PURE__ */ new Date();
58
+ }
59
+ /**
60
+ * * Extract Time in `HH:MM` format from given UTC value.
61
+ *
62
+ * @param utc UTC value in `UTC-01:30` or `UTC+01:30` format.
63
+ * @returns The UTC value in `HH:MM` format.
64
+ */
65
+ function extractTimeFromUTC(utc) {
66
+ return utc.replace(/^UTC[+]?/g, "");
67
+ }
68
+ /**
69
+ * * Converts a UTC value in `UTC-01:30` or `UTC+01:30` format into total minutes in number.
70
+ *
71
+ * @param time - UTC value in `UTC-01:30` or `UTC+01:30` format.
72
+ * @returns The total minutes elapsed since `00:00`.
73
+ */
74
+ function extractMinutesFromUTC(utc) {
75
+ return getTotalMinutes(extractTimeFromUTC(utc));
76
+ }
77
+ /**
78
+ * * Converts a number of minutes into a time string in "HH:MM" format.
79
+ *
80
+ * @param minutes - The number of minutes to convert. Can be a number or a numeric string.
81
+ * @returns A string representing the time in "HH:MM" format.
82
+ *
83
+ * @remarks Always returns the absolute value of the minutes, ignoring the sign if they are negative.
84
+ *
85
+ * @example
86
+ * convertMinutesToTime(75); // "1:15"
87
+ * convertMinutesToTime(-45); // "0:45"
88
+ */
89
+ function convertMinutesToTime(minutes) {
90
+ const parsed = require_utilities.normalizeNumber(minutes);
91
+ if (require_primitives.isUndefined(parsed)) throw new TypeError(`Invalid numeric input!`, { cause: `${minutes} cannot be converted to a number.` });
92
+ const numMIn = Math.abs(parsed);
93
+ return `${String(Math.floor(numMIn / 60))}:${String(numMIn % 60).padStart(2, "0")}`;
94
+ }
95
+ /**
96
+ * * Converts a minute-based offset to a UTC offset string in the format `UTC±HH:MM`.
97
+ *
98
+ * @param minutes - The offset in minutes (positive or negative).
99
+ * @returns A formatted UTC offset string like `UTC+05:30` or `UTC-04:00`.
100
+ */
101
+ function formatUTCOffset(minutes) {
102
+ const parsed = require_utilities.normalizeNumber(minutes);
103
+ if (require_primitives.isUndefined(parsed)) throw new TypeError(`Invalid numeric input!`, { cause: `${minutes} cannot be converted to a number.` });
104
+ const sign = parsed < 0 ? "-" : "+";
105
+ const abs = Math.abs(parsed);
106
+ return `UTC${sign}${String(Math.floor(abs / 60)).padStart(2, "0")}:${String(abs % 60).padStart(2, "0")}`;
107
+ }
108
+ /** Get the current system's time zone identifier using {@link Intl.DateTimeFormat} API. */
109
+ function getNativeTimeZoneId() {
110
+ return Intl.DateTimeFormat().resolvedOptions().timeZone;
111
+ }
112
+ /**
113
+ * * Retrieves comprehensive time zone details using the {@link Intl.DateTimeFormat} API.
114
+ * @param tzId Optional timezone identifier. Defaults to the system timezone.
115
+ * @param date Optional date for which to resolve the information.
116
+ * @returns Object containing time zone identifier, names, and offset.
117
+ */
118
+ function getTimeZoneDetails(tzId, date) {
119
+ const TZ_NAME_TYPES = [
120
+ "long",
121
+ "longGeneric",
122
+ "longOffset"
123
+ ];
124
+ const $tzId = tzId || getNativeTimeZoneId();
125
+ const obj = { tzIdentifier: $tzId };
126
+ for (const type of TZ_NAME_TYPES) {
127
+ const key = `tzName${type[0].toUpperCase()}${type.slice(1)}`;
128
+ obj[key] = require_parse._resolveNativeTzName($tzId, type, date);
129
+ }
130
+ return obj;
131
+ }
132
+ /** Cache for offset to time zone */
133
+ const TZ_MAP = /* @__PURE__ */ new Map();
134
+ /**
135
+ * * Resolves all IANA time-zone identifiers that match a given UTC offset.
136
+ *
137
+ * @remarks
138
+ * - Uses an internal in-memory cache that persists for the lifetime of the running application.
139
+ * - The cache is lazily populated so the `offset`-to-`time-zone` mapping is computed only once per offset.
140
+ * - Offset and time-zone identifier detection uses the {@link Intl.DateTimeFormat} API.
141
+ *
142
+ * @param offset The UTC offset in `"UTC±HH:MM"` format.
143
+ * @returns An array of matching IANA time-zone identifiers, or an empty array if the offset is invalid.
144
+ */
145
+ function getTimeZoneIds(offset) {
146
+ if (!require_guards.isValidUTCOffset(offset)) return [];
147
+ if (TZ_MAP.has(offset)) return TZ_MAP.get(offset) ?? [];
148
+ for (const zone of require_timezone.NATIVE_TZ_IDS) {
149
+ const off = require_parse._gmtToUtcOffset(require_parse._resolveNativeTzName(zone, "longOffset"));
150
+ if (off) TZ_MAP.set(off, [...TZ_MAP.get(off) ?? [], zone]);
151
+ }
152
+ return TZ_MAP.get(offset) ?? [];
153
+ }
154
+ /**
155
+ * * Formats a date into a specified string format.
156
+ *
157
+ * @param options Options to control date and time formatting.
158
+ *
159
+ * @remarks
160
+ * - If no date is provided, the current date and time will be used.
161
+ * - If the provided date is invalid, the function will return `'Invalid Date!'`.
162
+ * - The default format is `'dd, mmm DD, YYYY HH:mm:ss'` (e.g., `'Sun, Apr 06, 2025 16:11:55'`).
163
+ * - By default, local time is used; set `useUTC` to `true` to format in UTC.
164
+ * - The format string supports various tokens for date and time components, as well as literal text enclosed in square brackets.
165
+ * - See {@link https://toolbox.nazmul-nhb.dev/docs/utilities/date/formatDate#format-tokens format tokens} for details on supported tokens.
166
+ * - For more complex date/time manipulations, consider using the {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos Chronos} class.
167
+ *
168
+ * @returns Date/time string in specified format.
169
+ */
170
+ function formatDate(options) {
171
+ const { date = /* @__PURE__ */ new Date(), format = "dd, mmm DD, YYYY HH:mm:ss", useUTC = false } = options ?? {};
172
+ const $date = require_parse._dateArgsToDate(date);
173
+ if (isNaN($date.getTime())) return "Invalid Date!";
174
+ /** Get unit value for {@link $date} for specific unit in local or UTC time */
175
+ const _getUnitValue = (suffix) => {
176
+ return useUTC ? $date[`getUTC${suffix}`]() : $date[`get${suffix}`]();
177
+ };
178
+ return require_parse._formatDate(format, _getUnitValue("FullYear"), _getUnitValue("Month"), _getUnitValue("Day"), _getUnitValue("Date"), _getUnitValue("Hours"), _getUnitValue("Minutes"), _getUnitValue("Seconds"), _getUnitValue("Milliseconds"), useUTC ? "Z" : formatUTCOffset(-$date.getTimezoneOffset()).slice(3));
179
+ }
180
+ /**
181
+ * * Formats a time-only string into a formatted time string.
182
+ *
183
+ * @param time - Time string to be formatted. Supported formats include:
184
+ * - `HH:mm` → e.g., `'14:50'`
185
+ * - `HH:mm:ss` → e.g., `'14:50:00'`
186
+ * - `HH:mm:ss.mss` → e.g., `'14:50:00.800'`
187
+ * - `HH:mm+TimeZoneOffset(HH)` → e.g., `'14:50+06'`
188
+ * - `HH:mm+TimeZoneOffset(HH:mm)` → e.g., `'14:50+06:00'`
189
+ * - `HH:mm:ss+TimeZoneOffset(HH)` → e.g., `'14:50:00+06'`
190
+ * - `HH:mm:ss+TimeZoneOffset(HH:mm)` → e.g., `'14:50:00+05:30'`
191
+ * - `HH:mm:ss.mss+TimeZoneOffset(HH)` → e.g., `'14:50:00.800+06'`
192
+ * - `HH:mm:ss.mss+TimeZoneOffset(HH:mm)` → e.g., `'14:50:00.800+06:30'`
193
+ *
194
+ * - *Input will default to today's date and assume local timezone if no offset is provided.*
195
+ *
196
+ * @param format - Format tokens accepted by {@link formatDate} method ({@link TimeOnlyFormat}) for time part only.
197
+ * Default: `hh:mm:ss a` → 02:33:36 pm.
198
+ * @returns Formatted time string in local (System) time.
199
+ */
200
+ function formatTimePart(time, format) {
201
+ return formatDate({
202
+ date: `${formatDate({ format: "YYYY-MM-DD" })}T${require_parse._normalizeOffset(time)}`,
203
+ format: format || "hh:mm:ss a"
204
+ });
205
+ }
206
+ /**
207
+ * * Formats a date as a relative time string (e.g., "5m ago", "2h from now").
208
+ *
209
+ * @param date - The date to format, which can be a `Date` object, a date string, or a timestamp number.
210
+ * @param format - Optional format string for dates older than 7 days. Defaults to `'mmm D, yyyy hh:mm a'`.
211
+ * @returns A relative time string if the date is within the last 7 days, otherwise a formatted date string.
212
+ *
213
+ * @remarks
214
+ * - If date is provided but `undefined`, current date and time will be used.
215
+ * - If the provided date is invalid, the function will return `'Invalid Date!'`.
216
+ * - For dates within the last 7 days, the output will be in the format of "Xm ago" or "Xh from now".
217
+ * - For dates older than 7 days, the output will be formatted using the provided `format` string or the default format if none is provided.
218
+ *
219
+ * @example
220
+ * formatDateRelative(Date.now() - 5 * 60000); // "5m ago"
221
+ * formatDateRelative(Date.now() + 2 * 3600000); // "2h from now"
222
+ * formatDateRelative(Date.now() - 10 * 86400000); // "Apr 6, 2026 04:11 PM" (formatted date string)
223
+ */
224
+ function formatDateRelative(date, format) {
225
+ const $date = require_parse._dateArgsToDate(date);
226
+ if (isNaN($date.getTime())) return "Invalid Date!";
227
+ const now = Date.now();
228
+ const then = $date.getTime();
229
+ const diff = Math.abs(now - then);
230
+ const minutes = Math.floor(diff / 6e4);
231
+ const hours = Math.floor(diff / 36e5);
232
+ const days = Math.floor(diff / 864e5);
233
+ const suffix = then < now ? "ago" : "from now";
234
+ if (minutes < 1) return "Just now";
235
+ if (minutes < 60) return `${minutes}m ${suffix}`;
236
+ if (hours < 24) return `${hours}h ${suffix}`;
237
+ if (days < 7) return `${days}d ${suffix}`;
238
+ return formatDate({
239
+ date,
240
+ format: format || "mmm D, yyyy hh:mm a"
241
+ });
242
+ }
243
+ /** Get timestamp in ISO 8601 format. */
244
+ function getTimestamp(args, format) {
245
+ let $value;
246
+ let $format;
247
+ const _isTsOptions = (opt) => {
248
+ return require_specials.isObject(opt) && ("value" in opt || "format" in opt);
249
+ };
250
+ if (_isTsOptions(args)) {
251
+ $value = args.value || /* @__PURE__ */ new Date();
252
+ $format = args.format || "utc";
253
+ } else {
254
+ $value = args || /* @__PURE__ */ new Date();
255
+ $format = format || "utc";
256
+ }
257
+ let date = require_parse._dateArgsToDate($value);
258
+ if (isNaN(date.getTime())) date = /* @__PURE__ */ new Date();
259
+ if ($format === "local") {
260
+ const offsetMins = date.getTimezoneOffset();
261
+ const localDate = /* @__PURE__ */ new Date(date.getTime() - offsetMins * 6e4);
262
+ const offset = formatUTCOffset(-offsetMins).slice(3);
263
+ return localDate.toISOString().replace("Z", offset);
264
+ }
265
+ return date.toISOString();
266
+ }
267
+
268
+ //#endregion
269
+ //#region src/date/greet.ts
270
+ /**
271
+ * * Returns a greeting message based on the provided time or current time.
272
+ *
273
+ * @param configs - Configuration options for greeting times and messages.
274
+ * @returns The appropriate greeting message.
275
+ */
276
+ function getGreeting(configs) {
277
+ const { morningEnds = "11:59", noonEnds = "12:59", afternoonEnds = "17:59", eveningEnds = "23:59", midnightEnds = "02:59", currentTime, appendToMsg = "", prependToMsg = "", morningMessage = "Good Morning!", noonMessage = "Good Noon!", afternoonMessage = "Good Afternoon!", eveningMessage = "Good Evening!", midnightMessage = "Hello, Night Owl!", defaultMessage = "Greetings!" } = configs || {};
278
+ let hour;
279
+ let minute;
280
+ if (currentTime && require_guards.isValidTime(currentTime)) [hour, minute] = extractHourMinute(currentTime);
281
+ else {
282
+ hour = getCurrentDateTime().getHours();
283
+ minute = getCurrentDateTime().getMinutes();
284
+ }
285
+ const currentTotalMinutes = hour * 60 + minute;
286
+ const morningEndMinutes = getTotalMinutes(morningEnds);
287
+ const noonEndMinutes = getTotalMinutes(noonEnds);
288
+ const afternoonEndMinutes = getTotalMinutes(afternoonEnds);
289
+ const eveningEndMinutes = getTotalMinutes(eveningEnds);
290
+ if (currentTotalMinutes <= getTotalMinutes(midnightEnds)) return prependToMsg.concat(midnightMessage.concat(appendToMsg));
291
+ else if (currentTotalMinutes <= morningEndMinutes) return prependToMsg.concat(morningMessage.concat(appendToMsg));
292
+ else if (currentTotalMinutes <= noonEndMinutes) return prependToMsg.concat(noonMessage.concat(appendToMsg));
293
+ else if (currentTotalMinutes <= afternoonEndMinutes) return prependToMsg.concat(afternoonMessage.concat(appendToMsg));
294
+ else if (currentTotalMinutes <= eveningEndMinutes) return prependToMsg.concat(eveningMessage.concat(appendToMsg));
295
+ else return prependToMsg.concat(defaultMessage.concat(appendToMsg));
296
+ }
297
+
298
+ //#endregion
299
+ exports.convertMinutesToHourMinutes = convertMinutesToTime;
300
+ exports.convertMinutesToTime = convertMinutesToTime;
301
+ exports.convertMinutesToUTCOffset = formatUTCOffset;
302
+ exports.extractHourMinute = extractHourMinute;
303
+ exports.extractMinutesFromUTC = extractMinutesFromUTC;
304
+ exports.extractTimeFromUTC = extractTimeFromUTC;
305
+ exports.extractTimeStringFromUTC = extractTimeFromUTC;
306
+ exports.extractTotalMinutesFromTime = getTotalMinutes;
307
+ exports.formatDate = formatDate;
308
+ exports.formatDateRelative = formatDateRelative;
309
+ exports.formatDateTime = formatDate;
310
+ exports.formatRelativeDate = formatDateRelative;
311
+ exports.formatRelativeTime = formatDateRelative;
312
+ exports.formatTimePart = formatTimePart;
313
+ exports.formatUTCOffset = formatUTCOffset;
314
+ exports.generateGreeting = getGreeting;
315
+ exports.getCurrentDateTime = getCurrentDateTime;
316
+ exports.getCurrentTime = getCurrentDateTime;
317
+ exports.getGreeting = getGreeting;
318
+ exports.getHourMinutesFromMinutes = convertMinutesToTime;
319
+ exports.getMinutesFromUTC = extractMinutesFromUTC;
320
+ exports.getNativeTimeZoneId = getNativeTimeZoneId;
321
+ exports.getTimeFromMinutes = convertMinutesToTime;
322
+ exports.getTimeStringFromUTC = extractTimeFromUTC;
323
+ exports.getTimeZoneDetails = getTimeZoneDetails;
324
+ exports.getTimeZoneIds = getTimeZoneIds;
325
+ exports.getTimestamp = getTimestamp;
326
+ exports.getTotalMinutes = getTotalMinutes;
327
+ exports.getTotalMinutesFromTime = getTotalMinutes;
328
+ exports.getTotalMinutesFromUTC = extractMinutesFromUTC;
329
+ exports.greet = getGreeting;
330
+ exports.minutesToUTCOffset = formatUTCOffset;
331
+ exports.parseMSec = require_parse.parseMSec;
332
+ exports.parseMs = require_parse.parseMSec;