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] = "29d1a9ae-6323-4f32-b5a5-68e641346c54", e._sentryDebugIdIdentifier = "sentry-dbid-29d1a9ae-6323-4f32-b5a5-68e641346c54");
} catch (e) {}
import { t as LegalEntityTypes } from "./legal-entity-type-VIfNYnJP.js";
import { t as getLegalEntityCountry } from "./getLegalEntityCountry-C6bSV6sB.js";
import { t as CountryCodes } from "./country-code-D3oCpE4i.js";
import { t as getCapabilities } from "./processCapabilities-CDSEJpB8.js";
import { d as hasOwnEntityAssociationOfType } from "./entityAssociationUtil-C0gX4Ewv.js";
import { t as CompanyTypesValues } from "./company-types-value-B-nraMaa.js";
import { t as allowIndividualWithoutSoleProp } from "./accountHolderUtils-AnlUAp6W.js";
import { r as SOLE_PROP_COUNTRIES } from "./Individual.rules-BaOxBQUI.js";
import { t as ALLOWED_UNINCORPORATED_PARTNERSHIP_COUNTRIES } from "./types-ewJwhKUi.js";
//#region src/components/Shared/forms/BusinessTypeSelection/utils.ts
var TRUST_COUNTRIES = [CountryCodes.Australia, CountryCodes.NewZealand];
var BUSINESS_BANK_ACCOUNT_COUNTRIES = [
	CountryCodes.UnitedStates,
	CountryCodes.UnitedKingdom,
	CountryCodes.Netherlands,
	CountryCodes.France,
	CountryCodes.Germany,
	CountryCodes.Spain,
	CountryCodes.Belgium
];
/**
* this is messy business logic
* we determine the legal entity type by the account holder
* however we have partnershipIncorporated;
* which shares the same account holder type as company (a subtype of company)
* we have to force the result of this function to 'legalArrangement' should organization.type is partnershipIncorporated
* could possibly be more of such cases in the future.
*
* @param businessTypeItems - list of BusinessTypeModel
* @param accountHolder - the entity we payout to
* @param legalEntityType - the type of legal entity
* @param companyTypesValue - the subtype of an organization see CompanyValuesType
*/
var organizationTypesToSkipCompanyStructureForm = ["partnershipIncorporated", "associationIncorporated"];
var getBusinessType = (businessTypeItems, country, accountHolder, legalEntityType, companyTypesValue, capabilities = []) => {
	const findBusinessType = (id) => businessTypeItems[id];
	if (organizationTypesToSkipCompanyStructureForm.includes(companyTypesValue ?? "")) return businessTypeItems.legalArrangement;
	if (accountHolder) {
		if ([
			"aTrust",
			"partnershipUnincorporated",
			"anAssociation"
		].includes(accountHolder)) return businessTypeItems.legalArrangement;
		return Object.values(businessTypeItems).find((businessTypeItem) => businessTypeItem.accountHolder === accountHolder);
	}
	switch (legalEntityType) {
		case LegalEntityTypes.ORGANIZATION: return findBusinessType("company");
		case LegalEntityTypes.INDIVIDUAL:
			if (allowIndividualWithoutSoleProp(capabilities)) return findBusinessType("individual");
			if (SOLE_PROP_COUNTRIES.includes(country)) return findBusinessType("soleProprietorship");
			return findBusinessType("company");
		default:
	}
};
var businessTypeMetadata = {
	individual: {
		id: "individual",
		accountHolder: "myName",
		name: "individual",
		description: "youAreNotSoleProprietorAndUseBankAccount"
	},
	soleProprietorship: {
		id: "soleProprietorship",
		accountHolder: "mySoleProprietorName",
		name: "soleProprietorship",
		description: "youAreRegisteredSoleProprietorAndUseBankAccount"
	},
	company: {
		id: "company",
		accountHolder: "theCompanyIWorkFor",
		name: "company",
		description: "yourBusinessIsRegisteredAsASeparateLegalEntityFromItsOwners"
	},
	legalArrangement: {
		id: "legalArrangement",
		name: "trustPartnershipOrAssociation",
		description: "youAreIndividualOrCompanyAndUseBankAccountInNameOfTrustPartnershipOrAssociation"
	}
};
var businessTypeIcons = {
	individual: "user",
	soleProprietorship: "user-business",
	company: "company-2",
	legalArrangement: "users-3"
};
var createAllowBusinessTypeOptionDecider = (country, capabilities) => (option) => {
	switch (option) {
		case "individual": return allowIndividualWithoutSoleProp(capabilities);
		case "soleProprietorship": return SOLE_PROP_COUNTRIES.includes(country);
		default: return true;
	}
};
var getBusinessTypeOptionsAndMetadata = (country, capabilities) => {
	const shouldAllowBusinessTypeOption = createAllowBusinessTypeOptionDecider(country, capabilities);
	const allowedBusinessTypeMetadata = {};
	Object.entries(businessTypeMetadata).forEach(([key, value]) => {
		const businessType = key;
		if (shouldAllowBusinessTypeOption(businessType)) allowedBusinessTypeMetadata[businessType] = value;
	});
	const adjustedBusinessTypeMetadata = {
		...allowedBusinessTypeMetadata,
		...!TRUST_COUNTRIES.includes(country) ? { legalArrangement: {
			id: "legalArrangement",
			name: "partnershipOrAssociation",
			description: "youAreIndividualOrCompanyAndUseBankAccountInNameOfPartnershipOrAssociation"
		} } : {}
	};
	if (capabilities?.includes("issueBankAccount") && BUSINESS_BANK_ACCOUNT_COUNTRIES.includes(country)) {
		delete adjustedBusinessTypeMetadata?.legalArrangement;
		delete adjustedBusinessTypeMetadata?.individual;
	}
	return adjustedBusinessTypeMetadata;
};
var legalArrangementMetadata = {
	aTrust: {
		id: "aTrust",
		accountHolder: "aTrust",
		name: "trust",
		description: "youAreTrusteeManagingTheTrustForBeneficiaries"
	},
	partnershipIncorporated: {
		id: "partnershipIncorporated",
		accountHolder: "theCompanyIWorkFor",
		name: "partnershipIncorporated",
		description: "partnershipIncorporatedDescription"
	},
	partnershipUnincorporated: {
		id: "partnershipUnincorporated",
		accountHolder: "anUnincorporatedPartnership",
		name: "partnershipUnincorporated",
		description: "partnershipUnincorporatedDescription"
	},
	associationIncorporated: {
		id: "associationIncorporated",
		accountHolder: "theCompanyIWorkFor",
		name: "associationIncorporated",
		description: "yourAssociationIsRegisteredItWasSetUpForNonCommercialPurpose"
	}
};
var legalArragementOptions = Object.keys(legalArrangementMetadata);
var getLegalArrangementOptions = (country) => legalArragementOptions.filter((option) => {
	if (option === "partnershipIncorporated" || option === "associationIncorporated") return true;
	if (option === "partnershipUnincorporated") return ALLOWED_UNINCORPORATED_PARTNERSHIP_COUNTRIES.includes(country);
	return TRUST_COUNTRIES.includes(country);
});
var useSelectionOptions = (legalEntityResponse) => {
	const country = getLegalEntityCountry(legalEntityResponse);
	return {
		adjustedBusinessTypeMetadata: getBusinessTypeOptionsAndMetadata(country, getCapabilities(legalEntityResponse)),
		legalArrangementOptions: getLegalArrangementOptions(country)
	};
};
var mapLegalArrangementOptionToCompanyTypesValue = (legalArrangement) => {
	switch (legalArrangement) {
		case "partnershipIncorporated": return CompanyTypesValues.INCORPORATED_PARTNERSHIP;
		case "associationIncorporated": return CompanyTypesValues.INCORPORATED_ASSOCIATION;
		default: return;
	}
};
var determineOrganizationTypeToUpdate = (targetLegalArrangement, currentCompanyTypeValue) => {
	if (targetLegalArrangement === "aTrust") return;
	if (!targetLegalArrangement) {
		if (currentCompanyTypeValue === CompanyTypesValues.INCORPORATED_ASSOCIATION || currentCompanyTypeValue === CompanyTypesValues.INCORPORATED_PARTNERSHIP) return CompanyTypesValues.PRIVATE_COMPANY;
	}
	return mapLegalArrangementOptionToCompanyTypesValue(targetLegalArrangement);
};
var getDefaultLegalArrangementOrSuborganizationType = (legalEntityResponse, accountHolder) => {
	const entityAssociations = legalEntityResponse?.entityAssociations;
	const suborganizationType = legalEntityResponse?.organization?.type;
	if (hasOwnEntityAssociationOfType(LegalEntityTypes.TRUST, entityAssociations, legalEntityResponse?.id) || accountHolder === "aTrust") return "aTrust";
	if (hasOwnEntityAssociationOfType(LegalEntityTypes.UNINCORPORATED_PARTNERSHIP, entityAssociations, legalEntityResponse?.id) || accountHolder === "anUnincorporatedPartnership") return "partnershipUnincorporated";
	if (suborganizationType === CompanyTypesValues.INCORPORATED_PARTNERSHIP) return "partnershipIncorporated";
	if (suborganizationType === CompanyTypesValues.INCORPORATED_ASSOCIATION) return "associationIncorporated";
};
var getTargetLegalEntityType = (businessType, legalArrangement, trusteeType, currentLegalEntityType) => {
	const trustOrUnincorporatedPartnership = legalArrangement === "aTrust" || legalArrangement === "partnershipUnincorporated";
	if (businessType === "legalArrangement" && trustOrUnincorporatedPartnership && trusteeType === "company" || businessType === "company") return LegalEntityTypes.ORGANIZATION;
	if (businessType === "legalArrangement" && trustOrUnincorporatedPartnership && trusteeType === "individual" || businessType === "individual" || businessType === "soleProprietorship") return LegalEntityTypes.INDIVIDUAL;
	if (legalArrangement && isLegalArrangementOrganizationSubtype(legalArrangement)) return LegalEntityTypes.ORGANIZATION;
	return currentLegalEntityType;
};
var isLegalArrangementOrganizationSubtype = (legalArrangementOption) => legalArrangementOption === "partnershipIncorporated" || legalArrangementOption === "associationIncorporated";
//#endregion
export { getTargetLegalEntityType as a, useSelectionOptions as c, getDefaultLegalArrangementOrSuborganizationType as i, determineOrganizationTypeToUpdate as n, legalArrangementMetadata as o, getBusinessType as r, organizationTypesToSkipCompanyStructureForm as s, businessTypeIcons as t };
