"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ShareLinkToViewContainer = void 0;
var tslib_1 = require("tslib");
var React = tslib_1.__importStar(require("react"));
var i18n_1 = require("../api/i18n");
var runtime_1 = require("../api/runtime");
var react_copy_to_clipboard_1 = tslib_1.__importDefault(require("react-copy-to-clipboard"));
var url_1 = require("../utils/url");
var core_1 = require("@blueprintjs/core");
var hooks_1 = require("./hooks");
var hooks_mapguide_1 = require("./hooks-mapguide");
function NOOP() { }
var ShareLinkToViewContainer = function () {
    var _a = React.useState(false), showSession = _a[0], setShowSession = _a[1];
    var locale = (0, hooks_1.useViewerLocale)();
    var map = (0, hooks_mapguide_1.useActiveMapState)();
    var onShowSessionChanged = function () { return setShowSession(!showSession); };
    var onCopied = function () {
        var v = (0, runtime_1.getViewer)();
        if (v) {
            v.toastSuccess("clipboard", (0, i18n_1.tr)("SHARE_LINK_COPIED", locale));
        }
    };
    var parsed = (0, url_1.parseUrl)("".concat(window.location));
    if (!showSession) {
        delete parsed.query.session;
    }
    var shareUrl = "".concat(parsed.url, "?").concat((0, url_1.stringifyQuery)(parsed.query));
    return React.createElement("div", null,
        React.createElement(core_1.TextArea, { fill: true, rows: 16, readOnly: true, value: shareUrl, onChange: NOOP }),
        React.createElement("br", null),
        React.createElement("div", { style: { padding: 15 } },
            map && React.createElement(core_1.Checkbox, { checked: showSession, label: (0, i18n_1.tr)("SHARE_LINK_INCLUDE_SESSION", locale), onChange: onShowSessionChanged }),
            React.createElement(react_copy_to_clipboard_1.default, { text: shareUrl, onCopy: onCopied },
                React.createElement(core_1.Button, { intent: core_1.Intent.PRIMARY }, (0, i18n_1.tr)("SHARE_LINK_COPY_CLIPBOARD", locale)))));
};
exports.ShareLinkToViewContainer = ShareLinkToViewContainer;
//# sourceMappingURL=share-link-to-view.js.map