import { resetComponent as t, genFocusStyle as n } from "../../style/index.mjs";
import { initFadeMotion as l } from "../../style/motion/fade.mjs";
import { initZoomMotion as g } from "../../style/motion/zoom.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 i } 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 c } from "../../theme/util/genComponentStyleHook.mjs";
import { merge as m } from "../../theme/util/statistic.mjs";
function a(o) {
  return {
    position: o,
    inset: 0
  };
}
const p = (o) => {
  const {
    componentCls: r,
    antCls: e
  } = o;
  return [{
    [`${r}-root`]: {
      [`${r}${e}-zoom-enter, ${r}${e}-zoom-appear`]: {
        // reset scale avoid mousePosition bug
        transform: "none",
        opacity: 0,
        animationDuration: o.motionDurationSlow,
        // https://github.com/ant-design/ant-design/issues/11777
        userSelect: "none"
      },
      // https://github.com/ant-design/ant-design/issues/37329
      // https://github.com/ant-design/ant-design/issues/40272
      [`${r}${e}-zoom-leave ${r}-content`]: {
        pointerEvents: "none"
      },
      [`${r}-mask`]: Object.assign(Object.assign({}, a("fixed")), {
        zIndex: o.zIndexPopupBase,
        height: "100%",
        backgroundColor: o.colorBgMask,
        pointerEvents: "none",
        [`${r}-hidden`]: {
          display: "none"
        }
      }),
      [`${r}-wrap`]: Object.assign(Object.assign({}, a("fixed")), {
        zIndex: o.zIndexPopupBase,
        overflow: "auto",
        outline: 0,
        WebkitOverflowScrolling: "touch",
        // Note: Firefox not support `:has` yet
        [`&:has(${r}${e}-zoom-enter), &:has(${r}${e}-zoom-appear)`]: {
          pointerEvents: "none"
        }
      })
    }
  }, {
    [`${r}-root`]: l(o)
  }];
}, s = (o) => {
  const {
    componentCls: r
  } = o;
  return [
    // ======================== Root =========================
    {
      [`${r}-root`]: {
        [`${r}-wrap-rtl`]: {
          direction: "rtl"
        },
        [`${r}-centered`]: {
          textAlign: "center",
          "&::before": {
            display: "inline-block",
            width: 0,
            height: "100%",
            verticalAlign: "middle",
            content: '""'
          },
          [r]: {
            top: 0,
            display: "inline-block",
            paddingBottom: 0,
            textAlign: "start",
            verticalAlign: "middle"
          }
        },
        [`@media (max-width: ${o.screenSMMax}px)`]: {
          [r]: {
            maxWidth: "calc(100vw - 16px)",
            margin: `${i(o.marginXS)} auto`
          },
          [`${r}-centered`]: {
            [r]: {
              flex: 1
            }
          }
        }
      }
    },
    // ======================== Modal ========================
    {
      [r]: Object.assign(Object.assign({}, t(o)), {
        pointerEvents: "none",
        position: "relative",
        top: 100,
        width: "auto",
        maxWidth: `calc(100vw - ${i(o.calc(o.margin).mul(2).equal())})`,
        margin: "0 auto",
        paddingBottom: o.paddingLG,
        [`${r}-title`]: {
          margin: 0,
          color: o.titleColor,
          fontWeight: o.fontWeightStrong,
          fontSize: o.titleFontSize,
          lineHeight: o.titleLineHeight,
          wordWrap: "break-word"
        },
        [`${r}-content`]: {
          position: "relative",
          backgroundColor: o.contentBg,
          backgroundClip: "padding-box",
          border: 0,
          borderRadius: o.borderRadiusLG,
          boxShadow: o.boxShadow,
          pointerEvents: "auto",
          padding: o.contentPadding
        },
        [`${r}-close`]: Object.assign({
          position: "absolute",
          top: o.calc(o.modalHeaderHeight).sub(o.modalCloseBtnSize).div(2).equal(),
          insetInlineEnd: o.calc(o.modalHeaderHeight).sub(o.modalCloseBtnSize).div(2).equal(),
          zIndex: o.calc(o.zIndexPopupBase).add(10).equal(),
          padding: 0,
          color: o.modalCloseIconColor,
          fontWeight: o.fontWeightStrong,
          lineHeight: 1,
          textDecoration: "none",
          background: "transparent",
          borderRadius: o.borderRadiusSM,
          width: o.modalCloseBtnSize,
          height: o.modalCloseBtnSize,
          border: 0,
          outline: 0,
          cursor: "pointer",
          transition: `color ${o.motionDurationMid}, background-color ${o.motionDurationMid}`,
          "&-x": {
            display: "flex",
            fontSize: o.fontSizeLG,
            fontStyle: "normal",
            lineHeight: `${i(o.modalCloseBtnSize)}`,
            justifyContent: "center",
            textTransform: "none",
            textRendering: "auto"
          },
          "&:hover": {
            color: o.modalIconHoverColor,
            backgroundColor: o.closeBtnHoverBg,
            textDecoration: "none"
          },
          "&:active": {
            backgroundColor: o.closeBtnActiveBg
          }
        }, n(o)),
        [`${r}-header`]: {
          color: o.colorText,
          background: o.headerBg,
          borderRadius: `${i(o.borderRadiusLG)} ${i(o.borderRadiusLG)} 0 0`,
          marginBottom: o.headerMarginBottom,
          padding: o.headerPadding,
          borderBottom: o.headerBorderBottom
        },
        [`${r}-body`]: {
          fontSize: o.fontSize,
          lineHeight: o.lineHeight,
          wordWrap: "break-word",
          padding: o.bodyPadding
        },
        [`${r}-footer`]: {
          textAlign: "end",
          background: o.footerBg,
          marginTop: o.footerMarginTop,
          padding: o.footerPadding,
          borderTop: o.footerBorderTop,
          borderRadius: o.footerBorderRadius,
          [`${o.antCls}-btn + ${o.antCls}-btn:not(${o.antCls}-dropdown-trigger)`]: {
            marginBottom: 0,
            marginInlineStart: o.marginXS
          }
        },
        [`${r}-open`]: {
          overflow: "hidden"
        }
      })
    },
    // ======================== Pure =========================
    {
      [`${r}-pure-panel`]: {
        top: "auto",
        padding: 0,
        display: "flex",
        flexDirection: "column",
        [`${r}-content,
          ${r}-body,
          ${r}-confirm-body-wrapper`]: {
          display: "flex",
          flexDirection: "column",
          flex: "auto"
        },
        [`${r}-confirm-body`]: {
          marginBottom: "auto"
        }
      }
    }
  ];
}, u = (o) => {
  const {
    componentCls: r
  } = o;
  return {
    [`${r}-root`]: {
      [`${r}-wrap-rtl`]: {
        direction: "rtl",
        [`${r}-confirm-body`]: {
          direction: "rtl"
        }
      }
    }
  };
}, f = (o) => {
  const r = o.padding, e = o.fontSizeHeading5, d = o.lineHeightHeading5;
  return m(o, {
    modalHeaderHeight: o.calc(o.calc(d).mul(e).equal()).add(o.calc(r).mul(2).equal()).equal(),
    modalFooterBorderColorSplit: o.colorSplit,
    modalFooterBorderStyle: o.lineType,
    modalFooterBorderWidth: o.lineWidth,
    modalIconHoverColor: o.colorIconHover,
    modalCloseIconColor: o.colorIcon,
    modalCloseBtnSize: o.fontHeight,
    modalConfirmIconSize: o.fontHeight,
    modalTitleHeight: o.calc(o.titleFontSize).mul(o.titleLineHeight).equal()
  });
}, $ = (o) => ({
  footerBg: "transparent",
  headerBg: o.colorBgElevated,
  titleLineHeight: o.lineHeightHeading5,
  titleFontSize: o.fontSizeHeading5,
  contentBg: o.colorBgElevated,
  titleColor: o.colorTextHeading,
  // internal
  closeBtnHoverBg: o.wireframe ? "transparent" : o.colorFillContent,
  closeBtnActiveBg: o.wireframe ? "transparent" : o.colorFillContentHover,
  contentPadding: o.wireframe ? 0 : `${i(o.paddingMD)} ${i(o.paddingContentHorizontalLG)}`,
  headerPadding: o.wireframe ? `${i(o.padding)} ${i(o.paddingLG)}` : 0,
  headerBorderBottom: o.wireframe ? `${i(o.lineWidth)} ${o.lineType} ${o.colorSplit}` : "none",
  headerMarginBottom: o.wireframe ? 0 : o.marginXS,
  bodyPadding: o.wireframe ? o.paddingLG : 0,
  footerPadding: o.wireframe ? `${i(o.paddingXS)} ${i(o.padding)}` : 0,
  footerBorderTop: o.wireframe ? `${i(o.lineWidth)} ${o.lineType} ${o.colorSplit}` : "none",
  footerBorderRadius: o.wireframe ? `0 0 ${i(o.borderRadiusLG)} ${i(o.borderRadiusLG)}` : 0,
  footerMarginTop: o.wireframe ? 0 : o.marginSM,
  confirmBodyPadding: o.wireframe ? `${i(o.padding * 2)} ${i(o.padding * 2)} ${i(o.paddingLG)}` : 0,
  confirmIconMarginInlineEnd: o.wireframe ? o.margin : o.marginSM,
  confirmBtnsMarginTop: o.wireframe ? o.marginLG : o.marginSM
}), G = c("Modal", (o) => {
  const r = f(o);
  return [s(r), u(r), p(r), g(r, "zoom")];
}, $, {
  unitless: {
    titleLineHeight: !0
  }
});
export {
  G as default,
  p as genModalMaskStyle,
  $ as prepareComponentToken,
  f as prepareToken
};
