import React from 'react';
import { createRoot } from 'react-dom/client';

import App from './App';
import './i18n';

import { checkLogin, login } from './helpers/login';

// 屏蔽 ECharts 在 RadarChart 多 Y 轴场景下的 alignTicks 噪音警告
const _warn = console.warn.bind(console);
console.warn = (...args: any[]) => {
  if (typeof args[0] === 'string' && args[0].includes('alignTicks')) return;
  _warn(...args);
};

if (!checkLogin()) {
  login();
} else {
  const container = document.getElementById('root') as HTMLElement;
  const root = createRoot(container);

  root.render(
    <React.Suspense fallback="loading">
      <App />
    </React.Suspense>,
  );
}
