var fakeStorage={_data:{},getItem:function(e){if(Object.prototype.hasOwnProperty.call(fakeStorage._data,e)){return fakeStorage._data[e]}return null},setItem:function(e,t){fakeStorage._data[e]=t},removeItem:function(e){if(Object.prototype.hasOwnProperty.call(fakeStorage._data,e)){delete fakeStorage._data[e]}}};var getStorage=function(){try{return window.localStorage}catch(e){return fakeStorage}};var OJSON=window.JSON;var storage=getStorage();var StorageService={get:function(e){var t=storage.getItem(e);if(/^\{.*\}$/.test(t)){t=OJSON.parse(t)}return t},set:function(e,t){if(typeof t===typeof{}){t=OJSON.stringify(t)}return storage.setItem(e,t)},remove:function(e){return storage.removeItem(e)}};var create=function(){return Object.assign((function(e,t){return StorageService.set(e,t)}),StorageService)};var Store=create();var themeModeStorageKey="ui.theme.mode";var breakpoints={sm:576,md:768,lg:992,xl:1200};var ThemeService=function(){function e(e){if(e===void 0){e="light"}var t=this;this.mode=e;this.width=0;this.height=0;this.size="xs";if(Store.get(themeModeStorageKey)){this.switch(Store.get(themeModeStorageKey))}else{this.autodetectTheme()}this.setupSizes(document.documentElement.clientWidth,document.documentElement.clientHeight);this.isMobile()&&document.querySelector("body").classList.add("is-mobile");window.addEventListener("resize",(function(){t.setupSizes(document.documentElement.clientWidth,document.documentElement.clientHeight)}))}e.prototype.isMobile=function(){var e=[/Android/i,/webOS/i,/iPhone/i,/iPad/i,/iPod/i,/BlackBerry/i,/Windows Phone/i];var t=e.some((function(e){return e.exec(navigator.userAgent)}));var r=Math.min(document.documentElement.clientWidth,document.documentElement.clientHeight)<=breakpoints.sm;return t||r};e.prototype.toggle=function(){this.switch(this.mode==="dark"?"light":"dark")};e.prototype.validateModals=function(){if(typeof document!=="undefined"){setTimeout((function(){var e=Boolean(document.querySelector("x-overlay-container x-modal.modal-show"));if(e){document.querySelector("body").classList.add("modal-open")}else{document.querySelector("body").classList.remove("modal-open")}}),100)}};e.prototype.is=function(){var e=[];for(var t=0;t<arguments.length;t++){e[t]=arguments[t]}if(Array.isArray(e)){return e.includes(this.size)}return false};e.prototype.getTheme=function(){return this.mode};e.prototype.autodetectTheme=function(){this.switch(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")};e.prototype.setupSizes=function(e,t){this.width=e;this.height=t;this.size=this.getSizeByWidth(e);if(this.isMobile()){document.querySelector("body").classList.add("is-mobile")}else{document.querySelector("body").classList.remove("is-mobile")}};e.prototype.getSizeByWidth=function(e){if(e>=breakpoints.xl){return"xl"}if(e>=breakpoints.lg){return"lg"}if(e>=breakpoints.md){return"md"}if(e>=breakpoints.sm){return"sm"}return"xs"};e.prototype.switch=function(e){if(e=="dark"&&document){this.mode=e;document.querySelector("body").classList.add("is-dark-mode");Store.set(themeModeStorageKey,e)}if(e=="light"&&document){this.mode=e;document.querySelector("body").classList.remove("is-dark-mode");Store.set(themeModeStorageKey,e)}};e.create=function(){var t=new e;return Object.assign((function(e){return t.switch(e)}),{toggle:function(){return t.toggle()},validateModals:function(){return t.validateModals()},is:function(){var e=[];for(var r=0;r<arguments.length;r++){e[r]=arguments[r]}return t.is.apply(t,e)},isMobile:function(){return t.isMobile()},getTheme:function(){return t.getTheme()},autodetectTheme:function(){return t.autodetectTheme()},size:t.size})};return e}();var Theme=ThemeService.create();var Query=function(e,t){var r;return(r=(t||document).querySelector('[ref="'.concat(e,'"]')))!==null&&r!==void 0?r:(t||document).querySelector(e)};export{Query as Q,Store as S,Theme as T};