import { Ot as nextTick, Qn as toRef, U as computed, Vn as onScopeDispose, Wn as reactive, Zt as resolveDynamicComponent } from "./vue.runtime.esm-bundler-BvoXUmaf.js";
import { N as hasEvent, Q as IN_BROWSER, l as propsFactory, s as getCurrentInstance } from "./defineComponent-DB6xIcDy.js";
import { t as deepEqual } from "./deepEqual-DDqmGqyF.js";
//#region node_modules/vuetify/lib/composables/router.js
function useRoute() {
	const vm = getCurrentInstance("useRoute");
	return computed(() => vm?.proxy?.$route);
}
function useRouter() {
	return getCurrentInstance("useRouter")?.proxy?.$router;
}
function useLink(props, attrs) {
	const RouterLink = resolveDynamicComponent("RouterLink");
	const isLink = toRef(() => !!(props.href || props.to));
	const isClickable = computed(() => {
		return isLink?.value || hasEvent(attrs, "click") || hasEvent(props, "click");
	});
	if (typeof RouterLink === "string" || !("useLink" in RouterLink)) {
		const href = toRef(() => props.href);
		return {
			isLink,
			isRouterLink: toRef(() => false),
			isClickable,
			href,
			linkProps: reactive({ href }),
			route: toRef(() => void 0),
			navigate: toRef(() => void 0)
		};
	}
	const routerLink = RouterLink.useLink({
		to: toRef(() => props.to || ""),
		replace: toRef(() => props.replace)
	});
	const link = computed(() => props.to ? routerLink : void 0);
	const route = useRoute();
	const isActive = computed(() => {
		if (!link.value) return false;
		if (!props.exact) return link.value.isActive?.value ?? false;
		if (!route.value) return link.value.isExactActive?.value ?? false;
		return link.value.isExactActive?.value && deepEqual(link.value.route.value.query, route.value.query);
	});
	const href = computed(() => props.to ? link.value?.route.value.href : props.href);
	return {
		isLink,
		isRouterLink: toRef(() => !!props.to),
		isClickable,
		isActive,
		route: toRef(() => link.value?.route.value),
		navigate: toRef(() => link.value?.navigate),
		href,
		linkProps: reactive({
			href,
			"aria-current": toRef(() => isActive.value ? "page" : void 0),
			"aria-disabled": toRef(() => props.disabled && isLink.value ? "true" : void 0),
			tabindex: toRef(() => props.disabled && isLink.value ? "-1" : void 0)
		})
	};
}
var makeRouterProps = propsFactory({
	href: String,
	replace: Boolean,
	to: [String, Object],
	exact: Boolean
}, "router");
var inTransition = false;
function useBackButton(router, cb) {
	let popped = false;
	let removeBefore;
	let removeAfter;
	if (IN_BROWSER && router?.beforeEach) {
		nextTick(() => {
			window.addEventListener("popstate", onPopstate);
			removeBefore = router.beforeEach(() => {
				if (!inTransition) {
					inTransition = true;
					return new Promise((resolve) => {
						setTimeout(() => resolve(popped ? cb() : void 0));
					});
				}
				return popped ? cb() : void 0;
			});
			removeAfter = router?.afterEach(() => {
				inTransition = false;
			});
		});
		onScopeDispose(() => {
			window.removeEventListener("popstate", onPopstate);
			removeBefore?.();
			removeAfter?.();
		});
	}
	function onPopstate(e) {
		if (e.state?.replaced) return;
		popped = true;
		setTimeout(() => popped = false);
	}
}
//#endregion
export { useRouter as i, useBackButton as n, useLink as r, makeRouterProps as t };

//# sourceMappingURL=router-D_jP4Uwb.js.map