"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.zoomApplyY = exports.zoomApplyX = exports.zoomApply = exports.zoomInvertY = exports.zoomInvertX = exports.zoomInvert = exports.scale = exports.translate = exports.zoomTransformCentered = exports.getTransform = exports.zoomTransformCenteredAt = exports.ZOOM_IDENTITY = void 0;
exports.ZOOM_IDENTITY = { z: 1, x: 0, y: 0 };
const zoomTransformCenteredAt = (x, y, z, width, height) => {
    return { z, x: x - width / 2 / z, y: y - height / 2 / z };
};
exports.zoomTransformCenteredAt = zoomTransformCenteredAt;
const getTransform = (zoom) => {
    return `scale(${zoom.z}) translate(${-zoom.x}px, ${-zoom.y}px)`;
};
exports.getTransform = getTransform;
const zoomTransformCentered = (z, width, height) => {
    return (0, exports.zoomTransformCenteredAt)(width / 2, height / 2, z, width, height);
};
exports.zoomTransformCentered = zoomTransformCentered;
const translate = (zoom, x, y) => {
    return { z: zoom.z, x: zoom.x - x / zoom.z, y: zoom.y - y / zoom.z };
};
exports.translate = translate;
const scale = (zoom, z) => {
    return { z: z, x: zoom.x * z, y: zoom.y * z };
};
exports.scale = scale;
const zoomInvert = (zoom, x, y) => {
    return [(x - zoom.x) / zoom.z, (y - zoom.y) / zoom.z];
};
exports.zoomInvert = zoomInvert;
const zoomInvertX = (zoom, x) => {
    return (x - zoom.x) / zoom.z;
};
exports.zoomInvertX = zoomInvertX;
const zoomInvertY = (zoom, y) => {
    return (y - zoom.y) / zoom.z;
};
exports.zoomInvertY = zoomInvertY;
const zoomApply = (zoom, { x, y }) => {
    return { x: (0, exports.zoomApplyX)(zoom, x), y: (0, exports.zoomApplyY)(zoom, y) };
};
exports.zoomApply = zoomApply;
const zoomApplyX = (zoom, x) => {
    return x * zoom.z + zoom.x;
};
exports.zoomApplyX = zoomApplyX;
const zoomApplyY = (zoom, y) => {
    return y * zoom.z + zoom.y;
};
exports.zoomApplyY = zoomApplyY;
//# sourceMappingURL=zoom.js.map