{"version":3,"file":"popover.cjs","sources":["../../../components/popover/popover.vue"],"sourcesContent":["<!-- eslint-disable vuejs-accessibility/mouse-events-have-key-events -->\n<template>\n  <div>\n    <portal v-if=\"modal && isOpen\">\n      <div\n        class=\"d-modal--transparent\"\n        @click.prevent.stop\n      />\n    </portal>\n    <component\n      :is=\"elementType\"\n      ref=\"popover\"\n      :class=\"['d-popover', { 'd-popover__anchor--opened': isOpen }]\"\n      data-qa=\"dt-popover-container\"\n      v-on=\"$listeners\"\n    >\n      <!-- eslint-disable-next-line vuejs-accessibility/no-static-element-interactions -->\n      <div\n        :id=\"!ariaLabelledby && labelledBy\"\n        ref=\"anchor\"\n        :data-qa=\"$attrs['data-qa'] ? `${$attrs['data-qa']}-anchor` : 'dt-popover-anchor'\"\n        :tabindex=\"openOnContext ? 0 : undefined\"\n        @click.capture=\"defaultToggleOpen\"\n        @contextmenu=\"onContext\"\n        @keydown.up.prevent=\"onArrowKeyPress\"\n        @keydown.down.prevent=\"onArrowKeyPress\"\n        @keydown.escape.capture=\"closePopover\"\n        @mouseenter=\"onMouseEnter\"\n        @mouseleave=\"onMouseLeave\"\n      >\n        <!-- @slot Anchor element that activates the popover. Usually a button. -->\n        <slot\n          name=\"anchor\"\n          :attrs=\"{\n            'aria-expanded': isOpen.toString(),\n            'aria-controls': id,\n            'aria-haspopup': role,\n          }\"\n        />\n      </div>\n      <dt-lazy-show\n        :id=\"id\"\n        ref=\"content\"\n        :role=\"role\"\n        :data-qa=\"$attrs['data-qa'] ? `${$attrs['data-qa']}__dialog` : 'dt-popover'\"\n        :aria-hidden=\"`${!isOpen}`\"\n        :aria-labelledby=\"labelledBy\"\n        :aria-label=\"ariaLabel\"\n        :aria-modal=\"`${!modal}`\"\n        :transition=\"transition\"\n        :show=\"isOpen\"\n        :class=\"['d-popover__dialog', { 'd-popover__dialog--modal': modal }, dialogClass]\"\n        :style=\"{\n          'max-height': calculatedMaxHeight,\n          'max-width': maxWidth,\n        }\"\n        :tabindex=\"contentTabindex\"\n        appear\n        v-on=\"popoverListeners\"\n        @mouseenter=\"onMouseEnterAnchor\"\n        @mouseleave=\"onMouseLeaveAnchor\"\n      >\n        <popover-header-footer\n          v-if=\"$slots.headerContent || showCloseButton\"\n          ref=\"popover__header\"\n          :class=\"POPOVER_HEADER_FOOTER_PADDING_CLASSES[padding]\"\n          :content-class=\"headerClass\"\n          type=\"header\"\n          :show-close-button=\"showCloseButton\"\n          @close=\"closePopover\"\n        >\n          <template #content>\n            <!-- @slot Slot for popover header content -->\n            <slot\n              name=\"headerContent\"\n              :close=\"closePopover\"\n            />\n          </template>\n        </popover-header-footer>\n        <div\n          ref=\"popover__content\"\n          :data-qa=\"$attrs['data-qa'] ? `${$attrs['data-qa']}-content` : 'dt-popover-content'\"\n          :class=\"[\n            'd-popover__content',\n            POPOVER_PADDING_CLASSES[padding],\n            contentClass,\n          ]\"\n        >\n          <!-- @slot Slot for the content that is displayed in the popover when it is open. -->\n          <slot\n            name=\"content\"\n            :close=\"closePopover\"\n          />\n        </div>\n        <popover-header-footer\n          v-if=\"hasFooter()\"\n          ref=\"popover__footer\"\n          type=\"footer\"\n          :class=\"POPOVER_HEADER_FOOTER_PADDING_CLASSES[padding]\"\n          :content-class=\"footerClass\"\n        >\n          <template #content>\n            <!-- @slot Slot for the footer content. -->\n            <slot\n              name=\"footerContent\"\n              :close=\"closePopover\"\n            />\n          </template>\n        </popover-header-footer>\n        <sr-only-close-button\n          v-if=\"!showCloseButton\"\n          @close=\"closePopover\"\n        />\n      </dt-lazy-show>\n    </component>\n  </div>\n</template>\n\n<script>\n/* eslint-disable max-lines */\nimport {\n  POPOVER_APPEND_TO_VALUES,\n  POPOVER_CONTENT_WIDTHS,\n  POPOVER_HEADER_FOOTER_PADDING_CLASSES,\n  POPOVER_INITIAL_FOCUS_STRINGS,\n  POPOVER_PADDING_CLASSES,\n  POPOVER_ROLES,\n  POPOVER_STICKY_VALUES,\n} from './popover_constants';\nimport { getUniqueString, isOutOfViewPort, warnIfUnmounted, disableRootScrolling, enableRootScrolling } from '@/common/utils';\nimport { DtLazyShow } from '@/components/lazy_show';\nimport { Portal } from '@linusborg/vue-simple-portal';\nimport ModalMixin from '@/common/mixins/modal';\nimport { createTippyPopover, getPopperOptions } from './tippy_utils';\nimport PopoverHeaderFooter from './popover_header_footer.vue';\nimport SrOnlyCloseButton from '@/common/sr_only_close_button.vue';\n\n/**\n * A Popover displays a content overlay when its anchor element is activated.\n * @see https://dialtone.dialpad.com/components/popover.html\n */\nexport default {\n  name: 'DtPopover',\n\n  /********************\n   * CHILD COMPONENTS *\n   ********************/\n  components: {\n    SrOnlyCloseButton,\n    DtLazyShow,\n    PopoverHeaderFooter,\n    Portal,\n  },\n\n  mixins: [ModalMixin],\n\n  props: {\n    /**\n     * Controls whether the popover is shown. Leaving this null will have the popover trigger on click by default.\n     * If you set this value, the default trigger behavior will be disabled, and you can control it as you need.\n     * Supports .sync modifier\n     * @values null, true, false\n     */\n    open: {\n      type: Boolean,\n      default: null,\n    },\n\n    /**\n     * Opens the popover on right click (context menu). If you set this value to `true`,\n     * the default trigger behavior will be disabled.\n     * @values true, false\n     */\n    openOnContext: {\n      type: Boolean,\n      default: false,\n    },\n\n    /**\n     * Element type (tag name) of the root element of the component.\n     */\n    elementType: {\n      type: String,\n      default: 'div',\n    },\n\n    /**\n     * Named transition when the content display is toggled.\n     * @see DtLazyShow\n     */\n    transition: {\n      type: String,\n      default: 'fade',\n    },\n\n    /**\n     * ARIA role for the content of the popover. Defaults to \"dialog\".\n     * <a class=\"d-link\" href=\"https://www.w3.org/TR/wai-aria/#aria-haspopup\" target=\"_blank\">aria-haspopup</a>\n     */\n    role: {\n      type: String,\n      default: 'dialog',\n      validator: (role) => {\n        return POPOVER_ROLES.includes(role);\n      },\n    },\n\n    /**\n     * ID of the element that serves as the label for the popover content.\n     * Defaults to the \"anchor\" element; this exists to provide a different\n     * ID of the label element if, for example, the anchor slot contains\n     * other items that do not serve as a label. You should provide this\n     * or ariaLabel, but not both.\n     */\n    ariaLabelledby: {\n      type: String,\n      default: null,\n    },\n\n    /**\n     * Descriptive label for the popover content. You should provide this\n     * or ariaLabelledby, but not both.\n     */\n    ariaLabel: {\n      type: String,\n      default: null,\n    },\n\n    /**\n     * Padding size class for the popover content.\n     * @values none, small, medium, large\n     */\n    padding: {\n      type: String,\n      default: 'large',\n      validator: (padding) => {\n        return Object.keys(POPOVER_PADDING_CLASSES).some((item) => item === padding);\n      },\n    },\n\n    /**\n     * Additional class name for the content wrapper element.\n     */\n    contentClass: {\n      type: [String, Array, Object],\n      default: '',\n    },\n\n    /**\n     * Width configuration for the popover content. When its value is 'anchor',\n     * the popover content will have the same width as the anchor.\n     * @values null, anchor\n     */\n    contentWidth: {\n      type: String,\n      default: '',\n      validator: contentWidth => POPOVER_CONTENT_WIDTHS.includes(contentWidth),\n    },\n\n    /**\n     * Tabindex value for the content. Passing null, no tabindex attribute will be set.\n     */\n    contentTabindex: {\n      type: Number || null,\n      default: -1,\n    },\n\n    /**\n     * External anchor id to use in those cases the anchor can't be provided via the slot.\n     * For instance, using the combobox's input as the anchor for the popover.\n     */\n    externalAnchor: {\n      type: String,\n      default: '',\n    },\n\n    /**\n     * The id of the tooltip\n     */\n    id: {\n      type: String,\n      default () { return getUniqueString(); },\n    },\n\n    /**\n     *  Displaces the content box from its anchor element\n     *  by the specified number of pixels.\n     *  <a\n     *    class=\"d-link\"\n     *    href=\"https://atomiks.github.io/tippyjs/v6/all-props/#offset\"\n     *    target=\"_blank\"\n     *  >\n     *    Tippy.js docs\n     *  </a>\n     */\n    offset: {\n      type: Array,\n      default: () => [0, 4],\n    },\n\n    /**\n     * Determines if the popover hides upon clicking the\n     * anchor or outside the content box.\n     * @values true, false\n     */\n    hideOnClick: {\n      type: Boolean,\n      default: true,\n    },\n\n    /**\n     * Determines modal state. If enabled popover has a modal overlay\n     * preventing interaction with elements below it, but it is invisible.\n     * @values true, false\n     */\n    modal: {\n      type: Boolean,\n      default: true,\n    },\n\n    /**\n     * If the popover does not fit in the direction described by \"placement\",\n     * it will attempt to change its direction to the \"fallbackPlacements\".\n     * <a\n     *   class=\"d-link\"\n     *   href=\"https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements\"\n     *   target=\"_blank\"\n     * >\n     *   Popper.js docs\n     * </a>\n     * */\n    fallbackPlacements: {\n      type: Array,\n      default: () => {\n        return ['auto'];\n      },\n    },\n\n    /**\n     * The direction the popover displays relative to the anchor.\n     * <a\n     *   class=\"d-link\"\n     *   href=\"https://atomiks.github.io/tippyjs/v6/all-props/#placement\"\n     *   target=\"_blank\"\n     * >\n     *   Tippy.js docs\n     * </a>\n     * @values top, top-start, top-end,\n     * right, right-start, right-end,\n     * left, left-start, left-end,\n     * bottom, bottom-start, bottom-end,\n     * auto, auto-start, auto-end\n     */\n    placement: {\n      type: String,\n      default: 'bottom-end',\n    },\n\n    /**\n     * If set to false the dialog will display over top of the anchor when there is insufficient space.\n     * If set to true it will never move from its position relative to the anchor and will clip instead.\n     * <a\n     *   class=\"d-link\"\n     *   href=\"https://popper.js.org/docs/v2/modifiers/prevent-overflow/#tether\"\n     *   target=\"_blank\"\n     * >\n     *   Popper.js docs\n     * </a>\n     * @values true, false\n     */\n    tether: {\n      type: Boolean,\n      default: true,\n    },\n\n    /**\n     * If the popover sticks to the anchor. This is usually not needed, but can be needed\n     * if the reference element's position is animating, or to automatically update the popover\n     * position in those cases the DOM layout changes the reference element's position.\n     * `true` enables it, `reference` only checks the \"reference\" rect for changes and `popper` only\n     * checks the \"popper\" rect for changes.\n     * <a\n     *   class=\"d-link\"\n     *   href=\"https://atomiks.github.io/tippyjs/v6/all-props/#sticky\"\n     *   target=\"_blank\"\n     * >\n     *   Tippy.js docs\n     * </a>\n     * @values true, false, reference, popper\n     */\n    sticky: {\n      type: [Boolean, String],\n      default: false,\n      validator: (sticky) => {\n        return POPOVER_STICKY_VALUES.includes(sticky);\n      },\n    },\n\n    /**\n     * Determines maximum height for the popover before overflow.\n     * Possible units rem|px|em\n     */\n    maxHeight: {\n      type: String,\n      default: '',\n    },\n\n    /**\n     * Determines maximum width for the popover before overflow.\n     * Possible units rem|px|%|em\n     */\n    maxWidth: {\n      type: String,\n      default: '',\n    },\n\n    /**\n     * Determines visibility for close button\n     * @values true, false\n     */\n    showCloseButton: {\n      type: Boolean,\n      default: false,\n    },\n\n    /**\n     * Additional class name for the header content wrapper element.\n     */\n    headerClass: {\n      type: [String, Array, Object],\n      default: '',\n    },\n\n    /**\n     * Additional class name for the footer content wrapper element.\n     */\n    footerClass: {\n      type: [String, Array, Object],\n      default: '',\n    },\n\n    /**\n     * Additional class name for the dialog element.\n     */\n    dialogClass: {\n      type: [String, Array, Object],\n      default: '',\n    },\n\n    /**\n     * The element that is focused when the popover is opened. This can be an\n     * HTMLElement within the popover, a string starting with '#' which will\n     * find the element by ID. 'first' which will automatically focus\n     * the first element, or 'dialog' which will focus the dialog window itself.\n     * If the dialog is modal this prop cannot be 'none'.\n     * @values none, dialog, first\n     */\n    initialFocusElement: {\n      type: [String, HTMLElement],\n      default: 'first',\n      validator: initialFocusElement => {\n        return POPOVER_INITIAL_FOCUS_STRINGS.includes(initialFocusElement) ||\n          (initialFocusElement instanceof HTMLElement) ||\n          initialFocusElement.startsWith('#');\n      },\n    },\n\n    /**\n     * If the popover should open pressing up or down arrow key on the anchor element.\n     * This can be set when not passing open prop.\n     * @values true, false\n     */\n    openWithArrowKeys: {\n      type: Boolean,\n      default: false,\n    },\n\n    /**\n     * Sets the element to which the popover is going to append to.\n     * 'body' will append to the nearest body (supports shadow DOM).\n     * 'root' will try append to the iFrame's parent body if it is contained in an iFrame\n     * and has permissions to access it, else, it'd default to 'parent'.\n     * @values 'body', 'parent', 'root', HTMLElement\n     */\n    appendTo: {\n      type: [HTMLElement, String],\n      default: 'body',\n      validator: appendTo => {\n        return POPOVER_APPEND_TO_VALUES.includes(appendTo) ||\n            (appendTo instanceof HTMLElement);\n      },\n    },\n  },\n\n  emits: [\n    /**\n     * Emitted when popover is shown or hidden\n     *\n     * @event opened\n     * @type {Boolean | Array}\n     */\n    'opened',\n\n    /**\n     * Emitted to sync value with parent\n     *\n     * @event update:opened\n     * @type {Boolean | Array}\n     */\n    'update:open',\n\n    /**\n     * Emitted when the mouse enters the popover\n     *\n     * @event mouseenter-popover\n     */\n    'mouseenter-popover',\n\n    /**\n     * Emitted when the mouse leaves the popover\n     *\n     * @event mouseleave-popover\n     */\n    'mouseleave-popover',\n\n    /**\n     * Emitted when the mouse enters the popover anchor\n     *\n     * @event mouseenter-popover-anchor\n     */\n    'mouseenter-popover-anchor',\n\n    /**\n     * Emitted when the mouse leaves the popover anchor\n     *\n     * @event mouseleave-popover-anchor\n     */\n    'mouseleave-popover-anchor',\n  ],\n\n  data () {\n    return {\n      POPOVER_PADDING_CLASSES,\n      POPOVER_HEADER_FOOTER_PADDING_CLASSES,\n      intersectionObserver: null,\n      isOutsideViewport: false,\n      isOpen: false,\n      anchorEl: null,\n      popoverContentEl: null,\n    };\n  },\n\n  computed: {\n    popoverListeners () {\n      return {\n        ...this.$listeners,\n\n        keydown: event => {\n          this.onKeydown(event);\n          this.$emit('keydown', event);\n        },\n\n        'after-leave': () => {\n          this.onLeaveTransitionComplete();\n        },\n\n        'after-enter': () => {\n          this.onEnterTransitionComplete();\n        },\n      };\n    },\n\n    calculatedMaxHeight () {\n      if (this.isOutsideViewport && this.modal) {\n        return `calc(100vh - var(--dt-space-300))`;\n      }\n      return this.maxHeight;\n    },\n\n    labelledBy () {\n      // aria-labelledby should be set only if aria-labelledby is passed as a prop, or if\n      // there is no aria-label and the labelledby should point to the anchor.\n      return this.ariaLabelledby || (!this.ariaLabel && getUniqueString('DtPopover__anchor'));\n    },\n  },\n\n  watch: {\n    $props: {\n      immediate: true,\n      deep: true,\n      handler () {\n        this.validateProps();\n      },\n    },\n\n    modal (modal) {\n      this.tip?.setProps({\n        zIndex: modal ? 650 : this.calculateAnchorZindex(),\n      });\n    },\n\n    offset (offset) {\n      this.tip?.setProps({\n        offset,\n      });\n    },\n\n    sticky (sticky) {\n      this.tip?.setProps({\n        sticky,\n      });\n    },\n\n    fallbackPlacements () {\n      this.tip?.setProps({\n        popperOptions: this.popperOptions(),\n      });\n    },\n\n    tether () {\n      this.tip?.setProps({\n        popperOptions: this.popperOptions(),\n      });\n    },\n\n    placement (placement) {\n      this.tip?.setProps({\n        placement,\n      });\n    },\n\n    open: {\n      handler: function (open) {\n        if (open !== null) {\n          this.isOpen = open;\n        }\n      },\n\n      immediate: true,\n    },\n\n    isOpen (isOpen, isPrev) {\n      if (isOpen) {\n        this.initTippyInstance();\n        this.tip.show();\n      } else if (!isOpen && isPrev !== isOpen) {\n        this.removeEventListeners();\n        this.tip.hide();\n      }\n    },\n  },\n\n  mounted () {\n    warnIfUnmounted(this.$el, this.$options.name);\n\n    const externalAnchorEl = this.externalAnchor\n      ? this.$refs.anchor.getRootNode().querySelector(`#${this.externalAnchor}`)\n      : null;\n    this.anchorEl = externalAnchorEl ?? this.$refs.anchor.children[0];\n    this.popoverContentEl = this.$refs.content?.$el;\n\n    if (this.isOpen) {\n      this.initTippyInstance();\n      this.tip.show();\n    }\n\n    // rootMargin here must be greater than the margin of the height we are setting in calculatedMaxHeight which\n    // currently is var(--dt-space-300) (4px). If not the intersectionObserver will continually trigger in an infinite\n    // loop.\n    // threshold 1.0 makes this trigger every time the dialog \"touches\" the edge of the viewport.\n    this.intersectionObserver = new IntersectionObserver(this.hasIntersectedViewport);\n    this.intersectionObserver.observe(this.popoverContentEl);\n  },\n\n  beforeDestroy () {\n    this.tip?.destroy();\n    this.intersectionObserver?.disconnect();\n    this.removeReferences();\n    this.removeEventListeners();\n  },\n\n  /******************\n   *     METHODS    *\n   ******************/\n  methods: {\n    hasIntersectedViewport (entries) {\n      const dialog = entries?.[0]?.target;\n      if (!dialog) return;\n      const isOut = isOutOfViewPort(dialog);\n      this.isOutsideViewport = isOut.bottom || isOut.top;\n    },\n\n    popperOptions () {\n      return getPopperOptions({\n        fallbackPlacements: this.fallbackPlacements,\n        tether: this.tether,\n        hasHideModifierEnabled: true,\n      });\n    },\n\n    validateProps () {\n      if (this.modal && this.initialFocusElement === 'none') {\n        console.error('If the popover is modal you must set the ' +\n        'initialFocusElement prop. Possible values: \"dialog\", \"first\", HTMLElement');\n      }\n    },\n\n    calculateAnchorZindex () {\n      // if a modal is currently active render at modal-element z-index, otherwise at popover z-index\n      if (this.$el.getRootNode()\n        .querySelector('.d-modal[aria-hidden=\"false\"], .d-modal--transparent[aria-hidden=\"false\"]') ||\n        // Special case because we don't have any dialtone drawer component yet. Render at 650 when\n        // anchor of popover is within a drawer.\n        this.anchorEl?.closest('.d-zi-drawer')) {\n        return 650;\n      } else {\n        return 300;\n      }\n    },\n\n    defaultToggleOpen (e) {\n      if (this.openOnContext) { return; }\n\n      // Only use default toggle behaviour if the user has not set the open prop.\n      // Check that the anchor element specifically was clicked.\n      this.open ?? (this.anchorEl?.contains(e.target) && !this.anchorEl?.disabled && this.toggleOpen());\n    },\n\n    async onContext (event) {\n      if (!this.openOnContext) { return; }\n\n      event.preventDefault();\n\n      this.isOpen = true;\n      await this.$nextTick();\n      this.tip.setProps({\n        placement: 'right-start',\n        getReferenceClientRect: () => ({\n          width: 0,\n          height: 0,\n          top: event.clientY,\n          bottom: event.clientY,\n          left: event.clientX,\n          right: event.clientX,\n        }),\n      });\n    },\n\n    toggleOpen () {\n      this.isOpen = !this.isOpen;\n    },\n\n    onArrowKeyPress (e) {\n      if (this.open !== null) { return; }\n\n      if (this.openWithArrowKeys && this.anchorEl?.contains(e.target)) {\n        if (!this.isOpen) {\n          this.isOpen = true;\n        }\n      }\n    },\n\n    addEventListeners () {\n      window.addEventListener('dt-popover-close', this.closePopover);\n      // align popover content width when contentWidth is 'anchor'\n      if (this.contentWidth === 'anchor') {\n        window.addEventListener('resize', this.onResize);\n      }\n    },\n\n    removeEventListeners () {\n      window.removeEventListener('dt-popover-close', this.closePopover);\n      if (this.contentWidth === 'anchor') {\n        window.removeEventListener('resize', this.onResize);\n      }\n    },\n\n    closePopover () {\n      this.isOpen = false;\n    },\n\n    /**\n     * Prevents scrolling outside of the currently opened modal popover by:\n     *   - when anchor is not within another popover: setting the body to overflow: hidden\n     *   - when anchor is within another popover: set the popover dialog container to it's non-modal z-index\n     *     since it is no longer the active modal. This puts it underneath the overlay and prevents scrolling.\n     */\n    preventScrolling () {\n      if (this.modal) {\n        const element = this.anchorEl?.closest('body, .tippy-box');\n        if (!element) return;\n        if (element.tagName?.toLowerCase() === 'body') {\n          disableRootScrolling(this.anchorEl.getRootNode().host);\n          this.tip.setProps({ offset: this.offset });\n        } else {\n          element.classList.add('d-zi-popover');\n        }\n      }\n    },\n\n    /**\n     * Resets the prevent scrolling properties set in preventScrolling() back to normal.\n     */\n    enableScrolling () {\n      const element = this.anchorEl?.closest('body, .tippy-box');\n      if (!element) return;\n      if (element.tagName?.toLowerCase() === 'body') {\n        enableRootScrolling(this.anchorEl.getRootNode().host);\n        this.tip.setProps({ offset: this.offset });\n      } else {\n        element.classList.remove('d-zi-popover');\n      }\n    },\n\n    removeReferences () {\n      this.anchorEl = null;\n      this.popoverContentEl = null;\n      this.tip = null;\n    },\n\n    async onShow () {\n      if (this.contentWidth === 'anchor') {\n        await this.setPopoverContentAnchorWidth();\n      }\n\n      if (this.contentWidth === null) {\n        this.popoverContentEl.style.width = 'auto';\n      }\n\n      this.addEventListeners();\n    },\n\n    async onLeaveTransitionComplete () {\n      if (this.modal) {\n        await this.focusFirstElement(this.$refs.anchor);\n        // await next tick in case the user wants to change focus themselves.\n        await this.$nextTick();\n        this.enableScrolling();\n      }\n      this.tip?.unmount();\n      this.$emit('opened', false);\n      if (this.open !== null) {\n        this.$emit('update:open', false);\n      }\n    },\n\n    async onEnterTransitionComplete () {\n      this.focusInitialElement();\n      // await next tick in case the user wants to change focus themselves.\n      await this.$nextTick();\n      this.preventScrolling();\n      this.$emit('opened', true, this.$refs.popover__content);\n      if (this.open !== null) {\n        this.$emit('update:open', true);\n      }\n    },\n\n    focusInitialElement () {\n      if (this.initialFocusElement === 'dialog') {\n        this.$refs.content?.$el?.focus();\n      }\n      // find by ID\n      if (this.initialFocusElement.startsWith('#')) {\n        this.focusInitialElementById();\n      }\n      if (this.initialFocusElement === 'first') {\n        this.focusFirstElementIfNeeded(this.$refs.popover__content);\n      }\n      if (this.initialFocusElement instanceof HTMLElement) {\n        this.initialFocusElement.focus();\n      }\n    },\n\n    focusInitialElementById () {\n      const result = this.$refs.content?.$el?.querySelector(this.initialFocusElement);\n      if (result) {\n        result.focus();\n      } else {\n        console.warn('Could not find the element specified in dt-popover prop \"initialFocusElement\". ' +\n          'Defaulting to focusing the dialog.');\n      }\n      result ? result.focus() : this.$refs.content?.$el.focus();\n    },\n\n    onResize () {\n      this.closePopover();\n    },\n\n    onClickOutside () {\n      if (!this.hideOnClick) return;\n      // If a popover is opened inside of this one, do not hide on click out\n      const innerModals = this.popoverContentEl?.querySelector('.d-popover__anchor--opened');\n      if (!innerModals) {\n        this.closePopover();\n      }\n    },\n\n    onKeydown (e) {\n      if (e.key === 'Tab') {\n        if (this.modal) {\n          this.focusTrappedTabPress(e, this.popoverContentEl);\n        }\n      }\n      if (e.key === 'Escape') {\n        this.closePopover();\n      }\n    },\n\n    async setPopoverContentAnchorWidth () {\n      await this.$nextTick();\n      this.popoverContentEl.style.width = `${this.anchorEl?.clientWidth}px`;\n    },\n\n    focusFirstElementIfNeeded (domEl) {\n      const focusableElements = this._getFocusableElements(domEl, true);\n      if (focusableElements.length !== 0) {\n        this.focusFirstElement(domEl);\n      } else if (this.showCloseButton) {\n        this.$refs.popover__header?.focusCloseButton();\n      } else {\n        // if there are no focusable elements at all focus the dialog itself\n        this.$refs.content?.$el.focus();\n      }\n    },\n\n    /**\n     * Return's the anchor ClientRect object relative to the window.\n     * Refer to: https://atomiks.github.io/tippyjs/v6/all-props/#getreferenceclientrect for more information\n     * @param error\n     */\n    getReferenceClientRect (error) {\n      const anchorReferenceRect = this.anchorEl?.getBoundingClientRect();\n\n      if (this.appendTo !== 'root' || error) return anchorReferenceRect;\n\n      const anchorOwnerDocument = this.anchorEl?.ownerDocument;\n      const anchorParentWindow = anchorOwnerDocument?.defaultView || anchorOwnerDocument?.parentWindow;\n      const anchorIframe = anchorParentWindow?.frameElement;\n\n      if (!anchorIframe) return anchorReferenceRect;\n\n      const iframeReferenceRect = anchorIframe.getBoundingClientRect();\n\n      return {\n        width: anchorReferenceRect?.width,\n        height: anchorReferenceRect?.height,\n        top: iframeReferenceRect?.top + anchorReferenceRect?.top,\n        left: iframeReferenceRect?.left + anchorReferenceRect?.left,\n        right: iframeReferenceRect?.right + anchorReferenceRect?.right,\n        bottom: iframeReferenceRect?.bottom + anchorReferenceRect?.bottom,\n      };\n    },\n\n    initTippyInstance () {\n      let internalAppendTo = null;\n      let iFrameError = false;\n\n      switch (this.appendTo) {\n        case 'body':\n          internalAppendTo = this.anchorEl?.getRootNode()?.querySelector('body');\n          break;\n\n        case 'root':\n          // Try to attach the popover to root document, fallback to parent is fail\n          try {\n            internalAppendTo = window.parent.document.body;\n          } catch (err) {\n            console.error('Could not attach the popover to iframe parent window: ', err);\n            internalAppendTo = 'parent';\n            iFrameError = true;\n          }\n          break;\n\n        default:\n          internalAppendTo = this.appendTo;\n          break;\n      }\n\n      this.tip = createTippyPopover(this.anchorEl, {\n        popperOptions: this.popperOptions(),\n        contentElement: this.popoverContentEl,\n        placement: this.placement,\n        offset: this.offset,\n        sticky: this.sticky,\n        appendTo: internalAppendTo,\n        interactive: true,\n        trigger: 'manual',\n        getReferenceClientRect: () => this.getReferenceClientRect(iFrameError),\n        // We have to manage hideOnClick functionality manually to handle\n        // popover within popover situations.\n        hideOnClick: false,\n        zIndex: this.modal ? 650 : this.calculateAnchorZindex(),\n        onClickOutside: this.onClickOutside,\n        onShow: this.onShow,\n      });\n    },\n\n    onMouseEnter () {\n      this.$emit('mouseenter-popover');\n    },\n\n    onMouseLeave () {\n      this.$emit('mouseleave-popover');\n    },\n\n    onMouseEnterAnchor () {\n      this.$emit('mouseenter-popover-anchor');\n    },\n\n    onMouseLeaveAnchor () {\n      this.$emit('mouseleave-popover-anchor');\n    },\n\n    hasFooter () {\n      return this.$slots.footerContent || this.$scopedSlots.footerContent?.();\n    },\n  },\n};\n</script>\n"],"names":["_sfc_main","SrOnlyCloseButton","DtLazyShow","PopoverHeaderFooter","Portal","ModalMixin","role","POPOVER_ROLES","padding","POPOVER_PADDING_CLASSES","item","contentWidth","POPOVER_CONTENT_WIDTHS","getUniqueString","sticky","POPOVER_STICKY_VALUES","initialFocusElement","POPOVER_INITIAL_FOCUS_STRINGS","appendTo","POPOVER_APPEND_TO_VALUES","POPOVER_HEADER_FOOTER_PADDING_CLASSES","event","modal","_a","offset","placement","open","isOpen","isPrev","warnIfUnmounted","externalAnchorEl","_b","entries","dialog","isOut","isOutOfViewPort","getPopperOptions","e","element","disableRootScrolling","enableRootScrolling","result","_c","domEl","error","anchorReferenceRect","anchorOwnerDocument","anchorParentWindow","anchorIframe","iframeReferenceRect","internalAppendTo","iFrameError","err","createTippyPopover"],"mappings":"wgBA6IAA,EAAA,CACA,KAAA,YAKA,WAAA,CACA,kBAAAC,EAAAA,QACA,WAAAC,EAAAA,QACA,oBAAAC,EAAAA,QACA,OAAAC,EAAAA,MACA,EAEA,OAAA,CAAAC,EAAAA,OAAA,EAEA,MAAA,CAOA,KAAA,CACA,KAAA,QACA,QAAA,IACA,EAOA,cAAA,CACA,KAAA,QACA,QAAA,EACA,EAKA,YAAA,CACA,KAAA,OACA,QAAA,KACA,EAMA,WAAA,CACA,KAAA,OACA,QAAA,MACA,EAMA,KAAA,CACA,KAAA,OACA,QAAA,SACA,UAAAC,GACAC,EAAAA,cAAA,SAAAD,CAAA,CAEA,EASA,eAAA,CACA,KAAA,OACA,QAAA,IACA,EAMA,UAAA,CACA,KAAA,OACA,QAAA,IACA,EAMA,QAAA,CACA,KAAA,OACA,QAAA,QACA,UAAAE,GACA,OAAA,KAAAC,yBAAA,EAAA,KAAAC,GAAAA,IAAAF,CA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