import { resetComponent as f } from "../../style/index.mjs";
import { initZoomMotion as h } from "../../style/motion/zoom.mjs";
import x, { MAX_VERTICAL_CONTENT_RADIUS as S, getArrowOffsetToken as w } from "../../style/placementArrow.mjs";
import "../../../../@ant-design/cssinjs/es/extractStyle.mjs";
import "../../../../@ant-design/cssinjs/es/hooks/useCacheToken.mjs";
import "react";
import "../../../../@ant-design/cssinjs/es/StyleContext.mjs";
import { unit as d } from "../../../../@ant-design/cssinjs/es/util/index.mjs";
import "../../../../@ant-design/cssinjs/es/hooks/useCompatibleInsertionEffect.mjs";
import "../../../../@ant-design/cssinjs/es/hooks/useEffectCleanupRegister.mjs";
import "../../../../@ant-design/cssinjs/es/hooks/useHMR.mjs";
import "../../../../rc-util/es/warning.mjs";
import "../../../../@ant-design/cssinjs/es/theme/createTheme.mjs";
import "../../../../@ant-design/cssinjs/es/theme/ThemeCache.mjs";
import "../../../../@ant-design/cssinjs/es/transformers/legacyLogicalProperties.mjs";
import { genStyleHooks as y } from "../../theme/util/genComponentStyleHook.mjs";
import T from "../../theme/util/genPresetColor.mjs";
import { merge as s } from "../../theme/util/statistic.mjs";
import { getArrowToken as R } from "../../style/roundedArrow.mjs";
const C = (o) => {
  const {
    componentCls: t,
    // ant-tooltip
    tooltipMaxWidth: l,
    tooltipColor: r,
    tooltipBg: i,
    tooltipBorderRadius: e,
    zIndexPopup: a,
    controlHeight: n,
    boxShadowSecondary: m,
    paddingSM: c,
    paddingXS: g
  } = o;
  return [
    {
      [t]: Object.assign(Object.assign(Object.assign(Object.assign({}, f(o)), {
        position: "absolute",
        zIndex: a,
        display: "block",
        width: "max-content",
        maxWidth: l,
        visibility: "visible",
        transformOrigin: "var(--arrow-x, 50%) var(--arrow-y, 50%)",
        "&-hidden": {
          display: "none"
        },
        "--antd-arrow-background-color": i,
        // Wrapper for the tooltip content
        [`${t}-inner`]: {
          minWidth: n,
          minHeight: n,
          padding: `${d(o.calc(c).div(2).equal())} ${d(g)}`,
          color: r,
          textAlign: "start",
          textDecoration: "none",
          wordWrap: "break-word",
          backgroundColor: i,
          borderRadius: e,
          boxShadow: m,
          boxSizing: "border-box"
        },
        // Limit left and right placement radius
        [["&-placement-left", "&-placement-leftTop", "&-placement-leftBottom", "&-placement-right", "&-placement-rightTop", "&-placement-rightBottom"].join(",")]: {
          [`${t}-inner`]: {
            borderRadius: o.min(e, S)
          }
        },
        [`${t}-content`]: {
          position: "relative"
        }
      }), T(o, (u, b) => {
        let {
          darkColor: p
        } = b;
        return {
          [`&${t}-${u}`]: {
            [`${t}-inner`]: {
              backgroundColor: p
            },
            [`${t}-arrow`]: {
              "--antd-arrow-background-color": p
            }
          }
        };
      })), {
        // RTL
        "&-rtl": {
          direction: "rtl"
        }
      })
    },
    // Arrow Style
    x(o, "var(--antd-arrow-background-color)"),
    // Pure Render
    {
      [`${t}-pure`]: {
        position: "relative",
        maxWidth: "none",
        margin: o.sizePopupArrow
      }
    }
  ];
}, O = (o) => Object.assign(Object.assign({
  zIndexPopup: o.zIndexPopupBase + 70
}, w({
  contentRadius: o.borderRadius,
  limitVerticalRadius: !0
})), R(s(o, {
  borderRadiusOuter: Math.min(o.borderRadiusOuter, 4)
}))), q = function(o) {
  let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0;
  return y("Tooltip", (r) => {
    const {
      borderRadius: i,
      colorTextLightSolid: e,
      colorBgSpotlight: a
    } = r, n = s(r, {
      // default variables
      tooltipMaxWidth: 250,
      tooltipColor: e,
      tooltipBorderRadius: i,
      tooltipBg: a
    });
    return [C(n), h(r, "zoom-big-fast")];
  }, O, {
    resetStyle: !1,
    // Popover use Tooltip as internal component. We do not need to handle this.
    injectStyle: t
  })(o);
};
export {
  q as default,
  O as prepareComponentToken
};
