import React from "react";
import { Box, Typography, IconButton, Tooltip } from "@mui/material";
import OpenInNewIcon from "@mui/icons-material/OpenInNew";
import ShareIcon from "@mui/icons-material/Share";

const ExternalLinks = () => {
  const handleShare = async () => {
    try {
      await navigator.share({
        title: "YourBench Demo",
        text: "Check out this benchmark evaluation on YourBench!",
        url: window.location.href,
      });
    } catch (err) {
      console.log("Error sharing:", err);
    }
  };

  return (
    <Box
      sx={{
        position: "fixed",
        top: 24,
        left: 24,
        right: 24,
        margin: "auto",
        display: "flex",
        justifyContent: "space-between",
        alignItems: "center",
        zIndex: 1000,
      }}
    >
      <Typography
        variant="body2"
        sx={{
          display: "flex",
          gap: 2,
          alignItems: "center",
        }}
      >
        <a
          href="https://github.com/huggingface/yourbench"
          target="_blank"
          rel="noopener noreferrer"
          style={{ textDecoration: "none", color: "inherit" }}
        >
          GitHub
          <OpenInNewIcon sx={{ fontSize: "0.75rem", ml: 0.5, opacity: 0.6 }} />
        </a>
        <Typography component="span" sx={{ opacity: 0.5 }}>
          •
        </Typography>
        <a
          href="https://huggingface.co/datasets/sumuks/tempora"
          target="_blank"
          rel="noopener noreferrer"
          style={{ textDecoration: "none", color: "inherit" }}
        >
          Dataset
          <OpenInNewIcon sx={{ fontSize: "0.75rem", ml: 0.5, opacity: 0.6 }} />
        </a>
        <Typography component="span" sx={{ opacity: 0.5 }}>
          •
        </Typography>
        <a
          href="https://github.com/huggingface/yourbench/tree/main/docs"
          target="_blank"
          rel="noopener noreferrer"
          style={{ textDecoration: "none", color: "inherit" }}
        >
          Documentation
          <OpenInNewIcon sx={{ fontSize: "0.75rem", ml: 0.5, opacity: 0.6 }} />
        </a>
      </Typography>
      <Tooltip title="Share">
        <IconButton
          onClick={handleShare}
          size="small"
          sx={{
            ml: 1,
            color: "inherit",
            opacity: 0.7,
            "&:hover": {
              opacity: 1,
            },
          }}
        >
          <ShareIcon fontSize="small" />
        </IconButton>
      </Tooltip>
    </Box>
  );
};

export default ExternalLinks;
