import React, { useEffect } from "react";
import { useCandyMachine } from "@strata-foundation/marketplace-ui";
import { Spinner } from "@chakra-ui/react";
import { useVariables, useVariablesContext } from "../../theme/Root/variables";
import { recursiveTransformBN } from "../../theme/ReactLiveScope/AsyncButton";
//@ts-ignore
import BrowserOnly from "@docusaurus/BrowserOnly";
import { usePublicKey } from "@strata-foundation/react";
function BrowserOnlyReactJson(props) {
    return (React.createElement(BrowserOnly, { fallback: React.createElement("div", null, "...") }, () => {
        const Component = require("react-json-view").default;
        return React.createElement(Component, { ...props });
    }));
}
export function CandyMachineConfig() {
    const { setVariables } = useVariablesContext();
    const variables = useVariables();
    const candyMachineKey = usePublicKey(variables?.candyMachineId);
    const { info, loading } = useCandyMachine(candyMachineKey);
    useEffect(() => {
        setVariables((vars) => ({
            ...vars,
            candyMachine: info,
        }));
    }, [variables.candyMachineId]);
    if (loading) {
        return React.createElement(Spinner, null);
    }
    return (React.createElement(BrowserOnlyReactJson, { theme: "bright:inverted", collapsed: 1, displayDataTypes: false, name: false, src: recursiveTransformBN(info || {}) }));
}
//# sourceMappingURL=index.js.map