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] = "5144e77f-0da1-482e-82c8-de496a990b9d", e._sentryDebugIdIdentifier = "sentry-dbid-5144e77f-0da1-482e-82c8-de496a990b9d");
} catch (e) {}
import { t as TaskTypes } from "./taskTypes-DWaxzvnQ.js";
import { t as DecisionMakerTypes } from "./decision-maker-type-DHBYiKIe.js";
import { t as Scenarios } from "./get-scenarios-D432otQE.js";
import { computed, signal } from "@preact/signals";
//#region src/components/Individual/forms/IdNowVerificationModal/isIdNowModalOpen.ts
var showIdNowModal = signal(false);
var idNowModalChildEntityId = signal();
var idNowPostSubmit = signal(false);
var shouldShowIdNowModal = computed(() => {
	const idNowModalChildEntityIdValue = !!idNowModalChildEntityId.value;
	return showIdNowModal.value && idNowModalChildEntityIdValue;
});
//#endregion
//#region src/components/Individual/helpers/bafinUtils.ts
/**
* Checks whether the legal entity has both required data points for IDnow verification:
* birth city (placeOfBirth) and nationality.
*/
var hasRequiredDataForIdNow = (legalEntity) => Boolean(legalEntity.individual?.birthData?.placeOfBirth && legalEntity.individual?.nationality);
/**
* For an IDnow-qualified BAFIN signatory, returns an object describing which of the two required
* data points (placeOfBirth, nationality) are still missing, or `null` when no action is needed.
*
* Returns `null` when any of the following conditions are true:
* - The entity is not a signatory, or the L_BAFIN scenario is not active
* - The `2_215` (live-selfie) remediation code is absent from problems
* - Both placeOfBirth and nationality are already present
*/
var getIdNowMissingDataPoints = (problems, legalEntity, scenarios, roles) => {
	if (!roles.includes(DecisionMakerTypes.SIGNATORY) || !scenarios?.includes(Scenarios.L_BAFIN)) return null;
	if (!problems) return null;
	if (!problems.missingData?.some((item) => item.remediatingActions?.some((action) => action.code === "2_215"))) return null;
	const missingPlaceOfBirth = !legalEntity.individual?.birthData?.placeOfBirth;
	const missingNationality = !legalEntity.individual?.nationality;
	if (!missingPlaceOfBirth && !missingNationality) return null;
	return {
		missingPlaceOfBirth,
		missingNationality
	};
};
/**
* For the BAFIN signatory flow, certain ID verification errors and remediation actions are not applicable.
* This utility function takes a problems object and returns a new, deeply cloned object with all
* ID verification-related issues removed.
*
* Specifically, it removes:
* - 'missingData' entries related to ID document upload ('1_301').
* - The '1_301' remediation action from `remediationActions`.
* - The entire `idVerificationMethod` object from `verificationErrors`.
* - Any nested sub-errors with code '1_301' from `basicDetails` and `additionalPersonalDetails`.
*
* @param problems - The original entity problems object.
* @returns A new `EntityProblems` object with BAFIN-specific modifications.
*/
var removeIdVerificationProblemsForBafinSignatory = (problems, decisionMakerLe) => {
	const newProblems = structuredClone(problems);
	if (newProblems.missingData?.some((item) => item.remediatingActions?.some((action) => action.code === "1_301" || action.code === "2_215"))) {
		if (hasRequiredDataForIdNow(decisionMakerLe)) 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;
	["basicDetails", "additionalPersonalDetails"].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;
};
/**
* Type guard to check if the data object is a LegalEntityAssociation.
*/
var isLegalEntityAssociation = (data) => "legalEntityId" in data;
/**
* Checks if the current context matches the specific flow for a BAFIN signatory.
* This is true when the task is for a decision maker, their role is 'signatory',
* and the BAFIN scenario is active.
*
* @param params - The parameters for the check.
* @returns `true` if the conditions for the BAFIN signatory flow are met.
*/
var 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;
};
//#endregion
export { idNowPostSubmit as a, idNowModalChildEntityId as i, isBafinSignatoryFlow as n, shouldShowIdNowModal as o, removeIdVerificationProblemsForBafinSignatory as r, showIdNowModal as s, getIdNowMissingDataPoints as t };
