"use strict";
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
    if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
    return cooked;
};
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = __importStar(require("react"));
var styled_components_1 = __importDefault(require("styled-components"));
var styleConstants_1 = require("./styleConstants");
var Button_1 = require("./Button");
var Box = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n  border: 1px solid ", ";\n  border-right: none;\n  background-color: ", ";\n  padding: 9px;\n  font-size: 14px;\n  white-space: nowrap;\n  overflow: hidden;\n  text-overflow: ellipsis;\n  width: calc(100% - 21px);\n"], ["\n  border: 1px solid ", ";\n  border-right: none;\n  background-color: ", ";\n  padding: 9px;\n  font-size: 14px;\n  white-space: nowrap;\n  overflow: hidden;\n  text-overflow: ellipsis;\n  width: calc(100% - 21px);\n"])), styleConstants_1.colors.accent.CIVIL_GRAY_3, styleConstants_1.colors.basic.WHITE);
var Wrapper = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n  display: flex;\n  flex-direction: row;\n  justify-content: start;\n  align-items: center;\n  margin-bottom: 10px;\n"], ["\n  display: flex;\n  flex-direction: row;\n  justify-content: start;\n  align-items: center;\n  margin-bottom: 10px;\n"])));
var Button = styled_components_1.default(Button_1.SecondaryButton)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n  padding: 10px;\n  font-size: 14px;\n"], ["\n  padding: 10px;\n  font-size: 14px;\n"])));
var AddressWithCopyButton = /** @class */ (function (_super) {
    __extends(AddressWithCopyButton, _super);
    function AddressWithCopyButton() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.copy = function () {
            var el = document.createElement("textarea");
            el.value = _this.addressBox.textContent;
            el.setAttribute("readonly", "");
            el.style.position = "absolute";
            el.style.left = "-9999px";
            document.body.appendChild(el);
            el.select();
            document.execCommand("copy");
            document.body.removeChild(el);
        };
        return _this;
    }
    AddressWithCopyButton.prototype.render = function () {
        var _this = this;
        return (React.createElement(Wrapper, null,
            React.createElement(Box, { ref: function (el) { return (_this.addressBox = el); } }, this.props.address),
            React.createElement(Button, { size: Button_1.buttonSizes.SMALL, onClick: this.copy }, "Copy")));
    };
    return AddressWithCopyButton;
}(React.Component));
exports.AddressWithCopyButton = AddressWithCopyButton;
var templateObject_1, templateObject_2, templateObject_3;
//# sourceMappingURL=AddressWithCopyButton.js.map