// (C) 2007-2025 GoodData Corporation
import { merge } from "lodash-es";
import { Overlay } from "./Overlay.js";
/**
 * @internal
 */
export class FullScreenOverlay extends Overlay {
    constructor(props) {
        super(props);
        this.state = merge(this.state, {
            position: {},
            overflow: "auto",
            scrollTop: 0,
        });
    }
    UNSAFE_componentWillMount() {
        const { body } = document;
        const { overflow } = getComputedStyle(body);
        const { scrollTop } = body;
        this.setState({
            overflow,
            scrollTop,
        });
        body.style.overflow = "hidden";
        body.scrollTop = 0;
    }
    componentWillUnmount() {
        super.componentWillUnmount();
        const { body } = document;
        body.style.overflow = this.state.overflow ?? "";
        body.scrollTop = this.state.scrollTop ?? 0;
    }
    getOverlayStyles = () => {
        const zIndex = this.getZIndex();
        const additionalStyles = zIndex ? { zIndex } : {};
        return {
            position: "fixed",
            left: 0,
            top: 0,
            bottom: 0,
            right: 0,
            ...additionalStyles,
        };
    };
}
