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 } from 'vega-slimmer/core';
import { AutoRunWhenReRenderTaskQueueSlimmer } from '../../../../../helpers/slimmers/auto-run-when-re-render-task-queue-slimmer.abstract';
/**
 * The `VegaCalendarDayViewFocusSlimmer` class is a slimmer that focuses on the day view title element of a calendar component after the component has been re-rendered. It extends the `AutoRunWhenReRenderTaskQueueSlimmer` class, which allows it to schedule a task to be executed after the component has been updated.
 */
export class VegaCalendarDayViewFocusSlimmer extends AutoRunWhenReRenderTaskQueueSlimmer {
  /**
   * Schedule a task to focus on the day view title element after the component has been re-rendered.
   */
  scheduleFocus() {
    super.enqueueTheTaskIntoQueue();
  }
  /**
   * The `doTask` method is called after the component has been re-rendered. It focuses on the day view title element in the calendar component's shadow DOM.
   */
  async doTask() {
    await Promise.resolve(); // push behind componentDidUpdate's own microTasks
    if (this.host.shadowRoot) {
      const dayTitle = this.host.shadowRoot.querySelector('.calendar-view-day .calendar-view-title > div');
      if (dayTitle) {
        dayTitle.focus();
      }
    }
  }
}
__decorate([
  MapToComponentField()
], VegaCalendarDayViewFocusSlimmer.prototype, "host", void 0);
