import {
  Heading
} from "./chunk-HK224ADT.js";
import {
  Card
} from "./chunk-2ZQK7NTN.js";
import {
  Flex
} from "./chunk-25HMMI7R.js";
import {
  Button
} from "./chunk-U7JPP7WJ.js";
import {
  DownloadIcon
} from "./chunk-ODI7VQOP.js";

// src/app/platform/report-card.tsx
import { useCallback } from "react";
import { jsx, jsxs } from "react/jsx-runtime";
function ReportCard(props) {
  const { title, file, status } = props;
  const onClickDownload = useCallback(() => {
    if (!file)
      return;
    const { url, fileName } = file;
    const link = document.createElement("a");
    link.href = url;
    link.download = fileName;
    link.target = "_blank";
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);
  }, [file]);
  if (status) {
    return /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(Flex, { align: "center", justify: "between", children: [
      /* @__PURE__ */ jsx(Heading, { variant: "heading4", children: title }),
      status
    ] }) });
  }
  return /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(
    Flex,
    {
      direction: { initial: "column", xs: "row" },
      gapY: "2",
      justify: "between",
      children: [
        /* @__PURE__ */ jsx(Heading, { variant: "heading4", children: title }),
        /* @__PURE__ */ jsx(Button, { onClick: onClickDownload, variant: "surface", children: /* @__PURE__ */ jsxs(Flex, { gap: "2", width: "100%", children: [
          /* @__PURE__ */ jsx(DownloadIcon, {}),
          file == null ? void 0 : file.buttonName
        ] }) }, file == null ? void 0 : file.url)
      ]
    }
  ) });
}

export {
  ReportCard
};
//# sourceMappingURL=chunk-EQKVFOK5.js.map