"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=':not(:disabled):not([aria-disabled="true"]):not([role="presentation"])',r=`${o}:not([tabindex="-1"])`,a="button,[href],input,select,textarea,details,[tabindex]",c={methods:{async getFirstFocusableElement(e){await this.$nextTick();const t=this._getFocusableElements(e,!0);return this._getFirstFocusElement(t)},async focusFirstElement(e=this.$el){const t=await this.getFirstFocusableElement(e);t==null||t.focus({preventScroll:!0})},async focusElementById(e){var s;await this.$nextTick();const t=(s=this.$el)==null?void 0:s.querySelector(e);if(t){t.focus();return}console.warn('Could not find the element specified in dt-modal prop "initialFocusElement". Defaulting to focusing the first element.'),await this.focusFirstElement()},_getFirstFocusElement(e){if(!e.length)return;let t=e[0];return t.matches('[type="radio"]:not(:checked)')&&(t=e.find(s=>s.checked&&s.name===t.name)||t),t},_getFocusableElements(e=this.$el,t=!1){return e?[...e.querySelectorAll(a)].filter(n=>{const i=window.getComputedStyle(n);return i.getPropertyValue("display")!=="none"&&i.getPropertyValue("visibility")!=="hidden"&&n.matches(t?o:r)}):[]},focusTrappedTabPress(e,t){if(!(e.key==="Tab"))return;const n=this._getFocusableElements(t);if(!n.length){e.preventDefault();return}const i=this._getFirstFocusElement(n),l=n[n.length-1];e.shiftKey?document.activeElement===i&&(l.focus(),e.preventDefault()):document.activeElement===l&&(i.focus(),e.preventDefault())}}};exports.default=c;
//# sourceMappingURL=modal.cjs.map
