import e, { useContext as Q } from "react";
import V from "../../../@ant-design/icons/es/icons/ReloadOutlined.mjs";
import k from "../../../classnames/index.mjs";
import { QRCodeCanvas as _, QRCodeSVG as L } from "../../../qrcode.react/lib/esm/index.mjs";
import { devUseWarning as j } from "../_util/warning.mjs";
import D from "../button/button.mjs";
import "../config-provider/index.mjs";
import $ from "../spin/index.mjs";
import "../../../@ant-design/cssinjs/es/extractStyle.mjs";
import "../../../@ant-design/cssinjs/es/hooks/useCacheToken.mjs";
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 z from "../theme/useToken.mjs";
import P from "./style/index.mjs";
import { ConfigContext as q } from "../config-provider/context.mjs";
import T from "../locale/useLocale.mjs";
const u = (f) => {
  const [, g] = z(), {
    value: r,
    type: v = "canvas",
    icon: i = "",
    size: n = 160,
    iconSize: a = 40,
    color: C = g.colorText,
    errorLevel: l = "M",
    status: s = "active",
    bordered: E = !0,
    onRefresh: c,
    style: N,
    className: h,
    rootClassName: x,
    prefixCls: b,
    bgColor: m = "transparent"
  } = f, {
    getPrefixCls: R
  } = Q(q), t = R("qrcode", b), [y, O, S] = P(t), d = {
    value: r,
    size: n,
    level: l,
    bgColor: m,
    fgColor: C,
    style: {
      width: void 0,
      height: void 0
    },
    imageSettings: i ? {
      src: i,
      x: void 0,
      y: void 0,
      height: a,
      width: a,
      excavate: !0
    } : void 0
  }, [o] = T("QRCode");
  if (process.env.NODE_ENV !== "production") {
    const p = j("QRCode");
    process.env.NODE_ENV !== "production" && p(!!r, "usage", "need to receive `value` props"), process.env.NODE_ENV !== "production" && p(!(i && l === "L"), "usage", "ErrorLevel `L` is not recommended to be used with `icon`, for scanning result would be affected by low level.");
  }
  if (!r)
    return null;
  const w = k(t, h, x, O, S, {
    [`${t}-borderless`]: !E
  });
  return y(/* @__PURE__ */ e.createElement("div", {
    className: w,
    style: Object.assign(Object.assign({}, N), {
      width: n,
      height: n,
      backgroundColor: m
    })
  }, s !== "active" && /* @__PURE__ */ e.createElement("div", {
    className: `${t}-mask`
  }, s === "loading" && /* @__PURE__ */ e.createElement($, null), s === "expired" && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("p", {
    className: `${t}-expired`
  }, o == null ? void 0 : o.expired), c && /* @__PURE__ */ e.createElement(D, {
    type: "link",
    icon: /* @__PURE__ */ e.createElement(V, null),
    onClick: c
  }, o == null ? void 0 : o.refresh))), v === "canvas" ? /* @__PURE__ */ e.createElement(_, Object.assign({}, d)) : /* @__PURE__ */ e.createElement(L, Object.assign({}, d))));
};
process.env.NODE_ENV !== "production" && (u.displayName = "QRCode");
const ce = u;
export {
  ce as default
};
