@splendidlabz/utils 1.10.2 → 1.10.3

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 (201) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/dom/accessibility.cjs +0 -2
  3. package/dist/cjs/dom/actions/index.cjs +7 -391
  4. package/dist/cjs/dom/actions/masonry.cjs +6 -97
  5. package/dist/cjs/dom/actions/prefer-horizontal-scroll.cjs +14 -58
  6. package/dist/cjs/dom/actions/sticky.cjs +6 -126
  7. package/dist/cjs/dom/bounding-box.cjs +0 -2
  8. package/dist/cjs/dom/clipboard.cjs +0 -2
  9. package/dist/cjs/dom/cookie.cjs +1 -3
  10. package/dist/cjs/dom/css-vars.cjs +3 -13
  11. package/dist/cjs/dom/events.cjs +0 -2
  12. package/dist/cjs/dom/focusable.cjs +0 -2
  13. package/dist/cjs/dom/font-size.cjs +3 -15
  14. package/dist/cjs/dom/get-element.cjs +1 -3
  15. package/dist/cjs/dom/hash.cjs +0 -2
  16. package/dist/cjs/dom/index.cjs +47 -1248
  17. package/dist/cjs/dom/keyboard.cjs +0 -2
  18. package/dist/cjs/dom/local-store.cjs +1 -3
  19. package/dist/cjs/dom/media.cjs +0 -2
  20. package/dist/cjs/dom/observers/index.cjs +9 -235
  21. package/dist/cjs/dom/observers/intersection-observer.cjs +6 -38
  22. package/dist/cjs/dom/observers/mutation-observer.cjs +6 -38
  23. package/dist/cjs/dom/observers/observer.cjs +2 -12
  24. package/dist/cjs/dom/observers/resize-observer.cjs +6 -38
  25. package/dist/cjs/dom/observers/scroll-observer.cjs +3 -62
  26. package/dist/cjs/dom/pkce.cjs +3 -13
  27. package/dist/cjs/dom/query-params.cjs +1 -3
  28. package/dist/cjs/dom/random-string.cjs +0 -2
  29. package/dist/cjs/dom/sanitize.cjs +3 -27
  30. package/dist/cjs/dom/session-store.cjs +1 -3
  31. package/dist/cjs/dom/spam-prevention.cjs +0 -2
  32. package/dist/cjs/dom/trap-focus.cjs +9 -131
  33. package/dist/cjs/dom/ui/aria-current.cjs +0 -2
  34. package/dist/cjs/dom/ui/inconsistent-button-fix.cjs +0 -2
  35. package/dist/cjs/dom/ui/index.cjs +9 -87
  36. package/dist/cjs/dom/ui/scroll-container.cjs +0 -2
  37. package/dist/cjs/dom/ui/traverse-and-scramble.cjs +0 -2
  38. package/dist/cjs/lib/arrays/index.cjs +13 -121
  39. package/dist/cjs/lib/arrays/item-position.cjs +0 -2
  40. package/dist/cjs/lib/arrays/join.cjs +2 -10
  41. package/dist/cjs/lib/arrays/shuffle.cjs +0 -2
  42. package/dist/cjs/lib/arrays/sort.cjs +3 -11
  43. package/dist/cjs/lib/arrays/split-array.cjs +0 -2
  44. package/dist/cjs/lib/arrays/unique.cjs +0 -2
  45. package/dist/cjs/lib/auth/index.cjs +3 -35
  46. package/dist/cjs/lib/auth/route-manager.cjs +0 -2
  47. package/dist/cjs/lib/checks.cjs +0 -2
  48. package/dist/cjs/lib/date/days.cjs +1 -3
  49. package/dist/cjs/lib/date/index.cjs +7 -190
  50. package/dist/cjs/lib/date/months.cjs +1 -3
  51. package/dist/cjs/lib/date/time.cjs +2 -14
  52. package/dist/cjs/lib/form/form-data.cjs +0 -2
  53. package/dist/cjs/lib/form/index.cjs +5 -104
  54. package/dist/cjs/lib/form/sanitize.cjs +0 -2
  55. package/dist/cjs/lib/functions/callback.cjs +0 -2
  56. package/dist/cjs/lib/functions/debounce.cjs +0 -2
  57. package/dist/cjs/lib/functions/env.cjs +0 -2
  58. package/dist/cjs/lib/functions/functional.cjs +0 -2
  59. package/dist/cjs/lib/functions/index.cjs +11 -124
  60. package/dist/cjs/lib/functions/throttle.cjs +0 -2
  61. package/dist/cjs/lib/functions/timeout.cjs +0 -2
  62. package/dist/cjs/lib/hash.cjs +0 -2
  63. package/dist/cjs/lib/index.cjs +29 -1155
  64. package/dist/cjs/lib/numbers/index.cjs +4 -17
  65. package/dist/cjs/lib/numbers/math.cjs +0 -2
  66. package/dist/cjs/lib/objects/camelcase-keys.cjs +4 -45
  67. package/dist/cjs/lib/objects/empty.cjs +0 -2
  68. package/dist/cjs/lib/objects/equal.cjs +0 -2
  69. package/dist/cjs/lib/objects/extend.cjs +6 -117
  70. package/dist/cjs/lib/objects/flatten.cjs +3 -11
  71. package/dist/cjs/lib/objects/index.cjs +27 -360
  72. package/dist/cjs/lib/objects/json.cjs +0 -2
  73. package/dist/cjs/lib/objects/loop.cjs +0 -2
  74. package/dist/cjs/lib/objects/mix/mix.cjs +3 -5
  75. package/dist/cjs/lib/objects/nested-property.cjs +0 -2
  76. package/dist/cjs/lib/objects/normalize-object.cjs +4 -78
  77. package/dist/cjs/lib/objects/omit-empty.cjs +0 -2
  78. package/dist/cjs/lib/objects/size.cjs +0 -2
  79. package/dist/cjs/lib/objects/split.cjs +0 -2
  80. package/dist/cjs/lib/promises/index.cjs +3 -51
  81. package/dist/cjs/lib/promises/reject.cjs +2 -19
  82. package/dist/cjs/lib/sse.cjs +4 -29
  83. package/dist/cjs/lib/strings/convert-case/convert-case.cjs +0 -2
  84. package/dist/cjs/lib/strings/index.cjs +11 -179
  85. package/dist/cjs/lib/strings/markdown.cjs +1 -3
  86. package/dist/cjs/lib/strings/name.cjs +0 -2
  87. package/dist/cjs/lib/strings/pluralize.cjs +1 -3
  88. package/dist/cjs/lib/strings/query-string.cjs +0 -2
  89. package/dist/cjs/lib/style/index.cjs +2 -31
  90. package/dist/cjs/lib/symbols/index.cjs +3 -22
  91. package/dist/cjs/lib/symbols/symbols.cjs +0 -2
  92. package/dist/cjs/node/common.cjs +0 -2
  93. package/dist/cjs/node/dirname.cjs +2 -4
  94. package/dist/cjs/node/file-cache.cjs +3 -45
  95. package/dist/cjs/node/file.cjs +2 -4
  96. package/dist/cjs/node/hash.cjs +1 -3
  97. package/dist/cjs/node/index.cjs +15 -272
  98. package/dist/cjs/node/pkce.cjs +5 -15
  99. package/dist/cjs/node/random-string.cjs +1 -3
  100. package/dist/cjs/node/sanitize.cjs +3 -27
  101. package/dist/esm/dom/accessibility.js +0 -1
  102. package/dist/esm/dom/actions/index.js +3 -381
  103. package/dist/esm/dom/actions/masonry.js +3 -91
  104. package/dist/esm/dom/actions/prefer-horizontal-scroll.js +4 -45
  105. package/dist/esm/dom/actions/sticky.js +3 -120
  106. package/dist/esm/dom/bounding-box.js +0 -1
  107. package/dist/esm/dom/clipboard.js +0 -1
  108. package/dist/esm/dom/cookie.js +1 -2
  109. package/dist/esm/dom/css-vars.js +1 -8
  110. package/dist/esm/dom/events.js +0 -1
  111. package/dist/esm/dom/focusable.js +0 -1
  112. package/dist/esm/dom/font-size.js +1 -10
  113. package/dist/esm/dom/get-element.js +1 -2
  114. package/dist/esm/dom/hash.js +0 -1
  115. package/dist/esm/dom/index.js +23 -1168
  116. package/dist/esm/dom/keyboard.js +0 -1
  117. package/dist/esm/dom/local-store.js +1 -2
  118. package/dist/esm/dom/media.js +0 -1
  119. package/dist/esm/dom/observers/index.js +4 -224
  120. package/dist/esm/dom/observers/intersection-observer.js +2 -31
  121. package/dist/esm/dom/observers/mutation-observer.js +3 -32
  122. package/dist/esm/dom/observers/observer.js +1 -8
  123. package/dist/esm/dom/observers/resize-observer.js +2 -31
  124. package/dist/esm/dom/observers/scroll-observer.js +2 -58
  125. package/dist/esm/dom/pkce.js +1 -8
  126. package/dist/esm/dom/query-params.js +1 -2
  127. package/dist/esm/dom/random-string.js +0 -1
  128. package/dist/esm/dom/sanitize.js +3 -26
  129. package/dist/esm/dom/session-store.js +1 -2
  130. package/dist/esm/dom/spam-prevention.js +0 -1
  131. package/dist/esm/dom/trap-focus.js +2 -121
  132. package/dist/esm/dom/ui/aria-current.js +0 -1
  133. package/dist/esm/dom/ui/inconsistent-button-fix.js +0 -1
  134. package/dist/esm/dom/ui/index.js +4 -75
  135. package/dist/esm/dom/ui/scroll-container.js +0 -1
  136. package/dist/esm/dom/ui/traverse-and-scramble.js +0 -1
  137. package/dist/esm/lib/arrays/index.js +6 -106
  138. package/dist/esm/lib/arrays/item-position.js +0 -1
  139. package/dist/esm/lib/arrays/join.js +1 -6
  140. package/dist/esm/lib/arrays/shuffle.js +0 -1
  141. package/dist/esm/lib/arrays/sort.js +1 -6
  142. package/dist/esm/lib/arrays/split-array.js +0 -1
  143. package/dist/esm/lib/arrays/unique.js +0 -1
  144. package/dist/esm/lib/auth/index.js +1 -26
  145. package/dist/esm/lib/auth/route-manager.js +0 -1
  146. package/dist/esm/lib/checks.js +0 -1
  147. package/dist/esm/lib/date/days.js +1 -2
  148. package/dist/esm/lib/date/index.js +3 -173
  149. package/dist/esm/lib/date/months.js +1 -2
  150. package/dist/esm/lib/date/time.js +1 -10
  151. package/dist/esm/lib/form/form-data.js +0 -1
  152. package/dist/esm/lib/form/index.js +2 -92
  153. package/dist/esm/lib/form/sanitize.js +0 -1
  154. package/dist/esm/lib/functions/callback.js +0 -1
  155. package/dist/esm/lib/functions/debounce.js +0 -1
  156. package/dist/esm/lib/functions/env.js +0 -1
  157. package/dist/esm/lib/functions/functional.js +0 -1
  158. package/dist/esm/lib/functions/index.js +5 -105
  159. package/dist/esm/lib/functions/throttle.js +0 -1
  160. package/dist/esm/lib/functions/timeout.js +0 -1
  161. package/dist/esm/lib/hash.js +0 -1
  162. package/dist/esm/lib/index.js +14 -1052
  163. package/dist/esm/lib/numbers/index.js +2 -12
  164. package/dist/esm/lib/numbers/math.js +0 -1
  165. package/dist/esm/lib/objects/camelcase-keys.js +2 -40
  166. package/dist/esm/lib/objects/empty.js +0 -1
  167. package/dist/esm/lib/objects/equal.js +0 -1
  168. package/dist/esm/lib/objects/extend.js +3 -111
  169. package/dist/esm/lib/objects/flatten.js +1 -6
  170. package/dist/esm/lib/objects/index.js +13 -323
  171. package/dist/esm/lib/objects/json.js +0 -1
  172. package/dist/esm/lib/objects/loop.js +0 -1
  173. package/dist/esm/lib/objects/mix/mix.js +3 -4
  174. package/dist/esm/lib/objects/nested-property.js +0 -1
  175. package/dist/esm/lib/objects/normalize-object.js +3 -74
  176. package/dist/esm/lib/objects/omit-empty.js +0 -1
  177. package/dist/esm/lib/objects/size.js +0 -1
  178. package/dist/esm/lib/objects/split.js +0 -1
  179. package/dist/esm/lib/promises/index.js +1 -33
  180. package/dist/esm/lib/promises/reject.js +1 -17
  181. package/dist/esm/lib/sse.js +2 -24
  182. package/dist/esm/lib/strings/convert-case/convert-case.js +0 -1
  183. package/dist/esm/lib/strings/index.js +5 -147
  184. package/dist/esm/lib/strings/markdown.js +1 -2
  185. package/dist/esm/lib/strings/name.js +0 -1
  186. package/dist/esm/lib/strings/pluralize.js +1 -2
  187. package/dist/esm/lib/strings/query-string.js +0 -1
  188. package/dist/esm/lib/style/index.js +1 -27
  189. package/dist/esm/lib/symbols/index.js +1 -13
  190. package/dist/esm/lib/symbols/symbols.js +0 -1
  191. package/dist/esm/node/common.js +0 -1
  192. package/dist/esm/node/dirname.js +2 -3
  193. package/dist/esm/node/file-cache.js +2 -43
  194. package/dist/esm/node/file.js +2 -3
  195. package/dist/esm/node/hash.js +1 -2
  196. package/dist/esm/node/index.js +7 -243
  197. package/dist/esm/node/pkce.js +3 -12
  198. package/dist/esm/node/random-string.js +1 -2
  199. package/dist/esm/node/sanitize.js +3 -26
  200. package/package.json +1 -1
  201. package/tsup.config.mjs +2 -0
@@ -25,39 +25,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  mod
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/dom/sanitize.js
30
28
  var sanitize_exports = {};
31
29
  __export(sanitize_exports, {
32
- sanitize: () => sanitize2
30
+ sanitize: () => sanitize
33
31
  });
34
32
  module.exports = __toCommonJS(sanitize_exports);
35
33
  var import_dompurify = __toESM(require("dompurify"), 1);
36
-
37
- // src/lib/form/sanitize.js
34
+ var import_sanitize = require("../lib/form/sanitize.js");
38
35
  function sanitize(value, options = {}) {
39
- const { sanitizer, ...rest } = options;
40
- if (!sanitizer) throw new Error("sanitizer function is required");
41
- if (typeof value === "string") return sanitizer(value, rest);
42
- if (Array.isArray(value)) return sanitizeArray(value, { sanitizer, ...rest });
43
- if (value && typeof value === "object") {
44
- return Object.fromEntries(
45
- Object.entries(value).map(([key, val]) => [
46
- key,
47
- sanitize(val, { sanitizer, ...rest })
48
- ])
49
- );
50
- }
51
- return value;
52
- }
53
- function sanitizeArray(arr, { sanitizer, ...rest }) {
54
- if (!sanitizer) throw new Error("sanitizer function is required");
55
- return arr.map((item) => sanitize(item, { sanitizer, ...rest }));
56
- }
57
-
58
- // src/dom/sanitize.js
59
- function sanitize2(value, options = {}) {
60
- return sanitize(value, { sanitizer: import_dompurify.default.sanitize, ...options });
36
+ return (0, import_sanitize.sanitize)(value, { sanitizer: import_dompurify.default.sanitize, ...options });
61
37
  }
62
38
  // Annotate the CommonJS export names for ESM import in node:
63
39
  0 && (module.exports = {
@@ -15,14 +15,12 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/dom/session-store.js
20
18
  var session_store_exports = {};
21
19
  __export(session_store_exports, {
22
20
  sessionStore: () => sessionStore
23
21
  });
24
22
  module.exports = __toCommonJS(session_store_exports);
25
- var sessionStore = {
23
+ const sessionStore = {
26
24
  get(key) {
27
25
  const value = sessionStorage.getItem(key);
28
26
  if (!value) return;
@@ -15,8 +15,6 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/dom/spam-prevention.js
20
18
  var spam_prevention_exports = {};
21
19
  __export(spam_prevention_exports, {
22
20
  preventSpam: () => preventSpam
@@ -15,143 +15,21 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/dom/trap-focus.js
20
18
  var trap_focus_exports = {};
21
19
  __export(trap_focus_exports, {
22
20
  manageFocus: () => manageFocus,
23
21
  trapFocus: () => trapFocus
24
22
  });
25
23
  module.exports = __toCommonJS(trap_focus_exports);
26
-
27
- // src/dom/focusable.js
28
- function getFocusableElements(container = document.body) {
29
- return {
30
- /**
31
- * Gets the number of keyboard focusable elements.
32
- * This is useful for checking if there are any focusable elements
33
- * before attempting to focus them.
34
- *
35
- * @returns {number} The number of keyboard focusable elements
36
- */
37
- get length() {
38
- return this.keyboard.length;
39
- },
40
- /**
41
- * Gets all focusable elements within the container that are visible and enabled.
42
- * This includes elements that can be focused via mouse or programmatically,
43
- * but may not be keyboard focusable.
44
- *
45
- * Elements are considered focusable if they:
46
- * - Are not disabled
47
- * - Are not hidden
48
- * - Are not display:none
49
- *
50
- * @returns {HTMLElement[]} Array of focusable elements that are visible and enabled
51
- */
52
- get all() {
53
- const elements = Array.from(
54
- container.querySelectorAll(
55
- `a,
56
- button,
57
- input,
58
- textarea,
59
- select,
60
- details,
61
- iframe,
62
- embed,
63
- object,
64
- summary,
65
- dialog,
66
- audio[controls],
67
- video[controls],
68
- [contenteditable],
69
- [tabindex]
70
- `
71
- )
72
- );
73
- return elements.filter((el) => {
74
- if (el.hasAttribute("disabled")) return false;
75
- if (el.hasAttribute("hidden")) return false;
76
- if (window.getComputedStyle(el).display === "none") return false;
77
- return true;
78
- });
79
- },
80
- /**
81
- * Gets elements that can be focused via keyboard (tabIndex > -1).
82
- * These are the elements that will be focused when using the Tab key.
83
- *
84
- * @returns {HTMLElement[]} Array of keyboard focusable elements
85
- */
86
- get keyboard() {
87
- return this.all.filter((el) => el instanceof HTMLElement && el.tabIndex > -1);
88
- },
89
- /**
90
- * Alias for keyboard focusable elements.
91
- * This is provided for semantic clarity in certain contexts.
92
- *
93
- * @returns {HTMLElement[]} Array of keyboard focusable elements
94
- */
95
- get keyboardOnly() {
96
- return this.keyboard;
97
- },
98
- /**
99
- * Gets the first keyboard focusable element.
100
- * This is useful for setting initial focus when opening a modal or dialog.
101
- *
102
- * @returns {HTMLElement|null} The first focusable element or null if none exist
103
- */
104
- get first() {
105
- return this.keyboard[0] || null;
106
- },
107
- /**
108
- * Gets the last keyboard focusable element.
109
- * This is useful for focus trapping when using Shift+Tab.
110
- *
111
- * @returns {HTMLElement|null} The last focusable element or null if none exist
112
- */
113
- get last() {
114
- return this.keyboard[this.length - 1] || null;
115
- },
116
- /**
117
- * Gets the next focusable element after the given index.
118
- * This is useful for implementing custom tab order or focus management.
119
- *
120
- * @param {number} index - The current element's index in the keyboard focusable array
121
- * @returns {HTMLElement|null} The next focusable element or null if none exists
122
- */
123
- next(index) {
124
- return this.keyboard[index + 1] || null;
125
- },
126
- /**
127
- * Gets the previous focusable element before the given index.
128
- * This is useful for implementing custom tab order or focus management.
129
- *
130
- * @param {number} index - The current element's index in the keyboard focusable array
131
- * @returns {HTMLElement|null} The previous focusable element or null if none exists
132
- */
133
- prev(index) {
134
- return this.keyboard[index - 1] || null;
135
- }
136
- };
137
- }
138
-
139
- // src/dom/keyboard.js
140
- function isTab(event) {
141
- return !event.shiftKey && event.key === "Tab";
142
- }
143
- function isShiftTab(event) {
144
- return event.shiftKey && event.key === "Tab";
145
- }
146
-
147
- // src/dom/trap-focus.js
24
+ var import_focusable = require("./focusable.js");
25
+ var import_keyboard = require("./keyboard.js");
148
26
  function trapFocus({ event, focusables }) {
149
27
  if (event.key !== "Tab") return;
150
- if (isTab(event) && document.activeElement === focusables.last) {
28
+ if ((0, import_keyboard.isTab)(event) && document.activeElement === focusables.last) {
151
29
  event.preventDefault();
152
30
  focusables.first.focus();
153
31
  }
154
- if (isShiftTab(event) && document.activeElement === focusables.first) {
32
+ if ((0, import_keyboard.isShiftTab)(event) && document.activeElement === focusables.first) {
155
33
  event.preventDefault();
156
34
  focusables.last.focus();
157
35
  }
@@ -167,11 +45,11 @@ function manageFocus({
167
45
  }
168
46
  }) {
169
47
  const activeEl = document.activeElement;
170
- if (activeEl === contentNode && isShiftTab(event)) return backFocus();
171
- if (activeEl === contentNode && focusables.length === 0 && isTab(event))
48
+ if (activeEl === contentNode && (0, import_keyboard.isShiftTab)(event)) return backFocus();
49
+ if (activeEl === contentNode && focusables.length === 0 && (0, import_keyboard.isTab)(event))
172
50
  return nextFocus();
173
- if (activeEl === focusables.last && isTab(event)) return nextFocus();
174
- if (activeEl === focusables.first && isShiftTab(event)) return backFocus();
51
+ if (activeEl === focusables.last && (0, import_keyboard.isTab)(event)) return nextFocus();
52
+ if (activeEl === focusables.first && (0, import_keyboard.isShiftTab)(event)) return backFocus();
175
53
  function backFocus() {
176
54
  event.preventDefault();
177
55
  triggerNode.focus();
@@ -181,7 +59,7 @@ function manageFocus({
181
59
  if (tabOutFocus === "trigger") triggerNode.focus();
182
60
  if (tabOutFocus === "next") {
183
61
  event.preventDefault();
184
- const DOMFocusables = getFocusableElements().keyboard;
62
+ const DOMFocusables = (0, import_focusable.getFocusableElements)().keyboard;
185
63
  const index = DOMFocusables.findIndex((e) => e === triggerNode);
186
64
  const next = DOMFocusables[index + 1];
187
65
  if (next) next.focus();
@@ -15,8 +15,6 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/dom/ui/aria-current.js
20
18
  var aria_current_exports = {};
21
19
  __export(aria_current_exports, {
22
20
  markActiveAnchorIn: () => markActiveAnchorIn,
@@ -15,8 +15,6 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/dom/ui/inconsistent-button-fix.js
20
18
  var inconsistent_button_fix_exports = {};
21
19
  __export(inconsistent_button_fix_exports, {
22
20
  inconsistentButtonFix: () => inconsistentButtonFix
@@ -2,10 +2,6 @@ var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
5
  var __copyProps = (to, from, except, desc) => {
10
6
  if (from && typeof from === "object" || typeof from === "function") {
11
7
  for (let key of __getOwnPropNames(from))
@@ -14,92 +10,18 @@ var __copyProps = (to, from, except, desc) => {
14
10
  }
15
11
  return to;
16
12
  };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
17
14
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/dom/ui/index.js
20
15
  var ui_exports = {};
21
- __export(ui_exports, {
22
- findScrollContainer: () => findScrollContainer,
23
- inconsistentButtonFix: () => inconsistentButtonFix,
24
- markActiveAnchorIn: () => markActiveAnchorIn,
25
- scrollToElement: () => scrollToElement,
26
- traverseAndScramble: () => traverseAndScramble
27
- });
28
16
  module.exports = __toCommonJS(ui_exports);
29
-
30
- // src/dom/ui/aria-current.js
31
- function markActiveAnchorIn(container, anchorType = "page") {
32
- if (!container) return;
33
- const { pathname } = window.location;
34
- const element = container.querySelector(`[href="${pathname}"]`);
35
- if (!element) return;
36
- element.setAttribute("aria-current", "page");
37
- return element;
38
- }
39
- function scrollToElement(element, { scrollBehaviour = "instant", scrollMargin = "3rem" } = {}) {
40
- if (!element) return;
41
- element.style.scrollMarginTop = scrollMargin;
42
- element.scrollIntoView({ behavior: scrollBehaviour });
43
- }
44
-
45
- // src/dom/ui/inconsistent-button-fix.js
46
- function inconsistentButtonFix() {
47
- document.addEventListener("click", (event) => {
48
- if (event.target instanceof HTMLButtonElement) {
49
- event.target.focus();
50
- }
51
- });
52
- }
53
-
54
- // src/dom/ui/scroll-container.js
55
- function findScrollContainer(element, direction = "both") {
56
- if (!element) return;
57
- let parent = element.parentElement;
58
- while (parent) {
59
- const { overflow, overflowX, overflowY } = getComputedStyle(parent);
60
- if (direction === "both") {
61
- if (overflow.includes("auto") || overflow.includes("scroll"))
62
- return parent;
63
- }
64
- if (direction === "horizontal") {
65
- if (overflowX === "auto" || overflowX === "scroll") return parent;
66
- }
67
- if (direction === "vertical") {
68
- if (overflowY === "auto" || overflowY === "scroll") return parent;
69
- }
70
- parent = parent.parentElement;
71
- }
72
- return document.documentElement;
73
- }
74
-
75
- // src/dom/ui/traverse-and-scramble.js
76
- function traverseAndScramble(node, { excludes = [] } = {}) {
77
- if (node instanceof Element && excludes.some((selector) => node.matches(selector))) {
78
- return;
79
- }
80
- node.childNodes.forEach((child) => {
81
- if (child.nodeType === 3) {
82
- child.nodeValue = scrambleText(child.nodeValue);
83
- } else if (child.nodeType === 1 && child instanceof Element) {
84
- traverseAndScramble(child, { excludes });
85
- }
86
- });
87
- }
88
- function scrambleText(text) {
89
- return text.split("").map((char) => {
90
- if (/^[A-Za-z0-9]$/.test(char)) {
91
- const randomCharCode = Math.random() < 26 / 36 ? Math.floor(Math.random() * 26) + (char === char.toUpperCase() ? 65 : 97) : Math.floor(Math.random() * 10) + 48;
92
- return String.fromCharCode(randomCharCode);
93
- } else {
94
- return char;
95
- }
96
- }).join("");
97
- }
17
+ __reExport(ui_exports, require("./aria-current.js"), module.exports);
18
+ __reExport(ui_exports, require("./inconsistent-button-fix.js"), module.exports);
19
+ __reExport(ui_exports, require("./scroll-container.js"), module.exports);
20
+ __reExport(ui_exports, require("./traverse-and-scramble.js"), module.exports);
98
21
  // Annotate the CommonJS export names for ESM import in node:
99
22
  0 && (module.exports = {
100
- findScrollContainer,
101
- inconsistentButtonFix,
102
- markActiveAnchorIn,
103
- scrollToElement,
104
- traverseAndScramble
23
+ ...require("./aria-current.js"),
24
+ ...require("./inconsistent-button-fix.js"),
25
+ ...require("./scroll-container.js"),
26
+ ...require("./traverse-and-scramble.js")
105
27
  });
@@ -15,8 +15,6 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/dom/ui/scroll-container.js
20
18
  var scroll_container_exports = {};
21
19
  __export(scroll_container_exports, {
22
20
  findScrollContainer: () => findScrollContainer
@@ -15,8 +15,6 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/dom/ui/traverse-and-scramble.js
20
18
  var traverse_and_scramble_exports = {};
21
19
  __export(traverse_and_scramble_exports, {
22
20
  traverseAndScramble: () => traverseAndScramble
@@ -2,10 +2,6 @@ var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
5
  var __copyProps = (to, from, except, desc) => {
10
6
  if (from && typeof from === "object" || typeof from === "function") {
11
7
  for (let key of __getOwnPropNames(from))
@@ -14,126 +10,22 @@ var __copyProps = (to, from, except, desc) => {
14
10
  }
15
11
  return to;
16
12
  };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
17
14
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/lib/arrays/index.js
20
15
  var arrays_exports = {};
21
- __export(arrays_exports, {
22
- isLastItem: () => isLastItem,
23
- joinWithConjunction: () => joinWithConjunction,
24
- last: () => last,
25
- lastArrayItem: () => lastArrayItem,
26
- shuffle: () => shuffle,
27
- sort: () => sort,
28
- splitArray: () => splitArray,
29
- uniqueArray: () => uniqueArray
30
- });
31
16
  module.exports = __toCommonJS(arrays_exports);
32
-
33
- // src/lib/arrays/item-position.js
34
- function last(array, index) {
35
- console.warn("last is deprecated. Use isLastItem instead.");
36
- return index === array.length - 1;
37
- }
38
- function isLastItem(array, index) {
39
- return index === array.length - 1;
40
- }
41
- function lastArrayItem(array) {
42
- return array[array.length - 1];
43
- }
44
-
45
- // src/lib/arrays/join.js
46
- function joinWithConjunction(array, { conjunction = "and" } = {}) {
47
- if (!array?.length) return "";
48
- if (array.length === 1) return array[0];
49
- if (array.length === 2) return `${array[0]} ${conjunction} ${array[1]}`;
50
- const lastItem = lastArrayItem(array);
51
- const rest = array.slice(0, -1);
52
- return `${rest.join(", ")} ${conjunction} ${lastItem}`;
53
- }
54
-
55
- // src/lib/arrays/shuffle.js
56
- function shuffle(array) {
57
- const clone = array.slice();
58
- let currentIndex = array.length;
59
- let temporaryValue;
60
- let randomIndex;
61
- while (currentIndex !== 0) {
62
- randomIndex = Math.floor(Math.random() * currentIndex);
63
- currentIndex -= 1;
64
- temporaryValue = clone[currentIndex];
65
- clone[currentIndex] = clone[randomIndex];
66
- clone[randomIndex] = temporaryValue;
67
- }
68
- return clone;
69
- }
70
-
71
- // src/lib/objects/nested-property.js
72
- function getNestedValue(object, path) {
73
- return path.split(".").reduce((acc, part) => acc?.[part], object);
74
- }
75
-
76
- // src/lib/arrays/sort.js
77
- function sort(array, { props = null, reverse = false } = {}) {
78
- const clone = array.slice();
79
- if (props === null) {
80
- return clone.sort((a, b) => {
81
- const comparison = compareValues(a, b);
82
- return reverse ? -comparison : comparison;
83
- });
84
- }
85
- const properties = Array.isArray(props) ? props : [props];
86
- return clone.sort((a, b) => {
87
- for (const property of properties) {
88
- const aValue = getNestedValue(a, property);
89
- const bValue = getNestedValue(b, property);
90
- if (aValue === bValue) continue;
91
- if (aValue == null) return 1;
92
- if (bValue == null) return -1;
93
- const comparison = compareValues(aValue, bValue);
94
- return reverse ? -comparison : comparison;
95
- }
96
- return 0;
97
- });
98
- }
99
- function compareValues(a, b) {
100
- if (typeof a === "number" && typeof b === "number") return a - b;
101
- if (typeof a === "string" && typeof b === "string") return a.localeCompare(b);
102
- const aDate = new Date(a);
103
- const bDate = new Date(b);
104
- const aTime = aDate.getTime();
105
- const bTime = bDate.getTime();
106
- if (!isNaN(aTime) && !isNaN(bTime)) return aTime - bTime;
107
- return String(a).localeCompare(String(b));
108
- }
109
-
110
- // src/lib/arrays/split-array.js
111
- function splitArray(array, predicate) {
112
- const ret = {
113
- picked: [],
114
- omitted: []
115
- };
116
- array.forEach((item, index, arr) => {
117
- if (predicate(item, index, arr)) ret.picked.push(item);
118
- else ret.omitted.push(item);
119
- });
120
- ret.p = ret.picked;
121
- ret.o = ret.omitted;
122
- return ret;
123
- }
124
-
125
- // src/lib/arrays/unique.js
126
- function uniqueArray(array) {
127
- return Array.from(new Set(array));
128
- }
17
+ __reExport(arrays_exports, require("./item-position.js"), module.exports);
18
+ __reExport(arrays_exports, require("./join.js"), module.exports);
19
+ __reExport(arrays_exports, require("./shuffle.js"), module.exports);
20
+ __reExport(arrays_exports, require("./sort.js"), module.exports);
21
+ __reExport(arrays_exports, require("./split-array.js"), module.exports);
22
+ __reExport(arrays_exports, require("./unique.js"), module.exports);
129
23
  // Annotate the CommonJS export names for ESM import in node:
130
24
  0 && (module.exports = {
131
- isLastItem,
132
- joinWithConjunction,
133
- last,
134
- lastArrayItem,
135
- shuffle,
136
- sort,
137
- splitArray,
138
- uniqueArray
25
+ ...require("./item-position.js"),
26
+ ...require("./join.js"),
27
+ ...require("./shuffle.js"),
28
+ ...require("./sort.js"),
29
+ ...require("./split-array.js"),
30
+ ...require("./unique.js")
139
31
  });
@@ -15,8 +15,6 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/lib/arrays/item-position.js
20
18
  var item_position_exports = {};
21
19
  __export(item_position_exports, {
22
20
  isLastItem: () => isLastItem,
@@ -15,25 +15,17 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/lib/arrays/join.js
20
18
  var join_exports = {};
21
19
  __export(join_exports, {
22
20
  joinWithConjunction: () => joinWithConjunction
23
21
  });
24
22
  module.exports = __toCommonJS(join_exports);
25
-
26
- // src/lib/arrays/item-position.js
27
- function lastArrayItem(array) {
28
- return array[array.length - 1];
29
- }
30
-
31
- // src/lib/arrays/join.js
23
+ var import_item_position = require("./item-position.js");
32
24
  function joinWithConjunction(array, { conjunction = "and" } = {}) {
33
25
  if (!array?.length) return "";
34
26
  if (array.length === 1) return array[0];
35
27
  if (array.length === 2) return `${array[0]} ${conjunction} ${array[1]}`;
36
- const lastItem = lastArrayItem(array);
28
+ const lastItem = (0, import_item_position.lastArrayItem)(array);
37
29
  const rest = array.slice(0, -1);
38
30
  return `${rest.join(", ")} ${conjunction} ${lastItem}`;
39
31
  }
@@ -15,8 +15,6 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/lib/arrays/shuffle.js
20
18
  var shuffle_exports = {};
21
19
  __export(shuffle_exports, {
22
20
  shuffle: () => shuffle
@@ -15,20 +15,12 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/lib/arrays/sort.js
20
18
  var sort_exports = {};
21
19
  __export(sort_exports, {
22
20
  sort: () => sort
23
21
  });
24
22
  module.exports = __toCommonJS(sort_exports);
25
-
26
- // src/lib/objects/nested-property.js
27
- function getNestedValue(object, path) {
28
- return path.split(".").reduce((acc, part) => acc?.[part], object);
29
- }
30
-
31
- // src/lib/arrays/sort.js
23
+ var import_nested_property = require("../objects/nested-property.js");
32
24
  function sort(array, { props = null, reverse = false } = {}) {
33
25
  const clone = array.slice();
34
26
  if (props === null) {
@@ -40,8 +32,8 @@ function sort(array, { props = null, reverse = false } = {}) {
40
32
  const properties = Array.isArray(props) ? props : [props];
41
33
  return clone.sort((a, b) => {
42
34
  for (const property of properties) {
43
- const aValue = getNestedValue(a, property);
44
- const bValue = getNestedValue(b, property);
35
+ const aValue = (0, import_nested_property.getNestedValue)(a, property);
36
+ const bValue = (0, import_nested_property.getNestedValue)(b, property);
45
37
  if (aValue === bValue) continue;
46
38
  if (aValue == null) return 1;
47
39
  if (bValue == null) return -1;
@@ -15,8 +15,6 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/lib/arrays/split-array.js
20
18
  var split_array_exports = {};
21
19
  __export(split_array_exports, {
22
20
  splitArray: () => splitArray
@@ -15,8 +15,6 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/lib/arrays/unique.js
20
18
  var unique_exports = {};
21
19
  __export(unique_exports, {
22
20
  uniqueArray: () => uniqueArray