"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const vue = require("vue");
function useRoomToolbar(containerRef, autoHideDelay = 5e3, mouseMoveThrottle = 1e3) {
  const showToolbar = vue.ref(true);
  const hideToolTimer = vue.ref(null);
  const throttleTimer = vue.ref(null);
  const isThrottled = vue.ref(false);
  const clearHideTimer = () => {
    if (hideToolTimer.value !== null) {
      clearTimeout(hideToolTimer.value);
      hideToolTimer.value = null;
    }
  };
  const clearThrottleTimer = () => {
    if (throttleTimer.value !== null) {
      clearTimeout(throttleTimer.value);
      throttleTimer.value = null;
    }
  };
  const setHideTimer = () => {
    clearHideTimer();
    hideToolTimer.value = window.setTimeout(() => {
      showToolbar.value = false;
    }, autoHideDelay);
  };
  const handleMouseEnter = () => {
    showToolbar.value = true;
    setHideTimer();
  };
  const handleMouseMoveThrottled = () => {
    if (isThrottled.value) {
      return;
    }
    showToolbar.value = true;
    setHideTimer();
    isThrottled.value = true;
    throttleTimer.value = window.setTimeout(() => {
      isThrottled.value = false;
    }, mouseMoveThrottle);
  };
  const handleMouseLeave = () => {
    clearHideTimer();
    clearThrottleTimer();
    isThrottled.value = false;
    showToolbar.value = false;
  };
  const addEventListeners = () => {
    const container = containerRef.value;
    if (!container) {
      return;
    }
    container.addEventListener("mouseenter", handleMouseEnter);
    container.addEventListener("mousemove", handleMouseMoveThrottled);
    container.addEventListener("mouseleave", handleMouseLeave);
  };
  const removeEventListeners = () => {
    const container = containerRef.value;
    if (!container) {
      return;
    }
    container.removeEventListener("mouseenter", handleMouseEnter);
    container.removeEventListener("mousemove", handleMouseMoveThrottled);
    container.removeEventListener("mouseleave", handleMouseLeave);
  };
  vue.onMounted(() => {
    addEventListeners();
    setHideTimer();
  });
  vue.onUnmounted(() => {
    clearHideTimer();
    clearThrottleTimer();
    removeEventListeners();
  });
  return {
    showToolbar
  };
}
exports.useRoomToolbar = useRoomToolbar;
