import{r as o,c as t,h as r,H as e}from"./p-8e4e97b4.js";import{N as s,O as i,W as a,c,g as h}from"./p-8242c24f.js";const n=class{constructor(r){o(this,r);this.brandChange=t(this,"brandChange",7);this.icThemeChange=t(this,"icThemeChange",7);this.themeClass="";this.brandColor=null;this.theme="light";this.darkModeChangeHandler=()=>{if(this.theme==="system"){this.themeClass=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"ic-theme-dark":"ic-theme-light"}else{this.themeClass=`ic-theme-${this.theme}`}this.icThemeChange.emit(this.theme)};this.checkBrandColorContrast=()=>{if(s()<i&&s()>a){console.warn(`The brand colour does not provide enough contrast with either of the ICDS black or white foreground colours. Consider choosing a colour with a different brightness to achieve sufficient colour contrast for good visibility. See https://www.w3.org/TR/AERT/#color-contrast for more information about colour contrast.`)}};this.setBrandColor=()=>{const o=this.brandColor?c(this.brandColor):null;if(o){const{r:t,g:r,b:e,a:s}=o;const{style:i}=document.documentElement;i.setProperty("--ic-brand-color-primary-r",`${t}`);i.setProperty("--ic-brand-color-primary-g",`${r}`);i.setProperty("--ic-brand-color-primary-b",`${e}`);i.setProperty("--ic-brand-color-primary-a",`${s}`);this.checkBrandColorContrast();this.brandChange.emit({mode:h(),color:o})}}}watchBrandColorPropHandler(){this.setBrandColor()}watchThemePropHandler(){this.darkModeChangeHandler()}componentWillLoad(){this.darkModeChangeHandler();this.setBrandColor();window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",this.darkModeChangeHandler)}render(){const{themeClass:o}=this;return r(e,{key:"d994b33e982d89fdb62837456a5a1c90471d0a6a",class:o},r("slot",{key:"cc67f5ec282adfe4695a7ecf9134fba920a71a7e"}))}static get watchers(){return{brandColor:["watchBrandColorPropHandler"],theme:["watchThemePropHandler"]}}};export{n as ic_theme};
//# sourceMappingURL=p-b8da5c07.entry.js.map