Files
discord-decomp/_bundle/isStripeJSURL.js
T
2026-11-01 12:12:55 +02:00

193 lines
6.8 KiB
JavaScript

// Metro module 4517 (f4518).
let c2725_1, c2725_2, c2725_3, c2725_4, c2725_5, c2725_6, c2725_7, isStripeJSURL, injectScript, c2725_10, c2725_11, c2725_12, loadScript, validateLoadParams, c2725_15;
const _typeof = function _typeof(a0) {
_typeof = typeof globalThis.Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(a0) {
return typeof a0;
} : function(a0) {
return a0 && typeof globalThis.Symbol === "function" && a0.constructor === Symbol ? a0 === Symbol.prototype ? typeof a0 : "symbol" : typeof a0;
};
return _typeof(a0);
};
c2725_2 = "basil";
c2725_3 = "https://js.stripe.com";
c2725_4 = "".concat("https://js.stripe.com", "/").concat("basil", "/stripe.js");
c2725_5 = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
c2725_6 = /^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/;
c2725_7 = "loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";
isStripeJSURL = function isStripeJSURL(a0) {};
injectScript = function injectScript(a0) {
const r4 = a0 ? a0.advancedFraudSignals ? "" : "?advancedFraudSignals=false" : "";
const element = document.createElement("script");
element.src = "".concat(c2725_4).concat(r4);
const r18 = document.head || document.body;
if (r18) {
r18.appendChild(element);
return element;
}
throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");
};
c2725_10 = null;
c2725_11 = null;
c2725_12 = null;
loadScript = function loadScript(a0) {};
validateLoadParams = function validateLoadParams(a0) {};
c2725_15 = false;
export function loadStripe() {
const length = arguments.length;
const array = new Array(length);
let c14282_0 = array;
let r0 = 0;
while (r0 < length) {
array[r0] = arguments[r0];
r0 = r0 + 1;
}
c2725_15 = true;
const startTime = Date.now();
let c14283_0 = c2725_1;
let r26 = c2725_10;
if (r26 === null) {
const promise = new Promise(function(resolve, reject) {
L25: {
if (typeof globalThis.window !== "undefined" && typeof globalThis.document !== "undefined") {
if (window.Stripe && c14283_0) {
console.warn(c2725_7);
}
if (window.Stripe) {
resolve(window.Stripe);
break L25;
}
try {
const r27 = (function findScript() {
const r15 = document.querySelectorAll("script[src^=\"".concat(c2725_3, "\"]"));
const length = r15.length;
let r0 = 0;
if (0 < length) {
do {
const r17 = r15[r0];
const src = r17.src;
const r1 = r0;
if (c2725_5.test(src) || c2725_6.test(src)) {
return r17;
}
r0 = r1 + 1;
} while (r0 < r15.length);
}
return null;
})();
let r28 = r27;
if (r27 && c14283_0) {
console.warn(c2725_7);
} else if (r28) {
if (r28 && c2725_12 !== null && c2725_11 !== null) {
const r36 = r28;
r36.removeEventListener("load", c2725_12);
r36.removeEventListener("error", c2725_11);
const parentNode = r36.parentNode;
if (!(parentNode === null || parentNode === void 0)) {
parentNode.removeChild(r28);
}
r28 = injectScript(c14283_0);
}
} else {
r28 = injectScript(c14283_0);
}
c2725_12 = (function onLoad(c29400_0, c29400_1) {
return function() {
if (window.Stripe) {
c29400_0(window.Stripe);
} else {
c29400_1(new Error("Stripe.js not available"));
}
};
})(resolve, reject);
c2725_11 = (function onError(c29401_0) {
return function(a0) {
c29401_0(new Error("Failed to load Stripe.js", {
cause: a0
}));
};
})(reject);
const r60 = r28;
r60.addEventListener("load", c2725_12);
r60.addEventListener("error", c2725_11);
break L25;
} catch ($e) {
reject($e);
return void 0;
}
}
resolve(null);
}
});
c2725_10 = promise;
r26 = promise.catch(function(error) {
c2725_10 = null;
return Promise.reject(error);
});
}
return r26.then(function(result) {
let r13 = null;
if (result !== null) {
let r14 = c14282_0[0].match(/^pk_test/);
const version = result.version;
const r12 = version !== 3 ? version : "v3";
if (r14) {
r14 = r12 !== c2725_2;
}
if (r14) {
console.warn("Stripe.js@".concat(r12, " was loaded on the page, but @stripe/stripe-js@").concat("7.3.1", " expected Stripe.js@").concat(c2725_2, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
}
const r31 = result.apply(void 0, c14282_0);
const r32 = r31 ? r31._registerWrapper : r31;
r13 = r31;
if (r32) {
r31._registerWrapper({
name: "stripe-js",
version: "7.3.1",
startTime
});
r13 = r31;
}
}
return r13;
});
}
loadStripe.setLoadParameters = function(a0) {
let c14284_0;
L10: {
c14284_0 = a0;
if (c2725_15 && c2725_1) {
const r20 = "invalid load parameters; expected object of shape\n\n {advancedFraudSignals: boolean}\n\nbut received\n\n ".concat(JSON.stringify(a0), "\n");
if (a0 !== null && _typeof(a0) === "object") {
if (Object.keys(a0).length === 1 && typeof a0.advancedFraudSignals === "boolean") {
if (Object.keys(a0).reduce(function(acc, item) {
let r2 = acc;
if (acc) {
const r4 = c14284_0[item];
r2 = r4 === (c2725_1 !== null ? c2725_1 !== void 0 ? c2725_1[item] : void 0 : void 0);
}
return r2;
}, true)) {
return void 0;
}
break L10;
}
throw new Error(r20);
}
throw new Error(r20);
}
}
if (c2725_15) {
throw new Error("You cannot change load parameters after calling loadStripe");
}
const r52 = "invalid load parameters; expected object of shape\n\n {advancedFraudSignals: boolean}\n\nbut received\n\n ".concat(JSON.stringify(a0), "\n");
if (a0 !== null && _typeof(a0) === "object") {
if (Object.keys(a0).length === 1 && typeof a0.advancedFraudSignals === "boolean") {
c2725_1 = a0;
return void 0;
}
throw new Error(r52);
}
throw new Error(r52);
};