;
{
  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] = "22bf3be4-5de7-46af-9558-9ac9ca50177e", e._sentryDebugIdIdentifier = "sentry-dbid-22bf3be4-5de7-46af-9558-9ac9ca50177e");
  } catch (e) {
  }
}
;
import { ax as DecisionMakerTypes, j as TaskTypes, ay as Scenarios } from "./StoreProvider-CqQrndhS.js";
import { signal, computed } from "@preact/signals";
const showIdNowModal = signal(false);
const idNowModalChildEntityId = signal();
const idNowPostSubmit = signal(false);
const shouldShowIdNowModal = computed(() => {
  const idNowModalChildEntityIdValue = !!idNowModalChildEntityId.value;
  return showIdNowModal.value && idNowModalChildEntityIdValue;
});
const removeIdVerificationProblemsForBafinSignatory = (problems, decisionMakerLe) => {
  const newProblems = structuredClone(problems);
  const hasCode301or215 = newProblems.missingData?.some(
    (item) => item.remediatingActions?.some((action) => action.code === "1_301" || action.code === "2_215")
  );
  if (hasCode301or215) {
    setTimeout(() => {
      idNowModalChildEntityId.value = decisionMakerLe;
      showIdNowModal.value = true;
    }, 100);
  }
  if (Array.isArray(newProblems.missingData)) {
    newProblems.missingData = newProblems.missingData.filter(
      (item) => !item.remediatingActions?.some(
        (action) => action.code === "1_301" || action.code === "2_215"
      )
    );
  }
  if (newProblems.remediationActions?.["1_301"]) {
    delete newProblems.remediationActions["1_301"];
  }
  if (newProblems.remediationActions?.["2_215"]) {
    delete newProblems.remediationActions["2_215"];
  }
  if (newProblems.verificationErrors?.idVerificationMethod) {
    delete newProblems.verificationErrors.idVerificationMethod;
  }
  const formsToClean = [
    "basicDetails",
    "additionalPersonalDetails"
  ];
  formsToClean.forEach((formName) => {
    const subErrors = newProblems.verificationErrors?.[formName]?.["1_30"]?.["1_3000"];
    if (newProblems.verificationErrors?.[formName]?.["1_30"] && Array.isArray(subErrors)) {
      newProblems.verificationErrors[formName]["1_30"]["1_3000"] = subErrors.filter(
        (error) => error.code !== "1_301"
      );
    }
  });
  return newProblems;
};
const isLegalEntityAssociation = (data) => "legalEntityId" in data;
const isBafinSignatoryFlow = ({
  taskType,
  data,
  scenarios
}) => {
  if (!data || !scenarios) return false;
  const isSignatory = isLegalEntityAssociation(data) ? data.type === DecisionMakerTypes.SIGNATORY : data.basicDetails?.role?.includes(DecisionMakerTypes.SIGNATORY);
  if (taskType === TaskTypes.DECISION_MAKER && isSignatory) {
    return scenarios.includes(Scenarios.L_BAFIN);
  }
  return false;
};
export {
  idNowPostSubmit as a,
  idNowModalChildEntityId as b,
  shouldShowIdNowModal as c,
  isBafinSignatoryFlow as i,
  removeIdVerificationProblemsForBafinSignatory as r,
  showIdNowModal as s
};
