"use client";

import { PrivyProvider } from "@privy-io/react-auth";

import { toSolanaWalletConnectors } from "@privy-io/react-auth/solana";

const solanaConnectors = toSolanaWalletConnectors({
  // By default, shouldAutoConnect is enabled
  shouldAutoConnect: false,
});

export default function MyPrivyProvider({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <PrivyProvider
      appId={process.env.NEXT_PUBLIC_PRIVY_APP_ID!}
      config={{
        // Customize Privy's appearance in your app
        appearance: {
          accentColor: "#812f20",
          theme: "light",
          showWalletLoginFirst: false,
          walletChainType: "solana-only",
          // walletList: ["phantom"],
          logo: "https://supabasekong-swwwcowsg8kso0cg4swosw48.dev3vds1.link/storage/v1/object/public/logo/banner.png",
        },
        loginMethods: ["email", "wallet"],
        fundingMethodConfig: {
          moonpay: {
            useSandbox: true,
          },
        },
        // Create embedded wallets for users who don't have a wallet
        embeddedWallets: {
          createOnLogin: "all-users",
          showWalletUIs: true,
        },
        mfa: {
          noPromptOnMfaRequired: false,
        },
        externalWallets: {
          solana: { connectors: solanaConnectors },
        },
      }}
    >
      {children}
    </PrivyProvider>
  );
}
