"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoordinateTrackerContainer = void 0;
var tslib_1 = require("tslib");
var React = tslib_1.__importStar(require("react"));
var i18n_1 = require("../api/i18n");
var olProj = tslib_1.__importStar(require("ol/proj"));
var core_1 = require("@blueprintjs/core");
var hooks_1 = require("./hooks");
var hooks_mapguide_1 = require("./hooks-mapguide");
var CoordinateTrackerContainer = function (props) {
    var projections = props.projections;
    var aProjections = Array.isArray(projections) ? projections : [projections];
    var locale = (0, hooks_1.useViewerLocale)();
    var mouse = (0, hooks_1.useCurrentMouseCoordinates)();
    var proj = (0, hooks_mapguide_1.useActiveMapProjection)();
    if (aProjections && aProjections.length) {
        return React.createElement("div", { style: { margin: 8 } },
            React.createElement("h4", { className: "bp3-heading" }, (0, i18n_1.tr)("COORDTRACKER", locale)),
            aProjections.map(function (p) {
                var _a;
                var x = NaN;
                var y = NaN;
                if (mouse && proj) {
                    try {
                        _a = olProj.transform(mouse, proj, p), x = _a[0], y = _a[1];
                    }
                    catch (e) {
                    }
                }
                return React.createElement(core_1.Card, { key: p, style: { marginBottom: 10 } },
                    React.createElement("h5", { className: "bp3-heading" },
                        React.createElement("a", { href: "#" }, p)),
                    React.createElement("p", null,
                        React.createElement("strong", null, "X:"),
                        " ",
                        x),
                    React.createElement("p", null,
                        React.createElement("strong", null, "Y:"),
                        " ",
                        y));
            }));
    }
    else {
        return React.createElement(core_1.Callout, { intent: core_1.Intent.DANGER, title: (0, i18n_1.tr)("ERROR", locale), icon: "error" }, (0, i18n_1.tr)("COORDTRACKER_NO_PROJECTIONS", locale));
    }
};
exports.CoordinateTrackerContainer = CoordinateTrackerContainer;
//# sourceMappingURL=coordinate-tracker.js.map