import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
import { c as cls } from './helpers.js';
import { d as defineCustomElement$3 } from './component6.js';
import { d as defineCustomElement$2 } from './component2.js';

const XTimeline = /*@__PURE__*/ proxyCustomElement(class XTimeline extends HTMLElement {
    constructor() {
        super();
        this.__registerHost();
        /**
         * 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: '3e83b0dc0abd3c57de8518acc1f5ea94e716ff5c', class: cls(`timeline-color-${this.color}`, { 'timeline-bullet-accent': this.accent }) }, this.time && h("div", { key: '57f15db151a85a0c2dc14f1be5d298bd731a5a09', class: "timeline-item-time", innerHTML: this.parseTime(this.time) }), h("div", { key: '421dfe549aaf9559064c33a3ca11c0f1d583d0c7', class: "timeline-item-bullet" }), h("div", { key: 'b6dc73725a2ca5dd234913fb8969857d27107ce6', class: "timeline-item-body" }, this.hasCollapseSlot && h("x-collapse", { key: '22c930c236c4f5d1d602f35a3ffa7dba8d18518e' }, h("div", { key: '864b48d38bf3611a7c94d319104fe5570162bb8d', class: "timeline-item-header", slot: "header" }, h("div", { key: 'f8940c7fb8243b39a111403842ef3c848a424471', class: "timeline-item-text" }, h("slot", { key: '3893adcbaed6a8644fadf956d23e75590690a598' })), this.meta && h("div", { key: '89fa1adc7cf690b050132670f72a2b3e45670c07', class: "timeline-item-meta", innerHTML: this.meta })), h("div", { key: 'c52a0e9ee96eb9c6f3c51e5f020dfa609e2e441f', class: "timeline-item-colapse" }, h("slot", { key: 'c38f5aba42930c50f5ed563c3093f02c8d6a535c', name: "collapse" }))), !this.hasCollapseSlot && h("div", { key: '0e16653efa4dea214000ab1eef93f60943afccb7', class: "timeline-item-header" }, h("div", { key: '99e792a525e2818fa5fbd7172f2d5bcfb1433998', class: "timeline-item-text" }, h("slot", { key: 'd8fd1f6e9ac38fe505d67b1e8c06e404357d3dba' })), this.meta && h("div", { key: '5eecdd9328deffafccaa6c3661eda786905726a2', class: "timeline-item-meta", innerHTML: this.meta }))));
    }
    get el() { return this; }
}, [4, "x-timeline-item", {
        "color": [1],
        "accent": [4],
        "time": [1],
        "meta": [1]
    }]);
function defineCustomElement$1() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["x-timeline-item", "x-collapse", "x-icon"];
    components.forEach(tagName => { switch (tagName) {
        case "x-timeline-item":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, XTimeline);
            }
            break;
        case "x-collapse":
            if (!customElements.get(tagName)) {
                defineCustomElement$3();
            }
            break;
        case "x-icon":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
    } });
}

const XTimelineItem = XTimeline;
const defineCustomElement = defineCustomElement$1;

export { XTimelineItem, defineCustomElement };
