'use strict';

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

var vue = require('vue');
require('../index.js');
var main = require('./main.js');
var props = require('./props.js');

const tooltipEmitsVNodeKeys = props.tooltipEmits.map((item) => {
  return `on${item[0].toUpperCase()}${item.slice(1).replace(/-(\w)/g, (_, c) => c.toUpperCase())}`;
});
function useTooltip(props, e) {
  if (props.disabled)
    return;
  if (Reflect.get(e, "__tooltip__")) {
    return;
  }
  Reflect.set(e, "__tooltip__", 1);
  const domList = document.querySelectorAll(".group-tooltip-list-item");
  Array.from(domList).forEach((item) => item.remove());
  const container = document.createElement("div");
  container.className = "group-tooltip-list-item";
  let vNode;
  let destroyTooltip;
  const renderComponent = vue.defineComponent({
    setup() {
      const isRender = vue.ref(true);
      destroyTooltip = () => {
        setTimeout(() => {
          isRender.value = false;
          vNode = null;
          vue.render(null, container);
          container.remove();
          Reflect.set(e, "__tooltip__", null);
        }, Math.max(0, props.hideAfter, props.showAfter) + 50);
      };
      return () => {
        if (!isRender.value) {
          return null;
        }
        return vue.createVNode(main["default"], {
          ...props,
          content: typeof props.content === "string" ? props.content : "",
          virtualTriggering: true,
          virtualRef: e,
          onHide(value) {
            var _a;
            (_a = props.onHide) == null ? void 0 : _a.call(props, value);
            destroyTooltip == null ? void 0 : destroyTooltip();
          }
        }, {
          content: typeof props.content !== "string" ? props.content : void 0
        });
      };
    }
  });
  vNode = vue.createVNode(renderComponent);
  vue.render(vNode, container);
  document.body.appendChild(container);
  return () => {
    destroyTooltip == null ? void 0 : destroyTooltip();
    destroyTooltip = null;
  };
}

exports.useTooltip = useTooltip;
//# sourceMappingURL=method.js.map
