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 { InjectVegaSlimmer, MapToComponentField as MapToSlimmerField, VegaSlimmer } from 'vega-slimmer/core';
import { DefaultWrapper } from './body-positioned-wrapper/default-wrapper';
import { PositionRelativeToWrapper } from './body-positioned-wrapper/position-relative-to-wrapper';
import { VegaModalWrapper } from './body-positioned-wrapper/vega-modal-wrapper';
import { VegaPopoverWrapper } from './body-positioned-wrapper/vega-popover-wrapper';
import { ThirdPartyDialogWrapper } from './body-positioned-wrapper/third-party-dialog-wrapper';
/**
 * This class is responsible for setting the container element for appending an element based on certain conditions.
 *
 * @property {HTMLElement} container the container
 * @property {HTMLElement} showConfig the show config
 */
export class ElementAppenderContainerController extends VegaSlimmer {
  constructor() {
    super(...arguments);
    this.positionRelativeToWrapper = new PositionRelativeToWrapper();
    this.vegaPopoverWrapper = new VegaPopoverWrapper();
    this.vegaModalWrapper = new VegaModalWrapper();
    this.thirdPartyDialogWrapper = new ThirdPartyDialogWrapper();
    this.defaultWrapper = new DefaultWrapper();
  }
  /**
   * The function sets the container element by iterating through a list of retrievers, defaulting to the document body.
   */
  setContainer() {
    this.setContainerRetrievers();
    for (const retriever of this.containerRetrievers) {
      if (retriever.canRetrieve()) {
        this.container = retriever.retrieve();
        return;
      }
    }
  }
  /**
   * The function sets up an array of container retrievers based on certain conditions.
   */
  setContainerRetrievers() {
    this.containerRetrievers = [
      this.positionRelativeToWrapper,
      this.vegaPopoverWrapper,
      this.vegaModalWrapper,
      this.thirdPartyDialogWrapper,
      this.defaultWrapper,
    ];
  }
}
__decorate([
  MapToSlimmerField({ writable: true })
], ElementAppenderContainerController.prototype, "container", void 0);
__decorate([
  MapToSlimmerField({ writable: true })
], ElementAppenderContainerController.prototype, "showConfig", void 0);
__decorate([
  InjectVegaSlimmer()
], ElementAppenderContainerController.prototype, "positionRelativeToWrapper", void 0);
__decorate([
  InjectVegaSlimmer()
], ElementAppenderContainerController.prototype, "vegaPopoverWrapper", void 0);
__decorate([
  InjectVegaSlimmer()
], ElementAppenderContainerController.prototype, "vegaModalWrapper", void 0);
__decorate([
  InjectVegaSlimmer()
], ElementAppenderContainerController.prototype, "thirdPartyDialogWrapper", void 0);
__decorate([
  InjectVegaSlimmer()
], ElementAppenderContainerController.prototype, "defaultWrapper", void 0);
