(function(){this.CheckoutButton={};CheckoutButton.endPoint="https://www.SnappyCheckout.com/StripeCheckout/Pay";CheckoutButton.resources="https://s3.amazonaws.com/snappycheckout";CheckoutButton.options={};CheckoutButton.load=function(d){this.loadScript("https://checkout.stripe.com/checkout.js")};CheckoutButton.loadButton=function(d){null==d&&(d={});CheckoutButton.options=d;0==this.options.key.length?alert("Error: You must set your Stripe publishable key in your payment button."):(CheckoutButton.stripeCheckoutHandler=
StripeCheckout.configure({key:this.options.key,token:function(c,e){void 0==e.billing_name&&(e.billing_name="");void 0==e.billing_address_country&&(e.billing_address_country="");void 0==e.billing_address_zip&&(e.billing_address_zip="");void 0==e.billing_address_state&&(e.billing_address_state="");void 0==e.billing_address_line1&&(e.billing_address_line1="");void 0==e.billing_address_city&&(e.billing_address_city="");void 0==e.shipping_name&&(e.shipping_name="");void 0==e.shipping_address_country&&
(e.shipping_address_country="");void 0==e.shipping_address_zip&&(e.shipping_address_zip="");void 0==e.shipping_address_state&&(e.shipping_address_state="");void 0==e.shipping_address_line1&&(e.shipping_address_line1="");void 0==e.shipping_address_city&&(e.shipping_address_city="");CheckoutButton.args=e;CheckoutButton.token=c;CheckoutButton.submitPayment(c.id,c.email)}}),CheckoutButton.stripeCheckoutHandler.open({name:d.name,description:d.description,amount:d.amount.replace(".",""),panelLabel:d.checkoutLabel,
currency:d.currency,billingAddress:d.billing,shippingAddress:d.shipping,image:d.image,allowRememberMe:d.rememberMe}))};CheckoutButton.submitPayment=function(d,c){this.download(this.endPoint+"?Key="+encodeURIComponent(CheckoutButton.options.key)+"&Token="+d+"&Amount="+CheckoutButton.options.amount+"&Currency="+CheckoutButton.options.currency+"&Name="+encodeURIComponent(CheckoutButton.options.name)+"&Description="+encodeURIComponent(CheckoutButton.options.description)+"&CustomerName="+encodeURIComponent(CheckoutButton.args.billing_name)+
"&CustomerEmail="+encodeURIComponent(c)+"&Plan="+encodeURIComponent(CheckoutButton.options.plan)+"&Address1="+encodeURIComponent(CheckoutButton.args.billing_address_line1)+"&City="+encodeURIComponent(CheckoutButton.args.billing_address_city)+"&State="+encodeURIComponent(CheckoutButton.args.billing_address_state)+"&Zip="+encodeURIComponent(CheckoutButton.args.billing_address_zip)+"&Country="+encodeURIComponent(CheckoutButton.args.billing_address_country)+"&ShippingName="+encodeURIComponent(CheckoutButton.args.shipping_name)+
"&ShippingAddress1="+encodeURIComponent(CheckoutButton.args.shipping_address_line1)+"&ShippingCity="+encodeURIComponent(CheckoutButton.args.shipping_address_city)+"&ShippingState="+encodeURIComponent(CheckoutButton.args.shipping_address_state)+"&ShippingZip="+encodeURIComponent(CheckoutButton.args.shipping_address_zip)+"&ShippingCountry="+encodeURIComponent(CheckoutButton.args.shipping_address_country))};CheckoutButton.submitPaymentCallback=function(d){null==d&&(d="");0==d.length&&(d="Error: Your purchase could not be completed. An unknown error occurred.");
"OK"!=d?alert(d):(0<CheckoutButton.options.message.length&&alert(CheckoutButton.options.message),0<CheckoutButton.options.redirect.length&&(window.location.href=CheckoutButton.options.redirect+(-1<CheckoutButton.options.redirect.indexOf("?")?"&":"?")+"Amount="+CheckoutButton.options.amount+"&Currency="+CheckoutButton.options.currency+"&Name="+encodeURIComponent(CheckoutButton.options.name)+"&Description="+encodeURIComponent(CheckoutButton.options.description)+"&CustomerName="+encodeURIComponent(CheckoutButton.args.billing_name)+
"&CustomerEmail="+encodeURIComponent(CheckoutButton.token.email)+"&Plan="+encodeURIComponent(CheckoutButton.options.plan)+"&Address1="+encodeURIComponent(CheckoutButton.args.billing_address_line1)+"&City="+encodeURIComponent(CheckoutButton.args.billing_address_city)+"&State="+encodeURIComponent(CheckoutButton.args.billing_address_state)+"&Zip="+encodeURIComponent(CheckoutButton.args.billing_address_zip)))};CheckoutButton.download=function(d){var c=document.createElement("script");c.src=d;var e=document.getElementsByTagName("head")[0],
a=!1;c.onload=c.onreadystatechange=function(){a||this.readyState&&"loaded"!=this.readyState&&"complete"!=this.readyState&&4!=this.readyState||(a=!0,c.onload=c.onreadystatechange=null,e.removeChild(c))};e.appendChild(c)};CheckoutButton.loadScript=function(d){var c;c=document.createElement("script");c.type="text/javascript";c.src=d;d=document.getElementsByTagName("script")[0];d.parentNode.insertBefore(c,d)}}).call(this);
(function(){var d,c=[].indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(b in this&&this[b]===a)return b;return-1},e=[].slice;d=function(a){return a&&(""+a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")};CheckoutButton.Utils={$:function(a){return document.querySelectorAll(a)},$$:function(a){var b,c,e,d,g;if("function"===typeof document.getElementsByClassName)return document.getElementsByClassName(a);if("function"===typeof document.querySelectorAll)return document.querySelectorAll("."+
a);b=RegExp("(^|\\s)"+a+"(\\s|$)");d=document.getElementsByTagName("*");g=[];c=0;for(e=d.length;c<e;c++)a=d[c],b.test(a.className)&&g.push(a);return g},attr:function(a,b,c){a.className||(a=document.getElementById(a));return null!=c?a.setAttribute(b,c):a.getAttribute(b)},rattr:function(a,b){a.className||(a=document.getElementById(a));if(a)return a.removeAttribute(b)},hasAttr:function(a,b){var c;a.className||(a=document.getElementById(a));if("function"===typeof a.hasAttribute)return a.hasAttribute(b);
c=a.getAttributeNode(b);return!(!c||!c.specified&&!c.nodeValue)},bind:function(a,b,c){return a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent("on"+b,c)},unbind:function(a,b,c){return a.removeEventListener?a.removeEventListener(b,c,!1):a.detachEvent("on"+b,c)},addClass:function(a,b){a.className||(a=document.getElementById(a));a.className&&(a.className+=" "+b)},hasClass:function(a,b){return 0<=c.call(a.className.split(" "),b)},css:function(a,b){return a.style.cssText+=";"+b},insertBefore:function(a,
b){return a.parentNode.insertBefore(b,a)},insertAfter:function(a,b){return a.parentNode.insertBefore(b,a.nextSibling)},append:function(a,b){return a.appendChild(b)},remove:function(a){var b;a=document.getElementById(a);return null!=a&&null!=(b=a.parentNode)?b.removeChild(a):void 0},parents:function(a){var b;for(b=[];(a=a.parentNode)&&a!==document&&0>c.call(b,a);)b.push(a);return b},host:function(a){var b;b=document.createElement("div");b.innerHTML='<a href="'+d(a)+'">x</a>';a=b.firstChild;return""+
a.protocol+"//"+a.host},resolve:function(a){var b;b=document.createElement("a");b.href=a;return""+b.href},escape:d,text:function(a,b){"innerText"in a?a.innerText=b:a.textContent=b;return b},except:function(){var a,b,d,h,k;d=arguments[0];b=2<=arguments.length?e.call(arguments,1):[];h={};for(a in d)k=d[a],0>c.call(b,a)&&(h[a]=k);return h},hide:function(a){if(a=document.getElementById(a))a.style.display="none"},show:function(a){if(a=document.getElementById(a))a.style.display=""},focusField:function(a){(a=
document.getElementById(a))&&a.focus()},getTextBox:function(a){return(a=document.getElementById(a))?a.value:""},getDropdown:function(a){return(a=document.getElementById(a))?a.options[a.selectedIndex].value:""},getDiv:function(a){return(a=document.getElementById(a))?a.innerHTML:""},setDiv:function(a,b){var c=document.getElementById(a);c&&(c.innerHTML=b)},checkEmail:function(a){return/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/.test(a)?!0:!1},setClass:function(a,b){var c=document.getElementById(a);
c&&(c.className=b)}}}).call(this);
(function(){var d,c,e,a,b,m,h,k,g,l=function(a,b){return function(){return a.apply(b,arguments)}};g=CheckoutButton.Utils;e=g.bind;k=g.unbind;d=g.append;h=g.text;m=g.parents;b=g.insertAfter;c=g.attr;a=g.hasAttr;CheckoutButton.Button=function(){function f(a){null==a&&(a={});this.setOptions=l(this.setOptions,this);this.parentHead=l(this.parentHead,this);this.parentForm=l(this.parentForm,this);this.open=l(this.open,this);this.submit=l(this.submit,this);this.append=l(this.append,this);this.render=l(this.render,
this);this.setOptions(a);this.$el=document.createElement("button");this.$el.setAttribute("type","submit");this.$el.className=this.options.className;e(this.$el,"click",this.submit);e(this.$el,"touchstart",function(){});this.render()}f.prototype.defaults={key:"",label:"Buy Now",checkoutlabel:"Pay {{amount}}",currency:"usd",billing:!1,shipping:!1,redirect:"",message:"",plan:"",image:"",rememberMe:!1,cssPath:CheckoutButton.resources+"/button.css",className:"checkout-button-el"};f.prototype.render=function(){this.$el.innerHTML=
"";this.$el.style.visibility="hidden";this.$span=document.createElement("span");h(this.$span,this.options.label);this.$span.setAttribute("tabindex","0");this.options.nostyle||(this.$span.style.display="block");this.$style=document.createElement("link");this.$style.setAttribute("type","text/css");this.$style.setAttribute("rel","stylesheet");this.$style.setAttribute("href",this.options.cssPath);return d(this.$el,this.$span)};f.prototype.append=function(){var a,c=this;this.options.script&&b(this.options.script,
this.$el);this.options.nostyle||(a=this.parentHead())&&d(a,this.$style);if(this.$form=this.parentForm())k(this.$form,"submit",this.submit),e(this.$form,"submit",this.submit);return setTimeout(function(){return c.$el.style.visibility="visible"},1E3)};f.prototype.disable=function(){return c(this.$el,"disabled",!0)};f.prototype.enable=function(){return this.$el.removeAttribute("disabled")};f.prototype.isDisabled=function(){return a(this.$el,"disabled")};f.prototype.submit=function(a){this.open();return!1};
f.prototype.open=function(a){CheckoutButton.loadButton(this.options)};f.prototype.renderInput=function(a){var b;b=document.createElement("input");b.type="hidden";b.value=a;return b};f.prototype.parentForm=function(){var a,b,c,d,e;b=m(this.$el);c=0;for(d=b.length;c<d;c++)if(a=b[c],"form"===(null!=(e=a.tagName)?e.toLowerCase():void 0))return a;return null};f.prototype.parentHead=function(){var a,b;return(null!=(a=this.options.document)?a.head:void 0)||(null!=(b=this.options.document)?b.getElementsByTagName("head")[0]:
void 0)||this.options.document.body};f.prototype.setOptions=function(a){var b,c,d,e;null==a&&(a={});this.options||(this.options={});if(a.script)for(c in b=this.elementOptions(a.script),b)d=b[c],this.options[c]=d;for(c in a)d=a[c],this.options[c]=d;a=this.defaults;for(c in a)d=a[c],null==(e=this.options)[c]&&(e[c]=d);this.options.amount=this.options.amount.replace(".","").replace(",","").replace("$","")};f.prototype.elementOptions=function(a){return{key:c(a,"key"),checkoutLabel:c(a,"checkoutlabel"),
label:c(a,"label"),name:c(a,"name"),description:c(a,"description"),amount:c(a,"amount"),currency:c(a,"currency"),billing:"true"==c(a,"billing"),shipping:"true"==c(a,"shipping"),redirect:c(a,"redirect"),message:c(a,"message"),plan:c(a,"plan"),image:c(a,"image"),rememberMe:"true"==c(a,"rememberme"),className:c(a,"className"),document:a.ownerDocument,body:a.ownerDocument.body}};return f}()}).call(this);
(function(){var d,c,e,a;e=CheckoutButton.Utils;d=e.$$;a=e.hasClass;c=e.addClass;e=e.bind;e(window,"load",function(){return CheckoutButton.load()});(function(){var b;b=d("checkout-button");var e,h,k;k=[];e=0;for(h=b.length;e<h;e++)el=b[e],a(el,"active")||k.push(el);b=k;if(b=b[b.length-1])return c(b,"active"),b=new CheckoutButton.Button({script:b}),b.render(),b.append(),!0})()}).call(this);
