import { h } from "@stencil/core";
import { themes } from "../../themes/themes";
export class SpwThemeProvider {
    constructor() {
        /** Définit le thème employé, conditionne les tokens associés au thème */
        this.theme = 'rouge';
    }
    componentWillLoad() {
        this.applyTheme(this.theme);
    }
    componentWillUpdate() {
        this.applyTheme(this.theme);
    }
    applyTheme(theme) {
        const styleId = 'theme-styles';
        let styleElement = document.getElementById(styleId);
        if (!styleElement) {
            styleElement = document.createElement('style');
            styleElement.id = styleId;
            document.head.appendChild(styleElement);
        }
        const css = themes[theme];
        styleElement.innerHTML = typeof css === 'function' ? css() : css;
        document.documentElement.setAttribute('data-theme', theme);
    }
    render() {
        return (h("main", { key: 'f5a89ddcd66778c2b01aeb9060259606826f56e3', class: `spw-theme-${this.theme}` }, h("slot", { key: 'ad8c44ad796c3cc358c3d0a4317730d858000c96' })));
    }
    static get is() { return "spw-theme-provider"; }
    static get properties() {
        return {
            "theme": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "SpwTheme",
                    "resolved": "\"bleu\" | \"bleuClair\" | \"gris\" | \"indigo\" | \"mauve\" | \"orange\" | \"rouge\" | \"turquoise\" | \"vert\" | \"vertLeger\"",
                    "references": {
                        "SpwTheme": {
                            "location": "import",
                            "path": "@themes/themes",
                            "id": "src/themes/themes.ts::SpwTheme",
                            "referenceLocation": "SpwTheme"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "D\u00E9finit le th\u00E8me employ\u00E9, conditionne les tokens associ\u00E9s au th\u00E8me"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "theme",
                "defaultValue": "'rouge'"
            }
        };
    }
    static get elementRef() { return "el"; }
}
