UNPKG

@adyen/kyc-components

Version:

This guide assumes that you have already an account with Adyen. A legalEntity needs to be created, and you need to have a `legalEntityId` to instatiate a Component.

855 lines (854 loc) 34.3 kB
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] = "21ea7565-88f7-41d6-b3cb-77f87bb14048", e._sentryDebugIdIdentifier = "sentry-dbid-21ea7565-88f7-41d6-b3cb-77f87bb14048"); } catch (e) {} import { Children, Fragment, Suspense, cloneElement, createContext, createElement, isValidElement, lazy, useCallback, useContext, useEffect, useRef, useState } from "preact/compat"; import cx from "classnames"; import { jsx } from "preact/jsx-runtime"; //#region \0rolldown/runtime.js var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports); var __exportAll = (all, no_symbols) => { let target = {}; for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" }); return target; }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { key = keys[i]; if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: ((k) => from[k]).bind(null, key), enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); //#endregion //#region node_modules/.pnpm/html-parse-stringify@3.0.1/node_modules/html-parse-stringify/dist/html-parse-stringify.module.js var import_void_elements = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => { /** * This file automatically generated from `pre-publish.js`. * Do not manually edit. */ module.exports = { "area": true, "base": true, "br": true, "col": true, "embed": true, "hr": true, "img": true, "input": true, "link": true, "meta": true, "param": true, "source": true, "track": true, "wbr": true }; })))()); var t = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g; function n(n) { var r = { type: "tag", name: "", voidElement: !1, attrs: {}, children: [] }, i = n.match(/<\/?([^\s]+?)[/\s>]/); if (i && (r.name = i[1], (import_void_elements.default[i[1]] || "/" === n.charAt(n.length - 2)) && (r.voidElement = !0), r.name.startsWith("!--"))) { var s = n.indexOf("-->"); return { type: "comment", comment: -1 !== s ? n.slice(4, s) : "" }; } for (var a = new RegExp(t), c = null; null !== (c = a.exec(n));) if (c[0].trim()) if (c[1]) { var o = c[1].trim(), l = [o, ""]; o.indexOf("=") > -1 && (l = o.split("=")), r.attrs[l[0]] = l[1], a.lastIndex--; } else c[2] && (r.attrs[c[2]] = c[3].trim().substring(1, c[3].length - 1)); return r; } var r = /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g, i = /^\s*$/, s = Object.create(null); function a(e, t) { switch (t.type) { case "text": return e + t.content; case "tag": return e += "<" + t.name + (t.attrs ? function(e) { var t = []; for (var n in e) t.push(n + "=\"" + e[n] + "\""); return t.length ? " " + t.join(" ") : ""; }(t.attrs) : "") + (t.voidElement ? "/>" : ">"), t.voidElement ? e : e + t.children.reduce(a, "") + "</" + t.name + ">"; case "comment": return e + "<!--" + t.comment + "-->"; } } var c = { parse: function(e, t) { t || (t = {}), t.components || (t.components = s); var a, c = [], o = [], l = -1, m = !1; if (0 !== e.indexOf("<")) { var u = e.indexOf("<"); c.push({ type: "text", content: -1 === u ? e : e.substring(0, u) }); } return e.replace(r, function(r, s) { if (m) { if (r !== "</" + a.name + ">") return; m = !1; } var u, f = "/" !== r.charAt(1), h = r.startsWith("<!--"), p = s + r.length, d = e.charAt(p); if (h) { var v = n(r); return l < 0 ? (c.push(v), c) : ((u = o[l]).children.push(v), c); } if (f && (l++, "tag" === (a = n(r)).type && t.components[a.name] && (a.type = "component", m = !0), a.voidElement || m || !d || "<" === d || a.children.push({ type: "text", content: e.slice(p, e.indexOf("<", p)) }), 0 === l && c.push(a), (u = o[l - 1]) && u.children.push(a), o[l] = a), (!f || a.voidElement) && (l > -1 && (a.voidElement || a.name === r.slice(2, -1)) && (l--, a = -1 === l ? c : o[l]), !m && "<" !== d && d)) { u = -1 === l ? c : o[l].children; var x = e.indexOf("<", p), g = e.slice(p, -1 === x ? void 0 : x); i.test(g) && (g = " "), (x > -1 && l + u.length >= 0 || " " !== g) && u.push({ type: "text", content: g }); } }), c; }, stringify: function(e) { return e.reduce(function(e, t) { return e + a("", t); }, ""); } }; //#endregion //#region node_modules/.pnpm/react-i18next@15.7.4_@preact+compat@18.3.2_preact@10.29.1__@preact+compat@18.3.2_preact_0ac46649a2538802a85990d3df6dff02/node_modules/react-i18next/dist/es/utils.js var warn = (i18n, code, msg, rest) => { const args = [msg, { code, ...rest || {} }]; if (i18n?.services?.logger?.forward) return i18n.services.logger.forward(args, "warn", "react-i18next::", true); if (isString(args[0])) args[0] = `react-i18next:: ${args[0]}`; if (i18n?.services?.logger?.warn) i18n.services.logger.warn(...args); else if (console?.warn) console.warn(...args); }; var alreadyWarned = {}; var warnOnce = (i18n, code, msg, rest) => { if (isString(msg) && alreadyWarned[msg]) return; if (isString(msg)) alreadyWarned[msg] = /* @__PURE__ */ new Date(); warn(i18n, code, msg, rest); }; var loadedClb = (i18n, cb) => () => { if (i18n.isInitialized) cb(); else { const initialized = () => { setTimeout(() => { i18n.off("initialized", initialized); }, 0); cb(); }; i18n.on("initialized", initialized); } }; var loadNamespaces = (i18n, ns, cb) => { i18n.loadNamespaces(ns, loadedClb(i18n, cb)); }; var loadLanguages = (i18n, lng, ns, cb) => { if (isString(ns)) ns = [ns]; if (i18n.options.preload && i18n.options.preload.indexOf(lng) > -1) return loadNamespaces(i18n, ns, cb); ns.forEach((n) => { if (i18n.options.ns.indexOf(n) < 0) i18n.options.ns.push(n); }); i18n.loadLanguages(lng, loadedClb(i18n, cb)); }; var hasLoadedNamespace = (ns, i18n, options = {}) => { if (!i18n.languages || !i18n.languages.length) { warnOnce(i18n, "NO_LANGUAGES", "i18n.languages were undefined or empty", { languages: i18n.languages }); return true; } return i18n.hasLoadedNamespace(ns, { lng: options.lng, precheck: (i18nInstance, loadNotPending) => { if (options.bindI18n && options.bindI18n.indexOf("languageChanging") > -1 && i18nInstance.services.backendConnector.backend && i18nInstance.isLanguageChangingTo && !loadNotPending(i18nInstance.isLanguageChangingTo, ns)) return false; } }); }; var isString = (obj) => typeof obj === "string"; var isObject = (obj) => typeof obj === "object" && obj !== null; //#endregion //#region node_modules/.pnpm/react-i18next@15.7.4_@preact+compat@18.3.2_preact@10.29.1__@preact+compat@18.3.2_preact_0ac46649a2538802a85990d3df6dff02/node_modules/react-i18next/dist/es/unescape.js var matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g; var htmlEntities = { "&amp;": "&", "&#38;": "&", "&lt;": "<", "&#60;": "<", "&gt;": ">", "&#62;": ">", "&apos;": "'", "&#39;": "'", "&quot;": "\"", "&#34;": "\"", "&nbsp;": " ", "&#160;": " ", "&copy;": "©", "&#169;": "©", "&reg;": "®", "&#174;": "®", "&hellip;": "…", "&#8230;": "…", "&#x2F;": "/", "&#47;": "/" }; var unescapeHtmlEntity = (m) => htmlEntities[m]; var unescape = (text) => text.replace(matchHtmlEntity, unescapeHtmlEntity); //#endregion //#region node_modules/.pnpm/react-i18next@15.7.4_@preact+compat@18.3.2_preact@10.29.1__@preact+compat@18.3.2_preact_0ac46649a2538802a85990d3df6dff02/node_modules/react-i18next/dist/es/defaults.js var defaultOptions = { bindI18n: "languageChanged", bindI18nStore: "", transEmptyNodeValue: "", transSupportBasicHtmlNodes: true, transWrapTextNodes: "", transKeepBasicHtmlNodesFor: [ "br", "strong", "i", "p" ], useSuspense: true, unescape }; var setDefaults = (options = {}) => { defaultOptions = { ...defaultOptions, ...options }; }; var getDefaults = () => defaultOptions; //#endregion //#region node_modules/.pnpm/react-i18next@15.7.4_@preact+compat@18.3.2_preact@10.29.1__@preact+compat@18.3.2_preact_0ac46649a2538802a85990d3df6dff02/node_modules/react-i18next/dist/es/i18nInstance.js var i18nInstance; var setI18n = (instance) => { i18nInstance = instance; }; var getI18n = () => i18nInstance; //#endregion //#region node_modules/.pnpm/react-i18next@15.7.4_@preact+compat@18.3.2_preact@10.29.1__@preact+compat@18.3.2_preact_0ac46649a2538802a85990d3df6dff02/node_modules/react-i18next/dist/es/TransWithoutContext.js var hasChildren = (node, checkLength) => { if (!node) return false; const base = node.props?.children ?? node.children; if (checkLength) return base.length > 0; return !!base; }; var getChildren = (node) => { if (!node) return []; const children = node.props?.children ?? node.children; return node.props?.i18nIsDynamicList ? getAsArray(children) : children; }; var hasValidReactChildren = (children) => Array.isArray(children) && children.every(isValidElement); var getAsArray = (data) => Array.isArray(data) ? data : [data]; var mergeProps = (source, target) => { const newTarget = { ...target }; newTarget.props = Object.assign(source.props, target.props); return newTarget; }; var nodesToString = (children, i18nOptions, i18n, i18nKey) => { if (!children) return ""; let stringNode = ""; const childrenArray = getAsArray(children); const keepArray = i18nOptions?.transSupportBasicHtmlNodes ? i18nOptions.transKeepBasicHtmlNodesFor ?? [] : []; childrenArray.forEach((child, childIndex) => { if (isString(child)) { stringNode += `${child}`; return; } if (isValidElement(child)) { const { props, type } = child; const childPropsCount = Object.keys(props).length; const shouldKeepChild = keepArray.indexOf(type) > -1; const childChildren = props.children; if (!childChildren && shouldKeepChild && !childPropsCount) { stringNode += `<${type}/>`; return; } if (!childChildren && (!shouldKeepChild || childPropsCount) || props.i18nIsDynamicList) { stringNode += `<${childIndex}></${childIndex}>`; return; } if (shouldKeepChild && childPropsCount === 1 && isString(childChildren)) { stringNode += `<${type}>${childChildren}</${type}>`; return; } const content = nodesToString(childChildren, i18nOptions, i18n, i18nKey); stringNode += `<${childIndex}>${content}</${childIndex}>`; return; } if (child === null) { warn(i18n, "TRANS_NULL_VALUE", `Passed in a null value as child`, { i18nKey }); return; } if (isObject(child)) { const { format, ...clone } = child; const keys = Object.keys(clone); if (keys.length === 1) { const value = format ? `${keys[0]}, ${format}` : keys[0]; stringNode += `{{${value}}}`; return; } warn(i18n, "TRANS_INVALID_OBJ", `Invalid child - Object should only have keys {{ value, format }} (format is optional).`, { i18nKey, child }); return; } warn(i18n, "TRANS_INVALID_VAR", `Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`, { i18nKey, child }); }); return stringNode; }; var renderNodes = (children, knownComponentsMap, targetString, i18n, i18nOptions, combinedTOpts, shouldUnescape) => { if (targetString === "") return []; const keepArray = i18nOptions.transKeepBasicHtmlNodesFor || []; const emptyChildrenButNeedsHandling = targetString && new RegExp(keepArray.map((keep) => `<${keep}`).join("|")).test(targetString); if (!children && !knownComponentsMap && !emptyChildrenButNeedsHandling && !shouldUnescape) return [targetString]; const data = knownComponentsMap ?? {}; const getData = (childs) => { getAsArray(childs).forEach((child) => { if (isString(child)) return; if (hasChildren(child)) getData(getChildren(child)); else if (isObject(child) && !isValidElement(child)) Object.assign(data, child); }); }; getData(children); const ast = c.parse(`<0>${targetString}</0>`); const opts = { ...data, ...combinedTOpts }; const renderInner = (child, node, rootReactNode) => { const childs = getChildren(child); const mappedChildren = mapAST(childs, node.children, rootReactNode); return hasValidReactChildren(childs) && mappedChildren.length === 0 || child.props?.i18nIsDynamicList ? childs : mappedChildren; }; const pushTranslatedJSX = (child, inner, mem, i, isVoid) => { if (child.dummy) { child.children = inner; mem.push(cloneElement(child, { key: i }, isVoid ? void 0 : inner)); } else mem.push(...Children.map([child], (c) => { const props = { ...c.props }; delete props.i18nIsDynamicList; return createElement(c.type, { ...props, key: i, ref: c.props.ref ?? c.ref }, isVoid ? null : inner); })); }; const mapAST = (reactNode, astNode, rootReactNode) => { const reactNodes = getAsArray(reactNode); return getAsArray(astNode).reduce((mem, node, i) => { const translationContent = node.children?.[0]?.content && i18n.services.interpolator.interpolate(node.children[0].content, opts, i18n.language); if (node.type === "tag") { let tmp = reactNodes[parseInt(node.name, 10)]; if (!tmp && knownComponentsMap) tmp = knownComponentsMap[node.name]; if (rootReactNode.length === 1 && !tmp) tmp = rootReactNode[0][node.name]; if (!tmp) tmp = {}; const child = Object.keys(node.attrs).length !== 0 ? mergeProps({ props: node.attrs }, tmp) : tmp; const isElement = isValidElement(child); const isValidTranslationWithChildren = isElement && hasChildren(node, true) && !node.voidElement; const isEmptyTransWithHTML = emptyChildrenButNeedsHandling && isObject(child) && child.dummy && !isElement; const isKnownComponent = isObject(knownComponentsMap) && Object.hasOwnProperty.call(knownComponentsMap, node.name); if (isString(child)) { const value = i18n.services.interpolator.interpolate(child, opts, i18n.language); mem.push(value); } else if (hasChildren(child) || isValidTranslationWithChildren) pushTranslatedJSX(child, renderInner(child, node, rootReactNode), mem, i); else if (isEmptyTransWithHTML) pushTranslatedJSX(child, mapAST(reactNodes, node.children, rootReactNode), mem, i); else if (Number.isNaN(parseFloat(node.name))) if (isKnownComponent) pushTranslatedJSX(child, renderInner(child, node, rootReactNode), mem, i, node.voidElement); else if (i18nOptions.transSupportBasicHtmlNodes && keepArray.indexOf(node.name) > -1) if (node.voidElement) mem.push(createElement(node.name, { key: `${node.name}-${i}` })); else { const inner = mapAST(reactNodes, node.children, rootReactNode); mem.push(createElement(node.name, { key: `${node.name}-${i}` }, inner)); } else if (node.voidElement) mem.push(`<${node.name} />`); else { const inner = mapAST(reactNodes, node.children, rootReactNode); mem.push(`<${node.name}>${inner}</${node.name}>`); } else if (isObject(child) && !isElement) { const content = node.children[0] ? translationContent : null; if (content) mem.push(content); } else pushTranslatedJSX(child, translationContent, mem, i, node.children.length !== 1 || !translationContent); } else if (node.type === "text") { const wrapTextNodes = i18nOptions.transWrapTextNodes; const content = shouldUnescape ? i18nOptions.unescape(i18n.services.interpolator.interpolate(node.content, opts, i18n.language)) : i18n.services.interpolator.interpolate(node.content, opts, i18n.language); if (wrapTextNodes) mem.push(createElement(wrapTextNodes, { key: `${node.name}-${i}` }, content)); else mem.push(content); } return mem; }, []); }; return getChildren(mapAST([{ dummy: true, children: children || [] }], ast, getAsArray(children || []))[0]); }; var fixComponentProps = (component, index, translation) => { const componentKey = component.key || index; const comp = cloneElement(component, { key: componentKey }); if (!comp.props || !comp.props.children || translation.indexOf(`${index}/>`) < 0 && translation.indexOf(`${index} />`) < 0) return comp; function Componentized() { return createElement(Fragment, null, comp); } return createElement(Componentized, { key: componentKey }); }; var generateArrayComponents = (components, translation) => components.map((c, index) => fixComponentProps(c, index, translation)); var generateObjectComponents = (components, translation) => { const componentMap = {}; Object.keys(components).forEach((c) => { Object.assign(componentMap, { [c]: fixComponentProps(components[c], c, translation) }); }); return componentMap; }; var generateComponents = (components, translation, i18n, i18nKey) => { if (!components) return null; if (Array.isArray(components)) return generateArrayComponents(components, translation); if (isObject(components)) return generateObjectComponents(components, translation); warnOnce(i18n, "TRANS_INVALID_COMPONENTS", `<Trans /> "components" prop expects an object or array`, { i18nKey }); return null; }; var isComponentsMap = (object) => { if (!isObject(object)) return false; if (Array.isArray(object)) return false; return Object.keys(object).reduce((acc, key) => acc && Number.isNaN(Number.parseFloat(key)), true); }; function Trans$2({ children, count, parent, i18nKey, context, tOptions = {}, values, defaults, components, ns, i18n: i18nFromProps, t: tFromProps, shouldUnescape, ...additionalProps }) { const i18n = i18nFromProps || getI18n(); if (!i18n) { warnOnce(i18n, "NO_I18NEXT_INSTANCE", `Trans: You need to pass in an i18next instance using i18nextReactModule`, { i18nKey }); return children; } const t = tFromProps || i18n.t.bind(i18n) || ((k) => k); const reactI18nextOptions = { ...getDefaults(), ...i18n.options?.react }; let namespaces = ns || t.ns || i18n.options?.defaultNS; namespaces = isString(namespaces) ? [namespaces] : namespaces || ["translation"]; const nodeAsString = nodesToString(children, reactI18nextOptions, i18n, i18nKey); const defaultValue = defaults || nodeAsString || reactI18nextOptions.transEmptyNodeValue || i18nKey; const { hashTransKey } = reactI18nextOptions; const key = i18nKey || (hashTransKey ? hashTransKey(nodeAsString || defaultValue) : nodeAsString || defaultValue); if (i18n.options?.interpolation?.defaultVariables) values = values && Object.keys(values).length > 0 ? { ...values, ...i18n.options.interpolation.defaultVariables } : { ...i18n.options.interpolation.defaultVariables }; const interpolationOverride = values || count !== void 0 && !i18n.options?.interpolation?.alwaysFormat || !children ? tOptions.interpolation : { interpolation: { ...tOptions.interpolation, prefix: "#$?", suffix: "?$#" } }; const combinedTOpts = { ...tOptions, context: context || tOptions.context, count, ...values, ...interpolationOverride, defaultValue, ns: namespaces }; const translation = key ? t(key, combinedTOpts) : defaultValue; const generatedComponents = generateComponents(components, translation, i18n, i18nKey); let indexedChildren = generatedComponents || children; let componentsMap = null; if (isComponentsMap(generatedComponents)) { componentsMap = generatedComponents; indexedChildren = children; } const content = renderNodes(indexedChildren, componentsMap, translation, i18n, reactI18nextOptions, combinedTOpts, shouldUnescape); const useAsParent = parent ?? reactI18nextOptions.defaultTransParent; return useAsParent ? createElement(useAsParent, additionalProps, content) : content; } //#endregion //#region node_modules/.pnpm/react-i18next@15.7.4_@preact+compat@18.3.2_preact@10.29.1__@preact+compat@18.3.2_preact_0ac46649a2538802a85990d3df6dff02/node_modules/react-i18next/dist/es/initReactI18next.js var initReactI18next = { type: "3rdParty", init(instance) { setDefaults(instance.options.react); setI18n(instance); } }; //#endregion //#region node_modules/.pnpm/react-i18next@15.7.4_@preact+compat@18.3.2_preact@10.29.1__@preact+compat@18.3.2_preact_0ac46649a2538802a85990d3df6dff02/node_modules/react-i18next/dist/es/context.js var I18nContext = createContext(); var ReportNamespaces = class { constructor() { this.usedNamespaces = {}; } addUsedNamespaces(namespaces) { namespaces.forEach((ns) => { if (!this.usedNamespaces[ns]) this.usedNamespaces[ns] = true; }); } getUsedNamespaces() { return Object.keys(this.usedNamespaces); } }; //#endregion //#region node_modules/.pnpm/react-i18next@15.7.4_@preact+compat@18.3.2_preact@10.29.1__@preact+compat@18.3.2_preact_0ac46649a2538802a85990d3df6dff02/node_modules/react-i18next/dist/es/Trans.js function Trans$1({ children, count, parent, i18nKey, context, tOptions = {}, values, defaults, components, ns, i18n: i18nFromProps, t: tFromProps, shouldUnescape, ...additionalProps }) { const { i18n: i18nFromContext, defaultNS: defaultNSFromContext } = useContext(I18nContext) || {}; const i18n = i18nFromProps || i18nFromContext || getI18n(); const t = tFromProps || i18n?.t.bind(i18n); return Trans$2({ children, count, parent, i18nKey, context, tOptions, values, defaults, components, ns: ns || t?.ns || defaultNSFromContext || i18n?.options?.defaultNS, i18n, t: tFromProps, shouldUnescape, ...additionalProps }); } //#endregion //#region node_modules/.pnpm/react-i18next@15.7.4_@preact+compat@18.3.2_preact@10.29.1__@preact+compat@18.3.2_preact_0ac46649a2538802a85990d3df6dff02/node_modules/react-i18next/dist/es/useTranslation.js var usePrevious = (value, ignore) => { const ref = useRef(); useEffect(() => { ref.current = ignore ? ref.current : value; }, [value, ignore]); return ref.current; }; var alwaysNewT = (i18n, language, namespace, keyPrefix) => i18n.getFixedT(language, namespace, keyPrefix); var useMemoizedT = (i18n, language, namespace, keyPrefix) => useCallback(alwaysNewT(i18n, language, namespace, keyPrefix), [ i18n, language, namespace, keyPrefix ]); var useTranslation$1 = (ns, props = {}) => { const { i18n: i18nFromProps } = props; const { i18n: i18nFromContext, defaultNS: defaultNSFromContext } = useContext(I18nContext) || {}; const i18n = i18nFromProps || i18nFromContext || getI18n(); if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces(); if (!i18n) { warnOnce(i18n, "NO_I18NEXT_INSTANCE", "useTranslation: You will need to pass in an i18next instance by using initReactI18next"); const notReadyT = (k, optsOrDefaultValue) => { if (isString(optsOrDefaultValue)) return optsOrDefaultValue; if (isObject(optsOrDefaultValue) && isString(optsOrDefaultValue.defaultValue)) return optsOrDefaultValue.defaultValue; return Array.isArray(k) ? k[k.length - 1] : k; }; const retNotReady = [ notReadyT, {}, false ]; retNotReady.t = notReadyT; retNotReady.i18n = {}; retNotReady.ready = false; return retNotReady; } if (i18n.options.react?.wait) warnOnce(i18n, "DEPRECATED_OPTION", "useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour."); const i18nOptions = { ...getDefaults(), ...i18n.options.react, ...props }; const { useSuspense, keyPrefix } = i18nOptions; let namespaces = ns || defaultNSFromContext || i18n.options?.defaultNS; namespaces = isString(namespaces) ? [namespaces] : namespaces || ["translation"]; i18n.reportNamespaces.addUsedNamespaces?.(namespaces); const ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every((n) => hasLoadedNamespace(n, i18n, i18nOptions)); const memoGetT = useMemoizedT(i18n, props.lng || null, i18nOptions.nsMode === "fallback" ? namespaces : namespaces[0], keyPrefix); const getT = () => memoGetT; const getNewT = () => alwaysNewT(i18n, props.lng || null, i18nOptions.nsMode === "fallback" ? namespaces : namespaces[0], keyPrefix); const [t, setT] = useState(getT); let joinedNS = namespaces.join(); if (props.lng) joinedNS = `${props.lng}${joinedNS}`; const previousJoinedNS = usePrevious(joinedNS); const isMounted = useRef(true); useEffect(() => { const { bindI18n, bindI18nStore } = i18nOptions; isMounted.current = true; if (!ready && !useSuspense) if (props.lng) loadLanguages(i18n, props.lng, namespaces, () => { if (isMounted.current) setT(getNewT); }); else loadNamespaces(i18n, namespaces, () => { if (isMounted.current) setT(getNewT); }); if (ready && previousJoinedNS && previousJoinedNS !== joinedNS && isMounted.current) setT(getNewT); const boundReset = () => { if (isMounted.current) setT(getNewT); }; if (bindI18n) i18n?.on(bindI18n, boundReset); if (bindI18nStore) i18n?.store.on(bindI18nStore, boundReset); return () => { isMounted.current = false; if (i18n && bindI18n) bindI18n?.split(" ").forEach((e) => i18n.off(e, boundReset)); if (bindI18nStore && i18n) bindI18nStore.split(" ").forEach((e) => i18n.store.off(e, boundReset)); }; }, [i18n, joinedNS]); useEffect(() => { if (isMounted.current && ready) setT(getT); }, [ i18n, keyPrefix, ready ]); const ret = [ t, i18n, ready ]; ret.t = t; ret.i18n = i18n; ret.ready = ready; if (ready) return ret; if (!ready && !useSuspense) return ret; throw new Promise((resolve) => { if (props.lng) loadLanguages(i18n, props.lng, namespaces, () => resolve()); else loadNamespaces(i18n, namespaces, () => resolve()); }); }; //#endregion //#region src/utils/logger.ts var consoleMethodsPrefixable = Object.freeze([ "debug", "info", "log", "warn", "error", "trace" ]); var stringSubstitutionRegex = /%([soOc]|(\.\d)?[dif])/; /** * Creates a Logger instance */ var createLogger = () => { const methods = {}; consoleMethodsPrefixable.forEach((method) => { methods[method] = (arg1, ...args) => { if (!console[method]) return; if (stringSubstitutionRegex.test(arg1)) console[method](`${arg1}`, ...args); else console[method](arg1, ...args); }; }); return methods; }; var Svg_module_default = { "svg-icon": "adyen-kyc-svg-icon", svgIcon: "adyen-kyc-svg-icon", "svg-image": "adyen-kyc-svg-image", svgImage: "adyen-kyc-svg-image" }; //#endregion //#region src/components/ui/atoms/Svg/svgs.ts /** * Icons are fetched from @adyen/ui-assets-icons-16 package * @see https://adyen-ui-assets.netlify.app/ * * This is a subset of the available icons in the package, not because * of a specific optimization, but vite needs complete paths to icons as * shown below for static analysis. * * How to add a new icon? * Search for it in the url/package above, add the entry below changing * the object key and the svg filename. */ var icons = { "arrow-right": lazy(() => import("./arrow-right-CBQUuXWn.js")), bag: lazy(() => import("./bag-B73BWByo.js")), bank: lazy(() => import("./bank-BfKT2Hlo.js")), bin: lazy(() => import("./bin-CR2JtyeA.js")), check: lazy(() => import("./checkmark-B5bpiMC3.js")), certificate: lazy(() => import("./certificate-Cv-GCGT_.js")), checkmark: lazy(() => import("./checkmark-circle-fill-BEzw_Ad8.js")), "checkmark-circle": lazy(() => import("./checkmark-circle-lv03ep4H.js")), "checkmark-small": lazy(() => import("./checkmark-small-3mQnvwQ8.js")), "chevron-down": lazy(() => import("./chevron-down-dEHOUt1A.js")), "chevron-right": lazy(() => import("./chevron-right-Bul4T3tl.js")), "chevron-left": lazy(() => import("./chevron-left-DPUZ5uGm.js")), "chevron-up": lazy(() => import("./chevron-up-DMqLHgxc.js")), "cash-stack": lazy(() => import("./cash-stack-qIbSKCET.js")), circle: lazy(() => import("./circle-BrnvXI-e.js")), "circle-small-filled": lazy(() => import("./circle-small-filled-ni7ir6ux.js")), clock: lazy(() => import("./clock-CGVkf1Ve.js")), company: lazy(() => import("./headquarter-i418irxh.js")), capital: lazy(() => import("./capital-C0dL_JnU.js")), "company-2": lazy(() => import("./hotel-a4lSlfvp.js")), contract: lazy(() => import("./contract-BKSU2cwd.js")), cross: lazy(() => import("./cross-Du29KQ50.js")), coins: lazy(() => import("./coins-CZegEaHP.js")), "decision-maker": lazy(() => import("./person-oQB0xWxS.js")), document: lazy(() => import("./document-1-aQlMSWwx.js")), download: lazy(() => import("./download-Byq3TeQ7.js")), edit: lazy(() => import("./edit-1-B3TJrgU8.js")), "external-link": lazy(() => import("./external-link-DYtCXxMx.js")), "graph-up": lazy(() => import("./graph-up-CE291Upm.js")), graph: lazy(() => import("./graph-CzlxS7Vy.js")), gift: lazy(() => import("./gift-30hYMA9-.js")), "field-error": lazy(() => import("./warning-circle-fill-8KMHOOon.js")), headquarter: lazy(() => import("./headquarter-i418irxh.js")), "info-circle": lazy(() => import("./info-DEkQ-8WE.js")), "info-circle-filled": lazy(() => import("./info-filled-C68IJNrw.js")), image: lazy(() => import("./image-DobgR711.js")), location: lazy(() => import("./location-CGZGwAk9.js")), "more-horiz": lazy(() => import("./options-horizontal-D-HDgCXI.js")), mail: lazy(() => import("./mail-DoEbKDBx.js")), minusCircleFilled: lazy(() => import("./minus-circle-filled-BnkSMCtd.js")), payByLinkPlane: lazy(() => import("./pay-by-link-plane-CPfnEsJ1.js")), payout: lazy(() => import("./payout-BLb3D4s1.js")), pci: lazy(() => import("./checkmark-circle-lv03ep4H.js")), plus: lazy(() => import("./plus-ohr5jEJX.js")), plusCircleFilled: lazy(() => import("./plus-circle-filled-DjQkTAs3.js")), recurring: lazy(() => import("./recurring-DmyMJdwC.js")), remove: lazy(() => import("./cross-circle-fill-small-CbhK-gt9.js")), error: lazy(() => import("./cross-circle-fill-DKtory30.js")), "revenue-accelerate": lazy(() => import("./revenue-accelerate-BN3AdS3k.js")), save: lazy(() => import("./save-CsdmY84G.js")), search: lazy(() => import("./search-BXGLED99.js")), show: lazy(() => import("./show-nnMbIf7M.js")), solutionPayments: lazy(() => import("./solution-payments-C_H8klpJ.js")), store: lazy(() => import("./store-D8kYfDDN.js")), terminal: lazy(() => import("./terminal-1-B3NwyGSs.js")), trust: lazy(() => import("./partner-d2hFoENh.js")), user: lazy(() => import("./person-oQB0xWxS.js")), "user-business": lazy(() => import("./document-person-CjV96CE2.js")), upload: lazy(() => import("./upload-5PvAU00H.js")), "users-3": lazy(() => import("./4-people-CmxKfDnH.js")), warning: lazy(() => import("./warning-diamond-filled-CKvlLEGk.js")), webinar: lazy(() => import("./webinar-D2TO4Mw_.js")) }; var customIcons = { review: lazy(() => import("./review-CUy6wn1_.js")), "funds-in": lazy(() => import("./funds-in-CAnTUH27.js")), house: lazy(() => import("./house-g9QDTtcl.js")), reporting: lazy(() => import("./reporting-CuIVqmAt.js")) }; var svgs = { ...icons, ...customIcons }; var unscalableIconNames = [ "bin", "check", "checkmark", "checkmark-small", "chevron-right", "chevron-left", "company", "contract", "cross", "decision-maker", "document", "download", "edit", "error", "info-circle", "info-circle-filled", "image", "location", "payout", "pci", "plus", "remove", "save", "search", "trust", "user", "upload", "warning" ]; //#endregion //#region src/components/ui/atoms/Svg/Svg.tsx var logger = createLogger(); var Svg = ({ className, name, testId, title }) => { const LazyLoadedSvg = svgs[name]; /** * TODO: temporary solution to add a viewbox to the ui-asset-icons * If the package gets the viewbox we can safely remove this * If it doesn't we can remove the package and go back to non-package icons * * This is used as a conditional below to make sure that svg that have a viewbox * do not see it getting removed by viewBox={undefined} */ const viewBox = unscalableIconNames.includes(name) ? "0 0 16 16" : void 0; if (!LazyLoadedSvg) { logger.error(`No such svg: "${name}"`); return null; } return /* @__PURE__ */ jsx("span", { className: cx(Svg_module_default[`svg-icon`], className), "data-testid": testId ?? "svg-icon", children: /* @__PURE__ */ jsx(Suspense, { fallback: null, children: viewBox ? /* @__PURE__ */ jsx(LazyLoadedSvg, { "aria-hidden": true, viewBox, title: title || name }) : /* @__PURE__ */ jsx(LazyLoadedSvg, { "aria-hidden": true, title: title || name }) }) }); }; //#endregion //#region src/components/ui/atoms/Icon/Icon.tsx var Icon = ({ name, className, ...props }) => /* @__PURE__ */ jsx(Svg, { className, name, ...props }); //#endregion //#region src/components/ui/atoms/Typography/Typography.tsx var Typography = ({ el = "p", variant = "body", color = "primary", className, children, ...props }) => { const TypographyElement = el; const classNames = cx(className, "adyen-kyc-typography", `adyen-kyc-typography--${color}`, `adyen-kyc-typography--${variant}`); return /* @__PURE__ */ jsx(TypographyElement, { ...props, className: classNames, children }); }; //#endregion //#region src/utils/translation.ts var useTranslation = useTranslation$1; var Trans = Trans$1; var addResourceBundles = (i18n, resourceDetails) => { resourceDetails.forEach(async (resourceDetail) => { const { ns, importFn } = resourceDetail; if (i18n.hasResourceBundle(i18n.language, ns)) return; const namespaceFile = (await importFn(i18n.language)).default; i18n.addResourceBundle(i18n.language, ns, namespaceFile); if (!i18n.hasResourceBundle("en-US", ns)) { const enFile = (await importFn("en-US")).default; i18n.addResourceBundle("en-US", ns, enFile); } }); }; //#endregion export { Icon as a, __exportAll as c, Typography as i, addResourceBundles as n, createLogger as o, useTranslation as r, initReactI18next as s, Trans as t };