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