@bquery/bquery 1.2.0 → 1.4.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 (309) hide show
  1. package/README.md +127 -27
  2. package/dist/batch-x7b2eZST.js +13 -0
  3. package/dist/batch-x7b2eZST.js.map +1 -0
  4. package/dist/component/component.d.ts +69 -0
  5. package/dist/component/component.d.ts.map +1 -0
  6. package/dist/component/html.d.ts +35 -0
  7. package/dist/component/html.d.ts.map +1 -0
  8. package/dist/component/index.d.ts +3 -126
  9. package/dist/component/index.d.ts.map +1 -1
  10. package/dist/component/props.d.ts +18 -0
  11. package/dist/component/props.d.ts.map +1 -0
  12. package/dist/component/types.d.ts +77 -0
  13. package/dist/component/types.d.ts.map +1 -0
  14. package/dist/component.es.mjs +90 -59
  15. package/dist/component.es.mjs.map +1 -1
  16. package/dist/core/collection.d.ts +55 -3
  17. package/dist/core/collection.d.ts.map +1 -1
  18. package/dist/core/dom.d.ts +6 -0
  19. package/dist/core/dom.d.ts.map +1 -0
  20. package/dist/core/element.d.ts +31 -4
  21. package/dist/core/element.d.ts.map +1 -1
  22. package/dist/core/index.d.ts +2 -0
  23. package/dist/core/index.d.ts.map +1 -1
  24. package/dist/core/utils/array.d.ts +74 -0
  25. package/dist/core/utils/array.d.ts.map +1 -0
  26. package/dist/core/utils/function.d.ts +87 -0
  27. package/dist/core/utils/function.d.ts.map +1 -0
  28. package/dist/core/utils/index.d.ts +70 -0
  29. package/dist/core/utils/index.d.ts.map +1 -0
  30. package/dist/core/utils/misc.d.ts +63 -0
  31. package/dist/core/utils/misc.d.ts.map +1 -0
  32. package/dist/core/utils/number.d.ts +65 -0
  33. package/dist/core/utils/number.d.ts.map +1 -0
  34. package/dist/core/utils/object.d.ts +133 -0
  35. package/dist/core/utils/object.d.ts.map +1 -0
  36. package/dist/core/utils/string.d.ts +80 -0
  37. package/dist/core/utils/string.d.ts.map +1 -0
  38. package/dist/core/utils/type-guards.d.ts +79 -0
  39. package/dist/core/utils/type-guards.d.ts.map +1 -0
  40. package/dist/core-BhpuvPhy.js +170 -0
  41. package/dist/core-BhpuvPhy.js.map +1 -0
  42. package/dist/core.es.mjs +495 -489
  43. package/dist/core.es.mjs.map +1 -1
  44. package/dist/full.d.ts +2 -2
  45. package/dist/full.d.ts.map +1 -1
  46. package/dist/full.es.mjs +87 -64
  47. package/dist/full.es.mjs.map +1 -1
  48. package/dist/full.iife.js +2 -2
  49. package/dist/full.iife.js.map +1 -1
  50. package/dist/full.umd.js +2 -2
  51. package/dist/full.umd.js.map +1 -1
  52. package/dist/index.es.mjs +138 -68
  53. package/dist/index.es.mjs.map +1 -1
  54. package/dist/motion/animate.d.ts +25 -0
  55. package/dist/motion/animate.d.ts.map +1 -0
  56. package/dist/motion/easing.d.ts +30 -0
  57. package/dist/motion/easing.d.ts.map +1 -0
  58. package/dist/motion/flip.d.ts +55 -0
  59. package/dist/motion/flip.d.ts.map +1 -0
  60. package/dist/motion/index.d.ts +11 -138
  61. package/dist/motion/index.d.ts.map +1 -1
  62. package/dist/motion/keyframes.d.ts +21 -0
  63. package/dist/motion/keyframes.d.ts.map +1 -0
  64. package/dist/motion/reduced-motion.d.ts +12 -0
  65. package/dist/motion/reduced-motion.d.ts.map +1 -0
  66. package/dist/motion/scroll.d.ts +15 -0
  67. package/dist/motion/scroll.d.ts.map +1 -0
  68. package/dist/motion/spring.d.ts +42 -0
  69. package/dist/motion/spring.d.ts.map +1 -0
  70. package/dist/motion/stagger.d.ts +22 -0
  71. package/dist/motion/stagger.d.ts.map +1 -0
  72. package/dist/motion/timeline.d.ts +21 -0
  73. package/dist/motion/timeline.d.ts.map +1 -0
  74. package/dist/motion/transition.d.ts +22 -0
  75. package/dist/motion/transition.d.ts.map +1 -0
  76. package/dist/motion/types.d.ts +182 -0
  77. package/dist/motion/types.d.ts.map +1 -0
  78. package/dist/motion.es.mjs +320 -61
  79. package/dist/motion.es.mjs.map +1 -1
  80. package/dist/persisted-DHoi3uEs.js +278 -0
  81. package/dist/persisted-DHoi3uEs.js.map +1 -0
  82. package/dist/platform/storage.d.ts.map +1 -1
  83. package/dist/platform.es.mjs +12 -7
  84. package/dist/platform.es.mjs.map +1 -1
  85. package/dist/reactive/batch.d.ts +13 -0
  86. package/dist/reactive/batch.d.ts.map +1 -0
  87. package/dist/reactive/computed.d.ts +50 -0
  88. package/dist/reactive/computed.d.ts.map +1 -0
  89. package/dist/reactive/core.d.ts +72 -0
  90. package/dist/reactive/core.d.ts.map +1 -0
  91. package/dist/reactive/effect.d.ts +15 -0
  92. package/dist/reactive/effect.d.ts.map +1 -0
  93. package/dist/reactive/index.d.ts +2 -2
  94. package/dist/reactive/index.d.ts.map +1 -1
  95. package/dist/reactive/internals.d.ts +42 -0
  96. package/dist/reactive/internals.d.ts.map +1 -0
  97. package/dist/reactive/linked.d.ts +36 -0
  98. package/dist/reactive/linked.d.ts.map +1 -0
  99. package/dist/reactive/persisted.d.ts +14 -0
  100. package/dist/reactive/persisted.d.ts.map +1 -0
  101. package/dist/reactive/readonly.d.ts +26 -0
  102. package/dist/reactive/readonly.d.ts.map +1 -0
  103. package/dist/reactive/signal.d.ts +13 -312
  104. package/dist/reactive/signal.d.ts.map +1 -1
  105. package/dist/reactive/type-guards.d.ts +20 -0
  106. package/dist/reactive/type-guards.d.ts.map +1 -0
  107. package/dist/reactive/untrack.d.ts +29 -0
  108. package/dist/reactive/untrack.d.ts.map +1 -0
  109. package/dist/reactive/watch.d.ts +42 -0
  110. package/dist/reactive/watch.d.ts.map +1 -0
  111. package/dist/reactive.es.mjs +30 -163
  112. package/dist/reactive.es.mjs.map +1 -1
  113. package/dist/router/index.d.ts +6 -252
  114. package/dist/router/index.d.ts.map +1 -1
  115. package/dist/router/links.d.ts +44 -0
  116. package/dist/router/links.d.ts.map +1 -0
  117. package/dist/router/match.d.ts +20 -0
  118. package/dist/router/match.d.ts.map +1 -0
  119. package/dist/router/navigation.d.ts +45 -0
  120. package/dist/router/navigation.d.ts.map +1 -0
  121. package/dist/router/query.d.ts +16 -0
  122. package/dist/router/query.d.ts.map +1 -0
  123. package/dist/router/router.d.ts +34 -0
  124. package/dist/router/router.d.ts.map +1 -0
  125. package/dist/router/state.d.ts +27 -0
  126. package/dist/router/state.d.ts.map +1 -0
  127. package/dist/router/types.d.ts +88 -0
  128. package/dist/router/types.d.ts.map +1 -0
  129. package/dist/router/utils.d.ts +65 -0
  130. package/dist/router/utils.d.ts.map +1 -0
  131. package/dist/router.es.mjs +168 -132
  132. package/dist/router.es.mjs.map +1 -1
  133. package/dist/sanitize-Cxvxa-DX.js +283 -0
  134. package/dist/sanitize-Cxvxa-DX.js.map +1 -0
  135. package/dist/security/constants.d.ts +42 -0
  136. package/dist/security/constants.d.ts.map +1 -0
  137. package/dist/security/csp.d.ts +24 -0
  138. package/dist/security/csp.d.ts.map +1 -0
  139. package/dist/security/index.d.ts +4 -2
  140. package/dist/security/index.d.ts.map +1 -1
  141. package/dist/security/sanitize-core.d.ts +13 -0
  142. package/dist/security/sanitize-core.d.ts.map +1 -0
  143. package/dist/security/sanitize.d.ts +5 -57
  144. package/dist/security/sanitize.d.ts.map +1 -1
  145. package/dist/security/trusted-types.d.ts +25 -0
  146. package/dist/security/trusted-types.d.ts.map +1 -0
  147. package/dist/security/types.d.ts +36 -0
  148. package/dist/security/types.d.ts.map +1 -0
  149. package/dist/security.es.mjs +50 -277
  150. package/dist/security.es.mjs.map +1 -1
  151. package/dist/store/create-store.d.ts +15 -0
  152. package/dist/store/create-store.d.ts.map +1 -0
  153. package/dist/store/define-store.d.ts +28 -0
  154. package/dist/store/define-store.d.ts.map +1 -0
  155. package/dist/store/devtools.d.ts +22 -0
  156. package/dist/store/devtools.d.ts.map +1 -0
  157. package/dist/store/index.d.ts +10 -286
  158. package/dist/store/index.d.ts.map +1 -1
  159. package/dist/store/mapping.d.ts +28 -0
  160. package/dist/store/mapping.d.ts.map +1 -0
  161. package/dist/store/persisted.d.ts +13 -0
  162. package/dist/store/persisted.d.ts.map +1 -0
  163. package/dist/store/plugins.d.ts +13 -0
  164. package/dist/store/plugins.d.ts.map +1 -0
  165. package/dist/store/registry.d.ts +28 -0
  166. package/dist/store/registry.d.ts.map +1 -0
  167. package/dist/store/types.d.ts +71 -0
  168. package/dist/store/types.d.ts.map +1 -0
  169. package/dist/store/utils.d.ts +28 -0
  170. package/dist/store/utils.d.ts.map +1 -0
  171. package/dist/store/watch.d.ts +23 -0
  172. package/dist/store/watch.d.ts.map +1 -0
  173. package/dist/store.es.mjs +22 -224
  174. package/dist/store.es.mjs.map +1 -1
  175. package/dist/type-guards-BdKlYYlS.js +32 -0
  176. package/dist/type-guards-BdKlYYlS.js.map +1 -0
  177. package/dist/untrack-DNnnqdlR.js +6 -0
  178. package/dist/untrack-DNnnqdlR.js.map +1 -0
  179. package/dist/view/directives/bind.d.ts +7 -0
  180. package/dist/view/directives/bind.d.ts.map +1 -0
  181. package/dist/view/directives/class.d.ts +8 -0
  182. package/dist/view/directives/class.d.ts.map +1 -0
  183. package/dist/view/directives/for.d.ts +23 -0
  184. package/dist/view/directives/for.d.ts.map +1 -0
  185. package/dist/view/directives/html.d.ts +7 -0
  186. package/dist/view/directives/html.d.ts.map +1 -0
  187. package/dist/view/directives/if.d.ts +7 -0
  188. package/dist/view/directives/if.d.ts.map +1 -0
  189. package/dist/view/directives/index.d.ts +12 -0
  190. package/dist/view/directives/index.d.ts.map +1 -0
  191. package/dist/view/directives/model.d.ts +7 -0
  192. package/dist/view/directives/model.d.ts.map +1 -0
  193. package/dist/view/directives/on.d.ts +7 -0
  194. package/dist/view/directives/on.d.ts.map +1 -0
  195. package/dist/view/directives/ref.d.ts +7 -0
  196. package/dist/view/directives/ref.d.ts.map +1 -0
  197. package/dist/view/directives/show.d.ts +7 -0
  198. package/dist/view/directives/show.d.ts.map +1 -0
  199. package/dist/view/directives/style.d.ts +7 -0
  200. package/dist/view/directives/style.d.ts.map +1 -0
  201. package/dist/view/directives/text.d.ts +7 -0
  202. package/dist/view/directives/text.d.ts.map +1 -0
  203. package/dist/view/evaluate.d.ts +43 -0
  204. package/dist/view/evaluate.d.ts.map +1 -0
  205. package/dist/view/index.d.ts +3 -93
  206. package/dist/view/index.d.ts.map +1 -1
  207. package/dist/view/mount.d.ts +69 -0
  208. package/dist/view/mount.d.ts.map +1 -0
  209. package/dist/view/process.d.ts +26 -0
  210. package/dist/view/process.d.ts.map +1 -0
  211. package/dist/view/types.d.ts +36 -0
  212. package/dist/view/types.d.ts.map +1 -0
  213. package/dist/view.es.mjs +358 -251
  214. package/dist/view.es.mjs.map +1 -1
  215. package/dist/watch-DXXv3iAI.js +58 -0
  216. package/dist/watch-DXXv3iAI.js.map +1 -0
  217. package/package.json +14 -14
  218. package/src/component/component.ts +289 -0
  219. package/src/component/html.ts +53 -0
  220. package/src/component/index.ts +40 -414
  221. package/src/component/props.ts +116 -0
  222. package/src/component/types.ts +85 -0
  223. package/src/core/collection.ts +181 -7
  224. package/src/core/dom.ts +38 -0
  225. package/src/core/element.ts +59 -25
  226. package/src/core/index.ts +48 -4
  227. package/src/core/utils/array.ts +102 -0
  228. package/src/core/utils/function.ts +151 -0
  229. package/src/core/utils/index.ts +83 -0
  230. package/src/core/utils/misc.ts +82 -0
  231. package/src/core/utils/number.ts +78 -0
  232. package/src/core/utils/object.ts +206 -0
  233. package/src/core/utils/string.ts +112 -0
  234. package/src/core/utils/type-guards.ts +112 -0
  235. package/src/full.ts +187 -150
  236. package/src/index.ts +36 -36
  237. package/src/motion/animate.ts +113 -0
  238. package/src/motion/easing.ts +40 -0
  239. package/src/motion/flip.ts +176 -0
  240. package/src/motion/index.ts +41 -358
  241. package/src/motion/keyframes.ts +46 -0
  242. package/src/motion/reduced-motion.ts +17 -0
  243. package/src/motion/scroll.ts +57 -0
  244. package/src/motion/spring.ts +150 -0
  245. package/src/motion/stagger.ts +43 -0
  246. package/src/motion/timeline.ts +246 -0
  247. package/src/motion/transition.ts +51 -0
  248. package/src/motion/types.ts +198 -0
  249. package/src/platform/storage.ts +215 -208
  250. package/src/reactive/batch.ts +22 -0
  251. package/src/reactive/computed.ts +92 -0
  252. package/src/reactive/core.ts +114 -0
  253. package/src/reactive/effect.ts +54 -0
  254. package/src/reactive/index.ts +23 -22
  255. package/src/reactive/internals.ts +122 -0
  256. package/src/reactive/linked.ts +56 -0
  257. package/src/reactive/persisted.ts +74 -0
  258. package/src/reactive/readonly.ts +35 -0
  259. package/src/reactive/signal.ts +20 -520
  260. package/src/reactive/type-guards.ts +22 -0
  261. package/src/reactive/untrack.ts +31 -0
  262. package/src/reactive/watch.ts +73 -0
  263. package/src/router/index.ts +41 -718
  264. package/src/router/links.ts +130 -0
  265. package/src/router/match.ts +106 -0
  266. package/src/router/navigation.ts +71 -0
  267. package/src/router/query.ts +35 -0
  268. package/src/router/router.ts +211 -0
  269. package/src/router/state.ts +46 -0
  270. package/src/router/types.ts +93 -0
  271. package/src/router/utils.ts +116 -0
  272. package/src/security/constants.ts +209 -0
  273. package/src/security/csp.ts +77 -0
  274. package/src/security/index.ts +4 -12
  275. package/src/security/sanitize-core.ts +364 -0
  276. package/src/security/sanitize.ts +66 -625
  277. package/src/security/trusted-types.ts +69 -0
  278. package/src/security/types.ts +40 -0
  279. package/src/store/create-store.ts +329 -0
  280. package/src/store/define-store.ts +48 -0
  281. package/src/store/devtools.ts +45 -0
  282. package/src/store/index.ts +22 -848
  283. package/src/store/mapping.ts +73 -0
  284. package/src/store/persisted.ts +61 -0
  285. package/src/store/plugins.ts +32 -0
  286. package/src/store/registry.ts +51 -0
  287. package/src/store/types.ts +94 -0
  288. package/src/store/utils.ts +141 -0
  289. package/src/store/watch.ts +52 -0
  290. package/src/view/directives/bind.ts +23 -0
  291. package/src/view/directives/class.ts +70 -0
  292. package/src/view/directives/for.ts +275 -0
  293. package/src/view/directives/html.ts +19 -0
  294. package/src/view/directives/if.ts +30 -0
  295. package/src/view/directives/index.ts +11 -0
  296. package/src/view/directives/model.ts +56 -0
  297. package/src/view/directives/on.ts +41 -0
  298. package/src/view/directives/ref.ts +41 -0
  299. package/src/view/directives/show.ts +26 -0
  300. package/src/view/directives/style.ts +47 -0
  301. package/src/view/directives/text.ts +15 -0
  302. package/src/view/evaluate.ts +290 -0
  303. package/src/view/index.ts +112 -1041
  304. package/src/view/mount.ts +200 -0
  305. package/src/view/process.ts +92 -0
  306. package/src/view/types.ts +44 -0
  307. package/dist/core/utils.d.ts +0 -313
  308. package/dist/core/utils.d.ts.map +0 -1
  309. package/src/core/utils.ts +0 -444
package/dist/core.es.mjs CHANGED
@@ -1,9 +1,23 @@
1
- import { sanitize as f } from "./security.es.mjs";
2
- const p = (r) => Array.isArray(r) ? r : [r], o = (r, e) => {
3
- for (const t of r)
1
+ import { s as f } from "./sanitize-Cxvxa-DX.js";
2
+ const g = (n) => Array.isArray(n) ? n : [n], l = (n, e) => {
3
+ for (const t of n)
4
4
  e(t);
5
+ }, p = (n) => f(n), w = (n, e) => {
6
+ n.innerHTML = f(e);
7
+ }, y = (n) => {
8
+ const e = document.createElement("template");
9
+ return e.innerHTML = f(n), e.content.firstElementChild ?? document.createElement("div");
10
+ }, b = (n, e, t) => {
11
+ if (typeof e == "string") {
12
+ n.insertAdjacentHTML(t, f(e));
13
+ return;
14
+ }
15
+ const r = g(e), i = t === "afterbegin" || t === "afterend" ? r.slice().reverse() : r;
16
+ l(i, (o) => {
17
+ n.insertAdjacentElement(t, o);
18
+ });
5
19
  };
6
- class a {
20
+ class h {
7
21
  /**
8
22
  * Creates a new BQueryElement wrapper.
9
23
  * @param element - The DOM element to wrap
@@ -41,14 +55,23 @@ class a {
41
55
  attr(e, t) {
42
56
  return t === void 0 ? this.element.getAttribute(e) ?? "" : (this.element.setAttribute(e, t), this);
43
57
  }
58
+ /** Remove an attribute. */
59
+ removeAttr(e) {
60
+ return this.element.removeAttribute(e), this;
61
+ }
62
+ /** Toggle an attribute on/off. */
63
+ toggleAttr(e, t) {
64
+ const r = this.element.hasAttribute(e);
65
+ return t ?? !r ? this.element.setAttribute(e, "") : this.element.removeAttribute(e), this;
66
+ }
44
67
  /** Get or set a property. */
45
68
  prop(e, t) {
46
69
  return t === void 0 ? this.element[e] : (this.element[e] = t, this);
47
70
  }
48
71
  /** Read or write data attributes in camelCase. */
49
72
  data(e, t) {
50
- const n = e.replace(/[A-Z]/g, (s) => `-${s.toLowerCase()}`);
51
- return t === void 0 ? this.element.getAttribute(`data-${n}`) ?? "" : (this.element.setAttribute(`data-${n}`, t), this);
73
+ const r = e.replace(/[A-Z]/g, (s) => `-${s.toLowerCase()}`);
74
+ return t === void 0 ? this.element.getAttribute(`data-${r}`) ?? "" : (this.element.setAttribute(`data-${r}`, t), this);
52
75
  }
53
76
  /** Get or set text content. */
54
77
  text(e) {
@@ -68,7 +91,7 @@ class a {
68
91
  * ```
69
92
  */
70
93
  html(e) {
71
- return this.element.innerHTML = f(e), this;
94
+ return w(this.element, e), this;
72
95
  }
73
96
  /**
74
97
  * Sets HTML content without sanitization.
@@ -82,27 +105,15 @@ class a {
82
105
  htmlUnsafe(e) {
83
106
  return this.element.innerHTML = e, this;
84
107
  }
85
- /**
86
- * Gets or sets CSS styles on the element.
87
- *
88
- * @param property - A CSS property name or an object of property-value pairs
89
- * @param value - The value when setting a single property
90
- * @returns The instance for method chaining
91
- *
92
- * @example
93
- * ```ts
94
- * // Single property
95
- * $('#box').css('color', 'red');
96
- *
97
- * // Multiple properties
98
- * $('#box').css({ color: 'red', 'font-size': '16px' });
99
- * ```
100
- */
101
108
  css(e, t) {
102
- if (typeof e == "string")
103
- return t !== void 0 && this.element.style.setProperty(e, t), this;
104
- for (const [n, s] of Object.entries(e))
105
- this.element.style.setProperty(n, s);
109
+ if (typeof e == "string") {
110
+ if (t !== void 0)
111
+ return this.element.style.setProperty(e, t), this;
112
+ const r = this.element.ownerDocument?.defaultView;
113
+ return !r || typeof r.getComputedStyle != "function" ? "" : r.getComputedStyle(this.element).getPropertyValue(e);
114
+ }
115
+ for (const [r, s] of Object.entries(e))
116
+ this.element.style.setProperty(r, s);
106
117
  return this;
107
118
  }
108
119
  /**
@@ -161,6 +172,10 @@ class a {
161
172
  * Removes the parent element, keeping this element in its place.
162
173
  * Essentially the opposite of wrap().
163
174
  *
175
+ * **Important**: This method only moves the current element out of its parent
176
+ * before removing the parent. Any sibling elements will be removed along with
177
+ * the parent. For unwrapping multiple siblings, use a collection: `$$(siblings).unwrap()`.
178
+ *
164
179
  * @returns The instance for method chaining
165
180
  *
166
181
  * @example
@@ -186,13 +201,8 @@ class a {
186
201
  * ```
187
202
  */
188
203
  replaceWith(e) {
189
- let t;
190
- if (typeof e == "string") {
191
- const n = document.createElement("template");
192
- n.innerHTML = f(e), t = n.content.firstElementChild ?? document.createElement("div");
193
- } else
194
- t = e;
195
- return this.element.replaceWith(t), new a(t);
204
+ const t = typeof e == "string" ? y(e) : e;
205
+ return this.element.replaceWith(t), new h(t);
196
206
  }
197
207
  /**
198
208
  * Scrolls the element into view with configurable behavior.
@@ -232,7 +242,7 @@ class a {
232
242
  * @returns A new BQueryElement wrapping the cloned element
233
243
  */
234
244
  clone(e = !0) {
235
- return new a(this.element.cloneNode(e));
245
+ return new h(this.element.cloneNode(e));
236
246
  }
237
247
  /**
238
248
  * Finds all descendant elements matching the selector.
@@ -363,12 +373,12 @@ class a {
363
373
  * $('#list').undelegate('click', '.item', handler);
364
374
  * ```
365
375
  */
366
- delegate(e, t, n) {
367
- const s = `${e}:${t}`, i = (l) => {
368
- const h = l.target.closest(t);
369
- h && this.element.contains(h) && n(l, h);
376
+ delegate(e, t, r) {
377
+ const s = `${e}:${t}`, i = (o) => {
378
+ const u = o.target.closest(t);
379
+ u && this.element.contains(u) && r(o, u);
370
380
  };
371
- return this.delegatedHandlers.has(s) || this.delegatedHandlers.set(s, /* @__PURE__ */ new Map()), this.delegatedHandlers.get(s).set(n, i), this.element.addEventListener(e, i), this;
381
+ return this.delegatedHandlers.has(s) || this.delegatedHandlers.set(s, /* @__PURE__ */ new Map()), this.delegatedHandlers.get(s).set(r, i), this.element.addEventListener(e, i), this;
372
382
  }
373
383
  /**
374
384
  * Removes a delegated event listener previously added with `delegate()`.
@@ -387,11 +397,11 @@ class a {
387
397
  * $('#list').undelegate('click', '.item', handler);
388
398
  * ```
389
399
  */
390
- undelegate(e, t, n) {
400
+ undelegate(e, t, r) {
391
401
  const s = `${e}:${t}`, i = this.delegatedHandlers.get(s);
392
402
  if (i) {
393
- const l = i.get(n);
394
- l && (this.element.removeEventListener(e, l), i.delete(n), i.size === 0 && this.delegatedHandlers.delete(s));
403
+ const o = i.get(r);
404
+ o && (this.element.removeEventListener(e, o), i.delete(r), i.size === 0 && this.delegatedHandlers.delete(s));
395
405
  }
396
406
  return this;
397
407
  }
@@ -404,6 +414,22 @@ class a {
404
414
  matches(e) {
405
415
  return this.element.matches(e);
406
416
  }
417
+ /**
418
+ * Alias for `matches()`. Checks if the element matches a CSS selector.
419
+ *
420
+ * @param selector - CSS selector to match against
421
+ * @returns True if the element matches the selector
422
+ *
423
+ * @example
424
+ * ```ts
425
+ * if ($('#el').is('.active')) {
426
+ * console.log('Element is active');
427
+ * }
428
+ * ```
429
+ */
430
+ is(e) {
431
+ return this.matches(e);
432
+ }
407
433
  /**
408
434
  * Checks if the element has a specific class.
409
435
  *
@@ -483,12 +509,12 @@ class a {
483
509
  const e = this.element;
484
510
  if (e.tagName.toLowerCase() !== "form")
485
511
  return {};
486
- const t = {}, n = new FormData(e);
487
- for (const [s, i] of n.entries())
512
+ const t = {}, r = new FormData(e);
513
+ for (const [s, i] of r.entries())
488
514
  if (typeof i == "string")
489
515
  if (s in t) {
490
- const l = t[s];
491
- Array.isArray(l) ? l.push(i) : t[s] = [l, i];
516
+ const o = t[s];
517
+ Array.isArray(o) ? o.push(i) : t[s] = [o, i];
492
518
  } else
493
519
  t[s] = i;
494
520
  return t;
@@ -508,10 +534,10 @@ class a {
508
534
  const e = this.element;
509
535
  if (e.tagName.toLowerCase() !== "form")
510
536
  return "";
511
- const t = new FormData(e), n = new URLSearchParams();
537
+ const t = new FormData(e), r = new URLSearchParams();
512
538
  for (const [s, i] of t.entries())
513
- typeof i == "string" && n.append(s, i);
514
- return n.toString();
539
+ typeof i == "string" && r.append(s, i);
540
+ return r.toString();
515
541
  }
516
542
  /**
517
543
  * Gets the bounding client rectangle of the element.
@@ -540,17 +566,10 @@ class a {
540
566
  * @internal
541
567
  */
542
568
  insertContent(e, t) {
543
- if (typeof e == "string") {
544
- this.element.insertAdjacentHTML(t, f(e));
545
- return;
546
- }
547
- const n = p(e);
548
- o(n, (s) => {
549
- this.element.insertAdjacentElement(t, s);
550
- });
569
+ b(this.element, e, t);
551
570
  }
552
571
  }
553
- class m {
572
+ class c {
554
573
  /**
555
574
  * Creates a new collection wrapper.
556
575
  * @param elements - Array of DOM elements to wrap
@@ -579,7 +598,7 @@ class m {
579
598
  */
580
599
  eq(e) {
581
600
  const t = this.elements[e];
582
- return t ? new a(t) : void 0;
601
+ return t ? new h(t) : void 0;
583
602
  }
584
603
  /**
585
604
  * Gets the first element as a BQueryElement wrapper.
@@ -604,8 +623,8 @@ class m {
604
623
  * @returns The instance for method chaining
605
624
  */
606
625
  each(e) {
607
- return this.elements.forEach((t, n) => {
608
- e(new a(t), n);
626
+ return this.elements.forEach((t, r) => {
627
+ e(new h(t), r);
609
628
  }), this;
610
629
  }
611
630
  /**
@@ -624,7 +643,7 @@ class m {
624
643
  * @returns New BQueryCollection with matching elements
625
644
  */
626
645
  filter(e) {
627
- return new m(this.elements.filter(e));
646
+ return new c(this.elements.filter(e));
628
647
  }
629
648
  /**
630
649
  * Reduces the collection to a single value.
@@ -642,19 +661,19 @@ class m {
642
661
  * @returns Array of BQueryElement instances
643
662
  */
644
663
  toArray() {
645
- return this.elements.map((e) => new a(e));
664
+ return this.elements.map((e) => new h(e));
646
665
  }
647
666
  /** Add one or more classes to all elements. */
648
667
  addClass(...e) {
649
- return o(this.elements, (t) => t.classList.add(...e)), this;
668
+ return l(this.elements, (t) => t.classList.add(...e)), this;
650
669
  }
651
670
  /** Remove one or more classes from all elements. */
652
671
  removeClass(...e) {
653
- return o(this.elements, (t) => t.classList.remove(...e)), this;
672
+ return l(this.elements, (t) => t.classList.remove(...e)), this;
654
673
  }
655
674
  /** Toggle a class on all elements. */
656
675
  toggleClass(e, t) {
657
- return o(this.elements, (n) => n.classList.toggle(e, t)), this;
676
+ return l(this.elements, (r) => r.classList.toggle(e, t)), this;
658
677
  }
659
678
  /**
660
679
  * Sets an attribute on all elements or gets from first.
@@ -664,7 +683,7 @@ class m {
664
683
  * @returns Attribute value when getting, instance when setting
665
684
  */
666
685
  attr(e, t) {
667
- return t === void 0 ? this.first()?.getAttribute(e) ?? "" : (o(this.elements, (n) => n.setAttribute(e, t)), this);
686
+ return t === void 0 ? this.first()?.getAttribute(e) ?? "" : (l(this.elements, (r) => r.setAttribute(e, t)), this);
668
687
  }
669
688
  /**
670
689
  * Removes an attribute from all elements.
@@ -673,7 +692,14 @@ class m {
673
692
  * @returns The instance for method chaining
674
693
  */
675
694
  removeAttr(e) {
676
- return o(this.elements, (t) => t.removeAttribute(e)), this;
695
+ return l(this.elements, (t) => t.removeAttribute(e)), this;
696
+ }
697
+ /** Toggle an attribute on all elements. */
698
+ toggleAttr(e, t) {
699
+ return l(this.elements, (r) => {
700
+ const s = r.hasAttribute(e);
701
+ t ?? !s ? r.setAttribute(e, "") : r.removeAttribute(e);
702
+ }), this;
677
703
  }
678
704
  /**
679
705
  * Sets text content on all elements or gets from first.
@@ -682,7 +708,7 @@ class m {
682
708
  * @returns Text content when getting, instance when setting
683
709
  */
684
710
  text(e) {
685
- return e === void 0 ? this.first()?.textContent ?? "" : (o(this.elements, (t) => {
711
+ return e === void 0 ? this.first()?.textContent ?? "" : (l(this.elements, (t) => {
686
712
  t.textContent = e;
687
713
  }), this);
688
714
  }
@@ -695,9 +721,9 @@ class m {
695
721
  html(e) {
696
722
  if (e === void 0)
697
723
  return this.first()?.innerHTML ?? "";
698
- const t = f(e);
699
- return o(this.elements, (n) => {
700
- n.innerHTML = t;
724
+ const t = p(e);
725
+ return l(this.elements, (r) => {
726
+ r.innerHTML = t;
701
727
  }), this;
702
728
  }
703
729
  /**
@@ -708,24 +734,88 @@ class m {
708
734
  * @warning Bypasses XSS protection
709
735
  */
710
736
  htmlUnsafe(e) {
711
- return o(this.elements, (t) => {
737
+ return l(this.elements, (t) => {
712
738
  t.innerHTML = e;
713
739
  }), this;
714
740
  }
741
+ /** Append content to all elements. */
742
+ append(e) {
743
+ return this.insertAll(e, "beforeend"), this;
744
+ }
745
+ /** Prepend content to all elements. */
746
+ prepend(e) {
747
+ return this.insertAll(e, "afterbegin"), this;
748
+ }
749
+ /** Insert content before all elements. */
750
+ before(e) {
751
+ return this.insertAll(e, "beforebegin"), this;
752
+ }
753
+ /** Insert content after all elements. */
754
+ after(e) {
755
+ return this.insertAll(e, "afterend"), this;
756
+ }
757
+ css(e, t) {
758
+ if (typeof e == "string") {
759
+ if (t !== void 0)
760
+ return l(this.elements, (i) => {
761
+ i.style.setProperty(e, t);
762
+ }), this;
763
+ const r = this.first();
764
+ if (!r)
765
+ return "";
766
+ const s = r.ownerDocument?.defaultView;
767
+ return !s || typeof s.getComputedStyle != "function" ? "" : s.getComputedStyle(r).getPropertyValue(e);
768
+ }
769
+ return l(this.elements, (r) => {
770
+ for (const [s, i] of Object.entries(e))
771
+ r.style.setProperty(s, i);
772
+ }), this;
773
+ }
774
+ /** Wrap each element with a wrapper element or tag. */
775
+ wrap(e) {
776
+ return this.elements.forEach((t, r) => {
777
+ const s = typeof e == "string" ? document.createElement(e) : r === 0 ? e : e.cloneNode(!0);
778
+ t.parentNode?.insertBefore(s, t), s.appendChild(t);
779
+ }), this;
780
+ }
715
781
  /**
716
- * Applies CSS styles to all elements.
782
+ * Remove the parent element of each element, keeping the elements in place.
717
783
  *
718
- * @param property - Property name or object of properties
719
- * @param value - Value when setting single property
720
- * @returns The instance for method chaining
784
+ * **Important**: This method unwraps ALL children of each parent element,
785
+ * not just the elements in the collection. If you call `unwrap()` on a
786
+ * collection containing only some children of a parent, all siblings will
787
+ * also be unwrapped. This behavior is consistent with jQuery's `.unwrap()`.
788
+ *
789
+ * @returns The collection for chaining
790
+ *
791
+ * @example
792
+ * ```ts
793
+ * // HTML: <div><section><span>A</span><span>B</span></section></div>
794
+ * const spans = $$('span');
795
+ * spans.unwrap(); // Removes <section>, both spans move to <div>
796
+ * // Result: <div><span>A</span><span>B</span></div>
797
+ * ```
721
798
  */
722
- css(e, t) {
723
- return typeof e == "string" ? (t !== void 0 && o(this.elements, (n) => {
724
- n.style.setProperty(e, t);
725
- }), this) : (o(this.elements, (n) => {
726
- for (const [s, i] of Object.entries(e))
727
- n.style.setProperty(s, i);
728
- }), this);
799
+ unwrap() {
800
+ const e = /* @__PURE__ */ new Set();
801
+ for (const t of this.elements)
802
+ t.parentElement && e.add(t.parentElement);
803
+ return e.forEach((t) => {
804
+ const r = t.parentNode;
805
+ if (r) {
806
+ for (; t.firstChild; )
807
+ r.insertBefore(t.firstChild, t);
808
+ t.remove();
809
+ }
810
+ }), this;
811
+ }
812
+ /** Replace each element with provided content. */
813
+ replaceWith(e) {
814
+ const t = [];
815
+ return this.elements.forEach((r, s) => {
816
+ const i = typeof e == "string" ? y(e) : s === 0 ? e : e.cloneNode(!0);
817
+ r.replaceWith(i), t.push(i);
818
+ }), new c(t);
729
819
  }
730
820
  /**
731
821
  * Shows all elements.
@@ -734,7 +824,7 @@ class m {
734
824
  * @returns The instance for method chaining
735
825
  */
736
826
  show(e = "") {
737
- return o(this.elements, (t) => {
827
+ return l(this.elements, (t) => {
738
828
  t.removeAttribute("hidden"), t.style.display = e;
739
829
  }), this;
740
830
  }
@@ -744,7 +834,7 @@ class m {
744
834
  * @returns The instance for method chaining
745
835
  */
746
836
  hide() {
747
- return o(this.elements, (e) => {
837
+ return l(this.elements, (e) => {
748
838
  e.style.display = "none";
749
839
  }), this;
750
840
  }
@@ -756,7 +846,7 @@ class m {
756
846
  * @returns The instance for method chaining
757
847
  */
758
848
  on(e, t) {
759
- return o(this.elements, (n) => n.addEventListener(e, t)), this;
849
+ return l(this.elements, (r) => r.addEventListener(e, t)), this;
760
850
  }
761
851
  /**
762
852
  * Adds a one-time event listener to all elements.
@@ -766,7 +856,7 @@ class m {
766
856
  * @returns The instance for method chaining
767
857
  */
768
858
  once(e, t) {
769
- return o(this.elements, (n) => n.addEventListener(e, t, { once: !0 })), this;
859
+ return l(this.elements, (r) => r.addEventListener(e, t, { once: !0 })), this;
770
860
  }
771
861
  /**
772
862
  * Removes an event listener from all elements.
@@ -776,7 +866,7 @@ class m {
776
866
  * @returns The instance for method chaining
777
867
  */
778
868
  off(e, t) {
779
- return o(this.elements, (n) => n.removeEventListener(e, t)), this;
869
+ return l(this.elements, (r) => r.removeEventListener(e, t)), this;
780
870
  }
781
871
  /**
782
872
  * Triggers a custom event on all elements.
@@ -786,8 +876,8 @@ class m {
786
876
  * @returns The instance for method chaining
787
877
  */
788
878
  trigger(e, t) {
789
- return o(this.elements, (n) => {
790
- n.dispatchEvent(new CustomEvent(e, { detail: t, bubbles: !0, cancelable: !0 }));
879
+ return l(this.elements, (r) => {
880
+ r.dispatchEvent(new CustomEvent(e, { detail: t, bubbles: !0, cancelable: !0 }));
791
881
  }), this;
792
882
  }
793
883
  /**
@@ -810,16 +900,16 @@ class m {
810
900
  * $$('.container').undelegate('click', '.item', handler);
811
901
  * ```
812
902
  */
813
- delegate(e, t, n) {
903
+ delegate(e, t, r) {
814
904
  const s = `${e}:${t}`;
815
- return o(this.elements, (i) => {
816
- const l = (u) => {
817
- const d = u.target.closest(t);
818
- d && i.contains(d) && n(u, d);
905
+ return l(this.elements, (i) => {
906
+ const o = (a) => {
907
+ const m = a.target.closest(t);
908
+ m && i.contains(m) && r(a, m);
819
909
  };
820
910
  this.delegatedHandlers.has(i) || this.delegatedHandlers.set(i, /* @__PURE__ */ new Map());
821
- const h = this.delegatedHandlers.get(i);
822
- h.has(s) || h.set(s, /* @__PURE__ */ new Map()), h.get(s).set(n, l), i.addEventListener(e, l);
911
+ const u = this.delegatedHandlers.get(i);
912
+ u.has(s) || u.set(s, /* @__PURE__ */ new Map()), u.get(s).set(r, o), i.addEventListener(e, o);
823
913
  }), this;
824
914
  }
825
915
  /**
@@ -839,24 +929,45 @@ class m {
839
929
  * $$('.container').undelegate('click', '.item', handler);
840
930
  * ```
841
931
  */
842
- undelegate(e, t, n) {
932
+ undelegate(e, t, r) {
843
933
  const s = `${e}:${t}`;
844
- return o(this.elements, (i) => {
845
- const l = this.delegatedHandlers.get(i);
846
- if (!l) return;
847
- const h = l.get(s);
848
- if (!h) return;
849
- const u = h.get(n);
850
- u && (i.removeEventListener(e, u), h.delete(n), h.size === 0 && l.delete(s), l.size === 0 && this.delegatedHandlers.delete(i));
934
+ return l(this.elements, (i) => {
935
+ const o = this.delegatedHandlers.get(i);
936
+ if (!o) return;
937
+ const u = o.get(s);
938
+ if (!u) return;
939
+ const a = u.get(r);
940
+ a && (i.removeEventListener(e, a), u.delete(r), u.size === 0 && o.delete(s), o.size === 0 && this.delegatedHandlers.delete(i));
851
941
  }), this;
852
942
  }
943
+ /**
944
+ * Finds all descendant elements matching the selector across all elements
945
+ * in the collection. Returns a new BQueryCollection with the results.
946
+ *
947
+ * @param selector - CSS selector to match
948
+ * @returns A new BQueryCollection with all matching descendants
949
+ *
950
+ * @example
951
+ * ```ts
952
+ * $$('.container').find('.item').addClass('highlight');
953
+ * ```
954
+ */
955
+ find(e) {
956
+ const t = /* @__PURE__ */ new Set(), r = [];
957
+ for (const s of this.elements) {
958
+ const i = s.querySelectorAll(e);
959
+ for (let o = 0; o < i.length; o++)
960
+ t.has(i[o]) || (t.add(i[o]), r.push(i[o]));
961
+ }
962
+ return new c(r);
963
+ }
853
964
  /**
854
965
  * Removes all elements from the DOM.
855
966
  *
856
967
  * @returns The instance for method chaining
857
968
  */
858
969
  remove() {
859
- return o(this.elements, (e) => e.remove()), this;
970
+ return l(this.elements, (e) => e.remove()), this;
860
971
  }
861
972
  /**
862
973
  * Clears all child nodes from all elements.
@@ -864,395 +975,290 @@ class m {
864
975
  * @returns The instance for method chaining
865
976
  */
866
977
  empty() {
867
- return o(this.elements, (e) => {
978
+ return l(this.elements, (e) => {
868
979
  e.innerHTML = "";
869
980
  }), this;
870
981
  }
982
+ /** @internal */
983
+ insertAll(e, t) {
984
+ if (typeof e == "string") {
985
+ const s = p(e);
986
+ l(this.elements, (i) => {
987
+ i.insertAdjacentHTML(t, s);
988
+ });
989
+ return;
990
+ }
991
+ const r = g(e);
992
+ this.elements.forEach((s, i) => {
993
+ const o = i === 0 ? r : r.map((u) => u.cloneNode(!0));
994
+ b(s, o, t);
995
+ });
996
+ }
871
997
  }
872
- const y = (r) => {
873
- if (typeof r != "string")
874
- return new a(r);
875
- const e = document.querySelector(r);
998
+ const oe = (n) => {
999
+ if (typeof n != "string")
1000
+ return new h(n);
1001
+ const e = document.querySelector(n);
876
1002
  if (!e)
877
- throw new Error(`bQuery: element not found for selector "${r}"`);
878
- return new a(e);
879
- }, b = (r) => Array.isArray(r) ? new m(r) : r instanceof NodeList ? new m(Array.from(r)) : new m(Array.from(document.querySelectorAll(r))), c = {
880
- /**
881
- * Creates a deep clone using structuredClone if available, otherwise fallback to JSON.
882
- *
883
- * @template T - The type of value being cloned
884
- * @param value - The value to clone
885
- * @returns A deep copy of the value
886
- *
887
- * @example
888
- * ```ts
889
- * const original = { nested: { value: 1 } };
890
- * const copy = utils.clone(original);
891
- * copy.nested.value = 2;
892
- * console.log(original.nested.value); // 1
893
- * ```
894
- */
895
- clone(r) {
896
- return typeof structuredClone == "function" ? structuredClone(r) : JSON.parse(JSON.stringify(r));
897
- },
898
- /**
899
- * Deep-merges plain objects into a new object.
900
- * Later sources override earlier ones for primitive values.
901
- * Objects are recursively merged.
902
- *
903
- * @template T - The type of the merged object
904
- * @param sources - Objects to merge
905
- * @returns A new object with all sources merged
906
- *
907
- * @example
908
- * ```ts
909
- * const result = utils.merge(
910
- * { a: 1, nested: { x: 1 } },
911
- * { b: 2, nested: { y: 2 } }
912
- * );
913
- * // Result: { a: 1, b: 2, nested: { x: 1, y: 2 } }
914
- * ```
915
- *
916
- * @security This method is protected against prototype pollution attacks.
917
- * Keys like `__proto__`, `constructor`, and `prototype` are ignored.
918
- */
919
- merge(...r) {
920
- const e = {};
921
- for (const t of r)
922
- for (const [n, s] of Object.entries(t))
923
- c.isPrototypePollutionKey(n) || (c.isPlainObject(s) && c.isPlainObject(e[n]) ? e[n] = c.merge(
924
- e[n],
925
- s
926
- ) : e[n] = s);
927
- return e;
928
- },
929
- /**
930
- * Checks if a key could cause prototype pollution.
931
- * These keys are dangerous when used in object merging operations.
932
- *
933
- * @param key - The key to check
934
- * @returns True if the key is a prototype pollution vector
935
- *
936
- * @internal
937
- */
938
- isPrototypePollutionKey(r) {
939
- return r === "__proto__" || r === "constructor" || r === "prototype";
940
- },
941
- /**
942
- * Creates a debounced function that delays execution until after
943
- * the specified delay has elapsed since the last call.
944
- *
945
- * @template TArgs - The argument types of the function
946
- * @param fn - The function to debounce
947
- * @param delayMs - Delay in milliseconds
948
- * @returns A debounced version of the function
949
- *
950
- * @example
951
- * ```ts
952
- * const search = utils.debounce((query: string) => {
953
- * console.log('Searching:', query);
954
- * }, 300);
955
- *
956
- * search('h');
957
- * search('he');
958
- * search('hello'); // Only this call executes after 300ms
959
- * ```
960
- */
961
- debounce(r, e) {
962
- let t;
963
- return (...n) => {
964
- t && clearTimeout(t), t = setTimeout(() => r(...n), e);
965
- };
966
- },
967
- /**
968
- * Creates a throttled function that runs at most once per interval.
969
- *
970
- * @template TArgs - The argument types of the function
971
- * @param fn - The function to throttle
972
- * @param intervalMs - Minimum interval between calls in milliseconds
973
- * @returns A throttled version of the function
974
- *
975
- * @example
976
- * ```ts
977
- * const handleScroll = utils.throttle(() => {
978
- * console.log('Scroll position:', window.scrollY);
979
- * }, 100);
980
- *
981
- * window.addEventListener('scroll', handleScroll);
982
- * ```
983
- */
984
- throttle(r, e) {
985
- let t = 0;
986
- return (...n) => {
987
- const s = Date.now();
988
- s - t >= e && (t = s, r(...n));
989
- };
990
- },
991
- /**
992
- * Creates a stable unique ID for DOM usage.
993
- *
994
- * @param prefix - Optional prefix for the ID (default: 'bQuery')
995
- * @returns A unique identifier string
996
- *
997
- * @example
998
- * ```ts
999
- * const id = utils.uid('modal'); // 'modal_x7k2m9p'
1000
- * ```
1001
- */
1002
- uid(r = "bQuery") {
1003
- return `${r}_${Math.random().toString(36).slice(2, 9)}`;
1004
- },
1005
- /**
1006
- * Checks if a value is a DOM Element.
1007
- *
1008
- * @param value - The value to check
1009
- * @returns True if the value is an Element
1010
- */
1011
- isElement(r) {
1012
- return r instanceof Element;
1013
- },
1014
- /**
1015
- * Checks if a value is a BQueryCollection-like object.
1016
- *
1017
- * @param value - The value to check
1018
- * @returns True if the value has an elements array property
1019
- */
1020
- isCollection(r) {
1021
- return !!(r && typeof r == "object" && "elements" in r);
1022
- },
1023
- /**
1024
- * Checks for emptiness across common value types.
1025
- *
1026
- * @param value - The value to check
1027
- * @returns True if the value is empty (null, undefined, empty string, empty array, or empty object)
1028
- *
1029
- * @example
1030
- * ```ts
1031
- * utils.isEmpty(''); // true
1032
- * utils.isEmpty([]); // true
1033
- * utils.isEmpty({}); // true
1034
- * utils.isEmpty(null); // true
1035
- * utils.isEmpty('hello'); // false
1036
- * utils.isEmpty([1, 2]); // false
1037
- * ```
1038
- */
1039
- isEmpty(r) {
1040
- return r == null ? !0 : typeof r == "string" ? r.trim().length === 0 : Array.isArray(r) ? r.length === 0 : typeof r == "object" ? Object.keys(r).length === 0 : !1;
1041
- },
1042
- /**
1043
- * Checks if a value is a plain object (not null, array, or class instance).
1044
- *
1045
- * @param value - The value to check
1046
- * @returns True if the value is a plain object
1047
- */
1048
- isPlainObject(r) {
1049
- return Object.prototype.toString.call(r) === "[object Object]";
1050
- },
1051
- /**
1052
- * Checks if a value is a function.
1053
- *
1054
- * @param value - The value to check
1055
- * @returns True if the value is a function
1056
- */
1057
- isFunction(r) {
1058
- return typeof r == "function";
1059
- },
1060
- /**
1061
- * Checks if a value is a string.
1062
- *
1063
- * @param value - The value to check
1064
- * @returns True if the value is a string
1065
- */
1066
- isString(r) {
1067
- return typeof r == "string";
1068
- },
1069
- /**
1070
- * Checks if a value is a number (excluding NaN).
1071
- *
1072
- * @param value - The value to check
1073
- * @returns True if the value is a valid number
1074
- */
1075
- isNumber(r) {
1076
- return typeof r == "number" && !Number.isNaN(r);
1077
- },
1078
- /**
1079
- * Checks if a value is a boolean.
1080
- *
1081
- * @param value - The value to check
1082
- * @returns True if the value is a boolean
1083
- */
1084
- isBoolean(r) {
1085
- return typeof r == "boolean";
1086
- },
1087
- /**
1088
- * Checks if a value is an array.
1089
- *
1090
- * @template T - The type of array elements
1091
- * @param value - The value to check
1092
- * @returns True if the value is an array
1093
- */
1094
- isArray(r) {
1095
- return Array.isArray(r);
1096
- },
1097
- /**
1098
- * Safely parses a JSON string, returning a default value on error.
1099
- *
1100
- * @template T - The expected type of the parsed value
1101
- * @param json - The JSON string to parse
1102
- * @param fallback - The default value if parsing fails
1103
- * @returns The parsed value or the fallback
1104
- *
1105
- * @example
1106
- * ```ts
1107
- * utils.parseJson('{"name":"bQuery"}', {}); // { name: 'bQuery' }
1108
- * utils.parseJson('invalid', {}); // {}
1109
- * ```
1110
- */
1111
- parseJson(r, e) {
1112
- try {
1113
- return JSON.parse(r);
1114
- } catch {
1115
- return e;
1003
+ throw new Error(`bQuery: element not found for selector "${n}"`);
1004
+ return new h(e);
1005
+ }, le = (n) => Array.isArray(n) ? new c(n) : n instanceof NodeList ? new c(Array.from(n)) : new c(Array.from(document.querySelectorAll(n)));
1006
+ function E(n) {
1007
+ return n == null ? [] : Array.isArray(n) ? n : [n];
1008
+ }
1009
+ function C(n) {
1010
+ return Array.from(new Set(n));
1011
+ }
1012
+ function L(n, e) {
1013
+ if (e <= 0) return [];
1014
+ const t = [];
1015
+ for (let r = 0; r < n.length; r += e)
1016
+ t.push(n.slice(r, r + e));
1017
+ return t;
1018
+ }
1019
+ function v(n) {
1020
+ return n.filter(Boolean);
1021
+ }
1022
+ function H(n) {
1023
+ const e = [];
1024
+ for (const t of n)
1025
+ Array.isArray(t) ? e.push(...t) : e.push(t);
1026
+ return e;
1027
+ }
1028
+ function N(n, e) {
1029
+ let t;
1030
+ return Object.assign(
1031
+ (...s) => {
1032
+ t !== void 0 && clearTimeout(t), t = setTimeout(() => {
1033
+ t = void 0, n(...s);
1034
+ }, e);
1035
+ },
1036
+ {
1037
+ cancel: () => {
1038
+ t !== void 0 && (clearTimeout(t), t = void 0);
1039
+ }
1116
1040
  }
1117
- },
1118
- /**
1119
- * Picks specified keys from an object.
1120
- *
1121
- * @template T - The object type
1122
- * @template K - The key type
1123
- * @param obj - The source object
1124
- * @param keys - Keys to pick
1125
- * @returns A new object with only the specified keys
1126
- *
1127
- * @example
1128
- * ```ts
1129
- * const user = { name: 'John', age: 30, email: 'john@example.com' };
1130
- * utils.pick(user, ['name', 'email']); // { name: 'John', email: 'john@example.com' }
1131
- * ```
1132
- */
1133
- pick(r, e) {
1134
- const t = {};
1135
- for (const n of e)
1136
- n in r && (t[n] = r[n]);
1137
- return t;
1138
- },
1139
- /**
1140
- * Omits specified keys from an object.
1141
- *
1142
- * @template T - The object type
1143
- * @template K - The key type
1144
- * @param obj - The source object
1145
- * @param keys - Keys to omit
1146
- * @returns A new object without the specified keys
1147
- *
1148
- * @example
1149
- * ```ts
1150
- * const user = { name: 'John', age: 30, password: 'secret' };
1151
- * utils.omit(user, ['password']); // { name: 'John', age: 30 }
1152
- * ```
1153
- */
1154
- omit(r, e) {
1155
- const t = { ...r };
1156
- for (const n of e)
1157
- delete t[n];
1158
- return t;
1159
- },
1160
- /**
1161
- * Delays execution for a specified number of milliseconds.
1162
- *
1163
- * @param ms - Milliseconds to delay
1164
- * @returns A promise that resolves after the delay
1165
- *
1166
- * @example
1167
- * ```ts
1168
- * await utils.sleep(1000); // Wait 1 second
1169
- * console.log('Done!');
1170
- * ```
1171
- */
1172
- sleep(r) {
1173
- return new Promise((e) => setTimeout(e, r));
1174
- },
1175
- /**
1176
- * Generates a random integer between min and max (inclusive).
1177
- *
1178
- * @param min - Minimum value
1179
- * @param max - Maximum value
1180
- * @returns A random integer in the range [min, max]
1181
- *
1182
- * @example
1183
- * ```ts
1184
- * const roll = utils.randomInt(1, 6); // Random dice roll
1185
- * ```
1186
- */
1187
- randomInt(r, e) {
1188
- return Math.floor(Math.random() * (e - r + 1)) + r;
1189
- },
1190
- /**
1191
- * Clamps a number between a minimum and maximum value.
1192
- *
1193
- * @param value - The value to clamp
1194
- * @param min - Minimum value
1195
- * @param max - Maximum value
1196
- * @returns The clamped value
1197
- *
1198
- * @example
1199
- * ```ts
1200
- * utils.clamp(150, 0, 100); // 100
1201
- * utils.clamp(-10, 0, 100); // 0
1202
- * utils.clamp(50, 0, 100); // 50
1203
- * ```
1204
- */
1205
- clamp(r, e, t) {
1206
- return Math.min(Math.max(r, e), t);
1207
- },
1208
- /**
1209
- * Capitalizes the first letter of a string.
1210
- *
1211
- * @param str - The string to capitalize
1212
- * @returns The capitalized string
1213
- *
1214
- * @example
1215
- * ```ts
1216
- * utils.capitalize('hello'); // 'Hello'
1217
- * ```
1218
- */
1219
- capitalize(r) {
1220
- return r && r.charAt(0).toUpperCase() + r.slice(1);
1221
- },
1222
- /**
1223
- * Converts a string to kebab-case.
1224
- *
1225
- * @param str - The string to convert
1226
- * @returns The kebab-cased string
1227
- *
1228
- * @example
1229
- * ```ts
1230
- * utils.toKebabCase('myVariableName'); // 'my-variable-name'
1231
- * ```
1232
- */
1233
- toKebabCase(r) {
1234
- return r.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
1235
- },
1236
- /**
1237
- * Converts a string to camelCase.
1238
- *
1239
- * @param str - The string to convert
1240
- * @returns The camelCased string
1241
- *
1242
- * @example
1243
- * ```ts
1244
- * utils.toCamelCase('my-variable-name'); // 'myVariableName'
1245
- * ```
1246
- */
1247
- toCamelCase(r) {
1248
- return r.replace(/[-_\s]+(.)?/g, (e, t) => t ? t.toUpperCase() : "").replace(/^[A-Z]/, (e) => e.toLowerCase());
1041
+ );
1042
+ }
1043
+ function S(n, e) {
1044
+ let t = 0;
1045
+ return Object.assign(
1046
+ (...s) => {
1047
+ const i = Date.now();
1048
+ i - t >= e && (t = i, n(...s));
1049
+ },
1050
+ {
1051
+ cancel: () => {
1052
+ t = 0;
1053
+ }
1054
+ }
1055
+ );
1056
+ }
1057
+ function $(n) {
1058
+ let e = !1, t;
1059
+ return (...r) => (e || (t = n(...r), e = !0), t);
1060
+ }
1061
+ function M() {
1062
+ }
1063
+ function j(n = "bQuery") {
1064
+ return `${n}_${Math.random().toString(36).slice(2, 9)}`;
1065
+ }
1066
+ function O(n) {
1067
+ return new Promise((e) => setTimeout(e, n));
1068
+ }
1069
+ function T(n, e) {
1070
+ try {
1071
+ return JSON.parse(n);
1072
+ } catch {
1073
+ return e;
1249
1074
  }
1075
+ }
1076
+ function P(n) {
1077
+ return n == null ? !0 : typeof n == "string" ? n.trim().length === 0 : Array.isArray(n) ? n.length === 0 : typeof n == "object" ? Object.keys(n).length === 0 : !1;
1078
+ }
1079
+ function k(n, e) {
1080
+ return Math.floor(Math.random() * (e - n + 1)) + n;
1081
+ }
1082
+ function z(n, e, t) {
1083
+ return Math.min(Math.max(n, e), t);
1084
+ }
1085
+ function D(n, e, t, r = !0) {
1086
+ return r ? n >= e && n <= t : n > e && n < t;
1087
+ }
1088
+ function q(n, e = 0) {
1089
+ const t = typeof n == "number" ? n : Number(n);
1090
+ return Number.isNaN(t) ? e : t;
1091
+ }
1092
+ function d(n) {
1093
+ return Object.prototype.toString.call(n) === "[object Object]";
1094
+ }
1095
+ function x(n) {
1096
+ return n === "__proto__" || n === "constructor" || n === "prototype";
1097
+ }
1098
+ function R(n) {
1099
+ return typeof structuredClone == "function" ? structuredClone(n) : JSON.parse(JSON.stringify(n));
1100
+ }
1101
+ function A(...n) {
1102
+ const e = {};
1103
+ for (const t of n)
1104
+ for (const [r, s] of Object.entries(t))
1105
+ x(r) || (d(s) && d(e[r]) ? e[r] = A(
1106
+ e[r],
1107
+ s
1108
+ ) : e[r] = s);
1109
+ return e;
1110
+ }
1111
+ function B(n, e) {
1112
+ const t = {};
1113
+ for (const r of e)
1114
+ r in n && (t[r] = n[r]);
1115
+ return t;
1116
+ }
1117
+ function W(n, e) {
1118
+ const t = { ...n };
1119
+ for (const r of e)
1120
+ delete t[r];
1121
+ return t;
1122
+ }
1123
+ function F(n, e) {
1124
+ return Object.prototype.hasOwnProperty.call(n, e);
1125
+ }
1126
+ function U(n) {
1127
+ return n && n.charAt(0).toUpperCase() + n.slice(1);
1128
+ }
1129
+ function J(n) {
1130
+ return n.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
1131
+ }
1132
+ function V(n) {
1133
+ return n.replace(/[-_\s]+(.)?/g, (e, t) => t ? t.toUpperCase() : "").replace(/^[A-Z]/, (e) => e.toLowerCase());
1134
+ }
1135
+ function _(n, e, t = "…") {
1136
+ if (e <= 0) return "";
1137
+ if (n.length <= e) return n;
1138
+ const r = Math.max(0, e - t.length);
1139
+ return `${n.slice(0, r)}${t}`;
1140
+ }
1141
+ function I(n) {
1142
+ return n.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\w\s-]/g, "").trim().replace(/[\s_-]+/g, "-").toLowerCase();
1143
+ }
1144
+ function Z(n) {
1145
+ return n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1146
+ }
1147
+ function K(n) {
1148
+ return typeof Element < "u" && n instanceof Element;
1149
+ }
1150
+ function G(n) {
1151
+ return !!(n && typeof n == "object" && "elements" in n);
1152
+ }
1153
+ function X(n) {
1154
+ return typeof n == "function";
1155
+ }
1156
+ function Y(n) {
1157
+ return typeof n == "string";
1158
+ }
1159
+ function Q(n) {
1160
+ return typeof n == "number" && !Number.isNaN(n);
1161
+ }
1162
+ function ee(n) {
1163
+ return typeof n == "boolean";
1164
+ }
1165
+ function te(n) {
1166
+ return Array.isArray(n);
1167
+ }
1168
+ function ne(n) {
1169
+ return n instanceof Date;
1170
+ }
1171
+ function re(n) {
1172
+ return !!(n && (n instanceof Promise || typeof n == "object" && "then" in n && typeof n.then == "function"));
1173
+ }
1174
+ function se(n) {
1175
+ return typeof n == "object" && n !== null;
1176
+ }
1177
+ const ue = {
1178
+ clone: R,
1179
+ merge: A,
1180
+ pick: B,
1181
+ omit: W,
1182
+ hasOwn: F,
1183
+ debounce: N,
1184
+ throttle: S,
1185
+ once: $,
1186
+ noop: M,
1187
+ uid: j,
1188
+ isElement: K,
1189
+ isCollection: G,
1190
+ isEmpty: P,
1191
+ isPlainObject: d,
1192
+ isFunction: X,
1193
+ isString: Y,
1194
+ isNumber: Q,
1195
+ isBoolean: ee,
1196
+ isArray: te,
1197
+ isDate: ne,
1198
+ isPromise: re,
1199
+ isObject: se,
1200
+ parseJson: T,
1201
+ sleep: O,
1202
+ randomInt: k,
1203
+ clamp: z,
1204
+ inRange: D,
1205
+ toNumber: q,
1206
+ capitalize: U,
1207
+ toKebabCase: J,
1208
+ toCamelCase: V,
1209
+ truncate: _,
1210
+ slugify: I,
1211
+ escapeRegExp: Z,
1212
+ ensureArray: E,
1213
+ unique: C,
1214
+ chunk: L,
1215
+ compact: v,
1216
+ flatten: H
1250
1217
  };
1251
1218
  export {
1252
- y as $,
1253
- b as $$,
1254
- m as BQueryCollection,
1255
- a as BQueryElement,
1256
- c as utils
1219
+ oe as $,
1220
+ le as $$,
1221
+ c as BQueryCollection,
1222
+ h as BQueryElement,
1223
+ U as capitalize,
1224
+ L as chunk,
1225
+ z as clamp,
1226
+ R as clone,
1227
+ v as compact,
1228
+ N as debounce,
1229
+ E as ensureArray,
1230
+ Z as escapeRegExp,
1231
+ H as flatten,
1232
+ F as hasOwn,
1233
+ D as inRange,
1234
+ te as isArray,
1235
+ ee as isBoolean,
1236
+ G as isCollection,
1237
+ ne as isDate,
1238
+ K as isElement,
1239
+ P as isEmpty,
1240
+ X as isFunction,
1241
+ Q as isNumber,
1242
+ se as isObject,
1243
+ d as isPlainObject,
1244
+ re as isPromise,
1245
+ Y as isString,
1246
+ A as merge,
1247
+ M as noop,
1248
+ W as omit,
1249
+ $ as once,
1250
+ T as parseJson,
1251
+ B as pick,
1252
+ k as randomInt,
1253
+ O as sleep,
1254
+ I as slugify,
1255
+ S as throttle,
1256
+ V as toCamelCase,
1257
+ J as toKebabCase,
1258
+ q as toNumber,
1259
+ _ as truncate,
1260
+ j as uid,
1261
+ C as unique,
1262
+ ue as utils
1257
1263
  };
1258
1264
  //# sourceMappingURL=core.es.mjs.map