'use strict';

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

var vue = require('vue');
var classNames = require('../_util/classNames.js');
var index = require('../_util/props-util/index.js');
var isVisible = require('../vc-util/Dom/isVisible.js');
require('../hooks/index.js');
var style = require('./style.js');
var useWave = require('./useWave.js');
var useConfigInject = require('../config-provider/hooks/useConfigInject.js');

var Wave = /* @__PURE__ */ vue.defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "Wave",
  props: {
    disabled: Boolean
  },
  setup(props, {
    slots
  }) {
    const instance = vue.getCurrentInstance();
    const {
      prefixCls
    } = useConfigInject.default("wave", props);
    const [, hashId] = style.default(prefixCls);
    const showWave = useWave.default(instance, vue.computed(() => classNames.default(prefixCls.value, hashId.value)));
    let onClick;
    const clear = () => {
      const node = index.findDOMNode(instance);
      node.removeEventListener("click", onClick, true);
    };
    vue.onMounted(() => {
      vue.watch(() => props.disabled, () => {
        clear();
        vue.nextTick(() => {
          const node = index.findDOMNode(instance);
          if (!node || node.nodeType !== 1 || props.disabled)
            return;
          const onClick2 = (e) => {
            if (e.target.tagName === "INPUT" || !isVisible.default(e.target) || !node.getAttribute || node.getAttribute("disabled") || node.disabled || node.className.includes("disabled") || node.className.includes("-leave"))
              return;
            showWave();
          };
          node.addEventListener("click", onClick2, 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=index.js.map
