;
{
  try {
    let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
    n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "b4fe67d8-dbe2-4c3e-a676-ad69bfe0d534", e._sentryDebugIdIdentifier = "sentry-dbid-b4fe67d8-dbe2-4c3e-a676-ad69bfe0d534");
  } catch (e) {
  }
}
;
import { jsx, jsxs } from "preact/jsx-runtime";
import { useState } from "preact/hooks";
import { useMutation } from "@tanstack/preact-query";
import { b as useApiContext, $ as httpPost, u as useTranslation } from "./StoreProvider-CqQrndhS.js";
import { C as Checkbox } from "./Checkbox-CyQM2V4n.js";
import { H as Header } from "./Header-Dt-hNg1U.js";
import { L as LoaderWrapper } from "./LoaderWrapper-Dr1uK-LS.js";
import { u as useToastContext } from "./useToastContext-CPvuqSMm.js";
import { A as ActionBar } from "./ActionBar-DPfNdSxA.js";
import { D as DropinLayout } from "./DropinLayout-CBP_cHLC.js";
const confirmReview = async (legalEntityId, baseUrl) => {
  return httpPost({
    baseUrl,
    path: `legalEntities/${legalEntityId}/confirmDataReview`
  });
};
const useConfirmReview = (options) => {
  const { rootLegalEntityId, baseUrl } = useApiContext();
  return useMutation({
    mutationFn: () => {
      return confirmReview(rootLegalEntityId.value, baseUrl.value);
    },
    ...options
  });
};
function Review({ handleHomeClick }) {
  const { t } = useTranslation("common");
  const [loadingStatus, setLoadingStatus] = useState();
  const { showToast } = useToastContext();
  const [hasConfirmed, setHasConfirmed] = useState(false);
  const content = /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(LoaderWrapper, { status: loadingStatus, formOpacityWhenLoading: 0.3, showSpinner: false, children: [
    /* @__PURE__ */ jsx(Header, { title: t(($) => $["submitReviewOfYourData"]) }),
    /* @__PURE__ */ jsx("span", { children: t(($) => $["pleaseNote"]) }),
    /* @__PURE__ */ jsx("br", {}),
    /* @__PURE__ */ jsx("br", {}),
    /* @__PURE__ */ jsx(
      Checkbox,
      {
        id: "review-checkbox",
        checked: hasConfirmed,
        onChange: setHasConfirmed,
        label: t(($) => $["byClickingSubmitReview"]),
        name: "confirmReviewData"
      }
    )
  ] }) });
  const { mutateAsync: confirmReview2 } = useConfirmReview();
  const onConfirmClick = async () => {
    try {
      setLoadingStatus("loading");
      await confirmReview2();
      setLoadingStatus("success");
      showToast({ label: t(($) => $["submitSuccessful"]), variant: "success" });
      handleHomeClick();
    } catch {
      showToast({ label: t(($) => $["submitFailed"]), variant: "error" });
    } finally {
      setLoadingStatus("success");
    }
  };
  const footer = /* @__PURE__ */ jsx(
    ActionBar,
    {
      onHome: handleHomeClick,
      homeButtonLabel: t(($) => $["goToOverview"]),
      onNext: onConfirmClick,
      nextButtonLabel: t(($) => $["submitReview"]),
      nextButtonDisabled: !hasConfirmed
    }
  );
  return /* @__PURE__ */ jsx(DropinLayout, { content, footer });
}
export {
  Review
};
