"use strict";
const React = require("react");
const isEqualWith = require("../../../../../../../lodash@4.17.21/node_modules/lodash/isEqualWith.js");
const classNames = require("../../_util/classNames.js");
const utils = require("../utils.js");
const throttleByRaf = require("../../_util/throttleByRaf.js");
const emotionReactJsxRuntime_browser_esm = require("../../../../../../../@emotion_react@11.10.4_3toe27fv7etiytxb5kxc7fxaw4/node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js");
var getInkStyle = function(direction, curTitle, headerRef) {
  var style = {};
  if (curTitle) {
    var diffStyle = utils.getRectDiff(curTitle, headerRef);
    if (direction === "vertical") {
      style = {
        top: diffStyle.top + "px",
        height: curTitle.offsetHeight + "px",
        left: "",
        width: ""
      };
    } else {
      style = {
        left: diffStyle.left + "px",
        width: curTitle.offsetWidth + "px",
        top: "",
        height: ""
      };
    }
  }
  return style;
};
var TabInk = function(_a) {
  var _b;
  var prefixCls = _a.prefixCls, animation = _a.animation, disabled = _a.disabled, direction = _a.direction, getTitleRef = _a.getTitleRef, activeTab = _a.activeTab, getHeaderRef = _a.getHeaderRef;
  var inkRef = React.useRef();
  var inkStyleRef = React.useRef();
  React.useEffect(function() {
    var setInkStyle = throttleByRaf(function() {
      var newStyle = getInkStyle(direction, getTitleRef(activeTab), getHeaderRef("headerRef").current);
      if (newStyle && !isEqualWith(inkStyleRef.current, newStyle)) {
        inkStyleRef.current = newStyle;
        Object.keys(newStyle).forEach(function(key) {
          inkRef.current.style[key] = newStyle[key];
        });
      }
    });
    setInkStyle();
    return function() {
      setInkStyle.cancel && setInkStyle.cancel();
    };
  });
  return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("div", {
    className: classNames(prefixCls + "-header-ink", (_b = {}, _b[prefixCls + "-header-ink-no-animation"] = !animation, _b[prefixCls + "-header-ink-disabled"] = disabled, _b)),
    ref: inkRef
  });
};
const TabInk$1 = TabInk;
module.exports = TabInk$1;
//# sourceMappingURL=tab-ink.js.map
