import { h, getAssetPath } from '@stencil/core';
export class EclTimeline {
  constructor() {
    this.theme = 'ec';
    this.styleClass = undefined;
    this.eclScript = false;
  }
  getClass() {
    const styleClasses = [
      `ecl-timeline`,
      this.styleClass
    ];
    return styleClasses.join(' ');
  }
  componentDidRender() {
    const items = this.el.querySelectorAll('.ecl-timeline__item');
    this.el.querySelector('.ecl-timeline').innerHTML = '';
    this.el.querySelector('.ecl-timeline').append(...items);
    if (this.eclScript) {
      // Load the ECL vanilla js if not already present.
      const src = getAssetPath('./build/scripts/ecl-timeline-vanilla.js');
      if (document.querySelector(`script[src="${src}"]`)) {
        document.querySelector(`script[src="${src}"]`).remove();
      }
      const script = document.createElement('script');
      script.src = src;
      script.onload = () => {
        const timeline = new ECL.Timeline(this.el.firstElementChild);
        timeline.init();
      };
      document.body.appendChild(script);
    }
  }
  render() {
    return (h("ol", { class: this.getClass(), "data-ecl-timeline": true }, h("slot", null)));
  }
  static get is() { return "ecl-timeline"; }
  static get originalStyleUrls() {
    return {
      "ec": ["./build/styles/ecl-timeline-ec.css"],
      "eu": ["./build/styles/ecl-timeline-eu.css"]
    };
  }
  static get styleUrls() {
    return {
      "ec": ["./build/styles/ecl-timeline-ec.css"],
      "eu": ["./build/styles/ecl-timeline-eu.css"]
    };
  }
  static get assetsDirs() { return ["build"]; }
  static get properties() {
    return {
      "theme": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "theme",
        "reflect": false,
        "defaultValue": "'ec'"
      },
      "styleClass": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "style-class",
        "reflect": false
      },
      "eclScript": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "ecl-script",
        "reflect": false,
        "defaultValue": "false"
      }
    };
  }
  static get elementRef() { return "el"; }
}
//# sourceMappingURL=ecl-timeline.js.map
