2026-07-24 07:16:23 +00:00
// Module ID: 8246
// Function ID: 65092
2026-07-20 16:05:17 +00:00
// Name: _createForOfIteratorHelperLoose
2026-07-24 07:16:23 +00:00
// Dependencies: [57, 31, 3781, 653, 1851, 44, 8247, 3776, 5638, 566, 8249, 3712, 2]
2026-07-20 16:05:17 +00:00
// Exports: didBeginPurchaseFlowOnFractionalPremium, getOrFetchSubscriptionPlan, getSubscriptionPauseDurations, getSubscriptionSKUs, subscriptionCanDowngrade, useGetOrFetchSubscriptionPlan
2026-07-24 07:16:23 +00:00
// Module 8246 (_createForOfIteratorHelperLoose)
2026-07-23 10:11:24 +00:00
import _slicedToArray from "_slicedToArray" ;
import result from "result" ;
import _isNativeReflectConstruct from "_isNativeReflectConstruct" ;
import ME from "ME" ;
import GuildFeatures from "GuildFeatures" ;
let closure_6 ;
let closure_7 ;
let closure_8 ;
let closure_9 ;
const require = arg1 ;
function _createForOfIteratorHelperLoose ( iterable ) {
let closure_0 = iterable ;
iterable = "undefined" !== typeof Symbol ;
if ( iterable ) {
2026-07-20 16:05:17 +00:00
const _Symbol = Symbol ;
2026-07-23 10:11:24 +00:00
iterable = iterable [ Symbol . iterator ] ;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
if ( ! iterable ) {
iterable = iterable [ Symbol . iterator ] ;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
if ( iterable ) {
const iter = iterable . call ( iterable ) ;
2026-07-20 16:05:17 +00:00
const next = iter . next ;
return next . bind ( iter ) ;
} else {
const _Array = Array ;
2026-07-23 10:11:24 +00:00
let tmp = iterable ;
if ( ! Array . isArray ( iterable ) ) {
2026-07-20 16:05:17 +00:00
let tmp2 ;
2026-07-23 10:11:24 +00:00
if ( iterable ) {
if ( "string" === typeof iterable ) {
tmp2 = _arrayLikeToArray ( iterable , undefined ) ;
2026-07-20 16:05:17 +00:00
} else {
const toString = { } . toString ;
2026-07-23 10:11:24 +00:00
const substr = toString . call ( iterable ) . slice ( 8 , - 1 ) ;
2026-07-20 16:05:17 +00:00
let name = substr ;
if ( tmp3 ) {
2026-07-23 10:11:24 +00:00
name = iterable . constructor . name ;
2026-07-20 16:05:17 +00:00
}
if ( "Map" !== name ) {
if ( "Set" !== name ) {
if ( "Arguments" === name ) {
2026-07-23 10:11:24 +00:00
let arr = _arrayLikeToArray ( iterable , undefined ) ;
2026-07-20 16:05:17 +00:00
} else {
2026-07-23 10:11:24 +00:00
let obj = /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/ ;
2026-07-20 16:05:17 +00:00
}
}
tmp2 = arr ;
}
const _Array2 = Array ;
2026-07-23 10:11:24 +00:00
arr = Array . from ( iterable ) ;
const callResult = toString . call ( iterable ) ;
tmp3 = "Object" === substr && iterable . constructor ;
2026-07-20 16:05:17 +00:00
}
}
tmp = tmp2 ;
if ( ! tmp2 ) {
const _TypeError = TypeError ;
const typeError = new TypeError ( "Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method." ) ;
throw typeError ;
}
}
if ( tmp ) {
2026-07-23 10:11:24 +00:00
closure_0 = tmp ;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
let c1 = 0 ;
2026-07-20 16:05:17 +00:00
return ( ) = > {
2026-07-23 10:11:24 +00:00
if ( closure_1 >= length . length ) {
2026-07-20 16:05:17 +00:00
let obj = { done : true } ;
} else {
obj = { done : false } ;
closure_1 = tmp3 + 1 ;
2026-07-23 10:11:24 +00:00
obj . value = length [ + closure_1 ] ;
2026-07-20 16:05:17 +00:00
}
return obj ;
} ;
}
}
function _arrayLikeToArray ( arg0 , arg1 ) {
let length ;
if ( tmp ) {
length = arg0 . length ;
}
const ArrayResult = Array ( length ) ;
for ( let num = 0 ; num < length ; num = num + 1 ) {
ArrayResult [ num ] = arg0 [ num ] ;
}
return ArrayResult ;
}
function getSubscriptionPlans ( items ) {
items = items . items ;
return items . map ( ( planId ) = > {
2026-07-23 10:11:24 +00:00
const value = outer1_5 . get ( planId . planId ) ;
outer1_1 ( outer1_2 [ 5 ] ) ( null != value , "Unable to fetch plan" ) ;
2026-07-20 16:05:17 +00:00
return value ;
} ) ;
}
function subscriptionCanSwitchImmediately ( getCurrentSubscriptionPlanIdForGroup , newPlanId , arr ) {
const currentSubscriptionPlanIdForGroup = getCurrentSubscriptionPlanIdForGroup . getCurrentSubscriptionPlanIdForGroup ( arr ) ;
if ( getCurrentSubscriptionPlanIdForGroup . type === constants2 . PREMIUM ) {
if ( null == currentSubscriptionPlanIdForGroup ) {
return true ;
}
}
let obj = { oldPlanId : currentSubscriptionPlanIdForGroup , newPlanId } ;
if ( null == currentSubscriptionPlanIdForGroup ) {
2026-07-24 07:16:23 +00:00
const CheckoutError2 = require ( 8247 ) /* _isNativeReflectConstruct */ . CheckoutError ;
2026-07-20 16:05:17 +00:00
obj = { message : "Current subscription has no plan in group" } ;
obj . extraSentryInformation = obj ;
const prototype2 = CheckoutError2 . prototype ;
const checkoutError2 = new CheckoutError2 ( obj ) ;
throw checkoutError2 ;
} else {
if ( currentSubscriptionPlanIdForGroup === closure_8 . PREMIUM_YEAR_TIER_1 ) {
if ( newPlanId === closure_8 . PREMIUM_MONTH_TIER_2 ) {
2026-07-24 07:16:23 +00:00
const CheckoutError = require ( 8247 ) /* _isNativeReflectConstruct */ . CheckoutError ;
2026-07-20 16:05:17 +00:00
obj = { message : "Unexpected plan switch" } ;
obj . extraSentryInformation = obj ;
const prototype = CheckoutError . prototype ;
const checkoutError = new CheckoutError ( obj ) ;
throw checkoutError ;
}
}
const index = arr . indexOf ( currentSubscriptionPlanIdForGroup ) ;
return index < arr . indexOf ( newPlanId ) ;
}
}
2026-07-23 10:11:24 +00:00
( { SubscriptionStatusTypes : closure_6 , SubscriptionTypes : closure_7 } = ME ) ;
( { SubscriptionPlans : closure_8 , SubscriptionPlanInfo : closure_9 } = GuildFeatures ) ;
let result = require ( "_isNativeReflectConstruct" ) . fileFinishedImporting ( "utils/SubscriptionUtils.tsx" ) ;
2026-07-20 16:05:17 +00:00
export { getSubscriptionPlans } ;
export const getSubscriptionSKUs = function getSubscriptionSKUs ( items ) {
return getSubscriptionPlans ( items ) . map ( ( skuId ) = > skuId . skuId ) ;
} ;
export { subscriptionCanSwitchImmediately } ;
export const subscriptionCanDowngrade = function subscriptionCanDowngrade ( getCurrentSubscriptionPlanIdForGroup , newPlanId , arr ) {
return ! subscriptionCanSwitchImmediately ( getCurrentSubscriptionPlanIdForGroup , newPlanId , arr ) ;
} ;
2026-07-23 10:11:24 +00:00
export const getOrFetchSubscriptionPlan = function getOrFetchSubscriptionPlan ( subscriptionPlanId , closure_1 ) {
const value = _isNativeReflectConstruct . get ( subscriptionPlanId ) ;
2026-07-20 16:05:17 +00:00
if ( null == value ) {
const _HermesInternal = HermesInternal ;
2026-07-23 10:11:24 +00:00
importDefault ( 44 ) ( null != table [ subscriptionPlanId ] , "Missing hardcoded subscriptionPlan: " + subscriptionPlanId ) ;
const tmp10 = importDefault ( 44 ) ;
const tmp11 = null != table [ subscriptionPlanId ] ;
const result = require ( 3776 ) /* _createForOfIteratorHelperLoose */ . castPremiumSubscriptionAsSkuId ( tmp7 . skuId ) ;
if ( ! _isNativeReflectConstruct . isFetchingForSKU ( result ) ) {
const subscriptionPlansForSKU = require ( 5638 ) /* fetchSubscriptionPlansForSKU */ . fetchSubscriptionPlansForSKU ( result , closure_1 ) ;
const obj = require ( 5638 ) /* fetchSubscriptionPlansForSKU */ ;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
const obj2 = require ( 3776 ) /* _createForOfIteratorHelperLoose */ ;
2026-07-20 16:05:17 +00:00
}
return value ;
} ;
export const useGetOrFetchSubscriptionPlan = function useGetOrFetchSubscriptionPlan ( subscriptionPlanId ) {
2026-07-23 10:11:24 +00:00
const _require = subscriptionPlanId ;
let closure_1 = arg1 ;
let items = [ _isNativeReflectConstruct ] ;
const tmp = callback ( _require ( first [ 9 ] ) . useStateFromStoresArray ( items , ( ) = > {
2026-07-20 16:05:17 +00:00
let value = null ;
2026-07-23 10:11:24 +00:00
if ( null != closure_0 ) {
value = outer1_5 . get ( closure_0 ) ;
2026-07-20 16:05:17 +00:00
}
const items = [ value , ] ;
let isFetchingForSKUResult = null != value ;
if ( isFetchingForSKUResult ) {
2026-07-23 10:11:24 +00:00
isFetchingForSKUResult = outer1_5 . isFetchingForSKU ( value . skuId ) ;
2026-07-20 16:05:17 +00:00
}
items [ 1 ] = isFetchingForSKUResult ;
return items ;
} ) , 2 ) ;
2026-07-23 10:11:24 +00:00
first = tmp [ 0 ] ;
callback = tmp3 ;
2026-07-20 16:05:17 +00:00
const items1 = [ first , subscriptionPlanId , arg1 , tmp [ 1 ] ] ;
const effect = React . useEffect ( ( ) = > {
if ( null == first ) {
2026-07-23 10:11:24 +00:00
if ( null != subscriptionPlanId ) {
if ( ! _slicedToArray ) {
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal ;
2026-07-23 10:11:24 +00:00
callback ( first [ 5 ] ) ( null != outer1_9 [ subscriptionPlanId ] , "Missing hardcoded subscriptionPlan: " + subscriptionPlanId ) ;
const tmp6 = callback ( first [ 5 ] ) ;
const tmp7 = null != outer1_9 [ subscriptionPlanId ] ;
const obj = subscriptionPlanId ( first [ 8 ] ) ;
const subscriptionPlansForSKU = obj . fetchSubscriptionPlansForSKU ( subscriptionPlanId ( first [ 7 ] ) . castPremiumSubscriptionAsSkuId ( tmp3 . skuId ) , callback ) ;
const obj2 = subscriptionPlanId ( first [ 7 ] ) ;
2026-07-20 16:05:17 +00:00
}
}
}
} , items1 ) ;
return first ;
} ;
export const getSubscriptionPauseDurations = function getSubscriptionPauseDurations ( status ) {
let iter2 ;
2026-07-24 07:16:23 +00:00
const keys = Object . keys ( require ( 8249 ) /* PauseDuration */ . PauseDuration ) ;
2026-07-20 16:05:17 +00:00
const found = keys . filter ( ( arg0 ) = > isNaN ( Number ( arg0 ) ) ) ;
if ( status . status !== constants . PAUSED ) {
let obj = { durations : found , currentDaysPaused : 0 } ;
return obj ;
} else if ( null != status . pauseEndsAt ) {
2026-07-23 10:11:24 +00:00
const tmp4 = importDefault ( 3712 ) ( status . currentPeriodStart ) ;
2026-07-20 16:05:17 +00:00
const _Math = Math ;
2026-07-23 10:11:24 +00:00
const rounded = Math . round ( importDefault ( 3712 ) ( status . pauseEndsAt ) . diff ( tmp4 , "days" , true ) ) ;
2026-07-20 16:05:17 +00:00
const items = [ ] ;
const tmp7 = _createForOfIteratorHelperLoose ( found ) ;
let iter = tmp7 ( ) ;
if ( ! iter . done ) {
do {
let value = iter . value ;
2026-07-23 10:11:24 +00:00
let tmp8 = require ;
let tmp9 = dependencyMap ;
2026-07-24 07:16:23 +00:00
if ( require ( 8249 ) /* PauseDuration */ . PauseDuration [ value ] > rounded ) {
2026-07-20 16:05:17 +00:00
let arr = items . push ( value ) ;
}
iter2 = tmp7 ( ) ;
iter = iter2 ;
} while ( ! iter2 . done ) ;
}
obj = { durations : items , currentDaysPaused : rounded } ;
return obj ;
} else {
obj = { durations : [ ] , currentDaysPaused : 0 } ;
return obj ;
}
} ;
export const didBeginPurchaseFlowOnFractionalPremium = function didBeginPurchaseFlowOnFractionalPremium ( isSameOrAfter ) {
let isMomentResult = null != isSameOrAfter ;
if ( isMomentResult ) {
2026-07-23 10:11:24 +00:00
isMomentResult = importDefault ( 3712 ) . isMoment ( isSameOrAfter ) ;
const obj = importDefault ( 3712 ) ;
2026-07-20 16:05:17 +00:00
}
if ( isMomentResult ) {
2026-07-23 10:11:24 +00:00
isMomentResult = isSameOrAfter . isSameOrAfter ( importDefault ( 3712 ) ( ) ) ;
2026-07-20 16:05:17 +00:00
}
return isMomentResult ;
} ;