import { Ot as nextTick, Qn as toRef, Vn as onScopeDispose, er as toValue, gn as watch } from "./vue.runtime.esm-bundler-BvoXUmaf.js"; import { O as focusableChildren, Q as IN_BROWSER, b as defer, l as propsFactory } from "./defineComponent-DB6xIcDy.js"; //#region node_modules/vuetify/lib/composables/delay.js var makeDelayProps = propsFactory({ closeDelay: [Number, String], openDelay: [Number, String] }, "delay"); function useDelay(props, cb) { let clearDelay = () => {}; function runDelay(isOpening, options) { clearDelay?.(); const delay = isOpening ? props.openDelay : props.closeDelay; const normalizedDelay = Math.max(options?.minDelay ?? 0, Number(delay ?? 0)); return new Promise((resolve) => { clearDelay = defer(normalizedDelay, () => { cb?.(isOpening); resolve(isOpening); }); }); } function runOpenDelay() { return runDelay(true); } function runCloseDelay(options) { return runDelay(false, options); } return { clearDelay, runOpenDelay, runCloseDelay }; } //#endregion //#region node_modules/vuetify/lib/composables/focusTrap.js var makeFocusTrapProps = propsFactory({ retainFocus: Boolean, captureFocus: Boolean, /** @deprecated */ disableInitialFocus: Boolean }, "focusTrap"); var registry = /* @__PURE__ */ new Map(); var subscribers = 0; function onKeydown(e) { const activeElement = document.activeElement; if (e.key !== "Tab" || !activeElement) return; const parentTraps = Array.from(registry.values()).filter(({ isActive, contentEl }) => isActive.value && contentEl.value?.contains(activeElement)).map((x) => x.contentEl.value); let closestTrap; let currentParent = activeElement.parentElement; while (currentParent) { if (parentTraps.includes(currentParent)) { closestTrap = currentParent; break; } currentParent = currentParent.parentElement; } if (!closestTrap) return; const focusable = focusableChildren(closestTrap).filter((x) => x.tabIndex >= 0); if (!focusable.length) return; const active = document.activeElement; if (focusable.length === 1 && focusable[0].classList.contains("v-list") && focusable[0].contains(active)) { e.preventDefault(); return; } const firstElement = focusable[0]; const lastElement = focusable[focusable.length - 1]; if (e.shiftKey && (active === firstElement || firstElement.classList.contains("v-list") && firstElement.contains(active))) { e.preventDefault(); lastElement.focus(); } if (!e.shiftKey && (active === lastElement || lastElement.classList.contains("v-list") && lastElement.contains(active))) { e.preventDefault(); firstElement.focus(); } } function useFocusTrap(props, { isActive, localTop, activatorEl, contentEl }) { const trapId = Symbol("trap"); let focusTrapSuppressed = false; let focusTrapSuppressionTimeout = -1; async function onPointerdown() { focusTrapSuppressed = true; focusTrapSuppressionTimeout = window.setTimeout(() => { focusTrapSuppressed = false; }, 100); } async function captureOnFocus(e) { const before = e.relatedTarget; const after = e.target; document.removeEventListener("pointerdown", onPointerdown); document.removeEventListener("keydown", captureOnKeydown); await nextTick(); if (isActive.value && !focusTrapSuppressed && before !== after && contentEl.value && toValue(localTop) && ![document, contentEl.value].includes(after) && !contentEl.value.contains(after)) focusableChildren(contentEl.value)[0]?.focus(); } function captureOnKeydown(e) { if (e.key !== "Tab") return; document.removeEventListener("keydown", captureOnKeydown); if (isActive.value && contentEl.value && e.target && !contentEl.value.contains(e.target)) { const allFocusableElements = focusableChildren(document.documentElement); if (e.shiftKey && e.target === allFocusableElements.at(0) || !e.shiftKey && e.target === allFocusableElements.at(-1)) { const focusable = focusableChildren(contentEl.value); if (focusable.length > 0) { e.preventDefault(); focusable[0].focus(); } } } } const shouldCapture = toRef(() => isActive.value && props.captureFocus && !props.disableInitialFocus); if (IN_BROWSER) { watch(() => props.retainFocus, (val) => { if (val) registry.set(trapId, { isActive, contentEl }); else registry.delete(trapId); }, { immediate: true }); watch(shouldCapture, (val) => { if (val) { document.addEventListener("pointerdown", onPointerdown); document.addEventListener("focusin", captureOnFocus, { once: true }); document.addEventListener("keydown", captureOnKeydown); } else { document.removeEventListener("pointerdown", onPointerdown); document.removeEventListener("focusin", captureOnFocus); document.removeEventListener("keydown", captureOnKeydown); } }, { immediate: true }); if (subscribers++ < 1) document.addEventListener("keydown", onKeydown); } onScopeDispose(() => { registry.delete(trapId); if (!IN_BROWSER) return; clearTimeout(focusTrapSuppressionTimeout); document.removeEventListener("pointerdown", onPointerdown); document.removeEventListener("focusin", captureOnFocus); document.removeEventListener("keydown", captureOnKeydown); if (--subscribers < 1) document.removeEventListener("keydown", onKeydown); }); } //#endregion export { useDelay as i, useFocusTrap as n, makeDelayProps as r, makeFocusTrapProps as t }; //# sourceMappingURL=focusTrap-rHoJd0qS.js.map