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: 'b1110e1043038c50f0700437e367c1ae3ed09e0e', class: cls(`timeline-color-${this.color}`, { 'timeline-bullet-accent': this.accent }) }, this.time && h("div", { key: '0cec286cfe8a8350099e2844f0ba05336423dba4', class: "timeline-item-time", innerHTML: this.parseTime(this.time) }), h("div", { key: 'f28653bb400ad57333e1240b1e8f0ea44e2bd2a9', class: "timeline-item-bullet" }), h("div", { key: '7f2bf8ced9a16102ff131ff162aff790767b1492', class: "timeline-item-body" }, this.hasCollapseSlot && h("x-collapse", { key: 'e4448f76e8488e741ff5c1a2f297e22413a53355' }, h("div", { key: 'd74b5610b6102651a1b4bb8caceb85a31804fcb5', class: "timeline-item-header", slot: "header" }, h("div", { key: 'd481262c02393a08557f0ab4fa42cd757bd52758', class: "timeline-item-text" }, h("slot", { key: '76b1fee9bc6e98995b320185fd0cd9ddbc1f4920' })), this.meta && h("div", { key: '4f4c688e0b5e67861c340e104d4fb2f2a192c912', class: "timeline-item-meta", innerHTML: this.meta })), h("div", { key: 'f80197f3093c2ca8ae494442474936683c2df946', class: "timeline-item-colapse" }, h("slot", { key: '2a9f654eff84445118100153a83333f657b321ea', name: "collapse" }))), !this.hasCollapseSlot && h("div", { key: 'af082499e1513bcf5b7cb823fd8d17ae9062f564', class: "timeline-item-header" }, h("div", { key: 'dcd611d47042c76e06592a1683466f3417618eb9', class: "timeline-item-text" }, h("slot", { key: 'fb0bcdd5c8984d94cc9c03e5e6e871e63d29c7b7' })), this.meta && h("div", { key: '9ee100a4ffa596ed26dd4993e99c9f62b44c576d', 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"; }
}
