import { ref, onUnmounted } from 'vue';

const useTimeoutPromise = () => {
  const timeoutids = ref(/* @__PURE__ */ new Set());
  const start = (delay = 1e3) => {
    return new Promise((resolve) => {
      const newId = window.setTimeout(() => {
        timeoutids.value.delete(newId);
        resolve(newId);
      }, delay);
      timeoutids.value.add(newId);
    });
  };
  onUnmounted(() => {
    timeoutids.value.forEach((id) => {
      window.clearTimeout(id);
    });
  });
  return {
    start
  };
};

export { useTimeoutPromise };
//# sourceMappingURL=index.mjs.map
