import { Host, h } from "@stencil/core";
import { cls } from "../../utils/helpers";
export class XTimeline {
    constructor() {
        /**
         * Element has not empty collapse slot
         */
        this.hasCollapseSlot = false;
        this.color = undefined;
        this.accent = undefined;
        this.time = undefined;
        this.meta = undefined;
    }
    /**
     * On component will be loaded hook
     */
    componentWillLoad() {
        this.hasCollapseSlot = !!this.el.querySelector('[slot="collapse"]');
    }
    parseTime(datetime) {
        const match = datetime.match(/(\d+:)/g);
        const minutes = parseInt(match[1]) || 0;
        const hours = parseInt(match[0]) || 0;
        const hour = hours === 0 ? 12 : hours;
        const clock = hours >= 12 ? 'PM' : 'AM';
        const formattedHours = hours > 12 ? hours - 12 : hour;
        return `${formattedHours}:${minutes.toString().padStart(2, '0')} <small>${clock}</small>`;
    }
    /**
     * Render element
     */
    render() {
        return h(Host, { key: 'ec86d9ef34a2a967fca524384364e2d9c8e39547', class: cls(`timeline-color-${this.color}`, { 'timeline-bullet-accent': this.accent }) }, this.time && h("div", { key: '6bee837029f2fc8e7ccc47bed5fdc25fc9135049', class: "timeline-item-time", innerHTML: this.parseTime(this.time) }), h("div", { key: '8e57bd60ad8d24a915f3fede9c12916df774015c', class: "timeline-item-bullet" }), h("div", { key: 'e26de1d67059227df9a4e5f0c234d302653a4b18', class: "timeline-item-body" }, this.hasCollapseSlot && h("x-collapse", { key: 'f979f606b09777220ed12e30873adf5b976e3703' }, h("div", { key: '3ce1519e23bd2b49c72fbcb5039d62246feb4211', class: "timeline-item-header", slot: "header" }, h("div", { key: 'b2aee9f204b80125e9ff0bfdcd76a02e5839ffbd', class: "timeline-item-text" }, h("slot", { key: 'f1f3a072da7aa047a5e77377fb7ccaf761bc1d9c' })), this.meta && h("div", { key: 'c8b78290b2dd58632ee68ceade9b6a5bdd56f3f1', class: "timeline-item-meta", innerHTML: this.meta })), h("div", { key: 'a25e3f4f46b30ae62e0093aae15978d97520ec06', class: "timeline-item-colapse" }, h("slot", { key: 'f7e0b5b7eb3ba2b69d8f727707625509720eb0d6', name: "collapse" }))), !this.hasCollapseSlot && h("div", { key: '2f06991b86fd0b993a6b9a47855682ac498d25c7', class: "timeline-item-header" }, h("div", { key: 'edeed6ee91a730692a14c2edf12b94c916ddb1d7', class: "timeline-item-text" }, h("slot", { key: 'ecfa26f32a4fab4c11814b4e99ed0ffcdbef7954' })), this.meta && h("div", { key: '62eb31421e25f8f5a31df3c68c435f05cc2e684a', class: "timeline-item-meta", innerHTML: this.meta }))));
    }
    static get is() { return "x-timeline-item"; }
    static get properties() {
        return {
            "color": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "ColorType",
                    "resolved": "\"accent\" | \"blue\" | \"cyan\" | \"danger\" | \"default\" | \"green\" | \"indigo\" | \"info\" | \"orange\" | \"pink\" | \"primary\" | \"purple\" | \"red\" | \"success\" | \"teal\" | \"warning\" | \"yellow\"",
                    "references": {
                        "ColorType": {
                            "location": "import",
                            "path": "../../constants/colors",
                            "id": "src/constants/colors.ts::ColorType"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Element color name"
                },
                "attribute": "color",
                "reflect": false
            },
            "accent": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Element accent checkpoint"
                },
                "attribute": "accent",
                "reflect": false
            },
            "time": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "time",
                "reflect": false
            },
            "meta": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "meta",
                "reflect": false
            }
        };
    }
    static get elementRef() { return "el"; }
}
