@rzl-zone/utils-js 3.4.0 → 3.5.1

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 (118) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +94 -45
  3. package/dist/assertions/index.cjs +41 -1
  4. package/dist/assertions/index.d.ts +11 -2
  5. package/dist/assertions/index.js +14 -1
  6. package/dist/chunk-2CQX5CBG.js +262 -1
  7. package/dist/chunk-2IOOEY45.cjs +30 -1
  8. package/dist/chunk-2WA36TC5.cjs +189 -0
  9. package/dist/chunk-3IBQ5MOM.js +16 -1
  10. package/dist/chunk-3VA554KW.js +34 -1
  11. package/dist/chunk-5757UBXJ.cjs +157 -1
  12. package/dist/chunk-5IGC6PBH.js +33 -1
  13. package/dist/chunk-5KJFVIQT.cjs +65 -1
  14. package/dist/chunk-6JFCSH7J.js +35 -1
  15. package/dist/chunk-6JFZL7YE.cjs +24 -1
  16. package/dist/chunk-7ODAAXX5.cjs +397 -1
  17. package/dist/chunk-BAV5T2E3.cjs +15 -1
  18. package/dist/chunk-CAH33WOQ.cjs +36 -1
  19. package/dist/chunk-CDCERIZ2.js +177 -0
  20. package/dist/chunk-CKTLUNWX.js +22 -1
  21. package/dist/chunk-CMW2TBOQ.js +567 -1
  22. package/dist/chunk-D3ENH7H6.cjs +101 -1
  23. package/dist/chunk-DEZZUYE2.js +152 -1
  24. package/dist/chunk-DVMHRLKP.cjs +16 -1
  25. package/dist/chunk-DWF2R5GD.cjs +225 -1
  26. package/dist/chunk-E55EQK2U.cjs +18 -1
  27. package/dist/chunk-E74U6CYP.cjs +18 -1
  28. package/dist/chunk-EL6A35UR.cjs +64 -1
  29. package/dist/chunk-F6IPNNSJ.cjs +554 -1
  30. package/dist/chunk-FJZGG54N.cjs +267 -1
  31. package/dist/chunk-FWCKOJZM.js +542 -1
  32. package/dist/chunk-FWHNWL2P.cjs +419 -1
  33. package/dist/chunk-GGEADHZO.js +90 -1
  34. package/dist/chunk-GQR4R5WY.js +31 -1
  35. package/dist/chunk-H66AC7GK.cjs +93 -1
  36. package/dist/chunk-HQWOFR56.cjs +33 -1
  37. package/dist/chunk-HYRQMTRH.cjs +24 -1
  38. package/dist/chunk-IRFL4MAX.js +63 -1
  39. package/dist/chunk-IVL7CKVH.cjs +37 -1
  40. package/dist/chunk-IZPBKKPO.js +16 -1
  41. package/dist/chunk-JBQMXC5I.cjs +106 -1
  42. package/dist/chunk-JEQEF5WD.js +95 -1
  43. package/dist/chunk-JMJQCN74.js +370 -1
  44. package/dist/chunk-KHO2SBNA.cjs +16 -1
  45. package/dist/chunk-KVAL5PAG.cjs +26 -1
  46. package/dist/chunk-L5RDAVVH.js +14 -1
  47. package/dist/chunk-LS6U7FAY.cjs +110 -1
  48. package/dist/chunk-NBZWMBO6.js +101 -1
  49. package/dist/chunk-NRF6LWBC.cjs +56 -1
  50. package/dist/chunk-OI5XKNZO.js +53 -1
  51. package/dist/chunk-ONZFBJVW.js +14 -1
  52. package/dist/chunk-OYTYSY7G.js +106 -1
  53. package/dist/chunk-PET42Z7W.js +119 -1
  54. package/dist/chunk-PZQ6I4JJ.cjs +605 -1
  55. package/dist/chunk-QBKAEVYG.js +113 -1
  56. package/dist/chunk-QNKGP5DY.js +14 -1
  57. package/dist/chunk-RIPKY4RU.js +417 -1
  58. package/dist/chunk-RZW35UN5.cjs +116 -1
  59. package/dist/chunk-SBFNXGTJ.js +220 -1
  60. package/dist/chunk-SBKGWRS5.js +22 -1
  61. package/dist/chunk-SIM77PU4.js +59 -1
  62. package/dist/chunk-T2T7K3KR.js +28 -1
  63. package/dist/chunk-T7PU2V7X.cjs +123 -1
  64. package/dist/chunk-UDA26MCU.cjs +16 -1
  65. package/dist/chunk-V45XJKHW.cjs +18 -1
  66. package/dist/chunk-VJDDGRIK.cjs +16 -1
  67. package/dist/chunk-W2WNBUDE.js +16 -1
  68. package/dist/chunk-WVSPXFTY.js +14 -1
  69. package/dist/chunk-XABCB3Y7.cjs +582 -1
  70. package/dist/chunk-XEDXFSGI.js +24 -1
  71. package/dist/chunk-YKPSRP5G.js +571 -1
  72. package/dist/chunk-YWHHVDT4.js +13 -1
  73. package/dist/chunk-ZETAZZLD.cjs +38 -1
  74. package/dist/conversions/index.cjs +104 -1
  75. package/dist/conversions/index.d.ts +10 -1
  76. package/dist/conversions/index.js +25 -1
  77. package/dist/events/index.cjs +32 -1
  78. package/dist/events/index.d.ts +10 -1
  79. package/dist/events/index.js +13 -1
  80. package/dist/formatters/index.cjs +62 -1
  81. package/dist/formatters/index.d.ts +10 -1
  82. package/dist/formatters/index.js +19 -1
  83. package/dist/generators/index.cjs +38 -1
  84. package/dist/generators/index.d.ts +10 -1
  85. package/dist/generators/index.js +15 -1
  86. package/dist/index.d.ts +39 -12
  87. package/dist/{isPlainObject-CEPWPiXh.d.ts → isPlainObject-FWmcJF6k.d.ts} +13 -4
  88. package/dist/next/index.cjs +218 -1
  89. package/dist/next/index.d.ts +10 -1
  90. package/dist/next/index.js +213 -1
  91. package/dist/next/server/index.cjs +43 -1
  92. package/dist/next/server/index.d.ts +10 -1
  93. package/dist/next/server/index.js +41 -1
  94. package/dist/operations/index.cjs +33 -1
  95. package/dist/operations/index.d.ts +10 -1
  96. package/dist/operations/index.js +18 -1
  97. package/dist/parsers/index.cjs +18 -1
  98. package/dist/parsers/index.d.ts +10 -1
  99. package/dist/parsers/index.js +11 -1
  100. package/dist/predicates/index.cjs +299 -1
  101. package/dist/predicates/index.d.ts +13 -4
  102. package/dist/predicates/index.js +24 -1
  103. package/dist/promises/index.cjs +25 -1
  104. package/dist/promises/index.d.ts +10 -1
  105. package/dist/promises/index.js +14 -1
  106. package/dist/rzl-utils.global.js +25 -1
  107. package/dist/strings/index.cjs +82 -1
  108. package/dist/strings/index.d.ts +10 -1
  109. package/dist/strings/index.js +15 -1
  110. package/dist/tailwind/index.cjs +43 -1
  111. package/dist/tailwind/index.d.ts +10 -1
  112. package/dist/tailwind/index.js +12 -1
  113. package/dist/urls/index.cjs +51 -1
  114. package/dist/urls/index.d.ts +10 -1
  115. package/dist/urls/index.js +24 -1
  116. package/package.json +60 -179
  117. package/dist/chunk-JYQTCICM.js +0 -1
  118. package/dist/chunk-YLA3DURS.cjs +0 -1
@@ -1 +1,220 @@
1
- import{isURL as r}from"./chunk-ONZFBJVW.js";import{normalizeString as e}from"./chunk-IZPBKKPO.js";import{toStringArrayUnRecursive as t}from"./chunk-OI5XKNZO.js";import{isEmptyValue as n}from"./chunk-GQR4R5WY.js";import{isInteger as o}from"./chunk-WVSPXFTY.js";import{normalizePathname as a}from"./chunk-GGEADHZO.js";import{isEmptyString as i}from"./chunk-W2WNBUDE.js";import{assertIsArray as s}from"./chunk-CKTLUNWX.js";import{safeStableStringify as u}from"./chunk-PET42Z7W.js";import{isString as m,getPreciseType as c,isUndefined as p,isNonEmptyString as f,isFunction as l,isNumber as h,isError as y,isArray as b,isNil as d,isNull as w,isPlainObject as v,isBoolean as g,isNonEmptyArray as $}from"./chunk-CMW2TBOQ.js";var T=(o,a,b)=>{if(m(o)){if(i(o))throw new TypeError("First parameter (`baseUrl`) cannot be an empty-string.");o=e(o)}else if(!r(o))throw new TypeError(`First parameter (\`baseUrl\`) must be of type an URL instance or a \`string\` and a non empty-string, but received: \`${c(o)}\`, with current value: \`${u(o)}\`.`);if(!p(b)&&(s(b,{message:({currentType:r,validType:e})=>`Third parameter (\`removeParams\`) must be of type \`${e} of strings\`, but received: \`${r}\`.`}),!b.every(r=>f(r))))throw new TypeError("Third parameter (`removeParams`) must be of type `array` and contains `string` only and non empty-string.");try{if(!p(a)&&!l(a[Symbol.iterator]))throw new TypeError(`Second parameter (\`queryParams\`) must be iterable (like URLSearchParams.entries() or an array of [[string, string | number]...]), but received: \`${c(a)}\`, with value: \`${u(a)}\`.`);const r=new URL(o);if(!p(a)){const e=Object.fromEntries(a);if(!n(e)){const n=new URLSearchParams(r.search);for(const[r,t]of Object.entries(e)){if(!f(t)&&!h(t,{includeNaN:!0}))throw new TypeError(`Second parameter (\`queryParams\`) must be iterable (like URLSearchParams.entries() or an array of [[string, string | number]...]), but received: \`${c(a)}\`, with value: \`${u(a)}\`.`);n.set(r,String(t))}b?.length&&t(b).map(r=>{n.delete(r)}),r.search=n.toString()}}return b?.forEach(e=>r.searchParams.delete(e)),r}catch(r){if(y(r))throw r;throw new Error("Failed to construct a valid URL in `constructURL()`, Error:"+r)}},E=r=>{if(!f(r))return null;let e;try{e=decodeURIComponent(r)}catch{return null}const t=e.match(/https?:\/\/.*?(?=https?:\/\/|\s|$)/g);if(!t)return null;const n=t.map(r=>r.replace(/[.,;:!?)]*$/,"")).filter(r=>{try{const e=new URL(r);return"http:"===e.protocol||"https:"===e.protocol}catch{return!1}});return n.length?n:null},P=(r,e="/")=>{if(!f(e))throw new TypeError(`Second parameter (\`defaultValue\`) must be of type \`string\` and not an \`empty-string\`, but received: \`${c(e)}\`, with value: \`${u(e)}\`.`);if(b(r)){if(!r.every(r=>m(r)))throw new TypeError(`First parameter (\`result\`) must be of type \`string\` or \`array of string\`, but received: \`${c(r)}\`, with value: \`${u(r)}\`.`);for(const e of r){const r=a(e);if("/"!==r)return r}return a(e)}if(m(r)){const t=a(r);return"/"!==t?t:a(e)}if(!d(r))throw new TypeError(`First parameter (\`result\`) must be of type \`string\`, \`array-string\`, \`null\` or \`undefined\`, but received: \`${c(r)}\`.`);return a(e)},j=(r,e=null,t={})=>{const n=[];m(r)||b(r)||n.push(`First parameter (\`url\`) must be of type \`string\` or \`array-string\`, but received: \`${c(r)}\`.`),m(e)||b(e)||w(e)||n.push(`Second parameter (\`base\`) must be of type \`string\`, \`array-string\` or \`null\`, but received: \`${c(e)}\`.`),v(t)||n.push(`Second parameter (\`options\`) must be of type \`plain-object\`, but received: \`${c(t)}\`.`);const{levels:i=1,removeDuplicates:s=!0}=t;if((!o(i)||o(i)&&i<0)&&n.push(`Parameter \`levels\` property of the \`options\` (second parameter) must be of type \`integer-number\` and minimum is \`0\`, but received: \`${c(i)}\`, with value: \`${u(i)}\`.`),g(s)||n.push(`Parameter \`removeDuplicates\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: \`${c(s)}\`.`),$(n))throw new TypeError(`Invalid parameter(s) in \`getPrefixPathname\` function:\n- ${n.join("\n- ")}`);function p(r){return`/${a(r).split("/").filter(Boolean).slice(0,i).join("/")}`}function l(r){if(e){if(r=a(r),b(e)){for(const t of e)if(r.startsWith(a(t)))return p(r)}else if(f(e)&&r.startsWith(a(e)))return p(r);return null}return p(r)}if(b(r)){const e=r.map(l).filter(r=>!w(r)),t=s?[...new Set(e)]:e;return 1===t.length?t[0]:t}return l(r)};export{T as constructURL,E as extractURLs,P as getFirstPrefixPathname,j as getPrefixPathname};
1
+ /*!
2
+ * ====================================================
3
+ * Rzl Utils-JS.
4
+ * ----------------------------------------------------
5
+ * Version: 3.5.1.
6
+ * Author: Rizalvin Dwiky.
7
+ * Repository: https://github.com/rzl-zone/utils-js.
8
+ * ====================================================
9
+ */
10
+ import { isURL } from './chunk-ONZFBJVW.js';
11
+ import { normalizeString } from './chunk-IZPBKKPO.js';
12
+ import { toStringArrayUnRecursive } from './chunk-OI5XKNZO.js';
13
+ import { isEmptyValue } from './chunk-GQR4R5WY.js';
14
+ import { isInteger } from './chunk-WVSPXFTY.js';
15
+ import { normalizePathname } from './chunk-GGEADHZO.js';
16
+ import { isEmptyString } from './chunk-W2WNBUDE.js';
17
+ import { assertIsArray } from './chunk-CKTLUNWX.js';
18
+ import { safeStableStringify } from './chunk-PET42Z7W.js';
19
+ import { isString, getPreciseType, isUndefined, isNonEmptyString, isFunction, isNumber, isError, isArray, isNil, isNull, isPlainObject, isBoolean, isNonEmptyArray } from './chunk-CMW2TBOQ.js';
20
+
21
+ var constructURL = (baseUrl, queryParams, removeParams) => {
22
+ if (isString(baseUrl)) {
23
+ if (isEmptyString(baseUrl)) {
24
+ throw new TypeError(`First parameter (\`baseUrl\`) cannot be an empty-string.`);
25
+ }
26
+ baseUrl = normalizeString(baseUrl);
27
+ } else if (!isURL(baseUrl)) {
28
+ throw new TypeError(
29
+ `First parameter (\`baseUrl\`) must be of type an URL instance or a \`string\` and a non empty-string, but received: \`${getPreciseType(
30
+ baseUrl
31
+ )}\`, with current value: \`${safeStableStringify(baseUrl)}\`.`
32
+ );
33
+ }
34
+ if (!isUndefined(removeParams)) {
35
+ assertIsArray(removeParams, {
36
+ message: ({ currentType, validType }) => `Third parameter (\`removeParams\`) must be of type \`${validType} of strings\`, but received: \`${currentType}\`.`
37
+ });
38
+ if (!removeParams.every((param) => isNonEmptyString(param))) {
39
+ throw new TypeError(
40
+ `Third parameter (\`removeParams\`) must be of type \`array\` and contains \`string\` only and non empty-string.`
41
+ );
42
+ }
43
+ }
44
+ try {
45
+ if (!isUndefined(queryParams) && !isFunction(queryParams[Symbol.iterator])) {
46
+ throw new TypeError(
47
+ `Second parameter (\`queryParams\`) must be iterable (like URLSearchParams.entries() or an array of [[string, string | number]...]), but received: \`${getPreciseType(
48
+ queryParams
49
+ )}\`, with value: \`${safeStableStringify(queryParams)}\`.`
50
+ );
51
+ }
52
+ const urlInstance = new URL(baseUrl);
53
+ if (!isUndefined(queryParams)) {
54
+ const paramObject = Object.fromEntries(queryParams);
55
+ if (!isEmptyValue(paramObject)) {
56
+ const mergedParams = new URLSearchParams(urlInstance.search);
57
+ for (const [key, value] of Object.entries(paramObject)) {
58
+ if (!isNonEmptyString(value) && !isNumber(value, { includeNaN: true })) {
59
+ throw new TypeError(
60
+ `Second parameter (\`queryParams\`) must be iterable (like URLSearchParams.entries() or an array of [[string, string | number]...]), but received: \`${getPreciseType(
61
+ queryParams
62
+ )}\`, with value: \`${safeStableStringify(queryParams)}\`.`
63
+ );
64
+ }
65
+ mergedParams.set(key, String(value));
66
+ }
67
+ if (removeParams?.length) {
68
+ toStringArrayUnRecursive(removeParams).map((paramKey) => {
69
+ mergedParams.delete(paramKey);
70
+ });
71
+ }
72
+ urlInstance.search = mergedParams.toString();
73
+ }
74
+ }
75
+ removeParams?.forEach((param) => urlInstance.searchParams.delete(param));
76
+ return urlInstance;
77
+ } catch (error) {
78
+ if (isError(error)) throw error;
79
+ throw new Error(
80
+ "Failed to construct a valid URL in `constructURL()`, Error:" + error
81
+ );
82
+ }
83
+ };
84
+
85
+ var extractURLs = (url) => {
86
+ if (!isNonEmptyString(url)) return null;
87
+ let decoded;
88
+ try {
89
+ decoded = decodeURIComponent(url);
90
+ } catch {
91
+ return null;
92
+ }
93
+ const urlPattern = /https?:\/\/.*?(?=https?:\/\/|\s|$)/g;
94
+ const matches = decoded.match(urlPattern);
95
+ if (!matches) return null;
96
+ const cleaned = matches.map((url2) => url2.replace(/[.,;:!?)]*$/, "")).filter((url2) => {
97
+ try {
98
+ const u = new URL(url2);
99
+ return u.protocol === "http:" || u.protocol === "https:";
100
+ } catch {
101
+ return false;
102
+ }
103
+ });
104
+ return cleaned.length ? cleaned : null;
105
+ };
106
+
107
+ var getFirstPrefixPathname = (result, defaultValue = "/") => {
108
+ if (!isNonEmptyString(defaultValue)) {
109
+ throw new TypeError(
110
+ `Second parameter (\`defaultValue\`) must be of type \`string\` and not an \`empty-string\`, but received: \`${getPreciseType(
111
+ defaultValue
112
+ )}\`, with value: \`${safeStableStringify(defaultValue)}\`.`
113
+ );
114
+ }
115
+ if (isArray(result)) {
116
+ if (!result.every((item) => isString(item))) {
117
+ throw new TypeError(
118
+ `First parameter (\`result\`) must be of type \`string\` or \`array of string\`, but received: \`${getPreciseType(
119
+ result
120
+ )}\`, with value: \`${safeStableStringify(result)}\`.`
121
+ );
122
+ }
123
+ for (const item of result) {
124
+ const normalized = normalizePathname(item);
125
+ if (normalized !== "/") {
126
+ return normalized;
127
+ }
128
+ }
129
+ return normalizePathname(defaultValue);
130
+ }
131
+ if (isString(result)) {
132
+ const normalized = normalizePathname(result);
133
+ return normalized !== "/" ? normalized : normalizePathname(defaultValue);
134
+ }
135
+ if (!isNil(result)) {
136
+ throw new TypeError(
137
+ `First parameter (\`result\`) must be of type \`string\`, \`array-string\`, \`null\` or \`undefined\`, but received: \`${getPreciseType(
138
+ result
139
+ )}\`.`
140
+ );
141
+ }
142
+ return normalizePathname(defaultValue);
143
+ };
144
+
145
+ var getPrefixPathname = (url, base = null, options = {}) => {
146
+ const errors = [];
147
+ if (!isString(url) && !isArray(url)) {
148
+ errors.push(
149
+ `First parameter (\`url\`) must be of type \`string\` or \`array-string\`, but received: \`${getPreciseType(
150
+ url
151
+ )}\`.`
152
+ );
153
+ }
154
+ if (!isString(base) && !isArray(base) && !isNull(base)) {
155
+ errors.push(
156
+ `Second parameter (\`base\`) must be of type \`string\`, \`array-string\` or \`null\`, but received: \`${getPreciseType(
157
+ base
158
+ )}\`.`
159
+ );
160
+ }
161
+ if (!isPlainObject(options)) {
162
+ errors.push(
163
+ `Second parameter (\`options\`) must be of type \`plain-object\`, but received: \`${getPreciseType(
164
+ options
165
+ )}\`.`
166
+ );
167
+ }
168
+ const { levels = 1, removeDuplicates = true } = options;
169
+ if (!isInteger(levels) || isInteger(levels) && levels < 0) {
170
+ errors.push(
171
+ `Parameter \`levels\` property of the \`options\` (second parameter) must be of type \`integer-number\` and minimum is \`0\`, but received: \`${getPreciseType(
172
+ levels
173
+ )}\`, with value: \`${safeStableStringify(levels)}\`.`
174
+ );
175
+ }
176
+ if (!isBoolean(removeDuplicates)) {
177
+ errors.push(
178
+ `Parameter \`removeDuplicates\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: \`${getPreciseType(
179
+ removeDuplicates
180
+ )}\`.`
181
+ );
182
+ }
183
+ if (isNonEmptyArray(errors)) {
184
+ throw new TypeError(
185
+ `Invalid parameter(s) in \`getPrefixPathname\` function:
186
+ - ${errors.join("\n- ")}`
187
+ );
188
+ }
189
+ function getLevel(singleUrl) {
190
+ const parts = normalizePathname(singleUrl).split("/").filter(Boolean);
191
+ return `/${parts.slice(0, levels).join("/")}`;
192
+ }
193
+ function processUrl(singleUrl) {
194
+ if (base) {
195
+ singleUrl = normalizePathname(singleUrl);
196
+ if (isArray(base)) {
197
+ for (const b of base) {
198
+ if (singleUrl.startsWith(normalizePathname(b))) {
199
+ return getLevel(singleUrl);
200
+ }
201
+ }
202
+ } else if (isNonEmptyString(base) && singleUrl.startsWith(normalizePathname(base))) {
203
+ return getLevel(singleUrl);
204
+ }
205
+ return null;
206
+ }
207
+ return getLevel(singleUrl);
208
+ }
209
+ if (isArray(url)) {
210
+ const result = url.map(processUrl).filter((r) => !isNull(r));
211
+ const uniqueResult = removeDuplicates ? [...new Set(result)] : result;
212
+ if (uniqueResult.length === 1) {
213
+ return uniqueResult[0];
214
+ }
215
+ return uniqueResult;
216
+ }
217
+ return processUrl(url);
218
+ };
219
+
220
+ export { constructURL, extractURLs, getFirstPrefixPathname, getPrefixPathname };
@@ -1 +1,22 @@
1
- import{isString as r,resolveErrorMessageAssertions as e}from"./chunk-CMW2TBOQ.js";var o=(o,t={})=>{if(r(o))return;const i=e({value:o,options:t,requiredValidType:"string"});throw new TypeError(i)};export{o as assertIsString};
1
+ /*!
2
+ * ====================================================
3
+ * Rzl Utils-JS.
4
+ * ----------------------------------------------------
5
+ * Version: 3.5.1.
6
+ * Author: Rizalvin Dwiky.
7
+ * Repository: https://github.com/rzl-zone/utils-js.
8
+ * ====================================================
9
+ */
10
+ import { isString, resolveErrorMessageAssertions } from './chunk-CMW2TBOQ.js';
11
+
12
+ var assertIsString = (value, options = {}) => {
13
+ if (isString(value)) return;
14
+ const errorMessage = resolveErrorMessageAssertions({
15
+ value,
16
+ options,
17
+ requiredValidType: "string"
18
+ });
19
+ throw new TypeError(errorMessage);
20
+ };
21
+
22
+ export { assertIsString };
@@ -1 +1,59 @@
1
- import{isServer as e}from"./chunk-L5RDAVVH.js";import{assertIsString as t}from"./chunk-SBKGWRS5.js";import{isPlainObject as o,hasOwnProp as s,isNonEmptyString as r,isNumber as i}from"./chunk-CMW2TBOQ.js";var n=(o="on_processing")=>{if(e())return;t(o,{message:({validType:e,currentType:t})=>`First parameter \`className\` must be of type \`${e}\`, but received: \`${t}\`.`});const{documentElement:s}=document;s&&!s.classList.contains(o)&&s.classList.add(o)},m=(o="on_processing")=>{if(e())return;t(o,{message:({validType:e,currentType:t})=>`First parameter \`className\` must be of type \`${e}\`, but received: \`${t}\`.`});const{documentElement:s}=document;s&&s.classList.contains(o)&&s.classList.remove(o)},c=()=>{if(e())return;const t=document.activeElement;t instanceof HTMLElement&&t.blur()},a=t=>{if(e())return;o(t)||(t={});const n=s(t,"behavior")&&r(t.behavior)&&["auto","instant","smooth"].includes(t.behavior)?t.behavior:"smooth";let m=s(t,"timeout")&&i(t.timeout)&&t.timeout>=1?t.timeout:1;m=m>2147483647?2147483647:m,setTimeout(()=>window.scrollTo({top:0,left:0,behavior:n}),m)};export{n as disableUserInteraction,m as enableUserInteraction,c as removeElementFocus,a as scrollToTop};
1
+ /*!
2
+ * ====================================================
3
+ * Rzl Utils-JS.
4
+ * ----------------------------------------------------
5
+ * Version: 3.5.1.
6
+ * Author: Rizalvin Dwiky.
7
+ * Repository: https://github.com/rzl-zone/utils-js.
8
+ * ====================================================
9
+ */
10
+ import { isServer } from './chunk-L5RDAVVH.js';
11
+ import { assertIsString } from './chunk-SBKGWRS5.js';
12
+ import { isPlainObject, hasOwnProp, isNonEmptyString, isNumber } from './chunk-CMW2TBOQ.js';
13
+
14
+ var disableUserInteraction = (className = "on_processing") => {
15
+ if (isServer()) return;
16
+ assertIsString(className, {
17
+ message({ validType, currentType }) {
18
+ return `First parameter \`className\` must be of type \`${validType}\`, but received: \`${currentType}\`.`;
19
+ }
20
+ });
21
+ const { documentElement } = document;
22
+ if (documentElement && !documentElement.classList.contains(className)) {
23
+ documentElement.classList.add(className);
24
+ }
25
+ };
26
+
27
+ var enableUserInteraction = (className = "on_processing") => {
28
+ if (isServer()) return;
29
+ assertIsString(className, {
30
+ message({ validType, currentType }) {
31
+ return `First parameter \`className\` must be of type \`${validType}\`, but received: \`${currentType}\`.`;
32
+ }
33
+ });
34
+ const { documentElement } = document;
35
+ if (documentElement && documentElement.classList.contains(className)) {
36
+ documentElement.classList.remove(className);
37
+ }
38
+ };
39
+
40
+ var removeElementFocus = () => {
41
+ if (isServer()) return;
42
+ const activeElement = document.activeElement;
43
+ if (activeElement instanceof HTMLElement) {
44
+ activeElement.blur();
45
+ }
46
+ };
47
+
48
+ var scrollToTop = (options) => {
49
+ if (isServer()) return;
50
+ if (!isPlainObject(options)) {
51
+ options = {};
52
+ }
53
+ const behavior = hasOwnProp(options, "behavior") && isNonEmptyString(options.behavior) && ["auto", "instant", "smooth"].includes(options.behavior) ? options.behavior : "smooth";
54
+ let timeout = hasOwnProp(options, "timeout") && isNumber(options.timeout) && options.timeout >= 1 ? options.timeout : 1;
55
+ timeout = timeout > 2147483647 ? 2147483647 : timeout;
56
+ setTimeout(() => window.scrollTo({ top: 0, left: 0, behavior }), timeout);
57
+ };
58
+
59
+ export { disableUserInteraction, enableUserInteraction, removeElementFocus, scrollToTop };
@@ -1 +1,28 @@
1
- import{isNonEmptyString as r,isPlainObject as t}from"./chunk-CMW2TBOQ.js";var i=(i,m={withTrim:!0,trimOnly:!1})=>{if(!r(i))return"";t(m)||(m={});const{trimOnly:n=!1,withTrim:e=!0}=m;return n?i.trim():(e&&(i=i.trim()),i.replace(/\s+/g," "))};export{i as normalizeSpaces};
1
+ /*!
2
+ * ====================================================
3
+ * Rzl Utils-JS.
4
+ * ----------------------------------------------------
5
+ * Version: 3.5.1.
6
+ * Author: Rizalvin Dwiky.
7
+ * Repository: https://github.com/rzl-zone/utils-js.
8
+ * ====================================================
9
+ */
10
+ import { isNonEmptyString, isPlainObject } from './chunk-CMW2TBOQ.js';
11
+
12
+ var normalizeSpaces = (value, options = {
13
+ withTrim: true,
14
+ trimOnly: false
15
+ }) => {
16
+ if (!isNonEmptyString(value)) return "";
17
+ if (!isPlainObject(options)) {
18
+ options = {};
19
+ }
20
+ const { trimOnly = false, withTrim = true } = options;
21
+ if (trimOnly) return value.trim();
22
+ if (withTrim) {
23
+ value = value.trim();
24
+ }
25
+ return value.replace(/\s+/g, " ");
26
+ };
27
+
28
+ export { normalizeSpaces };
@@ -1 +1,123 @@
1
- "use strict";var e=require("./chunk-UDA26MCU.cjs"),r=require("./chunk-PZQ6I4JJ.cjs");function t(e){return"[object Map]"===Object.prototype.toString.call(e)||e instanceof Map}var n=(e,t={})=>{r.assertIsPlainObject(t,{message:({currentType:e,validType:r})=>`Second parameter (\`options\`) must be of type \`${r}\`, but received: \`${e}\`.`});const n=!(!r.isPlainObject(t)||!r.isBoolean(t.skipInvalidDate))&&t.skipInvalidDate,i=e instanceof Date;return n?i:i&&!r.isNaN(e.getTime())};exports.isDate=n,exports.isMap=t,exports.safeStableStringify=(i,s={})=>{r.assertIsPlainObject(s,{message:({currentType:e,validType:r})=>`Second parameter (\`options\`) must be of type \`${r}\`, but received: \`${e}\`.`});const o=!!r.hasOwnProp(s,"pretty")&&s.pretty,a=!r.hasOwnProp(s,"sortKeys")||s.sortKeys,u=!!r.hasOwnProp(s,"sortArray")&&s.sortArray,c=!!r.hasOwnProp(s,"keepUndefined")&&s.keepUndefined;if(!(r.isBoolean(a)&&r.isBoolean(u)&&r.isBoolean(o)&&r.isBoolean(c)))throw new TypeError(`Parameters \`sortKeys\`, \`sortArray\`, \`keepUndefined\` and \`pretty\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: "['sortKeys': \`${r.getPreciseType(a)}\`, 'sortArray': \`${r.getPreciseType(u)}\`, 'keepUndefined': \`${r.getPreciseType(c)}\`, 'pretty': \`${r.getPreciseType(o)}\`]".`);if(r.isUndefined(i))return c?"undefined":"null";const p=new WeakSet,f=e=>r.isNull(e)||!r.isObjectOrArray(e)&&!r.isFunction(e),l=i=>{if(r.isNumberObject(i)){const e=i.valueOf();return r.isNaN(e)||r.isInfinityNumber(e)?null:e}if(r.isStringObject(i))return i.valueOf();if(r.isBooleanObject(i))return i.valueOf();if(!r.isFunction(i)&&!r.isSymbol(i)){if(e.isBigInt(i))return i.toString();if(r.isNaN(i)||r.isInfinityNumber(i))return null;if(r.isUndefined(i))return c?void 0:null;if(r.isObjectOrArray(i)){if(p.has(i))return"[Circular]";if(p.add(i),n(i))return i.toISOString();if(t(i))return{map:Array.from(i.entries()).map(([e,r])=>[e,l(r)])};if(r.isSet(i))return{set:Array.from(i.values()).map(l)};if(r.isArray(i)){const e=i.map(l);if(u){const t=[],n=[];for(const r of e)f(r)?t.push(r):n.push(r);return t.sort((e,t)=>r.isNumber(e)&&r.isNumber(t)?e-t:String(e).localeCompare(String(t))),[...t,...n]}return e}const e=Object.keys(i);a&&e.sort((e,t)=>{const n=Number(e),i=Number(t);return r.isNaN(n)||r.isNaN(i)?e.localeCompare(t):n-i});const s={};if(r.isObject(i))for(const t of e){const e=l(i[t]);r.isUndefined(e)||(s[t]=e)}return s}return i}};try{return JSON.stringify(l(i),null,o?2:0)}catch(e){return console.warn("Error in safeStableStringify:",e),"{}"}};
1
+ /*!
2
+ * ====================================================
3
+ * Rzl Utils-JS.
4
+ * ----------------------------------------------------
5
+ * Version: 3.5.1.
6
+ * Author: Rizalvin Dwiky.
7
+ * Repository: https://github.com/rzl-zone/utils-js.
8
+ * ====================================================
9
+ */
10
+ 'use strict';
11
+
12
+ var chunkUDA26MCU_cjs = require('./chunk-UDA26MCU.cjs');
13
+ var chunkPZQ6I4JJ_cjs = require('./chunk-PZQ6I4JJ.cjs');
14
+
15
+ function isMap(value) {
16
+ return Object.prototype.toString.call(value) === "[object Map]" || value instanceof Map;
17
+ }
18
+
19
+ var isDate = (value, options = {}) => {
20
+ chunkPZQ6I4JJ_cjs.assertIsPlainObject(options, {
21
+ message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
22
+ });
23
+ const skipInvalidDate = chunkPZQ6I4JJ_cjs.isPlainObject(options) && chunkPZQ6I4JJ_cjs.isBoolean(options.skipInvalidDate) ? options.skipInvalidDate : false;
24
+ const instanceDate = value instanceof Date;
25
+ if (skipInvalidDate) return instanceDate;
26
+ return instanceDate && !chunkPZQ6I4JJ_cjs.isNaN(value.getTime());
27
+ };
28
+
29
+ var safeStableStringify = (value, options = {}) => {
30
+ chunkPZQ6I4JJ_cjs.assertIsPlainObject(options, {
31
+ message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
32
+ });
33
+ const pretty = chunkPZQ6I4JJ_cjs.hasOwnProp(options, "pretty") ? options.pretty : false;
34
+ const sortKeys = chunkPZQ6I4JJ_cjs.hasOwnProp(options, "sortKeys") ? options.sortKeys : true;
35
+ const sortArray = chunkPZQ6I4JJ_cjs.hasOwnProp(options, "sortArray") ? options.sortArray : false;
36
+ const keepUndefined = chunkPZQ6I4JJ_cjs.hasOwnProp(options, "keepUndefined") ? options.keepUndefined : false;
37
+ if (!chunkPZQ6I4JJ_cjs.isBoolean(sortKeys) || !chunkPZQ6I4JJ_cjs.isBoolean(sortArray) || !chunkPZQ6I4JJ_cjs.isBoolean(pretty) || !chunkPZQ6I4JJ_cjs.isBoolean(keepUndefined)) {
38
+ throw new TypeError(
39
+ `Parameters \`sortKeys\`, \`sortArray\`, \`keepUndefined\` and \`pretty\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: "['sortKeys': \`${chunkPZQ6I4JJ_cjs.getPreciseType(
40
+ sortKeys
41
+ )}\`, 'sortArray': \`${chunkPZQ6I4JJ_cjs.getPreciseType(
42
+ sortArray
43
+ )}\`, 'keepUndefined': \`${chunkPZQ6I4JJ_cjs.getPreciseType(
44
+ keepUndefined
45
+ )}\`, 'pretty': \`${chunkPZQ6I4JJ_cjs.getPreciseType(pretty)}\`]".`
46
+ );
47
+ }
48
+ if (chunkPZQ6I4JJ_cjs.isUndefined(value)) {
49
+ return keepUndefined ? "undefined" : "null";
50
+ }
51
+ const seen = /* @__PURE__ */ new WeakSet();
52
+ const isPrimitive = (val) => chunkPZQ6I4JJ_cjs.isNull(val) || !chunkPZQ6I4JJ_cjs.isObjectOrArray(val) && !chunkPZQ6I4JJ_cjs.isFunction(val);
53
+ const deepProcess = (val) => {
54
+ if (chunkPZQ6I4JJ_cjs.isNumberObject(val)) {
55
+ const valOf = val.valueOf();
56
+ return chunkPZQ6I4JJ_cjs.isNaN(valOf) || chunkPZQ6I4JJ_cjs.isInfinityNumber(valOf) ? null : valOf;
57
+ }
58
+ if (chunkPZQ6I4JJ_cjs.isStringObject(val)) return val.valueOf();
59
+ if (chunkPZQ6I4JJ_cjs.isBooleanObject(val)) return val.valueOf();
60
+ if (chunkPZQ6I4JJ_cjs.isFunction(val) || chunkPZQ6I4JJ_cjs.isSymbol(val)) return void 0;
61
+ if (chunkUDA26MCU_cjs.isBigInt(val)) return val.toString();
62
+ if (chunkPZQ6I4JJ_cjs.isNaN(val) || chunkPZQ6I4JJ_cjs.isInfinityNumber(val)) return null;
63
+ if (chunkPZQ6I4JJ_cjs.isUndefined(val)) {
64
+ return keepUndefined ? void 0 : null;
65
+ }
66
+ if (chunkPZQ6I4JJ_cjs.isObjectOrArray(val)) {
67
+ if (seen.has(val)) return "[Circular]";
68
+ seen.add(val);
69
+ if (isDate(val)) return val.toISOString();
70
+ if (isMap(val)) {
71
+ return {
72
+ map: Array.from(val.entries()).map(([k, v]) => [k, deepProcess(v)])
73
+ };
74
+ }
75
+ if (chunkPZQ6I4JJ_cjs.isSet(val)) return { set: Array.from(val.values()).map(deepProcess) };
76
+ if (chunkPZQ6I4JJ_cjs.isArray(val)) {
77
+ const processedArr = val.map(deepProcess);
78
+ if (sortArray) {
79
+ const primitives = [];
80
+ const nonPrimitives = [];
81
+ for (const item of processedArr) {
82
+ if (isPrimitive(item)) primitives.push(item);
83
+ else nonPrimitives.push(item);
84
+ }
85
+ primitives.sort((a, b) => {
86
+ if (chunkPZQ6I4JJ_cjs.isNumber(a) && chunkPZQ6I4JJ_cjs.isNumber(b)) return a - b;
87
+ return String(a).localeCompare(String(b));
88
+ });
89
+ return [...primitives, ...nonPrimitives];
90
+ }
91
+ return processedArr;
92
+ }
93
+ const keys = Object.keys(val);
94
+ if (sortKeys) {
95
+ keys.sort((a, b) => {
96
+ const na = Number(a);
97
+ const nb = Number(b);
98
+ if (!chunkPZQ6I4JJ_cjs.isNaN(na) && !chunkPZQ6I4JJ_cjs.isNaN(nb)) return na - nb;
99
+ return a.localeCompare(b);
100
+ });
101
+ }
102
+ const result = {};
103
+ if (chunkPZQ6I4JJ_cjs.isObject(val)) {
104
+ for (const k of keys) {
105
+ const v = deepProcess(val[k]);
106
+ if (!chunkPZQ6I4JJ_cjs.isUndefined(v)) result[k] = v;
107
+ }
108
+ }
109
+ return result;
110
+ }
111
+ return val;
112
+ };
113
+ try {
114
+ return JSON.stringify(deepProcess(value), null, pretty ? 2 : 0);
115
+ } catch (err) {
116
+ console.warn("Error in safeStableStringify:", err);
117
+ return "{}";
118
+ }
119
+ };
120
+
121
+ exports.isDate = isDate;
122
+ exports.isMap = isMap;
123
+ exports.safeStableStringify = safeStableStringify;
@@ -1 +1,16 @@
1
- "use strict";exports.isBigInt=t=>"bigint"==typeof t;
1
+ /*!
2
+ * ====================================================
3
+ * Rzl Utils-JS.
4
+ * ----------------------------------------------------
5
+ * Version: 3.5.1.
6
+ * Author: Rizalvin Dwiky.
7
+ * Repository: https://github.com/rzl-zone/utils-js.
8
+ * ====================================================
9
+ */
10
+ 'use strict';
11
+
12
+ var isBigInt = (value) => {
13
+ return typeof value === "bigint";
14
+ };
15
+
16
+ exports.isBigInt = isBigInt;
@@ -1 +1,18 @@
1
- "use strict";var i=require("./chunk-PZQ6I4JJ.cjs");exports.isFinite=function(e){return i.isNumber(e)&&Number.isFinite(e)};
1
+ /*!
2
+ * ====================================================
3
+ * Rzl Utils-JS.
4
+ * ----------------------------------------------------
5
+ * Version: 3.5.1.
6
+ * Author: Rizalvin Dwiky.
7
+ * Repository: https://github.com/rzl-zone/utils-js.
8
+ * ====================================================
9
+ */
10
+ 'use strict';
11
+
12
+ var chunkPZQ6I4JJ_cjs = require('./chunk-PZQ6I4JJ.cjs');
13
+
14
+ function isFinite(value) {
15
+ return chunkPZQ6I4JJ_cjs.isNumber(value) && Number.isFinite(value);
16
+ }
17
+
18
+ exports.isFinite = isFinite;
@@ -1 +1,16 @@
1
- "use strict";exports.isServer=()=>"undefined"==typeof window||"undefined"==typeof document;
1
+ /*!
2
+ * ====================================================
3
+ * Rzl Utils-JS.
4
+ * ----------------------------------------------------
5
+ * Version: 3.5.1.
6
+ * Author: Rizalvin Dwiky.
7
+ * Repository: https://github.com/rzl-zone/utils-js.
8
+ * ====================================================
9
+ */
10
+ 'use strict';
11
+
12
+ var isServer = () => {
13
+ return typeof window === "undefined" || typeof document === "undefined";
14
+ };
15
+
16
+ exports.isServer = isServer;
@@ -1 +1,16 @@
1
- import{isNonEmptyString as r}from"./chunk-CMW2TBOQ.js";var o=(o,m={})=>!r(o,m);export{o as isEmptyString};
1
+ /*!
2
+ * ====================================================
3
+ * Rzl Utils-JS.
4
+ * ----------------------------------------------------
5
+ * Version: 3.5.1.
6
+ * Author: Rizalvin Dwiky.
7
+ * Repository: https://github.com/rzl-zone/utils-js.
8
+ * ====================================================
9
+ */
10
+ import { isNonEmptyString } from './chunk-CMW2TBOQ.js';
11
+
12
+ var isEmptyString = (value, options = {}) => {
13
+ return !isNonEmptyString(value, options);
14
+ };
15
+
16
+ export { isEmptyString };
@@ -1 +1,14 @@
1
- function e(e){return"number"==typeof e&&Number.isInteger(e)}export{e as isInteger};
1
+ /*!
2
+ * ====================================================
3
+ * Rzl Utils-JS.
4
+ * ----------------------------------------------------
5
+ * Version: 3.5.1.
6
+ * Author: Rizalvin Dwiky.
7
+ * Repository: https://github.com/rzl-zone/utils-js.
8
+ * ====================================================
9
+ */
10
+ function isInteger(value) {
11
+ return typeof value === "number" && Number.isInteger(value);
12
+ }
13
+
14
+ export { isInteger };