import { provide, computed, inject } from 'vue';

const PortalContextKey = Symbol("PortalContextKey");
function useProvidePortal(instance, config = { inTriggerContext: true }) {
  provide(PortalContextKey, {
    inTriggerContext: config.inTriggerContext,
    shouldRender: computed(() => {
      const { sPopupVisible, popupRef, forceRender, autoDestroy } = instance || {};
      let shouldRender = false;
      if (sPopupVisible || popupRef || forceRender)
        shouldRender = true;
      if (!sPopupVisible && autoDestroy)
        shouldRender = false;
      return shouldRender;
    })
  });
}
function useInjectPortal() {
  useProvidePortal({}, { inTriggerContext: false });
  const portalContext = inject(PortalContextKey, {
    shouldRender: computed(() => false),
    inTriggerContext: false
  });
  return {
    shouldRender: computed(
      () => portalContext.shouldRender.value || portalContext.inTriggerContext === false
    )
  };
}

export { useInjectPortal, useProvidePortal };
//# sourceMappingURL=context.mjs.map
