import { WalletModalProvider } from "@solana/wallet-adapter-react-ui";
import { ChatSdkProvider, EmojisProvider, ReplyProvider } from "@strata-foundation/chat-ui";
import { MarketplaceSdkProvider } from "@strata-foundation/marketplace-ui";
import { AcceleratorProvider, AccountProvider, ErrorHandlerProvider, GraphqlProvider, Notification, ProviderContextProvider, StrataSdksProvider, ThemeProvider } from "@strata-foundation/react";
import React from "react";
import toast, { Toaster } from "react-hot-toast";
import { Wallet } from "../../contexts/Wallet";
import "./bufferFill";
import { VariablesProvider } from "./variables";
// Default styles that can be overridden by your app
require("@solana/wallet-adapter-react-ui/styles.css");
export default ({ children }) => {
    const onError = React.useCallback((error) => {
        console.error(error);
        if (error.message?.includes("Attempt to debit an account but found no record of a prior credit.")) {
            error = new Error("Not enough SOL to perform this action");
        }
        const code = (error.message?.match("custom program error: (.*)") ||
            [])[1];
        if (code == "0x1") {
            error = new Error("Insufficient balance.");
        }
        else if (code == "0x136") {
            error = new Error("Purchased more than the cap of 100 bWUM");
        }
        else if (code === "0x0") {
            error = new Error("Blockhash expired. Please retry");
        }
        toast.custom((t) => (React.createElement(Notification, { type: "error", show: t.visible, heading: error.name, 
            // @ts-ignore
            message: error.message || error.msg || error.toString(), onDismiss: () => toast.dismiss(t.id) })));
    }, [toast]);
    return (React.createElement(React.Fragment, null,
        React.createElement(ThemeProvider, null,
            React.createElement(ErrorHandlerProvider, { onError: onError },
                React.createElement(Wallet, null,
                    React.createElement(ProviderContextProvider, null,
                        React.createElement(WalletModalProvider, null,
                            React.createElement(AccountProvider, { commitment: "confirmed" },
                                React.createElement(StrataSdksProvider, null,
                                    React.createElement(MarketplaceSdkProvider, null,
                                        React.createElement(ChatSdkProvider, null,
                                            React.createElement(GraphqlProvider, null,
                                                React.createElement(EmojisProvider, null,
                                                    React.createElement(ReplyProvider, null,
                                                        React.createElement(AcceleratorProvider, { url: "wss://prod-api.teamwumbo.com/accelerator" },
                                                            React.createElement(VariablesProvider, null,
                                                                children,
                                                                React.createElement(Toaster, { position: "bottom-center", containerStyle: {
                                                                        margin: "auto",
                                                                        width: "420px",
                                                                    } })))))))))))))))));
};
//# sourceMappingURL=index.js.map