import _ from "lodash";
import React from "react";
/** Grows a dimension proportionally to a scale factor. */
export const proportionalZoom = (zoom, scaleFactor) => {
    return zoom * Math.sqrt(Math.max(scaleFactor || 0, 0) || 1);
};
/** Scale zoom vertically */
export const scaleZoom = (verticalFactor, zoom) => {
    const scaledZoom = [
        zoom,
        proportionalZoom(zoom, verticalFactor),
    ];
    return scaledZoom;
};
export const getZoom = (viewport, fb_zoom) => {
    var _a;
    const zoom = (_a = viewport.zoom) !== null && _a !== void 0 ? _a : fb_zoom;
    if (viewport.show3D) {
        return zoom;
    }
    return viewport.verticalScale
        ? scaleZoom(viewport.verticalScale, zoom)
        : zoom;
};
export const useLateralZoom = (viewState) => {
    return React.useMemo(() => {
        var _a;
        const zoom = (_a = _.find(viewState)) === null || _a === void 0 ? void 0 : _a.zoom;
        if (_.isArray(zoom)) {
            return zoom[0];
        }
        else {
            return zoom !== null && zoom !== void 0 ? zoom : -5;
        }
    }, [viewState]);
};
//# sourceMappingURL=camera.js.map