function _instanceof(left, right) {
    if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
        return !!right[Symbol.hasInstance](left);
    } else {
        return left instanceof right;
    }
}
export function isWindow(obj) {
    return obj !== null && obj !== undefined && obj === obj.window;
}
var getScroll = function(target) {
    if (typeof window === 'undefined') {
        /* istanbul ignore next */ return 0;
    }
    var result = 0;
    if (isWindow(target)) {
        result = target.pageYOffset;
    } else if (_instanceof(target, Document)) {
        result = target.documentElement.scrollTop;
    } else if (_instanceof(target, HTMLElement)) {
        result = target.scrollTop;
    } else if (target) {
        // According to the type inference, the `target` is `never` type.
        // Since we configured the loose mode type checking, and supports mocking the target with such shape below::
        //    `{ documentElement: { scrollLeft: 200, scrollTop: 400 } }`,
        //    the program may falls into this branch.
        // Check the corresponding tests for details. Don't sure what is the real scenario this happens.
        /* biome-ignore lint/complexity/useLiteralKeys: target is a never type */ /* eslint-disable-next-line dot-notation */ result = target['scrollTop'];
    }
    if (target && !isWindow(target) && typeof result !== 'number') {
        var _target_ownerDocument;
        var _documentElement;
        result = (_documentElement = ((_target_ownerDocument = target.ownerDocument) !== null && _target_ownerDocument !== void 0 ? _target_ownerDocument : target).documentElement) === null || _documentElement === void 0 ? void 0 : _documentElement.scrollTop;
    }
    return result;
};
export var getScrollRailHeight = function(target) {
    if (typeof window === 'undefined') {
        /* istanbul ignore next */ return 0;
    }
    if (isWindow(target)) {
        return target.document.documentElement.scrollHeight - target.document.documentElement.clientHeight;
    }
    if (_instanceof(target, Document)) {
        return target.documentElement.scrollHeight - target.documentElement.clientHeight;
    }
    if (_instanceof(target, HTMLElement)) {
        return target.scrollHeight - target.offsetHeight;
    }
    return 0;
};
export default getScroll;
