import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useEventEmitter } from "@orderly.network/hooks";
import { useEffect, useRef, useState } from "react";
// import diff from "deep-diff";
export const DebugPrinter = ()=>{
    const [info, setInfo] = useState();
    const prevInfo = useRef(info);
    const ee = useEventEmitter();
    useEffect(()=>{
        window.__ORDERLY__DEBUGER = {};
    }, []);
    useEffect(()=>{
        const print = (data)=>{
            setInfo(data);
        // const differences = diff.diff(prevInfo.current, data);
        // console.log(differences);
        //   const error = new Error();
        //   const stack = error
        //     .stack!.split("\n")
        //     .slice(2)
        //     .map((line) => line.replace(/\s+at\s+/, ""))
        //     .join("\n");
        //   console.log(stack);
        };
        ee.on("print:data", print);
        return ()=>{
            ee.off("print:data", print);
        };
    }, []);
    // Save the most recent data for comparison
    useEffect(()=>{
        setTimeout(()=>{
            prevInfo.current = info;
        }, 200);
    }, [
        info
    ]);
    return /*#__PURE__*/ _jsxs("div", {
        className: "orderly-fixed orderly-left-3 orderly-bottom-10 orderly-min-w-[300px] orderly-bg-base-700/70 orderly-z-50 orderly-rounded !orderly-text-xs orderly-grid orderly-grid-cols-2 orderly-max-h-screen orderly-overflow-y-auto  orderly-pointer-events-none",
        children: [
            /*#__PURE__*/ _jsxs("div", {
                className: "orderly-border-r orderly-border-base-500 orderly-p-2",
                children: [
                    /*#__PURE__*/ _jsx("div", {
                        children: "Prev"
                    }),
                    /*#__PURE__*/ _jsx("pre", {
                        children: JSON.stringify(prevInfo.current, null, 2)
                    })
                ]
            }),
            /*#__PURE__*/ _jsxs("div", {
                className: "orderly-p-2",
                children: [
                    /*#__PURE__*/ _jsx("div", {
                        children: "New"
                    }),
                    /*#__PURE__*/ _jsx("pre", {
                        children: JSON.stringify(info, null, 2)
                    })
                ]
            })
        ]
    });
};

//# sourceMappingURL=dataConsole.js.map