{"id":26916,"date":"2022-10-18T12:28:28","date_gmt":"2022-10-18T16:28:28","guid":{"rendered":"https:\/\/okelks.org\/?page_id=26916"},"modified":"2026-03-23T08:21:39","modified_gmt":"2026-03-23T12:21:39","slug":"auto-draft","status":"publish","type":"page","link":"https:\/\/okelks.org\/?page_id=26916","title":{"rendered":"Registration"},"content":{"rendered":"<p>[et_pb_section fb_built=&#8221;1&#8243; module_class=&#8221;wpt-divi-forms wpt-divi-forms wpt-divi-forms wpt-divi-forms wpt-divi-forms wpt-divi-forms&#8221; _builder_version=&#8221;4.18.0&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;][et_pb_row _builder_version=&#8221;4.21.0&#8243; _module_preset=&#8221;default&#8221; custom_padding=&#8221;|||30px||&#8221; global_colors_info=&#8221;{}&#8221;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.21.0&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;][de_fb_form title=&#8221;New User Registration&#8221; form_id=&#8221;New User Registration&#8221; form_type=&#8221;register&#8221; default_user_role=&#8221;subscriber&#8221; google_recaptcha=&#8221;on&#8221; recaptcha_sitekey_type=&#8221;recaptcha_3&#8243; recaptcha_sitekey_v3=&#8221;6LeD3FYmAAAAABB2E9Fqkax91RDD8ff2pEr5YKCr&#8221; recaptcha_seckey_v3=&#8221;6LeD3FYmAAAAAEpOOy7kVEUK7_F-pr2MhWsSeFDH&#8221; recaptcha_score_v3=&#8221;0.4&#8243; use_honeypot_captcha=&#8221;off&#8221; _builder_version=&#8221;4.27.0&#8243; _module_preset=&#8221;default&#8221; _unique_id=&#8221;9debf61a-33f8-4223-b668-187f86aae3d5&#8243; custom_padding=&#8221;|0px||0px||&#8221; global_colors_info=&#8221;{}&#8221;][de_fb_form_field field_title=&#8221;Username&#8221; admin_title=&#8221;Username&#8221; field_id=&#8221;Username&#8221; allowed_symbols=&#8221;letters&#8221; required_mark=&#8221;on&#8221; field_grid_column=&#8221;et_pb_column_2_3&#8243; field_label_position=&#8221;top&#8221; enable_placeholder=&#8221;off&#8221; _builder_version=&#8221;4.21.0&#8243; _module_preset=&#8221;default&#8221; form_field_custom_padding=&#8221;|||0px|false|false&#8221; global_colors_info=&#8221;{}&#8221;][\/de_fb_form_field][de_fb_form_field field_title=&#8221;First Name&#8221; admin_title=&#8221;First Name&#8221; field_id=&#8221;FirstName&#8221; allowed_symbols=&#8221;letters&#8221; required_mark=&#8221;on&#8221; required_message_position=&#8221;top&#8221; field_grid_column=&#8221;et_pb_column_2_3&#8243; field_label_position=&#8221;top&#8221; enable_placeholder=&#8221;off&#8221; enable_autocomplete=&#8221;off&#8221; _builder_version=&#8221;4.21.0&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;][\/de_fb_form_field][de_fb_form_field field_title=&#8221;Last Name&#8221; admin_title=&#8221;Last Name&#8221; field_id=&#8221;LastName&#8221; add_field_prefix=&#8221;off&#8221; allowed_symbols=&#8221;letters&#8221; required_mark=&#8221;on&#8221; field_grid_column=&#8221;et_pb_column_2_3&#8243; field_label_position=&#8221;top&#8221; enable_placeholder=&#8221;off&#8221; enable_autocomplete=&#8221;off&#8221; _builder_version=&#8221;4.21.0&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;][\/de_fb_form_field][de_fb_form_field field_title=&#8221;Email&#8221; admin_title=&#8221;Email&#8221; field_id=&#8221;Email&#8221; field_type=&#8221;email&#8221; add_field_prefix=&#8221;off&#8221; required_mark=&#8221;on&#8221; field_grid_column=&#8221;et_pb_column_2_3&#8243; field_label_position=&#8221;top&#8221; enable_autocomplete=&#8221;off&#8221; _builder_version=&#8221;4.21.0&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;][\/de_fb_form_field][de_fb_form_field field_title=&#8221;Confirm Email&#8221; admin_title=&#8221;Confirm Email&#8221; field_id=&#8221;ConfirmEmail&#8221; field_type=&#8221;email&#8221; add_field_prefix=&#8221;off&#8221; required_mark=&#8221;on&#8221; field_grid_column=&#8221;et_pb_column_2_3&#8243; field_label_position=&#8221;top&#8221; enable_placeholder=&#8221;off&#8221; enable_autocomplete=&#8221;off&#8221; _builder_version=&#8221;4.21.0&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;][\/de_fb_form_field][de_fb_form_field field_title=&#8221;Password&#8221; admin_title=&#8221;Password&#8221; field_id=&#8221;Password&#8221; field_type=&#8221;password&#8221; add_field_prefix=&#8221;off&#8221; min_length=&#8221;6&#8243; max_length=&#8221;12&#8243; required_mark=&#8221;on&#8221; field_grid_column=&#8221;et_pb_column_2_3&#8243; field_label_position=&#8221;top&#8221; enable_placeholder=&#8221;off&#8221; enable_autocomplete=&#8221;off&#8221; _builder_version=&#8221;4.21.0&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;][\/de_fb_form_field][de_fb_form_field field_title=&#8221;Confirm Password&#8221; admin_title=&#8221;Confirm Password&#8221; field_id=&#8221;ConfirmPassword&#8221; field_type=&#8221;password&#8221; add_field_prefix=&#8221;off&#8221; min_length=&#8221;6&#8243; max_length=&#8221;12&#8243; required_mark=&#8221;on&#8221; field_grid_column=&#8221;et_pb_column_2_3&#8243; field_label_position=&#8221;top&#8221; enable_placeholder=&#8221;off&#8221; enable_autocomplete=&#8221;off&#8221; _builder_version=&#8221;4.21.0&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;][\/de_fb_form_field][de_fb_form_field field_title=&#8221;Lodge Number&#8221; admin_title=&#8221;Lodge Number&#8221; field_id=&#8221;LodgeNumber&#8221; add_field_prefix=&#8221;off&#8221; min_length=&#8221;4&#8243; max_length=&#8221;4&#8243; allowed_symbols=&#8221;numbers&#8221; required_mark=&#8221;on&#8221; field_grid_column=&#8221;et_pb_column_1_2&#8243; field_label_position=&#8221;top&#8221; enable_placeholder=&#8221;off&#8221; enable_autocomplete=&#8221;off&#8221; _builder_version=&#8221;4.21.0&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;][\/de_fb_form_field][de_fb_form_field field_title=&#8221;Lodge Name&#8221; admin_title=&#8221;Lodge Name&#8221; field_id=&#8221;LodgeName&#8221; required_mark=&#8221;on&#8221; field_grid_column=&#8221;et_pb_column_2_3&#8243; field_label_position=&#8221;top&#8221; _builder_version=&#8221;4.27.0&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;][\/de_fb_form_field][\/de_fb_form][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p><div class=\"et_pb_module de_fb_form de_fb_form_0 clearfix  align-button_right align-module_left\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_module_inner\">\n\t\t\t\t\t\t<form method=\"POST\" enctype=\"multipart\/form-data\" action=\"\" id=\"fb_form_null-0\" class=\"et_pb_contact fb_form   hide_until_loaded hide_until_loaded \"  aria-label=\"New User Registration\" data-ajax-btn=\"Processing\" data-ajax-hide-sub=\"off\" data-reset-form-on-submit=\"false\" data-scrollto-form-after-submit=\"off\" data-scrollto-form-offset=\"0\" data-form-key=\"null-0\" data-form-id=\"New User Registration\" data-form-type=\"register\" data-unique-id=\"9debf61a-33f8-4223-b668-187f86aae3d5\" data-page-id=\"\" style=\"display: none;\"><h2 class=\"form-title\">New User Registration<\/h2><div class=\"divi-form-wrapper\"><input class=\"df_hidden_user_role\" type=\"hidden\" name=\"role\" value=\"subscriber\"><\/div><input type=\"hidden\" value=\"null-0\" name=\"form_key\"><input type=\"hidden\" value=\"9debf61a-33f8-4223-b668-187f86aae3d5\" name=\"unique_id\"><input type=\"hidden\" value=\"off\" name=\"enable_payment\"><input type=\"hidden\" value=\"\" name=\"dfb_page_id\"><input type=\"hidden\" name=\"fb_nonce\" class=\"fb_nonce\" value=\"e933171a98\"><input type=\"hidden\" name=\"is_user_edit\" value=\"off\"><input type=\"hidden\" name=\"default_user_role\" value=\"subscriber\"><div class=\"et_contact_bottom_container\"><div class=\"submit-container\"><script src=\"https:\/\/www.google.com\/recaptcha\/api.js?render=6LeD3FYmAAAAABB2E9Fqkax91RDD8ff2pEr5YKCr\" id=\"fb-recaptcha-v3-null-0\"><\/script><input type=\"hidden\" name=\"recaptcha_v3_token\" class=\"recaptcha-v3-token\"><div class=\"de_fb_submit_container\"><div class=\"divi-form-submit-container\"><button class=\"divi-form-submit et_pb_button\" type=\"submit\" aria-label=\"Submit\">Submit<\/button><\/div><input type=\"hidden\" name=\"form_type\" value=\"register\"><input type=\"hidden\" name=\"divi-form-submit\" value=\"yes\"><input type=\"hidden\" name=\"form_id\" value=\"New User Registration\"><input type=\"hidden\" name=\"form_display_type\" value=\"\"><\/div><\/div><script>\n\/\/ Stripe payment flows:\n\/\/ - Divi 4 uses the legacy token\/charge flow (v2 behavior)\n\/\/ - Divi 5 uses PaymentIntents \/ Payment Element (v3 behavior)\nwindow.dfbIsDivi5 = false;\n\/\/ Ensure checkbox\/radio options are focusable (Tab + Space) when CSS is overridden by other stylesheets.\n(function() {\n    function dfbEnsureCheckboxRadioFocusable() {\n        var lists = document.querySelectorAll('.et_pb_contact_field_options_list');\n        lists.forEach(function(list) {\n            var inputs = list.querySelectorAll('input[type=\"checkbox\"], input[type=\"radio\"]');\n            inputs.forEach(function(inp, index) {\n                if (inp.getAttribute('tabindex') === '-1') { inp.removeAttribute('tabindex'); }\n                inp.setAttribute('tabindex', '0');\n                var parent = inp.closest('.et_pb_contact_field_checkbox, .et_pb_contact_field_radio');\n                if (parent) {\n                    if (getComputedStyle(parent).position === 'static') {\n                        parent.style.setProperty('position', 'relative', 'important');\n                    }\n                    parent.style.setProperty('overflow', 'visible', 'important');\n                }\n                inp.style.setProperty('position', 'absolute', 'important');\n                inp.style.setProperty('left', '0', 'important');\n                inp.style.setProperty('top', '0', 'important');\n                inp.style.setProperty('width', '100%', 'important');\n                inp.style.setProperty('height', '100%', 'important');\n                inp.style.setProperty('opacity', '0', 'important');\n                inp.style.setProperty('margin', '0', 'important');\n                inp.style.setProperty('pointer-events', 'auto', 'important');\n                inp.style.setProperty('display', 'block', 'important');\n                inp.style.setProperty('z-index', String(index + 1), 'important');\n            });\n        });\n    }\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', dfbEnsureCheckboxRadioFocusable);\n    } else {\n        dfbEnsureCheckboxRadioFocusable();\n    }\n})();\n\/\/ Ensure text inputs (e.g. name field), textareas, and selects are in tab order if they had tabindex=\"-1\".\n(function() {\n    function dfbEnsureInputsFocusable() {\n        var form = document.querySelector('.de_fb_form form, .divi-form-wrapper form');\n        if (!form) { return; }\n        var focusables = form.querySelectorAll('input:not([type=\"hidden\"]):not([type=\"checkbox\"]):not([type=\"radio\"]), textarea, select');\n        focusables.forEach(function(el) {\n            if (el.getAttribute('tabindex') === '-1') {\n                el.removeAttribute('tabindex');\n                el.setAttribute('tabindex', '0');\n            }\n        });\n    }\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', dfbEnsureInputsFocusable);\n    } else {\n        dfbEnsureInputsFocusable();\n    }\n})();\n\/\/ Phase 4: Make fetchPaymentIntentAndInit globally accessible immediately\n\/\/ Define it FIRST, before any other code, so it's available as soon as script tag is parsed\nvar fetchPaymentIntentAndInitFn = null;\nvar fetchPaymentIntentAndInitReady = false;\n\n\/\/ Create global function that can be called immediately\n\/\/ This ensures it exists even if called before jQuery is ready or before this script finishes loading\nwindow.fetchPaymentIntentAndInit = function() {\n\n    if (fetchPaymentIntentAndInitReady) {\n        if (fetchPaymentIntentAndInitFn) {\n            \/\/ Function is ready, call it immediately\n\n            fetchPaymentIntentAndInitFn();\n        }\n    } else if (typeof jQuery !== 'undefined') {\n        \/\/ jQuery exists but function not ready yet, wait for it\n\n        jQuery(document).ready(function($) {\n            if (fetchPaymentIntentAndInitFn) {\n\n                fetchPaymentIntentAndInitFn();\n            } else {\n\n            }\n        });\n    } else {\n        \/\/ jQuery not loaded yet, wait for it\n\n        if (typeof window.addEventListener !== 'undefined') {\n            window.addEventListener('DOMContentLoaded', function() {\n                if (typeof jQuery !== 'undefined') {\n                    jQuery(document).ready(function($) {\n                        if (fetchPaymentIntentAndInitFn) {\n\n                            fetchPaymentIntentAndInitFn();\n                        } else {\n\n                        }\n                    });\n                } else {\n                    console.error('jQuery still not available after DOMContentLoaded');\n                }\n            });\n        }\n    }\n};\n\njQuery(document).ready(function($){\n    \/\/ Phase 4: Fetch PaymentIntent before form render (for Payment Element support)\n    function fetchPaymentIntentAndInit() {\n        \/\/ Divi 4 must stay on legacy Stripe flow (no PaymentIntent prefetch \/ Payment Element).\n        if (!window.dfbIsDivi5) {\n            window.fetchPaymentIntentAndInitExecuting = false;\n            window.fetchPaymentIntentAndInitCompleted = true;\n            waitForStripeAndInit();\n            return;\n        }\n\n        \/\/ Mark as executing\n        window.fetchPaymentIntentAndInitExecuting = true;\n\n        \/\/ Handle Stripe redirect return URLs (Klarna, Amazon Pay, etc.).\n        \/\/ If Stripe redirected back with setup_intent\/payment_intent client secret, finalize and submit.\n        try {\n            const params = new URLSearchParams(window.location.search || '');\n            const paypalCancel = params.get('paypal_cancel');\n            const paypalToken = params.get('token');\n            const returnToken = params.get('dfb_stripe_return');\n            const redirectStatus = params.get('redirect_status');\n            const setupClientSecret = params.get('setup_intent_client_secret');\n            const paymentClientSecret = params.get('payment_intent_client_secret');\n\n            if (paypalCancel === '1') {\n                const processedKey = 'dfb_paypal_cancel_' + (paypalToken || '1');\n                if (!sessionStorage.getItem(processedKey)) {\n                    sessionStorage.setItem(processedKey, '1');\n\n                    const form = $('.de_fb_gateway_paypal_form').first().length ? $('.de_fb_gateway_paypal_form').first() : $('form').first();\n\n                    try {\n                        const cleanUrl = window.location.origin + window.location.pathname + (window.location.hash || '');\n                        window.history.replaceState({}, document.title, cleanUrl);\n                    } catch (e) {}\n\n                    try {\n                        const msg = 'Payment was cancelled. Please try again.';\n                        const cardErrors = form.find('.card-errors').first();\n                        const paymentErrors = form.find(\".payment-errors\").first();\n                        if (cardErrors.length) {\n                            cardErrors.text(msg);\n                            if (paymentErrors.length) {\n                                paymentErrors.html('');\n                            }\n                        } else if (paymentErrors.length) {\n                            paymentErrors.html(msg);\n                        }\n                        form.find('.divi-form-submit').prop('disabled', false);\n                    } catch (e) {}\n                }\n                return;\n            }\n\n            if ((redirectStatus === 'failed' || redirectStatus === 'canceled') && (setupClientSecret || paymentClientSecret)) {\n                const storedMsgKey = setupClientSecret ? ('dfb_stripe_redirect_fail_msg_seti_' + setupClientSecret) : ('dfb_stripe_redirect_fail_msg_pi_' + paymentClientSecret);\n\n                const form = $('.de_fb_gateway_stripe_form').first();\n                const cardWrap = form.find('.card-wrap').first();\n                const stripeKey = cardWrap.data('publishable-key') || cardWrap.data('publishableKey') || cardWrap.attr('data-publishable-key');\n\n                const showError = (msg) => {\n                    try {\n                        const cardErrors = form.find('.card-errors').first();\n                        const paymentErrors = form.find(\".payment-errors\").first();\n\n                        if (cardErrors.length) {\n                            cardErrors.text(msg);\n                            if (paymentErrors.length) {\n                                paymentErrors.html('');\n                            }\n                        } else if (paymentErrors.length) {\n                            paymentErrors.html(msg);\n                        }\n\n                        form.find('.divi-form-submit').prop('disabled', false);\n                    } catch (e) {}\n                };\n\n                try {\n                    const cleanUrl = window.location.origin + window.location.pathname + (window.location.hash || '');\n                    window.history.replaceState({}, document.title, cleanUrl);\n                } catch (e) {}\n\n                try {\n                    const storedMsg = sessionStorage.getItem(storedMsgKey);\n                    if (storedMsg) {\n                        showError(storedMsg);\n                        return;\n                    }\n                } catch (e) {}\n\n                if (form.length && stripeKey) {\n                    const stripe = Stripe(stripeKey);\n                    if (paymentClientSecret) {\n                        stripe.retrievePaymentIntent(paymentClientSecret).then(function(result) {\n                            const msg = (result && result.paymentIntent && result.paymentIntent.last_payment_error && result.paymentIntent.last_payment_error.message)\n                                ? result.paymentIntent.last_payment_error.message\n                                : 'Payment was not completed. Please try again.';\n                            try { sessionStorage.setItem(storedMsgKey, msg); } catch (e) {}\n                            showError(msg);\n\n                            try {\n                                const cardElementContainer = form.find('.card-element').first();\n                                if (cardElementContainer.length && result && result.paymentIntent && result.paymentIntent.id) {\n                                    cardElementContainer.data('dfb-stripe-sticky-error', msg);\n                                    cardElementContainer.data('client-secret', paymentClientSecret);\n                                    cardElementContainer.data('payment-intent-id', result.paymentIntent.id);\n                                    cardElementContainer.data('payment-intent-fetched', true);\n                                    cardElementContainer.removeData('stripe-mounted');\n                                    form.find('input[name=\"payment_intent_id\"]').remove();\n                                    form.append(\"<input type='hidden' name='payment_intent_id' value='\" + result.paymentIntent.id + \"'\/>\");\n                                }\n                                if (typeof waitForStripeAndInit === 'function') {\n                                    waitForStripeAndInit();\n                                }\n                            } catch (e) {}\n                        });\n                        return;\n                    }\n                    if (setupClientSecret) {\n                        stripe.retrieveSetupIntent(setupClientSecret).then(function(result) {\n                            const msg = (result && result.setupIntent && result.setupIntent.last_setup_error && result.setupIntent.last_setup_error.message)\n                                ? result.setupIntent.last_setup_error.message\n                                : 'Payment was not completed. Please try again.';\n                            try { sessionStorage.setItem(storedMsgKey, msg); } catch (e) {}\n                            showError(msg);\n                        });\n                        return;\n                    }\n                } else {\n                    const fallbackMsg = 'Payment was not completed. Please try again.';\n                    try { sessionStorage.setItem(storedMsgKey, fallbackMsg); } catch (e) {}\n                    showError(fallbackMsg);\n                    return;\n                }\n            }\n\n            if (returnToken) {\n                const processedKey = 'dfb_stripe_return_' + returnToken;\n                if (!sessionStorage.getItem(processedKey)) {\n                    sessionStorage.setItem(processedKey, '1');\n                    const form = $('.de_fb_gateway_stripe_form').first();\n                    if (form.length) {\n                        form.find('input[name=\"dfb_stripe_return\"]').remove();\n                        form.append(\"<input type='hidden' name='dfb_stripe_return' value='\" + returnToken + \"'\/>\");\n                        \/\/ Ensure server processes Stripe on return (default gateway can be PayPal).\n                        try {\n                            form.find('input[name=\"de_fb_payment_action\"]').val('stripe');\n                        } catch (e) {}\n                        try {\n                            const cleanUrl = window.location.origin + window.location.pathname + (window.location.hash || '');\n                            window.history.replaceState({}, document.title, cleanUrl);\n                        } catch (e) {}\n\n                        if (form.find('.divi-form-submit').hasClass('de_fb_ajax_submit')) {\n                            de_fb_ajax_form_submit(form[0]);\n                        } else {\n                            form.find('.fb_nonce').remove();\n                            form.append('<input type=\"hidden\" name=\"fb_nonce\" class=\"fb_nonce\" value=\"e933171a98\">');\n                            form.unbind('submit').submit();\n                        }\n                        return;\n                    }\n                }\n            }\n\n            if (redirectStatus === 'succeeded' && (setupClientSecret || paymentClientSecret)) {\n                const processedKey = setupClientSecret ? ('dfb_stripe_redirect_seti_' + setupClientSecret) : ('dfb_stripe_redirect_pi_' + paymentClientSecret);\n                if (!sessionStorage.getItem(processedKey)) {\n                    sessionStorage.setItem(processedKey, '1');\n\n                    const form = $('.de_fb_gateway_stripe_form').first();\n                    const cardWrap = form.find('.card-wrap').first();\n                    const cardElementContainer = form.find('.card-element').first();\n                    const stripeKey = cardWrap.data('publishable-key') || cardWrap.data('publishableKey') || cardWrap.attr('data-publishable-key');\n\n                    if (form.length && stripeKey) {\n                        const stripe = Stripe(stripeKey);\n\n                        const submitForm = () => {\n                            \/\/ Mark as completed so normal init doesn't run again.\n                            window.fetchPaymentIntentAndInitExecuting = false;\n                            window.fetchPaymentIntentAndInitCompleted = true;\n\n                            \/\/ Clean URL so params don't stick around.\n                            try {\n                                const cleanUrl = window.location.origin + window.location.pathname + (window.location.hash || '');\n                                window.history.replaceState({}, document.title, cleanUrl);\n                            } catch (e) {}\n\n                            if (form.find('.divi-form-submit').hasClass('de_fb_ajax_submit')) {\n                                de_fb_ajax_form_submit(form[0]);\n                            } else {\n                                form.find('.fb_nonce').remove();\n                                form.append('<input type=\"hidden\" name=\"fb_nonce\" class=\"fb_nonce\" value=\"e933171a98\">');\n                                form.unbind('submit').submit();\n                            }\n                        };\n\n                        if (setupClientSecret) {\n                            stripe.retrieveSetupIntent(setupClientSecret).then(function(result) {\n                                if (result && result.setupIntent && result.setupIntent.payment_method) {\n                                    form.find('input[name=\"stripe_payment_method\"]').remove();\n                                    form.append(\"<input type='hidden' name='stripe_payment_method' value='\" + result.setupIntent.payment_method + \"'\/>\");\n                                    if (cardElementContainer.length) {\n                                        cardElementContainer.data('is-setup-intent', true);\n                                    }\n                                    submitForm();\n                                }\n                            });\n                            return;\n                        }\n\n                        if (paymentClientSecret) {\n                            stripe.retrievePaymentIntent(paymentClientSecret).then(function(result) {\n                                if (result && result.paymentIntent && result.paymentIntent.id) {\n                                    form.find('input[name=\"payment_intent_id\"]').remove();\n                                    form.append(\"<input type='hidden' name='payment_intent_id' value='\" + result.paymentIntent.id + \"'\/>\");\n                                    \/\/ Ensure Stripe is the selected gateway on return.\n                                    try { form.find('input[name=\\\"de_fb_payment_action\\\"]').val('stripe'); } catch (e) {}\n                                    \/\/ Best-effort: hydrate amount for client-side validation (server uses Stripe amount anyway).\n                                    try {\n                                        if (result.paymentIntent.amount) {\n                                            let amt = (parseFloat(result.paymentIntent.amount) || 0) \/ 100;\n                                            if (amt > 0) {\n                                                let paymentField = form.find('input[name=\\\"de_fb_payment_amount\\\"]').first();\n                                                if (paymentField.length) {\n                                                    paymentField.val(amt.toFixed(2)).trigger('input').trigger('change');\n                                                }\n                                            }\n                                        }\n                                    } catch (e) {}\n                                    \/\/ Clear cached PI\/token for next checkout after redirect completion.\n                                    try {\n                                        if (typeof sessionStorage !== 'undefined') {\n                                            let storageFormId = '';\n                                            try {\n                                                storageFormId = form.attr('id') || '';\n                                                if (typeof storageFormId === 'string') {\n                                                    if (storageFormId.indexOf('fb_form_') === 0) {\n                                                        storageFormId = storageFormId.replace('fb_form_', '');\n                                                    }\n                                                }\n                                            } catch (e) {}\n                                            if (storageFormId) {\n                                                sessionStorage.removeItem('dfb_stripe_pi_' + storageFormId);\n                                                sessionStorage.removeItem('dfb_stripe_pi_token_' + storageFormId);\n                                            }\n                                        }\n                                    } catch (e) {}\n                                    submitForm();\n                                }\n                            });\n                            return;\n                        }\n                    }\n                }\n            }\n        } catch (e) {}\n\n        \/\/ Check if we have any Stripe forms with card elements\n        if ($('.de_fb_gateway_stripe_form .card-element').length === 0) {\n            \/\/ No Stripe forms, proceed directly to initialization\n\n            window.fetchPaymentIntentAndInitExecuting = false;\n            window.fetchPaymentIntentAndInitCompleted = true;\n            waitForStripeAndInit();\n            return;\n        }\n        \n        \/\/ Process each Stripe form\n        let formsProcessed = 0;\n        let totalForms = $('.de_fb_gateway_stripe_form').length;\n\n        $('.de_fb_gateway_stripe_form').each(function() {\n            let form = $(this);\n            let cardElementContainer = form.find('.card-element');\n            \n            if (!cardElementContainer.length) {\n                formsProcessed++;\n                if (formsProcessed >= totalForms) {\n                    \/\/ All forms processed, proceed to initialization\n                    window.fetchPaymentIntentAndInitExecuting = false;\n                    window.fetchPaymentIntentAndInitCompleted = true;\n                    waitForStripeAndInit();\n                }\n                return true; \/\/ Continue to next form\n            }\n            \n            \/\/ Check if already processed or currently being fetched - check both flags and ID\n            \/\/ Try multiple keys - jQuery converts kebab-case to camelCase\n            let existingPaymentIntentId = cardElementContainer.data('payment-intent-id') || \n                                          cardElementContainer.data('paymentIntentId') ||\n                                          cardElementContainer.data('paymentIntent-id');\n            let paymentIntentFetched = cardElementContainer.data('payment-intent-fetched') ||\n                                       cardElementContainer.data('paymentIntentFetched');\n            \n            \/\/ If the UI shows $0.00, do not keep\/reuse any existing PI id from a previous checkout.\n            try {\n                let visibleAmt = 0;\n                let hasVisibleAmt = false;\n                try {\n                    let priceEl = form.find('#custom_price_wrapper .price').first();\n                    if (!priceEl.length) { priceEl = form.find('.plan-price .price').first(); }\n                    if (priceEl.length) {\n                        visibleAmt = parseFloat((String(priceEl.text() || '')).replace(\/,\/g, '')) || 0;\n                        hasVisibleAmt = true;\n                    }\n                } catch (e) { visibleAmt = 0; hasVisibleAmt = false; }\n                if (hasVisibleAmt && visibleAmt <= 0) {\n                    existingPaymentIntentId = '';\n                    paymentIntentFetched = false;\n                    try { cardElementContainer.removeData('payment-intent-id'); } catch (e) {}\n                    try { cardElementContainer.removeData('paymentIntentId'); } catch (e) {}\n                    try { cardElementContainer.removeData('paymentIntent-id'); } catch (e) {}\n                    try { form.removeData('payment-intent-id'); } catch (e) {}\n                    try { form.find('input[name=\"payment_intent_id\"]').remove(); } catch (e) {}\n                    try {\n                        if (typeof sessionStorage !== 'undefined') {\n                            let storageFormId = '';\n                            try {\n                                storageFormId = form.attr('id') || '';\n                                if (typeof storageFormId === 'string') {\n                                    if (storageFormId.indexOf('fb_form_') === 0) {\n                                        storageFormId = storageFormId.replace('fb_form_', '');\n                                    }\n                                }\n                            } catch (e) {}\n                            if (!storageFormId) {\n                                try { storageFormId = form.find('input[name=\"form_key\"]').val() || ''; } catch (e) {}\n                            }\n                            if (storageFormId) {\n                                try { sessionStorage.removeItem('dfb_stripe_pi_' + storageFormId); } catch (e) {}\n                                try { sessionStorage.removeItem('dfb_stripe_pi_token_' + storageFormId); } catch (e) {}\n                                try { sessionStorage.removeItem('dfb_stripe_pi_amt_' + storageFormId); } catch (e) {}\n                            }\n                        }\n                    } catch (e) {}\n                }\n            } catch (e) {}\n            \n            \/\/ If the previous submit just succeeded, skip auto-creating a new PaymentIntent on page init.\n            \/\/ This avoids extra \"Incomplete\" Stripe entries created by post-submit field resets.\n            try {\n                if (typeof sessionStorage !== 'undefined') {\n                    let storageFormId = '';\n                    try {\n                        storageFormId = form.attr('id') || '';\n                        if (typeof storageFormId === 'string') {\n                            if (storageFormId.indexOf('fb_form_') === 0) {\n                                storageFormId = storageFormId.replace('fb_form_', '');\n                            }\n                        }\n                    } catch (e) {}\n                    if (!storageFormId) {\n                        try { storageFormId = form.find('input[name=\"form_key\"]').val() || ''; } catch (e) {}\n                    }\n                    if (storageFormId) {\n                        let ts = sessionStorage.getItem('dfb_stripe_skip_init_' + storageFormId) || '';\n                        let t = 0;\n                        try { t = parseInt(ts, 10) || 0; } catch (e) { t = 0; }\n                        if (t) {\n                            if ((Date.now() - t) < 60000) {\n                                \/\/ Only skip if this form already has a client_secret (same-page re-render).\n                                \/\/ On full page reload the DOM is fresh and has no client_secret; we must create a new PI and mount.\n                                let hasClientSecret = !!(cardElementContainer.data('client-secret') || (form.find('input[name=\"payment_intent_client_secret\"]').val()));\n                                if (hasClientSecret) {\n                                    cardElementContainer.data('payment-intent-fetched', true);\n                                    paymentIntentFetched = true;\n                                } else {\n                                    try { sessionStorage.removeItem('dfb_stripe_skip_init_' + storageFormId); } catch (e) {}\n                                }\n                            } else {\n                                try { sessionStorage.removeItem('dfb_stripe_skip_init_' + storageFormId); } catch (e) {}\n                            }\n                        }\n                    }\n                }\n            } catch (e) {}\n\n            if (existingPaymentIntentId || paymentIntentFetched) {\n\n                formsProcessed++;\n                if (formsProcessed >= totalForms) {\n                    \/\/ All forms processed (already had an intent), proceed to initialization.\n                    window.fetchPaymentIntentAndInitExecuting = false;\n                    window.fetchPaymentIntentAndInitCompleted = true;\n                    waitForStripeAndInit();\n                }\n                return true; \/\/ DO NOT create duplicate\n            }\n            \n            \/\/ Check if currently being fetched (prevent duplicate requests)\n            if (cardElementContainer.data('payment-intent-fetching')) {\n                \/\/ Wait for the existing fetch to complete\n                let checkInterval = setInterval(function() {\n                    if (cardElementContainer.data('payment-intent-fetched')) {\n                        clearInterval(checkInterval);\n                        formsProcessed++;\n                        if (formsProcessed >= totalForms) {\n                            \/\/ All forms processed (wait completed), proceed to initialization.\n                            window.fetchPaymentIntentAndInitExecuting = false;\n                            window.fetchPaymentIntentAndInitCompleted = true;\n                            waitForStripeAndInit();\n                        }\n                    }\n                }, 100);\n                return true;\n            }\n            \n            \/\/ Mark as fetching BEFORE making AJAX call (prevents duplicate requests)\n            cardElementContainer.data('payment-intent-fetching', true);\n            \n            \/\/ Get form data\n            let formId = form.data('form-id') || form.attr('id');\n            \/\/ Try to get amount and currency from card-wrap data attributes (Phase 7)\n            let cardWrap = form.find('.card-wrap');\n            if (!cardWrap.length) {\n                cardWrap = $('.card-wrap').first();\n            }\n            let amount = 0;\n            let forceZeroFromCustomPrice = false;\n            let amountInput = form.find('input[name=\"de_fb_payment_amount\"]');\n            if (amountInput.length) {\n                amount = parseFloat(amountInput.val()) || 0;\n            }\n            \/\/ For custom-price forms only, do not create a PaymentIntent until the user actually enters values.\n            \/\/ Fixed and calculated price have a known amount on load; only \"custom\" (user-entered) should wait.\n            try {\n                let priceTypeEl = form.find('.fb_payment_price_cont').first();\n                let priceType = priceTypeEl.length ? (priceTypeEl.data('price-type') || '') : '';\n                if (form.find('.de_fb_form_field_custom_price').length && priceType === 'custom') {\n                    let hasUserValue = false;\n                    try {\n                        form.find('input[name^=\"de_fb_\"]').each(function() {\n                            try {\n                                let n = String(jQuery(this).attr('name') || '');\n                                if (n === 'de_fb_payment_amount') { return; }\n                                let v = String(jQuery(this).val() || '').trim();\n                                if (v !== '') { hasUserValue = true; }\n                            } catch (e) {}\n                        });\n                        if (!hasUserValue && form.find('input[name=\"custom_price\"]').length) {\n                            let cv = String(form.find('input[name=\"custom_price\"]').first().val() || '').trim();\n                            if (cv !== '') { hasUserValue = true; }\n                        }\n                    } catch (e) {}\n                    if (!hasUserValue) {\n                        amount = 0;\n                        forceZeroFromCustomPrice = true;\n                    }\n                }\n            } catch (e) {}\n            \/\/ For fixed price, trust the hidden input only (visible .price contains currency symbol, parse would fail).\n            try {\n                if (priceType !== 'fixed') {\n                    let visibleAmt = 0;\n                    let hasVisibleAmt = false;\n                    try {\n                        let priceEl = form.find('#custom_price_wrapper .price').first();\n                        if (!priceEl.length) {\n                            priceEl = form.find('.plan-price .price').first();\n                        }\n                        if (priceEl.length) {\n                            visibleAmt = parseFloat((String(priceEl.text() || '')).replace(\/,\/g, '').replace(\/[^\\d.-]\/g, '')) || 0;\n                            hasVisibleAmt = true;\n                        }\n                    } catch (e) { visibleAmt = 0; hasVisibleAmt = false; }\n                    if (hasVisibleAmt) {\n                        if (visibleAmt <= 0) {\n                            amount = 0;\n                            forceZeroFromCustomPrice = true;\n                        } else {\n                            amount = visibleAmt;\n                        }\n                    } else {\n                        if (form.find('#custom_price_wrapper').length || form.find('.plan-price .price').length) {\n                            if (amount <= 0) {\n                                amount = 0;\n                                forceZeroFromCustomPrice = true;\n                            }\n                        }\n                    }\n                }\n            } catch (e) {}\n            if (amount <= 0) {\n                if (!forceZeroFromCustomPrice) {\n                    amount = cardWrap.length ? parseFloat(cardWrap.data('payment-amount')) || 0 : 0;\n                }\n            }\n            let currency = cardWrap.length ? (cardWrap.data('payment-currency') || 'usd') : 'usd';\n            let paymentMethodMode = cardWrap.length ? (cardWrap.data('stripe-payment-method-mode') || 'simple') : 'simple';\n            \n            \/\/ PaymentIntent-only flow:\n            \/\/ - Simple mode with 0 amount: skip, will use Card Element\n            \/\/ - Advanced mode with 0 amount: skip for now (we'll create PaymentIntent later once amount is known)\n            if (!formId) {\n                cardElementContainer.data('payment-intent-fetched', true);\n                formsProcessed++;\n                if (formsProcessed >= totalForms) {\n                    waitForStripeAndInit();\n                }\n                return true;\n            }\n            \n            \/\/ Simple mode with 0 amount: skip, will use Card Element\n            if (paymentMethodMode === 'simple') {\n                if (amount <= 0) {\n                    cardElementContainer.data('payment-intent-fetched', true);\n                    formsProcessed++;\n                    if (formsProcessed >= totalForms) {\n                        waitForStripeAndInit();\n                    }\n                    return true;\n                }\n            }\n\n            \/\/ Advanced mode with 0 amount: do not create PaymentIntent yet.\n            if (paymentMethodMode === 'advanced') {\n                if (amount <= 0) {\n                try {\n                    cardElementContainer.removeData('payment-intent-id');\n                    cardElementContainer.removeData('paymentIntentId');\n                    cardElementContainer.removeData('paymentIntent-id');\n                    form.removeData('payment-intent-id');\n                    form.find('input[name=\"payment_intent_id\"]').remove();\n                } catch (e) {}\n                try {\n                    if (typeof sessionStorage !== 'undefined') {\n                        let storageFormId = '';\n                        try {\n                            storageFormId = form.attr('id') || '';\n                            if (typeof storageFormId === 'string') {\n                                if (storageFormId.indexOf('fb_form_') === 0) {\n                                    storageFormId = storageFormId.replace('fb_form_', '');\n                                }\n                            }\n                        } catch (e) {}\n                        if (!storageFormId) {\n                            try { storageFormId = form.find('input[name=\"form_key\"]').val() || ''; } catch (e) {}\n                        }\n                        if (storageFormId) {\n                            try { sessionStorage.removeItem('dfb_stripe_pi_' + storageFormId); } catch (e) {}\n                            try { sessionStorage.removeItem('dfb_stripe_pi_token_' + storageFormId); } catch (e) {}\n                            try { sessionStorage.removeItem('dfb_stripe_pi_amt_' + storageFormId); } catch (e) {}\n                        }\n                    }\n                } catch (e) {}\n                cardElementContainer.data('payment-intent-fetching', false);\n                formsProcessed++;\n                if (formsProcessed >= totalForms) {\n                    waitForStripeAndInit();\n                }\n                return true;\n                }\n            }\n            \n            \/\/ Extract form ID number if it's in format \"fb_form_123\"\n            if (typeof formId === 'string' && formId.indexOf('fb_form_') === 0) {\n                formId = formId.replace('fb_form_', '');\n            }\n            \n            \/\/ PaymentIntent-only: always create a PaymentIntent when amount > 0.\n            let ajaxAction = 'de_fb_create_stripe_payment_intent';\n            \n            \/\/ Get AJAX URL and nonce from de_fb_obj or fallback to PHP values\n            let ajaxUrl = \"https:\\\/\\\/okelks.org\\\/wp-admin\\\/admin-ajax.php\";\n            let fbNonce = \"e933171a98\";\n            if (typeof de_fb_obj !== 'undefined') {\n                if (de_fb_obj.ajax_url) { ajaxUrl = de_fb_obj.ajax_url; }\n                if (de_fb_obj.fb_nonce) { fbNonce = de_fb_obj.fb_nonce; }\n            }\n            \n            let ajaxData = {\n                action: ajaxAction,\n                fb_nonce: fbNonce,\n                form_id: formId,\n                payment_method_mode: paymentMethodMode\n            };\n            ajaxData.amount = amount;\n            ajaxData.currency = currency;\n            \n            \/\/ Reuse existing PaymentIntent if already created (prevents duplicates).\n            let existingPi = cardElementContainer.data('payment-intent-id') ||\n                             cardElementContainer.data('paymentIntentId') ||\n                             cardElementContainer.data('paymentIntent-id');\n            if (!existingPi) {\n                let piInput = form.find('input[name=\"payment_intent_id\"]');\n                if (piInput.length && piInput.val()) {\n                    existingPi = piInput.val();\n                }\n            }\n            \/\/ Also try sessionStorage (survives DOM re-renders and prevents a second PI on fast submit).\n            if (!existingPi) {\n                try {\n                    if (typeof sessionStorage !== 'undefined') {\n                        let storageFormId = '';\n                        try {\n                            storageFormId = form.attr('id') || '';\n                            if (typeof storageFormId === 'string') {\n                                if (storageFormId.indexOf('fb_form_') === 0) {\n                                    storageFormId = storageFormId.replace('fb_form_', '');\n                                }\n                            }\n                            if (!storageFormId) {\n                                storageFormId = formId || '';\n                            }\n                        } catch (e) {}\n                        if (storageFormId) {\n                            existingPi = sessionStorage.getItem('dfb_stripe_pi_' + storageFormId) || '';\n                        }\n                    }\n                } catch (e) {}\n            }\n            if (existingPi) {\n                ajaxData.payment_intent_id = existingPi;\n            }\n\n            \/\/ Per-checkout token to prevent duplicate PI creation (server uses it for reuse\/idempotency).\n            let piToken = '';\n            try {\n                if (typeof sessionStorage !== 'undefined') {\n                    let storageFormId = '';\n                    try {\n                        storageFormId = form.attr('id') || '';\n                        if (typeof storageFormId === 'string') {\n                            if (storageFormId.indexOf('fb_form_') === 0) {\n                                storageFormId = storageFormId.replace('fb_form_', '');\n                            }\n                        }\n                        if (!storageFormId) {\n                            storageFormId = formId || '';\n                        }\n                    } catch (e) {}\n\n                    if (storageFormId) {\n                        let tokenKey = 'dfb_stripe_pi_token_' + storageFormId;\n                        piToken = sessionStorage.getItem(tokenKey) || '';\n                        if (!piToken) {\n                            if (window.crypto) {\n                                if (typeof window.crypto.randomUUID === 'function') {\n                                    piToken = window.crypto.randomUUID();\n                                }\n                            }\n                            if (!piToken) {\n                                piToken = 'tok_' + String(Date.now()) + '_' + Math.random().toString(16).slice(2);\n                            }\n                            try { sessionStorage.setItem(tokenKey, piToken); } catch (e) {}\n                        }\n                    }\n                }\n            } catch (e) {}\n            if (piToken) {\n                ajaxData.pi_token = piToken;\n            }\n\n            \/\/ Fetch PaymentIntent client_secret\n            \n            $.ajax({\n                url: ajaxUrl,\n                type: 'POST',\n                dataType: 'json',\n                data: ajaxData,\n                success: function(response) {\n                    \/\/ Clear fetching flag\n                    cardElementContainer.data('payment-intent-fetching', false);\n\n                    let hasClientSecret = false;\n                    if (response.success) {\n                        if (response.data) {\n                            if (response.data.client_secret) {\n                                hasClientSecret = true;\n                            }\n                        }\n                    }\n                    if (hasClientSecret) {\n                        \/\/ Store client_secret in card element container\n                        cardElementContainer.data('client-secret', response.data.client_secret);\n                        cardElementContainer.data('payment-intent-fetched', true);\n                        \n                        \/\/ Store the appropriate ID and type\n                        let isSetupIntent = response.data.is_setup_intent || false;\n                        cardElementContainer.data('is-setup-intent', isSetupIntent);\n                        \n                        let intentId = isSetupIntent ? response.data.setup_intent_id : response.data.payment_intent_id;\n                        cardElementContainer.data('payment-intent-id', intentId);\n                        \/\/ Track last synced amount so we can update the intent when totals change.\n                        cardElementContainer.data('payment-intent-amount', amount);\n\n                        \/\/ Persist PI id for this form in sessionStorage so submit\/init can reuse it even if DOM re-renders.\n                        if (!isSetupIntent) {\n                            try {\n                                if (typeof sessionStorage !== 'undefined') {\n                                    let storageFormId = '';\n                                    try {\n                                        storageFormId = form.attr('id') || '';\n                                        if (typeof storageFormId === 'string') {\n                                            if (storageFormId.indexOf('fb_form_') === 0) {\n                                                storageFormId = storageFormId.replace('fb_form_', '');\n                                            }\n                                        }\n                                        if (!storageFormId) {\n                                            try {\n                                                storageFormId = form.find('input[name=\"form_key\"]').val() || '';\n                                            } catch (e) {}\n                                            if (!storageFormId) {\n                                                storageFormId = formId || '';\n                                            }\n                                        }\n                                    } catch (e) {}\n                                    if (storageFormId) {\n                                        if (intentId) {\n                                            sessionStorage.setItem('dfb_stripe_pi_' + storageFormId, intentId);\n                                            try { sessionStorage.setItem('dfb_stripe_pi_amt_' + storageFormId, String((parseFloat(amount) || 0).toFixed(2))); } catch (e) {}\n                                        }\n                                    }\n                                }\n                            } catch (e) {}\n                        }\n                        \n                        \/\/ Also store in the form's data attributes for easier retrieval\n                        let form = cardElementContainer.closest('form');\n                        if (form.length) {\n                            form.data('payment-intent-id', intentId);\n                            form.data('is-setup-intent', isSetupIntent);\n                            \n                            \/\/ Add as hidden inputs\n                            form.find('input[name=\"payment_intent_id\"]').remove();\n                            form.find('input[name=\"is_setup_intent\"]').remove();\n                            if (!isSetupIntent) {\n                                form.append(\"<input type='hidden' name='payment_intent_id' value='\" + intentId + \"'\/>\");\n                            } else {\n                                form.append(\"<input type='hidden' name='setup_intent_id' value='\" + intentId + \"'\/>\");\n                                form.append(\"<input type='hidden' name='is_setup_intent' value='1'\/>\");\n                            }\n                        }\n                        \n                    } else {\n                        \/\/ Fallback to Card Element\n                        cardElementContainer.data('payment-intent-fetched', true);\n                    }\n                    \n                    formsProcessed++;\n                    if (formsProcessed >= totalForms) {\n                        \/\/ All forms processed, proceed to initialization\n\n                        waitForStripeAndInit();\n                    }\n                },\n                error: function(xhr, status, error) {\n                    \/\/ Clear fetching flag\n                    cardElementContainer.data('payment-intent-fetching', false);\n\n                    \/\/ Fallback to Card Element\n                    cardElementContainer.data('payment-intent-fetched', true);\n                    \n                    formsProcessed++;\n                    if (formsProcessed >= totalForms) {\n                        \/\/ All forms processed, proceed to initialization\n                        window.fetchPaymentIntentAndInitExecuting = false;\n                        window.fetchPaymentIntentAndInitCompleted = true;\n                        waitForStripeAndInit();\n                    }\n                }\n            });\n        });\n    }\n    \n    \/\/ Store function reference and mark as ready\n    fetchPaymentIntentAndInitFn = fetchPaymentIntentAndInit;\n    fetchPaymentIntentAndInitReady = true;\n\n    \/\/ Also make it available globally (in case it's called from outside this scope)\n    window.fetchPaymentIntentAndInit = fetchPaymentIntentAndInit;\n    \n    \/\/ Initialize Stripe Elements for all Stripe forms on page load\n    function initializeStripeElements() {\n        if (typeof Stripe === 'undefined') {\n            console.warn('Stripe.js is not loaded yet');\n            return false;\n        }\n        \/\/ Divi 4 uses the legacy Stripe (v2-style) UI and does not mount Stripe Elements\/Payment Element.\n        if (!window.dfbIsDivi5) {\n            return false;\n        }\n        \n        let initialized = false;\n        $('.de_fb_gateway_stripe_form').each(function() {\n            let form = $(this);\n            \/\/ Try to find card-wrap within the form or anywhere on the page\n            let cardWrap = form.find('.card-wrap');\n            if (!cardWrap.length) {\n                \/\/ If not found in form, try to find it on the page (might be outside form)\n                cardWrap = $('.card-wrap').first();\n            }\n            \n            let stripeKey = cardWrap.length ? cardWrap.data('publishable-key') : null;\n            \n            if (!stripeKey) {\n                console.warn('Stripe publishable key not found for form:', form.attr('id') || 'unknown');\n                return true; \/\/ Continue to next form\n            }\n            \n            let cardElementContainer = form.find('.card-element');\n            if (!cardElementContainer.length) {\n                console.warn('Card element container not found in form:', form.attr('id') || 'unknown');\n                return true; \/\/ Continue to next form\n            }\n            \n            \/\/ Skip if already mounted\n            if (cardElementContainer.data('stripe-mounted')) {\n                return true; \/\/ Continue to next form\n            }\n            \n            \/\/ Get placeholder settings from data attributes\n            \/\/ IMPORTANT: Stripe Elements v3 unified 'card' element does NOT support custom placeholder text\n            \/\/ Placeholders are automatically generated by Stripe based on browser locale\n            \/\/ Custom placeholders would require using separate elements (cardNumber, cardExpiry, cardCvc)\n            \/\/ The placeholder data below is stored for potential future use\n            let displayPlaceholders = cardWrap.data('display-placeholders') || 'on';\n            let cardNumberPlaceholder = cardWrap.data('card-number-placeholder') || '';\n            let expiryMonthPlaceholder = cardWrap.data('expiry-month-placeholder') || '';\n            let expiryYearPlaceholder = cardWrap.data('expiry-year-placeholder') || '';\n            let cvcPlaceholder = cardWrap.data('cvc-placeholder') || '';\n            \n            try {\n                \/\/ Check if we have a client_secret (Payment Element) or need to use Card Element (fallback)\n                let clientSecret = cardElementContainer.data('client-secret');\n                let paymentElement = null;\n                let cardElement = null;\n                \n                \/\/ Get payment method mode and layout from form data attributes\n                let paymentMethodMode = cardWrap.data('stripe-payment-method-mode') || 'simple';\n                let paymentElementLayout = cardWrap.data('stripe-payment-element-layout') || 'accordion';\n            \/\/ Divi 4: force simple mode so Card Element mounts (advanced mode is Divi 5 only).\n            if (!window.dfbIsDivi5) {\n                paymentMethodMode = 'simple';\n            }\n                \n                \/\/ Debug logging\n\n                let willUsePaymentElement = false;\n                if (clientSecret) {\n                    if (paymentMethodMode === 'advanced') {\n                        willUsePaymentElement = true;\n                    }\n                }\n\n                let stripe = Stripe(stripeKey);\n                \n                if (willUsePaymentElement) {\n                    \/\/ Use Payment Element (supports multiple payment methods)\n                    let elements = stripe.elements({ clientSecret: clientSecret });\n                    paymentElement = elements.create('payment', {\n                        layout: paymentElementLayout \/\/ 'accordion' or 'tabs'\n                    });\n                    paymentElement.mount(cardElementContainer[0]);\n                    cardElementContainer.data('stripe-payment-element', paymentElement);\n                    cardElementContainer.data('stripe-elements', elements); \/\/ Store elements instance for confirmPayment\n                    cardElementContainer.data('stripe-mounted', true);\n                    cardElementContainer.data('stripe-instance', stripe);\n                    initialized = true;\n\n                    \/\/ Handle payment element events\n                    paymentElement.on('change', function(event) {\n                        let displayError = cardElementContainer.closest('.card-wrap').find('.card-errors');\n                        if (displayError.length === 0) {\n                            displayError = form.find('.card-errors').first();\n                        }\n                        if (event.error) {\n                            try { cardElementContainer.removeData('dfb-stripe-sticky-error'); } catch (e) {}\n                            displayError.text(event.error.message);\n                        } else {\n                            try {\n                                const stickyError = cardElementContainer.data('dfb-stripe-sticky-error');\n                                if (stickyError) {\n                                    if (event) {\n                                        if (event.complete === true) {\n                                            cardElementContainer.removeData('dfb-stripe-sticky-error');\n                                            displayError.text('');\n                                        }\n                                    }\n                                } else {\n                                    displayError.text('');\n                                }\n                            } catch (e) {\n                                displayError.text('');\n                            }\n                        }\n\n                        \/\/ Persist selected payment method type (e.g. amazon_pay, klarna) on the form\n                        \/\/ so PHP can read it on submit.\n                        try {\n                            let methodType = '';\n                            if (event) {\n                                if (event.value) {\n                                    if (event.value.type) {\n                                        methodType = event.value.type;\n                                    }\n                                }\n                            }\n                            if (methodType) {\n                                let lastType = cardElementContainer.data('stripe-selected-method-type') || '';\n                                if (lastType !== methodType) {\n                                    cardElementContainer.data('stripe-selected-method-type', methodType);\n\n                                    form.find('input[name=\"stripe_payment_method_type\"]').remove();\n                                    form.append(\"<input type='hidden' name='stripe_payment_method_type' value='\" + methodType + \"'\/>\");\n                                }\n                            }\n                        } catch (e) {}\n                    });\n                } else {\n                    \/\/ Advanced mode requires Payment Element. If we don't have a client_secret yet, wait.\n                    if (paymentMethodMode === 'advanced') {\n                        if (!clientSecret) {\n                            return true;\n                        }\n                    }\n\n                    \/\/ Fallback: Use Card Element (backwards compatibility or simple mode)\n                    \/\/ Get computed font styles from the card-element container\n                    let computedStyles = window.getComputedStyle(cardElementContainer[0]);\n                    let fontFamily = computedStyles.fontFamily || 'Roboto, Open Sans, Segoe UI, sans-serif';\n                    let fontSize = computedStyles.fontSize || '16px';\n                    let fontWeight = computedStyles.fontWeight || '400';\n                    let fontStyle = computedStyles.fontStyle || 'normal';\n                    let letterSpacing = computedStyles.letterSpacing || 'normal';\n                    let lineHeight = computedStyles.lineHeight || 'normal';\n                    let color = computedStyles.color || '#313259';\n                    \n                    \/\/ Get placeholder color from computed styles or default (WCAG AA: 4.5:1 on white)\n                    let placeholderColor = '#6b7280';\n                    try {\n                        \/\/ Try to get placeholder color from ::placeholder pseudo-element\n                        let placeholderStyles = window.getComputedStyle(cardElementContainer[0], '::placeholder');\n                        if (placeholderStyles && placeholderStyles.color) {\n                            placeholderColor = placeholderStyles.color;\n                        }\n                    } catch (e) {\n                        \/\/ Fallback to default if ::placeholder is not supported\n                    }\n                    \n                    let elements = stripe.elements();\n                    cardElement = elements.create('card', {\n                        hidePostalCode: true,\n                        style: {\n                            base: {\n                                iconColor: '#666EE8',\n                                color: color,\n                                fontWeight: parseInt(fontWeight) || 400,\n                                fontFamily: fontFamily,\n                                fontSize: fontSize,\n                                fontStyle: fontStyle,\n                                letterSpacing: letterSpacing,\n                                lineHeight: lineHeight,\n                                '::placeholder': {\n                                    color: placeholderColor,\n                                },\n                            },\n                            invalid: {\n                                iconColor: '#FFC7EE',\n                                color: '#FFC7EE',\n                            },\n                        }\n                    });\n                    \n                    \/\/ Mount to the actual DOM element, not the selector\n                    cardElement.mount(cardElementContainer[0]);\n                    cardElementContainer.data('stripe-mounted', true);\n                    cardElementContainer.data('stripe-instance', stripe);\n                    cardElementContainer.data('stripe-card-element', cardElement);\n                    initialized = true;\n\n                    \/\/ Handle card element events\n                    cardElement.on('change', function(event) {\n                        \/\/ Find the card-errors element within the same card-wrap container to avoid duplicates\n                        let displayError = cardElementContainer.closest('.card-wrap').find('.card-errors');\n                        if (displayError.length === 0) {\n                            displayError = form.find('.card-errors').first();\n                        }\n                        if (event.error) {\n                            try { cardElementContainer.removeData('dfb-stripe-sticky-error'); } catch (e) {}\n                            displayError.text(event.error.message);\n                        } else {\n                            try {\n                                const stickyError = cardElementContainer.data('dfb-stripe-sticky-error');\n                                if (stickyError) {\n                                    if (event) {\n                                        if (event.complete === true) {\n                                            cardElementContainer.removeData('dfb-stripe-sticky-error');\n                                            displayError.text('');\n                                        }\n                                    }\n                                } else {\n                                    displayError.text('');\n                                }\n                            } catch (e) {\n                                displayError.text('');\n                            }\n                        }\n                    });\n                }\n            } catch (error) {\n                console.error('Error initializing Stripe Elements for form ' + (form.attr('id') || 'unknown') + ':', error);\n            }\n            \n            return true; \/\/ Continue to next form\n        });\n        \n        return initialized;\n    }\n    \n    \/\/ Wait for Stripe.js to load, then initialize\n    function waitForStripeAndInit() {\n        if (typeof Stripe !== 'undefined') {\n            initializeStripeElements();\n            return true;\n        }\n        return false;\n    }\n    \n    \/\/ Phase 4: Start by fetching PaymentIntent (if needed), then initialize Stripe Elements\n    \/\/ Global flag to prevent duplicate execution across all forms\n    if (typeof window.fetchPaymentIntentAndInitExecuting === 'undefined') {\n        window.fetchPaymentIntentAndInitExecuting = false;\n    }\n    if (typeof window.fetchPaymentIntentAndInitCompleted === 'undefined') {\n        window.fetchPaymentIntentAndInitCompleted = false;\n    }\n    \n    \/\/ Try to fetch PaymentIntent immediately (only once)\n    \n    if (!window.fetchPaymentIntentAndInitExecuting) {\n        if (!window.fetchPaymentIntentAndInitCompleted) {\n            window.fetchPaymentIntentAndInitExecuting = true;\n            window.fetchPaymentIntentAndInit();\n        }\n    } else {\n    }\n    \n    \/\/ Function to create PaymentIntent when payment gateway is clicked (amount becomes available)\n    \/\/ This is needed because the amount might be 0 on page load, but becomes available when gateway is clicked\n    \/\/ Only define once globally\n    if (typeof window.createPaymentIntentOnGatewayClick === 'undefined') {\n        window.createPaymentIntentOnGatewayClick = function() {\n            \/\/ Divi 4 must not create PaymentIntents (Stripe v3 flow is Divi 5 only).\n            if (!window.dfbIsDivi5) {\n                return;\n            }\n            \n            \/\/ If fetchPaymentIntentAndInit is executing, wait for it to complete\n            if (window.fetchPaymentIntentAndInitExecuting) {\n                let startTime = Date.now();\n                let checkInterval = setInterval(function() {\n                    if (!window.fetchPaymentIntentAndInitExecuting) {\n                        clearInterval(checkInterval);\n                        \/\/ Recursively call this function after fetchPaymentIntentAndInit completes\n                        \/\/ This will re-check the amount (which might have changed from 0 to > 0)\n                        window.createPaymentIntentOnGatewayClick();\n                        return;\n                    }\n                    \/\/ Fail-safe: do not block forever if the init flag gets stuck.\n                    if ((Date.now() - startTime) > 3000) {\n                        clearInterval(checkInterval);\n                        try { window.fetchPaymentIntentAndInitExecuting = false; } catch (e) {}\n                        window.createPaymentIntentOnGatewayClick();\n                    }\n                }, 100);\n                return;\n            }\n            \n            \n            $('.de_fb_gateway_stripe_form').each(function() {\n                let form = $(this);\n                let cardElementContainer = form.find('.card-element');\n                \n                if (!cardElementContainer.length) {\n                    return true; \/\/ Continue to next form\n                }\n                \n                \/\/ Get form data FIRST to check amount (amount might have changed since page load)\n                let formId = form.data('form-id') || form.attr('id');\n                let cardWrap = form.find('.card-wrap');\n                if (!cardWrap.length) {\n                    cardWrap = $('.card-wrap').first();\n                }\n                \n                \/\/ IMPORTANT: Re-check amount - it might have changed from 0 to > 0\n                \/\/ Try multiple sources for amount (it might be updated dynamically)\n                let amount = 0;\n                \n                \/\/ First: Try hidden input (most reliable - updated when form fields change)\n                let amountInput = form.find('input[name=\"de_fb_payment_amount\"]');\n                if (amountInput.length) {\n                    amount = parseFloat(amountInput.val()) || 0;\n                }\n                \n                \/\/ Second: Try card-wrap data attribute\n                if (amount <= 0) {\n                    if (cardWrap.length) {\n                        amount = parseFloat(cardWrap.data('payment-amount')) || 0;\n                    }\n                }\n                \n                \/\/ Third: Try form data attribute\n                if (amount <= 0) {\n                    amount = parseFloat(form.data('payment-amount')) || 0;\n                }\n                \n                let currency = cardWrap.length ? (cardWrap.data('payment-currency') || 'usd') : 'usd';\n                let paymentMethodMode = cardWrap.length ? (cardWrap.data('stripe-payment-method-mode') || 'simple') : 'simple';\n                \n                \n                \/\/ Check if PaymentIntent already exists\n                \/\/ Try multiple keys - jQuery converts kebab-case to camelCase\n                let fetched = cardElementContainer.data('payment-intent-fetched') || \n                              cardElementContainer.data('paymentIntentFetched');\n                let id = cardElementContainer.data('payment-intent-id') || \n                         cardElementContainer.data('paymentIntentId') ||\n                         cardElementContainer.data('paymentIntent-id');\n                \/\/ Also check form input\n                if (!id) {\n                    let formInput = form.find('input[name=\"payment_intent_id\"]');\n                    if (formInput.length) {\n                        if (formInput.val()) {\n                            id = formInput.val();\n                        }\n                    }\n                }\n                let existingIntentId = id || '';\n                let lastIntentAmount = parseFloat(cardElementContainer.data('payment-intent-amount')) || 0;\n                \n                \/\/ Check if currently being fetched\n                if (cardElementContainer.data('payment-intent-fetching')) {\n                    return true; \/\/ Continue to next form\n                }\n                \n                \/\/ Only create PaymentIntent if we have amount and form ID\n                if (!formId || amount <= 0) {\n                    return true; \/\/ Continue to next form\n                }\n\n                if (existingIntentId) {\n                    if (lastIntentAmount > 0) {\n                        if (Math.abs(amount - lastIntentAmount) < 0.0001) {\n                            return true; \/\/ Continue to next form\n                        }\n                    }\n                }\n                \n                \/\/ Extract form ID number if it's in format \"fb_form_123\"\n                if (typeof formId === 'string') {\n                    if (formId.indexOf('fb_form_') === 0) {\n                        formId = formId.replace('fb_form_', '');\n                    }\n                }\n\n                \/\/ If DOM was re-rendered and we lost the PI id, reuse it from sessionStorage.\n                if (!existingIntentId) {\n                    try {\n                        if (typeof sessionStorage !== 'undefined') {\n                            let storageFormId = '';\n                            try {\n                                storageFormId = form.attr('id') || '';\n                                if (typeof storageFormId === 'string') {\n                                    if (storageFormId.indexOf('fb_form_') === 0) {\n                                        storageFormId = storageFormId.replace('fb_form_', '');\n                                    }\n                                }\n                                if (!storageFormId) {\n                                    storageFormId = formId || '';\n                                }\n                            } catch (e) {}\n                            if (storageFormId) {\n                                let storedPi = sessionStorage.getItem('dfb_stripe_pi_' + storageFormId);\n                                if (storedPi) {\n                                    existingIntentId = storedPi;\n                                    \/\/ Keep DOM in sync so submit flow uses the same PI.\n                                    cardElementContainer.data('payment-intent-id', existingIntentId);\n                                    form.data('payment-intent-id', existingIntentId);\n                                    form.find('input[name=\"payment_intent_id\"]').remove();\n                                    form.append(\"<input type='hidden' name='payment_intent_id' value='\" + existingIntentId + \"'\/>\");\n                                }\n                            }\n                        }\n                    } catch (e) {}\n                }\n                \n                \/\/ Mark as fetching\n                cardElementContainer.data('payment-intent-fetching', true);\n                \n                \n                \/\/ Fetch PaymentIntent client_secret\n                var ajaxUrl = 'https:\/\/okelks.org\/wp-admin\/admin-ajax.php';\n                if (typeof de_fb_obj !== 'undefined') {\n                    if (typeof de_fb_obj.ajax_url !== 'undefined') {\n                        ajaxUrl = de_fb_obj.ajax_url;\n                    }\n                }\n                var fbNonce = 'e933171a98';\n                if (typeof de_fb_obj !== 'undefined') {\n                    if (typeof de_fb_obj.fb_nonce !== 'undefined') {\n                        fbNonce = de_fb_obj.fb_nonce;\n                    }\n                }\n                \/\/ Per-checkout token to prevent duplicate PI creation (server uses it for reuse\/idempotency).\n                var piToken = '';\n                try {\n                    if (typeof sessionStorage !== 'undefined') {\n                        var storageFormId = '';\n                        try {\n                            storageFormId = form.attr('id') || '';\n                            if (typeof storageFormId === 'string') {\n                                if (storageFormId.indexOf('fb_form_') === 0) {\n                                    storageFormId = storageFormId.replace('fb_form_', '');\n                                }\n                            }\n                            if (!storageFormId) {\n                                try {\n                                    storageFormId = form.find('input[name=\"form_key\"]').val() || '';\n                                } catch (e) {}\n                                if (!storageFormId) {\n                                    storageFormId = formId || '';\n                                }\n                            }\n                        } catch (e) {}\n                        if (storageFormId) {\n                            var tokenKey = 'dfb_stripe_pi_token_' + storageFormId;\n                            piToken = sessionStorage.getItem(tokenKey) || '';\n                            if (!piToken) {\n                                if (window.crypto) {\n                                    if (typeof window.crypto.randomUUID === 'function') {\n                                        piToken = window.crypto.randomUUID();\n                                    }\n                                }\n                                if (!piToken) {\n                                    piToken = 'tok_' + String(Date.now()) + '_' + Math.random().toString(16).slice(2);\n                                }\n                                try { sessionStorage.setItem(tokenKey, piToken); } catch (e) {}\n                            }\n                        }\n                    }\n                } catch (e) {}\n                $.ajax({\n                    url: ajaxUrl,\n                    type: 'POST',\n                    dataType: 'json',\n                    data: {\n                        action: 'de_fb_create_stripe_payment_intent',\n                        fb_nonce: fbNonce,\n                        form_id: formId,\n                        pi_token: piToken,\n                        amount: amount,\n                        currency: currency,\n                        payment_method_mode: paymentMethodMode,\n                        payment_intent_id: existingIntentId\n                    },\n                    success: function(response) {\n                        \/\/ Clear fetching flag\n                        cardElementContainer.data('payment-intent-fetching', false);\n                        \n                        \n                        if (response.success) {\n                            if (response.data) {\n                                if (response.data.client_secret) {\n                                    \/\/ Store client_secret in card element container.\n                                    \/\/ If Stripe returns a NEW client_secret (e.g. PI was recreated), we must remount Elements.\n                                    let prevClientSecret = cardElementContainer.data('client-secret') || '';\n                                    let prevPiId = cardElementContainer.data('payment-intent-id') || '';\n\n                                    cardElementContainer.data('client-secret', response.data.client_secret);\n                                    cardElementContainer.data('payment-intent-id', response.data.payment_intent_id);\n                                    cardElementContainer.data('payment-intent-fetched', true);\n                                    cardElementContainer.data('payment-intent-amount', amount);\n\n                                    let needsRemount = false;\n                                    try {\n                                        if (prevClientSecret && prevClientSecret !== response.data.client_secret) {\n                                            needsRemount = true;\n                                        } else if (prevPiId && prevPiId !== response.data.payment_intent_id && prevClientSecret !== response.data.client_secret) {\n                                            needsRemount = true;\n                                        }\n                                    } catch (e) {}\n\n                                    if (needsRemount) {\n                                        try {\n                                            cardElementContainer.removeData('stripe-mounted');\n                                            cardElementContainer.removeData('stripe-elements');\n                                            cardElementContainer.removeData('stripe-payment-element');\n                                        } catch (e) {}\n                                        try { waitForStripeAndInit(); } catch (e) {}\n                                    }\n                                    \/\/ Persist PI id for this form in sessionStorage (prevents creating a second PI).\n                                    try {\n                                        if (typeof sessionStorage !== 'undefined') {\n                                            let storageFormId = '';\n                                            try {\n                                                storageFormId = form.attr('id') || '';\n                                                if (typeof storageFormId === 'string') {\n                                                    if (storageFormId.indexOf('fb_form_') === 0) {\n                                                        storageFormId = storageFormId.replace('fb_form_', '');\n                                                    }\n                                                }\n                                                if (!storageFormId) {\n                                                    try {\n                                                        storageFormId = form.find('input[name=\"form_key\"]').val() || '';\n                                                    } catch (e) {}\n                                                    if (!storageFormId) {\n                                                        storageFormId = formId || '';\n                                                    }\n                                                }\n                                            } catch (e) {}\n                                            if (storageFormId) {\n                                                if (response.data.payment_intent_id) {\n                                                    sessionStorage.setItem('dfb_stripe_pi_' + storageFormId, response.data.payment_intent_id);\n                                                    try { sessionStorage.setItem('dfb_stripe_pi_amt_' + storageFormId, String((parseFloat(amount) || 0).toFixed(2))); } catch (e) {}\n                                                }\n                                            }\n                                        }\n                                    } catch (e) {}\n                                    \n                                    \/\/ Also store PaymentIntent ID in the form's data attributes for easier retrieval\n                                    let form = cardElementContainer.closest('form');\n                                    if (form.length) {\n                                        form.data('payment-intent-id', response.data.payment_intent_id);\n                                        \/\/ Also add PaymentIntent ID to form as hidden input immediately\n                                        form.find('input[name=\"payment_intent_id\"]').remove(); \/\/ Remove any existing\n                                        form.append(\"<input type='hidden' name='payment_intent_id' value='\" + response.data.payment_intent_id + \"'\/>\");\n                                    }\n\n                                    \/\/ If we did not remount, fetch updates so wallets reflect the latest amount.\n                                    try {\n                                        if (!needsRemount) {\n                                            let elements = cardElementContainer.data('stripe-elements');\n                                            if (elements) {\n                                                if (typeof elements.fetchUpdates === 'function') {\n                                                    elements.fetchUpdates();\n                                                }\n                                            }\n                                        }\n                                    } catch (e) {}\n                                    \n                                } else {\n\n                                    \/\/ Fallback to Card Element\n                                    cardElementContainer.data('payment-intent-fetched', true);\n                                }\n                            } else {\n\n                                \/\/ Fallback to Card Element\n                                cardElementContainer.data('payment-intent-fetched', true);\n                            }\n                        } else {\n                            var errorMsg = 'Unknown error';\n                            if (response.data) {\n                                if (response.data.message) {\n                                    errorMsg = response.data.message;\n                                }\n                            }\n\n                            \/\/ Fallback to Card Element\n                            cardElementContainer.data('payment-intent-fetched', true);\n                        }\n                    },\n                    error: function(xhr, status, error) {\n                        \/\/ Clear fetching flag\n                        cardElementContainer.data('payment-intent-fetching', false);\n\n                        \/\/ Fallback to Card Element\n                        cardElementContainer.data('payment-intent-fetched', true);\n                    }\n                });\n            });\n        };\n    }\n    \n    \/\/ Listen for payment gateway clicks and create PaymentIntent when amount becomes available\n    \/\/ Use document-level listener to catch clicks from minified JS\n    \/\/ Only add listener once (check if it already exists)\n    if (typeof window.stripeGatewayClickListenerAdded === 'undefined') {\n        window.stripeGatewayClickListenerAdded = true;\n        $(document).on('click', '.divi_fb_gateways a', function() {\n            \/\/ Wait a bit for the amount to be updated, then create PaymentIntent\n            setTimeout(function() {\n                if (typeof window.createPaymentIntentOnGatewayClick === 'function') {\n                    window.createPaymentIntentOnGatewayClick();\n                }\n            }, 200);\n        });\n    }\n\n    \/\/ Also create\/update PaymentIntent when amount changes (custom\/calculated price) in Advanced mode,\n    \/\/ so the Payment Element stays in sync when the total changes.\n    if (typeof window.stripeAmountChangeListenerAdded === 'undefined') {\n        window.stripeAmountChangeListenerAdded = true;\n        let dfbStripeAmountTimer = null;\n        $(document).on('input change', '.de_fb_gateway_stripe_form input[name=\"de_fb_payment_amount\"], .de_fb_gateway_stripe_form input[name=\"custom_price\"]', function() {\n            var __el = this;\n            clearTimeout(dfbStripeAmountTimer);\n            dfbStripeAmountTimer = setTimeout(function() {\n                try {\n                    let form = jQuery('.de_fb_gateway_stripe_form').first();\n                    try { form = jQuery(__el).closest('form'); } catch (e) {}\n                    if (form.length) {\n                        let storageFormId = '';\n                        try {\n                            storageFormId = form.attr('id') || '';\n                            if (typeof storageFormId === 'string') {\n                                if (storageFormId.indexOf('fb_form_') === 0) {\n                                    storageFormId = storageFormId.replace('fb_form_', '');\n                                }\n                            }\n                        } catch (e) {}\n                        if (!storageFormId) {\n                            try { storageFormId = form.find('input[name=\"form_key\"]').val() || ''; } catch (e) {}\n                        }\n                        if (storageFormId) {\n                            try { sessionStorage.removeItem('dfb_stripe_skip_init_' + storageFormId); } catch (e) {}\n                        }\n                    }\n                } catch (e) {}\n                if (typeof window.createPaymentIntentOnGatewayClick === 'function') {\n                    window.createPaymentIntentOnGatewayClick();\n                }\n            }, 300);\n        });\n    }\n\n    \/\/ Ensure custom-price forms always sync visible total -> hidden amount -> PI update.\n    if (typeof window.stripeCustomPriceSyncListenerAdded === 'undefined') {\n        window.stripeCustomPriceSyncListenerAdded = true;\n        let dfbStripeCustomSyncTimer = null;\n        $(document).on('input change', '.de_fb_gateway_stripe_form input[name^=\"de_fb_\"]:not([name=\"de_fb_payment_amount\"])', function() {\n            var __el = this;\n            clearTimeout(dfbStripeCustomSyncTimer);\n            dfbStripeCustomSyncTimer = setTimeout(function() {\n                try {\n                    let form = jQuery(__el).closest('form.de_fb_gateway_stripe_form');\n                    if (!form.length) { return; }\n                    if (!form.find('.de_fb_form_field_custom_price').length) { return; }\n\n                    let visibleAmt = 0;\n                    let hasVisibleAmt = false;\n                    try {\n                        let priceEl = form.find('#custom_price_wrapper .price').first();\n                        if (!priceEl.length) {\n                            priceEl = form.find('.plan-price .price').first();\n                        }\n                        if (priceEl.length) {\n                            visibleAmt = parseFloat((String(priceEl.text() || '')).replace(\/,\/g, '')) || 0;\n                            hasVisibleAmt = true;\n                        }\n                    } catch (e) { visibleAmt = 0; hasVisibleAmt = false; }\n                    if (!hasVisibleAmt || visibleAmt <= 0) { return; }\n\n                    let amtField = form.find('input[name=\"de_fb_payment_amount\"]').first();\n                    if (amtField.length) {\n                        amtField.val(visibleAmt.toFixed(2)).trigger('input').trigger('change');\n                    }\n\n                    try {\n                        if (typeof sessionStorage !== 'undefined') {\n                            let storageFormId = '';\n                            try {\n                                storageFormId = form.attr('id') || '';\n                                if (typeof storageFormId === 'string') {\n                                    if (storageFormId.indexOf('fb_form_') === 0) {\n                                        storageFormId = storageFormId.replace('fb_form_', '');\n                                    }\n                                }\n                            } catch (e) {}\n                            if (!storageFormId) {\n                                try { storageFormId = form.find('input[name=\"form_key\"]').val() || ''; } catch (e) {}\n                            }\n                            if (storageFormId) {\n                                try { sessionStorage.removeItem('dfb_stripe_skip_init_' + storageFormId); } catch (e) {}\n                            }\n                        }\n                    } catch (e) {}\n\n                    if (typeof window.createPaymentIntentOnGatewayClick === 'function') {\n                        window.createPaymentIntentOnGatewayClick();\n                    }\n                } catch (e) {}\n            }, 250);\n        });\n    }\n\n    jQuery(\"#fb_form_null-0\").submit(function(e){\n        e.preventDefault();\n        \n        $(this).find('.divi-form-submit').prop('disabled', true);\n        var required_check = true;\n        var form = jQuery(this);\n        let required_fields = $('.required',form);\n        var stripeEnabled = $(this).hasClass('de_fb_gateway_stripe_form');\n        let paymentField = $(this).find('input[name=\"de_fb_payment_amount\"]');\n        let paymentInput = $(this).find('input[name=\"custom_price\"]');\n        let paymentErrors = $(this).find('.payment-errors').length > 0;\n        var paymentEnabled = $(this).find('input[name=\"enable_payment\"]').val();\n        var showTc = $(this).find('input[name=\"show_tc\"]').val();\n        let stripeErrorMessages = {};\n        var default_required_message = \"This field is required.\";\n\n        $(this).find('.datepicker-field').each(function() {\n            var $field = $(this);\n            var isAcfField = $field.attr(\"acf-date\");\n            var selectedDate = $field.datepicker('getDate');\n            if (selectedDate) {\n                if (isAcfField == true) {\n                    var formatted = $.datepicker.formatDate('yymmdd', selectedDate);\n                    $field.val(formatted);\n                }\n            }\n        });\n\n        if ( required_fields.length > 0 ) {\n            \n            $.each(required_fields, function (index, element) {\n                var $parent = $(this).closest('.et_pb_contact_field').parent();\n                $parent.find('.error').each(function() {\n                    var errId = $(this).attr('id');\n                    if (errId) { $parent.find('[aria-describedby=\"' + errId + '\"]').removeAttr('aria-describedby'); }\n                });\n                $parent.find('.error').remove();\n                if ( !$(this).closest('.de_fb_form_field').hasClass('condition-hide') ) {\n                    var field_type = $(this).closest('.et_pb_contact_field').data('type');\n                    \n                    if ( field_type == 'checkbox' || field_type == 'radio' ) {\n                        if ( jQuery(this).find('input:checked').length == 0 ) {\n                            required_check = false;\n                        }\n                    } else if ( field_type == 'file' || field_type == 'image' ) {\n                        var value_field_id = jQuery(this).find('input.upload_field').attr('id') + '_value';\n                        if ( jQuery(this).find('.files .template-upload').length == 0 ) {\n                            if ( jQuery(this).find('#' + value_field_id).val() == \"\") {\n                                required_check = false;\n                            }\n                        }\n                    } else {\n                        if ( jQuery(this).val() == '' ) {\n                            required_check = false;\n                        }\n                    }\n                    if ( !required_check ) {\n                        var required_message = $(this).attr('data-required_message') || default_required_message;\n                        var required_message_pos = $(this).attr('data-required_position') || 'bottom';\n                        var inputId = $(this).attr('id');\n                        var errorId = inputId ? inputId + '_error' : null;\n                        var errorAttrs = errorId ? ' id=\"' + errorId + '\" role=\"alert\" aria-live=\"polite\"' : '';\n                        if (errorId) { $(this).attr('aria-describedby', errorId); }\n                        if ( required_message_pos == 'top' ) {\n                            $(this).closest('.et_pb_contact_field').before('<p class=\"error\"' + errorAttrs + '>' + required_message + '<\/p>');\n                        } else {\n                            $(this).closest('.et_pb_contact_field').after('<p class=\"error\"' + errorAttrs + '>' + required_message + '<\/p>');\n                        }\n                    }\n                }\n                \n                \n            });\n        }\n        \n        if ( form.find('.bloom_subscribe').find('input[required]').length > 0 ) {\n            form.find('.bloom_subscribe').find('.error').remove();\n            if ( !form.find('.bloom_subscribe').find('input[required]').is(\":checked\") ) {\n                required_check = false;\n                var required_message = \"This field is required.\";\n                var required_message_pos = \"bottom\";\n\n                if ( required_message_pos == 'top' ) {\n                    form.find('.bloom_subscribe').prepend('<p class=\"error\" role=\"alert\" aria-live=\"polite\"><span class=\"dfb-error-icon\" aria-hidden=\"true\">&#9888;<\/span> ' + required_message + '<\/p>');\n                } else {\n                    form.find('.bloom_subscribe').append('<p class=\"error\" role=\"alert\" aria-live=\"polite\"><span class=\"dfb-error-icon\" aria-hidden=\"true\">&#9888;<\/span> ' + required_message + '<\/p>');\n                }\n            }\n        }\n        \n        if ( !required_check ) {\n            $('html, body').animate({\n                scrollTop: form.offset().top - 10\n            }, 300);\n\n            form.find('.divi-form-submit').removeProp('disabled');\n            form.find('.divi-form-submit').removeAttr('disabled');\n        }\n\n        var validation_result = form.valid();\n\n        if ( !validation_result ) {\n            e.preventDefault();\n            let inputs_error= $('.input-field.error',form);\n            inputs_error.each(function (){\n                let input=$(this);\n                let parent=input.parent();\n                let label = $('label.error',parent).first();\n                let icon = $('.dfb_input_icon',parent).first();\n                if(icon.length){\n                    if(input.next().is(label)){\n                        label.detach().appendTo(parent.parent());\n                    }\n                }\n            });\n            $(this).find('.divi-form-submit').removeProp('disabled');\n            $(this).find('.divi-form-submit').removeAttr('disabled');\n            return false;\n        }\n\n        if (paymentField.hasClass('error')) {\n            e.preventDefault();\n            return false;\n        }\n\n                var $_p = form.find('input[name=\"de_fb_user_pass\"], input[name=\"user_pass\"]').first();\n        var $_c = form.find('input[name=\"de_fb_pass_repeat\"], input[name=\"pass_repeat\"]').first();\n        if ($_p.length && $_c.length && $_p.val() !== $_c.val()) {\n            var $pwParent = $_c.closest('.et_pb_contact_field').parent();\n            $pwParent.find('.error').each(function() { var id = $(this).attr('id'); if (id) $pwParent.find('[aria-describedby=\"'+id+'\"]').removeAttr('aria-describedby'); });\n            $pwParent.find('.error').remove();\n            var confirmErrId = $_c.attr('id') ? $_c.attr('id') + '_error' : null;\n            if (confirmErrId) { $_c.attr('aria-describedby', confirmErrId); }\n            $_c.closest('.et_pb_contact_field').after('<p class=\"error\"' + (confirmErrId ? ' id=\"'+confirmErrId+'\" role=\"alert\" aria-live=\"polite\"' : '') + '>' + \"Sorry, your passwords do not match.\" + '<\/p>');\n            $_c.focus();\n            form.find('.divi-form-submit').removeProp('disabled');\n            form.find('.divi-form-submit').removeAttr('disabled');\n            return false;\n        }\n                \/\/ Non-AJAX + AI trigger \"form-submit\": generate AI and do not submit traditional form.\n        var isAjaxSubmitButton = form.find('.divi-form-submit').hasClass('de_fb_ajax_submit');\n        var $aiFormInputForSubmit = form.find('[name=\"dfb_ai_form\"]').first();\n        var aiTriggerForSubmit = form.find('[name=\"form_ai_api_call_trigger\"]').first().val() || '';\n        if ( !isAjaxSubmitButton && $aiFormInputForSubmit.length && aiTriggerForSubmit === 'form-submit' ) {\n            var aiSettingsRaw = $aiFormInputForSubmit.attr('data-ai-settings') || '';\n            var aiIdsRaw = $aiFormInputForSubmit.attr('data-ai-fields-array') || '[]';\n            var aiSettingsForSubmit = null;\n            var aiIdsForSubmit = [];\n            var aiFieldValuesForSubmit = {};\n            var aiFieldTitlesForSubmit = {};\n            try {\n                aiSettingsForSubmit = JSON.parse(aiSettingsRaw);\n                aiIdsForSubmit = JSON.parse(aiIdsRaw);\n            } catch (err) {\n                aiSettingsForSubmit = null;\n                aiIdsForSubmit = [];\n            }\n            if (aiSettingsForSubmit && typeof window['dfb_send_ai_data_null-0'] === 'function') {\n                form.find('.ai_field').each(function() {\n                    var field = this;\n                    var fieldId = field.id || field.name || '';\n                    if (!fieldId) {\n                        return;\n                    }\n                    var fieldValue = '';\n                    if (field.tagName && field.tagName.toLowerCase() === 'select') {\n                        if (field.multiple) {\n                            fieldValue = [];\n                            for (var i = 0; i < field.options.length; i++) {\n                                if (field.options[i].selected) {\n                                    fieldValue.push(field.options[i].value);\n                                }\n                            }\n                        } else {\n                            fieldValue = field.options[field.selectedIndex] ? field.options[field.selectedIndex].value : '';\n                        }\n                    } else {\n                        var fieldType = field.type || '';\n                        if (fieldType === 'checkbox' || fieldType === 'radio') {\n                            fieldValue = field.checked ? (field.value || '') : '';\n                        } else {\n                            fieldValue = field.value || '';\n                        }\n                    }\n                    aiFieldValuesForSubmit[fieldId] = fieldValue;\n                    aiFieldTitlesForSubmit[fieldId] = jQuery(field).closest('.de_fb_form_field').find('input[name=\"field_title[]\"]').val() || '';\n                });\n\n                window['dfb_send_ai_data_null-0'](\n                    aiIdsForSubmit,\n                    aiSettingsForSubmit,\n                    aiFieldValuesForSubmit,\n                    aiFieldTitlesForSubmit\n                );\n                form.find('.divi-form-submit').prop('disabled', false).removeAttr('disabled');\n                return false;\n            }\n        }\n        if ($(this).find('.signature-field').length > 0) {\n            $.each( $(this).find('.signature-field'), function(i) {\n                var field_id = $(this).find('input').attr('id');\n                $(\"#\" + field_id).val( fb_signature.signature_objs['signaturePad_' + field_id].toDataURL() );\n            });\n        }\n        if(showTc){ \n            let activeTab = form.find(\".gateway-form:visible\");\n            let tcCheck = activeTab.find(\"input[type='checkbox']\");\n\n            form.find('.tcerror').remove();\n            if (!tcCheck.is(\":checked\")) {\n                tcCheck.closest(\".tc_wrap\").after('<p class=\"tcerror\">You must accept the Terms & Conditions.<\/p>');\n                form.find('.divi-form-submit').prop('disabled', false);\n                return false;\n            }\n        }\n        \/\/ Payment amount validation (important for wallet methods like Amazon Pay).\n        \/\/ We must validate against the latest computed amount, not just the raw hidden input value.\n        let dfbPaymentAmount = 0;\n        try {\n            let v = parseFloat(paymentField.val()) || 0;\n            if (v > 0) { dfbPaymentAmount = v; }\n\n            if (dfbPaymentAmount <= 0) {\n                let pv = 0;\n                try { pv = parseFloat(paymentInput.val()) || 0; } catch (e) {}\n                if (pv > 0) { dfbPaymentAmount = pv; }\n            }\n\n            if (dfbPaymentAmount <= 0) {\n                let cardWrap = form.find('.card-wrap');\n                if (!cardWrap.length) { cardWrap = $('.card-wrap').first(); }\n                if (cardWrap.length) {\n                    let cw = parseFloat(cardWrap.data('payment-amount')) || 0;\n                    if (cw > 0) { dfbPaymentAmount = cw; }\n                }\n            }\n\n            if (dfbPaymentAmount <= 0) {\n                let fa = parseFloat(form.data('payment-amount')) || 0;\n                if (fa > 0) { dfbPaymentAmount = fa; }\n            }\n\n            if (dfbPaymentAmount <= 0) {\n                \/\/ Fallback: parse visible text (e.g. \"$19.00\", \"\u00a319.00\")\n                let txt = '';\n                try { txt = (form.find('.plan-price').first().text() || '').replace(\/,\/g, ''); } catch (e) {}\n                let m = txt.match(\/-?\\d+(\\.\\d+)?\/);\n                if (m) {\n                    if (m[0]) {\n                        let tv = parseFloat(m[0]) || 0;\n                        if (tv > 0) { dfbPaymentAmount = tv; }\n                    }\n                }\n            }\n        } catch (e) {}\n\n        if (dfbPaymentAmount > 0) {\n            try { paymentField.val(dfbPaymentAmount.toFixed(2)); } catch (e) {}\n            try { paymentField.removeClass('input-error'); } catch (e) {}\n            try { form.find('.plan-price').find('.payment-error').remove(); } catch (e) {}\n        } else {\n            form.find('.plan-price').find('.payment-error').remove();\n            if(form.find('.plan-price .payment-error').length === 0){\n                form.find('.plan-price').append('<div class=\"payment-error et_pb_contact_error_text\" role=\"alert\" aria-live=\"polite\"><span class=\"dfb-error-icon\" aria-hidden=\"true\">&#9888;<\/span> Please add a valid value for payment<\/div>');\n            }\n            required_check = false;\n            paymentField.addClass('input-error');\n            form.find('.divi-form-submit').removeProp('disabled');\n            form.find('.divi-form-submit').removeAttr('disabled');\n            \/\/ Debug (WP_DEBUG only): log why we think amount is invalid.\n            try {\n                let methodType = form.find('input[name=\"stripe_payment_method_type\"]').val() || '';\n                if (methodType) {\n                    console.warn('[DFB Stripe] Invalid payment amount detected', {\n                        methodType: methodType,\n                        paymentField: paymentField.val(),\n                        custom_price: paymentInput.val ? paymentInput.val() : '',\n                        formPaymentAmount: form.data('payment-amount') || '',\n                        pi: form.find('input[name=\"payment_intent_id\"]').val() || ''\n                    });\n                }\n            } catch (e) {}\n            try {\n                var debugUrl = 'https:\/\/okelks.org\/wp-admin\/admin-ajax.php';\n                if (typeof de_fb_obj !== 'undefined') {\n                    if (typeof de_fb_obj.ajax_url !== 'undefined') { debugUrl = de_fb_obj.ajax_url; }\n                }\n                var debugNonce = 'e933171a98';\n                if (typeof de_fb_obj !== 'undefined') {\n                    if (typeof de_fb_obj.fb_nonce !== 'undefined') { debugNonce = de_fb_obj.fb_nonce; }\n                }\n                var methodType = form.find('input[name=\"stripe_payment_method_type\"]').val() || '';\n                if (methodType) {\n                    jQuery.post(debugUrl, {\n                        action: 'de_fb_stripe_debug_log',\n                        fb_nonce: debugNonce,\n                        event: 'payment_amount_invalid',\n                        form_id: 0,\n                        method_type: methodType,\n                        error: 'payment_amount_invalid',\n                        intent_id: form.find('input[name=\"payment_intent_id\"]').val() || ''\n                    });\n                }\n            } catch (e) {}\n            \/\/ Critical: stop here so we don't proceed into Stripe\/payment submission logic.\n            return false;\n        }\n        if ( required_check ) {\n            grecaptcha.ready(function() {\n                grecaptcha.execute('6LeD3FYmAAAAABB2E9Fqkax91RDD8ff2pEr5YKCr', {action: 'submit'}).then(function(token) {\n                    \/\/ Set token in the hidden input field (recaptcha_v3_token)\n                    form.find('input[name=\"recaptcha_v3_token\"]').val(token);\n                    \/\/ Also set as recaptcha_token for backend compatibility\n                    var existingToken = form.find('input[name=\"recaptcha_token\"]');\n                    if (existingToken.length) {\n                        existingToken.val(token);\n                    } else {\n                        form.append('<input type=\"hidden\" name=\"recaptcha_token\" value=\"' + token + '\">');\n                    }\n                    setTimeout(function() {\n                        if ( form.find('.file_preview_container .template-upload').length > 0 ) {\n                            e.preventDefault();\n                            $(this).addClass('submitting');\n                            de_fb_ajax_files_upload( form );\n                        } else {\n                            if ( form.find('.calculate_field').length > 0 ) {\n                                $('.calculation').hide();\n                                $.each(form.find('.calculate_field'), function() {\n                                    var calc_field_wrapper = $(this);\n                                    var field_id = calc_field_wrapper.attr('id');\n                                    field_id = field_id.replace('de_fb_', '').replace('_wrapper', '');\n                                    var field_type = calc_field_wrapper.find('.et_pb_contact_field').attr('data-type');\n                                    var check_values = 0;\n                                    if ( field_type == 'checkbox' || field_type == 'radio' ) {\n                                        $.each( calc_field_wrapper.find('input:checked'), function() {\n                                            check_values =  check_values + parseFloat( $(this).attr('data-calc_value') );\n                                        });\n                                        calc_field_wrapper.append('<input type=\"hidden\" name=\"' + field_id + '_calc_value\" value=\"' + check_values + '\">');\n                                    } else if ( field_type == 'select' ) {\n                                        if ( calc_field_wrapper.find('select option:selected').length > 0 ) {\n                                            check_values = parseFloat(calc_field_wrapper.find('select option:selected').attr('data-calc_value'));\n                                        }\n                                        calc_field_wrapper.append('<input type=\"hidden\" name=\"' + field_id + '_calc_value\" value=\"' + check_values + '\">');\n                                    }  else {\n                                        if ( calc_field_wrapper.find('input:not([type=\"hidden\"])').val() == '' ) {\n                                            var calc_default_value = calc_field_wrapper.find('input:not([type=\"hidden\"])').attr('data-calc_default');\n                                            calc_field_wrapper.append('<input type=\"hidden\" name=\"' + field_id + '_calc_value\" value=\"' + calc_default_value + '\">');\n                                        }\n                                    }\n\n                                });\n                            }\n                            if ( form.find('.divi-form-submit').hasClass('de_fb_ajax_submit') ) {\n                                if ( paymentEnabled !== 'on' ) {\n                                    $(this).addClass('submitting');\n                                    de_fb_ajax_form_submit( form[0] );\n                                    e.preventDefault();\n                                }\n                            } else {\n                                $(this).addClass('submitting');\n                                jQuery(\"#fb_form_null-0\").find('.fb_nonce').remove();\n                                jQuery(\"#fb_form_null-0\").append('<input type=\"hidden\" name=\"fb_nonce\" class=\"fb_nonce\" value=\"e933171a98\">');\n                                if (( !paymentInput.length || !paymentInput.hasClass('input-error') ) && ( !stripeEnabled || (stripeEnabled && !paymentErrors) )) {\n                                    jQuery(\"#fb_form_null-0\").unbind('submit').submit();\n                                } else {\n                                    form.find('.divi-form-submit').prop('disabled', false);\n                                }\n                            }   \n                        }\n                    }, 100);\n                });\n            });\n        } else {\n            e.preventDefault();\n        }\n\n        if (stripeEnabled) {\n            form.find('.divi-form-submit').prop('disabled', true);\n\n            \/\/ Divi 4 legacy Stripe flow (old UI + tokenization).\n            \/\/ Uses Stripe.js v2-style API: Stripe.setPublishableKey + Stripe.card.createToken.\n            if (!window.dfbIsDivi5) {\n                e.preventDefault();\n\n                let cardWrap = form.find('#card-wrap').first();\n                if (!cardWrap.length) {\n                    cardWrap = form.find('.card-wrap').first();\n                }\n                if (!cardWrap.length) {\n                    cardWrap = jQuery('.card-wrap').first();\n                }\n\n                let stripeKey = cardWrap.data('publishable-key') || cardWrap.data('publishableKey') || cardWrap.attr('data-publishable-key');\n\n                const showLegacyError = (msg) => {\n                    try {\n                        const cardErrors = form.find('.card-errors').first();\n                        const paymentErrors = form.find('.payment-errors').first();\n                        if (cardErrors.length) {\n                            cardErrors.text(msg);\n                        }\n                        if (paymentErrors.length) {\n                            paymentErrors.html(msg);\n                        }\n                    } catch (e2) {}\n                    form.find('.divi-form-submit').prop('disabled', false);\n                };\n\n                if (!stripeKey) {\n                    showLegacyError('Stripe is not configured. Please check your settings.');\n                    return false;\n                }\n                if (typeof Stripe === 'undefined' || !Stripe.card || !Stripe.setPublishableKey) {\n                    showLegacyError('Payment system not ready. Please refresh and try again.');\n                    return false;\n                }\n\n                try { Stripe.setPublishableKey(stripeKey); } catch (e2) {}\n\n                const number = String(form.find('#card-number').val() || '').replace(\/\\s+\/g, '');\n                const expMonth = String((form.find('#card-exp-month').val() || form.find('#card-expiry-month').val()) || '').trim();\n                const expYearRaw = String((form.find('#card-exp-year').val() || form.find('#card-expiry-year').val()) || '').trim();\n                const cvc = String(form.find('#card-cvc').val() || '').trim();\n\n                if (!number || !expMonth || !expYearRaw || !cvc) {\n                    showLegacyError('Please complete your card details.');\n                    return false;\n                }\n\n                let expYear = expYearRaw;\n                if (\/^\\d{2}$\/.test(expYearRaw)) {\n                    expYear = '20' + expYearRaw;\n                }\n\n                Stripe.card.createToken(\n                    {\n                        number: number,\n                        exp_month: expMonth,\n                        exp_year: expYear,\n                        cvc: cvc,\n                    },\n                    function(status, response) {\n                        if (response && response.error) {\n                            showLegacyError(response.error.message || 'Payment details are invalid.');\n                            return;\n                        }\n                        if (!response || !response.id) {\n                            showLegacyError('Payment could not be processed. Please try again.');\n                            return;\n                        }\n\n                        form.find('input[name=\"stripeToken\"]').remove();\n                        form.find('input[name=\"stripePaymentMethodId\"]').remove();\n                        form.append(\"<input type='hidden' name='stripeToken' value='\" + response.id + \"'\/>\");\n\n                        if (form.find('.divi-form-submit').hasClass('de_fb_ajax_submit')) {\n                            de_fb_ajax_form_submit(form[0]);\n                        } else {\n                            form.find('.fb_nonce').remove();\n                            form.append('<input type=\"hidden\" name=\"fb_nonce\" class=\"fb_nonce\" value=\"e933171a98\">');\n                            form.unbind('submit').submit();\n                        }\n                    }\n                );\n\n                return false;\n            }\n            \n            let cardElementContainer = form.find('.card-element');\n            let stripe = cardElementContainer.data('stripe-instance');\n            let cardElement = cardElementContainer.data('stripe-card-element');\n            let paymentElement = cardElementContainer.data('stripe-payment-element');\n            let clientSecret = cardElementContainer.data('client-secret');\n            \n            \/\/ FIRST: Check if PaymentIntent ID is already in the form (most reliable source)\n            let existingPaymentIntentInput = form.find('input[name=\"payment_intent_id\"]');\n            let paymentIntentId = null;\n            if (existingPaymentIntentInput.length) {\n                if (existingPaymentIntentInput.val()) {\n                    paymentIntentId = existingPaymentIntentInput.val();\n                }\n            }\n            \n            \/\/ SECOND: Try multiple keys from cardElementContainer - jQuery converts kebab-case to camelCase\n            if (!paymentIntentId) {\n                paymentIntentId = cardElementContainer.data('payment-intent-id') || \n                                  cardElementContainer.data('paymentIntentId') ||\n                                  cardElementContainer.data('paymentIntent-id');\n                if (paymentIntentId) {\n                }\n            }\n            \n            \/\/ THIRD: Check form's data attribute (fallback)\n            if (!paymentIntentId) {\n                paymentIntentId = form.data('payment-intent-id') || \n                                 form.data('paymentIntentId') ||\n                                 form.data('paymentIntent-id');\n                if (paymentIntentId) {\n                }\n            }\n            \n            \/\/ Debug: Log all possible sources of PaymentIntent ID\n            \n            \/\/ If PaymentIntent ID not found, check if we need to create one\n            \/\/ This can happen if amount was 0 on page load but is now > 0\n            if (!paymentIntentId) {\n                \/\/ Try sessionStorage first (prevents creating a second PI on fast submit \/ DOM re-render).\n                try {\n                    if (typeof sessionStorage !== 'undefined') {\n                        let storageFormId = '';\n                        try {\n                            storageFormId = form.attr('id') || '';\n                            if (typeof storageFormId === 'string') {\n                                if (storageFormId.indexOf('fb_form_') === 0) {\n                                    storageFormId = storageFormId.replace('fb_form_', '');\n                                }\n                            }\n                            if (!storageFormId) {\n                                try { storageFormId = form.find('input[name=\"form_key\"]').val() || ''; } catch (e) {}\n                                if (!storageFormId) { storageFormId = form.data('form-id') || ''; }\n                            }\n                        } catch (e) {}\n                        if (storageFormId) {\n                            let storedPi = sessionStorage.getItem('dfb_stripe_pi_' + storageFormId) || '';\n                            let storedAmt = sessionStorage.getItem('dfb_stripe_pi_amt_' + storageFormId) || '';\n                            let curAmt = 0;\n                            try { curAmt = parseFloat(form.find('input[name=\"de_fb_payment_amount\"]').first().val()) || 0; } catch (e) { curAmt = 0; }\n                            if (curAmt > 0 && storedPi) {\n                                let okToReuse = false;\n                                if (storedAmt) {\n                                    let sAmt = 0;\n                                    try { sAmt = parseFloat(storedAmt) || 0; } catch (e) { sAmt = 0; }\n                                    if (sAmt > 0) {\n                                        if (Math.abs(curAmt - sAmt) < 0.01) {\n                                            okToReuse = true;\n                                        }\n                                    }\n                                }\n                                if (okToReuse) {\n                                    paymentIntentId = storedPi;\n                                    cardElementContainer.data('payment-intent-id', paymentIntentId);\n                                    cardElementContainer.data('payment-intent-fetched', true);\n                                    form.data('payment-intent-id', paymentIntentId);\n                                    form.find('input[name=\"payment_intent_id\"]').remove();\n                                    form.append(\"<input type='hidden' name='payment_intent_id' value='\" + paymentIntentId + \"'\/>\");\n                                } else {\n                                    try {\n                                        sessionStorage.removeItem('dfb_stripe_pi_' + storageFormId);\n                                        sessionStorage.removeItem('dfb_stripe_pi_amt_' + storageFormId);\n                                        sessionStorage.removeItem('dfb_stripe_pi_token_' + storageFormId);\n                                    } catch (e) {}\n                                }\n                            } else if (storedPi && curAmt <= 0) {\n                                try {\n                                    sessionStorage.removeItem('dfb_stripe_pi_' + storageFormId);\n                                    sessionStorage.removeItem('dfb_stripe_pi_amt_' + storageFormId);\n                                    sessionStorage.removeItem('dfb_stripe_pi_token_' + storageFormId);\n                                } catch (e) {}\n                            }\n                        }\n                    }\n                } catch (e) {}\n                \n                \/\/ Get current amount from form - try multiple sources\n                let amountInput = form.find('input[name=\"de_fb_payment_amount\"]');\n                let currentAmount = 0;\n                if (amountInput.length) {\n                    currentAmount = parseFloat(amountInput.val()) || 0;\n                }\n                \n                \/\/ Also try card-wrap data attribute\n                if (currentAmount <= 0) {\n                    let cardWrap = form.find('.card-wrap');\n                    if (!cardWrap.length) {\n                        cardWrap = $('.card-wrap').first();\n                    }\n                    if (cardWrap.length) {\n                        currentAmount = parseFloat(cardWrap.data('payment-amount')) || 0;\n                    }\n                }\n\n                \/\/ For custom-price forms, trust the visible total (it can update before the hidden field updates).\n                try {\n                    if (form.find('.de_fb_form_field_custom_price').length) {\n                        let visibleAmt = 0;\n                        let hasVisibleAmt = false;\n                        try {\n                            let priceEl = form.find('#custom_price_wrapper .price').first();\n                            if (!priceEl.length) {\n                                priceEl = form.find('.plan-price .price').first();\n                            }\n                            if (priceEl.length) {\n                                visibleAmt = parseFloat((String(priceEl.text() || '')).replace(\/,\/g, '')) || 0;\n                                hasVisibleAmt = true;\n                            }\n                        } catch (e) { visibleAmt = 0; hasVisibleAmt = false; }\n                        if (hasVisibleAmt) {\n                            if (visibleAmt > 0) {\n                                currentAmount = visibleAmt;\n                                if (amountInput.length) {\n                                    amountInput.val(visibleAmt.toFixed(2)).trigger('input').trigger('change');\n                                }\n                            }\n                        }\n                    }\n                } catch (e) {}\n                \n                \n                \/\/ If amount > 0 and no PaymentIntent exists, create one now\n                if (currentAmount > 0) {\n                    \n                    \/\/ Get form ID\n                    let formId = form.data('form-id') || form.attr('id');\n                    if (typeof formId === 'string') {\n                        if (formId.indexOf('fb_form_') === 0) {\n                            formId = formId.replace('fb_form_', '');\n                        }\n                    }\n                    \n                    \/\/ Get currency\n                    let cardWrap = form.find('.card-wrap');\n                    if (!cardWrap.length) {\n                        cardWrap = $('.card-wrap').first();\n                    }\n                    let currency = cardWrap.length ? (cardWrap.data('payment-currency') || 'usd') : 'usd';\n                    let paymentMethodMode = cardWrap.length ? (cardWrap.data('stripe-payment-method-mode') || 'simple') : 'simple';\n                    \n                    \n                    \/\/ Mark as fetching to prevent duplicates\n                    cardElementContainer.data('payment-intent-fetching', true);\n                    \n                    \/\/ Create PaymentIntent synchronously (we need to wait for it)\n                    var ajaxUrl = 'https:\/\/okelks.org\/wp-admin\/admin-ajax.php';\n                    if (typeof de_fb_obj !== 'undefined') {\n                        if (typeof de_fb_obj.ajax_url !== 'undefined') {\n                            ajaxUrl = de_fb_obj.ajax_url;\n                        }\n                    }\n                    var fbNonce = 'e933171a98';\n                    if (typeof de_fb_obj !== 'undefined') {\n                        if (typeof de_fb_obj.fb_nonce !== 'undefined') {\n                            fbNonce = de_fb_obj.fb_nonce;\n                        }\n                    }\n                    \n                    \/\/ Per-checkout token to prevent duplicate PI creation (server uses it for reuse\/idempotency).\n                    var piToken = '';\n                    try {\n                        if (typeof sessionStorage !== 'undefined') {\n                            var storageFormId = '';\n                            try {\n                                storageFormId = form.attr('id') || '';\n                                if (typeof storageFormId === 'string') {\n                                    if (storageFormId.indexOf('fb_form_') === 0) {\n                                        storageFormId = storageFormId.replace('fb_form_', '');\n                                    }\n                                }\n                                if (!storageFormId) {\n                                    try {\n                                        storageFormId = form.find('input[name=\"form_key\"]').val() || '';\n                                    } catch (e) {}\n                                    if (!storageFormId) {\n                                        storageFormId = formId || '';\n                                    }\n                                }\n                            } catch (e) {}\n                            if (storageFormId) {\n                                var tokenKey = 'dfb_stripe_pi_token_' + storageFormId;\n                                piToken = sessionStorage.getItem(tokenKey) || '';\n                                if (!piToken) {\n                                    if (window.crypto) {\n                                        if (typeof window.crypto.randomUUID === 'function') {\n                                            piToken = window.crypto.randomUUID();\n                                        }\n                                    }\n                                    if (!piToken) {\n                                        piToken = 'tok_' + String(Date.now()) + '_' + Math.random().toString(16).slice(2);\n                                    }\n                                    try { sessionStorage.setItem(tokenKey, piToken); } catch (e) {}\n                                }\n                            }\n                        }\n                    } catch (e) {}\n                    \n                    try {\n                        $.ajax({\n                            url: ajaxUrl,\n                            type: 'POST',\n                            dataType: 'json',\n                            async: false, \/\/ Synchronous - we need to wait\n                            data: {\n                                action: 'de_fb_create_stripe_payment_intent',\n                                fb_nonce: fbNonce,\n                                form_id: formId,\n                                pi_token: piToken,\n                                amount: currentAmount,\n                                currency: currency,\n                                payment_method_mode: paymentMethodMode\n                            },\n                            success: function(response) {\n                                cardElementContainer.data('payment-intent-fetching', false);\n                                if (response.success) {\n                                    if (response.data) {\n                                        if (response.data.payment_intent_id) {\n                                            paymentIntentId = response.data.payment_intent_id;\n                                            cardElementContainer.data('payment-intent-id', paymentIntentId);\n                                            cardElementContainer.data('payment-intent-fetched', true);\n                                            form.data('payment-intent-id', paymentIntentId);\n                                            form.find('input[name=\"payment_intent_id\"]').remove();\n                                            form.append(\"<input type='hidden' name='payment_intent_id' value='\" + paymentIntentId + \"'\/>\");\n                                        } else {\n\n                                        }\n                                    } else {\n\n                                    }\n                                } else {\n\n                                }\n                            },\n                            error: function(xhr, status, error) {\n                                cardElementContainer.data('payment-intent-fetching', false);\n\n                            }\n                        });\n                    } catch (e) {\n                        cardElementContainer.data('payment-intent-fetching', false);\n\n                    }\n                } else {\n                }\n            }\n            \n            \/\/ If not initialized, try to initialize now\n            if (!stripe || (!cardElement && !paymentElement)) {\n                console.warn('Stripe Elements not found for form:', form.attr('id'));\n                \n                if (typeof Stripe !== 'undefined' && typeof initializeStripeElements === 'function') {\n                    initializeStripeElements();\n                    \/\/ Re-check after initialization\n                    cardElementContainer = form.find('.card-element');\n                    stripe = cardElementContainer.data('stripe-instance');\n                    cardElement = cardElementContainer.data('stripe-card-element');\n                    paymentElement = cardElementContainer.data('stripe-payment-element');\n                    clientSecret = cardElementContainer.data('client-secret');\n                    \/\/ Try multiple keys - jQuery converts kebab-case to camelCase\n                    paymentIntentId = cardElementContainer.data('payment-intent-id') || \n                                      cardElementContainer.data('paymentIntentId') ||\n                                      cardElementContainer.data('paymentIntent-id');\n                }\n                \n                if (!stripe || (!cardElement && !paymentElement)) {\n                    let errorMsg = 'Stripe Elements not initialized. ';\n                    if (typeof Stripe === 'undefined') {\n                        errorMsg += 'Stripe.js is not loaded. ';\n                    }\n                    if (!cardElementContainer.length) {\n                        errorMsg += 'Card element container not found. ';\n                    }\n                    errorMsg += 'Please refresh the page.';\n                    form.find(\".payment-errors\").html(errorMsg);\n                    form.find('.divi-form-submit').prop('disabled', false);\n                    return false;\n                }\n            }\n\n            $.ajax({\n                url: 'https:\/\/okelks.org\/wp-admin\/admin-ajax.php',\n                type: \"POST\",\n                data: { action: \"get_stripe_error_messages\", fb_nonce: 'e933171a98' },\n                success: function (response) {\n                    stripeErrorMessages = response;\n                },\n                error: function () {\n                    console.error(\"Failed to load Stripe error messages.\");\n                }\n            });\n\n            \/\/ Check if using Payment Element or Card Element\n            if (paymentElement && clientSecret) {\n                \/\/ Payment Element flow - use the stored elements instance from initialization\n                let elements = cardElementContainer.data('stripe-elements');\n                \n                if (!elements) {\n                    form.find('.divi-form-submit').prop('disabled', false);\n                    return false;\n                }\n\n                \/\/ Ensure the PaymentIntent amount is up-to-date right before confirmPayment.\n                \/\/ This is critical for redirect\/wallet methods (Amazon Pay, Klarna, etc.) which use the PaymentIntent amount.\n                try {\n                    let currentAmount = 0;\n                    let amountInput = form.find('input[name=\"de_fb_payment_amount\"]');\n                    if (amountInput.length) {\n                        currentAmount = parseFloat(amountInput.val()) || 0;\n                    }\n\n                    \/\/ Fallbacks: recompute from other sources in case the hidden amount is stale (common with calculated totals).\n                    try {\n                        if (currentAmount <= 0) {\n                            let pv = 0;\n                            let paymentInput = form.find('input[name=\"custom_price\"]');\n                            if (paymentInput.length) {\n                                pv = parseFloat(paymentInput.val()) || 0;\n                            }\n                            if (pv > 0) { currentAmount = pv; }\n                        }\n                        if (currentAmount <= 0) {\n                            let cardWrap = form.find('.card-wrap');\n                            if (!cardWrap.length) { cardWrap = jQuery('.card-wrap').first(); }\n                            if (cardWrap.length) {\n                                let cw = parseFloat(cardWrap.data('payment-amount')) || 0;\n                                if (cw > 0) { currentAmount = cw; }\n                            }\n                        }\n                        if (currentAmount <= 0) {\n                            let fa = parseFloat(form.data('payment-amount')) || 0;\n                            if (fa > 0) { currentAmount = fa; }\n                        }\n                        if (currentAmount <= 0) {\n                            let txt = '';\n                            try { txt = (form.find('.plan-price').first().text() || '').replace(\/,\/g, ''); } catch (e) {}\n                            let m = txt.match(\/-?\\d+(\\.\\d+)?\/);\n                            if (m) {\n                                if (m[0]) {\n                                    let tv = parseFloat(m[0]) || 0;\n                                    if (tv > 0) { currentAmount = tv; }\n                                }\n                            }\n                        }\n                    } catch (e) {}\n\n                    \/\/ Keep the hidden field in sync so the server receives the correct amount too.\n                    try {\n                        if (currentAmount > 0) {\n                            if (amountInput.length) {\n                                amountInput.val(currentAmount.toFixed(2)).trigger('input').trigger('change');\n                            }\n                        }\n                    } catch (e) {}\n\n                    if (currentAmount > 0) {\n                        \/\/ Find existing PaymentIntent ID (prefer hidden input).\n                        let existingPi = '';\n                        let piInput = form.find('input[name=\"payment_intent_id\"]');\n                        if (piInput.length) {\n                            if (piInput.val()) {\n                                existingPi = piInput.val();\n                            }\n                        }\n                        if (!existingPi) {\n                            if (paymentIntentId) {\n                                existingPi = paymentIntentId;\n                            }\n                        }\n\n                        if (existingPi) {\n                            \/\/ Determine currency\/mode.\n                            let cardWrap = form.find('.card-wrap');\n                            if (!cardWrap.length) {\n                                cardWrap = $('.card-wrap').first();\n                            }\n                            let currency = cardWrap.length ? (cardWrap.data('payment-currency') || 'usd') : 'usd';\n                            let paymentMethodMode = cardWrap.length ? (cardWrap.data('stripe-payment-method-mode') || 'simple') : 'simple';\n\n                            \/\/ Only update if amount changed since last sync.\n                            let lastIntentAmount = parseFloat(cardElementContainer.data('payment-intent-amount')) || 0;\n                            let needsUpdate = false;\n                            if (lastIntentAmount <= 0) {\n                                needsUpdate = true;\n                            } else if (Math.abs(currentAmount - lastIntentAmount) >= 0.0001) {\n                                needsUpdate = true;\n                            }\n\n                            if (needsUpdate) {\n                                var ajaxUrl = 'https:\/\/okelks.org\/wp-admin\/admin-ajax.php';\n                                if (typeof de_fb_obj !== 'undefined') {\n                                    if (typeof de_fb_obj.ajax_url !== 'undefined') {\n                                        ajaxUrl = de_fb_obj.ajax_url;\n                                    }\n                                }\n                                var fbNonce = 'e933171a98';\n                                if (typeof de_fb_obj !== 'undefined') {\n                                    if (typeof de_fb_obj.fb_nonce !== 'undefined') {\n                                        fbNonce = de_fb_obj.fb_nonce;\n                                    }\n                                }\n\n                                \/\/ Per-checkout token to prevent duplicate PI creation (server uses it for reuse\/idempotency).\n                                var piToken = '';\n                                try {\n                                    if (typeof sessionStorage !== 'undefined') {\n                                        var storageFormId = '';\n                                        try {\n                                            storageFormId = form.attr('id') || '';\n                                            if (typeof storageFormId === 'string') {\n                                                if (storageFormId.indexOf('fb_form_') === 0) {\n                                                    storageFormId = storageFormId.replace('fb_form_', '');\n                                                }\n                                            }\n                                            if (!storageFormId) {\n                                                try {\n                                                    storageFormId = form.find('input[name=\"form_key\"]').val() || '';\n                                                } catch (e) {}\n                                                if (!storageFormId) {\n                                                    storageFormId = formId || '';\n                                                }\n                                            }\n                                        } catch (e) {}\n                                        if (storageFormId) {\n                                            var tokenKey = 'dfb_stripe_pi_token_' + storageFormId;\n                                            piToken = sessionStorage.getItem(tokenKey) || '';\n                                            if (!piToken) {\n                                                if (window.crypto) {\n                                                    if (typeof window.crypto.randomUUID === 'function') {\n                                                        piToken = window.crypto.randomUUID();\n                                                    }\n                                                }\n                                                if (!piToken) {\n                                                    piToken = 'tok_' + String(Date.now()) + '_' + Math.random().toString(16).slice(2);\n                                                }\n                                                try { sessionStorage.setItem(tokenKey, piToken); } catch (e) {}\n                                            }\n                                        }\n                                    }\n                                } catch (e) {}\n\n                                $.ajax({\n                                    url: ajaxUrl,\n                                    type: 'POST',\n                                    dataType: 'json',\n                                    async: false, \/\/ Must complete before confirmPayment\n                                    data: {\n                                        action: 'de_fb_create_stripe_payment_intent',\n                                        fb_nonce: fbNonce,\n                                        form_id: formId,\n                                        pi_token: piToken,\n                                        amount: currentAmount,\n                                        currency: currency,\n                                        payment_method_mode: paymentMethodMode,\n                                        payment_intent_id: existingPi\n                                    },\n                                    success: function(response) {\n                                        if (response) {\n                                            if (response.success) {\n                                                if (response.data) {\n                                                    if (response.data.payment_intent_id) {\n                                                        paymentIntentId = response.data.payment_intent_id;\n                                                        cardElementContainer.data('payment-intent-id', paymentIntentId);\n                                                        form.find('input[name=\"payment_intent_id\"]').remove();\n                                                        form.append(\"<input type='hidden' name='payment_intent_id' value='\" + paymentIntentId + \"'\/>\");\n                                                        cardElementContainer.data('payment-intent-amount', currentAmount);\n                                                    }\n                                                }\n                                            }\n                                        }\n                                    }\n                                });\n\n                                \/\/ Refresh Elements state (so wallets\/redirect methods reflect latest amount).\n                                try {\n                                    if (elements) {\n                                        if (typeof elements.fetchUpdates === 'function') {\n                                            elements.fetchUpdates();\n                                        }\n                                    }\n                                } catch (e2) {}\n                            }\n                        }\n                    }\n                } catch (e1) {}\n\n                \/\/ PaymentIntent-only flow - confirm payment directly.\n                stripe.confirmPayment({\n                    elements: elements,\n                    confirmParams: {\n                        return_url: window.location.href\n                    },\n                    redirect: 'if_required'\n                }).then(function(result) {\n                        if (result.error) {\n                            let cardWrap = cardElementContainer.closest('.card-wrap');\n                            let displayError = cardWrap.length > 0 ? cardWrap.find('.card-errors') : form.find('.card-errors').first();\n                            displayError.text(result.error.message);\n                            form.find(\".payment-errors\").html(result.error.message);\n                            form.find('.divi-form-submit').prop('disabled', false);\n                            return false;\n                        }\n                        \n                        \/\/ Payment successful - add payment_intent_id to form\n                        if (result.paymentIntent && result.paymentIntent.id) {\n                            form.append(\"<input type='hidden' name='payment_intent_id' value='\" + result.paymentIntent.id + \"'\/>\");\n                            paymentIntentId = result.paymentIntent.id;\n                        } else if (paymentIntentId) {\n                            form.append(\"<input type='hidden' name='payment_intent_id' value='\" + paymentIntentId + \"'\/>\");\n                        }\n                        \n                        \/\/ If redirect was required, handle it\n                        if (result.paymentIntent && result.paymentIntent.status === 'requires_action') {\n                            return true;\n                        }\n                        \n                        \/\/ Clear cached PI\/token so a new checkout doesn't reuse a succeeded PaymentIntent.\n                        try {\n                            if (typeof sessionStorage !== 'undefined') {\n                                let storageFormId = '';\n                                try {\n                                    storageFormId = form.attr('id') || '';\n                                    if (typeof storageFormId === 'string') {\n                                        if (storageFormId.indexOf('fb_form_') === 0) {\n                                            storageFormId = storageFormId.replace('fb_form_', '');\n                                        }\n                                    }\n                                } catch (e) {}\n                                if (!storageFormId) {\n                                    try { storageFormId = form.find('input[name=\"form_key\"]').val() || ''; } catch (e) {}\n                                }\n                                if (storageFormId) {\n                                    \/\/ Avoid creating a new \"init\" PaymentIntent immediately after a successful payment.\n                                    \/\/ This prevents extra \"Incomplete\" entries in Stripe caused by post-submit resets.\n                                    try { sessionStorage.setItem('dfb_stripe_skip_init_' + storageFormId, String(Date.now())); } catch (e) {}\n                                    sessionStorage.removeItem('dfb_stripe_pi_' + storageFormId);\n                                    sessionStorage.removeItem('dfb_stripe_pi_token_' + storageFormId);\n                                    sessionStorage.removeItem('dfb_stripe_pi_amt_' + storageFormId);\n                                }\n                            }\n                        } catch (e) {}\n\n                        \/\/ Payment completed - proceed with form submission\n                        if ( ( ! paymentInput.length || ! paymentInput.hasClass('input-error') ) ) {\n                            if (form.find('.divi-form-submit').hasClass('de_fb_ajax_submit')) {\n                                e.preventDefault();\n                                let formElement = form[0];  \n                                if (formElement instanceof HTMLFormElement) {\n                                    de_fb_ajax_form_submit(formElement);\n                                } else {\n                                    console.error(\"Form is not a valid HTMLFormElement\");\n                                }\n                            } else {\n                                jQuery(\"#fb_form_null-0\").find('.fb_nonce').remove();\n                                jQuery(\"#fb_form_null-0\").append('<input type=\"hidden\" name=\"fb_nonce\" class=\"fb_nonce\" value=\"e933171a98\">');\n                                form.unbind('submit').submit();\n                            }\n                        } else {\n                            form.find('.divi-form-submit').prop('disabled', false);\n                        }\n                    }).catch(function(error) {\n                        let cardWrap = cardElementContainer.closest('.card-wrap');\n                        let displayError = cardWrap.length > 0 ? cardWrap.find('.card-errors') : form.find('.card-errors').first();\n                        displayError.text(error.message);\n                        form.find(\".payment-errors\").html(error.message);\n                        form.find('.divi-form-submit').prop('disabled', false);\n                    });\n            } else if (cardElement) {\n                \/\/ Card Element flow (backwards compatibility)\n                \/\/ Re-check PaymentIntent ID from cardElementContainer data (in case it was updated)\n                \/\/ Try multiple keys - jQuery converts kebab-case to camelCase\n                if (!paymentIntentId) {\n                    paymentIntentId = cardElementContainer.data('payment-intent-id') || \n                                      cardElementContainer.data('paymentIntentId') ||\n                                      cardElementContainer.data('paymentIntent-id');\n                }\n                \n                \/\/ Add PaymentIntent ID to form BEFORE creating payment method (if it exists)\n                \/\/ This ensures it's in the form data when submission happens\n                \/\/ Try multiple sources to find PaymentIntent ID\n                if (!paymentIntentId) {\n                    paymentIntentId = form.data('payment-intent-id') || \n                                     form.data('paymentIntentId') ||\n                                     form.data('paymentIntent-id');\n                }\n                if (!paymentIntentId) {\n                    let existingInput = form.find('input[name=\"payment_intent_id\"]');\n                    if (existingInput.length) {\n                        if (existingInput.val()) {\n                            paymentIntentId = existingInput.val();\n                        }\n                    }\n                \n                if (paymentIntentId) {\n                    \/\/ Remove any existing payment_intent_id input to avoid duplicates\n                    form.find('input[name=\"payment_intent_id\"]').remove();\n                    form.append(\"<input type='hidden' name='payment_intent_id' value='\" + paymentIntentId + \"'\/>\");\n                } else {\n\n                }\n                \n                if (!window.dfbIsDivi5) {\n                    stripe.createToken(cardElement).then(function(result) {\n                        if (result.error) {\n                            let errorType = result.error.code;\n                            let errorMessage = stripeErrorMessages[errorType] || result.error.message;\n                            let cardWrap = cardElementContainer.closest('.card-wrap');\n                            let displayError = cardWrap.length > 0 ? cardWrap.find('.card-errors') : form.find('.card-errors').first();\n                            displayError.text(errorMessage);\n                            form.find(\".payment-errors\").html(errorMessage);\n                            form.find('.divi-form-submit').prop('disabled', false);\n                            return false;\n                        }\n\n                        if (!result.token || !result.token.id) {\n                            let msg = 'Payment could not be processed. Please try again.';\n                            let cardWrap = cardElementContainer.closest('.card-wrap');\n                            let displayError = cardWrap.length > 0 ? cardWrap.find('.card-errors') : form.find('.card-errors').first();\n                            displayError.text(msg);\n                            form.find(\".payment-errors\").html(msg);\n                            form.find('.divi-form-submit').prop('disabled', false);\n                            return false;\n                        }\n\n                        form.find('input[name=\"stripeToken\"]').remove();\n                        form.find('input[name=\"stripePaymentMethodId\"]').remove();\n                        form.append(\"<input type='hidden' name='stripeToken' value='\" + result.token.id + \"'\/>\");\n\n                        if ( ( ! paymentInput.length || ! paymentInput.hasClass('input-error') ) ) {\n                            if (form.find('.divi-form-submit').hasClass('de_fb_ajax_submit')) {\n                                e.preventDefault();\n                                let formElement = form[0];\n                                if (formElement instanceof HTMLFormElement) {\n                                    de_fb_ajax_form_submit(formElement);\n                                } else {\n                                    console.error(\"Form is not a valid HTMLFormElement\");\n                                }\n                            } else {\n                                jQuery(\"#fb_form_null-0\").find('.fb_nonce').remove();\n                                jQuery(\"#fb_form_null-0\").append('<input type=\"hidden\" name=\"fb_nonce\" class=\"fb_nonce\" value=\"e933171a98\">');\n                                form.unbind('submit').submit();\n                            }\n                        } else {\n                            form.find('.divi-form-submit').prop('disabled', false);\n                        }\n                    }).catch(function(error) {\n                        let cardWrap = cardElementContainer.closest('.card-wrap');\n                        let displayError = cardWrap.length > 0 ? cardWrap.find('.card-errors') : form.find('.card-errors').first();\n                        displayError.text(error.message);\n                        form.find(\".payment-errors\").html(error.message);\n                        form.find('.divi-form-submit').prop('disabled', false);\n                    });\n                } else {\n                    stripe.createPaymentMethod({\n                        type: 'card',\n                        card: cardElement,\n                    }).then(function(result) {\n                        if (result.error) {\n                            let errorType = result.error.code;\n                            let errorMessage = stripeErrorMessages[errorType] || result.error.message;\n                            \/\/ Find the card-errors element within the same card-wrap container to avoid duplicates\n                            let cardWrap = cardElementContainer.closest('.card-wrap');\n                            let displayError = cardWrap.length > 0 ? cardWrap.find('.card-errors') : form.find('.card-errors').first();\n                            displayError.text(errorMessage);\n                            form.find(\".payment-errors\").html(errorMessage);\n                            form.find('.divi-form-submit').prop('disabled', false);\n                            return false;\n                        } else {\n                            form.append(\"<input type='hidden' name='stripePaymentMethodId' value='\" + result.paymentMethod.id + \"'\/>\");\n                            form.append(\"<input type='hidden' name='stripeToken' value='\" + result.paymentMethod.id + \"'\/>\");\n                            \n                            \/\/ Re-check PaymentIntent ID one more time (in case it was updated)\n                            \/\/ FIRST: Check form input (most reliable - it was added immediately when created)\n                            let finalPaymentIntentId = form.find('input[name=\"payment_intent_id\"]').val();\n                            \n                            \/\/ SECOND: Try multiple keys from data - jQuery converts kebab-case to camelCase\n                            if (!finalPaymentIntentId) {\n                                finalPaymentIntentId = paymentIntentId || \n                                                       cardElementContainer.data('payment-intent-id') ||\n                                                       cardElementContainer.data('paymentIntentId') ||\n                                                       cardElementContainer.data('paymentIntent-id') ||\n                                                       form.data('payment-intent-id') ||\n                                                       form.data('paymentIntentId') ||\n                                                       form.data('paymentIntent-id');\n                            }\n                            \n                            \/\/ Ensure PaymentIntent ID is in form (add if not already there)\n                            if (finalPaymentIntentId) {\n                                \/\/ Always ensure it's in the form, even if it was added before\n                                form.find('input[name=\"payment_intent_id\"]').remove(); \/\/ Remove any existing\n                                form.append(\"<input type='hidden' name='payment_intent_id' value='\" + finalPaymentIntentId + \"'\/>\");\n                                \n                                \/\/ Verify it's actually in the DOM\n                                let verifyInput = form.find('input[name=\"payment_intent_id\"]');\n                                if (verifyInput.length) {\n                                    if (verifyInput.val() === finalPaymentIntentId) {\n                                    } else {\n\n                                    }\n                                }\n                            } else {\n\n                            }\n                            \n                            if ( ( ! paymentInput.length || ! paymentInput.hasClass('input-error') ) ) {\n                                if (form.find('.divi-form-submit').hasClass('de_fb_ajax_submit')) {\n                                    e.preventDefault();\n                                    \n                                    \/\/ Final check: ensure PaymentIntent ID is in form before submission\n                                    let finalCheck = form.find('input[name=\"payment_intent_id\"]');\n                                    if (finalCheck.length) {\n                                    } else {\n\n                                    }\n                                    \n                                    let formElement = form[0];  \n                                    if (formElement instanceof HTMLFormElement) {\n                                        de_fb_ajax_form_submit(formElement);\n                                    } else {\n                                        console.error(\"Form is not a valid HTMLFormElement\");\n                                    }\n                                } else {\n                                    jQuery(\"#fb_form_null-0\").find('.fb_nonce').remove();\n                                    jQuery(\"#fb_form_null-0\").append('<input type=\"hidden\" name=\"fb_nonce\" class=\"fb_nonce\" value=\"e933171a98\">');\n                                    form.unbind('submit').submit();\n                                }\n                            } else {\n                                form.find('.divi-form-submit').prop('disabled', false);\n                            }\n                        }\n                    }).catch(function(error) {\n                        \/\/ Find the card-errors element within the same card-wrap container to avoid duplicates\n                        let cardWrap = cardElementContainer.closest('.card-wrap');\n                        let displayError = cardWrap.length > 0 ? cardWrap.find('.card-errors') : form.find('.card-errors').first();\n                        displayError.text(error.message);\n                        form.find(\".payment-errors\").html(error.message);\n                        form.find('.divi-form-submit').prop('disabled', false);\n                    });\n                }\n            } else {\n                \/\/ Neither Payment Element nor Card Element found\n                let errorMsg = 'Stripe Elements not initialized. Please refresh the page.';\n                form.find(\".payment-errors\").html(errorMsg);\n                form.find('.divi-form-submit').prop('disabled', false);\n                return false;\n            }\n\n            return false;\n        }\n        \n    });\n        (function() {\n        var $_form = jQuery(\"#fb_form_null-0\");\n        var $passInputs = $_form.find('input[name=\"de_fb_user_pass\"], input[name=\"user_pass\"], input[name=\"de_fb_pass_repeat\"], input[name=\"pass_repeat\"]');\n        $passInputs.on('input keyup', function() {\n            var $confirm = $_form.find('input[name=\"de_fb_pass_repeat\"], input[name=\"pass_repeat\"]').first();\n            if ($confirm.length) {\n                var $err = $confirm.closest('.et_pb_contact_field').next('.error');\n                if ($err.length && $err.attr('id')) { $confirm.removeAttr('aria-describedby'); }\n                $err.remove();\n            }\n        });\n    })();\n        });\n<\/script>\n        <\/div><\/form><script>\njQuery(document).ready(function($) {\n    \/\/ Wait for jQuery validation plugin to be loaded\n    if (typeof $.validator === 'undefined') {\n        console.error('jQuery Validation plugin not loaded');\n        return;\n    }\n    \n    let old_url = jQuery.validator.methods.url;\n    \n    jQuery.validator.addMethod('url', function(value, element) {\n        if (old_url.call(this, value, element)) {\n            return true;\n        }\n        \n        if (value && !value.startsWith('http:\/\/') && !value.startsWith('https:\/\/')) {\n            return old_url.call(this, 'http:\/\/' + value, element);\n        }\n        \n        return false;\n    }, \"Please enter a valid URL.\");\n\n    (function($){\n    var trim = function(s){ return (s || '').trim(); };\n    $.validator.methods.email = function (value, element) {\n        if (this.optional(element)) return true;\n        var v = trim(value);\n        return \/^[^\\s@]+@([^\\s@]+\\.)+[^\\s@]{2,}$\/.test(v);\n    };\n    })(jQuery);\n\n    $.validator.setDefaults({\n        highlight: function(element) {\n            $(element).addClass('input-error');\n            $(element).closest('.et_pb_contact_field').addClass('input-field-error');\n        },\n        unhighlight: function(element) {\n            $(element).removeClass('input-error');\n            $(element).removeAttr('aria-describedby');\n            $(element).closest('.et_pb_contact_field').removeClass('input-field-error');\n            $(element).closest('.et_pb_contact_field').find('label.error').remove();\n        }\n    });\n\n    $('#fb_form_null-0').validate({\n        normalizer: function(value) {\n            return $.trim(value);\n        },\n        errorPlacement: function(error, element) {\n            var fieldId = element.attr('id');\n            var errorId = fieldId ? fieldId + '_error' : null;\n            if (errorId) {\n                error.attr('id', errorId).attr('role', 'alert').attr('aria-live', 'polite');\n                element.attr('aria-describedby', errorId);\n            }\n            var message_position = element.attr('data-required_position');\n            if ( message_position == 'top' ) {\n                element.before(error);\n            } else {\n                element.after(error);\n            }\n        }\n    });\n\n    if ($('.de_fb_autocomplete').length > 0 && typeof init_autocomplete_fields == 'function') {\n        init_autocomplete_fields();\n    }\n});\n\nif ( window.history.replaceState ) {\n  window.history.replaceState( null, null, window.location.href );\n}\n\nif ( typeof form_grid_columns === 'function' ) {\n    form_grid_columns();\n}\n<\/script>\n        \n\t\t\t\t<\/div>\n\t\t\t<\/div><div class=\"et_pb_module de_fb_form_field de_fb_form_field_0 clearfix  grid_&#8221;et_pb_column_2_3&#8243;_12 &#8221;et_pb_column_2_3&#8243; et_pb_column\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_module_inner\">\n\t\t\t\t\t\t\t<div id=\"de_fb_&#8221;username&#8221;_wrapper\" class=\"field_wrapper search_filter_cont \" data-count=\"100\" >\r\n\t\t\t\t\t\t\t\t<p class=\"et_pb_contact_field\" data-type=\"input\">\r\n\t\t\t<input type=\"hidden\" name=\"field_title[]\" value=\"&#8221;Username&#8221;\"\/>\t\t\t\t\t\t\t<input type=\"text\" name=\"de_fb_&#8221;username&#8221;\" id=\"de_fb_&#8221;username&#8221;\" data-calc_default=\"0\" placeholder=\"&#8221;Username&#8221;\"   class=\"divi-form-builder-field input-field \" required value=\"\"  autocomplete=\"on\" \/>\r\n\t\t\t\t\t\t\t\t\t<\/p>\r\n\r\n\t\t\t\t\t<\/div>\r\n\n\t\t\t\t<\/div>\n\t\t\t<\/div><\/p>\n","protected":false},"author":254,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"class_list":["post-26916","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/okelks.org\/index.php?rest_route=\/wp\/v2\/pages\/26916","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/okelks.org\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/okelks.org\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/okelks.org\/index.php?rest_route=\/wp\/v2\/users\/254"}],"replies":[{"embeddable":true,"href":"https:\/\/okelks.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=26916"}],"version-history":[{"count":1,"href":"https:\/\/okelks.org\/index.php?rest_route=\/wp\/v2\/pages\/26916\/revisions"}],"predecessor-version":[{"id":987485378,"href":"https:\/\/okelks.org\/index.php?rest_route=\/wp\/v2\/pages\/26916\/revisions\/987485378"}],"wp:attachment":[{"href":"https:\/\/okelks.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=26916"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}