@payrails/web-sdk 5.37.7 → 5.37.9-RC.0
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.
- package/README.md +11 -0
- package/index.js +4 -4
- package/package.json +1 -1
- package/payrails.d.ts +48 -32
- package/payrails.js +4 -4
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
!function(){"use strict";function e(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(i[n[s]]=e[n[s]])}return i}function t(e,t,i,n){return new(i||(i=Promise))(function(s,o){function r(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,a)}l((n=n.apply(e,t||[])).next())})}function i(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)}function n(e,t,i,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,i):s?s.value=i:t.set(e,i),i}exports.ElementType=void 0,function(e){e.CARD_NUMBER="CARD_NUMBER",e.CARDHOLDER_NAME="CARDHOLDER_NAME",e.CVV="CVV",e.EXPIRATION_MONTH="EXPIRATION_MONTH",e.EXPIRATION_YEAR="EXPIRATION_YEAR",e.EXPIRATION_DATE="EXPIRATION_DATE"}(exports.ElementType||(exports.ElementType={})),"function"==typeof SuppressedError&&SuppressedError;var s={};!function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t=(e=>(e.PAYRAILS_CLIENT_CONFIG_MALFORMED="payrails:client:init.config_malformed",e.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT="payrails:client:collectContainer.unmountable",e.PAYRAILS_CLIENT_UI_ELEMENT_MISSING="payrails:client:mount.ui_element_missing",e.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING="payrails:client:mount.parent_element_missing",e.PAYRAILS_CLIENT_SUBELEMENTS_RENDER_ERROR="payrails:client:mount.subelements_render_error",e.PAYRAILS_CLIENT_CARD_FORM_MISSING="payrails:client:pay.card_form_missing",e.PAYRAILS_CLIENT_GPAY_LOADING_ERROR="payrails:client:mount.gpay_loading_error",e.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING="payrails:client:init.gpay_config_missing",e.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR="payrails:client:mount.applepay_loading_error",e.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING="payrails:client:init.applepay_config_missing",e.PAYRAILS_CLIENT_APPLEPAY_START_PAYMENT_SESSION_ERROR="payrails:client:init.applepay_start_payment_session_error",e.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR="payrails:client:init.paypal_loading_error",e.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING="payrails:client:init.paypal_config_missing",e.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION="payrails:client:init.paypal_order_creation",e.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT="payrails:client:mount.paypal_button_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR="payrails:client:payment_executor.pay_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAYOUT_ERROR="payrails:client:payment_executor.payout_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR="payrails:client:payment_executor.3ds_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR="payrails:client:payment_executor.confirm_error",e.PAYRAILS_API_UNAUTHORIZED="payrails:api:unauthorized",e.PAYRAILS_API_TOO_MANY_REQUESTS="payrails:api:too_many_requests",e.PAYRAILS_API_UNSUCCESSFUL="payrails:api:unsuccessful",e.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED="payrails:api:authorization_not_requested",e.PAYRAILS_API_AUTHENTICATION_ERROR="payrails:api:request_authentication_error",e.PAYRAILS_API_AUTHORIZATION_ERROR="payrails:api:request_authorization_error",e.PAYRAILS_API_PAYOUT_ERROR="payrails:api:request_payout_error",e.PAYRAILS_CLIENT_API_URL_NOT_FOUND="payrails:client:api_url_not_found",e.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND="payrails:client:workflow_execution_not_found",e.PAYRAILS_CARD_FORM_CREATION_FAILED="payrails:card_form:iframe_creation_failed",e.PAYRAILS_CARD_FORM_IFRAME_URL_MISSING="payrails:card_form:iframe_url_missing",e.PAYRAILS_CLIENT_UNKNOWN_ERROR="payrails:client:unknown",e.PAYRAILS_API_UNKNOWN_ERROR="payrails:api:unknown",e.PAYRAILS_CLIENT_SESSION_REFRESH_FAILED="payrails:client:session_refresh_failed",e.PAYRAILS_CLIENT_CALLBACK_FAILED="payrails:client:callback_failed",e.PAYRAILS_API_BIN_LOOKUP_FAILED="payrails:api:bin_lookup_failed",e.PAYRAILS_CARD_FORM_ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE="payrails.card_form.element_not_mounted_in_element_match_rule",e.PAYRAILS_CARD_FORM_REQUIRED_PARAMS_NOT_PROVIDED="payrails.card_form.required_params_not_provided",e.PAYRAILS_CARD_FORM_CLIENT_CONNECTION="payrails.card_form.client_connection",e.PAYRAILS_CARD_FORM_IFRAME_NOT_FOUND="payrails.card_form.iframe_not_found",e.PAYRAILS_CARD_FORM_IFRAME_LOADING_ERROR="payrails.card_form.iframe_loading_error",e.PAYRAILS_CARD_FORM_CSP_ERROR="payrails.card_form.iframe_csp_error",e.PAYRAILS_CARD_FORM_COMPLETE_AND_VALID_INPUTS="payrails.card_form.complete_and_valid_inputs",e.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED="payrails.card_form.collect_element_not_mounted",e.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK="payrails:client:generic_redirect.missing.redirect_link",e.PAYRAILS_CLIENT_COLLECT_CREATION_FAILED="payrails:client:collect_container.creation.failed",e.PAYRAILS_CLIENT_COLLECT_EMPTY_CONTAINER_TYPE="payrails:client:collect_container.empty_container_type",e.PAYRAILS_CLIENT_COLLECT_INVALID_CONTAINER_TYPE="payrails:client:collect_container.invalid_container_type",e.PAYRAILS_CLIENT_COLLECT_OPERATION_FAILED="payrails:client:collect_container.collect_operation_failed",e.PAYRAILS_CLIENT_VAULT_CONNECTION_ERROR="payrails:client:vault.connection_error",e.PAYRAILS_CLIENT_VAULT_NETWORK_ERROR="payrails:client:vault.network.error",e.PAYRAILS_CLIENT_COLLECT_UNIQUE_ELEMENT_NAME="payrails:client:collect_container.unique_element_name",e.PAYRAILS_CLIENT_COLLECT_INVALID_TOKENS="payrails:client:collect_container.invalid_tokens",e.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_IN_MOUNT="payrails:client:collect_container.empty_element",e.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_LISTENER="payrails:client:collect_container.invalid_event_listener",e.PAYRAILS_CLIENT_COLLECT_MISSING_HANDLER_IN_EVENT_LISTENER="payrails:client:collect_container.missing_event_handler",e.PAYRAILS_CLIENT_COLLECT_INVALID_HANDLER_IN_EVENT_LISTENER="payrails:client:collect_container.invalid_event_handler",e.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_TYPE="payrails:client:collect_container.invalid_event_type",e.PAYRAILS_CLIENT_COLLECT_TABLE_NAME_MISSING="payrails:client:collect_container.table_name_missing",e.PAYRAILS_CLIENT_COLLECT_EMPTY_TABLE="payrails:client:collect_container.empty_table",e.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_NAME="payrails:client:collect_container.invalid_table_name",e.PAYRAILS_CLIENT_COLLECT_MISSING_COLUMN="payrails:client:collect_container.missing_column",e.PAYRAILS_CLIENT_COLLECT_EMPTY_COLUMN="payrails:client:collect_container.empty_column",e.PAYRAILS_CLIENT_COLLECT_INVALID_COLUMN="payrails:client:collect_container.invalid_column",e.PAYRAILS_CLIENT_COLLECT_EMPTY_SKYFLOW_ID="payrails:client:collect_container.empty_skyflow_id",e.PAYRAILS_CLIENT_COLLECT_INVALID_SKYFLOW_ID="payrails:client:collect_container.invalid_skyflow_id",e.PAYRAILS_CLIENT_COLLECT_MISMATCH_ELEMENT_COUNT_LAYOUT_SUM="payrails:client:collect_container.mismatch_element_count_layout_sum",e.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_SELECTOR="payrails:client:collect_container.invalid_element_selector",e.PAYRAILS_CLIENT_COLLECT_DUPLICATE_ELEMENT="payrails:client:collect_container.duplicate_element",e.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_TYPE="payrails:client:collect_container.invalid_element_type",e.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATIONS_TYPE="payrails:client:collect_container.invalid_validations_type",e.PAYRAILS_CLIENT_COLLECT_MISSING_VALIDATION_RULE_TYPE="payrails:client:collect_container.missing_validation_rule_type",e.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATION_RULE_TYPE="payrails:client:collect_container.invalid_validation_rule_type",e.PAYRAILS_CLIENT_COLLECT_MISSING_VALIDATION_RULE_PARAMS="payrails:client:collect_container.missing_validation_rule_params",e.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATION_RULE_PARAMS="payrails:client:collect_container.invalid_validation_rule_params",e.PAYRAILS_CLIENT_COLLECT_MISSING_REGEX_IN_REGEX_MATCH_RULE="payrails:client:collect_container.missing_regex_in_regex_match_rule",e.PAYRAILS_CLIENT_COLLECT_MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE="payrails:client:collect_container.missing_min_and_max_in_length_match_rule",e.PAYRAILS_CLIENT_COLLECT_MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE="payrails:client:collect_container.missing_element_in_element_match_rule",e.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE="payrails:client:collect_container.invalid_element_in_element_match_rule",e.PAYRAILS_CLIENT_COLLECT_INVALID_REGEX_IN_REGEX_MATCH_RULE="payrails:client:collect_container.invalid_regex_in_regex_match_rule",e.PAYRAILS_CLIENT_COLLECT_INVALID_BOOLEAN_OPTIONS="payrails:client:collect_container.invalid_boolean_options",e.PAYRAILS_CLIENT_COLLECT_MISSING_ELEMENT_TYPE="payrails:client:collect_container.missing_element_type",e.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_TYPE="payrails:client:collect_container.empty_element_type",e.PAYRAILS_CLIENT_COLLECT_INVALID_UPSERT_OPTION_TYPE="payrails:client:collect_container.invalid_upsert_option_type",e.PAYRAILS_CLIENT_COLLECT_EMPTY_UPSERT_OPTIONS_ARRAY="payrails:client:collect_container.empty_upsert_options_array",e.PAYRAILS_CLIENT_COLLECT_INVALID_UPSERT_OPTION_OBJECT_TYPE="payrails:client:collect_container.invalid_upsert_option_object_type",e.PAYRAILS_CLIENT_COLLECT_MISSING_TABLE_IN_UPSERT_OPTION="payrails:client:collect_container.missing_table_in_upsert_option",e.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_IN_UPSERT_OPTION="payrails:client:collect_container.invalid_table_in_upsert_option",e.PAYRAILS_CLIENT_COLLECT_MISSING_COLUMN_IN_UPSERT_OPTION="payrails:client:collect_container.missing_column_in_upsert_option",e.PAYRAILS_CLIENT_COLLECT_INVALID_COLUMN_IN_UPSERT_OPTION="payrails:client:collect_container.invalid_column_in_upsert_option",e.PAYRAILS_CLIENT_COLLECT_MISSING_COMPOSABLE_CONTAINER_OPTIONS="payrails:client:collect_container.missing_composable_container_options",e.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_CONTAINER_OPTIONS="payrails:client:collect_container.invalid_composable_container_options",e.PAYRAILS_CLIENT_COLLECT_MISSING_COMPOSABLE_LAYOUT_KEY="payrails:client:collect_container.missing_composable_layout_key",e.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_LAYOUT_TYPE="payrails:client:collect_container.invalid_composable_layout_type",e.PAYRAILS_CLIENT_COLLECT_EMPTY_COMPOSABLE_LAYOUT_ARRAY="payrails:client:collect_container.empty_composable_layout_array",e.PAYRAILS_CLIENT_COLLECT_NEGATIVE_VALUES_COMPOSABLE_LAYOUT="payrails:client:collect_container.negative_values_composable_layout",e.PAYRAILS_CLIENT_COLLECT_INVALID_INPUT_OPTIONS_FORMAT="payrails:client:collect_container.invalid_input_options_format",e.PAYRAILS_CLIENT_COLLECT_INVALID_INPUT_OPTIONS_TRANSLATION="payrails:client:collect_container.invalid_input_options_translation",e.PAYRAILS_CLIENT_COLLECT_RECORDS_KEY_MISSING_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.records_key_missing_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_INVALID_RECORDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.invalid_records_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_MISSING_RECORDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.missing_records_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_MISSING_TABLE_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.missing_table_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_EMPTY_TABLE_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.empty_table_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.invalid_table_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_MISSING_FIELDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.missing_fields_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_EMPTY_FIELDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.empty_fields_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_INVALID_FIELDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.invalid_fields_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_GET_BEARER_TOKEN_MISSING="payrails:client:collect_container.get_bearer_token_missing",e.PAYRAILS_CLIENT_COMPOSABLE_CONTAINER_OPTIONS_MISSING="payrails:client:composable_container_options_missing",e.PAYRAILS_CLIENT_COMPOSABLE_CONTAINER_OPTIONS_INVALID="payrails:client:composable_container_options_invalid",e.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_UNSUPPORTED_COMPONENT_TYPE="payrails:client:dynamic_element_form.unsupported_component_type",e.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_MISSING_CONFIG="payrails:client:dynamic_element_form.missing_config",e.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_NOT_MOUNTED="payrails:client:dynamic_element_form.not_mounted",e.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_FORM_INVALID="payrails:client:dynamic_element_form.form_invalid",e.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_PAYMENT_BUTTON_MISSING_WORKFLOW_CODE="payrails:client:payment_button.no_instrument_selected",e.PAYRAILS_CLIENT_CREATE_STORED_INSTRUMENT_INVALID_ELEMENT_TYPE="payrails:client:create_stored_instrument.invalid_element_type",e.PAYRAILS_CLIENT_API_PAYOUT_NO_INSTRUMENT_SELECTED="payrails:client:api:payout_no_instrument_selected",e))(t||{});const i={"payrails:client:init.config_malformed":{description:"The provided configuration string is invalid. Please ensure it matches the required format and structure as defined in the documentation",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:unknown":{description:"Unknown Client",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:unauthorized":{description:"Unauthorized access to the Payrails API",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:too_many_requests":{description:"Too many requests to the Payrails API",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:unsuccessful":{description:"Unsuccessful request to the Payrails API",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collectContainer.unmountable":{description:"Collect container cannot be mounted",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.ui_element_missing":{description:"Collect container element does not exist",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:pay.card_form_missing":{description:"Trying to collect values from non-existent card form",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.gpay_loading_error":{description:"Google pay can not be initialized",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.paypal_loading_error":{description:"Paypal can not be initialized",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.paypal_order_creation":{description:"Paypal order creation failed",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.paypal_button_error":{description:"PaypalButtonError occurred",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.parent_element_missing":{description:"Parent element not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.subelements_render_error":{description:"Subelements could not be rendered. Please set id for the element first.",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:api_url_not_found":{description:"API URL not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:workflow_execution_not_found":{description:"Workflow execution not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.paypal_config_missing":{description:"Paypal config not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:authorization_not_requested":{description:"Authorization was not requested",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.gpay_config_missing":{description:"Google pay config not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.applepay_loading_error":{description:"Apple pay can not be initialized",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.applepay_config_missing":{description:"Apple pay config not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.applepay_start_payment_session_error":{description:"Apple pay start payment session call failed",docUrl:"https://docs.payrails.com/"},"payrails:card_form:iframe_creation_failed":{description:"Error occured while creating an iframe",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:card_form:iframe_url_missing":{description:"Iframe URL is missing",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:callback_failed":{description:"Callback passed threw an error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:session_refresh_failed":{description:"Error occured while refreshing the session",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:bin_lookup_failed":{description:"Error occured while looking up the BIN",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:request_authentication_error":{description:"Authentication error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:unknown":{description:"Unknown API error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_executor.pay_error":{description:"Error occured while executing a payment",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_executor.payout_error":{description:"Error occured while executing a payout",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_executor.confirm_error":{description:"Error occured while confirming a payment",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:request_authorization_error":{description:"Authorization error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:request_payout_error":{description:"Payout error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_executor.3ds_error":{description:"Authorization failed after 3DS challenge.",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.element_not_mounted_in_element_match_rule":{description:"Interface: collect element - collect element is not mounted in ValidationRule params at index %s1 in validations array",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.required_params_not_provided":{description:"Interface: collect element - Required params are not provided.",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.client_connection":{description:"Interface: collect container - client connection not established. client info has not reached iframes",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.iframe_not_found":{description:"Interface: collect element - frame not found:",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.complete_and_valid_inputs":{description:"Interface: collect container - Provide complete and valid inputs",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.collect_element_not_mounted":{description:"Interface: composable collect - collect element is not mounted",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.iframe_loading_error":{description:"Interface: collect element - Error occured while loading iframe",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.iframe_csp_error":{description:"Interface: collect element - Content Security Policy error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:generic_redirect.missing.redirect_link":{description:"[Generic Redirect] Missing redirect link in response"},"payrails:client:collect_container.creation.failed":{description:"Collect container failed to initialize",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_container_type":{description:"client container - Invalid container type. Container object cannot be empty.",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_container_type":{description:"client container - Invalid container type. Invalid container object",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:vault.connection_error":{description:"Vault connection error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:vault.network.error":{description:"Vault network error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.unique_element_name":{description:"client container - Element name must be unique",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_tokens":{description:"client container - Invalid tokens",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_element":{description:"client container - Element cannot be empty",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_event_listener":{description:"client container - Invalid event listener",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_event_handler":{description:"client container - Missing handler in event listener",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_event_handler":{description:"client container - Invalid handler in event listener",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_event_type":{description:"client container - Invalid event type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.table_name_missing":{description:"client container - Table name missing",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_table":{description:"client container - Table cannot be empty",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_table_name":{description:"client container - Invalid table name",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_column":{description:"client container - Column missing",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_column":{description:"client container - Column cannot be empty",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_column":{description:"client container - Invalid column",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_skyflow_id":{description:"client container - Skyflow ID cannot be empty",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_skyflow_id":{description:"client container - Invalid Skyflow ID",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.mismatch_element_count_layout_sum":{description:"client container - Element count does not match layout sum",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_element_selector":{description:"client container - Invalid element selector",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.duplicate_element":{description:"client container - Duplicate element",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_element_type":{description:"client container - Invalid element type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_validations_type":{description:"client container - Invalid validations type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_validation_rule_type":{description:"client container - Missing validation rule type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_validation_rule_type":{description:"client container - Invalid validation rule type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_validation_rule_params":{description:"client container - Missing validation rule params",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_validation_rule_params":{description:"client container - Invalid validation rule params",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_regex_in_regex_match_rule":{description:"client container - Missing regex in regex match rule",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_min_and_max_in_length_match_rule":{description:"client container - Missing min and max in length match rule",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_element_in_element_match_rule":{description:"client container - Missing element in element match rule",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_element_in_element_match_rule":{description:"client container - Invalid element in element match rule",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_regex_in_regex_match_rule":{description:"client container - Invalid regex in regex match rule",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_boolean_options":{description:"client container - Invalid boolean options",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_element_type":{description:"client container - Missing element type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_element_type":{description:"client container - EMPTY element type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_upsert_option_type":{description:"client container - Invalid upsert option type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_upsert_options_array":{description:"client container - Empty upsert options array",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_upsert_option_object_type":{description:"client container - Invalid upsert option object type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_table_in_upsert_option":{description:"client container - Missing table in upsert option",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_table_in_upsert_option":{description:"client container - Invalid table in upsert option",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_column_in_upsert_option":{description:"client container - Missing column in upsert option",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_column_in_upsert_option":{description:"client container - Invalid column in upsert option",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_composable_container_options":{description:"client container - Missing composable container options",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_composable_container_options":{description:"client container - Invalid composable container options",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_composable_layout_key":{description:"client container - Missing composable layout key",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_composable_layout_type":{description:"client container - Invalid composable layout type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_composable_layout_array":{description:"client container - Empty composable layout array",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.negative_values_composable_layout":{description:"client container - Negative values in composable layout",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_input_options_format":{description:"client container - Invalid input options format",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_input_options_translation":{description:"client container - Invalid input options translation",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.records_key_missing_in_additional_fields":{description:"client container - Records key missing in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_records_in_additional_fields":{description:"client container - Invalid records in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_records_in_additional_fields":{description:"client container - Missing records in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_table_in_additional_fields":{description:"client container - Missing table in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_table_in_additional_fields":{description:"client container - Empty table in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_table_in_additional_fields":{description:"client container - Invalid table in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_fields_in_additional_fields":{description:"client container - Missing fields in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_fields_in_additional_fields":{description:"client container - Empty fields in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_fields_in_additional_fields":{description:"client container - Invalid fields in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.get_bearer_token_missing":{description:"client container - Get bearer token missing",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:composable_container_options_missing":{description:"client container - Composable container options missing",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:composable_container_options_invalid":{description:"client container - Composable container options invalid",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.collect_operation_failed":{description:"client container - Collect operation failed",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:dynamic_element_form.unsupported_component_type":{description:"client container - Unsupported component type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:dynamic_element_form.missing_config":{description:"client container - Dynamic element form missing config",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:dynamic_element_form.not_mounted":{description:"client container - Dynamic element form not mounted",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:dynamic_element_form.form_invalid":{description:"client container - Dynamic element form is invalid",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_button.no_instrument_selected":{description:"client container - Dynamic element payment button can only support payout workflows",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:create_stored_instrument.invalid_element_type":{description:"client container - Invalid element type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:api:payout_no_instrument_selected":{description:"client container - No instrument selected for payout",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"}};var n=(e=>(e.ERROR="payrails:error",e.INFO="payrails:info",e.DEBUG="payrails:debug",e.WARN="payrails:warn",e))(n||{});class s extends Error{constructor(e,t){var n;const{description:o,docUrl:r,cause:a}=null!=t?t:{},{description:l,docUrl:d}=i[e]||{},c=null!=(n=null!=o?o:l)?n:"An unknown error occurred",u=null!=r?r:d;super(c),this.name=e,this.docUrl=u,this.cause=a,this.message=c,Error.captureStackTrace&&Error.captureStackTrace(this,s)}toJSON(){return{name:this.name,message:this.message,docUrl:this.docUrl,stack:this.stack,cause:this.cause}}}e.ERROR_CODES=t,e.PAYRAILS_OBSERVABILITY_EVENTS=n,e.PayrailsError=s}(s);var o={};!function(e){var t=Object.defineProperty,i=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,o=(e,i,n)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n,r=(e,t)=>{for(var r in t||(t={}))n.call(t,r)&&o(e,r,t[r]);if(i)for(var r of i(t))s.call(t,r)&&o(e,r,t[r]);return e};Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var a=(e=>(e.PAYRAILS_CLIENT_CONFIG_MALFORMED="payrails:client:init.config_malformed",e.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT="payrails:client:collectContainer.unmountable",e.PAYRAILS_CLIENT_UI_ELEMENT_MISSING="payrails:client:mount.ui_element_missing",e.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING="payrails:client:mount.parent_element_missing",e.PAYRAILS_CLIENT_SUBELEMENTS_RENDER_ERROR="payrails:client:mount.subelements_render_error",e.PAYRAILS_CLIENT_CARD_FORM_MISSING="payrails:client:pay.card_form_missing",e.PAYRAILS_CLIENT_GPAY_LOADING_ERROR="payrails:client:mount.gpay_loading_error",e.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING="payrails:client:init.gpay_config_missing",e.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR="payrails:client:mount.applepay_loading_error",e.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING="payrails:client:init.applepay_config_missing",e.PAYRAILS_CLIENT_APPLEPAY_START_PAYMENT_SESSION_ERROR="payrails:client:init.applepay_start_payment_session_error",e.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR="payrails:client:init.paypal_loading_error",e.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING="payrails:client:init.paypal_config_missing",e.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION="payrails:client:init.paypal_order_creation",e.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT="payrails:client:mount.paypal_button_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR="payrails:client:payment_executor.pay_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAYOUT_ERROR="payrails:client:payment_executor.payout_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR="payrails:client:payment_executor.3ds_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR="payrails:client:payment_executor.confirm_error",e.PAYRAILS_API_UNAUTHORIZED="payrails:api:unauthorized",e.PAYRAILS_API_TOO_MANY_REQUESTS="payrails:api:too_many_requests",e.PAYRAILS_API_UNSUCCESSFUL="payrails:api:unsuccessful",e.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED="payrails:api:authorization_not_requested",e.PAYRAILS_API_AUTHENTICATION_ERROR="payrails:api:request_authentication_error",e.PAYRAILS_API_AUTHORIZATION_ERROR="payrails:api:request_authorization_error",e.PAYRAILS_API_PAYOUT_ERROR="payrails:api:request_payout_error",e.PAYRAILS_CLIENT_API_URL_NOT_FOUND="payrails:client:api_url_not_found",e.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND="payrails:client:workflow_execution_not_found",e.PAYRAILS_CARD_FORM_CREATION_FAILED="payrails:card_form:iframe_creation_failed",e.PAYRAILS_CARD_FORM_IFRAME_URL_MISSING="payrails:card_form:iframe_url_missing",e.PAYRAILS_CLIENT_UNKNOWN_ERROR="payrails:client:unknown",e.PAYRAILS_API_UNKNOWN_ERROR="payrails:api:unknown",e.PAYRAILS_CLIENT_SESSION_REFRESH_FAILED="payrails:client:session_refresh_failed",e.PAYRAILS_CLIENT_CALLBACK_FAILED="payrails:client:callback_failed",e.PAYRAILS_API_BIN_LOOKUP_FAILED="payrails:api:bin_lookup_failed",e.PAYRAILS_CARD_FORM_ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE="payrails.card_form.element_not_mounted_in_element_match_rule",e.PAYRAILS_CARD_FORM_REQUIRED_PARAMS_NOT_PROVIDED="payrails.card_form.required_params_not_provided",e.PAYRAILS_CARD_FORM_CLIENT_CONNECTION="payrails.card_form.client_connection",e.PAYRAILS_CARD_FORM_IFRAME_NOT_FOUND="payrails.card_form.iframe_not_found",e.PAYRAILS_CARD_FORM_IFRAME_LOADING_ERROR="payrails.card_form.iframe_loading_error",e.PAYRAILS_CARD_FORM_CSP_ERROR="payrails.card_form.iframe_csp_error",e.PAYRAILS_CARD_FORM_COMPLETE_AND_VALID_INPUTS="payrails.card_form.complete_and_valid_inputs",e.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED="payrails.card_form.collect_element_not_mounted",e.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK="payrails:client:generic_redirect.missing.redirect_link",e.PAYRAILS_CLIENT_COLLECT_CREATION_FAILED="payrails:client:collect_container.creation.failed",e.PAYRAILS_CLIENT_COLLECT_EMPTY_CONTAINER_TYPE="payrails:client:collect_container.empty_container_type",e.PAYRAILS_CLIENT_COLLECT_INVALID_CONTAINER_TYPE="payrails:client:collect_container.invalid_container_type",e.PAYRAILS_CLIENT_COLLECT_OPERATION_FAILED="payrails:client:collect_container.collect_operation_failed",e.PAYRAILS_CLIENT_VAULT_CONNECTION_ERROR="payrails:client:vault.connection_error",e.PAYRAILS_CLIENT_VAULT_NETWORK_ERROR="payrails:client:vault.network.error",e.PAYRAILS_CLIENT_COLLECT_UNIQUE_ELEMENT_NAME="payrails:client:collect_container.unique_element_name",e.PAYRAILS_CLIENT_COLLECT_INVALID_TOKENS="payrails:client:collect_container.invalid_tokens",e.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_IN_MOUNT="payrails:client:collect_container.empty_element",e.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_LISTENER="payrails:client:collect_container.invalid_event_listener",e.PAYRAILS_CLIENT_COLLECT_MISSING_HANDLER_IN_EVENT_LISTENER="payrails:client:collect_container.missing_event_handler",e.PAYRAILS_CLIENT_COLLECT_INVALID_HANDLER_IN_EVENT_LISTENER="payrails:client:collect_container.invalid_event_handler",e.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_TYPE="payrails:client:collect_container.invalid_event_type",e.PAYRAILS_CLIENT_COLLECT_TABLE_NAME_MISSING="payrails:client:collect_container.table_name_missing",e.PAYRAILS_CLIENT_COLLECT_EMPTY_TABLE="payrails:client:collect_container.empty_table",e.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_NAME="payrails:client:collect_container.invalid_table_name",e.PAYRAILS_CLIENT_COLLECT_MISSING_COLUMN="payrails:client:collect_container.missing_column",e.PAYRAILS_CLIENT_COLLECT_EMPTY_COLUMN="payrails:client:collect_container.empty_column",e.PAYRAILS_CLIENT_COLLECT_INVALID_COLUMN="payrails:client:collect_container.invalid_column",e.PAYRAILS_CLIENT_COLLECT_EMPTY_SKYFLOW_ID="payrails:client:collect_container.empty_skyflow_id",e.PAYRAILS_CLIENT_COLLECT_INVALID_SKYFLOW_ID="payrails:client:collect_container.invalid_skyflow_id",e.PAYRAILS_CLIENT_COLLECT_MISMATCH_ELEMENT_COUNT_LAYOUT_SUM="payrails:client:collect_container.mismatch_element_count_layout_sum",e.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_SELECTOR="payrails:client:collect_container.invalid_element_selector",e.PAYRAILS_CLIENT_COLLECT_DUPLICATE_ELEMENT="payrails:client:collect_container.duplicate_element",e.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_TYPE="payrails:client:collect_container.invalid_element_type",e.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATIONS_TYPE="payrails:client:collect_container.invalid_validations_type",e.PAYRAILS_CLIENT_COLLECT_MISSING_VALIDATION_RULE_TYPE="payrails:client:collect_container.missing_validation_rule_type",e.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATION_RULE_TYPE="payrails:client:collect_container.invalid_validation_rule_type",e.PAYRAILS_CLIENT_COLLECT_MISSING_VALIDATION_RULE_PARAMS="payrails:client:collect_container.missing_validation_rule_params",e.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATION_RULE_PARAMS="payrails:client:collect_container.invalid_validation_rule_params",e.PAYRAILS_CLIENT_COLLECT_MISSING_REGEX_IN_REGEX_MATCH_RULE="payrails:client:collect_container.missing_regex_in_regex_match_rule",e.PAYRAILS_CLIENT_COLLECT_MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE="payrails:client:collect_container.missing_min_and_max_in_length_match_rule",e.PAYRAILS_CLIENT_COLLECT_MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE="payrails:client:collect_container.missing_element_in_element_match_rule",e.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE="payrails:client:collect_container.invalid_element_in_element_match_rule",e.PAYRAILS_CLIENT_COLLECT_INVALID_REGEX_IN_REGEX_MATCH_RULE="payrails:client:collect_container.invalid_regex_in_regex_match_rule",e.PAYRAILS_CLIENT_COLLECT_INVALID_BOOLEAN_OPTIONS="payrails:client:collect_container.invalid_boolean_options",e.PAYRAILS_CLIENT_COLLECT_MISSING_ELEMENT_TYPE="payrails:client:collect_container.missing_element_type",e.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_TYPE="payrails:client:collect_container.empty_element_type",e.PAYRAILS_CLIENT_COLLECT_INVALID_UPSERT_OPTION_TYPE="payrails:client:collect_container.invalid_upsert_option_type",e.PAYRAILS_CLIENT_COLLECT_EMPTY_UPSERT_OPTIONS_ARRAY="payrails:client:collect_container.empty_upsert_options_array",e.PAYRAILS_CLIENT_COLLECT_INVALID_UPSERT_OPTION_OBJECT_TYPE="payrails:client:collect_container.invalid_upsert_option_object_type",e.PAYRAILS_CLIENT_COLLECT_MISSING_TABLE_IN_UPSERT_OPTION="payrails:client:collect_container.missing_table_in_upsert_option",e.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_IN_UPSERT_OPTION="payrails:client:collect_container.invalid_table_in_upsert_option",e.PAYRAILS_CLIENT_COLLECT_MISSING_COLUMN_IN_UPSERT_OPTION="payrails:client:collect_container.missing_column_in_upsert_option",e.PAYRAILS_CLIENT_COLLECT_INVALID_COLUMN_IN_UPSERT_OPTION="payrails:client:collect_container.invalid_column_in_upsert_option",e.PAYRAILS_CLIENT_COLLECT_MISSING_COMPOSABLE_CONTAINER_OPTIONS="payrails:client:collect_container.missing_composable_container_options",e.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_CONTAINER_OPTIONS="payrails:client:collect_container.invalid_composable_container_options",e.PAYRAILS_CLIENT_COLLECT_MISSING_COMPOSABLE_LAYOUT_KEY="payrails:client:collect_container.missing_composable_layout_key",e.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_LAYOUT_TYPE="payrails:client:collect_container.invalid_composable_layout_type",e.PAYRAILS_CLIENT_COLLECT_EMPTY_COMPOSABLE_LAYOUT_ARRAY="payrails:client:collect_container.empty_composable_layout_array",e.PAYRAILS_CLIENT_COLLECT_NEGATIVE_VALUES_COMPOSABLE_LAYOUT="payrails:client:collect_container.negative_values_composable_layout",e.PAYRAILS_CLIENT_COLLECT_INVALID_INPUT_OPTIONS_FORMAT="payrails:client:collect_container.invalid_input_options_format",e.PAYRAILS_CLIENT_COLLECT_INVALID_INPUT_OPTIONS_TRANSLATION="payrails:client:collect_container.invalid_input_options_translation",e.PAYRAILS_CLIENT_COLLECT_RECORDS_KEY_MISSING_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.records_key_missing_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_INVALID_RECORDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.invalid_records_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_MISSING_RECORDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.missing_records_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_MISSING_TABLE_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.missing_table_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_EMPTY_TABLE_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.empty_table_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.invalid_table_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_MISSING_FIELDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.missing_fields_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_EMPTY_FIELDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.empty_fields_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_INVALID_FIELDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.invalid_fields_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_GET_BEARER_TOKEN_MISSING="payrails:client:collect_container.get_bearer_token_missing",e.PAYRAILS_CLIENT_COMPOSABLE_CONTAINER_OPTIONS_MISSING="payrails:client:composable_container_options_missing",e.PAYRAILS_CLIENT_COMPOSABLE_CONTAINER_OPTIONS_INVALID="payrails:client:composable_container_options_invalid",e.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_UNSUPPORTED_COMPONENT_TYPE="payrails:client:dynamic_element_form.unsupported_component_type",e.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_MISSING_CONFIG="payrails:client:dynamic_element_form.missing_config",e.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_NOT_MOUNTED="payrails:client:dynamic_element_form.not_mounted",e.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_FORM_INVALID="payrails:client:dynamic_element_form.form_invalid",e.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_PAYMENT_BUTTON_MISSING_WORKFLOW_CODE="payrails:client:payment_button.no_instrument_selected",e.PAYRAILS_CLIENT_CREATE_STORED_INSTRUMENT_INVALID_ELEMENT_TYPE="payrails:client:create_stored_instrument.invalid_element_type",e.PAYRAILS_CLIENT_API_PAYOUT_NO_INSTRUMENT_SELECTED="payrails:client:api:payout_no_instrument_selected",e))(a||{}),l=(e=>(e.ERROR="payrails:error",e.INFO="payrails:info",e.DEBUG="payrails:debug",e.WARN="payrails:warn",e))(l||{});class d{log(e,t){console.group(`%c[${e}] : ${t.mssg}`,function(e){switch(e){case"error":return"color:red";case"info":return"color:blue";case"warn":return"color:orange";default:return"color:black"}}(e)),console.log(t.error),console.log("metadata",t.withMetada),console.log("extra",t.extra),console.groupEnd()}}function c(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var u,p={},_={};var h,E={};var m,v={};var y,I={};var f,A={};var L,O={};var g,T={};var C,R={};var N,S={};var P,b={};var D,M,w,k,Y={},U={};function x(){if(D)return U;D=1,Object.defineProperty(U,"__esModule",{value:!0}),U.Framebus=void 0;var e=$(),t="undefined"!=typeof window&&window.Promise,i=function(){function i(e){void 0===e&&(e={}),this.origin=e.origin||"*",this.channel=e.channel||"",this.verifyDomain=e.verifyDomain,this.targetFrames=e.targetFrames||[],this.limitBroadcastToFramesArray=Boolean(e.targetFrames),this.isDestroyed=!1,this.listeners=[],this.hasAdditionalChecksForOnListeners=Boolean(this.verifyDomain||this.limitBroadcastToFramesArray)}return i.setPromise=function(e){i.Promise=e},i.target=function(e){return new i(e)},i.prototype.addTargetFrame=function(e){this.limitBroadcastToFramesArray&&this.targetFrames.push(e)},i.prototype.include=function(t){return null!=t&&(null!=t.Window&&(t.constructor===t.Window&&(e.childWindows.push(t),!0)))},i.prototype.target=function(e){return i.target(e)},i.prototype.emit=function(t,i,n){if(this.isDestroyed)return!1;var s=this.origin;if(t=this.namespaceEvent(t),(0,e.isntString)(t))return!1;if((0,e.isntString)(s))return!1;"function"==typeof i&&(n=i,i=void 0);var o=(0,e.packagePayload)(t,s,i,n);return!!o&&(this.limitBroadcastToFramesArray?this.targetFramesAsWindows().forEach(function(t){(0,e.sendMessage)(t,o,s)}):(0,e.broadcast)(o,{origin:s,frame:window.top||window.self}),!0)},i.prototype.emitAsPromise=function(e,t){var n=this;return new i.Promise(function(i,s){n.emit(e,t,function(e){i(e)})||s(new Error('Listener not added for "'.concat(e,'"')))})},i.prototype.on=function(t,i){if(this.isDestroyed)return!1;var n=this,s=this.origin,o=i;return t=this.namespaceEvent(t),!(0,e.subscriptionArgsInvalid)(t,o,s)&&(this.hasAdditionalChecksForOnListeners&&(o=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];n.passesVerifyDomainCheck(this&&this.origin)&&n.hasMatchingTargetFrame(this&&this.source)&&i.apply(void 0,e)}),this.listeners.push({eventName:t,handler:o,originalHandler:i}),e.subscribers[s]=e.subscribers[s]||{},e.subscribers[s][t]=e.subscribers[s][t]||[],e.subscribers[s][t].push(o),!0)},i.prototype.off=function(t,i){var n=i;if(this.isDestroyed)return!1;if(this.verifyDomain)for(var s=0;s<this.listeners.length;s++){var o=this.listeners[s];o.originalHandler===i&&(n=o.handler)}t=this.namespaceEvent(t);var r=this.origin;if((0,e.subscriptionArgsInvalid)(t,n,r))return!1;var a=e.subscribers[r]&&e.subscribers[r][t];if(!a)return!1;for(s=0;s<a.length;s++)if(a[s]===n)return a.splice(s,1),!0;return!1},i.prototype.teardown=function(){if(!this.isDestroyed){this.isDestroyed=!0;for(var e=0;e<this.listeners.length;e++){var t=this.listeners[e];this.off(t.eventName,t.handler)}this.listeners.length=0}},i.prototype.passesVerifyDomainCheck=function(e){return!this.verifyDomain||this.checkOrigin(e)},i.prototype.targetFramesAsWindows=function(){return this.limitBroadcastToFramesArray?this.targetFrames.map(function(e){return e instanceof HTMLIFrameElement?e.contentWindow:e}).filter(function(e){return e}):[]},i.prototype.hasMatchingTargetFrame=function(e){if(!this.limitBroadcastToFramesArray)return!0;var t=this.targetFramesAsWindows().find(function(t){return t===e});return Boolean(t)},i.prototype.checkOrigin=function(e){var t,i=document.createElement("a");return i.href=location.href,t="https:"===i.protocol?i.host.replace(/:443$/,""):"http:"===i.protocol?i.host.replace(/:80$/,""):i.host,i.protocol+"//"+t===e||(!this.verifyDomain||this.verifyDomain(e))},i.prototype.namespaceEvent=function(e){return this.channel?"".concat(this.channel,":").concat(e):e},i.Promise=t,i}();return U.Framebus=i,U}function F(){if(k)return Y;k=1;var e=Y&&Y.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Y,"__esModule",{value:!0}),Y.subscribeReplier=void 0;var t=x(),i=e((w||(w=1,M=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}),M));return Y.subscribeReplier=function(e,n){var s=(0,i.default)();return t.Framebus.target({origin:n}).on(s,function i(o,r){e(o,r),t.Framebus.target({origin:n}).off(s,i)}),s},Y}var j,B={};var V,G={};var X,z,H,q,W={};function $(){return z||(z=1,e=p,t=p&&p.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,s)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),i=p&&p.__exportStar||function(e,i){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(i,n)||t(i,e,n)},Object.defineProperty(e,"__esModule",{value:!0}),i(function(){if(u)return _;u=1,Object.defineProperty(_,"__esModule",{value:!0}),_.detach=_.attach=void 0;var e=$(),t=!1;return _.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},_.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},_}(),e),i(function(){if(h)return E;h=1,Object.defineProperty(E,"__esModule",{value:!0}),E.broadcastToChildWindows=void 0;var e=$();return E.broadcastToChildWindows=function(t,i,n){for(var s=e.childWindows.length-1;s>=0;s--){var o=e.childWindows[s];o.closed?e.childWindows.splice(s,1):n!==o&&(0,e.broadcast)(t,{origin:i,frame:o.top})}},E}(),e),i(function(){if(m)return v;m=1,Object.defineProperty(v,"__esModule",{value:!0}),v.broadcast=void 0;var e=$();return v.broadcast=function t(i,n){var s,o=0,r=n.origin,a=n.frame;try{for(a.postMessage(i,r),(0,e.hasOpener)(a)&&a.opener.top!==window.top&&t(i,{origin:r,frame:a.opener.top});s=a.frames[o];)t(i,{origin:r,frame:s}),o++}catch(e){}},v}(),e),i((y||(y=1,Object.defineProperty(I,"__esModule",{value:!0}),I.subscribers=I.childWindows=I.prefix=void 0,I.prefix="/*framebus*/",I.childWindows=[],I.subscribers={}),I),e),i(function(){if(f)return A;f=1,Object.defineProperty(A,"__esModule",{value:!0}),A.dispatch=void 0;var e=$();return A.dispatch=function(t,i,n,s,o){if(e.subscribers[t]&&e.subscribers[t][i]){var r=[];n&&r.push(n),s&&r.push(s);for(var a=0;a<e.subscribers[t][i].length;a++)e.subscribers[t][i][a].apply(o,r)}},A}(),e),i((L||(L=1,Object.defineProperty(O,"__esModule",{value:!0}),O.hasOpener=void 0,O.hasOpener=function(e){return e.top===e&&null!=e.opener&&e.opener!==e&&!0!==e.opener.closed}),O),e),i((g||(g=1,Object.defineProperty(T,"__esModule",{value:!0}),T.isntString=void 0,T.isntString=function(e){return"string"!=typeof e}),T),e),i(function(){if(C)return R;C=1,Object.defineProperty(R,"__esModule",{value:!0}),R.onMessage=void 0;var e=$();return R.onMessage=function(t){if(!(0,e.isntString)(t.data)){var i=(0,e.unpackPayload)(t);if(i){var n=i.eventData,s=i.reply;(0,e.dispatch)("*",i.event,n,s,t),(0,e.dispatch)(t.origin,i.event,n,s,t),(0,e.broadcastToChildWindows)(t.data,i.origin,t.source)}}},R}(),e),i(function(){if(N)return S;N=1,Object.defineProperty(S,"__esModule",{value:!0}),S.packagePayload=void 0;var e=$();return S.packagePayload=function(t,i,n,s){var o,r={event:t,origin:i};"function"==typeof s&&(r.reply=(0,e.subscribeReplier)(s,i)),r.eventData=n;try{o=e.prefix+JSON.stringify(r)}catch(e){throw new Error("Could not stringify event: ".concat(e.message))}return o},S}(),e),i((P||(P=1,Object.defineProperty(b,"__esModule",{value:!0}),b.sendMessage=void 0,b.sendMessage=function(e,t,i){try{e.postMessage(t,i)}catch(e){}}),b),e),i(F(),e),i(function(){if(j)return B;j=1,Object.defineProperty(B,"__esModule",{value:!0}),B.subscriptionArgsInvalid=void 0;var e=$();return B.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},B}(),e),i((V||(V=1,Object.defineProperty(G,"__esModule",{value:!0})),G),e),i(function(){if(X)return W;X=1,Object.defineProperty(W,"__esModule",{value:!0}),W.unpackPayload=void 0;var e=$();return W.unpackPayload=function(t){var i;if(t.data.slice(0,e.prefix.length)!==e.prefix)return!1;try{i=JSON.parse(t.data.slice(e.prefix.length))}catch(e){return!1}if(i.reply){var n=t.origin,s=t.source,o=i.reply;i.reply=function(t){if(s){var i=(0,e.packagePayload)(o,n,t);i&&s.postMessage(i,n)}}}return i},W}(),e)),p;var e,t,i}const K=c(function(){if(q)return H;q=1;var e=$(),t=x();return(0,e.attach)(),H=t.Framebus}());class Z{constructor(e){this.origin=null,this.listeners=[],this.bus=new K(e)}static getInstance(){return Z.instance||(Z.instance=new Z),Z.instance}on(e,t){return this.bus.on(e,t)}off(e,t){return this.bus.off(e,t)}emit(e,t,i=void 0){return this.bus.emit(e,t,i)}target(e){return this.bus.target(e)}}class J{constructor(){this.bus=Z.getInstance()}log(e,t){this.bus.emit(l.ERROR,{level:e,event:t})}}var Q,ee;const te=c(function(){if(ee)return Q;ee=1;var e=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var i=Object.prototype.toString.call(e);return"[object RegExp]"===i||"[object Date]"===i||function(e){return e.$$typeof===t}(e)}(e)},t="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function i(e,t){return!1!==t.clone&&t.isMergeableObject(e)?a((i=e,Array.isArray(i)?[]:{}),e,t):e;var i}function n(e,t,n){return e.concat(t).map(function(e){return i(e,n)})}function s(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}(e))}function o(e,t){try{return t in e}catch(e){return!1}}function r(e,t,n){var r={};return n.isMergeableObject(e)&&s(e).forEach(function(t){r[t]=i(e[t],n)}),s(t).forEach(function(s){(function(e,t){return o(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,s)||(o(e,s)&&n.isMergeableObject(t[s])?r[s]=function(e,t){if(!t.customMerge)return a;var i=t.customMerge(e);return"function"==typeof i?i:a}(s,n)(e[s],t[s],n):r[s]=i(t[s],n))}),r}function a(t,s,o){(o=o||{}).arrayMerge=o.arrayMerge||n,o.isMergeableObject=o.isMergeableObject||e,o.cloneUnlessOtherwiseSpecified=i;var a=Array.isArray(s);return a===Array.isArray(t)?a?o.arrayMerge(t,s,o):r(t,s,o):i(s,o)}return a.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,i){return a(e,i,t)},{})},Q=a}());class ie{constructor(){this.state={}}static getInstance(){return ie.instance||(ie.instance=new ie),ie.instance}getState(e){return this.state[e]}setState(e){this.state=te(this.state,e)}}const ne=ie.getInstance(),se=()=>window&&window.navigator,oe=()=>window&&window.screen,re=()=>({resolution:`${oe().width}x${oe().height}`,user_agent:se().userAgent,language:se().language}),ae=[a.PAYRAILS_API_AUTHORIZATION_ERROR,a.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR,a.PAYRAILS_API_UNSUCCESSFUL];class le{constructor(e){this.adapter=[new J],this.enabled=e.enabled||!0,this.initGlobalState(e),e.logLevel=e.logLevel||"error","debug"===e.logLevel&&this.addAdapter(new d)}static init(e){le.instance=new le(e)}static getLogger(){return le.instance}initGlobalState(e){ne.setState({payrails:e.payrails,sdk:e.sdk})}static setState(e){ne.setState(e)}log(e,t,i){var n;this.enabled&&-1===ae.indexOf(null==(n=null==i?void 0:i.error)?void 0:n.name)&&this.adapter.forEach(n=>{n.log(e,{mssg:t,error:null==i?void 0:i.error,withMetada:r(r({},this.constructMetadata()),null==i?void 0:i.withMetada),extra:null==i?void 0:i.extra})})}constructMetadata(){return{device:re(),payrails:ne.getState("payrails"),sdk:ne.getState("sdk")}}addAdapter(e){this.adapter.push(e)}static log(e,t){this.getLogger().log("info",e,t)}static debug(e,t){this.getLogger().log("debug",e,t)}static info(e,t){this.getLogger().log("info",e,t)}static warn(e,t){this.getLogger().log("warning",e,t)}static error(e,t){this.getLogger().log("error",e,t)}static exception(e,t){this.error(e,t)}}e.PayrailsLogger=le,e.getDeviceInfo=re}(o);for(var r,a=[],l=0;l<256;++l)a.push((l+256).toString(16).slice(1));var d=new Uint8Array(16);function c(){if(!r&&!(r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return r(d)}var u={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function p(e,t,i){if(u.randomUUID&&!t&&!e)return u.randomUUID();var n=(e=e||{}).random||(e.rng||c)();return n[6]=15&n[6]|64,n[8]=63&n[8]|128,function(e,t=0){return(a[e[t+0]]+a[e[t+1]]+a[e[t+2]]+a[e[t+3]]+"-"+a[e[t+4]]+a[e[t+5]]+"-"+a[e[t+6]]+a[e[t+7]]+"-"+a[e[t+8]]+a[e[t+9]]+"-"+a[e[t+10]]+a[e[t+11]]+a[e[t+12]]+a[e[t+13]]+a[e[t+14]]+a[e[t+15]]).toLowerCase()}(n)}var _;!function(e){e.GET="GET",e.POST="POST",e.DELETE="DELETE",e.PATCH="PATCH"}(_||(_={}));const h=e=>t(void 0,[e],void 0,function*({url:e,method:t=_.GET,token:i="",body:n}){const s={method:t,headers:Object.assign(Object.assign(Object.assign({},f()),I(i)),A())};t!==_.POST&&t!==_.PATCH||(s.body=JSON.stringify(n||{}));const o=yield fetch(e,s);if([401,403].includes(o.status))throw new E(e,t);if(429===o.status)throw new v(e,t);if(!o.ok)throw new m(e,t);const r=yield o.json();return{ok:o.ok,req:Object.assign({url:e},s),res:r}});class E extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_UNAUTHORIZED,{description:`[${t}] ${e} unauthorized`})}}let m=class extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{description:`[${t}] ${e} unsuccessful`})}},v=class extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} too many requests`})}};class y extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} max poll attempts exceeded.`})}}const I=e=>({authorization:`Bearer ${e}`}),f=()=>({"x-idempotency-key":p()}),A=()=>{const e={version:"5.37.7",type:"web-sdk"};return{"x-client-version":e.version,"x-client-type":e.type}};var L={};!function(e){function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var i,n={},s={};var o,r={};var a,l={};var d,c={};var u,p={};var _,h={};var E,m={};var v,y={};var I,f={};var A,L={};var O,g,T,C,R={},N={};function S(){if(O)return N;O=1,Object.defineProperty(N,"__esModule",{value:!0}),N.Framebus=void 0;var e=j(),t="undefined"!=typeof window&&window.Promise,i=function(){function i(e){void 0===e&&(e={}),this.origin=e.origin||"*",this.channel=e.channel||"",this.verifyDomain=e.verifyDomain,this.targetFrames=e.targetFrames||[],this.limitBroadcastToFramesArray=Boolean(e.targetFrames),this.isDestroyed=!1,this.listeners=[],this.hasAdditionalChecksForOnListeners=Boolean(this.verifyDomain||this.limitBroadcastToFramesArray)}return i.setPromise=function(e){i.Promise=e},i.target=function(e){return new i(e)},i.prototype.addTargetFrame=function(e){this.limitBroadcastToFramesArray&&this.targetFrames.push(e)},i.prototype.include=function(t){return null!=t&&(null!=t.Window&&(t.constructor===t.Window&&(e.childWindows.push(t),!0)))},i.prototype.target=function(e){return i.target(e)},i.prototype.emit=function(t,i,n){if(this.isDestroyed)return!1;var s=this.origin;if(t=this.namespaceEvent(t),(0,e.isntString)(t))return!1;if((0,e.isntString)(s))return!1;"function"==typeof i&&(n=i,i=void 0);var o=(0,e.packagePayload)(t,s,i,n);return!!o&&(this.limitBroadcastToFramesArray?this.targetFramesAsWindows().forEach(function(t){(0,e.sendMessage)(t,o,s)}):(0,e.broadcast)(o,{origin:s,frame:window.top||window.self}),!0)},i.prototype.emitAsPromise=function(e,t){var n=this;return new i.Promise(function(i,s){n.emit(e,t,function(e){i(e)})||s(new Error('Listener not added for "'.concat(e,'"')))})},i.prototype.on=function(t,i){if(this.isDestroyed)return!1;var n=this,s=this.origin,o=i;return t=this.namespaceEvent(t),!(0,e.subscriptionArgsInvalid)(t,o,s)&&(this.hasAdditionalChecksForOnListeners&&(o=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];n.passesVerifyDomainCheck(this&&this.origin)&&n.hasMatchingTargetFrame(this&&this.source)&&i.apply(void 0,e)}),this.listeners.push({eventName:t,handler:o,originalHandler:i}),e.subscribers[s]=e.subscribers[s]||{},e.subscribers[s][t]=e.subscribers[s][t]||[],e.subscribers[s][t].push(o),!0)},i.prototype.off=function(t,i){var n=i;if(this.isDestroyed)return!1;if(this.verifyDomain)for(var s=0;s<this.listeners.length;s++){var o=this.listeners[s];o.originalHandler===i&&(n=o.handler)}t=this.namespaceEvent(t);var r=this.origin;if((0,e.subscriptionArgsInvalid)(t,n,r))return!1;var a=e.subscribers[r]&&e.subscribers[r][t];if(!a)return!1;for(s=0;s<a.length;s++)if(a[s]===n)return a.splice(s,1),!0;return!1},i.prototype.teardown=function(){if(!this.isDestroyed){this.isDestroyed=!0;for(var e=0;e<this.listeners.length;e++){var t=this.listeners[e];this.off(t.eventName,t.handler)}this.listeners.length=0}},i.prototype.passesVerifyDomainCheck=function(e){return!this.verifyDomain||this.checkOrigin(e)},i.prototype.targetFramesAsWindows=function(){return this.limitBroadcastToFramesArray?this.targetFrames.map(function(e){return e instanceof HTMLIFrameElement?e.contentWindow:e}).filter(function(e){return e}):[]},i.prototype.hasMatchingTargetFrame=function(e){if(!this.limitBroadcastToFramesArray)return!0;var t=this.targetFramesAsWindows().find(function(t){return t===e});return Boolean(t)},i.prototype.checkOrigin=function(e){var t,i=document.createElement("a");return i.href=location.href,t="https:"===i.protocol?i.host.replace(/:443$/,""):"http:"===i.protocol?i.host.replace(/:80$/,""):i.host,i.protocol+"//"+t===e||(!this.verifyDomain||this.verifyDomain(e))},i.prototype.namespaceEvent=function(e){return this.channel?"".concat(this.channel,":").concat(e):e},i.Promise=t,i}();return N.Framebus=i,N}function P(){if(C)return R;C=1;var e=R&&R.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(R,"__esModule",{value:!0}),R.subscribeReplier=void 0;var t=S(),i=e((T||(T=1,g=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}),g));return R.subscribeReplier=function(e,n){var s=(0,i.default)();return t.Framebus.target({origin:n}).on(s,function i(o,r){e(o,r),t.Framebus.target({origin:n}).off(s,i)}),s},R}var b,D={};var M,w={};var k,Y,U,x,F={};function j(){return Y||(Y=1,e=n,t=n&&n.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,s)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),O=n&&n.__exportStar||function(e,i){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(i,n)||t(i,e,n)},Object.defineProperty(e,"__esModule",{value:!0}),O(function(){if(i)return s;i=1,Object.defineProperty(s,"__esModule",{value:!0}),s.detach=s.attach=void 0;var e=j(),t=!1;return s.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},s.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},s}(),e),O(function(){if(o)return r;o=1,Object.defineProperty(r,"__esModule",{value:!0}),r.broadcastToChildWindows=void 0;var e=j();return r.broadcastToChildWindows=function(t,i,n){for(var s=e.childWindows.length-1;s>=0;s--){var o=e.childWindows[s];o.closed?e.childWindows.splice(s,1):n!==o&&(0,e.broadcast)(t,{origin:i,frame:o.top})}},r}(),e),O(function(){if(a)return l;a=1,Object.defineProperty(l,"__esModule",{value:!0}),l.broadcast=void 0;var e=j();return l.broadcast=function t(i,n){var s,o=0,r=n.origin,a=n.frame;try{for(a.postMessage(i,r),(0,e.hasOpener)(a)&&a.opener.top!==window.top&&t(i,{origin:r,frame:a.opener.top});s=a.frames[o];)t(i,{origin:r,frame:s}),o++}catch(e){}},l}(),e),O((d||(d=1,Object.defineProperty(c,"__esModule",{value:!0}),c.subscribers=c.childWindows=c.prefix=void 0,c.prefix="/*framebus*/",c.childWindows=[],c.subscribers={}),c),e),O(function(){if(u)return p;u=1,Object.defineProperty(p,"__esModule",{value:!0}),p.dispatch=void 0;var e=j();return p.dispatch=function(t,i,n,s,o){if(e.subscribers[t]&&e.subscribers[t][i]){var r=[];n&&r.push(n),s&&r.push(s);for(var a=0;a<e.subscribers[t][i].length;a++)e.subscribers[t][i][a].apply(o,r)}},p}(),e),O((_||(_=1,Object.defineProperty(h,"__esModule",{value:!0}),h.hasOpener=void 0,h.hasOpener=function(e){return e.top===e&&null!=e.opener&&e.opener!==e&&!0!==e.opener.closed}),h),e),O((E||(E=1,Object.defineProperty(m,"__esModule",{value:!0}),m.isntString=void 0,m.isntString=function(e){return"string"!=typeof e}),m),e),O(function(){if(v)return y;v=1,Object.defineProperty(y,"__esModule",{value:!0}),y.onMessage=void 0;var e=j();return y.onMessage=function(t){if(!(0,e.isntString)(t.data)){var i=(0,e.unpackPayload)(t);if(i){var n=i.eventData,s=i.reply;(0,e.dispatch)("*",i.event,n,s,t),(0,e.dispatch)(t.origin,i.event,n,s,t),(0,e.broadcastToChildWindows)(t.data,i.origin,t.source)}}},y}(),e),O(function(){if(I)return f;I=1,Object.defineProperty(f,"__esModule",{value:!0}),f.packagePayload=void 0;var e=j();return f.packagePayload=function(t,i,n,s){var o,r={event:t,origin:i};"function"==typeof s&&(r.reply=(0,e.subscribeReplier)(s,i)),r.eventData=n;try{o=e.prefix+JSON.stringify(r)}catch(e){throw new Error("Could not stringify event: ".concat(e.message))}return o},f}(),e),O((A||(A=1,Object.defineProperty(L,"__esModule",{value:!0}),L.sendMessage=void 0,L.sendMessage=function(e,t,i){try{e.postMessage(t,i)}catch(e){}}),L),e),O(P(),e),O(function(){if(b)return D;b=1,Object.defineProperty(D,"__esModule",{value:!0}),D.subscriptionArgsInvalid=void 0;var e=j();return D.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},D}(),e),O((M||(M=1,Object.defineProperty(w,"__esModule",{value:!0})),w),e),O(function(){if(k)return F;k=1,Object.defineProperty(F,"__esModule",{value:!0}),F.unpackPayload=void 0;var e=j();return F.unpackPayload=function(t){var i;if(t.data.slice(0,e.prefix.length)!==e.prefix)return!1;try{i=JSON.parse(t.data.slice(e.prefix.length))}catch(e){return!1}if(i.reply){var n=t.origin,s=t.source,o=i.reply;i.reply=function(t){if(s){var i=(0,e.packagePayload)(o,n,t);i&&s.postMessage(i,n)}}}return i},F}(),e)),n;var e,t,O}const B=t(function(){if(x)return U;x=1;var e=j(),t=S();return(0,e.attach)(),U=t.Framebus}());class V{constructor(e){this.origin=null,this.listeners=[],this.bus=new B(e)}static getInstance(){return V.instance||(V.instance=new V),V.instance}on(e,t){return this.bus.on(e,t)}off(e,t){return this.bus.off(e,t)}emit(e,t,i=void 0){return this.bus.emit(e,t,i)}target(e){return this.bus.target(e)}}e.IframeEventBus=V,e.getEventBus=()=>V.getInstance()}(L);const O={INITIALIZE_CLIENT:"%s1 - Initializing skyflow client.",CLIENT_INITIALIZED:"%s1 - Initialized skyflow client successfully.",CREATE_COLLECT_CONTAINER:"%s1 - Creating Collect container.",COLLECT_CONTAINER_CREATED:"%s1 - Created Collect container successfully.",VALIDATE_RECORDS:"%s1 - Validating insert records.",VALIDATE_DETOKENIZE_INPUT:"%s1 - Validating detokenize input.",VALIDATE_GET_INPUT:"%s1 - Validating get input.",VALIDATE_DELETE_INPUT:"%s1 - Validating delete input.",VALIDATE_COLLECT_RECORDS:"%s1 - Validating collect element input.",CREATED_ELEMENT:"%s1 - Created %s2 element.",ELEMENT_MOUNTED:"%s1 - %s2 Element mounted.",COLLECT_SUBMIT_SUCCESS:"%s1 - Data has been collected successfully.",INSERT_DATA_SUCCESS:"%s1 - Data has been inserted successfully.",DELETE_SUCCESS:"%s1 - Data has been deleted successfully.",BEARER_TOKEN_LISTENER:"%s1 - Get bearer token listener added.",CAPTURED_BEARER_TOKEN_EVENT:"%s1 - Captured bearer token event.",BEARER_TOKEN_RESOLVED:"%s1 - GetBearerToken promise resolved successfully.",REUSE_BEARER_TOKEN:"%s1 - Reusing the bearer token.",PUREJS_CONTROLLER_INITIALIZED:"%s1 - SkyflowController initialized.",PUREJS_LISTENER_READY:"%s1 - Purejs listener ready.",EMIT_PURE_JS_CONTROLLER:"%s1 - Emitted Skyflow controller event.",INSERT_TRIGGERED:"%s1 - Insert method triggered.",DETOKENIZE_TRIGGERED:"%s1 - Detokenize method triggered.",GET_TRIGGERED:"%s1 - Get method triggered.",GET_BY_ID_TRIGGERED:"%s1 - Get method triggered.",DELETE_TRIGGERED:"%s1 - Delete method triggered.",EMIT_PURE_JS_REQUEST:"%s1 - Emitted %s2 request.",CAPTURE_PURE_JS_REQUEST:"%s1 - Captured %s2 event.",LISTEN_PURE_JS_REQUEST:"%s1 - Listening to %s2 event.",CAPTURE_PUREJS_FRAME:"%s1 - Captured SkyflowController frame ready event.",FETCH_RECORDS_RESOLVED:"%s1 - Detokenize request is resolved.",INSERT_RECORDS_RESOLVED:"%s1 - Insert request is resolved.",GET_RESOLVED:"%s1 - Get request is resolved.",GET_BY_SKYFLOWID_RESOLVED:"%s1 - GetById request is resolved.",DELETE_RESOLVED:"%s1 - Delete request is resolved",EMIT_EVENT:"%s1 - %s2 event emitted",CAPTURE_EVENT:"%s1 - Captured event %s2",LISTEN_COLLECT_FRAME_READY:"%s1 - Listening to collect FRAME_READY event",EMIT_COLLECT_ELEMENT_FRAME_READY:"%s1 - Emitting collect element %s2 FRAME_READY event",ENTERED_COLLECT_FRAME_READY_CB:"%s1 - In IFrameForm constructor, Entered FRAME_READY callback",EXECUTE_COLLECT_ELEMENT_FRAME_READY_CB:"%s1 - In IFrameForm, executing collect element, %s2 FRAME_READY callback",CLIENT_METADATA_NOT_SET:"%s1 - Client metadata not set",EXECUTE_COLLECT_ELEMENT_INIT:"%s1 - calling Collect element init",INSIDE__COLLECT_ELEMENT_INIT:"%s1 - Inside Collect element init for %s2",CREATING_COLLECT_ELEMENT_FORM:"%s1 - Start, creating iframe form for %s2",COLLECT_FRAME_READY_CB:"%s1 - In FrameElements, executing collect element FRAME_READY cb for %s2, sending metadata",INSIDE_FRAME_ELEMENTS_CONSTRUCOTR:"%s1 - Inside FrameElements constructor",SETUP_IN_START:"%s1 - Inside FrameElements start(), calling setup",SETUP_IN_CONSTRUCTOR:"%s1 - Inside FrameElements constructor, calling setup",COLLECT_ELEMET_START:"%s1 - %s2, Collect Element start",COLLECT_CONTROLLER_START:"%s1 - %s2, Collect Controller start",EMIT_COLLECT_FRAME_CONTROLLER_EVENT:"%s1 - Emit collect FrameController FRAME_READY event",EXECUTE_COLLECT_CONTROLLER_READY_CB:"%s1 - Executing collect FrameController FRAME_READY callback, set client metadata",IFRAMEFORM_CONSTRUCTOR_FRAME_READY_LISTNER:"%s1 - In IFrameForm constructor, Adding listner for FRAME_READY event",IFRAMEFORM_CONSTRUCTOR_TOKENIZATION_LISTNER:"%s1 - In IFrameForm constructor, Adding listner for TOKENIZATION_REQUEST event",CURRENT_ENV:"%s1 - Client Env is %s2",CURRENT_LOG_LEVEL:"%s1 - Client LogLevel is %s2",VALIDATE_GET_BY_ID_INPUT:"%s1 - Validating getByID input."},g={CLIENT_CONNECTION:"Interface: collect container - client connection not established. client info has not reached iframes",INVALID_BEARER_TOKEN:"Interface: init - Invalid token is generated from getBearerToken callback",BEARER_TOKEN_REJECTED:"Interface: init - GetBearerToken promise got rejected.",VAULTID_IS_REQUIRED:"Interface: init - Invalid client credentials. vaultID is required.",EMPTY_VAULTID_IN_INIT:"Interface: init - Invalid client credentials. vaultID cannot be empty.",VAULTURL_IS_REQUIRED:"Interface: init - Invalid client credentials. vaultURL is required.",EMPTY_VAULTURL_IN_INIT:"Interface: init - Invalid client credentials. vaultURL cannot be empty.",INVALID_VAULTURL_IN_INIT:"Interface: init - Invalid client credentials. Expecting https://XYZ for vaultURL",GET_BEARER_TOKEN_IS_REQUIRED:"Interface: init - Invalid client credentials. getBearerToken is required.",EMPTY_CONTAINER_TYPE:"Interface: client {containerType} container - Invalid container type. Container object cannot be empty.",INVALID_CONTAINER_TYPE:"Interface: client {containerType} container - Invalid container type. Invalid container object.",INVALID_COLLECT_VALUE:"Invalid value",INVALID_COLLECT_VALUE_WITH_LABEL:"Invalid %s1",REQUIRED_COLLECT_VALUE:"%s1 is required",DEFAULT_REQUIRED_COLLECT_VALUE:"Field is required",RECORDS_KEY_NOT_FOUND:"Interface: client insert - records object is required.",INVALID_RECORDS_IN_INSERT:"Interface: client insert - Invalid records. records object should be an array.",EMPTY_RECORDS_IN_INSERT:"Interface: client insert - records array cannot be empty.",MISSING_TABLE_IN_INSERT:'Interface: client insert - "table" key is required in records array at index %s1',EMPTY_TABLE_IN_INSERT:"Interface: client insert - table cannot be empty in records array at index %s1",INVALID_TABLE_IN_INSERT:"Interface: client insert - table of type string is required at index %s1 in records array.",EMPTY_FIELDS_IN_INSERT:"Interface: client insert - fields cannot be empty in records array at index %s1",MISSING_FIELDS_IN_INSERT:'Interface: client insert - "fields" key is required in records array at index %s1',INVALID_FIELDS_IN_INSERT:"Interface: client insert - fields of type object is required at index %s1 in records array.",INVALID_TOKENS_IN_INSERT:"Interface: client insert - Invalid tokens in options. tokens of type boolean is required.",RECORDS_KEY_NOT_FOUND_DELETE:"Interface: client delete - records object is required.",INVALID_RECORDS_IN_DELETE:"Interface: client delete - Invalid records. records object should be an array.",EMPTY_RECORDS_IN_DELETE:"Interface: client delete - records array cannot be empty.",MISSING_TABLE_IN_DELETE:'Interface: client delete - "table" key is required in records array at index %s1',EMPTY_TABLE_IN_DELETE:"Interface: client delete - table cannot be empty in records array at index %s1",INVALID_TABLE_IN_DELETE:"Interface: client delete - table of type string is required at index %s1 in records array.",MISSING_ID_IN_DELETE:'Interface: client delete - "id" key is required in records array at index %s1',EMPTY_ID_IN_DELETE:"Interface: client delete - id cannot be empty in records array at index %s1",INVALID_ID_IN_DELETE:"Interface: client delete - id of type string is required at index %s1 in records array.",DELETE_RECORDS_REJECTED:"Interface: client delete - delete request is rejected.",INVALID_TOKENS_IN_COLLECT:"Interface: collect container - Invalid tokens. tokens of type boolean is required.",RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS:'Interface: collect container - "records" key not found in additionalFields',INVALID_RECORDS_IN_ADDITIONAL_FIELDS:"Interface: collect container - records should be an array inside additionalFields",EMPTY_RECORDS_IN_ADDITIONAL_FIELDS:"Interface: collect container - records object cannot be empty in additionalFields",MISSING_TABLE_IN_ADDITIONAL_FIELDS:'Interface: collect container - "table" key not found in additionalFields records at index %s1',INVALID_TABLE_IN_ADDITIONAL_FIELDS:"Interface: collect container - Provide valid table name in additionalFields records at index %s1",INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:"Interface: collect container - Provide valid skyflow id in additionalFields records at index %s1",MISSING_FIELDS_IN_ADDITIONAL_FIELDS:'Interface: collect container - "fields" key not found in additionalFields records at index %s1',INVALID_FIELDS_IN_ADDITIONAL_FIELDS:"Interface: collect container - Provide valid fields in additionalFields records at index %s1",RECORDS_KEY_NOT_FOUND_DETOKENIZE:"Interface: client detokenize - records object is required.",EMPTY_RECORDS_DETOKENIZE:"Interface: client detokenize - records array cannot be empty.",INVALID_RECORDS_IN_DETOKENIZE:"Interface: client detokenize - Invalid records. records object should be an array.",MISSING_TOKEN_IN_DETOKENIZE:'Interface: client detokenize - "token" key is required in records array at index %s1 ',INVALID_TOKEN_IN_DETOKENIZE:"Interface: client detokenize - Invalid token. token of type string is required at index %s1 in records array.",RECORDS_KEY_NOT_FOUND_GET:"Interface: client get - records object is required.",INVALID_RECORDS_IN_GET:"Interface: client get - Invalid records. records object should be an array.",EMPTY_RECORDS_GET:"Interface: client get - records array cannot be empty.",MISSING_IDS_IN_GET:'Interface: client get - "ids" key is required in records array at index %s1',INVALID_IDS_IN_GET:"Interface: client get - Invalid ids. ids object should be an array.",INVALID_COLUMN_VALUES_IN_GET:"Interface: client get - Invalid column values. column values object should be an array.",EMPTY_IDS_IN_GET:"Interface: client get - ids array cannot be empty at index %s1",INVALID_SKYFLOWID_TYPE_IN_GET:"Interface: client get - Invalid skyflowId in ids array at index %s1",MISSING_TABLE_IN_GET:'Interface: client get - "table" key is required in records array at index %s1',INVALID_TABLE_IN_GET:"Interface: client get - table of type string is required at index %s1 in records array.",MISSING_REDACTION_IN_GET:'Interface: client get - "redaction" key is required in records array at index %s1',INVALID_REDACTION_TYPE_IN_GET:"Interface: client get - Invalid redaction type in records array at index %s1",INVALID_TOKENS_IN_GET:"Interface: client get - Invalid tokens in options. tokens of type boolean is required.",TOKENS_GET_COLUMN_NOT_SUPPORTED:"Interface: client get - column_name or column_values cannot be used with tokens in options.",REDACTION_WITH_TOKENS_NOT_SUPPORTED:"Interface: client get - redaction cannot be used when tokens are true in options.",INVALID_REDACTION_TYPE_IN_DETOKENIZE:"Interface: client get - Invalid redaction type in records array at index %s1",EMPTY_TABLE_IN_ADDITIONAL_FIELDS:"Interface: collect container - table cannot be empty in additionalFields at index %s1",EMPTY_FIELDS_IN_ADDITIONAL_FIELDS:"Interface: collect container - fields cannot be empty in additionalFields at index %s1",EMPTY_TOKEN_IN_DETOKENIZE:"Interface: client detokenize - token cannot be empty in records array at index %s1",EMPTY_SKYFLOWID_IN_GET:"Interface: client get - id cannot be empty in records array at index %s1",EMPTY_TABLE_IN_GET:"Interface: client get - table cannot be empty in records array at index %s1",EMPTY_REDACTION_TYPE_IN_GET:"Interface: client get - redaction cannot be empty in records array at index %s1",FETCH_RECORDS_REJECTED:"Interface: client detokenize - detokenize request is rejected.",INSERT_RECORDS_REJECTED:"Interface: client insert - insert request is rejected.",GET_REJECTED:"Interface: client get - get request is rejected.",MISSING_TABLE_IN_COLLECT:'Interface: collect element - "table" key is required.',EMPTY_TABLE_IN_COLLECT:"Interface: collect element - table cannot be empty.",EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:"Interface: collect element - id cannot be empty.",INVALID_TABLE_IN_COLLECT:"Interface: collect element - Invalid table. table of type string is required",INVALID_SKYFLOWID_IN_COLLECT:"Interface: collect element - Invalid id. id of type string is required",MISSING_COLUMN_IN_COLLECT:'Interface: collect element - "column" key is required.',EMPTY_COLUMN_IN_COLLECT:"Interface: collect element - column cannot be empty.",INVALID_COLUMN_IN_COLLECT:"Interface: collect element - Invalid column. column of type string is required",UNIQUE_ELEMENT_NAME:"The element name has to unique: %s1",ELEMENTS_NOT_MOUNTED:"Interface: collect container - Elements should be mounted before invoking collect",DUPLICATE_ELEMENT:"Interface: collect container - Duplicate column %s1 found in %s2.",DUPLICATE_ELEMENT_ADDITIONAL_FIELDS:"Interface: collect container - Duplicate column %s1 found in %s2 in additional fields",MISSING_ELEMENT_TYPE:'Interface:container element with type {TYPE} - Invalid element type. "type" key is required.',EMPTY_ELEMENT_TYPE:"Interface:container element with type {TYPE} - Invalid element type. type cannot be empty.",INVALID_ELEMENT_TYPE:"Interface:container element with type {TYPE} - invalid element type. type not found",INVALID_ELEMENT_SELECTOR:"Interface: container element with type {TYPE} - Div cannot be found.",CANNOT_CHANGE_ELEMENT:"Element can't be changed.",INVALID_IFRAME:"Error occured while creating an iframe",INVALID_FIELD:"Invalid Field.",FRAME_NOT_FOUND:"Interface: collect element - %s1 frame not found:",COMPLETE_AND_VALID_INPUTS:"Interface: collect container - Provide complete and valid inputs for %s1",REQUIRED_PARAMS_NOT_PROVIDED:"Interface: collect element - Required params are not provided.",INVALID_EVENT_TYPE:"Interface: collect element - Provide a valid event type.",INVALID_EVENT_LISTENER:'Interface: "on" on CollectElement - Provide valid event listener.',MISSING_HANDLER_IN_EVENT_LISTENER:'Interface: "on" on CollectElement - Second argument is missing. handler cannot be empty.',INVALID_HANDLER_IN_EVENT_LISTENER:'Interface: "on" on CollectElement - Invalid handler. handler should be of type function.',UNKNOWN_ERROR:"Unknown Error.",NETWORK_ERROR:"A network error occurred. This could be a CORS issue or a dropped internet connection. It is not possible for us to know. Please reach out to skyflow if you see this error",CONNECTION_ERROR:"Error while initializing the connection.",ERROR_OCCURED:"Error occurred.",INVALID_VALIDATIONS_TYPE:"Interface: collect element - Invalid validations type.",MISSING_VALIDATION_RULE_TYPE:"Interface: collect element - Type is missing in validationRule at index %s1 in validations array",INVALID_VALIDATION_RULE_TYPE:"Interface: collect element - Invalid ValidationRuleType at index %s1 in validations array",MISSING_VALIDATION_RULE_PARAMS:"Interface: collect element - params are missing in validationRule at index %s1 in validations array",INVALID_VALIDATION_RULE_PARAMS:"Interface: collect element - Invalid ValidationRule params at index %s1 in validations array",MISSING_REGEX_IN_REGEX_MATCH_RULE:"Interface: collect element - Missing regex in ValidationRule params at index %s1 in validations array",INVALID_REGEX_IN_REGEX_MATCH_RULE:"Interface: collect element - Invalid regex in ValidationRule params at index %s1 in validations array",MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE:"Interface: collect element - Either min or max is required in ValidationRule params at index %s1 in validations array",MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE:"Interface: collect element - Missing element in ValidationRule params at index %s1 in validations array",INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE:"Interface: collect element - Invalid collect element in ValidationRule params at index %s1 in validations array",ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE:"Interface: collect element - collect element is not mounted in ValidationRule params at index %s1 in validations array",EMPTY_ELEMENT_IN_MOUNT:"Interface: mount element with type %s1 - Mount cannot be empty.",VALIDATION_FAILED:"Validation failed",INVALID_UPSERT_OPTION_TYPE:"Invalid upsert option, should be an array",EMPTY_UPSERT_OPTIONS_ARRAY:"upsert option cannot be an empty array, atleast one object of table and column is required.",INVALID_UPSERT_OPTION_OBJECT_TYPE:"Invalid upsert object at index %s1, an object of table and column is required.",MISSING_TABLE_IN_UPSERT_OPTION:'"table" key is required in upsert options object at index %s1',MISSING_COLUMN_IN_UPSERT_OPTION:'"column" key is required in upsert option at index %s1',INVALID_TABLE_IN_UPSERT_OPTION:"Invalid table in upsert object at index %s1, table of type non empty string is required",INVALID_COLUMN_IN_UPSERT_OPTION:"Invalid column in upsert object at index %s1, column of type non empty string is required",INVALID_RECORD_COLUMN_VALUE:"Invalid Record Column value.",MISSING_RECORD_COLUMN_VALUE:"Column Values is required when Column Name is specified.",MISSING_RECORD_COLUMN_NAME:"Column Name is required when Column Values are specified.",INVALID_RECORD_COLUMN_VALUE_TYPE:"Invalid Type of Records Column Values.",INVALID_COLUMN_VALUES_TYPE:"Invalid column values type, should be an Array.",EMPTY_RECORD_COLUMN_VALUES:"Record column values cannot be empty.",EMPTY_COLUMN_VALUE:"Column Value is empty.",MISSING_IDS_OR_COLUMN_VALUES_IN_GET:'Interface: client get - "ids" key or "columnValues" key is missing.',SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED:"ids and columnName can not be specified together.",GET_BY_SKYFLOWID_RESOLVED:"%s1 - GetById request is resolved.",RECORDS_KEY_NOT_FOUND_GETBYID:"Interface: client getById - records object is required.",INVALID_RECORDS_IN_GETBYID:"Interface: client getById - Invalid records. records object should be an array.",EMPTY_RECORDS_GETBYID:"Interface: client getById - records array cannot be empty.",MISSING_IDS_IN_GETBYID:'Interface: client getById - "ids" key is required in records array at index %s1',INVALID_IDS_IN_GETBYID:"Interface: client getById - Invalid ids. ids object should be an array.",EMPTY_IDS_IN_GETBYID:"Interface: client getById - ids array cannot be empty at index %s1",INVALID_SKYFLOWID_TYPE_IN_GETBYID:"Interface: client getById - Invalid skyflowId in ids array at index %s1",MISSING_TABLE_IN_GETBYID:'Interface: client getById - "table" key is required in records array at index %s1',INVALID_TABLE_IN_GETBYID:"Interface: client getById - table of type string is required at index %s1 in records array.",MISSING_REDACTION_IN_GETBYID:'Interface: client getById - "redaction" key is required in records array at index %s1',INVALID_REDACTION_TYPE_IN_GETBYID:"Interface: client getById - Invalid redaction type in records array at index %s1",EMPTY_SKYFLOWID_IN_GETBYID:"Interface: client getById - id cannot be empty in records array at index %s1",EMPTY_TABLE_IN_GETBYID:"Interface: client getById - table cannot be empty in records array at index %s1",EMPTY_REDACTION_TYPE_IN_GETBYID:"Interface: client getById - redaction cannot be empty in records array at index %s1",GET_BY_SKYFLOWID_REJECTED:"Interface: client getById - getById request is rejected.",MISSING_COMPOSABLE_LAYOUT_KEY:"Interface: client container - layout is required in composable container options.",EMPTY_COMPOSABLE_LAYOUT_ARRAY:"Interface: client container - layout array cannot be empty in composable container options.",INVALID_COMPOSABLE_LAYOUT_TYPE:"Interface: client container - invalid layout value, layout should be of type array of numbers in composable container options.",NEGATIVE_VALUES_COMPOSABLE_LAYOUT:"Interface: client container - layout array should only have postive numbers in composable container options.",MISMATCH_ELEMENT_COUNT_LAYOUT_SUM:"Interface: composable container mount - created elements count should be equal to sum of layout values.",MISSING_COMPOSABLE_CONTAINER_OPTIONS:"Interface: client composable container - options object is required for composable container.",INVALID_COMPOSABLE_CONTAINER_OPTIONS:"Interface: client composable container - invalid options value, should be an object type.",COMPOSABLE_CONTAINER_NOT_MOUNTED:"Interface: composable collect - container should be mounted before invoking collect.",INVALID_BOOLEAN_OPTIONS:"Interface: container create - Invaild %s1 in options, %s1 of type boolean is required.",INVALID_INPUT_OPTIONS_FORMAT:"Interface: container create - Invalid type, format must be of non-empty string type.",INVALID_INPUT_OPTIONS_TRANSLATION:"Interface: container create - Invalid type, translation must be of non-empty object type.",EMPTY_COLLECT_CUSTOM_FORMAT:"Interface: container create - %s1 cannot be empty object."},T={INVALID_EXPIRATION_DATE_FORMAT:"EXPIRATION_DATE format must be in one of %s1, the format is set to default MM/YY",INVALID_EXPIRATION_YEAR_FORMAT:"EXPIRATION_YEAR format must be in one of %s1, the format is set to default YY",UNABLE_TO_SET_VALUE_IN_PROD_ENV:"%s1 setValue() cannot invoked while in PROD env. It is Not Recommeded",UNABLE_TO_CLEAR_VALUE_IN_PROD_ENV:"%s1 clearValue() cannot invoked while in PROD env. It is Not Recommeded",COLLECT_ALT_TEXT_DEPERECATED:"altText is DEPERECATED, passing altText will not have any effect",GET_BY_ID_DEPRECATED:"getById is deprecated, use new get method",INPUT_FORMATTING_NOT_SUPPROTED:"format or translation are not supported on %s1 element type.",INVALID_INPUT_TRANSLATION:"invalid or unsupported translation provided for %s1 element type."},C="collect_controller",R="element",N="ERROR",S={CHANGE:"CHANGE",READY:"READY",FOCUS:"FOCUS",BLUR:"BLUR",ESCAPE:"ESCAPE",CLICK:"CLICK",ERROR:"ERROR",SUCCESS:"SUCCESS",SUBMIT:"SUBMIT",CREATED:"CREATED",MOUNTED:"MOUNTED",HEIGHT:"HEIGHT"},P="FRAME_READY",b="TOKENIZATION_REQUEST",D="RESET",M="INPUT_EVENT",w="DESTROY_FRAME",k="SET_VALUE",Y="SET_ATTRIBUTE",U="GET_BEARER_TOKEN",x="COLLECT_ELEMENT_SET_ERROR",F="COMPOSABLE_UPDATE_OPTIONS",j="VALIDATE_ELEMENT",B="COMPOSABLE_CONTAINER_MOUNTED",V="COLLECT_CONTAINER_MOUNTED";var G,X;!function(e){e.CVV="CVV",e.EXPIRATION_DATE="EXPIRATION_DATE",e.CARD_NUMBER="CARD_NUMBER",e.CARDHOLDER_NAME="CARDHOLDER_NAME",e.INPUT_FIELD="INPUT_FIELD",e.PIN="PIN",e.EXPIRATION_MONTH="EXPIRATION_MONTH",e.EXPIRATION_YEAR="EXPIRATION_YEAR"}(G||(G={})),function(e){e.VISA="VISA",e.MASTERCARD="MASTERCARD",e.AMEX="AMEX",e.DINERS_CLUB="DINERS_CLUB",e.DISCOVER="DISCOVER",e.JCB="JCB",e.MAESTRO="MAESTRO",e.UNIONPAY="UNIONPAY",e.HIPERCARD="HIPERCARD",e.DEFAULT="DEFAULT",e.CVV="CVV",e.EXPIRY="EXPIRY",e.ERROR="ERROR",e.UNKNOWN="UNKNOWN",e.ELO="ELO"}(X||(X={}));const z={[X.AMEX]:["XXXX XXXXXX XXXXX",{X:"[0-9]"}],[X.VISA]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[X.MASTERCARD]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[X.DISCOVER]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[X.DINERS_CLUB]:["XXXX XXXXXX XXXXXX",{X:"[0-9]"}],[X.JCB]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[X.MAESTRO]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[X.UNIONPAY]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[X.HIPERCARD]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[X.DEFAULT]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[X.UNKNOWN]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[X.ELO]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}]},H={textarea:{name:"textarea",attributes:{type:"textarea"},sensitive:!1},checkbox:{name:"checkbox",attributes:{type:"checkbox"},sensitive:!1},radio:{name:"radio",attributes:{type:"radio"},sensitive:!1},dropdown:{name:"dropdown",attributes:{type:"select"},sensitive:!1},[G.CARDHOLDER_NAME]:{name:"cardHolderName",attributes:{type:"text",autocomplete:"cc-name"},sensitive:!0,regex:/^([a-zA-Z\\ \\,\\.\\-\\']{2,})$/},[G.CARD_NUMBER]:{name:"CARD_NUMBER",attributes:{type:"text",autocomplete:"cc-number",inputmode:"numeric"},sensitive:!0,mask:z[X.DEFAULT],regex:/$|^[\s]*?([0-9]{2,6}[ -]?){3,5}[\s]*/},[G.EXPIRATION_DATE]:{name:"EXPIRATION_DATE",attributes:{type:"text",autocomplete:"cc-exp",inputmode:"numeric"},sensitive:!0},[G.EXPIRATION_MONTH]:{name:"EXPIRATION_MONTH",attributes:{maxLength:2,type:"text",inputmode:"numeric",autocomplete:"cc-exp-month"},sensitive:!0,mask:["XX",{X:"[0-9]"}]},[G.EXPIRATION_YEAR]:{name:"EXPIRATION_YEAR",attributes:{type:"text",inputmode:"numeric",autocomplete:"cc-exp-year"},sensitive:!0},[G.CVV]:{name:"CVV",attributes:{type:"text",inputmode:"numeric",maxLength:3},sensitive:!0,regex:/^$|^[0-9]{3,4}$/},[G.INPUT_FIELD]:{name:"INPUT_FIELD",sensitive:!0,attributes:{type:"text"}},[G.PIN]:{name:"PIN",attributes:{type:"text",inputmode:"numeric",maxLength:12,minLength:4},sensitive:!0,regex:/^$|^[0-9]{4,12}$/}},q="XXXX-XXXX-XXXX-XXXX",W={height:"100%",width:"100%",margin:0,padding:0,border:0,position:"absolute",top:0,left:0,"user-select":"none"},$={position:"absolute",top:0,width:0,height:0,visibility:"hidden",left:"-99999999px","user-select":"none"},K={width:"100%",height:"100%",border:"0",padding:"0",margin:"0",outline:"none"},Z={WEBPACKAUTOFILL:"-webkit-autofill",BASE:"base",FOCUS:"focus",COMPLETE:"complete",EMPTY:"empty",INVALID:"invalid",GLOBAL:"global",REQUIRED_ASTERISK:"requiredAsterisk"},J={[X.VISA]:{regex:/^4\d*/,maxCardLength:19,cardLengthRange:[13,16]},[X.MASTERCARD]:{regex:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,maxCardLength:16,cardLengthRange:[16]},[X.AMEX]:{regex:/^3[47]\d*/,maxCardLength:15,cardLengthRange:[15]},[X.DINERS_CLUB]:{regex:/^(36|38|30[0-5])\d*/,maxCardLength:16,cardLengthRange:[14,15,16,17,18,19]},[X.DISCOVER]:{regex:/^(6011|65|64[4-9]|622)\d*/,maxCardLength:16,cardLengthRange:[16,17,18,19]},[X.JCB]:{regex:/^35\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[X.HIPERCARD]:{regex:/^606282\d*/,maxCardLength:19,cardLengthRange:[14,15,16,17,18,19]},[X.UNIONPAY]:{regex:/^62\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[X.MAESTRO]:{regex:/^(5018|5020|5038|5043|5[6-9]|6020|6304|6703|6759|676[1-3])\d*/,maxCardLength:19,cardLengthRange:[12,13,14,15,16,17,18,19]},[X.ELO]:{regex:/^(?:40117[89]|431274|438935|451416|457393|45763[12]|504175|506(699|7[0-6]\d|77[0-8])|509\d{3}|627780|636(297|368)|650(0(3[1-3]|3[5-9]|4\d|5[01])|4(0[5-9]|[12]\d|3\d)|(4(8[5-9]|9\d)|5([0-2]\d|3[0-8]))|5(4[1-9]|[5-8]\d|9[0-8])|7(0\d|1[0-8]|2[0-7])|9(0[1-9]|[1-6]\d|7[0-8]))|6516(5[2-9]|[67]\d)|6550([01]\d|2[1-9]|[34]\d|5[0-8]))\d*/,maxCardLength:16,cardLengthRange:[16]}};X.DEFAULT,X.CVV,X.EXPIRY,X.ERROR,X.AMEX,X.DINERS_CLUB,X.DISCOVER,X.HIPERCARD,X.JCB,X.MAESTRO,X.MASTERCARD,X.UNIONPAY,X.VISA,X.ELO;const Q="MM/YY",ee=[Q,"YYYY/MM","YY/MM","MM/YYYY"],te=["YY","YYYY"];var ie;!function(e){e.APPLICATIONORJSON="application/json",e.TEXTORPLAIN="text/plain",e.TEXTORXML="text/xml",e.FORMURLENCODED="application/x-www-form-urlencoded",e.FORMDATA="multipart/form-data"}(ie||(ie={})),G.CARD_NUMBER,G.EXPIRATION_DATE,G.EXPIRATION_MONTH,G.EXPIRATION_YEAR,G.CVV,G.EXPIRATION_DATE,G.CARD_NUMBER,G.CARDHOLDER_NAME,G.INPUT_FIELD,g.INVALID_COLLECT_VALUE,G.PIN,G.EXPIRATION_MONTH,G.EXPIRATION_YEAR,G.CVV,G.EXPIRATION_DATE,G.CARD_NUMBER,G.CARDHOLDER_NAME,G.INPUT_FIELD,g.DEFAULT_REQUIRED_COLLECT_VALUE,G.PIN,G.EXPIRATION_MONTH,G.EXPIRATION_YEAR;const ne=[G.CARDHOLDER_NAME,G.EXPIRATION_MONTH,G.PIN,G.CVV],se={X:"[0-9]"};class oe{constructor(){this.events={}}on(e,t,i=!1){this.events[e]?this.events[e].push({priority:i,callback:t}):this.events[e]=[{priority:i,callback:t}]}off(e,t){const i=this.events[e];if(!i)return;const n=i.findIndex(e=>e.callback===t);i.splice(n,1)}_emit(e,...t){const i=this.events[e];i&&i.forEach(e=>{e.callback(...t)})}hasListener(e){const t=this.events[e];return!!t&&t.length>0}resetEvents(){const e={};Object.keys(this.events).forEach(t=>{const i=this.events[t];if(i&&i.length>0){const n=[];i.forEach(e=>{e.priority&&n.push(e)}),e[t]=n}}),this.events=e}static createChild(e){e.prototype=Object.create(oe.prototype,{constructor:e})}}
|
|
1
|
+
!function(){"use strict";function e(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(i[n[s]]=e[n[s]])}return i}function t(e,t,i,n){return new(i||(i=Promise))(function(s,o){function r(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,a)}l((n=n.apply(e,t||[])).next())})}function i(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)}function n(e,t,i,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,i):s?s.value=i:t.set(e,i),i}exports.ElementType=void 0,function(e){e.CARD_NUMBER="CARD_NUMBER",e.CARDHOLDER_NAME="CARDHOLDER_NAME",e.CVV="CVV",e.EXPIRATION_MONTH="EXPIRATION_MONTH",e.EXPIRATION_YEAR="EXPIRATION_YEAR",e.EXPIRATION_DATE="EXPIRATION_DATE"}(exports.ElementType||(exports.ElementType={})),"function"==typeof SuppressedError&&SuppressedError;var s={};!function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t=(e=>(e.PAYRAILS_CLIENT_CONFIG_MALFORMED="payrails:client:init.config_malformed",e.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT="payrails:client:collectContainer.unmountable",e.PAYRAILS_CLIENT_UI_ELEMENT_MISSING="payrails:client:mount.ui_element_missing",e.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING="payrails:client:mount.parent_element_missing",e.PAYRAILS_CLIENT_SUBELEMENTS_RENDER_ERROR="payrails:client:mount.subelements_render_error",e.PAYRAILS_CLIENT_CARD_FORM_MISSING="payrails:client:pay.card_form_missing",e.PAYRAILS_CLIENT_GPAY_LOADING_ERROR="payrails:client:mount.gpay_loading_error",e.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING="payrails:client:init.gpay_config_missing",e.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR="payrails:client:mount.applepay_loading_error",e.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING="payrails:client:init.applepay_config_missing",e.PAYRAILS_CLIENT_APPLEPAY_START_PAYMENT_SESSION_ERROR="payrails:client:init.applepay_start_payment_session_error",e.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR="payrails:client:init.paypal_loading_error",e.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING="payrails:client:init.paypal_config_missing",e.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION="payrails:client:init.paypal_order_creation",e.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT="payrails:client:mount.paypal_button_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR="payrails:client:payment_executor.pay_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAYOUT_ERROR="payrails:client:payment_executor.payout_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR="payrails:client:payment_executor.3ds_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR="payrails:client:payment_executor.confirm_error",e.PAYRAILS_API_UNAUTHORIZED="payrails:api:unauthorized",e.PAYRAILS_API_TOO_MANY_REQUESTS="payrails:api:too_many_requests",e.PAYRAILS_API_UNSUCCESSFUL="payrails:api:unsuccessful",e.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED="payrails:api:authorization_not_requested",e.PAYRAILS_API_AUTHENTICATION_ERROR="payrails:api:request_authentication_error",e.PAYRAILS_API_AUTHORIZATION_ERROR="payrails:api:request_authorization_error",e.PAYRAILS_API_PAYOUT_ERROR="payrails:api:request_payout_error",e.PAYRAILS_CLIENT_API_URL_NOT_FOUND="payrails:client:api_url_not_found",e.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND="payrails:client:workflow_execution_not_found",e.PAYRAILS_CARD_FORM_CREATION_FAILED="payrails:card_form:iframe_creation_failed",e.PAYRAILS_CARD_FORM_IFRAME_URL_MISSING="payrails:card_form:iframe_url_missing",e.PAYRAILS_CLIENT_UNKNOWN_ERROR="payrails:client:unknown",e.PAYRAILS_API_UNKNOWN_ERROR="payrails:api:unknown",e.PAYRAILS_CLIENT_SESSION_REFRESH_FAILED="payrails:client:session_refresh_failed",e.PAYRAILS_CLIENT_CALLBACK_FAILED="payrails:client:callback_failed",e.PAYRAILS_API_BIN_LOOKUP_FAILED="payrails:api:bin_lookup_failed",e.PAYRAILS_CARD_FORM_ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE="payrails.card_form.element_not_mounted_in_element_match_rule",e.PAYRAILS_CARD_FORM_REQUIRED_PARAMS_NOT_PROVIDED="payrails.card_form.required_params_not_provided",e.PAYRAILS_CARD_FORM_CLIENT_CONNECTION="payrails.card_form.client_connection",e.PAYRAILS_CARD_FORM_IFRAME_NOT_FOUND="payrails.card_form.iframe_not_found",e.PAYRAILS_CARD_FORM_IFRAME_LOADING_ERROR="payrails.card_form.iframe_loading_error",e.PAYRAILS_CARD_FORM_CSP_ERROR="payrails.card_form.iframe_csp_error",e.PAYRAILS_CARD_FORM_COMPLETE_AND_VALID_INPUTS="payrails.card_form.complete_and_valid_inputs",e.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED="payrails.card_form.collect_element_not_mounted",e.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK="payrails:client:generic_redirect.missing.redirect_link",e.PAYRAILS_CLIENT_COLLECT_CREATION_FAILED="payrails:client:collect_container.creation.failed",e.PAYRAILS_CLIENT_COLLECT_EMPTY_CONTAINER_TYPE="payrails:client:collect_container.empty_container_type",e.PAYRAILS_CLIENT_COLLECT_INVALID_CONTAINER_TYPE="payrails:client:collect_container.invalid_container_type",e.PAYRAILS_CLIENT_COLLECT_OPERATION_FAILED="payrails:client:collect_container.collect_operation_failed",e.PAYRAILS_CLIENT_VAULT_CONNECTION_ERROR="payrails:client:vault.connection_error",e.PAYRAILS_CLIENT_VAULT_NETWORK_ERROR="payrails:client:vault.network.error",e.PAYRAILS_CLIENT_COLLECT_UNIQUE_ELEMENT_NAME="payrails:client:collect_container.unique_element_name",e.PAYRAILS_CLIENT_COLLECT_INVALID_TOKENS="payrails:client:collect_container.invalid_tokens",e.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_IN_MOUNT="payrails:client:collect_container.empty_element",e.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_LISTENER="payrails:client:collect_container.invalid_event_listener",e.PAYRAILS_CLIENT_COLLECT_MISSING_HANDLER_IN_EVENT_LISTENER="payrails:client:collect_container.missing_event_handler",e.PAYRAILS_CLIENT_COLLECT_INVALID_HANDLER_IN_EVENT_LISTENER="payrails:client:collect_container.invalid_event_handler",e.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_TYPE="payrails:client:collect_container.invalid_event_type",e.PAYRAILS_CLIENT_COLLECT_TABLE_NAME_MISSING="payrails:client:collect_container.table_name_missing",e.PAYRAILS_CLIENT_COLLECT_EMPTY_TABLE="payrails:client:collect_container.empty_table",e.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_NAME="payrails:client:collect_container.invalid_table_name",e.PAYRAILS_CLIENT_COLLECT_MISSING_COLUMN="payrails:client:collect_container.missing_column",e.PAYRAILS_CLIENT_COLLECT_EMPTY_COLUMN="payrails:client:collect_container.empty_column",e.PAYRAILS_CLIENT_COLLECT_INVALID_COLUMN="payrails:client:collect_container.invalid_column",e.PAYRAILS_CLIENT_COLLECT_EMPTY_SKYFLOW_ID="payrails:client:collect_container.empty_skyflow_id",e.PAYRAILS_CLIENT_COLLECT_INVALID_SKYFLOW_ID="payrails:client:collect_container.invalid_skyflow_id",e.PAYRAILS_CLIENT_COLLECT_MISMATCH_ELEMENT_COUNT_LAYOUT_SUM="payrails:client:collect_container.mismatch_element_count_layout_sum",e.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_SELECTOR="payrails:client:collect_container.invalid_element_selector",e.PAYRAILS_CLIENT_COLLECT_DUPLICATE_ELEMENT="payrails:client:collect_container.duplicate_element",e.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_TYPE="payrails:client:collect_container.invalid_element_type",e.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATIONS_TYPE="payrails:client:collect_container.invalid_validations_type",e.PAYRAILS_CLIENT_COLLECT_MISSING_VALIDATION_RULE_TYPE="payrails:client:collect_container.missing_validation_rule_type",e.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATION_RULE_TYPE="payrails:client:collect_container.invalid_validation_rule_type",e.PAYRAILS_CLIENT_COLLECT_MISSING_VALIDATION_RULE_PARAMS="payrails:client:collect_container.missing_validation_rule_params",e.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATION_RULE_PARAMS="payrails:client:collect_container.invalid_validation_rule_params",e.PAYRAILS_CLIENT_COLLECT_MISSING_REGEX_IN_REGEX_MATCH_RULE="payrails:client:collect_container.missing_regex_in_regex_match_rule",e.PAYRAILS_CLIENT_COLLECT_MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE="payrails:client:collect_container.missing_min_and_max_in_length_match_rule",e.PAYRAILS_CLIENT_COLLECT_MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE="payrails:client:collect_container.missing_element_in_element_match_rule",e.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE="payrails:client:collect_container.invalid_element_in_element_match_rule",e.PAYRAILS_CLIENT_COLLECT_INVALID_REGEX_IN_REGEX_MATCH_RULE="payrails:client:collect_container.invalid_regex_in_regex_match_rule",e.PAYRAILS_CLIENT_COLLECT_INVALID_BOOLEAN_OPTIONS="payrails:client:collect_container.invalid_boolean_options",e.PAYRAILS_CLIENT_COLLECT_MISSING_ELEMENT_TYPE="payrails:client:collect_container.missing_element_type",e.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_TYPE="payrails:client:collect_container.empty_element_type",e.PAYRAILS_CLIENT_COLLECT_INVALID_UPSERT_OPTION_TYPE="payrails:client:collect_container.invalid_upsert_option_type",e.PAYRAILS_CLIENT_COLLECT_EMPTY_UPSERT_OPTIONS_ARRAY="payrails:client:collect_container.empty_upsert_options_array",e.PAYRAILS_CLIENT_COLLECT_INVALID_UPSERT_OPTION_OBJECT_TYPE="payrails:client:collect_container.invalid_upsert_option_object_type",e.PAYRAILS_CLIENT_COLLECT_MISSING_TABLE_IN_UPSERT_OPTION="payrails:client:collect_container.missing_table_in_upsert_option",e.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_IN_UPSERT_OPTION="payrails:client:collect_container.invalid_table_in_upsert_option",e.PAYRAILS_CLIENT_COLLECT_MISSING_COLUMN_IN_UPSERT_OPTION="payrails:client:collect_container.missing_column_in_upsert_option",e.PAYRAILS_CLIENT_COLLECT_INVALID_COLUMN_IN_UPSERT_OPTION="payrails:client:collect_container.invalid_column_in_upsert_option",e.PAYRAILS_CLIENT_COLLECT_MISSING_COMPOSABLE_CONTAINER_OPTIONS="payrails:client:collect_container.missing_composable_container_options",e.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_CONTAINER_OPTIONS="payrails:client:collect_container.invalid_composable_container_options",e.PAYRAILS_CLIENT_COLLECT_MISSING_COMPOSABLE_LAYOUT_KEY="payrails:client:collect_container.missing_composable_layout_key",e.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_LAYOUT_TYPE="payrails:client:collect_container.invalid_composable_layout_type",e.PAYRAILS_CLIENT_COLLECT_EMPTY_COMPOSABLE_LAYOUT_ARRAY="payrails:client:collect_container.empty_composable_layout_array",e.PAYRAILS_CLIENT_COLLECT_NEGATIVE_VALUES_COMPOSABLE_LAYOUT="payrails:client:collect_container.negative_values_composable_layout",e.PAYRAILS_CLIENT_COLLECT_INVALID_INPUT_OPTIONS_FORMAT="payrails:client:collect_container.invalid_input_options_format",e.PAYRAILS_CLIENT_COLLECT_INVALID_INPUT_OPTIONS_TRANSLATION="payrails:client:collect_container.invalid_input_options_translation",e.PAYRAILS_CLIENT_COLLECT_RECORDS_KEY_MISSING_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.records_key_missing_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_INVALID_RECORDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.invalid_records_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_MISSING_RECORDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.missing_records_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_MISSING_TABLE_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.missing_table_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_EMPTY_TABLE_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.empty_table_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.invalid_table_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_MISSING_FIELDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.missing_fields_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_EMPTY_FIELDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.empty_fields_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_INVALID_FIELDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.invalid_fields_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_GET_BEARER_TOKEN_MISSING="payrails:client:collect_container.get_bearer_token_missing",e.PAYRAILS_CLIENT_COMPOSABLE_CONTAINER_OPTIONS_MISSING="payrails:client:composable_container_options_missing",e.PAYRAILS_CLIENT_COMPOSABLE_CONTAINER_OPTIONS_INVALID="payrails:client:composable_container_options_invalid",e.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_UNSUPPORTED_COMPONENT_TYPE="payrails:client:dynamic_element_form.unsupported_component_type",e.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_MISSING_CONFIG="payrails:client:dynamic_element_form.missing_config",e.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_NOT_MOUNTED="payrails:client:dynamic_element_form.not_mounted",e.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_FORM_INVALID="payrails:client:dynamic_element_form.form_invalid",e.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_PAYMENT_BUTTON_MISSING_WORKFLOW_CODE="payrails:client:payment_button.no_instrument_selected",e.PAYRAILS_CLIENT_CREATE_STORED_INSTRUMENT_INVALID_ELEMENT_TYPE="payrails:client:create_stored_instrument.invalid_element_type",e.PAYRAILS_CLIENT_API_PAYOUT_NO_INSTRUMENT_SELECTED="payrails:client:api:payout_no_instrument_selected",e))(t||{});const i={"payrails:client:init.config_malformed":{description:"The provided configuration string is invalid. Please ensure it matches the required format and structure as defined in the documentation",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:unknown":{description:"Unknown Client",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:unauthorized":{description:"Unauthorized access to the Payrails API",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:too_many_requests":{description:"Too many requests to the Payrails API",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:unsuccessful":{description:"Unsuccessful request to the Payrails API",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collectContainer.unmountable":{description:"Collect container cannot be mounted",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.ui_element_missing":{description:"Collect container element does not exist",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:pay.card_form_missing":{description:"Trying to collect values from non-existent card form",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.gpay_loading_error":{description:"Google pay can not be initialized",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.paypal_loading_error":{description:"Paypal can not be initialized",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.paypal_order_creation":{description:"Paypal order creation failed",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.paypal_button_error":{description:"PaypalButtonError occurred",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.parent_element_missing":{description:"Parent element not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.subelements_render_error":{description:"Subelements could not be rendered. Please set id for the element first.",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:api_url_not_found":{description:"API URL not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:workflow_execution_not_found":{description:"Workflow execution not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.paypal_config_missing":{description:"Paypal config not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:authorization_not_requested":{description:"Authorization was not requested",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.gpay_config_missing":{description:"Google pay config not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.applepay_loading_error":{description:"Apple pay can not be initialized",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.applepay_config_missing":{description:"Apple pay config not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.applepay_start_payment_session_error":{description:"Apple pay start payment session call failed",docUrl:"https://docs.payrails.com/"},"payrails:card_form:iframe_creation_failed":{description:"Error occured while creating an iframe",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:card_form:iframe_url_missing":{description:"Iframe URL is missing",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:callback_failed":{description:"Callback passed threw an error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:session_refresh_failed":{description:"Error occured while refreshing the session",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:bin_lookup_failed":{description:"Error occured while looking up the BIN",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:request_authentication_error":{description:"Authentication error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:unknown":{description:"Unknown API error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_executor.pay_error":{description:"Error occured while executing a payment",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_executor.payout_error":{description:"Error occured while executing a payout",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_executor.confirm_error":{description:"Error occured while confirming a payment",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:request_authorization_error":{description:"Authorization error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:request_payout_error":{description:"Payout error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_executor.3ds_error":{description:"Authorization failed after 3DS challenge.",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.element_not_mounted_in_element_match_rule":{description:"Interface: collect element - collect element is not mounted in ValidationRule params at index %s1 in validations array",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.required_params_not_provided":{description:"Interface: collect element - Required params are not provided.",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.client_connection":{description:"Interface: collect container - client connection not established. client info has not reached iframes",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.iframe_not_found":{description:"Interface: collect element - frame not found:",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.complete_and_valid_inputs":{description:"Interface: collect container - Provide complete and valid inputs",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.collect_element_not_mounted":{description:"Interface: composable collect - collect element is not mounted",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.iframe_loading_error":{description:"Interface: collect element - Error occured while loading iframe",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.iframe_csp_error":{description:"Interface: collect element - Content Security Policy error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:generic_redirect.missing.redirect_link":{description:"[Generic Redirect] Missing redirect link in response"},"payrails:client:collect_container.creation.failed":{description:"Collect container failed to initialize",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_container_type":{description:"client container - Invalid container type. Container object cannot be empty.",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_container_type":{description:"client container - Invalid container type. Invalid container object",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:vault.connection_error":{description:"Vault connection error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:vault.network.error":{description:"Vault network error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.unique_element_name":{description:"client container - Element name must be unique",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_tokens":{description:"client container - Invalid tokens",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_element":{description:"client container - Element cannot be empty",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_event_listener":{description:"client container - Invalid event listener",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_event_handler":{description:"client container - Missing handler in event listener",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_event_handler":{description:"client container - Invalid handler in event listener",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_event_type":{description:"client container - Invalid event type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.table_name_missing":{description:"client container - Table name missing",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_table":{description:"client container - Table cannot be empty",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_table_name":{description:"client container - Invalid table name",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_column":{description:"client container - Column missing",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_column":{description:"client container - Column cannot be empty",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_column":{description:"client container - Invalid column",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_skyflow_id":{description:"client container - Skyflow ID cannot be empty",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_skyflow_id":{description:"client container - Invalid Skyflow ID",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.mismatch_element_count_layout_sum":{description:"client container - Element count does not match layout sum",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_element_selector":{description:"client container - Invalid element selector",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.duplicate_element":{description:"client container - Duplicate element",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_element_type":{description:"client container - Invalid element type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_validations_type":{description:"client container - Invalid validations type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_validation_rule_type":{description:"client container - Missing validation rule type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_validation_rule_type":{description:"client container - Invalid validation rule type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_validation_rule_params":{description:"client container - Missing validation rule params",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_validation_rule_params":{description:"client container - Invalid validation rule params",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_regex_in_regex_match_rule":{description:"client container - Missing regex in regex match rule",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_min_and_max_in_length_match_rule":{description:"client container - Missing min and max in length match rule",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_element_in_element_match_rule":{description:"client container - Missing element in element match rule",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_element_in_element_match_rule":{description:"client container - Invalid element in element match rule",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_regex_in_regex_match_rule":{description:"client container - Invalid regex in regex match rule",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_boolean_options":{description:"client container - Invalid boolean options",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_element_type":{description:"client container - Missing element type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_element_type":{description:"client container - EMPTY element type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_upsert_option_type":{description:"client container - Invalid upsert option type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_upsert_options_array":{description:"client container - Empty upsert options array",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_upsert_option_object_type":{description:"client container - Invalid upsert option object type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_table_in_upsert_option":{description:"client container - Missing table in upsert option",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_table_in_upsert_option":{description:"client container - Invalid table in upsert option",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_column_in_upsert_option":{description:"client container - Missing column in upsert option",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_column_in_upsert_option":{description:"client container - Invalid column in upsert option",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_composable_container_options":{description:"client container - Missing composable container options",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_composable_container_options":{description:"client container - Invalid composable container options",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_composable_layout_key":{description:"client container - Missing composable layout key",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_composable_layout_type":{description:"client container - Invalid composable layout type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_composable_layout_array":{description:"client container - Empty composable layout array",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.negative_values_composable_layout":{description:"client container - Negative values in composable layout",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_input_options_format":{description:"client container - Invalid input options format",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_input_options_translation":{description:"client container - Invalid input options translation",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.records_key_missing_in_additional_fields":{description:"client container - Records key missing in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_records_in_additional_fields":{description:"client container - Invalid records in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_records_in_additional_fields":{description:"client container - Missing records in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_table_in_additional_fields":{description:"client container - Missing table in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_table_in_additional_fields":{description:"client container - Empty table in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_table_in_additional_fields":{description:"client container - Invalid table in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.missing_fields_in_additional_fields":{description:"client container - Missing fields in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.empty_fields_in_additional_fields":{description:"client container - Empty fields in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.invalid_fields_in_additional_fields":{description:"client container - Invalid fields in additional fields",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.get_bearer_token_missing":{description:"client container - Get bearer token missing",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:composable_container_options_missing":{description:"client container - Composable container options missing",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:composable_container_options_invalid":{description:"client container - Composable container options invalid",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collect_container.collect_operation_failed":{description:"client container - Collect operation failed",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:dynamic_element_form.unsupported_component_type":{description:"client container - Unsupported component type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:dynamic_element_form.missing_config":{description:"client container - Dynamic element form missing config",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:dynamic_element_form.not_mounted":{description:"client container - Dynamic element form not mounted",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:dynamic_element_form.form_invalid":{description:"client container - Dynamic element form is invalid",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_button.no_instrument_selected":{description:"client container - Dynamic element payment button can only support payout workflows",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:create_stored_instrument.invalid_element_type":{description:"client container - Invalid element type",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:api:payout_no_instrument_selected":{description:"client container - No instrument selected for payout",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"}};var n=(e=>(e.ERROR="payrails:error",e.INFO="payrails:info",e.DEBUG="payrails:debug",e.WARN="payrails:warn",e))(n||{});class s extends Error{constructor(e,t){var n;const{description:o,docUrl:r,cause:a}=null!=t?t:{},{description:l,docUrl:d}=i[e]||{},c=null!=(n=null!=o?o:l)?n:"An unknown error occurred",u=null!=r?r:d;super(c),this.name=e,this.docUrl=u,this.cause=a,this.message=c,Error.captureStackTrace&&Error.captureStackTrace(this,s)}toJSON(){return{name:this.name,message:this.message,docUrl:this.docUrl,stack:this.stack,cause:this.cause}}}e.ERROR_CODES=t,e.PAYRAILS_OBSERVABILITY_EVENTS=n,e.PayrailsError=s}(s);var o={};!function(e){var t=Object.defineProperty,i=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,o=(e,i,n)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n,r=(e,t)=>{for(var r in t||(t={}))n.call(t,r)&&o(e,r,t[r]);if(i)for(var r of i(t))s.call(t,r)&&o(e,r,t[r]);return e};Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var a=(e=>(e.PAYRAILS_CLIENT_CONFIG_MALFORMED="payrails:client:init.config_malformed",e.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT="payrails:client:collectContainer.unmountable",e.PAYRAILS_CLIENT_UI_ELEMENT_MISSING="payrails:client:mount.ui_element_missing",e.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING="payrails:client:mount.parent_element_missing",e.PAYRAILS_CLIENT_SUBELEMENTS_RENDER_ERROR="payrails:client:mount.subelements_render_error",e.PAYRAILS_CLIENT_CARD_FORM_MISSING="payrails:client:pay.card_form_missing",e.PAYRAILS_CLIENT_GPAY_LOADING_ERROR="payrails:client:mount.gpay_loading_error",e.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING="payrails:client:init.gpay_config_missing",e.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR="payrails:client:mount.applepay_loading_error",e.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING="payrails:client:init.applepay_config_missing",e.PAYRAILS_CLIENT_APPLEPAY_START_PAYMENT_SESSION_ERROR="payrails:client:init.applepay_start_payment_session_error",e.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR="payrails:client:init.paypal_loading_error",e.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING="payrails:client:init.paypal_config_missing",e.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION="payrails:client:init.paypal_order_creation",e.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT="payrails:client:mount.paypal_button_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR="payrails:client:payment_executor.pay_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAYOUT_ERROR="payrails:client:payment_executor.payout_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR="payrails:client:payment_executor.3ds_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR="payrails:client:payment_executor.confirm_error",e.PAYRAILS_API_UNAUTHORIZED="payrails:api:unauthorized",e.PAYRAILS_API_TOO_MANY_REQUESTS="payrails:api:too_many_requests",e.PAYRAILS_API_UNSUCCESSFUL="payrails:api:unsuccessful",e.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED="payrails:api:authorization_not_requested",e.PAYRAILS_API_AUTHENTICATION_ERROR="payrails:api:request_authentication_error",e.PAYRAILS_API_AUTHORIZATION_ERROR="payrails:api:request_authorization_error",e.PAYRAILS_API_PAYOUT_ERROR="payrails:api:request_payout_error",e.PAYRAILS_CLIENT_API_URL_NOT_FOUND="payrails:client:api_url_not_found",e.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND="payrails:client:workflow_execution_not_found",e.PAYRAILS_CARD_FORM_CREATION_FAILED="payrails:card_form:iframe_creation_failed",e.PAYRAILS_CARD_FORM_IFRAME_URL_MISSING="payrails:card_form:iframe_url_missing",e.PAYRAILS_CLIENT_UNKNOWN_ERROR="payrails:client:unknown",e.PAYRAILS_API_UNKNOWN_ERROR="payrails:api:unknown",e.PAYRAILS_CLIENT_SESSION_REFRESH_FAILED="payrails:client:session_refresh_failed",e.PAYRAILS_CLIENT_CALLBACK_FAILED="payrails:client:callback_failed",e.PAYRAILS_API_BIN_LOOKUP_FAILED="payrails:api:bin_lookup_failed",e.PAYRAILS_CARD_FORM_ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE="payrails.card_form.element_not_mounted_in_element_match_rule",e.PAYRAILS_CARD_FORM_REQUIRED_PARAMS_NOT_PROVIDED="payrails.card_form.required_params_not_provided",e.PAYRAILS_CARD_FORM_CLIENT_CONNECTION="payrails.card_form.client_connection",e.PAYRAILS_CARD_FORM_IFRAME_NOT_FOUND="payrails.card_form.iframe_not_found",e.PAYRAILS_CARD_FORM_IFRAME_LOADING_ERROR="payrails.card_form.iframe_loading_error",e.PAYRAILS_CARD_FORM_CSP_ERROR="payrails.card_form.iframe_csp_error",e.PAYRAILS_CARD_FORM_COMPLETE_AND_VALID_INPUTS="payrails.card_form.complete_and_valid_inputs",e.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED="payrails.card_form.collect_element_not_mounted",e.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK="payrails:client:generic_redirect.missing.redirect_link",e.PAYRAILS_CLIENT_COLLECT_CREATION_FAILED="payrails:client:collect_container.creation.failed",e.PAYRAILS_CLIENT_COLLECT_EMPTY_CONTAINER_TYPE="payrails:client:collect_container.empty_container_type",e.PAYRAILS_CLIENT_COLLECT_INVALID_CONTAINER_TYPE="payrails:client:collect_container.invalid_container_type",e.PAYRAILS_CLIENT_COLLECT_OPERATION_FAILED="payrails:client:collect_container.collect_operation_failed",e.PAYRAILS_CLIENT_VAULT_CONNECTION_ERROR="payrails:client:vault.connection_error",e.PAYRAILS_CLIENT_VAULT_NETWORK_ERROR="payrails:client:vault.network.error",e.PAYRAILS_CLIENT_COLLECT_UNIQUE_ELEMENT_NAME="payrails:client:collect_container.unique_element_name",e.PAYRAILS_CLIENT_COLLECT_INVALID_TOKENS="payrails:client:collect_container.invalid_tokens",e.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_IN_MOUNT="payrails:client:collect_container.empty_element",e.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_LISTENER="payrails:client:collect_container.invalid_event_listener",e.PAYRAILS_CLIENT_COLLECT_MISSING_HANDLER_IN_EVENT_LISTENER="payrails:client:collect_container.missing_event_handler",e.PAYRAILS_CLIENT_COLLECT_INVALID_HANDLER_IN_EVENT_LISTENER="payrails:client:collect_container.invalid_event_handler",e.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_TYPE="payrails:client:collect_container.invalid_event_type",e.PAYRAILS_CLIENT_COLLECT_TABLE_NAME_MISSING="payrails:client:collect_container.table_name_missing",e.PAYRAILS_CLIENT_COLLECT_EMPTY_TABLE="payrails:client:collect_container.empty_table",e.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_NAME="payrails:client:collect_container.invalid_table_name",e.PAYRAILS_CLIENT_COLLECT_MISSING_COLUMN="payrails:client:collect_container.missing_column",e.PAYRAILS_CLIENT_COLLECT_EMPTY_COLUMN="payrails:client:collect_container.empty_column",e.PAYRAILS_CLIENT_COLLECT_INVALID_COLUMN="payrails:client:collect_container.invalid_column",e.PAYRAILS_CLIENT_COLLECT_EMPTY_SKYFLOW_ID="payrails:client:collect_container.empty_skyflow_id",e.PAYRAILS_CLIENT_COLLECT_INVALID_SKYFLOW_ID="payrails:client:collect_container.invalid_skyflow_id",e.PAYRAILS_CLIENT_COLLECT_MISMATCH_ELEMENT_COUNT_LAYOUT_SUM="payrails:client:collect_container.mismatch_element_count_layout_sum",e.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_SELECTOR="payrails:client:collect_container.invalid_element_selector",e.PAYRAILS_CLIENT_COLLECT_DUPLICATE_ELEMENT="payrails:client:collect_container.duplicate_element",e.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_TYPE="payrails:client:collect_container.invalid_element_type",e.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATIONS_TYPE="payrails:client:collect_container.invalid_validations_type",e.PAYRAILS_CLIENT_COLLECT_MISSING_VALIDATION_RULE_TYPE="payrails:client:collect_container.missing_validation_rule_type",e.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATION_RULE_TYPE="payrails:client:collect_container.invalid_validation_rule_type",e.PAYRAILS_CLIENT_COLLECT_MISSING_VALIDATION_RULE_PARAMS="payrails:client:collect_container.missing_validation_rule_params",e.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATION_RULE_PARAMS="payrails:client:collect_container.invalid_validation_rule_params",e.PAYRAILS_CLIENT_COLLECT_MISSING_REGEX_IN_REGEX_MATCH_RULE="payrails:client:collect_container.missing_regex_in_regex_match_rule",e.PAYRAILS_CLIENT_COLLECT_MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE="payrails:client:collect_container.missing_min_and_max_in_length_match_rule",e.PAYRAILS_CLIENT_COLLECT_MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE="payrails:client:collect_container.missing_element_in_element_match_rule",e.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE="payrails:client:collect_container.invalid_element_in_element_match_rule",e.PAYRAILS_CLIENT_COLLECT_INVALID_REGEX_IN_REGEX_MATCH_RULE="payrails:client:collect_container.invalid_regex_in_regex_match_rule",e.PAYRAILS_CLIENT_COLLECT_INVALID_BOOLEAN_OPTIONS="payrails:client:collect_container.invalid_boolean_options",e.PAYRAILS_CLIENT_COLLECT_MISSING_ELEMENT_TYPE="payrails:client:collect_container.missing_element_type",e.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_TYPE="payrails:client:collect_container.empty_element_type",e.PAYRAILS_CLIENT_COLLECT_INVALID_UPSERT_OPTION_TYPE="payrails:client:collect_container.invalid_upsert_option_type",e.PAYRAILS_CLIENT_COLLECT_EMPTY_UPSERT_OPTIONS_ARRAY="payrails:client:collect_container.empty_upsert_options_array",e.PAYRAILS_CLIENT_COLLECT_INVALID_UPSERT_OPTION_OBJECT_TYPE="payrails:client:collect_container.invalid_upsert_option_object_type",e.PAYRAILS_CLIENT_COLLECT_MISSING_TABLE_IN_UPSERT_OPTION="payrails:client:collect_container.missing_table_in_upsert_option",e.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_IN_UPSERT_OPTION="payrails:client:collect_container.invalid_table_in_upsert_option",e.PAYRAILS_CLIENT_COLLECT_MISSING_COLUMN_IN_UPSERT_OPTION="payrails:client:collect_container.missing_column_in_upsert_option",e.PAYRAILS_CLIENT_COLLECT_INVALID_COLUMN_IN_UPSERT_OPTION="payrails:client:collect_container.invalid_column_in_upsert_option",e.PAYRAILS_CLIENT_COLLECT_MISSING_COMPOSABLE_CONTAINER_OPTIONS="payrails:client:collect_container.missing_composable_container_options",e.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_CONTAINER_OPTIONS="payrails:client:collect_container.invalid_composable_container_options",e.PAYRAILS_CLIENT_COLLECT_MISSING_COMPOSABLE_LAYOUT_KEY="payrails:client:collect_container.missing_composable_layout_key",e.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_LAYOUT_TYPE="payrails:client:collect_container.invalid_composable_layout_type",e.PAYRAILS_CLIENT_COLLECT_EMPTY_COMPOSABLE_LAYOUT_ARRAY="payrails:client:collect_container.empty_composable_layout_array",e.PAYRAILS_CLIENT_COLLECT_NEGATIVE_VALUES_COMPOSABLE_LAYOUT="payrails:client:collect_container.negative_values_composable_layout",e.PAYRAILS_CLIENT_COLLECT_INVALID_INPUT_OPTIONS_FORMAT="payrails:client:collect_container.invalid_input_options_format",e.PAYRAILS_CLIENT_COLLECT_INVALID_INPUT_OPTIONS_TRANSLATION="payrails:client:collect_container.invalid_input_options_translation",e.PAYRAILS_CLIENT_COLLECT_RECORDS_KEY_MISSING_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.records_key_missing_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_INVALID_RECORDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.invalid_records_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_MISSING_RECORDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.missing_records_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_MISSING_TABLE_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.missing_table_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_EMPTY_TABLE_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.empty_table_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.invalid_table_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_MISSING_FIELDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.missing_fields_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_EMPTY_FIELDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.empty_fields_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_INVALID_FIELDS_IN_ADDITIONAL_FIELDS="payrails:client:collect_container.invalid_fields_in_additional_fields",e.PAYRAILS_CLIENT_COLLECT_GET_BEARER_TOKEN_MISSING="payrails:client:collect_container.get_bearer_token_missing",e.PAYRAILS_CLIENT_COMPOSABLE_CONTAINER_OPTIONS_MISSING="payrails:client:composable_container_options_missing",e.PAYRAILS_CLIENT_COMPOSABLE_CONTAINER_OPTIONS_INVALID="payrails:client:composable_container_options_invalid",e.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_UNSUPPORTED_COMPONENT_TYPE="payrails:client:dynamic_element_form.unsupported_component_type",e.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_MISSING_CONFIG="payrails:client:dynamic_element_form.missing_config",e.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_NOT_MOUNTED="payrails:client:dynamic_element_form.not_mounted",e.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_FORM_INVALID="payrails:client:dynamic_element_form.form_invalid",e.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_PAYMENT_BUTTON_MISSING_WORKFLOW_CODE="payrails:client:payment_button.no_instrument_selected",e.PAYRAILS_CLIENT_CREATE_STORED_INSTRUMENT_INVALID_ELEMENT_TYPE="payrails:client:create_stored_instrument.invalid_element_type",e.PAYRAILS_CLIENT_API_PAYOUT_NO_INSTRUMENT_SELECTED="payrails:client:api:payout_no_instrument_selected",e))(a||{}),l=(e=>(e.ERROR="payrails:error",e.INFO="payrails:info",e.DEBUG="payrails:debug",e.WARN="payrails:warn",e))(l||{});class d{log(e,t){console.group(`%c[${e}] : ${t.mssg}`,function(e){switch(e){case"error":return"color:red";case"info":return"color:blue";case"warn":return"color:orange";default:return"color:black"}}(e)),console.log(t.error),console.log("metadata",t.withMetada),console.log("extra",t.extra),console.groupEnd()}}function c(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var u,p={},_={};var h,E={};var m,v={};var y,I={};var f,A={};var L,O={};var g,T={};var C,R={};var N,S={};var P,b={};var D,M,w,k,Y={},U={};function x(){if(D)return U;D=1,Object.defineProperty(U,"__esModule",{value:!0}),U.Framebus=void 0;var e=K(),t="undefined"!=typeof window&&window.Promise,i=function(){function i(e){void 0===e&&(e={}),this.origin=e.origin||"*",this.channel=e.channel||"",this.verifyDomain=e.verifyDomain,this.targetFrames=e.targetFrames||[],this.limitBroadcastToFramesArray=Boolean(e.targetFrames),this.isDestroyed=!1,this.listeners=[],this.hasAdditionalChecksForOnListeners=Boolean(this.verifyDomain||this.limitBroadcastToFramesArray)}return i.setPromise=function(e){i.Promise=e},i.target=function(e){return new i(e)},i.prototype.addTargetFrame=function(e){this.limitBroadcastToFramesArray&&this.targetFrames.push(e)},i.prototype.include=function(t){return null!=t&&(null!=t.Window&&(t.constructor===t.Window&&(e.childWindows.push(t),!0)))},i.prototype.target=function(e){return i.target(e)},i.prototype.emit=function(t,i,n){if(this.isDestroyed)return!1;var s=this.origin;if(t=this.namespaceEvent(t),(0,e.isntString)(t))return!1;if((0,e.isntString)(s))return!1;"function"==typeof i&&(n=i,i=void 0);var o=(0,e.packagePayload)(t,s,i,n);return!!o&&(this.limitBroadcastToFramesArray?this.targetFramesAsWindows().forEach(function(t){(0,e.sendMessage)(t,o,s)}):(0,e.broadcast)(o,{origin:s,frame:window.top||window.self}),!0)},i.prototype.emitAsPromise=function(e,t){var n=this;return new i.Promise(function(i,s){n.emit(e,t,function(e){i(e)})||s(new Error('Listener not added for "'.concat(e,'"')))})},i.prototype.on=function(t,i){if(this.isDestroyed)return!1;var n=this,s=this.origin,o=i;return t=this.namespaceEvent(t),!(0,e.subscriptionArgsInvalid)(t,o,s)&&(this.hasAdditionalChecksForOnListeners&&(o=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];n.passesVerifyDomainCheck(this&&this.origin)&&n.hasMatchingTargetFrame(this&&this.source)&&i.apply(void 0,e)}),this.listeners.push({eventName:t,handler:o,originalHandler:i}),e.subscribers[s]=e.subscribers[s]||{},e.subscribers[s][t]=e.subscribers[s][t]||[],e.subscribers[s][t].push(o),!0)},i.prototype.off=function(t,i){var n=i;if(this.isDestroyed)return!1;if(this.verifyDomain)for(var s=0;s<this.listeners.length;s++){var o=this.listeners[s];o.originalHandler===i&&(n=o.handler)}t=this.namespaceEvent(t);var r=this.origin;if((0,e.subscriptionArgsInvalid)(t,n,r))return!1;var a=e.subscribers[r]&&e.subscribers[r][t];if(!a)return!1;for(s=0;s<a.length;s++)if(a[s]===n)return a.splice(s,1),!0;return!1},i.prototype.teardown=function(){if(!this.isDestroyed){this.isDestroyed=!0;for(var e=0;e<this.listeners.length;e++){var t=this.listeners[e];this.off(t.eventName,t.handler)}this.listeners.length=0}},i.prototype.passesVerifyDomainCheck=function(e){return!this.verifyDomain||this.checkOrigin(e)},i.prototype.targetFramesAsWindows=function(){return this.limitBroadcastToFramesArray?this.targetFrames.map(function(e){return e instanceof HTMLIFrameElement?e.contentWindow:e}).filter(function(e){return e}):[]},i.prototype.hasMatchingTargetFrame=function(e){if(!this.limitBroadcastToFramesArray)return!0;var t=this.targetFramesAsWindows().find(function(t){return t===e});return Boolean(t)},i.prototype.checkOrigin=function(e){var t,i=document.createElement("a");return i.href=location.href,t="https:"===i.protocol?i.host.replace(/:443$/,""):"http:"===i.protocol?i.host.replace(/:80$/,""):i.host,i.protocol+"//"+t===e||(!this.verifyDomain||this.verifyDomain(e))},i.prototype.namespaceEvent=function(e){return this.channel?"".concat(this.channel,":").concat(e):e},i.Promise=t,i}();return U.Framebus=i,U}function F(){if(k)return Y;k=1;var e=Y&&Y.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Y,"__esModule",{value:!0}),Y.subscribeReplier=void 0;var t=x(),i=e((w||(w=1,M=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}),M));return Y.subscribeReplier=function(e,n){var s=(0,i.default)();return t.Framebus.target({origin:n}).on(s,function i(o,r){e(o,r),t.Framebus.target({origin:n}).off(s,i)}),s},Y}var j,B={};var V,G={};var X,z,H,q,W={};function K(){return z||(z=1,e=p,t=p&&p.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,s)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),i=p&&p.__exportStar||function(e,i){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(i,n)||t(i,e,n)},Object.defineProperty(e,"__esModule",{value:!0}),i(function(){if(u)return _;u=1,Object.defineProperty(_,"__esModule",{value:!0}),_.detach=_.attach=void 0;var e=K(),t=!1;return _.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},_.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},_}(),e),i(function(){if(h)return E;h=1,Object.defineProperty(E,"__esModule",{value:!0}),E.broadcastToChildWindows=void 0;var e=K();return E.broadcastToChildWindows=function(t,i,n){for(var s=e.childWindows.length-1;s>=0;s--){var o=e.childWindows[s];o.closed?e.childWindows.splice(s,1):n!==o&&(0,e.broadcast)(t,{origin:i,frame:o.top})}},E}(),e),i(function(){if(m)return v;m=1,Object.defineProperty(v,"__esModule",{value:!0}),v.broadcast=void 0;var e=K();return v.broadcast=function t(i,n){var s,o=0,r=n.origin,a=n.frame;try{for(a.postMessage(i,r),(0,e.hasOpener)(a)&&a.opener.top!==window.top&&t(i,{origin:r,frame:a.opener.top});s=a.frames[o];)t(i,{origin:r,frame:s}),o++}catch(e){}},v}(),e),i((y||(y=1,Object.defineProperty(I,"__esModule",{value:!0}),I.subscribers=I.childWindows=I.prefix=void 0,I.prefix="/*framebus*/",I.childWindows=[],I.subscribers={}),I),e),i(function(){if(f)return A;f=1,Object.defineProperty(A,"__esModule",{value:!0}),A.dispatch=void 0;var e=K();return A.dispatch=function(t,i,n,s,o){if(e.subscribers[t]&&e.subscribers[t][i]){var r=[];n&&r.push(n),s&&r.push(s);for(var a=0;a<e.subscribers[t][i].length;a++)e.subscribers[t][i][a].apply(o,r)}},A}(),e),i((L||(L=1,Object.defineProperty(O,"__esModule",{value:!0}),O.hasOpener=void 0,O.hasOpener=function(e){return e.top===e&&null!=e.opener&&e.opener!==e&&!0!==e.opener.closed}),O),e),i((g||(g=1,Object.defineProperty(T,"__esModule",{value:!0}),T.isntString=void 0,T.isntString=function(e){return"string"!=typeof e}),T),e),i(function(){if(C)return R;C=1,Object.defineProperty(R,"__esModule",{value:!0}),R.onMessage=void 0;var e=K();return R.onMessage=function(t){if(!(0,e.isntString)(t.data)){var i=(0,e.unpackPayload)(t);if(i){var n=i.eventData,s=i.reply;(0,e.dispatch)("*",i.event,n,s,t),(0,e.dispatch)(t.origin,i.event,n,s,t),(0,e.broadcastToChildWindows)(t.data,i.origin,t.source)}}},R}(),e),i(function(){if(N)return S;N=1,Object.defineProperty(S,"__esModule",{value:!0}),S.packagePayload=void 0;var e=K();return S.packagePayload=function(t,i,n,s){var o,r={event:t,origin:i};"function"==typeof s&&(r.reply=(0,e.subscribeReplier)(s,i)),r.eventData=n;try{o=e.prefix+JSON.stringify(r)}catch(e){throw new Error("Could not stringify event: ".concat(e.message))}return o},S}(),e),i((P||(P=1,Object.defineProperty(b,"__esModule",{value:!0}),b.sendMessage=void 0,b.sendMessage=function(e,t,i){try{e.postMessage(t,i)}catch(e){}}),b),e),i(F(),e),i(function(){if(j)return B;j=1,Object.defineProperty(B,"__esModule",{value:!0}),B.subscriptionArgsInvalid=void 0;var e=K();return B.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},B}(),e),i((V||(V=1,Object.defineProperty(G,"__esModule",{value:!0})),G),e),i(function(){if(X)return W;X=1,Object.defineProperty(W,"__esModule",{value:!0}),W.unpackPayload=void 0;var e=K();return W.unpackPayload=function(t){var i;if(t.data.slice(0,e.prefix.length)!==e.prefix)return!1;try{i=JSON.parse(t.data.slice(e.prefix.length))}catch(e){return!1}if(i.reply){var n=t.origin,s=t.source,o=i.reply;i.reply=function(t){if(s){var i=(0,e.packagePayload)(o,n,t);i&&s.postMessage(i,n)}}}return i},W}(),e)),p;var e,t,i}const $=c(function(){if(q)return H;q=1;var e=K(),t=x();return(0,e.attach)(),H=t.Framebus}());class Z{constructor(e){this.origin=null,this.listeners=[],this.bus=new $(e)}static getInstance(){return Z.instance||(Z.instance=new Z),Z.instance}on(e,t){return this.bus.on(e,t)}off(e,t){return this.bus.off(e,t)}emit(e,t,i=void 0){return this.bus.emit(e,t,i)}target(e){return this.bus.target(e)}}class J{constructor(){this.bus=Z.getInstance()}log(e,t){this.bus.emit(l.ERROR,{level:e,event:t})}}var Q,ee;const te=c(function(){if(ee)return Q;ee=1;var e=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var i=Object.prototype.toString.call(e);return"[object RegExp]"===i||"[object Date]"===i||function(e){return e.$$typeof===t}(e)}(e)},t="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function i(e,t){return!1!==t.clone&&t.isMergeableObject(e)?a((i=e,Array.isArray(i)?[]:{}),e,t):e;var i}function n(e,t,n){return e.concat(t).map(function(e){return i(e,n)})}function s(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}(e))}function o(e,t){try{return t in e}catch(e){return!1}}function r(e,t,n){var r={};return n.isMergeableObject(e)&&s(e).forEach(function(t){r[t]=i(e[t],n)}),s(t).forEach(function(s){(function(e,t){return o(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,s)||(o(e,s)&&n.isMergeableObject(t[s])?r[s]=function(e,t){if(!t.customMerge)return a;var i=t.customMerge(e);return"function"==typeof i?i:a}(s,n)(e[s],t[s],n):r[s]=i(t[s],n))}),r}function a(t,s,o){(o=o||{}).arrayMerge=o.arrayMerge||n,o.isMergeableObject=o.isMergeableObject||e,o.cloneUnlessOtherwiseSpecified=i;var a=Array.isArray(s);return a===Array.isArray(t)?a?o.arrayMerge(t,s,o):r(t,s,o):i(s,o)}return a.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,i){return a(e,i,t)},{})},Q=a}());class ie{constructor(){this.state={}}static getInstance(){return ie.instance||(ie.instance=new ie),ie.instance}getState(e){return this.state[e]}setState(e){this.state=te(this.state,e)}}const ne=ie.getInstance(),se=()=>window&&window.navigator,oe=()=>window&&window.screen,re=()=>({resolution:`${oe().width}x${oe().height}`,user_agent:se().userAgent,language:se().language}),ae=[a.PAYRAILS_API_AUTHORIZATION_ERROR,a.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR,a.PAYRAILS_API_UNSUCCESSFUL];class le{constructor(e){this.adapter=[new J],this.enabled=e.enabled||!0,this.initGlobalState(e),e.logLevel=e.logLevel||"error","debug"===e.logLevel&&this.addAdapter(new d)}static init(e){le.instance=new le(e)}static getLogger(){return le.instance}initGlobalState(e){ne.setState({payrails:e.payrails,sdk:e.sdk})}static setState(e){ne.setState(e)}log(e,t,i){var n;this.enabled&&-1===ae.indexOf(null==(n=null==i?void 0:i.error)?void 0:n.name)&&this.adapter.forEach(n=>{n.log(e,{mssg:t,error:null==i?void 0:i.error,withMetada:r(r({},this.constructMetadata()),null==i?void 0:i.withMetada),extra:null==i?void 0:i.extra})})}constructMetadata(){return{device:re(),payrails:ne.getState("payrails"),sdk:ne.getState("sdk")}}addAdapter(e){this.adapter.push(e)}static log(e,t){this.getLogger().log("info",e,t)}static debug(e,t){this.getLogger().log("debug",e,t)}static info(e,t){this.getLogger().log("info",e,t)}static warn(e,t){this.getLogger().log("warning",e,t)}static error(e,t){this.getLogger().log("error",e,t)}static exception(e,t){this.error(e,t)}}e.PayrailsLogger=le,e.getDeviceInfo=re}(o);for(var r,a=[],l=0;l<256;++l)a.push((l+256).toString(16).slice(1));var d=new Uint8Array(16);function c(){if(!r&&!(r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return r(d)}var u={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function p(e,t,i){if(u.randomUUID&&!t&&!e)return u.randomUUID();var n=(e=e||{}).random||(e.rng||c)();return n[6]=15&n[6]|64,n[8]=63&n[8]|128,function(e,t=0){return(a[e[t+0]]+a[e[t+1]]+a[e[t+2]]+a[e[t+3]]+"-"+a[e[t+4]]+a[e[t+5]]+"-"+a[e[t+6]]+a[e[t+7]]+"-"+a[e[t+8]]+a[e[t+9]]+"-"+a[e[t+10]]+a[e[t+11]]+a[e[t+12]]+a[e[t+13]]+a[e[t+14]]+a[e[t+15]]).toLowerCase()}(n)}var _;!function(e){e.GET="GET",e.POST="POST",e.DELETE="DELETE",e.PATCH="PATCH"}(_||(_={}));const h=e=>t(void 0,[e],void 0,function*({url:e,method:t=_.GET,token:i="",body:n}){const s={method:t,headers:Object.assign(Object.assign(Object.assign({},f()),I(i)),A())};t!==_.POST&&t!==_.PATCH||(s.body=JSON.stringify(n||{}));const o=yield fetch(e,s);if([401,403].includes(o.status))throw new E(e,t);if(429===o.status)throw new v(e,t);if(!o.ok)throw new m(e,t);const r=yield o.json();return{ok:o.ok,req:Object.assign({url:e},s),res:r}});class E extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_UNAUTHORIZED,{description:`[${t}] ${e} unauthorized`})}}let m=class extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{description:`[${t}] ${e} unsuccessful`})}},v=class extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} too many requests`})}};class y extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} max poll attempts exceeded.`})}}const I=e=>({authorization:`Bearer ${e}`}),f=()=>({"x-idempotency-key":p()}),A=()=>{const e={version:"5.37.9-RC.0",type:"web-sdk"};return{"x-client-version":e.version,"x-client-type":e.type}};var L={};!function(e){function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var i,n={},s={};var o,r={};var a,l={};var d,c={};var u,p={};var _,h={};var E,m={};var v,y={};var I,f={};var A,L={};var O,g,T,C,R={},N={};function S(){if(O)return N;O=1,Object.defineProperty(N,"__esModule",{value:!0}),N.Framebus=void 0;var e=j(),t="undefined"!=typeof window&&window.Promise,i=function(){function i(e){void 0===e&&(e={}),this.origin=e.origin||"*",this.channel=e.channel||"",this.verifyDomain=e.verifyDomain,this.targetFrames=e.targetFrames||[],this.limitBroadcastToFramesArray=Boolean(e.targetFrames),this.isDestroyed=!1,this.listeners=[],this.hasAdditionalChecksForOnListeners=Boolean(this.verifyDomain||this.limitBroadcastToFramesArray)}return i.setPromise=function(e){i.Promise=e},i.target=function(e){return new i(e)},i.prototype.addTargetFrame=function(e){this.limitBroadcastToFramesArray&&this.targetFrames.push(e)},i.prototype.include=function(t){return null!=t&&(null!=t.Window&&(t.constructor===t.Window&&(e.childWindows.push(t),!0)))},i.prototype.target=function(e){return i.target(e)},i.prototype.emit=function(t,i,n){if(this.isDestroyed)return!1;var s=this.origin;if(t=this.namespaceEvent(t),(0,e.isntString)(t))return!1;if((0,e.isntString)(s))return!1;"function"==typeof i&&(n=i,i=void 0);var o=(0,e.packagePayload)(t,s,i,n);return!!o&&(this.limitBroadcastToFramesArray?this.targetFramesAsWindows().forEach(function(t){(0,e.sendMessage)(t,o,s)}):(0,e.broadcast)(o,{origin:s,frame:window.top||window.self}),!0)},i.prototype.emitAsPromise=function(e,t){var n=this;return new i.Promise(function(i,s){n.emit(e,t,function(e){i(e)})||s(new Error('Listener not added for "'.concat(e,'"')))})},i.prototype.on=function(t,i){if(this.isDestroyed)return!1;var n=this,s=this.origin,o=i;return t=this.namespaceEvent(t),!(0,e.subscriptionArgsInvalid)(t,o,s)&&(this.hasAdditionalChecksForOnListeners&&(o=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];n.passesVerifyDomainCheck(this&&this.origin)&&n.hasMatchingTargetFrame(this&&this.source)&&i.apply(void 0,e)}),this.listeners.push({eventName:t,handler:o,originalHandler:i}),e.subscribers[s]=e.subscribers[s]||{},e.subscribers[s][t]=e.subscribers[s][t]||[],e.subscribers[s][t].push(o),!0)},i.prototype.off=function(t,i){var n=i;if(this.isDestroyed)return!1;if(this.verifyDomain)for(var s=0;s<this.listeners.length;s++){var o=this.listeners[s];o.originalHandler===i&&(n=o.handler)}t=this.namespaceEvent(t);var r=this.origin;if((0,e.subscriptionArgsInvalid)(t,n,r))return!1;var a=e.subscribers[r]&&e.subscribers[r][t];if(!a)return!1;for(s=0;s<a.length;s++)if(a[s]===n)return a.splice(s,1),!0;return!1},i.prototype.teardown=function(){if(!this.isDestroyed){this.isDestroyed=!0;for(var e=0;e<this.listeners.length;e++){var t=this.listeners[e];this.off(t.eventName,t.handler)}this.listeners.length=0}},i.prototype.passesVerifyDomainCheck=function(e){return!this.verifyDomain||this.checkOrigin(e)},i.prototype.targetFramesAsWindows=function(){return this.limitBroadcastToFramesArray?this.targetFrames.map(function(e){return e instanceof HTMLIFrameElement?e.contentWindow:e}).filter(function(e){return e}):[]},i.prototype.hasMatchingTargetFrame=function(e){if(!this.limitBroadcastToFramesArray)return!0;var t=this.targetFramesAsWindows().find(function(t){return t===e});return Boolean(t)},i.prototype.checkOrigin=function(e){var t,i=document.createElement("a");return i.href=location.href,t="https:"===i.protocol?i.host.replace(/:443$/,""):"http:"===i.protocol?i.host.replace(/:80$/,""):i.host,i.protocol+"//"+t===e||(!this.verifyDomain||this.verifyDomain(e))},i.prototype.namespaceEvent=function(e){return this.channel?"".concat(this.channel,":").concat(e):e},i.Promise=t,i}();return N.Framebus=i,N}function P(){if(C)return R;C=1;var e=R&&R.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(R,"__esModule",{value:!0}),R.subscribeReplier=void 0;var t=S(),i=e((T||(T=1,g=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}),g));return R.subscribeReplier=function(e,n){var s=(0,i.default)();return t.Framebus.target({origin:n}).on(s,function i(o,r){e(o,r),t.Framebus.target({origin:n}).off(s,i)}),s},R}var b,D={};var M,w={};var k,Y,U,x,F={};function j(){return Y||(Y=1,e=n,t=n&&n.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,s)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),O=n&&n.__exportStar||function(e,i){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(i,n)||t(i,e,n)},Object.defineProperty(e,"__esModule",{value:!0}),O(function(){if(i)return s;i=1,Object.defineProperty(s,"__esModule",{value:!0}),s.detach=s.attach=void 0;var e=j(),t=!1;return s.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},s.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},s}(),e),O(function(){if(o)return r;o=1,Object.defineProperty(r,"__esModule",{value:!0}),r.broadcastToChildWindows=void 0;var e=j();return r.broadcastToChildWindows=function(t,i,n){for(var s=e.childWindows.length-1;s>=0;s--){var o=e.childWindows[s];o.closed?e.childWindows.splice(s,1):n!==o&&(0,e.broadcast)(t,{origin:i,frame:o.top})}},r}(),e),O(function(){if(a)return l;a=1,Object.defineProperty(l,"__esModule",{value:!0}),l.broadcast=void 0;var e=j();return l.broadcast=function t(i,n){var s,o=0,r=n.origin,a=n.frame;try{for(a.postMessage(i,r),(0,e.hasOpener)(a)&&a.opener.top!==window.top&&t(i,{origin:r,frame:a.opener.top});s=a.frames[o];)t(i,{origin:r,frame:s}),o++}catch(e){}},l}(),e),O((d||(d=1,Object.defineProperty(c,"__esModule",{value:!0}),c.subscribers=c.childWindows=c.prefix=void 0,c.prefix="/*framebus*/",c.childWindows=[],c.subscribers={}),c),e),O(function(){if(u)return p;u=1,Object.defineProperty(p,"__esModule",{value:!0}),p.dispatch=void 0;var e=j();return p.dispatch=function(t,i,n,s,o){if(e.subscribers[t]&&e.subscribers[t][i]){var r=[];n&&r.push(n),s&&r.push(s);for(var a=0;a<e.subscribers[t][i].length;a++)e.subscribers[t][i][a].apply(o,r)}},p}(),e),O((_||(_=1,Object.defineProperty(h,"__esModule",{value:!0}),h.hasOpener=void 0,h.hasOpener=function(e){return e.top===e&&null!=e.opener&&e.opener!==e&&!0!==e.opener.closed}),h),e),O((E||(E=1,Object.defineProperty(m,"__esModule",{value:!0}),m.isntString=void 0,m.isntString=function(e){return"string"!=typeof e}),m),e),O(function(){if(v)return y;v=1,Object.defineProperty(y,"__esModule",{value:!0}),y.onMessage=void 0;var e=j();return y.onMessage=function(t){if(!(0,e.isntString)(t.data)){var i=(0,e.unpackPayload)(t);if(i){var n=i.eventData,s=i.reply;(0,e.dispatch)("*",i.event,n,s,t),(0,e.dispatch)(t.origin,i.event,n,s,t),(0,e.broadcastToChildWindows)(t.data,i.origin,t.source)}}},y}(),e),O(function(){if(I)return f;I=1,Object.defineProperty(f,"__esModule",{value:!0}),f.packagePayload=void 0;var e=j();return f.packagePayload=function(t,i,n,s){var o,r={event:t,origin:i};"function"==typeof s&&(r.reply=(0,e.subscribeReplier)(s,i)),r.eventData=n;try{o=e.prefix+JSON.stringify(r)}catch(e){throw new Error("Could not stringify event: ".concat(e.message))}return o},f}(),e),O((A||(A=1,Object.defineProperty(L,"__esModule",{value:!0}),L.sendMessage=void 0,L.sendMessage=function(e,t,i){try{e.postMessage(t,i)}catch(e){}}),L),e),O(P(),e),O(function(){if(b)return D;b=1,Object.defineProperty(D,"__esModule",{value:!0}),D.subscriptionArgsInvalid=void 0;var e=j();return D.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},D}(),e),O((M||(M=1,Object.defineProperty(w,"__esModule",{value:!0})),w),e),O(function(){if(k)return F;k=1,Object.defineProperty(F,"__esModule",{value:!0}),F.unpackPayload=void 0;var e=j();return F.unpackPayload=function(t){var i;if(t.data.slice(0,e.prefix.length)!==e.prefix)return!1;try{i=JSON.parse(t.data.slice(e.prefix.length))}catch(e){return!1}if(i.reply){var n=t.origin,s=t.source,o=i.reply;i.reply=function(t){if(s){var i=(0,e.packagePayload)(o,n,t);i&&s.postMessage(i,n)}}}return i},F}(),e)),n;var e,t,O}const B=t(function(){if(x)return U;x=1;var e=j(),t=S();return(0,e.attach)(),U=t.Framebus}());class V{constructor(e){this.origin=null,this.listeners=[],this.bus=new B(e)}static getInstance(){return V.instance||(V.instance=new V),V.instance}on(e,t){return this.bus.on(e,t)}off(e,t){return this.bus.off(e,t)}emit(e,t,i=void 0){return this.bus.emit(e,t,i)}target(e){return this.bus.target(e)}}e.IframeEventBus=V,e.getEventBus=()=>V.getInstance()}(L);const O={INITIALIZE_CLIENT:"%s1 - Initializing skyflow client.",CLIENT_INITIALIZED:"%s1 - Initialized skyflow client successfully.",CREATE_COLLECT_CONTAINER:"%s1 - Creating Collect container.",COLLECT_CONTAINER_CREATED:"%s1 - Created Collect container successfully.",VALIDATE_RECORDS:"%s1 - Validating insert records.",VALIDATE_DETOKENIZE_INPUT:"%s1 - Validating detokenize input.",VALIDATE_GET_INPUT:"%s1 - Validating get input.",VALIDATE_DELETE_INPUT:"%s1 - Validating delete input.",VALIDATE_COLLECT_RECORDS:"%s1 - Validating collect element input.",CREATED_ELEMENT:"%s1 - Created %s2 element.",ELEMENT_MOUNTED:"%s1 - %s2 Element mounted.",COLLECT_SUBMIT_SUCCESS:"%s1 - Data has been collected successfully.",INSERT_DATA_SUCCESS:"%s1 - Data has been inserted successfully.",DELETE_SUCCESS:"%s1 - Data has been deleted successfully.",BEARER_TOKEN_LISTENER:"%s1 - Get bearer token listener added.",CAPTURED_BEARER_TOKEN_EVENT:"%s1 - Captured bearer token event.",BEARER_TOKEN_RESOLVED:"%s1 - GetBearerToken promise resolved successfully.",REUSE_BEARER_TOKEN:"%s1 - Reusing the bearer token.",PUREJS_CONTROLLER_INITIALIZED:"%s1 - SkyflowController initialized.",PUREJS_LISTENER_READY:"%s1 - Purejs listener ready.",EMIT_PURE_JS_CONTROLLER:"%s1 - Emitted Skyflow controller event.",INSERT_TRIGGERED:"%s1 - Insert method triggered.",DETOKENIZE_TRIGGERED:"%s1 - Detokenize method triggered.",GET_TRIGGERED:"%s1 - Get method triggered.",GET_BY_ID_TRIGGERED:"%s1 - Get method triggered.",DELETE_TRIGGERED:"%s1 - Delete method triggered.",EMIT_PURE_JS_REQUEST:"%s1 - Emitted %s2 request.",CAPTURE_PURE_JS_REQUEST:"%s1 - Captured %s2 event.",LISTEN_PURE_JS_REQUEST:"%s1 - Listening to %s2 event.",CAPTURE_PUREJS_FRAME:"%s1 - Captured SkyflowController frame ready event.",FETCH_RECORDS_RESOLVED:"%s1 - Detokenize request is resolved.",INSERT_RECORDS_RESOLVED:"%s1 - Insert request is resolved.",GET_RESOLVED:"%s1 - Get request is resolved.",GET_BY_SKYFLOWID_RESOLVED:"%s1 - GetById request is resolved.",DELETE_RESOLVED:"%s1 - Delete request is resolved",EMIT_EVENT:"%s1 - %s2 event emitted",CAPTURE_EVENT:"%s1 - Captured event %s2",LISTEN_COLLECT_FRAME_READY:"%s1 - Listening to collect FRAME_READY event",EMIT_COLLECT_ELEMENT_FRAME_READY:"%s1 - Emitting collect element %s2 FRAME_READY event",ENTERED_COLLECT_FRAME_READY_CB:"%s1 - In IFrameForm constructor, Entered FRAME_READY callback",EXECUTE_COLLECT_ELEMENT_FRAME_READY_CB:"%s1 - In IFrameForm, executing collect element, %s2 FRAME_READY callback",CLIENT_METADATA_NOT_SET:"%s1 - Client metadata not set",EXECUTE_COLLECT_ELEMENT_INIT:"%s1 - calling Collect element init",INSIDE__COLLECT_ELEMENT_INIT:"%s1 - Inside Collect element init for %s2",CREATING_COLLECT_ELEMENT_FORM:"%s1 - Start, creating iframe form for %s2",COLLECT_FRAME_READY_CB:"%s1 - In FrameElements, executing collect element FRAME_READY cb for %s2, sending metadata",INSIDE_FRAME_ELEMENTS_CONSTRUCOTR:"%s1 - Inside FrameElements constructor",SETUP_IN_START:"%s1 - Inside FrameElements start(), calling setup",SETUP_IN_CONSTRUCTOR:"%s1 - Inside FrameElements constructor, calling setup",COLLECT_ELEMET_START:"%s1 - %s2, Collect Element start",COLLECT_CONTROLLER_START:"%s1 - %s2, Collect Controller start",EMIT_COLLECT_FRAME_CONTROLLER_EVENT:"%s1 - Emit collect FrameController FRAME_READY event",EXECUTE_COLLECT_CONTROLLER_READY_CB:"%s1 - Executing collect FrameController FRAME_READY callback, set client metadata",IFRAMEFORM_CONSTRUCTOR_FRAME_READY_LISTNER:"%s1 - In IFrameForm constructor, Adding listner for FRAME_READY event",IFRAMEFORM_CONSTRUCTOR_TOKENIZATION_LISTNER:"%s1 - In IFrameForm constructor, Adding listner for TOKENIZATION_REQUEST event",CURRENT_ENV:"%s1 - Client Env is %s2",CURRENT_LOG_LEVEL:"%s1 - Client LogLevel is %s2",VALIDATE_GET_BY_ID_INPUT:"%s1 - Validating getByID input."},g={CLIENT_CONNECTION:"Interface: collect container - client connection not established. client info has not reached iframes",INVALID_BEARER_TOKEN:"Interface: init - Invalid token is generated from getBearerToken callback",BEARER_TOKEN_REJECTED:"Interface: init - GetBearerToken promise got rejected.",VAULTID_IS_REQUIRED:"Interface: init - Invalid client credentials. vaultID is required.",EMPTY_VAULTID_IN_INIT:"Interface: init - Invalid client credentials. vaultID cannot be empty.",VAULTURL_IS_REQUIRED:"Interface: init - Invalid client credentials. vaultURL is required.",EMPTY_VAULTURL_IN_INIT:"Interface: init - Invalid client credentials. vaultURL cannot be empty.",INVALID_VAULTURL_IN_INIT:"Interface: init - Invalid client credentials. Expecting https://XYZ for vaultURL",GET_BEARER_TOKEN_IS_REQUIRED:"Interface: init - Invalid client credentials. getBearerToken is required.",EMPTY_CONTAINER_TYPE:"Interface: client {containerType} container - Invalid container type. Container object cannot be empty.",INVALID_CONTAINER_TYPE:"Interface: client {containerType} container - Invalid container type. Invalid container object.",INVALID_COLLECT_VALUE:"Invalid value",INVALID_COLLECT_VALUE_WITH_LABEL:"Invalid %s1",REQUIRED_COLLECT_VALUE:"%s1 is required",DEFAULT_REQUIRED_COLLECT_VALUE:"Field is required",RECORDS_KEY_NOT_FOUND:"Interface: client insert - records object is required.",INVALID_RECORDS_IN_INSERT:"Interface: client insert - Invalid records. records object should be an array.",EMPTY_RECORDS_IN_INSERT:"Interface: client insert - records array cannot be empty.",MISSING_TABLE_IN_INSERT:'Interface: client insert - "table" key is required in records array at index %s1',EMPTY_TABLE_IN_INSERT:"Interface: client insert - table cannot be empty in records array at index %s1",INVALID_TABLE_IN_INSERT:"Interface: client insert - table of type string is required at index %s1 in records array.",EMPTY_FIELDS_IN_INSERT:"Interface: client insert - fields cannot be empty in records array at index %s1",MISSING_FIELDS_IN_INSERT:'Interface: client insert - "fields" key is required in records array at index %s1',INVALID_FIELDS_IN_INSERT:"Interface: client insert - fields of type object is required at index %s1 in records array.",INVALID_TOKENS_IN_INSERT:"Interface: client insert - Invalid tokens in options. tokens of type boolean is required.",RECORDS_KEY_NOT_FOUND_DELETE:"Interface: client delete - records object is required.",INVALID_RECORDS_IN_DELETE:"Interface: client delete - Invalid records. records object should be an array.",EMPTY_RECORDS_IN_DELETE:"Interface: client delete - records array cannot be empty.",MISSING_TABLE_IN_DELETE:'Interface: client delete - "table" key is required in records array at index %s1',EMPTY_TABLE_IN_DELETE:"Interface: client delete - table cannot be empty in records array at index %s1",INVALID_TABLE_IN_DELETE:"Interface: client delete - table of type string is required at index %s1 in records array.",MISSING_ID_IN_DELETE:'Interface: client delete - "id" key is required in records array at index %s1',EMPTY_ID_IN_DELETE:"Interface: client delete - id cannot be empty in records array at index %s1",INVALID_ID_IN_DELETE:"Interface: client delete - id of type string is required at index %s1 in records array.",DELETE_RECORDS_REJECTED:"Interface: client delete - delete request is rejected.",INVALID_TOKENS_IN_COLLECT:"Interface: collect container - Invalid tokens. tokens of type boolean is required.",RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS:'Interface: collect container - "records" key not found in additionalFields',INVALID_RECORDS_IN_ADDITIONAL_FIELDS:"Interface: collect container - records should be an array inside additionalFields",EMPTY_RECORDS_IN_ADDITIONAL_FIELDS:"Interface: collect container - records object cannot be empty in additionalFields",MISSING_TABLE_IN_ADDITIONAL_FIELDS:'Interface: collect container - "table" key not found in additionalFields records at index %s1',INVALID_TABLE_IN_ADDITIONAL_FIELDS:"Interface: collect container - Provide valid table name in additionalFields records at index %s1",INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:"Interface: collect container - Provide valid skyflow id in additionalFields records at index %s1",MISSING_FIELDS_IN_ADDITIONAL_FIELDS:'Interface: collect container - "fields" key not found in additionalFields records at index %s1',INVALID_FIELDS_IN_ADDITIONAL_FIELDS:"Interface: collect container - Provide valid fields in additionalFields records at index %s1",RECORDS_KEY_NOT_FOUND_DETOKENIZE:"Interface: client detokenize - records object is required.",EMPTY_RECORDS_DETOKENIZE:"Interface: client detokenize - records array cannot be empty.",INVALID_RECORDS_IN_DETOKENIZE:"Interface: client detokenize - Invalid records. records object should be an array.",MISSING_TOKEN_IN_DETOKENIZE:'Interface: client detokenize - "token" key is required in records array at index %s1 ',INVALID_TOKEN_IN_DETOKENIZE:"Interface: client detokenize - Invalid token. token of type string is required at index %s1 in records array.",RECORDS_KEY_NOT_FOUND_GET:"Interface: client get - records object is required.",INVALID_RECORDS_IN_GET:"Interface: client get - Invalid records. records object should be an array.",EMPTY_RECORDS_GET:"Interface: client get - records array cannot be empty.",MISSING_IDS_IN_GET:'Interface: client get - "ids" key is required in records array at index %s1',INVALID_IDS_IN_GET:"Interface: client get - Invalid ids. ids object should be an array.",INVALID_COLUMN_VALUES_IN_GET:"Interface: client get - Invalid column values. column values object should be an array.",EMPTY_IDS_IN_GET:"Interface: client get - ids array cannot be empty at index %s1",INVALID_SKYFLOWID_TYPE_IN_GET:"Interface: client get - Invalid skyflowId in ids array at index %s1",MISSING_TABLE_IN_GET:'Interface: client get - "table" key is required in records array at index %s1',INVALID_TABLE_IN_GET:"Interface: client get - table of type string is required at index %s1 in records array.",MISSING_REDACTION_IN_GET:'Interface: client get - "redaction" key is required in records array at index %s1',INVALID_REDACTION_TYPE_IN_GET:"Interface: client get - Invalid redaction type in records array at index %s1",INVALID_TOKENS_IN_GET:"Interface: client get - Invalid tokens in options. tokens of type boolean is required.",TOKENS_GET_COLUMN_NOT_SUPPORTED:"Interface: client get - column_name or column_values cannot be used with tokens in options.",REDACTION_WITH_TOKENS_NOT_SUPPORTED:"Interface: client get - redaction cannot be used when tokens are true in options.",INVALID_REDACTION_TYPE_IN_DETOKENIZE:"Interface: client get - Invalid redaction type in records array at index %s1",EMPTY_TABLE_IN_ADDITIONAL_FIELDS:"Interface: collect container - table cannot be empty in additionalFields at index %s1",EMPTY_FIELDS_IN_ADDITIONAL_FIELDS:"Interface: collect container - fields cannot be empty in additionalFields at index %s1",EMPTY_TOKEN_IN_DETOKENIZE:"Interface: client detokenize - token cannot be empty in records array at index %s1",EMPTY_SKYFLOWID_IN_GET:"Interface: client get - id cannot be empty in records array at index %s1",EMPTY_TABLE_IN_GET:"Interface: client get - table cannot be empty in records array at index %s1",EMPTY_REDACTION_TYPE_IN_GET:"Interface: client get - redaction cannot be empty in records array at index %s1",FETCH_RECORDS_REJECTED:"Interface: client detokenize - detokenize request is rejected.",INSERT_RECORDS_REJECTED:"Interface: client insert - insert request is rejected.",GET_REJECTED:"Interface: client get - get request is rejected.",MISSING_TABLE_IN_COLLECT:'Interface: collect element - "table" key is required.',EMPTY_TABLE_IN_COLLECT:"Interface: collect element - table cannot be empty.",EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:"Interface: collect element - id cannot be empty.",INVALID_TABLE_IN_COLLECT:"Interface: collect element - Invalid table. table of type string is required",INVALID_SKYFLOWID_IN_COLLECT:"Interface: collect element - Invalid id. id of type string is required",MISSING_COLUMN_IN_COLLECT:'Interface: collect element - "column" key is required.',EMPTY_COLUMN_IN_COLLECT:"Interface: collect element - column cannot be empty.",INVALID_COLUMN_IN_COLLECT:"Interface: collect element - Invalid column. column of type string is required",UNIQUE_ELEMENT_NAME:"The element name has to unique: %s1",ELEMENTS_NOT_MOUNTED:"Interface: collect container - Elements should be mounted before invoking collect",DUPLICATE_ELEMENT:"Interface: collect container - Duplicate column %s1 found in %s2.",DUPLICATE_ELEMENT_ADDITIONAL_FIELDS:"Interface: collect container - Duplicate column %s1 found in %s2 in additional fields",MISSING_ELEMENT_TYPE:'Interface:container element with type {TYPE} - Invalid element type. "type" key is required.',EMPTY_ELEMENT_TYPE:"Interface:container element with type {TYPE} - Invalid element type. type cannot be empty.",INVALID_ELEMENT_TYPE:"Interface:container element with type {TYPE} - invalid element type. type not found",INVALID_ELEMENT_SELECTOR:"Interface: container element with type {TYPE} - Div cannot be found.",CANNOT_CHANGE_ELEMENT:"Element can't be changed.",INVALID_IFRAME:"Error occured while creating an iframe",INVALID_FIELD:"Invalid Field.",FRAME_NOT_FOUND:"Interface: collect element - %s1 frame not found:",COMPLETE_AND_VALID_INPUTS:"Interface: collect container - Provide complete and valid inputs for %s1",REQUIRED_PARAMS_NOT_PROVIDED:"Interface: collect element - Required params are not provided.",INVALID_EVENT_TYPE:"Interface: collect element - Provide a valid event type.",INVALID_EVENT_LISTENER:'Interface: "on" on CollectElement - Provide valid event listener.',MISSING_HANDLER_IN_EVENT_LISTENER:'Interface: "on" on CollectElement - Second argument is missing. handler cannot be empty.',INVALID_HANDLER_IN_EVENT_LISTENER:'Interface: "on" on CollectElement - Invalid handler. handler should be of type function.',UNKNOWN_ERROR:"Unknown Error.",NETWORK_ERROR:"A network error occurred. This could be a CORS issue or a dropped internet connection. It is not possible for us to know. Please reach out to skyflow if you see this error",CONNECTION_ERROR:"Error while initializing the connection.",ERROR_OCCURED:"Error occurred.",INVALID_VALIDATIONS_TYPE:"Interface: collect element - Invalid validations type.",MISSING_VALIDATION_RULE_TYPE:"Interface: collect element - Type is missing in validationRule at index %s1 in validations array",INVALID_VALIDATION_RULE_TYPE:"Interface: collect element - Invalid ValidationRuleType at index %s1 in validations array",MISSING_VALIDATION_RULE_PARAMS:"Interface: collect element - params are missing in validationRule at index %s1 in validations array",INVALID_VALIDATION_RULE_PARAMS:"Interface: collect element - Invalid ValidationRule params at index %s1 in validations array",MISSING_REGEX_IN_REGEX_MATCH_RULE:"Interface: collect element - Missing regex in ValidationRule params at index %s1 in validations array",INVALID_REGEX_IN_REGEX_MATCH_RULE:"Interface: collect element - Invalid regex in ValidationRule params at index %s1 in validations array",MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE:"Interface: collect element - Either min or max is required in ValidationRule params at index %s1 in validations array",MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE:"Interface: collect element - Missing element in ValidationRule params at index %s1 in validations array",INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE:"Interface: collect element - Invalid collect element in ValidationRule params at index %s1 in validations array",ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE:"Interface: collect element - collect element is not mounted in ValidationRule params at index %s1 in validations array",EMPTY_ELEMENT_IN_MOUNT:"Interface: mount element with type %s1 - Mount cannot be empty.",VALIDATION_FAILED:"Validation failed",INVALID_UPSERT_OPTION_TYPE:"Invalid upsert option, should be an array",EMPTY_UPSERT_OPTIONS_ARRAY:"upsert option cannot be an empty array, atleast one object of table and column is required.",INVALID_UPSERT_OPTION_OBJECT_TYPE:"Invalid upsert object at index %s1, an object of table and column is required.",MISSING_TABLE_IN_UPSERT_OPTION:'"table" key is required in upsert options object at index %s1',MISSING_COLUMN_IN_UPSERT_OPTION:'"column" key is required in upsert option at index %s1',INVALID_TABLE_IN_UPSERT_OPTION:"Invalid table in upsert object at index %s1, table of type non empty string is required",INVALID_COLUMN_IN_UPSERT_OPTION:"Invalid column in upsert object at index %s1, column of type non empty string is required",INVALID_RECORD_COLUMN_VALUE:"Invalid Record Column value.",MISSING_RECORD_COLUMN_VALUE:"Column Values is required when Column Name is specified.",MISSING_RECORD_COLUMN_NAME:"Column Name is required when Column Values are specified.",INVALID_RECORD_COLUMN_VALUE_TYPE:"Invalid Type of Records Column Values.",INVALID_COLUMN_VALUES_TYPE:"Invalid column values type, should be an Array.",EMPTY_RECORD_COLUMN_VALUES:"Record column values cannot be empty.",EMPTY_COLUMN_VALUE:"Column Value is empty.",MISSING_IDS_OR_COLUMN_VALUES_IN_GET:'Interface: client get - "ids" key or "columnValues" key is missing.',SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED:"ids and columnName can not be specified together.",GET_BY_SKYFLOWID_RESOLVED:"%s1 - GetById request is resolved.",RECORDS_KEY_NOT_FOUND_GETBYID:"Interface: client getById - records object is required.",INVALID_RECORDS_IN_GETBYID:"Interface: client getById - Invalid records. records object should be an array.",EMPTY_RECORDS_GETBYID:"Interface: client getById - records array cannot be empty.",MISSING_IDS_IN_GETBYID:'Interface: client getById - "ids" key is required in records array at index %s1',INVALID_IDS_IN_GETBYID:"Interface: client getById - Invalid ids. ids object should be an array.",EMPTY_IDS_IN_GETBYID:"Interface: client getById - ids array cannot be empty at index %s1",INVALID_SKYFLOWID_TYPE_IN_GETBYID:"Interface: client getById - Invalid skyflowId in ids array at index %s1",MISSING_TABLE_IN_GETBYID:'Interface: client getById - "table" key is required in records array at index %s1',INVALID_TABLE_IN_GETBYID:"Interface: client getById - table of type string is required at index %s1 in records array.",MISSING_REDACTION_IN_GETBYID:'Interface: client getById - "redaction" key is required in records array at index %s1',INVALID_REDACTION_TYPE_IN_GETBYID:"Interface: client getById - Invalid redaction type in records array at index %s1",EMPTY_SKYFLOWID_IN_GETBYID:"Interface: client getById - id cannot be empty in records array at index %s1",EMPTY_TABLE_IN_GETBYID:"Interface: client getById - table cannot be empty in records array at index %s1",EMPTY_REDACTION_TYPE_IN_GETBYID:"Interface: client getById - redaction cannot be empty in records array at index %s1",GET_BY_SKYFLOWID_REJECTED:"Interface: client getById - getById request is rejected.",MISSING_COMPOSABLE_LAYOUT_KEY:"Interface: client container - layout is required in composable container options.",EMPTY_COMPOSABLE_LAYOUT_ARRAY:"Interface: client container - layout array cannot be empty in composable container options.",INVALID_COMPOSABLE_LAYOUT_TYPE:"Interface: client container - invalid layout value, layout should be of type array of numbers in composable container options.",NEGATIVE_VALUES_COMPOSABLE_LAYOUT:"Interface: client container - layout array should only have postive numbers in composable container options.",MISMATCH_ELEMENT_COUNT_LAYOUT_SUM:"Interface: composable container mount - created elements count should be equal to sum of layout values.",MISSING_COMPOSABLE_CONTAINER_OPTIONS:"Interface: client composable container - options object is required for composable container.",INVALID_COMPOSABLE_CONTAINER_OPTIONS:"Interface: client composable container - invalid options value, should be an object type.",COMPOSABLE_CONTAINER_NOT_MOUNTED:"Interface: composable collect - container should be mounted before invoking collect.",INVALID_BOOLEAN_OPTIONS:"Interface: container create - Invaild %s1 in options, %s1 of type boolean is required.",INVALID_INPUT_OPTIONS_FORMAT:"Interface: container create - Invalid type, format must be of non-empty string type.",INVALID_INPUT_OPTIONS_TRANSLATION:"Interface: container create - Invalid type, translation must be of non-empty object type.",EMPTY_COLLECT_CUSTOM_FORMAT:"Interface: container create - %s1 cannot be empty object."},T={INVALID_EXPIRATION_DATE_FORMAT:"EXPIRATION_DATE format must be in one of %s1, the format is set to default MM/YY",INVALID_EXPIRATION_YEAR_FORMAT:"EXPIRATION_YEAR format must be in one of %s1, the format is set to default YY",UNABLE_TO_SET_VALUE_IN_PROD_ENV:"%s1 setValue() cannot invoked while in PROD env. It is Not Recommeded",UNABLE_TO_CLEAR_VALUE_IN_PROD_ENV:"%s1 clearValue() cannot invoked while in PROD env. It is Not Recommeded",COLLECT_ALT_TEXT_DEPERECATED:"altText is DEPERECATED, passing altText will not have any effect",GET_BY_ID_DEPRECATED:"getById is deprecated, use new get method",INPUT_FORMATTING_NOT_SUPPROTED:"format or translation are not supported on %s1 element type.",INVALID_INPUT_TRANSLATION:"invalid or unsupported translation provided for %s1 element type."},C="collect_controller",R="element",N="ERROR",S={CHANGE:"CHANGE",READY:"READY",FOCUS:"FOCUS",BLUR:"BLUR",ESCAPE:"ESCAPE",CLICK:"CLICK",ERROR:"ERROR",SUCCESS:"SUCCESS",SUBMIT:"SUBMIT",CREATED:"CREATED",MOUNTED:"MOUNTED",HEIGHT:"HEIGHT"},P="FRAME_READY",b="TOKENIZATION_REQUEST",D="RESET",M="INPUT_EVENT",w="DESTROY_FRAME",k="SET_VALUE",Y="SET_ATTRIBUTE",U="GET_BEARER_TOKEN",x="COLLECT_ELEMENT_SET_ERROR",F="COMPOSABLE_UPDATE_OPTIONS",j="VALIDATE_ELEMENT",B="COMPOSABLE_CONTAINER_MOUNTED",V="COLLECT_CONTAINER_MOUNTED";var G,X;!function(e){e.CVV="CVV",e.EXPIRATION_DATE="EXPIRATION_DATE",e.CARD_NUMBER="CARD_NUMBER",e.CARDHOLDER_NAME="CARDHOLDER_NAME",e.INPUT_FIELD="INPUT_FIELD",e.PIN="PIN",e.EXPIRATION_MONTH="EXPIRATION_MONTH",e.EXPIRATION_YEAR="EXPIRATION_YEAR"}(G||(G={})),function(e){e.VISA="VISA",e.MASTERCARD="MASTERCARD",e.AMEX="AMEX",e.DINERS_CLUB="DINERS_CLUB",e.DISCOVER="DISCOVER",e.JCB="JCB",e.MAESTRO="MAESTRO",e.UNIONPAY="UNIONPAY",e.HIPERCARD="HIPERCARD",e.DEFAULT="DEFAULT",e.CVV="CVV",e.EXPIRY="EXPIRY",e.ERROR="ERROR",e.UNKNOWN="UNKNOWN",e.ELO="ELO"}(X||(X={}));const z={[X.AMEX]:["XXXX XXXXXX XXXXX",{X:"[0-9]"}],[X.VISA]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[X.MASTERCARD]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[X.DISCOVER]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[X.DINERS_CLUB]:["XXXX XXXXXX XXXXXX",{X:"[0-9]"}],[X.JCB]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[X.MAESTRO]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[X.UNIONPAY]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[X.HIPERCARD]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[X.DEFAULT]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[X.UNKNOWN]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[X.ELO]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}]},H={textarea:{name:"textarea",attributes:{type:"textarea"},sensitive:!1},checkbox:{name:"checkbox",attributes:{type:"checkbox"},sensitive:!1},radio:{name:"radio",attributes:{type:"radio"},sensitive:!1},dropdown:{name:"dropdown",attributes:{type:"select"},sensitive:!1},[G.CARDHOLDER_NAME]:{name:"cardHolderName",attributes:{type:"text",autocomplete:"cc-name"},sensitive:!0,regex:/^([a-zA-Z\\ \\,\\.\\-\\']{2,})$/},[G.CARD_NUMBER]:{name:"CARD_NUMBER",attributes:{type:"text",autocomplete:"cc-number",inputmode:"numeric"},sensitive:!0,mask:z[X.DEFAULT],regex:/$|^[\s]*?([0-9]{2,6}[ -]?){3,5}[\s]*/},[G.EXPIRATION_DATE]:{name:"EXPIRATION_DATE",attributes:{type:"text",autocomplete:"cc-exp",inputmode:"numeric"},sensitive:!0},[G.EXPIRATION_MONTH]:{name:"EXPIRATION_MONTH",attributes:{maxLength:2,type:"text",inputmode:"numeric",autocomplete:"cc-exp-month"},sensitive:!0,mask:["XX",{X:"[0-9]"}]},[G.EXPIRATION_YEAR]:{name:"EXPIRATION_YEAR",attributes:{type:"text",inputmode:"numeric",autocomplete:"cc-exp-year"},sensitive:!0},[G.CVV]:{name:"CVV",attributes:{type:"text",inputmode:"numeric",maxLength:3},sensitive:!0,regex:/^$|^[0-9]{3,4}$/},[G.INPUT_FIELD]:{name:"INPUT_FIELD",sensitive:!0,attributes:{type:"text"}},[G.PIN]:{name:"PIN",attributes:{type:"text",inputmode:"numeric",maxLength:12,minLength:4},sensitive:!0,regex:/^$|^[0-9]{4,12}$/}},q="XXXX-XXXX-XXXX-XXXX",W={height:"100%",width:"100%",margin:0,padding:0,border:0,position:"absolute",top:0,left:0,"user-select":"none"},K={position:"absolute",top:0,width:0,height:0,visibility:"hidden",left:"-99999999px","user-select":"none"},$={width:"100%",height:"100%",border:"0",padding:"0",margin:"0",outline:"none"},Z={WEBPACKAUTOFILL:"-webkit-autofill",BASE:"base",FOCUS:"focus",COMPLETE:"complete",EMPTY:"empty",INVALID:"invalid",GLOBAL:"global",REQUIRED_ASTERISK:"requiredAsterisk"},J={[X.VISA]:{regex:/^4\d*/,maxCardLength:19,cardLengthRange:[13,16]},[X.MASTERCARD]:{regex:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,maxCardLength:16,cardLengthRange:[16]},[X.AMEX]:{regex:/^3[47]\d*/,maxCardLength:15,cardLengthRange:[15]},[X.DINERS_CLUB]:{regex:/^(36|38|30[0-5])\d*/,maxCardLength:16,cardLengthRange:[14,15,16,17,18,19]},[X.DISCOVER]:{regex:/^(6011|65|64[4-9]|622)\d*/,maxCardLength:16,cardLengthRange:[16,17,18,19]},[X.JCB]:{regex:/^35\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[X.HIPERCARD]:{regex:/^606282\d*/,maxCardLength:19,cardLengthRange:[14,15,16,17,18,19]},[X.UNIONPAY]:{regex:/^62\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[X.MAESTRO]:{regex:/^(5018|5020|5038|5043|5[6-9]|6020|6304|6703|6759|676[1-3])\d*/,maxCardLength:19,cardLengthRange:[12,13,14,15,16,17,18,19]},[X.ELO]:{regex:/^(?:40117[89]|431274|438935|451416|457393|45763[12]|504175|506(699|7[0-6]\d|77[0-8])|509\d{3}|627780|636(297|368)|650(0(3[1-3]|3[5-9]|4\d|5[01])|4(0[5-9]|[12]\d|3\d)|(4(8[5-9]|9\d)|5([0-2]\d|3[0-8]))|5(4[1-9]|[5-8]\d|9[0-8])|7(0\d|1[0-8]|2[0-7])|9(0[1-9]|[1-6]\d|7[0-8]))|6516(5[2-9]|[67]\d)|6550([01]\d|2[1-9]|[34]\d|5[0-8]))\d*/,maxCardLength:16,cardLengthRange:[16]}};X.DEFAULT,X.CVV,X.EXPIRY,X.ERROR,X.AMEX,X.DINERS_CLUB,X.DISCOVER,X.HIPERCARD,X.JCB,X.MAESTRO,X.MASTERCARD,X.UNIONPAY,X.VISA,X.ELO;const Q="MM/YY",ee=[Q,"YYYY/MM","YY/MM","MM/YYYY"],te=["YY","YYYY"];var ie;!function(e){e.APPLICATIONORJSON="application/json",e.TEXTORPLAIN="text/plain",e.TEXTORXML="text/xml",e.FORMURLENCODED="application/x-www-form-urlencoded",e.FORMDATA="multipart/form-data"}(ie||(ie={})),G.CARD_NUMBER,G.EXPIRATION_DATE,G.EXPIRATION_MONTH,G.EXPIRATION_YEAR,G.CVV,G.EXPIRATION_DATE,G.CARD_NUMBER,G.CARDHOLDER_NAME,G.INPUT_FIELD,g.INVALID_COLLECT_VALUE,G.PIN,G.EXPIRATION_MONTH,G.EXPIRATION_YEAR,G.CVV,G.EXPIRATION_DATE,G.CARD_NUMBER,G.CARDHOLDER_NAME,G.INPUT_FIELD,g.DEFAULT_REQUIRED_COLLECT_VALUE,G.PIN,G.EXPIRATION_MONTH,G.EXPIRATION_YEAR;const ne=[G.CARDHOLDER_NAME,G.EXPIRATION_MONTH,G.PIN,G.CVV],se={X:"[0-9]"};class oe{constructor(){this.events={}}on(e,t,i=!1){this.events[e]?this.events[e].push({priority:i,callback:t}):this.events[e]=[{priority:i,callback:t}]}off(e,t){const i=this.events[e];if(!i)return;const n=i.findIndex(e=>e.callback===t);i.splice(n,1)}_emit(e,...t){const i=this.events[e];i&&i.forEach(e=>{e.callback(...t)})}hasListener(e){const t=this.events[e];return!!t&&t.length>0}resetEvents(){const e={};Object.keys(this.events).forEach(t=>{const i=this.events[t];if(i&&i.length>0){const n=[];i.forEach(e=>{e.priority&&n.push(e)}),e[t]=n}}),this.events=e}static createChild(e){e.prototype=Object.create(oe.prototype,{constructor:e})}}
|
|
2
2
|
/* @copyright
|
|
3
3
|
Copyright (c) 2022 Skyflow, Inc.
|
|
4
|
-
*/const re={IFRAME_SECURE_SITE:"https://js.skyflow.com/v1/elements/index.html",IFRAME_SECURE_ORGIN:"https://js.skyflow.com"},ae="https://assets.payrails.io/a676210/card/index.html",le="https://assets.payrails.io",de={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no",style:"width: 100%;",allow:"clipboard-read; clipboard-write"},ce=(e,t)=>{Object.keys(t).forEach(i=>{if(Object.prototype.hasOwnProperty.call(t,i)){const n=t[i];null==n?e.removeAttribute(i):e.setAttribute(i,n)}})};var ue=(e={})=>{const t=document.createElement("iframe"),i=Object.assign(Object.assign({},de),e);return Object.assign(t.style,W),ce(t,i),t.getAttribute("id")||(t.id=t.name),t};const pe=()=>re.IFRAME_SECURE_SITE,_e=(e,t)=>{Object.keys(t).forEach(i=>{Object.prototype.hasOwnProperty.call(t,i)&&(e.style[i]=t[i])})};function he(e){return JSON.parse(JSON.stringify(e))}var Ee,me,ve,ye,Ie,fe,Ae;!function(e){e.DEFAULT="DEFAULT",e.PLAIN_TEXT="PLAIN_TEXT",e.MASKED="MASKED",e.REDACTED="REDACTED"}(Ee||(Ee={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH",e.DELETE="DELETE"}(me||(me={})),function(e){e.CHANGE="CHANGE",e.READY="READY",e.FOCUS="FOCUS",e.BLUR="BLUR",e.SUBMIT="SUBMIT"}(ve||(ve={})),function(e){e.WARN="WARN",e.INFO="INFO",e.DEBUG="DEBUG",e.ERROR="ERROR"}(ye||(ye={})),function(e){e.DEV="DEV",e.PROD="PROD"}(Ie||(Ie={})),function(e){e.LOG="LOG",e.WARN="WARN",e.ERROR="ERROR"}(fe||(fe={})),function(e){e.REGEX_MATCH_RULE="REGEX_MATCH_RULE",e.LENGTH_MATCH_RULE="LENGTH_MATCH_RULE",e.ELEMENT_VALUE_MATCH_RULE="ELEMENT_VALUE_MATCH_RULE"}(Ae||(Ae={}));const Le={DEBUG:{showDebugLogs:!0,showInfoLogs:!0,showWarnLogs:!0,showErrorLogs:!0},INFO:{showDebugLogs:!1,showInfoLogs:!0,showWarnLogs:!0,showErrorLogs:!0},WARN:{showDebugLogs:!1,showInfoLogs:!1,showWarnLogs:!0,showErrorLogs:!0},ERROR:{showDebugLogs:!1,showInfoLogs:!1,showWarnLogs:!1,showErrorLogs:!0}},Oe={PROD:{doesReturnValue:!1},DEV:{doesReturnValue:!0}},ge="[Skyflow]",Te=(e,t,i)=>{if(i&&Le[i]){const{showDebugLogs:n,showInfoLogs:s,showWarnLogs:o,showErrorLogs:r}=Le[i];t===fe.LOG&&n?console.log(`${ye.DEBUG}: ${ge} ${e}`):t===fe.LOG&&s?console.log(`${ye.INFO}: ${ge} ${e}`):t===fe.WARN&&o?console.warn(`${ye.WARN}: ${ge} ${e}`):t===fe.ERROR&&r&&console.error(`${ye.ERROR}: ${ge} ${e}`)}},Ce=(...e)=>{const t=e[0],i=e.filter((e,t)=>0!==t);return t?t.replace(/%s[0-9]+/g,e=>{const t=e.replace("%s","")-1;return i[t]}):""},Re=(e="")=>{const t=e.split(":");if("group"===t[1])return"composable container";let i=atob(t[2]);return-1!==i.indexOf(":")&&(i=i.substring(0,i.indexOf(":"))),i},Ne=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_RECORDS_KEY_MISSING_IN_ADDITIONAL_FIELDS);const{records:t}=e;if(!t||!Array.isArray(t))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_RECORDS_IN_ADDITIONAL_FIELDS);if(0===t.length)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_RECORDS_IN_ADDITIONAL_FIELDS);t.forEach((e,t)=>{var i,n,o,r;if(!e||!Object.prototype.hasOwnProperty.call(e,"table"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_TABLE_IN_ADDITIONAL_FIELDS);if(!e.table)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_TABLE_IN_ADDITIONAL_FIELDS);if(void 0!==(null===(i=e.fields)||void 0===i?void 0:i.skyflowID)){if(!(null===(n=e.fields)||void 0===n?void 0:n.skyflowID))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_SKYFLOW_ID);if(!("string"==typeof(null===(o=e.fields)||void 0===o?void 0:o.skyflowID)||(null===(r=e.fields)||void 0===r?void 0:r.skyflowID)instanceof String))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_SKYFLOW_ID)}if(!("string"==typeof e.table||e.table instanceof String))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_IN_ADDITIONAL_FIELDS);if(!Object.prototype.hasOwnProperty.call(e,"fields"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_FIELDS_IN_ADDITIONAL_FIELDS);if(!e.fields)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_FIELDS_IN_ADDITIONAL_FIELDS);if("object"!=typeof e.fields||Array.isArray(e.fields))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_FIELDS_IN_ADDITIONAL_FIELDS)})},Se=e=>{let t=!0;try{new RegExp(e)}catch(e){t=!1}return t},Pe=e=>{if(!Object.prototype.hasOwnProperty.call(e,"getBearerToken"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_GET_BEARER_TOKEN_MISSING)},be=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_ELEMENT_TYPE);if(!e.type)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_TYPE);if(Object.prototype.hasOwnProperty.call(e,"altText")&&Te(T.COLLECT_ALT_TEXT_DEPERECATED,fe.WARN,t),Object.prototype.hasOwnProperty.call(e,"skyflowID")&&"string"!=typeof e.skyflowID)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_SKYFLOW_ID)},De=e=>{if(!e||!Array.isArray(e))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_UPSERT_OPTION_TYPE);if(!e.length)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_UPSERT_OPTIONS_ARRAY);e.forEach((e,t)=>{if(!e||"object"!=typeof e)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_UPSERT_OPTION_OBJECT_TYPE);if(!Object.prototype.hasOwnProperty.call(e,"table"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_TABLE_IN_UPSERT_OPTION);if(!e.table||"string"!=typeof e.table||!e.table.length)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_IN_UPSERT_OPTION);if(!Object.prototype.hasOwnProperty.call(e,"column"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_COLUMN_IN_UPSERT_OPTION);if(!e.column||"string"!=typeof e.column||!e.column.length)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COLUMN_IN_UPSERT_OPTION)})},Me=e=>"boolean"==typeof e;function we(e){const t=e.split(":");return t.length>2?(t.pop(),t.pop(),t.join(":")):""}const ke=(e,t,i)=>{if("string"!=typeof e)return e;if(t===G.CARD_NUMBER){if(e=e&&e.replace(/\s/g,""),!i){((e="")=>{const t=e.replace(/[\s-]/g,"");let i=X.DEFAULT;Object.entries(J).forEach(([e,n])=>{n.regex.test(t)&&(i=e)})})(e);const t=e.length<=15?6:8;return e.length>t?e.replace(new RegExp(`.(?=.{0,${(null==e?void 0:e.length)-t-1}}$)`,"g"),"X"):e}return e}return i?e:void 0};function Ye(e){var t,i,n,s;if((null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.customElementsURL)&&(e=>{if(!e||"https"!==e.substring(0,5).toLowerCase())return!1;try{if(new URL(e))return!0}catch(e){return!1}return!0})(null===(i=null==e?void 0:e.options)||void 0===i?void 0:i.customElementsURL)){const t=null===(n=null==e?void 0:e.options)||void 0===n?void 0:n.customElementsURL,i=new URL(t),o=i.protocol,r=i.hostname;re.IFRAME_SECURE_ORGIN=`${o}//${r}`,re.IFRAME_SECURE_SITE=null===(s=null==e?void 0:e.options)||void 0===s?void 0:s.customElementsURL}re.IFRAME_SECURE_ORGIN=le,re.IFRAME_SECURE_SITE=ae}class Ue{constructor(e,t,i,n){this.setAttributess=e=>{ce(this.iframe,{src:e})},this.mount=e=>{var t;this.unmount();try{if("string"==typeof e){if(this.container=document.querySelector(e)||void 0,!this.container)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_SELECTOR)}else{if(!(e instanceof HTMLElement))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_SELECTOR);this.container=e}}catch(e){console.error(e)}ce(this.iframe,{src:pe(),title:"Secure Credit Card Form","aria-label":"Secure payment form",role:"application",tabindex:"0"}),null===(t=this.container)||void 0===t||t.appendChild(this.iframe)},this.setIframeHeight=e=>{this.iframe.getAttribute("height")!==`${e}px`&&this.iframe.setAttribute("height",`${e}px`)},this.unmount=()=>{this.iframe.remove()},this.name=`${e}:${i}:${n}`,this.metadata=t,this.iframe=ue({name:this.name})}}class xe{}var Fe,je,Be,Ve,Ge,Xe,ze,He,qe,We,$e,Ke,Ze,Je,Qe,et,tt,it,nt,st,ot;const rt="Element";class at extends xe{constructor(t,o,r,a,l=!1,d,c,u,p){var _;super(),this.type=vi.COLLECT,Fe.set(this,void 0),je.set(this,!1),Be.set(this,void 0),Ve.set(this,void 0),Ge.set(this,{isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:void 0,isRequired:!1}),Xe.set(this,void 0),ze.set(this,new oe),He.set(this,void 0),qe.set(this,L.getEventBus()),We.set(this,void 0),$e.set(this,[]),Ke.set(this,!1),Ze.set(this,void 0),Je.set(this,void 0),Qe.set(this,!1),this.getID=()=>i(this,Fe,"f"),this.mount=t=>{var o;if(!t)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_IN_MOUNT);const r=(t,s)=>{if(t.name===i(this,We,"f").name){s(i(this,Xe,"f")),i(this,ot,"f").call(this);const t=e(i(this,Be,"f")[0],["name"]);i(this,Ve,"f").length>1?i(this,Ve,"f").forEach((e,t)=>{i(this,He,"f")&&i(this,He,"f")._emit(`${S.READY}:${e.elementName}`,Object.assign(Object.assign({},i(this,Be,"f")[t]),{elementType:e.elementType}))}):i(this,ze,"f")._emit(S.READY,Object.assign({},t)),i(this,qe,"f").off(P+this.containerId,r),Te(`${Ce(O.ELEMENT_MOUNTED,rt,Re(i(this,We,"f").name))} `,fe.LOG,i(this,Ze,"f").logLevel),i(this,$e,"f").forEach(e=>e()),n(this,$e,[],"f")}};if(i(this,Ve,"f").length>1)i(this,We,"f").mount(t),i(this,qe,"f").on(P+this.containerId,r);else{if(i(this,Qe,"f"))return i(this,We,"f").mount(t),void i(this,qe,"f").on(P+this.containerId,r);null===(o=i(this,He,"f"))||void 0===o||o.on(V,e=>{(null==e?void 0:e.containerId)===this.containerId&&(i(this,We,"f").mount(t),i(this,qe,"f").on(P+this.containerId,r))})}},this.unmount=()=>{i(this,qe,"f").off(M,i(this,nt,"f")),i(this,We,"f").unmount()},this.update=e=>{let t=he(e);const s=()=>{i(this,je,"f")&&(t={rows:[{elements:[Object.assign({},t)]}]}),n(this,Xe,dt(i(this,Xe,"f"),t),"f"),n(this,Ve,ct(i(this,Xe,"f")),"f"),i(this,je,"f")?i(this,qe,"f").emit(k,{name:i(this,We,"f").name,options:i(this,Ve,"f")[0],isSingleElementAPI:!0}):(i(this,Ve,"f").forEach(e=>{i(this,qe,"f").emit(k,{name:e.elementName,options:e,isSingleElementAPI:!0})}),i(this,qe,"f").emit(k,{name:i(this,We,"f").name,options:i(this,Xe,"f"),isSingleElementAPI:!1})),i(this,ot,"f").call(this)};i(this,Ke,"f")?s():i(this,$e,"f").push(s)},et.set(this,e=>{i(this,je,"f")||i(this,ze,"f").on(k,()=>{e(i(this,Ve,"f"))},!0)}),this.updateElement=e=>{i(this,qe,"f").emit(k,{name:e.elementName,options:e,isSingleElementAPI:!0})},tt.set(this,()=>{i(this,Be,"f").forEach((e,t)=>{var n;if(0===t){i(this,Ge,"f").isEmpty=e.isEmpty,i(this,Ge,"f").isComplete=e.isComplete,i(this,Ge,"f").isValid=e.isValid,i(this,Ge,"f").isFocused=e.isFocused,i(this,Ge,"f").isRequired=e.isRequired,i(this,Ge,"f").value={};const n=i(this,Ve,"f")[t].elementName,s=e.value&&ke(e.value,e.elementType,i(this,Je,"f"));i(this,je,"f")?i(this,Ge,"f").value=s:i(this,Ge,"f").value[n]=s}else i(this,Ge,"f").isEmpty=i(this,Ge,"f").isEmpty||e.isEmpty,i(this,Ge,"f").isComplete=i(this,Ge,"f").isComplete&&e.isComplete,i(this,Ge,"f").isValid=i(this,Ge,"f").isValid&&e.isValid,i(this,Ge,"f").isFocused=i(this,Ge,"f").isFocused||e.isFocused,i(this,Ge,"f").isRequired=i(this,Ge,"f").isRequired||e.isRequired,i(this,Ge,"f").value||(i(this,Ge,"f").value={}),!i(this,Ve,"f")[t]&&(null===(n=i(this,Ve,"f")[t])||void 0===n?void 0:n.sensitive)&&(i(this,Ge,"f").value[i(this,Ve,"f")[t].elementName]=e.value||"")})}),this.getState=()=>({isEmpty:i(this,Ge,"f").isEmpty,isComplete:i(this,Ge,"f").isComplete,isValid:i(this,Ge,"f").isValid,isFocused:i(this,Ge,"f").isFocused,value:i(this,Ge,"f").value,required:i(this,Ge,"f").isRequired}),this.getOptions=()=>{let e=he(i(this,Xe,"f"));return i(this,je,"f")?e=e.rows[0].elements[0]:e.rows.forEach(e=>{e.elements.forEach(e=>{delete e.elementName})}),delete e.elementName,e},it.set(this,e=>{i(this,ze,"f").on(w,()=>{const t=i(this,Ve,"f").map(e=>e.elementName);i(this,je,"f")||t.push(i(this,We,"f").name),e(t)},!0)}),nt.set(this,e=>{if(i(this,je,"f")&&e.event===S.READY&&e.name===i(this,We,"f").name)i(this,ze,"f")._emit(S.READY);else{const t=i(this,Ve,"f").length>1;i(this,Ve,"f").forEach((n,o)=>{var r;if(e.name===n.elementName){let a="";switch(e.event){case S.FOCUS:a=S.FOCUS;break;case S.BLUR:a=S.BLUR;break;case S.CHANGE:a=S.CHANGE;break;case S.READY:a=S.READY;break;case S.SUBMIT:return void(null===(r=i(this,He,"f"))||void 0===r||r._emit(S.SUBMIT));default:throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_TYPE)}i(this,Be,"f")[o].isEmpty=e.value.isEmpty,i(this,Be,"f")[o].isValid=e.value.isValid,i(this,Be,"f")[o].isComplete=e.value.isComplete,i(this,Be,"f")[o].isFocused=e.value.isFocused,i(this,Be,"f")[o].isRequired=e.value.isRequired,Object.prototype.hasOwnProperty.call(e.value,"value")?i(this,Be,"f")[o].value=e.value.value:i(this,Be,"f")[o].value=void 0,a=t?`${a}:${e.name}`:a,i(this,qe,"f").emit(S.HEIGHT+i(this,We,"f").name,{},e=>{i(this,We,"f").setIframeHeight(e.height)}),i(this,tt,"f").call(this);const l=Object.assign(Object.assign({},i(this,Be,"f")[o]),{elementType:n.elementType});t&&i(this,He,"f")?i(this,He,"f")._emit(a,l):i(this,ze,"f")._emit(a,l)}})}}),st.set(this,()=>{i(this,qe,"f").on(M,i(this,nt,"f"))}),ot.set(this,()=>{const{rows:e}=i(this,Xe,"f");e.forEach(e=>{e.elements.forEach(e=>{e.elementType!==H.radio.name&&e.elementType!==H.checkbox.name&&(e.value=void 0)})}),n(this,Ve,ct(i(this,Xe,"f")),"f")}),this.containerId=a.containerId,n(this,Fe,t,"f"),n(this,Ze,u,"f"),n(this,Xe,dt(o),"f"),n(this,Ve,ct(o),"f"),n(this,je,l,"f"),p&&n(this,He,p,"f"),n(this,Je,Oe[i(this,Ze,"f").env].doesReturnValue,"f"),this.elementType=i(this,je,"f")?i(this,Ve,"f")[0].elementType:"group",n(this,Be,[],"f"),i(this,Ve,"f").forEach(e=>{i(this,Be,"f").push({isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:i(this,Je,"f")?"":void 0,elementType:e.elementType,name:e.elementName,isRequired:!1})}),n(this,We,new Ue(i(this,Xe,"f").elementName,r,this.containerId,i(this,Ze,"f").logLevel),"f"),i(this,st,"f").call(this),i(this,it,"f").call(this,d),i(this,et,"f").call(this,c),Te(Ce(O.CREATED_ELEMENT,rt,Re(i(this,We,"f").name)),fe.LOG,i(this,Ze,"f").logLevel),n(this,Qe,a.isMounted,"f"),null===(_=i(this,He,"f"))||void 0===_||_.on(V,e=>{(null==e?void 0:e.containerId)===this.containerId&&n(this,Qe,!0,"f")});const h=e=>{e.height&&e.height>0&&i(this,We,"f").setIframeHeight(e.height)};i(this,qe,"f").on(S.MOUNTED,e=>{a.type===vi.COMPOSABLE?i(this,Ve,"f").forEach(t=>{e.name===t.elementName&&(t.isMounted=!0,n(this,Ke,!0,"f"))}):e.name===i(this,Ve,"f")[0].elementName&&(i(this,Ve,"f")[0].isMounted=!0,n(this,Ke,!0,"f")),i(this,qe,"f").emit(S.HEIGHT+i(this,We,"f").name,{},h)})}on(e,t){if(!Object.values(S).includes(e))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_LISTENER);if(!t)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_HANDLER_IN_EVENT_LISTENER);if("function"!=typeof t)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_HANDLER_IN_EVENT_LISTENER);i(this,ze,"f").on(e,e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,t(e)})}iframeName(){return i(this,We,"f").name}isMounted(){return i(this,Ke,"f")}isValidElement(){for(let e=0;e<i(this,Ve,"f").length;e+=1){if(!Object.prototype.hasOwnProperty.call(i(this,Ve,"f")[e],"table"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_TABLE_NAME_MISSING);if(!i(this,Ve,"f")[e].table)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_TABLE);if(!("string"==typeof i(this,Ve,"f")[e].table||i(this,Ve,"f")[e].table instanceof String))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_NAME);if(!Object.prototype.hasOwnProperty.call(i(this,Ve,"f")[e],"column"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_COLUMN);if(!i(this,Ve,"f")[e].column)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_COLUMN);if(!("string"==typeof i(this,Ve,"f")[e].column||i(this,Ve,"f")[e].column instanceof String))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COLUMN);if(void 0!==i(this,Ve,"f")[e].skyflowID&&!i(this,Ve,"f")[e].skyflowID)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_SKYFLOW_ID)}return!0}setError(e){i(this,qe,"f").emit(x,{name:we(i(this,We,"f").name),isTriggerError:!0,clientErrorText:e})}resetError(){i(this,qe,"f").emit(x,{name:we(i(this,We,"f").name),isTriggerError:!1})}setValue(e){i(this,Ze,"f").env!==Ie.PROD?i(this,je,"f")&&i(this,qe,"f").emit(k,{name:i(this,We,"f").name,options:Object.assign(Object.assign({},i(this,Ve,"f")[0]),{value:e}),isSingleElementAPI:!0}):Te(Ce(T.UNABLE_TO_SET_VALUE_IN_PROD_ENV,i(this,Ve,"f")[0].elementType),fe.WARN,i(this,Ze,"f").logLevel)}clearValue(){i(this,Ze,"f").env!==Ie.PROD?i(this,je,"f")&&i(this,qe,"f").emit(k,{name:i(this,We,"f").name,options:Object.assign(Object.assign({},i(this,Ve,"f")[0]),{value:""}),isSingleElementAPI:!0}):Te(Ce(T.UNABLE_TO_CLEAR_VALUE_IN_PROD_ENV,i(this,Ve,"f")[0].elementType),fe.WARN,i(this,Ze,"f").logLevel)}setAttribute(e,t){i(this,qe,"f").emit(Y,{name:i(this,We,"f").name,attribute:e,value:t})}}function lt(e,t,i={}){if("group"!==e&&!Object.prototype.hasOwnProperty.call(H,e))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_TYPE);if(Object.prototype.hasOwnProperty.call(t,"validations")){if(!Array.isArray(t.validations))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATIONS_TYPE);t.validations.forEach((e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_VALIDATION_RULE_TYPE);if(!Object.values(Ae).includes(e.type))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATION_RULE_TYPE);if(!Object.prototype.hasOwnProperty.call(e,"params"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_VALIDATION_RULE_PARAMS);if("object"!=typeof e.params||Array.isArray(e.params)||null===e.params)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATION_RULE_PARAMS);if(e.type===Ae.REGEX_MATCH_RULE){if(!Object.prototype.hasOwnProperty.call(e.params,"regex"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_REGEX_IN_REGEX_MATCH_RULE)}else if(e.type===Ae.LENGTH_MATCH_RULE&&!Object.prototype.hasOwnProperty.call(e.params,"min")&&!Object.prototype.hasOwnProperty.call(e.params,"max"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE)})}if(Object.prototype.hasOwnProperty.call(i,"name")&&i.name!==t.name)throw new Error("Name attribute can't be updated");if((i=Object.assign(Object.assign({},t),i)).mask||i.replacePattern){const{type:t}=H[e].attributes;"text"===t&&"textarea"===t&&"email"===t||(delete i.mask,delete i.replacePattern)}if(void 0===!i.mask&&!Array.isArray(i.mask))throw new Error("mask option has to be array or undefined");if(Array.isArray(i.mask)){const e=i.mask;if("string"!=typeof e[0]||e[1]&&"object"!=typeof e[1])throw new Error("mask array values has to be string")}if(Array.isArray(i.replacePattern)){const e=i.replacePattern;if("string"!=typeof e[0]||e[1]&&"string"!=typeof e[1])throw new Error("replacePatterns array values has to be string")}if((e===H.radio.name||e===H.checkbox.name)&&!i.value)throw new Error("Elements radio and checkbox requires value attribute");if(!(e!==H.dropdown.name||i.options&&Array.isArray(i.options)&&0!==i.options.length))throw new Error("Element dropdown requires options attribute with an array of objects containing value and text attributes")}function dt(e,t={},i=!0){return(t=Object.assign(Object.assign({},e),t)).rows.forEach((n,s)=>{const o=n,r=e.rows[s];t.rows[s]=Object.assign(Object.assign({},r),o),o.elements.forEach((e,t)=>{var n,s;const a=r.elements[t],l=e;if(l.elementType&&a.elementType!==l.elementType&&a.elementName&&a.elementName!==l.elementName)throw new Error(g.CANNOT_CHANGE_ELEMENT);lt(a.elementType,a,l),o.elements[t]=Object.assign(Object.assign(Object.assign({},a),l),{elementName:a.elementName});const d=l.classes||{},c=l.styles||{};c.base=Object.assign(Object.assign({},K),c.base),l.classes=d,l.styles=c;const u=(null===(n=null==l?void 0:l.labelStyles)||void 0===n?void 0:n.classes)||{},p=(null===(s=null==l?void 0:l.labelStyles)||void 0===s?void 0:s.styles)||{};i&&function(e,t){Object.values(Z).forEach(i=>{if(e[i]||t[i])switch(i){case Z.BASE:t[i]=Object.assign({},t[i]);break;case Z.FOCUS:t[Z.BASE]=Object.assign(Object.assign({},t[Z.BASE]),{":focus":Object.assign({},t[Z.BASE]&&t[Z.BASE][":focus"])});break;case Z.WEBPACKAUTOFILL:t[Z.BASE]=Object.assign(Object.assign({},t[Z.BASE]),{":-webkit-autofill":Object.assign({},t[Z.BASE]&&t[Z.BASE][":-webkit-autofill"])});break;default:t[i]=Object.assign(Object.assign({},t[Z.BASE]),t[i])}}),Object.keys(t).forEach(e=>{const i=t[e][":-webkit-autofill"];"object"==typeof i&&Object.keys(i).forEach(e=>{i[e]&&!i[e].includes("!important")&&(i[e]=`${i[e]} !important`)})})}(u,p),l.labelStyles={labelClasses:u},l.labelStyles.styles=p})}),t}Fe=new WeakMap,je=new WeakMap,Be=new WeakMap,Ve=new WeakMap,Ge=new WeakMap,Xe=new WeakMap,ze=new WeakMap,He=new WeakMap,qe=new WeakMap,We=new WeakMap,$e=new WeakMap,Ke=new WeakMap,Ze=new WeakMap,Je=new WeakMap,Qe=new WeakMap,et=new WeakMap,tt=new WeakMap,it=new WeakMap,nt=new WeakMap,st=new WeakMap,ot=new WeakMap;const ct=e=>{const{rows:t}=e,i=[];return t.forEach(e=>{e.elements.forEach(e=>{i.push(e)})}),i},ut=e=>{const t=e.validations;return t&&Array.isArray(t)&&t.length>0&&t.forEach((e,t)=>{if(e&&e.type===Ae.ELEMENT_VALUE_MATCH_RULE){if(e.params&&!Object.prototype.hasOwnProperty.call(e.params,"element"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE);if(e.params&&(null==e.params.element||!(e.params.element instanceof at)))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE);e.params&&e.params.element&&e.params.element instanceof at&&(e.params.element=e.params.element.iframeName())}else if(e&&e.type===Ae.REGEX_MATCH_RULE){if(e.params&&e.params.regex&&!Se(e.params.regex))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_REGEX_IN_REGEX_MATCH_RULE);e.params&&e.params.regex&&Se(e.params.regex)&&(e.params.regex=e.params.regex.toString())}}),t},pt=(e,t,i)=>{let n=Object.assign({required:!1},t);if((Object.prototype.hasOwnProperty.call(n,"format")||Object.prototype.hasOwnProperty.call(n,"translation"))&&(ne.includes(e)?(Te(Ce(T.INPUT_FORMATTING_NOT_SUPPROTED,e),fe.WARN,i),null==n||delete n.format,null==n||delete n.translation):e===H.INPUT_FIELD.name&&((e=>{if(e){if(Object.prototype.hasOwnProperty.call(e,"format")&&"string"!=typeof e.format)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_INPUT_OPTIONS_FORMAT);if(Object.prototype.hasOwnProperty.call(e,"translation")&&("object"!=typeof e.translation||"[object Object]"!==Object.prototype.toString.call(e.translation)))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_INPUT_OPTIONS_TRANSLATION)}})(t),n=Object.assign(Object.assign({},n),{mask:[n.format,n.translation?n.translation:se]}),null==n||delete n.format,null==n||delete n.translation)),e===H.CARD_NUMBER.name){Object.prototype.hasOwnProperty.call(n,"enableCardIcon")||(n=Object.assign(Object.assign({},n),{enableCardIcon:!0}));let e=" ";(null==n?void 0:n.format)===q&&(e="-"),n=Object.assign(Object.assign({},n),{cardSeperator:e}),null==n||delete n.format,null==n||delete n.translation}else if(e===H.EXPIRATION_DATE.name){let e=!1;n.format&&(e=!!(o=n.format.toUpperCase())&&ee.includes(o),e||Te(Ce(T.INVALID_EXPIRATION_DATE_FORMAT,ee.toString()),fe.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():Q}),null==n||delete n.translation}else if(e===H.EXPIRATION_YEAR.name){let e=!1;n.format&&(e=(e=>!!e&&te.includes(e))(n.format.toUpperCase()),e||Te(Ce(T.INVALID_EXPIRATION_YEAR_FORMAT,te.toString()),fe.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():"YY"}),null==n||delete n.translation}var o;if(Object.prototype.hasOwnProperty.call(n,"enableCardIcon")&&!Me(n.enableCardIcon))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_BOOLEAN_OPTIONS,{description:"Interface: container create - Invaild enableCardIcon in options, enableCardIcon of type boolean is required."});if(Object.prototype.hasOwnProperty.call(n,"required")&&!Me(n.required))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_BOOLEAN_OPTIONS,{description:"Interface: container create - Invaild required in options, required of type boolean is required."});return n};function _t(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=crypto.getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*16|0;return("x"===e?t:3&t|8).toString(16)})}class ht{}var Et,mt,vt,yt,It,ft,At,Lt,Ot,gt,Tt,Ct;const Rt="CollectContainer";class Nt extends ht{constructor(e,t,o,r){super(),Et.set(this,void 0),mt.set(this,{}),vt.set(this,void 0),yt.set(this,void 0),It.set(this,void 0),this.type=vi.COLLECT,ft.set(this,void 0),At.set(this,!1),this.create=(e,t={required:!1})=>{be(e,i(this,yt,"f").logLevel);const n=ut(e),s=pt(e.type,t,i(this,yt,"f").logLevel),o={rows:[{elements:[Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column,accept:t.allowedFileType},e),s),{validations:n})]}]};return i(this,Lt,"f").call(this,o,!0)},Lt.set(this,(e,t=!1)=>{const n=[],o=he(e);if(o.rows.forEach(e=>{e.elements.forEach(e=>{const t=e,{elementType:i}=t;lt(i,t),t.sensitive=t.sensitive||H[i].sensitive,t.replacePattern=t.replacePattern||H[i].replacePattern,t.mask=t.mask||H[i].mask,t.isMounted=!1,t.elementType!==H.radio.name&&t.elementType!==H.checkbox.name||(t.elementName=`${t.elementName}:${btoa(t.value)}`),t.elementName=`${R}:${t.elementType}:${btoa(_t())}`,t.label=e.label,t.skyflowID=e.skyflowID,n.push(t)})}),o.elementName=t?n[0].elementName:`${R}:group:${btoa(o.name)}`,t&&!i(this,mt,"f")[n[0].elementName]&&i(this,Ct,"f").call(this,n[0].name))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_UNIQUE_ELEMENT_NAME);let r=i(this,mt,"f")[o.elementName];if(r)t?r.update(n[0]):r.update(o);else{const e=_t();r=new at(e,o,i(this,vt,"f"),{containerId:i(this,Et,"f"),isMounted:i(this,At,"f"),type:this.type},t,i(this,gt,"f"),i(this,Tt,"f"),i(this,yt,"f"),i(this,ft,"f")),i(this,mt,"f")[o.elementName]=r,i(this,It,"f")[e]=r}return t||n.forEach(e=>{const t=e.elementName;i(this,mt,"f")[t]?i(this,mt,"f")[t].update(e):i(this,mt,"f")[t]=this.create(e.elementType,r)}),r}),Ot.set(this,e=>{Object.keys(i(this,mt,"f")).forEach(t=>{t===e&&delete i(this,mt,"f")[t]})}),gt.set(this,e=>{e.forEach(e=>{i(this,Ot,"f").call(this,e)})}),Tt.set(this,e=>{e.forEach(e=>{i(this,mt,"f")[e.elementName]&&i(this,mt,"f")[e.elementName].update(e)})}),Ct.set(this,e=>{const t=Object.keys(i(this,mt,"f"));for(let i=0;i<t.length;i+=1)if(atob(t[i].split(":")[2])===e)return!0;return!1}),this.validate=()=>new Promise((e,t)=>{Object.values(i(this,mt,"f")).forEach(e=>{if(!e.isMounted())throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);e.isValidElement()}),this.bus.emit(j+i(this,Et,"f"),{},t=>{e(t)})}),this.collect=(e={tokens:!0})=>new Promise((t,n)=>{try{Pe(i(this,vt,"f").clientJSON.config);const o=Object.values(i(this,mt,"f"));let r=Q;if(o.forEach(e=>{if(!e.isMounted())throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);e.isValidElement();const t=e.getOptions();t.elementType===G.EXPIRATION_DATE&&(r=t.format||"MM/YY")}),Object.prototype.hasOwnProperty.call(e,"tokens")&&!Me(e.tokens))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TOKENS);(null==e?void 0:e.additionalFields)&&Ne(e.additionalFields),(null==e?void 0:e.upsert)&&De(null==e?void 0:e.upsert),this.bus.target(re.IFRAME_SECURE_ORGIN).emit(b+i(this,Et,"f"),Object.assign(Object.assign({},Object.assign(Object.assign({},e),{expiryDateFormat:r})),{tokens:void 0===(null==e?void 0:e.tokens)||e.tokens}),e=>{!e||(null==e?void 0:e.error)?(Te(`${JSON.stringify(null==e?void 0:e.error)}`,fe.ERROR,i(this,yt,"f").logLevel),n(null==e?void 0:e.error)):(Te(Ce(O.COLLECT_SUBMIT_SUCCESS,Rt),fe.LOG,i(this,yt,"f").logLevel),t(e))}),Te(Ce(O.EMIT_EVENT,Rt,b),fe.LOG,i(this,yt,"f").logLevel)}catch(e){Te(`${e.message}`,fe.ERROR,i(this,yt,"f").logLevel),n(e)}}),this.unmount=()=>{this.iframe.remove()},this.bus=L.getEventBus(),n(this,Et,_t(),"f"),n(this,vt,Object.assign(Object.assign({},t),(null==e?void 0:e.fonts)?{fonts:e.fonts}:{}),"f"),n(this,It,o,"f"),n(this,yt,r,"f"),n(this,ft,new oe,"f"),this.iframe=ue({name:`${C}:${i(this,Et,"f")}:${i(this,yt,"f").logLevel}`}),ce(this.iframe,{src:pe()}),_e(this.iframe,Object.assign({},$)),Te(Ce(O.CREATE_COLLECT_CONTAINER,Rt),fe.LOG,i(this,yt,"f").logLevel);const a=(e,t)=>{e.name===C+i(this,Et,"f")&&(t(Object.assign(Object.assign({},i(this,vt,"f")),{clientJSON:Object.assign(Object.assign({},i(this,vt,"f").clientJSON),{config:Object.assign({},i(this,vt,"f").clientJSON.config)}),context:i(this,yt,"f")})),n(this,At,!0,"f"),i(this,ft,"f")._emit(V,{containerId:i(this,Et,"f")}),this.bus.target({origin:re.IFRAME_SECURE_ORGIN}).off(P+i(this,Et,"f"),a))};this.bus.target({origin:re.IFRAME_SECURE_ORGIN}).on(P+i(this,Et,"f"),a),document.body.append(this.iframe)}reset(){this.bus.emit(D+i(this,Et,"f"))}}Et=new WeakMap,mt=new WeakMap,vt=new WeakMap,yt=new WeakMap,It=new WeakMap,ft=new WeakMap,At=new WeakMap,Lt=new WeakMap,Ot=new WeakMap,gt=new WeakMap,Tt=new WeakMap,Ct=new WeakMap;const St=(e,t,i)=>{const n=t.split(/[\.\[\]]/g);let s=e;for(const e of n){if(null===s)return i;if(void 0===s)return i;const t=e.replace(/['"]/g,"");""!==t.trim()&&(s=s[t])}return void 0===s?i:s},Pt=(e,t,i)=>{if(!e)return{};if(!t||void 0===i)return e;const n=t.split(/[\.\[\]]/g).filter(e=>!!e.trim()),s=e=>{if(n.length>1){const t=n.shift(),i=null!==((e,t)=>{const i=void 0===t?0:t;if(null==e)return i;const n=parseInt(e);return isNaN(n)?i:n})(n[0],null);e[t]=void 0===e[t]?i?[]:{}:e[t],s(e[t])}else e[n[0]]=i},o=(e=>{if(null==(t=e)||"object"!=typeof t&&"function"!=typeof t)return e;var t;if("function"==typeof e)return e.bind({});const i=new e.constructor;return Object.getOwnPropertyNames(e).forEach(t=>{i[t]=e[t]}),i})(e);return s(o),o};var bt,Dt,Mt,wt,kt,Yt,Ut,xt,Ft,jt,Bt,Vt,Gt,Xt,zt,Ht,qt,Wt,$t,Kt,Zt,Jt,Qt;class ei{constructor(e,t){bt.set(this,void 0),Dt.set(this,void 0),this.type=vi.COMPOSABLE,Mt.set(this,!1),wt.set(this,!1),this.update=e=>{n(this,wt,!0,"f"),i(this,Mt,"f")?(i(this,Dt,"f")._emit(F,{elementName:i(this,bt,"f"),elementOptions:e}),n(this,wt,!1,"f")):i(this,wt,"f")&&i(this,Dt,"f").on(`${ve.READY}:${i(this,bt,"f")}`,()=>{i(this,Dt,"f")._emit(F,{elementName:i(this,bt,"f"),elementOptions:e}),n(this,Mt,!0,"f"),n(this,wt,!1,"f")})},n(this,bt,e,"f"),n(this,Dt,t,"f"),i(this,Dt,"f").on(`${ve.READY}:${i(this,bt,"f")}`,()=>{n(this,Mt,!0,"f")})}on(e,t){if(!Object.values(S).includes(e))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_LISTENER);if(!t)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_HANDLER_IN_EVENT_LISTENER);if("function"!=typeof t)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_HANDLER_IN_EVENT_LISTENER);i(this,Dt,"f").on(`${e}:${i(this,bt,"f")}`,e=>{if(void 0===e.value&&(e.value=""),"CARD_NUMBER"===e.elementType&&e.value){const{value:t}=e;e.value=t.slice(0,8)}delete e.isComplete,delete e.name,t(e)})}setAttribute(e,t){i(this,Dt,"f")._emit(Y,{elementName:i(this,bt,"f"),attribute:e,value:t})}}bt=new WeakMap,Dt=new WeakMap,Mt=new WeakMap,wt=new WeakMap;const ti="CollectContainer";class ii extends ht{constructor(e,t,r,a){super(),kt.set(this,void 0),Yt.set(this,{}),Ut.set(this,void 0),xt.set(this,{rows:[]}),Ft.set(this,[]),jt.set(this,void 0),Bt.set(this,void 0),Vt.set(this,void 0),Gt.set(this,!1),Xt.set(this,void 0),zt.set(this,void 0),this.type=vi.COMPOSABLE,Ht.set(this,!1),qt.set(this,{}),this.create=(e,t={required:!1})=>{be(e,i(this,jt,"f").logLevel);const n=ut(e),s=pt(e.type,t,i(this,jt,"f").logLevel),o=`${R}:${e.type}:${btoa(_t())}`;return i(this,Ft,"f").push(Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column},e),s),{validations:n,elementName:o})),new ei(o,i(this,Vt,"f"))},Wt.set(this,(e,t=!1)=>{const o=[];if(n(this,Yt,{},"f"),n(this,qt,he(e),"f"),i(this,qt,"f").rows.forEach(e=>{e.elements.forEach(e=>{const t=e,{elementType:i}=t;lt(i,t),t.sensitive=t.sensitive||H[i].sensitive,t.replacePattern=t.replacePattern||H[i].replacePattern,t.mask=t.mask||H[i].mask,t.isMounted=!1,t.label=e.label,t.skyflowID=e.skyflowID,o.push(t)})}),i(this,qt,"f").elementName=t?o[0].elementName:`${R}:group:${btoa(i(this,qt,"f").name)}`,t&&!i(this,Yt,"f")[o[0].elementName]&&i(this,Jt,"f").call(this,o[0].name))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_UNIQUE_ELEMENT_NAME);let r=i(this,Yt,"f")[i(this,qt,"f").elementName];if(r)t?r.update(o[0]):r.update(i(this,qt,"f"));else{const e=_t();r=new at(e,i(this,qt,"f"),i(this,Ut,"f"),{containerId:i(this,kt,"f"),isMounted:i(this,Ht,"f"),type:this.type},!0,i(this,Kt,"f"),i(this,Zt,"f"),i(this,jt,"f"),i(this,Vt,"f")),i(this,Yt,"f")[i(this,qt,"f").elementName]=r,i(this,Bt,"f")[e]=r}return r}),$t.set(this,e=>{Object.keys(i(this,Yt,"f")).forEach(t=>{t===e&&delete i(this,Yt,"f")[t]})}),Kt.set(this,e=>{e.forEach(e=>{i(this,$t,"f").call(this,e)})}),Zt.set(this,e=>{e.forEach(e=>{i(this,Yt,"f")[e.elementName]&&i(this,Yt,"f")[e.elementName].update(e)})}),Jt.set(this,e=>{const t=Object.keys(i(this,Yt,"f"));for(let i=0;i<t.length;i+=1)if(atob(t[i].split(":")[2])===e)return!0;return!1}),this.on=(e,t)=>{if(!Object.values(S).includes(e))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_LISTENER);if(!t)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_HANDLER_IN_EVENT_LISTENER);if("function"!=typeof t)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_HANDLER_IN_EVENT_LISTENER);i(this,Vt,"f").on(S.SUBMIT,()=>{t()})},this.mount=e=>{if(!e)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_IN_MOUNT);n(this,xt,{rows:[]},"f");const{layout:t}=i(this,Xt,"f");if((t||[]).reduce((e,t)=>e+t,0)!==i(this,Ft,"f").length)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISMATCH_ELEMENT_COUNT_LAYOUT_SUM);let o=0;if(t.forEach((e,t)=>{i(this,xt,"f").rows=[...i(this,xt,"f").rows,{elements:[]}];for(let n=0;n<e;n++)i(this,xt,"f").rows[t].elements.push(i(this,Ft,"f")[o]),o++}),i(this,Xt,"f").styles&&(i(this,xt,"f").styles=Object.assign({},i(this,Xt,"f").styles)),i(this,Xt,"f").errorTextStyles&&(i(this,xt,"f").errorTextStyles=Object.assign({},i(this,Xt,"f").errorTextStyles)),i(this,Ht,"f"))return i(this,zt,"f")&&(i(this,zt,"f").unmount(),n(this,zt,null,"f")),n(this,Yt,{},"f"),n(this,zt,i(this,Wt,"f").call(this,i(this,xt,"f"),!1),"f"),this.mountContainerElement(e),void n(this,Gt,!0,"f");i(this,Vt,"f").on(B+i(this,kt,"f"),()=>{n(this,Yt,{},"f"),n(this,zt,i(this,Wt,"f").call(this,i(this,xt,"f"),!1),"f"),this.mountContainerElement(e),n(this,Gt,!0,"f")})},this.mountContainerElement=e=>{i(this,zt,"f").mount(e)},this.unmount=()=>{var e;[...i(this,Ft,"f").map(e=>e.elementName)].forEach(e=>{i(this,$t,"f").call(this,e)}),n(this,Ft,[],"f"),n(this,xt,{rows:[]},"f"),n(this,Yt,{},"f"),null===(e=i(this,zt,"f"))||void 0===e||e.unmount(),this.iframe.remove(),n(this,Gt,!1,"f"),n(this,Ht,!1,"f")},this.validate=()=>new Promise((e,t)=>{Object.values(i(this,Yt,"f")).forEach(e=>{if(!e.isMounted())throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);e.isValidElement()}),this.bus.emit(j+i(this,kt,"f"),{},t=>{e(t)})}),this.collect=(e={tokens:!0})=>new Promise((t,n)=>{try{if(Pe(i(this,Ut,"f").clientJSON.config),!i(this,Gt,"f")){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);throw o.PayrailsLogger.error(e.message,{error:e}),e}ct(i(this,qt,"f")).forEach(e=>{if(!(null==e?void 0:e.isMounted))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING)});if(Object.values(i(this,Yt,"f")).forEach(e=>{e.isValidElement()}),e&&e.tokens&&"boolean"!=typeof e.tokens)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TOKENS);(null==e?void 0:e.additionalFields)&&Ne(e.additionalFields),(null==e?void 0:e.upsert)&&De(null==e?void 0:e.upsert),this.bus.emit(b+i(this,kt,"f"),Object.assign(Object.assign({},e),{tokens:void 0===(null==e?void 0:e.tokens)||e.tokens}),e=>{!e||(null==e?void 0:e.error)?(Te(`${JSON.stringify(null==e?void 0:e.error)}`,fe.ERROR,i(this,jt,"f").logLevel),n(null==e?void 0:e.error)):(Te(Ce(O.COLLECT_SUBMIT_SUCCESS,ti),fe.LOG,i(this,jt,"f").logLevel),t(e))}),Te(Ce(O.EMIT_EVENT,ti,b),fe.LOG,i(this,jt,"f").logLevel)}catch(e){Te(`${e.message}`,fe.ERROR,i(this,jt,"f").logLevel),n(e)}}),Qt.set(this,()=>{i(this,Vt,"f").on(F,e=>{let t;const n=i(this,Ft,"f").map((i,n)=>i.elementName===e.elementName?(t=n,Object.assign({elementName:i.elementName},e.elementOptions)):i);i(this,zt,"f")&&i(this,zt,"f").updateElement(Object.assign({},n[t]))})}),this.bus=L.getEventBus(),n(this,kt,_t(),"f"),n(this,Ut,Object.assign(Object.assign({},t),(null==e?void 0:e.fonts)?{fonts:e.fonts}:{}),"f"),n(this,Bt,r,"f"),n(this,jt,a,"f"),n(this,Xt,e,"f"),n(this,Vt,new oe,"f"),this.iframe=ue({name:`${C}:${i(this,kt,"f")}:${i(this,jt,"f").logLevel}`}),ce(this.iframe,{src:pe()}),_e(this.iframe,Object.assign({},$)),Te(Ce(O.CREATE_COLLECT_CONTAINER,ti),fe.LOG,i(this,jt,"f").logLevel);const l=(e,t)=>{e.name===C+i(this,kt,"f")&&(t(Object.assign(Object.assign({},i(this,Ut,"f")),{clientJSON:Object.assign(Object.assign({},i(this,Ut,"f").clientJSON),{config:Object.assign({},i(this,Ut,"f").clientJSON.config)}),context:i(this,jt,"f")})),n(this,Ht,!0,"f"),i(this,Vt,"f")._emit(B+i(this,kt,"f"),{containerId:i(this,kt,"f")}),this.bus.target({origin:re.IFRAME_SECURE_ORGIN}).off(P+i(this,kt,"f"),l))};this.bus.target({origin:re.IFRAME_SECURE_ORGIN}).on(P+i(this,kt,"f"),l),document.body.append(this.iframe),i(this,Qt,"f").call(this)}reset(){this.bus.emit(D+i(this,kt,"f"),{})}}function ni(e){this.message=e}kt=new WeakMap,Yt=new WeakMap,Ut=new WeakMap,xt=new WeakMap,Ft=new WeakMap,jt=new WeakMap,Bt=new WeakMap,Vt=new WeakMap,Gt=new WeakMap,Xt=new WeakMap,zt=new WeakMap,Ht=new WeakMap,qt=new WeakMap,Wt=new WeakMap,$t=new WeakMap,Kt=new WeakMap,Zt=new WeakMap,Jt=new WeakMap,Qt=new WeakMap,ni.prototype=new Error,ni.prototype.name="InvalidCharacterError";var si="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new ni("'atob' failed: The string to be decoded is not correctly encoded.");for(var i,n,s=0,o=0,r="";n=t.charAt(o++);~n&&(i=s%4?64*i+n:n,s++%4)?r+=String.fromCharCode(255&i>>(-2*s&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return r};function oi(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(si(e).replace(/(.)/g,function(e,t){var i=t.charCodeAt(0).toString(16).toUpperCase();return i.length<2&&(i="0"+i),"%"+i}))}(t)}catch(e){return si(t)}}function ri(e){this.message=e}ri.prototype=new Error,ri.prototype.name="InvalidTokenError";const ai=e=>{try{if(!e)return!1;if(t=e,"[object String]"!==Object.prototype.toString.call(t))return!1;let i=!1;const n=function(e,t){if("string"!=typeof e)throw new ri("Invalid token specified");var i=!0===(t=t||{}).header?0:1;try{return JSON.parse(oi(e.split(".")[i]))}catch(e){throw new ri("Invalid token specified: "+e.message)}}(e),s=(new Date).getTime()/1e3,o=n.exp;return o&&s>o&&(i=!0),!i}catch(e){return!1}var t};var li,di,ci,ui,pi,_i,hi,Ei,mi,vi;class yi{constructor(e,t){li.set(this,void 0),this.config=e,n(this,li,t,"f")}toJSON(){return{config:this.config,metaData:i(this,li,"f")}}static fromJSON(e){return new yi(e.config,e.metaData)}}li=new WeakMap,function(e){e.COLLECT="COLLECT",e.COMPOSABLE="COMPOSABLE"}(vi||(vi={}));const Ii="Skyflow";class fi{constructor(e){var t,r;di.set(this,void 0),ci.set(this,_t()),ui.set(this,{uuid:i(this,ci,"f"),clientDomain:window.location.origin}),pi.set(this,""),_i.set(this,void 0),hi.set(this,void 0),Ei.set(this,void 0),mi.set(this,void 0),this.bus=L.getEventBus();const a=localStorage.getItem("sdk_version")||"";i(this,ui,"f").sdkVersion=a,n(this,di,new yi(Object.assign({},e),i(this,ui,"f")),"f"),n(this,hi,(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||ye.ERROR,"f"),n(this,Ei,(null===(r=null==e?void 0:e.options)||void 0===r?void 0:r.env)||Ie.PROD,"f"),n(this,mi,{},"f");this.bus.on(N,e=>{if(e&&e.errorCode){const t=new s.PayrailsError(e.errorCode,{cause:null==e?void 0:e.originalError});o.PayrailsLogger.error(t.message,{error:t})}}),this.bus.target({origin:re.IFRAME_SECURE_ORGIN}).on(U+i(this,ci,"f"),(e,t)=>{Te(Ce(O.CAPTURED_BEARER_TOKEN_EVENT,Ii),fe.LOG,i(this,hi,"f")),!i(this,di,"f").config.getBearerToken||i(this,pi,"f")&&ai(i(this,pi,"f"))?(Te(Ce(O.REUSE_BEARER_TOKEN,Ii),fe.LOG,i(this,hi,"f")),t({authToken:i(this,pi,"f")})):i(this,di,"f").config.getBearerToken().then(e=>{ai(e)?(Te(Ce(O.BEARER_TOKEN_RESOLVED,Ii),fe.LOG,i(this,hi,"f")),n(this,pi,e,"f"),t({authToken:i(this,pi,"f")})):(Te(g.INVALID_BEARER_TOKEN,fe.ERROR,i(this,hi,"f")),t({error:g.INVALID_BEARER_TOKEN}))}).catch(e=>{Te(g.BEARER_TOKEN_REJECTED,fe.ERROR,i(this,hi,"f")),t({error:e})})}),Te(Ce(O.BEARER_TOKEN_LISTENER,Ii),fe.LOG,i(this,hi,"f")),Te(Ce(O.CURRENT_ENV,Ii,i(this,Ei,"f")),fe.LOG,i(this,hi,"f")),Te(Ce(O.CURRENT_LOG_LEVEL,Ii,i(this,hi,"f")),fe.LOG,i(this,hi,"f"))}static init(e){var t;const i=(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||ye.ERROR;Ye(e),Te(Ce(O.INITIALIZE_CLIENT,Ii),fe.LOG,i);const n=e;var s;n.vaultURL="string"!=typeof(s=e.vaultURL)?s:"/"===(null==s?void 0:s.trim().slice(-1))?s.slice(0,-1):s.trim();const o=new fi(n);return Te(Ce(O.CLIENT_INITIALIZED,Ii),fe.LOG,i),o}container(e,t){switch(e){case vi.COLLECT:{const n=new Nt(t,Object.assign(Object.assign({},i(this,ui,"f")),{clientJSON:i(this,di,"f").toJSON(),containerType:e}),i(this,mi,"f"),{logLevel:i(this,hi,"f"),env:i(this,Ei,"f")});return Te(Ce(O.COLLECT_CONTAINER_CREATED,Ii),fe.LOG,i(this,hi,"f")),n}case vi.COMPOSABLE:{(e=>{if(!e)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_COMPOSABLE_CONTAINER_OPTIONS);if("object"!=typeof e)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COMPOSABLE_CONTAINER_OPTIONS_INVALID);if(!Object.prototype.hasOwnProperty.call(e,"layout"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_COMPOSABLE_LAYOUT_KEY);if(!e.layout)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_LAYOUT_TYPE);if(!Array.isArray(e.layout))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_LAYOUT_TYPE);if(0===e.layout.length)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_COMPOSABLE_LAYOUT_ARRAY);e.layout.forEach(e=>{if("number"!=typeof e)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_LAYOUT_TYPE);if(e<0)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_NEGATIVE_VALUES_COMPOSABLE_LAYOUT)})})(t);const n=new ii(t,Object.assign(Object.assign({},i(this,ui,"f")),{clientJSON:i(this,di,"f").toJSON(),containerType:e}),i(this,mi,"f"),{logLevel:i(this,hi,"f"),env:i(this,Ei,"f")});return Te(Ce(O.COLLECT_CONTAINER_CREATED,Ii),fe.LOG,i(this,hi,"f")),n}default:if(!e)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_CONTAINER_TYPE);throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_CONTAINER_TYPE)}}static get ContainerType(){return vi}static get ElementType(){return G}static get RedactionType(){return Ee}static get RequestMethod(){return me}static get LogLevel(){return ye}static get EventName(){return ve}static get Env(){return Ie}static get ValidationRuleType(){return Ae}}di=new WeakMap,ci=new WeakMap,ui=new WeakMap,pi=new WeakMap,_i=new WeakMap,hi=new WeakMap,Ei=new WeakMap,mi=new WeakMap;const Ai=({url:e,token:t,body:i})=>h({url:e,token:t,method:_.POST,body:i}),Li=(e,i)=>t(void 0,void 0,void 0,function*(){try{const t=yield Ps(e,i);if(!t){const n=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onRequestStart resolved to false"});return Ss(e,i,{code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:n.message}),t}}catch(t){const n=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onRequestStart threw an error",cause:t});return o.PayrailsLogger.error(n.message,{error:n}),Ss(e,i,{code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:n.message}),!1}return!0});let Oi={};var gi,Ti,Ci,Ri;exports.PAYMENT_METHOD_CODES=void 0,(gi=exports.PAYMENT_METHOD_CODES||(exports.PAYMENT_METHOD_CODES={})).CARD="card",gi.GOOGLE_PAY="googlePay",gi.PAYPAL="payPal",gi.APPLE_PAY="applePay",gi.GENERIC_REDIRECT="genericRedirect",gi.MERCADO_PAGO="mercadoPago",gi.PIX="pix",gi.BANK_ACCOUNT="bankAccount",gi.IDEAL="iDeal",gi.YAPE="yape",gi.UPI="upi",gi.KLARNA="klarna",function(e){e.ENABLED="enabled",e.CREATED="created",e.DELETED="deleted",e.DISABLED="disabled",e.INVALID="invalid",e.TRANSIENT="transient"}(Ti||(Ti={}));class Ni{static get response(){if(!Ni._response){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND);throw o.PayrailsLogger.error(e.message,{error:e}),e}return Ni._response}static setResponse(e){return Ni._response=e,Ni}static get workflowCode(){return Ni.response.workflow.code}static get lookup(){return Ni.response.initialResults.find(({body:{name:e}})=>"lookup"===e)}static get holderReference(){return Ni.response.holderReference}static get savedCreditCards(){return Ni.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.CARD)}static get savedPaypalAccounts(){return Ni.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.PAYPAL).filter(({status:e})=>e===Ti.ENABLED)}static get savedGooglePayAccounts(){return Ni.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.GOOGLE_PAY).filter(({status:e})=>e===Ti.ENABLED)}static get savedApplePayAccounts(){return Ni.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.APPLE_PAY)}static get paypalConfig(){const e=Ni.availablePaymentMethods.find(({paymentMethodCode:e})=>e===exports.PAYMENT_METHOD_CODES.PAYPAL);if(!e){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING);throw o.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:Ni.availablePaymentMethods}}),e}return e.config||{}}static get googlePayConfig(){var e;const t=Ni.availablePaymentMethods.find(({paymentMethodCode:e})=>e===exports.PAYMENT_METHOD_CODES.GOOGLE_PAY);if(!t){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING);throw o.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:Ni.availablePaymentMethods}}),e}const i=t;return(null===(e=i.clientConfig)||void 0===e?void 0:e.additionalConfig)&&void 0!==i.clientConfig.additionalConfig.apiVersion?i.clientConfig.additionalConfig:[i.config]}static isPaymentMethodAvailable(e){return Ni.availablePaymentMethods.some(({paymentMethodCode:t})=>t===e)}static get applePayConfig(){const e=Ni.availablePaymentMethods.find(({paymentMethodCode:e})=>e===exports.PAYMENT_METHOD_CODES.APPLE_PAY);if(!e){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING);throw o.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:Ni.availablePaymentMethods}}),e}return e.config.parameters}static get url(){return Ni.response.links.self}static get meta(){return Ni.response.meta}static get availablePaymentMethods(){var e;return(null===(e=Ni.lookup)||void 0===e?void 0:e.body.data.paymentCompositionOptions)||[]}static get authorizeLink(){var e,t;return null===(t=null===(e=Ni.lookup)||void 0===e?void 0:e.body.links.authorize)||void 0===t?void 0:t.href}static get payoutLink(){var e,t;return null===(t=null===(e=Ni.lookup)||void 0===e?void 0:e.body.links.payout)||void 0===t?void 0:t.href}static get createSessionLink(){var e;return null===(e=Ni.response.links.startPaymentSession)||void 0===e?void 0:e.href}static get createInstrumentLink(){var e;return null===(e=Ni.response.links.createInstrument)||void 0===e?void 0:e.href}static get storedPaymentInstruments(){return Ni.availablePaymentMethods.flatMap(e=>e.paymentInstruments||[]).filter(({paymentMethod:e,status:t})=>t===Ti.ENABLED||![exports.PAYMENT_METHOD_CODES.GOOGLE_PAY,exports.PAYMENT_METHOD_CODES.PAYPAL].includes(e))}static get storedDropinInstruments(){return Ni.storedPaymentInstruments.filter(({paymentMethod:e})=>![exports.PAYMENT_METHOD_CODES.GOOGLE_PAY,exports.PAYMENT_METHOD_CODES.APPLE_PAY].includes(e))}static getFullPaymentMethodConfig(e){return Ni.availablePaymentMethods.find(({paymentMethodCode:t})=>t===e)}static isAddressSelectorEnabled(e){var t,i;return!!Ni._response&&(null===(i=null===(t=Ni.getFullPaymentMethodConfig(e))||void 0===t?void 0:t.clientConfig)||void 0===i?void 0:i.supportsBillingInfo)}static isPaymentInstallmentsEnabled(e){var t;if(Ni._response){const i=this.getFullPaymentMethodConfig(e);return i&&(null===(t=this.getPaymentMethodConfig(i).clientConfig)||void 0===t?void 0:t.supportsInstallments)}return!1}static getPaymentInstallmentOptions(e){var t;const i=this.getFullPaymentMethodConfig(e);return i&&(null===(t=this.getPaymentMethodConfig(i).clientConfig)||void 0===t?void 0:t.installments)||{}}static getStoredInstrumentForPaymentMethod(e){var t;return(null===(t=this.availablePaymentMethods.find(({paymentMethodCode:t})=>t===e))||void 0===t?void 0:t.paymentInstruments)||[]}static getPaymentMethodForStoredInstrument(e){const t=this.availablePaymentMethods.find(({paymentInstruments:t})=>null==t?void 0:t.some(({id:t})=>t===e.id));return t&&this.getPaymentMethodConfig(t)}static getPaymentMethodConfig(t){return e(t,["paymentInstruments"])}static updateInstallmentOptions(e){const t=Ni.getFullPaymentMethodConfig(exports.PAYMENT_METHOD_CODES.CARD);(null==t?void 0:t.clientConfig)&&(t.clientConfig.installments=e)}}!function(e){e.REDIRECT="redirect",e.DIRECT="direct",e.EMBEDDED="embedded"}(Ci||(Ci={})),exports.INTEGRATION_TYPE=void 0,(Ri=exports.INTEGRATION_TYPE||(exports.INTEGRATION_TYPE={})).API="api",Ri.HPP="hpp";class Si{constructor(){this._config=void 0}static getInstance(){return Si._instance||(Si._instance=new Si),Si._instance}set config(e){try{Si.getInstance()._config=e}catch(e){o.PayrailsLogger.error("Error parsing SDK Configuration",{error:e})}}get config(){return Si.getInstance()._config||o.PayrailsLogger.error("SDK Configuration not set"),Si.getInstance()._config||{}}}const Pi=()=>Si.getInstance().config,bi=e=>{try{const t=JSON.parse(function(e){const t=window.atob(e);return decodeURIComponent(Array.prototype.map.call(t,e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""))}(e.data));Si.getInstance().config=t,t.execution&&Ni.setResponse(t.execution)}catch(e){o.PayrailsLogger.error("Error parsing SDK Configuration",{error:e})}},Di=(e=window,t=navigator)=>{const i={userAgent:t.userAgent,language:t.language,screenHeight:e.screen.height,screenWidth:e.screen.width,colorDepth:e.screen.colorDepth,timeZoneOffset:(new Date).getTimezoneOffset(),acceptHeader:"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",javaEnabled:!1,javaScriptEnabled:!0},n=Mi(t.userAgent);return n&&(i.osType=n),i},Mi=e=>/android/i.test(e)?"android":/iphone|ipad|ipod/i.test(e)?"ios":/windows|linux|mac/i.test(e)?"web":void 0,wi={success:"https://assets.payrails.io/html/payrails-success.html",error:"https://assets.payrails.io/html/payrails-error.html",cancel:"https://assets.payrails.io/html/payrails-cancel.html",pending:"https://assets.payrails.io/html/payrails-pending.html"};class ki{static getInstance(){return this.instance||(this.instance=new ki),this.instance}constructor(e=""){this.lastActionUpdateTime=e,ki.instance=this}}class Yi{constructor(e=wi,t=680,i=60,n=2e3,s=5,o=ki.getInstance()){this.returnLinks=e,this.POLL_INTERVAL=t,this.MAX_POLL_ATTEMPTS=i,this.POLL_INITIAL_DELAY=n,this.POLL_ERROR_COUNT_MULTIPLIER=s,this.paymentStatus=o}pay(e){return t(this,void 0,void 0,function*(){try{const t=(yield this.authorize(e)).res.links.execution;return yield this.pollForAuthorizationResult(t)}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR,{cause:e});throw o.PayrailsLogger.error(t.message,{error:t}),e}})}payout(e){return t(this,void 0,void 0,function*(){try{const t=(yield this.executePayout(e)).res.links.execution;return yield this.pollForAuthorizationResult(t)}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAYOUT_ERROR,{cause:e});throw o.PayrailsLogger.error(t.message,{error:t}),e}})}confirm(e){return t(this,arguments,void 0,function*(e,t={}){try{const i=yield h({url:e,method:_.POST,token:Pi().token,body:{data:t}}),n=yield this.pollForAuthorizationResult(i.res.links.execution);if(n.finalState)return n;const s=n.response.status.slice().sort((e,t)=>new Date(t.time).getTime()-new Date(e.time).getTime())[0].time,{res:o}=yield this.getExecution(i.res.links.execution,s);return{finalState:o.status.find(({code:e,time:t})=>["authorizeSuccessful","authorizeFailed"].includes(e)&&new Date(t)>new Date(s)),response:o}}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR,{cause:e});throw o.PayrailsLogger.error(t.message,{error:t}),e}})}getExecution(e,i){return t(this,arguments,void 0,function*(e,t,i=0,n){if(i>this.MAX_POLL_ATTEMPTS)throw new y(e,_.GET);0===i&&t?yield this.wait(this.POLL_INITIAL_DELAY,n):yield this.wait(this.POLL_INTERVAL,n);try{const s=yield h({url:e,token:Pi().token});if(t){if(!s.res.status.find(({time:e})=>new Date(e)>new Date(t)))return yield this.wait(this.POLL_INTERVAL,n),this.getExecution(e,t,i+1,n)}return s}catch(s){if(s instanceof m)return yield this.wait(this.POLL_INTERVAL,n),this.getExecution(e,t,i+this.POLL_ERROR_COUNT_MULTIPLIER,n);if(s instanceof v)return yield this.wait(this.POLL_INTERVAL*i,n),this.getExecution(e,t,i+1,n);throw s}})}createApplePaySession(e){return t(this,void 0,void 0,function*(){return h({url:e.requestUrl,method:_.POST,token:Pi().token,body:{integrationType:"api",paymentMethodCode:"applePay",amount:Pi().amount,meta:{sessionURL:e.sessionUrl,clientContext:{host:e.clientDomain||window.location.host}}}})})}authorize(e){return t(this,void 0,void 0,function*(){if(!Ni.authorizeLink||!Pi().amount){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND,{description:"SDK was not initialized with workflow execution"});throw o.PayrailsLogger.error(e.message,{error:e}),e}const{success:t=wi.success,error:i=wi.error,cancel:n=wi.cancel,pending:r=wi.pending}=this.returnLinks,a=this.attachMetaToPaymentComposition({amount:Pi().amount,paymentComposition:e,returnInfo:{success:t,cancel:n,error:i,pending:r}});return h({url:Ni.authorizeLink,method:_.POST,token:Pi().token,body:a})})}executePayout(e){return t(this,void 0,void 0,function*(){if(!Ni.payoutLink||!Pi().amount){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND,{description:"SDK was not initialized with workflow execution"});throw o.PayrailsLogger.error(e.message,{error:e}),e}const t={amount:Pi().amount,payoutComposition:e};return h({url:Ni.payoutLink,method:_.POST,token:Pi().token,body:t})})}getFirstNonFraudNetId(e){const t=Object.keys(e||{}).find(e=>"fraudNet"!==e);return t?e[t]:null}attachMetaToPaymentComposition(e){var t,i,n,s,o,r,a;let l;l=e.paymentComposition[0].paymentMethodCode===exports.PAYMENT_METHOD_CODES.PAYPAL&&(null===(i=null===(t=window.PayrailsData)||void 0===t?void 0:t.riskIds)||void 0===i?void 0:i.fraudNet)?null===(s=null===(n=window.PayrailsData)||void 0===n?void 0:n.riskIds)||void 0===s?void 0:s.fraudNet:this.getFirstNonFraudNetId(null===(o=window.PayrailsData)||void 0===o?void 0:o.riskIds)||"";const d=Object.assign(Object.assign({},e),{meta:Object.assign({},e.meta)});return!1!==(null===(r=Oi.telemetry)||void 0===r?void 0:r.collectMetadata)&&(d.meta=Object.assign(Object.assign({},d.meta),{clientContext:Object.assign(Object.assign({},(null===(a=d.meta)||void 0===a?void 0:a.clientContext)||{}),Di())})),l&&(d.meta.risk={sessionId:l}),d}wait(e,i){return t(this,void 0,void 0,function*(){var t;if(null==i?void 0:i.aborted)throw null!==(t=i.reason)&&void 0!==t?t:new DOMException("Aborted","AbortError");return new Promise((t,n)=>{const s=setTimeout(()=>{null==i||i.removeEventListener("abort",o),t()},e),o=()=>{var e;clearTimeout(s),null==i||i.removeEventListener("abort",o),n(null!==(e=null==i?void 0:i.reason)&&void 0!==e?e:new DOMException("Aborted","AbortError"))};null==i||i.addEventListener("abort",o,{once:!0})})})}pollForAuthorizationResult(e){return t(this,arguments,void 0,function*(e,t=0,i=["authorizePending","authorizeSuccessful","authorizeFailed","payoutPending","payoutSuccessful","payoutFailed"],n){var r;const a=null==n?void 0:n.signal;if(null==a?void 0:a.aborted)throw null!==(r=a.reason)&&void 0!==r?r:new DOMException("Aborted","AbortError");const l=(yield this.getExecution(e,this.paymentStatus.lastActionUpdateTime,t,a)).res,d=l.status,c=d.find(({code:e})=>"authorizeRequested"===e||"payoutRequested"===e);if(!c&&t<10)return yield this.wait(this.POLL_INTERVAL,a),this.pollForAuthorizationResult(e,t+1,i,{signal:a});if(!c){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED);throw o.PayrailsLogger.error(e.message,{error:e}),e}const u=d.find(({code:e,time:t})=>"confirmRequested"===e&&new Date(t)>new Date(c.time)),p=u?u.time:c.time,_=d.filter(({code:e,time:t})=>i.includes(e)&&new Date(t)>new Date(p)).sort((e,t)=>new Date(t.time).getTime()-new Date(e.time).getTime())[0];return _?(this.paymentStatus.lastActionUpdateTime=_.time,{finalState:_,response:l}):this.pollForAuthorizationResult(e,t+1,i,{signal:a})})}}
|
|
4
|
+
*/const re={IFRAME_SECURE_SITE:"https://js.skyflow.com/v1/elements/index.html",IFRAME_SECURE_ORGIN:"https://js.skyflow.com"},ae="https://assets.payrails.io/e38a94f/card/index.html",le="https://assets.payrails.io",de={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no",style:"width: 100%;",allow:"clipboard-read; clipboard-write"},ce=(e,t)=>{Object.keys(t).forEach(i=>{if(Object.prototype.hasOwnProperty.call(t,i)){const n=t[i];null==n?e.removeAttribute(i):e.setAttribute(i,n)}})};var ue=(e={})=>{const t=document.createElement("iframe"),i=Object.assign(Object.assign({},de),e);return Object.assign(t.style,W),ce(t,i),t.getAttribute("id")||(t.id=t.name),t};const pe=()=>re.IFRAME_SECURE_SITE,_e=(e,t)=>{Object.keys(t).forEach(i=>{Object.prototype.hasOwnProperty.call(t,i)&&(e.style[i]=t[i])})};function he(e){return JSON.parse(JSON.stringify(e))}var Ee,me,ve,ye,Ie,fe,Ae;!function(e){e.DEFAULT="DEFAULT",e.PLAIN_TEXT="PLAIN_TEXT",e.MASKED="MASKED",e.REDACTED="REDACTED"}(Ee||(Ee={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH",e.DELETE="DELETE"}(me||(me={})),function(e){e.CHANGE="CHANGE",e.READY="READY",e.FOCUS="FOCUS",e.BLUR="BLUR",e.SUBMIT="SUBMIT"}(ve||(ve={})),function(e){e.WARN="WARN",e.INFO="INFO",e.DEBUG="DEBUG",e.ERROR="ERROR"}(ye||(ye={})),function(e){e.DEV="DEV",e.PROD="PROD"}(Ie||(Ie={})),function(e){e.LOG="LOG",e.WARN="WARN",e.ERROR="ERROR"}(fe||(fe={})),function(e){e.REGEX_MATCH_RULE="REGEX_MATCH_RULE",e.LENGTH_MATCH_RULE="LENGTH_MATCH_RULE",e.ELEMENT_VALUE_MATCH_RULE="ELEMENT_VALUE_MATCH_RULE"}(Ae||(Ae={}));const Le={DEBUG:{showDebugLogs:!0,showInfoLogs:!0,showWarnLogs:!0,showErrorLogs:!0},INFO:{showDebugLogs:!1,showInfoLogs:!0,showWarnLogs:!0,showErrorLogs:!0},WARN:{showDebugLogs:!1,showInfoLogs:!1,showWarnLogs:!0,showErrorLogs:!0},ERROR:{showDebugLogs:!1,showInfoLogs:!1,showWarnLogs:!1,showErrorLogs:!0}},Oe={PROD:{doesReturnValue:!1},DEV:{doesReturnValue:!0}},ge="[Skyflow]",Te=(e,t,i)=>{if(i&&Le[i]){const{showDebugLogs:n,showInfoLogs:s,showWarnLogs:o,showErrorLogs:r}=Le[i];t===fe.LOG&&n?console.log(`${ye.DEBUG}: ${ge} ${e}`):t===fe.LOG&&s?console.log(`${ye.INFO}: ${ge} ${e}`):t===fe.WARN&&o?console.warn(`${ye.WARN}: ${ge} ${e}`):t===fe.ERROR&&r&&console.error(`${ye.ERROR}: ${ge} ${e}`)}},Ce=(...e)=>{const t=e[0],i=e.filter((e,t)=>0!==t);return t?t.replace(/%s[0-9]+/g,e=>{const t=e.replace("%s","")-1;return i[t]}):""},Re=(e="")=>{const t=e.split(":");if("group"===t[1])return"composable container";let i=atob(t[2]);return-1!==i.indexOf(":")&&(i=i.substring(0,i.indexOf(":"))),i},Ne=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_RECORDS_KEY_MISSING_IN_ADDITIONAL_FIELDS);const{records:t}=e;if(!t||!Array.isArray(t))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_RECORDS_IN_ADDITIONAL_FIELDS);if(0===t.length)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_RECORDS_IN_ADDITIONAL_FIELDS);t.forEach((e,t)=>{var i,n,o,r;if(!e||!Object.prototype.hasOwnProperty.call(e,"table"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_TABLE_IN_ADDITIONAL_FIELDS);if(!e.table)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_TABLE_IN_ADDITIONAL_FIELDS);if(void 0!==(null===(i=e.fields)||void 0===i?void 0:i.skyflowID)){if(!(null===(n=e.fields)||void 0===n?void 0:n.skyflowID))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_SKYFLOW_ID);if(!("string"==typeof(null===(o=e.fields)||void 0===o?void 0:o.skyflowID)||(null===(r=e.fields)||void 0===r?void 0:r.skyflowID)instanceof String))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_SKYFLOW_ID)}if(!("string"==typeof e.table||e.table instanceof String))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_IN_ADDITIONAL_FIELDS);if(!Object.prototype.hasOwnProperty.call(e,"fields"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_FIELDS_IN_ADDITIONAL_FIELDS);if(!e.fields)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_FIELDS_IN_ADDITIONAL_FIELDS);if("object"!=typeof e.fields||Array.isArray(e.fields))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_FIELDS_IN_ADDITIONAL_FIELDS)})},Se=e=>{let t=!0;try{new RegExp(e)}catch(e){t=!1}return t},Pe=e=>{if(!Object.prototype.hasOwnProperty.call(e,"getBearerToken"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_GET_BEARER_TOKEN_MISSING)},be=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_ELEMENT_TYPE);if(!e.type)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_TYPE);if(Object.prototype.hasOwnProperty.call(e,"altText")&&Te(T.COLLECT_ALT_TEXT_DEPERECATED,fe.WARN,t),Object.prototype.hasOwnProperty.call(e,"skyflowID")&&"string"!=typeof e.skyflowID)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_SKYFLOW_ID)},De=e=>{if(!e||!Array.isArray(e))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_UPSERT_OPTION_TYPE);if(!e.length)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_UPSERT_OPTIONS_ARRAY);e.forEach((e,t)=>{if(!e||"object"!=typeof e)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_UPSERT_OPTION_OBJECT_TYPE);if(!Object.prototype.hasOwnProperty.call(e,"table"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_TABLE_IN_UPSERT_OPTION);if(!e.table||"string"!=typeof e.table||!e.table.length)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_IN_UPSERT_OPTION);if(!Object.prototype.hasOwnProperty.call(e,"column"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_COLUMN_IN_UPSERT_OPTION);if(!e.column||"string"!=typeof e.column||!e.column.length)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COLUMN_IN_UPSERT_OPTION)})},Me=e=>"boolean"==typeof e;function we(e){const t=e.split(":");return t.length>2?(t.pop(),t.pop(),t.join(":")):""}const ke=(e,t,i)=>{if("string"!=typeof e)return e;if(t===G.CARD_NUMBER){if(e=e&&e.replace(/\s/g,""),!i){((e="")=>{const t=e.replace(/[\s-]/g,"");let i=X.DEFAULT;Object.entries(J).forEach(([e,n])=>{n.regex.test(t)&&(i=e)})})(e);const t=e.length<=15?6:8;return e.length>t?e.replace(new RegExp(`.(?=.{0,${(null==e?void 0:e.length)-t-1}}$)`,"g"),"X"):e}return e}return i?e:void 0};function Ye(e){var t,i,n,s;if((null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.customElementsURL)&&(e=>{if(!e||"https"!==e.substring(0,5).toLowerCase())return!1;try{if(new URL(e))return!0}catch(e){return!1}return!0})(null===(i=null==e?void 0:e.options)||void 0===i?void 0:i.customElementsURL)){const t=null===(n=null==e?void 0:e.options)||void 0===n?void 0:n.customElementsURL,i=new URL(t),o=i.protocol,r=i.hostname;re.IFRAME_SECURE_ORGIN=`${o}//${r}`,re.IFRAME_SECURE_SITE=null===(s=null==e?void 0:e.options)||void 0===s?void 0:s.customElementsURL}re.IFRAME_SECURE_ORGIN=le,re.IFRAME_SECURE_SITE=ae}class Ue{constructor(e,t,i,n){this.setAttributess=e=>{ce(this.iframe,{src:e})},this.mount=e=>{var t;this.unmount();try{if("string"==typeof e){if(this.container=document.querySelector(e)||void 0,!this.container)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_SELECTOR)}else{if(!(e instanceof HTMLElement))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_SELECTOR);this.container=e}}catch(e){console.error(e)}ce(this.iframe,{src:pe(),title:"Secure Credit Card Form","aria-label":"Secure payment form",role:"application",tabindex:"0"}),null===(t=this.container)||void 0===t||t.appendChild(this.iframe)},this.setIframeHeight=e=>{this.iframe.getAttribute("height")!==`${e}px`&&this.iframe.setAttribute("height",`${e}px`)},this.unmount=()=>{this.iframe.remove()},this.name=`${e}:${i}:${n}`,this.metadata=t,this.iframe=ue({name:this.name})}}class xe{}var Fe,je,Be,Ve,Ge,Xe,ze,He,qe,We,Ke,$e,Ze,Je,Qe,et,tt,it,nt,st,ot;const rt="Element";class at extends xe{constructor(t,o,r,a,l=!1,d,c,u,p){var _;super(),this.type=Ii.COLLECT,Fe.set(this,void 0),je.set(this,!1),Be.set(this,void 0),Ve.set(this,void 0),Ge.set(this,{isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:void 0,isRequired:!1}),Xe.set(this,void 0),ze.set(this,new oe),He.set(this,void 0),qe.set(this,L.getEventBus()),We.set(this,void 0),Ke.set(this,[]),$e.set(this,!1),Ze.set(this,void 0),Je.set(this,void 0),Qe.set(this,!1),this.getID=()=>i(this,Fe,"f"),this.mount=t=>{var o;if(!t)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_IN_MOUNT);const r=(t,s)=>{if(t.name===i(this,We,"f").name){s(i(this,Xe,"f")),i(this,ot,"f").call(this);const t=e(i(this,Be,"f")[0],["name"]);i(this,Ve,"f").length>1?i(this,Ve,"f").forEach((e,t)=>{i(this,He,"f")&&i(this,He,"f")._emit(`${S.READY}:${e.elementName}`,Object.assign(Object.assign({},i(this,Be,"f")[t]),{elementType:e.elementType}))}):i(this,ze,"f")._emit(S.READY,Object.assign({},t)),i(this,qe,"f").off(P+this.containerId,r),Te(`${Ce(O.ELEMENT_MOUNTED,rt,Re(i(this,We,"f").name))} `,fe.LOG,i(this,Ze,"f").logLevel),i(this,Ke,"f").forEach(e=>e()),n(this,Ke,[],"f")}};if(i(this,Ve,"f").length>1)i(this,We,"f").mount(t),i(this,qe,"f").on(P+this.containerId,r);else{if(i(this,Qe,"f"))return i(this,We,"f").mount(t),void i(this,qe,"f").on(P+this.containerId,r);null===(o=i(this,He,"f"))||void 0===o||o.on(V,e=>{(null==e?void 0:e.containerId)===this.containerId&&(i(this,We,"f").mount(t),i(this,qe,"f").on(P+this.containerId,r))})}},this.unmount=()=>{i(this,qe,"f").off(M,i(this,nt,"f")),i(this,We,"f").unmount()},this.update=e=>{let t=he(e);const s=()=>{i(this,je,"f")&&(t={rows:[{elements:[Object.assign({},t)]}]}),n(this,Xe,dt(i(this,Xe,"f"),t),"f"),n(this,Ve,ct(i(this,Xe,"f")),"f"),i(this,je,"f")?i(this,qe,"f").emit(k,{name:i(this,We,"f").name,options:i(this,Ve,"f")[0],isSingleElementAPI:!0}):(i(this,Ve,"f").forEach(e=>{i(this,qe,"f").emit(k,{name:e.elementName,options:e,isSingleElementAPI:!0})}),i(this,qe,"f").emit(k,{name:i(this,We,"f").name,options:i(this,Xe,"f"),isSingleElementAPI:!1})),i(this,ot,"f").call(this)};i(this,$e,"f")?s():i(this,Ke,"f").push(s)},et.set(this,e=>{i(this,je,"f")||i(this,ze,"f").on(k,()=>{e(i(this,Ve,"f"))},!0)}),this.updateElement=e=>{i(this,qe,"f").emit(k,{name:e.elementName,options:e,isSingleElementAPI:!0})},tt.set(this,()=>{i(this,Be,"f").forEach((e,t)=>{var n;if(0===t){i(this,Ge,"f").isEmpty=e.isEmpty,i(this,Ge,"f").isComplete=e.isComplete,i(this,Ge,"f").isValid=e.isValid,i(this,Ge,"f").isFocused=e.isFocused,i(this,Ge,"f").isRequired=e.isRequired,i(this,Ge,"f").value={};const n=i(this,Ve,"f")[t].elementName,s=e.value&&ke(e.value,e.elementType,i(this,Je,"f"));i(this,je,"f")?i(this,Ge,"f").value=s:i(this,Ge,"f").value[n]=s}else i(this,Ge,"f").isEmpty=i(this,Ge,"f").isEmpty||e.isEmpty,i(this,Ge,"f").isComplete=i(this,Ge,"f").isComplete&&e.isComplete,i(this,Ge,"f").isValid=i(this,Ge,"f").isValid&&e.isValid,i(this,Ge,"f").isFocused=i(this,Ge,"f").isFocused||e.isFocused,i(this,Ge,"f").isRequired=i(this,Ge,"f").isRequired||e.isRequired,i(this,Ge,"f").value||(i(this,Ge,"f").value={}),!i(this,Ve,"f")[t]&&(null===(n=i(this,Ve,"f")[t])||void 0===n?void 0:n.sensitive)&&(i(this,Ge,"f").value[i(this,Ve,"f")[t].elementName]=e.value||"")})}),this.getState=()=>({isEmpty:i(this,Ge,"f").isEmpty,isComplete:i(this,Ge,"f").isComplete,isValid:i(this,Ge,"f").isValid,isFocused:i(this,Ge,"f").isFocused,value:i(this,Ge,"f").value,required:i(this,Ge,"f").isRequired}),this.getOptions=()=>{let e=he(i(this,Xe,"f"));return i(this,je,"f")?e=e.rows[0].elements[0]:e.rows.forEach(e=>{e.elements.forEach(e=>{delete e.elementName})}),delete e.elementName,e},it.set(this,e=>{i(this,ze,"f").on(w,()=>{const t=i(this,Ve,"f").map(e=>e.elementName);i(this,je,"f")||t.push(i(this,We,"f").name),e(t)},!0)}),nt.set(this,e=>{if(i(this,je,"f")&&e.event===S.READY&&e.name===i(this,We,"f").name)i(this,ze,"f")._emit(S.READY);else{const t=i(this,Ve,"f").length>1;i(this,Ve,"f").forEach((n,o)=>{var r;if(e.name===n.elementName){let a="";switch(e.event){case S.FOCUS:a=S.FOCUS;break;case S.BLUR:a=S.BLUR;break;case S.CHANGE:a=S.CHANGE;break;case S.READY:a=S.READY;break;case S.SUBMIT:return void(null===(r=i(this,He,"f"))||void 0===r||r._emit(S.SUBMIT));default:throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_TYPE)}i(this,Be,"f")[o].isEmpty=e.value.isEmpty,i(this,Be,"f")[o].isValid=e.value.isValid,i(this,Be,"f")[o].isComplete=e.value.isComplete,i(this,Be,"f")[o].isFocused=e.value.isFocused,i(this,Be,"f")[o].isRequired=e.value.isRequired,Object.prototype.hasOwnProperty.call(e.value,"value")?i(this,Be,"f")[o].value=e.value.value:i(this,Be,"f")[o].value=void 0,a=t?`${a}:${e.name}`:a,i(this,qe,"f").emit(S.HEIGHT+i(this,We,"f").name,{},e=>{i(this,We,"f").setIframeHeight(e.height)}),i(this,tt,"f").call(this);const l=Object.assign(Object.assign({},i(this,Be,"f")[o]),{elementType:n.elementType});t&&i(this,He,"f")?i(this,He,"f")._emit(a,l):i(this,ze,"f")._emit(a,l)}})}}),st.set(this,()=>{i(this,qe,"f").on(M,i(this,nt,"f"))}),ot.set(this,()=>{const{rows:e}=i(this,Xe,"f");e.forEach(e=>{e.elements.forEach(e=>{e.elementType!==H.radio.name&&e.elementType!==H.checkbox.name&&(e.value=void 0)})}),n(this,Ve,ct(i(this,Xe,"f")),"f")}),this.containerId=a.containerId,n(this,Fe,t,"f"),n(this,Ze,u,"f"),n(this,Xe,dt(o),"f"),n(this,Ve,ct(o),"f"),n(this,je,l,"f"),p&&n(this,He,p,"f"),n(this,Je,Oe[i(this,Ze,"f").env].doesReturnValue,"f"),this.elementType=i(this,je,"f")?i(this,Ve,"f")[0].elementType:"group",n(this,Be,[],"f"),i(this,Ve,"f").forEach(e=>{i(this,Be,"f").push({isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:i(this,Je,"f")?"":void 0,elementType:e.elementType,name:e.elementName,isRequired:!1})}),n(this,We,new Ue(i(this,Xe,"f").elementName,r,this.containerId,i(this,Ze,"f").logLevel),"f"),i(this,st,"f").call(this),i(this,it,"f").call(this,d),i(this,et,"f").call(this,c),Te(Ce(O.CREATED_ELEMENT,rt,Re(i(this,We,"f").name)),fe.LOG,i(this,Ze,"f").logLevel),n(this,Qe,a.isMounted,"f"),null===(_=i(this,He,"f"))||void 0===_||_.on(V,e=>{(null==e?void 0:e.containerId)===this.containerId&&n(this,Qe,!0,"f")});const h=e=>{e.height&&e.height>0&&i(this,We,"f").setIframeHeight(e.height)};i(this,qe,"f").on(S.MOUNTED,e=>{a.type===Ii.COMPOSABLE?i(this,Ve,"f").forEach(t=>{e.name===t.elementName&&(t.isMounted=!0,n(this,$e,!0,"f"))}):e.name===i(this,Ve,"f")[0].elementName&&(i(this,Ve,"f")[0].isMounted=!0,n(this,$e,!0,"f")),i(this,qe,"f").emit(S.HEIGHT+i(this,We,"f").name,{},h)})}on(e,t){if(!Object.values(S).includes(e))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_LISTENER);if(!t)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_HANDLER_IN_EVENT_LISTENER);if("function"!=typeof t)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_HANDLER_IN_EVENT_LISTENER);i(this,ze,"f").on(e,e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,t(e)})}iframeName(){return i(this,We,"f").name}isMounted(){return i(this,$e,"f")}isValidElement(){for(let e=0;e<i(this,Ve,"f").length;e+=1){if(!Object.prototype.hasOwnProperty.call(i(this,Ve,"f")[e],"table"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_TABLE_NAME_MISSING);if(!i(this,Ve,"f")[e].table)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_TABLE);if(!("string"==typeof i(this,Ve,"f")[e].table||i(this,Ve,"f")[e].table instanceof String))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_NAME);if(!Object.prototype.hasOwnProperty.call(i(this,Ve,"f")[e],"column"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_COLUMN);if(!i(this,Ve,"f")[e].column)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_COLUMN);if(!("string"==typeof i(this,Ve,"f")[e].column||i(this,Ve,"f")[e].column instanceof String))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COLUMN);if(void 0!==i(this,Ve,"f")[e].skyflowID&&!i(this,Ve,"f")[e].skyflowID)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_SKYFLOW_ID)}return!0}setError(e){i(this,qe,"f").emit(x,{name:we(i(this,We,"f").name),isTriggerError:!0,clientErrorText:e})}resetError(){i(this,qe,"f").emit(x,{name:we(i(this,We,"f").name),isTriggerError:!1})}setValue(e){i(this,Ze,"f").env!==Ie.PROD?i(this,je,"f")&&i(this,qe,"f").emit(k,{name:i(this,We,"f").name,options:Object.assign(Object.assign({},i(this,Ve,"f")[0]),{value:e}),isSingleElementAPI:!0}):Te(Ce(T.UNABLE_TO_SET_VALUE_IN_PROD_ENV,i(this,Ve,"f")[0].elementType),fe.WARN,i(this,Ze,"f").logLevel)}clearValue(){i(this,Ze,"f").env!==Ie.PROD?i(this,je,"f")&&i(this,qe,"f").emit(k,{name:i(this,We,"f").name,options:Object.assign(Object.assign({},i(this,Ve,"f")[0]),{value:""}),isSingleElementAPI:!0}):Te(Ce(T.UNABLE_TO_CLEAR_VALUE_IN_PROD_ENV,i(this,Ve,"f")[0].elementType),fe.WARN,i(this,Ze,"f").logLevel)}setAttribute(e,t){i(this,qe,"f").emit(Y,{name:i(this,We,"f").name,attribute:e,value:t})}focus(){var e;if(!(null===(e=i(this,Ve,"f"))||void 0===e?void 0:e.length))return;const t=this.getState();i(this,qe,"f").emit(M,{name:i(this,Ve,"f")[0].elementName,event:S.FOCUS,value:{isEmpty:t.isEmpty,isValid:t.isValid,isComplete:t.isComplete,isFocused:!0,isRequired:t.required,value:t.value}})}}function lt(e,t,i={}){if("group"!==e&&!Object.prototype.hasOwnProperty.call(H,e))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_TYPE);if(Object.prototype.hasOwnProperty.call(t,"validations")){if(!Array.isArray(t.validations))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATIONS_TYPE);t.validations.forEach((e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_VALIDATION_RULE_TYPE);if(!Object.values(Ae).includes(e.type))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATION_RULE_TYPE);if(!Object.prototype.hasOwnProperty.call(e,"params"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_VALIDATION_RULE_PARAMS);if("object"!=typeof e.params||Array.isArray(e.params)||null===e.params)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATION_RULE_PARAMS);if(e.type===Ae.REGEX_MATCH_RULE){if(!Object.prototype.hasOwnProperty.call(e.params,"regex"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_REGEX_IN_REGEX_MATCH_RULE)}else if(e.type===Ae.LENGTH_MATCH_RULE&&!Object.prototype.hasOwnProperty.call(e.params,"min")&&!Object.prototype.hasOwnProperty.call(e.params,"max"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE)})}if(Object.prototype.hasOwnProperty.call(i,"name")&&i.name!==t.name)throw new Error("Name attribute can't be updated");if((i=Object.assign(Object.assign({},t),i)).mask||i.replacePattern){const{type:t}=H[e].attributes;"text"===t&&"textarea"===t&&"email"===t||(delete i.mask,delete i.replacePattern)}if(void 0===!i.mask&&!Array.isArray(i.mask))throw new Error("mask option has to be array or undefined");if(Array.isArray(i.mask)){const e=i.mask;if("string"!=typeof e[0]||e[1]&&"object"!=typeof e[1])throw new Error("mask array values has to be string")}if(Array.isArray(i.replacePattern)){const e=i.replacePattern;if("string"!=typeof e[0]||e[1]&&"string"!=typeof e[1])throw new Error("replacePatterns array values has to be string")}if((e===H.radio.name||e===H.checkbox.name)&&!i.value)throw new Error("Elements radio and checkbox requires value attribute");if(!(e!==H.dropdown.name||i.options&&Array.isArray(i.options)&&0!==i.options.length))throw new Error("Element dropdown requires options attribute with an array of objects containing value and text attributes")}function dt(e,t={},i=!0){return(t=Object.assign(Object.assign({},e),t)).rows.forEach((n,s)=>{const o=n,r=e.rows[s];t.rows[s]=Object.assign(Object.assign({},r),o),o.elements.forEach((e,t)=>{var n,s;const a=r.elements[t],l=e;if(l.elementType&&a.elementType!==l.elementType&&a.elementName&&a.elementName!==l.elementName)throw new Error(g.CANNOT_CHANGE_ELEMENT);lt(a.elementType,a,l),o.elements[t]=Object.assign(Object.assign(Object.assign({},a),l),{elementName:a.elementName});const d=l.classes||{},c=l.styles||{};c.base=Object.assign(Object.assign({},$),c.base),l.classes=d,l.styles=c;const u=(null===(n=null==l?void 0:l.labelStyles)||void 0===n?void 0:n.classes)||{},p=(null===(s=null==l?void 0:l.labelStyles)||void 0===s?void 0:s.styles)||{};i&&function(e,t){Object.values(Z).forEach(i=>{if(e[i]||t[i])switch(i){case Z.BASE:t[i]=Object.assign({},t[i]);break;case Z.FOCUS:t[Z.BASE]=Object.assign(Object.assign({},t[Z.BASE]),{":focus":Object.assign({},t[Z.BASE]&&t[Z.BASE][":focus"])});break;case Z.WEBPACKAUTOFILL:t[Z.BASE]=Object.assign(Object.assign({},t[Z.BASE]),{":-webkit-autofill":Object.assign({},t[Z.BASE]&&t[Z.BASE][":-webkit-autofill"])});break;default:t[i]=Object.assign(Object.assign({},t[Z.BASE]),t[i])}}),Object.keys(t).forEach(e=>{const i=t[e][":-webkit-autofill"];"object"==typeof i&&Object.keys(i).forEach(e=>{i[e]&&!i[e].includes("!important")&&(i[e]=`${i[e]} !important`)})})}(u,p),l.labelStyles={labelClasses:u},l.labelStyles.styles=p})}),t}Fe=new WeakMap,je=new WeakMap,Be=new WeakMap,Ve=new WeakMap,Ge=new WeakMap,Xe=new WeakMap,ze=new WeakMap,He=new WeakMap,qe=new WeakMap,We=new WeakMap,Ke=new WeakMap,$e=new WeakMap,Ze=new WeakMap,Je=new WeakMap,Qe=new WeakMap,et=new WeakMap,tt=new WeakMap,it=new WeakMap,nt=new WeakMap,st=new WeakMap,ot=new WeakMap;const ct=e=>{const{rows:t}=e,i=[];return t.forEach(e=>{e.elements.forEach(e=>{i.push(e)})}),i},ut=e=>{const t=e.validations;return t&&Array.isArray(t)&&t.length>0&&t.forEach((e,t)=>{if(e&&e.type===Ae.ELEMENT_VALUE_MATCH_RULE){if(e.params&&!Object.prototype.hasOwnProperty.call(e.params,"element"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE);if(e.params&&(null==e.params.element||!(e.params.element instanceof at)))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE);e.params&&e.params.element&&e.params.element instanceof at&&(e.params.element=e.params.element.iframeName())}else if(e&&e.type===Ae.REGEX_MATCH_RULE){if(e.params&&e.params.regex&&!Se(e.params.regex))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_REGEX_IN_REGEX_MATCH_RULE);e.params&&e.params.regex&&Se(e.params.regex)&&(e.params.regex=e.params.regex.toString())}}),t},pt=(e,t,i)=>{let n=Object.assign({required:!1},t);if((Object.prototype.hasOwnProperty.call(n,"format")||Object.prototype.hasOwnProperty.call(n,"translation"))&&(ne.includes(e)?(Te(Ce(T.INPUT_FORMATTING_NOT_SUPPROTED,e),fe.WARN,i),null==n||delete n.format,null==n||delete n.translation):e===H.INPUT_FIELD.name&&((e=>{if(e){if(Object.prototype.hasOwnProperty.call(e,"format")&&"string"!=typeof e.format)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_INPUT_OPTIONS_FORMAT);if(Object.prototype.hasOwnProperty.call(e,"translation")&&("object"!=typeof e.translation||"[object Object]"!==Object.prototype.toString.call(e.translation)))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_INPUT_OPTIONS_TRANSLATION)}})(t),n=Object.assign(Object.assign({},n),{mask:[n.format,n.translation?n.translation:se]}),null==n||delete n.format,null==n||delete n.translation)),e===H.CARD_NUMBER.name){Object.prototype.hasOwnProperty.call(n,"enableCardIcon")||(n=Object.assign(Object.assign({},n),{enableCardIcon:!0}));let e=" ";(null==n?void 0:n.format)===q&&(e="-"),n=Object.assign(Object.assign({},n),{cardSeperator:e}),null==n||delete n.format,null==n||delete n.translation}else if(e===H.EXPIRATION_DATE.name){let e=!1;n.format&&(e=!!(o=n.format.toUpperCase())&&ee.includes(o),e||Te(Ce(T.INVALID_EXPIRATION_DATE_FORMAT,ee.toString()),fe.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():Q}),null==n||delete n.translation}else if(e===H.EXPIRATION_YEAR.name){let e=!1;n.format&&(e=(e=>!!e&&te.includes(e))(n.format.toUpperCase()),e||Te(Ce(T.INVALID_EXPIRATION_YEAR_FORMAT,te.toString()),fe.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():"YY"}),null==n||delete n.translation}var o;if(Object.prototype.hasOwnProperty.call(n,"enableCardIcon")&&!Me(n.enableCardIcon))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_BOOLEAN_OPTIONS,{description:"Interface: container create - Invaild enableCardIcon in options, enableCardIcon of type boolean is required."});if(Object.prototype.hasOwnProperty.call(n,"required")&&!Me(n.required))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_BOOLEAN_OPTIONS,{description:"Interface: container create - Invaild required in options, required of type boolean is required."});return n};function _t(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=crypto.getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*16|0;return("x"===e?t:3&t|8).toString(16)})}class ht{}var Et,mt,vt,yt,It,ft,At,Lt,Ot,gt,Tt,Ct;const Rt="CollectContainer";class Nt extends ht{constructor(e,t,o,r){super(),Et.set(this,void 0),mt.set(this,{}),vt.set(this,void 0),yt.set(this,void 0),It.set(this,void 0),this.type=Ii.COLLECT,ft.set(this,void 0),At.set(this,!1),this.create=(e,t={required:!1})=>{be(e,i(this,yt,"f").logLevel);const n=ut(e),s=pt(e.type,t,i(this,yt,"f").logLevel),o={rows:[{elements:[Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column,accept:t.allowedFileType},e),s),{validations:n})]}]};return i(this,Lt,"f").call(this,o,!0)},Lt.set(this,(e,t=!1)=>{const n=[],o=he(e);if(o.rows.forEach(e=>{e.elements.forEach(e=>{const t=e,{elementType:i}=t;lt(i,t),t.sensitive=t.sensitive||H[i].sensitive,t.replacePattern=t.replacePattern||H[i].replacePattern,t.mask=t.mask||H[i].mask,t.isMounted=!1,t.elementType!==H.radio.name&&t.elementType!==H.checkbox.name||(t.elementName=`${t.elementName}:${btoa(t.value)}`),t.elementName=`${R}:${t.elementType}:${btoa(_t())}`,t.label=e.label,t.skyflowID=e.skyflowID,n.push(t)})}),o.elementName=t?n[0].elementName:`${R}:group:${btoa(o.name)}`,t&&!i(this,mt,"f")[n[0].elementName]&&i(this,Ct,"f").call(this,n[0].name))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_UNIQUE_ELEMENT_NAME);let r=i(this,mt,"f")[o.elementName];if(r)t?r.update(n[0]):r.update(o);else{const e=_t();r=new at(e,o,i(this,vt,"f"),{containerId:i(this,Et,"f"),isMounted:i(this,At,"f"),type:this.type},t,i(this,gt,"f"),i(this,Tt,"f"),i(this,yt,"f"),i(this,ft,"f")),i(this,mt,"f")[o.elementName]=r,i(this,It,"f")[e]=r}return t||n.forEach(e=>{const t=e.elementName;i(this,mt,"f")[t]?i(this,mt,"f")[t].update(e):i(this,mt,"f")[t]=this.create(e.elementType,r)}),r}),Ot.set(this,e=>{Object.keys(i(this,mt,"f")).forEach(t=>{t===e&&delete i(this,mt,"f")[t]})}),gt.set(this,e=>{e.forEach(e=>{i(this,Ot,"f").call(this,e)})}),Tt.set(this,e=>{e.forEach(e=>{i(this,mt,"f")[e.elementName]&&i(this,mt,"f")[e.elementName].update(e)})}),Ct.set(this,e=>{const t=Object.keys(i(this,mt,"f"));for(let i=0;i<t.length;i+=1)if(atob(t[i].split(":")[2])===e)return!0;return!1}),this.validate=()=>new Promise((e,t)=>{Object.values(i(this,mt,"f")).forEach(e=>{if(!e.isMounted())throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);e.isValidElement()}),this.bus.emit(j+i(this,Et,"f"),{},t=>{e(t)})}),this.collect=(e={tokens:!0})=>new Promise((t,n)=>{try{Pe(i(this,vt,"f").clientJSON.config);const o=Object.values(i(this,mt,"f"));let r=Q;if(o.forEach(e=>{if(!e.isMounted())throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);e.isValidElement();const t=e.getOptions();t.elementType===G.EXPIRATION_DATE&&(r=t.format||"MM/YY")}),Object.prototype.hasOwnProperty.call(e,"tokens")&&!Me(e.tokens))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TOKENS);(null==e?void 0:e.additionalFields)&&Ne(e.additionalFields),(null==e?void 0:e.upsert)&&De(null==e?void 0:e.upsert),this.bus.target(re.IFRAME_SECURE_ORGIN).emit(b+i(this,Et,"f"),Object.assign(Object.assign({},Object.assign(Object.assign({},e),{expiryDateFormat:r})),{tokens:void 0===(null==e?void 0:e.tokens)||e.tokens}),e=>{!e||(null==e?void 0:e.error)?(Te(`${JSON.stringify(null==e?void 0:e.error)}`,fe.ERROR,i(this,yt,"f").logLevel),n(null==e?void 0:e.error)):(Te(Ce(O.COLLECT_SUBMIT_SUCCESS,Rt),fe.LOG,i(this,yt,"f").logLevel),t(e))}),Te(Ce(O.EMIT_EVENT,Rt,b),fe.LOG,i(this,yt,"f").logLevel)}catch(e){Te(`${e.message}`,fe.ERROR,i(this,yt,"f").logLevel),n(e)}}),this.unmount=()=>{this.iframe.remove()},this.bus=L.getEventBus(),n(this,Et,_t(),"f"),n(this,vt,Object.assign(Object.assign({},t),(null==e?void 0:e.fonts)?{fonts:e.fonts}:{}),"f"),n(this,It,o,"f"),n(this,yt,r,"f"),n(this,ft,new oe,"f"),this.iframe=ue({name:`${C}:${i(this,Et,"f")}:${i(this,yt,"f").logLevel}`}),ce(this.iframe,{src:pe()}),_e(this.iframe,Object.assign({},K)),Te(Ce(O.CREATE_COLLECT_CONTAINER,Rt),fe.LOG,i(this,yt,"f").logLevel);const a=(e,t)=>{e.name===C+i(this,Et,"f")&&(t(Object.assign(Object.assign({},i(this,vt,"f")),{clientJSON:Object.assign(Object.assign({},i(this,vt,"f").clientJSON),{config:Object.assign({},i(this,vt,"f").clientJSON.config)}),context:i(this,yt,"f")})),n(this,At,!0,"f"),i(this,ft,"f")._emit(V,{containerId:i(this,Et,"f")}),this.bus.target({origin:re.IFRAME_SECURE_ORGIN}).off(P+i(this,Et,"f"),a))};this.bus.target({origin:re.IFRAME_SECURE_ORGIN}).on(P+i(this,Et,"f"),a),document.body.append(this.iframe)}reset(){this.bus.emit(D+i(this,Et,"f"))}}Et=new WeakMap,mt=new WeakMap,vt=new WeakMap,yt=new WeakMap,It=new WeakMap,ft=new WeakMap,At=new WeakMap,Lt=new WeakMap,Ot=new WeakMap,gt=new WeakMap,Tt=new WeakMap,Ct=new WeakMap;const St=(e,t,i)=>{const n=t.split(/[\.\[\]]/g);let s=e;for(const e of n){if(null===s)return i;if(void 0===s)return i;const t=e.replace(/['"]/g,"");""!==t.trim()&&(s=s[t])}return void 0===s?i:s},Pt=(e,t,i)=>{if(!e)return{};if(!t||void 0===i)return e;const n=t.split(/[\.\[\]]/g).filter(e=>!!e.trim()),s=e=>{if(n.length>1){const t=n.shift(),i=null!==((e,t)=>{const i=void 0===t?0:t;if(null==e)return i;const n=parseInt(e);return isNaN(n)?i:n})(n[0],null);e[t]=void 0===e[t]?i?[]:{}:e[t],s(e[t])}else e[n[0]]=i},o=(e=>{if(null==(t=e)||"object"!=typeof t&&"function"!=typeof t)return e;var t;if("function"==typeof e)return e.bind({});const i=new e.constructor;return Object.getOwnPropertyNames(e).forEach(t=>{i[t]=e[t]}),i})(e);return s(o),o};var bt,Dt,Mt,wt,kt,Yt,Ut,xt,Ft,jt,Bt,Vt,Gt,Xt,zt,Ht,qt,Wt,Kt,$t,Zt,Jt,Qt,ei,ti;class ii{constructor(e,t){bt.set(this,void 0),Dt.set(this,void 0),Mt.set(this,L.getEventBus()),wt.set(this,null),this.type=Ii.COMPOSABLE,kt.set(this,!1),Yt.set(this,!1),this.update=e=>{n(this,Yt,!0,"f"),i(this,kt,"f")?(i(this,Dt,"f")._emit(F,{elementName:i(this,bt,"f"),elementOptions:e}),n(this,Yt,!1,"f")):i(this,Yt,"f")&&i(this,Dt,"f").on(`${ve.READY}:${i(this,bt,"f")}`,()=>{i(this,Dt,"f")._emit(F,{elementName:i(this,bt,"f"),elementOptions:e}),n(this,kt,!0,"f"),n(this,Yt,!1,"f")})},n(this,bt,e,"f"),n(this,Dt,t,"f"),i(this,Dt,"f").on(`${ve.READY}:${i(this,bt,"f")}`,()=>{n(this,kt,!0,"f")})}on(e,t){if(!Object.values(S).includes(e))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_LISTENER);if(!t)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_HANDLER_IN_EVENT_LISTENER);if("function"!=typeof t)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_HANDLER_IN_EVENT_LISTENER);i(this,Dt,"f").on(`${e}:${i(this,bt,"f")}`,e=>{if(void 0===e.value&&(e.value=""),"CARD_NUMBER"===e.elementType&&e.value){const{value:t}=e;e.value=t.slice(0,8)}n(this,wt,{isEmpty:e.isEmpty,isValid:e.isValid,isComplete:e.isComplete,isFocused:e.isFocused,isRequired:e.isRequired,value:e.value},"f"),delete e.isComplete,delete e.name,t(e)})}focus(){const e=i(this,wt,"f")||{isEmpty:!0,isValid:!1,isComplete:!1,isFocused:!0,isRequired:!1};i(this,Mt,"f").emit(M,{name:i(this,bt,"f"),event:S.FOCUS,value:Object.assign(Object.assign({},e),{isFocused:!0})})}setAttribute(e,t){i(this,Dt,"f")._emit(Y,{elementName:i(this,bt,"f"),attribute:e,value:t})}}bt=new WeakMap,Dt=new WeakMap,Mt=new WeakMap,wt=new WeakMap,kt=new WeakMap,Yt=new WeakMap;const ni="CollectContainer";class si extends ht{constructor(e,t,r,a){super(),Ut.set(this,void 0),xt.set(this,{}),Ft.set(this,void 0),jt.set(this,{rows:[]}),Bt.set(this,[]),Vt.set(this,void 0),Gt.set(this,void 0),Xt.set(this,void 0),zt.set(this,!1),Ht.set(this,void 0),qt.set(this,void 0),this.type=Ii.COMPOSABLE,Wt.set(this,!1),Kt.set(this,{}),this.create=(e,t={required:!1})=>{be(e,i(this,Vt,"f").logLevel);const n=ut(e),s=pt(e.type,t,i(this,Vt,"f").logLevel),o=`${R}:${e.type}:${btoa(_t())}`;return i(this,Bt,"f").push(Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column},e),s),{validations:n,elementName:o})),new ii(o,i(this,Xt,"f"))},$t.set(this,(e,t=!1)=>{const o=[];if(n(this,xt,{},"f"),n(this,Kt,he(e),"f"),i(this,Kt,"f").rows.forEach(e=>{e.elements.forEach(e=>{const t=e,{elementType:i}=t;lt(i,t),t.sensitive=t.sensitive||H[i].sensitive,t.replacePattern=t.replacePattern||H[i].replacePattern,t.mask=t.mask||H[i].mask,t.isMounted=!1,t.label=e.label,t.skyflowID=e.skyflowID,o.push(t)})}),i(this,Kt,"f").elementName=t?o[0].elementName:`${R}:group:${btoa(i(this,Kt,"f").name)}`,t&&!i(this,xt,"f")[o[0].elementName]&&i(this,ei,"f").call(this,o[0].name))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_UNIQUE_ELEMENT_NAME);let r=i(this,xt,"f")[i(this,Kt,"f").elementName];if(r)t?r.update(o[0]):r.update(i(this,Kt,"f"));else{const e=_t();r=new at(e,i(this,Kt,"f"),i(this,Ft,"f"),{containerId:i(this,Ut,"f"),isMounted:i(this,Wt,"f"),type:this.type},!0,i(this,Jt,"f"),i(this,Qt,"f"),i(this,Vt,"f"),i(this,Xt,"f")),i(this,xt,"f")[i(this,Kt,"f").elementName]=r,i(this,Gt,"f")[e]=r}return r}),Zt.set(this,e=>{Object.keys(i(this,xt,"f")).forEach(t=>{t===e&&delete i(this,xt,"f")[t]})}),Jt.set(this,e=>{e.forEach(e=>{i(this,Zt,"f").call(this,e)})}),Qt.set(this,e=>{e.forEach(e=>{i(this,xt,"f")[e.elementName]&&i(this,xt,"f")[e.elementName].update(e)})}),ei.set(this,e=>{const t=Object.keys(i(this,xt,"f"));for(let i=0;i<t.length;i+=1)if(atob(t[i].split(":")[2])===e)return!0;return!1}),this.on=(e,t)=>{if(!Object.values(S).includes(e))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_LISTENER);if(!t)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_HANDLER_IN_EVENT_LISTENER);if("function"!=typeof t)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_HANDLER_IN_EVENT_LISTENER);i(this,Xt,"f").on(S.SUBMIT,()=>{t()})},this.mount=e=>{if(!e)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_IN_MOUNT);n(this,jt,{rows:[]},"f");const{layout:t}=i(this,Ht,"f");if((t||[]).reduce((e,t)=>e+t,0)!==i(this,Bt,"f").length)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISMATCH_ELEMENT_COUNT_LAYOUT_SUM);let o=0;if(t.forEach((e,t)=>{i(this,jt,"f").rows=[...i(this,jt,"f").rows,{elements:[]}];for(let n=0;n<e;n++)i(this,jt,"f").rows[t].elements.push(i(this,Bt,"f")[o]),o++}),i(this,Ht,"f").styles&&(i(this,jt,"f").styles=Object.assign({},i(this,Ht,"f").styles)),i(this,Ht,"f").errorTextStyles&&(i(this,jt,"f").errorTextStyles=Object.assign({},i(this,Ht,"f").errorTextStyles)),i(this,Wt,"f"))return i(this,qt,"f")&&(i(this,qt,"f").unmount(),n(this,qt,null,"f")),n(this,xt,{},"f"),n(this,qt,i(this,$t,"f").call(this,i(this,jt,"f"),!1),"f"),this.mountContainerElement(e),void n(this,zt,!0,"f");i(this,Xt,"f").on(B+i(this,Ut,"f"),()=>{n(this,xt,{},"f"),n(this,qt,i(this,$t,"f").call(this,i(this,jt,"f"),!1),"f"),this.mountContainerElement(e),n(this,zt,!0,"f")})},this.mountContainerElement=e=>{i(this,qt,"f").mount(e)},this.unmount=()=>{var e;[...i(this,Bt,"f").map(e=>e.elementName)].forEach(e=>{i(this,Zt,"f").call(this,e)}),n(this,Bt,[],"f"),n(this,jt,{rows:[]},"f"),n(this,xt,{},"f"),null===(e=i(this,qt,"f"))||void 0===e||e.unmount(),this.iframe.remove(),n(this,zt,!1,"f"),n(this,Wt,!1,"f")},this.validate=()=>new Promise((e,t)=>{Object.values(i(this,xt,"f")).forEach(e=>{if(!e.isMounted())throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);e.isValidElement()}),this.bus.emit(j+i(this,Ut,"f"),{},t=>{e(t)})}),this.collect=(e={tokens:!0})=>new Promise((t,n)=>{try{if(Pe(i(this,Ft,"f").clientJSON.config),!i(this,zt,"f")){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);throw o.PayrailsLogger.error(e.message,{error:e}),e}ct(i(this,Kt,"f")).forEach(e=>{if(!(null==e?void 0:e.isMounted))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING)});if(Object.values(i(this,xt,"f")).forEach(e=>{e.isValidElement()}),e&&e.tokens&&"boolean"!=typeof e.tokens)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TOKENS);(null==e?void 0:e.additionalFields)&&Ne(e.additionalFields),(null==e?void 0:e.upsert)&&De(null==e?void 0:e.upsert),this.bus.emit(b+i(this,Ut,"f"),Object.assign(Object.assign({},e),{tokens:void 0===(null==e?void 0:e.tokens)||e.tokens}),e=>{!e||(null==e?void 0:e.error)?(Te(`${JSON.stringify(null==e?void 0:e.error)}`,fe.ERROR,i(this,Vt,"f").logLevel),n(null==e?void 0:e.error)):(Te(Ce(O.COLLECT_SUBMIT_SUCCESS,ni),fe.LOG,i(this,Vt,"f").logLevel),t(e))}),Te(Ce(O.EMIT_EVENT,ni,b),fe.LOG,i(this,Vt,"f").logLevel)}catch(e){Te(`${e.message}`,fe.ERROR,i(this,Vt,"f").logLevel),n(e)}}),ti.set(this,()=>{i(this,Xt,"f").on(F,e=>{let t;const n=i(this,Bt,"f").map((i,n)=>i.elementName===e.elementName?(t=n,Object.assign({elementName:i.elementName},e.elementOptions)):i);i(this,qt,"f")&&i(this,qt,"f").updateElement(Object.assign({},n[t]))})}),this.bus=L.getEventBus(),n(this,Ut,_t(),"f"),n(this,Ft,Object.assign(Object.assign({},t),(null==e?void 0:e.fonts)?{fonts:e.fonts}:{}),"f"),n(this,Gt,r,"f"),n(this,Vt,a,"f"),n(this,Ht,e,"f"),n(this,Xt,new oe,"f"),this.iframe=ue({name:`${C}:${i(this,Ut,"f")}:${i(this,Vt,"f").logLevel}`}),ce(this.iframe,{src:pe()}),_e(this.iframe,Object.assign({},K)),Te(Ce(O.CREATE_COLLECT_CONTAINER,ni),fe.LOG,i(this,Vt,"f").logLevel);const l=(e,t)=>{e.name===C+i(this,Ut,"f")&&(t(Object.assign(Object.assign({},i(this,Ft,"f")),{clientJSON:Object.assign(Object.assign({},i(this,Ft,"f").clientJSON),{config:Object.assign({},i(this,Ft,"f").clientJSON.config)}),context:i(this,Vt,"f")})),n(this,Wt,!0,"f"),i(this,Xt,"f")._emit(B+i(this,Ut,"f"),{containerId:i(this,Ut,"f")}),this.bus.target({origin:re.IFRAME_SECURE_ORGIN}).off(P+i(this,Ut,"f"),l))};this.bus.target({origin:re.IFRAME_SECURE_ORGIN}).on(P+i(this,Ut,"f"),l),document.body.append(this.iframe),i(this,ti,"f").call(this)}reset(){this.bus.emit(D+i(this,Ut,"f"),{})}}function oi(e){this.message=e}Ut=new WeakMap,xt=new WeakMap,Ft=new WeakMap,jt=new WeakMap,Bt=new WeakMap,Vt=new WeakMap,Gt=new WeakMap,Xt=new WeakMap,zt=new WeakMap,Ht=new WeakMap,qt=new WeakMap,Wt=new WeakMap,Kt=new WeakMap,$t=new WeakMap,Zt=new WeakMap,Jt=new WeakMap,Qt=new WeakMap,ei=new WeakMap,ti=new WeakMap,oi.prototype=new Error,oi.prototype.name="InvalidCharacterError";var ri="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new oi("'atob' failed: The string to be decoded is not correctly encoded.");for(var i,n,s=0,o=0,r="";n=t.charAt(o++);~n&&(i=s%4?64*i+n:n,s++%4)?r+=String.fromCharCode(255&i>>(-2*s&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return r};function ai(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(ri(e).replace(/(.)/g,function(e,t){var i=t.charCodeAt(0).toString(16).toUpperCase();return i.length<2&&(i="0"+i),"%"+i}))}(t)}catch(e){return ri(t)}}function li(e){this.message=e}li.prototype=new Error,li.prototype.name="InvalidTokenError";const di=e=>{try{if(!e)return!1;if(t=e,"[object String]"!==Object.prototype.toString.call(t))return!1;let i=!1;const n=function(e,t){if("string"!=typeof e)throw new li("Invalid token specified");var i=!0===(t=t||{}).header?0:1;try{return JSON.parse(ai(e.split(".")[i]))}catch(e){throw new li("Invalid token specified: "+e.message)}}(e),s=(new Date).getTime()/1e3,o=n.exp;return o&&s>o&&(i=!0),!i}catch(e){return!1}var t};var ci,ui,pi,_i,hi,Ei,mi,vi,yi,Ii;class fi{constructor(e,t){ci.set(this,void 0),this.config=e,n(this,ci,t,"f")}toJSON(){return{config:this.config,metaData:i(this,ci,"f")}}static fromJSON(e){return new fi(e.config,e.metaData)}}ci=new WeakMap,function(e){e.COLLECT="COLLECT",e.COMPOSABLE="COMPOSABLE"}(Ii||(Ii={}));const Ai="Skyflow";class Li{constructor(e){var t,r;ui.set(this,void 0),pi.set(this,_t()),_i.set(this,{uuid:i(this,pi,"f"),clientDomain:window.location.origin}),hi.set(this,""),Ei.set(this,void 0),mi.set(this,void 0),vi.set(this,void 0),yi.set(this,void 0),this.bus=L.getEventBus();const a=localStorage.getItem("sdk_version")||"";i(this,_i,"f").sdkVersion=a,n(this,ui,new fi(Object.assign({},e),i(this,_i,"f")),"f"),n(this,mi,(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||ye.ERROR,"f"),n(this,vi,(null===(r=null==e?void 0:e.options)||void 0===r?void 0:r.env)||Ie.PROD,"f"),n(this,yi,{},"f");this.bus.on(N,e=>{if(e&&e.errorCode){const t=new s.PayrailsError(e.errorCode,{cause:null==e?void 0:e.originalError});o.PayrailsLogger.error(t.message,{error:t})}}),this.bus.target({origin:re.IFRAME_SECURE_ORGIN}).on(U+i(this,pi,"f"),(e,t)=>{Te(Ce(O.CAPTURED_BEARER_TOKEN_EVENT,Ai),fe.LOG,i(this,mi,"f")),!i(this,ui,"f").config.getBearerToken||i(this,hi,"f")&&di(i(this,hi,"f"))?(Te(Ce(O.REUSE_BEARER_TOKEN,Ai),fe.LOG,i(this,mi,"f")),t({authToken:i(this,hi,"f")})):i(this,ui,"f").config.getBearerToken().then(e=>{di(e)?(Te(Ce(O.BEARER_TOKEN_RESOLVED,Ai),fe.LOG,i(this,mi,"f")),n(this,hi,e,"f"),t({authToken:i(this,hi,"f")})):(Te(g.INVALID_BEARER_TOKEN,fe.ERROR,i(this,mi,"f")),t({error:g.INVALID_BEARER_TOKEN}))}).catch(e=>{Te(g.BEARER_TOKEN_REJECTED,fe.ERROR,i(this,mi,"f")),t({error:e})})}),Te(Ce(O.BEARER_TOKEN_LISTENER,Ai),fe.LOG,i(this,mi,"f")),Te(Ce(O.CURRENT_ENV,Ai,i(this,vi,"f")),fe.LOG,i(this,mi,"f")),Te(Ce(O.CURRENT_LOG_LEVEL,Ai,i(this,mi,"f")),fe.LOG,i(this,mi,"f"))}static init(e){var t;const i=(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||ye.ERROR;Ye(e),Te(Ce(O.INITIALIZE_CLIENT,Ai),fe.LOG,i);const n=e;var s;n.vaultURL="string"!=typeof(s=e.vaultURL)?s:"/"===(null==s?void 0:s.trim().slice(-1))?s.slice(0,-1):s.trim();const o=new Li(n);return Te(Ce(O.CLIENT_INITIALIZED,Ai),fe.LOG,i),o}container(e,t){switch(e){case Ii.COLLECT:{const n=new Nt(t,Object.assign(Object.assign({},i(this,_i,"f")),{clientJSON:i(this,ui,"f").toJSON(),containerType:e}),i(this,yi,"f"),{logLevel:i(this,mi,"f"),env:i(this,vi,"f")});return Te(Ce(O.COLLECT_CONTAINER_CREATED,Ai),fe.LOG,i(this,mi,"f")),n}case Ii.COMPOSABLE:{(e=>{if(!e)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_COMPOSABLE_CONTAINER_OPTIONS);if("object"!=typeof e)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COMPOSABLE_CONTAINER_OPTIONS_INVALID);if(!Object.prototype.hasOwnProperty.call(e,"layout"))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_COMPOSABLE_LAYOUT_KEY);if(!e.layout)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_LAYOUT_TYPE);if(!Array.isArray(e.layout))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_LAYOUT_TYPE);if(0===e.layout.length)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_COMPOSABLE_LAYOUT_ARRAY);e.layout.forEach(e=>{if("number"!=typeof e)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_LAYOUT_TYPE);if(e<0)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_NEGATIVE_VALUES_COMPOSABLE_LAYOUT)})})(t);const n=new si(t,Object.assign(Object.assign({},i(this,_i,"f")),{clientJSON:i(this,ui,"f").toJSON(),containerType:e}),i(this,yi,"f"),{logLevel:i(this,mi,"f"),env:i(this,vi,"f")});return Te(Ce(O.COLLECT_CONTAINER_CREATED,Ai),fe.LOG,i(this,mi,"f")),n}default:if(!e)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_CONTAINER_TYPE);throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_CONTAINER_TYPE)}}static get ContainerType(){return Ii}static get ElementType(){return G}static get RedactionType(){return Ee}static get RequestMethod(){return me}static get LogLevel(){return ye}static get EventName(){return ve}static get Env(){return Ie}static get ValidationRuleType(){return Ae}}ui=new WeakMap,pi=new WeakMap,_i=new WeakMap,hi=new WeakMap,Ei=new WeakMap,mi=new WeakMap,vi=new WeakMap,yi=new WeakMap;const Oi=({url:e,token:t,body:i})=>h({url:e,token:t,method:_.POST,body:i}),gi=(e,i)=>t(void 0,void 0,void 0,function*(){try{const t=yield Ds(e,i);if(!t){const n=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onRequestStart resolved to false"});return bs(e,i,{code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:n.message}),t}}catch(t){const n=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onRequestStart threw an error",cause:t});return o.PayrailsLogger.error(n.message,{error:n}),bs(e,i,{code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:n.message}),!1}return!0});let Ti={};var Ci,Ri,Ni,Si;exports.PAYMENT_METHOD_CODES=void 0,(Ci=exports.PAYMENT_METHOD_CODES||(exports.PAYMENT_METHOD_CODES={})).CARD="card",Ci.GOOGLE_PAY="googlePay",Ci.PAYPAL="payPal",Ci.APPLE_PAY="applePay",Ci.GENERIC_REDIRECT="genericRedirect",Ci.MERCADO_PAGO="mercadoPago",Ci.PIX="pix",Ci.BANK_ACCOUNT="bankAccount",Ci.IDEAL="iDeal",Ci.YAPE="yape",Ci.UPI="upi",Ci.KLARNA="klarna",function(e){e.ENABLED="enabled",e.CREATED="created",e.DELETED="deleted",e.DISABLED="disabled",e.INVALID="invalid",e.TRANSIENT="transient"}(Ri||(Ri={}));class Pi{static get response(){if(!Pi._response){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND);throw o.PayrailsLogger.error(e.message,{error:e}),e}return Pi._response}static setResponse(e){return Pi._response=e,Pi}static get workflowCode(){return Pi.response.workflow.code}static get lookup(){return Pi.response.initialResults.find(({body:{name:e}})=>"lookup"===e)}static get holderReference(){return Pi.response.holderReference}static get savedCreditCards(){return Pi.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.CARD)}static get savedPaypalAccounts(){return Pi.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.PAYPAL).filter(({status:e})=>e===Ri.ENABLED)}static get savedGooglePayAccounts(){return Pi.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.GOOGLE_PAY).filter(({status:e})=>e===Ri.ENABLED)}static get savedApplePayAccounts(){return Pi.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.APPLE_PAY)}static get paypalConfig(){const e=Pi.availablePaymentMethods.find(({paymentMethodCode:e})=>e===exports.PAYMENT_METHOD_CODES.PAYPAL);if(!e){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING);throw o.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:Pi.availablePaymentMethods}}),e}return e.config||{}}static get googlePayConfig(){var e;const t=Pi.availablePaymentMethods.find(({paymentMethodCode:e})=>e===exports.PAYMENT_METHOD_CODES.GOOGLE_PAY);if(!t){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING);throw o.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:Pi.availablePaymentMethods}}),e}const i=t;return(null===(e=i.clientConfig)||void 0===e?void 0:e.additionalConfig)&&void 0!==i.clientConfig.additionalConfig.apiVersion?i.clientConfig.additionalConfig:[i.config]}static isPaymentMethodAvailable(e){return Pi.availablePaymentMethods.some(({paymentMethodCode:t})=>t===e)}static get applePayConfig(){const e=Pi.availablePaymentMethods.find(({paymentMethodCode:e})=>e===exports.PAYMENT_METHOD_CODES.APPLE_PAY);if(!e){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING);throw o.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:Pi.availablePaymentMethods}}),e}return e.config.parameters}static get url(){return Pi.response.links.self}static get meta(){return Pi.response.meta}static get availablePaymentMethods(){var e;return(null===(e=Pi.lookup)||void 0===e?void 0:e.body.data.paymentCompositionOptions)||[]}static get authorizeLink(){var e,t;return null===(t=null===(e=Pi.lookup)||void 0===e?void 0:e.body.links.authorize)||void 0===t?void 0:t.href}static get payoutLink(){var e,t;return null===(t=null===(e=Pi.lookup)||void 0===e?void 0:e.body.links.payout)||void 0===t?void 0:t.href}static get createSessionLink(){var e;return null===(e=Pi.response.links.startPaymentSession)||void 0===e?void 0:e.href}static get createInstrumentLink(){var e;return null===(e=Pi.response.links.createInstrument)||void 0===e?void 0:e.href}static get storedPaymentInstruments(){return Pi.availablePaymentMethods.flatMap(e=>e.paymentInstruments||[]).filter(({paymentMethod:e,status:t})=>t===Ri.ENABLED||![exports.PAYMENT_METHOD_CODES.GOOGLE_PAY,exports.PAYMENT_METHOD_CODES.PAYPAL].includes(e))}static get storedDropinInstruments(){return Pi.storedPaymentInstruments.filter(({paymentMethod:e})=>![exports.PAYMENT_METHOD_CODES.GOOGLE_PAY,exports.PAYMENT_METHOD_CODES.APPLE_PAY].includes(e))}static getFullPaymentMethodConfig(e){return Pi.availablePaymentMethods.find(({paymentMethodCode:t})=>t===e)}static isAddressSelectorEnabled(e){var t,i;return!!Pi._response&&(null===(i=null===(t=Pi.getFullPaymentMethodConfig(e))||void 0===t?void 0:t.clientConfig)||void 0===i?void 0:i.supportsBillingInfo)}static isPaymentInstallmentsEnabled(e){var t;if(Pi._response){const i=this.getFullPaymentMethodConfig(e);return i&&(null===(t=this.getPaymentMethodConfig(i).clientConfig)||void 0===t?void 0:t.supportsInstallments)}return!1}static getPaymentInstallmentOptions(e){var t;const i=this.getFullPaymentMethodConfig(e);return i&&(null===(t=this.getPaymentMethodConfig(i).clientConfig)||void 0===t?void 0:t.installments)||{}}static getStoredInstrumentForPaymentMethod(e){var t;return(null===(t=this.availablePaymentMethods.find(({paymentMethodCode:t})=>t===e))||void 0===t?void 0:t.paymentInstruments)||[]}static getPaymentMethodForStoredInstrument(e){const t=this.availablePaymentMethods.find(({paymentInstruments:t})=>null==t?void 0:t.some(({id:t})=>t===e.id));return t&&this.getPaymentMethodConfig(t)}static getPaymentMethodConfig(t){return e(t,["paymentInstruments"])}static updateInstallmentOptions(e){const t=Pi.getFullPaymentMethodConfig(exports.PAYMENT_METHOD_CODES.CARD);(null==t?void 0:t.clientConfig)&&(t.clientConfig.installments=e)}}!function(e){e.REDIRECT="redirect",e.DIRECT="direct",e.EMBEDDED="embedded"}(Ni||(Ni={})),exports.INTEGRATION_TYPE=void 0,(Si=exports.INTEGRATION_TYPE||(exports.INTEGRATION_TYPE={})).API="api",Si.HPP="hpp";class bi{constructor(){this._config=void 0}static getInstance(){return bi._instance||(bi._instance=new bi),bi._instance}set config(e){try{bi.getInstance()._config=e}catch(e){o.PayrailsLogger.error("Error parsing SDK Configuration",{error:e})}}get config(){return bi.getInstance()._config||o.PayrailsLogger.error("SDK Configuration not set"),bi.getInstance()._config||{}}}const Di=()=>bi.getInstance().config,Mi=e=>{try{const t=JSON.parse(function(e){const t=window.atob(e);return decodeURIComponent(Array.prototype.map.call(t,e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""))}(e.data));bi.getInstance().config=t,t.execution&&Pi.setResponse(t.execution)}catch(e){o.PayrailsLogger.error("Error parsing SDK Configuration",{error:e})}},wi=(e=window,t=navigator)=>{const i={userAgent:t.userAgent,language:t.language,screenHeight:e.screen.height,screenWidth:e.screen.width,colorDepth:e.screen.colorDepth,timeZoneOffset:(new Date).getTimezoneOffset(),acceptHeader:"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",javaEnabled:!1,javaScriptEnabled:!0},n=ki(t.userAgent);return n&&(i.osType=n),i},ki=e=>/android/i.test(e)?"android":/iphone|ipad|ipod/i.test(e)?"ios":/windows|linux|mac/i.test(e)?"web":void 0,Yi={success:"https://assets.payrails.io/html/payrails-success.html",error:"https://assets.payrails.io/html/payrails-error.html",cancel:"https://assets.payrails.io/html/payrails-cancel.html",pending:"https://assets.payrails.io/html/payrails-pending.html"};class Ui{static getInstance(){return this.instance||(this.instance=new Ui),this.instance}constructor(e=""){this.lastActionUpdateTime=e,Ui.instance=this}}class xi{constructor(e=Yi,t=680,i=60,n=2e3,s=5,o=Ui.getInstance()){this.returnLinks=e,this.POLL_INTERVAL=t,this.MAX_POLL_ATTEMPTS=i,this.POLL_INITIAL_DELAY=n,this.POLL_ERROR_COUNT_MULTIPLIER=s,this.paymentStatus=o}pay(e){return t(this,void 0,void 0,function*(){try{const t=(yield this.authorize(e)).res.links.execution;return yield this.pollForAuthorizationResult(t)}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR,{cause:e});throw o.PayrailsLogger.error(t.message,{error:t}),e}})}payout(e){return t(this,void 0,void 0,function*(){try{const t=(yield this.executePayout(e)).res.links.execution;return yield this.pollForAuthorizationResult(t)}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAYOUT_ERROR,{cause:e});throw o.PayrailsLogger.error(t.message,{error:t}),e}})}confirm(e){return t(this,arguments,void 0,function*(e,t={}){try{const i=yield h({url:e,method:_.POST,token:Di().token,body:{data:t}}),n=yield this.pollForAuthorizationResult(i.res.links.execution);if(n.finalState)return n;const s=n.response.status.slice().sort((e,t)=>new Date(t.time).getTime()-new Date(e.time).getTime())[0].time,{res:o}=yield this.getExecution(i.res.links.execution,s);return{finalState:o.status.find(({code:e,time:t})=>["authorizeSuccessful","authorizeFailed"].includes(e)&&new Date(t)>new Date(s)),response:o}}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR,{cause:e});throw o.PayrailsLogger.error(t.message,{error:t}),e}})}getExecution(e,i){return t(this,arguments,void 0,function*(e,t,i=0,n){if(i>this.MAX_POLL_ATTEMPTS)throw new y(e,_.GET);0===i&&t?yield this.wait(this.POLL_INITIAL_DELAY,n):yield this.wait(this.POLL_INTERVAL,n);try{const s=yield h({url:e,token:Di().token});if(t){if(!s.res.status.find(({time:e})=>new Date(e)>new Date(t)))return yield this.wait(this.POLL_INTERVAL,n),this.getExecution(e,t,i+1,n)}return s}catch(s){if(s instanceof m)return yield this.wait(this.POLL_INTERVAL,n),this.getExecution(e,t,i+this.POLL_ERROR_COUNT_MULTIPLIER,n);if(s instanceof v)return yield this.wait(this.POLL_INTERVAL*i,n),this.getExecution(e,t,i+1,n);throw s}})}createApplePaySession(e){return t(this,void 0,void 0,function*(){return h({url:e.requestUrl,method:_.POST,token:Di().token,body:{integrationType:"api",paymentMethodCode:"applePay",amount:Di().amount,meta:{sessionURL:e.sessionUrl,clientContext:{host:e.clientDomain||window.location.host}}}})})}authorize(e){return t(this,void 0,void 0,function*(){if(!Pi.authorizeLink||!Di().amount){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND,{description:"SDK was not initialized with workflow execution"});throw o.PayrailsLogger.error(e.message,{error:e}),e}const{success:t=Yi.success,error:i=Yi.error,cancel:n=Yi.cancel,pending:r=Yi.pending}=this.returnLinks,a=this.attachMetaToPaymentComposition({amount:Di().amount,paymentComposition:e,returnInfo:{success:t,cancel:n,error:i,pending:r}});return h({url:Pi.authorizeLink,method:_.POST,token:Di().token,body:a})})}executePayout(e){return t(this,void 0,void 0,function*(){if(!Pi.payoutLink||!Di().amount){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND,{description:"SDK was not initialized with workflow execution"});throw o.PayrailsLogger.error(e.message,{error:e}),e}const t={amount:Di().amount,payoutComposition:e};return h({url:Pi.payoutLink,method:_.POST,token:Di().token,body:t})})}getFirstNonFraudNetId(e){const t=Object.keys(e||{}).find(e=>"fraudNet"!==e);return t?e[t]:null}attachMetaToPaymentComposition(e){var t,i,n,s,o,r,a;let l;l=e.paymentComposition[0].paymentMethodCode===exports.PAYMENT_METHOD_CODES.PAYPAL&&(null===(i=null===(t=window.PayrailsData)||void 0===t?void 0:t.riskIds)||void 0===i?void 0:i.fraudNet)?null===(s=null===(n=window.PayrailsData)||void 0===n?void 0:n.riskIds)||void 0===s?void 0:s.fraudNet:this.getFirstNonFraudNetId(null===(o=window.PayrailsData)||void 0===o?void 0:o.riskIds)||"";const d=Object.assign(Object.assign({},e),{meta:Object.assign({},e.meta)});return!1!==(null===(r=Ti.telemetry)||void 0===r?void 0:r.collectMetadata)&&(d.meta=Object.assign(Object.assign({},d.meta),{clientContext:Object.assign(Object.assign({},(null===(a=d.meta)||void 0===a?void 0:a.clientContext)||{}),wi())})),l&&(d.meta.risk={sessionId:l}),d}wait(e,i){return t(this,void 0,void 0,function*(){var t;if(null==i?void 0:i.aborted)throw null!==(t=i.reason)&&void 0!==t?t:new DOMException("Aborted","AbortError");return new Promise((t,n)=>{const s=setTimeout(()=>{null==i||i.removeEventListener("abort",o),t()},e),o=()=>{var e;clearTimeout(s),null==i||i.removeEventListener("abort",o),n(null!==(e=null==i?void 0:i.reason)&&void 0!==e?e:new DOMException("Aborted","AbortError"))};null==i||i.addEventListener("abort",o,{once:!0})})})}pollForAuthorizationResult(e){return t(this,arguments,void 0,function*(e,t=0,i=["authorizePending","authorizeSuccessful","authorizeFailed","payoutPending","payoutSuccessful","payoutFailed"],n){var r;const a=null==n?void 0:n.signal;if(null==a?void 0:a.aborted)throw null!==(r=a.reason)&&void 0!==r?r:new DOMException("Aborted","AbortError");const l=(yield this.getExecution(e,this.paymentStatus.lastActionUpdateTime,t,a)).res,d=l.status,c=d.find(({code:e})=>"authorizeRequested"===e||"payoutRequested"===e);if(!c&&t<10)return yield this.wait(this.POLL_INTERVAL,a),this.pollForAuthorizationResult(e,t+1,i,{signal:a});if(!c){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED);throw o.PayrailsLogger.error(e.message,{error:e}),e}const u=d.find(({code:e,time:t})=>"confirmRequested"===e&&new Date(t)>new Date(c.time)),p=u?u.time:c.time,_=d.filter(({code:e,time:t})=>i.includes(e)&&new Date(t)>new Date(p)).sort((e,t)=>new Date(t.time).getTime()-new Date(e.time).getTime())[0];return _?(this.paymentStatus.lastActionUpdateTime=_.time,{finalState:_,response:l}):this.pollForAuthorizationResult(e,t+1,i,{signal:a})})}}
|
|
5
5
|
/*!
|
|
6
6
|
* paypal-js v5.1.4 (2022-11-29T23:08:21.847Z)
|
|
7
7
|
* Copyright 2020-present, PayPal, Inc. All rights reserved.
|
|
@@ -17,8 +17,8 @@ Copyright (c) 2022 Skyflow, Inc.
|
|
|
17
17
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
18
|
* See the License for the specific language governing permissions and
|
|
19
19
|
* limitations under the License.
|
|
20
|
-
*/function Ui(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseURL&&(t=e.sdkBaseURL,delete e.sdkBaseURL),function(e){var t=e["merchant-id"],i=e["data-merchant-id"],n="",s="";Array.isArray(t)?t.length>1?(n="*",s=t.toString()):n=t.toString():"string"==typeof t&&t.length>0?n=t:"string"==typeof i&&i.length>0&&(n="*",s=i);e["merchant-id"]=n,e["data-merchant-id"]=s}(e);var i=Object.keys(e).filter(function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]}).reduce(function(t,i){var n=e[i].toString();return"data-"===i.substring(0,5)?t.dataAttributes[i]=n:t.queryParams[i]=n,t},{queryParams:{},dataAttributes:{}}),n=i.queryParams,s=i.dataAttributes;return{url:"".concat(t,"?").concat(xi(n)),dataAttributes:s}}function xi(e){var t="";return Object.keys(e).forEach(function(i){0!==t.length&&(t+="&"),t+=i+"="+e[i]}),t}function Fi(e,t){void 0===t&&(t={});var i=document.createElement("script");return i.src=e,Object.keys(t).forEach(function(e){i.setAttribute(e,t[e]),"data-csp-nonce"===e&&i.setAttribute("nonce",t["data-csp-nonce"])}),i}function ji(e,t){if(void 0===t&&(t=Bi()),Gi(e,t),"undefined"==typeof window)return t.resolve(null);var i=Ui(e),n=i.url,s=i.dataAttributes,o=s["data-namespace"]||"paypal",r=Vi(o);return function(e,t){var i=document.querySelector('script[src="'.concat(e,'"]'));if(null===i)return null;var n=Fi(e,t),s=i.cloneNode();if(delete s.dataset.uidAuto,Object.keys(s.dataset).length!==Object.keys(n.dataset).length)return null;var o=!0;return Object.keys(s.dataset).forEach(function(e){s.dataset[e]!==n.dataset[e]&&(o=!1)}),o?i:null}(n,s)&&r?t.resolve(r):function(e,t){void 0===t&&(t=Bi());Gi(e,t);var i=e.url,n=e.attributes;if("string"!=typeof i||0===i.length)throw new Error("Invalid url.");if(void 0!==n&&"object"!=typeof n)throw new Error("Expected attributes to be an object.");return new t(function(e,t){if("undefined"==typeof window)return e();!function(e){var t=e.url,i=e.attributes,n=e.onSuccess,s=e.onError,o=Fi(t,i);o.onerror=s,o.onload=n,document.head.insertBefore(o,document.head.firstElementChild)}({url:i,attributes:n,onSuccess:function(){return e()},onError:function(){var e=new Error('The script "'.concat(i,'" failed to load.'));return window.fetch?fetch(i).then(function(i){return 200===i.status&&t(e),i.text()}).then(function(e){var i=function(e){var t=e.split("/* Original Error:")[1];return t?t.replace(/\n/g,"").replace("*/","").trim():e}(e);t(new Error(i))}).catch(function(e){t(e)}):t(e)}})})}({url:n,attributes:s},t).then(function(){var e=Vi(o);if(e)return e;throw new Error("The window.".concat(o," global variable is not available."))})}function Bi(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function Vi(e){return window[e]}function Gi(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}class Xi{static load(e,i){const n=e.toString(),s=Xi.scriptMap.get(n);if(s)return s;const o=(()=>t(this,void 0,void 0,function*(){try{if(e===zi.PayPal){if(!i)throw new Error("PayPal config is required");return yield Xi.loadPayPalScript(i)}return yield Xi.loadScript(e)}finally{Xi.scriptMap.delete(n)}}))();return Xi.scriptMap.set(n,o),o}static reset(){Xi.scriptMap.clear()}static preloadCardForm(){const e="https://assets.payrails.io/a676210/card";[[`${e}/index.js`,"payrails-iframe-js-v2"],[`${e}/index.html`,"payrails-iframe-html-v2"]].forEach(([e,t])=>{if(!document.getElementById(t)){const i=document.createElement("link");i.id=t,i.rel="preload",i.as="script",i.href=e,document.head.appendChild(i)}})}static loadScript(e){const t=`payrails-script-${JSON.stringify(e)}`;if(Xi.scriptMap.has(t))return Xi.scriptMap.get(t);const i=document.createElement("script");i.src=e,i.id=t;const n=new Promise((t,n)=>{i.onload=()=>t(),i.onerror=t=>n(Xi.logLoadError(e,new Error(t.toString())))});return Xi.scriptMap.set(t,n),document.body.appendChild(i),n}static loadPayPalScript(e){return t(this,arguments,void 0,function*({clientId:e,currency:t,vault:i,intent:n}){try{const s=yield ji({"client-id":e,components:"buttons,funding-eligibility",intent:n,currency:t,vault:i,"data-namespace":"payrailsPaypal"});if(s)return s}catch(e){throw Xi.logLoadError(zi.PayPal,e)}throw Xi.logLoadError(zi.PayPal)})}constructor(){}static logLoadError(e,t){const i=new Map([[zi.ApplePay,s.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR],[zi.GooglePay,s.ERROR_CODES.PAYRAILS_CLIENT_GPAY_LOADING_ERROR],[zi.PayPal,s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR]]),n=new s.PayrailsError(i.get(e)||s.ERROR_CODES.PAYRAILS_CLIENT_UNKNOWN_ERROR,{cause:t,description:null==t?void 0:t.message});return o.PayrailsLogger.error(n.message,{error:n}),n}}var zi;Xi.scriptMap=new Map,function(e){e.ApplePay="https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js",e.GooglePay="https://pay.google.com/gp/p/js/pay.js",e.PayPal="paypal-sdk"}(zi||(zi={}));class Hi{constructor(e,{id:t="",className:i="",dataTestId:n=""}={}){this.subElements=[],this.eventBus=L.getEventBus();const s=document.createElement(e);t&&(this.id=t,s.setAttribute("id",t)),n&&(this.dataTestId=n,s.setAttribute("data-testid",n)),i&&(Array.isArray(i)?s.setAttribute("class",function(...e){return e.filter(Boolean).join(" ")}(...i)):s.setAttribute("class",i)),this.element=s}get parentElement(){return this.element.parentElement}get selector(){if(!this.id)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);return`#${this.id}`}mount(e){const t=document.querySelector(e);if(!t)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING,{description:`Element with selector "${e}" not found in in the DOM`});this.clean(),t.appendChild(this.element),this.subElements.forEach(e=>{if(!this.id)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_SUBELEMENTS_RENDER_ERROR);e.mount(this.selector)})}clean(){var e;null===(e=document.getElementById(this.element.id))||void 0===e||e.remove()}unmount(){var e;this.subElements.forEach(e=>e.unmount()),null===(e=this.parentElement)||void 0===e||e.removeChild(this.element)}}class qi extends Hi{constructor(e){super("span",{id:e.id,className:"payrails-store-instrument",dataTestId:e.dataTestId}),this.options=e,this.createHTML(),this.applyStyles(),this.addListeners()}get isChecked(){var e;return!!(null===(e=this.element.querySelector("input"))||void 0===e?void 0:e.checked)}createHTML(){var e,t,i,n,s,o,r,a,l,d;const c=(null===(i=null===(t=null===(e=this.options)||void 0===e?void 0:e.translations)||void 0===t?void 0:t.labels)||void 0===i?void 0:i.saveInstrument)||(null===(o=null===(s=null===(n=this.options)||void 0===n?void 0:n.translations)||void 0===s?void 0:s.labels)||void 0===o?void 0:o.storeInstrument)||"Save instrument for future payments",u=`${this.id}-checkbox`,p=`${this.dataTestId}-checkbox`;(null===(l=null===(a=null===(r=this.options)||void 0===r?void 0:r.translations)||void 0===a?void 0:a.labels)||void 0===l?void 0:l.saveInstrument)&&console.warn("The saveInstrument label is deprecated, please use storeInstrument instead");const _="checked"==(null===(d=this.options)||void 0===d?void 0:d.defaultStoreInstrumentState);this.element.innerHTML=`<label for="${u}"><input type="checkbox" id="${u}" name="${u}" data-testid="${p}" class="payrails-store-instrument-checkbox">${c}</label>`,_&&(this.element.querySelector("input").checked=!0)}applyStyles(){var e,t;Object.keys((null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.storeInstrumentCheckbox)||{}).forEach(e=>{var t,i,n;this.element.style[e]=null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.storeInstrumentCheckbox)||void 0===n?void 0:n[e]})}addListeners(){this.element.addEventListener("change",e=>{var t,i,n,s;(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onSaveInstrumentCheckboxChanged)&&(null===(s=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===s||s.onSaveInstrumentCheckboxChanged({checked:this.isChecked})),e.stopPropagation(),e.stopImmediatePropagation()}),this.element.addEventListener("click",e=>{e.stopPropagation(),e.stopImmediatePropagation()})}}class Wi extends Hi{constructor(e,i){var n,s,o,r,a;super(e,i),this.options=i,this.storeInstrumentCheckbox=null,(null===(n=this.options)||void 0===n?void 0:n.showStoreInstrumentCheckbox)&&(this.storeInstrumentCheckbox=new qi(Object.assign(Object.assign({},i),{id:`${null===(s=this.options)||void 0===s?void 0:s.id}-store-instrument-checkbox`,dataTestId:(null===(o=this.options)||void 0===o?void 0:o.dataTestId)?`${null===(r=this.options)||void 0===r?void 0:r.dataTestId}-store-instrument-checkbox`:`${null===(a=this.options)||void 0===a?void 0:a.id}-store-instrument-checkbox`,events:{onSaveInstrumentCheckboxChanged:e=>t(this,void 0,void 0,function*(){var t,n;null===(n=null===(t=null==i?void 0:i.events)||void 0===t?void 0:t.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(t,e)})}})),this.subElements.push(this.storeInstrumentCheckbox))}get shouldStoreInstrument(){var e,t;return(null===(e=this.storeInstrumentCheckbox)||void 0===e?void 0:e.isChecked)||(null===(t=this.options)||void 0===t?void 0:t.alwaysStoreInstrument)||!1}}class $i extends Wi{static isApplePayAvailable(){return t(this,void 0,void 0,function*(){try{return yield Xi.load(zi.ApplePay),ApplePaySession.canMakePayments()}catch(e){return!1}})}constructor(e){super("div",Object.assign(Object.assign({},e),{id:`payrails-apple-pay-button-${p()}`,dataTestId:"payrails-apple-pay-button"})),this.options=e,this.appleButton=null,this.isProcessing=!1,this.completedSessions=new WeakSet,this.abortedSessionReasons=new WeakMap,this.paymentExecutor=new Yi,$i.isApplePayAvailable().then(e=>{var t,i,n;e&&(null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onApplePayAvailable)||void 0===n||n.call(i))}),this.action="tokenization"===Pi().type?Cs.TOKENIZE:Cs.AUTHORIZE}mount(e){this.unmount(),super.mount(e),(()=>{t(this,void 0,void 0,function*(){try{(yield $i.isApplePayAvailable())&&(yield this.mountApplePayButton())}catch(e){}})})()}unmount(){var e,t;null===(t=null===(e=this.appleButton)||void 0===e?void 0:e.parentElement)||void 0===t||t.removeChild(this.appleButton),super.unmount()}mountApplePayButton(){return t(this,void 0,void 0,function*(){var e,i,n;try{const s=(null===(e=this.options.styles)||void 0===e?void 0:e.type)||"buy",o=(null===(i=this.options.styles)||void 0===i?void 0:i.style)||"black";this.element.innerHTML=`<apple-pay-button buttonstyle="${o}" type="${s}" locale="en-GB"></apple-pay-button>`,null===(n=this.storeInstrumentCheckbox)||void 0===n||n.mount(this.selector);const r=this.element.querySelector("apple-pay-button");null==r||r.setAttribute("style","width: 100%;"),null==r||r.addEventListener("click",()=>t(this,void 0,void 0,function*(){this.isProcessing||(this.isProcessing=!0,yield this.createApplePaySession())}))}catch(e){}})}onAuthorizeFailedHandler(e,t){this.isProcessing=!1,this.options.abortAfterAuthorizeFailed?(this.abortedSessionReasons.set(e,t),this.completeApplePaySession(e,"abort")):(this.completeApplePaySession(e,"failure"),Ss(Cs.AUTHORIZE,this.options.events,t instanceof s.PayrailsError?t:void 0))}completeApplePaySession(e,t){if(!this.completedSessions.has(e)){this.completedSessions.add(e);try{if("abort"===t)return void e.abort();e.completePayment("success"===t?ApplePaySession.STATUS_SUCCESS:ApplePaySession.STATUS_FAILURE)}catch(e){o.PayrailsLogger.warn(`ApplePaySession completion failed (${t})`,{error:e instanceof s.PayrailsError?e:void 0})}}}createApplePaySession(){return t(this,void 0,void 0,function*(){var e,i;const n=Ni.applePayConfig,{countryCode:r,supportedNetworks:a,merchantCapabilities:l,requiredBillingContactFields:d=[],requiredShippingContactFields:c=[]}=n,{amount:u}=Pi();try{const n=new ApplePaySession(3,{countryCode:r,currencyCode:u.currency,merchantCapabilities:l,supportedNetworks:a,total:{label:(null===(i=null===(e=this.options.translations)||void 0===e?void 0:e.labels)||void 0===i?void 0:i.paymentScreenLabel)||"",type:"final",amount:u.value},requiredBillingContactFields:d,requiredShippingContactFields:c});n.onvalidatemerchant=e=>t(this,void 0,void 0,function*(){try{const{res:t}=yield this.paymentExecutor.createApplePaySession({requestUrl:Ni.createSessionLink,sessionUrl:e.validationURL,clientDomain:this.options.clientDomain}),i=t.data.data;n.completeMerchantValidation(i)}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_START_PAYMENT_SESSION_ERROR);o.PayrailsLogger.error(t.message,{error:t}),n.abort()}}),n.oncancel=()=>{this.isProcessing=!1;const e=this.abortedSessionReasons.get(n);this.abortedSessionReasons.delete(n),Ss(this.action,this.options.events,e)},n.onpaymentauthorized=e=>t(this,void 0,void 0,function*(){yield this.onApplePayAuthorized(e.payment,n)});return(yield Ds(this.action,this.options.events))?n.begin():this.isProcessing=!1,n}catch(e){return this.isProcessing=!1,null}})}onApplePayAuthorized(e,i){return t(this,void 0,void 0,function*(){return(yield Li(this.action,this.options.events))?this.action===Cs.TOKENIZE?yield this.doTokenize(e,i):yield this.doAuthorizedPayment(e,i):(this.action===Cs.AUTHORIZE?this.onAuthorizeFailedHandler(i,{code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:"Authorization request start validation failed"}):(this.isProcessing=!1,this.completeApplePaySession(i,"failure"),Ss(this.action,this.options.events,{code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:"Request start validation failed"})),null)})}doAuthorizedPayment(e,i){return t(this,void 0,void 0,function*(){var t,n,s,o,r;const a=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.APPLE_PAY,integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(e)},amount:Pi().amount,storeInstrument:this.shouldStoreInstrument}];try{const e=yield this.paymentExecutor.pay(a);if("authorizeSuccessful"===(null===(t=e.finalState)||void 0===t?void 0:t.code))this.completeApplePaySession(i,"success"),this.isProcessing=!1,Ns(Cs.AUTHORIZE,this.options.events,e);else this.onAuthorizeFailedHandler(i,{code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:(null===(r=null===(o=null===(s=null===(n=e.finalState)||void 0===n?void 0:n.errors)||void 0===s?void 0:s[0])||void 0===o?void 0:o.reason)||void 0===r?void 0:r.result)||"Authorization Failed"});return e}catch(e){this.onAuthorizeFailedHandler(i,e)}})}doTokenize(e,i){return t(this,void 0,void 0,function*(){const t=Pi(),n=Ni.createInstrumentLink,s=t.token;if(!n)return this.completeApplePaySession(i,"failure"),this.isProcessing=!1,void Ss(Cs.TOKENIZE,this.options.events);let o;try{o=JSON.stringify(e)}catch(e){return this.completeApplePaySession(i,"failure"),this.isProcessing=!1,void Ss(Cs.TOKENIZE,this.options.events,e)}const r={holderReference:t.holderReference,paymentMethod:exports.PAYMENT_METHOD_CODES.APPLE_PAY,data:{paymentToken:o}};try{const e=yield Ai({url:n,token:s,body:r});return e.ok?(this.completeApplePaySession(i,"success"),this.isProcessing=!1,Ns(Cs.TOKENIZE,this.options.events,e.res),e.res):(this.completeApplePaySession(i,"failure"),this.isProcessing=!1,void Ss(Cs.TOKENIZE,this.options.events))}catch(e){return this.completeApplePaySession(i,"failure"),this.isProcessing=!1,void Ss(Cs.TOKENIZE,this.options.events,e)}})}}function Ki(...e){function t(e,i){if("object"!=typeof e||null===e)return i;if("object"!=typeof i||null===i)return i;if(Array.isArray(i)||Array.isArray(e))return i;const n=Object.assign({},e);for(const s of Object.keys(i))i[s]&&"object"==typeof i[s]&&!Array.isArray(i[s])&&e[s]&&"object"==typeof e[s]&&!Array.isArray(e[s])?n[s]=t(e[s],i[s]):n[s]=i[s];return n}return e.reduce((e,i)=>t(e,i),{})}const Zi={wrapper:{display:"flex",flexDirection:"column"}};var Ji;!function(e){e.GET="GET"}(Ji||(Ji={}));const Qi=e=>t(void 0,[e],void 0,function*({url:e}){const t={method:Ji.GET},i=yield fetch(e,t),n=yield i.json();if(429===i.status)throw new tn(e,Ji.GET);if(!i.ok)throw new en(e,Ji.GET);return{ok:i.ok,req:Object.assign({url:e},t),res:n}});class en extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{description:`[${t}] ${e} unsuccessful`})}}class tn extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} too many requests`})}}const nn=()=>t(void 0,void 0,void 0,function*(){const e=yield(({url:e})=>Qi({url:e}))({url:"https://assets.payrails.io/json/countries.json"});return new Map(Object.entries(e.res))});class sn extends Hi{constructor(e,t){super(e,{id:t.id,className:t.className}),this.applyStyles(t.styles)}applyStyles(e){Object.keys(e||{}).forEach(t=>{this.element.style[t]=null==e?void 0:e[t]})}}const on="__payrails-selectedCountry";class rn extends sn{constructor(e){var t,i;super("span",Object.assign(Object.assign({},e),{id:"payrails-country-select",className:"payrails-country-selector-wrapper",styles:null===(t=e.styles)||void 0===t?void 0:t.wrapper})),this.options=e,this._countriesList=null===(i=e.config)||void 0===i?void 0:i.data,this.createHTML(),this.attachEvents()}set countriesList(e){this._countriesList=e,this.populateCountrySelect(),this.setDefaultCountry()}get countriesList(){return this._countriesList}populateCountrySelect(){return t(this,void 0,void 0,function*(){var e,t;const i=document.createElement("option");i.value="",i.textContent=(null===(e=this.options.translations)||void 0===e?void 0:e.placeholder)||"Select Country",null===(t=this.selectElement)||void 0===t||t.appendChild(i),this._countriesList.forEach(e=>{var t;const i=document.createElement("option");i.value=e.code,i.textContent=e.name,null===(t=this.selectElement)||void 0===t||t.appendChild(i)})})}setDefaultCountry(){const e=JSON.parse(sessionStorage.getItem(on)||"{}");if(null==e?void 0:e.code)return void(this.value=e.code);const t=Intl.DateTimeFormat().resolvedOptions().timeZone;t&&this.countriesList.forEach(e=>{var i;if(null===(i=e.timezones)||void 0===i?void 0:i.includes(t))return this.value=e.code,void sessionStorage.setItem(on,JSON.stringify(this.value))})}createHTML(){this.createLabel(),this.createSelectBox()}createSelectBox(){var e;this.selectElement=document.createElement("select"),this.selectElement.id=this.options.id,this.selectElement.className="payrails-country-select-element",this._countriesList&&this.populateCountrySelect(),this.applyStylesToSubElements(null===(e=this.options.styles)||void 0===e?void 0:e.element,this.selectElement),this.element.appendChild(this.selectElement)}createLabel(){var e,t,i;this.label=document.createElement("label"),this.label.textContent=(null===(e=this.options.translations)||void 0===e?void 0:e.label)||"Country",this.applyStylesToSubElements(null===(t=this.options.styles)||void 0===t?void 0:t.label,this.label),(null===(i=this.options.translations)||void 0===i?void 0:i.label)&&this.element.appendChild(this.label)}applyStylesToSubElements(e,t){Object.keys(e||{}).forEach(i=>{t.style[i]=null==e?void 0:e[i]})}attachEvents(){var e;null===(e=this.selectElement)||void 0===e||e.addEventListener("change",e=>{var t,i;null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onChange)||void 0===i||i.call(t,{country:this.value}),sessionStorage.setItem(on,JSON.stringify(this.value)),e.stopPropagation(),e.stopImmediatePropagation()})}get isValid(){var e;return""!==(null===(e=this.selectElement)||void 0===e?void 0:e.value)}get value(){var e,t,i,n,s,o;return{code:null===(e=this.selectElement)||void 0===e?void 0:e.value,fullName:(null===(i=null===(t=this.selectElement)||void 0===t?void 0:t.options[this.selectElement.selectedIndex])||void 0===i?void 0:i.textContent)||"",iso3:(null===(o=null===(n=this._countriesList)||void 0===n?void 0:n.get(null===(s=this.selectElement)||void 0===s?void 0:s.value))||void 0===o?void 0:o.iso3)||""}}set value(e){this.selectElement&&(this.selectElement.value=e)}}class an extends sn{set selectedCountry(e){this._selectedCountry=e}get selectedCountry(){return this._selectedCountry}constructor(e){var t;super("span",Object.assign(Object.assign({},e),{id:"payrails-postal-code-wrapper",className:"payrails-postal-code-wrapper",styles:null===(t=e.styles)||void 0===t?void 0:t.wrapper})),this.options=e,this._selectedCountry="",this._countriesList=void 0,this._countriesList=e.config.data,this.createHTML(),this.attachEvents()}createHTML(){this.createLabel(),this.createInput()}createInput(){var e,t;this.inputElement=document.createElement("input"),this.inputElement.type="text",this.inputElement.placeholder=(null===(e=this.options.translations)||void 0===e?void 0:e.placeholder)||"Postal Code",this.inputElement.id=this.options.id,this.inputElement.className="payrails-postal-code-input",this.applyStylesToSubElements(null===(t=this.options.styles)||void 0===t?void 0:t.element,this.inputElement),this.element.appendChild(this.inputElement)}createLabel(){var e,t,i;this.label=document.createElement("label"),this.label.textContent=(null===(e=this.options.translations)||void 0===e?void 0:e.label)||"Postal Code",this.applyStylesToSubElements(null===(t=this.options.styles)||void 0===t?void 0:t.label,this.label),(null===(i=this.options.translations)||void 0===i?void 0:i.label)&&this.element.appendChild(this.label)}applyStylesToSubElements(e,t){Object.keys(e||{}).forEach(i=>{t.style[i]=null==e?void 0:e[i]})}attachEvents(){var e,t,i;null===(e=this.inputElement)||void 0===e||e.addEventListener("change",e=>{e.stopPropagation(),e.stopImmediatePropagation()}),null===(t=this.inputElement)||void 0===t||t.addEventListener("input",e=>{var t,i,n;null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onChange)||void 0===i||i.call(t,{postalCode:this.value}),null===(n=this.inputElement)||void 0===n||n.classList.remove("error"),e.stopPropagation(),e.stopImmediatePropagation()}),null===(i=this.inputElement)||void 0===i||i.addEventListener("focusout",e=>{var t;this.isValid||null===(t=this.inputElement)||void 0===t||t.classList.add("error"),e.stopPropagation(),e.stopImmediatePropagation()})}set countriesList(e){this._countriesList=e}get value(){var e;return(null===(e=this.inputElement)||void 0===e?void 0:e.value)||""}set value(e){this.inputElement&&(this.inputElement.value=e)}show(){this.element.style.display="flex"}hide(){this.element.style.display="none"}get isValid(){var e,t,i;const n=null===(e=this.inputElement)||void 0===e?void 0:e.value,s=this.selectedCountry,o=(null===(i=null===(t=this._countriesList)||void 0===t?void 0:t.get(s))||void 0===i?void 0:i.postalCodeRegex)||"";let r=!1;if(n)return r=o?new RegExp(o).test(n):n.length>0,r}setValidation(e){this.inputElement&&(this.inputElement.pattern=e,this.inputElement.classList.remove("error"))}}class ln extends Hi{get fullAddress(){var e,t,i,n;const s={},o=null===(e=this.countrySelector)||void 0===e?void 0:e.value;return o&&(s.country=o,o.code&&(null===(i=null===(t=this.countriesMap)||void 0===t?void 0:t.get(o.code))||void 0===i?void 0:i.showPostalCode)&&(s.postalCode=null===(n=this.postalCodeInput)||void 0===n?void 0:n.value)),Object.assign({},s)}constructor(e){var t,i;super("div",{id:e.id,className:"payrails-address-selector-wrapper",styles:(null===(t=e.styles)||void 0===t?void 0:t.wrapper)||(null===(i=Zi)||void 0===i?void 0:i.wrapper)}),this.options=e,this.countriesMap=void 0,this.createAddressComponents(),this.init(),this.applyStyles(),nn().then(e=>{this.countriesMap=e,this.countrySelector&&(this.countrySelector.countriesList=e),this.postalCodeInput&&(this.postalCodeInput.countriesList=e)})}applyStyles(){var e,t;Object.keys((null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.wrapper)||{}).forEach(e=>{var t,i,n;this.element.style[e]=null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.wrapper)||void 0===n?void 0:n[e]})}createAddressComponents(e){var t,i,n,s,o,r,a,l,d,c,u,p;const _={id:"country-selector",styles:(null===(t=this.options.styles)||void 0===t?void 0:t.countrySelector)||(null===(i=Zi)||void 0===i?void 0:i.countrySelector),events:{onChange:e=>{var t,i;const{country:n}=e;this.onCountryChange(n),null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onBillingAddressChanged)||void 0===i||i.call(t,{isValid:this.isValid,billingAddress:this.fullAddress})}},translations:{label:null===(s=null===(n=this.options.translations)||void 0===n?void 0:n.labels)||void 0===s?void 0:s.countrySelector,placeholder:null===(r=null===(o=this.options.translations)||void 0===o?void 0:o.placeholders)||void 0===r?void 0:r.countrySelector}},h={id:"postal-code-input",translations:{label:null===(l=null===(a=this.options.translations)||void 0===a?void 0:a.labels)||void 0===l?void 0:l.postalCodeInput,placeholder:null===(c=null===(d=this.options.translations)||void 0===d?void 0:d.placeholders)||void 0===c?void 0:c.postalCodeInput},styles:(null===(u=this.options.styles)||void 0===u?void 0:u.postalCodeInput)||(null===(p=Zi)||void 0===p?void 0:p.postalCodeInput),events:{onChange:()=>{var e,t;null===(t=null===(e=this.options.events)||void 0===e?void 0:e.onBillingAddressChanged)||void 0===t||t.call(e,{isValid:this.isValid,billingAddress:this.fullAddress})}},config:{data:e}};this.countrySelector=new rn(_),this.postalCodeInput=new an(h)}init(){var e,t;this.countrySelector&&this.subElements.push(this.countrySelector),this.postalCodeInput&&this.subElements.push(this.postalCodeInput),null===(e=this.postalCodeInput)||void 0===e||e.hide(),(null===(t=this.options.styles)||void 0===t?void 0:t.wrapper)&&Object.assign(this.element.style,this.options.styles.wrapper)}get isValid(){var e,t,i,n;let s=this.countrySelector&&this.countrySelector.isValid;const o=null===(t=null===(e=this.countrySelector)||void 0===e?void 0:e.value)||void 0===t?void 0:t.code;return o&&(null===(n=null===(i=this.countriesMap)||void 0===i?void 0:i.get(o))||void 0===n?void 0:n.showPostalCode)&&(s=s&&this.postalCodeInput&&this.postalCodeInput.isValid),!!s}onCountryChange(e){var t;const i=null==e?void 0:e.code;if(!i)return;const n=null===(t=this.countriesMap)||void 0===t?void 0:t.get(i);if(this.postalCodeInput)if(n&&(null==n?void 0:n.showPostalCode)){const e=new RegExp(n.postalCodeRegex||"[0-9]*");this.postalCodeInput.setValidation(e.source),this.postalCodeInput.selectedCountry=i,this.postalCodeInput.show()}else this.postalCodeInput.hide(),this.postalCodeInput.setValidation(""),this.postalCodeInput.value=""}get selectedCountry(){var e;return null===(e=this.countrySelector)||void 0===e?void 0:e.value}get postalCode(){var e;return null===(e=this.postalCodeInput)||void 0===e?void 0:e.value}show(){this.element.style.display="flex"}hide(){this.element.style.display="none"}}class dn extends Hi{constructor(e){var t;super("div",{id:e.id,className:e.className}),this.options=e,this.INSTALLMENT_STORAGE_KEY="__payrails-selectedInstallmentCount",this.installmentOptions=[],this.installmentOptions=(null===(t=e.installmentConfig)||void 0===t?void 0:t.installmentOptions)||[],this.createHTML(),this.applyStyles(),this.addListeners()}generateOptionsHTML(e){var t,i,n,s,o;const r=(null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.translations)||void 0===i?void 0:i.labels)||void 0===n?void 0:n.paymentInstallments)||"Split payment into monthly installments",a=parseInt(null!==(s=sessionStorage.getItem(this.INSTALLMENT_STORAGE_KEY))&&void 0!==s?s:"",10)||(null===(o=this.options.installmentConfig)||void 0===o?void 0:o.defaultInstallment);return[`<option value="">${r}</option>`,...(null==e?void 0:e.map(e=>{const t=e.count===a?" selected":"";return`<option value="${e.count}" ${t}>${e.count} x ${e.amount}</option>`}))||[]].join("")}renderOptions(e){const t=this.element.querySelector("select");t&&(t.innerHTML=this.generateOptionsHTML(e),e.length>0?this.setDisabled(!1):this.setDisabled(!0))}updateOptions(e){this.updateConfig(Object.assign(Object.assign({},this.options.installmentConfig),{installmentOptions:e}))}updateConfig(e){var t,i,n,s,o,r,a;if(!this.options)return;const l=null!==(t=this.options.installmentConfig)&&void 0!==t?t:{},d=null!=e?e:{};this.options.installmentConfig={installmentCurrency:null!==(i=d.installmentCurrency)&&void 0!==i?i:l.installmentCurrency,installmentOptions:null!==(s=null!==(n=d.installmentOptions)&&void 0!==n?n:l.installmentOptions)&&void 0!==s?s:[],defaultInstallment:null!==(o=d.defaultInstallment)&&void 0!==o?o:l.defaultInstallment},this.installmentOptions=null!==(r=this.options.installmentConfig.installmentOptions)&&void 0!==r?r:[],null===(a=this.renderOptions)||void 0===a||a.call(this,this.installmentOptions)}createHTML(){const e=`${this.id}-dropdown`;this.element.innerHTML=`<select name="${this.options.className}" id="${e}"></select>`,this.renderOptions(this.installmentOptions||[])}applyStyles(){var e,t;Object.keys((null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.paymentInstallmentsDropdown)||{}).forEach(e=>{var t,i,n;this.element.style[e]=null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.paymentInstallmentsDropdown)||void 0===n?void 0:n[e]})}addListeners(){this.element.addEventListener("change",e=>{var t;e.stopPropagation(),e.stopImmediatePropagation();const i=null===(t=this.element.querySelector("select"))||void 0===t?void 0:t.value;i?sessionStorage.setItem(this.INSTALLMENT_STORAGE_KEY,i):sessionStorage.removeItem(this.INSTALLMENT_STORAGE_KEY)}),this.element.addEventListener("click",e=>{e.stopPropagation(),e.stopImmediatePropagation()})}get selectedInstallmentValue(){var e;return null===(e=this.element.querySelector("select"))||void 0===e?void 0:e.value}setDisabled(e){const t=this.element.querySelector("select");t&&0!==this.installmentOptions.length?t&&(t.disabled=e,this.setVisible(!e)):this.setVisible(!1)}setVisible(e){const t=this.element.querySelector("select");t&&t.parentElement&&(t.parentElement.style.display=e?"block":"none")}}class cn extends Hi{constructor(e,t){var i,n;super(e,t),this.options=t,this.paymentInstallmentsDropdown=null,this.paymentInstallmentsDropdown=new dn(Object.assign(Object.assign({},t),{id:`${null===(i=this.options)||void 0===i?void 0:i.id}-dropdown`,className:"payrails-payment-installments-dropdown",installmentConfig:null===(n=this.options)||void 0===n?void 0:n.installmentConfig})),this.subElements.push(this.paymentInstallmentsDropdown)}get selectedInstallmentValue(){var e;return parseInt((null===(e=this.paymentInstallmentsDropdown)||void 0===e?void 0:e.selectedInstallmentValue)||"0")}updateInstallmentOptions(e){var t;this.options&&(null===(t=this.paymentInstallmentsDropdown)||void 0===t||t.updateOptions(e))}updateInstallmentConfig(e){var t;this.options&&(this.options.installmentConfig=Object.assign(Object.assign({},this.options.installmentConfig),e),null===(t=this.paymentInstallmentsDropdown)||void 0===t||t.updateConfig(this.options.installmentConfig))}setDisabled(e){var t;null===(t=this.paymentInstallmentsDropdown)||void 0===t||t.setDisabled(e)}}const{CARD_NUMBER:un,CVV:pn,CARDHOLDER_NAME:_n,EXPIRATION_DATE:hn,EXPIRATION_MONTH:En,EXPIRATION_YEAR:mn}=exports.ElementType,vn={base:{border:"none",padding:"10px 16px",color:"#1d1d1d",backgroundColor:"#fff"},invalid:{backgroundColor:"#f9e1e1",borderColor:"#f25226",border:"1px solid"}},yn=[{type:_n,placeholder:"Card holder",styles:Object.assign(Object.assign({},vn),{base:Object.assign(Object.assign({},vn.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px"})})},{type:un,placeholder:"1234 1234 1234 1234",styles:Object.assign(Object.assign({},vn),{base:Object.assign(Object.assign({},vn.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px",textIndent:"0"}),cardIcon:{position:"absolute",right:"8px",height:"24px",bottom:"calc(50% - 12px)"}})},{type:En,placeholder:"MM",styles:Object.assign(Object.assign({},vn),{base:Object.assign(Object.assign({},vn.base),{borderBottom:"1px solid #eae8ee",borderLeft:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomLeftRadius:"4px"})})},{type:mn,placeholder:"YY",format:"YY",styles:Object.assign(Object.assign({},vn),{base:Object.assign(Object.assign({},vn.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee"})})},{type:hn,placeholder:"MM/YY",format:"MM/YY",styles:Object.assign(Object.assign({},vn),{base:Object.assign(Object.assign({},vn.base),{borderBottom:"1px solid #eae8ee",borderLeft:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomLeftRadius:"4px"}),cardIcon:{position:"absolute",right:"8px",height:"24px",bottom:"calc(50% - 12px)"}})},{type:pn,placeholder:"CVC",styles:Object.assign(Object.assign({},vn),{base:Object.assign(Object.assign({},vn.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomRightRadius:"4px"}),cardIcon:{position:"absolute",right:"8px",height:"24px",bottom:"calc(50% - 12px)"}})}];class In extends Wi{get bin(){return this.collectContainer.bin}get isBinLookupEnabled(){return this.collectContainer.isBinLookupEnabled}constructor(e,t){var i,n,s,o,r,a,l,d,c;super("div",Object.assign(Object.assign({},t),{translations:Object.assign(Object.assign({},null==t?void 0:t.translations),{labels:Object.assign(Object.assign({},null===(i=null==t?void 0:t.translations)||void 0===i?void 0:i.labels),{saveInstrument:null===(s=null===(n=null==t?void 0:t.translations)||void 0===n?void 0:n.labels)||void 0===s?void 0:s.saveCreditCard})}),styles:Object.assign({storeInstrumentCheckbox:null===(o=null==t?void 0:t.styles)||void 0===o?void 0:o.storeCardCheckbox},null==t?void 0:t.styles),id:"payrails-card-form"})),this.collectContainer=e,this.options=t,this.formFields=[],this.paymentInstallmentsDropdown=null,this.addressComponent=null,this.lastBin=null,this.lastBinLookup=null,this.defaultStyles={},this.defaultTranslations={},this.defaultStyles=(null===(r=this.options)||void 0===r?void 0:r.styles)||{},this.defaultTranslations=(null===(a=this.options)||void 0===a?void 0:a.translations)||{},this.eventsRef=null===(l=this.options)||void 0===l?void 0:l.events,this.throttledFetchBinLookup=function(e,t){let i,n;return function(...s){return new Promise((o,r)=>{n?(clearTimeout(i),i=setTimeout(()=>{Date.now()-n>=t&&(e(...s).then(o).catch(r),n=Date.now())},t-(Date.now()-n))):(e(...s).then(o).catch(r),n=Date.now())})}}(this.fetchBinLookup.bind(this),500),(null===(d=null==t?void 0:t.styles)||void 0===d?void 0:d.storeCardCheckbox)&&console.warn("The `storeCardCheckbox` option for styles is deprecated. Please use `storeInstrumentCheckbox` instead."),this.initializeFormFields(),this.subElements.push(this.collectContainer),Ni.isPaymentInstallmentsEnabled(exports.PAYMENT_METHOD_CODES.CARD)&&(this.paymentInstallmentsDropdown=new cn("span",Object.assign(Object.assign({},t),{installmentConfig:{installmentCurrency:"",installmentOptions:this.getinstallmentOptions(),defaultInstallment:null===(c=null==t?void 0:t.installmentConfig)||void 0===c?void 0:c.defaultInstallment},id:"payrails-card-form-payment-installments",className:"payrails-card-form-payment-installments-container"})),this.paymentInstallmentsDropdown&&this.subElements.push(this.paymentInstallmentsDropdown)),Ni.isAddressSelectorEnabled(exports.PAYMENT_METHOD_CODES.CARD)&&(this.addressComponent=this.createAddressSelector(),this.subElements.push(this.addressComponent)),this.storeInstrumentCheckbox&&this.subElements.push(this.storeInstrumentCheckbox)}initializeFormFields(){var e;(null===(e=this.options)||void 0===e?void 0:e.layout)&&this.options.layout.length>0?this.initializeCustomLayout():this.initializeDefaultLayout()}getErrorTextStyles(e){return(null==e?void 0:e.base)?e:{base:{}}}updateStyles(e){return this.formFields.forEach(t=>{var i,n,s,o;const r=Ki((null===(i=null==e?void 0:e.inputFields)||void 0===i?void 0:i.all)||{},(null===(n=null==e?void 0:e.inputFields)||void 0===n?void 0:n[t.type])||{}),a=this.prepareInputStyles(r,t.type),l=Ki((null===(s=null==e?void 0:e.labels)||void 0===s?void 0:s.all)||{},(null===(o=null==e?void 0:e.labels)||void 0===o?void 0:o[t.type])||{}),d=this.prepareLabelStyles(t.type,l),c=this.prepareErrorStyles(null==e?void 0:e.errorTextStyles);t.update({styles:{inputStyles:a,labelStyles:d,errorTextStyles:c}})}),Ki(this.defaultStyles,e||{})}updateTranslations(e){const t=Ki(this.defaultTranslations||{},e||{});return this.formFields.forEach(e=>{var i,n,s,o;e.update({translations:{label:(null===(i=t.labels)||void 0===i?void 0:i[e.type])||"",placeholder:(null===(n=t.placeholders)||void 0===n?void 0:n[e.type])||"",translations:{error:{default:(null===(o=null===(s=t.error)||void 0===s?void 0:s.default)||void 0===o?void 0:o[e.type])||""}}}})}),t}updateEvents(e){this.eventsRef=Object.assign(Object.assign({},this.eventsRef),e),this.formFields.forEach(e=>{e.update({events:{onFocus:()=>{var e,t;return null===(t=null===(e=this.eventsRef)||void 0===e?void 0:e.onFocus)||void 0===t?void 0:t.call(e)},onChange:this.onChange.bind(this),onReady:this.triggerOnReady.bind(this)}})})}update(e){(null==e?void 0:e.styles)&&(this.defaultStyles=this.updateStyles(e.styles)),(null==e?void 0:e.translations)&&(this.defaultTranslations=this.updateTranslations(e.translations)),(null==e?void 0:e.events)&&this.updateEvents(e.events)}updateInstallmentConfig(e){var t,i,n,s,o;if(!this.paymentInstallmentsDropdown)return;const r=Ni.getPaymentInstallmentOptions(exports.PAYMENT_METHOD_CODES.CARD),a={installmentCurrency:(null===(t=Pi().amount)||void 0===t?void 0:t.currency)||""};this.options&&e&&Object.prototype.hasOwnProperty.call(e,"defaultInstallment")&&(this.options.installmentConfig={defaultInstallment:null!==(i=e.defaultInstallment)&&void 0!==i?i:null},a.defaultInstallment=null!==(n=e.defaultInstallment)&&void 0!==n?n:null);const l=null===(o=null===(s=this.lastBinLookup)||void 0===s?void 0:s.issuerCountry)||void 0===o?void 0:o.code,d=l&&r?r[l]:void 0;a.installmentOptions=d||[],this.paymentInstallmentsDropdown.updateInstallmentConfig(a)}createFormField(e,t,i,n,s,o=!1){var r,a,l,d,c,u,p;const _=this.prepareErrorStyles(i);return new fn(this.collectContainer,{type:e,required:o,label:null===(a=null===(r=this.defaultTranslations)||void 0===r?void 0:r.labels)||void 0===a?void 0:a[e],errorTextStyles:_,placeholder:(null===(d=null===(l=this.defaultTranslations)||void 0===l?void 0:l.placeholders)||void 0===d?void 0:d[e])||s,labelStyles:this.prepareLabelStyles(e),inputStyles:this.prepareInputStyles(t,e),translations:{error:{default:(null===(p=null===(u=null===(c=this.defaultTranslations)||void 0===c?void 0:c.error)||void 0===u?void 0:u.default)||void 0===p?void 0:p[e])||""}},format:n,events:{onFocus:()=>{var e,t;return null===(t=null===(e=this.eventsRef)||void 0===e?void 0:e.onFocus)||void 0===t?void 0:t.call(e)},onChange:this.onChange.bind(this),onReady:this.triggerOnReady.bind(this)}})}initializeCustomLayout(){var e;if(!(null===(e=this.options)||void 0===e?void 0:e.layout))return;const t=e=>{e.forEach(e=>{var t,i,n;const o=yn.find(t=>t.type===e);if(!o)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_TYPE);if(this.hasFieldBeenUsed(o.type))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_DUPLICATE_ELEMENT);const{type:r,styles:a,format:l,placeholder:d}=o,c=!!(null===(i=null===(t=this.defaultStyles)||void 0===t?void 0:t.errorTextStyles)||void 0===i?void 0:i.base);this.formFields.push(this.createFormField(r,a,null===(n=this.defaultStyles)||void 0===n?void 0:n.errorTextStyles,l,d,c))})};this.options.layout.forEach(e=>t(e))}hasFieldBeenUsed(e){return this.formFields.some(t=>t.type===e)}initializeDefaultLayout(){var e,t;const i=e=>{var t,i,n;return!(null===(t=this.options)||void 0===t?void 0:t.showCardHolderName)&&e===exports.ElementType.CARDHOLDER_NAME||(!(null===(i=this.options)||void 0===i?void 0:i.showSingleExpiryDateField)&&e===exports.ElementType.EXPIRATION_DATE||!(!(null===(n=this.options)||void 0===n?void 0:n.showSingleExpiryDateField)||e!==exports.ElementType.EXPIRATION_MONTH&&e!==exports.ElementType.EXPIRATION_YEAR))},n=!!(null===(t=null===(e=this.defaultStyles)||void 0===e?void 0:e.errorTextStyles)||void 0===t?void 0:t.base);yn.filter(({type:e})=>!i(e)).forEach(({type:e,styles:t,format:i,placeholder:s})=>{var o;this.formFields.push(this.createFormField(e,t,null===(o=this.defaultStyles)||void 0===o?void 0:o.errorTextStyles,i,s,n))})}throttledFetchBinLookupIfChanged(){return t(this,void 0,void 0,function*(){return this.bin!==this.lastBin&&(this.lastBin=this.bin,this.lastBinLookup=yield this.throttledFetchBinLookup()),this.lastBinLookup})}tokenize(e){return this.collectContainer.tokenize(e)}createAddressSelector(){var e,t;return new ln({id:"payrails-address-selector",events:Object.assign(Object.assign({},this.eventsRef),{onBillingAddressChanged:e=>{var t,i;this.onChange(),null===(i=null===(t=this.eventsRef)||void 0===t?void 0:t.onBillingAddressChanged)||void 0===i||i.call(t,e)}}),styles:null===(e=this.defaultStyles)||void 0===e?void 0:e.addressSelector,translations:null===(t=this.defaultTranslations)||void 0===t?void 0:t.addressSelector})}show(){var e;const t=document.getElementById(this.collectContainer.id);if(!t){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw o.PayrailsLogger.error(e.message,{error:e}),e}Object.assign(t.style,null===(e=this.defaultStyles)||void 0===e?void 0:e.wrapper),this.element.style.display="flex"}hide(e={}){this.element.style.display="none",e.reset&&this.reset()}triggerOnReady(){var e,t;this.formFields.reduce((e,t)=>e&&t.isReady,!0)&&(this.updateTranslations(this.defaultTranslations||{}),this.updateStyles(this.defaultStyles||{}),null===(t=null===(e=this.eventsRef)||void 0===e?void 0:e.onReady)||void 0===t||t.call(e))}prepareErrorStyles(e){var t,i;const n={base:{}};return n.base=Object.assign(Object.assign({},(null===(i=null===(t=this.defaultStyles)||void 0===t?void 0:t.errorTextStyles)||void 0===i?void 0:i.base)||{}),(null==e?void 0:e.base)||{}),n}prepareLabelStyles(e,t){var i,n,s,o,r;const a={};return a.base=Object.assign(Object.assign(Object.assign(Object.assign({},(null===(i=this.defaultStyles)||void 0===i?void 0:i.base)||{}),(null===(s=null===(n=this.defaultStyles)||void 0===n?void 0:n.labels)||void 0===s?void 0:s.all)||{}),(null===(r=null===(o=this.defaultStyles)||void 0===o?void 0:o.labels)||void 0===r?void 0:r[e])||{}),t||{}),a}prepareInputStyles(e,t){var i;const n={};return["base","complete","empty","focus","invalid","cardIcon","copyIcon"].forEach(i=>{var s,o,r,a,l,d;n[i]=Object.assign(Object.assign(Object.assign({},(null===(r=null===(o=null===(s=this.defaultStyles)||void 0===s?void 0:s.inputFields)||void 0===o?void 0:o.all)||void 0===r?void 0:r[i])||{}),(null===(d=null===(l=null===(a=this.defaultStyles)||void 0===a?void 0:a.inputFields)||void 0===l?void 0:l[t])||void 0===d?void 0:d[i])||{}),(null==e?void 0:e[i])||{})}),(null===(i=this.options)||void 0===i?void 0:i.showCardHolderName)&&t===exports.ElementType.CARD_NUMBER&&(this.element.setAttribute("class","with-card-holder"),n.base=Object.assign(Object.assign(Object.assign({},vn.base),{border:"1px solid #eae8ee",borderTop:"none",padding:"10px 16px",textIndent:"0"}),n.base)),n}validate(){return this.collectContainer.validate()}get isValid(){var e;const t=this.formFields.reduce((e,t)=>e&&t.isValid,!0);return this.addressComponent?t&&!!(null===(e=this.addressComponent)||void 0===e?void 0:e.isValid):t}get cardNetwork(){var e,t;return null!==(t=null===(e=this.formFields.find(e=>Boolean(e.cardNetwork)))||void 0===e?void 0:e.cardNetwork)&&void 0!==t?t:""}onChange(){var e;(null===(e=this.eventsRef)||void 0===e?void 0:e.onChange)&&(this.eventsRef.onChange({isValid:this.isValid,cardNetwork:this.cardNetwork,bin:this.bin,billingAddress:this.billingAddress}),Ni.isPaymentInstallmentsEnabled(exports.PAYMENT_METHOD_CODES.CARD)&&this.bin.length>=6&&this.throttledFetchBinLookupIfChanged().then(e=>{this.updateInstallments(e)}))}updateInstallments(e){var t;if(this.paymentInstallmentsDropdown&&this.isBinLookupEnabled){const i=this.getinstallmentOptions(null===(t=null==e?void 0:e.issuerCountry)||void 0===t?void 0:t.code);i?this.paymentInstallmentsDropdown.updateInstallmentOptions(i):this.paymentInstallmentsDropdown.updateInstallmentOptions([])}}reset(){this.collectContainer.reset()}collectValues(){return t(this,void 0,void 0,function*(){return{cardData:yield this.collectContainer.collect(),storeInstrument:this.shouldStoreInstrument,selectedInstallment:this.selectedInstallment,enrollInstrumentToNetworkOffers:Boolean(this.enforceEnrollInstrumentToNetworkOffersForMasterCard()),billingInfo:this.billingAddress}})}get selectedInstallment(){var e;return null===(e=this.paymentInstallmentsDropdown)||void 0===e?void 0:e.selectedInstallmentValue}get billingAddress(){var e;return null===(e=this.addressComponent)||void 0===e?void 0:e.fullAddress}enforceEnrollInstrumentToNetworkOffersForMasterCard(){var e;return"mastercard"!==this.cardNetwork&&(null===(e=this.options)||void 0===e?void 0:e.enrollInstrumentToNetworkOffers)}fetchBinLookup(){return t(this,void 0,void 0,function*(){return this.isBinLookupEnabled?yield this.collectContainer.fetchBinLookup(this.bin):this.bin})}getinstallmentOptions(e){if(e){const t=Ni.getPaymentInstallmentOptions(exports.PAYMENT_METHOD_CODES.CARD);return t?t[e]:null}return null}unmount(){this.hide({reset:!0}),super.unmount()}mount(e){super.mount(e),this.show()}}class fn{constructor(e,t){this.isValid=!1,this.isReady=!1,this.cardNetwork="";const{events:i}=t;this.vaultElement=e.createCollectElement(t),this.type=t.type,(null==i?void 0:i.onFocus)&&this.vaultElement.on("FOCUS",i.onFocus),this.vaultElement.on("READY",()=>{var e,i;this.isReady=!0,null===(i=null===(e=t.events)||void 0===e?void 0:e.onReady)||void 0===i||i.call(e)}),this.vaultElement.on("CHANGE",e=>{const{isEmpty:t,isValid:n,network:s}=e;this.isValid=!t&&n,this.cardNetwork=null!=s?s:"",(null==i?void 0:i.onChange)&&i.onChange(this)})}updateStyles(e){var t,i;null===(i=(t=this.vaultElement).update)||void 0===i||i.call(t,{type:this.type,errorTextStyles:(null==e?void 0:e.errorTextStyles)||{base:{}},inputStyles:(null==e?void 0:e.inputStyles)||{},labelStyles:(null==e?void 0:e.labelStyles)||{}})}updateTranslations(e){var t,i,n,s;null===(i=(t=this.vaultElement).update)||void 0===i||i.call(t,{type:this.type,label:(null==e?void 0:e.label)||"",translations:{error:{default:null===(s=null===(n=null==e?void 0:e.translations)||void 0===n?void 0:n.error)||void 0===s?void 0:s.default}},placeholder:(null==e?void 0:e.placeholder)||""})}update(e){e.styles&&this.updateStyles(e.styles),e.translations&&this.updateTranslations(e.translations)}}class An extends Hi{constructor(e,t,i,n,s){super("div",{id:e,className:"payrails-dropin-item"}),this.events=n,this.styles=s,this.isActive=!1,this.mountContainerClass="payrails-dropin-item-container",this.applyBaseStyles();const o=`payrails-dropin-item-${e}`,r=document.createElement("label");r.setAttribute("for",o);const a=document.createElement("input");if(a.setAttribute("type","radio"),a.setAttribute("name","payment-option"),a.setAttribute("id",o),a.setAttribute("value",o),this.input=a,r.appendChild(a),this.label=r,i){const e=document.createElement("img");e.src=null!=i?i:"",e.className="payrails-store-instrument-icon",r.appendChild(e)}const l=document.createElement("span");r.appendChild(l),l.innerText=t,this.element.addEventListener("click",()=>{var e,t;null===(t=(e=this.label).onchange)||void 0===t||t.call(e,new Event("change"))}),this.element.appendChild(r);const d=document.createElement("div");d.setAttribute("class",this.mountContainerClass),this.element.appendChild(d)}get identifier(){return`payrails-dropin-item-${this.id}`}deactivate(){var e,t;this.isActive&&(this.isActive=!1,this.input.checked=!1,this.applyBaseStyles(),null===(e=this.component)||void 0===e||e.unmount(),(null===(t=this.events)||void 0===t?void 0:t.onDeactivate)&&this.events.onDeactivate())}applyBaseStyles(){var e,t;this.element.classList.remove("active"),Object.keys((null===(e=this.styles)||void 0===e?void 0:e.active)||{}).forEach(e=>{this.element.style.removeProperty(e)}),Object.assign(this.element.style,null===(t=this.styles)||void 0===t?void 0:t.base)}applyActiveStyles(){var e,t;this.element.classList.add("active"),Object.assign(this.element.style,null===(e=this.styles)||void 0===e?void 0:e.base,null===(t=this.styles)||void 0===t?void 0:t.active)}activate(){var e,t,i;this.isActive||(null===(e=this.component)||void 0===e||e.mount(`${this.selector} .${this.mountContainerClass}`),this.applyActiveStyles(),this.input.checked=!0,this.isActive=!0,(null===(t=this.events)||void 0===t?void 0:t.onActivate)&&this.events.onActivate(),(null===(i=this.events)||void 0===i?void 0:i.onPaymentOptionVisibilityChange)&&this.events.onPaymentOptionVisibilityChange())}mount(e){var t,i;super.mount(e),null===(i=null===(t=this.events)||void 0===t?void 0:t.onAvailable)||void 0===i||i.call(t)}}var Ln;!function(e){e.AMEX="amex",e.DINERS="diners",e.DISCOVER="discover",e.HIPERCARD="hipercard",e.JCB="jcb",e.MAESTRO="maestro",e.MASTERCARD="mastercard",e.UNIONPAY="unionpay",e.VISA="visa"}(Ln||(Ln={}));const On={[exports.PAYMENT_METHOD_CODES.CARD]:"https://assets.payrails.io/img/logos/card/",[exports.PAYMENT_METHOD_CODES.PAYPAL]:"https://assets.payrails.io/img/logos/paypal/",[exports.PAYMENT_METHOD_CODES.APPLE_PAY]:"https://assets.payrails.io/img/logos/applepay/",[exports.PAYMENT_METHOD_CODES.GOOGLE_PAY]:"https://assets.payrails.io/img/logos/googlepay/"};class gn extends An{constructor(e,t,i,n,s){const o=e.displayName&&""!==e.displayName?e.displayName:"Unavailable";super(`payrails-payment-instrument-${e.id}`,o,gn.getInstrumentIcon(e),{onActivate:()=>{i(e),this.component.setDisabled(!1),this.installmentDropdown&&this.component.setPaymentInstallmentsDropdown(this.installmentDropdown)}},n),this.installmentDropdown=null,s&&(this.installmentDropdown=s),this.instrumentData=e,this.component=new Tn(t,s)}static getInstrumentIcon(e){var t;if(e.paymentMethod===exports.PAYMENT_METHOD_CODES.CARD){const i=On[exports.PAYMENT_METHOD_CODES.CARD];switch(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.network){case Ln.AMEX:return i+"amex.svg";case Ln.DINERS:return i+"diners-club.svg";case Ln.DISCOVER:return i+"discover.svg";case Ln.HIPERCARD:return i+"hipercard.svg";case Ln.JCB:return i+"jcb.svg";case Ln.MAESTRO:return i+"maestro.svg";case Ln.MASTERCARD:return i+"mastercard.svg";case Ln.UNIONPAY:return i+"unionpay.svg";case Ln.VISA:return i+"visa.svg"}return i+"default.svg"}return e.paymentMethod===exports.PAYMENT_METHOD_CODES.PAYPAL?On[exports.PAYMENT_METHOD_CODES.PAYPAL]+"logo.svg":e.paymentMethod===exports.PAYMENT_METHOD_CODES.APPLE_PAY?On[exports.PAYMENT_METHOD_CODES.APPLE_PAY]+"logo.svg":e.paymentMethod===exports.PAYMENT_METHOD_CODES.GOOGLE_PAY?On[exports.PAYMENT_METHOD_CODES.GOOGLE_PAY]+"logo.svg":""}updateInstallmentConfig(e){var t,i,n,s,o;if(!this.installmentDropdown||this.instrumentData.paymentMethod!==exports.PAYMENT_METHOD_CODES.CARD)return;const r=Ni.getPaymentInstallmentOptions(exports.PAYMENT_METHOD_CODES.CARD),a=null===(n=null===(i=null===(t=this.instrumentData.data)||void 0===t?void 0:t.binLookup)||void 0===i?void 0:i.issuerCountry)||void 0===n?void 0:n.code,l={installmentCurrency:(null===(s=Pi().amount)||void 0===s?void 0:s.currency)||""};e&&Object.prototype.hasOwnProperty.call(e,"defaultInstallment")&&(l.defaultInstallment=null!==(o=e.defaultInstallment)&&void 0!==o?o:null);const d=a&&r?r[a]:void 0;l.installmentOptions=d||[],this.installmentDropdown.updateInstallmentConfig(l)}}class Tn extends Hi{constructor(e,t){super("div",{id:"stored-instrument-container",className:"payrails-stored-instrument-container"}),this.paymentButton=e,this.paymentInstallmentDropdown=t,this.paymentInstallmentDropdown&&this.subElements.push(this.paymentInstallmentDropdown),this.subElements.push(this.paymentButton)}setDisabled(e){this.paymentButton.setDisabled(e),this.paymentInstallmentDropdown&&this.paymentInstallmentDropdown.setDisabled(e)}setPaymentInstallmentsDropdown(e){this.paymentInstallmentDropdown=e,this.paymentButton.setPaymentInstallmentsDropdown(e)}}class Cn extends Hi{constructor(e){super("div",{id:"payrails-card-list"}),this.listItems=[],Ni.savedCreditCards.forEach(t=>{const i=new Rn(()=>{(null==e?void 0:e.onCardChange)&&e.onCardChange(t)},t);this.listItems.push(i),this.subElements.push(i)})}reset(){this.element.querySelectorAll("input").forEach(e=>e.checked=!1)}}class Rn extends Hi{constructor(e,t){super("div",{className:"payrails-card-list-item",id:`payrails-card-list-item-${t.id}`});const{id:i}=t,n=t.displayName&&""!==t.displayName?t.displayName:"Unavailable",s=document.createElement("label");s.setAttribute("for",i),s.addEventListener("click",e);const o=document.createElement("input");o.setAttribute("type","radio"),o.setAttribute("name","payment-option"),o.setAttribute("id",i),o.setAttribute("value",i),s.appendChild(o);const r=document.createElement("span");r.className="payment-option-text",s.appendChild(r);const a=document.createElement("img");a.src=gn.getInstrumentIcon(t),a.className="payment-option-icon",r.appendChild(a),r.appendChild(document.createTextNode(n)),this.element.appendChild(s)}}class Nn extends Hi{constructor(e){var t;super("div",{id:"authorization-failed-message"}),this.options=e;const i=(null===(t=null==e?void 0:e.translations)||void 0===t?void 0:t.label)||"Authorization failed, please try again.";this.element.innerText=i,this.setStyles((null==e?void 0:e.styles)||{}),this.element.innerHTML=`\n <div>\n <svg class="checkmark-cross" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">\n <circle class="checkmark-cross_circle" cx="26" cy="26" r="25" fill="none"/>\n <path class="checkmark-cross_check" fill="none" d="M14.1 14.1l23.8 23.8 m0,-23.8 l-23.8,23.8"/>\n </svg>\n </div>\n <div class="payrails-auth-failed-label">${i}</div>`,this.element.addEventListener("click",e=>{e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),this.unmount()})}mount(e){super.mount(e),this.scheduleAutoHide()}setStyles(e){Object.keys(e).forEach(t=>{this.element.style[t]=e[t]})}scheduleAutoHide(){var e,t;const i=null===(t=null===(e=this.options)||void 0===e?void 0:e.configuration)||void 0===t?void 0:t.autoHideTTL;i&&setTimeout(()=>{this.unmount()},i)}}class Sn extends Hi{constructor(e){var t;super("div",{id:"payrails-authorization-success-msg"}),this.setStyles((null==e?void 0:e.styles)||{}),this.element.innerHTML=`\n <div class="checkmark-wrapper">\n <svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">\n <circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none"/>\n <path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/>\n </svg>\n </div>\n <div id="payrails-authorization-success">${(null===(t=null==e?void 0:e.translations)||void 0===t?void 0:t.label)||"Payment successful"}</div`}setStyles(e){Object.keys(e).forEach(t=>{this.element.style[t]=e[t]})}}class Pn extends Hi{constructor(e){super("div",{id:"payrails-dropin-loader",className:"payrails-dropin-loader-wrapper"}),this.options=e,this.selectors={[bn.overlay]:".loading-overlay",[bn.loader]:".lds-ring .loading-ring"},this.element.innerHTML="\n <div class='loading-overlay'>\n <div class='lds-ring'>\n <div></div>\n <div></div>\n <div></div>\n <div class='loading-ring'></div>\n </div>\n </div>\n "}mount(e){var t;(null===(t=this.options)||void 0===t?void 0:t.styles)&&this.setStyles(this.options.styles),super.mount(e)}setStyles(e){Object.keys(e).forEach(t=>{const i=t;e[i]&&this.applyStyles(i,e[i])})}applyStyles(e,t){const i=this.element.querySelector(this.selectors[e]);i&&Object.keys(t).forEach(e=>{i.style[e]=t[e]})}}var bn;!function(e){e.overlay="overlay",e.loader="loader"}(bn||(bn={}));const Dn="https://assets.payrails.io/img/logos";function Mn(e=""){switch(e=e.trim().split(/\s+/).join("").toLowerCase()){case"adyen-old":e="adyen";break;case"checkout.com":e="checkout";break;case"visaoffersplatform":e="visa";break;case"bankAccount":e="banktransfer"}return"card"!==e?`${Dn}/${e}/logo.svg`:`${Dn}/card/credit-card-regular.svg`}class wn extends An{constructor(){super(...arguments),this.buttonShown=!1}activate(){var e,t;if(!this.buttonShown)return super.activate(),void(this.buttonShown=!0);this.applyActiveStyles(),this.isActive=!0,this.element.querySelector(this.component.selector).style.display="block",null===(t=null===(e=this.events)||void 0===e?void 0:e.onPaymentOptionVisibilityChange)||void 0===t||t.call(e)}deactivate(){this.isActive&&(this.isActive=!1,this.applyBaseStyles(),this.element.querySelector(this.component.selector).style.display="none")}mountAfterAvailable(){var e,t;super.mount(`#${this.loadElementId}`),null===(t=null===(e=this.events)||void 0===e?void 0:e.onAvailable)||void 0===t||t.call(e)}mount(e){const t=document.querySelector(e);if(!t){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);throw o.PayrailsLogger.error(e.message,{error:e}),e}const i=document.createElement("div");i.setAttribute("id",this.loadElementId),i.setAttribute("style","width: 100%;"),t.appendChild(i)}unmount(){var e;super.unmount(),null===(e=document.querySelector(`#${this.loadElementId}`))||void 0===e||e.remove()}}class kn extends wn{constructor(e){var t,i;super("apple-pay-dropin",(null===(i=null===(t=e.translations)||void 0===t?void 0:t.labels)||void 0===i?void 0:i.label)||"Apple Pay",e.showPaymentMethodLogo?Mn("applepay"):void 0,void 0,e.styles),this.loadElementId="apple-pay-dropin-load-element",this.component=new $i(Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},e.events),{onApplePayAvailable:()=>{this.mountAfterAvailable()}})}))}}class Yn extends An{constructor(e,t,i){var n,s;super("payrails-credit-card-wrapper",(null===(s=null===(n=i.translations)||void 0===n?void 0:n.labels)||void 0===s?void 0:s.label)||"Card",i.showPaymentMethodLogo?Mn("card"):void 0,Object.assign({},i.events),Object.assign({},i.styles)),this.cardForm=e,this.paymentButton=t,this.cardFormShown=!1,this.component=new Un(e,t)}activate(){var e,t,i;this.applyActiveStyles(),this.cardFormShown||(this.cardFormShown=!0,null===(e=this.component)||void 0===e||e.mount(this.selector)),this.isActive||(this.paymentButton.selectedInstrument=null,this.paymentButton.mount(this.selector),this.paymentButton.setDisabled(!this.cardForm.isValid),this.paymentButton.mount("#payrails-card-form"),this.input.checked=!0,this.cardForm.show(),this.isActive=!0,(null===(t=this.events)||void 0===t?void 0:t.onActivate)&&this.events.onActivate(),(null===(i=this.events)||void 0===i?void 0:i.onPaymentOptionVisibilityChange)&&this.events.onPaymentOptionVisibilityChange())}deactivate(){var e;this.isActive&&(this.applyBaseStyles(),this.paymentButton.unmount(),this.cardForm.hide(),this.isActive=!1,(null===(e=this.events)||void 0===e?void 0:e.onDeactivate)&&this.events.onDeactivate())}}class Un extends Hi{constructor(e,t){super("div",{id:"payrails-form-container"}),this.subElements.push(e,t)}}class xn{constructor(e,t,i,n=Fn.THREE_DS){this.link=e,this.paymentExecutor=t,this.options=i,this.type=n,this.THREE_DS_SIZES=[[250,400],[390,400],[500,600],[600,450]],this.internalPopupBackground=null,this.SCREEN_WIDTH=window.innerWidth,this.SCREEN_HEIGHT=window.innerHeight}get iframeSize(){return this.type===Fn.THREE_DS?this.THREE_DS_SIZES.reduce((e,t)=>this.SCREEN_WIDTH>t[0]?t:e,[250,400]):[this.SCREEN_WIDTH-50,this.SCREEN_HEIGHT-50]}get popupBackground(){if(this.internalPopupBackground)return this.internalPopupBackground;{const e=document.createElement("div");e.setAttribute("id","payrails-popup-background"),e.appendChild(this.popup),this.internalPopupBackground=e}return this.internalPopupBackground}get popupCancelButton(){const e=document.createElement("button");return e.setAttribute("id","payrails-popup-cancel-button"),e.setAttribute("type","button"),e.setAttribute("aria-label","Close"),e.addEventListener("click",()=>{L.getEventBus().emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}),Ss(Cs.AUTHORIZE,this.options.events,{code:exports.AuthorizationFailureReasons.USER_CANCELLED,message:"User cancelled the authorization."}),this.unmount()}),e}get popup(){const e=document.createElement("div");return e.setAttribute("id","payrails-popup"),e.setAttribute("width",this.iframeSize[0].toString()),e.setAttribute("height",this.iframeSize[1].toString()),!0===this.options.showCancelButton&&e.appendChild(this.popupCancelButton),e.appendChild(this.iframe),e.style.width=`${this.iframeSize[0]+4}px`,e.style.height=`${this.iframeSize[1]+4}px`,e}get iframe(){const e=document.createElement("iframe");return e.setAttribute("id","payrails-frame"),e.setAttribute("src",this.link),e.setAttribute("width",this.iframeSize[0].toString()),e.setAttribute("height",this.iframeSize[1].toString()),e.setAttribute("allow","clipboard-write; clipboard-read"),e}handleMessages(){const e=i=>t(this,void 0,void 0,function*(){var t,n,s,o,r;if(i.data&&'{"type":"3DS-challenge-completed"}'===i.data){window.removeEventListener("message",e);const i=yield this.paymentExecutor.pollForAuthorizationResult(Ni.url);switch(null===(t=i.finalState)||void 0===t?void 0:t.code){case"authorizeSuccessful":Ns(Cs.AUTHORIZE,this.options.events);break;case"authorizePending":bs(Cs.AUTHORIZE,this.options.events);break;default:Ss(Cs.AUTHORIZE,this.options.events,{code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:(null===(r=null===(o=null===(s=null===(n=i.finalState)||void 0===n?void 0:n.errors)||void 0===s?void 0:s[0])||void 0===o?void 0:o.reason)||void 0===r?void 0:r.result)||"Authorization failed after 3DS challenge."})}this.unmount()}});window.addEventListener("message",e)}mount(){var e;this.popup.remove(),null===(e=document.querySelector("body"))||void 0===e||e.appendChild(this.popupBackground),this.handleMessages()}unmount(){this.popupBackground.remove(),this.internalPopupBackground=null}}var Fn;!function(e){e[e.THREE_DS=0]="THREE_DS",e[e.GENERIC_REDIRECT=1]="GENERIC_REDIRECT"}(Fn||(Fn={}));const jn="__PAYRAILS__TAB_MANUAL_CLOSE_ERROR__",Bn={label:"Generic redirect"},Vn={pix:75e4,modo:6e5},Gn={showCancelButton:!0};class Xn extends Hi{constructor(e,t){var i,n,s;super("button",{id:`payrails-generic-redirect-${e.paymentMethod.paymentMethodCode}`,className:"payrails-generic-button"}),this.options=e,this.returnInfo=t,this.popup=null,this.isDisabled=!1,this.isLoading=!1,this.element.innerText=null!==(n=null===(i=this.options.translations)||void 0===i?void 0:i.label)&&void 0!==n?n:Bn.label,(null===(s=this.options.styles)||void 0===s?void 0:s.base)&&this.setStyles(this.options.styles.base),this.element.addEventListener("click",this.onClick.bind(this)),this.element.addEventListener("mouseenter",()=>{var e;!this.isDisabled&&(null===(e=this.options.styles)||void 0===e?void 0:e.hover)&&this.setStyles(this.options.styles.hover)}),this.element.addEventListener("mouseleave",()=>{var e;!this.isDisabled&&(null===(e=this.options.styles)||void 0===e?void 0:e.hover)&&this.removeStyles(this.options.styles.hover)}),this.paymentExecutor=new Yi(this.returnInfo),this.eventBus.on("PAYRAILS_CLIENT_SESSION_EXPIRED",()=>{this.triggerLoading(!1)})}setStyles(e){var t;const i=Object.assign(Object.assign({},null===(t=this.options.styles)||void 0===t?void 0:t.base),e);Object.keys(i).forEach(e=>{this.element.style[e]=i[e]})}removeStyles(e){var t;const i=Object.keys((null===(t=this.options.styles)||void 0===t?void 0:t.base)||{});Object.keys(e).forEach(e=>{var t,n;i.includes(e)?this.element.style[e]=null===(n=null===(t=this.options.styles)||void 0===t?void 0:t.base)||void 0===n?void 0:n[e]:this.element.style[e]=""})}triggerLoading(e){var t,i,n,s;this.isDisabled=e,this.isLoading=e,e?(this.element.innerHTML='\n <div class="dot-flashing-container">\n <div class="dot-flashing"></div>\n <span class="dot-flashing-text" aria-hidden="true">Loading</span>\n </div>\n ',(null===(t=this.options.styles)||void 0===t?void 0:t.loading)&&this.setStyles(this.options.styles.loading)):(this.element.innerText=null!==(n=null===(i=this.options.translations)||void 0===i?void 0:i.label)&&void 0!==n?n:Bn.label,this.removeStyles((null===(s=this.options.styles)||void 0===s?void 0:s.loading)||{}))}isSafari(){const e=navigator.userAgent.toLowerCase();return e.includes("safari")&&!e.includes("chrome")&&!e.includes("chromium")}onClick(){return t(this,void 0,void 0,function*(){var e,t;if(this.isDisabled)return;let i=null;this.options.openInNewTab&&this.isSafari()&&(i=window.open("","_blank"));try{this.triggerLoading(!0);if(!(yield Ds(Cs.AUTHORIZE,null!==(e=this.options.events)&&void 0!==e?e:{})))return this.triggerLoading(!1),void(i&&!i.closed&&i.close());const n=null===(t=Ni.availablePaymentMethods.find(({paymentMethodCode:e})=>e===this.options.paymentMethod.paymentMethodCode))||void 0===t?void 0:t.integrationType;if(!n)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED);const o=yield this.paymentExecutor.pay([{paymentMethodCode:this.options.paymentMethod.paymentMethodCode,integrationType:n,amount:Pi().amount}]),{action:r,link:a}=this.handleAuthorizationResult(o);if("redirect"!==r)return void(i&&!i.closed&&i.close());if(!a)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK);if(Object.keys(Vn).includes(this.options.paymentMethod.paymentMethodCode)){i&&!i.closed&&i.close();const e=Vn[this.options.paymentMethod.paymentMethodCode],t=2e4,n=2e3,s=Math.ceil((e-t)/n);return new Yi(this.returnInfo,n,s,t).pollForAuthorizationResult(Ni.url,0,["authorizeSuccessful","authorizeFailed"]).then(e=>{var t;this.handleAuthorizationResult(e),null===(t=this.popup)||void 0===t||t.unmount()}),this.createPopupWithTimeout(a,e)}return this.redirectToPaymentLink(a,i)}catch(e){i&&!i.closed&&i.close(),e instanceof s.PayrailsError&&o.PayrailsLogger.error(e.message,{error:e}),Ss(Cs.AUTHORIZE,this.options.events),this.triggerLoading(!1)}finally{this.isLoading||this.triggerLoading(!1)}})}handleAuthorizationResult(e){var t,i;if("authorizePending"===(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code)){const t=e.response.links.redirect;if(!t)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK);return{code:"authorizePending",link:t,action:"redirect"}}return"authorizeSuccessful"===(null===(i=null==e?void 0:e.finalState)||void 0===i?void 0:i.code)?(Ns(Cs.AUTHORIZE,this.options.events),{code:"authorizeSuccessful",action:"success"}):(Ss(Cs.AUTHORIZE,this.options.events,e),this.triggerLoading(!1),{code:"authorizeFailed",action:"fail"})}createPopupWithTimeout(e,t){return new Promise(()=>{const i=new xn(e,this.paymentExecutor,Object.assign(Object.assign({},this.options),Gn));this.popup=i,this.popup.mount(),setTimeout(()=>{null==i||i.unmount(),Ss(Cs.AUTHORIZE,this.options.events),this.triggerLoading(!1)},t)})}redirectToPaymentLink(e,t=null){return new Promise(i=>{if(this.options.openInNewTab){const n=t||window.open(e,"_blank");if(!n||n.closed||void 0===n.closed){o.PayrailsLogger.warn("Popup blocked. Falling back to same tab redirect."),window.location.href=e;const t=setTimeout(()=>{var e;Ss(Cs.AUTHORIZE,this.options.events),(null===(e=this.returnInfo)||void 0===e?void 0:e.error)?window.location.href=this.returnInfo.error:(this.triggerLoading(!1),this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}))},6e4);return window.addEventListener("pagehide",()=>{clearTimeout(t)}),void i()}t&&(n.location.href=e),this.monitorRedirectInNewTab(n).finally(()=>{i()})}else{window.location.href=e;const t=setTimeout(()=>{var e;Ss(Cs.AUTHORIZE,this.options.events),(null===(e=this.returnInfo)||void 0===e?void 0:e.error)?window.location.href=this.returnInfo.error:(this.triggerLoading(!1),this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}))},6e4);window.addEventListener("pagehide",()=>{clearTimeout(t)}),i()}})}monitorRedirectInNewTab(e){return t(this,void 0,void 0,function*(){var t,i,n,s,r,a;let l;try{l=Ni.url}catch(n){return o.PayrailsLogger.error("Unable to resolve workflow execution URL.",{error:n}),this.triggerLoading(!1),e.closed||e.close(),void(null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onAuthorizeFailed)||void 0===i||i.call(t,{code:exports.AuthorizationFailureReasons.UNKNOWN_ERROR,message:"Unable to resolve workflow execution URL.",rawError:n}))}const d=new Yi(this.returnInfo),c=new AbortController,{promise:u,cleanup:p}=this.watchTabClosure(e,()=>{c.signal.aborted||c.abort(jn),this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{})});try{const e=yield Promise.race([d.pollForAuthorizationResult(l,0,["authorizeSuccessful","authorizeFailed"],{signal:c.signal}),u]);c.signal.aborted||c.abort("authorization-completed"),this.handleAuthorizationResult(e)}catch(e){if(c.signal.aborted||c.abort(e),e===jn){try{const e=new Yi(this.returnInfo,1e3,3,0),t=yield e.pollForAuthorizationResult(l,0,["authorizeSuccessful","authorizeFailed"]);return void this.handleAuthorizationResult(t)}catch(e){}null===(s=null===(n=this.options.events)||void 0===n?void 0:n.onAuthorizeFailed)||void 0===s||s.call(n,{code:exports.AuthorizationFailureReasons.USER_CANCELLED,message:"User closed the payment window before completion."})}else o.PayrailsLogger.error("Failed to retrieve authorization result after redirect.",{error:e}),null===(a=null===(r=this.options.events)||void 0===r?void 0:r.onAuthorizeFailed)||void 0===a||a.call(r,{code:exports.AuthorizationFailureReasons.UNKNOWN_ERROR,message:"Failed to retrieve authorization result after redirect.",rawError:e})}finally{c.signal.aborted||c.abort("cleanup"),p(),e.closed||e.close(),this.triggerLoading(!1)}})}watchTabClosure(e,t){let i,n=!0;const s=()=>{void 0!==i&&(window.clearInterval(i),i=void 0),n=!1};return{promise:new Promise((o,r)=>{i=window.setInterval(()=>{if(!n)return;let i=!1;try{i=e.closed}catch(e){i=!0}i&&(s(),null==t||t(),r(jn))},500)}),cleanup:s}}updateStyles(e){var t,i;this.options.styles=Object.assign(Object.assign({},this.options.styles||{}),e),this.isLoading?this.setStyles((null===(t=this.options.styles)||void 0===t?void 0:t.loading)||{}):this.setStyles((null===(i=this.options.styles)||void 0===i?void 0:i.base)||{})}updateTranslations(e){var t,i;this.options.translations=Object.assign(Object.assign({},this.options.translations||{}),e),this.element.innerText=null!==(i=null===(t=this.options.translations)||void 0===t?void 0:t.label)&&void 0!==i?i:Bn.label}updateEvents(e){this.options.events=Object.assign(Object.assign({},this.options.events||{}),e)}update(e){e.styles&&this.updateStyles(e.styles),e.translations&&this.updateTranslations(e.translations),e.events&&this.updateEvents(e.events)}}const zn=e=>e===exports.PAYMENT_METHOD_CODES.GENERIC_REDIRECT?{translations:{label:"Mercado Pago",button:{label:"Pay with Mercado Pago"}}}:{translations:{label:e,button:{label:`Pay with ${e}`}}};class Hn extends An{constructor(e,t){var i,n,s,o,r,a;super(`payrails-${e.paymentMethod.paymentMethodCode}-dropin-element`,(null===(i=null==e?void 0:e.translations)||void 0===i?void 0:i.label)||zn(e.paymentMethod.paymentMethodCode).translations.label,(null===(n=e.config)||void 0===n?void 0:n.showPaymentMethodLogo)?Mn(e.paymentMethod.paymentMethodCode):void 0,null==e?void 0:e.events,null===(s=null==e?void 0:e.styles)||void 0===s?void 0:s.element),this.returnInfo=t,this.component=new Xn({styles:(null===(o=null==e?void 0:e.styles)||void 0===o?void 0:o[e.paymentMethod.paymentMethodCode])||{},translations:(null===(r=null==e?void 0:e.translations)||void 0===r?void 0:r.button)||zn(e.paymentMethod.paymentMethodCode).translations.button,events:null==e?void 0:e.events,paymentMethod:e.paymentMethod,openInNewTab:null===(a=e.config)||void 0===a?void 0:a.openInNewTab},this.returnInfo)}}class qn{constructor(e,t){this.options=e,this.paymentExecutor=t}handle3ds(e){var t,i,n;try{null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onThreeDSecureChallenge)||void 0===i||i.call(t)}catch(e){}const s=null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.links["3ds"];if(s)if(this.options.redirectFor3DS)window.location.assign(s);else{new xn(s,this.paymentExecutor,this.options).mount()}}}const Wn={apiVersion:2,apiVersionMinor:0};class $n extends Wi{static getGooglePayConfigAsArray(e){return Array.isArray(e)?e:e.allowedPaymentMethods?e.allowedPaymentMethods:[]}static getSDKClient(){return t(this,arguments,void 0,function*(e=exports.PayrailsEnvironment.TEST,t){return yield Xi.load(zi.GooglePay),$n.googleSDKClient||($n.googleSDKClient=new google.payments.api.PaymentsClient({environment:e,merchantInfo:t})),$n.googleSDKClient})}static isGooglePayAvailable(e){return t(this,arguments,void 0,function*(e,t=exports.PayrailsEnvironment.TEST,i){try{const n=yield $n.getSDKClient(t,i),s=$n.getGooglePayConfigAsArray(e),o=Object.assign(Object.assign(Object.assign({},Wn),{allowedPaymentMethods:s}),!Array.isArray(e)&&void 0!==e.existingPaymentMethodRequired&&{existingPaymentMethodRequired:e.existingPaymentMethodRequired}),{result:r}=yield n.isReadyToPay(o);return r}catch(e){return!1}})}constructor(e){var t;super("div",Object.assign(Object.assign({},e),{id:`payrails-google-pay-button-${p()}`,dataTestId:"payrails-google-pay-button"})),this.options=e,this.sdkLoadedCalled=!1,this.isProcessing=!1,this.buttonElement=null,this.paymentExecutor=new Yi(null===(t=this.options)||void 0===t?void 0:t.returnInfo),$n.isGooglePayAvailable(Ni.googlePayConfig,this.options.environment,this.options.merchantInfo).then(e=>{var t,i,n;e&&(null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onGooglePayAvailable)||void 0===n||n.call(i))})}sdkLoaded(e){return t(this,void 0,void 0,function*(){var i,n,s,o,r,a,l,d;if(this.sdkLoadedCalled)return this.buttonElement;this.sdkLoadedCalled=!0;const c=(null===(n=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===n?void 0:n.buttonColor)||"black",u=(null===(o=null===(s=this.options)||void 0===s?void 0:s.styles)||void 0===o?void 0:o.buttonType)||"long",p=(null===(a=null===(r=this.options)||void 0===r?void 0:r.styles)||void 0===a?void 0:a.buttonSizeMode)||"fill",_=(null===(d=null===(l=this.options)||void 0===l?void 0:l.styles)||void 0===d?void 0:d.buttonLocale)||void 0,h=$n.getGooglePayConfigAsArray(Ni.googlePayConfig);return this.buttonElement=e.createButton({buttonColor:c,buttonType:u,buttonSizeMode:p,buttonLocale:_,onClick:()=>t(this,void 0,void 0,function*(){if(this.isProcessing)return;this.isProcessing=!0;(yield Ds(Cs.AUTHORIZE,this.options.events))?yield this.authorize(e):this.isProcessing=!1}),allowedPaymentMethods:h}),this.element.appendChild(this.buttonElement),this.buttonElement})}onLoadPaymentData(e){return t(this,void 0,void 0,function*(){var t,i,n,s,o,r;const a={paymentToken:JSON.stringify(e)},l=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.GOOGLE_PAY,integrationType:"api",paymentInstrumentData:a,amount:Pi().amount,storeInstrument:this.shouldStoreInstrument}];if(!(yield Li(Cs.AUTHORIZE,this.options.events)))return void(this.isProcessing=!1);const d=yield this.paymentExecutor.pay(l);if("authorizePending"===(null===(t=null==d?void 0:d.finalState)||void 0===t?void 0:t.code)){new qn(this.options,this.paymentExecutor).handle3ds(d)}else"authorizeSuccessful"===(null===(i=null==d?void 0:d.finalState)||void 0===i?void 0:i.code)?Ns(Cs.AUTHORIZE,this.options.events):Ss(Cs.AUTHORIZE,this.options.events,{code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:(null===(r=null===(o=null===(s=null===(n=d.finalState)||void 0===n?void 0:n.errors)||void 0===s?void 0:s[0])||void 0===o?void 0:o.reason)||void 0===r?void 0:r.result)||"Authorization Failed"});this.isProcessing=!1})}authorize(e){return t(this,void 0,void 0,function*(){var t,i,n,s,o,r,a,l,d,c;const u=Ni.googlePayConfig,p=!Array.isArray(u),_=Object.assign(Object.assign({},p&&void 0!==u.apiVersion?{apiVersion:u.apiVersion,apiVersionMinor:u.apiVersionMinor}:Wn),{allowedPaymentMethods:$n.getGooglePayConfigAsArray(u),transactionInfo:{totalPriceStatus:"FINAL",totalPrice:null===(t=Pi().amount)||void 0===t?void 0:t.value,currencyCode:null===(i=Pi().amount)||void 0===i?void 0:i.currency,countryCode:null===(r=null===(o=null===(s=null===(n=Ni.meta)||void 0===n?void 0:n.order)||void 0===s?void 0:s.billingAddress)||void 0===o?void 0:o.country)||void 0===r?void 0:r.code},merchantInfo:{merchantId:(null===(a=u.merchantInfo)||void 0===a?void 0:a.merchantId)||(null===(l=this.options.merchantInfo)||void 0===l?void 0:l.merchantId)||"",merchantName:(null===(d=u.merchantInfo)||void 0===d?void 0:d.merchantName)||(null===(c=this.options.merchantInfo)||void 0===c?void 0:c.merchantName)||""}});p&&(void 0!==u.emailRequired&&(_.emailRequired=u.emailRequired),void 0!==u.shippingAddressRequired&&(_.shippingAddressRequired=u.shippingAddressRequired),u.shippingAddressParameters&&(_.shippingAddressParameters=u.shippingAddressParameters));try{const t=yield e.loadPaymentData(_);yield this.onLoadPaymentData(t)}catch(e){this.isProcessing=!1,Ss(Cs.AUTHORIZE,this.options.events,e)}})}mount(e){super.mount(e),(()=>{t(this,void 0,void 0,function*(){var e;try{if(yield $n.isGooglePayAvailable(Ni.googlePayConfig,this.options.environment,this.options.merchantInfo)){const t=yield $n.getSDKClient(this.options.environment,this.options.merchantInfo),i=yield this.sdkLoaded(t);this.element.appendChild(i),null===(e=this.storeInstrumentCheckbox)||void 0===e||e.mount(this.selector)}}catch(e){}})})()}unmount(){var e;null===(e=this.storeInstrumentCheckbox)||void 0===e||e.unmount(),this.buttonElement=null,super.unmount()}}$n.googleSDKClient=null;class Kn extends wn{constructor(e){var t,i;super("google-pay-dropin",(null===(i=null===(t=e.translations)||void 0===t?void 0:t.labels)||void 0===i?void 0:i.label)||"Google Pay",e.showPaymentMethodLogo?Mn("googlepay"):void 0,e.events,e.styles),this.loadElementId="google-pay-dropin-load-element",this.component=new $n(Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},e.events),{onGooglePayAvailable:()=>{this.mountAfterAvailable()}}),returnInfo:e.returnInfo}))}}class Zn extends Wi{constructor(e){var i;Zn.instance&&(Zn.instance=void 0);const n="express"===(null===(i=null==Ni?void 0:Ni.paypalConfig)||void 0===i?void 0:i.integrationMode),s=!n&&(null==e?void 0:e.showStoreInstrumentCheckbox),o=n?"unchecked":null==e?void 0:e.defaultStoreInstrumentState,r=Object.assign(Object.assign({},e),{showStoreInstrumentCheckbox:s,defaultStoreInstrumentState:o,id:"payrails-paypal-button",events:Object.assign(Object.assign({},null==e?void 0:e.events),{onSaveInstrumentCheckboxChanged:i=>t(this,void 0,void 0,function*(){var t,n,s;null===(n=null===(t=null==e?void 0:e.events)||void 0===t?void 0:t.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(t,i),null===(s=this.button)||void 0===s||s.close(),this.debouncedRender()})})});super("div",r),this.options=e,this.renderDebounceTimeout=null,this.currentAbortController=null,this.isRendering=!1,this.buttonWrapperId="payrails-paypal-button-wrapper",this.checkboxWrapperId="payrails-paypal-checkbox-wrapper",this.createOneTimeOrder=()=>t(this,void 0,void 0,function*(){var e,t,i,n,s;const o=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.PAYPAL,integrationType:"api",amount:Pi().amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!1}],r=yield this.paymentExecutor.pay(o),a=null===(i=null===(t=null===(e=r.response.links.confirm)||void 0===e?void 0:e.action)||void 0===t?void 0:t.parameters)||void 0===i?void 0:i.orderId;if(!a)throw Ss(Cs.AUTHORIZE,null===(n=this.options)||void 0===n?void 0:n.events),new Jn("No order id returned");return this.confirmLink=null===(s=r.response.links.confirm)||void 0===s?void 0:s.href,a}),this.loadPaypal().catch(()=>{}),this.element.innerHTML=`<div id="${this.buttonWrapperId}"></div><div id="${this.checkboxWrapperId}"></div>`,this.paymentExecutor=new Yi}loadPaypal(){return t(this,void 0,void 0,function*(){const e=yield Xi.load(zi.PayPal,this.paypalScriptConfig);return yield this.createPaypalButton(e)})}debouncedRender(){return this.renderDebounceTimeout&&clearTimeout(this.renderDebounceTimeout),this.currentAbortController&&this.currentAbortController.abort(),new Promise(e=>{this.renderDebounceTimeout=setTimeout(()=>t(this,void 0,void 0,function*(){try{yield this.renderButton(),e()}catch(t){console.error("Failed to render PayPal button:",t),e()}}),300)})}get paypalScriptConfig(){const e=this.shouldStoreInstrument?"tokenize":"Instant"===Ni.paypalConfig.captureMode?"capture":"authorize";return{clientId:Ni.paypalConfig.clientId,intent:e,currency:Pi().amount.currency,vault:this.shouldStoreInstrument}}createPaypalButton(e){return t(this,void 0,void 0,function*(){var t,i,n;if(!e.Buttons)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR);const o=e.Buttons(this.createPayPalButtonConfig());return null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onPaypalAvailable)||void 0===n||n.call(i),o})}createPayPalButtonConfig(){return this.shouldStoreInstrument?this.createBillingAgreementConfig():this.createOneTimeOrderConfig()}createBillingAgreementConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{onApprove:this.approvePayment.bind(this),createBillingAgreement:()=>t(this,void 0,void 0,function*(){var e,t,i,n;const s=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.PAYPAL,integrationType:"api",amount:Pi().amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!0}],o=yield this.paymentExecutor.pay(s);return this.confirmLink=null===(e=o.response.links.confirm)||void 0===e?void 0:e.href,(null===(n=null===(i=null===(t=o.response.links.confirm)||void 0===t?void 0:t.action)||void 0===i?void 0:i.parameters)||void 0===n?void 0:n.tokenId)||""})})}onCancel(){var e;this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}),Ss(Cs.AUTHORIZE,null===(e=this.options)||void 0===e?void 0:e.events)}createOneTimeOrderConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{createOrder:this.createOneTimeOrder.bind(this),onApprove:this.approvePayment.bind(this)})}createBaseConfig(){var e,i,n,r,a,l,d,c,u,p;return{fundingSource:"paypal",style:{color:(null===(i=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===i?void 0:i.color)||"gold",height:(null===(r=null===(n=this.options)||void 0===n?void 0:n.styles)||void 0===r?void 0:r.height)||40,label:(null===(l=null===(a=this.options)||void 0===a?void 0:a.styles)||void 0===l?void 0:l.label)||"paypal",shape:(null===(c=null===(d=this.options)||void 0===d?void 0:d.styles)||void 0===c?void 0:c.shape)||"rect",tagline:(null===(p=null===(u=this.options)||void 0===u?void 0:u.styles)||void 0===p?void 0:p.tagline)||!1,disableMaxWidth:!0},onError:e=>{var t;this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}),Ss(Cs.AUTHORIZE,null===(t=this.options)||void 0===t?void 0:t.events,e)},onClick:(e,i)=>t(this,void 0,void 0,function*(){var e;return(yield Ds(Cs.AUTHORIZE,null===(e=this.options)||void 0===e?void 0:e.events))?i.resolve():i.reject()}),onCancel:this.onCancel.bind(this),onShippingAddressChange:(e,i)=>t(this,void 0,void 0,function*(){var n;let r;e.shippingAddress&&(r={deliveryAddress:{city:e.shippingAddress.city,postalCode:e.shippingAddress.postalCode,state:e.shippingAddress.state,country:{code:e.shippingAddress.countryCode}}});const a=yield((e,i)=>t(void 0,void 0,void 0,function*(){if(null==e?void 0:e.onDeliveryAddressChanged)try{const t=yield e.onDeliveryAddressChanged(i);if(!t){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onDeliveryAddressChanged resolved to false"});return o.PayrailsLogger.error(e.message,{error:e}),!1}return t}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onDeliveryAddressChanged threw an error",cause:e});return o.PayrailsLogger.error(t.message,{error:t}),!1}return!0}))(null===(n=this.options)||void 0===n?void 0:n.events,r);if(!a)return i.reject()})}}approvePayment(e){return t(this,void 0,void 0,function*(){var t,i,n,s,o,r,a,l,d;if(!this.confirmLink)throw Ss(Cs.AUTHORIZE,null===(t=this.options)||void 0===t?void 0:t.events),new Jn("No confirm link");const c={};this.shouldStoreInstrument&&e.billingToken&&(c.tokenId=e.billingToken),this.fraudNetGuid&&(c.riskSessionCorrelationId=this.fraudNetGuid);if(!(yield Li(Cs.AUTHORIZE,null===(i=this.options)||void 0===i?void 0:i.events)))throw new Jn("Authorization request start validation failed");const u=yield this.paymentExecutor.confirm(this.confirmLink,c);"authorizeSuccessful"===(null===(n=u.finalState)||void 0===n?void 0:n.code)?Ns(Cs.AUTHORIZE,null===(s=this.options)||void 0===s?void 0:s.events):Ss(Cs.AUTHORIZE,null===(o=this.options)||void 0===o?void 0:o.events,{code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:(null===(d=null===(l=null===(a=null===(r=u.finalState)||void 0===r?void 0:r.errors)||void 0===a?void 0:a[0])||void 0===l?void 0:l.reason)||void 0===d?void 0:d.result)||"Authorization Failed"})})}get fraudNetGuid(){var e,t;return null===(t=null===(e=window.PayrailsData)||void 0===e?void 0:e.riskIds)||void 0===t?void 0:t.fraudNet}mount(e){Zn.instance||(Zn.instance=this,super.mount(e),(()=>{t(this,void 0,void 0,function*(){yield this.debouncedRender()})})())}renderButton(){return t(this,void 0,void 0,function*(){var e;this.isRendering&&this.currentAbortController&&this.currentAbortController.abort(),this.currentAbortController=new AbortController;const t=this.currentAbortController.signal;try{this.isRendering=!0,this.button&&(this.button.close(),this.button=void 0);const i=yield Promise.race([this.loadPaypal(),new Promise((e,i)=>{t.addEventListener("abort",()=>i(new Qn("PayPal button loading aborted")))})]);if(t.aborted)return;i&&(this.button=i,yield null===(e=this.button)||void 0===e?void 0:e.render(`#${this.buttonWrapperId}`))}catch(e){if(!t.aborted)throw e}finally{t.aborted||(this.isRendering=!1,this.currentAbortController=null)}})}unmount(){var e;this.renderDebounceTimeout&&clearTimeout(this.renderDebounceTimeout),this.currentAbortController&&this.currentAbortController.abort(),null===(e=this.button)||void 0===e||e.close(),this.isRendering=!1,Zn.instance=void 0,super.unmount()}}class Jn extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION,{description:`PaypalOrderError: ${e}`,cause:t})}}class Qn extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT,{description:`PaypalButtonError: ${e}`,cause:t})}}class es extends wn{constructor(e){var t,i;super("payrails-paypal-button-dropin",(null===(i=null===(t=null==e?void 0:e.translations)||void 0===t?void 0:t.labels)||void 0===i?void 0:i.label)||"PayPal",(null==e?void 0:e.showPaymentMethodLogo)?Mn("paypal"):void 0,{onActivate:()=>{var t;super.activate(),(null===(t=null==e?void 0:e.events)||void 0===t?void 0:t.onPaymentOptionVisibilityChange)&&e.events.onPaymentOptionVisibilityChange()}},null==e?void 0:e.styles),this.loadElementId="paypal-dropin-load-element",this.component=new Zn(Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},null==e?void 0:e.events),{onPaypalAvailable:()=>{this.mountAfterAvailable()}})}))}}class ts extends Hi{constructor(e,t,i){var n,s,o;super("fieldset",{id:"payrails-dropin-component"}),this.collectContainer=e,this.clientConfig=t,this.dropinConfig=i,this.applyStyles();void 0!==(null===(s=null===(n=this.dropinConfig.paymentMethodsConfiguration)||void 0===n?void 0:n.cards)||void 0===s?void 0:s.showExistingCards)&&console.warn("The `showExistingCards` option is deprecated and will be removed in a future version. Please use `showStoredInstruments` instead.");const r=new Map;Ni.storedDropinInstruments.forEach(e=>{if(this.isStoredInstrumentEnabled(e.paymentMethod)){this.cardPaymentButton=this.createCardPaymentButton();const t=this.createStoredInstrumentElement(e);t&&r.set(t.identifier,t)}});const a={[exports.PAYMENT_METHOD_CODES.CARD]:this.createCreditCardButton.bind(this),[exports.PAYMENT_METHOD_CODES.PAYPAL]:this.createPayPalButton.bind(this),[exports.PAYMENT_METHOD_CODES.GOOGLE_PAY]:this.createGooglePayButton.bind(this),[exports.PAYMENT_METHOD_CODES.APPLE_PAY]:this.createApplePayButton.bind(this)};Ni.availablePaymentMethods.forEach(e=>{const t=e.paymentMethodCode;if(t&&a[t]){const i=(0,a[t])(Ni.getPaymentMethodConfig(e));r.set(i.identifier,i)}else if(this.isHppIntegration(e)&&t){const t=this.createHppIntegrationElement(e);r.set(t.identifier,t)}}),this.element.addEventListener("change",e=>{var t,i;const n=(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.value)||"";r.forEach(e=>{e.deactivate()}),null===(i=r.get(n))||void 0===i||i.activate()}),1===this.totalPaymentOptions&&this.element.classList.add("payrails-dropin-component--single"),this.subElements.push(...Array.from(r.values())),this.loadingScreen=new Pn({styles:null===(o=this.dropinConfig.styles)||void 0===o?void 0:o.loadingScreen})}get returnInfo(){return this.dropinConfig.returnInfo||this.clientConfig.returnInfo}isHppIntegration(e){var t;return e.paymentMethodCode===exports.PAYMENT_METHOD_CODES.GENERIC_REDIRECT||(null===(t=e.clientConfig)||void 0===t?void 0:t.flow)===Ci.REDIRECT}createStoredInstrumentElement(e){var t;let i;if(this.cardPaymentButton=this.createCardPaymentButton(),e.paymentMethod!==exports.PAYMENT_METHOD_CODES.BANK_ACCOUNT)return e.paymentMethod===exports.PAYMENT_METHOD_CODES.CARD&&Ni.isPaymentInstallmentsEnabled(e.paymentMethod)&&(i=this.createInstallmentsDropdown(e)),new gn(e,this.cardPaymentButton,e=>{var t,i;if(this.cardPaymentButton){this.cardPaymentButton.selectedInstrument=e;const n=Ni.getPaymentMethodForStoredInstrument(e);null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onPaymentOptionSelected)||void 0===i||i.call(t,{paymentMethod:n,instrument:e})}},null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.element,i)}createInstallmentsDropdown(e){var t,i,n;const s=this.getInstallmentOptionsForInstrument(e);return new cn("span",{installmentConfig:{installmentCurrency:Pi().amount.currency,installmentOptions:s,defaultInstallment:null===(n=null===(i=null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.cards)||void 0===i?void 0:i.installmentConfig)||void 0===n?void 0:n.defaultInstallment},id:`payrails-card-form-payment-installments-${e.id}`,className:"payrails-card-form-payment-installments-container"})}getInstallmentOptionsForInstrument(e){var t,i,n;const s=e.paymentMethod,o=Ni.getPaymentInstallmentOptions(s),r=null===(n=null===(i=null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.binLookup)||void 0===i?void 0:i.issuerCountry)||void 0===n?void 0:n.code;return r?o[r]:null}updateInstallmentConfig(e){var t,i,n;const s=null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.cards;s&&e&&Object.prototype.hasOwnProperty.call(e,"defaultInstallment")&&(s.installmentConfig={defaultInstallment:null!==(i=e.defaultInstallment)&&void 0!==i?i:null}),null===(n=this.cardForm)||void 0===n||n.updateInstallmentConfig(e),this.subElements.forEach(t=>{t instanceof gn&&t.updateInstallmentConfig(e)})}createHppIntegrationElement(e){var t,i,n,r,a,l,d,c,u,p,_,h;const E=e.paymentMethodCode;if(!E){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED,{description:`Payment method code is missing for payment method - ${JSON.stringify(e)}`});throw o.PayrailsLogger.error(t.message,{error:t}),t}return new Hn({paymentMethod:e,config:Object.assign(Object.assign({},null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t[E]),{showPaymentMethodLogo:null!==(l=null!==(r=null===(n=null===(i=this.dropinConfig.paymentMethodsConfiguration)||void 0===i?void 0:i[E])||void 0===n?void 0:n.showPaymentMethodLogo)&&void 0!==r?r:null===(a=this.dropinConfig.paymentMethodsConfiguration)||void 0===a?void 0:a.showPaymentMethodLogo)&&void 0!==l&&l}),styles:{element:null===(c=null===(d=this.dropinConfig)||void 0===d?void 0:d.styles)||void 0===c?void 0:c.element,button:null===(_=null===(p=null===(u=this.dropinConfig)||void 0===u?void 0:u.styles)||void 0===p?void 0:p[E])||void 0===_?void 0:_.button},translations:null===(h=this.dropinConfig.translations)||void 0===h?void 0:h[E],events:Object.assign(Object.assign({},this.getElementEvents()),{onPaymentOptionVisibilityChange:()=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onPaymentOptionSelected)||void 0===i||i.call(t,{paymentMethod:e})}})},this.returnInfo)}get totalPaymentOptions(){return Ni.availablePaymentMethods.length+Ni.storedDropinInstruments.length}createCreditCardButton(e){var t,i,n,s,o,r,a;return this.creditCard=new Yn(this.createCardForm(),this.createCardPaymentButton(),{events:Object.assign(Object.assign({},this.getElementEvents()),{onPaymentOptionVisibilityChange:()=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onPaymentOptionSelected)||void 0===i||i.call(t,{paymentMethod:e})}}),styles:null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.element,showPaymentMethodLogo:null!==(r=null!==(s=null===(n=null===(i=this.dropinConfig.paymentMethodsConfiguration)||void 0===i?void 0:i.cards)||void 0===n?void 0:n.showPaymentMethodLogo)&&void 0!==s?s:null===(o=this.dropinConfig.paymentMethodsConfiguration)||void 0===o?void 0:o.showPaymentMethodLogo)&&void 0!==r&&r,translations:null===(a=this.dropinConfig.translations)||void 0===a?void 0:a.cardForm}),this.creditCard}createGooglePayButton(e){var t,i,n,s,o,r,a,l;return this.googlePay=new Kn(Object.assign({environment:this.clientConfig.environment||exports.PayrailsEnvironment.TEST,events:Object.assign(Object.assign({},this.getElementEvents()),{onPaymentOptionVisibilityChange:()=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onPaymentOptionSelected)||void 0===i||i.call(t,{paymentMethod:e})}}),redirectFor3DS:this.clientConfig.redirectFor3DS,showPaymentMethodLogo:null!==(o=null!==(n=null===(i=null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.googlePay)||void 0===i?void 0:i.showPaymentMethodLogo)&&void 0!==n?n:null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s.showPaymentMethodLogo)&&void 0!==o&&o,styles:Object.assign(Object.assign({},null===(r=this.dropinConfig.styles)||void 0===r?void 0:r.googlePayButton),null===(a=this.dropinConfig.styles)||void 0===a?void 0:a.element),returnInfo:this.returnInfo},null===(l=this.dropinConfig.paymentMethodsConfiguration)||void 0===l?void 0:l.googlePay)),this.googlePay}createPayPalButton(e){var t,i,n,s,o,r,a,l;return this.paypal=new es(Object.assign(Object.assign({showPaymentMethodLogo:null!==(o=null!==(n=null===(i=null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.payPal)||void 0===i?void 0:i.showPaymentMethodLogo)&&void 0!==n?n:null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s.showPaymentMethodLogo)&&void 0!==o&&o},null===(r=this.dropinConfig.paymentMethodsConfiguration)||void 0===r?void 0:r.payPal),{styles:Object.assign(Object.assign({},null===(a=this.dropinConfig.styles)||void 0===a?void 0:a.paypalButton),null===(l=this.dropinConfig.styles)||void 0===l?void 0:l.element),events:Object.assign(Object.assign({},this.getElementEvents()),{onPaymentOptionVisibilityChange:()=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onPaymentOptionSelected)||void 0===i||i.call(t,{paymentMethod:e})}})})),this.paypal}createCardForm(){var e,t,i,n,s,o,r,a;if(!this.cardForm){const l=null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.cards,d=Boolean(null==l?void 0:l.showStoreInstrumentCheckbox),c=Boolean(null==l?void 0:l.showCardHolderName),u=Boolean(null==l?void 0:l.alwaysStoreInstrument),p=Boolean(null==l?void 0:l.showSingleExpiryDateField),_=(null==l?void 0:l.layout)||[];this.cardForm=new In(this.collectContainer,{showStoreInstrumentCheckbox:d,showCardHolderName:c,showSingleExpiryDateField:p,alwaysStoreInstrument:u,installmentConfig:null===(i=null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.cards)||void 0===i?void 0:i.installmentConfig,layout:_,translations:Object.assign(Object.assign({},null===(n=this.dropinConfig.translations)||void 0===n?void 0:n.cardForm),{addressSelector:null===(s=this.dropinConfig.translations)||void 0===s?void 0:s.addressSelector}),styles:Object.assign(Object.assign(Object.assign({},null===(o=this.dropinConfig.styles)||void 0===o?void 0:o.cardForm),null===(r=this.dropinConfig.styles)||void 0===r?void 0:r.element),{addressSelector:null===(a=this.dropinConfig.styles)||void 0===a?void 0:a.addressSelector}),events:Object.assign(Object.assign({},this.getElementEvents()),{onFocus:()=>{var e;null===(e=this.creditCard)||void 0===e||e.activate()},onChange:({isValid:e})=>{var t,i,n,s,o,r,a;const l="boolean"!=typeof(null===(i=null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.cards)||void 0===i?void 0:i.disablePaymentButton)||(null===(s=null===(n=this.dropinConfig.paymentMethodsConfiguration)||void 0===n?void 0:n.cards)||void 0===s?void 0:s.disablePaymentButton)?!e:null===(r=null===(o=this.dropinConfig.paymentMethodsConfiguration)||void 0===o?void 0:o.cards)||void 0===r?void 0:r.disablePaymentButton;null===(a=this.cardPaymentButton)||void 0===a||a.setDisabled(l)},onSaveInstrumentCheckboxChanged:e=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onSaveInstrumentCheckboxChanged)||void 0===i||i.call(t,e)}})})}return this.cardPaymentButton&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardForm}createApplePayButton(e){var i,n,s,o,r,a,l,d,c;return this.applePay=new kn(Object.assign(Object.assign({events:Object.assign(Object.assign({},this.getElementEvents()),{onAuthorizeSuccess:e=>{var t;if(e)if("authorizeSuccessful"===(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code))this.onAuthorizeSuccess();else this.onAuthorizeFailed()},onPaymentOptionVisibilityChange:()=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onPaymentOptionSelected)||void 0===i||i.call(t,{paymentMethod:e})},onPaymentButtonClicked:e=>t(this,void 0,void 0,function*(){var t,i;return!!(yield null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onPaymentButtonClicked)||void 0===i?void 0:i.call(t,e))})})},null===(i=this.dropinConfig.paymentMethodsConfiguration)||void 0===i?void 0:i.applePay),{styles:Object.assign(Object.assign({},null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.applePayButton),null===(s=this.dropinConfig.styles)||void 0===s?void 0:s.element),translations:null===(o=this.dropinConfig.translations)||void 0===o?void 0:o.applePayButton,showPaymentMethodLogo:null!==(c=null!==(l=null===(a=null===(r=this.dropinConfig.paymentMethodsConfiguration)||void 0===r?void 0:r.applePay)||void 0===a?void 0:a.showPaymentMethodLogo)&&void 0!==l?l:null===(d=this.dropinConfig.paymentMethodsConfiguration)||void 0===d?void 0:d.showPaymentMethodLogo)&&void 0!==c&&c})),this.applePay}createCardPaymentButton(){var e,t,i,n;return this.cardPaymentButton||(this.cardPaymentButton=new Ms({styles:null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.cardPaymentButton,translations:null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.cardPaymentButton,redirectFor3DS:this.clientConfig.redirectFor3DS,disabledByDefault:null===(n=null===(i=this.dropinConfig.paymentMethodsConfiguration)||void 0===i?void 0:i.cards)||void 0===n?void 0:n.disablePaymentButton,events:this.getElementEvents()},this.returnInfo)),this.cardForm&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardPaymentButton}onAuthorizeSuccess(){var e,t,i,n,s,o,r;null===(e=this.loadingScreen)||void 0===e||e.unmount(),this.subElements.forEach(e=>e.unmount()),new Sn({translations:{label:null===(n=null===(i=null===(t=this.dropinConfig)||void 0===t?void 0:t.translations)||void 0===i?void 0:i.paymentResult)||void 0===n?void 0:n.success},styles:null===(o=null===(s=this.dropinConfig)||void 0===s?void 0:s.styles)||void 0===o?void 0:o.authSuccess}).mount(this.selector),(null===(r=this.dropinConfig.events)||void 0===r?void 0:r.onAuthorizeSuccess)&&this.dropinConfig.events.onAuthorizeSuccess()}getElementEvents(){return Object.assign(Object.assign({},this.dropinConfig.events),{onAuthorizeSuccess:this.onAuthorizeSuccess.bind(this),onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onAuthorizePending:this.onAuthorizePending.bind(this),onAvailable:()=>{var e;(1===this.totalPaymentOptions||(null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.preselectFirstPaymentOption))&&setTimeout(()=>{try{this.subElements[0].activate()}catch(e){o.PayrailsLogger.error("Error while auto-activating the first payment option",{error:new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING,{cause:e})})}},0)},onPaymentButtonClicked:e=>t(this,void 0,void 0,function*(){var t,i,n,s;null===(t=this.loadingScreen)||void 0===t||t.mount(this.selector);let o=!0;return(null===(i=this.dropinConfig.events)||void 0===i?void 0:i.onPaymentButtonClicked)&&(o=!!(yield null===(s=null===(n=this.dropinConfig.events)||void 0===n?void 0:n.onPaymentButtonClicked)||void 0===s?void 0:s.call(n,e))),o})})}onAuthorizePending(){var e,t,i,n,s,o,r,a;null===(e=this.loadingScreen)||void 0===e||e.unmount(),this.subElements.forEach(e=>e.unmount()),new Sn({translations:{label:(null===(n=null===(i=null===(t=this.dropinConfig)||void 0===t?void 0:t.translations)||void 0===i?void 0:i.paymentResult)||void 0===n?void 0:n.pending)||"Payment pending"},styles:null===(o=null===(s=this.dropinConfig)||void 0===s?void 0:s.styles)||void 0===o?void 0:o.authSuccess}).mount(this.selector),null===(a=null===(r=this.dropinConfig.events)||void 0===r?void 0:r.onAuthorizePending)||void 0===a||a.call(r)}getErrorMessage(e){var t,i,n,s,o,r;let a=null===(i=null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.paymentResult)||void 0===i?void 0:i.fail;return(null==e?void 0:e.message)&&(null===(s=null===(n=this.dropinConfig.translations)||void 0===n?void 0:n.errorMessages)||void 0===s?void 0:s[null==e?void 0:e.message])&&(a=null===(r=null===(o=this.dropinConfig.translations)||void 0===o?void 0:o.errorMessages)||void 0===r?void 0:r[null==e?void 0:e.message]),a}onAuthorizeFailed(e){return t(this,void 0,void 0,function*(){var t,i,n,s,o;null===(t=this.loadingScreen)||void 0===t||t.unmount();new Nn({translations:{label:this.getErrorMessage(e)},styles:null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.authFailed,configuration:null===(n=this.dropinConfig.configuration)||void 0===n?void 0:n.authFailMsg}).mount(this.selector),null===(o=null===(s=this.dropinConfig.events)||void 0===s?void 0:s.onAuthorizeFailed)||void 0===o||o.call(s,e)})}isStoredInstrumentEnabled(e){var t,i,n,s,o,r;switch(e){case exports.PAYMENT_METHOD_CODES.CARD:return!1!==(null===(i=null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.cards)||void 0===i?void 0:i.showStoredInstruments)&&!1!==(null===(s=null===(n=this.dropinConfig.paymentMethodsConfiguration)||void 0===n?void 0:n.cards)||void 0===s?void 0:s.showExistingCards);case exports.PAYMENT_METHOD_CODES.PAYPAL:case exports.PAYMENT_METHOD_CODES.GOOGLE_PAY:case exports.PAYMENT_METHOD_CODES.APPLE_PAY:return!1!==(null===(r=null===(o=this.dropinConfig.paymentMethodsConfiguration)||void 0===o?void 0:o[e])||void 0===r?void 0:r.showStoredInstruments);default:return!1}}applyStyles(){var e;(null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.container)&&Object.assign(this.element.style,this.dropinConfig.styles.container.styles)}fetchBinLookup(){return t(this,void 0,void 0,function*(){var e;return null===(e=this.cardForm)||void 0===e?void 0:e.fetchBinLookup()})}}class is extends Hi{tokenize(e){return t(this,void 0,void 0,function*(){const t=yield this.collect(),i=Pi(),n=i.vaultConfiguration.links.saveInstrument,r=i.token;if(!n.href){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND,{description:"Save instrument URL not available!"});throw o.PayrailsLogger.error(e.message,{error:e}),e}const a=yield this.constructSaveInstrumentBody(t,e);return(yield Ai({url:n.href,token:r,body:a})).res})}}class ns{static minLength(e,t){return!!(t.minLength&&e.length<t.minLength)}static maxLength(e,t){return!!(t.maxLength&&e.length>t.maxLength)}static required(e,t,i){return!(!t||e)}static pattern(e,t){if(!t.pattern)return!1;return!new RegExp(t.pattern).test(e)}static oneOf(e,t){if(!t.oneOf||0===t.oneOf.length)return!1;return!t.oneOf.map(e=>e.const).includes(e)}}class ss extends Hi{get name(){return this.options.name}get isVisible(){return this._isVisible}get isRequired(){return this._isRequired}constructor(e){super("div",{id:e.id,className:"payrails-dynamic-element-form-field"}),this.options=e,this.errors=[],this._isVisible=!0,this._isRequired=!!this.options.required,this.makeField()}setVisible(e){this._isVisible=e,this.element.style.display=e?"block":"none"}setRequired(e){this._isRequired=e}validate(e=!1){e||this.clearError();const t=[];if(this._isVisible&&this._isRequired){ns.required(this.value,!0,this.options.property)&&t.push(this.options.errors.required)}if(this.value){ns.minLength(this.value,this.options.property)&&t.push(this.options.errors.minLength);ns.maxLength(this.value,this.options.property)&&t.push(this.options.errors.maxLength);ns.pattern(this.value,this.options.property)&&t.push(this.options.errors.pattern);ns.oneOf(this.value,this.options.property)&&t.push(this.options.errors.oneOf)}if(e){return 0===t.length}return this.setErrors(t),this.isValid?this.updateStyles("base"):this.updateStyles("invalid"),this.isValid}makeField(){this.createLabel(),this.createComponentContainer(),this.createErrorMessageContainer()}createLabel(){this.label=document.createElement("label"),this.label.textContent=this.options.label,this.label.className="payrails-dynamic-element-form-field-label",this.label.htmlFor=this.options.name,this.element.appendChild(this.label)}createComponentContainer(){this.componentContainer=document.createElement("div"),this.componentContainer.className="payrails-dynamic-element-form-field-component",this.element.appendChild(this.componentContainer)}createErrorMessageContainer(){this.errorMessage=document.createElement("div"),this.errorMessage.className="payrails-dynamic-element-form-field-error",this.errorMessage.style.display="none",this.element.appendChild(this.errorMessage)}setErrors(e){var t;if(this.errors=e,this.errorMessage){for(;this.errorMessage.firstChild;)this.errorMessage.removeChild(this.errorMessage.firstChild);if(e.length>0){const t=document.createElement("ul");e.forEach(e=>{var i;const n=document.createElement("li");n.textContent=e,(null===(i=this.options.styles)||void 0===i?void 0:i.errors)&&Object.assign(n.style,this.options.styles.errors),t.appendChild(n)}),this.errorMessage.appendChild(t),this.errorMessage.style.display="block"}else this.errorMessage.style.display="none";(null===(t=this.options.styles)||void 0===t?void 0:t.errors)&&Object.assign(this.errorMessage.style,this.options.styles.errors),this.isValid?this.element.classList.remove("error"):this.element.classList.add("error")}}clearError(){this.errors=[],this.errorMessage&&(this.errorMessage.textContent="",this.errorMessage.style.display="none",this.element.classList.remove("error"))}injectElement(e){this.componentContainer&&(e.id=this.options.name,e.setAttribute("name",this.options.name),this.componentContainer.appendChild(e),this.options.events.onReady(this.value))}get isValid(){return 0===this.errors.length}}class os extends ss{constructor(e){super(e),this.makeComponent(),this.attachEvents()}makeComponent(){this.component=document.createElement("input"),this.component.type="text",this.component.className="payrails-dynamic-element-input",this.component.placeholder=this.options.placeholder,this.updateStyles("base"),this.injectElement(this.component)}attachEvents(){this.component&&(this.component.addEventListener("change",e=>{var t,i;e.stopPropagation(),null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onChange)||void 0===i||i.call(t,this.value)}),this.component.addEventListener("input",()=>{var e,t;this.updateValidationState(),null===(t=null===(e=this.options.events)||void 0===e?void 0:e.onChange)||void 0===t||t.call(e,this.value)}),this.component.addEventListener("blur",()=>{var e,t;this.updateStyles("base"),this.updateValidationState(),null===(t=null===(e=this.options.events)||void 0===e?void 0:e.onBlur)||void 0===t||t.call(e)}),this.component.addEventListener("focus",()=>{this.updateStyles("focus")}))}updateValidationState(){this.validate(),this.isValid?(this.updateStyles("complete"),this.updateCustomValidity(!0)):(this.updateStyles("invalid"),this.updateCustomValidity(!1))}updateStyles(e){var t,i;(null===(i=null===(t=this.options.styles)||void 0===t?void 0:t.input)||void 0===i?void 0:i[e])&&this.component&&Object.assign(this.component.style,this.options.styles.input[e])}updateCustomValidity(e){this.component&&this.component.setCustomValidity(e?"":this.errors.join(", "))}get value(){var e;return(null===(e=this.component)||void 0===e?void 0:e.value)||""}set value(e){this.component&&(this.component.value=e,this.updateValidationState())}}class rs extends ss{get value(){var e;return(null===(e=this.component)||void 0===e?void 0:e.value)||""}set value(e){this.component&&(this.component.value=e)}constructor(e){super(e),this.selectOptions=e.options,this.makeComponent(),this.attachEvents()}attachEvents(){this.component&&(this.component.addEventListener("change",e=>{var t,i;e.stopPropagation(),this.validate(),null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onChange)||void 0===i||i.call(t,this.value)}),this.component.addEventListener("blur",()=>{var e,t;this.updateStyles("base"),this.validate(),null===(t=null===(e=this.options.events)||void 0===e?void 0:e.onBlur)||void 0===t||t.call(e)}),this.component.addEventListener("focus",()=>{this.updateStyles("focus")}))}makeComponent(){this.component=document.createElement("select"),this.component.className="payrails-dynamic-element-select",this.selectOptions.forEach(e=>{const t=document.createElement("option");t.value=e.value,t.textContent=e.label,this.component&&this.component.appendChild(t)}),this.updateStyles("base"),this.injectElement(this.component)}updateStyles(e){var t,i;(null===(i=null===(t=this.options.styles)||void 0===t?void 0:t.select)||void 0===i?void 0:i[e])&&this.component&&Object.assign(this.component.style,this.options.styles.select[e])}}class as extends ss{get value(){return this.currentValue}set value(e){this.currentValue!==e&&(this.currentValue=e,this.updateTabStates())}constructor(e){var t,i,n,s;super(e),this.tabs=new Map,this.options=e,this.tabOptions=e.options,this.currentValue=(null===(t=this.tabOptions[0])||void 0===t?void 0:t.value)||"",this.component=document.createElement("div"),this.component.className="payrails-dynamic-element-tabs",(null===(s=null===(n=null===(i=this.options.styles)||void 0===i?void 0:i.tabs)||void 0===n?void 0:n.container)||void 0===s?void 0:s.base)&&Object.assign(this.component.style,this.options.styles.tabs.container.base),this.makeTabs(),this.injectElement(this.component)}createTab(e){var t,i,n;const s=document.createElement("button");return s.type="button",s.textContent=e.label,s.className="payrails-dynamic-element-tab",(null===(n=null===(i=null===(t=this.options.styles)||void 0===t?void 0:t.tabs)||void 0===i?void 0:i.tab)||void 0===n?void 0:n.base)&&Object.assign(s.style,this.options.styles.tabs.tab.base),s.addEventListener("click",t=>{var i,n;t.stopPropagation(),t.stopImmediatePropagation(),this.value=e.value,this.options.events.onChange(this.value),null===(n=null===(i=this.options.events)||void 0===i?void 0:i.onBlur)||void 0===n||n.call(i)}),s}makeTabs(){this.component.innerHTML="",this.tabs.clear(),this.tabOptions.forEach(e=>{const t=this.createTab(e);this.component.appendChild(t),this.tabs.set(e.value,t)}),this.updateTabStates()}updateTabStates(){this.tabs.forEach((e,t)=>{var i,n,s,o,r,a;e.classList.toggle("active",t===this.currentValue),e.removeAttribute("style"),t===this.currentValue&&(null===(s=null===(n=null===(i=this.options.styles)||void 0===i?void 0:i.tabs)||void 0===n?void 0:n.tab)||void 0===s?void 0:s.active)?Object.assign(e.style,this.options.styles.tabs.tab.active):(null===(a=null===(r=null===(o=this.options.styles)||void 0===o?void 0:o.tabs)||void 0===r?void 0:r.tab)||void 0===a?void 0:a.base)&&Object.assign(e.style,this.options.styles.tabs.tab.base)})}updateStyles(){}}const ls="ui:position";function ds(e){return t(this,void 0,void 0,function*(){if(!e||"object"!=typeof e)return e;const i=cs(e);if(0===i.size)return e;const n=yield function(e){return t(this,void 0,void 0,function*(){const i=new Map,n=Array.from(e).map(e=>t(this,void 0,void 0,function*(){try{const t=(yield Qi({url:e})).res;i.set(e,t)}catch(t){console.warn(`Failed to fetch schema from ${e}:`,t)}}));return yield Promise.all(n),i})}(i);return us(e,n)})}function cs(e,t=new Set){return Array.isArray(e)?e.forEach(e=>cs(e,t)):e&&"object"==typeof e&&(e.$ref&&/^https?:\/\//.test(e.$ref)&&t.add(e.$ref),Object.values(e).forEach(e=>cs(e,t))),t}function us(e,t){if(Array.isArray(e))return e.map(e=>us(e,t));if(e&&"object"==typeof e){if(e.$ref&&/^https?:\/\//.test(e.$ref)){if(!t.has(e.$ref))return;const i=us(t.get(e.$ref),t);return void 0!==e[ls]?Object.assign(Object.assign({},i),{[ls]:e[ls]}):i}const i={};for(const[n,s]of Object.entries(e)){const e=us(s,t);void 0!==e&&(i[n]=e)}return i}return e}function ps(e,t,i){var n,s;const o=null===(n=e.oneOf)||void 0===n?void 0:n.find(e=>{var n,s;return(null===(s=null===(n=e.properties)||void 0===n?void 0:n[t])||void 0===s?void 0:s.const)===i});if(!o)return{};const r=new Set(o.required||[]),a=new Set((null===(s=e.oneOf)||void 0===s?void 0:s.flatMap(e=>e.required||[]))||[]);return Object.fromEntries(Array.from(a).filter(e=>e!==t).map(e=>[e,{isVisible:r.has(e),isRequired:r.has(e)}]))}function _s(e,t,i,n){var s,o,r,a,l,d,c,u,p,_,h,E;return{id:`payrails-dynamic-element-field:${e}`,name:e,property:t,label:null!==(a=null!==(r=null===(o=null===(s=null==n?void 0:n.fields)||void 0===s?void 0:s[e])||void 0===o?void 0:o.label)&&void 0!==r?r:t.title)&&void 0!==a?a:`${e}:label`,placeholder:null!==(c=null===(d=null===(l=null==n?void 0:n.fields)||void 0===l?void 0:l[e])||void 0===d?void 0:d.placeholder)&&void 0!==c?c:`${e}:placeholder`,errors:Ki({required:"This field is required",minLength:"This field is too short",maxLength:"This field is too long",pattern:"This field is invalid",oneOf:"This field is invalid"},null!==(u=t.errorMessage)&&void 0!==u?u:{},null!==(p=null==n?void 0:n.errors)&&void 0!==p?p:{},null!==(E=null===(h=null===(_=null==n?void 0:n.fields)||void 0===_?void 0:_[e])||void 0===h?void 0:h.errors)&&void 0!==E?E:{}),required:i}}function hs(e){var t,i;return null!==(i=null===(t=e.oneOf)||void 0===t?void 0:t.map(e=>({value:String(e.const),label:e.title})))&&void 0!==i?i:[]}class Es extends is{constructor(e,t,i){super("div",{id:"payrails-dynamic-element-form",className:"payrails-dynamic-element-form"}),this.options=e,this.formConfig=t,this.returnInfo=i,this.formFields=new Map,this.formData={},this.__schema=null,this._previousFormValidState=null}collect(){return t(this,void 0,void 0,function*(){if(!this.parentElement)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_NOT_MOUNTED,{description:"Dynamic element form is not mounted"});let e={};const t=Object.fromEntries(this.formFields.entries());if(Object.values(t).forEach(t=>{t.validate(),t.isVisible&&(e=Pt(e,t.name,t.value))}),!this.isFormValid())throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_FORM_INVALID,{description:"Dynamic element form is invalid"});return e})}constructSaveInstrumentBody(e,i){return t(this,void 0,void 0,function*(){var t;return{data:e,merchantReference:Ni.response.merchantReference,holderReference:Ni.response.holderReference,holderId:Ni.response.holderId,paymentMethod:this.options.paymentMethod.paymentMethodCode,storeInstrument:null!==(t=null==i?void 0:i.storeInstrument)&&void 0!==t&&t}})}isFormValid(){return Object.values(this.formFields).filter(e=>e.isVisible).every(e=>e.isValid)}isFormValidSilent(){return Object.values(this.formFields).filter(e=>e.isVisible).every(e=>e.validate(!0))}checkAndTriggerValidationChange(){var e,t;const i=this.isFormValidSilent();this._previousFormValidState!==i&&(this._previousFormValidState=i,null===(t=null===(e=this.options.events)||void 0===e?void 0:e.onValidationChange)||void 0===t||t.call(e,i))}mount(e){const i=Object.create(null,{mount:{get:()=>super.mount}});return t(this,void 0,void 0,function*(){var t,n;yield this.makeForm(),i.mount.call(this,e),null===(n=null===(t=this.options.events)||void 0===t?void 0:t.onReady)||void 0===n||n.call(t)})}makeForm(){return t(this,void 0,void 0,function*(){var e;if(!(null===(e=this.formConfig)||void 0===e?void 0:e.schema))return;this.__schema=yield ds(this.formConfig.schema);const t=function(e,t){const i={};if(!function(e){return e&&"object"==typeof e}(e))return i;const n=(e,s)=>{var o;if(e.properties)for(const[r,a]of Object.entries(e.properties)){const l=s?`${s}.${r}`:r,d=a;"object"===d.type&&d.properties?n(d,l):i[l]=_s(l,d,(null===(o=e.required)||void 0===o?void 0:o.includes(r))||!1,t)}};return n(e,""),i}(this.__schema,this.options.translations),i=Object.values(t).sort((e,t)=>{var i,n;return(null!==(i=e.property[ls])&&void 0!==i?i:0)-(null!==(n=t.property[ls])&&void 0!==n?n:0)});for(const e of i)this.createField(e);this.evaluateDependencies()})}createField(e){const t=this.createFieldSync(e);t&&(this.formFields.set(e.name,t),this.subElements.push(t))}createFieldSync(e){return t=e.property,Boolean(t.oneOf&&t.oneOf.length>0)?this.createOneOfField(e):function(e){return"string"===e.type&&!e.oneOf}(e.property)?this.createStringField(e):null;var t}createOneOfField(e){const t="bankAccount.holder.type"===e.name?"tabs":"select";return this.createFieldByType(e,t)}createStringField(e){return this.createFieldByType(e,"input")}createFieldByType(e,t){const i=this.extractStyles(e.name,t),n=this.makeFieldEvents(e.name);switch(t){case"tabs":return new as(Object.assign(Object.assign({},e),{events:n,styles:i,options:hs(e.property)}));case"select":return new rs(Object.assign(Object.assign({},e),{events:n,styles:i,options:hs(e.property)}));case"input":return new os(Object.assign(Object.assign({},e),{events:n,styles:i}));default:throw new Error(`Unsupported component type: ${t}`)}}extractStyles(e,t){var i,n,s,o,r,a,l,d,c,u,p,_,h,E;const m=Ki({},null!==(s=null===(n=null===(i=this.options.styles)||void 0===i?void 0:i.all)||void 0===n?void 0:n[t])&&void 0!==s?s:{},null!==(l=null===(a=null===(r=null===(o=this.options.styles)||void 0===o?void 0:o.fields)||void 0===r?void 0:r[e])||void 0===a?void 0:a[t])&&void 0!==l?l:{}),v=Ki({},null!==(u=null===(c=null===(d=this.options.styles)||void 0===d?void 0:d.all)||void 0===c?void 0:c.errors)&&void 0!==u?u:{},null!==(E=null===(h=null===(_=null===(p=this.options.styles)||void 0===p?void 0:p.fields)||void 0===_?void 0:_[e])||void 0===h?void 0:h.errors)&&void 0!==E?E:{});return{[t]:m,errors:v}}makeFieldEvents(e){return{onChange:(t=>{this.formData=Pt(this.formData,e,t),this.evaluateDependencies()}).bind(this),onReady:(t=>{this.formData=Pt(this.formData,e,t)}).bind(this),onBlur:(()=>{this.checkAndTriggerValidationChange()}).bind(this)}}evaluateDependencies(){if(!this.__schema)return;const e=function(e,t){const i={};if(!e.dependentSchemas)return i;for(const[n,s]of Object.entries(e.dependentSchemas)){const e=St(t,n);if(s.oneOf){const t=ps(s,n,e);Object.assign(i,t)}}return i}(this.__schema,this.formData);for(const[t,i]of Object.entries(e)){const e=this.formFields.get(t);e&&(e.setVisible(i.isVisible),e.setRequired(i.isRequired))}}}const ms=e=>t(void 0,void 0,void 0,function*(){if(null==e?void 0:e.onSessionExpired)try{const t=yield e.onSessionExpired();if(t)bi(t),(null==e?void 0:e.onClientInitialized)&&e.onClientInitialized(Ni);else{const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_SESSION_REFRESH_FAILED,{description:"Session refresh failed with no result returned"});o.PayrailsLogger.error(e.message,{error:e})}}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_SESSION_REFRESH_FAILED,{description:"Callback passed to onSessionExpired threw an error",cause:e});o.PayrailsLogger.error(t.message,{error:t})}}),vs={visa:J.VISA.regex,mastercard:J.MASTERCARD.regex,amex:J.AMEX.regex,diners_club:J.DINERS_CLUB.regex,discover:J.DISCOVER.regex,jcb:J.JCB.regex,hipercard:J.HIPERCARD.regex,unionpay:J.UNIONPAY.regex,maestro:J.MAESTRO.regex,elo:J.ELO.regex};class ys{constructor(e,i){var n;this.bin="",this.isBinLookupEnabled=!1,this.id="payrails-container-wrapper",this.dataTestId="payrails-container-wrapper",this.className="payrails-container-wrapper",this.containerType="COMPOSABLE",this.manualErrorElements=new Set,this.fetchBinLookup=e=>t(this,void 0,void 0,function*(){var t,i;if(!e)return{bin:""};if(e.length<6)return{bin:e};const n=`${null===(i=null===(t=Pi().links)||void 0===t?void 0:t.binLookup)||void 0===i?void 0:i.href}`;if(!n)return{bin:e};const r=Pi().token,a={bin:e};try{const e=yield(({url:e,token:t,body:i})=>h({url:e,method:_.POST,token:t,body:i}))({url:n,token:r,body:a});return e.res}catch(t){const i=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_BIN_LOOKUP_FAILED,{description:"Error fetching BIN lookup data!",cause:t});return o.PayrailsLogger.error(i.message,{error:i}),{bin:e}}}),this.cardTableName=i.cardTableName||"cards",this.containerType=i.containerType||"COMPOSABLE",this.isBinLookupEnabled=!!(null===(n=Pi().links)||void 0===n?void 0:n.binLookup);try{this.__container=e.container(this.containerType,i)}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CREATION_FAILED,{cause:e});o.PayrailsLogger.error(t.message,{error:t})}}static init(e,t){var i;return this.instance&&(null===(i=this.instance.__container)||void 0===i||i.unmount()),this.instance=new ys(e,t),this.instance}createCollectElement(e){var t;const i={required:!!e.required,enableCardIcon:!1!==e.enableCardIcon},n=null===(t=this.__container)||void 0===t?void 0:t.create(Object.assign(Object.assign({table:this.cardTableName,labelStyles:{},errorTextStyles:{},column:this.elementToFieldMap.get(e.type)},e),{type:e.type===exports.ElementType.CARDHOLDER_NAME?"INPUT_FIELD":e.type}),e.format?Object.assign(Object.assign({},i),{format:e.format}):i);if(!n){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING,{description:"Error creating collect element!"});throw o.PayrailsLogger.error(e.message,{error:e}),e}return this.attachCustomEventHandler(n)}mount(e){if("COLLECT"===this.containerType){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw o.PayrailsLogger.error(e.message,{error:e}),e}this.element=document.createElement("span"),this.element.setAttribute("id",`${this.id}`),this.element.setAttribute("data-testid",this.dataTestId),this.element.setAttribute("class",this.className);const t=document.querySelector(e);if(!t){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING);throw o.PayrailsLogger.error(t.message,{error:t,extra:{elementSelector:e}}),t}t.appendChild(this.element);try{window.setTimeout(()=>{this.__container.mount(`#${this.id}`)},50)}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);o.PayrailsLogger.error(t.message,{error:t})}}unmount(){this.element&&this.element.remove()}validate(){return t(this,void 0,void 0,function*(){var e;return yield null===(e=this.__container)||void 0===e?void 0:e.validate()})}collect(){return t(this,void 0,void 0,function*(){try{return yield this.collectPayrailsData()}catch(e){const t=new Error(e.message);t.stack=e.stack,t.name=e.name,t.message=e.message;const i=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_OPERATION_FAILED,{description:"Error collecting data from the iframe!",cause:t});throw t.name!==s.ERROR_CODES.PAYRAILS_CARD_FORM_COMPLETE_AND_VALID_INPUTS&&o.PayrailsLogger.error(i.message,{error:i}),i}})}reset(){var e;null===(e=this.__container)||void 0===e||e.reset()}collectPayrailsData(){return t(this,void 0,void 0,function*(){var e;const t=yield null===(e=this.__container)||void 0===e?void 0:e.collect();return Object.assign(Object.assign({},t),{vaultProviderConfigId:Pi().vaultConfiguration.providerConfigId})})}tokenize(e){return t(this,void 0,void 0,function*(){const t=yield this.collect(),i=Pi().vaultConfiguration.links.saveInstrument.href,n=Pi().token;if(!i){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND,{description:"Save instrument URL not available!"});throw o.PayrailsLogger.error(e.message,{error:e}),e}return(yield Ai({url:i,token:n,body:this.constructSaveInstrumentBody(t,e)})).res})}constructSaveInstrumentBody(e,t){var i,n;const s={holderReference:Pi().holderReference,paymentMethod:"card",storeInstrument:null!==(i=null==t?void 0:t.storeInstrument)&&void 0!==i&&i,futureUsage:null!==(n=null==t?void 0:t.futureUsage)&&void 0!==n?n:"CardOnFile"};return s.data={encryptedData:e.encryptedData,vaultProviderConfigId:e.vaultProviderConfigId},s}attachCustomEventHandler(e){return new Proxy(e,{get:(e,t)=>{const i=e[t];if("on"===t){return((i,n)=>{e[t].call(e,i,t=>{"CHANGE"===i?(this.manualErrorElements.has(e)&&!t.isEmpty&&("resetError"in e&&"function"==typeof e.resetError&&e.resetError(),this.manualErrorElements.delete(e)),t.elementType===exports.ElementType.CARD_NUMBER&&(t.network=function(e){for(const[t,i]of Object.entries(vs))if(i.test(e))return t;return""}(t.value),t.bin=this.formatBin(t.value),this.bin=this.formatBin(t.value)),n(t)):n(t)})}).bind(e)}return"setError"===t?(...t)=>(this.manualErrorElements.add(e),i.apply(e,t)):"function"==typeof i?i.bind(e):i}})}formatBin(e){return e.replace(/[-X]/g,"").slice(0,8)}get elementToFieldMap(){return new Map([[exports.ElementType.CARD_NUMBER,"card_number"],[exports.ElementType.CARDHOLDER_NAME,"cardholder_name"],[exports.ElementType.CVV,"security_code"],[exports.ElementType.EXPIRATION_MONTH,"expiry_month"],[exports.ElementType.EXPIRATION_YEAR,"expiry_year"],[exports.ElementType.EXPIRATION_DATE,"expiry_date"]])}}const Is=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;class fs{static setSelectedInstrument(e){if(!e||!e.id.match(Is))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Instrument is not valid"});this._selectedInstrument=e}static getSelectedInstrument(){return this._selectedInstrument}static clearSelectedInstrument(){this._selectedInstrument=null}}fs._selectedInstrument=null;const As={deleteInstrument:{linkKey:"instrumentDelete",method:_.DELETE,createRequest:e=>{var t,i;if(!e.resourceId)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_UNKNOWN_ERROR);const n=null===(i=null===(t=Pi().links)||void 0===t?void 0:t.instrumentDelete)||void 0===i?void 0:i.href;if(!n)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND);return{url:e.resourceId?null==n?void 0:n.replace(":instrumentId",e.resourceId):n}},requestType:void 0,responseType:{}},updateInstrument:{linkKey:"instrumentUpdate",method:_.PATCH,createRequest:e=>{var t,i;const n=null===(i=null===(t=Pi().links)||void 0===t?void 0:t.instrumentUpdate)||void 0===i?void 0:i.href;if(!n)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND);return{url:e.resourceId?null==n?void 0:n.replace(":instrumentId",e.resourceId):n,body:e.body}},requestType:{},responseType:{}},payout:{linkKey:"payout",method:_.POST,createRequest:()=>{const e=Ni.payoutLink;if(!e)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND);const t=fs.getSelectedInstrument();if(!t)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_API_PAYOUT_NO_INSTRUMENT_SELECTED,{cause:new Error("No selected instrument for payout, set an instrument first using setState")});const i=[{integrationType:"api",amount:Pi().amount,paymentMethodCode:t.paymentMethod,paymentInstrumentId:t.id}];return{url:e,body:{amount:Pi().amount,payoutComposition:i}}},onSuccess:e=>t(void 0,void 0,void 0,function*(){const t=new Yi;return yield t.pollForAuthorizationResult(e.links.execution)}),requestType:{},responseType:{}}},Ls={holderReference:{path:["holderReference"],returnType:""},amount:{path:["amount"],returnType:{}},binLookup:{path:["links","binLookup"],returnType:{}},instrumentUpdate:{path:["links","instrumentUpdate"],returnType:{}},instrumentDelete:{path:["links","instrumentDelete"],returnType:{}},executionId:{path:["execution","id"],returnType:void 0},paymentMethodConfig:{path:[],returnType:{}},paymentMethodInstruments:{path:[],returnType:{}}};const Os=(e,t)=>{try{const i=Pi(),n=Ls[e];if(!n)return o.PayrailsLogger.warn(`No query definition found for key: ${e}`),null;if("paymentMethodConfig"===e){const e=null==t?void 0:t.paymentMethodCode;return e?function(e){try{return e?Ni.availablePaymentMethods.find(({paymentMethodCode:t})=>t===e)||null:(o.PayrailsLogger.error("Payment method code is required"),null)}catch(t){return o.PayrailsLogger.error(`Error getting config for payment method: ${e}`,{error:t}),null}}(e):(o.PayrailsLogger.warn("Payment method code is required for paymentMethodConfig query"),null)}if("paymentMethodInstruments"===e){const e=null==t?void 0:t.paymentMethodCode;return e?function(e){return Ni.getStoredInstrumentForPaymentMethod(e)}(e):(o.PayrailsLogger.warn("Payment method code is required for paymentMethodInstruments query"),null)}const{path:s}=n;return function(e,t){if(!e||!t||!t.length)return;let i=e;for(const e of t){if(null==i)return;i=i[e]}return i}(i,s)||null}catch(e){return o.PayrailsLogger.error("Error querying SDK Configuration",{error:e}),null}},gs=(e={})=>{const t=document.getElementById("sdk-observer");return t||(e=>{const t=document.createElement("iframe");t.id="sdk-observer";const i=new URLSearchParams(e).toString();return t.src=`https://assets.payrails.io/a676210/observability/index.html?${i}`,t.width="1px",t.height="1px",document.body.appendChild(t),t})(e)};
|
|
20
|
+
*/function Fi(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseURL&&(t=e.sdkBaseURL,delete e.sdkBaseURL),function(e){var t=e["merchant-id"],i=e["data-merchant-id"],n="",s="";Array.isArray(t)?t.length>1?(n="*",s=t.toString()):n=t.toString():"string"==typeof t&&t.length>0?n=t:"string"==typeof i&&i.length>0&&(n="*",s=i);e["merchant-id"]=n,e["data-merchant-id"]=s}(e);var i=Object.keys(e).filter(function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]}).reduce(function(t,i){var n=e[i].toString();return"data-"===i.substring(0,5)?t.dataAttributes[i]=n:t.queryParams[i]=n,t},{queryParams:{},dataAttributes:{}}),n=i.queryParams,s=i.dataAttributes;return{url:"".concat(t,"?").concat(ji(n)),dataAttributes:s}}function ji(e){var t="";return Object.keys(e).forEach(function(i){0!==t.length&&(t+="&"),t+=i+"="+e[i]}),t}function Bi(e,t){void 0===t&&(t={});var i=document.createElement("script");return i.src=e,Object.keys(t).forEach(function(e){i.setAttribute(e,t[e]),"data-csp-nonce"===e&&i.setAttribute("nonce",t["data-csp-nonce"])}),i}function Vi(e,t){if(void 0===t&&(t=Gi()),zi(e,t),"undefined"==typeof window)return t.resolve(null);var i=Fi(e),n=i.url,s=i.dataAttributes,o=s["data-namespace"]||"paypal",r=Xi(o);return function(e,t){var i=document.querySelector('script[src="'.concat(e,'"]'));if(null===i)return null;var n=Bi(e,t),s=i.cloneNode();if(delete s.dataset.uidAuto,Object.keys(s.dataset).length!==Object.keys(n.dataset).length)return null;var o=!0;return Object.keys(s.dataset).forEach(function(e){s.dataset[e]!==n.dataset[e]&&(o=!1)}),o?i:null}(n,s)&&r?t.resolve(r):function(e,t){void 0===t&&(t=Gi());zi(e,t);var i=e.url,n=e.attributes;if("string"!=typeof i||0===i.length)throw new Error("Invalid url.");if(void 0!==n&&"object"!=typeof n)throw new Error("Expected attributes to be an object.");return new t(function(e,t){if("undefined"==typeof window)return e();!function(e){var t=e.url,i=e.attributes,n=e.onSuccess,s=e.onError,o=Bi(t,i);o.onerror=s,o.onload=n,document.head.insertBefore(o,document.head.firstElementChild)}({url:i,attributes:n,onSuccess:function(){return e()},onError:function(){var e=new Error('The script "'.concat(i,'" failed to load.'));return window.fetch?fetch(i).then(function(i){return 200===i.status&&t(e),i.text()}).then(function(e){var i=function(e){var t=e.split("/* Original Error:")[1];return t?t.replace(/\n/g,"").replace("*/","").trim():e}(e);t(new Error(i))}).catch(function(e){t(e)}):t(e)}})})}({url:n,attributes:s},t).then(function(){var e=Xi(o);if(e)return e;throw new Error("The window.".concat(o," global variable is not available."))})}function Gi(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function Xi(e){return window[e]}function zi(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}class Hi{static load(e,i){const n=e.toString(),s=Hi.scriptMap.get(n);if(s)return s;const o=(()=>t(this,void 0,void 0,function*(){try{if(e===qi.PayPal){if(!i)throw new Error("PayPal config is required");return yield Hi.loadPayPalScript(i)}return yield Hi.loadScript(e)}finally{Hi.scriptMap.delete(n)}}))();return Hi.scriptMap.set(n,o),o}static reset(){Hi.scriptMap.clear()}static preloadCardForm(){const e="https://assets.payrails.io/e38a94f/card";[[`${e}/index.js`,"payrails-iframe-js-v2"],[`${e}/index.html`,"payrails-iframe-html-v2"]].forEach(([e,t])=>{if(!document.getElementById(t)){const i=document.createElement("link");i.id=t,i.rel="preload",i.as="script",i.href=e,document.head.appendChild(i)}})}static loadScript(e){const t=`payrails-script-${JSON.stringify(e)}`;if(Hi.scriptMap.has(t))return Hi.scriptMap.get(t);const i=document.createElement("script");i.src=e,i.id=t;const n=new Promise((t,n)=>{i.onload=()=>t(),i.onerror=t=>n(Hi.logLoadError(e,new Error(t.toString())))});return Hi.scriptMap.set(t,n),document.body.appendChild(i),n}static loadPayPalScript(e){return t(this,arguments,void 0,function*({clientId:e,currency:t,vault:i,intent:n}){try{const s=yield Vi({"client-id":e,components:"buttons,funding-eligibility",intent:n,currency:t,vault:i,"data-namespace":"payrailsPaypal"});if(s)return s}catch(e){throw Hi.logLoadError(qi.PayPal,e)}throw Hi.logLoadError(qi.PayPal)})}constructor(){}static logLoadError(e,t){const i=new Map([[qi.ApplePay,s.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR],[qi.GooglePay,s.ERROR_CODES.PAYRAILS_CLIENT_GPAY_LOADING_ERROR],[qi.PayPal,s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR]]),n=new s.PayrailsError(i.get(e)||s.ERROR_CODES.PAYRAILS_CLIENT_UNKNOWN_ERROR,{cause:t,description:null==t?void 0:t.message});return o.PayrailsLogger.error(n.message,{error:n}),n}}var qi;Hi.scriptMap=new Map,function(e){e.ApplePay="https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js",e.GooglePay="https://pay.google.com/gp/p/js/pay.js",e.PayPal="paypal-sdk"}(qi||(qi={}));class Wi{constructor(e,{id:t="",className:i="",dataTestId:n=""}={}){this.subElements=[],this.eventBus=L.getEventBus();const s=document.createElement(e);t&&(this.id=t,s.setAttribute("id",t)),n&&(this.dataTestId=n,s.setAttribute("data-testid",n)),i&&(Array.isArray(i)?s.setAttribute("class",function(...e){return e.filter(Boolean).join(" ")}(...i)):s.setAttribute("class",i)),this.element=s}get parentElement(){return this.element.parentElement}get selector(){if(!this.id)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);return`#${this.id}`}mount(e){const t=document.querySelector(e);if(!t)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING,{description:`Element with selector "${e}" not found in in the DOM`});this.clean(),t.appendChild(this.element),this.subElements.forEach(e=>{if(!this.id)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_SUBELEMENTS_RENDER_ERROR);e.mount(this.selector)})}clean(){var e;null===(e=document.getElementById(this.element.id))||void 0===e||e.remove()}unmount(){var e;this.subElements.forEach(e=>e.unmount()),null===(e=this.parentElement)||void 0===e||e.removeChild(this.element)}}class Ki extends Wi{constructor(e){super("span",{id:e.id,className:"payrails-store-instrument",dataTestId:e.dataTestId}),this.options=e,this.createHTML(),this.applyStyles(),this.addListeners()}get isChecked(){var e;return!!(null===(e=this.element.querySelector("input"))||void 0===e?void 0:e.checked)}createHTML(){var e,t,i,n,s,o,r,a,l,d;const c=(null===(i=null===(t=null===(e=this.options)||void 0===e?void 0:e.translations)||void 0===t?void 0:t.labels)||void 0===i?void 0:i.saveInstrument)||(null===(o=null===(s=null===(n=this.options)||void 0===n?void 0:n.translations)||void 0===s?void 0:s.labels)||void 0===o?void 0:o.storeInstrument)||"Save instrument for future payments",u=`${this.id}-checkbox`,p=`${this.dataTestId}-checkbox`;(null===(l=null===(a=null===(r=this.options)||void 0===r?void 0:r.translations)||void 0===a?void 0:a.labels)||void 0===l?void 0:l.saveInstrument)&&console.warn("The saveInstrument label is deprecated, please use storeInstrument instead");const _="checked"==(null===(d=this.options)||void 0===d?void 0:d.defaultStoreInstrumentState);this.element.innerHTML=`<label for="${u}"><input type="checkbox" id="${u}" name="${u}" data-testid="${p}" class="payrails-store-instrument-checkbox">${c}</label>`,_&&(this.element.querySelector("input").checked=!0)}applyStyles(){var e,t;Object.keys((null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.storeInstrumentCheckbox)||{}).forEach(e=>{var t,i,n;this.element.style[e]=null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.storeInstrumentCheckbox)||void 0===n?void 0:n[e]})}addListeners(){this.element.addEventListener("change",e=>{var t,i,n,s;(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onSaveInstrumentCheckboxChanged)&&(null===(s=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===s||s.onSaveInstrumentCheckboxChanged({checked:this.isChecked})),e.stopPropagation(),e.stopImmediatePropagation()}),this.element.addEventListener("click",e=>{e.stopPropagation(),e.stopImmediatePropagation()})}}class $i extends Wi{constructor(e,i){var n,s,o,r,a;super(e,i),this.options=i,this.storeInstrumentCheckbox=null,(null===(n=this.options)||void 0===n?void 0:n.showStoreInstrumentCheckbox)&&(this.storeInstrumentCheckbox=new Ki(Object.assign(Object.assign({},i),{id:`${null===(s=this.options)||void 0===s?void 0:s.id}-store-instrument-checkbox`,dataTestId:(null===(o=this.options)||void 0===o?void 0:o.dataTestId)?`${null===(r=this.options)||void 0===r?void 0:r.dataTestId}-store-instrument-checkbox`:`${null===(a=this.options)||void 0===a?void 0:a.id}-store-instrument-checkbox`,events:{onSaveInstrumentCheckboxChanged:e=>t(this,void 0,void 0,function*(){var t,n;null===(n=null===(t=null==i?void 0:i.events)||void 0===t?void 0:t.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(t,e)})}})),this.subElements.push(this.storeInstrumentCheckbox))}get shouldStoreInstrument(){var e,t;return(null===(e=this.storeInstrumentCheckbox)||void 0===e?void 0:e.isChecked)||(null===(t=this.options)||void 0===t?void 0:t.alwaysStoreInstrument)||!1}}class Zi extends $i{static isApplePayAvailable(){return t(this,void 0,void 0,function*(){try{return yield Hi.load(qi.ApplePay),ApplePaySession.canMakePayments()}catch(e){return!1}})}constructor(e){super("div",Object.assign(Object.assign({},e),{id:`payrails-apple-pay-button-${p()}`,dataTestId:"payrails-apple-pay-button"})),this.options=e,this.appleButton=null,this.isProcessing=!1,this.completedSessions=new WeakSet,this.abortedSessionReasons=new WeakMap,this.paymentExecutor=new xi,Zi.isApplePayAvailable().then(e=>{var t,i,n;e&&(null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onApplePayAvailable)||void 0===n||n.call(i))}),this.action="tokenization"===Di().type?Ns.TOKENIZE:Ns.AUTHORIZE}mount(e){this.unmount(),super.mount(e),(()=>{t(this,void 0,void 0,function*(){try{(yield Zi.isApplePayAvailable())&&(yield this.mountApplePayButton())}catch(e){}})})()}unmount(){var e,t;null===(t=null===(e=this.appleButton)||void 0===e?void 0:e.parentElement)||void 0===t||t.removeChild(this.appleButton),super.unmount()}mountApplePayButton(){return t(this,void 0,void 0,function*(){var e,i,n;try{const s=(null===(e=this.options.styles)||void 0===e?void 0:e.type)||"buy",o=(null===(i=this.options.styles)||void 0===i?void 0:i.style)||"black";this.element.innerHTML=`<apple-pay-button buttonstyle="${o}" type="${s}" locale="en-GB"></apple-pay-button>`,null===(n=this.storeInstrumentCheckbox)||void 0===n||n.mount(this.selector);const r=this.element.querySelector("apple-pay-button");null==r||r.setAttribute("style","width: 100%;"),null==r||r.addEventListener("click",()=>t(this,void 0,void 0,function*(){this.isProcessing||(this.isProcessing=!0,yield this.createApplePaySession())}))}catch(e){}})}onAuthorizeFailedHandler(e,t){this.isProcessing=!1,this.options.abortAfterAuthorizeFailed?(this.abortedSessionReasons.set(e,t),this.completeApplePaySession(e,"abort")):(this.completeApplePaySession(e,"failure"),bs(Ns.AUTHORIZE,this.options.events,t instanceof s.PayrailsError?t:void 0))}completeApplePaySession(e,t){if(!this.completedSessions.has(e)){this.completedSessions.add(e);try{if("abort"===t)return void e.abort();e.completePayment("success"===t?ApplePaySession.STATUS_SUCCESS:ApplePaySession.STATUS_FAILURE)}catch(e){o.PayrailsLogger.warn(`ApplePaySession completion failed (${t})`,{error:e instanceof s.PayrailsError?e:void 0})}}}createApplePaySession(){return t(this,void 0,void 0,function*(){var e,i;const n=Pi.applePayConfig,{countryCode:r,supportedNetworks:a,merchantCapabilities:l,requiredBillingContactFields:d=[],requiredShippingContactFields:c=[]}=n,{amount:u}=Di();try{const n=new ApplePaySession(3,{countryCode:r,currencyCode:u.currency,merchantCapabilities:l,supportedNetworks:a,total:{label:(null===(i=null===(e=this.options.translations)||void 0===e?void 0:e.labels)||void 0===i?void 0:i.paymentScreenLabel)||"",type:"final",amount:u.value},requiredBillingContactFields:d,requiredShippingContactFields:c});n.onvalidatemerchant=e=>t(this,void 0,void 0,function*(){try{const{res:t}=yield this.paymentExecutor.createApplePaySession({requestUrl:Pi.createSessionLink,sessionUrl:e.validationURL,clientDomain:this.options.clientDomain}),i=t.data.data;n.completeMerchantValidation(i)}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_START_PAYMENT_SESSION_ERROR);o.PayrailsLogger.error(t.message,{error:t}),n.abort()}}),n.oncancel=()=>{this.isProcessing=!1;const e=this.abortedSessionReasons.get(n);this.abortedSessionReasons.delete(n),bs(this.action,this.options.events,e)},n.onpaymentauthorized=e=>t(this,void 0,void 0,function*(){yield this.onApplePayAuthorized(e.payment,n)});return(yield ws(this.action,this.options.events))?n.begin():this.isProcessing=!1,n}catch(e){return this.isProcessing=!1,null}})}onApplePayAuthorized(e,i){return t(this,void 0,void 0,function*(){return(yield gi(this.action,this.options.events))?this.action===Ns.TOKENIZE?yield this.doTokenize(e,i):yield this.doAuthorizedPayment(e,i):(this.action===Ns.AUTHORIZE?this.onAuthorizeFailedHandler(i,{code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:"Authorization request start validation failed"}):(this.isProcessing=!1,this.completeApplePaySession(i,"failure"),bs(this.action,this.options.events,{code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:"Request start validation failed"})),null)})}doAuthorizedPayment(e,i){return t(this,void 0,void 0,function*(){var t,n,s,o,r;const a=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.APPLE_PAY,integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(e)},amount:Di().amount,storeInstrument:this.shouldStoreInstrument}];try{const e=yield this.paymentExecutor.pay(a);if("authorizeSuccessful"===(null===(t=e.finalState)||void 0===t?void 0:t.code))this.completeApplePaySession(i,"success"),this.isProcessing=!1,Ps(Ns.AUTHORIZE,this.options.events,e);else this.onAuthorizeFailedHandler(i,{code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:(null===(r=null===(o=null===(s=null===(n=e.finalState)||void 0===n?void 0:n.errors)||void 0===s?void 0:s[0])||void 0===o?void 0:o.reason)||void 0===r?void 0:r.result)||"Authorization Failed"});return e}catch(e){this.onAuthorizeFailedHandler(i,e)}})}doTokenize(e,i){return t(this,void 0,void 0,function*(){const t=Di(),n=Pi.createInstrumentLink,s=t.token;if(!n)return this.completeApplePaySession(i,"failure"),this.isProcessing=!1,void bs(Ns.TOKENIZE,this.options.events);let o;try{o=JSON.stringify(e)}catch(e){return this.completeApplePaySession(i,"failure"),this.isProcessing=!1,void bs(Ns.TOKENIZE,this.options.events,e)}const r={holderReference:t.holderReference,paymentMethod:exports.PAYMENT_METHOD_CODES.APPLE_PAY,data:{paymentToken:o}};try{const e=yield Oi({url:n,token:s,body:r});return e.ok?(this.completeApplePaySession(i,"success"),this.isProcessing=!1,Ps(Ns.TOKENIZE,this.options.events,e.res),e.res):(this.completeApplePaySession(i,"failure"),this.isProcessing=!1,void bs(Ns.TOKENIZE,this.options.events))}catch(e){return this.completeApplePaySession(i,"failure"),this.isProcessing=!1,void bs(Ns.TOKENIZE,this.options.events,e)}})}}function Ji(...e){function t(e,i){if("object"!=typeof e||null===e)return i;if("object"!=typeof i||null===i)return i;if(Array.isArray(i)||Array.isArray(e))return i;const n=Object.assign({},e);for(const s of Object.keys(i))i[s]&&"object"==typeof i[s]&&!Array.isArray(i[s])&&e[s]&&"object"==typeof e[s]&&!Array.isArray(e[s])?n[s]=t(e[s],i[s]):n[s]=i[s];return n}return e.reduce((e,i)=>t(e,i),{})}const Qi={wrapper:{display:"flex",flexDirection:"column"}};var en;!function(e){e.GET="GET"}(en||(en={}));const tn=e=>t(void 0,[e],void 0,function*({url:e}){const t={method:en.GET},i=yield fetch(e,t),n=yield i.json();if(429===i.status)throw new sn(e,en.GET);if(!i.ok)throw new nn(e,en.GET);return{ok:i.ok,req:Object.assign({url:e},t),res:n}});class nn extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{description:`[${t}] ${e} unsuccessful`})}}class sn extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} too many requests`})}}const on=()=>t(void 0,void 0,void 0,function*(){const e=yield(({url:e})=>tn({url:e}))({url:"https://assets.payrails.io/json/countries.json"});return new Map(Object.entries(e.res))});class rn extends Wi{constructor(e,t){super(e,{id:t.id,className:t.className}),this.applyStyles(t.styles)}applyStyles(e){Object.keys(e||{}).forEach(t=>{this.element.style[t]=null==e?void 0:e[t]})}}const an="__payrails-selectedCountry";class ln extends rn{constructor(e){var t,i;super("span",Object.assign(Object.assign({},e),{id:"payrails-country-select",className:"payrails-country-selector-wrapper",styles:null===(t=e.styles)||void 0===t?void 0:t.wrapper})),this.options=e,this._countriesList=null===(i=e.config)||void 0===i?void 0:i.data,this.createHTML(),this.attachEvents()}set countriesList(e){this._countriesList=e,this.populateCountrySelect(),this.setDefaultCountry()}get countriesList(){return this._countriesList}populateCountrySelect(){return t(this,void 0,void 0,function*(){var e,t;const i=document.createElement("option");i.value="",i.textContent=(null===(e=this.options.translations)||void 0===e?void 0:e.placeholder)||"Select Country",null===(t=this.selectElement)||void 0===t||t.appendChild(i),this._countriesList.forEach(e=>{var t;const i=document.createElement("option");i.value=e.code,i.textContent=e.name,null===(t=this.selectElement)||void 0===t||t.appendChild(i)})})}setDefaultCountry(){const e=JSON.parse(sessionStorage.getItem(an)||"{}");if(null==e?void 0:e.code)return void(this.value=e.code);const t=Intl.DateTimeFormat().resolvedOptions().timeZone;t&&this.countriesList.forEach(e=>{var i;if(null===(i=e.timezones)||void 0===i?void 0:i.includes(t))return this.value=e.code,void sessionStorage.setItem(an,JSON.stringify(this.value))})}createHTML(){this.createLabel(),this.createSelectBox()}createSelectBox(){var e;this.selectElement=document.createElement("select"),this.selectElement.id=this.options.id,this.selectElement.className="payrails-country-select-element",this._countriesList&&this.populateCountrySelect(),this.applyStylesToSubElements(null===(e=this.options.styles)||void 0===e?void 0:e.element,this.selectElement),this.element.appendChild(this.selectElement)}createLabel(){var e,t,i;this.label=document.createElement("label"),this.label.textContent=(null===(e=this.options.translations)||void 0===e?void 0:e.label)||"Country",this.applyStylesToSubElements(null===(t=this.options.styles)||void 0===t?void 0:t.label,this.label),(null===(i=this.options.translations)||void 0===i?void 0:i.label)&&this.element.appendChild(this.label)}applyStylesToSubElements(e,t){Object.keys(e||{}).forEach(i=>{t.style[i]=null==e?void 0:e[i]})}attachEvents(){var e;null===(e=this.selectElement)||void 0===e||e.addEventListener("change",e=>{var t,i;null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onChange)||void 0===i||i.call(t,{country:this.value}),sessionStorage.setItem(an,JSON.stringify(this.value)),e.stopPropagation(),e.stopImmediatePropagation()})}get isValid(){var e;return""!==(null===(e=this.selectElement)||void 0===e?void 0:e.value)}get value(){var e,t,i,n,s,o;return{code:null===(e=this.selectElement)||void 0===e?void 0:e.value,fullName:(null===(i=null===(t=this.selectElement)||void 0===t?void 0:t.options[this.selectElement.selectedIndex])||void 0===i?void 0:i.textContent)||"",iso3:(null===(o=null===(n=this._countriesList)||void 0===n?void 0:n.get(null===(s=this.selectElement)||void 0===s?void 0:s.value))||void 0===o?void 0:o.iso3)||""}}set value(e){this.selectElement&&(this.selectElement.value=e)}}class dn extends rn{set selectedCountry(e){this._selectedCountry=e}get selectedCountry(){return this._selectedCountry}constructor(e){var t;super("span",Object.assign(Object.assign({},e),{id:"payrails-postal-code-wrapper",className:"payrails-postal-code-wrapper",styles:null===(t=e.styles)||void 0===t?void 0:t.wrapper})),this.options=e,this._selectedCountry="",this._countriesList=void 0,this._countriesList=e.config.data,this.createHTML(),this.attachEvents()}createHTML(){this.createLabel(),this.createInput()}createInput(){var e,t;this.inputElement=document.createElement("input"),this.inputElement.type="text",this.inputElement.placeholder=(null===(e=this.options.translations)||void 0===e?void 0:e.placeholder)||"Postal Code",this.inputElement.id=this.options.id,this.inputElement.className="payrails-postal-code-input",this.applyStylesToSubElements(null===(t=this.options.styles)||void 0===t?void 0:t.element,this.inputElement),this.element.appendChild(this.inputElement)}createLabel(){var e,t,i;this.label=document.createElement("label"),this.label.textContent=(null===(e=this.options.translations)||void 0===e?void 0:e.label)||"Postal Code",this.applyStylesToSubElements(null===(t=this.options.styles)||void 0===t?void 0:t.label,this.label),(null===(i=this.options.translations)||void 0===i?void 0:i.label)&&this.element.appendChild(this.label)}applyStylesToSubElements(e,t){Object.keys(e||{}).forEach(i=>{t.style[i]=null==e?void 0:e[i]})}attachEvents(){var e,t,i;null===(e=this.inputElement)||void 0===e||e.addEventListener("change",e=>{e.stopPropagation(),e.stopImmediatePropagation()}),null===(t=this.inputElement)||void 0===t||t.addEventListener("input",e=>{var t,i,n;null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onChange)||void 0===i||i.call(t,{postalCode:this.value}),null===(n=this.inputElement)||void 0===n||n.classList.remove("error"),e.stopPropagation(),e.stopImmediatePropagation()}),null===(i=this.inputElement)||void 0===i||i.addEventListener("focusout",e=>{var t;this.isValid||null===(t=this.inputElement)||void 0===t||t.classList.add("error"),e.stopPropagation(),e.stopImmediatePropagation()})}set countriesList(e){this._countriesList=e}get value(){var e;return(null===(e=this.inputElement)||void 0===e?void 0:e.value)||""}set value(e){this.inputElement&&(this.inputElement.value=e)}show(){this.element.style.display="flex"}hide(){this.element.style.display="none"}get isValid(){var e,t,i;const n=null===(e=this.inputElement)||void 0===e?void 0:e.value,s=this.selectedCountry,o=(null===(i=null===(t=this._countriesList)||void 0===t?void 0:t.get(s))||void 0===i?void 0:i.postalCodeRegex)||"";let r=!1;if(n)return r=o?new RegExp(o).test(n):n.length>0,r}setValidation(e){this.inputElement&&(this.inputElement.pattern=e,this.inputElement.classList.remove("error"))}}class cn extends Wi{get fullAddress(){var e,t,i,n;const s={},o=null===(e=this.countrySelector)||void 0===e?void 0:e.value;return o&&(s.country=o,o.code&&(null===(i=null===(t=this.countriesMap)||void 0===t?void 0:t.get(o.code))||void 0===i?void 0:i.showPostalCode)&&(s.postalCode=null===(n=this.postalCodeInput)||void 0===n?void 0:n.value)),Object.assign({},s)}constructor(e){var t,i;super("div",{id:e.id,className:"payrails-address-selector-wrapper",styles:(null===(t=e.styles)||void 0===t?void 0:t.wrapper)||(null===(i=Qi)||void 0===i?void 0:i.wrapper)}),this.options=e,this.countriesMap=void 0,this.createAddressComponents(),this.init(),this.applyStyles(),on().then(e=>{this.countriesMap=e,this.countrySelector&&(this.countrySelector.countriesList=e),this.postalCodeInput&&(this.postalCodeInput.countriesList=e)})}applyStyles(){var e,t;Object.keys((null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.wrapper)||{}).forEach(e=>{var t,i,n;this.element.style[e]=null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.wrapper)||void 0===n?void 0:n[e]})}createAddressComponents(e){var t,i,n,s,o,r,a,l,d,c,u,p;const _={id:"country-selector",styles:(null===(t=this.options.styles)||void 0===t?void 0:t.countrySelector)||(null===(i=Qi)||void 0===i?void 0:i.countrySelector),events:{onChange:e=>{var t,i;const{country:n}=e;this.onCountryChange(n),null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onBillingAddressChanged)||void 0===i||i.call(t,{isValid:this.isValid,billingAddress:this.fullAddress})}},translations:{label:null===(s=null===(n=this.options.translations)||void 0===n?void 0:n.labels)||void 0===s?void 0:s.countrySelector,placeholder:null===(r=null===(o=this.options.translations)||void 0===o?void 0:o.placeholders)||void 0===r?void 0:r.countrySelector}},h={id:"postal-code-input",translations:{label:null===(l=null===(a=this.options.translations)||void 0===a?void 0:a.labels)||void 0===l?void 0:l.postalCodeInput,placeholder:null===(c=null===(d=this.options.translations)||void 0===d?void 0:d.placeholders)||void 0===c?void 0:c.postalCodeInput},styles:(null===(u=this.options.styles)||void 0===u?void 0:u.postalCodeInput)||(null===(p=Qi)||void 0===p?void 0:p.postalCodeInput),events:{onChange:()=>{var e,t;null===(t=null===(e=this.options.events)||void 0===e?void 0:e.onBillingAddressChanged)||void 0===t||t.call(e,{isValid:this.isValid,billingAddress:this.fullAddress})}},config:{data:e}};this.countrySelector=new ln(_),this.postalCodeInput=new dn(h)}init(){var e,t;this.countrySelector&&this.subElements.push(this.countrySelector),this.postalCodeInput&&this.subElements.push(this.postalCodeInput),null===(e=this.postalCodeInput)||void 0===e||e.hide(),(null===(t=this.options.styles)||void 0===t?void 0:t.wrapper)&&Object.assign(this.element.style,this.options.styles.wrapper)}get isValid(){var e,t,i,n;let s=this.countrySelector&&this.countrySelector.isValid;const o=null===(t=null===(e=this.countrySelector)||void 0===e?void 0:e.value)||void 0===t?void 0:t.code;return o&&(null===(n=null===(i=this.countriesMap)||void 0===i?void 0:i.get(o))||void 0===n?void 0:n.showPostalCode)&&(s=s&&this.postalCodeInput&&this.postalCodeInput.isValid),!!s}onCountryChange(e){var t;const i=null==e?void 0:e.code;if(!i)return;const n=null===(t=this.countriesMap)||void 0===t?void 0:t.get(i);if(this.postalCodeInput)if(n&&(null==n?void 0:n.showPostalCode)){const e=new RegExp(n.postalCodeRegex||"[0-9]*");this.postalCodeInput.setValidation(e.source),this.postalCodeInput.selectedCountry=i,this.postalCodeInput.show()}else this.postalCodeInput.hide(),this.postalCodeInput.setValidation(""),this.postalCodeInput.value=""}get selectedCountry(){var e;return null===(e=this.countrySelector)||void 0===e?void 0:e.value}get postalCode(){var e;return null===(e=this.postalCodeInput)||void 0===e?void 0:e.value}show(){this.element.style.display="flex"}hide(){this.element.style.display="none"}}class un extends Wi{constructor(e){var t;super("div",{id:e.id,className:e.className}),this.options=e,this.INSTALLMENT_STORAGE_KEY="__payrails-selectedInstallmentCount",this.installmentOptions=[],this.installmentOptions=(null===(t=e.installmentConfig)||void 0===t?void 0:t.installmentOptions)||[],this.createHTML(),this.applyStyles(),this.addListeners()}generateOptionsHTML(e){var t,i,n,s,o;const r=(null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.translations)||void 0===i?void 0:i.labels)||void 0===n?void 0:n.paymentInstallments)||"Split payment into monthly installments",a=parseInt(null!==(s=sessionStorage.getItem(this.INSTALLMENT_STORAGE_KEY))&&void 0!==s?s:"",10)||(null===(o=this.options.installmentConfig)||void 0===o?void 0:o.defaultInstallment);return[`<option value="">${r}</option>`,...(null==e?void 0:e.map(e=>{const t=e.count===a?" selected":"";return`<option value="${e.count}" ${t}>${e.count} x ${e.amount}</option>`}))||[]].join("")}renderOptions(e){const t=this.element.querySelector("select");t&&(t.innerHTML=this.generateOptionsHTML(e),e.length>0?this.setDisabled(!1):this.setDisabled(!0))}updateOptions(e){this.updateConfig(Object.assign(Object.assign({},this.options.installmentConfig),{installmentOptions:e}))}updateConfig(e){var t,i,n,s,o,r,a;if(!this.options)return;const l=null!==(t=this.options.installmentConfig)&&void 0!==t?t:{},d=null!=e?e:{};this.options.installmentConfig={installmentCurrency:null!==(i=d.installmentCurrency)&&void 0!==i?i:l.installmentCurrency,installmentOptions:null!==(s=null!==(n=d.installmentOptions)&&void 0!==n?n:l.installmentOptions)&&void 0!==s?s:[],defaultInstallment:null!==(o=d.defaultInstallment)&&void 0!==o?o:l.defaultInstallment},this.installmentOptions=null!==(r=this.options.installmentConfig.installmentOptions)&&void 0!==r?r:[],null===(a=this.renderOptions)||void 0===a||a.call(this,this.installmentOptions)}createHTML(){const e=`${this.id}-dropdown`;this.element.innerHTML=`<select name="${this.options.className}" id="${e}"></select>`,this.renderOptions(this.installmentOptions||[])}applyStyles(){var e,t;Object.keys((null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.paymentInstallmentsDropdown)||{}).forEach(e=>{var t,i,n;this.element.style[e]=null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.paymentInstallmentsDropdown)||void 0===n?void 0:n[e]})}addListeners(){this.element.addEventListener("change",e=>{var t;e.stopPropagation(),e.stopImmediatePropagation();const i=null===(t=this.element.querySelector("select"))||void 0===t?void 0:t.value;i?sessionStorage.setItem(this.INSTALLMENT_STORAGE_KEY,i):sessionStorage.removeItem(this.INSTALLMENT_STORAGE_KEY)}),this.element.addEventListener("click",e=>{e.stopPropagation(),e.stopImmediatePropagation()})}get selectedInstallmentValue(){var e;return null===(e=this.element.querySelector("select"))||void 0===e?void 0:e.value}setDisabled(e){const t=this.element.querySelector("select");t&&0!==this.installmentOptions.length?t&&(t.disabled=e,this.setVisible(!e)):this.setVisible(!1)}setVisible(e){const t=this.element.querySelector("select");t&&t.parentElement&&(t.parentElement.style.display=e?"block":"none")}}class pn extends Wi{constructor(e,t){var i,n;super(e,t),this.options=t,this.paymentInstallmentsDropdown=null,this.paymentInstallmentsDropdown=new un(Object.assign(Object.assign({},t),{id:`${null===(i=this.options)||void 0===i?void 0:i.id}-dropdown`,className:"payrails-payment-installments-dropdown",installmentConfig:null===(n=this.options)||void 0===n?void 0:n.installmentConfig})),this.subElements.push(this.paymentInstallmentsDropdown)}get selectedInstallmentValue(){var e;return parseInt((null===(e=this.paymentInstallmentsDropdown)||void 0===e?void 0:e.selectedInstallmentValue)||"0")}updateInstallmentOptions(e){var t;this.options&&(null===(t=this.paymentInstallmentsDropdown)||void 0===t||t.updateOptions(e))}updateInstallmentConfig(e){var t;this.options&&(this.options.installmentConfig=Object.assign(Object.assign({},this.options.installmentConfig),e),null===(t=this.paymentInstallmentsDropdown)||void 0===t||t.updateConfig(this.options.installmentConfig))}setDisabled(e){var t;null===(t=this.paymentInstallmentsDropdown)||void 0===t||t.setDisabled(e)}}const{CARD_NUMBER:_n,CVV:hn,CARDHOLDER_NAME:En,EXPIRATION_DATE:mn,EXPIRATION_MONTH:vn,EXPIRATION_YEAR:yn}=exports.ElementType,In={base:{border:"none",padding:"10px 16px",color:"#1d1d1d",backgroundColor:"#fff"},invalid:{backgroundColor:"#f9e1e1",borderColor:"#f25226",border:"1px solid"}},fn=[{type:En,placeholder:"Card holder",styles:Object.assign(Object.assign({},In),{base:Object.assign(Object.assign({},In.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px"})})},{type:_n,placeholder:"1234 1234 1234 1234",styles:Object.assign(Object.assign({},In),{base:Object.assign(Object.assign({},In.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px",textIndent:"0"}),cardIcon:{position:"absolute",right:"8px",height:"24px",bottom:"calc(50% - 12px)"}})},{type:vn,placeholder:"MM",styles:Object.assign(Object.assign({},In),{base:Object.assign(Object.assign({},In.base),{borderBottom:"1px solid #eae8ee",borderLeft:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomLeftRadius:"4px"})})},{type:yn,placeholder:"YY",format:"YY",styles:Object.assign(Object.assign({},In),{base:Object.assign(Object.assign({},In.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee"})})},{type:mn,placeholder:"MM/YY",format:"MM/YY",styles:Object.assign(Object.assign({},In),{base:Object.assign(Object.assign({},In.base),{borderBottom:"1px solid #eae8ee",borderLeft:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomLeftRadius:"4px"}),cardIcon:{position:"absolute",right:"8px",height:"24px",bottom:"calc(50% - 12px)"}})},{type:hn,placeholder:"CVC",styles:Object.assign(Object.assign({},In),{base:Object.assign(Object.assign({},In.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomRightRadius:"4px"}),cardIcon:{position:"absolute",right:"8px",height:"24px",bottom:"calc(50% - 12px)"}})}];class An extends $i{get bin(){return this.collectContainer.bin}get isBinLookupEnabled(){return this.collectContainer.isBinLookupEnabled}constructor(e,t){var i,n,s,o,r,a,l,d,c;super("div",Object.assign(Object.assign({},t),{translations:Object.assign(Object.assign({},null==t?void 0:t.translations),{labels:Object.assign(Object.assign({},null===(i=null==t?void 0:t.translations)||void 0===i?void 0:i.labels),{saveInstrument:null===(s=null===(n=null==t?void 0:t.translations)||void 0===n?void 0:n.labels)||void 0===s?void 0:s.saveCreditCard})}),styles:Object.assign({storeInstrumentCheckbox:null===(o=null==t?void 0:t.styles)||void 0===o?void 0:o.storeCardCheckbox},null==t?void 0:t.styles),id:"payrails-card-form"})),this.collectContainer=e,this.options=t,this.formFields=[],this.paymentInstallmentsDropdown=null,this.addressComponent=null,this.lastBin=null,this.lastBinLookup=null,this.defaultStyles={},this.defaultTranslations={},this.defaultStyles=(null===(r=this.options)||void 0===r?void 0:r.styles)||{},this.defaultTranslations=(null===(a=this.options)||void 0===a?void 0:a.translations)||{},this.eventsRef=null===(l=this.options)||void 0===l?void 0:l.events,this.throttledFetchBinLookup=function(e,t){let i,n;return function(...s){return new Promise((o,r)=>{n?(clearTimeout(i),i=setTimeout(()=>{Date.now()-n>=t&&(e(...s).then(o).catch(r),n=Date.now())},t-(Date.now()-n))):(e(...s).then(o).catch(r),n=Date.now())})}}(this.fetchBinLookup.bind(this),500),(null===(d=null==t?void 0:t.styles)||void 0===d?void 0:d.storeCardCheckbox)&&console.warn("The `storeCardCheckbox` option for styles is deprecated. Please use `storeInstrumentCheckbox` instead."),this.initializeFormFields(),this.subElements.push(this.collectContainer),Pi.isPaymentInstallmentsEnabled(exports.PAYMENT_METHOD_CODES.CARD)&&(this.paymentInstallmentsDropdown=new pn("span",Object.assign(Object.assign({},t),{installmentConfig:{installmentCurrency:"",installmentOptions:this.getinstallmentOptions(),defaultInstallment:null===(c=null==t?void 0:t.installmentConfig)||void 0===c?void 0:c.defaultInstallment},id:"payrails-card-form-payment-installments",className:"payrails-card-form-payment-installments-container"})),this.paymentInstallmentsDropdown&&this.subElements.push(this.paymentInstallmentsDropdown)),Pi.isAddressSelectorEnabled(exports.PAYMENT_METHOD_CODES.CARD)&&(this.addressComponent=this.createAddressSelector(),this.subElements.push(this.addressComponent)),this.storeInstrumentCheckbox&&this.subElements.push(this.storeInstrumentCheckbox)}initializeFormFields(){var e;(null===(e=this.options)||void 0===e?void 0:e.layout)&&this.options.layout.length>0?this.initializeCustomLayout():this.initializeDefaultLayout()}getErrorTextStyles(e){return(null==e?void 0:e.base)?e:{base:{}}}updateStyles(e){return this.formFields.forEach(t=>{var i,n,s,o;const r=Ji((null===(i=null==e?void 0:e.inputFields)||void 0===i?void 0:i.all)||{},(null===(n=null==e?void 0:e.inputFields)||void 0===n?void 0:n[t.type])||{}),a=this.prepareInputStyles(r,t.type),l=Ji((null===(s=null==e?void 0:e.labels)||void 0===s?void 0:s.all)||{},(null===(o=null==e?void 0:e.labels)||void 0===o?void 0:o[t.type])||{}),d=this.prepareLabelStyles(t.type,l),c=this.prepareErrorStyles(null==e?void 0:e.errorTextStyles);t.update({styles:{inputStyles:a,labelStyles:d,errorTextStyles:c}})}),Ji(this.defaultStyles,e||{})}updateTranslations(e){const t=Ji(this.defaultTranslations||{},e||{});return this.formFields.forEach(e=>{var i,n,s,o;e.update({translations:{label:(null===(i=t.labels)||void 0===i?void 0:i[e.type])||"",placeholder:(null===(n=t.placeholders)||void 0===n?void 0:n[e.type])||"",translations:{error:{default:(null===(o=null===(s=t.error)||void 0===s?void 0:s.default)||void 0===o?void 0:o[e.type])||""}}}})}),t}updateEvents(e){this.eventsRef=Object.assign(Object.assign({},this.eventsRef),e),this.formFields.forEach(e=>{e.update({events:{onFocus:()=>{var e,t;return null===(t=null===(e=this.eventsRef)||void 0===e?void 0:e.onFocus)||void 0===t?void 0:t.call(e)},onChange:this.onChange.bind(this),onReady:this.triggerOnReady.bind(this)}})})}update(e){(null==e?void 0:e.styles)&&(this.defaultStyles=this.updateStyles(e.styles)),(null==e?void 0:e.translations)&&(this.defaultTranslations=this.updateTranslations(e.translations)),(null==e?void 0:e.events)&&this.updateEvents(e.events)}updateInstallmentConfig(e){var t,i,n,s,o;if(!this.paymentInstallmentsDropdown)return;const r=Pi.getPaymentInstallmentOptions(exports.PAYMENT_METHOD_CODES.CARD),a={installmentCurrency:(null===(t=Di().amount)||void 0===t?void 0:t.currency)||""};this.options&&e&&Object.prototype.hasOwnProperty.call(e,"defaultInstallment")&&(this.options.installmentConfig={defaultInstallment:null!==(i=e.defaultInstallment)&&void 0!==i?i:null},a.defaultInstallment=null!==(n=e.defaultInstallment)&&void 0!==n?n:null);const l=null===(o=null===(s=this.lastBinLookup)||void 0===s?void 0:s.issuerCountry)||void 0===o?void 0:o.code,d=l&&r?r[l]:void 0;a.installmentOptions=d||[],this.paymentInstallmentsDropdown.updateInstallmentConfig(a)}createFormField(e,t,i,n,s,o=!1){var r,a,l,d,c,u,p;const _=this.prepareErrorStyles(i);return new Ln(this.collectContainer,{type:e,required:o,label:null===(a=null===(r=this.defaultTranslations)||void 0===r?void 0:r.labels)||void 0===a?void 0:a[e],errorTextStyles:_,placeholder:(null===(d=null===(l=this.defaultTranslations)||void 0===l?void 0:l.placeholders)||void 0===d?void 0:d[e])||s,labelStyles:this.prepareLabelStyles(e),inputStyles:this.prepareInputStyles(t,e),translations:{error:{default:(null===(p=null===(u=null===(c=this.defaultTranslations)||void 0===c?void 0:c.error)||void 0===u?void 0:u.default)||void 0===p?void 0:p[e])||""}},format:n,events:{onFocus:()=>{var e,t;return null===(t=null===(e=this.eventsRef)||void 0===e?void 0:e.onFocus)||void 0===t?void 0:t.call(e)},onChange:this.onChange.bind(this),onReady:this.triggerOnReady.bind(this)}})}initializeCustomLayout(){var e;if(!(null===(e=this.options)||void 0===e?void 0:e.layout))return;const t=e=>{e.forEach(e=>{var t,i,n;const o=fn.find(t=>t.type===e);if(!o)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_TYPE);if(this.hasFieldBeenUsed(o.type))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_DUPLICATE_ELEMENT);const{type:r,styles:a,format:l,placeholder:d}=o,c=!!(null===(i=null===(t=this.defaultStyles)||void 0===t?void 0:t.errorTextStyles)||void 0===i?void 0:i.base);this.formFields.push(this.createFormField(r,a,null===(n=this.defaultStyles)||void 0===n?void 0:n.errorTextStyles,l,d,c))})};this.options.layout.forEach(e=>t(e))}hasFieldBeenUsed(e){return this.formFields.some(t=>t.type===e)}initializeDefaultLayout(){var e,t;const i=e=>{var t,i,n;return!(null===(t=this.options)||void 0===t?void 0:t.showCardHolderName)&&e===exports.ElementType.CARDHOLDER_NAME||(!(null===(i=this.options)||void 0===i?void 0:i.showSingleExpiryDateField)&&e===exports.ElementType.EXPIRATION_DATE||!(!(null===(n=this.options)||void 0===n?void 0:n.showSingleExpiryDateField)||e!==exports.ElementType.EXPIRATION_MONTH&&e!==exports.ElementType.EXPIRATION_YEAR))},n=!!(null===(t=null===(e=this.defaultStyles)||void 0===e?void 0:e.errorTextStyles)||void 0===t?void 0:t.base);fn.filter(({type:e})=>!i(e)).forEach(({type:e,styles:t,format:i,placeholder:s})=>{var o;this.formFields.push(this.createFormField(e,t,null===(o=this.defaultStyles)||void 0===o?void 0:o.errorTextStyles,i,s,n))})}throttledFetchBinLookupIfChanged(){return t(this,void 0,void 0,function*(){return this.bin!==this.lastBin&&(this.lastBin=this.bin,this.lastBinLookup=yield this.throttledFetchBinLookup()),this.lastBinLookup})}tokenize(e){return this.collectContainer.tokenize(e)}createAddressSelector(){var e,t;return new cn({id:"payrails-address-selector",events:Object.assign(Object.assign({},this.eventsRef),{onBillingAddressChanged:e=>{var t,i;this.onChange(),null===(i=null===(t=this.eventsRef)||void 0===t?void 0:t.onBillingAddressChanged)||void 0===i||i.call(t,e)}}),styles:null===(e=this.defaultStyles)||void 0===e?void 0:e.addressSelector,translations:null===(t=this.defaultTranslations)||void 0===t?void 0:t.addressSelector})}show(){var e;const t=document.getElementById(this.collectContainer.id);if(!t){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw o.PayrailsLogger.error(e.message,{error:e}),e}Object.assign(t.style,null===(e=this.defaultStyles)||void 0===e?void 0:e.wrapper),this.element.style.display="flex"}hide(e={}){this.element.style.display="none",e.reset&&this.reset()}triggerOnReady(){var e,t;this.formFields.reduce((e,t)=>e&&t.isReady,!0)&&(this.updateTranslations(this.defaultTranslations||{}),this.updateStyles(this.defaultStyles||{}),null===(t=null===(e=this.eventsRef)||void 0===e?void 0:e.onReady)||void 0===t||t.call(e))}prepareErrorStyles(e){var t,i;const n={base:{}};return n.base=Object.assign(Object.assign({},(null===(i=null===(t=this.defaultStyles)||void 0===t?void 0:t.errorTextStyles)||void 0===i?void 0:i.base)||{}),(null==e?void 0:e.base)||{}),n}prepareLabelStyles(e,t){var i,n,s,o,r;const a={};return a.base=Object.assign(Object.assign(Object.assign(Object.assign({},(null===(i=this.defaultStyles)||void 0===i?void 0:i.base)||{}),(null===(s=null===(n=this.defaultStyles)||void 0===n?void 0:n.labels)||void 0===s?void 0:s.all)||{}),(null===(r=null===(o=this.defaultStyles)||void 0===o?void 0:o.labels)||void 0===r?void 0:r[e])||{}),t||{}),a}prepareInputStyles(e,t){var i;const n={};return["base","complete","empty","focus","invalid","cardIcon","copyIcon"].forEach(i=>{var s,o,r,a,l,d;n[i]=Object.assign(Object.assign(Object.assign({},(null===(r=null===(o=null===(s=this.defaultStyles)||void 0===s?void 0:s.inputFields)||void 0===o?void 0:o.all)||void 0===r?void 0:r[i])||{}),(null===(d=null===(l=null===(a=this.defaultStyles)||void 0===a?void 0:a.inputFields)||void 0===l?void 0:l[t])||void 0===d?void 0:d[i])||{}),(null==e?void 0:e[i])||{})}),(null===(i=this.options)||void 0===i?void 0:i.showCardHolderName)&&t===exports.ElementType.CARD_NUMBER&&(this.element.setAttribute("class","with-card-holder"),n.base=Object.assign(Object.assign(Object.assign({},In.base),{border:"1px solid #eae8ee",borderTop:"none",padding:"10px 16px",textIndent:"0"}),n.base)),n}validate(){return this.collectContainer.validate()}focus(){const e=this.formFields.find(e=>!e.isValid)||this.formFields[0];if(!e)return;const t=document.getElementById(this.collectContainer.id)||this.element;t&&"function"==typeof t.scrollIntoView&&t.scrollIntoView({behavior:"smooth",block:"center"}),window.requestAnimationFrame(()=>{e.focus()})}get isValid(){var e;const t=this.formFields.reduce((e,t)=>e&&t.isValid,!0);return this.addressComponent?t&&!!(null===(e=this.addressComponent)||void 0===e?void 0:e.isValid):t}get cardNetwork(){var e,t;return null!==(t=null===(e=this.formFields.find(e=>Boolean(e.cardNetwork)))||void 0===e?void 0:e.cardNetwork)&&void 0!==t?t:""}onChange(){var e;(null===(e=this.eventsRef)||void 0===e?void 0:e.onChange)&&(this.eventsRef.onChange({isValid:this.isValid,cardNetwork:this.cardNetwork,bin:this.bin,billingAddress:this.billingAddress}),Pi.isPaymentInstallmentsEnabled(exports.PAYMENT_METHOD_CODES.CARD)&&this.bin.length>=6&&this.throttledFetchBinLookupIfChanged().then(e=>{this.updateInstallments(e)}))}updateInstallments(e){var t;if(this.paymentInstallmentsDropdown&&this.isBinLookupEnabled){const i=this.getinstallmentOptions(null===(t=null==e?void 0:e.issuerCountry)||void 0===t?void 0:t.code);i?this.paymentInstallmentsDropdown.updateInstallmentOptions(i):this.paymentInstallmentsDropdown.updateInstallmentOptions([])}}reset(){this.collectContainer.reset()}collectValues(){return t(this,void 0,void 0,function*(){return{cardData:yield this.collectContainer.collect(),storeInstrument:this.shouldStoreInstrument,selectedInstallment:this.selectedInstallment,enrollInstrumentToNetworkOffers:Boolean(this.enforceEnrollInstrumentToNetworkOffersForMasterCard()),billingInfo:this.billingAddress}})}get selectedInstallment(){var e;return null===(e=this.paymentInstallmentsDropdown)||void 0===e?void 0:e.selectedInstallmentValue}get billingAddress(){var e;return null===(e=this.addressComponent)||void 0===e?void 0:e.fullAddress}enforceEnrollInstrumentToNetworkOffersForMasterCard(){var e;return"mastercard"!==this.cardNetwork&&(null===(e=this.options)||void 0===e?void 0:e.enrollInstrumentToNetworkOffers)}fetchBinLookup(){return t(this,void 0,void 0,function*(){return this.isBinLookupEnabled?yield this.collectContainer.fetchBinLookup(this.bin):this.bin})}getinstallmentOptions(e){if(e){const t=Pi.getPaymentInstallmentOptions(exports.PAYMENT_METHOD_CODES.CARD);return t?t[e]:null}return null}unmount(){this.hide({reset:!0}),super.unmount()}mount(e){super.mount(e),this.show()}}class Ln{constructor(e,t){this.isValid=!1,this.isReady=!1,this.cardNetwork="";const{events:i}=t;this.vaultElement=e.createCollectElement(t),this.type=t.type,(null==i?void 0:i.onFocus)&&this.vaultElement.on("FOCUS",i.onFocus),this.vaultElement.on("READY",()=>{var e,i;this.isReady=!0,null===(i=null===(e=t.events)||void 0===e?void 0:e.onReady)||void 0===i||i.call(e)}),this.vaultElement.on("CHANGE",e=>{const{isEmpty:t,isValid:n,network:s}=e;this.isValid=!t&&n,this.cardNetwork=null!=s?s:"",(null==i?void 0:i.onChange)&&i.onChange(this)})}updateStyles(e){var t,i;null===(i=(t=this.vaultElement).update)||void 0===i||i.call(t,{type:this.type,errorTextStyles:(null==e?void 0:e.errorTextStyles)||{base:{}},inputStyles:(null==e?void 0:e.inputStyles)||{},labelStyles:(null==e?void 0:e.labelStyles)||{}})}updateTranslations(e){var t,i,n,s;null===(i=(t=this.vaultElement).update)||void 0===i||i.call(t,{type:this.type,label:(null==e?void 0:e.label)||"",translations:{error:{default:null===(s=null===(n=null==e?void 0:e.translations)||void 0===n?void 0:n.error)||void 0===s?void 0:s.default}},placeholder:(null==e?void 0:e.placeholder)||""})}update(e){e.styles&&this.updateStyles(e.styles),e.translations&&this.updateTranslations(e.translations)}focus(){var e,t;null===(t=(e=this.vaultElement).focus)||void 0===t||t.call(e)}}class On extends Wi{constructor(e,t,i,n,s){super("div",{id:e,className:"payrails-dropin-item"}),this.events=n,this.styles=s,this.isActive=!1,this.mountContainerClass="payrails-dropin-item-container",this.applyBaseStyles();const o=`payrails-dropin-item-${e}`,r=document.createElement("label");r.setAttribute("for",o);const a=document.createElement("input");if(a.setAttribute("type","radio"),a.setAttribute("name","payment-option"),a.setAttribute("id",o),a.setAttribute("value",o),this.input=a,r.appendChild(a),this.label=r,i){const e=document.createElement("img");e.src=null!=i?i:"",e.className="payrails-store-instrument-icon",r.appendChild(e)}const l=document.createElement("span");r.appendChild(l),l.innerText=t,this.element.addEventListener("click",()=>{var e,t;null===(t=(e=this.label).onchange)||void 0===t||t.call(e,new Event("change"))}),this.element.appendChild(r);const d=document.createElement("div");d.setAttribute("class",this.mountContainerClass),this.element.appendChild(d)}get identifier(){return`payrails-dropin-item-${this.id}`}deactivate(){var e,t;this.isActive&&(this.isActive=!1,this.input.checked=!1,this.applyBaseStyles(),null===(e=this.component)||void 0===e||e.unmount(),(null===(t=this.events)||void 0===t?void 0:t.onDeactivate)&&this.events.onDeactivate())}applyBaseStyles(){var e,t;this.element.classList.remove("active"),Object.keys((null===(e=this.styles)||void 0===e?void 0:e.active)||{}).forEach(e=>{this.element.style.removeProperty(e)}),Object.assign(this.element.style,null===(t=this.styles)||void 0===t?void 0:t.base)}applyActiveStyles(){var e,t;this.element.classList.add("active"),Object.assign(this.element.style,null===(e=this.styles)||void 0===e?void 0:e.base,null===(t=this.styles)||void 0===t?void 0:t.active)}activate(){var e,t,i;this.isActive||(null===(e=this.component)||void 0===e||e.mount(`${this.selector} .${this.mountContainerClass}`),this.applyActiveStyles(),this.input.checked=!0,this.isActive=!0,(null===(t=this.events)||void 0===t?void 0:t.onActivate)&&this.events.onActivate(),(null===(i=this.events)||void 0===i?void 0:i.onPaymentOptionVisibilityChange)&&this.events.onPaymentOptionVisibilityChange())}mount(e){var t,i;super.mount(e),null===(i=null===(t=this.events)||void 0===t?void 0:t.onAvailable)||void 0===i||i.call(t)}}var gn;!function(e){e.AMEX="amex",e.DINERS="diners",e.DISCOVER="discover",e.HIPERCARD="hipercard",e.JCB="jcb",e.MAESTRO="maestro",e.MASTERCARD="mastercard",e.UNIONPAY="unionpay",e.VISA="visa"}(gn||(gn={}));const Tn={[exports.PAYMENT_METHOD_CODES.CARD]:"https://assets.payrails.io/img/logos/card/",[exports.PAYMENT_METHOD_CODES.PAYPAL]:"https://assets.payrails.io/img/logos/paypal/",[exports.PAYMENT_METHOD_CODES.APPLE_PAY]:"https://assets.payrails.io/img/logos/applepay/",[exports.PAYMENT_METHOD_CODES.GOOGLE_PAY]:"https://assets.payrails.io/img/logos/googlepay/"};class Cn extends On{constructor(e,t,i,n,s){const o=e.displayName&&""!==e.displayName?e.displayName:"Unavailable";super(`payrails-payment-instrument-${e.id}`,o,Cn.getInstrumentIcon(e),{onActivate:()=>{i(e),this.component.setDisabled(!1),this.installmentDropdown&&this.component.setPaymentInstallmentsDropdown(this.installmentDropdown)}},n),this.installmentDropdown=null,s&&(this.installmentDropdown=s),this.instrumentData=e,this.component=new Rn(t,s)}static getInstrumentIcon(e){var t;if(e.paymentMethod===exports.PAYMENT_METHOD_CODES.CARD){const i=Tn[exports.PAYMENT_METHOD_CODES.CARD];switch(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.network){case gn.AMEX:return i+"amex.svg";case gn.DINERS:return i+"diners-club.svg";case gn.DISCOVER:return i+"discover.svg";case gn.HIPERCARD:return i+"hipercard.svg";case gn.JCB:return i+"jcb.svg";case gn.MAESTRO:return i+"maestro.svg";case gn.MASTERCARD:return i+"mastercard.svg";case gn.UNIONPAY:return i+"unionpay.svg";case gn.VISA:return i+"visa.svg"}return i+"default.svg"}return e.paymentMethod===exports.PAYMENT_METHOD_CODES.PAYPAL?Tn[exports.PAYMENT_METHOD_CODES.PAYPAL]+"logo.svg":e.paymentMethod===exports.PAYMENT_METHOD_CODES.APPLE_PAY?Tn[exports.PAYMENT_METHOD_CODES.APPLE_PAY]+"logo.svg":e.paymentMethod===exports.PAYMENT_METHOD_CODES.GOOGLE_PAY?Tn[exports.PAYMENT_METHOD_CODES.GOOGLE_PAY]+"logo.svg":""}updateInstallmentConfig(e){var t,i,n,s,o;if(!this.installmentDropdown||this.instrumentData.paymentMethod!==exports.PAYMENT_METHOD_CODES.CARD)return;const r=Pi.getPaymentInstallmentOptions(exports.PAYMENT_METHOD_CODES.CARD),a=null===(n=null===(i=null===(t=this.instrumentData.data)||void 0===t?void 0:t.binLookup)||void 0===i?void 0:i.issuerCountry)||void 0===n?void 0:n.code,l={installmentCurrency:(null===(s=Di().amount)||void 0===s?void 0:s.currency)||""};e&&Object.prototype.hasOwnProperty.call(e,"defaultInstallment")&&(l.defaultInstallment=null!==(o=e.defaultInstallment)&&void 0!==o?o:null);const d=a&&r?r[a]:void 0;l.installmentOptions=d||[],this.installmentDropdown.updateInstallmentConfig(l)}}class Rn extends Wi{constructor(e,t){super("div",{id:"stored-instrument-container",className:"payrails-stored-instrument-container"}),this.paymentButton=e,this.paymentInstallmentDropdown=t,this.paymentInstallmentDropdown&&this.subElements.push(this.paymentInstallmentDropdown),this.subElements.push(this.paymentButton)}setDisabled(e){this.paymentButton.setDisabled(e),this.paymentInstallmentDropdown&&this.paymentInstallmentDropdown.setDisabled(e)}setPaymentInstallmentsDropdown(e){this.paymentInstallmentDropdown=e,this.paymentButton.setPaymentInstallmentsDropdown(e)}}class Nn extends Wi{constructor(e){super("div",{id:"payrails-card-list"}),this.listItems=[],Pi.savedCreditCards.forEach(t=>{const i=new Sn(()=>{(null==e?void 0:e.onCardChange)&&e.onCardChange(t)},t);this.listItems.push(i),this.subElements.push(i)})}reset(){this.element.querySelectorAll("input").forEach(e=>e.checked=!1)}}class Sn extends Wi{constructor(e,t){super("div",{className:"payrails-card-list-item",id:`payrails-card-list-item-${t.id}`});const{id:i}=t,n=t.displayName&&""!==t.displayName?t.displayName:"Unavailable",s=document.createElement("label");s.setAttribute("for",i),s.addEventListener("click",e);const o=document.createElement("input");o.setAttribute("type","radio"),o.setAttribute("name","payment-option"),o.setAttribute("id",i),o.setAttribute("value",i),s.appendChild(o);const r=document.createElement("span");r.className="payment-option-text",s.appendChild(r);const a=document.createElement("img");a.src=Cn.getInstrumentIcon(t),a.className="payment-option-icon",r.appendChild(a),r.appendChild(document.createTextNode(n)),this.element.appendChild(s)}}class Pn extends Wi{constructor(e){var t;super("div",{id:"authorization-failed-message"}),this.options=e;const i=(null===(t=null==e?void 0:e.translations)||void 0===t?void 0:t.label)||"Authorization failed, please try again.";this.element.innerText=i,this.setStyles((null==e?void 0:e.styles)||{}),this.element.innerHTML=`\n <div>\n <svg class="checkmark-cross" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">\n <circle class="checkmark-cross_circle" cx="26" cy="26" r="25" fill="none"/>\n <path class="checkmark-cross_check" fill="none" d="M14.1 14.1l23.8 23.8 m0,-23.8 l-23.8,23.8"/>\n </svg>\n </div>\n <div class="payrails-auth-failed-label">${i}</div>`,this.element.addEventListener("click",e=>{e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),this.unmount()})}mount(e){super.mount(e),this.scheduleAutoHide()}setStyles(e){Object.keys(e).forEach(t=>{this.element.style[t]=e[t]})}scheduleAutoHide(){var e,t;const i=null===(t=null===(e=this.options)||void 0===e?void 0:e.configuration)||void 0===t?void 0:t.autoHideTTL;i&&setTimeout(()=>{this.unmount()},i)}}class bn extends Wi{constructor(e){var t;super("div",{id:"payrails-authorization-success-msg"}),this.setStyles((null==e?void 0:e.styles)||{}),this.element.innerHTML=`\n <div class="checkmark-wrapper">\n <svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">\n <circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none"/>\n <path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/>\n </svg>\n </div>\n <div id="payrails-authorization-success">${(null===(t=null==e?void 0:e.translations)||void 0===t?void 0:t.label)||"Payment successful"}</div`}setStyles(e){Object.keys(e).forEach(t=>{this.element.style[t]=e[t]})}}class Dn extends Wi{constructor(e){super("div",{id:"payrails-dropin-loader",className:"payrails-dropin-loader-wrapper"}),this.options=e,this.selectors={[Mn.overlay]:".loading-overlay",[Mn.loader]:".lds-ring .loading-ring"},this.element.innerHTML="\n <div class='loading-overlay'>\n <div class='lds-ring'>\n <div></div>\n <div></div>\n <div></div>\n <div class='loading-ring'></div>\n </div>\n </div>\n "}mount(e){var t;(null===(t=this.options)||void 0===t?void 0:t.styles)&&this.setStyles(this.options.styles),super.mount(e)}setStyles(e){Object.keys(e).forEach(t=>{const i=t;e[i]&&this.applyStyles(i,e[i])})}applyStyles(e,t){const i=this.element.querySelector(this.selectors[e]);i&&Object.keys(t).forEach(e=>{i.style[e]=t[e]})}}var Mn;!function(e){e.overlay="overlay",e.loader="loader"}(Mn||(Mn={}));const wn="https://assets.payrails.io/img/logos";function kn(e=""){switch(e=e.trim().split(/\s+/).join("").toLowerCase()){case"adyen-old":e="adyen";break;case"checkout.com":e="checkout";break;case"visaoffersplatform":e="visa";break;case"bankAccount":e="banktransfer"}return"card"!==e?`${wn}/${e}/logo.svg`:`${wn}/card/credit-card-regular.svg`}class Yn extends On{constructor(){super(...arguments),this.buttonShown=!1}activate(){var e,t;if(!this.buttonShown)return super.activate(),void(this.buttonShown=!0);this.applyActiveStyles(),this.isActive=!0,this.element.querySelector(this.component.selector).style.display="block",null===(t=null===(e=this.events)||void 0===e?void 0:e.onPaymentOptionVisibilityChange)||void 0===t||t.call(e)}deactivate(){this.isActive&&(this.isActive=!1,this.applyBaseStyles(),this.element.querySelector(this.component.selector).style.display="none")}mountAfterAvailable(){var e,t;super.mount(`#${this.loadElementId}`),null===(t=null===(e=this.events)||void 0===e?void 0:e.onAvailable)||void 0===t||t.call(e)}mount(e){const t=document.querySelector(e);if(!t){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);throw o.PayrailsLogger.error(e.message,{error:e}),e}const i=document.createElement("div");i.setAttribute("id",this.loadElementId),i.setAttribute("style","width: 100%;"),t.appendChild(i)}unmount(){var e;super.unmount(),null===(e=document.querySelector(`#${this.loadElementId}`))||void 0===e||e.remove()}}class Un extends Yn{constructor(e){var t,i;super("apple-pay-dropin",(null===(i=null===(t=e.translations)||void 0===t?void 0:t.labels)||void 0===i?void 0:i.label)||"Apple Pay",e.showPaymentMethodLogo?kn("applepay"):void 0,void 0,e.styles),this.loadElementId="apple-pay-dropin-load-element",this.component=new Zi(Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},e.events),{onApplePayAvailable:()=>{this.mountAfterAvailable()}})}))}}class xn extends On{constructor(e,t,i){var n,s;super("payrails-credit-card-wrapper",(null===(s=null===(n=i.translations)||void 0===n?void 0:n.labels)||void 0===s?void 0:s.label)||"Card",i.showPaymentMethodLogo?kn("card"):void 0,Object.assign({},i.events),Object.assign({},i.styles)),this.cardForm=e,this.paymentButton=t,this.cardFormShown=!1,this.component=new Fn(e,t)}activate(){var e,t,i;this.applyActiveStyles(),this.cardFormShown||(this.cardFormShown=!0,null===(e=this.component)||void 0===e||e.mount(this.selector)),this.isActive||(this.paymentButton.selectedInstrument=null,this.paymentButton.mount(this.selector),this.paymentButton.setDisabled(!this.cardForm.isValid),this.paymentButton.mount("#payrails-card-form"),this.input.checked=!0,this.cardForm.show(),this.isActive=!0,(null===(t=this.events)||void 0===t?void 0:t.onActivate)&&this.events.onActivate(),(null===(i=this.events)||void 0===i?void 0:i.onPaymentOptionVisibilityChange)&&this.events.onPaymentOptionVisibilityChange())}deactivate(){var e;this.isActive&&(this.applyBaseStyles(),this.paymentButton.unmount(),this.cardForm.hide(),this.isActive=!1,(null===(e=this.events)||void 0===e?void 0:e.onDeactivate)&&this.events.onDeactivate())}}class Fn extends Wi{constructor(e,t){super("div",{id:"payrails-form-container"}),this.subElements.push(e,t)}}class jn{constructor(e,t,i,n=Bn.THREE_DS){this.link=e,this.paymentExecutor=t,this.options=i,this.type=n,this.THREE_DS_SIZES=[[250,400],[390,400],[500,600],[600,450]],this.internalPopupBackground=null,this.SCREEN_WIDTH=window.innerWidth,this.SCREEN_HEIGHT=window.innerHeight}get iframeSize(){return this.type===Bn.THREE_DS?this.THREE_DS_SIZES.reduce((e,t)=>this.SCREEN_WIDTH>t[0]?t:e,[250,400]):[this.SCREEN_WIDTH-50,this.SCREEN_HEIGHT-50]}get popupBackground(){if(this.internalPopupBackground)return this.internalPopupBackground;{const e=document.createElement("div");e.setAttribute("id","payrails-popup-background"),e.appendChild(this.popup),this.internalPopupBackground=e}return this.internalPopupBackground}get popupCancelButton(){const e=document.createElement("button");return e.setAttribute("id","payrails-popup-cancel-button"),e.setAttribute("type","button"),e.setAttribute("aria-label","Close"),e.addEventListener("click",()=>{L.getEventBus().emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}),bs(Ns.AUTHORIZE,this.options.events,{code:exports.AuthorizationFailureReasons.USER_CANCELLED,message:"User cancelled the authorization."}),this.unmount()}),e}get popup(){const e=document.createElement("div");return e.setAttribute("id","payrails-popup"),e.setAttribute("width",this.iframeSize[0].toString()),e.setAttribute("height",this.iframeSize[1].toString()),!0===this.options.showCancelButton&&e.appendChild(this.popupCancelButton),e.appendChild(this.iframe),e.style.width=`${this.iframeSize[0]+4}px`,e.style.height=`${this.iframeSize[1]+4}px`,e}get iframe(){const e=document.createElement("iframe");return e.setAttribute("id","payrails-frame"),e.setAttribute("src",this.link),e.setAttribute("width",this.iframeSize[0].toString()),e.setAttribute("height",this.iframeSize[1].toString()),e.setAttribute("allow","clipboard-write; clipboard-read"),e}handleMessages(){const e=i=>t(this,void 0,void 0,function*(){var t,n,s,o,r;if(i.data&&'{"type":"3DS-challenge-completed"}'===i.data){window.removeEventListener("message",e);const i=yield this.paymentExecutor.pollForAuthorizationResult(Pi.url);switch(null===(t=i.finalState)||void 0===t?void 0:t.code){case"authorizeSuccessful":Ps(Ns.AUTHORIZE,this.options.events);break;case"authorizePending":Ms(Ns.AUTHORIZE,this.options.events);break;default:bs(Ns.AUTHORIZE,this.options.events,{code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:(null===(r=null===(o=null===(s=null===(n=i.finalState)||void 0===n?void 0:n.errors)||void 0===s?void 0:s[0])||void 0===o?void 0:o.reason)||void 0===r?void 0:r.result)||"Authorization failed after 3DS challenge."})}this.unmount()}});window.addEventListener("message",e)}mount(){var e;this.popup.remove(),null===(e=document.querySelector("body"))||void 0===e||e.appendChild(this.popupBackground),this.handleMessages()}unmount(){this.popupBackground.remove(),this.internalPopupBackground=null}}var Bn;!function(e){e[e.THREE_DS=0]="THREE_DS",e[e.GENERIC_REDIRECT=1]="GENERIC_REDIRECT"}(Bn||(Bn={}));const Vn="__PAYRAILS__TAB_MANUAL_CLOSE_ERROR__",Gn={label:"Generic redirect"},Xn={pix:75e4,modo:6e5},zn={showCancelButton:!0};class Hn extends Wi{constructor(e,t){var i,n,s;super("button",{id:`payrails-generic-redirect-${e.paymentMethod.paymentMethodCode}`,className:"payrails-generic-button"}),this.options=e,this.returnInfo=t,this.popup=null,this.isDisabled=!1,this.isLoading=!1,this.element.innerText=null!==(n=null===(i=this.options.translations)||void 0===i?void 0:i.label)&&void 0!==n?n:Gn.label,(null===(s=this.options.styles)||void 0===s?void 0:s.base)&&this.setStyles(this.options.styles.base),this.element.addEventListener("click",this.onClick.bind(this)),this.element.addEventListener("mouseenter",()=>{var e;!this.isDisabled&&(null===(e=this.options.styles)||void 0===e?void 0:e.hover)&&this.setStyles(this.options.styles.hover)}),this.element.addEventListener("mouseleave",()=>{var e;!this.isDisabled&&(null===(e=this.options.styles)||void 0===e?void 0:e.hover)&&this.removeStyles(this.options.styles.hover)}),this.paymentExecutor=new xi(this.returnInfo),this.eventBus.on("PAYRAILS_CLIENT_SESSION_EXPIRED",()=>{this.triggerLoading(!1)})}setStyles(e){var t;const i=Object.assign(Object.assign({},null===(t=this.options.styles)||void 0===t?void 0:t.base),e);Object.keys(i).forEach(e=>{this.element.style[e]=i[e]})}removeStyles(e){var t;const i=Object.keys((null===(t=this.options.styles)||void 0===t?void 0:t.base)||{});Object.keys(e).forEach(e=>{var t,n;i.includes(e)?this.element.style[e]=null===(n=null===(t=this.options.styles)||void 0===t?void 0:t.base)||void 0===n?void 0:n[e]:this.element.style[e]=""})}triggerLoading(e){var t,i,n,s;this.isDisabled=e,this.isLoading=e,e?(this.element.innerHTML='\n <div class="dot-flashing-container">\n <div class="dot-flashing"></div>\n <span class="dot-flashing-text" aria-hidden="true">Loading</span>\n </div>\n ',(null===(t=this.options.styles)||void 0===t?void 0:t.loading)&&this.setStyles(this.options.styles.loading)):(this.element.innerText=null!==(n=null===(i=this.options.translations)||void 0===i?void 0:i.label)&&void 0!==n?n:Gn.label,this.removeStyles((null===(s=this.options.styles)||void 0===s?void 0:s.loading)||{}))}isSafari(){const e=navigator.userAgent.toLowerCase();return e.includes("safari")&&!e.includes("chrome")&&!e.includes("chromium")}onClick(){return t(this,void 0,void 0,function*(){var e,t;if(this.isDisabled)return;let i=null;this.options.openInNewTab&&this.isSafari()&&(i=window.open("","_blank"));try{this.triggerLoading(!0);if(!(yield ws(Ns.AUTHORIZE,null!==(e=this.options.events)&&void 0!==e?e:{})))return this.triggerLoading(!1),void(i&&!i.closed&&i.close());const n=null===(t=Pi.availablePaymentMethods.find(({paymentMethodCode:e})=>e===this.options.paymentMethod.paymentMethodCode))||void 0===t?void 0:t.integrationType;if(!n)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED);const o=yield this.paymentExecutor.pay([{paymentMethodCode:this.options.paymentMethod.paymentMethodCode,integrationType:n,amount:Di().amount}]),{action:r,link:a}=this.handleAuthorizationResult(o);if("redirect"!==r)return void(i&&!i.closed&&i.close());if(!a)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK);if(Object.keys(Xn).includes(this.options.paymentMethod.paymentMethodCode)){i&&!i.closed&&i.close();const e=Xn[this.options.paymentMethod.paymentMethodCode],t=2e4,n=2e3,s=Math.ceil((e-t)/n);return new xi(this.returnInfo,n,s,t).pollForAuthorizationResult(Pi.url,0,["authorizeSuccessful","authorizeFailed"]).then(e=>{var t;this.handleAuthorizationResult(e),null===(t=this.popup)||void 0===t||t.unmount()}),this.createPopupWithTimeout(a,e)}return this.redirectToPaymentLink(a,i)}catch(e){i&&!i.closed&&i.close(),e instanceof s.PayrailsError&&o.PayrailsLogger.error(e.message,{error:e}),bs(Ns.AUTHORIZE,this.options.events),this.triggerLoading(!1)}finally{this.isLoading||this.triggerLoading(!1)}})}handleAuthorizationResult(e){var t,i;if("authorizePending"===(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code)){const t=e.response.links.redirect;if(!t)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK);return{code:"authorizePending",link:t,action:"redirect"}}return"authorizeSuccessful"===(null===(i=null==e?void 0:e.finalState)||void 0===i?void 0:i.code)?(Ps(Ns.AUTHORIZE,this.options.events),{code:"authorizeSuccessful",action:"success"}):(bs(Ns.AUTHORIZE,this.options.events,e),this.triggerLoading(!1),{code:"authorizeFailed",action:"fail"})}createPopupWithTimeout(e,t){return new Promise(()=>{const i=new jn(e,this.paymentExecutor,Object.assign(Object.assign({},this.options),zn));this.popup=i,this.popup.mount(),setTimeout(()=>{null==i||i.unmount(),bs(Ns.AUTHORIZE,this.options.events),this.triggerLoading(!1)},t)})}redirectToPaymentLink(e,t=null){return new Promise(i=>{if(this.options.openInNewTab){const n=t||window.open(e,"_blank");if(!n||n.closed||void 0===n.closed){o.PayrailsLogger.warn("Popup blocked. Falling back to same tab redirect."),window.location.href=e;const t=setTimeout(()=>{var e;bs(Ns.AUTHORIZE,this.options.events),(null===(e=this.returnInfo)||void 0===e?void 0:e.error)?window.location.href=this.returnInfo.error:(this.triggerLoading(!1),this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}))},6e4);return window.addEventListener("pagehide",()=>{clearTimeout(t)}),void i()}t&&(n.location.href=e),this.monitorRedirectInNewTab(n).finally(()=>{i()})}else{window.location.href=e;const t=setTimeout(()=>{var e;bs(Ns.AUTHORIZE,this.options.events),(null===(e=this.returnInfo)||void 0===e?void 0:e.error)?window.location.href=this.returnInfo.error:(this.triggerLoading(!1),this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}))},6e4);window.addEventListener("pagehide",()=>{clearTimeout(t)}),i()}})}monitorRedirectInNewTab(e){return t(this,void 0,void 0,function*(){var t,i,n,s,r,a;let l;try{l=Pi.url}catch(n){return o.PayrailsLogger.error("Unable to resolve workflow execution URL.",{error:n}),this.triggerLoading(!1),e.closed||e.close(),void(null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onAuthorizeFailed)||void 0===i||i.call(t,{code:exports.AuthorizationFailureReasons.UNKNOWN_ERROR,message:"Unable to resolve workflow execution URL.",rawError:n}))}const d=new xi(this.returnInfo),c=new AbortController,{promise:u,cleanup:p}=this.watchTabClosure(e,()=>{c.signal.aborted||c.abort(Vn),this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{})});try{const e=yield Promise.race([d.pollForAuthorizationResult(l,0,["authorizeSuccessful","authorizeFailed"],{signal:c.signal}),u]);c.signal.aborted||c.abort("authorization-completed"),this.handleAuthorizationResult(e)}catch(e){if(c.signal.aborted||c.abort(e),e===Vn){try{const e=new xi(this.returnInfo,1e3,3,0),t=yield e.pollForAuthorizationResult(l,0,["authorizeSuccessful","authorizeFailed"]);return void this.handleAuthorizationResult(t)}catch(e){}null===(s=null===(n=this.options.events)||void 0===n?void 0:n.onAuthorizeFailed)||void 0===s||s.call(n,{code:exports.AuthorizationFailureReasons.USER_CANCELLED,message:"User closed the payment window before completion."})}else o.PayrailsLogger.error("Failed to retrieve authorization result after redirect.",{error:e}),null===(a=null===(r=this.options.events)||void 0===r?void 0:r.onAuthorizeFailed)||void 0===a||a.call(r,{code:exports.AuthorizationFailureReasons.UNKNOWN_ERROR,message:"Failed to retrieve authorization result after redirect.",rawError:e})}finally{c.signal.aborted||c.abort("cleanup"),p(),e.closed||e.close(),this.triggerLoading(!1)}})}watchTabClosure(e,t){let i,n=!0;const s=()=>{void 0!==i&&(window.clearInterval(i),i=void 0),n=!1};return{promise:new Promise((o,r)=>{i=window.setInterval(()=>{if(!n)return;let i=!1;try{i=e.closed}catch(e){i=!0}i&&(s(),null==t||t(),r(Vn))},500)}),cleanup:s}}updateStyles(e){var t,i;this.options.styles=Object.assign(Object.assign({},this.options.styles||{}),e),this.isLoading?this.setStyles((null===(t=this.options.styles)||void 0===t?void 0:t.loading)||{}):this.setStyles((null===(i=this.options.styles)||void 0===i?void 0:i.base)||{})}updateTranslations(e){var t,i;this.options.translations=Object.assign(Object.assign({},this.options.translations||{}),e),this.element.innerText=null!==(i=null===(t=this.options.translations)||void 0===t?void 0:t.label)&&void 0!==i?i:Gn.label}updateEvents(e){this.options.events=Object.assign(Object.assign({},this.options.events||{}),e)}update(e){e.styles&&this.updateStyles(e.styles),e.translations&&this.updateTranslations(e.translations),e.events&&this.updateEvents(e.events)}}const qn=e=>e===exports.PAYMENT_METHOD_CODES.GENERIC_REDIRECT?{translations:{label:"Mercado Pago",button:{label:"Pay with Mercado Pago"}}}:{translations:{label:e,button:{label:`Pay with ${e}`}}};class Wn extends On{constructor(e,t){var i,n,s,o,r,a;super(`payrails-${e.paymentMethod.paymentMethodCode}-dropin-element`,(null===(i=null==e?void 0:e.translations)||void 0===i?void 0:i.label)||qn(e.paymentMethod.paymentMethodCode).translations.label,(null===(n=e.config)||void 0===n?void 0:n.showPaymentMethodLogo)?kn(e.paymentMethod.paymentMethodCode):void 0,null==e?void 0:e.events,null===(s=null==e?void 0:e.styles)||void 0===s?void 0:s.element),this.returnInfo=t,this.component=new Hn({styles:(null===(o=null==e?void 0:e.styles)||void 0===o?void 0:o[e.paymentMethod.paymentMethodCode])||{},translations:(null===(r=null==e?void 0:e.translations)||void 0===r?void 0:r.button)||qn(e.paymentMethod.paymentMethodCode).translations.button,events:null==e?void 0:e.events,paymentMethod:e.paymentMethod,openInNewTab:null===(a=e.config)||void 0===a?void 0:a.openInNewTab},this.returnInfo)}}class Kn{constructor(e,t){this.options=e,this.paymentExecutor=t}handle3ds(e){var t,i,n;try{null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onThreeDSecureChallenge)||void 0===i||i.call(t)}catch(e){}const s=null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.links["3ds"];if(s)if(this.options.redirectFor3DS)window.location.assign(s);else{new jn(s,this.paymentExecutor,this.options).mount()}}}const $n={apiVersion:2,apiVersionMinor:0};class Zn extends $i{static getGooglePayConfigAsArray(e){return Array.isArray(e)?e:e.allowedPaymentMethods?e.allowedPaymentMethods:[]}static getSDKClient(){return t(this,arguments,void 0,function*(e=exports.PayrailsEnvironment.TEST,t){return yield Hi.load(qi.GooglePay),Zn.googleSDKClient||(Zn.googleSDKClient=new google.payments.api.PaymentsClient({environment:e,merchantInfo:t})),Zn.googleSDKClient})}static isGooglePayAvailable(e){return t(this,arguments,void 0,function*(e,t=exports.PayrailsEnvironment.TEST,i){try{const n=yield Zn.getSDKClient(t,i),s=Zn.getGooglePayConfigAsArray(e),o=Object.assign(Object.assign(Object.assign({},$n),{allowedPaymentMethods:s}),!Array.isArray(e)&&void 0!==e.existingPaymentMethodRequired&&{existingPaymentMethodRequired:e.existingPaymentMethodRequired}),{result:r}=yield n.isReadyToPay(o);return r}catch(e){return!1}})}constructor(e){var t;super("div",Object.assign(Object.assign({},e),{id:`payrails-google-pay-button-${p()}`,dataTestId:"payrails-google-pay-button"})),this.options=e,this.sdkLoadedCalled=!1,this.isProcessing=!1,this.buttonElement=null,this.paymentExecutor=new xi(null===(t=this.options)||void 0===t?void 0:t.returnInfo),Zn.isGooglePayAvailable(Pi.googlePayConfig,this.options.environment,this.options.merchantInfo).then(e=>{var t,i,n;e&&(null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onGooglePayAvailable)||void 0===n||n.call(i))}),this.action="tokenization"===Di().type?Ns.TOKENIZE:Ns.AUTHORIZE}sdkLoaded(e){return t(this,void 0,void 0,function*(){var i,n,s,o,r,a,l,d;if(this.sdkLoadedCalled)return this.buttonElement;this.sdkLoadedCalled=!0;const c=(null===(n=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===n?void 0:n.buttonColor)||"black",u=(null===(o=null===(s=this.options)||void 0===s?void 0:s.styles)||void 0===o?void 0:o.buttonType)||"long",p=(null===(a=null===(r=this.options)||void 0===r?void 0:r.styles)||void 0===a?void 0:a.buttonSizeMode)||"fill",_=(null===(d=null===(l=this.options)||void 0===l?void 0:l.styles)||void 0===d?void 0:d.buttonLocale)||void 0,h=Zn.getGooglePayConfigAsArray(Pi.googlePayConfig);return this.buttonElement=e.createButton({buttonColor:c,buttonType:u,buttonSizeMode:p,buttonLocale:_,onClick:()=>t(this,void 0,void 0,function*(){if(this.isProcessing)return;this.isProcessing=!0;(yield ws(this.action,this.options.events))?yield this.authorize(e):this.isProcessing=!1}),allowedPaymentMethods:h}),this.element.appendChild(this.buttonElement),this.buttonElement})}authorize(e){return t(this,void 0,void 0,function*(){var t,i,n,s,o,r,a,l,d,c;const u=Pi.googlePayConfig,p=!Array.isArray(u),_=Object.assign(Object.assign({},p&&void 0!==u.apiVersion?{apiVersion:u.apiVersion,apiVersionMinor:u.apiVersionMinor}:$n),{allowedPaymentMethods:Zn.getGooglePayConfigAsArray(u),transactionInfo:{totalPriceStatus:"FINAL",totalPrice:null===(t=Di().amount)||void 0===t?void 0:t.value,currencyCode:null===(i=Di().amount)||void 0===i?void 0:i.currency,countryCode:null===(r=null===(o=null===(s=null===(n=Pi.meta)||void 0===n?void 0:n.order)||void 0===s?void 0:s.billingAddress)||void 0===o?void 0:o.country)||void 0===r?void 0:r.code},merchantInfo:{merchantId:(null===(a=u.merchantInfo)||void 0===a?void 0:a.merchantId)||(null===(l=this.options.merchantInfo)||void 0===l?void 0:l.merchantId)||"",merchantName:(null===(d=u.merchantInfo)||void 0===d?void 0:d.merchantName)||(null===(c=this.options.merchantInfo)||void 0===c?void 0:c.merchantName)||""}});p&&(void 0!==u.emailRequired&&(_.emailRequired=u.emailRequired),void 0!==u.shippingAddressRequired&&(_.shippingAddressRequired=u.shippingAddressRequired),u.shippingAddressParameters&&(_.shippingAddressParameters=u.shippingAddressParameters));try{const t=yield e.loadPaymentData(_);yield this.onLoadPaymentData(t)}catch(e){this.isProcessing=!1,bs(this.action,this.options.events,e)}})}onLoadPaymentData(e){return t(this,void 0,void 0,function*(){(yield gi(this.action,this.options.events))?(this.action===Ns.TOKENIZE?yield this.doTokenize(e):yield this.doAuthorizePayment(e),this.isProcessing=!1):this.isProcessing=!1})}doTokenize(e){return t(this,void 0,void 0,function*(){const t=Di(),i=Pi.createInstrumentLink,n=t.token;if(!i)return this.isProcessing=!1,void bs(Ns.TOKENIZE,this.options.events);let s;try{s=JSON.stringify(e)}catch(e){return this.isProcessing=!1,void bs(Ns.TOKENIZE,this.options.events,e)}const o={holderReference:t.holderReference,paymentMethod:exports.PAYMENT_METHOD_CODES.GOOGLE_PAY,data:{paymentToken:s}};try{const e=yield Oi({url:i,token:n,body:o});return e.ok?(this.isProcessing=!1,Ps(Ns.TOKENIZE,this.options.events,e.res),e.res):(this.isProcessing=!1,void bs(Ns.TOKENIZE,this.options.events))}catch(e){return this.isProcessing=!1,void bs(Ns.TOKENIZE,this.options.events,e)}})}doAuthorizePayment(e){return t(this,void 0,void 0,function*(){var t,i,n,s,o,r;const a={paymentToken:JSON.stringify(e)},l=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.GOOGLE_PAY,integrationType:"api",paymentInstrumentData:a,amount:Di().amount,storeInstrument:this.shouldStoreInstrument}],d=yield this.paymentExecutor.pay(l);if("authorizePending"===(null===(t=null==d?void 0:d.finalState)||void 0===t?void 0:t.code)){new Kn(this.options,this.paymentExecutor).handle3ds(d)}else"authorizeSuccessful"===(null===(i=null==d?void 0:d.finalState)||void 0===i?void 0:i.code)?Ps(Ns.AUTHORIZE,this.options.events):bs(Ns.AUTHORIZE,this.options.events,{code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:(null===(r=null===(o=null===(s=null===(n=d.finalState)||void 0===n?void 0:n.errors)||void 0===s?void 0:s[0])||void 0===o?void 0:o.reason)||void 0===r?void 0:r.result)||"Authorization Failed"})})}mount(e){super.mount(e),(()=>{t(this,void 0,void 0,function*(){var e;try{if(yield Zn.isGooglePayAvailable(Pi.googlePayConfig,this.options.environment,this.options.merchantInfo)){const t=yield Zn.getSDKClient(this.options.environment,this.options.merchantInfo),i=yield this.sdkLoaded(t);this.element.appendChild(i),null===(e=this.storeInstrumentCheckbox)||void 0===e||e.mount(this.selector)}}catch(e){}})})()}unmount(){var e;null===(e=this.storeInstrumentCheckbox)||void 0===e||e.unmount(),this.buttonElement=null,super.unmount()}}Zn.googleSDKClient=null;class Jn extends Yn{constructor(e){var t,i;super("google-pay-dropin",(null===(i=null===(t=e.translations)||void 0===t?void 0:t.labels)||void 0===i?void 0:i.label)||"Google Pay",e.showPaymentMethodLogo?kn("googlepay"):void 0,e.events,e.styles),this.loadElementId="google-pay-dropin-load-element",this.component=new Zn(Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},e.events),{onGooglePayAvailable:()=>{this.mountAfterAvailable()}}),returnInfo:e.returnInfo}))}}class Qn extends $i{constructor(e){var i;Qn.instance&&(Qn.instance=void 0);const n="express"===(null===(i=null==Pi?void 0:Pi.paypalConfig)||void 0===i?void 0:i.integrationMode),s=!n&&(null==e?void 0:e.showStoreInstrumentCheckbox),o=n?"unchecked":null==e?void 0:e.defaultStoreInstrumentState,r=Object.assign(Object.assign({},e),{showStoreInstrumentCheckbox:s,defaultStoreInstrumentState:o,id:"payrails-paypal-button",events:Object.assign(Object.assign({},null==e?void 0:e.events),{onSaveInstrumentCheckboxChanged:i=>t(this,void 0,void 0,function*(){var t,n,s;null===(n=null===(t=null==e?void 0:e.events)||void 0===t?void 0:t.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(t,i),null===(s=this.button)||void 0===s||s.close(),this.debouncedRender()})})});super("div",r),this.options=e,this.renderDebounceTimeout=null,this.currentAbortController=null,this.isRendering=!1,this.buttonWrapperId="payrails-paypal-button-wrapper",this.checkboxWrapperId="payrails-paypal-checkbox-wrapper",this.createOneTimeOrder=()=>t(this,void 0,void 0,function*(){var e,t,i,n,s;const o=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.PAYPAL,integrationType:"api",amount:Di().amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!1}],r=yield this.paymentExecutor.pay(o),a=null===(i=null===(t=null===(e=r.response.links.confirm)||void 0===e?void 0:e.action)||void 0===t?void 0:t.parameters)||void 0===i?void 0:i.orderId;if(!a)throw bs(Ns.AUTHORIZE,null===(n=this.options)||void 0===n?void 0:n.events),new es("No order id returned");return this.confirmLink=null===(s=r.response.links.confirm)||void 0===s?void 0:s.href,a}),this.loadPaypal().catch(()=>{}),this.element.innerHTML=`<div id="${this.buttonWrapperId}"></div><div id="${this.checkboxWrapperId}"></div>`,this.paymentExecutor=new xi}loadPaypal(){return t(this,void 0,void 0,function*(){const e=yield Hi.load(qi.PayPal,this.paypalScriptConfig);return yield this.createPaypalButton(e)})}debouncedRender(){return this.renderDebounceTimeout&&clearTimeout(this.renderDebounceTimeout),this.currentAbortController&&this.currentAbortController.abort(),new Promise(e=>{this.renderDebounceTimeout=setTimeout(()=>t(this,void 0,void 0,function*(){try{yield this.renderButton(),e()}catch(t){console.error("Failed to render PayPal button:",t),e()}}),300)})}get paypalScriptConfig(){const e=this.shouldStoreInstrument?"tokenize":"Instant"===Pi.paypalConfig.captureMode?"capture":"authorize";return{clientId:Pi.paypalConfig.clientId,intent:e,currency:Di().amount.currency,vault:this.shouldStoreInstrument}}createPaypalButton(e){return t(this,void 0,void 0,function*(){var t,i,n;if(!e.Buttons)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR);const o=e.Buttons(this.createPayPalButtonConfig());return null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onPaypalAvailable)||void 0===n||n.call(i),o})}createPayPalButtonConfig(){return this.shouldStoreInstrument?this.createBillingAgreementConfig():this.createOneTimeOrderConfig()}createBillingAgreementConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{onApprove:this.approvePayment.bind(this),createBillingAgreement:()=>t(this,void 0,void 0,function*(){var e,t,i,n;const s=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.PAYPAL,integrationType:"api",amount:Di().amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!0}],o=yield this.paymentExecutor.pay(s);return this.confirmLink=null===(e=o.response.links.confirm)||void 0===e?void 0:e.href,(null===(n=null===(i=null===(t=o.response.links.confirm)||void 0===t?void 0:t.action)||void 0===i?void 0:i.parameters)||void 0===n?void 0:n.tokenId)||""})})}onCancel(){var e;this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}),bs(Ns.AUTHORIZE,null===(e=this.options)||void 0===e?void 0:e.events)}createOneTimeOrderConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{createOrder:this.createOneTimeOrder.bind(this),onApprove:this.approvePayment.bind(this)})}createBaseConfig(){var e,i,n,r,a,l,d,c,u,p;return{fundingSource:"paypal",style:{color:(null===(i=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===i?void 0:i.color)||"gold",height:(null===(r=null===(n=this.options)||void 0===n?void 0:n.styles)||void 0===r?void 0:r.height)||40,label:(null===(l=null===(a=this.options)||void 0===a?void 0:a.styles)||void 0===l?void 0:l.label)||"paypal",shape:(null===(c=null===(d=this.options)||void 0===d?void 0:d.styles)||void 0===c?void 0:c.shape)||"rect",tagline:(null===(p=null===(u=this.options)||void 0===u?void 0:u.styles)||void 0===p?void 0:p.tagline)||!1,disableMaxWidth:!0},onError:e=>{var t;this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}),bs(Ns.AUTHORIZE,null===(t=this.options)||void 0===t?void 0:t.events,e)},onClick:(e,i)=>t(this,void 0,void 0,function*(){var e;return(yield ws(Ns.AUTHORIZE,null===(e=this.options)||void 0===e?void 0:e.events))?i.resolve():i.reject()}),onCancel:this.onCancel.bind(this),onShippingAddressChange:(e,i)=>t(this,void 0,void 0,function*(){var n;let r;e.shippingAddress&&(r={deliveryAddress:{city:e.shippingAddress.city,postalCode:e.shippingAddress.postalCode,state:e.shippingAddress.state,country:{code:e.shippingAddress.countryCode}}});const a=yield((e,i)=>t(void 0,void 0,void 0,function*(){if(null==e?void 0:e.onDeliveryAddressChanged)try{const t=yield e.onDeliveryAddressChanged(i);if(!t){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onDeliveryAddressChanged resolved to false"});return o.PayrailsLogger.error(e.message,{error:e}),!1}return t}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onDeliveryAddressChanged threw an error",cause:e});return o.PayrailsLogger.error(t.message,{error:t}),!1}return!0}))(null===(n=this.options)||void 0===n?void 0:n.events,r);if(!a)return i.reject()})}}approvePayment(e){return t(this,void 0,void 0,function*(){var t,i,n,s,o,r,a,l,d;if(!this.confirmLink)throw bs(Ns.AUTHORIZE,null===(t=this.options)||void 0===t?void 0:t.events),new es("No confirm link");const c={};this.shouldStoreInstrument&&e.billingToken&&(c.tokenId=e.billingToken),this.fraudNetGuid&&(c.riskSessionCorrelationId=this.fraudNetGuid);if(!(yield gi(Ns.AUTHORIZE,null===(i=this.options)||void 0===i?void 0:i.events)))throw new es("Authorization request start validation failed");const u=yield this.paymentExecutor.confirm(this.confirmLink,c);"authorizeSuccessful"===(null===(n=u.finalState)||void 0===n?void 0:n.code)?Ps(Ns.AUTHORIZE,null===(s=this.options)||void 0===s?void 0:s.events):bs(Ns.AUTHORIZE,null===(o=this.options)||void 0===o?void 0:o.events,{code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:(null===(d=null===(l=null===(a=null===(r=u.finalState)||void 0===r?void 0:r.errors)||void 0===a?void 0:a[0])||void 0===l?void 0:l.reason)||void 0===d?void 0:d.result)||"Authorization Failed"})})}get fraudNetGuid(){var e,t;return null===(t=null===(e=window.PayrailsData)||void 0===e?void 0:e.riskIds)||void 0===t?void 0:t.fraudNet}mount(e){Qn.instance||(Qn.instance=this,super.mount(e),(()=>{t(this,void 0,void 0,function*(){yield this.debouncedRender()})})())}renderButton(){return t(this,void 0,void 0,function*(){var e;this.isRendering&&this.currentAbortController&&this.currentAbortController.abort(),this.currentAbortController=new AbortController;const t=this.currentAbortController.signal;try{this.isRendering=!0,this.button&&(this.button.close(),this.button=void 0);const i=yield Promise.race([this.loadPaypal(),new Promise((e,i)=>{t.addEventListener("abort",()=>i(new ts("PayPal button loading aborted")))})]);if(t.aborted)return;i&&(this.button=i,yield null===(e=this.button)||void 0===e?void 0:e.render(`#${this.buttonWrapperId}`))}catch(e){if(!t.aborted)throw e}finally{t.aborted||(this.isRendering=!1,this.currentAbortController=null)}})}unmount(){var e;this.renderDebounceTimeout&&clearTimeout(this.renderDebounceTimeout),this.currentAbortController&&this.currentAbortController.abort(),null===(e=this.button)||void 0===e||e.close(),this.isRendering=!1,Qn.instance=void 0,super.unmount()}}class es extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION,{description:`PaypalOrderError: ${e}`,cause:t})}}class ts extends s.PayrailsError{constructor(e,t){super(s.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT,{description:`PaypalButtonError: ${e}`,cause:t})}}class is extends Yn{constructor(e){var t,i;super("payrails-paypal-button-dropin",(null===(i=null===(t=null==e?void 0:e.translations)||void 0===t?void 0:t.labels)||void 0===i?void 0:i.label)||"PayPal",(null==e?void 0:e.showPaymentMethodLogo)?kn("paypal"):void 0,{onActivate:()=>{var t;super.activate(),(null===(t=null==e?void 0:e.events)||void 0===t?void 0:t.onPaymentOptionVisibilityChange)&&e.events.onPaymentOptionVisibilityChange()}},null==e?void 0:e.styles),this.loadElementId="paypal-dropin-load-element",this.component=new Qn(Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},null==e?void 0:e.events),{onPaypalAvailable:()=>{this.mountAfterAvailable()}})}))}}class ns extends Wi{constructor(e,t,i){var n,s,o;super("fieldset",{id:"payrails-dropin-component"}),this.collectContainer=e,this.clientConfig=t,this.dropinConfig=i,this.applyStyles();void 0!==(null===(s=null===(n=this.dropinConfig.paymentMethodsConfiguration)||void 0===n?void 0:n.cards)||void 0===s?void 0:s.showExistingCards)&&console.warn("The `showExistingCards` option is deprecated and will be removed in a future version. Please use `showStoredInstruments` instead.");const r=new Map;Pi.storedDropinInstruments.forEach(e=>{if(this.isStoredInstrumentEnabled(e.paymentMethod)){this.cardPaymentButton=this.createCardPaymentButton();const t=this.createStoredInstrumentElement(e);t&&r.set(t.identifier,t)}});const a={[exports.PAYMENT_METHOD_CODES.CARD]:this.createCreditCardButton.bind(this),[exports.PAYMENT_METHOD_CODES.PAYPAL]:this.createPayPalButton.bind(this),[exports.PAYMENT_METHOD_CODES.GOOGLE_PAY]:this.createGooglePayButton.bind(this),[exports.PAYMENT_METHOD_CODES.APPLE_PAY]:this.createApplePayButton.bind(this)};Pi.availablePaymentMethods.forEach(e=>{const t=e.paymentMethodCode;if(t&&a[t]){const i=(0,a[t])(Pi.getPaymentMethodConfig(e));r.set(i.identifier,i)}else if(this.isHppIntegration(e)&&t){const t=this.createHppIntegrationElement(e);r.set(t.identifier,t)}}),this.element.addEventListener("change",e=>{var t,i;const n=(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.value)||"";r.forEach(e=>{e.deactivate()}),null===(i=r.get(n))||void 0===i||i.activate()}),1===this.totalPaymentOptions&&this.element.classList.add("payrails-dropin-component--single"),this.subElements.push(...Array.from(r.values())),this.loadingScreen=new Dn({styles:null===(o=this.dropinConfig.styles)||void 0===o?void 0:o.loadingScreen})}get returnInfo(){return this.dropinConfig.returnInfo||this.clientConfig.returnInfo}isHppIntegration(e){var t;return e.paymentMethodCode===exports.PAYMENT_METHOD_CODES.GENERIC_REDIRECT||(null===(t=e.clientConfig)||void 0===t?void 0:t.flow)===Ni.REDIRECT}createStoredInstrumentElement(e){var t;let i;if(this.cardPaymentButton=this.createCardPaymentButton(),e.paymentMethod!==exports.PAYMENT_METHOD_CODES.BANK_ACCOUNT)return e.paymentMethod===exports.PAYMENT_METHOD_CODES.CARD&&Pi.isPaymentInstallmentsEnabled(e.paymentMethod)&&(i=this.createInstallmentsDropdown(e)),new Cn(e,this.cardPaymentButton,e=>{var t,i;if(this.cardPaymentButton){this.cardPaymentButton.selectedInstrument=e;const n=Pi.getPaymentMethodForStoredInstrument(e);null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onPaymentOptionSelected)||void 0===i||i.call(t,{paymentMethod:n,instrument:e})}},null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.element,i)}createInstallmentsDropdown(e){var t,i,n;const s=this.getInstallmentOptionsForInstrument(e);return new pn("span",{installmentConfig:{installmentCurrency:Di().amount.currency,installmentOptions:s,defaultInstallment:null===(n=null===(i=null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.cards)||void 0===i?void 0:i.installmentConfig)||void 0===n?void 0:n.defaultInstallment},id:`payrails-card-form-payment-installments-${e.id}`,className:"payrails-card-form-payment-installments-container"})}getInstallmentOptionsForInstrument(e){var t,i,n;const s=e.paymentMethod,o=Pi.getPaymentInstallmentOptions(s),r=null===(n=null===(i=null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.binLookup)||void 0===i?void 0:i.issuerCountry)||void 0===n?void 0:n.code;return r?o[r]:null}updateInstallmentConfig(e){var t,i,n;const s=null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.cards;s&&e&&Object.prototype.hasOwnProperty.call(e,"defaultInstallment")&&(s.installmentConfig={defaultInstallment:null!==(i=e.defaultInstallment)&&void 0!==i?i:null}),null===(n=this.cardForm)||void 0===n||n.updateInstallmentConfig(e),this.subElements.forEach(t=>{t instanceof Cn&&t.updateInstallmentConfig(e)})}createHppIntegrationElement(e){var t,i,n,r,a,l,d,c,u,p,_,h;const E=e.paymentMethodCode;if(!E){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED,{description:`Payment method code is missing for payment method - ${JSON.stringify(e)}`});throw o.PayrailsLogger.error(t.message,{error:t}),t}return new Wn({paymentMethod:e,config:Object.assign(Object.assign({},null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t[E]),{showPaymentMethodLogo:null!==(l=null!==(r=null===(n=null===(i=this.dropinConfig.paymentMethodsConfiguration)||void 0===i?void 0:i[E])||void 0===n?void 0:n.showPaymentMethodLogo)&&void 0!==r?r:null===(a=this.dropinConfig.paymentMethodsConfiguration)||void 0===a?void 0:a.showPaymentMethodLogo)&&void 0!==l&&l}),styles:{element:null===(c=null===(d=this.dropinConfig)||void 0===d?void 0:d.styles)||void 0===c?void 0:c.element,button:null===(_=null===(p=null===(u=this.dropinConfig)||void 0===u?void 0:u.styles)||void 0===p?void 0:p[E])||void 0===_?void 0:_.button},translations:null===(h=this.dropinConfig.translations)||void 0===h?void 0:h[E],events:Object.assign(Object.assign({},this.getElementEvents()),{onPaymentOptionVisibilityChange:()=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onPaymentOptionSelected)||void 0===i||i.call(t,{paymentMethod:e})}})},this.returnInfo)}get totalPaymentOptions(){return Pi.availablePaymentMethods.length+Pi.storedDropinInstruments.length}createCreditCardButton(e){var t,i,n,s,o,r,a;return this.creditCard=new xn(this.createCardForm(),this.createCardPaymentButton(),{events:Object.assign(Object.assign({},this.getElementEvents()),{onPaymentOptionVisibilityChange:()=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onPaymentOptionSelected)||void 0===i||i.call(t,{paymentMethod:e})}}),styles:null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.element,showPaymentMethodLogo:null!==(r=null!==(s=null===(n=null===(i=this.dropinConfig.paymentMethodsConfiguration)||void 0===i?void 0:i.cards)||void 0===n?void 0:n.showPaymentMethodLogo)&&void 0!==s?s:null===(o=this.dropinConfig.paymentMethodsConfiguration)||void 0===o?void 0:o.showPaymentMethodLogo)&&void 0!==r&&r,translations:null===(a=this.dropinConfig.translations)||void 0===a?void 0:a.cardForm}),this.creditCard}createGooglePayButton(e){var t,i,n,s,o,r,a,l;return this.googlePay=new Jn(Object.assign({environment:this.clientConfig.environment||exports.PayrailsEnvironment.TEST,events:Object.assign(Object.assign({},this.getElementEvents()),{onPaymentOptionVisibilityChange:()=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onPaymentOptionSelected)||void 0===i||i.call(t,{paymentMethod:e})}}),redirectFor3DS:this.clientConfig.redirectFor3DS,showPaymentMethodLogo:null!==(o=null!==(n=null===(i=null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.googlePay)||void 0===i?void 0:i.showPaymentMethodLogo)&&void 0!==n?n:null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s.showPaymentMethodLogo)&&void 0!==o&&o,styles:Object.assign(Object.assign({},null===(r=this.dropinConfig.styles)||void 0===r?void 0:r.googlePayButton),null===(a=this.dropinConfig.styles)||void 0===a?void 0:a.element),returnInfo:this.returnInfo},null===(l=this.dropinConfig.paymentMethodsConfiguration)||void 0===l?void 0:l.googlePay)),this.googlePay}createPayPalButton(e){var t,i,n,s,o,r,a,l;return this.paypal=new is(Object.assign(Object.assign({showPaymentMethodLogo:null!==(o=null!==(n=null===(i=null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.payPal)||void 0===i?void 0:i.showPaymentMethodLogo)&&void 0!==n?n:null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s.showPaymentMethodLogo)&&void 0!==o&&o},null===(r=this.dropinConfig.paymentMethodsConfiguration)||void 0===r?void 0:r.payPal),{styles:Object.assign(Object.assign({},null===(a=this.dropinConfig.styles)||void 0===a?void 0:a.paypalButton),null===(l=this.dropinConfig.styles)||void 0===l?void 0:l.element),events:Object.assign(Object.assign({},this.getElementEvents()),{onPaymentOptionVisibilityChange:()=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onPaymentOptionSelected)||void 0===i||i.call(t,{paymentMethod:e})}})})),this.paypal}createCardForm(){var e,t,i,n,s,o,r,a;if(!this.cardForm){const l=null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.cards,d=Boolean(null==l?void 0:l.showStoreInstrumentCheckbox),c=Boolean(null==l?void 0:l.showCardHolderName),u=Boolean(null==l?void 0:l.alwaysStoreInstrument),p=Boolean(null==l?void 0:l.showSingleExpiryDateField),_=(null==l?void 0:l.layout)||[];this.cardForm=new An(this.collectContainer,{showStoreInstrumentCheckbox:d,showCardHolderName:c,showSingleExpiryDateField:p,alwaysStoreInstrument:u,installmentConfig:null===(i=null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.cards)||void 0===i?void 0:i.installmentConfig,layout:_,translations:Object.assign(Object.assign({},null===(n=this.dropinConfig.translations)||void 0===n?void 0:n.cardForm),{addressSelector:null===(s=this.dropinConfig.translations)||void 0===s?void 0:s.addressSelector}),styles:Object.assign(Object.assign(Object.assign({},null===(o=this.dropinConfig.styles)||void 0===o?void 0:o.cardForm),null===(r=this.dropinConfig.styles)||void 0===r?void 0:r.element),{addressSelector:null===(a=this.dropinConfig.styles)||void 0===a?void 0:a.addressSelector}),events:Object.assign(Object.assign({},this.getElementEvents()),{onFocus:()=>{var e;null===(e=this.creditCard)||void 0===e||e.activate()},onChange:({isValid:e})=>{var t,i,n,s,o,r,a;const l="boolean"!=typeof(null===(i=null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.cards)||void 0===i?void 0:i.disablePaymentButton)||(null===(s=null===(n=this.dropinConfig.paymentMethodsConfiguration)||void 0===n?void 0:n.cards)||void 0===s?void 0:s.disablePaymentButton)?!e:null===(r=null===(o=this.dropinConfig.paymentMethodsConfiguration)||void 0===o?void 0:o.cards)||void 0===r?void 0:r.disablePaymentButton;null===(a=this.cardPaymentButton)||void 0===a||a.setDisabled(l)},onSaveInstrumentCheckboxChanged:e=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onSaveInstrumentCheckboxChanged)||void 0===i||i.call(t,e)}})})}return this.cardPaymentButton&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardForm}createApplePayButton(e){var i,n,s,o,r,a,l,d,c;return this.applePay=new Un(Object.assign(Object.assign({events:Object.assign(Object.assign({},this.getElementEvents()),{onAuthorizeSuccess:e=>{var t;if(e)if("authorizeSuccessful"===(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code))this.onAuthorizeSuccess();else this.onAuthorizeFailed()},onPaymentOptionVisibilityChange:()=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onPaymentOptionSelected)||void 0===i||i.call(t,{paymentMethod:e})},onPaymentButtonClicked:e=>t(this,void 0,void 0,function*(){var t,i,n;return!(null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onPaymentButtonClicked)||Boolean(yield null===(n=null===(i=this.dropinConfig.events)||void 0===i?void 0:i.onPaymentButtonClicked)||void 0===n?void 0:n.call(i,e))})})},null===(i=this.dropinConfig.paymentMethodsConfiguration)||void 0===i?void 0:i.applePay),{styles:Object.assign(Object.assign({},null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.applePayButton),null===(s=this.dropinConfig.styles)||void 0===s?void 0:s.element),translations:null===(o=this.dropinConfig.translations)||void 0===o?void 0:o.applePayButton,showPaymentMethodLogo:null!==(c=null!==(l=null===(a=null===(r=this.dropinConfig.paymentMethodsConfiguration)||void 0===r?void 0:r.applePay)||void 0===a?void 0:a.showPaymentMethodLogo)&&void 0!==l?l:null===(d=this.dropinConfig.paymentMethodsConfiguration)||void 0===d?void 0:d.showPaymentMethodLogo)&&void 0!==c&&c})),this.applePay}createCardPaymentButton(){var e,t,i,n;return this.cardPaymentButton||(this.cardPaymentButton=new ks({styles:null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.cardPaymentButton,translations:null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.cardPaymentButton,redirectFor3DS:this.clientConfig.redirectFor3DS,disabledByDefault:null===(n=null===(i=this.dropinConfig.paymentMethodsConfiguration)||void 0===i?void 0:i.cards)||void 0===n?void 0:n.disablePaymentButton,events:this.getElementEvents()},this.returnInfo)),this.cardForm&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardPaymentButton}onAuthorizeSuccess(){var e,t,i,n,s,o,r;null===(e=this.loadingScreen)||void 0===e||e.unmount(),this.subElements.forEach(e=>e.unmount()),new bn({translations:{label:null===(n=null===(i=null===(t=this.dropinConfig)||void 0===t?void 0:t.translations)||void 0===i?void 0:i.paymentResult)||void 0===n?void 0:n.success},styles:null===(o=null===(s=this.dropinConfig)||void 0===s?void 0:s.styles)||void 0===o?void 0:o.authSuccess}).mount(this.selector),(null===(r=this.dropinConfig.events)||void 0===r?void 0:r.onAuthorizeSuccess)&&this.dropinConfig.events.onAuthorizeSuccess()}getElementEvents(){return Object.assign(Object.assign({},this.dropinConfig.events),{onAuthorizeSuccess:this.onAuthorizeSuccess.bind(this),onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onAuthorizePending:this.onAuthorizePending.bind(this),onAvailable:()=>{var e;(1===this.totalPaymentOptions||(null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.preselectFirstPaymentOption))&&setTimeout(()=>{try{this.subElements[0].activate()}catch(e){o.PayrailsLogger.error("Error while auto-activating the first payment option",{error:new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING,{cause:e})})}},0)},onPaymentButtonClicked:e=>t(this,void 0,void 0,function*(){var t,i,n,s;null===(t=this.loadingScreen)||void 0===t||t.mount(this.selector);let o=!0;return(null===(i=this.dropinConfig.events)||void 0===i?void 0:i.onPaymentButtonClicked)&&(o=!!(yield null===(s=null===(n=this.dropinConfig.events)||void 0===n?void 0:n.onPaymentButtonClicked)||void 0===s?void 0:s.call(n,e))),o})})}onAuthorizePending(){var e,t,i,n,s,o,r,a;null===(e=this.loadingScreen)||void 0===e||e.unmount(),this.subElements.forEach(e=>e.unmount()),new bn({translations:{label:(null===(n=null===(i=null===(t=this.dropinConfig)||void 0===t?void 0:t.translations)||void 0===i?void 0:i.paymentResult)||void 0===n?void 0:n.pending)||"Payment pending"},styles:null===(o=null===(s=this.dropinConfig)||void 0===s?void 0:s.styles)||void 0===o?void 0:o.authSuccess}).mount(this.selector),null===(a=null===(r=this.dropinConfig.events)||void 0===r?void 0:r.onAuthorizePending)||void 0===a||a.call(r)}getErrorMessage(e){var t,i,n,s,o,r;let a=null===(i=null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.paymentResult)||void 0===i?void 0:i.fail;return(null==e?void 0:e.message)&&(null===(s=null===(n=this.dropinConfig.translations)||void 0===n?void 0:n.errorMessages)||void 0===s?void 0:s[null==e?void 0:e.message])&&(a=null===(r=null===(o=this.dropinConfig.translations)||void 0===o?void 0:o.errorMessages)||void 0===r?void 0:r[null==e?void 0:e.message]),a}onAuthorizeFailed(e){return t(this,void 0,void 0,function*(){var t,i,n,s,o;null===(t=this.loadingScreen)||void 0===t||t.unmount();new Pn({translations:{label:this.getErrorMessage(e)},styles:null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.authFailed,configuration:null===(n=this.dropinConfig.configuration)||void 0===n?void 0:n.authFailMsg}).mount(this.selector),null===(o=null===(s=this.dropinConfig.events)||void 0===s?void 0:s.onAuthorizeFailed)||void 0===o||o.call(s,e)})}isStoredInstrumentEnabled(e){var t,i,n,s,o,r;switch(e){case exports.PAYMENT_METHOD_CODES.CARD:return!1!==(null===(i=null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.cards)||void 0===i?void 0:i.showStoredInstruments)&&!1!==(null===(s=null===(n=this.dropinConfig.paymentMethodsConfiguration)||void 0===n?void 0:n.cards)||void 0===s?void 0:s.showExistingCards);case exports.PAYMENT_METHOD_CODES.PAYPAL:case exports.PAYMENT_METHOD_CODES.GOOGLE_PAY:case exports.PAYMENT_METHOD_CODES.APPLE_PAY:return!1!==(null===(r=null===(o=this.dropinConfig.paymentMethodsConfiguration)||void 0===o?void 0:o[e])||void 0===r?void 0:r.showStoredInstruments);default:return!1}}applyStyles(){var e;(null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.container)&&Object.assign(this.element.style,this.dropinConfig.styles.container.styles)}fetchBinLookup(){return t(this,void 0,void 0,function*(){var e;return null===(e=this.cardForm)||void 0===e?void 0:e.fetchBinLookup()})}}class ss extends Wi{tokenize(e){return t(this,void 0,void 0,function*(){const t=yield this.collect(),i=Di(),n=i.vaultConfiguration.links.saveInstrument,r=i.token;if(!n.href){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND,{description:"Save instrument URL not available!"});throw o.PayrailsLogger.error(e.message,{error:e}),e}const a=yield this.constructSaveInstrumentBody(t,e);return(yield Oi({url:n.href,token:r,body:a})).res})}}class os{static minLength(e,t){return!!(t.minLength&&e.length<t.minLength)}static maxLength(e,t){return!!(t.maxLength&&e.length>t.maxLength)}static required(e,t,i){return!(!t||e)}static pattern(e,t){if(!t.pattern)return!1;return!new RegExp(t.pattern).test(e)}static oneOf(e,t){if(!t.oneOf||0===t.oneOf.length)return!1;return!t.oneOf.map(e=>e.const).includes(e)}}class rs extends Wi{get name(){return this.options.name}get isVisible(){return this._isVisible}get isRequired(){return this._isRequired}constructor(e){super("div",{id:e.id,className:"payrails-dynamic-element-form-field"}),this.options=e,this.errors=[],this._isVisible=!0,this._isRequired=!!this.options.required,this.makeField()}setVisible(e){this._isVisible=e,this.element.style.display=e?"block":"none"}setRequired(e){this._isRequired=e}validate(e=!1){e||this.clearError();const t=[];if(this._isVisible&&this._isRequired){os.required(this.value,!0,this.options.property)&&t.push(this.options.errors.required)}if(this.value){os.minLength(this.value,this.options.property)&&t.push(this.options.errors.minLength);os.maxLength(this.value,this.options.property)&&t.push(this.options.errors.maxLength);os.pattern(this.value,this.options.property)&&t.push(this.options.errors.pattern);os.oneOf(this.value,this.options.property)&&t.push(this.options.errors.oneOf)}if(e){return 0===t.length}return this.setErrors(t),this.isValid?this.updateStyles("base"):this.updateStyles("invalid"),this.isValid}makeField(){this.createLabel(),this.createComponentContainer(),this.createErrorMessageContainer()}createLabel(){this.label=document.createElement("label"),this.label.textContent=this.options.label,this.label.className="payrails-dynamic-element-form-field-label",this.label.htmlFor=this.options.name,this.element.appendChild(this.label)}createComponentContainer(){this.componentContainer=document.createElement("div"),this.componentContainer.className="payrails-dynamic-element-form-field-component",this.element.appendChild(this.componentContainer)}createErrorMessageContainer(){this.errorMessage=document.createElement("div"),this.errorMessage.className="payrails-dynamic-element-form-field-error",this.errorMessage.style.display="none",this.element.appendChild(this.errorMessage)}setErrors(e){var t;if(this.errors=e,this.errorMessage){for(;this.errorMessage.firstChild;)this.errorMessage.removeChild(this.errorMessage.firstChild);if(e.length>0){const t=document.createElement("ul");e.forEach(e=>{var i;const n=document.createElement("li");n.textContent=e,(null===(i=this.options.styles)||void 0===i?void 0:i.errors)&&Object.assign(n.style,this.options.styles.errors),t.appendChild(n)}),this.errorMessage.appendChild(t),this.errorMessage.style.display="block"}else this.errorMessage.style.display="none";(null===(t=this.options.styles)||void 0===t?void 0:t.errors)&&Object.assign(this.errorMessage.style,this.options.styles.errors),this.isValid?this.element.classList.remove("error"):this.element.classList.add("error")}}clearError(){this.errors=[],this.errorMessage&&(this.errorMessage.textContent="",this.errorMessage.style.display="none",this.element.classList.remove("error"))}injectElement(e){this.componentContainer&&(e.id=this.options.name,e.setAttribute("name",this.options.name),this.componentContainer.appendChild(e),this.options.events.onReady(this.value))}get isValid(){return 0===this.errors.length}}class as extends rs{constructor(e){super(e),this.makeComponent(),this.attachEvents()}makeComponent(){this.component=document.createElement("input"),this.component.type="text",this.component.className="payrails-dynamic-element-input",this.component.placeholder=this.options.placeholder,this.updateStyles("base"),this.injectElement(this.component)}attachEvents(){this.component&&(this.component.addEventListener("change",e=>{var t,i;e.stopPropagation(),null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onChange)||void 0===i||i.call(t,this.value)}),this.component.addEventListener("input",()=>{var e,t;this.updateValidationState(),null===(t=null===(e=this.options.events)||void 0===e?void 0:e.onChange)||void 0===t||t.call(e,this.value)}),this.component.addEventListener("blur",()=>{var e,t;this.updateStyles("base"),this.updateValidationState(),null===(t=null===(e=this.options.events)||void 0===e?void 0:e.onBlur)||void 0===t||t.call(e)}),this.component.addEventListener("focus",()=>{this.updateStyles("focus")}))}updateValidationState(){this.validate(),this.isValid?(this.updateStyles("complete"),this.updateCustomValidity(!0)):(this.updateStyles("invalid"),this.updateCustomValidity(!1))}updateStyles(e){var t,i;(null===(i=null===(t=this.options.styles)||void 0===t?void 0:t.input)||void 0===i?void 0:i[e])&&this.component&&Object.assign(this.component.style,this.options.styles.input[e])}updateCustomValidity(e){this.component&&this.component.setCustomValidity(e?"":this.errors.join(", "))}get value(){var e;return(null===(e=this.component)||void 0===e?void 0:e.value)||""}set value(e){this.component&&(this.component.value=e,this.updateValidationState())}}class ls extends rs{get value(){var e;return(null===(e=this.component)||void 0===e?void 0:e.value)||""}set value(e){this.component&&(this.component.value=e)}constructor(e){super(e),this.selectOptions=e.options,this.makeComponent(),this.attachEvents()}attachEvents(){this.component&&(this.component.addEventListener("change",e=>{var t,i;e.stopPropagation(),this.validate(),null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onChange)||void 0===i||i.call(t,this.value)}),this.component.addEventListener("blur",()=>{var e,t;this.updateStyles("base"),this.validate(),null===(t=null===(e=this.options.events)||void 0===e?void 0:e.onBlur)||void 0===t||t.call(e)}),this.component.addEventListener("focus",()=>{this.updateStyles("focus")}))}makeComponent(){this.component=document.createElement("select"),this.component.className="payrails-dynamic-element-select",this.selectOptions.forEach(e=>{const t=document.createElement("option");t.value=e.value,t.textContent=e.label,this.component&&this.component.appendChild(t)}),this.updateStyles("base"),this.injectElement(this.component)}updateStyles(e){var t,i;(null===(i=null===(t=this.options.styles)||void 0===t?void 0:t.select)||void 0===i?void 0:i[e])&&this.component&&Object.assign(this.component.style,this.options.styles.select[e])}}class ds extends rs{get value(){return this.currentValue}set value(e){this.currentValue!==e&&(this.currentValue=e,this.updateTabStates())}constructor(e){var t,i,n,s;super(e),this.tabs=new Map,this.options=e,this.tabOptions=e.options,this.currentValue=(null===(t=this.tabOptions[0])||void 0===t?void 0:t.value)||"",this.component=document.createElement("div"),this.component.className="payrails-dynamic-element-tabs",(null===(s=null===(n=null===(i=this.options.styles)||void 0===i?void 0:i.tabs)||void 0===n?void 0:n.container)||void 0===s?void 0:s.base)&&Object.assign(this.component.style,this.options.styles.tabs.container.base),this.makeTabs(),this.injectElement(this.component)}createTab(e){var t,i,n;const s=document.createElement("button");return s.type="button",s.textContent=e.label,s.className="payrails-dynamic-element-tab",(null===(n=null===(i=null===(t=this.options.styles)||void 0===t?void 0:t.tabs)||void 0===i?void 0:i.tab)||void 0===n?void 0:n.base)&&Object.assign(s.style,this.options.styles.tabs.tab.base),s.addEventListener("click",t=>{var i,n;t.stopPropagation(),t.stopImmediatePropagation(),this.value=e.value,this.options.events.onChange(this.value),null===(n=null===(i=this.options.events)||void 0===i?void 0:i.onBlur)||void 0===n||n.call(i)}),s}makeTabs(){this.component.innerHTML="",this.tabs.clear(),this.tabOptions.forEach(e=>{const t=this.createTab(e);this.component.appendChild(t),this.tabs.set(e.value,t)}),this.updateTabStates()}updateTabStates(){this.tabs.forEach((e,t)=>{var i,n,s,o,r,a;e.classList.toggle("active",t===this.currentValue),e.removeAttribute("style"),t===this.currentValue&&(null===(s=null===(n=null===(i=this.options.styles)||void 0===i?void 0:i.tabs)||void 0===n?void 0:n.tab)||void 0===s?void 0:s.active)?Object.assign(e.style,this.options.styles.tabs.tab.active):(null===(a=null===(r=null===(o=this.options.styles)||void 0===o?void 0:o.tabs)||void 0===r?void 0:r.tab)||void 0===a?void 0:a.base)&&Object.assign(e.style,this.options.styles.tabs.tab.base)})}updateStyles(){}}const cs="ui:position";function us(e){return t(this,void 0,void 0,function*(){if(!e||"object"!=typeof e)return e;const i=ps(e);if(0===i.size)return e;const n=yield function(e){return t(this,void 0,void 0,function*(){const i=new Map,n=Array.from(e).map(e=>t(this,void 0,void 0,function*(){try{const t=(yield tn({url:e})).res;i.set(e,t)}catch(t){console.warn(`Failed to fetch schema from ${e}:`,t)}}));return yield Promise.all(n),i})}(i);return _s(e,n)})}function ps(e,t=new Set){return Array.isArray(e)?e.forEach(e=>ps(e,t)):e&&"object"==typeof e&&(e.$ref&&/^https?:\/\//.test(e.$ref)&&t.add(e.$ref),Object.values(e).forEach(e=>ps(e,t))),t}function _s(e,t){if(Array.isArray(e))return e.map(e=>_s(e,t));if(e&&"object"==typeof e){if(e.$ref&&/^https?:\/\//.test(e.$ref)){if(!t.has(e.$ref))return;const i=_s(t.get(e.$ref),t);return void 0!==e[cs]?Object.assign(Object.assign({},i),{[cs]:e[cs]}):i}const i={};for(const[n,s]of Object.entries(e)){const e=_s(s,t);void 0!==e&&(i[n]=e)}return i}return e}function hs(e,t,i){var n,s;const o=null===(n=e.oneOf)||void 0===n?void 0:n.find(e=>{var n,s;return(null===(s=null===(n=e.properties)||void 0===n?void 0:n[t])||void 0===s?void 0:s.const)===i});if(!o)return{};const r=new Set(o.required||[]),a=new Set((null===(s=e.oneOf)||void 0===s?void 0:s.flatMap(e=>e.required||[]))||[]);return Object.fromEntries(Array.from(a).filter(e=>e!==t).map(e=>[e,{isVisible:r.has(e),isRequired:r.has(e)}]))}function Es(e,t,i,n){var s,o,r,a,l,d,c,u,p,_,h,E;return{id:`payrails-dynamic-element-field:${e}`,name:e,property:t,label:null!==(a=null!==(r=null===(o=null===(s=null==n?void 0:n.fields)||void 0===s?void 0:s[e])||void 0===o?void 0:o.label)&&void 0!==r?r:t.title)&&void 0!==a?a:`${e}:label`,placeholder:null!==(c=null===(d=null===(l=null==n?void 0:n.fields)||void 0===l?void 0:l[e])||void 0===d?void 0:d.placeholder)&&void 0!==c?c:`${e}:placeholder`,errors:Ji({required:"This field is required",minLength:"This field is too short",maxLength:"This field is too long",pattern:"This field is invalid",oneOf:"This field is invalid"},null!==(u=t.errorMessage)&&void 0!==u?u:{},null!==(p=null==n?void 0:n.errors)&&void 0!==p?p:{},null!==(E=null===(h=null===(_=null==n?void 0:n.fields)||void 0===_?void 0:_[e])||void 0===h?void 0:h.errors)&&void 0!==E?E:{}),required:i}}function ms(e){var t,i;return null!==(i=null===(t=e.oneOf)||void 0===t?void 0:t.map(e=>({value:String(e.const),label:e.title})))&&void 0!==i?i:[]}class vs extends ss{constructor(e,t,i){super("div",{id:"payrails-dynamic-element-form",className:"payrails-dynamic-element-form"}),this.options=e,this.formConfig=t,this.returnInfo=i,this.formFields=new Map,this.formData={},this.__schema=null,this._previousFormValidState=null}collect(){return t(this,void 0,void 0,function*(){if(!this.parentElement)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_NOT_MOUNTED,{description:"Dynamic element form is not mounted"});let e={};const t=Object.fromEntries(this.formFields.entries());if(Object.values(t).forEach(t=>{t.validate(),t.isVisible&&(e=Pt(e,t.name,t.value))}),!this.isFormValid())throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_FORM_INVALID,{description:"Dynamic element form is invalid"});return e})}constructSaveInstrumentBody(e,i){return t(this,void 0,void 0,function*(){var t;return{data:e,merchantReference:Pi.response.merchantReference,holderReference:Pi.response.holderReference,holderId:Pi.response.holderId,paymentMethod:this.options.paymentMethod.paymentMethodCode,storeInstrument:null!==(t=null==i?void 0:i.storeInstrument)&&void 0!==t&&t}})}isFormValid(){return Object.values(this.formFields).filter(e=>e.isVisible).every(e=>e.isValid)}isFormValidSilent(){return Object.values(this.formFields).filter(e=>e.isVisible).every(e=>e.validate(!0))}checkAndTriggerValidationChange(){var e,t;const i=this.isFormValidSilent();this._previousFormValidState!==i&&(this._previousFormValidState=i,null===(t=null===(e=this.options.events)||void 0===e?void 0:e.onValidationChange)||void 0===t||t.call(e,i))}mount(e){const i=Object.create(null,{mount:{get:()=>super.mount}});return t(this,void 0,void 0,function*(){var t,n;yield this.makeForm(),i.mount.call(this,e),null===(n=null===(t=this.options.events)||void 0===t?void 0:t.onReady)||void 0===n||n.call(t)})}makeForm(){return t(this,void 0,void 0,function*(){var e;if(!(null===(e=this.formConfig)||void 0===e?void 0:e.schema))return;this.__schema=yield us(this.formConfig.schema);const t=function(e,t){const i={};if(!function(e){return e&&"object"==typeof e}(e))return i;const n=(e,s)=>{var o;if(e.properties)for(const[r,a]of Object.entries(e.properties)){const l=s?`${s}.${r}`:r,d=a;"object"===d.type&&d.properties?n(d,l):i[l]=Es(l,d,(null===(o=e.required)||void 0===o?void 0:o.includes(r))||!1,t)}};return n(e,""),i}(this.__schema,this.options.translations),i=Object.values(t).sort((e,t)=>{var i,n;return(null!==(i=e.property[cs])&&void 0!==i?i:0)-(null!==(n=t.property[cs])&&void 0!==n?n:0)});for(const e of i)this.createField(e);this.evaluateDependencies()})}createField(e){const t=this.createFieldSync(e);t&&(this.formFields.set(e.name,t),this.subElements.push(t))}createFieldSync(e){return t=e.property,Boolean(t.oneOf&&t.oneOf.length>0)?this.createOneOfField(e):function(e){return"string"===e.type&&!e.oneOf}(e.property)?this.createStringField(e):null;var t}createOneOfField(e){const t="bankAccount.holder.type"===e.name?"tabs":"select";return this.createFieldByType(e,t)}createStringField(e){return this.createFieldByType(e,"input")}createFieldByType(e,t){const i=this.extractStyles(e.name,t),n=this.makeFieldEvents(e.name);switch(t){case"tabs":return new ds(Object.assign(Object.assign({},e),{events:n,styles:i,options:ms(e.property)}));case"select":return new ls(Object.assign(Object.assign({},e),{events:n,styles:i,options:ms(e.property)}));case"input":return new as(Object.assign(Object.assign({},e),{events:n,styles:i}));default:throw new Error(`Unsupported component type: ${t}`)}}extractStyles(e,t){var i,n,s,o,r,a,l,d,c,u,p,_,h,E;const m=Ji({},null!==(s=null===(n=null===(i=this.options.styles)||void 0===i?void 0:i.all)||void 0===n?void 0:n[t])&&void 0!==s?s:{},null!==(l=null===(a=null===(r=null===(o=this.options.styles)||void 0===o?void 0:o.fields)||void 0===r?void 0:r[e])||void 0===a?void 0:a[t])&&void 0!==l?l:{}),v=Ji({},null!==(u=null===(c=null===(d=this.options.styles)||void 0===d?void 0:d.all)||void 0===c?void 0:c.errors)&&void 0!==u?u:{},null!==(E=null===(h=null===(_=null===(p=this.options.styles)||void 0===p?void 0:p.fields)||void 0===_?void 0:_[e])||void 0===h?void 0:h.errors)&&void 0!==E?E:{});return{[t]:m,errors:v}}makeFieldEvents(e){return{onChange:(t=>{this.formData=Pt(this.formData,e,t),this.evaluateDependencies()}).bind(this),onReady:(t=>{this.formData=Pt(this.formData,e,t)}).bind(this),onBlur:(()=>{this.checkAndTriggerValidationChange()}).bind(this)}}evaluateDependencies(){if(!this.__schema)return;const e=function(e,t){const i={};if(!e.dependentSchemas)return i;for(const[n,s]of Object.entries(e.dependentSchemas)){const e=St(t,n);if(s.oneOf){const t=hs(s,n,e);Object.assign(i,t)}}return i}(this.__schema,this.formData);for(const[t,i]of Object.entries(e)){const e=this.formFields.get(t);e&&(e.setVisible(i.isVisible),e.setRequired(i.isRequired))}}}const ys=e=>t(void 0,void 0,void 0,function*(){if(null==e?void 0:e.onSessionExpired)try{const t=yield e.onSessionExpired();if(t)Mi(t),(null==e?void 0:e.onClientInitialized)&&e.onClientInitialized(Pi);else{const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_SESSION_REFRESH_FAILED,{description:"Session refresh failed with no result returned"});o.PayrailsLogger.error(e.message,{error:e})}}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_SESSION_REFRESH_FAILED,{description:"Callback passed to onSessionExpired threw an error",cause:e});o.PayrailsLogger.error(t.message,{error:t})}}),Is={visa:J.VISA.regex,mastercard:J.MASTERCARD.regex,amex:J.AMEX.regex,diners_club:J.DINERS_CLUB.regex,discover:J.DISCOVER.regex,jcb:J.JCB.regex,hipercard:J.HIPERCARD.regex,unionpay:J.UNIONPAY.regex,maestro:J.MAESTRO.regex,elo:J.ELO.regex};class fs{constructor(e,i){var n;this.bin="",this.isBinLookupEnabled=!1,this.id="payrails-container-wrapper",this.dataTestId="payrails-container-wrapper",this.className="payrails-container-wrapper",this.containerType="COMPOSABLE",this.manualErrorElements=new Set,this.fetchBinLookup=e=>t(this,void 0,void 0,function*(){var t,i;if(!e)return{bin:""};if(e.length<6)return{bin:e};const n=`${null===(i=null===(t=Di().links)||void 0===t?void 0:t.binLookup)||void 0===i?void 0:i.href}`;if(!n)return{bin:e};const r=Di().token,a={bin:e};try{const e=yield(({url:e,token:t,body:i})=>h({url:e,method:_.POST,token:t,body:i}))({url:n,token:r,body:a});return e.res}catch(t){const i=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_BIN_LOOKUP_FAILED,{description:"Error fetching BIN lookup data!",cause:t});return o.PayrailsLogger.error(i.message,{error:i}),{bin:e}}}),this.cardTableName=i.cardTableName||"cards",this.containerType=i.containerType||"COMPOSABLE",this.isBinLookupEnabled=!!(null===(n=Di().links)||void 0===n?void 0:n.binLookup);try{this.__container=e.container(this.containerType,i)}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CREATION_FAILED,{cause:e});o.PayrailsLogger.error(t.message,{error:t})}}static init(e,t){var i;return this.instance&&(null===(i=this.instance.__container)||void 0===i||i.unmount()),this.instance=new fs(e,t),this.instance}createCollectElement(e){var t;const i={required:!!e.required,enableCardIcon:!1!==e.enableCardIcon},n=null===(t=this.__container)||void 0===t?void 0:t.create(Object.assign(Object.assign({table:this.cardTableName,labelStyles:{},errorTextStyles:{},column:this.elementToFieldMap.get(e.type)},e),{type:e.type===exports.ElementType.CARDHOLDER_NAME?"INPUT_FIELD":e.type}),e.format?Object.assign(Object.assign({},i),{format:e.format}):i);if(!n){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING,{description:"Error creating collect element!"});throw o.PayrailsLogger.error(e.message,{error:e}),e}return this.attachCustomEventHandler(n)}mount(e){if("COLLECT"===this.containerType){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw o.PayrailsLogger.error(e.message,{error:e}),e}this.element=document.createElement("span"),this.element.setAttribute("id",`${this.id}`),this.element.setAttribute("data-testid",this.dataTestId),this.element.setAttribute("class",this.className);const t=document.querySelector(e);if(!t){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING);throw o.PayrailsLogger.error(t.message,{error:t,extra:{elementSelector:e}}),t}t.appendChild(this.element);try{window.setTimeout(()=>{this.__container.mount(`#${this.id}`)},50)}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);o.PayrailsLogger.error(t.message,{error:t})}}unmount(){this.element&&this.element.remove()}validate(){return t(this,void 0,void 0,function*(){var e;return yield null===(e=this.__container)||void 0===e?void 0:e.validate()})}collect(){return t(this,void 0,void 0,function*(){try{return yield this.collectPayrailsData()}catch(e){const t=new Error(e.message);t.stack=e.stack,t.name=e.name,t.message=e.message;const i=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_OPERATION_FAILED,{description:"Error collecting data from the iframe!",cause:t});throw t.name!==s.ERROR_CODES.PAYRAILS_CARD_FORM_COMPLETE_AND_VALID_INPUTS&&o.PayrailsLogger.error(i.message,{error:i}),i}})}reset(){var e;null===(e=this.__container)||void 0===e||e.reset()}collectPayrailsData(){return t(this,void 0,void 0,function*(){var e;const t=yield null===(e=this.__container)||void 0===e?void 0:e.collect();return Object.assign(Object.assign({},t),{vaultProviderConfigId:Di().vaultConfiguration.providerConfigId})})}tokenize(e){return t(this,void 0,void 0,function*(){const t=yield this.collect(),i=Di().vaultConfiguration.links.saveInstrument.href,n=Di().token;if(!i){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND,{description:"Save instrument URL not available!"});throw o.PayrailsLogger.error(e.message,{error:e}),e}return(yield Oi({url:i,token:n,body:this.constructSaveInstrumentBody(t,e)})).res})}constructSaveInstrumentBody(e,t){var i,n;const s={holderReference:Di().holderReference,paymentMethod:"card",storeInstrument:null!==(i=null==t?void 0:t.storeInstrument)&&void 0!==i&&i,futureUsage:null!==(n=null==t?void 0:t.futureUsage)&&void 0!==n?n:"CardOnFile"};return s.data={encryptedData:e.encryptedData,vaultProviderConfigId:e.vaultProviderConfigId},s}attachCustomEventHandler(e){return new Proxy(e,{get:(e,t)=>{const i=e[t];if("on"===t){return((i,n)=>{e[t].call(e,i,t=>{"CHANGE"===i?(this.manualErrorElements.has(e)&&!t.isEmpty&&("resetError"in e&&"function"==typeof e.resetError&&e.resetError(),this.manualErrorElements.delete(e)),t.elementType===exports.ElementType.CARD_NUMBER&&(t.network=function(e){for(const[t,i]of Object.entries(Is))if(i.test(e))return t;return""}(t.value),t.bin=this.formatBin(t.value),this.bin=this.formatBin(t.value)),n(t)):n(t)})}).bind(e)}return"setError"===t?(...t)=>(this.manualErrorElements.add(e),i.apply(e,t)):"function"==typeof i?i.bind(e):i}})}formatBin(e){return e.replace(/[-X]/g,"").slice(0,8)}get elementToFieldMap(){return new Map([[exports.ElementType.CARD_NUMBER,"card_number"],[exports.ElementType.CARDHOLDER_NAME,"cardholder_name"],[exports.ElementType.CVV,"security_code"],[exports.ElementType.EXPIRATION_MONTH,"expiry_month"],[exports.ElementType.EXPIRATION_YEAR,"expiry_year"],[exports.ElementType.EXPIRATION_DATE,"expiry_date"]])}}const As=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;class Ls{static setSelectedInstrument(e){if(!e||!e.id.match(As))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Instrument is not valid"});this._selectedInstrument=e}static getSelectedInstrument(){return this._selectedInstrument}static clearSelectedInstrument(){this._selectedInstrument=null}}Ls._selectedInstrument=null;const Os={deleteInstrument:{linkKey:"instrumentDelete",method:_.DELETE,createRequest:e=>{var t,i;if(!e.resourceId)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_UNKNOWN_ERROR);const n=null===(i=null===(t=Di().links)||void 0===t?void 0:t.instrumentDelete)||void 0===i?void 0:i.href;if(!n)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND);return{url:e.resourceId?null==n?void 0:n.replace(":instrumentId",e.resourceId):n}},requestType:void 0,responseType:{}},updateInstrument:{linkKey:"instrumentUpdate",method:_.PATCH,createRequest:e=>{var t,i;const n=null===(i=null===(t=Di().links)||void 0===t?void 0:t.instrumentUpdate)||void 0===i?void 0:i.href;if(!n)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND);return{url:e.resourceId?null==n?void 0:n.replace(":instrumentId",e.resourceId):n,body:e.body}},requestType:{},responseType:{}},payout:{linkKey:"payout",method:_.POST,createRequest:()=>{const e=Pi.payoutLink;if(!e)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND);const t=Ls.getSelectedInstrument();if(!t)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_API_PAYOUT_NO_INSTRUMENT_SELECTED,{cause:new Error("No selected instrument for payout, set an instrument first using setState")});const i=[{integrationType:"api",amount:Di().amount,paymentMethodCode:t.paymentMethod,paymentInstrumentId:t.id}];return{url:e,body:{amount:Di().amount,payoutComposition:i}}},onSuccess:e=>t(void 0,void 0,void 0,function*(){const t=new xi;return yield t.pollForAuthorizationResult(e.links.execution)}),requestType:{},responseType:{}}},gs={holderReference:{path:["holderReference"],returnType:""},amount:{path:["amount"],returnType:{}},binLookup:{path:["links","binLookup"],returnType:{}},instrumentUpdate:{path:["links","instrumentUpdate"],returnType:{}},instrumentDelete:{path:["links","instrumentDelete"],returnType:{}},executionId:{path:["execution","id"],returnType:void 0},paymentMethodConfig:{path:[],returnType:{}},paymentMethodInstruments:{path:[],returnType:{}}};const Ts=(e,t)=>{try{const i=Di(),n=gs[e];if(!n)return o.PayrailsLogger.warn(`No query definition found for key: ${e}`),null;if("paymentMethodConfig"===e){const e=null==t?void 0:t.paymentMethodCode;return e?function(e){try{return e?Pi.availablePaymentMethods.find(({paymentMethodCode:t})=>t===e)||null:(o.PayrailsLogger.error("Payment method code is required"),null)}catch(t){return o.PayrailsLogger.error(`Error getting config for payment method: ${e}`,{error:t}),null}}(e):(o.PayrailsLogger.warn("Payment method code is required for paymentMethodConfig query"),null)}if("paymentMethodInstruments"===e){const e=null==t?void 0:t.paymentMethodCode;return e?function(e){return Pi.getStoredInstrumentForPaymentMethod(e)}(e):(o.PayrailsLogger.warn("Payment method code is required for paymentMethodInstruments query"),null)}const{path:s}=n;return function(e,t){if(!e||!t||!t.length)return;let i=e;for(const e of t){if(null==i)return;i=i[e]}return i}(i,s)||null}catch(e){return o.PayrailsLogger.error("Error querying SDK Configuration",{error:e}),null}},Cs=(e={})=>{const t=document.getElementById("sdk-observer");return t||(e=>{const t=document.createElement("iframe");t.id="sdk-observer";const i=new URLSearchParams(e).toString();return t.src=`https://assets.payrails.io/e38a94f/observability/index.html?${i}`,t.width="1px",t.height="1px",document.body.appendChild(t),t})(e)};
|
|
21
21
|
/* @copyright
|
|
22
22
|
Copyright (c) 2023 Payrails (https://www.payrails.com/)
|
|
23
23
|
*/
|
|
24
|
-
class Ts{static init(e,t){var i,n,r,a,l,d,c,u,p,_,h,E;try{const s="5.37.7",m="web-sdk";gs({version:s,packageName:m}),o.PayrailsLogger.init({enabled:(null===(i=null==t?void 0:t.telemetry)||void 0===i?void 0:i.enabled)||!0,logLevel:(null===(n=null==t?void 0:t.telemetry)||void 0===n?void 0:n.logLevel)||"error",environment:(null==t?void 0:t.environment)||"TEST",sdk:{name:m,version:s}}),bi(e);const v=Pi();o.PayrailsLogger.setState({payrails:{execution_id:null===(r=null==v?void 0:v.execution)||void 0===r?void 0:r.id,holder_reference:null==v?void 0:v.holderReference,vault_provider:null===(a=null==v?void 0:v.vaultConfiguration)||void 0===a?void 0:a.vaultType,merchant_reference:null===(l=null==v?void 0:v.execution)||void 0===l?void 0:l.merchantReference,workflow:{code:(null===(c=null===(d=null==v?void 0:v.execution)||void 0===d?void 0:d.workflow)||void 0===c?void 0:c.code)||"",version:(null===(p=null===(u=null==v?void 0:v.execution)||void 0===u?void 0:u.workflow)||void 0===p?void 0:p.version)||0}}});const{vaultConfiguration:{vaultId:y,vaultUrl:I,token:f},execution:A}=v;null===(_=v.vaultConfiguration)||void 0===_||_.vaultId;const L=fi.init({vaultID:y,vaultURL:I,getBearerToken:()=>f?Promise.resolve(f):Promise.resolve(""),options:{initResponse:e,deserializedData:Object.assign({},v),logLevel:(null===(E=null===(h=null==t?void 0:t.telemetry)||void 0===h?void 0:h.logLevel)||void 0===E?void 0:E.toUpperCase())||"ERROR"}});return A&&(Ni.setResponse(A),Ni.isPaymentMethodAvailable(exports.PAYMENT_METHOD_CODES.CARD)&&Xi.preloadCardForm()),new Ts(L,t)}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED,{cause:e});throw o.PayrailsLogger.error(t.message,{error:t}),t}}update(e){var t,i,n,s;Pi().amount={value:e.value,currency:e.currency};const o=e.installmentConfig;if(!o||0===Object.keys(o).length)return;const r=Ni.getPaymentInstallmentOptions(exports.PAYMENT_METHOD_CODES.CARD)||{},a=null===(t=o.installmentCountry)||void 0===t?void 0:t.toString();if(a&&Object.prototype.hasOwnProperty.call(o,"installmentOptions")){const e=Array.isArray(o.installmentOptions)?o.installmentOptions:[],t=Object.assign(Object.assign({},r),{[a]:e});Ni.updateInstallmentOptions(t)}const l={};Object.prototype.hasOwnProperty.call(o,"defaultInstallment")&&(l.defaultInstallment=null!==(i=o.defaultInstallment)&&void 0!==i?i:null),null===(n=this.__cardForm)||void 0===n||n.updateInstallmentConfig(l),null===(s=this.__dropin)||void 0===s||s.updateInstallmentConfig(l)}collectContainer(e){var t;if("COMPOSABLE"===e.containerType&&!e.layout){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw o.PayrailsLogger.error(e.message,{error:e}),e}return this.__container=ys.init(this.vaultClient,Object.assign(Object.assign({},e),{cardTableName:null===(t=Pi().vaultConfiguration)||void 0===t?void 0:t.cardTableName})),this.__container}googlePayButton(e){var t;return this.logIntegrationMode("elements"),new $n(Object.assign({environment:null===(t=this.options)||void 0===t?void 0:t.environment},e))}isGooglePayAvailable(e){var t;return $n.isGooglePayAvailable(Ni.googlePayConfig,null===(t=this.options)||void 0===t?void 0:t.environment,e)}applePayButton(e){return this.logIntegrationMode("elements"),new $i(e)}isApplePayAvailable(){return $i.isApplePayAvailable()}setState({instrument:e}){e&&fs.setSelectedInstrument(e)}cardList(e){return this.logIntegrationMode("elements"),this.__cardList||(this.__cardList=new Cn({onCardChange:t=>{this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=t,this.__cardPaymentButton.setDisabled(!1)),null==e||e.onCardChange(t)}})),this.__cardList}cardForm(e){var t,i;if(this.logIntegrationMode("elements"),!this.__cardForm){const n=this.getContainerLayout(null==e?void 0:e.showCardHolderName,null==e?void 0:e.showSingleExpiryDateField,null==e?void 0:e.layout);this.__container=this.collectContainer(Object.assign(Object.assign({layout:n,errorTextStyles:{base:{display:"none"}}},null===(t=null==e?void 0:e.styles)||void 0===t?void 0:t.errorTextStyles),{styles:{base:null===(i=null==e?void 0:e.styles)||void 0===i?void 0:i.base},fonts:null==e?void 0:e.fonts})),this.__cardForm=new In(this.__container,Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},null==e?void 0:e.events),{onChange:t=>{var i;if(this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=null,this.__cardForm)){const e=!!this.__cardPaymentButton.disabledByDefault&&!this.__cardForm.isValid;this.__cardPaymentButton.setDisabled(e)}(null===(i=null==e?void 0:e.events)||void 0===i?void 0:i.onChange)&&e.events.onChange(t)},onFocus:()=>{var t;if(this.__cardList&&this.__cardList.reset(),this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=null,this.__cardForm)){const e=!!this.__cardPaymentButton.disabledByDefault&&!this.__cardForm.isValid;this.__cardPaymentButton.setDisabled(e)}(null===(t=null==e?void 0:e.events)||void 0===t?void 0:t.onFocus)&&e.events.onFocus()}})}))}return this.__cardPaymentButton&&this.__cardPaymentButton.setCardForm(this.__cardForm),this.__cardForm}dropin(e){var t,i,n,s,o,r;this.logIntegrationMode("dropin");const a=this.getContainerLayout(null===(i=null===(t=e.paymentMethodsConfiguration)||void 0===t?void 0:t.cards)||void 0===i?void 0:i.showCardHolderName,null===(s=null===(n=e.paymentMethodsConfiguration)||void 0===n?void 0:n.cards)||void 0===s?void 0:s.showSingleExpiryDateField,null===(r=null===(o=e.paymentMethodsConfiguration)||void 0===o?void 0:o.cards)||void 0===r?void 0:r.layout);return this.__container=this.collectContainer({layout:a,errorTextStyles:{base:{display:"none"}}}),this.__dropin=new ts(this.__container,Object.assign({},this.options||{}),e),this.__dropin}getSavedCreditCards(){return this.logIntegrationMode("elements"),Ni.savedCreditCards}getSavedGooglePayAccounts(){return this.logIntegrationMode("elements"),Ni.savedGooglePayAccounts}getSavedApplePayAccounts(){return this.logIntegrationMode("elements"),Ni.savedApplePayAccounts}query(e,t){return this.logIntegrationMode("headless"),Os(e,t)}api(e){return t(this,void 0,void 0,function*(){return this.logIntegrationMode("headless"),(e=>t(void 0,void 0,void 0,function*(){const{operation:t}=e,i=Pi(),n=As[t];try{const t=n.createRequest(e),s=yield h(Object.assign({url:t.url,token:i.token,method:n.method},void 0!==t.body&&{body:t.body}));return n.onSuccess?yield n.onSuccess(s.res):s.res}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{cause:e});throw o.PayrailsLogger.error(t.message,{error:t}),t}}))(e)})}getStoredInstruments(){return this.logIntegrationMode("elements"),Ni.storedPaymentInstruments}getStoredInstrumentsByPaymentMethod(e){return this.logIntegrationMode("elements"),Ni.storedPaymentInstruments.filter(t=>t.paymentMethod===e)}getAvailablePaymentMethods(){return this.logIntegrationMode("elements"),Ni.availablePaymentMethods.map(({paymentMethodCode:e})=>e).filter(e=>!!e)}paymentButton(e){var t;return this.logIntegrationMode("elements"),this.__cardPaymentButton||(this.__cardPaymentButton=new Ms(e,(null===(t=this.options)||void 0===t?void 0:t.returnInfo)||{})),this.__cardPaymentButton.setDisabled(!!e.disabledByDefault),this.__cardForm&&this.__cardPaymentButton.setCardForm(this.__cardForm),this.__cardPaymentButton}paypalButton(e){return this.logIntegrationMode("elements"),this.__paypalButton=new Zn(Object.assign({},e)),this.__paypalButton}genericRedirectButton(e){return this.logIntegrationMode("elements"),this.__genericRedirectButton=new Xn(e,e.returnInfo),this.__genericRedirectButton}dynamicElement(e){var t;this.logIntegrationMode("elements");const i=Ni.getFullPaymentMethodConfig(e.paymentMethod.paymentMethodCode);if(!(null===(t=null==i?void 0:i.clientConfig)||void 0===t?void 0:t.instrumentDataSchema))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_MISSING_CONFIG,{description:`Form schema not found for payment method ${e.paymentMethod.paymentMethodCode}`});const n={schema:i.clientConfig.instrumentDataSchema};return this.__dynamicElementForm=new Es(e,n),this.__dynamicElementForm}getSavedPaypalAccounts(){return this.logIntegrationMode("elements"),Ni.savedPaypalAccounts||[]}logIntegrationMode(e){o.PayrailsLogger.setState({sdk:{integration_mode:e}})}constructor(e,i){var n,s,o;this.vaultClient=e,this.options=i,null===(s=null===(n=null==i?void 0:i.events)||void 0===n?void 0:n.onClientInitialized)||void 0===s||s.call(n,Ni),o=this.options||{},Oi=o,L.getEventBus().on("PAYRAILS_CLIENT_SESSION_EXPIRED",()=>t(this,void 0,void 0,function*(){var e;yield null==ms?void 0:ms(null===(e=this.options)||void 0===e?void 0:e.events)}))}getContainerLayout(e,t,i){const n=[];return i?i.forEach(e=>{n.push(e.length)}):(n.push(1),e&&n.push(1),t?n.push(2):n.push(3)),n}binLookup(){return t(this,void 0,void 0,function*(){var e,t;if(!this.__dropin&&!this.__cardForm&&!this.__container)return void console.warn("No container found");let i;return this.__dropin?i=yield this.__dropin.fetchBinLookup():this.__cardForm?i=yield null===(e=this.__cardForm)||void 0===e?void 0:e.fetchBinLookup():this.__container&&(i=yield null===(t=this.__container)||void 0===t?void 0:t.fetchBinLookup(this.__container.bin)),i})}}var Cs,Rs;Ts.preloadCardForm=Xi.preloadCardForm,function(e){e.AUTHORIZE="AUTHORIZE",e.TOKENIZE="TOKENIZE"}(Cs||(Cs={})),exports.PayrailsEnvironment=void 0,(Rs=exports.PayrailsEnvironment||(exports.PayrailsEnvironment={})).TEST="TEST",Rs.PRODUCTION="PRODUCTION";const Ns=(e,t,i)=>{var n;(null==t?void 0:t.onAuthorizeSuccess)&&e===Cs.AUTHORIZE&&(console.warn("onAuthorizeSuccess is marked as deprecated and will be removed in future releases. Use `onSuccess` instead."),t.onAuthorizeSuccess(i)),null===(n=null==t?void 0:t.onSuccess)||void 0===n||n.call(t,e,i)},Ss=(e,t,i)=>{var n;(null==t?void 0:t.onAuthorizeFailed)&&e===Cs.AUTHORIZE&&(console.warn("onAuthorizeFailed is marked as deprecated and will be removed in future releases. Use `onFailed` instead."),t.onAuthorizeFailed(i)),null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e,i)},Ps=(e,i)=>t(void 0,void 0,void 0,function*(){if(!i)return Promise.resolve(!0);i.onAuthorizeRequestStart&&e===Cs.AUTHORIZE&&console.warn("onAuthorizeRequestStart is marked as deprecated and will be removed in future releases. Use `onRequestStart` instead.");const t="function"==typeof i.onAuthorizeRequestStart&&e===Cs.AUTHORIZE?i.onAuthorizeRequestStart():Promise.resolve(!0),n="function"==typeof i.onRequestStart?i.onRequestStart(e):Promise.resolve(!0);return Promise.all([t,n]).then(e=>e.every(e=>!0===e))}),bs=(e,t,i)=>{var n;(null==t?void 0:t.onAuthorizePending)&&e===Cs.AUTHORIZE&&(console.warn("onAuthorizePending is marked as deprecated and will be removed in future releases. Use `onPending` instead."),t.onAuthorizePending(i)),null===(n=null==t?void 0:t.onPending)||void 0===n||n.call(t,e,i)},Ds=(e,i,n)=>t(void 0,void 0,void 0,function*(){try{const o=yield((e,i,n)=>t(void 0,void 0,void 0,function*(){if(!i)return Promise.resolve(!0);i.onPaymentButtonClicked&&console.warn("onPaymentButtonClicked is marked as deprecated and will be removed in future releases. Use `onButtonClicked` instead.");const t="function"==typeof i.onPaymentButtonClicked&&e===Cs.AUTHORIZE?i.onPaymentButtonClicked(n):Promise.resolve(!0),s="function"==typeof i.onButtonClicked?i.onButtonClicked(e,n):Promise.resolve(!0);return Promise.all([t,s]).then(e=>e.every(e=>!0===e))}))(e,i,n);if(!o){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onButtonClicked resolved to false"});return Ss(e,i,{code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:t.message}),o}}catch(t){const n=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onButtonClicked threw an error",cause:t});return Ss(e,i,{code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:n.message}),!1}return!0});class Ms extends Hi{get bin(){var e;return this.selectedInstrument?this.selectedInstrument.data.bin?this.selectedInstrument.data.bin:"":(null===(e=this.cardForm)||void 0===e?void 0:e.bin)||""}constructor(e,t){var i;super("button",{id:"payrails-card-payment-button"}),this.options=e,this.returnInfo=t,this.selectedInstrument=null,this.paymentInstallmentElement=null,this.isLoading=!1,this.disabledByDefault=!0,this.element.innerText=(null===(i=null==e?void 0:e.translations)||void 0===i?void 0:i.label)||"Pay",this.disabledByDefault="boolean"!=typeof e.disabledByDefault||e.disabledByDefault,this.setDisabled(this.disabledByDefault),this.element.addEventListener("click",this.onPay.bind(this)),this.element.addEventListener("mouseenter",()=>{var e;this.element.classList.contains("disabled")||(this.element.classList.add("hover"),this.setStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{}))}),this.element.addEventListener("mouseleave",()=>{var e;this.element.classList.contains("disabled")||(this.element.classList.remove("hover"),this.removeStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{}))}),this.paymentExecutor=new Yi(this.returnInfo)}setDisabled(e){var t,i,n,s,o;this.element.classList.contains("disabled")!==e&&(null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onStateChanged)||void 0===i||i.call(t,e?"disabled":"enabled")),this.element.disabled=e,e?(this.element.classList.add("disabled"),(null===(n=this.options.styles)||void 0===n?void 0:n.disabled)&&this.setStyles(this.options.styles.disabled)):(this.element.classList.remove("disabled"),this.removeStyles((null===(s=this.options.styles)||void 0===s?void 0:s.disabled)||{}),(null===(o=this.options.styles)||void 0===o?void 0:o.base)&&this.setStyles(this.options.styles.base))}setSavedCreditCard(e){console.warn("setSavedCreditCard is deprecated, please use setSavedInstrument"),this.setSavedInstrument(e)}setSavedInstrument(e){this.selectedInstrument=e,this.setDisabled(!1)}setStyles(e){var t;const i=Object.assign(Object.assign({},null===(t=this.options.styles)||void 0===t?void 0:t.base),e);Object.keys(i).forEach(e=>{this.element.style[e]=i[e]})}removeStyles(e){var t;const i=Object.keys((null===(t=this.options.styles)||void 0===t?void 0:t.base)||{});Object.keys(e).forEach(e=>{var t,n;i.includes(e)?this.element.style[e]=null===(n=null===(t=this.options.styles)||void 0===t?void 0:t.base)||void 0===n?void 0:n[e]:this.element.style[e]=""})}setLabel(e){this.element.innerText=e}setCardForm(e){this.cardForm=e}setPaymentInstallmentsDropdown(e){this.paymentInstallmentElement=e}triggerLoading(e){var t,i,n,s;const o=this.element.offsetWidth;this.element.style.minWidth=`${o}px`,this.isLoading=e,e?(this.element.innerHTML='<div class="dot-flashing"></div>',this.element.classList.add("loading"),(null===(t=this.options.styles)||void 0===t?void 0:t.loading)&&this.setStyles(this.options.styles.loading)):(this.element.innerText=(null===(n=null===(i=this.options)||void 0===i?void 0:i.translations)||void 0===n?void 0:n.label)||"Pay",this.element.classList.remove("loading"),this.removeStyles((null===(s=this.options.styles)||void 0===s?void 0:s.loading)||{}))}onAuthorizationFailed(e){this.setDisabled(!1),this.triggerLoading(!1),Ss(Cs.AUTHORIZE,this.options.events,e)}onPay(){return t(this,void 0,void 0,function*(){var e,t,i,n,r,a,l,d,c,u,p,_,h;let m;if(this.setDisabled(!0),this.triggerLoading(!0),!(null===(e=this.selectedInstrument)||void 0===e?void 0:e.id)&&(m=null===(i=yield null===(t=this.cardForm)||void 0===t?void 0:t.validate())||void 0===i?void 0:i.isValid,!m))return this.setDisabled(!1),void this.triggerLoading(!1);if(m=yield Ds(Cs.AUTHORIZE,this.options.events,{bin:this.bin||""}),!m)return this.setDisabled(!1),void this.triggerLoading(!1);try{let e=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.CARD,integrationType:"api",amount:Pi().amount,storeInstrument:!1}];if(null===(n=this.selectedInstrument)||void 0===n?void 0:n.id)e[0].paymentInstrumentId=null===(r=this.selectedInstrument)||void 0===r?void 0:r.id,e[0].paymentMethodCode=null===(a=this.selectedInstrument)||void 0===a?void 0:a.paymentMethod,this.paymentInstallmentElement&&(null===(l=this.paymentInstallmentElement)||void 0===l?void 0:l.selectedInstallmentValue)&&(e[0].installments={count:null===(d=this.paymentInstallmentElement)||void 0===d?void 0:d.selectedInstallmentValue});else{if(!this.cardForm){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CARD_FORM_MISSING);throw o.PayrailsLogger.error(e.message,{error:e}),e}e=yield this.constructEncryptedPayment(e)}const t=yield this.paymentExecutor.pay(e);this.handleAuthorizationResult(t)}catch(e){let t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_AUTHENTICATION_ERROR,{cause:e});e instanceof E||[401,403].includes(null===(c=null==e?void 0:e.error)||void 0===c?void 0:c.code)?(null===(p=null===(u=this.options.events)||void 0===u?void 0:u.onPaymentSessionExpired)||void 0===p||p.call(u),t.message="API token is not valid or expired.",o.PayrailsLogger.error(t.message,{error:t}),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:t.message})):e.toString().includes("Invalid token")?(null===(h=null===(_=this.options.events)||void 0===_?void 0:_.onPaymentSessionExpired)||void 0===h||h.call(_),t.message="Vault token is not valid or expired.",o.PayrailsLogger.error(t.message,{error:t})):t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_UNKNOWN_ERROR,{cause:e}),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:t.message})}})}constructEncryptedPayment(e){return t(this,void 0,void 0,function*(){if(!this.cardForm)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CARD_FORM_MISSING);const{cardData:t,storeInstrument:i,enrollInstrumentToNetworkOffers:n,selectedInstallment:o,billingInfo:r}=yield this.cardForm.collectValues();return e[0].paymentInstrumentData=Object.assign(Object.assign({},t),{billingAddress:r}),e[0].storeInstrument=i,e[0].enrollInstrumentToNetworkOffers=n,o&&(e[0].installments={count:o}),e})}updateStyles(e){this.options.styles&&(this.options.styles=Object.assign(Object.assign({},this.options.styles),e)),this.isLoading?this.setStyles((null==e?void 0:e.loading)||{}):this.setStyles((null==e?void 0:e.base)||{})}updateTranslations(e){this.options.translations&&(this.options.translations=Object.assign(Object.assign({},this.options.translations),e)),(null==e?void 0:e.label)&&this.setLabel(e.label)}updateEvents(e){this.options.events&&(this.options.events=Object.assign(Object.assign({},this.options.events),e))}update(e){e.styles&&this.updateStyles(e.styles),e.translations&&this.updateTranslations(e.translations),e.events&&this.updateEvents(e.events)}handleAuthorizationResult(e){var t,i,n,o,r,a,l;let d;switch(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code){case"authorizeSuccessful":this.triggerLoading(!1),Ns(Cs.AUTHORIZE,this.options.events);break;case"authorizePending":if("3ds"===(null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.actionRequired)){new qn(Object.assign(Object.assign({},this.options),{events:Object.assign(Object.assign({},this.options.events),{onAuthorizeFailed:e=>{this.onAuthorizationFailed(e)}})}),this.paymentExecutor).handle3ds(e)}else(null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.actionRequired)||(this.triggerLoading(!1),bs(Cs.AUTHORIZE,this.options.events));break;default:d=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_ERROR),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:(null===(l=null===(a=null===(r=null===(o=e.finalState)||void 0===o?void 0:o.errors)||void 0===r?void 0:r[0])||void 0===a?void 0:a.reason)||void 0===l?void 0:l.result)||d.message})}}}var ws;exports.AuthorizationFailureReasons=void 0,(ws=exports.AuthorizationFailureReasons||(exports.AuthorizationFailureReasons={})).VALIDATION_FAILED="VALIDATION_FAILED",ws.AUTHORIZATION_ERROR="AUTHORIZATION_ERROR",ws.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",ws.UNKNOWN_ERROR="UNKNOWN_ERROR",ws.USER_CANCELLED="USER_CANCELLED",exports.Payrails=Ts}();
|
|
24
|
+
class Rs{static init(e,t){var i,n,r,a,l,d,c,u,p,_,h,E;try{const s="5.37.9-RC.0",m="web-sdk";Cs({version:s,packageName:m}),o.PayrailsLogger.init({enabled:(null===(i=null==t?void 0:t.telemetry)||void 0===i?void 0:i.enabled)||!0,logLevel:(null===(n=null==t?void 0:t.telemetry)||void 0===n?void 0:n.logLevel)||"error",environment:(null==t?void 0:t.environment)||"TEST",sdk:{name:m,version:s}}),Mi(e);const v=Di();o.PayrailsLogger.setState({payrails:{execution_id:null===(r=null==v?void 0:v.execution)||void 0===r?void 0:r.id,holder_reference:null==v?void 0:v.holderReference,vault_provider:null===(a=null==v?void 0:v.vaultConfiguration)||void 0===a?void 0:a.vaultType,merchant_reference:null===(l=null==v?void 0:v.execution)||void 0===l?void 0:l.merchantReference,workflow:{code:(null===(c=null===(d=null==v?void 0:v.execution)||void 0===d?void 0:d.workflow)||void 0===c?void 0:c.code)||"",version:(null===(p=null===(u=null==v?void 0:v.execution)||void 0===u?void 0:u.workflow)||void 0===p?void 0:p.version)||0}}});const{vaultConfiguration:{vaultId:y,vaultUrl:I,token:f},execution:A}=v;null===(_=v.vaultConfiguration)||void 0===_||_.vaultId;const L=Li.init({vaultID:y,vaultURL:I,getBearerToken:()=>f?Promise.resolve(f):Promise.resolve(""),options:{initResponse:e,deserializedData:Object.assign({},v),logLevel:(null===(E=null===(h=null==t?void 0:t.telemetry)||void 0===h?void 0:h.logLevel)||void 0===E?void 0:E.toUpperCase())||"ERROR"}});return A&&(Pi.setResponse(A),Pi.isPaymentMethodAvailable(exports.PAYMENT_METHOD_CODES.CARD)&&Hi.preloadCardForm()),new Rs(L,t)}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED,{cause:e});throw o.PayrailsLogger.error(t.message,{error:t}),t}}update(e){var t,i,n,s;Di().amount={value:e.value,currency:e.currency};const o=e.installmentConfig;if(!o||0===Object.keys(o).length)return;const r=Pi.getPaymentInstallmentOptions(exports.PAYMENT_METHOD_CODES.CARD)||{},a=null===(t=o.installmentCountry)||void 0===t?void 0:t.toString();if(a&&Object.prototype.hasOwnProperty.call(o,"installmentOptions")){const e=Array.isArray(o.installmentOptions)?o.installmentOptions:[],t=Object.assign(Object.assign({},r),{[a]:e});Pi.updateInstallmentOptions(t)}const l={};Object.prototype.hasOwnProperty.call(o,"defaultInstallment")&&(l.defaultInstallment=null!==(i=o.defaultInstallment)&&void 0!==i?i:null),null===(n=this.__cardForm)||void 0===n||n.updateInstallmentConfig(l),null===(s=this.__dropin)||void 0===s||s.updateInstallmentConfig(l)}collectContainer(e){var t;if("COMPOSABLE"===e.containerType&&!e.layout){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw o.PayrailsLogger.error(e.message,{error:e}),e}return this.__container=fs.init(this.vaultClient,Object.assign(Object.assign({},e),{cardTableName:null===(t=Di().vaultConfiguration)||void 0===t?void 0:t.cardTableName})),this.__container}googlePayButton(e){var t;return this.logIntegrationMode("elements"),new Zn(Object.assign({environment:null===(t=this.options)||void 0===t?void 0:t.environment},e))}isGooglePayAvailable(e){var t;return Zn.isGooglePayAvailable(Pi.googlePayConfig,null===(t=this.options)||void 0===t?void 0:t.environment,e)}applePayButton(e){return this.logIntegrationMode("elements"),new Zi(e)}isApplePayAvailable(){return Zi.isApplePayAvailable()}setState({instrument:e}){e&&Ls.setSelectedInstrument(e)}cardList(e){return this.logIntegrationMode("elements"),this.__cardList||(this.__cardList=new Nn({onCardChange:t=>{this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=t,this.__cardPaymentButton.setDisabled(!1)),null==e||e.onCardChange(t)}})),this.__cardList}cardForm(e){var t,i;if(this.logIntegrationMode("elements"),!this.__cardForm){const n=this.getContainerLayout(null==e?void 0:e.showCardHolderName,null==e?void 0:e.showSingleExpiryDateField,null==e?void 0:e.layout);this.__container=this.collectContainer(Object.assign(Object.assign({layout:n,errorTextStyles:{base:{display:"none"}}},null===(t=null==e?void 0:e.styles)||void 0===t?void 0:t.errorTextStyles),{styles:{base:null===(i=null==e?void 0:e.styles)||void 0===i?void 0:i.base},fonts:null==e?void 0:e.fonts})),this.__cardForm=new An(this.__container,Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},null==e?void 0:e.events),{onChange:t=>{var i;if(this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=null,this.__cardForm)){const e=!!this.__cardPaymentButton.disabledByDefault&&!this.__cardForm.isValid;this.__cardPaymentButton.setDisabled(e)}(null===(i=null==e?void 0:e.events)||void 0===i?void 0:i.onChange)&&e.events.onChange(t)},onFocus:()=>{var t;if(this.__cardList&&this.__cardList.reset(),this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=null,this.__cardForm)){const e=!!this.__cardPaymentButton.disabledByDefault&&!this.__cardForm.isValid;this.__cardPaymentButton.setDisabled(e)}(null===(t=null==e?void 0:e.events)||void 0===t?void 0:t.onFocus)&&e.events.onFocus()}})}))}return this.__cardPaymentButton&&this.__cardPaymentButton.setCardForm(this.__cardForm),this.__cardForm}dropin(e){var t,i,n,s,o,r;this.logIntegrationMode("dropin");const a=this.getContainerLayout(null===(i=null===(t=e.paymentMethodsConfiguration)||void 0===t?void 0:t.cards)||void 0===i?void 0:i.showCardHolderName,null===(s=null===(n=e.paymentMethodsConfiguration)||void 0===n?void 0:n.cards)||void 0===s?void 0:s.showSingleExpiryDateField,null===(r=null===(o=e.paymentMethodsConfiguration)||void 0===o?void 0:o.cards)||void 0===r?void 0:r.layout);return this.__container=this.collectContainer({layout:a,errorTextStyles:{base:{display:"none"}}}),this.__dropin=new ns(this.__container,Object.assign({},this.options||{}),e),this.__dropin}getSavedCreditCards(){return this.logIntegrationMode("elements"),Pi.savedCreditCards}getSavedGooglePayAccounts(){return this.logIntegrationMode("elements"),Pi.savedGooglePayAccounts}getSavedApplePayAccounts(){return this.logIntegrationMode("elements"),Pi.savedApplePayAccounts}query(e,t){return this.logIntegrationMode("headless"),Ts(e,t)}api(e){return t(this,void 0,void 0,function*(){return this.logIntegrationMode("headless"),(e=>t(void 0,void 0,void 0,function*(){const{operation:t}=e,i=Di(),n=Os[t];try{const t=n.createRequest(e),s=yield h(Object.assign({url:t.url,token:i.token,method:n.method},void 0!==t.body&&{body:t.body}));return n.onSuccess?yield n.onSuccess(s.res):s.res}catch(e){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{cause:e});throw o.PayrailsLogger.error(t.message,{error:t}),t}}))(e)})}getStoredInstruments(){return this.logIntegrationMode("elements"),Pi.storedPaymentInstruments}getStoredInstrumentsByPaymentMethod(e){return this.logIntegrationMode("elements"),Pi.storedPaymentInstruments.filter(t=>t.paymentMethod===e)}getAvailablePaymentMethods(){return this.logIntegrationMode("elements"),Pi.availablePaymentMethods.map(({paymentMethodCode:e})=>e).filter(e=>!!e)}paymentButton(e){var t;return this.logIntegrationMode("elements"),this.__cardPaymentButton||(this.__cardPaymentButton=new ks(e,(null===(t=this.options)||void 0===t?void 0:t.returnInfo)||{})),this.__cardPaymentButton.setDisabled(!!e.disabledByDefault),this.__cardForm&&this.__cardPaymentButton.setCardForm(this.__cardForm),this.__cardPaymentButton}paypalButton(e){return this.logIntegrationMode("elements"),this.__paypalButton=new Qn(Object.assign({},e)),this.__paypalButton}genericRedirectButton(e){return this.logIntegrationMode("elements"),this.__genericRedirectButton=new Hn(e,e.returnInfo),this.__genericRedirectButton}dynamicElement(e){var t;this.logIntegrationMode("elements");const i=Pi.getFullPaymentMethodConfig(e.paymentMethod.paymentMethodCode);if(!(null===(t=null==i?void 0:i.clientConfig)||void 0===t?void 0:t.instrumentDataSchema))throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_MISSING_CONFIG,{description:`Form schema not found for payment method ${e.paymentMethod.paymentMethodCode}`});const n={schema:i.clientConfig.instrumentDataSchema};return this.__dynamicElementForm=new vs(e,n),this.__dynamicElementForm}getSavedPaypalAccounts(){return this.logIntegrationMode("elements"),Pi.savedPaypalAccounts||[]}logIntegrationMode(e){o.PayrailsLogger.setState({sdk:{integration_mode:e}})}constructor(e,i){var n,s,o;this.vaultClient=e,this.options=i,null===(s=null===(n=null==i?void 0:i.events)||void 0===n?void 0:n.onClientInitialized)||void 0===s||s.call(n,Pi),o=this.options||{},Ti=o,L.getEventBus().on("PAYRAILS_CLIENT_SESSION_EXPIRED",()=>t(this,void 0,void 0,function*(){var e;yield null==ys?void 0:ys(null===(e=this.options)||void 0===e?void 0:e.events)}))}getContainerLayout(e,t,i){const n=[];return i?i.forEach(e=>{n.push(e.length)}):(n.push(1),e&&n.push(1),t?n.push(2):n.push(3)),n}binLookup(){return t(this,void 0,void 0,function*(){var e,t;if(!this.__dropin&&!this.__cardForm&&!this.__container)return void console.warn("No container found");let i;return this.__dropin?i=yield this.__dropin.fetchBinLookup():this.__cardForm?i=yield null===(e=this.__cardForm)||void 0===e?void 0:e.fetchBinLookup():this.__container&&(i=yield null===(t=this.__container)||void 0===t?void 0:t.fetchBinLookup(this.__container.bin)),i})}}var Ns,Ss;Rs.preloadCardForm=Hi.preloadCardForm,function(e){e.AUTHORIZE="AUTHORIZE",e.TOKENIZE="TOKENIZE"}(Ns||(Ns={})),exports.PayrailsEnvironment=void 0,(Ss=exports.PayrailsEnvironment||(exports.PayrailsEnvironment={})).TEST="TEST",Ss.PRODUCTION="PRODUCTION";const Ps=(e,t,i)=>{var n;(null==t?void 0:t.onAuthorizeSuccess)&&e===Ns.AUTHORIZE&&(console.warn("onAuthorizeSuccess is marked as deprecated and will be removed in future releases. Use `onSuccess` instead."),t.onAuthorizeSuccess(i)),null===(n=null==t?void 0:t.onSuccess)||void 0===n||n.call(t,e,i)},bs=(e,t,i)=>{var n;(null==t?void 0:t.onAuthorizeFailed)&&e===Ns.AUTHORIZE&&(console.warn("onAuthorizeFailed is marked as deprecated and will be removed in future releases. Use `onFailed` instead."),t.onAuthorizeFailed(i)),null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e,i)},Ds=(e,i)=>t(void 0,void 0,void 0,function*(){if(!i)return Promise.resolve(!0);i.onAuthorizeRequestStart&&e===Ns.AUTHORIZE&&console.warn("onAuthorizeRequestStart is marked as deprecated and will be removed in future releases. Use `onRequestStart` instead.");const t="function"==typeof i.onAuthorizeRequestStart&&e===Ns.AUTHORIZE?i.onAuthorizeRequestStart():Promise.resolve(!0),n="function"==typeof i.onRequestStart?i.onRequestStart(e):Promise.resolve(!0);return Promise.all([t,n]).then(e=>e.every(e=>!0===e))}),Ms=(e,t,i)=>{var n;(null==t?void 0:t.onAuthorizePending)&&e===Ns.AUTHORIZE&&(console.warn("onAuthorizePending is marked as deprecated and will be removed in future releases. Use `onPending` instead."),t.onAuthorizePending(i)),null===(n=null==t?void 0:t.onPending)||void 0===n||n.call(t,e,i)},ws=(e,i,n)=>t(void 0,void 0,void 0,function*(){try{const o=yield((e,i,n)=>t(void 0,void 0,void 0,function*(){if(!i)return Promise.resolve(!0);i.onPaymentButtonClicked&&console.warn("onPaymentButtonClicked is marked as deprecated and will be removed in future releases. Use `onButtonClicked` instead.");const t="function"==typeof i.onPaymentButtonClicked&&e===Ns.AUTHORIZE?i.onPaymentButtonClicked(n):Promise.resolve(!0),s="function"==typeof i.onButtonClicked?i.onButtonClicked(e,n):Promise.resolve(!0);return Promise.all([t,s]).then(e=>e.every(e=>!0===e))}))(e,i,n);if(!o){const t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onButtonClicked resolved to false"});return bs(e,i,{code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:t.message}),o}}catch(t){const n=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onButtonClicked threw an error",cause:t});return bs(e,i,{code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:n.message}),!1}return!0});class ks extends Wi{get bin(){var e;return this.selectedInstrument?this.selectedInstrument.data.bin?this.selectedInstrument.data.bin:"":(null===(e=this.cardForm)||void 0===e?void 0:e.bin)||""}constructor(e,t){var i;super("button",{id:"payrails-card-payment-button"}),this.options=e,this.returnInfo=t,this.selectedInstrument=null,this.paymentInstallmentElement=null,this.isLoading=!1,this.disabledByDefault=!0,this.element.innerText=(null===(i=null==e?void 0:e.translations)||void 0===i?void 0:i.label)||"Pay",this.disabledByDefault="boolean"!=typeof e.disabledByDefault||e.disabledByDefault,this.setDisabled(this.disabledByDefault),this.element.addEventListener("click",this.onPay.bind(this)),this.element.addEventListener("mouseenter",()=>{var e;this.element.classList.contains("disabled")||(this.element.classList.add("hover"),this.setStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{}))}),this.element.addEventListener("mouseleave",()=>{var e;this.element.classList.contains("disabled")||(this.element.classList.remove("hover"),this.removeStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{}))}),this.paymentExecutor=new xi(this.returnInfo)}setDisabled(e){var t,i,n,s,o;this.element.classList.contains("disabled")!==e&&(null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onStateChanged)||void 0===i||i.call(t,e?"disabled":"enabled")),this.element.disabled=e,e?(this.element.classList.add("disabled"),(null===(n=this.options.styles)||void 0===n?void 0:n.disabled)&&this.setStyles(this.options.styles.disabled)):(this.element.classList.remove("disabled"),this.removeStyles((null===(s=this.options.styles)||void 0===s?void 0:s.disabled)||{}),(null===(o=this.options.styles)||void 0===o?void 0:o.base)&&this.setStyles(this.options.styles.base))}setSavedCreditCard(e){console.warn("setSavedCreditCard is deprecated, please use setSavedInstrument"),this.setSavedInstrument(e)}setSavedInstrument(e){this.selectedInstrument=e,this.setDisabled(!1)}setStyles(e){var t;const i=Object.assign(Object.assign({},null===(t=this.options.styles)||void 0===t?void 0:t.base),e);Object.keys(i).forEach(e=>{this.element.style[e]=i[e]})}removeStyles(e){var t;const i=Object.keys((null===(t=this.options.styles)||void 0===t?void 0:t.base)||{});Object.keys(e).forEach(e=>{var t,n;i.includes(e)?this.element.style[e]=null===(n=null===(t=this.options.styles)||void 0===t?void 0:t.base)||void 0===n?void 0:n[e]:this.element.style[e]=""})}setLabel(e){this.element.innerText=e}setCardForm(e){this.cardForm=e}setPaymentInstallmentsDropdown(e){this.paymentInstallmentElement=e}triggerLoading(e){var t,i,n,s;const o=this.element.offsetWidth;this.element.style.minWidth=`${o}px`,this.isLoading=e,e?(this.element.innerHTML='<div class="dot-flashing"></div>',this.element.classList.add("loading"),(null===(t=this.options.styles)||void 0===t?void 0:t.loading)&&this.setStyles(this.options.styles.loading)):(this.element.innerText=(null===(n=null===(i=this.options)||void 0===i?void 0:i.translations)||void 0===n?void 0:n.label)||"Pay",this.element.classList.remove("loading"),this.removeStyles((null===(s=this.options.styles)||void 0===s?void 0:s.loading)||{}))}onAuthorizationFailed(e){this.setDisabled(!1),this.triggerLoading(!1),bs(Ns.AUTHORIZE,this.options.events,e)}onPay(){return t(this,void 0,void 0,function*(){var e,t,i,n,r,a,l,d,c,u,p,_,h,m;let v;if(this.setDisabled(!0),this.triggerLoading(!0),!(null===(e=this.selectedInstrument)||void 0===e?void 0:e.id)){const e=yield null===(t=this.cardForm)||void 0===t?void 0:t.validate();if(v=!!(null==e?void 0:e.isValid),null===(n=null===(i=this.options.events)||void 0===i?void 0:i.onValidate)||void 0===n||n.call(i,{isValid:!!v,error:null==e?void 0:e.error,fieldErrors:null==e?void 0:e.fieldErrors}),!v)return this.setDisabled(!1),void this.triggerLoading(!1)}if(v=yield ws(Ns.AUTHORIZE,this.options.events,{bin:this.bin||""}),!v)return this.setDisabled(!1),void this.triggerLoading(!1);try{let e=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.CARD,integrationType:"api",amount:Di().amount,storeInstrument:!1}];if(null===(r=this.selectedInstrument)||void 0===r?void 0:r.id)e[0].paymentInstrumentId=null===(a=this.selectedInstrument)||void 0===a?void 0:a.id,e[0].paymentMethodCode=null===(l=this.selectedInstrument)||void 0===l?void 0:l.paymentMethod,this.paymentInstallmentElement&&(null===(d=this.paymentInstallmentElement)||void 0===d?void 0:d.selectedInstallmentValue)&&(e[0].installments={count:null===(c=this.paymentInstallmentElement)||void 0===c?void 0:c.selectedInstallmentValue});else{if(!this.cardForm){const e=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CARD_FORM_MISSING);throw o.PayrailsLogger.error(e.message,{error:e}),e}e=yield this.constructEncryptedPayment(e)}const t=yield this.paymentExecutor.pay(e);this.handleAuthorizationResult(t)}catch(e){let t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_AUTHENTICATION_ERROR,{cause:e});e instanceof E||[401,403].includes(null===(u=null==e?void 0:e.error)||void 0===u?void 0:u.code)?(null===(_=null===(p=this.options.events)||void 0===p?void 0:p.onPaymentSessionExpired)||void 0===_||_.call(p),t.message="API token is not valid or expired.",o.PayrailsLogger.error(t.message,{error:t}),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:t.message})):e.toString().includes("Invalid token")?(null===(m=null===(h=this.options.events)||void 0===h?void 0:h.onPaymentSessionExpired)||void 0===m||m.call(h),t.message="Vault token is not valid or expired.",o.PayrailsLogger.error(t.message,{error:t})):t=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_UNKNOWN_ERROR,{cause:e}),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:t.message})}})}constructEncryptedPayment(e){return t(this,void 0,void 0,function*(){if(!this.cardForm)throw new s.PayrailsError(s.ERROR_CODES.PAYRAILS_CLIENT_CARD_FORM_MISSING);const{cardData:t,storeInstrument:i,enrollInstrumentToNetworkOffers:n,selectedInstallment:o,billingInfo:r}=yield this.cardForm.collectValues();return e[0].paymentInstrumentData=Object.assign(Object.assign({},t),{billingAddress:r}),e[0].storeInstrument=i,e[0].enrollInstrumentToNetworkOffers=n,o&&(e[0].installments={count:o}),e})}updateStyles(e){this.options.styles&&(this.options.styles=Object.assign(Object.assign({},this.options.styles),e)),this.isLoading?this.setStyles((null==e?void 0:e.loading)||{}):this.setStyles((null==e?void 0:e.base)||{})}updateTranslations(e){this.options.translations&&(this.options.translations=Object.assign(Object.assign({},this.options.translations),e)),(null==e?void 0:e.label)&&this.setLabel(e.label)}updateEvents(e){this.options.events&&(this.options.events=Object.assign(Object.assign({},this.options.events),e))}update(e){e.styles&&this.updateStyles(e.styles),e.translations&&this.updateTranslations(e.translations),e.events&&this.updateEvents(e.events)}handleAuthorizationResult(e){var t,i,n,o,r,a,l;let d;switch(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code){case"authorizeSuccessful":this.triggerLoading(!1),Ps(Ns.AUTHORIZE,this.options.events);break;case"authorizePending":if("3ds"===(null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.actionRequired)){new Kn(Object.assign(Object.assign({},this.options),{events:Object.assign(Object.assign({},this.options.events),{onAuthorizeFailed:e=>{this.onAuthorizationFailed(e)}})}),this.paymentExecutor).handle3ds(e)}else(null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.actionRequired)||(this.triggerLoading(!1),Ms(Ns.AUTHORIZE,this.options.events));break;default:d=new s.PayrailsError(s.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_ERROR),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:(null===(l=null===(a=null===(r=null===(o=e.finalState)||void 0===o?void 0:o.errors)||void 0===r?void 0:r[0])||void 0===a?void 0:a.reason)||void 0===l?void 0:l.result)||d.message})}}}var Ys;exports.AuthorizationFailureReasons=void 0,(Ys=exports.AuthorizationFailureReasons||(exports.AuthorizationFailureReasons={})).VALIDATION_FAILED="VALIDATION_FAILED",Ys.AUTHORIZATION_ERROR="AUTHORIZATION_ERROR",Ys.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",Ys.UNKNOWN_ERROR="UNKNOWN_ERROR",Ys.USER_CANCELLED="USER_CANCELLED",exports.Payrails=Rs}();
|