var bluesnap=function(){function p(){try{this.ccn=k("ccn"),this.cvv=k("cvv"),this.exp=k("exp")}catch(a){}}function k(a){return f.hostedPaymentFields.hasOwnProperty(a)?document.querySelector("[data-bluesnap="+f.hostedPaymentFields[a]+"]"):null}function l(a){var b=new p,b={ccn:b.ccn,cvv:b.cvv,exp:b.exp};try{return b[a]}catch(d){}}function q(){var a="";try{"_"!==e.token.slice(-1)&&(g="https://www"+e.token.slice(-1)+".bluesnap.com/services/hosted-payment-fields/v1.0/bluesnap.iframe.html#"),a=g}catch(b){}try{c.forEach(function(b){var d= l(b),c=a,e=window.btoa(document.location.origin+b);d.innerHTML=""})}catch(b){}}function m(a){l(a.tagId).querySelectorAll("iframe[id^='bluesnap-hosted-iframe-']")[0].contentWindow.postMessage(JSON.stringify(a),g.split("/services/")[0])}function r(a){c.forEach(function(b){m({tagId:b, event:a})})}function t(a){var b="color font font-family font-size font-style font-weight line-height opacity outline text-shadow transition".split(" "),d="#ccn #cvv #exp input :focus .valid .invalid #ccn:focus #cvv:focus #exp:focus #ccn.valid #cvv.valid #exp.valid #ccn.invalid #cvv.invalid #exp.invalid .valid:focus .invalid:focus".split(" ");if("object"===typeof a.style&&null!==a.style){for(var c in a.style){if(-1==d.indexOf(c))return[!1,"error"];for(var e in a.style[c])if(-1==b.indexOf(e))return[!1, "error"]}return[!0,"object"]}return[!0,"not an object"]}var g=document.querySelector("script[src*='bluesnap.hpf.mini.js']").src.split("/services/")[0]+"/services/hosted-payment-fields/v1.0/bluesnap.iframe.html#",e={token:"",style:{},ccnPlaceHolder:"Card number",cvvPlaceHolder:"CVC/CVV",expPlaceHolder:"MM/YYYY"},f={hostedPaymentFields:{},onFieldEventHandler:{}},c=[],n={cvv:!1,ccn:!1,exp:!1,responseJSON:{},setSuccess:function(a,b){this[a]=!0;if("ccn"===a){var d=JSON.parse(b);this.responseJSON.ccType= d.ccType;this.responseJSON.last4Digits=d.last4Digits;this.responseJSON.issuingCountry="Planet Earth";try{null!=d.issuingCountry&&(this.responseJSON.issuingCountry=d.issuingCountry)}catch(c){}}"exp"===a&&(this.responseJSON.exp=b);this.cvv&&this.ccn&&this.exp&&this.callback&&this.callback(this.responseJSON)},setCallBack:function(a){this.ccn=0>c.indexOf("ccn");this.cvv=0>c.indexOf("cvv");this.exp=0>c.indexOf("exp");this.callback=a}};(function(a,b,d){a.addEventListener?a.addEventListener(b,d,!1):a.attachEvent? a.attachEvent("on"+b,d):a["on"+b]=d})(window,"message",function(a){if(a.origin===g.split("/services/")[0]){var b="";if(a.data)try{b=JSON.parse(a.data)}catch(c){}if("implementation"==b.event)m({tagId:b.tagId,event:"implementation",tokenAndStyle:e});else if(a=b,"put"===a.event)n.setSuccess(a.tagId,a.param);else try{var d=a.event,h="on"+(d.charAt(0).toUpperCase()+d.slice(1));switch(h){case "onError":case "onEmpty":f.onFieldEventHandler[h](a.tagId,a.errorCode);break;case "onType":f.onFieldEventHandler[h](a.tagId, a.cardType);break;default:f.onFieldEventHandler[h](a.tagId)}}catch(c){}}});return{submitCredentials:function(a){n.setCallBack(a);r("put")},hostedPaymentFieldsCreation:function(a,b){c=[];b.hostedPaymentFields.hasOwnProperty("ccn")&&(c[c.length]="ccn");b.hostedPaymentFields.hasOwnProperty("cvv")&&(c[c.length]="cvv");b.hostedPaymentFields.hasOwnProperty("exp")&&(c[c.length]="exp");var d=t(b);d[0]&&("object"===d[1]?e.style=b.style:delete e.style,e.token=a,"undefined"!==typeof b.ccnPlaceHolder&&null!== b.ccnPlaceHolder&&(e.ccnPlaceHolder=b.ccnPlaceHolder),"undefined"!==typeof b.cvvPlaceHolder&&null!==b.cvvPlaceHolder&&(e.cvvPlaceHolder=b.cvvPlaceHolder),"undefined"!==typeof b.expPlaceHolder&&null!==b.expPlaceHolder&&(e.expPlaceHolder=b.expPlaceHolder),f.hostedPaymentFields=b.hostedPaymentFields,f.onFieldEventHandler=b.onFieldEventHandler,q())}}}();