"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "OrdersEmptyView", {
    enumerable: true,
    get: function() {
        return OrdersEmptyView;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _emptyView = require("../../../listView/emptyView");
const _react = require("react");
const OrdersEmptyView = (props)=>{
    const { watchRef, left, right } = props;
    const [xPosition, setXPosition] = (0, _react.useState)({
        left: 0,
        right: 0
    });
    const calcPoistion = (left, right)=>{
        const leftTargetElement = document.getElementById("table_left_fixed_divide");
        const rightTargetElement = document.getElementById("table_right_fixed_divide");
        let xLeft = left;
        let xRight = right;
        if (leftTargetElement && leftTargetElement?.parentElement) {
            const parentElement = leftTargetElement?.parentElement;
            const rect = leftTargetElement.getBoundingClientRect();
            const parentRect = parentElement.getBoundingClientRect();
            const position = {
                top: rect.top - parentRect.top,
                left: rect.left - parentRect.left,
                width: rect.width,
                height: rect.height
            };
            // console.log('left Div position:', position);
            xLeft = rect.width > 0 ? rect.left - parentRect.left : xLeft;
        }
        if (rightTargetElement && rightTargetElement?.parentElement) {
            const parentElement = rightTargetElement?.parentElement;
            const rect = rightTargetElement.getBoundingClientRect();
            const parentRect = parentElement.getBoundingClientRect();
            const position = {
                top: rect.top - parentRect.top,
                left: rect.left - parentRect.left,
                width: rect.width,
                height: rect.height
            };
            // console.log('right Div position:', position);
            xRight = right; //rect.width > 0 ? right : 0;
        }
        setXPosition({
            left: xLeft,
            right: xRight
        });
    };
    (0, _react.useEffect)(()=>{
        calcPoistion(left, right);
    }, [
        left,
        right
    ]);
    (0, _react.useEffect)(()=>{
        const divElement = watchRef.current;
        if (!divElement) return;
        const resizeObserver = new ResizeObserver((entries)=>{
            for (const entry of entries){
                calcPoistion(left, right);
            }
        });
        resizeObserver.observe(divElement);
        return ()=>{
            resizeObserver.unobserve(divElement);
        };
    }, [
        watchRef,
        left,
        right
    ]);
    return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
        className: "orderly-ui-table-empty orderly-absolute orderly-left-0 orderly-right-0 orderly-top-[44px] orderly-bottom-10 orderly-bg-base-900",
        style: {
            paddingLeft: `${xPosition.left}px`,
            paddingRight: `${xPosition.right}px`
        },
        children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_emptyView.EmptyView, {})
    });
};

//# sourceMappingURL=ordersEmptyView.js.map