@payrails/web-sdk 5.25.0-RC.1 → 5.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
- !function(){"use strict";function e(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(i[n[o]]=e[n[o]])}return i}function t(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{l(n.next(e))}catch(e){s(e)}}function a(e){try{l(n.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}l((n=n.apply(e,t||[])).next())}))}function i(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)}function n(e,t,i,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,i):o?o.value=i:t.set(e,i),i}exports.ElementType=void 0,function(e){e.CARD_NUMBER="CARD_NUMBER",e.CARDHOLDER_NAME="CARDHOLDER_NAME",e.CVV="CVV",e.EXPIRATION_MONTH="EXPIRATION_MONTH",e.EXPIRATION_YEAR="EXPIRATION_YEAR",e.EXPIRATION_DATE="EXPIRATION_DATE"}(exports.ElementType||(exports.ElementType={})),"function"==typeof SuppressedError&&SuppressedError;var 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_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_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_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_ONPAY_CALLBACK_FAILED="payrails:client:card.onpay_callback_failed",e.PAYRAILS_CLIENT_SESSION_REFRESH_FAILED="payrails:client:session_refresh_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))(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: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:card.onpay_callback_failed":{description:"Callback passed to onPaymentButtonClicked 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.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: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"}};var n=(e=>(e.ERROR="payrails:error",e.INFO="payrails:info",e.DEBUG="payrails:debug",e.WARN="payrails:warn",e))(n||{});class o extends Error{constructor(e,t){var n;const{description:s,docUrl:r,cause:a}=null!=t?t:{},{description:l,docUrl:c}=i[e]||{},d=null!=(n=null!=s?s:l)?n:"An unknown error occurred",u=null!=r?r:c;super(d),this.name=e,this.docUrl=u,this.cause=a,this.message=d,Error.captureStackTrace&&Error.captureStackTrace(this,o)}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=o}(o);var s={};!function(e){var t=Object.defineProperty,i=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,s=(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)&&s(e,r,t[r]);if(i)for(var r of i(t))o.call(t,r)&&s(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_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_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_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_ONPAY_CALLBACK_FAILED="payrails:client:card.onpay_callback_failed",e.PAYRAILS_CLIENT_SESSION_REFRESH_FAILED="payrails:client:session_refresh_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))(a||{}),l=(e=>(e.ERROR="payrails:error",e.INFO="payrails:info",e.DEBUG="payrails:debug",e.WARN="payrails:warn",e))(l||{});class c{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 d(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var u,_={},p={};var E,h={};var I,v={};var m,y={};var L,A={};var f,O={};var T,R={};var C,g={};var N,S={};var P,b={};var D,M,w,k,Y={},U={};function x(){if(D)return U;D=1,Object.defineProperty(U,"__esModule",{value:!0}),U.Framebus=void 0;var e=$(),t="undefined"!=typeof window&&window.Promise,i=function(){function i(e){void 0===e&&(e={}),this.origin=e.origin||"*",this.channel=e.channel||"",this.verifyDomain=e.verifyDomain,this.targetFrames=e.targetFrames||[],this.limitBroadcastToFramesArray=Boolean(e.targetFrames),this.isDestroyed=!1,this.listeners=[],this.hasAdditionalChecksForOnListeners=Boolean(this.verifyDomain||this.limitBroadcastToFramesArray)}return i.setPromise=function(e){i.Promise=e},i.target=function(e){return new i(e)},i.prototype.addTargetFrame=function(e){this.limitBroadcastToFramesArray&&this.targetFrames.push(e)},i.prototype.include=function(t){return null!=t&&(null!=t.Window&&(t.constructor===t.Window&&(e.childWindows.push(t),!0)))},i.prototype.target=function(e){return i.target(e)},i.prototype.emit=function(t,i,n){if(this.isDestroyed)return!1;var o=this.origin;if(t=this.namespaceEvent(t),(0,e.isntString)(t))return!1;if((0,e.isntString)(o))return!1;"function"==typeof i&&(n=i,i=void 0);var s=(0,e.packagePayload)(t,o,i,n);return!!s&&(this.limitBroadcastToFramesArray?this.targetFramesAsWindows().forEach((function(t){(0,e.sendMessage)(t,s,o)})):(0,e.broadcast)(s,{origin:o,frame:window.top||window.self}),!0)},i.prototype.emitAsPromise=function(e,t){var n=this;return new i.Promise((function(i,o){n.emit(e,t,(function(e){i(e)}))||o(new Error('Listener not added for "'.concat(e,'"')))}))},i.prototype.on=function(t,i){if(this.isDestroyed)return!1;var n=this,o=this.origin,s=i;return t=this.namespaceEvent(t),!(0,e.subscriptionArgsInvalid)(t,s,o)&&(this.hasAdditionalChecksForOnListeners&&(s=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:s,originalHandler:i}),e.subscribers[o]=e.subscribers[o]||{},e.subscribers[o][t]=e.subscribers[o][t]||[],e.subscribers[o][t].push(s),!0)},i.prototype.off=function(t,i){var n=i;if(this.isDestroyed)return!1;if(this.verifyDomain)for(var o=0;o<this.listeners.length;o++){var s=this.listeners[o];s.originalHandler===i&&(n=s.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(o=0;o<a.length;o++)if(a[o]===n)return a.splice(o,1),!0;return!1},i.prototype.teardown=function(){if(!this.isDestroyed){this.isDestroyed=!0;for(var e=0;e<this.listeners.length;e++){var t=this.listeners[e];this.off(t.eventName,t.handler)}this.listeners.length=0}},i.prototype.passesVerifyDomainCheck=function(e){return!this.verifyDomain||this.checkOrigin(e)},i.prototype.targetFramesAsWindows=function(){return this.limitBroadcastToFramesArray?this.targetFrames.map((function(e){return e instanceof HTMLIFrameElement?e.contentWindow:e})).filter((function(e){return e})):[]},i.prototype.hasMatchingTargetFrame=function(e){if(!this.limitBroadcastToFramesArray)return!0;var t=this.targetFramesAsWindows().find((function(t){return t===e}));return Boolean(t)},i.prototype.checkOrigin=function(e){var t,i=document.createElement("a");return i.href=location.href,t="https:"===i.protocol?i.host.replace(/:443$/,""):"http:"===i.protocol?i.host.replace(/:80$/,""):i.host,i.protocol+"//"+t===e||(!this.verifyDomain||this.verifyDomain(e))},i.prototype.namespaceEvent=function(e){return this.channel?"".concat(this.channel,":").concat(e):e},i.Promise=t,i}();return U.Framebus=i,U}function F(){if(k)return Y;k=1;var e=Y&&Y.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Y,"__esModule",{value:!0}),Y.subscribeReplier=void 0;var t=x(),i=e((w||(w=1,M=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}),M));return Y.subscribeReplier=function(e,n){var o=(0,i.default)();return t.Framebus.target({origin:n}).on(o,(function i(s,r){e(s,r),t.Framebus.target({origin:n}).off(o,i)})),o},Y}var B,j={};var V,G={};var X,z,H,W,q={};function $(){return z||(z=1,e=_,t=_&&_.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),i=_&&_.__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 p;u=1,Object.defineProperty(p,"__esModule",{value:!0}),p.detach=p.attach=void 0;var e=$(),t=!1;return p.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},p.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},p}(),e),i(function(){if(E)return h;E=1,Object.defineProperty(h,"__esModule",{value:!0}),h.broadcastToChildWindows=void 0;var e=$();return h.broadcastToChildWindows=function(t,i,n){for(var o=e.childWindows.length-1;o>=0;o--){var s=e.childWindows[o];s.closed?e.childWindows.splice(o,1):n!==s&&(0,e.broadcast)(t,{origin:i,frame:s.top})}},h}(),e),i(function(){if(I)return v;I=1,Object.defineProperty(v,"__esModule",{value:!0}),v.broadcast=void 0;var e=$();return v.broadcast=function t(i,n){var o,s=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});o=a.frames[s];)t(i,{origin:r,frame:o}),s++}catch(e){}},v}(),e),i((m||(m=1,Object.defineProperty(y,"__esModule",{value:!0}),y.subscribers=y.childWindows=y.prefix=void 0,y.prefix="/*framebus*/",y.childWindows=[],y.subscribers={}),y),e),i(function(){if(L)return A;L=1,Object.defineProperty(A,"__esModule",{value:!0}),A.dispatch=void 0;var e=$();return A.dispatch=function(t,i,n,o,s){if(e.subscribers[t]&&e.subscribers[t][i]){var r=[];n&&r.push(n),o&&r.push(o);for(var a=0;a<e.subscribers[t][i].length;a++)e.subscribers[t][i][a].apply(s,r)}},A}(),e),i((f||(f=1,Object.defineProperty(O,"__esModule",{value:!0}),O.hasOpener=void 0,O.hasOpener=function(e){return e.top===e&&null!=e.opener&&e.opener!==e&&!0!==e.opener.closed}),O),e),i((T||(T=1,Object.defineProperty(R,"__esModule",{value:!0}),R.isntString=void 0,R.isntString=function(e){return"string"!=typeof e}),R),e),i(function(){if(C)return g;C=1,Object.defineProperty(g,"__esModule",{value:!0}),g.onMessage=void 0;var e=$();return g.onMessage=function(t){if(!(0,e.isntString)(t.data)){var i=(0,e.unpackPayload)(t);if(i){var n=i.eventData,o=i.reply;(0,e.dispatch)("*",i.event,n,o,t),(0,e.dispatch)(t.origin,i.event,n,o,t),(0,e.broadcastToChildWindows)(t.data,i.origin,t.source)}}},g}(),e),i(function(){if(N)return S;N=1,Object.defineProperty(S,"__esModule",{value:!0}),S.packagePayload=void 0;var e=$();return S.packagePayload=function(t,i,n,o){var s,r={event:t,origin:i};"function"==typeof o&&(r.reply=(0,e.subscribeReplier)(o,i)),r.eventData=n;try{s=e.prefix+JSON.stringify(r)}catch(e){throw new Error("Could not stringify event: ".concat(e.message))}return s},S}(),e),i((P||(P=1,Object.defineProperty(b,"__esModule",{value:!0}),b.sendMessage=void 0,b.sendMessage=function(e,t,i){try{e.postMessage(t,i)}catch(e){}}),b),e),i(F(),e),i(function(){if(B)return j;B=1,Object.defineProperty(j,"__esModule",{value:!0}),j.subscriptionArgsInvalid=void 0;var e=$();return j.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},j}(),e),i((V||(V=1,Object.defineProperty(G,"__esModule",{value:!0})),G),e),i(function(){if(X)return q;X=1,Object.defineProperty(q,"__esModule",{value:!0}),q.unpackPayload=void 0;var e=$();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,o=t.source,s=i.reply;i.reply=function(t){if(o){var i=(0,e.packagePayload)(s,n,t);i&&o.postMessage(i,n)}}}return i},q}(),e)),_;var e,t,i}const K=d(function(){if(W)return H;W=1;var e=$(),t=x();return(0,e.attach)(),H=t.Framebus}());class J{constructor(e){this.origin=null,this.listeners=[],this.bus=new K(e)}static getInstance(){return J.instance||(J.instance=new J),J.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 Z{constructor(){this.bus=J.getInstance()}log(e,t){this.bus.emit(l.ERROR,{level:e,event:t})}}var Q,ee;const te=d(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 o(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 s(e,t){try{return t in e}catch(e){return!1}}function r(e,t,n){var r={};return n.isMergeableObject(e)&&o(e).forEach((function(t){r[t]=i(e[t],n)})),o(t).forEach((function(o){(function(e,t){return s(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,o)||(s(e,o)&&n.isMergeableObject(t[o])?r[o]=function(e,t){if(!t.customMerge)return a;var i=t.customMerge(e);return"function"==typeof i?i:a}(o,n)(e[o],t[o],n):r[o]=i(t[o],n))})),r}function a(t,o,s){(s=s||{}).arrayMerge=s.arrayMerge||n,s.isMergeableObject=s.isMergeableObject||e,s.cloneUnlessOtherwiseSpecified=i;var a=Array.isArray(o);return a===Array.isArray(t)?a?s.arrayMerge(t,o,s):r(t,o,s):i(o,s)}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(),oe=()=>window&&window.navigator,se=()=>window&&window.screen,re=()=>({resolution:`${se().width}x${se().height}`,user_agent:oe().userAgent,language:oe().language}),ae=[a.PAYRAILS_API_AUTHORIZATION_ERROR,a.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR];class le{constructor(e){this.adapter=[new Z],this.enabled=e.enabled||!0,this.initGlobalState(e),e.logLevel=e.logLevel||"error","debug"===e.logLevel&&this.addAdapter(new c)}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}(s);const r=[];for(let e=0;e<256;++e)r.push((e+256).toString(16).slice(1));let a;const l=new Uint8Array(16);var c={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function d(e,t,i){if(c.randomUUID&&!t&&!e)return c.randomUUID();const n=(e=e||{}).random??e.rng?.()??function(){if(!a){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");a=crypto.getRandomValues.bind(crypto)}return a(l)}();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){if((i=i||0)<0||i+16>t.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[i+e]=n[e];return t}return function(e,t=0){return(r[e[t+0]]+r[e[t+1]]+r[e[t+2]]+r[e[t+3]]+"-"+r[e[t+4]]+r[e[t+5]]+"-"+r[e[t+6]]+r[e[t+7]]+"-"+r[e[t+8]]+r[e[t+9]]+"-"+r[e[t+10]]+r[e[t+11]]+r[e[t+12]]+r[e[t+13]]+r[e[t+14]]+r[e[t+15]]).toLowerCase()}(n)}var u;!function(e){e.GET="GET",e.POST="POST"}(u||(u={}));const _=e=>t(void 0,[e],void 0,(function*({url:e,method:t=u.GET,token:i="",body:n}){const o={method:t,headers:Object.assign(Object.assign(Object.assign({},m()),v(i)),y())};t===u.POST&&(o.body=JSON.stringify(n||{}));const s=yield fetch(e,o),r=yield s.json();if([401,403].includes(s.status))throw new p(e,t);if(429===s.status)throw new h(e,t);if(!s.ok)throw new E(e,t);return{ok:s.ok,req:Object.assign({url:e},o),res:r}}));class p extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_UNAUTHORIZED,{description:`[${t}] ${e} unauthorized`})}}let E=class extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{description:`[${t}] ${e} unsuccessful`})}},h=class extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} too many requests`})}};class I extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} max poll attempts exceeded.`})}}const v=e=>({authorization:`Bearer ${e}`}),m=()=>({"x-idempotency-key":d()}),y=()=>{const e={version:"5.25.0-RC.1",type:"web-sdk"};return{"x-client-version":e.version,"x-client-type":e.type}},L=(e,i)=>t(void 0,void 0,void 0,(function*(){var t,n;if(null==e?void 0:e.onPaymentButtonClicked)try{const n=yield e.onPaymentButtonClicked(i);if(!n){const i=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED,{description:"Callback passed to onPaymentButtonClicked resolved to false"});return null===(t=null==e?void 0:e.onAuthorizeFailed)||void 0===t||t.call(e,{code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:i.message}),n}}catch(t){const i=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED,{description:"Callback passed to onPaymentButtonClicked threw an error",cause:t});return null===(n=e.onAuthorizeFailed)||void 0===n||n.call(e,{code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:i.message}),!1}return!0}));var A,f,O,T;exports.PAYMENT_METHOD_CODES=void 0,(A=exports.PAYMENT_METHOD_CODES||(exports.PAYMENT_METHOD_CODES={})).CARD="card",A.GOOGLE_PAY="googlePay",A.PAYPAL="payPal",A.APPLE_PAY="applePay",A.GENERIC_REDIRECT="genericRedirect",function(e){e.ENABLED="enabled",e.CREATED="created",e.DELETED="deleted",e.DISABLED="disabled",e.INVALID="invalid",e.TRANSIENT="transient"}(f||(f={}));class R{static get response(){if(!R._response){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND);throw s.PayrailsLogger.error(e.message,{error:e}),e}return R._response}static setResponse(e){return R._response=e,R}static get lookup(){return R.response.initialResults.find((({body:{name:e}})=>"lookup"===e))}static get holderReference(){return R.response.holderReference}static get savedCreditCards(){return R.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.CARD)}static get savedPaypalAccounts(){return R.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.PAYPAL).filter((({status:e})=>e===f.ENABLED))}static get savedGooglePayAccounts(){return R.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.GOOGLE_PAY).filter((({status:e})=>e===f.ENABLED))}static get savedApplePayAccounts(){return R.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.APPLE_PAY)}static get paypalConfig(){const e=R.availablePaymentMethods.find((({paymentMethodCode:e})=>e===exports.PAYMENT_METHOD_CODES.PAYPAL));if(!e){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING);throw s.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:R.availablePaymentMethods}}),e}return e.config||{}}static get googlePayConfig(){const e=R.availablePaymentMethods.find((({paymentMethodCode:e})=>e===exports.PAYMENT_METHOD_CODES.GOOGLE_PAY));if(!e){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING);throw s.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:R.availablePaymentMethods}}),e}return e?[e.config]:[]}static isPaymentMethodAvailable(e){return R.availablePaymentMethods.some((({paymentMethodCode:t})=>t===e))}static get applePayConfig(){const e=R.availablePaymentMethods.find((({paymentMethodCode:e})=>e===exports.PAYMENT_METHOD_CODES.APPLE_PAY));if(!e){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING);throw s.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:R.availablePaymentMethods}}),e}return e.config.parameters}static get url(){return R.response.links.self}static get meta(){return R.response.meta}static get availablePaymentMethods(){var e;return(null===(e=R.lookup)||void 0===e?void 0:e.body.data.paymentCompositionOptions)||[]}static get authorizeLink(){var e;return null===(e=R.lookup)||void 0===e?void 0:e.body.links.authorize.href}static get createSessionLink(){var e;return null===(e=R.response.links.startPaymentSession)||void 0===e?void 0:e.href}static get storedPaymentInstruments(){return R.availablePaymentMethods.flatMap((e=>e.paymentInstruments||[])).filter((({paymentMethod:e,status:t})=>t===f.ENABLED||![exports.PAYMENT_METHOD_CODES.GOOGLE_PAY,exports.PAYMENT_METHOD_CODES.PAYPAL].includes(e)))}static get storedDropinInstruments(){return R.storedPaymentInstruments.filter((({paymentMethod:e})=>![exports.PAYMENT_METHOD_CODES.GOOGLE_PAY,exports.PAYMENT_METHOD_CODES.APPLE_PAY].includes(e)))}static getFullPaymentMethodConfig(e){return R.availablePaymentMethods.find((({paymentMethodCode:t})=>t===e))}static isAddressSelectorEnabled(e){var t,i;return!!R._response&&(null===(i=null===(t=R.getFullPaymentMethodConfig(e))||void 0===t?void 0:t.clientConfig)||void 0===i?void 0:i.supportsBillingInfo)}static isPaymentInstallmentsEnabled(e){var t;if(R._response){const i=this.getFullPaymentMethodConfig(e);return i&&(null===(t=this.getPaymentMethodConfig(i).clientConfig)||void 0===t?void 0:t.supportsInstallments)}return!1}static getPaymentInstallmentOptions(e){var t;const i=this.getFullPaymentMethodConfig(e);return i&&(null===(t=this.getPaymentMethodConfig(i).clientConfig)||void 0===t?void 0:t.installments)||{}}static getStoredInstrumentForPaymentMethod(e){var t;return(null===(t=this.availablePaymentMethods.find((({paymentMethodCode:t})=>t===e)))||void 0===t?void 0:t.paymentInstruments)||[]}static getPaymentMethodForStoredInstrument(e){const t=this.availablePaymentMethods.find((({paymentInstruments:t})=>null==t?void 0:t.some((({id:t})=>t===e.id))));return t&&this.getPaymentMethodConfig(t)}static getPaymentMethodConfig(t){return e(t,["paymentInstruments"])}}!function(e){e.REDIRECT="redirect",e.DIRECT="direct"}(O||(O={})),exports.INTEGRATION_TYPE=void 0,(T=exports.INTEGRATION_TYPE||(exports.INTEGRATION_TYPE={})).API="api",T.HPP="hpp";class C{constructor(){this._config=void 0}static getInstance(){return C._instance||(C._instance=new C),C._instance}set config(e){try{C.getInstance()._config=e}catch(e){s.PayrailsLogger.error("Error parsing SDK Configuration",{error:e})}}get config(){return C.getInstance()._config||s.PayrailsLogger.error("SDK Configuration not set"),C.getInstance()._config||{}}}const g=()=>C.getInstance().config,N=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));C.getInstance().config=t,t.execution&&R.setResponse(t.execution)}catch(e){s.PayrailsLogger.error("Error parsing SDK Configuration",{error:e})}},S={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 P{static getInstance(){return this.instance||(this.instance=new P),this.instance}constructor(e=""){this.lastActionUpdateTime=e,P.instance=this}}class b{constructor(e=S,t=680,i=60,n=2e3,o=5,s=P.getInstance()){this.returnLinks=e,this.POLL_INTERVAL=t,this.MAX_POLL_ATTEMPTS=i,this.POLL_INITIAL_DELAY=n,this.POLL_ERROR_COUNT_MULTIPLIER=o,this.paymentStatus=s}pay(e){return t(this,void 0,void 0,(function*(){try{const t=(yield this.authorize(e)).res.links.execution;return yield this.pollForAuthorizationResult(t)}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR,{cause:e});throw s.PayrailsLogger.error(t.message,{error:t}),e}}))}confirm(e){return t(this,arguments,void 0,(function*(e,t={}){try{const i=yield _({url:e,method:u.POST,token:g().token,body:{data:t}}),n=yield this.pollForAuthorizationResult(i.res.links.execution);if(n.finalState)return n;const o=n.response.status.slice().sort(((e,t)=>new Date(t.time).getTime()-new Date(e.time).getTime()))[0].time,{res:s}=yield this.getExecution(i.res.links.execution,o);return{finalState:s.status.find((({code:e,time:t})=>["authorizeSuccessful","authorizeFailed"].includes(e)&&new Date(t)>new Date(o))),response:s}}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR,{cause:e});throw s.PayrailsLogger.error(t.message,{error:t}),e}}))}getExecution(e,i){return t(this,arguments,void 0,(function*(e,t,i=0){if(i>this.MAX_POLL_ATTEMPTS)throw new I(e,u.GET);0===i&&t?yield this.wait(this.POLL_INITIAL_DELAY):yield this.wait(this.POLL_INTERVAL);try{const n=yield _({url:e,token:g().token});if(t){if(!n.res.status.find((({time:e})=>new Date(e)>new Date(t))))return yield this.wait(this.POLL_INTERVAL),this.getExecution(e,t,i+1)}return n}catch(n){if(n instanceof E)return yield this.wait(this.POLL_INTERVAL),this.getExecution(e,t,i+this.POLL_ERROR_COUNT_MULTIPLIER);if(n instanceof h)return yield this.wait(this.POLL_INTERVAL*i),this.getExecution(e,t,i+1);throw n}}))}createApplePaySession(e){return t(this,void 0,void 0,(function*(){return _({url:e.requestUrl,method:u.POST,token:g().token,body:{integrationType:"api",paymentMethodCode:"applePay",amount:g().amount,meta:{sessionURL:e.sessionUrl,clientContext:{host:e.clientDomain||window.location.host}}}})}))}authorize(e){return t(this,void 0,void 0,(function*(){if(!R.authorizeLink||!g().amount){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND,{description:"SDK was not initialized with workflow execution"});throw s.PayrailsLogger.error(e.message,{error:e}),e}const{success:t=S.success,error:i=S.error,cancel:n=S.cancel,pending:r=S.pending}=this.returnLinks,a=this.attachRiskIdToPaymentComposition({amount:g().amount,paymentComposition:e,returnInfo:{success:t,cancel:n,error:i,pending:r}});return _({url:R.authorizeLink,method:u.POST,token:g().token,body:a})}))}getFirstNonFraudNetId(e){const t=Object.keys(e||{}).find((e=>"fraudNet"!==e));return t?e[t]:null}attachRiskIdToPaymentComposition(e){var t,i,n,o,s;let r;return r=e.paymentComposition[0].paymentMethodCode===exports.PAYMENT_METHOD_CODES.PAYPAL&&(null===(i=null===(t=window.PayrailsData)||void 0===t?void 0:t.riskIds)||void 0===i?void 0:i.fraudNet)?null===(o=null===(n=window.PayrailsData)||void 0===n?void 0:n.riskIds)||void 0===o?void 0:o.fraudNet:this.getFirstNonFraudNetId(null===(s=window.PayrailsData)||void 0===s?void 0:s.riskIds)||"",r?Object.assign(Object.assign({},e),{meta:{risk:{sessionId:r}}}):e}wait(e){return t(this,void 0,void 0,(function*(){return new Promise((t=>setTimeout(t,e)))}))}pollForAuthorizationResult(e){return t(this,arguments,void 0,(function*(e,t=0,i=["authorizePending","authorizeSuccessful","authorizeFailed"]){const n=(yield this.getExecution(e,this.paymentStatus.lastActionUpdateTime,t)).res,r=n.status,a=r.find((({code:e})=>"authorizeRequested"===e));if(!a&&t<10)return yield new Promise((e=>setTimeout(e,this.POLL_INTERVAL))),this.pollForAuthorizationResult(e,t+1);if(!a){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED);throw s.PayrailsLogger.error(e.message,{error:e}),e}const l=r.find((({code:e,time:t})=>"confirmRequested"===e&&new Date(t)>new Date(a.time))),c=l?l.time:a.time,d=r.filter((({code:e,time:t})=>i.includes(e)&&new Date(t)>new Date(c))).sort(((e,t)=>new Date(t.time).getTime()-new Date(e.time).getTime()))[0];return d?(this.paymentStatus.lastActionUpdateTime=d.time,{finalState:d,response:n}):this.pollForAuthorizationResult(e,t+1,i)}))}}class D{constructor(e,t,i,n=M.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,400]],this.internalPopupBackground=null,this.SCREEN_WIDTH=window.innerWidth,this.SCREEN_HEIGHT=window.innerHeight}get iframeSize(){return this.type===M.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 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()),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}handleMessages(){const e=i=>t(this,void 0,void 0,(function*(){var t,n,o,s,r,a,l;if(i.data&&'{"type":"3DS-challenge-completed"}'===i.data){window.removeEventListener("message",e);switch(null===(t=(yield this.paymentExecutor.pollForAuthorizationResult(R.url)).finalState)||void 0===t?void 0:t.code){case"authorizeSuccessful":null===(o=null===(n=this.options.events)||void 0===n?void 0:n.onAuthorizeSuccess)||void 0===o||o.call(n);break;case"authorizePending":null===(r=null===(s=this.options.events)||void 0===s?void 0:s.onAuthorizePending)||void 0===r||r.call(s);break;default:null===(l=null===(a=this.options.events)||void 0===a?void 0:a.onAuthorizeFailed)||void 0===l||l.call(a,{code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:"Authorization failed after 3DS challenge."})}this.unmount()}}));window.addEventListener("message",e)}mount(){var e;this.popup.remove(),null===(e=document.querySelector("body"))||void 0===e||e.appendChild(this.popupBackground),this.handleMessages()}unmount(){this.popupBackground.remove(),this.internalPopupBackground=null}}var M;!function(e){e[e.THREE_DS=0]="THREE_DS",e[e.GENERIC_REDIRECT=1]="GENERIC_REDIRECT"}(M||(M={}));class w{constructor(e,t){this.options=e,this.paymentExecutor=t}handle3ds(e){var t,i,n;try{null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onThreeDSecureChallenge)||void 0===i||i.call(t)}catch(e){}const o=null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.links["3ds"];if(o)if(this.options.redirectFor3DS)window.location.assign(o);else{new D(o,this.paymentExecutor,this.options).mount()}}}var k,Y={};!function(e){function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var i,n={},o={};var s,r={};var a,l={};var c,d={};var u,_={};var p,E={};var h,I={};var v,m={};var y,L={};var A,f={};var O,T,R,C,g={},N={};function S(){if(O)return N;O=1,Object.defineProperty(N,"__esModule",{value:!0}),N.Framebus=void 0;var e=B(),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 o=this.origin;if(t=this.namespaceEvent(t),(0,e.isntString)(t))return!1;if((0,e.isntString)(o))return!1;"function"==typeof i&&(n=i,i=void 0);var s=(0,e.packagePayload)(t,o,i,n);return!!s&&(this.limitBroadcastToFramesArray?this.targetFramesAsWindows().forEach((function(t){(0,e.sendMessage)(t,s,o)})):(0,e.broadcast)(s,{origin:o,frame:window.top||window.self}),!0)},i.prototype.emitAsPromise=function(e,t){var n=this;return new i.Promise((function(i,o){n.emit(e,t,(function(e){i(e)}))||o(new Error('Listener not added for "'.concat(e,'"')))}))},i.prototype.on=function(t,i){if(this.isDestroyed)return!1;var n=this,o=this.origin,s=i;return t=this.namespaceEvent(t),!(0,e.subscriptionArgsInvalid)(t,s,o)&&(this.hasAdditionalChecksForOnListeners&&(s=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:s,originalHandler:i}),e.subscribers[o]=e.subscribers[o]||{},e.subscribers[o][t]=e.subscribers[o][t]||[],e.subscribers[o][t].push(s),!0)},i.prototype.off=function(t,i){var n=i;if(this.isDestroyed)return!1;if(this.verifyDomain)for(var o=0;o<this.listeners.length;o++){var s=this.listeners[o];s.originalHandler===i&&(n=s.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(o=0;o<a.length;o++)if(a[o]===n)return a.splice(o,1),!0;return!1},i.prototype.teardown=function(){if(!this.isDestroyed){this.isDestroyed=!0;for(var e=0;e<this.listeners.length;e++){var t=this.listeners[e];this.off(t.eventName,t.handler)}this.listeners.length=0}},i.prototype.passesVerifyDomainCheck=function(e){return!this.verifyDomain||this.checkOrigin(e)},i.prototype.targetFramesAsWindows=function(){return this.limitBroadcastToFramesArray?this.targetFrames.map((function(e){return e instanceof HTMLIFrameElement?e.contentWindow:e})).filter((function(e){return e})):[]},i.prototype.hasMatchingTargetFrame=function(e){if(!this.limitBroadcastToFramesArray)return!0;var t=this.targetFramesAsWindows().find((function(t){return t===e}));return Boolean(t)},i.prototype.checkOrigin=function(e){var t,i=document.createElement("a");return i.href=location.href,t="https:"===i.protocol?i.host.replace(/:443$/,""):"http:"===i.protocol?i.host.replace(/:80$/,""):i.host,i.protocol+"//"+t===e||(!this.verifyDomain||this.verifyDomain(e))},i.prototype.namespaceEvent=function(e){return this.channel?"".concat(this.channel,":").concat(e):e},i.Promise=t,i}();return N.Framebus=i,N}function P(){if(C)return g;C=1;var e=g&&g.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(g,"__esModule",{value:!0}),g.subscribeReplier=void 0;var t=S(),i=e((R||(R=1,T=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)}))}),T));return g.subscribeReplier=function(e,n){var o=(0,i.default)();return t.Framebus.target({origin:n}).on(o,(function i(s,r){e(s,r),t.Framebus.target({origin:n}).off(o,i)})),o},g}var b,D={};var M,w={};var k,Y,U,x,F={};function B(){return Y||(Y=1,e=n,t=n&&n.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),O=n&&n.__exportStar||function(e,i){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(i,n)||t(i,e,n)},Object.defineProperty(e,"__esModule",{value:!0}),O(function(){if(i)return o;i=1,Object.defineProperty(o,"__esModule",{value:!0}),o.detach=o.attach=void 0;var e=B(),t=!1;return o.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},o.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},o}(),e),O(function(){if(s)return r;s=1,Object.defineProperty(r,"__esModule",{value:!0}),r.broadcastToChildWindows=void 0;var e=B();return r.broadcastToChildWindows=function(t,i,n){for(var o=e.childWindows.length-1;o>=0;o--){var s=e.childWindows[o];s.closed?e.childWindows.splice(o,1):n!==s&&(0,e.broadcast)(t,{origin:i,frame:s.top})}},r}(),e),O(function(){if(a)return l;a=1,Object.defineProperty(l,"__esModule",{value:!0}),l.broadcast=void 0;var e=B();return l.broadcast=function t(i,n){var o,s=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});o=a.frames[s];)t(i,{origin:r,frame:o}),s++}catch(e){}},l}(),e),O((c||(c=1,Object.defineProperty(d,"__esModule",{value:!0}),d.subscribers=d.childWindows=d.prefix=void 0,d.prefix="/*framebus*/",d.childWindows=[],d.subscribers={}),d),e),O(function(){if(u)return _;u=1,Object.defineProperty(_,"__esModule",{value:!0}),_.dispatch=void 0;var e=B();return _.dispatch=function(t,i,n,o,s){if(e.subscribers[t]&&e.subscribers[t][i]){var r=[];n&&r.push(n),o&&r.push(o);for(var a=0;a<e.subscribers[t][i].length;a++)e.subscribers[t][i][a].apply(s,r)}},_}(),e),O((p||(p=1,Object.defineProperty(E,"__esModule",{value:!0}),E.hasOpener=void 0,E.hasOpener=function(e){return e.top===e&&null!=e.opener&&e.opener!==e&&!0!==e.opener.closed}),E),e),O((h||(h=1,Object.defineProperty(I,"__esModule",{value:!0}),I.isntString=void 0,I.isntString=function(e){return"string"!=typeof e}),I),e),O(function(){if(v)return m;v=1,Object.defineProperty(m,"__esModule",{value:!0}),m.onMessage=void 0;var e=B();return m.onMessage=function(t){if(!(0,e.isntString)(t.data)){var i=(0,e.unpackPayload)(t);if(i){var n=i.eventData,o=i.reply;(0,e.dispatch)("*",i.event,n,o,t),(0,e.dispatch)(t.origin,i.event,n,o,t),(0,e.broadcastToChildWindows)(t.data,i.origin,t.source)}}},m}(),e),O(function(){if(y)return L;y=1,Object.defineProperty(L,"__esModule",{value:!0}),L.packagePayload=void 0;var e=B();return L.packagePayload=function(t,i,n,o){var s,r={event:t,origin:i};"function"==typeof o&&(r.reply=(0,e.subscribeReplier)(o,i)),r.eventData=n;try{s=e.prefix+JSON.stringify(r)}catch(e){throw new Error("Could not stringify event: ".concat(e.message))}return s},L}(),e),O((A||(A=1,Object.defineProperty(f,"__esModule",{value:!0}),f.sendMessage=void 0,f.sendMessage=function(e,t,i){try{e.postMessage(t,i)}catch(e){}}),f),e),O(P(),e),O(function(){if(b)return D;b=1,Object.defineProperty(D,"__esModule",{value:!0}),D.subscriptionArgsInvalid=void 0;var e=B();return D.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},D}(),e),O((M||(M=1,Object.defineProperty(w,"__esModule",{value:!0})),w),e),O(function(){if(k)return F;k=1,Object.defineProperty(F,"__esModule",{value:!0}),F.unpackPayload=void 0;var e=B();return F.unpackPayload=function(t){var i;if(t.data.slice(0,e.prefix.length)!==e.prefix)return!1;try{i=JSON.parse(t.data.slice(e.prefix.length))}catch(e){return!1}if(i.reply){var n=t.origin,o=t.source,s=i.reply;i.reply=function(t){if(o){var i=(0,e.packagePayload)(s,n,t);i&&o.postMessage(i,n)}}}return i},F}(),e)),n;var e,t,O}const j=t(function(){if(x)return U;x=1;var e=B(),t=S();return(0,e.attach)(),U=t.Framebus}());class V{constructor(e){this.origin=null,this.listeners=[],this.bus=new j(e)}static getInstance(){return V.instance||(V.instance=new V),V.instance}on(e,t){return this.bus.on(e,t)}off(e,t){return this.bus.off(e,t)}emit(e,t,i=void 0){return this.bus.emit(e,t,i)}target(e){return this.bus.target(e)}}e.IframeEventBus=V,e.getEventBus=()=>V.getInstance()}(Y);class U{constructor(e,{id:t="",className:i=""}={}){this.subElements=[],this.eventBus=Y.getEventBus();const n=document.createElement(e);t&&(this.id=t,n.setAttribute("id",t)),i&&(Array.isArray(i)?n.setAttribute("class",function(...e){return e.filter(Boolean).join(" ")}(...i)):n.setAttribute("class",i)),this.element=n}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 x extends U{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.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 b(this.returnInfo)}setDisabled(e){var t,i,n,o,s;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===(o=this.options.styles)||void 0===o?void 0:o.disabled)||{}),(null===(s=this.options.styles)||void 0===s?void 0:s.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,o;const s=this.element.offsetWidth;this.element.style.minWidth=`${s}px`,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===(o=this.options.styles)||void 0===o?void 0:o.loading)||{}))}onAuthorizationFailed(e){var t,i;this.setDisabled(!1),this.triggerLoading(!1),(null===(t=this.options.events)||void 0===t?void 0:t.onAuthorizeFailed)&&(null===(i=this.options.events)||void 0===i||i.onAuthorizeFailed(e))}onPay(){return t(this,void 0,void 0,(function*(){var e,t,i,n,r,a,l,c,d,u,_,E,h;let I;if(this.setDisabled(!0),this.triggerLoading(!0),!(null===(e=this.selectedInstrument)||void 0===e?void 0:e.id)&&(I=null===(i=yield null===(t=this.cardForm)||void 0===t?void 0:t.validate())||void 0===i?void 0:i.isValid,!I))return this.setDisabled(!1),void this.triggerLoading(!1);if(I=yield L(this.options.events,{bin:this.bin||""}),!I)return this.setDisabled(!1),void this.triggerLoading(!1);try{let e=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.CARD,integrationType:"api",amount:g().amount,storeInstrument:!1}];if(null===(n=this.selectedInstrument)||void 0===n?void 0:n.id)e[0].paymentInstrumentId=null===(r=this.selectedInstrument)||void 0===r?void 0:r.id,e[0].paymentMethodCode=null===(a=this.selectedInstrument)||void 0===a?void 0:a.paymentMethod,this.paymentInstallmentElement&&(null===(l=this.paymentInstallmentElement)||void 0===l?void 0:l.selectedInstallmentValue)&&(e[0].installments={count:null===(c=this.paymentInstallmentElement)||void 0===c?void 0:c.selectedInstallmentValue});else{if(!this.cardForm){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CARD_FORM_MISSING);throw s.PayrailsLogger.error(e.message,{error:e}),e}e=yield this.constructEncryptedPayment(e)}const t=yield this.paymentExecutor.pay(e);this.handleAuthorizationResult(t)}catch(e){let t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_AUTHENTICATION_ERROR,{cause:e});e instanceof p||[401,403].includes(null===(d=null==e?void 0:e.error)||void 0===d?void 0:d.code)?(null===(_=null===(u=this.options.events)||void 0===u?void 0:u.onPaymentSessionExpired)||void 0===_||_.call(u),t.message="API token is not valid or expired.",s.PayrailsLogger.error(t.message,{error:t}),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:t.message})):e.toString().includes("Invalid token")?(null===(h=null===(E=this.options.events)||void 0===E?void 0:E.onPaymentSessionExpired)||void 0===h||h.call(E),t.message="Vault token is not valid or expired.",s.PayrailsLogger.error(t.message,{error:t})):t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_UNKNOWN_ERROR,{cause:e}),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:t.message})}}))}constructEncryptedPayment(e){return t(this,void 0,void 0,(function*(){if(!this.cardForm)throw new 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}))}handleAuthorizationResult(e){var t,i,n,s,r,a,l;let c;switch(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code){case"authorizeSuccessful":this.triggerLoading(!1),null===(n=null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeSuccess)||void 0===n||n.call(i);break;case"authorizePending":if("3ds"===(null===(s=null==e?void 0:e.response)||void 0===s?void 0:s.actionRequired)){new w(Object.assign(Object.assign({},this.options),{events:Object.assign(Object.assign({},this.options.events),{onAuthorizeFailed:e=>{this.onAuthorizationFailed(e)}})}),this.paymentExecutor).handle3ds(e)}else(null===(r=null==e?void 0:e.response)||void 0===r?void 0:r.actionRequired)||(this.triggerLoading(!1),null===(l=null===(a=this.options.events)||void 0===a?void 0:a.onAuthorizePending)||void 0===l||l.call(a));break;default:c=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_ERROR),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:c.message})}}}exports.AuthorizationFailureReasons=void 0,(k=exports.AuthorizationFailureReasons||(exports.AuthorizationFailureReasons={})).VALIDATION_FAILED="VALIDATION_FAILED",k.AUTHORIZATION_ERROR="AUTHORIZATION_ERROR",k.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",k.UNKNOWN_ERROR="UNKNOWN_ERROR";const F={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."},B={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."},j={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."},V="collect_controller",G="element",X="ERROR",z={CHANGE:"CHANGE",READY:"READY",FOCUS:"FOCUS",BLUR:"BLUR",ESCAPE:"ESCAPE",CLICK:"CLICK",ERROR:"ERROR",SUCCESS:"SUCCESS",SUBMIT:"SUBMIT",CREATED:"CREATED",MOUNTED:"MOUNTED",HEIGHT:"HEIGHT"},H="FRAME_READY",W="TOKENIZATION_REQUEST",q="INPUT_EVENT",$="DESTROY FRAME",K="SET_VALUE",J="GET_BEARER_TOKEN",Z="COLLECT_ELEMENT_SET_ERROR",Q="COMPOSABLE_UPDATE_OPTIONS",ee="VALIDATE_ELEMENT",te="COMPOSABLE_CONTAINER_MOUNTED",ie="COLLECT_CONTAINER_MOUNTED";var ne,oe;!function(e){e.CVV="CVV",e.EXPIRATION_DATE="EXPIRATION_DATE",e.CARD_NUMBER="CARD_NUMBER",e.CARDHOLDER_NAME="CARDHOLDER_NAME",e.INPUT_FIELD="INPUT_FIELD",e.PIN="PIN",e.EXPIRATION_MONTH="EXPIRATION_MONTH",e.EXPIRATION_YEAR="EXPIRATION_YEAR"}(ne||(ne={})),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"}(oe||(oe={}));const se={[oe.AMEX]:["XXXX XXXXXX XXXXX",{X:"[0-9]"}],[oe.VISA]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[oe.MASTERCARD]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[oe.DISCOVER]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[oe.DINERS_CLUB]:["XXXX XXXXXX XXXXXX",{X:"[0-9]"}],[oe.JCB]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[oe.MAESTRO]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[oe.UNIONPAY]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[oe.HIPERCARD]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[oe.DEFAULT]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[oe.UNKNOWN]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}]},re={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},[ne.CARDHOLDER_NAME]:{name:"cardHolderName",attributes:{type:"text",autocomplete:"cc-name"},sensitive:!0,regex:/^([a-zA-Z\\ \\,\\.\\-\\']{2,})$/},[ne.CARD_NUMBER]:{name:"CARD_NUMBER",attributes:{type:"text",autocomplete:"cc-number",inputmode:"numeric"},sensitive:!0,mask:se[oe.DEFAULT],regex:/$|^[\s]*?([0-9]{2,6}[ -]?){3,5}[\s]*/},[ne.EXPIRATION_DATE]:{name:"EXPIRATION_DATE",attributes:{type:"text",autocomplete:"cc-exp",inputmode:"numeric"},sensitive:!0},[ne.EXPIRATION_MONTH]:{name:"EXPIRATION_MONTH",attributes:{maxLength:2,type:"text",inputmode:"numeric",autocomplete:"cc-exp-month"},sensitive:!0,mask:["XX",{X:"[0-9]"}]},[ne.EXPIRATION_YEAR]:{name:"EXPIRATION_YEAR",attributes:{type:"text",inputmode:"numeric",autocomplete:"cc-exp-year"},sensitive:!0},[ne.CVV]:{name:"CVV",attributes:{type:"text",inputmode:"numeric",maxLength:3},sensitive:!0,regex:/^$|^[0-9]{3,4}$/},[ne.INPUT_FIELD]:{name:"INPUT_FIELD",sensitive:!0,attributes:{type:"text"}},[ne.PIN]:{name:"PIN",attributes:{type:"text",inputmode:"numeric",maxLength:12,minLength:4},sensitive:!0,regex:/^$|^[0-9]{4,12}$/}},ae="XXXX-XXXX-XXXX-XXXX",le={height:"100%",width:"100%",margin:0,padding:0,border:0,position:"absolute",top:0,left:0,"user-select":"none"},ce={position:"absolute",top:0,width:0,height:0,visibility:"hidden",left:"-99999999px","user-select":"none"},de={width:"100%",height:"100%",border:"0",padding:"0",margin:"0",outline:"none"},ue={WEBPACKAUTOFILL:"-webkit-autofill",BASE:"base",FOCUS:"focus",COMPLETE:"complete",EMPTY:"empty",INVALID:"invalid",GLOBAL:"global",REQUIRED_ASTERISK:"requiredAsterisk"},_e={[oe.VISA]:{regex:/^4\d*/,maxCardLength:19,cardLengthRange:[13,16]},[oe.MASTERCARD]:{regex:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,maxCardLength:16,cardLengthRange:[16]},[oe.AMEX]:{regex:/^3[47]\d*/,maxCardLength:15,cardLengthRange:[15]},[oe.DINERS_CLUB]:{regex:/^(36|38|30[0-5])\d*/,maxCardLength:16,cardLengthRange:[14,15,16,17,18,19]},[oe.DISCOVER]:{regex:/^(6011|65|64[4-9]|622)\d*/,maxCardLength:16,cardLengthRange:[16,17,18,19]},[oe.JCB]:{regex:/^35\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[oe.HIPERCARD]:{regex:/^606282\d*/,maxCardLength:19,cardLengthRange:[14,15,16,17,18,19]},[oe.UNIONPAY]:{regex:/^62\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[oe.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]}};oe.DEFAULT,oe.CVV,oe.EXPIRY,oe.ERROR,oe.AMEX,oe.DINERS_CLUB,oe.DISCOVER,oe.HIPERCARD,oe.JCB,oe.MAESTRO,oe.MASTERCARD,oe.UNIONPAY,oe.VISA;const pe="MM/YY",Ee=[pe,"YYYY/MM","YY/MM","MM/YYYY"],he=["YY","YYYY"];var Ie;!function(e){e.APPLICATIONORJSON="application/json",e.TEXTORPLAIN="text/plain",e.TEXTORXML="text/xml",e.FORMURLENCODED="application/x-www-form-urlencoded",e.FORMDATA="multipart/form-data"}(Ie||(Ie={})),ne.CARD_NUMBER,ne.EXPIRATION_DATE,ne.EXPIRATION_MONTH,ne.EXPIRATION_YEAR,ne.CVV,ne.EXPIRATION_DATE,ne.CARD_NUMBER,ne.CARDHOLDER_NAME,ne.INPUT_FIELD,B.INVALID_COLLECT_VALUE,ne.PIN,ne.EXPIRATION_MONTH,ne.EXPIRATION_YEAR,ne.CVV,ne.EXPIRATION_DATE,ne.CARD_NUMBER,ne.CARDHOLDER_NAME,ne.INPUT_FIELD,B.DEFAULT_REQUIRED_COLLECT_VALUE,ne.PIN,ne.EXPIRATION_MONTH,ne.EXPIRATION_YEAR;const ve=[ne.CARDHOLDER_NAME,ne.EXPIRATION_MONTH,ne.PIN,ne.CVV],me={X:"[0-9]"};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(){"use strict";function e(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(i[n[o]]=e[n[o]])}return i}function t(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{l(n.next(e))}catch(e){s(e)}}function a(e){try{l(n.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}l((n=n.apply(e,t||[])).next())}))}function i(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)}function n(e,t,i,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,i):o?o.value=i:t.set(e,i),i}exports.ElementType=void 0,function(e){e.CARD_NUMBER="CARD_NUMBER",e.CARDHOLDER_NAME="CARDHOLDER_NAME",e.CVV="CVV",e.EXPIRATION_MONTH="EXPIRATION_MONTH",e.EXPIRATION_YEAR="EXPIRATION_YEAR",e.EXPIRATION_DATE="EXPIRATION_DATE"}(exports.ElementType||(exports.ElementType={})),"function"==typeof SuppressedError&&SuppressedError;var 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_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_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_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))(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: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.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: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"}};var n=(e=>(e.ERROR="payrails:error",e.INFO="payrails:info",e.DEBUG="payrails:debug",e.WARN="payrails:warn",e))(n||{});class o extends Error{constructor(e,t){var n;const{description:s,docUrl:r,cause:a}=null!=t?t:{},{description:l,docUrl:c}=i[e]||{},d=null!=(n=null!=s?s:l)?n:"An unknown error occurred",u=null!=r?r:c;super(d),this.name=e,this.docUrl=u,this.cause=a,this.message=d,Error.captureStackTrace&&Error.captureStackTrace(this,o)}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=o}(o);var s={};!function(e){var t=Object.defineProperty,i=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,s=(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)&&s(e,r,t[r]);if(i)for(var r of i(t))o.call(t,r)&&s(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_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_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_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))(a||{}),l=(e=>(e.ERROR="payrails:error",e.INFO="payrails:info",e.DEBUG="payrails:debug",e.WARN="payrails:warn",e))(l||{});class c{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 d(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var u,_={},p={};var E,h={};var I,v={};var m,y={};var L,A={};var f,O={};var T,C={};var R,g={};var N,S={};var P,b={};var D,M,w,k,Y={},U={};function x(){if(D)return U;D=1,Object.defineProperty(U,"__esModule",{value:!0}),U.Framebus=void 0;var e=$(),t="undefined"!=typeof window&&window.Promise,i=function(){function i(e){void 0===e&&(e={}),this.origin=e.origin||"*",this.channel=e.channel||"",this.verifyDomain=e.verifyDomain,this.targetFrames=e.targetFrames||[],this.limitBroadcastToFramesArray=Boolean(e.targetFrames),this.isDestroyed=!1,this.listeners=[],this.hasAdditionalChecksForOnListeners=Boolean(this.verifyDomain||this.limitBroadcastToFramesArray)}return i.setPromise=function(e){i.Promise=e},i.target=function(e){return new i(e)},i.prototype.addTargetFrame=function(e){this.limitBroadcastToFramesArray&&this.targetFrames.push(e)},i.prototype.include=function(t){return null!=t&&(null!=t.Window&&(t.constructor===t.Window&&(e.childWindows.push(t),!0)))},i.prototype.target=function(e){return i.target(e)},i.prototype.emit=function(t,i,n){if(this.isDestroyed)return!1;var o=this.origin;if(t=this.namespaceEvent(t),(0,e.isntString)(t))return!1;if((0,e.isntString)(o))return!1;"function"==typeof i&&(n=i,i=void 0);var s=(0,e.packagePayload)(t,o,i,n);return!!s&&(this.limitBroadcastToFramesArray?this.targetFramesAsWindows().forEach((function(t){(0,e.sendMessage)(t,s,o)})):(0,e.broadcast)(s,{origin:o,frame:window.top||window.self}),!0)},i.prototype.emitAsPromise=function(e,t){var n=this;return new i.Promise((function(i,o){n.emit(e,t,(function(e){i(e)}))||o(new Error('Listener not added for "'.concat(e,'"')))}))},i.prototype.on=function(t,i){if(this.isDestroyed)return!1;var n=this,o=this.origin,s=i;return t=this.namespaceEvent(t),!(0,e.subscriptionArgsInvalid)(t,s,o)&&(this.hasAdditionalChecksForOnListeners&&(s=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:s,originalHandler:i}),e.subscribers[o]=e.subscribers[o]||{},e.subscribers[o][t]=e.subscribers[o][t]||[],e.subscribers[o][t].push(s),!0)},i.prototype.off=function(t,i){var n=i;if(this.isDestroyed)return!1;if(this.verifyDomain)for(var o=0;o<this.listeners.length;o++){var s=this.listeners[o];s.originalHandler===i&&(n=s.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(o=0;o<a.length;o++)if(a[o]===n)return a.splice(o,1),!0;return!1},i.prototype.teardown=function(){if(!this.isDestroyed){this.isDestroyed=!0;for(var e=0;e<this.listeners.length;e++){var t=this.listeners[e];this.off(t.eventName,t.handler)}this.listeners.length=0}},i.prototype.passesVerifyDomainCheck=function(e){return!this.verifyDomain||this.checkOrigin(e)},i.prototype.targetFramesAsWindows=function(){return this.limitBroadcastToFramesArray?this.targetFrames.map((function(e){return e instanceof HTMLIFrameElement?e.contentWindow:e})).filter((function(e){return e})):[]},i.prototype.hasMatchingTargetFrame=function(e){if(!this.limitBroadcastToFramesArray)return!0;var t=this.targetFramesAsWindows().find((function(t){return t===e}));return Boolean(t)},i.prototype.checkOrigin=function(e){var t,i=document.createElement("a");return i.href=location.href,t="https:"===i.protocol?i.host.replace(/:443$/,""):"http:"===i.protocol?i.host.replace(/:80$/,""):i.host,i.protocol+"//"+t===e||(!this.verifyDomain||this.verifyDomain(e))},i.prototype.namespaceEvent=function(e){return this.channel?"".concat(this.channel,":").concat(e):e},i.Promise=t,i}();return U.Framebus=i,U}function F(){if(k)return Y;k=1;var e=Y&&Y.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Y,"__esModule",{value:!0}),Y.subscribeReplier=void 0;var t=x(),i=e((w||(w=1,M=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}),M));return Y.subscribeReplier=function(e,n){var o=(0,i.default)();return t.Framebus.target({origin:n}).on(o,(function i(s,r){e(s,r),t.Framebus.target({origin:n}).off(o,i)})),o},Y}var B,j={};var V,G={};var X,z,H,W,q={};function $(){return z||(z=1,e=_,t=_&&_.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),i=_&&_.__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 p;u=1,Object.defineProperty(p,"__esModule",{value:!0}),p.detach=p.attach=void 0;var e=$(),t=!1;return p.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},p.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},p}(),e),i(function(){if(E)return h;E=1,Object.defineProperty(h,"__esModule",{value:!0}),h.broadcastToChildWindows=void 0;var e=$();return h.broadcastToChildWindows=function(t,i,n){for(var o=e.childWindows.length-1;o>=0;o--){var s=e.childWindows[o];s.closed?e.childWindows.splice(o,1):n!==s&&(0,e.broadcast)(t,{origin:i,frame:s.top})}},h}(),e),i(function(){if(I)return v;I=1,Object.defineProperty(v,"__esModule",{value:!0}),v.broadcast=void 0;var e=$();return v.broadcast=function t(i,n){var o,s=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});o=a.frames[s];)t(i,{origin:r,frame:o}),s++}catch(e){}},v}(),e),i((m||(m=1,Object.defineProperty(y,"__esModule",{value:!0}),y.subscribers=y.childWindows=y.prefix=void 0,y.prefix="/*framebus*/",y.childWindows=[],y.subscribers={}),y),e),i(function(){if(L)return A;L=1,Object.defineProperty(A,"__esModule",{value:!0}),A.dispatch=void 0;var e=$();return A.dispatch=function(t,i,n,o,s){if(e.subscribers[t]&&e.subscribers[t][i]){var r=[];n&&r.push(n),o&&r.push(o);for(var a=0;a<e.subscribers[t][i].length;a++)e.subscribers[t][i][a].apply(s,r)}},A}(),e),i((f||(f=1,Object.defineProperty(O,"__esModule",{value:!0}),O.hasOpener=void 0,O.hasOpener=function(e){return e.top===e&&null!=e.opener&&e.opener!==e&&!0!==e.opener.closed}),O),e),i((T||(T=1,Object.defineProperty(C,"__esModule",{value:!0}),C.isntString=void 0,C.isntString=function(e){return"string"!=typeof e}),C),e),i(function(){if(R)return g;R=1,Object.defineProperty(g,"__esModule",{value:!0}),g.onMessage=void 0;var e=$();return g.onMessage=function(t){if(!(0,e.isntString)(t.data)){var i=(0,e.unpackPayload)(t);if(i){var n=i.eventData,o=i.reply;(0,e.dispatch)("*",i.event,n,o,t),(0,e.dispatch)(t.origin,i.event,n,o,t),(0,e.broadcastToChildWindows)(t.data,i.origin,t.source)}}},g}(),e),i(function(){if(N)return S;N=1,Object.defineProperty(S,"__esModule",{value:!0}),S.packagePayload=void 0;var e=$();return S.packagePayload=function(t,i,n,o){var s,r={event:t,origin:i};"function"==typeof o&&(r.reply=(0,e.subscribeReplier)(o,i)),r.eventData=n;try{s=e.prefix+JSON.stringify(r)}catch(e){throw new Error("Could not stringify event: ".concat(e.message))}return s},S}(),e),i((P||(P=1,Object.defineProperty(b,"__esModule",{value:!0}),b.sendMessage=void 0,b.sendMessage=function(e,t,i){try{e.postMessage(t,i)}catch(e){}}),b),e),i(F(),e),i(function(){if(B)return j;B=1,Object.defineProperty(j,"__esModule",{value:!0}),j.subscriptionArgsInvalid=void 0;var e=$();return j.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},j}(),e),i((V||(V=1,Object.defineProperty(G,"__esModule",{value:!0})),G),e),i(function(){if(X)return q;X=1,Object.defineProperty(q,"__esModule",{value:!0}),q.unpackPayload=void 0;var e=$();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,o=t.source,s=i.reply;i.reply=function(t){if(o){var i=(0,e.packagePayload)(s,n,t);i&&o.postMessage(i,n)}}}return i},q}(),e)),_;var e,t,i}const K=d(function(){if(W)return H;W=1;var e=$(),t=x();return(0,e.attach)(),H=t.Framebus}());class J{constructor(e){this.origin=null,this.listeners=[],this.bus=new K(e)}static getInstance(){return J.instance||(J.instance=new J),J.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 Z{constructor(){this.bus=J.getInstance()}log(e,t){this.bus.emit(l.ERROR,{level:e,event:t})}}var Q,ee;const te=d(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 o(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 s(e,t){try{return t in e}catch(e){return!1}}function r(e,t,n){var r={};return n.isMergeableObject(e)&&o(e).forEach((function(t){r[t]=i(e[t],n)})),o(t).forEach((function(o){(function(e,t){return s(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,o)||(s(e,o)&&n.isMergeableObject(t[o])?r[o]=function(e,t){if(!t.customMerge)return a;var i=t.customMerge(e);return"function"==typeof i?i:a}(o,n)(e[o],t[o],n):r[o]=i(t[o],n))})),r}function a(t,o,s){(s=s||{}).arrayMerge=s.arrayMerge||n,s.isMergeableObject=s.isMergeableObject||e,s.cloneUnlessOtherwiseSpecified=i;var a=Array.isArray(o);return a===Array.isArray(t)?a?s.arrayMerge(t,o,s):r(t,o,s):i(o,s)}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(),oe=()=>window&&window.navigator,se=()=>window&&window.screen,re=()=>({resolution:`${se().width}x${se().height}`,user_agent:oe().userAgent,language:oe().language}),ae=[a.PAYRAILS_API_AUTHORIZATION_ERROR,a.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR];class le{constructor(e){this.adapter=[new Z],this.enabled=e.enabled||!0,this.initGlobalState(e),e.logLevel=e.logLevel||"error","debug"===e.logLevel&&this.addAdapter(new c)}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}(s);const r=[];for(let e=0;e<256;++e)r.push((e+256).toString(16).slice(1));let a;const l=new Uint8Array(16);var c={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function d(e,t,i){if(c.randomUUID&&!t&&!e)return c.randomUUID();const n=(e=e||{}).random??e.rng?.()??function(){if(!a){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");a=crypto.getRandomValues.bind(crypto)}return a(l)}();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){if((i=i||0)<0||i+16>t.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[i+e]=n[e];return t}return function(e,t=0){return(r[e[t+0]]+r[e[t+1]]+r[e[t+2]]+r[e[t+3]]+"-"+r[e[t+4]]+r[e[t+5]]+"-"+r[e[t+6]]+r[e[t+7]]+"-"+r[e[t+8]]+r[e[t+9]]+"-"+r[e[t+10]]+r[e[t+11]]+r[e[t+12]]+r[e[t+13]]+r[e[t+14]]+r[e[t+15]]).toLowerCase()}(n)}var u;!function(e){e.GET="GET",e.POST="POST"}(u||(u={}));const _=e=>t(void 0,[e],void 0,(function*({url:e,method:t=u.GET,token:i="",body:n}){const o={method:t,headers:Object.assign(Object.assign(Object.assign({},m()),v(i)),y())};t===u.POST&&(o.body=JSON.stringify(n||{}));const s=yield fetch(e,o),r=yield s.json();if([401,403].includes(s.status))throw new p(e,t);if(429===s.status)throw new h(e,t);if(!s.ok)throw new E(e,t);return{ok:s.ok,req:Object.assign({url:e},o),res:r}}));class p extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_UNAUTHORIZED,{description:`[${t}] ${e} unauthorized`})}}let E=class extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{description:`[${t}] ${e} unsuccessful`})}},h=class extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} too many requests`})}};class I extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} max poll attempts exceeded.`})}}const v=e=>({authorization:`Bearer ${e}`}),m=()=>({"x-idempotency-key":d()}),y=()=>{const e={version:"5.25.0",type:"web-sdk"};return{"x-client-version":e.version,"x-client-type":e.type}},L=(e,i)=>t(void 0,void 0,void 0,(function*(){var t,n;if(null==e?void 0:e.onPaymentButtonClicked)try{const n=yield e.onPaymentButtonClicked(i);if(!n){const i=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onPaymentButtonClicked resolved to false"});return null===(t=null==e?void 0:e.onAuthorizeFailed)||void 0===t||t.call(e,{code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:i.message}),n}}catch(t){const i=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onPaymentButtonClicked threw an error",cause:t});return null===(n=e.onAuthorizeFailed)||void 0===n||n.call(e,{code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:i.message}),!1}return!0}));var A,f,O,T;exports.PAYMENT_METHOD_CODES=void 0,(A=exports.PAYMENT_METHOD_CODES||(exports.PAYMENT_METHOD_CODES={})).CARD="card",A.GOOGLE_PAY="googlePay",A.PAYPAL="payPal",A.APPLE_PAY="applePay",A.GENERIC_REDIRECT="genericRedirect",function(e){e.ENABLED="enabled",e.CREATED="created",e.DELETED="deleted",e.DISABLED="disabled",e.INVALID="invalid",e.TRANSIENT="transient"}(f||(f={}));class C{static get response(){if(!C._response){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND);throw s.PayrailsLogger.error(e.message,{error:e}),e}return C._response}static setResponse(e){return C._response=e,C}static get lookup(){return C.response.initialResults.find((({body:{name:e}})=>"lookup"===e))}static get holderReference(){return C.response.holderReference}static get savedCreditCards(){return C.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.CARD)}static get savedPaypalAccounts(){return C.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.PAYPAL).filter((({status:e})=>e===f.ENABLED))}static get savedGooglePayAccounts(){return C.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.GOOGLE_PAY).filter((({status:e})=>e===f.ENABLED))}static get savedApplePayAccounts(){return C.getStoredInstrumentForPaymentMethod(exports.PAYMENT_METHOD_CODES.APPLE_PAY)}static get paypalConfig(){const e=C.availablePaymentMethods.find((({paymentMethodCode:e})=>e===exports.PAYMENT_METHOD_CODES.PAYPAL));if(!e){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING);throw s.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:C.availablePaymentMethods}}),e}return e.config||{}}static get googlePayConfig(){const e=C.availablePaymentMethods.find((({paymentMethodCode:e})=>e===exports.PAYMENT_METHOD_CODES.GOOGLE_PAY));if(!e){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING);throw s.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:C.availablePaymentMethods}}),e}return e?[e.config]:[]}static isPaymentMethodAvailable(e){return C.availablePaymentMethods.some((({paymentMethodCode:t})=>t===e))}static get applePayConfig(){const e=C.availablePaymentMethods.find((({paymentMethodCode:e})=>e===exports.PAYMENT_METHOD_CODES.APPLE_PAY));if(!e){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING);throw s.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:C.availablePaymentMethods}}),e}return e.config.parameters}static get url(){return C.response.links.self}static get meta(){return C.response.meta}static get availablePaymentMethods(){var e;return(null===(e=C.lookup)||void 0===e?void 0:e.body.data.paymentCompositionOptions)||[]}static get authorizeLink(){var e;return null===(e=C.lookup)||void 0===e?void 0:e.body.links.authorize.href}static get createSessionLink(){var e;return null===(e=C.response.links.startPaymentSession)||void 0===e?void 0:e.href}static get storedPaymentInstruments(){return C.availablePaymentMethods.flatMap((e=>e.paymentInstruments||[])).filter((({paymentMethod:e,status:t})=>t===f.ENABLED||![exports.PAYMENT_METHOD_CODES.GOOGLE_PAY,exports.PAYMENT_METHOD_CODES.PAYPAL].includes(e)))}static get storedDropinInstruments(){return C.storedPaymentInstruments.filter((({paymentMethod:e})=>![exports.PAYMENT_METHOD_CODES.GOOGLE_PAY,exports.PAYMENT_METHOD_CODES.APPLE_PAY].includes(e)))}static getFullPaymentMethodConfig(e){return C.availablePaymentMethods.find((({paymentMethodCode:t})=>t===e))}static isAddressSelectorEnabled(e){var t,i;return!!C._response&&(null===(i=null===(t=C.getFullPaymentMethodConfig(e))||void 0===t?void 0:t.clientConfig)||void 0===i?void 0:i.supportsBillingInfo)}static isPaymentInstallmentsEnabled(e){var t;if(C._response){const i=this.getFullPaymentMethodConfig(e);return i&&(null===(t=this.getPaymentMethodConfig(i).clientConfig)||void 0===t?void 0:t.supportsInstallments)}return!1}static getPaymentInstallmentOptions(e){var t;const i=this.getFullPaymentMethodConfig(e);return i&&(null===(t=this.getPaymentMethodConfig(i).clientConfig)||void 0===t?void 0:t.installments)||{}}static getStoredInstrumentForPaymentMethod(e){var t;return(null===(t=this.availablePaymentMethods.find((({paymentMethodCode:t})=>t===e)))||void 0===t?void 0:t.paymentInstruments)||[]}static getPaymentMethodForStoredInstrument(e){const t=this.availablePaymentMethods.find((({paymentInstruments:t})=>null==t?void 0:t.some((({id:t})=>t===e.id))));return t&&this.getPaymentMethodConfig(t)}static getPaymentMethodConfig(t){return e(t,["paymentInstruments"])}}!function(e){e.REDIRECT="redirect",e.DIRECT="direct"}(O||(O={})),exports.INTEGRATION_TYPE=void 0,(T=exports.INTEGRATION_TYPE||(exports.INTEGRATION_TYPE={})).API="api",T.HPP="hpp";class R{constructor(){this._config=void 0}static getInstance(){return R._instance||(R._instance=new R),R._instance}set config(e){try{R.getInstance()._config=e}catch(e){s.PayrailsLogger.error("Error parsing SDK Configuration",{error:e})}}get config(){return R.getInstance()._config||s.PayrailsLogger.error("SDK Configuration not set"),R.getInstance()._config||{}}}const g=()=>R.getInstance().config,N=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));R.getInstance().config=t,t.execution&&C.setResponse(t.execution)}catch(e){s.PayrailsLogger.error("Error parsing SDK Configuration",{error:e})}},S={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 P{static getInstance(){return this.instance||(this.instance=new P),this.instance}constructor(e=""){this.lastActionUpdateTime=e,P.instance=this}}class b{constructor(e=S,t=680,i=60,n=2e3,o=5,s=P.getInstance()){this.returnLinks=e,this.POLL_INTERVAL=t,this.MAX_POLL_ATTEMPTS=i,this.POLL_INITIAL_DELAY=n,this.POLL_ERROR_COUNT_MULTIPLIER=o,this.paymentStatus=s}pay(e){return t(this,void 0,void 0,(function*(){try{const t=(yield this.authorize(e)).res.links.execution;return yield this.pollForAuthorizationResult(t)}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR,{cause:e});throw s.PayrailsLogger.error(t.message,{error:t}),e}}))}confirm(e){return t(this,arguments,void 0,(function*(e,t={}){try{const i=yield _({url:e,method:u.POST,token:g().token,body:{data:t}}),n=yield this.pollForAuthorizationResult(i.res.links.execution);if(n.finalState)return n;const o=n.response.status.slice().sort(((e,t)=>new Date(t.time).getTime()-new Date(e.time).getTime()))[0].time,{res:s}=yield this.getExecution(i.res.links.execution,o);return{finalState:s.status.find((({code:e,time:t})=>["authorizeSuccessful","authorizeFailed"].includes(e)&&new Date(t)>new Date(o))),response:s}}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR,{cause:e});throw s.PayrailsLogger.error(t.message,{error:t}),e}}))}getExecution(e,i){return t(this,arguments,void 0,(function*(e,t,i=0){if(i>this.MAX_POLL_ATTEMPTS)throw new I(e,u.GET);0===i&&t?yield this.wait(this.POLL_INITIAL_DELAY):yield this.wait(this.POLL_INTERVAL);try{const n=yield _({url:e,token:g().token});if(t){if(!n.res.status.find((({time:e})=>new Date(e)>new Date(t))))return yield this.wait(this.POLL_INTERVAL),this.getExecution(e,t,i+1)}return n}catch(n){if(n instanceof E)return yield this.wait(this.POLL_INTERVAL),this.getExecution(e,t,i+this.POLL_ERROR_COUNT_MULTIPLIER);if(n instanceof h)return yield this.wait(this.POLL_INTERVAL*i),this.getExecution(e,t,i+1);throw n}}))}createApplePaySession(e){return t(this,void 0,void 0,(function*(){return _({url:e.requestUrl,method:u.POST,token:g().token,body:{integrationType:"api",paymentMethodCode:"applePay",amount:g().amount,meta:{sessionURL:e.sessionUrl,clientContext:{host:e.clientDomain||window.location.host}}}})}))}authorize(e){return t(this,void 0,void 0,(function*(){if(!C.authorizeLink||!g().amount){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND,{description:"SDK was not initialized with workflow execution"});throw s.PayrailsLogger.error(e.message,{error:e}),e}const{success:t=S.success,error:i=S.error,cancel:n=S.cancel,pending:r=S.pending}=this.returnLinks,a=this.attachRiskIdToPaymentComposition({amount:g().amount,paymentComposition:e,returnInfo:{success:t,cancel:n,error:i,pending:r}});return _({url:C.authorizeLink,method:u.POST,token:g().token,body:a})}))}getFirstNonFraudNetId(e){const t=Object.keys(e||{}).find((e=>"fraudNet"!==e));return t?e[t]:null}attachRiskIdToPaymentComposition(e){var t,i,n,o,s;let r;return r=e.paymentComposition[0].paymentMethodCode===exports.PAYMENT_METHOD_CODES.PAYPAL&&(null===(i=null===(t=window.PayrailsData)||void 0===t?void 0:t.riskIds)||void 0===i?void 0:i.fraudNet)?null===(o=null===(n=window.PayrailsData)||void 0===n?void 0:n.riskIds)||void 0===o?void 0:o.fraudNet:this.getFirstNonFraudNetId(null===(s=window.PayrailsData)||void 0===s?void 0:s.riskIds)||"",r?Object.assign(Object.assign({},e),{meta:{risk:{sessionId:r}}}):e}wait(e){return t(this,void 0,void 0,(function*(){return new Promise((t=>setTimeout(t,e)))}))}pollForAuthorizationResult(e){return t(this,arguments,void 0,(function*(e,t=0,i=["authorizePending","authorizeSuccessful","authorizeFailed"]){const n=(yield this.getExecution(e,this.paymentStatus.lastActionUpdateTime,t)).res,r=n.status,a=r.find((({code:e})=>"authorizeRequested"===e));if(!a&&t<10)return yield new Promise((e=>setTimeout(e,this.POLL_INTERVAL))),this.pollForAuthorizationResult(e,t+1);if(!a){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED);throw s.PayrailsLogger.error(e.message,{error:e}),e}const l=r.find((({code:e,time:t})=>"confirmRequested"===e&&new Date(t)>new Date(a.time))),c=l?l.time:a.time,d=r.filter((({code:e,time:t})=>i.includes(e)&&new Date(t)>new Date(c))).sort(((e,t)=>new Date(t.time).getTime()-new Date(e.time).getTime()))[0];return d?(this.paymentStatus.lastActionUpdateTime=d.time,{finalState:d,response:n}):this.pollForAuthorizationResult(e,t+1,i)}))}}class D{constructor(e,t,i,n=M.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,400]],this.internalPopupBackground=null,this.SCREEN_WIDTH=window.innerWidth,this.SCREEN_HEIGHT=window.innerHeight}get iframeSize(){return this.type===M.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 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()),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}handleMessages(){const e=i=>t(this,void 0,void 0,(function*(){var t,n,o,s,r,a,l;if(i.data&&'{"type":"3DS-challenge-completed"}'===i.data){window.removeEventListener("message",e);switch(null===(t=(yield this.paymentExecutor.pollForAuthorizationResult(C.url)).finalState)||void 0===t?void 0:t.code){case"authorizeSuccessful":null===(o=null===(n=this.options.events)||void 0===n?void 0:n.onAuthorizeSuccess)||void 0===o||o.call(n);break;case"authorizePending":null===(r=null===(s=this.options.events)||void 0===s?void 0:s.onAuthorizePending)||void 0===r||r.call(s);break;default:null===(l=null===(a=this.options.events)||void 0===a?void 0:a.onAuthorizeFailed)||void 0===l||l.call(a,{code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:"Authorization failed after 3DS challenge."})}this.unmount()}}));window.addEventListener("message",e)}mount(){var e;this.popup.remove(),null===(e=document.querySelector("body"))||void 0===e||e.appendChild(this.popupBackground),this.handleMessages()}unmount(){this.popupBackground.remove(),this.internalPopupBackground=null}}var M;!function(e){e[e.THREE_DS=0]="THREE_DS",e[e.GENERIC_REDIRECT=1]="GENERIC_REDIRECT"}(M||(M={}));class w{constructor(e,t){this.options=e,this.paymentExecutor=t}handle3ds(e){var t,i,n;try{null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onThreeDSecureChallenge)||void 0===i||i.call(t)}catch(e){}const o=null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.links["3ds"];if(o)if(this.options.redirectFor3DS)window.location.assign(o);else{new D(o,this.paymentExecutor,this.options).mount()}}}var k,Y={};!function(e){function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var i,n={},o={};var s,r={};var a,l={};var c,d={};var u,_={};var p,E={};var h,I={};var v,m={};var y,L={};var A,f={};var O,T,C,R,g={},N={};function S(){if(O)return N;O=1,Object.defineProperty(N,"__esModule",{value:!0}),N.Framebus=void 0;var e=B(),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 o=this.origin;if(t=this.namespaceEvent(t),(0,e.isntString)(t))return!1;if((0,e.isntString)(o))return!1;"function"==typeof i&&(n=i,i=void 0);var s=(0,e.packagePayload)(t,o,i,n);return!!s&&(this.limitBroadcastToFramesArray?this.targetFramesAsWindows().forEach((function(t){(0,e.sendMessage)(t,s,o)})):(0,e.broadcast)(s,{origin:o,frame:window.top||window.self}),!0)},i.prototype.emitAsPromise=function(e,t){var n=this;return new i.Promise((function(i,o){n.emit(e,t,(function(e){i(e)}))||o(new Error('Listener not added for "'.concat(e,'"')))}))},i.prototype.on=function(t,i){if(this.isDestroyed)return!1;var n=this,o=this.origin,s=i;return t=this.namespaceEvent(t),!(0,e.subscriptionArgsInvalid)(t,s,o)&&(this.hasAdditionalChecksForOnListeners&&(s=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:s,originalHandler:i}),e.subscribers[o]=e.subscribers[o]||{},e.subscribers[o][t]=e.subscribers[o][t]||[],e.subscribers[o][t].push(s),!0)},i.prototype.off=function(t,i){var n=i;if(this.isDestroyed)return!1;if(this.verifyDomain)for(var o=0;o<this.listeners.length;o++){var s=this.listeners[o];s.originalHandler===i&&(n=s.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(o=0;o<a.length;o++)if(a[o]===n)return a.splice(o,1),!0;return!1},i.prototype.teardown=function(){if(!this.isDestroyed){this.isDestroyed=!0;for(var e=0;e<this.listeners.length;e++){var t=this.listeners[e];this.off(t.eventName,t.handler)}this.listeners.length=0}},i.prototype.passesVerifyDomainCheck=function(e){return!this.verifyDomain||this.checkOrigin(e)},i.prototype.targetFramesAsWindows=function(){return this.limitBroadcastToFramesArray?this.targetFrames.map((function(e){return e instanceof HTMLIFrameElement?e.contentWindow:e})).filter((function(e){return e})):[]},i.prototype.hasMatchingTargetFrame=function(e){if(!this.limitBroadcastToFramesArray)return!0;var t=this.targetFramesAsWindows().find((function(t){return t===e}));return Boolean(t)},i.prototype.checkOrigin=function(e){var t,i=document.createElement("a");return i.href=location.href,t="https:"===i.protocol?i.host.replace(/:443$/,""):"http:"===i.protocol?i.host.replace(/:80$/,""):i.host,i.protocol+"//"+t===e||(!this.verifyDomain||this.verifyDomain(e))},i.prototype.namespaceEvent=function(e){return this.channel?"".concat(this.channel,":").concat(e):e},i.Promise=t,i}();return N.Framebus=i,N}function P(){if(R)return g;R=1;var e=g&&g.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(g,"__esModule",{value:!0}),g.subscribeReplier=void 0;var t=S(),i=e((C||(C=1,T=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)}))}),T));return g.subscribeReplier=function(e,n){var o=(0,i.default)();return t.Framebus.target({origin:n}).on(o,(function i(s,r){e(s,r),t.Framebus.target({origin:n}).off(o,i)})),o},g}var b,D={};var M,w={};var k,Y,U,x,F={};function B(){return Y||(Y=1,e=n,t=n&&n.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),O=n&&n.__exportStar||function(e,i){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(i,n)||t(i,e,n)},Object.defineProperty(e,"__esModule",{value:!0}),O(function(){if(i)return o;i=1,Object.defineProperty(o,"__esModule",{value:!0}),o.detach=o.attach=void 0;var e=B(),t=!1;return o.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},o.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},o}(),e),O(function(){if(s)return r;s=1,Object.defineProperty(r,"__esModule",{value:!0}),r.broadcastToChildWindows=void 0;var e=B();return r.broadcastToChildWindows=function(t,i,n){for(var o=e.childWindows.length-1;o>=0;o--){var s=e.childWindows[o];s.closed?e.childWindows.splice(o,1):n!==s&&(0,e.broadcast)(t,{origin:i,frame:s.top})}},r}(),e),O(function(){if(a)return l;a=1,Object.defineProperty(l,"__esModule",{value:!0}),l.broadcast=void 0;var e=B();return l.broadcast=function t(i,n){var o,s=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});o=a.frames[s];)t(i,{origin:r,frame:o}),s++}catch(e){}},l}(),e),O((c||(c=1,Object.defineProperty(d,"__esModule",{value:!0}),d.subscribers=d.childWindows=d.prefix=void 0,d.prefix="/*framebus*/",d.childWindows=[],d.subscribers={}),d),e),O(function(){if(u)return _;u=1,Object.defineProperty(_,"__esModule",{value:!0}),_.dispatch=void 0;var e=B();return _.dispatch=function(t,i,n,o,s){if(e.subscribers[t]&&e.subscribers[t][i]){var r=[];n&&r.push(n),o&&r.push(o);for(var a=0;a<e.subscribers[t][i].length;a++)e.subscribers[t][i][a].apply(s,r)}},_}(),e),O((p||(p=1,Object.defineProperty(E,"__esModule",{value:!0}),E.hasOpener=void 0,E.hasOpener=function(e){return e.top===e&&null!=e.opener&&e.opener!==e&&!0!==e.opener.closed}),E),e),O((h||(h=1,Object.defineProperty(I,"__esModule",{value:!0}),I.isntString=void 0,I.isntString=function(e){return"string"!=typeof e}),I),e),O(function(){if(v)return m;v=1,Object.defineProperty(m,"__esModule",{value:!0}),m.onMessage=void 0;var e=B();return m.onMessage=function(t){if(!(0,e.isntString)(t.data)){var i=(0,e.unpackPayload)(t);if(i){var n=i.eventData,o=i.reply;(0,e.dispatch)("*",i.event,n,o,t),(0,e.dispatch)(t.origin,i.event,n,o,t),(0,e.broadcastToChildWindows)(t.data,i.origin,t.source)}}},m}(),e),O(function(){if(y)return L;y=1,Object.defineProperty(L,"__esModule",{value:!0}),L.packagePayload=void 0;var e=B();return L.packagePayload=function(t,i,n,o){var s,r={event:t,origin:i};"function"==typeof o&&(r.reply=(0,e.subscribeReplier)(o,i)),r.eventData=n;try{s=e.prefix+JSON.stringify(r)}catch(e){throw new Error("Could not stringify event: ".concat(e.message))}return s},L}(),e),O((A||(A=1,Object.defineProperty(f,"__esModule",{value:!0}),f.sendMessage=void 0,f.sendMessage=function(e,t,i){try{e.postMessage(t,i)}catch(e){}}),f),e),O(P(),e),O(function(){if(b)return D;b=1,Object.defineProperty(D,"__esModule",{value:!0}),D.subscriptionArgsInvalid=void 0;var e=B();return D.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},D}(),e),O((M||(M=1,Object.defineProperty(w,"__esModule",{value:!0})),w),e),O(function(){if(k)return F;k=1,Object.defineProperty(F,"__esModule",{value:!0}),F.unpackPayload=void 0;var e=B();return F.unpackPayload=function(t){var i;if(t.data.slice(0,e.prefix.length)!==e.prefix)return!1;try{i=JSON.parse(t.data.slice(e.prefix.length))}catch(e){return!1}if(i.reply){var n=t.origin,o=t.source,s=i.reply;i.reply=function(t){if(o){var i=(0,e.packagePayload)(s,n,t);i&&o.postMessage(i,n)}}}return i},F}(),e)),n;var e,t,O}const j=t(function(){if(x)return U;x=1;var e=B(),t=S();return(0,e.attach)(),U=t.Framebus}());class V{constructor(e){this.origin=null,this.listeners=[],this.bus=new j(e)}static getInstance(){return V.instance||(V.instance=new V),V.instance}on(e,t){return this.bus.on(e,t)}off(e,t){return this.bus.off(e,t)}emit(e,t,i=void 0){return this.bus.emit(e,t,i)}target(e){return this.bus.target(e)}}e.IframeEventBus=V,e.getEventBus=()=>V.getInstance()}(Y);class U{constructor(e,{id:t="",className:i=""}={}){this.subElements=[],this.eventBus=Y.getEventBus();const n=document.createElement(e);t&&(this.id=t,n.setAttribute("id",t)),i&&(Array.isArray(i)?n.setAttribute("class",function(...e){return e.filter(Boolean).join(" ")}(...i)):n.setAttribute("class",i)),this.element=n}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 x extends U{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.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 b(this.returnInfo)}setDisabled(e){var t,i,n,o,s;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===(o=this.options.styles)||void 0===o?void 0:o.disabled)||{}),(null===(s=this.options.styles)||void 0===s?void 0:s.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,o;const s=this.element.offsetWidth;this.element.style.minWidth=`${s}px`,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===(o=this.options.styles)||void 0===o?void 0:o.loading)||{}))}onAuthorizationFailed(e){var t,i;this.setDisabled(!1),this.triggerLoading(!1),(null===(t=this.options.events)||void 0===t?void 0:t.onAuthorizeFailed)&&(null===(i=this.options.events)||void 0===i||i.onAuthorizeFailed(e))}onPay(){return t(this,void 0,void 0,(function*(){var e,t,i,n,r,a,l,c,d,u,_,E,h;let I;if(this.setDisabled(!0),this.triggerLoading(!0),!(null===(e=this.selectedInstrument)||void 0===e?void 0:e.id)&&(I=null===(i=yield null===(t=this.cardForm)||void 0===t?void 0:t.validate())||void 0===i?void 0:i.isValid,!I))return this.setDisabled(!1),void this.triggerLoading(!1);if(I=yield L(this.options.events,{bin:this.bin||""}),!I)return this.setDisabled(!1),void this.triggerLoading(!1);try{let e=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.CARD,integrationType:"api",amount:g().amount,storeInstrument:!1}];if(null===(n=this.selectedInstrument)||void 0===n?void 0:n.id)e[0].paymentInstrumentId=null===(r=this.selectedInstrument)||void 0===r?void 0:r.id,e[0].paymentMethodCode=null===(a=this.selectedInstrument)||void 0===a?void 0:a.paymentMethod,this.paymentInstallmentElement&&(null===(l=this.paymentInstallmentElement)||void 0===l?void 0:l.selectedInstallmentValue)&&(e[0].installments={count:null===(c=this.paymentInstallmentElement)||void 0===c?void 0:c.selectedInstallmentValue});else{if(!this.cardForm){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CARD_FORM_MISSING);throw s.PayrailsLogger.error(e.message,{error:e}),e}e=yield this.constructEncryptedPayment(e)}const t=yield this.paymentExecutor.pay(e);this.handleAuthorizationResult(t)}catch(e){let t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_AUTHENTICATION_ERROR,{cause:e});e instanceof p||[401,403].includes(null===(d=null==e?void 0:e.error)||void 0===d?void 0:d.code)?(null===(_=null===(u=this.options.events)||void 0===u?void 0:u.onPaymentSessionExpired)||void 0===_||_.call(u),t.message="API token is not valid or expired.",s.PayrailsLogger.error(t.message,{error:t}),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:t.message})):e.toString().includes("Invalid token")?(null===(h=null===(E=this.options.events)||void 0===E?void 0:E.onPaymentSessionExpired)||void 0===h||h.call(E),t.message="Vault token is not valid or expired.",s.PayrailsLogger.error(t.message,{error:t})):t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_UNKNOWN_ERROR,{cause:e}),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:t.message})}}))}constructEncryptedPayment(e){return t(this,void 0,void 0,(function*(){if(!this.cardForm)throw new 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}))}handleAuthorizationResult(e){var t,i,n,s,r,a,l;let c;switch(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code){case"authorizeSuccessful":this.triggerLoading(!1),null===(n=null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeSuccess)||void 0===n||n.call(i);break;case"authorizePending":if("3ds"===(null===(s=null==e?void 0:e.response)||void 0===s?void 0:s.actionRequired)){new w(Object.assign(Object.assign({},this.options),{events:Object.assign(Object.assign({},this.options.events),{onAuthorizeFailed:e=>{this.onAuthorizationFailed(e)}})}),this.paymentExecutor).handle3ds(e)}else(null===(r=null==e?void 0:e.response)||void 0===r?void 0:r.actionRequired)||(this.triggerLoading(!1),null===(l=null===(a=this.options.events)||void 0===a?void 0:a.onAuthorizePending)||void 0===l||l.call(a));break;default:c=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_ERROR),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:c.message})}}}exports.AuthorizationFailureReasons=void 0,(k=exports.AuthorizationFailureReasons||(exports.AuthorizationFailureReasons={})).VALIDATION_FAILED="VALIDATION_FAILED",k.AUTHORIZATION_ERROR="AUTHORIZATION_ERROR",k.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",k.UNKNOWN_ERROR="UNKNOWN_ERROR";const F={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."},B={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."},j={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."},V="collect_controller",G="element",X="ERROR",z={CHANGE:"CHANGE",READY:"READY",FOCUS:"FOCUS",BLUR:"BLUR",ESCAPE:"ESCAPE",CLICK:"CLICK",ERROR:"ERROR",SUCCESS:"SUCCESS",SUBMIT:"SUBMIT",CREATED:"CREATED",MOUNTED:"MOUNTED",HEIGHT:"HEIGHT"},H="FRAME_READY",W="TOKENIZATION_REQUEST",q="INPUT_EVENT",$="DESTROY FRAME",K="SET_VALUE",J="GET_BEARER_TOKEN",Z="COLLECT_ELEMENT_SET_ERROR",Q="COMPOSABLE_UPDATE_OPTIONS",ee="VALIDATE_ELEMENT",te="COMPOSABLE_CONTAINER_MOUNTED",ie="COLLECT_CONTAINER_MOUNTED";var ne,oe;!function(e){e.CVV="CVV",e.EXPIRATION_DATE="EXPIRATION_DATE",e.CARD_NUMBER="CARD_NUMBER",e.CARDHOLDER_NAME="CARDHOLDER_NAME",e.INPUT_FIELD="INPUT_FIELD",e.PIN="PIN",e.EXPIRATION_MONTH="EXPIRATION_MONTH",e.EXPIRATION_YEAR="EXPIRATION_YEAR"}(ne||(ne={})),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"}(oe||(oe={}));const se={[oe.AMEX]:["XXXX XXXXXX XXXXX",{X:"[0-9]"}],[oe.VISA]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[oe.MASTERCARD]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[oe.DISCOVER]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[oe.DINERS_CLUB]:["XXXX XXXXXX XXXXXX",{X:"[0-9]"}],[oe.JCB]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[oe.MAESTRO]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[oe.UNIONPAY]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[oe.HIPERCARD]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[oe.DEFAULT]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[oe.UNKNOWN]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}]},re={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},[ne.CARDHOLDER_NAME]:{name:"cardHolderName",attributes:{type:"text",autocomplete:"cc-name"},sensitive:!0,regex:/^([a-zA-Z\\ \\,\\.\\-\\']{2,})$/},[ne.CARD_NUMBER]:{name:"CARD_NUMBER",attributes:{type:"text",autocomplete:"cc-number",inputmode:"numeric"},sensitive:!0,mask:se[oe.DEFAULT],regex:/$|^[\s]*?([0-9]{2,6}[ -]?){3,5}[\s]*/},[ne.EXPIRATION_DATE]:{name:"EXPIRATION_DATE",attributes:{type:"text",autocomplete:"cc-exp",inputmode:"numeric"},sensitive:!0},[ne.EXPIRATION_MONTH]:{name:"EXPIRATION_MONTH",attributes:{maxLength:2,type:"text",inputmode:"numeric",autocomplete:"cc-exp-month"},sensitive:!0,mask:["XX",{X:"[0-9]"}]},[ne.EXPIRATION_YEAR]:{name:"EXPIRATION_YEAR",attributes:{type:"text",inputmode:"numeric",autocomplete:"cc-exp-year"},sensitive:!0},[ne.CVV]:{name:"CVV",attributes:{type:"text",inputmode:"numeric",maxLength:3},sensitive:!0,regex:/^$|^[0-9]{3,4}$/},[ne.INPUT_FIELD]:{name:"INPUT_FIELD",sensitive:!0,attributes:{type:"text"}},[ne.PIN]:{name:"PIN",attributes:{type:"text",inputmode:"numeric",maxLength:12,minLength:4},sensitive:!0,regex:/^$|^[0-9]{4,12}$/}},ae="XXXX-XXXX-XXXX-XXXX",le={height:"100%",width:"100%",margin:0,padding:0,border:0,position:"absolute",top:0,left:0,"user-select":"none"},ce={position:"absolute",top:0,width:0,height:0,visibility:"hidden",left:"-99999999px","user-select":"none"},de={width:"100%",height:"100%",border:"0",padding:"0",margin:"0",outline:"none"},ue={WEBPACKAUTOFILL:"-webkit-autofill",BASE:"base",FOCUS:"focus",COMPLETE:"complete",EMPTY:"empty",INVALID:"invalid",GLOBAL:"global",REQUIRED_ASTERISK:"requiredAsterisk"},_e={[oe.VISA]:{regex:/^4\d*/,maxCardLength:19,cardLengthRange:[13,16]},[oe.MASTERCARD]:{regex:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,maxCardLength:16,cardLengthRange:[16]},[oe.AMEX]:{regex:/^3[47]\d*/,maxCardLength:15,cardLengthRange:[15]},[oe.DINERS_CLUB]:{regex:/^(36|38|30[0-5])\d*/,maxCardLength:16,cardLengthRange:[14,15,16,17,18,19]},[oe.DISCOVER]:{regex:/^(6011|65|64[4-9]|622)\d*/,maxCardLength:16,cardLengthRange:[16,17,18,19]},[oe.JCB]:{regex:/^35\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[oe.HIPERCARD]:{regex:/^606282\d*/,maxCardLength:19,cardLengthRange:[14,15,16,17,18,19]},[oe.UNIONPAY]:{regex:/^62\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[oe.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]}};oe.DEFAULT,oe.CVV,oe.EXPIRY,oe.ERROR,oe.AMEX,oe.DINERS_CLUB,oe.DISCOVER,oe.HIPERCARD,oe.JCB,oe.MAESTRO,oe.MASTERCARD,oe.UNIONPAY,oe.VISA;const pe="MM/YY",Ee=[pe,"YYYY/MM","YY/MM","MM/YYYY"],he=["YY","YYYY"];var Ie;!function(e){e.APPLICATIONORJSON="application/json",e.TEXTORPLAIN="text/plain",e.TEXTORXML="text/xml",e.FORMURLENCODED="application/x-www-form-urlencoded",e.FORMDATA="multipart/form-data"}(Ie||(Ie={})),ne.CARD_NUMBER,ne.EXPIRATION_DATE,ne.EXPIRATION_MONTH,ne.EXPIRATION_YEAR,ne.CVV,ne.EXPIRATION_DATE,ne.CARD_NUMBER,ne.CARDHOLDER_NAME,ne.INPUT_FIELD,B.INVALID_COLLECT_VALUE,ne.PIN,ne.EXPIRATION_MONTH,ne.EXPIRATION_YEAR,ne.CVV,ne.EXPIRATION_DATE,ne.CARD_NUMBER,ne.CARDHOLDER_NAME,ne.INPUT_FIELD,B.DEFAULT_REQUIRED_COLLECT_VALUE,ne.PIN,ne.EXPIRATION_MONTH,ne.EXPIRATION_YEAR;const ve=[ne.CARDHOLDER_NAME,ne.EXPIRATION_MONTH,ne.PIN,ne.CVV],me={X:"[0-9]"};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})}}
2
2
  /* @copyright
3
3
  Copyright (c) 2022 Skyflow, Inc.
4
- */const Le={IFRAME_SECURE_SITE:"https://js.skyflow.com/v1/elements/index.html",IFRAME_SECURE_ORGIN:"https://js.skyflow.com"},Ae="https://assets.payrails.io/da44fa4/card/index.html",fe="https://assets.payrails.io",Oe={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 Re=(e={})=>{const t=document.createElement("iframe"),i=Object.assign(Object.assign({},Oe),e);return Object.assign(t.style,le),Te(t,i),t.getAttribute("id")||(t.id=t.name),t};const Ce=()=>Le.IFRAME_SECURE_SITE,ge=(e,t)=>{Object.keys(t).forEach((i=>{Object.prototype.hasOwnProperty.call(t,i)&&(e.style[i]=t[i])}))};function Ne(e){return JSON.parse(JSON.stringify(e))}var Se,Pe,be,De,Me,we,ke;!function(e){e.DEFAULT="DEFAULT",e.PLAIN_TEXT="PLAIN_TEXT",e.MASKED="MASKED",e.REDACTED="REDACTED"}(Se||(Se={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH",e.DELETE="DELETE"}(Pe||(Pe={})),function(e){e.CHANGE="CHANGE",e.READY="READY",e.FOCUS="FOCUS",e.BLUR="BLUR",e.SUBMIT="SUBMIT"}(be||(be={})),function(e){e.WARN="WARN",e.INFO="INFO",e.DEBUG="DEBUG",e.ERROR="ERROR"}(De||(De={})),function(e){e.DEV="DEV",e.PROD="PROD"}(Me||(Me={})),function(e){e.LOG="LOG",e.WARN="WARN",e.ERROR="ERROR"}(we||(we={})),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"}(ke||(ke={}));const Ye={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}},Ue={PROD:{doesReturnValue:!1},DEV:{doesReturnValue:!0}},xe="[Skyflow]",Fe=(e,t,i)=>{if(i&&Ye[i]){const{showDebugLogs:n,showInfoLogs:o,showWarnLogs:s,showErrorLogs:r}=Ye[i];t===we.LOG&&n?console.log(`${De.DEBUG}: ${xe} ${e}`):t===we.LOG&&o?console.log(`${De.INFO}: ${xe} ${e}`):t===we.WARN&&s?console.warn(`${De.WARN}: ${xe} ${e}`):t===we.ERROR&&r&&console.error(`${De.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]})):""},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},Ve=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)}))},Ge=e=>{let t=!0;try{new RegExp(e)}catch(e){t=!1}return t},Xe=e=>{if(!Object.prototype.hasOwnProperty.call(e,"getBearerToken"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_GET_BEARER_TOKEN_MISSING)},ze=(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(j.COLLECT_ALT_TEXT_DEPERECATED,we.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)},He=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)}))},We=e=>"boolean"==typeof e;function qe(e){const t=e.split(":");return t.length>2?(t.pop(),t.pop(),t.join(":")):""}const $e=(e,t,i)=>{if("string"!=typeof e)return e;if(t===ne.CARD_NUMBER){if(e=e&&e.replace(/\s/g,""),!i){((e="")=>{const t=e.replace(/[\s-]/g,"");let i=oe.DEFAULT;Object.entries(_e).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,o;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),s=i.protocol,r=i.hostname;Le.IFRAME_SECURE_ORGIN=`${s}//${r}`,Le.IFRAME_SECURE_SITE=null===(o=null==e?void 0:e.options)||void 0===o?void 0:o.customElementsURL}Le.IFRAME_SECURE_ORGIN=fe,Le.IFRAME_SECURE_SITE=Ae}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:Ce()}),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=Re({name:this.name})}}class Ze{}var Qe,et,tt,it,nt,ot,st,rt,at,lt,ct,dt,ut,_t,pt,Et,ht,It,vt,mt;const yt="Element";class Lt extends Ze{constructor(t,s,r,a,l=!1,c,d,u,_){var p;super(),this.type=Ni.COLLECT,Qe.set(this,void 0),et.set(this,!1),tt.set(this,void 0),it.set(this,void 0),nt.set(this,{isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:void 0,isRequired:!1}),ot.set(this,void 0),st.set(this,new ye),rt.set(this,void 0),at.set(this,Y.getEventBus()),lt.set(this,void 0),ct.set(this,[]),dt.set(this,!1),ut.set(this,void 0),_t.set(this,void 0),pt.set(this,!1),this.getID=()=>i(this,Qe,"f"),this.mount=t=>{var s;if(!t)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_IN_MOUNT);const r=(t,o)=>{if(t.name===i(this,lt,"f").name){o(i(this,ot,"f")),i(this,mt,"f").call(this);const t=e(i(this,tt,"f")[0],["name"]);i(this,it,"f").length>1?i(this,it,"f").forEach(((e,t)=>{i(this,rt,"f")&&i(this,rt,"f")._emit(`${z.READY}:${e.elementName}`,Object.assign(Object.assign({},i(this,tt,"f")[t]),{elementType:e.elementType}))})):i(this,st,"f")._emit(z.READY,Object.assign({},t)),i(this,at,"f").off(H+this.containerId,r),Fe(`${Be(F.ELEMENT_MOUNTED,yt,je(i(this,lt,"f").name))} `,we.LOG,i(this,ut,"f").logLevel),i(this,ct,"f").forEach((e=>e())),n(this,ct,[],"f")}};if(i(this,it,"f").length>1)i(this,lt,"f").mount(t),i(this,at,"f").on(H+this.containerId,r);else{if(i(this,pt,"f"))return i(this,lt,"f").mount(t),void i(this,at,"f").on(H+this.containerId,r);null===(s=i(this,rt,"f"))||void 0===s||s.on(ie,(e=>{(null==e?void 0:e.containerId)===this.containerId&&(i(this,lt,"f").mount(t),i(this,at,"f").on(H+this.containerId,r))}))}},this.unmount=()=>{i(this,lt,"f").unmount()},this.update=e=>{let t=Ne(e);const o=()=>{i(this,et,"f")&&(t={rows:[{elements:[Object.assign({},t)]}]}),n(this,ot,ft(i(this,ot,"f"),t),"f"),n(this,it,Ot(i(this,ot,"f")),"f"),i(this,et,"f")?i(this,at,"f").emit(K,{name:i(this,lt,"f").name,options:i(this,it,"f")[0],isSingleElementAPI:!0}):(i(this,it,"f").forEach((e=>{i(this,at,"f").emit(K,{name:e.elementName,options:e,isSingleElementAPI:!0})})),i(this,at,"f").emit(K,{name:i(this,lt,"f").name,options:i(this,ot,"f"),isSingleElementAPI:!1})),i(this,mt,"f").call(this)};i(this,dt,"f")?o():i(this,ct,"f").push(o)},Et.set(this,(e=>{i(this,et,"f")||i(this,st,"f").on(K,(()=>{e(i(this,it,"f"))}),!0)})),this.updateElement=e=>{i(this,at,"f").emit(K,{name:e.elementName,options:e,isSingleElementAPI:!0})},ht.set(this,(()=>{i(this,tt,"f").forEach(((e,t)=>{if(0===t){i(this,nt,"f").isEmpty=e.isEmpty,i(this,nt,"f").isComplete=e.isComplete,i(this,nt,"f").isValid=e.isValid,i(this,nt,"f").isFocused=e.isFocused,i(this,nt,"f").isRequired=e.isRequired,i(this,nt,"f").value={};const n=i(this,it,"f")[t].elementName,o=e.value&&$e(e.value,e.elementType,i(this,_t,"f"));i(this,et,"f")?i(this,nt,"f").value=o:i(this,nt,"f").value[n]=o}else i(this,nt,"f").isEmpty=i(this,nt,"f").isEmpty||e.isEmpty,i(this,nt,"f").isComplete=i(this,nt,"f").isComplete&&e.isComplete,i(this,nt,"f").isValid=i(this,nt,"f").isValid&&e.isValid,i(this,nt,"f").isFocused=i(this,nt,"f").isFocused||e.isFocused,i(this,nt,"f").isRequired=i(this,nt,"f").isRequired||e.isRequired,i(this,nt,"f").value||(i(this,nt,"f").value={}),i(this,it,"f")[t].sensitive||(i(this,nt,"f").value[i(this,it,"f")[t].elementName]=e.value||"")}))})),this.getState=()=>({isEmpty:i(this,nt,"f").isEmpty,isComplete:i(this,nt,"f").isComplete,isValid:i(this,nt,"f").isValid,isFocused:i(this,nt,"f").isFocused,value:i(this,nt,"f").value,required:i(this,nt,"f").isRequired}),this.getOptions=()=>{let e=Ne(i(this,ot,"f"));return i(this,et,"f")?e=e.rows[0].elements[0]:e.rows.forEach((e=>{e.elements.forEach((e=>{delete e.elementName}))})),delete e.elementName,e},It.set(this,(e=>{i(this,st,"f").on($,(()=>{const t=i(this,it,"f").map((e=>e.elementName));i(this,et,"f")||t.push(i(this,lt,"f").name),e(t)}),!0)})),vt.set(this,(()=>{i(this,at,"f").on(q,(e=>{if(i(this,et,"f")&&e.event===z.READY&&e.name===i(this,lt,"f").name)i(this,st,"f")._emit(z.READY);else{const t=i(this,it,"f").length>1;i(this,it,"f").forEach(((n,s)=>{var r;if(e.name===n.elementName){let a="";switch(e.event){case z.FOCUS:a=z.FOCUS;break;case z.BLUR:a=z.BLUR;break;case z.CHANGE:a=z.CHANGE;break;case z.READY:a=z.READY;break;case z.SUBMIT:return void(null===(r=i(this,rt,"f"))||void 0===r||r._emit(z.SUBMIT));default:throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_TYPE)}i(this,tt,"f")[s].isEmpty=e.value.isEmpty,i(this,tt,"f")[s].isValid=e.value.isValid,i(this,tt,"f")[s].isComplete=e.value.isComplete,i(this,tt,"f")[s].isFocused=e.value.isFocused,i(this,tt,"f")[s].isRequired=e.value.isRequired,Object.prototype.hasOwnProperty.call(e.value,"value")?i(this,tt,"f")[s].value=e.value.value:i(this,tt,"f")[s].value=void 0,a=t?`${a}:${e.name}`:a,i(this,at,"f").emit(z.HEIGHT+i(this,lt,"f").name,{},(e=>{i(this,lt,"f").setIframeHeight(e.height)})),i(this,ht,"f").call(this);const l=Object.assign(Object.assign({},i(this,tt,"f")[s]),{elementType:n.elementType});t&&i(this,rt,"f")?i(this,rt,"f")._emit(a,l):i(this,st,"f")._emit(a,l)}}))}}))})),mt.set(this,(()=>{const{rows:e}=i(this,ot,"f");e.forEach((e=>{e.elements.forEach((e=>{e.elementType!==re.radio.name&&e.elementType!==re.checkbox.name&&(e.value=void 0)}))})),n(this,it,Ot(i(this,ot,"f")),"f")})),this.containerId=a.containerId,n(this,Qe,t,"f"),n(this,ut,u,"f"),n(this,ot,ft(s),"f"),n(this,it,Ot(s),"f"),n(this,et,l,"f"),_&&n(this,rt,_,"f"),n(this,_t,Ue[i(this,ut,"f").env].doesReturnValue,"f"),this.elementType=i(this,et,"f")?i(this,it,"f")[0].elementType:"group",n(this,tt,[],"f"),i(this,it,"f").forEach((e=>{i(this,tt,"f").push({isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:i(this,_t,"f")?"":void 0,elementType:e.elementType,name:e.elementName,isRequired:!1})})),n(this,lt,new Je(i(this,ot,"f").elementName,r,this.containerId,i(this,ut,"f").logLevel),"f"),i(this,vt,"f").call(this),i(this,It,"f").call(this,c),i(this,Et,"f").call(this,d),Fe(Be(F.CREATED_ELEMENT,yt,je(i(this,lt,"f").name)),we.LOG,i(this,ut,"f").logLevel),n(this,pt,a.isMounted,"f"),null===(p=i(this,rt,"f"))||void 0===p||p.on(ie,(e=>{(null==e?void 0:e.containerId)===this.containerId&&n(this,pt,!0,"f")}));const E=e=>{e.height&&e.height>0&&i(this,lt,"f").setIframeHeight(e.height)};i(this,at,"f").on(z.MOUNTED,(e=>{a.type===Ni.COMPOSABLE?i(this,it,"f").forEach((t=>{e.name===t.elementName&&(t.isMounted=!0,n(this,dt,!0,"f"))})):e.name===i(this,it,"f")[0].elementName&&(i(this,it,"f")[0].isMounted=!0,n(this,dt,!0,"f")),i(this,at,"f").emit(z.HEIGHT+i(this,lt,"f").name,{},E)}))}on(e,t){if(!Object.values(z).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);i(this,st,"f").on(e,(e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,t(e)}))}iframeName(){return i(this,lt,"f").name}isMounted(){return i(this,dt,"f")}isValidElement(){for(let e=0;e<i(this,it,"f").length;e+=1){if(!Object.prototype.hasOwnProperty.call(i(this,it,"f")[e],"table"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_TABLE_NAME_MISSING);if(!i(this,it,"f")[e].table)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_TABLE);if(!("string"==typeof i(this,it,"f")[e].table||i(this,it,"f")[e].table instanceof String))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_NAME);if(!Object.prototype.hasOwnProperty.call(i(this,it,"f")[e],"column"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_COLUMN);if(!i(this,it,"f")[e].column)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_COLUMN);if(!("string"==typeof i(this,it,"f")[e].column||i(this,it,"f")[e].column instanceof String))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COLUMN);if(void 0!==i(this,it,"f")[e].skyflowID&&!i(this,it,"f")[e].skyflowID)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_SKYFLOW_ID)}return!0}setError(e){i(this,at,"f").emit(Z,{name:qe(i(this,lt,"f").name),isTriggerError:!0,clientErrorText:e})}resetError(){i(this,at,"f").emit(Z,{name:qe(i(this,lt,"f").name),isTriggerError:!1})}setValue(e){i(this,ut,"f").env!==Me.PROD?i(this,et,"f")&&i(this,at,"f").emit(K,{name:i(this,lt,"f").name,options:Object.assign(Object.assign({},i(this,it,"f")[0]),{value:e}),isSingleElementAPI:!0}):Fe(Be(j.UNABLE_TO_SET_VALUE_IN_PROD_ENV,i(this,it,"f")[0].elementType),we.WARN,i(this,ut,"f").logLevel)}clearValue(){i(this,ut,"f").env!==Me.PROD?i(this,et,"f")&&i(this,at,"f").emit(K,{name:i(this,lt,"f").name,options:Object.assign(Object.assign({},i(this,it,"f")[0]),{value:""}),isSingleElementAPI:!0}):Fe(Be(j.UNABLE_TO_CLEAR_VALUE_IN_PROD_ENV,i(this,it,"f")[0].elementType),we.WARN,i(this,ut,"f").logLevel)}}function At(e,t,i={}){if("group"!==e&&!Object.prototype.hasOwnProperty.call(re,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(ke).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===ke.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===ke.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}=re[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===re.radio.name||e===re.checkbox.name)&&!i.value)throw new Error("Elements radio and checkbox requires value attribute");if(!(e!==re.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 ft(e,t={},i=!0){return(t=Object.assign(Object.assign({},e),t)).rows.forEach(((n,o)=>{const s=n,r=e.rows[o];t.rows[o]=Object.assign(Object.assign({},r),s),s.elements.forEach(((e,t)=>{var n,o;const a=r.elements[t],l=e;if(l.elementType&&a.elementType!==l.elementType&&a.elementName&&a.elementName!==l.elementName)throw new Error(B.CANNOT_CHANGE_ELEMENT);At(a.elementType,a,l),s.elements[t]=Object.assign(Object.assign(Object.assign({},a),l),{elementName:a.elementName});const c=l.classes||{},d=l.styles||{};d.base=Object.assign(Object.assign({},de),d.base),l.classes=c,l.styles=d;const u=(null===(n=null==l?void 0:l.labelStyles)||void 0===n?void 0:n.classes)||{},_=(null===(o=null==l?void 0:l.labelStyles)||void 0===o?void 0:o.styles)||{};i&&function(e,t){Object.values(ue).forEach((i=>{if(e[i]||t[i])switch(i){case ue.BASE:t[i]=Object.assign({},t[i]);break;case ue.FOCUS:t[ue.BASE]=Object.assign(Object.assign({},t[ue.BASE]),{":focus":Object.assign({},t[ue.BASE]&&t[ue.BASE][":focus"])});break;case ue.WEBPACKAUTOFILL:t[ue.BASE]=Object.assign(Object.assign({},t[ue.BASE]),{":-webkit-autofill":Object.assign({},t[ue.BASE]&&t[ue.BASE][":-webkit-autofill"])});break;default:t[i]=Object.assign(Object.assign({},t[ue.BASE]),t[i])}})),Object.keys(t).forEach((e=>{const i=t[e][":-webkit-autofill"];"object"==typeof i&&Object.keys(i).forEach((e=>{i[e]&&!i[e].includes("!important")&&(i[e]=`${i[e]} !important`)}))}))}(u,_),l.labelStyles={labelClasses:u},l.labelStyles.styles=_}))})),t}Qe=new WeakMap,et=new WeakMap,tt=new WeakMap,it=new WeakMap,nt=new WeakMap,ot=new WeakMap,st=new WeakMap,rt=new WeakMap,at=new WeakMap,lt=new WeakMap,ct=new WeakMap,dt=new WeakMap,ut=new WeakMap,_t=new WeakMap,pt=new WeakMap,Et=new WeakMap,ht=new WeakMap,It=new WeakMap,vt=new WeakMap,mt=new WeakMap;const Ot=e=>{const{rows:t}=e,i=[];return t.forEach((e=>{e.elements.forEach((e=>{i.push(e)}))})),i},Tt=e=>{const t=e.validations;return t&&Array.isArray(t)&&t.length>0&&t.forEach(((e,t)=>{if(e&&e.type===ke.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===ke.REGEX_MATCH_RULE){if(e.params&&e.params.regex&&!Ge(e.params.regex))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_REGEX_IN_REGEX_MATCH_RULE);e.params&&e.params.regex&&Ge(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"))&&(ve.includes(e)?(Fe(Be(j.INPUT_FORMATTING_NOT_SUPPROTED,e),we.WARN,i),null==n||delete n.format,null==n||delete n.translation):e===re.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:me]}),null==n||delete n.format,null==n||delete n.translation)),e===re.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)===ae&&(e="-"),n=Object.assign(Object.assign({},n),{cardSeperator:e}),null==n||delete n.format,null==n||delete n.translation}else if(e===re.EXPIRATION_DATE.name){let e=!1;n.format&&(e=!!(s=n.format.toUpperCase())&&Ee.includes(s),e||Fe(Be(j.INVALID_EXPIRATION_DATE_FORMAT,Ee.toString()),we.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():pe}),null==n||delete n.translation}else if(e===re.EXPIRATION_YEAR.name){let e=!1;n.format&&(e=(e=>!!e&&he.includes(e))(n.format.toUpperCase()),e||Fe(Be(j.INVALID_EXPIRATION_YEAR_FORMAT,he.toString()),we.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")&&!We(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")&&!We(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 gt{}var Nt,St,Pt,bt,Dt,Mt,wt,kt,Yt,Ut,xt,Ft;const Bt="CollectContainer";class jt extends gt{constructor(e,t,s,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=Ni.COLLECT,Mt.set(this,void 0),wt.set(this,!1),this.create=(e,t={required:!1})=>{ze(e,i(this,bt,"f").logLevel);const n=Tt(e),o=Rt(e.type,t,i(this,bt,"f").logLevel),s={rows:[{elements:[Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column,accept:t.allowedFileType},e),o),{validations:n})]}]};return i(this,kt,"f").call(this,s,!0)},kt.set(this,((e,t=!1)=>{const n=[],s=Ne(e);if(s.rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;At(i,t),t.sensitive=t.sensitive||re[i].sensitive,t.replacePattern=t.replacePattern||re[i].replacePattern,t.mask=t.mask||re[i].mask,t.isMounted=!1,t.elementType!==re.radio.name&&t.elementType!==re.checkbox.name||(t.elementName=`${t.elementName}:${btoa(t.value)}`),t.elementName=`${G}:${t.elementType}:${btoa(Ct())}`,t.label=e.label,t.skyflowID=e.skyflowID,n.push(t)}))})),s.elementName=t?n[0].elementName:`${G}:group:${btoa(s.name)}`,t&&!i(this,St,"f")[n[0].elementName]&&i(this,Ft,"f").call(this,n[0].name))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_UNIQUE_ELEMENT_NAME);let r=i(this,St,"f")[s.elementName];if(r)t?r.update(n[0]):r.update(s);else{const e=Ct();r=new Lt(e,s,i(this,Pt,"f"),{containerId:i(this,Nt,"f"),isMounted:i(this,wt,"f"),type:this.type},t,i(this,Ut,"f"),i(this,xt,"f"),i(this,bt,"f"),i(this,Mt,"f")),i(this,St,"f")[s.elementName]=r,i(this,Dt,"f")[e]=r}return t||n.forEach((e=>{const t=e.elementName;i(this,St,"f")[t]?i(this,St,"f")[t].update(e):i(this,St,"f")[t]=this.create(e.elementType,r)})),r})),Yt.set(this,(e=>{Object.keys(i(this,St,"f")).forEach((t=>{t===e&&delete i(this,St,"f")[t]}))})),Ut.set(this,(e=>{e.forEach((e=>{i(this,Yt,"f").call(this,e)}))})),xt.set(this,(e=>{e.forEach((e=>{i(this,St,"f")[e.elementName]&&i(this,St,"f")[e.elementName].update(e)}))})),Ft.set(this,(e=>{const t=Object.keys(i(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(i(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(ee+i(this,Nt,"f"),{},(t=>{e(t)}))})),this.collect=(e={tokens:!0})=>new Promise(((t,n)=>{try{Xe(i(this,Pt,"f").clientJSON.config);if(Object.values(i(this,St,"f")).forEach((e=>{if(!e.isMounted())throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);e.isValidElement()})),Object.prototype.hasOwnProperty.call(e,"tokens")&&!We(e.tokens))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TOKENS);(null==e?void 0:e.additionalFields)&&Ve(e.additionalFields),(null==e?void 0:e.upsert)&&He(null==e?void 0:e.upsert),this.bus.emit(W+i(this,Nt,"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)}`,we.ERROR,i(this,bt,"f").logLevel),n(null==e?void 0:e.error)):(Fe(Be(F.COLLECT_SUBMIT_SUCCESS,Bt),we.LOG,i(this,bt,"f").logLevel),t(e))})),Fe(Be(F.EMIT_EVENT,Bt,W),we.LOG,i(this,bt,"f").logLevel)}catch(e){Fe(`${e.message}`,we.ERROR,i(this,bt,"f").logLevel),n(e)}})),this.unmount=()=>{this.iframe.remove()},this.bus=Y.getEventBus(),n(this,Nt,Ct(),"f"),n(this,Pt,t,"f"),n(this,Dt,s,"f"),n(this,bt,r,"f"),n(this,Mt,new ye,"f"),this.iframe=Re({name:`${V}:${i(this,Nt,"f")}:${i(this,bt,"f").logLevel}`}),Te(this.iframe,{src:Ce()}),ge(this.iframe,Object.assign({},ce)),Fe(Be(F.CREATE_COLLECT_CONTAINER,Bt),we.LOG,i(this,bt,"f").logLevel);const a=(e,o)=>{e.name===V+i(this,Nt,"f")&&(o(Object.assign(Object.assign({},t),{clientJSON:Object.assign(Object.assign({},t.clientJSON),{config:Object.assign({},t.clientJSON.config)}),context:r})),n(this,wt,!0,"f"),i(this,Mt,"f")._emit(ie,{containerId:i(this,Nt,"f")}),this.bus.target({origin:Le.IFRAME_SECURE_ORGIN}).off(H+i(this,Nt,"f"),a))};this.bus.target({origin:Le.IFRAME_SECURE_ORGIN}).on(H+i(this,Nt,"f"),a),document.body.append(this.iframe)}}var Vt,Gt,Xt,zt,Ht,Wt,qt,$t,Kt,Jt,Zt,Qt,ei,ti,ii,ni,oi,si,ri,ai,li,ci,di;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,xt=new WeakMap,Ft=new WeakMap;class ui{constructor(e,t){Vt.set(this,void 0),Gt.set(this,void 0),this.type=Ni.COMPOSABLE,Xt.set(this,!1),zt.set(this,!1),this.update=e=>{n(this,zt,!0,"f"),i(this,Xt,"f")?(i(this,Gt,"f")._emit(Q,{elementName:i(this,Vt,"f"),elementOptions:e}),n(this,zt,!1,"f")):i(this,zt,"f")&&i(this,Gt,"f").on(`${be.READY}:${i(this,Vt,"f")}`,(()=>{i(this,Gt,"f")._emit(Q,{elementName:i(this,Vt,"f"),elementOptions:e}),n(this,Xt,!0,"f"),n(this,zt,!1,"f")}))},n(this,Vt,e,"f"),n(this,Gt,t,"f"),i(this,Gt,"f").on(`${be.READY}:${i(this,Vt,"f")}`,(()=>{n(this,Xt,!0,"f")}))}on(e,t){if(!Object.values(z).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);i(this,Gt,"f").on(`${e}:${i(this,Vt,"f")}`,(e=>{if(void 0===e.value&&(e.value=""),"CARD_NUMBER"===e.elementType&&e.value){const{value:t}=e;e.value=t.slice(0,8)}delete e.isComplete,delete e.name,t(e)}))}}Vt=new WeakMap,Gt=new WeakMap,Xt=new WeakMap,zt=new WeakMap;const _i="CollectContainer";class pi extends gt{constructor(e,t,r,a){super(),Ht.set(this,void 0),Wt.set(this,{}),qt.set(this,void 0),$t.set(this,{rows:[]}),Kt.set(this,[]),Jt.set(this,void 0),Zt.set(this,void 0),Qt.set(this,void 0),ei.set(this,!1),ti.set(this,void 0),ii.set(this,void 0),this.type=Ni.COMPOSABLE,ni.set(this,!1),oi.set(this,{}),this.create=(e,t={required:!1})=>{ze(e,i(this,Jt,"f").logLevel);const n=Tt(e),o=Rt(e.type,t,i(this,Jt,"f").logLevel),s=`${G}:${e.type}:${btoa(Ct())}`;return i(this,Kt,"f").push(Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column},e),o),{validations:n,elementName:s})),new ui(s,i(this,Qt,"f"))},si.set(this,((e,t=!1)=>{const s=[];if(n(this,oi,Ne(e),"f"),i(this,oi,"f").rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;At(i,t),t.sensitive=t.sensitive||re[i].sensitive,t.replacePattern=t.replacePattern||re[i].replacePattern,t.mask=t.mask||re[i].mask,t.isMounted=!1,t.label=e.label,t.skyflowID=e.skyflowID,s.push(t)}))})),i(this,oi,"f").elementName=t?s[0].elementName:`${G}:group:${btoa(i(this,oi,"f").name)}`,t&&!i(this,Wt,"f")[s[0].elementName]&&i(this,ci,"f").call(this,s[0].name))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_UNIQUE_ELEMENT_NAME);let r=i(this,Wt,"f")[i(this,oi,"f").elementName];if(r)t?r.update(s[0]):r.update(i(this,oi,"f"));else{const e=Ct();r=new Lt(e,i(this,oi,"f"),i(this,qt,"f"),{containerId:i(this,Ht,"f"),isMounted:i(this,ni,"f"),type:this.type},!0,i(this,ai,"f"),i(this,li,"f"),i(this,Jt,"f"),i(this,Qt,"f")),i(this,Wt,"f")[i(this,oi,"f").elementName]=r,i(this,Zt,"f")[e]=r}return r})),ri.set(this,(e=>{Object.keys(i(this,Wt,"f")).forEach((t=>{t===e&&delete i(this,Wt,"f")[t]}))})),ai.set(this,(e=>{e.forEach((e=>{i(this,ri,"f").call(this,e)}))})),li.set(this,(e=>{e.forEach((e=>{i(this,Wt,"f")[e.elementName]&&i(this,Wt,"f")[e.elementName].update(e)}))})),ci.set(this,(e=>{const t=Object.keys(i(this,Wt,"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(z).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);i(this,Qt,"f").on(z.SUBMIT,(()=>{t()}))},this.mount=e=>{if(!e)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_IN_MOUNT);const{layout:t}=i(this,ti,"f");if((t||[]).reduce(((e,t)=>e+(s?s(t):t)),0)!==i(this,Kt,"f").length)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISMATCH_ELEMENT_COUNT_LAYOUT_SUM);var s;let r=0;if(t.forEach(((e,t)=>{i(this,$t,"f").rows=[...i(this,$t,"f").rows,{elements:[]}];for(let n=0;n<e;n++)i(this,$t,"f").rows[t].elements.push(i(this,Kt,"f")[r]),r++})),i(this,ti,"f").styles&&(i(this,$t,"f").styles=Object.assign({},i(this,ti,"f").styles)),i(this,ti,"f").errorTextStyles&&(i(this,$t,"f").errorTextStyles=Object.assign({},i(this,ti,"f").errorTextStyles)),i(this,ni,"f"))return n(this,ii,i(this,si,"f").call(this,i(this,$t,"f"),!1),"f"),i(this,ii,"f").mount(e),void n(this,ei,!0,"f");i(this,Qt,"f").on(te+i(this,Ht,"f"),(()=>{n(this,ii,i(this,si,"f").call(this,i(this,$t,"f"),!1),"f"),i(this,ii,"f").mount(e),n(this,ei,!0,"f")}))},this.unmount=()=>{var e;null===(e=i(this,ii,"f"))||void 0===e||e.unmount(),this.iframe.remove()},this.validate=()=>new Promise(((e,t)=>{Object.values(i(this,Wt,"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(ee+i(this,Ht,"f"),{},(t=>{e(t)}))})),this.collect=(e={tokens:!0})=>new Promise(((t,n)=>{try{if(Xe(i(this,qt,"f").clientJSON.config),!i(this,ei,"f")){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);throw s.PayrailsLogger.error(e.message,{error:e}),e}Ot(i(this,oi,"f")).forEach((e=>{if(!(null==e?void 0:e.isMounted))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING)}));if(Object.values(i(this,Wt,"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)&&Ve(e.additionalFields),(null==e?void 0:e.upsert)&&He(null==e?void 0:e.upsert),this.bus.emit(W+i(this,Ht,"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)}`,we.ERROR,i(this,Jt,"f").logLevel),n(null==e?void 0:e.error)):(Fe(Be(F.COLLECT_SUBMIT_SUCCESS,_i),we.LOG,i(this,Jt,"f").logLevel),t(e))})),Fe(Be(F.EMIT_EVENT,_i,W),we.LOG,i(this,Jt,"f").logLevel)}catch(e){Fe(`${e.message}`,we.ERROR,i(this,Jt,"f").logLevel),n(e)}})),di.set(this,(()=>{i(this,Qt,"f").on(Q,(e=>{let t;const n=i(this,Kt,"f").map(((i,n)=>i.elementName===e.elementName?(t=n,Object.assign({elementName:i.elementName},e.elementOptions)):i));i(this,ii,"f")&&i(this,ii,"f").updateElement(Object.assign({},n[t]))}))})),this.bus=Y.getEventBus(),n(this,Ht,Ct(),"f"),n(this,qt,t,"f"),n(this,Zt,r,"f"),n(this,Jt,a,"f"),n(this,ti,e,"f"),n(this,Qt,new ye,"f"),this.iframe=Re({name:`${V}:${i(this,Ht,"f")}:${i(this,Jt,"f").logLevel}`}),Te(this.iframe,{src:Ce()}),ge(this.iframe,Object.assign({},ce)),Fe(Be(F.CREATE_COLLECT_CONTAINER,_i),we.LOG,i(this,Jt,"f").logLevel);const l=(e,o)=>{e.name===V+i(this,Ht,"f")&&(o(Object.assign(Object.assign({},t),{clientJSON:Object.assign(Object.assign({},t.clientJSON),{config:Object.assign({},t.clientJSON.config)}),context:a})),n(this,ni,!0,"f"),i(this,Qt,"f")._emit(te+i(this,Ht,"f"),{containerId:i(this,Ht,"f")}),this.bus.target({origin:Le.IFRAME_SECURE_ORGIN}).off(H+i(this,Ht,"f"),l))};this.bus.target({origin:Le.IFRAME_SECURE_ORGIN}).on(H+i(this,Ht,"f"),l),document.body.append(this.iframe),i(this,di,"f").call(this)}}function Ei(e){this.message=e}Ht=new WeakMap,Wt=new WeakMap,qt=new WeakMap,$t=new WeakMap,Kt=new WeakMap,Jt=new WeakMap,Zt=new WeakMap,Qt=new WeakMap,ei=new WeakMap,ti=new WeakMap,ii=new WeakMap,ni=new WeakMap,oi=new WeakMap,si=new WeakMap,ri=new WeakMap,ai=new WeakMap,li=new WeakMap,ci=new WeakMap,di=new WeakMap,Ei.prototype=new Error,Ei.prototype.name="InvalidCharacterError";var hi="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new Ei("'atob' failed: The string to be decoded is not correctly encoded.");for(var i,n,o=0,s=0,r="";n=t.charAt(s++);~n&&(i=o%4?64*i+n:n,o++%4)?r+=String.fromCharCode(255&i>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return r};function Ii(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(hi(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 hi(t)}}function vi(e){this.message=e}vi.prototype=new Error,vi.prototype.name="InvalidTokenError";const mi=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 vi("Invalid token specified");var i=!0===(t=t||{}).header?0:1;try{return JSON.parse(Ii(e.split(".")[i]))}catch(e){throw new vi("Invalid token specified: "+e.message)}}(e),o=(new Date).getTime()/1e3,s=n.exp;return s&&o>s&&(i=!0),!i}catch(e){return!1}var t};var yi,Li,Ai,fi,Oi,Ti,Ri,Ci,gi,Ni,Si={name:"skyflow-js",preferGlobal:!0,analyze:!1,version:"1.30.1",author:"Skyflow",description:"Skyflow JavaScript SDK"};class Pi{constructor(e,t){yi.set(this,void 0),this.request=e=>new Promise(((t,n)=>{var s,r,a,l;const c=new XMLHttpRequest;if(c){if(c.open(e.requestMethod,e.url),e.headers){const t=function(e,t,i){var n,o,s,r,a;const l={sdkName:e.name,sdkVersion:e.version},c=function(e,t){return""!==e?`${e}`:`${t.sdkName}@${t.sdkVersion}`}(t.sdkVersion,l),d=function(e){var t,i,n,o,s,r,a,l,c,d,u,_;let p=null,E=null;return/Windows/.test(e)?(p="Windows",E=null!==(i=null===(t=/Windows NT (\d+\.\d+)/.exec(e))||void 0===t?void 0:t[1])&&void 0!==i?i:null):/Android/.test(e)?(p="Android",E=null!==(o=null===(n=/Android (\d+\.\d+)/.exec(e))||void 0===n?void 0:n[1])&&void 0!==o?o:null):/iOS/.test(e)||/iPhone/.test(e)?(p="iOS",E=null!==(a=null===(r=null===(s=/OS (\d+[._]\d+[._]?\d*)/.exec(e))||void 0===s?void 0:s[1])||void 0===r?void 0:r.replace(/_/g,"."))&&void 0!==a?a:null):/Mac OS X/.test(e)?(p="Mac OS X",E=null!==(d=null===(c=null===(l=/Mac OS X (\d+([._]\d+)*)/.exec(e))||void 0===l?void 0:l[1])||void 0===c?void 0:c.replace(/_/g,"."))&&void 0!==d?d:null):/Linux/.test(e)&&(p="Linux",E=null!==(_=null===(u=/Linux( \w+)*?\/([\w.]+)/.exec(e))||void 0===u?void 0:u[2])&&void 0!==_?_:null),{os:p,version:E}}(i.userAgent),u=function(e){let t="",i="";if(-1!==e.indexOf("MSIE")||-1!==e.indexOf("Trident/")){t="Internet Explorer";const n=e.match(/(MSIE|rv:)\s?([\d.]+)/);n&&(i=n[2])}else if(-1!==e.indexOf("Edge")){t="Microsoft Edge";const n=e.match(/Edge\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Chrome")){t="Google Chrome";const n=e.match(/Chrome\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Firefox")){t="Mozilla Firefox";const n=e.match(/Firefox\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Safari")){t="Apple Safari";const n=e.match(/Version\/([\d.]+)/);n&&(i=n[1])}return{browserName:t,browserVersion:i}}(i.userAgent);var _;return{sdk_name_version:c,sdk_client_device_model:(_=i.userAgent,/(ipad|tablet)/gi.test(_)?"tablet":/Mobile|iP(hone|od)|Android|BlackBerry|IEMobile/.test(_)?"mobile":"desktop"),sdk_os_version:null!==(n=i.platform)&&void 0!==n?n:`${null!==(o=d.os)&&void 0!==o?o:""} ${null!==(s=d.version)&&void 0!==s?s:""}`,sdk_runtime_details:`${null!==(r=u.browserName)&&void 0!==r?r:""} ${null!==(a=u.browserVersion)&&void 0!==a?a:""}`}}(Si,i(this,yi,"f"),navigator);e.headers["sky-metadata"]=JSON.stringify(t);const{headers:n}=e;Object.keys(e.headers).forEach((e=>{"content-type"===e&&n[e]&&n[e].includes(Ie.FORMDATA)||c.setRequestHeader(e,n[e])}))}(null===(r=null===(s=e.headers)||void 0===s?void 0:s["content-type"])||void 0===r?void 0:r.includes(Ie.FORMURLENCODED))||(null===(l=null===(a=e.headers)||void 0===a?void 0:a["content-type"])||void 0===l?void 0:l.includes(Ie.FORMDATA))?c.send(e.body):c.send(JSON.stringify(Object.assign({},e.body))),c.onload=()=>{var e,i,s;const r=c.getAllResponseHeaders().trim().split(/[\r\n]+/),a={};r.forEach((e=>{const t=e.split(": "),i=t.shift()||"",n=t.join(": ");a[i]=n}));const l=a["content-type"],d=a["x-request-id"];if(c.status<200||c.status>=400)if(l&&l.includes("application/json")){let t=JSON.parse(c.response);(null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.message)&&(t=d?`${null===(i=null==t?void 0:t.error)||void 0===i?void 0:i.message} - requestId: ${d}`:null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.message),n(new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_VAULT_NETWORK_ERROR,{description:t}))}else l&&l.includes("text/plain")?n(new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_VAULT_NETWORK_ERROR,{description:d?`${c.response} - requestId: ${d}`:c.response})):n(new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_VAULT_NETWORK_ERROR,{description:d?`${B.ERROR_OCCURED} - requestId: ${d}`:B.ERROR_OCCURED}));l&&l.includes("application/json")&&t(JSON.parse(c.response)),t(c.response)},c.onerror=()=>{n(new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_VAULT_NETWORK_ERROR))}}else n(new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_VAULT_CONNECTION_ERROR))})),this.config=e,n(this,yi,t,"f")}toJSON(){return{config:this.config,metaData:i(this,yi,"f")}}static fromJSON(e){return new Pi(e.config,e.metaData)}}yi=new WeakMap,function(e){e.COLLECT="COLLECT",e.COMPOSABLE="COMPOSABLE"}(Ni||(Ni={}));const bi="Skyflow";class Di{constructor(e){var t,r;Li.set(this,void 0),Ai.set(this,Ct()),fi.set(this,{uuid:i(this,Ai,"f"),clientDomain:window.location.origin}),Oi.set(this,""),Ti.set(this,void 0),Ri.set(this,void 0),Ci.set(this,void 0),gi.set(this,void 0),this.bus=Y.getEventBus();const a=localStorage.getItem("sdk_version")||"";i(this,fi,"f").sdkVersion=a,n(this,Li,new Pi(Object.assign({},e),i(this,fi,"f")),"f"),n(this,Ri,(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||De.ERROR,"f"),n(this,Ci,(null===(r=null==e?void 0:e.options)||void 0===r?void 0:r.env)||Me.PROD,"f"),n(this,gi,{},"f");this.bus.on(X,(e=>{if(e&&e.errorCode){const t=new o.PayrailsError(e.errorCode,{cause:null==e?void 0:e.originalError});s.PayrailsLogger.error(t.message,{error:t})}})),this.bus.target({origin:Le.IFRAME_SECURE_ORGIN}).on(J+i(this,Ai,"f"),((e,t)=>{Fe(Be(F.CAPTURED_BEARER_TOKEN_EVENT,bi),we.LOG,i(this,Ri,"f")),!i(this,Li,"f").config.getBearerToken||i(this,Oi,"f")&&mi(i(this,Oi,"f"))?(Fe(Be(F.REUSE_BEARER_TOKEN,bi),we.LOG,i(this,Ri,"f")),t({authToken:i(this,Oi,"f")})):i(this,Li,"f").config.getBearerToken().then((e=>{mi(e)?(Fe(Be(F.BEARER_TOKEN_RESOLVED,bi),we.LOG,i(this,Ri,"f")),n(this,Oi,e,"f"),t({authToken:i(this,Oi,"f")})):(Fe(B.INVALID_BEARER_TOKEN,we.ERROR,i(this,Ri,"f")),t({error:B.INVALID_BEARER_TOKEN}))})).catch((e=>{Fe(B.BEARER_TOKEN_REJECTED,we.ERROR,i(this,Ri,"f")),t({error:e})}))})),Fe(Be(F.BEARER_TOKEN_LISTENER,bi),we.LOG,i(this,Ri,"f")),Fe(Be(F.CURRENT_ENV,bi,i(this,Ci,"f")),we.LOG,i(this,Ri,"f")),Fe(Be(F.CURRENT_LOG_LEVEL,bi,i(this,Ri,"f")),we.LOG,i(this,Ri,"f"))}static init(e){var t;const i=(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||De.ERROR;Ke(e),Fe(Be(F.INITIALIZE_CLIENT,bi),we.LOG,i);const n=e;var o;n.vaultURL="string"!=typeof(o=e.vaultURL)?o:"/"===(null==o?void 0:o.trim().slice(-1))?o.slice(0,-1):o.trim();const s=new Di(n);return Fe(Be(F.CLIENT_INITIALIZED,bi),we.LOG,i),s}container(e,t){switch(e){case Ni.COLLECT:{const n=new jt(t,Object.assign(Object.assign({},i(this,fi,"f")),{clientJSON:i(this,Li,"f").toJSON(),containerType:e}),i(this,gi,"f"),{logLevel:i(this,Ri,"f"),env:i(this,Ci,"f")});return Fe(Be(F.COLLECT_CONTAINER_CREATED,bi),we.LOG,i(this,Ri,"f")),n}case Ni.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 n=new pi(t,Object.assign(Object.assign({},i(this,fi,"f")),{clientJSON:i(this,Li,"f").toJSON(),containerType:e}),i(this,gi,"f"),{logLevel:i(this,Ri,"f"),env:i(this,Ci,"f")});return Fe(Be(F.COLLECT_CONTAINER_CREATED,bi),we.LOG,i(this,Ri,"f")),n}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 Ni}static get ElementType(){return ne}static get RedactionType(){return Se}static get RequestMethod(){return Pe}static get LogLevel(){return De}static get EventName(){return be}static get Env(){return Me}static get ValidationRuleType(){return ke}}function Mi(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="",o="";Array.isArray(t)?t.length>1?(n="*",o=t.toString()):n=t.toString():"string"==typeof t&&t.length>0?n=t:"string"==typeof i&&i.length>0&&(n="*",o=i);e["merchant-id"]=n,e["data-merchant-id"]=o}(e);var i=Object.keys(e).filter((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})).reduce((function(t,i){var n=e[i].toString();return"data-"===i.substring(0,5)?t.dataAttributes[i]=n:t.queryParams[i]=n,t}),{queryParams:{},dataAttributes:{}}),n=i.queryParams,o=i.dataAttributes;return{url:"".concat(t,"?").concat(wi(n)),dataAttributes:o}}function wi(e){var t="";return Object.keys(e).forEach((function(i){0!==t.length&&(t+="&"),t+=i+"="+e[i]})),t}function ki(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 Yi(e,t){if(void 0===t&&(t=Ui()),Fi(e,t),"undefined"==typeof window)return t.resolve(null);var i=Mi(e),n=i.url,o=i.dataAttributes,s=o["data-namespace"]||"paypal",r=xi(s);
4
+ */const Le={IFRAME_SECURE_SITE:"https://js.skyflow.com/v1/elements/index.html",IFRAME_SECURE_ORGIN:"https://js.skyflow.com"},Ae="https://assets.payrails.io/32d29cd/card/index.html",fe="https://assets.payrails.io",Oe={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({},Oe),e);return Object.assign(t.style,le),Te(t,i),t.getAttribute("id")||(t.id=t.name),t};const Re=()=>Le.IFRAME_SECURE_SITE,ge=(e,t)=>{Object.keys(t).forEach((i=>{Object.prototype.hasOwnProperty.call(t,i)&&(e.style[i]=t[i])}))};function Ne(e){return JSON.parse(JSON.stringify(e))}var Se,Pe,be,De,Me,we,ke;!function(e){e.DEFAULT="DEFAULT",e.PLAIN_TEXT="PLAIN_TEXT",e.MASKED="MASKED",e.REDACTED="REDACTED"}(Se||(Se={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH",e.DELETE="DELETE"}(Pe||(Pe={})),function(e){e.CHANGE="CHANGE",e.READY="READY",e.FOCUS="FOCUS",e.BLUR="BLUR",e.SUBMIT="SUBMIT"}(be||(be={})),function(e){e.WARN="WARN",e.INFO="INFO",e.DEBUG="DEBUG",e.ERROR="ERROR"}(De||(De={})),function(e){e.DEV="DEV",e.PROD="PROD"}(Me||(Me={})),function(e){e.LOG="LOG",e.WARN="WARN",e.ERROR="ERROR"}(we||(we={})),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"}(ke||(ke={}));const Ye={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}},Ue={PROD:{doesReturnValue:!1},DEV:{doesReturnValue:!0}},xe="[Skyflow]",Fe=(e,t,i)=>{if(i&&Ye[i]){const{showDebugLogs:n,showInfoLogs:o,showWarnLogs:s,showErrorLogs:r}=Ye[i];t===we.LOG&&n?console.log(`${De.DEBUG}: ${xe} ${e}`):t===we.LOG&&o?console.log(`${De.INFO}: ${xe} ${e}`):t===we.WARN&&s?console.warn(`${De.WARN}: ${xe} ${e}`):t===we.ERROR&&r&&console.error(`${De.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]})):""},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},Ve=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)}))},Ge=e=>{let t=!0;try{new RegExp(e)}catch(e){t=!1}return t},Xe=e=>{if(!Object.prototype.hasOwnProperty.call(e,"getBearerToken"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_GET_BEARER_TOKEN_MISSING)},ze=(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(j.COLLECT_ALT_TEXT_DEPERECATED,we.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)},He=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)}))},We=e=>"boolean"==typeof e;function qe(e){const t=e.split(":");return t.length>2?(t.pop(),t.pop(),t.join(":")):""}const $e=(e,t,i)=>{if("string"!=typeof e)return e;if(t===ne.CARD_NUMBER){if(e=e&&e.replace(/\s/g,""),!i){((e="")=>{const t=e.replace(/[\s-]/g,"");let i=oe.DEFAULT;Object.entries(_e).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,o;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),s=i.protocol,r=i.hostname;Le.IFRAME_SECURE_ORGIN=`${s}//${r}`,Le.IFRAME_SECURE_SITE=null===(o=null==e?void 0:e.options)||void 0===o?void 0:o.customElementsURL}Le.IFRAME_SECURE_ORGIN=fe,Le.IFRAME_SECURE_SITE=Ae}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()}),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 Ze{}var Qe,et,tt,it,nt,ot,st,rt,at,lt,ct,dt,ut,_t,pt,Et,ht,It,vt,mt;const yt="Element";class Lt extends Ze{constructor(t,s,r,a,l=!1,c,d,u,_){var p;super(),this.type=Ni.COLLECT,Qe.set(this,void 0),et.set(this,!1),tt.set(this,void 0),it.set(this,void 0),nt.set(this,{isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:void 0,isRequired:!1}),ot.set(this,void 0),st.set(this,new ye),rt.set(this,void 0),at.set(this,Y.getEventBus()),lt.set(this,void 0),ct.set(this,[]),dt.set(this,!1),ut.set(this,void 0),_t.set(this,void 0),pt.set(this,!1),this.getID=()=>i(this,Qe,"f"),this.mount=t=>{var s;if(!t)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_IN_MOUNT);const r=(t,o)=>{if(t.name===i(this,lt,"f").name){o(i(this,ot,"f")),i(this,mt,"f").call(this);const t=e(i(this,tt,"f")[0],["name"]);i(this,it,"f").length>1?i(this,it,"f").forEach(((e,t)=>{i(this,rt,"f")&&i(this,rt,"f")._emit(`${z.READY}:${e.elementName}`,Object.assign(Object.assign({},i(this,tt,"f")[t]),{elementType:e.elementType}))})):i(this,st,"f")._emit(z.READY,Object.assign({},t)),i(this,at,"f").off(H+this.containerId,r),Fe(`${Be(F.ELEMENT_MOUNTED,yt,je(i(this,lt,"f").name))} `,we.LOG,i(this,ut,"f").logLevel),i(this,ct,"f").forEach((e=>e())),n(this,ct,[],"f")}};if(i(this,it,"f").length>1)i(this,lt,"f").mount(t),i(this,at,"f").on(H+this.containerId,r);else{if(i(this,pt,"f"))return i(this,lt,"f").mount(t),void i(this,at,"f").on(H+this.containerId,r);null===(s=i(this,rt,"f"))||void 0===s||s.on(ie,(e=>{(null==e?void 0:e.containerId)===this.containerId&&(i(this,lt,"f").mount(t),i(this,at,"f").on(H+this.containerId,r))}))}},this.unmount=()=>{i(this,lt,"f").unmount()},this.update=e=>{let t=Ne(e);const o=()=>{i(this,et,"f")&&(t={rows:[{elements:[Object.assign({},t)]}]}),n(this,ot,ft(i(this,ot,"f"),t),"f"),n(this,it,Ot(i(this,ot,"f")),"f"),i(this,et,"f")?i(this,at,"f").emit(K,{name:i(this,lt,"f").name,options:i(this,it,"f")[0],isSingleElementAPI:!0}):(i(this,it,"f").forEach((e=>{i(this,at,"f").emit(K,{name:e.elementName,options:e,isSingleElementAPI:!0})})),i(this,at,"f").emit(K,{name:i(this,lt,"f").name,options:i(this,ot,"f"),isSingleElementAPI:!1})),i(this,mt,"f").call(this)};i(this,dt,"f")?o():i(this,ct,"f").push(o)},Et.set(this,(e=>{i(this,et,"f")||i(this,st,"f").on(K,(()=>{e(i(this,it,"f"))}),!0)})),this.updateElement=e=>{i(this,at,"f").emit(K,{name:e.elementName,options:e,isSingleElementAPI:!0})},ht.set(this,(()=>{i(this,tt,"f").forEach(((e,t)=>{if(0===t){i(this,nt,"f").isEmpty=e.isEmpty,i(this,nt,"f").isComplete=e.isComplete,i(this,nt,"f").isValid=e.isValid,i(this,nt,"f").isFocused=e.isFocused,i(this,nt,"f").isRequired=e.isRequired,i(this,nt,"f").value={};const n=i(this,it,"f")[t].elementName,o=e.value&&$e(e.value,e.elementType,i(this,_t,"f"));i(this,et,"f")?i(this,nt,"f").value=o:i(this,nt,"f").value[n]=o}else i(this,nt,"f").isEmpty=i(this,nt,"f").isEmpty||e.isEmpty,i(this,nt,"f").isComplete=i(this,nt,"f").isComplete&&e.isComplete,i(this,nt,"f").isValid=i(this,nt,"f").isValid&&e.isValid,i(this,nt,"f").isFocused=i(this,nt,"f").isFocused||e.isFocused,i(this,nt,"f").isRequired=i(this,nt,"f").isRequired||e.isRequired,i(this,nt,"f").value||(i(this,nt,"f").value={}),i(this,it,"f")[t].sensitive||(i(this,nt,"f").value[i(this,it,"f")[t].elementName]=e.value||"")}))})),this.getState=()=>({isEmpty:i(this,nt,"f").isEmpty,isComplete:i(this,nt,"f").isComplete,isValid:i(this,nt,"f").isValid,isFocused:i(this,nt,"f").isFocused,value:i(this,nt,"f").value,required:i(this,nt,"f").isRequired}),this.getOptions=()=>{let e=Ne(i(this,ot,"f"));return i(this,et,"f")?e=e.rows[0].elements[0]:e.rows.forEach((e=>{e.elements.forEach((e=>{delete e.elementName}))})),delete e.elementName,e},It.set(this,(e=>{i(this,st,"f").on($,(()=>{const t=i(this,it,"f").map((e=>e.elementName));i(this,et,"f")||t.push(i(this,lt,"f").name),e(t)}),!0)})),vt.set(this,(()=>{i(this,at,"f").on(q,(e=>{if(i(this,et,"f")&&e.event===z.READY&&e.name===i(this,lt,"f").name)i(this,st,"f")._emit(z.READY);else{const t=i(this,it,"f").length>1;i(this,it,"f").forEach(((n,s)=>{var r;if(e.name===n.elementName){let a="";switch(e.event){case z.FOCUS:a=z.FOCUS;break;case z.BLUR:a=z.BLUR;break;case z.CHANGE:a=z.CHANGE;break;case z.READY:a=z.READY;break;case z.SUBMIT:return void(null===(r=i(this,rt,"f"))||void 0===r||r._emit(z.SUBMIT));default:throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_EVENT_TYPE)}i(this,tt,"f")[s].isEmpty=e.value.isEmpty,i(this,tt,"f")[s].isValid=e.value.isValid,i(this,tt,"f")[s].isComplete=e.value.isComplete,i(this,tt,"f")[s].isFocused=e.value.isFocused,i(this,tt,"f")[s].isRequired=e.value.isRequired,Object.prototype.hasOwnProperty.call(e.value,"value")?i(this,tt,"f")[s].value=e.value.value:i(this,tt,"f")[s].value=void 0,a=t?`${a}:${e.name}`:a,i(this,at,"f").emit(z.HEIGHT+i(this,lt,"f").name,{},(e=>{i(this,lt,"f").setIframeHeight(e.height)})),i(this,ht,"f").call(this);const l=Object.assign(Object.assign({},i(this,tt,"f")[s]),{elementType:n.elementType});t&&i(this,rt,"f")?i(this,rt,"f")._emit(a,l):i(this,st,"f")._emit(a,l)}}))}}))})),mt.set(this,(()=>{const{rows:e}=i(this,ot,"f");e.forEach((e=>{e.elements.forEach((e=>{e.elementType!==re.radio.name&&e.elementType!==re.checkbox.name&&(e.value=void 0)}))})),n(this,it,Ot(i(this,ot,"f")),"f")})),this.containerId=a.containerId,n(this,Qe,t,"f"),n(this,ut,u,"f"),n(this,ot,ft(s),"f"),n(this,it,Ot(s),"f"),n(this,et,l,"f"),_&&n(this,rt,_,"f"),n(this,_t,Ue[i(this,ut,"f").env].doesReturnValue,"f"),this.elementType=i(this,et,"f")?i(this,it,"f")[0].elementType:"group",n(this,tt,[],"f"),i(this,it,"f").forEach((e=>{i(this,tt,"f").push({isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:i(this,_t,"f")?"":void 0,elementType:e.elementType,name:e.elementName,isRequired:!1})})),n(this,lt,new Je(i(this,ot,"f").elementName,r,this.containerId,i(this,ut,"f").logLevel),"f"),i(this,vt,"f").call(this),i(this,It,"f").call(this,c),i(this,Et,"f").call(this,d),Fe(Be(F.CREATED_ELEMENT,yt,je(i(this,lt,"f").name)),we.LOG,i(this,ut,"f").logLevel),n(this,pt,a.isMounted,"f"),null===(p=i(this,rt,"f"))||void 0===p||p.on(ie,(e=>{(null==e?void 0:e.containerId)===this.containerId&&n(this,pt,!0,"f")}));const E=e=>{e.height&&e.height>0&&i(this,lt,"f").setIframeHeight(e.height)};i(this,at,"f").on(z.MOUNTED,(e=>{a.type===Ni.COMPOSABLE?i(this,it,"f").forEach((t=>{e.name===t.elementName&&(t.isMounted=!0,n(this,dt,!0,"f"))})):e.name===i(this,it,"f")[0].elementName&&(i(this,it,"f")[0].isMounted=!0,n(this,dt,!0,"f")),i(this,at,"f").emit(z.HEIGHT+i(this,lt,"f").name,{},E)}))}on(e,t){if(!Object.values(z).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);i(this,st,"f").on(e,(e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,t(e)}))}iframeName(){return i(this,lt,"f").name}isMounted(){return i(this,dt,"f")}isValidElement(){for(let e=0;e<i(this,it,"f").length;e+=1){if(!Object.prototype.hasOwnProperty.call(i(this,it,"f")[e],"table"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_TABLE_NAME_MISSING);if(!i(this,it,"f")[e].table)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_TABLE);if(!("string"==typeof i(this,it,"f")[e].table||i(this,it,"f")[e].table instanceof String))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TABLE_NAME);if(!Object.prototype.hasOwnProperty.call(i(this,it,"f")[e],"column"))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISSING_COLUMN);if(!i(this,it,"f")[e].column)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_COLUMN);if(!("string"==typeof i(this,it,"f")[e].column||i(this,it,"f")[e].column instanceof String))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_COLUMN);if(void 0!==i(this,it,"f")[e].skyflowID&&!i(this,it,"f")[e].skyflowID)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_SKYFLOW_ID)}return!0}setError(e){i(this,at,"f").emit(Z,{name:qe(i(this,lt,"f").name),isTriggerError:!0,clientErrorText:e})}resetError(){i(this,at,"f").emit(Z,{name:qe(i(this,lt,"f").name),isTriggerError:!1})}setValue(e){i(this,ut,"f").env!==Me.PROD?i(this,et,"f")&&i(this,at,"f").emit(K,{name:i(this,lt,"f").name,options:Object.assign(Object.assign({},i(this,it,"f")[0]),{value:e}),isSingleElementAPI:!0}):Fe(Be(j.UNABLE_TO_SET_VALUE_IN_PROD_ENV,i(this,it,"f")[0].elementType),we.WARN,i(this,ut,"f").logLevel)}clearValue(){i(this,ut,"f").env!==Me.PROD?i(this,et,"f")&&i(this,at,"f").emit(K,{name:i(this,lt,"f").name,options:Object.assign(Object.assign({},i(this,it,"f")[0]),{value:""}),isSingleElementAPI:!0}):Fe(Be(j.UNABLE_TO_CLEAR_VALUE_IN_PROD_ENV,i(this,it,"f")[0].elementType),we.WARN,i(this,ut,"f").logLevel)}}function At(e,t,i={}){if("group"!==e&&!Object.prototype.hasOwnProperty.call(re,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(ke).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===ke.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===ke.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}=re[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===re.radio.name||e===re.checkbox.name)&&!i.value)throw new Error("Elements radio and checkbox requires value attribute");if(!(e!==re.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 ft(e,t={},i=!0){return(t=Object.assign(Object.assign({},e),t)).rows.forEach(((n,o)=>{const s=n,r=e.rows[o];t.rows[o]=Object.assign(Object.assign({},r),s),s.elements.forEach(((e,t)=>{var n,o;const a=r.elements[t],l=e;if(l.elementType&&a.elementType!==l.elementType&&a.elementName&&a.elementName!==l.elementName)throw new Error(B.CANNOT_CHANGE_ELEMENT);At(a.elementType,a,l),s.elements[t]=Object.assign(Object.assign(Object.assign({},a),l),{elementName:a.elementName});const c=l.classes||{},d=l.styles||{};d.base=Object.assign(Object.assign({},de),d.base),l.classes=c,l.styles=d;const u=(null===(n=null==l?void 0:l.labelStyles)||void 0===n?void 0:n.classes)||{},_=(null===(o=null==l?void 0:l.labelStyles)||void 0===o?void 0:o.styles)||{};i&&function(e,t){Object.values(ue).forEach((i=>{if(e[i]||t[i])switch(i){case ue.BASE:t[i]=Object.assign({},t[i]);break;case ue.FOCUS:t[ue.BASE]=Object.assign(Object.assign({},t[ue.BASE]),{":focus":Object.assign({},t[ue.BASE]&&t[ue.BASE][":focus"])});break;case ue.WEBPACKAUTOFILL:t[ue.BASE]=Object.assign(Object.assign({},t[ue.BASE]),{":-webkit-autofill":Object.assign({},t[ue.BASE]&&t[ue.BASE][":-webkit-autofill"])});break;default:t[i]=Object.assign(Object.assign({},t[ue.BASE]),t[i])}})),Object.keys(t).forEach((e=>{const i=t[e][":-webkit-autofill"];"object"==typeof i&&Object.keys(i).forEach((e=>{i[e]&&!i[e].includes("!important")&&(i[e]=`${i[e]} !important`)}))}))}(u,_),l.labelStyles={labelClasses:u},l.labelStyles.styles=_}))})),t}Qe=new WeakMap,et=new WeakMap,tt=new WeakMap,it=new WeakMap,nt=new WeakMap,ot=new WeakMap,st=new WeakMap,rt=new WeakMap,at=new WeakMap,lt=new WeakMap,ct=new WeakMap,dt=new WeakMap,ut=new WeakMap,_t=new WeakMap,pt=new WeakMap,Et=new WeakMap,ht=new WeakMap,It=new WeakMap,vt=new WeakMap,mt=new WeakMap;const Ot=e=>{const{rows:t}=e,i=[];return t.forEach((e=>{e.elements.forEach((e=>{i.push(e)}))})),i},Tt=e=>{const t=e.validations;return t&&Array.isArray(t)&&t.length>0&&t.forEach(((e,t)=>{if(e&&e.type===ke.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===ke.REGEX_MATCH_RULE){if(e.params&&e.params.regex&&!Ge(e.params.regex))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_REGEX_IN_REGEX_MATCH_RULE);e.params&&e.params.regex&&Ge(e.params.regex)&&(e.params.regex=e.params.regex.toString())}})),t},Ct=(e,t,i)=>{let n=Object.assign({required:!1},t);if((Object.prototype.hasOwnProperty.call(n,"format")||Object.prototype.hasOwnProperty.call(n,"translation"))&&(ve.includes(e)?(Fe(Be(j.INPUT_FORMATTING_NOT_SUPPROTED,e),we.WARN,i),null==n||delete n.format,null==n||delete n.translation):e===re.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:me]}),null==n||delete n.format,null==n||delete n.translation)),e===re.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)===ae&&(e="-"),n=Object.assign(Object.assign({},n),{cardSeperator:e}),null==n||delete n.format,null==n||delete n.translation}else if(e===re.EXPIRATION_DATE.name){let e=!1;n.format&&(e=!!(s=n.format.toUpperCase())&&Ee.includes(s),e||Fe(Be(j.INVALID_EXPIRATION_DATE_FORMAT,Ee.toString()),we.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():pe}),null==n||delete n.translation}else if(e===re.EXPIRATION_YEAR.name){let e=!1;n.format&&(e=(e=>!!e&&he.includes(e))(n.format.toUpperCase()),e||Fe(Be(j.INVALID_EXPIRATION_YEAR_FORMAT,he.toString()),we.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")&&!We(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")&&!We(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 Rt(){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 gt{}var Nt,St,Pt,bt,Dt,Mt,wt,kt,Yt,Ut,xt,Ft;const Bt="CollectContainer";class jt extends gt{constructor(e,t,s,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=Ni.COLLECT,Mt.set(this,void 0),wt.set(this,!1),this.create=(e,t={required:!1})=>{ze(e,i(this,bt,"f").logLevel);const n=Tt(e),o=Ct(e.type,t,i(this,bt,"f").logLevel),s={rows:[{elements:[Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column,accept:t.allowedFileType},e),o),{validations:n})]}]};return i(this,kt,"f").call(this,s,!0)},kt.set(this,((e,t=!1)=>{const n=[],s=Ne(e);if(s.rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;At(i,t),t.sensitive=t.sensitive||re[i].sensitive,t.replacePattern=t.replacePattern||re[i].replacePattern,t.mask=t.mask||re[i].mask,t.isMounted=!1,t.elementType!==re.radio.name&&t.elementType!==re.checkbox.name||(t.elementName=`${t.elementName}:${btoa(t.value)}`),t.elementName=`${G}:${t.elementType}:${btoa(Rt())}`,t.label=e.label,t.skyflowID=e.skyflowID,n.push(t)}))})),s.elementName=t?n[0].elementName:`${G}:group:${btoa(s.name)}`,t&&!i(this,St,"f")[n[0].elementName]&&i(this,Ft,"f").call(this,n[0].name))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_UNIQUE_ELEMENT_NAME);let r=i(this,St,"f")[s.elementName];if(r)t?r.update(n[0]):r.update(s);else{const e=Rt();r=new Lt(e,s,i(this,Pt,"f"),{containerId:i(this,Nt,"f"),isMounted:i(this,wt,"f"),type:this.type},t,i(this,Ut,"f"),i(this,xt,"f"),i(this,bt,"f"),i(this,Mt,"f")),i(this,St,"f")[s.elementName]=r,i(this,Dt,"f")[e]=r}return t||n.forEach((e=>{const t=e.elementName;i(this,St,"f")[t]?i(this,St,"f")[t].update(e):i(this,St,"f")[t]=this.create(e.elementType,r)})),r})),Yt.set(this,(e=>{Object.keys(i(this,St,"f")).forEach((t=>{t===e&&delete i(this,St,"f")[t]}))})),Ut.set(this,(e=>{e.forEach((e=>{i(this,Yt,"f").call(this,e)}))})),xt.set(this,(e=>{e.forEach((e=>{i(this,St,"f")[e.elementName]&&i(this,St,"f")[e.elementName].update(e)}))})),Ft.set(this,(e=>{const t=Object.keys(i(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(i(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(ee+i(this,Nt,"f"),{},(t=>{e(t)}))})),this.collect=(e={tokens:!0})=>new Promise(((t,n)=>{try{Xe(i(this,Pt,"f").clientJSON.config);if(Object.values(i(this,St,"f")).forEach((e=>{if(!e.isMounted())throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);e.isValidElement()})),Object.prototype.hasOwnProperty.call(e,"tokens")&&!We(e.tokens))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_TOKENS);(null==e?void 0:e.additionalFields)&&Ve(e.additionalFields),(null==e?void 0:e.upsert)&&He(null==e?void 0:e.upsert),this.bus.emit(W+i(this,Nt,"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)}`,we.ERROR,i(this,bt,"f").logLevel),n(null==e?void 0:e.error)):(Fe(Be(F.COLLECT_SUBMIT_SUCCESS,Bt),we.LOG,i(this,bt,"f").logLevel),t(e))})),Fe(Be(F.EMIT_EVENT,Bt,W),we.LOG,i(this,bt,"f").logLevel)}catch(e){Fe(`${e.message}`,we.ERROR,i(this,bt,"f").logLevel),n(e)}})),this.unmount=()=>{this.iframe.remove()},this.bus=Y.getEventBus(),n(this,Nt,Rt(),"f"),n(this,Pt,t,"f"),n(this,Dt,s,"f"),n(this,bt,r,"f"),n(this,Mt,new ye,"f"),this.iframe=Ce({name:`${V}:${i(this,Nt,"f")}:${i(this,bt,"f").logLevel}`}),Te(this.iframe,{src:Re()}),ge(this.iframe,Object.assign({},ce)),Fe(Be(F.CREATE_COLLECT_CONTAINER,Bt),we.LOG,i(this,bt,"f").logLevel);const a=(e,o)=>{e.name===V+i(this,Nt,"f")&&(o(Object.assign(Object.assign({},t),{clientJSON:Object.assign(Object.assign({},t.clientJSON),{config:Object.assign({},t.clientJSON.config)}),context:r})),n(this,wt,!0,"f"),i(this,Mt,"f")._emit(ie,{containerId:i(this,Nt,"f")}),this.bus.target({origin:Le.IFRAME_SECURE_ORGIN}).off(H+i(this,Nt,"f"),a))};this.bus.target({origin:Le.IFRAME_SECURE_ORGIN}).on(H+i(this,Nt,"f"),a),document.body.append(this.iframe)}}var Vt,Gt,Xt,zt,Ht,Wt,qt,$t,Kt,Jt,Zt,Qt,ei,ti,ii,ni,oi,si,ri,ai,li,ci,di;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,xt=new WeakMap,Ft=new WeakMap;class ui{constructor(e,t){Vt.set(this,void 0),Gt.set(this,void 0),this.type=Ni.COMPOSABLE,Xt.set(this,!1),zt.set(this,!1),this.update=e=>{n(this,zt,!0,"f"),i(this,Xt,"f")?(i(this,Gt,"f")._emit(Q,{elementName:i(this,Vt,"f"),elementOptions:e}),n(this,zt,!1,"f")):i(this,zt,"f")&&i(this,Gt,"f").on(`${be.READY}:${i(this,Vt,"f")}`,(()=>{i(this,Gt,"f")._emit(Q,{elementName:i(this,Vt,"f"),elementOptions:e}),n(this,Xt,!0,"f"),n(this,zt,!1,"f")}))},n(this,Vt,e,"f"),n(this,Gt,t,"f"),i(this,Gt,"f").on(`${be.READY}:${i(this,Vt,"f")}`,(()=>{n(this,Xt,!0,"f")}))}on(e,t){if(!Object.values(z).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);i(this,Gt,"f").on(`${e}:${i(this,Vt,"f")}`,(e=>{if(void 0===e.value&&(e.value=""),"CARD_NUMBER"===e.elementType&&e.value){const{value:t}=e;e.value=t.slice(0,8)}delete e.isComplete,delete e.name,t(e)}))}}Vt=new WeakMap,Gt=new WeakMap,Xt=new WeakMap,zt=new WeakMap;const _i="CollectContainer";class pi extends gt{constructor(e,t,r,a){super(),Ht.set(this,void 0),Wt.set(this,{}),qt.set(this,void 0),$t.set(this,{rows:[]}),Kt.set(this,[]),Jt.set(this,void 0),Zt.set(this,void 0),Qt.set(this,void 0),ei.set(this,!1),ti.set(this,void 0),ii.set(this,void 0),this.type=Ni.COMPOSABLE,ni.set(this,!1),oi.set(this,{}),this.create=(e,t={required:!1})=>{ze(e,i(this,Jt,"f").logLevel);const n=Tt(e),o=Ct(e.type,t,i(this,Jt,"f").logLevel),s=`${G}:${e.type}:${btoa(Rt())}`;return i(this,Kt,"f").push(Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column},e),o),{validations:n,elementName:s})),new ui(s,i(this,Qt,"f"))},si.set(this,((e,t=!1)=>{const s=[];if(n(this,oi,Ne(e),"f"),i(this,oi,"f").rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;At(i,t),t.sensitive=t.sensitive||re[i].sensitive,t.replacePattern=t.replacePattern||re[i].replacePattern,t.mask=t.mask||re[i].mask,t.isMounted=!1,t.label=e.label,t.skyflowID=e.skyflowID,s.push(t)}))})),i(this,oi,"f").elementName=t?s[0].elementName:`${G}:group:${btoa(i(this,oi,"f").name)}`,t&&!i(this,Wt,"f")[s[0].elementName]&&i(this,ci,"f").call(this,s[0].name))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_UNIQUE_ELEMENT_NAME);let r=i(this,Wt,"f")[i(this,oi,"f").elementName];if(r)t?r.update(s[0]):r.update(i(this,oi,"f"));else{const e=Rt();r=new Lt(e,i(this,oi,"f"),i(this,qt,"f"),{containerId:i(this,Ht,"f"),isMounted:i(this,ni,"f"),type:this.type},!0,i(this,ai,"f"),i(this,li,"f"),i(this,Jt,"f"),i(this,Qt,"f")),i(this,Wt,"f")[i(this,oi,"f").elementName]=r,i(this,Zt,"f")[e]=r}return r})),ri.set(this,(e=>{Object.keys(i(this,Wt,"f")).forEach((t=>{t===e&&delete i(this,Wt,"f")[t]}))})),ai.set(this,(e=>{e.forEach((e=>{i(this,ri,"f").call(this,e)}))})),li.set(this,(e=>{e.forEach((e=>{i(this,Wt,"f")[e.elementName]&&i(this,Wt,"f")[e.elementName].update(e)}))})),ci.set(this,(e=>{const t=Object.keys(i(this,Wt,"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(z).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);i(this,Qt,"f").on(z.SUBMIT,(()=>{t()}))},this.mount=e=>{if(!e)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_EMPTY_ELEMENT_IN_MOUNT);const{layout:t}=i(this,ti,"f");if((t||[]).reduce(((e,t)=>e+(s?s(t):t)),0)!==i(this,Kt,"f").length)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_MISMATCH_ELEMENT_COUNT_LAYOUT_SUM);var s;let r=0;if(t.forEach(((e,t)=>{i(this,$t,"f").rows=[...i(this,$t,"f").rows,{elements:[]}];for(let n=0;n<e;n++)i(this,$t,"f").rows[t].elements.push(i(this,Kt,"f")[r]),r++})),i(this,ti,"f").styles&&(i(this,$t,"f").styles=Object.assign({},i(this,ti,"f").styles)),i(this,ti,"f").errorTextStyles&&(i(this,$t,"f").errorTextStyles=Object.assign({},i(this,ti,"f").errorTextStyles)),i(this,ni,"f"))return n(this,ii,i(this,si,"f").call(this,i(this,$t,"f"),!1),"f"),i(this,ii,"f").mount(e),void n(this,ei,!0,"f");i(this,Qt,"f").on(te+i(this,Ht,"f"),(()=>{n(this,ii,i(this,si,"f").call(this,i(this,$t,"f"),!1),"f"),i(this,ii,"f").mount(e),n(this,ei,!0,"f")}))},this.unmount=()=>{var e;null===(e=i(this,ii,"f"))||void 0===e||e.unmount(),this.iframe.remove()},this.validate=()=>new Promise(((e,t)=>{Object.values(i(this,Wt,"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(ee+i(this,Ht,"f"),{},(t=>{e(t)}))})),this.collect=(e={tokens:!0})=>new Promise(((t,n)=>{try{if(Xe(i(this,qt,"f").clientJSON.config),!i(this,ei,"f")){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);throw s.PayrailsLogger.error(e.message,{error:e}),e}Ot(i(this,oi,"f")).forEach((e=>{if(!(null==e?void 0:e.isMounted))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING)}));if(Object.values(i(this,Wt,"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)&&Ve(e.additionalFields),(null==e?void 0:e.upsert)&&He(null==e?void 0:e.upsert),this.bus.emit(W+i(this,Ht,"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)}`,we.ERROR,i(this,Jt,"f").logLevel),n(null==e?void 0:e.error)):(Fe(Be(F.COLLECT_SUBMIT_SUCCESS,_i),we.LOG,i(this,Jt,"f").logLevel),t(e))})),Fe(Be(F.EMIT_EVENT,_i,W),we.LOG,i(this,Jt,"f").logLevel)}catch(e){Fe(`${e.message}`,we.ERROR,i(this,Jt,"f").logLevel),n(e)}})),di.set(this,(()=>{i(this,Qt,"f").on(Q,(e=>{let t;const n=i(this,Kt,"f").map(((i,n)=>i.elementName===e.elementName?(t=n,Object.assign({elementName:i.elementName},e.elementOptions)):i));i(this,ii,"f")&&i(this,ii,"f").updateElement(Object.assign({},n[t]))}))})),this.bus=Y.getEventBus(),n(this,Ht,Rt(),"f"),n(this,qt,t,"f"),n(this,Zt,r,"f"),n(this,Jt,a,"f"),n(this,ti,e,"f"),n(this,Qt,new ye,"f"),this.iframe=Ce({name:`${V}:${i(this,Ht,"f")}:${i(this,Jt,"f").logLevel}`}),Te(this.iframe,{src:Re()}),ge(this.iframe,Object.assign({},ce)),Fe(Be(F.CREATE_COLLECT_CONTAINER,_i),we.LOG,i(this,Jt,"f").logLevel);const l=(e,o)=>{e.name===V+i(this,Ht,"f")&&(o(Object.assign(Object.assign({},t),{clientJSON:Object.assign(Object.assign({},t.clientJSON),{config:Object.assign({},t.clientJSON.config)}),context:a})),n(this,ni,!0,"f"),i(this,Qt,"f")._emit(te+i(this,Ht,"f"),{containerId:i(this,Ht,"f")}),this.bus.target({origin:Le.IFRAME_SECURE_ORGIN}).off(H+i(this,Ht,"f"),l))};this.bus.target({origin:Le.IFRAME_SECURE_ORGIN}).on(H+i(this,Ht,"f"),l),document.body.append(this.iframe),i(this,di,"f").call(this)}}function Ei(e){this.message=e}Ht=new WeakMap,Wt=new WeakMap,qt=new WeakMap,$t=new WeakMap,Kt=new WeakMap,Jt=new WeakMap,Zt=new WeakMap,Qt=new WeakMap,ei=new WeakMap,ti=new WeakMap,ii=new WeakMap,ni=new WeakMap,oi=new WeakMap,si=new WeakMap,ri=new WeakMap,ai=new WeakMap,li=new WeakMap,ci=new WeakMap,di=new WeakMap,Ei.prototype=new Error,Ei.prototype.name="InvalidCharacterError";var hi="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new Ei("'atob' failed: The string to be decoded is not correctly encoded.");for(var i,n,o=0,s=0,r="";n=t.charAt(s++);~n&&(i=o%4?64*i+n:n,o++%4)?r+=String.fromCharCode(255&i>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return r};function Ii(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(hi(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 hi(t)}}function vi(e){this.message=e}vi.prototype=new Error,vi.prototype.name="InvalidTokenError";const mi=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 vi("Invalid token specified");var i=!0===(t=t||{}).header?0:1;try{return JSON.parse(Ii(e.split(".")[i]))}catch(e){throw new vi("Invalid token specified: "+e.message)}}(e),o=(new Date).getTime()/1e3,s=n.exp;return s&&o>s&&(i=!0),!i}catch(e){return!1}var t};var yi,Li,Ai,fi,Oi,Ti,Ci,Ri,gi,Ni,Si={name:"skyflow-js",preferGlobal:!0,analyze:!1,version:"1.30.1",author:"Skyflow",description:"Skyflow JavaScript SDK"};class Pi{constructor(e,t){yi.set(this,void 0),this.request=e=>new Promise(((t,n)=>{var s,r,a,l;const c=new XMLHttpRequest;if(c){if(c.open(e.requestMethod,e.url),e.headers){const t=function(e,t,i){var n,o,s,r,a;const l={sdkName:e.name,sdkVersion:e.version},c=function(e,t){return""!==e?`${e}`:`${t.sdkName}@${t.sdkVersion}`}(t.sdkVersion,l),d=function(e){var t,i,n,o,s,r,a,l,c,d,u,_;let p=null,E=null;return/Windows/.test(e)?(p="Windows",E=null!==(i=null===(t=/Windows NT (\d+\.\d+)/.exec(e))||void 0===t?void 0:t[1])&&void 0!==i?i:null):/Android/.test(e)?(p="Android",E=null!==(o=null===(n=/Android (\d+\.\d+)/.exec(e))||void 0===n?void 0:n[1])&&void 0!==o?o:null):/iOS/.test(e)||/iPhone/.test(e)?(p="iOS",E=null!==(a=null===(r=null===(s=/OS (\d+[._]\d+[._]?\d*)/.exec(e))||void 0===s?void 0:s[1])||void 0===r?void 0:r.replace(/_/g,"."))&&void 0!==a?a:null):/Mac OS X/.test(e)?(p="Mac OS X",E=null!==(d=null===(c=null===(l=/Mac OS X (\d+([._]\d+)*)/.exec(e))||void 0===l?void 0:l[1])||void 0===c?void 0:c.replace(/_/g,"."))&&void 0!==d?d:null):/Linux/.test(e)&&(p="Linux",E=null!==(_=null===(u=/Linux( \w+)*?\/([\w.]+)/.exec(e))||void 0===u?void 0:u[2])&&void 0!==_?_:null),{os:p,version:E}}(i.userAgent),u=function(e){let t="",i="";if(-1!==e.indexOf("MSIE")||-1!==e.indexOf("Trident/")){t="Internet Explorer";const n=e.match(/(MSIE|rv:)\s?([\d.]+)/);n&&(i=n[2])}else if(-1!==e.indexOf("Edge")){t="Microsoft Edge";const n=e.match(/Edge\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Chrome")){t="Google Chrome";const n=e.match(/Chrome\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Firefox")){t="Mozilla Firefox";const n=e.match(/Firefox\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Safari")){t="Apple Safari";const n=e.match(/Version\/([\d.]+)/);n&&(i=n[1])}return{browserName:t,browserVersion:i}}(i.userAgent);var _;return{sdk_name_version:c,sdk_client_device_model:(_=i.userAgent,/(ipad|tablet)/gi.test(_)?"tablet":/Mobile|iP(hone|od)|Android|BlackBerry|IEMobile/.test(_)?"mobile":"desktop"),sdk_os_version:null!==(n=i.platform)&&void 0!==n?n:`${null!==(o=d.os)&&void 0!==o?o:""} ${null!==(s=d.version)&&void 0!==s?s:""}`,sdk_runtime_details:`${null!==(r=u.browserName)&&void 0!==r?r:""} ${null!==(a=u.browserVersion)&&void 0!==a?a:""}`}}(Si,i(this,yi,"f"),navigator);e.headers["sky-metadata"]=JSON.stringify(t);const{headers:n}=e;Object.keys(e.headers).forEach((e=>{"content-type"===e&&n[e]&&n[e].includes(Ie.FORMDATA)||c.setRequestHeader(e,n[e])}))}(null===(r=null===(s=e.headers)||void 0===s?void 0:s["content-type"])||void 0===r?void 0:r.includes(Ie.FORMURLENCODED))||(null===(l=null===(a=e.headers)||void 0===a?void 0:a["content-type"])||void 0===l?void 0:l.includes(Ie.FORMDATA))?c.send(e.body):c.send(JSON.stringify(Object.assign({},e.body))),c.onload=()=>{var e,i,s;const r=c.getAllResponseHeaders().trim().split(/[\r\n]+/),a={};r.forEach((e=>{const t=e.split(": "),i=t.shift()||"",n=t.join(": ");a[i]=n}));const l=a["content-type"],d=a["x-request-id"];if(c.status<200||c.status>=400)if(l&&l.includes("application/json")){let t=JSON.parse(c.response);(null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.message)&&(t=d?`${null===(i=null==t?void 0:t.error)||void 0===i?void 0:i.message} - requestId: ${d}`:null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.message),n(new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_VAULT_NETWORK_ERROR,{description:t}))}else l&&l.includes("text/plain")?n(new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_VAULT_NETWORK_ERROR,{description:d?`${c.response} - requestId: ${d}`:c.response})):n(new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_VAULT_NETWORK_ERROR,{description:d?`${B.ERROR_OCCURED} - requestId: ${d}`:B.ERROR_OCCURED}));l&&l.includes("application/json")&&t(JSON.parse(c.response)),t(c.response)},c.onerror=()=>{n(new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_VAULT_NETWORK_ERROR))}}else n(new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_VAULT_CONNECTION_ERROR))})),this.config=e,n(this,yi,t,"f")}toJSON(){return{config:this.config,metaData:i(this,yi,"f")}}static fromJSON(e){return new Pi(e.config,e.metaData)}}yi=new WeakMap,function(e){e.COLLECT="COLLECT",e.COMPOSABLE="COMPOSABLE"}(Ni||(Ni={}));const bi="Skyflow";class Di{constructor(e){var t,r;Li.set(this,void 0),Ai.set(this,Rt()),fi.set(this,{uuid:i(this,Ai,"f"),clientDomain:window.location.origin}),Oi.set(this,""),Ti.set(this,void 0),Ci.set(this,void 0),Ri.set(this,void 0),gi.set(this,void 0),this.bus=Y.getEventBus();const a=localStorage.getItem("sdk_version")||"";i(this,fi,"f").sdkVersion=a,n(this,Li,new Pi(Object.assign({},e),i(this,fi,"f")),"f"),n(this,Ci,(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||De.ERROR,"f"),n(this,Ri,(null===(r=null==e?void 0:e.options)||void 0===r?void 0:r.env)||Me.PROD,"f"),n(this,gi,{},"f");this.bus.on(X,(e=>{if(e&&e.errorCode){const t=new o.PayrailsError(e.errorCode,{cause:null==e?void 0:e.originalError});s.PayrailsLogger.error(t.message,{error:t})}})),this.bus.target({origin:Le.IFRAME_SECURE_ORGIN}).on(J+i(this,Ai,"f"),((e,t)=>{Fe(Be(F.CAPTURED_BEARER_TOKEN_EVENT,bi),we.LOG,i(this,Ci,"f")),!i(this,Li,"f").config.getBearerToken||i(this,Oi,"f")&&mi(i(this,Oi,"f"))?(Fe(Be(F.REUSE_BEARER_TOKEN,bi),we.LOG,i(this,Ci,"f")),t({authToken:i(this,Oi,"f")})):i(this,Li,"f").config.getBearerToken().then((e=>{mi(e)?(Fe(Be(F.BEARER_TOKEN_RESOLVED,bi),we.LOG,i(this,Ci,"f")),n(this,Oi,e,"f"),t({authToken:i(this,Oi,"f")})):(Fe(B.INVALID_BEARER_TOKEN,we.ERROR,i(this,Ci,"f")),t({error:B.INVALID_BEARER_TOKEN}))})).catch((e=>{Fe(B.BEARER_TOKEN_REJECTED,we.ERROR,i(this,Ci,"f")),t({error:e})}))})),Fe(Be(F.BEARER_TOKEN_LISTENER,bi),we.LOG,i(this,Ci,"f")),Fe(Be(F.CURRENT_ENV,bi,i(this,Ri,"f")),we.LOG,i(this,Ci,"f")),Fe(Be(F.CURRENT_LOG_LEVEL,bi,i(this,Ci,"f")),we.LOG,i(this,Ci,"f"))}static init(e){var t;const i=(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||De.ERROR;Ke(e),Fe(Be(F.INITIALIZE_CLIENT,bi),we.LOG,i);const n=e;var o;n.vaultURL="string"!=typeof(o=e.vaultURL)?o:"/"===(null==o?void 0:o.trim().slice(-1))?o.slice(0,-1):o.trim();const s=new Di(n);return Fe(Be(F.CLIENT_INITIALIZED,bi),we.LOG,i),s}container(e,t){switch(e){case Ni.COLLECT:{const n=new jt(t,Object.assign(Object.assign({},i(this,fi,"f")),{clientJSON:i(this,Li,"f").toJSON(),containerType:e}),i(this,gi,"f"),{logLevel:i(this,Ci,"f"),env:i(this,Ri,"f")});return Fe(Be(F.COLLECT_CONTAINER_CREATED,bi),we.LOG,i(this,Ci,"f")),n}case Ni.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 n=new pi(t,Object.assign(Object.assign({},i(this,fi,"f")),{clientJSON:i(this,Li,"f").toJSON(),containerType:e}),i(this,gi,"f"),{logLevel:i(this,Ci,"f"),env:i(this,Ri,"f")});return Fe(Be(F.COLLECT_CONTAINER_CREATED,bi),we.LOG,i(this,Ci,"f")),n}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 Ni}static get ElementType(){return ne}static get RedactionType(){return Se}static get RequestMethod(){return Pe}static get LogLevel(){return De}static get EventName(){return be}static get Env(){return Me}static get ValidationRuleType(){return ke}}function Mi(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="",o="";Array.isArray(t)?t.length>1?(n="*",o=t.toString()):n=t.toString():"string"==typeof t&&t.length>0?n=t:"string"==typeof i&&i.length>0&&(n="*",o=i);e["merchant-id"]=n,e["data-merchant-id"]=o}(e);var i=Object.keys(e).filter((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})).reduce((function(t,i){var n=e[i].toString();return"data-"===i.substring(0,5)?t.dataAttributes[i]=n:t.queryParams[i]=n,t}),{queryParams:{},dataAttributes:{}}),n=i.queryParams,o=i.dataAttributes;return{url:"".concat(t,"?").concat(wi(n)),dataAttributes:o}}function wi(e){var t="";return Object.keys(e).forEach((function(i){0!==t.length&&(t+="&"),t+=i+"="+e[i]})),t}function ki(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 Yi(e,t){if(void 0===t&&(t=Ui()),Fi(e,t),"undefined"==typeof window)return t.resolve(null);var i=Mi(e),n=i.url,o=i.dataAttributes,s=o["data-namespace"]||"paypal",r=xi(s);
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.
@@ -18,8 +18,8 @@ Copyright (c) 2022 Skyflow, Inc.
18
18
  * See the License for the specific language governing permissions and
19
19
  * limitations under the License.
20
20
  */
21
- return function(e,t){var i=document.querySelector('script[src="'.concat(e,'"]'));if(null===i)return null;var n=ki(e,t),o=i.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(n.dataset).length)return null;var s=!0;return Object.keys(o.dataset).forEach((function(e){o.dataset[e]!==n.dataset[e]&&(s=!1)})),s?i:null}(n,o)&&r?t.resolve(r):function(e,t){void 0===t&&(t=Ui());Fi(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,o=e.onError,s=ki(t,i);s.onerror=o,s.onload=n,document.head.insertBefore(s,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:o},t).then((function(){var e=xi(s);if(e)return e;throw new Error("The window.".concat(s," global variable is not available."))}))}function Ui(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function xi(e){return window[e]}function Fi(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.")}Li=new WeakMap,Ai=new WeakMap,fi=new WeakMap,Oi=new WeakMap,Ti=new WeakMap,Ri=new WeakMap,Ci=new WeakMap,gi=new WeakMap;class Bi{static load(e,i){const n=e.toString(),o=Bi.scriptMap.get(n);if(o)return o;const s=(()=>t(this,void 0,void 0,(function*(){try{if(e===ji.PayPal){if(!i)throw new Error("PayPal config is required");return yield Bi.loadPayPalScript(i)}return yield Bi.loadScript(e)}finally{Bi.scriptMap.delete(n)}})))();return Bi.scriptMap.set(n,s),s}static reset(){Bi.scriptMap.clear()}static preloadCardForm(){const e="https://assets.payrails.io/da44fa4/card";[[`${e}/index.js`,"payrails-iframe-js-v2"],[`${e}/index.html`,"payrails-iframe-html-v2"]].forEach((([e,t])=>{if(!document.getElementById(t)){const i=document.createElement("link");i.id=t,i.rel="preload",i.as="script",i.href=e,document.head.appendChild(i)}}))}static loadScript(e){const t=`payrails-script-${JSON.stringify(e)}`;if(Bi.scriptMap.has(t))return Bi.scriptMap.get(t);const i=document.createElement("script");i.src=e,i.id=t;const n=new Promise(((t,n)=>{i.onload=()=>t(),i.onerror=t=>n(Bi.logLoadError(e,new Error(t.toString())))}));return Bi.scriptMap.set(t,n),document.body.appendChild(i),n}static loadPayPalScript(e){return t(this,arguments,void 0,(function*({clientId:e,currency:t,vault:i,intent:n}){try{const o=yield Yi({"client-id":e,components:"buttons,funding-eligibility",intent:n,currency:t,vault:i,"data-namespace":"payrailsPaypal"});if(o)return o}catch(e){throw Bi.logLoadError(ji.PayPal,e)}throw Bi.logLoadError(ji.PayPal)}))}constructor(){}static logLoadError(e,t){const i=new Map([[ji.ApplePay,o.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR],[ji.GooglePay,o.ERROR_CODES.PAYRAILS_CLIENT_GPAY_LOADING_ERROR],[ji.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 s.PayrailsLogger.error(n.message,{error:n}),n}}var ji;Bi.scriptMap=new Map,function(e){e.ApplePay="https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js",e.GooglePay="https://pay.google.com/gp/p/js/pay.js",e.PayPal="paypal-sdk"}(ji||(ji={}));class Vi extends U{constructor(e){super("span",{id:e.id,className:"payrails-store-instrument"}),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,o,s,r,a,l,c;const d=(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===(s=null===(o=null===(n=this.options)||void 0===n?void 0:n.translations)||void 0===o?void 0:o.labels)||void 0===s?void 0:s.storeInstrument)||"Save instrument for future payments",u=`${this.id}-checkbox`;(null===(l=null===(a=null===(r=this.options)||void 0===r?void 0:r.translations)||void 0===a?void 0:a.labels)||void 0===l?void 0:l.saveInstrument)&&console.warn("The saveInstrument label is deprecated, please use storeInstrument instead");const _="checked"==(null===(c=this.options)||void 0===c?void 0:c.defaultStoreInstrumentState);this.element.innerHTML=`<label for="${u}"><input type="checkbox" id="${u}" name="${u}" class="payrails-store-instrument-checkbox">${d}</label>`,_&&(this.element.querySelector("input").checked=!0)}applyStyles(){var e,t;Object.keys((null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.storeInstrumentCheckbox)||{}).forEach((e=>{var t,i,n;this.element.style[e]=null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.storeInstrumentCheckbox)||void 0===n?void 0:n[e]}))}addListeners(){this.element.addEventListener("change",(e=>{var t,i,n,o;(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onSaveInstrumentCheckboxChanged)&&(null===(o=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===o||o.onSaveInstrumentCheckboxChanged({checked:this.isChecked})),e.stopPropagation(),e.stopImmediatePropagation()})),this.element.addEventListener("click",(e=>{e.stopPropagation(),e.stopImmediatePropagation()}))}}class Gi extends U{constructor(e,i){var n,o;super(e,i),this.options=i,this.storeInstrumentCheckbox=null,(null===(n=this.options)||void 0===n?void 0:n.showStoreInstrumentCheckbox)&&(this.storeInstrumentCheckbox=new Vi(Object.assign(Object.assign({},i),{id:`${null===(o=this.options)||void 0===o?void 0:o.id}-store-instrument-checkbox`,events:{onSaveInstrumentCheckboxChanged:e=>t(this,void 0,void 0,(function*(){var t,n;null===(n=null===(t=null==i?void 0:i.events)||void 0===t?void 0:t.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(t,e)}))}})),this.subElements.push(this.storeInstrumentCheckbox))}get shouldStoreInstrument(){var e,t;return(null===(e=this.storeInstrumentCheckbox)||void 0===e?void 0:e.isChecked)||(null===(t=this.options)||void 0===t?void 0:t.alwaysStoreInstrument)||!1}}class Xi extends Gi{static isApplePayAvailable(){return t(this,void 0,void 0,(function*(){try{return yield Bi.load(ji.ApplePay),ApplePaySession.canMakePayments()}catch(e){return!1}}))}constructor(e){super("div",Object.assign(Object.assign({},e),{id:"payrails-apple-pay-button"})),this.options=e,this.appleButton=null,this.paymentExecutor=new b,Xi.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))}))}mount(e){this.unmount(),super.mount(e),(()=>{t(this,void 0,void 0,(function*(){try{(yield Xi.isApplePayAvailable())&&(yield this.mountApplePayButton())}catch(e){}}))})()}unmount(){var e,t;null===(t=null===(e=this.appleButton)||void 0===e?void 0:e.parentElement)||void 0===t||t.removeChild(this.appleButton),super.unmount()}mountApplePayButton(){return t(this,void 0,void 0,(function*(){var e,i,n;try{const o=(null===(e=this.options.styles)||void 0===e?void 0:e.type)||"buy",s=(null===(i=this.options.styles)||void 0===i?void 0:i.style)||"black";this.element.innerHTML=`<apple-pay-button buttonstyle="${s}" type="${o}" locale="en-GB"></apple-pay-button>`,null===(n=this.storeInstrumentCheckbox)||void 0===n||n.mount(this.selector);const r=this.element.querySelector("apple-pay-button");null==r||r.setAttribute("style","width: 100%;"),null==r||r.addEventListener("click",(()=>t(this,void 0,void 0,(function*(){yield this.createApplePaySession()}))))}catch(e){}}))}createApplePaySession(){return t(this,void 0,void 0,(function*(){const e=R.applePayConfig,{countryCode:i,supportedNetworks:n,merchantCapabilities:o,requiredBillingContactFields:s=[]}=e,{amount:r}=g();try{const e=new ApplePaySession(3,{countryCode:i,currencyCode:r.currency,merchantCapabilities:o,supportedNetworks:n,total:{label:"",type:"final",amount:r.value},requiredBillingContactFields:s});e.onvalidatemerchant=i=>t(this,void 0,void 0,(function*(){const{res:t}=yield this.paymentExecutor.createApplePaySession({requestUrl:R.createSessionLink,sessionUrl:i.validationURL,clientDomain:this.options.clientDomain}),n=t.data.data;e.completeMerchantValidation(n)})),e.oncancel=()=>{var e,t,i;(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onAuthorizeFailed)&&(null===(i=this.options)||void 0===i||i.events.onAuthorizeFailed())},e.onpaymentauthorized=i=>t(this,void 0,void 0,(function*(){var t,n,o,s,r,a,l,c,d,u,_,p;try{const u=yield this.onApplePayAuthorized(i.payment.token,{billingContact:i.payment.billingContact});if("authorizeSuccessful"===(null===(t=null==u?void 0:u.finalState)||void 0===t?void 0:t.code))(null===(n=this.options.events)||void 0===n?void 0:n.onAuthorizeSuccess)&&this.options.events.onAuthorizeSuccess();else e.completePayment(ApplePaySession.STATUS_FAILURE),(null===(s=null===(o=this.options)||void 0===o?void 0:o.events)||void 0===s?void 0:s.onAuthorizeFailed)&&(null===(r=this.options)||void 0===r||r.events.onAuthorizeFailed());e.completePayment(ApplePaySession.STATUS_SUCCESS),(null===(l=null===(a=this.options)||void 0===a?void 0:a.events)||void 0===l?void 0:l.onAuthorizeSuccess)&&(null===(d=null===(c=this.options)||void 0===c?void 0:c.events)||void 0===d||d.onAuthorizeSuccess(u))}catch(t){e.completePayment(ApplePaySession.STATUS_FAILURE),(null===(_=null===(u=this.options)||void 0===u?void 0:u.events)||void 0===_?void 0:_.onAuthorizeFailed)&&(null===(p=this.options)||void 0===p||p.events.onAuthorizeFailed(t))}}));return(yield L(this.options.events))&&e.begin(),e}catch(e){return null}}))}onApplePayAuthorized(e,i){return t(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},e),{paymentNetwork:e.paymentMethod.network,paymentInstrumentName:e.paymentMethod.displayName}),n={paymentToken:JSON.stringify(t)};(null==i?void 0:i.billingContact)&&(n.billingAddress={country:{name:null==i?void 0:i.billingContact.country,code:null==i?void 0:i.billingContact.countryCode},postalCode:null==i?void 0:i.billingContact.postalCode});const o=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.APPLE_PAY,integrationType:"api",paymentInstrumentData:n,amount:g().amount,storeInstrument:this.shouldStoreInstrument}];return yield this.paymentExecutor.pay(o)}))}}const zi={wrapper:{display:"flex",flexDirection:"column"}};var Hi;!function(e){e.GET="GET"}(Hi||(Hi={}));class Wi extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{description:`[${t}] ${e} unsuccessful`})}}class qi extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} too many requests`})}}const $i=({url:e})=>t(void 0,[{url: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 qi(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 Ki extends U{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 Ji="__payrails-selectedCountry";class Zi extends Ki{constructor(e){var t,i;super("span",Object.assign(Object.assign({},e),{id:"payrails-country-select",className:"payrails-country-selector-wrapper",styles:null===(t=e.styles)||void 0===t?void 0:t.wrapper})),this.options=e,this._countriesList=null===(i=e.config)||void 0===i?void 0:i.data,this.createHTML(),this.attachEvents()}set countriesList(e){this._countriesList=e,this.populateCountrySelect(),this.setDefaultCountry()}get countriesList(){return this._countriesList}populateCountrySelect(){return t(this,void 0,void 0,(function*(){var e,t;const i=document.createElement("option");i.value="",i.textContent=(null===(e=this.options.translations)||void 0===e?void 0:e.placeholder)||"Select Country",null===(t=this.selectElement)||void 0===t||t.appendChild(i),this._countriesList.forEach((e=>{var t;const i=document.createElement("option");i.value=e.code,i.textContent=e.name,null===(t=this.selectElement)||void 0===t||t.appendChild(i)}))}))}setDefaultCountry(){const e=JSON.parse(sessionStorage.getItem(Ji)||"{}");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(Ji,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(Ji,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,o,s;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===(s=null===(n=this._countriesList)||void 0===n?void 0:n.get(null===(o=this.selectElement)||void 0===o?void 0:o.value))||void 0===s?void 0:s.iso3)||""}}set value(e){this.selectElement&&(this.selectElement.value=e)}}class Qi extends Ki{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,o=this.selectedCountry,s=(null===(i=null===(t=this._countriesList)||void 0===t?void 0:t.get(o))||void 0===i?void 0:i.postalCodeRegex)||"";let r=!1;if(n)return r=s?new RegExp(s).test(n):n.length>0,r}setValidation(e){this.inputElement&&(this.inputElement.pattern=e,this.inputElement.classList.remove("error"))}}class en extends U{get fullAddress(){var e,t,i,n;const o={},s=null===(e=this.countrySelector)||void 0===e?void 0:e.value;return s&&(o.country=s,s.code&&(null===(i=null===(t=this.countriesMap)||void 0===t?void 0:t.get(s.code))||void 0===i?void 0:i.showPostalCode)&&(o.postalCode=null===(n=this.postalCodeInput)||void 0===n?void 0:n.value)),Object.assign({},o)}constructor(e){var i,n;super("div",{id:e.id,className:"payrails-address-selector-wrapper",styles:(null===(i=e.styles)||void 0===i?void 0:i.wrapper)||(null===(n=zi)||void 0===n?void 0:n.wrapper)}),this.options=e,this.countriesMap=void 0,this.createAddressComponents(),this.init(),this.applyStyles(),t(void 0,void 0,void 0,(function*(){const e=yield $i({url:"https://assets.payrails.io/json/countries.json"});return new Map(Object.entries(e.res))})).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,o,s,r,a,l,c,d,u,_;const p={id:"country-selector",styles:(null===(t=this.options.styles)||void 0===t?void 0:t.countrySelector)||(null===(i=zi)||void 0===i?void 0:i.countrySelector),events:{onChange:e=>{var t,i;const{country:n}=e;this.onCountryChange(n),null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onBillingAddressChanged)||void 0===i||i.call(t,{isValid:this.isValid,billingAddress:this.fullAddress})}},translations:{label:null===(o=null===(n=this.options.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.countrySelector,placeholder:null===(r=null===(s=this.options.translations)||void 0===s?void 0:s.placeholders)||void 0===r?void 0:r.countrySelector}},E={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===(d=null===(c=this.options.translations)||void 0===c?void 0:c.placeholders)||void 0===d?void 0:d.postalCodeInput},styles:(null===(u=this.options.styles)||void 0===u?void 0:u.postalCodeInput)||(null===(_=zi)||void 0===_?void 0:_.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 Zi(p),this.postalCodeInput=new Qi(E)}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 o=this.countrySelector&&this.countrySelector.isValid;const s=null===(t=null===(e=this.countrySelector)||void 0===e?void 0:e.value)||void 0===t?void 0:t.code;return s&&(null===(n=null===(i=this.countriesMap)||void 0===i?void 0:i.get(s))||void 0===n?void 0:n.showPostalCode)&&(o=o&&this.postalCodeInput&&this.postalCodeInput.isValid),!!o}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 tn extends U{constructor(e){super("div",{id:e.id,className:e.className}),this.options=e,this.installmentOptions=[],this.installmentOptions=e.installmentOptions||[],this.createHTML(),this.applyStyles(),this.addListeners()}generateOptionsHTML(e){var t,i,n;return[`<option value="">${(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"}</option>`,...(null==e?void 0:e.map((e=>`<option value="${e.count}">${e.count} x ${e.amount}</option>`)))||[]].join("")}renderOptions(e){const t=this.element.querySelector("select");t&&(t.innerHTML=this.generateOptionsHTML(e),e.length>0?this.setDisabled(!1):this.setDisabled(!0))}updateOptions(e){this.installmentOptions=e,this.renderOptions(e)}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=>{e.stopPropagation(),e.stopImmediatePropagation()})),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 nn extends U{constructor(e,t){var i,n,o;super(e,t),this.options=t,this.paymentInstallmentsDropdown=null,this.paymentInstallmentsDropdown=new tn(Object.assign(Object.assign({},t),{id:`${null===(i=this.options)||void 0===i?void 0:i.id}-dropdown`,className:"payrails-payment-installments-dropdown",installmentCurrency:null===(n=this.options)||void 0===n?void 0:n.installmentCurrency,installmentOptions:null===(o=this.options)||void 0===o?void 0:o.installmentOptions})),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))}setDisabled(e){var t;null===(t=this.paymentInstallmentsDropdown)||void 0===t||t.setDisabled(e)}}const{CARD_NUMBER:on,CVV:sn,CARDHOLDER_NAME:rn,EXPIRATION_DATE:an,EXPIRATION_MONTH:ln,EXPIRATION_YEAR:cn}=exports.ElementType,dn={base:{border:"none",padding:"10px 16px",color:"#1d1d1d",backgroundColor:"#fff"},invalid:{backgroundColor:"#f9e1e1",borderColor:"#f25226",border:"1px solid"}},un=[{type:rn,placeholder:"Card holder",styles:Object.assign(Object.assign({},dn),{base:Object.assign(Object.assign({},dn.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px"})})},{type:on,placeholder:"1234 1234 1234 1234",styles:Object.assign(Object.assign({},dn),{base:Object.assign(Object.assign({},dn.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:ln,placeholder:"MM",styles:Object.assign(Object.assign({},dn),{base:Object.assign(Object.assign({},dn.base),{borderBottom:"1px solid #eae8ee",borderLeft:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomLeftRadius:"4px"})})},{type:cn,placeholder:"YY",format:"YY",styles:Object.assign(Object.assign({},dn),{base:Object.assign(Object.assign({},dn.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee"})})},{type:an,placeholder:"MM/YY",format:"MM/YY",styles:Object.assign(Object.assign({},dn),{base:Object.assign(Object.assign({},dn.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:sn,placeholder:"CVC",styles:Object.assign(Object.assign({},dn),{base:Object.assign(Object.assign({},dn.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomRightRadius:"4px"}),cardIcon:{position:"absolute",right:"8px",height:"24px",bottom:"calc(50% - 12px)"}})}];class _n extends Gi{get bin(){return this.collectContainer.bin}get isBinLookupEnabled(){return this.collectContainer.isBinLookupEnabled}constructor(e,t){var i,n,o,s,r;super("div",Object.assign(Object.assign({},t),{translations:Object.assign(Object.assign({},null==t?void 0:t.translations),{labels:Object.assign(Object.assign({},null===(i=null==t?void 0:t.translations)||void 0===i?void 0:i.labels),{saveInstrument:null===(o=null===(n=null==t?void 0:t.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.saveCreditCard})}),styles:Object.assign({storeInstrumentCheckbox:null===(s=null==t?void 0:t.styles)||void 0===s?void 0:s.storeCardCheckbox},null==t?void 0:t.styles),id:"payrails-card-form"})),this.collectContainer=e,this.options=t,this.formFields=[],this.paymentInstallmentsDropdown=null,this.addressComponent=null,this.lastBin=null,this.lastBinLookup=null,this.throttledFetchBinLookup=function(e,t){let i,n;return function(...o){return new Promise(((s,r)=>{n?(clearTimeout(i),i=setTimeout((()=>{Date.now()-n>=t&&(e(...o).then(s).catch(r),n=Date.now())}),t-(Date.now()-n))):(e(...o).then(s).catch(r),n=Date.now())}))}}(this.fetchBinLookup.bind(this),500),(null===(r=null==t?void 0:t.styles)||void 0===r?void 0:r.storeCardCheckbox)&&console.warn("The `storeCardCheckbox` option for styles is deprecated. Please use `storeInstrumentCheckbox` instead."),this.initializeFormFields(),this.subElements.push(this.collectContainer),R.isPaymentInstallmentsEnabled(exports.PAYMENT_METHOD_CODES.CARD)&&(this.paymentInstallmentsDropdown=new nn("span",Object.assign(Object.assign({},t),{installmentCurrency:"",installmentOptions:this.getinstallmentOptions(),id:"payrails-card-form-payment-installments",className:"payrails-card-form-payment-installments-container"})),this.paymentInstallmentsDropdown&&this.subElements.push(this.paymentInstallmentsDropdown)),R.isAddressSelectorEnabled(exports.PAYMENT_METHOD_CODES.CARD)&&(this.addressComponent=this.createAddressSelector(),this.subElements.push(this.addressComponent)),this.storeInstrumentCheckbox&&this.subElements.push(this.storeInstrumentCheckbox)}initializeFormFields(){var e;(null===(e=this.options)||void 0===e?void 0:e.layout)&&this.options.layout.length>0?this.initializeCustomLayout():this.initializeDefaultLayout()}getErrorTextStyles(e){return(null==e?void 0:e.base)?e:{base:{}}}createFormField(e,t,i,n,o,s=!1){var r,a,l,c,d,u,_,p,E,h,I,v;const m=this.getErrorTextStyles(i);return new pn(this.collectContainer,{type:e,required:s,label: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[e],errorTextStyles:m,placeholder:(null===(u=null===(d=null===(c=this.options)||void 0===c?void 0:c.translations)||void 0===d?void 0:d.placeholders)||void 0===u?void 0:u[e])||o,labelStyles:this.prepareLabelStyles(e),inputStyles:this.prepareInputStyles(t,e),translations:{error:{default:(null===(h=null===(E=null===(p=null===(_=this.options)||void 0===_?void 0:_.translations)||void 0===p?void 0:p.error)||void 0===E?void 0:E.default)||void 0===h?void 0:h[e])||""}},format:n,events:{onFocus:null===(v=null===(I=this.options)||void 0===I?void 0:I.events)||void 0===v?void 0:v.onFocus,onChange:this.onChange.bind(this),onReady:this.triggerOnReady.bind(this)}})}initializeCustomLayout(){var e;if(!(null===(e=this.options)||void 0===e?void 0:e.layout))return;const t=e=>{e.forEach((e=>{var t,i,n,s,r;const a=un.find((t=>t.type===e));if(!a)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_TYPE);if(this.hasFieldBeenUsed(a.type))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_DUPLICATE_ELEMENT);const{type:l,styles:c,format:d,placeholder:u}=a,_=!!(null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.errorTextStyles)||void 0===n?void 0:n.base);this.formFields.push(this.createFormField(l,c,null===(r=null===(s=this.options)||void 0===s?void 0:s.styles)||void 0===r?void 0:r.errorTextStyles,d,u,_))}))};this.options.layout.forEach((e=>t(e)))}hasFieldBeenUsed(e){return this.formFields.some((t=>t.type===e))}initializeDefaultLayout(){var e,t,i;const n=e=>{var t,i,n;return!(null===(t=this.options)||void 0===t?void 0:t.showCardHolderName)&&e===exports.ElementType.CARDHOLDER_NAME||(!(null===(i=this.options)||void 0===i?void 0:i.showSingleExpiryDateField)&&e===exports.ElementType.EXPIRATION_DATE||!(!(null===(n=this.options)||void 0===n?void 0:n.showSingleExpiryDateField)||e!==exports.ElementType.EXPIRATION_MONTH&&e!==exports.ElementType.EXPIRATION_YEAR))},o=!!(null===(i=null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.errorTextStyles)||void 0===i?void 0:i.base);un.filter((({type:e})=>!n(e))).forEach((({type:e,styles:t,format:i,placeholder:n})=>{var s,r;this.formFields.push(this.createFormField(e,t,null===(r=null===(s=this.options)||void 0===s?void 0:s.styles)||void 0===r?void 0:r.errorTextStyles,i,n,o))}))}throttledFetchBinLookupIfChanged(){return t(this,void 0,void 0,(function*(){return this.bin!==this.lastBin&&(this.lastBin=this.bin,this.lastBinLookup=yield this.throttledFetchBinLookup()),this.lastBinLookup}))}tokenize(e){return this.collectContainer.tokenize(e)}createAddressSelector(){var e,t,i,n,o;return new en({id:"payrails-address-selector",events:Object.assign(Object.assign({},null===(e=this.options)||void 0===e?void 0:e.events),{onBillingAddressChanged:e=>{var t,i,n;this.onChange(),null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onBillingAddressChanged)||void 0===n||n.call(i,e)}}),styles:null===(i=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.addressSelector,translations:null===(o=null===(n=this.options)||void 0===n?void 0:n.translations)||void 0===o?void 0:o.addressSelector})}show(){var e,t;const i=document.getElementById(this.collectContainer.id);if(!i){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw s.PayrailsLogger.error(e.message,{error:e}),e}Object.assign(i.style,null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.wrapper),this.element.style.display="flex"}hide(){this.element.style.display="none"}triggerOnReady(){var e,t,i;this.formFields.reduce(((e,t)=>e&&t.isReady),!0)&&(null===(i=null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onReady)||void 0===i||i.call(t))}prepareLabelStyles(e){return["base"].reduce(((t,i)=>{var n,o,s,r,a,l,c,d;return t[i]=Object.assign(Object.assign(Object.assign({},null===(o=null===(n=this.options)||void 0===n?void 0:n.styles)||void 0===o?void 0:o.base),null===(a=null===(r=null===(s=this.options)||void 0===s?void 0:s.styles)||void 0===r?void 0:r.labels)||void 0===a?void 0:a.all),null===(d=null===(c=null===(l=this.options)||void 0===l?void 0:l.styles)||void 0===c?void 0:c.labels)||void 0===d?void 0:d[e]),t}),{})}prepareInputStyles(e,t){var i;let n=JSON.parse(JSON.stringify(e));return(null===(i=this.options)||void 0===i?void 0:i.showCardHolderName)&&t===exports.ElementType.CARD_NUMBER&&(this.element.setAttribute("class","with-card-holder"),n=Object.assign(Object.assign({},e),{base:Object.assign(Object.assign({},dn.base),{border:"1px solid #eae8ee",borderTop:"none",padding:"10px 16px",textIndent:"0"})})),["base","complete","empty","focus","invalid","cardIcon","copyIcon"].forEach((e=>{var i,o,s,r,a,l,c,d;n[e]=Object.assign(Object.assign(Object.assign({},n[e]),null===(r=null===(s=null===(o=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===o?void 0:o.inputFields)||void 0===s?void 0:s.all)||void 0===r?void 0:r[e]),null===(d=null===(c=null===(l=null===(a=this.options)||void 0===a?void 0:a.styles)||void 0===l?void 0:l.inputFields)||void 0===c?void 0:c[t])||void 0===d?void 0:d[e])})),n}validate(){return this.collectContainer.validate()}get isValid(){var e;const t=this.formFields.reduce(((e,t)=>e&&t.isValid),!0);return this.addressComponent?t&&!!(null===(e=this.addressComponent)||void 0===e?void 0:e.isValid):t}get cardNetwork(){var e,t;return null!==(t=null===(e=this.formFields.find((e=>Boolean(e.cardNetwork))))||void 0===e?void 0:e.cardNetwork)&&void 0!==t?t:""}onChange(){var e,t,i,n;(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onChange)&&(null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n||n.onChange({isValid:this.isValid,cardNetwork:this.cardNetwork,bin:this.bin,billingAddress:this.billingAddress}),R.isPaymentInstallmentsEnabled(exports.PAYMENT_METHOD_CODES.CARD)&&this.bin.length>=6&&this.throttledFetchBinLookupIfChanged().then((e=>{this.updateInstallments(e)})))}updateInstallments(e){var t;if(this.paymentInstallmentsDropdown&&this.isBinLookupEnabled){const i=this.getinstallmentOptions(null===(t=null==e?void 0:e.issuerCountry)||void 0===t?void 0:t.code);i?this.paymentInstallmentsDropdown.updateInstallmentOptions(i):this.paymentInstallmentsDropdown.updateInstallmentOptions([])}}collectValues(){return t(this,void 0,void 0,(function*(){return{cardData:yield this.collectContainer.collect(),storeInstrument:this.shouldStoreInstrument,selectedInstallment:this.selectedInstallment,enrollInstrumentToNetworkOffers:Boolean(this.enforceEnrollInstrumentToNetworkOffersForMasterCard()),billingInfo:this.billingAddress}}))}get selectedInstallment(){var e;return null===(e=this.paymentInstallmentsDropdown)||void 0===e?void 0:e.selectedInstallmentValue}get billingAddress(){var e;return null===(e=this.addressComponent)||void 0===e?void 0:e.fullAddress}enforceEnrollInstrumentToNetworkOffersForMasterCard(){var e;return"mastercard"!==this.cardNetwork&&(null===(e=this.options)||void 0===e?void 0:e.enrollInstrumentToNetworkOffers)}fetchBinLookup(){return t(this,void 0,void 0,(function*(){return this.isBinLookupEnabled?yield this.collectContainer.fetchBinLookup(this.bin):this.bin}))}getinstallmentOptions(e){if(e){const t=R.getPaymentInstallmentOptions(exports.PAYMENT_METHOD_CODES.CARD);return t?t[e]:null}return null}}class pn{constructor(e,t){this.isValid=!1,this.isReady=!1,this.cardNetwork="";const{events:i}=t,n=e.createCollectElement(t);this.type=t.type,(null==i?void 0:i.onFocus)&&n.on("FOCUS",i.onFocus),n.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)})),n.on("CHANGE",(e=>{const{isEmpty:t,isValid:n,network:o}=e;this.isValid=!t&&n,this.cardNetwork=null!=o?o:"",(null==i?void 0:i.onChange)&&i.onChange(this)}))}}class En extends U{constructor(e,t,i,n,o){super("div",{id:e,className:"payrails-dropin-item"}),this.events=n,this.styles=o,this.isActive=!1,this.mountContainerClass="payrails-dropin-item-container",this.applyBaseStyles();const s=`payrails-dropin-item-${e}`,r=document.createElement("label");r.setAttribute("for",s);const a=document.createElement("input");if(a.setAttribute("type","radio"),a.setAttribute("name","payment-option"),a.setAttribute("id",s),a.setAttribute("value",s),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 c=document.createElement("div");c.setAttribute("class",this.mountContainerClass),this.element.appendChild(c)}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 hn;!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"}(hn||(hn={}));const In="https://assets.payrails.io/img/";class vn extends En{constructor(e,t,i,n,o){const s=e.displayName&&""!==e.displayName?e.displayName:"Unavailable";super(`payrails-payment-instrument-${e.id}`,s,vn.getInstrumentIcon(e),{onActivate:()=>{i(e),this.component.setDisabled(!1),this.installmentDropdown&&this.component.setPaymentInstallmentsDropdown(this.installmentDropdown)}},n),this.installmentDropdown=null,o&&(this.installmentDropdown=o),this.component=new mn(t,o)}static getInstrumentIcon(e){var t;if(e.paymentMethod===exports.PAYMENT_METHOD_CODES.CARD){switch(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.network){case hn.AMEX:return In+"amex.svg";case hn.DINERS:return In+"diners-club.svg";case hn.DISCOVER:return In+"discover.svg";case hn.HIPERCARD:return In+"hipercard.svg";case hn.JCB:return In+"jcb.svg";case hn.MAESTRO:return In+"maestro.svg";case hn.MASTERCARD:return In+"mastercard.svg";case hn.UNIONPAY:return In+"unionpay.svg";case hn.VISA:return In+"visa.svg"}return In+"default.svg"}return e.paymentMethod===exports.PAYMENT_METHOD_CODES.PAYPAL?In+"paypal.png":e.paymentMethod===exports.PAYMENT_METHOD_CODES.APPLE_PAY?In+"applepay.png":e.paymentMethod===exports.PAYMENT_METHOD_CODES.GOOGLE_PAY?In+"googlepay.png":""}}class mn extends U{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 yn extends U{constructor(e){super("div",{id:"payrails-card-list"}),this.listItems=[],R.savedCreditCards.forEach((t=>{const i=new Ln((()=>{(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 Ln extends U{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",o=document.createElement("label");o.setAttribute("for",i),o.addEventListener("click",e);const s=document.createElement("input");s.setAttribute("type","radio"),s.setAttribute("name","payment-option"),s.setAttribute("id",i),s.setAttribute("value",i),o.appendChild(s);const r=document.createElement("span");r.className="payment-option-text",o.appendChild(r);const a=document.createElement("img");a.src=vn.getInstrumentIcon(t),a.className="payment-option-icon",r.appendChild(a),r.appendChild(document.createTextNode(n)),this.element.appendChild(o)}}class An extends U{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 fn extends U{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 On extends U{constructor(e){super("div",{id:"payrails-dropin-loader",className:"payrails-dropin-loader-wrapper"}),this.options=e,this.selectors={[Tn.overlay]:".loading-overlay",[Tn.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 Tn;!function(e){e.overlay="overlay",e.loader="loader"}(Tn||(Tn={}));const Rn="https://assets.payrails.io/img";function Cn(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"}return"card"!==e?`${Rn}/${e}.png`:`${Rn}/credit-card-regular.svg`}class gn extends En{constructor(){super(...arguments),this.buttonShown=!1}activate(){var e,t;if(!this.buttonShown)return super.activate(),void(this.buttonShown=!0);this.applyActiveStyles(),this.isActive=!0,this.element.querySelector(this.component.selector).style.display="block",null===(t=null===(e=this.events)||void 0===e?void 0:e.onPaymentOptionVisibilityChange)||void 0===t||t.call(e)}deactivate(){this.isActive&&(this.isActive=!1,this.applyBaseStyles(),this.element.querySelector(this.component.selector).style.display="none")}mountAfterAvailable(){var e,t;super.mount(`#${this.loadElementId}`),null===(t=null===(e=this.events)||void 0===e?void 0:e.onAvailable)||void 0===t||t.call(e)}mount(e){const t=document.querySelector(e);if(!t){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);throw s.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 Nn extends gn{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?Cn("applepay"):void 0,void 0,e.styles),this.loadElementId="apple-pay-dropin-load-element",this.component=new Xi(Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},e.events),{onApplePayAvailable:()=>{this.mountAfterAvailable()}})}))}}class Sn extends En{constructor(e,t,i){var n,o;super("payrails-credit-card-wrapper",(null===(o=null===(n=i.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.label)||"Card",i.showPaymentMethodLogo?Cn("card"):void 0,Object.assign({},i.events),Object.assign({},i.styles)),this.cardForm=e,this.paymentButton=t,this.cardFormShown=!1,this.component=new Pn(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 Pn extends U{constructor(e,t){super("div",{id:"payrails-form-container"}),this.subElements.push(e,t)}}class bn extends U{constructor(e){var t,i,n,o;super("button",{id:e.id,className:"payrails-generic-button",styles:null!==(i=null===(t=e.styles)||void 0===t?void 0:t.base)&&void 0!==i?i:{}}),this.options=e,this.isDisabled=!1,this.element.innerText=null==e?void 0:e.translations.label,e.styles&&this.setStyles(null!==(o=null===(n=e.styles)||void 0===n?void 0:n.base)&&void 0!==o?o:{}),this.element.addEventListener("click",this.onClick.bind(this)),this.element.addEventListener("mouseenter",(()=>{var e;this.isDisabled||this.setStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{})})),this.element.addEventListener("mouseleave",(()=>{var e;this.isDisabled||this.removeStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{})}))}getElement(){return this.element}onClick(){return t(this,void 0,void 0,(function*(){var e,t;if((null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onClick)&&!this.isDisabled){try{this.triggerLoading(!0),yield this.options.events.onClick()}catch(e){throw this.triggerLoading(!1),e}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;this.isDisabled=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===(i=this.options)||void 0===i?void 0:i.translations.label,this.removeStyles((null===(n=this.options.styles)||void 0===n?void 0:n.loading)||{}))}}const Dn={label:"Generic redirect"},Mn={pix:75e4};class wn extends U{constructor(e,t){super("div",{id:`payrails-generic-redirect-${e.paymentMethod.paymentMethodCode}`}),this.options=e,this.returnInfo=t,this.popup=null;const i=this.buildRedirectButton();this.element.appendChild(i.getElement()),this.paymentExecutor=new b(this.returnInfo)}buildRedirectButton(){var e,t,i;return new bn({id:"payrails-generic-redirect-button",translations:{label:null!==(t=null===(e=this.options.translations)||void 0===e?void 0:e.label)&&void 0!==t?t:Dn.label},events:{onClick:this.onClick.bind(this)},styles:null!==(i=this.options.styles)&&void 0!==i?i:{}})}onClick(){return t(this,void 0,void 0,(function*(){var e,t,i,n;if(yield L(null!==(e=this.options.events)&&void 0!==e?e:{}))try{const e=null===(t=R.availablePaymentMethods.find((({paymentMethodCode:e})=>e===this.options.paymentMethod.paymentMethodCode)))||void 0===t?void 0:t.integrationType;if(!e)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED);const i=yield this.paymentExecutor.pay([{paymentMethodCode:this.options.paymentMethod.paymentMethodCode,integrationType:e,amount:g().amount}]),{action:n,link:s}=this.handleAuthorizationResult(i);if("redirect"!==n)return;if(!s)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK);if(Object.keys(Mn).includes(this.options.paymentMethod.paymentMethodCode)){const e=Mn[this.options.paymentMethod.paymentMethodCode],t=2e4,i=2e3,n=Math.ceil((e-t)/i);return new b(this.returnInfo,i,n,t).pollForAuthorizationResult(R.url,0,["authorizeSuccessful","authorizeFailed"]).then((e=>{var t;this.handleAuthorizationResult(e),null===(t=this.popup)||void 0===t||t.unmount()})),this.createPopupWithTimeout(s,e)}return this.redirectToPaymentLink(s)}catch(e){e instanceof o.PayrailsError&&s.PayrailsLogger.error(e.message,{error:e}),null===(n=null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeFailed)||void 0===n||n.call(i)}}))}handleAuthorizationResult(e){var t,i,n,s,r,a,l,c;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)?(null===(r=null===(s=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===s?void 0:s.onAuthorizeSuccess)||void 0===r||r.call(s),{code:"authorizeSuccessful",action:"success"}):(null===(c=null===(l=null===(a=this.options)||void 0===a?void 0:a.events)||void 0===l?void 0:l.onAuthorizeFailed)||void 0===c||c.call(l,e),{code:"authorizeFailed",action:"fail"})}createPopupWithTimeout(e,t){return new Promise((()=>{const i=new D(e,this.paymentExecutor,this.options);this.popup=i,this.popup.mount(),setTimeout((()=>{var e,t;null==i||i.unmount(),null===(t=null===(e=this.options.events)||void 0===e?void 0:e.onAuthorizeFailed)||void 0===t||t.call(e)}),t)}))}redirectToPaymentLink(e){return new Promise((()=>{window.location.href=e,setTimeout((()=>{var e,t;null===(t=null===(e=this.options.events)||void 0===e?void 0:e.onAuthorizeFailed)||void 0===t||t.call(e)}),3e4)}))}}const kn=e=>e===exports.PAYMENT_METHOD_CODES.GENERIC_REDIRECT?{translations:{label:"Mercado Pago",button:{label:"Pay with Mercado Pago"}}}:{translations:{label:e,button:{label:`Pay with ${e}`}}};class Yn extends En{constructor(e,t){var i,n,o,s,r;super(`payrails-${e.paymentMethod.paymentMethodCode}-dropin-element`,(null===(i=null==e?void 0:e.translations)||void 0===i?void 0:i.label)||kn(e.paymentMethod.paymentMethodCode).translations.label,(null===(n=e.config)||void 0===n?void 0:n.showPaymentMethodLogo)?Cn(e.paymentMethod.paymentMethodCode):void 0,null==e?void 0:e.events,null===(o=null==e?void 0:e.styles)||void 0===o?void 0:o.element),this.returnInfo=t,this.component=new wn({styles:(null===(s=null==e?void 0:e.styles)||void 0===s?void 0:s[e.paymentMethod.paymentMethodCode])||{},translations:(null===(r=null==e?void 0:e.translations)||void 0===r?void 0:r.button)||kn(e.paymentMethod.paymentMethodCode).translations.button,events:null==e?void 0:e.events,paymentMethod:e.paymentMethod},this.returnInfo)}}const Un={apiVersion:2,apiVersionMinor:0};class xn extends Gi{static getSDKClient(){return t(this,arguments,void 0,(function*(e=exports.PayrailsEnvironment.TEST,t){return yield Bi.load(ji.GooglePay),xn.googleSDKClient||(xn.googleSDKClient=new google.payments.api.PaymentsClient({environment:e,merchantInfo:t})),xn.googleSDKClient}))}static isGooglePayAvailable(e){return t(this,arguments,void 0,(function*(e,t=exports.PayrailsEnvironment.TEST,i){try{const n=yield xn.getSDKClient(t,i),o=Object.assign(Object.assign({},Un),{allowedPaymentMethods:e}),{result:s}=yield n.isReadyToPay(o);return s}catch(e){return!1}}))}constructor(e){var t;super("div",Object.assign(Object.assign({},e),{id:"payrails-google-pay-button"})),this.options=e,this.paymentExecutor=new b(null===(t=this.options)||void 0===t?void 0:t.returnInfo),xn.isGooglePayAvailable(R.googlePayConfig,this.options.environment,this.options.merchantInfo).then((e=>{var t,i,n;e&&(null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onGooglePayAvailable)||void 0===n||n.call(i))}))}sdkLoaded(e){return t(this,void 0,void 0,(function*(){var i,n,o,s,r,a,l,c;if(xn.instance)return xn.instance;const d=(null===(n=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===n?void 0:n.buttonColor)||"black",u=(null===(s=null===(o=this.options)||void 0===o?void 0:o.styles)||void 0===s?void 0:s.buttonType)||"long",_=(null===(a=null===(r=this.options)||void 0===r?void 0:r.styles)||void 0===a?void 0:a.buttonSizeMode)||"fill",p=(null===(c=null===(l=this.options)||void 0===l?void 0:l.styles)||void 0===c?void 0:c.buttonLocale)||void 0;return xn.instance=e.createButton({buttonColor:d,buttonType:u,buttonSizeMode:_,buttonLocale:p,onClick:()=>t(this,void 0,void 0,(function*(){(yield L(this.options.events))&&(yield this.authorize(e))})),allowedPaymentMethods:R.googlePayConfig}),this.element.appendChild(xn.instance),xn.instance}))}onLoadPaymentData(e){return t(this,void 0,void 0,(function*(){var t,i,n,o,s,r,a,l,c,d;const u={paymentToken:JSON.stringify(e)},_=null===(i=null===(t=e.paymentMethodData)||void 0===t?void 0:t.info)||void 0===i?void 0:i.billingAddress;_&&(u.billingAddress={country:{code:null==_?void 0:_.countryCode},postalCode:null==_?void 0:_.postalCode});const p=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.GOOGLE_PAY,integrationType:"api",paymentInstrumentData:u,amount:g().amount,storeInstrument:this.shouldStoreInstrument}],E=yield this.paymentExecutor.pay(p);if("authorizePending"===(null===(n=null==E?void 0:E.finalState)||void 0===n?void 0:n.code)){new w(this.options,this.paymentExecutor).handle3ds(E)}else"authorizeSuccessful"===(null===(o=null==E?void 0:E.finalState)||void 0===o?void 0:o.code)?null===(a=null===(r=null===(s=this.options)||void 0===s?void 0:s.events)||void 0===r?void 0:r.onAuthorizeSuccess)||void 0===a||a.call(r):null===(d=null===(c=null===(l=this.options)||void 0===l?void 0:l.events)||void 0===c?void 0:c.onAuthorizeFailed)||void 0===d||d.call(c,E)}))}authorize(e){return t(this,void 0,void 0,(function*(){var t,i,n,o,s,r,a,l;const c=Object.assign(Object.assign({},Un),{allowedPaymentMethods:R.googlePayConfig,transactionInfo:{totalPriceStatus:"FINAL",totalPrice:null===(t=g().amount)||void 0===t?void 0:t.value,currencyCode:null===(i=g().amount)||void 0===i?void 0:i.currency,countryCode:null===(r=null===(s=null===(o=null===(n=R.meta)||void 0===n?void 0:n.order)||void 0===o?void 0:o.billingAddress)||void 0===s?void 0:s.country)||void 0===r?void 0:r.code},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)||""}});e.loadPaymentData(c).then((e=>{this.onLoadPaymentData(e)})).catch((e=>{var t,i,n;(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onAuthorizeFailed)&&(null===(n=this.options)||void 0===n||n.events.onAuthorizeFailed(e))}))}))}mount(e){super.mount(e),(()=>{t(this,void 0,void 0,(function*(){var e;try{if(yield xn.isGooglePayAvailable(R.googlePayConfig,this.options.environment,this.options.merchantInfo)){const t=yield xn.getSDKClient(this.options.environment,this.options.merchantInfo),i=yield this.sdkLoaded(t);this.element.appendChild(i),null===(e=this.storeInstrumentCheckbox)||void 0===e||e.mount(this.selector)}}catch(e){}}))})()}unmount(){var e;null===(e=this.storeInstrumentCheckbox)||void 0===e||e.unmount(),xn.instance=null,super.unmount()}}xn.instance=null,xn.googleSDKClient=null;class Fn extends gn{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?Cn("googlepay"):void 0,e.events,e.styles),this.loadElementId="google-pay-dropin-load-element",this.component=new xn(Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},e.events),{onGooglePayAvailable:()=>{this.mountAfterAvailable()}}),returnInfo:e.returnInfo}))}}class Bn extends Gi{constructor(e){Bn.instance&&(Bn.instance=void 0),super("div",Object.assign(Object.assign({},e),{id:"payrails-paypal-button",events:Object.assign(Object.assign({},null==e?void 0:e.events),{onSaveInstrumentCheckboxChanged:e=>t(this,void 0,void 0,(function*(){var t,i,n,o;null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(i,e),null===(o=this.button)||void 0===o||o.close(),this.debouncedRender()}))})})),this.options=e,this.renderDebounceTimeout=null,this.currentAbortController=null,this.isRendering=!1,this.buttonWrapperId="payrails-paypal-button-wrapper",this.checkboxWrapperId="payrails-paypal-checkbox-wrapper",this.createOneTimeOrder=()=>t(this,void 0,void 0,(function*(){var e,t,i,n,o,s,r;const a=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.PAYPAL,integrationType:"api",amount:g().amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!1}],l=yield this.paymentExecutor.pay(a),c=null===(i=null===(t=null===(e=l.response.links.confirm)||void 0===e?void 0:e.action)||void 0===t?void 0:t.parameters)||void 0===i?void 0:i.orderId;if(!c)throw null===(s=null===(o=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===o?void 0:o.onAuthorizeFailed)||void 0===s||s.call(o),new jn("No order id returned");return this.confirmLink=null===(r=l.response.links.confirm)||void 0===r?void 0:r.href,c})),this.loadPaypal().catch((()=>{})),this.element.innerHTML=`<div id="${this.buttonWrapperId}"></div><div id="${this.checkboxWrapperId}"></div>`,this.paymentExecutor=new b}loadPaypal(){return t(this,void 0,void 0,(function*(){const e=yield Bi.load(ji.PayPal,this.paypalScriptConfig);return yield this.createPaypalButton(e)}))}debouncedRender(){return this.renderDebounceTimeout&&clearTimeout(this.renderDebounceTimeout),this.currentAbortController&&this.currentAbortController.abort(),new Promise((e=>{this.renderDebounceTimeout=setTimeout((()=>t(this,void 0,void 0,(function*(){try{yield this.renderButton(),e()}catch(t){console.error("Failed to render PayPal button:",t),e()}}))),300)}))}get paypalScriptConfig(){const e=this.shouldStoreInstrument?"tokenize":"Instant"===R.paypalConfig.captureMode?"capture":"authorize";return{clientId:R.paypalConfig.clientId,intent:e,currency:g().amount.currency,vault:this.shouldStoreInstrument}}createPaypalButton(e){return t(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:()=>t(this,void 0,void 0,(function*(){var e,t,i,n;const o=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.PAYPAL,integrationType:"api",amount:g().amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!0}],s=yield this.paymentExecutor.pay(o);return this.confirmLink=null===(e=s.response.links.confirm)||void 0===e?void 0:e.href,(null===(n=null===(i=null===(t=s.response.links.confirm)||void 0===t?void 0:t.action)||void 0===i?void 0:i.parameters)||void 0===n?void 0:n.tokenId)||""}))})}onCancel(){var e,t;this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}),(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onAuthorizeFailed)&&this.options.events.onAuthorizeFailed()}createOneTimeOrderConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{createOrder:this.createOneTimeOrder.bind(this),onApprove:this.approvePayment.bind(this)})}createBaseConfig(){var e,i,n,o,s,r,a,l,c,d;return{fundingSource:"paypal",style:{color:(null===(i=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===i?void 0:i.color)||"gold",height:(null===(o=null===(n=this.options)||void 0===n?void 0:n.styles)||void 0===o?void 0:o.height)||40,label:(null===(r=null===(s=this.options)||void 0===s?void 0:s.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===(d=null===(c=this.options)||void 0===c?void 0:c.styles)||void 0===d?void 0:d.tagline)||!1},onError:e=>{var t,i;this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}),(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onAuthorizeFailed)&&this.options.events.onAuthorizeFailed(e)},onClick:(e,i)=>t(this,void 0,void 0,(function*(){var e;return(yield L(null===(e=this.options)||void 0===e?void 0:e.events))?i.resolve():i.reject()})),onCancel:this.onCancel.bind(this)}}approvePayment(e){return t(this,void 0,void 0,(function*(){var t,i,n,o,s,r,a,l,c,d;if(!this.confirmLink)throw null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onAuthorizeFailed)||void 0===n||n.call(i),new jn("No confirm link");const u={};this.shouldStoreInstrument&&e.billingToken&&(u.tokenId=e.billingToken),this.fraudNetGuid&&(u.riskSessionCorrelationId=this.fraudNetGuid);"authorizeSuccessful"===(null===(o=(yield this.paymentExecutor.confirm(this.confirmLink,u)).finalState)||void 0===o?void 0:o.code)?null===(a=null===(r=null===(s=this.options)||void 0===s?void 0:s.events)||void 0===r?void 0:r.onAuthorizeSuccess)||void 0===a||a.call(r):null===(d=null===(c=null===(l=this.options)||void 0===l?void 0:l.events)||void 0===c?void 0:c.onAuthorizeFailed)||void 0===d||d.call(c)}))}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){Bn.instance||(Bn.instance=this,super.mount(e),(()=>{t(this,void 0,void 0,(function*(){yield this.debouncedRender()}))})())}renderButton(){return t(this,void 0,void 0,(function*(){var e;this.isRendering&&this.currentAbortController&&this.currentAbortController.abort(),this.currentAbortController=new AbortController;const t=this.currentAbortController.signal;try{this.isRendering=!0,this.button&&(this.button.close(),this.button=void 0);const i=yield Promise.race([this.loadPaypal(),new Promise(((e,i)=>{t.addEventListener("abort",(()=>i(new Vn("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,Bn.instance=void 0,super.unmount()}}class jn extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION,{description:`PaypalOrderError: ${e}`,cause:t})}}class Vn extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT,{description:`PaypalButtonError: ${e}`,cause:t})}}class Gn extends gn{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)?Cn("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 Bn(Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},null==e?void 0:e.events),{onPaypalAvailable:()=>{this.mountAfterAvailable()}})}))}}class Xn extends U{constructor(e,t,i){var n,o,s;super("fieldset",{id:"payrails-dropin-component"}),this.collectContainer=e,this.clientConfig=t,this.dropinConfig=i,this.applyStyles();void 0!==(null===(o=null===(n=this.dropinConfig.paymentMethodsConfiguration)||void 0===n?void 0:n.cards)||void 0===o?void 0:o.showExistingCards)&&console.warn("The `showExistingCards` option is deprecated and will be removed in a future version. Please use `showStoredInstruments` instead.");const r=new Map;R.storedDropinInstruments.forEach((e=>{if(this.isStoredInstrumentEnabled(e.paymentMethod)){this.cardPaymentButton=this.createCardPaymentButton();const t=this.createStoredInstrumentElement(e);r.set(t.identifier,t)}}));const a={[exports.PAYMENT_METHOD_CODES.CARD]:this.createCreditCardButton.bind(this),[exports.PAYMENT_METHOD_CODES.PAYPAL]:this.createPayPalButton.bind(this),[exports.PAYMENT_METHOD_CODES.GOOGLE_PAY]:this.createGooglePayButton.bind(this),[exports.PAYMENT_METHOD_CODES.APPLE_PAY]:this.createApplePayButton.bind(this)};R.availablePaymentMethods.forEach((e=>{const t=e.paymentMethodCode;if(t&&a[t]){a[t];const i=R.getPaymentMethodConfig(e),n=a[t](i);r.set(n.identifier,n)}else if(this.isHppIntegration(e)&&t){const t=this.createHppIntegrationElement(e);r.set(t.identifier,t)}})),this.element.addEventListener("change",(e=>{var t,i;const n=(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.value)||"";r.forEach((e=>{e.deactivate()})),null===(i=r.get(n))||void 0===i||i.activate()})),1===this.totalPaymentOptions&&this.element.classList.add("payrails-dropin-component--single"),this.subElements.push(...Array.from(r.values())),this.loadingScreen=new On({styles:null===(s=this.dropinConfig.styles)||void 0===s?void 0:s.loadingScreen})}isHppIntegration(e){var t;return e.paymentMethodCode===exports.PAYMENT_METHOD_CODES.GENERIC_REDIRECT||(null===(t=e.clientConfig)||void 0===t?void 0:t.flow)===O.REDIRECT}createStoredInstrumentElement(e){var t;let i;return this.cardPaymentButton=this.createCardPaymentButton(),e.paymentMethod===exports.PAYMENT_METHOD_CODES.CARD&&R.isPaymentInstallmentsEnabled(e.paymentMethod)&&(i=this.createInstallmentsDropdown(e)),new vn(e,this.cardPaymentButton,(e=>{var t,i;if(this.cardPaymentButton){this.cardPaymentButton.selectedInstrument=e;const n=R.getPaymentMethodForStoredInstrument(e);null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onPaymentOptionSelected)||void 0===i||i.call(t,{paymentMethod:n,instrument:e})}}),null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.element,i)}createInstallmentsDropdown(e){const t=this.getInstallmentOptionsForInstrument(e);return new nn("span",{installmentCurrency:g().amount.currency,installmentOptions:t,id:`payrails-card-form-payment-installments-${e.id}`,className:"payrails-card-form-payment-installments-container"})}getInstallmentOptionsForInstrument(e){var t,i,n;const o=e.paymentMethod,s=R.getPaymentInstallmentOptions(o),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?s[r]:null}createHppIntegrationElement(e){var t,i,n,r,a,l,c;const d=e.paymentMethodCode;if(!d){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 s.PayrailsLogger.error(t.message,{error:t}),t}return new Yn({paymentMethod:e,config:null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t[d],styles:{element:null===(n=null===(i=this.dropinConfig)||void 0===i?void 0:i.styles)||void 0===n?void 0:n.element,button:null===(l=null===(a=null===(r=this.dropinConfig)||void 0===r?void 0:r.styles)||void 0===a?void 0:a[d])||void 0===l?void 0:l.button},translations:null===(c=this.dropinConfig.translations)||void 0===c?void 0:c[d],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.clientConfig.returnInfo)}get totalPaymentOptions(){return R.availablePaymentMethods.length+R.storedDropinInstruments.length}createCreditCardButton(e){var t,i,n,o;return this.creditCard=new Sn(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===(n=null===(i=this.dropinConfig.paymentMethodsConfiguration)||void 0===i?void 0:i.cards)||void 0===n?void 0:n.showPaymentMethodLogo,translations:null===(o=this.dropinConfig.translations)||void 0===o?void 0:o.cardForm}),this.creditCard}createGooglePayButton(e){var t,i,n,o,s;return this.googlePay=new Fn(Object.assign({environment:this.clientConfig.environment||exports.PayrailsEnvironment.TEST,events:Object.assign(Object.assign({},this.getElementEvents()),{onPaymentOptionVisibilityChange:()=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onPaymentOptionSelected)||void 0===i||i.call(t,{paymentMethod:e})}}),redirectFor3DS:this.clientConfig.redirectFor3DS,showPaymentMethodLogo:null===(i=null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.googlePay)||void 0===i?void 0:i.showPaymentMethodLogo,styles:Object.assign(Object.assign({},null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.googlePayButton),null===(o=this.dropinConfig.styles)||void 0===o?void 0:o.element),returnInfo:this.clientConfig.returnInfo},null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s.googlePay)),this.googlePay}createPayPalButton(e){var t,i,n;return this.paypal=new Gn(Object.assign(Object.assign({},null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.payPal),{styles:Object.assign(Object.assign({},null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.paypalButton),null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.element),events:Object.assign(Object.assign({},this.getElementEvents()),{onPaymentOptionVisibilityChange:()=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onPaymentOptionSelected)||void 0===i||i.call(t,{paymentMethod:e})}})})),this.paypal}createCardForm(){var e,t,i,n,o,s;if(!this.cardForm){const r=null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.cards,a=Boolean(null==r?void 0:r.showStoreInstrumentCheckbox),l=Boolean(null==r?void 0:r.showCardHolderName),c=Boolean(null==r?void 0:r.alwaysStoreInstrument),d=Boolean(null==r?void 0:r.showSingleExpiryDateField),u=(null==r?void 0:r.layout)||[];this.cardForm=new _n(this.collectContainer,{showStoreInstrumentCheckbox:a,showCardHolderName:l,showSingleExpiryDateField:d,alwaysStoreInstrument:c,layout:u,translations:Object.assign(Object.assign({},null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.cardForm),{addressSelector:null===(i=this.dropinConfig.translations)||void 0===i?void 0:i.addressSelector}),styles:Object.assign(Object.assign(Object.assign({},null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.cardForm),null===(o=this.dropinConfig.styles)||void 0===o?void 0:o.element),{addressSelector:null===(s=this.dropinConfig.styles)||void 0===s?void 0:s.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,o,s,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===(o=null===(n=this.dropinConfig.paymentMethodsConfiguration)||void 0===n?void 0:n.cards)||void 0===o?void 0:o.disablePaymentButton)?!e:null===(r=null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s.cards)||void 0===r?void 0:r.disablePaymentButton;console.log("shouldDisablePaymentButton",l),null===(a=this.cardPaymentButton)||void 0===a||a.setDisabled(l)},onSaveInstrumentCheckboxChanged:e=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onSaveInstrumentCheckboxChanged)||void 0===i||i.call(t,e)}})})}return this.cardPaymentButton&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardForm}createApplePayButton(e){var i,n,o,s,r;return this.applePay=new Nn(Object.assign(Object.assign({events:Object.assign(Object.assign({},this.getElementEvents()),{onAuthorizeSuccess:e=>{var t;if(e)if("authorizeSuccessful"===(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code))this.onAuthorizeSuccess();else this.onAuthorizeFailed()},onPaymentOptionVisibilityChange:()=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onPaymentOptionSelected)||void 0===i||i.call(t,{paymentMethod:e})},onPaymentButtonClicked:e=>t(this,void 0,void 0,(function*(){var t,i;return!!(yield null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onPaymentButtonClicked)||void 0===i?void 0:i.call(t,e))}))})},null===(i=this.dropinConfig.paymentMethodsConfiguration)||void 0===i?void 0:i.applePay),{styles:Object.assign(Object.assign({},null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.applePayButton),null===(o=this.dropinConfig.styles)||void 0===o?void 0:o.element),showPaymentMethodLogo:null===(r=null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s.applePay)||void 0===r?void 0:r.showPaymentMethodLogo})),this.applePay}createCardPaymentButton(){var e,t,i,n;return this.cardPaymentButton||(this.cardPaymentButton=new x({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.clientConfig.returnInfo)),this.cardForm&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardPaymentButton}onAuthorizeSuccess(){var e,t,i,n,o,s,r;null===(e=this.loadingScreen)||void 0===e||e.unmount(),this.subElements.forEach((e=>e.unmount())),new fn({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===(s=null===(o=this.dropinConfig)||void 0===o?void 0:o.styles)||void 0===s?void 0:s.authSuccess}).mount(this.selector),(null===(r=this.dropinConfig.events)||void 0===r?void 0:r.onAuthorizeSuccess)&&this.dropinConfig.events.onAuthorizeSuccess()}getElementEvents(){return Object.assign(Object.assign({},this.dropinConfig.events),{onAuthorizeSuccess:this.onAuthorizeSuccess.bind(this),onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onAuthorizePending:this.onAuthorizePending.bind(this),onAvailable:()=>{var e;(1===this.totalPaymentOptions||(null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.preselectFirstPaymentOption))&&this.subElements[0].activate()},onPaymentButtonClicked:e=>t(this,void 0,void 0,(function*(){var t,i,n,o;null===(t=this.loadingScreen)||void 0===t||t.mount(this.selector);let s=!0;return(null===(i=this.dropinConfig.events)||void 0===i?void 0:i.onPaymentButtonClicked)&&(s=!!(yield null===(o=null===(n=this.dropinConfig.events)||void 0===n?void 0:n.onPaymentButtonClicked)||void 0===o?void 0:o.call(n,e))),s}))})}onAuthorizePending(){var e,t,i,n,o,s,r,a;null===(e=this.loadingScreen)||void 0===e||e.unmount(),this.subElements.forEach((e=>e.unmount())),new fn({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===(s=null===(o=this.dropinConfig)||void 0===o?void 0:o.styles)||void 0===s?void 0:s.authSuccess}).mount(this.selector),null===(a=null===(r=this.dropinConfig.events)||void 0===r?void 0:r.onAuthorizePending)||void 0===a||a.call(r)}onAuthorizeFailed(e){return t(this,void 0,void 0,(function*(){var t,i,n,o,s,r,a;null===(t=this.loadingScreen)||void 0===t||t.unmount();new An({translations:{label:null===(n=null===(i=this.dropinConfig.translations)||void 0===i?void 0:i.paymentResult)||void 0===n?void 0:n.fail},styles:null===(o=this.dropinConfig.styles)||void 0===o?void 0:o.authFailed,configuration:null===(s=this.dropinConfig.configuration)||void 0===s?void 0:s.authFailMsg}).mount(this.selector),null===(a=null===(r=this.dropinConfig.events)||void 0===r?void 0:r.onAuthorizeFailed)||void 0===a||a.call(r,e)}))}isStoredInstrumentEnabled(e){var t,i,n,o,s,r;switch(e){case exports.PAYMENT_METHOD_CODES.CARD:return!1!==(null===(i=null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.cards)||void 0===i?void 0:i.showStoredInstruments)&&!1!==(null===(o=null===(n=this.dropinConfig.paymentMethodsConfiguration)||void 0===n?void 0:n.cards)||void 0===o?void 0:o.showExistingCards);case exports.PAYMENT_METHOD_CODES.PAYPAL:case exports.PAYMENT_METHOD_CODES.GOOGLE_PAY:case exports.PAYMENT_METHOD_CODES.APPLE_PAY:return!1!==(null===(r=null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s[e])||void 0===r?void 0:r.showStoredInstruments);default:return!1}}applyStyles(){var e;(null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.container)&&Object.assign(this.element.style,this.dropinConfig.styles.container.styles)}fetchBinLookup(){return t(this,void 0,void 0,(function*(){var e;return null===(e=this.cardForm)||void 0===e?void 0:e.fetchBinLookup()}))}}const zn={visa:/^4\d*/,mastercard:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,amex:/^3[47]\d*/,diners:/^(36|38|30[0-5])\d*/,discover:/^(6011|65|64[4-9]|622)\d*/,jcb:/^35\d*/,hipercard:/^606282\d*/,unionpay:/^62\d*/,maestro:/^(5018|5020|5038|5043|5[6-9]|6020|6304|6703|6759|676[1-3])\d*/};class Hn{constructor(e,i){var n;this.bin="",this.isBinLookupEnabled=!1,this.id="payrails-container-wrapper",this.containerType="COMPOSABLE",this.fetchBinLookup=e=>t(this,void 0,void 0,(function*(){var t,i;const n=`${null===(i=null===(t=g().links)||void 0===t?void 0:t.binLookup)||void 0===i?void 0:i.href}`,r=g().token,a={bin:e};if(!n)return e;try{const e=yield(({url:e,token:t,body:i})=>_({url:e,method:u.POST,token:t,body:i}))({url:n,token:r,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 s.PayrailsLogger.error(i.message,{error:i}),{bin:e}}})),this.cardTableName=i.cardTableName||"cards",this.containerType=i.containerType||"COMPOSABLE",this.isBinLookupEnabled=!!(null===(n=g().links)||void 0===n?void 0:n.binLookup);try{this.__container=e.container(this.containerType,i)}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CREATION_FAILED,{cause:e});s.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 Hn(e,t),this.instance}createCollectElement(e){var t;const i={required:!!e.required,enableCardIcon:!1!==e.enableCardIcon},n=null===(t=this.__container)||void 0===t?void 0:t.create(Object.assign(Object.assign({table:this.cardTableName,labelStyles:{},errorTextStyles:{},column:this.elementToFieldMap.get(e.type)},e),{type:e.type===exports.ElementType.CARDHOLDER_NAME?"INPUT_FIELD":e.type}),e.format?Object.assign(Object.assign({},i),{format:e.format}):i);if(!n){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING,{description:"Error creating collect element!"});throw s.PayrailsLogger.error(e.message,{error:e}),e}return this.attachCustomEventHandler(n)}mount(e){if("COLLECT"===this.containerType){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw s.PayrailsLogger.error(e.message,{error:e}),e}this.element=document.createElement("span"),this.element.setAttribute("id",this.id);const t=document.querySelector(e);if(!t){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING);throw s.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);s.PayrailsLogger.error(t.message,{error:t})}}unmount(){this.element&&this.element.remove()}validate(){return t(this,void 0,void 0,(function*(){var e;return yield null===(e=this.__container)||void 0===e?void 0:e.validate()}))}collect(){return t(this,void 0,void 0,(function*(){try{return yield this.collectPayrailsData()}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_OPERATION_FAILED,{description:"Error collecting data from the iframe!",cause:e});throw s.PayrailsLogger.error(t.message,{error:t}),t}}))}collectPayrailsData(){return t(this,void 0,void 0,(function*(){var e;const t=yield null===(e=this.__container)||void 0===e?void 0:e.collect();return Object.assign(Object.assign({},t),{vaultProviderConfigId:g().vaultConfiguration.providerConfigId})}))}tokenize(e){return t(this,void 0,void 0,(function*(){const t=yield this.collect(),i=g().vaultConfiguration.links.saveInstrument.href,n=g().token;if(!i){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND,{description:"Save instrument URL not available!"});throw s.PayrailsLogger.error(e.message,{error:e}),e}const r=yield(({url:e,token:t,body:i})=>_({url:e,token:t,method:u.POST,body:i}))({url:i,token:n,body:this.constructSaveInstrumentBody(t,e)});return r.res}))}constructSaveInstrumentBody(e,t){var i,n;const o={holderReference:g().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 o.data={encryptedData:e.encryptedData,vaultProviderConfigId:e.vaultProviderConfigId},o}attachCustomEventHandler(e){return new Proxy(e,{get:(e,t)=>{if("on"!==t)return e[t];return((i,n)=>{e[t].call(e,i,(e=>{"CHANGE"===i?(e.elementType===exports.ElementType.CARD_NUMBER&&(e.network=function(e){for(const[t,i]of Object.entries(zn))if(i.test(e))return t;return""}(e.value),e.bin=this.formatBin(e.value),this.bin=this.formatBin(e.value)),n(e)):n(e)}))}).bind(e)}})}formatBin(e){return e.replace(/[-X]/g,"").slice(0,8)}get elementToFieldMap(){return new Map([[exports.ElementType.CARD_NUMBER,"card_number"],[exports.ElementType.CARDHOLDER_NAME,"cardholder_name"],[exports.ElementType.CVV,"security_code"],[exports.ElementType.EXPIRATION_MONTH,"expiry_month"],[exports.ElementType.EXPIRATION_YEAR,"expiry_year"],[exports.ElementType.EXPIRATION_DATE,"expiry_date"]])}}const Wn=(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/da44fa4/observability/index.html?${i}`,t.width="1px",t.height="1px",document.body.appendChild(t),t})(e)};
21
+ return function(e,t){var i=document.querySelector('script[src="'.concat(e,'"]'));if(null===i)return null;var n=ki(e,t),o=i.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(n.dataset).length)return null;var s=!0;return Object.keys(o.dataset).forEach((function(e){o.dataset[e]!==n.dataset[e]&&(s=!1)})),s?i:null}(n,o)&&r?t.resolve(r):function(e,t){void 0===t&&(t=Ui());Fi(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,o=e.onError,s=ki(t,i);s.onerror=o,s.onload=n,document.head.insertBefore(s,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:o},t).then((function(){var e=xi(s);if(e)return e;throw new Error("The window.".concat(s," global variable is not available."))}))}function Ui(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function xi(e){return window[e]}function Fi(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.")}Li=new WeakMap,Ai=new WeakMap,fi=new WeakMap,Oi=new WeakMap,Ti=new WeakMap,Ci=new WeakMap,Ri=new WeakMap,gi=new WeakMap;class Bi{static load(e,i){const n=e.toString(),o=Bi.scriptMap.get(n);if(o)return o;const s=(()=>t(this,void 0,void 0,(function*(){try{if(e===ji.PayPal){if(!i)throw new Error("PayPal config is required");return yield Bi.loadPayPalScript(i)}return yield Bi.loadScript(e)}finally{Bi.scriptMap.delete(n)}})))();return Bi.scriptMap.set(n,s),s}static reset(){Bi.scriptMap.clear()}static preloadCardForm(){const e="https://assets.payrails.io/32d29cd/card";[[`${e}/index.js`,"payrails-iframe-js-v2"],[`${e}/index.html`,"payrails-iframe-html-v2"]].forEach((([e,t])=>{if(!document.getElementById(t)){const i=document.createElement("link");i.id=t,i.rel="preload",i.as="script",i.href=e,document.head.appendChild(i)}}))}static loadScript(e){const t=`payrails-script-${JSON.stringify(e)}`;if(Bi.scriptMap.has(t))return Bi.scriptMap.get(t);const i=document.createElement("script");i.src=e,i.id=t;const n=new Promise(((t,n)=>{i.onload=()=>t(),i.onerror=t=>n(Bi.logLoadError(e,new Error(t.toString())))}));return Bi.scriptMap.set(t,n),document.body.appendChild(i),n}static loadPayPalScript(e){return t(this,arguments,void 0,(function*({clientId:e,currency:t,vault:i,intent:n}){try{const o=yield Yi({"client-id":e,components:"buttons,funding-eligibility",intent:n,currency:t,vault:i,"data-namespace":"payrailsPaypal"});if(o)return o}catch(e){throw Bi.logLoadError(ji.PayPal,e)}throw Bi.logLoadError(ji.PayPal)}))}constructor(){}static logLoadError(e,t){const i=new Map([[ji.ApplePay,o.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR],[ji.GooglePay,o.ERROR_CODES.PAYRAILS_CLIENT_GPAY_LOADING_ERROR],[ji.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 s.PayrailsLogger.error(n.message,{error:n}),n}}var ji;Bi.scriptMap=new Map,function(e){e.ApplePay="https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js",e.GooglePay="https://pay.google.com/gp/p/js/pay.js",e.PayPal="paypal-sdk"}(ji||(ji={}));class Vi extends U{constructor(e){super("span",{id:e.id,className:"payrails-store-instrument"}),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,o,s,r,a,l,c;const d=(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===(s=null===(o=null===(n=this.options)||void 0===n?void 0:n.translations)||void 0===o?void 0:o.labels)||void 0===s?void 0:s.storeInstrument)||"Save instrument for future payments",u=`${this.id}-checkbox`;(null===(l=null===(a=null===(r=this.options)||void 0===r?void 0:r.translations)||void 0===a?void 0:a.labels)||void 0===l?void 0:l.saveInstrument)&&console.warn("The saveInstrument label is deprecated, please use storeInstrument instead");const _="checked"==(null===(c=this.options)||void 0===c?void 0:c.defaultStoreInstrumentState);this.element.innerHTML=`<label for="${u}"><input type="checkbox" id="${u}" name="${u}" class="payrails-store-instrument-checkbox">${d}</label>`,_&&(this.element.querySelector("input").checked=!0)}applyStyles(){var e,t;Object.keys((null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.storeInstrumentCheckbox)||{}).forEach((e=>{var t,i,n;this.element.style[e]=null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.storeInstrumentCheckbox)||void 0===n?void 0:n[e]}))}addListeners(){this.element.addEventListener("change",(e=>{var t,i,n,o;(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onSaveInstrumentCheckboxChanged)&&(null===(o=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===o||o.onSaveInstrumentCheckboxChanged({checked:this.isChecked})),e.stopPropagation(),e.stopImmediatePropagation()})),this.element.addEventListener("click",(e=>{e.stopPropagation(),e.stopImmediatePropagation()}))}}class Gi extends U{constructor(e,i){var n,o;super(e,i),this.options=i,this.storeInstrumentCheckbox=null,(null===(n=this.options)||void 0===n?void 0:n.showStoreInstrumentCheckbox)&&(this.storeInstrumentCheckbox=new Vi(Object.assign(Object.assign({},i),{id:`${null===(o=this.options)||void 0===o?void 0:o.id}-store-instrument-checkbox`,events:{onSaveInstrumentCheckboxChanged:e=>t(this,void 0,void 0,(function*(){var t,n;null===(n=null===(t=null==i?void 0:i.events)||void 0===t?void 0:t.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(t,e)}))}})),this.subElements.push(this.storeInstrumentCheckbox))}get shouldStoreInstrument(){var e,t;return(null===(e=this.storeInstrumentCheckbox)||void 0===e?void 0:e.isChecked)||(null===(t=this.options)||void 0===t?void 0:t.alwaysStoreInstrument)||!1}}class Xi extends Gi{static isApplePayAvailable(){return t(this,void 0,void 0,(function*(){try{return yield Bi.load(ji.ApplePay),ApplePaySession.canMakePayments()}catch(e){return!1}}))}constructor(e){super("div",Object.assign(Object.assign({},e),{id:"payrails-apple-pay-button"})),this.options=e,this.appleButton=null,this.paymentExecutor=new b,Xi.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))}))}mount(e){this.unmount(),super.mount(e),(()=>{t(this,void 0,void 0,(function*(){try{(yield Xi.isApplePayAvailable())&&(yield this.mountApplePayButton())}catch(e){}}))})()}unmount(){var e,t;null===(t=null===(e=this.appleButton)||void 0===e?void 0:e.parentElement)||void 0===t||t.removeChild(this.appleButton),super.unmount()}mountApplePayButton(){return t(this,void 0,void 0,(function*(){var e,i,n;try{const o=(null===(e=this.options.styles)||void 0===e?void 0:e.type)||"buy",s=(null===(i=this.options.styles)||void 0===i?void 0:i.style)||"black";this.element.innerHTML=`<apple-pay-button buttonstyle="${s}" type="${o}" locale="en-GB"></apple-pay-button>`,null===(n=this.storeInstrumentCheckbox)||void 0===n||n.mount(this.selector);const r=this.element.querySelector("apple-pay-button");null==r||r.setAttribute("style","width: 100%;"),null==r||r.addEventListener("click",(()=>t(this,void 0,void 0,(function*(){yield this.createApplePaySession()}))))}catch(e){}}))}createApplePaySession(){return t(this,void 0,void 0,(function*(){const e=C.applePayConfig,{countryCode:i,supportedNetworks:n,merchantCapabilities:o,requiredBillingContactFields:s=[]}=e,{amount:r}=g();try{const e=new ApplePaySession(3,{countryCode:i,currencyCode:r.currency,merchantCapabilities:o,supportedNetworks:n,total:{label:"",type:"final",amount:r.value},requiredBillingContactFields:s});e.onvalidatemerchant=i=>t(this,void 0,void 0,(function*(){const{res:t}=yield this.paymentExecutor.createApplePaySession({requestUrl:C.createSessionLink,sessionUrl:i.validationURL,clientDomain:this.options.clientDomain}),n=t.data.data;e.completeMerchantValidation(n)})),e.oncancel=()=>{var e,t,i;(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onAuthorizeFailed)&&(null===(i=this.options)||void 0===i||i.events.onAuthorizeFailed())},e.onpaymentauthorized=i=>t(this,void 0,void 0,(function*(){var t,n,o,s,r,a,l,c,d,u,_,p;try{const u=yield this.onApplePayAuthorized(i.payment.token,{billingContact:i.payment.billingContact});if("authorizeSuccessful"===(null===(t=null==u?void 0:u.finalState)||void 0===t?void 0:t.code))(null===(n=this.options.events)||void 0===n?void 0:n.onAuthorizeSuccess)&&this.options.events.onAuthorizeSuccess();else e.completePayment(ApplePaySession.STATUS_FAILURE),(null===(s=null===(o=this.options)||void 0===o?void 0:o.events)||void 0===s?void 0:s.onAuthorizeFailed)&&(null===(r=this.options)||void 0===r||r.events.onAuthorizeFailed());e.completePayment(ApplePaySession.STATUS_SUCCESS),(null===(l=null===(a=this.options)||void 0===a?void 0:a.events)||void 0===l?void 0:l.onAuthorizeSuccess)&&(null===(d=null===(c=this.options)||void 0===c?void 0:c.events)||void 0===d||d.onAuthorizeSuccess(u))}catch(t){e.completePayment(ApplePaySession.STATUS_FAILURE),(null===(_=null===(u=this.options)||void 0===u?void 0:u.events)||void 0===_?void 0:_.onAuthorizeFailed)&&(null===(p=this.options)||void 0===p||p.events.onAuthorizeFailed(t))}}));return(yield L(this.options.events))&&e.begin(),e}catch(e){return null}}))}onApplePayAuthorized(e,i){return t(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},e),{paymentNetwork:e.paymentMethod.network,paymentInstrumentName:e.paymentMethod.displayName}),n={paymentToken:JSON.stringify(t)};(null==i?void 0:i.billingContact)&&(n.billingAddress={country:{name:null==i?void 0:i.billingContact.country,code:null==i?void 0:i.billingContact.countryCode},postalCode:null==i?void 0:i.billingContact.postalCode});const o=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.APPLE_PAY,integrationType:"api",paymentInstrumentData:n,amount:g().amount,storeInstrument:this.shouldStoreInstrument}];return yield this.paymentExecutor.pay(o)}))}}const zi={wrapper:{display:"flex",flexDirection:"column"}};var Hi;!function(e){e.GET="GET"}(Hi||(Hi={}));class Wi extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{description:`[${t}] ${e} unsuccessful`})}}class qi extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} too many requests`})}}const $i=({url:e})=>t(void 0,[{url: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 qi(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 Ki extends U{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 Ji="__payrails-selectedCountry";class Zi extends Ki{constructor(e){var t,i;super("span",Object.assign(Object.assign({},e),{id:"payrails-country-select",className:"payrails-country-selector-wrapper",styles:null===(t=e.styles)||void 0===t?void 0:t.wrapper})),this.options=e,this._countriesList=null===(i=e.config)||void 0===i?void 0:i.data,this.createHTML(),this.attachEvents()}set countriesList(e){this._countriesList=e,this.populateCountrySelect(),this.setDefaultCountry()}get countriesList(){return this._countriesList}populateCountrySelect(){return t(this,void 0,void 0,(function*(){var e,t;const i=document.createElement("option");i.value="",i.textContent=(null===(e=this.options.translations)||void 0===e?void 0:e.placeholder)||"Select Country",null===(t=this.selectElement)||void 0===t||t.appendChild(i),this._countriesList.forEach((e=>{var t;const i=document.createElement("option");i.value=e.code,i.textContent=e.name,null===(t=this.selectElement)||void 0===t||t.appendChild(i)}))}))}setDefaultCountry(){const e=JSON.parse(sessionStorage.getItem(Ji)||"{}");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(Ji,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(Ji,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,o,s;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===(s=null===(n=this._countriesList)||void 0===n?void 0:n.get(null===(o=this.selectElement)||void 0===o?void 0:o.value))||void 0===s?void 0:s.iso3)||""}}set value(e){this.selectElement&&(this.selectElement.value=e)}}class Qi extends Ki{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,o=this.selectedCountry,s=(null===(i=null===(t=this._countriesList)||void 0===t?void 0:t.get(o))||void 0===i?void 0:i.postalCodeRegex)||"";let r=!1;if(n)return r=s?new RegExp(s).test(n):n.length>0,r}setValidation(e){this.inputElement&&(this.inputElement.pattern=e,this.inputElement.classList.remove("error"))}}class en extends U{get fullAddress(){var e,t,i,n;const o={},s=null===(e=this.countrySelector)||void 0===e?void 0:e.value;return s&&(o.country=s,s.code&&(null===(i=null===(t=this.countriesMap)||void 0===t?void 0:t.get(s.code))||void 0===i?void 0:i.showPostalCode)&&(o.postalCode=null===(n=this.postalCodeInput)||void 0===n?void 0:n.value)),Object.assign({},o)}constructor(e){var i,n;super("div",{id:e.id,className:"payrails-address-selector-wrapper",styles:(null===(i=e.styles)||void 0===i?void 0:i.wrapper)||(null===(n=zi)||void 0===n?void 0:n.wrapper)}),this.options=e,this.countriesMap=void 0,this.createAddressComponents(),this.init(),this.applyStyles(),t(void 0,void 0,void 0,(function*(){const e=yield $i({url:"https://assets.payrails.io/json/countries.json"});return new Map(Object.entries(e.res))})).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,o,s,r,a,l,c,d,u,_;const p={id:"country-selector",styles:(null===(t=this.options.styles)||void 0===t?void 0:t.countrySelector)||(null===(i=zi)||void 0===i?void 0:i.countrySelector),events:{onChange:e=>{var t,i;const{country:n}=e;this.onCountryChange(n),null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onBillingAddressChanged)||void 0===i||i.call(t,{isValid:this.isValid,billingAddress:this.fullAddress})}},translations:{label:null===(o=null===(n=this.options.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.countrySelector,placeholder:null===(r=null===(s=this.options.translations)||void 0===s?void 0:s.placeholders)||void 0===r?void 0:r.countrySelector}},E={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===(d=null===(c=this.options.translations)||void 0===c?void 0:c.placeholders)||void 0===d?void 0:d.postalCodeInput},styles:(null===(u=this.options.styles)||void 0===u?void 0:u.postalCodeInput)||(null===(_=zi)||void 0===_?void 0:_.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 Zi(p),this.postalCodeInput=new Qi(E)}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 o=this.countrySelector&&this.countrySelector.isValid;const s=null===(t=null===(e=this.countrySelector)||void 0===e?void 0:e.value)||void 0===t?void 0:t.code;return s&&(null===(n=null===(i=this.countriesMap)||void 0===i?void 0:i.get(s))||void 0===n?void 0:n.showPostalCode)&&(o=o&&this.postalCodeInput&&this.postalCodeInput.isValid),!!o}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 tn extends U{constructor(e){super("div",{id:e.id,className:e.className}),this.options=e,this.installmentOptions=[],this.installmentOptions=e.installmentOptions||[],this.createHTML(),this.applyStyles(),this.addListeners()}generateOptionsHTML(e){var t,i,n;return[`<option value="">${(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"}</option>`,...(null==e?void 0:e.map((e=>`<option value="${e.count}">${e.count} x ${e.amount}</option>`)))||[]].join("")}renderOptions(e){const t=this.element.querySelector("select");t&&(t.innerHTML=this.generateOptionsHTML(e),e.length>0?this.setDisabled(!1):this.setDisabled(!0))}updateOptions(e){this.installmentOptions=e,this.renderOptions(e)}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=>{e.stopPropagation(),e.stopImmediatePropagation()})),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 nn extends U{constructor(e,t){var i,n,o;super(e,t),this.options=t,this.paymentInstallmentsDropdown=null,this.paymentInstallmentsDropdown=new tn(Object.assign(Object.assign({},t),{id:`${null===(i=this.options)||void 0===i?void 0:i.id}-dropdown`,className:"payrails-payment-installments-dropdown",installmentCurrency:null===(n=this.options)||void 0===n?void 0:n.installmentCurrency,installmentOptions:null===(o=this.options)||void 0===o?void 0:o.installmentOptions})),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))}setDisabled(e){var t;null===(t=this.paymentInstallmentsDropdown)||void 0===t||t.setDisabled(e)}}const{CARD_NUMBER:on,CVV:sn,CARDHOLDER_NAME:rn,EXPIRATION_DATE:an,EXPIRATION_MONTH:ln,EXPIRATION_YEAR:cn}=exports.ElementType,dn={base:{border:"none",padding:"10px 16px",color:"#1d1d1d",backgroundColor:"#fff"},invalid:{backgroundColor:"#f9e1e1",borderColor:"#f25226",border:"1px solid"}},un=[{type:rn,placeholder:"Card holder",styles:Object.assign(Object.assign({},dn),{base:Object.assign(Object.assign({},dn.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px"})})},{type:on,placeholder:"1234 1234 1234 1234",styles:Object.assign(Object.assign({},dn),{base:Object.assign(Object.assign({},dn.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:ln,placeholder:"MM",styles:Object.assign(Object.assign({},dn),{base:Object.assign(Object.assign({},dn.base),{borderBottom:"1px solid #eae8ee",borderLeft:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomLeftRadius:"4px"})})},{type:cn,placeholder:"YY",format:"YY",styles:Object.assign(Object.assign({},dn),{base:Object.assign(Object.assign({},dn.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee"})})},{type:an,placeholder:"MM/YY",format:"MM/YY",styles:Object.assign(Object.assign({},dn),{base:Object.assign(Object.assign({},dn.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:sn,placeholder:"CVC",styles:Object.assign(Object.assign({},dn),{base:Object.assign(Object.assign({},dn.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomRightRadius:"4px"}),cardIcon:{position:"absolute",right:"8px",height:"24px",bottom:"calc(50% - 12px)"}})}];class _n extends Gi{get bin(){return this.collectContainer.bin}get isBinLookupEnabled(){return this.collectContainer.isBinLookupEnabled}constructor(e,t){var i,n,o,s,r;super("div",Object.assign(Object.assign({},t),{translations:Object.assign(Object.assign({},null==t?void 0:t.translations),{labels:Object.assign(Object.assign({},null===(i=null==t?void 0:t.translations)||void 0===i?void 0:i.labels),{saveInstrument:null===(o=null===(n=null==t?void 0:t.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.saveCreditCard})}),styles:Object.assign({storeInstrumentCheckbox:null===(s=null==t?void 0:t.styles)||void 0===s?void 0:s.storeCardCheckbox},null==t?void 0:t.styles),id:"payrails-card-form"})),this.collectContainer=e,this.options=t,this.formFields=[],this.paymentInstallmentsDropdown=null,this.addressComponent=null,this.lastBin=null,this.lastBinLookup=null,this.throttledFetchBinLookup=function(e,t){let i,n;return function(...o){return new Promise(((s,r)=>{n?(clearTimeout(i),i=setTimeout((()=>{Date.now()-n>=t&&(e(...o).then(s).catch(r),n=Date.now())}),t-(Date.now()-n))):(e(...o).then(s).catch(r),n=Date.now())}))}}(this.fetchBinLookup.bind(this),500),(null===(r=null==t?void 0:t.styles)||void 0===r?void 0:r.storeCardCheckbox)&&console.warn("The `storeCardCheckbox` option for styles is deprecated. Please use `storeInstrumentCheckbox` instead."),this.initializeFormFields(),this.subElements.push(this.collectContainer),C.isPaymentInstallmentsEnabled(exports.PAYMENT_METHOD_CODES.CARD)&&(this.paymentInstallmentsDropdown=new nn("span",Object.assign(Object.assign({},t),{installmentCurrency:"",installmentOptions:this.getinstallmentOptions(),id:"payrails-card-form-payment-installments",className:"payrails-card-form-payment-installments-container"})),this.paymentInstallmentsDropdown&&this.subElements.push(this.paymentInstallmentsDropdown)),C.isAddressSelectorEnabled(exports.PAYMENT_METHOD_CODES.CARD)&&(this.addressComponent=this.createAddressSelector(),this.subElements.push(this.addressComponent)),this.storeInstrumentCheckbox&&this.subElements.push(this.storeInstrumentCheckbox)}initializeFormFields(){var e;(null===(e=this.options)||void 0===e?void 0:e.layout)&&this.options.layout.length>0?this.initializeCustomLayout():this.initializeDefaultLayout()}getErrorTextStyles(e){return(null==e?void 0:e.base)?e:{base:{}}}createFormField(e,t,i,n,o,s=!1){var r,a,l,c,d,u,_,p,E,h,I,v;const m=this.getErrorTextStyles(i);return new pn(this.collectContainer,{type:e,required:s,label: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[e],errorTextStyles:m,placeholder:(null===(u=null===(d=null===(c=this.options)||void 0===c?void 0:c.translations)||void 0===d?void 0:d.placeholders)||void 0===u?void 0:u[e])||o,labelStyles:this.prepareLabelStyles(e),inputStyles:this.prepareInputStyles(t,e),translations:{error:{default:(null===(h=null===(E=null===(p=null===(_=this.options)||void 0===_?void 0:_.translations)||void 0===p?void 0:p.error)||void 0===E?void 0:E.default)||void 0===h?void 0:h[e])||""}},format:n,events:{onFocus:null===(v=null===(I=this.options)||void 0===I?void 0:I.events)||void 0===v?void 0:v.onFocus,onChange:this.onChange.bind(this),onReady:this.triggerOnReady.bind(this)}})}initializeCustomLayout(){var e;if(!(null===(e=this.options)||void 0===e?void 0:e.layout))return;const t=e=>{e.forEach((e=>{var t,i,n,s,r;const a=un.find((t=>t.type===e));if(!a)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_INVALID_ELEMENT_TYPE);if(this.hasFieldBeenUsed(a.type))throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_DUPLICATE_ELEMENT);const{type:l,styles:c,format:d,placeholder:u}=a,_=!!(null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.errorTextStyles)||void 0===n?void 0:n.base);this.formFields.push(this.createFormField(l,c,null===(r=null===(s=this.options)||void 0===s?void 0:s.styles)||void 0===r?void 0:r.errorTextStyles,d,u,_))}))};this.options.layout.forEach((e=>t(e)))}hasFieldBeenUsed(e){return this.formFields.some((t=>t.type===e))}initializeDefaultLayout(){var e,t,i;const n=e=>{var t,i,n;return!(null===(t=this.options)||void 0===t?void 0:t.showCardHolderName)&&e===exports.ElementType.CARDHOLDER_NAME||(!(null===(i=this.options)||void 0===i?void 0:i.showSingleExpiryDateField)&&e===exports.ElementType.EXPIRATION_DATE||!(!(null===(n=this.options)||void 0===n?void 0:n.showSingleExpiryDateField)||e!==exports.ElementType.EXPIRATION_MONTH&&e!==exports.ElementType.EXPIRATION_YEAR))},o=!!(null===(i=null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.errorTextStyles)||void 0===i?void 0:i.base);un.filter((({type:e})=>!n(e))).forEach((({type:e,styles:t,format:i,placeholder:n})=>{var s,r;this.formFields.push(this.createFormField(e,t,null===(r=null===(s=this.options)||void 0===s?void 0:s.styles)||void 0===r?void 0:r.errorTextStyles,i,n,o))}))}throttledFetchBinLookupIfChanged(){return t(this,void 0,void 0,(function*(){return this.bin!==this.lastBin&&(this.lastBin=this.bin,this.lastBinLookup=yield this.throttledFetchBinLookup()),this.lastBinLookup}))}tokenize(e){return this.collectContainer.tokenize(e)}createAddressSelector(){var e,t,i,n,o;return new en({id:"payrails-address-selector",events:Object.assign(Object.assign({},null===(e=this.options)||void 0===e?void 0:e.events),{onBillingAddressChanged:e=>{var t,i,n;this.onChange(),null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onBillingAddressChanged)||void 0===n||n.call(i,e)}}),styles:null===(i=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.addressSelector,translations:null===(o=null===(n=this.options)||void 0===n?void 0:n.translations)||void 0===o?void 0:o.addressSelector})}show(){var e,t;const i=document.getElementById(this.collectContainer.id);if(!i){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw s.PayrailsLogger.error(e.message,{error:e}),e}Object.assign(i.style,null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.wrapper),this.element.style.display="flex"}hide(){this.element.style.display="none"}triggerOnReady(){var e,t,i;this.formFields.reduce(((e,t)=>e&&t.isReady),!0)&&(null===(i=null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onReady)||void 0===i||i.call(t))}prepareLabelStyles(e){return["base"].reduce(((t,i)=>{var n,o,s,r,a,l,c,d;return t[i]=Object.assign(Object.assign(Object.assign({},null===(o=null===(n=this.options)||void 0===n?void 0:n.styles)||void 0===o?void 0:o.base),null===(a=null===(r=null===(s=this.options)||void 0===s?void 0:s.styles)||void 0===r?void 0:r.labels)||void 0===a?void 0:a.all),null===(d=null===(c=null===(l=this.options)||void 0===l?void 0:l.styles)||void 0===c?void 0:c.labels)||void 0===d?void 0:d[e]),t}),{})}prepareInputStyles(e,t){var i;let n=JSON.parse(JSON.stringify(e));return(null===(i=this.options)||void 0===i?void 0:i.showCardHolderName)&&t===exports.ElementType.CARD_NUMBER&&(this.element.setAttribute("class","with-card-holder"),n=Object.assign(Object.assign({},e),{base:Object.assign(Object.assign({},dn.base),{border:"1px solid #eae8ee",borderTop:"none",padding:"10px 16px",textIndent:"0"})})),["base","complete","empty","focus","invalid","cardIcon","copyIcon"].forEach((e=>{var i,o,s,r,a,l,c,d;n[e]=Object.assign(Object.assign(Object.assign({},n[e]),null===(r=null===(s=null===(o=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===o?void 0:o.inputFields)||void 0===s?void 0:s.all)||void 0===r?void 0:r[e]),null===(d=null===(c=null===(l=null===(a=this.options)||void 0===a?void 0:a.styles)||void 0===l?void 0:l.inputFields)||void 0===c?void 0:c[t])||void 0===d?void 0:d[e])})),n}validate(){return this.collectContainer.validate()}get isValid(){var e;const t=this.formFields.reduce(((e,t)=>e&&t.isValid),!0);return this.addressComponent?t&&!!(null===(e=this.addressComponent)||void 0===e?void 0:e.isValid):t}get cardNetwork(){var e,t;return null!==(t=null===(e=this.formFields.find((e=>Boolean(e.cardNetwork))))||void 0===e?void 0:e.cardNetwork)&&void 0!==t?t:""}onChange(){var e,t,i,n;(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onChange)&&(null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n||n.onChange({isValid:this.isValid,cardNetwork:this.cardNetwork,bin:this.bin,billingAddress:this.billingAddress}),C.isPaymentInstallmentsEnabled(exports.PAYMENT_METHOD_CODES.CARD)&&this.bin.length>=6&&this.throttledFetchBinLookupIfChanged().then((e=>{this.updateInstallments(e)})))}updateInstallments(e){var t;if(this.paymentInstallmentsDropdown&&this.isBinLookupEnabled){const i=this.getinstallmentOptions(null===(t=null==e?void 0:e.issuerCountry)||void 0===t?void 0:t.code);i?this.paymentInstallmentsDropdown.updateInstallmentOptions(i):this.paymentInstallmentsDropdown.updateInstallmentOptions([])}}collectValues(){return t(this,void 0,void 0,(function*(){return{cardData:yield this.collectContainer.collect(),storeInstrument:this.shouldStoreInstrument,selectedInstallment:this.selectedInstallment,enrollInstrumentToNetworkOffers:Boolean(this.enforceEnrollInstrumentToNetworkOffersForMasterCard()),billingInfo:this.billingAddress}}))}get selectedInstallment(){var e;return null===(e=this.paymentInstallmentsDropdown)||void 0===e?void 0:e.selectedInstallmentValue}get billingAddress(){var e;return null===(e=this.addressComponent)||void 0===e?void 0:e.fullAddress}enforceEnrollInstrumentToNetworkOffersForMasterCard(){var e;return"mastercard"!==this.cardNetwork&&(null===(e=this.options)||void 0===e?void 0:e.enrollInstrumentToNetworkOffers)}fetchBinLookup(){return t(this,void 0,void 0,(function*(){return this.isBinLookupEnabled?yield this.collectContainer.fetchBinLookup(this.bin):this.bin}))}getinstallmentOptions(e){if(e){const t=C.getPaymentInstallmentOptions(exports.PAYMENT_METHOD_CODES.CARD);return t?t[e]:null}return null}}class pn{constructor(e,t){this.isValid=!1,this.isReady=!1,this.cardNetwork="";const{events:i}=t,n=e.createCollectElement(t);this.type=t.type,(null==i?void 0:i.onFocus)&&n.on("FOCUS",i.onFocus),n.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)})),n.on("CHANGE",(e=>{const{isEmpty:t,isValid:n,network:o}=e;this.isValid=!t&&n,this.cardNetwork=null!=o?o:"",(null==i?void 0:i.onChange)&&i.onChange(this)}))}}class En extends U{constructor(e,t,i,n,o){super("div",{id:e,className:"payrails-dropin-item"}),this.events=n,this.styles=o,this.isActive=!1,this.mountContainerClass="payrails-dropin-item-container",this.applyBaseStyles();const s=`payrails-dropin-item-${e}`,r=document.createElement("label");r.setAttribute("for",s);const a=document.createElement("input");if(a.setAttribute("type","radio"),a.setAttribute("name","payment-option"),a.setAttribute("id",s),a.setAttribute("value",s),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 c=document.createElement("div");c.setAttribute("class",this.mountContainerClass),this.element.appendChild(c)}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 hn;!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"}(hn||(hn={}));const In="https://assets.payrails.io/img/";class vn extends En{constructor(e,t,i,n,o){const s=e.displayName&&""!==e.displayName?e.displayName:"Unavailable";super(`payrails-payment-instrument-${e.id}`,s,vn.getInstrumentIcon(e),{onActivate:()=>{i(e),this.component.setDisabled(!1),this.installmentDropdown&&this.component.setPaymentInstallmentsDropdown(this.installmentDropdown)}},n),this.installmentDropdown=null,o&&(this.installmentDropdown=o),this.component=new mn(t,o)}static getInstrumentIcon(e){var t;if(e.paymentMethod===exports.PAYMENT_METHOD_CODES.CARD){switch(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.network){case hn.AMEX:return In+"amex.svg";case hn.DINERS:return In+"diners-club.svg";case hn.DISCOVER:return In+"discover.svg";case hn.HIPERCARD:return In+"hipercard.svg";case hn.JCB:return In+"jcb.svg";case hn.MAESTRO:return In+"maestro.svg";case hn.MASTERCARD:return In+"mastercard.svg";case hn.UNIONPAY:return In+"unionpay.svg";case hn.VISA:return In+"visa.svg"}return In+"default.svg"}return e.paymentMethod===exports.PAYMENT_METHOD_CODES.PAYPAL?In+"paypal.png":e.paymentMethod===exports.PAYMENT_METHOD_CODES.APPLE_PAY?In+"applepay.png":e.paymentMethod===exports.PAYMENT_METHOD_CODES.GOOGLE_PAY?In+"googlepay.png":""}}class mn extends U{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 yn extends U{constructor(e){super("div",{id:"payrails-card-list"}),this.listItems=[],C.savedCreditCards.forEach((t=>{const i=new Ln((()=>{(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 Ln extends U{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",o=document.createElement("label");o.setAttribute("for",i),o.addEventListener("click",e);const s=document.createElement("input");s.setAttribute("type","radio"),s.setAttribute("name","payment-option"),s.setAttribute("id",i),s.setAttribute("value",i),o.appendChild(s);const r=document.createElement("span");r.className="payment-option-text",o.appendChild(r);const a=document.createElement("img");a.src=vn.getInstrumentIcon(t),a.className="payment-option-icon",r.appendChild(a),r.appendChild(document.createTextNode(n)),this.element.appendChild(o)}}class An extends U{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 fn extends U{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 On extends U{constructor(e){super("div",{id:"payrails-dropin-loader",className:"payrails-dropin-loader-wrapper"}),this.options=e,this.selectors={[Tn.overlay]:".loading-overlay",[Tn.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 Tn;!function(e){e.overlay="overlay",e.loader="loader"}(Tn||(Tn={}));const Cn="https://assets.payrails.io/img";function Rn(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"}return"card"!==e?`${Cn}/${e}.png`:`${Cn}/credit-card-regular.svg`}class gn extends En{constructor(){super(...arguments),this.buttonShown=!1}activate(){var e,t;if(!this.buttonShown)return super.activate(),void(this.buttonShown=!0);this.applyActiveStyles(),this.isActive=!0,this.element.querySelector(this.component.selector).style.display="block",null===(t=null===(e=this.events)||void 0===e?void 0:e.onPaymentOptionVisibilityChange)||void 0===t||t.call(e)}deactivate(){this.isActive&&(this.isActive=!1,this.applyBaseStyles(),this.element.querySelector(this.component.selector).style.display="none")}mountAfterAvailable(){var e,t;super.mount(`#${this.loadElementId}`),null===(t=null===(e=this.events)||void 0===e?void 0:e.onAvailable)||void 0===t||t.call(e)}mount(e){const t=document.querySelector(e);if(!t){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);throw s.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 Nn extends gn{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?Rn("applepay"):void 0,void 0,e.styles),this.loadElementId="apple-pay-dropin-load-element",this.component=new Xi(Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},e.events),{onApplePayAvailable:()=>{this.mountAfterAvailable()}})}))}}class Sn extends En{constructor(e,t,i){var n,o;super("payrails-credit-card-wrapper",(null===(o=null===(n=i.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.label)||"Card",i.showPaymentMethodLogo?Rn("card"):void 0,Object.assign({},i.events),Object.assign({},i.styles)),this.cardForm=e,this.paymentButton=t,this.cardFormShown=!1,this.component=new Pn(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 Pn extends U{constructor(e,t){super("div",{id:"payrails-form-container"}),this.subElements.push(e,t)}}class bn extends U{constructor(e){var t,i,n,o;super("button",{id:e.id,className:"payrails-generic-button",styles:null!==(i=null===(t=e.styles)||void 0===t?void 0:t.base)&&void 0!==i?i:{}}),this.options=e,this.isDisabled=!1,this.element.innerText=null==e?void 0:e.translations.label,e.styles&&this.setStyles(null!==(o=null===(n=e.styles)||void 0===n?void 0:n.base)&&void 0!==o?o:{}),this.element.addEventListener("click",this.onClick.bind(this)),this.element.addEventListener("mouseenter",(()=>{var e;this.isDisabled||this.setStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{})})),this.element.addEventListener("mouseleave",(()=>{var e;this.isDisabled||this.removeStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{})}))}getElement(){return this.element}onClick(){return t(this,void 0,void 0,(function*(){var e,t;if((null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onClick)&&!this.isDisabled){try{this.triggerLoading(!0),yield this.options.events.onClick()}catch(e){throw this.triggerLoading(!1),e}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;this.isDisabled=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===(i=this.options)||void 0===i?void 0:i.translations.label,this.removeStyles((null===(n=this.options.styles)||void 0===n?void 0:n.loading)||{}))}}const Dn={label:"Generic redirect"},Mn={pix:75e4};class wn extends U{constructor(e,t){super("div",{id:`payrails-generic-redirect-${e.paymentMethod.paymentMethodCode}`}),this.options=e,this.returnInfo=t,this.popup=null;const i=this.buildRedirectButton();this.element.appendChild(i.getElement()),this.paymentExecutor=new b(this.returnInfo)}buildRedirectButton(){var e,t,i;return new bn({id:"payrails-generic-redirect-button",translations:{label:null!==(t=null===(e=this.options.translations)||void 0===e?void 0:e.label)&&void 0!==t?t:Dn.label},events:{onClick:this.onClick.bind(this)},styles:null!==(i=this.options.styles)&&void 0!==i?i:{}})}onClick(){return t(this,void 0,void 0,(function*(){var e,t,i,n;if(yield L(null!==(e=this.options.events)&&void 0!==e?e:{}))try{const e=null===(t=C.availablePaymentMethods.find((({paymentMethodCode:e})=>e===this.options.paymentMethod.paymentMethodCode)))||void 0===t?void 0:t.integrationType;if(!e)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED);const i=yield this.paymentExecutor.pay([{paymentMethodCode:this.options.paymentMethod.paymentMethodCode,integrationType:e,amount:g().amount}]),{action:n,link:s}=this.handleAuthorizationResult(i);if("redirect"!==n)return;if(!s)throw new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK);if(Object.keys(Mn).includes(this.options.paymentMethod.paymentMethodCode)){const e=Mn[this.options.paymentMethod.paymentMethodCode],t=2e4,i=2e3,n=Math.ceil((e-t)/i);return new b(this.returnInfo,i,n,t).pollForAuthorizationResult(C.url,0,["authorizeSuccessful","authorizeFailed"]).then((e=>{var t;this.handleAuthorizationResult(e),null===(t=this.popup)||void 0===t||t.unmount()})),this.createPopupWithTimeout(s,e)}return this.redirectToPaymentLink(s)}catch(e){e instanceof o.PayrailsError&&s.PayrailsLogger.error(e.message,{error:e}),null===(n=null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeFailed)||void 0===n||n.call(i)}}))}handleAuthorizationResult(e){var t,i,n,s,r,a,l,c;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)?(null===(r=null===(s=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===s?void 0:s.onAuthorizeSuccess)||void 0===r||r.call(s),{code:"authorizeSuccessful",action:"success"}):(null===(c=null===(l=null===(a=this.options)||void 0===a?void 0:a.events)||void 0===l?void 0:l.onAuthorizeFailed)||void 0===c||c.call(l,e),{code:"authorizeFailed",action:"fail"})}createPopupWithTimeout(e,t){return new Promise((()=>{const i=new D(e,this.paymentExecutor,this.options);this.popup=i,this.popup.mount(),setTimeout((()=>{var e,t;null==i||i.unmount(),null===(t=null===(e=this.options.events)||void 0===e?void 0:e.onAuthorizeFailed)||void 0===t||t.call(e)}),t)}))}redirectToPaymentLink(e){return new Promise((()=>{window.location.href=e,setTimeout((()=>{var e,t;null===(t=null===(e=this.options.events)||void 0===e?void 0:e.onAuthorizeFailed)||void 0===t||t.call(e)}),3e4)}))}}const kn=e=>e===exports.PAYMENT_METHOD_CODES.GENERIC_REDIRECT?{translations:{label:"Mercado Pago",button:{label:"Pay with Mercado Pago"}}}:{translations:{label:e,button:{label:`Pay with ${e}`}}};class Yn extends En{constructor(e,t){var i,n,o,s,r;super(`payrails-${e.paymentMethod.paymentMethodCode}-dropin-element`,(null===(i=null==e?void 0:e.translations)||void 0===i?void 0:i.label)||kn(e.paymentMethod.paymentMethodCode).translations.label,(null===(n=e.config)||void 0===n?void 0:n.showPaymentMethodLogo)?Rn(e.paymentMethod.paymentMethodCode):void 0,null==e?void 0:e.events,null===(o=null==e?void 0:e.styles)||void 0===o?void 0:o.element),this.returnInfo=t,this.component=new wn({styles:(null===(s=null==e?void 0:e.styles)||void 0===s?void 0:s[e.paymentMethod.paymentMethodCode])||{},translations:(null===(r=null==e?void 0:e.translations)||void 0===r?void 0:r.button)||kn(e.paymentMethod.paymentMethodCode).translations.button,events:null==e?void 0:e.events,paymentMethod:e.paymentMethod},this.returnInfo)}}const Un={apiVersion:2,apiVersionMinor:0};class xn extends Gi{static getSDKClient(){return t(this,arguments,void 0,(function*(e=exports.PayrailsEnvironment.TEST,t){return yield Bi.load(ji.GooglePay),xn.googleSDKClient||(xn.googleSDKClient=new google.payments.api.PaymentsClient({environment:e,merchantInfo:t})),xn.googleSDKClient}))}static isGooglePayAvailable(e){return t(this,arguments,void 0,(function*(e,t=exports.PayrailsEnvironment.TEST,i){try{const n=yield xn.getSDKClient(t,i),o=Object.assign(Object.assign({},Un),{allowedPaymentMethods:e}),{result:s}=yield n.isReadyToPay(o);return s}catch(e){return!1}}))}constructor(e){var t;super("div",Object.assign(Object.assign({},e),{id:"payrails-google-pay-button"})),this.options=e,this.paymentExecutor=new b(null===(t=this.options)||void 0===t?void 0:t.returnInfo),xn.isGooglePayAvailable(C.googlePayConfig,this.options.environment,this.options.merchantInfo).then((e=>{var t,i,n;e&&(null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onGooglePayAvailable)||void 0===n||n.call(i))}))}sdkLoaded(e){return t(this,void 0,void 0,(function*(){var i,n,o,s,r,a,l,c;if(xn.instance)return xn.instance;const d=(null===(n=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===n?void 0:n.buttonColor)||"black",u=(null===(s=null===(o=this.options)||void 0===o?void 0:o.styles)||void 0===s?void 0:s.buttonType)||"long",_=(null===(a=null===(r=this.options)||void 0===r?void 0:r.styles)||void 0===a?void 0:a.buttonSizeMode)||"fill",p=(null===(c=null===(l=this.options)||void 0===l?void 0:l.styles)||void 0===c?void 0:c.buttonLocale)||void 0;return xn.instance=e.createButton({buttonColor:d,buttonType:u,buttonSizeMode:_,buttonLocale:p,onClick:()=>t(this,void 0,void 0,(function*(){(yield L(this.options.events))&&(yield this.authorize(e))})),allowedPaymentMethods:C.googlePayConfig}),this.element.appendChild(xn.instance),xn.instance}))}onLoadPaymentData(e){return t(this,void 0,void 0,(function*(){var t,i,n,o,s,r,a,l,c,d;const u={paymentToken:JSON.stringify(e)},_=null===(i=null===(t=e.paymentMethodData)||void 0===t?void 0:t.info)||void 0===i?void 0:i.billingAddress;_&&(u.billingAddress={country:{code:null==_?void 0:_.countryCode},postalCode:null==_?void 0:_.postalCode});const p=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.GOOGLE_PAY,integrationType:"api",paymentInstrumentData:u,amount:g().amount,storeInstrument:this.shouldStoreInstrument}],E=yield this.paymentExecutor.pay(p);if("authorizePending"===(null===(n=null==E?void 0:E.finalState)||void 0===n?void 0:n.code)){new w(this.options,this.paymentExecutor).handle3ds(E)}else"authorizeSuccessful"===(null===(o=null==E?void 0:E.finalState)||void 0===o?void 0:o.code)?null===(a=null===(r=null===(s=this.options)||void 0===s?void 0:s.events)||void 0===r?void 0:r.onAuthorizeSuccess)||void 0===a||a.call(r):null===(d=null===(c=null===(l=this.options)||void 0===l?void 0:l.events)||void 0===c?void 0:c.onAuthorizeFailed)||void 0===d||d.call(c,E)}))}authorize(e){return t(this,void 0,void 0,(function*(){var t,i,n,o,s,r,a,l;const c=Object.assign(Object.assign({},Un),{allowedPaymentMethods:C.googlePayConfig,transactionInfo:{totalPriceStatus:"FINAL",totalPrice:null===(t=g().amount)||void 0===t?void 0:t.value,currencyCode:null===(i=g().amount)||void 0===i?void 0:i.currency,countryCode:null===(r=null===(s=null===(o=null===(n=C.meta)||void 0===n?void 0:n.order)||void 0===o?void 0:o.billingAddress)||void 0===s?void 0:s.country)||void 0===r?void 0:r.code},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)||""}});e.loadPaymentData(c).then((e=>{this.onLoadPaymentData(e)})).catch((e=>{var t,i,n;(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onAuthorizeFailed)&&(null===(n=this.options)||void 0===n||n.events.onAuthorizeFailed(e))}))}))}mount(e){super.mount(e),(()=>{t(this,void 0,void 0,(function*(){var e;try{if(yield xn.isGooglePayAvailable(C.googlePayConfig,this.options.environment,this.options.merchantInfo)){const t=yield xn.getSDKClient(this.options.environment,this.options.merchantInfo),i=yield this.sdkLoaded(t);this.element.appendChild(i),null===(e=this.storeInstrumentCheckbox)||void 0===e||e.mount(this.selector)}}catch(e){}}))})()}unmount(){var e;null===(e=this.storeInstrumentCheckbox)||void 0===e||e.unmount(),xn.instance=null,super.unmount()}}xn.instance=null,xn.googleSDKClient=null;class Fn extends gn{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?Rn("googlepay"):void 0,e.events,e.styles),this.loadElementId="google-pay-dropin-load-element",this.component=new xn(Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},e.events),{onGooglePayAvailable:()=>{this.mountAfterAvailable()}}),returnInfo:e.returnInfo}))}}class Bn extends Gi{constructor(e){var i;Bn.instance&&(Bn.instance=void 0);const n="express"===(null===(i=null==C?void 0:C.paypalConfig)||void 0===i?void 0:i.integrationMode),o=!n&&(null==e?void 0:e.showStoreInstrumentCheckbox),s=n?"unchecked":null==e?void 0:e.defaultStoreInstrumentState,r=Object.assign(Object.assign({},e),{showStoreInstrumentCheckbox:o,defaultStoreInstrumentState:s,id:"payrails-paypal-button",events:Object.assign(Object.assign({},null==e?void 0:e.events),{onSaveInstrumentCheckboxChanged:i=>t(this,void 0,void 0,(function*(){var t,n,o;null===(n=null===(t=null==e?void 0:e.events)||void 0===t?void 0:t.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(t,i),null===(o=this.button)||void 0===o||o.close(),this.debouncedRender()}))})});super("div",r),this.options=e,this.renderDebounceTimeout=null,this.currentAbortController=null,this.isRendering=!1,this.buttonWrapperId="payrails-paypal-button-wrapper",this.checkboxWrapperId="payrails-paypal-checkbox-wrapper",this.createOneTimeOrder=()=>t(this,void 0,void 0,(function*(){var e,t,i,n,o,s,r;const a=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.PAYPAL,integrationType:"api",amount:g().amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!1}],l=yield this.paymentExecutor.pay(a),c=null===(i=null===(t=null===(e=l.response.links.confirm)||void 0===e?void 0:e.action)||void 0===t?void 0:t.parameters)||void 0===i?void 0:i.orderId;if(!c)throw null===(s=null===(o=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===o?void 0:o.onAuthorizeFailed)||void 0===s||s.call(o),new jn("No order id returned");return this.confirmLink=null===(r=l.response.links.confirm)||void 0===r?void 0:r.href,c})),this.loadPaypal().catch((()=>{})),this.element.innerHTML=`<div id="${this.buttonWrapperId}"></div><div id="${this.checkboxWrapperId}"></div>`,this.paymentExecutor=new b}loadPaypal(){return t(this,void 0,void 0,(function*(){const e=yield Bi.load(ji.PayPal,this.paypalScriptConfig);return yield this.createPaypalButton(e)}))}debouncedRender(){return this.renderDebounceTimeout&&clearTimeout(this.renderDebounceTimeout),this.currentAbortController&&this.currentAbortController.abort(),new Promise((e=>{this.renderDebounceTimeout=setTimeout((()=>t(this,void 0,void 0,(function*(){try{yield this.renderButton(),e()}catch(t){console.error("Failed to render PayPal button:",t),e()}}))),300)}))}get paypalScriptConfig(){const e=this.shouldStoreInstrument?"tokenize":"Instant"===C.paypalConfig.captureMode?"capture":"authorize";return{clientId:C.paypalConfig.clientId,intent:e,currency:g().amount.currency,vault:this.shouldStoreInstrument}}createPaypalButton(e){return t(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:()=>t(this,void 0,void 0,(function*(){var e,t,i,n;const o=[{paymentMethodCode:exports.PAYMENT_METHOD_CODES.PAYPAL,integrationType:"api",amount:g().amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!0}],s=yield this.paymentExecutor.pay(o);return this.confirmLink=null===(e=s.response.links.confirm)||void 0===e?void 0:e.href,(null===(n=null===(i=null===(t=s.response.links.confirm)||void 0===t?void 0:t.action)||void 0===i?void 0:i.parameters)||void 0===n?void 0:n.tokenId)||""}))})}onCancel(){var e,t;this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}),(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onAuthorizeFailed)&&this.options.events.onAuthorizeFailed()}createOneTimeOrderConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{createOrder:this.createOneTimeOrder.bind(this),onApprove:this.approvePayment.bind(this)})}createBaseConfig(){var e,i,n,r,a,l,c,d,u,_;return{fundingSource:"paypal",style:{color:(null===(i=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===i?void 0:i.color)||"gold",height:(null===(r=null===(n=this.options)||void 0===n?void 0:n.styles)||void 0===r?void 0:r.height)||40,label:(null===(l=null===(a=this.options)||void 0===a?void 0:a.styles)||void 0===l?void 0:l.label)||"paypal",shape:(null===(d=null===(c=this.options)||void 0===c?void 0:c.styles)||void 0===d?void 0:d.shape)||"rect",tagline:(null===(_=null===(u=this.options)||void 0===u?void 0:u.styles)||void 0===_?void 0:_.tagline)||!1},onError:e=>{var t,i;this.eventBus.emit("PAYRAILS_CLIENT_SESSION_EXPIRED",{}),(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onAuthorizeFailed)&&this.options.events.onAuthorizeFailed(e)},onClick:(e,i)=>t(this,void 0,void 0,(function*(){var e;return(yield L(null===(e=this.options)||void 0===e?void 0:e.events))?i.resolve():i.reject()})),onCancel:this.onCancel.bind(this),onShippingAddressChange:(e,i)=>t(this,void 0,void 0,(function*(){var n;let r;e.shippingAddress&&(r={deliveryAddress:{city:e.shippingAddress.city,postalCode:e.shippingAddress.postalCode,state:e.shippingAddress.state,country:{code:e.shippingAddress.countryCode}}});const a=yield((e,i)=>t(void 0,void 0,void 0,(function*(){if(null==e?void 0:e.onDeliveryAddressChanged)try{const t=yield e.onDeliveryAddressChanged(i);if(!t){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CALLBACK_FAILED,{description:"Callback passed to onDeliveryAddressChanged resolved to false"});return s.PayrailsLogger.error(e.message,{error:e}),!1}return t}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 s.PayrailsLogger.error(t.message,{error:t}),!1}return!0})))(null===(n=this.options)||void 0===n?void 0:n.events,r);if(!a)return i.reject()}))}}approvePayment(e){return t(this,void 0,void 0,(function*(){var t,i,n,o,s,r,a,l,c,d;if(!this.confirmLink)throw null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onAuthorizeFailed)||void 0===n||n.call(i),new jn("No confirm link");const u={};this.shouldStoreInstrument&&e.billingToken&&(u.tokenId=e.billingToken),this.fraudNetGuid&&(u.riskSessionCorrelationId=this.fraudNetGuid);"authorizeSuccessful"===(null===(o=(yield this.paymentExecutor.confirm(this.confirmLink,u)).finalState)||void 0===o?void 0:o.code)?null===(a=null===(r=null===(s=this.options)||void 0===s?void 0:s.events)||void 0===r?void 0:r.onAuthorizeSuccess)||void 0===a||a.call(r):null===(d=null===(c=null===(l=this.options)||void 0===l?void 0:l.events)||void 0===c?void 0:c.onAuthorizeFailed)||void 0===d||d.call(c)}))}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){Bn.instance||(Bn.instance=this,super.mount(e),(()=>{t(this,void 0,void 0,(function*(){yield this.debouncedRender()}))})())}renderButton(){return t(this,void 0,void 0,(function*(){var e;this.isRendering&&this.currentAbortController&&this.currentAbortController.abort(),this.currentAbortController=new AbortController;const t=this.currentAbortController.signal;try{this.isRendering=!0,this.button&&(this.button.close(),this.button=void 0);const i=yield Promise.race([this.loadPaypal(),new Promise(((e,i)=>{t.addEventListener("abort",(()=>i(new Vn("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,Bn.instance=void 0,super.unmount()}}class jn extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION,{description:`PaypalOrderError: ${e}`,cause:t})}}class Vn extends o.PayrailsError{constructor(e,t){super(o.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT,{description:`PaypalButtonError: ${e}`,cause:t})}}class Gn extends gn{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)?Rn("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 Bn(Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},null==e?void 0:e.events),{onPaypalAvailable:()=>{this.mountAfterAvailable()}})}))}}class Xn extends U{constructor(e,t,i){var n,o,s;super("fieldset",{id:"payrails-dropin-component"}),this.collectContainer=e,this.clientConfig=t,this.dropinConfig=i,this.applyStyles();void 0!==(null===(o=null===(n=this.dropinConfig.paymentMethodsConfiguration)||void 0===n?void 0:n.cards)||void 0===o?void 0:o.showExistingCards)&&console.warn("The `showExistingCards` option is deprecated and will be removed in a future version. Please use `showStoredInstruments` instead.");const r=new Map;C.storedDropinInstruments.forEach((e=>{if(this.isStoredInstrumentEnabled(e.paymentMethod)){this.cardPaymentButton=this.createCardPaymentButton();const t=this.createStoredInstrumentElement(e);r.set(t.identifier,t)}}));const a={[exports.PAYMENT_METHOD_CODES.CARD]:this.createCreditCardButton.bind(this),[exports.PAYMENT_METHOD_CODES.PAYPAL]:this.createPayPalButton.bind(this),[exports.PAYMENT_METHOD_CODES.GOOGLE_PAY]:this.createGooglePayButton.bind(this),[exports.PAYMENT_METHOD_CODES.APPLE_PAY]:this.createApplePayButton.bind(this)};C.availablePaymentMethods.forEach((e=>{const t=e.paymentMethodCode;if(t&&a[t]){a[t];const i=C.getPaymentMethodConfig(e),n=a[t](i);r.set(n.identifier,n)}else if(this.isHppIntegration(e)&&t){const t=this.createHppIntegrationElement(e);r.set(t.identifier,t)}})),this.element.addEventListener("change",(e=>{var t,i;const n=(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.value)||"";r.forEach((e=>{e.deactivate()})),null===(i=r.get(n))||void 0===i||i.activate()})),1===this.totalPaymentOptions&&this.element.classList.add("payrails-dropin-component--single"),this.subElements.push(...Array.from(r.values())),this.loadingScreen=new On({styles:null===(s=this.dropinConfig.styles)||void 0===s?void 0:s.loadingScreen})}isHppIntegration(e){var t;return e.paymentMethodCode===exports.PAYMENT_METHOD_CODES.GENERIC_REDIRECT||(null===(t=e.clientConfig)||void 0===t?void 0:t.flow)===O.REDIRECT}createStoredInstrumentElement(e){var t;let i;return this.cardPaymentButton=this.createCardPaymentButton(),e.paymentMethod===exports.PAYMENT_METHOD_CODES.CARD&&C.isPaymentInstallmentsEnabled(e.paymentMethod)&&(i=this.createInstallmentsDropdown(e)),new vn(e,this.cardPaymentButton,(e=>{var t,i;if(this.cardPaymentButton){this.cardPaymentButton.selectedInstrument=e;const n=C.getPaymentMethodForStoredInstrument(e);null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onPaymentOptionSelected)||void 0===i||i.call(t,{paymentMethod:n,instrument:e})}}),null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.element,i)}createInstallmentsDropdown(e){const t=this.getInstallmentOptionsForInstrument(e);return new nn("span",{installmentCurrency:g().amount.currency,installmentOptions:t,id:`payrails-card-form-payment-installments-${e.id}`,className:"payrails-card-form-payment-installments-container"})}getInstallmentOptionsForInstrument(e){var t,i,n;const o=e.paymentMethod,s=C.getPaymentInstallmentOptions(o),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?s[r]:null}createHppIntegrationElement(e){var t,i,n,r,a,l,c;const d=e.paymentMethodCode;if(!d){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 s.PayrailsLogger.error(t.message,{error:t}),t}return new Yn({paymentMethod:e,config:null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t[d],styles:{element:null===(n=null===(i=this.dropinConfig)||void 0===i?void 0:i.styles)||void 0===n?void 0:n.element,button:null===(l=null===(a=null===(r=this.dropinConfig)||void 0===r?void 0:r.styles)||void 0===a?void 0:a[d])||void 0===l?void 0:l.button},translations:null===(c=this.dropinConfig.translations)||void 0===c?void 0:c[d],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.clientConfig.returnInfo)}get totalPaymentOptions(){return C.availablePaymentMethods.length+C.storedDropinInstruments.length}createCreditCardButton(e){var t,i,n,o;return this.creditCard=new Sn(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===(n=null===(i=this.dropinConfig.paymentMethodsConfiguration)||void 0===i?void 0:i.cards)||void 0===n?void 0:n.showPaymentMethodLogo,translations:null===(o=this.dropinConfig.translations)||void 0===o?void 0:o.cardForm}),this.creditCard}createGooglePayButton(e){var t,i,n,o,s;return this.googlePay=new Fn(Object.assign({environment:this.clientConfig.environment||exports.PayrailsEnvironment.TEST,events:Object.assign(Object.assign({},this.getElementEvents()),{onPaymentOptionVisibilityChange:()=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onPaymentOptionSelected)||void 0===i||i.call(t,{paymentMethod:e})}}),redirectFor3DS:this.clientConfig.redirectFor3DS,showPaymentMethodLogo:null===(i=null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.googlePay)||void 0===i?void 0:i.showPaymentMethodLogo,styles:Object.assign(Object.assign({},null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.googlePayButton),null===(o=this.dropinConfig.styles)||void 0===o?void 0:o.element),returnInfo:this.clientConfig.returnInfo},null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s.googlePay)),this.googlePay}createPayPalButton(e){var t,i,n;return this.paypal=new Gn(Object.assign(Object.assign({},null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.payPal),{styles:Object.assign(Object.assign({},null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.paypalButton),null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.element),events:Object.assign(Object.assign({},this.getElementEvents()),{onPaymentOptionVisibilityChange:()=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onPaymentOptionSelected)||void 0===i||i.call(t,{paymentMethod:e})}})})),this.paypal}createCardForm(){var e,t,i,n,o,s;if(!this.cardForm){const r=null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.cards,a=Boolean(null==r?void 0:r.showStoreInstrumentCheckbox),l=Boolean(null==r?void 0:r.showCardHolderName),c=Boolean(null==r?void 0:r.alwaysStoreInstrument),d=Boolean(null==r?void 0:r.showSingleExpiryDateField),u=(null==r?void 0:r.layout)||[];this.cardForm=new _n(this.collectContainer,{showStoreInstrumentCheckbox:a,showCardHolderName:l,showSingleExpiryDateField:d,alwaysStoreInstrument:c,layout:u,translations:Object.assign(Object.assign({},null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.cardForm),{addressSelector:null===(i=this.dropinConfig.translations)||void 0===i?void 0:i.addressSelector}),styles:Object.assign(Object.assign(Object.assign({},null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.cardForm),null===(o=this.dropinConfig.styles)||void 0===o?void 0:o.element),{addressSelector:null===(s=this.dropinConfig.styles)||void 0===s?void 0:s.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,o,s,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===(o=null===(n=this.dropinConfig.paymentMethodsConfiguration)||void 0===n?void 0:n.cards)||void 0===o?void 0:o.disablePaymentButton)?!e:null===(r=null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s.cards)||void 0===r?void 0:r.disablePaymentButton;null===(a=this.cardPaymentButton)||void 0===a||a.setDisabled(l)},onSaveInstrumentCheckboxChanged:e=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onSaveInstrumentCheckboxChanged)||void 0===i||i.call(t,e)}})})}return this.cardPaymentButton&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardForm}createApplePayButton(e){var i,n,o,s,r;return this.applePay=new Nn(Object.assign(Object.assign({events:Object.assign(Object.assign({},this.getElementEvents()),{onAuthorizeSuccess:e=>{var t;if(e)if("authorizeSuccessful"===(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code))this.onAuthorizeSuccess();else this.onAuthorizeFailed()},onPaymentOptionVisibilityChange:()=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onPaymentOptionSelected)||void 0===i||i.call(t,{paymentMethod:e})},onPaymentButtonClicked:e=>t(this,void 0,void 0,(function*(){var t,i;return!!(yield null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onPaymentButtonClicked)||void 0===i?void 0:i.call(t,e))}))})},null===(i=this.dropinConfig.paymentMethodsConfiguration)||void 0===i?void 0:i.applePay),{styles:Object.assign(Object.assign({},null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.applePayButton),null===(o=this.dropinConfig.styles)||void 0===o?void 0:o.element),showPaymentMethodLogo:null===(r=null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s.applePay)||void 0===r?void 0:r.showPaymentMethodLogo})),this.applePay}createCardPaymentButton(){var e,t,i,n;return this.cardPaymentButton||(this.cardPaymentButton=new x({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.clientConfig.returnInfo)),this.cardForm&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardPaymentButton}onAuthorizeSuccess(){var e,t,i,n,o,s,r;null===(e=this.loadingScreen)||void 0===e||e.unmount(),this.subElements.forEach((e=>e.unmount())),new fn({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===(s=null===(o=this.dropinConfig)||void 0===o?void 0:o.styles)||void 0===s?void 0:s.authSuccess}).mount(this.selector),(null===(r=this.dropinConfig.events)||void 0===r?void 0:r.onAuthorizeSuccess)&&this.dropinConfig.events.onAuthorizeSuccess()}getElementEvents(){return Object.assign(Object.assign({},this.dropinConfig.events),{onAuthorizeSuccess:this.onAuthorizeSuccess.bind(this),onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onAuthorizePending:this.onAuthorizePending.bind(this),onAvailable:()=>{var e;(1===this.totalPaymentOptions||(null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.preselectFirstPaymentOption))&&this.subElements[0].activate()},onPaymentButtonClicked:e=>t(this,void 0,void 0,(function*(){var t,i,n,o;null===(t=this.loadingScreen)||void 0===t||t.mount(this.selector);let s=!0;return(null===(i=this.dropinConfig.events)||void 0===i?void 0:i.onPaymentButtonClicked)&&(s=!!(yield null===(o=null===(n=this.dropinConfig.events)||void 0===n?void 0:n.onPaymentButtonClicked)||void 0===o?void 0:o.call(n,e))),s}))})}onAuthorizePending(){var e,t,i,n,o,s,r,a;null===(e=this.loadingScreen)||void 0===e||e.unmount(),this.subElements.forEach((e=>e.unmount())),new fn({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===(s=null===(o=this.dropinConfig)||void 0===o?void 0:o.styles)||void 0===s?void 0:s.authSuccess}).mount(this.selector),null===(a=null===(r=this.dropinConfig.events)||void 0===r?void 0:r.onAuthorizePending)||void 0===a||a.call(r)}onAuthorizeFailed(e){return t(this,void 0,void 0,(function*(){var t,i,n,o,s,r,a;null===(t=this.loadingScreen)||void 0===t||t.unmount();new An({translations:{label:null===(n=null===(i=this.dropinConfig.translations)||void 0===i?void 0:i.paymentResult)||void 0===n?void 0:n.fail},styles:null===(o=this.dropinConfig.styles)||void 0===o?void 0:o.authFailed,configuration:null===(s=this.dropinConfig.configuration)||void 0===s?void 0:s.authFailMsg}).mount(this.selector),null===(a=null===(r=this.dropinConfig.events)||void 0===r?void 0:r.onAuthorizeFailed)||void 0===a||a.call(r,e)}))}isStoredInstrumentEnabled(e){var t,i,n,o,s,r;switch(e){case exports.PAYMENT_METHOD_CODES.CARD:return!1!==(null===(i=null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.cards)||void 0===i?void 0:i.showStoredInstruments)&&!1!==(null===(o=null===(n=this.dropinConfig.paymentMethodsConfiguration)||void 0===n?void 0:n.cards)||void 0===o?void 0:o.showExistingCards);case exports.PAYMENT_METHOD_CODES.PAYPAL:case exports.PAYMENT_METHOD_CODES.GOOGLE_PAY:case exports.PAYMENT_METHOD_CODES.APPLE_PAY:return!1!==(null===(r=null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s[e])||void 0===r?void 0:r.showStoredInstruments);default:return!1}}applyStyles(){var e;(null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.container)&&Object.assign(this.element.style,this.dropinConfig.styles.container.styles)}fetchBinLookup(){return t(this,void 0,void 0,(function*(){var e;return null===(e=this.cardForm)||void 0===e?void 0:e.fetchBinLookup()}))}}const zn={visa:/^4\d*/,mastercard:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,amex:/^3[47]\d*/,diners:/^(36|38|30[0-5])\d*/,discover:/^(6011|65|64[4-9]|622)\d*/,jcb:/^35\d*/,hipercard:/^606282\d*/,unionpay:/^62\d*/,maestro:/^(5018|5020|5038|5043|5[6-9]|6020|6304|6703|6759|676[1-3])\d*/};class Hn{constructor(e,i){var n;this.bin="",this.isBinLookupEnabled=!1,this.id="payrails-container-wrapper",this.containerType="COMPOSABLE",this.fetchBinLookup=e=>t(this,void 0,void 0,(function*(){var t,i;const n=`${null===(i=null===(t=g().links)||void 0===t?void 0:t.binLookup)||void 0===i?void 0:i.href}`,r=g().token,a={bin:e};if(!n)return e;try{const e=yield(({url:e,token:t,body:i})=>_({url:e,method:u.POST,token:t,body:i}))({url:n,token:r,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 s.PayrailsLogger.error(i.message,{error:i}),{bin:e}}})),this.cardTableName=i.cardTableName||"cards",this.containerType=i.containerType||"COMPOSABLE",this.isBinLookupEnabled=!!(null===(n=g().links)||void 0===n?void 0:n.binLookup);try{this.__container=e.container(this.containerType,i)}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CREATION_FAILED,{cause:e});s.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 Hn(e,t),this.instance}createCollectElement(e){var t;const i={required:!!e.required,enableCardIcon:!1!==e.enableCardIcon},n=null===(t=this.__container)||void 0===t?void 0:t.create(Object.assign(Object.assign({table:this.cardTableName,labelStyles:{},errorTextStyles:{},column:this.elementToFieldMap.get(e.type)},e),{type:e.type===exports.ElementType.CARDHOLDER_NAME?"INPUT_FIELD":e.type}),e.format?Object.assign(Object.assign({},i),{format:e.format}):i);if(!n){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING,{description:"Error creating collect element!"});throw s.PayrailsLogger.error(e.message,{error:e}),e}return this.attachCustomEventHandler(n)}mount(e){if("COLLECT"===this.containerType){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw s.PayrailsLogger.error(e.message,{error:e}),e}this.element=document.createElement("span"),this.element.setAttribute("id",this.id);const t=document.querySelector(e);if(!t){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING);throw s.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);s.PayrailsLogger.error(t.message,{error:t})}}unmount(){this.element&&this.element.remove()}validate(){return t(this,void 0,void 0,(function*(){var e;return yield null===(e=this.__container)||void 0===e?void 0:e.validate()}))}collect(){return t(this,void 0,void 0,(function*(){try{return yield this.collectPayrailsData()}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_OPERATION_FAILED,{description:"Error collecting data from the iframe!",cause:e});throw s.PayrailsLogger.error(t.message,{error:t}),t}}))}collectPayrailsData(){return t(this,void 0,void 0,(function*(){var e;const t=yield null===(e=this.__container)||void 0===e?void 0:e.collect();return Object.assign(Object.assign({},t),{vaultProviderConfigId:g().vaultConfiguration.providerConfigId})}))}tokenize(e){return t(this,void 0,void 0,(function*(){const t=yield this.collect(),i=g().vaultConfiguration.links.saveInstrument.href,n=g().token;if(!i){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND,{description:"Save instrument URL not available!"});throw s.PayrailsLogger.error(e.message,{error:e}),e}const r=yield(({url:e,token:t,body:i})=>_({url:e,token:t,method:u.POST,body:i}))({url:i,token:n,body:this.constructSaveInstrumentBody(t,e)});return r.res}))}constructSaveInstrumentBody(e,t){var i,n;const o={holderReference:g().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 o.data={encryptedData:e.encryptedData,vaultProviderConfigId:e.vaultProviderConfigId},o}attachCustomEventHandler(e){return new Proxy(e,{get:(e,t)=>{if("on"!==t)return e[t];return((i,n)=>{e[t].call(e,i,(e=>{"CHANGE"===i?(e.elementType===exports.ElementType.CARD_NUMBER&&(e.network=function(e){for(const[t,i]of Object.entries(zn))if(i.test(e))return t;return""}(e.value),e.bin=this.formatBin(e.value),this.bin=this.formatBin(e.value)),n(e)):n(e)}))}).bind(e)}})}formatBin(e){return e.replace(/[-X]/g,"").slice(0,8)}get elementToFieldMap(){return new Map([[exports.ElementType.CARD_NUMBER,"card_number"],[exports.ElementType.CARDHOLDER_NAME,"cardholder_name"],[exports.ElementType.CVV,"security_code"],[exports.ElementType.EXPIRATION_MONTH,"expiry_month"],[exports.ElementType.EXPIRATION_YEAR,"expiry_year"],[exports.ElementType.EXPIRATION_DATE,"expiry_date"]])}}const Wn=(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/32d29cd/observability/index.html?${i}`,t.width="1px",t.height="1px",document.body.appendChild(t),t})(e)};
22
22
  /* @copyright
23
23
  Copyright (c) 2023 Payrails (https://www.payrails.com/)
24
24
  */
25
- class qn{static init(e,t){var i,n,r,a,l,c,d,u,_,p,E,h;try{const o="5.25.0-RC.1",I="web-sdk";Wn({version:o,packageName:I}),s.PayrailsLogger.init({enabled:(null===(i=null==t?void 0:t.telemetry)||void 0===i?void 0:i.enabled)||!0,logLevel:(null===(n=null==t?void 0:t.telemetry)||void 0===n?void 0:n.logLevel)||"error",environment:(null==t?void 0:t.environment)||"TEST",sdk:{name:I,version:o}}),N(e);const v=g();s.PayrailsLogger.setState({payrails:{execution_id:null===(r=null==v?void 0:v.execution)||void 0===r?void 0:r.id,holder_reference:null==v?void 0:v.holderReference,vault_provider:null===(a=null==v?void 0:v.vaultConfiguration)||void 0===a?void 0:a.vaultType,merchant_reference:null===(l=null==v?void 0:v.execution)||void 0===l?void 0:l.merchantReference,workflow:{code:(null===(d=null===(c=null==v?void 0:v.execution)||void 0===c?void 0:c.workflow)||void 0===d?void 0:d.code)||"",version:(null===(_=null===(u=null==v?void 0:v.execution)||void 0===u?void 0:u.workflow)||void 0===_?void 0:_.version)||0}}});const{vaultConfiguration:{vaultId:m,vaultUrl:y,token:L},execution:A}=v;null===(p=v.vaultConfiguration)||void 0===p||p.vaultId;const f=Di.init({vaultID:m,vaultURL:y,getBearerToken:()=>L?Promise.resolve(L):Promise.resolve(""),options:{initResponse:e,deserializedData:Object.assign({},v),logLevel:(null===(h=null===(E=null==t?void 0:t.telemetry)||void 0===E?void 0:E.logLevel)||void 0===h?void 0:h.toUpperCase())||"ERROR"}});return A&&(R.setResponse(A),R.isPaymentMethodAvailable(exports.PAYMENT_METHOD_CODES.CARD)&&Bi.preloadCardForm()),new qn(f,t)}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED,{cause:e});throw s.PayrailsLogger.error(t.message,{error:t}),t}}update(e){g().amount=e}collectContainer(e){var t;if("COMPOSABLE"===e.containerType&&!e.layout){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw s.PayrailsLogger.error(e.message,{error:e}),e}return this.__container=Hn.init(this.vaultClient,Object.assign(Object.assign({},e),{cardTableName:null===(t=g().vaultConfiguration)||void 0===t?void 0:t.cardTableName})),this.__container}googlePayButton(e){var t;return this.logIntegrationMode("elements"),new xn(Object.assign({environment:null===(t=this.options)||void 0===t?void 0:t.environment},e))}isGooglePayAvailable(e){var t;return xn.isGooglePayAvailable(R.googlePayConfig,null===(t=this.options)||void 0===t?void 0:t.environment,e)}applePayButton(e){return this.logIntegrationMode("elements"),new Xi(e)}isApplePayAvailable(){return Xi.isApplePayAvailable()}cardList(e){return this.logIntegrationMode("elements"),this.__cardList||(this.__cardList=new yn({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}})),this.__cardForm=new _n(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,o,s,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===(o=null===(n=e.paymentMethodsConfiguration)||void 0===n?void 0:n.cards)||void 0===o?void 0:o.showSingleExpiryDateField,null===(r=null===(s=e.paymentMethodsConfiguration)||void 0===s?void 0:s.cards)||void 0===r?void 0:r.layout);return this.__container=this.collectContainer({layout:a,errorTextStyles:{base:{display:"none"}}}),this.__dropin=new Xn(this.__container,Object.assign({},this.options||{}),e),this.__dropin}getSavedCreditCards(){return this.logIntegrationMode("elements"),R.savedCreditCards}getSavedGooglePayAccounts(){return this.logIntegrationMode("elements"),R.savedGooglePayAccounts}getSavedApplePayAccounts(){return this.logIntegrationMode("elements"),R.savedApplePayAccounts}getStoredInstruments(){return this.logIntegrationMode("elements"),R.storedPaymentInstruments}getAvailablePaymentMethods(){return this.logIntegrationMode("elements"),R.availablePaymentMethods.map((({paymentMethodCode:e})=>e)).filter((e=>!!e))}paymentButton(e){var t;return this.logIntegrationMode("elements"),this.__cardPaymentButton||(this.__cardPaymentButton=new x(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 Bn(Object.assign({},e)),this.__paypalButton}genericRedirectButton(e){return this.logIntegrationMode("elements"),this.__genericRedirectButton=new wn(e),this.__genericRedirectButton}getSavedPaypalAccounts(){return this.logIntegrationMode("elements"),R.savedPaypalAccounts||[]}logIntegrationMode(e){s.PayrailsLogger.setState({sdk:{integration_mode:e}})}constructor(e,i){var n;this.vaultClient=e,this.options=i,(null===(n=null==i?void 0:i.events)||void 0===n?void 0:n.onClientInitialized)&&i.events.onClientInitialized(R),Y.getEventBus().on("PAYRAILS_CLIENT_SESSION_EXPIRED",(()=>t(this,void 0,void 0,(function*(){var e,n,r;(null===(e=null==i?void 0:i.events)||void 0===e?void 0:e.onSessionExpired)&&(yield(r=null===(n=this.options)||void 0===n?void 0:n.events,t(void 0,void 0,void 0,(function*(){if(null==r?void 0:r.onSessionExpired)try{const e=yield r.onSessionExpired();if(e)N(e),(null==r?void 0:r.onClientInitialized)&&r.onClientInitialized(R);else{const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_SESSION_REFRESH_FAILED,{description:"Session refresh failed with no result returned"});s.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});s.PayrailsLogger.error(t.message,{error:t})}}))))}))))}getContainerLayout(e,t,i){const n=[];return i?i.forEach((e=>{n.push(e.length)})):(n.push(1),e&&n.push(1),t?n.push(2):n.push(3)),n}binLookup(){return t(this,void 0,void 0,(function*(){var e;if(!this.__dropin&&!this.__cardForm)return void console.warn("No dropin or card form found");let t;return t=this.__dropin?yield this.__dropin.fetchBinLookup():yield null===(e=this.__cardForm)||void 0===e?void 0:e.fetchBinLookup(),t}))}}var $n;qn.preloadCardForm=Bi.preloadCardForm,exports.PayrailsEnvironment=void 0,($n=exports.PayrailsEnvironment||(exports.PayrailsEnvironment={})).TEST="TEST",$n.PRODUCTION="PRODUCTION",exports.Payrails=qn}();
25
+ class qn{static init(e,t){var i,n,r,a,l,c,d,u,_,p,E,h;try{const o="5.25.0",I="web-sdk";Wn({version:o,packageName:I}),s.PayrailsLogger.init({enabled:(null===(i=null==t?void 0:t.telemetry)||void 0===i?void 0:i.enabled)||!0,logLevel:(null===(n=null==t?void 0:t.telemetry)||void 0===n?void 0:n.logLevel)||"error",environment:(null==t?void 0:t.environment)||"TEST",sdk:{name:I,version:o}}),N(e);const v=g();s.PayrailsLogger.setState({payrails:{execution_id:null===(r=null==v?void 0:v.execution)||void 0===r?void 0:r.id,holder_reference:null==v?void 0:v.holderReference,vault_provider:null===(a=null==v?void 0:v.vaultConfiguration)||void 0===a?void 0:a.vaultType,merchant_reference:null===(l=null==v?void 0:v.execution)||void 0===l?void 0:l.merchantReference,workflow:{code:(null===(d=null===(c=null==v?void 0:v.execution)||void 0===c?void 0:c.workflow)||void 0===d?void 0:d.code)||"",version:(null===(_=null===(u=null==v?void 0:v.execution)||void 0===u?void 0:u.workflow)||void 0===_?void 0:_.version)||0}}});const{vaultConfiguration:{vaultId:m,vaultUrl:y,token:L},execution:A}=v;null===(p=v.vaultConfiguration)||void 0===p||p.vaultId;const f=Di.init({vaultID:m,vaultURL:y,getBearerToken:()=>L?Promise.resolve(L):Promise.resolve(""),options:{initResponse:e,deserializedData:Object.assign({},v),logLevel:(null===(h=null===(E=null==t?void 0:t.telemetry)||void 0===E?void 0:E.logLevel)||void 0===h?void 0:h.toUpperCase())||"ERROR"}});return A&&(C.setResponse(A),C.isPaymentMethodAvailable(exports.PAYMENT_METHOD_CODES.CARD)&&Bi.preloadCardForm()),new qn(f,t)}catch(e){const t=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED,{cause:e});throw s.PayrailsLogger.error(t.message,{error:t}),t}}update(e){g().amount=e}collectContainer(e){var t;if("COMPOSABLE"===e.containerType&&!e.layout){const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw s.PayrailsLogger.error(e.message,{error:e}),e}return this.__container=Hn.init(this.vaultClient,Object.assign(Object.assign({},e),{cardTableName:null===(t=g().vaultConfiguration)||void 0===t?void 0:t.cardTableName})),this.__container}googlePayButton(e){var t;return this.logIntegrationMode("elements"),new xn(Object.assign({environment:null===(t=this.options)||void 0===t?void 0:t.environment},e))}isGooglePayAvailable(e){var t;return xn.isGooglePayAvailable(C.googlePayConfig,null===(t=this.options)||void 0===t?void 0:t.environment,e)}applePayButton(e){return this.logIntegrationMode("elements"),new Xi(e)}isApplePayAvailable(){return Xi.isApplePayAvailable()}cardList(e){return this.logIntegrationMode("elements"),this.__cardList||(this.__cardList=new yn({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}})),this.__cardForm=new _n(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,o,s,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===(o=null===(n=e.paymentMethodsConfiguration)||void 0===n?void 0:n.cards)||void 0===o?void 0:o.showSingleExpiryDateField,null===(r=null===(s=e.paymentMethodsConfiguration)||void 0===s?void 0:s.cards)||void 0===r?void 0:r.layout);return this.__container=this.collectContainer({layout:a,errorTextStyles:{base:{display:"none"}}}),this.__dropin=new Xn(this.__container,Object.assign({},this.options||{}),e),this.__dropin}getSavedCreditCards(){return this.logIntegrationMode("elements"),C.savedCreditCards}getSavedGooglePayAccounts(){return this.logIntegrationMode("elements"),C.savedGooglePayAccounts}getSavedApplePayAccounts(){return this.logIntegrationMode("elements"),C.savedApplePayAccounts}getStoredInstruments(){return this.logIntegrationMode("elements"),C.storedPaymentInstruments}getAvailablePaymentMethods(){return this.logIntegrationMode("elements"),C.availablePaymentMethods.map((({paymentMethodCode:e})=>e)).filter((e=>!!e))}paymentButton(e){var t;return this.logIntegrationMode("elements"),this.__cardPaymentButton||(this.__cardPaymentButton=new x(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 Bn(Object.assign({},e)),this.__paypalButton}genericRedirectButton(e){return this.logIntegrationMode("elements"),this.__genericRedirectButton=new wn(e),this.__genericRedirectButton}getSavedPaypalAccounts(){return this.logIntegrationMode("elements"),C.savedPaypalAccounts||[]}logIntegrationMode(e){s.PayrailsLogger.setState({sdk:{integration_mode:e}})}constructor(e,i){var n;this.vaultClient=e,this.options=i,(null===(n=null==i?void 0:i.events)||void 0===n?void 0:n.onClientInitialized)&&i.events.onClientInitialized(C),Y.getEventBus().on("PAYRAILS_CLIENT_SESSION_EXPIRED",(()=>t(this,void 0,void 0,(function*(){var e,n,r;(null===(e=null==i?void 0:i.events)||void 0===e?void 0:e.onSessionExpired)&&(yield(r=null===(n=this.options)||void 0===n?void 0:n.events,t(void 0,void 0,void 0,(function*(){if(null==r?void 0:r.onSessionExpired)try{const e=yield r.onSessionExpired();if(e)N(e),(null==r?void 0:r.onClientInitialized)&&r.onClientInitialized(C);else{const e=new o.PayrailsError(o.ERROR_CODES.PAYRAILS_CLIENT_SESSION_REFRESH_FAILED,{description:"Session refresh failed with no result returned"});s.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});s.PayrailsLogger.error(t.message,{error:t})}}))))}))))}getContainerLayout(e,t,i){const n=[];return i?i.forEach((e=>{n.push(e.length)})):(n.push(1),e&&n.push(1),t?n.push(2):n.push(3)),n}binLookup(){return t(this,void 0,void 0,(function*(){var e;if(!this.__dropin&&!this.__cardForm)return void console.warn("No dropin or card form found");let t;return t=this.__dropin?yield this.__dropin.fetchBinLookup():yield null===(e=this.__cardForm)||void 0===e?void 0:e.fetchBinLookup(),t}))}}var $n;qn.preloadCardForm=Bi.preloadCardForm,exports.PayrailsEnvironment=void 0,($n=exports.PayrailsEnvironment||(exports.PayrailsEnvironment={})).TEST="TEST",$n.PRODUCTION="PRODUCTION",exports.Payrails=qn}();