"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 __assign = (this && this.__assign) || Object.assign || function(t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
        s = arguments[i];
        for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
            t[p] = s[p];
    }
    return t;
};
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
            t[p[i]] = s[p[i]];
    return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
var copyToClipboard = require("copy-to-clipboard");
var React = require("react");
var FaClipboard = require("react-icons/lib/fa/clipboard");
var recompose_1 = require("recompose");
var styled_components_1 = require("styled-components");
var asRendition_1 = require("../asRendition");
var utils_1 = require("../utils");
var Grid_1 = require("./Grid");
var Txt_1 = require("./Txt");
var Wrapper = utils_1.withProps()(styled_components_1.default(Txt_1.default.span))(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\tdisplay: inline-block;\n\twhite-space: nowrap;\n\n\t.text-with-copy__content {\n\t\twhite-space: normal;\n\t\tword-wrap: break-word;\n\t\tmargin-right: 3px;\n\t}\n\n\t& > .text-with-copy__copy_wrapper {\n\t\tdisplay: inline-block;\n\t}\n\n\t.text-with-copy__copy {\n\t\tfont-size: 0.875em;\n\t\ttransform: translateY(-0.08em);\n\t\tcursor: pointer;\n\t\tvisibility: ", ";\n\t}\n\n\t&:hover .text-with-copy__copy {\n\t\tvisibility: visible;\n\t}\n"], ["\n\tdisplay: inline-block;\n\twhite-space: nowrap;\n\n\t.text-with-copy__content {\n\t\twhite-space: normal;\n\t\tword-wrap: break-word;\n\t\tmargin-right: 3px;\n\t}\n\n\t& > .text-with-copy__copy_wrapper {\n\t\tdisplay: inline-block;\n\t}\n\n\t.text-with-copy__copy {\n\t\tfont-size: 0.875em;\n\t\ttransform: translateY(-0.08em);\n\t\tcursor: pointer;\n\t\tvisibility: ",
    ";\n\t}\n\n\t&:hover .text-with-copy__copy {\n\t\tvisibility: visible;\n\t}\n"])), function (props) {
    return props.showCopyButton === 'always' ? 'visible' : 'hidden';
});
var Base = function (_a) {
    var copy = _a.copy, props = __rest(_a, ["copy"]);
    return (React.createElement(Wrapper, __assign({ copy: copy, title: copy }, props, { className: "text-with-copy" }),
        !!props.children && (React.createElement("span", { className: "text-with-copy__content" }, props.children)),
        React.createElement("span", { onClick: function (e) { return utils_1.stopEvent(e); }, className: "text-with-copy__copy_wrapper" },
            React.createElement(Grid_1.Box, { tooltip: { text: 'Copied!', trigger: 'click' }, onClick: function () { return copyToClipboard((copy || '').trim()); }, className: "text-with-copy__copy" },
                React.createElement(FaClipboard, null)))));
};
exports.default = recompose_1.compose(styled_components_1.withTheme, asRendition_1.default)(Base);
var templateObject_1;
