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] = "b1109edd-2092-4456-8caf-5e13e2c5f66c", e._sentryDebugIdIdentifier = "sentry-dbid-b1109edd-2092-4456-8caf-5e13e2c5f66c");
} catch (e) {}
import { n as addResourceBundles, o as createLogger, r as useTranslation, s as initReactI18next } from "./translation-Br5wIPO-.js";
import { r as Loader, t as Button } from "./Button-BDEdGXnd.js";
import { a as setSdkTokenHandler, i as refreshSession, n as httpGet, o as ApiProvider, r as httpPost, s as useApiContext } from "./http-CHTzpXCd.js";
import { r as useLegalEntity, t as ROOT_LE } from "./useLegalEntity-Dm6g0wmt.js";
import { t as getLegalEntityCountry } from "./getLegalEntityCountry-C6bSV6sB.js";
import { t as useAccountHolder } from "./useAccountHolder-BUQwFdWW.js";
import { n as SettingsContext, t as useSettingsContext } from "./useSettingsContext-DzwVt0W0.js";
import { l as keysOf, t as AnalyticsContext } from "./AnalyticsContext-C0HNdPss.js";
import { t as StateContext } from "./StateContext-BExuJcFK.js";
import { y as isEmpty } from "./validatorUtils-Dz6AklT-.js";
import { t as ToastContextProvider } from "./ToastContextProvider-DmZQLSHH.js";
import { n as ToggleContext, t as useToggleContext } from "./useToggleContext-CLfowItk.js";
import { t as listToRecord } from "./listToRecord-CVX8Zg0w.js";
import { t as _rolldown_dynamic_import_helper_default } from "./_rolldown_dynamic_import_helper-CCXvMgfE.js";
import { t as Header } from "./Header-B_MIsVov.js";
import { t as useAllowedCountries } from "./useAllowedCountries-BIhbvxWx.js";
import { t as useDataset } from "./useDataset-BRZZoPVn.js";
import { t as datasetIdentifier } from "./datasetUtil-BZmNUckr.js";
import { n as Skeleton } from "./Accordion-DJ1F7dI4.js";
import { n as AlertIcon } from "./Alert-CjZYipjN.js";
import { n as createGlobalStore, t as StoreContext } from "./globalStore-D0yv1fc_.js";
import i18n from "i18next";
import { Suspense, lazy } from "preact/compat";
import { useCallback as useCallback$1, useEffect as useEffect$1, useMemo as useMemo$1, useReducer, useState as useState$1 } from "preact/hooks";
import { Fragment as Fragment$1, jsx, jsxs } from "preact/jsx-runtime";
import { QueryCache, QueryClient, QueryClientProvider, useMutation, useQuery } from "@tanstack/preact-query";
//#region node_modules/.pnpm/vite-plugin-shadow-styles@0.0.3_vite@8.0.12_@types+node@25.7.0_esbuild@0.27.7_jiti@2.7.0_sass@1.99.0_/node_modules/vite-plugin-shadow-styles/dist/stylesheets.js
var sheet = new CSSStyleSheet();
var stylesheets = [sheet];
import("./styles-BKzp-1_V.js").then(({ css }) => {
	sheet.replaceSync(css);
}).catch((err) => console.error("Error loading styles", err));
//#endregion
//#region src/language/i18n.ts
/**
* Initializes i18next and defines configurations
* i18next-resources-to-backend is a simple plugin used for the lazy loading of translation resources
*/
i18n.use(initReactI18next).init({
	defaultNS: false,
	fallbackLng: "en-US",
	load: "currentOnly",
	resources: {},
	showSupportNotice: false,
	react: {
		transSupportBasicHtmlNodes: true,
		transKeepBasicHtmlNodesFor: [
			"strong",
			"i",
			"em"
		],
		bindI18n: "languageChanged",
		bindI18nStore: "added"
	},
	interpolation: {
		prefix: "%{",
		suffix: "}"
	}
});
//#endregion
//#region src/api/configurations/useVersionConfiguration.ts
/**
* Retrieves information about the onboarding version and version-specific features to enable
* linked to the legalEntityId
*/
var getVersionConfiguration = async (legalEntityId, baseUrl) => {
	return httpGet({
		baseUrl,
		path: `legalEntities/${legalEntityId}/configurations/version`
	});
};
var useVersionConfiguration = (options) => {
	const { rootLegalEntityId, baseUrl } = useApiContext();
	return useQuery({
		queryKey: ["versionConfiguration"],
		queryFn: () => getVersionConfiguration(rootLegalEntityId.value, baseUrl.value),
		...options
	});
};
//#endregion
//#region src/api/uiAnalytics/useAnalyticsSession.ts
/**
* @description Request to get an analytics session ID and fire an "Initiate session" event on Mixpanel
* @param data.userData Sets user profile properties on Mixpanel
* @returns a session id that is sent with every subsequent log event request
*/
var getAnalyticsSession = async (baseUrl, data) => {
	return httpPost({
		baseUrl,
		path: `analytics/ui`
	}, data);
};
var useAnalyticsSession = (sessionData, onboardingVersion, options) => {
	const { baseUrl } = useApiContext();
	return useQuery({
		queryKey: ["analyticsSession", onboardingVersion],
		queryFn: () => getAnalyticsSession(baseUrl.value, sessionData),
		enabled: Boolean(onboardingVersion),
		...options
	});
};
//#endregion
//#region src/core/user-events.ts
var UserEvents = class {
	queue = [];
	subscriptions = /* @__PURE__ */ new Set();
	/** payload of commmon props sent in every event */
	baseTrackingPayload;
	/** properties not set with every event but that may be shared between some events
	* ex. `page` value for `Interacted with form field` events
	*/
	sharedEventProperties;
	constructor() {
		this.baseTrackingPayload = {
			category: "onboarding",
			subCategory: "hosted onboarding"
		};
		this.sharedEventProperties = {};
	}
	add(...args) {
		this.queue.push(...args);
	}
	notifySubscribers() {
		while (this.queue.length > 0) {
			const lastEvent = this.queue.pop();
			this.subscriptions.forEach((callback) => callback(lastEvent));
		}
	}
	/**
	* Adds an analytics event with all base event properties.
	*/
	addEvent(eventName, properties) {
		const completeEvent = {
			...this.baseTrackingPayload,
			...properties
		};
		this.add({
			type: "add_event",
			name: eventName,
			properties: completeEvent
		});
		this.notifySubscribers();
	}
	/**
	* Adds an event with context specific to journey-related events
	*/
	addJourneyEvent(eventName, properties) {
		this.addEvent(eventName, {
			actionLevel: "journey",
			...properties
		});
	}
	/**
	* Adds an event with context specific to task-related events
	*/
	addTaskEvent(eventName, properties) {
		this.addEvent(eventName, {
			actionLevel: "task",
			...properties
		});
	}
	/**
	* Adds an event with context specific to page-related events
	*/
	addPageEvent(eventName, properties) {
		this.addEvent(eventName, {
			actionLevel: "page",
			page: this.sharedEventProperties.page,
			...properties
		});
	}
	/**
	* Adds an event with context specific to field-related events
	*/
	addFieldEvent(eventName, properties) {
		this.addEvent(eventName, {
			actionLevel: "field",
			page: this.sharedEventProperties.page,
			...properties
		});
	}
	/**
	* Tracks an experiment for Mixpanel experiment reporting
	*/
	trackExperiment({ name, variant }) {
		this.add({
			type: "add_event",
			name: "$experiment_started",
			properties: {
				...this.baseTrackingPayload,
				"Experiment name": name,
				"Variant name": variant
			}
		});
	}
	/**
	* Subscribes a callback to analytics events. It gets called every time
	* one of the above public methods get called, and the event data is passed back as an array.
	* The callback must have a single argument which is an array of [eventName, eventPayload?].
	* @example
	* ```js
	* const callback = ([eventName, eventPayload]) => console.log(eventName, eventPayload);
	* this.subscribe(callback);
	*
	* const exampleEventPayload = { count: 1, segmentation: { foo: 'bar' } };
	* this.addEvent('exampleEventDidOccur', exampleEventPayload);
	*
	* // `callback` will get called with `['exampleEventDidOccur', exampleEventPayload]`
	* ```
	*/
	subscribe(callback) {
		this.subscriptions.add(callback);
	}
	/**
	* Sets params that are sent on every event
	* */
	updateBaseTrackingPayload(baseTrackingPayload) {
		this.baseTrackingPayload = {
			...this.baseTrackingPayload,
			...baseTrackingPayload
		};
	}
	/**
	* Sets params that may be shared between events
	* */
	updateSharedEventProperties = (props) => {
		this.sharedEventProperties = {
			...this.sharedEventProperties,
			...props
		};
	};
	/**
	* Removes a subscribed callback
	*/
	unsubscribe(callback) {
		if (this.subscriptions.has(callback)) this.subscriptions.delete(callback);
	}
};
var createUserEvents = () => {
	return new UserEvents();
};
//#endregion
//#region src/api/uiAnalytics/usePushAnalyticEvent.ts
var pushAnalyticEvent = async (baseUrl, sessionId, data) => {
	return httpPost({
		baseUrl,
		path: `analytics/ui/${sessionId}`
	}, data);
};
var usePushAnalyticEvent = (sessionId, options) => {
	const { baseUrl } = useApiContext();
	return useMutation({
		mutationFn: (data) => pushAnalyticEvent(baseUrl.value, sessionId, data),
		...options
	});
};
//#endregion
//#region src/utils/analytics/convertToEmbeddedEvent.ts
var convertToEmbeddedEvent = (eventQueueItem, sessionData) => {
	const { type, name, properties } = eventQueueItem;
	return {
		eventName: name,
		eventType: type,
		eventData: properties || {},
		legalEntityId: sessionData.legalEntityId,
		userAgent: sessionData.userAgent,
		componentName: sessionData.componentName,
		sdkVersion: sessionData.sdkVersion
	};
};
//#endregion
//#region src/utils/analytics/getAnalyticsAssociatedEntityDetails.ts
/**
* Gets associated legal entity type and ID for the base tracking payload
* Based on selected account holder type
*/
var getAnalyticsAssociatedEntityDetails = (rootLegalEntity, accountHolderType) => {
	let associatedLegalEntityType;
	switch (accountHolderType) {
		case "aTrust":
			associatedLegalEntityType = "trust";
			break;
		case "mySoleProprietorName":
			associatedLegalEntityType = "soleProprietorship";
			break;
		case "anUnincorporatedPartnership":
			associatedLegalEntityType = "unincorporatedPartnership";
			break;
		default: associatedLegalEntityType = void 0;
	}
	const associatedLegalEntity = rootLegalEntity.entityAssociations?.find((ea) => ea.type === associatedLegalEntityType);
	return {
		associatedLegalEntityType,
		associatedLegalEntityId: associatedLegalEntity?.legalEntityId
	};
};
//#endregion
//#region src/hooks/useAnalytics/useAnalytics.ts
var useAnalytics = ({ userEvents, sessionId, sessionData }) => {
	const sdkVersion = "4.12.2";
	const { data: rootLegalEntity } = useLegalEntity(ROOT_LE);
	const { mutateAsync } = usePushAnalyticEvent(sessionId ?? "");
	const { accountHolder } = useAccountHolder();
	useEffect$1(() => {
		if (!rootLegalEntity) return;
		const countryCode = getLegalEntityCountry(rootLegalEntity);
		const capabilities = Object.keys(rootLegalEntity?.capabilities ?? {});
		userEvents.updateBaseTrackingPayload({
			entityType: rootLegalEntity.type,
			countryCode,
			capabilities,
			sdkVersion,
			componentName: sessionData.componentName,
			userAgent: navigator.userAgent,
			...getAnalyticsAssociatedEntityDetails(rootLegalEntity, accountHolder)
		});
	}, [
		rootLegalEntity,
		accountHolder,
		sdkVersion,
		sessionData.componentName,
		userEvents
	]);
	const pushEvents = useCallback$1((data) => {
		mutateAsync(convertToEmbeddedEvent(data, sessionData));
	}, [mutateAsync, sessionData]);
	useEffect$1(() => {
		if (!sessionId) return;
		userEvents.subscribe(pushEvents);
		return () => {
			userEvents.unsubscribe(pushEvents);
		};
	}, [
		sessionId,
		mutateAsync,
		userEvents,
		sessionData,
		pushEvents
	]);
};
//#endregion
//#region src/utils/analytics/getPrefilledDetails.ts
var getOrganizationPrefilledFields = (organization) => {
	const { dateOfIncorporation, financialReports, registeredAddress, registrationNumber, support, taxInformation, type, vatNumber } = organization;
	const financialReport = financialReports?.[0];
	return {
		dateOfIncorporation: !!dateOfIncorporation,
		financialReport: {
			annualTurnover: !!financialReport?.annualTurnover,
			balanceSheetTotal: !!financialReport?.balanceSheetTotal,
			dateOfFinancialData: !!financialReport?.dateOfFinancialData,
			employeeCount: !!financialReport?.employeeCount
		},
		registeredAddress: {
			city: !!registeredAddress?.city,
			postalCode: !!registeredAddress?.postalCode,
			stateOrProvince: !!registeredAddress?.stateOrProvince,
			street: !!registeredAddress?.street
		},
		registrationNumber: !!registrationNumber,
		support: {
			email: !!support?.email,
			phone: !!support?.phone
		},
		taxInformation: !!taxInformation?.some((taxInfo) => taxInfo.country && taxInfo.number),
		type: !!type,
		vatNumber: !!vatNumber
	};
};
var getPrefilledDetails = (legalEntity) => {
	if (!legalEntity) return;
	const { organization, transferInstruments, entityAssociations } = legalEntity;
	return {
		transferInstrumentCount: transferInstruments?.length || 0,
		entityAssociations: entityAssociations?.map((entity) => entity.type) || [],
		organization: organization && getOrganizationPrefilledFields(organization)
	};
};
//#endregion
//#region src/context/AnalyticsContext/AnalyticsProvider.tsx
/**
* The provider exists to scope analytics to one application instance.
* This would otherwise be problematic when a consumer might have several
* instantiations of a embedded Component for instance on the same page
*/
var AnalyticsProvider = ({ componentName, children, rootLegalEntityId, locale }) => {
	const { settings } = useSettingsContext();
	const { data: rootLegalEntity } = useLegalEntity(ROOT_LE);
	const { data: versionData, isError, isLoading } = useVersionConfiguration();
	const userEvents = useMemo$1(() => createUserEvents(), []);
	const onboardingVersion = isLoading ? void 0 : isError ? 1 : versionData?.version;
	const capabilities = rootLegalEntity?.capabilities && Object.keys(rootLegalEntity.capabilities);
	const shouldTrackPrefilledDetails = capabilities?.includes("receivePayments") && onboardingVersion && onboardingVersion > 1;
	const sessionData = {
		sdkVersion: "4.12.2",
		componentName,
		userAgent: navigator.userAgent,
		legalEntityId: rootLegalEntityId,
		capabilities,
		entityType: rootLegalEntity?.type,
		eventData: shouldTrackPrefilledDetails ? getPrefilledDetails(rootLegalEntity) : void 0,
		userData: {
			onboardingVersion,
			isDirectMerchant: settings.merchantType === "direct",
			settings,
			country: rootLegalEntity && getLegalEntityCountry(rootLegalEntity)
		}
	};
	const { data } = useAnalyticsSession(sessionData, onboardingVersion);
	userEvents.updateBaseTrackingPayload({ locale });
	useAnalytics({
		userEvents,
		sessionId: data?.id,
		sessionData
	});
	return /* @__PURE__ */ jsx(AnalyticsContext.Provider, {
		value: userEvents,
		children
	});
};
//#endregion
//#region src/context/QueryContext/QueryClient.ts
var QueryClient$1 = new QueryClient({
	defaultOptions: {
		queries: {
			staleTime: 300 * 1e3,
			refetchOnWindowFocus: false,
			refetchOnReconnect: true,
			refetchOnMount: true,
			retry: 2
		},
		mutations: { retry: 1 }
	},
	queryCache: new QueryCache({
		onSuccess: (data, query) => {
			if (query.meta?.onSuccess && typeof query.meta.onSuccess === "function") query.meta.onSuccess(data);
		},
		onError: (data, query) => {
			if (query.meta?.onError && typeof query.meta.onError === "function") query.meta.onError(data);
		}
	})
});
//#endregion
//#region src/context/QueryContext/QueryClientProvider.tsx
/** Standard tanstack query provider, needed for it to work */
var QueryClientProvider$1 = ({ children }) => /* @__PURE__ */ jsx(QueryClientProvider, {
	client: QueryClient$1,
	children
});
//#endregion
//#region src/context/SettingsContext/SettingsProvider.tsx
var settingsDefaults = {
	acceptedCountries: void 0,
	allowBankAccountFormatSelection: false,
	allowDebugUi: false,
	allowIntraRegionCrossBorderPayout: false,
	changeLegalEntityType: true,
	editPrefilledCountry: true,
	requirePciSignEcomMoto: false,
	requirePciSignEcommerce: false,
	requirePciSignPos: false,
	requirePciSignPosMoto: false,
	hideOnboardingIntroductionIndividual: true,
	hideOnboardingIntroductionOrganization: true,
	hideOnboardingIntroductionTrust: true,
	hideOnboardingIntroductionSoleProprietor: true,
	viewOnboardingGuidance: false,
	transferInstrumentLimit: 0,
	instantBankVerification: true,
	showServiceAgreementsFirst: false,
	showBusinessFinancingFirst: false,
	enforceLegalAge: false,
	merchantType: void 0,
	allowBusinessLines: false,
	allowCrossBorderPayout: false
};
/**
* Consumers can pass settings @see settingsDefaults, which can alter on runtime
* the behaviour of our library
* The settings are dynamically passed during SDK initialization (same as legalEntityId)
* @param settings - dictionary of type Settings
*/
function SettingsProvider({ children, settings }) {
	const mergedSettings = {
		...settingsDefaults,
		...settings
	};
	const contextValue = useMemo$1(() => ({
		isSettingEnabled: (settingName) => mergedSettings[settingName],
		getSetting: (settingName) => mergedSettings[settingName],
		settings: mergedSettings
	}), [settings]);
	return /* @__PURE__ */ jsx(SettingsContext.Provider, {
		value: contextValue,
		children
	});
}
//#endregion
//#region src/utils/removeObjectEmptyValues.ts
function removeObjectPropsWithEmptyValues(obj) {
	keysOf(obj).forEach((key) => {
		if (obj[key] === null || isEmpty(obj[key])) delete obj[key];
	});
	return obj;
}
//#endregion
//#region src/context/StateContext/StateReducer.ts
var INITIAL_STATE = {
	data: {},
	allData: {},
	initialData: {},
	errors: {},
	valid: {},
	fieldProblems: {},
	isValid: false,
	allValid: false
};
var logger = createLogger();
function StateReducer() {
	const [schemas, setSchemas] = useState$1({});
	const [activeForms, setActiveForms] = useState$1([]);
	const setCurrentForms = (forms) => {
		setActiveForms(forms);
	};
	function reducer({ currentState: currState, prevState }, action) {
		switch (action.type) {
			case "addToState": {
				if (!action.value.dataStoreId) {
					logger.warn("No dataStoreId provided, hence no update can be done");
					return {
						currentState: currState,
						prevState
					};
				}
				const dataStoreId = action.value.dataStoreId;
				const state = structuredClone(currState);
				const schema = action.value.schema || null;
				const schemaHasChanged = schema && schemas?.[dataStoreId]?.toString() !== schema.toString();
				const mergedState = {
					...state,
					data: {
						...state.data,
						[dataStoreId]: {
							...state.data[dataStoreId],
							...action.value.data
						}
					},
					allData: {
						...state.allData,
						[dataStoreId]: {
							...state.allData[dataStoreId],
							...removeObjectPropsWithEmptyValues(action.value.data)
						}
					},
					errors: {
						...state.errors,
						[dataStoreId]: {
							...state.errors[dataStoreId],
							...action.value.errors
						}
					},
					valid: {
						...state.valid,
						[dataStoreId]: {
							...state.valid[dataStoreId],
							...action.value.valid
						}
					},
					fieldProblems: {
						...state.fieldProblems,
						[dataStoreId]: {
							...state.fieldProblems[dataStoreId],
							...action.value.fieldProblems
						}
					}
				};
				/**
				* Some components e.g. personalDetails, are parents for other components and the data from these children is collected
				* under the parent's id (aka dataStoreId) i.e. 'personalDetails.
				*
				* With these parents sometimes their schema for their useForm implementation updates at run time - so this fny checks
				* if a schema has changed and if so ensures that the keys output in the data, valid, errors, fieldProblems objects
				* match those of the parent schema
				*/
				if (schemaHasChanged) {
					setSchemas({
						...schemas,
						[dataStoreId]: schema
					});
					const processedBySchema = schema.reduce((acc, fieldKey) => {
						const dataObjByFormId = mergedState.data[dataStoreId];
						const allDataObjByFormId = mergedState.allData[dataStoreId];
						const validObjByFormId = mergedState.valid[dataStoreId];
						const errorsObjByFormId = mergedState.errors[dataStoreId];
						const fieldProblemsObjByFormId = mergedState.fieldProblems[dataStoreId];
						return {
							data: {
								...acc.data,
								[fieldKey]: dataObjByFormId[fieldKey] ?? allDataObjByFormId[fieldKey]
							},
							valid: {
								...acc.valid,
								[fieldKey]: validObjByFormId[fieldKey]
							},
							errors: {
								...acc.errors,
								[fieldKey]: errorsObjByFormId[fieldKey]
							},
							fieldProblems: {
								...acc.fieldProblems,
								[fieldKey]: fieldProblemsObjByFormId[fieldKey]
							}
						};
					}, {
						data: {},
						valid: {},
						errors: {},
						fieldProblems: {}
					});
					mergedState.data[dataStoreId] = processedBySchema.data;
					mergedState.valid[dataStoreId] = processedBySchema.valid;
					mergedState.errors[dataStoreId] = processedBySchema.errors;
					mergedState.fieldProblems[dataStoreId] = processedBySchema.fieldProblems;
				}
				mergedState.validityByForm = {
					...mergedState.validityByForm,
					[dataStoreId]: Object.values(mergedState.valid[dataStoreId]).every((isValid) => isValid)
				};
				mergedState.allValid = Object.values(mergedState.validityByForm).every((isValid) => isValid);
				mergedState.isValid = !activeForms.length ? mergedState.allValid : activeForms.every((item) => mergedState.validityByForm?.[item]);
				mergedState.initialData = structuredClone(state.initialData);
				return {
					currentState: mergedState,
					prevState: state
				};
			}
			case "removeFromState": {
				if (!action.value.dataStoreId) {
					logger.warn("No dataStoreId provided, hence no update can be done");
					return {
						currentState: currState,
						prevState
					};
				}
				const dataStoreId = action.value.dataStoreId;
				const state = structuredClone(currState);
				const mergedState = {
					...state,
					data: {
						...state.data,
						[dataStoreId]: {}
					},
					allData: {
						...state.allData,
						[dataStoreId]: {}
					},
					errors: {
						...state.errors,
						[dataStoreId]: {}
					},
					valid: {
						...state.valid,
						[dataStoreId]: false
					},
					fieldProblems: {
						...state.fieldProblems,
						[dataStoreId]: {}
					}
				};
				mergedState.validityByForm = {
					...mergedState.validityByForm,
					[dataStoreId]: false
				};
				mergedState.allValid = Object.values(mergedState.validityByForm).every((isValid) => isValid);
				mergedState.isValid = !activeForms.length ? mergedState.allValid : activeForms.every((item) => mergedState.validityByForm?.[item]);
				mergedState.initialData = structuredClone(state.initialData);
				return {
					currentState: mergedState,
					prevState: state
				};
			}
			case "resetState": return {
				currentState: INITIAL_STATE,
				prevState: currState
			};
			default: throw new Error(`Unhandled action type: ${action.type}`);
		}
	}
	return {
		reducer,
		setCurrentForms
	};
}
//#endregion
//#region src/context/StateContext/StateProvider.tsx
function StateProvider({ defaultData = {}, children }) {
	const defaultState = {
		currentState: {
			data: defaultData,
			allData: defaultData,
			valid: {},
			errors: {},
			fieldProblems: {},
			validityByForm: {},
			initialData: defaultData
		},
		prevState: {}
	};
	const reducerObj = StateReducer();
	const [state, dispatch] = useReducer(reducerObj.reducer, defaultState);
	/**
	* Create an object from the returned reducer props
	* - the state property in this object will be available to any handler functions set on StateContextWatcher
	* - the dispatch property is made available to the StateContextSetter
	*/
	const contextValue = useMemo$1(() => ({
		state,
		dispatch,
		setActiveForms: reducerObj.setCurrentForms,
		getData: () => state?.currentState?.data ?? {},
		getState: () => state?.currentState
	}), [reducerObj, state]);
	return /* @__PURE__ */ jsx(StateContext.Provider, {
		value: contextValue,
		children
	});
}
//#endregion
//#region src/api/toggles/useToggles.ts
/**
* Retrieves experiments and onboardingcomponents-specific feature flags
* as defined in `OnboardingcomponentsFeatures.java` linked to the legalEntityId
*/
var getToggles = async (legalEntityId, baseUrl) => {
	const { experiments, features } = await httpGet({
		baseUrl,
		path: `legalEntities/${legalEntityId}/flags`
	});
	return {
		experiments: experiments ? Object.values(experiments).reduce((acc, val) => {
			return {
				...acc,
				[val]: true
			};
		}, {}) : {},
		features
	};
};
var useToggles = (options) => {
	const { rootLegalEntityId, baseUrl } = useApiContext();
	const { features } = useToggleContext();
	return useQuery({
		queryKey: ["toggles"],
		queryFn: () => getToggles(rootLegalEntityId.value, baseUrl.value),
		enabled: !!features.EnableOnboardingTogglesEndpoint,
		...options
	});
};
//#endregion
//#region src/context/ToggleContext/ToggleContextProvider.tsx
/**
* To manage accessing non-production-ready features of SDK
* or features under active experimentation/testing.
* @param children - components rendered
* @param features - dictionary of type Features
* @param refreshExperiments - handler to refresh experiments for the legal entity
*/
function ToggleContextProvider({ children, features: propFeatures, refreshExperiments }) {
	const { data: toggleData } = useToggles();
	const { data: versionData } = useVersionConfiguration();
	const features = useMemo$1(() => ({
		...toggleData?.features,
		...propFeatures,
		...listToRecord(versionData?.features ?? [], () => true)
	}), [
		versionData,
		propFeatures,
		toggleData?.features
	]);
	const experiments = useMemo$1(() => ({ ...toggleData?.experiments }), [toggleData?.experiments]);
	const contextValue = useMemo$1(() => ({
		features,
		isFeatureEnabled: (feature) => features[feature] ?? false,
		experiments,
		isExperimentEnabled: (experiment) => experiments[experiment] ?? false,
		refreshExperiments
	}), [
		features,
		experiments,
		refreshExperiments
	]);
	return /* @__PURE__ */ jsx(ToggleContext.Provider, {
		value: contextValue,
		children
	});
}
//#endregion
//#region src/components/Shared/AllowedCountryGate/AllowedCountryGate.tsx
/**
* Blocks the user from onboarding if they are from a disallowed country.
*/
var AllowedCountryGate = ({ children }) => {
	const allowedCountries = useAllowedCountries();
	const { t, i18n } = useTranslation("common");
	const { data: rootLegalEntity } = useLegalEntity(ROOT_LE);
	const { dataset: countries } = useDataset(datasetIdentifier.country);
	addResourceBundles(i18n, [{
		ns: "common",
		importFn: (lang) => _rolldown_dynamic_import_helper_default(/* @__PURE__ */ Object.assign({
			"../../../language/locales/bg-BG.json": () => import("./bg-BG-NwL6SZRu.js"),
			"../../../language/locales/cs-CZ.json": () => import("./cs-CZ-BZkot6xs.js"),
			"../../../language/locales/da-DK.json": () => import("./da-DK-Bc6oX5Ct.js"),
			"../../../language/locales/de-DE.json": () => import("./de-DE-JZBqb8ce.js"),
			"../../../language/locales/el-GR.json": () => import("./el-GR-C8jFvyDg.js"),
			"../../../language/locales/en-US.instructions.json": () => import("./en-US.instructions-DlxMDbRu.js"),
			"../../../language/locales/en-US.json": () => import("./en-US-Cq6Cl6Yl.js"),
			"../../../language/locales/es-ES.json": () => import("./es-ES-mdSA-CIT.js"),
			"../../../language/locales/et-EE.json": () => import("./et-EE-B4ZMHksf.js"),
			"../../../language/locales/fi-FI.json": () => import("./fi-FI-koFpyMaq.js"),
			"../../../language/locales/fr-FR.json": () => import("./fr-FR-B0eVVc8V.js"),
			"../../../language/locales/hr-HR.json": () => import("./hr-HR-D_X-RNUl.js"),
			"../../../language/locales/hu-HU.json": () => import("./hu-HU-3FpAw9b1.js"),
			"../../../language/locales/it-IT.json": () => import("./it-IT-BgULENxX.js"),
			"../../../language/locales/ja-JP.json": () => import("./ja-JP-BT70_5Cd.js"),
			"../../../language/locales/lt-LT.json": () => import("./lt-LT-CKltvr9j.js"),
			"../../../language/locales/lv-LV.json": () => import("./lv-LV-DwsdNJrk.js"),
			"../../../language/locales/nl-NL.json": () => import("./nl-NL-CxlTSECX.js"),
			"../../../language/locales/no-NO.json": () => import("./no-NO-FtH9gIpv.js"),
			"../../../language/locales/pl-PL.json": () => import("./pl-PL-CK40GB3R.js"),
			"../../../language/locales/pt-BR.json": () => import("./pt-BR-zUBVM8_b.js"),
			"../../../language/locales/pt-PT.json": () => import("./pt-PT-CxnB9Jff.js"),
			"../../../language/locales/ro-RO.json": () => import("./ro-RO-Cuw1RmFc.js"),
			"../../../language/locales/sk-SK.json": () => import("./sk-SK-1i0L4zIs.js"),
			"../../../language/locales/sl-SI.json": () => import("./sl-SI-D3zK3MPP.js"),
			"../../../language/locales/sv-SE.json": () => import("./sv-SE-CVRa-6Y0.js")
		}), `../../../language/locales/${lang}.json`, 6)
	}]);
	if (!rootLegalEntity || !allowedCountries) return /* @__PURE__ */ jsx(Loader, {});
	const country = getLegalEntityCountry(rootLegalEntity);
	const isAllowed = allowedCountries.includes(country);
	const countryName = countries.find(({ id }) => id === country)?.name ?? country;
	if (!isAllowed) return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(AlertIcon, { variant: "error" }), /* @__PURE__ */ jsx(Header, {
		title: t(($) => $["countryNotSupported"]),
		description: t(($) => $["weDontSupportOnboardingInCountry"], { country: countryName })
	})] });
	return /* @__PURE__ */ jsx(Fragment$1, { children });
};
//#endregion
//#region src/components/Shared/devex/DebugListener/DebugListener.tsx
var DebugModal = lazy(async () => (await import("./DebugModal-DjGbXw-4.js")).DebugModal);
/**
* Adds a listener on the page to open the debug modal when the
* debug modal key combination is pressed to open it
*/
var DebugListener = () => {
	const [debugUiOpen, setDebugUiOpen] = useState$1(false);
	const { isSettingEnabled } = useSettingsContext();
	const debugUiAllowed = isSettingEnabled("allowDebugUi");
	useEffect$1(() => {
		if (!debugUiAllowed) return;
		const handleKeyDown = ({ code, ctrlKey, altKey, shiftKey }) => {
			if (ctrlKey && (altKey || shiftKey) && code === "Backslash") setDebugUiOpen(true);
		};
		document.addEventListener("keydown", handleKeyDown);
		return () => document.removeEventListener("keydown", handleKeyDown);
	}, [debugUiAllowed]);
	return /* @__PURE__ */ jsx(Fragment$1, { children: debugUiAllowed && debugUiOpen ? /* @__PURE__ */ jsx(Suspense, {
		fallback: /* @__PURE__ */ jsx("div", {}),
		children: /* @__PURE__ */ jsx(DebugModal, { onExit: () => setDebugUiOpen(false) })
	}) : null });
};
//#endregion
//#region src/stores/globalStore/StoreProvider.tsx
/**
* `<StoreProvider>` postpones render of the remaining tree until root legal entity data has been
* retrieved and the {@link GlobalStore} has been initialized.
*
* This provider can (and should) also be used from tests and stories.
* If you prefer to mock global state, see {@link MockedStoreProvider}.
*/
var StoreProvider = ({ children }) => {
	const [store, setStore] = useState$1();
	const { data: rootLegalEntity } = useLegalEntity(ROOT_LE);
	useEffect$1(() => {
		if (!rootLegalEntity || store) return;
		setStore(createGlobalStore({ rootLegalEntity }));
	}, [rootLegalEntity, store]);
	if (!store) return /* @__PURE__ */ jsx(Skeleton, {});
	return /* @__PURE__ */ jsx(StoreContext.Provider, {
		value: store,
		children
	});
};
//#endregion
//#region src/core/EmbedShell/EmbedShell.tsx
/** conditional polyfill for container queries */
if (CSS.supports("container", "foo / inline-size") === false) import("container-query-polyfill");
/**
* Bootstraps any component for external usage by consumers
* Import it in your component and wrap it inside the EmbedShell, eg:
*
* @example
* ```jsx
* <EmbedShell {...consumerProps}>
*    <MyReadyToGoForm {...consumerProps} />
* </EmbedShell>
* ```
*
* @param props given by consumer, be it HO, merchant using library or a TaskList component
* @returns
*/
var EmbedShell = ({ children, rootLegalEntityId, settings, features, refreshExperiments, baseUrl, getSdkToken, componentName, locale }) => {
	const { i18n } = useTranslation("common");
	const [isLoading, setIsLoading] = useState$1(true);
	const [hasError, setHasError] = useState$1(false);
	setSdkTokenHandler(getSdkToken);
	const { isFeatureEnabled } = useToggleContext();
	useEffect$1(() => {
		if (locale === "ja-JP" && !isFeatureEnabled("EnableJapanLocalization")) return;
		i18n.changeLanguage(locale);
	}, [
		locale,
		i18n,
		isFeatureEnabled
	]);
	useEffect$1(() => {
		refreshSession().then((hasRefreshed) => {
			if (!hasRefreshed) setHasError(true);
			setIsLoading(false);
		});
	}, []);
	if (hasError) return /* @__PURE__ */ jsxs("div", { children: ["Something went wrong, please", /* @__PURE__ */ jsx(Button, {
		onClick: () => location.reload(),
		children: "refresh the page."
	})] });
	if (isLoading) return /* @__PURE__ */ jsx(Loader, {});
	return /* @__PURE__ */ jsx(SettingsProvider, {
		settings,
		children: /* @__PURE__ */ jsx(QueryClientProvider$1, { children: /* @__PURE__ */ jsx(ApiProvider, {
			rootLegalEntityId,
			baseUrl,
			children: /* @__PURE__ */ jsx(ToggleContextProvider, {
				features,
				refreshExperiments,
				children: /* @__PURE__ */ jsxs(StoreProvider, { children: [/* @__PURE__ */ jsx("span", {
					id: "sdk-version",
					hidden: true,
					children: "4.12.2"
				}), /* @__PURE__ */ jsx(AnalyticsProvider, {
					componentName,
					locale,
					rootLegalEntityId,
					children: /* @__PURE__ */ jsx(Suspense, {
						fallback: /* @__PURE__ */ jsx(Loader, {}),
						children: /* @__PURE__ */ jsxs(AllowedCountryGate, { children: [/* @__PURE__ */ jsx(DebugListener, {}), /* @__PURE__ */ jsx("div", {
							className: "adyen-kyc-ui-element-container-wrapper",
							children: /* @__PURE__ */ jsx("div", {
								className: "adyen-kyc-ui-element-container",
								children: /* @__PURE__ */ jsx(ToastContextProvider, { children: /* @__PURE__ */ jsx(StateProvider, { children }) })
							})
						})] })
					})
				})] })
			})
		}) })
	});
};
//#endregion
//#region src/core/environment/normalizeEnvironment.ts
var normalizeEnvironment = (env) => env.endsWith("/") ? env : `${env}/`;
//#endregion
//#region src/core/environment/resolveEnvironment.ts
var environmentMap = Object.freeze({
	live: "https://onboardingcomponents-live.adyen.com/",
	test: "https://test.adyen.com/"
});
var resolveEnvironment = (environment) => environmentMap[environment] ?? normalizeEnvironment(environment);
//#endregion
export { stylesheets as i, EmbedShell as n, useToggles as r, resolveEnvironment as t };
