/**
 * This file is part of the SplendidBear Websites' projects.
 *
 * Copyright (c) 2026 @ www.splendidbear.org
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

import React, { useRef } from 'react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { GameProvider } from '@mine-contexts';
import { GameBoard } from '@mine-components';
import { string } from 'prop-types';

const queryClient = new QueryClient();

const MineSeeker = ({ env, gameId, opponentName = '' }) => {
  const isEnvDev = 'dev' === env;
  const gameAssoc = useRef('' !== gameId ? gameId : crypto.randomUUID()).current;
  const gameInherited = '' !== gameId;

  return (
    <QueryClientProvider client={queryClient}>
      <GameProvider>
        <GameBoard
          gameAssoc={gameAssoc}
          gameInherited={gameInherited}
          opponentName={opponentName}
          isEnvDev={isEnvDev}
        />
      </GameProvider>
    </QueryClientProvider>
  );
};

export default MineSeeker;

MineSeeker.propTypes = {
  env:          string.isRequired,
  gameId:       string,
  opponentName: string,
};
