Build 589089stable
Module 354729
2,954 characters · in 514.d733764d42c2ab66.jsDependencies
Source Raw
function(e,t){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var r,i="basil",a="https://js.stripe.com",o="".concat(a,"/").concat(i,"/stripe.js"),s=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,l=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/,u="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",c=function(){for(var e=document.querySelectorAll('script[src^="'.concat(a,'"]')),t=0;t<e.length;t++){var n,r=e[t];if(n=r.src,s.test(n)||l.test(n))return r}return null},d=function(e){var t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",n=document.createElement("script");n.src="".concat(o).concat(t);var r=document.head||document.body;if(!r)throw Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return r.appendChild(n),n},f=function(e,t){e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",version:"7.3.1",startTime:t})},p=null,h=null,m=null,g=function(e,t,n){if(null===e)return null;var r,a=t[0].match(/^pk_test/),o=3===(r=e.version)?"v3":r;a&&o!==i&&console.warn("Stripe.js@".concat(o," was loaded on the page, but @stripe/stripe-js@").concat("7.3.1"," expected Stripe.js@").concat(i,". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));var s=e.apply(void 0,t);return f(s,n),s},v=function(e){var t="invalid load parameters; expected object of shape\n\n {advancedFraudSignals: boolean}\n\nbut received\n\n ".concat(JSON.stringify(e),"\n");if(null===e||"object"!==n(e))throw Error(t);if(1===Object.keys(e).length&&"boolean"==typeof e.advancedFraudSignals)return e;throw Error(t)},y=!1,b=function(){for(var e,t=arguments.length,n=Array(t),i=0;i<t;i++)n[i]=arguments[i];y=!0;var a=Date.now();return(e=r,null!==p?p:(p=new Promise(function(t,n){if("u"<typeof window||"u"<typeof document)return void t(null);if(window.Stripe&&e&&console.warn(u),window.Stripe)return void t(window.Stripe);try{var r,i=c();i&&e?console.warn(u):i?i&&null!==m&&null!==h&&(i.removeEventListener("load",m),i.removeEventListener("error",h),null==(r=i.parentNode)||r.removeChild(i),i=d(e)):i=d(e),m=function(){window.Stripe?t(window.Stripe):n(Error("Stripe.js not available"))},h=function(e){n(Error("Failed to load Stripe.js",{cause:e}))},i.addEventListener("load",m),i.addEventListener("error",h)}catch(e){n(e);return}})).catch(function(e){return p=null,Promise.reject(e)})).then(function(e){return g(e,n,a)})};b.setLoadParameters=function(e){if(!(y&&r&&Object.keys(v(e)).reduce(function(t,n){var i;return t&&e[n]===(null==(i=r)?void 0:i[n])},!0))){if(y)throw Error("You cannot change load parameters after calling loadStripe");r=v(e)}},t.loadStripe=b}