import { t as e } from "../../utils-B7XIe3qq.js";
import { t } from "../../dist-BCCeHAQm.js";
import { t as n } from "../../check-CybgTpDT.js";
import { t as r } from "../../copy-Hv8btfHH.js";
import * as i from "react";
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
//#region src/react/primitives/copy-button.tsx
var c = t("inline-flex items-center justify-center gap-2 rounded-xl text-[13px] font-semibold transition-all duration-250 cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=\"size-\"])]:size-4", {
	variants: {
		variant: {
			default: "border border-border-glass bg-glass text-foreground hover:bg-glass-hover hover:border-primary backdrop-blur-[20px]",
			ghost: "hover:bg-glass-hover text-foreground-secondary hover:text-foreground"
		},
		size: {
			default: "h-8 px-3",
			sm: "h-7 px-2 text-[12px]",
			icon: "size-8",
			"icon-sm": "size-7"
		}
	},
	defaultVariants: {
		variant: "default",
		size: "default"
	}
});
function l({ className: t, variant: l, size: u, value: d, label: f = "Copy", copiedLabel: p = "Copied!", copiedDuration: m = 2e3, onCopy: h, iconOnly: g = !1, ..._ }) {
	let [v, y] = i.useState(!1), b = i.useRef(null);
	i.useEffect(() => () => {
		b.current && clearTimeout(b.current);
	}, []);
	let x = i.useCallback(() => {
		navigator.clipboard.writeText(d).then(() => {
			y(!0), h?.(), b.current && clearTimeout(b.current), b.current = setTimeout(() => {
				y(!1), b.current = null;
			}, m);
		}).catch(() => {});
	}, [
		d,
		m,
		h
	]);
	return /* @__PURE__ */ o("button", {
		"data-slot": "copy-button",
		"data-copied": v || void 0,
		type: "button",
		className: e(c({
			variant: l,
			size: g ? "icon" : u
		}), v && "text-accent-cyan border-accent-cyan/30", t),
		onClick: x,
		"aria-label": g ? v ? p : f : void 0,
		..._,
		children: v ? /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o(n, { className: "size-3.5" }), !g && /* @__PURE__ */ o("span", { children: p })] }) : /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o(r, { className: "size-3.5" }), !g && /* @__PURE__ */ o("span", { children: f })] })
	});
}
//#endregion
export { l as CopyButton, c as copyButtonVariants };

//# sourceMappingURL=copy-button.js.map