const t={_data:{},getItem:e=>Object.prototype.hasOwnProperty.call(t._data,e)?t._data[e]:null,setItem:(e,o)=>{t._data[e]=o},removeItem:e=>{Object.prototype.hasOwnProperty.call(t._data,e)&&delete t._data[e]}},e=window.JSON,o=(()=>{try{return window.localStorage}catch(e){return t}})(),i={get(t){let i=o.getItem(t);return/^\{.*\}$/.test(i)&&(i=e.parse(i)),i},set:(t,i)=>(typeof i==typeof{}&&(i=e.stringify(i)),o.setItem(t,i)),remove:t=>o.removeItem(t)},s=Object.assign(((t,e)=>i.set(t,e)),i),d="ui.theme.mode";class n{constructor(t="light"){this.mode=t,this.width=0,this.height=0,this.size="xs",s.get(d)?this.switch(s.get(d)):this.autodetectTheme(),this.setupSizes(window.innerWidth,window.innerHeight),window.addEventListener("resize",(()=>{this.setupSizes(window.innerWidth,window.innerHeight)}))}toggle(){this.switch("dark"===this.mode?"light":"dark")}validateModals(){"undefined"!=typeof document&&setTimeout((()=>{Boolean(document.querySelector("x-overlay-container x-modal.modal-show"))?document.querySelector("body").classList.add("modal-open"):document.querySelector("body").classList.remove("modal-open")}),100)}is(...t){return!!Array.isArray(t)&&t.includes(this.size)}getTheme(){return this.mode}autodetectTheme(){this.switch(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}setupSizes(t,e){this.width=t,this.height=e,this.size=this.getSizeByWidth(t)}getSizeByWidth(t){return t>=1200?"xl":t>=992?"lg":t>=768?"md":t>=576?"sm":"xs"}switch(t){"dark"==t&&document&&(this.mode=t,document.querySelector("body").classList.add("is-dark-mode"),s.set(d,t)),"light"==t&&document&&(this.mode=t,document.querySelector("body").classList.remove("is-dark-mode"),s.set(d,t))}static create(){const t=new n;return Object.assign((e=>t.switch(e)),{toggle:()=>t.toggle(),validateModals:()=>t.validateModals(),is:(...e)=>t.is(...e),getTheme:()=>t.getTheme(),autodetectTheme:()=>t.autodetectTheme(),size:t.size})}}const r=n.create(),h=(t,e)=>(e||document).querySelector(`[ref="${t}"]`);export{h as Q,s as S,r as T}