98 lines
5.8 KiB
TypeScript
98 lines
5.8 KiB
TypeScript
/* Metro module 13422; source: modules/parent_tools/SpendingLimitDisplay.tsx; dependencies: [1348, 5116, 1880, 566, 13350, 5137, 5138, 1244, 2224, 2] */
|
|
import UserSettingsProtoStore from '../user_settings/UserSettingsProtoStore.tsx'; /* Metro dependency 1348 */
|
|
import FamilyCenterStore from './FamilyCenterStore.tsx'; /* Metro dependency 5116 */
|
|
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
|
|
import * as FluxModule from '../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */
|
|
import * as PremiumConstantsModule from '../premium/PremiumConstants.tsx'; /* Metro dependency 1880 */
|
|
import * as PriceUtilsModule from '../../utils/PriceUtils.tsx'; /* Metro dependency 5137 */
|
|
import * as PriceUtilsModule2 from '../../external/discord_common/js/shared/utils/PriceUtils.tsx'; /* Metro dependency 5138 */
|
|
import * as SpendingLimitUtilsModule from './SpendingLimitUtils.tsx'; /* Metro dependency 13350 */
|
|
|
|
function _fun102130(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#102130, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13612:6, offset: 0x0222e30d, size: 199 bytes, params: 8, frame: 20
|
|
const env0_0 = require;
|
|
const getSpendingLimitDisplayState2 = getSpendingLimitDisplayState;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
(FileImportTrackerModule).fileFinishedImporting('modules/parent_tools/SpendingLimitDisplay.tsx');
|
|
exports.useSpendingLimitFromUserSettings = function() {
|
|
return require(dependencyMap[3]).useStateFromStores([UserSettingsProtoStore], _fun102133, undefined,
|
|
require(dependencyMap[4]).spendingLimitEqual);
|
|
};
|
|
exports.CLOSE_TO_LIMIT_THRESHOLD_MAJOR_UNITS = 10;
|
|
exports.getSpendingLimitDisplayState = getSpendingLimitDisplayState2;
|
|
exports.useSpendingLimitDisplayState = useSpendingLimitDisplayState;
|
|
function getSpendingLimitDisplayState(a0, a1) { // fn#102131, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13612:152, offset: 0x0222e3d4, size: 380 bytes, params: 3, frame: 23
|
|
var object;
|
|
var intl;
|
|
var formatToPlainString;
|
|
var object2;
|
|
if (a0 == null) {
|
|
return {kind: 'off'};
|
|
}
|
|
if (a0.amount === 0) {
|
|
return {kind: 'blocked'};
|
|
}
|
|
const currency = a0.currency;
|
|
const formatRate = PriceUtilsModule.formatRate;
|
|
const value2 = PriceUtilsModule.formatPrice(a0.amount, currency);
|
|
const MONTH = SubscriptionIntervalTypes.MONTH;
|
|
const value3 = Reflect.apply(formatRate, PriceUtilsModule, [value2, MONTH, 1]);
|
|
if (a1 >= a0.amount) {
|
|
return {kind: 'spent', monthlyText: value3};
|
|
}
|
|
const CurrencyExponents = (PriceUtilsModule2).CurrencyExponents;
|
|
let property = CurrencyExponents[a0.currency];
|
|
let r0 = property ?? 2;
|
|
const value5 = a0.amount - a1;
|
|
if (value5 <= 10 * exponentiationOperator(10, r0, undefined)) {
|
|
object = {kind: 'close-to-limit', monthlyText: value3};
|
|
intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
|
|
formatToPlainString = intl.formatToPlainString;
|
|
property = (importDefault(2224) /* metro dependency 2224: FamilyCenterMessages */)['+Q+bU1'];
|
|
object2 = {};
|
|
object2.amount = PriceUtilsModule.formatPrice(value5, currency);
|
|
object.remainingText = Reflect.apply(formatToPlainString, intl, [property, object2]);
|
|
r0 = object;
|
|
} else {
|
|
r0 = {kind: 'on', monthlyText: value3};
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function useSpendingLimitFromUserSettings() { // fn#102132, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13612:769, offset: 0x0222e550, size: 83 bytes, params: 1, frame: 18
|
|
return (FluxModule).useStateFromStores([UserSettingsProtoStore], _fun102133,
|
|
undefined, (SpendingLimitUtilsModule).spendingLimitEqual);
|
|
function _fun102133() { // fn#102133, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13612:852, offset: 0x0222e5a3, size: 104 bytes, params: 1, frame: 14
|
|
var r0;
|
|
var object;
|
|
let value = environment.__proto__;
|
|
const safetySettings = UserSettingsProtoStore.settings.safetySettings;
|
|
value = null;
|
|
const oneTimePurchaseLimit = value == safetySettings || value == safetySettings.spendingLimitSettings ? undefined : safetySettings.spendingLimitSettings.oneTimePurchaseLimit;
|
|
if (value == oneTimePurchaseLimit) {
|
|
r0 = value;
|
|
} else {
|
|
object = {};
|
|
object.amount = global.Number(oneTimePurchaseLimit.amount);
|
|
object.currency = oneTimePurchaseLimit.currency;
|
|
r0 = object;
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
}
|
|
|
|
function useSpendingLimitDisplayState(a0) { // fn#102134, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13612:1203, offset: 0x0222e60b, size: 101 bytes, params: 2, frame: 15
|
|
const value2 = undefined;
|
|
const monthlyPurchases = (require(566) /* metro dependency 566: flux */).useStateFromStores([FamilyCenterStore],
|
|
function() {
|
|
return FamilyCenterStore.getMonthlyPurchases();
|
|
});
|
|
return getSpendingLimitDisplayState(a0, (monthlyPurchases == null ? value2 : monthlyPurchases.total_amount) ?? 0);
|
|
}
|
|
|
|
}
|
|
|
|
global.__d(_fun102130, 13422, [1348, 5116, 1880, 566, 13350, 5137, 5138, 1244, 2224,
|
|
2]) /* metro module 13422, dependencies: [1348, 5116, 1880, 566, 13350, 5137, 5138, 1244, 2224, 2] */;
|