import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Icon } from "@powerhousedao/design-system";
import { useCopyToClipboard } from "usehooks-ts";
import { formatEthAddress } from "../../../utils/address.js";
import { ENSAvatar } from "../../ens-avatar/ens-avatar.js";
import { ConnectTooltip } from "../../tooltip/tooltip.js";
export function Address(props) {
    const { address, chainId } = props;
    const [, copy] = useCopyToClipboard();
    if (!address)
        return null;
    const shortenedAddress = formatEthAddress(address);
    function handleCopy(text) {
        return () => {
            copy(text).catch((error) => {
                console.error("Failed to copy!", error);
            });
        };
    }
    const tooltipContent = (_jsxs("button", { className: "flex items-center gap-1", onClick: handleCopy(address), children: [address, _jsx(Icon, { className: "inline-block text-gray-600", name: "FilesEarmark", size: 16 })] }));
    return (_jsx(ConnectTooltip, { content: tooltipContent, children: _jsxs("span", { className: "flex w-fit cursor-pointer items-center gap-1 rounded-lg bg-gray-100 p-1 text-xs text-slate-100", children: [_jsx(ENSAvatar, { address: address, chainId: chainId }), shortenedAddress] }) }));
}
//# sourceMappingURL=address.js.map