-
Notifications
You must be signed in to change notification settings - Fork 1
/
chunk-GIEOXITA.js
1 lines (1 loc) · 1.34 KB
/
chunk-GIEOXITA.js
1
import{u as d}from"./chunk-LRGM5MED.js";import{Gc as i,La as c,Qc as n,aa as h,ga as r,hb as m,k as a}from"./chunk-DXS2GHCC.js";var l="themePreference",f="docs-dark-mode",u="docs-light-mode",E="(prefers-color-scheme: dark)",I=(()=>{let o=class o{constructor(){this.document=r(i),this.localStorage=r(d),this.platformId=r(c),this.theme=m(this.getThemeFromLocalStorageValue()),this.themeChanged$=new a,n(this.platformId)&&(this.loadThemePreference(),this.watchPreferredColorScheme())}setTheme(t){this.theme.set(t),this.setThemeInLocalStorage(),this.setThemeBodyClasses(t==="auto"?S():t)}loadThemePreference(){let e=this.getThemeFromLocalStorageValue()??"auto";this.theme.set(e),this.setThemeBodyClasses(e==="auto"?S():e)}setThemeBodyClasses(t){let e=this.document.documentElement.classList;t==="dark"?(e.add(f),e.remove(u)):(e.add(u),e.remove(f)),this.themeChanged$.next()}getThemeFromLocalStorageValue(){return this.localStorage?.getItem(l)??null}setThemeInLocalStorage(){this.theme()&&this.localStorage?.setItem(l,this.theme())}watchPreferredColorScheme(){window.matchMedia(E).addEventListener("change",t=>{let e=t.matches?"dark":"light";this.setThemeBodyClasses(e)})}};o.\u0275fac=function(e){return new(e||o)},o.\u0275prov=h({token:o,factory:o.\u0275fac,providedIn:"root"});let s=o;return s})();function S(){return window.matchMedia(E).matches?"dark":"light"}export{I as a};