import { defineComponent, ref, watch, onActivated, onBeforeUnmount, createVNode } from 'vue';
import '../../../utils/index.mjs';
import { Tooltip } from '../../tooltip/index.mjs';
import { tooltipProps } from '../../tooltip/src/props.mjs';
import { raf } from '../../../utils/vue/raf.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() {
      raf.cancel(rafRef.value);
      rafRef.value = null;
    }
    function keepAlign() {
      rafRef.value = raf(() => {
        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, {
        "ref": innerRef,
        ...props,
        ...attrs
      }, slots);
    };
  }
});

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