var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { MapToComponentField, MapToComponentMethod, VegaSlimmer } from 'vega-slimmer/core';
import changeManager from '../../../../../helpers/change-manager/change-manager';
import domNodeSubjectFactory from '../../../../../helpers/change-manager/subject/dom-node-subject/dom-node-subject-factory';
import { Observer } from '../../../../../helpers/change-manager/observer/observer';
import { VegaInternalDatePickerCalendarClear } from '../../../../../helpers/event-manager/event-id/vega-internal-event-id';
/**
 * Date picker calendar state base abstract class
 */
export class VegaDatePickerCalendarStateBaseAbstract extends VegaSlimmer {
  /** connectedCallback */
  connectedCallback() {
    this.initCalendarClearObserver();
  }
  /** disconnectedCallback */
  disconnectedCallback() {
    this.removeCalendarClearObserver();
  }
  /**
   * Initialize calendar clear observer
   */
  initCalendarClearObserver() {
    this.calendarClearObserver = new Observer(this.canAcceptClearEvent.bind(this), this.clear.bind(this));
    changeManager.register(domNodeSubjectFactory.getSubject(this.host, VegaInternalDatePickerCalendarClear), this.calendarClearObserver);
  }
  /**
   * Remove calendar clear observer
   */
  removeCalendarClearObserver() {
    changeManager.unregister(domNodeSubjectFactory.getSubject(this.host, VegaInternalDatePickerCalendarClear), this.calendarClearObserver);
  }
  /**
   * Check if can accept form reset event
   *
   * @returns {boolean} - true if can accept, false otherwise.
   */
  canAcceptClearEvent() {
    return true;
  }
}
__decorate([
  MapToComponentField()
], VegaDatePickerCalendarStateBaseAbstract.prototype, "host", void 0);
__decorate([
  MapToComponentMethod('connectedCallback')
], VegaDatePickerCalendarStateBaseAbstract.prototype, "connectedCallback", null);
__decorate([
  MapToComponentMethod('disconnectedCallback')
], VegaDatePickerCalendarStateBaseAbstract.prototype, "disconnectedCallback", null);
