'use strict';

var conversion = require('../geometry/conversion.js');
var deltaApply = require('../geometry/delta-apply.js');

function measureViewportBox(instance, transformPoint) {
    return conversion.convertBoundingBoxToBox(conversion.transformBoxPoints(instance.getBoundingClientRect(), transformPoint));
}
function measurePageBox(element, rootProjectionNode, transformPagePoint) {
    const viewportBox = measureViewportBox(element, transformPagePoint);
    const { scroll } = rootProjectionNode;
    if (scroll) {
        deltaApply.translateAxis(viewportBox.x, scroll.offset.x);
        deltaApply.translateAxis(viewportBox.y, scroll.offset.y);
    }
    return viewportBox;
}

exports.measurePageBox = measurePageBox;
exports.measureViewportBox = measureViewportBox;
