import * as __WEBPACK_EXTERNAL_MODULE__chakra_ui_react__ from "@chakra-ui/react";
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE_react_icons_md__ from "react-icons/md";
function CopyButton({ content, showLabel = false, showIcon = true, customLabel, iconSize = 18, ...props }) {
    const { hasCopied, onCopy, value, setValue } = (0, __WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.useClipboard)(content);
    // If content has changed, set the clipboard value
    (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
        if (value !== content) setValue(content);
    }, [
        content
    ]);
    return /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Button, {
        variant: "ghost-white",
        "data-testid": "copy-button",
        size: "1rem",
        p: 1.5,
        fontSize: "xs",
        ...props,
        onClick: (event)=>{
            onCopy();
            props.onClick?.(event);
        },
        "aria-label": hasCopied ? 'Copied' : customLabel || 'Copy'
    }, hasCopied ? /*#__PURE__*/ React.createElement(React.Fragment, null, showIcon && /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE_react_icons_md__.MdOutlineCheck, {
        size: iconSize
    }), showLabel && /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.chakra.span, {
        ml: 1
    }, "Copied")) : /*#__PURE__*/ React.createElement(React.Fragment, null, showIcon && /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE_react_icons_md__.MdContentCopy, {
        size: iconSize
    }), showLabel && /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.chakra.span, {
        ml: 1
    }, customLabel || 'Copy')));
}
/* ESM default export */ const CopyButton_rslib_entry_ = CopyButton;
export { CopyButton_rslib_entry_ as default };
