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"]');
    }
    /**
     * Parse the time value to visible format
     */
    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: '8c5a327be18074b5393c62866628e0cdf3017da5', class: cls(`timeline-color-${this.color}`, { 'timeline-bullet-accent': this.accent }) }, this.time && h("div", { key: '63726eea92046fe360f4bc6eef55ba237a3af8ec', class: "timeline-item-time", innerHTML: this.parseTime(this.time) }), h("div", { key: 'e2b2d3630d45daf27fc88812c5d897a8bd99f596', class: "timeline-item-bullet" }), h("div", { key: '23556febf82a042adf22197263b79e4a227d49f6', class: "timeline-item-body" }, this.hasCollapseSlot && h("x-collapse", { key: '83a529dd84df54e4ca365837d0f84a34b200e486' }, h("div", { key: '517cbd06932afd56d438decb501657760924f84e', class: "timeline-item-header", slot: "header" }, h("div", { key: 'd8e403404ff791b78d4b637ba129b477964be123', class: "timeline-item-text" }, h("slot", { key: 'ebe2cd52cd7c95b474213b44277263a196c7791b' })), this.meta && h("div", { key: 'ce2e4dd482e02d54196df4b9c2c09ed7f94ccb2e', class: "timeline-item-meta", innerHTML: this.meta })), h("div", { key: '71fc6b47122bb07aeea0b003b40b293cb28036af', class: "timeline-item-colapse" }, h("slot", { key: '677d6935644c6eb02d040176342e8a0c877afbe9', name: "collapse" }))), !this.hasCollapseSlot && h("div", { key: '9ce2f0691265bd12f1a6b43cca99ccd9ea97cd6d', class: "timeline-item-header" }, h("div", { key: 'f2ad1ce6f30765db8e2139ce38cd43aebdacaa0b', class: "timeline-item-text" }, h("slot", { key: '20db4b004f2d96d1d474c660906a1fa867679dac' })), this.meta && h("div", { key: '8685478a353840a448a1340eba24e6325a185bd3', 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\" | \"brown\" | \"cyan\" | \"danger\" | \"default\" | \"green\" | \"indigo\" | \"info\" | \"orange\" | \"pink\" | \"primary\" | \"purple\" | \"red\" | \"stone\" | \"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": "Element time format"
                },
                "attribute": "time",
                "reflect": false
            },
            "meta": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Element meta text showing right"
                },
                "attribute": "meta",
                "reflect": false
            }
        };
    }
    static get elementRef() { return "el"; }
}
