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] = "a937856d-ac00-40c7-9752-a15c3f54bb56", e._sentryDebugIdIdentifier = "sentry-dbid-a937856d-ac00-40c7-9752-a15c3f54bb56");
} catch (e) {}
import { S as remediationPayoutApiKeyMapping, d as remediationIndividualApiKeyMapping, v as remediationBusinessDetailsApiKeyMapping } from "./processCapabilities-CDSEJpB8.js";
import { t as TaskTypes } from "./taskTypes-DWaxzvnQ.js";
import { t as assignToProp } from "./utils--gwzjjeS.js";
//#region src/types/errors/maintenance-mode-error.ts
var isMaintenanceModeError = (error) => error && typeof error === "object" && "messageCode" in error && error.messageCode === "maintenanceMode";
//#endregion
//#region src/utils/api/processValidationErrors.ts
var overrideKeyMapping = {
	[TaskTypes.INDIVIDUAL]: { TAX_ID_NUMBER: "individual.taxInformation" },
	[TaskTypes.BUSINESS_DETAILS]: { TAX_ID_NUMBER: "organization.taxInformation" }
};
/**
* Processes server validation errors received from an erroneous HTTP response.
* @param validationError - the validation error contain all invalid fields.
* @param dropinTask - the dropin page we are processing validations for.
* @param keyMappings - the actual keymappings, for non-task components
*/
var processValidationErrors = (validationError, dropinTask, keyMappings) => {
	if (validationError?.invalidFields && validationError?.invalidFields.length > 0) return validationError?.invalidFields.reduce((acc, invalidField) => {
		if (invalidField?.name) {
			let mappedFieldPath = mapField(invalidField?.name, dropinTask);
			if (keyMappings) mappedFieldPath = keyMappings[invalidField?.name];
			if (mappedFieldPath) assignToProp(mappedFieldPath, acc, true);
		}
		return acc;
	}, {});
};
var mapField = (lePath, dropinTask) => {
	switch (dropinTask) {
		case TaskTypes.INDIVIDUAL: {
			const mappedPath = overrideKeyMapping?.[TaskTypes.INDIVIDUAL]?.[lePath];
			return mappedPath ? mappedPath : remediationIndividualApiKeyMapping[lePath];
		}
		case TaskTypes.BUSINESS_DETAILS: {
			const mappedPath = overrideKeyMapping?.[TaskTypes.BUSINESS_DETAILS]?.[lePath];
			return mappedPath ? mappedPath : remediationBusinessDetailsApiKeyMapping[lePath];
		}
		case TaskTypes.PAYOUT:
		case TaskTypes.PAYIN: return remediationPayoutApiKeyMapping[lePath];
		default: return null;
	}
};
//#endregion
//#region src/utils/validationError.ts
var API_VALIDATION_ERROR_CODE = "30_102";
var ID_DOCUMENT_UPLOAD_ERROR_CODE = "30_105";
var BANK_STATEMENT_UPLOAD_ERROR_CODE = "30_106";
var CreateOrUpdateTransferInstrumentErrorMessage = { TRANSFER_INSTRUMENT_LIMIT_HAS_ALREADY_BEEN_MET: "Transfer instrument limit has already been met" };
var validateErrorCode = (error, errorCode) => !!error && typeof error === "object" && "errorCode" in error && error.errorCode === errorCode;
var isValidationError = (error) => validateErrorCode(error, API_VALIDATION_ERROR_CODE);
var isIdDocumentUploadError = (error) => validateErrorCode(error, ID_DOCUMENT_UPLOAD_ERROR_CODE);
var isBankStatementUploadError = (error) => validateErrorCode(error, BANK_STATEMENT_UPLOAD_ERROR_CODE);
var isBusinessSelectionLegalArrangementError = (error) => {
	return typeof error === "object" && error.invalidFields?.length > 0 && error.invalidFields[0].name === "type";
};
var mapCreateOrUpdateTransferInstrumentErrorMessageToTranslatable = (error) => {
	if (!error) return "failedToUpdateDetails";
	switch (error?.sourceError?.detail) {
		case CreateOrUpdateTransferInstrumentErrorMessage.TRANSFER_INSTRUMENT_LIMIT_HAS_ALREADY_BEEN_MET: return "transferInstrumentLimitHasAlreadyBeenMet";
		default: return "failedToUpdateDetails";
	}
};
//#endregion
export { mapCreateOrUpdateTransferInstrumentErrorMessageToTranslatable as a, isValidationError as i, isBusinessSelectionLegalArrangementError as n, processValidationErrors as o, isIdDocumentUploadError as r, isMaintenanceModeError as s, isBankStatementUploadError as t };
