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 { findParent } from '../../../../utils/ui';
import { BodyPositionedWrapper } from './body-positioned-wrapper.abstract';
import { MapToComponentField as MapToSlimmerField } from 'vega-slimmer/core';
/**
 * This class is used to get the class `vega-popover` as a container and store the element appender element.
 *
 * @property {HTMLElement} showConfig the show config
 */
export class VegaPopoverWrapper extends BodyPositionedWrapper {
  /**
   * The canRetrieve function just determine whether the target of showConfig has the class `vega-popover`. If not, search upwards layer by layer.
   *
   * @returns {boolean} the boolean type.
   */
  canRetrieve() {
    return super.canRetrieve() && !!findParent(this.showConfig.target, '.vega-popover');
  }
  /**
   * The retrieve function get the element that if the target of showConfig does not have the class vega-popover, search upwards layer by layer until this element is found.
   *
   * @returns {HTMLElement} the element.
   */
  retrieve() {
    const container = findParent(this.showConfig.target, '.vega-popover');
    container.append(this.showConfig.appendableElement);
    return container;
  }
}
__decorate([
  MapToSlimmerField()
], VegaPopoverWrapper.prototype, "showConfig", void 0);
