248 lines
7.7 KiB
TypeScript
248 lines
7.7 KiB
TypeScript
// Metro module 6352 (f6353).
|
|
import { NativeModules } from "react-native";
|
|
import { convertToAlpha2 } from "../../i18n/CountryCodeUtils";
|
|
import { CurrencyExponents } from "../../../_bundle/convertToMajorCurrencyUnits";
|
|
import { getProducts } from "../../../_bundle/Module6333";
|
|
let RNIapIosSk2;
|
|
let env4056 = {};
|
|
const productSK2ToIAPProduct = function productSK2ToIAPProduct(a0) {
|
|
const discounts = a0.subscription.promotionalOffers != null ? a0.subscription.promotionalOffers.map((promotionalOffer) => {
|
|
const paymentMode = promotionalOffer.paymentMode;
|
|
const paymentMode2 = paymentMode === "freeTrial" ? "FREETRIAL" : paymentMode === "payAsYouGo" ? "PAYASYOUGO" : paymentMode !== "payUpFront" ? "" : "PAYUPFRONT";
|
|
return {
|
|
identifier: promotionalOffer.id,
|
|
type: "SUBSCRIPTION",
|
|
numberOfPeriods: promotionalOffer.period.value.toString(),
|
|
price: promotionalOffer.price.toString(),
|
|
localizedPrice: promotionalOffer.displayPrice,
|
|
paymentMode: paymentMode2,
|
|
subscriptionPeriod: promotionalOffer.period.unit.toUpperCase()
|
|
};
|
|
}) : [];
|
|
if (a0.subscription.introductoryOffer != null) {
|
|
const introductoryOffer = a0.subscription.introductoryOffer;
|
|
const paymentMode = introductoryOffer.paymentMode;
|
|
const paymentMode2 = paymentMode === "freeTrial" ? "FREETRIAL" : paymentMode === "payAsYouGo" ? "PAYASYOUGO" : paymentMode !== "payUpFront" ? "" : "PAYUPFRONT";
|
|
discounts.push({
|
|
identifier: introductoryOffer.id,
|
|
type: "SUBSCRIPTION",
|
|
numberOfPeriods: introductoryOffer.period.value.toString(),
|
|
price: introductoryOffer.price.toString(),
|
|
localizedPrice: introductoryOffer.displayPrice,
|
|
paymentMode: paymentMode2,
|
|
subscriptionPeriod: introductoryOffer.period.unit.toUpperCase()
|
|
});
|
|
}
|
|
const price = Number(a0.price.toFixed(CurrencyExponents[a0.currency.toLowerCase()]));
|
|
return {
|
|
identifier: String(a0.id),
|
|
price,
|
|
currencySymbol: a0.displayPrice.split(/[0-9]/)[0],
|
|
currencyCode: a0.currency.toLowerCase(),
|
|
priceString: String(price),
|
|
countryCode: "",
|
|
downloadable: false,
|
|
description: a0.description,
|
|
title: a0.displayName,
|
|
discounts
|
|
};
|
|
};
|
|
RNIapIosSk2 = NativeModules.RNIapIosSk2;
|
|
class StorekitIAPQueueClass {
|
|
constructor() {
|
|
return {
|
|
__proto__: new.target.prototype,
|
|
_queue: [],
|
|
_processingQueue: false
|
|
};
|
|
}
|
|
fetchSubscriptions(c15683_0) {
|
|
const _this = this;
|
|
const promise = new Promise((c25828_0, c25828_1) => {
|
|
_this._queue.push(async () => {
|
|
let c29759_0, c29759_1, c29759_2;
|
|
let c29759_3 = 0;
|
|
const r12 = void 0;
|
|
L10: {
|
|
try {
|
|
let env31419;
|
|
c29759_1 = r12;
|
|
const r27 = env31419 = {};
|
|
c29759_0 = r27;
|
|
env31419[0] = void 0;
|
|
c29759_3 = 1;
|
|
env31419[0] = (await RNIapIosSk2.getItems(c15683_0)).filter((item) => item.subscription != null).map(productSK2ToIAPProduct);
|
|
(0, c25828_0)(env31419[0]);
|
|
c29759_3 = 0;
|
|
} catch ($e) {
|
|
const r25 = $e;
|
|
let r7 = r25;
|
|
c29759_2 = r25;
|
|
if (c29759_3 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r64 = c29759_2;
|
|
c29759_3 = 0;
|
|
(0, c25828_1)(r64);
|
|
break L10;
|
|
} catch (r61) {
|
|
r7 = r61;
|
|
c29759_2 = r61;
|
|
if (c29759_3 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r7;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
this.processQueue();
|
|
return promise;
|
|
}
|
|
fetchProducts(skus) {
|
|
const _this2 = this;
|
|
const promise = new Promise((c25829_0, c25829_1) => {
|
|
_this2._queue.push(async () => {
|
|
let c29760_0, c29760_1, c29760_2;
|
|
let c29760_3 = 0;
|
|
const r12 = void 0;
|
|
const r11 = env4056;
|
|
L10: {
|
|
try {
|
|
let env31420;
|
|
c29760_1 = r12;
|
|
const r26 = env31420 = {
|
|
$parent: r11
|
|
};
|
|
c29760_0 = r26;
|
|
env31420[0] = void 0;
|
|
c29760_3 = 1;
|
|
env31420[0] = await getProducts({
|
|
skus
|
|
}).then((result) => result.filter((item) => item.type === "iap").map((item) => (function mapToIAPProduct(a0) {
|
|
let countryCode = "";
|
|
if (a0.countryCode != null && a0.countryCode.length !== 0) {
|
|
try {
|
|
countryCode = (0, convertToAlpha2)(a0.countryCode);
|
|
} catch ($e) {}
|
|
}
|
|
const r15 = {
|
|
identifier: a0.productId,
|
|
price: parseFloat(a0.price),
|
|
currencySymbol: null,
|
|
currencyCode: null,
|
|
priceString: null,
|
|
countryCode: null,
|
|
downloadable: false,
|
|
description: null,
|
|
title: null,
|
|
discounts: null
|
|
};
|
|
const localizedPrice = a0.localizedPrice;
|
|
r15.currencySymbol = localizedPrice == null ? void 0 : localizedPrice.split(/[0-9]/)[0];
|
|
r15.currencyCode = a0.currency.toLowerCase();
|
|
r15.priceString = a0.price;
|
|
r15.countryCode = countryCode;
|
|
r15.description = a0.description;
|
|
r15.title = a0.title;
|
|
r15.discounts = "discounts" in a0 ? a0.discounts : void 0;
|
|
return r15;
|
|
})(item)));
|
|
(0, c25829_0)(env31420[0]);
|
|
c29760_3 = 0;
|
|
} catch ($e) {
|
|
const r24 = $e;
|
|
let r7 = r24;
|
|
c29760_2 = r24;
|
|
if (c29760_3 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r64 = c29760_2;
|
|
c29760_3 = 0;
|
|
(0, c25829_1)(r64);
|
|
break L10;
|
|
} catch (r61) {
|
|
r7 = r61;
|
|
c29760_2 = r61;
|
|
if (c29760_3 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r7;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
this.processQueue();
|
|
return promise;
|
|
}
|
|
async processQueue() {
|
|
const _this3 = this;
|
|
let c25830_2;
|
|
let c25830_3 = 0;
|
|
let c29761_0;
|
|
L19: {
|
|
L17: {
|
|
try {
|
|
c29761_0 = void 0;
|
|
if (_this3._processingQueue) {
|
|
break L19;
|
|
}
|
|
_this3._processingQueue = true;
|
|
c25830_3 = 1;
|
|
if (!(_this3._queue.length > 0)) {
|
|
c25830_3 = 0;
|
|
_this3._processingQueue = false;
|
|
break L19;
|
|
}
|
|
c29761_0 = _this3._queue.shift();
|
|
await (0, c29761_0)();
|
|
while (true) {
|
|
if (!(_this3._queue.length > 0)) {
|
|
c25830_3 = 0;
|
|
_this3._processingQueue = false;
|
|
break L17;
|
|
}
|
|
c29761_0 = _this3._queue.shift();
|
|
await (0, c29761_0)();
|
|
}
|
|
break L19;
|
|
} catch ($e) {
|
|
const r26 = $e;
|
|
let r8 = r26;
|
|
c25830_2 = r26;
|
|
if (c25830_3 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r99 = c25830_2;
|
|
c25830_3 = 0;
|
|
_this3._processingQueue = false;
|
|
throw r99;
|
|
} catch (r96) {
|
|
r8 = r96;
|
|
c25830_2 = r96;
|
|
if (c25830_3 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
}
|
|
return void 0;
|
|
}
|
|
}
|
|
}
|
|
const r33 = {
|
|
__proto__: StorekitIAPQueueClass.prototype,
|
|
_queue: [],
|
|
_processingQueue: false
|
|
};
|
|
export default r33;
|