"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TransactionHash = void 0;
const react_1 = __importStar(require("react"));
const react_copy_to_clipboard_1 = __importDefault(require("react-copy-to-clipboard"));
const Flex_1 = require("../Flex");
const Box_1 = require("../Box");
const Text_1 = require("../Text");
const TextEllipsis_1 = require("../TextEllipsis");
const Link_1 = require("../Link");
const Icon_1 = require("../Icon");
const icons_1 = require("../../assets/images/icons");
const styles_1 = require("../../styles");
exports.TransactionHash = ({ hash = '', copyLink, link, size, flexProps, variant = 'primary', buttonProps, }) => {
    const [copied, setCopied] = react_1.useState(false);
    const isPrimary = variant === 'primary';
    const handleCopyClick = () => {
        setCopied(true);
        setTimeout(() => {
            setCopied(false);
        }, 2000);
    };
    return (react_1.default.createElement(Flex_1.Flex, Object.assign({}, flexProps),
        react_1.default.createElement(Box_1.Box, Object.assign({ borderRadius: "2", px: "1", mr: "s" }, (isPrimary ? { bg: 'brandLightest' } : {})),
            react_1.default.createElement(Text_1.Text, { fontSize: "0", color: "brandMain" }, size ? react_1.default.createElement(TextEllipsis_1.TextEllipsis, { size: size }, hash) : hash)),
        react_1.default.createElement(CopyButton, { text: copyLink && link ? link : hash },
            react_1.default.createElement(CopyIcon, Object.assign({}, (buttonProps && buttonProps.copyId
                ? { id: buttonProps.copyId }
                : {}), { Asset: icons_1.SvgCopy, width: 14, height: 14, color: "gray.2", onClick: handleCopyClick, copied: copied }))),
        link && (react_1.default.createElement(Link_1.Link, Object.assign({}, (buttonProps && buttonProps.linkId
            ? { id: buttonProps.linkId }
            : {}), { href: link }),
            react_1.default.createElement(Icon_1.Icon, { Asset: icons_1.SvgShare, width: 12, height: 12, color: "gray.2", ml: "s" })))));
};
const CopyButton = styles_1.styled(react_copy_to_clipboard_1.default) `
  cursor: pointer;
`;
const CopyIcon = styles_1.styled(Icon_1.Icon) `
  position: relative;

  &::after {
    content: 'Copied';
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    padding: 5px;
    background-color: rgba(0, 0, 0, 0.7);
    color: #ffffff;
    border-radius: 8px;
    font-size: 9px;
    font-weight: bold;
    pointer-events: none;
    opacity: ${(props) => (props.copied ? 1 : 0)};
    transition: opacity 0.3s;
  }
`;
//# sourceMappingURL=TransactionHash.js.map