@payrails/web-sdk 5.47.0 → 5.47.1

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/payrails.js CHANGED
@@ -1,7 +1,7 @@
1
- !function(e){"use strict";function t(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 i(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 n(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 s(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}"function"==typeof SuppressedError&&SuppressedError;var o={};!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_APPLEPAY_MERCHANT_VALIDATION_FAILED="payrails:client:init.applepay_merchant_validation_failed",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:client:init.applepay_merchant_validation_failed":{description:"Apple pay merchant validation failed",docUrl:"https://docs.payrails.com/docs/apple-pay#pre-requisites"},"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}(o);var r={};!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_APPLEPAY_MERCHANT_VALIDATION_FAILED="payrails:client:init.applepay_merchant_validation_failed",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,h,p,_,E,m,v,y,I,f,A,L,g,O,T={},C={},R={},N={},S={},P={},b={},D={},M={},w={},k={},Y={},U={};function F(){if(A)return U;A=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 x(){if(O)return Y;O=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=F(),i=e((g||(g=1,L=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)})}),L));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,V,G,X,z,H={},q={},W={};function K(){return G||(G=1,function(e){var t=T&&T.__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=T&&T.__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 C;u=1,Object.defineProperty(C,"__esModule",{value:!0}),C.detach=C.attach=void 0;var e=K(),t=!1;return C.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},C.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},C}(),e),i(function(){if(h)return R;h=1,Object.defineProperty(R,"__esModule",{value:!0}),R.broadcastToChildWindows=void 0;var e=K();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),i(function(){if(p)return N;p=1,Object.defineProperty(N,"__esModule",{value:!0}),N.broadcast=void 0;var e=K();return N.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){}},N}(),e),i((_||(_=1,Object.defineProperty(S,"__esModule",{value:!0}),S.subscribers=S.childWindows=S.prefix=void 0,S.prefix="/*framebus*/",S.childWindows=[],S.subscribers={}),S),e),i(function(){if(E)return P;E=1,Object.defineProperty(P,"__esModule",{value:!0}),P.dispatch=void 0;var e=K();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),i((m||(m=1,Object.defineProperty(b,"__esModule",{value:!0}),b.hasOpener=void 0,b.hasOpener=function(e){return e.top===e&&null!=e.opener&&e.opener!==e&&!0!==e.opener.closed}),b),e),i((v||(v=1,Object.defineProperty(D,"__esModule",{value:!0}),D.isntString=void 0,D.isntString=function(e){return"string"!=typeof e}),D),e),i(function(){if(y)return M;y=1,Object.defineProperty(M,"__esModule",{value:!0}),M.onMessage=void 0;var e=K();return M.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)}}},M}(),e),i(function(){if(I)return w;I=1,Object.defineProperty(w,"__esModule",{value:!0}),w.packagePayload=void 0;var e=K();return w.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},w}(),e),i((f||(f=1,Object.defineProperty(k,"__esModule",{value:!0}),k.sendMessage=void 0,k.sendMessage=function(e,t,i){try{e.postMessage(t,i)}catch(e){}}),k),e),i(x(),e),i(function(){if(j)return H;j=1,Object.defineProperty(H,"__esModule",{value:!0}),H.subscriptionArgsInvalid=void 0;var e=K();return H.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},H}(),e),i((B||(B=1,Object.defineProperty(q,"__esModule",{value:!0})),q),e),i(function(){if(V)return W;V=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)}(T)),T}const $=c(function(){if(z)return X;z=1;var e=K(),t=F();return(0,e.attach)(),X=t.Framebus}());class Z{constructor(e){this.origin=null,this.onAndEmit=(e,t,i="*")=>{const n=`${e}-REQ`,s=n=>{return s=this,o=null,r=function*(){const s=yield t(n);this.bus.target({origin:i}).emit(`${e}-RES`,s)},new Promise((e,t)=>{var i=e=>{try{a(r.next(e))}catch(e){t(e)}},n=e=>{try{a(r.throw(e))}catch(e){t(e)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,n);a((r=r.apply(s,o)).next())});var s,o,r};return this.bus.on(n,s),()=>this.bus.off(n,s)},this.emitAndResolve=(e,t,i="*",n)=>new Promise((s,o)=>{if(null==n?void 0:n.aborted)return void o(n.reason);const a=`${e}-RES`,l=e=>{c(),s(e)},d=()=>{c(),o(n.reason)},c=()=>{this.bus.off(a,l),null==n||n.removeEventListener("abort",d)};this.bus.on(a,l),null==n||n.addEventListener("abort",d),this.bus.target({origin:i}).emit(`${e}-REQ`,r({},t))}),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}(r);const a={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."},l={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."},d={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",u="element",h="ERROR",p={CHANGE:"CHANGE",READY:"READY",FOCUS:"FOCUS",BLUR:"BLUR",ESCAPE:"ESCAPE",CLICK:"CLICK",ERROR:"ERROR",SUCCESS:"SUCCESS",SUBMIT:"SUBMIT",CREATED:"CREATED",MOUNTED:"MOUNTED",HEIGHT:"HEIGHT"},_="FRAME_READY",E="TOKENIZATION_REQUEST",m="RESET",v="INPUT_EVENT",y="DESTROY_FRAME",I="SET_VALUE",f="SET_ATTRIBUTE",A="GET_BEARER_TOKEN",L="COLLECT_ELEMENT_SET_ERROR",g="COMPOSABLE_UPDATE_OPTIONS",O="VALIDATE_ELEMENT",T="COMPOSABLE_CONTAINER_MOUNTED",C="COLLECT_CONTAINER_MOUNTED";var R,N,S;(N=R||(R={})).CVV="CVV",N.EXPIRATION_DATE="EXPIRATION_DATE",N.CARD_NUMBER="CARD_NUMBER",N.CARDHOLDER_NAME="CARDHOLDER_NAME",N.INPUT_FIELD="INPUT_FIELD",N.PIN="PIN",N.EXPIRATION_MONTH="EXPIRATION_MONTH",N.EXPIRATION_YEAR="EXPIRATION_YEAR",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"}(S||(S={}));const P={[S.AMEX]:["XXXX XXXXXX XXXXX",{X:"[0-9]"}],[S.VISA]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[S.MASTERCARD]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[S.DISCOVER]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[S.DINERS_CLUB]:["XXXX XXXXXX XXXXXX",{X:"[0-9]"}],[S.JCB]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[S.MAESTRO]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[S.UNIONPAY]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[S.HIPERCARD]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[S.DEFAULT]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[S.UNKNOWN]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[S.ELO]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}]},b={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},[R.CARDHOLDER_NAME]:{name:"cardHolderName",attributes:{type:"text",autocomplete:"cc-name"},sensitive:!0,regex:/^([a-zA-Z\\ \\,\\.\\-\\']{2,})$/},[R.CARD_NUMBER]:{name:"CARD_NUMBER",attributes:{type:"text",autocomplete:"cc-number",inputmode:"numeric"},sensitive:!0,mask:P[S.DEFAULT],regex:/$|^[\s]*?([0-9]{2,6}[ -]?){3,5}[\s]*/},[R.EXPIRATION_DATE]:{name:"EXPIRATION_DATE",attributes:{type:"text",autocomplete:"cc-exp",inputmode:"numeric"},sensitive:!0},[R.EXPIRATION_MONTH]:{name:"EXPIRATION_MONTH",attributes:{maxLength:2,type:"text",inputmode:"numeric",autocomplete:"cc-exp-month"},sensitive:!0,mask:["XX",{X:"[0-9]"}]},[R.EXPIRATION_YEAR]:{name:"EXPIRATION_YEAR",attributes:{type:"text",inputmode:"numeric",autocomplete:"cc-exp-year"},sensitive:!0},[R.CVV]:{name:"CVV",attributes:{type:"text",inputmode:"numeric",maxLength:3},sensitive:!0,regex:/^$|^[0-9]{3,4}$/},[R.INPUT_FIELD]:{name:"INPUT_FIELD",sensitive:!0,attributes:{type:"text"}},[R.PIN]:{name:"PIN",attributes:{type:"text",inputmode:"numeric",maxLength:12,minLength:4},sensitive:!0,regex:/^$|^[0-9]{4,12}$/}},D="XXXX-XXXX-XXXX-XXXX",M={height:"100%",width:"100%",margin:0,padding:0,border:0,position:"absolute",top:0,left:0,"user-select":"none"},w={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"},Y={WEBPACKAUTOFILL:"-webkit-autofill",BASE:"base",FOCUS:"focus",COMPLETE:"complete",EMPTY:"empty",INVALID:"invalid",GLOBAL:"global",REQUIRED_ASTERISK:"requiredAsterisk"},U={[S.VISA]:{regex:/^4\d*/,maxCardLength:19,cardLengthRange:[13,16]},[S.MASTERCARD]:{regex:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,maxCardLength:16,cardLengthRange:[16]},[S.AMEX]:{regex:/^3[47]\d*/,maxCardLength:15,cardLengthRange:[15]},[S.DINERS_CLUB]:{regex:/^(36|38|30[0-5])\d*/,maxCardLength:16,cardLengthRange:[14,15,16,17,18,19]},[S.DISCOVER]:{regex:/^(6011|65|64[4-9]|622)\d*/,maxCardLength:16,cardLengthRange:[16,17,18,19]},[S.JCB]:{regex:/^35\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[S.HIPERCARD]:{regex:/^606282\d*/,maxCardLength:19,cardLengthRange:[14,15,16,17,18,19]},[S.UNIONPAY]:{regex:/^62\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[S.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]},[S.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]}};S.DEFAULT,S.CVV,S.EXPIRY,S.ERROR,S.AMEX,S.DINERS_CLUB,S.DISCOVER,S.HIPERCARD,S.JCB,S.MAESTRO,S.MASTERCARD,S.UNIONPAY,S.VISA,S.ELO;const F="MM/YY",x=[F,"YYYY/MM","YY/MM","MM/YYYY"],j=["YY","YYYY"];var B;!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"}(B||(B={})),R.CARD_NUMBER,R.EXPIRATION_DATE,R.EXPIRATION_MONTH,R.EXPIRATION_YEAR,R.CVV,R.EXPIRATION_DATE,R.CARD_NUMBER,R.CARDHOLDER_NAME,R.INPUT_FIELD,l.INVALID_COLLECT_VALUE,R.PIN,R.EXPIRATION_MONTH,R.EXPIRATION_YEAR,R.CVV,R.EXPIRATION_DATE,R.CARD_NUMBER,R.CARDHOLDER_NAME,R.INPUT_FIELD,l.DEFAULT_REQUIRED_COLLECT_VALUE,R.PIN,R.EXPIRATION_MONTH,R.EXPIRATION_YEAR;const V=[R.CARDHOLDER_NAME,R.EXPIRATION_MONTH,R.PIN,R.CVV],G={X:"[0-9]"},X={visa:U.VISA.regex,mastercard:U.MASTERCARD.regex,amex:U.AMEX.regex,diners_club:U.DINERS_CLUB.regex,discover:U.DISCOVER.regex,jcb:U.JCB.regex,hipercard:U.HIPERCARD.regex,unionpay:U.UNIONPAY.regex,maestro:U.MAESTRO.regex,elo:U.ELO.regex},z=[];for(let e=0;e<256;++e)z.push((e+256).toString(16).slice(1));let H;const q=new Uint8Array(16);var W,K={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function $(e,t,i){if(K.randomUUID&&!e)return K.randomUUID();const n=(e=e||{}).random??e.rng?.()??function(){if(!H){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");H=crypto.getRandomValues.bind(crypto)}return H(q)}();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=15&n[6]|64,n[8]=63&n[8]|128,function(e,t=0){return(z[e[t+0]]+z[e[t+1]]+z[e[t+2]]+z[e[t+3]]+"-"+z[e[t+4]]+z[e[t+5]]+"-"+z[e[t+6]]+z[e[t+7]]+"-"+z[e[t+8]]+z[e[t+9]]+"-"+z[e[t+10]]+z[e[t+11]]+z[e[t+12]]+z[e[t+13]]+z[e[t+14]]+z[e[t+15]]).toLowerCase()}(n)}!function(e){e.GET="GET",e.POST="POST",e.DELETE="DELETE",e.PATCH="PATCH"}(W||(W={}));const Z=e=>i(void 0,[e],void 0,function*({url:e,method:t=W.GET,token:i="",body:n}){const s={method:t,headers:Object.assign(Object.assign(Object.assign({},ne()),ie(i)),se())};t!==W.POST&&t!==W.PATCH||(s.body=JSON.stringify(n||{}));const o=yield fetch(e,s);if([401,403].includes(o.status))throw new J(e,t);if(429===o.status)throw new ee(e,t);if(!o.ok)throw new Q(e,t);const r=yield o.json();return{ok:o.ok,req:Object.assign({url:e},s),res:r}});class J extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_UNAUTHORIZED,{description:`[${t}] ${e} unauthorized`})}}let Q=class extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{description:`[${t}] ${e} unsuccessful`})}},ee=class extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} too many requests`})}};class te extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} max poll attempts exceeded.`})}}const ie=e=>({authorization:`Bearer ${e}`}),ne=()=>({"x-idempotency-key":$()}),se=()=>{const e={version:"5.47.0",type:"web-sdk"};return{"x-client-version":e.version,"x-client-type":e.type}},oe=({url:e,token:t,body:i})=>Z({url:e,token:t,method:W.POST,body:i});function re(...e){function t(e,i){if(void 0===i)return e;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))void 0!==i[s]&&(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),{})}var ae,le;e.PAYMENT_METHOD_CODES=void 0,(ae=e.PAYMENT_METHOD_CODES||(e.PAYMENT_METHOD_CODES={})).CARD="card",ae.GOOGLE_PAY="googlePay",ae.PAYPAL="payPal",ae.APPLE_PAY="applePay",ae.GENERIC_REDIRECT="genericRedirect",ae.LEAN="lean",ae.MERCADO_PAGO="mercadoPago",ae.PIX="pix",ae.BANK_ACCOUNT="bankAccount",ae.IDEAL="iDeal",ae.YAPE="yape",ae.UPI="upi",ae.KLARNA="klarna",ae.ONE_VOUCHER="1voucher",ae.ALFA="alfa",ae.APLAZO="aplazo",ae.BANK_TRANSFER="bankTransfer",ae.CAPITEC_PAY="capitecPay",ae.EASYPAISA="easypaisa",ae.EFT_PRO="eftPro",ae.FAWRY_PAY="fawryPay",ae.JAZZ_CASH="jazzCash",ae.KONNECT="konnect",ae.KUESKI="kueski",ae.MONO_DIRECT_DEBIT="monoDirectDebit",ae.O_PAY_WALLET="oPayWallet",ae.PAGA_WALLET="pagaWallet",ae.PAYFLEX="payflex",ae.PAY_JUST_NOW="payjustnow",ae.WAFA_CASH_WALLET="wafaCashWallet",ae.MERCADO_PAGO_WALLET="mercadoPagoWallet",ae.MERCADO_PAGO_CONSUMER_CREDIT="mercadoPagoConsumerCredit",ae.NET_BANKING="netBanking",ae.CASH_FREE_WALLET="cashFreeWallet",ae.PAYTM_WALLET="paytmWallet",ae.NIBSS_PAY="nibssPay",ae.NIBSS_INSTANT_PAY="nibssInstantPay",ae.MEEZA_WALLET="meezaWallet",ae.VODAFONE_CASH="vodafoneCash",ae.SEPA_DIRECT_DEBIT="sepaDirectDebit",ae.MODO="modo",ae.PAYZONE_CASH="payzoneCash",ae.REVOLUT_PAY="revolutPay",Object.fromEntries(Object.entries(e.PAYMENT_METHOD_CODES).map(([e,t])=>[e,t])),function(e){e.ENABLED="enabled",e.CREATED="created",e.DELETED="deleted",e.DISABLED="disabled",e.INVALID="invalid",e.TRANSIENT="transient"}(le||(le={}));const de=["customer"];class ce{static get response(){if(!ce._response){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND);throw r.PayrailsLogger.error(e.message,{error:e}),e}return ce._response}static setResponse(e){return ce._response=e,ce._updatedMetaKeys=new Set,ce}static get executionId(){var e;return null===(e=ce._response)||void 0===e?void 0:e.id}static get workflowCode(){return ce.response.workflow.code}static get lookup(){return ce.response.initialResults.find(({body:{name:e}})=>"lookup"===e)}static get holderReference(){return ce.response.holderReference}static get savedCreditCards(){return ce.getStoredInstrumentForPaymentMethod(e.PAYMENT_METHOD_CODES.CARD)}static get savedPaypalAccounts(){return ce.getStoredInstrumentForPaymentMethod(e.PAYMENT_METHOD_CODES.PAYPAL).filter(({status:e})=>e===le.ENABLED)}static get savedGooglePayAccounts(){return ce.getStoredInstrumentForPaymentMethod(e.PAYMENT_METHOD_CODES.GOOGLE_PAY).filter(({status:e})=>e===le.ENABLED)}static get savedApplePayAccounts(){return ce.getStoredInstrumentForPaymentMethod(e.PAYMENT_METHOD_CODES.APPLE_PAY)}static get paypalConfig(){const t=ce.availablePaymentMethods.find(({paymentMethodCode:t})=>t===e.PAYMENT_METHOD_CODES.PAYPAL);if(!t){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING);throw r.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:ce.availablePaymentMethods}}),e}return t.config||{}}static get googlePayConfig(){var t;const i=ce.availablePaymentMethods.find(({paymentMethodCode:t})=>t===e.PAYMENT_METHOD_CODES.GOOGLE_PAY);if(!i){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING);throw r.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:ce.availablePaymentMethods}}),e}const n=i;return(null===(t=n.clientConfig)||void 0===t?void 0:t.additionalConfig)&&void 0!==n.clientConfig.additionalConfig.apiVersion?n.clientConfig.additionalConfig:[n.config]}static isPaymentMethodAvailable(e){return ce.availablePaymentMethods.some(({paymentMethodCode:t})=>t===e)}static get applePayConfig(){const t=ce.availablePaymentMethods.find(({paymentMethodCode:t})=>t===e.PAYMENT_METHOD_CODES.APPLE_PAY);if(!t){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING);throw r.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:ce.availablePaymentMethods}}),e}return t.config.parameters}static get url(){return ce.response.links.self}static get meta(){return ce.response.meta}static get availablePaymentMethods(){var e;return(null===(e=ce.lookup)||void 0===e?void 0:e.body.data.paymentCompositionOptions)||[]}static get authorizeLink(){var e,t;return null===(t=null===(e=ce.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=ce.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=ce.response.links.startPaymentSession)||void 0===e?void 0:e.href}static get createInstrumentLink(){var e;return null===(e=ce.response.links.createInstrument)||void 0===e?void 0:e.href}static get storedPaymentInstruments(){return ce.availablePaymentMethods.flatMap(e=>e.paymentInstruments||[]).filter(({paymentMethod:t,status:i})=>{const n=[e.PAYMENT_METHOD_CODES.GOOGLE_PAY,e.PAYMENT_METHOD_CODES.PAYPAL];return i===le.ENABLED||!n.includes(t)})}static get storedDropinInstruments(){return ce.storedPaymentInstruments.filter(({paymentMethod:t})=>![e.PAYMENT_METHOD_CODES.GOOGLE_PAY,e.PAYMENT_METHOD_CODES.APPLE_PAY].includes(t))}static getFullPaymentMethodConfig(e){return ce.availablePaymentMethods.find(({paymentMethodCode:t})=>t===e)}static isAddressSelectorEnabled(e){var t,i;return!!ce._response&&(null===(i=null===(t=ce.getFullPaymentMethodConfig(e))||void 0===t?void 0:t.clientConfig)||void 0===i?void 0:i.supportsBillingInfo)}static isPaymentInstallmentsEnabled(e){var t;if(ce._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(e){const{paymentInstruments:i}=e;return t(e,["paymentInstruments"])}static updateInstallmentOptions(t){const i=ce.getFullPaymentMethodConfig(e.PAYMENT_METHOD_CODES.CARD);(null==i?void 0:i.clientConfig)&&(i.clientConfig.installments=t)}static updateMeta(e,t){if(!de.includes(e))return;const i=ce.response.meta||{},n=re(i[e]||{},t);ce._response=Object.assign(Object.assign({},ce.response),{meta:Object.assign(Object.assign({},i),{[e]:n})}),ce._updatedMetaKeys.add(e)}static getAllowedMeta(){const e=ce.response.meta||{};return ce.pickMetaByKeys(e,de)}static getUpdatedMeta(){const e=ce.response.meta||{};return ce.pickMetaByKeys(e,ce._updatedMetaKeys)}static pickMetaByKeys(e,t){const i={};for(const n of t){const t=e[n];void 0!==t&&(i[n]=t)}return i}}var ue,he;ce._updatedMetaKeys=new Set,function(e){e.REDIRECT="redirect",e.DIRECT="direct",e.EMBEDDED="embedded"}(ue||(ue={})),e.INTEGRATION_TYPE=void 0,(he=e.INTEGRATION_TYPE||(e.INTEGRATION_TYPE={})).API="api",he.HPP="hpp";class pe{constructor(){this._config=void 0}static getInstance(){return pe._instance||(pe._instance=new pe),pe._instance}set config(e){try{pe.getInstance()._config=e}catch(e){r.PayrailsLogger.error("Error parsing SDK Configuration",{error:e})}}get config(){return pe.getInstance()._config||r.PayrailsLogger.error("SDK Configuration not set"),pe.getInstance()._config||{}}}const _e=()=>pe.getInstance().config,Ee=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));pe.getInstance().config=t,t.execution&&ce.setResponse(t.execution)}catch(e){r.PayrailsLogger.error("Error parsing SDK Configuration",{error:e})}};e.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"}(e.ElementType||(e.ElementType={}));class me{constructor(e,t){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=>i(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=_e().links)||void 0===t?void 0:t.binLookup)||void 0===i?void 0:i.href}`;if(!n)return{bin:e};const s=_e().token,a={bin:e};try{const e=yield(({url:e,token:t,body:i})=>Z({url:e,method:W.POST,token:t,body:i}))({url:n,token:s,body:a});return e.res}catch(t){const i=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_BIN_LOOKUP_FAILED,{description:"Error fetching BIN lookup data!",cause:t});return r.PayrailsLogger.error(i.message,{error:i}),{bin:e}}}),this.cardTableName=t.cardTableName||"cards",this.containerType=t.containerType||"COMPOSABLE",this.isBinLookupEnabled=!!(null===(n=_e().links)||void 0===n?void 0:n.binLookup);try{this.__container=e.container(this.containerType,t)}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CREATION_FAILED,{cause:e});r.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 me(e,t),this.instance}createCollectElement(t){var i;const n={required:!!t.required,enableCardIcon:!1!==t.enableCardIcon},s=null===(i=this.__container)||void 0===i?void 0:i.create(Object.assign(Object.assign({table:this.cardTableName,labelStyles:{},errorTextStyles:{},column:this.elementToFieldMap.get(t.type)},t),{type:t.type===e.ElementType.CARDHOLDER_NAME?"INPUT_FIELD":t.type}),t.format?Object.assign(Object.assign({},n),{format:t.format}):n);if(!s){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING,{description:"Error creating collect element!"});throw r.PayrailsLogger.error(e.message,{error:e}),e}return this.attachCustomEventHandler(s)}mount(e){if("COLLECT"===this.containerType){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw r.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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING);throw r.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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);r.PayrailsLogger.error(t.message,{error:t})}}unmount(){this.element&&this.element.remove()}validate(){return i(this,void 0,void 0,function*(){var e;return yield null===(e=this.__container)||void 0===e?void 0:e.validate()})}collect(){return i(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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_OPERATION_FAILED,{description:"Error collecting data from the iframe!",cause:t});throw t.name!==o.ERROR_CODES.PAYRAILS_CARD_FORM_COMPLETE_AND_VALID_INPUTS&&r.PayrailsLogger.error(i.message,{error:i}),i}})}reset(){var e;null===(e=this.__container)||void 0===e||e.reset()}collectPayrailsData(){return i(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:_e().vaultConfiguration.providerConfigId})})}tokenize(e){return i(this,void 0,void 0,function*(){const t=yield this.collect(),i=_e().vaultConfiguration.links.saveInstrument.href,n=_e().token;if(!i){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND,{description:"Save instrument URL not available!"});throw r.PayrailsLogger.error(e.message,{error:e}),e}return(yield oe({url:i,token:n,body:this.constructSaveInstrumentBody(t,e)})).res})}constructSaveInstrumentBody(e,t){var i,n;const s={holderReference:_e().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(t){return new Proxy(t,{get:(t,i)=>{const n=t[i];return"on"===i?((n,s)=>{t[i].call(t,n,i=>{"CHANGE"===n?(this.manualErrorElements.has(t)&&!i.isEmpty&&("resetError"in t&&"function"==typeof t.resetError&&t.resetError(),this.manualErrorElements.delete(t)),i.elementType===e.ElementType.CARD_NUMBER&&(i.network=function(e){for(const[t,i]of Object.entries(X))if(i.test(e))return t;return""}(i.value),i.bin=this.formatBin(i.value),this.bin=this.formatBin(i.value)),s(i)):s(i)})}).bind(t):"setError"===i?(...e)=>(this.manualErrorElements.add(t),n.apply(t,e)):"function"==typeof n?n.bind(t):n}})}formatBin(e){return e.replace(/[-X]/g,"").slice(0,8)}get elementToFieldMap(){return new Map([[e.ElementType.CARD_NUMBER,"card_number"],[e.ElementType.CARDHOLDER_NAME,"cardholder_name"],[e.ElementType.CVV,"security_code"],[e.ElementType.EXPIRATION_MONTH,"expiry_month"],[e.ElementType.EXPIRATION_YEAR,"expiry_year"],[e.ElementType.EXPIRATION_DATE,"expiry_date"]])}}var ve={};!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;function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var a,l,d,c,u,h,p,_,E,m,v,y,I,f,A={},L={},g={},O={},T={},C={},R={},N={},S={},P={},b={},D={},M={};function w(){if(v)return M;v=1,Object.defineProperty(M,"__esModule",{value:!0}),M.Framebus=void 0;var e=z(),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 M.Framebus=i,M}function k(){if(f)return D;f=1;var e=D&&D.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(D,"__esModule",{value:!0}),D.subscribeReplier=void 0;var t=w(),i=e((I||(I=1,y=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)})}),y));return D.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},D}var Y,U,F,x,j,B,V={},G={},X={};function z(){return x||(x=1,function(e){var t=A&&A.__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=A&&A.__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(a)return L;a=1,Object.defineProperty(L,"__esModule",{value:!0}),L.detach=L.attach=void 0;var e=z(),t=!1;return L.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},L.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},L}(),e),i(function(){if(l)return g;l=1,Object.defineProperty(g,"__esModule",{value:!0}),g.broadcastToChildWindows=void 0;var e=z();return g.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})}},g}(),e),i(function(){if(d)return O;d=1,Object.defineProperty(O,"__esModule",{value:!0}),O.broadcast=void 0;var e=z();return O.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){}},O}(),e),i((c||(c=1,Object.defineProperty(T,"__esModule",{value:!0}),T.subscribers=T.childWindows=T.prefix=void 0,T.prefix="/*framebus*/",T.childWindows=[],T.subscribers={}),T),e),i(function(){if(u)return C;u=1,Object.defineProperty(C,"__esModule",{value:!0}),C.dispatch=void 0;var e=z();return C.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)}},C}(),e),i((h||(h=1,Object.defineProperty(R,"__esModule",{value:!0}),R.hasOpener=void 0,R.hasOpener=function(e){return e.top===e&&null!=e.opener&&e.opener!==e&&!0!==e.opener.closed}),R),e),i((p||(p=1,Object.defineProperty(N,"__esModule",{value:!0}),N.isntString=void 0,N.isntString=function(e){return"string"!=typeof e}),N),e),i(function(){if(_)return S;_=1,Object.defineProperty(S,"__esModule",{value:!0}),S.onMessage=void 0;var e=z();return S.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)}}},S}(),e),i(function(){if(E)return P;E=1,Object.defineProperty(P,"__esModule",{value:!0}),P.packagePayload=void 0;var e=z();return P.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},P}(),e),i((m||(m=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(k(),e),i(function(){if(Y)return V;Y=1,Object.defineProperty(V,"__esModule",{value:!0}),V.subscriptionArgsInvalid=void 0;var e=z();return V.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},V}(),e),i((U||(U=1,Object.defineProperty(G,"__esModule",{value:!0})),G),e),i(function(){if(F)return X;F=1,Object.defineProperty(X,"__esModule",{value:!0}),X.unpackPayload=void 0;var e=z();return X.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},X}(),e)}(A)),A}const H=r(function(){if(B)return j;B=1;var e=z(),t=w();return(0,e.attach)(),j=t.Framebus}());class q{constructor(e){this.origin=null,this.onAndEmit=(e,t,i="*")=>{const n=`${e}-REQ`,s=n=>{return s=this,o=null,r=function*(){const s=yield t(n);this.bus.target({origin:i}).emit(`${e}-RES`,s)},new Promise((e,t)=>{var i=e=>{try{a(r.next(e))}catch(e){t(e)}},n=e=>{try{a(r.throw(e))}catch(e){t(e)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,n);a((r=r.apply(s,o)).next())});var s,o,r};return this.bus.on(n,s),()=>this.bus.off(n,s)},this.emitAndResolve=(e,t,r="*",a)=>new Promise((l,d)=>{if(null==a?void 0:a.aborted)return void d(a.reason);const c=`${e}-RES`,u=e=>{p(),l(e)},h=()=>{p(),d(a.reason)},p=()=>{this.bus.off(c,u),null==a||a.removeEventListener("abort",h)};this.bus.on(c,u),null==a||a.addEventListener("abort",h),this.bus.target({origin:r}).emit(`${e}-REQ`,((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})({},t))}),this.bus=new H(e)}static getInstance(){return q.instance||(q.instance=new q),q.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)}}var W=(e=>(e.BUTTON_CLICK_VALIDATE="BUTTON_CLICK_VALIDATE",e.COLLECT="COLLECT",e.READY="READY",e.SHOW="SHOW",e.ERROR="ERROR",e.COLLECT_ERROR="COLLECT_ERROR",e.RESIZE="RESIZE",e.IS_AVAILABLE="IS_AVAILABLE",e))(W||{}),K=(e=>(e.Collect="COLLECT",e.Display="DISPLAY",e))(K||{}),$=(e=>(e.GooglePay="GOOGLE_PAY",e))($||{});e.COLLECT_FRAME_EVENT_NAMES=W,e.IframeEventBus=q,e.SecureFrameMode=K,e.SecureFrameType=$,e.getEventBus=()=>q.getInstance()}(ve);class ye{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(ye.prototype,{constructor:e})}}
1
+ !function(e){"use strict";function t(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 i(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 n(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 s(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}"function"==typeof SuppressedError&&SuppressedError;var o={};!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_APPLEPAY_MERCHANT_VALIDATION_FAILED="payrails:client:init.applepay_merchant_validation_failed",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:client:init.applepay_merchant_validation_failed":{description:"Apple pay merchant validation failed",docUrl:"https://docs.payrails.com/docs/apple-pay#pre-requisites"},"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}(o);var r={};!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_APPLEPAY_MERCHANT_VALIDATION_FAILED="payrails:client:init.applepay_merchant_validation_failed",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,h,p,_,E,m,v,y,I,f,A,L,O,g,T={},C={},R={},N={},S={},P={},b={},D={},M={},w={},k={},Y={},U={};function F(){if(A)return U;A=1,Object.defineProperty(U,"__esModule",{value:!0}),U.Framebus=void 0;var e=W(),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 x(){if(g)return Y;g=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=F(),i=e((O||(O=1,L=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)})}),L));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,V,G,X,z,H={},$={},q={};function W(){return G||(G=1,function(e){var t=T&&T.__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=T&&T.__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 C;u=1,Object.defineProperty(C,"__esModule",{value:!0}),C.detach=C.attach=void 0;var e=W(),t=!1;return C.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},C.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},C}(),e),i(function(){if(h)return R;h=1,Object.defineProperty(R,"__esModule",{value:!0}),R.broadcastToChildWindows=void 0;var e=W();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),i(function(){if(p)return N;p=1,Object.defineProperty(N,"__esModule",{value:!0}),N.broadcast=void 0;var e=W();return N.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){}},N}(),e),i((_||(_=1,Object.defineProperty(S,"__esModule",{value:!0}),S.subscribers=S.childWindows=S.prefix=void 0,S.prefix="/*framebus*/",S.childWindows=[],S.subscribers={}),S),e),i(function(){if(E)return P;E=1,Object.defineProperty(P,"__esModule",{value:!0}),P.dispatch=void 0;var e=W();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),i((m||(m=1,Object.defineProperty(b,"__esModule",{value:!0}),b.hasOpener=void 0,b.hasOpener=function(e){return e.top===e&&null!=e.opener&&e.opener!==e&&!0!==e.opener.closed}),b),e),i((v||(v=1,Object.defineProperty(D,"__esModule",{value:!0}),D.isntString=void 0,D.isntString=function(e){return"string"!=typeof e}),D),e),i(function(){if(y)return M;y=1,Object.defineProperty(M,"__esModule",{value:!0}),M.onMessage=void 0;var e=W();return M.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)}}},M}(),e),i(function(){if(I)return w;I=1,Object.defineProperty(w,"__esModule",{value:!0}),w.packagePayload=void 0;var e=W();return w.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},w}(),e),i((f||(f=1,Object.defineProperty(k,"__esModule",{value:!0}),k.sendMessage=void 0,k.sendMessage=function(e,t,i){try{e.postMessage(t,i)}catch(e){}}),k),e),i(x(),e),i(function(){if(j)return H;j=1,Object.defineProperty(H,"__esModule",{value:!0}),H.subscriptionArgsInvalid=void 0;var e=W();return H.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},H}(),e),i((B||(B=1,Object.defineProperty($,"__esModule",{value:!0})),$),e),i(function(){if(V)return q;V=1,Object.defineProperty(q,"__esModule",{value:!0}),q.unpackPayload=void 0;var e=W();return q.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},q}(),e)}(T)),T}const K=c(function(){if(z)return X;z=1;var e=W(),t=F();return(0,e.attach)(),X=t.Framebus}());class Z{constructor(e){this.origin=null,this.onAndEmit=(e,t,i="*")=>{const n=`${e}-REQ`,s=n=>{return s=this,o=null,r=function*(){const s=yield t(n);this.bus.target({origin:i}).emit(`${e}-RES`,s)},new Promise((e,t)=>{var i=e=>{try{a(r.next(e))}catch(e){t(e)}},n=e=>{try{a(r.throw(e))}catch(e){t(e)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,n);a((r=r.apply(s,o)).next())});var s,o,r};return this.bus.on(n,s),()=>this.bus.off(n,s)},this.emitAndResolve=(e,t,i="*",n)=>new Promise((s,o)=>{if(null==n?void 0:n.aborted)return void o(n.reason);const a=`${e}-RES`,l=e=>{c(),s(e)},d=()=>{c(),o(n.reason)},c=()=>{this.bus.off(a,l),null==n||n.removeEventListener("abort",d)};this.bus.on(a,l),null==n||n.addEventListener("abort",d),this.bus.target({origin:i}).emit(`${e}-REQ`,r({},t))}),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}(r);const a={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."},l={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."},d={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",u="element",h="ERROR",p={CHANGE:"CHANGE",READY:"READY",FOCUS:"FOCUS",BLUR:"BLUR",ESCAPE:"ESCAPE",CLICK:"CLICK",ERROR:"ERROR",SUCCESS:"SUCCESS",SUBMIT:"SUBMIT",CREATED:"CREATED",MOUNTED:"MOUNTED",HEIGHT:"HEIGHT"},_="FRAME_READY",E="TOKENIZATION_REQUEST",m="RESET",v="INPUT_EVENT",y="DESTROY_FRAME",I="SET_VALUE",f="SET_ATTRIBUTE",A="GET_BEARER_TOKEN",L="COLLECT_ELEMENT_SET_ERROR",O="COMPOSABLE_UPDATE_OPTIONS",g="VALIDATE_ELEMENT",T="COMPOSABLE_CONTAINER_MOUNTED",C="COLLECT_CONTAINER_MOUNTED";var R,N,S;(N=R||(R={})).CVV="CVV",N.EXPIRATION_DATE="EXPIRATION_DATE",N.CARD_NUMBER="CARD_NUMBER",N.CARDHOLDER_NAME="CARDHOLDER_NAME",N.INPUT_FIELD="INPUT_FIELD",N.PIN="PIN",N.EXPIRATION_MONTH="EXPIRATION_MONTH",N.EXPIRATION_YEAR="EXPIRATION_YEAR",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"}(S||(S={}));const P={[S.AMEX]:["XXXX XXXXXX XXXXX",{X:"[0-9]"}],[S.VISA]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[S.MASTERCARD]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[S.DISCOVER]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[S.DINERS_CLUB]:["XXXX XXXXXX XXXXXXXXX",{X:"[0-9]"}],[S.JCB]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[S.MAESTRO]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[S.UNIONPAY]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[S.HIPERCARD]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[S.DEFAULT]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[S.UNKNOWN]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[S.ELO]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}]},b={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},[R.CARDHOLDER_NAME]:{name:"cardHolderName",attributes:{type:"text",autocomplete:"cc-name"},sensitive:!0,regex:/^([a-zA-Z\\ \\,\\.\\-\\']{2,})$/},[R.CARD_NUMBER]:{name:"CARD_NUMBER",attributes:{type:"text",autocomplete:"cc-number",inputmode:"numeric"},sensitive:!0,mask:P[S.DEFAULT],regex:/$|^[\s]*?([0-9]{2,6}[ -]?){3,5}[\s]*/},[R.EXPIRATION_DATE]:{name:"EXPIRATION_DATE",attributes:{type:"text",autocomplete:"cc-exp",inputmode:"numeric"},sensitive:!0},[R.EXPIRATION_MONTH]:{name:"EXPIRATION_MONTH",attributes:{maxLength:2,type:"text",inputmode:"numeric",autocomplete:"cc-exp-month"},sensitive:!0,mask:["XX",{X:"[0-9]"}]},[R.EXPIRATION_YEAR]:{name:"EXPIRATION_YEAR",attributes:{type:"text",inputmode:"numeric",autocomplete:"cc-exp-year"},sensitive:!0},[R.CVV]:{name:"CVV",attributes:{type:"text",inputmode:"numeric",maxLength:3},sensitive:!0,regex:/^$|^[0-9]{3,4}$/},[R.INPUT_FIELD]:{name:"INPUT_FIELD",sensitive:!0,attributes:{type:"text"}},[R.PIN]:{name:"PIN",attributes:{type:"text",inputmode:"numeric",maxLength:12,minLength:4},sensitive:!0,regex:/^$|^[0-9]{4,12}$/}},D="XXXX-XXXX-XXXX-XXXX",M={height:"100%",width:"100%",margin:0,padding:0,border:0,position:"absolute",top:0,left:0,"user-select":"none"},w={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"},Y={WEBPACKAUTOFILL:"-webkit-autofill",BASE:"base",FOCUS:"focus",COMPLETE:"complete",EMPTY:"empty",INVALID:"invalid",GLOBAL:"global",REQUIRED_ASTERISK:"requiredAsterisk"},U={[S.VISA]:{regex:/^4\d*/,maxCardLength:19,cardLengthRange:[13,16,18,19]},[S.MASTERCARD]:{regex:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,maxCardLength:16,cardLengthRange:[16]},[S.AMEX]:{regex:/^3[47]\d*/,maxCardLength:15,cardLengthRange:[15]},[S.DINERS_CLUB]:{regex:/^(36|38|39|30[0-5])\d*/,maxCardLength:19,cardLengthRange:[14,15,16,17,18,19]},[S.DISCOVER]:{regex:/^(6011|65|64[4-9]|622)\d*/,maxCardLength:16,cardLengthRange:[16,17,18,19]},[S.JCB]:{regex:/^35\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[S.HIPERCARD]:{regex:/^606282\d*/,maxCardLength:19,cardLengthRange:[14,15,16,17,18,19]},[S.UNIONPAY]:{regex:/^(62|81)\d*/,maxCardLength:19,cardLengthRange:[14,15,16,17,18,19]},[S.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]},[S.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]}};S.DEFAULT,S.CVV,S.EXPIRY,S.ERROR,S.AMEX,S.DINERS_CLUB,S.DISCOVER,S.HIPERCARD,S.JCB,S.MAESTRO,S.MASTERCARD,S.UNIONPAY,S.VISA,S.ELO;const F="MM/YY",x=[F,"YYYY/MM","YY/MM","MM/YYYY"],j=["YY","YYYY"];var B;!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"}(B||(B={})),R.CARD_NUMBER,R.EXPIRATION_DATE,R.EXPIRATION_MONTH,R.EXPIRATION_YEAR,R.CVV,R.EXPIRATION_DATE,R.CARD_NUMBER,R.CARDHOLDER_NAME,R.INPUT_FIELD,l.INVALID_COLLECT_VALUE,R.PIN,R.EXPIRATION_MONTH,R.EXPIRATION_YEAR,R.CVV,R.EXPIRATION_DATE,R.CARD_NUMBER,R.CARDHOLDER_NAME,R.INPUT_FIELD,l.DEFAULT_REQUIRED_COLLECT_VALUE,R.PIN,R.EXPIRATION_MONTH,R.EXPIRATION_YEAR;const V=[R.CARDHOLDER_NAME,R.EXPIRATION_MONTH,R.PIN,R.CVV],G={X:"[0-9]"},X={visa:U.VISA.regex,mastercard:U.MASTERCARD.regex,amex:U.AMEX.regex,diners_club:U.DINERS_CLUB.regex,discover:U.DISCOVER.regex,jcb:U.JCB.regex,hipercard:U.HIPERCARD.regex,unionpay:U.UNIONPAY.regex,maestro:U.MAESTRO.regex,elo:U.ELO.regex};function z(...e){function t(e,i){if(void 0===i)return e;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))void 0!==i[s]&&(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),{})}var H,$;e.PAYMENT_METHOD_CODES=void 0,(H=e.PAYMENT_METHOD_CODES||(e.PAYMENT_METHOD_CODES={})).CARD="card",H.GOOGLE_PAY="googlePay",H.PAYPAL="payPal",H.APPLE_PAY="applePay",H.GENERIC_REDIRECT="genericRedirect",H.LEAN="lean",H.MERCADO_PAGO="mercadoPago",H.PIX="pix",H.BANK_ACCOUNT="bankAccount",H.IDEAL="iDeal",H.YAPE="yape",H.UPI="upi",H.KLARNA="klarna",H.ONE_VOUCHER="1voucher",H.ALFA="alfa",H.APLAZO="aplazo",H.BANK_TRANSFER="bankTransfer",H.CAPITEC_PAY="capitecPay",H.EASYPAISA="easypaisa",H.EFT_PRO="eftPro",H.FAWRY_PAY="fawryPay",H.JAZZ_CASH="jazzCash",H.KONNECT="konnect",H.KUESKI="kueski",H.MONO_DIRECT_DEBIT="monoDirectDebit",H.O_PAY_WALLET="oPayWallet",H.PAGA_WALLET="pagaWallet",H.PAYFLEX="payflex",H.PAY_JUST_NOW="payjustnow",H.WAFA_CASH_WALLET="wafaCashWallet",H.MERCADO_PAGO_WALLET="mercadoPagoWallet",H.MERCADO_PAGO_CONSUMER_CREDIT="mercadoPagoConsumerCredit",H.NET_BANKING="netBanking",H.CASH_FREE_WALLET="cashFreeWallet",H.PAYTM_WALLET="paytmWallet",H.NIBSS_PAY="nibssPay",H.NIBSS_INSTANT_PAY="nibssInstantPay",H.MEEZA_WALLET="meezaWallet",H.VODAFONE_CASH="vodafoneCash",H.SEPA_DIRECT_DEBIT="sepaDirectDebit",H.MODO="modo",H.PAYZONE_CASH="payzoneCash",H.REVOLUT_PAY="revolutPay",Object.fromEntries(Object.entries(e.PAYMENT_METHOD_CODES).map(([e,t])=>[e,t])),function(e){e.ENABLED="enabled",e.CREATED="created",e.DELETED="deleted",e.DISABLED="disabled",e.INVALID="invalid",e.TRANSIENT="transient"}($||($={}));const q=["customer"];class W{static get response(){if(!W._response){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND);throw r.PayrailsLogger.error(e.message,{error:e}),e}return W._response}static setResponse(e){return W._response=e,W._updatedMetaKeys=new Set,W}static get executionId(){var e;return null===(e=W._response)||void 0===e?void 0:e.id}static get workflowCode(){return W.response.workflow.code}static get lookup(){return W.response.initialResults.find(({body:{name:e}})=>"lookup"===e)}static get holderReference(){return W.response.holderReference}static get savedCreditCards(){return W.getStoredInstrumentForPaymentMethod(e.PAYMENT_METHOD_CODES.CARD)}static get savedPaypalAccounts(){return W.getStoredInstrumentForPaymentMethod(e.PAYMENT_METHOD_CODES.PAYPAL).filter(({status:e})=>e===$.ENABLED)}static get savedGooglePayAccounts(){return W.getStoredInstrumentForPaymentMethod(e.PAYMENT_METHOD_CODES.GOOGLE_PAY).filter(({status:e})=>e===$.ENABLED)}static get savedApplePayAccounts(){return W.getStoredInstrumentForPaymentMethod(e.PAYMENT_METHOD_CODES.APPLE_PAY)}static get paypalConfig(){const t=W.availablePaymentMethods.find(({paymentMethodCode:t})=>t===e.PAYMENT_METHOD_CODES.PAYPAL);if(!t){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING);throw r.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:W.availablePaymentMethods}}),e}return t.config||{}}static get googlePayConfig(){var t;const i=W.availablePaymentMethods.find(({paymentMethodCode:t})=>t===e.PAYMENT_METHOD_CODES.GOOGLE_PAY);if(!i){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING);throw r.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:W.availablePaymentMethods}}),e}const n=i;return(null===(t=n.clientConfig)||void 0===t?void 0:t.additionalConfig)&&void 0!==n.clientConfig.additionalConfig.apiVersion?n.clientConfig.additionalConfig:[n.config]}static isPaymentMethodAvailable(e){return W.availablePaymentMethods.some(({paymentMethodCode:t})=>t===e)}static get applePayConfig(){const t=W.availablePaymentMethods.find(({paymentMethodCode:t})=>t===e.PAYMENT_METHOD_CODES.APPLE_PAY);if(!t){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING);throw r.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:W.availablePaymentMethods}}),e}return t.config.parameters}static get url(){return W.response.links.self}static get meta(){return W.response.meta}static get availablePaymentMethods(){var e;return(null===(e=W.lookup)||void 0===e?void 0:e.body.data.paymentCompositionOptions)||[]}static get authorizeLink(){var e,t;return null===(t=null===(e=W.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=W.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=W.response.links.startPaymentSession)||void 0===e?void 0:e.href}static get createInstrumentLink(){var e;return null===(e=W.response.links.createInstrument)||void 0===e?void 0:e.href}static get storedPaymentInstruments(){return W.availablePaymentMethods.flatMap(e=>e.paymentInstruments||[]).filter(({paymentMethod:t,status:i})=>{const n=[e.PAYMENT_METHOD_CODES.GOOGLE_PAY,e.PAYMENT_METHOD_CODES.PAYPAL];return i===$.ENABLED||!n.includes(t)})}static get storedDropinInstruments(){return W.storedPaymentInstruments.filter(({paymentMethod:t})=>![e.PAYMENT_METHOD_CODES.GOOGLE_PAY,e.PAYMENT_METHOD_CODES.APPLE_PAY].includes(t))}static getFullPaymentMethodConfig(e){return W.availablePaymentMethods.find(({paymentMethodCode:t})=>t===e)}static isAddressSelectorEnabled(e){var t,i;return!!W._response&&(null===(i=null===(t=W.getFullPaymentMethodConfig(e))||void 0===t?void 0:t.clientConfig)||void 0===i?void 0:i.supportsBillingInfo)}static isPaymentInstallmentsEnabled(e){var t;if(W._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(e){const{paymentInstruments:i}=e;return t(e,["paymentInstruments"])}static updateInstallmentOptions(t){const i=W.getFullPaymentMethodConfig(e.PAYMENT_METHOD_CODES.CARD);(null==i?void 0:i.clientConfig)&&(i.clientConfig.installments=t)}static updateMeta(e,t){if(!q.includes(e))return;const i=W.response.meta||{},n=z(i[e]||{},t);W._response=Object.assign(Object.assign({},W.response),{meta:Object.assign(Object.assign({},i),{[e]:n})}),W._updatedMetaKeys.add(e)}static getAllowedMeta(){const e=W.response.meta||{};return W.pickMetaByKeys(e,q)}static getUpdatedMeta(){const e=W.response.meta||{};return W.pickMetaByKeys(e,W._updatedMetaKeys)}static pickMetaByKeys(e,t){const i={};for(const n of t){const t=e[n];void 0!==t&&(i[n]=t)}return i}}var K,Z;W._updatedMetaKeys=new Set,function(e){e.REDIRECT="redirect",e.DIRECT="direct",e.EMBEDDED="embedded"}(K||(K={})),e.INTEGRATION_TYPE=void 0,(Z=e.INTEGRATION_TYPE||(e.INTEGRATION_TYPE={})).API="api",Z.HPP="hpp";class J{constructor(){this._config=void 0}static getInstance(){return J._instance||(J._instance=new J),J._instance}set config(e){try{J.getInstance()._config=e}catch(e){r.PayrailsLogger.error("Error parsing SDK Configuration",{error:e})}}get config(){return J.getInstance()._config||r.PayrailsLogger.error("SDK Configuration not set"),J.getInstance()._config||{}}}const Q=()=>J.getInstance().config,ee=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));J.getInstance().response=e,J.getInstance().config=t,t.execution&&W.setResponse(t.execution)}catch(e){r.PayrailsLogger.error("Error parsing SDK Configuration",{error:e})}},te=[];for(let e=0;e<256;++e)te.push((e+256).toString(16).slice(1));let ie;const ne=new Uint8Array(16);var se,oe={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function re(e,t,i){if(oe.randomUUID&&!e)return oe.randomUUID();const n=(e=e||{}).random??e.rng?.()??function(){if(!ie){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ie=crypto.getRandomValues.bind(crypto)}return ie(ne)}();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=15&n[6]|64,n[8]=63&n[8]|128,function(e,t=0){return(te[e[t+0]]+te[e[t+1]]+te[e[t+2]]+te[e[t+3]]+"-"+te[e[t+4]]+te[e[t+5]]+"-"+te[e[t+6]]+te[e[t+7]]+"-"+te[e[t+8]]+te[e[t+9]]+"-"+te[e[t+10]]+te[e[t+11]]+te[e[t+12]]+te[e[t+13]]+te[e[t+14]]+te[e[t+15]]).toLowerCase()}(n)}!function(e){e.GET="GET",e.POST="POST",e.DELETE="DELETE",e.PATCH="PATCH"}(se||(se={}));const ae=e=>i(void 0,[e],void 0,function*({url:e,method:t=se.GET,token:i="",body:n}){const s={method:t,headers:Object.assign(Object.assign(Object.assign({},pe()),he(i)),_e())};t!==se.POST&&t!==se.PATCH||(s.body=JSON.stringify(n||{}));const o=yield fetch(e,s);if([401,403].includes(o.status))throw new le(e,t);if(429===o.status)throw new ce(e,t);if(!o.ok)throw new de(e,t);const r=yield o.json();return{ok:o.ok,req:Object.assign({url:e},s),res:r}});class le extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_UNAUTHORIZED,{description:`[${t}] ${e} unauthorized`})}}let de=class extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{description:`[${t}] ${e} unsuccessful`})}},ce=class extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} too many requests`})}};class ue extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} max poll attempts exceeded.`})}}const he=e=>({authorization:`Bearer ${e}`}),pe=()=>({"x-idempotency-key":re()}),_e=()=>{const e={version:"5.47.1",type:"web-sdk"};return{"x-client-version":e.version,"x-client-type":e.type}},Ee=e=>i(void 0,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=Q().links)||void 0===t?void 0:t.binLookup)||void 0===i?void 0:i.href;if(!n)return{bin:e};try{const t=yield((e,t,i)=>ae({url:e,method:se.POST,token:t,body:{bin:i}}))(n,Q().token,e);return t.res}catch(t){const i=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_BIN_LOOKUP_FAILED,{description:"Error fetching BIN lookup data!",cause:t});return r.PayrailsLogger.error(i.message,{error:i}),{bin:e}}}),me=({url:e,token:t,body:i})=>ae({url:e,token:t,method:se.POST,body:i}),ve=(e,t)=>i(void 0,void 0,void 0,function*(){var i,n;const s=yield e(),a=Q().vaultConfiguration.links.saveInstrument.href,l=Q().token;if(!a){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND,{description:"Save instrument URL not available!"});throw r.PayrailsLogger.error(e.message,{error:e}),e}const d={holderReference:Q().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",data:{encryptedData:s.encryptedData,vaultProviderConfigId:s.vaultProviderConfigId}};return(yield me({url:a,token:l,body:d})).res});e.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",e.CARD_FORM="CARD_FORM"}(e.ElementType||(e.ElementType={}));class ye{constructor(e,t){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=>i(this,void 0,void 0,function*(){return Ee(e)}),this.cardTableName=t.cardTableName||"cards",this.containerType=t.containerType||"COMPOSABLE",this.isBinLookupEnabled=!!(null===(n=Q().links)||void 0===n?void 0:n.binLookup);try{this.__container=e.container(this.containerType,t)}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CREATION_FAILED,{cause:e});r.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 ye(e,t),this.instance}createCollectElement(t){var i;const n={required:!!t.required,enableCardIcon:!1!==t.enableCardIcon},s=null===(i=this.__container)||void 0===i?void 0:i.create(Object.assign(Object.assign({table:this.cardTableName,labelStyles:{},errorTextStyles:{},column:this.elementToFieldMap.get(t.type)},t),{type:t.type===e.ElementType.CARDHOLDER_NAME?"INPUT_FIELD":t.type}),t.format?Object.assign(Object.assign({},n),{format:t.format}):n);if(!s){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING,{description:"Error creating collect element!"});throw r.PayrailsLogger.error(e.message,{error:e}),e}return this.attachCustomEventHandler(s)}mount(e){if("COLLECT"===this.containerType){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw r.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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING);throw r.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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);r.PayrailsLogger.error(t.message,{error:t})}}unmount(){this.element&&this.element.remove()}validate(){return i(this,void 0,void 0,function*(){var e;return yield null===(e=this.__container)||void 0===e?void 0:e.validate()})}collect(){return i(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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_OPERATION_FAILED,{description:"Error collecting data from the iframe!",cause:t});throw t.name!==o.ERROR_CODES.PAYRAILS_CARD_FORM_COMPLETE_AND_VALID_INPUTS&&r.PayrailsLogger.error(i.message,{error:i}),i}})}reset(){var e;null===(e=this.__container)||void 0===e||e.reset()}collectPayrailsData(){return i(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:Q().vaultConfiguration.providerConfigId})})}tokenize(e){return i(this,void 0,void 0,function*(){return ve(()=>this.collect(),e)})}attachCustomEventHandler(t){return new Proxy(t,{get:(t,i)=>{const n=t[i];return"on"===i?((n,s)=>{t[i].call(t,n,i=>{"CHANGE"===n?(this.manualErrorElements.has(t)&&!i.isEmpty&&("resetError"in t&&"function"==typeof t.resetError&&t.resetError(),this.manualErrorElements.delete(t)),i.elementType===e.ElementType.CARD_NUMBER&&(i.network=function(e){for(const[t,i]of Object.entries(X))if(i.test(e))return t;return""}(i.value),i.bin=this.formatBin(i.value),this.bin=this.formatBin(i.value)),s(i)):s(i)})}).bind(t):"setError"===i?(...e)=>(this.manualErrorElements.add(t),n.apply(t,e)):"function"==typeof n?n.bind(t):n}})}formatBin(e){return e.replace(/[-X]/g,"").slice(0,8)}get elementToFieldMap(){return new Map([[e.ElementType.CARD_NUMBER,"card_number"],[e.ElementType.CARDHOLDER_NAME,"cardholder_name"],[e.ElementType.CVV,"security_code"],[e.ElementType.EXPIRATION_MONTH,"expiry_month"],[e.ElementType.EXPIRATION_YEAR,"expiry_year"],[e.ElementType.EXPIRATION_DATE,"expiry_date"]])}}var Ie={};!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;function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var a,l,d,c,u,h,p,_,E,m,v,y,I,f,A={},L={},O={},g={},T={},C={},R={},N={},S={},P={},b={},D={},M={};function w(){if(v)return M;v=1,Object.defineProperty(M,"__esModule",{value:!0}),M.Framebus=void 0;var e=z(),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 M.Framebus=i,M}function k(){if(f)return D;f=1;var e=D&&D.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(D,"__esModule",{value:!0}),D.subscribeReplier=void 0;var t=w(),i=e((I||(I=1,y=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)})}),y));return D.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},D}var Y,U,F,x,j,B,V={},G={},X={};function z(){return x||(x=1,function(e){var t=A&&A.__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=A&&A.__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(a)return L;a=1,Object.defineProperty(L,"__esModule",{value:!0}),L.detach=L.attach=void 0;var e=z(),t=!1;return L.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},L.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},L}(),e),i(function(){if(l)return O;l=1,Object.defineProperty(O,"__esModule",{value:!0}),O.broadcastToChildWindows=void 0;var e=z();return O.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})}},O}(),e),i(function(){if(d)return g;d=1,Object.defineProperty(g,"__esModule",{value:!0}),g.broadcast=void 0;var e=z();return g.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){}},g}(),e),i((c||(c=1,Object.defineProperty(T,"__esModule",{value:!0}),T.subscribers=T.childWindows=T.prefix=void 0,T.prefix="/*framebus*/",T.childWindows=[],T.subscribers={}),T),e),i(function(){if(u)return C;u=1,Object.defineProperty(C,"__esModule",{value:!0}),C.dispatch=void 0;var e=z();return C.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)}},C}(),e),i((h||(h=1,Object.defineProperty(R,"__esModule",{value:!0}),R.hasOpener=void 0,R.hasOpener=function(e){return e.top===e&&null!=e.opener&&e.opener!==e&&!0!==e.opener.closed}),R),e),i((p||(p=1,Object.defineProperty(N,"__esModule",{value:!0}),N.isntString=void 0,N.isntString=function(e){return"string"!=typeof e}),N),e),i(function(){if(_)return S;_=1,Object.defineProperty(S,"__esModule",{value:!0}),S.onMessage=void 0;var e=z();return S.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)}}},S}(),e),i(function(){if(E)return P;E=1,Object.defineProperty(P,"__esModule",{value:!0}),P.packagePayload=void 0;var e=z();return P.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},P}(),e),i((m||(m=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(k(),e),i(function(){if(Y)return V;Y=1,Object.defineProperty(V,"__esModule",{value:!0}),V.subscriptionArgsInvalid=void 0;var e=z();return V.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},V}(),e),i((U||(U=1,Object.defineProperty(G,"__esModule",{value:!0})),G),e),i(function(){if(F)return X;F=1,Object.defineProperty(X,"__esModule",{value:!0}),X.unpackPayload=void 0;var e=z();return X.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},X}(),e)}(A)),A}const H=r(function(){if(B)return j;B=1;var e=z(),t=w();return(0,e.attach)(),j=t.Framebus}());class ${constructor(e){this.origin=null,this.onAndEmit=(e,t,i="*")=>{const n=`${e}-REQ`,s=n=>{return s=this,o=null,r=function*(){const s=yield t(n);this.bus.target({origin:i}).emit(`${e}-RES`,s)},new Promise((e,t)=>{var i=e=>{try{a(r.next(e))}catch(e){t(e)}},n=e=>{try{a(r.throw(e))}catch(e){t(e)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,n);a((r=r.apply(s,o)).next())});var s,o,r};return this.bus.on(n,s),()=>this.bus.off(n,s)},this.emitAndResolve=(e,t,r="*",a)=>new Promise((l,d)=>{if(null==a?void 0:a.aborted)return void d(a.reason);const c=`${e}-RES`,u=e=>{p(),l(e)},h=()=>{p(),d(a.reason)},p=()=>{this.bus.off(c,u),null==a||a.removeEventListener("abort",h)};this.bus.on(c,u),null==a||a.addEventListener("abort",h),this.bus.target({origin:r}).emit(`${e}-REQ`,((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})({},t))}),this.bus=new H(e)}static getInstance(){return $.instance||($.instance=new $),$.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)}}var q=(e=>(e.BUTTON_CLICK_VALIDATE="BUTTON_CLICK_VALIDATE",e.COLLECT="COLLECT",e.READY="READY",e.SHOW="SHOW",e.CHANGE="CHANGE",e.FOCUS="FOCUS",e.BLUR="BLUR",e.ERROR="ERROR",e.COLLECT_ERROR="COLLECT_ERROR",e.FOCUS_ELEMENT="FOCUS_ELEMENT",e.SET_ERROR="SET_ERROR",e.UPDATE="UPDATE",e.SET_ATTRIBUTE="SET_ATTRIBUTE",e.VALIDATE="VALIDATE",e.RESET="RESET",e.SUBMIT="SUBMIT",e.RESIZE="RESIZE",e.IS_AVAILABLE="IS_AVAILABLE",e))(q||{}),W=(e=>(e.Collect="COLLECT",e.Display="DISPLAY",e))(W||{}),K=(e=>(e.GooglePay="GOOGLE_PAY",e.CardForm="CARD_FORM",e.CardNumber="CARD_NUMBER",e.ExpiryYear="EXPIRATION_YEAR",e.ExpiryMonth="EXPIRATION_MONTH",e.ExpiryDate="EXPIRATION_DATE",e.SecurityCode="CVV",e.CardHolderName="CARDHOLDER_NAME",e))(K||{});e.COLLECT_FRAME_EVENT_NAMES=q,e.IframeEventBus=$,e.SecureFrameMode=W,e.SecureFrameType=K,e.getEventBus=()=>$.getInstance()}(Ie);class fe{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(fe.prototype,{constructor:e})}}
2
2
  /* @copyright
3
3
  Copyright (c) 2022 Skyflow, Inc.
4
- */const Ie={IFRAME_SECURE_SITE:"https://js.skyflow.com/v1/elements/index.html",IFRAME_SECURE_ORGIN:"https://js.skyflow.com"},fe="https://assets.payrails.io/739d580/card/index.html",Ae="https://assets.payrails.io",Le={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no",style:"width: 100%;",allow:"clipboard-read; clipboard-write"},ge=(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 Oe=(e={})=>{const t=document.createElement("iframe"),i=Object.assign(Object.assign({},Le),e);return Object.assign(t.style,M),ge(t,i),t.getAttribute("id")||(t.id=t.name),t};const Te=()=>Ie.IFRAME_SECURE_SITE,Ce=(e,t)=>{Object.keys(t).forEach(i=>{Object.prototype.hasOwnProperty.call(t,i)&&(e.style[i]=t[i])})};function Re(e){return JSON.parse(JSON.stringify(e))}var Ne,Se,Pe,be,De,Me,we;!function(e){e.DEFAULT="DEFAULT",e.PLAIN_TEXT="PLAIN_TEXT",e.MASKED="MASKED",e.REDACTED="REDACTED"}(Ne||(Ne={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH",e.DELETE="DELETE"}(Se||(Se={})),function(e){e.CHANGE="CHANGE",e.READY="READY",e.FOCUS="FOCUS",e.BLUR="BLUR",e.SUBMIT="SUBMIT"}(Pe||(Pe={})),function(e){e.WARN="WARN",e.INFO="INFO",e.DEBUG="DEBUG",e.ERROR="ERROR"}(be||(be={})),function(e){e.DEV="DEV",e.PROD="PROD"}(De||(De={})),function(e){e.LOG="LOG",e.WARN="WARN",e.ERROR="ERROR"}(Me||(Me={})),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"}(we||(we={}));const ke={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}},Ye={PROD:{doesReturnValue:!1},DEV:{doesReturnValue:!0}},Ue="[Skyflow]",Fe=(e,t,i)=>{if(i&&ke[i]){const{showDebugLogs:n,showInfoLogs:s,showWarnLogs:o,showErrorLogs:r}=ke[i];t===Me.LOG&&n?console.log(`${be.DEBUG}: ${Ue} ${e}`):t===Me.LOG&&s?console.log(`${be.INFO}: ${Ue} ${e}`):t===Me.WARN&&o?console.warn(`${be.WARN}: ${Ue} ${e}`):t===Me.ERROR&&r&&console.error(`${be.ERROR}: ${Ue} ${e}`)}},xe=(...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]}):""},je=(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},Be=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_RECORDS_KEY_MISSING_IN_ADDITIONAL_FIELDS);const{records:t}=e;if(!t||!Array.isArray(t))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_RECORDS_IN_ADDITIONAL_FIELDS);if(0===t.length)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_RECORDS_IN_ADDITIONAL_FIELDS);t.forEach((e,t)=>{var i,n,s,r;if(!e||!Object.prototype.hasOwnProperty.call(e,"table"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_TABLE_IN_ADDITIONAL_FIELDS);if(!e.table)throw new o.PayrailsError(o.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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_SKYFLOW_ID);if(!("string"==typeof(null===(s=e.fields)||void 0===s?void 0:s.skyflowID)||(null===(r=e.fields)||void 0===r?void 0:r.skyflowID)instanceof String))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_SKYFLOW_ID)}if(!("string"==typeof e.table||e.table instanceof String))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_IN_ADDITIONAL_FIELDS);if(!Object.prototype.hasOwnProperty.call(e,"fields"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_FIELDS_IN_ADDITIONAL_FIELDS);if(!e.fields)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_FIELDS_IN_ADDITIONAL_FIELDS);if("object"!=typeof e.fields||Array.isArray(e.fields))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_FIELDS_IN_ADDITIONAL_FIELDS)})},Ve=e=>{let t=!0;try{new RegExp(e)}catch(e){t=!1}return t},Ge=e=>{if(!Object.prototype.hasOwnProperty.call(e,"getBearerToken"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_GET_BEARER_TOKEN_MISSING)},Xe=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_ELEMENT_TYPE);if(!e.type)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_TYPE);if(Object.prototype.hasOwnProperty.call(e,"altText")&&Fe(d.COLLECT_ALT_TEXT_DEPERECATED,Me.WARN,t),Object.prototype.hasOwnProperty.call(e,"skyflowID")&&"string"!=typeof e.skyflowID)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_SKYFLOW_ID)},ze=e=>{if(!e||!Array.isArray(e))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_UPSERT_OPTION_TYPE);if(!e.length)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_UPSERT_OPTIONS_ARRAY);e.forEach((e,t)=>{if(!e||"object"!=typeof e)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_UPSERT_OPTION_OBJECT_TYPE);if(!Object.prototype.hasOwnProperty.call(e,"table"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_TABLE_IN_UPSERT_OPTION);if(!e.table||"string"!=typeof e.table||!e.table.length)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_IN_UPSERT_OPTION);if(!Object.prototype.hasOwnProperty.call(e,"column"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_COLUMN_IN_UPSERT_OPTION);if(!e.column||"string"!=typeof e.column||!e.column.length)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COLUMN_IN_UPSERT_OPTION)})},He=e=>"boolean"==typeof e;function qe(e){const t=e.split(":");return t.length>2?(t.pop(),t.pop(),t.join(":")):""}const We=(e,t,i)=>{if("string"!=typeof e)return e;if(t===R.CARD_NUMBER){if(e=e&&e.replace(/\s/g,""),!i){((e="")=>{const t=e.replace(/[\s-]/g,"");let i=S.DEFAULT;Object.entries(U).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 Ke(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;Ie.IFRAME_SECURE_ORGIN=`${o}//${r}`,Ie.IFRAME_SECURE_SITE=null===(s=null==e?void 0:e.options)||void 0===s?void 0:s.customElementsURL}Ie.IFRAME_SECURE_ORGIN=Ae,Ie.IFRAME_SECURE_SITE=fe}class $e{constructor(e,t,i,n){this.setAttributess=e=>{ge(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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_SELECTOR)}else{if(!(e instanceof HTMLElement))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_SELECTOR);this.container=e}}catch(e){console.error(e)}ge(this.iframe,{src:Te(),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=Oe({name:this.name})}}class Ze{}var Je,Qe,et,tt,it,nt,st,ot,rt,at,lt,dt,ct,ut,ht,pt,_t,Et,mt,vt,yt;const It="Element";class ft extends Ze{constructor(e,i,r,l,d=!1,c,u,h,E){var m;super(),this.type=Di.COLLECT,Je.set(this,void 0),Qe.set(this,!1),et.set(this,void 0),tt.set(this,void 0),it.set(this,{isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:void 0,isRequired:!1}),nt.set(this,void 0),st.set(this,new ye),ot.set(this,void 0),rt.set(this,ve.getEventBus()),at.set(this,void 0),lt.set(this,[]),dt.set(this,!1),ct.set(this,void 0),ut.set(this,void 0),ht.set(this,!1),this.getID=()=>n(this,Je,"f"),this.mount=e=>{var i;if(!e)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_IN_MOUNT);const r=(e,i)=>{if(e.name===n(this,at,"f").name){i(n(this,nt,"f")),n(this,yt,"f").call(this);const e=n(this,et,"f")[0],{name:o}=e,l=t(e,["name"]);n(this,tt,"f").length>1?n(this,tt,"f").forEach((e,t)=>{n(this,ot,"f")&&n(this,ot,"f")._emit(`${p.READY}:${e.elementName}`,Object.assign(Object.assign({},n(this,et,"f")[t]),{elementType:e.elementType}))}):n(this,st,"f")._emit(p.READY,Object.assign({},l)),n(this,rt,"f").off(_+this.containerId,r),Fe(`${xe(a.ELEMENT_MOUNTED,It,je(n(this,at,"f").name))} `,Me.LOG,n(this,ct,"f").logLevel),n(this,lt,"f").forEach(e=>e()),s(this,lt,[],"f")}};if(n(this,tt,"f").length>1)n(this,at,"f").mount(e),n(this,rt,"f").on(_+this.containerId,r);else{if(n(this,ht,"f"))return n(this,at,"f").mount(e),void n(this,rt,"f").on(_+this.containerId,r);null===(i=n(this,ot,"f"))||void 0===i||i.on(C,t=>{(null==t?void 0:t.containerId)===this.containerId&&(n(this,at,"f").mount(e),n(this,rt,"f").on(_+this.containerId,r))})}},this.unmount=()=>{n(this,rt,"f").off(v,n(this,mt,"f")),n(this,at,"f").unmount()},this.update=e=>{let t=Re(e);const i=()=>{n(this,Qe,"f")&&(t={rows:[{elements:[Object.assign({},t)]}]}),s(this,nt,Lt(n(this,nt,"f"),t),"f"),s(this,tt,gt(n(this,nt,"f")),"f"),n(this,Qe,"f")?n(this,rt,"f").emit(I,{name:n(this,at,"f").name,options:n(this,tt,"f")[0],isSingleElementAPI:!0}):(n(this,tt,"f").forEach(e=>{n(this,rt,"f").emit(I,{name:e.elementName,options:e,isSingleElementAPI:!0})}),n(this,rt,"f").emit(I,{name:n(this,at,"f").name,options:n(this,nt,"f"),isSingleElementAPI:!1})),n(this,yt,"f").call(this)};n(this,dt,"f")?i():n(this,lt,"f").push(i)},pt.set(this,e=>{n(this,Qe,"f")||n(this,st,"f").on(I,()=>{e(n(this,tt,"f"))},!0)}),this.updateElement=e=>{n(this,rt,"f").emit(I,{name:e.elementName,options:e,isSingleElementAPI:!0})},_t.set(this,()=>{n(this,et,"f").forEach((e,t)=>{var i;if(0===t){n(this,it,"f").isEmpty=e.isEmpty,n(this,it,"f").isComplete=e.isComplete,n(this,it,"f").isValid=e.isValid,n(this,it,"f").isFocused=e.isFocused,n(this,it,"f").isRequired=e.isRequired,n(this,it,"f").value={};const i=n(this,tt,"f")[t].elementName,s=e.value&&We(e.value,e.elementType,n(this,ut,"f"));n(this,Qe,"f")?n(this,it,"f").value=s:n(this,it,"f").value[i]=s}else n(this,it,"f").isEmpty=n(this,it,"f").isEmpty||e.isEmpty,n(this,it,"f").isComplete=n(this,it,"f").isComplete&&e.isComplete,n(this,it,"f").isValid=n(this,it,"f").isValid&&e.isValid,n(this,it,"f").isFocused=n(this,it,"f").isFocused||e.isFocused,n(this,it,"f").isRequired=n(this,it,"f").isRequired||e.isRequired,n(this,it,"f").value||(n(this,it,"f").value={}),!n(this,tt,"f")[t]&&(null===(i=n(this,tt,"f")[t])||void 0===i?void 0:i.sensitive)&&(n(this,it,"f").value[n(this,tt,"f")[t].elementName]=e.value||"")})}),this.getState=()=>({isEmpty:n(this,it,"f").isEmpty,isComplete:n(this,it,"f").isComplete,isValid:n(this,it,"f").isValid,isFocused:n(this,it,"f").isFocused,value:n(this,it,"f").value,required:n(this,it,"f").isRequired}),this.getOptions=()=>{let e=Re(n(this,nt,"f"));return n(this,Qe,"f")?e=e.rows[0].elements[0]:e.rows.forEach(e=>{e.elements.forEach(e=>{delete e.elementName})}),delete e.elementName,e},Et.set(this,e=>{n(this,st,"f").on(y,()=>{const t=n(this,tt,"f").map(e=>e.elementName);n(this,Qe,"f")||t.push(n(this,at,"f").name),e(t)},!0)}),mt.set(this,e=>{if(n(this,Qe,"f")&&e.event===p.READY&&e.name===n(this,at,"f").name)n(this,st,"f")._emit(p.READY);else{const t=n(this,tt,"f").length>1;n(this,tt,"f").forEach((i,s)=>{var r;if(e.name===i.elementName){let a="";switch(e.event){case p.FOCUS:a=p.FOCUS;break;case p.BLUR:a=p.BLUR;break;case p.CHANGE:a=p.CHANGE;break;case p.READY:a=p.READY;break;case p.SUBMIT:return void(null===(r=n(this,ot,"f"))||void 0===r||r._emit(p.SUBMIT));default:throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_TYPE)}n(this,et,"f")[s].isEmpty=e.value.isEmpty,n(this,et,"f")[s].isValid=e.value.isValid,n(this,et,"f")[s].isComplete=e.value.isComplete,n(this,et,"f")[s].isFocused=e.value.isFocused,n(this,et,"f")[s].isRequired=e.value.isRequired,Object.prototype.hasOwnProperty.call(e.value,"value")?n(this,et,"f")[s].value=e.value.value:n(this,et,"f")[s].value=void 0,a=t?`${a}:${e.name}`:a,n(this,rt,"f").emit(p.HEIGHT+n(this,at,"f").name,{},e=>{(null==e?void 0:e.height)>0&&n(this,at,"f").setIframeHeight(e.height)}),n(this,_t,"f").call(this);const l=Object.assign(Object.assign({},n(this,et,"f")[s]),{elementType:i.elementType});t&&n(this,ot,"f")?n(this,ot,"f")._emit(a,l):n(this,st,"f")._emit(a,l)}})}}),vt.set(this,()=>{n(this,rt,"f").on(v,n(this,mt,"f"))}),yt.set(this,()=>{const{rows:e}=n(this,nt,"f");e.forEach(e=>{e.elements.forEach(e=>{e.elementType!==b.radio.name&&e.elementType!==b.checkbox.name&&(e.value=void 0)})}),s(this,tt,gt(n(this,nt,"f")),"f")}),this.containerId=l.containerId,s(this,Je,e,"f"),s(this,ct,h,"f"),s(this,nt,Lt(i),"f"),s(this,tt,gt(i),"f"),s(this,Qe,d,"f"),E&&s(this,ot,E,"f"),s(this,ut,Ye[n(this,ct,"f").env].doesReturnValue,"f"),this.elementType=n(this,Qe,"f")?n(this,tt,"f")[0].elementType:"group",s(this,et,[],"f"),n(this,tt,"f").forEach(e=>{n(this,et,"f").push({isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:n(this,ut,"f")?"":void 0,elementType:e.elementType,name:e.elementName,isRequired:!1})}),s(this,at,new $e(n(this,nt,"f").elementName,r,this.containerId,n(this,ct,"f").logLevel),"f"),n(this,vt,"f").call(this),n(this,Et,"f").call(this,c),n(this,pt,"f").call(this,u),Fe(xe(a.CREATED_ELEMENT,It,je(n(this,at,"f").name)),Me.LOG,n(this,ct,"f").logLevel),s(this,ht,l.isMounted,"f"),null===(m=n(this,ot,"f"))||void 0===m||m.on(C,e=>{(null==e?void 0:e.containerId)===this.containerId&&s(this,ht,!0,"f")});const f=e=>{e.height&&e.height>0&&n(this,at,"f").setIframeHeight(e.height)};n(this,rt,"f").on(p.MOUNTED,e=>{l.type===Di.COMPOSABLE?n(this,tt,"f").forEach(t=>{e.name===t.elementName&&(t.isMounted=!0,s(this,dt,!0,"f"))}):e.name===n(this,tt,"f")[0].elementName&&(n(this,tt,"f")[0].isMounted=!0,s(this,dt,!0,"f")),n(this,rt,"f").emit(p.HEIGHT+n(this,at,"f").name,{},f)})}on(e,t){if(!Object.values(p).includes(e))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_LISTENER);if(!t)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_HANDLER_IN_EVENT_LISTENER);if("function"!=typeof t)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_HANDLER_IN_EVENT_LISTENER);n(this,st,"f").on(e,e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,t(e)})}iframeName(){return n(this,at,"f").name}isMounted(){return n(this,dt,"f")}isValidElement(){for(let e=0;e<n(this,tt,"f").length;e+=1){if(!Object.prototype.hasOwnProperty.call(n(this,tt,"f")[e],"table"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_TABLE_NAME_MISSING);if(!n(this,tt,"f")[e].table)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_TABLE);if(!("string"==typeof n(this,tt,"f")[e].table||n(this,tt,"f")[e].table instanceof String))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_NAME);if(!Object.prototype.hasOwnProperty.call(n(this,tt,"f")[e],"column"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_COLUMN);if(!n(this,tt,"f")[e].column)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_COLUMN);if(!("string"==typeof n(this,tt,"f")[e].column||n(this,tt,"f")[e].column instanceof String))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COLUMN);if(void 0!==n(this,tt,"f")[e].skyflowID&&!n(this,tt,"f")[e].skyflowID)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_SKYFLOW_ID)}return!0}setError(e){n(this,rt,"f").emit(L,{name:qe(n(this,at,"f").name),isTriggerError:!0,clientErrorText:e})}resetError(){n(this,rt,"f").emit(L,{name:qe(n(this,at,"f").name),isTriggerError:!1})}setValue(e){n(this,ct,"f").env!==De.PROD?n(this,Qe,"f")&&n(this,rt,"f").emit(I,{name:n(this,at,"f").name,options:Object.assign(Object.assign({},n(this,tt,"f")[0]),{value:e}),isSingleElementAPI:!0}):Fe(xe(d.UNABLE_TO_SET_VALUE_IN_PROD_ENV,n(this,tt,"f")[0].elementType),Me.WARN,n(this,ct,"f").logLevel)}clearValue(){n(this,ct,"f").env!==De.PROD?n(this,Qe,"f")&&n(this,rt,"f").emit(I,{name:n(this,at,"f").name,options:Object.assign(Object.assign({},n(this,tt,"f")[0]),{value:""}),isSingleElementAPI:!0}):Fe(xe(d.UNABLE_TO_CLEAR_VALUE_IN_PROD_ENV,n(this,tt,"f")[0].elementType),Me.WARN,n(this,ct,"f").logLevel)}setAttribute(e,t){n(this,rt,"f").emit(f,{name:n(this,at,"f").name,attribute:e,value:t})}focus(){var e;if(!(null===(e=n(this,tt,"f"))||void 0===e?void 0:e.length))return;const t=this.getState();n(this,rt,"f").emit(v,{name:n(this,tt,"f")[0].elementName,event:p.FOCUS,value:{isEmpty:t.isEmpty,isValid:t.isValid,isComplete:t.isComplete,isFocused:!0,isRequired:t.required,value:t.value}})}}function At(e,t,i={}){if("group"!==e&&!Object.prototype.hasOwnProperty.call(b,e))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_TYPE);if(Object.prototype.hasOwnProperty.call(t,"validations")){if(!Array.isArray(t.validations))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATIONS_TYPE);t.validations.forEach((e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_VALIDATION_RULE_TYPE);if(!Object.values(we).includes(e.type))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATION_RULE_TYPE);if(!Object.prototype.hasOwnProperty.call(e,"params"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_VALIDATION_RULE_PARAMS);if("object"!=typeof e.params||Array.isArray(e.params)||null===e.params)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATION_RULE_PARAMS);if(e.type===we.REGEX_MATCH_RULE){if(!Object.prototype.hasOwnProperty.call(e.params,"regex"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_REGEX_IN_REGEX_MATCH_RULE)}else if(e.type===we.LENGTH_MATCH_RULE&&!Object.prototype.hasOwnProperty.call(e.params,"min")&&!Object.prototype.hasOwnProperty.call(e.params,"max"))throw new o.PayrailsError(o.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}=b[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===b.radio.name||e===b.checkbox.name)&&!i.value)throw new Error("Elements radio and checkbox requires value attribute");if(!(e!==b.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 Lt(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],d=e;if(d.elementType&&a.elementType!==d.elementType&&a.elementName&&a.elementName!==d.elementName)throw new Error(l.CANNOT_CHANGE_ELEMENT);At(a.elementType,a,d),o.elements[t]=Object.assign(Object.assign(Object.assign({},a),d),{elementName:a.elementName});const c=d.classes||{},u=d.styles||{};u.base=Object.assign(Object.assign({},k),u.base),d.classes=c,d.styles=u;const h=(null===(n=null==d?void 0:d.labelStyles)||void 0===n?void 0:n.classes)||{},p=(null===(s=null==d?void 0:d.labelStyles)||void 0===s?void 0:s.styles)||{};i&&function(e,t){Object.values(Y).forEach(i=>{if(e[i]||t[i])switch(i){case Y.BASE:t[i]=Object.assign({},t[i]);break;case Y.FOCUS:t[Y.BASE]=Object.assign(Object.assign({},t[Y.BASE]),{":focus":Object.assign({},t[Y.BASE]&&t[Y.BASE][":focus"])});break;case Y.WEBPACKAUTOFILL:t[Y.BASE]=Object.assign(Object.assign({},t[Y.BASE]),{":-webkit-autofill":Object.assign({},t[Y.BASE]&&t[Y.BASE][":-webkit-autofill"])});break;default:t[i]=Object.assign(Object.assign({},t[Y.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`)})})}(h,p),d.labelStyles={labelClasses:h},d.labelStyles.styles=p})}),t}Je=new WeakMap,Qe=new WeakMap,et=new WeakMap,tt=new WeakMap,it=new WeakMap,nt=new WeakMap,st=new WeakMap,ot=new WeakMap,rt=new WeakMap,at=new WeakMap,lt=new WeakMap,dt=new WeakMap,ct=new WeakMap,ut=new WeakMap,ht=new WeakMap,pt=new WeakMap,_t=new WeakMap,Et=new WeakMap,mt=new WeakMap,vt=new WeakMap,yt=new WeakMap;const gt=e=>{const{rows:t}=e,i=[];return t.forEach(e=>{e.elements.forEach(e=>{i.push(e)})}),i},Ot=e=>{const t=e.validations;return t&&Array.isArray(t)&&t.length>0&&t.forEach((e,t)=>{if(e&&e.type===we.ELEMENT_VALUE_MATCH_RULE){if(e.params&&!Object.prototype.hasOwnProperty.call(e.params,"element"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE);if(e.params&&(null==e.params.element||!(e.params.element instanceof ft)))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE);e.params&&e.params.element&&e.params.element instanceof ft&&(e.params.element=e.params.element.iframeName())}else if(e&&e.type===we.REGEX_MATCH_RULE){if(e.params&&e.params.regex&&!Ve(e.params.regex))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_REGEX_IN_REGEX_MATCH_RULE);e.params&&e.params.regex&&Ve(e.params.regex)&&(e.params.regex=e.params.regex.toString())}}),t},Tt=(e,t,i)=>{let n=Object.assign({required:!1},t);if((Object.prototype.hasOwnProperty.call(n,"format")||Object.prototype.hasOwnProperty.call(n,"translation"))&&(V.includes(e)?(Fe(xe(d.INPUT_FORMATTING_NOT_SUPPROTED,e),Me.WARN,i),null==n||delete n.format,null==n||delete n.translation):e===b.INPUT_FIELD.name&&((e=>{if(e){if(Object.prototype.hasOwnProperty.call(e,"format")&&"string"!=typeof e.format)throw new o.PayrailsError(o.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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_INPUT_OPTIONS_TRANSLATION)}})(t),n=Object.assign(Object.assign({},n),{mask:[n.format,n.translation?n.translation:G]}),null==n||delete n.format,null==n||delete n.translation)),e===b.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)===D&&(e="-"),n=Object.assign(Object.assign({},n),{cardSeperator:e}),null==n||delete n.format,null==n||delete n.translation}else if(e===b.EXPIRATION_DATE.name){let e=!1;n.format&&(e=!!(s=n.format.toUpperCase())&&x.includes(s),e||Fe(xe(d.INVALID_EXPIRATION_DATE_FORMAT,x.toString()),Me.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():F}),null==n||delete n.translation}else if(e===b.EXPIRATION_YEAR.name){let e=!1;n.format&&(e=(e=>!!e&&j.includes(e))(n.format.toUpperCase()),e||Fe(xe(d.INVALID_EXPIRATION_YEAR_FORMAT,j.toString()),Me.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():"YY"}),null==n||delete n.translation}var s;if(Object.prototype.hasOwnProperty.call(n,"enableCardIcon")&&!He(n.enableCardIcon))throw new o.PayrailsError(o.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")&&!He(n.required))throw new o.PayrailsError(o.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 Ct(){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 Rt{}var Nt,St,Pt,bt,Dt,Mt,wt,kt,Yt,Ut,Ft,xt;const jt="CollectContainer";class Bt extends Rt{constructor(e,t,i,r){super(),Nt.set(this,void 0),St.set(this,{}),Pt.set(this,void 0),bt.set(this,void 0),Dt.set(this,void 0),this.type=Di.COLLECT,Mt.set(this,void 0),wt.set(this,!1),this.create=(e,t={required:!1})=>{Xe(e,n(this,bt,"f").logLevel);const i=Ot(e),s=Tt(e.type,t,n(this,bt,"f").logLevel),o={rows:[{elements:[Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column,accept:t.allowedFileType},e),s),{validations:i})]}]};return n(this,kt,"f").call(this,o,!0)},kt.set(this,(e,t=!1)=>{const i=[],s=Re(e);if(s.rows.forEach(e=>{e.elements.forEach(e=>{const t=e,{elementType:n}=t;At(n,t),t.sensitive=t.sensitive||b[n].sensitive,t.replacePattern=t.replacePattern||b[n].replacePattern,t.mask=t.mask||b[n].mask,t.isMounted=!1,t.elementType!==b.radio.name&&t.elementType!==b.checkbox.name||(t.elementName=`${t.elementName}:${btoa(t.value)}`),t.elementName=`${u}:${t.elementType}:${btoa(Ct())}`,t.label=e.label,t.skyflowID=e.skyflowID,i.push(t)})}),s.elementName=t?i[0].elementName:`${u}:group:${btoa(s.name)}`,t&&!n(this,St,"f")[i[0].elementName]&&n(this,xt,"f").call(this,i[0].name))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_UNIQUE_ELEMENT_NAME);let r=n(this,St,"f")[s.elementName];if(r)t?r.update(i[0]):r.update(s);else{const e=Ct();r=new ft(e,s,n(this,Pt,"f"),{containerId:n(this,Nt,"f"),isMounted:n(this,wt,"f"),type:this.type},t,n(this,Ut,"f"),n(this,Ft,"f"),n(this,bt,"f"),n(this,Mt,"f")),n(this,St,"f")[s.elementName]=r,n(this,Dt,"f")[e]=r}return t||i.forEach(e=>{const t=e.elementName;n(this,St,"f")[t]?n(this,St,"f")[t].update(e):n(this,St,"f")[t]=this.create(e.elementType,r)}),r}),Yt.set(this,e=>{Object.keys(n(this,St,"f")).forEach(t=>{t===e&&delete n(this,St,"f")[t]})}),Ut.set(this,e=>{e.forEach(e=>{n(this,Yt,"f").call(this,e)})}),Ft.set(this,e=>{e.forEach(e=>{n(this,St,"f")[e.elementName]&&n(this,St,"f")[e.elementName].update(e)})}),xt.set(this,e=>{const t=Object.keys(n(this,St,"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(n(this,St,"f")).forEach(e=>{if(!e.isMounted())throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);e.isValidElement()}),this.bus.emit(O+n(this,Nt,"f"),{},t=>{e(t)})}),this.collect=(e={tokens:!0})=>new Promise((t,i)=>{try{Ge(n(this,Pt,"f").clientJSON.config);const s=Object.values(n(this,St,"f"));let r=F;if(s.forEach(e=>{if(!e.isMounted())throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);e.isValidElement();const t=e.getOptions();t.elementType===R.EXPIRATION_DATE&&(r=t.format||"MM/YY")}),Object.prototype.hasOwnProperty.call(e,"tokens")&&!He(e.tokens))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TOKENS);(null==e?void 0:e.additionalFields)&&Be(e.additionalFields),(null==e?void 0:e.upsert)&&ze(null==e?void 0:e.upsert),this.bus.target(Ie.IFRAME_SECURE_ORGIN).emit(E+n(this,Nt,"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)?(Fe(`${JSON.stringify(null==e?void 0:e.error)}`,Me.ERROR,n(this,bt,"f").logLevel),i(null==e?void 0:e.error)):(Fe(xe(a.COLLECT_SUBMIT_SUCCESS,jt),Me.LOG,n(this,bt,"f").logLevel),t(e))}),Fe(xe(a.EMIT_EVENT,jt,E),Me.LOG,n(this,bt,"f").logLevel)}catch(e){Fe(`${e.message}`,Me.ERROR,n(this,bt,"f").logLevel),i(e)}}),this.unmount=()=>{this.iframe.remove()},this.bus=ve.getEventBus(),s(this,Nt,Ct(),"f"),s(this,Pt,Object.assign(Object.assign({},t),(null==e?void 0:e.fonts)?{fonts:e.fonts}:{}),"f"),s(this,Dt,i,"f"),s(this,bt,r,"f"),s(this,Mt,new ye,"f"),this.iframe=Oe({name:`${c}:${n(this,Nt,"f")}:${n(this,bt,"f").logLevel}`}),ge(this.iframe,{src:Te()}),Ce(this.iframe,Object.assign({},w)),Fe(xe(a.CREATE_COLLECT_CONTAINER,jt),Me.LOG,n(this,bt,"f").logLevel);const l=(e,t)=>{e.name===c+n(this,Nt,"f")&&(t(Object.assign(Object.assign({},n(this,Pt,"f")),{clientJSON:Object.assign(Object.assign({},n(this,Pt,"f").clientJSON),{config:Object.assign({},n(this,Pt,"f").clientJSON.config)}),context:n(this,bt,"f")})),s(this,wt,!0,"f"),n(this,Mt,"f")._emit(C,{containerId:n(this,Nt,"f")}),this.bus.target({origin:Ie.IFRAME_SECURE_ORGIN}).off(_+n(this,Nt,"f"),l))};this.bus.target({origin:Ie.IFRAME_SECURE_ORGIN}).on(_+n(this,Nt,"f"),l),document.body.append(this.iframe)}reset(){this.bus.emit(m+n(this,Nt,"f"))}}Nt=new WeakMap,St=new WeakMap,Pt=new WeakMap,bt=new WeakMap,Dt=new WeakMap,Mt=new WeakMap,wt=new WeakMap,kt=new WeakMap,Yt=new WeakMap,Ut=new WeakMap,Ft=new WeakMap,xt=new WeakMap;const Vt=(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},Gt=(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=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 Xt,zt,Ht,qt,Wt,Kt,$t,Zt,Jt,Qt,ei,ti,ii,ni,si,oi,ri,ai,li,di,ci,ui,hi,pi,_i;class Ei{constructor(e,t){Xt.set(this,void 0),zt.set(this,void 0),Ht.set(this,ve.getEventBus()),qt.set(this,null),this.type=Di.COMPOSABLE,Wt.set(this,!1),Kt.set(this,!1),this.update=e=>{s(this,Kt,!0,"f"),n(this,Wt,"f")?(n(this,zt,"f")._emit(g,{elementName:n(this,Xt,"f"),elementOptions:e}),s(this,Kt,!1,"f")):n(this,Kt,"f")&&n(this,zt,"f").on(`${Pe.READY}:${n(this,Xt,"f")}`,()=>{n(this,zt,"f")._emit(g,{elementName:n(this,Xt,"f"),elementOptions:e}),s(this,Wt,!0,"f"),s(this,Kt,!1,"f")})},s(this,Xt,e,"f"),s(this,zt,t,"f"),n(this,zt,"f").on(`${Pe.READY}:${n(this,Xt,"f")}`,()=>{s(this,Wt,!0,"f")})}on(e,t){if(!Object.values(p).includes(e))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_LISTENER);if(!t)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_HANDLER_IN_EVENT_LISTENER);if("function"!=typeof t)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_HANDLER_IN_EVENT_LISTENER);n(this,zt,"f").on(`${e}:${n(this,Xt,"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)}s(this,qt,{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=n(this,qt,"f")||{isEmpty:!0,isValid:!1,isComplete:!1,isFocused:!0,isRequired:!1};n(this,Ht,"f").emit(v,{name:n(this,Xt,"f"),event:p.FOCUS,value:Object.assign(Object.assign({},e),{isFocused:!0})})}setAttribute(e,t){n(this,zt,"f")._emit(f,{elementName:n(this,Xt,"f"),attribute:e,value:t})}}Xt=new WeakMap,zt=new WeakMap,Ht=new WeakMap,qt=new WeakMap,Wt=new WeakMap,Kt=new WeakMap;const mi="CollectContainer";class vi extends Rt{constructor(e,t,i,l){super(),$t.set(this,void 0),Zt.set(this,{}),Jt.set(this,void 0),Qt.set(this,{rows:[]}),ei.set(this,[]),ti.set(this,void 0),ii.set(this,void 0),ni.set(this,void 0),si.set(this,!1),oi.set(this,void 0),ri.set(this,void 0),this.type=Di.COMPOSABLE,ai.set(this,!1),li.set(this,{}),this.create=(e,t={required:!1})=>{Xe(e,n(this,ti,"f").logLevel);const i=Ot(e),s=Tt(e.type,t,n(this,ti,"f").logLevel),o=`${u}:${e.type}:${btoa(Ct())}`;return n(this,ei,"f").push(Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column},e),s),{validations:i,elementName:o})),new Ei(o,n(this,ni,"f"))},di.set(this,(e,t=!1)=>{const i=[];if(s(this,Zt,{},"f"),s(this,li,Re(e),"f"),n(this,li,"f").rows.forEach(e=>{e.elements.forEach(e=>{const t=e,{elementType:n}=t;At(n,t),t.sensitive=t.sensitive||b[n].sensitive,t.replacePattern=t.replacePattern||b[n].replacePattern,t.mask=t.mask||b[n].mask,t.isMounted=!1,t.label=e.label,t.skyflowID=e.skyflowID,i.push(t)})}),n(this,li,"f").elementName=t?i[0].elementName:`${u}:group:${btoa(n(this,li,"f").name)}`,t&&!n(this,Zt,"f")[i[0].elementName]&&n(this,pi,"f").call(this,i[0].name))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_UNIQUE_ELEMENT_NAME);let r=n(this,Zt,"f")[n(this,li,"f").elementName];if(r)t?r.update(i[0]):r.update(n(this,li,"f"));else{const e=Ct();r=new ft(e,n(this,li,"f"),n(this,Jt,"f"),{containerId:n(this,$t,"f"),isMounted:n(this,ai,"f"),type:this.type},!0,n(this,ui,"f"),n(this,hi,"f"),n(this,ti,"f"),n(this,ni,"f")),n(this,Zt,"f")[n(this,li,"f").elementName]=r,n(this,ii,"f")[e]=r}return r}),ci.set(this,e=>{Object.keys(n(this,Zt,"f")).forEach(t=>{t===e&&delete n(this,Zt,"f")[t]})}),ui.set(this,e=>{e.forEach(e=>{n(this,ci,"f").call(this,e)})}),hi.set(this,e=>{e.forEach(e=>{n(this,Zt,"f")[e.elementName]&&n(this,Zt,"f")[e.elementName].update(e)})}),pi.set(this,e=>{const t=Object.keys(n(this,Zt,"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(p).includes(e))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_LISTENER);if(!t)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_HANDLER_IN_EVENT_LISTENER);if("function"!=typeof t)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_HANDLER_IN_EVENT_LISTENER);n(this,ni,"f").on(p.SUBMIT,()=>{t()})},this.mount=e=>{if(!e)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_IN_MOUNT);s(this,Qt,{rows:[]},"f");const{layout:t}=n(this,oi,"f");if((t||[]).reduce((e,t)=>e+t,0)!==n(this,ei,"f").length)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISMATCH_ELEMENT_COUNT_LAYOUT_SUM);let i=0;if(t.forEach((e,t)=>{n(this,Qt,"f").rows=[...n(this,Qt,"f").rows,{elements:[]}];for(let s=0;s<e;s++)n(this,Qt,"f").rows[t].elements.push(n(this,ei,"f")[i]),i++}),n(this,oi,"f").styles&&(n(this,Qt,"f").styles=Object.assign({},n(this,oi,"f").styles)),n(this,oi,"f").errorTextStyles&&(n(this,Qt,"f").errorTextStyles=Object.assign({},n(this,oi,"f").errorTextStyles)),n(this,ai,"f"))return n(this,ri,"f")&&(n(this,ri,"f").unmount(),s(this,ri,null,"f")),s(this,Zt,{},"f"),s(this,ri,n(this,di,"f").call(this,n(this,Qt,"f"),!1),"f"),this.mountContainerElement(e),void s(this,si,!0,"f");n(this,ni,"f").on(T+n(this,$t,"f"),()=>{s(this,Zt,{},"f"),s(this,ri,n(this,di,"f").call(this,n(this,Qt,"f"),!1),"f"),this.mountContainerElement(e),s(this,si,!0,"f")})},this.mountContainerElement=e=>{n(this,ri,"f").mount(e)},this.unmount=()=>{var e;[...n(this,ei,"f").map(e=>e.elementName)].forEach(e=>{n(this,ci,"f").call(this,e)}),s(this,ei,[],"f"),s(this,Qt,{rows:[]},"f"),s(this,Zt,{},"f"),null===(e=n(this,ri,"f"))||void 0===e||e.unmount(),this.iframe.remove(),s(this,si,!1,"f"),s(this,ai,!1,"f")},this.validate=()=>new Promise((e,t)=>{Object.values(n(this,Zt,"f")).forEach(e=>{if(!e.isMounted())throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);e.isValidElement()}),this.bus.emit(O+n(this,$t,"f"),{},t=>{e(t)})}),this.collect=(e={tokens:!0})=>new Promise((t,i)=>{try{if(Ge(n(this,Jt,"f").clientJSON.config),!n(this,si,"f")){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);throw r.PayrailsLogger.error(e.message,{error:e}),e}if(gt(n(this,li,"f")).forEach(e=>{if(!(null==e?void 0:e.isMounted))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING)}),Object.values(n(this,Zt,"f")).forEach(e=>{e.isValidElement()}),e&&e.tokens&&"boolean"!=typeof e.tokens)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TOKENS);(null==e?void 0:e.additionalFields)&&Be(e.additionalFields),(null==e?void 0:e.upsert)&&ze(null==e?void 0:e.upsert),this.bus.emit(E+n(this,$t,"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)?(Fe(`${JSON.stringify(null==e?void 0:e.error)}`,Me.ERROR,n(this,ti,"f").logLevel),i(null==e?void 0:e.error)):(Fe(xe(a.COLLECT_SUBMIT_SUCCESS,mi),Me.LOG,n(this,ti,"f").logLevel),t(e))}),Fe(xe(a.EMIT_EVENT,mi,E),Me.LOG,n(this,ti,"f").logLevel)}catch(e){Fe(`${e.message}`,Me.ERROR,n(this,ti,"f").logLevel),i(e)}}),_i.set(this,()=>{n(this,ni,"f").on(g,e=>{let t;const i=n(this,ei,"f").map((i,n)=>i.elementName===e.elementName?(t=n,Object.assign({elementName:i.elementName},e.elementOptions)):i);n(this,ri,"f")&&n(this,ri,"f").updateElement(Object.assign({},i[t]))})}),this.bus=ve.getEventBus(),s(this,$t,Ct(),"f"),s(this,Jt,Object.assign(Object.assign({},t),(null==e?void 0:e.fonts)?{fonts:e.fonts}:{}),"f"),s(this,ii,i,"f"),s(this,ti,l,"f"),s(this,oi,e,"f"),s(this,ni,new ye,"f"),this.iframe=Oe({name:`${c}:${n(this,$t,"f")}:${n(this,ti,"f").logLevel}`}),ge(this.iframe,{src:Te()}),Ce(this.iframe,Object.assign({},w)),Fe(xe(a.CREATE_COLLECT_CONTAINER,mi),Me.LOG,n(this,ti,"f").logLevel);const d=(e,t)=>{e.name===c+n(this,$t,"f")&&(t(Object.assign(Object.assign({},n(this,Jt,"f")),{clientJSON:Object.assign(Object.assign({},n(this,Jt,"f").clientJSON),{config:Object.assign({},n(this,Jt,"f").clientJSON.config)}),context:n(this,ti,"f")})),s(this,ai,!0,"f"),n(this,ni,"f")._emit(T+n(this,$t,"f"),{containerId:n(this,$t,"f")}),this.bus.target({origin:Ie.IFRAME_SECURE_ORGIN}).off(_+n(this,$t,"f"),d))};this.bus.target({origin:Ie.IFRAME_SECURE_ORGIN}).on(_+n(this,$t,"f"),d),document.body.append(this.iframe),n(this,_i,"f").call(this)}reset(){this.bus.emit(m+n(this,$t,"f"),{})}}function yi(e){this.message=e}$t=new WeakMap,Zt=new WeakMap,Jt=new WeakMap,Qt=new WeakMap,ei=new WeakMap,ti=new WeakMap,ii=new WeakMap,ni=new WeakMap,si=new WeakMap,oi=new WeakMap,ri=new WeakMap,ai=new WeakMap,li=new WeakMap,di=new WeakMap,ci=new WeakMap,ui=new WeakMap,hi=new WeakMap,pi=new WeakMap,_i=new WeakMap,yi.prototype=new Error,yi.prototype.name="InvalidCharacterError";var Ii="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new yi("'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 fi(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(Ii(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 Ii(t)}}function Ai(e){this.message=e}Ai.prototype=new Error,Ai.prototype.name="InvalidTokenError";const Li=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 Ai("Invalid token specified");var i=!0===(t=t||{}).header?0:1;try{return JSON.parse(fi(e.split(".")[i]))}catch(e){throw new Ai("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 gi,Oi,Ti,Ci,Ri,Ni,Si,Pi,bi,Di;class Mi{constructor(e,t){gi.set(this,void 0),this.config=e,s(this,gi,t,"f")}toJSON(){return{config:this.config,metaData:n(this,gi,"f")}}static fromJSON(e){return new Mi(e.config,e.metaData)}}gi=new WeakMap,function(e){e.COLLECT="COLLECT",e.COMPOSABLE="COMPOSABLE"}(Di||(Di={}));const wi="Skyflow";class ki{constructor(e){var t,i;Oi.set(this,void 0),Ti.set(this,Ct()),Ci.set(this,{uuid:n(this,Ti,"f"),clientDomain:window.location.origin}),Ri.set(this,""),Ni.set(this,void 0),Si.set(this,void 0),Pi.set(this,void 0),bi.set(this,void 0),this.bus=ve.getEventBus();const d=localStorage.getItem("sdk_version")||"";n(this,Ci,"f").sdkVersion=d,s(this,Oi,new Mi(Object.assign({},e),n(this,Ci,"f")),"f"),s(this,Si,(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||be.ERROR,"f"),s(this,Pi,(null===(i=null==e?void 0:e.options)||void 0===i?void 0:i.env)||De.PROD,"f"),s(this,bi,{},"f"),this.bus.on(h,e=>{if(e&&e.errorCode){const t=new o.PayrailsError(e.errorCode,{cause:null==e?void 0:e.originalError});r.PayrailsLogger.error(t.message,{error:t})}}),this.bus.target({origin:Ie.IFRAME_SECURE_ORGIN}).on(A+n(this,Ti,"f"),(e,t)=>{Fe(xe(a.CAPTURED_BEARER_TOKEN_EVENT,wi),Me.LOG,n(this,Si,"f")),!n(this,Oi,"f").config.getBearerToken||n(this,Ri,"f")&&Li(n(this,Ri,"f"))?(Fe(xe(a.REUSE_BEARER_TOKEN,wi),Me.LOG,n(this,Si,"f")),t({authToken:n(this,Ri,"f")})):n(this,Oi,"f").config.getBearerToken().then(e=>{Li(e)?(Fe(xe(a.BEARER_TOKEN_RESOLVED,wi),Me.LOG,n(this,Si,"f")),s(this,Ri,e,"f"),t({authToken:n(this,Ri,"f")})):(Fe(l.INVALID_BEARER_TOKEN,Me.ERROR,n(this,Si,"f")),t({error:l.INVALID_BEARER_TOKEN}))}).catch(e=>{Fe(l.BEARER_TOKEN_REJECTED,Me.ERROR,n(this,Si,"f")),t({error:e})})}),Fe(xe(a.BEARER_TOKEN_LISTENER,wi),Me.LOG,n(this,Si,"f")),Fe(xe(a.CURRENT_ENV,wi,n(this,Pi,"f")),Me.LOG,n(this,Si,"f")),Fe(xe(a.CURRENT_LOG_LEVEL,wi,n(this,Si,"f")),Me.LOG,n(this,Si,"f"))}static init(e){var t;const i=(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||be.ERROR;Ke(e),Fe(xe(a.INITIALIZE_CLIENT,wi),Me.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 ki(n);return Fe(xe(a.CLIENT_INITIALIZED,wi),Me.LOG,i),o}container(e,t){switch(e){case Di.COLLECT:{const i=new Bt(t,Object.assign(Object.assign({},n(this,Ci,"f")),{clientJSON:n(this,Oi,"f").toJSON(),containerType:e}),n(this,bi,"f"),{logLevel:n(this,Si,"f"),env:n(this,Pi,"f")});return Fe(xe(a.COLLECT_CONTAINER_CREATED,wi),Me.LOG,n(this,Si,"f")),i}case Di.COMPOSABLE:{(e=>{if(!e)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_COMPOSABLE_CONTAINER_OPTIONS);if("object"!=typeof e)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COMPOSABLE_CONTAINER_OPTIONS_INVALID);if(!Object.prototype.hasOwnProperty.call(e,"layout"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_COMPOSABLE_LAYOUT_KEY);if(!e.layout)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_LAYOUT_TYPE);if(!Array.isArray(e.layout))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_LAYOUT_TYPE);if(0===e.layout.length)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_COMPOSABLE_LAYOUT_ARRAY);e.layout.forEach(e=>{if("number"!=typeof e)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_LAYOUT_TYPE);if(e<0)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_NEGATIVE_VALUES_COMPOSABLE_LAYOUT)})})(t);const i=new vi(t,Object.assign(Object.assign({},n(this,Ci,"f")),{clientJSON:n(this,Oi,"f").toJSON(),containerType:e}),n(this,bi,"f"),{logLevel:n(this,Si,"f"),env:n(this,Pi,"f")});return Fe(xe(a.COLLECT_CONTAINER_CREATED,wi),Me.LOG,n(this,Si,"f")),i}default:if(!e)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_CONTAINER_TYPE);throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_CONTAINER_TYPE)}}static get ContainerType(){return Di}static get ElementType(){return R}static get RedactionType(){return Ne}static get RequestMethod(){return Se}static get LogLevel(){return be}static get EventName(){return Pe}static get Env(){return De}static get ValidationRuleType(){return we}}Oi=new WeakMap,Ti=new WeakMap,Ci=new WeakMap,Ri=new WeakMap,Ni=new WeakMap,Si=new WeakMap,Pi=new WeakMap,bi=new WeakMap;const Yi=(e,t)=>i(void 0,void 0,void 0,function*(){if(null==e?void 0:e.onDeliveryAddressChanged)try{const i=yield e.onDeliveryAddressChanged(t);if(!i){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onDeliveryAddressChanged resolved to false"});return r.PayrailsLogger.error(e.message,{error:e}),!1}return i}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onDeliveryAddressChanged threw an error",cause:e});return r.PayrailsLogger.error(t.message,{error:t}),!1}return!0}),Ui=(t,n)=>i(void 0,void 0,void 0,function*(){try{const i=yield co(t,n);if(!i){const s=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onRequestStart resolved to false"});return lo(t,n,{code:e.AuthorizationFailureReasons.VALIDATION_FAILED,message:s.message}),i}}catch(i){const s=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onRequestStart threw an error",cause:i});return r.PayrailsLogger.error(s.message,{error:s}),lo(t,n,{code:e.AuthorizationFailureReasons.VALIDATION_FAILED,message:s.message}),!1}return!0});let Fi={};class xi{constructor(e,{id:t="",className:i="",dataTestId:n=""}={}){this.subElements=[],this.eventBus=ve.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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);return`#${this.id}`}mount(e){const t=document.querySelector(e);if(!t)throw new o.PayrailsError(o.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 o.PayrailsError(o.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 ji extends xi{tokenize(e){return i(this,void 0,void 0,function*(){const t=yield this.collect(),i=_e(),n=i.vaultConfiguration.links.saveInstrument,s=i.token;if(!n.href){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND,{description:"Save instrument URL not available!"});throw r.PayrailsLogger.error(e.message,{error:e}),e}const a=yield this.constructSaveInstrumentBody(t,e);return(yield oe({url:n.href,token:s,body:a})).res})}}class Bi{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){return!!t.pattern&&!new RegExp(t.pattern).test(e)}static oneOf(e,t){return!(!t.oneOf||0===t.oneOf.length)&&!t.oneOf.map(e=>e.const).includes(e)}}class Vi extends xi{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=[];return this._isVisible&&this._isRequired&&Bi.required(this.value,!0,this.options.property)&&t.push(this.options.errors.required),this.value&&(Bi.minLength(this.value,this.options.property)&&t.push(this.options.errors.minLength),Bi.maxLength(this.value,this.options.property)&&t.push(this.options.errors.maxLength),Bi.pattern(this.value,this.options.property)&&t.push(this.options.errors.pattern),Bi.oneOf(this.value,this.options.property)&&t.push(this.options.errors.oneOf)),e?0===t.length:(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 Gi extends Vi{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,void 0!==this.options.value&&(this.component.value=this.options.value),this.options.readOnly&&(this.component.readOnly=!0,this.component.classList.add("payrails-dynamic-element-input--readonly")),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 Xi extends Vi{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)}),void 0!==this.options.value&&(this.component.value=this.options.value),this.options.readOnly&&(this.component.disabled=!0,this.component.classList.add("payrails-dynamic-element-select--readonly")),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 zi extends Vi{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(){}}var Hi;!function(e){e.GET="GET"}(Hi||(Hi={}));const qi=e=>i(void 0,[e],void 0,function*({url:e}){const t={method:Hi.GET},i=yield fetch(e,t),n=yield i.json();if(429===i.status)throw new Ki(e,Hi.GET);if(!i.ok)throw new Wi(e,Hi.GET);return{ok:i.ok,req:Object.assign({url:e},t),res:n}});class Wi extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{description:`[${t}] ${e} unsuccessful`})}}class Ki extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} too many requests`})}}const $i="ui:position";function Zi(e){return i(this,void 0,void 0,function*(){if(!e||"object"!=typeof e)return e;const t=Ji(e);if(0===t.size)return e;const n=yield function(e){return i(this,void 0,void 0,function*(){const t=new Map,n=Array.from(e).map(e=>i(this,void 0,void 0,function*(){try{const i=(yield qi({url:e})).res;t.set(e,i)}catch(t){console.warn(`Failed to fetch schema from ${e}:`,t)}}));return yield Promise.all(n),t})}(t);return Qi(e,n)})}function Ji(e,t=new Set){return Array.isArray(e)?e.forEach(e=>Ji(e,t)):e&&"object"==typeof e&&(e.$ref&&/^https?:\/\//.test(e.$ref)&&t.add(e.$ref),Object.values(e).forEach(e=>Ji(e,t))),t}function Qi(e,t){if(Array.isArray(e))return e.map(e=>Qi(e,t));if(e&&"object"==typeof e){if(e.$ref&&/^https?:\/\//.test(e.$ref)){if(!t.has(e.$ref))return;const i=Qi(t.get(e.$ref),t);return void 0!==e[$i]?Object.assign(Object.assign({},i),{[$i]:e[$i]}):i}const i={};for(const[n,s]of Object.entries(e)){const e=Qi(s,t);void 0!==e&&(i[n]=e)}return i}return e}function en(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 tn(e,t,i,n){var s,o,r,a,l,d,c,u,h,p,_,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:re({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!==(h=null==n?void 0:n.errors)&&void 0!==h?h:{},null!==(E=null===(_=null===(p=null==n?void 0:n.fields)||void 0===p?void 0:p[e])||void 0===_?void 0:_.errors)&&void 0!==E?E:{}),required:i}}function nn(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 sn extends ji{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 i(this,void 0,void 0,function*(){if(!this.parentElement)throw new o.PayrailsError(o.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=Gt(e,t.name,t.value))}),!this.isFormValid())throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_FORM_INVALID,{description:"Dynamic element form is invalid"});return e})}constructSaveInstrumentBody(e,t){return i(this,void 0,void 0,function*(){var i,n;return{data:e,merchantReference:ce.response.merchantReference,holderReference:ce.response.holderReference,holderId:ce.response.holderId,paymentMethod:null===(i=this.options.paymentMethod)||void 0===i?void 0:i.paymentMethodCode,storeInstrument:null!==(n=null==t?void 0:t.storeInstrument)&&void 0!==n&&n}})}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 t=Object.create(null,{mount:{get:()=>super.mount}});return i(this,void 0,void 0,function*(){var i,n;yield this.makeForm(),t.mount.call(this,e),null===(n=null===(i=this.options.events)||void 0===i?void 0:i.onReady)||void 0===n||n.call(i)})}makeForm(){return i(this,void 0,void 0,function*(){var e;if(!(null===(e=this.formConfig)||void 0===e?void 0:e.schema))return;this.__schema=yield Zi(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]=tn(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[$i])&&void 0!==i?i:0)-(null!==(n=t.property[$i])&&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){var i,n;const s=this.extractStyles(e.name,t),o=this.makeFieldEvents(e.name),r=re(e,null!==(n=null===(i=this.options.fieldOverrides)||void 0===i?void 0:i[e.name])&&void 0!==n?n:{});switch(t){case"tabs":return new zi(Object.assign(Object.assign({},r),{events:o,styles:s,options:nn(e.property)}));case"select":return new Xi(Object.assign(Object.assign({},r),{events:o,styles:s,options:nn(e.property)}));case"input":return new Gi(Object.assign(Object.assign({},r),{events:o,styles:s}));default:throw new Error(`Unsupported component type: ${t}`)}}extractStyles(e,t){var i,n,s,o,r,a,l,d,c,u,h,p,_,E;const m=re({},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=re({},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===(_=null===(p=null===(h=this.options.styles)||void 0===h?void 0:h.fields)||void 0===p?void 0:p[e])||void 0===_?void 0:_.errors)&&void 0!==E?E:{});return{[t]:m,errors:v}}makeFieldEvents(e){return{onChange:(t=>{this.formData=Gt(this.formData,e,t),this.evaluateDependencies()}).bind(this),onReady:(t=>{this.formData=Gt(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=Vt(t,n);if(s.oneOf){const t=en(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 on={fields:{email:{label:"Email",placeholder:"you@example.com"},line1:{label:"Address line 1",placeholder:"Street and number"},line2:{label:"Address line 2",placeholder:"Apartment, suite, etc."},city:{label:"City",placeholder:"City"},state:{label:"State / region",placeholder:"State / region"},postalCode:{label:"Postal code",placeholder:"Postal code"},country:{label:"Country",placeholder:"Select a country"}}};class rn extends xi{constructor(e){super("div",{className:"payrails-billing-address-form-title"}),this.element.innerText=e}}class an extends xi{static get current(){return an._current}static reset(){an._current=void 0}constructor(e){var t,i,n;super("div",{id:"payrails-billing-address-form",className:"payrails-billing-address-form"}),this.form=new sn({styles:e.styles,translations:re(on,null!==(t=e.translations)&&void 0!==t?t:{}),fieldOverrides:an.toFieldOverrides(e.prefill),events:{onReady:null===(i=e.events)||void 0===i?void 0:i.onReady}},{schema:e.schema}),this.subElements.push(new rn(null!==(n=e.title)&&void 0!==n?n:"Billing Address"),this.form)}static toFieldOverrides(e={}){const{street:i}=e,n=t(e,["street"]),s=Object.assign(Object.assign({},n),{line1:i});return Object.fromEntries(Object.entries(s).filter(([,e])=>e).map(([e,t])=>[e,{value:t,readOnly:!0}]))}collect(){return i(this,void 0,void 0,function*(){an._current=void 0;const e=yield this.form.collect();return an._current=e,e})}}const ln=(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=dn(t.userAgent);return n&&(i.osType=n),i},dn=e=>/android/i.test(e)?"android":/iphone|ipad|ipod/i.test(e)?"ios":/windows|linux|mac/i.test(e)?"web":void 0,cn={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 un{static getInstance(){return this.instance||(this.instance=new un),this.instance}constructor(e=""){this.lastActionUpdateTime=e,un.instance=this}}class hn{constructor(e=cn,t=680,i=60,n=2e3,s=5,o=un.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 i(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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR,{cause:e});throw r.PayrailsLogger.error(t.message,{error:t}),e}})}payout(e){return i(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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAYOUT_ERROR,{cause:e});throw r.PayrailsLogger.error(t.message,{error:t}),e}})}confirm(e){return i(this,arguments,void 0,function*(e,t={}){try{const i=yield Z({url:e,method:W.POST,token:_e().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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR,{cause:e});throw r.PayrailsLogger.error(t.message,{error:t}),e}})}getExecution(e,t){return i(this,arguments,void 0,function*(e,t,i=0,n){if(i>this.MAX_POLL_ATTEMPTS)throw new te(e,W.GET);0===i&&t?yield this.wait(this.POLL_INITIAL_DELAY,n):yield this.wait(this.POLL_INTERVAL,n);try{const s=yield Z({url:e,token:_e().token});return t&&!s.res.status.find(({time:e})=>new Date(e)>new Date(t))?(yield this.wait(this.POLL_INTERVAL,n),this.getExecution(e,t,i+1,n)):s}catch(s){if(s instanceof Q)return yield this.wait(this.POLL_INTERVAL,n),this.getExecution(e,t,i+this.POLL_ERROR_COUNT_MULTIPLIER,n);if(s instanceof ee)return yield this.wait(this.POLL_INTERVAL*i,n),this.getExecution(e,t,i+1,n);throw s}})}createApplePaySession(e){return i(this,void 0,void 0,function*(){return Z({url:e.requestUrl,method:W.POST,token:_e().token,body:{integrationType:"api",paymentMethodCode:"applePay",amount:_e().amount,meta:{sessionURL:e.sessionUrl,clientContext:{host:e.clientDomain||window.location.host}}}})})}authorize(e){return i(this,void 0,void 0,function*(){if(!ce.authorizeLink||!_e().amount){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND,{description:"SDK was not initialized with workflow execution"});throw r.PayrailsLogger.error(e.message,{error:e}),e}const{success:t=cn.success,error:i=cn.error,cancel:n=cn.cancel,pending:s=cn.pending}=this.returnLinks,a=this.attachMetaToPaymentComposition({amount:_e().amount,paymentComposition:e,returnInfo:{success:t,cancel:n,error:i,pending:s}});return Z({url:ce.authorizeLink,method:W.POST,token:_e().token,body:a})})}executePayout(e){return i(this,void 0,void 0,function*(){if(!ce.payoutLink||!_e().amount){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND,{description:"SDK was not initialized with workflow execution"});throw r.PayrailsLogger.error(e.message,{error:e}),e}const t={amount:_e().amount,payoutComposition:e};return Z({url:ce.payoutLink,method:W.POST,token:_e().token,body:t})})}getFirstNonFraudNetId(e){const t=Object.keys(e||{}).find(e=>"fraudNet"!==e);return t?e[t]:null}attachMetaToPaymentComposition(t){var i,n,s,o,r,a,l;let d;d=t.paymentComposition[0].paymentMethodCode===e.PAYMENT_METHOD_CODES.PAYPAL&&(null===(n=null===(i=window.PayrailsData)||void 0===i?void 0:i.riskIds)||void 0===n?void 0:n.fraudNet)?null===(o=null===(s=window.PayrailsData)||void 0===s?void 0:s.riskIds)||void 0===o?void 0:o.fraudNet:this.getFirstNonFraudNetId(null===(r=window.PayrailsData)||void 0===r?void 0:r.riskIds)||"";const c=Object.assign(Object.assign({},t),{meta:Object.assign(Object.assign({},ce.getUpdatedMeta()),t.meta)});!1!==(null===(a=Fi.telemetry)||void 0===a?void 0:a.collectMetadata)&&(c.meta=Object.assign(Object.assign({},c.meta),{clientContext:Object.assign(Object.assign({},(null===(l=c.meta)||void 0===l?void 0:l.clientContext)||{}),ln())})),d&&(c.meta.risk={sessionId:d});const u=an.current;return u&&(c.paymentComposition=c.paymentComposition.map(e=>{var t,i;return(null===(t=e.paymentInstrumentData)||void 0===t?void 0:t.billingAddress)?e:Object.assign(Object.assign({},e),{paymentInstrumentData:Object.assign(Object.assign({},null!==(i=e.paymentInstrumentData)&&void 0!==i?i:{}),{billingAddress:u})})})),c}wait(e,t){return i(this,void 0,void 0,function*(){var i;if(null==t?void 0:t.aborted)throw null!==(i=t.reason)&&void 0!==i?i:new DOMException("Aborted","AbortError");return new Promise((i,n)=>{const s=setTimeout(()=>{null==t||t.removeEventListener("abort",o),i()},e),o=()=>{var e;clearTimeout(s),null==t||t.removeEventListener("abort",o),n(null!==(e=null==t?void 0:t.reason)&&void 0!==e?e:new DOMException("Aborted","AbortError"))};null==t||t.addEventListener("abort",o,{once:!0})})})}pollForAuthorizationResult(e){return i(this,arguments,void 0,function*(e,t=0,i=["authorizePending","authorizeSuccessful","authorizeFailed","payoutPending","payoutSuccessful","payoutFailed"],n){var s;const a=null==n?void 0:n.signal;if(null==a?void 0:a.aborted)throw null!==(s=a.reason)&&void 0!==s?s: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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED);throw r.PayrailsLogger.error(e.message,{error:e}),e}const u=d.find(({code:e,time:t})=>"confirmRequested"===e&&new Date(t)>new Date(c.time)),h=u?u.time:c.time,p=d.filter(({code:e,time:t})=>i.includes(e)&&new Date(t)>new Date(h)).sort((e,t)=>new Date(t.time).getTime()-new Date(e.time).getTime())[0];return p?(this.paymentStatus.lastActionUpdateTime=p.time,{finalState:p,response:l}):this.pollForAuthorizationResult(e,t+1,i,{signal:a})})}}
4
+ */const Ae={IFRAME_SECURE_SITE:"https://js.skyflow.com/v1/elements/index.html",IFRAME_SECURE_ORGIN:"https://js.skyflow.com"},Le="https://assets.payrails.io/c344ea7/card/index.html",Oe="https://assets.payrails.io",ge={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no",style:"width: 100%;",allow:"clipboard-read; clipboard-write"},Te=(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 Ce=(e={})=>{const t=document.createElement("iframe"),i=Object.assign(Object.assign({},ge),e);return Object.assign(t.style,M),Te(t,i),t.getAttribute("id")||(t.id=t.name),t};const Re=()=>Ae.IFRAME_SECURE_SITE,Ne=(e,t)=>{Object.keys(t).forEach(i=>{Object.prototype.hasOwnProperty.call(t,i)&&(e.style[i]=t[i])})};function Se(e){return JSON.parse(JSON.stringify(e))}var Pe,be,De,Me,we,ke,Ye;!function(e){e.DEFAULT="DEFAULT",e.PLAIN_TEXT="PLAIN_TEXT",e.MASKED="MASKED",e.REDACTED="REDACTED"}(Pe||(Pe={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH",e.DELETE="DELETE"}(be||(be={})),function(e){e.CHANGE="CHANGE",e.READY="READY",e.FOCUS="FOCUS",e.BLUR="BLUR",e.SUBMIT="SUBMIT"}(De||(De={})),function(e){e.WARN="WARN",e.INFO="INFO",e.DEBUG="DEBUG",e.ERROR="ERROR"}(Me||(Me={})),function(e){e.DEV="DEV",e.PROD="PROD"}(we||(we={})),function(e){e.LOG="LOG",e.WARN="WARN",e.ERROR="ERROR"}(ke||(ke={})),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"}(Ye||(Ye={}));const Ue={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}},Fe={PROD:{doesReturnValue:!1},DEV:{doesReturnValue:!0}},xe="[Skyflow]",je=(e,t,i)=>{if(i&&Ue[i]){const{showDebugLogs:n,showInfoLogs:s,showWarnLogs:o,showErrorLogs:r}=Ue[i];t===ke.LOG&&n?console.log(`${Me.DEBUG}: ${xe} ${e}`):t===ke.LOG&&s?console.log(`${Me.INFO}: ${xe} ${e}`):t===ke.WARN&&o?console.warn(`${Me.WARN}: ${xe} ${e}`):t===ke.ERROR&&r&&console.error(`${Me.ERROR}: ${xe} ${e}`)}},Be=(...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]}):""},Ve=(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},Ge=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_RECORDS_KEY_MISSING_IN_ADDITIONAL_FIELDS);const{records:t}=e;if(!t||!Array.isArray(t))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_RECORDS_IN_ADDITIONAL_FIELDS);if(0===t.length)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_RECORDS_IN_ADDITIONAL_FIELDS);t.forEach((e,t)=>{var i,n,s,r;if(!e||!Object.prototype.hasOwnProperty.call(e,"table"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_TABLE_IN_ADDITIONAL_FIELDS);if(!e.table)throw new o.PayrailsError(o.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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_SKYFLOW_ID);if(!("string"==typeof(null===(s=e.fields)||void 0===s?void 0:s.skyflowID)||(null===(r=e.fields)||void 0===r?void 0:r.skyflowID)instanceof String))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_SKYFLOW_ID)}if(!("string"==typeof e.table||e.table instanceof String))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_IN_ADDITIONAL_FIELDS);if(!Object.prototype.hasOwnProperty.call(e,"fields"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_FIELDS_IN_ADDITIONAL_FIELDS);if(!e.fields)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_FIELDS_IN_ADDITIONAL_FIELDS);if("object"!=typeof e.fields||Array.isArray(e.fields))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_FIELDS_IN_ADDITIONAL_FIELDS)})},Xe=e=>{let t=!0;try{new RegExp(e)}catch(e){t=!1}return t},ze=e=>{if(!Object.prototype.hasOwnProperty.call(e,"getBearerToken"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_GET_BEARER_TOKEN_MISSING)},He=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_ELEMENT_TYPE);if(!e.type)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_TYPE);if(Object.prototype.hasOwnProperty.call(e,"altText")&&je(d.COLLECT_ALT_TEXT_DEPERECATED,ke.WARN,t),Object.prototype.hasOwnProperty.call(e,"skyflowID")&&"string"!=typeof e.skyflowID)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_SKYFLOW_ID)},$e=e=>{if(!e||!Array.isArray(e))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_UPSERT_OPTION_TYPE);if(!e.length)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_UPSERT_OPTIONS_ARRAY);e.forEach((e,t)=>{if(!e||"object"!=typeof e)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_UPSERT_OPTION_OBJECT_TYPE);if(!Object.prototype.hasOwnProperty.call(e,"table"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_TABLE_IN_UPSERT_OPTION);if(!e.table||"string"!=typeof e.table||!e.table.length)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_IN_UPSERT_OPTION);if(!Object.prototype.hasOwnProperty.call(e,"column"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_COLUMN_IN_UPSERT_OPTION);if(!e.column||"string"!=typeof e.column||!e.column.length)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COLUMN_IN_UPSERT_OPTION)})},qe=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===R.CARD_NUMBER){if(e=e&&e.replace(/\s/g,""),!i){((e="")=>{const t=e.replace(/[\s-]/g,"");let i=S.DEFAULT;Object.entries(U).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 Ze(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;Ae.IFRAME_SECURE_ORGIN=`${o}//${r}`,Ae.IFRAME_SECURE_SITE=null===(s=null==e?void 0:e.options)||void 0===s?void 0:s.customElementsURL}Ae.IFRAME_SECURE_ORGIN=Oe,Ae.IFRAME_SECURE_SITE=Le}class Je{constructor(e,t,i,n){this.setAttributess=e=>{Te(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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_SELECTOR)}else{if(!(e instanceof HTMLElement))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_SELECTOR);this.container=e}}catch(e){console.error(e)}Te(this.iframe,{src:Re(),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=Ce({name:this.name})}}class Qe{}var et,tt,it,nt,st,ot,rt,at,lt,dt,ct,ut,ht,pt,_t,Et,mt,vt,yt,It,ft;const At="Element";class Lt extends Qe{constructor(e,i,r,l,d=!1,c,u,h,E){var m;super(),this.type=wi.COLLECT,et.set(this,void 0),tt.set(this,!1),it.set(this,void 0),nt.set(this,void 0),st.set(this,{isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:void 0,isRequired:!1}),ot.set(this,void 0),rt.set(this,new fe),at.set(this,void 0),lt.set(this,Ie.getEventBus()),dt.set(this,void 0),ct.set(this,[]),ut.set(this,!1),ht.set(this,void 0),pt.set(this,void 0),_t.set(this,!1),this.getID=()=>n(this,et,"f"),this.mount=e=>{var i;if(!e)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_IN_MOUNT);const r=(e,i)=>{if(e.name===n(this,dt,"f").name){i(n(this,ot,"f")),n(this,ft,"f").call(this);const e=n(this,it,"f")[0],{name:o}=e,l=t(e,["name"]);n(this,nt,"f").length>1?n(this,nt,"f").forEach((e,t)=>{n(this,at,"f")&&n(this,at,"f")._emit(`${p.READY}:${e.elementName}`,Object.assign(Object.assign({},n(this,it,"f")[t]),{elementType:e.elementType}))}):n(this,rt,"f")._emit(p.READY,Object.assign({},l)),n(this,lt,"f").off(_+this.containerId,r),je(`${Be(a.ELEMENT_MOUNTED,At,Ve(n(this,dt,"f").name))} `,ke.LOG,n(this,ht,"f").logLevel),n(this,ct,"f").forEach(e=>e()),s(this,ct,[],"f")}};if(n(this,nt,"f").length>1)n(this,dt,"f").mount(e),n(this,lt,"f").on(_+this.containerId,r);else{if(n(this,_t,"f"))return n(this,dt,"f").mount(e),void n(this,lt,"f").on(_+this.containerId,r);null===(i=n(this,at,"f"))||void 0===i||i.on(C,t=>{(null==t?void 0:t.containerId)===this.containerId&&(n(this,dt,"f").mount(e),n(this,lt,"f").on(_+this.containerId,r))})}},this.unmount=()=>{n(this,lt,"f").off(v,n(this,yt,"f")),n(this,dt,"f").unmount()},this.update=e=>{let t=Se(e);const i=()=>{n(this,tt,"f")&&(t={rows:[{elements:[Object.assign({},t)]}]}),s(this,ot,gt(n(this,ot,"f"),t),"f"),s(this,nt,Tt(n(this,ot,"f")),"f"),n(this,tt,"f")?n(this,lt,"f").emit(I,{name:n(this,dt,"f").name,options:n(this,nt,"f")[0],isSingleElementAPI:!0}):(n(this,nt,"f").forEach(e=>{n(this,lt,"f").emit(I,{name:e.elementName,options:e,isSingleElementAPI:!0})}),n(this,lt,"f").emit(I,{name:n(this,dt,"f").name,options:n(this,ot,"f"),isSingleElementAPI:!1})),n(this,ft,"f").call(this)};n(this,ut,"f")?i():n(this,ct,"f").push(i)},Et.set(this,e=>{n(this,tt,"f")||n(this,rt,"f").on(I,()=>{e(n(this,nt,"f"))},!0)}),this.updateElement=e=>{n(this,lt,"f").emit(I,{name:e.elementName,options:e,isSingleElementAPI:!0})},mt.set(this,()=>{n(this,it,"f").forEach((e,t)=>{var i;if(0===t){n(this,st,"f").isEmpty=e.isEmpty,n(this,st,"f").isComplete=e.isComplete,n(this,st,"f").isValid=e.isValid,n(this,st,"f").isFocused=e.isFocused,n(this,st,"f").isRequired=e.isRequired,n(this,st,"f").value={};const i=n(this,nt,"f")[t].elementName,s=e.value&&Ke(e.value,e.elementType,n(this,pt,"f"));n(this,tt,"f")?n(this,st,"f").value=s:n(this,st,"f").value[i]=s}else n(this,st,"f").isEmpty=n(this,st,"f").isEmpty||e.isEmpty,n(this,st,"f").isComplete=n(this,st,"f").isComplete&&e.isComplete,n(this,st,"f").isValid=n(this,st,"f").isValid&&e.isValid,n(this,st,"f").isFocused=n(this,st,"f").isFocused||e.isFocused,n(this,st,"f").isRequired=n(this,st,"f").isRequired||e.isRequired,n(this,st,"f").value||(n(this,st,"f").value={}),!n(this,nt,"f")[t]&&(null===(i=n(this,nt,"f")[t])||void 0===i?void 0:i.sensitive)&&(n(this,st,"f").value[n(this,nt,"f")[t].elementName]=e.value||"")})}),this.getState=()=>({isEmpty:n(this,st,"f").isEmpty,isComplete:n(this,st,"f").isComplete,isValid:n(this,st,"f").isValid,isFocused:n(this,st,"f").isFocused,value:n(this,st,"f").value,required:n(this,st,"f").isRequired}),this.getOptions=()=>{let e=Se(n(this,ot,"f"));return n(this,tt,"f")?e=e.rows[0].elements[0]:e.rows.forEach(e=>{e.elements.forEach(e=>{delete e.elementName})}),delete e.elementName,e},vt.set(this,e=>{n(this,rt,"f").on(y,()=>{const t=n(this,nt,"f").map(e=>e.elementName);n(this,tt,"f")||t.push(n(this,dt,"f").name),e(t)},!0)}),yt.set(this,e=>{if(n(this,tt,"f")&&e.event===p.READY&&e.name===n(this,dt,"f").name)n(this,rt,"f")._emit(p.READY);else{const t=n(this,nt,"f").length>1;n(this,nt,"f").forEach((i,s)=>{var r;if(e.name===i.elementName){let a="";switch(e.event){case p.FOCUS:a=p.FOCUS;break;case p.BLUR:a=p.BLUR;break;case p.CHANGE:a=p.CHANGE;break;case p.READY:a=p.READY;break;case p.SUBMIT:return void(null===(r=n(this,at,"f"))||void 0===r||r._emit(p.SUBMIT));default:throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_TYPE)}n(this,it,"f")[s].isEmpty=e.value.isEmpty,n(this,it,"f")[s].isValid=e.value.isValid,n(this,it,"f")[s].isComplete=e.value.isComplete,n(this,it,"f")[s].isFocused=e.value.isFocused,n(this,it,"f")[s].isRequired=e.value.isRequired,Object.prototype.hasOwnProperty.call(e.value,"value")?n(this,it,"f")[s].value=e.value.value:n(this,it,"f")[s].value=void 0,a=t?`${a}:${e.name}`:a,n(this,lt,"f").emit(p.HEIGHT+n(this,dt,"f").name,{},e=>{(null==e?void 0:e.height)>0&&n(this,dt,"f").setIframeHeight(e.height)}),n(this,mt,"f").call(this);const l=Object.assign(Object.assign({},n(this,it,"f")[s]),{elementType:i.elementType});t&&n(this,at,"f")?n(this,at,"f")._emit(a,l):n(this,rt,"f")._emit(a,l)}})}}),It.set(this,()=>{n(this,lt,"f").on(v,n(this,yt,"f"))}),ft.set(this,()=>{const{rows:e}=n(this,ot,"f");e.forEach(e=>{e.elements.forEach(e=>{e.elementType!==b.radio.name&&e.elementType!==b.checkbox.name&&(e.value=void 0)})}),s(this,nt,Tt(n(this,ot,"f")),"f")}),this.containerId=l.containerId,s(this,et,e,"f"),s(this,ht,h,"f"),s(this,ot,gt(i),"f"),s(this,nt,Tt(i),"f"),s(this,tt,d,"f"),E&&s(this,at,E,"f"),s(this,pt,Fe[n(this,ht,"f").env].doesReturnValue,"f"),this.elementType=n(this,tt,"f")?n(this,nt,"f")[0].elementType:"group",s(this,it,[],"f"),n(this,nt,"f").forEach(e=>{n(this,it,"f").push({isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:n(this,pt,"f")?"":void 0,elementType:e.elementType,name:e.elementName,isRequired:!1})}),s(this,dt,new Je(n(this,ot,"f").elementName,r,this.containerId,n(this,ht,"f").logLevel),"f"),n(this,It,"f").call(this),n(this,vt,"f").call(this,c),n(this,Et,"f").call(this,u),je(Be(a.CREATED_ELEMENT,At,Ve(n(this,dt,"f").name)),ke.LOG,n(this,ht,"f").logLevel),s(this,_t,l.isMounted,"f"),null===(m=n(this,at,"f"))||void 0===m||m.on(C,e=>{(null==e?void 0:e.containerId)===this.containerId&&s(this,_t,!0,"f")});const f=e=>{e.height&&e.height>0&&n(this,dt,"f").setIframeHeight(e.height)};n(this,lt,"f").on(p.MOUNTED,e=>{l.type===wi.COMPOSABLE?n(this,nt,"f").forEach(t=>{e.name===t.elementName&&(t.isMounted=!0,s(this,ut,!0,"f"))}):e.name===n(this,nt,"f")[0].elementName&&(n(this,nt,"f")[0].isMounted=!0,s(this,ut,!0,"f")),n(this,lt,"f").emit(p.HEIGHT+n(this,dt,"f").name,{},f)})}on(e,t){if(!Object.values(p).includes(e))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_LISTENER);if(!t)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_HANDLER_IN_EVENT_LISTENER);if("function"!=typeof t)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_HANDLER_IN_EVENT_LISTENER);n(this,rt,"f").on(e,e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,t(e)})}iframeName(){return n(this,dt,"f").name}isMounted(){return n(this,ut,"f")}isValidElement(){for(let e=0;e<n(this,nt,"f").length;e+=1){if(!Object.prototype.hasOwnProperty.call(n(this,nt,"f")[e],"table"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_TABLE_NAME_MISSING);if(!n(this,nt,"f")[e].table)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_TABLE);if(!("string"==typeof n(this,nt,"f")[e].table||n(this,nt,"f")[e].table instanceof String))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_NAME);if(!Object.prototype.hasOwnProperty.call(n(this,nt,"f")[e],"column"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_COLUMN);if(!n(this,nt,"f")[e].column)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_COLUMN);if(!("string"==typeof n(this,nt,"f")[e].column||n(this,nt,"f")[e].column instanceof String))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COLUMN);if(void 0!==n(this,nt,"f")[e].skyflowID&&!n(this,nt,"f")[e].skyflowID)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_SKYFLOW_ID)}return!0}setError(e){n(this,lt,"f").emit(L,{name:We(n(this,dt,"f").name),isTriggerError:!0,clientErrorText:e})}resetError(){n(this,lt,"f").emit(L,{name:We(n(this,dt,"f").name),isTriggerError:!1})}setValue(e){n(this,ht,"f").env!==we.PROD?n(this,tt,"f")&&n(this,lt,"f").emit(I,{name:n(this,dt,"f").name,options:Object.assign(Object.assign({},n(this,nt,"f")[0]),{value:e}),isSingleElementAPI:!0}):je(Be(d.UNABLE_TO_SET_VALUE_IN_PROD_ENV,n(this,nt,"f")[0].elementType),ke.WARN,n(this,ht,"f").logLevel)}clearValue(){n(this,ht,"f").env!==we.PROD?n(this,tt,"f")&&n(this,lt,"f").emit(I,{name:n(this,dt,"f").name,options:Object.assign(Object.assign({},n(this,nt,"f")[0]),{value:""}),isSingleElementAPI:!0}):je(Be(d.UNABLE_TO_CLEAR_VALUE_IN_PROD_ENV,n(this,nt,"f")[0].elementType),ke.WARN,n(this,ht,"f").logLevel)}setAttribute(e,t){n(this,lt,"f").emit(f,{name:n(this,dt,"f").name,attribute:e,value:t})}focus(){var e;if(!(null===(e=n(this,nt,"f"))||void 0===e?void 0:e.length))return;const t=this.getState();n(this,lt,"f").emit(v,{name:n(this,nt,"f")[0].elementName,event:p.FOCUS,value:{isEmpty:t.isEmpty,isValid:t.isValid,isComplete:t.isComplete,isFocused:!0,isRequired:t.required,value:t.value}})}}function Ot(e,t,i={}){if("group"!==e&&!Object.prototype.hasOwnProperty.call(b,e))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_TYPE);if(Object.prototype.hasOwnProperty.call(t,"validations")){if(!Array.isArray(t.validations))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATIONS_TYPE);t.validations.forEach((e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_VALIDATION_RULE_TYPE);if(!Object.values(Ye).includes(e.type))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATION_RULE_TYPE);if(!Object.prototype.hasOwnProperty.call(e,"params"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_VALIDATION_RULE_PARAMS);if("object"!=typeof e.params||Array.isArray(e.params)||null===e.params)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_VALIDATION_RULE_PARAMS);if(e.type===Ye.REGEX_MATCH_RULE){if(!Object.prototype.hasOwnProperty.call(e.params,"regex"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_REGEX_IN_REGEX_MATCH_RULE)}else if(e.type===Ye.LENGTH_MATCH_RULE&&!Object.prototype.hasOwnProperty.call(e.params,"min")&&!Object.prototype.hasOwnProperty.call(e.params,"max"))throw new o.PayrailsError(o.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}=b[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===b.radio.name||e===b.checkbox.name)&&!i.value)throw new Error("Elements radio and checkbox requires value attribute");if(!(e!==b.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 gt(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],d=e;if(d.elementType&&a.elementType!==d.elementType&&a.elementName&&a.elementName!==d.elementName)throw new Error(l.CANNOT_CHANGE_ELEMENT);Ot(a.elementType,a,d),o.elements[t]=Object.assign(Object.assign(Object.assign({},a),d),{elementName:a.elementName});const c=d.classes||{},u=d.styles||{};u.base=Object.assign(Object.assign({},k),u.base),d.classes=c,d.styles=u;const h=(null===(n=null==d?void 0:d.labelStyles)||void 0===n?void 0:n.classes)||{},p=(null===(s=null==d?void 0:d.labelStyles)||void 0===s?void 0:s.styles)||{};i&&function(e,t){Object.values(Y).forEach(i=>{if(e[i]||t[i])switch(i){case Y.BASE:t[i]=Object.assign({},t[i]);break;case Y.FOCUS:t[Y.BASE]=Object.assign(Object.assign({},t[Y.BASE]),{":focus":Object.assign({},t[Y.BASE]&&t[Y.BASE][":focus"])});break;case Y.WEBPACKAUTOFILL:t[Y.BASE]=Object.assign(Object.assign({},t[Y.BASE]),{":-webkit-autofill":Object.assign({},t[Y.BASE]&&t[Y.BASE][":-webkit-autofill"])});break;default:t[i]=Object.assign(Object.assign({},t[Y.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`)})})}(h,p),d.labelStyles={labelClasses:h},d.labelStyles.styles=p})}),t}et=new WeakMap,tt=new WeakMap,it=new WeakMap,nt=new WeakMap,st=new WeakMap,ot=new WeakMap,rt=new WeakMap,at=new WeakMap,lt=new WeakMap,dt=new WeakMap,ct=new WeakMap,ut=new WeakMap,ht=new WeakMap,pt=new WeakMap,_t=new WeakMap,Et=new WeakMap,mt=new WeakMap,vt=new WeakMap,yt=new WeakMap,It=new WeakMap,ft=new WeakMap;const Tt=e=>{const{rows:t}=e,i=[];return t.forEach(e=>{e.elements.forEach(e=>{i.push(e)})}),i},Ct=e=>{const t=e.validations;return t&&Array.isArray(t)&&t.length>0&&t.forEach((e,t)=>{if(e&&e.type===Ye.ELEMENT_VALUE_MATCH_RULE){if(e.params&&!Object.prototype.hasOwnProperty.call(e.params,"element"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE);if(e.params&&(null==e.params.element||!(e.params.element instanceof Lt)))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE);e.params&&e.params.element&&e.params.element instanceof Lt&&(e.params.element=e.params.element.iframeName())}else if(e&&e.type===Ye.REGEX_MATCH_RULE){if(e.params&&e.params.regex&&!Xe(e.params.regex))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_REGEX_IN_REGEX_MATCH_RULE);e.params&&e.params.regex&&Xe(e.params.regex)&&(e.params.regex=e.params.regex.toString())}}),t},Rt=(e,t,i)=>{let n=Object.assign({required:!1},t);if((Object.prototype.hasOwnProperty.call(n,"format")||Object.prototype.hasOwnProperty.call(n,"translation"))&&(V.includes(e)?(je(Be(d.INPUT_FORMATTING_NOT_SUPPROTED,e),ke.WARN,i),null==n||delete n.format,null==n||delete n.translation):e===b.INPUT_FIELD.name&&((e=>{if(e){if(Object.prototype.hasOwnProperty.call(e,"format")&&"string"!=typeof e.format)throw new o.PayrailsError(o.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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_INPUT_OPTIONS_TRANSLATION)}})(t),n=Object.assign(Object.assign({},n),{mask:[n.format,n.translation?n.translation:G]}),null==n||delete n.format,null==n||delete n.translation)),e===b.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)===D&&(e="-"),n=Object.assign(Object.assign({},n),{cardSeperator:e}),null==n||delete n.format,null==n||delete n.translation}else if(e===b.EXPIRATION_DATE.name){let e=!1;n.format&&(e=!!(s=n.format.toUpperCase())&&x.includes(s),e||je(Be(d.INVALID_EXPIRATION_DATE_FORMAT,x.toString()),ke.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():F}),null==n||delete n.translation}else if(e===b.EXPIRATION_YEAR.name){let e=!1;n.format&&(e=(e=>!!e&&j.includes(e))(n.format.toUpperCase()),e||je(Be(d.INVALID_EXPIRATION_YEAR_FORMAT,j.toString()),ke.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():"YY"}),null==n||delete n.translation}var s;if(Object.prototype.hasOwnProperty.call(n,"enableCardIcon")&&!qe(n.enableCardIcon))throw new o.PayrailsError(o.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")&&!qe(n.required))throw new o.PayrailsError(o.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 Nt(){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 St{}var Pt,bt,Dt,Mt,wt,kt,Yt,Ut,Ft,xt,jt,Bt;const Vt="CollectContainer";class Gt extends St{constructor(e,t,i,r){super(),Pt.set(this,void 0),bt.set(this,{}),Dt.set(this,void 0),Mt.set(this,void 0),wt.set(this,void 0),this.type=wi.COLLECT,kt.set(this,void 0),Yt.set(this,!1),this.create=(e,t={required:!1})=>{He(e,n(this,Mt,"f").logLevel);const i=Ct(e),s=Rt(e.type,t,n(this,Mt,"f").logLevel),o={rows:[{elements:[Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column,accept:t.allowedFileType},e),s),{validations:i})]}]};return n(this,Ut,"f").call(this,o,!0)},Ut.set(this,(e,t=!1)=>{const i=[],s=Se(e);if(s.rows.forEach(e=>{e.elements.forEach(e=>{const t=e,{elementType:n}=t;Ot(n,t),t.sensitive=t.sensitive||b[n].sensitive,t.replacePattern=t.replacePattern||b[n].replacePattern,t.mask=t.mask||b[n].mask,t.isMounted=!1,t.elementType!==b.radio.name&&t.elementType!==b.checkbox.name||(t.elementName=`${t.elementName}:${btoa(t.value)}`),t.elementName=`${u}:${t.elementType}:${btoa(Nt())}`,t.label=e.label,t.skyflowID=e.skyflowID,i.push(t)})}),s.elementName=t?i[0].elementName:`${u}:group:${btoa(s.name)}`,t&&!n(this,bt,"f")[i[0].elementName]&&n(this,Bt,"f").call(this,i[0].name))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_UNIQUE_ELEMENT_NAME);let r=n(this,bt,"f")[s.elementName];if(r)t?r.update(i[0]):r.update(s);else{const e=Nt();r=new Lt(e,s,n(this,Dt,"f"),{containerId:n(this,Pt,"f"),isMounted:n(this,Yt,"f"),type:this.type},t,n(this,xt,"f"),n(this,jt,"f"),n(this,Mt,"f"),n(this,kt,"f")),n(this,bt,"f")[s.elementName]=r,n(this,wt,"f")[e]=r}return t||i.forEach(e=>{const t=e.elementName;n(this,bt,"f")[t]?n(this,bt,"f")[t].update(e):n(this,bt,"f")[t]=this.create(e.elementType,r)}),r}),Ft.set(this,e=>{Object.keys(n(this,bt,"f")).forEach(t=>{t===e&&delete n(this,bt,"f")[t]})}),xt.set(this,e=>{e.forEach(e=>{n(this,Ft,"f").call(this,e)})}),jt.set(this,e=>{e.forEach(e=>{n(this,bt,"f")[e.elementName]&&n(this,bt,"f")[e.elementName].update(e)})}),Bt.set(this,e=>{const t=Object.keys(n(this,bt,"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(n(this,bt,"f")).forEach(e=>{if(!e.isMounted())throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);e.isValidElement()}),this.bus.emit(g+n(this,Pt,"f"),{},t=>{e(t)})}),this.collect=(e={tokens:!0})=>new Promise((t,i)=>{try{ze(n(this,Dt,"f").clientJSON.config);const s=Object.values(n(this,bt,"f"));let r=F;if(s.forEach(e=>{if(!e.isMounted())throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);e.isValidElement();const t=e.getOptions();t.elementType===R.EXPIRATION_DATE&&(r=t.format||"MM/YY")}),Object.prototype.hasOwnProperty.call(e,"tokens")&&!qe(e.tokens))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TOKENS);(null==e?void 0:e.additionalFields)&&Ge(e.additionalFields),(null==e?void 0:e.upsert)&&$e(null==e?void 0:e.upsert),this.bus.target(Ae.IFRAME_SECURE_ORGIN).emit(E+n(this,Pt,"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)?(je(`${JSON.stringify(null==e?void 0:e.error)}`,ke.ERROR,n(this,Mt,"f").logLevel),i(null==e?void 0:e.error)):(je(Be(a.COLLECT_SUBMIT_SUCCESS,Vt),ke.LOG,n(this,Mt,"f").logLevel),t(e))}),je(Be(a.EMIT_EVENT,Vt,E),ke.LOG,n(this,Mt,"f").logLevel)}catch(e){je(`${e.message}`,ke.ERROR,n(this,Mt,"f").logLevel),i(e)}}),this.unmount=()=>{this.iframe.remove()},this.bus=Ie.getEventBus(),s(this,Pt,Nt(),"f"),s(this,Dt,Object.assign(Object.assign({},t),(null==e?void 0:e.fonts)?{fonts:e.fonts}:{}),"f"),s(this,wt,i,"f"),s(this,Mt,r,"f"),s(this,kt,new fe,"f"),this.iframe=Ce({name:`${c}:${n(this,Pt,"f")}:${n(this,Mt,"f").logLevel}`}),Te(this.iframe,{src:Re()}),Ne(this.iframe,Object.assign({},w)),je(Be(a.CREATE_COLLECT_CONTAINER,Vt),ke.LOG,n(this,Mt,"f").logLevel);const l=(e,t)=>{e.name===c+n(this,Pt,"f")&&(t(Object.assign(Object.assign({},n(this,Dt,"f")),{clientJSON:Object.assign(Object.assign({},n(this,Dt,"f").clientJSON),{config:Object.assign({},n(this,Dt,"f").clientJSON.config)}),context:n(this,Mt,"f")})),s(this,Yt,!0,"f"),n(this,kt,"f")._emit(C,{containerId:n(this,Pt,"f")}),this.bus.target({origin:Ae.IFRAME_SECURE_ORGIN}).off(_+n(this,Pt,"f"),l))};this.bus.target({origin:Ae.IFRAME_SECURE_ORGIN}).on(_+n(this,Pt,"f"),l),document.body.append(this.iframe)}reset(){this.bus.emit(m+n(this,Pt,"f"))}}Pt=new WeakMap,bt=new WeakMap,Dt=new WeakMap,Mt=new WeakMap,wt=new WeakMap,kt=new WeakMap,Yt=new WeakMap,Ut=new WeakMap,Ft=new WeakMap,xt=new WeakMap,jt=new WeakMap,Bt=new WeakMap;const Xt=(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},zt=(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=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 Ht,$t,qt,Wt,Kt,Zt,Jt,Qt,ei,ti,ii,ni,si,oi,ri,ai,li,di,ci,ui,hi,pi,_i,Ei,mi;class vi{constructor(e,t){Ht.set(this,void 0),$t.set(this,void 0),qt.set(this,Ie.getEventBus()),Wt.set(this,null),this.type=wi.COMPOSABLE,Kt.set(this,!1),Zt.set(this,!1),this.update=e=>{s(this,Zt,!0,"f"),n(this,Kt,"f")?(n(this,$t,"f")._emit(O,{elementName:n(this,Ht,"f"),elementOptions:e}),s(this,Zt,!1,"f")):n(this,Zt,"f")&&n(this,$t,"f").on(`${De.READY}:${n(this,Ht,"f")}`,()=>{n(this,$t,"f")._emit(O,{elementName:n(this,Ht,"f"),elementOptions:e}),s(this,Kt,!0,"f"),s(this,Zt,!1,"f")})},s(this,Ht,e,"f"),s(this,$t,t,"f"),n(this,$t,"f").on(`${De.READY}:${n(this,Ht,"f")}`,()=>{s(this,Kt,!0,"f")})}on(e,t){if(!Object.values(p).includes(e))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_LISTENER);if(!t)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_HANDLER_IN_EVENT_LISTENER);if("function"!=typeof t)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_HANDLER_IN_EVENT_LISTENER);n(this,$t,"f").on(`${e}:${n(this,Ht,"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)}s(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=n(this,Wt,"f")||{isEmpty:!0,isValid:!1,isComplete:!1,isFocused:!0,isRequired:!1};n(this,qt,"f").emit(v,{name:n(this,Ht,"f"),event:p.FOCUS,value:Object.assign(Object.assign({},e),{isFocused:!0})})}setAttribute(e,t){n(this,$t,"f")._emit(f,{elementName:n(this,Ht,"f"),attribute:e,value:t})}}Ht=new WeakMap,$t=new WeakMap,qt=new WeakMap,Wt=new WeakMap,Kt=new WeakMap,Zt=new WeakMap;const yi="CollectContainer";class Ii extends St{constructor(e,t,i,l){super(),Jt.set(this,void 0),Qt.set(this,{}),ei.set(this,void 0),ti.set(this,{rows:[]}),ii.set(this,[]),ni.set(this,void 0),si.set(this,void 0),oi.set(this,void 0),ri.set(this,!1),ai.set(this,void 0),li.set(this,void 0),this.type=wi.COMPOSABLE,di.set(this,!1),ci.set(this,{}),this.create=(e,t={required:!1})=>{He(e,n(this,ni,"f").logLevel);const i=Ct(e),s=Rt(e.type,t,n(this,ni,"f").logLevel),o=`${u}:${e.type}:${btoa(Nt())}`;return n(this,ii,"f").push(Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column},e),s),{validations:i,elementName:o})),new vi(o,n(this,oi,"f"))},ui.set(this,(e,t=!1)=>{const i=[];if(s(this,Qt,{},"f"),s(this,ci,Se(e),"f"),n(this,ci,"f").rows.forEach(e=>{e.elements.forEach(e=>{const t=e,{elementType:n}=t;Ot(n,t),t.sensitive=t.sensitive||b[n].sensitive,t.replacePattern=t.replacePattern||b[n].replacePattern,t.mask=t.mask||b[n].mask,t.isMounted=!1,t.label=e.label,t.skyflowID=e.skyflowID,i.push(t)})}),n(this,ci,"f").elementName=t?i[0].elementName:`${u}:group:${btoa(n(this,ci,"f").name)}`,t&&!n(this,Qt,"f")[i[0].elementName]&&n(this,Ei,"f").call(this,i[0].name))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_UNIQUE_ELEMENT_NAME);let r=n(this,Qt,"f")[n(this,ci,"f").elementName];if(r)t?r.update(i[0]):r.update(n(this,ci,"f"));else{const e=Nt();r=new Lt(e,n(this,ci,"f"),n(this,ei,"f"),{containerId:n(this,Jt,"f"),isMounted:n(this,di,"f"),type:this.type},!0,n(this,pi,"f"),n(this,_i,"f"),n(this,ni,"f"),n(this,oi,"f")),n(this,Qt,"f")[n(this,ci,"f").elementName]=r,n(this,si,"f")[e]=r}return r}),hi.set(this,e=>{Object.keys(n(this,Qt,"f")).forEach(t=>{t===e&&delete n(this,Qt,"f")[t]})}),pi.set(this,e=>{e.forEach(e=>{n(this,hi,"f").call(this,e)})}),_i.set(this,e=>{e.forEach(e=>{n(this,Qt,"f")[e.elementName]&&n(this,Qt,"f")[e.elementName].update(e)})}),Ei.set(this,e=>{const t=Object.keys(n(this,Qt,"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(p).includes(e))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_LISTENER);if(!t)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_HANDLER_IN_EVENT_LISTENER);if("function"!=typeof t)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_HANDLER_IN_EVENT_LISTENER);n(this,oi,"f").on(p.SUBMIT,()=>{t()})},this.mount=e=>{if(!e)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_IN_MOUNT);s(this,ti,{rows:[]},"f");const{layout:t}=n(this,ai,"f");if((t||[]).reduce((e,t)=>e+t,0)!==n(this,ii,"f").length)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISMATCH_ELEMENT_COUNT_LAYOUT_SUM);let i=0;if(t.forEach((e,t)=>{n(this,ti,"f").rows=[...n(this,ti,"f").rows,{elements:[]}];for(let s=0;s<e;s++)n(this,ti,"f").rows[t].elements.push(n(this,ii,"f")[i]),i++}),n(this,ai,"f").styles&&(n(this,ti,"f").styles=Object.assign({},n(this,ai,"f").styles)),n(this,ai,"f").errorTextStyles&&(n(this,ti,"f").errorTextStyles=Object.assign({},n(this,ai,"f").errorTextStyles)),n(this,di,"f"))return n(this,li,"f")&&(n(this,li,"f").unmount(),s(this,li,null,"f")),s(this,Qt,{},"f"),s(this,li,n(this,ui,"f").call(this,n(this,ti,"f"),!1),"f"),this.mountContainerElement(e),void s(this,ri,!0,"f");n(this,oi,"f").on(T+n(this,Jt,"f"),()=>{s(this,Qt,{},"f"),s(this,li,n(this,ui,"f").call(this,n(this,ti,"f"),!1),"f"),this.mountContainerElement(e),s(this,ri,!0,"f")})},this.mountContainerElement=e=>{n(this,li,"f").mount(e)},this.unmount=()=>{var e;[...n(this,ii,"f").map(e=>e.elementName)].forEach(e=>{n(this,hi,"f").call(this,e)}),s(this,ii,[],"f"),s(this,ti,{rows:[]},"f"),s(this,Qt,{},"f"),null===(e=n(this,li,"f"))||void 0===e||e.unmount(),this.iframe.remove(),s(this,ri,!1,"f"),s(this,di,!1,"f")},this.validate=()=>new Promise((e,t)=>{Object.values(n(this,Qt,"f")).forEach(e=>{if(!e.isMounted())throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);e.isValidElement()}),this.bus.emit(g+n(this,Jt,"f"),{},t=>{e(t)})}),this.collect=(e={tokens:!0})=>new Promise((t,i)=>{try{if(ze(n(this,ei,"f").clientJSON.config),!n(this,ri,"f")){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);throw r.PayrailsLogger.error(e.message,{error:e}),e}if(Tt(n(this,ci,"f")).forEach(e=>{if(!(null==e?void 0:e.isMounted))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING)}),Object.values(n(this,Qt,"f")).forEach(e=>{e.isValidElement()}),e&&e.tokens&&"boolean"!=typeof e.tokens)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TOKENS);(null==e?void 0:e.additionalFields)&&Ge(e.additionalFields),(null==e?void 0:e.upsert)&&$e(null==e?void 0:e.upsert),this.bus.emit(E+n(this,Jt,"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)?(je(`${JSON.stringify(null==e?void 0:e.error)}`,ke.ERROR,n(this,ni,"f").logLevel),i(null==e?void 0:e.error)):(je(Be(a.COLLECT_SUBMIT_SUCCESS,yi),ke.LOG,n(this,ni,"f").logLevel),t(e))}),je(Be(a.EMIT_EVENT,yi,E),ke.LOG,n(this,ni,"f").logLevel)}catch(e){je(`${e.message}`,ke.ERROR,n(this,ni,"f").logLevel),i(e)}}),mi.set(this,()=>{n(this,oi,"f").on(O,e=>{let t;const i=n(this,ii,"f").map((i,n)=>i.elementName===e.elementName?(t=n,Object.assign({elementName:i.elementName},e.elementOptions)):i);n(this,li,"f")&&n(this,li,"f").updateElement(Object.assign({},i[t]))})}),this.bus=Ie.getEventBus(),s(this,Jt,Nt(),"f"),s(this,ei,Object.assign(Object.assign({},t),(null==e?void 0:e.fonts)?{fonts:e.fonts}:{}),"f"),s(this,si,i,"f"),s(this,ni,l,"f"),s(this,ai,e,"f"),s(this,oi,new fe,"f"),this.iframe=Ce({name:`${c}:${n(this,Jt,"f")}:${n(this,ni,"f").logLevel}`}),Te(this.iframe,{src:Re()}),Ne(this.iframe,Object.assign({},w)),je(Be(a.CREATE_COLLECT_CONTAINER,yi),ke.LOG,n(this,ni,"f").logLevel);const d=(e,t)=>{e.name===c+n(this,Jt,"f")&&(t(Object.assign(Object.assign({},n(this,ei,"f")),{clientJSON:Object.assign(Object.assign({},n(this,ei,"f").clientJSON),{config:Object.assign({},n(this,ei,"f").clientJSON.config)}),context:n(this,ni,"f")})),s(this,di,!0,"f"),n(this,oi,"f")._emit(T+n(this,Jt,"f"),{containerId:n(this,Jt,"f")}),this.bus.target({origin:Ae.IFRAME_SECURE_ORGIN}).off(_+n(this,Jt,"f"),d))};this.bus.target({origin:Ae.IFRAME_SECURE_ORGIN}).on(_+n(this,Jt,"f"),d),document.body.append(this.iframe),n(this,mi,"f").call(this)}reset(){this.bus.emit(m+n(this,Jt,"f"),{})}}function fi(e){this.message=e}Jt=new WeakMap,Qt=new WeakMap,ei=new WeakMap,ti=new WeakMap,ii=new WeakMap,ni=new WeakMap,si=new WeakMap,oi=new WeakMap,ri=new WeakMap,ai=new WeakMap,li=new WeakMap,di=new WeakMap,ci=new WeakMap,ui=new WeakMap,hi=new WeakMap,pi=new WeakMap,_i=new WeakMap,Ei=new WeakMap,mi=new WeakMap,fi.prototype=new Error,fi.prototype.name="InvalidCharacterError";var Ai="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new fi("'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 Li(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(Ai(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 Ai(t)}}function Oi(e){this.message=e}Oi.prototype=new Error,Oi.prototype.name="InvalidTokenError";const gi=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 Oi("Invalid token specified");var i=!0===(t=t||{}).header?0:1;try{return JSON.parse(Li(e.split(".")[i]))}catch(e){throw new Oi("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 Ti,Ci,Ri,Ni,Si,Pi,bi,Di,Mi,wi;class ki{constructor(e,t){Ti.set(this,void 0),this.config=e,s(this,Ti,t,"f")}toJSON(){return{config:this.config,metaData:n(this,Ti,"f")}}static fromJSON(e){return new ki(e.config,e.metaData)}}Ti=new WeakMap,function(e){e.COLLECT="COLLECT",e.COMPOSABLE="COMPOSABLE"}(wi||(wi={}));const Yi="Skyflow";class Ui{constructor(e){var t,i;Ci.set(this,void 0),Ri.set(this,Nt()),Ni.set(this,{uuid:n(this,Ri,"f"),clientDomain:window.location.origin}),Si.set(this,""),Pi.set(this,void 0),bi.set(this,void 0),Di.set(this,void 0),Mi.set(this,void 0),this.bus=Ie.getEventBus();const d=localStorage.getItem("sdk_version")||"";n(this,Ni,"f").sdkVersion=d,s(this,Ci,new ki(Object.assign({},e),n(this,Ni,"f")),"f"),s(this,bi,(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||Me.ERROR,"f"),s(this,Di,(null===(i=null==e?void 0:e.options)||void 0===i?void 0:i.env)||we.PROD,"f"),s(this,Mi,{},"f"),this.bus.on(h,e=>{if(e&&e.errorCode){const t=new o.PayrailsError(e.errorCode,{cause:null==e?void 0:e.originalError});r.PayrailsLogger.error(t.message,{error:t})}}),this.bus.target({origin:Ae.IFRAME_SECURE_ORGIN}).on(A+n(this,Ri,"f"),(e,t)=>{je(Be(a.CAPTURED_BEARER_TOKEN_EVENT,Yi),ke.LOG,n(this,bi,"f")),!n(this,Ci,"f").config.getBearerToken||n(this,Si,"f")&&gi(n(this,Si,"f"))?(je(Be(a.REUSE_BEARER_TOKEN,Yi),ke.LOG,n(this,bi,"f")),t({authToken:n(this,Si,"f")})):n(this,Ci,"f").config.getBearerToken().then(e=>{gi(e)?(je(Be(a.BEARER_TOKEN_RESOLVED,Yi),ke.LOG,n(this,bi,"f")),s(this,Si,e,"f"),t({authToken:n(this,Si,"f")})):(je(l.INVALID_BEARER_TOKEN,ke.ERROR,n(this,bi,"f")),t({error:l.INVALID_BEARER_TOKEN}))}).catch(e=>{je(l.BEARER_TOKEN_REJECTED,ke.ERROR,n(this,bi,"f")),t({error:e})})}),je(Be(a.BEARER_TOKEN_LISTENER,Yi),ke.LOG,n(this,bi,"f")),je(Be(a.CURRENT_ENV,Yi,n(this,Di,"f")),ke.LOG,n(this,bi,"f")),je(Be(a.CURRENT_LOG_LEVEL,Yi,n(this,bi,"f")),ke.LOG,n(this,bi,"f"))}static init(e){var t;const i=(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||Me.ERROR;Ze(e),je(Be(a.INITIALIZE_CLIENT,Yi),ke.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 Ui(n);return je(Be(a.CLIENT_INITIALIZED,Yi),ke.LOG,i),o}container(e,t){switch(e){case wi.COLLECT:{const i=new Gt(t,Object.assign(Object.assign({},n(this,Ni,"f")),{clientJSON:n(this,Ci,"f").toJSON(),containerType:e}),n(this,Mi,"f"),{logLevel:n(this,bi,"f"),env:n(this,Di,"f")});return je(Be(a.COLLECT_CONTAINER_CREATED,Yi),ke.LOG,n(this,bi,"f")),i}case wi.COMPOSABLE:{(e=>{if(!e)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_COMPOSABLE_CONTAINER_OPTIONS);if("object"!=typeof e)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COMPOSABLE_CONTAINER_OPTIONS_INVALID);if(!Object.prototype.hasOwnProperty.call(e,"layout"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_COMPOSABLE_LAYOUT_KEY);if(!e.layout)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_LAYOUT_TYPE);if(!Array.isArray(e.layout))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_LAYOUT_TYPE);if(0===e.layout.length)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_COMPOSABLE_LAYOUT_ARRAY);e.layout.forEach(e=>{if("number"!=typeof e)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COMPOSABLE_LAYOUT_TYPE);if(e<0)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_NEGATIVE_VALUES_COMPOSABLE_LAYOUT)})})(t);const i=new Ii(t,Object.assign(Object.assign({},n(this,Ni,"f")),{clientJSON:n(this,Ci,"f").toJSON(),containerType:e}),n(this,Mi,"f"),{logLevel:n(this,bi,"f"),env:n(this,Di,"f")});return je(Be(a.COLLECT_CONTAINER_CREATED,Yi),ke.LOG,n(this,bi,"f")),i}default:if(!e)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_CONTAINER_TYPE);throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_CONTAINER_TYPE)}}static get ContainerType(){return wi}static get ElementType(){return R}static get RedactionType(){return Pe}static get RequestMethod(){return be}static get LogLevel(){return Me}static get EventName(){return De}static get Env(){return we}static get ValidationRuleType(){return Ye}}Ci=new WeakMap,Ri=new WeakMap,Ni=new WeakMap,Si=new WeakMap,Pi=new WeakMap,bi=new WeakMap,Di=new WeakMap,Mi=new WeakMap;const Fi=(e,t)=>i(void 0,void 0,void 0,function*(){if(null==e?void 0:e.onDeliveryAddressChanged)try{const i=yield e.onDeliveryAddressChanged(t);if(!i){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onDeliveryAddressChanged resolved to false"});return r.PayrailsLogger.error(e.message,{error:e}),!1}return i}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onDeliveryAddressChanged threw an error",cause:e});return r.PayrailsLogger.error(t.message,{error:t}),!1}return!0}),xi=(t,n)=>i(void 0,void 0,void 0,function*(){try{const i=yield Eo(t,n);if(!i){const s=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onRequestStart resolved to false"});return _o(t,n,{code:e.AuthorizationFailureReasons.VALIDATION_FAILED,message:s.message}),i}}catch(i){const s=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onRequestStart threw an error",cause:i});return r.PayrailsLogger.error(s.message,{error:s}),_o(t,n,{code:e.AuthorizationFailureReasons.VALIDATION_FAILED,message:s.message}),!1}return!0});let ji={};class Bi{constructor(e,{id:t="",className:i="",dataTestId:n=""}={}){this.subElements=[],this.eventBus=Ie.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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);return`#${this.id}`}mount(e){const t=document.querySelector(e);if(!t)throw new o.PayrailsError(o.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 o.PayrailsError(o.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 Vi extends Bi{tokenize(e){return i(this,void 0,void 0,function*(){const t=yield this.collect(),i=Q(),n=i.vaultConfiguration.links.saveInstrument,s=i.token;if(!n.href){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND,{description:"Save instrument URL not available!"});throw r.PayrailsLogger.error(e.message,{error:e}),e}const a=yield this.constructSaveInstrumentBody(t,e);return(yield me({url:n.href,token:s,body:a})).res})}}class Gi{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){return!!t.pattern&&!new RegExp(t.pattern).test(e)}static oneOf(e,t){return!(!t.oneOf||0===t.oneOf.length)&&!t.oneOf.map(e=>e.const).includes(e)}}class Xi extends Bi{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=[];return this._isVisible&&this._isRequired&&Gi.required(this.value,!0,this.options.property)&&t.push(this.options.errors.required),this.value&&(Gi.minLength(this.value,this.options.property)&&t.push(this.options.errors.minLength),Gi.maxLength(this.value,this.options.property)&&t.push(this.options.errors.maxLength),Gi.pattern(this.value,this.options.property)&&t.push(this.options.errors.pattern),Gi.oneOf(this.value,this.options.property)&&t.push(this.options.errors.oneOf)),e?0===t.length:(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 zi extends Xi{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,void 0!==this.options.value&&(this.component.value=this.options.value),this.options.readOnly&&(this.component.readOnly=!0,this.component.classList.add("payrails-dynamic-element-input--readonly")),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 Hi extends Xi{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)}),void 0!==this.options.value&&(this.component.value=this.options.value),this.options.readOnly&&(this.component.disabled=!0,this.component.classList.add("payrails-dynamic-element-select--readonly")),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 $i extends Xi{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(){}}var qi;!function(e){e.GET="GET"}(qi||(qi={}));const Wi=e=>i(void 0,[e],void 0,function*({url:e}){const t={method:qi.GET},i=yield fetch(e,t),n=yield i.json();if(429===i.status)throw new Zi(e,qi.GET);if(!i.ok)throw new Ki(e,qi.GET);return{ok:i.ok,req:Object.assign({url:e},t),res:n}});class Ki extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{description:`[${t}] ${e} unsuccessful`})}}class Zi extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} too many requests`})}}const Ji="ui:position";function Qi(e){return i(this,void 0,void 0,function*(){if(!e||"object"!=typeof e)return e;const t=en(e);if(0===t.size)return e;const n=yield function(e){return i(this,void 0,void 0,function*(){const t=new Map,n=Array.from(e).map(e=>i(this,void 0,void 0,function*(){try{const i=(yield Wi({url:e})).res;t.set(e,i)}catch(t){console.warn(`Failed to fetch schema from ${e}:`,t)}}));return yield Promise.all(n),t})}(t);return tn(e,n)})}function en(e,t=new Set){return Array.isArray(e)?e.forEach(e=>en(e,t)):e&&"object"==typeof e&&(e.$ref&&/^https?:\/\//.test(e.$ref)&&t.add(e.$ref),Object.values(e).forEach(e=>en(e,t))),t}function tn(e,t){if(Array.isArray(e))return e.map(e=>tn(e,t));if(e&&"object"==typeof e){if(e.$ref&&/^https?:\/\//.test(e.$ref)){if(!t.has(e.$ref))return;const i=tn(t.get(e.$ref),t);return void 0!==e[Ji]?Object.assign(Object.assign({},i),{[Ji]:e[Ji]}):i}const i={};for(const[n,s]of Object.entries(e)){const e=tn(s,t);void 0!==e&&(i[n]=e)}return i}return e}function nn(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 sn(e,t,i,n){var s,o,r,a,l,d,c,u,h,p,_,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:z({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!==(h=null==n?void 0:n.errors)&&void 0!==h?h:{},null!==(E=null===(_=null===(p=null==n?void 0:n.fields)||void 0===p?void 0:p[e])||void 0===_?void 0:_.errors)&&void 0!==E?E:{}),required:i}}function on(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 rn extends Vi{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 i(this,void 0,void 0,function*(){if(!this.parentElement)throw new o.PayrailsError(o.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=zt(e,t.name,t.value))}),!this.isFormValid())throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_DYNAMIC_ELEMENT_FORM_INVALID,{description:"Dynamic element form is invalid"});return e})}constructSaveInstrumentBody(e,t){return i(this,void 0,void 0,function*(){var i,n;return{data:e,merchantReference:W.response.merchantReference,holderReference:W.response.holderReference,holderId:W.response.holderId,paymentMethod:null===(i=this.options.paymentMethod)||void 0===i?void 0:i.paymentMethodCode,storeInstrument:null!==(n=null==t?void 0:t.storeInstrument)&&void 0!==n&&n}})}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 t=Object.create(null,{mount:{get:()=>super.mount}});return i(this,void 0,void 0,function*(){var i,n;yield this.makeForm(),t.mount.call(this,e),null===(n=null===(i=this.options.events)||void 0===i?void 0:i.onReady)||void 0===n||n.call(i)})}makeForm(){return i(this,void 0,void 0,function*(){var e;if(!(null===(e=this.formConfig)||void 0===e?void 0:e.schema))return;this.__schema=yield Qi(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]=sn(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[Ji])&&void 0!==i?i:0)-(null!==(n=t.property[Ji])&&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){var i,n;const s=this.extractStyles(e.name,t),o=this.makeFieldEvents(e.name),r=z(e,null!==(n=null===(i=this.options.fieldOverrides)||void 0===i?void 0:i[e.name])&&void 0!==n?n:{});switch(t){case"tabs":return new $i(Object.assign(Object.assign({},r),{events:o,styles:s,options:on(e.property)}));case"select":return new Hi(Object.assign(Object.assign({},r),{events:o,styles:s,options:on(e.property)}));case"input":return new zi(Object.assign(Object.assign({},r),{events:o,styles:s}));default:throw new Error(`Unsupported component type: ${t}`)}}extractStyles(e,t){var i,n,s,o,r,a,l,d,c,u,h,p,_,E;const m=z({},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=z({},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===(_=null===(p=null===(h=this.options.styles)||void 0===h?void 0:h.fields)||void 0===p?void 0:p[e])||void 0===_?void 0:_.errors)&&void 0!==E?E:{});return{[t]:m,errors:v}}makeFieldEvents(e){return{onChange:(t=>{this.formData=zt(this.formData,e,t),this.evaluateDependencies()}).bind(this),onReady:(t=>{this.formData=zt(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=Xt(t,n);if(s.oneOf){const t=nn(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 an={fields:{email:{label:"Email",placeholder:"you@example.com"},line1:{label:"Address line 1",placeholder:"Street and number"},line2:{label:"Address line 2",placeholder:"Apartment, suite, etc."},city:{label:"City",placeholder:"City"},state:{label:"State / region",placeholder:"State / region"},postalCode:{label:"Postal code",placeholder:"Postal code"},country:{label:"Country",placeholder:"Select a country"}}};class ln extends Bi{constructor(e){super("div",{className:"payrails-billing-address-form-title"}),this.element.innerText=e}}class dn extends Bi{static get current(){return dn._current}static reset(){dn._current=void 0}constructor(e){var t,i,n;super("div",{id:"payrails-billing-address-form",className:"payrails-billing-address-form"}),this.form=new rn({styles:e.styles,translations:z(an,null!==(t=e.translations)&&void 0!==t?t:{}),fieldOverrides:dn.toFieldOverrides(e.prefill),events:{onReady:null===(i=e.events)||void 0===i?void 0:i.onReady}},{schema:e.schema}),this.subElements.push(new ln(null!==(n=e.title)&&void 0!==n?n:"Billing Address"),this.form)}static toFieldOverrides(e={}){const{street:i}=e,n=t(e,["street"]),s=Object.assign(Object.assign({},n),{line1:i});return Object.fromEntries(Object.entries(s).filter(([,e])=>e).map(([e,t])=>[e,{value:t,readOnly:!0}]))}collect(){return i(this,void 0,void 0,function*(){dn._current=void 0;const e=yield this.form.collect();return dn._current=e,e})}}const cn=(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=un(t.userAgent);return n&&(i.osType=n),i},un=e=>/android/i.test(e)?"android":/iphone|ipad|ipod/i.test(e)?"ios":/windows|linux|mac/i.test(e)?"web":void 0,hn={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 pn{static getInstance(){return this.instance||(this.instance=new pn),this.instance}constructor(e=""){this.lastActionUpdateTime=e,pn.instance=this}}class _n{constructor(e=hn,t=680,i=60,n=2e3,s=5,o=pn.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 i(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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR,{cause:e});throw r.PayrailsLogger.error(t.message,{error:t}),e}})}payout(e){return i(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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAYOUT_ERROR,{cause:e});throw r.PayrailsLogger.error(t.message,{error:t}),e}})}confirm(e){return i(this,arguments,void 0,function*(e,t={}){try{const i=yield ae({url:e,method:se.POST,token:Q().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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR,{cause:e});throw r.PayrailsLogger.error(t.message,{error:t}),e}})}getExecution(e,t){return i(this,arguments,void 0,function*(e,t,i=0,n){if(i>this.MAX_POLL_ATTEMPTS)throw new ue(e,se.GET);0===i&&t?yield this.wait(this.POLL_INITIAL_DELAY,n):yield this.wait(this.POLL_INTERVAL,n);try{const s=yield ae({url:e,token:Q().token});return t&&!s.res.status.find(({time:e})=>new Date(e)>new Date(t))?(yield this.wait(this.POLL_INTERVAL,n),this.getExecution(e,t,i+1,n)):s}catch(s){if(s instanceof de)return yield this.wait(this.POLL_INTERVAL,n),this.getExecution(e,t,i+this.POLL_ERROR_COUNT_MULTIPLIER,n);if(s instanceof ce)return yield this.wait(this.POLL_INTERVAL*i,n),this.getExecution(e,t,i+1,n);throw s}})}createApplePaySession(e){return i(this,void 0,void 0,function*(){return ae({url:e.requestUrl,method:se.POST,token:Q().token,body:{integrationType:"api",paymentMethodCode:"applePay",amount:Q().amount,meta:{sessionURL:e.sessionUrl,clientContext:{host:e.clientDomain||window.location.host}}}})})}authorize(e){return i(this,void 0,void 0,function*(){if(!W.authorizeLink||!Q().amount){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND,{description:"SDK was not initialized with workflow execution"});throw r.PayrailsLogger.error(e.message,{error:e}),e}const{success:t=hn.success,error:i=hn.error,cancel:n=hn.cancel,pending:s=hn.pending}=this.returnLinks,a=this.attachMetaToPaymentComposition({amount:Q().amount,paymentComposition:e,returnInfo:{success:t,cancel:n,error:i,pending:s}});return ae({url:W.authorizeLink,method:se.POST,token:Q().token,body:a})})}executePayout(e){return i(this,void 0,void 0,function*(){if(!W.payoutLink||!Q().amount){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND,{description:"SDK was not initialized with workflow execution"});throw r.PayrailsLogger.error(e.message,{error:e}),e}const t={amount:Q().amount,payoutComposition:e};return ae({url:W.payoutLink,method:se.POST,token:Q().token,body:t})})}getFirstNonFraudNetId(e){const t=Object.keys(e||{}).find(e=>"fraudNet"!==e);return t?e[t]:null}attachMetaToPaymentComposition(t){var i,n,s,o,r,a,l;let d;d=t.paymentComposition[0].paymentMethodCode===e.PAYMENT_METHOD_CODES.PAYPAL&&(null===(n=null===(i=window.PayrailsData)||void 0===i?void 0:i.riskIds)||void 0===n?void 0:n.fraudNet)?null===(o=null===(s=window.PayrailsData)||void 0===s?void 0:s.riskIds)||void 0===o?void 0:o.fraudNet:this.getFirstNonFraudNetId(null===(r=window.PayrailsData)||void 0===r?void 0:r.riskIds)||"";const c=Object.assign(Object.assign({},t),{meta:Object.assign(Object.assign({},W.getUpdatedMeta()),t.meta)});!1!==(null===(a=ji.telemetry)||void 0===a?void 0:a.collectMetadata)&&(c.meta=Object.assign(Object.assign({},c.meta),{clientContext:Object.assign(Object.assign({},(null===(l=c.meta)||void 0===l?void 0:l.clientContext)||{}),cn())})),d&&(c.meta.risk={sessionId:d});const u=dn.current;return u&&(c.paymentComposition=c.paymentComposition.map(e=>{var t,i;return(null===(t=e.paymentInstrumentData)||void 0===t?void 0:t.billingAddress)?e:Object.assign(Object.assign({},e),{paymentInstrumentData:Object.assign(Object.assign({},null!==(i=e.paymentInstrumentData)&&void 0!==i?i:{}),{billingAddress:u})})})),c}wait(e,t){return i(this,void 0,void 0,function*(){var i;if(null==t?void 0:t.aborted)throw null!==(i=t.reason)&&void 0!==i?i:new DOMException("Aborted","AbortError");return new Promise((i,n)=>{const s=setTimeout(()=>{null==t||t.removeEventListener("abort",o),i()},e),o=()=>{var e;clearTimeout(s),null==t||t.removeEventListener("abort",o),n(null!==(e=null==t?void 0:t.reason)&&void 0!==e?e:new DOMException("Aborted","AbortError"))};null==t||t.addEventListener("abort",o,{once:!0})})})}pollForAuthorizationResult(e){return i(this,arguments,void 0,function*(e,t=0,i=["authorizePending","authorizeSuccessful","authorizeFailed","payoutPending","payoutSuccessful","payoutFailed"],n){var s;const a=null==n?void 0:n.signal;if(null==a?void 0:a.aborted)throw null!==(s=a.reason)&&void 0!==s?s: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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED);throw r.PayrailsLogger.error(e.message,{error:e}),e}const u=d.find(({code:e,time:t})=>"confirmRequested"===e&&new Date(t)>new Date(c.time)),h=u?u.time:c.time,p=d.filter(({code:e,time:t})=>i.includes(e)&&new Date(t)>new Date(h)).sort((e,t)=>new Date(t.time).getTime()-new Date(e.time).getTime())[0];return p?(this.paymentStatus.lastActionUpdateTime=p.time,{finalState:p,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 pn(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,n,s=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:{}}),o=s.queryParams,r=s.dataAttributes;return{url:"".concat(t,"?").concat((i=o,n="",Object.keys(i).forEach(function(e){0!==n.length&&(n+="&"),n+=e+"="+i[e]}),n)),dataAttributes:r}}function _n(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 En(e,t){if(void 0===t&&(t=mn()),yn(e,t),"undefined"==typeof window)return t.resolve(null);var i=pn(e),n=i.url,s=i.dataAttributes,o=s["data-namespace"]||"paypal",r=vn(o);return function(e,t){var i=document.querySelector('script[src="'.concat(e,'"]'));if(null===i)return null;var n=_n(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=mn()),yn(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=_n(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=vn(o);if(e)return e;throw new Error("The window.".concat(o," global variable is not available."))})}function mn(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function vn(e){return window[e]}function yn(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.")}var In;!function(e){e.ApplePay="https://applepay.cdn-apple.com/jsapi/v1.3.2/apple-pay-sdk.js",e.GooglePay="https://pay.google.com/gp/p/js/pay.js",e.PayPal="paypal-sdk",e.Lean="https://cdn.leantech.me/link/loader/prod/ae/latest/lean-link-loader.min.js"}(In||(In={}));class fn{static load(e,t){const n=e.toString(),s=fn.scriptMap.get(n);if(s)return s;const o=(()=>i(this,void 0,void 0,function*(){try{if(e===In.PayPal){if(!t)throw new Error("PayPal config is required");return yield fn.loadPayPalScript(t)}return yield fn.loadScript(e)}finally{fn.scriptMap.delete(n)}}))();return fn.scriptMap.set(n,o),o}static reset(){fn.scriptMap.clear()}static invalidate(e){var t;fn.scriptMap.delete(e.toString());const i=fn.getScriptKey(e);fn.scriptMap.delete(i),null===(t=document.getElementById(i))||void 0===t||t.remove()}static preloadCardForm(){const e="https://assets.payrails.io/739d580/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=fn.getScriptKey(e);if(fn.scriptMap.has(t))return fn.scriptMap.get(t);const i=document.createElement("script");i.src=e,i.id=t;const n=fn.sdkScriptAttributes[e];n&&Object.entries(n).forEach(([e,t])=>{i.setAttribute(e,t)});const s=new Promise((t,n)=>{i.onload=()=>t(),i.onerror=t=>n(fn.logLoadError(e,new Error(t.toString())))}).catch(e=>{throw fn.scriptMap.delete(t),i.remove(),e});return fn.scriptMap.set(t,s),document.body.appendChild(i),s}static getScriptKey(e){return`payrails-script-${JSON.stringify(e)}`}static loadPayPalScript(e){return i(this,arguments,void 0,function*({clientId:e,currency:t,vault:i,intent:n,locale:s}){let a;for(let l=0;l<=fn.PAYPAL_MAX_RETRIES;l++){l>0&&(fn.removePayPalScriptElements(),yield fn.delay(fn.PAYPAL_BASE_DELAY_MS*Math.pow(2,l-1)));try{const o=yield En(Object.assign({"client-id":e,components:"buttons,funding-eligibility",intent:n,currency:t,vault:i,"data-namespace":"payrailsPaypal"},s&&{locale:s}));if(o)return o;a=new Error("The window.payrailsPaypal global variable is not available.")}catch(e){a=e}const d=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR,{cause:a});r.PayrailsLogger.error(`PayPal SDK load attempt ${l+1}/${fn.PAYPAL_MAX_RETRIES+1} failed`,{error:d})}throw fn.logLoadError(In.PayPal,a)})}static removePayPalScriptElements(){document.querySelectorAll('script[src*="paypal.com/sdk/js"]').forEach(e=>e.remove())}static delay(e){return new Promise(t=>setTimeout(t,e))}constructor(){}static logLoadError(e,t){const i=new Map([[In.ApplePay,o.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR],[In.GooglePay,o.ERROR_CODES.PAYRAILS_CLIENT_GPAY_LOADING_ERROR],[In.PayPal,o.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR]]),n=new o.PayrailsError(i.get(e)||o.ERROR_CODES.PAYRAILS_CLIENT_UNKNOWN_ERROR,{cause:t,description:null==t?void 0:t.message});return r.PayrailsLogger.error(n.message,{error:n}),n}}fn.scriptMap=new Map,fn.sdkScriptAttributes={[In.ApplePay]:{crossorigin:"anonymous",integrity:"sha384-DZRWMZLyVXr+7shJfal8pIG2v4KisLoSWFjZQMUv0+GWaCwoa82qeHsWrbBIUDPU"}},fn.PAYPAL_MAX_RETRIES=2,fn.PAYPAL_BASE_DELAY_MS=1e3;const An=/^[a-zA-Z]+([_-][a-zA-Z0-9]+)*$/,Ln=e=>e.replace("_","-"),gn=e=>{if(e&&An.test(e))return e},On=e=>{var t,i;const n=gn(e)||gn(null===(i=null===(t=ce.meta)||void 0===t?void 0:t.customer)||void 0===i?void 0:i.language)||"en-GB";return Ln(n)};class Tn extends xi{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`,h=`${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 p="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="${h}" class="payrails-store-instrument-checkbox">${c}</label>`,p&&(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 Cn extends xi{constructor(e,t){var n,s,o,r,a;super(e,t),this.options=t,this.storeInstrumentCheckbox=null,(null===(n=this.options)||void 0===n?void 0:n.showStoreInstrumentCheckbox)&&(this.storeInstrumentCheckbox=new Tn(Object.assign(Object.assign({},t),{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=>i(this,void 0,void 0,function*(){var i,n;null===(n=null===(i=null==t?void 0:t.events)||void 0===i?void 0:i.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(i,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 Rn extends Cn{static isApplePayAvailable(){return i(this,void 0,void 0,function*(){try{return yield fn.load(In.ApplePay),ApplePaySession.canMakePayments()}catch(e){return!1}})}constructor(e){super("div",Object.assign(Object.assign({},e),{id:`payrails-apple-pay-button-${$()}`,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 hn,Rn.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"===_e().type?oo.TOKENIZE:oo.AUTHORIZE}mount(e){this.unmount(),super.mount(e),(()=>{i(this,void 0,void 0,function*(){try{(yield Rn.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 i(this,void 0,void 0,function*(){var e,t,n,s;try{const o=(null===(e=this.options.styles)||void 0===e?void 0:e.type)||"buy",r=(null===(t=this.options.styles)||void 0===t?void 0:t.style)||"black",a=On(null===(n=this.options.styles)||void 0===n?void 0:n.locale);this.element.innerHTML=`<apple-pay-button buttonstyle="${r}" type="${o}" locale="${a}"></apple-pay-button>`,null===(s=this.storeInstrumentCheckbox)||void 0===s||s.mount(this.selector);const l=this.element.querySelector("apple-pay-button");null==l||l.setAttribute("style","width: 100%;"),null==l||l.addEventListener("click",()=>i(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"),lo(oo.AUTHORIZE,this.options.events,t))}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){r.PayrailsLogger.warn(`ApplePaySession completion failed (${t})`,{error:e instanceof o.PayrailsError?e:void 0})}}}createApplePaySession(){return i(this,void 0,void 0,function*(){var t,n,s,a;const l=ce.applePayConfig,{countryCode:d,supportedNetworks:c,merchantCapabilities:u,requiredBillingContactFields:h=[],requiredShippingContactFields:p=[]}=l,{amount:_}=_e();try{const l=new ApplePaySession(3,{countryCode:d,currencyCode:_.currency,merchantCapabilities:u,supportedNetworks:c,total:{label:(null===(n=null===(t=this.options.translations)||void 0===t?void 0:t.labels)||void 0===n?void 0:n.paymentScreenLabel)||"",type:"final",amount:_.value},requiredBillingContactFields:h,requiredShippingContactFields:p});return l.onvalidatemerchant=e=>i(this,void 0,void 0,function*(){let t;try{const{res:i}=yield this.paymentExecutor.createApplePaySession({requestUrl:ce.createSessionLink,sessionUrl:e.validationURL,clientDomain:this.options.clientDomain});t=i}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_START_PAYMENT_SESSION_ERROR);return r.PayrailsLogger.error(t.message,{error:t,extra:{catchError:e}}),this.abortedSessionReasons.set(l,t),void l.abort()}try{const e=t.data.data;l.completeMerchantValidation(e)}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_MERCHANT_VALIDATION_FAILED);r.PayrailsLogger.error(t.message,{error:t,extra:{catchError:e}}),this.abortedSessionReasons.set(l,t),l.abort()}}),l.oncancel=t=>{this.isProcessing=!1;const i=this.abortedSessionReasons.get(l);i instanceof o.PayrailsError?(this.abortedSessionReasons.delete(l),lo(this.action,this.options.events,i)):lo(this.action,this.options.events,{code:e.AuthorizationFailureReasons.USER_CANCELLED})},p.length>0&&(null===(a=null===(s=this.options)||void 0===s?void 0:s.events)||void 0===a?void 0:a.onDeliveryAddressChanged)&&(l.onshippingcontactselected=e=>i(this,void 0,void 0,function*(){yield this.onApplePayShippingContactSelected(e,l,_)})),l.onpaymentauthorized=e=>i(this,void 0,void 0,function*(){yield this.onApplePayAuthorized(e.payment,l)}),(yield ho(this.action,this.options.events))?l.begin():this.isProcessing=!1,l}catch(e){return this.isProcessing=!1,null}})}onApplePayShippingContactSelected(e,t,n){return i(this,void 0,void 0,function*(){var i,s,a,l;const d=e.shippingContact;let c;d&&(c={deliveryAddress:{city:d.locality,postalCode:d.postalCode,state:d.administrativeArea,country:{code:null===(i=d.countryCode)||void 0===i?void 0:i.toUpperCase()}}});const u=yield Yi(null===(s=this.options)||void 0===s?void 0:s.events,c),h={label:(null===(l=null===(a=this.options.translations)||void 0===a?void 0:a.labels)||void 0===l?void 0:l.paymentScreenLabel)||"",type:"final",amount:n.value};try{if(!u)return void t.completeShippingContactSelection({newTotal:h,errors:[new ApplePayError("shippingContactInvalid","postalAddress","Delivery to this address is not supported.")]});t.completeShippingContactSelection({newTotal:h})}catch(e){r.PayrailsLogger.warn("ApplePaySession completeShippingContactSelection failed",{error:e instanceof o.PayrailsError?e:void 0})}})}onApplePayAuthorized(t,n){return i(this,void 0,void 0,function*(){return(yield Ui(this.action,this.options.events))?this.action===oo.TOKENIZE?yield this.doTokenize(t,n):yield this.doAuthorizedPayment(t,n):(this.action===oo.AUTHORIZE?this.onAuthorizeFailedHandler(n,{code:e.AuthorizationFailureReasons.VALIDATION_FAILED,message:"Authorization request start validation failed"}):(this.isProcessing=!1,this.completeApplePaySession(n,"failure"),lo(this.action,this.options.events,{code:e.AuthorizationFailureReasons.VALIDATION_FAILED,message:"Request start validation failed"})),null)})}doAuthorizedPayment(t,n){return i(this,void 0,void 0,function*(){var i,s,r,a,l;const d=[{paymentMethodCode:e.PAYMENT_METHOD_CODES.APPLE_PAY,integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(t)},amount:_e().amount,storeInstrument:this.shouldStoreInstrument}];try{const t=yield this.paymentExecutor.pay(d);return"authorizeSuccessful"===(null===(i=t.finalState)||void 0===i?void 0:i.code)?(this.completeApplePaySession(n,"success"),this.isProcessing=!1,ao(oo.AUTHORIZE,this.options.events,t)):this.onAuthorizeFailedHandler(n,{code:e.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:(null===(l=null===(a=null===(r=null===(s=t.finalState)||void 0===s?void 0:s.errors)||void 0===r?void 0:r[0])||void 0===a?void 0:a.reason)||void 0===l?void 0:l.result)||"Authorization Failed"}),t}catch(t){this.onAuthorizeFailedHandler(n,{code:e.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:t instanceof o.PayrailsError?t.message:"Authorization Failed"})}})}doTokenize(t,n){return i(this,void 0,void 0,function*(){const i=_e(),s=ce.createInstrumentLink,o=i.token;if(!s)return this.completeApplePaySession(n,"failure"),this.isProcessing=!1,void lo(oo.TOKENIZE,this.options.events);let r;try{r=JSON.stringify(t)}catch(e){return this.completeApplePaySession(n,"failure"),this.isProcessing=!1,void lo(oo.TOKENIZE,this.options.events,e)}const a={holderReference:i.holderReference,paymentMethod:e.PAYMENT_METHOD_CODES.APPLE_PAY,storeInstrument:this.shouldStoreInstrument,data:{paymentToken:r}};try{const e=yield oe({url:s,token:o,body:a});return e.ok?(this.completeApplePaySession(n,"success"),this.isProcessing=!1,ao(oo.TOKENIZE,this.options.events,e.res),e.res):(this.completeApplePaySession(n,"failure"),this.isProcessing=!1,void lo(oo.TOKENIZE,this.options.events))}catch(e){return this.completeApplePaySession(n,"failure"),this.isProcessing=!1,void lo(oo.TOKENIZE,this.options.events,e)}})}}const Nn={wrapper:{display:"flex",flexDirection:"column"}},Sn=()=>i(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 Pn extends xi{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 bn="__payrails-selectedCountry";class Dn extends Pn{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 i(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(bn)||"{}");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(bn,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(bn,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 Mn extends Pn{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 wn extends xi{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=Nn)||void 0===i?void 0:i.wrapper)}),this.options=e,this.countriesMap=void 0,this.createAddressComponents(),this.init(),this.applyStyles(),Sn().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,h;const p={id:"country-selector",styles:(null===(t=this.options.styles)||void 0===t?void 0:t.countrySelector)||(null===(i=Nn)||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}},_={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===(h=Nn)||void 0===h?void 0:h.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 Dn(p),this.postalCodeInput=new Mn(_)}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 kn extends xi{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()}getDefaultInstallment(){var e,t;return parseInt(null!==(e=sessionStorage.getItem(this.INSTALLMENT_STORAGE_KEY))&&void 0!==e?e:"",10)||(null===(t=this.options.installmentConfig)||void 0===t?void 0:t.defaultInstallment)}generateOptionsHTML(e){var t,i,n;const s=(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",o=this.getDefaultInstallment();return[`<option value="">${s}</option>`,...(null==e?void 0:e.map(e=>{const t=e.count===o?" selected":"";return`<option value="${e.count}" ${t}>${e.count} x ${e.amount}</option>`}))||[]].join("")}renderOptions(e){const t=this.element.querySelector("select");if(t){t.innerHTML=this.generateOptionsHTML(e);const i=this.getDefaultInstallment();i&&(t.value=String(i)),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 Yn extends xi{constructor(e,t){var i,n;super(e,t),this.options=t,this.paymentInstallmentsDropdown=null,this.paymentInstallmentsDropdown=new kn(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:Fn,CARDHOLDER_NAME:xn,EXPIRATION_DATE:jn,EXPIRATION_MONTH:Bn,EXPIRATION_YEAR:Vn}=e.ElementType,Gn={base:{border:"none",padding:"10px 16px",color:"#1d1d1d",backgroundColor:"#fff"},invalid:{backgroundColor:"#f9e1e1",borderColor:"#f25226",border:"1px solid"}},Xn=[{type:xn,placeholder:"Card holder",styles:Object.assign(Object.assign({},Gn),{base:Object.assign(Object.assign({},Gn.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px"})})},{type:Un,placeholder:"1234 1234 1234 1234",styles:Object.assign(Object.assign({},Gn),{base:Object.assign(Object.assign({},Gn.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:Bn,placeholder:"MM",styles:Object.assign(Object.assign({},Gn),{base:Object.assign(Object.assign({},Gn.base),{borderBottom:"1px solid #eae8ee",borderLeft:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomLeftRadius:"4px"})})},{type:Vn,placeholder:"YY",format:"YY",styles:Object.assign(Object.assign({},Gn),{base:Object.assign(Object.assign({},Gn.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee"})})},{type:jn,placeholder:"MM/YY",format:"MM/YY",styles:Object.assign(Object.assign({},Gn),{base:Object.assign(Object.assign({},Gn.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:Fn,placeholder:"CVC",styles:Object.assign(Object.assign({},Gn),{base:Object.assign(Object.assign({},Gn.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomRightRadius:"4px"}),cardIcon:{position:"absolute",right:"8px",height:"24px",bottom:"calc(50% - 12px)"}})}];class zn extends Cn{get bin(){return this.collectContainer.bin}get isBinLookupEnabled(){return this.collectContainer.isBinLookupEnabled}constructor(t,i){var n,s,o,r,a,l,d,c,u;super("div",Object.assign(Object.assign({},i),{translations:Object.assign(Object.assign({},null==i?void 0:i.translations),{labels:Object.assign(Object.assign({},null===(n=null==i?void 0:i.translations)||void 0===n?void 0:n.labels),{saveInstrument:null===(o=null===(s=null==i?void 0:i.translations)||void 0===s?void 0:s.labels)||void 0===o?void 0:o.saveCreditCard})}),styles:Object.assign({storeInstrumentCheckbox:null===(r=null==i?void 0:i.styles)||void 0===r?void 0:r.storeCardCheckbox},null==i?void 0:i.styles),id:"payrails-card-form"})),this.collectContainer=t,this.options=i,this.formFields=[],this.paymentInstallmentsDropdown=null,this.addressComponent=null,this.lastBin=null,this.lastBinLookup=null,this.defaultStyles={},this.defaultTranslations={},this.defaultStyles=(null===(a=this.options)||void 0===a?void 0:a.styles)||{},this.defaultTranslations=(null===(l=this.options)||void 0===l?void 0:l.translations)||{},this.eventsRef=null===(d=this.options)||void 0===d?void 0:d.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===(c=null==i?void 0:i.styles)||void 0===c?void 0:c.storeCardCheckbox)&&console.warn("The `storeCardCheckbox` option for styles is deprecated. Please use `storeInstrumentCheckbox` instead."),this.initializeFormFields(),this.subElements.push(this.collectContainer),ce.isPaymentInstallmentsEnabled(e.PAYMENT_METHOD_CODES.CARD)&&(this.paymentInstallmentsDropdown=new Yn("span",Object.assign(Object.assign({},i),{installmentConfig:{installmentCurrency:"",installmentOptions:this.getinstallmentOptions(),defaultInstallment:null===(u=null==i?void 0:i.installmentConfig)||void 0===u?void 0:u.defaultInstallment},id:"payrails-card-form-payment-installments",className:"payrails-card-form-payment-installments-container"})),this.paymentInstallmentsDropdown&&this.subElements.push(this.paymentInstallmentsDropdown)),ce.isAddressSelectorEnabled(e.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=re((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=re((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}})}),re(this.defaultStyles,e||{})}updateTranslations(e){const t=re(this.defaultTranslations||{},e||{});return this.formFields.forEach(e=>{var i,n,s,o;const r=null===(i=t.labels)||void 0===i?void 0:i[e.type],a=null===(n=t.placeholders)||void 0===n?void 0:n[e.type],l=null===(o=null===(s=t.error)||void 0===s?void 0:s.default)||void 0===o?void 0:o[e.type];e.update({translations:Object.assign(Object.assign(Object.assign({},void 0!==r&&{label:r}),void 0!==a&&{placeholder:a}),void 0!==l&&{translations:{error:{default:l}}})})}),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(t){var i,n,s,o,r;if(!this.paymentInstallmentsDropdown)return;const a=ce.getPaymentInstallmentOptions(e.PAYMENT_METHOD_CODES.CARD),l={installmentCurrency:(null===(i=_e().amount)||void 0===i?void 0:i.currency)||""};this.options&&t&&Object.prototype.hasOwnProperty.call(t,"defaultInstallment")&&(this.options.installmentConfig={defaultInstallment:null!==(n=t.defaultInstallment)&&void 0!==n?n:null},l.defaultInstallment=null!==(s=t.defaultInstallment)&&void 0!==s?s:null);const d=null===(r=null===(o=this.lastBinLookup)||void 0===o?void 0:o.issuerCountry)||void 0===r?void 0:r.code,c=d&&a?a[d]:void 0;l.installmentOptions=c||[],this.paymentInstallmentsDropdown.updateInstallmentConfig(l)}createFormField(e,t,i,n,s,o=!1){var r,a,l,d,c,u,h;const p=this.prepareErrorStyles(i);return new Hn(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:p,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===(h=null===(u=null===(c=this.defaultTranslations)||void 0===c?void 0:c.error)||void 0===u?void 0:u.default)||void 0===h?void 0:h[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)}})}isFieldRequired(){var e,t;return!!(null===(t=null===(e=this.defaultStyles)||void 0===e?void 0:e.errorTextStyles)||void 0===t?void 0:t.base)}initializeCustomLayout(){var e;if(!(null===(e=this.options)||void 0===e?void 0:e.layout))return;const t=e=>{e.forEach(e=>{var t;const i=Xn.find(t=>t.type===e);if(!i)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_TYPE);if(this.hasFieldBeenUsed(i.type))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_DUPLICATE_ELEMENT);const{type:n,styles:s,format:r,placeholder:a}=i,l=this.isFieldRequired();this.formFields.push(this.createFormField(n,s,null===(t=this.defaultStyles)||void 0===t?void 0:t.errorTextStyles,r,a,l))})};this.options.layout.forEach(e=>t(e))}hasFieldBeenUsed(e){return this.formFields.some(t=>t.type===e)}initializeDefaultLayout(){const t=t=>{var i,n,s;return!(null===(i=this.options)||void 0===i?void 0:i.showCardHolderName)&&t===e.ElementType.CARDHOLDER_NAME||!(null===(n=this.options)||void 0===n?void 0:n.showSingleExpiryDateField)&&t===e.ElementType.EXPIRATION_DATE||!(!(null===(s=this.options)||void 0===s?void 0:s.showSingleExpiryDateField)||t!==e.ElementType.EXPIRATION_MONTH&&t!==e.ElementType.EXPIRATION_YEAR)};Xn.filter(({type:e})=>!t(e)).forEach(({type:e,styles:t,format:i,placeholder:n})=>{var s;const o=this.isFieldRequired();this.formFields.push(this.createFormField(e,t,null===(s=this.defaultStyles)||void 0===s?void 0:s.errorTextStyles,i,n,o))})}throttledFetchBinLookupIfChanged(){return i(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 wn({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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw r.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(t,i){var n;const s={};return["base","complete","empty","focus","invalid","cardIcon","copyIcon"].forEach(e=>{var n,o,r,a,l,d;s[e]=Object.assign(Object.assign(Object.assign({},(null===(r=null===(o=null===(n=this.defaultStyles)||void 0===n?void 0:n.inputFields)||void 0===o?void 0:o.all)||void 0===r?void 0:r[e])||{}),(null===(d=null===(l=null===(a=this.defaultStyles)||void 0===a?void 0:a.inputFields)||void 0===l?void 0:l[i])||void 0===d?void 0:d[e])||{}),(null==t?void 0:t[e])||{})}),(null===(n=this.options)||void 0===n?void 0:n.showCardHolderName)&&i===e.ElementType.CARD_NUMBER&&(this.element.setAttribute("class","with-card-holder"),s.base=Object.assign(Object.assign(Object.assign({},Gn.base),{border:"1px solid #eae8ee",borderTop:"none",padding:"10px 16px",textIndent:"0"}),s.base)),s}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 t;(null===(t=this.eventsRef)||void 0===t?void 0:t.onChange)&&(this.eventsRef.onChange({isValid:this.isValid,cardNetwork:this.cardNetwork,bin:this.bin,billingAddress:this.billingAddress}),ce.isPaymentInstallmentsEnabled(e.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 i(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 i(this,void 0,void 0,function*(){return this.isBinLookupEnabled?yield this.collectContainer.fetchBinLookup(this.bin):this.bin})}getinstallmentOptions(t){if(t){const i=ce.getPaymentInstallmentOptions(e.PAYMENT_METHOD_CODES.CARD);return i?i[t]:null}return null}unmount(){this.hide({reset:!0}),super.unmount()}mount(e){super.mount(e),this.show()}}class Hn{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;const o=null===(i=null===(t=null==e?void 0:e.translations)||void 0===t?void 0:t.error)||void 0===i?void 0:i.default;null===(s=(n=this.vaultElement).update)||void 0===s||s.call(n,Object.assign(Object.assign(Object.assign({type:this.type},void 0!==(null==e?void 0:e.label)&&{label:e.label}),void 0!==o&&{translations:{error:{default:o}}}),void 0!==(null==e?void 0:e.placeholder)&&{placeholder: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 qn extends xi{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.element.setAttribute("data-testid",`dropin-item-${e}`),this.applyBaseStyles();const o=`payrails-dropin-item-${e}`,r=document.createElement("label");r.setAttribute("for",o),r.setAttribute("data-testid",`dropin-item-label-${e}`);const a=document.createElement("input");if(a.setAttribute("type","radio"),a.setAttribute("name","payment-option"),a.setAttribute("id",o),a.setAttribute("value",o),a.setAttribute("data-testid",`dropin-item-radio-${e}`),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),d.setAttribute("data-testid","dropin-item-container"),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 Wn;!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"}(Wn||(Wn={}));const Kn={[e.PAYMENT_METHOD_CODES.CARD]:"https://assets.payrails.io/img/logos/card/",[e.PAYMENT_METHOD_CODES.PAYPAL]:"https://assets.payrails.io/img/logos/paypal/",[e.PAYMENT_METHOD_CODES.APPLE_PAY]:"https://assets.payrails.io/img/logos/applepay/",[e.PAYMENT_METHOD_CODES.GOOGLE_PAY]:"https://assets.payrails.io/img/logos/googlepay/"};class $n extends qn{constructor(e,t,i,n,s){const o=e.displayName&&""!==e.displayName?e.displayName:"Unavailable";super(`payrails-payment-instrument-${e.id}`,o,$n.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 Zn(t,s)}static getInstrumentIcon(t){var i;if(t.paymentMethod===e.PAYMENT_METHOD_CODES.CARD){const n=Kn[e.PAYMENT_METHOD_CODES.CARD];switch(null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.network){case Wn.AMEX:return n+"amex.svg";case Wn.DINERS:return n+"diners-club.svg";case Wn.DISCOVER:return n+"discover.svg";case Wn.HIPERCARD:return n+"hipercard.svg";case Wn.JCB:return n+"jcb.svg";case Wn.MAESTRO:return n+"maestro.svg";case Wn.MASTERCARD:return n+"mastercard.svg";case Wn.UNIONPAY:return n+"unionpay.svg";case Wn.VISA:return n+"visa.svg"}return n+"default.svg"}return t.paymentMethod===e.PAYMENT_METHOD_CODES.PAYPAL?Kn[e.PAYMENT_METHOD_CODES.PAYPAL]+"logo.svg":t.paymentMethod===e.PAYMENT_METHOD_CODES.APPLE_PAY?Kn[e.PAYMENT_METHOD_CODES.APPLE_PAY]+"logo.svg":t.paymentMethod===e.PAYMENT_METHOD_CODES.GOOGLE_PAY?Kn[e.PAYMENT_METHOD_CODES.GOOGLE_PAY]+"logo.svg":""}updateInstallmentConfig(t){var i,n,s,o,r;if(!this.installmentDropdown||this.instrumentData.paymentMethod!==e.PAYMENT_METHOD_CODES.CARD)return;const a=ce.getPaymentInstallmentOptions(e.PAYMENT_METHOD_CODES.CARD),l=null===(s=null===(n=null===(i=this.instrumentData.data)||void 0===i?void 0:i.binLookup)||void 0===n?void 0:n.issuerCountry)||void 0===s?void 0:s.code,d={installmentCurrency:(null===(o=_e().amount)||void 0===o?void 0:o.currency)||""};t&&Object.prototype.hasOwnProperty.call(t,"defaultInstallment")&&(d.defaultInstallment=null!==(r=t.defaultInstallment)&&void 0!==r?r:null);const c=l&&a?a[l]:void 0;d.installmentOptions=c||[],this.installmentDropdown.updateInstallmentConfig(d)}}class Zn extends xi{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 Jn extends xi{constructor(e){super("div",{id:"payrails-card-list"}),this.listItems=[],ce.savedCreditCards.forEach(t=>{const i=new Qn(()=>{(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 Qn extends xi{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=$n.getInstrumentIcon(t),a.className="payment-option-icon",r.appendChild(a),r.appendChild(document.createTextNode(n)),this.element.appendChild(s)}}class es extends xi{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 ts extends xi{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 is extends xi{constructor(e){super("div",{id:"payrails-dropin-loader",className:"payrails-dropin-loader-wrapper"}),this.options=e,this.selectors={[ns.overlay]:".loading-overlay",[ns.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 ns;!function(e){e.overlay="overlay",e.loader="loader"}(ns||(ns={}));const ss="https://assets.payrails.io/img/logos";function os(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?`${ss}/${e}/logo.svg`:`${ss}/card/credit-card-regular.svg`}class rs extends qn{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;const i=this.element.querySelector(this.component.selector);i&&(i.style.display="block"),null===(t=null===(e=this.events)||void 0===e?void 0:e.onPaymentOptionVisibilityChange)||void 0===t||t.call(e)}deactivate(){if(!this.isActive)return;this.isActive=!1,this.applyBaseStyles();const e=this.element.querySelector(this.component.selector);e&&(e.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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);throw r.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 as extends rs{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?os("applepay"):void 0,void 0,e.styles),this.loadElementId="apple-pay-dropin-load-element",this.component=new Rn(Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},e.events),{onApplePayAvailable:()=>{this.mountAfterAvailable()}})}))}}class ls extends qn{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?os("card"):void 0,Object.assign({},i.events),Object.assign({},i.styles)),this.cardForm=e,this.paymentButton=t,this.cardFormShown=!1,this.component=new ds(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 ds extends xi{constructor(e,t){super("div",{id:"payrails-form-container"}),this.subElements.push(e,t)}}var cs;e.ACTION_REQUIRED_KIND=void 0,(cs=e.ACTION_REQUIRED_KIND||(e.ACTION_REQUIRED_KIND={})).GENERIC_REDIRECT="genericRedirect",cs.THREE_DS="3ds";const us=new class{constructor(){this.handlers=new Map}on(e,t){let i=this.handlers.get(e);return i||(i=new Set,this.handlers.set(e,i)),i.add(t),()=>this.off(e,t)}off(e,t){var i;null===(i=this.handlers.get(e))||void 0===i||i.delete(t)}hasListeners(e){const t=this.handlers.get(e);return!!t&&t.size>0}emit(e,t){return i(this,void 0,void 0,function*(){const i=this.handlers.get(e);if(i&&0!==i.size)for(const n of Array.from(i))try{yield n(t)}catch(t){const i=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_UNKNOWN_ERROR,{description:`Handler for "${e}" threw`,cause:t});r.PayrailsLogger.error(i.message,{error:i})}})}reset(){this.handlers.clear()}};function hs(){return us}const ps="actionRequired";function _s(e){return i(this,arguments,void 0,function*({url:e,kind:t,paymentMethodCode:i,executionId:n}){var s;let o=!1;const r={url:e,kind:t,paymentMethodCode:i,executionId:null!==(s=null!=n?n:ce.executionId)&&void 0!==s?s:"",preventDefault:()=>{o=!0}};return yield hs().emit(ps,r),o})}function Es(){return hs().hasListeners(ps)}class ms{constructor(e,t,i,n=vs.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===vs.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 t=document.createElement("button");return t.setAttribute("id","payrails-popup-cancel-button"),t.setAttribute("type","button"),t.setAttribute("aria-label","Close"),t.addEventListener("click",()=>{ve.getEventBus().emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}),lo(oo.AUTHORIZE,this.options.events,{code:e.AuthorizationFailureReasons.USER_CANCELLED,message:"User cancelled the authorization."}),this.unmount()}),t}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 t=n=>i(this,void 0,void 0,function*(){var i,s,o,r,a;if(n.data&&'{"type":"3DS-challenge-completed"}'===n.data){window.removeEventListener("message",t);const n=yield this.paymentExecutor.pollForAuthorizationResult(ce.url);switch(null===(i=n.finalState)||void 0===i?void 0:i.code){case"authorizeSuccessful":ao(oo.AUTHORIZE,this.options.events);break;case"authorizePending":uo(oo.AUTHORIZE,this.options.events);break;default:lo(oo.AUTHORIZE,this.options.events,{code:e.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:(null===(a=null===(r=null===(o=null===(s=n.finalState)||void 0===s?void 0:s.errors)||void 0===o?void 0:o[0])||void 0===r?void 0:r.reason)||void 0===a?void 0:a.result)||"Authorization failed after 3DS challenge."})}this.unmount()}});window.addEventListener("message",t)}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 vs;!function(e){e[e.THREE_DS=0]="THREE_DS",e[e.GENERIC_REDIRECT=1]="GENERIC_REDIRECT"}(vs||(vs={}));const ys="https://assets.payrails.io/img/logos/revolutpay/button",Is={backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"contain",backgroundColor:"transparent",fontSize:"0",color:"transparent",padding:"0",display:"block",maxWidth:"100%",margin:"0 auto",aspectRatio:"250 / 44",border:"none",cursor:"pointer",transition:"opacity 0.2s ease"},fs="lightOutline",As="Pay with Revolut Pay",Ls={dark:{base:{backgroundImage:`url(${ys}/dark/Medium.svg)`},hover:{opacity:"0.85"},loading:{backgroundImage:"none",backgroundColor:"#191C1F",color:"#FFFFFF"}},light:{base:{backgroundImage:`url(${ys}/white/Medium.svg)`},hover:{opacity:"0.85"},loading:{backgroundImage:"none",backgroundColor:"#FFFFFF",color:"#191C1F"}},lightOutline:{base:{backgroundImage:`url(${ys}/outline/Medium.svg)`},hover:{opacity:"0.85"},loading:{backgroundImage:"none",backgroundColor:"#FFFFFF",color:"#191C1F"}}};function gs(e){var t;const i=null==e?void 0:e.theme,n=Ls[i&&i in Ls?i:fs],s={width:null!==(t=null==e?void 0:e.width)&&void 0!==t?t:"250px"};return(null==e?void 0:e.borderRadius)&&(s.borderRadius=e.borderRadius),{base:Object.assign(Object.assign(Object.assign({},Is),null==n?void 0:n.base),s),hover:Object.assign({},null==n?void 0:n.hover),loading:Object.assign(Object.assign({},null==n?void 0:n.loading),s)}}const Os="__PAYRAILS__TAB_MANUAL_CLOSE_ERROR__",Ts={label:"Generic redirect"},Cs={pix:75e4,modo:6e5},Rs={showCancelButton:!0};class Ns extends xi{constructor(t,i){var n,s,o;super("button",{id:`payrails-generic-redirect-${t.paymentMethod.paymentMethodCode}`,className:"payrails-generic-button"}),this.returnInfo=i,this.popup=null,this.isDisabled=!1,this.isLoading=!1,this.isRevolutPay=t.paymentMethod.paymentMethodCode===e.PAYMENT_METHOD_CODES.REVOLUT_PAY,this.options=Object.assign(Object.assign({},t),{styles:this.isRevolutPay?gs(t.styles):t.styles,translations:this.isRevolutPay?{label:As}:t.translations}),this.element.innerText=null!==(s=null===(n=this.options.translations)||void 0===n?void 0:n.label)&&void 0!==s?s:Ts.label,(null===(o=this.options.styles)||void 0===o?void 0:o.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 hn(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:Ts.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 i(this,void 0,void 0,function*(){var t,i;if(this.isDisabled)return;let n=null;this.options.openInNewTab&&this.isSafari()&&(n=window.open("","_blank"));try{if(this.triggerLoading(!0),!(yield ho(oo.AUTHORIZE,null!==(t=this.options.events)&&void 0!==t?t:{})))return this.triggerLoading(!1),void(n&&!n.closed&&n.close());const s=null===(i=ce.availablePaymentMethods.find(({paymentMethodCode:e})=>e===this.options.paymentMethod.paymentMethodCode))||void 0===i?void 0:i.integrationType;if(!s)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED);const r=yield this.paymentExecutor.pay([{paymentMethodCode:this.options.paymentMethod.paymentMethodCode,integrationType:s,amount:_e().amount}]),{action:a,link:l}=this.handleAuthorizationResult(r);if("redirect"!==a)return void(n&&!n.closed&&n.close());if(!l)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK);if(Es()&&(yield _s({url:l,kind:e.ACTION_REQUIRED_KIND.GENERIC_REDIRECT,paymentMethodCode:this.options.paymentMethod.paymentMethodCode})))return n&&!n.closed&&n.close(),void this.triggerLoading(!1);if(Object.keys(Cs).includes(this.options.paymentMethod.paymentMethodCode)){n&&!n.closed&&n.close();const e=Cs[this.options.paymentMethod.paymentMethodCode],t=2e4,i=2e3,s=Math.ceil((e-t)/i);return new hn(this.returnInfo,i,s,t).pollForAuthorizationResult(ce.url,0,["authorizeSuccessful","authorizeFailed"]).then(e=>{var t;this.handleAuthorizationResult(e),null===(t=this.popup)||void 0===t||t.unmount()}),this.createPopupWithTimeout(l,e)}return this.redirectToPaymentLink(l,n)}catch(e){n&&!n.closed&&n.close(),e instanceof o.PayrailsError&&r.PayrailsLogger.error(e.message,{error:e}),lo(oo.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 o.PayrailsError(o.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)?(ao(oo.AUTHORIZE,this.options.events),{code:"authorizeSuccessful",action:"success"}):(lo(oo.AUTHORIZE,this.options.events,e),this.triggerLoading(!1),{code:"authorizeFailed",action:"fail"})}createPopupWithTimeout(e,t){return new Promise(()=>{const i=new ms(e,this.paymentExecutor,Object.assign(Object.assign({},this.options),Rs));this.popup=i,this.popup.mount(),setTimeout(()=>{null==i||i.unmount(),lo(oo.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){r.PayrailsLogger.warn("Popup blocked. Falling back to same tab redirect."),window.location.href=e;const t=setTimeout(()=>{var e;lo(oo.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;lo(oo.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(t){return i(this,void 0,void 0,function*(){var i,n,s,o,a,l;let d;try{d=ce.url}catch(s){return r.PayrailsLogger.error("Unable to resolve workflow execution URL.",{error:s}),this.triggerLoading(!1),t.closed||t.close(),void(null===(n=null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeFailed)||void 0===n||n.call(i,{code:e.AuthorizationFailureReasons.UNKNOWN_ERROR,message:"Unable to resolve workflow execution URL.",rawError:s}))}const c=new hn(this.returnInfo),u=new AbortController,{promise:h,cleanup:p}=this.watchTabClosure(t,()=>{u.signal.aborted||u.abort(Os),this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{})});try{const e=yield Promise.race([c.pollForAuthorizationResult(d,0,["authorizeSuccessful","authorizeFailed"],{signal:u.signal}),h]);u.signal.aborted||u.abort("authorization-completed"),this.handleAuthorizationResult(e)}catch(t){if(u.signal.aborted||u.abort(t),t===Os){try{const e=new hn(this.returnInfo,1e3,3,0),t=yield e.pollForAuthorizationResult(d,0,["authorizeSuccessful","authorizeFailed"]);return void this.handleAuthorizationResult(t)}catch(e){}null===(o=null===(s=this.options.events)||void 0===s?void 0:s.onAuthorizeFailed)||void 0===o||o.call(s,{code:e.AuthorizationFailureReasons.USER_CANCELLED,message:"User closed the payment window before completion."})}else r.PayrailsLogger.error("Failed to retrieve authorization result after redirect.",{error:t}),null===(l=null===(a=this.options.events)||void 0===a?void 0:a.onAuthorizeFailed)||void 0===l||l.call(a,{code:e.AuthorizationFailureReasons.UNKNOWN_ERROR,message:"Failed to retrieve authorization result after redirect.",rawError:t})}finally{u.signal.aborted||u.abort("cleanup"),p(),t.closed||t.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(Os))},500)}),cleanup:s}}updateStyles(e){var t,i;this.isRevolutPay?this.options.styles=gs(e):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.isRevolutPay||(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:Ts.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 Ss=t=>t===e.PAYMENT_METHOD_CODES.GENERIC_REDIRECT?{translations:{label:"Mercado Pago",button:{label:"Pay with Mercado Pago"}}}:{translations:{label:t,button:{label:`Pay with ${t}`}}};class Ps extends qn{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)||Ss(e.paymentMethod.paymentMethodCode).translations.label,(null===(n=e.config)||void 0===n?void 0:n.showPaymentMethodLogo)?os(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 Ns({styles:null===(o=null==e?void 0:e.styles)||void 0===o?void 0:o.button,translations:(null===(r=null==e?void 0:e.translations)||void 0===r?void 0:r.button)||Ss(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 bs{constructor(e,t){this.options=e,this.paymentExecutor=t}handle3ds(t){return i(this,void 0,void 0,function*(){var i,n,s,o;try{null===(n=null===(i=this.options.events)||void 0===i?void 0:i.onThreeDSecureChallenge)||void 0===n||n.call(i)}catch(e){}const r=null===(s=null==t?void 0:t.response)||void 0===s?void 0:s.links["3ds"];if(r){if(Es()&&(yield _s({url:r,kind:e.ACTION_REQUIRED_KIND.THREE_DS,paymentMethodCode:null!==(o=this.options.paymentMethodCode)&&void 0!==o?o:""})))return;this.options.redirectFor3DS?window.location.assign(r):new ms(r,this.paymentExecutor,this.options).mount()}})}}const Ds={apiVersion:2,apiVersionMinor:0},Ms=new Set(["BHD","IQD","JOD","KWD","LYD","OMR","TND"]);let ws=class t extends Cn{static getGooglePayConfigAsArray(e){return Array.isArray(e)?e:e.allowedPaymentMethods?e.allowedPaymentMethods:[]}static getSDKClient(){return i(this,arguments,void 0,function*(i=e.PayrailsEnvironment.TEST,n){return yield fn.load(In.GooglePay),t.googleSDKClient||(t.googleSDKClient=new google.payments.api.PaymentsClient({environment:i,merchantInfo:n})),t.googleSDKClient})}static isGooglePayAvailable(n){return i(this,arguments,void 0,function*(i,n=e.PayrailsEnvironment.TEST,s){var o,r,a,l;try{const e=Array.isArray(i)||null===(o=i.merchantInfo)||void 0===o?void 0:o.merchantName,d={merchantId:null!==(r=null==s?void 0:s.merchantId)&&void 0!==r?r:"",merchantName:null!==(l=null!==(a=null==s?void 0:s.merchantName)&&void 0!==a?a:e)&&void 0!==l?l:""},c=yield t.getSDKClient(n,d),u=t.getGooglePayConfigAsArray(i),h=Object.assign(Object.assign(Object.assign({},Ds),{allowedPaymentMethods:u}),!Array.isArray(i)&&void 0!==i.existingPaymentMethodRequired&&{existingPaymentMethodRequired:i.existingPaymentMethodRequired}),{result:p}=yield c.isReadyToPay(h);return p}catch(e){return!1}})}constructor(e){var i;super("div",Object.assign(Object.assign({},e),{id:`payrails-google-pay-button-${$()}`,dataTestId:"payrails-google-pay-button"})),this.options=e,this.sdkLoadedCalled=!1,this.isProcessing=!1,this.buttonElement=null,this.paymentExecutor=new hn(null===(i=this.options)||void 0===i?void 0:i.returnInfo),t.isGooglePayAvailable(ce.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"===_e().type?oo.TOKENIZE:oo.AUTHORIZE}sdkLoaded(e){return i(this,void 0,void 0,function*(){var n,s,o,r,a,l,d,c,u,h,p,_;if(this.sdkLoadedCalled)return this.buttonElement;this.sdkLoadedCalled=!0;const E=(null===(s=null===(n=this.options)||void 0===n?void 0:n.styles)||void 0===s?void 0:s.buttonColor)||"black",m=(null===(r=null===(o=this.options)||void 0===o?void 0:o.styles)||void 0===r?void 0:r.buttonType)||"long",v=(null===(l=null===(a=this.options)||void 0===a?void 0:a.styles)||void 0===l?void 0:l.buttonSizeMode)||"fill";(null===(c=null===(d=this.options)||void 0===d?void 0:d.styles)||void 0===c?void 0:c.buttonLocale)&&console.warn("Payrails: styles.buttonLocale is deprecated and will be removed in a future release. Use styles.locale instead.");const y=(null===(h=null===(u=this.options)||void 0===u?void 0:u.styles)||void 0===h?void 0:h.locale)||(null===(_=null===(p=this.options)||void 0===p?void 0:p.styles)||void 0===_?void 0:_.buttonLocale),I=y?(f=On(y),Ln(f).split("-")[0]):void 0;var f;const A=t.getGooglePayConfigAsArray(ce.googlePayConfig);return this.buttonElement=e.createButton({buttonColor:E,buttonType:m,buttonSizeMode:v,buttonLocale:I,onClick:()=>i(this,void 0,void 0,function*(){this.isProcessing||(this.isProcessing=!0,(yield ho(this.action,this.options.events))?yield this.authorize(e):this.isProcessing=!1)}),allowedPaymentMethods:A}),this.element.appendChild(this.buttonElement),this.buttonElement})}authorize(e){return i(this,void 0,void 0,function*(){var i,n,s,o,a,l,d;const c=ce.googlePayConfig,u=!Array.isArray(c),h=_e().amount,p=null===(o=null===(s=null===(n=null===(i=ce.meta)||void 0===i?void 0:i.order)||void 0===n?void 0:n.billingAddress)||void 0===s?void 0:s.country)||void 0===o?void 0:o.code,_=!!(null==h?void 0:h.currency)&&Ms.has(h.currency);_&&r.PayrailsLogger.debug(`Payrails: 3-decimal currency ${null==h?void 0:h.currency}, omitting totalPrice`);const E=Object.assign(Object.assign({},u&&void 0!==c.apiVersion?{apiVersion:c.apiVersion,apiVersionMinor:c.apiVersionMinor}:Ds),{allowedPaymentMethods:t.getGooglePayConfigAsArray(c),transactionInfo:_?{totalPriceStatus:"NOT_CURRENTLY_KNOWN",currencyCode:null==h?void 0:h.currency,countryCode:p}:{totalPriceStatus:"FINAL",totalPrice:null==h?void 0:h.value,currencyCode:null==h?void 0:h.currency,countryCode:p},merchantInfo:{merchantId:(null===(a=this.options.merchantInfo)||void 0===a?void 0:a.merchantId)||"",merchantName:(null===(l=this.options.merchantInfo)||void 0===l?void 0:l.merchantName)||(null===(d=c.merchantInfo)||void 0===d?void 0:d.merchantName)||""}});u&&(void 0!==c.emailRequired&&(E.emailRequired=c.emailRequired),void 0!==c.shippingAddressRequired&&(E.shippingAddressRequired=c.shippingAddressRequired),c.shippingAddressParameters&&(E.shippingAddressParameters=c.shippingAddressParameters));try{const t=yield e.loadPaymentData(E);yield this.onLoadPaymentData(t)}catch(e){this.isProcessing=!1,lo(this.action,this.options.events,e)}})}onLoadPaymentData(e){return i(this,void 0,void 0,function*(){(yield Ui(this.action,this.options.events))?(this.action===oo.TOKENIZE?yield this.doTokenize(e):yield this.doAuthorizePayment(e),this.isProcessing=!1):this.isProcessing=!1})}doTokenize(t){return i(this,void 0,void 0,function*(){const i=_e(),n=ce.createInstrumentLink,s=i.token;if(!n)return this.isProcessing=!1,void lo(oo.TOKENIZE,this.options.events);let o;try{o=JSON.stringify(t)}catch(e){return this.isProcessing=!1,void lo(oo.TOKENIZE,this.options.events,e)}const r={holderReference:i.holderReference,paymentMethod:e.PAYMENT_METHOD_CODES.GOOGLE_PAY,storeInstrument:this.shouldStoreInstrument,data:{paymentToken:o}};try{const e=yield oe({url:n,token:s,body:r});return e.ok?(this.isProcessing=!1,ao(oo.TOKENIZE,this.options.events,e.res),e.res):(this.isProcessing=!1,void lo(oo.TOKENIZE,this.options.events))}catch(e){return this.isProcessing=!1,void lo(oo.TOKENIZE,this.options.events,e)}})}doAuthorizePayment(t){return i(this,void 0,void 0,function*(){var i,n,s,o,r,a;const l={paymentToken:JSON.stringify(t)},d=[{paymentMethodCode:e.PAYMENT_METHOD_CODES.GOOGLE_PAY,integrationType:"api",paymentInstrumentData:l,amount:_e().amount,storeInstrument:this.shouldStoreInstrument}],c=yield this.paymentExecutor.pay(d);if("authorizePending"===(null===(i=null==c?void 0:c.finalState)||void 0===i?void 0:i.code)){const t=new bs(Object.assign(Object.assign({},this.options),{paymentMethodCode:e.PAYMENT_METHOD_CODES.GOOGLE_PAY}),this.paymentExecutor);yield t.handle3ds(c)}else"authorizeSuccessful"===(null===(n=null==c?void 0:c.finalState)||void 0===n?void 0:n.code)?ao(oo.AUTHORIZE,this.options.events):lo(oo.AUTHORIZE,this.options.events,{code:e.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:(null===(a=null===(r=null===(o=null===(s=c.finalState)||void 0===s?void 0:s.errors)||void 0===o?void 0:o[0])||void 0===r?void 0:r.reason)||void 0===a?void 0:a.result)||"Authorization Failed"})})}mount(e){super.mount(e),(()=>{i(this,void 0,void 0,function*(){var e;try{if(yield t.isGooglePayAvailable(ce.googlePayConfig,this.options.environment,this.options.merchantInfo)){const i=yield t.getSDKClient(this.options.environment,this.options.merchantInfo),n=yield this.sdkLoaded(i);this.element.appendChild(n),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()}};ws.googleSDKClient=null;class ks{constructor(t=e.PayrailsEnvironment.TEST){this.environment=t,this.iframe=null,this.bus=ve.getEventBus(),this.destroyed=!1,this.controller=new AbortController,this.busTeardowns=[],this.frameId=$(),this.readyPromise=this.armReadyPromise()}createIframe(){const e=document.createElement("iframe");var t;return e.src=(t=this.frameId,`https://assets.payrails.io/apps/secure-frame/v1/index.html?mode=${ve.SecureFrameMode.Collect}&type=${ve.SecureFrameType.GooglePay}&id=${t}`),e.setAttribute("data-payrails-gpay-frame",this.frameId),e.allow="payment",e.setAttribute("sandbox","allow-scripts allow-popups allow-same-origin allow-forms"),e.setAttribute("id",this.frameId),e.style.border="none",e}attachIframe(e,t){this.iframe=this.createIframe(),t.hidden&&(this.iframe.width="0",this.iframe.height="0",this.iframe.style.display="none"),e.appendChild(this.iframe)}armReadyPromise(){const e=`${this.frameId}-${ve.COLLECT_FRAME_EVENT_NAMES.READY}`,t=`${this.frameId}-${ve.COLLECT_FRAME_EVENT_NAMES.ERROR}`;return new Promise((i,n)=>{const s=()=>{this.bus.off(e,s),this.bus.off(t,o),i()},o=i=>{var a;this.bus.off(e,s),this.bus.off(t,o);const l=i;r.PayrailsLogger.error(null!==(a=null==l?void 0:l.message)&&void 0!==a?a:"Google Pay secure-frame error",{extra:l}),n(i)};this.bus.on(e,s),this.bus.on(t,o)})}isGooglePayAvailable(e){return i(this,void 0,void 0,function*(){var t;if(this.destroyed)return!1;try{if(this.attachIframe(document.body,{hidden:!0}),yield this.readyPromise,this.destroyed)return!1;const t=yield this.bus.emitAndResolve(`${this.frameId}-${ve.COLLECT_FRAME_EVENT_NAMES.IS_AVAILABLE}`,{googlePayConfig:e,environment:this.environment},"*",this.controller.signal);return Boolean(null==t?void 0:t.result)}catch(e){return!1}finally{null===(t=this.iframe)||void 0===t||t.remove(),this.iframe=null}})}mountButton(e){return i(this,void 0,void 0,function*(){this.destroyed||(this.readyPromise=this.armReadyPromise(),this.attachIframe(e.target,{hidden:!1}),this.applyMountSizing(e.buttonStyle),this.registerCollectListeners(e),yield this.requestShow(e))})}applyMountSizing(e){this.iframe&&(this.iframe.style.width="static"===e.buttonSizeMode?"0px":"100%",this.iframe.style.height="0px")}registerCollectListeners(e){const t=`${this.frameId}-${ve.COLLECT_FRAME_EVENT_NAMES.RESIZE}`,n=e=>{var t;const{width:i,height:n}=null!==(t=e)&&void 0!==t?t:{};this.iframe&&(i&&(this.iframe.style.width=i),n&&(this.iframe.style.height=n))};this.bus.on(t,n),this.busTeardowns.push(()=>this.bus.off(t,n));const s=this.bus.onAndEmit(`${this.frameId}-${ve.COLLECT_FRAME_EVENT_NAMES.BUTTON_CLICK_VALIDATE}`,()=>i(this,void 0,void 0,function*(){return{isValid:yield e.onButtonClicked()}}));this.busTeardowns.push(s);const o=`${this.frameId}-${ve.COLLECT_FRAME_EVENT_NAMES.COLLECT}`,r=t=>{var i;const{paymentData:n}=null!==(i=t)&&void 0!==i?i:{};n&&e.onCollect(n)};this.bus.on(o,r),this.busTeardowns.push(()=>this.bus.off(o,r));const a=`${this.frameId}-${ve.COLLECT_FRAME_EVENT_NAMES.COLLECT_ERROR}`,l=t=>{var i,n;null===(i=e.onCollectError)||void 0===i||i.call(e,null!==(n=t)&&void 0!==n?n:{code:"OTHER"})};this.bus.on(a,l),this.busTeardowns.push(()=>this.bus.off(a,l))}requestShow(e){return i(this,void 0,void 0,function*(){if(yield this.readyPromise,this.destroyed)return;const t={type:"GOOGLE_PAY_BUTTON",environment:e.environment,googlePayConfig:e.googlePayConfig,amount:e.amount,countryCode:e.countryCode,buttonStyle:e.buttonStyle},i=yield this.bus.emitAndResolve(`${this.frameId}-${ve.COLLECT_FRAME_EVENT_NAMES.SHOW}`,t,"*",this.controller.signal);if(!this.destroyed&&!(null==i?void 0:i.success))throw new Error(`Failed to render Google Pay button: ${i&&"error"in i?i.error:"unknown"}`)})}unmount(){var e;this.destroyed=!0,this.controller.abort();for(const e of this.busTeardowns)e();this.busTeardowns=[],null===(e=this.iframe)||void 0===e||e.remove(),this.iframe=null}destroy(){var e;this.destroyed=!0,this.controller.abort(),null===(e=this.iframe)||void 0===e||e.remove(),this.iframe=null}}function Ys(e,t={}){var i,n,s,o,r;const a=t.merchantInfo;if(Array.isArray(e))return{allowedPaymentMethods:e,merchantInfo:{merchantId:"",merchantName:null!==(i=null==a?void 0:a.merchantName)&&void 0!==i?i:""}};const l=null!=e?e:{},d=l.merchantInfo;return{apiVersion:l.apiVersion,apiVersionMinor:l.apiVersionMinor,allowedPaymentMethods:null!==(n=l.allowedPaymentMethods)&&void 0!==n?n:[],merchantInfo:{merchantId:null!==(s=null==d?void 0:d.merchantId)&&void 0!==s?s:"",merchantName:null!==(r=null!==(o=null==a?void 0:a.merchantName)&&void 0!==o?o:null==d?void 0:d.merchantName)&&void 0!==r?r:""},emailRequired:l.emailRequired,shippingAddressRequired:l.shippingAddressRequired,shippingAddressParameters:l.shippingAddressParameters,existingPaymentMethodRequired:l.existingPaymentMethodRequired}}let Us=class t extends Cn{static isGooglePayAvailable(t){return i(this,arguments,void 0,function*(t,i=e.PayrailsEnvironment.TEST,n){const s=new ks(i);try{return yield s.isGooglePayAvailable(Ys(t,{merchantInfo:n}))}finally{s.destroy()}})}constructor(e){var i;super("div",Object.assign(Object.assign({},e),{id:`payrails-google-pay-button-${$()}`,dataTestId:"payrails-google-pay-button"})),this.options=e,this.isProcessing=!1,this.frame=null,this.paymentExecutor=new hn(null===(i=this.options)||void 0===i?void 0:i.returnInfo),t.isGooglePayAvailable(ce.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"===_e().type?oo.TOKENIZE:oo.AUTHORIZE}onLoadPaymentData(e){return i(this,void 0,void 0,function*(){(yield Ui(this.action,this.options.events))?(this.action===oo.TOKENIZE?yield this.doTokenize(e):yield this.doAuthorizePayment(e),this.isProcessing=!1):this.isProcessing=!1})}doTokenize(t){return i(this,void 0,void 0,function*(){const i=_e(),n=ce.createInstrumentLink,s=i.token;if(!n)return this.isProcessing=!1,void lo(oo.TOKENIZE,this.options.events);let o;try{o=JSON.stringify(t)}catch(e){return this.isProcessing=!1,void lo(oo.TOKENIZE,this.options.events,e)}const r={holderReference:i.holderReference,paymentMethod:e.PAYMENT_METHOD_CODES.GOOGLE_PAY,storeInstrument:this.shouldStoreInstrument,data:{paymentToken:o}};try{const e=yield oe({url:n,token:s,body:r});return e.ok?(this.isProcessing=!1,ao(oo.TOKENIZE,this.options.events,e.res),e.res):(this.isProcessing=!1,void lo(oo.TOKENIZE,this.options.events))}catch(e){return this.isProcessing=!1,void lo(oo.TOKENIZE,this.options.events,e)}})}doAuthorizePayment(t){return i(this,void 0,void 0,function*(){var i,n,s,o,r,a;const l={paymentToken:JSON.stringify(t)},d=[{paymentMethodCode:e.PAYMENT_METHOD_CODES.GOOGLE_PAY,integrationType:"api",paymentInstrumentData:l,amount:_e().amount,storeInstrument:this.shouldStoreInstrument}],c=yield this.paymentExecutor.pay(d);if("authorizePending"===(null===(i=null==c?void 0:c.finalState)||void 0===i?void 0:i.code)){const t=new bs(Object.assign(Object.assign({},this.options),{paymentMethodCode:e.PAYMENT_METHOD_CODES.GOOGLE_PAY}),this.paymentExecutor);yield t.handle3ds(c)}else"authorizeSuccessful"===(null===(n=null==c?void 0:c.finalState)||void 0===n?void 0:n.code)?ao(oo.AUTHORIZE,this.options.events):lo(oo.AUTHORIZE,this.options.events,{code:e.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:(null===(a=null===(r=null===(o=null===(s=c.finalState)||void 0===s?void 0:s.errors)||void 0===o?void 0:o[0])||void 0===r?void 0:r.reason)||void 0===a?void 0:a.result)||"Authorization Failed"})})}mount(e){this.frame&&this.unmount(),super.mount(e),(()=>{i(this,void 0,void 0,function*(){var e,t,n,s,o,r,a;try{const l=Ys(ce.googlePayConfig,{merchantInfo:this.options.merchantInfo}),d=new ks(this.options.environment);if(this.frame=d,!(yield d.isGooglePayAvailable(l)))return d.destroy(),void(this.frame=null);yield d.mountButton({target:this.element,environment:null!==(e=this.options.environment)&&void 0!==e?e:"TEST",googlePayConfig:l,amount:_e().amount,countryCode:null===(o=null===(s=null===(n=null===(t=ce.meta)||void 0===t?void 0:t.order)||void 0===n?void 0:n.billingAddress)||void 0===s?void 0:s.country)||void 0===o?void 0:o.code,buttonStyle:null!==(r=this.options.styles)&&void 0!==r?r:{},onButtonClicked:()=>i(this,void 0,void 0,function*(){return Boolean(yield ho(this.action,this.options.events))}),onCollect:e=>{if(!this.isProcessing)return this.isProcessing=!0,this.onLoadPaymentData(e)},onCollectError:e=>{this.isProcessing=!1,lo(this.action,this.options.events,e)}}),null===(a=this.storeInstrumentCheckbox)||void 0===a||a.mount(this.selector)}catch(e){}})})()}unmount(){var e,t;null===(e=this.storeInstrumentCheckbox)||void 0===e||e.unmount(),null===(t=this.frame)||void 0===t||t.unmount(),this.frame=null,super.unmount()}},Fs=null;function xs(){var e,t;if(null!==Fs)return Fs;const i=null!==(t=null===(e=_e().featureConfig)||void 0===e?void 0:e.gpayIframeRollout)&&void 0!==t?t:0;return Fs=100*Math.random()<i,Fs}class js extends Cn{static isGooglePayAvailable(...e){return i(this,void 0,void 0,function*(){return xs()?Us.isGooglePayAvailable(...e):ws.isGooglePayAvailable(...e)})}constructor(e){return super("div",e),xs()?new Us(e):new ws(e)}}class Bs extends rs{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?os("googlepay"):void 0,e.events,e.styles),this.loadElementId="google-pay-dropin-load-element",this.component=new js(Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},e.events),{onGooglePayAvailable:()=>{this.mountAfterAvailable()}}),returnInfo:e.returnInfo}))}}const Vs="Pay by bank with Al Tareq";var Gs;!function(e){e.SUCCESS="success",e.ERROR="error",e.CANCELLED="cancelled"}(Gs||(Gs={}));class Xs extends xi{constructor(e){var t,i,n,s,o,r,a;super("button",{id:e.id||"payrails-lean-button",className:"payrails-lean-button",styles:null!==(n=null===(i=null===(t=e.styles)||void 0===t?void 0:t.button)||void 0===i?void 0:i.base)&&void 0!==n?n:{}}),this.isLoading=!1,this.handleClick=()=>{this.onClick()},this.handleMouseEnter=()=>{var e,t;(null===(t=null===(e=this.options.styles)||void 0===e?void 0:e.button)||void 0===t?void 0:t.hover)&&this.setStyles(this.options.styles.button.hover)},this.handleMouseLeave=()=>{var e,t;(null===(t=null===(e=this.options.styles)||void 0===e?void 0:e.button)||void 0===t?void 0:t.hover)&&this.removeStyles(this.options.styles.button.hover)},this.handleSessionExpired=()=>{this.triggerLoading(!1)},this.options=e,this.paymentExecutor=new hn(null===(s=this.options)||void 0===s?void 0:s.returnInfo),this.element.innerText=(null===(o=e.translations)||void 0===o?void 0:o.label)||Vs,this.setStyles((null===(a=null===(r=this.options.styles)||void 0===r?void 0:r.button)||void 0===a?void 0:a.base)||{})}mount(e){this.unmount(),super.mount(e),this.bindEvents(),Xs.preloadLeanSDK()}unmount(){this.unbindEvents(),super.unmount()}static initializeLeanSDK(){return window.Lean||Xs.leanSdkClient||(Xs.leanSdkClient=fn.load(In.Lean)),Xs.leanSdkClient}static preloadLeanSDK(){const e=Xs.initializeLeanSDK();null==e||e.catch(()=>{Xs.leanSdkClient===e&&(Xs.leanSdkClient=null)})}static getLeanSDK(){return i(this,void 0,void 0,function*(){Xs.initializeLeanSDK();try{yield Xs.leanSdkClient}catch(e){throw Xs.leanSdkClient=null,e}const e=window.Lean;if(!e)throw Xs.leanSdkClient=null,fn.invalidate(In.Lean),new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_UNKNOWN_ERROR,{description:"Lean SDK is not available"});return e})}static resetLeanSDK(){Xs.leanSdkClient=null}bindEvents(){this.element.addEventListener("click",this.handleClick),this.element.addEventListener("mouseenter",this.handleMouseEnter),this.element.addEventListener("mouseleave",this.handleMouseLeave),this.eventBus.on("PAYRAILS_CLIENT_SESSION_EXPIRED",this.handleSessionExpired)}unbindEvents(){var e,t;this.element.removeEventListener("click",this.handleClick),this.element.removeEventListener("mouseenter",this.handleMouseEnter),this.element.removeEventListener("mouseleave",this.handleMouseLeave),null===(t=(e=this.eventBus).off)||void 0===t||t.call(e,"PAYRAILS_CLIENT_SESSION_EXPIRED",this.handleSessionExpired)}setStyles(e){var t,i;const n=Object.assign(Object.assign({},null===(i=null===(t=this.options.styles)||void 0===t?void 0:t.button)||void 0===i?void 0:i.base),e);Object.keys(n).forEach(e=>{this.element.style[e]=n[e]})}removeStyles(e){var t,i;const n=Object.keys((null===(i=null===(t=this.options.styles)||void 0===t?void 0:t.button)||void 0===i?void 0:i.base)||{});Object.keys(e).forEach(e=>{var t,i,s;n.includes(e)?this.element.style[e]=null===(s=null===(i=null===(t=this.options.styles)||void 0===t?void 0:t.button)||void 0===i?void 0:i.base)||void 0===s?void 0:s[e]:this.element.style[e]=""})}triggerLoading(e){var t,i,n,s,o;this.isLoading=e,e?(this.element.innerHTML=this.renderLoadingMarkup(),(null===(i=null===(t=this.options.styles)||void 0===t?void 0:t.button)||void 0===i?void 0:i.loading)&&this.setStyles(this.options.styles.button.loading)):(this.element.innerText=(null===(n=this.options.translations)||void 0===n?void 0:n.label)||Vs,this.removeStyles((null===(o=null===(s=this.options.styles)||void 0===s?void 0:s.button)||void 0===o?void 0:o.loading)||{}))}renderLoadingMarkup(){return['<div class="dot-flashing-container">',' <div class="dot-flashing"></div>',' <span class="dot-flashing-text" aria-hidden="true">Loading</span>',"</div>"].join("")}getConfirmActionParameters(e){var t,i,n;const s=null===(n=null===(i=null===(t=e.response)||void 0===t?void 0:t.links)||void 0===i?void 0:i.confirm)||void 0===n?void 0:n.action;if(!((null==s?void 0:s.paymentId)&&(null==s?void 0:s.appToken)&&(null==s?void 0:s.sdkToken)&&(null==s?void 0:s.successUrl)&&(null==s?void 0:s.failureUrl)))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_UNKNOWN_ERROR,{description:"Lean payment parameters are missing from authorize polling response."});return{appToken:s.appToken,paymentId:s.paymentId,sdkToken:s.sdkToken,successUrl:s.successUrl,failureUrl:s.failureUrl,sandbox:s.sandbox}}startLeanCheckout(e,t){return i(this,void 0,void 0,function*(){return new Promise(i=>{var n;const s=this.toLeanCustomizationPayload(null===(n=this.options.styles)||void 0===n?void 0:n.dialog);e.checkout(Object.assign(Object.assign({app_token:t.appToken,access_token:t.sdkToken,payment_intent_id:t.paymentId,success_redirect_url:t.successUrl,fail_redirect_url:t.failureUrl},void 0!==t.sandbox?{sandbox:t.sandbox}:{}),{customization:s,callback:e=>{try{this.handleLeanCheckoutResponse(e)}finally{this.triggerLoading(!1),i()}}}))})})}handleLeanCheckoutResponse(e){var t;switch(null===(t=null==e?void 0:e.status)||void 0===t?void 0:t.toLowerCase()){case Gs.SUCCESS:return void ao(oo.AUTHORIZE,this.options.events,e);case Gs.ERROR:case Gs.CANCELLED:return this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}),void lo(oo.AUTHORIZE,this.options.events,e)}}toLeanCustomizationPayload(e){if(!e)return;const{themeColor:t,buttonTextColor:i,buttonBorderRadius:n,linkColor:s,overlayColor:o}=e;return{theme_color:t,button_text_color:i,button_border_radius:n,link_color:s,overlay_color:o}}onClick(){return i(this,void 0,void 0,function*(){var t;if(!this.isLoading)try{if(this.triggerLoading(!0),!(yield ho(oo.AUTHORIZE,null!==(t=this.options.events)&&void 0!==t?t:{})))return void this.triggerLoading(!1);const i=yield Xs.getLeanSDK(),n=[{paymentMethodCode:e.PAYMENT_METHOD_CODES.LEAN,integrationType:"api",amount:_e().amount,paymentInstrumentData:{},storeInstrument:!1}],s=yield this.paymentExecutor.pay(n),o=this.getConfirmActionParameters(s);yield this.startLeanCheckout(i,o),this.triggerLoading(!1)}catch(e){this.triggerLoading(!1),this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}),lo(oo.AUTHORIZE,this.options.events,e)}})}}Xs.leanSdkClient=null;class zs extends qn{constructor(e,t){var i;super("lean-dropin",(null===(i=e.translations)||void 0===i?void 0:i.label)||"Pay by bank with Al Tareq",void 0,e.events,e.elementStyles),this.returnInfo=t,this.component=new Xs(Object.assign(Object.assign({},e),{id:e.id||"payrails-lean-button-dropin",styles:e.styles,events:Object.assign({},e.events),returnInfo:this.returnInfo}))}}class Hs extends Cn{constructor(t){var n;Hs.instance&&(Hs.instance=void 0);const s="express"===(null===(n=null==ce?void 0:ce.paypalConfig)||void 0===n?void 0:n.integrationMode),o=!s&&(null==t?void 0:t.showStoreInstrumentCheckbox),r=s?"unchecked":null==t?void 0:t.defaultStoreInstrumentState,a=Object.assign(Object.assign({},t),{showStoreInstrumentCheckbox:o,defaultStoreInstrumentState:r,id:"payrails-paypal-button",events:Object.assign(Object.assign({},null==t?void 0:t.events),{onSaveInstrumentCheckboxChanged:e=>i(this,void 0,void 0,function*(){var i,n,s;null===(n=null===(i=null==t?void 0:t.events)||void 0===i?void 0:i.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(i,e),null===(s=this.button)||void 0===s||s.close(),this.debouncedRender()})})});super("div",a),this.options=t,this.renderDebounceTimeout=null,this.currentAbortController=null,this.isRendering=!1,this.buttonWrapperId="payrails-paypal-button-wrapper",this.checkboxWrapperId="payrails-paypal-checkbox-wrapper",this.createOneTimeOrder=()=>i(this,void 0,void 0,function*(){var t,i,n,s,o;const r=[{paymentMethodCode:e.PAYMENT_METHOD_CODES.PAYPAL,integrationType:"api",amount:_e().amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!1}],a=yield this.paymentExecutor.pay(r),l=null===(n=null===(i=null===(t=a.response.links.confirm)||void 0===t?void 0:t.action)||void 0===i?void 0:i.parameters)||void 0===n?void 0:n.orderId;if(!l)throw lo(oo.AUTHORIZE,null===(s=this.options)||void 0===s?void 0:s.events),new qs("No order id returned");return this.confirmLink=null===(o=a.response.links.confirm)||void 0===o?void 0:o.href,l}),this.loadPaypal().catch(()=>{}),this.element.innerHTML=`<div id="${this.buttonWrapperId}"></div><div id="${this.checkboxWrapperId}"></div>`,this.paymentExecutor=new hn}loadPaypal(){return i(this,void 0,void 0,function*(){const e=yield fn.load(In.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(()=>i(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(){var e,t;const i=this.shouldStoreInstrument?"tokenize":"Instant"===ce.paypalConfig.captureMode?"capture":"authorize";return Object.assign({clientId:ce.paypalConfig.clientId,intent:i,currency:_e().amount.currency,vault:this.shouldStoreInstrument},(null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.locale)&&{locale:(n=On(this.options.styles.locale),Ln(n).replace("-","_"))});var n}createPaypalButton(e){return i(this,void 0,void 0,function*(){var t,i,n;if(!e.Buttons)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR);const s=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),s})}createPayPalButtonConfig(){return this.shouldStoreInstrument?this.createBillingAgreementConfig():this.createOneTimeOrderConfig()}createBillingAgreementConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{onApprove:this.approvePayment.bind(this),createBillingAgreement:()=>i(this,void 0,void 0,function*(){var t,i,n,s;const o=[{paymentMethodCode:e.PAYMENT_METHOD_CODES.PAYPAL,integrationType:"api",amount:_e().amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!0}],r=yield this.paymentExecutor.pay(o);return this.confirmLink=null===(t=r.response.links.confirm)||void 0===t?void 0:t.href,(null===(s=null===(n=null===(i=r.response.links.confirm)||void 0===i?void 0:i.action)||void 0===n?void 0:n.parameters)||void 0===s?void 0:s.tokenId)||""})})}onCancel(){var e;this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}),lo(oo.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,t,n,s,o,r,a,l,d,c;return{fundingSource:"paypal",style:{color:(null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.color)||"gold",height:(null===(s=null===(n=this.options)||void 0===n?void 0:n.styles)||void 0===s?void 0:s.height)||40,label:(null===(r=null===(o=this.options)||void 0===o?void 0:o.styles)||void 0===r?void 0:r.label)||"paypal",shape:(null===(l=null===(a=this.options)||void 0===a?void 0:a.styles)||void 0===l?void 0:l.shape)||"rect",tagline:(null===(c=null===(d=this.options)||void 0===d?void 0:d.styles)||void 0===c?void 0:c.tagline)||!1,disableMaxWidth:!0},onError:e=>{var t;this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}),lo(oo.AUTHORIZE,null===(t=this.options)||void 0===t?void 0:t.events,e)},onClick:(e,t)=>i(this,void 0,void 0,function*(){var e;return(yield ho(oo.AUTHORIZE,null===(e=this.options)||void 0===e?void 0:e.events))?t.resolve():t.reject()}),onCancel:this.onCancel.bind(this),onShippingAddressChange:(e,t)=>i(this,void 0,void 0,function*(){var i;let n;if(e.shippingAddress&&(n={deliveryAddress:{city:e.shippingAddress.city,postalCode:e.shippingAddress.postalCode,state:e.shippingAddress.state,country:{code:e.shippingAddress.countryCode}}}),!(yield Yi(null===(i=this.options)||void 0===i?void 0:i.events,n)))return t.reject()})}}approvePayment(t){return i(this,void 0,void 0,function*(){var i,n,s,o,r,a,l,d,c;if(!this.confirmLink)throw lo(oo.AUTHORIZE,null===(i=this.options)||void 0===i?void 0:i.events),new qs("No confirm link");const u={};if(this.shouldStoreInstrument&&t.billingToken&&(u.tokenId=t.billingToken),this.fraudNetGuid&&(u.riskSessionCorrelationId=this.fraudNetGuid),!(yield Ui(oo.AUTHORIZE,null===(n=this.options)||void 0===n?void 0:n.events)))throw new qs("Authorization request start validation failed");const h=yield this.paymentExecutor.confirm(this.confirmLink,u);"authorizeSuccessful"===(null===(s=h.finalState)||void 0===s?void 0:s.code)?ao(oo.AUTHORIZE,null===(o=this.options)||void 0===o?void 0:o.events):lo(oo.AUTHORIZE,null===(r=this.options)||void 0===r?void 0:r.events,{code:e.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:(null===(c=null===(d=null===(l=null===(a=h.finalState)||void 0===a?void 0:a.errors)||void 0===l?void 0:l[0])||void 0===d?void 0:d.reason)||void 0===c?void 0:c.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){Hs.instance||(super.mount(e),Hs.instance=this,(()=>{i(this,void 0,void 0,function*(){yield this.debouncedRender()})})())}renderButton(){return i(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 Ws("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,Hs.instance=void 0,super.unmount()}}class qs extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION,{description:`PaypalOrderError: ${e}`,cause:t})}}class Ws extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT,{description:`PaypalButtonError: ${e}`,cause:t})}}class Ks extends rs{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)?os("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 Hs(Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},null==e?void 0:e.events),{onPaypalAvailable:()=>{this.mountAfterAvailable()}})}))}}class $s extends xi{constructor(t,i,n){var s,o,r,a,l,d;super("fieldset",{id:"payrails-dropin-component"}),this.collectContainer=t,this.clientConfig=i,this.dropinConfig=n,this.billingValidationBlocked=!1,this.applyStyles(),an.reset();const c=null===(s=_e().morData)||void 0===s?void 0:s.billingLines;(null==c?void 0:c.form)&&(this.billingAddressForm=new an({schema:c.form,prefill:c,styles:null===(o=this.dropinConfig.styles)||void 0===o?void 0:o.billingAddressForm,translations:null===(r=this.dropinConfig.translations)||void 0===r?void 0:r.billingAddressForm})),void 0!==(null===(l=null===(a=this.dropinConfig.paymentMethodsConfiguration)||void 0===a?void 0:a.cards)||void 0===l?void 0:l.showExistingCards)&&console.warn("The `showExistingCards` option is deprecated and will be removed in a future version. Please use `showStoredInstruments` instead.");const u=new Map;ce.storedDropinInstruments.forEach(e=>{if(this.isStoredInstrumentEnabled(e.paymentMethod)){this.cardPaymentButton=this.createCardPaymentButton();const t=this.createStoredInstrumentElement(e);t&&u.set(t.identifier,t)}});const h={[e.PAYMENT_METHOD_CODES.CARD]:this.createCreditCardButton.bind(this),[e.PAYMENT_METHOD_CODES.PAYPAL]:this.createPayPalButton.bind(this),[e.PAYMENT_METHOD_CODES.GOOGLE_PAY]:this.createGooglePayButton.bind(this),[e.PAYMENT_METHOD_CODES.APPLE_PAY]:this.createApplePayButton.bind(this),[e.PAYMENT_METHOD_CODES.LEAN]:this.createLeanButton.bind(this)};ce.availablePaymentMethods.forEach(e=>{const t=e.paymentMethodCode;if(t&&h[t]){const i=(0,h[t])(ce.getPaymentMethodConfig(e));u.set(i.identifier,i)}else if(this.isHppIntegration(e)&&t){const t=this.createHppIntegrationElement(e);u.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)||"";u.forEach(e=>{e.deactivate()}),null===(i=u.get(n))||void 0===i||i.activate()}),1===this.totalPaymentOptions&&this.element.classList.add("payrails-dropin-component--single"),this.billingAddressForm&&this.subElements.push(this.billingAddressForm),this.subElements.push(...Array.from(u.values())),this.loadingScreen=new is({styles:null===(d=this.dropinConfig.styles)||void 0===d?void 0:d.loadingScreen})}get returnInfo(){return this.dropinConfig.returnInfo||this.clientConfig.returnInfo}isHppIntegration(t){var i;return t.paymentMethodCode===e.PAYMENT_METHOD_CODES.GENERIC_REDIRECT||(null===(i=t.clientConfig)||void 0===i?void 0:i.flow)===ue.REDIRECT}createStoredInstrumentElement(t){var i;let n;if(this.cardPaymentButton=this.createCardPaymentButton(),t.paymentMethod!==e.PAYMENT_METHOD_CODES.BANK_ACCOUNT)return t.paymentMethod===e.PAYMENT_METHOD_CODES.CARD&&ce.isPaymentInstallmentsEnabled(t.paymentMethod)&&(n=this.createInstallmentsDropdown(t)),new $n(t,this.cardPaymentButton,e=>{var t,i;if(this.cardPaymentButton){this.cardPaymentButton.selectedInstrument=e;const n=ce.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===(i=this.dropinConfig.styles)||void 0===i?void 0:i.element,n)}createInstallmentsDropdown(e){var t,i,n;const s=this.getInstallmentOptionsForInstrument(e);return new Yn("span",{installmentConfig:{installmentCurrency:_e().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=ce.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 $n&&t.updateInstallmentConfig(e)})}createHppIntegrationElement(e){var t,i,n,s,a,l,d,c,u,h,p,_;const E=e.paymentMethodCode;if(!E){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED,{description:`Payment method code is missing for payment method - ${JSON.stringify(e)}`});throw r.PayrailsLogger.error(t.message,{error:t}),t}return new Ps({paymentMethod:e,config:Object.assign(Object.assign({},null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t[E]),{showPaymentMethodLogo:null!==(l=null!==(s=null===(n=null===(i=this.dropinConfig.paymentMethodsConfiguration)||void 0===i?void 0:i[E])||void 0===n?void 0:n.showPaymentMethodLogo)&&void 0!==s?s: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===(p=null===(h=null===(u=this.dropinConfig)||void 0===u?void 0:u.styles)||void 0===h?void 0:h[E])||void 0===p?void 0:p.button},translations:null===(_=this.dropinConfig.translations)||void 0===_?void 0:_[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 ce.availablePaymentMethods.length+ce.storedDropinInstruments.length}createCreditCardButton(e){var t,i,n,s,o,r,a;return this.creditCard=new ls(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(t){var i,n,s,o,r,a,l,d;return this.googlePay=new Bs(Object.assign({environment:this.clientConfig.environment||e.PayrailsEnvironment.TEST,events:Object.assign(Object.assign({},this.getElementEvents()),{onPaymentOptionVisibilityChange:()=>{var e,i;null===(i=null===(e=this.dropinConfig.events)||void 0===e?void 0:e.onPaymentOptionSelected)||void 0===i||i.call(e,{paymentMethod:t})}}),redirectFor3DS:this.clientConfig.redirectFor3DS,showPaymentMethodLogo:null!==(r=null!==(s=null===(n=null===(i=this.dropinConfig.paymentMethodsConfiguration)||void 0===i?void 0:i.googlePay)||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,styles:Object.assign(Object.assign({},null===(a=this.dropinConfig.styles)||void 0===a?void 0:a.googlePayButton),null===(l=this.dropinConfig.styles)||void 0===l?void 0:l.element),returnInfo:this.returnInfo},null===(d=this.dropinConfig.paymentMethodsConfiguration)||void 0===d?void 0:d.googlePay)),this.googlePay}createPayPalButton(e){var t,i,n,s,o,r,a,l;return this.paypal=new Ks(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}createLeanButton(e){var t,i,n,s;return this.lean=new zs(Object.assign(Object.assign({paymentMethod:e},null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.lean),{styles:null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.leanButton,elementStyles:null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.element,translations:null===(s=this.dropinConfig.translations)||void 0===s?void 0:s.leanButton,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),this.lean}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),h=Boolean(null==l?void 0:l.showSingleExpiryDateField),p=(null==l?void 0:l.layout)||[];this.cardForm=new zn(this.collectContainer,{showStoreInstrumentCheckbox:d,showCardHolderName:c,showSingleExpiryDateField:h,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:p,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 t,n,s,o,r,a,l,d,c;return this.applePay=new as(Object.assign(Object.assign({events:Object.assign(Object.assign({},this.getElementEvents()),{onAuthorizeSuccess:e=>{var t;e&&("authorizeSuccessful"===(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code)?this.onAuthorizeSuccess():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=>i(this,void 0,void 0,function*(){var t,i,n;return!!(yield this.validateBillingAddress())&&(!(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===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.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 po({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;an.reset(),null===(e=this.loadingScreen)||void 0===e||e.unmount(),this.subElements.forEach(e=>e.unmount()),new ts({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()}validateBillingAddress(){return i(this,void 0,void 0,function*(){if(!this.billingAddressForm)return!0;try{return yield this.billingAddressForm.collect(),!0}catch(e){return this.billingValidationBlocked=!0,!1}})}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{const e=this.subElements.find(e=>e instanceof qn);null==e||e.activate()}catch(e){r.PayrailsLogger.error("Error while auto-activating the first payment option",{error:new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING,{cause:e})})}},0)},onPaymentButtonClicked:e=>i(this,void 0,void 0,function*(){var t,i,n,s;if(!(yield this.validateBillingAddress()))return!1;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;an.reset(),null===(e=this.loadingScreen)||void 0===e||e.unmount(),this.subElements.forEach(e=>e.unmount()),new ts({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(t){return i(this,void 0,void 0,function*(){var i,n,s,o,r;null===(i=this.loadingScreen)||void 0===i||i.unmount(),this.billingValidationBlocked?this.billingValidationBlocked=!1:((null==t?void 0:t.code)!==e.AuthorizationFailureReasons.USER_CANCELLED&&new es({translations:{label:this.getErrorMessage(t)},styles:null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.authFailed,configuration:null===(s=this.dropinConfig.configuration)||void 0===s?void 0:s.authFailMsg}).mount(this.selector),null===(r=null===(o=this.dropinConfig.events)||void 0===o?void 0:o.onAuthorizeFailed)||void 0===r||r.call(o,t))})}isStoredInstrumentEnabled(t){var i,n,s,o,r,a;switch(t){case e.PAYMENT_METHOD_CODES.CARD:return!1!==(null===(n=null===(i=this.dropinConfig.paymentMethodsConfiguration)||void 0===i?void 0:i.cards)||void 0===n?void 0:n.showStoredInstruments)&&!1!==(null===(o=null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s.cards)||void 0===o?void 0:o.showExistingCards);case e.PAYMENT_METHOD_CODES.PAYPAL:case e.PAYMENT_METHOD_CODES.GOOGLE_PAY:case e.PAYMENT_METHOD_CODES.APPLE_PAY:return!1!==(null===(a=null===(r=this.dropinConfig.paymentMethodsConfiguration)||void 0===r?void 0:r[t])||void 0===a?void 0:a.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 i(this,void 0,void 0,function*(){var e;return null===(e=this.cardForm)||void 0===e?void 0:e.fetchBinLookup()})}}const Zs=e=>i(void 0,void 0,void 0,function*(){if(null==e?void 0:e.onSessionExpired)try{const t=yield e.onSessionExpired();if(t)Ee(t),(null==e?void 0:e.onClientInitialized)&&e.onClientInitialized(ce);else{const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_SESSION_REFRESH_FAILED,{description:"Session refresh failed with no result returned"});r.PayrailsLogger.error(e.message,{error:e})}}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_SESSION_REFRESH_FAILED,{description:"Callback passed to onSessionExpired threw an error",cause:e});r.PayrailsLogger.error(t.message,{error:t})}}),Js=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;class Qs{static setSelectedInstrument(e){if(!e||!e.id.match(Js))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Instrument is not valid"});this._selectedInstrument=e}static getSelectedInstrument(){return this._selectedInstrument}static clearSelectedInstrument(){this._selectedInstrument=null}}Qs._selectedInstrument=null;const eo={deleteInstrument:{linkKey:"instrumentDelete",method:W.DELETE,createRequest:e=>{var t,i;if(!e.resourceId)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_UNKNOWN_ERROR);const n=null===(i=null===(t=_e().links)||void 0===t?void 0:t.instrumentDelete)||void 0===i?void 0:i.href;if(!n)throw new o.PayrailsError(o.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:W.PATCH,createRequest:e=>{var t,i;const n=null===(i=null===(t=_e().links)||void 0===t?void 0:t.instrumentUpdate)||void 0===i?void 0:i.href;if(!n)throw new o.PayrailsError(o.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:W.POST,createRequest:()=>{const e=ce.payoutLink;if(!e)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND);const t=Qs.getSelectedInstrument();if(!t)throw new o.PayrailsError(o.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:_e().amount,paymentMethodCode:t.paymentMethod,paymentInstrumentId:t.id}];return{url:e,body:{amount:_e().amount,payoutComposition:i}}},onSuccess:e=>i(void 0,void 0,void 0,function*(){const t=new hn;return yield t.pollForAuthorizationResult(e.links.execution)}),requestType:{},responseType:{}}},to={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:{}}},io=(e,t)=>{try{const i=_e(),n=to[e];if(!n)return r.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){var t;try{if(!e)return r.PayrailsLogger.error("Payment method code is required"),null;const i=ce.availablePaymentMethods;return"all"===e?i:"redirect"===e?i.filter(e=>{var t;return(null===(t=e.clientConfig)||void 0===t?void 0:t.flow)===ue.REDIRECT}):null!==(t=i.find(({paymentMethodCode:t})=>t===e))&&void 0!==t?t:null}catch(t){return r.PayrailsLogger.error(`Error getting config for payment method: ${e}`,{error:t}),null}}(e):(r.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 ce.getStoredInstrumentForPaymentMethod(e)}(e):(r.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 r.PayrailsLogger.error("Error querying SDK Configuration",{error:e}),null}},no=(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/739d580/observability/index.html?${i}`,t.width="1px",t.height="1px",document.body.appendChild(t),t})(e)};
20
+ */function En(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,n,s=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:{}}),o=s.queryParams,r=s.dataAttributes;return{url:"".concat(t,"?").concat((i=o,n="",Object.keys(i).forEach(function(e){0!==n.length&&(n+="&"),n+=e+"="+i[e]}),n)),dataAttributes:r}}function mn(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 vn(e,t){if(void 0===t&&(t=yn()),fn(e,t),"undefined"==typeof window)return t.resolve(null);var i=En(e),n=i.url,s=i.dataAttributes,o=s["data-namespace"]||"paypal",r=In(o);return function(e,t){var i=document.querySelector('script[src="'.concat(e,'"]'));if(null===i)return null;var n=mn(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=yn()),fn(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=mn(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=In(o);if(e)return e;throw new Error("The window.".concat(o," global variable is not available."))})}function yn(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function In(e){return window[e]}function fn(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.")}var An;!function(e){e.ApplePay="https://applepay.cdn-apple.com/jsapi/v1.3.2/apple-pay-sdk.js",e.GooglePay="https://pay.google.com/gp/p/js/pay.js",e.PayPal="paypal-sdk",e.Lean="https://cdn.leantech.me/link/loader/prod/ae/latest/lean-link-loader.min.js"}(An||(An={}));class Ln{static load(e,t){const n=e.toString(),s=Ln.scriptMap.get(n);if(s)return s;const o=(()=>i(this,void 0,void 0,function*(){try{if(e===An.PayPal){if(!t)throw new Error("PayPal config is required");return yield Ln.loadPayPalScript(t)}return yield Ln.loadScript(e)}finally{Ln.scriptMap.delete(n)}}))();return Ln.scriptMap.set(n,o),o}static reset(){Ln.scriptMap.clear()}static invalidate(e){var t;Ln.scriptMap.delete(e.toString());const i=Ln.getScriptKey(e);Ln.scriptMap.delete(i),null===(t=document.getElementById(i))||void 0===t||t.remove()}static preloadCardForm(){const e="https://assets.payrails.io/c344ea7/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=Ln.getScriptKey(e);if(Ln.scriptMap.has(t))return Ln.scriptMap.get(t);const i=document.createElement("script");i.src=e,i.id=t;const n=Ln.sdkScriptAttributes[e];n&&Object.entries(n).forEach(([e,t])=>{i.setAttribute(e,t)});const s=new Promise((t,n)=>{i.onload=()=>t(),i.onerror=t=>n(Ln.logLoadError(e,new Error(t.toString())))}).catch(e=>{throw Ln.scriptMap.delete(t),i.remove(),e});return Ln.scriptMap.set(t,s),document.body.appendChild(i),s}static getScriptKey(e){return`payrails-script-${JSON.stringify(e)}`}static loadPayPalScript(e){return i(this,arguments,void 0,function*({clientId:e,currency:t,vault:i,intent:n,locale:s}){let a;for(let l=0;l<=Ln.PAYPAL_MAX_RETRIES;l++){l>0&&(Ln.removePayPalScriptElements(),yield Ln.delay(Ln.PAYPAL_BASE_DELAY_MS*Math.pow(2,l-1)));try{const o=yield vn(Object.assign({"client-id":e,components:"buttons,funding-eligibility",intent:n,currency:t,vault:i,"data-namespace":"payrailsPaypal"},s&&{locale:s}));if(o)return o;a=new Error("The window.payrailsPaypal global variable is not available.")}catch(e){a=e}const d=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR,{cause:a});r.PayrailsLogger.error(`PayPal SDK load attempt ${l+1}/${Ln.PAYPAL_MAX_RETRIES+1} failed`,{error:d})}throw Ln.logLoadError(An.PayPal,a)})}static removePayPalScriptElements(){document.querySelectorAll('script[src*="paypal.com/sdk/js"]').forEach(e=>e.remove())}static delay(e){return new Promise(t=>setTimeout(t,e))}constructor(){}static logLoadError(e,t){const i=new Map([[An.ApplePay,o.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR],[An.GooglePay,o.ERROR_CODES.PAYRAILS_CLIENT_GPAY_LOADING_ERROR],[An.PayPal,o.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR]]),n=new o.PayrailsError(i.get(e)||o.ERROR_CODES.PAYRAILS_CLIENT_UNKNOWN_ERROR,{cause:t,description:null==t?void 0:t.message});return r.PayrailsLogger.error(n.message,{error:n}),n}}Ln.scriptMap=new Map,Ln.sdkScriptAttributes={[An.ApplePay]:{crossorigin:"anonymous",integrity:"sha384-DZRWMZLyVXr+7shJfal8pIG2v4KisLoSWFjZQMUv0+GWaCwoa82qeHsWrbBIUDPU"}},Ln.PAYPAL_MAX_RETRIES=2,Ln.PAYPAL_BASE_DELAY_MS=1e3;const On=/^[a-zA-Z]+([_-][a-zA-Z0-9]+)*$/,gn=e=>e.replace("_","-"),Tn=e=>{if(e&&On.test(e))return e},Cn=e=>{var t,i;const n=Tn(e)||Tn(null===(i=null===(t=W.meta)||void 0===t?void 0:t.customer)||void 0===i?void 0:i.language)||"en-GB";return gn(n)};class Rn extends Bi{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`,h=`${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 p="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="${h}" class="payrails-store-instrument-checkbox">${c}</label>`,p&&(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 Nn extends Bi{constructor(e,t){var n,s,o,r,a;super(e,t),this.options=t,this.storeInstrumentCheckbox=null,(null===(n=this.options)||void 0===n?void 0:n.showStoreInstrumentCheckbox)&&(this.storeInstrumentCheckbox=new Rn(Object.assign(Object.assign({},t),{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=>i(this,void 0,void 0,function*(){var i,n;null===(n=null===(i=null==t?void 0:t.events)||void 0===i?void 0:i.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(i,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 Sn extends Nn{static isApplePayAvailable(){return i(this,void 0,void 0,function*(){try{return yield Ln.load(An.ApplePay),ApplePaySession.canMakePayments()}catch(e){return!1}})}constructor(e){super("div",Object.assign(Object.assign({},e),{id:`payrails-apple-pay-button-${re()}`,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 _n,Sn.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"===Q().type?uo.TOKENIZE:uo.AUTHORIZE}mount(e){this.unmount(),super.mount(e),(()=>{i(this,void 0,void 0,function*(){try{(yield Sn.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 i(this,void 0,void 0,function*(){var e,t,n,s;try{const o=(null===(e=this.options.styles)||void 0===e?void 0:e.type)||"buy",r=(null===(t=this.options.styles)||void 0===t?void 0:t.style)||"black",a=Cn(null===(n=this.options.styles)||void 0===n?void 0:n.locale);this.element.innerHTML=`<apple-pay-button buttonstyle="${r}" type="${o}" locale="${a}"></apple-pay-button>`,null===(s=this.storeInstrumentCheckbox)||void 0===s||s.mount(this.selector);const l=this.element.querySelector("apple-pay-button");null==l||l.setAttribute("style","width: 100%;"),null==l||l.addEventListener("click",()=>i(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"),_o(uo.AUTHORIZE,this.options.events,t))}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){r.PayrailsLogger.warn(`ApplePaySession completion failed (${t})`,{error:e instanceof o.PayrailsError?e:void 0})}}}createApplePaySession(){return i(this,void 0,void 0,function*(){var t,n,s,a;const l=W.applePayConfig,{countryCode:d,supportedNetworks:c,merchantCapabilities:u,requiredBillingContactFields:h=[],requiredShippingContactFields:p=[]}=l,{amount:_}=Q();try{const l=new ApplePaySession(3,{countryCode:d,currencyCode:_.currency,merchantCapabilities:u,supportedNetworks:c,total:{label:(null===(n=null===(t=this.options.translations)||void 0===t?void 0:t.labels)||void 0===n?void 0:n.paymentScreenLabel)||"",type:"final",amount:_.value},requiredBillingContactFields:h,requiredShippingContactFields:p});return l.onvalidatemerchant=e=>i(this,void 0,void 0,function*(){let t;try{const{res:i}=yield this.paymentExecutor.createApplePaySession({requestUrl:W.createSessionLink,sessionUrl:e.validationURL,clientDomain:this.options.clientDomain});t=i}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_START_PAYMENT_SESSION_ERROR);return r.PayrailsLogger.error(t.message,{error:t,extra:{catchError:e}}),this.abortedSessionReasons.set(l,t),void l.abort()}try{const e=t.data.data;l.completeMerchantValidation(e)}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_MERCHANT_VALIDATION_FAILED);r.PayrailsLogger.error(t.message,{error:t,extra:{catchError:e}}),this.abortedSessionReasons.set(l,t),l.abort()}}),l.oncancel=t=>{this.isProcessing=!1;const i=this.abortedSessionReasons.get(l);i instanceof o.PayrailsError?(this.abortedSessionReasons.delete(l),_o(this.action,this.options.events,i)):_o(this.action,this.options.events,{code:e.AuthorizationFailureReasons.USER_CANCELLED})},p.length>0&&(null===(a=null===(s=this.options)||void 0===s?void 0:s.events)||void 0===a?void 0:a.onDeliveryAddressChanged)&&(l.onshippingcontactselected=e=>i(this,void 0,void 0,function*(){yield this.onApplePayShippingContactSelected(e,l,_)})),l.onpaymentauthorized=e=>i(this,void 0,void 0,function*(){yield this.onApplePayAuthorized(e.payment,l)}),(yield vo(this.action,this.options.events))?l.begin():this.isProcessing=!1,l}catch(e){return this.isProcessing=!1,null}})}onApplePayShippingContactSelected(e,t,n){return i(this,void 0,void 0,function*(){var i,s,a,l;const d=e.shippingContact;let c;d&&(c={deliveryAddress:{city:d.locality,postalCode:d.postalCode,state:d.administrativeArea,country:{code:null===(i=d.countryCode)||void 0===i?void 0:i.toUpperCase()}}});const u=yield Fi(null===(s=this.options)||void 0===s?void 0:s.events,c),h={label:(null===(l=null===(a=this.options.translations)||void 0===a?void 0:a.labels)||void 0===l?void 0:l.paymentScreenLabel)||"",type:"final",amount:n.value};try{if(!u)return void t.completeShippingContactSelection({newTotal:h,errors:[new ApplePayError("shippingContactInvalid","postalAddress","Delivery to this address is not supported.")]});t.completeShippingContactSelection({newTotal:h})}catch(e){r.PayrailsLogger.warn("ApplePaySession completeShippingContactSelection failed",{error:e instanceof o.PayrailsError?e:void 0})}})}onApplePayAuthorized(t,n){return i(this,void 0,void 0,function*(){return(yield xi(this.action,this.options.events))?this.action===uo.TOKENIZE?yield this.doTokenize(t,n):yield this.doAuthorizedPayment(t,n):(this.action===uo.AUTHORIZE?this.onAuthorizeFailedHandler(n,{code:e.AuthorizationFailureReasons.VALIDATION_FAILED,message:"Authorization request start validation failed"}):(this.isProcessing=!1,this.completeApplePaySession(n,"failure"),_o(this.action,this.options.events,{code:e.AuthorizationFailureReasons.VALIDATION_FAILED,message:"Request start validation failed"})),null)})}doAuthorizedPayment(t,n){return i(this,void 0,void 0,function*(){var i,s,r,a,l;const d=[{paymentMethodCode:e.PAYMENT_METHOD_CODES.APPLE_PAY,integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(t)},amount:Q().amount,storeInstrument:this.shouldStoreInstrument}];try{const t=yield this.paymentExecutor.pay(d);return"authorizeSuccessful"===(null===(i=t.finalState)||void 0===i?void 0:i.code)?(this.completeApplePaySession(n,"success"),this.isProcessing=!1,po(uo.AUTHORIZE,this.options.events,t)):this.onAuthorizeFailedHandler(n,{code:e.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:(null===(l=null===(a=null===(r=null===(s=t.finalState)||void 0===s?void 0:s.errors)||void 0===r?void 0:r[0])||void 0===a?void 0:a.reason)||void 0===l?void 0:l.result)||"Authorization Failed"}),t}catch(t){this.onAuthorizeFailedHandler(n,{code:e.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:t instanceof o.PayrailsError?t.message:"Authorization Failed"})}})}doTokenize(t,n){return i(this,void 0,void 0,function*(){const i=Q(),s=W.createInstrumentLink,o=i.token;if(!s)return this.completeApplePaySession(n,"failure"),this.isProcessing=!1,void _o(uo.TOKENIZE,this.options.events);let r;try{r=JSON.stringify(t)}catch(e){return this.completeApplePaySession(n,"failure"),this.isProcessing=!1,void _o(uo.TOKENIZE,this.options.events,e)}const a={holderReference:i.holderReference,paymentMethod:e.PAYMENT_METHOD_CODES.APPLE_PAY,storeInstrument:this.shouldStoreInstrument,data:{paymentToken:r}};try{const e=yield me({url:s,token:o,body:a});return e.ok?(this.completeApplePaySession(n,"success"),this.isProcessing=!1,po(uo.TOKENIZE,this.options.events,e.res),e.res):(this.completeApplePaySession(n,"failure"),this.isProcessing=!1,void _o(uo.TOKENIZE,this.options.events))}catch(e){return this.completeApplePaySession(n,"failure"),this.isProcessing=!1,void _o(uo.TOKENIZE,this.options.events,e)}})}}class Pn extends Bi{getIframeLabel(){var e;if(null===(e=this.opts)||void 0===e?void 0:e.label)return this.opts.label;switch(this.opts.type){case"CARD_NUMBER":return"Card number";case"EXPIRATION_MONTH":return"Expiry month";case"EXPIRATION_YEAR":return"Expiry year";case"EXPIRATION_DATE":return"Expiry date";case"CVV":return"Security code";case"CARDHOLDER_NAME":return"Cardholder name";case"CARD_FORM":return"Payrails Card Form";default:return"Payrails Secure Field"}}constructor(e,t){super("div",{id:`${e.type}-${re()}`,className:"payrails-secure-field"}),this.opts=e,this.containerOpts=t,this.isReady=!1,this.bus=Ie.getEventBus(),this.state={isEmpty:!0,isValid:!1,isFocused:!1}}on(e,t){const i=`${this.element.id}-${e}`;this.bus.on(i,t)}off(e,t){const i=`${this.element.id}-${e}`;this.bus.off(i,t)}mount(e){super.mount(e);const t=this.createIframe();this.attachReadyListener(),this.handleResize(t),this.element.appendChild(t)}getState(){return{isEmpty:this.state.isEmpty,isComplete:!this.state.isEmpty&&this.state.isValid,isValid:this.state.isValid,isFocused:this.state.isFocused,value:void 0,required:Boolean(this.opts.required)}}focus(){this.bus.emit(`${this.element.id}-${Ie.COLLECT_FRAME_EVENT_NAMES.FOCUS_ELEMENT}`,{})}setError(e){this.bus.emit(`${this.element.id}-${Ie.COLLECT_FRAME_EVENT_NAMES.SET_ERROR}`,{errorText:e})}resetError(){this.bus.emit(`${this.element.id}-${Ie.COLLECT_FRAME_EVENT_NAMES.SET_ERROR}`,{errorText:""})}update(e){this.bus.emit(`${this.element.id}-${Ie.COLLECT_FRAME_EVENT_NAMES.UPDATE}`,{data:e})}setAttribute(e,t){this.bus.emit(`${this.element.id}-${Ie.COLLECT_FRAME_EVENT_NAMES.SET_ATTRIBUTE}`,{attribute:e,value:t})}handleResize(e){const t=`${this.element.id}-${Ie.COLLECT_FRAME_EVENT_NAMES.RESIZE}`;this.bus.on(t,t=>{var i,n;const s=null===(n=null===(i=this.containerOpts)||void 0===i?void 0:i.styles)||void 0===n?void 0:n.base;e.width=(null==s?void 0:s.width)||t.width,e.height=(null==s?void 0:s.height)||t.height})}attachReadyListener(){const e=`${this.element.id}-${Ie.COLLECT_FRAME_EVENT_NAMES.READY}`,t=()=>{const i=`${this.element.id}-${Ie.COLLECT_FRAME_EVENT_NAMES.SHOW}`;this.bus.emit(i,{data:Object.assign(Object.assign({},this.opts),{containerId:this.containerOpts.containerId,sdkConfig:Q(),initResponse:J.getInstance().response,containerOpts:this.containerOpts})}),this.isReady=!0,this.bus.off(e,t)};this.bus.on(e,t),this.trackState()}trackState(){const e=e=>{const t=e;this.state.isEmpty=t.isEmpty,this.state.isValid=t.isValid,this.state.isFocused=t.isFocused};this.bus.on(`${this.element.id}-${Ie.COLLECT_FRAME_EVENT_NAMES.CHANGE}`,e),this.bus.on(`${this.element.id}-${Ie.COLLECT_FRAME_EVENT_NAMES.FOCUS}`,e),this.bus.on(`${this.element.id}-${Ie.COLLECT_FRAME_EVENT_NAMES.BLUR}`,e),this.bus.on(`${this.element.id}-${Ie.COLLECT_FRAME_EVENT_NAMES.ERROR}`,e=>{const t=e.code||o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_OPERATION_FAILED,i=new o.PayrailsError(t,{description:e.message});r.PayrailsLogger.error(i.message,{error:i})})}createIframe(){const e=document.createElement("iframe"),t=this.getIframeLabel();var i,n;return e.setAttribute("title",t),e.setAttribute("aria-label",t),e.setAttribute("data-frame-id",this.element.id),e.style.borderStyle="none",e.width="CARD_FORM"===this.opts.type?"100%":"0",e.height="0",e.setAttribute("src",(i=this.element.id,n=this.opts.type,`https://assets.payrails.io/apps/secure-frame/v1/index.html?mode=${Ie.SecureFrameMode.Collect}&type=${n}&id=${i}`)),e}}class bn{constructor(e){this.opts=e,this.className="payrails-collect-frames-container",this.dataTestId="payrails-collect-frames-container",this.bus=Ie.getEventBus(),this.secureFields=[],this.fetchBinLookup=e=>i(this,void 0,void 0,function*(){return Ee(e)}),this.bin="",this.id=`payrails-collect-frames-container-${re()}`,this.opts.containerId=this.id}static init(e){return new bn(Object.assign({},e))}mount(e){if("COMPOSABLE"!==this.opts.containerType)throw new Error("CollectFramesContainer.mount() is only supported for COMPOSABLE containers.");const t=document.querySelector(e);if(!t)throw new Error(`Element "${e}" not found`);const i=document.createElement("div");i.id=this.id,i.className=this.className,i.setAttribute("data-testid",this.dataTestId),t.appendChild(i),this.secureFields.forEach(e=>e.mount(`#${this.id}`))}unmount(){const e=document.getElementById(this.id);e&&e.remove(),this.secureFields.forEach(e=>e.unmount())}createCollectElement(e){const t=new Pn(e,this.opts);return this.secureFields.push(t),t}validate(){return i(this,void 0,void 0,function*(){return this.handleGlobalEvent(Ie.COLLECT_FRAME_EVENT_NAMES.VALIDATE)})}collect(){return i(this,void 0,void 0,function*(){var e;const{isValid:t}=yield this.validate();if(!t)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CARD_FORM_COMPLETE_AND_VALID_INPUTS,{description:"Card form has incomplete or invalid inputs."});const{encrypted:i}=yield this.handleGlobalEvent(Ie.COLLECT_FRAME_EVENT_NAMES.COLLECT);return{encryptedData:i,vaultProviderConfigId:null===(e=Q().vaultConfiguration)||void 0===e?void 0:e.providerConfigId}})}tokenize(e){return ve(()=>this.collect(),e)}reset(){this.secureFields.filter(e=>e.isReady).forEach(e=>this.bus.emit(`${e.id}-${Ie.COLLECT_FRAME_EVENT_NAMES.RESET}`,{}))}get isBinLookupEnabled(){var e;return!!(null===(e=Q().links)||void 0===e?void 0:e.binLookup)}get firstReadyField(){return this.secureFields.find(e=>e.isReady)}handleGlobalEvent(e){return i(this,arguments,void 0,function*(e,t={}){const i=this.firstReadyField;if(!i)throw new Error("No ready secure fields to collect data from.");return this.bus.emitAndResolve(`${i.id}-${e}`,Object.assign({frameIds:this.secureFields.filter(e=>e.isReady).map(e=>e.id)},t))})}}const Dn={wrapper:{display:"flex",flexDirection:"column"}},Mn=()=>i(void 0,void 0,void 0,function*(){const e=yield(({url:e})=>Wi({url:e}))({url:"https://assets.payrails.io/json/countries.json"});return new Map(Object.entries(e.res))});class wn extends Bi{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 kn="__payrails-selectedCountry";class Yn extends wn{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 i(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(kn)||"{}");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(kn,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(kn,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 Un extends wn{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 Fn extends Bi{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=Dn)||void 0===i?void 0:i.wrapper)}),this.options=e,this.countriesMap=void 0,this.createAddressComponents(),this.init(),this.applyStyles(),Mn().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,h;const p={id:"country-selector",styles:(null===(t=this.options.styles)||void 0===t?void 0:t.countrySelector)||(null===(i=Dn)||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}},_={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===(h=Dn)||void 0===h?void 0:h.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 Yn(p),this.postalCodeInput=new Un(_)}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 xn extends Bi{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()}getDefaultInstallment(){var e,t;return parseInt(null!==(e=sessionStorage.getItem(this.INSTALLMENT_STORAGE_KEY))&&void 0!==e?e:"",10)||(null===(t=this.options.installmentConfig)||void 0===t?void 0:t.defaultInstallment)}generateOptionsHTML(e){var t,i,n;const s=(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",o=this.getDefaultInstallment();return[`<option value="">${s}</option>`,...(null==e?void 0:e.map(e=>{const t=e.count===o?" selected":"";return`<option value="${e.count}" ${t}>${e.count} x ${e.amount}</option>`}))||[]].join("")}renderOptions(e){const t=this.element.querySelector("select");if(t){t.innerHTML=this.generateOptionsHTML(e);const i=this.getDefaultInstallment();i&&(t.value=String(i)),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 jn extends Bi{constructor(e,t){var i,n;super(e,t),this.options=t,this.paymentInstallmentsDropdown=null,this.paymentInstallmentsDropdown=new xn(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:Bn,CVV:Vn,CARDHOLDER_NAME:Gn,EXPIRATION_DATE:Xn,EXPIRATION_MONTH:zn,EXPIRATION_YEAR:Hn}=e.ElementType,$n={base:{border:"none",padding:"10px 16px",color:"#1d1d1d",backgroundColor:"#fff"},invalid:{backgroundColor:"#f9e1e1",borderColor:"#f25226",border:"1px solid"}},qn=[{type:Gn,placeholder:"Card holder",styles:Object.assign(Object.assign({},$n),{base:Object.assign(Object.assign({},$n.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px"})})},{type:Bn,placeholder:"1234 1234 1234 1234",styles:Object.assign(Object.assign({},$n),{base:Object.assign(Object.assign({},$n.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:zn,placeholder:"MM",styles:Object.assign(Object.assign({},$n),{base:Object.assign(Object.assign({},$n.base),{borderBottom:"1px solid #eae8ee",borderLeft:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomLeftRadius:"4px"})})},{type:Hn,placeholder:"YY",format:"YY",styles:Object.assign(Object.assign({},$n),{base:Object.assign(Object.assign({},$n.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee"})})},{type:Xn,placeholder:"MM/YY",format:"MM/YY",styles:Object.assign(Object.assign({},$n),{base:Object.assign(Object.assign({},$n.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:Vn,placeholder:"CVC",styles:Object.assign(Object.assign({},$n),{base:Object.assign(Object.assign({},$n.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomRightRadius:"4px"}),cardIcon:{position:"absolute",right:"8px",height:"24px",bottom:"calc(50% - 12px)"}})}];class Wn extends Nn{get bin(){return this.collectContainer.bin}get isBinLookupEnabled(){return this.collectContainer.isBinLookupEnabled}constructor(t,i){var n,s,o,r,a,l,d,c,u;super("div",Object.assign(Object.assign({},i),{translations:Object.assign(Object.assign({},null==i?void 0:i.translations),{labels:Object.assign(Object.assign({},null===(n=null==i?void 0:i.translations)||void 0===n?void 0:n.labels),{saveInstrument:null===(o=null===(s=null==i?void 0:i.translations)||void 0===s?void 0:s.labels)||void 0===o?void 0:o.saveCreditCard})}),styles:Object.assign({storeInstrumentCheckbox:null===(r=null==i?void 0:i.styles)||void 0===r?void 0:r.storeCardCheckbox},null==i?void 0:i.styles),id:"payrails-card-form"})),this.collectContainer=t,this.options=i,this.formFields=[],this.paymentInstallmentsDropdown=null,this.addressComponent=null,this.lastBin=null,this.lastBinLookup=null,this.defaultStyles={},this.defaultTranslations={},this.defaultStyles=(null===(a=this.options)||void 0===a?void 0:a.styles)||{},this.defaultTranslations=(null===(l=this.options)||void 0===l?void 0:l.translations)||{},this.eventsRef=null===(d=this.options)||void 0===d?void 0:d.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===(c=null==i?void 0:i.styles)||void 0===c?void 0:c.storeCardCheckbox)&&console.warn("The `storeCardCheckbox` option for styles is deprecated. Please use `storeInstrumentCheckbox` instead."),this.initializeFormFields(),this.subElements.push(this.collectContainer),W.isPaymentInstallmentsEnabled(e.PAYMENT_METHOD_CODES.CARD)&&(this.paymentInstallmentsDropdown=new jn("span",Object.assign(Object.assign({},i),{installmentConfig:{installmentCurrency:"",installmentOptions:this.getinstallmentOptions(),defaultInstallment:null===(u=null==i?void 0:i.installmentConfig)||void 0===u?void 0:u.defaultInstallment},id:"payrails-card-form-payment-installments",className:"payrails-card-form-payment-installments-container"})),this.paymentInstallmentsDropdown&&this.subElements.push(this.paymentInstallmentsDropdown)),W.isAddressSelectorEnabled(e.PAYMENT_METHOD_CODES.CARD)&&(this.addressComponent=this.createAddressSelector(),this.subElements.push(this.addressComponent)),this.storeInstrumentCheckbox&&this.subElements.push(this.storeInstrumentCheckbox)}initializeFormFields(){var i;if(this.collectContainer instanceof bn){const i=this.options||{},{events:n}=i,s=t(i,["events"]);return void this.formFields.push(new Kn(this.collectContainer,Object.assign(Object.assign({type:e.ElementType.CARD_FORM},s),{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)}})))}(null===(i=this.options)||void 0===i?void 0:i.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=z((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=z((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}})}),z(this.defaultStyles,e||{})}updateTranslations(e){const t=z(this.defaultTranslations||{},e||{});return this.formFields.forEach(e=>{var i,n,s,o;const r=null===(i=t.labels)||void 0===i?void 0:i[e.type],a=null===(n=t.placeholders)||void 0===n?void 0:n[e.type],l=null===(o=null===(s=t.error)||void 0===s?void 0:s.default)||void 0===o?void 0:o[e.type];e.update({translations:Object.assign(Object.assign(Object.assign({},void 0!==r&&{label:r}),void 0!==a&&{placeholder:a}),void 0!==l&&{translations:{error:{default:l}}})})}),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){this.collectContainer instanceof bn?this.updateSecureFields(e):this.updateSkyflow(e)}updateSkyflow(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)}updateSecureFields(e){var t;((null==e?void 0:e.styles)||(null==e?void 0:e.translations))&&(null===(t=this.formFields[0])||void 0===t||t.updateForm({styles:e.styles,translations:e.translations})),(null==e?void 0:e.styles)&&(this.defaultStyles=z(this.defaultStyles||{},e.styles)),(null==e?void 0:e.translations)&&(this.defaultTranslations=z(this.defaultTranslations||{},e.translations)),(null==e?void 0:e.events)&&this.updateEvents(e.events)}updateInstallmentConfig(t){var i,n,s,o,r;if(!this.paymentInstallmentsDropdown)return;const a=W.getPaymentInstallmentOptions(e.PAYMENT_METHOD_CODES.CARD),l={installmentCurrency:(null===(i=Q().amount)||void 0===i?void 0:i.currency)||""};this.options&&t&&Object.prototype.hasOwnProperty.call(t,"defaultInstallment")&&(this.options.installmentConfig={defaultInstallment:null!==(n=t.defaultInstallment)&&void 0!==n?n:null},l.defaultInstallment=null!==(s=t.defaultInstallment)&&void 0!==s?s:null);const d=null===(r=null===(o=this.lastBinLookup)||void 0===o?void 0:o.issuerCountry)||void 0===r?void 0:r.code,c=d&&a?a[d]:void 0;l.installmentOptions=c||[],this.paymentInstallmentsDropdown.updateInstallmentConfig(l)}createFormField(e,t,i,n,s,o=!1){var r,a,l,d,c,u,h;const p=this.prepareErrorStyles(i);return new Kn(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:p,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===(h=null===(u=null===(c=this.defaultTranslations)||void 0===c?void 0:c.error)||void 0===u?void 0:u.default)||void 0===h?void 0:h[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)}})}isFieldRequired(){var e,t;return!!(null===(t=null===(e=this.defaultStyles)||void 0===e?void 0:e.errorTextStyles)||void 0===t?void 0:t.base)}initializeCustomLayout(){var e;if(!(null===(e=this.options)||void 0===e?void 0:e.layout))return;const t=e=>{e.forEach(e=>{var t;const i=qn.find(t=>t.type===e);if(!i)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_TYPE);if(this.hasFieldBeenUsed(i.type))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_DUPLICATE_ELEMENT);const{type:n,styles:s,format:r,placeholder:a}=i,l=this.isFieldRequired();this.formFields.push(this.createFormField(n,s,null===(t=this.defaultStyles)||void 0===t?void 0:t.errorTextStyles,r,a,l))})};this.options.layout.forEach(e=>t(e))}hasFieldBeenUsed(e){return this.formFields.some(t=>t.type===e)}initializeDefaultLayout(){const t=t=>{var i,n,s;return!(null===(i=this.options)||void 0===i?void 0:i.showCardHolderName)&&t===e.ElementType.CARDHOLDER_NAME||!(null===(n=this.options)||void 0===n?void 0:n.showSingleExpiryDateField)&&t===e.ElementType.EXPIRATION_DATE||!(!(null===(s=this.options)||void 0===s?void 0:s.showSingleExpiryDateField)||t!==e.ElementType.EXPIRATION_MONTH&&t!==e.ElementType.EXPIRATION_YEAR)};qn.filter(({type:e})=>!t(e)).forEach(({type:e,styles:t,format:i,placeholder:n})=>{var s;const o=this.isFieldRequired();this.formFields.push(this.createFormField(e,t,null===(s=this.defaultStyles)||void 0===s?void 0:s.errorTextStyles,i,n,o))})}throttledFetchBinLookupIfChanged(){return i(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 Fn({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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw r.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(t,i){var n;const s={};return["base","complete","empty","focus","invalid","cardIcon","copyIcon"].forEach(e=>{var n,o,r,a,l,d;s[e]=Object.assign(Object.assign(Object.assign({},(null===(r=null===(o=null===(n=this.defaultStyles)||void 0===n?void 0:n.inputFields)||void 0===o?void 0:o.all)||void 0===r?void 0:r[e])||{}),(null===(d=null===(l=null===(a=this.defaultStyles)||void 0===a?void 0:a.inputFields)||void 0===l?void 0:l[i])||void 0===d?void 0:d[e])||{}),(null==t?void 0:t[e])||{})}),(null===(n=this.options)||void 0===n?void 0:n.showCardHolderName)&&i===e.ElementType.CARD_NUMBER&&(this.element.setAttribute("class","with-card-holder"),s.base=Object.assign(Object.assign(Object.assign({},$n.base),{border:"1px solid #eae8ee",borderTop:"none",padding:"10px 16px",textIndent:"0"}),s.base)),s}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 t;const i=this.formFields.find(e=>e.bin);i&&(this.collectContainer.bin=i.bin),(null===(t=this.eventsRef)||void 0===t?void 0:t.onChange)&&(this.eventsRef.onChange({isValid:this.isValid,cardNetwork:this.cardNetwork,bin:this.bin,billingAddress:this.billingAddress}),W.isPaymentInstallmentsEnabled(e.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 i(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 i(this,void 0,void 0,function*(){return this.isBinLookupEnabled?yield this.collectContainer.fetchBinLookup(this.bin):this.bin})}getinstallmentOptions(t){if(t){const i=W.getPaymentInstallmentOptions(e.PAYMENT_METHOD_CODES.CARD);return i?i[t]:null}return null}unmount(){this.hide({reset:!0}),super.unmount()}mount(e){super.mount(e),this.show()}}class Kn{constructor(e,t){this.isValid=!1,this.isReady=!1,this.cardNetwork="",this.bin="";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,bin:o}=e;this.isValid=!t&&n,void 0!==o&&(this.bin=o),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;const o=null===(i=null===(t=null==e?void 0:e.translations)||void 0===t?void 0:t.error)||void 0===i?void 0:i.default;null===(s=(n=this.vaultElement).update)||void 0===s||s.call(n,Object.assign(Object.assign(Object.assign({type:this.type},void 0!==(null==e?void 0:e.label)&&{label:e.label}),void 0!==o&&{translations:{error:{default:o}}}),void 0!==(null==e?void 0:e.placeholder)&&{placeholder:e.placeholder}))}update(e){e.styles&&this.updateStyles(e.styles),e.translations&&this.updateTranslations(e.translations)}updateForm(e){var t,i;if(!e.styles&&!e.translations)return;const n=Object.assign(Object.assign({type:this.type},void 0!==e.styles&&{styles:e.styles}),void 0!==e.translations&&{translations:e.translations});null===(i=(t=this.vaultElement).update)||void 0===i||i.call(t,n)}focus(){var e,t;null===(t=(e=this.vaultElement).focus)||void 0===t||t.call(e)}}class Zn extends Bi{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.element.setAttribute("data-testid",`dropin-item-${e}`),this.applyBaseStyles();const o=`payrails-dropin-item-${e}`,r=document.createElement("label");r.setAttribute("for",o),r.setAttribute("data-testid",`dropin-item-label-${e}`);const a=document.createElement("input");if(a.setAttribute("type","radio"),a.setAttribute("name","payment-option"),a.setAttribute("id",o),a.setAttribute("value",o),a.setAttribute("data-testid",`dropin-item-radio-${e}`),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),d.setAttribute("data-testid","dropin-item-container"),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 Jn;!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"}(Jn||(Jn={}));const Qn={[e.PAYMENT_METHOD_CODES.CARD]:"https://assets.payrails.io/img/logos/card/",[e.PAYMENT_METHOD_CODES.PAYPAL]:"https://assets.payrails.io/img/logos/paypal/",[e.PAYMENT_METHOD_CODES.APPLE_PAY]:"https://assets.payrails.io/img/logos/applepay/",[e.PAYMENT_METHOD_CODES.GOOGLE_PAY]:"https://assets.payrails.io/img/logos/googlepay/"};class es extends Zn{constructor(e,t,i,n,s){const o=e.displayName&&""!==e.displayName?e.displayName:"Unavailable";super(`payrails-payment-instrument-${e.id}`,o,es.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 ts(t,s)}static getInstrumentIcon(t){var i;if(t.paymentMethod===e.PAYMENT_METHOD_CODES.CARD){const n=Qn[e.PAYMENT_METHOD_CODES.CARD];switch(null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.network){case Jn.AMEX:return n+"amex.svg";case Jn.DINERS:return n+"diners-club.svg";case Jn.DISCOVER:return n+"discover.svg";case Jn.HIPERCARD:return n+"hipercard.svg";case Jn.JCB:return n+"jcb.svg";case Jn.MAESTRO:return n+"maestro.svg";case Jn.MASTERCARD:return n+"mastercard.svg";case Jn.UNIONPAY:return n+"unionpay.svg";case Jn.VISA:return n+"visa.svg"}return n+"default.svg"}return t.paymentMethod===e.PAYMENT_METHOD_CODES.PAYPAL?Qn[e.PAYMENT_METHOD_CODES.PAYPAL]+"logo.svg":t.paymentMethod===e.PAYMENT_METHOD_CODES.APPLE_PAY?Qn[e.PAYMENT_METHOD_CODES.APPLE_PAY]+"logo.svg":t.paymentMethod===e.PAYMENT_METHOD_CODES.GOOGLE_PAY?Qn[e.PAYMENT_METHOD_CODES.GOOGLE_PAY]+"logo.svg":""}updateInstallmentConfig(t){var i,n,s,o,r;if(!this.installmentDropdown||this.instrumentData.paymentMethod!==e.PAYMENT_METHOD_CODES.CARD)return;const a=W.getPaymentInstallmentOptions(e.PAYMENT_METHOD_CODES.CARD),l=null===(s=null===(n=null===(i=this.instrumentData.data)||void 0===i?void 0:i.binLookup)||void 0===n?void 0:n.issuerCountry)||void 0===s?void 0:s.code,d={installmentCurrency:(null===(o=Q().amount)||void 0===o?void 0:o.currency)||""};t&&Object.prototype.hasOwnProperty.call(t,"defaultInstallment")&&(d.defaultInstallment=null!==(r=t.defaultInstallment)&&void 0!==r?r:null);const c=l&&a?a[l]:void 0;d.installmentOptions=c||[],this.installmentDropdown.updateInstallmentConfig(d)}}class ts extends Bi{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 is extends Bi{constructor(e){super("div",{id:"payrails-card-list"}),this.listItems=[],W.savedCreditCards.forEach(t=>{const i=new ns(()=>{(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 ns extends Bi{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=es.getInstrumentIcon(t),a.className="payment-option-icon",r.appendChild(a),r.appendChild(document.createTextNode(n)),this.element.appendChild(s)}}class ss extends Bi{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 os extends Bi{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 rs extends Bi{constructor(e){super("div",{id:"payrails-dropin-loader",className:"payrails-dropin-loader-wrapper"}),this.options=e,this.selectors={[as.overlay]:".loading-overlay",[as.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 as;!function(e){e.overlay="overlay",e.loader="loader"}(as||(as={}));const ls="https://assets.payrails.io/img/logos";function ds(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?`${ls}/${e}/logo.svg`:`${ls}/card/credit-card-regular.svg`}class cs extends Zn{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;const i=this.element.querySelector(this.component.selector);i&&(i.style.display="block"),null===(t=null===(e=this.events)||void 0===e?void 0:e.onPaymentOptionVisibilityChange)||void 0===t||t.call(e)}deactivate(){if(!this.isActive)return;this.isActive=!1,this.applyBaseStyles();const e=this.element.querySelector(this.component.selector);e&&(e.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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);throw r.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 us extends cs{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?ds("applepay"):void 0,void 0,e.styles),this.loadElementId="apple-pay-dropin-load-element",this.component=new Sn(Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},e.events),{onApplePayAvailable:()=>{this.mountAfterAvailable()}})}))}}class hs extends Zn{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?ds("card"):void 0,Object.assign({},i.events),Object.assign({},i.styles)),this.cardForm=e,this.paymentButton=t,this.cardFormShown=!1,this.component=new ps(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 ps extends Bi{constructor(e,t){super("div",{id:"payrails-form-container"}),this.subElements.push(e,t)}}var _s;e.ACTION_REQUIRED_KIND=void 0,(_s=e.ACTION_REQUIRED_KIND||(e.ACTION_REQUIRED_KIND={})).GENERIC_REDIRECT="genericRedirect",_s.THREE_DS="3ds";const Es=new class{constructor(){this.handlers=new Map}on(e,t){let i=this.handlers.get(e);return i||(i=new Set,this.handlers.set(e,i)),i.add(t),()=>this.off(e,t)}off(e,t){var i;null===(i=this.handlers.get(e))||void 0===i||i.delete(t)}hasListeners(e){const t=this.handlers.get(e);return!!t&&t.size>0}emit(e,t){return i(this,void 0,void 0,function*(){const i=this.handlers.get(e);if(i&&0!==i.size)for(const n of Array.from(i))try{yield n(t)}catch(t){const i=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_UNKNOWN_ERROR,{description:`Handler for "${e}" threw`,cause:t});r.PayrailsLogger.error(i.message,{error:i})}})}reset(){this.handlers.clear()}};function ms(){return Es}const vs="actionRequired";function ys(e){return i(this,arguments,void 0,function*({url:e,kind:t,paymentMethodCode:i,executionId:n}){var s;let o=!1;const r={url:e,kind:t,paymentMethodCode:i,executionId:null!==(s=null!=n?n:W.executionId)&&void 0!==s?s:"",preventDefault:()=>{o=!0}};return yield ms().emit(vs,r),o})}function Is(){return ms().hasListeners(vs)}class fs{constructor(e,t,i,n=As.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===As.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 t=document.createElement("button");return t.setAttribute("id","payrails-popup-cancel-button"),t.setAttribute("type","button"),t.setAttribute("aria-label","Close"),t.addEventListener("click",()=>{Ie.getEventBus().emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}),_o(uo.AUTHORIZE,this.options.events,{code:e.AuthorizationFailureReasons.USER_CANCELLED,message:"User cancelled the authorization."}),this.unmount()}),t}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 t=n=>i(this,void 0,void 0,function*(){var i,s,o,r,a;if(n.data&&'{"type":"3DS-challenge-completed"}'===n.data){window.removeEventListener("message",t);const n=yield this.paymentExecutor.pollForAuthorizationResult(W.url);switch(null===(i=n.finalState)||void 0===i?void 0:i.code){case"authorizeSuccessful":po(uo.AUTHORIZE,this.options.events);break;case"authorizePending":mo(uo.AUTHORIZE,this.options.events);break;default:_o(uo.AUTHORIZE,this.options.events,{code:e.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:(null===(a=null===(r=null===(o=null===(s=n.finalState)||void 0===s?void 0:s.errors)||void 0===o?void 0:o[0])||void 0===r?void 0:r.reason)||void 0===a?void 0:a.result)||"Authorization failed after 3DS challenge."})}this.unmount()}});window.addEventListener("message",t)}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 As;!function(e){e[e.THREE_DS=0]="THREE_DS",e[e.GENERIC_REDIRECT=1]="GENERIC_REDIRECT"}(As||(As={}));const Ls="https://assets.payrails.io/img/logos/revolutpay/button",Os={backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"contain",backgroundColor:"transparent",fontSize:"0",color:"transparent",padding:"0",display:"block",maxWidth:"100%",margin:"0 auto",aspectRatio:"250 / 44",border:"none",cursor:"pointer",transition:"opacity 0.2s ease"},gs="lightOutline",Ts="Pay with Revolut Pay",Cs={dark:{base:{backgroundImage:`url(${Ls}/dark/Medium.svg)`},hover:{opacity:"0.85"},loading:{backgroundImage:"none",backgroundColor:"#191C1F",color:"#FFFFFF"}},light:{base:{backgroundImage:`url(${Ls}/white/Medium.svg)`},hover:{opacity:"0.85"},loading:{backgroundImage:"none",backgroundColor:"#FFFFFF",color:"#191C1F"}},lightOutline:{base:{backgroundImage:`url(${Ls}/outline/Medium.svg)`},hover:{opacity:"0.85"},loading:{backgroundImage:"none",backgroundColor:"#FFFFFF",color:"#191C1F"}}};function Rs(e){var t;const i=null==e?void 0:e.theme,n=Cs[i&&i in Cs?i:gs],s={width:null!==(t=null==e?void 0:e.width)&&void 0!==t?t:"250px"};return(null==e?void 0:e.borderRadius)&&(s.borderRadius=e.borderRadius),{base:Object.assign(Object.assign(Object.assign({},Os),null==n?void 0:n.base),s),hover:Object.assign({},null==n?void 0:n.hover),loading:Object.assign(Object.assign({},null==n?void 0:n.loading),s)}}const Ns="__PAYRAILS__TAB_MANUAL_CLOSE_ERROR__",Ss={label:"Generic redirect"},Ps={pix:75e4,modo:6e5},bs={showCancelButton:!0};class Ds extends Bi{constructor(t,i){var n,s,o;super("button",{id:`payrails-generic-redirect-${t.paymentMethod.paymentMethodCode}`,className:"payrails-generic-button"}),this.returnInfo=i,this.popup=null,this.isDisabled=!1,this.isLoading=!1,this.isRevolutPay=t.paymentMethod.paymentMethodCode===e.PAYMENT_METHOD_CODES.REVOLUT_PAY,this.options=Object.assign(Object.assign({},t),{styles:this.isRevolutPay?Rs(t.styles):t.styles,translations:this.isRevolutPay?{label:Ts}:t.translations}),this.element.innerText=null!==(s=null===(n=this.options.translations)||void 0===n?void 0:n.label)&&void 0!==s?s:Ss.label,(null===(o=this.options.styles)||void 0===o?void 0:o.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 _n(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:Ss.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 i(this,void 0,void 0,function*(){var t,i;if(this.isDisabled)return;let n=null;this.options.openInNewTab&&this.isSafari()&&(n=window.open("","_blank"));try{if(this.triggerLoading(!0),!(yield vo(uo.AUTHORIZE,null!==(t=this.options.events)&&void 0!==t?t:{})))return this.triggerLoading(!1),void(n&&!n.closed&&n.close());const s=null===(i=W.availablePaymentMethods.find(({paymentMethodCode:e})=>e===this.options.paymentMethod.paymentMethodCode))||void 0===i?void 0:i.integrationType;if(!s)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED);const r=yield this.paymentExecutor.pay([{paymentMethodCode:this.options.paymentMethod.paymentMethodCode,integrationType:s,amount:Q().amount}]),{action:a,link:l}=this.handleAuthorizationResult(r);if("redirect"!==a)return void(n&&!n.closed&&n.close());if(!l)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK);if(Is()&&(yield ys({url:l,kind:e.ACTION_REQUIRED_KIND.GENERIC_REDIRECT,paymentMethodCode:this.options.paymentMethod.paymentMethodCode})))return n&&!n.closed&&n.close(),void this.triggerLoading(!1);if(Object.keys(Ps).includes(this.options.paymentMethod.paymentMethodCode)){n&&!n.closed&&n.close();const e=Ps[this.options.paymentMethod.paymentMethodCode],t=2e4,i=2e3,s=Math.ceil((e-t)/i);return new _n(this.returnInfo,i,s,t).pollForAuthorizationResult(W.url,0,["authorizeSuccessful","authorizeFailed"]).then(e=>{var t;this.handleAuthorizationResult(e),null===(t=this.popup)||void 0===t||t.unmount()}),this.createPopupWithTimeout(l,e)}return this.redirectToPaymentLink(l,n)}catch(e){n&&!n.closed&&n.close(),e instanceof o.PayrailsError&&r.PayrailsLogger.error(e.message,{error:e}),_o(uo.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 o.PayrailsError(o.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)?(po(uo.AUTHORIZE,this.options.events),{code:"authorizeSuccessful",action:"success"}):(_o(uo.AUTHORIZE,this.options.events,e),this.triggerLoading(!1),{code:"authorizeFailed",action:"fail"})}createPopupWithTimeout(e,t){return new Promise(()=>{const i=new fs(e,this.paymentExecutor,Object.assign(Object.assign({},this.options),bs));this.popup=i,this.popup.mount(),setTimeout(()=>{null==i||i.unmount(),_o(uo.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){r.PayrailsLogger.warn("Popup blocked. Falling back to same tab redirect."),window.location.href=e;const t=setTimeout(()=>{var e;_o(uo.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;_o(uo.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(t){return i(this,void 0,void 0,function*(){var i,n,s,o,a,l;let d;try{d=W.url}catch(s){return r.PayrailsLogger.error("Unable to resolve workflow execution URL.",{error:s}),this.triggerLoading(!1),t.closed||t.close(),void(null===(n=null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeFailed)||void 0===n||n.call(i,{code:e.AuthorizationFailureReasons.UNKNOWN_ERROR,message:"Unable to resolve workflow execution URL.",rawError:s}))}const c=new _n(this.returnInfo),u=new AbortController,{promise:h,cleanup:p}=this.watchTabClosure(t,()=>{u.signal.aborted||u.abort(Ns),this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{})});try{const e=yield Promise.race([c.pollForAuthorizationResult(d,0,["authorizeSuccessful","authorizeFailed"],{signal:u.signal}),h]);u.signal.aborted||u.abort("authorization-completed"),this.handleAuthorizationResult(e)}catch(t){if(u.signal.aborted||u.abort(t),t===Ns){try{const e=new _n(this.returnInfo,1e3,3,0),t=yield e.pollForAuthorizationResult(d,0,["authorizeSuccessful","authorizeFailed"]);return void this.handleAuthorizationResult(t)}catch(e){}null===(o=null===(s=this.options.events)||void 0===s?void 0:s.onAuthorizeFailed)||void 0===o||o.call(s,{code:e.AuthorizationFailureReasons.USER_CANCELLED,message:"User closed the payment window before completion."})}else r.PayrailsLogger.error("Failed to retrieve authorization result after redirect.",{error:t}),null===(l=null===(a=this.options.events)||void 0===a?void 0:a.onAuthorizeFailed)||void 0===l||l.call(a,{code:e.AuthorizationFailureReasons.UNKNOWN_ERROR,message:"Failed to retrieve authorization result after redirect.",rawError:t})}finally{u.signal.aborted||u.abort("cleanup"),p(),t.closed||t.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(Ns))},500)}),cleanup:s}}updateStyles(e){var t,i;this.isRevolutPay?this.options.styles=Rs(e):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.isRevolutPay||(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:Ss.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 Ms=t=>t===e.PAYMENT_METHOD_CODES.GENERIC_REDIRECT?{translations:{label:"Mercado Pago",button:{label:"Pay with Mercado Pago"}}}:t===e.PAYMENT_METHOD_CODES.IDEAL?{translations:{label:"iDEAL | Wero",button:{label:"Pay with iDEAL | Wero"}}}:{translations:{label:t,button:{label:`Pay with ${t}`}}};class ws extends Zn{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)||Ms(e.paymentMethod.paymentMethodCode).translations.label,(null===(n=e.config)||void 0===n?void 0:n.showPaymentMethodLogo)?ds(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 Ds({styles:null===(o=null==e?void 0:e.styles)||void 0===o?void 0:o.button,translations:(null===(r=null==e?void 0:e.translations)||void 0===r?void 0:r.button)||Ms(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)}}function ks(e){let t=null;return()=>{var i,n;if(null!==t)return t;const s=null!==(n=null===(i=Q().featureConfig)||void 0===i?void 0:i[e])&&void 0!==n?n:0;return t=100*Math.random()<s,t}}class Ys{constructor(e,t){this.options=e,this.paymentExecutor=t}handle3ds(t){return i(this,void 0,void 0,function*(){var i,n,s,o;try{null===(n=null===(i=this.options.events)||void 0===i?void 0:i.onThreeDSecureChallenge)||void 0===n||n.call(i)}catch(e){}const r=null===(s=null==t?void 0:t.response)||void 0===s?void 0:s.links["3ds"];if(r){if(Is()&&(yield ys({url:r,kind:e.ACTION_REQUIRED_KIND.THREE_DS,paymentMethodCode:null!==(o=this.options.paymentMethodCode)&&void 0!==o?o:""})))return;this.options.redirectFor3DS?window.location.assign(r):new fs(r,this.paymentExecutor,this.options).mount()}})}}const Us={apiVersion:2,apiVersionMinor:0},Fs=new Set(["BHD","IQD","JOD","KWD","LYD","OMR","TND"]);let xs=class t extends Nn{static getGooglePayConfigAsArray(e){return Array.isArray(e)?e:e.allowedPaymentMethods?e.allowedPaymentMethods:[]}static getSDKClient(){return i(this,arguments,void 0,function*(i=e.PayrailsEnvironment.TEST,n){return yield Ln.load(An.GooglePay),t.googleSDKClient||(t.googleSDKClient=new google.payments.api.PaymentsClient({environment:i,merchantInfo:n})),t.googleSDKClient})}static isGooglePayAvailable(n){return i(this,arguments,void 0,function*(i,n=e.PayrailsEnvironment.TEST,s){var o,r,a,l;try{const e=Array.isArray(i)||null===(o=i.merchantInfo)||void 0===o?void 0:o.merchantName,d={merchantId:null!==(r=null==s?void 0:s.merchantId)&&void 0!==r?r:"",merchantName:null!==(l=null!==(a=null==s?void 0:s.merchantName)&&void 0!==a?a:e)&&void 0!==l?l:""},c=yield t.getSDKClient(n,d),u=t.getGooglePayConfigAsArray(i),h=Object.assign(Object.assign(Object.assign({},Us),{allowedPaymentMethods:u}),!Array.isArray(i)&&void 0!==i.existingPaymentMethodRequired&&{existingPaymentMethodRequired:i.existingPaymentMethodRequired}),{result:p}=yield c.isReadyToPay(h);return p}catch(e){return!1}})}constructor(e){var i;super("div",Object.assign(Object.assign({},e),{id:`payrails-google-pay-button-${re()}`,dataTestId:"payrails-google-pay-button"})),this.options=e,this.sdkLoadedCalled=!1,this.isProcessing=!1,this.buttonElement=null,this.paymentExecutor=new _n(null===(i=this.options)||void 0===i?void 0:i.returnInfo),t.isGooglePayAvailable(W.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"===Q().type?uo.TOKENIZE:uo.AUTHORIZE}sdkLoaded(e){return i(this,void 0,void 0,function*(){var n,s,o,r,a,l,d,c,u,h,p,_;if(this.sdkLoadedCalled)return this.buttonElement;this.sdkLoadedCalled=!0;const E=(null===(s=null===(n=this.options)||void 0===n?void 0:n.styles)||void 0===s?void 0:s.buttonColor)||"black",m=(null===(r=null===(o=this.options)||void 0===o?void 0:o.styles)||void 0===r?void 0:r.buttonType)||"long",v=(null===(l=null===(a=this.options)||void 0===a?void 0:a.styles)||void 0===l?void 0:l.buttonSizeMode)||"fill";(null===(c=null===(d=this.options)||void 0===d?void 0:d.styles)||void 0===c?void 0:c.buttonLocale)&&console.warn("Payrails: styles.buttonLocale is deprecated and will be removed in a future release. Use styles.locale instead.");const y=(null===(h=null===(u=this.options)||void 0===u?void 0:u.styles)||void 0===h?void 0:h.locale)||(null===(_=null===(p=this.options)||void 0===p?void 0:p.styles)||void 0===_?void 0:_.buttonLocale),I=y?(f=Cn(y),gn(f).split("-")[0]):void 0;var f;const A=t.getGooglePayConfigAsArray(W.googlePayConfig);return this.buttonElement=e.createButton({buttonColor:E,buttonType:m,buttonSizeMode:v,buttonLocale:I,onClick:()=>i(this,void 0,void 0,function*(){this.isProcessing||(this.isProcessing=!0,(yield vo(this.action,this.options.events))?yield this.authorize(e):this.isProcessing=!1)}),allowedPaymentMethods:A}),this.element.appendChild(this.buttonElement),this.buttonElement})}authorize(e){return i(this,void 0,void 0,function*(){var i,n,s,o,a,l,d;const c=W.googlePayConfig,u=!Array.isArray(c),h=Q().amount,p=null===(o=null===(s=null===(n=null===(i=W.meta)||void 0===i?void 0:i.order)||void 0===n?void 0:n.billingAddress)||void 0===s?void 0:s.country)||void 0===o?void 0:o.code,_=!!(null==h?void 0:h.currency)&&Fs.has(h.currency);_&&r.PayrailsLogger.debug(`Payrails: 3-decimal currency ${null==h?void 0:h.currency}, omitting totalPrice`);const E=Object.assign(Object.assign({},u&&void 0!==c.apiVersion?{apiVersion:c.apiVersion,apiVersionMinor:c.apiVersionMinor}:Us),{allowedPaymentMethods:t.getGooglePayConfigAsArray(c),transactionInfo:_?{totalPriceStatus:"NOT_CURRENTLY_KNOWN",currencyCode:null==h?void 0:h.currency,countryCode:p}:{totalPriceStatus:"FINAL",totalPrice:null==h?void 0:h.value,currencyCode:null==h?void 0:h.currency,countryCode:p},merchantInfo:{merchantId:(null===(a=this.options.merchantInfo)||void 0===a?void 0:a.merchantId)||"",merchantName:(null===(l=this.options.merchantInfo)||void 0===l?void 0:l.merchantName)||(null===(d=c.merchantInfo)||void 0===d?void 0:d.merchantName)||""}});u&&(void 0!==c.emailRequired&&(E.emailRequired=c.emailRequired),void 0!==c.shippingAddressRequired&&(E.shippingAddressRequired=c.shippingAddressRequired),c.shippingAddressParameters&&(E.shippingAddressParameters=c.shippingAddressParameters));try{const t=yield e.loadPaymentData(E);yield this.onLoadPaymentData(t)}catch(e){this.isProcessing=!1,_o(this.action,this.options.events,e)}})}onLoadPaymentData(e){return i(this,void 0,void 0,function*(){(yield xi(this.action,this.options.events))?(this.action===uo.TOKENIZE?yield this.doTokenize(e):yield this.doAuthorizePayment(e),this.isProcessing=!1):this.isProcessing=!1})}doTokenize(t){return i(this,void 0,void 0,function*(){const i=Q(),n=W.createInstrumentLink,s=i.token;if(!n)return this.isProcessing=!1,void _o(uo.TOKENIZE,this.options.events);let o;try{o=JSON.stringify(t)}catch(e){return this.isProcessing=!1,void _o(uo.TOKENIZE,this.options.events,e)}const r={holderReference:i.holderReference,paymentMethod:e.PAYMENT_METHOD_CODES.GOOGLE_PAY,storeInstrument:this.shouldStoreInstrument,data:{paymentToken:o}};try{const e=yield me({url:n,token:s,body:r});return e.ok?(this.isProcessing=!1,po(uo.TOKENIZE,this.options.events,e.res),e.res):(this.isProcessing=!1,void _o(uo.TOKENIZE,this.options.events))}catch(e){return this.isProcessing=!1,void _o(uo.TOKENIZE,this.options.events,e)}})}doAuthorizePayment(t){return i(this,void 0,void 0,function*(){var i,n,s,o,r,a;const l={paymentToken:JSON.stringify(t)},d=[{paymentMethodCode:e.PAYMENT_METHOD_CODES.GOOGLE_PAY,integrationType:"api",paymentInstrumentData:l,amount:Q().amount,storeInstrument:this.shouldStoreInstrument}],c=yield this.paymentExecutor.pay(d);if("authorizePending"===(null===(i=null==c?void 0:c.finalState)||void 0===i?void 0:i.code)){const t=new Ys(Object.assign(Object.assign({},this.options),{paymentMethodCode:e.PAYMENT_METHOD_CODES.GOOGLE_PAY}),this.paymentExecutor);yield t.handle3ds(c)}else"authorizeSuccessful"===(null===(n=null==c?void 0:c.finalState)||void 0===n?void 0:n.code)?po(uo.AUTHORIZE,this.options.events):_o(uo.AUTHORIZE,this.options.events,{code:e.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:(null===(a=null===(r=null===(o=null===(s=c.finalState)||void 0===s?void 0:s.errors)||void 0===o?void 0:o[0])||void 0===r?void 0:r.reason)||void 0===a?void 0:a.result)||"Authorization Failed"})})}mount(e){super.mount(e),(()=>{i(this,void 0,void 0,function*(){var e;try{if(yield t.isGooglePayAvailable(W.googlePayConfig,this.options.environment,this.options.merchantInfo)){const i=yield t.getSDKClient(this.options.environment,this.options.merchantInfo),n=yield this.sdkLoaded(i);this.element.appendChild(n),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()}};xs.googleSDKClient=null;class js{constructor(t=e.PayrailsEnvironment.TEST){this.environment=t,this.iframe=null,this.bus=Ie.getEventBus(),this.destroyed=!1,this.controller=new AbortController,this.busTeardowns=[],this.frameId=re(),this.readyPromise=this.armReadyPromise()}createIframe(){const e=document.createElement("iframe");var t;return e.src=(t=this.frameId,`https://assets.payrails.io/apps/secure-frame/v1/index.html?mode=${Ie.SecureFrameMode.Collect}&type=${Ie.SecureFrameType.GooglePay}&id=${t}`),e.setAttribute("data-payrails-gpay-frame",this.frameId),e.allow="payment",e.setAttribute("sandbox","allow-scripts allow-popups allow-same-origin allow-forms"),e.setAttribute("id",this.frameId),e.style.border="none",e}attachIframe(e,t){this.iframe=this.createIframe(),t.hidden&&(this.iframe.width="0",this.iframe.height="0",this.iframe.style.display="none"),e.appendChild(this.iframe)}armReadyPromise(){const e=`${this.frameId}-${Ie.COLLECT_FRAME_EVENT_NAMES.READY}`,t=`${this.frameId}-${Ie.COLLECT_FRAME_EVENT_NAMES.ERROR}`;return new Promise((i,n)=>{const s=()=>{this.bus.off(e,s),this.bus.off(t,o),i()},o=i=>{var a;this.bus.off(e,s),this.bus.off(t,o);const l=i;r.PayrailsLogger.error(null!==(a=null==l?void 0:l.message)&&void 0!==a?a:"Google Pay secure-frame error",{extra:l}),n(i)};this.bus.on(e,s),this.bus.on(t,o)})}isGooglePayAvailable(e){return i(this,void 0,void 0,function*(){var t;if(this.destroyed)return!1;try{if(this.attachIframe(document.body,{hidden:!0}),yield this.readyPromise,this.destroyed)return!1;const t=yield this.bus.emitAndResolve(`${this.frameId}-${Ie.COLLECT_FRAME_EVENT_NAMES.IS_AVAILABLE}`,{googlePayConfig:e,environment:this.environment},"*",this.controller.signal);return Boolean(null==t?void 0:t.result)}catch(e){return!1}finally{null===(t=this.iframe)||void 0===t||t.remove(),this.iframe=null}})}mountButton(e){return i(this,void 0,void 0,function*(){this.destroyed||(this.readyPromise=this.armReadyPromise(),this.attachIframe(e.target,{hidden:!1}),this.applyMountSizing(e.buttonStyle),this.registerCollectListeners(e),yield this.requestShow(e))})}applyMountSizing(e){this.iframe&&(this.iframe.style.width="static"===e.buttonSizeMode?"0px":"100%",this.iframe.style.height="0px")}registerCollectListeners(e){const t=`${this.frameId}-${Ie.COLLECT_FRAME_EVENT_NAMES.RESIZE}`,n=e=>{var t;const{width:i,height:n}=null!==(t=e)&&void 0!==t?t:{};this.iframe&&(i&&(this.iframe.style.width=i),n&&(this.iframe.style.height=n))};this.bus.on(t,n),this.busTeardowns.push(()=>this.bus.off(t,n));const s=this.bus.onAndEmit(`${this.frameId}-${Ie.COLLECT_FRAME_EVENT_NAMES.BUTTON_CLICK_VALIDATE}`,()=>i(this,void 0,void 0,function*(){return{isValid:yield e.onButtonClicked()}}));this.busTeardowns.push(s);const o=`${this.frameId}-${Ie.COLLECT_FRAME_EVENT_NAMES.COLLECT}`,r=t=>{var i;const{paymentData:n}=null!==(i=t)&&void 0!==i?i:{};n&&e.onCollect(n)};this.bus.on(o,r),this.busTeardowns.push(()=>this.bus.off(o,r));const a=`${this.frameId}-${Ie.COLLECT_FRAME_EVENT_NAMES.COLLECT_ERROR}`,l=t=>{var i,n;null===(i=e.onCollectError)||void 0===i||i.call(e,null!==(n=t)&&void 0!==n?n:{code:"OTHER"})};this.bus.on(a,l),this.busTeardowns.push(()=>this.bus.off(a,l))}requestShow(e){return i(this,void 0,void 0,function*(){if(yield this.readyPromise,this.destroyed)return;const t={type:"GOOGLE_PAY_BUTTON",environment:e.environment,googlePayConfig:e.googlePayConfig,amount:e.amount,countryCode:e.countryCode,buttonStyle:e.buttonStyle},i=yield this.bus.emitAndResolve(`${this.frameId}-${Ie.COLLECT_FRAME_EVENT_NAMES.SHOW}`,t,"*",this.controller.signal);if(!this.destroyed&&!(null==i?void 0:i.success))throw new Error(`Failed to render Google Pay button: ${i&&"error"in i?i.error:"unknown"}`)})}unmount(){var e;this.destroyed=!0,this.controller.abort();for(const e of this.busTeardowns)e();this.busTeardowns=[],null===(e=this.iframe)||void 0===e||e.remove(),this.iframe=null}destroy(){var e;this.destroyed=!0,this.controller.abort(),null===(e=this.iframe)||void 0===e||e.remove(),this.iframe=null}}function Bs(e,t={}){var i,n,s,o,r;const a=t.merchantInfo;if(Array.isArray(e))return{allowedPaymentMethods:e,merchantInfo:{merchantId:"",merchantName:null!==(i=null==a?void 0:a.merchantName)&&void 0!==i?i:""}};const l=null!=e?e:{},d=l.merchantInfo;return{apiVersion:l.apiVersion,apiVersionMinor:l.apiVersionMinor,allowedPaymentMethods:null!==(n=l.allowedPaymentMethods)&&void 0!==n?n:[],merchantInfo:{merchantId:null!==(s=null==d?void 0:d.merchantId)&&void 0!==s?s:"",merchantName:null!==(r=null!==(o=null==a?void 0:a.merchantName)&&void 0!==o?o:null==d?void 0:d.merchantName)&&void 0!==r?r:""},emailRequired:l.emailRequired,shippingAddressRequired:l.shippingAddressRequired,shippingAddressParameters:l.shippingAddressParameters,existingPaymentMethodRequired:l.existingPaymentMethodRequired}}let Vs=class t extends Nn{static isGooglePayAvailable(t){return i(this,arguments,void 0,function*(t,i=e.PayrailsEnvironment.TEST,n){const s=new js(i);try{return yield s.isGooglePayAvailable(Bs(t,{merchantInfo:n}))}finally{s.destroy()}})}constructor(e){var i;super("div",Object.assign(Object.assign({},e),{id:`payrails-google-pay-button-${re()}`,dataTestId:"payrails-google-pay-button"})),this.options=e,this.isProcessing=!1,this.frame=null,this.paymentExecutor=new _n(null===(i=this.options)||void 0===i?void 0:i.returnInfo),t.isGooglePayAvailable(W.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"===Q().type?uo.TOKENIZE:uo.AUTHORIZE}onLoadPaymentData(e){return i(this,void 0,void 0,function*(){(yield xi(this.action,this.options.events))?(this.action===uo.TOKENIZE?yield this.doTokenize(e):yield this.doAuthorizePayment(e),this.isProcessing=!1):this.isProcessing=!1})}doTokenize(t){return i(this,void 0,void 0,function*(){const i=Q(),n=W.createInstrumentLink,s=i.token;if(!n)return this.isProcessing=!1,void _o(uo.TOKENIZE,this.options.events);let o;try{o=JSON.stringify(t)}catch(e){return this.isProcessing=!1,void _o(uo.TOKENIZE,this.options.events,e)}const r={holderReference:i.holderReference,paymentMethod:e.PAYMENT_METHOD_CODES.GOOGLE_PAY,storeInstrument:this.shouldStoreInstrument,data:{paymentToken:o}};try{const e=yield me({url:n,token:s,body:r});return e.ok?(this.isProcessing=!1,po(uo.TOKENIZE,this.options.events,e.res),e.res):(this.isProcessing=!1,void _o(uo.TOKENIZE,this.options.events))}catch(e){return this.isProcessing=!1,void _o(uo.TOKENIZE,this.options.events,e)}})}doAuthorizePayment(t){return i(this,void 0,void 0,function*(){var i,n,s,o,r,a;const l={paymentToken:JSON.stringify(t)},d=[{paymentMethodCode:e.PAYMENT_METHOD_CODES.GOOGLE_PAY,integrationType:"api",paymentInstrumentData:l,amount:Q().amount,storeInstrument:this.shouldStoreInstrument}],c=yield this.paymentExecutor.pay(d);if("authorizePending"===(null===(i=null==c?void 0:c.finalState)||void 0===i?void 0:i.code)){const t=new Ys(Object.assign(Object.assign({},this.options),{paymentMethodCode:e.PAYMENT_METHOD_CODES.GOOGLE_PAY}),this.paymentExecutor);yield t.handle3ds(c)}else"authorizeSuccessful"===(null===(n=null==c?void 0:c.finalState)||void 0===n?void 0:n.code)?po(uo.AUTHORIZE,this.options.events):_o(uo.AUTHORIZE,this.options.events,{code:e.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:(null===(a=null===(r=null===(o=null===(s=c.finalState)||void 0===s?void 0:s.errors)||void 0===o?void 0:o[0])||void 0===r?void 0:r.reason)||void 0===a?void 0:a.result)||"Authorization Failed"})})}mount(e){this.frame&&this.unmount(),super.mount(e),(()=>{i(this,void 0,void 0,function*(){var e,t,n,s,o,r,a;try{const l=Bs(W.googlePayConfig,{merchantInfo:this.options.merchantInfo}),d=new js(this.options.environment);if(this.frame=d,!(yield d.isGooglePayAvailable(l)))return d.destroy(),void(this.frame=null);yield d.mountButton({target:this.element,environment:null!==(e=this.options.environment)&&void 0!==e?e:"TEST",googlePayConfig:l,amount:Q().amount,countryCode:null===(o=null===(s=null===(n=null===(t=W.meta)||void 0===t?void 0:t.order)||void 0===n?void 0:n.billingAddress)||void 0===s?void 0:s.country)||void 0===o?void 0:o.code,buttonStyle:null!==(r=this.options.styles)&&void 0!==r?r:{},onButtonClicked:()=>i(this,void 0,void 0,function*(){return Boolean(yield vo(this.action,this.options.events))}),onCollect:e=>{if(!this.isProcessing)return this.isProcessing=!0,this.onLoadPaymentData(e)},onCollectError:e=>{this.isProcessing=!1,_o(this.action,this.options.events,e)}}),null===(a=this.storeInstrumentCheckbox)||void 0===a||a.mount(this.selector)}catch(e){}})})()}unmount(){var e,t;null===(e=this.storeInstrumentCheckbox)||void 0===e||e.unmount(),null===(t=this.frame)||void 0===t||t.unmount(),this.frame=null,super.unmount()}};const Gs=ks("gpayIframeRollout");class Xs extends Nn{static isGooglePayAvailable(...e){return i(this,void 0,void 0,function*(){return Gs()?Vs.isGooglePayAvailable(...e):xs.isGooglePayAvailable(...e)})}constructor(e){return super("div",e),Gs()?new Vs(e):new xs(e)}}class zs extends cs{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?ds("googlepay"):void 0,e.events,e.styles),this.loadElementId="google-pay-dropin-load-element",this.component=new Xs(Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},e.events),{onGooglePayAvailable:()=>{this.mountAfterAvailable()}}),returnInfo:e.returnInfo}))}}const Hs="Pay by bank with Al Tareq";var $s;!function(e){e.SUCCESS="success",e.ERROR="error",e.CANCELLED="cancelled"}($s||($s={}));class qs extends Bi{constructor(e){var t,i,n,s,o,r,a;super("button",{id:e.id||"payrails-lean-button",className:"payrails-lean-button",styles:null!==(n=null===(i=null===(t=e.styles)||void 0===t?void 0:t.button)||void 0===i?void 0:i.base)&&void 0!==n?n:{}}),this.isLoading=!1,this.handleClick=()=>{this.onClick()},this.handleMouseEnter=()=>{var e,t;(null===(t=null===(e=this.options.styles)||void 0===e?void 0:e.button)||void 0===t?void 0:t.hover)&&this.setStyles(this.options.styles.button.hover)},this.handleMouseLeave=()=>{var e,t;(null===(t=null===(e=this.options.styles)||void 0===e?void 0:e.button)||void 0===t?void 0:t.hover)&&this.removeStyles(this.options.styles.button.hover)},this.handleSessionExpired=()=>{this.triggerLoading(!1)},this.options=e,this.paymentExecutor=new _n(null===(s=this.options)||void 0===s?void 0:s.returnInfo),this.element.innerText=(null===(o=e.translations)||void 0===o?void 0:o.label)||Hs,this.setStyles((null===(a=null===(r=this.options.styles)||void 0===r?void 0:r.button)||void 0===a?void 0:a.base)||{})}mount(e){this.unmount(),super.mount(e),this.bindEvents(),qs.preloadLeanSDK()}unmount(){this.unbindEvents(),super.unmount()}static initializeLeanSDK(){return window.Lean||qs.leanSdkClient||(qs.leanSdkClient=Ln.load(An.Lean)),qs.leanSdkClient}static preloadLeanSDK(){const e=qs.initializeLeanSDK();null==e||e.catch(()=>{qs.leanSdkClient===e&&(qs.leanSdkClient=null)})}static getLeanSDK(){return i(this,void 0,void 0,function*(){qs.initializeLeanSDK();try{yield qs.leanSdkClient}catch(e){throw qs.leanSdkClient=null,e}const e=window.Lean;if(!e)throw qs.leanSdkClient=null,Ln.invalidate(An.Lean),new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_UNKNOWN_ERROR,{description:"Lean SDK is not available"});return e})}static resetLeanSDK(){qs.leanSdkClient=null}bindEvents(){this.element.addEventListener("click",this.handleClick),this.element.addEventListener("mouseenter",this.handleMouseEnter),this.element.addEventListener("mouseleave",this.handleMouseLeave),this.eventBus.on("PAYRAILS_CLIENT_SESSION_EXPIRED",this.handleSessionExpired)}unbindEvents(){var e,t;this.element.removeEventListener("click",this.handleClick),this.element.removeEventListener("mouseenter",this.handleMouseEnter),this.element.removeEventListener("mouseleave",this.handleMouseLeave),null===(t=(e=this.eventBus).off)||void 0===t||t.call(e,"PAYRAILS_CLIENT_SESSION_EXPIRED",this.handleSessionExpired)}setStyles(e){var t,i;const n=Object.assign(Object.assign({},null===(i=null===(t=this.options.styles)||void 0===t?void 0:t.button)||void 0===i?void 0:i.base),e);Object.keys(n).forEach(e=>{this.element.style[e]=n[e]})}removeStyles(e){var t,i;const n=Object.keys((null===(i=null===(t=this.options.styles)||void 0===t?void 0:t.button)||void 0===i?void 0:i.base)||{});Object.keys(e).forEach(e=>{var t,i,s;n.includes(e)?this.element.style[e]=null===(s=null===(i=null===(t=this.options.styles)||void 0===t?void 0:t.button)||void 0===i?void 0:i.base)||void 0===s?void 0:s[e]:this.element.style[e]=""})}triggerLoading(e){var t,i,n,s,o;this.isLoading=e,e?(this.element.innerHTML=this.renderLoadingMarkup(),(null===(i=null===(t=this.options.styles)||void 0===t?void 0:t.button)||void 0===i?void 0:i.loading)&&this.setStyles(this.options.styles.button.loading)):(this.element.innerText=(null===(n=this.options.translations)||void 0===n?void 0:n.label)||Hs,this.removeStyles((null===(o=null===(s=this.options.styles)||void 0===s?void 0:s.button)||void 0===o?void 0:o.loading)||{}))}renderLoadingMarkup(){return['<div class="dot-flashing-container">',' <div class="dot-flashing"></div>',' <span class="dot-flashing-text" aria-hidden="true">Loading</span>',"</div>"].join("")}getConfirmActionParameters(e){var t,i,n;const s=null===(n=null===(i=null===(t=e.response)||void 0===t?void 0:t.links)||void 0===i?void 0:i.confirm)||void 0===n?void 0:n.action;if(!((null==s?void 0:s.paymentId)&&(null==s?void 0:s.appToken)&&(null==s?void 0:s.sdkToken)&&(null==s?void 0:s.successUrl)&&(null==s?void 0:s.failureUrl)))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_UNKNOWN_ERROR,{description:"Lean payment parameters are missing from authorize polling response."});return{appToken:s.appToken,paymentId:s.paymentId,sdkToken:s.sdkToken,successUrl:s.successUrl,failureUrl:s.failureUrl,sandbox:s.sandbox}}startLeanCheckout(e,t){return i(this,void 0,void 0,function*(){return new Promise(i=>{var n;const s=this.toLeanCustomizationPayload(null===(n=this.options.styles)||void 0===n?void 0:n.dialog);e.checkout(Object.assign(Object.assign({app_token:t.appToken,access_token:t.sdkToken,payment_intent_id:t.paymentId,success_redirect_url:t.successUrl,fail_redirect_url:t.failureUrl},void 0!==t.sandbox?{sandbox:t.sandbox}:{}),{customization:s,callback:e=>{try{this.handleLeanCheckoutResponse(e)}finally{this.triggerLoading(!1),i()}}}))})})}handleLeanCheckoutResponse(e){var t;switch(null===(t=null==e?void 0:e.status)||void 0===t?void 0:t.toLowerCase()){case $s.SUCCESS:return void po(uo.AUTHORIZE,this.options.events,e);case $s.ERROR:case $s.CANCELLED:return this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}),void _o(uo.AUTHORIZE,this.options.events,e)}}toLeanCustomizationPayload(e){if(!e)return;const{themeColor:t,buttonTextColor:i,buttonBorderRadius:n,linkColor:s,overlayColor:o}=e;return{theme_color:t,button_text_color:i,button_border_radius:n,link_color:s,overlay_color:o}}onClick(){return i(this,void 0,void 0,function*(){var t;if(!this.isLoading)try{if(this.triggerLoading(!0),!(yield vo(uo.AUTHORIZE,null!==(t=this.options.events)&&void 0!==t?t:{})))return void this.triggerLoading(!1);const i=yield qs.getLeanSDK(),n=[{paymentMethodCode:e.PAYMENT_METHOD_CODES.LEAN,integrationType:"api",amount:Q().amount,paymentInstrumentData:{},storeInstrument:!1}],s=yield this.paymentExecutor.pay(n),o=this.getConfirmActionParameters(s);yield this.startLeanCheckout(i,o),this.triggerLoading(!1)}catch(e){this.triggerLoading(!1),this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}),_o(uo.AUTHORIZE,this.options.events,e)}})}}qs.leanSdkClient=null;class Ws extends Zn{constructor(e,t){var i;super("lean-dropin",(null===(i=e.translations)||void 0===i?void 0:i.label)||"Pay by bank with Al Tareq",void 0,e.events,e.elementStyles),this.returnInfo=t,this.component=new qs(Object.assign(Object.assign({},e),{id:e.id||"payrails-lean-button-dropin",styles:e.styles,events:Object.assign({},e.events),returnInfo:this.returnInfo}))}}class Ks extends Nn{constructor(t){var n;Ks.instance&&(Ks.instance=void 0);const s="express"===(null===(n=null==W?void 0:W.paypalConfig)||void 0===n?void 0:n.integrationMode),o=!s&&(null==t?void 0:t.showStoreInstrumentCheckbox),r=s?"unchecked":null==t?void 0:t.defaultStoreInstrumentState,a=Object.assign(Object.assign({},t),{showStoreInstrumentCheckbox:o,defaultStoreInstrumentState:r,id:"payrails-paypal-button",events:Object.assign(Object.assign({},null==t?void 0:t.events),{onSaveInstrumentCheckboxChanged:e=>i(this,void 0,void 0,function*(){var i,n,s;null===(n=null===(i=null==t?void 0:t.events)||void 0===i?void 0:i.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(i,e),null===(s=this.button)||void 0===s||s.close(),this.debouncedRender()})})});super("div",a),this.options=t,this.renderDebounceTimeout=null,this.currentAbortController=null,this.isRendering=!1,this.buttonWrapperId="payrails-paypal-button-wrapper",this.checkboxWrapperId="payrails-paypal-checkbox-wrapper",this.createOneTimeOrder=()=>i(this,void 0,void 0,function*(){var t,i,n,s,o;const r=[{paymentMethodCode:e.PAYMENT_METHOD_CODES.PAYPAL,integrationType:"api",amount:Q().amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!1}],a=yield this.paymentExecutor.pay(r),l=null===(n=null===(i=null===(t=a.response.links.confirm)||void 0===t?void 0:t.action)||void 0===i?void 0:i.parameters)||void 0===n?void 0:n.orderId;if(!l)throw _o(uo.AUTHORIZE,null===(s=this.options)||void 0===s?void 0:s.events),new Zs("No order id returned");return this.confirmLink=null===(o=a.response.links.confirm)||void 0===o?void 0:o.href,l}),this.loadPaypal().catch(()=>{}),this.element.innerHTML=`<div id="${this.buttonWrapperId}"></div><div id="${this.checkboxWrapperId}"></div>`,this.paymentExecutor=new _n}loadPaypal(){return i(this,void 0,void 0,function*(){const e=yield Ln.load(An.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(()=>i(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(){var e,t;const i=this.shouldStoreInstrument?"tokenize":"Instant"===W.paypalConfig.captureMode?"capture":"authorize";return Object.assign({clientId:W.paypalConfig.clientId,intent:i,currency:Q().amount.currency,vault:this.shouldStoreInstrument},(null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.locale)&&{locale:(n=Cn(this.options.styles.locale),gn(n).replace("-","_"))});var n}createPaypalButton(e){return i(this,void 0,void 0,function*(){var t,i,n;if(!e.Buttons)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR);const s=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),s})}createPayPalButtonConfig(){return this.shouldStoreInstrument?this.createBillingAgreementConfig():this.createOneTimeOrderConfig()}createBillingAgreementConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{onApprove:this.approvePayment.bind(this),createBillingAgreement:()=>i(this,void 0,void 0,function*(){var t,i,n,s;const o=[{paymentMethodCode:e.PAYMENT_METHOD_CODES.PAYPAL,integrationType:"api",amount:Q().amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!0}],r=yield this.paymentExecutor.pay(o);return this.confirmLink=null===(t=r.response.links.confirm)||void 0===t?void 0:t.href,(null===(s=null===(n=null===(i=r.response.links.confirm)||void 0===i?void 0:i.action)||void 0===n?void 0:n.parameters)||void 0===s?void 0:s.tokenId)||""})})}onCancel(){var e;this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}),_o(uo.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,t,n,s,o,r,a,l,d,c;return{fundingSource:"paypal",style:{color:(null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.color)||"gold",height:(null===(s=null===(n=this.options)||void 0===n?void 0:n.styles)||void 0===s?void 0:s.height)||40,label:(null===(r=null===(o=this.options)||void 0===o?void 0:o.styles)||void 0===r?void 0:r.label)||"paypal",shape:(null===(l=null===(a=this.options)||void 0===a?void 0:a.styles)||void 0===l?void 0:l.shape)||"rect",tagline:(null===(c=null===(d=this.options)||void 0===d?void 0:d.styles)||void 0===c?void 0:c.tagline)||!1,disableMaxWidth:!0},onError:e=>{var t;this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}),_o(uo.AUTHORIZE,null===(t=this.options)||void 0===t?void 0:t.events,e)},onClick:(e,t)=>i(this,void 0,void 0,function*(){var e;return(yield vo(uo.AUTHORIZE,null===(e=this.options)||void 0===e?void 0:e.events))?t.resolve():t.reject()}),onCancel:this.onCancel.bind(this),onShippingAddressChange:(e,t)=>i(this,void 0,void 0,function*(){var i;let n;if(e.shippingAddress&&(n={deliveryAddress:{city:e.shippingAddress.city,postalCode:e.shippingAddress.postalCode,state:e.shippingAddress.state,country:{code:e.shippingAddress.countryCode}}}),!(yield Fi(null===(i=this.options)||void 0===i?void 0:i.events,n)))return t.reject()})}}approvePayment(t){return i(this,void 0,void 0,function*(){var i,n,s,o,r,a,l,d,c;if(!this.confirmLink)throw _o(uo.AUTHORIZE,null===(i=this.options)||void 0===i?void 0:i.events),new Zs("No confirm link");const u={};if(this.shouldStoreInstrument&&t.billingToken&&(u.tokenId=t.billingToken),this.fraudNetGuid&&(u.riskSessionCorrelationId=this.fraudNetGuid),!(yield xi(uo.AUTHORIZE,null===(n=this.options)||void 0===n?void 0:n.events)))throw new Zs("Authorization request start validation failed");const h=yield this.paymentExecutor.confirm(this.confirmLink,u);"authorizeSuccessful"===(null===(s=h.finalState)||void 0===s?void 0:s.code)?po(uo.AUTHORIZE,null===(o=this.options)||void 0===o?void 0:o.events):_o(uo.AUTHORIZE,null===(r=this.options)||void 0===r?void 0:r.events,{code:e.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:(null===(c=null===(d=null===(l=null===(a=h.finalState)||void 0===a?void 0:a.errors)||void 0===l?void 0:l[0])||void 0===d?void 0:d.reason)||void 0===c?void 0:c.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){Ks.instance||(super.mount(e),Ks.instance=this,(()=>{i(this,void 0,void 0,function*(){yield this.debouncedRender()})})())}renderButton(){return i(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 Js("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,Ks.instance=void 0,super.unmount()}}class Zs extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION,{description:`PaypalOrderError: ${e}`,cause:t})}}class Js extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT,{description:`PaypalButtonError: ${e}`,cause:t})}}class Qs extends cs{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)?ds("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 Ks(Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},null==e?void 0:e.events),{onPaypalAvailable:()=>{this.mountAfterAvailable()}})}))}}class eo extends Bi{constructor(t,i,n){var s,o,r,a,l,d;super("fieldset",{id:"payrails-dropin-component"}),this.collectContainer=t,this.clientConfig=i,this.dropinConfig=n,this.billingValidationBlocked=!1,this.applyStyles(),dn.reset();const c=null===(s=Q().morData)||void 0===s?void 0:s.billingLines;(null==c?void 0:c.form)&&(this.billingAddressForm=new dn({schema:c.form,prefill:c,styles:null===(o=this.dropinConfig.styles)||void 0===o?void 0:o.billingAddressForm,translations:null===(r=this.dropinConfig.translations)||void 0===r?void 0:r.billingAddressForm})),void 0!==(null===(l=null===(a=this.dropinConfig.paymentMethodsConfiguration)||void 0===a?void 0:a.cards)||void 0===l?void 0:l.showExistingCards)&&console.warn("The `showExistingCards` option is deprecated and will be removed in a future version. Please use `showStoredInstruments` instead.");const u=new Map;W.storedDropinInstruments.forEach(e=>{if(this.isStoredInstrumentEnabled(e.paymentMethod)){this.cardPaymentButton=this.createCardPaymentButton();const t=this.createStoredInstrumentElement(e);t&&u.set(t.identifier,t)}});const h={[e.PAYMENT_METHOD_CODES.CARD]:this.createCreditCardButton.bind(this),[e.PAYMENT_METHOD_CODES.PAYPAL]:this.createPayPalButton.bind(this),[e.PAYMENT_METHOD_CODES.GOOGLE_PAY]:this.createGooglePayButton.bind(this),[e.PAYMENT_METHOD_CODES.APPLE_PAY]:this.createApplePayButton.bind(this),[e.PAYMENT_METHOD_CODES.LEAN]:this.createLeanButton.bind(this)};W.availablePaymentMethods.forEach(e=>{const t=e.paymentMethodCode;if(t&&h[t]){const i=(0,h[t])(W.getPaymentMethodConfig(e));u.set(i.identifier,i)}else if(this.isHppIntegration(e)&&t){const t=this.createHppIntegrationElement(e);u.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)||"";u.forEach(e=>{e.deactivate()}),null===(i=u.get(n))||void 0===i||i.activate()}),1===this.totalPaymentOptions&&this.element.classList.add("payrails-dropin-component--single"),this.billingAddressForm&&this.subElements.push(this.billingAddressForm),this.subElements.push(...Array.from(u.values())),this.loadingScreen=new rs({styles:null===(d=this.dropinConfig.styles)||void 0===d?void 0:d.loadingScreen})}get returnInfo(){return this.dropinConfig.returnInfo||this.clientConfig.returnInfo}isHppIntegration(t){var i;return t.paymentMethodCode===e.PAYMENT_METHOD_CODES.GENERIC_REDIRECT||(null===(i=t.clientConfig)||void 0===i?void 0:i.flow)===K.REDIRECT}createStoredInstrumentElement(t){var i;let n;if(this.cardPaymentButton=this.createCardPaymentButton(),t.paymentMethod!==e.PAYMENT_METHOD_CODES.BANK_ACCOUNT)return t.paymentMethod===e.PAYMENT_METHOD_CODES.CARD&&W.isPaymentInstallmentsEnabled(t.paymentMethod)&&(n=this.createInstallmentsDropdown(t)),new es(t,this.cardPaymentButton,e=>{var t,i;if(this.cardPaymentButton){this.cardPaymentButton.selectedInstrument=e;const n=W.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===(i=this.dropinConfig.styles)||void 0===i?void 0:i.element,n)}createInstallmentsDropdown(e){var t,i,n;const s=this.getInstallmentOptionsForInstrument(e);return new jn("span",{installmentConfig:{installmentCurrency:Q().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=W.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 es&&t.updateInstallmentConfig(e)})}createHppIntegrationElement(e){var t,i,n,s,a,l,d,c,u,h,p,_;const E=e.paymentMethodCode;if(!E){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED,{description:`Payment method code is missing for payment method - ${JSON.stringify(e)}`});throw r.PayrailsLogger.error(t.message,{error:t}),t}return new ws({paymentMethod:e,config:Object.assign(Object.assign({},null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t[E]),{showPaymentMethodLogo:null!==(l=null!==(s=null===(n=null===(i=this.dropinConfig.paymentMethodsConfiguration)||void 0===i?void 0:i[E])||void 0===n?void 0:n.showPaymentMethodLogo)&&void 0!==s?s: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===(p=null===(h=null===(u=this.dropinConfig)||void 0===u?void 0:u.styles)||void 0===h?void 0:h[E])||void 0===p?void 0:p.button},translations:null===(_=this.dropinConfig.translations)||void 0===_?void 0:_[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 W.availablePaymentMethods.length+W.storedDropinInstruments.length}createCreditCardButton(e){var t,i,n,s,o,r,a;return this.creditCard=new hs(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(t){var i,n,s,o,r,a,l,d;return this.googlePay=new zs(Object.assign({environment:this.clientConfig.environment||e.PayrailsEnvironment.TEST,events:Object.assign(Object.assign({},this.getElementEvents()),{onPaymentOptionVisibilityChange:()=>{var e,i;null===(i=null===(e=this.dropinConfig.events)||void 0===e?void 0:e.onPaymentOptionSelected)||void 0===i||i.call(e,{paymentMethod:t})}}),redirectFor3DS:this.clientConfig.redirectFor3DS,showPaymentMethodLogo:null!==(r=null!==(s=null===(n=null===(i=this.dropinConfig.paymentMethodsConfiguration)||void 0===i?void 0:i.googlePay)||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,styles:Object.assign(Object.assign({},null===(a=this.dropinConfig.styles)||void 0===a?void 0:a.googlePayButton),null===(l=this.dropinConfig.styles)||void 0===l?void 0:l.element),returnInfo:this.returnInfo},null===(d=this.dropinConfig.paymentMethodsConfiguration)||void 0===d?void 0:d.googlePay)),this.googlePay}createPayPalButton(e){var t,i,n,s,o,r,a,l;return this.paypal=new Qs(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}createLeanButton(e){var t,i,n,s;return this.lean=new Ws(Object.assign(Object.assign({paymentMethod:e},null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.lean),{styles:null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.leanButton,elementStyles:null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.element,translations:null===(s=this.dropinConfig.translations)||void 0===s?void 0:s.leanButton,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),this.lean}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),h=Boolean(null==l?void 0:l.showSingleExpiryDateField),p=(null==l?void 0:l.layout)||[];this.cardForm=new Wn(this.collectContainer,{showStoreInstrumentCheckbox:d,showCardHolderName:c,showSingleExpiryDateField:h,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:p,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 t,n,s,o,r,a,l,d,c;return this.applePay=new us(Object.assign(Object.assign({events:Object.assign(Object.assign({},this.getElementEvents()),{onAuthorizeSuccess:e=>{var t;e&&("authorizeSuccessful"===(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code)?this.onAuthorizeSuccess():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=>i(this,void 0,void 0,function*(){var t,i,n;return!!(yield this.validateBillingAddress())&&(!(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===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.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 yo({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;dn.reset(),null===(e=this.loadingScreen)||void 0===e||e.unmount(),this.subElements.forEach(e=>e.unmount()),new os({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()}validateBillingAddress(){return i(this,void 0,void 0,function*(){if(!this.billingAddressForm)return!0;try{return yield this.billingAddressForm.collect(),!0}catch(e){return this.billingValidationBlocked=!0,!1}})}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{const e=this.subElements.find(e=>e instanceof Zn);null==e||e.activate()}catch(e){r.PayrailsLogger.error("Error while auto-activating the first payment option",{error:new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING,{cause:e})})}},0)},onPaymentButtonClicked:e=>i(this,void 0,void 0,function*(){var t,i,n,s;if(!(yield this.validateBillingAddress()))return!1;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;dn.reset(),null===(e=this.loadingScreen)||void 0===e||e.unmount(),this.subElements.forEach(e=>e.unmount()),new os({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(t){return i(this,void 0,void 0,function*(){var i,n,s,o,r;null===(i=this.loadingScreen)||void 0===i||i.unmount(),this.billingValidationBlocked?this.billingValidationBlocked=!1:((null==t?void 0:t.code)!==e.AuthorizationFailureReasons.USER_CANCELLED&&new ss({translations:{label:this.getErrorMessage(t)},styles:null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.authFailed,configuration:null===(s=this.dropinConfig.configuration)||void 0===s?void 0:s.authFailMsg}).mount(this.selector),null===(r=null===(o=this.dropinConfig.events)||void 0===o?void 0:o.onAuthorizeFailed)||void 0===r||r.call(o,t))})}isStoredInstrumentEnabled(t){var i,n,s,o,r,a;switch(t){case e.PAYMENT_METHOD_CODES.CARD:return!1!==(null===(n=null===(i=this.dropinConfig.paymentMethodsConfiguration)||void 0===i?void 0:i.cards)||void 0===n?void 0:n.showStoredInstruments)&&!1!==(null===(o=null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s.cards)||void 0===o?void 0:o.showExistingCards);case e.PAYMENT_METHOD_CODES.PAYPAL:case e.PAYMENT_METHOD_CODES.GOOGLE_PAY:case e.PAYMENT_METHOD_CODES.APPLE_PAY:return!1!==(null===(a=null===(r=this.dropinConfig.paymentMethodsConfiguration)||void 0===r?void 0:r[t])||void 0===a?void 0:a.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 i(this,void 0,void 0,function*(){var e;return null===(e=this.cardForm)||void 0===e?void 0:e.fetchBinLookup()})}}const to=e=>i(void 0,void 0,void 0,function*(){if(null==e?void 0:e.onSessionExpired)try{const t=yield e.onSessionExpired();if(t)ee(t),(null==e?void 0:e.onClientInitialized)&&e.onClientInitialized(W);else{const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_SESSION_REFRESH_FAILED,{description:"Session refresh failed with no result returned"});r.PayrailsLogger.error(e.message,{error:e})}}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_SESSION_REFRESH_FAILED,{description:"Callback passed to onSessionExpired threw an error",cause:e});r.PayrailsLogger.error(t.message,{error:t})}}),io=ks("secureFieldsRollout"),no=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;class so{static setSelectedInstrument(e){if(!e||!e.id.match(no))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Instrument is not valid"});this._selectedInstrument=e}static getSelectedInstrument(){return this._selectedInstrument}static clearSelectedInstrument(){this._selectedInstrument=null}}so._selectedInstrument=null;const oo={deleteInstrument:{linkKey:"instrumentDelete",method:se.DELETE,createRequest:e=>{var t,i;if(!e.resourceId)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_UNKNOWN_ERROR);const n=null===(i=null===(t=Q().links)||void 0===t?void 0:t.instrumentDelete)||void 0===i?void 0:i.href;if(!n)throw new o.PayrailsError(o.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:se.PATCH,createRequest:e=>{var t,i;const n=null===(i=null===(t=Q().links)||void 0===t?void 0:t.instrumentUpdate)||void 0===i?void 0:i.href;if(!n)throw new o.PayrailsError(o.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:se.POST,createRequest:()=>{const e=W.payoutLink;if(!e)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND);const t=so.getSelectedInstrument();if(!t)throw new o.PayrailsError(o.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:Q().amount,paymentMethodCode:t.paymentMethod,paymentInstrumentId:t.id}];return{url:e,body:{amount:Q().amount,payoutComposition:i}}},onSuccess:e=>i(void 0,void 0,void 0,function*(){const t=new _n;return yield t.pollForAuthorizationResult(e.links.execution)}),requestType:{},responseType:{}}},ro={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:{}}},ao=(e,t)=>{try{const i=Q(),n=ro[e];if(!n)return r.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){var t;try{if(!e)return r.PayrailsLogger.error("Payment method code is required"),null;const i=W.availablePaymentMethods;return"all"===e?i:"redirect"===e?i.filter(e=>{var t;return(null===(t=e.clientConfig)||void 0===t?void 0:t.flow)===K.REDIRECT}):null!==(t=i.find(({paymentMethodCode:t})=>t===e))&&void 0!==t?t:null}catch(t){return r.PayrailsLogger.error(`Error getting config for payment method: ${e}`,{error:t}),null}}(e):(r.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 W.getStoredInstrumentForPaymentMethod(e)}(e):(r.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 r.PayrailsLogger.error("Error querying SDK Configuration",{error:e}),null}},lo=(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/c344ea7/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 so{static init(t,i){var n,s,a,l,d,c,u,h,p,_,E,m;try{const o="5.47.0",v="web-sdk";no({version:o,packageName:v}),hs().reset(),r.PayrailsLogger.init({enabled:(null===(n=null==i?void 0:i.telemetry)||void 0===n?void 0:n.enabled)||!0,logLevel:(null===(s=null==i?void 0:i.telemetry)||void 0===s?void 0:s.logLevel)||"error",environment:(null==i?void 0:i.environment)||"TEST",sdk:{name:v,version:o}}),Ee(t);const y=_e();r.PayrailsLogger.setState({payrails:{execution_id:null===(a=null==y?void 0:y.execution)||void 0===a?void 0:a.id,holder_reference:null==y?void 0:y.holderReference,vault_provider:null===(l=null==y?void 0:y.vaultConfiguration)||void 0===l?void 0:l.vaultType,merchant_reference:null===(d=null==y?void 0:y.execution)||void 0===d?void 0:d.merchantReference,workflow:{code:(null===(u=null===(c=null==y?void 0:y.execution)||void 0===c?void 0:c.workflow)||void 0===u?void 0:u.code)||"",version:(null===(p=null===(h=null==y?void 0:y.execution)||void 0===h?void 0:h.workflow)||void 0===p?void 0:p.version)||0}}});const{vaultConfiguration:{vaultId:I,vaultUrl:f,token:A},execution:L}=y;null===(_=y.vaultConfiguration)||void 0===_||_.vaultId;const g=ki.init({vaultID:I,vaultURL:f,getBearerToken:()=>A?Promise.resolve(A):Promise.resolve(""),options:{initResponse:t,deserializedData:Object.assign({},y),logLevel:(null===(m=null===(E=null==i?void 0:i.telemetry)||void 0===E?void 0:E.logLevel)||void 0===m?void 0:m.toUpperCase())||"ERROR"}});return L&&(ce.setResponse(L),ce.isPaymentMethodAvailable(e.PAYMENT_METHOD_CODES.CARD)&&fn.preloadCardForm()),new so(g,i)}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED,{cause:e});throw r.PayrailsLogger.error(t.message,{error:t}),t}}update(t){var i,n,s,o;void 0!==t.value&&void 0!==t.currency&&(_e().amount={value:t.value,currency:t.currency}),t.meta&&ce.updateMeta(t.meta.key,t.meta.value);const r=t.installmentConfig;if(!r||0===Object.keys(r).length)return;const a=ce.getPaymentInstallmentOptions(e.PAYMENT_METHOD_CODES.CARD)||{},l=null===(i=r.installmentCountry)||void 0===i?void 0:i.toString();if(l&&Object.prototype.hasOwnProperty.call(r,"installmentOptions")){const e=Array.isArray(r.installmentOptions)?r.installmentOptions:[],t=Object.assign(Object.assign({},a),{[l]:e});ce.updateInstallmentOptions(t)}const d={};Object.prototype.hasOwnProperty.call(r,"defaultInstallment")&&(d.defaultInstallment=null!==(n=r.defaultInstallment)&&void 0!==n?n:null),null===(s=this.__cardForm)||void 0===s||s.updateInstallmentConfig(d),null===(o=this.__dropin)||void 0===o||o.updateInstallmentConfig(d)}collectContainer(e){var t;if("COMPOSABLE"===e.containerType&&!e.layout){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw r.PayrailsLogger.error(e.message,{error:e}),e}return this.__container=me.init(this.vaultClient,Object.assign(Object.assign({},e),{cardTableName:null===(t=_e().vaultConfiguration)||void 0===t?void 0:t.cardTableName})),this.__container}googlePayButton(e){var t;return this.logIntegrationMode("elements"),new js(Object.assign({environment:null===(t=this.options)||void 0===t?void 0:t.environment},e))}isGooglePayAvailable(e){var t;return js.isGooglePayAvailable(ce.googlePayConfig,null===(t=this.options)||void 0===t?void 0:t.environment,e)}applePayButton(e){return this.logIntegrationMode("elements"),new Rn(e)}isApplePayAvailable(){return Rn.isApplePayAvailable()}setState({instrument:e}){e&&Qs.setSelectedInstrument(e)}cardList(e){return this.logIntegrationMode("elements"),this.__cardList||(this.__cardList=new Jn({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 zn(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 $s(this.__container,Object.assign({},this.options||{}),e),this.__dropin}getSavedCreditCards(){return this.logIntegrationMode("elements"),ce.savedCreditCards}getSavedGooglePayAccounts(){return this.logIntegrationMode("elements"),ce.savedGooglePayAccounts}getSavedApplePayAccounts(){return this.logIntegrationMode("elements"),ce.savedApplePayAccounts}query(e,t){return this.logIntegrationMode("headless"),io(e,t)}api(e){return i(this,void 0,void 0,function*(){return this.logIntegrationMode("headless"),(e=>i(void 0,void 0,void 0,function*(){const{operation:t}=e,i=_e(),n=eo[t];try{const t=n.createRequest(e),s=yield Z(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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{cause:e});throw r.PayrailsLogger.error(t.message,{error:t}),t}}))(e)})}getStoredInstruments(){return this.logIntegrationMode("elements"),ce.storedPaymentInstruments}getStoredInstrumentsByPaymentMethod(e){return this.logIntegrationMode("elements"),ce.storedPaymentInstruments.filter(t=>t.paymentMethod===e)}getAvailablePaymentMethods(){return this.logIntegrationMode("elements"),ce.availablePaymentMethods.map(({paymentMethodCode:e})=>e).filter(e=>!!e)}paymentButton(e){var t;return this.logIntegrationMode("elements"),this.__cardPaymentButton||(this.__cardPaymentButton=new po(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 Hs(Object.assign({},e)),this.__paypalButton}leanButton(e){return this.logIntegrationMode("elements"),this.__leanButton=new Xs(e),this.__leanButton}genericRedirectButton(e){return this.logIntegrationMode("elements"),this.__genericRedirectButton=new Ns(e,e.returnInfo),this.__genericRedirectButton}dynamicElement(e){var t;this.logIntegrationMode("elements");const i=ce.getFullPaymentMethodConfig(e.paymentMethod.paymentMethodCode);if(!(null===(t=null==i?void 0:i.clientConfig)||void 0===t?void 0:t.instrumentDataSchema))throw new o.PayrailsError(o.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 sn(e,n),this.__dynamicElementForm}getSavedPaypalAccounts(){return this.logIntegrationMode("elements"),ce.savedPaypalAccounts||[]}logIntegrationMode(e){r.PayrailsLogger.setState({sdk:{integration_mode:e}})}constructor(e,t){var n,s,o;this.vaultClient=e,this.options=t,null===(s=null===(n=null==t?void 0:t.events)||void 0===n?void 0:n.onClientInitialized)||void 0===s||s.call(n,ce),o=this.options||{},Fi=o,ve.getEventBus().on("PAYRAILS_CLIENT_SESSION_EXPIRED",()=>i(this,void 0,void 0,function*(){var e;yield null==Zs?void 0:Zs(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}on(e,t){return hs().on(e,t)}off(e,t){hs().off(e,t)}binLookup(){return i(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 oo,ro;so.preloadCardForm=fn.preloadCardForm,function(e){e.AUTHORIZE="AUTHORIZE",e.TOKENIZE="TOKENIZE"}(oo||(oo={})),e.PayrailsEnvironment=void 0,(ro=e.PayrailsEnvironment||(e.PayrailsEnvironment={})).TEST="TEST",ro.PRODUCTION="PRODUCTION";const ao=(e,t,i)=>{var n;(null==t?void 0:t.onAuthorizeSuccess)&&e===oo.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)},lo=(e,t,i)=>{var n;(null==t?void 0:t.onAuthorizeFailed)&&e===oo.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)},co=(e,t)=>i(void 0,void 0,void 0,function*(){if(!t)return Promise.resolve(!0);t.onAuthorizeRequestStart&&e===oo.AUTHORIZE&&console.warn("onAuthorizeRequestStart is marked as deprecated and will be removed in future releases. Use `onRequestStart` instead.");const i="function"==typeof t.onAuthorizeRequestStart&&e===oo.AUTHORIZE?t.onAuthorizeRequestStart():Promise.resolve(!0),n="function"==typeof t.onRequestStart?t.onRequestStart(e):Promise.resolve(!0);return Promise.all([i,n]).then(e=>e.every(e=>!0===e))}),uo=(e,t,i)=>{var n;(null==t?void 0:t.onAuthorizePending)&&e===oo.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)},ho=(t,n,s)=>i(void 0,void 0,void 0,function*(){try{const r=yield((e,t,n)=>i(void 0,void 0,void 0,function*(){if(!t)return Promise.resolve(!0);t.onPaymentButtonClicked&&console.warn("onPaymentButtonClicked is marked as deprecated and will be removed in future releases. Use `onButtonClicked` instead.");const i="function"==typeof t.onPaymentButtonClicked&&e===oo.AUTHORIZE?t.onPaymentButtonClicked(n):Promise.resolve(!0),s="function"==typeof t.onButtonClicked?t.onButtonClicked(e,n):Promise.resolve(!0);return Promise.all([i,s]).then(e=>e.every(e=>!0===e))}))(t,n,s);if(!r){const i=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onButtonClicked resolved to false"});return lo(t,n,{code:e.AuthorizationFailureReasons.VALIDATION_FAILED,message:i.message}),r}}catch(i){const s=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onButtonClicked threw an error",cause:i});return lo(t,n,{code:e.AuthorizationFailureReasons.VALIDATION_FAILED,message:s.message}),!1}return!0});class po extends xi{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 hn(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),lo(oo.AUTHORIZE,this.options.events,e)}onPay(){return i(this,void 0,void 0,function*(){var t,i,n,s,a,l,d,c,u,h,p,_,E,m;let v;if(this.setDisabled(!0),this.triggerLoading(!0),!(null===(t=this.selectedInstrument)||void 0===t?void 0:t.id)){const e=yield null===(i=this.cardForm)||void 0===i?void 0:i.validate();if(v=!!(null==e?void 0:e.isValid),null===(s=null===(n=this.options.events)||void 0===n?void 0:n.onValidate)||void 0===s||s.call(n,{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 ho(oo.AUTHORIZE,this.options.events,{bin:this.bin||""}),!v)return this.setDisabled(!1),void this.triggerLoading(!1);try{let t=[{paymentMethodCode:e.PAYMENT_METHOD_CODES.CARD,integrationType:"api",amount:_e().amount,storeInstrument:!1}];if(null===(a=this.selectedInstrument)||void 0===a?void 0:a.id)t[0].paymentInstrumentId=null===(l=this.selectedInstrument)||void 0===l?void 0:l.id,t[0].paymentMethodCode=null===(d=this.selectedInstrument)||void 0===d?void 0:d.paymentMethod,this.paymentInstallmentElement&&(null===(c=this.paymentInstallmentElement)||void 0===c?void 0:c.selectedInstallmentValue)&&(t[0].installments={count:null===(u=this.paymentInstallmentElement)||void 0===u?void 0:u.selectedInstallmentValue});else{if(!this.cardForm){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CARD_FORM_MISSING);throw r.PayrailsLogger.error(e.message,{error:e}),e}t=yield this.constructEncryptedPayment(t)}const i=yield this.paymentExecutor.pay(t);yield this.handleAuthorizationResult(i)}catch(t){let i=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_AUTHENTICATION_ERROR,{cause:t});t instanceof J||[401,403].includes(null===(h=null==t?void 0:t.error)||void 0===h?void 0:h.code)?(null===(_=null===(p=this.options.events)||void 0===p?void 0:p.onPaymentSessionExpired)||void 0===_||_.call(p),i.message="API token is not valid or expired.",r.PayrailsLogger.error(i.message,{error:i}),this.onAuthorizationFailed({code:e.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:i.message})):t.toString().includes("Invalid token")?(null===(m=null===(E=this.options.events)||void 0===E?void 0:E.onPaymentSessionExpired)||void 0===m||m.call(E),i.message="Vault token is not valid or expired.",r.PayrailsLogger.error(i.message,{error:i})):i=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_UNKNOWN_ERROR,{cause:t}),this.onAuthorizationFailed({code:e.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:i.message})}})}constructEncryptedPayment(e){return i(this,void 0,void 0,function*(){if(!this.cardForm)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CARD_FORM_MISSING);const{cardData:t,storeInstrument:i,enrollInstrumentToNetworkOffers:n,selectedInstallment:s,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,s&&(e[0].installments={count:s}),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(t){return i(this,void 0,void 0,function*(){var i,n,s,r,a,l,d;let c;switch(null===(i=null==t?void 0:t.finalState)||void 0===i?void 0:i.code){case"authorizeSuccessful":this.triggerLoading(!1),ao(oo.AUTHORIZE,this.options.events);break;case"authorizePending":if("3ds"===(null===(n=null==t?void 0:t.response)||void 0===n?void 0:n.actionRequired)){const i=new bs(Object.assign(Object.assign({},this.options),{paymentMethodCode:e.PAYMENT_METHOD_CODES.CARD,events:Object.assign(Object.assign({},this.options.events),{onAuthorizeFailed:e=>{this.onAuthorizationFailed(e)}})}),this.paymentExecutor);yield i.handle3ds(t)}else(null===(s=null==t?void 0:t.response)||void 0===s?void 0:s.actionRequired)||(this.triggerLoading(!1),uo(oo.AUTHORIZE,this.options.events));break;default:c=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_ERROR),this.onAuthorizationFailed({code:e.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:(null===(d=null===(l=null===(a=null===(r=t.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)||c.message})}})}}var _o;e.AuthorizationFailureReasons=void 0,(_o=e.AuthorizationFailureReasons||(e.AuthorizationFailureReasons={})).VALIDATION_FAILED="VALIDATION_FAILED",_o.AUTHORIZATION_ERROR="AUTHORIZATION_ERROR",_o.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",_o.UNKNOWN_ERROR="UNKNOWN_ERROR",_o.USER_CANCELLED="USER_CANCELLED",e.Payrails=so,e.PayrailsCollectContainer=me,e.REVOLUT_PAY_DEFAULT_LABEL=As,e.REVOLUT_PAY_DEFAULT_THEME=fs,window.Payrails=so}({});
24
+ class co{static init(t,i){var n,s,a,l,d,c,u,h,p,_,E,m;try{const o="5.47.1",v="web-sdk";lo({version:o,packageName:v}),ms().reset(),r.PayrailsLogger.init({enabled:(null===(n=null==i?void 0:i.telemetry)||void 0===n?void 0:n.enabled)||!0,logLevel:(null===(s=null==i?void 0:i.telemetry)||void 0===s?void 0:s.logLevel)||"error",environment:(null==i?void 0:i.environment)||"TEST",sdk:{name:v,version:o}}),ee(t);const y=Q();r.PayrailsLogger.setState({payrails:{execution_id:null===(a=null==y?void 0:y.execution)||void 0===a?void 0:a.id,holder_reference:null==y?void 0:y.holderReference,vault_provider:null===(l=null==y?void 0:y.vaultConfiguration)||void 0===l?void 0:l.vaultType,merchant_reference:null===(d=null==y?void 0:y.execution)||void 0===d?void 0:d.merchantReference,workflow:{code:(null===(u=null===(c=null==y?void 0:y.execution)||void 0===c?void 0:c.workflow)||void 0===u?void 0:u.code)||"",version:(null===(p=null===(h=null==y?void 0:y.execution)||void 0===h?void 0:h.workflow)||void 0===p?void 0:p.version)||0}}});const{vaultConfiguration:{vaultId:I,vaultUrl:f,token:A},execution:L}=y;null===(_=y.vaultConfiguration)||void 0===_||_.vaultId;const O=Ui.init({vaultID:I,vaultURL:f,getBearerToken:()=>A?Promise.resolve(A):Promise.resolve(""),options:{initResponse:t,deserializedData:Object.assign({},y),logLevel:(null===(m=null===(E=null==i?void 0:i.telemetry)||void 0===E?void 0:E.logLevel)||void 0===m?void 0:m.toUpperCase())||"ERROR"}});return L&&(W.setResponse(L),W.isPaymentMethodAvailable(e.PAYMENT_METHOD_CODES.CARD)&&Ln.preloadCardForm()),new co(O,i)}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED,{cause:e});throw r.PayrailsLogger.error(t.message,{error:t}),t}}update(t){var i,n,s,o;void 0!==t.value&&void 0!==t.currency&&(Q().amount={value:t.value,currency:t.currency}),t.meta&&W.updateMeta(t.meta.key,t.meta.value);const r=t.installmentConfig;if(!r||0===Object.keys(r).length)return;const a=W.getPaymentInstallmentOptions(e.PAYMENT_METHOD_CODES.CARD)||{},l=null===(i=r.installmentCountry)||void 0===i?void 0:i.toString();if(l&&Object.prototype.hasOwnProperty.call(r,"installmentOptions")){const e=Array.isArray(r.installmentOptions)?r.installmentOptions:[],t=Object.assign(Object.assign({},a),{[l]:e});W.updateInstallmentOptions(t)}const d={};Object.prototype.hasOwnProperty.call(r,"defaultInstallment")&&(d.defaultInstallment=null!==(n=r.defaultInstallment)&&void 0!==n?n:null),null===(s=this.__cardForm)||void 0===s||s.updateInstallmentConfig(d),null===(o=this.__dropin)||void 0===o||o.updateInstallmentConfig(d)}collectContainer(e){var t;if(io())return this.__container=bn.init(e),this.__container;if("COMPOSABLE"===e.containerType&&!e.layout){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw r.PayrailsLogger.error(e.message,{error:e}),e}return this.__container=ye.init(this.vaultClient,Object.assign(Object.assign({},e),{cardTableName:null===(t=Q().vaultConfiguration)||void 0===t?void 0:t.cardTableName})),this.__container}googlePayButton(e){var t;return this.logIntegrationMode("elements"),new Xs(Object.assign({environment:null===(t=this.options)||void 0===t?void 0:t.environment},e))}isGooglePayAvailable(e){var t;return Xs.isGooglePayAvailable(W.googlePayConfig,null===(t=this.options)||void 0===t?void 0:t.environment,e)}applePayButton(e){return this.logIntegrationMode("elements"),new Sn(e)}isApplePayAvailable(){return Sn.isApplePayAvailable()}setState({instrument:e}){e&&so.setSelectedInstrument(e)}cardList(e){return this.logIntegrationMode("elements"),this.__cardList||(this.__cardList=new is({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({containerType:"COMPOSABLE",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 Wn(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({containerType:"COMPOSABLE",layout:a,errorTextStyles:{base:{display:"none"}}}),this.__dropin=new eo(this.__container,Object.assign({},this.options||{}),e),this.__dropin}getSavedCreditCards(){return this.logIntegrationMode("elements"),W.savedCreditCards}getSavedGooglePayAccounts(){return this.logIntegrationMode("elements"),W.savedGooglePayAccounts}getSavedApplePayAccounts(){return this.logIntegrationMode("elements"),W.savedApplePayAccounts}query(e,t){return this.logIntegrationMode("headless"),ao(e,t)}api(e){return i(this,void 0,void 0,function*(){return this.logIntegrationMode("headless"),(e=>i(void 0,void 0,void 0,function*(){const{operation:t}=e,i=Q(),n=oo[t];try{const t=n.createRequest(e),s=yield ae(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 o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{cause:e});throw r.PayrailsLogger.error(t.message,{error:t}),t}}))(e)})}getStoredInstruments(){return this.logIntegrationMode("elements"),W.storedPaymentInstruments}getStoredInstrumentsByPaymentMethod(e){return this.logIntegrationMode("elements"),W.storedPaymentInstruments.filter(t=>t.paymentMethod===e)}getAvailablePaymentMethods(){return this.logIntegrationMode("elements"),W.availablePaymentMethods.map(({paymentMethodCode:e})=>e).filter(e=>!!e)}paymentButton(e){var t;return this.logIntegrationMode("elements"),this.__cardPaymentButton||(this.__cardPaymentButton=new yo(e,(null===(t=this.options)||void 0===t?void 0:t.returnInfo)||{})),this.__cardPaymentButton.setDisabled(!1!==e.disabledByDefault),this.__cardForm&&this.__cardPaymentButton.setCardForm(this.__cardForm),this.__cardPaymentButton}paypalButton(e){return this.logIntegrationMode("elements"),this.__paypalButton=new Ks(Object.assign({},e)),this.__paypalButton}leanButton(e){return this.logIntegrationMode("elements"),this.__leanButton=new qs(e),this.__leanButton}genericRedirectButton(e){return this.logIntegrationMode("elements"),this.__genericRedirectButton=new Ds(e,e.returnInfo),this.__genericRedirectButton}dynamicElement(e){var t;this.logIntegrationMode("elements");const i=W.getFullPaymentMethodConfig(e.paymentMethod.paymentMethodCode);if(!(null===(t=null==i?void 0:i.clientConfig)||void 0===t?void 0:t.instrumentDataSchema))throw new o.PayrailsError(o.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 rn(e,n),this.__dynamicElementForm}getSavedPaypalAccounts(){return this.logIntegrationMode("elements"),W.savedPaypalAccounts||[]}logIntegrationMode(e){r.PayrailsLogger.setState({sdk:{integration_mode:e}})}constructor(e,t){var n,s,o;this.vaultClient=e,this.options=t,null===(s=null===(n=null==t?void 0:t.events)||void 0===n?void 0:n.onClientInitialized)||void 0===s||s.call(n,W),o=this.options||{},ji=o,Ie.getEventBus().on("PAYRAILS_CLIENT_SESSION_EXPIRED",()=>i(this,void 0,void 0,function*(){var e;yield null==to?void 0:to(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}on(e,t){return ms().on(e,t)}off(e,t){ms().off(e,t)}binLookup(){return i(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 uo,ho;co.preloadCardForm=Ln.preloadCardForm,function(e){e.AUTHORIZE="AUTHORIZE",e.TOKENIZE="TOKENIZE"}(uo||(uo={})),e.PayrailsEnvironment=void 0,(ho=e.PayrailsEnvironment||(e.PayrailsEnvironment={})).TEST="TEST",ho.PRODUCTION="PRODUCTION";const po=(e,t,i)=>{var n;(null==t?void 0:t.onAuthorizeSuccess)&&e===uo.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)},_o=(e,t,i)=>{var n;(null==t?void 0:t.onAuthorizeFailed)&&e===uo.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)},Eo=(e,t)=>i(void 0,void 0,void 0,function*(){if(!t)return Promise.resolve(!0);t.onAuthorizeRequestStart&&e===uo.AUTHORIZE&&console.warn("onAuthorizeRequestStart is marked as deprecated and will be removed in future releases. Use `onRequestStart` instead.");const i="function"==typeof t.onAuthorizeRequestStart&&e===uo.AUTHORIZE?t.onAuthorizeRequestStart():Promise.resolve(!0),n="function"==typeof t.onRequestStart?t.onRequestStart(e):Promise.resolve(!0);return Promise.all([i,n]).then(e=>e.every(e=>!0===e))}),mo=(e,t,i)=>{var n;(null==t?void 0:t.onAuthorizePending)&&e===uo.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)},vo=(t,n,s)=>i(void 0,void 0,void 0,function*(){try{const r=yield((e,t,n)=>i(void 0,void 0,void 0,function*(){if(!t)return Promise.resolve(!0);t.onPaymentButtonClicked&&console.warn("onPaymentButtonClicked is marked as deprecated and will be removed in future releases. Use `onButtonClicked` instead.");const i="function"==typeof t.onPaymentButtonClicked&&e===uo.AUTHORIZE?t.onPaymentButtonClicked(n):Promise.resolve(!0),s="function"==typeof t.onButtonClicked?t.onButtonClicked(e,n):Promise.resolve(!0);return Promise.all([i,s]).then(e=>e.every(e=>!0===e))}))(t,n,s);if(!r){const i=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onButtonClicked resolved to false"});return _o(t,n,{code:e.AuthorizationFailureReasons.VALIDATION_FAILED,message:i.message}),r}}catch(i){const s=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onButtonClicked threw an error",cause:i});return _o(t,n,{code:e.AuthorizationFailureReasons.VALIDATION_FAILED,message:s.message}),!1}return!0});class yo extends Bi{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 _n(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),_o(uo.AUTHORIZE,this.options.events,e)}onPay(){return i(this,void 0,void 0,function*(){var t,i,n,s,a,l,d,c,u,h,p,_,E,m;let v;if(this.setDisabled(!0),this.triggerLoading(!0),!(null===(t=this.selectedInstrument)||void 0===t?void 0:t.id)){const e=yield null===(i=this.cardForm)||void 0===i?void 0:i.validate();if(v=!!(null==e?void 0:e.isValid),null===(s=null===(n=this.options.events)||void 0===n?void 0:n.onValidate)||void 0===s||s.call(n,{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 vo(uo.AUTHORIZE,this.options.events,{bin:this.bin||""}),!v)return this.setDisabled(!1),void this.triggerLoading(!1);try{let t=[{paymentMethodCode:e.PAYMENT_METHOD_CODES.CARD,integrationType:"api",amount:Q().amount,storeInstrument:!1}];if(null===(a=this.selectedInstrument)||void 0===a?void 0:a.id)t[0].paymentInstrumentId=null===(l=this.selectedInstrument)||void 0===l?void 0:l.id,t[0].paymentMethodCode=null===(d=this.selectedInstrument)||void 0===d?void 0:d.paymentMethod,this.paymentInstallmentElement&&(null===(c=this.paymentInstallmentElement)||void 0===c?void 0:c.selectedInstallmentValue)&&(t[0].installments={count:null===(u=this.paymentInstallmentElement)||void 0===u?void 0:u.selectedInstallmentValue});else{if(!this.cardForm){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CARD_FORM_MISSING);throw r.PayrailsLogger.error(e.message,{error:e}),e}t=yield this.constructEncryptedPayment(t)}const i=yield this.paymentExecutor.pay(t);yield this.handleAuthorizationResult(i)}catch(t){let i=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_AUTHENTICATION_ERROR,{cause:t});t instanceof le||[401,403].includes(null===(h=null==t?void 0:t.error)||void 0===h?void 0:h.code)?(null===(_=null===(p=this.options.events)||void 0===p?void 0:p.onPaymentSessionExpired)||void 0===_||_.call(p),i.message="API token is not valid or expired.",r.PayrailsLogger.error(i.message,{error:i}),this.onAuthorizationFailed({code:e.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:i.message})):t.toString().includes("Invalid token")?(null===(m=null===(E=this.options.events)||void 0===E?void 0:E.onPaymentSessionExpired)||void 0===m||m.call(E),i.message="Vault token is not valid or expired.",r.PayrailsLogger.error(i.message,{error:i})):i=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_UNKNOWN_ERROR,{cause:t}),this.onAuthorizationFailed({code:e.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:i.message})}})}constructEncryptedPayment(e){return i(this,void 0,void 0,function*(){if(!this.cardForm)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CARD_FORM_MISSING);const{cardData:t,storeInstrument:i,enrollInstrumentToNetworkOffers:n,selectedInstallment:s,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,s&&(e[0].installments={count:s}),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(t){return i(this,void 0,void 0,function*(){var i,n,s,r,a,l,d;let c;switch(null===(i=null==t?void 0:t.finalState)||void 0===i?void 0:i.code){case"authorizeSuccessful":this.triggerLoading(!1),po(uo.AUTHORIZE,this.options.events);break;case"authorizePending":if("3ds"===(null===(n=null==t?void 0:t.response)||void 0===n?void 0:n.actionRequired)){const i=new Ys(Object.assign(Object.assign({},this.options),{paymentMethodCode:e.PAYMENT_METHOD_CODES.CARD,events:Object.assign(Object.assign({},this.options.events),{onAuthorizeFailed:e=>{this.onAuthorizationFailed(e)}})}),this.paymentExecutor);yield i.handle3ds(t)}else(null===(s=null==t?void 0:t.response)||void 0===s?void 0:s.actionRequired)||(this.triggerLoading(!1),mo(uo.AUTHORIZE,this.options.events));break;default:c=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_ERROR),this.onAuthorizationFailed({code:e.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:(null===(d=null===(l=null===(a=null===(r=t.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)||c.message})}})}}var Io;e.AuthorizationFailureReasons=void 0,(Io=e.AuthorizationFailureReasons||(e.AuthorizationFailureReasons={})).VALIDATION_FAILED="VALIDATION_FAILED",Io.AUTHORIZATION_ERROR="AUTHORIZATION_ERROR",Io.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",Io.UNKNOWN_ERROR="UNKNOWN_ERROR",Io.USER_CANCELLED="USER_CANCELLED",e.Payrails=co,e.PayrailsCollectContainer=ye,e.REVOLUT_PAY_DEFAULT_LABEL=Ts,e.REVOLUT_PAY_DEFAULT_THEME=gs,window.Payrails=co}({});