import { h } from "@stencil/core";
export class EclContentItem {
    constructor() {
        this.styleClass = '';
        this.imagePosition = 'left';
        this.imageSize = 'medium';
        this.imageZoom = false;
        this.divider = false;
    }
    componentWillLoad() {
        var _a;
        this.theme = (_a = document.documentElement.getAttribute('data-ecl-theme')) !== null && _a !== void 0 ? _a : (this.theme || 'ec');
    }
    componentDidRender() {
        const picture = this.el.getElementsByTagName('picture')[0];
        const date = this.el.getElementsByTagName('ecl-date-block')[0];
        const themeClass = `sc-ecl-content-item-${this.theme}`;
        if (picture) {
            picture.classList.add(`sc-ecl-content-item-${this.theme}`, 'ecl-content-item__picture', `ecl-content-item__picture--${this.imageSize}`, `ecl-content-item__picture--${this.imagePosition}`);
            if (this.imageZoom) {
                picture.classList.add('ecl-picture--zoom');
            }
            if (this.imagePosition === 'right') {
                picture.parentElement.style.order = '1';
            }
            const img = picture.getElementsByTagName('img')[0];
            if (img) {
                img.classList.add(`ecl-content-item__image`, themeClass);
            }
        }
        else if (date) {
            date.firstElementChild.classList.add('ecl-content-item__date', `sc-ecl-content-item-${this.theme}`);
            this.el.firstElementChild.classList.add('ecl-content-item--inline');
        }
        const block = this.el.querySelector('.ecl-content-block');
        if (block) {
            block.classList.add(`ecl-content-item__content-block`, themeClass);
        }
    }
    getClass() {
        const styleClasses = [
            `ecl-content-item`,
            this.styleClass
        ];
        if (this.colorMode) {
            styleClasses.push(`ecl-color-mode--${this.colorMode}`);
        }
        if (this.divider) {
            styleClasses.push('ecl-content-item--divider');
        }
        return styleClasses.join(' ');
    }
    render() {
        return (h("article", { key: '00d0d7a665747c5a5e57ecc3d126baa84e5ba02d', class: this.getClass() }, h("slot", { key: 'f3abd838342f206ad6d4dafcb06b01c2c722f522', name: "sidebar" }), h("slot", { key: '1f46720cba1172da24824dfba7f02f08dc298c0f', name: "content-block" })));
    }
    static get is() { return "ecl-content-item"; }
    static get encapsulation() { return "scoped"; }
    static get originalStyleUrls() {
        return {
            "ec": ["./build/styles/ecl-content-item-ec.css"],
            "eu": ["./build/styles/ecl-content-item-eu.css"]
        };
    }
    static get styleUrls() {
        return {
            "ec": ["build/styles/ecl-content-item-ec.css"],
            "eu": ["build/styles/ecl-content-item-eu.css"]
        };
    }
    static get properties() {
        return {
            "styleClass": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "style-class",
                "defaultValue": "''"
            },
            "theme": {
                "type": "string",
                "mutable": true,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "theme"
            },
            "imagePosition": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "image-position",
                "defaultValue": "'left'"
            },
            "imageSize": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "image-size",
                "defaultValue": "'medium'"
            },
            "imageZoom": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "image-zoom",
                "defaultValue": "false"
            },
            "divider": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "divider",
                "defaultValue": "false"
            },
            "colorMode": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "color-mode"
            }
        };
    }
    static get elementRef() { return "el"; }
}
