Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const require_chunk = require("../chunk-BN4qSVkS.cjs");
const require_components_Icon_Icon = require("./Icon/Icon.cjs");
const require_components_Tooltip = require("./Tooltip.cjs");
const require_components_UnstyledButton = require("./UnstyledButton.cjs");
let _emotion_styled = require("@emotion/styled");
_emotion_styled = require_chunk.__toESM(_emotion_styled);
let react = require("react");
react = require_chunk.__toESM(react);
let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
let nanoid = require("nanoid");
//#region src/components/CopyToClipboardButton.tsx
const CopyToClipboardButton = (props) => {
	const originalTooltipContent = props.tooltipContent || "Click to copy";
	const icon = props.icon || "Copy";
	const id = `copy-node-name-${props.id ?? (0, nanoid.nanoid)()}`;
	const [tooltipContent, setTooltipContent] = (0, react.useState)(originalTooltipContent);
	return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)(_emotion_react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)(Button, {
		type: "button",
		onClick: () => {
			(async () => {
				try {
					await navigator.clipboard.writeText(props.value);
					setTooltipContent("Copied!");
				} catch {
					setTooltipContent("Unable to copy");
				}
				setTimeout(() => {
					setTooltipContent(originalTooltipContent);
				}, 2e3);
			})();
		},
		css: props.buttonCSS,
		ml: props.ml,
		"data-tooltip-id": id,
		children: [props.children ? /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(Children, { children: props.children }) : null, /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_components_Icon_Icon.Icon, {
			name: icon,
			width: props.isSm ? 12 : 16
		})]
	}), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_components_Tooltip.Tooltip, {
		id,
		place: props.place || "right",
		content: tooltipContent
	})] });
};
const Children = _emotion_styled.default.span`
  margin-right: 4px;
`;
const Button = (0, _emotion_styled.default)(require_components_UnstyledButton.UnstyledButton)`
  background: rgba(0, 0, 0, 0);
  vertical-align: middle;
  ${({ ml }) => ml ? `margin-left: ${ml}px` : ""};
`;
//#endregion
exports.CopyToClipboardButton = CopyToClipboardButton;
