'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-d0a4f2de.js');

const gascoCalendarCss = ":host(.gasco-calendar){position:relative;max-width:350px;width:100%}.native-calendar{max-width:inherit;width:100%}:host(.gasco-calendar) gasco-datetime{position:absolute;left:0;right:0;top:55px;box-shadow:0px 4px 4px var(--gasco-color-medium, #999999);border-radius:0 0 15px 15px;max-width:340px;margin-inline:5px;z-index:9999}";

const GascoCalendar = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.gascoChangeValue = index.createEvent(this, "gascoChangeValue", 7);
    this.gascoBlur = index.createEvent(this, "gascoBlur", 7);
    this.gascoFocus = index.createEvent(this, "gascoFocus", 7);
    this.fireFocusEvents = true;
    this.hasFocus = false;
    this.showCalendar = false;
    this.inputValue = '';
    this.onFocus = (ev) => {
      this.hasFocus = true;
      if (!this.showCalendar) {
        this.showCalendar = true;
      }
      if (this.fireFocusEvents) {
        this.gascoFocus.emit(ev);
      }
    };
    this.onBlur = (ev) => {
      this.hasFocus = false;
      if (this.showCalendar) {
        this.showCalendar = false;
      }
      if (this.fireFocusEvents) {
        this.gascoBlur.emit(ev);
      }
    };
  }
  handleDatetimeReady(ev) {
    const { month, day, year } = ev.detail;
    const value = `${day}/${month}/${year}`;
    this.inputValue = value;
    this.gascoChangeValue.emit({ value });
  }
  render() {
    const { onFocus, onBlur, showCalendar, inputValue } = this;
    return (index.h(index.Host, { onBlur: onBlur, onFocus: onFocus, class: {
        ['gasco-color']: true,
        ['gasco-calendar']: true,
        ['gasco-color-primary']: true,
        'has-focus': this.hasFocus,
      } }, index.h("div", { class: "native-calendar", part: "native" }, index.h("gasco-input", { class: "input-datetime", value: inputValue, readonly: true }, index.h("ion-icon", { name: "calendar-number-outline", slot: "end" })), showCalendar && index.h("gasco-datetime", { size: "cover" }))));
  }
};
GascoCalendar.style = gascoCalendarCss;

exports.gasco_calendar = GascoCalendar;
