'use strict';

var vue = require('vue');

const PortalContextKey = Symbol("PortalContextKey");
function useProvidePortal(instance, config = { inTriggerContext: true }) {
  vue.provide(PortalContextKey, {
    inTriggerContext: config.inTriggerContext,
    shouldRender: vue.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 = vue.inject(PortalContextKey, {
    shouldRender: vue.computed(() => false),
    inTriggerContext: false
  });
  return {
    shouldRender: vue.computed(
      () => portalContext.shouldRender.value || portalContext.inTriggerContext === false
    )
  };
}

exports.useInjectPortal = useInjectPortal;
exports.useProvidePortal = useProvidePortal;
//# sourceMappingURL=context.cjs.map
