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