@bquery/bquery 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/full.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(a,S){typeof exports=="object"&&typeof module<"u"?S(exports):typeof define=="function"&&define.amd?define(["exports"],S):(a=typeof globalThis<"u"?globalThis:a||self,S(a.bQuery={}))})(this,function(a){"use strict";const S="bquery-sanitizer";let E=null;const I=()=>typeof window.trustedTypes<"u",M=()=>{if(E)return E;const r=window;if(!r.trustedTypes)return null;try{return E=r.trustedTypes.createPolicy(S,{createHTML:e=>N(e)}),E}catch{return console.warn(`bQuery: Could not create Trusted Types policy "${S}"`),null}},R=new Set(["a","abbr","address","article","aside","b","bdi","bdo","blockquote","br","button","caption","cite","code","col","colgroup","data","dd","del","details","dfn","div","dl","dt","em","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","i","img","input","ins","kbd","label","legend","li","main","mark","nav","ol","optgroup","option","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","small","source","span","strong","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","u","ul","var","wbr"]),D=new Set(["script","iframe","frame","frameset","object","embed","applet","link","meta","style","base","template","slot","math","svg","foreignobject","noscript"]),U=new Set(["document","window","location","top","self","parent","frames","history","navigator","screen","alert","confirm","prompt","eval","Function","cookie","domain","referrer","body","head","forms","images","links","scripts","children","parentNode","firstChild","lastChild","innerHTML","outerHTML","textContent"]),z=new Set(["alt","class","dir","height","hidden","href","id","lang","loading","name","role","src","srcset","style","tabindex","title","type","width","aria-*"]),W=["on","formaction","xlink:","xmlns:"],Q=["javascript:","data:","vbscript:","file:"],J=(r,e,t)=>{const s=r.toLowerCase();for(const n of W)if(s.startsWith(n))return!1;return t&&s.startsWith("data-")||s.startsWith("aria-")?!0:e.has(s)},G=r=>{const e=r.toLowerCase().trim();return!U.has(e)},K=r=>r.replace(/[\u0000-\u001F\u007F]+/g,"").replace(/[\u200B-\u200D\uFEFF\u2028\u2029]+/g,"").replace(/\\u[\da-fA-F]{4}/g,"").replace(/\s+/g,"").toLowerCase(),V=r=>{const e=K(r);for(const t of Q)if(e.startsWith(t))return!1;return!0},N=(r,e={})=>{const{allowTags:t=[],allowAttributes:s=[],allowDataAttributes:n=!0,stripAllTags:i=!1}=e,o=new Set([...R,...t.map(u=>u.toLowerCase())].filter(u=>!D.has(u))),l=new Set([...z,...s.map(u=>u.toLowerCase())]),c=document.createElement("template");if(c.innerHTML=r,i)return c.content.textContent??"";const h=document.createTreeWalker(c.content,NodeFilter.SHOW_ELEMENT),f=[];for(;h.nextNode();){const u=h.currentNode,w=u.tagName.toLowerCase();if(D.has(w)){f.push(u);continue}if(!o.has(w)){f.push(u);continue}const y=[];for(const m of Array.from(u.attributes)){const p=m.name.toLowerCase();if(!J(p,l,n)){y.push(m.name);continue}if((p==="id"||p==="name")&&!G(m.value)){y.push(m.name);continue}(p==="href"||p==="src"||p==="srcset")&&!V(m.value)&&y.push(m.name)}for(const m of y)u.removeAttribute(m)}for(const u of f)u.remove();return c.innerHTML},b=(r,e={})=>N(r,e),Z=r=>{const e=M();return e?e.createHTML(r):b(r)},X=r=>{const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"};return r.replace(/[&<>"'`]/g,t=>e[t])},Y=r=>N(r,{stripAllTags:!0}),x=(r=16)=>{const e=new Uint8Array(r);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},ee=r=>{const e=document.querySelector('meta[http-equiv="Content-Security-Policy"]');return e?(e.getAttribute("content")??"").includes(r):!1},te=r=>Array.isArray(r)?r:[r],d=(r,e)=>{for(const t of r)e(t)};class g{constructor(e){this.element=e,this.delegatedHandlers=new Map}get raw(){return this.element}get node(){return this.element}addClass(...e){return this.element.classList.add(...e),this}removeClass(...e){return this.element.classList.remove(...e),this}toggleClass(e,t){return this.element.classList.toggle(e,t),this}attr(e,t){return t===void 0?this.element.getAttribute(e)??"":(this.element.setAttribute(e,t),this)}prop(e,t){return t===void 0?this.element[e]:(this.element[e]=t,this)}data(e,t){const s=e.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`);return t===void 0?this.element.getAttribute(`data-${s}`)??"":(this.element.setAttribute(`data-${s}`,t),this)}text(e){return e===void 0?this.element.textContent??"":(this.element.textContent=e,this)}html(e){return this.element.innerHTML=b(e),this}htmlUnsafe(e){return this.element.innerHTML=e,this}css(e,t){if(typeof e=="string")return t!==void 0&&this.element.style.setProperty(e,t),this;for(const[s,n]of Object.entries(e))this.element.style.setProperty(s,n);return this}append(e){return this.insertContent(e,"beforeend"),this}prepend(e){return this.insertContent(e,"afterbegin"),this}before(e){return this.insertContent(e,"beforebegin"),this}after(e){return this.insertContent(e,"afterend"),this}wrap(e){const t=typeof e=="string"?document.createElement(e):e;return this.element.parentNode?.insertBefore(t,this.element),t.appendChild(this.element),this}unwrap(){const e=this.element.parentElement;return e&&e.parentNode&&(e.parentNode.insertBefore(this.element,e),e.remove()),this}replaceWith(e){let t;if(typeof e=="string"){const s=document.createElement("template");s.innerHTML=b(e),t=s.content.firstElementChild??document.createElement("div")}else t=e;return this.element.replaceWith(t),new g(t)}scrollTo(e={behavior:"smooth"}){return this.element.scrollIntoView(e),this}remove(){return this.element.remove(),this}empty(){return this.element.innerHTML="",this}clone(e=!0){return new g(this.element.cloneNode(e))}find(e){return Array.from(this.element.querySelectorAll(e))}findOne(e){return this.element.querySelector(e)}closest(e){return this.element.closest(e)}parent(){return this.element.parentElement}children(){return Array.from(this.element.children)}siblings(){const e=this.element.parentElement;return e?Array.from(e.children).filter(t=>t!==this.element):[]}next(){return this.element.nextElementSibling}prev(){return this.element.previousElementSibling}on(e,t){return this.element.addEventListener(e,t),this}once(e,t){return this.element.addEventListener(e,t,{once:!0}),this}off(e,t){return this.element.removeEventListener(e,t),this}trigger(e,t){return this.element.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0})),this}delegate(e,t,s){const n=`${e}:${t}`,i=o=>{const l=o.target.closest(t);l&&this.element.contains(l)&&s(o,l)};return this.delegatedHandlers.has(n)||this.delegatedHandlers.set(n,new Map),this.delegatedHandlers.get(n).set(s,i),this.element.addEventListener(e,i),this}undelegate(e,t,s){const n=`${e}:${t}`,i=this.delegatedHandlers.get(n);if(i){const o=i.get(s);o&&(this.element.removeEventListener(e,o),i.delete(s),i.size===0&&this.delegatedHandlers.delete(n))}return this}matches(e){return this.element.matches(e)}hasClass(e){return this.element.classList.contains(e)}show(e=""){return this.element.removeAttribute("hidden"),this.element.style.display=e,this}hide(){return this.element.style.display="none",this}toggle(e){const t=this.element.style.display==="none";return e??t?this.show():this.hide()}focus(){return this.element.focus(),this}blur(){return this.element.blur(),this}val(e){const t=this.element;return e===void 0?t.value??"":(t.value=e,this)}serialize(){const e=this.element;if(e.tagName.toLowerCase()!=="form")return{};const t={},s=new FormData(e);for(const[n,i]of s.entries())if(typeof i=="string")if(n in t){const o=t[n];Array.isArray(o)?o.push(i):t[n]=[o,i]}else t[n]=i;return t}serializeString(){const e=this.element;if(e.tagName.toLowerCase()!=="form")return"";const t=new FormData(e),s=new URLSearchParams;for(const[n,i]of t.entries())typeof i=="string"&&s.append(n,i);return s.toString()}rect(){return this.element.getBoundingClientRect()}offset(){const e=this.element;return{width:e.offsetWidth,height:e.offsetHeight,top:e.offsetTop,left:e.offsetLeft}}insertContent(e,t){if(typeof e=="string"){this.element.insertAdjacentHTML(t,b(e));return}const s=te(e);d(s,n=>{this.element.insertAdjacentElement(t,n)})}}class v{constructor(e){this.elements=e,this.delegatedHandlers=new WeakMap}get length(){return this.elements.length}first(){return this.elements[0]}eq(e){const t=this.elements[e];return t?new g(t):void 0}firstEl(){return this.eq(0)}lastEl(){return this.eq(this.elements.length-1)}each(e){return this.elements.forEach((t,s)=>{e(new g(t),s)}),this}map(e){return this.elements.map(e)}filter(e){return new v(this.elements.filter(e))}reduce(e,t){return this.elements.reduce(e,t)}toArray(){return this.elements.map(e=>new g(e))}addClass(...e){return d(this.elements,t=>t.classList.add(...e)),this}removeClass(...e){return d(this.elements,t=>t.classList.remove(...e)),this}toggleClass(e,t){return d(this.elements,s=>s.classList.toggle(e,t)),this}attr(e,t){return t===void 0?this.first()?.getAttribute(e)??"":(d(this.elements,s=>s.setAttribute(e,t)),this)}removeAttr(e){return d(this.elements,t=>t.removeAttribute(e)),this}text(e){return e===void 0?this.first()?.textContent??"":(d(this.elements,t=>{t.textContent=e}),this)}html(e){if(e===void 0)return this.first()?.innerHTML??"";const t=b(e);return d(this.elements,s=>{s.innerHTML=t}),this}htmlUnsafe(e){return d(this.elements,t=>{t.innerHTML=e}),this}css(e,t){return typeof e=="string"?(t!==void 0&&d(this.elements,s=>{s.style.setProperty(e,t)}),this):(d(this.elements,s=>{for(const[n,i]of Object.entries(e))s.style.setProperty(n,i)}),this)}show(e=""){return d(this.elements,t=>{t.removeAttribute("hidden"),t.style.display=e}),this}hide(){return d(this.elements,e=>{e.style.display="none"}),this}on(e,t){return d(this.elements,s=>s.addEventListener(e,t)),this}once(e,t){return d(this.elements,s=>s.addEventListener(e,t,{once:!0})),this}off(e,t){return d(this.elements,s=>s.removeEventListener(e,t)),this}trigger(e,t){return d(this.elements,s=>{s.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0}))}),this}delegate(e,t,s){const n=`${e}:${t}`;return d(this.elements,i=>{const o=c=>{const h=c.target.closest(t);h&&i.contains(h)&&s(c,h)};this.delegatedHandlers.has(i)||this.delegatedHandlers.set(i,new Map);const l=this.delegatedHandlers.get(i);l.has(n)||l.set(n,new Map),l.get(n).set(s,o),i.addEventListener(e,o)}),this}undelegate(e,t,s){const n=`${e}:${t}`;return d(this.elements,i=>{const o=this.delegatedHandlers.get(i);if(!o)return;const l=o.get(n);if(!l)return;const c=l.get(s);c&&(i.removeEventListener(e,c),l.delete(s),l.size===0&&o.delete(n),o.size===0&&this.delegatedHandlers.delete(i))}),this}remove(){return d(this.elements,e=>e.remove()),this}empty(){return d(this.elements,e=>{e.innerHTML=""}),this}}const re=r=>{if(typeof r!="string")return new g(r);const e=document.querySelector(r);if(!e)throw new Error(`bQuery: element not found for selector "${r}"`);return new g(e)},se=r=>Array.isArray(r)?new v(r):r instanceof NodeList?new v(Array.from(r)):new v(Array.from(document.querySelectorAll(r))),C={clone(r){return typeof structuredClone=="function"?structuredClone(r):JSON.parse(JSON.stringify(r))},merge(...r){const e={};for(const t of r)for(const[s,n]of Object.entries(t))C.isPrototypePollutionKey(s)||(C.isPlainObject(n)&&C.isPlainObject(e[s])?e[s]=C.merge(e[s],n):e[s]=n);return e},isPrototypePollutionKey(r){return r==="__proto__"||r==="constructor"||r==="prototype"},debounce(r,e){let t;return(...s)=>{t&&clearTimeout(t),t=setTimeout(()=>r(...s),e)}},throttle(r,e){let t=0;return(...s)=>{const n=Date.now();n-t>=e&&(t=n,r(...s))}},uid(r="bQuery"){return`${r}_${Math.random().toString(36).slice(2,9)}`},isElement(r){return r instanceof Element},isCollection(r){return!!(r&&typeof r=="object"&&"elements"in r)},isEmpty(r){return r==null?!0:typeof r=="string"?r.trim().length===0:Array.isArray(r)?r.length===0:typeof r=="object"?Object.keys(r).length===0:!1},isPlainObject(r){return Object.prototype.toString.call(r)==="[object Object]"},isFunction(r){return typeof r=="function"},isString(r){return typeof r=="string"},isNumber(r){return typeof r=="number"&&!Number.isNaN(r)},isBoolean(r){return typeof r=="boolean"},isArray(r){return Array.isArray(r)},parseJson(r,e){try{return JSON.parse(r)}catch{return e}},pick(r,e){const t={};for(const s of e)s in r&&(t[s]=r[s]);return t},omit(r,e){const t={...r};for(const s of e)delete t[s];return t},sleep(r){return new Promise(e=>setTimeout(e,r))},randomInt(r,e){return Math.floor(Math.random()*(e-r+1))+r},clamp(r,e,t){return Math.min(Math.max(r,e),t)},capitalize(r){return r&&r.charAt(0).toUpperCase()+r.slice(1)},toKebabCase(r){return r.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()},toCamelCase(r){return r.replace(/[-_\s]+(.)?/g,(e,t)=>t?t.toUpperCase():"").replace(/^[A-Z]/,e=>e.toLowerCase())}},A=[];let L=0;const P=new Set;let T=!0;const j=(r,e)=>{A.push(r);try{return e()}finally{A.pop()}},q=r=>{if(L>0){P.add(r);return}r()},ne=()=>{for(const r of Array.from(P))P.delete(r),r()};class k{constructor(e){this._value=e,this.subscribers=new Set}get value(){if(T){const e=A[A.length-1];e&&this.subscribers.add(e)}return this._value}set value(e){if(!Object.is(this._value,e)){this._value=e;for(const t of this.subscribers)q(t)}}peek(){return this._value}update(e){this.value=e(this._value)}}class H{constructor(e){this.compute=e,this.dirty=!0,this.subscribers=new Set,this.markDirty=()=>{this.dirty=!0;for(const t of this.subscribers)q(t)}}get value(){const e=A[A.length-1];return e&&this.subscribers.add(e),this.dirty&&(this.dirty=!1,this.cachedValue=j(this.markDirty,this.compute)),this.cachedValue}}const F=r=>new k(r),ie=r=>new H(r),$=r=>{let e,t=!1;const s=()=>{t||(e&&e(),e=j(s,r))};return s(),()=>{t=!0,e&&e()}},oe=r=>{L+=1;try{r()}finally{L-=1,L===0&&ne()}},ae=(r,e)=>{let t=e;try{const n=localStorage.getItem(r);n!==null&&(t=JSON.parse(n))}catch{}const s=F(t);return $(()=>{try{localStorage.setItem(r,JSON.stringify(s.value))}catch{}}),s},ce=r=>({get value(){return r.value},peek(){return r.peek()}}),le=(r,e,t={})=>{let s,n=!0;return $(()=>{const i=r.value;if(n){n=!1,s=i,t.immediate&&e(i,void 0);return}e(i,s),s=i})},ue=r=>{const e=T;T=!1;try{return r()}finally{T=e}},he=r=>r instanceof k,de=r=>r instanceof H,me=(r,e)=>{const{type:t}=e;if(t===String)return r;if(t===Number){const s=Number(r);return Number.isNaN(s)?r:s}if(t===Boolean){const s=r.trim().toLowerCase();return s===""||s==="true"||s==="1"?!0:s==="false"||s==="0"?!1:!!r}if(t===Object||t===Array)try{return JSON.parse(r)}catch{return r}if(typeof t=="function"){const s=t,n=t;try{return s(r)}catch{return new n(r)}}return r},fe=(r,...e)=>r.reduce((t,s,n)=>`${t}${s}${e[n]??""}`,""),pe=(r,...e)=>{const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},s=n=>String(n??"").replace(/[&<>"'`]/g,o=>t[o]);return r.reduce((n,i,o)=>`${n}${i}${s(e[o])}`,"")},ge=(r,e)=>{class t extends HTMLElement{constructor(){super(),this.state={...e.state??{}},this.props={},this.attachShadow({mode:"open"}),this.syncProps()}static get observedAttributes(){return Object.keys(e.props??{})}connectedCallback(){try{e.beforeMount?.call(this),e.connected?.call(this),this.render()}catch(n){this.handleError(n)}}disconnectedCallback(){try{e.disconnected?.call(this)}catch(n){this.handleError(n)}}attributeChangedCallback(){try{this.syncProps(),this.render(!0)}catch(n){this.handleError(n)}}handleError(n){e.onError?e.onError.call(this,n):console.error(`bQuery component error in <${r}>:`,n)}setState(n,i){this.state[n]=i,this.render(!0)}getState(n){return this.state[n]}syncProps(){const n=e.props??{};for(const[i,o]of Object.entries(n)){const l=this.getAttribute(i);let c;if(l==null){if(o.required&&o.default===void 0)throw new Error(`bQuery component: missing required prop "${i}"`);c=o.default??void 0}else c=me(l,o);if(o.validator&&c!==void 0&&!o.validator(c))throw new Error(`bQuery component: validation failed for prop "${i}" with value ${JSON.stringify(c)}`);this.props[i]=c}}render(n=!1){try{if(n&&e.beforeUpdate&&e.beforeUpdate.call(this,this.props)===!1)return;const i=(c,h)=>{this.dispatchEvent(new CustomEvent(c,{detail:h,bubbles:!0,composed:!0}))};if(!this.shadowRoot)return;const o=e.render({props:this.props,state:this.state,emit:i}),l=e.styles?`<style>${e.styles}</style>`:"";this.shadowRoot.innerHTML=`${l}${o}`,n&&e.updated?.call(this)}catch(i){this.handleError(i)}}}customElements.get(r)||customElements.define(r,t)},ye=async r=>{const e=typeof r=="function"?r:r.update,t=document;if(t.startViewTransition){await t.startViewTransition(()=>e()).finished;return}e()},O=r=>{const e=r.getBoundingClientRect();return{top:e.top,left:e.left,width:e.width,height:e.height}},_=(r,e,t={})=>{const{duration:s=300,easing:n="ease-out",onComplete:i}=t,o=O(r);if(o.width===0||o.height===0)return Promise.resolve();const l=e.left-o.left,c=e.top-o.top,h=e.width/o.width,f=e.height/o.height;if(l===0&&c===0&&h===1&&f===1)return Promise.resolve();const u=r;return u.style.transform=`translate(${l}px, ${c}px) scale(${h}, ${f})`,u.style.transformOrigin="top left",u.offsetHeight,new Promise(w=>{const y=u.animate([{transform:`translate(${l}px, ${c}px) scale(${h}, ${f})`},{transform:"translate(0, 0) scale(1, 1)"}],{duration:s,easing:n,fill:"forwards"});y.onfinish=()=>{u.style.transform="",u.style.transformOrigin="",i?.(),w()}})},be=async(r,e,t={})=>{const s=new Map;for(const i of r)s.set(i,O(i));e();const n=r.map(i=>{const o=s.get(i);return o?_(i,o,t):Promise.resolve()});await Promise.all(n)},we={stiffness:100,damping:10,mass:1,precision:.01},Se=(r,e={})=>{const{stiffness:t,damping:s,mass:n,precision:i}={...we,...e};let o=r,l=0,c=r,h=null,f=null;const u=new Set,w=()=>{for(const m of u)m(o)},y=()=>{const m=o-c,p=-t*m,$e=-s*l,Oe=(p+$e)/n;if(l+=Oe*(1/60),o+=l*(1/60),w(),Math.abs(l)<i&&Math.abs(m)<i){o=c,l=0,h=null,w(),f?.(),f=null;return}h=requestAnimationFrame(y)};return{to(m){return c=m,h!==null&&cancelAnimationFrame(h),new Promise(p=>{f=p,h=requestAnimationFrame(y)})},current(){return o},stop(){h!==null&&(cancelAnimationFrame(h),h=null),l=0,f?.(),f=null},onChange(m){return u.add(m),()=>u.delete(m)}}},ve={gentle:{stiffness:80,damping:15},snappy:{stiffness:200,damping:20},bouncy:{stiffness:300,damping:8},stiff:{stiffness:400,damping:30}};class Ae{constructor(e){this.bucketName=e,this.dbPromise=null,this.storeName="blobs"}openDB(){if(this.dbPromise)return this.dbPromise;const e=`bquery-bucket-${this.bucketName}`;return this.dbPromise=new Promise((t,s)=>{const n=indexedDB.open(e,1);n.onupgradeneeded=()=>{const i=n.result;i.objectStoreNames.contains(this.storeName)||i.createObjectStore(this.storeName)},n.onsuccess=()=>t(n.result),n.onerror=()=>s(n.error)}),this.dbPromise}async withStore(e,t){const s=await this.openDB();return new Promise((n,i)=>{const l=s.transaction(this.storeName,e).objectStore(this.storeName),c=t(l);c.onsuccess=()=>n(c.result),c.onerror=()=>i(c.error)})}async put(e,t){await this.withStore("readwrite",s=>s.put(t,e))}async get(e){return await this.withStore("readonly",s=>s.get(e))??null}async remove(e){await this.withStore("readwrite",t=>t.delete(e))}async keys(){return(await this.withStore("readonly",t=>t.getAllKeys())).map(t=>String(t))}}const Ce={async open(r){return new Ae(r)}};class Ee{constructor(e){this.cache=e}async add(e){await this.cache.add(e)}async addAll(e){await this.cache.addAll(e)}async put(e,t){await this.cache.put(e,t)}async match(e){return this.cache.match(e)}async remove(e){return this.cache.delete(e)}async keys(){return(await this.cache.keys()).map(t=>t.url)}}const Le={isSupported(){return"caches"in window},async open(r){if(!this.isSupported())throw new Error("bQuery: Cache Storage API not supported");const e=await caches.open(r);return new Ee(e)},async delete(r){return this.isSupported()?caches.delete(r):!1},async keys(){return this.isSupported()?caches.keys():[]}},Te={isSupported(){return"Notification"in window},getPermission(){return this.isSupported()?Notification.permission:"denied"},async requestPermission(){return this.isSupported()?Notification.permission==="granted"?"granted":Notification.permission==="denied"?"denied":Notification.requestPermission():"denied"},send(r,e){return this.isSupported()?Notification.permission!=="granted"?(console.warn("bQuery: Notification permission not granted"),null):new Notification(r,e):(console.warn("bQuery: Notifications not supported in this browser"),null)}};class B{constructor(e){this.storage=e}async get(e){const t=this.storage.getItem(e);if(t===null)return null;try{return JSON.parse(t)}catch{return t}}async set(e,t){const s=typeof t=="string"?t:JSON.stringify(t);this.storage.setItem(e,s)}async remove(e){this.storage.removeItem(e)}async clear(){this.storage.clear()}async keys(){return Object.keys(this.storage)}}class Ne extends B{constructor(){super(localStorage)}}class Pe extends B{constructor(){super(sessionStorage)}}class ke{constructor(e){this.options=e,this.dbPromise=null}openDB(){return this.dbPromise?this.dbPromise:(this.dbPromise=new Promise((e,t)=>{const s=indexedDB.open(this.options.name,this.options.version??1);s.onupgradeneeded=()=>{const n=s.result;n.objectStoreNames.contains(this.options.store)||n.createObjectStore(this.options.store)},s.onsuccess=()=>e(s.result),s.onerror=()=>t(s.error)}),this.dbPromise)}async withStore(e,t){const s=await this.openDB();return new Promise((n,i)=>{const l=s.transaction(this.options.store,e).objectStore(this.options.store),c=t(l);c.onsuccess=()=>n(c.result),c.onerror=()=>i(c.error)})}async get(e){return await this.withStore("readonly",s=>s.get(e))??null}async set(e,t){await this.withStore("readwrite",s=>s.put(t,e))}async remove(e){await this.withStore("readwrite",t=>t.delete(e))}async clear(){await this.withStore("readwrite",e=>e.clear())}async keys(){return(await this.withStore("readonly",t=>t.getAllKeys())).map(t=>String(t))}}const He={local(){return new Ne},session(){return new Pe},indexedDB(r){return new ke(r)}};a.$=re,a.$$=se,a.BQueryCollection=v,a.BQueryElement=g,a.Computed=H,a.Signal=k,a.batch=oe,a.buckets=Ce,a.cache=Le,a.capturePosition=O,a.component=ge,a.computed=ie,a.createTrustedHtml=Z,a.effect=$,a.escapeHtml=X,a.flip=_,a.flipList=be,a.generateNonce=x,a.getTrustedTypesPolicy=M,a.hasCSPDirective=ee,a.html=fe,a.isComputed=de,a.isSignal=he,a.isTrustedTypesSupported=I,a.notifications=Te,a.persistedSignal=ae,a.readonly=ce,a.safeHtml=pe,a.sanitize=b,a.sanitizeHtml=b,a.signal=F,a.spring=Se,a.springPresets=ve,a.storage=He,a.stripTags=Y,a.transition=ye,a.untrack=ue,a.utils=C,a.watch=le,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
1
+ (function(a,S){typeof exports=="object"&&typeof module<"u"?S(exports):typeof define=="function"&&define.amd?define(["exports"],S):(a=typeof globalThis<"u"?globalThis:a||self,S(a.bQuery={}))})(this,function(a){"use strict";const S="bquery-sanitizer";let E=null;const W=()=>typeof window.trustedTypes<"u",q=()=>{if(E)return E;const r=window;if(!r.trustedTypes)return null;try{return E=r.trustedTypes.createPolicy(S,{createHTML:e=>N(e)}),E}catch{return console.warn(`bQuery: Could not create Trusted Types policy "${S}"`),null}},Q=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"]),_=new Set(["script","iframe","frame","frameset","object","embed","applet","link","meta","style","base","template","slot","math","svg","foreignobject","noscript"]),J=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"]),G=new Set(["alt","class","dir","height","hidden","href","id","lang","loading","name","rel","role","src","srcset","style","tabindex","target","title","type","width","aria-*"]),K=["on","formaction","xlink:","xmlns:"],x=["javascript:","data:","vbscript:","file:"],V=(r,e,t)=>{const s=r.toLowerCase();for(const n of K)if(s.startsWith(n))return!1;return t&&s.startsWith("data-")||s.startsWith("aria-")?!0:e.has(s)},Z=r=>{const e=r.toLowerCase().trim();return!J.has(e)},X=r=>r.replace(/[\u0000-\u001F\u007F]+/g,"").replace(/[\u200B-\u200D\uFEFF\u2028\u2029]+/g,"").replace(/\\u[\da-fA-F]{4}/g,"").replace(/\s+/g,"").toLowerCase(),Y=r=>{const e=X(r);for(const t of x)if(e.startsWith(t))return!1;return!0},ee=r=>{try{const e=r.trim();if(e.startsWith("//"))return!0;const t=e.toLowerCase();return/^[a-z][a-z0-9+.-]*:/i.test(e)&&!t.startsWith("http://")&&!t.startsWith("https://")?!0:!t.startsWith("http://")&&!t.startsWith("https://")?!1:typeof window>"u"||!window.location?!0:new URL(e,window.location.href).origin!==window.location.origin}catch{return!0}},N=(r,e={})=>{const{allowTags:t=[],allowAttributes:s=[],allowDataAttributes:n=!0,stripAllTags:i=!1}=e,o=new Set([...Q,...t.map(u=>u.toLowerCase())].filter(u=>!_.has(u))),c=new Set([...G,...s.map(u=>u.toLowerCase())]),l=document.createElement("template");if(l.innerHTML=r,i)return l.content.textContent??"";const h=document.createTreeWalker(l.content,NodeFilter.SHOW_ELEMENT),f=[];for(;h.nextNode();){const u=h.currentNode,b=u.tagName.toLowerCase();if(_.has(b)){f.push(u);continue}if(!o.has(b)){f.push(u);continue}const y=[];for(const m of Array.from(u.attributes)){const p=m.name.toLowerCase();if(!V(p,c,n)){y.push(m.name);continue}if((p==="id"||p==="name")&&!Z(m.value)){y.push(m.name);continue}(p==="href"||p==="src"||p==="srcset")&&!Y(m.value)&&y.push(m.name)}for(const m of y)u.removeAttribute(m);if(b==="a"){const m=u.getAttribute("href"),M=u.getAttribute("target")?.toLowerCase()==="_blank",j=m&&ee(m);if(M||j){const I=u.getAttribute("rel"),D=new Set(I?I.split(/\s+/).filter(Boolean):[]);D.add("noopener"),D.add("noreferrer"),u.setAttribute("rel",Array.from(D).join(" "))}}}for(const u of f)u.remove();return l.innerHTML},w=(r,e={})=>N(r,e),te=r=>{const e=q();return e?e.createHTML(r):w(r)},re=r=>{const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"};return r.replace(/[&<>"'`]/g,t=>e[t])},se=r=>N(r,{stripAllTags:!0}),ne=(r=16)=>{const e=new Uint8Array(r);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},ie=r=>{const e=document.querySelector('meta[http-equiv="Content-Security-Policy"]');return e?(e.getAttribute("content")??"").includes(r):!1},oe=r=>Array.isArray(r)?r:[r],d=(r,e)=>{for(const t of r)e(t)};class g{constructor(e){this.element=e,this.delegatedHandlers=new Map}get raw(){return this.element}get node(){return this.element}addClass(...e){return this.element.classList.add(...e),this}removeClass(...e){return this.element.classList.remove(...e),this}toggleClass(e,t){return this.element.classList.toggle(e,t),this}attr(e,t){return t===void 0?this.element.getAttribute(e)??"":(this.element.setAttribute(e,t),this)}prop(e,t){return t===void 0?this.element[e]:(this.element[e]=t,this)}data(e,t){const s=e.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`);return t===void 0?this.element.getAttribute(`data-${s}`)??"":(this.element.setAttribute(`data-${s}`,t),this)}text(e){return e===void 0?this.element.textContent??"":(this.element.textContent=e,this)}html(e){return this.element.innerHTML=w(e),this}htmlUnsafe(e){return this.element.innerHTML=e,this}css(e,t){if(typeof e=="string")return t!==void 0&&this.element.style.setProperty(e,t),this;for(const[s,n]of Object.entries(e))this.element.style.setProperty(s,n);return this}append(e){return this.insertContent(e,"beforeend"),this}prepend(e){return this.insertContent(e,"afterbegin"),this}before(e){return this.insertContent(e,"beforebegin"),this}after(e){return this.insertContent(e,"afterend"),this}wrap(e){const t=typeof e=="string"?document.createElement(e):e;return this.element.parentNode?.insertBefore(t,this.element),t.appendChild(this.element),this}unwrap(){const e=this.element.parentElement;return e&&e.parentNode&&(e.parentNode.insertBefore(this.element,e),e.remove()),this}replaceWith(e){let t;if(typeof e=="string"){const s=document.createElement("template");s.innerHTML=w(e),t=s.content.firstElementChild??document.createElement("div")}else t=e;return this.element.replaceWith(t),new g(t)}scrollTo(e={behavior:"smooth"}){return this.element.scrollIntoView(e),this}remove(){return this.element.remove(),this}empty(){return this.element.innerHTML="",this}clone(e=!0){return new g(this.element.cloneNode(e))}find(e){return Array.from(this.element.querySelectorAll(e))}findOne(e){return this.element.querySelector(e)}closest(e){return this.element.closest(e)}parent(){return this.element.parentElement}children(){return Array.from(this.element.children)}siblings(){const e=this.element.parentElement;return e?Array.from(e.children).filter(t=>t!==this.element):[]}next(){return this.element.nextElementSibling}prev(){return this.element.previousElementSibling}on(e,t){return this.element.addEventListener(e,t),this}once(e,t){return this.element.addEventListener(e,t,{once:!0}),this}off(e,t){return this.element.removeEventListener(e,t),this}trigger(e,t){return this.element.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0})),this}delegate(e,t,s){const n=`${e}:${t}`,i=o=>{const c=o.target.closest(t);c&&this.element.contains(c)&&s(o,c)};return this.delegatedHandlers.has(n)||this.delegatedHandlers.set(n,new Map),this.delegatedHandlers.get(n).set(s,i),this.element.addEventListener(e,i),this}undelegate(e,t,s){const n=`${e}:${t}`,i=this.delegatedHandlers.get(n);if(i){const o=i.get(s);o&&(this.element.removeEventListener(e,o),i.delete(s),i.size===0&&this.delegatedHandlers.delete(n))}return this}matches(e){return this.element.matches(e)}hasClass(e){return this.element.classList.contains(e)}show(e=""){return this.element.removeAttribute("hidden"),this.element.style.display=e,this}hide(){return this.element.style.display="none",this}toggle(e){const t=this.element.style.display==="none";return e??t?this.show():this.hide()}focus(){return this.element.focus(),this}blur(){return this.element.blur(),this}val(e){const t=this.element;return e===void 0?t.value??"":(t.value=e,this)}serialize(){const e=this.element;if(e.tagName.toLowerCase()!=="form")return{};const t={},s=new FormData(e);for(const[n,i]of s.entries())if(typeof i=="string")if(n in t){const o=t[n];Array.isArray(o)?o.push(i):t[n]=[o,i]}else t[n]=i;return t}serializeString(){const e=this.element;if(e.tagName.toLowerCase()!=="form")return"";const t=new FormData(e),s=new URLSearchParams;for(const[n,i]of t.entries())typeof i=="string"&&s.append(n,i);return s.toString()}rect(){return this.element.getBoundingClientRect()}offset(){const e=this.element;return{width:e.offsetWidth,height:e.offsetHeight,top:e.offsetTop,left:e.offsetLeft}}insertContent(e,t){if(typeof e=="string"){this.element.insertAdjacentHTML(t,w(e));return}const s=oe(e);d(s,n=>{this.element.insertAdjacentElement(t,n)})}}class v{constructor(e){this.elements=e,this.delegatedHandlers=new WeakMap}get length(){return this.elements.length}first(){return this.elements[0]}eq(e){const t=this.elements[e];return t?new g(t):void 0}firstEl(){return this.eq(0)}lastEl(){return this.eq(this.elements.length-1)}each(e){return this.elements.forEach((t,s)=>{e(new g(t),s)}),this}map(e){return this.elements.map(e)}filter(e){return new v(this.elements.filter(e))}reduce(e,t){return this.elements.reduce(e,t)}toArray(){return this.elements.map(e=>new g(e))}addClass(...e){return d(this.elements,t=>t.classList.add(...e)),this}removeClass(...e){return d(this.elements,t=>t.classList.remove(...e)),this}toggleClass(e,t){return d(this.elements,s=>s.classList.toggle(e,t)),this}attr(e,t){return t===void 0?this.first()?.getAttribute(e)??"":(d(this.elements,s=>s.setAttribute(e,t)),this)}removeAttr(e){return d(this.elements,t=>t.removeAttribute(e)),this}text(e){return e===void 0?this.first()?.textContent??"":(d(this.elements,t=>{t.textContent=e}),this)}html(e){if(e===void 0)return this.first()?.innerHTML??"";const t=w(e);return d(this.elements,s=>{s.innerHTML=t}),this}htmlUnsafe(e){return d(this.elements,t=>{t.innerHTML=e}),this}css(e,t){return typeof e=="string"?(t!==void 0&&d(this.elements,s=>{s.style.setProperty(e,t)}),this):(d(this.elements,s=>{for(const[n,i]of Object.entries(e))s.style.setProperty(n,i)}),this)}show(e=""){return d(this.elements,t=>{t.removeAttribute("hidden"),t.style.display=e}),this}hide(){return d(this.elements,e=>{e.style.display="none"}),this}on(e,t){return d(this.elements,s=>s.addEventListener(e,t)),this}once(e,t){return d(this.elements,s=>s.addEventListener(e,t,{once:!0})),this}off(e,t){return d(this.elements,s=>s.removeEventListener(e,t)),this}trigger(e,t){return d(this.elements,s=>{s.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0}))}),this}delegate(e,t,s){const n=`${e}:${t}`;return d(this.elements,i=>{const o=l=>{const h=l.target.closest(t);h&&i.contains(h)&&s(l,h)};this.delegatedHandlers.has(i)||this.delegatedHandlers.set(i,new Map);const c=this.delegatedHandlers.get(i);c.has(n)||c.set(n,new Map),c.get(n).set(s,o),i.addEventListener(e,o)}),this}undelegate(e,t,s){const n=`${e}:${t}`;return d(this.elements,i=>{const o=this.delegatedHandlers.get(i);if(!o)return;const c=o.get(n);if(!c)return;const l=c.get(s);l&&(i.removeEventListener(e,l),c.delete(s),c.size===0&&o.delete(n),o.size===0&&this.delegatedHandlers.delete(i))}),this}remove(){return d(this.elements,e=>e.remove()),this}empty(){return d(this.elements,e=>{e.innerHTML=""}),this}}const ae=r=>{if(typeof r!="string")return new g(r);const e=document.querySelector(r);if(!e)throw new Error(`bQuery: element not found for selector "${r}"`);return new g(e)},le=r=>Array.isArray(r)?new v(r):r instanceof NodeList?new v(Array.from(r)):new v(Array.from(document.querySelectorAll(r))),C={clone(r){return typeof structuredClone=="function"?structuredClone(r):JSON.parse(JSON.stringify(r))},merge(...r){const e={};for(const t of r)for(const[s,n]of Object.entries(t))C.isPrototypePollutionKey(s)||(C.isPlainObject(n)&&C.isPlainObject(e[s])?e[s]=C.merge(e[s],n):e[s]=n);return e},isPrototypePollutionKey(r){return r==="__proto__"||r==="constructor"||r==="prototype"},debounce(r,e){let t;return(...s)=>{t&&clearTimeout(t),t=setTimeout(()=>r(...s),e)}},throttle(r,e){let t=0;return(...s)=>{const n=Date.now();n-t>=e&&(t=n,r(...s))}},uid(r="bQuery"){return`${r}_${Math.random().toString(36).slice(2,9)}`},isElement(r){return r instanceof Element},isCollection(r){return!!(r&&typeof r=="object"&&"elements"in r)},isEmpty(r){return r==null?!0:typeof r=="string"?r.trim().length===0:Array.isArray(r)?r.length===0:typeof r=="object"?Object.keys(r).length===0:!1},isPlainObject(r){return Object.prototype.toString.call(r)==="[object Object]"},isFunction(r){return typeof r=="function"},isString(r){return typeof r=="string"},isNumber(r){return typeof r=="number"&&!Number.isNaN(r)},isBoolean(r){return typeof r=="boolean"},isArray(r){return Array.isArray(r)},parseJson(r,e){try{return JSON.parse(r)}catch{return e}},pick(r,e){const t={};for(const s of e)s in r&&(t[s]=r[s]);return t},omit(r,e){const t={...r};for(const s of e)delete t[s];return t},sleep(r){return new Promise(e=>setTimeout(e,r))},randomInt(r,e){return Math.floor(Math.random()*(e-r+1))+r},clamp(r,e,t){return Math.min(Math.max(r,e),t)},capitalize(r){return r&&r.charAt(0).toUpperCase()+r.slice(1)},toKebabCase(r){return r.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()},toCamelCase(r){return r.replace(/[-_\s]+(.)?/g,(e,t)=>t?t.toUpperCase():"").replace(/^[A-Z]/,e=>e.toLowerCase())}},A=[];let L=0;const P=new Set;let T=!0;const F=(r,e)=>{A.push(r);try{return e()}finally{A.pop()}},B=r=>{if(L>0){P.add(r);return}r()},ce=()=>{for(const r of Array.from(P))P.delete(r),r()};class k{constructor(e){this._value=e,this.subscribers=new Set}get value(){if(T){const e=A[A.length-1];e&&this.subscribers.add(e)}return this._value}set value(e){if(!Object.is(this._value,e)){this._value=e;for(const t of this.subscribers)B(t)}}peek(){return this._value}update(e){this.value=e(this._value)}}class H{constructor(e){this.compute=e,this.dirty=!0,this.subscribers=new Set,this.markDirty=()=>{this.dirty=!0;for(const t of this.subscribers)B(t)}}get value(){const e=A[A.length-1];return e&&this.subscribers.add(e),this.dirty&&(this.dirty=!1,this.cachedValue=F(this.markDirty,this.compute)),this.cachedValue}}const U=r=>new k(r),ue=r=>new H(r),$=r=>{let e,t=!1;const s=()=>{t||(e&&e(),e=F(s,r))};return s(),()=>{t=!0,e&&e()}},he=r=>{L+=1;try{r()}finally{L-=1,L===0&&ce()}},de=(r,e)=>{let t=e;try{const n=localStorage.getItem(r);n!==null&&(t=JSON.parse(n))}catch{}const s=U(t);return $(()=>{try{localStorage.setItem(r,JSON.stringify(s.value))}catch{}}),s},me=r=>({get value(){return r.value},peek(){return r.peek()}}),fe=(r,e,t={})=>{let s,n=!0;return $(()=>{const i=r.value;if(n){n=!1,s=i,t.immediate&&e(i,void 0);return}e(i,s),s=i})},pe=r=>{const e=T;T=!1;try{return r()}finally{T=e}},ge=r=>r instanceof k,ye=r=>r instanceof H,be=(r,e)=>{const{type:t}=e;if(t===String)return r;if(t===Number){const s=Number(r);return Number.isNaN(s)?r:s}if(t===Boolean){const s=r.trim().toLowerCase();return s===""||s==="true"||s==="1"?!0:s==="false"||s==="0"?!1:!!r}if(t===Object||t===Array)try{return JSON.parse(r)}catch{return r}if(typeof t=="function"){const s=t,n=t;try{return s(r)}catch{return new n(r)}}return r},we=(r,...e)=>r.reduce((t,s,n)=>`${t}${s}${e[n]??""}`,""),Se=(r,...e)=>{const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},s=n=>String(n??"").replace(/[&<>"'`]/g,o=>t[o]);return r.reduce((n,i,o)=>`${n}${i}${s(e[o])}`,"")},ve=(r,e)=>{class t extends HTMLElement{constructor(){super(),this.state={...e.state??{}},this.props={},this.attachShadow({mode:"open"}),this.syncProps()}static get observedAttributes(){return Object.keys(e.props??{})}connectedCallback(){try{e.beforeMount?.call(this),e.connected?.call(this),this.render()}catch(n){this.handleError(n)}}disconnectedCallback(){try{e.disconnected?.call(this)}catch(n){this.handleError(n)}}attributeChangedCallback(){try{this.syncProps(),this.render(!0)}catch(n){this.handleError(n)}}handleError(n){e.onError?e.onError.call(this,n):console.error(`bQuery component error in <${r}>:`,n)}setState(n,i){this.state[n]=i,this.render(!0)}getState(n){return this.state[n]}syncProps(){const n=e.props??{};for(const[i,o]of Object.entries(n)){const c=this.getAttribute(i);let l;if(c==null){if(o.required&&o.default===void 0)throw new Error(`bQuery component: missing required prop "${i}"`);l=o.default??void 0}else l=be(c,o);if(o.validator&&l!==void 0&&!o.validator(l))throw new Error(`bQuery component: validation failed for prop "${i}" with value ${JSON.stringify(l)}`);this.props[i]=l}}render(n=!1){try{if(n&&e.beforeUpdate&&e.beforeUpdate.call(this,this.props)===!1)return;const i=(l,h)=>{this.dispatchEvent(new CustomEvent(l,{detail:h,bubbles:!0,composed:!0}))};if(!this.shadowRoot)return;const o=e.render({props:this.props,state:this.state,emit:i}),c=e.styles?`<style>${e.styles}</style>`:"";this.shadowRoot.innerHTML=`${c}${o}`,n&&e.updated?.call(this)}catch(i){this.handleError(i)}}}customElements.get(r)||customElements.define(r,t)},Ae=async r=>{const e=typeof r=="function"?r:r.update,t=document;if(t.startViewTransition){await t.startViewTransition(()=>e()).finished;return}e()},O=r=>{const e=r.getBoundingClientRect();return{top:e.top,left:e.left,width:e.width,height:e.height}},R=(r,e,t={})=>{const{duration:s=300,easing:n="ease-out",onComplete:i}=t,o=O(r);if(o.width===0||o.height===0)return Promise.resolve();const c=e.left-o.left,l=e.top-o.top,h=e.width/o.width,f=e.height/o.height;if(c===0&&l===0&&h===1&&f===1)return Promise.resolve();const u=r;return u.style.transform=`translate(${c}px, ${l}px) scale(${h}, ${f})`,u.style.transformOrigin="top left",u.offsetHeight,new Promise(b=>{const y=u.animate([{transform:`translate(${c}px, ${l}px) scale(${h}, ${f})`},{transform:"translate(0, 0) scale(1, 1)"}],{duration:s,easing:n,fill:"forwards"});y.onfinish=()=>{u.style.transform="",u.style.transformOrigin="",i?.(),b()}})},Ce=async(r,e,t={})=>{const s=new Map;for(const i of r)s.set(i,O(i));e();const n=r.map(i=>{const o=s.get(i);return o?R(i,o,t):Promise.resolve()});await Promise.all(n)},Ee={stiffness:100,damping:10,mass:1,precision:.01},Le=(r,e={})=>{const{stiffness:t,damping:s,mass:n,precision:i}={...Ee,...e};let o=r,c=0,l=r,h=null,f=null;const u=new Set,b=()=>{for(const m of u)m(o)},y=()=>{const m=o-l,p=-t*m,M=-s*c,j=(p+M)/n;if(c+=j*(1/60),o+=c*(1/60),b(),Math.abs(c)<i&&Math.abs(m)<i){o=l,c=0,h=null,b(),f?.(),f=null;return}h=requestAnimationFrame(y)};return{to(m){return l=m,h!==null&&cancelAnimationFrame(h),new Promise(p=>{f=p,h=requestAnimationFrame(y)})},current(){return o},stop(){h!==null&&(cancelAnimationFrame(h),h=null),c=0,f?.(),f=null},onChange(m){return u.add(m),()=>u.delete(m)}}},Te={gentle:{stiffness:80,damping:15},snappy:{stiffness:200,damping:20},bouncy:{stiffness:300,damping:8},stiff:{stiffness:400,damping:30}};class Ne{constructor(e){this.bucketName=e,this.dbPromise=null,this.storeName="blobs"}openDB(){if(this.dbPromise)return this.dbPromise;const e=`bquery-bucket-${this.bucketName}`;return this.dbPromise=new Promise((t,s)=>{const n=indexedDB.open(e,1);n.onupgradeneeded=()=>{const i=n.result;i.objectStoreNames.contains(this.storeName)||i.createObjectStore(this.storeName)},n.onsuccess=()=>t(n.result),n.onerror=()=>s(n.error)}),this.dbPromise}async withStore(e,t){const s=await this.openDB();return new Promise((n,i)=>{const c=s.transaction(this.storeName,e).objectStore(this.storeName),l=t(c);l.onsuccess=()=>n(l.result),l.onerror=()=>i(l.error)})}async put(e,t){await this.withStore("readwrite",s=>s.put(t,e))}async get(e){return await this.withStore("readonly",s=>s.get(e))??null}async remove(e){await this.withStore("readwrite",t=>t.delete(e))}async keys(){return(await this.withStore("readonly",t=>t.getAllKeys())).map(t=>String(t))}}const Pe={async open(r){return new Ne(r)}};class ke{constructor(e){this.cache=e}async add(e){await this.cache.add(e)}async addAll(e){await this.cache.addAll(e)}async put(e,t){await this.cache.put(e,t)}async match(e){return this.cache.match(e)}async remove(e){return this.cache.delete(e)}async keys(){return(await this.cache.keys()).map(t=>t.url)}}const He={isSupported(){return"caches"in window},async open(r){if(!this.isSupported())throw new Error("bQuery: Cache Storage API not supported");const e=await caches.open(r);return new ke(e)},async delete(r){return this.isSupported()?caches.delete(r):!1},async keys(){return this.isSupported()?caches.keys():[]}},$e={isSupported(){return"Notification"in window},getPermission(){return this.isSupported()?Notification.permission:"denied"},async requestPermission(){return this.isSupported()?Notification.permission==="granted"?"granted":Notification.permission==="denied"?"denied":Notification.requestPermission():"denied"},send(r,e){return this.isSupported()?Notification.permission!=="granted"?(console.warn("bQuery: Notification permission not granted"),null):new Notification(r,e):(console.warn("bQuery: Notifications not supported in this browser"),null)}};class z{constructor(e){this.storage=e}async get(e){const t=this.storage.getItem(e);if(t===null)return null;try{return JSON.parse(t)}catch{return t}}async set(e,t){const s=typeof t=="string"?t:JSON.stringify(t);this.storage.setItem(e,s)}async remove(e){this.storage.removeItem(e)}async clear(){this.storage.clear()}async keys(){return Object.keys(this.storage)}}class Oe extends z{constructor(){super(localStorage)}}class Me extends z{constructor(){super(sessionStorage)}}class je{constructor(e){this.options=e,this.dbPromise=null}openDB(){return this.dbPromise?this.dbPromise:(this.dbPromise=new Promise((e,t)=>{const s=indexedDB.open(this.options.name,this.options.version??1);s.onupgradeneeded=()=>{const n=s.result;n.objectStoreNames.contains(this.options.store)||n.createObjectStore(this.options.store)},s.onsuccess=()=>e(s.result),s.onerror=()=>t(s.error)}),this.dbPromise)}async withStore(e,t){const s=await this.openDB();return new Promise((n,i)=>{const c=s.transaction(this.options.store,e).objectStore(this.options.store),l=t(c);l.onsuccess=()=>n(l.result),l.onerror=()=>i(l.error)})}async get(e){return await this.withStore("readonly",s=>s.get(e))??null}async set(e,t){await this.withStore("readwrite",s=>s.put(t,e))}async remove(e){await this.withStore("readwrite",t=>t.delete(e))}async clear(){await this.withStore("readwrite",e=>e.clear())}async keys(){return(await this.withStore("readonly",t=>t.getAllKeys())).map(t=>String(t))}}const De={local(){return new Oe},session(){return new Me},indexedDB(r){return new je(r)}};a.$=ae,a.$$=le,a.BQueryCollection=v,a.BQueryElement=g,a.Computed=H,a.Signal=k,a.batch=he,a.buckets=Pe,a.cache=He,a.capturePosition=O,a.component=ve,a.computed=ue,a.createTrustedHtml=te,a.effect=$,a.escapeHtml=re,a.flip=R,a.flipList=Ce,a.generateNonce=ne,a.getTrustedTypesPolicy=q,a.hasCSPDirective=ie,a.html=we,a.isComputed=ye,a.isSignal=ge,a.isTrustedTypesSupported=W,a.notifications=$e,a.persistedSignal=de,a.readonly=me,a.safeHtml=Se,a.sanitize=w,a.sanitizeHtml=w,a.signal=U,a.spring=Le,a.springPresets=Te,a.storage=De,a.stripTags=se,a.transition=Ae,a.untrack=pe,a.utils=C,a.watch=fe,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
2
2
  //# sourceMappingURL=full.umd.js.map