// Module ID: 14963 // Function ID: 14964 // Name: ChangeSpendingLimitFormState // Dependencies: [5, 32, 19, 7611, 14880, 504, 7309, 14882, 2] // Exports: useChangeSpendingLimitFormState // Module 14963 (ChangeSpendingLimitFormState) import SpendingLimitUtils from "SpendingLimitUtils" /* 14882 */; import asyncGeneratorStep from "asyncGeneratorStep" /* 5 */; import _slicedToArray from "module_32" /* 32 */; import noop from "module_19" /* 19 */; import FamilyCenterStore from "FamilyCenterStore" /* 7611 */; const require = globalThis.__r; require = fn; const size = fn(2); const result = size.fileFinishedImporting("modules/parent_tools/ChangeSpendingLimitFormState.tsx"); export const useChangeSpendingLimitFormState = function useChangeSpendingLimitFormState(teenId) { _require = teenId; let ParentalControlledSpendingLimit = require("ParentalControlledUserSettings").ParentalControlledSpendingLimit; controlledSetting = ParentalControlledSpendingLimit.useControlledSetting(teenId); const items = [closure_5]; const stateFromStores = require("initialize").useStateFromStores(items, () => closure_5.getSpendingLimit()); let obj = require("initialize"); const items1 = [closure_5]; const stateFromStores1 = require("initialize").useStateFromStores(items1, () => { const monthlyPurchases = closure_5.getMonthlyPurchases(); let total_amount; if (monthlyPurchases != null) { total_amount = monthlyPurchases.total_amount; } if (total_amount == null) { total_amount = null; } return total_amount; }); let str; if (controlledSetting != null) { str = controlledSetting.currency; } if (str == null) { let currency; if (stateFromStores != null) { currency = stateFromStores.currency; } str = currency; } if (str == null) { str = "usd"; } const formatted = str.toLowerCase(); let num = tmp(tmp2[6]).CurrencyExponents[formatted]; if (num == null) { num = 2; } const items2 = [formatted]; const memo = noop.useMemo(() => SpendingLimitUtils.getCurrencySymbol(formatted), items2); const memo1 = noop.useMemo(tmp(tmp2[7]).getNextRenewalDateLabel, []); let obj2 = require("initialize"); const tmp10 = num; [tmp12, noop] = num(noop.useState(() => { let str = ""; if (null != controlledSetting) { const _String = String; str = String(tmp.amount / 10 ** num); } return str; }), 2); const items3 = [num]; let tmp14 = "" === tmp12; const callback = noop.useCallback((arg0) => noop(SpendingLimitUtils.sanitizeAmountInput(arg0, num)), items3); if (tmp14) { tmp14 = null != controlledSetting; } closure_5 = tmp14; const parsed = parseFloat(tmp12); const isNaNResult = Number.isNaN(parsed); let tmp17 = !isNaNResult; if (!isNaNResult) { tmp17 = parsed >= 0; } let tmp18 = tmp14; if (!tmp14) { tmp18 = tmp17; } closure_6 = tmp18; let rounded = null; if (tmp17) { const _Math = Math; rounded = Math.round(parsed * 10 ** num); } const tmp10Result = tmp10(noop.useState(false), 2); closure_8 = tmp10Result[1]; const items4 = [tmp18, tmp14, rounded, teenId, formatted]; let obj4 = { amountInput: tmp12, handleAmountChange: callback, currency: formatted, currencySymbol: memo, exponent: num, isClearingCap: tmp14, isOverspending: null, canSave: null, isSubmitting: null, renewalDate: null, monthlySpend: null, save: null }; let tmp23 = null != stateFromStores1; const callback1 = obj3.useCallback(formatted(function*(arg0, value) { if (c4 === 2) { c4 = 3; throw new TypeError("Generator functions may not be called on executing generators"); } else if (tmp6 === 3) { if (arg0 === 1) { throw value; } else if (arg0 === 2) { const obj2 = { value, done: true }; return obj2; } else { return { value: "HermesInternal", done: null }; } } else { try { c4 = 2; if (0 === dependencyMap) { if (arg0 === 1) { c4 = 3; throw value; } else if (arg0 === 2) { c4 = 3; const obj3 = { value, done: true }; return obj3; } else { if (closure_6) { closure_8(true); c3 = 1; if (closure_5) { const ParentalControlledSpendingLimit2 = tmp3(14880).ParentalControlledSpendingLimit; dependencyMap = 2; c4 = 1; const obj4 = { value: ParentalControlledSpendingLimit2.updateControlledSetting(tmp3, null), done: false }; return obj4; } else if (null != rounded) { const ParentalControlledSpendingLimit = tmp3(14880).ParentalControlledSpendingLimit; const obj5 = { amount: tmp16, currency: formatted }; dependencyMap = 3; c4 = 1; const obj6 = { value: ParentalControlledSpendingLimit.updateControlledSetting(tmp3, obj5), done: false }; return obj6; } } c4 = 3; return { value: "HermesInternal", done: null }; } } else if (1 === tmp7) { c3 = 0; closure_128_8(false); throw closure_2; } else if (2 === tmp7) { if (arg0 === 1) { c4 = 3; throw value; } else if (arg0 === 2) { c3 = 0; closure_128_8(false); c4 = 3; const obj7 = { value, done: true }; return obj7; } } else if (arg0 === 1) { c4 = 3; throw value; } else if (arg0 === 2) { c3 = 0; closure_128_8(false); c4 = 3; const obj = { value, done: true }; return obj; } c3 = 0; closure_128_8(false); } catch (tmp27) { closure_2 = tmp27; if (tmp4 === c3) { c4 = tmp2; throw tmp27; } else { dependencyMap = tmp; } } } }), items4); if (tmp23) { tmp23 = stateFromStores1 > 0; } if (tmp23) { tmp23 = null != rounded; } if (tmp23) { tmp23 = rounded <= stateFromStores1; } obj4.isOverspending = tmp23; obj4.canSave = tmp18; obj4.isSubmitting = tmp10Result[0]; obj4.renewalDate = memo1; obj4.monthlySpend = stateFromStores1; obj4.save = callback1; return obj4; };