// source --> https://edelhanf.de/wp-content/plugins/retainful/assets/store/js/retainful-store.js?ver=1.0.5 
if (typeof (rtfl_jquery) === 'undefined') {
    rtfl_jquery = jQuery.noConflict();
}

rtfl = window.rtfl || {};

(function (rtfl) {

    let Url = retainful_localize_data?.ajax_url ?? '';
    /**
     * Validate email address
     * @param {string} value - Email address to validate
     * @returns {boolean} - True if valid, false otherwise
     */
    function validateEmail(value) {
        var valid = true;
        if (!value || value.trim() === '') {
            return false;
        }
        if (value.indexOf('@') === -1) {
            valid = false;
        } else {
            var parts = value.split('@');
            if (parts.length !== 2 || !parts[0] || !parts[1]) {
                valid = false;
            } else {
                var domain = parts[1];
                if (domain.indexOf('.') === -1) {
                    valid = false;
                } else {
                    var domainParts = domain.split('.');
                    var ext = domainParts[domainParts.length - 1];
                    if (!ext || ext.length > 14 || ext.length < 2) {
                        valid = false;
                    }
                }
            }
        }
        return valid;
    }

    /**
     * Validate phone number
     * @param {string} value - Phone number to validate
     * @returns {boolean} - True if valid, false otherwise
     */
    function validatePhone(value) {
        if (!value || value.trim() === '') {
            return false;
        }
        // Remove common phone number characters for validation
        var cleaned = value.replace(/[\s\-\(\)\+]/g, '');
        // Check if it contains only digits and has reasonable length (at least 7 digits, max 15)
        return /^\d+$/.test(cleaned) && cleaned.length >= 7 && cleaned.length <= 15;
    }

    /**
     * Update checkout and track user data
     * @param {string} email - User email
     * @param {string} phone - User phone
     * @param {object} guestData - Guest data object
     */
    function updateCheckout(email, phone, guestData) {
        if (!Url) {
            return;
        }

        // Validate email if provided
        if (email && email.trim() !== '' && !validateEmail(email)) {
            // Invalid email, don't send request
            return;
        }

        if ( email && validateEmail( email ) ) {
            var previous = sessionStorage.getItem( 'rtfl_customer_email' );
            sessionStorage.setItem( 'rtfl_customer_email', email );
            // Notify product-view tracker that a customer was just identified
            if ( previous !== email ) {
                rtfl_jquery( document ).trigger( 'rtfl:customer_identified', [ email ] );
            }
        }

        // Validate phone if provided
        if (phone && phone.trim() !== '' && !validatePhone(phone)) {
            // Invalid phone, don't send request
            return;
        }

        // Add nonce to the request data
        if (typeof retainful_localize_data !== 'undefined' && retainful_localize_data.nonce) {
            guestData.nonce = retainful_localize_data.nonce;
        }

        rtfl_jquery.ajax({
            url: Url,
            type: "POST",
            dataType: 'json',
            data: guestData,
            success: function(response) {
                // Cart tracking updated successfully
                if (response && response.success) {
                    // Optionally trigger cart sync after user data is updated
                }
            },
            error: function(xhr, status, error) {
                // Handle error silently or log if needed
                console.error('Retainful: Failed to track user data', error);
            }
        });
    }

    // Track cart when checkout email field updates (Traditional WooCommerce Checkout)
    // Support both old selector (rnoc_allow_gdpr) and new selector (rtfl_allow_gdpr) for backward compatibility
    rtfl_jquery(document).on('change', 'input#billing_email,input#billing_first_name,input#billing_last_name,input#billing_phone,input#rtfl_allow_gdpr,input#rnoc_allow_gdpr,input#rtfl_sms_consent', function () {
        var rnoc_phone = rtfl_jquery("#billing_phone").val();
        var rnoc_email = rtfl_jquery("#billing_email").val();
        var ship_to_bill = rtfl_jquery("#ship-to-different-address-checkbox:checked").length;

        // Get marketing consent checkbox value (support both old and new selectors)
        var marketing_consent_checkbox = rtfl_jquery('input#rtfl_allow_gdpr');
        if (marketing_consent_checkbox.length === 0) {
            marketing_consent_checkbox = rtfl_jquery('input#rnoc_allow_gdpr');
        }
        var allow_gdpr = marketing_consent_checkbox.is(':checked');

        // Get SMS consent checkbox value
        var sms_consent_checkbox = rtfl_jquery('input#rtfl_sms_consent');
        var sms_consent = sms_consent_checkbox.is(':checked');
        var guest_data = {
            billing_first_name: rtfl_jquery('#billing_first_name').val(),
            billing_last_name: rtfl_jquery('#billing_last_name').val(),
            billing_company: rtfl_jquery('#billing_company').val(),
            billing_address_1: rtfl_jquery('#billing_address_1').val(),
            billing_address_2: rtfl_jquery('#billing_address_2').val(),
            billing_city: rtfl_jquery('#billing_city').val(),
            billing_state: rtfl_jquery('#billing_state').val(),
            billing_postcode: rtfl_jquery('#billing_postcode').val(),
            billing_country: rtfl_jquery('#billing_country').val(),
            billing_phone: rtfl_jquery('#billing_phone').val(),
            billing_email: rtfl_jquery('#billing_email').val(),
            ship_to_billing: ship_to_bill,
            order_notes: rtfl_jquery('#order_comments').val(),
            shipping_first_name: rtfl_jquery('#shipping_first_name').val(),
            shipping_last_name: rtfl_jquery('#shipping_last_name').val(),
            shipping_company: rtfl_jquery('#shipping_company').val(),
            shipping_address_1: rtfl_jquery('#shipping_address_1').val(),
            shipping_address_2: rtfl_jquery('#shipping_address_2').val(),
            shipping_city: rtfl_jquery('#shipping_city').val(),
            shipping_state: rtfl_jquery('#shipping_state').val(),
            shipping_postcode: rtfl_jquery('#shipping_postcode').val(),
            shipping_country: rtfl_jquery('#shipping_country').val(),
            allow_gdpr: allow_gdpr,
            sms_consent: sms_consent,
            cart_token: localStorage.getItem('retainful_ac_cart_token'),
            action: 'rnoc_track_user_data'
        };

        updateCheckout(rnoc_email, rnoc_phone, guest_data);
    });

    // Track cart when checkout email field updates (WooCommerce Blocks Checkout)
    // Block Checkout uses name attributes with namespace format: rtfl--allow_gdpr or data attributes
    // We need to listen for multiple possible selectors to catch all cases
    rtfl_jquery(document).on('change', '.wp-block-woocommerce-checkout input[type="email"],.wp-block-woocommerce-checkout input[type="tel"],.wp-block-woocommerce-checkout input[name*="rtfl"],.wp-block-woocommerce-checkout input[name*="rnoc"],.wp-block-woocommerce-checkout input[id*="rtfl"],.wp-block-woocommerce-checkout input[id*="rnoc"]', function () {
        
        var rnoc_email = rtfl_jquery(".wp-block-woocommerce-checkout input[type='email']").first().val();
        var rnoc_phone = rtfl_jquery(".wp-block-woocommerce-checkout input[type='tel']").first().val();

        // Get marketing consent checkbox value
        // Block Checkout converts rtfl/allow_gdpr to name="rtfl--allow_gdpr" or similar format
        var marketing_consent_checkbox =
        rtfl_jquery('.wp-block-woocommerce-checkout #contact-rtfl-allow_gdpr').length
            ? rtfl_jquery('.wp-block-woocommerce-checkout #contact-rtfl-allow_gdpr')
            : rtfl_jquery('.wp-block-woocommerce-checkout #order-rtfl-allow_gdpr');
        
         var allow_gdpr = marketing_consent_checkbox.is(':checked');

        // Get SMS consent checkbox value
        // Block Checkout converts rtfl/sms_consent to name="rtfl--sms_consent" or similar format
        var sms_consent_checkbox =
        rtfl_jquery('.wp-block-woocommerce-checkout #billing-rtfl-sms_consent').length
            ? rtfl_jquery('.wp-block-woocommerce-checkout #billing-rtfl-sms_consent')
            : rtfl_jquery('.wp-block-woocommerce-checkout #order-rtfl-sms_consent');

        var sms_consent = sms_consent_checkbox.is(':checked');


        var guest_data = {
            billing_first_name: rtfl_jquery('.wp-block-woocommerce-checkout #billing-first_name').first().val() || '',
            billing_last_name: rtfl_jquery('.wp-block-woocommerce-checkout #billing-last_name').first().val() || '',
            billing_address_1: rtfl_jquery('.wp-block-woocommerce-checkout #billing-address_1').first().val() || '',
            billing_address_2: rtfl_jquery('.wp-block-woocommerce-checkout #billing-address_2').first().val() || '',
            billing_city: rtfl_jquery('.wp-block-woocommerce-checkout #billing-city').first().val() || '',
            billing_postcode: rtfl_jquery('.wp-block-woocommerce-checkout #billing-postcode').first().val() || '',
            billing_phone: rnoc_phone || '',
            billing_email: rnoc_email || '',
            allow_gdpr: allow_gdpr,
            sms_consent: sms_consent,
            ship_to_billing: 1,
            cart_token: localStorage.getItem('retainful_ac_cart_token'),
            action: 'rnoc_track_user_data'
        };

        updateCheckout(rnoc_email, rnoc_phone, guest_data);
    });

    rtfl_jquery(document).on("retainful-form-submitted", function (e, email) {
        if (e.email === undefined) {
            return;
        }
        var guest_data = {
            action: 'rnoc_track_user_data',
            billing_email: e.email
        };
        updateCheckout(e.email, '', guest_data);
    });


    rtfl_jquery(document).ready(function(){
        maybeTrack();
        // This runs when a product page is viewed
        /*if (typeof retainful_localize_data !== 'undefined' &&
            retainful_localize_data.viewed_product &&
            retainful_localize_data.viewed_product.product_id) {

            var productData = retainful_localize_data.viewed_product;
            var productId = productData.product_id;
            var quantity = productData.quantity || 0;

            window.wc_product = {
                id: productId,
                quantity: quantity
            };

        
        }*/
    });
    var trackingConfig = (typeof retainful_localize_data !== 'undefined')
    ? retainful_localize_data.viewed_product_tracking
    : null;

    if ( !trackingConfig || !trackingConfig.enabled ) return;

    var viewedProduct = (typeof retainful_localize_data !== 'undefined')
        ? retainful_localize_data.viewed_product
    : null;

    if ( !viewedProduct || !viewedProduct.product_id ) return;

    var productId    = parseInt( viewedProduct.product_id, 10 );
    var dedupMinutes = parseInt( trackingConfig.dedup_window || 30, 10 );

    /**
     * Get identified email: PHP-injected (logged in / WC session) OR
     * stored by the checkout field tracker in sessionStorage.
     */
    function getIdentifiedEmail() {
        // PHP-injected email (logged-in user or existing WC session)
        if ( trackingConfig.customer_email && trackingConfig.customer_email !== '' ) {
            return trackingConfig.customer_email;
        }
        // Written by the checkout field onChange handler when guest types email
        return sessionStorage.getItem( 'rtfl_customer_email' ) || '';
    }

    function isProductTrackEnabled() {
        return trackingConfig && trackingConfig.enabled;
    }

    /**
     * Check if this product view was already sent within the dedup window.
     * Key: rtfl_pv_{email_hash}_{product_id}
     * Value: timestamp of last send
     */
    function isDuplicate( email, productId ) {
        var key  = 'rtfl_pv_' + hashString( email ) + '_' + productId;
        var last = sessionStorage.getItem( key );
        if ( !last ) return false;
        var elapsed = ( Date.now() - parseInt( last, 10 ) ) / 1000 / 60; // minutes
        return elapsed < dedupMinutes;
    }

    function markAsSent( email, productId ) {
        var key = 'rtfl_pv_' + hashString( email ) + '_' + productId;
        sessionStorage.setItem( key, Date.now().toString() );
    }

    /** Tiny non-cryptographic hash — just enough for a sessionStorage key */
    function hashString( str ) {
        var h = 0;
        for ( var i = 0; i < str.length; i++ ) {
            h = ( Math.imul( 31, h ) + str.charCodeAt( i ) ) | 0;
        }
        return Math.abs( h ).toString( 36 );
    }

    function sendViewedProductEvent( email ) {
        if ( !Url || !email ) return;
        var isEnabled = isProductTrackEnabled();
        if( !isEnabled ) return;
        rtfl_jquery.ajax({
            url:      Url,
            type:     'POST',
            dataType: 'json',
            data: {
                action:     'rtfl_track_product_viewed',
                nonce:      retainful_localize_data.nonce,
                product_id: productId,
                email:      email,
            },
            success: function ( response ) {
                if ( response && response.success ) {
                    markAsSent( email, productId );
                }
            },
            error: function () {
                // Silent — non-critical tracking event
            }
        });
    }

    /**
     * Main entry: fire once on page load if customer is identified.
     * If not yet identified (anonymous visitor), listen for the checkout
     * field tracker to capture the email and fire then.
     */
    function maybeTrack() {
        var isEnabled = isProductTrackEnabled();
        if( !isEnabled ) return;
        var email = getIdentifiedEmail();
        if ( email && !isDuplicate( email, productId ) ) {
            if(typeof productId == 'undefined') return;
            sendViewedProductEvent( email );
            return;
        }

        // Anonymous visitor — wait for email identification from checkout tracker.
        // The checkout onChange handler stores email in sessionStorage as
        // 'rtfl_customer_email'; we listen for a custom event it dispatches.
        /*rtfl_jquery( document ).one( 'rtfl:customer_identified', function ( e, identifiedEmail ) {
            if ( identifiedEmail && !isDuplicate( identifiedEmail, productId ) ) {
                sendViewedProductEvent( identifiedEmail );
            }
        });*/
    }
})(rtfl_jquery);
// source --> https://edelhanf.de/wp-content/plugins/woocommerce/assets/js/jquery-payment/jquery.payment.min.js?ver=3.0.0-wc.10.8.1 
jQuery(function(t){(function(){var e,n,r,a,i,o,l,u,s,c,h,p,f,g,v,d,m,y,C,T,w,$,S,D=[].slice,k=[].indexOf||function(t){for(var e=0,n=this.length;e<n;e++)if(e in this&&this[e]===t)return e;return-1};(t=window.jQuery||window.Zepto||window.$).payment={},t.payment.fn={},t.fn.payment=function(){var e,n;return n=arguments[0],e=2<=arguments.length?D.call(arguments,1):[],t.payment.fn[n].apply(this,e)},a=/(\d{1,4})/g,t.payment.cards=r=[{type:"maestro",patterns:[5018,502,503,506,56,58,639,6220,67],format:a,length:[12,13,14,15,16,17,18,19],cvcLength:[3],luhn:!0},{type:"forbrugsforeningen",patterns:[600],format:a,length:[16],cvcLength:[3],luhn:!0},{type:"dankort",patterns:[5019],format:a,length:[16],cvcLength:[3],luhn:!0},{type:"visa",patterns:[4],format:a,length:[13,16],cvcLength:[3],luhn:!0},{type:"mastercard",patterns:[51,52,53,54,55,22,23,24,25,26,27],format:a,length:[16],cvcLength:[3],luhn:!0},{type:"amex",patterns:[34,37],format:/(\d{1,4})(\d{1,6})?(\d{1,5})?/,length:[15],cvcLength:[3,4],luhn:!0},{type:"dinersclub",patterns:[30,36,38,39],format:/(\d{1,4})(\d{1,6})?(\d{1,4})?/,length:[14],cvcLength:[3],luhn:!0},{type:"discover",patterns:[60,64,65,622],format:a,length:[16],cvcLength:[3],luhn:!0},{type:"unionpay",patterns:[62,88],format:a,length:[16,17,18,19],cvcLength:[3],luhn:!1},{type:"jcb",patterns:[35],format:a,length:[16],cvcLength:[3],luhn:!0}],e=function(t){var e,n,a,i,o,l,u;for(t=(t+"").replace(/\D/g,""),a=0,o=r.length;a<o;a++)for(i=0,l=(u=(e=r[a]).patterns).length;i<l;i++)if(n=u[i]+"",t.substr(0,n.length)===n)return e},n=function(t){var e,n,a;for(n=0,a=r.length;n<a;n++)if((e=r[n]).type===t)return e},p=function(t){var e,n,r,a,i,o;for(r=!0,a=0,i=0,o=(n=(t+"").split("").reverse()).length;i<o;i++)e=n[i],e=parseInt(e,10),(r=!r)&&(e*=2),e>9&&(e-=9),a+=e;return a%10==0},h=function(t){var e;return null!=t.prop("selectionStart")&&t.prop("selectionStart")!==t.prop("selectionEnd")||!(null==("undefined"!=typeof document&&null!==document&&null!=(e=document.selection)?e.createRange:void 0)||!document.selection.createRange().text)},$=function(t,e){var n,r,a,i,o;try{r=e.prop("selectionStart")}catch(l){l,r=null}if(i=e.val(),e.val(t),null!==r&&e.is(":focus"))return r===i.length&&(r=t.length),i!==t&&(o=i.slice(r-1,+r+1||9e9),n=t.slice(r-1,+r+1||9e9),a=t[r],/\d/.test(a)&&o===a+" "&&n===" "+a&&(r+=1)),e.prop("selectionStart",r),e.prop("selectionEnd",r)},m=function(t){var e,n,r,a,i,o;for(null==t&&(t=""),"０１２３４５６７８９","0123456789",a="",i=0,o=(e=t.split("")).length;i<o;i++)n=e[i],(r="０１２３４５６７８９".indexOf(n))>-1&&(n="0123456789"[r]),a+=n;return a},d=function(e){var n;return n=t(e.currentTarget),setTimeout(function(){var t;return t=n.val(),t=(t=m(t)).replace(/\D/g,""),$(t,n)})},g=function(e){var n;return n=t(e.currentTarget),setTimeout(function(){var e;return e=n.val(),e=m(e),e=t.payment.formatCardNumber(e),$(e,n)})},l=function(n){var r,a,i,o,l,u,s;if(i=String.fromCharCode(n.which),/^\d+$/.test(i)&&(r=t(n.currentTarget),s=r.val(),a=e(s+i),o=(s.replace(/\D/g,"")+i).length,u=16,a&&(u=a.length[a.length.length-1]),!(o>=u||null!=r.prop("selectionStart")&&r.prop("selectionStart")!==s.length)))return(l=a&&"amex"===a.type?/^(\d{4}|\d{4}\s\d{6})$/:/(?:^|\s)(\d{4})$/).test(s)?(n.preventDefault(),setTimeout(function(){return r.val(s+" "+i)})):l.test(s+i)?(n.preventDefault(),setTimeout(function(){return r.val(s+i+" ")})):void 0},i=function(e){var n,r;if(n=t(e.currentTarget),r=n.val(),8===e.which&&(null==n.prop("selectionStart")||n.prop("selectionStart")===r.length))return/\d\s$/.test(r)?(e.preventDefault(),setTimeout(function(){return n.val(r.replace(/\d\s$/,""))})):/\s\d?$/.test(r)?(e.preventDefault(),setTimeout(function(){return n.val(r.replace(/\d$/,""))})):void 0},v=function(e){var n;return n=t(e.currentTarget),setTimeout(function(){var e;return e=n.val(),e=m(e),e=t.payment.formatExpiry(e),$(e,n)})},u=function(e){var n,r,a;if(r=String.fromCharCode(e.which),/^\d+$/.test(r))return n=t(e.currentTarget),a=n.val()+r,/^\d$/.test(a)&&"0"!==a&&"1"!==a?(e.preventDefault(),setTimeout(function(){return n.val("0"+a+" / ")})):/^\d\d$/.test(a)?(e.preventDefault(),setTimeout(function(){var t,e;return t=parseInt(a[0],10),(e=parseInt(a[1],10))>2&&0!==t?n.val("0"+t+" / "+e):n.val(a+" / ")})):void 0},s=function(e){var n,r,a;if(r=String.fromCharCode(e.which),/^\d+$/.test(r))return a=(n=t(e.currentTarget)).val(),/^\d\d$/.test(a)?n.val(a+" / "):void 0},c=function(e){var n,r,a;if("/"===(a=String.fromCharCode(e.which))||" "===a)return r=(n=t(e.currentTarget)).val(),/^\d$/.test(r)&&"0"!==r?n.val("0"+r+" / "):void 0},o=function(e){var n,r;if(n=t(e.currentTarget),r=n.val(),8===e.which&&(null==n.prop("selectionStart")||n.prop("selectionStart")===r.length))return/\d\s\/\s$/.test(r)?(e.preventDefault(),setTimeout(function(){return n.val(r.replace(/\d\s\/\s$/,""))})):void 0},f=function(e){var n;return n=t(e.currentTarget),setTimeout(function(){var t;return t=n.val(),t=(t=m(t)).replace(/\D/g,"").slice(0,4),$(t,n)})},w=function(t){var e;return!(!t.metaKey&&!t.ctrlKey)||32!==t.which&&(0===t.which||(t.which<33||(e=String.fromCharCode(t.which),!!/[\d\s]/.test(e))))},C=function(n){var r,a,i,o;if(r=t(n.currentTarget),i=String.fromCharCode(n.which),/^\d+$/.test(i)&&!h(r))return o=(r.val()+i).replace(/\D/g,""),(a=e(o))?o.length<=a.length[a.length.length-1]:o.length<=16},T=function(e){var n,r;if(n=t(e.currentTarget),r=String.fromCharCode(e.which),/^\d+$/.test(r)&&!h(n))return!((n.val()+r).replace(/\D/g,"").length>6)&&void 0},y=function(e){var n,r;if(n=t(e.currentTarget),r=String.fromCharCode(e.which),/^\d+$/.test(r)&&!h(n))return(n.val()+r).length<=4},S=function(e){var n,a,i,o,l;if(l=(n=t(e.currentTarget)).val(),o=t.payment.cardType(l)||"unknown",!n.hasClass(o))return a=function(){var t,e,n;for(n=[],t=0,e=r.length;t<e;t++)i=r[t],n.push(i.type);return n}(),n.removeClass("unknown"),n.removeClass(a.join(" ")),n.addClass(o),n.toggleClass("identified","unknown"!==o),n.trigger("payment.cardType",o)},t.payment.fn.formatCardCVC=function(){return this.on("keypress",w),this.on("keypress",y),this.on("paste",f),this.on("change",f),this.on("input",f),this},t.payment.fn.formatCardExpiry=function(){return this.on("keypress",w),this.on("keypress",T),this.on("keypress",u),this.on("keypress",c),this.on("keypress",s),this.on("keydown",o),this.on("change",v),this.on("input",v),this},t.payment.fn.formatCardNumber=function(){return this.on("keypress",w),this.on("keypress",C),this.on("keypress",l),this.on("keydown",i),this.on("keyup",S),this.on("paste",g),this.on("change",g),this.on("input",g),this.on("input",S),this},t.payment.fn.restrictNumeric=function(){return this.on("keypress",w),this.on("paste",d),this.on("change",d),this.on("input",d),this},t.payment.fn.cardExpiryVal=function(){return t.payment.cardExpiryVal(t(this).val())},t.payment.cardExpiryVal=function(t){var e,n,r;return e=(r=t.split(/[\s\/]+/,2))[0],2===(null!=(n=r[1])?n.length:void 0)&&/^\d+$/.test(n)&&(n=(new Date).getFullYear().toString().slice(0,2)+n),{month:e=parseInt(e,10),year:n=parseInt(n,10)}},t.payment.validateCardNumber=function(t){var n,r;return t=(t+"").replace(/\s+|-/g,""),!!/^\d+$/.test(t)&&(!!(n=e(t))&&(r=t.length,k.call(n.length,r)>=0&&(!1===n.luhn||p(t))))},t.payment.validateCardExpiry=function(t,e){var n,r,a;return"object"==typeof t&&"month"in t&&(t=(a=t).month,e=a.year),!(!t||!e)&&(t=t||0==t?t.toString().trim():"",e=e||0==e?e.toString().trim():"",!!/^\d+$/.test(t)&&(!!/^\d+$/.test(e)&&(1<=t&&t<=12&&(2===e.length&&(e=e<70?"20"+e:"19"+e),4===e.length&&(r=new Date(e,t),n=new Date,r.setMonth(r.getMonth()-1),r.setMonth(r.getMonth()+1,1),r>n)))))},t.payment.validateCardCVC=function(t,e){var r,a;return t=t||0==t?t.toString().trim():"",!!/^\d+$/.test(t)&&(null!=(r=n(e))?(a=t.length,k.call(r.cvcLength,a)>=0):t.length>=3&&t.length<=4)},t.payment.cardType=function(t){var n;return t&&(null!=(n=e(t))?n.type:void 0)||null},t.payment.formatCardNumber=function(n){var r,a,i,o;return n=n.replace(/\D/g,""),(r=e(n))?(i=r.length[r.length.length-1],n=n.slice(0,i),r.format.global?null!=(o=n.match(r.format))?o.join(" "):void 0:null!=(a=r.format.exec(n))?(a.shift(),(a=t.grep(a,function(t){return t})).join(" ")):void 0):n},t.payment.formatExpiry=function(t){var e,n,r,a;return(n=t.match(/^\D*(\d{1,2})(\D+)?(\d{1,4})?/))?(e=n[1]||"",r=n[2]||"",(a=n[3]||"").length>0?r=" / ":" /"===r?(e=e.substring(0,1),r=""):2===e.length||r.length>0?r=" / ":1===e.length&&"0"!==e&&"1"!==e&&(e="0"+e,r=" / "),e+r+a):""}}).call(this)});