'use strict';

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

require('../../../theme/index.cjs');
require('../../../theme/style/motion/index.cjs');
var presetColor = require('../../../theme/style/presetColor.cjs');
var placementArrow = require('../../../theme/style/placementArrow.cjs');
var index = require('../../../theme/style/index.cjs');
var statistic = require('../../../theme/token/util/statistic.cjs');
var genComponentStyleHook = require('../../../theme/token/util/genComponentStyleHook.cjs');
var zoom = require('../../../theme/style/motion/zoom.cjs');

const genTooltipStyle = (token) => {
  const {
    componentCls,
    // ant-tooltip
    tooltipMaxWidth,
    tooltipColor,
    tooltipBg,
    tooltipBorderRadius,
    zIndexPopup,
    controlHeight,
    boxShadowSecondary,
    paddingSM,
    paddingXS,
    tooltipRadiusOuter
  } = token;
  return [
    {
      [componentCls]: {
        ...index.resetComponent(token),
        "position": "absolute",
        "zIndex": zIndexPopup,
        "display": "block",
        "&": [{ width: "max-content" }, { width: "intrinsic" }],
        "maxWidth": tooltipMaxWidth,
        "visibility": "visible",
        "&-hidden": {
          display: "none"
        },
        "--antd-arrow-background-color": tooltipBg,
        // Wrapper for the tooltip content
        [`${componentCls}-inner`]: {
          minWidth: controlHeight,
          minHeight: controlHeight,
          padding: `${paddingSM / 2}px ${paddingXS}px`,
          color: tooltipColor,
          textAlign: "start",
          textDecoration: "none",
          wordWrap: "break-word",
          backgroundColor: tooltipBg,
          borderRadius: tooltipBorderRadius,
          boxShadow: boxShadowSecondary
        },
        // Limit left and right placement radius
        [[
          "&-placement-left",
          "&-placement-leftTop",
          "&-placement-leftBottom",
          "&-placement-right",
          "&-placement-rightTop",
          "&-placement-rightBottom"
        ].join(",")]: {
          [`${componentCls}-inner`]: {
            borderRadius: Math.min(tooltipBorderRadius, placementArrow.MAX_VERTICAL_CONTENT_RADIUS)
          }
        },
        [`${componentCls}-content`]: {
          position: "relative"
        },
        // generator for preset color
        ...presetColor.genPresetColor(token, (colorKey, { darkColor }) => ({
          [`&${componentCls}-${colorKey}`]: {
            [`${componentCls}-inner`]: {
              backgroundColor: darkColor
            },
            [`${componentCls}-arrow`]: {
              "--antd-arrow-background-color": darkColor
            }
          }
        })),
        // RTL
        "&-rtl": {
          direction: "rtl"
        }
      }
    },
    // Arrow Style
    placementArrow.default(
      statistic.merge(token, {
        borderRadiusOuter: tooltipRadiusOuter
      }),
      {
        colorBg: "var(--antd-arrow-background-color)",
        showArrowCls: "",
        contentRadius: tooltipBorderRadius,
        limitVerticalRadius: true
      }
    ),
    // Pure Render
    {
      [`${componentCls}-pure`]: {
        position: "relative",
        maxWidth: "none"
      }
    }
  ];
};
var useStyle = (prefixCls, injectStyle) => {
  const useOriginHook = genComponentStyleHook.default(
    "Tooltip",
    (token) => {
      if ((injectStyle == null ? void 0 : injectStyle.value) === false)
        return [];
      const { borderRadius, colorTextLightSolid, colorBgDefault, borderRadiusOuter } = token;
      const TooltipToken = statistic.merge(token, {
        // default variables
        tooltipMaxWidth: 250,
        tooltipColor: colorTextLightSolid,
        tooltipBorderRadius: borderRadius,
        tooltipBg: colorBgDefault,
        tooltipRadiusOuter: borderRadiusOuter > 4 ? 4 : borderRadiusOuter
      });
      return [genTooltipStyle(TooltipToken), zoom.initZoomMotion(token, "zoom-big-fast")];
    },
    ({ zIndexPopupBase, colorBgSpotlight }) => ({
      zIndexPopup: zIndexPopupBase + 70,
      colorBgDefault: colorBgSpotlight
    })
  );
  return useOriginHook(prefixCls);
};

exports.default = useStyle;
//# sourceMappingURL=index.cjs.map
