import { useMemo, useCallback, useState } from "react";
import { DefaultTheme } from "../../theme";
import { useAccounts } from "../../contexts/polkadot/connect";
export const useTheme = () => useMemo(() => ({
    smallButton: {
        ...DefaultTheme.button,
        width: "132px",
        height: "40px",
        fontSize: "14px",
        margin: "0",
        background: "transparent",
        activeBackground: "transparent",
        hoverBackground: "transparent",
        border: `2px solid ${DefaultTheme.button?.background}`,
    },
}), []);
export const useConnect = (onConnected, onError) => {
    const { connected, connect } = useAccounts();
    const [pending, setPending] = useState(false);
    const onConnect = useCallback(async () => {
        if (!connected) {
            try {
                setPending(true);
                await connect();
                setPending(false);
            }
            catch (err) {
                if (err instanceof Error) {
                    onError ? onError(err) : console.error(err);
                }
            }
        }
        else if (onConnected) {
            await onConnected();
        }
    }, [connected, connect, onConnected, onError]);
    return {
        wrappedConnect: onConnect,
        pending,
    };
};
//# sourceMappingURL=hooks.js.map