-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathschema.min.js
4 lines (3 loc) · 31.6 KB
/
schema.min.js
1
2
3
4
/*! schema.js (Version 1.1.4) 2015-11-12 */
!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){function d(){}var e=b.exports={};e.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){var b=a.source;if((b===window||null===b)&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var d=c.shift();d()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),e.title="browser",e.browser=!0,e.env={},e.argv=[],e.on=d,e.addListener=d,e.once=d,e.off=d,e.removeListener=d,e.removeAllListeners=d,e.emit=d,e.binding=function(a){throw new Error("process.binding is not supported")},e.cwd=function(){return"/"},e.chdir=function(a){throw new Error("process.chdir is not supported")}},{}],2:[function(a,b,c){"use strict";function d(a){function b(a){return null===i?void k.push(a):void g(function(){var b=i?a.onFulfilled:a.onRejected;if(null===b)return void(i?a.resolve:a.reject)(j);var c;try{c=b(j)}catch(d){return void a.reject(d)}a.resolve(c)})}function c(a){try{if(a===l)throw new TypeError("A promise cannot be resolved with itself.");if(a&&("object"==typeof a||"function"==typeof a)){var b=a.then;if("function"==typeof b)return void f(b.bind(a),c,d)}i=!0,j=a,h()}catch(e){d(e)}}function d(a){i=!1,j=a,h()}function h(){for(var a=0,c=k.length;c>a;a++)b(k[a]);k=null}if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof a)throw new TypeError("not a function");var i=null,j=null,k=[],l=this;this.then=function(a,c){return new l.constructor(function(d,f){b(new e(a,c,d,f))})},f(a,c,d)}function e(a,b,c,d){this.onFulfilled="function"==typeof a?a:null,this.onRejected="function"==typeof b?b:null,this.resolve=c,this.reject=d}function f(a,b,c){var d=!1;try{a(function(a){d||(d=!0,b(a))},function(a){d||(d=!0,c(a))})}catch(e){if(d)return;d=!0,c(e)}}var g=a("asap");b.exports=d},{asap:4}],3:[function(a,b,c){"use strict";function d(a){this.then=function(b){return"function"!=typeof b?this:new e(function(c,d){f(function(){try{c(b(a))}catch(e){d(e)}})})}}var e=a("./core.js"),f=a("asap");b.exports=e,d.prototype=e.prototype;var g=new d(!0),h=new d(!1),i=new d(null),j=new d(void 0),k=new d(0),l=new d("");e.resolve=function(a){if(a instanceof e)return a;if(null===a)return i;if(void 0===a)return j;if(a===!0)return g;if(a===!1)return h;if(0===a)return k;if(""===a)return l;if("object"==typeof a||"function"==typeof a)try{var b=a.then;if("function"==typeof b)return new e(b.bind(a))}catch(c){return new e(function(a,b){b(c)})}return new d(a)},e.all=function(a){var b=Array.prototype.slice.call(a);return new e(function(a,c){function d(f,g){try{if(g&&("object"==typeof g||"function"==typeof g)){var h=g.then;if("function"==typeof h)return void h.call(g,function(a){d(f,a)},c)}b[f]=g,0===--e&&a(b)}catch(i){c(i)}}if(0===b.length)return a([]);for(var e=b.length,f=0;f<b.length;f++)d(f,b[f])})},e.reject=function(a){return new e(function(b,c){c(a)})},e.race=function(a){return new e(function(b,c){a.forEach(function(a){e.resolve(a).then(b,c)})})},e.prototype["catch"]=function(a){return this.then(null,a)}},{"./core.js":2,asap:4}],4:[function(a,b,c){(function(a){function c(){for(;e.next;){e=e.next;var a=e.task;e.task=void 0;var b=e.domain;b&&(e.domain=void 0,b.enter());try{a()}catch(d){if(i)throw b&&b.exit(),setTimeout(c,0),b&&b.enter(),d;setTimeout(function(){throw d},0)}b&&b.exit()}g=!1}function d(b){f=f.next={task:b,domain:i&&a.domain,next:null},g||(g=!0,h())}var e={task:void 0,next:null},f=e,g=!1,h=void 0,i=!1;if("undefined"!=typeof a&&a.nextTick)i=!0,h=function(){a.nextTick(c)};else if("function"==typeof setImmediate)h="undefined"!=typeof window?setImmediate.bind(window,c):function(){setImmediate(c)};else if("undefined"!=typeof MessageChannel){var j=new MessageChannel;j.port1.onmessage=c,h=function(){j.port2.postMessage(0)}}else h=function(){setTimeout(c,0)};b.exports=d}).call(this,a("_process"))},{_process:1}],5:[function(a,b,c){"function"!=typeof Promise.prototype.done&&(Promise.prototype.done=function(a,b){var c=arguments.length?this.then.apply(this,arguments):this;c.then(null,function(a){setTimeout(function(){throw a},0)})})},{}],6:[function(a,b,c){a("asap");"undefined"==typeof Promise&&(Promise=a("./lib/core.js"),a("./lib/es6-extensions.js")),a("./polyfill-done.js")},{"./lib/core.js":2,"./lib/es6-extensions.js":3,"./polyfill-done.js":5,asap:4}]},{},[6]),function(){var a=this.Schema={publicUrl:"https://api.schema.io",vaultUrl:"https://vault.schema.io",publicKey:null};a.setPublicKey=function(a){this.publicKey=a,delete this._vaultClient,delete this._publicClient},a.setPublishableKey=function(b){return a.setPublicKey(b)},a.card={},a.createToken=function(b,c){var d=null,e=null;if(b||(d="Card details are missing in `Schema.createToken(card, callback)`",e=""),c||(d="Callback function missing in `Schema.createToken(card, callback)`",e=""),a.card.validateCardNumber(b.number)||(d="Card number appears to be invalid",e="number"),b.exp){var f=a.cardExpiry(b.exp);b.exp_month=f.month,b.exp_year=f.year}return a.card.validateExpiry(b.exp_month,b.exp_year)||(d="Card expiry appears to be invalid",e="exp_month"),a.card.validateCVC(b.cvc)||(d="Card CVC code appears to be invalid",e="exp_cvc"),d?void setTimeout(function(){c(402,{error:{message:d,param:e}})},1):(b.billing||(b.billing={}),b.address_line1&&(b.billing.address1=b.address_line1),b.address_line2&&(b.billing.address2=b.address_line2),b.address_city&&(b.billing.city=b.address_city),b.address_state&&(b.billing.state=b.address_state),b.address_zip&&(b.billing.zip=b.address_zip),b.address_country&&(b.billing.country=b.address_country),void a.vault().post("/tokens",b,function(a,b){var d=a||{};if(b.$error)d.error={message:b.$error};else if(d.errors){var e=Object.keys(a.errors)[0];d.error=a.errors[e],d.error.param=e,b.$status=402}else a.toObject&&(d=a.toObject());return c(b.$status,d)}))},a.card.createToken=function(){return a.createToken.apply(this,arguments)},a.cardExpiry=function(a){if(a&&a.month&&a.year)return a;var b=new String(a).split(/[\s\/\-]+/,2),c=b[0],d=b[1];if(d&&2===d.length&&/^\d+$/.test(d)){var e=(new Date).getFullYear().toString().substring(0,2);d=e+d}return{month:~~c,year:~~d}},a.cardType=function(){return a.Stripe.card.cardType.apply(a.Stripe,arguments)},a.card.cardType=function(){return a.cardType.apply(this,arguments)},a.validateCardNumber=function(){return a.Stripe.card.validateCardNumber.apply(a.Stripe,arguments)},a.card.validateCardNumber=function(){return a.validateCardNumber.apply(this,arguments)},a.validateExpiry=function(){return a.Stripe.card.validateExpiry.apply(a.Stripe,arguments)},a.card.validateExpiry=function(){return a.validateExpiry.apply(this,arguments)},a.validateCVC=function(){return a.Stripe.card.validateCVC.apply(a.Stripe,arguments)},a.card.validateCVC=function(){return a.validateCVC.apply(this,arguments)},a.client=function(){if(this._publicClient)return this._publicClient;if(!this.publicKey)throw"Error: Public key must be set Schema.setPublicKey()";return this._publicClient=new a.Client(this.publicKey,{hostUrl:this.publicUrl}),this._publicClient},a.vault=function(){if(this._vaultClient)return this._vaultClient;if(!this.publicKey)throw"Error: Public key must be set Schema.setPublicKey()";return this._vaultClient=new a.Client(this.publicKey,{hostUrl:this.vaultUrl}),this._vaultClient},function(){var a,b,c,d,e,f={}.hasOwnProperty,g=function(a,b){function c(){this.constructor=a}for(var d in b)f.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},h=this;for(this.Stripe=function(){function a(){}return a.version=2,a.endpoint="https://api.stripe.com/v1",a.setPublishableKey=function(b){a.key=b},a.complete=function(b,c){return function(d,e,f){var g;return"success"!==d?(g=Math.round((new Date).getTime()/1e3),(new Image).src="https://q.stripe.com?event=stripejs-error&type="+d+"&key="+a.key+"×tamp="+g,"function"==typeof b?b(500,{error:{code:d,type:d,message:c}}):void 0):void 0}},a}.call(this),a=this.Stripe,this.Stripe.token=function(){function b(){}return b.validate=function(a,b){if(!a)throw b+" required";if("object"!=typeof a)throw b+" invalid"},b.formatData=function(b,c){return a.utils.isElement(b)&&(b=a.utils.paramsFromForm(b,c)),a.utils.underscoreKeys(b),b},b.create=function(b,c){return b.key||(b.key=a.key||a.publishableKey),a.utils.validateKey(b.key),a.ajaxJSONP({url:""+a.endpoint+"/tokens",data:b,method:"POST",success:function(a,b){return"function"==typeof c?c(b,a):void 0},complete:a.complete(c,"A network error has occurred, and you have not been charged. Please try again."),timeout:4e4})},b.get=function(b,c){if(!b)throw"token required";return a.utils.validateKey(a.key),a.ajaxJSONP({url:""+a.endpoint+"/tokens/"+b,data:{key:a.key},success:function(a,b){return"function"==typeof c?c(b,a):void 0},complete:a.complete(c,"A network error has occurred loading data from Stripe. Please try again."),timeout:4e4})},b}.call(this),this.Stripe.card=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return g(c,b),c.tokenName="card",c.whitelistedAttrs=["number","cvc","exp_month","exp_year","name","address_line1","address_line2","address_city","address_state","address_zip","address_country"],c.createToken=function(b,d,e){var f;return null==d&&(d={}),a.token.validate(b,"card"),"function"==typeof d?(e=d,d={}):"object"!=typeof d&&(f=parseInt(d,10),d={},f>0&&(d.amount=f)),d[c.tokenName]=a.token.formatData(b,c.whitelistedAttrs),a.token.create(d,e)},c.getToken=function(b,c){return a.token.get(b,c)},c.validateCardNumber=function(a){return a=(a+"").replace(/\s+|-/g,""),a.length>=10&&a.length<=16&&c.luhnCheck(a)},c.validateCVC=function(b){return b=a.utils.trim(b),/^\d+$/.test(b)&&b.length>=3&&b.length<=4},c.validateExpiry=function(b,c){var d,e;return b=a.utils.trim(b),c=a.utils.trim(c),/^\d+$/.test(b)&&/^\d+$/.test(c)&&parseInt(b,10)<=12?(e=new Date(c,b),d=new Date,e.setMonth(e.getMonth()-1),e.setMonth(e.getMonth()+1,1),e>d):!1},c.luhnCheck=function(a){var b,c,d,e,f,g;for(d=!0,e=0,c=(a+"").split("").reverse(),f=0,g=c.length;g>f;f++)b=c[f],b=parseInt(b,10),(d=!d)&&(b*=2),b>9&&(b-=9),e+=b;return e%10===0},c.cardType=function(a){return c.cardTypes[a.slice(0,2)]||"Unknown"},c.cardTypes=function(){var a,b,c,d;for(b={},a=c=40;49>=c;a=++c)b[a]="Visa";for(a=d=50;59>=d;a=++d)b[a]="MasterCard";return b[34]=b[37]="American Express",b[60]=b[62]=b[64]=b[65]="Discover",b[35]="JCB",b[30]=b[36]=b[38]=b[39]="Diners Club",b}(),c}.call(this,this.Stripe.token),this.Stripe.bankAccount=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return g(c,b),c.tokenName="bank_account",c.whitelistedAttrs=["country","routing_number","account_number"],c.createToken=function(b,d,e){return null==d&&(d={}),a.token.validate(b,"bank account"),"function"==typeof d&&(e=d,d={}),d[c.tokenName]=a.token.formatData(b,c.whitelistedAttrs),a.token.create(d,e)},c.getToken=function(b,c){return a.token.get(b,c)},c.validateRoutingNumber=function(b,d){switch(b=a.utils.trim(b),d){case"US":return/^\d+$/.test(b)&&9===b.length&&c.routingChecksum(b);case"CA":return/\d{5}\-\d{3}/.test(b)&&9===b.length;default:return!0}},c.validateAccountNumber=function(b,c){switch(b=a.utils.trim(b),c){case"US":return/^\d+$/.test(b)&&b.length>=1&&b.length<=17;default:return!0}},c.routingChecksum=function(a){var b,c,d,e,f,g;for(d=0,b=(a+"").split(""),g=[0,3,6],e=0,f=g.length;f>e;e++)c=g[e],d+=3*parseInt(b[c]),d+=7*parseInt(b[c+1]),d+=parseInt(b[c+2]);return 0!==d&&d%10===0},c}.call(this,this.Stripe.token),this.Stripe.bitcoinReceiver=function(){function b(){}return b._whitelistedAttrs=["amount","currency","email","description"],b.createReceiver=function(b,c){var d;return a.token.validate(b,"bitcoin_receiver data"),d=a.token.formatData(b,this._whitelistedAttrs),d.key=a.key||a.publishableKey,a.utils.validateKey(d.key),a.ajaxJSONP({url:""+a.endpoint+"/bitcoin/receivers",data:d,method:"POST",success:function(a,b){return"function"==typeof c?c(b,a):void 0},complete:a.complete(c,"A network error has occurred while creating a Bitcoin address. Please try again."),timeout:4e4})},b.getReceiver=function(b,c){var d;if(!b)throw"receiver id required";return d=a.key||a.publishableKey,a.utils.validateKey(d),a.ajaxJSONP({url:""+a.endpoint+"/bitcoin/receivers/"+b,data:{key:d},success:function(a,b){return"function"==typeof c?c(b,a):void 0},complete:a.complete(c,"A network error has occurred loading data from Stripe. Please try again."),timeout:4e4})},b._activeReceiverPolls={},b._clearReceiverPoll=function(a){return delete b._activeReceiverPolls[a]},b._pollInterval=1500,b.pollReceiver=function(a,b){if(null!=this._activeReceiverPolls[a])throw"You are already polling receiver "+a+". Please cancel that poll before polling it again.";return this._activeReceiverPolls[a]={},this._pollReceiver(a,b)},b._pollReceiver=function(a,c){b.getReceiver(a,function(d,e){var f,g;if(null!=b._activeReceiverPolls[a])return 200===d&&e.filled?(b._clearReceiverPoll(a),"function"==typeof c?c(d,e):void 0):d>=400&&500>d?(b._clearReceiverPoll(a),"function"==typeof c?c(d,e):void 0):(f=500===d?5e3:b._pollInterval,g=setTimeout(function(){return b._pollReceiver(a,c)},f),b._activeReceiverPolls[a].timeoutId=g)})},b.cancelReceiverPoll=function(a){var c;if(c=b._activeReceiverPolls[a],null==c)throw"You are not polling receiver "+a+".";null!=c.timeoutId&&clearTimeout(c.timeoutId),b._clearReceiverPoll(a)},b}.call(this),b=["createToken","getToken","cardType","validateExpiry","validateCVC","validateCardNumber"],d=0,e=b.length;e>d;d++)c=b[d],this.Stripe[c]=this.Stripe.card[c];"undefined"!=typeof module&&null!==module&&(module.exports=this.Stripe),"function"==typeof define&&define("stripe",[],function(){return h.Stripe})}.call(this),function(){var a,b,c,d=[].slice;a=encodeURIComponent,b=(new Date).getTime(),c=function(b,d,e){var f,g;null==d&&(d=[]);for(f in b)g=b[f],e&&(f=""+e+"["+f+"]"),"object"==typeof g?c(g,d,f):d.push(""+f+"="+a(g));return d.join("&").replace(/%20/g,"+")},this.Stripe.ajaxJSONP=function(a){var e,f,g,h,i,j;return null==a&&(a={}),g="sjsonp"+ ++b,i=document.createElement("script"),f=null,e=function(b){var c;return null==b&&(b="abort"),clearTimeout(f),null!=(c=i.parentNode)&&c.removeChild(i),g in window&&(window[g]=function(){}),"function"==typeof a.complete?a.complete(b,j,a):void 0},j={abort:e},i.onerror=function(){return j.abort(),"function"==typeof a.error?a.error(j,a):void 0},window[g]=function(){var b;b=1<=arguments.length?d.call(arguments,0):[],clearTimeout(f),i.parentNode.removeChild(i);try{delete window[g]}catch(c){window[g]=void 0}return"function"==typeof a.success&&a.success.apply(a,b),"function"==typeof a.complete?a.complete("success",j,a):void 0},a.data||(a.data={}),a.data.callback=g,a.method&&(a.data._method=a.method),i.src=a.url+"?"+c(a.data),h=document.getElementsByTagName("head")[0],h.appendChild(i),a.timeout>0&&(f=setTimeout(function(){return j.abort("timeout")},a.timeout)),j}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.Stripe.utils=function(){function b(){}return b.trim=function(a){return(a+"").replace(/^\s+|\s+$/g,"")},b.underscore=function(a){return(a+"").replace(/([A-Z])/g,function(a){return"_"+a.toLowerCase()}).replace(/-/g,"_")},b.underscoreKeys=function(a){var b,c,d;d=[];for(b in a)c=a[b],delete a[b],d.push(a[this.underscore(b)]=c);return d},b.isElement=function(a){return"object"!=typeof a?!1:"undefined"!=typeof jQuery&&null!==jQuery&&a instanceof jQuery?!0:1===a.nodeType},b.paramsFromForm=function(b,c){var d,e,f,g,h,i,j,k,l,m;for(null==c&&(c=[]),"undefined"!=typeof jQuery&&null!==jQuery&&b instanceof jQuery&&(b=b[0]),f=b.getElementsByTagName("input"),h=b.getElementsByTagName("select"),i={},j=0,l=f.length;l>j;j++)e=f[j],d=this.underscore(e.getAttribute("data-stripe")),a.call(c,d)<0||(i[d]=e.value);for(k=0,m=h.length;m>k;k++)g=h[k],d=this.underscore(g.getAttribute("data-stripe")),a.call(c,d)<0||null!=g.selectedIndex&&(i[d]=g.options[g.selectedIndex].value);return i},b.validateKey=function(a){if(!a||"string"!=typeof a)throw new Error("You did not set a valid publishable key. Call Stripe.setPublishableKey() with your publishable key. For more info, see https://stripe.com/docs/stripe.js");if(/\s/g.test(a))throw new Error("Your key is invalid, as it contains whitespace. For more info, see https://stripe.com/docs/stripe.js");if(/^sk_/.test(a))throw new Error("You are using a secret key with Stripe.js, instead of the publishable one. For more info, see https://stripe.com/docs/stripe.js")},b}()}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.Stripe.validator={"boolean":function(a,b){return"true"!==b&&"false"!==b?"Enter a boolean string (true or false)":void 0},integer:function(a,b){return/^\d+$/.test(b)?void 0:"Enter an integer"},positive:function(a,b){return!this.integer(a,b)&&parseInt(b,10)>0?void 0:"Enter a positive value"},range:function(b,c){var d;return d=parseInt(c,10),a.call(b,d)<0?"Needs to be between "+b[0]+" and "+b[b.length-1]:void 0},required:function(a,b){return!a||null!=b&&""!==b?void 0:"Required"},year:function(a,b){return/^\d{4}$/.test(b)?void 0:"Enter a 4-digit year"},birthYear:function(a,b){var c;return c=this.year(a,b),c?c:parseInt(b,10)>2e3?"You must be over 18":parseInt(b,10)<1900?"Enter your birth year":void 0},month:function(a,b){return this.integer(a,b)?"Please enter a month":this.range([1,2,3,4,5,6,7,8,9,10,11,12],b)?"Needs to be between 1 and 12":void 0},choices:function(b,c){return a.call(b,c)<0?"Not an acceptable value for this field":void 0},email:function(a,b){return/^[^@<\s>]+@[^@<\s>]+$/.test(b)?void 0:"That doesn't look like an email address"},url:function(a,b){return/^https?:\/\/.+\..+/.test(b)?void 0:"Not a valid url"},usTaxID:function(a,b){return/^\d{2}-?\d{1}-?\d{2}-?\d{4}$/.test(b)?void 0:"Not a valid tax ID"},ein:function(a,b){return/^\d{2}-?\d{7}$/.test(b)?void 0:"Not a valid EIN"},ssnLast4:function(a,b){return/^\d{4}$/.test(b)?void 0:"Not a valid last 4 digits for an SSN"},ownerPersonalID:function(a,b){var c;return c=function(){switch(a){case"CA":return/^\d{3}-?\d{3}-?\d{3}$/.test(b);case"US":return!0}}(),c?void 0:"Not a valid ID"},bizTaxID:function(a,b){var c,d,e,f,g,h,i,j;if(h={CA:["Tax ID",[/^\d{9}$/]],US:["EIN",[/^\d{2}-?\d{7}$/]]},g=h[a],null!=g){for(c=g[0],f=g[1],d=!1,i=0,j=f.length;j>i;i++)if(e=f[i],e.test(b)){d=!0;break}if(!d)return"Not a valid "+c}},zip:function(a,b){var c;return c=function(){switch(a.toUpperCase()){case"CA":return/^[\d\w]{6}$/.test(null!=b?b.replace(/\s+/g,""):void 0);case"US":return/^\d{5}$/.test(b)||/^\d{9}$/.test(b)}}(),c?void 0:"Not a valid zip"},bankAccountNumber:function(a,b){return/^\d{1,17}$/.test(b)?void 0:"Invalid bank account number"},usRoutingNumber:function(a){var b,c,d,e,f,g,h;if(!/^\d{9}$/.test(a))return"Routing number must have 9 digits";for(f=0,b=g=0,h=a.length-1;h>=g;b=g+=3)c=3*parseInt(a.charAt(b),10),d=7*parseInt(a.charAt(b+1),10),e=parseInt(a.charAt(b+2),10),f+=c+d+e;return 0===f||f%10!==0?"Invalid routing number":void 0},caRoutingNumber:function(a){return/^\d{5}\-\d{3}$/.test(a)?void 0:"Invalid transit number"},routingNumber:function(a,b){switch(a.toUpperCase()){case"CA":return this.caRoutingNumber(b);case"US":return this.usRoutingNumber(b)}},phoneNumber:function(a,b){var c;return c=b.replace(/[^0-9]/g,""),10!==c.length?"Invalid phone number":void 0},bizDBA:function(a,b){return/^.{1,23}$/.test(b)?void 0:"Statement descriptors can only have up to 23 characters"},nameLength:function(a,b){return 1===b.length?"Names need to be longer than one character":void 0}}}.call(this),this.Schema.Stripe=this.Stripe,this.Stripe.createToken=function(){return this.card.createToken.apply(arguments)},this.Stripe.cardType=function(){return this.card.cardType.apply(arguments)},this.Stripe.validateCardNumber=function(){return this.card.validateCardNumber.apply(arguments)},this.Stripe.validateExpiry=function(){return this.card.validateExpiry.apply(arguments)},this.Stripe.validateCVC=function(){return this.card.validateCVC.apply(arguments)},"undefined"!=typeof module&&(module.exports=this.Schema)}.call(this),function(){var a=(this.Promise,this.Schema.util={});a.inherits=function(a,b){a._base=b;var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a},a.inspect=function(a,b){return void 0!==require?require("util").inspect(a,b):console.log(a)},"undefined"!=typeof exports&&(exports.util=this.Schema.util)}.call(this),function(){var a=this.Schema.util,b=this.Schema.Resource=function(a,c,d){this.__url=a,this.__client=d,this.__data=null,c&&(c.$links?this.$links=b.$links[a]=c.$links:b.$links[a]&&(this.$links=b.$links[a]),c.$data&&this.__initData(c.$data))};b.$links={},b.prototype.__initData=function(a){if(a&&"object"==typeof a){this.__data=a;for(var b=Object.keys(a),c=0;c<b.length;c++){var d=b[c];a.hasOwnProperty(d)&&(this[d]=a[d])}}},b.prototype.toObject=function(){var a={};if(this.__data)for(var b=Object.keys(this.__data),c=0;c<b.length;c++){var d=b[c];a[d]=this.__data[d]}return a},b.prototype.toJSON=function(){return JSON.stringify(this.toObject())},b.prototype.toString=function(){return this.__url},b.prototype.inspect=function(b){var c=this.toObject();return this.$links&&(c.$links=this.$links),a.inspect(c,{depth:b,colors:!0})},"undefined"!=typeof exports&&(exports.Resource=this.Schema.Resource)}.call(this),function(){var a=this.Schema.util,b=this.Schema.Resource,c=this.Schema.Record=function(a,c,d,e){b.call(this,a,c,d),this.$links&&this.__initLinks(this.$links),this.collection=e};a.inherits(c,b),c.prototype.__initLinks=function(a){var b=this;this.__forEachLink(a,function(a,c,d,e){var f=b.__linkUrl(e);d[c]||(d[c]=function(a){return"function"==typeof a?(d.__client.get(f,null,a),this):void 0},d[c].each=function(a,b){"function"==typeof a&&d[c](function(c){if(c&&c.results)for(var d=0;d<c.results.length;d++)a(c.results[d]);else a(c);"function"==typeof b&&b(c)})},d[c].get=b.__linkRequest.bind(b,"get",f),d[c].put=b.__linkRequest.bind(b,"put",f),d[c].post=b.__linkRequest.bind(b,"post",f),d[c].post=b.__linkRequest.bind(b,"delete",f),d[c].toString=function(){return f})})},c.prototype.__forEachLink=function(a,b,c,d){if("function"==typeof b?(d=b,b=this,c=""):"function"==typeof c&&(d=c,c=""),b)for(var e=Object.keys(a),f=0;f<e.length;f++){var g=e[f],h=a[g],i=c+"/"+g;if(h.url&&d(h,g,b,i),h.links)if(h.links["*"]){if(!(b[g]instanceof Array))continue;for(var j=0;j<b[g].length;j++)b[g][j]&&(i+="/"+(b[g][j].id||j),this.__forEachLink(h.links["*"],b[g][j],i,d))}else this.__forEachLink(h.links,b[g],i,d)}},c.prototype.__linkRequest=function(a,b,c,d,e){return"function"==typeof c?(e=c,c=null):"function"==typeof d&&(e=d,d=null),"object"==typeof c&&(d=c,c=null,"function"==typeof d&&(e=d,d=null)),"function"==typeof e?(c&&(b=b+"/"+c.replace(/^\//,"")),this.__client[a](b,d,e)):void 0},c.prototype.__linkUrl=function(a){var b=this.__url,c=this.__url.indexOf("?");return-1!==c&&(b=b.substring(0,c)),b.replace(/\/$/,"")+"/"+a.replace(/^\//,"")},c.prototype.inspect=function(b){var c=this.toObject();return this.$links&&(this.collection||(c.$links=this.$links)),a.inspect(c,{depth:b,colors:!0})},"undefined"!=typeof exports&&(exports.Record=this.Schema.Record)}.call(this),function(){var a=this.Schema.util,b=this.Schema.Resource,c=this.Schema.Record,d=this.Schema.Collection=function(a,c,d){this.count=0,this.page=0,this.pages={},this.length=0,c&&c.$data&&(this.count=c.$data.count,this.page=c.$data.page,this.pages=c.$data.pages||{},this.length=c.$data.results?c.$data.results.length:0),c.$data=c.$data.results,c=this.__buildRecords(a,c,d),b.call(this,a,c,d),this.results=[];for(var e=0;e<this.length;e++)this.results[e]=this[e]};a.inherits(d,b),d.prototype.__buildRecords=function(a,b,d){if(!(b.$data instanceof Array))return null;var e=a.indexOf("?");-1!==e&&(a=a.substring(0,e)),a="/"+a.replace(/^\//,"").replace(/\/$/,"");for(var f=0;f<b.$data.length;f++){var g=b.$data[f],h=a+"/"+g.id;b.$data[f]=new c(h,{$data:g,$links:b.$links},d,this)}return b},d.prototype.each=function(a){for(var b=0;b<this.length;b++)a.call(this,this[b])},d.prototype.toObject=function(){var a=[];if(this.results)for(var b=0;b<this.results.length;b++)a[b]=this.results[b].toObject();return{count:this.count,results:a,page:this.page,pages:this.pages}},d.prototype.inspect=function(b){var c=this.toObject();return this.$links&&(c.$links=this.$links),a.inspect(c,{depth:b,colors:!0})},"undefined"!=typeof exports&&(exports.Collection=this.Schema.Collection)}.call(this),function(){function a(b,d,e){var f;if(d instanceof Array)for(var g=0;g<d.length;g++)c.test(b)?e(b,v):a(b+"["+("object"==typeof v&&null!=v?g:"")+"]",v,e);else if(d&&"object"==typeof d)for(f in d)a(b+"["+f+"]",d[f],e);else e(b,d)}if("undefined"==typeof module||!module.exports){var b=(this.Schema.util,this.Schema.Client=function(a,b){"object"==typeof a?(b=a,a=void 0):b=b||{},this.options={publicKey:a||b.publicKey||this.Schema.publicKey,hostUrl:b.hostUrl||this.Schema.publicUrl,timeout:b.timeout||15e3,version:b.version,session:b.session,api:b.api}});b.prototype.request=function(a,c,d,e){"function"==typeof d&&(e=d,d=null);var f=b.generateRequestId();c=c&&c.toString?c.toString():"",d={$jsonp:{method:a,callback:"Schema.Client.response"+f},$data:d,$key:this.options.publicKey};var g=document.createElement("script");g.type="text/javascript",g.src=this.options.hostUrl+"/"+c.replace(/^\//,"")+"?"+b.serializeData(d);var h=this,i=setTimeout(function(){Schema.Client["response"+f]({$error:"Request timed out after "+h.options.timeout/1e3+" seconds",$status:500})},h.options.timeout);Schema.Client["response"+f]=function(b){clearTimeout(i),h.response(a,c,b,e),delete Schema.Client["response"+f],g.parentNode.removeChild(g)},document.getElementsByTagName("head")[0].appendChild(g)},b.prototype.response=function(a,c,d,e){var f=null;return f=d&&d.$data&&"object"==typeof d.$data?b.createResource(d.$url,d,this):d.$data,e&&e.call(this,f,d)},b.prototype.get=function(a,b,c){return this.request("get",a,b,c)},b.prototype.put=function(a,b,c){return this.request("put",a,b,c)},b.prototype.post=function(a,b,c){return this.request("post",a,b,c)},b.prototype["delete"]=function(a,b,c){return this.request("delete",a,b,c)},b.generateRequestId=function(){return window.__schema_client_request_id=window.__schema_client_request_id||0,window.__schema_client_request_id++,window.__schema_client_request_id},b.serializeData=function(b){var c,d=[],e=function(a,b){"function"==typeof b?b=b():null==b&&(b=""),d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};for(c in b)a(c,b[c],e);return d.join("&").replace(" ","+")};var c=/\[\]$/;b.create=function(a,c){return new b(a,c)},b.createResource=function(a,b,c){return b&&b.$data&&"count"in b.$data&&b.$data.results?new Schema.Collection(a,b,c):new Schema.Record(a,b,c)}}}.call(this),function(){var a=this.Schema,b=a.Form=a.form={};b.onSubmitCard=function(a){b._validateCardParams(a),b._addEventListener(a.form,"submit",b._onSubmitCard.bind(this,a))},b._onSubmitCard=function(c,d){var e;e=c.fields.cardExp?a.cardExpiry(c.fields.cardExp.value):{month:c.fields.cardExpMonth.value,year:c.fields.cardExpYear.value};var f={number:c.fields.cardNumber.value,cvc:c.fields.cardCVC.value,exp_month:e.month,exp_year:e.year,billing:{}};if(c.fields.billing&&(f.billing={name:c.fields.billingName&&c.fields.billingName.value,address1:c.fields.billingAddress1&&c.fields.billingAddress1.value,address2:c.fields.billingAddress2&&c.fields.billingAddress2.value,city:c.fields.billingCity&&c.fields.billingCity.value,state:c.fields.billingState&&c.fields.billingState.value,zip:c.fields.billingZip&&c.fields.billingZip.value,country:c.fields.billingCountry&&c.fields.billingCountry.value}),"function"!=typeof c.onSubmit||c.onSubmit(f)!==!1){var g=JSON.stringify(f);if(c.form.__cardData!==g){b._preventDefault(d);var h=!0;a.validateCVC(f.cvc)||(h=!1,b._triggerFieldError(c.onError,c.fields.cardCVC,"")),a.validateExpiry(f.exp_month,f.exp_year)||(h=!1,c.fields.cardExp&&b._triggerFieldError(c.onError,c.fields.cardExp,""),c.fields.cardExpMonth&&b._triggerFieldError(c.onError,c.fields.cardExpMonth,""),c.fields.cardExpYear&&b._triggerFieldError(c.onError,c.fields.cardExpYear,"")),a.validateCardNumber(f.number)&&f.number||(h=!1,b._triggerFieldError(c.onError,c.fields.cardNumber,"")),h&&(c.form.__cardData=g,a.setPublicKey(c.publicKey),a.card.createToken(f,function(a,d){if(d.errors){c.form.__cardData=null;for(var e in d.errors){var f;switch(e){case"exp_month":f=c.fields.cardExp||c.fields.cardExpMonth;break;case"exp_year":f=c.fields.cardExp||c.fields.cardExpYear;break;case"cvc":f=c.fields.cardCVC;break;case"number":default:f=c.fields.cardNumber}b._triggerFieldError(c.onError,f,d.errors[e].message)}}else if(a>200)b._triggerFieldError(c.onError,c.fields.cardNumber,"Unknown gateway error, please try again");else{for(var g=document.getElementsByClassName("x-card-response-data"),h=0;h<g.length;h++)g[h].parentNode.removeChild(g[h]);{c.name}for(var e in d)if("object"!=typeof d[e]){var i=document.createElement("input");i.type="hidden",i.className="x-card-response-data",i.name=c.name+"["+e+"]",i.value=d[e],c.form.appendChild(i)}c.form.submit()}}))}}},b._validateCardParams=function(c){if(c.publicKey=c.publicKey||a.publicKey,!c.publicKey)throw"Form.onSubmitCard(): publicKey required";if(c.form=c.form?b._sanitizeElement(c.form):b._findDefaultFormElement(),null===c.form)throw"Form.onSubmitCard(): form not found with .card-number field";var d=c.fields||{};if(d.cardNumber=b._sanitizeElement(d.cardNumber||".card-number"),!d.cardNumber)throw"Form.onSubmitCard(): card number field not found";if(d.cardExp=b._sanitizeElement(d.cardExp||".card-exp"),d.cardExpMonth=b._sanitizeElement(d.cardExpMonth||".card-exp-month"),!d.cardExp&&!d.cardExpMonth)throw"Form.onSubmitCard(): card expiration field not found";if(d.cardExpYear=b._sanitizeElement(d.cardExpYear||".card-exp-year"),!d.cardExp&&!d.cardExpYear)throw"Form.onSubmitCard(): card expiration year field not found";if(d.cardCVC=b._sanitizeElement(d.cardCvc||d.cardCVC||".card-cvc"),!d.cardCVC)throw"Form.onSubmitCard(): card cvc field not found";d.billingName=b._sanitizeElement(d.billingName||".billing-name"),d.billingAddress1=b._sanitizeElement(d.billingAddress2||".billing-address1"),d.billingAddress2=b._sanitizeElement(d.billingAddress2||".billing-address2"),d.billingCity=b._sanitizeElement(d.billingCity||".billing-city"),d.billingState=b._sanitizeElement(d.billingState||".billing-state"),d.billingZip=b._sanitizeElement(d.billingZip||".billing-zip"),d.billingCountry=b._sanitizeElement(d.billingCountry||".billing-country"),d.billing=!!(d.billingName||d.billingAddress1||d.billingAddress2||d.billingCity||d.billingState||d.billingZip||d.billingCountry),c.fields=d,c.name=c.name||"card"},b._sanitizeElement=function(a){return jQuery?jQuery(a).get(0):"string"==typeof a?"."===a[0]?document.getElementsByClassName(a.substring(1))[0]:document.getElementById(a):"object"==typeof a&&null!==a&&0===a.toString().indexOf("[object HTML")?a:null},b._findDefaultFormElement=function(){var a=document.getElementsByClassName("card-number")[0];if(a)for(;;){if(!(a=a.parentNode))break;if("FORM"===a.tagName)return a}return null},b._triggerFieldError=function(a,b,c){return"function"==typeof a?a(b,c):void(b&&-1===b.className.indexOf("error")&&(b.className=b.className+" error"));
},b._addEventListener=function(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent("on"+b,function(){return c.call(a,window.event)})},b._preventDefault=function(a){a.preventDefault?a.preventDefault():a.returnValue=!1}}.call(this);