@adyen/adyen-web 6.0.0-alpha.0 → 6.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/auto/auto.js +2 -0
  2. package/dist/cjs/adyen.css +1 -1
  3. package/dist/cjs/index.cjs +2 -2
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/index.d.cts +161 -248
  6. package/dist/es/adyen.css +1 -1
  7. package/dist/es/components/ApplePay/ApplePay.js +1 -1
  8. package/dist/es/components/ApplePay/ApplePay.js.map +1 -1
  9. package/dist/es/components/Dropin/Dropin.js +1 -1
  10. package/dist/es/components/Dropin/Dropin.js.map +1 -1
  11. package/dist/es/components/Dropin/components/DropinComponent.js +1 -1
  12. package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
  13. package/dist/es/components/Dropin/defaultProps.js +1 -1
  14. package/dist/es/components/Dropin/defaultProps.js.map +1 -1
  15. package/dist/es/components/GooglePay/GooglePay.js +1 -1
  16. package/dist/es/components/GooglePay/GooglePay.js.map +1 -1
  17. package/dist/es/components/PayPal/Paypal.js +1 -1
  18. package/dist/es/components/PayPal/Paypal.js.map +1 -1
  19. package/dist/es/components/PayPal/components/PaypalButtons.js +1 -1
  20. package/dist/es/components/PayPal/components/PaypalButtons.js.map +1 -1
  21. package/dist/es/components/PayPal/components/PaypalComponent.js +1 -1
  22. package/dist/es/components/PayPal/components/PaypalComponent.js.map +1 -1
  23. package/dist/es/components/PayPal/defaultProps.js +1 -1
  24. package/dist/es/components/PayPal/defaultProps.js.map +1 -1
  25. package/dist/es/components/PayPal/utils/format-paypal-order-contact-to-adyen-format.js +1 -1
  26. package/dist/es/components/PayPal/utils/format-paypal-order-contact-to-adyen-format.js.map +1 -1
  27. package/dist/es/components/PayPal/utils/get-paypal-locale.js +2 -0
  28. package/dist/es/components/PayPal/utils/get-paypal-locale.js.map +1 -0
  29. package/dist/es/components/PayPal/utils/get-paypal-settings.js +2 -0
  30. package/dist/es/components/PayPal/utils/get-paypal-settings.js.map +1 -0
  31. package/dist/es/components/PayPal/utils/get-paypal-styles.js +2 -0
  32. package/dist/es/components/PayPal/utils/get-paypal-styles.js.map +1 -0
  33. package/dist/es/components/PayPal/utils/get-paypal-url.js +2 -0
  34. package/dist/es/components/PayPal/utils/get-paypal-url.js.map +1 -0
  35. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  36. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  37. package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
  38. package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
  39. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  40. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  41. package/dist/es/components/internal/UIElement/utils.js.map +1 -1
  42. package/dist/es/core/AdyenCheckout.js +1 -1
  43. package/dist/es/core/AdyenCheckout.js.map +1 -1
  44. package/dist/es/core/Analytics/Analytics.js +1 -1
  45. package/dist/es/core/Analytics/Analytics.js.map +1 -1
  46. package/dist/es/core/Analytics/EventsQueue.js +1 -1
  47. package/dist/es/core/Analytics/EventsQueue.js.map +1 -1
  48. package/dist/es/core/Analytics/utils.js +1 -1
  49. package/dist/es/core/Analytics/utils.js.map +1 -1
  50. package/dist/es/core/Errors/AdyenCheckoutError.js +1 -1
  51. package/dist/es/core/Errors/AdyenCheckoutError.js.map +1 -1
  52. package/dist/es/core/Errors/utils.js +1 -1
  53. package/dist/es/core/Errors/utils.js.map +1 -1
  54. package/dist/es/core/Services/analytics/collect-id.js +1 -1
  55. package/dist/es/core/Services/analytics/collect-id.js.map +1 -1
  56. package/dist/es/core/Services/analytics/log-event.js +1 -1
  57. package/dist/es/core/config.js +1 -1
  58. package/dist/es/core/config.js.map +1 -1
  59. package/dist/es/core/core.js +1 -1
  60. package/dist/es/core/core.js.map +1 -1
  61. package/dist/es/index.d.ts +161 -248
  62. package/dist/es/language/locales/en-US.json.js +1 -1
  63. package/dist/es/utils/Script.js +1 -1
  64. package/dist/es/utils/Script.js.map +1 -1
  65. package/dist/es-legacy/adyen.css +1 -1
  66. package/dist/es-legacy/components/ApplePay/ApplePay.js +1 -1
  67. package/dist/es-legacy/components/ApplePay/ApplePay.js.map +1 -1
  68. package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
  69. package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
  70. package/dist/es-legacy/components/Dropin/components/DropinComponent.js +1 -1
  71. package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
  72. package/dist/es-legacy/components/Dropin/defaultProps.js +1 -1
  73. package/dist/es-legacy/components/Dropin/defaultProps.js.map +1 -1
  74. package/dist/es-legacy/components/GooglePay/GooglePay.js +1 -1
  75. package/dist/es-legacy/components/GooglePay/GooglePay.js.map +1 -1
  76. package/dist/es-legacy/components/PayPal/Paypal.js +1 -1
  77. package/dist/es-legacy/components/PayPal/Paypal.js.map +1 -1
  78. package/dist/es-legacy/components/PayPal/components/PaypalButtons.js +1 -1
  79. package/dist/es-legacy/components/PayPal/components/PaypalButtons.js.map +1 -1
  80. package/dist/es-legacy/components/PayPal/components/PaypalComponent.js +1 -1
  81. package/dist/es-legacy/components/PayPal/components/PaypalComponent.js.map +1 -1
  82. package/dist/es-legacy/components/PayPal/defaultProps.js +1 -1
  83. package/dist/es-legacy/components/PayPal/defaultProps.js.map +1 -1
  84. package/dist/es-legacy/components/PayPal/utils/format-paypal-order-contact-to-adyen-format.js +1 -1
  85. package/dist/es-legacy/components/PayPal/utils/format-paypal-order-contact-to-adyen-format.js.map +1 -1
  86. package/dist/es-legacy/components/PayPal/utils/get-paypal-locale.js +2 -0
  87. package/dist/es-legacy/components/PayPal/utils/get-paypal-locale.js.map +1 -0
  88. package/dist/es-legacy/components/PayPal/utils/get-paypal-settings.js +2 -0
  89. package/dist/es-legacy/components/PayPal/utils/get-paypal-settings.js.map +1 -0
  90. package/dist/es-legacy/components/PayPal/utils/get-paypal-styles.js +2 -0
  91. package/dist/es-legacy/components/PayPal/utils/get-paypal-styles.js.map +1 -0
  92. package/dist/es-legacy/components/PayPal/utils/get-paypal-url.js +2 -0
  93. package/dist/es-legacy/components/PayPal/utils/get-paypal-url.js.map +1 -0
  94. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  95. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  96. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
  97. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
  98. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  99. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  100. package/dist/es-legacy/components/internal/UIElement/utils.js.map +1 -1
  101. package/dist/es-legacy/core/AdyenCheckout.js +1 -1
  102. package/dist/es-legacy/core/AdyenCheckout.js.map +1 -1
  103. package/dist/es-legacy/core/Analytics/Analytics.js +1 -1
  104. package/dist/es-legacy/core/Analytics/Analytics.js.map +1 -1
  105. package/dist/es-legacy/core/Analytics/EventsQueue.js +1 -1
  106. package/dist/es-legacy/core/Analytics/EventsQueue.js.map +1 -1
  107. package/dist/es-legacy/core/Analytics/utils.js +1 -1
  108. package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
  109. package/dist/es-legacy/core/Errors/AdyenCheckoutError.js +1 -1
  110. package/dist/es-legacy/core/Errors/AdyenCheckoutError.js.map +1 -1
  111. package/dist/es-legacy/core/Errors/utils.js +1 -1
  112. package/dist/es-legacy/core/Errors/utils.js.map +1 -1
  113. package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
  114. package/dist/es-legacy/core/Services/analytics/collect-id.js.map +1 -1
  115. package/dist/es-legacy/core/Services/analytics/log-event.js +1 -1
  116. package/dist/es-legacy/core/config.js +1 -1
  117. package/dist/es-legacy/core/config.js.map +1 -1
  118. package/dist/es-legacy/core/core.js +1 -1
  119. package/dist/es-legacy/core/core.js.map +1 -1
  120. package/dist/es-legacy/language/locales/en-US.json.js +1 -1
  121. package/dist/es-legacy/utils/Script.js +1 -1
  122. package/dist/es-legacy/utils/Script.js.map +1 -1
  123. package/dist/umd/adyen.css +1 -1
  124. package/dist/umd/adyen.js +2 -2
  125. package/dist/umd/adyen.js.map +1 -1
  126. package/package.json +2 -2
  127. package/dist/es/components/PayPal/utils.js +0 -2
  128. package/dist/es/components/PayPal/utils.js.map +0 -1
  129. package/dist/es-legacy/components/PayPal/utils.js +0 -2
  130. package/dist/es-legacy/components/PayPal/utils.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Analytics.js","sources":["../../../../src/core/Analytics/Analytics.ts"],"sourcesContent":["import LogEvent from '../Services/analytics/log-event';\nimport CollectId from '../Services/analytics/collect-id';\nimport EventsQueue, { EventsQueueModule } from './EventsQueue';\nimport { ANALYTICS_EVENT, AnalyticsInitialEvent, AnalyticsObject, AnalyticsProps, CreateAnalyticsEventObject } from './types';\nimport { ANALYTICS_EVENT_ERROR, ANALYTICS_EVENT_INFO, ANALYTICS_EVENT_LOG, ANALYTICS_INFO_TIMER_INTERVAL, ANALYTICS_PATH } from './constants';\nimport { debounce } from '../../utils/debounce';\nimport { AnalyticsModule } from '../../types/global-types';\nimport { createAnalyticsObject } from './utils';\nimport { analyticsPreProcessor } from './analyticsPreProcessor';\n\nlet capturedCheckoutAttemptId = null;\nlet hasLoggedPixel = false;\nlet sendEventsTimerId = null;\n\nconst Analytics = ({ loadingContext, locale, clientKey, analytics, amount, analyticsContext }: AnalyticsProps): AnalyticsModule => {\n const defaultProps = {\n enabled: true,\n telemetry: true,\n checkoutAttemptId: null\n };\n\n const props = { ...defaultProps, ...analytics };\n\n const { telemetry, enabled } = props;\n if (telemetry === true && enabled === true) {\n if (props.checkoutAttemptId) {\n // handle prefilled checkoutAttemptId // TODO is this still something that ever happens?\n capturedCheckoutAttemptId = props.checkoutAttemptId;\n }\n }\n\n const logEvent = LogEvent({ loadingContext, locale });\n const collectId = CollectId({ analyticsContext, clientKey, locale, amount, analyticsPath: ANALYTICS_PATH });\n const eventsQueue: EventsQueueModule = EventsQueue({ analyticsContext, clientKey, analyticsPath: ANALYTICS_PATH });\n\n const sendAnalyticsEvents = () => {\n if (capturedCheckoutAttemptId) {\n return eventsQueue.run(capturedCheckoutAttemptId);\n }\n return Promise.resolve(null);\n };\n\n const addAnalyticsEvent = (type: ANALYTICS_EVENT, obj: AnalyticsObject) => {\n const arrayName = type === ANALYTICS_EVENT_INFO ? type : `${type}s`;\n eventsQueue.add(`${arrayName}`, obj);\n\n /**\n * The logic is:\n * - info events are stored until a log or error comes along,\n * but, if after a set time, no other analytics event (log or error) has come along then we send the info events anyway\n */\n if (type === ANALYTICS_EVENT_INFO) {\n clearTimeout(sendEventsTimerId);\n sendEventsTimerId = setTimeout(sendAnalyticsEvents, ANALYTICS_INFO_TIMER_INTERVAL);\n }\n\n /**\n * The logic is:\n * - errors and logs get sent straightaway\n * ...but... tests with the 3DS2 process show that many logs can happen almost at the same time (or you can have an error followed immediately by a log),\n * so instead of making several sequential api calls we see if we can \"batch\" them using debounce\n */\n if (type === ANALYTICS_EVENT_LOG || type === ANALYTICS_EVENT_ERROR) {\n clearTimeout(sendEventsTimerId); // clear any timer that might be about to dispatch the info events array\n\n debounce(sendAnalyticsEvents)();\n }\n };\n\n const anlModule: AnalyticsModule = {\n setUp: async (initialEvent: AnalyticsInitialEvent) => {\n const { enabled, payload, telemetry } = props; // TODO what is payload, is it ever used?\n\n // console.log('### Analytics::setUp:: initialEvent', initialEvent);\n\n if (enabled === true) {\n if (telemetry === true && !capturedCheckoutAttemptId) {\n try {\n // fetch a new checkoutAttemptId if none is already available\n const checkoutAttemptId = await collectId({ ...initialEvent, ...(payload && { ...payload }) });\n capturedCheckoutAttemptId = checkoutAttemptId;\n } catch (e) {\n // Caught at collectId level. We do not expect this catch block to ever fire, but... just in case...\n console.debug(`Fetching checkoutAttemptId failed.${e ? ` Error=${e}` : ''}`);\n }\n }\n\n if (!hasLoggedPixel) {\n // Log pixel\n // TODO once we stop using the pixel we can stop requiring both \"enabled\" & \"telemetry\" config options.\n // And v6 will have a \"level: 'none\" | \"all\" | \"minimal\" config prop\n logEvent(initialEvent);\n hasLoggedPixel = true;\n }\n }\n },\n\n getCheckoutAttemptId: (): string => capturedCheckoutAttemptId,\n\n // Expose getter for testing purposes\n getEventsQueue: () => eventsQueue,\n\n createAnalyticsEvent: ({ event, data }: CreateAnalyticsEventObject) => {\n const aObj: AnalyticsObject = createAnalyticsObject({\n event,\n ...data\n });\n // console.log('### Analytics::createAnalyticsEvent:: event=', event, ' aObj=', aObj);\n\n addAnalyticsEvent(event, aObj);\n },\n\n getEnabled: () => props.enabled,\n\n sendAnalytics: null\n };\n\n anlModule.sendAnalytics = analyticsPreProcessor(anlModule);\n\n return anlModule;\n};\n\nexport default Analytics;\n"],"names":["capturedCheckoutAttemptId","hasLoggedPixel","sendEventsTimerId","Analytics","loadingContext","locale","clientKey","analytics","amount","analyticsContext","props","enabled","telemetry","checkoutAttemptId","logEvent","LogEvent","collectId","CollectId","analyticsPath","ANALYTICS_PATH","eventsQueue","EventsQueue","sendAnalyticsEvents","run","Promise","resolve","anlModule","setUp","async","initialEvent","payload","e","console","debug","getCheckoutAttemptId","getEventsQueue","createAnalyticsEvent","event","data","type","obj","arrayName","ANALYTICS_EVENT_INFO","add","clearTimeout","setTimeout","ANALYTICS_INFO_TIMER_INTERVAL","ANALYTICS_EVENT_LOG","ANALYTICS_EVENT_ERROR","debounce","addAnalyticsEvent","createAnalyticsObject","aObj","getEnabled","sendAnalytics","analyticsPreProcessor"],"mappings":"+cAUA,IAAIA,EAA4B,KAC5BC,GAAiB,EACjBC,EAAoB,KAExB,MAAMC,EAAY,EAAGC,iBAAgBC,SAAQC,YAAWC,YAAWC,SAAQC,uBACvE,MAMMC,EAAQ,CALVC,SAAS,EACTC,WAAW,EACXC,kBAAmB,QAGaN,IAE9BK,UAAEA,EAASD,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from '../Services/analytics/log-event';\nimport CollectId from '../Services/analytics/collect-id';\nimport EventsQueue, { EventsQueueModule } from './EventsQueue';\nimport { ANALYTICS_EVENT, AnalyticsInitialEvent, AnalyticsObject, AnalyticsProps, CreateAnalyticsEventObject } from './types';\nimport { ANALYTICS_EVENT_ERROR, ANALYTICS_EVENT_INFO, ANALYTICS_EVENT_LOG, ANALYTICS_INFO_TIMER_INTERVAL, ANALYTICS_PATH } from './constants';\nimport { debounce } from '../../utils/debounce';\nimport { AnalyticsModule } from '../../types/global-types';\nimport { createAnalyticsObject } from './utils';\nimport { analyticsPreProcessor } from './analyticsPreProcessor';\n\nlet capturedCheckoutAttemptId = null;\nlet hasLoggedPixel = false;\nlet sendEventsTimerId = null;\n\nconst Analytics = ({ loadingContext, locale, clientKey, analytics, amount, analyticsContext, bundleType }: AnalyticsProps): AnalyticsModule => {\n const defaultProps = {\n enabled: true,\n telemetry: true,\n checkoutAttemptId: null\n };\n\n const props = { ...defaultProps, ...analytics };\n\n const { telemetry, enabled } = props;\n if (telemetry === true && enabled === true) {\n if (props.checkoutAttemptId) {\n // handle prefilled checkoutAttemptId // TODO is this still something that ever happens?\n capturedCheckoutAttemptId = props.checkoutAttemptId;\n }\n }\n\n const logEvent = LogEvent({ loadingContext, locale });\n const collectId = CollectId({ analyticsContext, clientKey, locale, amount, analyticsPath: ANALYTICS_PATH, bundleType });\n const eventsQueue: EventsQueueModule = EventsQueue({ analyticsContext, clientKey, analyticsPath: ANALYTICS_PATH });\n\n const sendAnalyticsEvents = () => {\n if (capturedCheckoutAttemptId) {\n return eventsQueue.run(capturedCheckoutAttemptId);\n }\n return Promise.resolve(null);\n };\n\n const addAnalyticsEvent = (type: ANALYTICS_EVENT, obj: AnalyticsObject) => {\n const arrayName = type === ANALYTICS_EVENT_INFO ? type : `${type}s`;\n eventsQueue.add(`${arrayName}`, obj);\n\n /**\n * The logic is:\n * - info events are stored until a log or error comes along,\n * but, if after a set time, no other analytics event (log or error) has come along then we send the info events anyway\n */\n if (type === ANALYTICS_EVENT_INFO) {\n clearTimeout(sendEventsTimerId);\n sendEventsTimerId = setTimeout(sendAnalyticsEvents, ANALYTICS_INFO_TIMER_INTERVAL);\n }\n\n /**\n * The logic is:\n * - errors and logs get sent straightaway\n * ...but... tests with the 3DS2 process show that many logs can happen almost at the same time (or you can have an error followed immediately by a log),\n * so instead of making several sequential api calls we see if we can \"batch\" them using debounce\n */\n if (type === ANALYTICS_EVENT_LOG || type === ANALYTICS_EVENT_ERROR) {\n clearTimeout(sendEventsTimerId); // clear any timer that might be about to dispatch the info events array\n\n debounce(sendAnalyticsEvents)();\n }\n };\n\n const anlModule: AnalyticsModule = {\n setUp: async (initialEvent: AnalyticsInitialEvent) => {\n const { enabled, payload, telemetry } = props; // TODO what is payload, is it ever used?\n\n // console.log('### Analytics::setUp:: initialEvent', initialEvent);\n\n if (enabled === true) {\n if (telemetry === true && !capturedCheckoutAttemptId) {\n try {\n // fetch a new checkoutAttemptId if none is already available\n const checkoutAttemptId = await collectId({ ...initialEvent, ...(payload && { ...payload }) });\n capturedCheckoutAttemptId = checkoutAttemptId;\n } catch (e) {\n console.warn(`Fetching checkoutAttemptId failed.${e ? ` Error=${e}` : ''}`);\n }\n }\n\n if (!hasLoggedPixel) {\n // Log pixel\n // TODO once we stop using the pixel we can stop requiring both \"enabled\" & \"telemetry\" config options.\n // And v6 will have a \"level: 'none\" | \"all\" | \"minimal\" config prop\n logEvent(initialEvent);\n hasLoggedPixel = true;\n }\n }\n },\n\n getCheckoutAttemptId: (): string => capturedCheckoutAttemptId,\n\n // Expose getter for testing purposes\n getEventsQueue: () => eventsQueue,\n\n createAnalyticsEvent: ({ event, data }: CreateAnalyticsEventObject) => {\n const aObj: AnalyticsObject = createAnalyticsObject({\n event,\n ...data\n });\n // console.log('### Analytics::createAnalyticsEvent:: event=', event, ' aObj=', aObj);\n\n addAnalyticsEvent(event, aObj);\n },\n\n getEnabled: () => props.enabled,\n\n sendAnalytics: null\n };\n\n anlModule.sendAnalytics = analyticsPreProcessor(anlModule);\n\n return anlModule;\n};\n\nexport default Analytics;\n"],"names":["capturedCheckoutAttemptId","hasLoggedPixel","sendEventsTimerId","Analytics","loadingContext","locale","clientKey","analytics","amount","analyticsContext","bundleType","props","enabled","telemetry","checkoutAttemptId","logEvent","LogEvent","collectId","CollectId","analyticsPath","ANALYTICS_PATH","eventsQueue","EventsQueue","sendAnalyticsEvents","run","Promise","resolve","anlModule","setUp","async","initialEvent","payload","e","console","warn","getCheckoutAttemptId","getEventsQueue","createAnalyticsEvent","event","data","type","obj","arrayName","ANALYTICS_EVENT_INFO","add","clearTimeout","setTimeout","ANALYTICS_INFO_TIMER_INTERVAL","ANALYTICS_EVENT_LOG","ANALYTICS_EVENT_ERROR","debounce","addAnalyticsEvent","createAnalyticsObject","aObj","getEnabled","sendAnalytics","analyticsPreProcessor"],"mappings":"+cAUA,IAAIA,EAA4B,KAC5BC,GAAiB,EACjBC,EAAoB,KAExB,MAAMC,EAAY,EAAGC,iBAAgBC,SAAQC,YAAWC,YAAWC,SAAQC,mBAAkBC,iBACzF,MAMMC,EAAQ,CALVC,SAAS,EACTC,WAAW,EACXC,kBAAmB,QAGaP,IAE9BM,UAAEA,EAASD,QAAEA,GAAYD,GACb,IAAdE,IAAkC,IAAZD,GAClBD,EAAMG,oBAENd,EAA4BW,EAAMG,mBAI1C,MAAMC,EAAWC,EAAS,CAAEZ,iBAAgBC,WACtCY,EAAYC,EAAU,CAAET,mBAAkBH,YAAWD,SAAQG,SAAQW,cAAeC,EAAgBV,eACpGW,EAAiCC,EAAY,CAAEb,mBAAkBH,YAAWa,cAAeC,IAE3FG,EAAsB,IACpBvB,EACOqB,EAAYG,IAAIxB,GAEpByB,QAAQC,QAAQ,MA8BrBC,EAA6B,CAC/BC,MAAOC,MAAOC,IACV,MAAMlB,QAAEA,EAAOmB,QAAEA,EAAOlB,UAAEA,GAAcF,EAIxC,IAAgB,IAAZC,EAAkB,CAClB,IAAkB,IAAdC,IAAuBb,EACvB,IAEI,MAAMc,QAA0BG,EAAU,IAAKa,KAAkBC,GAAW,IAAKA,KACjF/B,EAA4Bc,CAChC,CAAE,MAAOkB,GACLC,QAAQC,KAAK,sCAAqCF,EAAI,UAAUA,IAAM,IAC1E,CAGC/B,IAIDc,EAASe,GACT7B,GAAiB,EAEzB,GAGJkC,qBAAsB,IAAcnC,EAGpCoC,eAAgB,IAAMf,EAEtBgB,qBAAsB,EAAGC,QAAOC,WA3DV,EAACC,EAAuBC,KAC9C,MAAMC,EAAYF,IAASG,EAAuBH,EAAO,GAAGA,KAC5DnB,EAAYuB,IAAI,GAAGF,IAAaD,GAO5BD,IAASG,IACTE,aAAa3C,GACbA,EAAoB4C,WAAWvB,EAAqBwB,IASpDP,IAASQ,GAAuBR,IAASS,IACzCJ,aAAa3C,GAEbgD,EAAS3B,EAAT2B,GACJ,EA0CIC,CAAkBb,EANYc,EAAsB,CAChDd,WACGC,IAIkBc,EAG7BC,WAAY,IAAM3C,EAAMC,QAExB2C,cAAe,MAKnB,OAFA5B,EAAU4B,cAAgBC,EAAsB7B,GAEzCA,CAAAA"}
@@ -1,2 +1,2 @@
1
- import{httpPost as e}from"../Services/http.js";const t=({analyticsContext:t,clientKey:n,analyticsPath:o})=>{const r={channel:"Web",info:[],errors:[],logs:[]};return{add:(e,t)=>{r[e].push(t)},run:s=>{const l=(s=>r.info.length||r.logs.length||r.errors.length?e({errorLevel:"silent",loadingContext:t,path:`${o}/${s}?clientKey=${n}`},r).then((()=>{})).catch((()=>{console.debug("### EventsQueue:::: send has failed")})):Promise.resolve(null))(s);return r.info=[],r.errors=[],r.logs=[],l},getQueue:()=>r}};export{t as default};
1
+ import{httpPost as e}from"../Services/http.js";const t=({analyticsContext:t,clientKey:n,analyticsPath:o})=>{const r={channel:"Web",platform:"Web",info:[],errors:[],logs:[]};return{add:(e,t)=>{r[e].push(t)},run:s=>{const l=(s=>r.info.length||r.logs.length||r.errors.length?e({errorLevel:"silent",loadingContext:t,path:`${o}/${s}?clientKey=${n}`},r).then((()=>{})).catch((()=>{console.debug("### EventsQueue:::: send has failed")})):Promise.resolve(null))(s);return r.info=[],r.errors=[],r.logs=[],l},getQueue:()=>r}};export{t as default};
2
2
  //# sourceMappingURL=EventsQueue.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EventsQueue.js","sources":["../../../../src/core/Analytics/EventsQueue.ts"],"sourcesContent":["import { HttpOptions, httpPost } from '../Services/http';\nimport { AnalyticsObject, EventQueueProps } from './types';\n\ninterface CAActions {\n channel: 'Web';\n info: AnalyticsObject[];\n errors: AnalyticsObject[];\n logs: AnalyticsObject[];\n}\n\nexport interface EventsQueueModule {\n add: (t: string, o: AnalyticsObject) => void;\n run: (id: string) => Promise<any>;\n getQueue: () => CAActions;\n}\n\nconst EventsQueue = ({ analyticsContext, clientKey, analyticsPath }: EventQueueProps): EventsQueueModule => {\n const caActions: CAActions = {\n channel: 'Web',\n info: [],\n errors: [],\n logs: []\n };\n\n const runQueue = (checkoutAttemptId: string): Promise<any> => {\n if (!caActions.info.length && !caActions.logs.length && !caActions.errors.length) {\n return Promise.resolve(null);\n }\n\n const options: HttpOptions = {\n errorLevel: 'silent' as const,\n loadingContext: analyticsContext,\n path: `${analyticsPath}/${checkoutAttemptId}?clientKey=${clientKey}`\n };\n\n const promise = httpPost(options, caActions)\n .then(() => {\n // Succeed, silently\n return undefined;\n })\n .catch(() => {\n // Caught, silently, at http level. We do not expect this catch block to ever fire, but... just in case...\n console.debug('### EventsQueue:::: send has failed');\n });\n\n return promise;\n };\n\n const eqModule: EventsQueueModule = {\n add: (type, actionObj) => {\n caActions[type].push(actionObj);\n },\n\n run: (checkoutAttemptId: string) => {\n const promise = runQueue(checkoutAttemptId);\n\n caActions.info = [];\n caActions.errors = [];\n caActions.logs = [];\n\n return promise;\n },\n\n // Expose getter for testing purposes\n getQueue: () => caActions\n };\n\n return eqModule;\n};\n\nexport default EventsQueue;\n"],"names":["EventsQueue","analyticsContext","clientKey","analyticsPath","caActions","channel","info","errors","logs","add","type","actionObj","push","run","checkoutAttemptId","promise","length","httpPost","errorLevel","loadingContext","path","then","undefined","catch","console","debug","Promise","resolve","runQueue","getQueue","eqModule"],"mappings":"+CAgBMA,MAAAA,EAAc,EAAGC,mBAAkBC,YAAWC,oBAChD,MAAMC,EAAuB,CACzBC,QAAS,MACTC,KAAM,GACNC,OAAQ,GACRC,KAAM,IA8CV,MAnBoC,CAChCC,IAAK,CAACC,EAAMC,KACRP,EAAUM,GAAME,KAAKD,EAAAA,EAGzBE,IAAMC,IACF,MAAMC,EA9BG,CAACD,GACTV,EAAUE,KAAKU,QAAWZ,EAAUI,KAAKQ,QAAWZ,EAAUG,OAAOS,OAU1DC,EANa,CACzBC,WAAY,SACZC,eAAgBlB,EAChBmB,KAAM,GAAGjB,KAAiBW,eAA+BZ,KAG3BE,GAC7BiB,MAAK,KAEKC,IAEVC,OAAM,KAEHC,QAAQC,MAAM,sCAAA,IAhBXC,QAAQC,QAAQ,MA4BPC,CAASd,GAMzB,OAJAV,EAAUE,KAAO,GACjBF,EAAUG,OAAS,GACnBH,EAAUI,KAAO,GAEVO,CAAAA,EAIXc,SAAU,IAAMzB,EAGb0B"}
1
+ {"version":3,"file":"EventsQueue.js","sources":["../../../../src/core/Analytics/EventsQueue.ts"],"sourcesContent":["import { HttpOptions, httpPost } from '../Services/http';\nimport { AnalyticsObject, EventQueueProps } from './types';\n\ninterface CAActions {\n channel: 'Web';\n platform: 'Web';\n info: AnalyticsObject[];\n errors: AnalyticsObject[];\n logs: AnalyticsObject[];\n}\n\nexport interface EventsQueueModule {\n add: (t: string, o: AnalyticsObject) => void;\n run: (id: string) => Promise<any>;\n getQueue: () => CAActions;\n}\n\nconst EventsQueue = ({ analyticsContext, clientKey, analyticsPath }: EventQueueProps): EventsQueueModule => {\n const caActions: CAActions = {\n channel: 'Web',\n platform: 'Web',\n info: [],\n errors: [],\n logs: []\n };\n\n const runQueue = (checkoutAttemptId: string): Promise<any> => {\n if (!caActions.info.length && !caActions.logs.length && !caActions.errors.length) {\n return Promise.resolve(null);\n }\n\n const options: HttpOptions = {\n errorLevel: 'silent' as const,\n loadingContext: analyticsContext,\n path: `${analyticsPath}/${checkoutAttemptId}?clientKey=${clientKey}`\n };\n\n const promise = httpPost(options, caActions)\n .then(() => {\n // Succeed, silently\n return undefined;\n })\n .catch(() => {\n // Caught, silently, at http level. We do not expect this catch block to ever fire, but... just in case...\n console.debug('### EventsQueue:::: send has failed');\n });\n\n return promise;\n };\n\n const eqModule: EventsQueueModule = {\n add: (type, actionObj) => {\n caActions[type].push(actionObj);\n },\n\n run: (checkoutAttemptId: string) => {\n const promise = runQueue(checkoutAttemptId);\n\n caActions.info = [];\n caActions.errors = [];\n caActions.logs = [];\n\n return promise;\n },\n\n // Expose getter for testing purposes\n getQueue: () => caActions\n };\n\n return eqModule;\n};\n\nexport default EventsQueue;\n"],"names":["EventsQueue","analyticsContext","clientKey","analyticsPath","caActions","channel","platform","info","errors","logs","add","type","actionObj","push","run","checkoutAttemptId","promise","length","httpPost","errorLevel","loadingContext","path","then","undefined","catch","console","debug","Promise","resolve","runQueue","getQueue","eqModule"],"mappings":"+CAiBMA,MAAAA,EAAc,EAAGC,mBAAkBC,YAAWC,oBAChD,MAAMC,EAAuB,CACzBC,QAAS,MACTC,SAAU,MACVC,KAAM,GACNC,OAAQ,GACRC,KAAM,IA8CV,MAnBoC,CAChCC,IAAK,CAACC,EAAMC,KACRR,EAAUO,GAAME,KAAKD,EAAAA,EAGzBE,IAAMC,IACF,MAAMC,EA9BG,CAACD,GACTX,EAAUG,KAAKU,QAAWb,EAAUK,KAAKQ,QAAWb,EAAUI,OAAOS,OAU1DC,EANa,CACzBC,WAAY,SACZC,eAAgBnB,EAChBoB,KAAM,GAAGlB,KAAiBY,eAA+Bb,KAG3BE,GAC7BkB,MAAK,KAEKC,IAEVC,OAAM,KAEHC,QAAQC,MAAM,sCAAA,IAhBXC,QAAQC,QAAQ,MA4BPC,CAASd,GAMzB,OAJAX,EAAUG,KAAO,GACjBH,EAAUI,OAAS,GACnBJ,EAAUK,KAAO,GAEVO,CAAAA,EAIXc,SAAU,IAAM1B,EAGb2B"}
@@ -1,2 +1,2 @@
1
- import{ANALYTICS_ACTION_STR as e,ANALYTICS_VALIDATION_ERROR_STR as t}from"./constants.js";const o=()=>Date.now(),r=r=>({timestamp:String(o()),component:r.component,..."error"===r.event&&{code:r.code,errorType:r.errorType,message:r.message},..."log"===r.event&&{type:r.type,message:r.message},..."log"===r.event&&r.type===e&&{subType:r.subtype},..."info"===r.event&&{type:r.type,target:r.target,issuer:r.issuer},..."info"===r.event&&r.isStoredPaymentMethod&&{isStoredPaymentMethod:r.isStoredPaymentMethod,brand:r.brand},..."info"===r.event&&r.type===t&&{validationErrorCode:r.validationErrorCode,validationErrorMessage:r.validationErrorMessage},...r.metadata&&{metadata:r.metadata}});export{r as createAnalyticsObject,o as getUTCTimestamp};
1
+ import{ANALYTICS_ACTION_STR as e,ANALYTICS_VALIDATION_ERROR_STR as t}from"./constants.js";import o from"../../utils/uuid.js";const r=()=>Date.now(),a=a=>({timestamp:String(r()),component:a.component,id:o(),..."error"===a.event&&{code:a.code,errorType:a.errorType,message:a.message},..."log"===a.event&&{type:a.type,message:a.message},..."log"===a.event&&a.type===e&&{subType:a.subtype},..."info"===a.event&&{type:a.type,target:a.target,issuer:a.issuer},..."info"===a.event&&a.isStoredPaymentMethod&&{isStoredPaymentMethod:a.isStoredPaymentMethod,brand:a.brand},..."info"===a.event&&a.type===t&&{validationErrorCode:a.validationErrorCode,validationErrorMessage:a.validationErrorMessage},...a.metadata&&{metadata:a.metadata}});export{a as createAnalyticsObject,r as getUTCTimestamp};
2
2
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../src/core/Analytics/utils.ts"],"sourcesContent":["import { AnalyticsObject, CreateAnalyticsObject } from './types';\nimport { ANALYTICS_ACTION_STR, ANALYTICS_VALIDATION_ERROR_STR } from './constants';\n\nexport const getUTCTimestamp = () => Date.now();\n\n/**\n * All objects for the /checkoutanalytics endpoint have base props:\n * \"timestamp\" & \"component\"\n *\n * Error objects have, in addition to the base props:\n * \"code\", \"errorType\" & \"message\"\n *\n * Log objects have, in addition to the base props:\n * \"message\" & \"type\" &\n * \"subtype\" (e.g. when an action is handled)\n *\n * Info objects have, in addition to the base props:\n * \"type\" & \"target\" &\n * \"isStoredPaymentMethod\" & \"brand\" (when a storedCard is \"selected\"), or,\n * \"validationErrorCode\" & \"validationErrorMessage\" (when the event is describing a validation error)\n *\n * All objects can also have a \"metadata\" object of key-value pairs\n */\nexport const createAnalyticsObject = (aObj: CreateAnalyticsObject): AnalyticsObject => ({\n timestamp: String(getUTCTimestamp()),\n component: aObj.component,\n /** ERROR */\n ...(aObj.event === 'error' && { code: aObj.code, errorType: aObj.errorType, message: aObj.message }), // error event\n /** LOG */\n ...(aObj.event === 'log' && { type: aObj.type, message: aObj.message }), // log event\n ...(aObj.event === 'log' && aObj.type === ANALYTICS_ACTION_STR && { subType: aObj.subtype }), // only added if we have a log event of Action type\n /** INFO */\n ...(aObj.event === 'info' && { type: aObj.type, target: aObj.target, issuer: aObj.issuer }), // info event\n ...(aObj.event === 'info' && aObj.isStoredPaymentMethod && { isStoredPaymentMethod: aObj.isStoredPaymentMethod, brand: aObj.brand }), // only added if we have an info event about a storedPM\n ...(aObj.event === 'info' &&\n aObj.type === ANALYTICS_VALIDATION_ERROR_STR && {\n validationErrorCode: aObj.validationErrorCode,\n validationErrorMessage: aObj.validationErrorMessage\n }), // only added if we have an info event describing a validation error\n /** All */\n ...(aObj.metadata && { metadata: aObj.metadata })\n});\n"],"names":["getUTCTimestamp","Date","now","createAnalyticsObject","aObj","timestamp","String","component","event","code","errorType","message","type","ANALYTICS_ACTION_STR","subType","subtype","target","issuer","isStoredPaymentMethod","brand","ANALYTICS_VALIDATION_ERROR_STR","validationErrorCode","validationErrorMessage","metadata"],"mappings":"0FAGaA,MAAAA,EAAkB,IAAMC,KAAKC,MAoB7BC,EAAyBC,IAAkD,CACpFC,UAAWC,OAAON,KAClBO,UAAWH,EAAKG,aAEG,UAAfH,EAAKI,OAAqB,CAAEC,KAAML,EAAKK,KAAMC,UAAWN,EAAKM,UAAWC,QAASP,EAAKO,YAEvE,QAAfP,EAAKI,OAAmB,CAAEI,KAAMR,EAAKQ,KAAMD,QAASP,EAAKO,YAC1C,QAAfP,EAAKI,OAAmBJ,EAAKQ,OAASC,GAAwB,CAAEC,QAASV,EAAKW,YAE/D,SAAfX,EAAKI,OAAoB,CAAEI,KAAMR,EAAKQ,KAAMI,OAAQZ,EAAKY,OAAQC,OAAQb,EAAKa,WAC/D,SAAfb,EAAKI,OAAoBJ,EAAKc,uBAAyB,CAAEA,sBAAuBd,EAAKc,sBAAuBC,MAAOf,EAAKe,UACzG,SAAff,EAAKI,OACLJ,EAAKQ,OAASQ,GAAkC,CAC5CC,oBAAqBjB,EAAKiB,oBAC1BC,uBAAwBlB,EAAKkB,2BAGjClB,EAAKmB,UAAY,CAAEA,SAAUnB,EAAKmB"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../src/core/Analytics/utils.ts"],"sourcesContent":["import { AnalyticsObject, CreateAnalyticsObject } from './types';\nimport { ANALYTICS_ACTION_STR, ANALYTICS_VALIDATION_ERROR_STR } from './constants';\nimport uuid from '../../utils/uuid';\n\nexport const getUTCTimestamp = () => Date.now();\n\n/**\n * All objects for the /checkoutanalytics endpoint have base props:\n * \"timestamp\" & \"component\"\n *\n * Error objects have, in addition to the base props:\n * \"code\", \"errorType\" & \"message\"\n *\n * Log objects have, in addition to the base props:\n * \"message\" & \"type\" &\n * \"subtype\" (e.g. when an action is handled)\n *\n * Info objects have, in addition to the base props:\n * \"type\" & \"target\" &\n * \"isStoredPaymentMethod\" & \"brand\" (when a storedCard is \"selected\"), or,\n * \"validationErrorCode\" & \"validationErrorMessage\" (when the event is describing a validation error)\n *\n * All objects can also have a \"metadata\" object of key-value pairs\n */\nexport const createAnalyticsObject = (aObj: CreateAnalyticsObject): AnalyticsObject => ({\n timestamp: String(getUTCTimestamp()),\n component: aObj.component,\n id: uuid(),\n /** ERROR */\n ...(aObj.event === 'error' && { code: aObj.code, errorType: aObj.errorType, message: aObj.message }), // error event\n /** LOG */\n ...(aObj.event === 'log' && { type: aObj.type, message: aObj.message }), // log event\n ...(aObj.event === 'log' && aObj.type === ANALYTICS_ACTION_STR && { subType: aObj.subtype }), // only added if we have a log event of Action type\n /** INFO */\n ...(aObj.event === 'info' && { type: aObj.type, target: aObj.target, issuer: aObj.issuer }), // info event\n ...(aObj.event === 'info' && aObj.isStoredPaymentMethod && { isStoredPaymentMethod: aObj.isStoredPaymentMethod, brand: aObj.brand }), // only added if we have an info event about a storedPM\n ...(aObj.event === 'info' &&\n aObj.type === ANALYTICS_VALIDATION_ERROR_STR && {\n validationErrorCode: aObj.validationErrorCode,\n validationErrorMessage: aObj.validationErrorMessage\n }), // only added if we have an info event describing a validation error\n /** All */\n ...(aObj.metadata && { metadata: aObj.metadata })\n});\n"],"names":["getUTCTimestamp","Date","now","createAnalyticsObject","aObj","timestamp","String","component","id","uuid","event","code","errorType","message","type","ANALYTICS_ACTION_STR","subType","subtype","target","issuer","isStoredPaymentMethod","brand","ANALYTICS_VALIDATION_ERROR_STR","validationErrorCode","validationErrorMessage","metadata"],"mappings":"6HAIaA,MAAAA,EAAkB,IAAMC,KAAKC,MAoB7BC,EAAyBC,IAAkD,CACpFC,UAAWC,OAAON,KAClBO,UAAWH,EAAKG,UAChBC,GAAIC,OAEe,UAAfL,EAAKM,OAAqB,CAAEC,KAAMP,EAAKO,KAAMC,UAAWR,EAAKQ,UAAWC,QAAST,EAAKS,YAEvE,QAAfT,EAAKM,OAAmB,CAAEI,KAAMV,EAAKU,KAAMD,QAAST,EAAKS,YAC1C,QAAfT,EAAKM,OAAmBN,EAAKU,OAASC,GAAwB,CAAEC,QAASZ,EAAKa,YAE/D,SAAfb,EAAKM,OAAoB,CAAEI,KAAMV,EAAKU,KAAMI,OAAQd,EAAKc,OAAQC,OAAQf,EAAKe,WAC/D,SAAff,EAAKM,OAAoBN,EAAKgB,uBAAyB,CAAEA,sBAAuBhB,EAAKgB,sBAAuBC,MAAOjB,EAAKiB,UACzG,SAAfjB,EAAKM,OACLN,EAAKU,OAASQ,GAAkC,CAC5CC,oBAAqBnB,EAAKmB,oBAC1BC,uBAAwBpB,EAAKoB,2BAGjCpB,EAAKqB,UAAY,CAAEA,SAAUrB,EAAKqB"}
@@ -1,2 +1,2 @@
1
- const R="NETWORK_ERROR",E="CANCEL",s="IMPLEMENTATION_ERROR",e="API_ERROR",r="ERROR";class O extends Error{static errorTypes={NETWORK_ERROR:R,CANCEL:E,IMPLEMENTATION_ERROR:s,API_ERROR:e,ERROR:r};cause;constructor(R,E,s){super(E),this.name=O.errorTypes[R],this.cause=s?.cause}}export{e as API_ERROR,E as CANCEL,r as ERROR,s as IMPLEMENTATION_ERROR,R as NETWORK_ERROR,O as default};
1
+ const R="NETWORK_ERROR",E="CANCEL",s="IMPLEMENTATION_ERROR",O="API_ERROR",e="ERROR",r="SCRIPT_ERROR";class t extends Error{static errorTypes={NETWORK_ERROR:R,CANCEL:E,IMPLEMENTATION_ERROR:s,API_ERROR:O,ERROR:e,SCRIPT_ERROR:r};cause;constructor(R,E,s){super(E),this.name=t.errorTypes[R],this.cause=s?.cause}}export{O as API_ERROR,E as CANCEL,e as ERROR,s as IMPLEMENTATION_ERROR,R as NETWORK_ERROR,r as SCRIPT_ERROR,t as default};
2
2
  //# sourceMappingURL=AdyenCheckoutError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AdyenCheckoutError.js","sources":["../../../../src/core/Errors/AdyenCheckoutError.ts"],"sourcesContent":["interface CheckoutErrorOptions {\n cause?: any;\n}\n\nexport const NETWORK_ERROR = 'NETWORK_ERROR';\nexport const CANCEL = 'CANCEL';\nexport const IMPLEMENTATION_ERROR = 'IMPLEMENTATION_ERROR';\nexport const API_ERROR = 'API_ERROR';\nexport const ERROR = 'ERROR';\n\nclass AdyenCheckoutError extends Error {\n protected static errorTypes = {\n /** Network error. */\n NETWORK_ERROR,\n\n /** Shopper canceled the current transaction. */\n CANCEL,\n\n /** Implementation error. The method or parameter are incorrect or are not supported. */\n IMPLEMENTATION_ERROR,\n\n /** API error. The API has not returned the expected data */\n API_ERROR,\n\n /** Generic error. */\n ERROR\n };\n\n public cause: unknown;\n\n constructor(type: keyof typeof AdyenCheckoutError.errorTypes, message?: string, options?: CheckoutErrorOptions) {\n super(message);\n\n this.name = AdyenCheckoutError.errorTypes[type];\n\n this.cause = options?.cause;\n }\n}\n\nexport default AdyenCheckoutError;\n"],"names":["NETWORK_ERROR","CANCEL","IMPLEMENTATION_ERROR","API_ERROR","ERROR","AdyenCheckoutError","Error","static","cause","constructor","type","message","options","super","this","name","errorTypes"],"mappings":"AAIO,MAAMA,EAAgB,gBAChBC,EAAS,SACTC,EAAuB,uBACvBC,EAAY,YACZC,EAAQ,QAErB,MAAMC,UAA2BC,MAC7BC,kBAA8B,CAE1BP,gBAGAC,SAGAC,uBAGAC,YAGAC,SAGGI,MAEPC,WAAAA,CAAYC,EAAkDC,EAAkBC,GAC5EC,MAAMF,GAENG,KAAKC,KAAOV,EAAmBW,WAAWN,GAE1CI,KAAKN,MAAQI,GAASJ,KAC1B"}
1
+ {"version":3,"file":"AdyenCheckoutError.js","sources":["../../../../src/core/Errors/AdyenCheckoutError.ts"],"sourcesContent":["interface CheckoutErrorOptions {\n cause?: any;\n}\n\nexport const NETWORK_ERROR = 'NETWORK_ERROR';\nexport const CANCEL = 'CANCEL';\nexport const IMPLEMENTATION_ERROR = 'IMPLEMENTATION_ERROR';\nexport const API_ERROR = 'API_ERROR';\nexport const ERROR = 'ERROR';\nexport const SCRIPT_ERROR = 'SCRIPT_ERROR';\n\nclass AdyenCheckoutError extends Error {\n protected static errorTypes = {\n /** Network error. */\n NETWORK_ERROR,\n\n /** Shopper canceled the current transaction. */\n CANCEL,\n\n /** Implementation error. The method or parameter are incorrect or are not supported. */\n IMPLEMENTATION_ERROR,\n\n /** API error. The API has not returned the expected data */\n API_ERROR,\n\n /** Generic error. */\n ERROR,\n\n /** Script error. The browser failed to load 3rd party script */\n SCRIPT_ERROR\n };\n\n public cause: unknown;\n\n constructor(type: keyof typeof AdyenCheckoutError.errorTypes, message?: string, options?: CheckoutErrorOptions) {\n super(message);\n\n this.name = AdyenCheckoutError.errorTypes[type];\n\n this.cause = options?.cause;\n }\n}\n\nexport default AdyenCheckoutError;\n"],"names":["NETWORK_ERROR","CANCEL","IMPLEMENTATION_ERROR","API_ERROR","ERROR","SCRIPT_ERROR","AdyenCheckoutError","Error","static","cause","constructor","type","message","options","super","this","name","errorTypes"],"mappings":"AAIO,MAAMA,EAAgB,gBAChBC,EAAS,SACTC,EAAuB,uBACvBC,EAAY,YACZC,EAAQ,QACRC,EAAe,eAE5B,MAAMC,UAA2BC,MAC7BC,kBAA8B,CAE1BR,gBAGAC,SAGAC,uBAGAC,YAGAC,QAGAC,gBAGGI,MAEPC,WAAAA,CAAYC,EAAkDC,EAAkBC,GAC5EC,MAAMF,GAENG,KAAKC,KAAOV,EAAmBW,WAAWN,GAE1CI,KAAKN,MAAQI,GAASJ,KAC1B"}
@@ -1,2 +1,2 @@
1
- import{ERROR_CODES as e,ERROR_ACTION_FOCUS_FIELD as r,ERROR_ACTION_BLUR_SCENARIO as s}from"./constants.js";import{ValidationRuleResult as t}from"../../utils/Validator/ValidationRuleResult.js";import{ENCRYPTED_BANK_LOCATION_FIELD as n,ENCRYPTED_BANK_ACCNT_NUMBER_FIELD as o,ENCRYPTED_PWD_FIELD as a,ENCRYPTED_SECURITY_CODE as c,ENCRYPTED_EXPIRY_YEAR as i,ENCRYPTED_EXPIRY_MONTH as l,ENCRYPTED_EXPIRY_DATE as u,ENCRYPTED_CARD_NUMBER as f}from"../../components/internal/SecuredFields/lib/configuration/constants.js";const d=r=>{let s=e[r];return s||(s=Object.keys(e).find((s=>e[s]===r)),s||r)},p=(r,s)=>Object.keys(e).reduce(((t,n)=>{const o=e[n];return(o.includes(s)||o.indexOf("gen.01")>-1)&&(t[o]=r.get(o)),t}),{}),g=(e,r,s)=>{const t={...e},n=y(s);return t.error=p(r,n),t},y=e=>{let r;switch(e){case f:r="sf-cc-num";break;case u:r="sf-cc-dat";break;case l:r="sf-cc-mth";break;case i:r="sf-cc-yr";break;case c:r="sf-cc-cvc";break;case a:r="sf-kcp-pwd";break;case o:r="sf-ach-num";break;case n:r="sf-ach-loc"}return r},b=({errors:e,i18n:r,layout:s,countrySpecificLabels:n,fieldTypeMappingFn:o})=>{const a="-sr";return Object.entries(e).reduce(((c,[i,l])=>{if(l){const l=e[i];let u,f;u=l instanceof t?"object"==typeof l.errorMessage?l.errorMessage.translationKey:l.errorMessage:l.error,f=l instanceof t||!("errorI18n"in l)?"object"==typeof l.errorMessage?`${r.get(l.errorMessage.translationKey)} ${l.errorMessage.translationObject.values.format}${a}`:r.get(l.errorMessage)+a:l.errorI18n+a;let d=f;if(o){const e=o(i,r,n);e&&(d=`${e}: ${f}`)}c.push({field:i,errorMessage:d,errorCode:u}),s&&c.sort(((e,r)=>s.indexOf(e.field)-s.indexOf(r.field)))}return c}),[])},M=({i18n:e,fieldTypeMappingFn:t,SRPanelRef:n},{errors:o,isValidating:a,layout:c,countrySpecificLabels:i})=>{const l=b({errors:o,i18n:e,fieldTypeMappingFn:t,countrySpecificLabels:i,layout:c});if(l.length){if(a){const e=l.map((e=>e.errorMessage));n.setMessages(e);const s=l.map((e=>e.field));return{currentErrorsSortedByLayout:l,action:r,fieldToFocus:s[0]}}return n?.setMessages(null),{currentErrorsSortedByLayout:l,action:s}}return n?.setMessages(null),{currentErrorsSortedByLayout:l,action:"none"}},m=(e,r)=>{if(!e)return null;return Object.entries(e).reduce(((e,[s,t])=>{if(t){e[`${r}${s}`]=t}return e}),{})};export{p as addAriaErrorTranslationsObject,g as addErrorTranslationsToObject,m as enhanceErrorObjectKeys,d as getError,M as setSRMessagesFromErrors,b as sortErrorsByLayout};
1
+ import{ERROR_CODES as e,ERROR_ACTION_FOCUS_FIELD as r,ERROR_ACTION_BLUR_SCENARIO as s}from"./constants.js";import{ValidationRuleResult as t}from"../../utils/Validator/ValidationRuleResult.js";import{ENCRYPTED_BANK_LOCATION_FIELD as n,ENCRYPTED_BANK_ACCNT_NUMBER_FIELD as o,ENCRYPTED_PWD_FIELD as a,ENCRYPTED_SECURITY_CODE as c,ENCRYPTED_EXPIRY_YEAR as i,ENCRYPTED_EXPIRY_MONTH as l,ENCRYPTED_EXPIRY_DATE as u,ENCRYPTED_CARD_NUMBER as f}from"../../components/internal/SecuredFields/lib/configuration/constants.js";const d=r=>{let s=e[r];return s||(s=Object.keys(e).find((s=>e[s]===r)),s||r)},p=(r,s)=>Object.keys(e).reduce(((t,n)=>{const o=e[n];return(o.includes(s)||o.indexOf("gen.01")>-1)&&(t[o]=r.get(o)),t}),{}),g=(e,r,s)=>{const t={...e},n=y(s);return t.error=p(r,n),t},y=e=>{let r;switch(e){case f:r="sf-cc-num";break;case u:r="sf-cc-dat";break;case l:r="sf-cc-mth";break;case i:r="sf-cc-yr";break;case c:r="sf-cc-cvc";break;case a:r="sf-kcp-pwd";break;case o:r="sf-ach-num";break;case n:r="sf-ach-loc"}return r},b=({errors:e,i18n:r,layout:s,countrySpecificLabels:n,fieldTypeMappingFn:o})=>{const a="-sr";return Object.entries(e).reduce(((c,[i,l])=>{if(l){const l=e[i];let u,f;if(u=l instanceof t?"object"==typeof l.errorMessage?l.errorMessage.translationKey:l.errorMessage:l.error,l instanceof t||!("errorI18n"in l))if("object"==typeof l.errorMessage)f=`${r.get(l.errorMessage.translationKey)} ${l.errorMessage.translationObject.values.format}${a}`;else{const e=o?o(i,r,n):"";f=r.get(l.errorMessage,{values:{label:e}})+a}else f=l.errorI18n+a;c.push({field:i,errorMessage:f,errorCode:u}),s&&c.sort(((e,r)=>s.indexOf(e.field)-s.indexOf(r.field)))}return c}),[])},M=({i18n:e,fieldTypeMappingFn:t,SRPanelRef:n},{errors:o,isValidating:a,layout:c,countrySpecificLabels:i})=>{const l=b({errors:o,i18n:e,fieldTypeMappingFn:t,countrySpecificLabels:i,layout:c});if(l.length){if(a){const e=l.map((e=>e.errorMessage));n.setMessages(e);const s=l.map((e=>e.field));return{currentErrorsSortedByLayout:l,action:r,fieldToFocus:s[0]}}return n?.setMessages(null),{currentErrorsSortedByLayout:l,action:s}}return n?.setMessages(null),{currentErrorsSortedByLayout:l,action:"none"}},m=(e,r)=>{if(!e)return null;return Object.entries(e).reduce(((e,[s,t])=>{if(t){e[`${r}${s}`]=t}return e}),{})};export{p as addAriaErrorTranslationsObject,g as addErrorTranslationsToObject,m as enhanceErrorObjectKeys,d as getError,M as setSRMessagesFromErrors,b as sortErrorsByLayout};
2
2
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../src/core/Errors/utils.ts"],"sourcesContent":["import { ERROR_ACTION_BLUR_SCENARIO, ERROR_ACTION_FOCUS_FIELD, ERROR_CODES } from './constants';\nimport { SFError } from '../../components/Card/components/CardInput/types';\nimport { SortErrorsObj, SortedErrorObject, GenericError, SetSRMessagesReturnObject } from './types';\nimport { ValidationRuleResult } from '../../utils/Validator/ValidationRuleResult';\nimport {\n ENCRYPTED_BANK_ACCNT_NUMBER_FIELD,\n ENCRYPTED_BANK_LOCATION_FIELD,\n ENCRYPTED_CARD_NUMBER,\n ENCRYPTED_EXPIRY_DATE,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR,\n ENCRYPTED_PWD_FIELD,\n ENCRYPTED_SECURITY_CODE\n} from '../../components/internal/SecuredFields/lib/configuration/constants';\n\n/**\n * Access items stored in the ERROR_CODES object by either sending in the key - in which case you get the value\n * or by sending in the value - in which case you get the key\n * @param keyOrValue - key (or value) by which to retrieve the corresponding value (or key)\n */\nexport const getError = (keyOrValue: string): string => {\n // Retrieve value\n let rtnVal = ERROR_CODES[keyOrValue];\n if (rtnVal) return rtnVal;\n\n // Retrieve key\n rtnVal = Object.keys(ERROR_CODES).find(key => ERROR_CODES[key] === keyOrValue);\n if (rtnVal) return rtnVal;\n\n // Neither exist\n return keyOrValue;\n};\n\nexport const addAriaErrorTranslationsObject = (i18n, errorCodeIdentifier) => {\n const errorKeys = Object.keys(ERROR_CODES);\n\n const transObj = errorKeys.reduce((acc, item) => {\n const value = ERROR_CODES[item];\n // Limit to errors related to specific sf (or general errors) TODO check if general errors are still used\n if (value.includes(errorCodeIdentifier) || value.indexOf('gen.01') > -1) {\n acc[value] = i18n.get(value);\n }\n return acc;\n }, {});\n\n return transObj;\n};\n\n/**\n * Adds a new error property to an object.\n * This error property is an object containing the translated errors, stored by code, that relate to the securedFields\n * @param originalObject - object we want to duplicate and enhance\n * @param i18n - an i18n object to use to get translations\n * @returns a duplicate of the original object with a new property: \"error\" whose value is a object containing the translated errors\n */\nexport const addErrorTranslationsToObject = (originalObj, i18n, fieldType) => {\n const nuObj = { ...originalObj };\n\n const errorCodeIdentifier = fieldTypeToErrorCodeIdentifier(fieldType);\n nuObj.error = addAriaErrorTranslationsObject(i18n, errorCodeIdentifier);\n\n return nuObj;\n};\n\nconst fieldTypeToErrorCodeIdentifier = fieldType => {\n let errorCodeIdentifier;\n switch (fieldType) {\n case ENCRYPTED_CARD_NUMBER:\n errorCodeIdentifier = 'sf-cc-num';\n break;\n case ENCRYPTED_EXPIRY_DATE:\n errorCodeIdentifier = 'sf-cc-dat';\n break;\n case ENCRYPTED_EXPIRY_MONTH:\n errorCodeIdentifier = 'sf-cc-mth';\n break;\n case ENCRYPTED_EXPIRY_YEAR:\n errorCodeIdentifier = 'sf-cc-yr';\n break;\n case ENCRYPTED_SECURITY_CODE:\n errorCodeIdentifier = 'sf-cc-cvc';\n break;\n case ENCRYPTED_PWD_FIELD:\n errorCodeIdentifier = 'sf-kcp-pwd';\n break;\n case ENCRYPTED_BANK_ACCNT_NUMBER_FIELD:\n errorCodeIdentifier = 'sf-ach-num';\n break;\n case ENCRYPTED_BANK_LOCATION_FIELD:\n errorCodeIdentifier = 'sf-ach-loc';\n break;\n default:\n }\n return errorCodeIdentifier;\n};\n\n/**\n * sortErrorsByLayout - takes a list of errors and a layout, and returns a sorted array of error objects with translated error messages\n *\n * @param errors - an object containing errors, referenced by field type\n * @param layout - a string[] controlling how the output error objects will be ordered. Required when it is known that the way the error object is populated can vary e.g. Card comp, &/or anything with a country selector\n * @param i18n - our internal Language mechanism\n * @param countrySpecificLabels - some errors are region specific, e.g. in the US \"postal code\" = \"zip code\", so map the fieldType value accordingly (if it is being added to the errorMessage string)\n * @param fieldTypeMappingFn - a component specific lookup function that will tell us both if we need to prepend the field type to the SR panel message, and, if so, will retrieve the correct translation for the field type\n */\nexport const sortErrorsByLayout = ({ errors, i18n, layout, countrySpecificLabels, fieldTypeMappingFn }: SortErrorsObj): SortedErrorObject[] => {\n const SR_INDICATOR_PREFIX = process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'test' ? '' : '-sr'; // Useful for testing whether SR is reading out aria-live errors (sr) or aria-describedby ones\n\n // Create array of error objects, sorted by layout\n const sortedErrors: SortedErrorObject[] = Object.entries(errors).reduce((acc, [key, value]) => {\n if (value) {\n const errObj: ValidationRuleResult | SFError | GenericError = errors[key];\n // console.log('### utils::sortErrorsByLayout:: key', key, 'errObj', errObj);\n\n /**\n * Get error codes - these are used if we need to distinguish between showValidation & onBlur errors\n * - For a ValidationRuleResult or GenericError the error \"code\" is contained in the errorMessage prop.\n * - For an SFError the error \"code\" is contained in the error prop.\n */\n let errorCode: string;\n if (!(errObj instanceof ValidationRuleResult)) {\n errorCode = errObj.error; // is SFError\n } else {\n /** Special handling for Address~postalCode which can have be passed an object in the 'errorMessage' prop containing a country specific error */\n if (typeof errObj.errorMessage === 'object') {\n errorCode = errObj.errorMessage.translationKey; // is ValidationRuleResult w. country specific error\n } else {\n errorCode = errObj.errorMessage; // is ValidationRuleResult || GenericError || an as yet incorrectly formed error\n }\n }\n\n /**\n * Get corresponding error msg - a translated string we can place into the SRPanel\n * NOTE: the error object for a secured field already contains the error in a translated form (errorI18n).\n * For other fields we still need to translate it, so we use the errorMessage prop as a translation key\n */\n let errorMsg: string;\n if (!(errObj instanceof ValidationRuleResult) && 'errorI18n' in errObj) {\n errorMsg = errObj.errorI18n + SR_INDICATOR_PREFIX; // is SFError\n } else {\n /** Special handling for Address~postalCode (see above) */\n if (typeof errObj.errorMessage === 'object') {\n /* prettier-ignore */\n errorMsg = `${i18n.get(errObj.errorMessage.translationKey)} ${errObj.errorMessage.translationObject.values.format}${SR_INDICATOR_PREFIX}`; // is ValidationRuleResult w. country specific error\n } else {\n errorMsg = i18n.get(errObj.errorMessage) + SR_INDICATOR_PREFIX; // is ValidationRuleResult || GenericError || an as yet incorrectly formed error\n }\n }\n\n let errorMessage = errorMsg;\n /**\n * For some fields we might need to append the field type to the start of the error message (varies on a component by component basis)\n * - necessary for a11y, when we know the translated error msg doesn't contain a reference to the field it refers to\n * TODO - in the future this should be something we can get rid of once we align all our error texts and translations\n */\n if (fieldTypeMappingFn) {\n const fieldType: string = fieldTypeMappingFn(key, i18n, countrySpecificLabels); // Get translation for field type\n if (fieldType) errorMessage = `${fieldType}: ${errorMsg}`;\n }\n\n acc.push({ field: key, errorMessage, errorCode });\n\n if (layout) acc.sort((a, b) => layout.indexOf(a.field) - layout.indexOf(b.field));\n }\n return acc;\n }, []);\n\n return sortedErrors;\n};\n\n/**\n * Implemented as a partial, with an object containing the first 6 arguments; then the final argument, errors, is passed to the partial\n *\n * NOTE: using this generic error setting fny is only suitable when errors for the SRPanel are *only* generated by showValidation().\n * When errors are also generated onBlur, as the user leaves the input, the SR message generation becomes more complex - see CardInput as an example\n */\nexport const setSRMessagesFromErrors = (\n { i18n, fieldTypeMappingFn, SRPanelRef },\n { errors, isValidating, layout, countrySpecificLabels }\n): SetSRMessagesReturnObject => {\n const currentErrorsSortedByLayout = sortErrorsByLayout({\n errors,\n i18n,\n fieldTypeMappingFn,\n countrySpecificLabels,\n layout\n });\n\n const doLog = false;\n\n if (doLog) console.log('### setSRMessagesFromErrors::currentErrorsSortedByLayout:: ', currentErrorsSortedByLayout);\n\n if (currentErrorsSortedByLayout.length) {\n /** If validating i.e. \"on submit\" type event - then display all errors in the SR panel */\n if (isValidating) {\n const errorMsgArr: string[] = currentErrorsSortedByLayout.map(errObj => errObj.errorMessage);\n if (doLog) console.log('### setSRMessagesFromErrors:: #1 multiple errors:: (validating) errorMsgArr=', errorMsgArr);\n SRPanelRef.setMessages(errorMsgArr);\n\n const fieldListArr: string[] = currentErrorsSortedByLayout.map(errObj => errObj.field);\n return { currentErrorsSortedByLayout, action: ERROR_ACTION_FOCUS_FIELD, fieldToFocus: fieldListArr[0] };\n } else {\n // prettier-ignore\n if (doLog) console.log('### setSRMessagesFromErrors:: #3 on blur scenario:: not validating but there might be an error, either to set or to clear');\n SRPanelRef?.setMessages(null);\n\n return { currentErrorsSortedByLayout, action: ERROR_ACTION_BLUR_SCENARIO }; // on blur scenario: not validating but there might be an error, either to set or to clear\n }\n } else {\n if (doLog) console.log('### setSRMessagesFromErrors::componentDidUpdate:: #4 clearing errors:: NO currentErrorsSortedByLayout');\n SRPanelRef?.setMessages(null); // no errors - so clear SR panel\n return { currentErrorsSortedByLayout, action: 'none' };\n }\n};\n\nexport const enhanceErrorObjectKeys = (errorObj, keyPrefix) => {\n if (!errorObj) return null;\n const enhancedObj = Object.entries(errorObj).reduce((acc, [key, value]) => {\n if (value) {\n const newKey = `${keyPrefix}${key}`;\n acc[newKey] = value;\n }\n return acc;\n }, {});\n\n return enhancedObj;\n};\n"],"names":["getError","keyOrValue","rtnVal","ERROR_CODES","Object","keys","find","key","addAriaErrorTranslationsObject","i18n","errorCodeIdentifier","reduce","acc","item","value","includes","indexOf","get","addErrorTranslationsToObject","originalObj","fieldType","nuObj","fieldTypeToErrorCodeIdentifier","error","ENCRYPTED_CARD_NUMBER","ENCRYPTED_EXPIRY_DATE","ENCRYPTED_EXPIRY_MONTH","ENCRYPTED_EXPIRY_YEAR","ENCRYPTED_SECURITY_CODE","ENCRYPTED_PWD_FIELD","ENCRYPTED_BANK_ACCNT_NUMBER_FIELD","ENCRYPTED_BANK_LOCATION_FIELD","sortErrorsByLayout","errors","layout","countrySpecificLabels","fieldTypeMappingFn","SR_INDICATOR_PREFIX","entries","errObj","errorCode","errorMsg","ValidationRuleResult","errorMessage","translationKey","translationObject","values","format","errorI18n","push","field","sort","a","b","sortedErrors","setSRMessagesFromErrors","SRPanelRef","isValidating","currentErrorsSortedByLayout","length","errorMsgArr","map","setMessages","fieldListArr","action","ERROR_ACTION_FOCUS_FIELD","fieldToFocus","ERROR_ACTION_BLUR_SCENARIO","enhanceErrorObjectKeys","errorObj","keyPrefix","enhancedObj"],"mappings":"igBAoBaA,MAAAA,EAAYC,IAErB,IAAIC,EAASC,EAAYF,GACzB,OAAIC,IAGJA,EAASE,OAAOC,KAAKF,GAAaG,MAAKC,GAAOJ,EAAYI,KAASN,IAC/DC,GAGGD,EAAAA,EAGEO,EAAiC,CAACC,EAAMC,IAC/BN,OAAOC,KAAKF,GAEHQ,QAAO,CAACC,EAAKC,KACpC,MAAMC,EAAQX,EAAYU,GAK1B,OAHIC,EAAMC,SAASL,IAAwBI,EAAME,QAAQ,WAAa,KAClEJ,EAAIE,GAASL,EAAKQ,IAAIH,IAEnBF,CAAAA,GACR,CAAC,GAYKM,EAA+B,CAACC,EAAaV,EAAMW,KAC5D,MAAMC,EAAQ,IAAKF,GAEbT,EAAsBY,EAA+BF,GAG3D,OAFAC,EAAME,MAAQf,EAA+BC,EAAMC,GAE5CW,CAAAA,EAGLC,EAAiCF,IACnC,IAAIV,EACJ,OAAQU,GACJ,KAAKI,EACDd,EAAsB,YACtB,MACJ,KAAKe,EACDf,EAAsB,YACtB,MACJ,KAAKgB,EACDhB,EAAsB,YACtB,MACJ,KAAKiB,EACDjB,EAAsB,WACtB,MACJ,KAAKkB,EACDlB,EAAsB,YACtB,MACJ,KAAKmB,EACDn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ea,EAAWM,YAAYF,GAEvB,MAAMG,EAAyBL,EAA4BG,KAAItB,GAAUA,EAAOW,QAChF,MAAO,CAAEQ,8BAA6BM,OAAQC,EAA0BC,aAAcH,EAAa,IAMnG,OAFAP,GAAYM,YAAY,MAEjB,CAAEJ,8BAA6BM,OAAQG,GAKlD,OADAX,GAAYM,YAAY,MACjB,CAAEJ,8BAA6BM,OAAQ,OAClD,EAGSI,EAAyB,CAACC,EAAUC,KAC7C,IAAKD,EAAU,OAAO,KAStB,OARoBjE,OAAOkC,QAAQ+B,GAAU1D,QAAO,CAACC,GAAML,EAAKO,MAC5D,GAAIA,EAAO,CAEPF,EADe,GAAG0D,IAAY/D,KAChBO,CAClB,CACA,OAAOF,CAAAA,GACR,CAAC,EAEG2D"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../src/core/Errors/utils.ts"],"sourcesContent":["import { ERROR_ACTION_BLUR_SCENARIO, ERROR_ACTION_FOCUS_FIELD, ERROR_CODES } from './constants';\nimport { SFError } from '../../components/Card/components/CardInput/types';\nimport { SortErrorsObj, SortedErrorObject, GenericError, SetSRMessagesReturnObject } from './types';\nimport { ValidationRuleResult } from '../../utils/Validator/ValidationRuleResult';\nimport {\n ENCRYPTED_BANK_ACCNT_NUMBER_FIELD,\n ENCRYPTED_BANK_LOCATION_FIELD,\n ENCRYPTED_CARD_NUMBER,\n ENCRYPTED_EXPIRY_DATE,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR,\n ENCRYPTED_PWD_FIELD,\n ENCRYPTED_SECURITY_CODE\n} from '../../components/internal/SecuredFields/lib/configuration/constants';\n\n/**\n * Access items stored in the ERROR_CODES object by either sending in the key - in which case you get the value\n * or by sending in the value - in which case you get the key\n * @param keyOrValue - key (or value) by which to retrieve the corresponding value (or key)\n */\nexport const getError = (keyOrValue: string): string => {\n // Retrieve value\n let rtnVal = ERROR_CODES[keyOrValue];\n if (rtnVal) return rtnVal;\n\n // Retrieve key\n rtnVal = Object.keys(ERROR_CODES).find(key => ERROR_CODES[key] === keyOrValue);\n if (rtnVal) return rtnVal;\n\n // Neither exist\n return keyOrValue;\n};\n\nexport const addAriaErrorTranslationsObject = (i18n, errorCodeIdentifier) => {\n const errorKeys = Object.keys(ERROR_CODES);\n\n const transObj = errorKeys.reduce((acc, item) => {\n const value = ERROR_CODES[item];\n // Limit to errors related to specific sf (or general errors) TODO check if general errors are still used\n if (value.includes(errorCodeIdentifier) || value.indexOf('gen.01') > -1) {\n acc[value] = i18n.get(value);\n }\n return acc;\n }, {});\n\n return transObj;\n};\n\n/**\n * Adds a new error property to an object.\n * This error property is an object containing the translated errors, stored by code, that relate to the securedFields\n * @param originalObject - object we want to duplicate and enhance\n * @param i18n - an i18n object to use to get translations\n * @returns a duplicate of the original object with a new property: \"error\" whose value is a object containing the translated errors\n */\nexport const addErrorTranslationsToObject = (originalObj, i18n, fieldType) => {\n const nuObj = { ...originalObj };\n\n const errorCodeIdentifier = fieldTypeToErrorCodeIdentifier(fieldType);\n nuObj.error = addAriaErrorTranslationsObject(i18n, errorCodeIdentifier);\n\n return nuObj;\n};\n\nconst fieldTypeToErrorCodeIdentifier = fieldType => {\n let errorCodeIdentifier;\n switch (fieldType) {\n case ENCRYPTED_CARD_NUMBER:\n errorCodeIdentifier = 'sf-cc-num';\n break;\n case ENCRYPTED_EXPIRY_DATE:\n errorCodeIdentifier = 'sf-cc-dat';\n break;\n case ENCRYPTED_EXPIRY_MONTH:\n errorCodeIdentifier = 'sf-cc-mth';\n break;\n case ENCRYPTED_EXPIRY_YEAR:\n errorCodeIdentifier = 'sf-cc-yr';\n break;\n case ENCRYPTED_SECURITY_CODE:\n errorCodeIdentifier = 'sf-cc-cvc';\n break;\n case ENCRYPTED_PWD_FIELD:\n errorCodeIdentifier = 'sf-kcp-pwd';\n break;\n case ENCRYPTED_BANK_ACCNT_NUMBER_FIELD:\n errorCodeIdentifier = 'sf-ach-num';\n break;\n case ENCRYPTED_BANK_LOCATION_FIELD:\n errorCodeIdentifier = 'sf-ach-loc';\n break;\n default:\n }\n return errorCodeIdentifier;\n};\n\n/**\n * sortErrorsByLayout - takes a list of errors and a layout, and returns a sorted array of error objects with translated error messages\n *\n * @param errors - an object containing errors, referenced by field type\n * @param layout - a string[] controlling how the output error objects will be ordered. Required when it is known that the way the error object is populated can vary e.g. Card comp, &/or anything with a country selector\n * @param i18n - our internal Language mechanism\n * @param countrySpecificLabels - some errors are region specific, e.g. in the US \"postal code\" = \"zip code\", so map the fieldType value accordingly (if it is being added to the errorMessage string)\n * @param fieldTypeMappingFn - a component specific lookup function that will tell us both if we need to prepend the field type to the SR panel message, and, if so, will retrieve the correct translation for the field type\n */\nexport const sortErrorsByLayout = ({ errors, i18n, layout, countrySpecificLabels, fieldTypeMappingFn }: SortErrorsObj): SortedErrorObject[] => {\n const SR_INDICATOR_PREFIX = process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'test' ? '' : '-sr'; // Useful for testing whether SR is reading out aria-live errors (sr) or aria-describedby ones\n\n // Create array of error objects, sorted by layout\n const sortedErrors: SortedErrorObject[] = Object.entries(errors).reduce((acc, [key, value]) => {\n if (value) {\n const errObj: ValidationRuleResult | SFError | GenericError = errors[key];\n\n /**\n * Get error codes - these are used if we need to distinguish between showValidation & onBlur errors\n * - For a ValidationRuleResult or GenericError the error \"code\" is contained in the errorMessage prop.\n * - For an SFError the error \"code\" is contained in the error prop.\n */\n let errorCode: string;\n if (!(errObj instanceof ValidationRuleResult)) {\n errorCode = errObj.error; // is SFError\n } else {\n /** Special handling for Address~postalCode which can have be passed an object in the 'errorMessage' prop */\n if (typeof errObj.errorMessage === 'object') {\n errorCode = errObj.errorMessage.translationKey; // is ValidationRuleResult w. country specific error\n } else {\n errorCode = errObj.errorMessage; // is ValidationRuleResult || GenericError || an as yet incorrectly formed error\n }\n }\n\n /**\n * Get corresponding error msg - a translated string we can place into the SRPanel\n * NOTE: the error object for a secured field already contains the error in a translated form (errorI18n).\n * For other fields we still need to translate it, so we use the errorMessage prop as a translation key\n */\n let errorMsg: string;\n if (!(errObj instanceof ValidationRuleResult) && 'errorI18n' in errObj) {\n errorMsg = errObj.errorI18n + SR_INDICATOR_PREFIX; // is SFError\n } else {\n /** Special handling for Address~postalCode where the errorMessage comes as an object containing the details of the country specific format that should have been used for the postcode */\n if (typeof errObj.errorMessage === 'object') {\n /* prettier-ignore */\n errorMsg = `${i18n.get(errObj.errorMessage.translationKey)} ${errObj.errorMessage.translationObject.values.format}${SR_INDICATOR_PREFIX}`; // is ValidationRuleResult w. country specific error\n } else {\n const mappedLabel = fieldTypeMappingFn ? fieldTypeMappingFn(key, i18n, countrySpecificLabels) : '';\n errorMsg = i18n.get(errObj.errorMessage, { values: { label: mappedLabel } }) + SR_INDICATOR_PREFIX; // is ValidationRuleResult || GenericError || an as yet incorrectly formed error\n }\n }\n\n acc.push({ field: key, errorMessage: errorMsg, errorCode });\n\n if (layout) acc.sort((a, b) => layout.indexOf(a.field) - layout.indexOf(b.field));\n }\n return acc;\n }, []);\n\n return sortedErrors;\n};\n\n/**\n * Implemented as a partial, with an object containing the first 6 arguments; then the final argument, errors, is passed to the partial\n *\n * NOTE: using this generic error setting fny is only suitable when errors for the SRPanel are *only* generated by showValidation().\n * When errors are also generated onBlur, as the user leaves the input, the SR message generation becomes more complex - see CardInput as an example\n */\nexport const setSRMessagesFromErrors = (\n { i18n, fieldTypeMappingFn, SRPanelRef },\n { errors, isValidating, layout, countrySpecificLabels }\n): SetSRMessagesReturnObject => {\n const currentErrorsSortedByLayout = sortErrorsByLayout({\n errors,\n i18n,\n fieldTypeMappingFn,\n countrySpecificLabels,\n layout\n });\n\n const doLog = false;\n\n if (doLog) console.log('### setSRMessagesFromErrors::currentErrorsSortedByLayout:: ', currentErrorsSortedByLayout);\n\n if (currentErrorsSortedByLayout.length) {\n /** If validating i.e. \"on submit\" type event - then display all errors in the SR panel */\n if (isValidating) {\n const errorMsgArr: string[] = currentErrorsSortedByLayout.map(errObj => errObj.errorMessage);\n if (doLog) console.log('### setSRMessagesFromErrors:: #1 multiple errors:: (validating) errorMsgArr=', errorMsgArr);\n SRPanelRef.setMessages(errorMsgArr);\n\n const fieldListArr: string[] = currentErrorsSortedByLayout.map(errObj => errObj.field);\n return { currentErrorsSortedByLayout, action: ERROR_ACTION_FOCUS_FIELD, fieldToFocus: fieldListArr[0] };\n } else {\n // prettier-ignore\n if (doLog) console.log('### setSRMessagesFromErrors:: #3 on blur scenario:: not validating but there might be an error, either to set or to clear');\n SRPanelRef?.setMessages(null);\n\n return { currentErrorsSortedByLayout, action: ERROR_ACTION_BLUR_SCENARIO }; // on blur scenario: not validating but there might be an error, either to set or to clear\n }\n } else {\n if (doLog) console.log('### setSRMessagesFromErrors::componentDidUpdate:: #4 clearing errors:: NO currentErrorsSortedByLayout');\n SRPanelRef?.setMessages(null); // no errors - so clear SR panel\n return { currentErrorsSortedByLayout, action: 'none' };\n }\n};\n\nexport const enhanceErrorObjectKeys = (errorObj, keyPrefix) => {\n if (!errorObj) return null;\n const enhancedObj = Object.entries(errorObj).reduce((acc, [key, value]) => {\n if (value) {\n const newKey = `${keyPrefix}${key}`;\n acc[newKey] = value;\n }\n return acc;\n }, {});\n\n return enhancedObj;\n};\n"],"names":["getError","keyOrValue","rtnVal","ERROR_CODES","Object","keys","find","key","addAriaErrorTranslationsObject","i18n","errorCodeIdentifier","reduce","acc","item","value","includes","indexOf","get","addErrorTranslationsToObject","originalObj","fieldType","nuObj","fieldTypeToErrorCodeIdentifier","error","ENCRYPTED_CARD_NUMBER","ENCRYPTED_EXPIRY_DATE","ENCRYPTED_EXPIRY_MONTH","ENCRYPTED_EXPIRY_YEAR","ENCRYPTED_SECURITY_CODE","ENCRYPTED_PWD_FIELD","ENCRYPTED_BANK_ACCNT_NUMBER_FIELD","ENCRYPTED_BANK_LOCATION_FIELD","sortErrorsByLayout","errors","layout","countrySpecificLabels","fieldTypeMappingFn","SR_INDICATOR_PREFIX","entries","errObj","errorCode","errorMsg","ValidationRuleResult","errorMessage","translationKey","translationObject","values","format","mappedLabel","label","errorI18n","push","field","sort","a","b","sortedErrors","setSRMessagesFromErrors","SRPanelRef","isValidating","currentErrorsSortedByLayout","length","errorMsgArr","map","setMessages","fieldListArr","action","ERROR_ACTION_FOCUS_FIELD","fieldToFocus","ERROR_ACTION_BLUR_SCENARIO","enhanceErrorObjectKeys","errorObj","keyPrefix","enhancedObj"],"mappings":"igBAoBaA,MAAAA,EAAYC,IAErB,IAAIC,EAASC,EAAYF,GACzB,OAAIC,IAGJA,EAASE,OAAOC,KAAKF,GAAaG,MAAKC,GAAOJ,EAAYI,KAASN,IAC/DC,GAGGD,EAAAA,EAGEO,EAAiC,CAACC,EAAMC,IAC/BN,OAAOC,KAAKF,GAEHQ,QAAO,CAACC,EAAKC,KACpC,MAAMC,EAAQX,EAAYU,GAK1B,OAHIC,EAAMC,SAASL,IAAwBI,EAAME,QAAQ,WAAa,KAClEJ,EAAIE,GAASL,EAAKQ,IAAIH,IAEnBF,CAAAA,GACR,CAAC,GAYKM,EAA+B,CAACC,EAAaV,EAAMW,KAC5D,MAAMC,EAAQ,IAAKF,GAEbT,EAAsBY,EAA+BF,GAG3D,OAFAC,EAAME,MAAQf,EAA+BC,EAAMC,GAE5CW,CAAAA,EAGLC,EAAiCF,IACnC,IAAIV,EACJ,OAAQU,GACJ,KAAKI,EACDd,EAAsB,YACtB,MACJ,KAAKe,EACDf,EAAsB,YACtB,MACJ,KAAKgB,EACDhB,EAAsB,YACtB,MACJ,KAAKiB,EACDjB,EAAsB,WACtB,MACJ,KAAKkB,EACDlB,EAAsB,YACtB,MACJ,KAAKmB,EACDnB,EAAsB,aACtB,MACJ,KAAKoB,EACDpB,EAAsB,aACtB,MACJ,KAAKqB,EACDrB,EAAsB,aAI9B,OAAOA,CAAAA,EAYEsB,EAAqB,EAAGC,SAAQxB,OAAMyB,SAAQC,wBAAuBC,yBAC9E,MAAMC,EAAsG,MAkD5G,OA/C0CjC,OAAOkC,QAAQL,GAAQtB,QAAO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B,CAAEJ,8BAA6BM,OAAQ,OAClD,EAGSI,EAAyB,CAACC,EAAUC,KAC7C,IAAKD,EAAU,OAAO,KAStB,OARoBnE,OAAOkC,QAAQiC,GAAU5D,QAAO,CAACC,GAAML,EAAKO,MAC5D,GAAIA,EAAO,CAEPF,EADe,GAAG4D,IAAYjE,KAChBO,CAClB,CACA,OAAOF,CAAAA,GACR,CAAC,EAEG6D"}
@@ -1,2 +1,2 @@
1
- import{httpPost as e}from"../http.js";import t from"../../../utils/Storage.js";const o='WARNING: Failed to retrieve "checkoutAttemptId". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';const n=({analyticsContext:n,clientKey:r,locale:i,analyticsPath:c})=>{let a;const l={errorLevel:"fatal",loadingContext:n,path:`${c}?clientKey=${r}`};return n=>{const c={version:"6.0.0-alpha.0",channel:"Web",platform:"Web",buildType:window.AdyenWeb?"umd":"compiled",locale:i,referrer:window.location.href,screenWidth:window.screen.width,...n};if(a)return a;if(!r)return Promise.reject("no-client-key");const s=new t("checkout-attempt-id","sessionStorage"),d=s.get();return function(e){if(!e?.id)return!1;const t=Date.now()-9e5;return e.timestamp>t}(d)?Promise.resolve(d.id):(a=e(l,c).then((e=>{if(e?.checkoutAttemptId)return s.set({id:e.checkoutAttemptId,timestamp:Date.now()}),e.checkoutAttemptId})).catch((()=>(console.debug(o),o))),a)}};export{o as FAILURE_MSG,n as default};
1
+ import{httpPost as e}from"../http.js";import t from"../../../utils/Storage.js";const o='WARNING: Failed to retrieve "checkoutAttemptId". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';const n=({analyticsContext:n,clientKey:r,locale:i,analyticsPath:a,bundleType:c})=>{let l;const s={errorLevel:"fatal",loadingContext:n,path:`${a}?clientKey=${r}`};return n=>{const a={version:"6.0.0-alpha.2",channel:"Web",platform:"Web",buildType:c,locale:i,referrer:window.location.href,screenWidth:window.screen.width,...n};if(l)return l;if(!r)return Promise.reject("no-client-key");const m=new t("checkout-attempt-id","sessionStorage"),p=m.get();return function(e){if(!e?.id)return!1;const t=Date.now()-9e5;return e.timestamp>t}(p)?Promise.resolve(p.id):(l=e(s,a).then((e=>{if(e?.checkoutAttemptId)return m.set({id:e.checkoutAttemptId,timestamp:Date.now()}),e.checkoutAttemptId})).catch((()=>Promise.reject(o))),l)}};export{o as FAILURE_MSG,n as default};
2
2
  //# sourceMappingURL=collect-id.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"collect-id.js","sources":["../../../../../src/core/Services/analytics/collect-id.ts"],"sourcesContent":["import { httpPost } from '../http';\nimport Storage from '../../../utils/Storage';\nimport { CheckoutAttemptIdSession, CollectIdProps, TelemetryEvent } from './types';\n\nexport const FAILURE_MSG =\n 'WARNING: Failed to retrieve \"checkoutAttemptId\". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';\n\n/**\n * If the checkout attempt ID was stored more than fifteen minutes ago, then we should request a new ID.\n * More here: COWEB-1099\n */\nfunction confirmSessionDurationIsMaxFifteenMinutes(checkoutAttemptIdSession: CheckoutAttemptIdSession): boolean {\n if (!checkoutAttemptIdSession?.id) return false;\n\n const fifteenMinInMs = 1000 * 60 * 15;\n const fifteenMinAgoTimestamp = Date.now() - fifteenMinInMs;\n return checkoutAttemptIdSession.timestamp > fifteenMinAgoTimestamp;\n}\n\n/**\n * Send an event to Adyen with some basic telemetry info and receive a checkoutAttemptId in response\n * @param config - object containing values needed to calculate the url for the request; and also some that need to be serialized and included in the body of request\n * @returns a function returning a promise containing the response of the call (an object containing a checkoutAttemptId property)\n */\n// const collectId = ({ analyticsContext, clientKey, locale, amount }: CollectIdProps) => { // TODO - amount will be supported in the future\nconst collectId = ({ analyticsContext, clientKey, locale, analyticsPath }: CollectIdProps) => {\n let promise;\n\n const options = {\n errorLevel: 'fatal' as const, // ensure our catch block is called\n loadingContext: analyticsContext,\n path: `${analyticsPath}?clientKey=${clientKey}`\n };\n\n return (event): Promise<string> => {\n const telemetryEvent: TelemetryEvent = {\n // amount, // TODO will be supported in the future\n version: process.env.VERSION,\n // The data team want both platform & channel properties:\n channel: 'Web',\n platform: 'Web',\n buildType: window['AdyenWeb'] ? 'umd' : 'compiled',\n locale,\n referrer: window.location.href,\n screenWidth: window.screen.width,\n ...event\n };\n\n if (promise) return promise; // Prevents multiple standalone components on the same page from making multiple calls to collect a checkoutAttemptId\n if (!clientKey) return Promise.reject('no-client-key');\n\n const storage = new Storage<CheckoutAttemptIdSession>('checkout-attempt-id', 'sessionStorage');\n const checkoutAttemptIdSession = storage.get();\n\n // In some cases, e.g. where the merchant has redirected the shopper and then returned them to checkout, we still have a valid checkoutAttemptId\n // so there is no need for the re-initialised Checkout to generate another one\n if (confirmSessionDurationIsMaxFifteenMinutes(checkoutAttemptIdSession)) {\n return Promise.resolve(checkoutAttemptIdSession.id);\n }\n\n promise = httpPost(options, telemetryEvent)\n .then(conversion => {\n if (conversion?.checkoutAttemptId) {\n storage.set({ id: conversion.checkoutAttemptId, timestamp: Date.now() });\n return conversion.checkoutAttemptId;\n }\n return undefined;\n })\n .catch(() => {\n console.debug(FAILURE_MSG);\n return FAILURE_MSG;\n });\n\n return promise;\n };\n};\n\nexport default collectId;\n"],"names":["FAILURE_MSG","collectId","analyticsContext","clientKey","locale","analyticsPath","promise","options","errorLevel","loadingContext","path","event","telemetryEvent","version","channel","platform","buildType","window","referrer","location","href","screenWidth","screen","width","Promise","reject","storage","Storage","checkoutAttemptIdSession","get","id","fifteenMinAgoTimestamp","Date","now","timestamp","confirmSessionDurationIsMaxFifteenMinutes","resolve","httpPost","then","conversion","checkoutAttemptId","set","undefined","catch","console","debug"],"mappings":"+EAIO,MAAMA,EACT,uKAoBEC,MAAAA,EAAY,EAAGC,mBAAkBC,YAAWC,SAAQC,oBACtD,IAAIC,EAEJ,MAAMC,EAAU,CACZC,WAAY,QACZC,eAAgBP,EAChBQ,KAAM,GAAGL,eAA2BF,KAGxC,OAAQQ,IACJ,MAAMC,EAAiC,CAEnCC,QAAS,gBAETC,QAAS,MACTC,SAAU,MACVC,UAAWC,OAAkB,SAAG,MAAQ,WACxCb,SACAc,SAAUD,OAAOE,SAASC,KAC1BC,YAAaJ,OAAOK,OAAOC,SACxBZ,GAGP,GAAIL,EAAS,OAAOA,EACpB,IAAKH,EAAW,OAAOqB,QAAQC,OAAO,iBAEtC,MAAMC,EAAU,IAAIC,EAAkC,sBAAuB,kBACvEC,EAA2BF,EAAQG,MAIzC,OA7CR,SAAmDD,GAC/C,IAAKA,GAA0BE,GAAI,OAAO,EAE1C,MACMC,EAAyBC,KAAKC,MADb,IAEvB,OAAOL,EAAyBM,UAAYH,CAChD,CAuCYI,CAA0CP,GACnCJ,QAAQY,QAAQR,EAAyBE,KAGpDxB,EAAU+B,EAAS9B,EAASK,GACvB0B,MAAKC,IACF,GAAIA,GAAYC,kBAEZ,OADAd,EAAQe,IAAI,CAAEX,GAAIS,EAAWC,kBAAmBN,UAAWF,KAAKC,QACzDM,EAAWC,iBAEfE,IAEVC,OAAM,KACHC,QAAQC,MAAM7C,GACPA,KAGRM,EAAAA,CACX"}
1
+ {"version":3,"file":"collect-id.js","sources":["../../../../../src/core/Services/analytics/collect-id.ts"],"sourcesContent":["import { httpPost } from '../http';\nimport Storage from '../../../utils/Storage';\nimport { CheckoutAttemptIdSession, CollectIdProps, TelemetryEvent } from './types';\n\nexport const FAILURE_MSG =\n 'WARNING: Failed to retrieve \"checkoutAttemptId\". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';\n\n/**\n * If the checkout attempt ID was stored more than fifteen minutes ago, then we should request a new ID.\n * More here: COWEB-1099\n */\nfunction confirmSessionDurationIsMaxFifteenMinutes(checkoutAttemptIdSession: CheckoutAttemptIdSession): boolean {\n if (!checkoutAttemptIdSession?.id) return false;\n\n const fifteenMinInMs = 1000 * 60 * 15;\n const fifteenMinAgoTimestamp = Date.now() - fifteenMinInMs;\n return checkoutAttemptIdSession.timestamp > fifteenMinAgoTimestamp;\n}\n\n/**\n * Send an event to Adyen with some basic telemetry info and receive a checkoutAttemptId in response\n * @param config - object containing values needed to calculate the url for the request; and also some that need to be serialized and included in the body of request\n * @returns a function returning a promise containing the response of the call (an object containing a checkoutAttemptId property)\n */\n// const collectId = ({ analyticsContext, clientKey, locale, amount }: CollectIdProps) => { // TODO - amount will be supported in the future\nconst collectId = ({ analyticsContext, clientKey, locale, analyticsPath, bundleType }: CollectIdProps) => {\n let promise;\n\n const options = {\n errorLevel: 'fatal' as const, // ensure our catch block is called\n loadingContext: analyticsContext,\n path: `${analyticsPath}?clientKey=${clientKey}`\n };\n\n return (event): Promise<string> => {\n const telemetryEvent: TelemetryEvent = {\n // amount, // TODO will be supported in the future\n version: process.env.VERSION,\n // The data team want both platform & channel properties:\n channel: 'Web',\n platform: 'Web',\n buildType: bundleType,\n locale,\n referrer: window.location.href,\n screenWidth: window.screen.width,\n ...event\n };\n\n if (promise) return promise; // Prevents multiple standalone components on the same page from making multiple calls to collect a checkoutAttemptId\n if (!clientKey) return Promise.reject('no-client-key');\n\n const storage = new Storage<CheckoutAttemptIdSession>('checkout-attempt-id', 'sessionStorage');\n const checkoutAttemptIdSession = storage.get();\n\n // In some cases, e.g. where the merchant has redirected the shopper and then returned them to checkout, we still have a valid checkoutAttemptId\n // so there is no need for the re-initialised Checkout to generate another one\n if (confirmSessionDurationIsMaxFifteenMinutes(checkoutAttemptIdSession)) {\n return Promise.resolve(checkoutAttemptIdSession.id);\n }\n\n promise = httpPost(options, telemetryEvent)\n .then(conversion => {\n if (conversion?.checkoutAttemptId) {\n storage.set({ id: conversion.checkoutAttemptId, timestamp: Date.now() });\n return conversion.checkoutAttemptId;\n }\n return undefined;\n })\n .catch(() => {\n return Promise.reject(FAILURE_MSG);\n });\n\n return promise;\n };\n};\n\nexport default collectId;\n"],"names":["FAILURE_MSG","collectId","analyticsContext","clientKey","locale","analyticsPath","bundleType","promise","options","errorLevel","loadingContext","path","event","telemetryEvent","version","channel","platform","buildType","referrer","window","location","href","screenWidth","screen","width","Promise","reject","storage","Storage","checkoutAttemptIdSession","get","id","fifteenMinAgoTimestamp","Date","now","timestamp","confirmSessionDurationIsMaxFifteenMinutes","resolve","httpPost","then","conversion","checkoutAttemptId","set","undefined","catch"],"mappings":"+EAIO,MAAMA,EACT,uKAoBJ,MAAMC,EAAY,EAAGC,mBAAkBC,YAAWC,SAAQC,gBAAeC,iBACrE,IAAIC,EAEJ,MAAMC,EAAU,CACZC,WAAY,QACZC,eAAgBR,EAChBS,KAAM,GAAGN,eAA2BF,KAGxC,OAAQS,IACJ,MAAMC,EAAiC,CAEnCC,QAAS,gBAETC,QAAS,MACTC,SAAU,MACVC,UAAWX,EACXF,SACAc,SAAUC,OAAOC,SAASC,KAC1BC,YAAaH,OAAOI,OAAOC,SACxBZ,GAGP,GAAIL,EAAS,OAAOA,EACpB,IAAKJ,EAAW,OAAOsB,QAAQC,OAAO,iBAEtC,MAAMC,EAAU,IAAIC,EAAkC,sBAAuB,kBACvEC,EAA2BF,EAAQG,MAIzC,OA7CR,SAAmDD,GAC/C,IAAKA,GAA0BE,GAAI,OAAO,EAE1C,MACMC,EAAyBC,KAAKC,MADb,IAEvB,OAAOL,EAAyBM,UAAYH,CAChD,CAuCYI,CAA0CP,GACnCJ,QAAQY,QAAQR,EAAyBE,KAGpDxB,EAAU+B,EAAS9B,EAASK,GACvB0B,MAAKC,IACF,GAAIA,GAAYC,kBAEZ,OADAd,EAAQe,IAAI,CAAEX,GAAIS,EAAWC,kBAAmBN,UAAWF,KAAKC,QACzDM,EAAWC,iBAEfE,IAEVC,OAAM,IACInB,QAAQC,OAAO1B,KAGvBO,EAAAA,CACX"}
@@ -1,2 +1,2 @@
1
- const e=e=>o=>{const n={version:"6.0.0-alpha.0",payload_version:1,platform:"web",locale:e.locale,...o},a=Object.keys(n).map((e=>`${encodeURIComponent(e)}=${encodeURIComponent(n[e])}`)).join("&");(new Image).src=`${e.loadingContext}images/analytics.png?${a}`};export{e as default};
1
+ const e=e=>o=>{const n={version:"6.0.0-alpha.2",payload_version:1,platform:"web",locale:e.locale,...o},a=Object.keys(n).map((e=>`${encodeURIComponent(e)}=${encodeURIComponent(n[e])}`)).join("&");(new Image).src=`${e.loadingContext}images/analytics.png?${a}`};export{e as default};
2
2
  //# sourceMappingURL=log-event.js.map
@@ -1,2 +1,2 @@
1
- const e="https://checkoutshopper-live.adyen.com/checkoutshopper/",o=["amount","secondaryAmount","countryCode","environment","loadingContext","i18n","modules","order","session","clientKey","showPayButton","redirectFromTopWhenInIframe","onPaymentCompleted","onPaymentFailed","beforeRedirect","beforeSubmit","onSubmit","onActionHandled","onAdditionalDetails","onChange","onError","onBalanceCheck","onOrderRequest","onOrderUpdated","setStatusAutomatically","onPaymentMethodsRequest"],n=6e4;export{n as DEFAULT_HTTP_TIMEOUT,e as FALLBACK_CONTEXT,o as GENERIC_OPTIONS};
1
+ const e="https://checkoutshopper-live.adyen.com/checkoutshopper/",o=["amount","secondaryAmount","countryCode","environment","loadingContext","i18n","modules","order","session","clientKey","showPayButton","redirectFromTopWhenInIframe","onPaymentCompleted","onPaymentFailed","beforeRedirect","beforeSubmit","onSubmit","onActionHandled","onAdditionalDetails","onChange","onError","onBalanceCheck","onOrderRequest","onOrderUpdated","onPaymentMethodsRequest"],n=6e4;export{n as DEFAULT_HTTP_TIMEOUT,e as FALLBACK_CONTEXT,o as GENERIC_OPTIONS};
2
2
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../../src/core/config.ts"],"sourcesContent":["/**\n * FALLBACK_CONTEXT\n */\nexport const FALLBACK_CONTEXT = 'https://checkoutshopper-live.adyen.com/checkoutshopper/';\n\nexport const GENERIC_OPTIONS = [\n 'amount',\n 'secondaryAmount',\n 'countryCode',\n 'environment',\n 'loadingContext',\n 'i18n',\n 'modules',\n 'order',\n 'session',\n 'clientKey',\n 'showPayButton',\n 'redirectFromTopWhenInIframe',\n\n // Events\n 'onPaymentCompleted',\n 'onPaymentFailed',\n 'beforeRedirect',\n 'beforeSubmit',\n 'onSubmit',\n 'onActionHandled',\n 'onAdditionalDetails',\n 'onChange',\n 'onError',\n 'onBalanceCheck',\n 'onOrderRequest',\n 'onOrderUpdated',\n 'setStatusAutomatically',\n 'onPaymentMethodsRequest'\n];\n\nexport const DEFAULT_HTTP_TIMEOUT = 60000;\n\nexport default {\n FALLBACK_CONTEXT,\n GENERIC_OPTIONS,\n DEFAULT_HTTP_TIMEOUT\n};\n"],"names":["FALLBACK_CONTEXT","GENERIC_OPTIONS","DEFAULT_HTTP_TIMEOUT"],"mappings":"AAGaA,MAAAA,EAAmB,0DAEnBC,EAAkB,CAC3B,SACA,kBACA,cACA,cACA,iBACA,OACA,UACA,QACA,UACA,YACA,gBACA,8BAGA,qBACA,kBACA,iBACA,eACA,WACA,kBACA,sBACA,WACA,UACA,iBACA,iBACA,iBACA,yBACA,2BAGSC,EAAuB"}
1
+ {"version":3,"file":"config.js","sources":["../../../src/core/config.ts"],"sourcesContent":["/**\n * FALLBACK_CONTEXT\n */\nexport const FALLBACK_CONTEXT = 'https://checkoutshopper-live.adyen.com/checkoutshopper/';\n\nexport const GENERIC_OPTIONS = [\n 'amount',\n 'secondaryAmount',\n 'countryCode',\n 'environment',\n 'loadingContext',\n 'i18n',\n 'modules',\n 'order',\n 'session',\n 'clientKey',\n 'showPayButton',\n 'redirectFromTopWhenInIframe',\n\n // Events\n 'onPaymentCompleted',\n 'onPaymentFailed',\n 'beforeRedirect',\n 'beforeSubmit',\n 'onSubmit',\n 'onActionHandled',\n 'onAdditionalDetails',\n 'onChange',\n 'onError',\n 'onBalanceCheck',\n 'onOrderRequest',\n 'onOrderUpdated',\n 'onPaymentMethodsRequest'\n];\n\nexport const DEFAULT_HTTP_TIMEOUT = 60000;\n\nexport default {\n FALLBACK_CONTEXT,\n GENERIC_OPTIONS,\n DEFAULT_HTTP_TIMEOUT\n};\n"],"names":["FALLBACK_CONTEXT","GENERIC_OPTIONS","DEFAULT_HTTP_TIMEOUT"],"mappings":"AAGaA,MAAAA,EAAmB,0DAEnBC,EAAkB,CAC3B,SACA,kBACA,cACA,cACA,iBACA,OACA,UACA,QACA,UACA,YACA,gBACA,8BAGA,qBACA,kBACA,iBACA,eACA,WACA,kBACA,sBACA,WACA,UACA,iBACA,iBACA,iBACA,2BAGSC,EAAuB"}
@@ -1,2 +1,2 @@
1
- import{Language as t}from"../language/Language.js";import o from"./RiskModule/RiskModule.js";import e from"./ProcessResponse/PaymentMethods/PaymentMethods.js";import{getComponentForAction as s}from"./ProcessResponse/PaymentAction/PaymentAction.js";import{resolveEnvironment as i,resolveCDNEnvironment as n,resolveAnalyticsEnvironment as r}from"./Environment/Environment.js";import a from"./Analytics/Analytics.js";import{processGlobalOptions as h}from"./utils.js";import c from"./CheckoutSession/CheckoutSession.js";import{hasOwnProperty as p}from"../utils/hasOwnProperty.js";import{Resources as l}from"./Context/Resources.js";import{SRPanel as m}from"./Errors/SRPanel.js";import d from"./core.registry.js";import{sanitizeResponse as u,verifyPaymentDidNotFail as y,cleanupFinalResult as C}from"../components/internal/UIElement/utils.js";import f,{IMPLEMENTATION_ERROR as g}from"./Errors/AdyenCheckoutError.js";import{ANALYTICS_ACTION_STR as w}from"./Analytics/constants.js";import{THREEDS2_FULL as v}from"../components/ThreeDS2/config.js";import{DEFAULT_LOCALE as b}from"../language/config.js";class j{session;paymentMethodsResponse;modules;options;loadingContext;cdnContext;analyticsContext;components=[];static version={version:"6.0.0-alpha.0",revision:"8e8ff69",branch:"HEAD",buildId:"@adyen/adyen-web-1c1883a8-5f9b-4f97-9b2a-7ddb8cfb4e1e",moduleType:"es"};static registry=d;static register(...t){d.add(...t)}register(...t){d.add(...t)}getComponent(t){return d.getComponent(t)}constructor(t){this.createFromAction=this.createFromAction.bind(this),this.setOptions(t),this.loadingContext=i(this.options.environment,this.options.environmentUrls?.api),this.cdnContext=n(this.options.resourceEnvironment||this.options.environment,this.options.environmentUrls?.api),this.analyticsContext=r(this.options.environment),this.session=this.options.session&&new c(this.options.session,this.options.clientKey,this.loadingContext);const o=this.options.clientKey?.substr(0,4);if(("test"===o||"live"===o)&&!this.loadingContext.includes(o))throw new Error(`Error: you are using a '${o}' clientKey against the '${this.options.environment}' environment`);window.adyenWebVersion=j.version.version}async initialize(){return await this.initializeCore(),this.validateCoreConfiguration(),this.createCoreModules(),this}async initializeCore(){return this.session?this.session.setupSession(this.options).then((t=>{const{amount:o,shopperLocale:e,countryCode:s,paymentMethods:i,...n}=t;return this.setOptions({...n,amount:this.options.order?this.options.order.remainingAmount:o,locale:this.options.locale||e,countryCode:this.options.countryCode||s}),this.createPaymentMethodsList(i),this})).catch((t=>(this.options.onError&&this.options.onError(t),Promise.reject(t)))):(this.createPaymentMethodsList(),Promise.resolve(this))}validateCoreConfiguration(){if(this.options.paymentMethodsConfiguration&&console.warn('WARNING: "paymentMethodsConfiguration" is supported only by Drop-in.'),this.options.locale||this.setOptions({locale:b}),!this.options.countryCode)throw new f(g,"You must specify a countryCode when initializing checkout. (If you are using a session then this session should be initialized with a countryCode.)")}submitDetails(t){let o=null;this.options.onAdditionalDetails&&(o=new Promise(((o,e)=>{this.options.onAdditionalDetails({data:t},void 0,{resolve:o,reject:e})}))),this.session&&(o=this.session.submitDetails(t).catch((t=>(this.options.onError?.(t),Promise.reject(t))))),o?o.then(u).then(y).then((t=>{C(t),this.options.onPaymentCompleted?.(t)})).catch((t=>{C(t),this.options.onPaymentFailed?.(t)})):this.options.onError?.(new f("IMPLEMENTATION_ERROR",'It can not submit the details. The callback "onAdditionalDetails" or the Session is not setup correctly.'))}createFromAction(t,o={}){if(!t||!t.type){if(p(t,"action")&&p(t,"resultCode"))throw new Error('createFromAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('createFromAction::Invalid Action - the passed action object does not have a "type" property')}if(t.type){const e=t.type===v?`${t.type}${t.subtype}`:t.paymentMethodType;this.modules.analytics.sendAnalytics(e,{type:w,subtype:t.type,message:`${e} action was handled by the SDK`});const i={...this.getCorePropsForComponent(),...o};return s(this,d,t,i)}return this.handleCreateError()}update=(t={})=>(this.setOptions(t),this.initialize().then((()=>(this.components.forEach((o=>o.update(t))),this))));remove=t=>(this.components=this.components.filter((o=>o._id!==t._id)),t.unmount(),this);setOptions=t=>{this.options={...this.options,...t,locale:t?.locale||this.options?.locale}};getCorePropsForComponent(){return{...h(this.options),core:this,i18n:this.modules.i18n,modules:this.modules,session:this.session,loadingContext:this.loadingContext,cdnContext:this.cdnContext,createFromAction:this.createFromAction}}storeElementReference(t){t&&this.components.push(t)}handleCreateError(t){const o=t?`${t?.name??"The passed payment method"} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(t)}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`:"No Payment Method component was passed";throw new Error(o)}createPaymentMethodsList(t){this.paymentMethodsResponse=new e(this.options.paymentMethodsResponse||t,this.options)}createCoreModules(){this.modules||(this.modules=Object.freeze({risk:new o(this,{...this.options,loadingContext:this.loadingContext}),analytics:a({loadingContext:this.loadingContext,analyticsContext:this.analyticsContext,clientKey:this.options.clientKey,locale:this.options.locale,analytics:this.options.analytics,amount:this.options.amount}),resources:new l(this.cdnContext),i18n:new t(this.options.locale,this.options.translations,this.options.translationFile),srPanel:new m(this,{...this.options.srConfig})}))}}export{j as default};
1
+ import{Language as t}from"../language/Language.js";import o from"./RiskModule/RiskModule.js";import e from"./ProcessResponse/PaymentMethods/PaymentMethods.js";import{getComponentForAction as s}from"./ProcessResponse/PaymentAction/PaymentAction.js";import{resolveEnvironment as i,resolveCDNEnvironment as n,resolveAnalyticsEnvironment as r}from"./Environment/Environment.js";import a from"./Analytics/Analytics.js";import{processGlobalOptions as h}from"./utils.js";import p from"./CheckoutSession/CheckoutSession.js";import{hasOwnProperty as c}from"../utils/hasOwnProperty.js";import{Resources as l}from"./Context/Resources.js";import{SRPanel as m}from"./Errors/SRPanel.js";import d from"./core.registry.js";import{sanitizeResponse as u,verifyPaymentDidNotFail as y,cleanupFinalResult as C}from"../components/internal/UIElement/utils.js";import f,{IMPLEMENTATION_ERROR as g}from"./Errors/AdyenCheckoutError.js";import{ANALYTICS_ACTION_STR as w}from"./Analytics/constants.js";import{THREEDS2_FULL as b}from"../components/ThreeDS2/config.js";import{DEFAULT_LOCALE as E}from"../language/config.js";class v{session;paymentMethodsResponse;modules;options;loadingContext;cdnContext;analyticsContext;components=[];static metadata={version:"6.0.0-alpha.2",revision:"9927564",branch:"HEAD",buildId:"@adyen/adyen-web-60e5b619-5779-4f8e-85c5-9e21794df694",bundleType:"esm"};static registry=d;static setBundleType(t){v.metadata.bundleType=t}static register(...t){d.add(...t)}register(...t){d.add(...t)}getComponent(t){return d.getComponent(t)}constructor(t){this.createFromAction=this.createFromAction.bind(this),this.setOptions({exposeLibraryMetadata:!0,...t}),this.loadingContext=i(this.options.environment,this.options.environmentUrls?.api),this.cdnContext=n(this.options.resourceEnvironment||this.options.environment,this.options.environmentUrls?.api),this.analyticsContext=r(this.options.environment),this.session=this.options.session&&new p(this.options.session,this.options.clientKey,this.loadingContext);const o=this.options.clientKey?.substr(0,4);if(("test"===o||"live"===o)&&!this.loadingContext.includes(o))throw new f("IMPLEMENTATION_ERROR",`Error: you are using a ${o} clientKey against the ${this.options.environment} environment`);this.options.exposeLibraryMetadata&&(window.AdyenWebMetadata=v.metadata)}async initialize(){return await this.initializeCore(),this.validateCoreConfiguration(),this.createCoreModules(),this}async initializeCore(){return this.session?this.session.setupSession(this.options).then((t=>{const{amount:o,shopperLocale:e,countryCode:s,paymentMethods:i,...n}=t;return this.setOptions({...n,amount:this.options.order?this.options.order.remainingAmount:o,locale:this.options.locale||e,countryCode:this.options.countryCode||s}),this.createPaymentMethodsList(i),this})).catch((t=>(this.options.onError&&this.options.onError(t),Promise.reject(t)))):(this.createPaymentMethodsList(),Promise.resolve(this))}validateCoreConfiguration(){if(this.options.paymentMethodsConfiguration&&console.warn('WARNING: "paymentMethodsConfiguration" is supported only by Drop-in.'),this.options.locale||this.setOptions({locale:E}),!this.options.countryCode)throw new f(g,"You must specify a countryCode when initializing checkout. (If you are using a session then this session should be initialized with a countryCode.)")}submitDetails(t){let o=null;this.options.onAdditionalDetails&&(o=new Promise(((o,e)=>{this.options.onAdditionalDetails({data:t},void 0,{resolve:o,reject:e})}))),this.session&&(o=this.session.submitDetails(t).catch((t=>(this.options.onError?.(t),Promise.reject(t))))),o?o.then(u).then(y).then((t=>{C(t),this.options.onPaymentCompleted?.(t)})).catch((t=>{C(t),this.options.onPaymentFailed?.(t)})):this.options.onError?.(new f("IMPLEMENTATION_ERROR",'It can not submit the details. The callback "onAdditionalDetails" or the Session is not setup correctly.'))}createFromAction(t,o={}){if(!t||!t.type){if(c(t,"action")&&c(t,"resultCode"))throw new Error('createFromAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('createFromAction::Invalid Action - the passed action object does not have a "type" property')}if(t.type){const e=t.type===b?`${t.type}${t.subtype}`:t.paymentMethodType;this.modules.analytics.sendAnalytics(e,{type:w,subtype:t.type,message:`${e} action was handled by the SDK`});const i={...this.getCorePropsForComponent(),...o};return s(this,d,t,i)}return this.handleCreateError()}update=(t={})=>(this.setOptions(t),this.initialize().then((()=>(this.components.forEach((o=>o.update(t))),this))));remove=t=>(this.components=this.components.filter((o=>o._id!==t._id)),t.unmount(),this);setOptions=t=>{this.options={...this.options,...t,locale:t?.locale||this.options?.locale}};getCorePropsForComponent(){return{...h(this.options),core:this,i18n:this.modules.i18n,modules:this.modules,session:this.session,loadingContext:this.loadingContext,cdnContext:this.cdnContext,createFromAction:this.createFromAction}}storeElementReference(t){t&&this.components.push(t)}handleCreateError(t){const o=t?`${t?.name??"The passed payment method"} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(t)}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`:"No Payment Method component was passed";throw new Error(o)}createPaymentMethodsList(t){this.paymentMethodsResponse=new e(this.options.paymentMethodsResponse||t,this.options)}createCoreModules(){this.modules||(this.modules=Object.freeze({risk:new o(this,{...this.options,loadingContext:this.loadingContext}),analytics:a({loadingContext:this.loadingContext,analyticsContext:this.analyticsContext,clientKey:this.options.clientKey,locale:this.options.locale,analytics:this.options.analytics,amount:this.options.amount,bundleType:v.metadata.bundleType}),resources:new l(this.cdnContext),i18n:new t(this.options.locale,this.options.translations,this.options.translationFile),srPanel:new m(this,{...this.options.srConfig})}))}}export{v as default};
2
2
  //# sourceMappingURL=core.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"core.js","sources":["../../../src/core/core.ts"],"sourcesContent":["import Language from '../language';\nimport UIElement from '../components/internal/UIElement/UIElement';\nimport RiskModule from './RiskModule';\nimport PaymentMethods from './ProcessResponse/PaymentMethods';\nimport getComponentForAction from './ProcessResponse/PaymentAction';\nimport { resolveEnvironment, resolveCDNEnvironment, resolveAnalyticsEnvironment } from './Environment';\nimport Analytics from './Analytics';\nimport { AdditionalDetailsStateData, PaymentAction, PaymentResponseData } from '../types/global-types';\nimport { CoreConfiguration, ICore } from './types';\nimport { processGlobalOptions } from './utils';\nimport Session from './CheckoutSession';\nimport { hasOwnProperty } from '../utils/hasOwnProperty';\nimport { Resources } from './Context/Resources';\nimport { SRPanel } from './Errors/SRPanel';\nimport registry, { NewableComponent } from './core.registry';\nimport { cleanupFinalResult, sanitizeResponse, verifyPaymentDidNotFail } from '../components/internal/UIElement/utils';\nimport AdyenCheckoutError, { IMPLEMENTATION_ERROR } from './Errors/AdyenCheckoutError';\nimport { ANALYTICS_ACTION_STR } from './Analytics/constants';\nimport { THREEDS2_FULL } from '../components/ThreeDS2/config';\nimport { DEFAULT_LOCALE } from '../language/config';\n\nclass Core implements ICore {\n public session?: Session;\n public paymentMethodsResponse: PaymentMethods;\n public modules: any;\n public options: CoreConfiguration;\n public loadingContext?: string;\n public cdnContext?: string;\n public analyticsContext?: string;\n\n private components: UIElement[] = [];\n\n public static readonly version = {\n version: process.env.VERSION,\n revision: process.env.COMMIT_HASH,\n branch: process.env.COMMIT_BRANCH,\n buildId: process.env.ADYEN_BUILD_ID,\n moduleType: process.env.MODULE_TYPE\n };\n\n public static registry = registry;\n\n public static register(...items: NewableComponent[]) {\n registry.add(...items);\n }\n\n /**\n * Used internally by the PaymentMethod components to auto-register themselves\n * @internal\n */\n public register(...items: NewableComponent[]) {\n registry.add(...items);\n }\n\n public getComponent(txVariant: string) {\n return registry.getComponent(txVariant);\n }\n\n constructor(props: CoreConfiguration) {\n this.createFromAction = this.createFromAction.bind(this);\n\n this.setOptions(props);\n\n this.loadingContext = resolveEnvironment(this.options.environment, this.options.environmentUrls?.api);\n this.cdnContext = resolveCDNEnvironment(this.options.resourceEnvironment || this.options.environment, this.options.environmentUrls?.api);\n this.analyticsContext = resolveAnalyticsEnvironment(this.options.environment);\n this.session = this.options.session && new Session(this.options.session, this.options.clientKey, this.loadingContext);\n\n const clientKeyType = this.options.clientKey?.substr(0, 4);\n if ((clientKeyType === 'test' || clientKeyType === 'live') && !this.loadingContext.includes(clientKeyType)) {\n throw new Error(`Error: you are using a '${clientKeyType}' clientKey against the '${this.options.environment}' environment`);\n }\n\n // Expose version number for npm builds\n window['adyenWebVersion'] = Core.version.version;\n }\n\n public async initialize(): Promise<this> {\n await this.initializeCore();\n this.validateCoreConfiguration();\n this.createCoreModules();\n return this;\n }\n\n private async initializeCore(): Promise<this> {\n if (this.session) {\n return this.session\n .setupSession(this.options)\n .then(sessionResponse => {\n const { amount, shopperLocale, countryCode, paymentMethods, ...rest } = sessionResponse;\n\n this.setOptions({\n ...rest,\n amount: this.options.order ? this.options.order.remainingAmount : amount,\n locale: this.options.locale || shopperLocale,\n countryCode: this.options.countryCode || countryCode\n });\n\n this.createPaymentMethodsList(paymentMethods);\n\n return this;\n })\n .catch(error => {\n if (this.options.onError) this.options.onError(error);\n return Promise.reject(error);\n });\n }\n\n this.createPaymentMethodsList();\n return Promise.resolve(this);\n }\n\n private validateCoreConfiguration(): void {\n // @ts-ignore This property does not exist, although merchants might be using when migrating from v5 to v6\n if (this.options.paymentMethodsConfiguration) {\n console.warn('WARNING: \"paymentMethodsConfiguration\" is supported only by Drop-in.');\n }\n\n if (!this.options.locale) {\n this.setOptions({ locale: DEFAULT_LOCALE });\n }\n\n if (!this.options.countryCode) {\n throw new AdyenCheckoutError(\n IMPLEMENTATION_ERROR,\n 'You must specify a countryCode when initializing checkout. (If you are using a session then this session should be initialized with a countryCode.)'\n );\n }\n }\n\n /**\n * Method used when handling redirects. It submits details using 'onAdditionalDetails' or the Sessions flow if available.\n *\n * @public\n * @see {https://docs.adyen.com/online-payments/build-your-integration/?platform=Web&integration=Components&version=5.55.1#handle-the-redirect}\n * @param details - Details object containing the redirectResult\n */\n public submitDetails(details: AdditionalDetailsStateData['data']): void {\n let promise = null;\n\n if (this.options.onAdditionalDetails) {\n promise = new Promise((resolve, reject) => {\n this.options.onAdditionalDetails({ data: details }, undefined, { resolve, reject });\n });\n }\n\n if (this.session) {\n promise = this.session.submitDetails(details).catch(error => {\n this.options.onError?.(error);\n return Promise.reject(error);\n });\n }\n\n if (!promise) {\n this.options.onError?.(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'It can not submit the details. The callback \"onAdditionalDetails\" or the Session is not setup correctly.'\n )\n );\n return;\n }\n\n promise\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then((response: PaymentResponseData) => {\n cleanupFinalResult(response);\n this.options.onPaymentCompleted?.(response);\n })\n .catch((response: PaymentResponseData) => {\n cleanupFinalResult(response);\n this.options.onPaymentFailed?.(response);\n });\n }\n\n /**\n * Instantiates a new element component ready to be mounted from an action object\n *\n * @param action - action defining the component with the component data\n * @param options - options that will be merged to the global Checkout props\n * @returns new UIElement\n */\n public createFromAction(action: PaymentAction, options = {}): any {\n if (!action || !action.type) {\n if (hasOwnProperty(action, 'action') && hasOwnProperty(action, 'resultCode')) {\n throw new Error(\n 'createFromAction::Invalid Action - the passed action object itself has an \"action\" property and ' +\n 'a \"resultCode\": have you passed in the whole response object by mistake?'\n );\n }\n throw new Error('createFromAction::Invalid Action - the passed action object does not have a \"type\" property');\n }\n\n if (action.type) {\n // 'threeDS2' OR 'qrCode', 'voucher', 'redirect', 'await', 'bankTransfer`\n const component = action.type === THREEDS2_FULL ? `${action.type}${action.subtype}` : action.paymentMethodType;\n\n this.modules.analytics.sendAnalytics(component, {\n type: ANALYTICS_ACTION_STR,\n subtype: action.type,\n message: `${component} action was handled by the SDK`\n });\n\n const props = {\n ...this.getCorePropsForComponent(),\n ...options\n };\n\n return getComponentForAction(this, registry, action, props);\n }\n\n return this.handleCreateError();\n }\n\n /**\n * Updates global configurations, resets the internal state and remounts each element.\n *\n * @param options - props to update\n * @returns this - the element instance\n */\n public update = (options: Partial<CoreConfiguration> = {}): Promise<this> => {\n this.setOptions(options);\n\n return this.initialize().then(() => {\n // Update each component under this instance\n // here we should update only the new options that have been received from core\n this.components.forEach(c => c.update(options));\n return this;\n });\n };\n\n /**\n * Remove the reference of a component\n * @param component - reference to the component to be removed\n * @returns this - the element instance\n * // TODO: Do we need this?\n */\n public remove = (component): this => {\n this.components = this.components.filter(c => c._id !== component._id);\n component.unmount();\n\n return this;\n };\n\n /**\n * @internal\n * Create or update the config object passed when AdyenCheckout is initialised (environment, clientKey, etc...)\n */\n private setOptions = (options: CoreConfiguration): void => {\n this.options = {\n ...this.options,\n ...options,\n locale: options?.locale || this.options?.locale\n };\n };\n\n /**\n * @internal\n * @returns props for a new UIElement\n */\n public getCorePropsForComponent(): any {\n const globalOptions = processGlobalOptions(this.options);\n\n return {\n ...globalOptions,\n core: this,\n i18n: this.modules.i18n,\n modules: this.modules,\n session: this.session,\n loadingContext: this.loadingContext,\n cdnContext: this.cdnContext,\n createFromAction: this.createFromAction\n };\n }\n\n public storeElementReference(element: UIElement) {\n if (element) {\n this.components.push(element);\n }\n }\n\n /**\n * @internal\n */\n private handleCreateError(paymentMethod?): never {\n const paymentMethodName = paymentMethod?.name ?? 'The passed payment method';\n const errorMessage = paymentMethod\n ? `${paymentMethodName} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(\n paymentMethod\n )}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`\n : 'No Payment Method component was passed';\n\n throw new Error(errorMessage);\n }\n\n private createPaymentMethodsList(paymentMethodsResponse?: PaymentMethods): void {\n this.paymentMethodsResponse = new PaymentMethods(this.options.paymentMethodsResponse || paymentMethodsResponse, this.options);\n }\n\n private createCoreModules(): void {\n if (this.modules) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('Core: Core modules are already created.');\n }\n return;\n }\n\n this.modules = Object.freeze({\n risk: new RiskModule(this, { ...this.options, loadingContext: this.loadingContext }),\n analytics: Analytics({\n loadingContext: this.loadingContext,\n analyticsContext: this.analyticsContext,\n clientKey: this.options.clientKey,\n locale: this.options.locale,\n analytics: this.options.analytics,\n amount: this.options.amount\n }),\n resources: new Resources(this.cdnContext),\n i18n: new Language(this.options.locale, this.options.translations, this.options.translationFile),\n srPanel: new SRPanel(this, { ...this.options.srConfig })\n });\n }\n}\n\nexport default Core;\n"],"names":["Core","session","paymentMethodsResponse","modules","options","loadingContext","cdnContext","analyticsContext","components","static","version","revision","branch","buildId","moduleType","registry","register","items","add","getComponent","txVariant","constructor","props","this","createFromAction","bind","setOptions","resolveEnvironment","environment","environmentUrls","api","resolveCDNEnvironment","resourceEnvironment","resolveAnalyticsEnvironment","Session","clientKey","clientKeyType","substr","includes","Error","window","initialize","initializeCore","validateCoreConfiguration","createCoreModules","setupSession","then","sessionResponse","amount","shopperLocale","countryCode","paymentMethods","rest","order","remainingAmount","locale","createPaymentMethodsList","catch","error","onError","Promise","reject","resolve","paymentMethodsConfiguration","console","warn","DEFAULT_LOCALE","AdyenCheckoutError","IMPLEMENTATION_ERROR","submitDetails","details","promise","onAdditionalDetails","data","undefined","sanitizeResponse","verifyPaymentDidNotFail","response","cleanupFinalResult","onPaymentCompleted","onPaymentFailed","action","type","hasOwnProperty","component","THREEDS2_FULL","subtype","paymentMethodType","analytics","sendAnalytics","ANALYTICS_ACTION_STR","message","getCorePropsForComponent","getComponentForAction","handleCreateError","update","forEach","c","remove","filter","_id","unmount","processGlobalOptions","core","i18n","storeElementReference","element","push","paymentMethod","errorMessage","name","JSON","stringify","PaymentMethods","Object","freeze","risk","RiskModule","Analytics","resources","Resources","Language","translations","translationFile","srPanel","SRPanel","srConfig"],"mappings":"skCAqBA,MAAMA,EACKC,QACAC,uBACAC,QACAC,QACAC,eACAC,WACAC,iBAECC,WAA0B,GAElCC,eAAiC,CAC7BC,QAAS,gBACTC,SAAU,UACVC,OAAQ,OACRC,QAAS,wDACTC,WAAY,MAGhBL,gBAAyBM,EAEzB,eAAcC,IAAYC,GACtBF,EAASG,OAAOD,EACpB,CAMA,QAAAD,IAAmBC,GACfF,EAASG,OAAOD,EACpB,CAEOE,YAAAA,CAAaC,GAChB,OAAOL,EAASI,aAAaC,EACjC,CAEAC,WAAAA,CAAYC,GACRC,KAAKC,iBAAmBD,KAAKC,iBAAiBC,KAAKF,MAEnDA,KAAKG,WAAWJ,GAEhBC,KAAKlB,eAAiBsB,EAAmBJ,KAAKnB,QAAQwB,YAAaL,KAAKnB,QAAQyB,iBAAiBC,KACjGP,KAAKjB,WAAayB,EAAsBR,KAAKnB,QAAQ4B,qBAAuBT,KAAKnB,QAAQwB,YAAaL,KAAKnB,QAAQyB,iBAAiBC,KACpIP,KAAKhB,iBAAmB0B,EAA4BV,KAAKnB,QAAQwB,aACjEL,KAAKtB,QAAUsB,KAAKnB,QAAQH,SAAW,IAAIiC,EAAQX,KAAKnB,QAAQH,QAASsB,KAAKnB,QAAQ+B,UAAWZ,KAAKlB,gBAEtG,MAAM+B,EAAgBb,KAAKnB,QAAQ+B,WAAWE,OAAO,EAAG,GACxD,IAAuB,SAAlBD,GAA8C,SAAlBA,KAA8Bb,KAAKlB,eAAeiC,SAASF,GACxF,MAAM,IAAIG,MAAM,2BAA2BH,6BAAyCb,KAAKnB,QAAQwB,4BAIrGY,OAAyB,gBAAGxC,EAAKU,QAAQA,OAC7C,CAEA,gBAAa+B,GA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C,WAAYiB,KAAKjB,WACjBkB,iBAAkBD,KAAKC,iBAE/B,CAEOiF,qBAAAA,CAAsBC,GACrBA,GACAnF,KAAKf,WAAWmG,KAAKD,EAE7B,CAKQZ,iBAAAA,CAAkBc,GACtB,MACMC,EAAeD,EACf,GAFoBA,GAAeE,MAAQ,sGAEoDC,KAAKC,UAChGJ,sGAEJ,yCAEN,MAAM,IAAIrE,MAAMsE,EACpB,CAEQrD,wBAAAA,CAAyBtD,GAC7BqB,KAAKrB,uBAAyB,IAAI+G,EAAe1F,KAAKnB,QAAQF,wBAA0BA,EAAwBqB,KAAKnB,QACzH,CAEQwC,iBAAAA,GACArB,KAAKpB,UAOToB,KAAKpB,QAAU+G,OAAOC,OAAO,CACzBC,KAAM,IAAIC,EAAW9F,KAAM,IAAKA,KAAKnB,QAASC,eAAgBkB,KAAKlB,iBACnEmF,UAAW8B,EAAU,CACjBjH,eAAgBkB,KAAKlB,eACrBE,iBAAkBgB,KAAKhB,iBACvB4B,UAAWZ,KAAKnB,QAAQ+B,UACxBoB,OAAQhC,KAAKnB,QAAQmD,OACrBiC,UAAWjE,KAAKnB,QAAQoF,UACxBxC,OAAQzB,KAAKnB,QAAQ4C,SAEzBuE,UAAW,IAAIC,EAAUjG,KAAKjB,YAC9BkG,KAAM,IAAIiB,EAASlG,KAAKnB,QAAQmD,OAAQhC,KAAKnB,QAAQsH,aAAcnG,KAAKnB,QAAQuH,iBAChFC,QAAS,IAAIC,EAAQtG,KAAM,IAAKA,KAAKnB,QAAQ0H,aAErD"}
1
+ {"version":3,"file":"core.js","sources":["../../../src/core/core.ts"],"sourcesContent":["import Language from '../language';\nimport UIElement from '../components/internal/UIElement/UIElement';\nimport RiskModule from './RiskModule';\nimport PaymentMethods from './ProcessResponse/PaymentMethods';\nimport getComponentForAction from './ProcessResponse/PaymentAction';\nimport { resolveEnvironment, resolveCDNEnvironment, resolveAnalyticsEnvironment } from './Environment';\nimport Analytics from './Analytics';\nimport { AdditionalDetailsStateData, PaymentAction, PaymentResponseData } from '../types/global-types';\nimport { CoreConfiguration, ICore } from './types';\nimport { processGlobalOptions } from './utils';\nimport Session from './CheckoutSession';\nimport { hasOwnProperty } from '../utils/hasOwnProperty';\nimport { Resources } from './Context/Resources';\nimport { SRPanel } from './Errors/SRPanel';\nimport registry, { NewableComponent } from './core.registry';\nimport { cleanupFinalResult, sanitizeResponse, verifyPaymentDidNotFail } from '../components/internal/UIElement/utils';\nimport AdyenCheckoutError, { IMPLEMENTATION_ERROR } from './Errors/AdyenCheckoutError';\nimport { ANALYTICS_ACTION_STR } from './Analytics/constants';\nimport { THREEDS2_FULL } from '../components/ThreeDS2/config';\nimport { DEFAULT_LOCALE } from '../language/config';\n\nclass Core implements ICore {\n public session?: Session;\n public paymentMethodsResponse: PaymentMethods;\n public modules: any;\n public options: CoreConfiguration;\n public loadingContext?: string;\n public cdnContext?: string;\n public analyticsContext?: string;\n\n private components: UIElement[] = [];\n\n public static readonly metadata = {\n version: process.env.VERSION,\n revision: process.env.COMMIT_HASH,\n branch: process.env.COMMIT_BRANCH,\n buildId: process.env.ADYEN_BUILD_ID,\n bundleType: process.env.BUNDLE_TYPE\n };\n\n public static registry = registry;\n\n public static setBundleType(type: string): void {\n Core.metadata.bundleType = type;\n }\n\n public static register(...items: NewableComponent[]) {\n registry.add(...items);\n }\n\n /**\n * Used internally by the PaymentMethod components to auto-register themselves\n * @internal\n */\n public register(...items: NewableComponent[]) {\n registry.add(...items);\n }\n\n public getComponent(txVariant: string) {\n return registry.getComponent(txVariant);\n }\n\n constructor(props: CoreConfiguration) {\n this.createFromAction = this.createFromAction.bind(this);\n\n this.setOptions({ exposeLibraryMetadata: true, ...props });\n\n this.loadingContext = resolveEnvironment(this.options.environment, this.options.environmentUrls?.api);\n this.cdnContext = resolveCDNEnvironment(this.options.resourceEnvironment || this.options.environment, this.options.environmentUrls?.api);\n this.analyticsContext = resolveAnalyticsEnvironment(this.options.environment);\n this.session = this.options.session && new Session(this.options.session, this.options.clientKey, this.loadingContext);\n\n const clientKeyType = this.options.clientKey?.substr(0, 4);\n if ((clientKeyType === 'test' || clientKeyType === 'live') && !this.loadingContext.includes(clientKeyType)) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Error: you are using a ${clientKeyType} clientKey against the ${this.options.environment} environment`\n );\n }\n\n if (this.options.exposeLibraryMetadata) {\n window['AdyenWebMetadata'] = Core.metadata;\n }\n }\n\n public async initialize(): Promise<this> {\n await this.initializeCore();\n this.validateCoreConfiguration();\n this.createCoreModules();\n return this;\n }\n\n private async initializeCore(): Promise<this> {\n if (this.session) {\n return this.session\n .setupSession(this.options)\n .then(sessionResponse => {\n const { amount, shopperLocale, countryCode, paymentMethods, ...rest } = sessionResponse;\n\n this.setOptions({\n ...rest,\n amount: this.options.order ? this.options.order.remainingAmount : amount,\n locale: this.options.locale || shopperLocale,\n countryCode: this.options.countryCode || countryCode\n });\n\n this.createPaymentMethodsList(paymentMethods);\n\n return this;\n })\n .catch(error => {\n if (this.options.onError) this.options.onError(error);\n return Promise.reject(error);\n });\n }\n\n this.createPaymentMethodsList();\n return Promise.resolve(this);\n }\n\n private validateCoreConfiguration(): void {\n // @ts-ignore This property does not exist, although merchants might be using when migrating from v5 to v6\n if (this.options.paymentMethodsConfiguration) {\n console.warn('WARNING: \"paymentMethodsConfiguration\" is supported only by Drop-in.');\n }\n\n if (!this.options.locale) {\n this.setOptions({ locale: DEFAULT_LOCALE });\n }\n\n if (!this.options.countryCode) {\n throw new AdyenCheckoutError(\n IMPLEMENTATION_ERROR,\n 'You must specify a countryCode when initializing checkout. (If you are using a session then this session should be initialized with a countryCode.)'\n );\n }\n }\n\n /**\n * Method used when handling redirects. It submits details using 'onAdditionalDetails' or the Sessions flow if available.\n *\n * @public\n * @see {https://docs.adyen.com/online-payments/build-your-integration/?platform=Web&integration=Components&version=5.55.1#handle-the-redirect}\n * @param details - Details object containing the redirectResult\n */\n public submitDetails(details: AdditionalDetailsStateData['data']): void {\n let promise = null;\n\n if (this.options.onAdditionalDetails) {\n promise = new Promise((resolve, reject) => {\n this.options.onAdditionalDetails({ data: details }, undefined, { resolve, reject });\n });\n }\n\n if (this.session) {\n promise = this.session.submitDetails(details).catch(error => {\n this.options.onError?.(error);\n return Promise.reject(error);\n });\n }\n\n if (!promise) {\n this.options.onError?.(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'It can not submit the details. The callback \"onAdditionalDetails\" or the Session is not setup correctly.'\n )\n );\n return;\n }\n\n promise\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then((response: PaymentResponseData) => {\n cleanupFinalResult(response);\n this.options.onPaymentCompleted?.(response);\n })\n .catch((response: PaymentResponseData) => {\n cleanupFinalResult(response);\n this.options.onPaymentFailed?.(response);\n });\n }\n\n /**\n * Instantiates a new element component ready to be mounted from an action object\n *\n * @param action - action defining the component with the component data\n * @param options - options that will be merged to the global Checkout props\n * @returns new UIElement\n */\n public createFromAction(action: PaymentAction, options = {}): any {\n if (!action || !action.type) {\n if (hasOwnProperty(action, 'action') && hasOwnProperty(action, 'resultCode')) {\n throw new Error(\n 'createFromAction::Invalid Action - the passed action object itself has an \"action\" property and ' +\n 'a \"resultCode\": have you passed in the whole response object by mistake?'\n );\n }\n throw new Error('createFromAction::Invalid Action - the passed action object does not have a \"type\" property');\n }\n\n if (action.type) {\n // 'threeDS2' OR 'qrCode', 'voucher', 'redirect', 'await', 'bankTransfer`\n const component = action.type === THREEDS2_FULL ? `${action.type}${action.subtype}` : action.paymentMethodType;\n\n this.modules.analytics.sendAnalytics(component, {\n type: ANALYTICS_ACTION_STR,\n subtype: action.type,\n message: `${component} action was handled by the SDK`\n });\n\n const props = {\n ...this.getCorePropsForComponent(),\n ...options\n };\n\n return getComponentForAction(this, registry, action, props);\n }\n\n return this.handleCreateError();\n }\n\n /**\n * Updates global configurations, resets the internal state and remounts each element.\n *\n * @param options - props to update\n * @returns this - the element instance\n */\n public update = (options: Partial<CoreConfiguration> = {}): Promise<this> => {\n this.setOptions(options);\n\n return this.initialize().then(() => {\n // Update each component under this instance\n // here we should update only the new options that have been received from core\n this.components.forEach(c => c.update(options));\n return this;\n });\n };\n\n /**\n * Remove the reference of a component\n * @param component - reference to the component to be removed\n * @returns this - the element instance\n * // TODO: Do we need this?\n */\n public remove = (component): this => {\n this.components = this.components.filter(c => c._id !== component._id);\n component.unmount();\n\n return this;\n };\n\n /**\n * @internal\n * Create or update the config object passed when AdyenCheckout is initialised (environment, clientKey, etc...)\n */\n private setOptions = (options: CoreConfiguration): void => {\n this.options = {\n ...this.options,\n ...options,\n locale: options?.locale || this.options?.locale\n };\n };\n\n /**\n * @internal\n * @returns props for a new UIElement\n */\n public getCorePropsForComponent(): any {\n const globalOptions = processGlobalOptions(this.options);\n\n return {\n ...globalOptions,\n core: this,\n i18n: this.modules.i18n,\n modules: this.modules,\n session: this.session,\n loadingContext: this.loadingContext,\n cdnContext: this.cdnContext,\n createFromAction: this.createFromAction\n };\n }\n\n public storeElementReference(element: UIElement) {\n if (element) {\n this.components.push(element);\n }\n }\n\n /**\n * @internal\n */\n private handleCreateError(paymentMethod?): never {\n const paymentMethodName = paymentMethod?.name ?? 'The passed payment method';\n const errorMessage = paymentMethod\n ? `${paymentMethodName} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(\n paymentMethod\n )}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`\n : 'No Payment Method component was passed';\n\n throw new Error(errorMessage);\n }\n\n private createPaymentMethodsList(paymentMethodsResponse?: PaymentMethods): void {\n this.paymentMethodsResponse = new PaymentMethods(this.options.paymentMethodsResponse || paymentMethodsResponse, this.options);\n }\n\n private createCoreModules(): void {\n if (this.modules) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('Core: Core modules are already created.');\n }\n return;\n }\n\n this.modules = Object.freeze({\n risk: new RiskModule(this, { ...this.options, loadingContext: this.loadingContext }),\n analytics: Analytics({\n loadingContext: this.loadingContext,\n analyticsContext: this.analyticsContext,\n clientKey: this.options.clientKey,\n locale: this.options.locale,\n analytics: this.options.analytics,\n amount: this.options.amount,\n bundleType: Core.metadata.bundleType\n }),\n resources: new Resources(this.cdnContext),\n i18n: new Language(this.options.locale, this.options.translations, this.options.translationFile),\n srPanel: new SRPanel(this, { ...this.options.srConfig })\n });\n }\n}\n\nexport default Core;\n"],"names":["Core","session","paymentMethodsResponse","modules","options","loadingContext","cdnContext","analyticsContext","components","static","version","revision","branch","buildId","bundleType","registry","setBundleType","type","metadata","register","items","add","getComponent","txVariant","constructor","props","this","createFromAction","bind","setOptions","exposeLibraryMetadata","resolveEnvironment","environment","environmentUrls","api","resolveCDNEnvironment","resourceEnvironment","resolveAnalyticsEnvironment","Session","clientKey","clientKeyType","substr","includes","AdyenCheckoutError","window","initialize","initializeCore","validateCoreConfiguration","createCoreModules","setupSession","then","sessionResponse","amount","shopperLocale","countryCode","paymentMethods","rest","order","remainingAmount","locale","createPaymentMethodsList","catch","error","onError","Promise","reject","resolve","paymentMethodsConfiguration","console","warn","DEFAULT_LOCALE","IMPLEMENTATION_ERROR","submitDetails","details","promise","onAdditionalDetails","data","undefined","sanitizeResponse","verifyPaymentDidNotFail","response","cleanupFinalResult","onPaymentCompleted","onPaymentFailed","action","hasOwnProperty","Error","component","THREEDS2_FULL","subtype","paymentMethodType","analytics","sendAnalytics","ANALYTICS_ACTION_STR","message","getCorePropsForComponent","getComponentForAction","handleCreateError","update","forEach","c","remove","filter","_id","unmount","processGlobalOptions","core","i18n","storeElementReference","element","push","paymentMethod","errorMessage","name","JSON","stringify","PaymentMethods","Object","freeze","risk","RiskModule","Analytics","resources","Resources","Language","translations","translationFile","srPanel","SRPanel","srConfig"],"mappings":"skCAqBA,MAAMA,EACKC,QACAC,uBACAC,QACAC,QACAC,eACAC,WACAC,iBAECC,WAA0B,GAElCC,gBAAkC,CAC9BC,QAAS,gBACTC,SAAU,UACVC,OAAQ,OACRC,QAAS,wDACTC,WAAY,OAGhBL,gBAAyBM,EAEzB,oBAA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