vrembem 4.0.0-next.31 → 4.0.0-next.33

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.
@@ -1,10 +1,10 @@
1
- (function(E,w){typeof exports=="object"&&typeof module<"u"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(E=typeof globalThis<"u"?globalThis:E||self,w(E.vrembem={}))})(this,function(E){"use strict";var Ie=E=>{throw TypeError(E)};var Fe=(E,w,S)=>w.has(E)||Ie("Cannot "+S);var $=(E,w,S)=>(Fe(E,w,"read from private field"),S?S.call(E):w.get(E)),_=(E,w,S)=>w.has(E)?Ie("Cannot add the same private member more than once"):w instanceof WeakSet?w.add(E):w.set(E,S),k=(E,w,S,W)=>(Fe(E,w,"write to private field"),W?W.call(E,S):w.set(E,S),S);var tt,ct,ft,ut,dt,O,Y,ht;const w=":not([inert])",S=':not([tabindex^="-"])',W=":not(:disabled)",Xt=[`a[href]${w}${S}`,`area[href]${w}${S}`,`input:not([type="hidden"]):not([type="radio"])${w}${S}${W}`,`input[type="radio"]${w}${S}${W}`,`select${w}${S}${W}`,`textarea${w}${S}${W}`,`button${w}${S}${W}`,`details${w} > summary:first-of-type${S}`,`iframe${w}${S}`,`audio[controls]${w}${S}`,`video[controls]${w}${S}`,`[contenteditable]${w}${S}`,`[tabindex]${w}${S}`];function Gt(t,e="config"){const n=(t.getAttribute(`data-${e}`)||"").replace(/'/g,'"');return n?JSON.parse(n):{}}function Dt(t){return typeof t=="string"?document.getElementById(t):t instanceof HTMLElement?t:null}async function z(t,e,...i){e in t&&typeof t[e]=="function"&&await t[e](...i)}function qt(t,e,i){if(typeof e=="string"){const s=document.querySelector(e);if(!s)throw new Error(`No teleport reference found for selector: ${e}`);e=s}else if(!(e instanceof HTMLElement))throw new Error(`Not a valid teleport reference: '${e}'`);if(typeof e[i]!="function")throw new Error(`Not a valid teleport method: '${i}'`);let n=document.createComment("teleported #"+t.id);return t.before(n),e[i](t),()=>{n&&(n.after(t),n.remove(),n=null)}}function Zt(t){return t.split("-").map((e,i)=>i===0?e:e.charAt(0).toUpperCase()+e.slice(1)).join("")}function It(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function te(t){if(typeof t=="number")return t;const e=parseFloat(t);if(!Number.isNaN(e)){const i=t.includes("ms");return e*(i?1:1e3)}throw new Error(`Could not convert value to milliseconds: ${t}`)}function gt(t,e,i,n,s=0){return new Promise(r=>{t.classList.remove(e),t.classList.add(i),setTimeout(()=>{t.classList.add(n),t.classList.remove(i),r(t)},te(s))})}function ee(t,e={}){const i={fallback:null,element:document.body,...e};if(!t.startsWith("--")){const s=Ct();s&&(t=`${s}${t}`),t=`--${t}`}const n=getComputedStyle(i.element).getPropertyValue(t).trim();if(n)return n;if(i.fallback)return i.fallback;throw new Error(`CSS variable "${t}" was not found!`)}async function B(t,e,i){await z(e,t,i),i&&await z(i,t);for(const n of e.plugins)await z(n,t,{plugin:n,parent:e,entry:i});await e.emit(t,i)}function ne(t){const e=getComputedStyle(t.el),i={},n=t.getSetting("customProps");for(let s=0;s<n.length;s++){const r=Ct(),o=t.parent.module.toLowerCase(),l=It(n[s]),a=e.getPropertyValue(`--${r}${o}-${l}`).trim();a&&(i[l]=a)}return i}function Ct(){return getComputedStyle(document.body).getPropertyValue("--vb-prefix").trim()}function He(t,e,i="camel"){return e=i==="camel"?Zt(e):It(e),t.split(".").concat(e).reduce((n,s)=>n==null?void 0:n[s],this)}function ie(t,e={}){const{fallback:i,props:n=["dataConfig","customProps","settings","parent.settings"]}=e;for(const s of n){const r=s!=="customProps"?"camel":"kebab",o=He.call(this,s,t,r);if(o!==void 0)return o}if(i!==void 0)return i;throw new Error(`${this.parent.module} setting does not exist: ${t}`)}function Ne(t,e){e&&document.querySelectorAll(e).forEach(n=>{t?n.style.overflow="hidden":n.style.removeProperty("overflow")})}function Be(t,e){e&&document.querySelectorAll(e).forEach(n=>{t?(n.inert=!0,n.setAttribute("aria-hidden","true")):(n.inert=!1,n.removeAttribute("aria-hidden"))})}function mt(t,e,i){Be(!!t,e),Ne(!!t,i)}const se={on(t,e,...i){this.events[t]||(this.events[t]=[]),this.events[t].some(s=>s.listener===e)||this.events[t].push({listener:e,args:i})},off(t,e){this.events[t]&&(this.events[t]=this.events[t].filter(i=>i.listener!==e))},async emit(t,e){if(t=t.startsWith("on")?t.slice(2,3).toLowerCase()+t.slice(3):t,!!this.events[t])for(const{listener:i,args:n}of this.events[t])await i(e,...n)}};class oe extends Array{constructor(e=null){super(),this.el=e,this.el&&this.set()}get first(){return this[0]}get last(){return this[this.length-1]}set(e=this.el){this.length=0,this.push(...e.querySelectorAll(Xt.join(",")))}clear(){this.length=0}}class re{constructor(e=null){this.el=e,this.focusable=new oe,this.handleFocusTrap=Ue.bind(this)}on(e=this.el){this.focusable.set(e),this.focusable.length?document.addEventListener("keydown",this.handleFocusTrap):document.addEventListener("keydown",le)}off(){this.focusable.clear(),document.removeEventListener("keydown",this.handleFocusTrap),document.removeEventListener("keydown",le)}}function le(t){(t.key==="Tab"||t.keyCode===9)&&t.preventDefault()}function Ue(t){if(t.key!=="Tab"&&t.keyCode!==9)return;const{activeElement:e}=document,{el:i,focusable:n}=this,s=t.shiftKey,r=e===n.first||e===i,o=e===n.last||e===i;(s&&r||!s&&o)&&(t.preventDefault(),(s?n.last:n.first).focus())}function Ft(t,e=!0){const i=localStorage.getItem(t),n=i?JSON.parse(i):{};return{get(s,r=void 0){return s?s in n?n[s]:r:n},set(s,r){return r?n[s]=r:delete n[s],e&&localStorage.setItem(t,JSON.stringify(n)),n}}}class ae extends Array{constructor(e={}){super(),this.presets=e}applySettings(e){var r;const i=(e==null?void 0:e.defaults)||{},n=((r=this.presets)==null?void 0:r[e.name])||{},s=(e==null?void 0:e.options)||{};e.settings={...i,...n,...s}}validate(e){return!("name"in e)||typeof e.name!="string"?(console.error("Plugin requires a name!"),!1):!0}get(e){return this.find(i=>i.name===e)}add(e){if(Array.isArray(e))e.forEach(i=>this.add(i));else if(this.applySettings(e),this.validate(e)){const i=this.findIndex(n=>n.name===e.name);~i?this[i]=e:this.push(e)}}remove(e){const i=this.findIndex(n=>n.name===e);~i&&this.splice(i,1)}}class ce extends Array{constructor(e={}){super(),this.settings=e}get copy(){return[...this]}get top(){const e=this[this.length-1];return e||null}updateIndex(){this.forEach((e,i)=>{e.el.style.zIndex=null;const n=getComputedStyle(e.el)["z-index"];e.el.style.zIndex=parseInt(n)+i+1})}onChange(){this.updateIndex(),typeof this.settings.onChange=="function"&&this.settings.onChange()}add(e){this.push(e),this.onChange()}remove(e){const i=this.findIndex(n=>n.id===e.id);~i&&(e.el.style.zIndex=null,this.splice(i,1),this.onChange())}moveToTop(e){const i=this.findIndex(n=>n.id===e.id);~i&&(this.splice(i,1),this.add(e))}}const Ve={condition:!0},_e={primary:"hsl(152deg 60% 50%)",secondary:"hsl(214deg 50% 50%)",neutral:"hsl(214deg 20% 50%)",important:"hsl(0deg 80% 50%)"};function We(t={}){const e={name:"debug",defaults:Ve,options:t};function i(o,l=[],a=["primary","secondary"]){const c=a.map(d=>`color: ${_e[d]}`);console.log(`%c📡 DEBUG: %c${o}`,...c,...l)}function n(o,...l){return typeof o=="function"?o(...l):o}const s={beforeMountRef:i.bind(null,"Event > beforeMount()"),afterMountRef:i.bind(null,"Event > afterMount()"),beforeUnmountRef:i.bind(null,"Event > beforeUnmount()",[],["important","neutral"]),afterUnmountRef:i.bind(null,"Event > afterUnmount()",[],["important","neutral"]),createEntryRef:(o,{parent:l,plugin:a})=>{if(n(a.settings.condition,o)){const c=l.collection.length;i(`Event > createEntry() > [${c}] #${o.id}`)}},registerEntryRef:(o,{parent:l,plugin:a})=>{if(n(a.settings.condition,o)){const c=l.collection.length;i(`Event > registerEntry() > [${c}] #${o.id}`)}},destroyEntryRef:(o,{parent:l,plugin:a})=>{if(n(a.settings.condition,o)){const c=l.collection.length;i(`Event > destroyEntry() > [${c}] #${o.id}`,[],["important","neutral"])}},deregisterEntryRef:(o,{parent:l,plugin:a})=>{if(n(a.settings.condition,o)){const c=l.collection.length;i(`Event > deregisterEntry() > [${c}] #${o.id}`,[],["important","neutral"])}}};return{...e,...{setup({parent:o}){i("Plugin > setup()",arguments,["secondary","neutral"]),o.on("beforeMount",s.beforeMountRef),o.on("createEntry",s.createEntryRef,{parent:o,plugin:this}),o.on("registerEntry",s.registerEntryRef,{parent:o,plugin:this}),o.on("afterMount",s.afterMountRef),o.on("beforeUnmount",s.beforeUnmountRef),o.on("destroyEntry",s.destroyEntryRef,{parent:o,plugin:this}),o.on("deregisterEntry",s.deregisterEntryRef,{parent:o,plugin:this}),o.on("afterUnmount",s.afterUnmountRef)},teardown({parent:o}){i("Plugin > teardown()",arguments,["secondary","neutral"]),o.off("beforeMount",s.beforeMountRef),o.off("createEntry",s.createEntryRef),o.off("registerEntry",s.registerEntryRef),o.off("afterMount",s.afterMountRef),o.off("beforeUnmount",s.beforeUnmountRef),o.off("destroyEntry",s.destroyEntryRef),o.off("deregisterEntry",s.deregisterEntryRef),o.off("afterUnmount",s.afterUnmountRef)},beforeMount(){i("Hook > beforeMount()",arguments)},onCreateEntry({parent:o,entry:l}){if(n(this.settings.condition,l)){const a=o.collection.length;i(`Hook > onCreateEntry() > [${a}] #${l.id}`,arguments)}},onRegisterEntry({parent:o,entry:l}){if(n(this.settings.condition,l)){const a=o.collection.length-1;i(`Hook > onRegisterEntry() > [${a}] #${l.id}`,arguments)}},afterMount(){i("Hook > afterMount()",arguments)},beforeUnmount(){i("Hook > beforeUnmount()",arguments,["important","neutral"])},onDestroyEntry({parent:o,entry:l}){if(n(this.settings.condition,l)){const a=o.collection.length-1;i(`Hook > onDestroyEntry() > [${a}] #${l.id}`,arguments,["important","neutral"])}},onDeregisterEntry({parent:o,entry:l}){if(n(this.settings.condition,l)){const a=o.collection.length;i(`Hook > onDeregisterEntry() > [${a}] #${l.id}`,arguments,["important","neutral"])}},afterUnmount(){i("Hook > afterUnmount()",arguments,["important","neutral"])}}}}const ze={condition:!0};function Qe(t={}){const e={name:"focusTrap",defaults:ze,options:t},i={setup({parent:o}){o.on("opened",s,this),o.on("closed",r,this)},teardown({parent:o}){o.off("opened",s),o.off("closed",r)},onCreateEntry({entry:o}){o.focusTrap=new re}};function n(o,...l){return typeof o=="function"?o(...l):o}function s(o,l){var c;const a={plugin:l,parent:o.parent,entry:o};n(l.settings.condition,a)&&((c=o.focusTrap)==null||c.on(o.dialog))}function r(o,l){var c;const a={plugin:l,parent:o.parent,entry:o};n(l.settings.condition,a)&&((c=o.focusTrap)==null||c.off())}return{...e,...i}}const Ke={dataBreakpoint:"breakpoint",dataMediaQuery:"media-query",token:"{{BP}}",breakpoint:null,mediaQuery:"(min-width: {{BP}})",breakpoints:{},mediaQueries:{},onChange:()=>{}};function je(t={}){const e={name:"mediaQuery",defaults:Ke,options:t},i={onCreateEntry({entry:l}){r.call(this,l)},onDestroyEntry({entry:l}){o(l)}};function n(l){const a=l.el.getAttribute(`data-${this.settings.dataMediaQuery}`);return!a&&l.id in this.settings.mediaQueries?this.settings.mediaQueries[l.id]:a}function s(l){let a=l.el.getAttribute(`data-${this.settings.dataBreakpoint}`);return!a&&l.id in this.settings.breakpoints&&(a=this.settings.breakpoints[l.id]),a&&a in this.settings.breakpoints&&(a=this.settings.breakpoints[a]),a&&(a=getComputedStyle(document.body).getPropertyValue(`--${Ct()}breakpoint-${a}`).trim()||a),a||this.settings.breakpoint}function r(l){let a=n.call(this,l);const c=s.call(this,l);if(!c&&!a)return;c&&!a&&(a=this.settings.mediaQuery);const d=a.replace(new RegExp(`${this.settings.token}`,"g"),c);l.mql=window.matchMedia(d),l.mql.onchange=f=>{this.settings.onChange(f,l)},this.settings.onChange(l.mql,l)}function o(l){l.mql&&(l.mql.onchange=null,l.mql=null)}return{...e,...i}}const Ye={prop:"state",value:null,keyPrefix:"VB:",key:null,condition:!1,onChange(){}};function Je(t={}){const e={name:"propStore",defaults:Ye,options:t,store:null},i={setup({parent:l}){this.store=Ft(o.call(this,l.module))},async onCreateEntry({entry:l}){await n.call(this,l)},onDestroyEntry({entry:l}){r.call(this,l)}};async function n(l){let a=l[this.settings.prop]||null;const c={plugin:this,parent:l.parent,entry:l};Object.defineProperty(l,this.settings.prop,{configurable:!0,get(){return a},set:async d=>{if(a===d)return;const f=a;a=d,s(this.settings.condition,c,d,f)&&this.store.set(l.id,d),await this.settings.onChange(c,d,f)}}),Object.defineProperty(l,"store",{configurable:!0,get:()=>this.store.get(l.id),set:d=>{l[this.settings.prop]=d}}),l[this.settings.prop]=await s(this.settings.value,c)||l[this.settings.prop]}function s(l,...a){return typeof l=="function"?l(...a):l}async function r(l){const a=l[this.settings.prop];delete l[this.settings.prop],l[this.settings.prop]=a,this.store.set(l.id,null)}function o(l){const a=this.settings.prop.charAt(0).toUpperCase()+this.settings.prop.slice(1),c=this.settings.key||l+a;return this.settings.keyPrefix+c}return{...e,...i}}const Xe={where:null,how:"append"};function Ge(t={}){const e={name:"teleport",defaults:Xe,options:t},i={onCreateEntry({plugin:r,entry:o}){n(r,o)},onDestroyEntry({plugin:r,entry:o}){s(r,o)}};function n(r,o){o.teleport=()=>{typeof o.teleportReturn=="function"&&o.teleportReturn(),o.teleportReturn=qt(o.el,o.getSetting("teleport",{fallback:r.settings.where}),o.getSetting("teleportMethod",{fallback:r.settings.how}))},o.teleport(),o.parent.emit("teleport",{plugin:r,parent,entry:o})}function s(r,o){typeof o.teleportReturn=="function"&&o.teleportReturn(),o.parent.emit("teleportReturn",{plugin:r,parent,entry:o})}return{...e,...i}}const qe={dataConfig:"config",customProps:[]};class pt{constructor(e,i,n={}){this.parent=e,this.id=(i==null?void 0:i.id)||i,this.el=Dt(i),this.settings={...n},this.dataConfig={},this.customProps={}}applySettings(e){return Object.assign(this.settings,e)}getSetting(e,i){return ie.call(this,e,i)}buildDataConfig(){return Object.assign(this.dataConfig,Gt(this.el,this.getSetting("dataConfig")))}buildCustomProps(){return Object.assign(this.customProps,ne(this))}async init(e={}){if(this.el===null)throw new Error(`${this.parent.module} element was not found with ID: "${this.id}"`);this.applySettings(e),this.buildDataConfig(),this.buildCustomProps()}async destroy(){Object.getOwnPropertyNames(this).forEach(e=>{e!=="id"&&delete this[e]})}}class $t{constructor(e={}){this.module=this.constructor.name,this.collection=[],this.entryClass=pt,this.settings={...qe,...e},this.plugins=new ae(this.settings.presets),this.events={},Object.assign(this,se)}get(e,i="id"){return this.collection.find(n=>n[i]===e)}applySettings(e){return Object.assign(this.settings,e)}async createEntry(e,i){const n=new this.entryClass(this,e,i);return await z(n,"init"),await B("onCreateEntry",this,n),n}async destroyEntry(e){return await B("onDestroyEntry",this,e),await z(e,"destroy"),e}async register(e,i={}){const n=Dt(e);if(n===null)throw new Error(`${this.module} element was not found with ID: "${(e==null?void 0:e.id)||e}"`);const s=this.collection.findIndex(r=>r.id===n.id);if(~s){const r=this.collection[s];return r.el=n,typeof r.init=="function"&&await r.init(i),r}else{const r=await this.createEntry(n,i);return this.collection.push(r),await B("onRegisterEntry",this,r),r}}async deregister(e){const i=this.collection.findIndex(n=>n.id===e);if(~i){const n=await this.destroyEntry(this.collection[i]);return await B("onDeregisterEntry",this,this.collection[i]),this.collection.splice(i,1),n}return null}async mount(e={}){var n;this.applySettings(e);for(const s of((n=this.settings)==null?void 0:n.plugins)||[])this.plugins.add(s);for(const s of this.plugins)await z(s,"setup",{plugin:s,parent:this});await B("beforeMount",this);const i=document.querySelectorAll(this.settings.selector);for(const s of i)await this.register(s);return await B("afterMount",this),this}async unmount(){for(await B("beforeUnmount",this);this.collection.length>0;)await this.deregister(this.collection[0].id);await B("afterUnmount",this);for(const e of this.plugins)await z(e,"teardown",{plugin:e,parent:this});for(const e of[...this.plugins])this.plugins.remove(e.name);return this}}function Ze(t){const e={prefix:ee("prefix-themes",{fallback:"vb-theme-"}),themes:["root","light","dark"],storeKey:"VB:Profile"};for(const[r]of Object.entries(e))t&&t[r]&&(e[r]=t[r]);const i={onInit(){},onChange(){}};for(const[r]of Object.entries(i))t&&t[r]&&(i[r]=t[r]);const n=Ft(e.storeKey),s={settings:e,add(r){e.themes.push(r)},remove(r){const o=e.themes.indexOf(r);~o&&e.themes.splice(o,1)},callback(r){i[r].call(this)},get class(){return`${e.prefix}${this.theme}`},get classes(){return e.themes.map(r=>`${e.prefix}${r}`)},get themes(){return e.themes},get theme(){return n.get("theme")||"root"},set theme(r){e.themes.includes(r)?this.theme!=r&&(n.set("theme",r),document.documentElement.classList.remove(...this.classes),document.documentElement.classList.add(`${e.prefix}${r}`),this.callback("onChange")):console.error(`Not a valid theme value: "${r}"`)}};return s.callback("onInit"),s}const tn=Object.freeze(Object.defineProperty({__proto__:null,Collection:$t,CollectionEntry:pt,FocusTrap:re,FocusableArray:oe,PluginsArray:ae,StackArray:ce,cssVar:ee,debug:We,dispatchLifecycleHook:B,eventEmitter:se,focusTrap:Qe,focusableSelectors:Xt,getCustomProps:ne,getDataConfig:Gt,getElement:Dt,getPrefix:Ct,getSetting:ie,localStore:Ft,maybeRunMethod:z,mediaQuery:je,propStore:Je,setGlobalState:mt,teleport:Ge,teleportElement:qt,themeStore:Ze,toCamel:Zt,toKebab:It,toMilliseconds:te,transition:gt},Symbol.toStringTag,{value:"Module"})),en={presets:{focusTrap:{condition:({entry:t})=>t.state==="closed"||t.state==="opened"&&t.mode==="modal"},mediaQuery:{onChange(t,e){e.mode=t.matches?"inline":"modal"}},propStore:{prop:"inlineState",value:({entry:t})=>t.store,condition:({entry:t})=>["opened","closed","indeterminate"].includes(t.state),onChange:({entry:t})=>t.applyState()}},dataOpen:"drawer-open",dataClose:"drawer-close",dataToggle:"drawer-toggle",selector:".drawer",selectorDialog:".drawer__dialog",selectorScreen:".drawer",selectorFocus:"[data-focus]",selectorInert:null,selectorOverflow:"body",stateOpened:"is-opened",stateOpening:"is-opening",stateClosing:"is-closing",stateClosed:"is-closed",classModal:"drawer_modal",customProps:["transition-duration"],breakpoints:null,customEventPrefix:"drawer:",setTabindex:!0,transition:!0,transitionDuration:300};function nn(t){switch(t.mode){case"inline":return sn.call(this,t);case"modal":return on.call(this,t);default:throw new Error(`"${t.mode}" is not a valid drawer mode.`)}}async function sn(t){return t.el.classList.remove(t.getSetting("classModal")),t.dialog.removeAttribute("aria-modal"),mt(!1,t.getSetting("selectorInert"),t.getSetting("selectorOverflow")),t.applyState(),t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"switchMode",{detail:this,bubbles:!0})),await t.parent.emit("switchMode",t),t}async function on(t){return t.el.classList.add(t.getSetting("classModal")),t.dialog.setAttribute("aria-modal","true"),await t.close(!1,!1),t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"switchMode",{detail:this,bubbles:!0})),await t.parent.emit("switchMode",t),t}class rn extends pt{constructor(i,n,s={}){super(i,n,s);_(this,tt);this.dialog=null,this.trigger=null,this.state=null,this.inlineState=null,k(this,tt,"indeterminate")}get mode(){return $(this,tt)}set mode(i){$(this,tt)!==i&&(k(this,tt,i),nn.call(this.parent,this))}setState(i){this.state=i;const n=["opening","closing"];this.mode==="inline"&&!n.includes(i)&&(this.inlineState=i),i==="indeterminate"&&(this.el.classList.remove(this.getSetting("stateOpened")),this.el.classList.remove(this.getSetting("stateOpening")),this.el.classList.remove(this.getSetting("stateClosed")),this.el.classList.remove(this.getSetting("stateClosing")))}async applyState(){if(this.mode!=="modal"){if(this.inlineState==="opened")return await this.open(!1,!1);if(this.inlineState==="closed")return await this.close(!1,!1);if(this.state===null){if(this.el.classList.contains(this.getSetting("stateOpened")))return await this.open(!1,!1);if(this.el.classList.contains(this.getSetting("stateClosed")))return await this.close(!1,!1)}return this.setState("indeterminate")}}async open(i,n){return this.parent.open(this,i,n)}async close(i,n){return this.parent.close(this,i,n)}async toggle(i,n){return this.parent.toggle(this,i,n)}async deregister(){return this.parent.deregister(this.id)}async onCreateEntry(){const i=this.el.querySelector(this.getSetting("selectorDialog"));this.dialog=i||this.el,this.getSetting("setTabindex")&&this.dialog.setAttribute("tabindex","-1"),await this.applyState(),this.inlineState=this.state,this.mode=this.el.classList.contains(this.getSetting("classModal"))?"modal":"inline"}async onDestroyEntry(){this.mode==="modal"&&this.state==="opened"&&await this.close(!1)}}tt=new WeakMap;function st(t){const e=typeof t=="string"?this.get(t):t;if(e)return e;throw new Error(`Drawer not found in collection with id of "${t.id||t}".`)}async function ln(t){const e=t.target.closest(`
2
- [data-${this.settings.dataOpen}],
3
- [data-${this.settings.dataToggle}],
4
- [data-${this.settings.dataClose}]
5
- `);if(e){t.preventDefault(),e.matches(`[data-${this.settings.dataToggle}]`)&&e.getAttribute(`data-${this.settings.dataToggle}`).trim().split(" ").forEach(n=>{const s=st.call(this,n);return s.trigger=e,s.toggle()}),e.matches(`[data-${this.settings.dataOpen}]`)&&e.getAttribute(`data-${this.settings.dataOpen}`).trim().split(" ").forEach(n=>{const s=st.call(this,n);return s.trigger=e,s.open()}),e.matches(`[data-${this.settings.dataClose}]`)&&e.getAttribute(`data-${this.settings.dataClose}`).trim().split(" ").forEach(n=>{if(n){const s=st.call(this,n);return s.trigger=e,s.close()}else{const s=t.target.closest(this.settings.selector);if(s)return this.close(s.id)}});return}if(this.activeModal&&t.target.matches(this.settings.selectorScreen))return this.close(this.activeModal.id)}function an(t){if(t.key==="Escape"&&this.activeModal)return this.close(this.activeModal.id)}function fe(t){t.state==="opened"?(t.dialog.querySelector(this.settings.selectorFocus)||t.dialog).focus():t.trigger&&(t.trigger.focus(),t.trigger=null)}async function ue(t,e,i=!0){const n=st.call(this,t);return(n.state==="closed"||n.state==="indeterminate"||n.state===null)&&(n.setState("opening"),e??n.getSetting("transition")?await gt(n.el,n.getSetting("stateClosed"),n.getSetting("stateOpening"),n.getSetting("stateOpened"),n.getSetting("transitionDuration")):(n.el.classList.add(n.getSetting("stateOpened")),n.el.classList.remove(n.getSetting("stateClosed"))),n.setState("opened"),n.mode==="modal"&&mt(!0,n.getSetting("selectorInert"),n.getSetting("selectorOverflow")),i&&fe.call(this,n),n.el.dispatchEvent(new CustomEvent(n.getSetting("customEventPrefix")+"opened",{detail:this,bubbles:!0})),await n.parent.emit("opened",n)),n}async function de(t,e,i=!0){const n=st.call(this,t);return(n.state==="opened"||n.state==="indeterminate"||n.state===null)&&(n.setState("closing"),document.activeElement.blur(),e??n.getSetting("transition")?await gt(n.el,n.getSetting("stateOpened"),n.getSetting("stateClosing"),n.getSetting("stateClosed"),n.getSetting("transitionDuration")):(n.el.classList.add(n.getSetting("stateClosed")),n.el.classList.remove(n.getSetting("stateOpened"))),n.setState("closed"),n.mode==="modal"&&mt(!1,n.getSetting("selectorInert"),n.getSetting("selectorOverflow")),i&&fe.call(this,n),n.el.dispatchEvent(new CustomEvent(n.getSetting("customEventPrefix")+"closed",{detail:this,bubbles:!0})),await n.parent.emit("closed",n)),n}async function cn(t,e,i){const n=st.call(this,t);return n.state==="closed"?ue.call(this,n,e,i):de.call(this,n,e,i)}class fn extends $t{constructor(i){super({...en,...i});_(this,ct);_(this,ft);this.module="Drawer",this.entryClass=rn,k(this,ct,ln.bind(this)),k(this,ft,an.bind(this))}get activeModal(){return this.collection.find(i=>i.state==="opened"&&i.mode==="modal")}async open(i,n,s){return ue.call(this,i,n,s)}async close(i,n,s){return de.call(this,i,n,s)}async toggle(i,n,s){return cn.call(this,i,n,s)}async afterMount(){document.addEventListener("click",$(this,ct),!1),document.addEventListener("keydown",$(this,ft),!1)}async beforeUnmount(){this.trigger=null}async afterUnmount(){document.removeEventListener("click",$(this,ct),!1),document.removeEventListener("keydown",$(this,ft),!1)}}ct=new WeakMap,ft=new WeakMap;const un={dataOpen:"modal-open",dataClose:"modal-close",dataReplace:"modal-replace",selector:".modal",selectorDialog:".modal__dialog",selectorScreen:".modal",selectorRequired:'[role="alertdialog"]',selectorFocus:"[data-focus]",selectorInert:null,selectorOverflow:"body",stateOpened:"is-opened",stateOpening:"is-opening",stateClosing:"is-closing",stateClosed:"is-closed",customProps:["transition-duration"],customEventPrefix:"modal:",setTabindex:!0,transition:!0,transitionDuration:300};class dn extends pt{constructor(e,i,n={}){super(e,i,n),this.state="closed",this.dialog=null}get isRequired(){return this.dialog.matches(this.getSetting("selectorRequired"))}async open(e,i){return this.parent.open(this,e,i)}async close(e,i){return this.parent.close(this,e,i)}async replace(e,i){return this.parent.replace(this,e,i)}async deregister(){return this.parent.deregister(this.id)}async onCreateEntry(){const e=this.el.querySelector(this.getSetting("selectorDialog"));this.dialog=e||this.el,this.dialog.setAttribute("aria-modal","true"),this.dialog.hasAttribute("role")||this.dialog.setAttribute("role","dialog"),this.getSetting("setTabindex")&&this.dialog.setAttribute("tabindex","-1")}async onRegisterEntry(){this.el.classList.contains(this.getSetting("stateOpened"))?await this.open(!1):(this.el.classList.remove(this.getSetting("stateOpening")),this.el.classList.remove(this.getSetting("stateClosing")),this.el.classList.add(this.getSetting("stateClosed")))}async onDestroyEntry(){this.state==="opened"&&await this.close(!1)}}function yt(t){const e=typeof t=="string"?this.get(t):this.get(t.id);if(e)return e;throw new Error(`Modal not found in collection with id of "${t.id||t}".`)}async function hn(t){const e=t.target.closest(`
6
- [data-${this.settings.dataOpen}],
7
- [data-${this.settings.dataReplace}],
8
- [data-${this.settings.dataClose}]
9
- `);if(e){if(t.preventDefault(),e.matches(`[data-${this.settings.dataOpen}]`)){const i=e.getAttribute(`data-${this.settings.dataOpen}`).trim(),n=yt.call(this,i);return t.target.closest(this.settings.selector)||(this.trigger=e),n.open()}if(e.matches(`[data-${this.settings.dataReplace}]`)){const i=e.getAttribute(`data-${this.settings.dataReplace}`).trim(),n=yt.call(this,i);return t.target.closest(this.settings.selector)||(this.trigger=e),n.replace()}if(e.matches(`[data-${this.settings.dataClose}]`)){const i=e.getAttribute(`data-${this.settings.dataClose}`).trim();return i==="*"?this.closeAll():this.close(i)}}if(this.active&&t.target.matches(this.settings.selectorScreen)&&!this.active.isRequired)return this.close(this.active.id)}function gn(t){if(t.key==="Escape"&&this.active&&!this.active.dialog.matches(this.settings.selectorRequired))return this.close()}function At(){this.active?(this.active.dialog.querySelector(this.settings.selectorFocus)||this.active.dialog).focus():this.trigger&&(this.trigger.focus(),this.trigger=null)}async function he(t,e=void 0,i=!0){const n=yt.call(this,t);return this.stack.moveToTop(n),n.state==="closed"&&(n.state="opening",this.stack.add(n),e??n.getSetting("transition")?await gt(n.el,n.getSetting("stateClosed"),n.getSetting("stateOpening"),n.getSetting("stateOpened"),n.getSetting("transitionDuration")):(n.el.classList.add(n.getSetting("stateOpened")),n.el.classList.remove(n.getSetting("stateClosed"))),n.state="opened"),i&&At.call(this),n.el.dispatchEvent(new CustomEvent(n.getSetting("customEventPrefix")+"opened",{detail:n,bubbles:!0})),await n.parent.emit("opened",n),n}async function ge(t,e,i=!0){const n=t?yt.call(this,t):this.active;return n&&n.state==="opened"&&(n.state="closing",document.activeElement.blur(),e??n.getSetting("transition")?await gt(n.el,n.getSetting("stateOpened"),n.getSetting("stateClosing"),n.getSetting("stateClosed"),n.getSetting("transitionDuration")):(n.el.classList.add(n.getSetting("stateClosed")),n.el.classList.remove(n.getSetting("stateOpened"))),this.stack.remove(n),n.state="closed",i&&At.call(this),n.el.dispatchEvent(new CustomEvent(n.getSetting("customEventPrefix")+"closed",{detail:n,bubbles:!0})),await n.parent.emit("closed",n)),n}async function Ht(t,e){const i=[];return await Promise.all(this.stack.copy.map(async n=>{t&&t===n.id||(i.push(await ge.call(this,n,e,!1)),n.trigger=null)})),i}async function mn(t,e,i=!0){const n=yt.call(this,t);let s,r;return n.state==="opened"?(s=n,r=await Ht.call(this,n.id,e)):(r=Ht.call(this,!1,e),s=he.call(this,n,e,!1),await Promise.all([s,r])),i&&At.call(this),{opened:s,closed:r}}class pn extends $t{constructor(i){super({...un,...i});_(this,ut);_(this,dt);this.module="Modal",this.entryClass=dn,this.trigger=null,k(this,ut,hn.bind(this)),k(this,dt,gn.bind(this)),this.stack=new ce({onChange:()=>{mt(this.stack.top,this.settings.selectorInert,this.settings.selectorOverflow)}})}get active(){return this.stack.top}async open(i,n,s){return he.call(this,i,n,s)}async close(i,n,s){return ge.call(this,i,n,s)}async replace(i,n,s){return mn.call(this,i,n,s)}async closeAll(i=!1,n,s=!0){const r=await Ht.call(this,i,n);return s&&At.call(this),r}async afterMount(){document.addEventListener("click",$(this,ut),!1),document.addEventListener("keydown",$(this,dt),!1)}async beforeUnmount(){this.trigger=null}async afterUnmount(){document.removeEventListener("click",$(this,ut),!1),document.removeEventListener("keydown",$(this,dt),!1)}}ut=new WeakMap,dt=new WeakMap;const yn={selector:".popover",selectorTooltip:".popover_tooltip",selectorArrow:".popover__arrow",stateActive:"is-active",customProps:["placement","event","offset","flip-padding","shift-padding","arrow-padding","toggle-delay"],customEventPrefix:"popover:",placement:"bottom",event:"click",offset:0,flipPadding:0,shiftPadding:0,arrowPadding:0,toggleDelay:0};function me(t,e,i){Object.assign(t.style,{left:e!=null?`${e}px`:"",top:i!=null?`${i}px`:""})}function pe(t,e){let i=t.getSetting("toggle-delay");typeof i=="string"&&(i.indexOf(",")>-1&&(i=i.split(",")),i.indexOf(" ")>-1&&(i=i.split(" "))),Array.isArray(i)&&(i=i[e]);const n=Number(i);if(Number.isNaN(n))throw new Error(`Provided delay value is not a number: "${i}"`);return n}function Nt(t){let e;const i=typeof t=="string"?t.trim().split(" "):[t];for(let n=0;n<i.length;n++)i[n]=Number(i[n]);switch(i.length){case 1:e=i[0];break;case 2:e={top:i[0],right:i[1],bottom:i[0],left:i[1]};break;case 3:e={top:i[0],right:i[1],bottom:i[2],left:i[1]};break;case 4:e={top:i[0],right:i[1],bottom:i[2],left:i[3]};break;default:e=!1;break}return e}function wn(t){return{offset:Number(t.getSetting("offset")),flip:{padding:Nt(t.getSetting("flip-padding"))},shift:{padding:Nt(t.getSetting("shift-padding"))},arrow:{element:t.getSetting("selectorArrow"),padding:Nt(t.getSetting("arrow-padding"))}}}function ye(t){const e=typeof t=="string"?this.get(t):this.get(t.id);if(e)return e;throw new Error(`Popover not found in collection with id of "${t}".`)}async function we(t){const e=t?ye.call(this,t):await be.call(this);return e&&e.state==="opened"&&(e.el.inert=!0,e.el.classList.remove(this.settings.stateActive),e.isTooltip||e.trigger.setAttribute("aria-expanded","false"),e.floatingCleanup(),e.state="closed",e.trigger===this.trigger&&(this.trigger=null),e.el.dispatchEvent(new CustomEvent(e.getSetting("customEventPrefix")+"closed",{detail:this,bubbles:!0})),await e.parent.emit("closed",e)),e}async function be(){const t=[];return await Promise.all(this.collection.map(async e=>{e.state==="opened"&&t.push(await we.call(this,e))})),t}function xe(t){t.state=="opened"&&setTimeout(()=>{const e=t.el.matches(":hover")===t.el||t.trigger.matches(":hover")===t.trigger;let i=document.activeElement.closest(`#${t.id}, [aria-controls="${t.id}"], [aria-describedby="${t.id}"]`);return!e&&!i&&t.close(),t},1)}function bn(t){t.state==="opened"?t.close():(this.trigger=t.trigger,t.open())}function xn(t){t.isTooltip&&(t.toggleDelayId&&clearTimeout(t.toggleDelayId),t.close())}function vn(t,e){if(t.isHovered=e,e.type=="focus"&&!t.trigger.matches(":focus-visible"))return;t.toggleDelayId&&clearTimeout(t.toggleDelayId);const i=t.trigger.getAttribute("aria-expanded");if(i&&i=="true")return;const n=this.activeHover?0:pe(t,0);this.activeHover&&this.activeHover.close(),t.toggleDelayId=setTimeout(()=>{t.id&&t.open()},n)}function En(t,e){setTimeout(()=>{t.isHovered=e,!t.isHovered&&(t.toggleDelayId&&clearTimeout(t.toggleDelayId),t.toggleDelayId=setTimeout(()=>{xe.call(this,t)},pe(t,1)))},1)}function Sn(t){switch(t.key){case"Escape":this.trigger&&this.trigger.focus(),be.call(this);return;case"Tab":this.collection.forEach(e=>{xe.call(this,e)});return;default:return}}function Cn(t){const e=this;document.addEventListener("click",function i(n){n.target.closest(`#${t.id}, [aria-controls="${t.id}"], [aria-describedby="${t.id}"]`)?t.el&&!t.el.classList.contains(e.settings.stateActive)&&this.removeEventListener("click",i):(t.el&&t.el.classList.contains(e.settings.stateActive)&&t.close(),this.removeEventListener("click",i))})}class $n extends pt{constructor(i,n,s={}){super(i,n,s);_(this,O);_(this,Y);this.state="closed",this.toggleDelayId=null,this.trigger=null,k(this,O,null),k(this,Y,{el:!1,trigger:!1}),this.floatingCleanup=()=>{}}get isTooltip(){return!!this.el.closest(this.getSetting("selectorTooltip"))||this.el.getAttribute("role")=="tooltip"}get isHovered(){return $(this,Y).el||$(this,Y).trigger}set isHovered(i){const n=i.type=="mouseenter"?!0:i.type=="mouseleave"?!1:void 0;if(n!=null)switch(i.target){case this.el:$(this,Y).el=n;break;case this.trigger:$(this,Y).trigger=n;break}}async open(){return this.parent.open(this)}async close(){return this.parent.close(this)}async deregister(){return this.parent.deregister(this.id)}registerEventListeners(){$(this,O)||(this.getSetting("event")==="hover"?(k(this,O,[{el:["el","trigger"],type:["mouseenter","focus"],listener:vn.bind(this.parent,this)},{el:["el","trigger"],type:["mouseleave","focusout"],listener:En.bind(this.parent,this)},{el:["trigger"],type:["click"],listener:xn.bind(this.parent,this)}]),$(this,O).forEach(n=>{n.el.forEach(s=>{n.type.forEach(r=>{this[s].addEventListener(r,n.listener,!1)})})})):(k(this,O,[{el:["trigger"],type:["click"],listener:bn.bind(this.parent,this)}]),$(this,O).forEach(n=>{n.el.forEach(s=>{n.type.forEach(r=>{this[s].addEventListener(r,n.listener,!1)})})})))}deregisterEventListeners(){$(this,O)&&($(this,O).forEach(i=>{i.el.forEach(n=>{i.type.forEach(s=>{this[n].removeEventListener(s,i.listener,!1)})})}),k(this,O,null))}async onCreateEntry(){this.trigger=document.querySelector(`[aria-controls="${this.id}"], [aria-describedby="${this.id}"]`),this.isTooltip?(this.settings.event="hover",this.el.setAttribute("role","tooltip")):this.trigger.setAttribute("aria-expanded","false"),this.registerEventListeners()}async onRegisterEntry(){this.el.classList.contains(this.getSetting("stateActive"))?await this.open():this.el.inert=!0}async onDestroyEntry(){this.state==="opened"&&await this.close(),this.floatingCleanup(),this.deregisterEventListeners()}}O=new WeakMap,Y=new WeakMap;const ot=Math.min,G=Math.max,kt=Math.round,Ot=Math.floor,D=t=>({x:t,y:t}),An={left:"right",right:"left",bottom:"top",top:"bottom"},kn={start:"end",end:"start"};function Bt(t,e,i){return G(t,ot(e,i))}function q(t,e){return typeof t=="function"?t(e):t}function Q(t){return t.split("-")[0]}function wt(t){return t.split("-")[1]}function Ut(t){return t==="x"?"y":"x"}function Vt(t){return t==="y"?"height":"width"}function K(t){return["top","bottom"].includes(Q(t))?"y":"x"}function _t(t){return Ut(K(t))}function On(t,e,i){i===void 0&&(i=!1);const n=wt(t),s=_t(t),r=Vt(s);let o=s==="x"?n===(i?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(o=Lt(o)),[o,Lt(o)]}function Ln(t){const e=Lt(t);return[Wt(t),e,Wt(e)]}function Wt(t){return t.replace(/start|end/g,e=>kn[e])}function Rn(t,e,i){const n=["left","right"],s=["right","left"],r=["top","bottom"],o=["bottom","top"];switch(t){case"top":case"bottom":return i?e?s:n:e?n:s;case"left":case"right":return e?r:o;default:return[]}}function Pn(t,e,i,n){const s=wt(t);let r=Rn(Q(t),i==="start",n);return s&&(r=r.map(o=>o+"-"+s),e&&(r=r.concat(r.map(Wt)))),r}function Lt(t){return t.replace(/left|right|bottom|top/g,e=>An[e])}function Tn(t){return{top:0,right:0,bottom:0,left:0,...t}}function ve(t){return typeof t!="number"?Tn(t):{top:t,right:t,bottom:t,left:t}}function Rt(t){const{x:e,y:i,width:n,height:s}=t;return{width:n,height:s,top:i,left:e,right:e+n,bottom:i+s,x:e,y:i}}function Ee(t,e,i){let{reference:n,floating:s}=t;const r=K(e),o=_t(e),l=Vt(o),a=Q(e),c=r==="y",d=n.x+n.width/2-s.width/2,f=n.y+n.height/2-s.height/2,h=n[l]/2-s[l]/2;let u;switch(a){case"top":u={x:d,y:n.y-s.height};break;case"bottom":u={x:d,y:n.y+n.height};break;case"right":u={x:n.x+n.width,y:f};break;case"left":u={x:n.x-s.width,y:f};break;default:u={x:n.x,y:n.y}}switch(wt(e)){case"start":u[o]-=h*(i&&c?-1:1);break;case"end":u[o]+=h*(i&&c?-1:1);break}return u}const Mn=async(t,e,i)=>{const{placement:n="bottom",strategy:s="absolute",middleware:r=[],platform:o}=i,l=r.filter(Boolean),a=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:t,floating:e,strategy:s}),{x:d,y:f}=Ee(c,n,a),h=n,u={},g=0;for(let m=0;m<l.length;m++){const{name:p,fn:y}=l[m],{x:b,y:x,data:C,reset:v}=await y({x:d,y:f,initialPlacement:n,placement:h,strategy:s,middlewareData:u,rects:c,platform:o,elements:{reference:t,floating:e}});d=b??d,f=x??f,u={...u,[p]:{...u[p],...C}},v&&g<=50&&(g++,typeof v=="object"&&(v.placement&&(h=v.placement),v.rects&&(c=v.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:s}):v.rects),{x:d,y:f}=Ee(c,h,a)),m=-1)}return{x:d,y:f,placement:h,strategy:s,middlewareData:u}};async function Se(t,e){var i;e===void 0&&(e={});const{x:n,y:s,platform:r,rects:o,elements:l,strategy:a}=t,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:u=0}=q(e,t),g=ve(u),p=l[h?f==="floating"?"reference":"floating":f],y=Rt(await r.getClippingRect({element:(i=await(r.isElement==null?void 0:r.isElement(p)))==null||i?p:p.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(l.floating)),boundary:c,rootBoundary:d,strategy:a})),b=f==="floating"?{x:n,y:s,width:o.floating.width,height:o.floating.height}:o.reference,x=await(r.getOffsetParent==null?void 0:r.getOffsetParent(l.floating)),C=await(r.isElement==null?void 0:r.isElement(x))?await(r.getScale==null?void 0:r.getScale(x))||{x:1,y:1}:{x:1,y:1},v=Rt(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:b,offsetParent:x,strategy:a}):b);return{top:(y.top-v.top+g.top)/C.y,bottom:(v.bottom-y.bottom+g.bottom)/C.y,left:(y.left-v.left+g.left)/C.x,right:(v.right-y.right+g.right)/C.x}}const Dn=t=>({name:"arrow",options:t,async fn(e){const{x:i,y:n,placement:s,rects:r,platform:o,elements:l,middlewareData:a}=e,{element:c,padding:d=0}=q(t,e)||{};if(c==null)return{};const f=ve(d),h={x:i,y:n},u=_t(s),g=Vt(u),m=await o.getDimensions(c),p=u==="y",y=p?"top":"left",b=p?"bottom":"right",x=p?"clientHeight":"clientWidth",C=r.reference[g]+r.reference[u]-h[u]-r.floating[g],v=h[u]-r.reference[u],L=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let R=L?L[x]:0;(!R||!await(o.isElement==null?void 0:o.isElement(L)))&&(R=l.floating[x]||r.floating[g]);const vt=C/2-v/2,et=R/2-m[g]/2-1,U=ot(f[y],et),Et=ot(f[b],et),nt=U,St=R-m[g]-Et,H=R/2-m[g]/2+vt,M=Bt(nt,H,St),it=!a.arrow&&wt(s)!=null&&H!==M&&r.reference[g]/2-(H<nt?U:Et)-m[g]/2<0,V=it?H<nt?H-nt:H-St:0;return{[u]:h[u]+V,data:{[u]:M,centerOffset:H-M-V,...it&&{alignmentOffset:V}},reset:it}}}),In=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var i,n;const{placement:s,middlewareData:r,rects:o,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:m=!0,...p}=q(t,e);if((i=r.arrow)!=null&&i.alignmentOffset)return{};const y=Q(s),b=K(l),x=Q(l)===l,C=await(a.isRTL==null?void 0:a.isRTL(c.floating)),v=h||(x||!m?[Lt(l)]:Ln(l)),L=g!=="none";!h&&L&&v.push(...Pn(l,m,g,C));const R=[l,...v],vt=await Se(e,p),et=[];let U=((n=r.flip)==null?void 0:n.overflows)||[];if(d&&et.push(vt[y]),f){const M=On(s,o,C);et.push(vt[M[0]],vt[M[1]])}if(U=[...U,{placement:s,overflows:et}],!et.every(M=>M<=0)){var Et,nt;const M=(((Et=r.flip)==null?void 0:Et.index)||0)+1,it=R[M];if(it){var St;const J=f==="alignment"?b!==K(it):!1,N=((St=U[0])==null?void 0:St.overflows[0])>0;if(!J||N)return{data:{index:M,overflows:U},reset:{placement:it}}}let V=(nt=U.filter(J=>J.overflows[0]<=0).sort((J,N)=>J.overflows[1]-N.overflows[1])[0])==null?void 0:nt.placement;if(!V)switch(u){case"bestFit":{var H;const J=(H=U.filter(N=>{if(L){const X=K(N.placement);return X===b||X==="y"}return!0}).map(N=>[N.placement,N.overflows.filter(X=>X>0).reduce((X,di)=>X+di,0)]).sort((N,X)=>N[1]-X[1])[0])==null?void 0:H[0];J&&(V=J);break}case"initialPlacement":V=l;break}if(s!==V)return{reset:{placement:V}}}return{}}}};async function Fn(t,e){const{placement:i,platform:n,elements:s}=t,r=await(n.isRTL==null?void 0:n.isRTL(s.floating)),o=Q(i),l=wt(i),a=K(i)==="y",c=["left","top"].includes(o)?-1:1,d=r&&a?-1:1,f=q(e,t);let{mainAxis:h,crossAxis:u,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof g=="number"&&(u=l==="end"?g*-1:g),a?{x:u*d,y:h*c}:{x:h*c,y:u*d}}const Hn=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var i,n;const{x:s,y:r,placement:o,middlewareData:l}=e,a=await Fn(e,t);return o===((i=l.offset)==null?void 0:i.placement)&&(n=l.arrow)!=null&&n.alignmentOffset?{}:{x:s+a.x,y:r+a.y,data:{...a,placement:o}}}}},Nn=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:i,y:n,placement:s}=e,{mainAxis:r=!0,crossAxis:o=!1,limiter:l={fn:p=>{let{x:y,y:b}=p;return{x:y,y:b}}},...a}=q(t,e),c={x:i,y:n},d=await Se(e,a),f=K(Q(s)),h=Ut(f);let u=c[h],g=c[f];if(r){const p=h==="y"?"top":"left",y=h==="y"?"bottom":"right",b=u+d[p],x=u-d[y];u=Bt(b,u,x)}if(o){const p=f==="y"?"top":"left",y=f==="y"?"bottom":"right",b=g+d[p],x=g-d[y];g=Bt(b,g,x)}const m=l.fn({...e,[h]:u,[f]:g});return{...m,data:{x:m.x-i,y:m.y-n,enabled:{[h]:r,[f]:o}}}}}},Bn=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:i,y:n,placement:s,rects:r,middlewareData:o}=e,{offset:l=0,mainAxis:a=!0,crossAxis:c=!0}=q(t,e),d={x:i,y:n},f=K(s),h=Ut(f);let u=d[h],g=d[f];const m=q(l,e),p=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(a){const x=h==="y"?"height":"width",C=r.reference[h]-r.floating[x]+p.mainAxis,v=r.reference[h]+r.reference[x]-p.mainAxis;u<C?u=C:u>v&&(u=v)}if(c){var y,b;const x=h==="y"?"width":"height",C=["top","left"].includes(Q(s)),v=r.reference[f]-r.floating[x]+(C&&((y=o.offset)==null?void 0:y[f])||0)+(C?0:p.crossAxis),L=r.reference[f]+r.reference[x]+(C?0:((b=o.offset)==null?void 0:b[f])||0)-(C?p.crossAxis:0);g<v?g=v:g>L&&(g=L)}return{[h]:u,[f]:g}}}};function Pt(){return typeof window<"u"}function rt(t){return Ce(t)?(t.nodeName||"").toLowerCase():"#document"}function A(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function I(t){var e;return(e=(Ce(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Ce(t){return Pt()?t instanceof Node||t instanceof A(t).Node:!1}function P(t){return Pt()?t instanceof Element||t instanceof A(t).Element:!1}function F(t){return Pt()?t instanceof HTMLElement||t instanceof A(t).HTMLElement:!1}function $e(t){return!Pt()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof A(t).ShadowRoot}function bt(t){const{overflow:e,overflowX:i,overflowY:n,display:s}=T(t);return/auto|scroll|overlay|hidden|clip/.test(e+n+i)&&!["inline","contents"].includes(s)}function Un(t){return["table","td","th"].includes(rt(t))}function Tt(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch{return!1}})}function zt(t){const e=Qt(),i=P(t)?T(t):t;return["transform","translate","scale","rotate","perspective"].some(n=>i[n]?i[n]!=="none":!1)||(i.containerType?i.containerType!=="normal":!1)||!e&&(i.backdropFilter?i.backdropFilter!=="none":!1)||!e&&(i.filter?i.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(n=>(i.willChange||"").includes(n))||["paint","layout","strict","content"].some(n=>(i.contain||"").includes(n))}function Vn(t){let e=j(t);for(;F(e)&&!lt(e);){if(zt(e))return e;if(Tt(e))return null;e=j(e)}return null}function Qt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function lt(t){return["html","body","#document"].includes(rt(t))}function T(t){return A(t).getComputedStyle(t)}function Mt(t){return P(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function j(t){if(rt(t)==="html")return t;const e=t.assignedSlot||t.parentNode||$e(t)&&t.host||I(t);return $e(e)?e.host:e}function Ae(t){const e=j(t);return lt(e)?t.ownerDocument?t.ownerDocument.body:t.body:F(e)&&bt(e)?e:Ae(e)}function xt(t,e,i){var n;e===void 0&&(e=[]),i===void 0&&(i=!0);const s=Ae(t),r=s===((n=t.ownerDocument)==null?void 0:n.body),o=A(s);if(r){const l=Kt(o);return e.concat(o,o.visualViewport||[],bt(s)?s:[],l&&i?xt(l):[])}return e.concat(s,xt(s,[],i))}function Kt(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function ke(t){const e=T(t);let i=parseFloat(e.width)||0,n=parseFloat(e.height)||0;const s=F(t),r=s?t.offsetWidth:i,o=s?t.offsetHeight:n,l=kt(i)!==r||kt(n)!==o;return l&&(i=r,n=o),{width:i,height:n,$:l}}function jt(t){return P(t)?t:t.contextElement}function at(t){const e=jt(t);if(!F(e))return D(1);const i=e.getBoundingClientRect(),{width:n,height:s,$:r}=ke(e);let o=(r?kt(i.width):i.width)/n,l=(r?kt(i.height):i.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const _n=D(0);function Oe(t){const e=A(t);return!Qt()||!e.visualViewport?_n:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Wn(t,e,i){return e===void 0&&(e=!1),!i||e&&i!==A(t)?!1:e}function Z(t,e,i,n){e===void 0&&(e=!1),i===void 0&&(i=!1);const s=t.getBoundingClientRect(),r=jt(t);let o=D(1);e&&(n?P(n)&&(o=at(n)):o=at(t));const l=Wn(r,i,n)?Oe(r):D(0);let a=(s.left+l.x)/o.x,c=(s.top+l.y)/o.y,d=s.width/o.x,f=s.height/o.y;if(r){const h=A(r),u=n&&P(n)?A(n):n;let g=h,m=Kt(g);for(;m&&n&&u!==g;){const p=at(m),y=m.getBoundingClientRect(),b=T(m),x=y.left+(m.clientLeft+parseFloat(b.paddingLeft))*p.x,C=y.top+(m.clientTop+parseFloat(b.paddingTop))*p.y;a*=p.x,c*=p.y,d*=p.x,f*=p.y,a+=x,c+=C,g=A(m),m=Kt(g)}}return Rt({width:d,height:f,x:a,y:c})}function Yt(t,e){const i=Mt(t).scrollLeft;return e?e.left+i:Z(I(t)).left+i}function Le(t,e,i){i===void 0&&(i=!1);const n=t.getBoundingClientRect(),s=n.left+e.scrollLeft-(i?0:Yt(t,n)),r=n.top+e.scrollTop;return{x:s,y:r}}function zn(t){let{elements:e,rect:i,offsetParent:n,strategy:s}=t;const r=s==="fixed",o=I(n),l=e?Tt(e.floating):!1;if(n===o||l&&r)return i;let a={scrollLeft:0,scrollTop:0},c=D(1);const d=D(0),f=F(n);if((f||!f&&!r)&&((rt(n)!=="body"||bt(o))&&(a=Mt(n)),F(n))){const u=Z(n);c=at(n),d.x=u.x+n.clientLeft,d.y=u.y+n.clientTop}const h=o&&!f&&!r?Le(o,a,!0):D(0);return{width:i.width*c.x,height:i.height*c.y,x:i.x*c.x-a.scrollLeft*c.x+d.x+h.x,y:i.y*c.y-a.scrollTop*c.y+d.y+h.y}}function Qn(t){return Array.from(t.getClientRects())}function Kn(t){const e=I(t),i=Mt(t),n=t.ownerDocument.body,s=G(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),r=G(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let o=-i.scrollLeft+Yt(t);const l=-i.scrollTop;return T(n).direction==="rtl"&&(o+=G(e.clientWidth,n.clientWidth)-s),{width:s,height:r,x:o,y:l}}function jn(t,e){const i=A(t),n=I(t),s=i.visualViewport;let r=n.clientWidth,o=n.clientHeight,l=0,a=0;if(s){r=s.width,o=s.height;const c=Qt();(!c||c&&e==="fixed")&&(l=s.offsetLeft,a=s.offsetTop)}return{width:r,height:o,x:l,y:a}}function Yn(t,e){const i=Z(t,!0,e==="fixed"),n=i.top+t.clientTop,s=i.left+t.clientLeft,r=F(t)?at(t):D(1),o=t.clientWidth*r.x,l=t.clientHeight*r.y,a=s*r.x,c=n*r.y;return{width:o,height:l,x:a,y:c}}function Re(t,e,i){let n;if(e==="viewport")n=jn(t,i);else if(e==="document")n=Kn(I(t));else if(P(e))n=Yn(e,i);else{const s=Oe(t);n={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return Rt(n)}function Pe(t,e){const i=j(t);return i===e||!P(i)||lt(i)?!1:T(i).position==="fixed"||Pe(i,e)}function Jn(t,e){const i=e.get(t);if(i)return i;let n=xt(t,[],!1).filter(l=>P(l)&&rt(l)!=="body"),s=null;const r=T(t).position==="fixed";let o=r?j(t):t;for(;P(o)&&!lt(o);){const l=T(o),a=zt(o);!a&&l.position==="fixed"&&(s=null),(r?!a&&!s:!a&&l.position==="static"&&!!s&&["absolute","fixed"].includes(s.position)||bt(o)&&!a&&Pe(t,o))?n=n.filter(d=>d!==o):s=l,o=j(o)}return e.set(t,n),n}function Xn(t){let{element:e,boundary:i,rootBoundary:n,strategy:s}=t;const o=[...i==="clippingAncestors"?Tt(e)?[]:Jn(e,this._c):[].concat(i),n],l=o[0],a=o.reduce((c,d)=>{const f=Re(e,d,s);return c.top=G(f.top,c.top),c.right=ot(f.right,c.right),c.bottom=ot(f.bottom,c.bottom),c.left=G(f.left,c.left),c},Re(e,l,s));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function Gn(t){const{width:e,height:i}=ke(t);return{width:e,height:i}}function qn(t,e,i){const n=F(e),s=I(e),r=i==="fixed",o=Z(t,!0,r,e);let l={scrollLeft:0,scrollTop:0};const a=D(0);function c(){a.x=Yt(s)}if(n||!n&&!r)if((rt(e)!=="body"||bt(s))&&(l=Mt(e)),n){const u=Z(e,!0,r,e);a.x=u.x+e.clientLeft,a.y=u.y+e.clientTop}else s&&c();r&&!n&&s&&c();const d=s&&!n&&!r?Le(s,l):D(0),f=o.left+l.scrollLeft-a.x-d.x,h=o.top+l.scrollTop-a.y-d.y;return{x:f,y:h,width:o.width,height:o.height}}function Jt(t){return T(t).position==="static"}function Te(t,e){if(!F(t)||T(t).position==="fixed")return null;if(e)return e(t);let i=t.offsetParent;return I(t)===i&&(i=i.ownerDocument.body),i}function Me(t,e){const i=A(t);if(Tt(t))return i;if(!F(t)){let s=j(t);for(;s&&!lt(s);){if(P(s)&&!Jt(s))return s;s=j(s)}return i}let n=Te(t,e);for(;n&&Un(n)&&Jt(n);)n=Te(n,e);return n&&lt(n)&&Jt(n)&&!zt(n)?i:n||Vn(t)||i}const Zn=async function(t){const e=this.getOffsetParent||Me,i=this.getDimensions,n=await i(t.floating);return{reference:qn(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function ti(t){return T(t).direction==="rtl"}const ei={convertOffsetParentRelativeRectToViewportRelativeRect:zn,getDocumentElement:I,getClippingRect:Xn,getOffsetParent:Me,getElementRects:Zn,getClientRects:Qn,getDimensions:Gn,getScale:at,isElement:P,isRTL:ti};function De(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function ni(t,e){let i=null,n;const s=I(t);function r(){var l;clearTimeout(n),(l=i)==null||l.disconnect(),i=null}function o(l,a){l===void 0&&(l=!1),a===void 0&&(a=1),r();const c=t.getBoundingClientRect(),{left:d,top:f,width:h,height:u}=c;if(l||e(),!h||!u)return;const g=Ot(f),m=Ot(s.clientWidth-(d+h)),p=Ot(s.clientHeight-(f+u)),y=Ot(d),x={rootMargin:-g+"px "+-m+"px "+-p+"px "+-y+"px",threshold:G(0,ot(1,a))||1};let C=!0;function v(L){const R=L[0].intersectionRatio;if(R!==a){if(!C)return o();R?o(!1,R):n=setTimeout(()=>{o(!1,1e-7)},1e3)}R===1&&!De(c,t.getBoundingClientRect())&&o(),C=!1}try{i=new IntersectionObserver(v,{...x,root:s.ownerDocument})}catch{i=new IntersectionObserver(v,x)}i.observe(t)}return o(!0),r}function ii(t,e,i,n){n===void 0&&(n={});const{ancestorScroll:s=!0,ancestorResize:r=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:a=!1}=n,c=jt(t),d=s||r?[...c?xt(c):[],...xt(e)]:[];d.forEach(y=>{s&&y.addEventListener("scroll",i,{passive:!0}),r&&y.addEventListener("resize",i)});const f=c&&l?ni(c,i):null;let h=-1,u=null;o&&(u=new ResizeObserver(y=>{let[b]=y;b&&b.target===c&&u&&(u.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var x;(x=u)==null||x.observe(e)})),i()}),c&&!a&&u.observe(c),u.observe(e));let g,m=a?Z(t):null;a&&p();function p(){const y=Z(t);m&&!De(m,y)&&i(),m=y,g=requestAnimationFrame(p)}return i(),()=>{var y;d.forEach(b=>{s&&b.removeEventListener("scroll",i),r&&b.removeEventListener("resize",i)}),f==null||f(),(y=u)==null||y.disconnect(),u=null,a&&cancelAnimationFrame(g)}}const si=Hn,oi=Nn,ri=In,li=Dn,ai=Bn,ci=(t,e,i)=>{const n=new Map,s={platform:ei,...i},r={...s.platform,_c:n};return Mn(t,e,{...s,platform:r})};async function fi(t){const e=ye.call(this,t);e.el.inert=!1,e.el.classList.add(this.settings.stateActive),e.isTooltip||e.trigger.setAttribute("aria-expanded","true"),e.buildCustomProps();const i=wn(e),n=e.el.querySelector(i.arrow.element);return i.arrow.element=n||void 0,e.floatingCleanup=ii(e.trigger,e.el,()=>{ci(e.trigger,e.el,{placement:e.getSetting("placement"),middleware:[ri(i.flip),oi({...i.shift,limiter:ai()}),si(i.offset),li(i.arrow)]}).then(({x:s,y:r,placement:o,middlewareData:l})=>{if(e.el){if(me(e.el,s,r),i.arrow.element&&l.arrow){const{x:a,y:c}=l.arrow;me(i.arrow.element,a,c)}e.el.setAttribute("data-floating-placement",o)}})}),e.state="opened",e.getSetting("event")==="click"&&Cn.call(this,e),e.el.dispatchEvent(new CustomEvent(e.getSetting("customEventPrefix")+"opened",{detail:this,bubbles:!0})),await e.parent.emit("opened",e),e}class ui extends $t{constructor(i={}){super({...yn,...i});_(this,ht);this.module="Popover",this.entryClass=$n,this.trigger=null,k(this,ht,Sn.bind(this))}get active(){return this.get("opened","state")}get activeHover(){return this.collection.find(i=>i.state=="opened"&&i.getSetting("event")=="hover")}async open(i){return fi.call(this,i)}async close(i){return we.call(this,i)}async afterMount(){document.addEventListener("keydown",$(this,ht),!1)}async beforeUnmount(){this.trigger=null}async afterUnmount(){document.removeEventListener("keydown",$(this,ht),!1)}}ht=new WeakMap,E.Drawer=fn,E.Modal=pn,E.Popover=ui,E.core=tn,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})});
1
+ (function(D,$){typeof exports=="object"&&typeof module<"u"?$(exports):typeof define=="function"&&define.amd?define(["exports"],$):(D=typeof globalThis<"u"?globalThis:D||self,$(D.vrembem={}))})(this,(function(D){"use strict";const $=":not([inert])",C=':not([tabindex^="-"])',ot=":not(:disabled)",Vt=[`a[href]${$}${C}`,`area[href]${$}${C}`,`input:not([type="hidden"]):not([type="radio"])${$}${C}${ot}`,`input[type="radio"]${$}${C}${ot}`,`select${$}${C}${ot}`,`textarea${$}${C}${ot}`,`button${$}${C}${ot}`,`details${$} > summary:first-of-type${C}`,`iframe${$}${C}`,`audio[controls]${$}${C}`,`video[controls]${$}${C}`,`[contenteditable]${$}${C}`,`[tabindex]${$}${C}`];function zt(t,e="config"){const n=(t.getAttribute(`data-${e}`)||"").replace(/'/g,'"');return n?JSON.parse(n):{}}function xt(t){if(typeof t=="string"){const e=document.getElementById(t);if(e)return e;throw new Error(`Element not found with ID: "${t}"`)}else if(t instanceof HTMLElement){if(!t.id)throw new Error("HTMLElement must have an ID");return t}else throw new Error("Invalid argument: query must be a string or HTMLElement")}async function j(t,e,...n){e in t&&typeof t[e]=="function"&&await t[e](...n)}function Bt(t,e,n){if(typeof e=="string"){const r=document.querySelector(e);if(!r)throw new Error(`No teleport reference found for selector: ${e}`);e=r}else if(!(e instanceof HTMLElement))throw new Error(`Not a valid teleport reference: '${e}'`);if(typeof e[n]!="function")throw new Error(`Not a valid teleport method: '${n}'`);let s=document.createComment("teleported #"+t.id);return t.before(s),e[n](t),()=>{s&&(s.after(t),s.remove(),s=null)}}function Wt(t){return t.split("-").map((e,n)=>n===0?e:e.charAt(0).toUpperCase()+e.slice(1)).join("")}function St(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function _t(t){if(typeof t=="number")return t;const e=parseFloat(t);if(!Number.isNaN(e)){const n=t.includes("ms");return e*(n?1:1e3)}throw new Error(`Could not convert value to milliseconds: ${t}`)}function Ue(t,e,n,s,r=0){return new Promise(i=>{t.classList.remove(e),t.classList.add(n),setTimeout(()=>{t.classList.add(s),t.classList.remove(n),i(t)},_t(r))})}function Qt(t,e={}){const n={fallback:null,element:document.body,...e};if(!t.startsWith("--")){const r=dt();r&&(t=`${r}${t}`),t=`--${t}`}const s=getComputedStyle(n.element).getPropertyValue(t).trim();if(s)return s;if(n.fallback)return n.fallback;throw new Error(`CSS variable "${t}" was not found!`)}async function M(t,e,n){await j(e,t,n),n&&await j(n,t);for(const s of e.plugins)await j(s,t,{plugin:s,parent:e,entry:n});await e.emit(t,n)}function Jt(t){const e=getComputedStyle(t.el),n={},s=t.getSetting("customProps");for(let r=0;r<s.length;r++){const i=dt(),o=t.parent.module.toLowerCase(),a=St(s[r]),l=e.getPropertyValue(`--${i}${o}-${a}`).trim();l&&(n[a]=l)}return n}function dt(){return getComputedStyle(document.body).getPropertyValue("--vb-prefix").trim()}function Fe(t,e,n="camel"){return e=n==="camel"?Wt(e):St(e),t.split(".").concat(e).reduce((s,r)=>s?.[r],this)}function Zt(t,e={}){const{fallback:n,props:s=["dataConfig","customProps","settings","parent.settings"]}=e;for(const r of s){const i=r!=="customProps"?"camel":"kebab",o=Fe.call(this,r,t,i);if(o!==void 0)return o}if(n!==void 0)return n;throw new Error(`${this.parent.module} setting does not exist: ${t}`)}function Ve(t,e){e&&document.querySelectorAll(e).forEach(n=>{t?n.style.overflow="hidden":n.style.removeProperty("overflow")})}function ze(t,e){e&&document.querySelectorAll(e).forEach(n=>{n.inert=t})}function Be(t,e,n){ze(!!t,e),Ve(!!t,n)}const Kt={events:{},on(t,e,...n){this.events[t]||(this.events[t]=[]),this.events[t].some(s=>s.listener===e)||this.events[t].push({listener:e,args:n})},off(t,e){this.events[t]&&(this.events[t]=this.events[t].filter(n=>n.listener!==e))},async emit(t,e){if(t=t.startsWith("on")?t.slice(2,3).toLowerCase()+t.slice(3):t,!!this.events[t])for(const{listener:n,args:s}of this.events[t])await n(e,...s)}};let Xt=class extends Array{constructor(e=null){super(),this.el=e,this.el&&this.set()}get first(){return this[0]}get last(){return this[this.length-1]}set(e=this.el){this.length=0,e&&this.push(...e.querySelectorAll(Vt.join(",")))}clear(){this.length=0}},Yt=class{constructor(e=null){this.el=e,this.focusable=new Xt,this.handleFocusTrap=We.bind(this)}on(e=this.el){this.focusable.set(e),this.focusable.length?document.addEventListener("keydown",this.handleFocusTrap):document.addEventListener("keydown",Gt)}off(){this.focusable.clear(),document.removeEventListener("keydown",this.handleFocusTrap),document.removeEventListener("keydown",Gt)}};function Gt(t){(t.key==="Tab"||t.keyCode===9)&&t.preventDefault()}function We(t){if(t.key!=="Tab"&&t.keyCode!==9)return;const{activeElement:e}=document,{el:n,focusable:s}=this,r=t.shiftKey,i=e===s.first||e===n,o=e===s.last||e===n;if(r&&i||!r&&o){t.preventDefault();const a=r?s.last:s.first;a&&typeof a.focus=="function"&&a.focus()}}function Ct(t,e=!0){const n=localStorage.getItem(t),s=n?JSON.parse(n):{};return{get(r,i){return r?r in s?s[r]:i:s},set(r,i){return i?s[r]=i:delete s[r],e&&localStorage.setItem(t,JSON.stringify(s)),s}}}let te=class extends Array{constructor(e={}){super(),this.presets=e}applySettings(e){const n=e?.defaults||{},s=this.presets?.[e.name]||{},r=e?.options||{};e.settings={...n,...s,...r}}validate(e){return!("name"in e)||typeof e.name!="string"?(console.error("Plugin requires a name!"),!1):!0}get(e){return this.find(n=>n.name===e)}add(e){if(Array.isArray(e))e.forEach(n=>this.add(n));else if(this.applySettings(e),this.validate(e)){const n=this.findIndex(s=>s.name===e.name);~n?this[n]=e:this.push(e)}}remove(e){const n=this.findIndex(s=>s.name===e);~n&&this.splice(n,1)}};class _e extends Array{constructor(e={}){super(),this.settings=e}get copy(){return[...this]}get top(){return this[this.length-1]||null}updateIndex(){this.forEach((e,n)=>{e.el.style.zIndex="";const s=getComputedStyle(e.el)["z-index"];e.el.style.zIndex=String(parseInt(s,10)+n+1)})}onChange(){this.updateIndex(),typeof this.settings.onChange=="function"&&this.settings.onChange()}add(e){this.push(e),this.onChange()}remove(e){const n=this.findIndex(s=>s.id===e.id);~n&&(e.el.style.zIndex="",this.splice(n,1),this.onChange())}moveToTop(e){const n=this.findIndex(s=>s.id===e.id);~n&&(this.splice(n,1),this.add(e))}}const Qe={condition:!0},Je={primary:"hsl(152deg 60% 50%)",secondary:"hsl(214deg 50% 50%)",neutral:"hsl(214deg 20% 50%)",important:"hsl(0deg 80% 50%)"};function Ze(t={}){const e={name:"debug",defaults:Qe,options:t};function n(i,o=[],a=["primary","secondary"]){const l=a.map(c=>`color: ${Je[c]}`);console.log(`%c📡 DEBUG: %c${i}`,...l,...o)}function s(i,...o){return typeof i=="function"?i(...o):i}const r={beforeMountRef:n.bind(null,"Event > beforeMount()"),afterMountRef:n.bind(null,"Event > afterMount()"),beforeUnmountRef:n.bind(null,"Event > beforeUnmount()",[],["important","neutral"]),afterUnmountRef:n.bind(null,"Event > afterUnmount()",[],["important","neutral"]),createEntryRef:(i,{parent:o,plugin:a})=>{if(s(a.settings.condition,i)){const l=o.collection.length;n(`Event > createEntry() > [${l}] #${i.id}`)}},registerEntryRef:(i,{parent:o,plugin:a})=>{if(s(a.settings.condition,i)){const l=o.collection.length;n(`Event > registerEntry() > [${l}] #${i.id}`)}},destroyEntryRef:(i,{parent:o,plugin:a})=>{if(s(a.settings.condition,i)){const l=o.collection.length;n(`Event > destroyEntry() > [${l}] #${i.id}`,[],["important","neutral"])}},deregisterEntryRef:(i,{parent:o,plugin:a})=>{if(s(a.settings.condition,i)){const l=o.collection.length;n(`Event > deregisterEntry() > [${l}]`,[],["important","neutral"])}}};return{...e,setup({parent:i}){n("Plugin > setup()",Array.from(arguments),["secondary","neutral"]),i.on("beforeMount",r.beforeMountRef),i.on("createEntry",r.createEntryRef,{parent:i,plugin:this}),i.on("registerEntry",r.registerEntryRef,{parent:i,plugin:this}),i.on("afterMount",r.afterMountRef),i.on("beforeUnmount",r.beforeUnmountRef),i.on("destroyEntry",r.destroyEntryRef,{parent:i,plugin:this}),i.on("deregisterEntry",r.deregisterEntryRef,{parent:i,plugin:this}),i.on("afterUnmount",r.afterUnmountRef)},teardown({parent:i}){n("Plugin > teardown()",Array.from(arguments),["secondary","neutral"]),i.off("beforeMount",r.beforeMountRef),i.off("createEntry",r.createEntryRef),i.off("registerEntry",r.registerEntryRef),i.off("afterMount",r.afterMountRef),i.off("beforeUnmount",r.beforeUnmountRef),i.off("destroyEntry",r.destroyEntryRef),i.off("deregisterEntry",r.deregisterEntryRef),i.off("afterUnmount",r.afterUnmountRef)},beforeMount(){n("Hook > beforeMount()",Array.from(arguments))},onCreateEntry({parent:i,entry:o}){if(s(this.settings.condition,o)){const a=i.collection.length;n(`Hook > onCreateEntry() > [${a}] #${o.id}`,Array.from(arguments))}},onRegisterEntry({parent:i,entry:o}){if(s(this.settings.condition,o)){const a=i.collection.length-1;n(`Hook > onRegisterEntry() > [${a}] #${o.id}`,Array.from(arguments))}},afterMount(){n("Hook > afterMount()",Array.from(arguments))},beforeUnmount(){n("Hook > beforeUnmount()",Array.from(arguments),["important","neutral"])},onDestroyEntry({parent:i,entry:o}){if(s(this.settings.condition,o)){const a=i.collection.length-1;n(`Hook > onDestroyEntry() > [${a}] #${o.id}`,Array.from(arguments),["important","neutral"])}},onDeregisterEntry({parent:i,entry:o}){if(s(this.settings.condition,o)){const a=i.collection.length;n(`Hook > onDeregisterEntry() > [${a}]`,Array.from(arguments),["important","neutral"])}},afterUnmount(){n("Hook > afterUnmount()",Array.from(arguments),["important","neutral"])}}}const Ke={condition:!0};function Xe(t={}){const e={name:"focusTrap",defaults:Ke,options:t},n={setup({parent:o}){o.on("opened",r,this),o.on("closed",i,this)},teardown({parent:o}){o.off("opened",r),o.off("closed",i)},onCreateEntry({entry:o}){o.focusTrap=new Yt}};function s(o,...a){return typeof o=="function"?o(...a):o}function r(o,a){const l={plugin:a,parent:o.parent,entry:o};s(a.settings.condition,l)&&o.focusTrap?.on(o.dialog)}function i(o,a){const l={plugin:a,parent:o.parent,entry:o};s(a.settings.condition,l)&&o.focusTrap?.off()}return{...e,...n}}const Ye={dataBreakpoint:"breakpoint",dataMediaQuery:"media-query",token:"{{BP}}",breakpoint:null,mediaQuery:"(min-width: {{BP}})",breakpoints:{},mediaQueries:{},onChange:()=>{}};function Ge(t={}){const e={name:"mediaQuery",defaults:Ye,options:t},n={onCreateEntry({entry:a}){i.call(this,a)},onDestroyEntry({entry:a}){o(a)}};function s(a){const l=a.el.getAttribute(`data-${this.settings.dataMediaQuery}`);return!l&&a.id in this.settings.mediaQueries?this.settings.mediaQueries[a.id]:l||void 0}function r(a){let l=a.el.getAttribute(`data-${this.settings.dataBreakpoint}`);return!l&&a.id in this.settings.breakpoints&&(l=this.settings.breakpoints[a.id]),l&&l in this.settings.breakpoints&&(l=this.settings.breakpoints[l]),l&&(l=getComputedStyle(document.body).getPropertyValue(`--${dt()}breakpoint-${l}`).trim()||l),l||this.settings.breakpoint}function i(a){let l=s.call(this,a);const c=r.call(this,a);if(!c&&!l)return;c&&!l&&(l=this.settings.mediaQuery);const f=l.replace(new RegExp(`${this.settings.token}`,"g"),c);a.mql=window.matchMedia(f),a.mql.onchange=h=>{this.settings.onChange(h,a)},this.settings.onChange(a.mql,a)}function o(a){a.mql&&(a.mql.onchange=null,a.mql=null)}return{...e,...n}}const tn={prop:"state",value:null,keyPrefix:"VB:",key:null,condition:!1,onChange(){}};function en(t={}){const e={name:"propStore",defaults:tn,options:t,store:null},n={setup({parent:a}){this.store=Ct(o.call(this,a.module))},async onCreateEntry({entry:a}){await s.call(this,a)},onDestroyEntry({entry:a}){i.call(this,a)}};async function s(a){let l=a[this.settings.prop]||null;const c={plugin:this,parent:a.parent,entry:a};Object.defineProperty(a,this.settings.prop,{configurable:!0,get(){return l},set:async f=>{if(l===f)return;const h=l;l=f,r(this.settings.condition,c,f,h)&&this.store.set(a.id,f),await this.settings.onChange(c,f,h)}}),Object.defineProperty(a,"store",{configurable:!0,get:()=>this.store.get(a.id),set:f=>{a[this.settings.prop]=f}}),a[this.settings.prop]=await r(this.settings.value,c)||a[this.settings.prop]}function r(a,...l){return typeof a=="function"?a(...l):a}async function i(a){const l=a[this.settings.prop];delete a[this.settings.prop],a[this.settings.prop]=l,this.store.set(a.id,null)}function o(a){const l=this.settings.prop.charAt(0).toUpperCase()+this.settings.prop.slice(1),c=this.settings.key||a+l;return this.settings.keyPrefix+c}return{...e,...n}}const nn={where:null,how:"append"};function sn(t={}){const e={name:"teleport",defaults:nn,options:t},n={onCreateEntry({plugin:i,entry:o}){s(i,o)},onDestroyEntry({plugin:i,entry:o}){r(i,o)}};function s(i,o){o.teleport=()=>{typeof o.teleportReturn=="function"&&o.teleportReturn(),o.teleportReturn=Bt(o.el,o.getSetting("teleport",{fallback:i.settings.where}),o.getSetting("teleportMethod",{fallback:i.settings.how}))},o.teleport(),o.parent.emit("teleport",{plugin:i,parent:o.parent,entry:o})}function r(i,o){typeof o.teleportReturn=="function"&&o.teleportReturn(),o.parent.emit("teleportReturn",{plugin:i,parent:o.parent,entry:o})}return{...e,...n}}const rn={dataConfig:"config",customProps:[]};let ee=class{constructor(e,n,s={}){this.parent=e,this.el=xt(n),this.settings={...s},this.dataConfig={},this.customProps={}}get id(){return this.el.id}applySettings(e){return Object.assign(this.settings,e)}getSetting(e,n){return Zt.call(this,e,n)}buildDataConfig(){return Object.assign(this.dataConfig,zt(this.el,this.getSetting("dataConfig")))}buildCustomProps(){return Object.assign(this.customProps,Jt(this))}async init(e={}){this.applySettings(e),this.buildDataConfig(),this.buildCustomProps()}async destroy(){Object.getOwnPropertyNames(this).forEach(e=>{delete this[e]})}},on=class{constructor(e={}){this.module=this.constructor.name,this.collection=[],this.entryClass=ee,this.settings={...rn,...e},this.plugins=new te(this.settings.presets),this.events={},Object.assign(this,Kt)}get(e,n="id"){return this.collection.find(s=>s[n]===e)}getOrThrow(e,n="id"){const s=this.get(e,n);if(s)return s;throw new Error(`${this.module} entry not found in collection with ${n} of "${e}"`)}applySettings(e){return Object.assign(this.settings,e)}async createEntry(e,n){const s=new this.entryClass(this,e,n);return await j(s,"init"),await M("onCreateEntry",this,s),s}async destroyEntry(e){return await M("onDestroyEntry",this,e),await j(e,"destroy"),e}async register(e,n={}){const s=xt(e),r=this.collection.findIndex(i=>i.id===s.id);if(~r){const i=this.collection[r];return i.el=s,typeof i.init=="function"&&await i.init(n),i}else{const i=await this.createEntry(s,n);return this.collection.push(i),await M("onRegisterEntry",this,i),i}}async deregister(e){const n=this.collection.findIndex(s=>s.id===e);if(~n){const s=await this.destroyEntry(this.collection[n]);return await M("onDeregisterEntry",this,this.collection[n]),this.collection.splice(n,1),s}return null}async mount(e={}){this.applySettings(e);for(const s of this.settings?.plugins||[])this.plugins.add(s);for(const s of this.plugins)await j(s,"setup",{plugin:s,parent:this});await M("beforeMount",this);const n=document.querySelectorAll(this.settings.selector);for(const s of n)await this.register(s);return await M("afterMount",this),this}async unmount(){for(await M("beforeUnmount",this);this.collection.length>0;)await this.deregister(this.collection[0].id);await M("afterUnmount",this);for(const e of this.plugins)await j(e,"teardown",{plugin:e,parent:this});for(const e of[...this.plugins])this.plugins.remove(e.name);return this}};function an(t={}){const e={prefix:Qt("prefix-themes",{fallback:"vb-theme-"}),themes:["root","light","dark"],storeKey:"VB:Profile"};for(const[i]of Object.entries(e))t&&t[i]&&(e[i]=t[i]);const n={onInit(){},onChange(){}};for(const[i]of Object.entries(n))t&&t[i]&&(n[i]=t[i]);const s=Ct(e.storeKey),r={settings:e,add(i){e.themes.push(i)},remove(i){const o=e.themes.indexOf(i);~o&&e.themes.splice(o,1)},callback(i){n[i].call(this)},get class(){return`${e.prefix}${this.theme}`},get classes(){return e.themes.map(i=>`${e.prefix}${i}`)},get themes(){return e.themes},get theme(){return s.get("theme")||"root"},set theme(i){e.themes.includes(i)?this.theme!=i&&(s.set("theme",i),document.documentElement.classList.remove(...this.classes),document.documentElement.classList.add(`${e.prefix}${i}`),this.callback("onChange")):console.error(`Not a valid theme value: "${i}"`)}};return r.callback("onInit"),r}const ln=Object.freeze(Object.defineProperty({__proto__:null,Collection:on,CollectionEntry:ee,FocusTrap:Yt,FocusableArray:Xt,PluginsArray:te,StackArray:_e,cssVar:Qt,debug:Ze,dispatchLifecycleHook:M,eventEmitter:Kt,focusTrap:Xe,focusableSelectors:Vt,getCustomProps:Jt,getDataConfig:zt,getElement:xt,getPrefix:dt,getSetting:Zt,localStore:Ct,maybeRunMethod:j,mediaQuery:Ge,propStore:en,setGlobalState:Be,teleport:sn,teleportElement:Bt,themeStore:an,toCamel:Wt,toKebab:St,toMilliseconds:_t,transition:Ue},Symbol.toStringTag,{value:"Module"}));function cn(t,e="config"){const n=(t.getAttribute(`data-${e}`)||"").replace(/'/g,'"');return n?JSON.parse(n):{}}function ne(t){if(typeof t=="string"){const e=document.getElementById(t);if(e)return e;throw new Error(`Element not found with ID: "${t}"`)}else if(t instanceof HTMLElement){if(!t.id)throw new Error("HTMLElement must have an ID");return t}else throw new Error("Invalid argument: query must be a string or HTMLElement")}async function _(t,e,...n){e in t&&typeof t[e]=="function"&&await t[e](...n)}function un(t){return t.split("-").map((e,n)=>n===0?e:e.charAt(0).toUpperCase()+e.slice(1)).join("")}function se(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function fn(t){if(typeof t=="number")return t;const e=parseFloat(t);if(!Number.isNaN(e)){const n=t.includes("ms");return e*(n?1:1e3)}throw new Error(`Could not convert value to milliseconds: ${t}`)}function ie(t,e,n,s,r=0){return new Promise(i=>{t.classList.remove(e),t.classList.add(n),setTimeout(()=>{t.classList.add(s),t.classList.remove(n),i(t)},fn(r))})}async function N(t,e,n){await _(e,t,n),n&&await _(n,t);for(const s of e.plugins)await _(s,t,{plugin:s,parent:e,entry:n});await e.emit(t,n)}function hn(t){const e=getComputedStyle(t.el),n={},s=t.getSetting("customProps");for(let r=0;r<s.length;r++){const i=dn(),o=t.parent.module.toLowerCase(),a=se(s[r]),l=e.getPropertyValue(`--${i}${o}-${a}`).trim();l&&(n[a]=l)}return n}function dn(){return getComputedStyle(document.body).getPropertyValue("--vb-prefix").trim()}function gn(t,e,n="camel"){return e=n==="camel"?un(e):se(e),t.split(".").concat(e).reduce((s,r)=>s?.[r],this)}function pn(t,e={}){const{fallback:n,props:s=["dataConfig","customProps","settings","parent.settings"]}=e;for(const r of s){const i=r!=="customProps"?"camel":"kebab",o=gn.call(this,r,t,i);if(o!==void 0)return o}if(n!==void 0)return n;throw new Error(`${this.parent.module} setting does not exist: ${t}`)}function mn(t,e){e&&document.querySelectorAll(e).forEach(n=>{t?n.style.overflow="hidden":n.style.removeProperty("overflow")})}function yn(t,e){e&&document.querySelectorAll(e).forEach(n=>{n.inert=t})}function Lt(t,e,n){yn(!!t,e),mn(!!t,n)}const wn={events:{},on(t,e,...n){this.events[t]||(this.events[t]=[]),this.events[t].some(s=>s.listener===e)||this.events[t].push({listener:e,args:n})},off(t,e){this.events[t]&&(this.events[t]=this.events[t].filter(n=>n.listener!==e))},async emit(t,e){if(t=t.startsWith("on")?t.slice(2,3).toLowerCase()+t.slice(3):t,!!this.events[t])for(const{listener:n,args:s}of this.events[t])await n(e,...s)}};let vn=class extends Array{constructor(e={}){super(),this.presets=e}applySettings(e){const n=e?.defaults||{},s=this.presets?.[e.name]||{},r=e?.options||{};e.settings={...n,...s,...r}}validate(e){return!("name"in e)||typeof e.name!="string"?(console.error("Plugin requires a name!"),!1):!0}get(e){return this.find(n=>n.name===e)}add(e){if(Array.isArray(e))e.forEach(n=>this.add(n));else if(this.applySettings(e),this.validate(e)){const n=this.findIndex(s=>s.name===e.name);~n?this[n]=e:this.push(e)}}remove(e){const n=this.findIndex(s=>s.name===e);~n&&this.splice(n,1)}};const bn={dataConfig:"config",customProps:[]};let re=class{constructor(e,n,s={}){this.parent=e,this.el=ne(n),this.settings={...s},this.dataConfig={},this.customProps={}}get id(){return this.el.id}applySettings(e){return Object.assign(this.settings,e)}getSetting(e,n){return pn.call(this,e,n)}buildDataConfig(){return Object.assign(this.dataConfig,cn(this.el,this.getSetting("dataConfig")))}buildCustomProps(){return Object.assign(this.customProps,hn(this))}async init(e={}){this.applySettings(e),this.buildDataConfig(),this.buildCustomProps()}async destroy(){Object.getOwnPropertyNames(this).forEach(e=>{delete this[e]})}},En=class{constructor(e={}){this.module=this.constructor.name,this.collection=[],this.entryClass=re,this.settings={...bn,...e},this.plugins=new vn(this.settings.presets),this.events={},Object.assign(this,wn)}get(e,n="id"){return this.collection.find(s=>s[n]===e)}getOrThrow(e,n="id"){const s=this.get(e,n);if(s)return s;throw new Error(`${this.module} entry not found in collection with ${n} of "${e}"`)}applySettings(e){return Object.assign(this.settings,e)}async createEntry(e,n){const s=new this.entryClass(this,e,n);return await _(s,"init"),await N("onCreateEntry",this,s),s}async destroyEntry(e){return await N("onDestroyEntry",this,e),await _(e,"destroy"),e}async register(e,n={}){const s=ne(e),r=this.collection.findIndex(i=>i.id===s.id);if(~r){const i=this.collection[r];return i.el=s,typeof i.init=="function"&&await i.init(n),i}else{const i=await this.createEntry(s,n);return this.collection.push(i),await N("onRegisterEntry",this,i),i}}async deregister(e){const n=this.collection.findIndex(s=>s.id===e);if(~n){const s=await this.destroyEntry(this.collection[n]);return await N("onDeregisterEntry",this,this.collection[n]),this.collection.splice(n,1),s}return null}async mount(e={}){this.applySettings(e);for(const s of this.settings?.plugins||[])this.plugins.add(s);for(const s of this.plugins)await _(s,"setup",{plugin:s,parent:this});await N("beforeMount",this);const n=document.querySelectorAll(this.settings.selector);for(const s of n)await this.register(s);return await N("afterMount",this),this}async unmount(){for(await N("beforeUnmount",this);this.collection.length>0;)await this.deregister(this.collection[0].id);await N("afterUnmount",this);for(const e of this.plugins)await _(e,"teardown",{plugin:e,parent:this});for(const e of[...this.plugins])this.plugins.remove(e.name);return this}};const $n={focusTrap:{condition:({entry:t})=>t.state==="closed"||t.state==="opened"&&t.mode==="modal"},mediaQuery:{onChange(t,e){e.mode=t.matches?"inline":"modal"}},propStore:{prop:"inlineState",value:({entry:t})=>t.store,condition:({entry:t})=>["opened","closed","indeterminate"].includes(t.state),onChange:({entry:t})=>t.applyState()}},xn={presets:$n,dataOpen:"drawer-open",dataClose:"drawer-close",dataToggle:"drawer-toggle",selector:".drawer",selectorDialog:".drawer__dialog",selectorScreen:".drawer",selectorFocus:"[data-focus]",selectorInert:null,selectorOverflow:"body",stateOpened:"is-opened",stateOpening:"is-opening",stateClosing:"is-closing",stateClosed:"is-closed",classModal:"drawer_modal",customProps:["transition-duration"],breakpoints:null,customEventPrefix:"drawer:",setTabindex:!0,transition:!0,transitionDuration:300};function Sn(t){switch(t.mode){case"inline":return Cn(t);case"modal":return Ln(t);default:throw new Error(`"${t.mode}" is not a valid drawer mode.`)}}async function Cn(t){return t.el.classList.remove(t.getSetting("classModal")),t.dialog.removeAttribute("aria-modal"),Lt(!1,t.getSetting("selectorInert"),t.getSetting("selectorOverflow")),t.applyState(),t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"switchMode",{detail:t.parent,bubbles:!0})),await t.parent.emit("switchMode",t),t}async function Ln(t){return t.el.classList.add(t.getSetting("classModal")),t.dialog.setAttribute("aria-modal","true"),await t.close(!1,!1),t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"switchMode",{detail:t.parent,bubbles:!0})),await t.parent.emit("switchMode",t),t}function oe(t){t.dialog&&t.state==="opened"?(t.dialog.querySelector(t.parent.settings.selectorFocus)||t.dialog).focus():t.trigger&&(t.trigger.focus(),t.trigger=null)}async function At(t,e,n=!0){return(t.state==="closed"||t.state==="indeterminate"||t.state===null)&&(t.setState("opening"),e??t.getSetting("transition")?await ie(t.el,t.getSetting("stateClosed"),t.getSetting("stateOpening"),t.getSetting("stateOpened"),t.getSetting("transitionDuration")):(t.el.classList.add(t.getSetting("stateOpened")),t.el.classList.remove(t.getSetting("stateClosed"))),t.setState("opened"),t.mode==="modal"&&Lt(!0,t.getSetting("selectorInert"),t.getSetting("selectorOverflow")),n&&oe(t),t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"opened",{detail:t.parent,bubbles:!0})),await t.parent.emit("opened",t)),t}async function Tt(t,e,n=!0){return(t.state==="opened"||t.state==="indeterminate"||t.state===null)&&(t.setState("closing"),document.activeElement&&document.activeElement instanceof HTMLElement&&document.activeElement.blur(),e??t.getSetting("transition")?await ie(t.el,t.getSetting("stateOpened"),t.getSetting("stateClosing"),t.getSetting("stateClosed"),t.getSetting("transitionDuration")):(t.el.classList.add(t.getSetting("stateClosed")),t.el.classList.remove(t.getSetting("stateOpened"))),t.setState("closed"),t.mode==="modal"&&Lt(!1,t.getSetting("selectorInert"),t.getSetting("selectorOverflow")),n&&oe(t),t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"closed",{detail:t.parent,bubbles:!0})),await t.parent.emit("closed",t)),t}async function ae(t,e,n){return t.state==="closed"?At(t,e,n):Tt(t,e,n)}class An extends re{#t;constructor(e,n,s={}){super(e,n,s),this.#t="indeterminate",this.dialog=this.el.querySelector(this.getSetting("selectorDialog"))||this.el,this.trigger=null,this.state=null,this.inlineState=null}get mode(){return this.#t}set mode(e){this.#t!==e&&(this.#t=e,Sn(this))}setState(e){this.state=e;const n=["opening","closing"];this.mode==="inline"&&!n.includes(e)&&(this.inlineState=e),e==="indeterminate"&&(this.el.classList.remove(this.getSetting("stateOpened")),this.el.classList.remove(this.getSetting("stateOpening")),this.el.classList.remove(this.getSetting("stateClosed")),this.el.classList.remove(this.getSetting("stateClosing")))}async applyState(){if(this.mode==="modal")return this;if(this.inlineState==="opened")return await this.open(!1,!1);if(this.inlineState==="closed")return await this.close(!1,!1);if(this.state===null){if(this.el.classList.contains(this.getSetting("stateOpened")))return await this.open(!1,!1);if(this.el.classList.contains(this.getSetting("stateClosed")))return await this.close(!1,!1)}return this.setState("indeterminate"),this}async open(e,n){return At(this,e,n)}async close(e,n){return Tt(this,e,n)}async toggle(e,n){return ae(this,e,n)}async deregister(){return this.parent.deregister(this.id)}async onCreateEntry(){this.getSetting("setTabindex")&&this.dialog&&this.dialog.setAttribute("tabindex","-1"),await this.applyState(),this.inlineState=this.state,this.mode=this.el&&this.el.classList.contains(this.getSetting("classModal"))?"modal":"inline"}async onDestroyEntry(){this.mode==="modal"&&this.state==="opened"&&await this.close(!1)}}async function Tn(t){const e=t.target;if(e){const n=e.closest(`
2
+ [data-${this.settings.dataOpen}],
3
+ [data-${this.settings.dataToggle}],
4
+ [data-${this.settings.dataClose}]
5
+ `);if(n){t.preventDefault(),n.matches(`[data-${this.settings.dataToggle}]`)&&n.getAttribute(`data-${this.settings.dataToggle}`)?.trim().split(" ")?.forEach(s=>{const r=this.getOrThrow(s);return r.trigger=n,r.toggle()}),n.matches(`[data-${this.settings.dataOpen}]`)&&n.getAttribute(`data-${this.settings.dataOpen}`)?.trim().split(" ")?.forEach(s=>{const r=this.getOrThrow(s);return r.trigger=n,r.open()}),n.matches(`[data-${this.settings.dataClose}]`)&&n.getAttribute(`data-${this.settings.dataClose}`)?.trim().split(" ")?.forEach(s=>{if(s){const r=this.getOrThrow(s);return r.trigger=n,r.close()}else{const r=e.closest(this.settings.selector);if(r)return this.close(r.id)}});return}if(this.activeModal&&e.matches(this.settings.selectorScreen))return this.close(this.activeModal.id)}}function On(t){if(t.key==="Escape"&&this.activeModal)return this.close(this.activeModal.id)}class Pn extends En{#t;#e;constructor(e){super({...xn,...e}),this.module="Drawer",this.entryClass=An,this.#t=Tn.bind(this),this.#e=On.bind(this)}get activeModal(){return this.collection.find(e=>e.state==="opened"&&e.mode==="modal")}async open(e,n,s){const r=this.getOrThrow(e);return At(r,n,s)}async close(e,n,s){const r=this.getOrThrow(e);return Tt(r,n,s)}async toggle(e,n,s){const r=this.getOrThrow(e);return ae(r,n,s)}async afterMount(){document.addEventListener("click",this.#t,!1),document.addEventListener("keydown",this.#e,!1)}async afterUnmount(){document.removeEventListener("click",this.#t,!1),document.removeEventListener("keydown",this.#e,!1)}}function kn(t,e="config"){const n=(t.getAttribute(`data-${e}`)||"").replace(/'/g,'"');return n?JSON.parse(n):{}}function le(t){if(typeof t=="string"){const e=document.getElementById(t);if(e)return e;throw new Error(`Element not found with ID: "${t}"`)}else if(t instanceof HTMLElement){if(!t.id)throw new Error("HTMLElement must have an ID");return t}else throw new Error("Invalid argument: query must be a string or HTMLElement")}async function Q(t,e,...n){e in t&&typeof t[e]=="function"&&await t[e](...n)}function Rn(t){return t.split("-").map((e,n)=>n===0?e:e.charAt(0).toUpperCase()+e.slice(1)).join("")}function ce(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function Dn(t){if(typeof t=="number")return t;const e=parseFloat(t);if(!Number.isNaN(e)){const n=t.includes("ms");return e*(n?1:1e3)}throw new Error(`Could not convert value to milliseconds: ${t}`)}function ue(t,e,n,s,r=0){return new Promise(i=>{t.classList.remove(e),t.classList.add(n),setTimeout(()=>{t.classList.add(s),t.classList.remove(n),i(t)},Dn(r))})}async function U(t,e,n){await Q(e,t,n),n&&await Q(n,t);for(const s of e.plugins)await Q(s,t,{plugin:s,parent:e,entry:n});await e.emit(t,n)}function Mn(t){const e=getComputedStyle(t.el),n={},s=t.getSetting("customProps");for(let r=0;r<s.length;r++){const i=In(),o=t.parent.module.toLowerCase(),a=ce(s[r]),l=e.getPropertyValue(`--${i}${o}-${a}`).trim();l&&(n[a]=l)}return n}function In(){return getComputedStyle(document.body).getPropertyValue("--vb-prefix").trim()}function Hn(t,e,n="camel"){return e=n==="camel"?Rn(e):ce(e),t.split(".").concat(e).reduce((s,r)=>s?.[r],this)}function qn(t,e={}){const{fallback:n,props:s=["dataConfig","customProps","settings","parent.settings"]}=e;for(const r of s){const i=r!=="customProps"?"camel":"kebab",o=Hn.call(this,r,t,i);if(o!==void 0)return o}if(n!==void 0)return n;throw new Error(`${this.parent.module} setting does not exist: ${t}`)}function jn(t,e){e&&document.querySelectorAll(e).forEach(n=>{t?n.style.overflow="hidden":n.style.removeProperty("overflow")})}function Nn(t,e){e&&document.querySelectorAll(e).forEach(n=>{n.inert=t})}function Un(t,e,n){Nn(!!t,e),jn(!!t,n)}const Fn={events:{},on(t,e,...n){this.events[t]||(this.events[t]=[]),this.events[t].some(s=>s.listener===e)||this.events[t].push({listener:e,args:n})},off(t,e){this.events[t]&&(this.events[t]=this.events[t].filter(n=>n.listener!==e))},async emit(t,e){if(t=t.startsWith("on")?t.slice(2,3).toLowerCase()+t.slice(3):t,!!this.events[t])for(const{listener:n,args:s}of this.events[t])await n(e,...s)}};let Vn=class extends Array{constructor(e={}){super(),this.presets=e}applySettings(e){const n=e?.defaults||{},s=this.presets?.[e.name]||{},r=e?.options||{};e.settings={...n,...s,...r}}validate(e){return!("name"in e)||typeof e.name!="string"?(console.error("Plugin requires a name!"),!1):!0}get(e){return this.find(n=>n.name===e)}add(e){if(Array.isArray(e))e.forEach(n=>this.add(n));else if(this.applySettings(e),this.validate(e)){const n=this.findIndex(s=>s.name===e.name);~n?this[n]=e:this.push(e)}}remove(e){const n=this.findIndex(s=>s.name===e);~n&&this.splice(n,1)}},zn=class extends Array{constructor(e={}){super(),this.settings=e}get copy(){return[...this]}get top(){return this[this.length-1]||null}updateIndex(){this.forEach((e,n)=>{e.el.style.zIndex="";const s=getComputedStyle(e.el)["z-index"];e.el.style.zIndex=String(parseInt(s,10)+n+1)})}onChange(){this.updateIndex(),typeof this.settings.onChange=="function"&&this.settings.onChange()}add(e){this.push(e),this.onChange()}remove(e){const n=this.findIndex(s=>s.id===e.id);~n&&(e.el.style.zIndex="",this.splice(n,1),this.onChange())}moveToTop(e){const n=this.findIndex(s=>s.id===e.id);~n&&(this.splice(n,1),this.add(e))}};const Bn={dataConfig:"config",customProps:[]};class fe{constructor(e,n,s={}){this.parent=e,this.el=le(n),this.settings={...s},this.dataConfig={},this.customProps={}}get id(){return this.el.id}applySettings(e){return Object.assign(this.settings,e)}getSetting(e,n){return qn.call(this,e,n)}buildDataConfig(){return Object.assign(this.dataConfig,kn(this.el,this.getSetting("dataConfig")))}buildCustomProps(){return Object.assign(this.customProps,Mn(this))}async init(e={}){this.applySettings(e),this.buildDataConfig(),this.buildCustomProps()}async destroy(){Object.getOwnPropertyNames(this).forEach(e=>{delete this[e]})}}class Wn{constructor(e={}){this.module=this.constructor.name,this.collection=[],this.entryClass=fe,this.settings={...Bn,...e},this.plugins=new Vn(this.settings.presets),this.events={},Object.assign(this,Fn)}get(e,n="id"){return this.collection.find(s=>s[n]===e)}getOrThrow(e,n="id"){const s=this.get(e,n);if(s)return s;throw new Error(`${this.module} entry not found in collection with ${n} of "${e}"`)}applySettings(e){return Object.assign(this.settings,e)}async createEntry(e,n){const s=new this.entryClass(this,e,n);return await Q(s,"init"),await U("onCreateEntry",this,s),s}async destroyEntry(e){return await U("onDestroyEntry",this,e),await Q(e,"destroy"),e}async register(e,n={}){const s=le(e),r=this.collection.findIndex(i=>i.id===s.id);if(~r){const i=this.collection[r];return i.el=s,typeof i.init=="function"&&await i.init(n),i}else{const i=await this.createEntry(s,n);return this.collection.push(i),await U("onRegisterEntry",this,i),i}}async deregister(e){const n=this.collection.findIndex(s=>s.id===e);if(~n){const s=await this.destroyEntry(this.collection[n]);return await U("onDeregisterEntry",this,this.collection[n]),this.collection.splice(n,1),s}return null}async mount(e={}){this.applySettings(e);for(const s of this.settings?.plugins||[])this.plugins.add(s);for(const s of this.plugins)await Q(s,"setup",{plugin:s,parent:this});await U("beforeMount",this);const n=document.querySelectorAll(this.settings.selector);for(const s of n)await this.register(s);return await U("afterMount",this),this}async unmount(){for(await U("beforeUnmount",this);this.collection.length>0;)await this.deregister(this.collection[0].id);await U("afterUnmount",this);for(const e of this.plugins)await Q(e,"teardown",{plugin:e,parent:this});for(const e of[...this.plugins])this.plugins.remove(e.name);return this}}const _n={dataOpen:"modal-open",dataClose:"modal-close",dataReplace:"modal-replace",selector:".modal",selectorDialog:".modal__dialog",selectorScreen:".modal",selectorRequired:'[role="alertdialog"]',selectorFocus:"[data-focus]",selectorInert:null,selectorOverflow:"body",stateOpened:"is-opened",stateOpening:"is-opening",stateClosing:"is-closing",stateClosed:"is-closed",customProps:["transition-duration"],customEventPrefix:"modal:",setTabindex:!0,transition:!0,transitionDuration:300};function gt(t){t.active?(t.active.dialog.querySelector(t.settings.selectorFocus)||t.active.dialog).focus():t.trigger&&(t.trigger.focus(),t.trigger=null)}async function Ot(t,e,n=!0){return t.parent.stack.moveToTop(t),t.state==="closed"&&(t.state="opening",t.parent.stack.add(t),e??t.getSetting("transition")?await ue(t.el,t.getSetting("stateClosed"),t.getSetting("stateOpening"),t.getSetting("stateOpened"),t.getSetting("transitionDuration")):(t.el.classList.add(t.getSetting("stateOpened")),t.el.classList.remove(t.getSetting("stateClosed"))),t.state="opened"),n&&gt(t.parent),t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"opened",{detail:t.parent,bubbles:!0})),await t.parent.emit("opened",t),t}async function Pt(t,e,n=!0){return t&&t.state==="opened"&&(t.state="closing",document.activeElement&&document.activeElement instanceof HTMLElement&&document.activeElement.blur(),e??t.getSetting("transition")?await ue(t.el,t.getSetting("stateOpened"),t.getSetting("stateClosing"),t.getSetting("stateClosed"),t.getSetting("transitionDuration")):(t.el.classList.add(t.getSetting("stateClosed")),t.el.classList.remove(t.getSetting("stateOpened"))),t.parent.stack.remove(t),t.state="closed",n&&gt(t.parent),t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"closed",{detail:t.parent,bubbles:!0})),await t.parent.emit("closed",t)),t}async function he(t,e,n=!0){let s,r;return t.state==="opened"?(s=t,r=await t.parent.closeAll(t.id,e)):[r,s]=await Promise.all([t.parent.closeAll("",e),Ot(t,e,!1)]),n&&gt(t.parent),{opened:s,closed:r}}let Qn=class extends fe{constructor(e,n,s={}){super(e,n,s),this.state="closed",this.dialog=this.el.querySelector(this.getSetting("selectorDialog"))||this.el}get isRequired(){return this.dialog.matches(this.getSetting("selectorRequired"))}async open(e,n){return Ot(this,e,n)}async close(e,n){return Pt(this,e,n)}async replace(e,n){return he(this,e,n)}async deregister(){return this.parent.deregister(this.id)}async onCreateEntry(){this.dialog.setAttribute("aria-modal","true"),this.dialog.hasAttribute("role")||this.dialog.setAttribute("role","dialog"),this.getSetting("setTabindex")&&this.dialog.setAttribute("tabindex","-1")}async onRegisterEntry(){this.el.classList.contains(this.getSetting("stateOpened"))?await this.open(!1):(this.el.classList.remove(this.getSetting("stateOpening")),this.el.classList.remove(this.getSetting("stateClosing")),this.el.classList.add(this.getSetting("stateClosed")))}async onDestroyEntry(){this.state==="opened"&&await this.close(!1)}};async function Jn(t){const e=t.target;if(e){const n=e.closest(`
6
+ [data-${this.settings.dataOpen}],
7
+ [data-${this.settings.dataReplace}],
8
+ [data-${this.settings.dataClose}]
9
+ `);if(n){if(t.preventDefault(),n.matches(`[data-${this.settings.dataOpen}]`)){const s=n.getAttribute(`data-${this.settings.dataOpen}`)?.trim(),r=this.getOrThrow(s);return e.closest(this.settings.selector)||(this.trigger=n),r.open()}if(n.matches(`[data-${this.settings.dataReplace}]`)){const s=n.getAttribute(`data-${this.settings.dataReplace}`)?.trim(),r=this.getOrThrow(s);return e.closest(this.settings.selector)||(this.trigger=n),r.replace()}if(n.matches(`[data-${this.settings.dataClose}]`)){const s=n.getAttribute(`data-${this.settings.dataClose}`)?.trim();return s==="*"?this.closeAll():this.close(s||"")}}if(this.active&&e.matches(this.settings.selectorScreen)&&!this.active.isRequired)return this.close()}}function Zn(t){if(t.key==="Escape"&&this.active&&!this.active.dialog.matches(this.settings.selectorRequired))return this.close()}async function Kn(t="",e){const n=[];return await Promise.all(this.stack.copy.map(async s=>{t&&t===s.id||n.push(await Pt(s,e,!1))})),n}let Xn=class extends Wn{#t;#e;constructor(e){super({..._n,...e}),this.module="Modal",this.entryClass=Qn,this.trigger=null,this.#t=Jn.bind(this),this.#e=Zn.bind(this),this.stack=new zn({onChange:()=>{Un(!!this.stack.top,this.settings.selectorInert,this.settings.selectorOverflow)}})}get active(){return this.stack.top}async open(e,n,s){const r=this.getOrThrow(e);return Ot(r,n,s)}async close(e,n,s){const r=e?this.getOrThrow(e):this.active;return Pt(r,n,s)}async replace(e,n,s){const r=this.getOrThrow(e);return he(r,n,s)}async closeAll(e,n,s=!0){const r=await Kn.call(this,e,n);return s&&gt(this),r}async afterMount(){document.addEventListener("click",this.#t,!1),document.addEventListener("keydown",this.#e,!1)}async beforeUnmount(){this.trigger=null}async afterUnmount(){document.removeEventListener("click",this.#t,!1),document.removeEventListener("keydown",this.#e,!1)}};function Yn(t,e="config"){const n=(t.getAttribute(`data-${e}`)||"").replace(/'/g,'"');return n?JSON.parse(n):{}}function de(t){if(typeof t=="string"){const e=document.getElementById(t);if(e)return e;throw new Error(`Element not found with ID: "${t}"`)}else if(t instanceof HTMLElement){if(!t.id)throw new Error("HTMLElement must have an ID");return t}else throw new Error("Invalid argument: query must be a string or HTMLElement")}async function J(t,e,...n){e in t&&typeof t[e]=="function"&&await t[e](...n)}function Gn(t){return t.split("-").map((e,n)=>n===0?e:e.charAt(0).toUpperCase()+e.slice(1)).join("")}function ge(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}async function F(t,e,n){await J(e,t,n),n&&await J(n,t);for(const s of e.plugins)await J(s,t,{plugin:s,parent:e,entry:n});await e.emit(t,n)}function ts(t){const e=getComputedStyle(t.el),n={},s=t.getSetting("customProps");for(let r=0;r<s.length;r++){const i=es(),o=t.parent.module.toLowerCase(),a=ge(s[r]),l=e.getPropertyValue(`--${i}${o}-${a}`).trim();l&&(n[a]=l)}return n}function es(){return getComputedStyle(document.body).getPropertyValue("--vb-prefix").trim()}function ns(t,e,n="camel"){return e=n==="camel"?Gn(e):ge(e),t.split(".").concat(e).reduce((s,r)=>s?.[r],this)}function ss(t,e={}){const{fallback:n,props:s=["dataConfig","customProps","settings","parent.settings"]}=e;for(const r of s){const i=r!=="customProps"?"camel":"kebab",o=ns.call(this,r,t,i);if(o!==void 0)return o}if(n!==void 0)return n;throw new Error(`${this.parent.module} setting does not exist: ${t}`)}const is={events:{},on(t,e,...n){this.events[t]||(this.events[t]=[]),this.events[t].some(s=>s.listener===e)||this.events[t].push({listener:e,args:n})},off(t,e){this.events[t]&&(this.events[t]=this.events[t].filter(n=>n.listener!==e))},async emit(t,e){if(t=t.startsWith("on")?t.slice(2,3).toLowerCase()+t.slice(3):t,!!this.events[t])for(const{listener:n,args:s}of this.events[t])await n(e,...s)}};class rs extends Array{constructor(e={}){super(),this.presets=e}applySettings(e){const n=e?.defaults||{},s=this.presets?.[e.name]||{},r=e?.options||{};e.settings={...n,...s,...r}}validate(e){return!("name"in e)||typeof e.name!="string"?(console.error("Plugin requires a name!"),!1):!0}get(e){return this.find(n=>n.name===e)}add(e){if(Array.isArray(e))e.forEach(n=>this.add(n));else if(this.applySettings(e),this.validate(e)){const n=this.findIndex(s=>s.name===e.name);~n?this[n]=e:this.push(e)}}remove(e){const n=this.findIndex(s=>s.name===e);~n&&this.splice(n,1)}}const os={dataConfig:"config",customProps:[]};class pe{constructor(e,n,s={}){this.parent=e,this.el=de(n),this.settings={...s},this.dataConfig={},this.customProps={}}get id(){return this.el.id}applySettings(e){return Object.assign(this.settings,e)}getSetting(e,n){return ss.call(this,e,n)}buildDataConfig(){return Object.assign(this.dataConfig,Yn(this.el,this.getSetting("dataConfig")))}buildCustomProps(){return Object.assign(this.customProps,ts(this))}async init(e={}){this.applySettings(e),this.buildDataConfig(),this.buildCustomProps()}async destroy(){Object.getOwnPropertyNames(this).forEach(e=>{delete this[e]})}}class as{constructor(e={}){this.module=this.constructor.name,this.collection=[],this.entryClass=pe,this.settings={...os,...e},this.plugins=new rs(this.settings.presets),this.events={},Object.assign(this,is)}get(e,n="id"){return this.collection.find(s=>s[n]===e)}getOrThrow(e,n="id"){const s=this.get(e,n);if(s)return s;throw new Error(`${this.module} entry not found in collection with ${n} of "${e}"`)}applySettings(e){return Object.assign(this.settings,e)}async createEntry(e,n){const s=new this.entryClass(this,e,n);return await J(s,"init"),await F("onCreateEntry",this,s),s}async destroyEntry(e){return await F("onDestroyEntry",this,e),await J(e,"destroy"),e}async register(e,n={}){const s=de(e),r=this.collection.findIndex(i=>i.id===s.id);if(~r){const i=this.collection[r];return i.el=s,typeof i.init=="function"&&await i.init(n),i}else{const i=await this.createEntry(s,n);return this.collection.push(i),await F("onRegisterEntry",this,i),i}}async deregister(e){const n=this.collection.findIndex(s=>s.id===e);if(~n){const s=await this.destroyEntry(this.collection[n]);return await F("onDeregisterEntry",this,this.collection[n]),this.collection.splice(n,1),s}return null}async mount(e={}){this.applySettings(e);for(const s of this.settings?.plugins||[])this.plugins.add(s);for(const s of this.plugins)await J(s,"setup",{plugin:s,parent:this});await F("beforeMount",this);const n=document.querySelectorAll(this.settings.selector);for(const s of n)await this.register(s);return await F("afterMount",this),this}async unmount(){for(await F("beforeUnmount",this);this.collection.length>0;)await this.deregister(this.collection[0].id);await F("afterUnmount",this);for(const e of this.plugins)await J(e,"teardown",{plugin:e,parent:this});for(const e of[...this.plugins])this.plugins.remove(e.name);return this}}const ls={selector:".popover",selectorTooltip:".popover_tooltip",selectorArrow:".popover__arrow",stateActive:"is-active",customProps:["placement","event","offset","flip-padding","shift-padding","arrow-padding","toggle-delay"],customEventPrefix:"popover:",placement:"bottom",event:"click",offset:0,flipPadding:0,shiftPadding:0,arrowPadding:0,toggleDelay:0},nt=Math.min,Z=Math.max,pt=Math.round,mt=Math.floor,P=t=>({x:t,y:t}),cs={left:"right",right:"left",bottom:"top",top:"bottom"},us={start:"end",end:"start"};function kt(t,e,n){return Z(t,nt(e,n))}function K(t,e){return typeof t=="function"?t(e):t}function V(t){return t.split("-")[0]}function at(t){return t.split("-")[1]}function Rt(t){return t==="x"?"y":"x"}function Dt(t){return t==="y"?"height":"width"}const fs=new Set(["top","bottom"]);function I(t){return fs.has(V(t))?"y":"x"}function Mt(t){return Rt(I(t))}function hs(t,e,n){n===void 0&&(n=!1);const s=at(t),r=Mt(t),i=Dt(r);let o=r==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=yt(o)),[o,yt(o)]}function ds(t){const e=yt(t);return[It(t),e,It(e)]}function It(t){return t.replace(/start|end/g,e=>us[e])}const me=["left","right"],ye=["right","left"],gs=["top","bottom"],ps=["bottom","top"];function ms(t,e,n){switch(t){case"top":case"bottom":return n?e?ye:me:e?me:ye;case"left":case"right":return e?gs:ps;default:return[]}}function ys(t,e,n,s){const r=at(t);let i=ms(V(t),n==="start",s);return r&&(i=i.map(o=>o+"-"+r),e&&(i=i.concat(i.map(It)))),i}function yt(t){return t.replace(/left|right|bottom|top/g,e=>cs[e])}function ws(t){return{top:0,right:0,bottom:0,left:0,...t}}function we(t){return typeof t!="number"?ws(t):{top:t,right:t,bottom:t,left:t}}function wt(t){const{x:e,y:n,width:s,height:r}=t;return{width:s,height:r,top:n,left:e,right:e+s,bottom:n+r,x:e,y:n}}function ve(t,e,n){let{reference:s,floating:r}=t;const i=I(e),o=Mt(e),a=Dt(o),l=V(e),c=i==="y",f=s.x+s.width/2-r.width/2,h=s.y+s.height/2-r.height/2,d=s[a]/2-r[a]/2;let u;switch(l){case"top":u={x:f,y:s.y-r.height};break;case"bottom":u={x:f,y:s.y+s.height};break;case"right":u={x:s.x+s.width,y:h};break;case"left":u={x:s.x-r.width,y:h};break;default:u={x:s.x,y:s.y}}switch(at(e)){case"start":u[o]-=d*(n&&c?-1:1);break;case"end":u[o]+=d*(n&&c?-1:1);break}return u}const vs=async(t,e,n)=>{const{placement:s="bottom",strategy:r="absolute",middleware:i=[],platform:o}=n,a=i.filter(Boolean),l=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:t,floating:e,strategy:r}),{x:f,y:h}=ve(c,s,l),d=s,u={},g=0;for(let p=0;p<a.length;p++){const{name:m,fn:y}=a[p],{x:w,y:v,data:b,reset:E}=await y({x:f,y:h,initialPlacement:s,placement:d,strategy:r,middlewareData:u,rects:c,platform:o,elements:{reference:t,floating:e}});f=w??f,h=v??h,u={...u,[m]:{...u[m],...b}},E&&g<=50&&(g++,typeof E=="object"&&(E.placement&&(d=E.placement),E.rects&&(c=E.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:r}):E.rects),{x:f,y:h}=ve(c,d,l)),p=-1)}return{x:f,y:h,placement:d,strategy:r,middlewareData:u}};async function be(t,e){var n;e===void 0&&(e={});const{x:s,y:r,platform:i,rects:o,elements:a,strategy:l}=t,{boundary:c="clippingAncestors",rootBoundary:f="viewport",elementContext:h="floating",altBoundary:d=!1,padding:u=0}=K(e,t),g=we(u),p=a[d?h==="floating"?"reference":"floating":h],m=wt(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(p)))==null||n?p:p.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:c,rootBoundary:f,strategy:l})),y=h==="floating"?{x:s,y:r,width:o.floating.width,height:o.floating.height}:o.reference,w=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),v=await(i.isElement==null?void 0:i.isElement(w))?await(i.getScale==null?void 0:i.getScale(w))||{x:1,y:1}:{x:1,y:1},b=wt(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:y,offsetParent:w,strategy:l}):y);return{top:(m.top-b.top+g.top)/v.y,bottom:(b.bottom-m.bottom+g.bottom)/v.y,left:(m.left-b.left+g.left)/v.x,right:(b.right-m.right+g.right)/v.x}}const bs=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:s,placement:r,rects:i,platform:o,elements:a,middlewareData:l}=e,{element:c,padding:f=0}=K(t,e)||{};if(c==null)return{};const h=we(f),d={x:n,y:s},u=Mt(r),g=Dt(u),p=await o.getDimensions(c),m=u==="y",y=m?"top":"left",w=m?"bottom":"right",v=m?"clientHeight":"clientWidth",b=i.reference[g]+i.reference[u]-d[u]-i.floating[g],E=d[u]-i.reference[u],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let Y=S?S[v]:0;(!Y||!await(o.isElement==null?void 0:o.isElement(S)))&&(Y=a.floating[v]||i.floating[g]);const ut=b/2-E/2,G=Y/2-p[g]/2-1,H=nt(h[y],G),ft=nt(h[w],G),tt=H,ht=Y-p[g]-ft,x=Y/2-p[g]/2+ut,et=kt(tt,x,ht),q=!l.arrow&&at(r)!=null&&x!==et&&i.reference[g]/2-(x<tt?H:ft)-p[g]/2<0,A=q?x<tt?x-tt:x-ht:0;return{[u]:d[u]+A,data:{[u]:et,centerOffset:x-et-A,...q&&{alignmentOffset:A}},reset:q}}}),Es=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,s;const{placement:r,middlewareData:i,rects:o,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:f=!0,crossAxis:h=!0,fallbackPlacements:d,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:p=!0,...m}=K(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const y=V(r),w=I(a),v=V(a)===a,b=await(l.isRTL==null?void 0:l.isRTL(c.floating)),E=d||(v||!p?[yt(a)]:ds(a)),S=g!=="none";!d&&S&&E.push(...ys(a,p,g,b));const Y=[a,...E],ut=await be(e,m),G=[];let H=((s=i.flip)==null?void 0:s.overflows)||[];if(f&&G.push(ut[y]),h){const x=hs(r,o,b);G.push(ut[x[0]],ut[x[1]])}if(H=[...H,{placement:r,overflows:G}],!G.every(x=>x<=0)){var ft,tt;const x=(((ft=i.flip)==null?void 0:ft.index)||0)+1,et=Y[x];if(et&&(!(h==="alignment"&&w!==I(et))||H.every(A=>I(A.placement)===w?A.overflows[0]>0:!0)))return{data:{index:x,overflows:H},reset:{placement:et}};let q=(tt=H.filter(A=>A.overflows[0]<=0).sort((A,B)=>A.overflows[1]-B.overflows[1])[0])==null?void 0:tt.placement;if(!q)switch(u){case"bestFit":{var ht;const A=(ht=H.filter(B=>{if(S){const W=I(B.placement);return W===w||W==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(W=>W>0).reduce((W,di)=>W+di,0)]).sort((B,W)=>B[1]-W[1])[0])==null?void 0:ht[0];A&&(q=A);break}case"initialPlacement":q=a;break}if(r!==q)return{reset:{placement:q}}}return{}}}},Ee=new Set(["left","top"]);async function $s(t,e){const{placement:n,platform:s,elements:r}=t,i=await(s.isRTL==null?void 0:s.isRTL(r.floating)),o=V(n),a=at(n),l=I(n)==="y",c=Ee.has(o)?-1:1,f=i&&l?-1:1,h=K(e,t);let{mainAxis:d,crossAxis:u,alignmentAxis:g}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&typeof g=="number"&&(u=a==="end"?g*-1:g),l?{x:u*f,y:d*c}:{x:d*c,y:u*f}}const xs=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,s;const{x:r,y:i,placement:o,middlewareData:a}=e,l=await $s(e,t);return o===((n=a.offset)==null?void 0:n.placement)&&(s=a.arrow)!=null&&s.alignmentOffset?{}:{x:r+l.x,y:i+l.y,data:{...l,placement:o}}}}},Ss=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:s,placement:r}=e,{mainAxis:i=!0,crossAxis:o=!1,limiter:a={fn:m=>{let{x:y,y:w}=m;return{x:y,y:w}}},...l}=K(t,e),c={x:n,y:s},f=await be(e,l),h=I(V(r)),d=Rt(h);let u=c[d],g=c[h];if(i){const m=d==="y"?"top":"left",y=d==="y"?"bottom":"right",w=u+f[m],v=u-f[y];u=kt(w,u,v)}if(o){const m=h==="y"?"top":"left",y=h==="y"?"bottom":"right",w=g+f[m],v=g-f[y];g=kt(w,g,v)}const p=a.fn({...e,[d]:u,[h]:g});return{...p,data:{x:p.x-n,y:p.y-s,enabled:{[d]:i,[h]:o}}}}}},Cs=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:s,placement:r,rects:i,middlewareData:o}=e,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=K(t,e),f={x:n,y:s},h=I(r),d=Rt(h);let u=f[d],g=f[h];const p=K(a,e),m=typeof p=="number"?{mainAxis:p,crossAxis:0}:{mainAxis:0,crossAxis:0,...p};if(l){const v=d==="y"?"height":"width",b=i.reference[d]-i.floating[v]+m.mainAxis,E=i.reference[d]+i.reference[v]-m.mainAxis;u<b?u=b:u>E&&(u=E)}if(c){var y,w;const v=d==="y"?"width":"height",b=Ee.has(V(r)),E=i.reference[h]-i.floating[v]+(b&&((y=o.offset)==null?void 0:y[h])||0)+(b?0:m.crossAxis),S=i.reference[h]+i.reference[v]+(b?0:((w=o.offset)==null?void 0:w[h])||0)-(b?m.crossAxis:0);g<E?g=E:g>S&&(g=S)}return{[d]:u,[h]:g}}}};function vt(){return typeof window<"u"}function st(t){return $e(t)?(t.nodeName||"").toLowerCase():"#document"}function L(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function k(t){var e;return(e=($e(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function $e(t){return vt()?t instanceof Node||t instanceof L(t).Node:!1}function T(t){return vt()?t instanceof Element||t instanceof L(t).Element:!1}function R(t){return vt()?t instanceof HTMLElement||t instanceof L(t).HTMLElement:!1}function xe(t){return!vt()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof L(t).ShadowRoot}const Ls=new Set(["inline","contents"]);function lt(t){const{overflow:e,overflowX:n,overflowY:s,display:r}=O(t);return/auto|scroll|overlay|hidden|clip/.test(e+s+n)&&!Ls.has(r)}const As=new Set(["table","td","th"]);function Ts(t){return As.has(st(t))}const Os=[":popover-open",":modal"];function bt(t){return Os.some(e=>{try{return t.matches(e)}catch{return!1}})}const Ps=["transform","translate","scale","rotate","perspective"],ks=["transform","translate","scale","rotate","perspective","filter"],Rs=["paint","layout","strict","content"];function Ht(t){const e=qt(),n=T(t)?O(t):t;return Ps.some(s=>n[s]?n[s]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||ks.some(s=>(n.willChange||"").includes(s))||Rs.some(s=>(n.contain||"").includes(s))}function Ds(t){let e=z(t);for(;R(e)&&!it(e);){if(Ht(e))return e;if(bt(e))return null;e=z(e)}return null}function qt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Ms=new Set(["html","body","#document"]);function it(t){return Ms.has(st(t))}function O(t){return L(t).getComputedStyle(t)}function Et(t){return T(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function z(t){if(st(t)==="html")return t;const e=t.assignedSlot||t.parentNode||xe(t)&&t.host||k(t);return xe(e)?e.host:e}function Se(t){const e=z(t);return it(e)?t.ownerDocument?t.ownerDocument.body:t.body:R(e)&&lt(e)?e:Se(e)}function ct(t,e,n){var s;e===void 0&&(e=[]),n===void 0&&(n=!0);const r=Se(t),i=r===((s=t.ownerDocument)==null?void 0:s.body),o=L(r);if(i){const a=jt(o);return e.concat(o,o.visualViewport||[],lt(r)?r:[],a&&n?ct(a):[])}return e.concat(r,ct(r,[],n))}function jt(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Ce(t){const e=O(t);let n=parseFloat(e.width)||0,s=parseFloat(e.height)||0;const r=R(t),i=r?t.offsetWidth:n,o=r?t.offsetHeight:s,a=pt(n)!==i||pt(s)!==o;return a&&(n=i,s=o),{width:n,height:s,$:a}}function Nt(t){return T(t)?t:t.contextElement}function rt(t){const e=Nt(t);if(!R(e))return P(1);const n=e.getBoundingClientRect(),{width:s,height:r,$:i}=Ce(e);let o=(i?pt(n.width):n.width)/s,a=(i?pt(n.height):n.height)/r;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const Is=P(0);function Le(t){const e=L(t);return!qt()||!e.visualViewport?Is:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Hs(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==L(t)?!1:e}function X(t,e,n,s){e===void 0&&(e=!1),n===void 0&&(n=!1);const r=t.getBoundingClientRect(),i=Nt(t);let o=P(1);e&&(s?T(s)&&(o=rt(s)):o=rt(t));const a=Hs(i,n,s)?Le(i):P(0);let l=(r.left+a.x)/o.x,c=(r.top+a.y)/o.y,f=r.width/o.x,h=r.height/o.y;if(i){const d=L(i),u=s&&T(s)?L(s):s;let g=d,p=jt(g);for(;p&&s&&u!==g;){const m=rt(p),y=p.getBoundingClientRect(),w=O(p),v=y.left+(p.clientLeft+parseFloat(w.paddingLeft))*m.x,b=y.top+(p.clientTop+parseFloat(w.paddingTop))*m.y;l*=m.x,c*=m.y,f*=m.x,h*=m.y,l+=v,c+=b,g=L(p),p=jt(g)}}return wt({width:f,height:h,x:l,y:c})}function $t(t,e){const n=Et(t).scrollLeft;return e?e.left+n:X(k(t)).left+n}function Ae(t,e){const n=t.getBoundingClientRect(),s=n.left+e.scrollLeft-$t(t,n),r=n.top+e.scrollTop;return{x:s,y:r}}function qs(t){let{elements:e,rect:n,offsetParent:s,strategy:r}=t;const i=r==="fixed",o=k(s),a=e?bt(e.floating):!1;if(s===o||a&&i)return n;let l={scrollLeft:0,scrollTop:0},c=P(1);const f=P(0),h=R(s);if((h||!h&&!i)&&((st(s)!=="body"||lt(o))&&(l=Et(s)),R(s))){const u=X(s);c=rt(s),f.x=u.x+s.clientLeft,f.y=u.y+s.clientTop}const d=o&&!h&&!i?Ae(o,l):P(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+f.x+d.x,y:n.y*c.y-l.scrollTop*c.y+f.y+d.y}}function js(t){return Array.from(t.getClientRects())}function Ns(t){const e=k(t),n=Et(t),s=t.ownerDocument.body,r=Z(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),i=Z(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let o=-n.scrollLeft+$t(t);const a=-n.scrollTop;return O(s).direction==="rtl"&&(o+=Z(e.clientWidth,s.clientWidth)-r),{width:r,height:i,x:o,y:a}}const Te=25;function Us(t,e){const n=L(t),s=k(t),r=n.visualViewport;let i=s.clientWidth,o=s.clientHeight,a=0,l=0;if(r){i=r.width,o=r.height;const f=qt();(!f||f&&e==="fixed")&&(a=r.offsetLeft,l=r.offsetTop)}const c=$t(s);if(c<=0){const f=s.ownerDocument,h=f.body,d=getComputedStyle(h),u=f.compatMode==="CSS1Compat"&&parseFloat(d.marginLeft)+parseFloat(d.marginRight)||0,g=Math.abs(s.clientWidth-h.clientWidth-u);g<=Te&&(i-=g)}else c<=Te&&(i+=c);return{width:i,height:o,x:a,y:l}}const Fs=new Set(["absolute","fixed"]);function Vs(t,e){const n=X(t,!0,e==="fixed"),s=n.top+t.clientTop,r=n.left+t.clientLeft,i=R(t)?rt(t):P(1),o=t.clientWidth*i.x,a=t.clientHeight*i.y,l=r*i.x,c=s*i.y;return{width:o,height:a,x:l,y:c}}function Oe(t,e,n){let s;if(e==="viewport")s=Us(t,n);else if(e==="document")s=Ns(k(t));else if(T(e))s=Vs(e,n);else{const r=Le(t);s={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return wt(s)}function Pe(t,e){const n=z(t);return n===e||!T(n)||it(n)?!1:O(n).position==="fixed"||Pe(n,e)}function zs(t,e){const n=e.get(t);if(n)return n;let s=ct(t,[],!1).filter(a=>T(a)&&st(a)!=="body"),r=null;const i=O(t).position==="fixed";let o=i?z(t):t;for(;T(o)&&!it(o);){const a=O(o),l=Ht(o);!l&&a.position==="fixed"&&(r=null),(i?!l&&!r:!l&&a.position==="static"&&r&&Fs.has(r.position)||lt(o)&&!l&&Pe(t,o))?s=s.filter(c=>c!==o):r=a,o=z(o)}return e.set(t,s),s}function Bs(t){let{element:e,boundary:n,rootBoundary:s,strategy:r}=t;const i=[...n==="clippingAncestors"?bt(e)?[]:zs(e,this._c):[].concat(n),s],o=i[0],a=i.reduce((l,c)=>{const f=Oe(e,c,r);return l.top=Z(f.top,l.top),l.right=nt(f.right,l.right),l.bottom=nt(f.bottom,l.bottom),l.left=Z(f.left,l.left),l},Oe(e,o,r));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function Ws(t){const{width:e,height:n}=Ce(t);return{width:e,height:n}}function _s(t,e,n){const s=R(e),r=k(e),i=n==="fixed",o=X(t,!0,i,e);let a={scrollLeft:0,scrollTop:0};const l=P(0);function c(){l.x=$t(r)}if(s||!s&&!i)if((st(e)!=="body"||lt(r))&&(a=Et(e)),s){const u=X(e,!0,i,e);l.x=u.x+e.clientLeft,l.y=u.y+e.clientTop}else r&&c();i&&!s&&r&&c();const f=r&&!s&&!i?Ae(r,a):P(0),h=o.left+a.scrollLeft-l.x-f.x,d=o.top+a.scrollTop-l.y-f.y;return{x:h,y:d,width:o.width,height:o.height}}function Ut(t){return O(t).position==="static"}function ke(t,e){if(!R(t)||O(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return k(t)===n&&(n=n.ownerDocument.body),n}function Re(t,e){const n=L(t);if(bt(t))return n;if(!R(t)){let r=z(t);for(;r&&!it(r);){if(T(r)&&!Ut(r))return r;r=z(r)}return n}let s=ke(t,e);for(;s&&Ts(s)&&Ut(s);)s=ke(s,e);return s&&it(s)&&Ut(s)&&!Ht(s)?n:s||Ds(t)||n}const Qs=async function(t){const e=this.getOffsetParent||Re,n=this.getDimensions,s=await n(t.floating);return{reference:_s(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function Js(t){return O(t).direction==="rtl"}const Zs={convertOffsetParentRelativeRectToViewportRelativeRect:qs,getDocumentElement:k,getClippingRect:Bs,getOffsetParent:Re,getElementRects:Qs,getClientRects:js,getDimensions:Ws,getScale:rt,isElement:T,isRTL:Js};function De(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function Ks(t,e){let n=null,s;const r=k(t);function i(){var a;clearTimeout(s),(a=n)==null||a.disconnect(),n=null}function o(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),i();const c=t.getBoundingClientRect(),{left:f,top:h,width:d,height:u}=c;if(a||e(),!d||!u)return;const g=mt(h),p=mt(r.clientWidth-(f+d)),m=mt(r.clientHeight-(h+u)),y=mt(f),w={rootMargin:-g+"px "+-p+"px "+-m+"px "+-y+"px",threshold:Z(0,nt(1,l))||1};let v=!0;function b(E){const S=E[0].intersectionRatio;if(S!==l){if(!v)return o();S?o(!1,S):s=setTimeout(()=>{o(!1,1e-7)},1e3)}S===1&&!De(c,t.getBoundingClientRect())&&o(),v=!1}try{n=new IntersectionObserver(b,{...w,root:r.ownerDocument})}catch{n=new IntersectionObserver(b,w)}n.observe(t)}return o(!0),i}function Xs(t,e,n,s){s===void 0&&(s={});const{ancestorScroll:r=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=s,c=Nt(t),f=r||i?[...c?ct(c):[],...ct(e)]:[];f.forEach(y=>{r&&y.addEventListener("scroll",n,{passive:!0}),i&&y.addEventListener("resize",n)});const h=c&&a?Ks(c,n):null;let d=-1,u=null;o&&(u=new ResizeObserver(y=>{let[w]=y;w&&w.target===c&&u&&(u.unobserve(e),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var v;(v=u)==null||v.observe(e)})),n()}),c&&!l&&u.observe(c),u.observe(e));let g,p=l?X(t):null;l&&m();function m(){const y=X(t);p&&!De(p,y)&&n(),p=y,g=requestAnimationFrame(m)}return n(),()=>{var y;f.forEach(w=>{r&&w.removeEventListener("scroll",n),i&&w.removeEventListener("resize",n)}),h?.(),(y=u)==null||y.disconnect(),u=null,l&&cancelAnimationFrame(g)}}const Ys=xs,Gs=Ss,ti=Es,ei=bs,ni=Cs,si=(t,e,n)=>{const s=new Map,r={platform:Zs,...n},i={...r.platform,_c:s};return vs(t,e,{...r,platform:i})};function Me(t,e,n){Object.assign(t.style,{left:e!=null?`${e}px`:"",top:n!=null?`${n}px`:""})}function Ie(t,e){let n=t.getSetting("toggle-delay");typeof n=="string"&&(n.indexOf(",")>-1&&(n=n.split(",")),n.indexOf(" ")>-1&&(n=n.split(" "))),Array.isArray(n)&&(n=n[e]);const s=Number(n);if(Number.isNaN(s))throw new Error(`Provided delay value is not a number: "${n}"`);return s}function Ft(t){let e;const n=typeof t=="string"?t.trim().split(" ").map(s=>parseFloat(s)).filter(s=>!isNaN(s)):[t];for(let s=0;s<n.length;s++)n[s]=Number(n[s]);switch(n.length){case 1:e=n[0];break;case 2:e={top:n[0],right:n[1],bottom:n[0],left:n[1]};break;case 3:e={top:n[0],right:n[1],bottom:n[2],left:n[1]};break;case 4:e={top:n[0],right:n[1],bottom:n[2],left:n[3]};break;default:e=void 0;break}return e}function ii(t){return{offset:Number(t.getSetting("offset")),flip:{padding:Ft(t.getSetting("flip-padding"))},shift:{padding:Ft(t.getSetting("shift-padding"))},arrow:{selector:t.getSetting("selectorArrow"),element:null,padding:Ft(t.getSetting("arrow-padding"))}}}async function He(t){return t&&t.state==="opened"&&(t.el.inert=!0,t.el.classList.remove(t.parent.settings.stateActive),t.isTooltip||t.trigger?.setAttribute("aria-expanded","false"),t.floatingCleanup(),t.state="closed",t.trigger===t.parent.trigger&&(t.parent.trigger=null),t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"closed",{detail:t.parent,bubbles:!0})),await t.parent.emit("closed",t)),t}async function qe(t){const e=[];for(const n of t.collection)n.state==="opened"&&e.push(await n.close());return e}function je(t){t.state=="opened"&&setTimeout(()=>(document.activeElement?.closest(`#${t.id}, [aria-controls="${t.id}"], [aria-describedby="${t.id}"]`)||t.close(),t),1)}function ri(t){t.state==="opened"?t.close():(this.trigger=t.trigger,t.open())}function oi(t){t.isTooltip&&(t.toggleDelayId&&clearTimeout(t.toggleDelayId),t.close())}function ai(t,e){if(t.isHovered=e,e.type=="focus"&&t.trigger&&!t.trigger.matches(":focus-visible"))return;t.toggleDelayId&&clearTimeout(t.toggleDelayId);const n=t.trigger?.getAttribute("aria-expanded");if(n&&n=="true")return;const s=this.activeHover?0:Ie(t,0);this.activeHover&&this.activeHover.close(),t.toggleDelayId=setTimeout(()=>{t.id&&t.open()},s)}function li(t,e){setTimeout(()=>{t.isHovered=e,!t.isHovered&&(t.toggleDelayId&&clearTimeout(t.toggleDelayId),t.toggleDelayId=setTimeout(()=>je(t),Ie(t,1)))},1)}function ci(t){switch(t.key){case"Escape":this.trigger&&this.trigger.focus(),qe(this);return;case"Tab":this.collection.forEach(e=>{je(e)});return;default:return}}function ui(t){const e=this;document.addEventListener("click",function n(s){const r=s.target;r&&(r.closest(`#${t.id}, [aria-controls="${t.id}"], [aria-describedby="${t.id}"]`)?t.el&&!t.el.classList.contains(e.settings.stateActive)&&this.removeEventListener("click",n):(t.el&&t.el.classList.contains(e.settings.stateActive)&&t.close(),this.removeEventListener("click",n)))})}async function Ne(t){t.el.inert=!1,t.el.classList.add(t.parent.settings.stateActive),t.isTooltip||t.trigger?.setAttribute("aria-expanded","true"),t.buildCustomProps();const e=ii(t),n=t.el.querySelector(e.arrow.selector);return e.arrow.element=n||null,t.trigger instanceof HTMLElement&&(t.floatingCleanup=Xs(t.trigger,t.el,()=>{const s=[ti(e.flip),Gs({...e.shift,limiter:ni()}),Ys(e.offset)];e.arrow.element&&s.push(ei({...e.arrow,element:e.arrow.element})),si(t.trigger,t.el,{placement:t.getSetting("placement"),middleware:s}).then(({x:r,y:i,placement:o,middlewareData:a})=>{if(t.el){if(Me(t.el,r,i),e.arrow.element&&a.arrow){const{x:l,y:c}=a.arrow;Me(e.arrow.element,l,c)}t.el.setAttribute("data-floating-placement",o)}})})),t.state="opened",t.getSetting("event")==="click"&&ui.call(t.parent,t),t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"opened",{detail:t.parent,bubbles:!0})),await t.parent.emit("opened",t),t}class fi extends pe{#t;#e;constructor(e,n,s={}){super(e,n,s),this.state="closed",this.toggleDelayId=null,this.trigger=null,this.#t=null,this.#e={el:!1,trigger:!1},this.floatingCleanup=()=>{}}get isTooltip(){return!!this.el.closest(this.getSetting("selectorTooltip"))||this.el.getAttribute("role")=="tooltip"}get isHovered(){return this.#e.el||this.#e.trigger}set isHovered(e){const n=e.type=="mouseenter"?!0:e.type=="mouseleave"?!1:void 0;if(n!=null)switch(e.target){case this.el:this.#e.el=n;break;case this.trigger:this.#e.trigger=n;break}}async open(){return Ne(this)}async close(){return He(this)}async deregister(){return this.parent.deregister(this.id)}registerEventListeners(){this.#t||(this.getSetting("event")==="hover"?(this.#t=[{el:["el","trigger"],type:["mouseenter","focus"],listener:ai.bind(this.parent,this)},{el:["el","trigger"],type:["mouseleave","focusout"],listener:li.bind(this.parent,this)},{el:["trigger"],type:["click"],listener:oi.bind(this.parent,this)}],this.#t.forEach(e=>{e.el.forEach(n=>{e.type.forEach(s=>{this[n].addEventListener(s,e.listener,!1)})})})):(this.#t=[{el:["trigger"],type:["click"],listener:ri.bind(this.parent,this)}],this.#t.forEach(e=>{e.el.forEach(n=>{e.type.forEach(s=>{this[n].addEventListener(s,e.listener,!1)})})})))}deregisterEventListeners(){this.#t&&(this.#t.forEach(e=>{e.el.forEach(n=>{e.type.forEach(s=>{this[n].removeEventListener(s,e.listener,!1)})})}),this.#t=null)}async onCreateEntry(){this.trigger=document.querySelector(`[aria-controls="${this.id}"], [aria-describedby="${this.id}"]`),this.isTooltip?(this.settings.event="hover",this.el.setAttribute("role","tooltip")):this.trigger&&this.trigger instanceof HTMLElement&&this.trigger.setAttribute("aria-expanded","false"),this.registerEventListeners()}async onRegisterEntry(){this.el.classList.contains(this.getSetting("stateActive"))?await this.open():this.el.inert=!0}async onDestroyEntry(){this.state==="opened"&&await this.close(),this.floatingCleanup(),this.deregisterEventListeners()}}class hi extends as{#t;constructor(e){super({...ls,...e}),this.module="Popover",this.entryClass=fi,this.trigger=null,this.#t=ci.bind(this)}get active(){return this.get("opened","state")}get activeHover(){return this.collection.find(e=>e.state=="opened"&&e.getSetting("event")=="hover")}async open(e){const n=this.getOrThrow(e);return Ne(n)}async close(e){const n=e?this.getOrThrow(e):void 0;return n?He(n):qe(this)}async afterMount(){document.addEventListener("keydown",this.#t,!1)}async beforeUnmount(){this.trigger=null}async afterUnmount(){document.removeEventListener("keydown",this.#t,!1)}}D.Drawer=Pn,D.Modal=Xn,D.Popover=hi,D.core=ln,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})}));
10
10
  //# sourceMappingURL=index.umd.cjs.map