'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
require('../../../utils/index.cjs');
var useConfigInject = require('../../config-provider/src/hooks/useConfigInject.cjs');
var index = require('../style/index.cjs');
var useWave = require('./useWave.cjs');
var _class = require('../../../utils/dom/class.cjs');
var props = require('../../../utils/vue/props.cjs');
var is = require('../../../utils/is.cjs');

var Wave = /* @__PURE__ */ vue.defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "VcWave",
  props: {
    disabled: Boolean
  },
  setup(props$1, {
    slots
  }) {
    const instance = vue.getCurrentInstance();
    const {
      prefixCls,
      wave
    } = useConfigInject.default("wave", props$1);
    const [, hashId] = index.default(prefixCls);
    const showWave = useWave.default(instance, vue.computed(() => _class.classNames(prefixCls.value, hashId.value)), wave);
    let onClick;
    const clear = () => {
      const node = props.findDOMNode(instance);
      node.removeEventListener("click", onClick, true);
    };
    vue.onMounted(() => {
      vue.watch(() => props$1.disabled, () => {
        clear();
        vue.nextTick(() => {
          const node = props.findDOMNode(instance);
          node == null ? void 0 : node.removeEventListener("click", onClick, true);
          if (!node || node.nodeType !== 1 || props$1.disabled)
            return;
          onClick = (e) => {
            if (e.target.tagName === "INPUT" || !is.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"
      });
    });
    vue.onBeforeUnmount(() => {
      clear();
    });
    return () => {
      var _a;
      const children = (_a = slots.default) == null ? void 0 : _a.call(slots)[0];
      return children;
    };
  }
});

exports.default = Wave;
//# sourceMappingURL=Wave.cjs.map
