import { jsx as _jsx } from "react/jsx-runtime";
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { IconButton } from '../../basic';
export default function AppClipboard({ text, size = 'x-small' }) {
    const { t } = useTranslation('common');
    const [copied, setCopied] = useState(false);
    const handleCopy = () => {
        navigator.clipboard
            .writeText(text)
            .then(() => {
            setCopied(true);
            setTimeout(() => {
                setCopied(false);
            }, 2000);
        })
            .catch((err) => {
            console.error('Failed to copy text:', err);
        });
    };
    const tooltipTitle = copied ? t('tooltip.copied') : t('tooltip.copy');
    return (_jsx(IconButton, { name: "content_copy", title: tooltipTitle, onClick: handleCopy, size: size }));
}
