import { jsx as i } from "react/jsx-runtime";
import S, { useState as B, useCallback as I } from "react";
import b from "@mui/icons-material/ContentCopy";
import M from "@mui/icons-material/Check";
import g from "@mui/material/IconButton";
import R from "@mui/material/CircularProgress";
import { toBorderRadius as k, toMuiSize as w, toMuiColor as z } from "./types.js";
const p = S.forwardRef(function({
  children: t,
  color: n = "neutral",
  emphasis: r,
  size: o = "sm",
  shape: c = "rounded",
  loading: e = !1,
  disabled: u,
  onClick: d,
  title: f,
  sx: a,
  ...C
}, y) {
  const h = z(n), x = w(o), m = {
    xs: 24,
    sm: 32,
    md: 40,
    lg: 48,
    xl: 56
  }, l = {
    xs: 14,
    sm: 18,
    md: 22,
    lg: 26,
    xl: 30
  };
  return /* @__PURE__ */ i(
    g,
    {
      ref: y,
      color: h,
      size: x,
      disabled: u || e,
      onClick: d,
      title: f,
      sx: {
        borderRadius: k(c),
        width: m[o],
        height: m[o],
        fontSize: l[o],
        ...typeof a == "object" && !Array.isArray(a) ? a : {}
      },
      ...C,
      children: e ? /* @__PURE__ */ i(R, { size: l[o] - 4, color: "inherit" }) : t
    }
  );
});
p.displayName = "IconButton";
function j({ value: s, size: t = "sm", label: n }) {
  const [r, o] = B(!1), c = I(() => {
    navigator.clipboard.writeText(s).then(() => {
      o(!0), setTimeout(() => o(!1), 1500);
    });
  }, [s]), e = t === "xs" ? 12 : t === "sm" ? 14 : t === "md" ? 16 : 18;
  return /* @__PURE__ */ i(
    p,
    {
      size: t,
      color: r ? "success" : "neutral",
      onClick: c,
      "aria-label": n ?? (r ? "Copied" : "Copy to clipboard"),
      title: n ?? (r ? "Copied!" : "Copy"),
      children: r ? /* @__PURE__ */ i(M, { sx: { fontSize: e } }) : /* @__PURE__ */ i(b, { sx: { fontSize: e } })
    }
  );
}
j.displayName = "CopyButton";
export {
  j as C,
  p as I
};
