import { resetComponent as h } from "../../style/index.mjs";
import { initZoomMotion as x } from "../../style/motion/zoom.mjs";
import $, { getArrowOffsetToken as f } 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 "../../../../@ant-design/cssinjs/es/theme/createTheme.mjs";
import "../../../../rc-util/es/warning.mjs";
import "../../../../@ant-design/cssinjs/es/theme/ThemeCache.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 "../../../../@ant-design/cssinjs/es/transformers/legacyLogicalProperties.mjs";
import { genStyleHooks as B } from "../../theme/util/genComponentStyleHook.mjs";
import { merge as v } from "../../theme/util/statistic.mjs";
import { getArrowToken as P } from "../../style/roundedArrow.mjs";
import { PresetColors as w } from "../../theme/interface/presetColors.mjs";
const S = (t) => {
  const {
    componentCls: o,
    popoverColor: e,
    titleMinWidth: r,
    fontWeightStrong: d,
    innerPadding: n,
    boxShadowSecondary: p,
    colorTextHeading: l,
    borderRadiusLG: s,
    zIndexPopup: c,
    titleMarginBottom: g,
    colorBgElevated: m,
    popoverBg: i,
    titleBorderBottom: u,
    innerContentPadding: b,
    titlePadding: a
  } = t;
  return [
    {
      [o]: Object.assign(Object.assign({}, h(t)), {
        position: "absolute",
        top: 0,
        // use `left` to fix https://github.com/ant-design/ant-design/issues/39195
        left: {
          _skip_check_: !0,
          value: 0
        },
        zIndex: c,
        fontWeight: "normal",
        whiteSpace: "normal",
        textAlign: "start",
        cursor: "auto",
        userSelect: "text",
        transformOrigin: "var(--arrow-x, 50%) var(--arrow-y, 50%)",
        "--antd-arrow-background-color": m,
        "&-rtl": {
          direction: "rtl"
        },
        "&-hidden": {
          display: "none"
        },
        [`${o}-content`]: {
          position: "relative"
        },
        [`${o}-inner`]: {
          backgroundColor: i,
          backgroundClip: "padding-box",
          borderRadius: s,
          boxShadow: p,
          padding: n
        },
        [`${o}-title`]: {
          minWidth: r,
          marginBottom: g,
          color: l,
          fontWeight: d,
          borderBottom: u,
          padding: a
        },
        [`${o}-inner-content`]: {
          color: e,
          padding: b
        }
      })
    },
    // Arrow Style
    $(t, "var(--antd-arrow-background-color)"),
    // Pure Render
    {
      [`${o}-pure`]: {
        position: "relative",
        maxWidth: "none",
        margin: t.sizePopupArrow,
        display: "inline-block",
        [`${o}-content`]: {
          display: "inline-block"
        }
      }
    }
  ];
}, k = (t) => {
  const {
    componentCls: o
  } = t;
  return {
    [o]: w.map((e) => {
      const r = t[`${e}6`];
      return {
        [`&${o}-${e}`]: {
          "--antd-arrow-background-color": r,
          [`${o}-inner`]: {
            backgroundColor: r
          },
          [`${o}-arrow`]: {
            background: "transparent"
          }
        }
      };
    })
  };
}, C = (t) => {
  const {
    lineWidth: o,
    controlHeight: e,
    fontHeight: r,
    padding: d,
    wireframe: n,
    zIndexPopupBase: p,
    borderRadiusLG: l,
    marginXS: s,
    lineType: c,
    colorSplit: g,
    paddingSM: m
  } = t, i = e - r, u = i / 2, b = i / 2 - o, a = d;
  return Object.assign(Object.assign(Object.assign({
    titleMinWidth: 177,
    zIndexPopup: p + 30
  }, P(t)), f({
    contentRadius: l,
    limitVerticalRadius: !0
  })), {
    // internal
    innerPadding: n ? 0 : 12,
    titleMarginBottom: n ? 0 : s,
    titlePadding: n ? `${u}px ${a}px ${b}px` : 0,
    titleBorderBottom: n ? `${o}px ${c} ${g}` : "none",
    innerContentPadding: n ? `${m}px ${a}px` : 0
  });
}, Z = B("Popover", (t) => {
  const {
    colorBgElevated: o,
    colorText: e
  } = t, r = v(t, {
    popoverBg: o,
    popoverColor: e
  });
  return [S(r), k(r), x(r, "zoom-big")];
}, C, {
  resetStyle: !1,
  deprecatedTokens: [["width", "titleMinWidth"], ["minWidth", "titleMinWidth"]]
});
export {
  Z as default,
  C as prepareComponentToken
};
