"use client";
import { jsxs, jsx } from "../../packages/jsx/src/jsx-runtime.js";
import { forwardRef, useState } from "react";
import { ButtonBase } from "./ButtonBase.js";
import { Icon } from "../../atoms/Icon/Icon.js";
const ButtonCopy = forwardRef(
  ({ value, children, onClick: onClickOriginal, ...props }, ref) => {
    const [isCopied, setIsCopied] = useState(false);
    const onClick = async (event) => {
      await navigator.clipboard.writeText(value);
      setIsCopied(true);
      setTimeout(() => setIsCopied(false), 2e3);
      onClickOriginal == null ? void 0 : onClickOriginal(event);
    };
    return /* @__PURE__ */ jsxs(
      ButtonBase,
      {
        ref,
        variant: "secondary",
        size: "small",
        shape: children ? "default" : "round",
        status: isCopied ? "success" : void 0,
        onClick: (event) => {
          void onClick(event);
        },
        sx: { width: "fit-content" },
        ...props,
        children: [
          children,
          /* @__PURE__ */ jsx(Icon.Copy, {})
        ]
      }
    );
  }
);
ButtonCopy.displayName = "Button.Copy";
export {
  ButtonCopy
};
