@bquery/bquery 1.3.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/README.md +546 -501
  2. package/dist/component/component.d.ts.map +1 -1
  3. package/dist/component/index.d.ts +2 -0
  4. package/dist/component/index.d.ts.map +1 -1
  5. package/dist/component/library.d.ts +34 -0
  6. package/dist/component/library.d.ts.map +1 -0
  7. package/dist/component/types.d.ts +10 -6
  8. package/dist/component/types.d.ts.map +1 -1
  9. package/dist/component-CY5MVoYN.js +531 -0
  10. package/dist/component-CY5MVoYN.js.map +1 -0
  11. package/dist/component.es.mjs +6 -184
  12. package/dist/config-DRmZZno3.js +40 -0
  13. package/dist/config-DRmZZno3.js.map +1 -0
  14. package/dist/core/collection.d.ts +19 -3
  15. package/dist/core/collection.d.ts.map +1 -1
  16. package/dist/core/element.d.ts +23 -4
  17. package/dist/core/element.d.ts.map +1 -1
  18. package/dist/core/index.d.ts +1 -0
  19. package/dist/core/index.d.ts.map +1 -1
  20. package/dist/core/utils/function.d.ts +21 -4
  21. package/dist/core/utils/function.d.ts.map +1 -1
  22. package/dist/core-CK2Mfpf4.js +648 -0
  23. package/dist/core-CK2Mfpf4.js.map +1 -0
  24. package/dist/core-DPdbItcq.js +112 -0
  25. package/dist/core-DPdbItcq.js.map +1 -0
  26. package/dist/core.es.mjs +45 -1218
  27. package/dist/full.d.ts +6 -6
  28. package/dist/full.d.ts.map +1 -1
  29. package/dist/full.es.mjs +98 -92
  30. package/dist/full.iife.js +173 -3
  31. package/dist/full.iife.js.map +1 -1
  32. package/dist/full.umd.js +173 -3
  33. package/dist/full.umd.js.map +1 -1
  34. package/dist/index.es.mjs +143 -139
  35. package/dist/motion/transition.d.ts +1 -1
  36. package/dist/motion/transition.d.ts.map +1 -1
  37. package/dist/motion/types.d.ts +11 -1
  38. package/dist/motion/types.d.ts.map +1 -1
  39. package/dist/motion-C5DRdPnO.js +415 -0
  40. package/dist/motion-C5DRdPnO.js.map +1 -0
  41. package/dist/motion.es.mjs +25 -361
  42. package/dist/object-qGpWr6-J.js +38 -0
  43. package/dist/object-qGpWr6-J.js.map +1 -0
  44. package/dist/platform/announcer.d.ts +59 -0
  45. package/dist/platform/announcer.d.ts.map +1 -0
  46. package/dist/platform/config.d.ts +92 -0
  47. package/dist/platform/config.d.ts.map +1 -0
  48. package/dist/platform/cookies.d.ts +45 -0
  49. package/dist/platform/cookies.d.ts.map +1 -0
  50. package/dist/platform/index.d.ts +8 -0
  51. package/dist/platform/index.d.ts.map +1 -1
  52. package/dist/platform/meta.d.ts +62 -0
  53. package/dist/platform/meta.d.ts.map +1 -0
  54. package/dist/platform/storage.d.ts.map +1 -1
  55. package/dist/platform-B7JhGBc7.js +361 -0
  56. package/dist/platform-B7JhGBc7.js.map +1 -0
  57. package/dist/platform.es.mjs +11 -243
  58. package/dist/reactive/async-data.d.ts +114 -0
  59. package/dist/reactive/async-data.d.ts.map +1 -0
  60. package/dist/reactive/core.d.ts +12 -0
  61. package/dist/reactive/core.d.ts.map +1 -1
  62. package/dist/reactive/effect.d.ts.map +1 -1
  63. package/dist/reactive/index.d.ts +2 -2
  64. package/dist/reactive/index.d.ts.map +1 -1
  65. package/dist/reactive/internals.d.ts +6 -0
  66. package/dist/reactive/internals.d.ts.map +1 -1
  67. package/dist/reactive/signal.d.ts +2 -0
  68. package/dist/reactive/signal.d.ts.map +1 -1
  69. package/dist/reactive-BDya-ia8.js +253 -0
  70. package/dist/reactive-BDya-ia8.js.map +1 -0
  71. package/dist/reactive.es.mjs +18 -34
  72. package/dist/router-CijiICxt.js +188 -0
  73. package/dist/router-CijiICxt.js.map +1 -0
  74. package/dist/router.es.mjs +11 -200
  75. package/dist/sanitize-jyJ2ryE2.js +302 -0
  76. package/dist/sanitize-jyJ2ryE2.js.map +1 -0
  77. package/dist/security/constants.d.ts.map +1 -1
  78. package/dist/security/sanitize-core.d.ts.map +1 -1
  79. package/dist/security.es.mjs +10 -56
  80. package/dist/store-CPK9E62U.js +262 -0
  81. package/dist/store-CPK9E62U.js.map +1 -0
  82. package/dist/store.es.mjs +12 -25
  83. package/dist/view/evaluate.d.ts.map +1 -1
  84. package/dist/view-Cdi0g-qo.js +396 -0
  85. package/dist/view-Cdi0g-qo.js.map +1 -0
  86. package/dist/view.es.mjs +10 -424
  87. package/package.json +136 -132
  88. package/src/component/component.ts +319 -289
  89. package/src/component/index.ts +42 -40
  90. package/src/component/library.ts +504 -0
  91. package/src/component/types.ts +91 -85
  92. package/src/core/collection.ts +44 -4
  93. package/src/core/element.ts +33 -5
  94. package/src/core/index.ts +1 -0
  95. package/src/core/utils/function.ts +56 -15
  96. package/src/full.ts +223 -187
  97. package/src/motion/transition.ts +97 -51
  98. package/src/motion/types.ts +208 -198
  99. package/src/platform/announcer.ts +208 -0
  100. package/src/platform/config.ts +163 -0
  101. package/src/platform/cookies.ts +165 -0
  102. package/src/platform/index.ts +39 -18
  103. package/src/platform/meta.ts +168 -0
  104. package/src/platform/storage.ts +8 -1
  105. package/src/reactive/async-data.ts +486 -0
  106. package/src/reactive/core.ts +21 -0
  107. package/src/reactive/effect.ts +18 -7
  108. package/src/reactive/index.ts +37 -23
  109. package/src/reactive/internals.ts +18 -1
  110. package/src/reactive/signal.ts +29 -20
  111. package/src/security/constants.ts +211 -209
  112. package/src/security/sanitize-core.ts +22 -1
  113. package/src/view/evaluate.ts +29 -13
  114. package/dist/batch-4LAvfLE7.js +0 -13
  115. package/dist/batch-4LAvfLE7.js.map +0 -1
  116. package/dist/component.es.mjs.map +0 -1
  117. package/dist/core-COenAZjD.js +0 -145
  118. package/dist/core-COenAZjD.js.map +0 -1
  119. package/dist/core.es.mjs.map +0 -1
  120. package/dist/full.es.mjs.map +0 -1
  121. package/dist/index.es.mjs.map +0 -1
  122. package/dist/motion.es.mjs.map +0 -1
  123. package/dist/persisted-Dz_ryNuC.js +0 -278
  124. package/dist/persisted-Dz_ryNuC.js.map +0 -1
  125. package/dist/platform.es.mjs.map +0 -1
  126. package/dist/reactive.es.mjs.map +0 -1
  127. package/dist/router.es.mjs.map +0 -1
  128. package/dist/sanitize-1FBEPAFH.js +0 -272
  129. package/dist/sanitize-1FBEPAFH.js.map +0 -1
  130. package/dist/security.es.mjs.map +0 -1
  131. package/dist/store.es.mjs.map +0 -1
  132. package/dist/type-guards-DRma3-Kc.js +0 -16
  133. package/dist/type-guards-DRma3-Kc.js.map +0 -1
  134. package/dist/untrack-BuEQKH7_.js +0 -6
  135. package/dist/untrack-BuEQKH7_.js.map +0 -1
  136. package/dist/view.es.mjs.map +0 -1
  137. package/dist/watch-CXyaBC_9.js +0 -58
  138. package/dist/watch-CXyaBC_9.js.map +0 -1
package/dist/full.iife.js CHANGED
@@ -1,7 +1,177 @@
1
- var bQuery=(function(h){"use strict";const we="bquery-sanitizer",ft=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"]),ve=new Set(["script","iframe","frame","frameset","object","embed","applet","link","meta","style","base","template","slot","math","svg","foreignobject","noscript"]),ht=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"]),dt=new Set(["alt","class","dir","height","hidden","href","id","lang","loading","name","rel","role","src","srcset","tabindex","target","title","type","width","aria-*"]),mt=["on","formaction","xlink:","xmlns:"],pt=["javascript:","data:","vbscript:","file:"],yt=(t,e,n)=>{const r=t.toLowerCase();for(const s of mt)if(r.startsWith(s))return!1;return n&&r.startsWith("data-")||r.startsWith("aria-")?!0:e.has(r)},gt=t=>{const e=t.toLowerCase().trim();return!ht.has(e)},bt=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(),wt=t=>{const e=bt(t);for(const n of pt)if(e.startsWith(n))return!1;return!0},vt=t=>{try{const e=t.trim();if(e.startsWith("//"))return!0;const n=e.toLowerCase();return/^[a-z][a-z0-9+.-]*:/i.test(e)&&!n.startsWith("http://")&&!n.startsWith("https://")?!0:!n.startsWith("http://")&&!n.startsWith("https://")?!1:typeof window>"u"||!window.location?!0:new URL(e,window.location.href).origin!==window.location.origin}catch{return!0}},St=t=>new DOMParser().parseFromString(t,"text/html"),Se=t=>{const e=(typeof t=="string"?t:String(t??"")).trim(),n=document.createDocumentFragment();if(e.length===0)return n;if(!(e.includes("<")||e.includes(">")))return n.appendChild(document.createTextNode(e)),n;const o=St(e).body;if(!o)return n;for(;o.firstChild;)n.appendChild(o.firstChild);return n},J=(t,e={})=>{const{allowTags:n=[],allowAttributes:r=[],allowDataAttributes:s=!0,stripAllTags:o=!1}=e,i=new Set([...ft,...n.map(f=>f.toLowerCase())].filter(f=>!ve.has(f))),a=new Set([...dt,...r.map(f=>f.toLowerCase())]),c=Se(t);if(o)return c.textContent??"";const l=document.createTreeWalker(c,NodeFilter.SHOW_ELEMENT),p=[];for(;l.nextNode();){const f=l.currentNode,g=f.tagName.toLowerCase();if(ve.has(g)){p.push(f);continue}if(!i.has(g)){p.push(f);continue}const w=[];for(const b of Array.from(f.attributes)){const A=b.name.toLowerCase();if(!yt(A,a,s)){w.push(b.name);continue}if((A==="id"||A==="name")&&!gt(b.value)){w.push(b.name);continue}(A==="href"||A==="src"||A==="srcset")&&!wt(b.value)&&w.push(b.name)}for(const b of w)f.removeAttribute(b);if(g==="a"){const b=f.getAttribute("href"),$=f.getAttribute("target")?.toLowerCase()==="_blank",L=b&&vt(b);if($||L){const v=f.getAttribute("rel"),E=new Set(v?v.split(/\s+/).filter(Boolean):[]);E.add("noopener"),E.add("noreferrer"),f.setAttribute("rel",Array.from(E).join(" "))}}}for(const f of p)f.remove();const d=f=>{const g=document.createElement("div");return g.appendChild(f.cloneNode(!0)),g.innerHTML},y=d(c),u=Se(y),m=d(u);return y!==m?c.textContent??"":m},Ae=1024,Ee=8192,At=(t=16)=>{if(!Number.isInteger(t)||t<1)throw new RangeError("generateNonce length must be a positive integer");if(t>Ae)throw new RangeError(`generateNonce length must not exceed ${Ae}`);if(typeof globalThis.crypto>"u"||typeof globalThis.crypto.getRandomValues!="function")throw new Error("generateNonce requires crypto.getRandomValues (not available in this environment)");if(typeof globalThis.btoa!="function")throw new Error("generateNonce requires btoa (not available in this environment)");const e=new Uint8Array(t);globalThis.crypto.getRandomValues(e);let n="";for(let r=0;r<e.length;r+=Ee){const s=e.subarray(r,Math.min(r+Ee,e.length));n+=String.fromCharCode(...s)}return globalThis.btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},Et=t=>{if(typeof document>"u")return!1;const e=document.querySelector('meta[http-equiv="Content-Security-Policy"]');return e?(e.getAttribute("content")??"").includes(t):!1};let Z=null,Ce=!1;const Ct=()=>typeof window<"u"&&typeof window.trustedTypes<"u",$e=()=>{if(Z)return Z;if(Ce||typeof window>"u")return null;const t=window;if(!t.trustedTypes)return null;Ce=!0;try{return Z=t.trustedTypes.createPolicy(we,{createHTML:e=>J(e)}),Z}catch(e){const n=e instanceof Error?e.message:String(e);return console.warn(`bQuery: Could not create Trusted Types policy "${we}": ${n}`),null}},$t=t=>{const e=$e();return e?e.createHTML(t):J(t)},H=(t,e={})=>J(t,e),Pt=t=>{const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"};return t.replace(/[&<>"'`]/g,n=>e[n])},kt=t=>J(t,{stripAllTags:!0}),Pe=t=>Array.isArray(t)?t:[t],S=(t,e)=>{for(const n of t)e(n)},ke=t=>H(t),Ot=(t,e)=>{t.innerHTML=H(e)},Oe=t=>{const e=document.createElement("template");return e.innerHTML=H(t),e.content.firstElementChild??document.createElement("div")},Ne=(t,e,n)=>{if(typeof e=="string"){t.insertAdjacentHTML(n,H(e));return}const r=Pe(e),o=n==="afterbegin"||n==="afterend"?r.slice().reverse():r;S(o,i=>{t.insertAdjacentElement(n,i)})};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,n){return this.element.classList.toggle(e,n),this}attr(e,n){return n===void 0?this.element.getAttribute(e)??"":(this.element.setAttribute(e,n),this)}removeAttr(e){return this.element.removeAttribute(e),this}toggleAttr(e,n){const r=this.element.hasAttribute(e);return n??!r?this.element.setAttribute(e,""):this.element.removeAttribute(e),this}prop(e,n){return n===void 0?this.element[e]:(this.element[e]=n,this)}data(e,n){const r=e.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`);return n===void 0?this.element.getAttribute(`data-${r}`)??"":(this.element.setAttribute(`data-${r}`,n),this)}text(e){return e===void 0?this.element.textContent??"":(this.element.textContent=e,this)}html(e){return Ot(this.element,e),this}htmlUnsafe(e){return this.element.innerHTML=e,this}css(e,n){if(typeof e=="string")return n!==void 0&&this.element.style.setProperty(e,n),this;for(const[r,s]of Object.entries(e))this.element.style.setProperty(r,s);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 n=typeof e=="string"?document.createElement(e):e;return this.element.parentNode?.insertBefore(n,this.element),n.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){const n=typeof e=="string"?Oe(e):e;return this.element.replaceWith(n),new _(n)}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(n=>n!==this.element):[]}next(){return this.element.nextElementSibling}prev(){return this.element.previousElementSibling}on(e,n){return this.element.addEventListener(e,n),this}once(e,n){return this.element.addEventListener(e,n,{once:!0}),this}off(e,n){return this.element.removeEventListener(e,n),this}trigger(e,n){return this.element.dispatchEvent(new CustomEvent(e,{detail:n,bubbles:!0,cancelable:!0})),this}delegate(e,n,r){const s=`${e}:${n}`,o=i=>{const a=i.target.closest(n);a&&this.element.contains(a)&&r(i,a)};return this.delegatedHandlers.has(s)||this.delegatedHandlers.set(s,new Map),this.delegatedHandlers.get(s).set(r,o),this.element.addEventListener(e,o),this}undelegate(e,n,r){const s=`${e}:${n}`,o=this.delegatedHandlers.get(s);if(o){const i=o.get(r);i&&(this.element.removeEventListener(e,i),o.delete(r),o.size===0&&this.delegatedHandlers.delete(s))}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 n=this.element.style.display==="none";return e??n?this.show():this.hide()}focus(){return this.element.focus(),this}blur(){return this.element.blur(),this}val(e){const n=this.element;return e===void 0?n.value??"":(n.value=e,this)}serialize(){const e=this.element;if(e.tagName.toLowerCase()!=="form")return{};const n={},r=new FormData(e);for(const[s,o]of r.entries())if(typeof o=="string")if(s in n){const i=n[s];Array.isArray(i)?i.push(o):n[s]=[i,o]}else n[s]=o;return n}serializeString(){const e=this.element;if(e.tagName.toLowerCase()!=="form")return"";const n=new FormData(e),r=new URLSearchParams;for(const[s,o]of n.entries())typeof o=="string"&&r.append(s,o);return r.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,n){Ne(this.element,e,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 n=this.elements[e];return n?new _(n):void 0}firstEl(){return this.eq(0)}lastEl(){return this.eq(this.elements.length-1)}each(e){return this.elements.forEach((n,r)=>{e(new _(n),r)}),this}map(e){return this.elements.map(e)}filter(e){return new q(this.elements.filter(e))}reduce(e,n){return this.elements.reduce(e,n)}toArray(){return this.elements.map(e=>new _(e))}addClass(...e){return S(this.elements,n=>n.classList.add(...e)),this}removeClass(...e){return S(this.elements,n=>n.classList.remove(...e)),this}toggleClass(e,n){return S(this.elements,r=>r.classList.toggle(e,n)),this}attr(e,n){return n===void 0?this.first()?.getAttribute(e)??"":(S(this.elements,r=>r.setAttribute(e,n)),this)}removeAttr(e){return S(this.elements,n=>n.removeAttribute(e)),this}toggleAttr(e,n){return S(this.elements,r=>{const s=r.hasAttribute(e);n??!s?r.setAttribute(e,""):r.removeAttribute(e)}),this}text(e){return e===void 0?this.first()?.textContent??"":(S(this.elements,n=>{n.textContent=e}),this)}html(e){if(e===void 0)return this.first()?.innerHTML??"";const n=ke(e);return S(this.elements,r=>{r.innerHTML=n}),this}htmlUnsafe(e){return S(this.elements,n=>{n.innerHTML=e}),this}append(e){return this.insertAll(e,"beforeend"),this}prepend(e){return this.insertAll(e,"afterbegin"),this}before(e){return this.insertAll(e,"beforebegin"),this}after(e){return this.insertAll(e,"afterend"),this}css(e,n){return typeof e=="string"?(n!==void 0&&S(this.elements,r=>{r.style.setProperty(e,n)}),this):(S(this.elements,r=>{for(const[s,o]of Object.entries(e))r.style.setProperty(s,o)}),this)}wrap(e){return this.elements.forEach((n,r)=>{const s=typeof e=="string"?document.createElement(e):r===0?e:e.cloneNode(!0);n.parentNode?.insertBefore(s,n),s.appendChild(n)}),this}unwrap(){const e=new Set;for(const n of this.elements)n.parentElement&&e.add(n.parentElement);return e.forEach(n=>{const r=n.parentNode;if(r){for(;n.firstChild;)r.insertBefore(n.firstChild,n);n.remove()}}),this}replaceWith(e){const n=[];return this.elements.forEach((r,s)=>{const o=typeof e=="string"?Oe(e):s===0?e:e.cloneNode(!0);r.replaceWith(o),n.push(o)}),new q(n)}show(e=""){return S(this.elements,n=>{n.removeAttribute("hidden"),n.style.display=e}),this}hide(){return S(this.elements,e=>{e.style.display="none"}),this}on(e,n){return S(this.elements,r=>r.addEventListener(e,n)),this}once(e,n){return S(this.elements,r=>r.addEventListener(e,n,{once:!0})),this}off(e,n){return S(this.elements,r=>r.removeEventListener(e,n)),this}trigger(e,n){return S(this.elements,r=>{r.dispatchEvent(new CustomEvent(e,{detail:n,bubbles:!0,cancelable:!0}))}),this}delegate(e,n,r){const s=`${e}:${n}`;return S(this.elements,o=>{const i=c=>{const l=c.target.closest(n);l&&o.contains(l)&&r(c,l)};this.delegatedHandlers.has(o)||this.delegatedHandlers.set(o,new Map);const a=this.delegatedHandlers.get(o);a.has(s)||a.set(s,new Map),a.get(s).set(r,i),o.addEventListener(e,i)}),this}undelegate(e,n,r){const s=`${e}:${n}`;return S(this.elements,o=>{const i=this.delegatedHandlers.get(o);if(!i)return;const a=i.get(s);if(!a)return;const c=a.get(r);c&&(o.removeEventListener(e,c),a.delete(r),a.size===0&&i.delete(s),i.size===0&&this.delegatedHandlers.delete(o))}),this}remove(){return S(this.elements,e=>e.remove()),this}empty(){return S(this.elements,e=>{e.innerHTML=""}),this}insertAll(e,n){if(typeof e=="string"){const s=ke(e);S(this.elements,o=>{o.insertAdjacentHTML(n,s)});return}const r=Pe(e);this.elements.forEach((s,o)=>{const i=o===0?r:r.map(a=>a.cloneNode(!0));Ne(s,i,n)})}}const Nt=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)},Lt=t=>Array.isArray(t)?new q(t):t instanceof NodeList?new q(Array.from(t)):new q(Array.from(document.querySelectorAll(t)));function Mt(t){return t==null?[]:Array.isArray(t)?t:[t]}function Rt(t){return Array.from(new Set(t))}function Tt(t,e){if(e<=0)return[];const n=[];for(let r=0;r<t.length;r+=e)n.push(t.slice(r,r+e));return n}function _t(t){return t.filter(Boolean)}function Dt(t){const e=[];for(const n of t)Array.isArray(n)?e.push(...n):e.push(n);return e}function jt(t,e){let n;return(...r)=>{n&&clearTimeout(n),n=setTimeout(()=>t(...r),e)}}function Ht(t,e){let n=0;return(...r)=>{const s=Date.now();s-n>=e&&(n=s,t(...r))}}function It(t){let e=!1,n;return(...r)=>(e||(n=t(...r),e=!0),n)}function qt(){}function Ft(t="bQuery"){return`${t}_${Math.random().toString(36).slice(2,9)}`}function zt(t){return new Promise(e=>setTimeout(e,t))}function Wt(t,e){try{return JSON.parse(t)}catch{return e}}function Bt(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}function Qt(t,e){return Math.floor(Math.random()*(e-t+1))+t}function Ut(t,e,n){return Math.min(Math.max(t,e),n)}function Vt(t,e,n,r=!0){return r?t>=e&&t<=n:t>e&&t<n}function Kt(t,e=0){const n=typeof t=="number"?t:Number(t);return Number.isNaN(n)?e:n}function ae(t){return Object.prototype.toString.call(t)==="[object Object]"}function Yt(t){return t==="__proto__"||t==="constructor"||t==="prototype"}function Jt(t){return typeof structuredClone=="function"?structuredClone(t):JSON.parse(JSON.stringify(t))}function Le(...t){const e={};for(const n of t)for(const[r,s]of Object.entries(n))Yt(r)||(ae(s)&&ae(e[r])?e[r]=Le(e[r],s):e[r]=s);return e}function Zt(t,e){const n={};for(const r of e)r in t&&(n[r]=t[r]);return n}function Gt(t,e){const n={...t};for(const r of e)delete n[r];return n}function Xt(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function xt(t){return t&&t.charAt(0).toUpperCase()+t.slice(1)}function en(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function tn(t){return t.replace(/[-_\s]+(.)?/g,(e,n)=>n?n.toUpperCase():"").replace(/^[A-Z]/,e=>e.toLowerCase())}function nn(t,e,n="…"){if(e<=0)return"";if(t.length<=e)return t;const r=Math.max(0,e-n.length);return`${t.slice(0,r)}${n}`}function rn(t){return t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\w\s-]/g,"").trim().replace(/[\s_-]+/g,"-").toLowerCase()}function sn(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function on(t){return typeof Element<"u"&&t instanceof Element}function an(t){return!!(t&&typeof t=="object"&&"elements"in t)}function cn(t){return typeof t=="function"}function ln(t){return typeof t=="string"}function un(t){return typeof t=="number"&&!Number.isNaN(t)}function fn(t){return typeof t=="boolean"}function hn(t){return Array.isArray(t)}function dn(t){return t instanceof Date}function mn(t){return!!(t&&(t instanceof Promise||typeof t=="object"&&"then"in t&&typeof t.then=="function"))}function pn(t){return typeof t=="object"&&t!==null}const yn={clone:Jt,merge:Le,pick:Zt,omit:Gt,hasOwn:Xt,debounce:jt,throttle:Ht,once:It,noop:qt,uid:Ft,isElement:on,isCollection:an,isEmpty:Bt,isPlainObject:ae,isFunction:cn,isString:ln,isNumber:un,isBoolean:fn,isArray:hn,isDate:dn,isPromise:mn,isObject:pn,parseJson:Wt,sleep:zt,randomInt:Qt,clamp:Ut,inRange:Vt,toNumber:Kt,capitalize:xt,toKebabCase:en,toCamelCase:tn,truncate:nn,slugify:rn,escapeRegExp:sn,ensureArray:Mt,unique:Rt,chunk:Tt,compact:_t,flatten:Dt},W=[];let G=0;const ce=new Set,le=new WeakMap,ue=(t,e)=>{W.push(t);try{return e()}finally{W.pop()}},Me=()=>W[W.length-1],gn=t=>{W.push(void 0);try{return t()}finally{W.pop()}},Re=t=>{if(G>0){ce.add(t);return}t()},bn=()=>{for(const t of Array.from(ce))ce.delete(t),t()},wn=()=>{G+=1},vn=()=>{G-=1,G===0&&bn()},Te=(t,e)=>{let n=le.get(t);n||(n=new Set,le.set(t,n)),n.add(e)},X=t=>{const e=le.get(t);if(e){for(const n of e)n.unsubscribe(t);e.clear()}},x=t=>{wn();try{t()}finally{vn()}};class fe{constructor(e){this.compute=e,this.dirty=!0,this.subscribers=new Set,this.markDirty=()=>{this.dirty=!0;const n=Array.from(this.subscribers);for(const r of n)Re(r)}}get value(){const e=Me();return e&&(this.subscribers.add(e),Te(e,this)),this.dirty&&(this.dirty=!1,X(this.markDirty),this.cachedValue=ue(this.markDirty,this.compute)),this.cachedValue}peek(){return this.dirty&&(this.dirty=!1,X(this.markDirty),this.cachedValue=ue(this.markDirty,this.compute)),this.cachedValue}unsubscribe(e){this.subscribers.delete(e)}}const ee=t=>new fe(t);class he{constructor(e){this._value=e,this.subscribers=new Set}get value(){const e=Me();return e&&(this.subscribers.add(e),Te(e,this)),this._value}set value(e){if(Object.is(this._value,e))return;this._value=e;const n=Array.from(this.subscribers);for(const r of n)Re(r)}peek(){return this._value}update(e){this.value=e(this._value)}unsubscribe(e){this.subscribers.delete(e)}}const B=t=>new he(t),k=t=>{let e,n=!1;const r=()=>{n||(e&&e(),X(r),e=ue(r,t))};return r(),()=>{n=!0,e&&e(),X(r)}},Sn=(t,e)=>{let n=!1,r=null;try{if(r=globalThis.localStorage,r){const i=`__bquery_test_${Math.random().toString(36).slice(2,9)}__`,a="__test__";try{r.setItem(i,a),r.getItem(i),n=!0}finally{try{r.removeItem(i)}catch{}}}}catch{n=!1}let s=e;if(n&&r)try{const i=r.getItem(t);i!==null&&(s=JSON.parse(i))}catch{}const o=B(s);return n&&r&&k(()=>{try{r.setItem(t,JSON.stringify(o.value))}catch{}}),o},An=t=>({get value(){return t.value},peek(){return t.peek()}}),te=t=>t instanceof he,_e=t=>t instanceof fe,De=t=>gn(t),En=(t,e,n={})=>{const{immediate:r=!1,equals:s=Object.is}=n;let o,i=!0;return k(()=>{const a=t.value;if(i){i=!1,o=a,r&&e(a,void 0);return}s(a,o)||(e(a,o),o=a)})},Cn=(t,e)=>{const{type:n}=e;if(n===String)return t;if(n===Number)return Number(t);if(n===Boolean){const r=t.trim().toLowerCase();return r===""||r==="true"||r==="1"?!0:r==="false"||r==="0"?!1:!!t}if(n===Object||n===Array)try{return JSON.parse(t)}catch{return t}if(typeof n=="function"){const r=n,s=n;if(e.construct===!0)return Reflect.construct(s,[t]);if(e.construct===!1)return r(t);const o=n.prototype!==void 0&&n.prototype!==null,a=(o?Object.getOwnPropertyNames(n.prototype):[]).length>1,c=o&&n.prototype.constructor!==n,l=/^class\s/.test(Function.prototype.toString.call(n));if(a||c||l)try{return Reflect.construct(s,[t])}catch{return r(t)}try{const d=r(t);if(d===void 0&&o)try{return Reflect.construct(s,[t])}catch{return d}return d}catch(d){if(d instanceof TypeError&&/cannot be invoked without 'new'|is not a function/i.test(d.message))return Reflect.construct(s,[t]);throw d}}return t},$n=(t,e)=>{class n extends HTMLElement{constructor(){super(),this.state={...e.state??{}},this.props={},this.missingRequiredProps=new Set,this.hasMounted=!1,this.attachShadow({mode:"open"}),this.syncProps()}static get observedAttributes(){return Object.keys(e.props??{})}connectedCallback(){try{if(this.missingRequiredProps.size>0)return;this.mount()}catch(s){this.handleError(s)}}mount(){this.hasMounted||(e.beforeMount?.call(this),e.connected?.call(this),this.render(),this.hasMounted=!0)}disconnectedCallback(){try{e.disconnected?.call(this)}catch(s){this.handleError(s)}}attributeChangedCallback(s,o,i){try{this.syncProps(),this.hasMounted?this.render(!0):this.isConnected&&this.missingRequiredProps.size===0&&this.mount()}catch(a){this.handleError(a)}}handleError(s){e.onError?e.onError.call(this,s):console.error(`bQuery component error in <${t}>:`,s)}setState(s,o){this.state[s]=o,this.render(!0)}getState(s){return this.state[s]}syncProps(){const s=e.props??{};for(const[o,i]of Object.entries(s)){const a=this.getAttribute(o);let c;if(a==null?i.required&&i.default===void 0?(this.missingRequiredProps.add(o),c=void 0):c=i.default??void 0:(this.missingRequiredProps.has(o)&&this.missingRequiredProps.delete(o),c=Cn(a,i)),i.validator&&c!==void 0&&!i.validator(c))throw new Error(`bQuery component: validation failed for prop "${o}" with value ${JSON.stringify(c)}`);this.props[o]=c}}render(s=!1){try{if(s&&e.beforeUpdate&&e.beforeUpdate.call(this,this.props)===!1)return;const o=(c,l)=>{this.dispatchEvent(new CustomEvent(c,{detail:l,bubbles:!0,composed:!0}))};if(!this.shadowRoot)return;const i=e.render({props:this.props,state:this.state,emit:o}),a=H(i);if(this.shadowRoot.innerHTML=a,e.styles){const c=document.createElement("style");c.textContent=e.styles,this.shadowRoot.prepend(c)}s&&e.updated?.call(this)}catch(o){this.handleError(o)}}}return n},Pn=(t,e)=>{const n=$n(t,e);customElements.get(t)||customElements.define(t,n)},kn=(t,...e)=>t.reduce((n,r,s)=>`${n}${r}${e[s]??""}`,""),On=(t,...e)=>{const n={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},r=s=>String(s??"").replace(/[&<>"'`]/g,i=>n[i]);return t.reduce((s,o,i)=>`${s}${o}${r(e[i])}`,"")},de=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,je=t=>typeof t=="string"||typeof t=="number",He=t=>t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),Q=(t,e)=>{const r=t.style;if(Array.isArray(e)){const s=e[e.length-1];if(!s)return;for(const[o,i]of Object.entries(s))if(!(o==="offset"||o==="easing"||o==="composite")&&je(i)){const a=o.startsWith("--")?o:He(o);r.setProperty(a,String(i))}return}for(const[s,o]of Object.entries(e)){if(s==="offset"||s==="easing"||s==="composite")continue;const i=Array.isArray(o)?o[o.length-1]:o;if(je(i)){const a=s.startsWith("--")?s:He(s);r.setProperty(a,String(i))}}},ne=(t,e)=>{const{keyframes:n,options:r,commitStyles:s=!0,respectReducedMotion:o=!0,onFinish:i}=e;if(o&&de())return s&&Q(t,n),i?.(),Promise.resolve();const a=t;return typeof a.animate!="function"?(s&&Q(t,n),i?.(),Promise.resolve()):new Promise(c=>{const l=a.animate(n,r);let p=!1;const d=()=>{p||(p=!0,s&&(typeof l.commitStyles=="function"?l.commitStyles():Q(t,n)),l.cancel(),i?.(),c())};l.onfinish=d,l.finished&&l.finished.then(d).catch(d)})},D=t=>Math.min(1,Math.max(0,t)),Ie=t=>D(t),qe=t=>D(t*t),Fe=t=>D(1-(1-t)*(1-t)),ze=t=>D(t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2),We=t=>D(t*t*t),Be=t=>D(1-Math.pow(1-t,3)),Qe=t=>D(t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2),Ue=t=>D(1+2.70158*Math.pow(t-1,3)+1.70158*Math.pow(t-1,2)),Ve=t=>D(t===1?1:1-Math.pow(2,-10*t)),Nn={linear:Ie,easeInQuad:qe,easeOutQuad:Fe,easeInOutQuad:ze,easeInCubic:We,easeOutCubic:Be,easeInOutCubic:Qe,easeOutBack:Ue,easeOutExpo:Ve},me=t=>{const e=t.getBoundingClientRect();return{top:e.top,left:e.left,width:e.width,height:e.height}},pe=(t,e,n={})=>{const{duration:r=300,easing:s="ease-out",onComplete:o}=n,i=me(t);if(i.width===0||i.height===0)return o?.(),Promise.resolve();const a=e.left-i.left,c=e.top-i.top,l=e.width/i.width,p=e.height/i.height;if(a===0&&c===0&&l===1&&p===1)return o?.(),Promise.resolve();const d=t;return typeof d.animate!="function"?(o?.(),Promise.resolve()):(d.style.transform=`translate(${a}px, ${c}px) scale(${l}, ${p})`,d.style.transformOrigin="top left",d.offsetHeight,new Promise(y=>{const u=d.animate([{transform:`translate(${a}px, ${c}px) scale(${l}, ${p})`},{transform:"translate(0, 0) scale(1, 1)"}],{duration:r,easing:s,fill:"forwards"});let m=!1;const f=()=>{m||(m=!0,d.style.transform="",d.style.transformOrigin="",o?.(),y())};u.onfinish=f,u.finished&&u.finished.then(f).catch(f)}))},Ln=async(t,e,n={})=>{await Ke(t,e,n)},Ke=async(t,e,n={})=>{const{stagger:r,...s}=n,o=new Map;for(const c of t)o.set(c,me(c));e();const i=t.length,a=t.map((c,l)=>{const p=o.get(c);if(!p)return Promise.resolve();const d=r?r(l,i):0;return d>0?new Promise(y=>setTimeout(y,d)).then(()=>pe(c,p,s)):pe(c,p,s)});await Promise.all(a)},Mn={fadeIn:(t=0,e=1)=>[{opacity:t},{opacity:e}],fadeOut:(t=1,e=0)=>[{opacity:t},{opacity:e}],slideInUp:(t=16)=>[{opacity:0,transform:`translateY(${t}px)`},{opacity:1,transform:"translateY(0)"}],slideInDown:(t=16)=>[{opacity:0,transform:`translateY(-${t}px)`},{opacity:1,transform:"translateY(0)"}],slideInLeft:(t=16)=>[{opacity:0,transform:`translateX(${t}px)`},{opacity:1,transform:"translateX(0)"}],slideInRight:(t=16)=>[{opacity:0,transform:`translateX(-${t}px)`},{opacity:1,transform:"translateX(0)"}],scaleIn:(t=.95,e=1)=>[{opacity:0,transform:`scale(${t})`},{opacity:1,transform:`scale(${e})`}],scaleOut:(t=1,e=.95)=>[{opacity:1,transform:`scale(${t})`},{opacity:0,transform:`scale(${e})`}],pop:(t=.9,e=1.02,n=1)=>[{opacity:0,transform:`scale(${t})`},{opacity:1,transform:`scale(${e})`,offset:.6},{opacity:1,transform:`scale(${n})`}],rotateIn:(t=6)=>[{opacity:0,transform:`rotate(${t}deg) scale(0.98)`},{opacity:1,transform:"rotate(0deg) scale(1)"}]},Rn=t=>typeof Element<"u"&&t instanceof Element?[t]:Array.from(t),Tn=(t,e)=>{const n=Rn(t);if(!n.length)return()=>{};const{root:r=null,rootMargin:s,threshold:o,once:i=!0,onEnter:a,...c}=e;if(typeof IntersectionObserver>"u")return n.forEach(p=>{a?.(p),ne(p,c)}),()=>{};const l=new IntersectionObserver(p=>{p.forEach(d=>{if(!d.isIntersecting)return;const y=d.target;a?.(y),ne(y,c),i&&l.unobserve(y)})},{root:r,rootMargin:s,threshold:o});return n.forEach(p=>l.observe(p)),()=>l.disconnect()},_n={stiffness:100,damping:10,mass:1,precision:.01},Dn=(t,e={})=>{const{stiffness:n,damping:r,mass:s,precision:o}={..._n,...e};let i=t,a=0,c=t,l=null,p=null,d=null;const y=new Set,u=()=>{for(const f of y)f(i)},m=f=>{const g=d!==null?(f-d)/1e3:.016666666666666666,w=Math.min(g,1/30);d=f;const b=i-c,A=-n*b,$=-r*a,L=(A+$)/s;if(a+=L*w,i+=a*w,u(),Math.abs(a)<o&&Math.abs(b)<o){i=c,a=0,l=null,u(),p?.(),p=null;return}l=requestAnimationFrame(m)};return{to(f){return c=f,l!==null&&cancelAnimationFrame(l),p?.(),d=null,new Promise(g=>{p=g,l=requestAnimationFrame(m)})},current(){return i},stop(){l!==null&&(cancelAnimationFrame(l),l=null),a=0,d=null,p?.(),p=null},onChange(f){return y.add(f),()=>y.delete(f)}}},jn={gentle:{stiffness:80,damping:15},snappy:{stiffness:200,damping:20},bouncy:{stiffness:300,damping:8},stiff:{stiffness:400,damping:30}},Hn=(t,e={})=>{const{start:n=0,from:r="start",easing:s}=e;return(o,i=0)=>{const a=typeof r=="number"?r:r==="center"?(i-1)/2:r==="end"?i-1:0,c=Math.abs(o-a),l=i>1?Math.max(a,i-1-a):1,p=l===0?0:c/l,d=s?s(p)*l:c;return n+d*t}},ye=t=>{if(typeof t=="number")return t;if(typeof t=="string"){const e=t.trim();if(e.endsWith("ms")){const r=Number.parseFloat(e.slice(0,-2));return Number.isFinite(r)?r:0}if(e.endsWith("s")){const r=Number.parseFloat(e.slice(0,-1));return Number.isFinite(r)?r*1e3:0}const n=Number.parseFloat(e);return Number.isFinite(n)?n:0}return 0},In=(t,e)=>{if(typeof t=="number")return t;if(typeof t=="string"){const n=/^([+-])=(\d+(?:\.\d+)?)$/.exec(t);if(n){const r=Number.parseFloat(n[2]);return Number.isFinite(r)?n[1]==="+"?e+r:e-r:e}}return e},qn=t=>{const e=ye(t?.duration),n=ye(t?.endDelay),r=t?.iterations??1;if(r===1/0)return Number.MAX_SAFE_INTEGER;const s=Math.max(0,r);return e*s+n},Ye=t=>{let e=0;return t.map(n=>{const r=In(n.at,e),s=ye(n.options?.delay),o=Math.max(0,r+s),i=qn(n.options),a=o+i;return e=Math.max(e,a),{step:n,start:o,end:a,duration:i}})},Fn=async(t,e={})=>{const{stagger:n,onFinish:r}=e,s=t.length;for(let o=0;o<t.length;o+=1){const i=t[o],a=n?n(o,s):0;a>0&&await new Promise(c=>setTimeout(c,a)),await ne(i.target,i)}r?.()},zn=(t=[],e={})=>{const n=[...t],r=new Set;let s=[],o=0,i=!1,a=!1;const{commitStyles:c=!0,respectReducedMotion:l=!0,onFinish:p}=e,d=()=>{if(!a){if(a=!0,c)for(const u of s){const{animation:m,step:f}=u;typeof m.commitStyles=="function"?m.commitStyles():Q(f.target,f.keyframes),m.cancel()}r.forEach(u=>u()),p?.()}},y=()=>{s.forEach(({animation:f})=>f.cancel()),s=[],a=!1;const u=Ye(n);if(o=u.length?Math.max(...u.map(f=>f.end)):0,l&&de()){c&&u.forEach(({step:f})=>Q(f.target,f.keyframes)),i=!0;return}if(u.some(({step:f})=>typeof f.target.animate!="function")){c&&u.forEach(({step:f})=>Q(f.target,f.keyframes)),i=!0;return}i=!1,s=u.map(({step:f,start:g})=>{const{delay:w,...b}=f.options??{};return{animation:f.target.animate(f.keyframes,{...b,delay:g,fill:b.fill??"both"}),step:f,start:g}})};return{add(u){n.push(u)},duration(){if(!n.length)return 0;if(!s.length){const u=Ye(n);return Math.max(...u.map(m=>m.end))}return o},async play(){if(y(),i||s.length===0){d();return}const u=s.map(m=>m.animation.finished.catch(()=>{}));await Promise.all(u),d()},pause(){i||s.forEach(({animation:u})=>u.pause())},resume(){i||s.forEach(({animation:u})=>u.play())},stop(){s.forEach(({animation:u})=>u.cancel()),s=[],i=!1},seek(u){i||s.forEach(({animation:m})=>{m.currentTime=u})},onFinish(u){return r.add(u),()=>r.delete(u)}}},Wn=async t=>{const e=typeof t=="function"?t:t.update;if(typeof document>"u"){e();return}const n=document;if(n.startViewTransition){await n.startViewTransition(()=>e()).finished;return}e()};class Bn{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((n,r)=>{const s=indexedDB.open(e,1);s.onupgradeneeded=()=>{const o=s.result;o.objectStoreNames.contains(this.storeName)||o.createObjectStore(this.storeName)},s.onsuccess=()=>n(s.result),s.onerror=()=>r(s.error)}),this.dbPromise}async withStore(e,n){const r=await this.openDB();return new Promise((s,o)=>{const a=r.transaction(this.storeName,e).objectStore(this.storeName),c=n(a);c.onsuccess=()=>s(c.result),c.onerror=()=>o(c.error)})}async put(e,n){await this.withStore("readwrite",r=>r.put(n,e))}async get(e){return await this.withStore("readonly",r=>r.get(e))??null}async remove(e){await this.withStore("readwrite",n=>n.delete(e))}async keys(){return(await this.withStore("readonly",n=>n.getAllKeys())).map(n=>String(n))}}const Qn={async open(t){return new Bn(t)}};class Un{constructor(e){this.cache=e}async add(e){await this.cache.add(e)}async addAll(e){await this.cache.addAll(e)}async put(e,n){await this.cache.put(e,n)}async match(e){return this.cache.match(e)}async remove(e){return this.cache.delete(e)}async keys(){return(await this.cache.keys()).map(n=>n.url)}}const Vn={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 Un(e)},async delete(t){return this.isSupported()?caches.delete(t):!1},async keys(){return this.isSupported()?caches.keys():[]}},Kn={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 Je{constructor(e){this.storage=e}async get(e){const n=this.storage.getItem(e);if(n===null)return null;try{return JSON.parse(n)}catch{return n}}async set(e,n){const r=typeof n=="string"?n:JSON.stringify(n);this.storage.setItem(e,r)}async remove(e){this.storage.removeItem(e)}async clear(){this.storage.clear()}async keys(){return Object.keys(this.storage)}}class Yn extends Je{constructor(){super(localStorage)}}class Jn extends Je{constructor(){super(sessionStorage)}}class Zn{constructor(e){this.options=e,this.dbPromise=null}openDB(){return this.dbPromise?this.dbPromise:(this.dbPromise=new Promise((e,n)=>{const r=indexedDB.open(this.options.name,this.options.version??1);r.onupgradeneeded=()=>{const s=r.result;s.objectStoreNames.contains(this.options.store)||s.createObjectStore(this.options.store)},r.onsuccess=()=>e(r.result),r.onerror=()=>n(r.error)}),this.dbPromise)}async withStore(e,n){const r=await this.openDB();return new Promise((s,o)=>{const a=r.transaction(this.options.store,e).objectStore(this.options.store),c=n(a);c.onsuccess=()=>s(c.result),c.onerror=()=>o(c.error)})}async get(e){return await this.withStore("readonly",r=>r.get(e))??null}async set(e,n){await this.withStore("readwrite",r=>r.put(n,e))}async remove(e){await this.withStore("readwrite",n=>n.delete(e))}async clear(){await this.withStore("readwrite",e=>e.clear())}async keys(){return(await this.withStore("readonly",n=>n.getAllKeys())).map(n=>String(n))}}const Gn={local(){return new Yn},session(){return new Jn},indexedDB(t){return new Zn(t)}};let Ze=null;const F=B({path:"",params:{},query:{},matched:null,hash:""}),Ge=ee(()=>F.value),U=()=>Ze,Xe=t=>{Ze=t},re=async(t,e={})=>{const n=U();if(!n)throw new Error("bQuery router: No router initialized. Call createRouter() first.");await n[e.replace?"replace":"push"](t)},Xn=()=>{const t=U();t?t.back():history.back()},xn=()=>{const t=U();t?t.forward():history.forward()},er=(t,e={})=>n=>{n.preventDefault(),re(t,e).catch(r=>{console.error("Navigation failed:",r)})},tr=t=>{const e=t??(typeof document<"u"?document.body:null);if(!e)return()=>{};const n=r=>{if(!(r instanceof MouseEvent)||r.defaultPrevented||r.button!==0||r.ctrlKey||r.metaKey||r.shiftKey||r.altKey||typeof Element>"u"||!(r.target instanceof Element))return;const o=r.target.closest("a");if(!o)return;const a=o.ownerDocument.defaultView?.HTMLAnchorElement??HTMLAnchorElement;if(!(o instanceof a)||o.target||o.hasAttribute("download")||typeof window>"u"||o.origin!==window.location.origin)return;const c=U();if(!c){r.preventDefault(),re(o.pathname+o.search+o.hash).catch(y=>{console.error("Navigation failed:",y)});return}const l=c.base,p=c.hash;let d;if(p&&o.hash&&o.hash.startsWith("#/"))d=o.hash.slice(1);else{let y=o.pathname;l&&l!=="/"&&y.startsWith(l)&&(y=y.slice(l.length)||"/"),d=y+o.search+o.hash}r.preventDefault(),re(d).catch(y=>{console.error("Navigation failed:",y)})};return e.addEventListener("click",n),()=>e.removeEventListener("click",n)},nr=t=>{const e={};return new URLSearchParams(t).forEach((r,s)=>{const o=e[s];o===void 0?e[s]=r:Array.isArray(o)?o.push(r):e[s]=[o,r]}),e},rr=t=>{if(t==="*")return/^.*$/;const e="\0P\0",n="\0W\0";let r=t.replace(/:([a-zA-Z_][a-zA-Z0-9_]*)/g,()=>e);return r=r.replace(/\*/g,n),r=r.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),r=r.replace(/\u0000P\u0000/g,()=>"([^/]+)"),r=r.replace(/\u0000W\u0000/g,".*"),new RegExp(`^${r}$`)},sr=t=>{const e=t.match(/:([a-zA-Z_][a-zA-Z0-9_]*)/g);return e?e.map(n=>n.slice(1)):[]},or=(t,e)=>{for(const n of e){const r=rr(n.path),s=t.match(r);if(s){const o=sr(n.path),i={};return o.forEach((a,c)=>{i[a]=s[c+1]||""}),{matched:n,params:i}}}return null},se=(t,e,n,r)=>{const s=or(t,r);return{path:t,params:s?.params??{},query:nr(e),matched:s?.matched??null,hash:n.replace(/^#/,"")}},xe=(t,e="")=>{const n=[];for(const r of t){const s=r.path==="*"?"*":`${e}${r.path}`.replace(/\/+/g,"/");n.push({...r,path:s}),r.children&&n.push(...xe(r.children,s))}return n},ir=(t,e={})=>{const n=U();if(!n)throw new Error("bQuery router: No router initialized.");const r=n.routes.find(o=>o.name===t);if(!r)throw new Error(`bQuery router: Route "${t}" not found.`);let s=r.path;for(const[o,i]of Object.entries(e))s=s.replace(`:${o}`,encodeURIComponent(i));return s},ar=(t,e=!1)=>{const n=F.value.path;return e?n===t:n.startsWith(t)},cr=(t,e=!1)=>ee(()=>{const n=F.value.path;return e?n===t:n.startsWith(t)}),lr=t=>{const e=U();e&&e.destroy();const{routes:n,base:r="",hash:s=!1}=t,o=[],i=[],a=xe(n),c=()=>{if(s){const m=window.location.hash.slice(1)||"/",[f,g=""]=m.split("#"),[w,b=""]=f.split("?");return{pathname:w,search:b?`?${b}`:"",hash:g?`#${g}`:""}}let u=window.location.pathname;return r&&(u===r||u.startsWith(r+"/"))&&(u=u.slice(r.length)||"/"),{pathname:u,search:window.location.search,hash:window.location.hash}},l=()=>{const{pathname:u,search:m,hash:f}=c(),g=se(u,m,f,a);F.value=g},p=async(u,m)=>{const{pathname:f,search:g,hash:w}=c(),b=se(f,g,w,a),A=new URL(u,window.location.origin),$=se(A.pathname,A.search,A.hash,a);for(const v of o)if(await v($,b)===!1)return;const L=s?`#${u}`:`${r}${u}`;history[m]({},"",L),l();for(const v of i)v(F.value,b)},d=async()=>{const{pathname:u,search:m,hash:f}=c(),g=F.value,w=se(u,m,f,a);for(const b of o)if(await b(w,g)===!1){const $=new URLSearchParams(Object.entries(g.query).flatMap(([N,M])=>Array.isArray(M)?M.map(I=>[N,I]):[[N,M]])).toString(),L=$?`?${$}`:"",v=g.hash?`#${g.hash}`:"",E=s?`#${g.path}${L}${v}`:`${r}${g.path}${L}${v}`;history.replaceState({},"",E);return}l();for(const b of i)b(F.value,g)};window.addEventListener("popstate",d),l();const y={push:u=>p(u,"pushState"),replace:u=>p(u,"replaceState"),back:()=>history.back(),forward:()=>history.forward(),go:u=>history.go(u),beforeEach:u=>(o.push(u),()=>{const m=o.indexOf(u);m>-1&&o.splice(m,1)}),afterEach:u=>(i.push(u),()=>{const m=i.indexOf(u);m>-1&&i.splice(m,1)}),currentRoute:Ge,routes:a,base:r,hash:s,destroy:()=>{window.removeEventListener("popstate",d),o.length=0,i.length=0,Xe(null)}};return Xe(y),y},ur=()=>{if(!(typeof window>"u"))return window.__BQUERY_DEVTOOLS__||(window.__BQUERY_DEVTOOLS__={stores:new Map}),window.__BQUERY_DEVTOOLS__},fr=(t,e)=>{const n=ur();n&&(n.stores.set(t,e),n.onStoreCreated?.(t,e))},hr=t=>{typeof window>"u"||!window.__BQUERY_DEVTOOLS__||window.__BQUERY_DEVTOOLS__.stores.delete(t)},dr=(t,e)=>{typeof window>"u"||window.__BQUERY_DEVTOOLS__?.onStateChange?.(t,e)},et=[],mr=t=>{et.push(t)},pr=(t,e)=>{for(const n of et){const r=n({store:t,options:e});r&&Object.assign(t,r)}},K=new Map,yr=t=>K.has(t),gr=(t,e)=>{K.set(t,e)},tt=t=>K.get(t),br=()=>Array.from(K.keys()),wr=t=>{K.delete(t),hr(t)},nt=t=>t!==null&&typeof t=="object"&&Object.getPrototypeOf(t)===Object.prototype,z=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(z);if(t instanceof Date)return new Date(t.getTime());if(t instanceof Map)return new Map(Array.from(t.entries()).map(([n,r])=>[n,z(r)]));if(t instanceof Set)return new Set(Array.from(t).map(z));const e={};for(const n of Object.keys(t))e[n]=z(t[n]);return e},Y=(t,e)=>{if(t===e)return!0;if(t===null||e===null||typeof t!="object"||typeof e!="object")return!1;if(t instanceof Date&&e instanceof Date)return t.getTime()===e.getTime();if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(const[s,o]of t.entries())if(!e.has(s)||!Y(o,e.get(s)))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(const s of t.values()){let o=!1;for(const i of e.values())if(Y(s,i)){o=!0;break}if(!o)return!1}return!0}if(Array.isArray(t)&&Array.isArray(e))return t.length!==e.length?!1:t.every((s,o)=>Y(s,e[o]));if(Array.isArray(t)!==Array.isArray(e))return!1;const n=Object.keys(t),r=Object.keys(e);return n.length!==r.length?!1:n.every(s=>Y(t[s],e[s]))},vr=(t,e,n)=>{const r=[];for(const s of Object.keys(e)){const o=t[s],i=e[s];n.get(s)===i&&nt(o)&&nt(i)&&!Y(o,i)&&r.push(s)}return r},ge=(()=>{try{const t=globalThis.process;return!(typeof t<"u"&&t.env?.NODE_ENV==="production")}catch{return!0}})(),rt=t=>{const{id:e,state:n,getters:r={},actions:s={}}=t;if(yr(e))return console.warn(`bQuery store: Store "${e}" already exists. Returning existing instance.`),tt(e);const o=n(),i=new Map;for(const u of Object.keys(o))i.set(u,B(o[u]));const a=[],c=()=>De(()=>({...p})),l=()=>{const u=typeof window<"u"&&typeof window.__BQUERY_DEVTOOLS__?.onStateChange=="function";if(a.length===0&&!u)return;const m=c();for(const f of a)f(m);dr(e,m)},p=new Proxy({},{get:(u,m)=>{const f=m;if(i.has(f))return i.get(f).value},ownKeys:()=>Array.from(i.keys()),getOwnPropertyDescriptor:(u,m)=>{if(i.has(m))return{enumerable:!0,configurable:!0}},has:(u,m)=>i.has(m)}),d=new Map,y={};for(const u of Object.keys(o))Object.defineProperty(y,u,{get:()=>i.get(u).value,set:m=>{i.get(u).value=m,l()},enumerable:!0,configurable:!1});for(const u of Object.keys(r)){const m=r[u],f=ee(()=>{const g=p,w=new Proxy({},{get:(b,A)=>{const $=A;if(d.has($))return d.get($).value}});return m(g,w)});d.set(u,f),Object.defineProperty(y,u,{get:()=>f.value,enumerable:!0,configurable:!1})}for(const u of Object.keys(s)){const m=s[u];y[u]=function(...f){const g=new Proxy(y,{get:(w,b)=>typeof b=="string"&&i.has(b)?i.get(b).value:w[b],set:(w,b,A)=>typeof b=="string"&&i.has(b)?(i.get(b).value=A,l(),!0):Reflect.set(w,b,A)});return m.apply(g,f)}}return Object.defineProperties(y,{$id:{value:e,writable:!1,enumerable:!1},$reset:{value:()=>{const u=n();x(()=>{for(const[m,f]of i)f.value=u[m]}),l()},writable:!1,enumerable:!1},$subscribe:{value:u=>(a.push(u),()=>{const m=a.indexOf(u);m>-1&&a.splice(m,1)}),writable:!1,enumerable:!1},$patch:{value:u=>{x(()=>{if(typeof u=="function"){const m=ge?z(c()):null,f=ge?new Map(Array.from(i.entries()).map(([w,b])=>[w,b.value])):null,g=c();if(u(g),ge&&m&&f){const w=vr(m,g,f);w.length>0&&console.warn(`[bQuery store "${e}"] Nested mutation detected in $patch() for keys: ${w.map(String).join(", ")}.
1
+ var bQuery=(function(d){Object.defineProperty(d,Symbol.toStringTag,{value:"Module"});var _e="bquery-sanitizer",Dt=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"]),De=new Set(["script","iframe","frame","frameset","object","embed","applet","link","meta","style","base","template","math","svg","foreignobject","noscript"]),qt=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"]),jt=new Set(["alt","class","dir","height","hidden","href","id","lang","loading","name","rel","role","src","srcset","tabindex","target","title","type","width","aria-*"]),It=["on","formaction","xlink:","xmlns:"],Ht=["javascript:","data:","vbscript:","file:"],zt=(e,t,r)=>{const n=e.toLowerCase();for(const s of It)if(n.startsWith(s))return!1;return r&&n.startsWith("data-")||n.startsWith("aria-")?!0:t.has(n)},Bt=e=>{const t=e.toLowerCase().trim();return!qt.has(t)},Ft=e=>e.replace(/[\u0000-\u001F\u007F]+/g,"").replace(/[\u200B-\u200D\uFEFF\u2028\u2029]+/g,"").replace(/\\u[\da-fA-F]{4}/g,"").replace(/\s+/g,"").toLowerCase(),qe=e=>{const t=Ft(e);for(const r of Ht)if(t.startsWith(r))return!1;return!0},Ut=e=>{const t=e.split(",");for(const r of t){const n=r.trim().split(/\s+/)[0];if(n&&!qe(n))return!1}return!0},xt=e=>{try{const t=e.trim();if(t.startsWith("//"))return!0;const r=t.toLowerCase();return/^[a-z][a-z0-9+.-]*:/i.test(t)&&!r.startsWith("http://")&&!r.startsWith("https://")?!0:!r.startsWith("http://")&&!r.startsWith("https://")?!1:typeof window>"u"||!window.location?!0:new URL(t,window.location.href).origin!==window.location.origin}catch{return!0}},Wt=e=>new DOMParser().parseFromString(e,"text/html"),je=e=>{const t=(typeof e=="string"?e:String(e??"")).trim(),r=document.createDocumentFragment();if(t.length===0)return r;if(!(t.includes("<")||t.includes(">")))return r.appendChild(document.createTextNode(t)),r;const n=Wt(t).body;if(!n)return r;for(;n.firstChild;)r.appendChild(n.firstChild);return r},te=(e,t={})=>{const{allowTags:r=[],allowAttributes:n=[],allowDataAttributes:s=!0,stripAllTags:a=!1}=t,i=new Set([...Dt,...r.map(f=>f.toLowerCase())].filter(f=>!De.has(f))),o=new Set([...jt,...n.map(f=>f.toLowerCase())]),c=je(e);if(a)return c.textContent??"";const l=document.createTreeWalker(c,NodeFilter.SHOW_ELEMENT),h=[];for(;l.nextNode();){const f=l.currentNode,m=f.tagName.toLowerCase();if(De.has(m)){h.push(f);continue}if(!i.has(m)){h.push(f);continue}const v=[];for(const g of Array.from(f.attributes)){const b=g.name.toLowerCase();if(!zt(b,o,s)){v.push(g.name);continue}if((b==="id"||b==="name")&&!Bt(g.value)){v.push(g.name);continue}if((b==="href"||b==="src"||b==="action")&&!qe(g.value)){v.push(g.name);continue}b==="srcset"&&!Ut(g.value)&&v.push(g.name)}for(const g of v)f.removeAttribute(g);if(m==="a"){const g=f.getAttribute("href"),b=f.getAttribute("target")?.toLowerCase()==="_blank",A=g&&xt(g);if(b||A){const D=f.getAttribute("rel"),L=new Set(D?D.split(/\s+/).filter(Boolean):[]);L.add("noopener"),L.add("noreferrer"),f.setAttribute("rel",Array.from(L).join(" "))}}}for(const f of h)f.remove();const p=f=>{const m=document.createElement("div");return m.appendChild(f.cloneNode(!0)),m.innerHTML},y=p(c),u=p(je(y));return y!==u?c.textContent??"":u},Ie=1024,He=8192,Qt=(e=16)=>{if(!Number.isInteger(e)||e<1)throw new RangeError("generateNonce length must be a positive integer");if(e>Ie)throw new RangeError(`generateNonce length must not exceed ${Ie}`);if(typeof globalThis.crypto>"u"||typeof globalThis.crypto.getRandomValues!="function")throw new Error("generateNonce requires crypto.getRandomValues (not available in this environment)");if(typeof globalThis.btoa!="function")throw new Error("generateNonce requires btoa (not available in this environment)");const t=new Uint8Array(e);globalThis.crypto.getRandomValues(t);let r="";for(let n=0;n<t.length;n+=He){const s=t.subarray(n,Math.min(n+He,t.length));r+=String.fromCharCode(...s)}return globalThis.btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},Vt=e=>{if(typeof document>"u")return!1;const t=document.querySelector('meta[http-equiv="Content-Security-Policy"]');return t?(t.getAttribute("content")??"").includes(e):!1},re=null,ze=!1,Kt=()=>typeof window<"u"&&typeof window.trustedTypes<"u",Be=()=>{if(re)return re;if(ze||typeof window>"u")return null;const e=window;if(!e.trustedTypes)return null;ze=!0;try{return re=e.trustedTypes.createPolicy(_e,{createHTML:t=>te(t)}),re}catch(t){const r=t instanceof Error?t.message:String(t);return console.warn(`bQuery: Could not create Trusted Types policy "${_e}": ${r}`),null}},Jt=e=>{const t=Be();return t?t.createHTML(e):te(e)},j=(e,t={})=>te(e,t),Fe=e=>{const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"};return e.replace(/[&<>"'`]/g,r=>t[r])},Gt=e=>te(e,{stripAllTags:!0}),Ue=e=>Array.isArray(e)?e:[e],S=(e,t)=>{for(const r of e)t(r)},xe=e=>j(e),Yt=(e,t)=>{e.innerHTML=j(t)},We=e=>{const t=document.createElement("template");return t.innerHTML=j(e),t.content.firstElementChild??document.createElement("div")},Qe=(e,t,r)=>{if(typeof t=="string"){e.insertAdjacentHTML(r,j(t));return}const n=Ue(t);S(r==="afterbegin"||r==="afterend"?n.slice().reverse():n,s=>{e.insertAdjacentElement(r,s)})},F=class Ne{constructor(t){this.element=t,this.delegatedHandlers=new Map}get raw(){return this.element}get node(){return this.element}addClass(...t){return this.element.classList.add(...t),this}removeClass(...t){return this.element.classList.remove(...t),this}toggleClass(t,r){return this.element.classList.toggle(t,r),this}attr(t,r){return r===void 0?this.element.getAttribute(t)??"":(this.element.setAttribute(t,r),this)}removeAttr(t){return this.element.removeAttribute(t),this}toggleAttr(t,r){const n=this.element.hasAttribute(t);return r??!n?this.element.setAttribute(t,""):this.element.removeAttribute(t),this}prop(t,r){return r===void 0?this.element[t]:(this.element[t]=r,this)}data(t,r){const n=t.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`);return r===void 0?this.element.getAttribute(`data-${n}`)??"":(this.element.setAttribute(`data-${n}`,r),this)}text(t){return t===void 0?this.element.textContent??"":(this.element.textContent=t,this)}html(t){return Yt(this.element,t),this}htmlUnsafe(t){return this.element.innerHTML=t,this}css(t,r){if(typeof t=="string"){if(r!==void 0)return this.element.style.setProperty(t,r),this;const n=this.element.ownerDocument?.defaultView;return!n||typeof n.getComputedStyle!="function"?"":n.getComputedStyle(this.element).getPropertyValue(t)}for(const[n,s]of Object.entries(t))this.element.style.setProperty(n,s);return this}append(t){return this.insertContent(t,"beforeend"),this}prepend(t){return this.insertContent(t,"afterbegin"),this}before(t){return this.insertContent(t,"beforebegin"),this}after(t){return this.insertContent(t,"afterend"),this}wrap(t){const r=typeof t=="string"?document.createElement(t):t;return this.element.parentNode?.insertBefore(r,this.element),r.appendChild(this.element),this}unwrap(){const t=this.element.parentElement;return t&&t.parentNode&&(t.parentNode.insertBefore(this.element,t),t.remove()),this}replaceWith(t){const r=typeof t=="string"?We(t):t;return this.element.replaceWith(r),new Ne(r)}scrollTo(t={behavior:"smooth"}){return this.element.scrollIntoView(t),this}remove(){return this.element.remove(),this}empty(){return this.element.innerHTML="",this}clone(t=!0){return new Ne(this.element.cloneNode(t))}find(t){return Array.from(this.element.querySelectorAll(t))}findOne(t){return this.element.querySelector(t)}closest(t){return this.element.closest(t)}parent(){return this.element.parentElement}children(){return Array.from(this.element.children)}siblings(){const t=this.element.parentElement;return t?Array.from(t.children).filter(r=>r!==this.element):[]}next(){return this.element.nextElementSibling}prev(){return this.element.previousElementSibling}on(t,r){return this.element.addEventListener(t,r),this}once(t,r){return this.element.addEventListener(t,r,{once:!0}),this}off(t,r){return this.element.removeEventListener(t,r),this}trigger(t,r){return this.element.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,cancelable:!0})),this}delegate(t,r,n){const s=`${t}:${r}`,a=i=>{const o=i.target.closest(r);o&&this.element.contains(o)&&n(i,o)};return this.delegatedHandlers.has(s)||this.delegatedHandlers.set(s,new Map),this.delegatedHandlers.get(s).set(n,a),this.element.addEventListener(t,a),this}undelegate(t,r,n){const s=`${t}:${r}`,a=this.delegatedHandlers.get(s);if(a){const i=a.get(n);i&&(this.element.removeEventListener(t,i),a.delete(n),a.size===0&&this.delegatedHandlers.delete(s))}return this}matches(t){return this.element.matches(t)}is(t){return this.matches(t)}hasClass(t){return this.element.classList.contains(t)}show(t=""){return this.element.removeAttribute("hidden"),this.element.style.display=t,this}hide(){return this.element.style.display="none",this}toggle(t){const r=this.element.style.display==="none";return t??r?this.show():this.hide()}focus(){return this.element.focus(),this}blur(){return this.element.blur(),this}val(t){const r=this.element;return t===void 0?r.value??"":(r.value=t,this)}serialize(){const t=this.element;if(t.tagName.toLowerCase()!=="form")return{};const r={},n=new FormData(t);for(const[s,a]of n.entries())if(typeof a=="string")if(s in r){const i=r[s];Array.isArray(i)?i.push(a):r[s]=[i,a]}else r[s]=a;return r}serializeString(){const t=this.element;if(t.tagName.toLowerCase()!=="form")return"";const r=new FormData(t),n=new URLSearchParams;for(const[s,a]of r.entries())typeof a=="string"&&n.append(s,a);return n.toString()}rect(){return this.element.getBoundingClientRect()}offset(){const t=this.element;return{width:t.offsetWidth,height:t.offsetHeight,top:t.offsetTop,left:t.offsetLeft}}insertContent(t,r){Qe(this.element,t,r)}},ne=class ve{constructor(t){this.elements=t,this.delegatedHandlers=new WeakMap}get length(){return this.elements.length}first(){return this.elements[0]}eq(t){const r=this.elements[t];return r?new F(r):void 0}firstEl(){return this.eq(0)}lastEl(){return this.eq(this.elements.length-1)}each(t){return this.elements.forEach((r,n)=>{t(new F(r),n)}),this}map(t){return this.elements.map(t)}filter(t){return new ve(this.elements.filter(t))}reduce(t,r){return this.elements.reduce(t,r)}toArray(){return this.elements.map(t=>new F(t))}addClass(...t){return S(this.elements,r=>r.classList.add(...t)),this}removeClass(...t){return S(this.elements,r=>r.classList.remove(...t)),this}toggleClass(t,r){return S(this.elements,n=>n.classList.toggle(t,r)),this}attr(t,r){return r===void 0?this.first()?.getAttribute(t)??"":(S(this.elements,n=>n.setAttribute(t,r)),this)}removeAttr(t){return S(this.elements,r=>r.removeAttribute(t)),this}toggleAttr(t,r){return S(this.elements,n=>{const s=n.hasAttribute(t);r??!s?n.setAttribute(t,""):n.removeAttribute(t)}),this}text(t){return t===void 0?this.first()?.textContent??"":(S(this.elements,r=>{r.textContent=t}),this)}html(t){if(t===void 0)return this.first()?.innerHTML??"";const r=xe(t);return S(this.elements,n=>{n.innerHTML=r}),this}htmlUnsafe(t){return S(this.elements,r=>{r.innerHTML=t}),this}append(t){return this.insertAll(t,"beforeend"),this}prepend(t){return this.insertAll(t,"afterbegin"),this}before(t){return this.insertAll(t,"beforebegin"),this}after(t){return this.insertAll(t,"afterend"),this}css(t,r){if(typeof t=="string"){if(r!==void 0)return S(this.elements,a=>{a.style.setProperty(t,r)}),this;const n=this.first();if(!n)return"";const s=n.ownerDocument?.defaultView;return!s||typeof s.getComputedStyle!="function"?"":s.getComputedStyle(n).getPropertyValue(t)}return S(this.elements,n=>{for(const[s,a]of Object.entries(t))n.style.setProperty(s,a)}),this}wrap(t){return this.elements.forEach((r,n)=>{const s=typeof t=="string"?document.createElement(t):n===0?t:t.cloneNode(!0);r.parentNode?.insertBefore(s,r),s.appendChild(r)}),this}unwrap(){const t=new Set;for(const r of this.elements)r.parentElement&&t.add(r.parentElement);return t.forEach(r=>{const n=r.parentNode;if(n){for(;r.firstChild;)n.insertBefore(r.firstChild,r);r.remove()}}),this}replaceWith(t){const r=[];return this.elements.forEach((n,s)=>{const a=typeof t=="string"?We(t):s===0?t:t.cloneNode(!0);n.replaceWith(a),r.push(a)}),new ve(r)}show(t=""){return S(this.elements,r=>{r.removeAttribute("hidden"),r.style.display=t}),this}hide(){return S(this.elements,t=>{t.style.display="none"}),this}on(t,r){return S(this.elements,n=>n.addEventListener(t,r)),this}once(t,r){return S(this.elements,n=>n.addEventListener(t,r,{once:!0})),this}off(t,r){return S(this.elements,n=>n.removeEventListener(t,r)),this}trigger(t,r){return S(this.elements,n=>{n.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,cancelable:!0}))}),this}delegate(t,r,n){const s=`${t}:${r}`;return S(this.elements,a=>{const i=c=>{const l=c.target.closest(r);l&&a.contains(l)&&n(c,l)};this.delegatedHandlers.has(a)||this.delegatedHandlers.set(a,new Map);const o=this.delegatedHandlers.get(a);o.has(s)||o.set(s,new Map),o.get(s).set(n,i),a.addEventListener(t,i)}),this}undelegate(t,r,n){const s=`${t}:${r}`;return S(this.elements,a=>{const i=this.delegatedHandlers.get(a);if(!i)return;const o=i.get(s);if(!o)return;const c=o.get(n);c&&(a.removeEventListener(t,c),o.delete(n),o.size===0&&i.delete(s),i.size===0&&this.delegatedHandlers.delete(a))}),this}find(t){const r=new Set,n=[];for(const s of this.elements){const a=s.querySelectorAll(t);for(let i=0;i<a.length;i++)r.has(a[i])||(r.add(a[i]),n.push(a[i]))}return new ve(n)}remove(){return S(this.elements,t=>t.remove()),this}empty(){return S(this.elements,t=>{t.innerHTML=""}),this}insertAll(t,r){if(typeof t=="string"){const s=xe(t);S(this.elements,a=>{a.insertAdjacentHTML(r,s)});return}const n=Ue(t);this.elements.forEach((s,a)=>{Qe(s,a===0?n:n.map(i=>i.cloneNode(!0)),r)})}},Zt=e=>{if(typeof e!="string")return new F(e);const t=document.querySelector(e);if(!t)throw new Error(`bQuery: element not found for selector "${e}"`);return new F(t)},Xt=e=>Array.isArray(e)?new ne(e):e instanceof NodeList?new ne(Array.from(e)):new ne(Array.from(document.querySelectorAll(e)));function er(e){return e==null?[]:Array.isArray(e)?e:[e]}function tr(e){return Array.from(new Set(e))}function rr(e,t){if(t<=0)return[];const r=[];for(let n=0;n<e.length;n+=t)r.push(e.slice(n,n+t));return r}function nr(e){return e.filter(Boolean)}function sr(e){const t=[];for(const r of e)Array.isArray(r)?t.push(...r):t.push(r);return t}function ar(e,t){let r;return Object.assign((...n)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...n)},t)},{cancel:()=>{r!==void 0&&(clearTimeout(r),r=void 0)}})}function ir(e,t){let r=0;return Object.assign((...n)=>{const s=Date.now();s-r>=t&&(r=s,e(...n))},{cancel:()=>{r=0}})}function or(e){let t=!1,r;return(...n)=>(t||(r=e(...n),t=!0),r)}function cr(){}function lr(e="bQuery"){return`${e}_${Math.random().toString(36).slice(2,9)}`}function ur(e){return new Promise(t=>setTimeout(t,e))}function fr(e,t){try{return JSON.parse(e)}catch{return t}}function dr(e){return e==null?!0:typeof e=="string"?e.trim().length===0:Array.isArray(e)?e.length===0:typeof e=="object"?Object.keys(e).length===0:!1}function hr(e,t){return Math.floor(Math.random()*(t-e+1))+e}function mr(e,t,r){return Math.min(Math.max(e,t),r)}function pr(e,t,r,n=!0){return n?e>=t&&e<=r:e>t&&e<r}function yr(e,t=0){const r=typeof e=="number"?e:Number(e);return Number.isNaN(r)?t:r}function se(e){return Object.prototype.toString.call(e)==="[object Object]"}function gr(e){return e==="__proto__"||e==="constructor"||e==="prototype"}function vr(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function ae(...e){const t={};for(const r of e)for(const[n,s]of Object.entries(r))gr(n)||(se(s)&&se(t[n])?t[n]=ae(t[n],s):t[n]=s);return t}function br(e,t){const r={};for(const n of t)n in e&&(r[n]=e[n]);return r}function wr(e,t){const r={...e};for(const n of t)delete r[n];return r}function Sr(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ar(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function Er(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function $r(e){return e.replace(/[-_\s]+(.)?/g,(t,r)=>r?r.toUpperCase():"").replace(/^[A-Z]/,t=>t.toLowerCase())}function kr(e,t,r="…"){if(t<=0)return"";if(e.length<=t)return e;const n=Math.max(0,t-r.length);return`${e.slice(0,n)}${r}`}function Cr(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\w\s-]/g,"").trim().replace(/[\s_-]+/g,"-").toLowerCase()}function Pr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Or(e){return typeof Element<"u"&&e instanceof Element}function Rr(e){return!!(e&&typeof e=="object"&&"elements"in e)}function Tr(e){return typeof e=="function"}function Lr(e){return typeof e=="string"}function Mr(e){return typeof e=="number"&&!Number.isNaN(e)}function Nr(e){return typeof e=="boolean"}function _r(e){return Array.isArray(e)}function Dr(e){return e instanceof Date}function qr(e){return!!(e&&(e instanceof Promise||typeof e=="object"&&"then"in e&&typeof e.then=="function"))}function jr(e){return typeof e=="object"&&e!==null}var Ir={clone:vr,merge:ae,pick:br,omit:wr,hasOwn:Sr,debounce:ar,throttle:ir,once:or,noop:cr,uid:lr,isElement:Or,isCollection:Rr,isEmpty:dr,isPlainObject:se,isFunction:Tr,isString:Lr,isNumber:Mr,isBoolean:Nr,isArray:_r,isDate:Dr,isPromise:qr,isObject:jr,parseJson:fr,sleep:ur,randomInt:hr,clamp:mr,inRange:pr,toNumber:yr,capitalize:Ar,toKebabCase:Er,toCamelCase:$r,truncate:kr,slugify:Cr,escapeRegExp:Pr,ensureArray:er,unique:tr,chunk:rr,compact:nr,flatten:sr},U=[],Y=0,be=new Set,ie=new WeakMap,we=(e,t)=>{U.push(e);try{return t()}finally{U.pop()}},Ve=()=>U[U.length-1],Hr=e=>{U.push(void 0);try{return e()}finally{U.pop()}},Ke=e=>{if(Y>0){be.add(e);return}e()},zr=()=>{for(const e of Array.from(be)){be.delete(e);try{e()}catch(t){console.error("bQuery reactive: Error in observer during batch flush",t)}}},Br=()=>{Y+=1},Fr=()=>{Y<=0||(Y-=1,Y===0&&zr())},Je=(e,t)=>{let r=ie.get(e);r||(r=new Set,ie.set(e,r)),r.add(t)},Ur=(e,t)=>{const r=ie.get(e);r&&r.delete(t)},oe=e=>{const t=ie.get(e);if(t){for(const r of t)r.unsubscribe(e);t.clear()}},ce=e=>{Br();try{e()}finally{Fr()}},Ge={fetch:{headers:{},parseAs:"json"},cookies:{path:"/",sameSite:"Lax",secure:!1},announcer:{politeness:"polite",atomic:!0,delay:16,clearDelay:1e3},pageMeta:{},transitions:{skipOnReducedMotion:!1,classes:[],types:[]},components:{prefix:"bq"}},Z=e=>{if(typeof Headers<"u"&&e instanceof Headers)return new Headers(e);if(Array.isArray(e))return e.map(t=>Z(t));if(se(e)){const t={};for(const[r,n]of Object.entries(e))t[r]=Z(n);return t}return e},Se=Z(Ge),xr=e=>(Se=Z(ae(Ge,Se,e)),I()),I=()=>Z(Se),Ae=class{constructor(e){this.compute=e,this.dirty=!0,this.subscribers=new Set,this.markDirty=()=>{this.dirty=!0;const t=Array.from(this.subscribers);for(const r of t)Ke(r)}}get value(){const e=Ve();return e&&(this.subscribers.add(e),Je(e,this)),this.dirty&&(this.dirty=!1,oe(this.markDirty),this.cachedValue=we(this.markDirty,this.compute)),this.cachedValue}peek(){return this.dirty&&(this.dirty=!1,oe(this.markDirty),this.cachedValue=we(this.markDirty,this.compute)),this.cachedValue}unsubscribe(e){this.subscribers.delete(e)}},x=e=>new Ae(e),C=e=>{let t,r=!1;const n=()=>{if(t){try{t()}catch(a){console.error("bQuery reactive: Error in effect cleanup",a)}t=void 0}},s=()=>{if(!r){n(),oe(s);try{t=we(s,e)}catch(a){console.error("bQuery reactive: Error in effect",a)}}};return s(),()=>{r=!0,n(),oe(s)}},Ee=class{constructor(e){this._value=e,this.subscribers=new Set}get value(){const e=Ve();return e&&(this.subscribers.add(e),Je(e,this)),this._value}set value(e){if(Object.is(this._value,e))return;this._value=e;const t=Array.from(this.subscribers);for(const r of t)Ke(r)}peek(){return this._value}update(e){this.value=e(this._value)}dispose(){for(const e of this.subscribers)Ur(e,this);this.subscribers.clear()}unsubscribe(e){this.subscribers.delete(e)}},T=e=>new Ee(e),le=e=>Hr(e),Wr=e=>{if(e instanceof Error)return e;if(typeof e=="string")return new Error(e);try{return new Error(JSON.stringify(e))}catch{return new Error(String(e))}},Qr=e=>typeof e=="function"?e():e.value,Ye=(...e)=>{const t=new Headers;for(const r of e)r&&new Headers(r).forEach((n,s)=>{t.set(s,n)});return t},Vr=e=>typeof e=="string"||e instanceof Blob||e instanceof FormData||e instanceof URLSearchParams||typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer||typeof ReadableStream<"u"&&e instanceof ReadableStream?!0:typeof e=="object"&&e!==null&&ArrayBuffer.isView(e),Kr=(e,t)=>e==null||Vr(e)?e:(t.has("content-type")||t.set("content-type","application/json"),JSON.stringify(e)),Jr=e=>typeof e=="function"?e():e,Gr=(e,t)=>{for(const[r,n]of Object.entries(t))if(n!=null){if(Array.isArray(n)){for(const s of n)s!=null&&e.searchParams.append(r,String(s));continue}e.searchParams.set(r,String(n))}},Yr=(e,t)=>{const r=typeof window<"u"&&/^https?:/i.test(window.location.href)?window.location.href:"http://localhost",n=t?new URL(t,r).toString():r;return e instanceof URL?new URL(e.toString(),n):new URL(e,n)},Zr=async(e,t)=>{if(t==="response")return e;if(t==="text")return await e.text();if(t==="blob")return await e.blob();if(t==="arrayBuffer")return await e.arrayBuffer();if(t==="formData")return await e.formData();const r=await e.text();if(r)try{return JSON.parse(r)}catch(n){const s=e.url?` for ${e.url}`:"";throw new Error(`Failed to parse JSON response${s} (status ${e.status}): ${n instanceof Error?n.message:String(n)}`)}},$e=e=>{const t=e?.trim();return t?t.toUpperCase():void 0},Xr=(e,t,r)=>{const n=t instanceof Request?$e(t.method):void 0;return e??n??(r?"POST":void 0)},en=(e,t,r)=>e||(t instanceof Request?void 0:r),tn=e=>{const t=$e(e.method);let r;if(t!=="GET"&&t!=="HEAD"&&!e.bodyUsed)try{r=e.clone().body??void 0}catch{r=void 0}return{method:t,headers:e.headers,body:r,cache:e.cache,credentials:e.credentials,integrity:e.integrity,keepalive:e.keepalive,mode:e.mode,redirect:e.redirect,referrer:e.referrer,referrerPolicy:e.referrerPolicy,signal:e.signal}},Ze=(e,t={})=>{const r=t.immediate??!0,n=T(t.defaultValue),s=T(null),a=T("idle"),i=x(()=>a.value==="pending");let o=0,c=!1,l=()=>{};const h=()=>{o+=1,n.value=t.defaultValue,s.value=null,a.value="idle"},p=()=>{c||(c=!0,o+=1,l())},y=async()=>{if(c)return n.peek();const u=++o;a.value="pending",s.value=null;try{const f=await e(),m=t.transform?t.transform(f):f;return c||u!==o?n.peek():(n.value=m,a.value="success",t.onSuccess?.(m),m)}catch(f){const m=Wr(f);return c||u!==o||(s.value=m,a.value="error",t.onError?.(m)),n.peek()}};if(t.watch?.length){let u=!1;l=C(()=>{for(const f of t.watch??[])Qr(f);if(!u){u=!0,r&&le(()=>y());return}le(()=>y())})}else r&&y();return{data:n,error:s,status:a,pending:i,execute:y,refresh:y,clear:h,dispose:p}},Xe=(e,t={})=>{const r=I().fetch,n=t.parseAs??r?.parseAs??"json",s=t.fetcher??fetch;return Ze(async()=>{const a=Jr(e),i=typeof a=="string"||a instanceof URL?Yr(a,t.baseUrl??r?.baseUrl):a instanceof Request&&t.query?new URL(a.url):null;i&&t.query&&Gr(i,t.query);const o=Ye(r?.headers,a instanceof Request?a.headers:void 0,t.headers),c=t.body!=null,l=$e(t.method),h=Xr(l,a,c),p=h==="GET"||h==="HEAD"?h:null;if(c&&p)throw new Error(`Cannot send a request body with ${p} requests`);const y=en(l,a,h),u={...t,method:y,headers:o,body:Kr(t.body,o)};delete u.baseUrl,delete u.query,delete u.parseAs,delete u.fetcher,delete u.defaultValue,delete u.immediate,delete u.watch,delete u.transform,delete u.onSuccess,delete u.onError;let f=i??a;a instanceof Request&&i&&i.toString()!==a.url&&(f=new Request(i.toString(),tn(a)));const m=await s(f,u);if(!m.ok)throw Object.assign(new Error(`Request failed with status ${m.status}`),{response:m,status:m.status,statusText:m.statusText});return Zr(m,n)},t)};function rn(e={}){return(t,r={})=>{const n=e,s=ae({},n.query??{},r.query??{});return Xe(t,{...n,...r,headers:Ye(n.headers,r.headers),query:Object.keys(s).length>0?s:void 0})}}var nn=(e,t)=>{const r=x(e);return{get value(){return r.value},set value(n){t(n)},peek(){return r.peek()}}},sn=(e,t)=>{let r=!1,n=null;try{if(n=globalThis.localStorage,n){const i=`__bquery_test_${Math.random().toString(36).slice(2,9)}__`,o="__test__";try{n.setItem(i,o),n.getItem(i),r=!0}finally{try{n.removeItem(i)}catch{}}}}catch{r=!1}let s=t;if(r&&n)try{const i=n.getItem(e);i!==null&&(s=JSON.parse(i))}catch{}const a=T(s);return r&&n&&C(()=>{try{n.setItem(e,JSON.stringify(a.value))}catch{}}),a},an=e=>({get value(){return e.value},peek(){return e.peek()}}),ue=e=>e instanceof Ee,et=e=>e instanceof Ae,on=(e,t,r={})=>{const{immediate:n=!1,equals:s=Object.is}=r;let a,i=!0;return C(()=>{const o=e.value;if(i){i=!1,a=o,n&&t(o,void 0);return}s(o,a)||(t(o,a),a=o)})},cn=(e,t)=>{const{type:r}=t;if(r===String)return e;if(r===Number)return Number(e);if(r===Boolean){const n=e.trim().toLowerCase();return n===""||n==="true"||n==="1"?!0:n==="false"||n==="0"?!1:!!e}if(r===Object||r===Array)try{return JSON.parse(e)}catch{return e}if(typeof r=="function"){const n=r,s=r;if(t.construct===!0)return Reflect.construct(s,[e]);if(t.construct===!1)return n(e);const a=r.prototype!==void 0&&r.prototype!==null,i=(a?Object.getOwnPropertyNames(r.prototype):[]).length>1,o=a&&r.prototype.constructor!==r,c=/^class\s/.test(Function.prototype.toString.call(r));if(i||o||c)try{return Reflect.construct(s,[e])}catch{return n(e)}try{const l=n(e);if(l===void 0&&a)try{return Reflect.construct(s,[e])}catch{return l}return l}catch(l){if(l instanceof TypeError&&/cannot be invoked without 'new'|is not a function/i.test(l.message))return Reflect.construct(s,[e]);throw l}}return e},ln=(e,t)=>{class r extends HTMLElement{constructor(){super(),this.state={...t.state??{}},this.props={},this.missingRequiredProps=new Set,this.hasMounted=!1,this.attachShadow({mode:"open"}),this.syncProps()}static get observedAttributes(){return Object.keys(t.props??{})}connectedCallback(){try{if(this.missingRequiredProps.size>0)return;this.mount()}catch(s){this.handleError(s)}}mount(){this.hasMounted||(t.beforeMount?.call(this),t.connected?.call(this),this.render(),this.hasMounted=!0)}disconnectedCallback(){try{t.disconnected?.call(this)}catch(s){this.handleError(s)}}attributeChangedCallback(s,a,i){try{this.syncProps(),this.hasMounted?this.render(!0):this.isConnected&&this.missingRequiredProps.size===0&&this.mount()}catch(o){this.handleError(o)}}handleError(s){t.onError?t.onError.call(this,s):console.error(`bQuery component error in <${e}>:`,s)}setState(s,a){this.state[s]=a,this.render(!0)}getState(s){return this.state[s]}syncProps(){const s=t.props??{};for(const[a,i]of Object.entries(s)){const o=this.getAttribute(a);let c;if(o==null?i.required&&i.default===void 0?(this.missingRequiredProps.add(a),c=void 0):c=i.default??void 0:(this.missingRequiredProps.has(a)&&this.missingRequiredProps.delete(a),c=cn(o,i)),i.validator&&c!==void 0&&!i.validator(c))throw new Error(`bQuery component: validation failed for prop "${a}" with value ${JSON.stringify(c)}`);this.props[a]=c}}render(s=!1){try{if(s&&t.beforeUpdate&&t.beforeUpdate.call(this,this.props)===!1)return;const a=(o,c)=>{this.dispatchEvent(new CustomEvent(o,{detail:c,bubbles:!0,composed:!0}))};if(!this.shadowRoot)return;const i=j(t.render({props:this.props,state:this.state,emit:a}),{allowTags:["slot"],allowAttributes:["part","disabled","checked","placeholder","value","rows","cols","readonly","required","maxlength","minlength","max","min","step","pattern","autocomplete","autofocus","for","multiple","selected","wrap"]});if(this.shadowRoot.innerHTML=i,t.styles){const o=document.createElement("style");o.textContent=t.styles,this.shadowRoot.prepend(o)}s&&t.updated?.call(this)}catch(a){this.handleError(a)}}}return r},W=(e,t)=>{const r=ln(e,t);customElements.get(e)||customElements.define(e,r)},Q=(e,...t)=>e.reduce((r,n,s)=>`${r}${n}${t[s]??""}`,""),un=(e,...t)=>{const r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},n=s=>String(s??"").replace(/[&<>"'`]/g,a=>r[a]);return e.reduce((s,a,i)=>`${s}${a}${n(t[i])}`,"")},fe=`
2
+ :host {
3
+ color: inherit;
4
+ font: inherit;
5
+ }
6
+ `,tt=`
7
+ ${fe}
8
+ .field {
9
+ display: inline-flex;
10
+ flex-direction: column;
11
+ gap: 0.375rem;
12
+ width: 100%;
13
+ }
14
+ .label {
15
+ color: #334155;
16
+ font-size: 0.875rem;
17
+ font-weight: 600;
18
+ }
19
+ .control {
20
+ border: 1px solid #cbd5e1;
21
+ border-radius: 0.75rem;
22
+ box-sizing: border-box;
23
+ font: inherit;
24
+ min-height: 2.75rem;
25
+ outline: none;
26
+ padding: 0.75rem 0.875rem;
27
+ width: 100%;
28
+ background: #fff;
29
+ color: #0f172a;
30
+ transition: border-color 160ms ease, box-shadow 160ms ease;
31
+ }
32
+ .control:focus {
33
+ border-color: #2563eb;
34
+ box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
35
+ }
36
+ .control:disabled {
37
+ background: #f8fafc;
38
+ color: #94a3b8;
39
+ cursor: not-allowed;
40
+ }
41
+ `,k=e=>Fe(e),ke=new WeakMap,Ce=(e,t)=>ke.get(e)?.[t],Pe=(e,t,r)=>{const n=ke.get(e)??{};n[t]=r,ke.set(e,n)},rt=e=>e.shadowRoot?.querySelector(".label")?.textContent??"",fn=(e,t)=>{const r=e.shadowRoot?.querySelector("input.control");return!r||rt(e)!==t.label||(r.getAttribute("type")??"text")!==t.type||(r.getAttribute("placeholder")??"")!==t.placeholder||(r.getAttribute("name")??"")!==t.name||r.disabled!==t.disabled?!1:(r.value!==t.value&&(r.value=t.value),!0)},dn=(e,t)=>{const r=e.shadowRoot?.querySelector("textarea.control");return!r||rt(e)!==t.label||(r.getAttribute("placeholder")??"")!==t.placeholder||(r.getAttribute("name")??"")!==t.name||r.getAttribute("rows")!==String(t.rows)||r.disabled!==t.disabled?!1:(r.value!==t.value&&(r.value=t.value),!0)},hn=e=>["<textarea",' part="control"',' class="control"',` placeholder="${k(e.placeholder)}"`,` name="${k(e.name)}"`,` rows="${e.rows}"`,e.disabled?" disabled":"",`>${k(e.value)}</textarea>`].join(""),mn=(e={})=>{const t=e.prefix??I().components?.prefix??"bq",r={button:`${t}-button`,card:`${t}-card`,input:`${t}-input`,textarea:`${t}-textarea`,checkbox:`${t}-checkbox`};return W(r.button,{props:{label:{type:String,default:""},variant:{type:String,default:"primary"},size:{type:String,default:"md"},type:{type:String,default:"button"},disabled:{type:Boolean,default:!1}},styles:`
42
+ ${fe}
43
+ button {
44
+ appearance: none;
45
+ border: 0;
46
+ border-radius: 999px;
47
+ cursor: pointer;
48
+ display: inline-flex;
49
+ align-items: center;
50
+ justify-content: center;
51
+ font: inherit;
52
+ font-weight: 600;
53
+ gap: 0.5rem;
54
+ min-height: 2.5rem;
55
+ padding: 0.65rem 1rem;
56
+ transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
57
+ background: #2563eb;
58
+ color: #fff;
59
+ }
60
+ button[data-variant='secondary'] {
61
+ background: #e2e8f0;
62
+ color: #0f172a;
63
+ }
64
+ button[data-size='sm'] {
65
+ min-height: 2.125rem;
66
+ padding: 0.5rem 0.875rem;
67
+ }
68
+ button[data-size='lg'] {
69
+ min-height: 3rem;
70
+ padding: 0.875rem 1.25rem;
71
+ }
72
+ button:hover:not(:disabled) {
73
+ transform: translateY(-1px);
74
+ }
75
+ button:disabled {
76
+ cursor: not-allowed;
77
+ opacity: 0.6;
78
+ }
79
+ `,render:({props:n})=>Q`
80
+ <button
81
+ part="button"
82
+ type="${k(n.type)}"
83
+ data-variant="${k(n.variant)}"
84
+ data-size="${k(n.size)}"
85
+ ${n.disabled?"disabled":""}
86
+ >
87
+ <slot>${k(n.label)}</slot>
88
+ </button>
89
+ `}),W(r.card,{props:{title:{type:String,default:""},footer:{type:String,default:""},elevated:{type:Boolean,default:!0}},styles:`
90
+ ${fe}
91
+ article {
92
+ background: #fff;
93
+ border: 1px solid #e2e8f0;
94
+ border-radius: 1rem;
95
+ box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
96
+ color: #0f172a;
97
+ display: block;
98
+ padding: 1rem;
99
+ }
100
+ article[data-elevated='false'] {
101
+ box-shadow: none;
102
+ }
103
+ header, footer {
104
+ color: #475569;
105
+ font-size: 0.95rem;
106
+ font-weight: 600;
107
+ }
108
+ header {
109
+ margin-bottom: 0.75rem;
110
+ }
111
+ footer {
112
+ margin-top: 0.75rem;
113
+ }
114
+ `,render:({props:n})=>Q`
115
+ <article part="card" data-elevated="${String(n.elevated)}">
116
+ ${n.title?`<header part="header">${k(n.title)}</header>`:""}
117
+ <section part="body"><slot></slot></section>
118
+ ${n.footer?`<footer part="footer">${k(n.footer)}</footer>`:""}
119
+ </article>
120
+ `}),W(r.input,{props:{label:{type:String,default:""},type:{type:String,default:"text"},value:{type:String,default:""},placeholder:{type:String,default:""},name:{type:String,default:""},disabled:{type:Boolean,default:!1}},styles:tt,beforeUpdate(n){return!fn(this,n)},connected(){const n=s=>{const a=s.target;a?.matches("input")&&(s.stopPropagation(),this.setAttribute("value",a.value),this.dispatchEvent(new CustomEvent("input",{detail:{value:a.value},bubbles:!0,composed:!0})))};Pe(this,"__bqueryInputHandler",n),this.shadowRoot?.addEventListener("input",n)},disconnected(){const n=Ce(this,"__bqueryInputHandler");n&&this.shadowRoot?.removeEventListener("input",n)},render:({props:n})=>Q`
121
+ <label part="field" class="field">
122
+ ${n.label?`<span part="label" class="label">${k(n.label)}</span>`:""}
123
+ <input
124
+ part="control"
125
+ class="control"
126
+ type="${k(n.type)}"
127
+ value="${k(n.value)}"
128
+ placeholder="${k(n.placeholder)}"
129
+ name="${k(n.name)}"
130
+ ${n.disabled?"disabled":""}
131
+ />
132
+ </label>
133
+ `}),W(r.textarea,{props:{label:{type:String,default:""},value:{type:String,default:""},placeholder:{type:String,default:""},name:{type:String,default:""},rows:{type:Number,default:4},disabled:{type:Boolean,default:!1}},styles:`${tt}
134
+ textarea.control {
135
+ min-height: 6rem;
136
+ resize: vertical;
137
+ }
138
+ `,beforeUpdate(n){return!dn(this,n)},connected(){const n=s=>{const a=s.target;a?.matches("textarea")&&(s.stopPropagation(),this.setAttribute("value",a.value),this.dispatchEvent(new CustomEvent("input",{detail:{value:a.value},bubbles:!0,composed:!0})))};Pe(this,"__bqueryTextareaHandler",n),this.shadowRoot?.addEventListener("input",n)},disconnected(){const n=Ce(this,"__bqueryTextareaHandler");n&&this.shadowRoot?.removeEventListener("input",n)},render:({props:n})=>Q`
139
+ <label part="field" class="field">
140
+ ${n.label?`<span part="label" class="label">${k(n.label)}</span>`:""}
141
+ ${hn(n)}
142
+ </label>
143
+ `}),W(r.checkbox,{props:{label:{type:String,default:""},checked:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},styles:`
144
+ ${fe}
145
+ label {
146
+ align-items: center;
147
+ color: #0f172a;
148
+ cursor: pointer;
149
+ display: inline-flex;
150
+ gap: 0.625rem;
151
+ }
152
+ input {
153
+ accent-color: #2563eb;
154
+ block-size: 1rem;
155
+ inline-size: 1rem;
156
+ }
157
+ input:disabled {
158
+ cursor: not-allowed;
159
+ }
160
+ `,connected(){const n=s=>{const a=s.target;a?.matches('input[type="checkbox"]')&&(s.stopPropagation(),a.checked?this.setAttribute("checked","true"):this.removeAttribute("checked"),this.dispatchEvent(new CustomEvent("change",{detail:{checked:a.checked},bubbles:!0,composed:!0})))};Pe(this,"__bqueryCheckboxHandler",n),this.shadowRoot?.addEventListener("change",n)},disconnected(){const n=Ce(this,"__bqueryCheckboxHandler");n&&this.shadowRoot?.removeEventListener("change",n)},render:({props:n})=>Q`
161
+ <label part="label">
162
+ <input
163
+ part="control"
164
+ type="checkbox"
165
+ ${n.checked?"checked":""}
166
+ ${n.disabled?"disabled":""}
167
+ />
168
+ <span part="text"><slot>${k(n.label)}</slot></span>
169
+ </label>
170
+ `}),r},de=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,nt=e=>typeof e=="string"||typeof e=="number",st=e=>e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),V=(e,t)=>{const r=e.style;if(Array.isArray(t)){const n=t[t.length-1];if(!n)return;for(const[s,a]of Object.entries(n))if(!(s==="offset"||s==="easing"||s==="composite")&&nt(a)){const i=s.startsWith("--")?s:st(s);r.setProperty(i,String(a))}return}for(const[n,s]of Object.entries(t)){if(n==="offset"||n==="easing"||n==="composite")continue;const a=Array.isArray(s)?s[s.length-1]:s;if(nt(a)){const i=n.startsWith("--")?n:st(n);r.setProperty(i,String(a))}}},he=(e,t)=>{const{keyframes:r,options:n,commitStyles:s=!0,respectReducedMotion:a=!0,onFinish:i}=t;if(a&&de())return s&&V(e,r),i?.(),Promise.resolve();const o=e;return typeof o.animate!="function"?(s&&V(e,r),i?.(),Promise.resolve()):new Promise(c=>{const l=o.animate(r,n);let h=!1;const p=()=>{h||(h=!0,s&&(typeof l.commitStyles=="function"?l.commitStyles():V(e,r)),l.cancel(),i?.(),c())};l.onfinish=p,l.finished&&l.finished.then(p).catch(p)})},_=e=>Math.min(1,Math.max(0,e)),at=e=>_(e),it=e=>_(e*e),ot=e=>_(1-(1-e)*(1-e)),ct=e=>_(e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2),lt=e=>_(e*e*e),ut=e=>_(1-Math.pow(1-e,3)),ft=e=>_(e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2),dt=e=>_(1+(1.70158+1)*Math.pow(e-1,3)+1.70158*Math.pow(e-1,2)),ht=e=>_(e===1?1:1-Math.pow(2,-10*e)),pn={linear:at,easeInQuad:it,easeOutQuad:ot,easeInOutQuad:ct,easeInCubic:lt,easeOutCubic:ut,easeInOutCubic:ft,easeOutBack:dt,easeOutExpo:ht},Oe=e=>{const t=e.getBoundingClientRect();return{top:t.top,left:t.left,width:t.width,height:t.height}},Re=(e,t,r={})=>{const{duration:n=300,easing:s="ease-out",onComplete:a}=r,i=Oe(e);if(i.width===0||i.height===0)return a?.(),Promise.resolve();const o=t.left-i.left,c=t.top-i.top,l=t.width/i.width,h=t.height/i.height;if(o===0&&c===0&&l===1&&h===1)return a?.(),Promise.resolve();const p=e;return typeof p.animate!="function"?(a?.(),Promise.resolve()):(p.style.transform=`translate(${o}px, ${c}px) scale(${l}, ${h})`,p.style.transformOrigin="top left",p.offsetHeight,new Promise(y=>{const u=p.animate([{transform:`translate(${o}px, ${c}px) scale(${l}, ${h})`},{transform:"translate(0, 0) scale(1, 1)"}],{duration:n,easing:s,fill:"forwards"});let f=!1;const m=()=>{f||(f=!0,p.style.transform="",p.style.transformOrigin="",a?.(),y())};u.onfinish=m,u.finished&&u.finished.then(m).catch(m)}))},yn=async(e,t,r={})=>{await mt(e,t,r)},mt=async(e,t,r={})=>{const{stagger:n,...s}=r,a=new Map;for(const c of e)a.set(c,Oe(c));t();const i=e.length,o=e.map((c,l)=>{const h=a.get(c);if(!h)return Promise.resolve();const p=n?n(l,i):0;return p>0?new Promise(y=>setTimeout(y,p)).then(()=>Re(c,h,s)):Re(c,h,s)});await Promise.all(o)},gn={fadeIn:(e=0,t=1)=>[{opacity:e},{opacity:t}],fadeOut:(e=1,t=0)=>[{opacity:e},{opacity:t}],slideInUp:(e=16)=>[{opacity:0,transform:`translateY(${e}px)`},{opacity:1,transform:"translateY(0)"}],slideInDown:(e=16)=>[{opacity:0,transform:`translateY(-${e}px)`},{opacity:1,transform:"translateY(0)"}],slideInLeft:(e=16)=>[{opacity:0,transform:`translateX(${e}px)`},{opacity:1,transform:"translateX(0)"}],slideInRight:(e=16)=>[{opacity:0,transform:`translateX(-${e}px)`},{opacity:1,transform:"translateX(0)"}],scaleIn:(e=.95,t=1)=>[{opacity:0,transform:`scale(${e})`},{opacity:1,transform:`scale(${t})`}],scaleOut:(e=1,t=.95)=>[{opacity:1,transform:`scale(${e})`},{opacity:0,transform:`scale(${t})`}],pop:(e=.9,t=1.02,r=1)=>[{opacity:0,transform:`scale(${e})`},{opacity:1,transform:`scale(${t})`,offset:.6},{opacity:1,transform:`scale(${r})`}],rotateIn:(e=6)=>[{opacity:0,transform:`rotate(${e}deg) scale(0.98)`},{opacity:1,transform:"rotate(0deg) scale(1)"}]},vn=e=>typeof Element<"u"&&e instanceof Element?[e]:Array.from(e),bn=(e,t)=>{const r=vn(e);if(!r.length)return()=>{};const{root:n=null,rootMargin:s,threshold:a,once:i=!0,onEnter:o,...c}=t;if(typeof IntersectionObserver>"u")return r.forEach(h=>{o?.(h),he(h,c)}),()=>{};const l=new IntersectionObserver(h=>{h.forEach(p=>{if(!p.isIntersecting)return;const y=p.target;o?.(y),he(y,c),i&&l.unobserve(y)})},{root:n,rootMargin:s,threshold:a});return r.forEach(h=>l.observe(h)),()=>l.disconnect()},wn={stiffness:100,damping:10,mass:1,precision:.01},Sn=(e,t={})=>{const{stiffness:r,damping:n,mass:s,precision:a}={...wn,...t};let i=e,o=0,c=e,l=null,h=null,p=null;const y=new Set,u=()=>{for(const m of y)m(i)},f=m=>{const v=p!==null?(m-p)/1e3:.016666666666666666,g=Math.min(v,1/30);p=m;const b=i-c,A=(-r*b+-n*o)/s;if(o+=A*g,i+=o*g,u(),Math.abs(o)<a&&Math.abs(b)<a){i=c,o=0,l=null,u(),h?.(),h=null;return}l=requestAnimationFrame(f)};return{to(m){return c=m,l!==null&&cancelAnimationFrame(l),h?.(),p=null,new Promise(v=>{h=v,l=requestAnimationFrame(f)})},current(){return i},stop(){l!==null&&(cancelAnimationFrame(l),l=null),o=0,p=null,h?.(),h=null},onChange(m){return y.add(m),()=>y.delete(m)}}},An={gentle:{stiffness:80,damping:15},snappy:{stiffness:200,damping:20},bouncy:{stiffness:300,damping:8},stiff:{stiffness:400,damping:30}},En=(e,t={})=>{const{start:r=0,from:n="start",easing:s}=t;return(a,i=0)=>{const o=typeof n=="number"?n:n==="center"?(i-1)/2:n==="end"?i-1:0,c=Math.abs(a-o),l=i>1?Math.max(o,i-1-o):1,h=l===0?0:c/l;return r+(s?s(h)*l:c)*e}},Te=e=>{if(typeof e=="number")return e;if(typeof e=="string"){const t=e.trim();if(t.endsWith("ms")){const n=Number.parseFloat(t.slice(0,-2));return Number.isFinite(n)?n:0}if(t.endsWith("s")){const n=Number.parseFloat(t.slice(0,-1));return Number.isFinite(n)?n*1e3:0}const r=Number.parseFloat(t);return Number.isFinite(r)?r:0}return 0},$n=(e,t)=>{if(typeof e=="number")return e;if(typeof e=="string"){const r=/^([+-])=(\d+(?:\.\d+)?)$/.exec(e);if(r){const n=Number.parseFloat(r[2]);return Number.isFinite(n)?r[1]==="+"?t+n:t-n:t}}return t},kn=e=>{const t=Te(e?.duration),r=Te(e?.endDelay),n=e?.iterations??1;return n===1/0?Number.MAX_SAFE_INTEGER:t*Math.max(0,n)+r},pt=e=>{let t=0;return e.map(r=>{const n=$n(r.at,t),s=Te(r.options?.delay),a=Math.max(0,n+s),i=kn(r.options),o=a+i;return t=Math.max(t,o),{step:r,start:a,end:o,duration:i}})},Cn=async(e,t={})=>{const{stagger:r,onFinish:n}=t,s=e.length;for(let a=0;a<e.length;a+=1){const i=e[a],o=r?r(a,s):0;o>0&&await new Promise(c=>setTimeout(c,o)),await he(i.target,i)}n?.()},Pn=(e=[],t={})=>{const r=[...e],n=new Set;let s=[],a=0,i=!1,o=!1;const{commitStyles:c=!0,respectReducedMotion:l=!0,onFinish:h}=t,p=()=>{if(!o){if(o=!0,c)for(const u of s){const{animation:f,step:m}=u;typeof f.commitStyles=="function"?f.commitStyles():V(m.target,m.keyframes),f.cancel()}n.forEach(u=>u()),h?.()}},y=()=>{s.forEach(({animation:f})=>f.cancel()),s=[],o=!1;const u=pt(r);if(a=u.length?Math.max(...u.map(f=>f.end)):0,l&&de()){c&&u.forEach(({step:f})=>V(f.target,f.keyframes)),i=!0;return}if(u.some(({step:f})=>typeof f.target.animate!="function")){c&&u.forEach(({step:f})=>V(f.target,f.keyframes)),i=!0;return}i=!1,s=u.map(({step:f,start:m})=>{const{delay:v,...g}=f.options??{};return{animation:f.target.animate(f.keyframes,{...g,delay:m,fill:g.fill??"both"}),step:f,start:m}})};return{add(u){r.push(u)},duration(){if(!r.length)return 0;if(!s.length){const u=pt(r);return Math.max(...u.map(f=>f.end))}return a},async play(){if(y(),i||s.length===0){p();return}const u=s.map(f=>f.animation.finished.catch(()=>{}));await Promise.all(u),p()},pause(){i||s.forEach(({animation:u})=>u.pause())},resume(){i||s.forEach(({animation:u})=>u.play())},stop(){s.forEach(({animation:u})=>u.cancel()),s=[],i=!1},seek(u){i||s.forEach(({animation:f})=>{f.currentTime=u})},onFinish(u){return n.add(u),()=>n.delete(u)}}},yt=e=>(e??[]).map(t=>t.trim()).filter(t=>t.length>0),On=async e=>{const t=I().transitions,r=typeof e=="function"?{update:e,classes:t?.classes,types:t?.types,skipOnReducedMotion:t?.skipOnReducedMotion}:{...e,classes:e.classes??t?.classes,types:e.types??t?.types,skipOnReducedMotion:e.skipOnReducedMotion??t?.skipOnReducedMotion},n=r.update;if(typeof document>"u"){await n();return}const s=document,a=document.documentElement,i=yt(r.classes),o=yt(r.types);if(!s.startViewTransition||r.skipOnReducedMotion&&de()){await n(),r.onFinish?.();return}i.forEach(c=>a.classList.add(c));try{const c=s.startViewTransition(()=>n()),l=c.types;if(l)for(const h of o)l.add(h);await c.ready,r.onReady?.(),await c.finished,r.onFinish?.()}finally{i.forEach(c=>a.classList.remove(c))}},Rn=class{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,r)=>{const n=indexedDB.open(e,1);n.onupgradeneeded=()=>{const s=n.result;s.objectStoreNames.contains(this.storeName)||s.createObjectStore(this.storeName)},n.onsuccess=()=>t(n.result),n.onerror=()=>r(n.error)}),this.dbPromise}async withStore(e,t){const r=await this.openDB();return new Promise((n,s)=>{const a=t(r.transaction(this.storeName,e).objectStore(this.storeName));a.onsuccess=()=>n(a.result),a.onerror=()=>s(a.error)})}async put(e,t){await this.withStore("readwrite",r=>r.put(t,e))}async get(e){return await this.withStore("readonly",t=>t.get(e))??null}async remove(e){await this.withStore("readwrite",t=>t.delete(e))}async keys(){return(await this.withStore("readonly",e=>e.getAllKeys())).map(e=>String(e))}},Tn={async open(e){return new Rn(e)}},Ln=class{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(e=>e.url)}},Mn={isSupported(){return"caches"in window},async open(e){if(!this.isSupported())throw new Error("bQuery: Cache Storage API not supported");return new Ln(await caches.open(e))},async delete(e){return this.isSupported()?caches.delete(e):!1},async keys(){return this.isSupported()?caches.keys():[]}},Nn=e=>{if(typeof document>"u")return null;const t=`${encodeURIComponent(e)}=`,r=document.cookie?document.cookie.split(";"):[];for(const n of r){const s=n.trim();if(s.startsWith(t)){const a=s.slice(t.length);try{return decodeURIComponent(a)}catch{return a}}}return null},_n=e=>{const t=e.trim();return t.startsWith("{")||t.startsWith("[")||t.startsWith('"')},Dn=(e,t)=>{if(typeof document>"u")return;const r=[`${encodeURIComponent(e)}=`,"Expires=Thu, 01 Jan 1970 00:00:00 GMT"];t.path&&r.push(`Path=${t.path}`),t.domain&&r.push(`Domain=${t.domain}`),t.sameSite&&r.push(`SameSite=${t.sameSite}`),t.secure&&r.push("Secure"),document.cookie=r.join("; ")},qn=(e,t,r)=>{if(typeof document>"u")return;const n=r.serialize?r.serialize(t):typeof t=="string"?t:JSON.stringify(t),s=[`${encodeURIComponent(e)}=${encodeURIComponent(n)}`];r.path&&s.push(`Path=${r.path}`),r.domain&&s.push(`Domain=${r.domain}`),typeof r.maxAge=="number"&&s.push(`Max-Age=${r.maxAge}`),r.expires&&s.push(`Expires=${r.expires.toUTCString()}`),r.sameSite&&s.push(`SameSite=${r.sameSite}`),r.secure&&s.push("Secure"),document.cookie=s.join("; ")},jn=(e,t={})=>{const r=I().cookies,n={path:r?.path??"/",sameSite:r?.sameSite??"Lax",secure:r?.secure??!1,watch:!0,...t};n.sameSite==="None"&&(n.secure=!0);const s=Nn(e);let a=n.defaultValue??null;if(s!==null)try{a=n.deserialize?n.deserialize(s):_n(s)?JSON.parse(s):s??a}catch(c){console.warn(`bQuery: Failed to deserialize cookie "${e}", using raw string value`,c),a=s??a}const i=T(a);if(typeof document>"u"||n.watch===!1)return i;let o=!1;return C(()=>{const c=i.value;if(!o){o=!0;return}if(c==null){Dn(e,n);return}qn(e,c,n)}),i},In={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(e,t){return this.isSupported()?Notification.permission!=="granted"?(console.warn("bQuery: Notification permission not granted"),null):new Notification(e,t):(console.warn("bQuery: Notifications not supported in this browser"),null)}},Hn=["position:absolute","width:1px","height:1px","padding:0","margin:-1px","overflow:hidden","clip:rect(0, 0, 0, 0)","white-space:nowrap","border:0"].join(";"),zn=(e={})=>{const t=I().announcer,r={politeness:t?.politeness??"polite",atomic:t?.atomic??!0,delay:t?.delay??16,clearDelay:t?.clearDelay??1e3,...e},n=T("");if(typeof document>"u")return{element:null,message:n,announce(m){n.value=m},clear(){n.value=""},destroy(){n.value=""}};const s=r.id?document.getElementById(r.id):null,a=s??document.createElement("div"),i=!s;if(r.id&&(a.id=r.id),r.className&&(a.className=r.className),a.setAttribute("aria-live",r.politeness),a.setAttribute("aria-atomic",String(r.atomic)),a.setAttribute("role",r.politeness==="assertive"?"alert":"status"),a.setAttribute("data-bquery-announcer","true"),a.getAttribute("style")||a.setAttribute("style",Hn),i){const m=r.container??document.body??document.documentElement;if(!m)return{element:null,message:n,announce(v){n.value=v},clear(){n.value=""},destroy(){n.value=""}};m.appendChild(a)}const o=C(()=>{a.textContent=n.value});let c,l,h=!1;const p=()=>{c&&(clearTimeout(c),c=void 0),l&&(clearTimeout(l),l=void 0)};return{element:a,message:n,announce:(m,v={})=>{if(h)return;const g=v.politeness??r.politeness,b=v.delay??r.delay,A=v.clearDelay??r.clearDelay;p(),a.setAttribute("aria-live",g),a.setAttribute("role",g==="assertive"?"alert":"status"),n.value="",c=setTimeout(()=>{h||(n.value=m,A>0&&(l=setTimeout(()=>{h||(n.value="")},A)))},b)},clear:()=>{h||(p(),n.value="")},destroy:()=>{h||(h=!0,p(),n.value="",o(),i&&a.remove())}}},gt=(e,t)=>{const r=new Map;for(const[n,s]of Object.entries(t))r.set(n,e.getAttribute(n)),e.setAttribute(n,s);return()=>{for(const[n,s]of r.entries())s==null?e.removeAttribute(n):e.setAttribute(n,s)}},vt=(e,t)=>{const r=document.createElement(e);r.setAttribute("data-bquery-page-meta","true");for(const[n,s]of Object.entries(t))s!==void 0&&r.setAttribute(n,s);return r},Bn=e=>{if(typeof document>"u")return()=>{};const t=I().pageMeta,r=e.title?t?.titleTemplate?t.titleTemplate(e.title):e.title:void 0,n=[],s=[],a=document.title;r!==void 0&&(document.title=r);const i=[...e.meta??[]];e.description&&i.unshift({name:"description",content:e.description});for(const o of i){const c=vt("meta",{name:o.name,property:o.property,"http-equiv":o.httpEquiv,content:o.content});document.head.appendChild(c),n.push(c)}for(const o of e.link??[]){const c=vt("link",{rel:o.rel,href:o.href,type:o.type,media:o.media,crossorigin:o.crossOrigin});document.head.appendChild(c),n.push(c)}return e.htmlAttributes&&s.push(gt(document.documentElement,e.htmlAttributes)),e.bodyAttributes&&document.body&&s.push(gt(document.body,e.bodyAttributes)),()=>{document.title=a;for(const o of s.reverse())o();for(const o of n)o.remove()}},bt=class{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 r=typeof t=="string"?t:JSON.stringify(t);this.storage.setItem(e,r)}async remove(e){this.storage.removeItem(e)}async clear(){this.storage.clear()}async keys(){const e=[];for(let t=0;t<this.storage.length;t++){const r=this.storage.key(t);r!==null&&e.push(r)}return e}},Fn=class extends bt{constructor(){super(localStorage)}},Un=class extends bt{constructor(){super(sessionStorage)}},xn=class{constructor(e){this.options=e,this.dbPromise=null}openDB(){return this.dbPromise?this.dbPromise:(this.dbPromise=new Promise((e,t)=>{const r=indexedDB.open(this.options.name,this.options.version??1);r.onupgradeneeded=()=>{const n=r.result;n.objectStoreNames.contains(this.options.store)||n.createObjectStore(this.options.store)},r.onsuccess=()=>e(r.result),r.onerror=()=>t(r.error)}),this.dbPromise)}async withStore(e,t){const r=await this.openDB();return new Promise((n,s)=>{const a=t(r.transaction(this.options.store,e).objectStore(this.options.store));a.onsuccess=()=>n(a.result),a.onerror=()=>s(a.error)})}async get(e){return await this.withStore("readonly",t=>t.get(e))??null}async set(e,t){await this.withStore("readwrite",r=>r.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",e=>e.getAllKeys())).map(e=>String(e))}},Wn={local(){return new Fn},session(){return new Un},indexedDB(e){return new xn(e)}},wt=null,z=T({path:"",params:{},query:{},matched:null,hash:""}),St=x(()=>z.value),K=()=>wt,At=e=>{wt=e},me=async(e,t={})=>{const r=K();if(!r)throw new Error("bQuery router: No router initialized. Call createRouter() first.");await r[t.replace?"replace":"push"](e)},Qn=()=>{const e=K();e?e.back():history.back()},Vn=()=>{const e=K();e?e.forward():history.forward()},Kn=(e,t={})=>r=>{r.preventDefault(),me(e,t).catch(n=>{console.error("Navigation failed:",n)})},Jn=e=>{const t=e??(typeof document<"u"?document.body:null);if(!t)return()=>{};const r=n=>{if(!(n instanceof MouseEvent)||n.defaultPrevented||n.button!==0||n.ctrlKey||n.metaKey||n.shiftKey||n.altKey||typeof Element>"u"||!(n.target instanceof Element))return;const s=n.target.closest("a");if(!s||!(s instanceof(s.ownerDocument.defaultView?.HTMLAnchorElement??HTMLAnchorElement))||s.target||s.hasAttribute("download")||typeof window>"u"||s.origin!==window.location.origin)return;const a=K();if(!a){n.preventDefault(),me(s.pathname+s.search+s.hash).catch(l=>{console.error("Navigation failed:",l)});return}const i=a.base,o=a.hash;let c;if(o&&s.hash&&s.hash.startsWith("#/"))c=s.hash.slice(1);else{let l=s.pathname;i&&i!=="/"&&l.startsWith(i)&&(l=l.slice(i.length)||"/"),c=l+s.search+s.hash}n.preventDefault(),me(c).catch(l=>{console.error("Navigation failed:",l)})};return t.addEventListener("click",r),()=>t.removeEventListener("click",r)},Gn=e=>{const t={};return new URLSearchParams(e).forEach((r,n)=>{const s=t[n];s===void 0?t[n]=r:Array.isArray(s)?s.push(r):t[n]=[s,r]}),t},Yn=e=>{if(e==="*")return/^.*$/;const t="\0P\0",r="\0W\0";let n=e.replace(/:([a-zA-Z_][a-zA-Z0-9_]*)/g,()=>t);return n=n.replace(/\*/g,r),n=n.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),n=n.replace(/\u0000P\u0000/g,()=>"([^/]+)"),n=n.replace(/\u0000W\u0000/g,".*"),new RegExp(`^${n}$`)},Zn=e=>{const t=e.match(/:([a-zA-Z_][a-zA-Z0-9_]*)/g);return t?t.map(r=>r.slice(1)):[]},Xn=(e,t)=>{for(const r of t){const n=Yn(r.path),s=e.match(n);if(s){const a=Zn(r.path),i={};return a.forEach((o,c)=>{i[o]=s[c+1]||""}),{matched:r,params:i}}}return null},pe=(e,t,r,n)=>{const s=Xn(e,n);return{path:e,params:s?.params??{},query:Gn(t),matched:s?.matched??null,hash:r.replace(/^#/,"")}},Et=(e,t="")=>{const r=[];for(const n of e){const s=n.path==="*"?"*":`${t}${n.path}`.replace(/\/+/g,"/");r.push({...n,path:s}),n.children&&r.push(...Et(n.children,s))}return r},es=(e,t={})=>{const r=K();if(!r)throw new Error("bQuery router: No router initialized.");const n=r.routes.find(a=>a.name===e);if(!n)throw new Error(`bQuery router: Route "${e}" not found.`);let s=n.path;for(const[a,i]of Object.entries(t))s=s.replace(`:${a}`,encodeURIComponent(i));return s},ts=(e,t=!1)=>{const r=z.value.path;return t?r===e:r.startsWith(e)},rs=(e,t=!1)=>x(()=>{const r=z.value.path;return t?r===e:r.startsWith(e)}),ns=e=>{const t=K();t&&t.destroy();const{routes:r,base:n="",hash:s=!1}=e,a=[],i=[],o=Et(r),c=()=>{if(s){const[f,m=""]=(window.location.hash.slice(1)||"/").split("#"),[v,g=""]=f.split("?");return{pathname:v,search:g?`?${g}`:"",hash:m?`#${m}`:""}}let u=window.location.pathname;return n&&(u===n||u.startsWith(n+"/"))&&(u=u.slice(n.length)||"/"),{pathname:u,search:window.location.search,hash:window.location.hash}},l=()=>{const{pathname:u,search:f,hash:m}=c();z.value=pe(u,f,m,o)},h=async(u,f)=>{const{pathname:m,search:v,hash:g}=c(),b=pe(m,v,g,o),A=new URL(u,window.location.origin),D=pe(A.pathname,A.search,A.hash,o);for(const w of a)if(await w(D,b)===!1)return;const L=s?`#${u}`:`${n}${u}`;history[f]({},"",L),l();for(const w of i)w(z.value,b)},p=async()=>{const{pathname:u,search:f,hash:m}=c(),v=z.value,g=pe(u,f,m,o);for(const b of a)if(await b(g,v)===!1){const A=new URLSearchParams(Object.entries(v.query).flatMap(([E,P])=>Array.isArray(P)?P.map(H=>[E,H]):[[E,P]])).toString(),D=A?`?${A}`:"",L=v.hash?`#${v.hash}`:"",w=s?`#${v.path}${D}${L}`:`${n}${v.path}${D}${L}`;history.replaceState({},"",w);return}l();for(const b of i)b(z.value,v)};window.addEventListener("popstate",p),l();const y={push:u=>h(u,"pushState"),replace:u=>h(u,"replaceState"),back:()=>history.back(),forward:()=>history.forward(),go:u=>history.go(u),beforeEach:u=>(a.push(u),()=>{const f=a.indexOf(u);f>-1&&a.splice(f,1)}),afterEach:u=>(i.push(u),()=>{const f=i.indexOf(u);f>-1&&i.splice(f,1)}),currentRoute:St,routes:o,base:n,hash:s,destroy:()=>{window.removeEventListener("popstate",p),a.length=0,i.length=0,At(null)}};return At(y),y},ss=()=>{if(!(typeof window>"u"))return window.__BQUERY_DEVTOOLS__||(window.__BQUERY_DEVTOOLS__={stores:new Map}),window.__BQUERY_DEVTOOLS__},as=(e,t)=>{const r=ss();r&&(r.stores.set(e,t),r.onStoreCreated?.(e,t))},is=e=>{typeof window>"u"||!window.__BQUERY_DEVTOOLS__||window.__BQUERY_DEVTOOLS__.stores.delete(e)},os=(e,t)=>{typeof window>"u"||window.__BQUERY_DEVTOOLS__?.onStateChange?.(e,t)},$t=[],cs=e=>{$t.push(e)},ls=(e,t)=>{for(const r of $t){const n=r({store:e,options:t});n&&Object.assign(e,n)}},X=new Map,us=e=>X.has(e),fs=(e,t)=>{X.set(e,t)},kt=e=>X.get(e),ds=()=>Array.from(X.keys()),hs=e=>{X.delete(e),is(e)},Ct=e=>e!==null&&typeof e=="object"&&Object.getPrototypeOf(e)===Object.prototype,B=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(B);if(e instanceof Date)return new Date(e.getTime());if(e instanceof Map)return new Map(Array.from(e.entries()).map(([r,n])=>[r,B(n)]));if(e instanceof Set)return new Set(Array.from(e).map(B));const t={};for(const r of Object.keys(e))t[r]=B(e[r]);return t},ee=(e,t)=>{if(e===t)return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[s,a]of e.entries())if(!t.has(s)||!ee(a,t.get(s)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const s of e.values()){let a=!1;for(const i of t.values())if(ee(s,i)){a=!0;break}if(!a)return!1}return!0}if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((s,a)=>ee(s,t[a]));if(Array.isArray(e)!==Array.isArray(t))return!1;const r=Object.keys(e),n=Object.keys(t);return r.length!==n.length?!1:r.every(s=>ee(e[s],t[s]))},ms=(e,t,r)=>{const n=[];for(const s of Object.keys(t)){const a=e[s],i=t[s];r.get(s)===i&&Ct(a)&&Ct(i)&&!ee(a,i)&&n.push(s)}return n},Le=(()=>{try{const e=globalThis.process;return!(typeof e<"u"&&e.env?.NODE_ENV==="production")}catch{return!0}})(),Pt=e=>{const{id:t,state:r,getters:n={},actions:s={}}=e;if(us(t))return console.warn(`bQuery store: Store "${t}" already exists. Returning existing instance.`),kt(t);const a=r(),i=new Map;for(const u of Object.keys(a))i.set(u,T(a[u]));const o=[],c=()=>le(()=>({...h})),l=()=>{const u=typeof window<"u"&&typeof window.__BQUERY_DEVTOOLS__?.onStateChange=="function";if(o.length===0&&!u)return;const f=c();for(const m of o)m(f);os(t,f)},h=new Proxy({},{get:(u,f)=>{const m=f;if(i.has(m))return i.get(m).value},ownKeys:()=>Array.from(i.keys()),getOwnPropertyDescriptor:(u,f)=>{if(i.has(f))return{enumerable:!0,configurable:!0}},has:(u,f)=>i.has(f)}),p=new Map,y={};for(const u of Object.keys(a))Object.defineProperty(y,u,{get:()=>i.get(u).value,set:f=>{i.get(u).value=f,l()},enumerable:!0,configurable:!1});for(const u of Object.keys(n)){const f=n[u],m=x(()=>f(h,new Proxy({},{get:(v,g)=>{const b=g;if(p.has(b))return p.get(b).value}})));p.set(u,m),Object.defineProperty(y,u,{get:()=>m.value,enumerable:!0,configurable:!1})}for(const u of Object.keys(s)){const f=s[u];y[u]=function(...m){const v=new Proxy(y,{get:(g,b)=>typeof b=="string"&&i.has(b)?i.get(b).value:g[b],set:(g,b,A)=>typeof b=="string"&&i.has(b)?(i.get(b).value=A,l(),!0):Reflect.set(g,b,A)});return f.apply(v,m)}}return Object.defineProperties(y,{$id:{value:t,writable:!1,enumerable:!1},$reset:{value:()=>{const u=r();ce(()=>{for(const[f,m]of i)m.value=u[f]}),l()},writable:!1,enumerable:!1},$subscribe:{value:u=>(o.push(u),()=>{const f=o.indexOf(u);f>-1&&o.splice(f,1)}),writable:!1,enumerable:!1},$patch:{value:u=>{ce(()=>{if(typeof u=="function"){const f=Le?B(c()):null,m=Le?new Map(Array.from(i.entries()).map(([g,b])=>[g,b.value])):null,v=c();if(u(v),Le&&f&&m){const g=ms(f,v,m);g.length>0&&console.warn(`[bQuery store "${t}"] Nested mutation detected in $patch() for keys: ${g.map(String).join(", ")}.
2
171
  Nested object mutations do not trigger reactive updates because the store uses shallow reactivity.
3
172
  To fix this, either:
4
173
  1. Replace the entire object: state.user = { ...state.user, name: "New" }
5
174
  2. Use $patchDeep() for automatic deep cloning
6
- See: https://bquery.dev/guide/store#deep-reactivity`)}for(const[w,b]of Object.entries(g))i.has(w)&&(i.get(w).value=b)}else for(const[m,f]of Object.entries(u))i.has(m)&&(i.get(m).value=f)}),l()},writable:!1,enumerable:!1},$patchDeep:{value:u=>{x(()=>{if(typeof u=="function"){const m=z(c());u(m);for(const[f,g]of Object.entries(m))i.has(f)&&(i.get(f).value=g)}else for(const[m,f]of Object.entries(u))i.has(m)&&(i.get(m).value=z(f))}),l()},writable:!1,enumerable:!1},$state:{get:()=>c(),enumerable:!1}}),gr(e,y),pr(y,t),fr(e,y),y},Sr=(t,e)=>{const n={};for(const r of e)Object.defineProperty(n,r,{get:()=>t[r],enumerable:!0});return n},Ar=(t,e)=>{const n={};for(const r of e)n[r]=(...s)=>t[r](...s);return n},Er=(t,e)=>{const n=e??`bquery-store-${t.id}`,r=t.state,s={...t,state:()=>{const i=r();if(typeof window<"u")try{const a=localStorage.getItem(n);if(a)return{...i,...JSON.parse(a)}}catch{}return i}},o=rt(s);return o.$subscribe(i=>{if(typeof window<"u")try{localStorage.setItem(n,JSON.stringify(i))}catch{}}),o},st=500;class ot{constructor(e){this.cache=new Map,this.maxSize=e}get(e){const n=this.cache.get(e);return n!==void 0&&(this.cache.delete(e),this.cache.set(e,n)),n}set(e,n){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){const r=this.cache.keys().next().value;r!==void 0&&this.cache.delete(r)}this.cache.set(e,n)}clear(){this.cache.clear()}get size(){return this.cache.size}}const it=new ot(st),at=new ot(st),Cr=t=>new Proxy(t,{get(e,n){if(typeof n!="string")return Reflect.get(e,n);const r=e[n];return te(r)||_e(r)?r.value:r},has(e,n){return typeof n!="string"?Reflect.has(e,n):n in e}}),O=(t,e)=>{try{const n=Cr(e);let r=it.get(t);return r||(r=new Function("$ctx",`with($ctx) { return (${t}); }`),it.set(t,r)),r(n)}catch(n){console.error(`bQuery view: Error evaluating "${t}"`,n);return}},oe=(t,e)=>{try{let n=at.get(t);return n||(n=new Function("$ctx",`with($ctx) { return (${t}); }`),at.set(t,n)),n(e)}catch(n){console.error(`bQuery view: Error evaluating "${t}"`,n);return}},ct=t=>{const e={},n=t.trim().replace(/^\{|\}$/g,"").trim();if(!n)return e;const r=[];let s="",o=0,i=null;for(let a=0;a<n.length;a++){const c=n[a],l=a>0?n[a-1]:"";if((c==='"'||c==="'"||c==="`")&&l!=="\\"){i===null?i=c:i===c&&(i=null),s+=c;continue}if(i!==null){s+=c;continue}c==="("||c==="["||c==="{"?(o++,s+=c):c===")"||c==="]"||c==="}"?(o--,s+=c):c===","&&o===0?(r.push(s.trim()),s=""):s+=c}s.trim()&&r.push(s.trim());for(const a of r){let c=-1,l=0,p=null;for(let d=0;d<a.length;d++){const y=a[d],u=d>0?a[d-1]:"";if((y==='"'||y==="'"||y==="`")&&u!=="\\"){p===null?p=y:p===y&&(p=null);continue}if(p===null){if(y==="("||y==="["||y==="{")l++;else if(y===")"||y==="]"||y==="}")l--;else if(y===":"&&l===0){c=d;break}}}if(c>-1){const d=a.slice(0,c).trim().replace(/^['"]|['"]$/g,""),y=a.slice(c+1).trim();e[d]=y}}return e},$r=t=>(e,n,r,s)=>{const o=k(()=>{const i=O(n,r);i==null||i===!1?e.removeAttribute(t):i===!0?e.setAttribute(t,""):e.setAttribute(t,String(i))});s.push(o)},Pr=(t,e,n,r)=>{let s=new Set;const o=k(()=>{const i=new Set;if(e.trimStart().startsWith("{")){const a=ct(e);for(const[c,l]of Object.entries(a)){const p=O(l,n);t.classList.toggle(c,!!p),i.add(c)}}else if(/^\s*\[/.test(e)){const a=O(e,n);if(Array.isArray(a))for(const c of a)c&&(t.classList.add(c),i.add(c))}else{const a=O(e,n);typeof a=="string"?a.split(/\s+/).forEach(c=>{c&&(t.classList.add(c),i.add(c))}):Array.isArray(a)&&a.forEach(c=>{c&&(t.classList.add(c),i.add(c))})}for(const a of s)i.has(a)||t.classList.remove(a);s=i});r.push(o)},kr=(t,e,n,r,s,o)=>{if(!n)return e;const i={...o,[r]:t};return s&&(i[s]=e),O(n,i)},Or=t=>{const{prefix:e,processElement:n,processChildren:r}=t;return(s,o,i,a)=>{const c=s.parentNode;if(!c)return;const l=o.match(/^\(?(\w+)(?:\s*,\s*(\w+))?\)?\s+in\s+(\S.*)$/);if(!l){console.error(`bQuery view: Invalid bq-for expression "${o}"`);return}const[,p,d,y]=l,u=s.getAttribute(":key")||s.getAttribute(`${e}-key`),m=s.cloneNode(!0);m.removeAttribute(`${e}-for`),m.removeAttribute(":key"),m.removeAttribute(`${e}-key`);const f=document.createComment(`bq-for: ${o}`);c.replaceChild(f,s);let g=new Map,w=[];const b=(v,E,N)=>{const M=m.cloneNode(!0),I=[],V=B(v),j=d?B(E):null,C={...i,[p]:V};return d&&j&&(C[d]=j),n(M,C,e,I),r(M,C,e,I),{key:N,element:M,cleanups:I,item:v,index:E,itemSignal:V,indexSignal:j}},A=v=>{for(const E of v.cleanups)E();v.element.remove()},$=(v,E,N)=>{Object.is(v.item,E)||(v.item=E,v.itemSignal.value=E),v.index!==N&&(v.index=N,v.indexSignal&&(v.indexSignal.value=N))},L=k(()=>{const v=O(y,i);if(!Array.isArray(v)){for(const C of g.values())A(C);g.clear(),w=[];return}const E=[],N=new Map,M=new Set;v.forEach((C,P)=>{let R=kr(C,P,u,p,d,i);M.has(R)&&(console.warn(`bq-for: Duplicate key "${String(R)}" detected at index ${P}. Falling back to index-based key for this item. Ensure :key expressions produce unique values for each item.`),R={__bqDuplicateKey:R,__bqIndex:P}),M.add(R),E.push(R),N.set(R,{item:C,index:P})});const I=[];for(const C of w)N.has(C)||I.push(C);for(const C of I){const P=g.get(C);P&&(A(P),g.delete(C))}const V=new Map;let j=f;for(let C=0;C<E.length;C++){const P=E[C],{item:R,index:ut}=N.get(P);let T=g.get(P);T?($(T,R,ut),V.set(P,T),j.nextSibling!==T.element&&j.after(T.element),j=T.element):(T=b(R,ut,P),V.set(P,T),j.after(T.element),j=T.element)}g=V,w=E});a.push(()=>{L();for(const v of g.values())for(const E of v.cleanups)E();g.clear()})}},Nr=t=>(e,n,r,s)=>{const o=k(()=>{const i=O(n,r),a=String(i??"");e.innerHTML=t?H(a):a});s.push(o)},Lr=(t,e,n,r)=>{const s=document.createComment(`bq-if: ${e}`);let o=!0;const i=k(()=>{const a=O(e,n);a&&!o?(s.replaceWith(t),o=!0):!a&&o&&(t.replaceWith(s),o=!1)});r.push(i)},Mr=(t,e,n,r)=>{const s=t,o=oe(e,n);if(!te(o)){console.warn(`bQuery view: bq-model requires a signal, got "${e}"`);return}const i=o,a=s.type==="checkbox",c=s.type==="radio",l=()=>{a?s.checked=!!i.value:c?s.checked=i.value===s.value:s.value=String(i.value??"")},p=k(()=>{l()});r.push(p);const d=s.tagName==="SELECT"?"change":"input",y=()=>{a?i.value=s.checked:c?s.checked&&(i.value=s.value):i.value=s.value};s.addEventListener(d,y),r.push(()=>s.removeEventListener(d,y))},Rr=t=>(e,n,r,s)=>{const o=i=>{const a={...r,$event:i,$el:e};if(!n.includes("(")){const l=oe(n,a);if(typeof l=="function"){l(i);return}return}oe(n,a)};e.addEventListener(t,o),s.push(()=>e.removeEventListener(t,o))};function Tr(t){const e=Object.getOwnPropertyDescriptor(t,"value");return e?"value"in e?e.writable===!0:typeof e.set=="function":!1}const _r=(t,e,n,r)=>{const s=oe(e,n);te(s)?(s.value=t,r.push(()=>{s.value=null})):typeof s=="object"&&s!==null&&Tr(s)&&(s.value=t,r.push(()=>{s.value=null}))},Dr=(t,e,n,r)=>{const s=t;let o=s.style.display;if(!o||o==="none"){const a=s.ownerDocument.defaultView?.getComputedStyle(s).display??"";o=a!=="none"?a:""}const i=k(()=>{const a=O(e,n);s.style.display=a?o:"none"});r.push(i)},jr=(t,e,n,r)=>{const s=t;let o=new Set;const i=k(()=>{const a=new Set;if(e.trimStart().startsWith("{")){const c=ct(e);for(const[l,p]of Object.entries(c)){const d=O(p,n),y=l.replace(/([A-Z])/g,"-$1").toLowerCase();s.style.setProperty(y,String(d??"")),a.add(y)}}else{const c=O(e,n);if(c&&typeof c=="object")for(const[l,p]of Object.entries(c)){const d=l.replace(/([A-Z])/g,"-$1").toLowerCase();s.style.setProperty(d,String(p??"")),a.add(d)}}for(const c of o)a.has(c)||s.style.removeProperty(c);o=a});r.push(i)},Hr=(t,e,n,r)=>{const s=k(()=>{const o=O(e,n);t.textContent=String(o??"")});r.push(s)},ie=(t,e,n,r,s)=>{const o=Array.from(t.attributes);for(const i of o){const{name:a,value:c}=i;if(!a.startsWith(`${n}-`))continue;const l=a.slice(n.length+1);if(l==="for"){s.for(t,c,e,r);return}if(l==="text")s.text(t,c,e,r);else if(l==="html")s.html(t,c,e,r);else if(l==="if")s.if(t,c,e,r);else if(l==="show")s.show(t,c,e,r);else if(l==="class")s.class(t,c,e,r);else if(l==="style")s.style(t,c,e,r);else if(l==="model")s.model(t,c,e,r);else if(l==="ref")s.ref(t,c,e,r);else if(l.startsWith("bind:")){const p=l.slice(5);s.bind(p)(t,c,e,r)}else if(l.startsWith("on:")){const p=l.slice(3);s.on(p)(t,c,e,r)}}},be=(t,e,n,r,s)=>{const o=Array.from(t.children);for(const i of o)i.hasAttribute(`${n}-for`)?ie(i,e,n,r,s):(ie(i,e,n,r,s),be(i,e,n,r,s))},lt=(t,e,n={})=>{const{prefix:r="bq",sanitize:s=!0}=n,o=typeof t=="string"?document.querySelector(t):t;if(!o)throw new Error(`bQuery view: Element "${t}" not found.`);if(o.hasAttribute(`${r}-for`))throw new Error(`bQuery view: Cannot mount on element with ${r}-for directive. Wrap the ${r}-for element in a container instead.`);const i=[],a={text:Hr,html:Nr(s),if:Lr,show:Dr,class:Pr,style:jr,model:Mr,ref:_r,for:Or({prefix:r,processElement:(l,p,d,y)=>ie(l,p,d,y,a),processChildren:(l,p,d,y)=>be(l,p,d,y,a)}),bind:$r,on:Rr};return((l,p,d)=>{const y=l.hasAttribute(`${r}-for`);ie(l,p,r,d,a),y||be(l,p,r,d,a)})(o,e,i),{el:o,context:e,update:l=>{Object.assign(e,l)},destroy:()=>{for(const l of i)l();i.length=0}}},Ir=(t,e={})=>n=>{const r=document.createElement("div");r.innerHTML=t.trim();const s=r.firstElementChild;if(!s)throw new Error("bQuery view: Template must contain a single root element.");if(r.childElementCount>1)throw new Error(`bQuery view: Template must contain exactly one root element, found ${r.childElementCount}.`);const{prefix:o="bq"}=e;if(s.hasAttribute(`${o}-for`)||s.hasAttribute(`${o}-if`)){const i=s.hasAttribute(`${o}-for`)?"for":"if";throw new Error(`bQuery view: Template root element cannot have ${o}-${i} directive. Wrap the ${o}-${i} element in a container instead.`)}return lt(s,n,e)};return h.$=Nt,h.$$=Lt,h.BQueryCollection=q,h.BQueryElement=_,h.Computed=fe,h.Signal=he,h.animate=ne,h.back=Xn,h.batch=x,h.buckets=Qn,h.cache=Vn,h.capturePosition=me,h.component=Pn,h.computed=ee,h.createPersistedStore=Er,h.createRouter=lr,h.createStore=rt,h.createTemplate=Ir,h.createTrustedHtml=$t,h.currentRoute=Ge,h.destroyStore=wr,h.easeInCubic=We,h.easeInOutCubic=Qe,h.easeInOutQuad=ze,h.easeInQuad=qe,h.easeOutBack=Ue,h.easeOutCubic=Be,h.easeOutExpo=Ve,h.easeOutQuad=Fe,h.easingPresets=Nn,h.effect=k,h.escapeHtml=Pt,h.flip=pe,h.flipElements=Ke,h.flipList=Ln,h.forward=xn,h.generateNonce=At,h.getStore=tt,h.getTrustedTypesPolicy=$e,h.hasCSPDirective=Et,h.html=kn,h.interceptLinks=tr,h.isActive=ar,h.isActiveSignal=cr,h.isComputed=_e,h.isSignal=te,h.isTrustedTypesSupported=Ct,h.keyframePresets=Mn,h.linear=Ie,h.link=er,h.listStores=br,h.mapActions=Ar,h.mapState=Sr,h.mount=lt,h.navigate=re,h.notifications=Kn,h.persistedSignal=Sn,h.prefersReducedMotion=de,h.readonly=An,h.registerPlugin=mr,h.resolve=ir,h.safeHtml=On,h.sanitize=H,h.sanitizeHtml=H,h.scrollAnimate=Tn,h.sequence=Fn,h.signal=B,h.spring=Dn,h.springPresets=jn,h.stagger=Hn,h.storage=Gn,h.stripTags=kt,h.timeline=zn,h.transition=Wn,h.untrack=De,h.utils=yn,h.watch=En,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"}),h})({});
7
- //# sourceMappingURL=full.iife.js.map
175
+ See: https://bquery.dev/guide/store#deep-reactivity`)}for(const[g,b]of Object.entries(v))i.has(g)&&(i.get(g).value=b)}else for(const[f,m]of Object.entries(u))i.has(f)&&(i.get(f).value=m)}),l()},writable:!1,enumerable:!1},$patchDeep:{value:u=>{ce(()=>{if(typeof u=="function"){const f=B(c());u(f);for(const[m,v]of Object.entries(f))i.has(m)&&(i.get(m).value=v)}else for(const[f,m]of Object.entries(u))i.has(f)&&(i.get(f).value=B(m))}),l()},writable:!1,enumerable:!1},$state:{get:()=>c(),enumerable:!1}}),fs(t,y),ls(y,e),as(t,y),y},ps=(e,t)=>{const r={};for(const n of t)Object.defineProperty(r,n,{get:()=>e[n],enumerable:!0});return r},ys=(e,t)=>{const r={};for(const n of t)r[n]=(...s)=>e[n](...s);return r},gs=(e,t)=>{const r=t??`bquery-store-${e.id}`,n=e.state,s=Pt({...e,state:()=>{const a=n();if(typeof window<"u")try{const i=localStorage.getItem(r);if(i)return{...a,...JSON.parse(i)}}catch{}return a}});return s.$subscribe(a=>{if(typeof window<"u")try{localStorage.setItem(r,JSON.stringify(a))}catch{}}),s},Ot=500,Rt=class{constructor(e){this.cache=new Map,this.maxSize=e}get(e){const t=this.cache.get(e);return t!==void 0&&(this.cache.delete(e),this.cache.set(e,t)),t}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){const r=this.cache.keys().next().value;r!==void 0&&this.cache.delete(r)}this.cache.set(e,t)}clear(){this.cache.clear()}get size(){return this.cache.size}},Tt=new Rt(Ot),Lt=new Rt(Ot),vs=e=>new Proxy(e,{get(t,r){if(typeof r!="string")return Reflect.get(t,r);const n=t[r];return ue(n)||et(n)?n.value:n},has(t,r){return typeof r!="string"?Reflect.has(t,r):r in t}}),R=(e,t)=>{try{const r=vs(t);let n=Tt.get(e);return n||(n=new Function("$ctx",`with($ctx) { return (${e}); }`),Tt.set(e,n)),n(r)}catch(r){console.error(`bQuery view: Error evaluating "${e}"`,r);return}},ye=(e,t)=>{try{let r=Lt.get(e);return r||(r=new Function("$ctx",`with($ctx) { return (${e}); }`),Lt.set(e,r)),r(t)}catch(r){console.error(`bQuery view: Error evaluating "${e}"`,r);return}},Mt=e=>{const t={},r=e.trim().replace(/^\{|\}$/g,"").trim();if(!r)return t;const n=[];let s="",a=0,i=null;for(let o=0;o<r.length;o++){const c=r[o];if(c==='"'||c==="'"||c==="`"){let l=0,h=o-1;for(;h>=0&&r[h]==="\\";)l++,h--;l%2===0&&(i===null?i=c:i===c&&(i=null)),s+=c;continue}if(i!==null){s+=c;continue}c==="("||c==="["||c==="{"?(a++,s+=c):c===")"||c==="]"||c==="}"?(a--,s+=c):c===","&&a===0?(n.push(s.trim()),s=""):s+=c}s.trim()&&n.push(s.trim());for(const o of n){let c=-1,l=0,h=null;for(let p=0;p<o.length;p++){const y=o[p];if(y==='"'||y==="'"||y==="`"){let u=0,f=p-1;for(;f>=0&&o[f]==="\\";)u++,f--;u%2===0&&(h===null?h=y:h===y&&(h=null));continue}if(h===null){if(y==="("||y==="["||y==="{")l++;else if(y===")"||y==="]"||y==="}")l--;else if(y===":"&&l===0){c=p;break}}}if(c>-1){const p=o.slice(0,c).trim().replace(/^['"]|['"]$/g,"");t[p]=o.slice(c+1).trim()}}return t},bs=e=>(t,r,n,s)=>{const a=C(()=>{const i=R(r,n);i==null||i===!1?t.removeAttribute(e):i===!0?t.setAttribute(e,""):t.setAttribute(e,String(i))});s.push(a)},ws=(e,t,r,n)=>{let s=new Set;const a=C(()=>{const i=new Set;if(t.trimStart().startsWith("{")){const o=Mt(t);for(const[c,l]of Object.entries(o)){const h=R(l,r);e.classList.toggle(c,!!h),i.add(c)}}else if(/^\s*\[/.test(t)){const o=R(t,r);if(Array.isArray(o))for(const c of o)c&&(e.classList.add(c),i.add(c))}else{const o=R(t,r);typeof o=="string"?o.split(/\s+/).forEach(c=>{c&&(e.classList.add(c),i.add(c))}):Array.isArray(o)&&o.forEach(c=>{c&&(e.classList.add(c),i.add(c))})}for(const o of s)i.has(o)||e.classList.remove(o);s=i});n.push(a)},Ss=(e,t,r,n,s,a)=>{if(!r)return t;const i={...a,[n]:e};return s&&(i[s]=t),R(r,i)},As=e=>{const{prefix:t,processElement:r,processChildren:n}=e;return(s,a,i,o)=>{const c=s.parentNode;if(!c)return;const l=a.match(/^\(?(\w+)(?:\s*,\s*(\w+))?\)?\s+in\s+(\S.*)$/);if(!l){console.error(`bQuery view: Invalid bq-for expression "${a}"`);return}const[,h,p,y]=l,u=s.getAttribute(":key")||s.getAttribute(`${t}-key`),f=s.cloneNode(!0);f.removeAttribute(`${t}-for`),f.removeAttribute(":key"),f.removeAttribute(`${t}-key`);const m=document.createComment(`bq-for: ${a}`);c.replaceChild(m,s);let v=new Map,g=[];const b=(w,E,P)=>{const H=f.cloneNode(!0),J=[],G=T(w),q=p?T(E):null,$={...i,[h]:G};return p&&q&&($[p]=q),r(H,$,t,J),n(H,$,t,J),{key:P,element:H,cleanups:J,item:w,index:E,itemSignal:G,indexSignal:q}},A=w=>{for(const E of w.cleanups)E();w.element.remove()},D=(w,E,P)=>{Object.is(w.item,E)||(w.item=E,w.itemSignal.value=E),w.index!==P&&(w.index=P,w.indexSignal&&(w.indexSignal.value=P))},L=C(()=>{const w=R(y,i);if(!Array.isArray(w)){for(const $ of v.values())A($);v.clear(),g=[];return}const E=[],P=new Map,H=new Set;w.forEach(($,O)=>{let M=Ss($,O,u,h,p,i);H.has(M)&&(console.warn(`bq-for: Duplicate key "${String(M)}" detected at index ${O}. Falling back to index-based key for this item. Ensure :key expressions produce unique values for each item.`),M={__bqDuplicateKey:M,__bqIndex:O}),H.add(M),E.push(M),P.set(M,{item:$,index:O})});const J=[];for(const $ of g)P.has($)||J.push($);for(const $ of J){const O=v.get($);O&&(A(O),v.delete($))}const G=new Map;let q=m;for(let $=0;$<E.length;$++){const O=E[$],{item:M,index:_t}=P.get(O);let N=v.get(O);N?(D(N,M,_t),G.set(O,N),q.nextSibling!==N.element&&q.after(N.element),q=N.element):(N=b(M,_t,O),G.set(O,N),q.after(N.element),q=N.element)}v=G,g=E});o.push(()=>{L();for(const w of v.values())for(const E of w.cleanups)E();v.clear()})}},Es=e=>(t,r,n,s)=>{const a=C(()=>{const i=R(r,n),o=String(i??"");t.innerHTML=e?j(o):o});s.push(a)},$s=(e,t,r,n)=>{const s=document.createComment(`bq-if: ${t}`);let a=!0;const i=C(()=>{const o=R(t,r);o&&!a?(s.replaceWith(e),a=!0):!o&&a&&(e.replaceWith(s),a=!1)});n.push(i)},ks=(e,t,r,n)=>{const s=e,a=ye(t,r);if(!ue(a)){console.warn(`bQuery view: bq-model requires a signal, got "${t}"`);return}const i=a,o=s.type==="checkbox",c=s.type==="radio",l=()=>{o?s.checked=!!i.value:c?s.checked=i.value===s.value:s.value=String(i.value??"")},h=C(()=>{l()});n.push(h);const p=s.tagName==="SELECT"?"change":"input",y=()=>{o?i.value=s.checked:c?s.checked&&(i.value=s.value):i.value=s.value};s.addEventListener(p,y),n.push(()=>s.removeEventListener(p,y))},Cs=e=>(t,r,n,s)=>{const a=i=>{const o={...n,$event:i,$el:t};if(!r.includes("(")){const c=ye(r,o);if(typeof c=="function"){c(i);return}return}ye(r,o)};t.addEventListener(e,a),s.push(()=>t.removeEventListener(e,a))};function Ps(e){const t=Object.getOwnPropertyDescriptor(e,"value");return t?"value"in t?t.writable===!0:typeof t.set=="function":!1}var Os=(e,t,r,n)=>{const s=ye(t,r);ue(s)?(s.value=e,n.push(()=>{s.value=null})):typeof s=="object"&&s!==null&&Ps(s)&&(s.value=e,n.push(()=>{s.value=null}))},Rs=(e,t,r,n)=>{const s=e;let a=s.style.display;if(!a||a==="none"){const o=s.ownerDocument.defaultView?.getComputedStyle(s).display??"";a=o!=="none"?o:""}const i=C(()=>{const o=R(t,r);s.style.display=o?a:"none"});n.push(i)},Ts=(e,t,r,n)=>{const s=e;let a=new Set;const i=C(()=>{const o=new Set;if(t.trimStart().startsWith("{")){const c=Mt(t);for(const[l,h]of Object.entries(c)){const p=R(h,r),y=l.replace(/([A-Z])/g,"-$1").toLowerCase();s.style.setProperty(y,String(p??"")),o.add(y)}}else{const c=R(t,r);if(c&&typeof c=="object")for(const[l,h]of Object.entries(c)){const p=l.replace(/([A-Z])/g,"-$1").toLowerCase();s.style.setProperty(p,String(h??"")),o.add(p)}}for(const c of a)o.has(c)||s.style.removeProperty(c);a=o});n.push(i)},Ls=(e,t,r,n)=>{const s=C(()=>{const a=R(t,r);e.textContent=String(a??"")});n.push(s)},ge=(e,t,r,n,s)=>{const a=Array.from(e.attributes);for(const i of a){const{name:o,value:c}=i;if(!o.startsWith(`${r}-`))continue;const l=o.slice(r.length+1);if(l==="for"){s.for(e,c,t,n);return}if(l==="text")s.text(e,c,t,n);else if(l==="html")s.html(e,c,t,n);else if(l==="if")s.if(e,c,t,n);else if(l==="show")s.show(e,c,t,n);else if(l==="class")s.class(e,c,t,n);else if(l==="style")s.style(e,c,t,n);else if(l==="model")s.model(e,c,t,n);else if(l==="ref")s.ref(e,c,t,n);else if(l.startsWith("bind:")){const h=l.slice(5);s.bind(h)(e,c,t,n)}else if(l.startsWith("on:")){const h=l.slice(3);s.on(h)(e,c,t,n)}}},Me=(e,t,r,n,s)=>{const a=Array.from(e.children);for(const i of a)i.hasAttribute(`${r}-for`)?ge(i,t,r,n,s):(ge(i,t,r,n,s),Me(i,t,r,n,s))},Nt=(e,t,r={})=>{const{prefix:n="bq",sanitize:s=!0}=r,a=typeof e=="string"?document.querySelector(e):e;if(!a)throw new Error(`bQuery view: Element "${e}" not found.`);if(a.hasAttribute(`${n}-for`))throw new Error(`bQuery view: Cannot mount on element with ${n}-for directive. Wrap the ${n}-for element in a container instead.`);const i=[],o={text:Ls,html:Es(s),if:$s,show:Rs,class:ws,style:Ts,model:ks,ref:Os,for:As({prefix:n,processElement:(l,h,p,y)=>ge(l,h,p,y,o),processChildren:(l,h,p,y)=>Me(l,h,p,y,o)}),bind:bs,on:Cs};return((l,h,p)=>{const y=l.hasAttribute(`${n}-for`);ge(l,h,n,p,o),y||Me(l,h,n,p,o)})(a,t,i),{el:a,context:t,update:l=>{Object.assign(t,l)},destroy:()=>{for(const l of i)l();i.length=0}}},Ms=(e,t={})=>r=>{const n=document.createElement("div");n.innerHTML=e.trim();const s=n.firstElementChild;if(!s)throw new Error("bQuery view: Template must contain a single root element.");if(n.childElementCount>1)throw new Error(`bQuery view: Template must contain exactly one root element, found ${n.childElementCount}.`);const{prefix:a="bq"}=t;if(s.hasAttribute(`${a}-for`)||s.hasAttribute(`${a}-if`)){const i=s.hasAttribute(`${a}-for`)?"for":"if";throw new Error(`bQuery view: Template root element cannot have ${a}-${i} directive. Wrap the ${a}-${i} element in a container instead.`)}return Nt(s,r,t)};return d.$=Zt,d.$$=Xt,d.BQueryCollection=ne,d.BQueryElement=F,d.Computed=Ae,d.Signal=Ee,d.animate=he,d.back=Qn,d.batch=ce,d.buckets=Tn,d.cache=Mn,d.capturePosition=Oe,d.component=W,d.computed=x,d.createPersistedStore=gs,d.createRouter=ns,d.createStore=Pt,d.createTemplate=Ms,d.createTrustedHtml=Jt,d.createUseFetch=rn,d.currentRoute=St,d.defineBqueryConfig=xr,d.definePageMeta=Bn,d.destroyStore=hs,d.easeInCubic=lt,d.easeInOutCubic=ft,d.easeInOutQuad=ct,d.easeInQuad=it,d.easeOutBack=dt,d.easeOutCubic=ut,d.easeOutExpo=ht,d.easeOutQuad=ot,d.easingPresets=pn,d.effect=C,d.escapeHtml=Fe,d.flip=Re,d.flipElements=mt,d.flipList=yn,d.forward=Vn,d.generateNonce=Qt,d.getBqueryConfig=I,d.getStore=kt,d.getTrustedTypesPolicy=Be,d.hasCSPDirective=Vt,d.html=Q,d.interceptLinks=Jn,d.isActive=ts,d.isActiveSignal=rs,d.isComputed=et,d.isSignal=ue,d.isTrustedTypesSupported=Kt,d.keyframePresets=gn,d.linear=at,d.link=Kn,d.linkedSignal=nn,d.listStores=ds,d.mapActions=ys,d.mapState=ps,d.mount=Nt,d.navigate=me,d.notifications=In,d.persistedSignal=sn,d.prefersReducedMotion=de,d.readonly=an,d.registerDefaultComponents=mn,d.registerPlugin=cs,d.resolve=es,d.safeHtml=un,d.sanitize=j,d.sanitizeHtml=j,d.scrollAnimate=bn,d.sequence=Cn,d.signal=T,d.spring=Sn,d.springPresets=An,d.stagger=En,d.storage=Wn,d.stripTags=Gt,d.timeline=Pn,d.transition=On,d.untrack=le,d.useAnnouncer=zn,d.useAsyncData=Ze,d.useCookie=jn,d.useFetch=Xe,d.utils=Ir,d.watch=on,d})({});
176
+
177
+ //# sourceMappingURL=full.iife.js.map