"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MgBuiltInLayers = exports.MG_BASE_LAYER_GROUP_NAME = exports.MG_LAYER_TYPE_NAME = exports.MgLayerType = exports.SourceProperty = exports.LayerProperty = exports.getExternalBaseLayers = exports.isVisualBaseLayer = exports.getCurrentView = exports.getRuntimeMap = exports.getSelectionSet = exports.getMapGuideSubState = exports.getInitialView = exports.ALWAYS_TRUE = exports.ALWAYS_FALSE = exports.NOOP = exports.KC_U = exports.KC_ESCAPE = exports.DEFAULT_MODAL_POSITION = exports.DEFAULT_MODAL_SIZE = exports.RefreshMode = exports.ActiveMapTool = exports.UnitOfMeasure = exports.BLANK_SIZE = void 0;
/**
 * The default blank size
 */
exports.BLANK_SIZE = { w: 1, h: 1 };
var UnitOfMeasure;
(function (UnitOfMeasure) {
    /**
     * An unknown unit
     */
    UnitOfMeasure[UnitOfMeasure["Unknown"] = 0] = "Unknown";
    /**
     * Inch unit
     */
    UnitOfMeasure[UnitOfMeasure["Inches"] = 1] = "Inches";
    /**
     * Feet unit
     */
    UnitOfMeasure[UnitOfMeasure["Feet"] = 2] = "Feet";
    /**
     * Yard unit
     */
    UnitOfMeasure[UnitOfMeasure["Yards"] = 3] = "Yards";
    /**
     * Mile unit
     */
    UnitOfMeasure[UnitOfMeasure["Miles"] = 4] = "Miles";
    /**
     * Nautical Mile unit
     */
    UnitOfMeasure[UnitOfMeasure["NauticalMiles"] = 5] = "NauticalMiles";
    /**
     * Millimeter unit
     */
    UnitOfMeasure[UnitOfMeasure["Millimeters"] = 6] = "Millimeters";
    /**
     * Centimeter unit
     */
    UnitOfMeasure[UnitOfMeasure["Centimeters"] = 7] = "Centimeters";
    /**
     * Meter unit
     */
    UnitOfMeasure[UnitOfMeasure["Meters"] = 8] = "Meters";
    /**
     * Kilometer unit
     */
    UnitOfMeasure[UnitOfMeasure["Kilometers"] = 9] = "Kilometers";
    /**
     * Degree unit
     */
    UnitOfMeasure[UnitOfMeasure["Degrees"] = 10] = "Degrees";
    /**
     * Decimal Degree unit
     */
    UnitOfMeasure[UnitOfMeasure["DecimalDegrees"] = 11] = "DecimalDegrees";
    /**
     * DMS unit
     */
    UnitOfMeasure[UnitOfMeasure["DMS"] = 12] = "DMS";
    /**
     * Pixel unit
     */
    UnitOfMeasure[UnitOfMeasure["Pixels"] = 13] = "Pixels";
})(UnitOfMeasure = exports.UnitOfMeasure || (exports.UnitOfMeasure = {}));
/**
 * An active map viewer tool
 *
 * @export
 * @enum {number}
 */
var ActiveMapTool;
(function (ActiveMapTool) {
    /**
     * Zoom tool
     */
    ActiveMapTool[ActiveMapTool["Zoom"] = 0] = "Zoom";
    /**
     * Selection tool
     */
    ActiveMapTool[ActiveMapTool["Select"] = 1] = "Select";
    /**
     * Pan tool
     */
    ActiveMapTool[ActiveMapTool["Pan"] = 2] = "Pan";
    /**
     * None
     */
    ActiveMapTool[ActiveMapTool["None"] = 3] = "None";
})(ActiveMapTool = exports.ActiveMapTool || (exports.ActiveMapTool = {}));
/**
 * A bit mask indicating how a map viewer should refresh
 *
 * @export
 * @enum {number}
 */
var RefreshMode;
(function (RefreshMode) {
    /**
     * Refresh only the layers
     */
    RefreshMode[RefreshMode["LayersOnly"] = 1] = "LayersOnly";
    /**
     * Refresh only the selection
     */
    RefreshMode[RefreshMode["SelectionOnly"] = 2] = "SelectionOnly";
})(RefreshMode = exports.RefreshMode || (exports.RefreshMode = {}));
/**
 * The default modal dialog size
 */
exports.DEFAULT_MODAL_SIZE = [350, 500];
/**
 * The default modal dialog position
 * @since 0.14.8
 */
exports.DEFAULT_MODAL_POSITION = [500, 80];
/**
 * Keyboard code for ESCAPE
 */
exports.KC_ESCAPE = 27;
/**
 * Keyboard code for the letter U
 */
exports.KC_U = 85;
/**
 * A function that does nothing
 *
 * @export
 */
function NOOP() { }
exports.NOOP = NOOP;
/**
 * A function that always returns false
 *
 * @export
 * @returns false
 */
function ALWAYS_FALSE() { return false; }
exports.ALWAYS_FALSE = ALWAYS_FALSE;
/**
 * A function that always returns true
 *
 * @export
 * @returns true
 */
function ALWAYS_TRUE() { return true; }
exports.ALWAYS_TRUE = ALWAYS_TRUE;
/**
 * Helper function to get the initial map view from the application state
 *
 * @export
 * @param {Readonly<IApplicationState>} state
 * @returns {(IMapView | undefined)}
 */
function getInitialView(state) {
    if (state.config.activeMapName) {
        return state.mapState[state.config.activeMapName].initialView;
    }
    return undefined;
}
exports.getInitialView = getInitialView;
/**
 * Helper function to get the mapguide-specific sub state of the current map group
 *
 * @export
 * @param {Readonly<IApplicationState>} state
 * @returns {(IMapGuideSubState | undefined)}
 * @since 0.14
 */
function getMapGuideSubState(state) {
    if (state.config.activeMapName) {
        return state.mapState[state.config.activeMapName].mapguide;
    }
    return undefined;
}
exports.getMapGuideSubState = getMapGuideSubState;
/**
 * Helper function to get the current selection set from the application state
 *
 * @export
 * @param {Readonly<IApplicationState>} state
 * @returns {(QueryMapFeaturesResponse | undefined)}
 */
function getSelectionSet(state) {
    var _a;
    return (_a = getMapGuideSubState(state)) === null || _a === void 0 ? void 0 : _a.selectionSet;
}
exports.getSelectionSet = getSelectionSet;
/**
 * Helper function to get the current runtime map state from the application state
 *
 * @export
 * @param {Readonly<IApplicationState>} state
 * @returns {(RuntimeMap | undefined)}
 */
function getRuntimeMap(state) {
    var _a;
    return (_a = getMapGuideSubState(state)) === null || _a === void 0 ? void 0 : _a.runtimeMap;
}
exports.getRuntimeMap = getRuntimeMap;
/**
 * Helper function to get the current view from the application state
 *
 * @export
 * @param {Readonly<IApplicationState>} state
 * @returns {(IMapView | undefined)}
 */
function getCurrentView(state) {
    if (state.config.activeMapName) {
        return state.mapState[state.config.activeMapName].currentView;
    }
    return undefined;
}
exports.getCurrentView = getCurrentView;
/**
 * Determines if the given external base layer is one with a visual representation
 *
 * @param layer
 * @returns
 * @since 0.14.9
 */
function isVisualBaseLayer(layer) {
    return layer.kind != "UTFGrid";
}
exports.isVisualBaseLayer = isVisualBaseLayer;
/**
 * Helper function to get the current set of available external base layers from the application state
 *
 * @remarks This does not include "non-visual" base layers such as UTFGrid tilesets
 *
 * @export
 * @param {Readonly<IApplicationState>} state
 * @returns {(IExternalBaseLayer[] | undefined)}
 *
 * @since 0.14.9 Removed includeNonVisual parameter
 */
function getExternalBaseLayers(state) {
    if (state.config.activeMapName) {
        return state.mapState[state.config.activeMapName].externalBaseLayers;
    }
    return undefined;
}
exports.getExternalBaseLayers = getExternalBaseLayers;
/**
 * Custom properties that can be attached to OpenLayers layer instances
 *
 * @since 0.13
 */
var LayerProperty;
(function (LayerProperty) {
    LayerProperty["LAYER_TYPE"] = "layer_type";
    LayerProperty["LAYER_NAME"] = "name";
    /**
     * @since 0.14
     */
    LayerProperty["LAYER_DISPLAY_NAME"] = "display_name";
    LayerProperty["IS_GROUP"] = "is_group";
    LayerProperty["IS_EXTERNAL"] = "is_external";
    LayerProperty["IS_SELECTABLE"] = "is_selectable";
    /**
     * @since 0.14.5
     */
    LayerProperty["DISABLE_HOVER"] = "disable_hover";
    LayerProperty["IS_SCRATCH"] = "is_scratch";
    LayerProperty["HAS_WMS_LEGEND"] = "has_wms_legend";
    LayerProperty["VECTOR_STYLE"] = "vector_style";
    LayerProperty["WGS84_BBOX"] = "wgs84_bbox";
    LayerProperty["BUSY_WORKER_COUNT"] = "busy_worker_count";
    /**
     * @since 0.14
     */
    LayerProperty["SELECTED_POPUP_CONFIGURATION"] = "popup_config";
    /**
     * @since 0.14
     */
    LayerProperty["LAYER_DESCRIPTION"] = "layer_description";
    /**
     * @since 0.14
     */
    LayerProperty["LAYER_METADATA"] = "layer_metadata";
    /**
     * @since 0.14
     */
    LayerProperty["IS_HOVER_HIGHLIGHT"] = "is_hover_highlight";
    /**
     * @since 0.14
     */
    LayerProperty["IS_MEASURE"] = "is_measure";
    /**
     * @since 0.14
     */
    LayerProperty["IS_WMS_SELECTION_OVERLAY"] = "is_wms_selection_overlay";
    /**
     * @since 0.14
     */
    LayerProperty["IS_HEATMAP"] = "is_heatmap";
    /**
     * A source definition to attach to the layer. This is to assist in persistence of this layer for easy
     * restoration on an application-defined basis
     *
     * @since 0.14.3
     */
    LayerProperty["LAYER_DEFN"] = "layer_defn";
})(LayerProperty = exports.LayerProperty || (exports.LayerProperty = {}));
/**
 * Custom properties that can be attached to OpenLayers image source instances
 *
 * @since 0.13
 */
var SourceProperty;
(function (SourceProperty) {
    SourceProperty["SUPPRESS_LOAD_EVENTS"] = "suppress_load_events";
})(SourceProperty = exports.SourceProperty || (exports.SourceProperty = {}));
/**
 * MapGuide layer types
 *
 * @since 0.13
 */
var MgLayerType;
(function (MgLayerType) {
    MgLayerType["Untiled"] = "MapGuide_Untiled";
    MgLayerType["Tiled"] = "MapGuide_Tiled";
})(MgLayerType = exports.MgLayerType || (exports.MgLayerType = {}));
/**
 * The type name for a MapGuide layer
 *
 * @since 0.13
 */
exports.MG_LAYER_TYPE_NAME = "MapGuide";
/**
 * The default group name for MapGuide tiled layers. This value
 * is not meant for localized display
 *
 * @since 0.13
 */
exports.MG_BASE_LAYER_GROUP_NAME = "Base Tile Layers";
/**
 * Default names for MapGuide built-in layer types. These value
 * are not meant for localized display
 *
 * @since 0.13
 */
var MgBuiltInLayers;
(function (MgBuiltInLayers) {
    MgBuiltInLayers["Overlay"] = "MapGuide Dynamic Overlay";
    MgBuiltInLayers["SelectionOverlay"] = "MapGuide Selection Overlay";
    MgBuiltInLayers["ActiveFeatureSelectionOverlay"] = "MapGuide Active Feature Selection Overlay";
})(MgBuiltInLayers = exports.MgBuiltInLayers || (exports.MgBuiltInLayers = {}));
//# sourceMappingURL=common.js.map