import { type FC, type PropsWithChildren } from 'react';
import { ChainType } from '../../../utils/chainType.js';
import { isItemAllowed } from '../../../utils/item.js';
import { useWidgetConfig } from '../../WidgetProvider/WidgetProvider.js';
import { EclipseBaseProvider } from './EclipseBaseProvider.js';

export const EclipseProvider: FC<PropsWithChildren> = ({ children }) => {
  const { chains } = useWidgetConfig();

  const isAllowEclipse = isItemAllowed(ChainType.ECLIPSE, chains?.types);

  const isAllowSVM = isItemAllowed(ChainType.SVM, chains?.types);
  return isAllowEclipse && !isAllowSVM ? (
    <EclipseBaseProvider>{children}</EclipseBaseProvider>
  ) : (
    <>{children}</>
  );
};
