(()=>{function t(t){this.elem=jQuery(t),this.captureName=!!this.elem.data("capture-name")&&this.elem.data("capture-name"),this.iconColour=!!this.elem.data("icon-colour")&&this.elem.data("icon-colour"),this.stripe=!!this.elem.data("stripe")&&this.elem.data("stripe"),this.stripe&&(this.captureName=!1),this.initCardNumberInput(),this.initNameInput(),this.initExpiryMonthInput(),this.initExpiryYearInput(),this.initCvcInput(),this.elem.empty(),this.setupCardNumberInput(),this.setupNameInput(),this.setupExpiryInput(),this.setupCvcInput(),this.iconColour&&this.setIconColour(this.iconColour),this.refreshCreditCardTypeIcon()}!function(e){var r={init:function(){return this.data("cardjs",new t(this)),this},cardNumber:function(){return this.data("cardjs").getCardNumber()},cardType:function(){return this.data("cardjs").getCardType()},name:function(){return this.data("cardjs").getName()},expiryMonth:function(){return this.data("cardjs").getExpiryMonth()},expiryYear:function(){return this.data("cardjs").getExpiryYear()},cvc:function(){return this.data("cardjs").getCvc()}};e.fn.CardJs=function(t){return r[t]?r[t].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof t&&t?void e.error("Method "+t+" does not exist on jQuery.CardJs"):r.init.apply(this,arguments)}}(jQuery),$((function(){$(".card-js").each((function(t,e){$(e).CardJs()}))})),t.prototype.constructor=t,t.KEYS={0:48,9:57,NUMPAD_0:96,NUMPAD_9:105,DELETE:46,BACKSPACE:8,ARROW_LEFT:37,ARROW_RIGHT:39,ARROW_UP:38,ARROW_DOWN:40,HOME:36,END:35,TAB:9,A:65,X:88,C:67,V:86},t.CREDIT_CARD_NUMBER_DEFAULT_MASK="XXXX XXXX XXXX XXXX",t.CREDIT_CARD_NUMBER_VISA_MASK="XXXX XXXX XXXX XXXX",t.CREDIT_CARD_NUMBER_MASTERCARD_MASK="XXXX XXXX XXXX XXXX",t.CREDIT_CARD_NUMBER_DISCOVER_MASK="XXXX XXXX XXXX XXXX",t.CREDIT_CARD_NUMBER_JCB_MASK="XXXX XXXX XXXX XXXX",t.CREDIT_CARD_NUMBER_AMEX_MASK="XXXX XXXXXX XXXXX",t.CREDIT_CARD_NUMBER_DINERS_MASK="XXXX XXXX XXXX XX",t.prototype.creditCardNumberMask=t.CREDIT_CARD_NUMBER_DEFAULT_MASK,t.CREDIT_CARD_NUMBER_PLACEHOLDER="Card number",t.NAME_PLACEHOLDER="Name on card",t.EXPIRY_MASK="XX / XX",t.EXPIRY_PLACEHOLDER="MM / YY",t.EXPIRY_USE_DROPDOWNS=!1,t.EXPIRY_NUMBER_OF_YEARS=10,t.CVC_MASK_3="XXX",t.CVC_MASK_4="XXXX",t.CVC_PLACEHOLDER="CVC",t.CREDIT_CARD_SVG='',t.LOCK_SVG='',t.CALENDAR_SVG='',t.USER_SVG='',t.MAIL_SVG='',t.INFORMATION_SVG='',t.keyCodeFromEvent=function(t){return t.which||t.keyCode},t.keyIsCommandFromEvent=function(t){return t.ctrlKey||t.metaKey},t.keyIsNumber=function(e){return t.keyIsTopNumber(e)||t.keyIsKeypadNumber(e)},t.keyIsTopNumber=function(e){var r=t.keyCodeFromEvent(e);return r>=t.KEYS[0]&&r<=t.KEYS[9]},t.keyIsKeypadNumber=function(e){var r=t.keyCodeFromEvent(e);return r>=t.KEYS.NUMPAD_0&&r<=t.KEYS.NUMPAD_9},t.keyIsDelete=function(e){return t.keyCodeFromEvent(e)==t.KEYS.DELETE},t.keyIsBackspace=function(e){return t.keyCodeFromEvent(e)==t.KEYS.BACKSPACE},t.keyIsDeletion=function(e){return t.keyIsDelete(e)||t.keyIsBackspace(e)},t.keyIsArrow=function(e){var r=t.keyCodeFromEvent(e);return r>=t.KEYS.ARROW_LEFT&&r<=t.KEYS.ARROW_DOWN},t.keyIsNavigation=function(e){var r=t.keyCodeFromEvent(e);return r==t.KEYS.HOME||r==t.KEYS.END},t.keyIsKeyboardCommand=function(e){var r=t.keyCodeFromEvent(e);return t.keyIsCommandFromEvent(e)&&(r==t.KEYS.A||r==t.KEYS.X||r==t.KEYS.C||r==t.KEYS.V)},t.keyIsTab=function(e){return t.keyCodeFromEvent(e)==t.KEYS.TAB},t.copyAllElementAttributes=function(t,e){$.each(t[0].attributes,(function(t,r){e.attr(r.nodeName,r.nodeValue)}))},t.numbersOnlyString=function(t){for(var e="",r=0;re||e>t.length)return 0;for(var n=0;ne||e>t.length)return 0;for(var n=0;n=t.KEYS[0]&&e<=t.KEYS[9]?e-t.KEYS[0]:e>=t.KEYS.NUMPAD_0&&e<=t.KEYS.NUMPAD_9?e-t.KEYS.NUMPAD_0:null},t.handleMaskedNumberInputKey=function(e,r){t.filterNumberOnlyKey(e);var n=e.which||e.keyCode,i=e.target,a=t.caretStartPosition(i),s=t.caretEndPosition(i),p=t.normaliseCaretPosition(r,a),c=t.normaliseCaretPosition(r,s),o=a,u=t.keyIsNumber(e),h=t.keyIsDelete(e),d=t.keyIsBackspace(e);if(u||h||d){e.preventDefault();var l=$(i).val(),y=t.numbersOnlyString(l),m=t.digitFromKeyCode(n),C=c>p;C&&(y=y.slice(0,p)+y.slice(c)),a!=r.length&&(u&&l.length<=r.length&&(y=y.slice(0,p)+m+y.slice(p),o=Math.max(t.denormaliseCaretPosition(r,p+1),t.denormaliseCaretPosition(r,p+2)-1)),h&&(y=y.slice(0,p)+y.slice(p+1))),0!=a&&d&&!C&&(y=y.slice(0,p-1)+y.slice(p),o=t.denormaliseCaretPosition(r,p-1)),$(i).val(t.applyFormatMask(y,r)),t.setCaretPosition(i,o)}},t.handleCreditCardNumberKey=function(e,r){t.handleMaskedNumberInputKey(e,r)},t.handleCreditCardNumberChange=function(t){},t.handleExpiryKey=function(e){t.handleMaskedNumberInputKey(e,t.EXPIRY_MASK)},t.prototype.getCardNumber=function(){return this.cardNumberInput.val()},t.prototype.getCardType=function(){return t.cardTypeFromNumber(this.getCardNumber())},t.prototype.getName=function(){return this.nameInput.val()},t.prototype.getExpiryMonth=function(){return this.expiryMonthInput.val()},t.prototype.getExpiryYear=function(){return this.expiryYearInput.val()},t.prototype.getCvc=function(){return this.cvcInput.val()},t.prototype.setIconColour=function(t){this.elem.find(".icon .svg").css({fill:t})},t.prototype.setIconColour=function(t){this.elem.find(".icon .svg").css({fill:t})},t.prototype.refreshCreditCardTypeIcon=function(){this.setCardTypeIconFromNumber(t.numbersOnlyString(this.cardNumberInput.val()))},t.prototype.clearCardTypeIcon=function(){this.elem.find(".card-number-wrapper .card-type-icon").removeClass("show")},t.prototype.setCardTypeIconAsVisa=function(){this.elem.find(".card-number-wrapper .card-type-icon").attr("class","card-type-icon show visa")},t.prototype.setCardTypeIconAsMasterCard=function(){this.elem.find(".card-number-wrapper .card-type-icon").attr("class","card-type-icon show master-card")},t.prototype.setCardTypeIconAsAmericanExpress=function(){this.elem.find(".card-number-wrapper .card-type-icon").attr("class","card-type-icon show american-express")},t.prototype.setCardTypeIconAsDiscover=function(){this.elem.find(".card-number-wrapper .card-type-icon").attr("class","card-type-icon show discover")},t.prototype.setCardTypeIconAsDiners=function(){this.elem.find(".card-number-wrapper .card-type-icon").attr("class","card-type-icon show diners")},t.prototype.setCardTypeIconAsJcb=function(){this.elem.find(".card-number-wrapper .card-type-icon").attr("class","card-type-icon show jcb")},t.prototype.setCardTypeIconFromNumber=function(e){switch(t.cardTypeFromNumber(e)){case"Visa Electron":case"Visa":this.setCardTypeAsVisa();break;case"Mastercard":this.setCardTypeAsMasterCard();break;case"AMEX":this.setCardTypeAsAmericanExpress();break;case"Discover":this.setCardTypeAsDiscover();break;case"Diners - Carte Blanche":case"Diners":this.setCardTypeAsDiners();break;case"JCB":this.setCardTypeAsJcb();break;default:this.clearCardType()}},t.prototype.setCardMask=function(t){this.creditCardNumberMask=t,this.cardNumberInput.attr("maxlength",t.length)},t.prototype.setCvc3=function(){this.cvcInput.attr("maxlength",t.CVC_MASK_3.length)},t.prototype.setCvc4=function(){this.cvcInput.attr("maxlength",t.CVC_MASK_4.length)},t.prototype.clearCardType=function(){this.clearCardTypeIcon(),this.setCardMask(t.CREDIT_CARD_NUMBER_DEFAULT_MASK),this.setCvc3()},t.prototype.setCardTypeAsVisa=function(){this.setCardTypeIconAsVisa(),this.setCardMask(t.CREDIT_CARD_NUMBER_VISA_MASK),this.setCvc3()},t.prototype.setCardTypeAsMasterCard=function(){this.setCardTypeIconAsMasterCard(),this.setCardMask(t.CREDIT_CARD_NUMBER_MASTERCARD_MASK),this.setCvc3()},t.prototype.setCardTypeAsAmericanExpress=function(){this.setCardTypeIconAsAmericanExpress(),this.setCardMask(t.CREDIT_CARD_NUMBER_AMEX_MASK),this.setCvc4()},t.prototype.setCardTypeAsDiscover=function(){this.setCardTypeIconAsDiscover(),this.setCardMask(t.CREDIT_CARD_NUMBER_DISCOVER_MASK),this.setCvc3()},t.prototype.setCardTypeAsDiners=function(){this.setCardTypeIconAsDiners(),this.setCardMask(t.CREDIT_CARD_NUMBER_DINERS_MASK),this.setCvc3()},t.prototype.setCardTypeAsJcb=function(){this.setCardTypeIconAsJcb(),this.setCardMask(t.CREDIT_CARD_NUMBER_JCB_MASK),this.setCvc3()},t.prototype.initCardNumberInput=function(){var e=this;this.cardNumberInput=this.elem.find(".card-number"),this.cardNumberInput[0]?this.cardNumberInput.detach():this.cardNumberInput=$(""),this.cardNumberInput.attr("type","tel"),this.cardNumberInput.attr("placeholder")||this.cardNumberInput.attr("placeholder",t.CREDIT_CARD_NUMBER_PLACEHOLDER),this.cardNumberInput.attr("maxlength",this.creditCardNumberMask.length),this.cardNumberInput.attr("x-autocompletetype","cc-number"),this.cardNumberInput.attr("autocompletetype","cc-number"),this.cardNumberInput.attr("autocorrect","off"),this.cardNumberInput.attr("spellcheck","off"),this.cardNumberInput.attr("autocapitalize","off"),this.cardNumberInput.keydown((function(r){t.handleCreditCardNumberKey(r,e.creditCardNumberMask)})),this.cardNumberInput.keyup((function(t){e.refreshCreditCardTypeIcon()})),this.cardNumberInput.change(t.handleCreditCardNumberChange)},t.prototype.initNameInput=function(){this.nameInput=this.elem.find(".name"),this.nameInput[0]?(this.captureName=!0,this.nameInput.detach()):this.nameInput=$(""),this.nameInput.attr("placeholder")||this.nameInput.attr("placeholder",t.NAME_PLACEHOLDER)},t.prototype.initExpiryMonthInput=function(){this.expiryMonthInput=this.elem.find(".expiry-month"),this.expiryMonthInput[0]?this.expiryMonthInput.detach():this.expiryMonthInput=$("")},t.prototype.initExpiryYearInput=function(){this.expiryYearInput=this.elem.find(".expiry-year"),this.expiryYearInput[0]?this.expiryYearInput.detach():this.expiryYearInput=$("")},t.prototype.initCvcInput=function(){this.cvcInput=this.elem.find(".cvc"),this.cvcInput[0]?this.cvcInput.detach():this.cvcInput=$(""),this.cvcInput.attr("type","tel"),this.cvcInput.attr("placeholder")||this.cvcInput.attr("placeholder",t.CVC_PLACEHOLDER),this.cvcInput.attr("maxlength",t.CVC_MASK_3.length),this.cvcInput.attr("x-autocompletetype","cc-csc"),this.cvcInput.attr("autocompletetype","cc-csc"),this.cvcInput.attr("autocorrect","off"),this.cvcInput.attr("spellcheck","off"),this.cvcInput.attr("autocapitalize","off"),this.cvcInput.keydown(t.filterNumberOnlyKey)},t.prototype.setupCardNumberInput=function(){this.stripe&&this.cardNumberInput.attr("data-stripe","number"),this.elem.append("
");var e=this.elem.find(".card-number-wrapper");e.append(this.cardNumberInput),e.append("
"),e.append("
"),e.find(".icon").append(t.CREDIT_CARD_SVG)},t.prototype.setupNameInput=function(){if(this.captureName){this.elem.append("
");var e=this.elem.find(".name-wrapper");e.append(this.nameInput),e.append("
"),e.find(".icon").append(t.USER_SVG)}},t.prototype.setupExpiryInput=function(){this.elem.append("
");var e,r=this.elem.find(".expiry-wrapper");if(this.EXPIRY_USE_DROPDOWNS){e=$("
");var n=$(""),i=this.expiryMonthInput;t.copyAllElementAttributes(i,n),this.expiryMonthInput.remove(),this.expiryMonthInput=n;for(var a=$(""),s=parseInt((new Date).getFullYear().toString().substring(2,4)),p=0;p"+s+""),s=(s+1)%100;var c=this.expiryYearInput;t.copyAllElementAttributes(c,a),this.expiryYearInput.remove(),this.expiryYearInput=a,e.append(this.expiryMonthInput),e.append(this.expiryYearInput)}else{e=$("
"),this.expiryMonthInput=$(""),this.expiryYearInput=$(""),this.stripe&&(this.expiryMonthInput.attr("data-stripe","exp-month"),this.expiryYearInput.attr("data-stripe","exp-year")),this.expiryMonthYearInput=$(""),this.expiryMonthYearInput.attr("type","tel"),this.expiryMonthYearInput.attr("placeholder")||this.expiryMonthYearInput.attr("placeholder",t.EXPIRY_PLACEHOLDER),this.expiryMonthYearInput.attr("maxlength",t.EXPIRY_MASK.length),this.expiryMonthYearInput.attr("x-autocompletetype","cc-exp"),this.expiryMonthYearInput.attr("autocompletetype","cc-exp"),this.expiryMonthYearInput.attr("autocorrect","off"),this.expiryMonthYearInput.attr("spellcheck","off"),this.expiryMonthYearInput.attr("autocapitalize","off");var o=this;this.expiryMonthYearInput.keydown((function(e){t.handleExpiryKey(e);var r=o.expiryMonthYearInput.val();1==r.length&&parseInt(r)>1&&t.keyIsNumber(e)&&o.expiryMonthYearInput.val(t.applyFormatMask("0"+r,t.EXPIRY_MASK)),o.EXPIRY_USE_DROPDOWNS||null==o.expiryMonthYearInput||(o.expiryMonthInput.val(o.expiryMonth()),o.expiryYearInput.val(7==r.length?r.substr(5,2):null))})),this.expiryMonthYearInput.blur((function(t){o.refreshExpiryMonthValidation()})),e.append(this.expiryMonthYearInput),e.append(this.expiryMonthInput),e.append(this.expiryYearInput)}r.append(e),r.append("
"),r.find(".icon").append(t.CALENDAR_SVG)},t.prototype.setupCvcInput=function(){this.stripe&&this.cvcInput.attr("data-stripe","cvc"),this.elem.append("
");var e=this.elem.find(".cvc-wrapper");e.append(this.cvcInput),e.append("
"),e.find(".icon").append(t.LOCK_SVG)},t.prototype.expiryMonth=function(){if(!this.EXPIRY_USE_DROPDOWNS&&null!=this.expiryMonthYearInput){var t=this.expiryMonthYearInput.val();return t.length>=2?parseInt(t.substr(0,2)):null}return null},t.isValidMonth=function(t){return t>=1&&12>=t},t.isExpiryValid=function(e,r){var n=new Date,i=n.getMonth()+1,a=""+n.getFullYear();return 2==(""+r).length&&(r=a.substring(0,2)+""+r),i=parseInt(i),a=parseInt(a),e=parseInt(e),r=parseInt(r),t.isValidMonth(e)&&(r>a||r==a&&e>=i)},t.prototype.refreshExpiryMonthValidation=function(){t.isExpiryValid(this.getExpiryMonth(),this.getExpiryYear())?this.setExpiryMonthAsValid():this.setExpiryMonthAsInvalid()},t.prototype.setExpiryMonthAsValid=function(){this.EXPIRY_USE_DROPDOWNS||this.expiryMonthYearInput.parent().removeClass("has-error")},t.prototype.setExpiryMonthAsInvalid=function(){this.EXPIRY_USE_DROPDOWNS||this.expiryMonthYearInput.parent().addClass("has-error")}})();