@bquery/bquery 1.1.1 → 1.2.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.
package/README.md CHANGED
@@ -90,18 +90,24 @@ import { component, html } from '@bquery/bquery/component';
90
90
  import { transition, spring } from '@bquery/bquery/motion';
91
91
  import { sanitize } from '@bquery/bquery/security';
92
92
  import { storage, cache } from '@bquery/bquery/platform';
93
+ import { createRouter, navigate } from '@bquery/bquery/router';
94
+ import { createStore } from '@bquery/bquery/store';
95
+ import { mount } from '@bquery/bquery/view';
93
96
  ```
94
97
 
95
98
  ## Modules at a glance
96
99
 
97
100
  | Module | Description | Size (gzip) |
98
101
  | ------------- | ---------------------------------------------- | ----------- |
99
- | **Core** | Selectors, DOM manipulation, events, utilities | ~6 KB |
100
- | **Reactive** | `signal`, `computed`, `effect`, `batch` | ~1 KB |
101
- | **Component** | Lightweight Web Components with props | ~1.3 KB |
102
+ | **Core** | Selectors, DOM manipulation, events, utilities | ~7.7 KB |
103
+ | **Reactive** | `signal`, `computed`, `effect`, `batch` | ~1.2 KB |
104
+ | **Component** | Lightweight Web Components with props | ~1.5 KB |
102
105
  | **Motion** | View transitions, FLIP animations, springs | ~1.2 KB |
103
- | **Security** | HTML sanitizing, Trusted Types, CSP | ~1.6 KB |
104
- | **Platform** | Storage, cache, notifications, buckets | ~1.7 KB |
106
+ | **Security** | HTML sanitizing, Trusted Types, CSP | ~2.2 KB |
107
+ | **Platform** | Storage, cache, notifications, buckets | ~1.6 KB |
108
+ | **Router** | SPA routing, navigation guards, history API | ~2 KB |
109
+ | **Store** | Signal-based state management, persistence | ~1.5 KB |
110
+ | **View** | Declarative DOM bindings, directives | ~2.6 KB |
105
111
 
106
112
  ## Quick examples
107
113
 
@@ -227,6 +233,9 @@ const safe = sanitize('<form id="cookie">...</form>'); // id stripped
227
233
  // Unicode bypass protection in URLs
228
234
  const urlSafe = sanitize('<a href="java\u200Bscript:alert(1)">click</a>');
229
235
 
236
+ // Automatic link security (adds rel="noopener noreferrer" to external/target="_blank" links)
237
+ const secureLink = sanitize('<a href="https://external.com" target="_blank">Link</a>');
238
+
230
239
  // Escape for text display
231
240
  const escaped = escapeHtml('<script>alert(1)</script>');
232
241
  ```
@@ -250,6 +259,98 @@ if (permission === 'granted') {
250
259
  }
251
260
  ```
252
261
 
262
+ ### Router – SPA navigation
263
+
264
+ ```ts
265
+ import { createRouter, navigate, currentRoute } from '@bquery/bquery/router';
266
+
267
+ // Create router with routes
268
+ const router = createRouter({
269
+ routes: [
270
+ { path: '/', name: 'home', component: HomePage },
271
+ { path: '/user/:id', name: 'user', component: UserPage },
272
+ { path: '*', component: NotFound },
273
+ ],
274
+ });
275
+
276
+ // Navigation guards
277
+ router.beforeEach(async (to, from) => {
278
+ if (to.path === '/admin' && !isAuthenticated()) {
279
+ await navigate('/login'); // Redirect
280
+ return false; // Cancel original navigation
281
+ }
282
+ });
283
+
284
+ // Navigate programmatically
285
+ await navigate('/user/42');
286
+ await navigate('/search?q=bquery'); // Query params in path
287
+ await navigate('/login', { replace: true }); // Replace history entry
288
+
289
+ // Reactive current route
290
+ effect(() => {
291
+ console.log('Current path:', currentRoute.value.path);
292
+ });
293
+ ```
294
+
295
+ ### Store – state management
296
+
297
+ ```ts
298
+ import { createStore, createPersistedStore } from '@bquery/bquery/store';
299
+
300
+ // Define a store
301
+ const useCounter = createStore({
302
+ id: 'counter',
303
+ state: () => ({ count: 0, name: 'Counter' }),
304
+ getters: {
305
+ doubled: (state) => state.count * 2,
306
+ },
307
+ actions: {
308
+ increment() {
309
+ this.count++;
310
+ },
311
+ async fetchCount() {
312
+ this.count = await api.getCount();
313
+ },
314
+ },
315
+ });
316
+
317
+ // Use the store
318
+ const counter = useCounter;
319
+ counter.increment();
320
+ console.log(counter.doubled); // Reactive getter
321
+
322
+ // Persisted store (localStorage)
323
+ const useSettings = createPersistedStore({
324
+ id: 'settings',
325
+ state: () => ({ theme: 'dark', language: 'en' }),
326
+ });
327
+ ```
328
+
329
+ ### View – declarative bindings
330
+
331
+ ```ts
332
+ import { mount, createTemplate } from '@bquery/bquery/view';
333
+ import { signal } from '@bquery/bquery/reactive';
334
+
335
+ // Mount reactive bindings to DOM
336
+ const count = signal(0);
337
+ const items = signal(['Apple', 'Banana', 'Cherry']);
338
+
339
+ const app = mount('#app', {
340
+ count,
341
+ items,
342
+ increment: () => count.value++,
343
+ });
344
+
345
+ // In HTML:
346
+ // <p bq-text="count"></p>
347
+ // <button bq-on:click="increment">+1</button>
348
+ // <ul><li bq-for="item in items" bq-text="item"></li></ul>
349
+ // <input bq-model="count" type="number" />
350
+ // <div bq-if="count > 5">Count is high!</div>
351
+ // <div bq-class="{ active: count > 0 }"></div>
352
+ ```
353
+
253
354
  ## Browser Support
254
355
 
255
356
  | Browser | Version | Support |
@@ -271,6 +372,9 @@ if (permission === 'granted') {
271
372
  - **Motion**: [docs/guide/motion.md](docs/guide/motion.md)
272
373
  - **Security**: [docs/guide/security.md](docs/guide/security.md)
273
374
  - **Platform**: [docs/guide/platform.md](docs/guide/platform.md)
375
+ - **Router**: [docs/guide/router.md](docs/guide/router.md)
376
+ - **Store**: [docs/guide/store.md](docs/guide/store.md)
377
+ - **View**: [docs/guide/view.md](docs/guide/view.md)
274
378
 
275
379
  ## Local Development
276
380
 
@@ -304,7 +408,10 @@ bQuery.js
304
408
  │ ├── component/ # Web Components helper
305
409
  │ ├── motion/ # View transitions, FLIP, springs
306
410
  │ ├── security/ # Sanitizer, CSP, Trusted Types
307
- └── platform/ # Storage, cache, notifications
411
+ ├── platform/ # Storage, cache, notifications
412
+ │ ├── router/ # SPA routing, navigation guards
413
+ │ ├── store/ # State management, persistence
414
+ │ └── view/ # Declarative DOM bindings
308
415
  ├── docs/ # VitePress documentation
309
416
  ├── playground/ # Vite demo app
310
417
  ├── tests/ # bun:test suites
package/dist/full.d.ts CHANGED
@@ -45,4 +45,10 @@ export { createTrustedHtml, escapeHtml, generateNonce, getTrustedTypesPolicy, ha
45
45
  export type { SanitizeOptions } from './security/index';
46
46
  export { buckets, cache, notifications, storage } from './platform/index';
47
47
  export type { Bucket, CacheHandle, IndexedDBOptions, NotificationOptions, StorageAdapter, } from './platform/index';
48
+ export { back, createRouter, currentRoute, forward, interceptLinks, isActive, isActiveSignal, link, navigate, resolve, } from './router/index';
49
+ export type { NavigationGuard, Route, RouteDefinition, Router, RouterOptions, } from './router/index';
50
+ export { createPersistedStore, createStore, destroyStore, getStore, listStores, mapActions, mapState, registerPlugin, } from './store/index';
51
+ export type { StateFactory, Store, StoreDefinition, StorePlugin } from './store/index';
52
+ export { createTemplate, mount } from './view/index';
53
+ export type { BindingContext, MountOptions, View } from './view/index';
48
54
  //# sourceMappingURL=full.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"full.d.ts","sourceRoot":"","sources":["../src/full.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAKH,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,gBAAgB,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAK7E,OAAO,EACL,QAAQ,EACR,MAAM,EACN,KAAK,EACL,QAAQ,EACR,MAAM,EACN,UAAU,EACV,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,MAAM,EACN,OAAO,EACP,KAAK,GACN,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAK5E,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC9D,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAK7E,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACpG,YAAY,EACV,aAAa,EACb,WAAW,EACX,MAAM,EACN,YAAY,EACZ,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,qBAAqB,EACrB,eAAe,EACf,uBAAuB,EACvB,QAAQ,EACR,YAAY,EACZ,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAKxD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC1E,YAAY,EACV,MAAM,EACN,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,GACf,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"full.d.ts","sourceRoot":"","sources":["../src/full.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAKH,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,gBAAgB,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAK7E,OAAO,EACL,QAAQ,EACR,MAAM,EACN,KAAK,EACL,QAAQ,EACR,MAAM,EACN,UAAU,EACV,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,MAAM,EACN,OAAO,EACP,KAAK,GACN,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAK5E,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC9D,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAK7E,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACpG,YAAY,EACV,aAAa,EACb,WAAW,EACX,MAAM,EACN,YAAY,EACZ,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,qBAAqB,EACrB,eAAe,EACf,uBAAuB,EACvB,QAAQ,EACR,YAAY,EACZ,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAKxD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC1E,YAAY,EACV,MAAM,EACN,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,GACf,MAAM,kBAAkB,CAAC;AAK1B,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,cAAc,EACd,QAAQ,EACR,cAAc,EACd,IAAI,EACJ,QAAQ,EACR,OAAO,GACR,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,eAAe,EACf,KAAK,EACL,eAAe,EACf,MAAM,EACN,aAAa,GACd,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,UAAU,EACV,QAAQ,EACR,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAKvF,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC"}
package/dist/full.es.mjs CHANGED
@@ -1,48 +1,71 @@
1
- import { $ as i, $$ as r, BQueryCollection as s, BQueryElement as o, utils as a } from "./core.es.mjs";
2
- import { Computed as p, Signal as c, batch as l, computed as m, effect as u, isComputed as f, isSignal as g, persistedSignal as d, readonly as x, signal as y, untrack as T, watch as h } from "./reactive.es.mjs";
3
- import { component as C, html as H, safeHtml as P } from "./component.es.mjs";
4
- import { capturePosition as $, flip as b, flipList as k, spring as B, springPresets as Q, transition as v } from "./motion.es.mjs";
5
- import { createTrustedHtml as D, escapeHtml as E, generateNonce as L, getTrustedTypesPolicy as N, hasCSPDirective as j, isTrustedTypesSupported as q, sanitize as A, sanitize as F, stripTags as G } from "./security.es.mjs";
6
- import { buckets as J, cache as K, notifications as M, storage as O } from "./platform.es.mjs";
1
+ import { $ as r, $$ as o, BQueryCollection as i, BQueryElement as s, utils as a } from "./core.es.mjs";
2
+ import { Computed as p, Signal as c, batch as l, computed as m, effect as u, isComputed as f, isSignal as g, persistedSignal as d, readonly as S, signal as x, untrack as y, watch as T } from "./reactive.es.mjs";
3
+ import { component as h, html as k, safeHtml as v } from "./component.es.mjs";
4
+ import { capturePosition as H, flip as b, flipList as z, spring as A, springPresets as $, transition as w } from "./motion.es.mjs";
5
+ import { createTrustedHtml as L, escapeHtml as Q, generateNonce as R, getTrustedTypesPolicy as D, hasCSPDirective as E, isTrustedTypesSupported as N, sanitize as j, sanitize as q, stripTags as F } from "./security.es.mjs";
6
+ import { buckets as I, cache as J, notifications as K, storage as M } from "./platform.es.mjs";
7
+ import { back as U, createRouter as V, currentRoute as W, forward as X, interceptLinks as Y, isActive as Z, isActiveSignal as _, link as ee, navigate as te, resolve as re } from "./router.es.mjs";
8
+ import { createPersistedStore as ie, createStore as se, destroyStore as ae, getStore as ne, listStores as pe, mapActions as ce, mapState as le, registerPlugin as me } from "./store.es.mjs";
9
+ import { createTemplate as fe, mount as ge } from "./view.es.mjs";
7
10
  export {
8
- i as $,
9
- r as $$,
10
- s as BQueryCollection,
11
- o as BQueryElement,
11
+ r as $,
12
+ o as $$,
13
+ i as BQueryCollection,
14
+ s as BQueryElement,
12
15
  p as Computed,
13
16
  c as Signal,
17
+ U as back,
14
18
  l as batch,
15
- J as buckets,
16
- K as cache,
17
- $ as capturePosition,
18
- C as component,
19
+ I as buckets,
20
+ J as cache,
21
+ H as capturePosition,
22
+ h as component,
19
23
  m as computed,
20
- D as createTrustedHtml,
24
+ ie as createPersistedStore,
25
+ V as createRouter,
26
+ se as createStore,
27
+ fe as createTemplate,
28
+ L as createTrustedHtml,
29
+ W as currentRoute,
30
+ ae as destroyStore,
21
31
  u as effect,
22
- E as escapeHtml,
32
+ Q as escapeHtml,
23
33
  b as flip,
24
- k as flipList,
25
- L as generateNonce,
26
- N as getTrustedTypesPolicy,
27
- j as hasCSPDirective,
28
- H as html,
34
+ z as flipList,
35
+ X as forward,
36
+ R as generateNonce,
37
+ ne as getStore,
38
+ D as getTrustedTypesPolicy,
39
+ E as hasCSPDirective,
40
+ k as html,
41
+ Y as interceptLinks,
42
+ Z as isActive,
43
+ _ as isActiveSignal,
29
44
  f as isComputed,
30
45
  g as isSignal,
31
- q as isTrustedTypesSupported,
32
- M as notifications,
46
+ N as isTrustedTypesSupported,
47
+ ee as link,
48
+ pe as listStores,
49
+ ce as mapActions,
50
+ le as mapState,
51
+ ge as mount,
52
+ te as navigate,
53
+ K as notifications,
33
54
  d as persistedSignal,
34
- x as readonly,
35
- P as safeHtml,
36
- A as sanitize,
37
- F as sanitizeHtml,
38
- y as signal,
39
- B as spring,
40
- Q as springPresets,
41
- O as storage,
42
- G as stripTags,
43
- v as transition,
44
- T as untrack,
55
+ S as readonly,
56
+ me as registerPlugin,
57
+ re as resolve,
58
+ v as safeHtml,
59
+ j as sanitize,
60
+ q as sanitizeHtml,
61
+ x as signal,
62
+ A as spring,
63
+ $ as springPresets,
64
+ M as storage,
65
+ F as stripTags,
66
+ w as transition,
67
+ y as untrack,
45
68
  a as utils,
46
- h as watch
69
+ T as watch
47
70
  };
48
71
  //# sourceMappingURL=full.es.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"full.es.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
1
+ {"version":3,"file":"full.es.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
package/dist/full.iife.js CHANGED
@@ -1,2 +1,7 @@
1
- var bQuery=function(a){"use strict";const O="bquery-sanitizer";let C=null;const I=()=>typeof window.trustedTypes<"u",M=()=>{if(C)return C;const r=window;if(!r.trustedTypes)return null;try{return C=r.trustedTypes.createPolicy(O,{createHTML:e=>N(e)}),C}catch{return console.warn(`bQuery: Could not create Trusted Types policy "${O}"`),null}},R=new Set(["a","abbr","address","article","aside","b","bdi","bdo","blockquote","br","button","caption","cite","code","col","colgroup","data","dd","del","details","dfn","div","dl","dt","em","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","i","img","input","ins","kbd","label","legend","li","main","mark","nav","ol","optgroup","option","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","small","source","span","strong","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","u","ul","var","wbr"]),D=new Set(["script","iframe","frame","frameset","object","embed","applet","link","meta","style","base","template","slot","math","svg","foreignobject","noscript"]),U=new Set(["document","window","location","top","self","parent","frames","history","navigator","screen","alert","confirm","prompt","eval","Function","cookie","domain","referrer","body","head","forms","images","links","scripts","children","parentNode","firstChild","lastChild","innerHTML","outerHTML","textContent"]),z=new Set(["alt","class","dir","height","hidden","href","id","lang","loading","name","role","src","srcset","style","tabindex","title","type","width","aria-*"]),W=["on","formaction","xlink:","xmlns:"],Q=["javascript:","data:","vbscript:","file:"],J=(r,e,t)=>{const s=r.toLowerCase();for(const n of W)if(s.startsWith(n))return!1;return t&&s.startsWith("data-")||s.startsWith("aria-")?!0:e.has(s)},G=r=>{const e=r.toLowerCase().trim();return!U.has(e)},K=r=>r.replace(/[\u0000-\u001F\u007F]+/g,"").replace(/[\u200B-\u200D\uFEFF\u2028\u2029]+/g,"").replace(/\\u[\da-fA-F]{4}/g,"").replace(/\s+/g,"").toLowerCase(),V=r=>{const e=K(r);for(const t of Q)if(e.startsWith(t))return!1;return!0},N=(r,e={})=>{const{allowTags:t=[],allowAttributes:s=[],allowDataAttributes:n=!0,stripAllTags:i=!1}=e,o=new Set([...R,...t.map(u=>u.toLowerCase())].filter(u=>!D.has(u))),l=new Set([...z,...s.map(u=>u.toLowerCase())]),c=document.createElement("template");if(c.innerHTML=r,i)return c.content.textContent??"";const h=document.createTreeWalker(c.content,NodeFilter.SHOW_ELEMENT),f=[];for(;h.nextNode();){const u=h.currentNode,w=u.tagName.toLowerCase();if(D.has(w)){f.push(u);continue}if(!o.has(w)){f.push(u);continue}const y=[];for(const m of Array.from(u.attributes)){const p=m.name.toLowerCase();if(!J(p,l,n)){y.push(m.name);continue}if((p==="id"||p==="name")&&!G(m.value)){y.push(m.name);continue}(p==="href"||p==="src"||p==="srcset")&&!V(m.value)&&y.push(m.name)}for(const m of y)u.removeAttribute(m)}for(const u of f)u.remove();return c.innerHTML},b=(r,e={})=>N(r,e),Z=r=>{const e=M();return e?e.createHTML(r):b(r)},X=r=>{const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"};return r.replace(/[&<>"'`]/g,t=>e[t])},Y=r=>N(r,{stripAllTags:!0}),x=(r=16)=>{const e=new Uint8Array(r);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},ee=r=>{const e=document.querySelector('meta[http-equiv="Content-Security-Policy"]');return e?(e.getAttribute("content")??"").includes(r):!1},te=r=>Array.isArray(r)?r:[r],d=(r,e)=>{for(const t of r)e(t)};class g{constructor(e){this.element=e,this.delegatedHandlers=new Map}get raw(){return this.element}get node(){return this.element}addClass(...e){return this.element.classList.add(...e),this}removeClass(...e){return this.element.classList.remove(...e),this}toggleClass(e,t){return this.element.classList.toggle(e,t),this}attr(e,t){return t===void 0?this.element.getAttribute(e)??"":(this.element.setAttribute(e,t),this)}prop(e,t){return t===void 0?this.element[e]:(this.element[e]=t,this)}data(e,t){const s=e.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`);return t===void 0?this.element.getAttribute(`data-${s}`)??"":(this.element.setAttribute(`data-${s}`,t),this)}text(e){return e===void 0?this.element.textContent??"":(this.element.textContent=e,this)}html(e){return this.element.innerHTML=b(e),this}htmlUnsafe(e){return this.element.innerHTML=e,this}css(e,t){if(typeof e=="string")return t!==void 0&&this.element.style.setProperty(e,t),this;for(const[s,n]of Object.entries(e))this.element.style.setProperty(s,n);return this}append(e){return this.insertContent(e,"beforeend"),this}prepend(e){return this.insertContent(e,"afterbegin"),this}before(e){return this.insertContent(e,"beforebegin"),this}after(e){return this.insertContent(e,"afterend"),this}wrap(e){const t=typeof e=="string"?document.createElement(e):e;return this.element.parentNode?.insertBefore(t,this.element),t.appendChild(this.element),this}unwrap(){const e=this.element.parentElement;return e&&e.parentNode&&(e.parentNode.insertBefore(this.element,e),e.remove()),this}replaceWith(e){let t;if(typeof e=="string"){const s=document.createElement("template");s.innerHTML=b(e),t=s.content.firstElementChild??document.createElement("div")}else t=e;return this.element.replaceWith(t),new g(t)}scrollTo(e={behavior:"smooth"}){return this.element.scrollIntoView(e),this}remove(){return this.element.remove(),this}empty(){return this.element.innerHTML="",this}clone(e=!0){return new g(this.element.cloneNode(e))}find(e){return Array.from(this.element.querySelectorAll(e))}findOne(e){return this.element.querySelector(e)}closest(e){return this.element.closest(e)}parent(){return this.element.parentElement}children(){return Array.from(this.element.children)}siblings(){const e=this.element.parentElement;return e?Array.from(e.children).filter(t=>t!==this.element):[]}next(){return this.element.nextElementSibling}prev(){return this.element.previousElementSibling}on(e,t){return this.element.addEventListener(e,t),this}once(e,t){return this.element.addEventListener(e,t,{once:!0}),this}off(e,t){return this.element.removeEventListener(e,t),this}trigger(e,t){return this.element.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0})),this}delegate(e,t,s){const n=`${e}:${t}`,i=o=>{const l=o.target.closest(t);l&&this.element.contains(l)&&s(o,l)};return this.delegatedHandlers.has(n)||this.delegatedHandlers.set(n,new Map),this.delegatedHandlers.get(n).set(s,i),this.element.addEventListener(e,i),this}undelegate(e,t,s){const n=`${e}:${t}`,i=this.delegatedHandlers.get(n);if(i){const o=i.get(s);o&&(this.element.removeEventListener(e,o),i.delete(s),i.size===0&&this.delegatedHandlers.delete(n))}return this}matches(e){return this.element.matches(e)}hasClass(e){return this.element.classList.contains(e)}show(e=""){return this.element.removeAttribute("hidden"),this.element.style.display=e,this}hide(){return this.element.style.display="none",this}toggle(e){const t=this.element.style.display==="none";return e??t?this.show():this.hide()}focus(){return this.element.focus(),this}blur(){return this.element.blur(),this}val(e){const t=this.element;return e===void 0?t.value??"":(t.value=e,this)}serialize(){const e=this.element;if(e.tagName.toLowerCase()!=="form")return{};const t={},s=new FormData(e);for(const[n,i]of s.entries())if(typeof i=="string")if(n in t){const o=t[n];Array.isArray(o)?o.push(i):t[n]=[o,i]}else t[n]=i;return t}serializeString(){const e=this.element;if(e.tagName.toLowerCase()!=="form")return"";const t=new FormData(e),s=new URLSearchParams;for(const[n,i]of t.entries())typeof i=="string"&&s.append(n,i);return s.toString()}rect(){return this.element.getBoundingClientRect()}offset(){const e=this.element;return{width:e.offsetWidth,height:e.offsetHeight,top:e.offsetTop,left:e.offsetLeft}}insertContent(e,t){if(typeof e=="string"){this.element.insertAdjacentHTML(t,b(e));return}const s=te(e);d(s,n=>{this.element.insertAdjacentElement(t,n)})}}class S{constructor(e){this.elements=e,this.delegatedHandlers=new WeakMap}get length(){return this.elements.length}first(){return this.elements[0]}eq(e){const t=this.elements[e];return t?new g(t):void 0}firstEl(){return this.eq(0)}lastEl(){return this.eq(this.elements.length-1)}each(e){return this.elements.forEach((t,s)=>{e(new g(t),s)}),this}map(e){return this.elements.map(e)}filter(e){return new S(this.elements.filter(e))}reduce(e,t){return this.elements.reduce(e,t)}toArray(){return this.elements.map(e=>new g(e))}addClass(...e){return d(this.elements,t=>t.classList.add(...e)),this}removeClass(...e){return d(this.elements,t=>t.classList.remove(...e)),this}toggleClass(e,t){return d(this.elements,s=>s.classList.toggle(e,t)),this}attr(e,t){return t===void 0?this.first()?.getAttribute(e)??"":(d(this.elements,s=>s.setAttribute(e,t)),this)}removeAttr(e){return d(this.elements,t=>t.removeAttribute(e)),this}text(e){return e===void 0?this.first()?.textContent??"":(d(this.elements,t=>{t.textContent=e}),this)}html(e){if(e===void 0)return this.first()?.innerHTML??"";const t=b(e);return d(this.elements,s=>{s.innerHTML=t}),this}htmlUnsafe(e){return d(this.elements,t=>{t.innerHTML=e}),this}css(e,t){return typeof e=="string"?(t!==void 0&&d(this.elements,s=>{s.style.setProperty(e,t)}),this):(d(this.elements,s=>{for(const[n,i]of Object.entries(e))s.style.setProperty(n,i)}),this)}show(e=""){return d(this.elements,t=>{t.removeAttribute("hidden"),t.style.display=e}),this}hide(){return d(this.elements,e=>{e.style.display="none"}),this}on(e,t){return d(this.elements,s=>s.addEventListener(e,t)),this}once(e,t){return d(this.elements,s=>s.addEventListener(e,t,{once:!0})),this}off(e,t){return d(this.elements,s=>s.removeEventListener(e,t)),this}trigger(e,t){return d(this.elements,s=>{s.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0}))}),this}delegate(e,t,s){const n=`${e}:${t}`;return d(this.elements,i=>{const o=c=>{const h=c.target.closest(t);h&&i.contains(h)&&s(c,h)};this.delegatedHandlers.has(i)||this.delegatedHandlers.set(i,new Map);const l=this.delegatedHandlers.get(i);l.has(n)||l.set(n,new Map),l.get(n).set(s,o),i.addEventListener(e,o)}),this}undelegate(e,t,s){const n=`${e}:${t}`;return d(this.elements,i=>{const o=this.delegatedHandlers.get(i);if(!o)return;const l=o.get(n);if(!l)return;const c=l.get(s);c&&(i.removeEventListener(e,c),l.delete(s),l.size===0&&o.delete(n),o.size===0&&this.delegatedHandlers.delete(i))}),this}remove(){return d(this.elements,e=>e.remove()),this}empty(){return d(this.elements,e=>{e.innerHTML=""}),this}}const re=r=>{if(typeof r!="string")return new g(r);const e=document.querySelector(r);if(!e)throw new Error(`bQuery: element not found for selector "${r}"`);return new g(e)},se=r=>Array.isArray(r)?new S(r):r instanceof NodeList?new S(Array.from(r)):new S(Array.from(document.querySelectorAll(r))),A={clone(r){return typeof structuredClone=="function"?structuredClone(r):JSON.parse(JSON.stringify(r))},merge(...r){const e={};for(const t of r)for(const[s,n]of Object.entries(t))A.isPrototypePollutionKey(s)||(A.isPlainObject(n)&&A.isPlainObject(e[s])?e[s]=A.merge(e[s],n):e[s]=n);return e},isPrototypePollutionKey(r){return r==="__proto__"||r==="constructor"||r==="prototype"},debounce(r,e){let t;return(...s)=>{t&&clearTimeout(t),t=setTimeout(()=>r(...s),e)}},throttle(r,e){let t=0;return(...s)=>{const n=Date.now();n-t>=e&&(t=n,r(...s))}},uid(r="bQuery"){return`${r}_${Math.random().toString(36).slice(2,9)}`},isElement(r){return r instanceof Element},isCollection(r){return!!(r&&typeof r=="object"&&"elements"in r)},isEmpty(r){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},isPlainObject(r){return Object.prototype.toString.call(r)==="[object Object]"},isFunction(r){return typeof r=="function"},isString(r){return typeof r=="string"},isNumber(r){return typeof r=="number"&&!Number.isNaN(r)},isBoolean(r){return typeof r=="boolean"},isArray(r){return Array.isArray(r)},parseJson(r,e){try{return JSON.parse(r)}catch{return e}},pick(r,e){const t={};for(const s of e)s in r&&(t[s]=r[s]);return t},omit(r,e){const t={...r};for(const s of e)delete t[s];return t},sleep(r){return new Promise(e=>setTimeout(e,r))},randomInt(r,e){return Math.floor(Math.random()*(e-r+1))+r},clamp(r,e,t){return Math.min(Math.max(r,e),t)},capitalize(r){return r&&r.charAt(0).toUpperCase()+r.slice(1)},toKebabCase(r){return r.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()},toCamelCase(r){return r.replace(/[-_\s]+(.)?/g,(e,t)=>t?t.toUpperCase():"").replace(/^[A-Z]/,e=>e.toLowerCase())}},v=[];let E=0;const T=new Set;let L=!0;const j=(r,e)=>{v.push(r);try{return e()}finally{v.pop()}},q=r=>{if(E>0){T.add(r);return}r()},ne=()=>{for(const r of Array.from(T))T.delete(r),r()};class P{constructor(e){this._value=e,this.subscribers=new Set}get value(){if(L){const e=v[v.length-1];e&&this.subscribers.add(e)}return this._value}set value(e){if(!Object.is(this._value,e)){this._value=e;for(const t of this.subscribers)q(t)}}peek(){return this._value}update(e){this.value=e(this._value)}}class k{constructor(e){this.compute=e,this.dirty=!0,this.subscribers=new Set,this.markDirty=()=>{this.dirty=!0;for(const t of this.subscribers)q(t)}}get value(){const e=v[v.length-1];return e&&this.subscribers.add(e),this.dirty&&(this.dirty=!1,this.cachedValue=j(this.markDirty,this.compute)),this.cachedValue}}const F=r=>new P(r),ie=r=>new k(r),H=r=>{let e,t=!1;const s=()=>{t||(e&&e(),e=j(s,r))};return s(),()=>{t=!0,e&&e()}},oe=r=>{E+=1;try{r()}finally{E-=1,E===0&&ne()}},ae=(r,e)=>{let t=e;try{const n=localStorage.getItem(r);n!==null&&(t=JSON.parse(n))}catch{}const s=F(t);return H(()=>{try{localStorage.setItem(r,JSON.stringify(s.value))}catch{}}),s},ce=r=>({get value(){return r.value},peek(){return r.peek()}}),le=(r,e,t={})=>{let s,n=!0;return H(()=>{const i=r.value;if(n){n=!1,s=i,t.immediate&&e(i,void 0);return}e(i,s),s=i})},ue=r=>{const e=L;L=!1;try{return r()}finally{L=e}},he=r=>r instanceof P,de=r=>r instanceof k,me=(r,e)=>{const{type:t}=e;if(t===String)return r;if(t===Number){const s=Number(r);return Number.isNaN(s)?r:s}if(t===Boolean){const s=r.trim().toLowerCase();return s===""||s==="true"||s==="1"?!0:s==="false"||s==="0"?!1:!!r}if(t===Object||t===Array)try{return JSON.parse(r)}catch{return r}if(typeof t=="function"){const s=t,n=t;try{return s(r)}catch{return new n(r)}}return r},fe=(r,...e)=>r.reduce((t,s,n)=>`${t}${s}${e[n]??""}`,""),pe=(r,...e)=>{const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},s=n=>String(n??"").replace(/[&<>"'`]/g,o=>t[o]);return r.reduce((n,i,o)=>`${n}${i}${s(e[o])}`,"")},ge=(r,e)=>{class t extends HTMLElement{constructor(){super(),this.state={...e.state??{}},this.props={},this.attachShadow({mode:"open"}),this.syncProps()}static get observedAttributes(){return Object.keys(e.props??{})}connectedCallback(){try{e.beforeMount?.call(this),e.connected?.call(this),this.render()}catch(n){this.handleError(n)}}disconnectedCallback(){try{e.disconnected?.call(this)}catch(n){this.handleError(n)}}attributeChangedCallback(){try{this.syncProps(),this.render(!0)}catch(n){this.handleError(n)}}handleError(n){e.onError?e.onError.call(this,n):console.error(`bQuery component error in <${r}>:`,n)}setState(n,i){this.state[n]=i,this.render(!0)}getState(n){return this.state[n]}syncProps(){const n=e.props??{};for(const[i,o]of Object.entries(n)){const l=this.getAttribute(i);let c;if(l==null){if(o.required&&o.default===void 0)throw new Error(`bQuery component: missing required prop "${i}"`);c=o.default??void 0}else c=me(l,o);if(o.validator&&c!==void 0&&!o.validator(c))throw new Error(`bQuery component: validation failed for prop "${i}" with value ${JSON.stringify(c)}`);this.props[i]=c}}render(n=!1){try{if(n&&e.beforeUpdate&&e.beforeUpdate.call(this,this.props)===!1)return;const i=(c,h)=>{this.dispatchEvent(new CustomEvent(c,{detail:h,bubbles:!0,composed:!0}))};if(!this.shadowRoot)return;const o=e.render({props:this.props,state:this.state,emit:i}),l=e.styles?`<style>${e.styles}</style>`:"";this.shadowRoot.innerHTML=`${l}${o}`,n&&e.updated?.call(this)}catch(i){this.handleError(i)}}}customElements.get(r)||customElements.define(r,t)},ye=async r=>{const e=typeof r=="function"?r:r.update,t=document;if(t.startViewTransition){await t.startViewTransition(()=>e()).finished;return}e()},$=r=>{const e=r.getBoundingClientRect();return{top:e.top,left:e.left,width:e.width,height:e.height}},_=(r,e,t={})=>{const{duration:s=300,easing:n="ease-out",onComplete:i}=t,o=$(r);if(o.width===0||o.height===0)return Promise.resolve();const l=e.left-o.left,c=e.top-o.top,h=e.width/o.width,f=e.height/o.height;if(l===0&&c===0&&h===1&&f===1)return Promise.resolve();const u=r;return u.style.transform=`translate(${l}px, ${c}px) scale(${h}, ${f})`,u.style.transformOrigin="top left",u.offsetHeight,new Promise(w=>{const y=u.animate([{transform:`translate(${l}px, ${c}px) scale(${h}, ${f})`},{transform:"translate(0, 0) scale(1, 1)"}],{duration:s,easing:n,fill:"forwards"});y.onfinish=()=>{u.style.transform="",u.style.transformOrigin="",i?.(),w()}})},be=async(r,e,t={})=>{const s=new Map;for(const i of r)s.set(i,$(i));e();const n=r.map(i=>{const o=s.get(i);return o?_(i,o,t):Promise.resolve()});await Promise.all(n)},we={stiffness:100,damping:10,mass:1,precision:.01},Se=(r,e={})=>{const{stiffness:t,damping:s,mass:n,precision:i}={...we,...e};let o=r,l=0,c=r,h=null,f=null;const u=new Set,w=()=>{for(const m of u)m(o)},y=()=>{const m=o-c,p=-t*m,$e=-s*l,Oe=(p+$e)/n;if(l+=Oe*(1/60),o+=l*(1/60),w(),Math.abs(l)<i&&Math.abs(m)<i){o=c,l=0,h=null,w(),f?.(),f=null;return}h=requestAnimationFrame(y)};return{to(m){return c=m,h!==null&&cancelAnimationFrame(h),new Promise(p=>{f=p,h=requestAnimationFrame(y)})},current(){return o},stop(){h!==null&&(cancelAnimationFrame(h),h=null),l=0,f?.(),f=null},onChange(m){return u.add(m),()=>u.delete(m)}}},ve={gentle:{stiffness:80,damping:15},snappy:{stiffness:200,damping:20},bouncy:{stiffness:300,damping:8},stiff:{stiffness:400,damping:30}};class Ae{constructor(e){this.bucketName=e,this.dbPromise=null,this.storeName="blobs"}openDB(){if(this.dbPromise)return this.dbPromise;const e=`bquery-bucket-${this.bucketName}`;return this.dbPromise=new Promise((t,s)=>{const n=indexedDB.open(e,1);n.onupgradeneeded=()=>{const i=n.result;i.objectStoreNames.contains(this.storeName)||i.createObjectStore(this.storeName)},n.onsuccess=()=>t(n.result),n.onerror=()=>s(n.error)}),this.dbPromise}async withStore(e,t){const s=await this.openDB();return new Promise((n,i)=>{const l=s.transaction(this.storeName,e).objectStore(this.storeName),c=t(l);c.onsuccess=()=>n(c.result),c.onerror=()=>i(c.error)})}async put(e,t){await this.withStore("readwrite",s=>s.put(t,e))}async get(e){return await this.withStore("readonly",s=>s.get(e))??null}async remove(e){await this.withStore("readwrite",t=>t.delete(e))}async keys(){return(await this.withStore("readonly",t=>t.getAllKeys())).map(t=>String(t))}}const Ce={async open(r){return new Ae(r)}};class Ee{constructor(e){this.cache=e}async add(e){await this.cache.add(e)}async addAll(e){await this.cache.addAll(e)}async put(e,t){await this.cache.put(e,t)}async match(e){return this.cache.match(e)}async remove(e){return this.cache.delete(e)}async keys(){return(await this.cache.keys()).map(t=>t.url)}}const Le={isSupported(){return"caches"in window},async open(r){if(!this.isSupported())throw new Error("bQuery: Cache Storage API not supported");const e=await caches.open(r);return new Ee(e)},async delete(r){return this.isSupported()?caches.delete(r):!1},async keys(){return this.isSupported()?caches.keys():[]}},Ne={isSupported(){return"Notification"in window},getPermission(){return this.isSupported()?Notification.permission:"denied"},async requestPermission(){return this.isSupported()?Notification.permission==="granted"?"granted":Notification.permission==="denied"?"denied":Notification.requestPermission():"denied"},send(r,e){return this.isSupported()?Notification.permission!=="granted"?(console.warn("bQuery: Notification permission not granted"),null):new Notification(r,e):(console.warn("bQuery: Notifications not supported in this browser"),null)}};class B{constructor(e){this.storage=e}async get(e){const t=this.storage.getItem(e);if(t===null)return null;try{return JSON.parse(t)}catch{return t}}async set(e,t){const s=typeof t=="string"?t:JSON.stringify(t);this.storage.setItem(e,s)}async remove(e){this.storage.removeItem(e)}async clear(){this.storage.clear()}async keys(){return Object.keys(this.storage)}}class Te extends B{constructor(){super(localStorage)}}class Pe extends B{constructor(){super(sessionStorage)}}class ke{constructor(e){this.options=e,this.dbPromise=null}openDB(){return this.dbPromise?this.dbPromise:(this.dbPromise=new Promise((e,t)=>{const s=indexedDB.open(this.options.name,this.options.version??1);s.onupgradeneeded=()=>{const n=s.result;n.objectStoreNames.contains(this.options.store)||n.createObjectStore(this.options.store)},s.onsuccess=()=>e(s.result),s.onerror=()=>t(s.error)}),this.dbPromise)}async withStore(e,t){const s=await this.openDB();return new Promise((n,i)=>{const l=s.transaction(this.options.store,e).objectStore(this.options.store),c=t(l);c.onsuccess=()=>n(c.result),c.onerror=()=>i(c.error)})}async get(e){return await this.withStore("readonly",s=>s.get(e))??null}async set(e,t){await this.withStore("readwrite",s=>s.put(t,e))}async remove(e){await this.withStore("readwrite",t=>t.delete(e))}async clear(){await this.withStore("readwrite",e=>e.clear())}async keys(){return(await this.withStore("readonly",t=>t.getAllKeys())).map(t=>String(t))}}const He={local(){return new Te},session(){return new Pe},indexedDB(r){return new ke(r)}};return a.$=re,a.$$=se,a.BQueryCollection=S,a.BQueryElement=g,a.Computed=k,a.Signal=P,a.batch=oe,a.buckets=Ce,a.cache=Le,a.capturePosition=$,a.component=ge,a.computed=ie,a.createTrustedHtml=Z,a.effect=H,a.escapeHtml=X,a.flip=_,a.flipList=be,a.generateNonce=x,a.getTrustedTypesPolicy=M,a.hasCSPDirective=ee,a.html=fe,a.isComputed=de,a.isSignal=he,a.isTrustedTypesSupported=I,a.notifications=Ne,a.persistedSignal=ae,a.readonly=ce,a.safeHtml=pe,a.sanitize=b,a.sanitizeHtml=b,a.signal=F,a.spring=Se,a.springPresets=ve,a.storage=He,a.stripTags=Y,a.transition=ye,a.untrack=ue,a.utils=A,a.watch=le,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),a}({});
1
+ var bQuery=function(d){"use strict";const le="bquery-sanitizer";let U=null;const ke=()=>typeof window.trustedTypes<"u",ue=()=>{if(U)return U;const t=window;if(!t.trustedTypes)return null;try{return U=t.trustedTypes.createPolicy(le,{createHTML:e=>X(e)}),U}catch{return console.warn(`bQuery: Could not create Trusted Types policy "${le}"`),null}},Ce=new Set(["a","abbr","address","article","aside","b","bdi","bdo","blockquote","br","button","caption","cite","code","col","colgroup","data","dd","del","details","dfn","div","dl","dt","em","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","i","img","input","ins","kbd","label","legend","li","main","mark","nav","ol","optgroup","option","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","small","source","span","strong","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","u","ul","var","wbr"]),he=new Set(["script","iframe","frame","frameset","object","embed","applet","link","meta","style","base","template","slot","math","svg","foreignobject","noscript"]),Le=new Set(["document","window","location","top","self","parent","frames","history","navigator","screen","alert","confirm","prompt","eval","Function","cookie","domain","referrer","body","head","forms","images","links","scripts","children","parentNode","firstChild","lastChild","innerHTML","outerHTML","textContent"]),$e=new Set(["alt","class","dir","height","hidden","href","id","lang","loading","name","rel","role","src","srcset","style","tabindex","target","title","type","width","aria-*"]),Oe=["on","formaction","xlink:","xmlns:"],Pe=["javascript:","data:","vbscript:","file:"],_e=(t,e,r)=>{const s=t.toLowerCase();for(const n of Oe)if(s.startsWith(n))return!1;return r&&s.startsWith("data-")||s.startsWith("aria-")?!0:e.has(s)},Ne=t=>{const e=t.toLowerCase().trim();return!Le.has(e)},Te=t=>t.replace(/[\u0000-\u001F\u007F]+/g,"").replace(/[\u200B-\u200D\uFEFF\u2028\u2029]+/g,"").replace(/\\u[\da-fA-F]{4}/g,"").replace(/\s+/g,"").toLowerCase(),Re=t=>{const e=Te(t);for(const r of Pe)if(e.startsWith(r))return!1;return!0},je=t=>{try{const e=t.trim();if(e.startsWith("//"))return!0;const r=e.toLowerCase();return/^[a-z][a-z0-9+.-]*:/i.test(e)&&!r.startsWith("http://")&&!r.startsWith("https://")?!0:!r.startsWith("http://")&&!r.startsWith("https://")?!1:typeof window>"u"||!window.location?!0:new URL(e,window.location.href).origin!==window.location.origin}catch{return!0}},X=(t,e={})=>{const{allowTags:r=[],allowAttributes:s=[],allowDataAttributes:n=!0,stripAllTags:i=!1}=e,o=new Set([...Ce,...r.map(m=>m.toLowerCase())].filter(m=>!he.has(m))),c=new Set([...$e,...s.map(m=>m.toLowerCase())]),a=document.createElement("template");if(a.innerHTML=t,i)return a.content.textContent??"";const h=document.createTreeWalker(a.content,NodeFilter.SHOW_ELEMENT),y=[];for(;h.nextNode();){const m=h.currentNode,u=m.tagName.toLowerCase();if(he.has(u)){y.push(m);continue}if(!o.has(u)){y.push(m);continue}const f=[];for(const l of Array.from(m.attributes)){const p=l.name.toLowerCase();if(!_e(p,c,n)){f.push(l.name);continue}if((p==="id"||p==="name")&&!Ne(l.value)){f.push(l.name);continue}(p==="href"||p==="src"||p==="srcset")&&!Re(l.value)&&f.push(l.name)}for(const l of f)m.removeAttribute(l);if(u==="a"){const l=m.getAttribute("href"),b=m.getAttribute("target")?.toLowerCase()==="_blank",g=l&&je(l);if(b||g){const w=m.getAttribute("rel"),C=new Set(w?w.split(/\s+/).filter(Boolean):[]);C.add("noopener"),C.add("noreferrer"),m.setAttribute("rel",Array.from(C).join(" "))}}}for(const m of y)m.remove();return a.innerHTML},R=(t,e={})=>X(t,e),Me=t=>{const e=ue();return e?e.createHTML(t):R(t)},De=t=>{const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"};return t.replace(/[&<>"'`]/g,r=>e[r])},He=t=>X(t,{stripAllTags:!0}),qe=(t=16)=>{const e=new Uint8Array(t);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},Be=t=>{const e=document.querySelector('meta[http-equiv="Content-Security-Policy"]');return e?(e.getAttribute("content")??"").includes(t):!1},Ie=t=>Array.isArray(t)?t:[t],v=(t,e)=>{for(const r of t)e(r)};class _{constructor(e){this.element=e,this.delegatedHandlers=new Map}get raw(){return this.element}get node(){return this.element}addClass(...e){return this.element.classList.add(...e),this}removeClass(...e){return this.element.classList.remove(...e),this}toggleClass(e,r){return this.element.classList.toggle(e,r),this}attr(e,r){return r===void 0?this.element.getAttribute(e)??"":(this.element.setAttribute(e,r),this)}prop(e,r){return r===void 0?this.element[e]:(this.element[e]=r,this)}data(e,r){const s=e.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`);return r===void 0?this.element.getAttribute(`data-${s}`)??"":(this.element.setAttribute(`data-${s}`,r),this)}text(e){return e===void 0?this.element.textContent??"":(this.element.textContent=e,this)}html(e){return this.element.innerHTML=R(e),this}htmlUnsafe(e){return this.element.innerHTML=e,this}css(e,r){if(typeof e=="string")return r!==void 0&&this.element.style.setProperty(e,r),this;for(const[s,n]of Object.entries(e))this.element.style.setProperty(s,n);return this}append(e){return this.insertContent(e,"beforeend"),this}prepend(e){return this.insertContent(e,"afterbegin"),this}before(e){return this.insertContent(e,"beforebegin"),this}after(e){return this.insertContent(e,"afterend"),this}wrap(e){const r=typeof e=="string"?document.createElement(e):e;return this.element.parentNode?.insertBefore(r,this.element),r.appendChild(this.element),this}unwrap(){const e=this.element.parentElement;return e&&e.parentNode&&(e.parentNode.insertBefore(this.element,e),e.remove()),this}replaceWith(e){let r;if(typeof e=="string"){const s=document.createElement("template");s.innerHTML=R(e),r=s.content.firstElementChild??document.createElement("div")}else r=e;return this.element.replaceWith(r),new _(r)}scrollTo(e={behavior:"smooth"}){return this.element.scrollIntoView(e),this}remove(){return this.element.remove(),this}empty(){return this.element.innerHTML="",this}clone(e=!0){return new _(this.element.cloneNode(e))}find(e){return Array.from(this.element.querySelectorAll(e))}findOne(e){return this.element.querySelector(e)}closest(e){return this.element.closest(e)}parent(){return this.element.parentElement}children(){return Array.from(this.element.children)}siblings(){const e=this.element.parentElement;return e?Array.from(e.children).filter(r=>r!==this.element):[]}next(){return this.element.nextElementSibling}prev(){return this.element.previousElementSibling}on(e,r){return this.element.addEventListener(e,r),this}once(e,r){return this.element.addEventListener(e,r,{once:!0}),this}off(e,r){return this.element.removeEventListener(e,r),this}trigger(e,r){return this.element.dispatchEvent(new CustomEvent(e,{detail:r,bubbles:!0,cancelable:!0})),this}delegate(e,r,s){const n=`${e}:${r}`,i=o=>{const c=o.target.closest(r);c&&this.element.contains(c)&&s(o,c)};return this.delegatedHandlers.has(n)||this.delegatedHandlers.set(n,new Map),this.delegatedHandlers.get(n).set(s,i),this.element.addEventListener(e,i),this}undelegate(e,r,s){const n=`${e}:${r}`,i=this.delegatedHandlers.get(n);if(i){const o=i.get(s);o&&(this.element.removeEventListener(e,o),i.delete(s),i.size===0&&this.delegatedHandlers.delete(n))}return this}matches(e){return this.element.matches(e)}hasClass(e){return this.element.classList.contains(e)}show(e=""){return this.element.removeAttribute("hidden"),this.element.style.display=e,this}hide(){return this.element.style.display="none",this}toggle(e){const r=this.element.style.display==="none";return e??r?this.show():this.hide()}focus(){return this.element.focus(),this}blur(){return this.element.blur(),this}val(e){const r=this.element;return e===void 0?r.value??"":(r.value=e,this)}serialize(){const e=this.element;if(e.tagName.toLowerCase()!=="form")return{};const r={},s=new FormData(e);for(const[n,i]of s.entries())if(typeof i=="string")if(n in r){const o=r[n];Array.isArray(o)?o.push(i):r[n]=[o,i]}else r[n]=i;return r}serializeString(){const e=this.element;if(e.tagName.toLowerCase()!=="form")return"";const r=new FormData(e),s=new URLSearchParams;for(const[n,i]of r.entries())typeof i=="string"&&s.append(n,i);return s.toString()}rect(){return this.element.getBoundingClientRect()}offset(){const e=this.element;return{width:e.offsetWidth,height:e.offsetHeight,top:e.offsetTop,left:e.offsetLeft}}insertContent(e,r){if(typeof e=="string"){this.element.insertAdjacentHTML(r,R(e));return}const s=Ie(e);v(s,n=>{this.element.insertAdjacentElement(r,n)})}}class q{constructor(e){this.elements=e,this.delegatedHandlers=new WeakMap}get length(){return this.elements.length}first(){return this.elements[0]}eq(e){const r=this.elements[e];return r?new _(r):void 0}firstEl(){return this.eq(0)}lastEl(){return this.eq(this.elements.length-1)}each(e){return this.elements.forEach((r,s)=>{e(new _(r),s)}),this}map(e){return this.elements.map(e)}filter(e){return new q(this.elements.filter(e))}reduce(e,r){return this.elements.reduce(e,r)}toArray(){return this.elements.map(e=>new _(e))}addClass(...e){return v(this.elements,r=>r.classList.add(...e)),this}removeClass(...e){return v(this.elements,r=>r.classList.remove(...e)),this}toggleClass(e,r){return v(this.elements,s=>s.classList.toggle(e,r)),this}attr(e,r){return r===void 0?this.first()?.getAttribute(e)??"":(v(this.elements,s=>s.setAttribute(e,r)),this)}removeAttr(e){return v(this.elements,r=>r.removeAttribute(e)),this}text(e){return e===void 0?this.first()?.textContent??"":(v(this.elements,r=>{r.textContent=e}),this)}html(e){if(e===void 0)return this.first()?.innerHTML??"";const r=R(e);return v(this.elements,s=>{s.innerHTML=r}),this}htmlUnsafe(e){return v(this.elements,r=>{r.innerHTML=e}),this}css(e,r){return typeof e=="string"?(r!==void 0&&v(this.elements,s=>{s.style.setProperty(e,r)}),this):(v(this.elements,s=>{for(const[n,i]of Object.entries(e))s.style.setProperty(n,i)}),this)}show(e=""){return v(this.elements,r=>{r.removeAttribute("hidden"),r.style.display=e}),this}hide(){return v(this.elements,e=>{e.style.display="none"}),this}on(e,r){return v(this.elements,s=>s.addEventListener(e,r)),this}once(e,r){return v(this.elements,s=>s.addEventListener(e,r,{once:!0})),this}off(e,r){return v(this.elements,s=>s.removeEventListener(e,r)),this}trigger(e,r){return v(this.elements,s=>{s.dispatchEvent(new CustomEvent(e,{detail:r,bubbles:!0,cancelable:!0}))}),this}delegate(e,r,s){const n=`${e}:${r}`;return v(this.elements,i=>{const o=a=>{const h=a.target.closest(r);h&&i.contains(h)&&s(a,h)};this.delegatedHandlers.has(i)||this.delegatedHandlers.set(i,new Map);const c=this.delegatedHandlers.get(i);c.has(n)||c.set(n,new Map),c.get(n).set(s,o),i.addEventListener(e,o)}),this}undelegate(e,r,s){const n=`${e}:${r}`;return v(this.elements,i=>{const o=this.delegatedHandlers.get(i);if(!o)return;const c=o.get(n);if(!c)return;const a=c.get(s);a&&(i.removeEventListener(e,a),c.delete(s),c.size===0&&o.delete(n),o.size===0&&this.delegatedHandlers.delete(i))}),this}remove(){return v(this.elements,e=>e.remove()),this}empty(){return v(this.elements,e=>{e.innerHTML=""}),this}}const Fe=t=>{if(typeof t!="string")return new _(t);const e=document.querySelector(t);if(!e)throw new Error(`bQuery: element not found for selector "${t}"`);return new _(e)},Ue=t=>Array.isArray(t)?new q(t):t instanceof NodeList?new q(Array.from(t)):new q(Array.from(document.querySelectorAll(t))),F={clone(t){return typeof structuredClone=="function"?structuredClone(t):JSON.parse(JSON.stringify(t))},merge(...t){const e={};for(const r of t)for(const[s,n]of Object.entries(r))F.isPrototypePollutionKey(s)||(F.isPlainObject(n)&&F.isPlainObject(e[s])?e[s]=F.merge(e[s],n):e[s]=n);return e},isPrototypePollutionKey(t){return t==="__proto__"||t==="constructor"||t==="prototype"},debounce(t,e){let r;return(...s)=>{r&&clearTimeout(r),r=setTimeout(()=>t(...s),e)}},throttle(t,e){let r=0;return(...s)=>{const n=Date.now();n-r>=e&&(r=n,t(...s))}},uid(t="bQuery"){return`${t}_${Math.random().toString(36).slice(2,9)}`},isElement(t){return t instanceof Element},isCollection(t){return!!(t&&typeof t=="object"&&"elements"in t)},isEmpty(t){return t==null?!0:typeof t=="string"?t.trim().length===0:Array.isArray(t)?t.length===0:typeof t=="object"?Object.keys(t).length===0:!1},isPlainObject(t){return Object.prototype.toString.call(t)==="[object Object]"},isFunction(t){return typeof t=="function"},isString(t){return typeof t=="string"},isNumber(t){return typeof t=="number"&&!Number.isNaN(t)},isBoolean(t){return typeof t=="boolean"},isArray(t){return Array.isArray(t)},parseJson(t,e){try{return JSON.parse(t)}catch{return e}},pick(t,e){const r={};for(const s of e)s in t&&(r[s]=t[s]);return r},omit(t,e){const r={...t};for(const s of e)delete r[s];return r},sleep(t){return new Promise(e=>setTimeout(e,t))},randomInt(t,e){return Math.floor(Math.random()*(e-t+1))+t},clamp(t,e,r){return Math.min(Math.max(t,e),r)},capitalize(t){return t&&t.charAt(0).toUpperCase()+t.slice(1)},toKebabCase(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()},toCamelCase(t){return t.replace(/[-_\s]+(.)?/g,(e,r)=>r?r.toUpperCase():"").replace(/^[A-Z]/,e=>e.toLowerCase())}},B=[];let Q=0;const x=new Set;let W=!0;const ee=(t,e)=>{B.push(t);try{return e()}finally{B.pop()}},fe=t=>{if(Q>0){x.add(t);return}t()},Qe=()=>{for(const t of Array.from(x))x.delete(t),t()};class te{constructor(e){this._value=e,this.subscribers=new Set}get value(){if(W){const e=B[B.length-1];e&&this.subscribers.add(e)}return this._value}set value(e){if(!Object.is(this._value,e)){this._value=e;for(const r of this.subscribers)fe(r)}}peek(){return this._value}update(e){this.value=e(this._value)}}class re{constructor(e){this.compute=e,this.dirty=!0,this.subscribers=new Set,this.markDirty=()=>{this.dirty=!0;for(const r of this.subscribers)fe(r)}}get value(){const e=B[B.length-1];return e&&this.subscribers.add(e),this.dirty&&(this.dirty=!1,this.cachedValue=ee(this.markDirty,this.compute)),this.cachedValue}peek(){return this.dirty&&(this.dirty=!1,this.cachedValue=ee(this.markDirty,this.compute)),this.cachedValue}}const z=t=>new te(t),V=t=>new re(t),L=t=>{let e,r=!1;const s=()=>{r||(e&&e(),e=ee(s,t))};return s(),()=>{r=!0,e&&e()}},K=t=>{Q+=1;try{t()}finally{Q-=1,Q===0&&Qe()}},We=(t,e)=>{let r=e;try{const n=localStorage.getItem(t);n!==null&&(r=JSON.parse(n))}catch{}const s=z(r);return L(()=>{try{localStorage.setItem(t,JSON.stringify(s.value))}catch{}}),s},ze=t=>({get value(){return t.value},peek(){return t.peek()}}),Ve=(t,e,r={})=>{let s,n=!0;return L(()=>{const i=t.value;if(n){n=!1,s=i,r.immediate&&e(i,void 0);return}e(i,s),s=i})},Ke=t=>{const e=W;W=!1;try{return t()}finally{W=e}},J=t=>t instanceof te,de=t=>t instanceof re,Je=(t,e)=>{const{type:r}=e;if(r===String)return t;if(r===Number){const s=Number(t);return Number.isNaN(s)?t:s}if(r===Boolean){const s=t.trim().toLowerCase();return s===""||s==="true"||s==="1"?!0:s==="false"||s==="0"?!1:!!t}if(r===Object||r===Array)try{return JSON.parse(t)}catch{return t}if(typeof r=="function"){const s=r,n=r;try{return s(t)}catch{return new n(t)}}return t},Ze=(t,...e)=>t.reduce((r,s,n)=>`${r}${s}${e[n]??""}`,""),Ye=(t,...e)=>{const r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},s=n=>String(n??"").replace(/[&<>"'`]/g,o=>r[o]);return t.reduce((n,i,o)=>`${n}${i}${s(e[o])}`,"")},Ge=(t,e)=>{class r extends HTMLElement{constructor(){super(),this.state={...e.state??{}},this.props={},this.attachShadow({mode:"open"}),this.syncProps()}static get observedAttributes(){return Object.keys(e.props??{})}connectedCallback(){try{e.beforeMount?.call(this),e.connected?.call(this),this.render()}catch(n){this.handleError(n)}}disconnectedCallback(){try{e.disconnected?.call(this)}catch(n){this.handleError(n)}}attributeChangedCallback(){try{this.syncProps(),this.render(!0)}catch(n){this.handleError(n)}}handleError(n){e.onError?e.onError.call(this,n):console.error(`bQuery component error in <${t}>:`,n)}setState(n,i){this.state[n]=i,this.render(!0)}getState(n){return this.state[n]}syncProps(){const n=e.props??{};for(const[i,o]of Object.entries(n)){const c=this.getAttribute(i);let a;if(c==null){if(o.required&&o.default===void 0)throw new Error(`bQuery component: missing required prop "${i}"`);a=o.default??void 0}else a=Je(c,o);if(o.validator&&a!==void 0&&!o.validator(a))throw new Error(`bQuery component: validation failed for prop "${i}" with value ${JSON.stringify(a)}`);this.props[i]=a}}render(n=!1){try{if(n&&e.beforeUpdate&&e.beforeUpdate.call(this,this.props)===!1)return;const i=(a,h)=>{this.dispatchEvent(new CustomEvent(a,{detail:h,bubbles:!0,composed:!0}))};if(!this.shadowRoot)return;const o=e.render({props:this.props,state:this.state,emit:i}),c=e.styles?`<style>${e.styles}</style>`:"";this.shadowRoot.innerHTML=`${c}${o}`,n&&e.updated?.call(this)}catch(i){this.handleError(i)}}}customElements.get(t)||customElements.define(t,r)},Xe=async t=>{const e=typeof t=="function"?t:t.update,r=document;if(r.startViewTransition){await r.startViewTransition(()=>e()).finished;return}e()},ne=t=>{const e=t.getBoundingClientRect();return{top:e.top,left:e.left,width:e.width,height:e.height}},me=(t,e,r={})=>{const{duration:s=300,easing:n="ease-out",onComplete:i}=r,o=ne(t);if(o.width===0||o.height===0)return Promise.resolve();const c=e.left-o.left,a=e.top-o.top,h=e.width/o.width,y=e.height/o.height;if(c===0&&a===0&&h===1&&y===1)return Promise.resolve();const m=t;return m.style.transform=`translate(${c}px, ${a}px) scale(${h}, ${y})`,m.style.transformOrigin="top left",m.offsetHeight,new Promise(u=>{const f=m.animate([{transform:`translate(${c}px, ${a}px) scale(${h}, ${y})`},{transform:"translate(0, 0) scale(1, 1)"}],{duration:s,easing:n,fill:"forwards"});f.onfinish=()=>{m.style.transform="",m.style.transformOrigin="",i?.(),u()}})},xe=async(t,e,r={})=>{const s=new Map;for(const i of t)s.set(i,ne(i));e();const n=t.map(i=>{const o=s.get(i);return o?me(i,o,r):Promise.resolve()});await Promise.all(n)},et={stiffness:100,damping:10,mass:1,precision:.01},tt=(t,e={})=>{const{stiffness:r,damping:s,mass:n,precision:i}={...et,...e};let o=t,c=0,a=t,h=null,y=null;const m=new Set,u=()=>{for(const l of m)l(o)},f=()=>{const l=o-a,p=-r*l,b=-s*c,g=(p+b)/n;if(c+=g*(1/60),o+=c*(1/60),u(),Math.abs(c)<i&&Math.abs(l)<i){o=a,c=0,h=null,u(),y?.(),y=null;return}h=requestAnimationFrame(f)};return{to(l){return a=l,h!==null&&cancelAnimationFrame(h),new Promise(p=>{y=p,h=requestAnimationFrame(f)})},current(){return o},stop(){h!==null&&(cancelAnimationFrame(h),h=null),c=0,y?.(),y=null},onChange(l){return m.add(l),()=>m.delete(l)}}},rt={gentle:{stiffness:80,damping:15},snappy:{stiffness:200,damping:20},bouncy:{stiffness:300,damping:8},stiff:{stiffness:400,damping:30}};class nt{constructor(e){this.bucketName=e,this.dbPromise=null,this.storeName="blobs"}openDB(){if(this.dbPromise)return this.dbPromise;const e=`bquery-bucket-${this.bucketName}`;return this.dbPromise=new Promise((r,s)=>{const n=indexedDB.open(e,1);n.onupgradeneeded=()=>{const i=n.result;i.objectStoreNames.contains(this.storeName)||i.createObjectStore(this.storeName)},n.onsuccess=()=>r(n.result),n.onerror=()=>s(n.error)}),this.dbPromise}async withStore(e,r){const s=await this.openDB();return new Promise((n,i)=>{const c=s.transaction(this.storeName,e).objectStore(this.storeName),a=r(c);a.onsuccess=()=>n(a.result),a.onerror=()=>i(a.error)})}async put(e,r){await this.withStore("readwrite",s=>s.put(r,e))}async get(e){return await this.withStore("readonly",s=>s.get(e))??null}async remove(e){await this.withStore("readwrite",r=>r.delete(e))}async keys(){return(await this.withStore("readonly",r=>r.getAllKeys())).map(r=>String(r))}}const st={async open(t){return new nt(t)}};class ot{constructor(e){this.cache=e}async add(e){await this.cache.add(e)}async addAll(e){await this.cache.addAll(e)}async put(e,r){await this.cache.put(e,r)}async match(e){return this.cache.match(e)}async remove(e){return this.cache.delete(e)}async keys(){return(await this.cache.keys()).map(r=>r.url)}}const it={isSupported(){return"caches"in window},async open(t){if(!this.isSupported())throw new Error("bQuery: Cache Storage API not supported");const e=await caches.open(t);return new ot(e)},async delete(t){return this.isSupported()?caches.delete(t):!1},async keys(){return this.isSupported()?caches.keys():[]}},at={isSupported(){return"Notification"in window},getPermission(){return this.isSupported()?Notification.permission:"denied"},async requestPermission(){return this.isSupported()?Notification.permission==="granted"?"granted":Notification.permission==="denied"?"denied":Notification.requestPermission():"denied"},send(t,e){return this.isSupported()?Notification.permission!=="granted"?(console.warn("bQuery: Notification permission not granted"),null):new Notification(t,e):(console.warn("bQuery: Notifications not supported in this browser"),null)}};class pe{constructor(e){this.storage=e}async get(e){const r=this.storage.getItem(e);if(r===null)return null;try{return JSON.parse(r)}catch{return r}}async set(e,r){const s=typeof r=="string"?r:JSON.stringify(r);this.storage.setItem(e,s)}async remove(e){this.storage.removeItem(e)}async clear(){this.storage.clear()}async keys(){return Object.keys(this.storage)}}class ct extends pe{constructor(){super(localStorage)}}class lt extends pe{constructor(){super(sessionStorage)}}class ut{constructor(e){this.options=e,this.dbPromise=null}openDB(){return this.dbPromise?this.dbPromise:(this.dbPromise=new Promise((e,r)=>{const s=indexedDB.open(this.options.name,this.options.version??1);s.onupgradeneeded=()=>{const n=s.result;n.objectStoreNames.contains(this.options.store)||n.createObjectStore(this.options.store)},s.onsuccess=()=>e(s.result),s.onerror=()=>r(s.error)}),this.dbPromise)}async withStore(e,r){const s=await this.openDB();return new Promise((n,i)=>{const c=s.transaction(this.options.store,e).objectStore(this.options.store),a=r(c);a.onsuccess=()=>n(a.result),a.onerror=()=>i(a.error)})}async get(e){return await this.withStore("readonly",s=>s.get(e))??null}async set(e,r){await this.withStore("readwrite",s=>s.put(r,e))}async remove(e){await this.withStore("readwrite",r=>r.delete(e))}async clear(){await this.withStore("readwrite",e=>e.clear())}async keys(){return(await this.withStore("readonly",r=>r.getAllKeys())).map(r=>String(r))}}const ht={local(){return new ct},session(){return new lt},indexedDB(t){return new ut(t)}};let $=null;const j=z({path:"",params:{},query:{},matched:null,hash:""}),ye=V(()=>j.value),ft=t=>{if(t==="*")return/^.*$/;const e="\0P\0",r="\0W\0",s=[];let n=t.replace(/:([a-zA-Z_][a-zA-Z0-9_]*)/g,(o,c)=>(s.push(c),e));n=n.replace(/\*/g,r),n=n.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&");let i=0;return n=n.replace(/\u0000P\u0000/g,()=>`(?<${s[i++]}>[^/]+)`),n=n.replace(/\u0000W\u0000/g,".*"),new RegExp(`^${n}$`)},dt=t=>{const e=t.match(/:([a-zA-Z_][a-zA-Z0-9_]*)/g);return e?e.map(r=>r.slice(1)):[]},mt=(t,e)=>{for(const r of e){const s=ft(r.path),n=t.match(s);if(n){const i=dt(r.path),o={};return n.groups?Object.assign(o,n.groups):i.forEach((c,a)=>{o[c]=n[a+1]||""}),{matched:r,params:o}}}return null},pt=t=>{const e={};return new URLSearchParams(t).forEach((s,n)=>{const i=e[n];i===void 0?e[n]=s:Array.isArray(i)?i.push(s):e[n]=[i,s]}),e},Z=(t,e,r,s)=>{const n=mt(t,s);return{path:t,params:n?.params??{},query:pt(e),matched:n?.matched??null,hash:r.replace(/^#/,"")}},se=async(t,e={})=>{if(!$)throw new Error("bQuery router: No router initialized. Call createRouter() first.");await $[e.replace?"replace":"push"](t)},yt=()=>{$?$.back():history.back()},gt=()=>{$?$.forward():history.forward()},wt=t=>{$&&$.destroy();const{routes:e,base:r="",hash:s=!1}=t,n=[],i=[],o=ge(e,r),c=()=>{if(s){const f=window.location.hash.slice(1)||"/",[l,p=""]=f.split("?"),[b,g=""]=p.split("#");return{pathname:l,search:b?`?${b}`:"",hash:g?`#${g}`:""}}let u=window.location.pathname;return r&&u.startsWith(r)&&(u=u.slice(r.length)||"/"),{pathname:u,search:window.location.search,hash:window.location.hash}},a=()=>{const{pathname:u,search:f,hash:l}=c(),p=Z(u,f,l,o);j.value=p},h=async(u,f)=>{const{pathname:l,search:p,hash:b}=c(),g=Z(l,p,b,o),w=new URL(u,window.location.origin),C=s?u:w.pathname,S=Z(C,w.search,w.hash,o);for(const N of n)if(await N(S,g)===!1)return;const A=s?`#${u}`:`${r}${u}`;history[f]({},"",A),a();for(const N of i)N(j.value,g)},y=async()=>{const{pathname:u,search:f,hash:l}=c(),p=j.value,b=Z(u,f,l,o);for(const g of n)if(await g(b,p)===!1){const C=s?`#${p.path}`:`${r}${p.path}`;history.pushState({},"",C);return}a();for(const g of i)g(j.value,p)};window.addEventListener("popstate",y),a();const m={push:u=>h(u,"pushState"),replace:u=>h(u,"replaceState"),back:()=>history.back(),forward:()=>history.forward(),go:u=>history.go(u),beforeEach:u=>(n.push(u),()=>{const f=n.indexOf(u);f>-1&&n.splice(f,1)}),afterEach:u=>(i.push(u),()=>{const f=i.indexOf(u);f>-1&&i.splice(f,1)}),currentRoute:ye,routes:o,destroy:()=>{window.removeEventListener("popstate",y),n.length=0,i.length=0,$=null}};return $=m,m},ge=(t,e="")=>{const r=[];for(const s of t){const n=s.path==="*"?"*":`${e}${s.path}`.replace(/\/+/g,"/");r.push({...s,path:n}),s.children&&r.push(...ge(s.children,n))}return r},bt=(t,e={})=>{if(!$)throw new Error("bQuery router: No router initialized.");const r=$.routes.find(n=>n.name===t);if(!r)throw new Error(`bQuery router: Route "${t}" not found.`);let s=r.path;for(const[n,i]of Object.entries(e))s=s.replace(`:${n}`,encodeURIComponent(i));return s},vt=(t,e=!1)=>{const r=j.value.path;return e?r===t:r.startsWith(t)},St=(t,e=!1)=>V(()=>{const r=j.value.path;return e?r===t:r.startsWith(t)}),At=(t,e={})=>r=>{r.preventDefault(),se(t,e)},Et=(t=document.body)=>{const e=r=>{const n=r.target.closest("a");if(!n||n.target||n.hasAttribute("download")||n.origin!==window.location.origin)return;const i=n.pathname+n.search+n.hash;r.preventDefault(),se(i)};return t.addEventListener("click",e),()=>t.removeEventListener("click",e)},I=new Map,we=t=>t!==null&&typeof t=="object"&&Object.getPrototypeOf(t)===Object.prototype,M=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(M);if(t instanceof Date)return new Date(t.getTime());if(t instanceof Map)return new Map(Array.from(t.entries()).map(([r,s])=>[r,M(s)]));if(t instanceof Set)return new Set(Array.from(t).map(M));const e={};for(const r of Object.keys(t))e[r]=M(t[r]);return e},oe=(t,e)=>{if(t===e)return!0;if(t===null||e===null||typeof t!="object"||typeof e!="object")return!1;if(Array.isArray(t)&&Array.isArray(e))return t.length!==e.length?!1:t.every((n,i)=>oe(n,e[i]));if(Array.isArray(t)!==Array.isArray(e))return!1;const r=Object.keys(t),s=Object.keys(e);return r.length!==s.length?!1:r.every(n=>oe(t[n],e[n]))},kt=(t,e,r)=>{const s=[];for(const n of Object.keys(e)){const i=t[n],o=e[n];r.get(n)===o&&we(i)&&we(o)&&!oe(i,o)&&s.push(n)}return s},ie=(()=>{try{const t=globalThis.process;return typeof t<"u"&&t.env?.NODE_ENV!=="production"}catch{return!0}})(),be=[],ve=t=>{const{id:e,state:r,getters:s={},actions:n={}}=t;if(I.has(e))return console.warn(`bQuery store: Store "${e}" already exists. Returning existing instance.`),I.get(e);const i=r(),o=new Map;for(const f of Object.keys(i))o.set(f,z(i[f]));const c=[],a=()=>{const f=y();for(const l of c)l(f);typeof window<"u"&&window.__BQUERY_DEVTOOLS__?.onStateChange&&window.__BQUERY_DEVTOOLS__.onStateChange(e,f)},h=new Proxy({},{get:(f,l)=>{const p=l;if(o.has(p))return o.get(p).value},ownKeys:()=>Array.from(o.keys()),getOwnPropertyDescriptor:(f,l)=>{if(o.has(l))return{enumerable:!0,configurable:!0}},has:(f,l)=>o.has(l)}),y=()=>({...h}),m=new Map,u={};for(const f of Object.keys(i))Object.defineProperty(u,f,{get:()=>o.get(f).value,set:l=>{o.get(f).value=l,a()},enumerable:!0,configurable:!1});for(const f of Object.keys(s)){const l=s[f],p=V(()=>{const b=h,g=new Proxy({},{get:(w,C)=>{const S=C;if(m.has(S))return m.get(S).value}});return l(b,g)});m.set(f,p),Object.defineProperty(u,f,{get:()=>p.value,enumerable:!0,configurable:!1})}for(const f of Object.keys(n)){const l=n[f];u[f]=function(...p){const b=new Proxy(u,{get:(g,w)=>typeof w=="string"&&o.has(w)?o.get(w).value:g[w],set:(g,w,C)=>typeof w=="string"&&o.has(w)?(o.get(w).value=C,a(),!0):!1});return l.apply(b,p)}}Object.defineProperties(u,{$id:{value:e,writable:!1,enumerable:!1},$reset:{value:()=>{const f=r();K(()=>{for(const[l,p]of o)p.value=f[l]}),a()},writable:!1,enumerable:!1},$subscribe:{value:f=>(c.push(f),()=>{const l=c.indexOf(f);l>-1&&c.splice(l,1)}),writable:!1,enumerable:!1},$patch:{value:f=>{K(()=>{if(typeof f=="function"){const l=ie?M(y()):null,p=ie?new Map(Array.from(o.entries()).map(([g,w])=>[g,w.value])):null,b=y();if(f(b),ie&&l&&p){const g=kt(l,b,p);g.length>0&&console.warn(`[bQuery store "${e}"] Nested mutation detected in $patch() for keys: ${g.map(String).join(", ")}.
2
+ Nested object mutations do not trigger reactive updates because the store uses shallow reactivity.
3
+ To fix this, either:
4
+ 1. Replace the entire object: state.user = { ...state.user, name: "New" }
5
+ 2. Use $patchDeep() for automatic deep cloning
6
+ See: https://bquery.dev/guide/store#deep-reactivity`)}for(const[g,w]of Object.entries(b))o.has(g)&&(o.get(g).value=w)}else for(const[l,p]of Object.entries(f))o.has(l)&&(o.get(l).value=p)}),a()},writable:!1,enumerable:!1},$patchDeep:{value:f=>{K(()=>{if(typeof f=="function"){const l=M(y());f(l);for(const[p,b]of Object.entries(l))o.has(p)&&(o.get(p).value=b)}else for(const[l,p]of Object.entries(f))o.has(l)&&(o.get(l).value=M(p))}),a()},writable:!1,enumerable:!1},$state:{get:()=>y(),enumerable:!1}}),I.set(e,u);for(const f of be){const l=f({store:u,options:t});l&&Object.assign(u,l)}return typeof window<"u"&&(window.__BQUERY_DEVTOOLS__||(window.__BQUERY_DEVTOOLS__={stores:new Map}),window.__BQUERY_DEVTOOLS__.stores.set(e,u),window.__BQUERY_DEVTOOLS__.onStoreCreated?.(e,u)),u},Ct=t=>I.get(t),Lt=()=>Array.from(I.keys()),$t=t=>{I.delete(t),typeof window<"u"&&window.__BQUERY_DEVTOOLS__&&window.__BQUERY_DEVTOOLS__.stores.delete(t)},Ot=t=>{be.push(t)},Pt=(t,e)=>{const r=e??`bquery-store-${t.id}`,s=t.state;t.state=()=>{const i=s();if(typeof window<"u")try{const o=localStorage.getItem(r);if(o)return{...i,...JSON.parse(o)}}catch{}return i};const n=ve(t);return n.$subscribe(i=>{if(typeof window<"u")try{localStorage.setItem(r,JSON.stringify(i))}catch{}}),n},_t=(t,e)=>{const r={};for(const s of e)Object.defineProperty(r,s,{get:()=>t[s],enumerable:!0});return r},Nt=(t,e)=>{const r={};for(const s of e)r[s]=(...n)=>t[s](...n);return r},k=(t,e)=>{try{const r=Object.keys(e),s=r.map(i=>{const o=e[i];return J(o)||de(o)?o.value:o});return new Function(...r,`return (${t})`)(...s)}catch(r){console.error(`bQuery view: Error evaluating "${t}"`,r);return}},ae=(t,e)=>{try{const r=Object.keys(e),s=r.map(i=>e[i]);return new Function(...r,`return (${t})`)(...s)}catch(r){console.error(`bQuery view: Error evaluating "${t}"`,r);return}},Se=t=>{const e={},r=t.trim().replace(/^\{|\}$/g,"").trim();if(!r)return e;const s=[];let n="",i=0,o=null;for(let c=0;c<r.length;c++){const a=r[c],h=c>0?r[c-1]:"";if((a==='"'||a==="'"||a==="`")&&h!=="\\"){o===null?o=a:o===a&&(o=null),n+=a;continue}if(o!==null){n+=a;continue}a==="("||a==="["||a==="{"?(i++,n+=a):a===")"||a==="]"||a==="}"?(i--,n+=a):a===","&&i===0?(s.push(n.trim()),n=""):n+=a}n.trim()&&s.push(n.trim());for(const c of s){let a=-1,h=0,y=null;for(let m=0;m<c.length;m++){const u=c[m],f=m>0?c[m-1]:"";if((u==='"'||u==="'"||u==="`")&&f!=="\\"){y===null?y=u:y===u&&(y=null);continue}if(y===null){if(u==="("||u==="["||u==="{")h++;else if(u===")"||u==="]"||u==="}")h--;else if(u===":"&&h===0){a=m;break}}}if(a>-1){const m=c.slice(0,a).trim().replace(/^['"]|['"]$/g,""),u=c.slice(a+1).trim();e[m]=u}}return e},Tt=(t,e,r,s)=>{const n=L(()=>{const i=k(e,r);t.textContent=String(i??"")});s.push(n)},Rt=t=>(e,r,s,n)=>{const i=L(()=>{const o=k(r,s),c=String(o??"");e.innerHTML=t?R(c):c});n.push(i)},jt=(t,e,r,s)=>{const n=t.parentNode,i=document.createComment(`bq-if: ${e}`);let o=!0;const c=L(()=>{const a=k(e,r);a&&!o?(n?.replaceChild(t,i),o=!0):!a&&o&&(n?.replaceChild(i,t),o=!1)});s.push(c)},Mt=(t,e,r,s)=>{const n=t,i=n.style.display,o=L(()=>{const c=k(e,r);n.style.display=c?i:"none"});s.push(o)},Dt=(t,e,r,s)=>{let n=new Set;const i=L(()=>{const o=new Set;if(e.startsWith("{")){const c=Se(e);for(const[a,h]of Object.entries(c)){const y=k(h,r);t.classList.toggle(a,!!y),o.add(a)}}else if(e.includes("[")){const c=k(e,r);if(Array.isArray(c))for(const a of c)a&&(t.classList.add(a),o.add(a))}else{const c=k(e,r);typeof c=="string"?c.split(/\s+/).forEach(a=>{a&&(t.classList.add(a),o.add(a))}):Array.isArray(c)&&c.forEach(a=>{a&&(t.classList.add(a),o.add(a))})}if(!e.startsWith("{"))for(const c of n)o.has(c)||t.classList.remove(c);n=o});s.push(i)},Ht=(t,e,r,s)=>{const n=t,i=L(()=>{if(e.startsWith("{")){const o=Se(e);for(const[c,a]of Object.entries(o)){const h=k(a,r),y=c.replace(/([A-Z])/g,"-$1").toLowerCase();n.style.setProperty(y,String(h??""))}}else{const o=k(e,r);if(o&&typeof o=="object")for(const[c,a]of Object.entries(o)){const h=c.replace(/([A-Z])/g,"-$1").toLowerCase();n.style.setProperty(h,String(a??""))}}});s.push(i)},qt=(t,e,r,s)=>{const n=t,i=ae(e,r);if(!J(i)){console.warn(`bQuery view: bq-model requires a signal, got "${e}"`);return}const o=i,c=n.type==="checkbox",a=n.type==="radio",h=()=>{c?n.checked=!!o.value:a?n.checked=o.value===n.value:n.value=String(o.value??"")},y=L(()=>{h()});s.push(y);const m=n.tagName==="SELECT"?"change":"input",u=()=>{c?o.value=n.checked:a?n.checked&&(o.value=n.value):o.value=n.value};n.addEventListener(m,u),s.push(()=>n.removeEventListener(m,u))},Bt=t=>(e,r,s,n)=>{const i=L(()=>{const o=k(r,s);o==null||o===!1?e.removeAttribute(t):o===!0?e.setAttribute(t,""):e.setAttribute(t,String(o))});n.push(i)},It=t=>(e,r,s,n)=>{const i=o=>{const c={...s,$event:o,$el:e};if(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(r.trim())){const h=ae(r,c);if(typeof h=="function"){h(o);return}}k(r,c)};e.addEventListener(t,i),n.push(()=>e.removeEventListener(t,i))},Ft=(t,e,r,s,n,i)=>{if(!r)return e;const o={...i,[s]:t};return n&&(o[n]=e),k(r,o)},Ut=(t,e)=>(r,s,n,i)=>{const o=r.parentNode;if(!o)return;const c=s.match(/^\(?(\w+)(?:\s*,\s*(\w+))?\)?\s+in\s+(\S.*)$/);if(!c){console.error(`bQuery view: Invalid bq-for expression "${s}"`);return}const[,a,h,y]=c,m=r.getAttribute(":key")||r.getAttribute(`${t}-key`),u=r.cloneNode(!0);u.removeAttribute(`${t}-for`),u.removeAttribute(":key"),u.removeAttribute(`${t}-key`);const f=document.createComment(`bq-for: ${s}`);o.replaceChild(f,r);let l=new Map,p=[];const b=(S,A,N)=>{const D=u.cloneNode(!0),H=[],T={...n,[a]:S};return h&&(T[h]=A),Y(D,T,t,e,H),ce(D,T,t,e,H),{key:N,element:D,cleanups:H,item:S,index:A}},g=S=>{for(const A of S.cleanups)A();S.element.remove()},w=(S,A)=>{S.index!==A&&h&&(S.index=A)},C=L(()=>{const S=k(y,n);if(!Array.isArray(S)){for(const E of l.values())g(E);l.clear(),p=[];return}const A=[],N=new Map;S.forEach((E,O)=>{const G=Ft(E,O,m,a,h,n);A.push(G),N.set(G,{item:E,index:O})});const D=[];for(const E of p)N.has(E)||D.push(E);for(const E of D){const O=l.get(E);O&&(g(O),l.delete(E))}const H=new Map;let T=f;for(let E=0;E<A.length;E++){const O=A[E],{item:G,index:Ee}=N.get(O);let P=l.get(O);P?(w(P,Ee),H.set(O,P),T.nextSibling!==P.element&&T.after(P.element),T=P.element):(P=b(G,Ee,O),H.set(O,P),T.after(P.element),T=P.element)}l=H,p=A});i.push(()=>{C();for(const S of l.values())for(const A of S.cleanups)A();l.clear()})},Qt=(t,e,r,s)=>{const n=ae(e,r);J(n)?(n.value=t,s.push(()=>{n.value=null})):typeof r[e]=="object"&&r[e]!==null&&(r[e].value=t)},Y=(t,e,r,s,n)=>{const i=Array.from(t.attributes);for(const o of i){const{name:c,value:a}=o;if(!c.startsWith(r))continue;const h=c.slice(r.length+1);if(h==="for"){Ut(r,s)(t,a,e,n);return}if(h==="text")Tt(t,a,e,n);else if(h==="html")Rt(s)(t,a,e,n);else if(h==="if")jt(t,a,e,n);else if(h==="show")Mt(t,a,e,n);else if(h==="class")Dt(t,a,e,n);else if(h==="style")Ht(t,a,e,n);else if(h==="model")qt(t,a,e,n);else if(h==="ref")Qt(t,a,e,n);else if(h.startsWith("bind:")){const y=h.slice(5);Bt(y)(t,a,e,n)}else if(h.startsWith("on:")){const y=h.slice(3);It(y)(t,a,e,n)}}},ce=(t,e,r,s,n)=>{const i=Array.from(t.children);for(const o of i)o.hasAttribute(`${r}-for`)?Y(o,e,r,s,n):(Y(o,e,r,s,n),ce(o,e,r,s,n))},Ae=(t,e,r={})=>{const{prefix:s="bq",sanitize:n=!0}=r,i=typeof t=="string"?document.querySelector(t):t;if(!i)throw new Error(`bQuery view: Element "${t}" not found.`);const o=[];return Y(i,e,s,n,o),ce(i,e,s,n,o),{el:i,context:e,update:c=>{Object.assign(e,c)},destroy:()=>{for(const c of o)c();o.length=0}}},Wt=(t,e={})=>r=>{const s=document.createElement("div");s.innerHTML=t.trim();const n=s.firstElementChild;if(!n)throw new Error("bQuery view: Template must contain a single root element.");return Ae(n,r,e)};return d.$=Fe,d.$$=Ue,d.BQueryCollection=q,d.BQueryElement=_,d.Computed=re,d.Signal=te,d.back=yt,d.batch=K,d.buckets=st,d.cache=it,d.capturePosition=ne,d.component=Ge,d.computed=V,d.createPersistedStore=Pt,d.createRouter=wt,d.createStore=ve,d.createTemplate=Wt,d.createTrustedHtml=Me,d.currentRoute=ye,d.destroyStore=$t,d.effect=L,d.escapeHtml=De,d.flip=me,d.flipList=xe,d.forward=gt,d.generateNonce=qe,d.getStore=Ct,d.getTrustedTypesPolicy=ue,d.hasCSPDirective=Be,d.html=Ze,d.interceptLinks=Et,d.isActive=vt,d.isActiveSignal=St,d.isComputed=de,d.isSignal=J,d.isTrustedTypesSupported=ke,d.link=At,d.listStores=Lt,d.mapActions=Nt,d.mapState=_t,d.mount=Ae,d.navigate=se,d.notifications=at,d.persistedSignal=We,d.readonly=ze,d.registerPlugin=Ot,d.resolve=bt,d.safeHtml=Ye,d.sanitize=R,d.sanitizeHtml=R,d.signal=z,d.spring=tt,d.springPresets=rt,d.storage=ht,d.stripTags=He,d.transition=Xe,d.untrack=Ke,d.utils=F,d.watch=Ve,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"}),d}({});
2
7
  //# sourceMappingURL=full.iife.js.map