import { ref, watch, effectScope, onScopeDispose, computed, toRaw } from "vue";
import { getCurrentInstance } from "../../utils/dist/index.mjs";
const stack = ref([]);
function useStack(isActive) {
  const vm = getCurrentInstance("stack");
  let scope;
  watch(isActive, (val) => {
    if (val) {
      scope = effectScope();
      scope.run(() => {
        stack.value.push(vm);
        onScopeDispose(() => {
          stack.value.splice(stack.value.indexOf(vm), 1);
        });
      });
    } else {
      scope == null ? void 0 : scope.stop();
    }
  }, { immediate: true });
  const isTop = computed(() => {
    return toRaw(stack.value[stack.value.length - 1]) === vm;
  });
  return {
    isTop
  };
}
export {
  useStack
};
//# sourceMappingURL=index.mjs.map
