import { defineComponent, getCurrentInstance, computed, onMounted, watch, nextTick, onBeforeUnmount } from 'vue';
import '../../../utils/index.mjs';
import useConfigInject from '../../config-provider/src/hooks/useConfigInject.mjs';
import useStyle from '../style/index.mjs';
import useWave from './useWave.mjs';
import { classNames } from '../../../utils/dom/class.mjs';
import { findDOMNode } from '../../../utils/vue/props.mjs';
import { isVisible } from '../../../utils/is.mjs';

var Wave = /* @__PURE__ */ defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "VcWave",
  props: {
    disabled: Boolean
  },
  setup(props, {
    slots
  }) {
    const instance = getCurrentInstance();
    const {
      prefixCls,
      wave
    } = useConfigInject("wave", props);
    const [, hashId] = useStyle(prefixCls);
    const showWave = useWave(instance, computed(() => classNames(prefixCls.value, hashId.value)), wave);
    let onClick;
    const clear = () => {
      const node = findDOMNode(instance);
      node.removeEventListener("click", onClick, true);
    };
    onMounted(() => {
      watch(() => props.disabled, () => {
        clear();
        nextTick(() => {
          const node = findDOMNode(instance);
          node == null ? void 0 : node.removeEventListener("click", onClick, true);
          if (!node || node.nodeType !== 1 || props.disabled)
            return;
          onClick = (e) => {
            if (e.target.tagName === "INPUT" || !isVisible(e.target) || !node.getAttribute || node.getAttribute("disabled") || node.disabled || node.className.includes("disabled") || node.className.includes("-leave"))
              return;
            showWave();
          };
          node.addEventListener("click", onClick, true);
        });
      }, {
        immediate: true,
        flush: "post"
      });
    });
    onBeforeUnmount(() => {
      clear();
    });
    return () => {
      var _a;
      const children = (_a = slots.default) == null ? void 0 : _a.call(slots)[0];
      return children;
    };
  }
});

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