@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,101 @@
1
- "use strict";var e=require("./chunk-E55EQK2U.cjs"),r=require("./chunk-PZQ6I4JJ.cjs");exports.capitalizeFirst=(e,t={lowerCaseNextRest:!0,trim:!1})=>{if(!r.isNonEmptyString(e))return"";r.isPlainObject(t)||(t={});const i=!1!==t.lowerCaseNextRest;return!0===t.trim&&(e=e.trim()),e[0].toUpperCase()+(i?e.slice(1).toLowerCase():e.slice(1))},exports.capitalizeWords=(e,t={collapseSpaces:!1,trim:!1})=>{if(!r.isNonEmptyString(e))return"";let i=e;r.isPlainObject(t)||(t={});const s=!0===t.collapseSpaces;if(!0===t.trim&&(i=i.trim()),s){const e=i.match(/^\s*/)?.[0]??"",r=i.match(/\s*$/)?.[0]??"";i=i.trim().replace(/\s+/g," "),i=`${e}${i}${r}`}return i.toLowerCase().split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")},exports.getInitialsName=e=>{if(!r.isNonEmptyString(e))return"";const t=(e=e.replace(/\s+/g," ").trim()).split(" ");return t.length>1?t[0][0]+t[1][0].toUpperCase():e.length>1?e.substring(0,2).toUpperCase():e[0].toUpperCase()},exports.replaceAt=(e,t,i)=>{if(!r.isNumber(e)||!r.isString(i)||!r.isString(t))throw new TypeError(`First parameter (\`index\`) must be of type \`number\`, second parameter (\`originalString\`) and third parameter (\`replaceTo\`) must be of type \`string\`, but received: "['index': \`${r.getPreciseType(e)}\`, 'originalString': \`${r.getPreciseType(t)}\`, 'replaceTo': \`${r.getPreciseType(i)}\`]".`);if(e<0||e>=t.length)throw new RangeError("First parameter (`index`) is out of range from second parameter (`originalString`).");return t.slice(0,e)+i+t.slice(e+1)},exports.stripHtmlTags=function(t){if(!r.isString(t))return;return e.isEmptyString(t)?"":t.replace(/<\/?[a-zA-Z][^<>]*\/?>/g," ").trim().replace(/\s+/g," ").trim()};
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 chunkE55EQK2U_cjs = require('./chunk-E55EQK2U.cjs');
13
+ var chunkPZQ6I4JJ_cjs = require('./chunk-PZQ6I4JJ.cjs');
14
+
15
+ var capitalizeFirst = (string, options = {
16
+ lowerCaseNextRest: true,
17
+ trim: false
18
+ }) => {
19
+ if (!chunkPZQ6I4JJ_cjs.isNonEmptyString(string)) return "";
20
+ if (!chunkPZQ6I4JJ_cjs.isPlainObject(options)) {
21
+ options = {};
22
+ }
23
+ const lowerCaseNextRest = options.lowerCaseNextRest !== false;
24
+ const trim = options.trim === true;
25
+ if (trim) string = string.trim();
26
+ return string[0].toUpperCase() + (lowerCaseNextRest ? string.slice(1).toLowerCase() : string.slice(1));
27
+ };
28
+
29
+ var capitalizeWords = (value, options = {
30
+ collapseSpaces: false,
31
+ trim: false
32
+ }) => {
33
+ if (!chunkPZQ6I4JJ_cjs.isNonEmptyString(value)) return "";
34
+ let result = value;
35
+ if (!chunkPZQ6I4JJ_cjs.isPlainObject(options)) {
36
+ options = {};
37
+ }
38
+ const collapseSpaces = options.collapseSpaces === true;
39
+ const trim = options.trim === true;
40
+ if (trim) {
41
+ result = result.trim();
42
+ }
43
+ if (collapseSpaces) {
44
+ const leadingSpaces = result.match(/^\s*/)?.[0] ?? "";
45
+ const trailingSpaces = result.match(/\s*$/)?.[0] ?? "";
46
+ result = result.trim().replace(/\s+/g, " ");
47
+ result = `${leadingSpaces}${result}${trailingSpaces}`;
48
+ }
49
+ return result.toLowerCase().split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
50
+ };
51
+
52
+ function stripHtmlTags(input) {
53
+ if (!chunkPZQ6I4JJ_cjs.isString(input)) {
54
+ return void 0;
55
+ }
56
+ if (chunkE55EQK2U_cjs.isEmptyString(input)) {
57
+ return "";
58
+ }
59
+ const stripped = input.replace(/<\/?[a-zA-Z][^<>]*\/?>/g, " ").trim();
60
+ const cleaned = stripped.replace(/\s+/g, " ").trim();
61
+ return cleaned;
62
+ }
63
+
64
+ var getInitialsName = (name) => {
65
+ if (!chunkPZQ6I4JJ_cjs.isNonEmptyString(name)) return "";
66
+ name = name.replace(/\s+/g, " ").trim();
67
+ const nameParts = name.split(" ");
68
+ if (nameParts.length > 1) {
69
+ return nameParts[0][0] + nameParts[1][0].toUpperCase();
70
+ }
71
+ return name.length > 1 ? name.substring(0, 2).toUpperCase() : (
72
+ // First two letters for single-word names
73
+ name[0].toUpperCase()
74
+ );
75
+ };
76
+
77
+ var replaceAt = (index, originalString, replaceTo) => {
78
+ if (!chunkPZQ6I4JJ_cjs.isNumber(index) || !chunkPZQ6I4JJ_cjs.isString(replaceTo) || !chunkPZQ6I4JJ_cjs.isString(originalString)) {
79
+ throw new TypeError(
80
+ `First parameter (\`index\`) must be of type \`number\`, second parameter (\`originalString\`) and third parameter (\`replaceTo\`) must be of type \`string\`, but received: "['index': \`${chunkPZQ6I4JJ_cjs.getPreciseType(
81
+ index
82
+ )}\`, 'originalString': \`${chunkPZQ6I4JJ_cjs.getPreciseType(
83
+ originalString
84
+ )}\`, 'replaceTo': \`${chunkPZQ6I4JJ_cjs.getPreciseType(replaceTo)}\`]".`
85
+ );
86
+ }
87
+ if (index < 0 || index >= originalString.length) {
88
+ throw new RangeError(
89
+ `First parameter (\`index\`) is out of range from second parameter (\`originalString\`).`
90
+ );
91
+ }
92
+ return originalString.slice(0, index) + // Extract before the index
93
+ replaceTo + // Insert replacement
94
+ originalString.slice(index + 1);
95
+ };
96
+
97
+ exports.capitalizeFirst = capitalizeFirst;
98
+ exports.capitalizeWords = capitalizeWords;
99
+ exports.getInitialsName = getInitialsName;
100
+ exports.replaceAt = replaceAt;
101
+ exports.stripHtmlTags = stripHtmlTags;
@@ -1 +1,152 @@
1
- import{isInteger as e}from"./chunk-WVSPXFTY.js";import{safeStableStringify as r}from"./chunk-PET42Z7W.js";import{isNonEmptyArray as t,getPreciseType as n,isNumber as a,isPlainObject as m,assertIsBoolean as i,isNaN as h}from"./chunk-CMW2TBOQ.js";function o(e){if(!t(e))return;return e[Math.floor(Math.random()*(e.length||0))]}var u=(t,a)=>{if(!e(t)||!e(a))throw new TypeError(`First parameter (\`min\`) and second parameter (\`max\`) must be of type \`integer-number\`${c(t,a)}value, but received: ['min': \`${n(t)}\` - (with value: \`${r(t)})\`, 'max': \`${n(a)}\` - (with value: \`${r(a)}\`)].`);if(t>a)throw new RangeError(`First parameter (\`min\`) must be less than or equal to second parameter (\`max\`), but received: ['min': ${s(t)}, 'max': ${s(a)}].`);return t=Math.max(1,t),a=Math.min(Number.MAX_SAFE_INTEGER,a),Math.floor(Math.random()*(a-t+1))+t},s=e=>a(e,{includeNaN:!0})?e===Number.MIN_VALUE?"`Number.MIN_VALUE`":`${e}`:`\`${n(e)}\``,c=(...e)=>e.some(e=>a(e,{includeNaN:!0})&&e===Number.MIN_VALUE)?" and can't be `Number.MIN_VALUE` ":" ",g=t=>{m(t)||(t={});const{minLength:a=1,maxLength:h=16,avoidZero:o=!1}=t;if(i(o,{message:({currentType:e,validType:r})=>`Parameters \`avoidZero\` must be of type \`${r}\`, but received: \`${e}\`.`}),!e(a)||!e(h))throw new TypeError(`Parameters \`minLength\` and \`maxLength\` must be of type \`integer-number\`, but received: ['minLength': \`${n(a)}\` - (with value: ${r(a)}), 'maxLength': \`${n(h)}\` - (with value: ${r(h)})].`);if(a<1||h>16||a>h)throw new RangeError(`Invalid range at parameters \`minLength\` must be ≥ 1, \`maxLength\` must be ≤ 16, and \`minLength\` ≤ \`maxLength\`, but received: ['minLength': \`${a}\`, 'maxLength': \`${h}\`].`);const s=a===h?a:u(a,h),c=10**(s-1);let g=u(c,10**s-1);return o&&0===g&&(g=c),g},p=t=>{m(t)||(t={});const{minLength:a=40,maxLength:o=40,type:s="string",avoidWhiteSpace:c=!0}=t;if(i(c,{message:({currentType:e,validType:r})=>`Parameters \`avoidWhiteSpace\` property of the \`options\` (first-parameter) must be of type \`${r}\`, but received: \`${e}\`.`}),!e(a)||!e(o))throw new TypeError(`Parameters \`minLength\` and \`maxLength\` must be of type \`integer-number\`, but received: ['minLength': \`${n(a)}\` - (with value: ${r(a)}), 'maxLength': \`${n(o)}\` - (with value: ${r(o)})].`);if(a<1||o>5e3||a>o)throw new RangeError(`Invalid range at parameters \`minLength\` must be ≥ 1, \`maxLength\` must be ≤ 5000, and \`minLength\` ≤ \`maxLength\`, but received: ['minLength': \`${a}\`, 'maxLength': \`${o}\`].`);if("string"!==s&&"number"!==s)throw new TypeError(`Parameter \`type\` must be of type \`string\` with value one of "string" | "number", but received: \`${n(s)}\`, with value: ${r(s)}.`);const g=u(a,o),p="number"===s?(h(Number(t.replaceGenInt))?void 0:t.replaceGenInt)??"0123456789":(t.replaceGenStr?t.replaceGenStr:void 0)??"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",d=(l=p,(c?l.replace(/\s|\n|\t/g,""):l)+(t.addChar||""));var l;if(!d.length){throw new Error(`Character set is empty. ${(()=>"number"===s?c?"If `avoidWhiteSpace` is true, and `replaceGenInt` cant be empty-string value, ensure `replaceGenInt` has valid characters and non-nan string number.":"Ensure `replaceGenInt` has valid characters and not a NaN number string while convert to number.":"Ensure `replaceGenStr` has valid characters and non empty string.")()}`)}let b="";for(let e=0;e<g;e++)b+=d.charAt(Math.floor(Math.random()*d.length));return b};export{o as getRandomItem,u as randomInt,g as randomIntByLength,p as randomStr};
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 { isInteger } from './chunk-WVSPXFTY.js';
11
+ import { safeStableStringify } from './chunk-PET42Z7W.js';
12
+ import { isNonEmptyArray, getPreciseType, isNumber, isPlainObject, assertIsBoolean, isNaN } from './chunk-CMW2TBOQ.js';
13
+
14
+ function getRandomItem(array) {
15
+ if (!isNonEmptyArray(array)) return void 0;
16
+ const randomIndex = Math.floor(Math.random() * (array.length || 0));
17
+ return array[randomIndex];
18
+ }
19
+
20
+ var randomInt = (min, max) => {
21
+ if (!isInteger(min) || !isInteger(max)) {
22
+ throw new TypeError(
23
+ `First parameter (\`min\`) and second parameter (\`max\`) must be of type \`integer-number\`${minValueNote(
24
+ min,
25
+ max
26
+ )}value, but received: ['min': \`${getPreciseType(
27
+ min
28
+ )}\` - (with value: \`${safeStableStringify(min)})\`, 'max': \`${getPreciseType(
29
+ max
30
+ )}\` - (with value: \`${safeStableStringify(max)}\`)].`
31
+ );
32
+ }
33
+ if (min > max) {
34
+ throw new RangeError(
35
+ `First parameter (\`min\`) must be less than or equal to second parameter (\`max\`), but received: ['min': ${formatValue(
36
+ min
37
+ )}, 'max': ${formatValue(max)}].`
38
+ );
39
+ }
40
+ min = Math.max(1, min);
41
+ max = Math.min(Number.MAX_SAFE_INTEGER, max);
42
+ return Math.floor(Math.random() * (max - min + 1)) + min;
43
+ };
44
+ var formatValue = (value) => {
45
+ return isNumber(value, { includeNaN: true }) ? value === Number.MIN_VALUE ? "`Number.MIN_VALUE`" : `${value}` : `\`${getPreciseType(value)}\``;
46
+ };
47
+ var minValueNote = (...values) => {
48
+ return values.some((v) => isNumber(v, { includeNaN: true }) && v === Number.MIN_VALUE) ? " and can't be `Number.MIN_VALUE` " : " ";
49
+ };
50
+
51
+ var randomIntByLength = (options) => {
52
+ if (!isPlainObject(options)) {
53
+ options = {};
54
+ }
55
+ const { minLength = 1, maxLength = 16, avoidZero = false } = options;
56
+ assertIsBoolean(avoidZero, {
57
+ message({ currentType, validType }) {
58
+ return `Parameters \`avoidZero\` must be of type \`${validType}\`, but received: \`${currentType}\`.`;
59
+ }
60
+ });
61
+ if (!isInteger(minLength) || !isInteger(maxLength)) {
62
+ throw new TypeError(
63
+ `Parameters \`minLength\` and \`maxLength\` must be of type \`integer-number\`, but received: ['minLength': \`${getPreciseType(
64
+ minLength
65
+ )}\` - (with value: ${safeStableStringify(
66
+ minLength
67
+ )}), 'maxLength': \`${getPreciseType(
68
+ maxLength
69
+ )}\` - (with value: ${safeStableStringify(maxLength)})].`
70
+ );
71
+ }
72
+ if (minLength < 1 || maxLength > 16 || minLength > maxLength) {
73
+ throw new RangeError(
74
+ `Invalid range at parameters \`minLength\` must be \u2265 1, \`maxLength\` must be \u2264 16, and \`minLength\` \u2264 \`maxLength\`, but received: ['minLength': \`${minLength}\`, 'maxLength': \`${maxLength}\`].`
75
+ );
76
+ }
77
+ const randomLength = minLength === maxLength ? minLength : randomInt(minLength, maxLength);
78
+ const minValue = 10 ** (randomLength - 1);
79
+ const maxValue = 10 ** randomLength - 1;
80
+ let result = randomInt(minValue, maxValue);
81
+ if (avoidZero && result === 0) {
82
+ result = minValue;
83
+ }
84
+ return result;
85
+ };
86
+
87
+ var randomStr = (options) => {
88
+ if (!isPlainObject(options)) {
89
+ options = {};
90
+ }
91
+ const {
92
+ minLength = 40,
93
+ maxLength = 40,
94
+ type = "string",
95
+ avoidWhiteSpace = true
96
+ } = options;
97
+ assertIsBoolean(avoidWhiteSpace, {
98
+ message({ currentType, validType }) {
99
+ return `Parameters \`avoidWhiteSpace\` property of the \`options\` (first-parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`;
100
+ }
101
+ });
102
+ if (!isInteger(minLength) || !isInteger(maxLength)) {
103
+ throw new TypeError(
104
+ `Parameters \`minLength\` and \`maxLength\` must be of type \`integer-number\`, but received: ['minLength': \`${getPreciseType(
105
+ minLength
106
+ )}\` - (with value: ${safeStableStringify(
107
+ minLength
108
+ )}), 'maxLength': \`${getPreciseType(
109
+ maxLength
110
+ )}\` - (with value: ${safeStableStringify(maxLength)})].`
111
+ );
112
+ }
113
+ if (minLength < 1 || maxLength > 5e3 || minLength > maxLength) {
114
+ throw new RangeError(
115
+ `Invalid range at parameters \`minLength\` must be \u2265 1, \`maxLength\` must be \u2264 5000, and \`minLength\` \u2264 \`maxLength\`, but received: ['minLength': \`${minLength}\`, 'maxLength': \`${maxLength}\`].`
116
+ );
117
+ }
118
+ if (type !== "string" && type !== "number") {
119
+ throw new TypeError(
120
+ `Parameter \`type\` must be of type \`string\` with value one of "string" | "number", but received: \`${getPreciseType(
121
+ type
122
+ )}\`, with value: ${safeStableStringify(type)}.`
123
+ );
124
+ }
125
+ const length = randomInt(minLength, maxLength);
126
+ const cleanCharacters = (charSet) => {
127
+ return avoidWhiteSpace ? charSet.replace(/\s|\n|\t/g, "") : charSet;
128
+ };
129
+ const defaultNumberSet = "0123456789";
130
+ const defaultStringSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
131
+ const baseCharSet = type === "number" ? (!isNaN(Number(options.replaceGenInt)) ? options.replaceGenInt : void 0) ?? defaultNumberSet : (options.replaceGenStr ? options.replaceGenStr : void 0) ?? defaultStringSet;
132
+ const characterSet = cleanCharacters(baseCharSet) + (options.addChar || "");
133
+ if (!characterSet.length) {
134
+ const errCharSet = () => {
135
+ if (type === "number") {
136
+ if (avoidWhiteSpace) {
137
+ return `If \`avoidWhiteSpace\` is true, and \`replaceGenInt\` cant be empty-string value, ensure \`replaceGenInt\` has valid characters and non-nan string number.`;
138
+ }
139
+ return `Ensure \`replaceGenInt\` has valid characters and not a NaN number string while convert to number.`;
140
+ }
141
+ return `Ensure \`replaceGenStr\` has valid characters and non empty string.`;
142
+ };
143
+ throw new Error(`Character set is empty. ${errCharSet()}`);
144
+ }
145
+ let result = "";
146
+ for (let i = 0; i < length; i++) {
147
+ result += characterSet.charAt(Math.floor(Math.random() * characterSet.length));
148
+ }
149
+ return result;
150
+ };
151
+
152
+ export { getRandomItem, randomInt, randomIntByLength, randomStr };
@@ -1 +1,16 @@
1
- "use strict";exports.isInteger=function(e){return"number"==typeof e&&Number.isInteger(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
+ function isInteger(value) {
13
+ return typeof value === "number" && Number.isInteger(value);
14
+ }
15
+
16
+ exports.isInteger = isInteger;
@@ -1 +1,225 @@
1
- "use strict";var e=require("./chunk-KHO2SBNA.cjs"),r=require("./chunk-E74U6CYP.cjs"),t=require("./chunk-NRF6LWBC.cjs"),n=require("./chunk-HQWOFR56.cjs"),i=require("./chunk-DVMHRLKP.cjs"),a=require("./chunk-H66AC7GK.cjs"),s=require("./chunk-E55EQK2U.cjs"),o=require("./chunk-6JFZL7YE.cjs"),u=require("./chunk-T7PU2V7X.cjs"),c=require("./chunk-PZQ6I4JJ.cjs");exports.constructURL=(i,a,m)=>{if(c.isString(i)){if(s.isEmptyString(i))throw new TypeError("First parameter (`baseUrl`) cannot be an empty-string.");i=r.normalizeString(i)}else if(!e.isURL(i))throw new TypeError(`First parameter (\`baseUrl\`) must be of type an URL instance or a \`string\` and a non empty-string, but received: \`${c.getPreciseType(i)}\`, with current value: \`${u.safeStableStringify(i)}\`.`);if(!c.isUndefined(m)&&(o.assertIsArray(m,{message:({currentType:e,validType:r})=>`Third parameter (\`removeParams\`) must be of type \`${r} of strings\`, but received: \`${e}\`.`}),!m.every(e=>c.isNonEmptyString(e))))throw new TypeError("Third parameter (`removeParams`) must be of type `array` and contains `string` only and non empty-string.");try{if(!c.isUndefined(a)&&!c.isFunction(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.getPreciseType(a)}\`, with value: \`${u.safeStableStringify(a)}\`.`);const e=new URL(i);if(!c.isUndefined(a)){const r=Object.fromEntries(a);if(!n.isEmptyValue(r)){const n=new URLSearchParams(e.search);for(const[e,t]of Object.entries(r)){if(!c.isNonEmptyString(t)&&!c.isNumber(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.getPreciseType(a)}\`, with value: \`${u.safeStableStringify(a)}\`.`);n.set(e,String(t))}m?.length&&t.toStringArrayUnRecursive(m).map(e=>{n.delete(e)}),e.search=n.toString()}}return m?.forEach(r=>e.searchParams.delete(r)),e}catch(e){if(c.isError(e))throw e;throw new Error("Failed to construct a valid URL in `constructURL()`, Error:"+e)}},exports.extractURLs=e=>{if(!c.isNonEmptyString(e))return null;let r;try{r=decodeURIComponent(e)}catch{return null}const t=r.match(/https?:\/\/.*?(?=https?:\/\/|\s|$)/g);if(!t)return null;const n=t.map(e=>e.replace(/[.,;:!?)]*$/,"")).filter(e=>{try{const r=new URL(e);return"http:"===r.protocol||"https:"===r.protocol}catch{return!1}});return n.length?n:null},exports.getFirstPrefixPathname=(e,r="/")=>{if(!c.isNonEmptyString(r))throw new TypeError(`Second parameter (\`defaultValue\`) must be of type \`string\` and not an \`empty-string\`, but received: \`${c.getPreciseType(r)}\`, with value: \`${u.safeStableStringify(r)}\`.`);if(c.isArray(e)){if(!e.every(e=>c.isString(e)))throw new TypeError(`First parameter (\`result\`) must be of type \`string\` or \`array of string\`, but received: \`${c.getPreciseType(e)}\`, with value: \`${u.safeStableStringify(e)}\`.`);for(const r of e){const e=a.normalizePathname(r);if("/"!==e)return e}return a.normalizePathname(r)}if(c.isString(e)){const t=a.normalizePathname(e);return"/"!==t?t:a.normalizePathname(r)}if(!c.isNil(e))throw new TypeError(`First parameter (\`result\`) must be of type \`string\`, \`array-string\`, \`null\` or \`undefined\`, but received: \`${c.getPreciseType(e)}\`.`);return a.normalizePathname(r)},exports.getPrefixPathname=(e,r=null,t={})=>{const n=[];c.isString(e)||c.isArray(e)||n.push(`First parameter (\`url\`) must be of type \`string\` or \`array-string\`, but received: \`${c.getPreciseType(e)}\`.`),c.isString(r)||c.isArray(r)||c.isNull(r)||n.push(`Second parameter (\`base\`) must be of type \`string\`, \`array-string\` or \`null\`, but received: \`${c.getPreciseType(r)}\`.`),c.isPlainObject(t)||n.push(`Second parameter (\`options\`) must be of type \`plain-object\`, but received: \`${c.getPreciseType(t)}\`.`);const{levels:s=1,removeDuplicates:o=!0}=t;if((!i.isInteger(s)||i.isInteger(s)&&s<0)&&n.push(`Parameter \`levels\` property of the \`options\` (second parameter) must be of type \`integer-number\` and minimum is \`0\`, but received: \`${c.getPreciseType(s)}\`, with value: \`${u.safeStableStringify(s)}\`.`),c.isBoolean(o)||n.push(`Parameter \`removeDuplicates\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: \`${c.getPreciseType(o)}\`.`),c.isNonEmptyArray(n))throw new TypeError(`Invalid parameter(s) in \`getPrefixPathname\` function:\n- ${n.join("\n- ")}`);function m(e){return`/${a.normalizePathname(e).split("/").filter(Boolean).slice(0,s).join("/")}`}function p(e){if(r){if(e=a.normalizePathname(e),c.isArray(r)){for(const t of r)if(e.startsWith(a.normalizePathname(t)))return m(e)}else if(c.isNonEmptyString(r)&&e.startsWith(a.normalizePathname(r)))return m(e);return null}return m(e)}if(c.isArray(e)){const r=e.map(p).filter(e=>!c.isNull(e)),t=o?[...new Set(r)]:r;return 1===t.length?t[0]:t}return p(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 chunkKHO2SBNA_cjs = require('./chunk-KHO2SBNA.cjs');
13
+ var chunkE74U6CYP_cjs = require('./chunk-E74U6CYP.cjs');
14
+ var chunkNRF6LWBC_cjs = require('./chunk-NRF6LWBC.cjs');
15
+ var chunkHQWOFR56_cjs = require('./chunk-HQWOFR56.cjs');
16
+ var chunkDVMHRLKP_cjs = require('./chunk-DVMHRLKP.cjs');
17
+ var chunkH66AC7GK_cjs = require('./chunk-H66AC7GK.cjs');
18
+ var chunkE55EQK2U_cjs = require('./chunk-E55EQK2U.cjs');
19
+ var chunk6JFZL7YE_cjs = require('./chunk-6JFZL7YE.cjs');
20
+ var chunkT7PU2V7X_cjs = require('./chunk-T7PU2V7X.cjs');
21
+ var chunkPZQ6I4JJ_cjs = require('./chunk-PZQ6I4JJ.cjs');
22
+
23
+ var constructURL = (baseUrl, queryParams, removeParams) => {
24
+ if (chunkPZQ6I4JJ_cjs.isString(baseUrl)) {
25
+ if (chunkE55EQK2U_cjs.isEmptyString(baseUrl)) {
26
+ throw new TypeError(`First parameter (\`baseUrl\`) cannot be an empty-string.`);
27
+ }
28
+ baseUrl = chunkE74U6CYP_cjs.normalizeString(baseUrl);
29
+ } else if (!chunkKHO2SBNA_cjs.isURL(baseUrl)) {
30
+ throw new TypeError(
31
+ `First parameter (\`baseUrl\`) must be of type an URL instance or a \`string\` and a non empty-string, but received: \`${chunkPZQ6I4JJ_cjs.getPreciseType(
32
+ baseUrl
33
+ )}\`, with current value: \`${chunkT7PU2V7X_cjs.safeStableStringify(baseUrl)}\`.`
34
+ );
35
+ }
36
+ if (!chunkPZQ6I4JJ_cjs.isUndefined(removeParams)) {
37
+ chunk6JFZL7YE_cjs.assertIsArray(removeParams, {
38
+ message: ({ currentType, validType }) => `Third parameter (\`removeParams\`) must be of type \`${validType} of strings\`, but received: \`${currentType}\`.`
39
+ });
40
+ if (!removeParams.every((param) => chunkPZQ6I4JJ_cjs.isNonEmptyString(param))) {
41
+ throw new TypeError(
42
+ `Third parameter (\`removeParams\`) must be of type \`array\` and contains \`string\` only and non empty-string.`
43
+ );
44
+ }
45
+ }
46
+ try {
47
+ if (!chunkPZQ6I4JJ_cjs.isUndefined(queryParams) && !chunkPZQ6I4JJ_cjs.isFunction(queryParams[Symbol.iterator])) {
48
+ throw new TypeError(
49
+ `Second parameter (\`queryParams\`) must be iterable (like URLSearchParams.entries() or an array of [[string, string | number]...]), but received: \`${chunkPZQ6I4JJ_cjs.getPreciseType(
50
+ queryParams
51
+ )}\`, with value: \`${chunkT7PU2V7X_cjs.safeStableStringify(queryParams)}\`.`
52
+ );
53
+ }
54
+ const urlInstance = new URL(baseUrl);
55
+ if (!chunkPZQ6I4JJ_cjs.isUndefined(queryParams)) {
56
+ const paramObject = Object.fromEntries(queryParams);
57
+ if (!chunkHQWOFR56_cjs.isEmptyValue(paramObject)) {
58
+ const mergedParams = new URLSearchParams(urlInstance.search);
59
+ for (const [key, value] of Object.entries(paramObject)) {
60
+ if (!chunkPZQ6I4JJ_cjs.isNonEmptyString(value) && !chunkPZQ6I4JJ_cjs.isNumber(value, { includeNaN: true })) {
61
+ throw new TypeError(
62
+ `Second parameter (\`queryParams\`) must be iterable (like URLSearchParams.entries() or an array of [[string, string | number]...]), but received: \`${chunkPZQ6I4JJ_cjs.getPreciseType(
63
+ queryParams
64
+ )}\`, with value: \`${chunkT7PU2V7X_cjs.safeStableStringify(queryParams)}\`.`
65
+ );
66
+ }
67
+ mergedParams.set(key, String(value));
68
+ }
69
+ if (removeParams?.length) {
70
+ chunkNRF6LWBC_cjs.toStringArrayUnRecursive(removeParams).map((paramKey) => {
71
+ mergedParams.delete(paramKey);
72
+ });
73
+ }
74
+ urlInstance.search = mergedParams.toString();
75
+ }
76
+ }
77
+ removeParams?.forEach((param) => urlInstance.searchParams.delete(param));
78
+ return urlInstance;
79
+ } catch (error) {
80
+ if (chunkPZQ6I4JJ_cjs.isError(error)) throw error;
81
+ throw new Error(
82
+ "Failed to construct a valid URL in `constructURL()`, Error:" + error
83
+ );
84
+ }
85
+ };
86
+
87
+ var extractURLs = (url) => {
88
+ if (!chunkPZQ6I4JJ_cjs.isNonEmptyString(url)) return null;
89
+ let decoded;
90
+ try {
91
+ decoded = decodeURIComponent(url);
92
+ } catch {
93
+ return null;
94
+ }
95
+ const urlPattern = /https?:\/\/.*?(?=https?:\/\/|\s|$)/g;
96
+ const matches = decoded.match(urlPattern);
97
+ if (!matches) return null;
98
+ const cleaned = matches.map((url2) => url2.replace(/[.,;:!?)]*$/, "")).filter((url2) => {
99
+ try {
100
+ const u = new URL(url2);
101
+ return u.protocol === "http:" || u.protocol === "https:";
102
+ } catch {
103
+ return false;
104
+ }
105
+ });
106
+ return cleaned.length ? cleaned : null;
107
+ };
108
+
109
+ var getFirstPrefixPathname = (result, defaultValue = "/") => {
110
+ if (!chunkPZQ6I4JJ_cjs.isNonEmptyString(defaultValue)) {
111
+ throw new TypeError(
112
+ `Second parameter (\`defaultValue\`) must be of type \`string\` and not an \`empty-string\`, but received: \`${chunkPZQ6I4JJ_cjs.getPreciseType(
113
+ defaultValue
114
+ )}\`, with value: \`${chunkT7PU2V7X_cjs.safeStableStringify(defaultValue)}\`.`
115
+ );
116
+ }
117
+ if (chunkPZQ6I4JJ_cjs.isArray(result)) {
118
+ if (!result.every((item) => chunkPZQ6I4JJ_cjs.isString(item))) {
119
+ throw new TypeError(
120
+ `First parameter (\`result\`) must be of type \`string\` or \`array of string\`, but received: \`${chunkPZQ6I4JJ_cjs.getPreciseType(
121
+ result
122
+ )}\`, with value: \`${chunkT7PU2V7X_cjs.safeStableStringify(result)}\`.`
123
+ );
124
+ }
125
+ for (const item of result) {
126
+ const normalized = chunkH66AC7GK_cjs.normalizePathname(item);
127
+ if (normalized !== "/") {
128
+ return normalized;
129
+ }
130
+ }
131
+ return chunkH66AC7GK_cjs.normalizePathname(defaultValue);
132
+ }
133
+ if (chunkPZQ6I4JJ_cjs.isString(result)) {
134
+ const normalized = chunkH66AC7GK_cjs.normalizePathname(result);
135
+ return normalized !== "/" ? normalized : chunkH66AC7GK_cjs.normalizePathname(defaultValue);
136
+ }
137
+ if (!chunkPZQ6I4JJ_cjs.isNil(result)) {
138
+ throw new TypeError(
139
+ `First parameter (\`result\`) must be of type \`string\`, \`array-string\`, \`null\` or \`undefined\`, but received: \`${chunkPZQ6I4JJ_cjs.getPreciseType(
140
+ result
141
+ )}\`.`
142
+ );
143
+ }
144
+ return chunkH66AC7GK_cjs.normalizePathname(defaultValue);
145
+ };
146
+
147
+ var getPrefixPathname = (url, base = null, options = {}) => {
148
+ const errors = [];
149
+ if (!chunkPZQ6I4JJ_cjs.isString(url) && !chunkPZQ6I4JJ_cjs.isArray(url)) {
150
+ errors.push(
151
+ `First parameter (\`url\`) must be of type \`string\` or \`array-string\`, but received: \`${chunkPZQ6I4JJ_cjs.getPreciseType(
152
+ url
153
+ )}\`.`
154
+ );
155
+ }
156
+ if (!chunkPZQ6I4JJ_cjs.isString(base) && !chunkPZQ6I4JJ_cjs.isArray(base) && !chunkPZQ6I4JJ_cjs.isNull(base)) {
157
+ errors.push(
158
+ `Second parameter (\`base\`) must be of type \`string\`, \`array-string\` or \`null\`, but received: \`${chunkPZQ6I4JJ_cjs.getPreciseType(
159
+ base
160
+ )}\`.`
161
+ );
162
+ }
163
+ if (!chunkPZQ6I4JJ_cjs.isPlainObject(options)) {
164
+ errors.push(
165
+ `Second parameter (\`options\`) must be of type \`plain-object\`, but received: \`${chunkPZQ6I4JJ_cjs.getPreciseType(
166
+ options
167
+ )}\`.`
168
+ );
169
+ }
170
+ const { levels = 1, removeDuplicates = true } = options;
171
+ if (!chunkDVMHRLKP_cjs.isInteger(levels) || chunkDVMHRLKP_cjs.isInteger(levels) && levels < 0) {
172
+ errors.push(
173
+ `Parameter \`levels\` property of the \`options\` (second parameter) must be of type \`integer-number\` and minimum is \`0\`, but received: \`${chunkPZQ6I4JJ_cjs.getPreciseType(
174
+ levels
175
+ )}\`, with value: \`${chunkT7PU2V7X_cjs.safeStableStringify(levels)}\`.`
176
+ );
177
+ }
178
+ if (!chunkPZQ6I4JJ_cjs.isBoolean(removeDuplicates)) {
179
+ errors.push(
180
+ `Parameter \`removeDuplicates\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: \`${chunkPZQ6I4JJ_cjs.getPreciseType(
181
+ removeDuplicates
182
+ )}\`.`
183
+ );
184
+ }
185
+ if (chunkPZQ6I4JJ_cjs.isNonEmptyArray(errors)) {
186
+ throw new TypeError(
187
+ `Invalid parameter(s) in \`getPrefixPathname\` function:
188
+ - ${errors.join("\n- ")}`
189
+ );
190
+ }
191
+ function getLevel(singleUrl) {
192
+ const parts = chunkH66AC7GK_cjs.normalizePathname(singleUrl).split("/").filter(Boolean);
193
+ return `/${parts.slice(0, levels).join("/")}`;
194
+ }
195
+ function processUrl(singleUrl) {
196
+ if (base) {
197
+ singleUrl = chunkH66AC7GK_cjs.normalizePathname(singleUrl);
198
+ if (chunkPZQ6I4JJ_cjs.isArray(base)) {
199
+ for (const b of base) {
200
+ if (singleUrl.startsWith(chunkH66AC7GK_cjs.normalizePathname(b))) {
201
+ return getLevel(singleUrl);
202
+ }
203
+ }
204
+ } else if (chunkPZQ6I4JJ_cjs.isNonEmptyString(base) && singleUrl.startsWith(chunkH66AC7GK_cjs.normalizePathname(base))) {
205
+ return getLevel(singleUrl);
206
+ }
207
+ return null;
208
+ }
209
+ return getLevel(singleUrl);
210
+ }
211
+ if (chunkPZQ6I4JJ_cjs.isArray(url)) {
212
+ const result = url.map(processUrl).filter((r) => !chunkPZQ6I4JJ_cjs.isNull(r));
213
+ const uniqueResult = removeDuplicates ? [...new Set(result)] : result;
214
+ if (uniqueResult.length === 1) {
215
+ return uniqueResult[0];
216
+ }
217
+ return uniqueResult;
218
+ }
219
+ return processUrl(url);
220
+ };
221
+
222
+ exports.constructURL = constructURL;
223
+ exports.extractURLs = extractURLs;
224
+ exports.getFirstPrefixPathname = getFirstPrefixPathname;
225
+ exports.getPrefixPathname = getPrefixPathname;
@@ -1 +1,18 @@
1
- "use strict";var r=require("./chunk-PZQ6I4JJ.cjs");exports.isEmptyString=(t,i={})=>!r.isNonEmptyString(t,i);
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
+ var isEmptyString = (value, options = {}) => {
15
+ return !chunkPZQ6I4JJ_cjs.isNonEmptyString(value, options);
16
+ };
17
+
18
+ exports.isEmptyString = isEmptyString;
@@ -1 +1,18 @@
1
- "use strict";var r=require("./chunk-PZQ6I4JJ.cjs");exports.normalizeString=i=>r.isNonEmptyString(i)?i.trim():"";
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
+ var normalizeString = (input) => {
15
+ return chunkPZQ6I4JJ_cjs.isNonEmptyString(input) ? input.trim() : "";
16
+ };
17
+
18
+ exports.normalizeString = normalizeString;
@@ -1 +1,64 @@
1
- "use strict";var e=require("./chunk-VJDDGRIK.cjs"),t=require("./chunk-HYRQMTRH.cjs"),s=require("./chunk-PZQ6I4JJ.cjs");exports.disableUserInteraction=(s="on_processing")=>{if(e.isServer())return;t.assertIsString(s,{message:({validType:e,currentType:t})=>`First parameter \`className\` must be of type \`${e}\`, but received: \`${t}\`.`});const{documentElement:r}=document;r&&!r.classList.contains(s)&&r.classList.add(s)},exports.enableUserInteraction=(s="on_processing")=>{if(e.isServer())return;t.assertIsString(s,{message:({validType:e,currentType:t})=>`First parameter \`className\` must be of type \`${e}\`, but received: \`${t}\`.`});const{documentElement:r}=document;r&&r.classList.contains(s)&&r.classList.remove(s)},exports.removeElementFocus=()=>{if(e.isServer())return;const t=document.activeElement;t instanceof HTMLElement&&t.blur()},exports.scrollToTop=t=>{if(e.isServer())return;s.isPlainObject(t)||(t={});const r=s.hasOwnProp(t,"behavior")&&s.isNonEmptyString(t.behavior)&&["auto","instant","smooth"].includes(t.behavior)?t.behavior:"smooth";let o=s.hasOwnProp(t,"timeout")&&s.isNumber(t.timeout)&&t.timeout>=1?t.timeout:1;o=o>2147483647?2147483647:o,setTimeout(()=>window.scrollTo({top:0,left:0,behavior:r}),o)};
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 chunkVJDDGRIK_cjs = require('./chunk-VJDDGRIK.cjs');
13
+ var chunkHYRQMTRH_cjs = require('./chunk-HYRQMTRH.cjs');
14
+ var chunkPZQ6I4JJ_cjs = require('./chunk-PZQ6I4JJ.cjs');
15
+
16
+ var disableUserInteraction = (className = "on_processing") => {
17
+ if (chunkVJDDGRIK_cjs.isServer()) return;
18
+ chunkHYRQMTRH_cjs.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.add(className);
26
+ }
27
+ };
28
+
29
+ var enableUserInteraction = (className = "on_processing") => {
30
+ if (chunkVJDDGRIK_cjs.isServer()) return;
31
+ chunkHYRQMTRH_cjs.assertIsString(className, {
32
+ message({ validType, currentType }) {
33
+ return `First parameter \`className\` must be of type \`${validType}\`, but received: \`${currentType}\`.`;
34
+ }
35
+ });
36
+ const { documentElement } = document;
37
+ if (documentElement && documentElement.classList.contains(className)) {
38
+ documentElement.classList.remove(className);
39
+ }
40
+ };
41
+
42
+ var removeElementFocus = () => {
43
+ if (chunkVJDDGRIK_cjs.isServer()) return;
44
+ const activeElement = document.activeElement;
45
+ if (activeElement instanceof HTMLElement) {
46
+ activeElement.blur();
47
+ }
48
+ };
49
+
50
+ var scrollToTop = (options) => {
51
+ if (chunkVJDDGRIK_cjs.isServer()) return;
52
+ if (!chunkPZQ6I4JJ_cjs.isPlainObject(options)) {
53
+ options = {};
54
+ }
55
+ const behavior = chunkPZQ6I4JJ_cjs.hasOwnProp(options, "behavior") && chunkPZQ6I4JJ_cjs.isNonEmptyString(options.behavior) && ["auto", "instant", "smooth"].includes(options.behavior) ? options.behavior : "smooth";
56
+ let timeout = chunkPZQ6I4JJ_cjs.hasOwnProp(options, "timeout") && chunkPZQ6I4JJ_cjs.isNumber(options.timeout) && options.timeout >= 1 ? options.timeout : 1;
57
+ timeout = timeout > 2147483647 ? 2147483647 : timeout;
58
+ setTimeout(() => window.scrollTo({ top: 0, left: 0, behavior }), timeout);
59
+ };
60
+
61
+ exports.disableUserInteraction = disableUserInteraction;
62
+ exports.enableUserInteraction = enableUserInteraction;
63
+ exports.removeElementFocus = removeElementFocus;
64
+ exports.scrollToTop = scrollToTop;