import { onBeforeUnmount } from 'vue';

function useLock(duration = 250) {
  let lock = null;
  let timeout;
  onBeforeUnmount(() => {
    clearTimeout(timeout);
  });
  function doLock(locked) {
    if (locked || lock === null)
      lock = locked;
    clearTimeout(timeout);
    timeout = setTimeout(() => {
      lock = null;
    }, duration);
  }
  return [() => lock, doLock];
}

export { useLock as default };
//# sourceMappingURL=useLock.mjs.map
