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 u } 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 { genFocusStyle as y } from "../../style/index.mjs";
import { genStyleHooks as B } from "../../theme/util/genComponentStyleHook.mjs";
import { merge as a } from "../../theme/util/statistic.mjs";
import $ from "./group.mjs";
const O = (o) => {
  const {
    componentCls: r,
    iconCls: l,
    fontWeight: i
  } = o;
  return {
    [r]: {
      outline: "none",
      position: "relative",
      display: "inline-block",
      fontWeight: i,
      whiteSpace: "nowrap",
      textAlign: "center",
      backgroundImage: "none",
      background: "transparent",
      border: `${u(o.lineWidth)} ${o.lineType} transparent`,
      cursor: "pointer",
      transition: `all ${o.motionDurationMid} ${o.motionEaseInOut}`,
      userSelect: "none",
      touchAction: "manipulation",
      lineHeight: o.lineHeight,
      color: o.colorText,
      "&:disabled > *": {
        pointerEvents: "none"
      },
      "> span": {
        display: "inline-block"
      },
      [`${r}-icon`]: {
        lineHeight: 0
      },
      // Leave a space between icon and text.
      [`> ${l} + span, > span + ${l}`]: {
        marginInlineStart: o.marginXS
      },
      [`&:not(${r}-icon-only) > ${r}-icon`]: {
        [`&${r}-loading-icon, &:not(:last-child)`]: {
          marginInlineEnd: o.marginXS
        }
      },
      "> a": {
        color: "currentColor"
      },
      "&:not(:disabled)": Object.assign({}, y(o)),
      [`&${r}-two-chinese-chars::first-letter`]: {
        letterSpacing: "0.34em"
      },
      [`&${r}-two-chinese-chars > *:not(${l})`]: {
        marginInlineEnd: "-0.34em",
        letterSpacing: "0.34em"
      },
      // make `btn-icon-only` not too narrow
      [`&-icon-only${r}-compact-item`]: {
        flex: "none"
      }
    }
  };
}, n = (o, r, l) => ({
  [`&:not(:disabled):not(${o}-disabled)`]: {
    "&:hover": r,
    "&:active": l
  }
}), H = (o) => ({
  minWidth: o.controlHeight,
  paddingInlineStart: 0,
  paddingInlineEnd: 0,
  borderRadius: "50%"
}), f = (o) => ({
  borderRadius: o.controlHeight,
  paddingInlineStart: o.calc(o.controlHeight).div(2).equal(),
  paddingInlineEnd: o.calc(o.controlHeight).div(2).equal()
}), v = (o) => ({
  cursor: "not-allowed",
  borderColor: o.borderColorDisabled,
  color: o.colorTextDisabled,
  background: o.colorBgContainerDisabled,
  boxShadow: "none"
}), c = (o, r, l, i, t, d, s, g) => ({
  [`&${o}-background-ghost`]: Object.assign(Object.assign({
    color: l || void 0,
    background: r,
    borderColor: i || void 0,
    boxShadow: "none"
  }, n(o, Object.assign({
    background: r
  }, s), Object.assign({
    background: r
  }, g))), {
    "&:disabled": {
      cursor: "not-allowed",
      color: t || void 0,
      borderColor: d || void 0
    }
  })
}), b = (o) => ({
  [`&:disabled, &${o.componentCls}-disabled`]: Object.assign({}, v(o))
}), S = (o) => Object.assign({}, b(o)), e = (o) => ({
  [`&:disabled, &${o.componentCls}-disabled`]: {
    cursor: "not-allowed",
    color: o.colorTextDisabled
  }
}), m = (o) => Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, S(o)), {
  background: o.defaultBg,
  borderColor: o.defaultBorderColor,
  color: o.defaultColor,
  boxShadow: o.defaultShadow
}), n(o.componentCls, {
  color: o.colorPrimaryHover,
  borderColor: o.colorPrimaryHover
}, {
  color: o.colorPrimaryActive,
  borderColor: o.colorPrimaryActive
})), c(o.componentCls, o.ghostBg, o.defaultGhostColor, o.defaultGhostBorderColor, o.colorTextDisabled, o.colorBorder)), {
  [`&${o.componentCls}-dangerous`]: Object.assign(Object.assign(Object.assign({
    color: o.colorError,
    borderColor: o.colorError
  }, n(o.componentCls, {
    color: o.colorErrorHover,
    borderColor: o.colorErrorBorderHover
  }, {
    color: o.colorErrorActive,
    borderColor: o.colorErrorActive
  })), c(o.componentCls, o.ghostBg, o.colorError, o.colorError, o.colorTextDisabled, o.colorBorder)), b(o))
}), z = (o) => Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, S(o)), {
  color: o.primaryColor,
  background: o.colorPrimary,
  boxShadow: o.primaryShadow
}), n(o.componentCls, {
  color: o.colorTextLightSolid,
  background: o.colorPrimaryHover
}, {
  color: o.colorTextLightSolid,
  background: o.colorPrimaryActive
})), c(o.componentCls, o.ghostBg, o.colorPrimary, o.colorPrimary, o.colorTextDisabled, o.colorBorder, {
  color: o.colorPrimaryHover,
  borderColor: o.colorPrimaryHover
}, {
  color: o.colorPrimaryActive,
  borderColor: o.colorPrimaryActive
})), {
  [`&${o.componentCls}-dangerous`]: Object.assign(Object.assign(Object.assign({
    background: o.colorError,
    boxShadow: o.dangerShadow,
    color: o.dangerColor
  }, n(o.componentCls, {
    background: o.colorErrorHover
  }, {
    background: o.colorErrorActive
  })), c(o.componentCls, o.ghostBg, o.colorError, o.colorError, o.colorTextDisabled, o.colorBorder, {
    color: o.colorErrorHover,
    borderColor: o.colorErrorHover
  }, {
    color: o.colorErrorActive,
    borderColor: o.colorErrorActive
  })), b(o))
}), x = (o) => Object.assign(Object.assign({}, m(o)), {
  borderStyle: "dashed"
}), j = (o) => Object.assign(Object.assign(Object.assign({
  color: o.colorLink
}, n(o.componentCls, {
  color: o.colorLinkHover,
  background: o.linkHoverBg
}, {
  color: o.colorLinkActive
})), e(o)), {
  [`&${o.componentCls}-dangerous`]: Object.assign(Object.assign({
    color: o.colorError
  }, n(o.componentCls, {
    color: o.colorErrorHover
  }, {
    color: o.colorErrorActive
  })), e(o))
}), E = (o) => Object.assign(Object.assign(Object.assign({}, n(o.componentCls, {
  color: o.colorText,
  background: o.textHoverBg
}, {
  color: o.colorText,
  background: o.colorBgTextActive
})), e(o)), {
  [`&${o.componentCls}-dangerous`]: Object.assign(Object.assign({
    color: o.colorError
  }, e(o)), n(o.componentCls, {
    color: o.colorErrorHover,
    background: o.colorErrorBg
  }, {
    color: o.colorErrorHover,
    background: o.colorErrorBg
  }))
}), I = (o) => {
  const {
    componentCls: r
  } = o;
  return {
    [`${r}-default`]: m(o),
    [`${r}-primary`]: z(o),
    [`${r}-dashed`]: x(o),
    [`${r}-link`]: j(o),
    [`${r}-text`]: E(o),
    [`${r}-ghost`]: c(o.componentCls, o.ghostBg, o.colorBgContainer, o.colorBgContainer, o.colorTextDisabled, o.colorBorder)
  };
}, p = function(o) {
  let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
  const {
    componentCls: l,
    controlHeight: i,
    fontSize: t,
    borderRadius: d,
    buttonPaddingHorizontal: s,
    iconCls: g,
    buttonPaddingVertical: h
  } = o, C = `${l}-icon-only`;
  return [
    // Size
    {
      [`${l}${r}`]: {
        fontSize: t,
        height: i,
        padding: `${u(h)} ${u(s)}`,
        borderRadius: d,
        [`&${C}`]: {
          width: i,
          paddingInlineStart: 0,
          paddingInlineEnd: 0,
          [`&${l}-round`]: {
            width: "auto"
          },
          [g]: {
            fontSize: o.buttonIconOnlyFontSize
          }
        },
        // Loading
        [`&${l}-loading`]: {
          opacity: o.opacityLoading,
          cursor: "default"
        },
        [`${l}-loading-icon`]: {
          transition: `width ${o.motionDurationSlow} ${o.motionEaseInOut}, opacity ${o.motionDurationSlow} ${o.motionEaseInOut}`
        }
      }
    },
    // Shape - patch prefixCls again to override solid border radius style
    {
      [`${l}${l}-circle${r}`]: H(o)
    },
    {
      [`${l}${l}-round${r}`]: f(o)
    }
  ];
}, T = (o) => p(a(o, {
  fontSize: o.contentFontSize
})), L = (o) => {
  const r = a(o, {
    controlHeight: o.controlHeightSM,
    fontSize: o.contentFontSizeSM,
    padding: o.paddingXS,
    buttonPaddingHorizontal: o.paddingInlineSM,
    buttonPaddingVertical: o.paddingBlockSM,
    borderRadius: o.borderRadiusSM,
    buttonIconOnlyFontSize: o.onlyIconSizeSM
  });
  return p(r, `${o.componentCls}-sm`);
}, P = (o) => {
  const r = a(o, {
    controlHeight: o.controlHeightLG,
    fontSize: o.contentFontSizeLG,
    buttonPaddingHorizontal: o.paddingInlineLG,
    buttonPaddingVertical: o.paddingBlockLG,
    borderRadius: o.borderRadiusLG,
    buttonIconOnlyFontSize: o.onlyIconSizeLG
  });
  return p(r, `${o.componentCls}-lg`);
}, w = (o) => {
  const {
    componentCls: r
  } = o;
  return {
    [r]: {
      [`&${r}-block`]: {
        width: "100%"
      }
    }
  };
}, G = (o) => {
  const {
    paddingInline: r,
    onlyIconSize: l,
    paddingBlock: i
  } = o;
  return a(o, {
    buttonPaddingHorizontal: r,
    buttonPaddingVertical: i,
    buttonIconOnlyFontSize: l
  });
}, D = (o) => {
  const r = o.fontSize, l = o.fontSize, i = o.fontSizeLG;
  return {
    fontWeight: 400,
    defaultShadow: `0 ${o.controlOutlineWidth}px 0 ${o.controlTmpOutline}`,
    primaryShadow: `0 ${o.controlOutlineWidth}px 0 ${o.controlOutline}`,
    dangerShadow: `0 ${o.controlOutlineWidth}px 0 ${o.colorErrorOutline}`,
    primaryColor: o.colorTextLightSolid,
    dangerColor: o.colorTextLightSolid,
    borderColorDisabled: o.colorBorder,
    defaultGhostColor: o.colorBgContainer,
    ghostBg: "transparent",
    defaultGhostBorderColor: o.colorBgContainer,
    paddingInline: o.paddingContentHorizontal - o.lineWidth,
    paddingInlineLG: o.paddingContentHorizontal - o.lineWidth,
    paddingInlineSM: 8 - o.lineWidth,
    paddingBlock: Math.max((o.controlHeight - r * o.lineHeight) / 2 - o.lineWidth, 0),
    paddingBlockSM: Math.max((o.controlHeightSM - l * o.lineHeight) / 2 - o.lineWidth, 0),
    paddingBlockLG: Math.max((o.controlHeightLG - i * o.lineHeight) / 2 - o.lineWidth, 0),
    onlyIconSize: o.fontSizeLG,
    onlyIconSizeSM: o.fontSizeLG - 2,
    onlyIconSizeLG: o.fontSizeLG + 2,
    groupBorderColor: o.colorPrimaryHover,
    linkHoverBg: "transparent",
    textHoverBg: o.colorBgTextHover,
    defaultColor: o.colorText,
    defaultBg: o.colorBgContainer,
    defaultBorderColor: o.colorBorder,
    defaultBorderColorDisabled: o.colorBorder,
    contentFontSize: r,
    contentFontSizeSM: l,
    contentFontSizeLG: i
  };
}, k = B("Button", (o) => {
  const r = G(o);
  return [
    // Shared
    O(r),
    // Size
    L(r),
    T(r),
    P(r),
    // Block
    w(r),
    // Group (type, ghost, danger, loading)
    I(r),
    // Button Group
    $(r)
  ];
}, D, {
  unitless: {
    fontWeight: !0
  }
});
export {
  k as default,
  D as prepareComponentToken,
  G as prepareToken
};
