/**
 * Calculate the scale ratio applied to the element in the horizontal/vertical axis.
 *
 * @param {HTMLElement} element The element to measure.
 * @param {'horizontal'|'vertical'} [axis='horizontal'] The axis to inspect.
 * @returns {number}
 */ "use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: Object.getOwnPropertyDescriptor(all, name).get
    });
}
_export(exports, {
    get getElementScaleFactor () {
        return getElementScaleFactor;
    },
    get normalizeVisualDelta () {
        return normalizeVisualDelta;
    }
});
function getElementScaleFactor(element, axis = 'horizontal') {
    const boundingRect = element.getBoundingClientRect();
    const transformedSize = axis === 'vertical' ? boundingRect.height : boundingRect.width;
    const unscaledSize = axis === 'vertical' ? element.offsetHeight : element.offsetWidth;
    if (!Number.isFinite(transformedSize) || !Number.isFinite(unscaledSize) || transformedSize <= 0 || unscaledSize <= 0) {
        return 1;
    }
    // Table headers and border-collapse can make `getBoundingClientRect()` one CSS pixel wider/taller
    // than `offsetWidth`/`offsetHeight` with no CSS transform. Treat that as unscaled so resize deltas
    // are not short by one layout pixel after `normalizeVisualDelta`.
    if (transformedSize >= unscaledSize && transformedSize - unscaledSize <= 1) {
        return 1;
    }
    const scaleFactor = transformedSize / unscaledSize;
    return Number.isFinite(scaleFactor) && scaleFactor > 0 ? scaleFactor : 1;
}
function normalizeVisualDelta(visualDelta, scaleFactor) {
    if (!Number.isFinite(scaleFactor) || scaleFactor <= 0) {
        return visualDelta;
    }
    return Math.round(visualDelta / scaleFactor);
}
