import { defineComponent, ref, watch, onActivated, onBeforeUnmount, createVNode, mergeProps } from 'vue';
import Tooltip from '../tooltip/index.mjs';
import wrapperRaf from '../_util/raf.mjs';
import { tooltipProps } from '../tooltip/Tooltip.mjs';

var SliderTooltip = /* @__PURE__ */ defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "SliderTooltip",
  inheritAttrs: false,
  props: tooltipProps(),
  setup(props, {
    attrs,
    slots
  }) {
    const innerRef = ref(null);
    const rafRef = ref(null);
    function cancelKeepAlign() {
      wrapperRaf.cancel(rafRef.value);
      rafRef.value = null;
    }
    function keepAlign() {
      rafRef.value = wrapperRaf(() => {
        var _a;
        (_a = innerRef.value) == null ? void 0 : _a.forcePopupAlign();
        rafRef.value = null;
      });
    }
    const align = () => {
      cancelKeepAlign();
      if (props.open)
        keepAlign();
    };
    watch([() => props.open, () => props.title], () => {
      align();
    }, {
      flush: "post",
      immediate: true
    });
    onActivated(() => {
      align();
    });
    onBeforeUnmount(() => {
      cancelKeepAlign();
    });
    return () => {
      return createVNode(Tooltip, mergeProps({
        "ref": innerRef
      }, props, attrs), slots);
    };
  }
});

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