import { _ as _applyDecoratedDescriptor, b as _defineProperty } from '../_rollupPluginBabelHelpers-9wjJaosZ.js';
import { setComponentTemplate } from '@ember/component';
import { precompileTemplate } from '@ember/template-compilation';
import Component from '@glimmer/component';
import { fn } from '@ember/helper';
import { action } from '@ember/object';
import didInsert from '@ember/render-modifiers/modifiers/did-insert';
import willDestroy from '@ember/render-modifiers/modifiers/will-destroy';

var _class;
let EuiTooltipPopover = setComponentTemplate(precompileTemplate(`
    <div
      class="euiToolTipPopover"
      {{didInsert this.setPopoverRef}}
      {{willDestroy (fn this.setPopoverRef null)}}
      ...attributes
    >
      {{#if @hasTitle}}
        <div class="euiToolTip__title">
          {{yield to="title"}}
        </div>
      {{/if}}
      {{yield to="content"}}
    </div>
  `, {
  strictMode: true,
  scope: () => ({
    didInsert,
    willDestroy,
    fn
  })
}), (_class = class EuiTooltipPopover extends Component {
  constructor(owner, args) {
    super(owner, args);
    _defineProperty(this, "popover", null);
    document.body.classList.add('euiBody-hasPortalContent');
    window.addEventListener('resize', this.updateDimensions);
    window.addEventListener('scroll', this.updateDimensions, true);
  }
  willDestroy() {
    super.willDestroy();
    document.body.classList.remove('euiBody-hasPortalContent');
    window.removeEventListener('resize', this.updateDimensions);
    window.removeEventListener('scroll', this.updateDimensions, true);
  }
  setPopoverRef(popover) {
    this.popover = popover;
    if (this.args.popoverRef) {
      this.args.popoverRef(popover);
    }
  }
  updateDimensions() {
    requestAnimationFrame(() => {
      // Because of this delay, sometimes `positionToolTip` becomes unavailable.
      if (this.popover) {
        this.args.positionToolTip();
      }
    });
  }
}, (_applyDecoratedDescriptor(_class.prototype, "setPopoverRef", [action], Object.getOwnPropertyDescriptor(_class.prototype, "setPopoverRef"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "updateDimensions", [action], Object.getOwnPropertyDescriptor(_class.prototype, "updateDimensions"), _class.prototype)), _class));

export { EuiTooltipPopover as default };
//# sourceMappingURL=eui-tool-tip-popover.js.map
