@idosgames/core 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +72 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +350 -33
- package/dist/index.d.ts +350 -33
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var zod=require('zod'),Ht=require('decimal.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Ht__default=/*#__PURE__*/_interopDefault(Ht);var wt=class{listeners=new Map;on(e,t){let i=this.listeners.get(e);return i||(i=new Set,this.listeners.set(e,i)),i.add(t),()=>{this.off(e,t);}}once(e,t){let i=this.on(e,r=>{i(),t(r);});return i}off(e,t){let i=this.listeners.get(e);i&&(i.delete(t),i.size===0&&this.listeners.delete(e));}emit(e,t){let i=this.listeners.get(e);if(i)for(let r of [...i])r(t);}removeAllListeners(){this.listeners.clear();}};function Xl(){let o=new Map;return {get:e=>o.get(e)??null,set:(e,t)=>{o.set(e,t);},remove:e=>{o.delete(e);}}}function ln(){return eu()??Xl()}function eu(){try{let o=globalThis.localStorage;if(!o)return null;let e="__idos_probe__";return o.setItem(e,"1"),o.removeItem(e),{get:t=>{try{return o.getItem(t)}catch{return null}},set:(t,i)=>{try{o.setItem(t,i);}catch{try{o.removeItem(t);}catch{}}},remove:t=>{try{o.removeItem(t);}catch{}}}}catch{return null}}var un="https://api.idosgames.com";function cn(o){return {titleID:o.titleID,titleTemplateID:o.titleTemplateID??"default",buildKey:o.buildKey??"",baseUrl:(o.baseUrl??un).replace(/\/+$/,""),devBuild:o.devBuild??false,debugLogging:o.debugLogging??false,configStorage:o.configStorage??ln(),locale:o.locale??tu()}}function tu(){try{return globalThis.navigator?.language??""}catch{return ""}}var gt=class{getString(e){if(typeof localStorage>"u")return null;try{return localStorage.getItem(e)}catch{return null}}setString(e,t){if(!(typeof localStorage>"u"))try{localStorage.setItem(e,t);}catch{}}remove(e){if(!(typeof localStorage>"u"))try{localStorage.removeItem(e);}catch{}}},Rt=class{map=new Map;getString(e){return this.map.get(e)??null}setString(e,t){this.map.set(e,t);}remove(e){this.map.delete(e);}};function yt(){return globalThis.Telegram?.WebApp??null}function P(){return crypto.randomUUID()}var pn="idos_device_id",Ct=class{storage;constructor(e=new gt){this.storage=e;}getPlatform(){return yt()?.platform??"Web"}getFullURL(){return typeof location<"u"?location.href:""}getStartParameter(){let e=yt()?.initDataUnsafe?.start_param;return typeof e=="string"?e:null}getTelegramInitDataRaw(){let e=yt()?.initData;return e&&e.length>0?e:null}getDeviceID(){let e=this.storage.getString(pn);return e||(e=P(),this.storage.setString(pn,e)),e}getDeviceModel(){return typeof navigator<"u"&&navigator.userAgent?navigator.userAgent:"Web"}shareLink(e){let t=yt();if(t?.openTelegramLink){t.openTelegramLink(e);return}typeof window<"u"&&window.open(e,"_blank");}openInvoice(e){let t=yt();if(t?.openInvoice){t.openInvoice(e);return}typeof window<"u"&&window.open(e,"_blank");}async showAd(e){let t=globalThis;typeof t.showAd=="function"&&await t.showAd(e);}async copyToClipboard(e){typeof navigator<"u"&&navigator.clipboard&&await navigator.clipboard.writeText(e);}};function dn(o){return {ok:true,data:o}}function n(o,e){return {ok:false,reason:o,error:e}}function iu(o){return o.ok}function ru(o){return !o.ok}var Ge={Virtual:"Virtual",Crypto:"Crypto"},St=zod.z.enum(["Virtual","Crypto"]),su={Item:"Item",VirtualCurrency:"VirtualCurrency",CryptoCurrency:"CryptoCurrency",UsdCent:"UsdCent"},Nt=zod.z.enum(["Item","VirtualCurrency","CryptoCurrency","UsdCent"]),nu={TimedEvent:"TimedEvent",Quest:"Quest",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season"},jt=zod.z.enum(["TimedEvent","Quest","Leaderboard","CoopEvent","Season"]),ou={Cyclic:"Cyclic",Scheduled:"Scheduled",Chained:"Chained"},At=zod.z.enum(["Cyclic","Scheduled","Chained"]),he={None:"None",Device:"Device",Email:"Email",iDosGames:"iDosGames",Facebook:"Facebook",Google:"Google",GooglePlay:"GooglePlay",Telegram:"Telegram",Wallet:"Wallet"};var w=zod.z.union([zod.z.number(),zod.z.string()]).transform((o,e)=>{let t=typeof o=="string"?Number(o):o;return Number.isFinite(t)?Math.trunc(t):(e.addIssue({code:zod.z.ZodIssueCode.custom,message:`Invalid integer amount: ${String(o)}`}),zod.z.NEVER)}),L=zod.z.union([zod.z.number(),zod.z.string()]).transform((o,e)=>{let t=typeof o=="number"?String(o):o.trim();return t===""||Number.isNaN(Number(t))?(e.addIssue({code:zod.z.ZodIssueCode.custom,message:`Invalid decimal: ${String(o)}`}),zod.z.NEVER):t}),u=zod.z.string();var Hr=zod.z.object({Type:Nt.nullish(),CurrencyID:zod.z.string().nullish(),Amount:w.nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish()}),au=zod.z.object({Type:jt.nullish(),EntityID:zod.z.string()}),lu=zod.z.object({Address:au.nullish(),Amount:w.nullish(),Source:zod.z.string().nullish()}),me=zod.z.object({Entries:zod.z.array(Hr).nullish(),EventTokens:zod.z.array(lu).nullish()}),hn=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Resources:me.nullish()}),q=zod.z.object({Standard:me.nullish(),PremiumBonuses:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(hn).nullish()}),Z=zod.z.object({Standard:me.nullish(),PremiumDiscounts:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(hn).nullish()}),b=zod.z.object({Grant:q.nullish(),Consume:Z.nullish()}),ut=zod.z.object({FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),FromResult:b.nullish(),ToResult:b.nullish()});zod.z.object({FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),Transferred:me.nullish()});var uu=zod.z.object({ExperimentID:zod.z.string().nullish(),Variants:zod.z.array(zod.z.string()).nullish()}).passthrough(),cu={Completed:"Completed",Started:"Started",StepReached:"StepReached"},pu=zod.z.object({FlowIDs:zod.z.array(zod.z.string()).nullish(),Mode:zod.z.enum(["Completed","Started","StepReached"]).nullish(),StepID:zod.z.string().nullish(),Negate:zod.z.boolean().nullish(),SkippedCountsAsCompleted:zod.z.boolean().nullish()}).passthrough(),Q=zod.z.object({Segments:zod.z.array(zod.z.string()).nullish(),MinPremiumTier:zod.z.number().nullish(),RequiredPremiumIDs:zod.z.array(zod.z.string()).nullish(),MinLevel:zod.z.number().nullish(),MaxLevel:zod.z.number().nullish(),Countries:zod.z.array(zod.z.string()).nullish(),RegisteredWithinDays:zod.z.number().nullish(),ActiveWithinDays:zod.z.number().nullish(),Experiment:uu.nullish(),Tutorial:pu.nullish()}).passthrough();var ge=zod.z.object({TotalCap:zod.z.number().nullish(),DailyCap:zod.z.number().nullish(),DailyWeightCap:zod.z.number().nullish(),PerActivationCap:zod.z.number().nullish(),CooldownSeconds:zod.z.number().nullish(),MaxPerWindow:zod.z.number().nullish(),WindowSeconds:zod.z.number().nullish()}).passthrough();var du=zod.z.object({OffsetSecondsFromParentStart:zod.z.number().nullish(),DurationSeconds:zod.z.number().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),hu=zod.z.object({StartUtc:zod.z.string().nullish(),EndUtc:zod.z.string().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),mu=zod.z.object({AnchorUtc:zod.z.string().nullish(),MaxCycles:zod.z.number().nullish(),PauseBetweenPhasesSec:zod.z.number().nullish(),PauseBetweenCyclesSec:zod.z.number().nullish()}).passthrough();zod.z.object({PhaseID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough();var fu=zod.z.object({Reset:zod.z.string().nullish(),IntervalSeconds:zod.z.number().nullish(),AnchorUtc:zod.z.string().nullish(),PauseBetweenCyclesSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough();zod.z.object({SourceType:zod.z.string().nullish(),TileType:zod.z.string().nullish(),TileIndex:zod.z.number().nullish(),ChanceOutcomeID:zod.z.string().nullish(),Outcome:zod.z.string().nullish(),Params:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough();var Ue=zod.z.object({SourceType:zod.z.string().nullish(),BaseWeight:zod.z.number().nullish(),ScaleWithRollMultiplier:zod.z.boolean().nullish(),TileTypeFilter:zod.z.array(zod.z.string()).nullish(),TileIndexFilter:zod.z.array(zod.z.number()).nullish(),ChanceOutcomeFilter:zod.z.array(zod.z.string()).nullish(),OutcomeFilter:zod.z.array(zod.z.string()).nullish(),Params:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Limits:ge.nullish()}).passthrough(),ce=zod.z.object({Mode:zod.z.string().nullish(),IsActive:zod.z.boolean().nullish(),Scheduled:hu.nullish(),Chain:mu.nullish(),Cyclic:fu.nullish(),ActivationTriggers:zod.z.array(Ue).nullish(),Relative:du.nullish()}).passthrough();var gu=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Rewards:q.nullish()}).passthrough(),Ru=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),$r=zod.z.object({Bundles:zod.z.array(gu).nullish(),Multipliers:zod.z.array(Ru).nullish()}).passthrough();var yu=zod.z.enum(["BoardStageLevel","BoardRank","BoardCyclesCompleted","CharacterLevel","SeasonTier","EventTokenTotalEarned","VirtualCurrencyBalance","PlayerLevel"]);var Cu=zod.z.enum(["Tiered","Linear"]);var Su=zod.z.enum(["Step","Linear"]),xu=zod.z.object({AtProgress:zod.z.number().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),Ft=zod.z.object({Source:yu.nullish(),SourceKey:zod.z.string().nullish(),CurveType:Cu.nullish(),Tiers:zod.z.array(xu).nullish(),TierMode:Su.nullish(),BaseMultiplier:zod.z.number().nullish(),PerUnit:zod.z.number().nullish(),Anchor:zod.z.number().nullish(),MinMultiplier:zod.z.number().nullish(),MaxMultiplier:zod.z.number().nullish(),IncludeRewards:me.nullish(),ExcludeRewards:me.nullish()}).passthrough(),xe=zod.z.object({MilestoneID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),RequiredProgress:zod.z.number().nullish(),Rewards:q.nullish(),BonusRewards:q.nullish(),SeasonTierRewards:$r.nullish(),SortOrder:zod.z.number().nullish(),IsFeatured:zod.z.boolean().nullish()}).passthrough(),rt=zod.z.object({Milestones:zod.z.record(zod.z.string(),xe).nullish()}).passthrough();var te=zod.z.object({PresetID:zod.z.string().nullish(),Remove:zod.z.array(zod.z.string()).nullish()}).passthrough();var Du=zod.z.object({TargetCurrencyID:zod.z.string().nullish(),Rate:zod.z.number().nullish(),MaxConvertAmount:zod.z.number().nullish()}).passthrough(),ct=zod.z.object({DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),MaxBalance:zod.z.number().nullish(),MaxPerGrant:zod.z.number().nullish(),DailyEarnCap:zod.z.number().nullish(),BurnOnEventEnd:zod.z.boolean().nullish(),BurnConversion:Du.nullish()}).passthrough();var se=o=>zod.z.object({Id:zod.z.string(),Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:o.nullish()}),st=o=>zod.z.object({ServerTimeUtc:u,Items:zod.z.array(se(o)),Resources:b.nullish()});var bu={Active:"Active",Completed:"Completed",Claimed:"Claimed",Expired:"Expired"},mn=zod.z.enum(["Active","Completed","Claimed","Expired"]),zu=zod.z.object({}).passthrough().transform(o=>o),Tu=zod.z.object({CycleID:zod.z.string(),InstanceKey:zod.z.string().nullish(),PhaseID:zod.z.string().nullish(),CycleIndex:zod.z.number().nullish(),CycleStartUtc:u.nullish(),CycleEndUtc:u.nullish(),PointsTotalEarned:w.nullish(),PointsCurrent:w.nullish(),ClaimedPointMilestoneIDs:zod.z.array(zod.z.string()).nullish()}),Zr=zod.z.object({QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),ObjectiveID:zod.z.string().nullish(),NewValue:w.nullish(),ObjectiveCompleted:zod.z.boolean().nullish(),Status:mn}),fn=zod.z.object({State:zu.nullish(),PointsTracks:zod.z.record(zod.z.string(),Tu).nullish()}),Jr=zod.z.object({ServerTimeUtc:u,QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),NewStatus:mn.nullish(),Resources:b.nullish()}),Yr=zod.z.object({ServerTimeUtc:u,CycleID:zod.z.string(),MilestoneID:zod.z.string(),PointsTotalEarned:w.nullish(),Resources:b.nullish()}),gn=zod.z.object({ServerTimeUtc:u,CycleID:zod.z.string(),GroupCompletionID:zod.z.string(),GroupID:zod.z.string().nullish(),CompletedGroupQuests:zod.z.number().nullish(),RequiredGroupQuests:zod.z.number().nullish(),Resources:b.nullish()}),Rn=zod.z.object({MetricID:zod.z.string(),Updates:zod.z.array(Zr).nullish()}),yn=zod.z.array(se(Jr)),Cn=zod.z.array(se(Yr)),vu={ClientApi:"ClientApi",ServerApi:"ServerApi",SystemEvent:"SystemEvent"},Pu=zod.z.enum(["ClientApi","ServerApi","SystemEvent"]),Iu={BlockProgressAndClaim:"BlockProgressAndClaim",BlockClaimOnly:"BlockClaimOnly"},ku=zod.z.enum(["BlockProgressAndClaim","BlockClaimOnly"]),Sn=zod.z.object({ObjectiveID:zod.z.string().nullish(),Source:Pu.nullish(),MaxProgressPerCall:zod.z.number().nullish(),MetricID:zod.z.string().nullish(),Triggers:zod.z.array(Ue).nullish(),TargetValue:zod.z.number().nullish(),AggregationMethod:zod.z.string().nullish()}).passthrough(),Xr=zod.z.object({Milestones:te.nullish(),Linking:te.nullish(),Availability:te.nullish(),Reward:te.nullish(),Objectives:te.nullish()}).passthrough(),Mu=zod.z.object({DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),xn=zod.z.object({CycleIDs:zod.z.array(zod.z.string()).nullish(),GroupID:zod.z.string().nullish(),PhaseIDs:zod.z.array(zod.z.string()).nullish(),RequiredQuestIDs:zod.z.array(zod.z.string()).nullish(),PrerequisiteMode:ku.nullish()}).passthrough(),Dn=zod.z.object({Schedule:ce.nullish(),AccrueProgressWhenLocked:zod.z.boolean().nullish(),Gate:Q.nullish(),Limits:ge.nullish()}).passthrough(),bn=zod.z.object({Grant:q.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),wu=zod.z.object({QuestID:zod.z.string().nullish(),Identity:Mu.nullish(),Linking:xn.nullish(),Availability:Dn.nullish(),Objectives:zod.z.record(zod.z.string(),Sn).nullish(),Reward:bn.nullish(),Presets:Xr.nullish()}).passthrough(),Au=zod.z.object({CompletionID:zod.z.string().nullish(),GroupID:zod.z.string().nullish(),RequiredCompletedQuests:zod.z.number().nullish(),Gate:Q.nullish(),Reward:q.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),Uu=zod.z.object({PhaseID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Gate:Q.nullish(),Milestones:zod.z.record(zod.z.string(),xe).nullish(),Presets:Xr.nullish(),PointsToken:ct.nullish()}).passthrough(),Ou=zod.z.object({Milestones:zod.z.record(zod.z.string(),rt).nullish(),Linking:zod.z.record(zod.z.string(),xn).nullish(),Availability:zod.z.record(zod.z.string(),Dn).nullish(),Reward:zod.z.record(zod.z.string(),bn).nullish(),Objectives:zod.z.record(zod.z.string(),zod.z.record(zod.z.string(),Sn)).nullish()}).passthrough(),Bu=zod.z.object({CycleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:ce.nullish(),Milestones:zod.z.record(zod.z.string(),xe).nullish(),Gate:Q.nullish(),PointsToken:ct.nullish(),GroupCompletions:zod.z.record(zod.z.string(),Au).nullish(),Phases:zod.z.record(zod.z.string(),Uu).nullish(),Presets:Xr.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),_t=zod.z.object({Cycles:zod.z.record(zod.z.string(),Bu).nullish(),Quests:zod.z.record(zod.z.string(),wu).nullish(),Presets:Ou.nullish()}).passthrough(),je={GetQuestDefinitions:"GetQuestDefinitions",GetUserQuestState:"GetUserQuestState",RefreshQuestCycles:"RefreshQuestCycles",ClaimQuestReward:"ClaimQuestReward",ClaimMilestoneReward:"ClaimMilestoneReward",AddQuestProgress:"AddQuestProgress",ClaimQuestRewardsBatch:"ClaimQuestRewardsBatch",ClaimMilestoneRewardsBatch:"ClaimMilestoneRewardsBatch",ClaimGroupCompletionReward:"ClaimGroupCompletionReward"};var Lu={ClientAck:"ClientAck",SystemEvent:"SystemEvent",Auto:"Auto",Composite:"Composite"},qu=zod.z.enum(["ClientAck","SystemEvent","Auto","Composite"]),Eu={Never:"Never",OnRequest:"OnRequest",Always:"Always"},Gu=zod.z.enum(["Never","OnRequest","Always"]),Nu={NotStarted:"NotStarted",InProgress:"InProgress",Completed:"Completed",Skipped:"Skipped",Expired:"Expired"},ju=zod.z.enum(["NotStarted","InProgress","Completed","Skipped","Expired"]),Fu={GameLoop:"GameLoop"},Vu={Raid:"Raid",Attack:"Attack"},_u=zod.z.object({Title:zod.z.string().nullish(),TitleKey:zod.z.string().nullish(),Body:zod.z.string().nullish(),BodyKey:zod.z.string().nullish(),AnchorID:zod.z.string().nullish(),HighlightTarget:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),UiHint:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Wu=zod.z.object({Mode:qu.nullish(),Triggers:zod.z.array(Ue).nullish(),TargetValue:zod.z.number().nullish(),RequireAllTriggers:zod.z.boolean().nullish()}).passthrough(),Qu=zod.z.object({Grant:q.nullish(),UnlockFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),Ku=zod.z.object({TileType:zod.z.string().nullish(),TileIndex:zod.z.number().nullish(),ChanceOutcomeID:zod.z.string().nullish(),RandomActionType:zod.z.enum(["Raid","Attack"]).nullish()}).passthrough(),Hu=zod.z.object({Module:zod.z.enum(["GameLoop"]).nullish(),Board:Ku.nullish(),MaxUses:zod.z.number().nullish()}).passthrough(),$u=zod.z.object({Skippable:zod.z.boolean().nullish(),TimeoutSeconds:zod.z.number().nullish()}).passthrough(),es=zod.z.object({StepID:zod.z.string().nullish(),Order:zod.z.number().nullish(),Identity:_u.nullish(),Completion:Wu.nullish(),Effects:Qu.nullish(),Script:Hu.nullish(),Policy:$u.nullish()}).passthrough(),Zu=zod.z.object({DisplayName:zod.z.string().nullish(),DisplayNameKey:zod.z.string().nullish(),Description:zod.z.string().nullish(),DescriptionKey:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),zn=zod.z.object({Schedule:ce.nullish(),Gate:Q.nullish(),RequiredFlowIDs:zod.z.array(zod.z.string()).nullish(),AutoStart:zod.z.boolean().nullish(),StartTrigger:Ue.nullish()}).passthrough(),Tn=zod.z.object({Skippable:zod.z.boolean().nullish(),SkippableFromOrder:zod.z.number().nullish(),RestartPolicy:Gu.nullish(),ExpireAfterSeconds:zod.z.number().nullish(),IsBlocking:zod.z.boolean().nullish(),UnlockFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),vn=zod.z.object({Grant:q.nullish(),AutoClaim:zod.z.boolean().nullish()}).passthrough(),Ju=zod.z.object({Availability:te.nullish(),Policy:te.nullish(),Reward:te.nullish(),Steps:te.nullish()}).passthrough(),Yu=zod.z.object({FlowID:zod.z.string().nullish(),Identity:Zu.nullish(),Availability:zn.nullish(),Policy:Tn.nullish(),Steps:zod.z.record(zod.z.string(),es).nullish(),Reward:vn.nullish(),Presets:Ju.nullish()}).passthrough(),Xu=zod.z.object({BlockingFlowIDs:zod.z.array(zod.z.string()).nullish(),BlockedModules:zod.z.array(zod.z.string()).nullish(),BlockedActions:zod.z.record(zod.z.string(),zod.z.array(zod.z.string())).nullish(),BlockBeforeStart:zod.z.boolean().nullish(),SkipLiftsBlock:zod.z.boolean().nullish()}).passthrough(),ec=zod.z.object({IsEnabled:zod.z.boolean().nullish(),MaxActiveFlows:zod.z.number().nullish(),Blocking:Xu.nullish()}).passthrough(),tc=zod.z.object({Availability:zod.z.record(zod.z.string(),zn).nullish(),Policy:zod.z.record(zod.z.string(),Tn).nullish(),Reward:zod.z.record(zod.z.string(),vn).nullish(),Steps:zod.z.record(zod.z.string(),zod.z.record(zod.z.string(),es)).nullish()}).passthrough(),Pn=zod.z.object({Flows:zod.z.record(zod.z.string(),Yu).nullish(),Settings:ec.nullish(),Presets:tc.nullish()}).passthrough(),ic=zod.z.object({}).passthrough().transform(o=>o),In=zod.z.object({FlowID:zod.z.string(),Status:ju,CurrentStepID:zod.z.string().nullish(),CurrentStep:es.nullish(),TotalSteps:zod.z.number(),CompletedSteps:zod.z.number(),CanSkip:zod.z.boolean(),RewardClaimed:zod.z.boolean(),RewardPending:zod.z.boolean(),VariantID:zod.z.string().nullish()}).passthrough(),kn=zod.z.object({State:ic.nullish(),Flows:zod.z.array(In).nullish(),UnlockedFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),nt=zod.z.object({Flow:In.nullish()}).passthrough(),Mn=zod.z.object({FlowID:zod.z.string().nullish(),Granted:b.nullish()}).passthrough(),wn=zod.z.array(se(nt)),An=zod.z.object({FlowID:zod.z.string(),StepID:zod.z.string(),Progress:zod.z.number(),Target:zod.z.number(),Completed:zod.z.boolean()}).passthrough(),Oe={GetTutorialDefinitions:"GetTutorialDefinitions",GetUserTutorialState:"GetUserTutorialState",StartFlow:"StartFlow",ReportStepShown:"ReportStepShown",CompleteStep:"CompleteStep",CompleteStepsBatch:"CompleteStepsBatch",SkipStep:"SkipStep",SkipFlow:"SkipFlow",ClaimFlowReward:"ClaimFlowReward",ResetFlow:"ResetFlow"};var Wt=class{constructor(e=600,t=()=>Date.now()){this.windowMs=e;this.now=t;}windowMs;now;last=new Map;tryAcquire(e){if(this.windowMs<=0)return true;let t=this.now(),i=this.last.get(e);return i!==void 0&&t-i<this.windowMs?false:(this.last.set(e,t),true)}reset(){this.last.clear();}};var Qt=class{set=new Set;add(e){return this.set.has(e)?false:(this.set.add(e),true)}remove(e){this.set.delete(e);}};function Un(o){return o===429||o>=500&&o<=599}function ts(o,e=Math.random){let t=Math.min(500*Math.pow(2,o-1),4e3),i=t*.2*(e()*2-1);return Math.max(50,t+i)}function is(o){return new Promise(e=>setTimeout(e,o))}var rc=12e3,sc=zod.z.object({Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:zod.z.unknown().optional(),QuestProgress:zod.z.array(Zr).nullish(),TutorialProgress:zod.z.array(An).nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish(),StateEpoch:zod.z.string().nullish()}).passthrough(),Kt=class{baseUrl;emitter;fetchImpl;debugLogging;throttler;inflight=new Qt;inFlightRequests=0;sessionRefreshHandler=null;constructor(e){this.baseUrl=e.baseUrl,this.emitter=e.emitter,this.fetchImpl=e.fetchImpl??globalThis.fetch.bind(globalThis),this.debugLogging=e.debugLogging??false,this.throttler=new Wt(e.throttleMs);}setSessionRefreshHandler(e){this.sessionRefreshHandler=e;}async post(e,t,i,r={}){let s=r.throttleKey??e;if(!this.throttler.tryAcquire(s))return n("throttled","Throttled");if(!this.inflight.add(s))return n("throttled","Duplicate request skipped");this.raiseBusy();try{let a=`${this.baseUrl}/${e}`,p=JSON.stringify(t),D=r.ticket??null,B=r.silent??!1,E=r.timeoutMs??rc,pe=r.autoRetry??!0,fe=!1,ve=0;for(;;){let _e;try{_e=await this.doFetch(a,p,D,E);}catch{if(pe&&ve<3){ve++,await is(ts(ve));continue}return this.connectionFailure("Internet Connection Error",B)}let We=_e.status;if(We>=200&&We<300)return await this.parseSuccess(_e,i,B,e);if(We===401){if(!fe&&this.sessionRefreshHandler){fe=!0;let Ze=null;try{Ze=await this.sessionRefreshHandler();}catch{Ze=null;}if(Ze){D=Ze;continue}}return this.emitter.emit("auth:unauthorized",void 0),n("unauthorized","Unauthorized")}if(Un(We)){if(pe&&ve<3){ve++,await is(ts(ve));continue}return this.connectionFailure(`Server temporarily unavailable (HTTP ${We})`,B)}return await this.handleWebError(_e,We,B)}}finally{this.inflight.remove(s),this.lowerBusy();}}async doFetch(e,t,i,r){let s=new AbortController,a=setTimeout(()=>{s.abort();},r);try{let p={"Content-Type":"application/json"};return i&&(p.Authorization=`Bearer ${i}`),await this.fetchImpl(e,{method:"POST",body:t,headers:p,signal:s.signal})}finally{clearTimeout(a);}}async parseSuccess(e,t,i,r){let s;try{s=await e.text();}catch{return this.globalError("Failed to read response body",i)}let a;try{a=JSON.parse(s);}catch{return this.globalError("JSON Parse Error",i)}let p=sc.safeParse(a);if(!p.success)return this.globalError("Malformed response envelope",i);if(!p.data.Success){let fe=p.data.Error??"Server returned Success=false";return i||this.emitter.emit("error:global",fe),n("server",fe)}let D=p.data.QuestProgress;D&&D.length>0&&this.emitter.emit("quest:systemProgress",D);let B=p.data.TutorialProgress;B&&B.length>0&&this.emitter.emit("tutorial:systemProgress",B);let E=p.data.StateVersions;E&&Object.keys(E).length>0&&this.emitter.emit("user:stateVersions",{epoch:p.data.StateEpoch??null,versions:E});let pe=t.safeParse(p.data.Data);if(!pe.success){let fe=`Validation error (${r}): ${pe.error.message}`;return this.debugLogging&&console.warn("[HttpTransport]",fe),i||this.emitter.emit("error:global",fe),n("validation",fe)}return dn(pe.data)}async handleWebError(e,t,i){let r=`HTTP ${t}`;try{let s=await e.text();if(s)try{let p=JSON.parse(s).Error;r=typeof p=="string"&&p.length>0?`HTTP ${t}: ${p}`:`HTTP ${t}: ${s}`;}catch{r=`HTTP ${t}: ${s}`;}}catch{}return i||this.emitter.emit("error:global",r),n("server",r)}connectionFailure(e,t){return t||this.emitter.emit("error:connection",e),n("connection",e)}globalError(e,t){return t||this.emitter.emit("error:global",e),n("server",e)}raiseBusy(){this.inFlightRequests++,this.inFlightRequests===1&&this.emitter.emit("transport:busy",true);}lowerBusy(){this.inFlightRequests>0&&(this.inFlightRequests--,this.inFlightRequests===0&&this.emitter.emit("transport:busy",false));}};function Dt(o){return (typeof o=="string"?o:o.toISOString()).slice(0,10)}function Ut(o){return `${Dt(o)}T00:00:00.000Z`}function Bn(o){let e=new Date(o);return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+1)).toISOString()}function Ln(o,e){return new Date(o.getTime()+e*6e4).toISOString()}function qn(o,e,t,i){let r={vcChanged:false,ccChanged:false,itemsChanged:false,tokensChanged:false};if(!e)return r;o.InventoryV2??={};let s=o.InventoryV2,a=i.toISOString(),p=new Map,D=new Map,B=new Map,E=new Map,pe=new Map,fe=new Map,ve=new Map,_e=new Map,We=e.Grant?.PremiumTiers??[],Ze=We.length;for(let ne=0;;ne++){let de,$;if(ne===0)de=e.Grant?.Standard?.Entries,$=false;else if(ne-1<Ze)de=We[ne-1]?.Resources?.Entries,$=false;else if(ne===1+Ze)de=e.Consume?.Standard?.Entries,$=true;else break;if(de)for(let V of de){if(V.Type==null)continue;let K=Math.max(0,V.Amount??0);if(!(K<=0))switch(V.Type){case "VirtualCurrency":{if(!V.CurrencyID)continue;let H=$?D:p;H.set(V.CurrencyID,(H.get(V.CurrencyID)??0)+K);break}case "CryptoCurrency":{if(!V.CurrencyID)continue;let H=$?E:B;H.set(V.CurrencyID,(H.get(V.CurrencyID)??new Ht__default.default(0)).plus(K));break}case "Item":{if(!V.ItemID)continue;let H=oc(t,V.CatalogID,V.ItemID),ie=(H?H.IsStackable??true:true)?$?fe:pe:$?_e:ve;ie.set(V.ItemID,(ie.get(V.ItemID)??0)+K);break}case "UsdCent":continue}}}if(r.vcChanged=p.size>0||D.size>0,r.vcChanged){s.VirtualCurrencies??={};for(let ne of new Set([...p.keys(),...D.keys()])){let de=p.get(ne)??0,$=D.get(ne)??0,V=de-$,K=s.VirtualCurrencies[ne];K?(K.Amount+=V,K.UpdatedAt=a,K.Daily&&Dt(K.Daily.PeriodStartUtc)===Dt(i)?(K.Daily.Earned+=de,K.Daily.Spent+=$):K.Daily={PeriodStartUtc:Ut(i),Earned:de,Spent:$}):s.VirtualCurrencies[ne]={Amount:V,CreatedAt:a,UpdatedAt:a,Daily:{PeriodStartUtc:Ut(i),Earned:de,Spent:$}};}}if(r.ccChanged=B.size>0||E.size>0,r.ccChanged){s.CryptoCurrencies??={};for(let ne of new Set([...B.keys(),...E.keys()])){let de=B.get(ne)??new Ht__default.default(0),$=E.get(ne)??new Ht__default.default(0),V=de.minus($),K=s.CryptoCurrencies[ne];K?(K.Amount=new Ht__default.default(K.Amount).plus(V).toString(),K.UpdatedAt=a):s.CryptoCurrencies[ne]={Amount:V.toString(),Frozen:"0",CreatedAt:a,UpdatedAt:a};}}if(r.itemsChanged=pe.size>0||fe.size>0||ve.size>0||_e.size>0,r.itemsChanged){s.Items??={},s.UnstackableItems??={};let ne=s.UnstackableItems,de=new Set([...pe.keys(),...fe.keys(),...ve.keys(),..._e.keys()]);for(let $ of de){let V=(pe.get($)??0)-(fe.get($)??0),K=(ve.get($)??0)-(_e.get($)??0),H=V+K,Ae=s.Items[$];Ae?(V!==0&&(Ae.StackableAmount+=V),K!==0&&(Ae.UnstackableAmount+=K),H!==0&&(Ae.TotalAmount+=H)):s.Items[$]={StackableAmount:Math.max(0,V),UnstackableAmount:Math.max(0,K),TotalAmount:Math.max(0,H)};}for(let[$,V]of _e){if(V<=0)continue;let K=Object.values(ne).filter(H=>H.ItemID===$&&H.EquippedSlot==null&&(H.ExpiresAt==null||new Date(H.ExpiresAt)>i)).sort(nc).slice(0,V).map(H=>H.ItemInstanceID);for(let H of K)delete ne[H];}for(let[$,V]of ve){let K=ac(t,$);for(let H=0;H<V;H++){let Ae=P();ne[Ae]={ItemInstanceID:Ae,ItemID:$,CatalogID:K,RemainingUses:1,AcquiredAt:a};}}}o.EventToken??={};let Yl=o.EventToken;for(let ne=0;;ne++){let de,$;if(ne===0)de=e.Grant?.Standard?.EventTokens,$=false;else if(ne-1<Ze)de=We[ne-1]?.Resources?.EventTokens,$=false;else if(ne===1+Ze)de=e.Consume?.Standard?.EventTokens,$=true;else break;if(!(!de||de.length===0))for(let V of de){let K=V.Address;if(!K||K.Type==null)continue;let H=V.Amount??0;if(H<=0)continue;let Ae=lc(Yl,K.Type);if(!Ae)continue;let ie=Ae[K.EntityID];ie||(ie={},Ae[K.EntityID]=ie),ie.Balance??={Current:0,TotalEarned:0,TotalSpent:0},ie.Daily??={Date:Ut(i),TotalEarned:0},ie.Meta??={};let Mt=V.Source&&V.Source.length>0?V.Source:"CustomAction";$?(ie.Balance.Current-=H,ie.Balance.TotalSpent+=H):(ie.Balance.Current+=H,ie.Balance.TotalEarned+=H,Dt(ie.Daily.Date)!==Dt(i)&&(ie.Daily={Date:Ut(i),TotalEarned:0}),ie.Daily.TotalEarned+=H,ie.Daily.EarnedBySource??={},ie.Daily.EarnedBySource[Mt]=(ie.Daily.EarnedBySource[Mt]??0)+H,ie.Daily.TriggersBySource??={},ie.Daily.TriggersBySource[Mt]=(ie.Daily.TriggersBySource[Mt]??0)+1,ie.Daily.LastTriggerBySource??={},ie.Daily.LastTriggerBySource[Mt]=a,ie.Meta.JoinedAtUtc||(ie.Meta.JoinedAtUtc=a),ie.Meta.LastEarnedAtUtc=a),r.tokensChanged=true;}}return r}function nc(o,e){return o.AcquiredAt!==e.AcquiredAt?o.AcquiredAt<e.AcquiredAt?-1:1:o.ItemInstanceID===e.ItemInstanceID?0:o.ItemInstanceID<e.ItemInstanceID?-1:1}function oc(o,e,t){let i=o?.Catalogs;if(i){if(e){let r=i[e]?.Items?.[t];if(r)return r}for(let r of Object.values(i)){let s=r.Items?.[t];if(s)return s}}}function ac(o,e){let t=o?.Catalogs;if(t){for(let[i,r]of Object.entries(t))if(r.Items&&e in r.Items)return i}}function lc(o,e){switch(e){case "TimedEvent":return o.TimedEvent??={};case "Quest":return o.Quest??={};case "Leaderboard":return o.Leaderboard??={};case "CoopEvent":return o.CoopEvent??={};case "Season":return o.Season??={};default:return null}}function rs(o,e){return o===e||o.startsWith(`${e}:`)}var $t=class{constructor(e){this.emitter=e;}emitter;currentState={};activeEventsCache=null;get state(){return this.currentState}getCachedActiveEvents(){return this.activeEventsCache}clear(){this.currentState=null,this.emitter.emit("user:anyUpdated",void 0);}applyUserState(e){this.currentState=e,this.emitter.emit("user:stateUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyUserStateContainers(e,t){if(t.length!==0){this.currentState??={};for(let i of t)this.currentState[i]=e[i];this.emitter.emit("user:stateUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}}applyInventory(e){this.currentState??={},this.currentState.InventoryV2=e,this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyVirtualCurrency(e){this.currentState??={},this.currentState.InventoryV2??={},this.currentState.InventoryV2.VirtualCurrencies=e,this.emitter.emit("user:virtualCurrencyUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyResourceOperation(e,t,i=new Date){if(!this.currentState)return;let r=qn(this.currentState,e,t,i);r.vcChanged&&this.emitter.emit("user:virtualCurrencyUpdated",void 0),(r.vcChanged||r.ccChanged||r.itemsChanged)&&this.emitter.emit("user:inventoryUpdated",void 0),r.tokensChanged&&this.emitter.emit("user:eventTokenUpdated",void 0),(r.vcChanged||r.ccChanged||r.itemsChanged||r.tokensChanged)&&this.emitter.emit("user:anyUpdated",void 0);}patchCryptoCurrencyDelta(e,t,i){if(!e||!this.currentState)return;this.currentState.InventoryV2??={},this.currentState.InventoryV2.CryptoCurrencies??={};let r=this.currentState.InventoryV2.CryptoCurrencies,s=t instanceof Ht__default.default?t:new Ht__default.default(t),a=i??new Date().toISOString(),p=r[e];p?(p.Amount=new Ht__default.default(p.Amount).plus(s).toString(),p.UpdatedAt=a):r[e]={Amount:s.toString(),Frozen:"0",CreatedAt:a,UpdatedAt:a},this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyStore(e){this.currentState??={},this.currentState.Store=e??{},this.emitter.emit("user:storeUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchStorePurchase(e,t,i){if(!e||t<1||!this.currentState)return;this.currentState.Store??={},this.currentState.Store.Purchases??={};let r=this.currentState.Store.Purchases,s=r[e];s||(s={OfferID:e,TotalPurchases:0,DailyPurchases:0,DailyResetUtc:"",LastPurchasedAt:""},r[e]=s),s.TotalPurchases+=t,s.LastPurchasedAt=i,i>=s.DailyResetUtc?(s.DailyPurchases=t,s.DailyResetUtc=Bn(i)):s.DailyPurchases+=t,this.emitter.emit("user:storeUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyLootboxPityTriggers(e,t,i){if(!e||i<=0)return;this.currentState??={};let r=this.currentState.Lootbox??={};if(r.Pity??={},t){let s=new Date().toISOString();for(let a of t)a.RuleID&&(r.Pity[`${e}:${a.RuleID}`]={OpensSinceLastTrigger:0,LastTriggeredAtUtc:s});}this.emitter.emit("user:lootboxUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyReward(e){this.currentState??={},this.currentState.Reward=e??{},this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchDailyCalendarState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.DailyCalendars??={},this.currentState.Reward.DailyCalendars[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchIdleAccrualState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.IdleAccruals??={},this.currentState.Reward.IdleAccruals[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchComebackState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.Comebacks??={},this.currentState.Reward.Comebacks[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchClaimRewardState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.Claims??={},this.currentState.Reward.Claims[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyQuest(e){this.currentState??={},this.currentState.Quest=e??{},this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchQuestStatus(e,t,i){if(!e)return;this.currentState??={},this.currentState.Quest??={};let r=this.currentState.Quest;if(t){r.Cycles??={};let s=r.Cycles[t];if(!s)return;s.Quests??={};let a=s.Quests[e]??={QuestID:e,Status:i};a.Status=i,i==="Claimed"&&(a.ClaimedAtUtc??=new Date().toISOString());}else {r.PermanentQuests??={};let s=r.PermanentQuests[e]??={QuestID:e,Status:i};s.Status=i,i==="Claimed"&&(s.ClaimedAtUtc??=new Date().toISOString());}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchMilestoneClaimed(e,t){if(!e||!t)return;let i=this.getQuestPointsProgress(e);i&&(i.Milestone??={},i.Milestone.ClaimedIDs??=[],i.Milestone.ClaimedIDs.includes(t)||i.Milestone.ClaimedIDs.push(t),this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchQuestPointsTracks(e){if(!e)return;this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.Quest??={};let t=this.currentState.EventToken.Quest;for(let i of Object.values(e)){if(!i.CycleID)continue;let r=i.InstanceKey?`${i.CycleID}:${i.InstanceKey}`:i.CycleID,s=t[r]??={};s.Balance??={Current:0,TotalEarned:0,TotalSpent:0},s.Balance.Current=i.PointsCurrent??0,s.Balance.TotalEarned=i.PointsTotalEarned??0,s.Milestone??={},s.Milestone.ClaimedIDs=i.ClaimedPointMilestoneIDs??[];}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchGroupCompletionClaimed(e,t){if(!e||!t)return;this.currentState??={},this.currentState.Quest??={},this.currentState.Quest.Cycles??={};let i=this.currentState.Quest.Cycles[e];i&&(i.ClaimedGroupCompletionIDs??=[],i.ClaimedGroupCompletionIDs.includes(t)||i.ClaimedGroupCompletionIDs.push(t),this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyTutorial(e){this.currentState??={},this.currentState.Tutorial=e??{},this.emitter.emit("user:tutorialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchTutorialFlow(e){if(!e?.FlowID)return;this.currentState??={},this.currentState.Tutorial??={};let t=this.currentState.Tutorial;t.Flows??={};let i=t.Flows[e.FlowID]??={FlowID:e.FlowID};i.Status=e.Status,i.CurrentStepID=e.CurrentStepID??null,i.RewardClaimed=e.RewardClaimed,e.VariantID!==void 0&&(i.VariantID=e.VariantID),this.emitter.emit("user:tutorialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchTutorialProgress(e){if(!e||e.length===0)return;this.currentState??={},this.currentState.Tutorial??={};let t=this.currentState.Tutorial;t.Flows??={};for(let i of e){if(!i.FlowID||!i.StepID)continue;let r=t.Flows[i.FlowID]??={FlowID:i.FlowID,Status:"InProgress"};r.Steps??={};let s=r.Steps[i.StepID]??={StepID:i.StepID};s.Progress=i.Progress,i.Completed&&(s.CompletedAtUtc??=new Date().toISOString(),r.CurrentStepID===i.StepID&&(r.CurrentStepID=null));}this.emitter.emit("user:tutorialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchQuestProgressUpdates(e){if(!e||e.length===0)return;this.currentState??={},this.currentState.Quest??={};let t=this.currentState.Quest;for(let i of e){if(!i.QuestID)continue;let r;if(!i.CycleID)t.PermanentQuests??={},r=t.PermanentQuests[i.QuestID]??={QuestID:i.QuestID,Status:i.Status};else {t.Cycles??={};let s=t.Cycles[i.CycleID];if(!s)continue;s.Quests??={},r=s.Quests[i.QuestID]??={QuestID:i.QuestID,Status:i.Status};}if(r.Status=i.Status,i.ObjectiveID){r.Objectives??={};let s=r.Objectives[i.ObjectiveID]??={ObjectiveID:i.ObjectiveID,CurrentValue:0,Completed:false};s.CurrentValue=i.NewValue??0,i.ObjectiveCompleted&&(s.Completed=true,s.CompletedAtUtc??=new Date().toISOString());}i.Status==="Completed"&&(r.CompletedAtUtc??=new Date().toISOString());}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}getQuestPointsProgress(e){if(!e)return null;let t=this.currentState?.EventToken?.Quest;if(!t)return null;for(let[i,r]of Object.entries(t))if(rs(i,e)&&r)return r;return null}applyActiveEvents(e){this.activeEventsCache=e??{},this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyUserLteState(e){e&&(this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.TimedEvent=e.Tokens??{},this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchTimedEventMilestoneClaimed(e,t,i){if(!(!t||!i)){this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.TimedEvent??={};for(let[r,s]of Object.entries(this.currentState.EventToken.TimedEvent))!rs(r,t)||!s||this.markMilestoneClaimed(s.Milestone??(s.Milestone={}),i);this.patchActiveEventMilestoneClaimed(e,t,i),this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}}patchActiveEventMilestoneClaimed(e,t,i){let r=this.activeEventsCache?.ActiveEvents;if(r)for(let s of r)s.Type!==e||s.TimedEventID!==t||(s.Progress??={},this.markMilestoneClaimed(s.Progress.Milestone??(s.Progress.Milestone={}),i));}markMilestoneClaimed(e,t){if(e.ClaimedIDs??=[],e.ClaimedIDs.includes(t)||e.ClaimedIDs.push(t),e.UnlockedIDs){let i=e.UnlockedIDs.indexOf(t);i>=0&&e.UnlockedIDs.splice(i,1);}}patchLeaderboardMyProgress(e,t){if(!e||!t)return;let i=this.ensureLeaderboardProgress(e);i.CurrentScore=t.CurrentScore??0,i.LastKnownRank=t.LastKnownRank??0,i.ScoreEarnedThisCycle=t.ScoreEarnedThisCycle??0,i.UnclaimedRewardCycleVersion=t.HasUnclaimedReward?Math.max(1,i.UnclaimedRewardCycleVersion??0):0,this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchLeaderboardScoreSubmitted(e,t,i,r){if(!e)return;let s=this.ensureLeaderboardProgress(e);(s.ScoreCycleVersion??0)<r&&(s.ScoreEarnedThisCycle=0,s.ClaimedMilestoneIDs=[],s.BracketID=null),s.CurrentScore=t,s.ScoreEarnedThisCycle=(s.ScoreEarnedThisCycle??0)+i,s.ScoreCycleVersion=r,s.LastScoreSubmitUtc=new Date().toISOString(),this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchLeaderboardCycleRewardClaimed(e){if(!e)return;let t=this.currentState?.Leaderboard?.ProgressByCycle?.[e];t&&(t.UnclaimedRewardCycleVersion=0,this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchLeaderboardMilestoneClaimed(e,t){if(!e||!t)return;let i=this.ensureLeaderboardProgress(e);i.ClaimedMilestoneIDs??=[],i.ClaimedMilestoneIDs.includes(t)||i.ClaimedMilestoneIDs.push(t),this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureLeaderboardProgress(e){this.currentState??={},this.currentState.Leaderboard??={},this.currentState.Leaderboard.ProgressByCycle??={};let t=this.currentState.Leaderboard.ProgressByCycle,i=t[e];return i||(i={CurrentScore:0,ScoreEarnedThisCycle:0,ScoreCycleVersion:0,UnclaimedRewardCycleVersion:0,LastKnownRank:0},t[e]=i),i}applySeasonsState(e){this.currentState??={},this.currentState.Season=e??{},this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSeasonState(e,t){!e||!t||(this.currentState??={},this.currentState.Season??={},this.currentState.Season.States??={},this.currentState.Season.States[e]=t,this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchSeasonCurrentTier(e,t){if(!e)return;let i=this.ensureSeasonState(e);i.CurrentTier=t,this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSeasonClaimedTier(e,t){if(!e)return;let i=this.ensureSeasonState(e);i.ClaimedTierRewards??=[],i.ClaimedTierRewards.includes(t)||i.ClaimedTierRewards.push(t),this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureSeasonState(e){this.currentState??={},this.currentState.Season??={},this.currentState.Season.States??={};let t=this.currentState.Season.States,i=t[e];return i||(i={SeasonChainID:e},t[e]=i),i}applyPremium(e){this.currentState??={},this.currentState.Premium=e??{},this.emitter.emit("user:premiumUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCharacter(e){this.currentState??={},this.currentState.Character??={},this.currentState.Character.Characters=e??{},this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCharacter(e,t){if(!e)return;this.currentState??={},this.currentState.Character??={},this.currentState.Character.Characters??={};let i=this.currentState.Character.Characters,r=i[e];r||(r={CharacterID:e},i[e]=r),t(r),this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCharacterEquipment(e,t,i){if(!e||!t)return;let r=this.currentState?.Character?.Characters?.[e];r&&(r.Equipment??={},i===null?delete r.Equipment[t]:r.Equipment[t]=i,this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyInventoryDelta(e){if(!e)return;this.currentState??={},this.currentState.InventoryV2??={},this.currentState.InventoryV2.UnstackableItems??={};let t=this.currentState.InventoryV2.UnstackableItems,i=false;for(let[r,s]of Object.entries(e.ChangedInstances??{}))t[r]=s,i=true;for(let r of e.RemovedInstanceIDs??[])r in t&&(delete t[r],i=true);i&&(this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyMatch(e){this.currentState??={},this.currentState.Match=e??{},this.emitter.emit("user:matchUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchMatchStrategy(e){e&&(this.currentState??={},this.currentState.Match??={},this.currentState.Match.PvPBattleStrategy=e,this.emitter.emit("user:matchUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyCollection(e){this.currentState??={},this.currentState.Collection=e??{},this.emitter.emit("user:collectionUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCoopEvent(e){this.currentState??={},this.currentState.CoopEvent=e??{MyObjectIndex:-1},this.emitter.emit("user:coopEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCoopEventActiveGroup(e,t,i){this.currentState??={};let r=this.currentState.CoopEvent??={MyObjectIndex:-1};r.ActiveGroupID=e,r.ActiveCoopEventID=t,r.MyObjectIndex=i,this.emitter.emit("user:coopEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyDealOffer(e){this.currentState??={},this.currentState.DealOffer=e??{},this.emitter.emit("user:dealOfferUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyReferral(e){this.currentState??={},this.currentState.Referral=e??{},this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchReferralSubscription(e){e&&(this.currentState??={},this.currentState.Referral??={},this.currentState.Referral.SubscribedToUserID=e,this.currentState.Referral.UpdatedAt=new Date().toISOString(),this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchReferralInviteRewardClaimed(e){e&&(this.currentState??={},this.currentState.Referral??={},this.currentState.Referral.InviteRewardStates??={},this.currentState.Referral.InviteRewardStates[e]={RewardID:e,IsClaimed:true,ClaimedAt:new Date().toISOString()},this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applySocialFriendsList(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.Accepted=(e??[]).map(t=>t.UserID),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applySocialIncomingRequests(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.IncomingRequests=(e??[]).map(t=>t.UserID),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applySocialTimeline(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.Timeline=e??[],this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialAddOutgoingRequest(e){if(!e)return;let t=this.ensureSocial();t.OutgoingRequests??=[],t.OutgoingRequests.includes(e)||t.OutgoingRequests.push(e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialAcceptFriend(e){if(!e)return;let t=this.ensureSocial();t.IncomingRequests=(t.IncomingRequests??[]).filter(i=>i!==e),t.Accepted??=[],t.Accepted.includes(e)||t.Accepted.push(e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialRemoveIncomingRequest(e){if(!e)return;let t=this.ensureSocial();t.IncomingRequests=(t.IncomingRequests??[]).filter(i=>i!==e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialRemoveFriend(e){if(!e)return;let t=this.ensureSocial();t.Accepted=(t.Accepted??[]).filter(i=>i!==e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureSocial(){return this.currentState??={},this.currentState.Social??={},this.currentState.Social}applyTimedBoost(e){this.currentState??={},this.currentState.TimedBoost=e??{},this.emitter.emit("user:timedBoostUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchActiveTimedBoost(e,t){this.currentState??={},this.currentState.TimedBoost??={},this.currentState.TimedBoost.Active??={};let i=this.currentState.TimedBoost.Active;if(t==="Replace"||t==="KeepBest")for(let r of Object.keys(i)){let s=i[r];s&&s.BoostID===e.BoostID&&r!==e.InstanceID&&delete i[r];}i[e.InstanceID]=e,this.emitter.emit("user:timedBoostUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyUserCustomData(e){this.currentState??={},this.currentState.CustomData??={};let t=this.currentState.CustomData;t.Version=e.Version??0,t.Private=e.Private??{},t.Public=e.Public??{},t.ReadOnly=e.ReadOnly??{},this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchUserCustomDataKey(e,t,i,r,s){if(!t)return;this.currentState??={},this.currentState.CustomData??={};let a=this.currentState.CustomData,p={Value:i,UpdatedAt:new Date().toISOString(),Version:r,LastWriter:"Client",ExpiresAt:s??null};if(e==="Private")a.Private??={},a.Private[t]=p;else if(e==="Public")a.Public??={},a.Public[t]=p;else return;a.Version=(a.Version??0)+1,this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}removeUserCustomDataKey(e,t){if(!t||!this.currentState?.CustomData)return;let i=this.currentState.CustomData;if(e==="Private")i.Private&&delete i.Private[t];else if(e==="Public")i.Public&&delete i.Public[t];else return;this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyBoardState(e){this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.Board=e??{},this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCommunityChestUserState(e){this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.CommunityChest=e??{},this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardState(e){let t=this.ensureBoard();e(t),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardBuilding(e,t){if(e<0)return;let i=this.ensureBoard();i.BuildingStates??=[];let r=i.BuildingStates.find(s=>s.SlotIndex===e);r||(r={SlotIndex:e},i.BuildingStates.push(r)),t(r),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardPendingRaidLayout(e,t){let r=this.ensureBoard().Pending;r&&(e&&(r.RaidLayout=e),t>=0&&(r.OpenedIndices??=[],r.OpenedIndices.includes(t)||r.OpenedIndices.push(t)),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchBoardSpecialPending(e){let i=this.ensureBoard().Pending;!i||i.Type.toUpperCase()!=="SPECIAL"||(i.Special??={},e(i.Special),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}clearBoardPending(){let e=this.currentState?.GameLoop?.Board;!e||!e.Pending||(e.Pending=null,this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}ensureBoard(){return this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.Board??={},this.currentState.GameLoop.Board}applyBlockchainState(e,t){this.currentState??={},this.currentState.Blockchain=e??{},t&&(this.currentState.InventoryV2??={},this.currentState.InventoryV2.CryptoCurrencies=t),this.emitter.emit("user:blockchainUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyMarketplaceState(e){this.currentState??={},this.currentState.Marketplace=e??{},this.emitter.emit("user:marketplaceUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}getVirtualCurrencyAmount(e){return this.currentState?.InventoryV2?.VirtualCurrencies?.[e]?.Amount??0}getCryptoCurrencyAmount(e){return this.currentState?.InventoryV2?.CryptoCurrencies?.[e]?.Amount??"0"}};var Zt=class{config=null;sections=new Map;itemDefs;currencyDefs;get titlePublicConfiguration(){return this.config}patchSection(e,t){this.sections.set(e,t);}getSection(e){return this.sections.get(e)}applyTitlePublicConfiguration(e){this.config=e&&typeof e=="object"?e:null;}get itemDefinitions(){return this.itemDefs??this.config?.Item??void 0}applyItemDefinitions(e){this.itemDefs=e;}get currencyDefinitions(){return this.currencyDefs??this.config?.Currency??void 0}applyCurrencyDefinitions(e){this.currencyDefs=e;}};var Jt=class{user;config;constructor(e){this.user=new $t(e),this.config=new Zt;}reset(){this.user.clear(),this.config.applyTitlePublicConfiguration(null);}};var Yt=class{constructor(e,t){this.storage=e;this.authTypeKey=`Saved_AuthType_${t}`,this.emailKey=`Saved_Auth_Email_${t}`,this.passwordKey=`Saved_Auth_Password_${t}`;}storage;authTypeKey;emailKey;passwordKey;get lastAuthType(){let e=this.storage.getString(this.authTypeKey);return uc(e)?e:he.None}saveAuthType(e){this.storage.setString(this.authTypeKey,e);}get savedEmail(){return this.storage.getString(this.emailKey)??""}get savedPassword(){return this.storage.getString(this.passwordKey)??""}saveEmailAndPassword(e,t){this.storage.setString(this.emailKey,e),this.storage.setString(this.passwordKey,t);}clear(){this.storage.remove(this.authTypeKey),this.storage.remove(this.emailKey),this.storage.remove(this.passwordKey);}};function uc(o){return o!==null&&Object.values(he).includes(o)}var cc=8,pc=100,dc=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i,En=["GameLoop"],Xt=class{constructor(e){this.ctx=e;}ctx;authContext=null;refreshing=false;rememberSession=true;sessionAuthType=he.None;sessionEmail="";sessionPassword="";get context(){return this.authContext}get isLoggedIn(){return this.authContext!==null&&this.authContext.userID.length>0&&this.authContext.clientSessionTicket.length>0}get lastAuthType(){return this.ctx.authStore.lastAuthType}setRememberSession(e){this.rememberSession=e;}get remembersSession(){return this.rememberSession}baseRequest(){return {BuildKey:this.ctx.settings.buildKey,WebAppLink:this.ctx.platform.getFullURL()}}async loginWithDeviceID(){this.ctx.emitter.emit("auth:requestSent",void 0);let e=this.baseRequest();e.DeviceID=this.ctx.platform.getDeviceID(),e.Device=this.ctx.platform.getDeviceModel(),e.Platform=this.ctx.platform.getPlatform();let t=await this.ctx.api.authentication.loginWithDeviceID(e);return t.ok?(this.applyAuthContext(t.data),this.fetchAndApplyClientState(he.Device)):t}async loginWithTelegram(){this.ctx.emitter.emit("auth:requestSent",void 0);let e=this.ctx.platform.getTelegramInitDataRaw();if(!e)return n("client","Telegram initData is not available.");let t=this.baseRequest();t.TelegramInitData=e;let i=await this.ctx.api.authentication.loginWithTelegram(t);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(he.Telegram)):i}async loginWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();i.Email=e,i.Password=t;let r=await this.ctx.api.authentication.loginWithEmail(i);if(!r.ok)return r;this.applyAuthContext(r.data);let s=await this.fetchAndApplyClientState(he.Email);return s.ok&&this.keepEmailCredentials(e,t),s}async registerWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();i.Email=e,i.Password=t,i.DeviceID=this.ctx.platform.getDeviceID(),i.Device=this.ctx.platform.getDeviceModel(),i.Platform=this.ctx.platform.getPlatform();let r=await this.ctx.api.authentication.registerWithEmail(i);if(!r.ok)return r;this.applyAuthContext(r.data);let s=await this.fetchAndApplyClientState(he.Email);return s.ok&&this.keepEmailCredentials(e,t),s}async loginWithGoogle(e){this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.GoogleIDToken=e;let i=await this.ctx.api.authentication.loginWithGoogle(t);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(he.Google)):i}async requestWalletChallenge(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();return i.WalletAddress=e,i.NetworkID=t,this.ctx.api.authentication.requestWalletChallenge(i)}async loginWithWallet(e,t,i){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();r.WalletAddress=e,r.NetworkID=t,r.WalletSignature=i,r.Platform=this.ctx.platform.getPlatform(),r.Device=this.ctx.platform.getDeviceModel(),r.DeviceID=this.ctx.platform.getDeviceID();let s=await this.ctx.api.authentication.loginWithWallet(r);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(he.Wallet)):s}async loginWithPlatformToken(e){if(!e)return n("client","AuthToken is null or empty.");this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.PlatformAuthToken=e,t.DeviceID=this.ctx.platform.getDeviceID(),t.Device=this.ctx.platform.getDeviceModel(),t.Platform=this.ctx.platform.getPlatform();let i=await this.ctx.api.authentication.loginWithPlatformToken(t);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(he.iDosGames)):i}async loginWithSsoCode(e){if(!e)return n("client","SSO code is null or empty.");this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.SsoCode=e,t.DeviceID=this.ctx.platform.getDeviceID(),t.Device=this.ctx.platform.getDeviceModel(),t.Platform=this.ctx.platform.getPlatform();let i=await this.ctx.api.authentication.loginWithSsoCode(t);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(he.iDosGames)):i}async forgotPassword(e){this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();return t.Email=e,this.ctx.api.authentication.forgotPassword(t)}async resetPassword(e,t,i){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();return r.Email=e,r.ResetToken=t,r.Password=i,this.ctx.api.authentication.resetPassword(r)}autoLogin(){return this.replay(this.ctx.authStore.lastAuthType,this.ctx.authStore.savedEmail,this.ctx.authStore.savedPassword)}replay(e,t,i){switch(e){case he.Email:return this.loginWithEmail(t,i);case he.Device:case he.None:return this.loginWithDeviceID();case he.Telegram:return this.loginWithTelegram();default:return Promise.resolve(n("client",`Cannot auto-login: last session used "${e}", which requires a fresh token from the platform SDK. Obtain a new token and call the matching login method (e.g. loginWithGoogle) instead of autoLogin().`))}}async refreshSession(){if(this.refreshing)return null;let e=this.sessionAuthType!==he.None?this.sessionAuthType:this.ctx.authStore.lastAuthType;if(e===he.None)return null;this.refreshing=true;try{return (await this.replay(e,this.sessionEmail||this.ctx.authStore.savedEmail,this.sessionPassword||this.ctx.authStore.savedPassword)).ok&&this.authContext?this.authContext.clientSessionTicket:null}catch{return null}finally{this.refreshing=false;}}logout(){this.authContext=null,this.forgetSession(),this.ctx.authStore.clear(),this.ctx.data.reset(),this.ctx.emitter.emit("auth:loggedOut",void 0);}static isValidEmail(e){return e.length>0&&dc.test(e)}static isValidPasswordLength(e){return e.length>=cc&&e.length<=pc}keepEmailCredentials(e,t){this.sessionEmail=e,this.sessionPassword=t,this.rememberSession&&this.ctx.authStore.saveEmailAndPassword(e,t);}forgetSession(){this.sessionAuthType=he.None,this.sessionEmail="",this.sessionPassword="";}applyAuthContext(e){this.authContext={userID:e.TitleUserID,clientSessionTicket:e.TitleClientSessionTicket,clientSessionTicketExpiration:e.TitleClientSessionTicketExpiration,platformUserID:e.PlatformUserID??void 0,platformAuthToken:e.PlatformAuthToken??void 0,platformAuthTokenExpiration:e.PlatformAuthTokenExpiration??void 0};}async fetchAndApplyClientState(e){let t=await this.ctx.userService.getClientStateExcept(En,En);return t.ok&&(this.sessionAuthType=e,this.rememberSession?this.ctx.authStore.saveAuthType(e):this.ctx.authStore.clear(),this.ctx.emitter.emit("auth:loggedIn",void 0)),t}};var hc="idos:cfg",bt=class{constructor(e,t){this.storage=e;this.titleId=t;}storage;titleId;static scopeOf(e,t){return t&&t.length>0?`x:${Gn(t)}`:e&&e.length>0?`f:${Gn(e)}`:t?"x:":"f:"}async read(e){try{let t=await this.storage.get(this.keyOf(e));if(!t)return null;let i=JSON.parse(t);return !i||typeof i!="object"||typeof i.v!="string"||!i.c?null:i}catch{return null}}async write(e,t,i){try{let r={v:t,c:i};await this.storage.set(this.keyOf(e),JSON.stringify(r));}catch{}}async clear(e){try{await this.storage.remove(this.keyOf(e));}catch{}}keyOf(e){return `${hc}:${this.titleId}:${e}`}};function Gn(o){return [...o].map(e=>e.toLowerCase()).sort().join(",")}var Nn="idos:loc",zt=class{constructor(e,t){this.storage=e;this.titleId=t;}storage;titleId;async read(e){try{let t=await this.storage.get(this.keyOf(e));if(!t)return null;let i=JSON.parse(t);return !i||typeof i!="object"||typeof i.v!="number"||!i.t||typeof i.t!="object"?null:i}catch{return null}}async write(e,t,i){try{let r={v:t,t:i};await this.storage.set(this.keyOf(e),JSON.stringify(r)),await this.noteVersion(e,t);}catch{}}async readVersions(){try{let e=await this.storage.get(this.versionsKey());if(!e)return {};let t=JSON.parse(e);if(!t||typeof t!="object")return {};let i={};for(let[r,s]of Object.entries(t))typeof s=="number"&&s>0&&(i[r]=s);return i}catch{return {}}}async noteVersion(e,t){let i=await this.readVersions();i[e]!==t&&(i[e]=t,await this.storage.set(this.versionsKey(),JSON.stringify(i)));}keyOf(e){return `${Nn}:${this.titleId}:${e}`}versionsKey(){return `${Nn}:${this.titleId}:versions`}};var mc="idos:state",ei=class{constructor(e,t){this.storage=e;this.titleId=t;}storage;titleId;async read(e){if(!e)return null;try{let t=await this.storage.get(this.keyOf(e));if(!t)return null;let i=JSON.parse(t);return !i||typeof i!="object"||typeof i.e!="string"||!i.v||!i.s?null:i}catch{return null}}async write(e,t,i,r){if(!(!e||!t))try{let s={e:t,v:i,s:r};await this.storage.set(this.keyOf(e),JSON.stringify(s));}catch{}}keyOf(e){return `${mc}:${this.titleId}:${e}`}};function fc(o,e){if(!o)return;let t=new Set((e??[]).map(r=>r.trim().toLowerCase()));if(t.size===0)return o;let i={};for(let[r,s]of Object.entries(o))t.has(r.toLowerCase())||(i[r]=s);return i}function ns(o,e,t,i){let r={...o??{}};if(!e||!t||!i)return r;for(let[s,a]of Object.entries(t))i[s]===a&&s in e&&(r[s]=e[s]);return r}function gc(o){return {...o??{}}}function os(o){return typeof o.StateEpoch=="string"&&o.StateEpoch.length>0?o.StateEpoch:null}var ti=class{constructor(e){this.cache=e;}cache;loadedFor=null;epoch=null;versions={};state=null;dirty=false;async load(e){if(this.loadedFor===e)return;let t=await this.cache.read(e);this.loadedFor=e,this.epoch=t?.e??null,this.versions=t?{...t.v}:{},this.state=t?.s??null,this.dirty=false;}get cachedState(){return this.state}get currentEpoch(){return this.epoch}versionsFor(e){if(!this.epoch)return;let t=fc(this.versions,e);return t&&Object.keys(t).length>0?t:void 0}noteMutation(e,t){if(!e||e!==this.epoch){e&&e!==this.epoch&&this.reset(e);return}for(let[i,r]of Object.entries(t)){let s=this.versions[i];s!==void 0&&r===s+1?this.versions[i]=r:delete this.versions[i],this.dirty=true;}}afterFullRead(e,t){e!==this.epoch&&this.reset(e),this.versions=gc(t),this.dirty=true;}afterSliceRead(e,t){e!==this.epoch&&this.reset(e);for(let[i,r]of Object.entries(t??{}))this.versions[i]=r;this.dirty=true;}async flush(e,t){!this.dirty||!this.epoch||!e||(this.state=t??{},this.dirty=false,await this.cache.write(e,this.epoch,this.versions,this.state));}reset(e){this.epoch=e,this.versions={},this.state=null,this.dirty=true;}};var jn=n("server","Title configuration is unavailable (CDN and API both failed)."),ii=class{constructor(e){this.ctx=e;}ctx;baseRequest(){let e=this.ctx.auth.context;return e?{UserID:e.userID,ClientSessionTicket:e.clientSessionTicket,BuildKey:this.ctx.settings.buildKey,WebAppLink:this.ctx.platform.getFullURL(),RelatedEntityID:P()}:null}get configCache(){return this.cache??=new bt(this.ctx.settings.configStorage,this.ctx.settings.titleID)}cache;get localizationCache(){return this.locCache??=new zt(this.ctx.settings.configStorage,this.ctx.settings.titleID)}locCache;get stateStore(){return this.versionStore??=new ti(new ei(this.ctx.settings.configStorage,this.ctx.settings.titleID))}versionStore;noteStateVersions(e,t){this.ctx.auth.context?.userID&&this.stateStore.currentEpoch&&this.stateStore.noteMutation(e,t);}async getClientState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=bt.scopeOf(e.TitleFields,null),i=await this.configCache.read(t);i&&(e.KnownTitleConfigVersion=i.v),await this.prepareLocalization(e);let r=await this.prepareStateHandshake(e,null),s=await this.ctx.api.user.getClientState(e);if(!s.ok)return s;let a=await this.resolveTitleConfig(s.data,t,i,{Fields:e.TitleFields});return a==null?jn:(this.finishStateHandshake(s.data,r),await this.applyClientState(s.data,a,void 0,void 0),await this.applyLocalization(s.data.Localization),await this.flushState(r),s)}async prepareStateHandshake(e,t){let i=this.ctx.auth.context?.userID;if(!i)return {userId:null,cached:null,sent:void 0};await this.stateStore.load(i),await this.stateStore.flush(i,this.ctx.data.user.state);let r=this.stateStore.versionsFor(t);if(r){e.KnownStateVersions=r;let s=this.stateStore.currentEpoch;s&&(e.KnownStateEpoch=s);}return {userId:i,cached:this.stateStore.cachedState,sent:r}}finishStateHandshake(e,t){let i=ns(e.User,t.cached,t.sent,e.StateVersions);e.User=i;let r=os(e);!r||!t.userId||this.stateStore.afterFullRead(r,e.StateVersions);}async resolveTitleConfig(e,t,i,r){let s=e.TitleConfigVersion;if(i&&s&&i.v===s)return i.c;if(e.TitleConfigUrl){let p=await this.fetchConfigFromCdn(e.TitleConfigUrl);if(p!=null)return s&&await this.configCache.write(t,s,p),p}let a=await this.fetchConfigFromApi(r);return a!=null?(s&&await this.configCache.write(t,s,a),a):i?.c??null}async fetchConfigFromCdn(e){try{let t=await this.ctx.fetchImpl(e);if(!t.ok)return null;let i=await t.json();return i&&typeof i=="object"?i:null}catch{return null}}async fetchConfigFromApi(e){let t=this.baseRequest();if(!t)return null;let i={...t,...e},r=e.ExcludeFields?await this.ctx.api.title.getTitlePublicConfigurationExcept(i):await this.ctx.api.title.getTitlePublicConfiguration(i);return r.ok?r.data:null}async getClientStateExcept(e,t){let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.ExcludeFields=e,i.ExcludeTitleFields=t;let r=bt.scopeOf(null,t??[]),s=await this.configCache.read(r);s&&(i.KnownTitleConfigVersion=s.v),await this.prepareLocalization(i);let a=await this.prepareStateHandshake(i,e??null),p=await this.ctx.api.user.getClientStateExcept(i);if(!p.ok)return p;let D=await this.resolveTitleConfig(p.data,r,s,{ExcludeFields:t??[]});return D==null?jn:(this.finishStateHandshake(p.data,a),await this.applyClientState(p.data,D,e,t),await this.applyLocalization(p.data.Localization),await this.flushState(a),p)}async prepareLocalization(e){let t=this.ctx.localization.locale??this.ctx.settings.locale;t&&(e.Locale=t);let i=await this.localizationCache.readVersions();Object.keys(i).length>0&&(e.KnownLocalizationVersions=i);}async applyLocalization(e){if(!e){this.ctx.localization.applyState(null,{table:null,fallbackTable:null});return}let t=await this.resolveLocalizationTable({Locale:e.Locale,Version:e.Version,Url:e.Url}),i=e.Fallback?await this.resolveLocalizationTable(e.Fallback):null;this.ctx.localization.applyState(e,{table:t,fallbackTable:i});}async resolveLocalizationTable(e){let t=e.Locale??null,i=e.Version??0;if(!t)return null;let r=await this.localizationCache.read(t);if(i<=0)return r?.t??null;if(r&&r.v===i)return r.t;if(e.Url){let a=await this.fetchLocalizationFromCdn(e.Url);if(a!=null)return await this.localizationCache.write(t,i,a),a}let s=await this.fetchLocalizationFromApi(t,r?.v??0);return s??r?.t??null}async fetchLocalizationFromCdn(e){try{let t=await this.ctx.fetchImpl(e);if(!t.ok)return null;let i=await t.json();return i&&typeof i=="object"?i:null}catch{return null}}async fetchLocalizationFromApi(e,t){let i=this.baseRequest();if(!i)return null;let r=await this.ctx.api.localization.getLocalizationTable({...i,Locale:e,KnownVersion:t});if(!r.ok)return null;let s=r.data;if(s.NotModified)return null;let a=s.Entries??{},p=s.Version??0,D=s.Locale??e;return p>0&&await this.localizationCache.write(D,p,a),a}async getStateVersions(e){let t=this.baseRequest();return t?(e&&e.length>0&&(t.Fields=e),this.ctx.api.user.getStateVersions(t)):n("unauthorized","Not logged in.")}async getUserState(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&e.length>0&&(t.Fields=e);let i=await this.prepareStateHandshake(t,null),r=await this.ctx.api.user.getUserState(t);if(!r.ok)return r;let s=ns(r.data.User,i.cached,i.sent,r.data.StateVersions);r.data.User=s;let a=Object.keys(r.data.StateVersions??{});this.ctx.data.user.applyUserStateContainers(s,a);let p=os(r.data);return p&&(this.stateStore.afterSliceRead(p,r.data.StateVersions),await this.flushState(i)),r}async flushState(e){e.userId&&await this.stateStore.flush(e.userId,this.ctx.data.user.state);}async getUserInventory(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getInventory(e);return t.ok&&(this.ctx.data.user.applyInventory(t.data),this.ctx.emitter.emit("user:inventoryReceived",t.data)),t}async getEventTokens(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getEventTokens(e);return t.ok&&this.ctx.emitter.emit("user:eventTokensReceived",t.data),t}async getUsageTime(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getUsageTime(e);return t.ok&&this.ctx.emitter.emit("user:usageTimeReceived",t.data),t}async addUsageTime(e,t,i){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.UsageTime=e,r.IsNewSession=t,r.SessionDurationSeconds=i;let s=await this.ctx.api.user.addUsageTime(r);return s.ok&&this.ctx.emitter.emit("user:usageTimeAdded",s.data),s}async deleteUserAccount(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.deleteUserAccount(e);return t.ok&&this.ctx.emitter.emit("user:accountDeleted",t.data),t}async changeUsername(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Username=e;let i=await this.ctx.api.user.changeUsername(t);return i.ok&&this.ctx.emitter.emit("user:usernameChanged",i.data),i}async applyClientState(e,t,i,r){let s=i?.includes("GameLoop")===true,a=r?.includes("GameLoop")===true,p=s?this.ctx.data.user.state?.GameLoop:void 0,D=a?this.ctx.data.config.titlePublicConfiguration?.GameLoop:void 0;this.ctx.data.config.applyTitlePublicConfiguration(t),this.ctx.data.user.applyUserState(e.User??{});let B=this.ctx.data.user.state;s&&B&&B.GameLoop==null&&(B.GameLoop=p);let E=this.ctx.data.config.titlePublicConfiguration;a&&E&&E.GameLoop==null&&(E.GameLoop=D),this.ctx.emitter.emit("user:clientStateReceived",e);}};var si=class{constructor(e){this.ctx=e;}ctx;async convert(e,t,i,r,s,a){if(!t)return n("client","SourceID is required.");if(!r)return n("client","TargetID is required.");if(s<=0)return n("client","Amount must be positive.");if(e===i&&t===r)return n("client","Source and target must differ.");if(e===Ge.Crypto||i===Ge.Crypto)return n("client","Convert supports VC\u2194VC only. Use cryptoConvert for crypto.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let p={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:i,TargetID:r,SourceAmount:String(Math.trunc(s)),TransactionID:a&&a.length>0?a:`convert_${e}_${t}_to_${i}_${r}_${P()}`},D=await this.ctx.api.currency.convert(p);if(D.ok){let B=D.data,E={Consume:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:B.SourceID,Amount:B.SourceSpent}]}},Grant:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:B.TargetID,Amount:B.TargetCredited}]}}};this.ctx.data.user.applyResourceOperation(E,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("currency:converted",B);}return D}async cryptoConvert(e,t,i,r,s,a){let p=s instanceof Ht__default.default?s:new Ht__default.default(s);if(!t)return n("client","SourceID is required.");if(!r)return n("client","TargetID is required.");if(p.lte(0))return n("client","SourceAmount must be a positive decimal.");if(e===i&&t===r)return n("client","Source and target must differ.");if(e===Ge.Virtual&&i===Ge.Virtual)return n("client","cryptoConvert requires at least one crypto side. Use convert for VC\u2194VC.");if(e===Ge.Virtual&&!p.isInteger())return n("client","Virtual currency source amount must be integer.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let D={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:i,TargetID:r,SourceAmount:p.toString(),TransactionID:a&&a.length>0?a:`crypto_convert_${e}_${t}_to_${i}_${r}_${P()}`},B=await this.ctx.api.currency.cryptoConvert(D);if(B.ok){let E=B.data,pe=[],fe=[];if(E.SourceType===Ge.Virtual&&pe.push({Type:"VirtualCurrency",CurrencyID:E.SourceID,Amount:Math.trunc(Number(E.SourceSpent))}),E.TargetType===Ge.Virtual&&fe.push({Type:"VirtualCurrency",CurrencyID:E.TargetID,Amount:Math.trunc(Number(E.TargetCredited))}),pe.length>0||fe.length>0){let ve={Consume:pe.length>0?{Standard:{Entries:pe}}:null,Grant:fe.length>0?{Standard:{Entries:fe}}:null};this.ctx.data.user.applyResourceOperation(ve,this.ctx.data.config.itemDefinitions);}E.SourceType===Ge.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(E.SourceID,new Ht__default.default(E.SourceSpent).negated(),E.ServerTimeUtc),E.TargetType===Ge.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(E.TargetID,new Ht__default.default(E.TargetCredited),E.ServerTimeUtc),this.ctx.emitter.emit("currency:cryptoConverted",E);}return B}};var ni=class{constructor(e){this.ctx=e;}ctx;async upgradeLevel(e,t){let i=e.trim();if(!i)return n("client","ItemInstanceID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),ItemInstanceID:i,RelatedEntityID:`upgrade_item_${i}_${P()}`};t&&t.length>0&&(r.FodderInstanceIDs=[...t]);let s=await this.ctx.api.item.upgradeLevel(r);return s.ok&&(await this.ctx.userService.getUserInventory(),this.ctx.emitter.emit("item:levelUpgraded",s.data)),s}async upgradeLevelsBatch(e){if(!e||e.length===0)return n("client","upgrades is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Upgrades:e},i=await this.ctx.api.item.upgradeLevelsBatch(t);return i.ok&&(await this.ctx.userService.getUserInventory(),this.ctx.emitter.emit("item:levelsUpgradedBatch",i.data)),i}};var Rc="Store",oi=class{constructor(e){this.ctx=e;}ctx;async purchase(e,t=1){if(!e)return n("client","OfferID is required.");if(t<1)return n("client","Count must be at least 1.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),OfferID:e,Count:t,RelatedEntityID:`store_buy_${e}_${i.userID}_${P()}`},s=await this.ctx.api.store.purchase(r);if(s.ok){let a=s.data;this.ctx.data.user.patchStorePurchase(e,t,a.ServerTimeUtc),this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("store:offerPurchased",a);}return s}async purchaseBatch(e){if(!e||e.length===0)return n("client","purchases is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Purchases:e},i=await this.ctx.api.store.purchaseBatch(t);if(i.ok){let r=false;for(let s of i.data)!s.Success||!s.Data||!s.Data.OfferID||(this.ctx.data.user.patchStorePurchase(s.Data.OfferID,s.Data.Count,s.Data.ServerTimeUtc),!r&&s.Data.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("store:offersPurchasedBatch",i.data);}return i}async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.store.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Rc,t.data),this.ctx.emitter.emit("store:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.store.getUserState(e);return t.ok&&(this.ctx.data.user.applyStore(t.data),this.ctx.emitter.emit("store:userStateLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var yc="Lootbox",ai=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.lootbox.getDefinitions(e);if(t.ok){let i=t.data.LootboxDefinitions;i&&(this.ctx.data.config.patchSection(yc,i),this.ctx.emitter.emit("lootbox:definitionsLoaded",i));}return t}async open(e,t,i){if(!e)return n("client","LootboxID is required.");if(t<1)return n("client","Count must be at least 1.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),LootboxID:e,Count:t,SelectedOptionID:i,RelatedEntityID:`lootbox_${e}_${i}_${P()}`},s=await this.ctx.api.lootbox.open(r);if(s.ok){let a=s.data;a.TriggeredPity&&a.TriggeredPity.length>0&&this.ctx.data.user.applyLootboxPityTriggers(e,a.TriggeredPity,t),this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.data.user.applyInventoryDelta(a.Inventory),this.ctx.emitter.emit("lootbox:opened",a);}return s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Cc="Reward";function as(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var li=class{constructor(e){this.ctx=e;}ctx;multiplier=1;multiplierEnabled=false;get milestoneRewardMultiplier(){return this.multiplier}get milestoneRewardMultiplierEnabled(){return this.multiplierEnabled}async getRewardDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.reward.getRewardDefinitions(e);if(t.ok){let i=t.data.RewardDefinitions;i&&(this.ctx.data.config.patchSection(Cc,i),this.ctx.emitter.emit("reward:definitionsLoaded",i));}return t}async getUserRewardsState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.reward.getUserRewardsState(e);return t.ok&&t.data.Rewards&&(this.ctx.data.user.applyReward(t.data.Rewards),this.ctx.emitter.emit("reward:userStateLoaded",t.data.Rewards)),t}async getMilestoneRewardMultiplier(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.reward.getMilestoneRewardMultiplier(e);if(t.ok){let i=t.data;this.multiplierEnabled=i.Enabled,this.multiplier=i.Enabled?i.Multiplier??1:1,this.ctx.emitter.emit("reward:milestoneMultiplierLoaded",i);}return t}async claimDailyReward(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CalendarID:e,RelatedEntityID:`dailyreward_${t.userID}_${e??"default"}_${P()}`},r=await this.ctx.api.reward.claimDailyReward(i);if(r.ok){let s=r.data;this.ctx.data.user.patchDailyCalendarState(s.CalendarID,s.DailyState),this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:dailyClaimed",s);}return r}async collectIdleAccrual(e){if(!as(e))return n("client",'AccrualID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),AccrualID:e,RelatedEntityID:`idle_collect_${e}_${P()}`},i=await this.ctx.api.reward.collectIdleAccrual(t);if(i.ok){let r=i.data;this.ctx.data.user.patchIdleAccrualState(r.AccrualID,r.IdleState),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:idleCollected",r);}return i}async claimComebackReward(e){if(!as(e))return n("client",'ComebackID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),ComebackID:e,RelatedEntityID:`comeback_claim_${e}_${P()}`},i=await this.ctx.api.reward.claimComebackReward(t);if(i.ok){let r=i.data;this.ctx.data.user.patchComebackState(r.ComebackID,r.ComebackState),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:comebackClaimed",r);}return i}async claimReward(e){if(!as(e))return n("client",'ClaimID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),ClaimID:e,RelatedEntityID:`reward_claim_${e}_${P()}`},i=await this.ctx.api.reward.claimReward(t);if(i.ok){let r=i.data;this.ctx.data.user.patchClaimRewardState(r.ClaimID,r.ClaimState),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:claimed",r);}return i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Sc="Tutorial",ui=class{constructor(e){this.ctx=e;}ctx;async getTutorialDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.tutorial.getTutorialDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Sc,t.data),this.ctx.emitter.emit("tutorial:definitionsLoaded",t.data)),t}async getUserTutorialState(e=true){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.AutoStart=e;let i=await this.ctx.api.tutorial.getUserTutorialState(t);if(i.ok){let r=i.data.State??{};this.ctx.data.user.applyTutorial(r),this.ctx.emitter.emit("tutorial:userStateLoaded",i.data);}return i}async startFlow(e){return this.flowCall(e,t=>this.ctx.api.tutorial.startFlow(t),{event:"tutorial:flowStarted"})}async reportStepShown(e,t){return this.stepCall(e,t,i=>this.ctx.api.tutorial.reportStepShown(i))}async completeStep(e,t){return this.stepCall(e,t,i=>this.ctx.api.tutorial.completeStep(i),{relatedEntityID:`tutorial_step_${e}_${t}_${P()}`})}async completeStepsBatch(e,t){let i=e?.trim();if(!i)return n("client","FlowID is required.");if(!t||t.length===0)return n("client","stepIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),FlowID:i,StepIDs:t,RelatedEntityID:`tutorial_batch_${i}_${P()}`},s=await this.ctx.api.tutorial.completeStepsBatch(r);return s.ok&&(await this.refreshAfterMutation(),this.ctx.emitter.emit("tutorial:stepsCompletedBatch",s.data)),s}async skipStep(e,t){return this.stepCall(e,t,i=>this.ctx.api.tutorial.skipStep(i))}async skipFlow(e){return this.flowCall(e,t=>this.ctx.api.tutorial.skipFlow(t),{event:"tutorial:flowSkipped"})}async claimFlowReward(e){let t=e?.trim();if(!t)return n("client","FlowID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),FlowID:t,RelatedEntityID:`tutorial_claim_${t}_${P()}`},r=await this.ctx.api.tutorial.claimFlowReward(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Granted,this.ctx.data.config.itemDefinitions),await this.refreshAfterMutation(),this.ctx.emitter.emit("tutorial:rewardClaimed",r.data)),r}async resetFlow(e){return this.flowCall(e,t=>this.ctx.api.tutorial.resetFlow(t),{event:"tutorial:flowReset"})}async flowCall(e,t,i){let r=e?.trim();if(!r)return n("client","FlowID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),FlowID:r},a=await t(s);return a.ok&&(this.applyFlowView(a.data),this.ctx.emitter.emit(i.event,a.data)),a}async stepCall(e,t,i,r){let s=e?.trim(),a=t?.trim();if(!s)return n("client","FlowID is required.");if(!a)return n("client","StepID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let p={...this.ctx.buildAuthedBaseRequest(),FlowID:s,StepID:a};r?.relatedEntityID&&(p.RelatedEntityID=r.relatedEntityID);let D=await i(p);return D.ok&&(this.applyFlowView(D.data),this.ctx.emitter.emit("tutorial:stepChanged",D.data)),D}applyFlowView(e){e?.Flow&&this.ctx.data.user.patchTutorialFlow(e.Flow);}async refreshAfterMutation(){await this.getUserTutorialState(false).catch(()=>{});}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var ci=Object.freeze({}),pi=class{constructor(e){this.ctx=e;}ctx;table={...ci};fallbackTable=null;currentLocale=null;currentFallbackLocale=null;pluralRules=null;get cache(){return this.tableCache??=new zt(this.ctx.settings.configStorage,this.ctx.settings.titleID)}tableCache;get locale(){return this.currentLocale}get fallbackLocale(){return this.currentFallbackLocale}get locales(){let e=this.ctx.data.config.titlePublicConfiguration?.Localization??null;return e?.Locales?Object.entries(e.Locales).filter(([,t])=>t?.IsEnabled!==false).map(([t,i])=>({Locale:i?.Locale??t,DisplayName:i?.DisplayName??null,Order:i?.Order??0})).sort((t,i)=>(t.Order??0)-(i.Order??0)):[]}has(e){return this.lookup(e)!==void 0}t(e,t){if(!e)return "";let i=this.resolveKey(e,t),r=this.lookup(i)??this.lookup(e);return r===void 0?this.onMissing(e):t?xc(r,t):r}applyState(e,t){if(!e){this.reset();return}let i=e.Locale??null;this.table=t.table??{...ci},this.fallbackTable=t.fallbackTable,this.currentFallbackLocale=e.Fallback?.Locale??null,this.setLocaleInternal(i),this.ctx.emitter.emit("localization:changed",{locale:i,fallbackLocale:this.currentFallbackLocale,entryCount:Object.keys(this.table).length});}async setLocale(e){if(!this.baseRequest())return n("unauthorized","Not logged in.");let i=await this.loadTableFromApi(e);if(!i.ok)return i;let{locale:r,table:s,fallbackLocale:a}=i.data,p=null;if(a){let D=await this.loadTableFromApi(a);D.ok&&(p=D.data.table);}return this.table=s,this.fallbackTable=p,this.currentFallbackLocale=a,this.setLocaleInternal(r),this.ctx.emitter.emit("localization:changed",{locale:r,fallbackLocale:a,entryCount:Object.keys(s).length}),{ok:true,data:r}}async getManifest(){let e=this.baseRequest();return e?(e.Locale=this.currentLocale??this.ctx.settings.locale,this.ctx.api.localization.getLocalizationManifest(e)):n("unauthorized","Not logged in.")}reset(){this.table={...ci},this.fallbackTable=null,this.currentFallbackLocale=null,this.setLocaleInternal(null);}setLocaleInternal(e){this.currentLocale=e,this.pluralRules=null;}baseRequest(){let e=this.ctx.auth.context;return e?{UserID:e.userID,ClientSessionTicket:e.clientSessionTicket,BuildKey:this.ctx.settings.buildKey,RelatedEntityID:P()}:null}async loadTableFromApi(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Locale=e;let i=await this.cache.read(Fn(e));i&&(t.KnownVersion=i.v);let r=await this.ctx.api.localization.getLocalizationTable(t);if(!r.ok)return r;let s=r.data,a=s.Locale??Fn(e),p=s.Version??0;if(s.NotModified){let B=i??await this.cache.read(a);return {ok:true,data:{locale:a,table:B?.t??{...ci},fallbackLocale:s.FallbackLocale??null}}}let D=s.Entries??{};return p>0&&await this.cache.write(a,p,D),{ok:true,data:{locale:a,table:D,fallbackLocale:s.FallbackLocale??null}}}lookup(e){let t=this.table[e];return t!==void 0?t:this.fallbackTable?.[e]}resolveKey(e,t){let i=t?.count;if(typeof i!="number")return e;let r=this.pluralCategory(i),s=`${e}.${r}`;if(this.lookup(s)!==void 0)return s;let a=`${e}.other`;return this.lookup(a)!==void 0?a:e}pluralCategory(e){try{return this.pluralRules??=new Intl.PluralRules(this.currentLocale??void 0),this.pluralRules.select(e)}catch{return "other"}}onMissing(e){let t=this.ctx.data.config.titlePublicConfiguration?.Localization?.MissingKeyMode??"ReturnKey";return t==="ReturnEmpty"?"":t==="ReturnMarkedKey"?`\u27E6${e}\u27E7`:e}};function xc(o,e){return o.replace(/\{(\w+)\}/g,(t,i)=>{let r=e[i];return r===void 0?t:String(r)})}function Fn(o){return o.trim().replace(/_/g,"-").toLowerCase()}var Dc="Quest",di=class{constructor(e){this.ctx=e;}ctx;async getQuestDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.quest.getQuestDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Dc,t.data),this.ctx.emitter.emit("quest:definitionsLoaded",t.data)),t}async getUserQuestState(e=true){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.AutoRefreshCycles=e;let i=await this.ctx.api.quest.getUserQuestState(t);if(i.ok){let r=i.data.State??{};this.ctx.data.user.applyQuest(r),this.ctx.data.user.patchQuestPointsTracks(i.data.PointsTracks),this.ctx.emitter.emit("quest:userStateLoaded",r);}return i}async refreshQuestCycles(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.quest.refreshQuestCycles(e);return t.ok&&this.ctx.emitter.emit("quest:cyclesRefreshed",void 0),t}async claimQuestReward(e,t){let i=e.trim();if(!i)return n("client","QuestID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r=t&&t.trim().length>0?t.trim():void 0,s={...this.ctx.buildAuthedBaseRequest(),QuestID:i,CycleID:r,RelatedEntityID:`quest_claim_${r??""}_${i}_${P()}`},a=await this.ctx.api.quest.claimQuestReward(s);if(a.ok){let p=a.data;this.ctx.data.user.patchQuestStatus(p.QuestID,p.CycleID,"Claimed"),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:rewardClaimed",p);}return a}async claimQuestRewardsBatch(e){if(!e||e.length===0)return n("client","quests is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Quests:e},i=await this.ctx.api.quest.claimQuestRewardsBatch(t);if(i.ok){let r=false;for(let s of i.data)!s.Success||!s.Data||(this.ctx.data.user.patchQuestStatus(s.Data.QuestID,s.Data.CycleID,"Claimed"),!r&&s.Data.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("quest:rewardsClaimedBatch",i.data);}return i}async claimMilestoneReward(e,t){let i=e.trim(),r=t.trim();if(!i||!r)return n("client","CycleID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CycleID:i,MilestoneID:r,RelatedEntityID:`milestone_claim_${i}_${r}_${P()}`},a=await this.ctx.api.quest.claimMilestoneReward(s);if(a.ok){let p=a.data;this.ctx.data.user.patchMilestoneClaimed(p.CycleID,p.MilestoneID),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:milestoneClaimed",p);}return a}async claimMilestoneRewardsBatch(e){if(!e||e.length===0)return n("client","milestones is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Milestones:e},i=await this.ctx.api.quest.claimMilestoneRewardsBatch(t);if(i.ok){let r=false;for(let s of i.data)!s.Success||!s.Data||(this.ctx.data.user.patchMilestoneClaimed(s.Data.CycleID,s.Data.MilestoneID),!r&&s.Data.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("quest:milestonesClaimedBatch",i.data);}return i}async claimGroupCompletionReward(e,t){let i=e.trim(),r=t.trim();if(!i||!r)return n("client","CycleID and GroupCompletionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CycleID:i,GroupCompletionID:r,RelatedEntityID:`group_completion_${i}_${r}_${P()}`},a=await this.ctx.api.quest.claimGroupCompletionReward(s);if(a.ok){let p=a.data;this.ctx.data.user.patchGroupCompletionClaimed(p.CycleID,p.GroupCompletionID),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:groupCompletionClaimed",p);}return a}async addQuestProgress(e,t){let i=e.trim();if(!i)return n("client","MetricID is required.");if(t<0)return n("client","ProgressValue must be >= 0.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),MetricID:i,ProgressValue:t},s=await this.ctx.api.quest.addQuestProgress(r);return s.ok&&(this.ctx.data.user.patchQuestProgressUpdates(s.data.Updates),this.ctx.emitter.emit("quest:progressAdded",s.data)),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var bc="TimedEvent",hi=class{constructor(e){this.ctx=e;}ctx;async getActiveEvents(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedEvent.getActiveEvents(e);return t.ok&&(this.ctx.data.user.applyActiveEvents(t.data),this.ctx.emitter.emit("timedEvent:activeEventsLoaded",t.data)),t}async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedEvent.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(bc,t.data),this.ctx.emitter.emit("timedEvent:definitionsLoaded",t.data)),t}async getUserLteState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedEvent.getUserLteState(e);return t.ok&&(this.ctx.data.user.applyUserLteState(t.data),this.ctx.emitter.emit("timedEvent:userStateLoaded",t.data)),t}async grantTokens(e,t,i,r,s,a,p=1){if(!t)return n("client","LteID is required.");if(!i)return n("client","SourceType is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let D={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,SourceType:i,Outcome:r,AmountOverride:s,SourceParams:a,RollMultiplier:p},B=await this.ctx.api.timedEvent.grantTokens(D);return B.ok&&(this.ctx.data.user.applyResourceOperation(B.data,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensGranted",B.data)),B}async spendTokens(e,t,i){if(!t)return n("client","LteID is required.");if(i<=0)return n("client","SpendAmount must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,SpendAmount:i},s=await this.ctx.api.timedEvent.spendTokens(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensSpent",s.data)),s}async claimMilestone(e,t,i){if(!t||!i)return n("client","LteID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,MilestoneID:i},s=await this.ctx.api.timedEvent.claimMilestone(r);if(s.ok){let a=s.data;this.ctx.data.user.applyResourceOperation(a.Rewards,this.ctx.data.config.itemDefinitions),this.ctx.data.user.patchTimedEventMilestoneClaimed(e,t,i),this.ctx.emitter.emit("timedEvent:milestoneClaimed",a);}return s}async claimMilestonesBatch(e){if(!e||e.length===0)return n("client","milestones is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Milestones:e},i=await this.ctx.api.timedEvent.claimMilestonesBatch(t);return i.ok&&(this.applyMilestoneClaimBatch(i.data),this.ctx.emitter.emit("timedEvent:milestonesClaimedBatch",i.data)),i}async claimAllMilestones(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&e.length>0&&(t.Events=e);let i=await this.ctx.api.timedEvent.claimAllMilestones(t);return i.ok&&(this.applyMilestoneClaimBatch(i.data),this.ctx.emitter.emit("timedEvent:allMilestonesClaimed",i.data)),i}async spendTokensBatch(e){if(!e||e.length===0)return n("client","spends is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Spends:e},i=await this.ctx.api.timedEvent.spendTokensBatch(t);if(i.ok){let r=false;for(let s of i.data)!r&&s.Success&&s.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("timedEvent:tokensSpentBatch",i.data);}return i}async grantTokensBatch(e){if(!e||e.length===0)return n("client","grants is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Grants:e},i=await this.ctx.api.timedEvent.grantTokensBatch(t);if(i.ok){let r=false;for(let s of i.data)!r&&s.Success&&s.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("timedEvent:tokensGrantedBatch",i.data);}return i}applyMilestoneClaimBatch(e){let t=false;for(let i of e){if(!i.Success||!i.Data)continue;let r=i.Data;r.Type&&r.LteID&&r.MilestoneID&&this.ctx.data.user.patchTimedEventMilestoneClaimed(r.Type,r.LteID,r.MilestoneID),!t&&r.Rewards&&(this.ctx.data.user.applyResourceOperation(r.Rewards,this.ctx.data.config.itemDefinitions),t=true);}}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var zc="Leaderboard",mi=class{constructor(e){this.ctx=e;}ctx;cycleDocID(e){return `${this.ctx.settings.titleID}_${e}`}async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.leaderboard.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(zc,t.data),this.ctx.emitter.emit("leaderboard:definitionsLoaded",t.data)),t}async getLeaderboard(e){if(!e)return n("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardID=e;let i=await this.ctx.api.leaderboard.getLeaderboard(t);return i.ok&&this.ctx.emitter.emit("leaderboard:loaded",i.data),i}async getMyProgress(e){if(!e)return n("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardID=e;let i=await this.ctx.api.leaderboard.getMyProgress(t);return i.ok&&(this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(e),i.data),this.ctx.emitter.emit("leaderboard:myProgressLoaded",i.data)),i}async submitScore(e,t){if(!e)return n("client","LeaderboardID is required.");if(t<=0)return n("client","Score must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,Score:t},r=await this.ctx.api.leaderboard.submitScore(i);if(r.ok){let s=r.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),s.NewScore,t,s.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",s);}return r}async submitScoreFromSource(e,t,i,r,s=1){if(!e)return n("client","LeaderboardID is required.");if(!t)return n("client","SourceType is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,SourceType:t,Outcome:i,Params:r,RollMultiplier:s},p=await this.ctx.api.leaderboard.submitScoreFromSource(a);if(p.ok){let D=p.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),D.NewScore,D.NewScore,D.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",D);}return p}async claimCycleReward(e){if(!e)return n("client","LeaderboardID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e},i=await this.ctx.api.leaderboard.claimCycleReward(t);if(i.ok){let r=i.data;this.ctx.data.user.patchLeaderboardCycleRewardClaimed(this.cycleDocID(e)),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("leaderboard:cycleRewardClaimed",r);}return i}async claimMilestone(e,t){if(!e||!t)return n("client","LeaderboardID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,MilestoneID:t},r=await this.ctx.api.leaderboard.claimMilestone(i);if(r.ok){let s=r.data;this.ctx.data.user.patchLeaderboardMilestoneClaimed(this.cycleDocID(e),t),this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("leaderboard:milestoneClaimed",s);}return r}async getFriendsLeaderboard(e){if(!e)return n("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardID=e;let i=await this.ctx.api.leaderboard.getFriendsLeaderboard(t);return i.ok&&this.ctx.emitter.emit("leaderboard:friendsLoaded",i.data),i}async getLeaderboardsBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardIDs=e;let i=await this.ctx.api.leaderboard.getLeaderboardsBatch(t);return i.ok&&this.ctx.emitter.emit("leaderboard:loadedBatch",i.data),i}async getProgressBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardIDs=e;let i=await this.ctx.api.leaderboard.getProgressBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(r.Data.LeaderboardID),r.Data);this.ctx.emitter.emit("leaderboard:myProgressLoadedBatch",i.data);}return i}async claimCycleRewardsBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardIDs:e},i=await this.ctx.api.leaderboard.claimCycleRewardsBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||(this.ctx.data.user.patchLeaderboardCycleRewardClaimed(this.cycleDocID(r.Data.LeaderboardID)),r.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.Data.Resources,this.ctx.data.config.itemDefinitions));this.ctx.emitter.emit("leaderboard:cycleRewardsClaimedBatch",i.data);}return i}async claimMilestonesBatch(e){if(!e||e.length===0)return n("client","milestones is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Milestones:e},i=await this.ctx.api.leaderboard.claimMilestonesBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||(this.ctx.data.user.patchLeaderboardMilestoneClaimed(this.cycleDocID(r.Data.LeaderboardID),r.Data.MilestoneID),r.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.Data.Resources,this.ctx.data.config.itemDefinitions));this.ctx.emitter.emit("leaderboard:milestonesClaimedBatch",i.data);}return i}async submitScoresBatch(e){if(!e||e.length===0)return n("client","scores is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Scores:e},i=await this.ctx.api.leaderboard.submitScoresBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(r.Data.LeaderboardID),r.Data.NewScore,r.Data.NewScore,r.Data.CycleVersion);this.ctx.emitter.emit("leaderboard:scoresSubmittedBatch",i.data);}return i}async claimAllRewardsBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardIDs:e},i=await this.ctx.api.leaderboard.claimAllRewardsBatch(t);if(i.ok){for(let r of i.data){let s=this.cycleDocID(r.LeaderboardID);r.CycleReward?.Success&&r.CycleReward.Data&&(this.ctx.data.user.patchLeaderboardCycleRewardClaimed(s),r.CycleReward.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.CycleReward.Data.Resources,this.ctx.data.config.itemDefinitions));for(let a of r.Milestones??[])!a.Success||!a.Data||(this.ctx.data.user.patchLeaderboardMilestoneClaimed(s,a.Data.MilestoneID),a.Data.Resources&&this.ctx.data.user.applyResourceOperation(a.Data.Resources,this.ctx.data.config.itemDefinitions));}this.ctx.emitter.emit("leaderboard:allRewardsClaimedBatch",i.data);}return i}async getOverviewBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardIDs=e;let i=await this.ctx.api.leaderboard.getOverviewBatch(t);if(i.ok){for(let r of i.data)r.Progress?.Success&&r.Progress.Data&&this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(r.LeaderboardID),r.Progress.Data);this.ctx.emitter.emit("leaderboard:overviewLoadedBatch",i.data);}return i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Tc="Season",fi=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.season.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Tc,t.data),this.ctx.emitter.emit("season:definitionsLoaded",t.data)),t}async getActiveSeason(e){if(!e)return n("client","SeasonChainID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.SeasonChainID=e;let i=await this.ctx.api.season.getActiveSeason(t);return i.ok&&(i.data.UserState&&this.ctx.data.user.patchSeasonState(e,i.data.UserState),this.ctx.emitter.emit("season:activeLoaded",i.data)),i}async getUserState(e){if(!e)return n("client","SeasonChainID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.SeasonChainID=e;let i=await this.ctx.api.season.getUserState(t);return i.ok&&(this.ctx.data.user.patchSeasonState(e,i.data),this.ctx.emitter.emit("season:userStateLoaded",i.data)),i}async grantStatusTokens(e,t){if(!e)return n("client","SeasonChainID is required.");if(t<=0)return n("client","Amount must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,Amount:t,RelatedEntityID:`season_grant_${e}_${P()}`},r=await this.ctx.api.season.grantStatusTokens(i);return r.ok&&(this.ctx.data.user.patchSeasonCurrentTier(e,r.data.NewTier),this.ctx.emitter.emit("season:statusTokensGranted",r.data)),r}async claimTierReward(e,t){if(!e)return n("client","SeasonChainID is required.");if(t<=0)return n("client","TierNumber must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,TierNumber:t,RelatedEntityID:`season_tier_${e}_t${t}_${P()}`},r=await this.ctx.api.season.claimTierReward(i);if(r.ok){let s=r.data;this.ctx.data.user.patchSeasonClaimedTier(e,t),this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("season:tierRewardClaimed",s);}return r}async claimTierRewardsBatch(e,t){if(!e)return n("client","SeasonChainID is required.");let i=(t??[]).filter(a=>a>0);if(i.length===0)return n("client","TierNumbers is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,TierNumbers:i,RelatedEntityID:`season_tier_batch_${e}_${P()}`},s=await this.ctx.api.season.claimTierRewardsBatch(r);if(s.ok){let a=s.data;for(let p of a.Items??[]){let D=p.Data?.TierNumber;p.Success&&typeof D=="number"&&this.ctx.data.user.patchSeasonClaimedTier(e,D);}this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("season:tierRewardsBatchClaimed",a);}return s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var vc="Premium",gi=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.premium.getDefinitions(e);return t.ok&&t.data.Premium&&(this.ctx.data.config.patchSection(vc,t.data.Premium),this.ctx.emitter.emit("premium:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.premium.getUserState(e);return t.ok&&t.data.Premium&&(this.ctx.data.user.applyPremium(t.data.Premium),this.ctx.emitter.emit("premium:stateLoaded",t.data)),t}async activateTrial(e,t){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,RelatedEntityID:`premium_trial_${e}_${t}`},r=await this.ctx.api.premium.activateTrial(i);return r.ok&&(r.data.Premium&&this.ctx.data.user.applyPremium(r.data.Premium),this.ctx.emitter.emit("premium:trialActivated",r.data)),r}async purchaseItemOrCurrency(e,t,i="Default",r=1){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,SelectedOptionID:i,Count:r,RelatedEntityID:`premium_purchase_${e}_${t}`},a=await this.ctx.api.premium.purchaseItemOrCurrency(s);if(a.ok){let p=a.data;p.Premium&&this.ctx.data.user.applyPremium(p.Premium),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:purchaseCompleted",p);}return a}async purchaseRealMoney(e,t,i,r,s,a,p,D){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!r||!s)return n("client","ProductID and ReceiptData are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let B={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,Store:i,ProductID:r,ReceiptData:s,PurchaseToken:a,PackageName:p,AppStoreEnvironment:D,RelatedEntityID:`premium_iap_${e}_${t}`},E=await this.ctx.api.premium.purchaseRealMoney(B);if(E.ok){let pe=E.data;pe.Premium&&this.ctx.data.user.applyPremium(pe.Premium),this.ctx.data.user.applyResourceOperation(pe.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:realMoneyPurchaseCompleted",pe);}return E}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Pc="Character",Ri=class{constructor(e){this.ctx=e;}ctx;async getCharacterDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.character.getCharacterDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Pc,t.data),this.ctx.emitter.emit("character:definitionsLoaded",t.data)),t}async getUserCharacters(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.character.getUserCharacters(e);if(t.ok){let i=t.data.Characters??{};this.ctx.data.user.applyCharacter(i),this.ctx.emitter.emit("character:userCharactersLoaded",i);}return t}async unlockCharacter(e){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,RelatedEntityID:`unlock_char_${e}_${P()}`},i=await this.ctx.api.character.unlockCharacter(t);if(i.ok){let r=i.data;this.ctx.data.user.patchCharacter(r.CharacterID,s=>{s.StatLevels??={},s.Equipment??={},r.Power!=null&&(s.Power=r.Power),s.UpdatedAt=r.ServerTimeUtc;}),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:unlocked",r);}return i}async upgradeStatLevel(e,t,i){if(!e||!t)return n("client","CharacterID and StatID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,StatID:t,RelatedEntityID:`upgrade_stat_${e}_${t}_${P()}`,...i?.levels!=null?{Levels:i.levels}:{},...i?.targetLevel!=null?{TargetLevel:i.targetLevel}:{}},s=await this.ctx.api.character.upgradeStatLevel(r);if(s.ok){let a=s.data;this.ctx.data.user.patchCharacter(a.CharacterID,p=>{p.StatLevels??={},p.StatLevels[a.StatID]=a.StatLevel,a.Power!=null&&(p.Power=a.Power),p.UpdatedAt=a.ServerTimeUtc;}),this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:statLevelUpgraded",a);}return s}async upgradeCharacterLevel(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,RelatedEntityID:`upgrade_char_${e}_${P()}`,...t?.levels!=null?{Levels:t.levels}:{},...t?.targetLevel!=null?{TargetLevel:t.targetLevel}:{}},r=await this.ctx.api.character.upgradeCharacterLevel(i);if(r.ok){let s=r.data;this.ctx.data.user.patchCharacter(s.CharacterID,a=>{a.Level=s.NewLevel,s.Power!=null&&(a.Power=s.Power),a.UpdatedAt=s.ServerTimeUtc,s.NewLevel===1&&(a.StatLevels??={},a.Equipment??={});}),this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:levelUpgraded",s);}return r}async equipItems(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,ItemsToEquip:t},r=await this.ctx.api.character.equipItems(i);return r.ok&&(this.applyEquipChangesLocally(e,r.data),this.ctx.emitter.emit("character:itemsEquipped",r.data)),r}async unequipItems(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,UnequipSlotIDs:t},r=await this.ctx.api.character.unequipItems(i);if(r.ok){let s=r.data;this.applyUnequipChangesLocally(e,s),this.ctx.emitter.emit("character:itemsUnequipped",{characterID:e,slotIDs:s.ClearedSlotIDs??[],power:s.Power??null});}return r}async unequipAllCharacters(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.character.unequipAllCharacters(e);return t.ok&&(this.applyUnequipAllLocally(t.data),this.ctx.emitter.emit("character:allUnequipped",t.data)),t}async unlockCharactersBatch(e){if(!e||e.length===0)return n("client","characterIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),UnlockCharacterIDs:e},i=await this.ctx.api.character.unlockCharactersBatch(t);return i.ok&&(this.applyBatchResults(i.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,s=>{s.StatLevels??={},s.Equipment??={},r.Power!=null&&(s.Power=r.Power),s.UpdatedAt=r.ServerTimeUtc;});}),this.ctx.emitter.emit("character:charactersUnlocked",i.data)),i}async upgradeCharacterLevelsBatch(e){if(!e||e.length===0)return n("client","upgrades is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LevelUpgrades:e},i=await this.ctx.api.character.upgradeCharacterLevelsBatch(t);return i.ok&&(this.applyBatchResults(i.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,s=>{s.Level=r.NewLevel,r.Power!=null&&(s.Power=r.Power),s.UpdatedAt=r.ServerTimeUtc,r.NewLevel===1&&(s.StatLevels??={},s.Equipment??={});});}),this.ctx.emitter.emit("character:levelsUpgraded",i.data)),i}async upgradeStatLevelsBatch(e){if(!e||e.length===0)return n("client","upgrades is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),StatUpgrades:e},i=await this.ctx.api.character.upgradeStatLevelsBatch(t);return i.ok&&(this.applyBatchResults(i.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,s=>{s.StatLevels??={},s.StatLevels[r.StatID]=r.StatLevel,r.Power!=null&&(s.Power=r.Power),s.UpdatedAt=r.ServerTimeUtc;});}),this.ctx.emitter.emit("character:statLevelsUpgraded",i.data)),i}applyBatchResults(e,t){e.Resources&&this.ctx.data.user.applyResourceOperation(e.Resources,this.ctx.data.config.itemDefinitions);for(let i of e.Items??[])!i.Success||!i.Data||t(i.Data);}applyInventoryDelta(e){this.ctx.data.user.applyInventoryDelta(e);}applyEquipChangesLocally(e,t){let i=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let[r,s]of Object.entries(t.Equipment??{}))i.patchCharacterEquipment(e,r,s);i.patchCharacter(e,r=>{t.Power!=null&&(r.Power=t.Power),r.UpdatedAt=t.ServerTimeUtc;});}applyUnequipChangesLocally(e,t){let i=t.ClearedSlotIDs??[];if(i.length===0&&t.Power==null)return;let r=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let s of i)r.patchCharacterEquipment(e,s,null);r.patchCharacter(e,s=>{t.Power!=null&&(s.Power=t.Power),s.UpdatedAt=t.ServerTimeUtc;});}applyUnequipAllLocally(e){let t=this.ctx.data.user;this.applyInventoryDelta(e.Inventory);for(let[i,r]of Object.entries(e.Characters??{})){for(let s of r.ClearedSlotIDs??[])t.patchCharacterEquipment(i,s,null);t.patchCharacter(i,s=>{r.Power!=null&&(s.Power=r.Power),s.UpdatedAt=e.ServerTimeUtc;});}}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ic="Match",yi=class{constructor(e){this.ctx=e;}ctx;async createMatch(e,t,i,r,s){let a=this.ctx.auth.context;if(!a)return n("unauthorized","Not logged in.");let p={...this.ctx.buildAuthedBaseRequest(),Entry:e,RuleID:t,CharacterID:i,BattleStrategy:r,TargetUserID:s,RelatedEntityID:`pvp_create_${a.userID}_${P()}`},D=await this.ctx.api.match.createMatch(p);return D.ok&&(this.ctx.data.user.applyResourceOperation(D.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:created",D.data)),D}async updateMatch(e,t={}){if(!e)return n("client","MatchID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),MatchID:e,TargetUserID:t.targetUserID,ClearTargetUser:t.clearTargetUser,RuleID:t.ruleID,CharacterID:t.characterID,BattleStrategy:t.battleStrategy},r=await this.ctx.api.match.updateMatch(i);return r.ok&&this.ctx.emitter.emit("match:updated",r.data),r}async cancelMatch(e){if(!e)return n("client","MatchID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),MatchID:e},i=await this.ctx.api.match.cancelMatch(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:cancelled",i.data)),i}async instantBattle(e,t,i,r){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),MatchID:e,RuleID:t,CharacterID:i,BattleStrategy:r,RelatedEntityID:`pvp_battle_${e}_${P()}`},p=await this.ctx.api.match.instantBattle(a);if(p.ok){let D=p.data,B=this.ctx.data.config.itemDefinitions;if(D.Resources)this.ctx.data.user.applyResourceOperation(D.Resources,B);else if(D.ResourcesDual){let E=D.ResourcesDual;E.FromUserID===s.userID&&E.FromResult?this.ctx.data.user.applyResourceOperation(E.FromResult,B):E.ToUserID===s.userID&&E.ToResult&&this.ctx.data.user.applyResourceOperation(E.ToResult,B);}this.ctx.emitter.emit("match:instantBattleCompleted",D);}return p}async saveStrategy(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BattleStrategy:e},i=await this.ctx.api.match.saveStrategy(t);return i.ok&&(this.ctx.data.user.patchMatchStrategy(e),this.ctx.emitter.emit("match:strategySaved",e)),i}async getMyMatches(e=0,t=20,i){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.Statuses=i;let s=await this.ctx.api.match.getMyMatches(r);return s.ok&&this.ctx.emitter.emit("match:myMatchesLoaded",s.data),s}async getAvailableMatches(e=0,t=20,i=false){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.OnlyPublic=i;let s=await this.ctx.api.match.getAvailableMatches(r);return s.ok&&this.ctx.emitter.emit("match:availableMatchesLoaded",s.data),s}async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.match.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Ic,t.data),this.ctx.emitter.emit("match:definitionsLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var kc="Craft",Ci=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.craft.getDefinitions(e);return t.ok&&t.data.CraftDefinitions&&(this.ctx.data.config.patchSection(kc,t.data.CraftDefinitions),this.ctx.emitter.emit("craft:definitionsLoaded",t.data.CraftDefinitions)),t}async craft(e,t,i=1,r){if(!e)return n("client","CraftID is required.");let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),CraftID:e,InputItemIDs:t,Count:i,SelectedOptionID:r,RelatedEntityID:`craft_${e}_${s.userID}_${P()}`},p=await this.ctx.api.craft.craft(a);return p.ok&&(this.ctx.data.user.applyResourceOperation(p.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("craft:completed",p.data)),p}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Mc="Collection",Si=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.collection.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Mc,t.data),this.ctx.emitter.emit("collection:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.collection.getUserState(e);return t.ok&&(this.ctx.data.user.applyCollection(t.data),this.ctx.emitter.emit("collection:userStateLoaded",t.data)),t}async openPack(e,t,i=1){let r=this.ctx.auth.context;if(!r)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,PackTypeID:t,Count:i,RelatedEntityID:`open_pack_${e}_${t}_${r.userID}_${P()}`},a=await this.ctx.api.collection.openPack(s);return a.ok&&(this.ctx.data.user.applyResourceOperation(a.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:packOpened",a.data)),a}async openCollectionChest(e,t,i=1){let r=this.ctx.auth.context;if(!r)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectionChestID:t,Count:i,RelatedEntityID:`open_chest_${e}_${t}_${r.userID}_${P()}`},a=await this.ctx.api.collection.openCollectionChest(s);return a.ok&&(this.ctx.data.user.applyResourceOperation(a.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:chestOpened",a.data)),a}async useCollectibleJoker(e,t){let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:false,RelatedEntityID:`use_joker_${e}_${t}_${i.userID}_${P()}`},s=await this.ctx.api.collection.useCollectibleJoker(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:jokerUsed",s.data)),s}async claimSetReward(e,t){let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,SetID:t,RelatedEntityID:`claim_set_${e}_${t}_${i.userID}_${P()}`},s=await this.ctx.api.collection.claimSetReward(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:setRewardClaimed",s.data)),s}async claimSetRewardsBatch(e){if(!e||e.length===0)return n("client","sets is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Sets:e},i=await this.ctx.api.collection.claimSetRewardsBatch(t);if(i.ok){let r=false;for(let s of i.data)!r&&s.Success&&s.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("collection:setRewardsClaimedBatch",i.data);}return i}async claimGrandPrize(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,RelatedEntityID:`grand_prize_${e}_${t.userID}_${P()}`},r=await this.ctx.api.collection.claimGrandPrize(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:grandPrizeClaimed",r.data)),r}async sendTradeOffer(e,t,i,r,s,a=false){let p=this.ctx.auth.context;if(!p)return n("unauthorized","Not logged in.");let D={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:i,ReceiverUserID:r,RequestedCollectibleID:s,RequestedCollectibleIsSpecial:a,RelatedEntityID:`trade_send_${p.userID}_${r}_${P()}`},B=await this.ctx.api.collection.sendTradeOffer(D);return B.ok&&this.ctx.emitter.emit("collection:tradeOfferSent",B.data),B}async cancelTradeOffer(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),OfferID:e,RelatedEntityID:`trade_cancel_${e}_${P()}`},i=await this.ctx.api.collection.cancelTradeOffer(t);return i.ok&&this.ctx.emitter.emit("collection:tradeOfferCancelled",i.data),i}async acceptTradeOffer(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),OfferID:e,RelatedEntityID:`trade_accept_${e}_${P()}`},i=await this.ctx.api.collection.acceptTradeOffer(t);return i.ok&&this.ctx.emitter.emit("collection:tradeOfferAccepted",i.data),i}async declineTradeOffer(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),OfferID:e,RelatedEntityID:`trade_decline_${e}_${P()}`},i=await this.ctx.api.collection.declineTradeOffer(t);return i.ok&&this.ctx.emitter.emit("collection:tradeOfferDeclined",i.data),i}async getMyTradeOffers(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CollectionID=e;let i=await this.ctx.api.collection.getMyTradeOffers(t);return i.ok&&this.ctx.emitter.emit("collection:myTradeOffersLoaded",i.data),i}async getIncomingTradeOffers(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CollectionID=e;let i=await this.ctx.api.collection.getIncomingTradeOffers(t);return i.ok&&this.ctx.emitter.emit("collection:incomingTradeOffersLoaded",i.data),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var wc="CoopEvent",xi=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.coopEvent.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(wc,t.data),this.ctx.emitter.emit("coopEvent:definitionsLoaded",t.data)),t}async getActiveEvent(e){if(!e)return n("client","CoopChainID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CoopChainID=e;let i=await this.ctx.api.coopEvent.getActiveEvent(t);return i.ok&&this.ctx.emitter.emit("coopEvent:activeEventLoaded",i.data),i}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.coopEvent.getUserState(e);return t.ok&&(this.ctx.data.user.applyCoopEvent(t.data.UserState??null),this.ctx.emitter.emit("coopEvent:userStateLoaded",t.data)),t}async getGroupState(e){if(!e)return n("client","GroupID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.GroupID=e;let i=await this.ctx.api.coopEvent.getGroupState(t);return i.ok&&this.ctx.emitter.emit("coopEvent:groupStateLoaded",i.data),i}async joinOrCreateGroup(e){if(!e)return n("client","CoopChainID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),CoopChainID:e},i=await this.ctx.api.coopEvent.joinOrCreateGroup(t);if(i.ok){let r=i.data.Group;r&&this.ctx.data.user.patchCoopEventActiveGroup(r.GroupID??null,r.CoopEventID??null,-1),this.ctx.emitter.emit("coopEvent:groupJoined",i.data);}return i}async spin(e,t,i=1){if(!e||!t)return n("client","CoopChainID and GroupID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CoopChainID:e,GroupID:t,Count:i,RelatedEntityID:P()},s=await this.ctx.api.coopEvent.spin(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("coopEvent:spinCompleted",s.data)),s}async claimObjectReward(e){if(!e)return n("client","GroupID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.coopEvent.claimObjectReward(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("coopEvent:objectRewardClaimed",i.data)),i}async claimGrandPrize(e){if(!e)return n("client","GroupID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.coopEvent.claimGrandPrize(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:grandPrizeClaimed",i.data)),i}async leaveGroup(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.coopEvent.leaveGroup(t);return i.ok&&(this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:groupLeft",i.data)),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ac="DealOffer",Di=class{constructor(e){this.ctx=e;}ctx;async getDefinition(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.dealOffer.getDefinition(e);return t.ok&&t.data.DealOfferDefinitions&&(this.ctx.data.config.patchSection(Ac,t.data.DealOfferDefinitions),this.ctx.emitter.emit("dealOffer:definitionLoaded",t.data.DealOfferDefinitions)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.dealOffer.getUserState(e);return t.ok&&t.data.DealOffers&&(this.ctx.data.user.applyDealOffer(t.data.DealOffers),this.ctx.emitter.emit("dealOffer:userStateLoaded",t.data.DealOffers)),t}async getActiveDeals(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.dealOffer.getActiveDeals(e);return t.ok&&this.ctx.emitter.emit("dealOffer:activeDealsLoaded",t.data),t}async dismissDeal(e){if(!e)return n("client","SlotID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),SlotID:e,RelatedEntityID:`deal_dismiss_${e}_${P()}`},i=await this.ctx.api.dealOffer.dismissDeal(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:dealDismissed",i.data)),i}async executeNode(e,t,i){if(!e||!t)return n("client","SlotID and NodeID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r=i&&i.trim().length>0?i.trim():void 0,s={...this.ctx.buildAuthedBaseRequest(),SlotID:e,NodeID:t,RelatedEntityID:r??`deal_exec_${e}_${t}_${P()}`},a=await this.ctx.api.dealOffer.executeNode(s);return a.ok&&(a.data.Idempotent||this.ctx.data.user.applyResourceOperation(a.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:nodeExecuted",a.data)),a}async recordShow(e){if(!e)return n("client","SlotID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),SlotID:e,RelatedEntityID:`deal_show_${e}_${P()}`},i=await this.ctx.api.dealOffer.recordShow(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:showRecorded",i.data)),i}async claimMilestone(e,t){if(!e||!t)return n("client","SlotID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneID:t,RelatedEntityID:`deal_milestone_${e}_${t}_${P()}`},r=await this.ctx.api.dealOffer.claimMilestone(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:milestoneClaimed",r.data)),r}async claimMilestonesBatch(e,t){if(!e)return n("client","SlotID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i=[...new Set(t.map(a=>a.trim()).filter(a=>a.length>0))],r={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneIDs:i,RelatedEntityID:`deal_milestone_batch_${e}_${P()}`},s=await this.ctx.api.dealOffer.claimMilestonesBatch(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:milestonesBatchClaimed",s.data)),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Uc="Referral",bi=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.referral.getDefinitions(e);return t.ok&&t.data.ReferralDefinitions&&(this.ctx.data.config.patchSection(Uc,t.data.ReferralDefinitions),this.ctx.emitter.emit("referral:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.referral.getUserState(e);return t.ok&&t.data.Referral&&(this.ctx.data.user.applyReferral(t.data.Referral),this.ctx.emitter.emit("referral:userStateLoaded",t.data)),t}async activateReferralCode(e){let t=e.trim().toUpperCase();if(!t)return n("client","ReferralCode is required.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),ReferralCode:t,RelatedEntityID:`referral_activation_${i.userID}`},s=await this.ctx.api.referral.activateReferralCode(r);if(s.ok){let a=s.data;a.ReferralCode&&this.ctx.data.user.patchReferralSubscription(a.ReferralCode),this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:codeActivated",a);}return s}async claimInviteReward(e){let t=e.trim();if(!t)return n("client","InviteRewardID is required.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),InviteRewardID:t,RelatedEntityID:`referral_invite_${t}_${i.userID}`},s=await this.ctx.api.referral.claimInviteReward(r);if(s.ok){let a=s.data;a.RewardID&&this.ctx.data.user.patchReferralInviteRewardClaimed(a.RewardID),this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:inviteRewardClaimed",a);}return s}async claimInviteRewardsBatch(e){let t=(e??[]).map(a=>a?.trim()).filter(Boolean);if(t.length===0)return n("client","InviteRewardIDs is required.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),InviteRewardIDs:t,RelatedEntityID:`referral_invite_batch_${t.join("_")}_${i.userID}`},s=await this.ctx.api.referral.claimInviteRewardsBatch(r);if(s.ok){let a=s.data;for(let p of a.Items??[])p.Success&&p.Id&&this.ctx.data.user.patchReferralInviteRewardClaimed(p.Id);this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:inviteRewardsBatchClaimed",a);}return s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var zi=class{constructor(e){this.ctx=e;}ctx;async getFriendsList(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getFriendsList(e);return t.ok&&(this.ctx.data.user.applySocialFriendsList(t.data.Friends),this.ctx.emitter.emit("social:friendsListLoaded",t.data)),t}async getIncomingRequests(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getIncomingRequests(e);return t.ok&&(this.ctx.data.user.applySocialIncomingRequests(t.data.Friends),this.ctx.emitter.emit("social:incomingRequestsLoaded",t.data)),t}async getRecommendedFriends(e=5){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Limit=e;let i=await this.ctx.api.social.getRecommendedFriends(t);return i.ok&&this.ctx.emitter.emit("social:recommendedFriendsLoaded",i.data),i}async sendFriendRequest(e){if(!e)return n("client","TargetUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.sendFriendRequest(t);return i.ok&&(this.ctx.data.user.patchSocialAddOutgoingRequest(e),this.ctx.emitter.emit("social:friendRequestSent",i.data)),i}async acceptFriendRequest(e){if(!e)return n("client","RequesterUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.acceptFriendRequest(t);return i.ok&&(this.ctx.data.user.patchSocialAcceptFriend(e),this.ctx.emitter.emit("social:friendRequestAccepted",i.data)),i}async declineFriendRequest(e){if(!e)return n("client","RequesterUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.declineFriendRequest(t);return i.ok&&(this.ctx.data.user.patchSocialRemoveIncomingRequest(e),this.ctx.emitter.emit("social:friendRequestDeclined",i.data)),i}async removeFriend(e){if(!e)return n("client","FriendUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.removeFriend(t);return i.ok&&(this.ctx.data.user.patchSocialRemoveFriend(e),this.ctx.emitter.emit("social:friendRemoved",i.data)),i}async getTimeline(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getTimeline(e);return t.ok&&(this.ctx.data.user.applySocialTimeline(t.data.Events),this.ctx.emitter.emit("social:timelineLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Oc="TimedBoost";function Bc(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var Ti=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Oc,t.data),this.ctx.emitter.emit("timedBoost:definitionsLoaded",t.data)),t}async getActive(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.getActive(e);return t.ok&&(this.ctx.data.user.applyTimedBoost({Active:t.data.Active??{}}),this.ctx.emitter.emit("timedBoost:activeLoaded",t.data)),t}async getActiveWindows(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.getActiveWindows(e);return t.ok&&this.ctx.emitter.emit("timedBoost:activeWindowsLoaded",t.data),t}async activate(e){let t=e.trim();if(!Bc(t))return n("client",'BoostID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),BoostID:t,RelatedEntityID:`timed_boost_activate_${t}_${P()}`},r=await this.ctx.api.timedBoost.activate(i);if(r.ok){let s=r.data;if(s.ActivatedBoost){let a=s.StackingPolicy??"Replace";this.ctx.data.user.patchActiveTimedBoost(s.ActivatedBoost,a);}this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedBoost:activated",s);}return r}async cleanupExpired(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.cleanupExpired(e);return t.ok&&(await this.getActive(),this.ctx.emitter.emit("timedBoost:expiredCleaned",void 0)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Je={Private:"Private",Public:"Public",ReadOnly:"ReadOnly",Internal:"Internal"},Lc={Client:"Client",Server:"Server",System:"System"},qc=zod.z.enum(["Client","Server","System"]),Ec=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:u.nullish(),Version:zod.z.number().nullish(),LastWriter:qc.nullish(),ExpiresAt:u.nullish()}).passthrough(),vi=zod.z.record(zod.z.string(),Ec),Vn=zod.z.object({Version:zod.z.number().nullish(),Private:vi.nullish(),Public:vi.nullish(),ReadOnly:vi.nullish()}),ls=zod.z.object({UserID:zod.z.string().nullish(),Version:zod.z.number().nullish(),Public:vi.nullish()}),us=zod.z.object({ServerTimeUtc:u.nullish(),Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:u.nullish()}),Gc=zod.z.object({Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:u.nullish()}),_n=zod.z.object({ServerTimeUtc:u.nullish(),Results:zod.z.array(Gc).nullish()}),Wn=zod.z.object({ServerTimeUtc:u.nullish(),DeletedCount:zod.z.number().nullish()}),Qn=zod.z.object({Results:zod.z.array(ls).nullish(),NotFoundUserIDs:zod.z.array(zod.z.string()).nullish()}),Nc={String:"String",Int:"Int",Bool:"Bool",Json:"Json"},jc=zod.z.enum(["String","Int","Bool","Json"]),Fc=zod.z.object({KeyID:zod.z.string(),Bucket:zod.z.string().nullish(),ValueType:jc.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),Pi=zod.z.object({Keys:zod.z.record(zod.z.string(),Fc).nullish(),DefaultMaxValueLengthBytes:zod.z.number().nullish(),DefaultTtlSeconds:zod.z.number().nullish(),MaxKeysPerBucket:zod.z.number().nullish(),MaxTotalSizeBytes:zod.z.number().nullish(),RejectUnregisteredKeys:zod.z.boolean().nullish()}).passthrough(),Fe={GetUserCustomDataDefinitions:"GetUserCustomDataDefinitions",GetMyUserCustomData:"GetMyUserCustomData",GetPublicUserCustomDataOf:"GetPublicUserCustomDataOf",SetPrivateData:"SetPrivateData",SetPublicData:"SetPublicData",DeleteKey:"DeleteKey",BatchSet:"BatchSet",BatchDelete:"BatchDelete",BatchGetPublicUserCustomDataOf:"BatchGetPublicUserCustomDataOf"};var Vc="UserCustomData";function Kn(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var Ii=class{constructor(e){this.ctx=e;}ctx;async getUserCustomDataDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.userCustomData.getUserCustomDataDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Vc,t.data),this.ctx.emitter.emit("userCustomData:definitionsLoaded",t.data)),t}async getMyUserCustomData(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.userCustomData.getMyUserCustomData(e);return t.ok&&(this.ctx.data.user.applyUserCustomData(t.data),this.ctx.emitter.emit("userCustomData:myDataLoaded",t.data)),t}async getPublicUserCustomDataOf(e){let t=e.trim();if(!t)return n("client","TargetUserID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.TargetUserID=t;let r=await this.ctx.api.userCustomData.getPublicUserCustomDataOf(i);return r.ok&&this.ctx.emitter.emit("userCustomData:publicDataLoaded",r.data),r}async setPrivateData(e,t){return this.setData(e,t,Je.Private)}async setPublicData(e,t){return this.setData(e,t,Je.Public)}async setData(e,t,i){let r=e.trim();if(!Kn(r))return n("client",'KeyID is required and must not contain "." or "$".');if(t==null)return n("client","Value is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),KeyID:r,Value:t},p=await(i===Je.Private?this.ctx.api.userCustomData.setPrivateData(s):this.ctx.api.userCustomData.setPublicData(s));if(p.ok){let D=p.data;this.ctx.data.user.patchUserCustomDataKey(i,D.KeyID,t,D.Version??0,D.ExpiresAt),this.ctx.emitter.emit(i===Je.Private?"userCustomData:privateDataSet":"userCustomData:publicDataSet",D);}return p}async deleteKey(e,t){let i=e.trim();if(!Kn(i))return n("client",'KeyID is required and must not contain "." or "$".');if(t!==Je.Private&&t!==Je.Public)return n("client","Only Private or Public keys can be deleted.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),KeyID:i,Bucket:t},s=await this.ctx.api.userCustomData.deleteKey(r);return s.ok&&(this.ctx.data.user.removeUserCustomDataKey(t,i),this.ctx.emitter.emit("userCustomData:keyDeleted",void 0)),s}async batchSet(e){if(!e.length)return n("client","At least one item is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BatchSetItems:e},i=await this.ctx.api.userCustomData.batchSet(t);if(i.ok){for(let r of i.data.Results??[]){let s=r.Bucket??Je.Private,a=e.find(p=>p.Bucket===s&&p.KeyID===r.KeyID);a&&this.ctx.data.user.patchUserCustomDataKey(s,r.KeyID,a.Value,r.Version??0,r.ExpiresAt);}this.ctx.emitter.emit("userCustomData:batchSet",i.data);}return i}async batchDelete(e){if(!e.length)return n("client","At least one item is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BatchDeleteItems:e},i=await this.ctx.api.userCustomData.batchDelete(t);if(i.ok){for(let r of e)this.ctx.data.user.removeUserCustomDataKey(r.Bucket,r.KeyID.trim());this.ctx.emitter.emit("userCustomData:batchDeleted",i.data);}return i}async batchGetPublicUserCustomDataOf(e){if(!e.length)return n("client","At least one target user id is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.TargetUserIDs=e;let i=await this.ctx.api.userCustomData.batchGetPublicUserCustomDataOf(t);return i.ok&&this.ctx.emitter.emit("userCustomData:batchPublicDataLoaded",i.data),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var _c="TitleCustomDataDefinitions",Hn=50;function Wc(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}function cs(o){if(o.ExpiresAt==null)return false;let e=Date.parse(o.ExpiresAt);return !Number.isNaN(e)&&e<=Date.now()}function Qc(o){let e={};for(let[t,i]of Object.entries(o))cs(i)||(e[t]=i);return e}var ki=class{constructor(e){this.ctx=e;}ctx;lastRuntimeVersion=null;runtimeCache={};async getTitleCustomDataDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.titleCustomData.getTitleCustomDataDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(_c,t.data),this.ctx.emitter.emit("titleCustomData:definitionsLoaded",t.data)),t}async getPublicTitleData(e=true){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&this.lastRuntimeVersion!=null&&(t.KnownRuntimeVersion=this.lastRuntimeVersion);let i=await this.ctx.api.titleCustomData.getPublicTitleData(t);return i.ok&&this.absorb(i.data),i}async getPublicTitleDataKeys(e){let t=e.map(s=>s.trim()).filter(s=>s.length>0);if(!t.length)return n("client","At least one KeyID is required.");if(t.some(s=>!Wc(s)))return n("client",'KeyID must not contain "." or "$".');if(t.length>Hn)return n("client",`At most ${Hn} keys per call \u2014 request them in chunks.`);let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.KeyIDs=t;let r=await this.ctx.api.titleCustomData.getPublicTitleDataKeys(i);return r.ok&&this.ctx.emitter.emit("titleCustomData:publicDataLoaded",r.data),r}getValue(e){let t=this.runtimeCache[e];if(t?.Value!=null&&!cs(t))return t.Value;let i=this.staticCache[e];if(i?.Value!=null&&!cs(i))return i.Value}get runtimeVersion(){return this.lastRuntimeVersion}staticCache={};absorb(e){e.Static&&(this.staticCache=e.Static),e.NotModified?(this.runtimeCache=Qc(this.runtimeCache),e.Runtime=this.runtimeCache):e.Runtime&&(this.runtimeCache=e.Runtime),e.RuntimeVersion!=null&&(this.lastRuntimeVersion=e.RuntimeVersion),this.ctx.emitter.emit("titleCustomData:publicDataLoaded",e);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Mi=class{constructor(e){this.ctx=e;}ctx;async getTitlePublicConfiguration(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.title.getTitlePublicConfiguration(e);return t.ok&&(this.ctx.data.config.applyTitlePublicConfiguration(t.data),this.ctx.emitter.emit("title:publicConfigurationReceived",t.data)),t}async getCurrencyDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.title.getCurrencyDefinitions(e);return t.ok&&(this.ctx.data.config.applyCurrencyDefinitions(t.data),this.ctx.emitter.emit("title:currencyDefinitionsReceived",t.data)),t}async getItemDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.title.getItemDefinitions(e);return t.ok&&(this.ctx.data.config.applyItemDefinitions(t.data),this.ctx.emitter.emit("title:itemDefinitionsReceived",t.data)),t}async getServerTime(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.title.getServerTime(e);return t.ok&&this.ctx.emitter.emit("title:serverTimeReceived",t.data),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Kc=15,Hc="GameLoop",$c="BoardDefinition",wi=class{constructor(e){this.ctx=e;}ctx;get itemDefs(){return this.ctx.data.config.itemDefinitions}async getGameLoops(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.gameLoop.getGameLoops(e);return t.ok&&(this.ctx.data.config.patchSection(Hc,t.data),this.ctx.emitter.emit("gameLoop:gameLoopsLoaded",t.data)),t}async getBoardDefinition(e=false){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");let i=await this.ctx.api.gameLoop.getBoardDefinition(t,e);return i.ok&&(this.ctx.data.config.patchSection($c,i.data),this.ctx.emitter.emit("gameLoop:boardDefinitionLoaded",i.data)),i}async getBoardDefinitionForLevel(e,t=false){if(e<=0)return n("client","stageLevel must be > 0.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.StageLevel=e;let r=await this.ctx.api.gameLoop.getBoardDefinitionForLevel(i,t);return r.ok&&this.ctx.emitter.emit("gameLoop:boardDefinitionForLevelLoaded",r.data),r}async getUserBoardState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.gameLoop.getUserBoardState(e);return t.ok&&(this.ctx.data.user.applyBoardState(t.data),this.ctx.emitter.emit("gameLoop:boardStateLoaded",t.data)),t}async boardLoopRoll(e=1){if(e<1)return n("client","rollMultiplier must be >= 1.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),RollMultiplier:e,RelatedEntityID:`roll_${t.userID}_${P()}`},r=await this.ctx.api.gameLoop.boardLoopRoll(i);if(r.ok){let s=r.data,a=Ln(new Date,Kc);this.ctx.data.user.patchBoardState(p=>{p.Position=s.NewPosition,p.CyclesCompleted=(p.CyclesCompleted??0)+(s.CyclesCompletedDelta??0),p.LastRollAtUtc=new Date().toISOString(),s.ActionRequired&&s.ActionData?p.Pending={Type:s.ActionRequired,TargetUserID:s.ActionData.TargetUserID,TargetPublicData:s.ActionData.PublicData,TargetBuildingStates:s.ActionData.TargetBuildingStates??void 0,TargetHasShield:s.ActionData.TargetHasShield??void 0,RollMultiplier:s.UsedMultiplier??1,ExpiresAtUtc:a}:s.SpecialModeOffer&&(p.Pending={Type:"SPECIAL",RollMultiplier:s.UsedMultiplier??1,ExpiresAtUtc:a,Special:{ModeID:s.SpecialModeOffer.ModeID??void 0,Choices:s.SpecialModeOffer.Choices??void 0}});}),s.Operation&&this.ctx.data.user.applyResourceOperation(s.Operation,this.itemDefs),s.ActionRequired==="RAID"&&await this.getUserBoardState(),this.ctx.emitter.emit("gameLoop:boardRolled",s);}return r}async boardLoopAttack(e=-1){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`attack_${t.userID}_${P()}`},r=await this.ctx.api.gameLoop.boardLoopAttack(i);if(r.ok){let s=r.data;this.ctx.data.user.clearBoardPending(),s.IsBotTarget&&s.Operation?this.ctx.data.user.applyResourceOperation(s.Operation,this.itemDefs):!s.IsBotTarget&&s.DualResult?.FromResult&&this.ctx.data.user.applyResourceOperation(s.DualResult.FromResult,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardAttacked",s);}else await this.getUserBoardState();return r}async boardLoopRaid(e,t){if(e<0||e>11)return n("client","digIndex must be between 0 and 11.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),DigIndex:e,RelatedEntityID:t??`raid_${i.userID}_${P()}`},s=await this.ctx.api.gameLoop.boardLoopRaid(r);if(s.ok){let a=s.data;a.Status==="CONTINUE"?this.ctx.data.user.patchBoardPendingRaidLayout(a.RaidLayout,a.OpenedIndex??-1):(this.ctx.data.user.clearBoardPending(),this.applyRaidResources(a)),this.ctx.emitter.emit("gameLoop:boardRaided",a);}else await this.getUserBoardState();return s}async boardLoopRaidFast(e){if(!e.length)return n("client","digIndices must not be empty.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),DigIndices:e,RelatedEntityID:`raidfast_${t.userID}_${P()}`},r=await this.ctx.api.gameLoop.boardLoopRaidFast(i);if(r.ok){let s=r.data;s.Status!=="CONTINUE"&&(this.ctx.data.user.clearBoardPending(),this.applyRaidResources(s)),this.ctx.emitter.emit("gameLoop:boardRaidedFast",s);}else await this.getUserBoardState();return r}async boardLoopBuild(e){if(e<0)return n("client","buildingIndex must be >= 0.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`build_${t.userID}_${e}_${P()}`},r=await this.ctx.api.gameLoop.boardLoopBuild(i);if(r.ok){let s=r.data;s.StageComplete?this.ctx.data.user.patchBoardState(a=>{a.StageLevel=(a.StageLevel??1)+1,a.Position=0,a.Pending=null,a.BuildingStates=null;}):this.ctx.data.user.patchBoardBuilding(s.BuiltIndex,a=>{s.NewLevel!=null&&(a.Level=s.NewLevel),a.IsDamaged=false,s.MaxLevelRewardClaimed&&(a.MaxLevelRewardClaimed=true);}),s.Operation&&this.ctx.data.user.applyResourceOperation(s.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardBuilt",s);}return r}async boardSpecialChoose(e){if(!e)return n("client","choiceID must not be empty.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),ChoiceID:e,RelatedEntityID:`special_choose_${t.userID}_${P()}`},r=await this.ctx.api.gameLoop.boardSpecialChoose(i);if(r.ok){let s=r.data;s.Mode==="Instant"||s.Mode===0?this.ctx.data.user.clearBoardPending():this.ctx.data.user.patchBoardSpecialPending(p=>{p.ChoiceID=e,p.ChosenMode=s.Mode??"Timed",p.StartedAtUtc=s.StartedAtUtc??null,p.DurationSeconds=s.DurationSeconds??null,p.AdViewsUsed=0;}),s.Operation&&this.ctx.data.user.applyResourceOperation(s.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialChose",s);}return r}async boardSpecialApplyMultiplier(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:e??`special_ad_${t.userID}_${P()}`},r=await this.ctx.api.gameLoop.boardSpecialApplyMultiplier(i);if(r.ok){let s=r.data;this.ctx.data.user.patchBoardSpecialPending(a=>{a.AdViewsUsed=s.AdViewsUsed??0,a.AccumulatedMultiplier=s.AccumulatedMultiplier??0;}),this.ctx.emitter.emit("gameLoop:boardSpecialApplyMultiplier",s);}return r}async boardSpecialClaim(){let e=this.ctx.auth.context;if(!e)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:`special_claim_${e.userID}_${P()}`},i=await this.ctx.api.gameLoop.boardSpecialClaim(t);if(i.ok){let r=i.data;this.ctx.data.user.clearBoardPending(),r.Operation&&this.ctx.data.user.applyResourceOperation(r.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialClaimed",r);}return i}async getCommunityChestState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.gameLoop.getCommunityChestState(e);return t.ok&&(this.ctx.data.user.applyCommunityChestUserState(t.data.UserState??null),this.ctx.emitter.emit("gameLoop:communityChestStateLoaded",t.data)),t}async joinOrCreateCommunityChest(){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let e={...this.ctx.buildAuthedBaseRequest()},t=await this.ctx.api.gameLoop.joinOrCreateCommunityChest(e);if(t.ok){let i=t.data.Group;i?.GroupID&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:i.GroupID,ActiveRoundIndex:i.RoundIndex??void 0}),this.ctx.emitter.emit("gameLoop:communityChestJoined",t.data);}return t}async claimCommunityChestMilestone(e,t){if(!e)return n("client","milestoneID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),MilestoneID:e,GroupID:t},r=await this.ctx.api.gameLoop.claimCommunityChestMilestone(i);return r.ok&&(r.data.Resources&&this.ctx.data.user.applyResourceOperation(r.data.Resources,this.itemDefs),this.ctx.emitter.emit("gameLoop:communityChestMilestoneClaimed",r.data)),r}async claimCommunityChestGrandPrize(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.gameLoop.claimCommunityChestGrandPrize(t);return i.ok&&(i.data.Resources&&this.ctx.data.user.applyResourceOperation(i.data.Resources,this.itemDefs),this.ctx.emitter.emit("gameLoop:communityChestGrandPrizeClaimed",i.data)),i}async leaveCommunityChest(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.gameLoop.leaveCommunityChest(t);return i.ok&&(i.data.Success&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:void 0,ActiveRoundIndex:-1}),this.ctx.emitter.emit("gameLoop:communityChestLeft",i.data)),i}applyRaidResources(e){e.Operation?this.ctx.data.user.applyResourceOperation(e.Operation,this.itemDefs):e.DualResult?.FromResult&&this.ctx.data.user.applyResourceOperation(e.DualResult.FromResult,this.itemDefs);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ai=class{constructor(e){this.ctx=e;}ctx;async execute(e,t,i,r){let s=e.trim();if(!s)return n("client","FunctionName is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),FunctionName:s,FunctionParameter:t,RevisionSelection:i,SpecificRevision:r},p=await this.ctx.api.cloudCode.execute(a);return p.ok&&this.ctx.emitter.emit("cloudCode:executed",p.data),p}};var $n=zod.z.object({ServerTimeUtc:u,SourceType:St,SourceID:zod.z.string(),TargetType:St,TargetID:zod.z.string(),SourceSpent:w,FeeAmount:w,RateApplied:L,TargetCredited:w}),Zn=zod.z.object({ServerTimeUtc:u,SourceType:St,SourceID:zod.z.string(),TargetType:St,TargetID:zod.z.string(),SourceSpent:L,FeeAmount:L,RateApplied:L,TargetCredited:L}),Ui={Convert:"Convert",CryptoConvert:"CryptoConvert"},Zc={Active:"Active",Hidden:"Hidden",Deprecated:"Deprecated",Maintenance:"Maintenance"},Jn=zod.z.enum(["Active","Hidden","Deprecated","Maintenance"]),Jc={Automatic:"Automatic",Manual:"Manual"},Yc=zod.z.enum(["Automatic","Manual"]),Xc=zod.z.object({ValueInUSD:L.nullish(),ValueInUSDUpdatedAt:u.nullish(),InitialDeposit:zod.z.number().nullish(),MinBalance:zod.z.number().nullish(),MaxBalance:zod.z.number().nullish(),DailyEarnLimit:zod.z.number().nullish(),DailySpendLimit:zod.z.number().nullish()}).passthrough(),ep=zod.z.object({Rate:zod.z.number().nullish(),Max:zod.z.number().nullish(),Period:zod.z.number().nullish()}).passthrough(),tp=zod.z.object({IsTradable:zod.z.boolean().nullish(),IsPurchasable:zod.z.boolean().nullish(),IsRefundable:zod.z.boolean().nullish()}).passthrough(),ip=zod.z.object({TargetCurrencyType:St.nullish(),TargetCurrencyID:zod.z.string(),Rate:L.nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish(),DailyLimit:zod.z.number().nullish()}).passthrough(),Yn=zod.z.object({Enabled:zod.z.boolean().nullish(),RateMode:Yc.nullish(),FeePercent:L.nullish(),Targets:zod.z.array(ip).nullish()}).passthrough(),Xn=zod.z.object({CreatedAt:u.nullish(),UpdatedAt:u.nullish()}).passthrough(),rp=zod.z.object({CurrencyID:zod.z.string(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Economy:Xc.nullish(),Recharge:ep.nullish(),Conversion:Yn.nullish(),Permissions:tp.nullish(),Audit:Xn.nullish(),Status:Jn.nullish()}).passthrough(),sp=zod.z.object({NetworkID:zod.z.string(),ContractAddress:zod.z.string().nullish(),Decimals:zod.z.number().nullish(),MinDeposit:L.nullish(),MinWithdraw:L.nullish(),WithdrawFee:L.nullish(),DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish()}).passthrough(),np=zod.z.object({DailyWithdrawUsd:L.nullish(),MonthlyWithdrawUsd:L.nullish(),KycRequiredAboveUsd:L.nullish()}).passthrough(),op=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),SpendableInGame:zod.z.boolean().nullish(),ConvertibleToVirtual:zod.z.boolean().nullish()}).passthrough(),ps=zod.z.object({CurrencyID:zod.z.string(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),DisplayDecimals:zod.z.number().nullish(),ValueInUSD:L.nullish(),ValueInUSDUpdatedAt:u.nullish(),DeveloperDepositSharePercent:L.nullish(),CommunityMarketingDepositSharePercent:L.nullish(),WithdrawalBurnPercent:L.nullish(),Networks:zod.z.array(sp).nullish(),Limits:np.nullish(),Permissions:op.nullish(),Conversion:Yn.nullish(),Audit:Xn.nullish(),Status:Jn.nullish()}).passthrough(),Oi=zod.z.object({VirtualCurrencies:zod.z.record(zod.z.string(),rp).nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),ps).nullish()}).passthrough();var eo=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),ItemInstanceID:zod.z.string().nullish(),EquippedAt:u.nullish()}),ds=zod.z.object({CharacterID:zod.z.string(),Level:zod.z.number().nullish(),Experience:w.nullish(),Power:zod.z.number().nullish(),StatLevels:zod.z.record(zod.z.string(),zod.z.number()).nullish(),Equipment:zod.z.record(zod.z.string(),eo).nullish(),UpdatedAt:u.nullish()}).passthrough(),ap=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),lp=zod.z.object({ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Quantity:zod.z.number().nullish(),RemainingUses:zod.z.number().nullish(),Level:zod.z.number().nullish(),AcquiredAt:u,ExpiresAt:u.nullish(),EquippedSlot:ap.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(o=>o),ot=zod.z.object({ChangedInstances:zod.z.record(zod.z.string(),lp).nullish(),RemovedInstanceIDs:zod.z.array(zod.z.string()).nullish()}),to=zod.z.object({Characters:zod.z.record(zod.z.string(),ds).nullish()}),hs=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),StatID:zod.z.string(),StatLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:b.nullish()}),ms=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),NewLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:b.nullish()}),io=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),Equipment:zod.z.record(zod.z.string(),eo).nullish(),ReplacedInstanceIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:ot.nullish()}),ro=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:ot.nullish()}),up=zod.z.object({ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish()}),so=zod.z.object({ServerTimeUtc:u,Characters:zod.z.record(zod.z.string(),up).nullish(),Inventory:ot.nullish()}),fs=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),Power:zod.z.number().nullish(),Resources:b.nullish()}),no=st(fs),oo=st(ms),ao=st(hs),lo=zod.z.object({RequiredStatID:zod.z.string(),RequiredLevel:zod.z.number()}).passthrough(),uo=zod.z.object({StatID:zod.z.string(),TypeID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),MaxLevel:zod.z.number().nullish(),Weight:zod.z.number().nullish(),BaseCostResource:Z.nullish(),CostScalingFactor:zod.z.number().nullish(),BaseStatValue:zod.z.number().nullish(),StatScalingFactor:zod.z.number().nullish(),CharacterLevelScalingFactor:zod.z.number().nullish(),Requirements:zod.z.array(lo).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),co=zod.z.object({Level:zod.z.number().nullish(),UpgradeCost:Z.nullish(),GlobalStatMultiplier:zod.z.number().nullish(),StatMaxLevelMultiplier:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),cp=zod.z.object({SlotID:zod.z.string(),MinCharacterLevel:zod.z.number().nullish(),StatRequirements:zod.z.array(lo).nullish(),AllowedRarityIDs:zod.z.array(zod.z.string()).nullish(),AllowedItemTags:zod.z.array(zod.z.string()).nullish(),MinItemLevel:zod.z.number().nullish(),MaxItemLevel:zod.z.number().nullish()}).passthrough(),po=zod.z.object({Slots:zod.z.record(zod.z.string(),cp).nullish()}).passthrough(),pp=zod.z.object({DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Lore:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),dp=zod.z.object({ClassID:zod.z.string().nullish(),RarityID:zod.z.string().nullish(),Tags:zod.z.array(zod.z.string()).nullish()}).passthrough(),hp=zod.z.object({UnlockedByDefault:zod.z.boolean().nullish(),Cost:Z.nullish()}).passthrough(),mp=zod.z.object({Stats:te.nullish(),Levels:te.nullish(),Equipment:te.nullish()}).passthrough(),fp=zod.z.object({CharacterID:zod.z.string(),Identity:pp.nullish(),Classification:dp.nullish(),Unlock:hp.nullish(),Presets:mp.nullish(),Equipment:po.nullish(),Stats:zod.z.record(zod.z.string(),uo).nullish(),Levels:zod.z.record(zod.z.string(),co).nullish()}).passthrough(),gp=zod.z.object({Stats:zod.z.record(zod.z.string(),uo).nullish()}).passthrough(),Rp=zod.z.object({Levels:zod.z.record(zod.z.string(),co).nullish()}).passthrough(),yp=zod.z.object({Equipment:po.nullish()}).passthrough(),Cp=zod.z.object({Stats:zod.z.record(zod.z.string(),gp).nullish(),Levels:zod.z.record(zod.z.string(),Rp).nullish(),Equipment:zod.z.record(zod.z.string(),yp).nullish()}).passthrough(),Bi=zod.z.object({Definitions:zod.z.record(zod.z.string(),fp).nullish(),Presets:Cp.nullish()}).passthrough(),ke={GetCharacterDefinitions:"GetCharacterDefinitions",GetUserCharacters:"GetUserCharacters",UnlockCharacter:"UnlockCharacter",UpgradeStatLevel:"UpgradeStatLevel",UpgradeCharacterLevel:"UpgradeCharacterLevel",EquipItems:"EquipItems",UnequipItems:"UnequipItems",UnequipAllCharacters:"UnequipAllCharacters",UnlockCharactersBatch:"UnlockCharactersBatch",UpgradeCharacterLevelsBatch:"UpgradeCharacterLevelsBatch",UpgradeStatLevelsBatch:"UpgradeStatLevelsBatch"};var Sp={EVM:"EVM",Solana:"Solana"},xp=zod.z.enum(["EVM","Solana"]),Dp={AutoLinkedFromTransaction:"AutoLinkedFromTransaction",SignatureVerified:"SignatureVerified",ManuallyLinked:"ManuallyLinked"},bp=zod.z.enum(["AutoLinkedFromTransaction","SignatureVerified","ManuallyLinked"]),zp={Token:"Token",Nft:"Nft"},ho=zod.z.enum(["Token","Nft"]),Tp={NotRequested:"NotRequested",Pending:"Pending",Verified:"Verified",Rejected:"Rejected",Expired:"Expired"},vp=zod.z.enum(["NotRequested","Pending","Verified","Rejected","Expired"]),Pp={None:"None",Tier1:"Tier1",Tier2:"Tier2",Tier3:"Tier3"},Ip=zod.z.enum(["None","Tier1","Tier2","Tier3"]),kp={Pending:"Pending",Completed:"Completed",Failed:"Failed",Expired:"Expired",Abandoned:"Abandoned"},gs=zod.z.enum(["Pending","Completed","Failed","Expired","Abandoned"]),mo={GameTopUp:"game_topup",CommunityReward:"community_reward"};function Li(o){let e=o?.trim();return e||mo.GameTopUp}var Mp={UsersCryptoWallet:"UsersCryptoWallet",Game:"Game"},fo=zod.z.enum(["UsersCryptoWallet","Game"]),wp=zod.z.object({ContractAddress:zod.z.string().nullish(),ItemCatalogID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish()}).passthrough(),go=zod.z.object({Ios:zod.z.boolean().nullish(),Android:zod.z.boolean().nullish(),Web:zod.z.boolean().nullish()}).passthrough(),Ap=zod.z.object({NetworkID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Type:xp.nullish(),ChainID:zod.z.number().nullish(),ChainTicker:zod.z.string().nullish(),RewardPoolAddress:zod.z.string().nullish(),VaultDepositAddress:zod.z.string().nullish(),ChainConfigVersion:zod.z.number().nullish(),RequiredConfirmations:zod.z.number().nullish(),DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),NftDepositsEnabled:zod.z.boolean().nullish(),NftWithdrawalsEnabled:zod.z.boolean().nullish(),PlatformOverrides:go.nullish(),NftCollections:zod.z.array(wp).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Up=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),NftDepositsEnabled:zod.z.boolean().nullish(),NftWithdrawalsEnabled:zod.z.boolean().nullish(),PlatformOverrides:go.nullish()}).passthrough(),Op=zod.z.object({MinAccountAgeDays:zod.z.number().nullish(),MultiAccountCheckEnabled:zod.z.boolean().nullish(),BanOnSharedWithdrawalAddress:zod.z.boolean().nullish(),PendingWithdrawalTtlHours:zod.z.number().nullish()}).passthrough();var Bp=zod.z.enum(["OnChain","Combined"]),Lp=zod.z.object({Enabled:zod.z.boolean().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),MinBalance:L.nullish(),BalanceSource:Bp.nullish(),DenyMessage:zod.z.string().nullish()}).passthrough(),qp=zod.z.object({Enabled:zod.z.boolean().nullish(),TokenGates:zod.z.array(Lp).nullish(),WalletConnectProjectId:zod.z.string().nullish()}).passthrough(),Rs=zod.z.object({SystemState:Up.nullish(),Networks:zod.z.record(zod.z.string(),Ap).nullish(),AccountSafety:Op.nullish(),WalletLogin:qp.nullish()}).passthrough(),Ep=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),LinkedAt:u.nullish(),LastUsedAt:u.nullish(),LinkType:bp.nullish(),IsSignatureVerified:zod.z.boolean().nullish()}).passthrough(),Ro=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Type:ho.nullish(),NetworkID:zod.z.string().nullish(),AssetID:zod.z.string().nullish(),Amount:L.nullish(),CreatedAt:u.nullish(),ExpiresAt:u.nullish()}).passthrough(),Gp=zod.z.object({Status:vp.nullish(),Tier:Ip.nullish(),VerifiedAt:u.nullish(),ExpiresAt:u.nullish(),RejectedAt:u.nullish(),ProviderReference:zod.z.string().nullish(),RejectionReason:zod.z.string().nullish()}).passthrough(),Np=zod.z.object({CurrencyID:zod.z.string().nullish(),Deposits:zod.z.number().nullish(),DepositsVolumeNative:L.nullish(),DepositsVolumeUsd:L.nullish(),Withdrawals:zod.z.number().nullish(),WithdrawalsVolumeNative:L.nullish(),WithdrawalsVolumeUsd:L.nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),FirstDepositAt:u.nullish(),LastDepositAt:u.nullish(),FirstWithdrawalAt:u.nullish(),LastWithdrawalAt:u.nullish()}).passthrough(),jp=zod.z.object({TotalDeposits:zod.z.number().nullish(),TotalWithdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),TotalDepositsVolumeUsd:L.nullish(),TotalWithdrawalsVolumeUsd:L.nullish(),PerCurrency:zod.z.record(zod.z.string(),Np).nullish()}).passthrough(),Fp=zod.z.object({NetworkID:zod.z.string().nullish(),ItemCatalogID:zod.z.string().nullish(),Deposits:zod.z.number().nullish(),Withdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),FirstDepositAt:u.nullish(),LastDepositAt:u.nullish(),FirstWithdrawalAt:u.nullish(),LastWithdrawalAt:u.nullish()}).passthrough(),Vp=zod.z.object({TotalDeposits:zod.z.number().nullish(),TotalWithdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),PerCollection:zod.z.record(zod.z.string(),Fp).nullish()}).passthrough(),_p=zod.z.object({Tokens:jp.nullish(),Nfts:Vp.nullish()}).passthrough(),Wp=zod.z.object({CurrencyID:zod.z.string().nullish(),Balance:L.nullish(),MinBalance:L.nullish()}).passthrough(),Qp=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),CheckedAt:u.nullish(),LoggedInAt:u.nullish(),GatePassed:zod.z.boolean().nullish(),GatedBalances:zod.z.array(Wp).nullish()}).passthrough(),Kp=zod.z.object({Version:zod.z.number().nullish(),Stats:_p.nullish(),LinkedWallets:zod.z.record(zod.z.string(),Ep).nullish(),LastWalletLogin:Qp.nullish(),PendingWithdrawals:zod.z.array(Ro).nullish(),Kyc:Gp.nullish(),FirstActivityAt:u.nullish(),LastActivityAt:u.nullish(),IsFlagged:zod.z.boolean().nullish(),FlagReason:zod.z.string().nullish()}).passthrough(),Hp=zod.z.object({CurrencyID:zod.z.string(),AmountDelta:L,FrozenDelta:L,UpdatedAt:u}).passthrough(),qi=zod.z.object({CryptoBalances:zod.z.record(zod.z.string(),Hp).nullish(),PendingAdded:Ro.nullish(),PendingRemovedIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),$p=zod.z.object({Amount:L,Frozen:L,CreatedAt:u.nullish(),UpdatedAt:u.nullish()}).passthrough().transform(o=>o),Zp=zod.z.object({ID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CreatedAt:u.nullish(),UpdatedAt:u.nullish(),UserID:zod.z.string().nullish(),TransactionHash:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ChainType:zod.z.string().nullish(),ChainID:zod.z.number().nullish(),Direction:fo.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:L.nullish(),Status:gs.nullish(),SignatureData:zod.z.string().nullish(),CompletedAt:u.nullish(),ExpiresAt:u.nullish(),FailReason:zod.z.string().nullish(),Reason:zod.z.string().nullish(),Category:zod.z.string().nullish(),TokenID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountUsd:L.nullish(),NetPayoutAmount:L.nullish()}).passthrough(),Jp=zod.z.object({ID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CreatedAt:u.nullish(),UpdatedAt:u.nullish(),UserID:zod.z.string().nullish(),TransactionHash:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ChainType:zod.z.string().nullish(),ChainID:zod.z.number().nullish(),Direction:fo.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:L.nullish(),Status:gs.nullish(),SignatureData:zod.z.string().nullish(),CompletedAt:u.nullish(),ExpiresAt:u.nullish(),FailReason:zod.z.string().nullish(),Reason:zod.z.string().nullish(),Category:zod.z.string().nullish(),NFTID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),SkinID:zod.z.string().nullish()}).passthrough(),yo=zod.z.object({To:zod.z.string().nullish(),Amount:zod.z.union([zod.z.string(),zod.z.number()]).nullish()}).passthrough(),ys=zod.z.object({TokenAddress:zod.z.string().nullish(),WalletAddress:zod.z.string().nullish(),Amount:zod.z.string().nullish(),BurnAmount:zod.z.string().nullish(),TokenId:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),ContractAddress:zod.z.string().nullish(),UserID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),Category:zod.z.string().nullish(),Deadline:zod.z.string().nullish(),SignatureEpoch:zod.z.string().nullish(),Splits:zod.z.array(yo).nullish(),Signature:zod.z.string().nullish()}).passthrough(),Cs=zod.z.object({Mint:zod.z.string().nullish(),WalletAddress:zod.z.string().nullish(),Amount:zod.z.string().nullish(),BurnAmount:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),ExpiresAt:zod.z.string().nullish(),ProgramID:zod.z.string().nullish(),SignatureEpoch:zod.z.string().nullish(),Domain:zod.z.string().nullish(),Splits:zod.z.array(yo).nullish(),SignatureHex:zod.z.string().nullish(),SigIxIndex:zod.z.number().nullish(),Ed25519PublicKey:zod.z.string().nullish(),Ed25519Message:zod.z.string().nullish(),UserID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),Category:zod.z.string().nullish()}).passthrough(),Co=zod.z.object({Blockchain:Rs.nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),ps).nullish()}).passthrough(),So=zod.z.object({State:Kp.nullish(),CryptoBalances:zod.z.record(zod.z.string(),$p).nullish()}).passthrough(),xo=zod.z.object({ServerTimeUtc:u.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:L.nullish(),AmountUsd:L.nullish(),StateDelta:qi.nullish()}).passthrough(),Do=zod.z.object({ServerTimeUtc:u.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),NftTokenID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),Resources:b.nullish(),Inventory:ot.nullish()}).passthrough(),bo=zod.z.object({ServerTimeUtc:u.nullish(),TitleTransactionID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:L.nullish(),NetAmountNative:L.nullish(),BurnAmountNative:L.nullish(),AmountUsd:L.nullish(),ExpiresAt:u.nullish(),EvmSignature:ys.nullish(),SolanaSignature:Cs.nullish(),StateDelta:qi.nullish()}).passthrough(),zo=zod.z.object({ServerTimeUtc:u.nullish(),TitleTransactionID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),NftTokenID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),ExpiresAt:u.nullish(),Resources:b.nullish(),EvmSignature:ys.nullish(),SolanaSignature:Cs.nullish(),StateDelta:qi.nullish(),Inventory:ot.nullish()}).passthrough(),To=zod.z.object({TokenTransactions:zod.z.array(Zp).nullish(),NFTTransactions:zod.z.array(Jp).nullish()}).passthrough(),Ss=zod.z.object({ServerTimeUtc:u.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:L.nullish(),AmountUsd:L.nullish(),Target:zod.z.string().nullish()}).passthrough(),vo=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Kind:ho.nullish(),EvmSignature:ys.nullish(),SolanaSignature:Cs.nullish()}).passthrough(),Po=zod.z.object({TitleTransactionID:zod.z.string().nullish(),OnChainTxHash:zod.z.string().nullish(),Status:gs.nullish(),StateDelta:qi.nullish()}).passthrough(),Me={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",DepositToken:"DepositToken",DepositNFT:"DepositNFT",RequestTokenWithdrawal:"RequestTokenWithdrawal",RequestNFTWithdrawal:"RequestNFTWithdrawal",GetTransactionHistory:"GetTransactionHistory",RetryWithdrawal:"RetryWithdrawal",ConfirmWithdrawal:"ConfirmWithdrawal",DonateToDeveloper:"DonateToDeveloper",DonateToUsersPool:"DonateToUsersPool"};var Yp="Blockchain",Ei=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.blockchain.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Yp,t.data.Blockchain),this.ctx.emitter.emit("blockchain:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.blockchain.getUserState(e);return t.ok&&(this.ctx.data.user.applyBlockchainState(t.data.State??null,t.data.CryptoBalances),this.ctx.emitter.emit("blockchain:userStateLoaded",t.data)),t}async depositToken(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.NetworkID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.depositToken(i);return r.ok&&r.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(r.data.CurrencyID,new Ht__default.default(r.data.AmountNative??0),r.data.ServerTimeUtc??void 0),this.ctx.emitter.emit("blockchain:tokenDeposited",r.data)),r}async depositNFT(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.NetworkID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.depositNFT(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("blockchain:nftDeposited",r.data)),r}async requestTokenWithdrawal(e,t,i,r,s){if(!e)return n("client","CurrencyID is required.");if(!t)return n("client","NetworkID is required.");if(!i)return n("client","WalletAddress is required.");if(!r)return n("client","Amount is required.");let a=this.baseRequest();if(!a)return n("unauthorized","Not logged in.");a.CurrencyID=e,a.NetworkID=t,a.WalletAddress=i,a.Amount=r,a.Category=Li(s);let p=await this.ctx.api.blockchain.requestTokenWithdrawal(a);return p.ok&&p.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(p.data.CurrencyID,new Ht__default.default(p.data.AmountNative??0).negated(),p.data.ServerTimeUtc??void 0),this.ctx.emitter.emit("blockchain:tokenWithdrawalRequested",p.data)),p}async requestNFTWithdrawal(e,t,i,r,s,a,p){if(!e)return n("client","ItemID is required.");if(!t)return n("client","NetworkID is required.");if(!i)return n("client","WalletAddress is required.");if(!r)return n("client","Amount is required.");let D=this.baseRequest();if(!D)return n("unauthorized","Not logged in.");D.ItemID=e,D.NetworkID=t,D.WalletAddress=i,D.Amount=r,D.Category=Li(s),a!==void 0&&(D.Level=a),p&&(D.ItemInstanceID=p);let B=await this.ctx.api.blockchain.requestNFTWithdrawal(D);return B.ok&&(this.ctx.data.user.applyResourceOperation(B.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("blockchain:nftWithdrawalRequested",B.data)),B}async getTransactionHistory(e=50){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Amount=String(e);let i=await this.ctx.api.blockchain.getTransactionHistory(t);return i.ok&&this.ctx.emitter.emit("blockchain:transactionHistoryLoaded",i.data),i}async retryWithdrawal(e){if(!e)return n("client","TitleTransactionID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.TitleTransactionID=e;let i=await this.ctx.api.blockchain.retryWithdrawal(t);return i.ok&&this.ctx.emitter.emit("blockchain:withdrawalRetried",i.data),i}async confirmWithdrawal(e,t){if(!e)return n("client","TitleTransactionID is required.");if(!t)return n("client","On-chain TransactionHash is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.TitleTransactionID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.confirmWithdrawal(i);return r.ok&&this.ctx.emitter.emit("blockchain:withdrawalConfirmed",r.data),r}async donateToDeveloper(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.NetworkID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.donateToDeveloper(i);return r.ok&&this.ctx.emitter.emit("blockchain:donatedToDeveloper",r.data),r}async donateToUsersPool(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.NetworkID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.donateToUsersPool(i);return r.ok&&this.ctx.emitter.emit("blockchain:donatedToUsersPool",r.data),r}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var De=zod.z.object({Username:zod.z.string().nullish(),Country:zod.z.string().nullish(),AvatarUrl:zod.z.string().nullish(),Premium:zod.z.boolean().nullish(),Level:zod.z.number().nullish(),Power:zod.z.number().nullish(),BoardRank:zod.z.number().nullish()}).passthrough();var Xp={Head:"Head",Torso:"Torso",Legs:"Legs"},Gi=zod.z.enum(["Head","Torso","Legs"]),ed={Open:"Open",InProgress:"InProgress",Cancelled:"Cancelled",Completed:"Completed"},xs=zod.z.enum(["Open","InProgress","Cancelled","Completed"]),Mo=zod.z.object({AttackTarget:Gi,DefenseTarget:Gi});var td=zod.z.enum(["Hit","Critical","Block","Dodge"]),id=zod.z.object({RoundIndex:zod.z.number().nullish(),AttackerID:zod.z.string().nullish(),DefenderID:zod.z.string().nullish(),AttackZone:Gi.nullish(),DefenseZone:Gi.nullish(),HitType:td.nullish(),DamageDealt:zod.z.number().nullish(),DefenderHpRemaining:zod.z.number().nullish()}).passthrough(),rd=zod.z.object({MaxHp:zod.z.number().nullish(),CurrentHp:zod.z.number().nullish(),Damage:zod.z.number().nullish(),AttackSpeed:zod.z.number().nullish(),CritChance:zod.z.number().nullish(),CritMultiplier:zod.z.number().nullish(),Armor:zod.z.number().nullish(),DodgeChance:zod.z.number().nullish()}).passthrough(),sd=zod.z.object({ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Quantity:zod.z.number().nullish(),RemainingUses:zod.z.number().nullish(),Level:zod.z.number().nullish(),AcquiredAt:u,ExpiresAt:u.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(o=>o),ko=zod.z.object({UserID:zod.z.string().nullish(),SelectedCharacterID:zod.z.string().nullish(),SelectedCharacter:ds.nullish(),BattleStrategy:zod.z.array(Mo).nullish(),UnstackableItems:zod.z.record(zod.z.string(),sd).nullish(),Stats:rd.nullish()}).passthrough(),nd=zod.z.object({WinnerUserID:zod.z.string().nullish(),LoserUserID:zod.z.string().nullish(),Entry:me.nullish(),NetReward:me.nullish(),BattleLog:zod.z.array(id).nullish(),IsDraw:zod.z.boolean().nullish(),P1BattleProfile:ko.nullish(),P2BattleProfile:ko.nullish()}).passthrough(),wo=zod.z.object({MatchID:zod.z.string(),TitleID:zod.z.string().nullish(),RuleID:zod.z.string().nullish(),CreatedAt:u.nullish(),CreatorID:zod.z.string().nullish(),CreatorCharacterID:zod.z.string().nullish(),CreatorStrategy:zod.z.array(Mo).nullish(),TargetUserID:zod.z.string().nullish(),Entry:me.nullish(),CreationCostPaid:me.nullish(),RefundCreationCostOnCancel:zod.z.boolean().nullish(),JoinedByUserID:zod.z.string().nullish(),JoinedByCharacterID:zod.z.string().nullish(),JoinedAt:u.nullish(),Status:xs.nullish(),WinnerUserID:zod.z.string().nullish(),CompletedAt:u.nullish(),IsRewardDistributed:zod.z.boolean().nullish(),RewardDistributedAt:u.nullish()}).passthrough(),Ao=zod.z.object({Status:xs,MatchID:zod.z.string(),Entry:me.nullish(),Resources:b.nullish()}),Uo=zod.z.object({Match:wo.nullish()}),Oo=zod.z.object({MatchID:zod.z.string(),Status:xs,Resources:b.nullish()}),Bo=zod.z.object({Battle:nd.nullish(),Resources:b.nullish(),ResourcesDual:ut.nullish()}),Ds=zod.z.object({Matches:zod.z.array(wo).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}),Ke={CreateMatch:"CreateMatch",UpdateMatch:"UpdateMatch",CancelMatch:"CancelMatch",InstantBattle:"InstantBattle",SaveStrategy:"SaveStrategy",GetMyMatches:"GetMyMatches",GetAvailableMatches:"GetAvailableMatches",GetDefinitions:"GetDefinitions"};var od=zod.z.enum(["VirtualCurrency","Item","EventToken"]);var ad=zod.z.enum(["Constant","Stat","RankMultiplier","AllMight","GearFlat","GearPercent"]),ld=zod.z.object({HealthStatID:zod.z.string().nullish(),DamageStatID:zod.z.string().nullish(),ArmorStatID:zod.z.string().nullish(),AttackSpeedStatID:zod.z.string().nullish(),CritChanceStatID:zod.z.string().nullish(),CritDamageStatID:zod.z.string().nullish(),DodgeStatID:zod.z.string().nullish(),AllMightStatID:zod.z.string().nullish()}).passthrough(),ud=zod.z.object({MaxRounds:zod.z.number().nullish(),BlockDamageMultiplier:zod.z.number().nullish(),MinHitDamage:zod.z.number().nullish(),DefaultCritMultiplier:zod.z.number().nullish(),MaxCritChance:zod.z.number().nullish(),MaxDodgeChance:zod.z.number().nullish()}).passthrough(),cd=zod.z.object({Source:ad.nullish(),StatID:zod.z.string().nullish(),Value:zod.z.number().nullish(),OnePlus:zod.z.boolean().nullish()}).passthrough(),pd=zod.z.object({Coefficient:zod.z.number().nullish(),Factors:zod.z.array(cd).nullish()}).passthrough(),pt=zod.z.object({Terms:zod.z.array(pd).nullish()}).passthrough(),dd=zod.z.object({Health:pt.nullish(),Damage:pt.nullish(),Armor:pt.nullish(),AttackSpeed:pt.nullish(),CritChance:pt.nullish(),CritDamage:pt.nullish(),Dodge:pt.nullish()}).passthrough(),Lo=zod.z.object({StatMapping:ld.nullish(),Combat:ud.nullish(),Formula:dd.nullish()}).passthrough(),hd=zod.z.object({BurnRate:zod.z.number().nullish()}).passthrough(),bs=zod.z.object({Kind:od.nullish(),CurrencyID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),TokenType:jt.nullish(),EntityID:zod.z.string().nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish()}).passthrough(),qo=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(bs).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),Eo=zod.z.object({Cost:Z.nullish(),RefundCostOnCancel:zod.z.boolean().nullish(),MaxOpenMatches:zod.z.number().nullish(),Limits:ge.nullish(),AllowPrivateMatches:zod.z.boolean().nullish(),MaxMatchesPerOpponentPerDay:zod.z.number().nullish()}).passthrough(),md=zod.z.object({RuleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Economy:hd.nullish(),Entry:qo.nullish(),Creation:Eo.nullish(),Settings:Lo.nullish()}).passthrough(),fd=zod.z.object({Rules:zod.z.record(zod.z.string(),md).nullish(),Defaults:Lo.nullish(),EntryDefaults:qo.nullish(),CreationDefaults:Eo.nullish()}).passthrough(),zs=zod.z.object({InstantBattle:fd.nullish()}).passthrough(),Go=zs;var gd={Listing:"Listing",Auction:"Auction",BuyOrder:"BuyOrder",DirectTrade:"DirectTrade"},Ts=zod.z.enum(["Listing","Auction","BuyOrder","DirectTrade"]),Rd={Active:"Active",Completed:"Completed",Cancelled:"Cancelled",Declined:"Declined",Expired:"Expired"},vs=zod.z.enum(["Active","Completed","Cancelled","Declined","Expired"]),yd={Burn:"Burn",Ledger:"Ledger"},Cd=zod.z.enum(["Burn","Ledger"]),ji={Item:"Item",VirtualCurrency:"VirtualCurrency"},Ps=zod.z.enum(["Item","VirtualCurrency"]),Sd=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:w.nullish()}).passthrough(),xd=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(bs).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),Dd=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:w.nullish(),Sink:Cd.nullish(),LedgerAccountID:zod.z.string().nullish(),PerCatalogOverrides:zod.z.record(zod.z.string(),Sd).nullish(),ApplyToDirectTrades:zod.z.boolean().nullish()}).passthrough(),bd=zod.z.object({AllowedCatalogIDs:zod.z.array(zod.z.string()).nullish(),DeniedCatalogIDs:zod.z.array(zod.z.string()).nullish(),DeniedItemIDs:zod.z.array(zod.z.string()).nullish(),AllowUnstackableWithState:zod.z.boolean().nullish()}).passthrough(),zd=zod.z.object({Enabled:zod.z.boolean().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),MaxActiveListings:zod.z.number().nullish(),CreateLimits:ge.nullish(),BuyLimits:ge.nullish(),ListingFee:Z.nullish(),RefundListingFeeOnCancel:zod.z.boolean().nullish()}).passthrough(),Td=zod.z.object({Enabled:zod.z.boolean().nullish(),MinDurationHours:zod.z.number().nullish(),MaxDurationHours:zod.z.number().nullish(),AntiSnipeWindowSeconds:zod.z.number().nullish(),AntiSnipeExtensionSeconds:zod.z.number().nullish(),MaxAntiSnipeExtensions:zod.z.number().nullish(),MinBidStepPercent:zod.z.number().nullish(),MinBidStepAbsolute:w.nullish(),BidLimits:ge.nullish()}).passthrough(),vd=zod.z.object({Enabled:zod.z.boolean().nullish(),MaxActiveOrders:zod.z.number().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),CreateLimits:ge.nullish(),FillLimits:ge.nullish()}).passthrough(),Pd=zod.z.object({Enabled:zod.z.boolean().nullish(),OfferExpirationHours:zod.z.number().nullish(),MaxPendingOutgoing:zod.z.number().nullish(),AllowGifts:zod.z.boolean().nullish(),CreateLimits:ge.nullish()}).passthrough(),Id=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),Is=zod.z.object({Enabled:zod.z.boolean().nullish(),Gate:Q.nullish(),Schedule:ce.nullish(),PricePolicy:xd.nullish(),Commission:Dd.nullish(),Tradability:bd.nullish(),Listings:zd.nullish(),Auctions:Td.nullish(),BuyOrders:vd.nullish(),DirectTrades:Pd.nullish(),Matching:Id.nullish()}).passthrough(),No=zod.z.object({BidIndex:zod.z.number().nullish(),UserID:zod.z.string().nullish(),Amount:w.nullish(),Settled:zod.z.boolean().nullish(),SettledAt:u.nullish()}).passthrough(),kd=zod.z.object({BidAxisType:Nt.nullish(),BidCurrencyID:zod.z.string().nullish(),BidCatalogID:zod.z.string().nullish(),BidItemID:zod.z.string().nullish(),StartingBid:w.nullish(),CurrentBid:w.nullish(),CurrentBidderID:zod.z.string().nullish(),BidCount:zod.z.number().nullish(),ExtensionCount:zod.z.number().nullish(),PendingRefunds:zod.z.array(No).nullish()}).passthrough(),Ni=zod.z.object({LastAt:u.nullish(),DailyCount:zod.z.number().nullish(),DailyResetUtc:u.nullish()}).passthrough(),Md=zod.z.object({Create:Ni.nullish(),Buy:Ni.nullish(),Sell:Ni.nullish(),Bid:Ni.nullish()}).passthrough(),wd=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),Ad=zod.z.object({ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Quantity:zod.z.number().nullish(),RemainingUses:zod.z.number().nullish(),Level:zod.z.number().nullish(),AcquiredAt:u,ExpiresAt:u.nullish(),EquippedSlot:wd.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(o=>o),Ye=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:Ts.nullish(),Status:vs.nullish(),CreatorUserID:zod.z.string().nullish(),CreatorPublicData:De.nullish(),TargetUserID:zod.z.string().nullish(),GoodsType:Ps.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:w.nullish(),GoodsInstances:zod.z.array(Ad).nullish(),Price:me.nullish(),Auction:kd.nullish(),CreatedAt:u.nullish(),ExpiresAt:u.nullish()}).passthrough(),Ud=zod.z.object({GoodsType:Ps.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),CountsByType:zod.z.record(Ts,w).nullish(),ListingCount:w.nullish(),AuctionCount:w.nullish(),BuyOrderCount:w.nullish()}).passthrough(),jo=zod.z.object({Definitions:Is.nullish(),IsOpenNow:zod.z.boolean().nullish(),GatePassed:zod.z.boolean().nullish()}).passthrough(),ks=zod.z.object({Offers:zod.z.array(Ye).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),Fo=zod.z.object({Groups:zod.z.array(Ud).nullish()}).passthrough(),Vo=zod.z.object({Offer:Ye.nullish()}).passthrough(),Be=zod.z.object({OfferID:zod.z.string().nullish(),Status:vs.nullish(),Settlement:ut.nullish(),Resources:b.nullish(),CommissionTaken:me.nullish()}).passthrough(),Ot=zod.z.object({OfferID:zod.z.string().nullish(),Offer:Ye.nullish(),Resources:b.nullish(),Matched:zod.z.boolean().nullish(),Settlement:Be.nullish()}).passthrough(),_o=zod.z.object({OfferID:zod.z.string().nullish(),CurrentBid:w.nullish(),BidCount:zod.z.number().nullish(),ExpiresAt:u.nullish(),Resources:b.nullish()}).passthrough(),Wo=zod.z.object({MyOffers:zod.z.array(Ye).nullish(),MyLeadingBids:zod.z.array(Ye).nullish(),MyBuyOrders:zod.z.array(Ye).nullish(),IncomingTrades:zod.z.array(Ye).nullish(),OutgoingTrades:zod.z.array(Ye).nullish(),Claimables:zod.z.array(Ye).nullish(),DrainedRefunds:zod.z.array(No).nullish(),Limits:Md.nullish()}).passthrough(),Od=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:Ts.nullish(),FinalStatus:vs.nullish(),SellerUserID:zod.z.string().nullish(),BuyerUserID:zod.z.string().nullish(),GoodsType:Ps.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:w.nullish(),PricePaid:me.nullish(),CommissionTaken:me.nullish(),CompletedAt:u.nullish()}).passthrough(),Qo=zod.z.object({Entries:zod.z.array(Od).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),oe={GetDefinitions:"GetDefinitions",GetGroupedOffers:"GetGroupedOffers",GetOffersByItem:"GetOffersByItem",GetOffer:"GetOffer",GetBuyOrders:"GetBuyOrders",GetMyState:"GetMyState",GetHistory:"GetHistory",CreateListing:"CreateListing",CancelListing:"CancelListing",Buy:"Buy",MarketBuy:"MarketBuy",MarketSell:"MarketSell",CreateAuction:"CreateAuction",PlaceBid:"PlaceBid",ClaimAuction:"ClaimAuction",CreateBuyOrder:"CreateBuyOrder",CancelBuyOrder:"CancelBuyOrder",FillBuyOrder:"FillBuyOrder",CreateDirectTrade:"CreateDirectTrade",RespondDirectTrade:"RespondDirectTrade",CancelDirectTrade:"CancelDirectTrade",ClaimBack:"ClaimBack"};var Bd="Marketplace",Fi=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.marketplace.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Bd,t.data.Definitions),this.ctx.emitter.emit("marketplace:definitionsLoaded",t.data)),t}async getGroupedOffers(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.marketplace.getGroupedOffers(e);return t.ok&&this.ctx.emitter.emit("marketplace:groupedOffersLoaded",t.data),t}async getOffersByItem(e,t,i,r=20){if(!e)return n("client","ItemID is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.ItemID=e,s.OfferTypeFilter=t,s.ContinuationToken=i,s.PageSize=r;let a=await this.ctx.api.marketplace.getOffersByItem(s);return a.ok&&this.ctx.emitter.emit("marketplace:offersByItemLoaded",a.data),a}async getOffer(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.getOffer(t);return i.ok&&this.ctx.emitter.emit("marketplace:offerLoaded",i.data),i}async getBuyOrders(e,t,i=20){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.ItemID=e,r.ContinuationToken=t,r.PageSize=i;let s=await this.ctx.api.marketplace.getBuyOrders(r);return s.ok&&this.ctx.emitter.emit("marketplace:buyOrdersLoaded",s.data),s}async getMyState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.marketplace.getMyState(e);return t.ok&&(this.ctx.data.user.applyMarketplaceState(t.data.Limits??null),this.ctx.emitter.emit("marketplace:myStateLoaded",t.data)),t}async getHistory(e,t=20){let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.ContinuationToken=e,i.PageSize=t;let r=await this.ctx.api.marketplace.getHistory(i);return r.ok&&this.ctx.emitter.emit("marketplace:historyLoaded",r.data),r}async createListing(e,t,i,r,s,a){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");if(!r)return n("client","PriceBundle is required.");let p=this.baseRequest();if(!p)return n("unauthorized","Not logged in.");p.ItemID=e,p.CatalogID=t,p.GoodsAmount=i,p.PriceBundle=r,p.DurationHours=s,p.ItemInstanceIDs=a;let D=await this.ctx.api.marketplace.createListing(p);return this.applyCreateOfferResult(D,"marketplace:listingCreated"),D}async cancelListing(e){return this.cancelOffer(e,t=>this.ctx.api.marketplace.cancelListing(t),"marketplace:listingCancelled")}async buy(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.buy(t);return i.ok&&(this.applyDualPartySettlement(i.data.Settlement),this.ctx.emitter.emit("marketplace:bought",i.data)),i}async marketBuy(e,t,i){if(!e||e<=0)return n("client","GoodsAmount must be positive.");if(!t)return n("client","PriceBundle is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");let s=this.applyGoodsSelector(r,i);if(s)return s;r.GoodsAmount=e,r.PriceBundle=t;let a=await this.ctx.api.marketplace.marketBuy(r);return a.ok&&(this.applyDualPartySettlement(a.data.Settlement),this.ctx.emitter.emit("marketplace:marketBought",a.data)),a}async marketSell(e,t,i){if(!e||e<=0)return n("client","GoodsAmount must be positive.");if(!t)return n("client","PriceBundle is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");let s=this.applyGoodsSelector(r,i);if(s)return s;r.GoodsAmount=e,r.PriceBundle=t;let a=await this.ctx.api.marketplace.marketSell(r);return a.ok&&(this.applyDualPartySettlement(a.data.Settlement),this.ctx.emitter.emit("marketplace:marketSold",a.data)),a}async createAuction(e,t,i,r,s,a,p={}){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");let D=this.baseRequest();if(!D)return n("unauthorized","Not logged in.");D.ItemID=e,D.CatalogID=t,D.GoodsAmount=i,D.BidAxisType=r,D.BidCurrencyID=p.bidCurrencyID,D.BidCatalogID=p.bidCatalogID,D.BidItemID=p.bidItemID,D.StartingBid=s,D.DurationHours=a,D.ItemInstanceIDs=p.itemInstanceIDs;let B=await this.ctx.api.marketplace.createAuction(D);return this.applyCreateOfferResult(B,"marketplace:auctionCreated"),B}async placeBid(e,t){if(!e)return n("client","OfferID is required.");if(!t||t<=0)return n("client","BidAmount must be positive.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.OfferID=e,i.BidAmount=t;let r=await this.ctx.api.marketplace.placeBid(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:bidPlaced",r.data)),r}async claimAuction(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.claimAuction(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:auctionClaimed",i.data)),i}async createBuyOrder(e,t,i,r,s){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");if(!r)return n("client","PriceBundle is required.");let a=this.baseRequest();if(!a)return n("unauthorized","Not logged in.");a.ItemID=e,a.CatalogID=t,a.GoodsAmount=i,a.PriceBundle=r,a.DurationHours=s;let p=await this.ctx.api.marketplace.createBuyOrder(a);return this.applyCreateOfferResult(p,"marketplace:buyOrderCreated"),p}async cancelBuyOrder(e){return this.cancelOffer(e,t=>this.ctx.api.marketplace.cancelBuyOrder(t),"marketplace:buyOrderCancelled")}async fillBuyOrder(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.fillBuyOrder(t);return i.ok&&(this.applyDualPartySettlement(i.data.Settlement),this.ctx.emitter.emit("marketplace:buyOrderFilled",i.data)),i}async createDirectTrade(e,t,i,r,s){if(!e)return n("client","TargetUserID is required.");if(!t)return n("client","CatalogID is required.");if(!i)return n("client","ItemID is required.");let a=this.baseRequest();if(!a)return n("unauthorized","Not logged in.");a.TargetUserID=e,a.CatalogID=t,a.ItemID=i,a.ItemInstanceIDs=r,a.RequestedBundle=s;let p=await this.ctx.api.marketplace.createDirectTrade(a);return this.applyCreateOfferResult(p,"marketplace:directTradeCreated"),p}async respondDirectTrade(e,t){if(!e)return n("client","OfferID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.OfferID=e,i.Accept=t;let r=await this.ctx.api.marketplace.respondDirectTrade(i);return r.ok&&(t&&(r.data.Settlement?this.applyDualPartySettlement(r.data.Settlement):r.data.Resources&&this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions)),this.ctx.emitter.emit("marketplace:directTradeResponded",r.data)),r}async cancelDirectTrade(e){return this.cancelOffer(e,t=>this.ctx.api.marketplace.cancelDirectTrade(t),"marketplace:directTradeCancelled")}async claimBack(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.claimBack(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:claimedBack",i.data)),i}async cancelOffer(e,t,i){if(!e)return n("client","OfferID is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.OfferID=e;let s=await t(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit(i,s.data)),s}applyCreateOfferResult(e,t){e.ok&&(e.data.Matched&&e.data.Settlement?this.applyDualPartySettlement(e.data.Settlement.Settlement):this.ctx.data.user.applyResourceOperation(e.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit(t,e.data));}applyGoodsSelector(e,t){return "goodsCurrencyID"in t&&t.goodsCurrencyID?(e.GoodsType=ji.VirtualCurrency,e.GoodsCurrencyID=t.goodsCurrencyID,null):"itemID"in t&&t.itemID&&t.catalogID?(e.GoodsType=ji.Item,e.ItemID=t.itemID,e.CatalogID=t.catalogID,null):n("client","Either itemID+catalogID or goodsCurrencyID is required.")}applyDualPartySettlement(e){let t=this.ctx.auth.context?.userID;if(!e||!t)return;let i=this.ctx.data.config.itemDefinitions;e.FromUserID===t&&e.FromResult?this.ctx.data.user.applyResourceOperation(e.FromResult,i):e.ToUserID===t&&e.ToResult&&this.ctx.data.user.applyResourceOperation(e.ToResult,i);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Vi=class{constructor(e){this.ctx=e;}ctx;async createRoom(e,t={}){if(!e)return n("client","RoomName is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomName=e,i.Topology=t.topology,i.ChatMode=t.chatMode,i.MaxPlayers=t.maxPlayers,i.Visibility=t.visibility,i.JoinCode=t.joinCode;let r=await this.ctx.api.multiplayer.createRoom(i);return r.ok&&this.ctx.emitter.emit("multiplayer:roomCreated",r.data),r}async joinRoom(e,t){if(!e)return n("client","RoomID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.JoinCode=t;let r=await this.ctx.api.multiplayer.joinRoom(i);return r.ok&&this.ctx.emitter.emit("multiplayer:roomJoined",r.data),r}async leaveRoom(e){if(!e)return n("client","RoomID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.RoomID=e;let i=await this.ctx.api.multiplayer.leaveRoom(t);return i.ok&&this.ctx.emitter.emit("multiplayer:roomLeft",i.data),i}async listRooms(e=0,t=20){let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.Page=e,i.PageSize=t;let r=await this.ctx.api.multiplayer.listRooms(i);return r.ok&&this.ctx.emitter.emit("multiplayer:roomsListed",r.data),r}async getRoom(e){if(!e)return n("client","RoomID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.RoomID=e;let i=await this.ctx.api.multiplayer.getRoom(t);return i.ok&&this.ctx.emitter.emit("multiplayer:roomLoaded",i.data),i}async closeRoom(e){if(!e)return n("client","RoomID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.RoomID=e;let i=await this.ctx.api.multiplayer.closeRoom(t);return i.ok&&this.ctx.emitter.emit("multiplayer:roomClosed",i.data),i}async poll(e,t){if(!e)return n("client","RoomID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.LastSeq=t;let r=await this.ctx.api.multiplayer.poll(i);return r.ok&&this.ctx.emitter.emit("multiplayer:polled",r.data),r}async sendSignal(e,t,i,r){if(!e)return n("client","RoomID is required.");if(!t)return n("client","TargetUserID is required.");if(!i)return n("client","SignalKind is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomID=e,s.TargetUserID=t,s.SignalKind=i,s.Payload=r;let a=await this.ctx.api.multiplayer.sendSignal(s);return a.ok&&this.ctx.emitter.emit("multiplayer:signalSent",a.data),a}async sendChat(e,t){if(!e)return n("client","RoomID is required.");if(!t)return n("client","ChatText is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.ChatText=t;let r=await this.ctx.api.multiplayer.sendChat(i);return r.ok&&this.ctx.emitter.emit("multiplayer:chatSent",r.data),r}async setMemberState(e,t,i){if(!e)return n("client","RoomID is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.RoomID=e,r.Ready=t,r.MemberState=i;let s=await this.ctx.api.multiplayer.setMemberState(r);return s.ok&&this.ctx.emitter.emit("multiplayer:memberStateSet",s.data),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ko=zod.z.object({PlatformUserID:zod.z.string().nullish(),PlatformAuthToken:zod.z.string().nullish(),PlatformAuthTokenExpiration:u.nullish(),TitleUserID:zod.z.string(),TitleClientSessionTicket:zod.z.string(),TitleClientSessionTicketExpiration:u}),be=zod.z.object({IsCompleted:zod.z.boolean().nullish(),ServerTime:u.nullish()}),Ho=zod.z.object({Message:zod.z.string(),ExpiresAt:u}),we={LoginWithDeviceID:"LoginWithDeviceID",LoginWithTelegram:"LoginWithTelegram",LoginWithEmail:"LoginWithEmail",LoginWithGoogle:"LoginWithGoogle",LoginWithPlatformToken:"LoginWithPlatformToken",LoginWithSsoCode:"LoginWithSsoCode",RegisterWithEmail:"RegisterWithEmail",RequestWalletChallenge:"RequestWalletChallenge",LoginWithWallet:"LoginWithWallet",ForgotPassword:"ForgotPassword",ResetPassword:"ResetPassword"};function A(o,e,t,i){let s=`api/v2/${o&&o.length>0?o:"0"}/Client/${e}/${t}`;return i==null?s:`${s}/${i}`}var _i=class{constructor(e){this.ctx=e;}ctx;endpoint(e){return A(this.ctx.settings.titleID,"Authentication",e)}login(e,t){return this.ctx.transport.post(this.endpoint(e),t,Ko,{ticket:null})}loginWithDeviceID(e){return this.login(we.LoginWithDeviceID,e)}loginWithTelegram(e){return this.login(we.LoginWithTelegram,e)}loginWithEmail(e){return this.login(we.LoginWithEmail,e)}loginWithGoogle(e){return this.login(we.LoginWithGoogle,e)}loginWithPlatformToken(e){return this.login(we.LoginWithPlatformToken,e)}loginWithSsoCode(e){return this.login(we.LoginWithSsoCode,e)}registerWithEmail(e){return this.login(we.RegisterWithEmail,e)}requestWalletChallenge(e){return this.ctx.transport.post(this.endpoint(we.RequestWalletChallenge),e,Ho,{ticket:null})}loginWithWallet(e){return this.login(we.LoginWithWallet,e)}forgotPassword(e){return this.ctx.transport.post(this.endpoint(we.ForgotPassword),e,be,{ticket:null})}resetPassword(e){return this.ctx.transport.post(this.endpoint(we.ResetPassword),e,be,{ticket:null})}};var Ld={ReturnKey:"ReturnKey",ReturnMarkedKey:"ReturnMarkedKey",ReturnEmpty:"ReturnEmpty"},$o=zod.z.enum(["ReturnKey","ReturnMarkedKey","ReturnEmpty"]),qd=zod.z.object({Locale:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Order:zod.z.number().nullish()}).passthrough(),Zo=zod.z.object({IsEnabled:zod.z.boolean().nullish(),DefaultLocale:zod.z.string().nullish(),Locales:zod.z.record(zod.z.string(),qd).nullish(),MissingKeyMode:$o.nullish(),MaxEntriesPerLocale:zod.z.number().nullish(),MaxValueLengthBytes:zod.z.number().nullish()}).passthrough(),Ed=zod.z.object({Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),Url:zod.z.string().nullish()}).passthrough(),Jo=zod.z.object({Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),Url:zod.z.string().nullish(),Fallback:Ed.nullish()}).passthrough(),Wi={GetLocalizationManifest:"GetLocalizationManifest",GetLocalizationTable:"GetLocalizationTable"},Gd=zod.z.object({Locale:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Order:zod.z.number().nullish(),Version:zod.z.number().nullish()}).passthrough(),Yo=zod.z.object({IsEnabled:zod.z.boolean().nullish(),DefaultLocale:zod.z.string().nullish(),MissingKeyMode:$o.nullish(),ResolvedLocale:zod.z.string().nullish(),Locales:zod.z.array(Gd).nullish()}).passthrough(),Xo=zod.z.object({RequestedLocale:zod.z.string().nullish(),Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),NotModified:zod.z.boolean().nullish(),Entries:zod.z.record(zod.z.string(),zod.z.string()).nullish(),FallbackLocale:zod.z.string().nullish(),FallbackVersion:zod.z.number().nullish()}).passthrough();var Ms=zod.z.object({TitleConfigVersion:zod.z.string().nullish(),TitleConfigUrl:zod.z.string().nullish(),User:zod.z.unknown().nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish(),StateEpoch:zod.z.string().nullish(),Localization:Jo.nullish()}).passthrough().transform(o=>o),ea=zod.z.object({StateEpoch:zod.z.string().nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough().transform(o=>o),ta=zod.z.object({StateEpoch:zod.z.string().nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish(),User:zod.z.unknown().nullish()}).passthrough().transform(o=>o),ia=zod.z.object({}).passthrough().transform(o=>o),ra=zod.z.object({}).passthrough().transform(o=>o),sa=zod.z.object({Today:zod.z.number(),Yesterday:zod.z.number(),CurrentWeek:zod.z.number(),CurrentMonth:zod.z.number(),Total:zod.z.number(),TotalSessions:zod.z.number(),FirstActiveAt:u.nullish(),LastActiveAt:u.nullish(),LongestSessionEverSeconds:zod.z.number().nullish(),CurrentWeekActiveHoursMask:zod.z.number().nullish(),CurrentMonthActiveHoursMask:zod.z.number().nullish(),ReactivationCount:zod.z.number().nullish(),History:zod.z.record(zod.z.string(),zod.z.unknown()).nullish()}).passthrough(),na=zod.z.object({Username:zod.z.string()}),Le={GetClientState:"GetClientState",GetClientStateExcept:"GetClientStateExcept",GetStateVersions:"GetStateVersions",GetUserState:"GetUserState",GetInventory:"GetInventory",GetEventTokens:"GetEventTokens",GetUsageTime:"GetUsageTime",AddUsageTime:"AddUsageTime",DeleteUserAccount:"DeleteUserAccount",ChangeUsername:"ChangeUsername"};var Qi=class{constructor(e){this.ctx=e;}ctx;endpoint(e,t){return A(this.ctx.settings.titleID,"User",e,t??"")}getClientState(e){return this.ctx.transport.post(this.endpoint(Le.GetClientState,e.UserID),e,Ms,{ticket:e.ClientSessionTicket})}getClientStateExcept(e){return this.ctx.transport.post(this.endpoint(Le.GetClientStateExcept,e.UserID),e,Ms,{ticket:e.ClientSessionTicket})}getStateVersions(e){return this.ctx.transport.post(this.endpoint(Le.GetStateVersions,e.UserID),e,ea,{ticket:e.ClientSessionTicket})}getUserState(e){return this.ctx.transport.post(this.endpoint(Le.GetUserState,e.UserID),e,ta,{ticket:e.ClientSessionTicket})}getInventory(e){return this.ctx.transport.post(this.endpoint(Le.GetInventory,e.UserID),e,ia,{ticket:e.ClientSessionTicket})}getEventTokens(e){return this.ctx.transport.post(this.endpoint(Le.GetEventTokens,e.UserID),e,ra,{ticket:e.ClientSessionTicket})}getUsageTime(e){return this.ctx.transport.post(this.endpoint(Le.GetUsageTime,e.UserID),e,sa,{ticket:e.ClientSessionTicket})}addUsageTime(e){return this.ctx.transport.post(this.endpoint(Le.AddUsageTime,e.UserID),e,be,{ticket:e.ClientSessionTicket,silent:true})}deleteUserAccount(e){return this.ctx.transport.post(this.endpoint(Le.DeleteUserAccount,e.UserID),e,be,{ticket:e.ClientSessionTicket})}changeUsername(e){return this.ctx.transport.post(this.endpoint(Le.ChangeUsername,e.UserID),e,na,{ticket:e.ClientSessionTicket})}};var Ki=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Currency",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}convert(e){return this.send(Ui.Convert,e,$n)}cryptoConvert(e){return this.send(Ui.CryptoConvert,e,Zn)}};var Nd=zod.z.object({ItemInstanceID:zod.z.string(),Units:zod.z.number(),Level:zod.z.number()}),ws=zod.z.object({ServerTimeUtc:u,ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Level:zod.z.number(),Resources:b.nullish(),FodderConsumed:zod.z.array(Nd).nullish()}),oa=zod.z.array(se(ws)),Hi={UpgradeLevel:"UpgradeLevel",UpgradeLevelsBatch:"UpgradeLevelsBatch"},jd={FlatCount:"FlatCount",Merge:"Merge",InvestmentRefund:"InvestmentRefund"},Fd=zod.z.enum(["FlatCount","Merge","InvestmentRefund"]),Vd={ProtectLeveled:"ProtectLeveled",CheapestFirst:"CheapestFirst",ClientSelected:"ClientSelected"},_d=zod.z.enum(["ProtectLeveled","CheapestFirst","ClientSelected"]),Wd=zod.z.object({ContractAddress:zod.z.string().nullish(),TokenID:zod.z.string().nullish(),TokenStandard:zod.z.string().nullish()}).passthrough(),Qd=zod.z.object({Networks:zod.z.record(zod.z.string(),Wd).nullish(),MetadataUrl:zod.z.string().nullish()}).passthrough(),Kd=zod.z.object({FlatBonuses:zod.z.record(zod.z.string(),zod.z.number()).nullish(),PercentBonuses:zod.z.record(zod.z.string(),zod.z.number()).nullish(),Power:zod.z.number().nullish()}).passthrough(),Hd=zod.z.object({MinCharacterLevel:zod.z.number().nullish(),UseRequirements:zod.z.record(zod.z.string(),zod.z.number()).nullish(),AllowedCharacterIDs:zod.z.array(zod.z.string()).nullish(),AllowedSlotIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),$d=zod.z.object({ValuationMode:Fd.nullish(),MergeRatio:zod.z.number().nullish(),Selection:_d.nullish()}).passthrough(),Zd=zod.z.object({MaxLevel:zod.z.number().nullish(),BaseCostResource:Z.nullish(),CostScalingFactor:zod.z.number().nullish(),FlatScalingFactor:zod.z.number().nullish(),PercentScalingFactor:zod.z.number().nullish(),PowerScalingFactor:zod.z.number().nullish(),Fodder:$d.nullish()}).passthrough(),Jd=zod.z.object({RarityID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),AuthorID:zod.z.string().nullish()}).passthrough(),Yd=zod.z.object({ItemID:zod.z.string(),CatalogID:zod.z.string(),ItemClass:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Tags:zod.z.array(zod.z.string()).nullish(),CustomData:zod.z.string().nullish(),IsStackable:zod.z.boolean().nullish(),IsTradable:zod.z.boolean().nullish(),Weight:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),NFT:Qd.nullish(),Stats:Kd.nullish(),Equipment:Hd.nullish(),Upgrade:Zd.nullish(),Metadata:Jd.nullish(),ExpirationDurationSeconds:zod.z.number().nullish()}).passthrough(),Xd=zod.z.object({Items:zod.z.record(zod.z.string(),Yd).nullish()}).passthrough(),$i=zod.z.object({Catalogs:zod.z.record(zod.z.string(),Xd).nullish()}).passthrough();var Zi=class{constructor(e){this.ctx=e;}ctx;upgradeLevel(e){let t=A(this.ctx.settings.titleID,"Item",Hi.UpgradeLevel,e.UserID??"");return this.ctx.transport.post(t,e,ws,{ticket:e.ClientSessionTicket})}upgradeLevelsBatch(e){let t=A(this.ctx.settings.titleID,"Item",Hi.UpgradeLevelsBatch,e.UserID??"");return this.ctx.transport.post(t,e,oa,{ticket:e.ClientSessionTicket})}};var As=zod.z.object({ServerTimeUtc:u,OfferID:zod.z.string(),Count:zod.z.number(),Resources:b.nullish()}),aa=zod.z.array(se(As)),eh=zod.z.object({OfferID:zod.z.string(),TotalPurchases:zod.z.number(),DailyPurchases:zod.z.number(),DailyResetUtc:u,LastPurchasedAt:u}),la=zod.z.object({Purchases:zod.z.record(zod.z.string(),eh).nullish()}).passthrough().transform(o=>o),th=zod.z.object({StartUtc:u.nullish(),EndUtc:u.nullish(),RequiredFlags:zod.z.array(zod.z.string()).nullish()}).passthrough(),ih=zod.z.object({StoreID:zod.z.string(),Type:zod.z.string().nullish(),Name:zod.z.string().nullish(),Description:zod.z.string().nullish(),Rules:th.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),rh=zod.z.object({StartUtc:u.nullish(),EndUtc:u.nullish(),Gate:Q.nullish(),Limits:ge.nullish()}).passthrough(),sh=zod.z.object({OfferID:zod.z.string(),StoreIDs:zod.z.array(zod.z.string()).nullish(),Name:zod.z.string().nullish(),Cost:Z.nullish(),Rewards:q.nullish(),Rules:rh.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Ji=zod.z.object({Stores:zod.z.record(zod.z.string(),ih).nullish(),StoreOffers:zod.z.record(zod.z.string(),sh).nullish()}).passthrough(),Tt={Purchase:"Purchase",GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",PurchaseBatch:"PurchaseBatch"};var Yi=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Store",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}purchase(e){return this.send(Tt.Purchase,e,As)}purchaseBatch(e){return this.send(Tt.PurchaseBatch,e,aa)}getDefinitions(e){return this.send(Tt.GetDefinitions,e,Ji)}getUserState(e){return this.send(Tt.GetUserState,e,la)}};var nh=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),ua=zod.z.object({Reward:q.nullish(),Weight:zod.z.number().nullish(),AmountRange:nh.nullish()}).passthrough(),vt=zod.z.object({SlotID:zod.z.string().nullish(),MinRolls:zod.z.number().nullish(),MaxRolls:zod.z.number().nullish(),Pool:zod.z.array(ua).nullish()}).passthrough(),Pt=zod.z.object({RuleID:zod.z.string().nullish(),Threshold:zod.z.number().nullish(),Pool:zod.z.array(ua).nullish()}).passthrough(),oh=zod.z.object({RewardSlots:zod.z.array(vt).nullish()}).passthrough(),ah=zod.z.object({PityRules:zod.z.array(Pt).nullish()}).passthrough(),Xi=zod.z.object({SlotPresets:zod.z.record(zod.z.string(),oh).nullish(),PityPresets:zod.z.record(zod.z.string(),ah).nullish()}).passthrough();var lh=zod.z.object({RuleID:zod.z.string(),BoxIndex:zod.z.number().nullish()}),ca=zod.z.object({ServerTimeUtc:u,LootboxID:zod.z.string(),OpenedCount:zod.z.number().nullish(),SelectedOptionID:zod.z.number().nullish(),Resources:b.nullish(),Inventory:ot.nullish(),Results:zod.z.array(b).nullish(),TriggeredPity:zod.z.array(lh).nullish()}),uh=zod.z.object({PriceOptionID:zod.z.number().nullish(),RequiredResources:Z.nullish()}).passthrough(),ch=zod.z.object({RewardSlots:te.nullish(),PityRules:te.nullish()}).passthrough(),ph=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),MaxDrops:w.nullish()}).passthrough(),dh=zod.z.object({LootboxID:zod.z.string(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),PriceOptions:zod.z.record(zod.z.string(),uh).nullish(),RewardSlots:zod.z.array(vt).nullish(),PityRules:zod.z.array(Pt).nullish(),Presets:ch.nullish(),RewardMultiplier:Ft.nullish(),SupplyLimits:zod.z.array(ph).nullish(),MaxOpenCount:zod.z.number().nullish()}).passthrough(),Us=zod.z.object({Definitions:zod.z.record(zod.z.string(),dh).nullish(),RewardPools:Xi.nullish()}).passthrough(),pa=zod.z.object({LootboxDefinitions:Us.nullish()}),er={GetDefinitions:"GetDefinitions",Open:"Open"};var tr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Lootbox",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(er.GetDefinitions,e,pa)}open(e){return this.send(er.Open,e,ca)}};var hh=zod.z.object({}).passthrough().transform(o=>o),mh=zod.z.object({}).passthrough().transform(o=>o),fh=zod.z.object({}).passthrough().transform(o=>o),gh=zod.z.object({}).passthrough().transform(o=>o),Rh=zod.z.object({}).passthrough().transform(o=>o),da=zod.z.object({ServerTimeUtc:u,CalendarID:zod.z.string(),DayNumber:zod.z.number().nullish(),DailyState:hh,Resources:b.nullish()}),ha=zod.z.object({ServerTimeUtc:u,AccrualID:zod.z.string(),AccruedSeconds:w.nullish(),AppliedRatePerSecond:zod.z.number().nullish(),IdleState:mh,Resources:b.nullish()}),ma=zod.z.object({ServerTimeUtc:u,ComebackID:zod.z.string(),ClaimedTierIndex:zod.z.number().nullish(),ComebackState:fh,Resources:b.nullish()}),fa=zod.z.object({ServerTimeUtc:u,ClaimID:zod.z.string(),ClaimState:gh,Resources:b.nullish()}),ga=zod.z.object({Enabled:zod.z.boolean(),Multiplier:zod.z.number().nullish(),Progress:w.nullish(),Source:zod.z.string().nullish(),SourceKey:zod.z.string().nullish()}),yh=zod.z.object({RewardMode:zod.z.string().nullish(),RewardStackLowerTiers:zod.z.boolean().nullish()}).passthrough(),Ch=zod.z.object({DayNumber:zod.z.number().nullish(),Rewards:q.nullish(),IsMilestone:zod.z.boolean().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Sh=zod.z.object({CalendarID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Days:zod.z.array(Ch).nullish(),IsLooping:zod.z.boolean().nullish(),MissBehavior:zod.z.string().nullish(),ResetByDays:zod.z.number().nullish(),MissThresholdMultiplier:zod.z.number().nullish(),ClaimMode:zod.z.string().nullish(),ClaimCooldownSeconds:zod.z.number().nullish(),Gate:Q.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),xh=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),Dh=zod.z.object({BaseRatePerSecond:zod.z.number().nullish(),PowerCoefficient:zod.z.number().nullish(),BoardRankCoefficient:zod.z.number().nullish(),EquipmentBonusEnabled:zod.z.boolean().nullish(),EquipmentCharacterID:zod.z.string().nullish(),PremiumMultipliers:zod.z.array(xh).nullish()}).passthrough(),bh=zod.z.object({MinCharacterLevel:zod.z.number().nullish(),RequirementsCharacterID:zod.z.string().nullish(),Gate:Q.nullish(),RequiredItemIDs:zod.z.array(zod.z.string()).nullish(),RequiredEquippedItemIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),zh=zod.z.object({AccrualID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rate:Dh.nullish(),Rewards:q.nullish(),MaxAccumulationSeconds:zod.z.number().nullish(),MinClaimSeconds:zod.z.number().nullish(),Requirements:bh.nullish(),FirstClaimMode:zod.z.string().nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Th=zod.z.object({MinAbsenceSeconds:zod.z.number().nullish(),Rewards:q.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),vh=zod.z.object({ComebackID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Tiers:zod.z.array(Th).nullish(),ClaimCooldownSeconds:zod.z.number().nullish(),ClaimWindowSeconds:zod.z.number().nullish(),TrackPresenceOnRead:zod.z.boolean().nullish(),Gate:Q.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Ph=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),CooldownSeconds:zod.z.number().nullish(),MaxClaimsPerWindow:zod.z.number().nullish(),WindowSeconds:zod.z.number().nullish(),TotalClaimLimit:zod.z.number().nullish()}).passthrough(),Ih=zod.z.object({ClaimID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Mode:zod.z.string().nullish(),Rewards:q.nullish(),Limits:ge.nullish(),PremiumLimitOverrides:zod.z.array(Ph).nullish(),Gate:Q.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Os=zod.z.object({TierRewards:yh.nullish(),MilestoneRewardMultiplier:Ft.nullish(),DailyCalendars:zod.z.record(zod.z.string(),Sh).nullish(),IdleAccruals:zod.z.record(zod.z.string(),zh).nullish(),Comebacks:zod.z.record(zod.z.string(),vh).nullish(),Claims:zod.z.record(zod.z.string(),Ih).nullish()}).passthrough(),Ra=zod.z.object({RewardDefinitions:Os.nullish()}),ya=zod.z.object({Rewards:Rh.nullish()}),et={GetRewardDefinitions:"GetRewardDefinitions",GetUserRewardsState:"GetUserRewardsState",ClaimDailyReward:"ClaimDailyReward",CollectIdleAccrual:"CollectIdleAccrual",ClaimComebackReward:"ClaimComebackReward",ClaimReward:"ClaimReward",ClaimRewardsBatch:"ClaimRewardsBatch",GetMilestoneRewardMultiplier:"GetMilestoneRewardMultiplier"};var ir=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Reward",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getRewardDefinitions(e){return this.send(et.GetRewardDefinitions,e,Ra)}getUserRewardsState(e){return this.send(et.GetUserRewardsState,e,ya)}getMilestoneRewardMultiplier(e){return this.send(et.GetMilestoneRewardMultiplier,e,ga)}claimDailyReward(e){return this.send(et.ClaimDailyReward,e,da)}collectIdleAccrual(e){return this.send(et.CollectIdleAccrual,e,ha)}claimComebackReward(e){return this.send(et.ClaimComebackReward,e,ma)}claimReward(e){return this.send(et.ClaimReward,e,fa)}};var rr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Tutorial",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getTutorialDefinitions(e){return this.send(Oe.GetTutorialDefinitions,e,Pn)}getUserTutorialState(e){return this.send(Oe.GetUserTutorialState,e,kn)}startFlow(e){return this.send(Oe.StartFlow,e,nt)}reportStepShown(e){return this.send(Oe.ReportStepShown,e,nt)}completeStep(e){return this.send(Oe.CompleteStep,e,nt)}completeStepsBatch(e){return this.send(Oe.CompleteStepsBatch,e,wn)}skipStep(e){return this.send(Oe.SkipStep,e,nt)}skipFlow(e){return this.send(Oe.SkipFlow,e,nt)}claimFlowReward(e){return this.send(Oe.ClaimFlowReward,e,Mn)}resetFlow(e){return this.send(Oe.ResetFlow,e,nt)}};var sr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Localization",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket,throttleKey:t.Locale?`${r}:${t.Locale}`:r})}getLocalizationManifest(e){return this.send(Wi.GetLocalizationManifest,e,Yo)}getLocalizationTable(e){return this.send(Wi.GetLocalizationTable,e,Xo)}};var nr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Quest",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getQuestDefinitions(e){return this.send(je.GetQuestDefinitions,e,_t)}getUserQuestState(e){return this.send(je.GetUserQuestState,e,fn)}refreshQuestCycles(e){return this.send(je.RefreshQuestCycles,e,be)}claimQuestReward(e){return this.send(je.ClaimQuestReward,e,Jr)}claimQuestRewardsBatch(e){return this.send(je.ClaimQuestRewardsBatch,e,yn)}claimMilestoneReward(e){return this.send(je.ClaimMilestoneReward,e,Yr)}claimMilestoneRewardsBatch(e){return this.send(je.ClaimMilestoneRewardsBatch,e,Cn)}claimGroupCompletionReward(e){return this.send(je.ClaimGroupCompletionReward,e,gn)}addQuestProgress(e){return this.send(je.AddQuestProgress,e,Rn)}};var Ca=zod.z.object({}).passthrough().transform(o=>o);var kh=zod.z.object({Order:zod.z.number().nullish(),Type:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),BonusMultiplier:zod.z.number().nullish()}).passthrough(),Mh=zod.z.object({Schedule:zod.z.array(kh).nullish(),RepeatCycle:zod.z.boolean().nullish(),MaxCycles:zod.z.number().nullish()}).passthrough(),wh=zod.z.object({IsActive:zod.z.boolean().nullish(),CurrentPhaseEndUtc:u.nullish(),NextBonusStartUtc:u.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentPhaseIndex:zod.z.number().nullish(),ActiveBonusMultiplier:zod.z.number().nullish()}).passthrough(),Ah=zod.z.object({Milestones:te.nullish()}).passthrough(),Bs=zod.z.object({DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Category:zod.z.string().nullish(),Token:ct.nullish(),TokenSources:zod.z.array(Ue).nullish(),ClaimMode:zod.z.string().nullish(),Milestones:zod.z.record(zod.z.string(),xe).nullish(),Presets:Ah.nullish(),BonusWindow:Mh.nullish()}).passthrough(),Uh=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Content:Bs.nullish(),ClaimGraceHours:zod.z.number().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Oh=zod.z.object({TimedEventID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Schedule:ce.nullish(),Content:Bs.nullish(),Events:zod.z.array(Uh).nullish(),Gate:Q.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Bh=zod.z.object({MaxConcurrentEvents:zod.z.number().nullish()}).passthrough(),Lh=zod.z.object({Milestones:zod.z.record(zod.z.string(),rt).nullish()}).passthrough(),or=zod.z.object({Definitions:zod.z.record(zod.z.string(),Oh).nullish(),Settings:Bh.nullish(),Presets:Lh.nullish()}).passthrough(),qh=zod.z.object({Type:At,TimedEventID:zod.z.string(),CurrentChainedEventID:zod.z.string().nullish(),Content:Bs.nullish(),Progress:Ca.nullish(),ComputedStartUtc:u.nullish(),ComputedEndUtc:u.nullish(),CanEarn:zod.z.boolean().nullish(),CanClaim:zod.z.boolean().nullish(),NextMilestone:xe.nullish(),BonusWindow:wh.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentEventOrder:zod.z.number().nullish(),TotalEventsInChain:zod.z.number().nullish()}).passthrough(),Sa=zod.z.object({ActiveEvents:zod.z.array(qh).nullish()}).passthrough(),xa=zod.z.object({Tokens:zod.z.record(zod.z.string(),Ca).nullish()}),Ls=zod.z.object({Type:At.nullish(),LteID:zod.z.string().nullish(),Resources:b.nullish()}),qs=zod.z.object({Type:At.nullish(),LteID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Rewards:b.nullish()}),Eh=zod.z.object({Type:At.nullish(),LteID:zod.z.string().nullish(),Resources:b.nullish()}),Es=zod.z.array(se(qs)),Da=zod.z.array(se(Ls)),ba=zod.z.array(se(Eh)),qe={GetActiveEvents:"GetActiveEvents",GrantTokens:"GrantTokens",SpendTokens:"SpendTokens",ClaimMilestone:"ClaimMilestone",GetDefinitions:"GetDefinitions",GetUserLteState:"GetUserLteState",ClaimMilestonesBatch:"ClaimMilestonesBatch",ClaimAllMilestones:"ClaimAllMilestones",SpendTokensBatch:"SpendTokensBatch",GrantTokensBatch:"GrantTokensBatch"};var ar=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"TimedEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getActiveEvents(e){return this.send(qe.GetActiveEvents,e,Sa)}getDefinitions(e){return this.send(qe.GetDefinitions,e,or)}getUserLteState(e){return this.send(qe.GetUserLteState,e,xa)}grantTokens(e){return this.send(qe.GrantTokens,e,b)}spendTokens(e){return this.send(qe.SpendTokens,e,Ls)}claimMilestone(e){return this.send(qe.ClaimMilestone,e,qs)}claimMilestonesBatch(e){return this.send(qe.ClaimMilestonesBatch,e,Es)}claimAllMilestones(e){return this.send(qe.ClaimAllMilestones,e,Es)}spendTokensBatch(e){return this.send(qe.SpendTokensBatch,e,Da)}grantTokensBatch(e){return this.send(qe.GrantTokensBatch,e,ba)}};var Gh=zod.z.object({UserID:zod.z.string(),Score:w.nullish(),Rank:zod.z.number().nullish(),LastScoreUpdateUtc:u.nullish(),IpHash:zod.z.string().nullish(),PublicProfile:De.nullish(),SeasonTierAtCycleEnd:zod.z.number().nullish()}).passthrough(),Bt=zod.z.object({LeaderboardID:zod.z.string(),CycleVersion:zod.z.number().nullish(),TotalParticipants:w.nullish(),CycleEndUtc:u.nullish(),TopUsers:zod.z.array(Gh).nullish(),BracketID:zod.z.string().nullish()}),Nh=zod.z.object({CycleKey:zod.z.string().nullish(),CycleEndUtc:u.nullish(),ClaimDeadlineUtc:u.nullish(),MilestoneTokensEarned:w.nullish(),ClaimableMilestoneIDs:zod.z.array(zod.z.string()).nullish(),CycleIndex:zod.z.number().nullish(),ChainedEventID:zod.z.string().nullish()}).passthrough(),lr=zod.z.object({LeaderboardID:zod.z.string(),CurrentScore:w.nullish(),LastKnownRank:zod.z.number().nullish(),HasUnclaimedReward:zod.z.boolean().nullish(),ScoreEarnedThisCycle:w.nullish(),MilestoneTokensEarned:w.nullish(),NextMilestone:xe.nullish(),HasUnclaimedMilestone:zod.z.boolean().nullish(),ClaimableGraceCycles:zod.z.array(Nh).nullish()}),ur=zod.z.object({LeaderboardID:zod.z.string(),NewScore:w,CycleVersion:zod.z.number()}),cr=zod.z.object({ServerTimeUtc:u,LeaderboardID:zod.z.string(),Rank:zod.z.number().nullish(),Resources:b.nullish()}),pr=zod.z.object({ServerTimeUtc:u,LeaderboardID:zod.z.string(),MilestoneID:zod.z.string(),Resources:b.nullish()}),za=zod.z.array(se(Bt)),Ta=zod.z.array(se(lr)),va=zod.z.array(se(cr)),Pa=zod.z.array(se(pr)),Ia=zod.z.array(se(ur)),jh=zod.z.object({LeaderboardID:zod.z.string(),CycleReward:se(cr).nullish(),Milestones:zod.z.array(se(pr)).nullish()}),ka=zod.z.array(jh),Fh=zod.z.object({LeaderboardID:zod.z.string(),Leaderboard:se(Bt).nullish(),Progress:se(lr).nullish()}),Ma=zod.z.array(Fh),Vh=zod.z.string(),wa=zod.z.object({Rank:zod.z.string().nullish(),Rewards:q.nullish(),SeasonTierRewards:$r.nullish()}).passthrough(),_h=zod.z.object({RankRewards:zod.z.array(wa).nullish()}).passthrough(),Wh=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Qh=zod.z.object({Milestones:te.nullish(),RankRewards:te.nullish()}).passthrough(),Kh=zod.z.object({LeaderboardID:zod.z.string(),DisplayName:zod.z.string().nullish(),ScoreDisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),IsEnabled:zod.z.boolean().nullish(),ScoreAggregation:Vh.nullish(),Schedule:ce.nullish(),ChainEvents:zod.z.array(Wh).nullish(),Gate:Q.nullish(),TopUsersLimit:zod.z.number().nullish(),MinScoreToEnterTop:zod.z.number().nullish(),BracketSize:zod.z.number().nullish(),LinkedSeasonChainID:zod.z.string().nullish(),RankRewards:zod.z.array(wa).nullish(),Milestones:zod.z.record(zod.z.string(),xe).nullish(),Presets:Qh.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneClaimGraceHours:zod.z.number().nullish(),ScoreSources:zod.z.array(Ue).nullish()}).passthrough(),Hh=zod.z.object({Milestones:zod.z.record(zod.z.string(),rt).nullish(),RankRewards:zod.z.record(zod.z.string(),_h).nullish()}).passthrough(),dr=zod.z.object({Definitions:zod.z.record(zod.z.string(),Kh).nullish(),Presets:Hh.nullish()}).passthrough(),Se={GetDefinitions:"GetDefinitions",GetLeaderboard:"GetLeaderboard",GetMyProgress:"GetMyProgress",SubmitScore:"SubmitScore",SubmitScoreFromSource:"SubmitScoreFromSource",ClaimCycleReward:"ClaimCycleReward",ClaimMilestone:"ClaimMilestone",GetFriendsLeaderboard:"GetFriendsLeaderboard",GetLeaderboardsBatch:"GetLeaderboardsBatch",GetProgressBatch:"GetProgressBatch",ClaimCycleRewardsBatch:"ClaimCycleRewardsBatch",ClaimMilestonesBatch:"ClaimMilestonesBatch",SubmitScoresBatch:"SubmitScoresBatch",ClaimAllRewardsBatch:"ClaimAllRewardsBatch",GetOverviewBatch:"GetOverviewBatch"};var hr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Leaderboard",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Se.GetDefinitions,e,dr)}getLeaderboard(e){return this.send(Se.GetLeaderboard,e,Bt)}getMyProgress(e){return this.send(Se.GetMyProgress,e,lr)}submitScore(e){return this.send(Se.SubmitScore,e,ur)}submitScoreFromSource(e){return this.send(Se.SubmitScoreFromSource,e,ur)}claimCycleReward(e){return this.send(Se.ClaimCycleReward,e,cr)}claimMilestone(e){return this.send(Se.ClaimMilestone,e,pr)}getFriendsLeaderboard(e){return this.send(Se.GetFriendsLeaderboard,e,Bt)}getLeaderboardsBatch(e){return this.send(Se.GetLeaderboardsBatch,e,za)}getProgressBatch(e){return this.send(Se.GetProgressBatch,e,Ta)}claimCycleRewardsBatch(e){return this.send(Se.ClaimCycleRewardsBatch,e,va)}claimMilestonesBatch(e){return this.send(Se.ClaimMilestonesBatch,e,Pa)}submitScoresBatch(e){return this.send(Se.SubmitScoresBatch,e,Ia)}claimAllRewardsBatch(e){return this.send(Se.ClaimAllRewardsBatch,e,ka)}getOverviewBatch(e){return this.send(Se.GetOverviewBatch,e,Ma)}};var Gs=zod.z.object({}).passthrough().transform(o=>o),Aa=zod.z.object({SeasonChainID:zod.z.string(),CycleIndex:zod.z.number().nullish(),Season:zod.z.lazy(()=>La).nullish(),ComputedStartUtc:u.nullish(),ComputedEndUtc:u.nullish(),SecondsRemaining:w.nullish(),UserState:Gs.nullish(),NextTier:zod.z.lazy(()=>Ba).nullish()}).passthrough(),Ua=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),AmountGranted:w.nullish(),NewStatusTokens:w.nullish(),OldTier:zod.z.number().nullish(),NewTier:zod.z.number(),TierUp:zod.z.boolean().nullish()}),Ns=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),TierNumber:zod.z.number(),Resources:b.nullish()}),Oa=st(Ns);var Ba=zod.z.object({Tier:zod.z.number().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),RequiredTokens:w.nullish(),TierReachedReward:q.nullish()}).passthrough(),La=zod.z.object({SeasonID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:w.nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Tiers:zod.z.array(Ba).nullish(),LinkedCollectionID:zod.z.string().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough();var $h=zod.z.object({SeasonChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:ce.nullish(),Seasons:zod.z.array(La).nullish(),GrantTokensAccessMode:zod.z.string().nullish(),Gate:Q.nullish()}).passthrough(),mr=zod.z.object({Chains:zod.z.record(zod.z.string(),$h).nullish()}).passthrough(),lt={GetDefinitions:"GetDefinitions",GetActiveSeason:"GetActiveSeason",GetUserState:"GetUserState",GrantStatusTokens:"GrantStatusTokens",ClaimTierReward:"ClaimTierReward",ClaimTierRewardsBatch:"ClaimTierRewardsBatch"};var fr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Season",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(lt.GetDefinitions,e,mr)}getActiveSeason(e){return this.send(lt.GetActiveSeason,e,Aa)}getUserState(e){return this.send(lt.GetUserState,e,Gs)}grantStatusTokens(e){return this.send(lt.GrantStatusTokens,e,Ua)}claimTierReward(e){return this.send(lt.ClaimTierReward,e,Ns)}claimTierRewardsBatch(e){return this.send(lt.ClaimTierRewardsBatch,e,Oa)}};var Zh={Apple:"Apple",Google:"Google"},qa=zod.z.object({}).passthrough().transform(o=>o),Jh=zod.z.object({PremiumID:zod.z.string().nullish(),PurchaseDate:zod.z.string().nullish(),ExpirationDate:zod.z.string().nullish(),TransactionID:zod.z.string().nullish(),IsAutoRenewEnabled:zod.z.boolean().nullish()}).passthrough(),Yh=zod.z.object({OptionID:zod.z.string().nullish(),Name:zod.z.string().nullish(),RequiredResources:Z.nullish()}).passthrough(),Xh=zod.z.object({PremiumID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Tier:zod.z.number().nullish(),DurationDays:zod.z.number().nullish(),TrialDurationDays:zod.z.number().nullish(),PriceOptions:zod.z.record(zod.z.string(),Yh).nullish(),AppleProductID:zod.z.string().nullish(),GoogleProductID:zod.z.string().nullish(),Benefits:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),js=zod.z.object({Definitions:zod.z.record(zod.z.string(),Xh).nullish()}).passthrough(),Ea=zod.z.object({Premium:js.nullish()}),Ga=zod.z.object({ServerTimeUtc:u.nullish(),Premium:qa.nullish()}),gr=zod.z.object({ServerTimeUtc:u.nullish(),Premium:qa.nullish(),Subscription:Jh.nullish(),Resources:b.nullish()}),dt={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateTrial:"ActivateTrial",PurchaseWithResources:"PurchaseWithResources",PurchaseRealMoney:"PurchaseRealMoney"};var Rr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Premium",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(dt.GetDefinitions,e,Ea)}getUserState(e){return this.send(dt.GetUserState,e,Ga)}activateTrial(e){return this.send(dt.ActivateTrial,e,gr)}purchaseItemOrCurrency(e){return this.send(dt.PurchaseWithResources,e,gr)}purchaseRealMoney(e){return this.send(dt.PurchaseRealMoney,e,gr)}};var yr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Character",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getCharacterDefinitions(e){return this.send(ke.GetCharacterDefinitions,e,Bi)}getUserCharacters(e){return this.send(ke.GetUserCharacters,e,to)}unlockCharacter(e){return this.send(ke.UnlockCharacter,e,fs)}upgradeStatLevel(e){return this.send(ke.UpgradeStatLevel,e,hs)}upgradeCharacterLevel(e){return this.send(ke.UpgradeCharacterLevel,e,ms)}equipItems(e){return this.send(ke.EquipItems,e,io)}unequipItems(e){return this.send(ke.UnequipItems,e,ro)}unequipAllCharacters(e){return this.send(ke.UnequipAllCharacters,e,so)}unlockCharactersBatch(e){return this.send(ke.UnlockCharactersBatch,e,no)}upgradeCharacterLevelsBatch(e){return this.send(ke.UpgradeCharacterLevelsBatch,e,oo)}upgradeStatLevelsBatch(e){return this.send(ke.UpgradeStatLevelsBatch,e,ao)}};var Cr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Match",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}createMatch(e){return this.send(Ke.CreateMatch,e,Ao)}updateMatch(e){return this.send(Ke.UpdateMatch,e,Uo)}cancelMatch(e){return this.send(Ke.CancelMatch,e,Oo)}instantBattle(e){return this.send(Ke.InstantBattle,e,Bo)}saveStrategy(e){return this.send(Ke.SaveStrategy,e,be)}getMyMatches(e){return this.send(Ke.GetMyMatches,e,Ds)}getAvailableMatches(e){return this.send(Ke.GetAvailableMatches,e,Ds)}getDefinitions(e){return this.send(Ke.GetDefinitions,e,Go)}};var em={TradeUpRarity:"TradeUpRarity",TradeUpCollection:"TradeUpCollection"},Na=zod.z.enum(["TradeUpRarity","TradeUpCollection"]),tm=zod.z.object({Index:zod.z.number().nullish(),BurnedItemIDs:zod.z.array(zod.z.string()).nullish(),RolledCollectionID:zod.z.string().nullish(),UsedCollections:zod.z.record(zod.z.string(),zod.z.number()).nullish(),Output:Hr.nullish()}),ja=zod.z.object({ServerTimeUtc:u,Type:Na.nullish(),CraftID:zod.z.string(),CraftedCount:zod.z.number().nullish(),SelectedOptionID:zod.z.string().nullish(),InputRarity:zod.z.string().nullish(),OutputRarity:zod.z.string().nullish(),Resources:b.nullish(),Results:zod.z.array(tm).nullish()}),im=zod.z.object({OptionID:zod.z.string().nullish(),RequiredResources:Z.nullish()}).passthrough(),rm=zod.z.object({CraftID:zod.z.string().nullish(),Type:Na.nullish(),CatalogID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),InputRarityID:zod.z.string().nullish(),OutputRarityID:zod.z.string().nullish(),RequiredItemCount:zod.z.number().nullish(),PriceOptions:zod.z.record(zod.z.string(),im).nullish()}).passthrough(),Fs=zod.z.object({Definitions:zod.z.record(zod.z.string(),rm).nullish()}).passthrough(),Fa=zod.z.object({ServerTimeUtc:u.nullish(),CraftDefinitions:Fs.nullish()}),Sr={GetDefinitions:"GetDefinitions",Craft:"Craft"};var xr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Craft",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Sr.GetDefinitions,e,Fa)}craft(e){return this.send(Sr.Craft,e,ja)}};var sm={Pending:"Pending",Accepted:"Accepted",Declined:"Declined",Cancelled:"Cancelled",Expired:"Expired"},nm=zod.z.enum(["Pending","Accepted","Declined","Cancelled","Expired"]),Va=zod.z.object({}).passthrough().transform(o=>o),It=zod.z.object({CollectibleID:zod.z.string(),Rarity:zod.z.number().nullish(),IsSpecial:zod.z.boolean().nullish(),IsDuplicate:zod.z.boolean().nullish(),CollectionCurrencyConverted:zod.z.number().nullish()}),_a=zod.z.object({GrantedCollectibles:zod.z.array(It).nullish(),DuplicateCollectibles:zod.z.array(It).nullish(),CollectionCurrencyEarned:w.nullish()}),Wa=zod.z.object({OpenedCount:zod.z.number().nullish(),Packs:zod.z.array(_a).nullish(),GrantedCollectibles:zod.z.array(It).nullish(),DuplicateCollectibles:zod.z.array(It).nullish(),CollectionCurrencyEarned:w.nullish(),NewCollectionCurrencyBalance:w.nullish(),NewlyCompletedSetIDs:zod.z.array(zod.z.string()).nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:b.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),Qa=zod.z.object({OpenedCount:zod.z.number().nullish(),Chests:zod.z.array(_a).nullish(),GrantedCollectibles:zod.z.array(It).nullish(),DuplicateCollectibles:zod.z.array(It).nullish(),CollectionCurrencyEarned:w.nullish(),NewCollectionCurrencyBalance:w.nullish(),Resources:b.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),Ka=zod.z.object({GrantedCollectibleID:zod.z.string().nullish(),NewlyCompletedSetID:zod.z.string().nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:b.nullish()}),Vs=zod.z.object({SetID:zod.z.string(),Resources:b.nullish()}),Ha=zod.z.array(se(Vs)),$a=zod.z.object({Resources:b.nullish()}),om=zod.z.object({OfferID:zod.z.string(),TitleID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderPublicData:De.nullish(),OfferedCollectibleID:zod.z.string().nullish(),OfferedCollectibleIsSpecial:zod.z.boolean().nullish(),ReceiverUserID:zod.z.string().nullish(),RequestedCollectibleID:zod.z.string().nullish(),RequestedCollectibleIsSpecial:zod.z.boolean().nullish(),Status:nm.nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),RespondedAtUtc:u.nullish(),DeclineReason:zod.z.string().nullish(),IsSpecialTradeEvent:zod.z.boolean().nullish(),SpecialTradeEventID:zod.z.string().nullish()}).passthrough(),Za=zod.z.object({OfferID:zod.z.string(),ExpiresAtUtc:u.nullish(),Resources:b.nullish()}),Ja=zod.z.object({OfferID:zod.z.string(),Resources:b.nullish()}),Ya=zod.z.object({OfferID:zod.z.string(),ReceivedCollectibleID:zod.z.string().nullish(),ReceivedIsSpecial:zod.z.boolean().nullish(),SentCollectibleID:zod.z.string().nullish(),SentCollectibleIsSpecial:zod.z.boolean().nullish(),Transfer:zod.z.unknown().nullish()}),Xa=zod.z.object({OfferID:zod.z.string(),Resources:b.nullish()}),_s=zod.z.object({Offers:zod.z.array(om).nullish()}),am=zod.z.object({CollectibleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rarity:zod.z.number().nullish(),HasSpecialVersion:zod.z.boolean().nullish(),SortOrder:zod.z.number().nullish()}).passthrough(),lm=zod.z.object({SetID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),SortOrder:zod.z.number().nullish(),Collectibles:zod.z.array(am).nullish(),SetCompletionReward:q.nullish()}).passthrough(),um=zod.z.object({CollectionID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),SeasonChainID:zod.z.string().nullish(),Sets:zod.z.array(lm).nullish(),GrandPrize:q.nullish()}).passthrough(),el=zod.z.object({BonusRewardSlots:te.nullish(),PityRules:te.nullish()}).passthrough(),cm=zod.z.object({PackTypeID:zod.z.string().nullish(),Cost:Z.nullish(),BonusRewardSlots:zod.z.array(vt).nullish(),PityRules:zod.z.array(Pt).nullish(),Presets:el.nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CollectibleCount:zod.z.number().nullish(),MaxOpenCount:zod.z.number().nullish(),GuaranteedMinRarity:zod.z.number().nullish(),GuaranteeMaxRarity:zod.z.boolean().nullish(),RarityWeights:zod.z.record(zod.z.string(),zod.z.number()).nullish(),ColorTier:zod.z.number().nullish()}).passthrough(),pm=zod.z.object({Rarity:zod.z.number().nullish(),CollectionCurrencyGranted:zod.z.number().nullish()}).passthrough(),dm=zod.z.object({CollectionChestID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CollectionCurrencyCost:zod.z.number().nullish(),MaxOpenCount:zod.z.number().nullish(),MinCollectibleCount:zod.z.number().nullish(),MaxCollectibleCount:zod.z.number().nullish(),GuaranteedMinRarity:zod.z.number().nullish(),BonusRewardSlots:zod.z.array(vt).nullish(),PityRules:zod.z.array(Pt).nullish(),Presets:el.nullish(),Tier:zod.z.number().nullish()}).passthrough(),hm=zod.z.object({SpecialTradeEventID:zod.z.string().nullish(),StartUtc:u.nullish(),EndUtc:u.nullish(),AllowedSpecialCollectibleIDs:zod.z.array(zod.z.string()).nullish(),SpecialTradeEventDailyTradeLimit:zod.z.number().nullish()}).passthrough(),Dr=zod.z.object({Collections:zod.z.record(zod.z.string(),um).nullish(),PackTypes:zod.z.record(zod.z.string(),cm).nullish(),CollectionChests:zod.z.array(dm).nullish(),DuplicateConversions:zod.z.array(pm).nullish(),DailyTradeLimit:zod.z.number().nullish(),CollectibleJokerCatalogID:zod.z.string().nullish(),CollectibleJokerItemID:zod.z.string().nullish(),SpecialTradeEvents:zod.z.array(hm).nullish(),RewardPools:Xi.nullish()}).passthrough(),ze={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",OpenPack:"OpenPack",OpenCollectionChest:"OpenCollectionChest",UseCollectibleJoker:"UseCollectibleJoker",ClaimSetReward:"ClaimSetReward",ClaimSetRewardsBatch:"ClaimSetRewardsBatch",ClaimGrandPrize:"ClaimGrandPrize",SendTradeOffer:"SendTradeOffer",CancelTradeOffer:"CancelTradeOffer",AcceptTradeOffer:"AcceptTradeOffer",DeclineTradeOffer:"DeclineTradeOffer",GetMyTradeOffers:"GetMyTradeOffers",GetIncomingTradeOffers:"GetIncomingTradeOffers"};var br=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Collection",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(ze.GetDefinitions,e,Dr)}getUserState(e){return this.send(ze.GetUserState,e,Va)}openPack(e){return this.send(ze.OpenPack,e,Wa)}openCollectionChest(e){return this.send(ze.OpenCollectionChest,e,Qa)}useCollectibleJoker(e){return this.send(ze.UseCollectibleJoker,e,Ka)}claimSetReward(e){return this.send(ze.ClaimSetReward,e,Vs)}claimSetRewardsBatch(e){return this.send(ze.ClaimSetRewardsBatch,e,Ha)}claimGrandPrize(e){return this.send(ze.ClaimGrandPrize,e,$a)}sendTradeOffer(e){return this.send(ze.SendTradeOffer,e,Za)}cancelTradeOffer(e){return this.send(ze.CancelTradeOffer,e,Ja)}acceptTradeOffer(e){return this.send(ze.AcceptTradeOffer,e,Ya)}declineTradeOffer(e){return this.send(ze.DeclineTradeOffer,e,Xa)}getMyTradeOffers(e){return this.send(ze.GetMyTradeOffers,e,_s)}getIncomingTradeOffers(e){return this.send(ze.GetIncomingTradeOffers,e,_s)}};var mm=zod.z.object({}).passthrough().transform(o=>o),fm={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},gm={Active:"Active",Left:"Left",Replaced:"Replaced"},Rm=zod.z.object({ObjectIndex:zod.z.number().nullish(),ObjectCompletionRewardClaimed:zod.z.boolean().nullish()}).passthrough(),ym=zod.z.object({UserID:zod.z.string().nullish(),PublicData:De.nullish(),BuildObjectsProgress:Rm.nullish(),IsBot:zod.z.boolean().nullish(),SpinsCount:zod.z.number().nullish(),TokensSpent:zod.z.number().nullish(),MemberStatus:zod.z.string().nullish(),GrandPrizeClaimed:zod.z.boolean().nullish(),JoinedAtUtc:u.nullish(),LeftAtUtc:u.nullish()}).passthrough(),Cm=zod.z.object({Index:zod.z.number().nullish(),OwnerUserID:zod.z.string().nullish(),CurrentProgress:zod.z.number().nullish(),MaxProgress:zod.z.number().nullish(),IsCompleted:zod.z.boolean().nullish()}).passthrough(),Sm=zod.z.object({Objects:zod.z.array(Cm).nullish()}).passthrough(),tl=zod.z.object({GroupID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CoopChainID:zod.z.string().nullish(),CoopEventID:zod.z.string().nullish(),CycleIndex:zod.z.number().nullish(),Members:zod.z.array(ym).nullish(),BuildObjectsState:Sm.nullish(),Status:zod.z.string().nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),Version:zod.z.number().nullish()}).passthrough(),il=zod.z.object({CoopChainID:zod.z.string()}).passthrough(),xm=zod.z.string(),Ws=zod.z.object({DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Weight:zod.z.number().nullish(),MinProgress:zod.z.number().nullish(),MaxProgress:zod.z.number().nullish()}).passthrough(),Dm=zod.z.object({Index:zod.z.number().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),MaxProgress:zod.z.number().nullish(),CompletionReward:q.nullish()}).passthrough(),bm=zod.z.object({Objects:zod.z.array(Dm).nullish(),SpinCost:Z.nullish(),SpinnerTable:zod.z.array(Ws).nullish(),MaxSpinsPerCall:zod.z.number().nullish()}).passthrough(),zm=zod.z.object({CoopEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),EventType:xm.nullish(),PartnerCount:zod.z.number().nullish(),MatchmakingTimeoutMinutes:zod.z.number().nullish(),MemberGracePeriodMinutes:zod.z.number().nullish(),BuildObjects:bm.nullish(),GrandPrize:q.nullish()}).passthrough(),Tm=zod.z.object({CoopChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:ce.nullish(),Events:zod.z.array(zm).nullish(),Gate:Q.nullish()}).passthrough(),rl=zod.z.object({ServerTimeUtc:u.nullish(),UserState:mm.nullish(),ActiveGroup:tl.nullish()}),Qs=zod.z.object({ServerTimeUtc:u.nullish(),Group:tl.nullish(),SecondsRemaining:w.nullish()}),sl=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Resources:b.nullish(),ObjectIndex:zod.z.number().nullish(),Sector:Ws.nullish(),RequestedSpins:zod.z.number().nullish(),SpinsUsed:zod.z.number().nullish(),Sectors:zod.z.array(Ws).nullish(),ProgressDelta:zod.z.number().nullish(),NewProgress:w.nullish(),MaxProgress:w.nullish(),ObjectCompleted:zod.z.boolean().nullish(),AllObjectsCompleted:zod.z.boolean().nullish()}),Ks=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),Resources:b.nullish()}),nl=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),zr=zod.z.object({Chains:zod.z.record(zod.z.string(),Tm).nullish()}).passthrough(),Ve={GetDefinitions:"GetDefinitions",GetActiveEvent:"GetActiveEvent",GetUserState:"GetUserState",GetGroupState:"GetGroupState",JoinOrCreateGroup:"JoinOrCreateGroup",Spin:"Spin",ClaimObjectReward:"ClaimObjectReward",ClaimGrandPrize:"ClaimGrandPrize",LeaveGroup:"LeaveGroup"};var Tr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"CoopEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ve.GetDefinitions,e,zr)}getActiveEvent(e){return this.send(Ve.GetActiveEvent,e,il)}getUserState(e){return this.send(Ve.GetUserState,e,rl)}getGroupState(e){return this.send(Ve.GetGroupState,e,Qs)}joinOrCreateGroup(e){return this.send(Ve.JoinOrCreateGroup,e,Qs)}spin(e){return this.send(Ve.Spin,e,sl)}claimObjectReward(e){return this.send(Ve.ClaimObjectReward,e,Ks)}claimGrandPrize(e){return this.send(Ve.ClaimGrandPrize,e,Ks)}leaveGroup(e){return this.send(Ve.LeaveGroup,e,nl)}};var vm={Active:"Active",Exhausted:"Exhausted",Expired:"Expired",Dismissed:"Dismissed"},Pm={Locked:"Locked",Available:"Available",InProgress:"InProgress",Completed:"Completed",Hidden:"Hidden"},Im=zod.z.object({NodeID:zod.z.string().nullish(),Status:zod.z.string().nullish(),ExecutionCount:zod.z.number().nullish(),UnlockedAtUtc:u.nullish(),CompletedAtUtc:u.nullish(),LastExecutedAtUtc:u.nullish(),NextAvailableAtUtc:u.nullish(),LastExecutionRefID:zod.z.string().nullish()}).passthrough(),km=zod.z.object({TrackID:zod.z.string().nullish(),CurrentValue:zod.z.number().nullish(),LastUpdatedUtc:u.nullish()}).passthrough(),ol=zod.z.object({OfferID:zod.z.string().nullish(),InstanceKey:zod.z.string().nullish(),SourceOfferVersion:zod.z.number().nullish(),Status:zod.z.string().nullish(),ActivatedAtUtc:u.nullish(),ExhaustedAtUtc:u.nullish(),ExpiredAtUtc:u.nullish(),DismissedAtUtc:u.nullish(),ShowCount:zod.z.number().nullish(),LastShownAtUtc:u.nullish(),Nodes:zod.z.record(zod.z.string(),Im).nullish(),Tracks:zod.z.record(zod.z.string(),km).nullish(),SelectedChoiceNodeID:zod.z.string().nullish()}).passthrough(),Mm=zod.z.object({SlotID:zod.z.string().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),ActiveOfferID:zod.z.string().nullish(),ActiveOfferStartedAtUtc:u.nullish(),ActiveOfferExpiresAtUtc:u.nullish(),ActiveOffer:ol.nullish(),NextCycleStartsAtUtc:u.nullish(),LastUpdatedUtc:u.nullish(),DismissSkipAvailableAtUtc:u.nullish(),LastDismissedAtUtc:u.nullish()}).passthrough(),wm=zod.z.object({TotalExecutions:zod.z.number().nullish(),DailyExecutions:zod.z.number().nullish(),DailyResetUtc:u.nullish()}).passthrough(),Am=zod.z.object({TotalActivations:zod.z.number().nullish(),TotalExhausted:zod.z.number().nullish(),TotalExpired:zod.z.number().nullish(),TotalDismissed:zod.z.number().nullish(),TotalShows:zod.z.number().nullish(),LastShownAtUtc:u.nullish(),LastActivatedAtUtc:u.nullish(),LastExhaustedAtUtc:u.nullish(),NodeCounts:zod.z.record(zod.z.string(),wm).nullish()}).passthrough(),Um=zod.z.object({Slots:zod.z.record(zod.z.string(),Mm).nullish(),OfferHistory:zod.z.record(zod.z.string(),Am).nullish(),LastUpdatedUtc:u.nullish()}).passthrough();var Om=zod.z.object({Order:zod.z.number().nullish(),OfferID:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),DelayBeforeActivationSec:zod.z.number().nullish()}).passthrough(),Bm=zod.z.object({SlotID:zod.z.string().nullish(),Enabled:zod.z.boolean().nullish(),SortOrder:zod.z.number().nullish(),Queue:zod.z.array(Om).nullish(),Schedule:ce.nullish(),Gate:Q.nullish(),AllowDismissSkip:zod.z.boolean().nullish(),DismissSkipDelaySec:zod.z.number().nullish()}).passthrough(),Lm=zod.z.object({StoreOfferID:zod.z.string().nullish(),BillingProductID:zod.z.string().nullish(),DirectCost:Z.nullish(),UseExternalRewards:zod.z.boolean().nullish()}).passthrough(),qm=zod.z.object({AdPlacementID:zod.z.string().nullish(),ViewsRequiredToComplete:zod.z.number().nullish(),MaxViewsPerActivation:zod.z.number().nullish(),CooldownSecondsBetweenViews:zod.z.number().nullish(),RequireServerVerification:zod.z.boolean().nullish(),GrantRewardsPerView:zod.z.boolean().nullish()}).passthrough(),Em=zod.z.object({Purchase:Lm.nullish(),RewardedVideo:qm.nullish()}).passthrough(),Gm=zod.z.object({TrackID:zod.z.string().nullish(),Operator:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),Nm=zod.z.object({Milestones:te.nullish()}).passthrough(),jm=zod.z.object({TrackID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),RespectBounds:zod.z.boolean().nullish()}).passthrough(),Fm=zod.z.object({TrackID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),StartValue:zod.z.number().nullish(),MinValue:zod.z.number().nullish(),MaxValue:zod.z.number().nullish(),ClampToMin:zod.z.boolean().nullish(),ClampToMax:zod.z.boolean().nullish(),HiddenFromUI:zod.z.boolean().nullish()}).passthrough(),Vm=zod.z.object({RequiredCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredAnyCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredTracks:zod.z.array(Gm).nullish(),VisibleWhileLocked:zod.z.boolean().nullish()}).passthrough(),_m=zod.z.object({NodeID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),Type:zod.z.string().nullish(),Action:Em.nullish(),Grants:q.nullish(),TrackChanges:zod.z.array(jm).nullish(),MilestonePoints:zod.z.number().nullish(),UnlockRules:Vm.nullish(),NextNodeIDs:zod.z.array(zod.z.string()).nullish(),ChoiceGroupID:zod.z.string().nullish(),Limits:ge.nullish(),HideWhenCompleted:zod.z.boolean().nullish(),ExhaustOfferOnComplete:zod.z.boolean().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Metadata:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),al=zod.z.object({OfferID:zod.z.string().nullish(),Version:zod.z.number().nullish(),Enabled:zod.z.boolean().nullish(),GraphMode:zod.z.string().nullish(),Name:zod.z.string().nullish(),Description:zod.z.string().nullish(),RootNodeIDs:zod.z.array(zod.z.string()).nullish(),Nodes:zod.z.array(_m).nullish(),Tracks:zod.z.array(Fm).nullish(),Milestones:zod.z.record(zod.z.string(),xe).nullish(),Presets:Nm.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneToken:ct.nullish(),ExhaustedWhenAllTerminalNodesCompleted:zod.z.boolean().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Metadata:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Wm=zod.z.object({Milestones:zod.z.record(zod.z.string(),rt).nullish()}).passthrough(),Hs=zod.z.object({Slots:zod.z.record(zod.z.string(),Bm).nullish(),Offers:zod.z.record(zod.z.string(),al).nullish(),Presets:Wm.nullish()}).passthrough(),ll=zod.z.object({DealOfferDefinitions:Hs.nullish()}),ul=zod.z.object({DealOffers:Um.nullish()}),Qm=zod.z.object({EntityID:zod.z.string().nullish(),TotalEarned:zod.z.number().nullish(),ClaimedIDs:zod.z.array(zod.z.string()).nullish(),ReachedUnclaimedIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),Km=zod.z.object({SlotID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),OfferDef:al.nullish(),ActivationState:ol.nullish(),IsNewActivation:zod.z.boolean().nullish(),ComputedExpiresAtUtc:u.nullish(),Cost:Z.nullish(),Milestone:Qm.nullish()}).passthrough(),cl=zod.z.object({Slots:zod.z.array(Km).nullish()}),pl=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),NodeID:zod.z.string().nullish(),NodeCompleted:zod.z.boolean().nullish(),OfferExhausted:zod.z.boolean().nullish(),Idempotent:zod.z.boolean().nullish(),Resources:b.nullish()}),dl=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),Resources:b.nullish()}),hl=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),Resources:b.nullish()}),ml=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:b.nullish()}),fl=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),ClaimedIDs:zod.z.array(zod.z.string()).nullish(),Rejected:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Resources:b.nullish()}),He={GetDefinition:"GetDefinition",GetUserState:"GetUserState",GetActiveDeals:"GetActiveDeals",DismissDeal:"DismissDeal",ExecuteNode:"ExecuteNode",RecordShow:"RecordShow",ClaimMilestone:"ClaimMilestone",ClaimMilestonesBatch:"ClaimMilestonesBatch"};var vr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"DealOffer",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinition(e){return this.send(He.GetDefinition,e,ll)}getUserState(e){return this.send(He.GetUserState,e,ul)}getActiveDeals(e){return this.send(He.GetActiveDeals,e,cl)}dismissDeal(e){return this.send(He.DismissDeal,e,dl)}executeNode(e){return this.send(He.ExecuteNode,e,pl)}recordShow(e){return this.send(He.RecordShow,e,hl)}claimMilestone(e){return this.send(He.ClaimMilestone,e,ml)}claimMilestonesBatch(e){return this.send(He.ClaimMilestonesBatch,e,fl)}};var Hm=zod.z.object({}).passthrough().transform(o=>o),$m=zod.z.object({FeatureKey:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Percent:zod.z.number().nullish(),SourceCurrencyID:zod.z.string().nullish(),TargetCurrencyID:zod.z.string().nullish()}).passthrough(),$s=zod.z.object({IsEnabled:zod.z.boolean().nullish(),ActivationReward:q.nullish(),InviteRewards:zod.z.record(zod.z.string(),xe).nullish(),SpendRewards:zod.z.array($m).nullish()}).passthrough(),gl=zod.z.object({ReferralDefinitions:$s.nullish()}),Rl=zod.z.object({Referral:Hm.nullish()}),yl=zod.z.object({ReferralCode:zod.z.string().nullish(),IsFirstActivation:zod.z.boolean().nullish(),Resources:b.nullish()}),Zs=zod.z.object({RewardID:zod.z.string().nullish(),Resources:b.nullish()}),Cl=st(Zs),ht={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateReferralCode:"ActivateReferralCode",ClaimInviteReward:"ClaimInviteReward",ClaimInviteRewardsBatch:"ClaimInviteRewardsBatch"};var Pr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Referral",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(ht.GetDefinitions,e,gl)}getUserState(e){return this.send(ht.GetUserState,e,Rl)}activateReferralCode(e){return this.send(ht.ActivateReferralCode,e,yl)}claimInviteReward(e){return this.send(ht.ClaimInviteReward,e,Zs)}claimInviteRewardsBatch(e){return this.send(ht.ClaimInviteRewardsBatch,e,Cl)}};var Zm={RequestSent:"RequestSent",Accepted:"Accepted",Declined:"Declined",Removed:"Removed"},Jm={Attack:"Attack",Raid:"Raid",FriendAdd:"FriendAdd"},Sl=zod.z.object({UserID:zod.z.string(),PublicData:De.nullish()}),Ym=zod.z.object({OwnerUserID:zod.z.string().nullish(),ActorUserID:zod.z.string().nullish(),ActorProfile:De.nullish(),Type:zod.z.string().nullish(),CreatedAt:u.nullish(),OwnerImpact:b.nullish(),IsBlocked:zod.z.boolean().nullish(),TargetObjectName:zod.z.string().nullish()}).passthrough(),Ir=zod.z.object({Friends:zod.z.array(Sl).nullish()}),Xm=zod.z.object({FriendsCount:zod.z.number().nullish(),IncomingRequestsCount:zod.z.number().nullish(),OutgoingRequestsCount:zod.z.number().nullish()}),Lt=zod.z.object({TargetUserID:zod.z.string().nullish(),Status:zod.z.string().nullish(),Target:Sl.nullish(),Counters:Xm.nullish()}),xl=zod.z.object({Events:zod.z.array(Ym).nullish()}),$e={GetFriendsList:"GetFriendsList",GetIncomingRequests:"GetIncomingRequests",GetRecommendedFriends:"GetRecommendedFriends",SendFriendRequest:"SendFriendRequest",AcceptFriendRequest:"AcceptFriendRequest",DeclineFriendRequest:"DeclineFriendRequest",RemoveFriend:"RemoveFriend",GetTimeline:"GetTimeline"};var kr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Social",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getFriendsList(e){return this.send($e.GetFriendsList,e,Ir)}getIncomingRequests(e){return this.send($e.GetIncomingRequests,e,Ir)}getRecommendedFriends(e){return this.send($e.GetRecommendedFriends,e,Ir)}sendFriendRequest(e){return this.send($e.SendFriendRequest,e,Lt)}acceptFriendRequest(e){return this.send($e.AcceptFriendRequest,e,Lt)}declineFriendRequest(e){return this.send($e.DeclineFriendRequest,e,Lt)}removeFriend(e){return this.send($e.RemoveFriend,e,Lt)}getTimeline(e){return this.send($e.GetTimeline,e,xl)}};var ef={Replace:"Replace",Refresh:"Refresh",KeepBest:"KeepBest",Stack:"Stack"};var kt=zod.z.object({Target:zod.z.string().nullish(),Operation:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),tf=zod.z.object({BoostID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),ActivationCost:Z.nullish(),Effect:kt.nullish(),DurationSeconds:zod.z.number().nullish(),Charges:zod.z.number().nullish(),StackingPolicy:zod.z.string().nullish(),MaxActiveInstances:zod.z.number().nullish(),Tags:zod.z.array(zod.z.string()).nullish()}).passthrough(),rf=zod.z.object({ScheduledBoostID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Tags:zod.z.array(zod.z.string()).nullish(),Schedule:ce.nullish(),Effects:zod.z.array(kt).nullish(),Gate:Q.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),sf=zod.z.object({ChainedBoostID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Effects:zod.z.array(kt).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),nf=zod.z.object({ChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Schedule:ce.nullish(),Phases:zod.z.array(sf).nullish(),Gate:Q.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),of=zod.z.object({TriggeredBoostID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Tags:zod.z.array(zod.z.string()).nullish(),Sources:zod.z.array(Ue).nullish(),Effects:zod.z.array(kt).nullish(),DurationSeconds:zod.z.number().nullish(),Charges:zod.z.number().nullish(),StackingPolicy:zod.z.string().nullish(),MaxActiveInstances:zod.z.number().nullish(),Gate:Q.nullish()}).passthrough(),af=zod.z.object({MaxAddPercent:zod.z.number().nullish(),MaxMultiply:zod.z.number().nullish(),MaxAddFlat:zod.z.number().nullish()}).passthrough(),lf=zod.z.object({StackingCaps:zod.z.record(zod.z.string(),af).nullish()}).passthrough(),Mr=zod.z.object({Definitions:zod.z.record(zod.z.string(),tf).nullish(),ScheduledBoosts:zod.z.record(zod.z.string(),rf).nullish(),BoostChains:zod.z.record(zod.z.string(),nf).nullish(),TriggeredBoosts:zod.z.record(zod.z.string(),of).nullish(),Settings:lf.nullish()}).passthrough(),Dl=zod.z.object({InstanceID:zod.z.string(),BoostID:zod.z.string(),ActivatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),RemainingCharges:zod.z.number().nullish(),EffectSnapshot:kt.nullish(),SourceType:zod.z.string().nullish(),SourceRef:zod.z.string().nullish()}).passthrough();zod.z.object({Date:u.nullish(),DailyCount:zod.z.number().nullish(),LastFiredUtc:u.nullish()}).passthrough();var bl=zod.z.object({ServerTimeUtc:u.nullish(),Active:zod.z.record(zod.z.string(),Dl).nullish()}),zl=zod.z.object({ServerTimeUtc:u.nullish(),BoostID:zod.z.string().nullish(),StackingPolicy:zod.z.string().nullish(),ActivatedBoost:Dl.nullish(),Resources:b.nullish()}),uf={Scheduled:"Scheduled",Chain:"Chain"},cf=zod.z.object({Kind:zod.z.string().nullish(),SourceID:zod.z.string().nullish(),PhaseID:zod.z.string().nullish(),CycleIndex:zod.z.number().nullish(),PhaseOrder:zod.z.number().nullish(),StartUtc:u.nullish(),EndUtc:u.nullish(),Effects:zod.z.array(kt).nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Tl=zod.z.object({ServerTimeUtc:u.nullish(),Windows:zod.z.array(cf).nullish()}),mt={GetDefinitions:"GetDefinitions",GetActive:"GetActive",GetActiveWindows:"GetActiveWindows",Activate:"Activate",CleanupExpired:"CleanupExpired"};var wr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"TimedBoost",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(mt.GetDefinitions,e,Mr)}getActive(e){return this.send(mt.GetActive,e,bl)}getActiveWindows(e){return this.send(mt.GetActiveWindows,e,Tl)}activate(e){return this.send(mt.Activate,e,zl)}cleanupExpired(e){return this.send(mt.CleanupExpired,e,be)}};var Ar=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"UserCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getUserCustomDataDefinitions(e){return this.send(Fe.GetUserCustomDataDefinitions,e,Pi)}getMyUserCustomData(e){return this.send(Fe.GetMyUserCustomData,e,Vn)}getPublicUserCustomDataOf(e){return this.send(Fe.GetPublicUserCustomDataOf,e,ls)}setPrivateData(e){return this.send(Fe.SetPrivateData,e,us)}setPublicData(e){return this.send(Fe.SetPublicData,e,us)}deleteKey(e){return this.send(Fe.DeleteKey,e,be)}batchSet(e){return this.send(Fe.BatchSet,e,_n)}batchDelete(e){return this.send(Fe.BatchDelete,e,Wn)}batchGetPublicUserCustomDataOf(e){return this.send(Fe.BatchGetPublicUserCustomDataOf,e,Qn)}};var pf={Static:"Static",Runtime:"Runtime"},df={Public:"Public",Private:"Private"},hf=zod.z.enum(["Client","Server","System"]),mf=zod.z.enum(["String","Int","Bool","Json"]),ff=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:u.nullish(),Version:zod.z.number().nullish(),LastWriter:hf.nullish(),ExpiresAt:u.nullish()}).passthrough(),vl=zod.z.record(zod.z.string(),ff),Js=zod.z.object({StaticVersion:zod.z.number().nullish(),RuntimeVersion:zod.z.number().nullish(),Static:vl.nullish(),Runtime:vl.nullish(),NotModified:zod.z.boolean().nullish()}),gf=zod.z.object({KeyID:zod.z.string(),Scope:zod.z.enum(["Static","Runtime"]).nullish(),Bucket:zod.z.enum(["Public","Private"]).nullish(),ValueType:mf.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),Ur=zod.z.object({Keys:zod.z.record(zod.z.string(),gf).nullish(),DefaultMaxValueLengthBytes:zod.z.number().nullish(),DefaultTtlSeconds:zod.z.number().nullish(),MaxKeysPerBucket:zod.z.number().nullish(),MaxTotalSizeBytes:zod.z.number().nullish(),RejectUnregisteredKeys:zod.z.boolean().nullish()}).passthrough(),qt={GetTitleCustomDataDefinitions:"GetTitleCustomDataDefinitions",GetPublicTitleData:"GetPublicTitleData",GetPublicTitleDataKeys:"GetPublicTitleDataKeys"};var Or=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"TitleCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getTitleCustomDataDefinitions(e){return this.send(qt.GetTitleCustomDataDefinitions,e,Ur)}getPublicTitleData(e){return this.send(qt.GetPublicTitleData,e,Js)}getPublicTitleDataKeys(e){return this.send(qt.GetPublicTitleDataKeys,e,Js)}};var Rf={Fast:"Fast",Sequential:"Sequential"},yf={Instant:"Instant",Timed:"Timed"},Cf={Hit:"Hit",Blocked:"Blocked"},Sf=zod.z.object({SlotIndex:zod.z.number(),Level:zod.z.number().nullish(),IsDamaged:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish()}).passthrough(),xf=zod.z.object({Symbol:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),OnOpenBonus:q.nullish(),BonusTag:zod.z.string().nullish()}).passthrough();zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:q.nullish()}).passthrough();zod.z.object({PlayedCount:zod.z.number().nullish(),RewardsClaimedCount:zod.z.number().nullish(),InstantClaimsCount:zod.z.number().nullish(),EarlyClaimsCount:zod.z.number().nullish(),LateClaimsCount:zod.z.number().nullish(),AdViewsTotal:zod.z.number().nullish()}).passthrough();var Pl=zod.z.object({}).passthrough().transform(o=>o),Il=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),Pe=zod.z.object({Operation:b.nullish(),ScaleWithRollMultiplier:zod.z.boolean().nullish()}).passthrough(),Df=zod.z.object({Count:zod.z.number().nullish(),Sides:zod.z.number().nullish()}).passthrough(),bf=zod.z.object({ShieldChance:zod.z.number().nullish(),DamagedBuildingChance:zod.z.number().nullish(),RankMultiplierMin:zod.z.number().nullish(),RankMultiplierMax:zod.z.number().nullish(),RankOffsetMin:zod.z.number().nullish(),RankOffsetMax:zod.z.number().nullish()}).passthrough(),zf=zod.z.object({CostMatrixTemplatesByID:zod.z.record(zod.z.string(),zod.z.array(zod.z.array(zod.z.number()))).nullish(),PerBoardGrowth:zod.z.number().nullish(),VisualTemplateCycle:zod.z.array(zod.z.string()).nullish(),EconomyScaledResources:me.nullish(),ScaleRaidStealWithEconomy:zod.z.boolean().nullish(),ScaleAttackRewardWithEconomy:zod.z.boolean().nullish(),AttackValueFromCostMatrix:zod.z.boolean().nullish(),AttackBlockedRewardFactor:zod.z.number().nullish(),ScaleVictimLossWithEconomy:zod.z.boolean().nullish(),ScaleVictimLossWithTier:zod.z.boolean().nullish(),SynthesizedBuildingSlots:zod.z.number().nullish(),SynthesizedBuildingMaxLevel:zod.z.number().nullish()}).passthrough(),Tf=zod.z.object({CostMatrix:zod.z.array(zod.z.array(zod.z.number())).nullish(),PerBoardGrowth:zod.z.number().nullish(),EconomyScale:zod.z.number().nullish(),ScaledResources:me.nullish()}).passthrough(),kl=zod.z.object({SlotIndex:zod.z.number().nullish(),Name:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),MaxLevel:zod.z.number().nullish(),MaxLevelReward:q.nullish()}).passthrough(),vf=zod.z.object({Index:zod.z.number().nullish(),Type:zod.z.string().nullish(),CustomTypeID:zod.z.string().nullish(),RandomActionAttackWeight:zod.z.number().nullish(),RandomActionRaidWeight:zod.z.number().nullish(),ChanceTableID:zod.z.string().nullish(),SpecialModeID:zod.z.string().nullish(),Params:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Pf=zod.z.object({Tiles:zod.z.record(zod.z.string(),vf).nullish()}).passthrough(),If=zod.z.object({Weight:zod.z.number().nullish(),Bonus:Pe.nullish(),Tag:zod.z.string().nullish()}).passthrough(),kf=zod.z.object({Weight:zod.z.number().nullish(),Tag:zod.z.string().nullish(),MinBonusCells:zod.z.number().nullish(),MaxBonusCells:zod.z.number().nullish(),BonusPool:zod.z.array(If).nullish(),GuaranteedBonus:Pe.nullish(),IsJackpot:zod.z.boolean().nullish(),JackpotFinalMultiplier:zod.z.number().nullish(),JackpotSymbolDistribution:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough(),Mf=zod.z.object({Variants:zod.z.array(kf).nullish()}).passthrough(),wf=zod.z.object({Weight:zod.z.number().nullish(),OutcomeID:zod.z.string().nullish(),Reward:Pe.nullish(),ForceAction:zod.z.string().nullish(),SpecialModeID:zod.z.string().nullish()}).passthrough(),Af=zod.z.object({Outcomes:zod.z.array(wf).nullish()}).passthrough(),Ml=zod.z.object({PerAdMultiplierRange:Il.nullish(),MaxAdViews:zod.z.number().nullish(),AdCreditCost:zod.z.number().nullish(),FormulaKind:zod.z.string().nullish(),ApplyMultiplierOnEarlyClaim:zod.z.boolean().nullish()}).passthrough(),Uf=zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:Pe.nullish()}).passthrough(),Of=zod.z.object({Tiers:zod.z.array(Uf).nullish(),BelowFirstTierReward:Pe.nullish()}).passthrough(),Bf=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:Pe.nullish(),DurationSeconds:zod.z.number().nullish(),EntryCost:Z.nullish(),Multipliers:Ml.nullish(),Gradation:Of.nullish()}).passthrough(),Lf=zod.z.object({Choices:zod.z.array(Bf).nullish(),OfferExpireSeconds:zod.z.number().nullish(),ClaimExpireSeconds:zod.z.number().nullish()}).passthrough(),qf=zod.z.object({Chance:zod.z.number().nullish(),RequiredOutcome:zod.z.string().nullish(),Reward:Pe.nullish(),Tag:zod.z.string().nullish()}).passthrough(),Ef=zod.z.object({OnPassStart:Pe.nullish(),OnTileLanding:zod.z.record(zod.z.string(),Pe).nullish(),OnAttack:zod.z.record(zod.z.string(),Pe).nullish(),OnRaid:zod.z.record(zod.z.string(),Pe).nullish(),OnBuild:Pe.nullish(),OnStageComplete:Pe.nullish(),OnAttackBonusDrops:zod.z.array(qf).nullish(),ChanceTablesByID:zod.z.record(zod.z.string(),Af).nullish(),SpecialModesByID:zod.z.record(zod.z.string(),Lf).nullish()}).passthrough(),wl=zod.z.object({BaseAttackReward:q.nullish(),BaseRaidReward:q.nullish(),MaxRollMultiplier:zod.z.number().nullish(),MaxShields:zod.z.number().nullish(),Buildings:zod.z.array(kl).nullish(),HeistGridBonusConfig:Mf.nullish(),StageOperations:Ef.nullish(),TileLandingMultiplier:Il.nullish(),EconomyOverride:Tf.nullish()}).passthrough(),Gf=zod.z.object({Name:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),BoardTemplateID:zod.z.string().nullish(),Buildings:zod.z.array(kl).nullish(),StageTemplateID:zod.z.string().nullish(),CostMatrixTemplateID:zod.z.string().nullish(),UnitValue:zod.z.number().nullish(),Override:wl.nullish()}).passthrough(),Br=zod.z.object({RollCurrencyID:zod.z.string().nullish(),ShieldCurrencyID:zod.z.string().nullish(),RaidMode:zod.z.string().nullish(),AllowedRollMultipliers:zod.z.array(zod.z.number()).nullish(),BoardTemplatesByID:zod.z.record(zod.z.string(),Pf).nullish(),StageTemplatesByID:zod.z.record(zod.z.string(),wl).nullish(),StagesByLevel:zod.z.record(zod.z.string(),Gf).nullish(),SoftCurrencyID:zod.z.string().nullish(),ProceduralEconomy:zf.nullish(),Dice:Df.nullish(),Bots:bf.nullish()}).passthrough(),Nf=zod.z.object({IsActive:zod.z.boolean().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),AnchorUtc:u.nullish(),RoundDurationSec:zod.z.number().nullish(),PauseBetweenRoundsSec:zod.z.number().nullish(),MaxRounds:zod.z.number().nullish(),PartnerCount:zod.z.number().nullish(),MatchmakingTimeoutMinutes:zod.z.number().nullish(),MemberGracePeriodMinutes:zod.z.number().nullish(),ContributionMin:zod.z.number().nullish(),ContributionMax:zod.z.number().nullish(),ScaleContributionWithRollMultiplier:zod.z.boolean().nullish(),MaxProgress:zod.z.number().nullish(),Milestones:zod.z.record(zod.z.string(),xe).nullish(),GrandPrize:q.nullish()}).passthrough(),Lr=zod.z.object({Board:Br.nullish(),CommunityChest:Nf.nullish()}).passthrough(),jf=zod.z.object({TargetUserID:zod.z.string().nullish(),IsBot:zod.z.boolean().nullish(),PublicData:De.nullish(),TargetBuildingStates:zod.z.array(Sf).nullish(),TargetHasShield:zod.z.boolean().nullish()}).passthrough(),Ff=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:Pe.nullish(),DurationSeconds:zod.z.number().nullish(),EntryCost:Z.nullish(),Multipliers:Ml.nullish()}).passthrough(),Vf=zod.z.object({ModeID:zod.z.string().nullish(),Choices:zod.z.array(Ff).nullish()}).passthrough(),_f=zod.z.object({GroupID:zod.z.string().nullish(),Delta:w.nullish(),NewProgress:w.nullish(),MaxProgress:w.nullish(),UnlockedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),Completed:zod.z.boolean().nullish()}).passthrough(),Al=zod.z.object({UsedMultiplier:zod.z.number().nullish(),Steps:zod.z.number().nullish(),OldPosition:zod.z.number().nullish(),NewPosition:zod.z.number(),CyclesCompletedDelta:w.nullish(),LandedTileType:zod.z.string().nullish(),Operation:b.nullish(),ActionRequired:zod.z.string().nullish(),ActionData:jf.nullish(),SpecialModeOffer:Vf.nullish(),CommunityChestContribution:_f.nullish()}).passthrough(),Ul=zod.z.object({Outcome:zod.z.string().nullish(),IsBotTarget:zod.z.boolean().nullish(),BuildingIndexHit:zod.z.number().nullish(),Operation:b.nullish(),DualResult:ut.nullish()}).passthrough(),Ys=zod.z.object({Status:zod.z.string().nullish(),Outcome:zod.z.string().nullish(),FoundSymbol:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),FoundBonus:q.nullish(),OpenedIndex:zod.z.number().nullish(),AttemptsLeft:zod.z.number().nullish(),RaidLayout:zod.z.array(xf).nullish(),HeistVariantTag:zod.z.string().nullish(),IsJackpot:zod.z.boolean().nullish(),Operation:b.nullish(),DualResult:ut.nullish()}).passthrough(),Ol=zod.z.object({BuiltIndex:zod.z.number(),NewLevel:zod.z.number().nullish(),StageComplete:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish(),Operation:b.nullish()}).passthrough(),Bl=zod.z.object({Mode:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),Operation:b.nullish(),DurationSeconds:zod.z.number().nullish(),StartedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish()}).passthrough(),Ll=zod.z.object({AdViewsUsed:zod.z.number().nullish(),RolledMultiplier:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),RemainingAdViews:zod.z.number().nullish()}).passthrough(),ql=zod.z.object({FinalMultiplier:zod.z.number().nullish(),AdViewsUsed:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),IsEarlyClaim:zod.z.boolean().nullish(),Operation:b.nullish()}).passthrough(),Wf={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},El=zod.z.enum(["Forming","Active","Completed","Failed","Expired"]),Qf={Active:"Active",Left:"Left",Replaced:"Replaced"},Kf=zod.z.enum(["Active","Left","Replaced"]),Hf=zod.z.object({CurrentProgress:w.nullish(),MaxProgress:w.nullish()}).passthrough(),$f=zod.z.object({UserID:zod.z.string().nullish(),PublicData:De.nullish(),IsBot:zod.z.boolean().nullish(),ContributionPoints:w.nullish(),ClaimedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),GrandPrizeClaimed:zod.z.boolean().nullish(),MemberStatus:Kf.nullish(),JoinedAtUtc:u.nullish(),LeftAtUtc:u.nullish()}).passthrough(),Gl=zod.z.object({GroupID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),Members:zod.z.array($f).nullish(),SharedProgress:Hf.nullish(),Status:El.nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),Version:zod.z.number().nullish()}).passthrough(),Zf=zod.z.object({GroupID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),FinalStatus:El.nullish(),GrandPrizeReceived:zod.z.boolean().nullish(),FinishedAtUtc:u.nullish()}).passthrough(),Jf=zod.z.object({ActiveGroupID:zod.z.string().nullish(),ActiveRoundIndex:zod.z.number().nullish(),History:zod.z.array(Zf).nullish()}).passthrough(),Nl=zod.z.object({ServerTimeUtc:u.nullish(),UserState:Jf.nullish(),ActiveGroup:Gl.nullish(),SecondsRemaining:w.nullish()}),jl=zod.z.object({ServerTimeUtc:u.nullish(),Group:Gl.nullish(),SecondsRemaining:w.nullish()}),Xs=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:b.nullish()}),Fl=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),Ce={GetGameLoops:"GetGameLoops",GetBoardDefinition:"GetBoardDefinition",GetBoardDefinitionForLevel:"GetBoardDefinitionForLevel",GetUserBoardState:"GetUserBoardState",BoardLoopRoll:"BoardLoopRoll",BoardLoopAttack:"BoardLoopAttack",BoardLoopRaid:"BoardLoopRaid",BoardLoopRaidFast:"BoardLoopRaidFast",BoardLoopBuild:"BoardLoopBuild",BoardSpecialChoose:"BoardSpecialChoose",BoardSpecialApplyMultiplier:"BoardSpecialApplyMultiplier",BoardSpecialClaim:"BoardSpecialClaim",GetCommunityChestState:"GetCommunityChestState",JoinOrCreateCommunityChest:"JoinOrCreateCommunityChest",ClaimCommunityChestMilestone:"ClaimCommunityChestMilestone",ClaimCommunityChestGrandPrize:"ClaimCommunityChestGrandPrize",LeaveCommunityChest:"LeaveCommunityChest"};var Yf=zod.z.object({VariantID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Weight:zod.z.number().nullish(),IsControl:zod.z.boolean().nullish(),Params:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Xf=zod.z.object({ExperimentID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Schedule:ce.nullish(),Gate:Q.nullish(),Variants:zod.z.array(Yf).nullish(),Salt:zod.z.string().nullish(),LayerID:zod.z.string().nullish(),StickyAssignment:zod.z.boolean().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Vl=zod.z.object({Experiments:zod.z.record(zod.z.string(),Xf).nullish()}).passthrough();var eg={Mesh:"Mesh",Host:"Host"},en=zod.z.enum(["Mesh","Host"]),tg={ServerRelay:"ServerRelay",P2P:"P2P"},tn=zod.z.enum(["ServerRelay","P2P"]),ig={Public:"Public",Private:"Private"},rg=zod.z.enum(["Public","Private"]),sg={Signal:"Signal",Chat:"Chat",PlayerJoined:"PlayerJoined",PlayerLeft:"PlayerLeft",HostChanged:"HostChanged",RoomClosed:"RoomClosed",MemberState:"MemberState"},ng=zod.z.enum(["Signal","Chat","PlayerJoined","PlayerLeft","HostChanged","RoomClosed","MemberState"]),_l=zod.z.object({Urls:zod.z.string().nullish(),Username:zod.z.string().nullish(),Credential:zod.z.string().nullish()}).passthrough(),og=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),Wl=zod.z.object({SystemState:og.nullish(),DefaultTopology:en.nullish(),AllowCreatorTopologyOverride:zod.z.boolean().nullish(),DefaultChatMode:tn.nullish(),AllowCreatorChatOverride:zod.z.boolean().nullish(),MaxPlayersPerRoom:zod.z.number().nullish(),RoomTtlSeconds:zod.z.number().nullish(),HeartbeatIntervalMs:zod.z.number().nullish(),MemberTimeoutMs:zod.z.number().nullish(),MaxSignalPayloadBytes:zod.z.number().nullish(),MaxChatTextLength:zod.z.number().nullish(),RoomLogCap:zod.z.number().nullish(),IceServers:zod.z.array(_l).nullish()}).passthrough(),ag=zod.z.object({UserID:zod.z.string().nullish(),Username:zod.z.string().nullish(),AvatarUrl:zod.z.string().nullish(),Level:zod.z.number().nullish(),Power:zod.z.number().nullish(),Ready:zod.z.boolean().nullish(),State:zod.z.record(zod.z.string(),zod.z.string()).nullish(),JoinedAt:zod.z.number().nullish(),IsHost:zod.z.boolean().nullish(),LastSeenMs:zod.z.number().nullish()}).passthrough(),lg=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),Topology:en.nullish(),ChatMode:tn.nullish(),MaxPlayers:zod.z.number().nullish(),MemberCount:zod.z.number().nullish(),CreatedAt:zod.z.number().nullish()}).passthrough(),ug=zod.z.object({Seq:zod.z.number().nullish(),Type:ng.nullish(),FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),Kind:zod.z.string().nullish(),Payload:zod.z.string().nullish(),Ts:zod.z.number().nullish()}).passthrough(),qr=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),OwnerUserID:zod.z.string().nullish(),Topology:en.nullish(),ChatMode:tn.nullish(),Visibility:rg.nullish(),Status:zod.z.string().nullish(),MaxPlayers:zod.z.number().nullish(),Members:zod.z.array(ag).nullish(),IceServers:zod.z.array(_l).nullish(),Seq:zod.z.number().nullish()}).passthrough(),rn=zod.z.object({Closed:zod.z.boolean().nullish(),NewHostUserID:zod.z.string().nullish()}).passthrough(),Ql=zod.z.object({Rooms:zod.z.array(lg).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}).passthrough(),Kl=zod.z.object({Envelopes:zod.z.array(ug).nullish(),MaxSeq:zod.z.number().nullish()}).passthrough(),Er=zod.z.object({Seq:zod.z.number().nullish()}).passthrough(),Ee={CreateRoom:"CreateRoom",JoinRoom:"JoinRoom",LeaveRoom:"LeaveRoom",ListRooms:"ListRooms",GetRoom:"GetRoom",CloseRoom:"CloseRoom",Poll:"Poll",SendSignal:"SendSignal",SendChat:"SendChat",SetMemberState:"SetMemberState"};var sn=zod.z.object({TitleCustomData:Ur.nullish(),Character:Bi.nullish(),Item:$i.nullish(),Currency:Oi.nullish(),Store:Ji.nullish(),Lootbox:Us.nullish(),Quest:_t.nullish(),TimedEvent:or.nullish(),Leaderboard:dr.nullish(),Season:mr.nullish(),Reward:Os.nullish(),Collection:Dr.nullish(),Craft:Fs.nullish(),DealOffer:Hs.nullish(),Premium:js.nullish(),TimedBoost:Mr.nullish(),CoopEvent:zr.nullish(),GameLoop:Lr.nullish(),Match:zs.nullish(),Experiment:Vl.nullish(),Blockchain:Rs.nullish(),Marketplace:Is.nullish(),Multiplayer:Wl.nullish(),UserCustomData:Pi.nullish(),Referral:$s.nullish(),Localization:Zo.nullish()}).passthrough();var ft={GetTitlePublicConfiguration:"GetTitlePublicConfiguration",GetTitlePublicConfigurationExcept:"GetTitlePublicConfigurationExcept",GetCurrencyDefinitions:"GetCurrencyDefinitions",GetItemDefinitions:"GetItemDefinitions",GetServerTime:"GetServerTime"};var Gr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Title",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getTitlePublicConfiguration(e){return this.send(ft.GetTitlePublicConfiguration,e,sn)}getTitlePublicConfigurationExcept(e){return this.send(ft.GetTitlePublicConfigurationExcept,e,sn)}getCurrencyDefinitions(e){return this.send(ft.GetCurrencyDefinitions,e,Oi)}getItemDefinitions(e){return this.send(ft.GetItemDefinitions,e,$i)}getServerTime(e){return this.send(ft.GetServerTime,e,be)}};var Nr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i,r=false){let s=A(this.ctx.settings.titleID,"GameLoop",e,t.UserID??"");return this.ctx.transport.post(s,t,i,{ticket:t.ClientSessionTicket,silent:r})}getGameLoops(e){return this.send(Ce.GetGameLoops,e,Lr)}getBoardDefinition(e,t=false){return this.send(Ce.GetBoardDefinition,e,Br,t)}getBoardDefinitionForLevel(e,t=false){return this.send(Ce.GetBoardDefinitionForLevel,e,Br,t)}getUserBoardState(e){return this.send(Ce.GetUserBoardState,e,Pl)}boardLoopRoll(e){return this.send(Ce.BoardLoopRoll,e,Al)}boardLoopAttack(e){return this.send(Ce.BoardLoopAttack,e,Ul)}boardLoopRaid(e){return this.send(Ce.BoardLoopRaid,e,Ys)}boardLoopRaidFast(e){return this.send(Ce.BoardLoopRaidFast,e,Ys)}boardLoopBuild(e){return this.send(Ce.BoardLoopBuild,e,Ol)}boardSpecialChoose(e){return this.send(Ce.BoardSpecialChoose,e,Bl)}boardSpecialApplyMultiplier(e){return this.send(Ce.BoardSpecialApplyMultiplier,e,Ll)}boardSpecialClaim(e){return this.send(Ce.BoardSpecialClaim,e,ql)}getCommunityChestState(e){return this.send(Ce.GetCommunityChestState,e,Nl)}joinOrCreateCommunityChest(e){return this.send(Ce.JoinOrCreateCommunityChest,e,jl)}claimCommunityChestMilestone(e){return this.send(Ce.ClaimCommunityChestMilestone,e,Xs)}claimCommunityChestGrandPrize(e){return this.send(Ce.ClaimCommunityChestGrandPrize,e,Xs)}leaveCommunityChest(e){return this.send(Ce.LeaveCommunityChest,e,Fl)}};var Et=zod.z.lazy(()=>zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null(),zod.z.array(Et),zod.z.record(zod.z.string(),Et)]));var pg={Live:"Live",Latest:"Latest",Specific:"Specific"},dg={Debug:"Debug",Info:"Info",Warning:"Warning",Error:"Error"},hg=zod.z.enum(["Debug","Info","Warning","Error"]),mg={None:"None",Disabled:"Disabled",NoActiveRevision:"NoActiveRevision",RevisionNotFound:"RevisionNotFound",InvalidFieldName:"InvalidFieldName",RateLimited:"RateLimited",HandlerNotFound:"HandlerNotFound",HandlerDisabled:"HandlerDisabled",Timeout:"Timeout",StatementCountExceeded:"StatementCountExceeded",StackOverflow:"StackOverflow",ApiCallLimitExceeded:"ApiCallLimitExceeded",JavaScriptException:"JavaScriptException",ExecutionError:"ExecutionError"},fg=zod.z.enum(["None","Disabled","NoActiveRevision","RevisionNotFound","InvalidFieldName","RateLimited","HandlerNotFound","HandlerDisabled","Timeout","StatementCountExceeded","StackOverflow","ApiCallLimitExceeded","JavaScriptException","ExecutionError"]),gg=zod.z.object({Level:hg,Message:zod.z.string().nullish(),Data:Et.nullish()}),Rg=zod.z.object({Error:fg,Message:zod.z.string().nullish(),StackTrace:zod.z.string().nullish()}),Hl=zod.z.object({FunctionName:zod.z.string().nullish(),Revision:zod.z.number().nullish(),FunctionResult:Et.nullish(),FunctionResultTooLarge:zod.z.boolean().nullish(),Logs:zod.z.array(gg).nullish(),LogsTooLarge:zod.z.boolean().nullish(),ExecutionTimeSeconds:zod.z.number().nullish(),APIRequestsIssued:zod.z.number().nullish(),Error:Rg.nullish()}),nn={Execute:"Execute"};var jr=class{constructor(e){this.ctx=e;}ctx;execute(e){let t=A(this.ctx.settings.titleID,"CloudCode",nn.Execute,e.UserID??"");return this.ctx.transport.post(t,e,Hl,{ticket:e.ClientSessionTicket})}};var Fr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Blockchain",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Me.GetDefinitions,e,Co)}getUserState(e){return this.send(Me.GetUserState,e,So)}depositToken(e){return this.send(Me.DepositToken,e,xo)}depositNFT(e){return this.send(Me.DepositNFT,e,Do)}requestTokenWithdrawal(e){return this.send(Me.RequestTokenWithdrawal,e,bo)}requestNFTWithdrawal(e){return this.send(Me.RequestNFTWithdrawal,e,zo)}getTransactionHistory(e){return this.send(Me.GetTransactionHistory,e,To)}retryWithdrawal(e){return this.send(Me.RetryWithdrawal,e,vo)}confirmWithdrawal(e){return this.send(Me.ConfirmWithdrawal,e,Po)}donateToDeveloper(e){return this.send(Me.DonateToDeveloper,e,Ss)}donateToUsersPool(e){return this.send(Me.DonateToUsersPool,e,Ss)}};var Vr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Marketplace",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(oe.GetDefinitions,e,jo)}getGroupedOffers(e){return this.send(oe.GetGroupedOffers,e,Fo)}getOffersByItem(e){return this.send(oe.GetOffersByItem,e,ks)}getOffer(e){return this.send(oe.GetOffer,e,Vo)}getBuyOrders(e){return this.send(oe.GetBuyOrders,e,ks)}getMyState(e){return this.send(oe.GetMyState,e,Wo)}getHistory(e){return this.send(oe.GetHistory,e,Qo)}createListing(e){return this.send(oe.CreateListing,e,Ot)}cancelListing(e){return this.send(oe.CancelListing,e,Be)}buy(e){return this.send(oe.Buy,e,Be)}marketBuy(e){return this.send(oe.MarketBuy,e,Be)}marketSell(e){return this.send(oe.MarketSell,e,Be)}createAuction(e){return this.send(oe.CreateAuction,e,Ot)}placeBid(e){return this.send(oe.PlaceBid,e,_o)}claimAuction(e){return this.send(oe.ClaimAuction,e,Be)}createBuyOrder(e){return this.send(oe.CreateBuyOrder,e,Ot)}cancelBuyOrder(e){return this.send(oe.CancelBuyOrder,e,Be)}fillBuyOrder(e){return this.send(oe.FillBuyOrder,e,Be)}createDirectTrade(e){return this.send(oe.CreateDirectTrade,e,Ot)}respondDirectTrade(e){return this.send(oe.RespondDirectTrade,e,Be)}cancelDirectTrade(e){return this.send(oe.CancelDirectTrade,e,Be)}claimBack(e){return this.send(oe.ClaimBack,e,Be)}};var _r=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Multiplayer",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}createRoom(e){return this.send(Ee.CreateRoom,e,qr)}joinRoom(e){return this.send(Ee.JoinRoom,e,qr)}leaveRoom(e){return this.send(Ee.LeaveRoom,e,rn)}listRooms(e){return this.send(Ee.ListRooms,e,Ql)}getRoom(e){return this.send(Ee.GetRoom,e,qr)}closeRoom(e){return this.send(Ee.CloseRoom,e,rn)}poll(e){return this.send(Ee.Poll,e,Kl)}sendSignal(e){return this.send(Ee.SendSignal,e,Er)}sendChat(e){return this.send(Ee.SendChat,e,Er)}setMemberState(e){return this.send(Ee.SetMemberState,e,Er)}};var Wr=class{settings;emitter;platform;transport;fetchImpl;data;authStore;api;auth;userService;currency;item;store;lootbox;reward;quest;tutorial;localization;timedEvent;leaderboard;season;premium;character;match;craft;collection;coopEvent;dealOffer;referral;social;timedBoost;userCustomData;titleCustomData;title;gameLoop;cloudCode;blockchain;marketplace;multiplayer;constructor(e){this.settings=cn(e),this.emitter=new wt,this.platform=e.platform??new Ct,this.fetchImpl=e.fetch??globalThis.fetch.bind(globalThis),this.transport=new Kt({baseUrl:this.settings.baseUrl,emitter:this.emitter,fetchImpl:e.fetch,debugLogging:this.settings.debugLogging,throttleMs:e.throttleMs}),this.data=new Jt(this.emitter),this.emitter.on("quest:systemProgress",t=>{this.data.user.patchQuestProgressUpdates(t);}),this.emitter.on("tutorial:systemProgress",t=>{this.data.user.patchTutorialProgress(t);}),this.emitter.on("user:stateVersions",({epoch:t,versions:i})=>{this.userService.noteStateVersions(t,i);}),this.authStore=new Yt(this.platform.storage,this.settings.titleID),this.api={authentication:new _i(this),user:new Qi(this),currency:new Ki(this),item:new Zi(this),store:new Yi(this),lootbox:new tr(this),reward:new ir(this),quest:new nr(this),tutorial:new rr(this),localization:new sr(this),timedEvent:new ar(this),leaderboard:new hr(this),season:new fr(this),premium:new Rr(this),character:new yr(this),match:new Cr(this),craft:new xr(this),collection:new br(this),coopEvent:new Tr(this),dealOffer:new vr(this),referral:new Pr(this),social:new kr(this),timedBoost:new wr(this),userCustomData:new Ar(this),titleCustomData:new Or(this),title:new Gr(this),gameLoop:new Nr(this),cloudCode:new jr(this),blockchain:new Fr(this),marketplace:new Vr(this),multiplayer:new _r(this)},this.userService=new ii(this),this.auth=new Xt(this),this.currency=new si(this),this.item=new ni(this),this.store=new oi(this),this.lootbox=new ai(this),this.reward=new li(this),this.quest=new di(this),this.tutorial=new ui(this),this.localization=new pi(this),this.timedEvent=new hi(this),this.leaderboard=new mi(this),this.season=new fi(this),this.premium=new gi(this),this.character=new Ri(this),this.match=new yi(this),this.craft=new Ci(this),this.collection=new Si(this),this.coopEvent=new xi(this),this.dealOffer=new Di(this),this.referral=new bi(this),this.social=new zi(this),this.timedBoost=new Ti(this),this.userCustomData=new Ii(this),this.titleCustomData=new ki(this),this.title=new Mi(this),this.gameLoop=new wi(this),this.cloudCode=new Ai(this),this.blockchain=new Ei(this),this.marketplace=new Fi(this),this.multiplayer=new Vi(this),this.transport.setSessionRefreshHandler(()=>this.auth.refreshSession());}buildAuthedBaseRequest(){let e=this.auth.context;return {UserID:e?.userID,ClientSessionTicket:e?.clientSessionTicket,BuildKey:this.settings.buildKey,WebAppLink:this.platform.getFullURL(),RelatedEntityID:P()}}};var Qr=class{ctx;constructor(e){this.ctx=new Wr(e);}get titleID(){return this.ctx.settings.titleID}get auth(){return this.ctx.auth}get user(){return this.ctx.userService}get currency(){return this.ctx.currency}get item(){return this.ctx.item}get store(){return this.ctx.store}get lootbox(){return this.ctx.lootbox}get reward(){return this.ctx.reward}get quest(){return this.ctx.quest}get tutorial(){return this.ctx.tutorial}get localization(){return this.ctx.localization}get timedEvent(){return this.ctx.timedEvent}get leaderboard(){return this.ctx.leaderboard}get season(){return this.ctx.season}get premium(){return this.ctx.premium}get character(){return this.ctx.character}get match(){return this.ctx.match}get craft(){return this.ctx.craft}get collection(){return this.ctx.collection}get coopEvent(){return this.ctx.coopEvent}get dealOffer(){return this.ctx.dealOffer}get referral(){return this.ctx.referral}get social(){return this.ctx.social}get timedBoost(){return this.ctx.timedBoost}get userCustomData(){return this.ctx.userCustomData}get titleCustomData(){return this.ctx.titleCustomData}get title(){return this.ctx.title}get gameLoop(){return this.ctx.gameLoop}get cloudCode(){return this.ctx.cloudCode}get blockchain(){return this.ctx.blockchain}get marketplace(){return this.ctx.marketplace}get multiplayer(){return this.ctx.multiplayer}get data(){return this.ctx.data}get platform(){return this.ctx.platform}on(e,t){return this.ctx.emitter.on(e,t)}once(e,t){return this.ctx.emitter.once(e,t)}off(e,t){this.ctx.emitter.off(e,t);}};function yg(o){return new Qr(o)}var $l="idos_sso",Zl="state",on="idos:sso:state",Cg="https://idosgames.com/sso/";function Sg(){if(typeof window>"u")return null;let o=window.location.hash?.startsWith("#")?window.location.hash.slice(1):window.location.hash;if(!o)return null;let e=new URLSearchParams(o),t=e.get($l);if(!t)return null;let i=e.get(Zl)??"",r=Tg();return Pg(e),vg(),r&&i!==r?null:{code:t,state:i}}function xg(o){if(typeof window>"u")return;let e=o.returnTo??Dg(),t=bg();zg(t);let i=new URL(o.ssoUrl??Cg);i.searchParams.set("title",o.titleID),i.searchParams.set("return_to",e),i.searchParams.set("state",t),window.location.assign(i.toString());}function Dg(){let{origin:o,pathname:e,search:t}=window.location;return `${o}${e}${t}`}function bg(){let o=new Uint8Array(16);if(typeof crypto<"u"&&crypto.getRandomValues)crypto.getRandomValues(o);else for(let e=0;e<o.length;e++)o[e]=Math.floor(Math.random()*256);return Array.from(o,e=>e.toString(16).padStart(2,"0")).join("")}function zg(o){try{window.sessionStorage.setItem(on,o);}catch{}}function Tg(){try{return window.sessionStorage.getItem(on)}catch{return null}}function vg(){try{window.sessionStorage.removeItem(on);}catch{}}function Pg(o){o.delete($l),o.delete(Zl);let e=o.toString(),{pathname:t,search:i}=window.location;window.history.replaceState(null,"",`${t}${i}${e?`#${e}`:""}`);}var Ig={Banner:"Banner",Interstitial:"Interstitial",RewardedVideo:"RewardedVideo",RewardedInterstitial:"RewardedInterstitial",AppOpen:"AppOpen",Native:"Native"},an=zod.z.enum(["Banner","Interstitial","RewardedVideo","RewardedInterstitial","AppOpen","Native"]),kg={Top:"Top",Bottom:"Bottom",Left:"Left",Right:"Right"},Mg=zod.z.enum(["Top","Bottom","Left","Right"]),wg=zod.z.object({PlacementID:zod.z.string().nullish(),Type:an.nullish(),Enabled:zod.z.boolean().nullish(),CooldownSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish(),CreditsRewarded:zod.z.number().nullish(),AllowedProviderIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),Ag=zod.z.object({DefaultCreditsPerView:zod.z.number().nullish(),MaxCreditsBalance:zod.z.number().nullish(),DailyCreditEarnCap:zod.z.number().nullish(),DailyViewCap:zod.z.number().nullish(),MinSecondsBetweenViews:zod.z.number().nullish()}).passthrough(),Ug=zod.z.object({CooldownSeconds:zod.z.number().nullish(),MinSessionTimeBeforeFirstSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),Og=zod.z.object({Enabled:zod.z.boolean().nullish(),Position:Mg.nullish(),RefreshIntervalSeconds:zod.z.number().nullish()}).passthrough(),Bg=zod.z.object({Enabled:zod.z.boolean().nullish(),CooldownSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish()}).passthrough(),Lg=zod.z.object({MaxImpressionsPerHour:zod.z.number().nullish(),MaxImpressionsPerDay:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),qg=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),DisableInterstitials:zod.z.boolean().nullish(),DisableBanners:zod.z.boolean().nullish(),DisableAppOpen:zod.z.boolean().nullish()}).passthrough(),Eg=zod.z.object({RequirePersonalizedAdsConsent:zod.z.boolean().nullish(),RequireTrackingConsent:zod.z.boolean().nullish(),CurrentPolicyVersion:zod.z.string().nullish(),RegulatedRegions:zod.z.array(zod.z.string()).nullish()}).passthrough(),Gg=zod.z.object({RequireServerSideVerification:zod.z.boolean().nullish(),PendingRequestTtlSeconds:zod.z.number().nullish(),MaxPendingRequestsPerUser:zod.z.number().nullish(),ProviderPublicKeys:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Ng=zod.z.object({AndroidUnitID:zod.z.string().nullish(),IosUnitID:zod.z.string().nullish(),WebUnitID:zod.z.string().nullish(),Type:an.nullish()}).passthrough(),jg=zod.z.object({ProviderID:zod.z.string().nullish(),Enabled:zod.z.boolean().nullish(),Priority:zod.z.number().nullish(),AndroidAppID:zod.z.string().nullish(),IosAppID:zod.z.string().nullish(),WebAppID:zod.z.string().nullish(),Units:zod.z.record(zod.z.string(),Ng).nullish()}).passthrough();zod.z.object({Enabled:zod.z.boolean().nullish(),Placements:zod.z.record(zod.z.string(),wg).nullish(),Providers:zod.z.record(zod.z.string(),jg).nullish(),RewardedVideo:Ag.nullish(),Interstitial:Ug.nullish(),Banner:Og.nullish(),AppOpen:Bg.nullish(),FrequencyCapping:Lg.nullish(),PremiumAdReductions:zod.z.array(qg).nullish(),Consent:Eg.nullish(),Verification:Gg.nullish()}).passthrough();var Fg=zod.z.object({RewardedVideoCredit:zod.z.number().nullish(),TotalEarned:zod.z.number().nullish(),TotalSpent:zod.z.number().nullish()}).passthrough(),Vg=zod.z.object({PlacementID:zod.z.string().nullish(),LastShownAt:u.nullish(),LastCompletedAt:u.nullish(),TotalImpressions:zod.z.number().nullish(),TotalCompletions:zod.z.number().nullish(),ConsecutiveFailures:zod.z.number().nullish()}).passthrough(),_g=zod.z.object({Date:u.nullish(),ImpressionsByPlacement:zod.z.record(zod.z.string(),zod.z.number()).nullish(),CompletionsByPlacement:zod.z.record(zod.z.string(),zod.z.number()).nullish(),TotalImpressions:zod.z.number().nullish(),InterstitialImpressions:zod.z.number().nullish(),RewardedCompletions:zod.z.number().nullish(),AppOpenImpressions:zod.z.number().nullish(),CreditsEarnedToday:zod.z.number().nullish()}).passthrough(),Wg=zod.z.object({SessionID:zod.z.string().nullish(),SessionStartAt:u.nullish(),Impressions:zod.z.number().nullish(),InterstitialImpressions:zod.z.number().nullish(),RewardedCompletions:zod.z.number().nullish()}).passthrough(),Qg=zod.z.object({PersonalizedAdsConsent:zod.z.boolean().nullish(),TrackingConsent:zod.z.boolean().nullish(),PolicyVersion:zod.z.string().nullish(),Region:zod.z.string().nullish(),ConsentGivenAt:u.nullish(),ConsentRevokedAt:u.nullish()}).passthrough(),Kg=zod.z.object({RequestID:zod.z.string().nullish(),PlacementID:zod.z.string().nullish(),ProviderID:zod.z.string().nullish(),Type:an.nullish(),IssuedAt:u.nullish(),ExpiresAt:u.nullish(),CreditsToAward:zod.z.number().nullish()}).passthrough(),Hg=zod.z.object({InvalidSsvCount:zod.z.number().nullish(),OrphanCompletions:zod.z.number().nullish(),FastCompletions:zod.z.number().nullish(),LastFlaggedAt:u.nullish()}).passthrough();zod.z.object({Credits:Fg.nullish(),Placements:zod.z.record(zod.z.string(),Vg).nullish(),Daily:_g.nullish(),Session:Wg.nullish(),LastImpressionAt:u.nullish(),LastInterstitialAt:u.nullish(),LastRewardedAt:u.nullish(),LastAppOpenAt:u.nullish(),TotalImpressions:zod.z.number().nullish(),TotalRewardedCompletions:zod.z.number().nullish(),AdsDisabledUntil:u.nullish(),Consent:Qg.nullish(),PendingRequests:zod.z.record(zod.z.string(),Kg).nullish(),FraudFlags:Hg.nullish(),UpdatedAt:u.nullish()}).passthrough();var $g={Unread:"Unread",Read:"Read",Deleted:"Deleted",Expired:"Expired"},Zg=zod.z.enum(["Unread","Read","Deleted","Expired"]),Jg={Admin:"Admin",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season",Collection:"Collection",MilestoneEvent:"MilestoneEvent",PlayerGift:"PlayerGift",Social:"Social",Compensation:"Compensation",Referral:"Referral",Quest:"Quest"},Yg=zod.z.enum(["Admin","Leaderboard","CoopEvent","Season","Collection","MilestoneEvent","PlayerGift","Social","Compensation","Referral","Quest"]),Xg={Active:"Active",Paused:"Paused",Cancelled:"Cancelled",Completed:"Completed"},eR=zod.z.enum(["Active","Paused","Cancelled","Completed"]),tR=zod.z.object({MessageTypeID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),IconPath:zod.z.string().nullish(),DisplayPriority:zod.z.number().nullish(),ExpirationHours:zod.z.number().nullish(),AutoClaim:zod.z.boolean().nullish(),AllowP2P:zod.z.boolean().nullish(),ShowBadge:zod.z.boolean().nullish()}).passthrough(),iR=zod.z.object({SegmentID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Gate:Q.nullish()}).passthrough();zod.z.object({MaxMessagesPerUser:zod.z.number().nullish(),ReadNoRewardRetentionHours:zod.z.number().nullish(),ClaimedRetentionHours:zod.z.number().nullish(),DefaultPageSize:zod.z.number().nullish(),EnableAutoClaim:zod.z.boolean().nullish(),MessageTypes:zod.z.record(zod.z.string(),tR).nullish(),Segments:zod.z.array(iR).nullish(),DailyP2PGiftLimit:zod.z.number().nullish(),MaxRewardsPerP2PMessage:zod.z.number().nullish()}).passthrough();zod.z.object({MessageID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),RecipientUserID:zod.z.string().nullish(),MessageTypeID:zod.z.string().nullish(),Source:Yg.nullish(),RelatedEntityID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderPublicData:De.nullish(),Subject:zod.z.string().nullish(),Body:zod.z.string().nullish(),TemplateParams:zod.z.record(zod.z.string(),zod.z.string()).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rewards:q.nullish(),Claimed:zod.z.boolean().nullish(),ClaimedAtUtc:u.nullish(),Status:Zg.nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),ReadAtUtc:u.nullish(),BroadcastID:zod.z.string().nullish(),Version:zod.z.number().nullish()}).passthrough();zod.z.object({BroadcastID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),MessageTypeID:zod.z.string().nullish(),Subject:zod.z.string().nullish(),Body:zod.z.string().nullish(),TemplateParams:zod.z.record(zod.z.string(),zod.z.string()).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rewards:q.nullish(),TargetSegmentID:zod.z.string().nullish(),TargetUserIDs:zod.z.array(zod.z.string()).nullish(),StartsAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),CreatedAtUtc:u.nullish(),CreatedByAdminID:zod.z.string().nullish(),AdminComment:zod.z.string().nullish(),Status:eR.nullish(),DeliveredCount:zod.z.number().nullish(),ClaimedCount:zod.z.number().nullish()}).passthrough();zod.z.object({UnreadCount:zod.z.number().nullish(),UnclaimedRewardCount:zod.z.number().nullish(),LastFetchCursor:u.nullish(),ReceivedBroadcastIDs:zod.z.array(zod.z.string()).nullish(),ClaimedBroadcastIDs:zod.z.array(zod.z.string()).nullish(),DailyP2PGiftsSent:zod.z.number().nullish(),DailyGiftsResetDate:u.nullish(),LastOpenedAtUtc:u.nullish(),TotalMessagesReceived:zod.z.number().nullish(),TotalRewardsClaimed:zod.z.number().nullish()}).passthrough();var Jl="idos_device_id",Kr=class{storage;constructor(e=new Rt){this.storage=e;}getPlatform(){return "Web"}getFullURL(){return ""}getStartParameter(){return null}getTelegramInitDataRaw(){return null}getDeviceID(){let e=this.storage.getString(Jl);return e||(e="noop-device",this.storage.setString(Jl,e)),e}getDeviceModel(){return "Noop"}shareLink(){}openInvoice(){}async showAd(){}async copyToClipboard(){}};
|
|
2
|
-
exports.AdType=
|
|
1
|
+
'use strict';var zod=require('zod'),ii=require('decimal.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ii__default=/*#__PURE__*/_interopDefault(ii);var Lt=class{listeners=new Map;on(e,t){let i=this.listeners.get(e);return i||(i=new Set,this.listeners.set(e,i)),i.add(t),()=>{this.off(e,t);}}once(e,t){let i=this.on(e,r=>{i(),t(r);});return i}off(e,t){let i=this.listeners.get(e);i&&(i.delete(t),i.size===0&&this.listeners.delete(e));}emit(e,t){let i=this.listeners.get(e);if(i)for(let r of [...i])r(t);}removeAllListeners(){this.listeners.clear();}};function yu(){let o=new Map;return {get:e=>o.get(e)??null,set:(e,t)=>{o.set(e,t);},remove:e=>{o.delete(e);}}}function Sn(){return Cu()??yu()}function Cu(){try{let o=globalThis.localStorage;if(!o)return null;let e="__idos_probe__";return o.setItem(e,"1"),o.removeItem(e),{get:t=>{try{return o.getItem(t)}catch{return null}},set:(t,i)=>{try{o.setItem(t,i);}catch{try{o.removeItem(t);}catch{}}},remove:t=>{try{o.removeItem(t);}catch{}}}}catch{return null}}var xn="https://api.idosgames.com";function Dn(o){return {titleID:o.titleID,titleTemplateID:o.titleTemplateID??"default",buildKey:o.buildKey??"",baseUrl:(o.baseUrl??xn).replace(/\/+$/,""),devBuild:o.devBuild??false,debugLogging:o.debugLogging??false,configStorage:o.configStorage??Sn(),locale:o.locale??Su()}}function Su(){try{return globalThis.navigator?.language??""}catch{return ""}}var Ct=class{getString(e){if(typeof localStorage>"u")return null;try{return localStorage.getItem(e)}catch{return null}}setString(e,t){if(!(typeof localStorage>"u"))try{localStorage.setItem(e,t);}catch{}}remove(e){if(!(typeof localStorage>"u"))try{localStorage.removeItem(e);}catch{}}},St=class{map=new Map;getString(e){return this.map.get(e)??null}setString(e,t){this.map.set(e,t);}remove(e){this.map.delete(e);}};function xt(){return globalThis.Telegram?.WebApp??null}function P(){return crypto.randomUUID()}var bn="idos_device_id",Dt=class{storage;constructor(e=new Ct){this.storage=e;}getPlatform(){return xt()?.platform??"Web"}getFullURL(){return typeof location<"u"?location.href:""}getStartParameter(){let e=xt()?.initDataUnsafe?.start_param;return typeof e=="string"?e:null}getTelegramInitDataRaw(){let e=xt()?.initData;return e&&e.length>0?e:null}getDeviceID(){let e=this.storage.getString(bn);return e||(e=P(),this.storage.setString(bn,e)),e}getDeviceModel(){return typeof navigator<"u"&&navigator.userAgent?navigator.userAgent:"Web"}shareLink(e){let t=xt();if(t?.openTelegramLink){t.openTelegramLink(e);return}typeof window<"u"&&window.open(e,"_blank");}openInvoice(e){let t=xt();if(t?.openInvoice){t.openInvoice(e);return}typeof window<"u"&&window.open(e,"_blank");}async showAd(e){let t=globalThis;typeof t.showAd=="function"&&await t.showAd(e);}async copyToClipboard(e){typeof navigator<"u"&&navigator.clipboard&&await navigator.clipboard.writeText(e);}};var je={Virtual:"Virtual",Crypto:"Crypto"},zt=zod.z.enum(["Virtual","Crypto"]),Wt={Item:"Item",VirtualCurrency:"VirtualCurrency",CryptoCurrency:"CryptoCurrency",RewardedVideoCredit:"RewardedVideoCredit",Purchase:"Purchase"},Qt=zod.z.enum(["Item","VirtualCurrency","CryptoCurrency","RewardedVideoCredit","Purchase"]),He={Unknown:"Unknown",Web:"Web",Android:"Android",Ios:"Ios"},Kt=zod.z.enum(["Unknown","Web","Android","Ios"]),xu={GooglePlay:"GooglePlay",AppleAppStore:"AppleAppStore"},Ht=zod.z.enum(["GooglePlay","AppleAppStore"]),Du={TimedEvent:"TimedEvent",Quest:"Quest",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season"},$t=zod.z.enum(["TimedEvent","Quest","Leaderboard","CoopEvent","Season"]),bu={Cyclic:"Cyclic",Scheduled:"Scheduled",Chained:"Chained"},qt=zod.z.enum(["Cyclic","Scheduled","Chained"]),me={None:"None",Device:"Device",Email:"Email",iDosGames:"iDosGames",Facebook:"Facebook",Google:"Google",GooglePlay:"GooglePlay",Telegram:"Telegram",Wallet:"Wallet"};function Tn(){let o=globalThis,e=o.Capacitor?.getPlatform?.();if(e)return zn(e);let t=o.cordova?.platformId;return t?zn(t):o.navigator?.userAgent??""?He.Web:He.Unknown}function zn(o){let e=o.toLowerCase();return e==="android"?He.Android:e==="ios"?He.Ios:e==="web"?He.Web:He.Unknown}function vn(o){return {ok:true,data:o}}function n(o,e){return {ok:false,reason:o,error:e}}function zu(o){return o.ok}function Tu(o){return !o.ok}var w=zod.z.union([zod.z.number(),zod.z.string()]).transform((o,e)=>{let t=typeof o=="string"?Number(o):o;return Number.isFinite(t)?Math.trunc(t):(e.addIssue({code:zod.z.ZodIssueCode.custom,message:`Invalid integer amount: ${String(o)}`}),zod.z.NEVER)}),q=zod.z.union([zod.z.number(),zod.z.string()]).transform((o,e)=>{let t=typeof o=="number"?String(o):o.trim();return t===""||Number.isNaN(Number(t))?(e.addIssue({code:zod.z.ZodIssueCode.custom,message:`Invalid decimal: ${String(o)}`}),zod.z.NEVER):t}),u=zod.z.string();var ns=zod.z.object({Type:Qt.nullish(),CurrencyID:zod.z.string().nullish(),Amount:w.nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),ProductID:zod.z.string().nullish()}),vu=zod.z.object({Type:$t.nullish(),EntityID:zod.z.string()}),Pu=zod.z.object({Address:vu.nullish(),Amount:w.nullish(),Source:zod.z.string().nullish()}),fe=zod.z.object({Entries:zod.z.array(ns).nullish(),EventTokens:zod.z.array(Pu).nullish()}),Pn=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Resources:fe.nullish()}),L=zod.z.object({Standard:fe.nullish(),PremiumBonuses:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(Pn).nullish()}),Et=zod.z.object({Standard:fe.nullish(),PremiumDiscounts:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(Pn).nullish()}),b=zod.z.object({Grant:L.nullish(),Consume:Et.nullish()}),dt=zod.z.object({FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),FromResult:b.nullish(),ToResult:b.nullish()});zod.z.object({FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),Transferred:fe.nullish()});var Iu=zod.z.object({ExperimentID:zod.z.string().nullish(),Variants:zod.z.array(zod.z.string()).nullish()}).passthrough(),ku={Completed:"Completed",Started:"Started",StepReached:"StepReached"},Mu=zod.z.object({FlowIDs:zod.z.array(zod.z.string()).nullish(),Mode:zod.z.enum(["Completed","Started","StepReached"]).nullish(),StepID:zod.z.string().nullish(),Negate:zod.z.boolean().nullish(),SkippedCountsAsCompleted:zod.z.boolean().nullish()}).passthrough(),_=zod.z.object({Segments:zod.z.array(zod.z.string()).nullish(),MinPremiumTier:zod.z.number().nullish(),RequiredPremiumIDs:zod.z.array(zod.z.string()).nullish(),MinLevel:zod.z.number().nullish(),MaxLevel:zod.z.number().nullish(),Countries:zod.z.array(zod.z.string()).nullish(),RegisteredWithinDays:zod.z.number().nullish(),ActiveWithinDays:zod.z.number().nullish(),Experiment:Iu.nullish(),Tutorial:Mu.nullish(),Platforms:zod.z.array(Kt).nullish()}).passthrough();var ge=zod.z.object({TotalCap:zod.z.number().nullish(),DailyCap:zod.z.number().nullish(),DailyWeightCap:zod.z.number().nullish(),PerActivationCap:zod.z.number().nullish(),CooldownSeconds:zod.z.number().nullish(),MaxPerWindow:zod.z.number().nullish(),WindowSeconds:zod.z.number().nullish()}).passthrough();var wu=zod.z.object({OffsetSecondsFromParentStart:zod.z.number().nullish(),DurationSeconds:zod.z.number().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Ou=zod.z.object({StartUtc:zod.z.string().nullish(),EndUtc:zod.z.string().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Au=zod.z.object({AnchorUtc:zod.z.string().nullish(),MaxCycles:zod.z.number().nullish(),PauseBetweenPhasesSec:zod.z.number().nullish(),PauseBetweenCyclesSec:zod.z.number().nullish()}).passthrough();zod.z.object({PhaseID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough();var Uu=zod.z.object({Reset:zod.z.string().nullish(),IntervalSeconds:zod.z.number().nullish(),AnchorUtc:zod.z.string().nullish(),PauseBetweenCyclesSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough();zod.z.object({SourceType:zod.z.string().nullish(),TileType:zod.z.string().nullish(),TileIndex:zod.z.number().nullish(),ChanceOutcomeID:zod.z.string().nullish(),Outcome:zod.z.string().nullish(),Params:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough();var Ue=zod.z.object({SourceType:zod.z.string().nullish(),BaseWeight:zod.z.number().nullish(),ScaleWithRollMultiplier:zod.z.boolean().nullish(),TileTypeFilter:zod.z.array(zod.z.string()).nullish(),TileIndexFilter:zod.z.array(zod.z.number()).nullish(),ChanceOutcomeFilter:zod.z.array(zod.z.string()).nullish(),OutcomeFilter:zod.z.array(zod.z.string()).nullish(),Params:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Limits:ge.nullish()}).passthrough(),pe=zod.z.object({Mode:zod.z.string().nullish(),IsActive:zod.z.boolean().nullish(),Scheduled:Ou.nullish(),Chain:Au.nullish(),Cyclic:Uu.nullish(),ActivationTriggers:zod.z.array(Ue).nullish(),Relative:wu.nullish()}).passthrough();var Bu=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Rewards:L.nullish()}).passthrough(),Lu=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),os=zod.z.object({Bundles:zod.z.array(Bu).nullish(),Multipliers:zod.z.array(Lu).nullish()}).passthrough();var qu=zod.z.enum(["BoardStageLevel","BoardRank","BoardCyclesCompleted","CharacterLevel","SeasonTier","EventTokenTotalEarned","VirtualCurrencyBalance","PlayerLevel"]);var Eu=zod.z.enum(["Tiered","Linear"]);var Gu=zod.z.enum(["Step","Linear"]),Nu=zod.z.object({AtProgress:zod.z.number().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),Zt=zod.z.object({Source:qu.nullish(),SourceKey:zod.z.string().nullish(),CurveType:Eu.nullish(),Tiers:zod.z.array(Nu).nullish(),TierMode:Gu.nullish(),BaseMultiplier:zod.z.number().nullish(),PerUnit:zod.z.number().nullish(),Anchor:zod.z.number().nullish(),MinMultiplier:zod.z.number().nullish(),MaxMultiplier:zod.z.number().nullish(),IncludeRewards:fe.nullish(),ExcludeRewards:fe.nullish()}).passthrough(),De=zod.z.object({MilestoneID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),RequiredProgress:zod.z.number().nullish(),Rewards:L.nullish(),BonusRewards:L.nullish(),SeasonTierRewards:os.nullish(),SortOrder:zod.z.number().nullish(),IsFeatured:zod.z.boolean().nullish()}).passthrough(),at=zod.z.object({Milestones:zod.z.record(zod.z.string(),De).nullish()}).passthrough();var X=zod.z.object({PresetID:zod.z.string().nullish(),Remove:zod.z.array(zod.z.string()).nullish()}).passthrough();var ju=zod.z.object({TargetCurrencyID:zod.z.string().nullish(),Rate:zod.z.number().nullish(),MaxConvertAmount:zod.z.number().nullish()}).passthrough(),ht=zod.z.object({DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),MaxBalance:zod.z.number().nullish(),MaxPerGrant:zod.z.number().nullish(),DailyEarnCap:zod.z.number().nullish(),BurnOnEventEnd:zod.z.boolean().nullish(),BurnConversion:ju.nullish()}).passthrough();var re=o=>zod.z.object({Id:zod.z.string(),Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:o.nullish()}),$e=o=>zod.z.object({ServerTimeUtc:u,Items:zod.z.array(re(o)),Resources:b.nullish()});var Fu={Active:"Active",Completed:"Completed",Claimed:"Claimed",Expired:"Expired"},In=zod.z.enum(["Active","Completed","Claimed","Expired"]),Vu=zod.z.object({}).passthrough().transform(o=>o),_u=zod.z.object({CycleID:zod.z.string(),InstanceKey:zod.z.string().nullish(),PhaseID:zod.z.string().nullish(),CycleIndex:zod.z.number().nullish(),CycleStartUtc:u.nullish(),CycleEndUtc:u.nullish(),PointsTotalEarned:w.nullish(),PointsCurrent:w.nullish(),ClaimedPointMilestoneIDs:zod.z.array(zod.z.string()).nullish()}),as=zod.z.object({QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),ObjectiveID:zod.z.string().nullish(),NewValue:w.nullish(),ObjectiveCompleted:zod.z.boolean().nullish(),Status:In}),kn=zod.z.object({State:Vu.nullish(),PointsTracks:zod.z.record(zod.z.string(),_u).nullish()}),ls=zod.z.object({ServerTimeUtc:u,QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),NewStatus:In.nullish(),Resources:b.nullish()}),us=zod.z.object({ServerTimeUtc:u,CycleID:zod.z.string(),MilestoneID:zod.z.string(),PointsTotalEarned:w.nullish(),Resources:b.nullish()}),Mn=zod.z.object({ServerTimeUtc:u,CycleID:zod.z.string(),GroupCompletionID:zod.z.string(),GroupID:zod.z.string().nullish(),CompletedGroupQuests:zod.z.number().nullish(),RequiredGroupQuests:zod.z.number().nullish(),Resources:b.nullish()}),wn=zod.z.object({MetricID:zod.z.string(),Updates:zod.z.array(as).nullish()}),On=zod.z.array(re(ls)),An=zod.z.array(re(us)),Wu={ClientApi:"ClientApi",ServerApi:"ServerApi",SystemEvent:"SystemEvent"},Qu=zod.z.enum(["ClientApi","ServerApi","SystemEvent"]),Ku={BlockProgressAndClaim:"BlockProgressAndClaim",BlockClaimOnly:"BlockClaimOnly"},Hu=zod.z.enum(["BlockProgressAndClaim","BlockClaimOnly"]),Un=zod.z.object({ObjectiveID:zod.z.string().nullish(),Source:Qu.nullish(),MaxProgressPerCall:zod.z.number().nullish(),MetricID:zod.z.string().nullish(),Triggers:zod.z.array(Ue).nullish(),TargetValue:zod.z.number().nullish(),AggregationMethod:zod.z.string().nullish()}).passthrough(),cs=zod.z.object({Milestones:X.nullish(),Linking:X.nullish(),Availability:X.nullish(),Reward:X.nullish(),Objectives:X.nullish()}).passthrough(),$u=zod.z.object({DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Bn=zod.z.object({CycleIDs:zod.z.array(zod.z.string()).nullish(),GroupID:zod.z.string().nullish(),PhaseIDs:zod.z.array(zod.z.string()).nullish(),RequiredQuestIDs:zod.z.array(zod.z.string()).nullish(),PrerequisiteMode:Hu.nullish()}).passthrough(),Ln=zod.z.object({Schedule:pe.nullish(),AccrueProgressWhenLocked:zod.z.boolean().nullish(),Gate:_.nullish(),Limits:ge.nullish()}).passthrough(),qn=zod.z.object({Grant:L.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),Zu=zod.z.object({QuestID:zod.z.string().nullish(),Identity:$u.nullish(),Linking:Bn.nullish(),Availability:Ln.nullish(),Objectives:zod.z.record(zod.z.string(),Un).nullish(),Reward:qn.nullish(),Presets:cs.nullish()}).passthrough(),Ju=zod.z.object({CompletionID:zod.z.string().nullish(),GroupID:zod.z.string().nullish(),RequiredCompletedQuests:zod.z.number().nullish(),Gate:_.nullish(),Reward:L.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),Yu=zod.z.object({PhaseID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Gate:_.nullish(),Milestones:zod.z.record(zod.z.string(),De).nullish(),Presets:cs.nullish(),PointsToken:ht.nullish()}).passthrough(),Xu=zod.z.object({Milestones:zod.z.record(zod.z.string(),at).nullish(),Linking:zod.z.record(zod.z.string(),Bn).nullish(),Availability:zod.z.record(zod.z.string(),Ln).nullish(),Reward:zod.z.record(zod.z.string(),qn).nullish(),Objectives:zod.z.record(zod.z.string(),zod.z.record(zod.z.string(),Un)).nullish()}).passthrough(),ec=zod.z.object({CycleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:pe.nullish(),Milestones:zod.z.record(zod.z.string(),De).nullish(),Gate:_.nullish(),PointsToken:ht.nullish(),GroupCompletions:zod.z.record(zod.z.string(),Ju).nullish(),Phases:zod.z.record(zod.z.string(),Yu).nullish(),Presets:cs.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Yt=zod.z.object({Cycles:zod.z.record(zod.z.string(),ec).nullish(),Quests:zod.z.record(zod.z.string(),Zu).nullish(),Presets:Xu.nullish()}).passthrough(),Ve={GetQuestDefinitions:"GetQuestDefinitions",GetUserQuestState:"GetUserQuestState",RefreshQuestCycles:"RefreshQuestCycles",ClaimQuestReward:"ClaimQuestReward",ClaimMilestoneReward:"ClaimMilestoneReward",AddQuestProgress:"AddQuestProgress",ClaimQuestRewardsBatch:"ClaimQuestRewardsBatch",ClaimMilestoneRewardsBatch:"ClaimMilestoneRewardsBatch",ClaimGroupCompletionReward:"ClaimGroupCompletionReward"};var tc={ClientAck:"ClientAck",SystemEvent:"SystemEvent",Auto:"Auto",Composite:"Composite"},ic=zod.z.enum(["ClientAck","SystemEvent","Auto","Composite"]),rc={Never:"Never",OnRequest:"OnRequest",Always:"Always"},sc=zod.z.enum(["Never","OnRequest","Always"]),nc={NotStarted:"NotStarted",InProgress:"InProgress",Completed:"Completed",Skipped:"Skipped",Expired:"Expired"},oc=zod.z.enum(["NotStarted","InProgress","Completed","Skipped","Expired"]),ac={GameLoop:"GameLoop"},lc={Raid:"Raid",Attack:"Attack"},uc=zod.z.object({Title:zod.z.string().nullish(),TitleKey:zod.z.string().nullish(),Body:zod.z.string().nullish(),BodyKey:zod.z.string().nullish(),AnchorID:zod.z.string().nullish(),HighlightTarget:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),UiHint:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),cc=zod.z.object({Mode:ic.nullish(),Triggers:zod.z.array(Ue).nullish(),TargetValue:zod.z.number().nullish(),RequireAllTriggers:zod.z.boolean().nullish()}).passthrough(),pc=zod.z.object({Grant:L.nullish(),UnlockFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),dc=zod.z.object({TileType:zod.z.string().nullish(),TileIndex:zod.z.number().nullish(),ChanceOutcomeID:zod.z.string().nullish(),RandomActionType:zod.z.enum(["Raid","Attack"]).nullish()}).passthrough(),hc=zod.z.object({Module:zod.z.enum(["GameLoop"]).nullish(),Board:dc.nullish(),MaxUses:zod.z.number().nullish()}).passthrough(),mc=zod.z.object({Skippable:zod.z.boolean().nullish(),TimeoutSeconds:zod.z.number().nullish()}).passthrough(),ps=zod.z.object({StepID:zod.z.string().nullish(),Order:zod.z.number().nullish(),Identity:uc.nullish(),Completion:cc.nullish(),Effects:pc.nullish(),Script:hc.nullish(),Policy:mc.nullish()}).passthrough(),fc=zod.z.object({DisplayName:zod.z.string().nullish(),DisplayNameKey:zod.z.string().nullish(),Description:zod.z.string().nullish(),DescriptionKey:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),En=zod.z.object({Schedule:pe.nullish(),Gate:_.nullish(),RequiredFlowIDs:zod.z.array(zod.z.string()).nullish(),AutoStart:zod.z.boolean().nullish(),StartTrigger:Ue.nullish()}).passthrough(),Gn=zod.z.object({Skippable:zod.z.boolean().nullish(),SkippableFromOrder:zod.z.number().nullish(),RestartPolicy:sc.nullish(),ExpireAfterSeconds:zod.z.number().nullish(),IsBlocking:zod.z.boolean().nullish(),UnlockFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),Nn=zod.z.object({Grant:L.nullish(),AutoClaim:zod.z.boolean().nullish()}).passthrough(),gc=zod.z.object({Availability:X.nullish(),Policy:X.nullish(),Reward:X.nullish(),Steps:X.nullish()}).passthrough(),Rc=zod.z.object({FlowID:zod.z.string().nullish(),Identity:fc.nullish(),Availability:En.nullish(),Policy:Gn.nullish(),Steps:zod.z.record(zod.z.string(),ps).nullish(),Reward:Nn.nullish(),Presets:gc.nullish()}).passthrough(),yc=zod.z.object({BlockingFlowIDs:zod.z.array(zod.z.string()).nullish(),BlockedModules:zod.z.array(zod.z.string()).nullish(),BlockedActions:zod.z.record(zod.z.string(),zod.z.array(zod.z.string())).nullish(),BlockBeforeStart:zod.z.boolean().nullish(),SkipLiftsBlock:zod.z.boolean().nullish()}).passthrough(),Cc=zod.z.object({IsEnabled:zod.z.boolean().nullish(),MaxActiveFlows:zod.z.number().nullish(),Blocking:yc.nullish()}).passthrough(),Sc=zod.z.object({Availability:zod.z.record(zod.z.string(),En).nullish(),Policy:zod.z.record(zod.z.string(),Gn).nullish(),Reward:zod.z.record(zod.z.string(),Nn).nullish(),Steps:zod.z.record(zod.z.string(),zod.z.record(zod.z.string(),ps)).nullish()}).passthrough(),jn=zod.z.object({Flows:zod.z.record(zod.z.string(),Rc).nullish(),Settings:Cc.nullish(),Presets:Sc.nullish()}).passthrough(),xc=zod.z.object({}).passthrough().transform(o=>o),Fn=zod.z.object({FlowID:zod.z.string(),Status:oc,CurrentStepID:zod.z.string().nullish(),CurrentStep:ps.nullish(),TotalSteps:zod.z.number(),CompletedSteps:zod.z.number(),CanSkip:zod.z.boolean(),RewardClaimed:zod.z.boolean(),RewardPending:zod.z.boolean(),VariantID:zod.z.string().nullish()}).passthrough(),Vn=zod.z.object({State:xc.nullish(),Flows:zod.z.array(Fn).nullish(),UnlockedFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),lt=zod.z.object({Flow:Fn.nullish()}).passthrough(),_n=zod.z.object({FlowID:zod.z.string().nullish(),Granted:b.nullish()}).passthrough(),Wn=zod.z.array(re(lt)),Qn=zod.z.object({FlowID:zod.z.string(),StepID:zod.z.string(),Progress:zod.z.number(),Target:zod.z.number(),Completed:zod.z.boolean()}).passthrough(),Be={GetTutorialDefinitions:"GetTutorialDefinitions",GetUserTutorialState:"GetUserTutorialState",StartFlow:"StartFlow",ReportStepShown:"ReportStepShown",CompleteStep:"CompleteStep",CompleteStepsBatch:"CompleteStepsBatch",SkipStep:"SkipStep",SkipFlow:"SkipFlow",ClaimFlowReward:"ClaimFlowReward",ResetFlow:"ResetFlow"};var Xt=class{constructor(e=600,t=()=>Date.now()){this.windowMs=e;this.now=t;}windowMs;now;last=new Map;tryAcquire(e){if(this.windowMs<=0)return true;let t=this.now(),i=this.last.get(e);return i!==void 0&&t-i<this.windowMs?false:(this.last.set(e,t),true)}reset(){this.last.clear();}};var ei=class{set=new Set;add(e){return this.set.has(e)?false:(this.set.add(e),true)}remove(e){this.set.delete(e);}};function Kn(o){return o===429||o>=500&&o<=599}function ds(o,e=Math.random){let t=Math.min(500*Math.pow(2,o-1),4e3),i=t*.2*(e()*2-1);return Math.max(50,t+i)}function hs(o){return new Promise(e=>setTimeout(e,o))}var Dc=12e3,bc=zod.z.object({Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:zod.z.unknown().optional(),QuestProgress:zod.z.array(as).nullish(),TutorialProgress:zod.z.array(Qn).nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish(),StateEpoch:zod.z.string().nullish()}).passthrough(),ti=class{baseUrl;emitter;fetchImpl;debugLogging;throttler;clientPlatform;inflight=new ei;inFlightRequests=0;sessionRefreshHandler=null;constructor(e){this.baseUrl=e.baseUrl,this.emitter=e.emitter,this.fetchImpl=e.fetchImpl??globalThis.fetch.bind(globalThis),this.debugLogging=e.debugLogging??false,this.throttler=new Xt(e.throttleMs),this.clientPlatform=e.clientPlatform??He.Unknown;}setSessionRefreshHandler(e){this.sessionRefreshHandler=e;}async post(e,t,i,r={}){let s=r.throttleKey??e;if(!this.throttler.tryAcquire(s))return n("throttled","Throttled");if(!this.inflight.add(s))return n("throttled","Duplicate request skipped");this.raiseBusy();try{let a=`${this.baseUrl}/${e}`,p=JSON.stringify(t),D=r.ticket??null,U=r.silent??!1,E=r.timeoutMs??Dc,de=r.autoRetry??!0,Re=!1,Pe=0;for(;;){let Qe;try{Qe=await this.doFetch(a,p,D,E);}catch{if(de&&Pe<3){Pe++,await hs(ds(Pe));continue}return this.connectionFailure("Internet Connection Error",U)}let Ke=Qe.status;if(Ke>=200&&Ke<300)return await this.parseSuccess(Qe,i,U,e);if(Ke===401){if(!Re&&this.sessionRefreshHandler){Re=!0;let et=null;try{et=await this.sessionRefreshHandler();}catch{et=null;}if(et){D=et;continue}}return this.emitter.emit("auth:unauthorized",void 0),n("unauthorized","Unauthorized")}if(Kn(Ke)){if(de&&Pe<3){Pe++,await hs(ds(Pe));continue}return this.connectionFailure(`Server temporarily unavailable (HTTP ${Ke})`,U)}return await this.handleWebError(Qe,Ke,U)}}finally{this.inflight.remove(s),this.lowerBusy();}}async doFetch(e,t,i,r){let s=new AbortController,a=setTimeout(()=>{s.abort();},r);try{let p={"Content-Type":"application/json","X-IG-Platform":this.clientPlatform};return i&&(p.Authorization=`Bearer ${i}`),await this.fetchImpl(e,{method:"POST",body:t,headers:p,signal:s.signal})}finally{clearTimeout(a);}}async parseSuccess(e,t,i,r){let s;try{s=await e.text();}catch{return this.globalError("Failed to read response body",i)}let a;try{a=JSON.parse(s);}catch{return this.globalError("JSON Parse Error",i)}let p=bc.safeParse(a);if(!p.success)return this.globalError("Malformed response envelope",i);if(!p.data.Success){let Re=p.data.Error??"Server returned Success=false";return i||this.emitter.emit("error:global",Re),n("server",Re)}let D=p.data.QuestProgress;D&&D.length>0&&this.emitter.emit("quest:systemProgress",D);let U=p.data.TutorialProgress;U&&U.length>0&&this.emitter.emit("tutorial:systemProgress",U);let E=p.data.StateVersions;E&&Object.keys(E).length>0&&this.emitter.emit("user:stateVersions",{epoch:p.data.StateEpoch??null,versions:E});let de=t.safeParse(p.data.Data);if(!de.success){let Re=`Validation error (${r}): ${de.error.message}`;return this.debugLogging&&console.warn("[HttpTransport]",Re),i||this.emitter.emit("error:global",Re),n("validation",Re)}return vn(de.data)}async handleWebError(e,t,i){let r=`HTTP ${t}`;try{let s=await e.text();if(s)try{let p=JSON.parse(s).Error;r=typeof p=="string"&&p.length>0?`HTTP ${t}: ${p}`:`HTTP ${t}: ${s}`;}catch{r=`HTTP ${t}: ${s}`;}}catch{}return i||this.emitter.emit("error:global",r),n("server",r)}connectionFailure(e,t){return t||this.emitter.emit("error:connection",e),n("connection",e)}globalError(e,t){return t||this.emitter.emit("error:global",e),n("server",e)}raiseBusy(){this.inFlightRequests++,this.inFlightRequests===1&&this.emitter.emit("transport:busy",true);}lowerBusy(){this.inFlightRequests>0&&(this.inFlightRequests--,this.inFlightRequests===0&&this.emitter.emit("transport:busy",false));}};function vt(o){return (typeof o=="string"?o:o.toISOString()).slice(0,10)}function Gt(o){return `${vt(o)}T00:00:00.000Z`}function $n(o){let e=new Date(o);return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+1)).toISOString()}function Zn(o,e){return new Date(o.getTime()+e*6e4).toISOString()}function Jn(o,e,t,i){let r={vcChanged:false,ccChanged:false,itemsChanged:false,tokensChanged:false};if(!e)return r;o.InventoryV2??={};let s=o.InventoryV2,a=i.toISOString(),p=new Map,D=new Map,U=new Map,E=new Map,de=new Map,Re=new Map,Pe=new Map,Qe=new Map,Ke=e.Grant?.PremiumTiers??[],et=Ke.length;for(let ne=0;;ne++){let he,Z;if(ne===0)he=e.Grant?.Standard?.Entries,Z=false;else if(ne-1<et)he=Ke[ne-1]?.Resources?.Entries,Z=false;else if(ne===1+et)he=e.Consume?.Standard?.Entries,Z=true;else break;if(he)for(let V of he){if(V.Type==null)continue;let H=Math.max(0,V.Amount??0);if(!(H<=0))switch(V.Type){case "VirtualCurrency":{if(!V.CurrencyID)continue;let $=Z?D:p;$.set(V.CurrencyID,($.get(V.CurrencyID)??0)+H);break}case "CryptoCurrency":{if(!V.CurrencyID)continue;let $=Z?E:U;$.set(V.CurrencyID,($.get(V.CurrencyID)??new ii__default.default(0)).plus(H));break}case "Item":{if(!V.ItemID)continue;let $=Tc(t,V.CatalogID,V.ItemID),ee=($?$.IsStackable??true:true)?Z?Re:de:Z?Qe:Pe;ee.set(V.ItemID,(ee.get(V.ItemID)??0)+H);break}case "Purchase":case "RewardedVideoCredit":continue}}}if(r.vcChanged=p.size>0||D.size>0,r.vcChanged){s.VirtualCurrencies??={};for(let ne of new Set([...p.keys(),...D.keys()])){let he=p.get(ne)??0,Z=D.get(ne)??0,V=he-Z,H=s.VirtualCurrencies[ne];H?(H.Amount+=V,H.UpdatedAt=a,H.Daily&&vt(H.Daily.PeriodStartUtc)===vt(i)?(H.Daily.Earned+=he,H.Daily.Spent+=Z):H.Daily={PeriodStartUtc:Gt(i),Earned:he,Spent:Z}):s.VirtualCurrencies[ne]={Amount:V,CreatedAt:a,UpdatedAt:a,Daily:{PeriodStartUtc:Gt(i),Earned:he,Spent:Z}};}}if(r.ccChanged=U.size>0||E.size>0,r.ccChanged){s.CryptoCurrencies??={};for(let ne of new Set([...U.keys(),...E.keys()])){let he=U.get(ne)??new ii__default.default(0),Z=E.get(ne)??new ii__default.default(0),V=he.minus(Z),H=s.CryptoCurrencies[ne];H?(H.Amount=new ii__default.default(H.Amount).plus(V).toString(),H.UpdatedAt=a):s.CryptoCurrencies[ne]={Amount:V.toString(),Frozen:"0",CreatedAt:a,UpdatedAt:a};}}if(r.itemsChanged=de.size>0||Re.size>0||Pe.size>0||Qe.size>0,r.itemsChanged){s.Items??={},s.UnstackableItems??={};let ne=s.UnstackableItems,he=new Set([...de.keys(),...Re.keys(),...Pe.keys(),...Qe.keys()]);for(let Z of he){let V=(de.get(Z)??0)-(Re.get(Z)??0),H=(Pe.get(Z)??0)-(Qe.get(Z)??0),$=V+H,Ae=s.Items[Z];Ae?(V!==0&&(Ae.StackableAmount+=V),H!==0&&(Ae.UnstackableAmount+=H),$!==0&&(Ae.TotalAmount+=$)):s.Items[Z]={StackableAmount:Math.max(0,V),UnstackableAmount:Math.max(0,H),TotalAmount:Math.max(0,$)};}for(let[Z,V]of Qe){if(V<=0)continue;let H=Object.values(ne).filter($=>$.ItemID===Z&&$.EquippedSlot==null&&($.ExpiresAt==null||new Date($.ExpiresAt)>i)).sort(zc).slice(0,V).map($=>$.ItemInstanceID);for(let $ of H)delete ne[$];}for(let[Z,V]of Pe){let H=vc(t,Z);for(let $=0;$<V;$++){let Ae=P();ne[Ae]={ItemInstanceID:Ae,ItemID:Z,CatalogID:H,RemainingUses:1,AcquiredAt:a};}}}o.EventToken??={};let Ru=o.EventToken;for(let ne=0;;ne++){let he,Z;if(ne===0)he=e.Grant?.Standard?.EventTokens,Z=false;else if(ne-1<et)he=Ke[ne-1]?.Resources?.EventTokens,Z=false;else if(ne===1+et)he=e.Consume?.Standard?.EventTokens,Z=true;else break;if(!(!he||he.length===0))for(let V of he){let H=V.Address;if(!H||H.Type==null)continue;let $=V.Amount??0;if($<=0)continue;let Ae=Pc(Ru,H.Type);if(!Ae)continue;let ee=Ae[H.EntityID];ee||(ee={},Ae[H.EntityID]=ee),ee.Balance??={Current:0,TotalEarned:0,TotalSpent:0},ee.Daily??={Date:Gt(i),TotalEarned:0},ee.Meta??={};let Bt=V.Source&&V.Source.length>0?V.Source:"CustomAction";Z?(ee.Balance.Current-=$,ee.Balance.TotalSpent+=$):(ee.Balance.Current+=$,ee.Balance.TotalEarned+=$,vt(ee.Daily.Date)!==vt(i)&&(ee.Daily={Date:Gt(i),TotalEarned:0}),ee.Daily.TotalEarned+=$,ee.Daily.EarnedBySource??={},ee.Daily.EarnedBySource[Bt]=(ee.Daily.EarnedBySource[Bt]??0)+$,ee.Daily.TriggersBySource??={},ee.Daily.TriggersBySource[Bt]=(ee.Daily.TriggersBySource[Bt]??0)+1,ee.Daily.LastTriggerBySource??={},ee.Daily.LastTriggerBySource[Bt]=a,ee.Meta.JoinedAtUtc||(ee.Meta.JoinedAtUtc=a),ee.Meta.LastEarnedAtUtc=a),r.tokensChanged=true;}}return r}function zc(o,e){return o.AcquiredAt!==e.AcquiredAt?o.AcquiredAt<e.AcquiredAt?-1:1:o.ItemInstanceID===e.ItemInstanceID?0:o.ItemInstanceID<e.ItemInstanceID?-1:1}function Tc(o,e,t){let i=o?.Catalogs;if(i){if(e){let r=i[e]?.Items?.[t];if(r)return r}for(let r of Object.values(i)){let s=r.Items?.[t];if(s)return s}}}function vc(o,e){let t=o?.Catalogs;if(t){for(let[i,r]of Object.entries(t))if(r.Items&&e in r.Items)return i}}function Pc(o,e){switch(e){case "TimedEvent":return o.TimedEvent??={};case "Quest":return o.Quest??={};case "Leaderboard":return o.Leaderboard??={};case "CoopEvent":return o.CoopEvent??={};case "Season":return o.Season??={};default:return null}}function ms(o,e){return o===e||o.startsWith(`${e}:`)}var ri=class{constructor(e){this.emitter=e;}emitter;currentState={};activeEventsCache=null;get state(){return this.currentState}getCachedActiveEvents(){return this.activeEventsCache}clear(){this.currentState=null,this.emitter.emit("user:anyUpdated",void 0);}applyUserState(e){this.currentState=e,this.emitter.emit("user:stateUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyUserStateContainers(e,t){if(t.length!==0){this.currentState??={};for(let i of t)this.currentState[i]=e[i];this.emitter.emit("user:stateUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}}applyInventory(e){this.currentState??={},this.currentState.InventoryV2=e,this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyVirtualCurrency(e){this.currentState??={},this.currentState.InventoryV2??={},this.currentState.InventoryV2.VirtualCurrencies=e,this.emitter.emit("user:virtualCurrencyUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyResourceOperation(e,t,i=new Date){if(!this.currentState)return;let r=Jn(this.currentState,e,t,i);r.vcChanged&&this.emitter.emit("user:virtualCurrencyUpdated",void 0),(r.vcChanged||r.ccChanged||r.itemsChanged)&&this.emitter.emit("user:inventoryUpdated",void 0),r.tokensChanged&&this.emitter.emit("user:eventTokenUpdated",void 0),(r.vcChanged||r.ccChanged||r.itemsChanged||r.tokensChanged)&&this.emitter.emit("user:anyUpdated",void 0);}patchCryptoCurrencyDelta(e,t,i){if(!e||!this.currentState)return;this.currentState.InventoryV2??={},this.currentState.InventoryV2.CryptoCurrencies??={};let r=this.currentState.InventoryV2.CryptoCurrencies,s=t instanceof ii__default.default?t:new ii__default.default(t),a=i??new Date().toISOString(),p=r[e];p?(p.Amount=new ii__default.default(p.Amount).plus(s).toString(),p.UpdatedAt=a):r[e]={Amount:s.toString(),Frozen:"0",CreatedAt:a,UpdatedAt:a},this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyStore(e){this.currentState??={},this.currentState.Store=e??{},this.emitter.emit("user:storeUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchStorePurchase(e,t,i){if(!e||t<1||!this.currentState)return;this.currentState.Store??={},this.currentState.Store.Purchases??={};let r=this.currentState.Store.Purchases,s=r[e];s||(s={OfferID:e,TotalPurchases:0,DailyPurchases:0,DailyResetUtc:"",LastPurchasedAt:""},r[e]=s),s.TotalPurchases+=t,s.LastPurchasedAt=i,i>=s.DailyResetUtc?(s.DailyPurchases=t,s.DailyResetUtc=$n(i)):s.DailyPurchases+=t,this.emitter.emit("user:storeUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyLootboxPityTriggers(e,t,i){if(!e||i<=0)return;this.currentState??={};let r=this.currentState.Lootbox??={};if(r.Pity??={},t){let s=new Date().toISOString();for(let a of t)a.RuleID&&(r.Pity[`${e}:${a.RuleID}`]={OpensSinceLastTrigger:0,LastTriggeredAtUtc:s});}this.emitter.emit("user:lootboxUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyReward(e){this.currentState??={},this.currentState.Reward=e??{},this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchDailyCalendarState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.DailyCalendars??={},this.currentState.Reward.DailyCalendars[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchIdleAccrualState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.IdleAccruals??={},this.currentState.Reward.IdleAccruals[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchComebackState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.Comebacks??={},this.currentState.Reward.Comebacks[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchClaimRewardState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.Claims??={},this.currentState.Reward.Claims[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyQuest(e){this.currentState??={},this.currentState.Quest=e??{},this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchQuestStatus(e,t,i){if(!e)return;this.currentState??={},this.currentState.Quest??={};let r=this.currentState.Quest;if(t){r.Cycles??={};let s=r.Cycles[t];if(!s)return;s.Quests??={};let a=s.Quests[e]??={QuestID:e,Status:i};a.Status=i,i==="Claimed"&&(a.ClaimedAtUtc??=new Date().toISOString());}else {r.PermanentQuests??={};let s=r.PermanentQuests[e]??={QuestID:e,Status:i};s.Status=i,i==="Claimed"&&(s.ClaimedAtUtc??=new Date().toISOString());}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchMilestoneClaimed(e,t){if(!e||!t)return;let i=this.getQuestPointsProgress(e);i&&(i.Milestone??={},i.Milestone.ClaimedIDs??=[],i.Milestone.ClaimedIDs.includes(t)||i.Milestone.ClaimedIDs.push(t),this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchQuestPointsTracks(e){if(!e)return;this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.Quest??={};let t=this.currentState.EventToken.Quest;for(let i of Object.values(e)){if(!i.CycleID)continue;let r=i.InstanceKey?`${i.CycleID}:${i.InstanceKey}`:i.CycleID,s=t[r]??={};s.Balance??={Current:0,TotalEarned:0,TotalSpent:0},s.Balance.Current=i.PointsCurrent??0,s.Balance.TotalEarned=i.PointsTotalEarned??0,s.Milestone??={},s.Milestone.ClaimedIDs=i.ClaimedPointMilestoneIDs??[];}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchGroupCompletionClaimed(e,t){if(!e||!t)return;this.currentState??={},this.currentState.Quest??={},this.currentState.Quest.Cycles??={};let i=this.currentState.Quest.Cycles[e];i&&(i.ClaimedGroupCompletionIDs??=[],i.ClaimedGroupCompletionIDs.includes(t)||i.ClaimedGroupCompletionIDs.push(t),this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyTutorial(e){this.currentState??={},this.currentState.Tutorial=e??{},this.emitter.emit("user:tutorialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchTutorialFlow(e){if(!e?.FlowID)return;this.currentState??={},this.currentState.Tutorial??={};let t=this.currentState.Tutorial;t.Flows??={};let i=t.Flows[e.FlowID]??={FlowID:e.FlowID};i.Status=e.Status,i.CurrentStepID=e.CurrentStepID??null,i.RewardClaimed=e.RewardClaimed,e.VariantID!==void 0&&(i.VariantID=e.VariantID),this.emitter.emit("user:tutorialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchTutorialProgress(e){if(!e||e.length===0)return;this.currentState??={},this.currentState.Tutorial??={};let t=this.currentState.Tutorial;t.Flows??={};for(let i of e){if(!i.FlowID||!i.StepID)continue;let r=t.Flows[i.FlowID]??={FlowID:i.FlowID,Status:"InProgress"};r.Steps??={};let s=r.Steps[i.StepID]??={StepID:i.StepID};s.Progress=i.Progress,i.Completed&&(s.CompletedAtUtc??=new Date().toISOString(),r.CurrentStepID===i.StepID&&(r.CurrentStepID=null));}this.emitter.emit("user:tutorialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchQuestProgressUpdates(e){if(!e||e.length===0)return;this.currentState??={},this.currentState.Quest??={};let t=this.currentState.Quest;for(let i of e){if(!i.QuestID)continue;let r;if(!i.CycleID)t.PermanentQuests??={},r=t.PermanentQuests[i.QuestID]??={QuestID:i.QuestID,Status:i.Status};else {t.Cycles??={};let s=t.Cycles[i.CycleID];if(!s)continue;s.Quests??={},r=s.Quests[i.QuestID]??={QuestID:i.QuestID,Status:i.Status};}if(r.Status=i.Status,i.ObjectiveID){r.Objectives??={};let s=r.Objectives[i.ObjectiveID]??={ObjectiveID:i.ObjectiveID,CurrentValue:0,Completed:false};s.CurrentValue=i.NewValue??0,i.ObjectiveCompleted&&(s.Completed=true,s.CompletedAtUtc??=new Date().toISOString());}i.Status==="Completed"&&(r.CompletedAtUtc??=new Date().toISOString());}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}getQuestPointsProgress(e){if(!e)return null;let t=this.currentState?.EventToken?.Quest;if(!t)return null;for(let[i,r]of Object.entries(t))if(ms(i,e)&&r)return r;return null}applyActiveEvents(e){this.activeEventsCache=e??{},this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyUserLteState(e){e&&(this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.TimedEvent=e.Tokens??{},this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchTimedEventMilestoneClaimed(e,t,i){if(!(!t||!i)){this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.TimedEvent??={};for(let[r,s]of Object.entries(this.currentState.EventToken.TimedEvent))!ms(r,t)||!s||this.markMilestoneClaimed(s.Milestone??(s.Milestone={}),i);this.patchActiveEventMilestoneClaimed(e,t,i),this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}}patchActiveEventMilestoneClaimed(e,t,i){let r=this.activeEventsCache?.ActiveEvents;if(r)for(let s of r)s.Type!==e||s.TimedEventID!==t||(s.Progress??={},this.markMilestoneClaimed(s.Progress.Milestone??(s.Progress.Milestone={}),i));}markMilestoneClaimed(e,t){if(e.ClaimedIDs??=[],e.ClaimedIDs.includes(t)||e.ClaimedIDs.push(t),e.UnlockedIDs){let i=e.UnlockedIDs.indexOf(t);i>=0&&e.UnlockedIDs.splice(i,1);}}patchLeaderboardMyProgress(e,t){if(!e||!t)return;let i=this.ensureLeaderboardProgress(e);i.CurrentScore=t.CurrentScore??0,i.LastKnownRank=t.LastKnownRank??0,i.ScoreEarnedThisCycle=t.ScoreEarnedThisCycle??0,i.UnclaimedRewardCycleVersion=t.HasUnclaimedReward?Math.max(1,i.UnclaimedRewardCycleVersion??0):0,this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchLeaderboardScoreSubmitted(e,t,i,r){if(!e)return;let s=this.ensureLeaderboardProgress(e);(s.ScoreCycleVersion??0)<r&&(s.ScoreEarnedThisCycle=0,s.ClaimedMilestoneIDs=[],s.BracketID=null),s.CurrentScore=t,s.ScoreEarnedThisCycle=(s.ScoreEarnedThisCycle??0)+i,s.ScoreCycleVersion=r,s.LastScoreSubmitUtc=new Date().toISOString(),this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchLeaderboardCycleRewardClaimed(e){if(!e)return;let t=this.currentState?.Leaderboard?.ProgressByCycle?.[e];t&&(t.UnclaimedRewardCycleVersion=0,this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchLeaderboardMilestoneClaimed(e,t){if(!e||!t)return;let i=this.ensureLeaderboardProgress(e);i.ClaimedMilestoneIDs??=[],i.ClaimedMilestoneIDs.includes(t)||i.ClaimedMilestoneIDs.push(t),this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureLeaderboardProgress(e){this.currentState??={},this.currentState.Leaderboard??={},this.currentState.Leaderboard.ProgressByCycle??={};let t=this.currentState.Leaderboard.ProgressByCycle,i=t[e];return i||(i={CurrentScore:0,ScoreEarnedThisCycle:0,ScoreCycleVersion:0,UnclaimedRewardCycleVersion:0,LastKnownRank:0},t[e]=i),i}applySeasonsState(e){this.currentState??={},this.currentState.Season=e??{},this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSeasonState(e,t){!e||!t||(this.currentState??={},this.currentState.Season??={},this.currentState.Season.States??={},this.currentState.Season.States[e]=t,this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchSeasonCurrentTier(e,t){if(!e)return;let i=this.ensureSeasonState(e);i.CurrentTier=t,this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSeasonClaimedTier(e,t){if(!e)return;let i=this.ensureSeasonState(e);i.ClaimedTierRewards??=[],i.ClaimedTierRewards.includes(t)||i.ClaimedTierRewards.push(t),this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureSeasonState(e){this.currentState??={},this.currentState.Season??={},this.currentState.Season.States??={};let t=this.currentState.Season.States,i=t[e];return i||(i={SeasonChainID:e},t[e]=i),i}applyPremium(e){this.currentState??={},this.currentState.Premium=e??{},this.emitter.emit("user:premiumUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCharacter(e){this.currentState??={},this.currentState.Character??={},this.currentState.Character.Characters=e??{},this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCharacter(e,t){if(!e)return;this.currentState??={},this.currentState.Character??={},this.currentState.Character.Characters??={};let i=this.currentState.Character.Characters,r=i[e];r||(r={CharacterID:e},i[e]=r),t(r),this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCharacterEquipment(e,t,i){if(!e||!t)return;let r=this.currentState?.Character?.Characters?.[e];r&&(r.Equipment??={},i===null?delete r.Equipment[t]:r.Equipment[t]=i,this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyInventoryDelta(e){if(!e)return;this.currentState??={},this.currentState.InventoryV2??={},this.currentState.InventoryV2.UnstackableItems??={};let t=this.currentState.InventoryV2.UnstackableItems,i=false;for(let[r,s]of Object.entries(e.ChangedInstances??{}))t[r]=s,i=true;for(let r of e.RemovedInstanceIDs??[])r in t&&(delete t[r],i=true);i&&(this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyMatch(e){this.currentState??={},this.currentState.Match=e??{},this.emitter.emit("user:matchUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchMatchStrategy(e){e&&(this.currentState??={},this.currentState.Match??={},this.currentState.Match.PvPBattleStrategy=e,this.emitter.emit("user:matchUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyCollection(e){this.currentState??={},this.currentState.Collection=e??{},this.emitter.emit("user:collectionUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCoopEvent(e){this.currentState??={},this.currentState.CoopEvent=e??{MyObjectIndex:-1},this.emitter.emit("user:coopEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCoopEventActiveGroup(e,t,i){this.currentState??={};let r=this.currentState.CoopEvent??={MyObjectIndex:-1};r.ActiveGroupID=e,r.ActiveCoopEventID=t,r.MyObjectIndex=i,this.emitter.emit("user:coopEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyDealOffer(e){this.currentState??={},this.currentState.DealOffer=e??{},this.emitter.emit("user:dealOfferUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyReferral(e){this.currentState??={},this.currentState.Referral=e??{},this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchReferralSubscription(e){e&&(this.currentState??={},this.currentState.Referral??={},this.currentState.Referral.SubscribedToUserID=e,this.currentState.Referral.UpdatedAt=new Date().toISOString(),this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchReferralInviteRewardClaimed(e){e&&(this.currentState??={},this.currentState.Referral??={},this.currentState.Referral.InviteRewardStates??={},this.currentState.Referral.InviteRewardStates[e]={RewardID:e,IsClaimed:true,ClaimedAt:new Date().toISOString()},this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applySocialFriendsList(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.Accepted=(e??[]).map(t=>t.UserID),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applySocialIncomingRequests(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.IncomingRequests=(e??[]).map(t=>t.UserID),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applySocialTimeline(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.Timeline=e??[],this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialAddOutgoingRequest(e){if(!e)return;let t=this.ensureSocial();t.OutgoingRequests??=[],t.OutgoingRequests.includes(e)||t.OutgoingRequests.push(e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialAcceptFriend(e){if(!e)return;let t=this.ensureSocial();t.IncomingRequests=(t.IncomingRequests??[]).filter(i=>i!==e),t.Accepted??=[],t.Accepted.includes(e)||t.Accepted.push(e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialRemoveIncomingRequest(e){if(!e)return;let t=this.ensureSocial();t.IncomingRequests=(t.IncomingRequests??[]).filter(i=>i!==e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialRemoveFriend(e){if(!e)return;let t=this.ensureSocial();t.Accepted=(t.Accepted??[]).filter(i=>i!==e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureSocial(){return this.currentState??={},this.currentState.Social??={},this.currentState.Social}applyTimedBoost(e){this.currentState??={},this.currentState.TimedBoost=e??{},this.emitter.emit("user:timedBoostUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchActiveTimedBoost(e,t){this.currentState??={},this.currentState.TimedBoost??={},this.currentState.TimedBoost.Active??={};let i=this.currentState.TimedBoost.Active;if(t==="Replace"||t==="KeepBest")for(let r of Object.keys(i)){let s=i[r];s&&s.BoostID===e.BoostID&&r!==e.InstanceID&&delete i[r];}i[e.InstanceID]=e,this.emitter.emit("user:timedBoostUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyUserCustomData(e){this.currentState??={},this.currentState.CustomData??={};let t=this.currentState.CustomData;t.Version=e.Version??0,t.Private=e.Private??{},t.Public=e.Public??{},t.ReadOnly=e.ReadOnly??{},this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchUserCustomDataKey(e,t,i,r,s){if(!t)return;this.currentState??={},this.currentState.CustomData??={};let a=this.currentState.CustomData,p={Value:i,UpdatedAt:new Date().toISOString(),Version:r,LastWriter:"Client",ExpiresAt:s??null};if(e==="Private")a.Private??={},a.Private[t]=p;else if(e==="Public")a.Public??={},a.Public[t]=p;else return;a.Version=(a.Version??0)+1,this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}removeUserCustomDataKey(e,t){if(!t||!this.currentState?.CustomData)return;let i=this.currentState.CustomData;if(e==="Private")i.Private&&delete i.Private[t];else if(e==="Public")i.Public&&delete i.Public[t];else return;this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyBoardState(e){this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.Board=e??{},this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCommunityChestUserState(e){this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.CommunityChest=e??{},this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardState(e){let t=this.ensureBoard();e(t),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardBuilding(e,t){if(e<0)return;let i=this.ensureBoard();i.BuildingStates??=[];let r=i.BuildingStates.find(s=>s.SlotIndex===e);r||(r={SlotIndex:e},i.BuildingStates.push(r)),t(r),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardPendingRaidLayout(e,t){let r=this.ensureBoard().Pending;r&&(e&&(r.RaidLayout=e),t>=0&&(r.OpenedIndices??=[],r.OpenedIndices.includes(t)||r.OpenedIndices.push(t)),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchBoardSpecialPending(e){let i=this.ensureBoard().Pending;!i||i.Type.toUpperCase()!=="SPECIAL"||(i.Special??={},e(i.Special),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}clearBoardPending(){let e=this.currentState?.GameLoop?.Board;!e||!e.Pending||(e.Pending=null,this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}ensureBoard(){return this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.Board??={},this.currentState.GameLoop.Board}applyBlockchainState(e,t){this.currentState??={},this.currentState.Blockchain=e??{},t&&(this.currentState.InventoryV2??={},this.currentState.InventoryV2.CryptoCurrencies=t),this.emitter.emit("user:blockchainUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyMarketplaceState(e){this.currentState??={},this.currentState.Marketplace=e??{},this.emitter.emit("user:marketplaceUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}getVirtualCurrencyAmount(e){return this.currentState?.InventoryV2?.VirtualCurrencies?.[e]?.Amount??0}getCryptoCurrencyAmount(e){return this.currentState?.InventoryV2?.CryptoCurrencies?.[e]?.Amount??"0"}};var si=class{config=null;sections=new Map;itemDefs;currencyDefs;get titlePublicConfiguration(){return this.config}patchSection(e,t){this.sections.set(e,t);}getSection(e){return this.sections.get(e)}applyTitlePublicConfiguration(e){this.config=e&&typeof e=="object"?e:null;}get itemDefinitions(){return this.itemDefs??this.config?.Item??void 0}applyItemDefinitions(e){this.itemDefs=e;}get currencyDefinitions(){return this.currencyDefs??this.config?.Currency??void 0}applyCurrencyDefinitions(e){this.currencyDefs=e;}};var ni=class{user;config;constructor(e){this.user=new ri(e),this.config=new si;}reset(){this.user.clear(),this.config.applyTitlePublicConfiguration(null);}};var oi=class{constructor(e,t){this.storage=e;this.authTypeKey=`Saved_AuthType_${t}`,this.emailKey=`Saved_Auth_Email_${t}`,this.passwordKey=`Saved_Auth_Password_${t}`;}storage;authTypeKey;emailKey;passwordKey;get lastAuthType(){let e=this.storage.getString(this.authTypeKey);return Ic(e)?e:me.None}saveAuthType(e){this.storage.setString(this.authTypeKey,e);}get savedEmail(){return this.storage.getString(this.emailKey)??""}get savedPassword(){return this.storage.getString(this.passwordKey)??""}saveEmailAndPassword(e,t){this.storage.setString(this.emailKey,e),this.storage.setString(this.passwordKey,t);}clear(){this.storage.remove(this.authTypeKey),this.storage.remove(this.emailKey),this.storage.remove(this.passwordKey);}};function Ic(o){return o!==null&&Object.values(me).includes(o)}var kc=8,Mc=100,wc=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i,Yn=["GameLoop"],ai=class{constructor(e){this.ctx=e;}ctx;authContext=null;refreshing=false;rememberSession=true;sessionAuthType=me.None;sessionEmail="";sessionPassword="";get context(){return this.authContext}get isLoggedIn(){return this.authContext!==null&&this.authContext.userID.length>0&&this.authContext.clientSessionTicket.length>0}get lastAuthType(){return this.ctx.authStore.lastAuthType}setRememberSession(e){this.rememberSession=e;}get remembersSession(){return this.rememberSession}baseRequest(){return {BuildKey:this.ctx.settings.buildKey,WebAppLink:this.ctx.platform.getFullURL()}}async loginWithDeviceID(){this.ctx.emitter.emit("auth:requestSent",void 0);let e=this.baseRequest();e.DeviceID=this.ctx.platform.getDeviceID(),e.Device=this.ctx.platform.getDeviceModel(),e.Platform=this.ctx.platform.getPlatform();let t=await this.ctx.api.authentication.loginWithDeviceID(e);return t.ok?(this.applyAuthContext(t.data),this.fetchAndApplyClientState(me.Device)):t}async loginWithTelegram(){this.ctx.emitter.emit("auth:requestSent",void 0);let e=this.ctx.platform.getTelegramInitDataRaw();if(!e)return n("client","Telegram initData is not available.");let t=this.baseRequest();t.TelegramInitData=e;let i=await this.ctx.api.authentication.loginWithTelegram(t);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(me.Telegram)):i}async loginWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();i.Email=e,i.Password=t;let r=await this.ctx.api.authentication.loginWithEmail(i);if(!r.ok)return r;this.applyAuthContext(r.data);let s=await this.fetchAndApplyClientState(me.Email);return s.ok&&this.keepEmailCredentials(e,t),s}async registerWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();i.Email=e,i.Password=t,i.DeviceID=this.ctx.platform.getDeviceID(),i.Device=this.ctx.platform.getDeviceModel(),i.Platform=this.ctx.platform.getPlatform();let r=await this.ctx.api.authentication.registerWithEmail(i);if(!r.ok)return r;this.applyAuthContext(r.data);let s=await this.fetchAndApplyClientState(me.Email);return s.ok&&this.keepEmailCredentials(e,t),s}async loginWithGoogle(e){this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.GoogleIDToken=e;let i=await this.ctx.api.authentication.loginWithGoogle(t);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(me.Google)):i}async requestWalletChallenge(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();return i.WalletAddress=e,i.NetworkID=t,this.ctx.api.authentication.requestWalletChallenge(i)}async loginWithWallet(e,t,i){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();r.WalletAddress=e,r.NetworkID=t,r.WalletSignature=i,r.Platform=this.ctx.platform.getPlatform(),r.Device=this.ctx.platform.getDeviceModel(),r.DeviceID=this.ctx.platform.getDeviceID();let s=await this.ctx.api.authentication.loginWithWallet(r);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(me.Wallet)):s}async loginWithPlatformToken(e){if(!e)return n("client","AuthToken is null or empty.");this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.PlatformAuthToken=e,t.DeviceID=this.ctx.platform.getDeviceID(),t.Device=this.ctx.platform.getDeviceModel(),t.Platform=this.ctx.platform.getPlatform();let i=await this.ctx.api.authentication.loginWithPlatformToken(t);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(me.iDosGames)):i}async loginWithSsoCode(e){if(!e)return n("client","SSO code is null or empty.");this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.SsoCode=e,t.DeviceID=this.ctx.platform.getDeviceID(),t.Device=this.ctx.platform.getDeviceModel(),t.Platform=this.ctx.platform.getPlatform();let i=await this.ctx.api.authentication.loginWithSsoCode(t);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(me.iDosGames)):i}async forgotPassword(e){this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();return t.Email=e,this.ctx.api.authentication.forgotPassword(t)}async resetPassword(e,t,i){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();return r.Email=e,r.ResetToken=t,r.Password=i,this.ctx.api.authentication.resetPassword(r)}autoLogin(){return this.replay(this.ctx.authStore.lastAuthType,this.ctx.authStore.savedEmail,this.ctx.authStore.savedPassword)}replay(e,t,i){switch(e){case me.Email:return this.loginWithEmail(t,i);case me.Device:case me.None:return this.loginWithDeviceID();case me.Telegram:return this.loginWithTelegram();default:return Promise.resolve(n("client",`Cannot auto-login: last session used "${e}", which requires a fresh token from the platform SDK. Obtain a new token and call the matching login method (e.g. loginWithGoogle) instead of autoLogin().`))}}async refreshSession(){if(this.refreshing)return null;let e=this.sessionAuthType!==me.None?this.sessionAuthType:this.ctx.authStore.lastAuthType;if(e===me.None)return null;this.refreshing=true;try{return (await this.replay(e,this.sessionEmail||this.ctx.authStore.savedEmail,this.sessionPassword||this.ctx.authStore.savedPassword)).ok&&this.authContext?this.authContext.clientSessionTicket:null}catch{return null}finally{this.refreshing=false;}}logout(){this.authContext=null,this.forgetSession(),this.ctx.authStore.clear(),this.ctx.data.reset(),this.ctx.emitter.emit("auth:loggedOut",void 0);}static isValidEmail(e){return e.length>0&&wc.test(e)}static isValidPasswordLength(e){return e.length>=kc&&e.length<=Mc}keepEmailCredentials(e,t){this.sessionEmail=e,this.sessionPassword=t,this.rememberSession&&this.ctx.authStore.saveEmailAndPassword(e,t);}forgetSession(){this.sessionAuthType=me.None,this.sessionEmail="",this.sessionPassword="";}applyAuthContext(e){this.authContext={userID:e.TitleUserID,clientSessionTicket:e.TitleClientSessionTicket,clientSessionTicketExpiration:e.TitleClientSessionTicketExpiration,platformUserID:e.PlatformUserID??void 0,platformAuthToken:e.PlatformAuthToken??void 0,platformAuthTokenExpiration:e.PlatformAuthTokenExpiration??void 0};}async fetchAndApplyClientState(e){let t=await this.ctx.userService.getClientStateExcept(Yn,Yn);return t.ok&&(this.sessionAuthType=e,this.rememberSession?this.ctx.authStore.saveAuthType(e):this.ctx.authStore.clear(),this.ctx.emitter.emit("auth:loggedIn",void 0)),t}};var Oc="idos:cfg",Pt=class{constructor(e,t){this.storage=e;this.titleId=t;}storage;titleId;static scopeOf(e,t){return t&&t.length>0?`x:${Xn(t)}`:e&&e.length>0?`f:${Xn(e)}`:t?"x:":"f:"}async read(e){try{let t=await this.storage.get(this.keyOf(e));if(!t)return null;let i=JSON.parse(t);return !i||typeof i!="object"||typeof i.v!="string"||!i.c?null:i}catch{return null}}async write(e,t,i){try{let r={v:t,c:i};await this.storage.set(this.keyOf(e),JSON.stringify(r));}catch{}}async clear(e){try{await this.storage.remove(this.keyOf(e));}catch{}}keyOf(e){return `${Oc}:${this.titleId}:${e}`}};function Xn(o){return [...o].map(e=>e.toLowerCase()).sort().join(",")}var eo="idos:loc",It=class{constructor(e,t){this.storage=e;this.titleId=t;}storage;titleId;async read(e){try{let t=await this.storage.get(this.keyOf(e));if(!t)return null;let i=JSON.parse(t);return !i||typeof i!="object"||typeof i.v!="number"||!i.t||typeof i.t!="object"?null:i}catch{return null}}async write(e,t,i){try{let r={v:t,t:i};await this.storage.set(this.keyOf(e),JSON.stringify(r)),await this.noteVersion(e,t);}catch{}}async readVersions(){try{let e=await this.storage.get(this.versionsKey());if(!e)return {};let t=JSON.parse(e);if(!t||typeof t!="object")return {};let i={};for(let[r,s]of Object.entries(t))typeof s=="number"&&s>0&&(i[r]=s);return i}catch{return {}}}async noteVersion(e,t){let i=await this.readVersions();i[e]!==t&&(i[e]=t,await this.storage.set(this.versionsKey(),JSON.stringify(i)));}keyOf(e){return `${eo}:${this.titleId}:${e}`}versionsKey(){return `${eo}:${this.titleId}:versions`}};var Ac="idos:state",li=class{constructor(e,t){this.storage=e;this.titleId=t;}storage;titleId;async read(e){if(!e)return null;try{let t=await this.storage.get(this.keyOf(e));if(!t)return null;let i=JSON.parse(t);return !i||typeof i!="object"||typeof i.e!="string"||!i.v||!i.s?null:i}catch{return null}}async write(e,t,i,r){if(!(!e||!t))try{let s={e:t,v:i,s:r};await this.storage.set(this.keyOf(e),JSON.stringify(s));}catch{}}keyOf(e){return `${Ac}:${this.titleId}:${e}`}};function Uc(o,e){if(!o)return;let t=new Set((e??[]).map(r=>r.trim().toLowerCase()));if(t.size===0)return o;let i={};for(let[r,s]of Object.entries(o))t.has(r.toLowerCase())||(i[r]=s);return i}function gs(o,e,t,i){let r={...o??{}};if(!e||!t||!i)return r;for(let[s,a]of Object.entries(t))i[s]===a&&s in e&&(r[s]=e[s]);return r}function Bc(o){return {...o??{}}}function Rs(o){return typeof o.StateEpoch=="string"&&o.StateEpoch.length>0?o.StateEpoch:null}var ui=class{constructor(e){this.cache=e;}cache;loadedFor=null;epoch=null;versions={};state=null;dirty=false;async load(e){if(this.loadedFor===e)return;let t=await this.cache.read(e);this.loadedFor=e,this.epoch=t?.e??null,this.versions=t?{...t.v}:{},this.state=t?.s??null,this.dirty=false;}get cachedState(){return this.state}get currentEpoch(){return this.epoch}versionsFor(e){if(!this.epoch)return;let t=Uc(this.versions,e);return t&&Object.keys(t).length>0?t:void 0}noteMutation(e,t){if(!e||e!==this.epoch){e&&e!==this.epoch&&this.reset(e);return}for(let[i,r]of Object.entries(t)){let s=this.versions[i];s!==void 0&&r===s+1?this.versions[i]=r:delete this.versions[i],this.dirty=true;}}afterFullRead(e,t){e!==this.epoch&&this.reset(e),this.versions=Bc(t),this.dirty=true;}afterSliceRead(e,t){e!==this.epoch&&this.reset(e);for(let[i,r]of Object.entries(t??{}))this.versions[i]=r;this.dirty=true;}async flush(e,t){!this.dirty||!this.epoch||!e||(this.state=t??{},this.dirty=false,await this.cache.write(e,this.epoch,this.versions,this.state));}reset(e){this.epoch=e,this.versions={},this.state=null,this.dirty=true;}};var to=n("server","Title configuration is unavailable (CDN and API both failed)."),ci=class{constructor(e){this.ctx=e;}ctx;baseRequest(){let e=this.ctx.auth.context;return e?{UserID:e.userID,ClientSessionTicket:e.clientSessionTicket,BuildKey:this.ctx.settings.buildKey,WebAppLink:this.ctx.platform.getFullURL(),RelatedEntityID:P()}:null}get configCache(){return this.cache??=new Pt(this.ctx.settings.configStorage,this.ctx.settings.titleID)}cache;get localizationCache(){return this.locCache??=new It(this.ctx.settings.configStorage,this.ctx.settings.titleID)}locCache;get stateStore(){return this.versionStore??=new ui(new li(this.ctx.settings.configStorage,this.ctx.settings.titleID))}versionStore;noteStateVersions(e,t){this.ctx.auth.context?.userID&&this.stateStore.currentEpoch&&this.stateStore.noteMutation(e,t);}async getClientState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=Pt.scopeOf(e.TitleFields,null),i=await this.configCache.read(t);i&&(e.KnownTitleConfigVersion=i.v),await this.prepareLocalization(e);let r=await this.prepareStateHandshake(e,null),s=await this.ctx.api.user.getClientState(e);if(!s.ok)return s;let a=await this.resolveTitleConfig(s.data,t,i,{Fields:e.TitleFields});return a==null?to:(this.finishStateHandshake(s.data,r),await this.applyClientState(s.data,a,void 0,void 0),await this.applyLocalization(s.data.Localization),await this.flushState(r),s)}async prepareStateHandshake(e,t){let i=this.ctx.auth.context?.userID;if(!i)return {userId:null,cached:null,sent:void 0};await this.stateStore.load(i),await this.stateStore.flush(i,this.ctx.data.user.state);let r=this.stateStore.versionsFor(t);if(r){e.KnownStateVersions=r;let s=this.stateStore.currentEpoch;s&&(e.KnownStateEpoch=s);}return {userId:i,cached:this.stateStore.cachedState,sent:r}}finishStateHandshake(e,t){let i=gs(e.User,t.cached,t.sent,e.StateVersions);e.User=i;let r=Rs(e);!r||!t.userId||this.stateStore.afterFullRead(r,e.StateVersions);}async resolveTitleConfig(e,t,i,r){let s=e.TitleConfigVersion;if(i&&s&&i.v===s)return i.c;if(e.TitleConfigUrl){let p=await this.fetchConfigFromCdn(e.TitleConfigUrl);if(p!=null)return s&&await this.configCache.write(t,s,p),p}let a=await this.fetchConfigFromApi(r);return a!=null?(s&&await this.configCache.write(t,s,a),a):i?.c??null}async fetchConfigFromCdn(e){try{let t=await this.ctx.fetchImpl(e);if(!t.ok)return null;let i=await t.json();return i&&typeof i=="object"?i:null}catch{return null}}async fetchConfigFromApi(e){let t=this.baseRequest();if(!t)return null;let i={...t,...e},r=e.ExcludeFields?await this.ctx.api.title.getTitlePublicConfigurationExcept(i):await this.ctx.api.title.getTitlePublicConfiguration(i);return r.ok?r.data:null}async getClientStateExcept(e,t){let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.ExcludeFields=e,i.ExcludeTitleFields=t;let r=Pt.scopeOf(null,t??[]),s=await this.configCache.read(r);s&&(i.KnownTitleConfigVersion=s.v),await this.prepareLocalization(i);let a=await this.prepareStateHandshake(i,e??null),p=await this.ctx.api.user.getClientStateExcept(i);if(!p.ok)return p;let D=await this.resolveTitleConfig(p.data,r,s,{ExcludeFields:t??[]});return D==null?to:(this.finishStateHandshake(p.data,a),await this.applyClientState(p.data,D,e,t),await this.applyLocalization(p.data.Localization),await this.flushState(a),p)}async prepareLocalization(e){let t=this.ctx.localization.locale??this.ctx.settings.locale;t&&(e.Locale=t);let i=await this.localizationCache.readVersions();Object.keys(i).length>0&&(e.KnownLocalizationVersions=i);}async applyLocalization(e){if(!e){this.ctx.localization.applyState(null,{table:null,fallbackTable:null});return}let t=await this.resolveLocalizationTable({Locale:e.Locale,Version:e.Version,Url:e.Url}),i=e.Fallback?await this.resolveLocalizationTable(e.Fallback):null;this.ctx.localization.applyState(e,{table:t,fallbackTable:i});}async resolveLocalizationTable(e){let t=e.Locale??null,i=e.Version??0;if(!t)return null;let r=await this.localizationCache.read(t);if(i<=0)return r?.t??null;if(r&&r.v===i)return r.t;if(e.Url){let a=await this.fetchLocalizationFromCdn(e.Url);if(a!=null)return await this.localizationCache.write(t,i,a),a}let s=await this.fetchLocalizationFromApi(t,r?.v??0);return s??r?.t??null}async fetchLocalizationFromCdn(e){try{let t=await this.ctx.fetchImpl(e);if(!t.ok)return null;let i=await t.json();return i&&typeof i=="object"?i:null}catch{return null}}async fetchLocalizationFromApi(e,t){let i=this.baseRequest();if(!i)return null;let r=await this.ctx.api.localization.getLocalizationTable({...i,Locale:e,KnownVersion:t});if(!r.ok)return null;let s=r.data;if(s.NotModified)return null;let a=s.Entries??{},p=s.Version??0,D=s.Locale??e;return p>0&&await this.localizationCache.write(D,p,a),a}async getStateVersions(e){let t=this.baseRequest();return t?(e&&e.length>0&&(t.Fields=e),this.ctx.api.user.getStateVersions(t)):n("unauthorized","Not logged in.")}async getUserState(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&e.length>0&&(t.Fields=e);let i=await this.prepareStateHandshake(t,null),r=await this.ctx.api.user.getUserState(t);if(!r.ok)return r;let s=gs(r.data.User,i.cached,i.sent,r.data.StateVersions);r.data.User=s;let a=Object.keys(r.data.StateVersions??{});this.ctx.data.user.applyUserStateContainers(s,a);let p=Rs(r.data);return p&&(this.stateStore.afterSliceRead(p,r.data.StateVersions),await this.flushState(i)),r}async flushState(e){e.userId&&await this.stateStore.flush(e.userId,this.ctx.data.user.state);}async getUserInventory(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getInventory(e);return t.ok&&(this.ctx.data.user.applyInventory(t.data),this.ctx.emitter.emit("user:inventoryReceived",t.data)),t}async getEventTokens(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getEventTokens(e);return t.ok&&this.ctx.emitter.emit("user:eventTokensReceived",t.data),t}async getUsageTime(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getUsageTime(e);return t.ok&&this.ctx.emitter.emit("user:usageTimeReceived",t.data),t}async addUsageTime(e,t,i){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.UsageTime=e,r.IsNewSession=t,r.SessionDurationSeconds=i;let s=await this.ctx.api.user.addUsageTime(r);return s.ok&&this.ctx.emitter.emit("user:usageTimeAdded",s.data),s}async deleteUserAccount(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.deleteUserAccount(e);return t.ok&&this.ctx.emitter.emit("user:accountDeleted",t.data),t}async changeUsername(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Username=e;let i=await this.ctx.api.user.changeUsername(t);return i.ok&&this.ctx.emitter.emit("user:usernameChanged",i.data),i}async applyClientState(e,t,i,r){let s=i?.includes("GameLoop")===true,a=r?.includes("GameLoop")===true,p=s?this.ctx.data.user.state?.GameLoop:void 0,D=a?this.ctx.data.config.titlePublicConfiguration?.GameLoop:void 0;this.ctx.data.config.applyTitlePublicConfiguration(t),this.ctx.data.user.applyUserState(e.User??{});let U=this.ctx.data.user.state;s&&U&&U.GameLoop==null&&(U.GameLoop=p);let E=this.ctx.data.config.titlePublicConfiguration;a&&E&&E.GameLoop==null&&(E.GameLoop=D),this.ctx.emitter.emit("user:clientStateReceived",e);}};var di=class{constructor(e){this.ctx=e;}ctx;async convert(e,t,i,r,s,a){if(!t)return n("client","SourceID is required.");if(!r)return n("client","TargetID is required.");if(s<=0)return n("client","Amount must be positive.");if(e===i&&t===r)return n("client","Source and target must differ.");if(e===je.Crypto||i===je.Crypto)return n("client","Convert supports VC\u2194VC only. Use cryptoConvert for crypto.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let p={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:i,TargetID:r,SourceAmount:String(Math.trunc(s)),TransactionID:a&&a.length>0?a:`convert_${e}_${t}_to_${i}_${r}_${P()}`},D=await this.ctx.api.currency.convert(p);if(D.ok){let U=D.data,E={Consume:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:U.SourceID,Amount:U.SourceSpent}]}},Grant:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:U.TargetID,Amount:U.TargetCredited}]}}};this.ctx.data.user.applyResourceOperation(E,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("currency:converted",U);}return D}async cryptoConvert(e,t,i,r,s,a){let p=s instanceof ii__default.default?s:new ii__default.default(s);if(!t)return n("client","SourceID is required.");if(!r)return n("client","TargetID is required.");if(p.lte(0))return n("client","SourceAmount must be a positive decimal.");if(e===i&&t===r)return n("client","Source and target must differ.");if(e===je.Virtual&&i===je.Virtual)return n("client","cryptoConvert requires at least one crypto side. Use convert for VC\u2194VC.");if(e===je.Virtual&&!p.isInteger())return n("client","Virtual currency source amount must be integer.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let D={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:i,TargetID:r,SourceAmount:p.toString(),TransactionID:a&&a.length>0?a:`crypto_convert_${e}_${t}_to_${i}_${r}_${P()}`},U=await this.ctx.api.currency.cryptoConvert(D);if(U.ok){let E=U.data,de=[],Re=[];if(E.SourceType===je.Virtual&&de.push({Type:"VirtualCurrency",CurrencyID:E.SourceID,Amount:Math.trunc(Number(E.SourceSpent))}),E.TargetType===je.Virtual&&Re.push({Type:"VirtualCurrency",CurrencyID:E.TargetID,Amount:Math.trunc(Number(E.TargetCredited))}),de.length>0||Re.length>0){let Pe={Consume:de.length>0?{Standard:{Entries:de}}:null,Grant:Re.length>0?{Standard:{Entries:Re}}:null};this.ctx.data.user.applyResourceOperation(Pe,this.ctx.data.config.itemDefinitions);}E.SourceType===je.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(E.SourceID,new ii__default.default(E.SourceSpent).negated(),E.ServerTimeUtc),E.TargetType===je.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(E.TargetID,new ii__default.default(E.TargetCredited),E.ServerTimeUtc),this.ctx.emitter.emit("currency:cryptoConverted",E);}return U}};var hi=class{constructor(e){this.ctx=e;}ctx;async upgradeLevel(e,t,i){let r=e.trim();if(!r)return n("client","ItemInstanceID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),ItemInstanceID:r,SelectedOptionID:i,RelatedEntityID:`upgrade_item_${r}_${P()}`};t&&t.length>0&&(s.FodderInstanceIDs=[...t]);let a=await this.ctx.api.item.upgradeLevel(s);return a.ok&&(await this.ctx.userService.getUserInventory(),this.ctx.emitter.emit("item:levelUpgraded",a.data)),a}async upgradeLevelsBatch(e){if(!e||e.length===0)return n("client","upgrades is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Upgrades:e},i=await this.ctx.api.item.upgradeLevelsBatch(t);return i.ok&&(await this.ctx.userService.getUserInventory(),this.ctx.emitter.emit("item:levelsUpgradedBatch",i.data)),i}};var Lc="Store",mi=class{constructor(e){this.ctx=e;}ctx;async purchase(e,t=1,i){if(!e)return n("client","OfferID is required.");if(t<1)return n("client","Count must be at least 1.");let r=this.ctx.auth.context;if(!r)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),OfferID:e,Count:t,SelectedOptionID:i?.selectedOptionID,Payment:i?.payment,RelatedEntityID:`store_buy_${e}_${r.userID}_${P()}`},a=await this.ctx.api.store.purchase(s);if(a.ok){let p=a.data;this.ctx.data.user.patchStorePurchase(e,t,p.ServerTimeUtc),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("store:offerPurchased",p);}return a}async purchaseBatch(e){if(!e||e.length===0)return n("client","purchases is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Purchases:e},i=await this.ctx.api.store.purchaseBatch(t);if(i.ok){let r=false;for(let s of i.data)!s.Success||!s.Data||!s.Data.OfferID||(this.ctx.data.user.patchStorePurchase(s.Data.OfferID,s.Data.Count,s.Data.ServerTimeUtc),!r&&s.Data.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("store:offersPurchasedBatch",i.data);}return i}async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.store.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Lc,t.data),this.ctx.emitter.emit("store:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.store.getUserState(e);return t.ok&&(this.ctx.data.user.applyStore(t.data),this.ctx.emitter.emit("store:userStateLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var fi=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let e={...this.ctx.buildAuthedBaseRequest()};return this.ctx.api.purchase.getDefinitions(e)}async getUserState(){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let e={...this.ctx.buildAuthedBaseRequest()};return this.ctx.api.purchase.getUserState(e)}async validatePurchase(e,t,i){if(!t)return n("client","Receipt is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),Store:e,Receipt:t,Signature:i?.signature,ProductID:i?.productID},s=await this.ctx.api.purchase.validatePurchase(r);return s.ok&&s.data.Granted&&this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),s}async validatePurchasesBatch(e){if(!e||e.length===0)return n("client","receipts is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Receipts:e};return this.ctx.api.purchase.validatePurchasesBatch(t)}};var gi=class{constructor(e){this.ctx=e;}ctx;get platform(){return this.ctx.clientPlatform}availableOptions(e){return e?Object.entries(e).filter(([,t])=>t!=null).map(([t,i])=>({...i,OptionID:i.OptionID||t})).filter(t=>this.isAvailable(t)).sort((t,i)=>(t.OptionID??"").localeCompare(i.OptionID??"")):[]}isAvailable(e){if(!e)return false;let t=e.AllowedPlatforms;return !t||t.length===0?true:t.includes(this.platform)}requirementOf(e){let t=this.storeProductOf(e.Cost);return t?{option:e,kind:"store",productID:t}:{option:e,kind:"resources",shortfall:this.cryptoShortfallOf(e.Cost)??void 0}}storeProductOf(e){let t=e?.Standard?.Entries;if(!t)return null;for(let i of t)if(i?.Type===Wt.Purchase&&i.ProductID)return i.ProductID;return null}cryptoShortfallOf(e){let t=e?.Standard?.Entries;if(!t)return null;for(let i of t){if(i?.Type!==Wt.CryptoCurrency||!i.CurrencyID)continue;let r=Number(i.Amount??0);if(!(r>0))continue;let s=this.cryptoBalance(i.CurrencyID);return s>=r?null:{currencyID:i.CurrencyID,required:r,available:s,missing:r-s}}return null}cryptoBalance(e){let i=this.ctx.data.user.state?.InventoryV2?.CryptoCurrencies?.[e];return Number(i?.Amount??0)}};var qc="Lootbox",Ri=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.lootbox.getDefinitions(e);if(t.ok){let i=t.data.LootboxDefinitions;i&&(this.ctx.data.config.patchSection(qc,i),this.ctx.emitter.emit("lootbox:definitionsLoaded",i));}return t}async open(e,t,i,r){if(!e)return n("client","LootboxID is required.");if(t<1)return n("client","Count must be at least 1.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),LootboxID:e,Count:t,SelectedOptionID:i,Payment:r,RelatedEntityID:`lootbox_${e}_${i??"default"}_${P()}`},a=await this.ctx.api.lootbox.open(s);if(a.ok){let p=a.data;p.TriggeredPity&&p.TriggeredPity.length>0&&this.ctx.data.user.applyLootboxPityTriggers(e,p.TriggeredPity,t),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.data.user.applyInventoryDelta(p.Inventory),this.ctx.emitter.emit("lootbox:opened",p);}return a}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ec="Reward";function ys(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var yi=class{constructor(e){this.ctx=e;}ctx;multiplier=1;multiplierEnabled=false;get milestoneRewardMultiplier(){return this.multiplier}get milestoneRewardMultiplierEnabled(){return this.multiplierEnabled}async getRewardDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.reward.getRewardDefinitions(e);if(t.ok){let i=t.data.RewardDefinitions;i&&(this.ctx.data.config.patchSection(Ec,i),this.ctx.emitter.emit("reward:definitionsLoaded",i));}return t}async getUserRewardsState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.reward.getUserRewardsState(e);return t.ok&&t.data.Rewards&&(this.ctx.data.user.applyReward(t.data.Rewards),this.ctx.emitter.emit("reward:userStateLoaded",t.data.Rewards)),t}async getMilestoneRewardMultiplier(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.reward.getMilestoneRewardMultiplier(e);if(t.ok){let i=t.data;this.multiplierEnabled=i.Enabled,this.multiplier=i.Enabled?i.Multiplier??1:1,this.ctx.emitter.emit("reward:milestoneMultiplierLoaded",i);}return t}async claimDailyReward(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CalendarID:e,RelatedEntityID:`dailyreward_${t.userID}_${e??"default"}_${P()}`},r=await this.ctx.api.reward.claimDailyReward(i);if(r.ok){let s=r.data;this.ctx.data.user.patchDailyCalendarState(s.CalendarID,s.DailyState),this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:dailyClaimed",s);}return r}async collectIdleAccrual(e){if(!ys(e))return n("client",'AccrualID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),AccrualID:e,RelatedEntityID:`idle_collect_${e}_${P()}`},i=await this.ctx.api.reward.collectIdleAccrual(t);if(i.ok){let r=i.data;this.ctx.data.user.patchIdleAccrualState(r.AccrualID,r.IdleState),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:idleCollected",r);}return i}async claimComebackReward(e){if(!ys(e))return n("client",'ComebackID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),ComebackID:e,RelatedEntityID:`comeback_claim_${e}_${P()}`},i=await this.ctx.api.reward.claimComebackReward(t);if(i.ok){let r=i.data;this.ctx.data.user.patchComebackState(r.ComebackID,r.ComebackState),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:comebackClaimed",r);}return i}async claimReward(e){if(!ys(e))return n("client",'ClaimID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),ClaimID:e,RelatedEntityID:`reward_claim_${e}_${P()}`},i=await this.ctx.api.reward.claimReward(t);if(i.ok){let r=i.data;this.ctx.data.user.patchClaimRewardState(r.ClaimID,r.ClaimState),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:claimed",r);}return i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Gc="Tutorial",Ci=class{constructor(e){this.ctx=e;}ctx;async getTutorialDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.tutorial.getTutorialDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Gc,t.data),this.ctx.emitter.emit("tutorial:definitionsLoaded",t.data)),t}async getUserTutorialState(e=true){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.AutoStart=e;let i=await this.ctx.api.tutorial.getUserTutorialState(t);if(i.ok){let r=i.data.State??{};this.ctx.data.user.applyTutorial(r),this.ctx.emitter.emit("tutorial:userStateLoaded",i.data);}return i}async startFlow(e){return this.flowCall(e,t=>this.ctx.api.tutorial.startFlow(t),{event:"tutorial:flowStarted"})}async reportStepShown(e,t){return this.stepCall(e,t,i=>this.ctx.api.tutorial.reportStepShown(i))}async completeStep(e,t){return this.stepCall(e,t,i=>this.ctx.api.tutorial.completeStep(i),{relatedEntityID:`tutorial_step_${e}_${t}_${P()}`})}async completeStepsBatch(e,t){let i=e?.trim();if(!i)return n("client","FlowID is required.");if(!t||t.length===0)return n("client","stepIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),FlowID:i,StepIDs:t,RelatedEntityID:`tutorial_batch_${i}_${P()}`},s=await this.ctx.api.tutorial.completeStepsBatch(r);return s.ok&&(await this.refreshAfterMutation(),this.ctx.emitter.emit("tutorial:stepsCompletedBatch",s.data)),s}async skipStep(e,t){return this.stepCall(e,t,i=>this.ctx.api.tutorial.skipStep(i))}async skipFlow(e){return this.flowCall(e,t=>this.ctx.api.tutorial.skipFlow(t),{event:"tutorial:flowSkipped"})}async claimFlowReward(e){let t=e?.trim();if(!t)return n("client","FlowID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),FlowID:t,RelatedEntityID:`tutorial_claim_${t}_${P()}`},r=await this.ctx.api.tutorial.claimFlowReward(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Granted,this.ctx.data.config.itemDefinitions),await this.refreshAfterMutation(),this.ctx.emitter.emit("tutorial:rewardClaimed",r.data)),r}async resetFlow(e){return this.flowCall(e,t=>this.ctx.api.tutorial.resetFlow(t),{event:"tutorial:flowReset"})}async flowCall(e,t,i){let r=e?.trim();if(!r)return n("client","FlowID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),FlowID:r},a=await t(s);return a.ok&&(this.applyFlowView(a.data),this.ctx.emitter.emit(i.event,a.data)),a}async stepCall(e,t,i,r){let s=e?.trim(),a=t?.trim();if(!s)return n("client","FlowID is required.");if(!a)return n("client","StepID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let p={...this.ctx.buildAuthedBaseRequest(),FlowID:s,StepID:a};r?.relatedEntityID&&(p.RelatedEntityID=r.relatedEntityID);let D=await i(p);return D.ok&&(this.applyFlowView(D.data),this.ctx.emitter.emit("tutorial:stepChanged",D.data)),D}applyFlowView(e){e?.Flow&&this.ctx.data.user.patchTutorialFlow(e.Flow);}async refreshAfterMutation(){await this.getUserTutorialState(false).catch(()=>{});}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Si=Object.freeze({}),xi=class{constructor(e){this.ctx=e;}ctx;table={...Si};fallbackTable=null;currentLocale=null;currentFallbackLocale=null;pluralRules=null;get cache(){return this.tableCache??=new It(this.ctx.settings.configStorage,this.ctx.settings.titleID)}tableCache;get locale(){return this.currentLocale}get fallbackLocale(){return this.currentFallbackLocale}get locales(){let e=this.ctx.data.config.titlePublicConfiguration?.Localization??null;return e?.Locales?Object.entries(e.Locales).filter(([,t])=>t?.IsEnabled!==false).map(([t,i])=>({Locale:i?.Locale??t,DisplayName:i?.DisplayName??null,Order:i?.Order??0})).sort((t,i)=>(t.Order??0)-(i.Order??0)):[]}has(e){return this.lookup(e)!==void 0}t(e,t){if(!e)return "";let i=this.resolveKey(e,t),r=this.lookup(i)??this.lookup(e);return r===void 0?this.onMissing(e):t?Nc(r,t):r}applyState(e,t){if(!e){this.reset();return}let i=e.Locale??null;this.table=t.table??{...Si},this.fallbackTable=t.fallbackTable,this.currentFallbackLocale=e.Fallback?.Locale??null,this.setLocaleInternal(i),this.ctx.emitter.emit("localization:changed",{locale:i,fallbackLocale:this.currentFallbackLocale,entryCount:Object.keys(this.table).length});}async setLocale(e){if(!this.baseRequest())return n("unauthorized","Not logged in.");let i=await this.loadTableFromApi(e);if(!i.ok)return i;let{locale:r,table:s,fallbackLocale:a}=i.data,p=null;if(a){let D=await this.loadTableFromApi(a);D.ok&&(p=D.data.table);}return this.table=s,this.fallbackTable=p,this.currentFallbackLocale=a,this.setLocaleInternal(r),this.ctx.emitter.emit("localization:changed",{locale:r,fallbackLocale:a,entryCount:Object.keys(s).length}),{ok:true,data:r}}async getManifest(){let e=this.baseRequest();return e?(e.Locale=this.currentLocale??this.ctx.settings.locale,this.ctx.api.localization.getLocalizationManifest(e)):n("unauthorized","Not logged in.")}reset(){this.table={...Si},this.fallbackTable=null,this.currentFallbackLocale=null,this.setLocaleInternal(null);}setLocaleInternal(e){this.currentLocale=e,this.pluralRules=null;}baseRequest(){let e=this.ctx.auth.context;return e?{UserID:e.userID,ClientSessionTicket:e.clientSessionTicket,BuildKey:this.ctx.settings.buildKey,RelatedEntityID:P()}:null}async loadTableFromApi(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Locale=e;let i=await this.cache.read(io(e));i&&(t.KnownVersion=i.v);let r=await this.ctx.api.localization.getLocalizationTable(t);if(!r.ok)return r;let s=r.data,a=s.Locale??io(e),p=s.Version??0;if(s.NotModified){let U=i??await this.cache.read(a);return {ok:true,data:{locale:a,table:U?.t??{...Si},fallbackLocale:s.FallbackLocale??null}}}let D=s.Entries??{};return p>0&&await this.cache.write(a,p,D),{ok:true,data:{locale:a,table:D,fallbackLocale:s.FallbackLocale??null}}}lookup(e){let t=this.table[e];return t!==void 0?t:this.fallbackTable?.[e]}resolveKey(e,t){let i=t?.count;if(typeof i!="number")return e;let r=this.pluralCategory(i),s=`${e}.${r}`;if(this.lookup(s)!==void 0)return s;let a=`${e}.other`;return this.lookup(a)!==void 0?a:e}pluralCategory(e){try{return this.pluralRules??=new Intl.PluralRules(this.currentLocale??void 0),this.pluralRules.select(e)}catch{return "other"}}onMissing(e){let t=this.ctx.data.config.titlePublicConfiguration?.Localization?.MissingKeyMode??"ReturnKey";return t==="ReturnEmpty"?"":t==="ReturnMarkedKey"?`\u27E6${e}\u27E7`:e}};function Nc(o,e){return o.replace(/\{(\w+)\}/g,(t,i)=>{let r=e[i];return r===void 0?t:String(r)})}function io(o){return o.trim().replace(/_/g,"-").toLowerCase()}var jc="Quest",Di=class{constructor(e){this.ctx=e;}ctx;async getQuestDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.quest.getQuestDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(jc,t.data),this.ctx.emitter.emit("quest:definitionsLoaded",t.data)),t}async getUserQuestState(e=true){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.AutoRefreshCycles=e;let i=await this.ctx.api.quest.getUserQuestState(t);if(i.ok){let r=i.data.State??{};this.ctx.data.user.applyQuest(r),this.ctx.data.user.patchQuestPointsTracks(i.data.PointsTracks),this.ctx.emitter.emit("quest:userStateLoaded",r);}return i}async refreshQuestCycles(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.quest.refreshQuestCycles(e);return t.ok&&this.ctx.emitter.emit("quest:cyclesRefreshed",void 0),t}async claimQuestReward(e,t){let i=e.trim();if(!i)return n("client","QuestID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r=t&&t.trim().length>0?t.trim():void 0,s={...this.ctx.buildAuthedBaseRequest(),QuestID:i,CycleID:r,RelatedEntityID:`quest_claim_${r??""}_${i}_${P()}`},a=await this.ctx.api.quest.claimQuestReward(s);if(a.ok){let p=a.data;this.ctx.data.user.patchQuestStatus(p.QuestID,p.CycleID,"Claimed"),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:rewardClaimed",p);}return a}async claimQuestRewardsBatch(e){if(!e||e.length===0)return n("client","quests is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Quests:e},i=await this.ctx.api.quest.claimQuestRewardsBatch(t);if(i.ok){let r=false;for(let s of i.data)!s.Success||!s.Data||(this.ctx.data.user.patchQuestStatus(s.Data.QuestID,s.Data.CycleID,"Claimed"),!r&&s.Data.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("quest:rewardsClaimedBatch",i.data);}return i}async claimMilestoneReward(e,t){let i=e.trim(),r=t.trim();if(!i||!r)return n("client","CycleID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CycleID:i,MilestoneID:r,RelatedEntityID:`milestone_claim_${i}_${r}_${P()}`},a=await this.ctx.api.quest.claimMilestoneReward(s);if(a.ok){let p=a.data;this.ctx.data.user.patchMilestoneClaimed(p.CycleID,p.MilestoneID),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:milestoneClaimed",p);}return a}async claimMilestoneRewardsBatch(e){if(!e||e.length===0)return n("client","milestones is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Milestones:e},i=await this.ctx.api.quest.claimMilestoneRewardsBatch(t);if(i.ok){let r=false;for(let s of i.data)!s.Success||!s.Data||(this.ctx.data.user.patchMilestoneClaimed(s.Data.CycleID,s.Data.MilestoneID),!r&&s.Data.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("quest:milestonesClaimedBatch",i.data);}return i}async claimGroupCompletionReward(e,t){let i=e.trim(),r=t.trim();if(!i||!r)return n("client","CycleID and GroupCompletionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CycleID:i,GroupCompletionID:r,RelatedEntityID:`group_completion_${i}_${r}_${P()}`},a=await this.ctx.api.quest.claimGroupCompletionReward(s);if(a.ok){let p=a.data;this.ctx.data.user.patchGroupCompletionClaimed(p.CycleID,p.GroupCompletionID),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:groupCompletionClaimed",p);}return a}async addQuestProgress(e,t){let i=e.trim();if(!i)return n("client","MetricID is required.");if(t<0)return n("client","ProgressValue must be >= 0.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),MetricID:i,ProgressValue:t},s=await this.ctx.api.quest.addQuestProgress(r);return s.ok&&(this.ctx.data.user.patchQuestProgressUpdates(s.data.Updates),this.ctx.emitter.emit("quest:progressAdded",s.data)),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Fc="TimedEvent",bi=class{constructor(e){this.ctx=e;}ctx;async getActiveEvents(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedEvent.getActiveEvents(e);return t.ok&&(this.ctx.data.user.applyActiveEvents(t.data),this.ctx.emitter.emit("timedEvent:activeEventsLoaded",t.data)),t}async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedEvent.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Fc,t.data),this.ctx.emitter.emit("timedEvent:definitionsLoaded",t.data)),t}async getUserLteState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedEvent.getUserLteState(e);return t.ok&&(this.ctx.data.user.applyUserLteState(t.data),this.ctx.emitter.emit("timedEvent:userStateLoaded",t.data)),t}async grantTokens(e,t,i,r,s,a,p=1){if(!t)return n("client","LteID is required.");if(!i)return n("client","SourceType is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let D={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,SourceType:i,Outcome:r,AmountOverride:s,SourceParams:a,RollMultiplier:p},U=await this.ctx.api.timedEvent.grantTokens(D);return U.ok&&(this.ctx.data.user.applyResourceOperation(U.data,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensGranted",U.data)),U}async spendTokens(e,t,i){if(!t)return n("client","LteID is required.");if(i<=0)return n("client","SpendAmount must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,SpendAmount:i},s=await this.ctx.api.timedEvent.spendTokens(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensSpent",s.data)),s}async claimMilestone(e,t,i){if(!t||!i)return n("client","LteID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,MilestoneID:i},s=await this.ctx.api.timedEvent.claimMilestone(r);if(s.ok){let a=s.data;this.ctx.data.user.applyResourceOperation(a.Rewards,this.ctx.data.config.itemDefinitions),this.ctx.data.user.patchTimedEventMilestoneClaimed(e,t,i),this.ctx.emitter.emit("timedEvent:milestoneClaimed",a);}return s}async claimMilestonesBatch(e){if(!e||e.length===0)return n("client","milestones is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Milestones:e},i=await this.ctx.api.timedEvent.claimMilestonesBatch(t);return i.ok&&(this.applyMilestoneClaimBatch(i.data),this.ctx.emitter.emit("timedEvent:milestonesClaimedBatch",i.data)),i}async claimAllMilestones(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&e.length>0&&(t.Events=e);let i=await this.ctx.api.timedEvent.claimAllMilestones(t);return i.ok&&(this.applyMilestoneClaimBatch(i.data),this.ctx.emitter.emit("timedEvent:allMilestonesClaimed",i.data)),i}async spendTokensBatch(e){if(!e||e.length===0)return n("client","spends is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Spends:e},i=await this.ctx.api.timedEvent.spendTokensBatch(t);if(i.ok){let r=false;for(let s of i.data)!r&&s.Success&&s.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("timedEvent:tokensSpentBatch",i.data);}return i}async grantTokensBatch(e){if(!e||e.length===0)return n("client","grants is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Grants:e},i=await this.ctx.api.timedEvent.grantTokensBatch(t);if(i.ok){let r=false;for(let s of i.data)!r&&s.Success&&s.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("timedEvent:tokensGrantedBatch",i.data);}return i}applyMilestoneClaimBatch(e){let t=false;for(let i of e){if(!i.Success||!i.Data)continue;let r=i.Data;r.Type&&r.LteID&&r.MilestoneID&&this.ctx.data.user.patchTimedEventMilestoneClaimed(r.Type,r.LteID,r.MilestoneID),!t&&r.Rewards&&(this.ctx.data.user.applyResourceOperation(r.Rewards,this.ctx.data.config.itemDefinitions),t=true);}}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Vc="Leaderboard",zi=class{constructor(e){this.ctx=e;}ctx;cycleDocID(e){return `${this.ctx.settings.titleID}_${e}`}async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.leaderboard.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Vc,t.data),this.ctx.emitter.emit("leaderboard:definitionsLoaded",t.data)),t}async getLeaderboard(e){if(!e)return n("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardID=e;let i=await this.ctx.api.leaderboard.getLeaderboard(t);return i.ok&&this.ctx.emitter.emit("leaderboard:loaded",i.data),i}async getMyProgress(e){if(!e)return n("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardID=e;let i=await this.ctx.api.leaderboard.getMyProgress(t);return i.ok&&(this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(e),i.data),this.ctx.emitter.emit("leaderboard:myProgressLoaded",i.data)),i}async submitScore(e,t){if(!e)return n("client","LeaderboardID is required.");if(t<=0)return n("client","Score must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,Score:t},r=await this.ctx.api.leaderboard.submitScore(i);if(r.ok){let s=r.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),s.NewScore,t,s.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",s);}return r}async submitScoreFromSource(e,t,i,r,s=1){if(!e)return n("client","LeaderboardID is required.");if(!t)return n("client","SourceType is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,SourceType:t,Outcome:i,Params:r,RollMultiplier:s},p=await this.ctx.api.leaderboard.submitScoreFromSource(a);if(p.ok){let D=p.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),D.NewScore,D.NewScore,D.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",D);}return p}async claimCycleReward(e){if(!e)return n("client","LeaderboardID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e},i=await this.ctx.api.leaderboard.claimCycleReward(t);if(i.ok){let r=i.data;this.ctx.data.user.patchLeaderboardCycleRewardClaimed(this.cycleDocID(e)),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("leaderboard:cycleRewardClaimed",r);}return i}async claimMilestone(e,t){if(!e||!t)return n("client","LeaderboardID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,MilestoneID:t},r=await this.ctx.api.leaderboard.claimMilestone(i);if(r.ok){let s=r.data;this.ctx.data.user.patchLeaderboardMilestoneClaimed(this.cycleDocID(e),t),this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("leaderboard:milestoneClaimed",s);}return r}async getFriendsLeaderboard(e){if(!e)return n("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardID=e;let i=await this.ctx.api.leaderboard.getFriendsLeaderboard(t);return i.ok&&this.ctx.emitter.emit("leaderboard:friendsLoaded",i.data),i}async getLeaderboardsBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardIDs=e;let i=await this.ctx.api.leaderboard.getLeaderboardsBatch(t);return i.ok&&this.ctx.emitter.emit("leaderboard:loadedBatch",i.data),i}async getProgressBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardIDs=e;let i=await this.ctx.api.leaderboard.getProgressBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(r.Data.LeaderboardID),r.Data);this.ctx.emitter.emit("leaderboard:myProgressLoadedBatch",i.data);}return i}async claimCycleRewardsBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardIDs:e},i=await this.ctx.api.leaderboard.claimCycleRewardsBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||(this.ctx.data.user.patchLeaderboardCycleRewardClaimed(this.cycleDocID(r.Data.LeaderboardID)),r.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.Data.Resources,this.ctx.data.config.itemDefinitions));this.ctx.emitter.emit("leaderboard:cycleRewardsClaimedBatch",i.data);}return i}async claimMilestonesBatch(e){if(!e||e.length===0)return n("client","milestones is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Milestones:e},i=await this.ctx.api.leaderboard.claimMilestonesBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||(this.ctx.data.user.patchLeaderboardMilestoneClaimed(this.cycleDocID(r.Data.LeaderboardID),r.Data.MilestoneID),r.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.Data.Resources,this.ctx.data.config.itemDefinitions));this.ctx.emitter.emit("leaderboard:milestonesClaimedBatch",i.data);}return i}async submitScoresBatch(e){if(!e||e.length===0)return n("client","scores is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Scores:e},i=await this.ctx.api.leaderboard.submitScoresBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(r.Data.LeaderboardID),r.Data.NewScore,r.Data.NewScore,r.Data.CycleVersion);this.ctx.emitter.emit("leaderboard:scoresSubmittedBatch",i.data);}return i}async claimAllRewardsBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardIDs:e},i=await this.ctx.api.leaderboard.claimAllRewardsBatch(t);if(i.ok){for(let r of i.data){let s=this.cycleDocID(r.LeaderboardID);r.CycleReward?.Success&&r.CycleReward.Data&&(this.ctx.data.user.patchLeaderboardCycleRewardClaimed(s),r.CycleReward.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.CycleReward.Data.Resources,this.ctx.data.config.itemDefinitions));for(let a of r.Milestones??[])!a.Success||!a.Data||(this.ctx.data.user.patchLeaderboardMilestoneClaimed(s,a.Data.MilestoneID),a.Data.Resources&&this.ctx.data.user.applyResourceOperation(a.Data.Resources,this.ctx.data.config.itemDefinitions));}this.ctx.emitter.emit("leaderboard:allRewardsClaimedBatch",i.data);}return i}async getOverviewBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardIDs=e;let i=await this.ctx.api.leaderboard.getOverviewBatch(t);if(i.ok){for(let r of i.data)r.Progress?.Success&&r.Progress.Data&&this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(r.LeaderboardID),r.Progress.Data);this.ctx.emitter.emit("leaderboard:overviewLoadedBatch",i.data);}return i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var _c="Season",Ti=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.season.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(_c,t.data),this.ctx.emitter.emit("season:definitionsLoaded",t.data)),t}async getActiveSeason(e){if(!e)return n("client","SeasonChainID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.SeasonChainID=e;let i=await this.ctx.api.season.getActiveSeason(t);return i.ok&&(i.data.UserState&&this.ctx.data.user.patchSeasonState(e,i.data.UserState),this.ctx.emitter.emit("season:activeLoaded",i.data)),i}async getUserState(e){if(!e)return n("client","SeasonChainID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.SeasonChainID=e;let i=await this.ctx.api.season.getUserState(t);return i.ok&&(this.ctx.data.user.patchSeasonState(e,i.data),this.ctx.emitter.emit("season:userStateLoaded",i.data)),i}async grantStatusTokens(e,t){if(!e)return n("client","SeasonChainID is required.");if(t<=0)return n("client","Amount must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,Amount:t,RelatedEntityID:`season_grant_${e}_${P()}`},r=await this.ctx.api.season.grantStatusTokens(i);return r.ok&&(this.ctx.data.user.patchSeasonCurrentTier(e,r.data.NewTier),this.ctx.emitter.emit("season:statusTokensGranted",r.data)),r}async claimTierReward(e,t){if(!e)return n("client","SeasonChainID is required.");if(t<=0)return n("client","TierNumber must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,TierNumber:t,RelatedEntityID:`season_tier_${e}_t${t}_${P()}`},r=await this.ctx.api.season.claimTierReward(i);if(r.ok){let s=r.data;this.ctx.data.user.patchSeasonClaimedTier(e,t),this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("season:tierRewardClaimed",s);}return r}async claimTierRewardsBatch(e,t){if(!e)return n("client","SeasonChainID is required.");let i=(t??[]).filter(a=>a>0);if(i.length===0)return n("client","TierNumbers is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,TierNumbers:i,RelatedEntityID:`season_tier_batch_${e}_${P()}`},s=await this.ctx.api.season.claimTierRewardsBatch(r);if(s.ok){let a=s.data;for(let p of a.Items??[]){let D=p.Data?.TierNumber;p.Success&&typeof D=="number"&&this.ctx.data.user.patchSeasonClaimedTier(e,D);}this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("season:tierRewardsBatchClaimed",a);}return s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Wc="Premium",vi=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.premium.getDefinitions(e);return t.ok&&t.data.Premium&&(this.ctx.data.config.patchSection(Wc,t.data.Premium),this.ctx.emitter.emit("premium:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.premium.getUserState(e);return t.ok&&t.data.Premium&&(this.ctx.data.user.applyPremium(t.data.Premium),this.ctx.emitter.emit("premium:stateLoaded",t.data)),t}async activateTrial(e,t){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,RelatedEntityID:`premium_trial_${e}_${t}`},r=await this.ctx.api.premium.activateTrial(i);return r.ok&&(r.data.Premium&&this.ctx.data.user.applyPremium(r.data.Premium),this.ctx.emitter.emit("premium:trialActivated",r.data)),r}async purchaseItemOrCurrency(e,t,i="Default",r=1){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,SelectedOptionID:i,Count:r,RelatedEntityID:`premium_purchase_${e}_${t}`},a=await this.ctx.api.premium.purchaseItemOrCurrency(s);if(a.ok){let p=a.data;p.Premium&&this.ctx.data.user.applyPremium(p.Premium),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:purchaseCompleted",p);}return a}async purchaseRealMoney(e,t,i,r,s,a,p,D){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!r||!s)return n("client","ProductID and ReceiptData are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let U={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,Store:i,ProductID:r,ReceiptData:s,PurchaseToken:a,PackageName:p,AppStoreEnvironment:D,RelatedEntityID:`premium_iap_${e}_${t}`},E=await this.ctx.api.premium.purchaseRealMoney(U);if(E.ok){let de=E.data;de.Premium&&this.ctx.data.user.applyPremium(de.Premium),this.ctx.data.user.applyResourceOperation(de.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:realMoneyPurchaseCompleted",de);}return E}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Qc="Character",Pi=class{constructor(e){this.ctx=e;}ctx;async getCharacterDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.character.getCharacterDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Qc,t.data),this.ctx.emitter.emit("character:definitionsLoaded",t.data)),t}async getUserCharacters(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.character.getUserCharacters(e);if(t.ok){let i=t.data.Characters??{};this.ctx.data.user.applyCharacter(i),this.ctx.emitter.emit("character:userCharactersLoaded",i);}return t}async unlockCharacter(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,SelectedOptionID:t?.selectedOptionID,Payment:t?.payment,RelatedEntityID:`unlock_char_${e}_${P()}`},r=await this.ctx.api.character.unlockCharacter(i);if(r.ok){let s=r.data;this.ctx.data.user.patchCharacter(s.CharacterID,a=>{a.StatLevels??={},a.Equipment??={},s.Power!=null&&(a.Power=s.Power),a.UpdatedAt=s.ServerTimeUtc;}),this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:unlocked",s);}return r}async upgradeStatLevel(e,t,i){if(!e||!t)return n("client","CharacterID and StatID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,StatID:t,RelatedEntityID:`upgrade_stat_${e}_${t}_${P()}`,...i?.levels!=null?{Levels:i.levels}:{},...i?.targetLevel!=null?{TargetLevel:i.targetLevel}:{}},s=await this.ctx.api.character.upgradeStatLevel(r);if(s.ok){let a=s.data;this.ctx.data.user.patchCharacter(a.CharacterID,p=>{p.StatLevels??={},p.StatLevels[a.StatID]=a.StatLevel,a.Power!=null&&(p.Power=a.Power),p.UpdatedAt=a.ServerTimeUtc;}),this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:statLevelUpgraded",a);}return s}async upgradeCharacterLevel(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,RelatedEntityID:`upgrade_char_${e}_${P()}`,...t?.levels!=null?{Levels:t.levels}:{},...t?.targetLevel!=null?{TargetLevel:t.targetLevel}:{}},r=await this.ctx.api.character.upgradeCharacterLevel(i);if(r.ok){let s=r.data;this.ctx.data.user.patchCharacter(s.CharacterID,a=>{a.Level=s.NewLevel,s.Power!=null&&(a.Power=s.Power),a.UpdatedAt=s.ServerTimeUtc,s.NewLevel===1&&(a.StatLevels??={},a.Equipment??={});}),this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:levelUpgraded",s);}return r}async equipItems(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,ItemsToEquip:t},r=await this.ctx.api.character.equipItems(i);return r.ok&&(this.applyEquipChangesLocally(e,r.data),this.ctx.emitter.emit("character:itemsEquipped",r.data)),r}async unequipItems(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,UnequipSlotIDs:t},r=await this.ctx.api.character.unequipItems(i);if(r.ok){let s=r.data;this.applyUnequipChangesLocally(e,s),this.ctx.emitter.emit("character:itemsUnequipped",{characterID:e,slotIDs:s.ClearedSlotIDs??[],power:s.Power??null});}return r}async unequipAllCharacters(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.character.unequipAllCharacters(e);return t.ok&&(this.applyUnequipAllLocally(t.data),this.ctx.emitter.emit("character:allUnequipped",t.data)),t}async unlockCharactersBatch(e){if(!e||e.length===0)return n("client","characterIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),UnlockCharacterIDs:e},i=await this.ctx.api.character.unlockCharactersBatch(t);return i.ok&&(this.applyBatchResults(i.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,s=>{s.StatLevels??={},s.Equipment??={},r.Power!=null&&(s.Power=r.Power),s.UpdatedAt=r.ServerTimeUtc;});}),this.ctx.emitter.emit("character:charactersUnlocked",i.data)),i}async upgradeCharacterLevelsBatch(e){if(!e||e.length===0)return n("client","upgrades is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LevelUpgrades:e},i=await this.ctx.api.character.upgradeCharacterLevelsBatch(t);return i.ok&&(this.applyBatchResults(i.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,s=>{s.Level=r.NewLevel,r.Power!=null&&(s.Power=r.Power),s.UpdatedAt=r.ServerTimeUtc,r.NewLevel===1&&(s.StatLevels??={},s.Equipment??={});});}),this.ctx.emitter.emit("character:levelsUpgraded",i.data)),i}async upgradeStatLevelsBatch(e){if(!e||e.length===0)return n("client","upgrades is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),StatUpgrades:e},i=await this.ctx.api.character.upgradeStatLevelsBatch(t);return i.ok&&(this.applyBatchResults(i.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,s=>{s.StatLevels??={},s.StatLevels[r.StatID]=r.StatLevel,r.Power!=null&&(s.Power=r.Power),s.UpdatedAt=r.ServerTimeUtc;});}),this.ctx.emitter.emit("character:statLevelsUpgraded",i.data)),i}applyBatchResults(e,t){e.Resources&&this.ctx.data.user.applyResourceOperation(e.Resources,this.ctx.data.config.itemDefinitions);for(let i of e.Items??[])!i.Success||!i.Data||t(i.Data);}applyInventoryDelta(e){this.ctx.data.user.applyInventoryDelta(e);}applyEquipChangesLocally(e,t){let i=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let[r,s]of Object.entries(t.Equipment??{}))i.patchCharacterEquipment(e,r,s);i.patchCharacter(e,r=>{t.Power!=null&&(r.Power=t.Power),r.UpdatedAt=t.ServerTimeUtc;});}applyUnequipChangesLocally(e,t){let i=t.ClearedSlotIDs??[];if(i.length===0&&t.Power==null)return;let r=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let s of i)r.patchCharacterEquipment(e,s,null);r.patchCharacter(e,s=>{t.Power!=null&&(s.Power=t.Power),s.UpdatedAt=t.ServerTimeUtc;});}applyUnequipAllLocally(e){let t=this.ctx.data.user;this.applyInventoryDelta(e.Inventory);for(let[i,r]of Object.entries(e.Characters??{})){for(let s of r.ClearedSlotIDs??[])t.patchCharacterEquipment(i,s,null);t.patchCharacter(i,s=>{r.Power!=null&&(s.Power=r.Power),s.UpdatedAt=e.ServerTimeUtc;});}}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Kc="Match",Ii=class{constructor(e){this.ctx=e;}ctx;async createMatch(e,t,i,r,s,a){let p=this.ctx.auth.context;if(!p)return n("unauthorized","Not logged in.");let D={...this.ctx.buildAuthedBaseRequest(),Entry:e,RuleID:t,CharacterID:i,BattleStrategy:r,TargetUserID:s,SelectedOptionID:a,RelatedEntityID:`pvp_create_${p.userID}_${P()}`},U=await this.ctx.api.match.createMatch(D);return U.ok&&(this.ctx.data.user.applyResourceOperation(U.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:created",U.data)),U}async updateMatch(e,t={}){if(!e)return n("client","MatchID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),MatchID:e,TargetUserID:t.targetUserID,ClearTargetUser:t.clearTargetUser,RuleID:t.ruleID,CharacterID:t.characterID,BattleStrategy:t.battleStrategy},r=await this.ctx.api.match.updateMatch(i);return r.ok&&this.ctx.emitter.emit("match:updated",r.data),r}async cancelMatch(e){if(!e)return n("client","MatchID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),MatchID:e},i=await this.ctx.api.match.cancelMatch(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:cancelled",i.data)),i}async instantBattle(e,t,i,r){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),MatchID:e,RuleID:t,CharacterID:i,BattleStrategy:r,RelatedEntityID:`pvp_battle_${e}_${P()}`},p=await this.ctx.api.match.instantBattle(a);if(p.ok){let D=p.data,U=this.ctx.data.config.itemDefinitions;if(D.Resources)this.ctx.data.user.applyResourceOperation(D.Resources,U);else if(D.ResourcesDual){let E=D.ResourcesDual;E.FromUserID===s.userID&&E.FromResult?this.ctx.data.user.applyResourceOperation(E.FromResult,U):E.ToUserID===s.userID&&E.ToResult&&this.ctx.data.user.applyResourceOperation(E.ToResult,U);}this.ctx.emitter.emit("match:instantBattleCompleted",D);}return p}async saveStrategy(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BattleStrategy:e},i=await this.ctx.api.match.saveStrategy(t);return i.ok&&(this.ctx.data.user.patchMatchStrategy(e),this.ctx.emitter.emit("match:strategySaved",e)),i}async getMyMatches(e=0,t=20,i){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.Statuses=i;let s=await this.ctx.api.match.getMyMatches(r);return s.ok&&this.ctx.emitter.emit("match:myMatchesLoaded",s.data),s}async getAvailableMatches(e=0,t=20,i=false){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.OnlyPublic=i;let s=await this.ctx.api.match.getAvailableMatches(r);return s.ok&&this.ctx.emitter.emit("match:availableMatchesLoaded",s.data),s}async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.match.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Kc,t.data),this.ctx.emitter.emit("match:definitionsLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Hc="Craft",ki=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.craft.getDefinitions(e);return t.ok&&t.data.CraftDefinitions&&(this.ctx.data.config.patchSection(Hc,t.data.CraftDefinitions),this.ctx.emitter.emit("craft:definitionsLoaded",t.data.CraftDefinitions)),t}async craft(e,t,i=1,r){if(!e)return n("client","CraftID is required.");let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),CraftID:e,InputItemIDs:t,Count:i,SelectedOptionID:r,RelatedEntityID:`craft_${e}_${s.userID}_${P()}`},p=await this.ctx.api.craft.craft(a);return p.ok&&(this.ctx.data.user.applyResourceOperation(p.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("craft:completed",p.data)),p}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var $c="Collection",Mi=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.collection.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection($c,t.data),this.ctx.emitter.emit("collection:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.collection.getUserState(e);return t.ok&&(this.ctx.data.user.applyCollection(t.data),this.ctx.emitter.emit("collection:userStateLoaded",t.data)),t}async openPack(e,t,i=1,r){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,PackTypeID:t,Count:i,SelectedOptionID:r?.selectedOptionID,Payment:r?.payment,RelatedEntityID:`open_pack_${e}_${t}_${s.userID}_${P()}`},p=await this.ctx.api.collection.openPack(a);return p.ok&&(this.ctx.data.user.applyResourceOperation(p.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:packOpened",p.data)),p}async openCollectionChest(e,t,i=1){let r=this.ctx.auth.context;if(!r)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectionChestID:t,Count:i,RelatedEntityID:`open_chest_${e}_${t}_${r.userID}_${P()}`},a=await this.ctx.api.collection.openCollectionChest(s);return a.ok&&(this.ctx.data.user.applyResourceOperation(a.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:chestOpened",a.data)),a}async useCollectibleJoker(e,t){let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:false,RelatedEntityID:`use_joker_${e}_${t}_${i.userID}_${P()}`},s=await this.ctx.api.collection.useCollectibleJoker(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:jokerUsed",s.data)),s}async claimSetReward(e,t){let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,SetID:t,RelatedEntityID:`claim_set_${e}_${t}_${i.userID}_${P()}`},s=await this.ctx.api.collection.claimSetReward(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:setRewardClaimed",s.data)),s}async claimSetRewardsBatch(e){if(!e||e.length===0)return n("client","sets is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Sets:e},i=await this.ctx.api.collection.claimSetRewardsBatch(t);if(i.ok){let r=false;for(let s of i.data)!r&&s.Success&&s.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("collection:setRewardsClaimedBatch",i.data);}return i}async claimGrandPrize(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,RelatedEntityID:`grand_prize_${e}_${t.userID}_${P()}`},r=await this.ctx.api.collection.claimGrandPrize(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:grandPrizeClaimed",r.data)),r}async sendTradeOffer(e,t,i,r,s,a=false){let p=this.ctx.auth.context;if(!p)return n("unauthorized","Not logged in.");let D={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:i,ReceiverUserID:r,RequestedCollectibleID:s,RequestedCollectibleIsSpecial:a,RelatedEntityID:`trade_send_${p.userID}_${r}_${P()}`},U=await this.ctx.api.collection.sendTradeOffer(D);return U.ok&&this.ctx.emitter.emit("collection:tradeOfferSent",U.data),U}async cancelTradeOffer(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),OfferID:e,RelatedEntityID:`trade_cancel_${e}_${P()}`},i=await this.ctx.api.collection.cancelTradeOffer(t);return i.ok&&this.ctx.emitter.emit("collection:tradeOfferCancelled",i.data),i}async acceptTradeOffer(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),OfferID:e,RelatedEntityID:`trade_accept_${e}_${P()}`},i=await this.ctx.api.collection.acceptTradeOffer(t);return i.ok&&this.ctx.emitter.emit("collection:tradeOfferAccepted",i.data),i}async declineTradeOffer(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),OfferID:e,RelatedEntityID:`trade_decline_${e}_${P()}`},i=await this.ctx.api.collection.declineTradeOffer(t);return i.ok&&this.ctx.emitter.emit("collection:tradeOfferDeclined",i.data),i}async getMyTradeOffers(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CollectionID=e;let i=await this.ctx.api.collection.getMyTradeOffers(t);return i.ok&&this.ctx.emitter.emit("collection:myTradeOffersLoaded",i.data),i}async getIncomingTradeOffers(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CollectionID=e;let i=await this.ctx.api.collection.getIncomingTradeOffers(t);return i.ok&&this.ctx.emitter.emit("collection:incomingTradeOffersLoaded",i.data),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Zc="CoopEvent",wi=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.coopEvent.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Zc,t.data),this.ctx.emitter.emit("coopEvent:definitionsLoaded",t.data)),t}async getActiveEvent(e){if(!e)return n("client","CoopChainID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CoopChainID=e;let i=await this.ctx.api.coopEvent.getActiveEvent(t);return i.ok&&this.ctx.emitter.emit("coopEvent:activeEventLoaded",i.data),i}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.coopEvent.getUserState(e);return t.ok&&(this.ctx.data.user.applyCoopEvent(t.data.UserState??null),this.ctx.emitter.emit("coopEvent:userStateLoaded",t.data)),t}async getGroupState(e){if(!e)return n("client","GroupID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.GroupID=e;let i=await this.ctx.api.coopEvent.getGroupState(t);return i.ok&&this.ctx.emitter.emit("coopEvent:groupStateLoaded",i.data),i}async joinOrCreateGroup(e){if(!e)return n("client","CoopChainID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),CoopChainID:e},i=await this.ctx.api.coopEvent.joinOrCreateGroup(t);if(i.ok){let r=i.data.Group;r&&this.ctx.data.user.patchCoopEventActiveGroup(r.GroupID??null,r.CoopEventID??null,-1),this.ctx.emitter.emit("coopEvent:groupJoined",i.data);}return i}async spin(e,t,i=1,r){if(!e||!t)return n("client","CoopChainID and GroupID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CoopChainID:e,GroupID:t,Count:i,SelectedOptionID:r,RelatedEntityID:P()},a=await this.ctx.api.coopEvent.spin(s);return a.ok&&(this.ctx.data.user.applyResourceOperation(a.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("coopEvent:spinCompleted",a.data)),a}async claimObjectReward(e){if(!e)return n("client","GroupID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.coopEvent.claimObjectReward(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("coopEvent:objectRewardClaimed",i.data)),i}async claimGrandPrize(e){if(!e)return n("client","GroupID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.coopEvent.claimGrandPrize(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:grandPrizeClaimed",i.data)),i}async leaveGroup(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.coopEvent.leaveGroup(t);return i.ok&&(this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:groupLeft",i.data)),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Jc="DealOffer",Oi=class{constructor(e){this.ctx=e;}ctx;async getDefinition(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.dealOffer.getDefinition(e);return t.ok&&t.data.DealOfferDefinitions&&(this.ctx.data.config.patchSection(Jc,t.data.DealOfferDefinitions),this.ctx.emitter.emit("dealOffer:definitionLoaded",t.data.DealOfferDefinitions)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.dealOffer.getUserState(e);return t.ok&&t.data.DealOffers&&(this.ctx.data.user.applyDealOffer(t.data.DealOffers),this.ctx.emitter.emit("dealOffer:userStateLoaded",t.data.DealOffers)),t}async getActiveDeals(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.dealOffer.getActiveDeals(e);return t.ok&&this.ctx.emitter.emit("dealOffer:activeDealsLoaded",t.data),t}async dismissDeal(e){if(!e)return n("client","SlotID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),SlotID:e,RelatedEntityID:`deal_dismiss_${e}_${P()}`},i=await this.ctx.api.dealOffer.dismissDeal(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:dealDismissed",i.data)),i}async executeNode(e,t,i,r){if(!e||!t)return n("client","SlotID and NodeID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s=i&&i.trim().length>0?i.trim():void 0,a={...this.ctx.buildAuthedBaseRequest(),SlotID:e,NodeID:t,SelectedOptionID:r?.selectedOptionID,Payment:r?.payment,RelatedEntityID:s??`deal_exec_${e}_${t}_${P()}`},p=await this.ctx.api.dealOffer.executeNode(a);return p.ok&&(p.data.Idempotent||this.ctx.data.user.applyResourceOperation(p.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:nodeExecuted",p.data)),p}async recordShow(e){if(!e)return n("client","SlotID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),SlotID:e,RelatedEntityID:`deal_show_${e}_${P()}`},i=await this.ctx.api.dealOffer.recordShow(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:showRecorded",i.data)),i}async claimMilestone(e,t){if(!e||!t)return n("client","SlotID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneID:t,RelatedEntityID:`deal_milestone_${e}_${t}_${P()}`},r=await this.ctx.api.dealOffer.claimMilestone(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:milestoneClaimed",r.data)),r}async claimMilestonesBatch(e,t){if(!e)return n("client","SlotID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i=[...new Set(t.map(a=>a.trim()).filter(a=>a.length>0))],r={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneIDs:i,RelatedEntityID:`deal_milestone_batch_${e}_${P()}`},s=await this.ctx.api.dealOffer.claimMilestonesBatch(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:milestonesBatchClaimed",s.data)),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Yc="Referral",Ai=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.referral.getDefinitions(e);return t.ok&&t.data.ReferralDefinitions&&(this.ctx.data.config.patchSection(Yc,t.data.ReferralDefinitions),this.ctx.emitter.emit("referral:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.referral.getUserState(e);return t.ok&&t.data.Referral&&(this.ctx.data.user.applyReferral(t.data.Referral),this.ctx.emitter.emit("referral:userStateLoaded",t.data)),t}async activateReferralCode(e){let t=e.trim().toUpperCase();if(!t)return n("client","ReferralCode is required.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),ReferralCode:t,RelatedEntityID:`referral_activation_${i.userID}`},s=await this.ctx.api.referral.activateReferralCode(r);if(s.ok){let a=s.data;a.ReferralCode&&this.ctx.data.user.patchReferralSubscription(a.ReferralCode),this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:codeActivated",a);}return s}async claimInviteReward(e){let t=e.trim();if(!t)return n("client","InviteRewardID is required.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),InviteRewardID:t,RelatedEntityID:`referral_invite_${t}_${i.userID}`},s=await this.ctx.api.referral.claimInviteReward(r);if(s.ok){let a=s.data;a.RewardID&&this.ctx.data.user.patchReferralInviteRewardClaimed(a.RewardID),this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:inviteRewardClaimed",a);}return s}async claimInviteRewardsBatch(e){let t=(e??[]).map(a=>a?.trim()).filter(Boolean);if(t.length===0)return n("client","InviteRewardIDs is required.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),InviteRewardIDs:t,RelatedEntityID:`referral_invite_batch_${t.join("_")}_${i.userID}`},s=await this.ctx.api.referral.claimInviteRewardsBatch(r);if(s.ok){let a=s.data;for(let p of a.Items??[])p.Success&&p.Id&&this.ctx.data.user.patchReferralInviteRewardClaimed(p.Id);this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:inviteRewardsBatchClaimed",a);}return s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ui=class{constructor(e){this.ctx=e;}ctx;async getFriendsList(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getFriendsList(e);return t.ok&&(this.ctx.data.user.applySocialFriendsList(t.data.Friends),this.ctx.emitter.emit("social:friendsListLoaded",t.data)),t}async getIncomingRequests(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getIncomingRequests(e);return t.ok&&(this.ctx.data.user.applySocialIncomingRequests(t.data.Friends),this.ctx.emitter.emit("social:incomingRequestsLoaded",t.data)),t}async getRecommendedFriends(e=5){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Limit=e;let i=await this.ctx.api.social.getRecommendedFriends(t);return i.ok&&this.ctx.emitter.emit("social:recommendedFriendsLoaded",i.data),i}async sendFriendRequest(e){if(!e)return n("client","TargetUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.sendFriendRequest(t);return i.ok&&(this.ctx.data.user.patchSocialAddOutgoingRequest(e),this.ctx.emitter.emit("social:friendRequestSent",i.data)),i}async acceptFriendRequest(e){if(!e)return n("client","RequesterUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.acceptFriendRequest(t);return i.ok&&(this.ctx.data.user.patchSocialAcceptFriend(e),this.ctx.emitter.emit("social:friendRequestAccepted",i.data)),i}async declineFriendRequest(e){if(!e)return n("client","RequesterUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.declineFriendRequest(t);return i.ok&&(this.ctx.data.user.patchSocialRemoveIncomingRequest(e),this.ctx.emitter.emit("social:friendRequestDeclined",i.data)),i}async removeFriend(e){if(!e)return n("client","FriendUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.removeFriend(t);return i.ok&&(this.ctx.data.user.patchSocialRemoveFriend(e),this.ctx.emitter.emit("social:friendRemoved",i.data)),i}async getTimeline(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getTimeline(e);return t.ok&&(this.ctx.data.user.applySocialTimeline(t.data.Events),this.ctx.emitter.emit("social:timelineLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Xc="TimedBoost";function ep(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var Bi=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Xc,t.data),this.ctx.emitter.emit("timedBoost:definitionsLoaded",t.data)),t}async getActive(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.getActive(e);return t.ok&&(this.ctx.data.user.applyTimedBoost({Active:t.data.Active??{}}),this.ctx.emitter.emit("timedBoost:activeLoaded",t.data)),t}async getActiveWindows(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.getActiveWindows(e);return t.ok&&this.ctx.emitter.emit("timedBoost:activeWindowsLoaded",t.data),t}async activate(e,t){let i=e.trim();if(!ep(i))return n("client",'BoostID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),BoostID:i,SelectedOptionID:t?.selectedOptionID,Payment:t?.payment,RelatedEntityID:`timed_boost_activate_${i}_${P()}`},s=await this.ctx.api.timedBoost.activate(r);if(s.ok){let a=s.data;if(a.ActivatedBoost){let p=a.StackingPolicy??"Replace";this.ctx.data.user.patchActiveTimedBoost(a.ActivatedBoost,p);}this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedBoost:activated",a);}return s}async cleanupExpired(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.cleanupExpired(e);return t.ok&&(await this.getActive(),this.ctx.emitter.emit("timedBoost:expiredCleaned",void 0)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var tt={Private:"Private",Public:"Public",ReadOnly:"ReadOnly",Internal:"Internal"},tp={Client:"Client",Server:"Server",System:"System"},ip=zod.z.enum(["Client","Server","System"]),rp=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:u.nullish(),Version:zod.z.number().nullish(),LastWriter:ip.nullish(),ExpiresAt:u.nullish()}).passthrough(),Li=zod.z.record(zod.z.string(),rp),ro=zod.z.object({Version:zod.z.number().nullish(),Private:Li.nullish(),Public:Li.nullish(),ReadOnly:Li.nullish()}),Cs=zod.z.object({UserID:zod.z.string().nullish(),Version:zod.z.number().nullish(),Public:Li.nullish()}),Ss=zod.z.object({ServerTimeUtc:u.nullish(),Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:u.nullish()}),sp=zod.z.object({Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:u.nullish()}),so=zod.z.object({ServerTimeUtc:u.nullish(),Results:zod.z.array(sp).nullish()}),no=zod.z.object({ServerTimeUtc:u.nullish(),DeletedCount:zod.z.number().nullish()}),oo=zod.z.object({Results:zod.z.array(Cs).nullish(),NotFoundUserIDs:zod.z.array(zod.z.string()).nullish()}),np={String:"String",Int:"Int",Bool:"Bool",Json:"Json"},op=zod.z.enum(["String","Int","Bool","Json"]),ap=zod.z.object({KeyID:zod.z.string(),Bucket:zod.z.string().nullish(),ValueType:op.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),qi=zod.z.object({Keys:zod.z.record(zod.z.string(),ap).nullish(),DefaultMaxValueLengthBytes:zod.z.number().nullish(),DefaultTtlSeconds:zod.z.number().nullish(),MaxKeysPerBucket:zod.z.number().nullish(),MaxTotalSizeBytes:zod.z.number().nullish(),RejectUnregisteredKeys:zod.z.boolean().nullish()}).passthrough(),_e={GetUserCustomDataDefinitions:"GetUserCustomDataDefinitions",GetMyUserCustomData:"GetMyUserCustomData",GetPublicUserCustomDataOf:"GetPublicUserCustomDataOf",SetPrivateData:"SetPrivateData",SetPublicData:"SetPublicData",DeleteKey:"DeleteKey",BatchSet:"BatchSet",BatchDelete:"BatchDelete",BatchGetPublicUserCustomDataOf:"BatchGetPublicUserCustomDataOf"};var lp="UserCustomData";function ao(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var Ei=class{constructor(e){this.ctx=e;}ctx;async getUserCustomDataDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.userCustomData.getUserCustomDataDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(lp,t.data),this.ctx.emitter.emit("userCustomData:definitionsLoaded",t.data)),t}async getMyUserCustomData(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.userCustomData.getMyUserCustomData(e);return t.ok&&(this.ctx.data.user.applyUserCustomData(t.data),this.ctx.emitter.emit("userCustomData:myDataLoaded",t.data)),t}async getPublicUserCustomDataOf(e){let t=e.trim();if(!t)return n("client","TargetUserID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.TargetUserID=t;let r=await this.ctx.api.userCustomData.getPublicUserCustomDataOf(i);return r.ok&&this.ctx.emitter.emit("userCustomData:publicDataLoaded",r.data),r}async setPrivateData(e,t){return this.setData(e,t,tt.Private)}async setPublicData(e,t){return this.setData(e,t,tt.Public)}async setData(e,t,i){let r=e.trim();if(!ao(r))return n("client",'KeyID is required and must not contain "." or "$".');if(t==null)return n("client","Value is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),KeyID:r,Value:t},p=await(i===tt.Private?this.ctx.api.userCustomData.setPrivateData(s):this.ctx.api.userCustomData.setPublicData(s));if(p.ok){let D=p.data;this.ctx.data.user.patchUserCustomDataKey(i,D.KeyID,t,D.Version??0,D.ExpiresAt),this.ctx.emitter.emit(i===tt.Private?"userCustomData:privateDataSet":"userCustomData:publicDataSet",D);}return p}async deleteKey(e,t){let i=e.trim();if(!ao(i))return n("client",'KeyID is required and must not contain "." or "$".');if(t!==tt.Private&&t!==tt.Public)return n("client","Only Private or Public keys can be deleted.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),KeyID:i,Bucket:t},s=await this.ctx.api.userCustomData.deleteKey(r);return s.ok&&(this.ctx.data.user.removeUserCustomDataKey(t,i),this.ctx.emitter.emit("userCustomData:keyDeleted",void 0)),s}async batchSet(e){if(!e.length)return n("client","At least one item is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BatchSetItems:e},i=await this.ctx.api.userCustomData.batchSet(t);if(i.ok){for(let r of i.data.Results??[]){let s=r.Bucket??tt.Private,a=e.find(p=>p.Bucket===s&&p.KeyID===r.KeyID);a&&this.ctx.data.user.patchUserCustomDataKey(s,r.KeyID,a.Value,r.Version??0,r.ExpiresAt);}this.ctx.emitter.emit("userCustomData:batchSet",i.data);}return i}async batchDelete(e){if(!e.length)return n("client","At least one item is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BatchDeleteItems:e},i=await this.ctx.api.userCustomData.batchDelete(t);if(i.ok){for(let r of e)this.ctx.data.user.removeUserCustomDataKey(r.Bucket,r.KeyID.trim());this.ctx.emitter.emit("userCustomData:batchDeleted",i.data);}return i}async batchGetPublicUserCustomDataOf(e){if(!e.length)return n("client","At least one target user id is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.TargetUserIDs=e;let i=await this.ctx.api.userCustomData.batchGetPublicUserCustomDataOf(t);return i.ok&&this.ctx.emitter.emit("userCustomData:batchPublicDataLoaded",i.data),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var up="TitleCustomDataDefinitions",lo=50;function cp(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}function xs(o){if(o.ExpiresAt==null)return false;let e=Date.parse(o.ExpiresAt);return !Number.isNaN(e)&&e<=Date.now()}function pp(o){let e={};for(let[t,i]of Object.entries(o))xs(i)||(e[t]=i);return e}var Gi=class{constructor(e){this.ctx=e;}ctx;lastRuntimeVersion=null;runtimeCache={};async getTitleCustomDataDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.titleCustomData.getTitleCustomDataDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(up,t.data),this.ctx.emitter.emit("titleCustomData:definitionsLoaded",t.data)),t}async getPublicTitleData(e=true){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&this.lastRuntimeVersion!=null&&(t.KnownRuntimeVersion=this.lastRuntimeVersion);let i=await this.ctx.api.titleCustomData.getPublicTitleData(t);return i.ok&&this.absorb(i.data),i}async getPublicTitleDataKeys(e){let t=e.map(s=>s.trim()).filter(s=>s.length>0);if(!t.length)return n("client","At least one KeyID is required.");if(t.some(s=>!cp(s)))return n("client",'KeyID must not contain "." or "$".');if(t.length>lo)return n("client",`At most ${lo} keys per call \u2014 request them in chunks.`);let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.KeyIDs=t;let r=await this.ctx.api.titleCustomData.getPublicTitleDataKeys(i);return r.ok&&this.ctx.emitter.emit("titleCustomData:publicDataLoaded",r.data),r}getValue(e){let t=this.runtimeCache[e];if(t?.Value!=null&&!xs(t))return t.Value;let i=this.staticCache[e];if(i?.Value!=null&&!xs(i))return i.Value}get runtimeVersion(){return this.lastRuntimeVersion}staticCache={};absorb(e){e.Static&&(this.staticCache=e.Static),e.NotModified?(this.runtimeCache=pp(this.runtimeCache),e.Runtime=this.runtimeCache):e.Runtime&&(this.runtimeCache=e.Runtime),e.RuntimeVersion!=null&&(this.lastRuntimeVersion=e.RuntimeVersion),this.ctx.emitter.emit("titleCustomData:publicDataLoaded",e);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ni=class{constructor(e){this.ctx=e;}ctx;async getTitlePublicConfiguration(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.title.getTitlePublicConfiguration(e);return t.ok&&(this.ctx.data.config.applyTitlePublicConfiguration(t.data),this.ctx.emitter.emit("title:publicConfigurationReceived",t.data)),t}async getCurrencyDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.title.getCurrencyDefinitions(e);return t.ok&&(this.ctx.data.config.applyCurrencyDefinitions(t.data),this.ctx.emitter.emit("title:currencyDefinitionsReceived",t.data)),t}async getItemDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.title.getItemDefinitions(e);return t.ok&&(this.ctx.data.config.applyItemDefinitions(t.data),this.ctx.emitter.emit("title:itemDefinitionsReceived",t.data)),t}async getServerTime(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.title.getServerTime(e);return t.ok&&this.ctx.emitter.emit("title:serverTimeReceived",t.data),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var dp=15,hp="GameLoop",mp="BoardDefinition",ji=class{constructor(e){this.ctx=e;}ctx;get itemDefs(){return this.ctx.data.config.itemDefinitions}async getGameLoops(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.gameLoop.getGameLoops(e);return t.ok&&(this.ctx.data.config.patchSection(hp,t.data),this.ctx.emitter.emit("gameLoop:gameLoopsLoaded",t.data)),t}async getBoardDefinition(e=false){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");let i=await this.ctx.api.gameLoop.getBoardDefinition(t,e);return i.ok&&(this.ctx.data.config.patchSection(mp,i.data),this.ctx.emitter.emit("gameLoop:boardDefinitionLoaded",i.data)),i}async getBoardDefinitionForLevel(e,t=false){if(e<=0)return n("client","stageLevel must be > 0.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.StageLevel=e;let r=await this.ctx.api.gameLoop.getBoardDefinitionForLevel(i,t);return r.ok&&this.ctx.emitter.emit("gameLoop:boardDefinitionForLevelLoaded",r.data),r}async getUserBoardState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.gameLoop.getUserBoardState(e);return t.ok&&(this.ctx.data.user.applyBoardState(t.data),this.ctx.emitter.emit("gameLoop:boardStateLoaded",t.data)),t}async boardLoopRoll(e=1){if(e<1)return n("client","rollMultiplier must be >= 1.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),RollMultiplier:e,RelatedEntityID:`roll_${t.userID}_${P()}`},r=await this.ctx.api.gameLoop.boardLoopRoll(i);if(r.ok){let s=r.data,a=Zn(new Date,dp);this.ctx.data.user.patchBoardState(p=>{p.Position=s.NewPosition,p.CyclesCompleted=(p.CyclesCompleted??0)+(s.CyclesCompletedDelta??0),p.LastRollAtUtc=new Date().toISOString(),s.ActionRequired&&s.ActionData?p.Pending={Type:s.ActionRequired,TargetUserID:s.ActionData.TargetUserID,TargetPublicData:s.ActionData.PublicData,TargetBuildingStates:s.ActionData.TargetBuildingStates??void 0,TargetHasShield:s.ActionData.TargetHasShield??void 0,RollMultiplier:s.UsedMultiplier??1,ExpiresAtUtc:a}:s.SpecialModeOffer&&(p.Pending={Type:"SPECIAL",RollMultiplier:s.UsedMultiplier??1,ExpiresAtUtc:a,Special:{ModeID:s.SpecialModeOffer.ModeID??void 0,Choices:s.SpecialModeOffer.Choices??void 0}});}),s.Operation&&this.ctx.data.user.applyResourceOperation(s.Operation,this.itemDefs),s.ActionRequired==="RAID"&&await this.getUserBoardState(),this.ctx.emitter.emit("gameLoop:boardRolled",s);}return r}async boardLoopAttack(e=-1){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`attack_${t.userID}_${P()}`},r=await this.ctx.api.gameLoop.boardLoopAttack(i);if(r.ok){let s=r.data;this.ctx.data.user.clearBoardPending(),s.IsBotTarget&&s.Operation?this.ctx.data.user.applyResourceOperation(s.Operation,this.itemDefs):!s.IsBotTarget&&s.DualResult?.FromResult&&this.ctx.data.user.applyResourceOperation(s.DualResult.FromResult,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardAttacked",s);}else await this.getUserBoardState();return r}async boardLoopRaid(e,t){if(e<0||e>11)return n("client","digIndex must be between 0 and 11.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),DigIndex:e,RelatedEntityID:t??`raid_${i.userID}_${P()}`},s=await this.ctx.api.gameLoop.boardLoopRaid(r);if(s.ok){let a=s.data;a.Status==="CONTINUE"?this.ctx.data.user.patchBoardPendingRaidLayout(a.RaidLayout,a.OpenedIndex??-1):(this.ctx.data.user.clearBoardPending(),this.applyRaidResources(a)),this.ctx.emitter.emit("gameLoop:boardRaided",a);}else await this.getUserBoardState();return s}async boardLoopRaidFast(e){if(!e.length)return n("client","digIndices must not be empty.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),DigIndices:e,RelatedEntityID:`raidfast_${t.userID}_${P()}`},r=await this.ctx.api.gameLoop.boardLoopRaidFast(i);if(r.ok){let s=r.data;s.Status!=="CONTINUE"&&(this.ctx.data.user.clearBoardPending(),this.applyRaidResources(s)),this.ctx.emitter.emit("gameLoop:boardRaidedFast",s);}else await this.getUserBoardState();return r}async boardLoopBuild(e){if(e<0)return n("client","buildingIndex must be >= 0.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`build_${t.userID}_${e}_${P()}`},r=await this.ctx.api.gameLoop.boardLoopBuild(i);if(r.ok){let s=r.data;s.StageComplete?this.ctx.data.user.patchBoardState(a=>{a.StageLevel=(a.StageLevel??1)+1,a.Position=0,a.Pending=null,a.BuildingStates=null;}):this.ctx.data.user.patchBoardBuilding(s.BuiltIndex,a=>{s.NewLevel!=null&&(a.Level=s.NewLevel),a.IsDamaged=false,s.MaxLevelRewardClaimed&&(a.MaxLevelRewardClaimed=true);}),s.Operation&&this.ctx.data.user.applyResourceOperation(s.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardBuilt",s);}return r}async boardSpecialChoose(e,t){if(!e)return n("client","choiceID must not be empty.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),ChoiceID:e,SelectedOptionID:t,RelatedEntityID:`special_choose_${i.userID}_${P()}`},s=await this.ctx.api.gameLoop.boardSpecialChoose(r);if(s.ok){let a=s.data;a.Mode==="Instant"||a.Mode===0?this.ctx.data.user.clearBoardPending():this.ctx.data.user.patchBoardSpecialPending(D=>{D.ChoiceID=e,D.ChosenMode=a.Mode??"Timed",D.StartedAtUtc=a.StartedAtUtc??null,D.DurationSeconds=a.DurationSeconds??null,D.AdViewsUsed=0;}),a.Operation&&this.ctx.data.user.applyResourceOperation(a.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialChose",a);}return s}async boardSpecialApplyMultiplier(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:e??`special_ad_${t.userID}_${P()}`},r=await this.ctx.api.gameLoop.boardSpecialApplyMultiplier(i);if(r.ok){let s=r.data;this.ctx.data.user.patchBoardSpecialPending(a=>{a.AdViewsUsed=s.AdViewsUsed??0,a.AccumulatedMultiplier=s.AccumulatedMultiplier??0;}),this.ctx.emitter.emit("gameLoop:boardSpecialApplyMultiplier",s);}return r}async boardSpecialClaim(){let e=this.ctx.auth.context;if(!e)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:`special_claim_${e.userID}_${P()}`},i=await this.ctx.api.gameLoop.boardSpecialClaim(t);if(i.ok){let r=i.data;this.ctx.data.user.clearBoardPending(),r.Operation&&this.ctx.data.user.applyResourceOperation(r.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialClaimed",r);}return i}async getCommunityChestState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.gameLoop.getCommunityChestState(e);return t.ok&&(this.ctx.data.user.applyCommunityChestUserState(t.data.UserState??null),this.ctx.emitter.emit("gameLoop:communityChestStateLoaded",t.data)),t}async joinOrCreateCommunityChest(){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let e={...this.ctx.buildAuthedBaseRequest()},t=await this.ctx.api.gameLoop.joinOrCreateCommunityChest(e);if(t.ok){let i=t.data.Group;i?.GroupID&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:i.GroupID,ActiveRoundIndex:i.RoundIndex??void 0}),this.ctx.emitter.emit("gameLoop:communityChestJoined",t.data);}return t}async claimCommunityChestMilestone(e,t){if(!e)return n("client","milestoneID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),MilestoneID:e,GroupID:t},r=await this.ctx.api.gameLoop.claimCommunityChestMilestone(i);return r.ok&&(r.data.Resources&&this.ctx.data.user.applyResourceOperation(r.data.Resources,this.itemDefs),this.ctx.emitter.emit("gameLoop:communityChestMilestoneClaimed",r.data)),r}async claimCommunityChestGrandPrize(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.gameLoop.claimCommunityChestGrandPrize(t);return i.ok&&(i.data.Resources&&this.ctx.data.user.applyResourceOperation(i.data.Resources,this.itemDefs),this.ctx.emitter.emit("gameLoop:communityChestGrandPrizeClaimed",i.data)),i}async leaveCommunityChest(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.gameLoop.leaveCommunityChest(t);return i.ok&&(i.data.Success&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:void 0,ActiveRoundIndex:-1}),this.ctx.emitter.emit("gameLoop:communityChestLeft",i.data)),i}applyRaidResources(e){e.Operation?this.ctx.data.user.applyResourceOperation(e.Operation,this.itemDefs):e.DualResult?.FromResult&&this.ctx.data.user.applyResourceOperation(e.DualResult.FromResult,this.itemDefs);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Fi=class{constructor(e){this.ctx=e;}ctx;async execute(e,t,i,r){let s=e.trim();if(!s)return n("client","FunctionName is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),FunctionName:s,FunctionParameter:t,RevisionSelection:i,SpecificRevision:r},p=await this.ctx.api.cloudCode.execute(a);return p.ok&&this.ctx.emitter.emit("cloudCode:executed",p.data),p}};var uo=zod.z.object({ServerTimeUtc:u,SourceType:zt,SourceID:zod.z.string(),TargetType:zt,TargetID:zod.z.string(),SourceSpent:w,FeeAmount:w,RateApplied:q,TargetCredited:w}),co=zod.z.object({ServerTimeUtc:u,SourceType:zt,SourceID:zod.z.string(),TargetType:zt,TargetID:zod.z.string(),SourceSpent:q,FeeAmount:q,RateApplied:q,TargetCredited:q}),Vi={Convert:"Convert",CryptoConvert:"CryptoConvert"},fp={Active:"Active",Hidden:"Hidden",Deprecated:"Deprecated",Maintenance:"Maintenance"},po=zod.z.enum(["Active","Hidden","Deprecated","Maintenance"]),gp={Automatic:"Automatic",Manual:"Manual"},Rp=zod.z.enum(["Automatic","Manual"]),yp=zod.z.object({ValueInUSD:q.nullish(),ValueInUSDUpdatedAt:u.nullish(),InitialDeposit:zod.z.number().nullish(),MinBalance:zod.z.number().nullish(),MaxBalance:zod.z.number().nullish(),DailyEarnLimit:zod.z.number().nullish(),DailySpendLimit:zod.z.number().nullish()}).passthrough(),Cp=zod.z.object({Rate:zod.z.number().nullish(),Max:zod.z.number().nullish(),Period:zod.z.number().nullish()}).passthrough(),Sp=zod.z.object({IsTradable:zod.z.boolean().nullish(),IsPurchasable:zod.z.boolean().nullish(),IsRefundable:zod.z.boolean().nullish()}).passthrough(),xp=zod.z.object({TargetCurrencyType:zt.nullish(),TargetCurrencyID:zod.z.string(),Rate:q.nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish(),DailyLimit:zod.z.number().nullish()}).passthrough(),ho=zod.z.object({Enabled:zod.z.boolean().nullish(),RateMode:Rp.nullish(),FeePercent:q.nullish(),Targets:zod.z.array(xp).nullish()}).passthrough(),mo=zod.z.object({CreatedAt:u.nullish(),UpdatedAt:u.nullish()}).passthrough(),Dp=zod.z.object({CurrencyID:zod.z.string(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Economy:yp.nullish(),Recharge:Cp.nullish(),Conversion:ho.nullish(),Permissions:Sp.nullish(),Audit:mo.nullish(),Status:po.nullish()}).passthrough(),bp=zod.z.object({NetworkID:zod.z.string(),ContractAddress:zod.z.string().nullish(),Decimals:zod.z.number().nullish(),MinDeposit:q.nullish(),MinWithdraw:q.nullish(),WithdrawFee:q.nullish(),DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish()}).passthrough(),zp=zod.z.object({DailyWithdrawUsd:q.nullish(),MonthlyWithdrawUsd:q.nullish(),KycRequiredAboveUsd:q.nullish()}).passthrough(),Tp=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),SpendableInGame:zod.z.boolean().nullish(),ConvertibleToVirtual:zod.z.boolean().nullish()}).passthrough(),Ds=zod.z.object({CurrencyID:zod.z.string(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),DisplayDecimals:zod.z.number().nullish(),ValueInUSD:q.nullish(),ValueInUSDUpdatedAt:u.nullish(),DeveloperDepositSharePercent:q.nullish(),CommunityMarketingDepositSharePercent:q.nullish(),WithdrawalBurnPercent:q.nullish(),Networks:zod.z.array(bp).nullish(),Limits:zp.nullish(),Permissions:Tp.nullish(),Conversion:ho.nullish(),Audit:mo.nullish(),Status:po.nullish()}).passthrough(),_i=zod.z.object({VirtualCurrencies:zod.z.record(zod.z.string(),Dp).nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Ds).nullish()}).passthrough();var fo=zod.z.object({OptionID:zod.z.string().nullish(),Name:zod.z.string().nullish(),Cost:Et.nullish(),AllowedPlatforms:zod.z.array(Kt).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Y=zod.z.record(zod.z.string(),fo),vp=zod.z.object({Store:Ht,Receipt:zod.z.string(),Signature:zod.z.string().nullish()}).passthrough();var go=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),ItemInstanceID:zod.z.string().nullish(),EquippedAt:u.nullish()}),bs=zod.z.object({CharacterID:zod.z.string(),Level:zod.z.number().nullish(),Experience:w.nullish(),Power:zod.z.number().nullish(),StatLevels:zod.z.record(zod.z.string(),zod.z.number()).nullish(),Equipment:zod.z.record(zod.z.string(),go).nullish(),UpdatedAt:u.nullish()}).passthrough(),Pp=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),Ip=zod.z.object({ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Quantity:zod.z.number().nullish(),RemainingUses:zod.z.number().nullish(),Level:zod.z.number().nullish(),AcquiredAt:u,ExpiresAt:u.nullish(),EquippedSlot:Pp.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(o=>o),ut=zod.z.object({ChangedInstances:zod.z.record(zod.z.string(),Ip).nullish(),RemovedInstanceIDs:zod.z.array(zod.z.string()).nullish()}),Ro=zod.z.object({Characters:zod.z.record(zod.z.string(),bs).nullish()}),zs=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),StatID:zod.z.string(),StatLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:b.nullish()}),Ts=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),NewLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:b.nullish()}),yo=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),Equipment:zod.z.record(zod.z.string(),go).nullish(),ReplacedInstanceIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:ut.nullish()}),Co=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:ut.nullish()}),kp=zod.z.object({ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish()}),So=zod.z.object({ServerTimeUtc:u,Characters:zod.z.record(zod.z.string(),kp).nullish(),Inventory:ut.nullish()}),vs=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),Power:zod.z.number().nullish(),Resources:b.nullish()}),xo=$e(vs),Do=$e(Ts),bo=$e(zs),zo=zod.z.object({RequiredStatID:zod.z.string(),RequiredLevel:zod.z.number()}).passthrough(),To=zod.z.object({StatID:zod.z.string(),TypeID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),MaxLevel:zod.z.number().nullish(),Weight:zod.z.number().nullish(),PriceOptions:Y.nullish(),CostScalingFactor:zod.z.number().nullish(),BaseStatValue:zod.z.number().nullish(),StatScalingFactor:zod.z.number().nullish(),CharacterLevelScalingFactor:zod.z.number().nullish(),Requirements:zod.z.array(zo).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),vo=zod.z.object({Level:zod.z.number().nullish(),PriceOptions:Y.nullish(),GlobalStatMultiplier:zod.z.number().nullish(),StatMaxLevelMultiplier:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Mp=zod.z.object({SlotID:zod.z.string(),MinCharacterLevel:zod.z.number().nullish(),StatRequirements:zod.z.array(zo).nullish(),AllowedRarityIDs:zod.z.array(zod.z.string()).nullish(),AllowedItemTags:zod.z.array(zod.z.string()).nullish(),MinItemLevel:zod.z.number().nullish(),MaxItemLevel:zod.z.number().nullish()}).passthrough(),Po=zod.z.object({Slots:zod.z.record(zod.z.string(),Mp).nullish()}).passthrough(),wp=zod.z.object({DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Lore:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Op=zod.z.object({ClassID:zod.z.string().nullish(),RarityID:zod.z.string().nullish(),Tags:zod.z.array(zod.z.string()).nullish()}).passthrough(),Ap=zod.z.object({UnlockedByDefault:zod.z.boolean().nullish(),PriceOptions:Y.nullish()}).passthrough(),Up=zod.z.object({Stats:X.nullish(),Levels:X.nullish(),Equipment:X.nullish()}).passthrough(),Bp=zod.z.object({CharacterID:zod.z.string(),Identity:wp.nullish(),Classification:Op.nullish(),Unlock:Ap.nullish(),Presets:Up.nullish(),Equipment:Po.nullish(),Stats:zod.z.record(zod.z.string(),To).nullish(),Levels:zod.z.record(zod.z.string(),vo).nullish()}).passthrough(),Lp=zod.z.object({Stats:zod.z.record(zod.z.string(),To).nullish()}).passthrough(),qp=zod.z.object({Levels:zod.z.record(zod.z.string(),vo).nullish()}).passthrough(),Ep=zod.z.object({Equipment:Po.nullish()}).passthrough(),Gp=zod.z.object({Stats:zod.z.record(zod.z.string(),Lp).nullish(),Levels:zod.z.record(zod.z.string(),qp).nullish(),Equipment:zod.z.record(zod.z.string(),Ep).nullish()}).passthrough(),Wi=zod.z.object({Definitions:zod.z.record(zod.z.string(),Bp).nullish(),Presets:Gp.nullish()}).passthrough(),Me={GetCharacterDefinitions:"GetCharacterDefinitions",GetUserCharacters:"GetUserCharacters",UnlockCharacter:"UnlockCharacter",UpgradeStatLevel:"UpgradeStatLevel",UpgradeCharacterLevel:"UpgradeCharacterLevel",EquipItems:"EquipItems",UnequipItems:"UnequipItems",UnequipAllCharacters:"UnequipAllCharacters",UnlockCharactersBatch:"UnlockCharactersBatch",UpgradeCharacterLevelsBatch:"UpgradeCharacterLevelsBatch",UpgradeStatLevelsBatch:"UpgradeStatLevelsBatch"};var Np={EVM:"EVM",Solana:"Solana"},jp=zod.z.enum(["EVM","Solana"]),Fp={AutoLinkedFromTransaction:"AutoLinkedFromTransaction",SignatureVerified:"SignatureVerified",ManuallyLinked:"ManuallyLinked"},Vp=zod.z.enum(["AutoLinkedFromTransaction","SignatureVerified","ManuallyLinked"]),_p={Token:"Token",Nft:"Nft"},Io=zod.z.enum(["Token","Nft"]),Wp={NotRequested:"NotRequested",Pending:"Pending",Verified:"Verified",Rejected:"Rejected",Expired:"Expired"},Qp=zod.z.enum(["NotRequested","Pending","Verified","Rejected","Expired"]),Kp={None:"None",Tier1:"Tier1",Tier2:"Tier2",Tier3:"Tier3"},Hp=zod.z.enum(["None","Tier1","Tier2","Tier3"]),$p={Pending:"Pending",Completed:"Completed",Failed:"Failed",Expired:"Expired",Abandoned:"Abandoned"},Ps=zod.z.enum(["Pending","Completed","Failed","Expired","Abandoned"]),ko={GameTopUp:"game_topup",CommunityReward:"community_reward"};function Qi(o){let e=o?.trim();return e||ko.GameTopUp}var Zp={UsersCryptoWallet:"UsersCryptoWallet",Game:"Game"},Mo=zod.z.enum(["UsersCryptoWallet","Game"]),Jp=zod.z.object({ContractAddress:zod.z.string().nullish(),ItemCatalogID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish()}).passthrough(),wo=zod.z.object({Ios:zod.z.boolean().nullish(),Android:zod.z.boolean().nullish(),Web:zod.z.boolean().nullish()}).passthrough(),Yp=zod.z.object({NetworkID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Type:jp.nullish(),ChainID:zod.z.number().nullish(),ChainTicker:zod.z.string().nullish(),RewardPoolAddress:zod.z.string().nullish(),VaultDepositAddress:zod.z.string().nullish(),ChainConfigVersion:zod.z.number().nullish(),RequiredConfirmations:zod.z.number().nullish(),DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),NftDepositsEnabled:zod.z.boolean().nullish(),NftWithdrawalsEnabled:zod.z.boolean().nullish(),PlatformOverrides:wo.nullish(),NftCollections:zod.z.array(Jp).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Xp=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),NftDepositsEnabled:zod.z.boolean().nullish(),NftWithdrawalsEnabled:zod.z.boolean().nullish(),PlatformOverrides:wo.nullish()}).passthrough(),ed=zod.z.object({MinAccountAgeDays:zod.z.number().nullish(),MultiAccountCheckEnabled:zod.z.boolean().nullish(),BanOnSharedWithdrawalAddress:zod.z.boolean().nullish(),PendingWithdrawalTtlHours:zod.z.number().nullish()}).passthrough();var td=zod.z.enum(["OnChain","Combined"]),id=zod.z.object({Enabled:zod.z.boolean().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),MinBalance:q.nullish(),BalanceSource:td.nullish(),DenyMessage:zod.z.string().nullish()}).passthrough(),rd=zod.z.object({Enabled:zod.z.boolean().nullish(),TokenGates:zod.z.array(id).nullish(),WalletConnectProjectId:zod.z.string().nullish()}).passthrough(),Is=zod.z.object({SystemState:Xp.nullish(),Networks:zod.z.record(zod.z.string(),Yp).nullish(),AccountSafety:ed.nullish(),WalletLogin:rd.nullish()}).passthrough(),sd=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),LinkedAt:u.nullish(),LastUsedAt:u.nullish(),LinkType:Vp.nullish(),IsSignatureVerified:zod.z.boolean().nullish()}).passthrough(),Oo=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Type:Io.nullish(),NetworkID:zod.z.string().nullish(),AssetID:zod.z.string().nullish(),Amount:q.nullish(),CreatedAt:u.nullish(),ExpiresAt:u.nullish()}).passthrough(),nd=zod.z.object({Status:Qp.nullish(),Tier:Hp.nullish(),VerifiedAt:u.nullish(),ExpiresAt:u.nullish(),RejectedAt:u.nullish(),ProviderReference:zod.z.string().nullish(),RejectionReason:zod.z.string().nullish()}).passthrough(),od=zod.z.object({CurrencyID:zod.z.string().nullish(),Deposits:zod.z.number().nullish(),DepositsVolumeNative:q.nullish(),DepositsVolumeUsd:q.nullish(),Withdrawals:zod.z.number().nullish(),WithdrawalsVolumeNative:q.nullish(),WithdrawalsVolumeUsd:q.nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),FirstDepositAt:u.nullish(),LastDepositAt:u.nullish(),FirstWithdrawalAt:u.nullish(),LastWithdrawalAt:u.nullish()}).passthrough(),ad=zod.z.object({TotalDeposits:zod.z.number().nullish(),TotalWithdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),TotalDepositsVolumeUsd:q.nullish(),TotalWithdrawalsVolumeUsd:q.nullish(),PerCurrency:zod.z.record(zod.z.string(),od).nullish()}).passthrough(),ld=zod.z.object({NetworkID:zod.z.string().nullish(),ItemCatalogID:zod.z.string().nullish(),Deposits:zod.z.number().nullish(),Withdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),FirstDepositAt:u.nullish(),LastDepositAt:u.nullish(),FirstWithdrawalAt:u.nullish(),LastWithdrawalAt:u.nullish()}).passthrough(),ud=zod.z.object({TotalDeposits:zod.z.number().nullish(),TotalWithdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),PerCollection:zod.z.record(zod.z.string(),ld).nullish()}).passthrough(),cd=zod.z.object({Tokens:ad.nullish(),Nfts:ud.nullish()}).passthrough(),pd=zod.z.object({CurrencyID:zod.z.string().nullish(),Balance:q.nullish(),MinBalance:q.nullish()}).passthrough(),dd=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),CheckedAt:u.nullish(),LoggedInAt:u.nullish(),GatePassed:zod.z.boolean().nullish(),GatedBalances:zod.z.array(pd).nullish()}).passthrough(),hd=zod.z.object({Version:zod.z.number().nullish(),Stats:cd.nullish(),LinkedWallets:zod.z.record(zod.z.string(),sd).nullish(),LastWalletLogin:dd.nullish(),PendingWithdrawals:zod.z.array(Oo).nullish(),Kyc:nd.nullish(),FirstActivityAt:u.nullish(),LastActivityAt:u.nullish(),IsFlagged:zod.z.boolean().nullish(),FlagReason:zod.z.string().nullish()}).passthrough(),md=zod.z.object({CurrencyID:zod.z.string(),AmountDelta:q,FrozenDelta:q,UpdatedAt:u}).passthrough(),Ki=zod.z.object({CryptoBalances:zod.z.record(zod.z.string(),md).nullish(),PendingAdded:Oo.nullish(),PendingRemovedIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),fd=zod.z.object({Amount:q,Frozen:q,CreatedAt:u.nullish(),UpdatedAt:u.nullish()}).passthrough().transform(o=>o),gd=zod.z.object({ID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CreatedAt:u.nullish(),UpdatedAt:u.nullish(),UserID:zod.z.string().nullish(),TransactionHash:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ChainType:zod.z.string().nullish(),ChainID:zod.z.number().nullish(),Direction:Mo.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:q.nullish(),Status:Ps.nullish(),SignatureData:zod.z.string().nullish(),CompletedAt:u.nullish(),ExpiresAt:u.nullish(),FailReason:zod.z.string().nullish(),Reason:zod.z.string().nullish(),Category:zod.z.string().nullish(),TokenID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountUsd:q.nullish(),NetPayoutAmount:q.nullish()}).passthrough(),Rd=zod.z.object({ID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CreatedAt:u.nullish(),UpdatedAt:u.nullish(),UserID:zod.z.string().nullish(),TransactionHash:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ChainType:zod.z.string().nullish(),ChainID:zod.z.number().nullish(),Direction:Mo.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:q.nullish(),Status:Ps.nullish(),SignatureData:zod.z.string().nullish(),CompletedAt:u.nullish(),ExpiresAt:u.nullish(),FailReason:zod.z.string().nullish(),Reason:zod.z.string().nullish(),Category:zod.z.string().nullish(),NFTID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),SkinID:zod.z.string().nullish()}).passthrough(),Ao=zod.z.object({To:zod.z.string().nullish(),Amount:zod.z.union([zod.z.string(),zod.z.number()]).nullish()}).passthrough(),ks=zod.z.object({TokenAddress:zod.z.string().nullish(),WalletAddress:zod.z.string().nullish(),Amount:zod.z.string().nullish(),BurnAmount:zod.z.string().nullish(),TokenId:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),ContractAddress:zod.z.string().nullish(),UserID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),Category:zod.z.string().nullish(),Deadline:zod.z.string().nullish(),SignatureEpoch:zod.z.string().nullish(),Splits:zod.z.array(Ao).nullish(),Signature:zod.z.string().nullish()}).passthrough(),Ms=zod.z.object({Mint:zod.z.string().nullish(),WalletAddress:zod.z.string().nullish(),Amount:zod.z.string().nullish(),BurnAmount:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),ExpiresAt:zod.z.string().nullish(),ProgramID:zod.z.string().nullish(),SignatureEpoch:zod.z.string().nullish(),Domain:zod.z.string().nullish(),Splits:zod.z.array(Ao).nullish(),SignatureHex:zod.z.string().nullish(),SigIxIndex:zod.z.number().nullish(),Ed25519PublicKey:zod.z.string().nullish(),Ed25519Message:zod.z.string().nullish(),UserID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),Category:zod.z.string().nullish()}).passthrough(),Uo=zod.z.object({Blockchain:Is.nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Ds).nullish()}).passthrough(),Bo=zod.z.object({State:hd.nullish(),CryptoBalances:zod.z.record(zod.z.string(),fd).nullish()}).passthrough(),Lo=zod.z.object({ServerTimeUtc:u.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:q.nullish(),AmountUsd:q.nullish(),StateDelta:Ki.nullish()}).passthrough(),qo=zod.z.object({ServerTimeUtc:u.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),NftTokenID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),Resources:b.nullish(),Inventory:ut.nullish()}).passthrough(),Eo=zod.z.object({ServerTimeUtc:u.nullish(),TitleTransactionID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:q.nullish(),NetAmountNative:q.nullish(),BurnAmountNative:q.nullish(),AmountUsd:q.nullish(),ExpiresAt:u.nullish(),EvmSignature:ks.nullish(),SolanaSignature:Ms.nullish(),StateDelta:Ki.nullish()}).passthrough(),Go=zod.z.object({ServerTimeUtc:u.nullish(),TitleTransactionID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),NftTokenID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),ExpiresAt:u.nullish(),Resources:b.nullish(),EvmSignature:ks.nullish(),SolanaSignature:Ms.nullish(),StateDelta:Ki.nullish(),Inventory:ut.nullish()}).passthrough(),No=zod.z.object({TokenTransactions:zod.z.array(gd).nullish(),NFTTransactions:zod.z.array(Rd).nullish()}).passthrough(),ws=zod.z.object({ServerTimeUtc:u.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:q.nullish(),AmountUsd:q.nullish(),Target:zod.z.string().nullish()}).passthrough(),jo=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Kind:Io.nullish(),EvmSignature:ks.nullish(),SolanaSignature:Ms.nullish()}).passthrough(),Fo=zod.z.object({TitleTransactionID:zod.z.string().nullish(),OnChainTxHash:zod.z.string().nullish(),Status:Ps.nullish(),StateDelta:Ki.nullish()}).passthrough(),we={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",DepositToken:"DepositToken",DepositNFT:"DepositNFT",RequestTokenWithdrawal:"RequestTokenWithdrawal",RequestNFTWithdrawal:"RequestNFTWithdrawal",GetTransactionHistory:"GetTransactionHistory",RetryWithdrawal:"RetryWithdrawal",ConfirmWithdrawal:"ConfirmWithdrawal",DonateToDeveloper:"DonateToDeveloper",DonateToUsersPool:"DonateToUsersPool"};var yd="Blockchain",Hi=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.blockchain.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(yd,t.data.Blockchain),this.ctx.emitter.emit("blockchain:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.blockchain.getUserState(e);return t.ok&&(this.ctx.data.user.applyBlockchainState(t.data.State??null,t.data.CryptoBalances),this.ctx.emitter.emit("blockchain:userStateLoaded",t.data)),t}async depositToken(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.NetworkID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.depositToken(i);return r.ok&&r.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(r.data.CurrencyID,new ii__default.default(r.data.AmountNative??0),r.data.ServerTimeUtc??void 0),this.ctx.emitter.emit("blockchain:tokenDeposited",r.data)),r}async depositNFT(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.NetworkID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.depositNFT(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("blockchain:nftDeposited",r.data)),r}async requestTokenWithdrawal(e,t,i,r,s){if(!e)return n("client","CurrencyID is required.");if(!t)return n("client","NetworkID is required.");if(!i)return n("client","WalletAddress is required.");if(!r)return n("client","Amount is required.");let a=this.baseRequest();if(!a)return n("unauthorized","Not logged in.");a.CurrencyID=e,a.NetworkID=t,a.WalletAddress=i,a.Amount=r,a.Category=Qi(s);let p=await this.ctx.api.blockchain.requestTokenWithdrawal(a);return p.ok&&p.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(p.data.CurrencyID,new ii__default.default(p.data.AmountNative??0).negated(),p.data.ServerTimeUtc??void 0),this.ctx.emitter.emit("blockchain:tokenWithdrawalRequested",p.data)),p}async requestNFTWithdrawal(e,t,i,r,s,a,p){if(!e)return n("client","ItemID is required.");if(!t)return n("client","NetworkID is required.");if(!i)return n("client","WalletAddress is required.");if(!r)return n("client","Amount is required.");let D=this.baseRequest();if(!D)return n("unauthorized","Not logged in.");D.ItemID=e,D.NetworkID=t,D.WalletAddress=i,D.Amount=r,D.Category=Qi(s),a!==void 0&&(D.Level=a),p&&(D.ItemInstanceID=p);let U=await this.ctx.api.blockchain.requestNFTWithdrawal(D);return U.ok&&(this.ctx.data.user.applyResourceOperation(U.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("blockchain:nftWithdrawalRequested",U.data)),U}async getTransactionHistory(e=50){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Amount=String(e);let i=await this.ctx.api.blockchain.getTransactionHistory(t);return i.ok&&this.ctx.emitter.emit("blockchain:transactionHistoryLoaded",i.data),i}async retryWithdrawal(e){if(!e)return n("client","TitleTransactionID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.TitleTransactionID=e;let i=await this.ctx.api.blockchain.retryWithdrawal(t);return i.ok&&this.ctx.emitter.emit("blockchain:withdrawalRetried",i.data),i}async confirmWithdrawal(e,t){if(!e)return n("client","TitleTransactionID is required.");if(!t)return n("client","On-chain TransactionHash is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.TitleTransactionID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.confirmWithdrawal(i);return r.ok&&this.ctx.emitter.emit("blockchain:withdrawalConfirmed",r.data),r}async donateToDeveloper(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.NetworkID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.donateToDeveloper(i);return r.ok&&this.ctx.emitter.emit("blockchain:donatedToDeveloper",r.data),r}async donateToUsersPool(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.NetworkID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.donateToUsersPool(i);return r.ok&&this.ctx.emitter.emit("blockchain:donatedToUsersPool",r.data),r}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var be=zod.z.object({Username:zod.z.string().nullish(),Country:zod.z.string().nullish(),AvatarUrl:zod.z.string().nullish(),Premium:zod.z.boolean().nullish(),Level:zod.z.number().nullish(),Power:zod.z.number().nullish(),BoardRank:zod.z.number().nullish()}).passthrough();var Cd={Head:"Head",Torso:"Torso",Legs:"Legs"},$i=zod.z.enum(["Head","Torso","Legs"]),Sd={Open:"Open",InProgress:"InProgress",Cancelled:"Cancelled",Completed:"Completed"},Os=zod.z.enum(["Open","InProgress","Cancelled","Completed"]),Wo=zod.z.object({AttackTarget:$i,DefenseTarget:$i});var xd=zod.z.enum(["Hit","Critical","Block","Dodge"]),Dd=zod.z.object({RoundIndex:zod.z.number().nullish(),AttackerID:zod.z.string().nullish(),DefenderID:zod.z.string().nullish(),AttackZone:$i.nullish(),DefenseZone:$i.nullish(),HitType:xd.nullish(),DamageDealt:zod.z.number().nullish(),DefenderHpRemaining:zod.z.number().nullish()}).passthrough(),bd=zod.z.object({MaxHp:zod.z.number().nullish(),CurrentHp:zod.z.number().nullish(),Damage:zod.z.number().nullish(),AttackSpeed:zod.z.number().nullish(),CritChance:zod.z.number().nullish(),CritMultiplier:zod.z.number().nullish(),Armor:zod.z.number().nullish(),DodgeChance:zod.z.number().nullish()}).passthrough(),zd=zod.z.object({ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Quantity:zod.z.number().nullish(),RemainingUses:zod.z.number().nullish(),Level:zod.z.number().nullish(),AcquiredAt:u,ExpiresAt:u.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(o=>o),_o=zod.z.object({UserID:zod.z.string().nullish(),SelectedCharacterID:zod.z.string().nullish(),SelectedCharacter:bs.nullish(),BattleStrategy:zod.z.array(Wo).nullish(),UnstackableItems:zod.z.record(zod.z.string(),zd).nullish(),Stats:bd.nullish()}).passthrough(),Td=zod.z.object({WinnerUserID:zod.z.string().nullish(),LoserUserID:zod.z.string().nullish(),Entry:fe.nullish(),NetReward:fe.nullish(),BattleLog:zod.z.array(Dd).nullish(),IsDraw:zod.z.boolean().nullish(),P1BattleProfile:_o.nullish(),P2BattleProfile:_o.nullish()}).passthrough(),Qo=zod.z.object({MatchID:zod.z.string(),TitleID:zod.z.string().nullish(),RuleID:zod.z.string().nullish(),CreatedAt:u.nullish(),CreatorID:zod.z.string().nullish(),CreatorCharacterID:zod.z.string().nullish(),CreatorStrategy:zod.z.array(Wo).nullish(),TargetUserID:zod.z.string().nullish(),Entry:fe.nullish(),CreationCostPaid:fe.nullish(),RefundCreationCostOnCancel:zod.z.boolean().nullish(),JoinedByUserID:zod.z.string().nullish(),JoinedByCharacterID:zod.z.string().nullish(),JoinedAt:u.nullish(),Status:Os.nullish(),WinnerUserID:zod.z.string().nullish(),CompletedAt:u.nullish(),IsRewardDistributed:zod.z.boolean().nullish(),RewardDistributedAt:u.nullish()}).passthrough(),Ko=zod.z.object({Status:Os,MatchID:zod.z.string(),Entry:fe.nullish(),Resources:b.nullish()}),Ho=zod.z.object({Match:Qo.nullish()}),$o=zod.z.object({MatchID:zod.z.string(),Status:Os,Resources:b.nullish()}),Zo=zod.z.object({Battle:Td.nullish(),Resources:b.nullish(),ResourcesDual:dt.nullish()}),As=zod.z.object({Matches:zod.z.array(Qo).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}),Je={CreateMatch:"CreateMatch",UpdateMatch:"UpdateMatch",CancelMatch:"CancelMatch",InstantBattle:"InstantBattle",SaveStrategy:"SaveStrategy",GetMyMatches:"GetMyMatches",GetAvailableMatches:"GetAvailableMatches",GetDefinitions:"GetDefinitions"};var vd=zod.z.enum(["VirtualCurrency","Item","EventToken"]);var Pd=zod.z.enum(["Constant","Stat","RankMultiplier","AllMight","GearFlat","GearPercent"]),Id=zod.z.object({HealthStatID:zod.z.string().nullish(),DamageStatID:zod.z.string().nullish(),ArmorStatID:zod.z.string().nullish(),AttackSpeedStatID:zod.z.string().nullish(),CritChanceStatID:zod.z.string().nullish(),CritDamageStatID:zod.z.string().nullish(),DodgeStatID:zod.z.string().nullish(),AllMightStatID:zod.z.string().nullish()}).passthrough(),kd=zod.z.object({MaxRounds:zod.z.number().nullish(),BlockDamageMultiplier:zod.z.number().nullish(),MinHitDamage:zod.z.number().nullish(),DefaultCritMultiplier:zod.z.number().nullish(),MaxCritChance:zod.z.number().nullish(),MaxDodgeChance:zod.z.number().nullish()}).passthrough(),Md=zod.z.object({Source:Pd.nullish(),StatID:zod.z.string().nullish(),Value:zod.z.number().nullish(),OnePlus:zod.z.boolean().nullish()}).passthrough(),wd=zod.z.object({Coefficient:zod.z.number().nullish(),Factors:zod.z.array(Md).nullish()}).passthrough(),mt=zod.z.object({Terms:zod.z.array(wd).nullish()}).passthrough(),Od=zod.z.object({Health:mt.nullish(),Damage:mt.nullish(),Armor:mt.nullish(),AttackSpeed:mt.nullish(),CritChance:mt.nullish(),CritDamage:mt.nullish(),Dodge:mt.nullish()}).passthrough(),Jo=zod.z.object({StatMapping:Id.nullish(),Combat:kd.nullish(),Formula:Od.nullish()}).passthrough(),Ad=zod.z.object({BurnRate:zod.z.number().nullish()}).passthrough(),Us=zod.z.object({Kind:vd.nullish(),CurrencyID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),TokenType:$t.nullish(),EntityID:zod.z.string().nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish()}).passthrough(),Yo=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(Us).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),Xo=zod.z.object({PriceOptions:Y.nullish(),RefundCostOnCancel:zod.z.boolean().nullish(),MaxOpenMatches:zod.z.number().nullish(),Limits:ge.nullish(),AllowPrivateMatches:zod.z.boolean().nullish(),MaxMatchesPerOpponentPerDay:zod.z.number().nullish()}).passthrough(),Ud=zod.z.object({RuleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Economy:Ad.nullish(),Entry:Yo.nullish(),Creation:Xo.nullish(),Settings:Jo.nullish()}).passthrough(),Bd=zod.z.object({Rules:zod.z.record(zod.z.string(),Ud).nullish(),Defaults:Jo.nullish(),EntryDefaults:Yo.nullish(),CreationDefaults:Xo.nullish()}).passthrough(),Bs=zod.z.object({InstantBattle:Bd.nullish()}).passthrough(),ea=Bs;var Ld={Listing:"Listing",Auction:"Auction",BuyOrder:"BuyOrder",DirectTrade:"DirectTrade"},Ls=zod.z.enum(["Listing","Auction","BuyOrder","DirectTrade"]),qd={Active:"Active",Completed:"Completed",Cancelled:"Cancelled",Declined:"Declined",Expired:"Expired"},qs=zod.z.enum(["Active","Completed","Cancelled","Declined","Expired"]),Ed={Burn:"Burn",Ledger:"Ledger"},Gd=zod.z.enum(["Burn","Ledger"]),Ji={Item:"Item",VirtualCurrency:"VirtualCurrency"},Es=zod.z.enum(["Item","VirtualCurrency"]),Nd=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:w.nullish()}).passthrough(),jd=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(Us).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),Fd=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:w.nullish(),Sink:Gd.nullish(),LedgerAccountID:zod.z.string().nullish(),PerCatalogOverrides:zod.z.record(zod.z.string(),Nd).nullish(),ApplyToDirectTrades:zod.z.boolean().nullish()}).passthrough(),Vd=zod.z.object({AllowedCatalogIDs:zod.z.array(zod.z.string()).nullish(),DeniedCatalogIDs:zod.z.array(zod.z.string()).nullish(),DeniedItemIDs:zod.z.array(zod.z.string()).nullish(),AllowUnstackableWithState:zod.z.boolean().nullish()}).passthrough(),_d=zod.z.object({Enabled:zod.z.boolean().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),MaxActiveListings:zod.z.number().nullish(),CreateLimits:ge.nullish(),BuyLimits:ge.nullish(),ListingFeeOptions:Y.nullish(),RefundListingFeeOnCancel:zod.z.boolean().nullish()}).passthrough(),Wd=zod.z.object({Enabled:zod.z.boolean().nullish(),MinDurationHours:zod.z.number().nullish(),MaxDurationHours:zod.z.number().nullish(),AntiSnipeWindowSeconds:zod.z.number().nullish(),AntiSnipeExtensionSeconds:zod.z.number().nullish(),MaxAntiSnipeExtensions:zod.z.number().nullish(),MinBidStepPercent:zod.z.number().nullish(),MinBidStepAbsolute:w.nullish(),BidLimits:ge.nullish()}).passthrough(),Qd=zod.z.object({Enabled:zod.z.boolean().nullish(),MaxActiveOrders:zod.z.number().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),CreateLimits:ge.nullish(),FillLimits:ge.nullish()}).passthrough(),Kd=zod.z.object({Enabled:zod.z.boolean().nullish(),OfferExpirationHours:zod.z.number().nullish(),MaxPendingOutgoing:zod.z.number().nullish(),AllowGifts:zod.z.boolean().nullish(),CreateLimits:ge.nullish()}).passthrough(),Hd=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),Gs=zod.z.object({Enabled:zod.z.boolean().nullish(),Gate:_.nullish(),Schedule:pe.nullish(),PricePolicy:jd.nullish(),Commission:Fd.nullish(),Tradability:Vd.nullish(),Listings:_d.nullish(),Auctions:Wd.nullish(),BuyOrders:Qd.nullish(),DirectTrades:Kd.nullish(),Matching:Hd.nullish()}).passthrough(),ta=zod.z.object({BidIndex:zod.z.number().nullish(),UserID:zod.z.string().nullish(),Amount:w.nullish(),Settled:zod.z.boolean().nullish(),SettledAt:u.nullish()}).passthrough(),$d=zod.z.object({BidAxisType:Qt.nullish(),BidCurrencyID:zod.z.string().nullish(),BidCatalogID:zod.z.string().nullish(),BidItemID:zod.z.string().nullish(),StartingBid:w.nullish(),CurrentBid:w.nullish(),CurrentBidderID:zod.z.string().nullish(),BidCount:zod.z.number().nullish(),ExtensionCount:zod.z.number().nullish(),PendingRefunds:zod.z.array(ta).nullish()}).passthrough(),Zi=zod.z.object({LastAt:u.nullish(),DailyCount:zod.z.number().nullish(),DailyResetUtc:u.nullish()}).passthrough(),Zd=zod.z.object({Create:Zi.nullish(),Buy:Zi.nullish(),Sell:Zi.nullish(),Bid:Zi.nullish()}).passthrough(),Jd=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),Yd=zod.z.object({ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Quantity:zod.z.number().nullish(),RemainingUses:zod.z.number().nullish(),Level:zod.z.number().nullish(),AcquiredAt:u,ExpiresAt:u.nullish(),EquippedSlot:Jd.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(o=>o),it=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:Ls.nullish(),Status:qs.nullish(),CreatorUserID:zod.z.string().nullish(),CreatorPublicData:be.nullish(),TargetUserID:zod.z.string().nullish(),GoodsType:Es.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:w.nullish(),GoodsInstances:zod.z.array(Yd).nullish(),Price:fe.nullish(),Auction:$d.nullish(),CreatedAt:u.nullish(),ExpiresAt:u.nullish()}).passthrough(),Xd=zod.z.object({GoodsType:Es.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),CountsByType:zod.z.record(Ls,w).nullish(),ListingCount:w.nullish(),AuctionCount:w.nullish(),BuyOrderCount:w.nullish()}).passthrough(),ia=zod.z.object({Definitions:Gs.nullish(),IsOpenNow:zod.z.boolean().nullish(),GatePassed:zod.z.boolean().nullish()}).passthrough(),Ns=zod.z.object({Offers:zod.z.array(it).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),ra=zod.z.object({Groups:zod.z.array(Xd).nullish()}).passthrough(),sa=zod.z.object({Offer:it.nullish()}).passthrough(),qe=zod.z.object({OfferID:zod.z.string().nullish(),Status:qs.nullish(),Settlement:dt.nullish(),Resources:b.nullish(),CommissionTaken:fe.nullish()}).passthrough(),Nt=zod.z.object({OfferID:zod.z.string().nullish(),Offer:it.nullish(),Resources:b.nullish(),Matched:zod.z.boolean().nullish(),Settlement:qe.nullish()}).passthrough(),na=zod.z.object({OfferID:zod.z.string().nullish(),CurrentBid:w.nullish(),BidCount:zod.z.number().nullish(),ExpiresAt:u.nullish(),Resources:b.nullish()}).passthrough(),oa=zod.z.object({MyOffers:zod.z.array(it).nullish(),MyLeadingBids:zod.z.array(it).nullish(),MyBuyOrders:zod.z.array(it).nullish(),IncomingTrades:zod.z.array(it).nullish(),OutgoingTrades:zod.z.array(it).nullish(),Claimables:zod.z.array(it).nullish(),DrainedRefunds:zod.z.array(ta).nullish(),Limits:Zd.nullish()}).passthrough(),eh=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:Ls.nullish(),FinalStatus:qs.nullish(),SellerUserID:zod.z.string().nullish(),BuyerUserID:zod.z.string().nullish(),GoodsType:Es.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:w.nullish(),PricePaid:fe.nullish(),CommissionTaken:fe.nullish(),CompletedAt:u.nullish()}).passthrough(),aa=zod.z.object({Entries:zod.z.array(eh).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),ae={GetDefinitions:"GetDefinitions",GetGroupedOffers:"GetGroupedOffers",GetOffersByItem:"GetOffersByItem",GetOffer:"GetOffer",GetBuyOrders:"GetBuyOrders",GetMyState:"GetMyState",GetHistory:"GetHistory",CreateListing:"CreateListing",CancelListing:"CancelListing",Buy:"Buy",MarketBuy:"MarketBuy",MarketSell:"MarketSell",CreateAuction:"CreateAuction",PlaceBid:"PlaceBid",ClaimAuction:"ClaimAuction",CreateBuyOrder:"CreateBuyOrder",CancelBuyOrder:"CancelBuyOrder",FillBuyOrder:"FillBuyOrder",CreateDirectTrade:"CreateDirectTrade",RespondDirectTrade:"RespondDirectTrade",CancelDirectTrade:"CancelDirectTrade",ClaimBack:"ClaimBack"};var th="Marketplace",Yi=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.marketplace.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(th,t.data.Definitions),this.ctx.emitter.emit("marketplace:definitionsLoaded",t.data)),t}async getGroupedOffers(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.marketplace.getGroupedOffers(e);return t.ok&&this.ctx.emitter.emit("marketplace:groupedOffersLoaded",t.data),t}async getOffersByItem(e,t,i,r=20){if(!e)return n("client","ItemID is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.ItemID=e,s.OfferTypeFilter=t,s.ContinuationToken=i,s.PageSize=r;let a=await this.ctx.api.marketplace.getOffersByItem(s);return a.ok&&this.ctx.emitter.emit("marketplace:offersByItemLoaded",a.data),a}async getOffer(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.getOffer(t);return i.ok&&this.ctx.emitter.emit("marketplace:offerLoaded",i.data),i}async getBuyOrders(e,t,i=20){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.ItemID=e,r.ContinuationToken=t,r.PageSize=i;let s=await this.ctx.api.marketplace.getBuyOrders(r);return s.ok&&this.ctx.emitter.emit("marketplace:buyOrdersLoaded",s.data),s}async getMyState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.marketplace.getMyState(e);return t.ok&&(this.ctx.data.user.applyMarketplaceState(t.data.Limits??null),this.ctx.emitter.emit("marketplace:myStateLoaded",t.data)),t}async getHistory(e,t=20){let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.ContinuationToken=e,i.PageSize=t;let r=await this.ctx.api.marketplace.getHistory(i);return r.ok&&this.ctx.emitter.emit("marketplace:historyLoaded",r.data),r}async createListing(e,t,i,r,s,a,p){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");if(!r)return n("client","PriceBundle is required.");let D=this.baseRequest();if(!D)return n("unauthorized","Not logged in.");D.ItemID=e,D.CatalogID=t,D.GoodsAmount=i,D.PriceBundle=r,D.DurationHours=s,D.ItemInstanceIDs=a,D.SelectedOptionID=p;let U=await this.ctx.api.marketplace.createListing(D);return this.applyCreateOfferResult(U,"marketplace:listingCreated"),U}async cancelListing(e){return this.cancelOffer(e,t=>this.ctx.api.marketplace.cancelListing(t),"marketplace:listingCancelled")}async buy(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.buy(t);return i.ok&&(this.applyDualPartySettlement(i.data.Settlement),this.ctx.emitter.emit("marketplace:bought",i.data)),i}async marketBuy(e,t,i){if(!e||e<=0)return n("client","GoodsAmount must be positive.");if(!t)return n("client","PriceBundle is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");let s=this.applyGoodsSelector(r,i);if(s)return s;r.GoodsAmount=e,r.PriceBundle=t;let a=await this.ctx.api.marketplace.marketBuy(r);return a.ok&&(this.applyDualPartySettlement(a.data.Settlement),this.ctx.emitter.emit("marketplace:marketBought",a.data)),a}async marketSell(e,t,i){if(!e||e<=0)return n("client","GoodsAmount must be positive.");if(!t)return n("client","PriceBundle is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");let s=this.applyGoodsSelector(r,i);if(s)return s;r.GoodsAmount=e,r.PriceBundle=t;let a=await this.ctx.api.marketplace.marketSell(r);return a.ok&&(this.applyDualPartySettlement(a.data.Settlement),this.ctx.emitter.emit("marketplace:marketSold",a.data)),a}async createAuction(e,t,i,r,s,a,p={}){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");let D=this.baseRequest();if(!D)return n("unauthorized","Not logged in.");D.ItemID=e,D.CatalogID=t,D.GoodsAmount=i,D.BidAxisType=r,D.BidCurrencyID=p.bidCurrencyID,D.BidCatalogID=p.bidCatalogID,D.BidItemID=p.bidItemID,D.StartingBid=s,D.DurationHours=a,D.ItemInstanceIDs=p.itemInstanceIDs,D.SelectedOptionID=p.selectedOptionID;let U=await this.ctx.api.marketplace.createAuction(D);return this.applyCreateOfferResult(U,"marketplace:auctionCreated"),U}async placeBid(e,t){if(!e)return n("client","OfferID is required.");if(!t||t<=0)return n("client","BidAmount must be positive.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.OfferID=e,i.BidAmount=t;let r=await this.ctx.api.marketplace.placeBid(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:bidPlaced",r.data)),r}async claimAuction(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.claimAuction(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:auctionClaimed",i.data)),i}async createBuyOrder(e,t,i,r,s){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");if(!r)return n("client","PriceBundle is required.");let a=this.baseRequest();if(!a)return n("unauthorized","Not logged in.");a.ItemID=e,a.CatalogID=t,a.GoodsAmount=i,a.PriceBundle=r,a.DurationHours=s;let p=await this.ctx.api.marketplace.createBuyOrder(a);return this.applyCreateOfferResult(p,"marketplace:buyOrderCreated"),p}async cancelBuyOrder(e){return this.cancelOffer(e,t=>this.ctx.api.marketplace.cancelBuyOrder(t),"marketplace:buyOrderCancelled")}async fillBuyOrder(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.fillBuyOrder(t);return i.ok&&(this.applyDualPartySettlement(i.data.Settlement),this.ctx.emitter.emit("marketplace:buyOrderFilled",i.data)),i}async createDirectTrade(e,t,i,r,s){if(!e)return n("client","TargetUserID is required.");if(!t)return n("client","CatalogID is required.");if(!i)return n("client","ItemID is required.");let a=this.baseRequest();if(!a)return n("unauthorized","Not logged in.");a.TargetUserID=e,a.CatalogID=t,a.ItemID=i,a.ItemInstanceIDs=r,a.RequestedBundle=s;let p=await this.ctx.api.marketplace.createDirectTrade(a);return this.applyCreateOfferResult(p,"marketplace:directTradeCreated"),p}async respondDirectTrade(e,t){if(!e)return n("client","OfferID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.OfferID=e,i.Accept=t;let r=await this.ctx.api.marketplace.respondDirectTrade(i);return r.ok&&(t&&(r.data.Settlement?this.applyDualPartySettlement(r.data.Settlement):r.data.Resources&&this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions)),this.ctx.emitter.emit("marketplace:directTradeResponded",r.data)),r}async cancelDirectTrade(e){return this.cancelOffer(e,t=>this.ctx.api.marketplace.cancelDirectTrade(t),"marketplace:directTradeCancelled")}async claimBack(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.claimBack(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:claimedBack",i.data)),i}async cancelOffer(e,t,i){if(!e)return n("client","OfferID is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.OfferID=e;let s=await t(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit(i,s.data)),s}applyCreateOfferResult(e,t){e.ok&&(e.data.Matched&&e.data.Settlement?this.applyDualPartySettlement(e.data.Settlement.Settlement):this.ctx.data.user.applyResourceOperation(e.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit(t,e.data));}applyGoodsSelector(e,t){return "goodsCurrencyID"in t&&t.goodsCurrencyID?(e.GoodsType=Ji.VirtualCurrency,e.GoodsCurrencyID=t.goodsCurrencyID,null):"itemID"in t&&t.itemID&&t.catalogID?(e.GoodsType=Ji.Item,e.ItemID=t.itemID,e.CatalogID=t.catalogID,null):n("client","Either itemID+catalogID or goodsCurrencyID is required.")}applyDualPartySettlement(e){let t=this.ctx.auth.context?.userID;if(!e||!t)return;let i=this.ctx.data.config.itemDefinitions;e.FromUserID===t&&e.FromResult?this.ctx.data.user.applyResourceOperation(e.FromResult,i):e.ToUserID===t&&e.ToResult&&this.ctx.data.user.applyResourceOperation(e.ToResult,i);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Xi=class{constructor(e){this.ctx=e;}ctx;async createRoom(e,t={}){if(!e)return n("client","RoomName is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomName=e,i.Topology=t.topology,i.ChatMode=t.chatMode,i.MaxPlayers=t.maxPlayers,i.Visibility=t.visibility,i.JoinCode=t.joinCode;let r=await this.ctx.api.multiplayer.createRoom(i);return r.ok&&this.ctx.emitter.emit("multiplayer:roomCreated",r.data),r}async joinRoom(e,t){if(!e)return n("client","RoomID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.JoinCode=t;let r=await this.ctx.api.multiplayer.joinRoom(i);return r.ok&&this.ctx.emitter.emit("multiplayer:roomJoined",r.data),r}async leaveRoom(e){if(!e)return n("client","RoomID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.RoomID=e;let i=await this.ctx.api.multiplayer.leaveRoom(t);return i.ok&&this.ctx.emitter.emit("multiplayer:roomLeft",i.data),i}async listRooms(e=0,t=20){let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.Page=e,i.PageSize=t;let r=await this.ctx.api.multiplayer.listRooms(i);return r.ok&&this.ctx.emitter.emit("multiplayer:roomsListed",r.data),r}async getRoom(e){if(!e)return n("client","RoomID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.RoomID=e;let i=await this.ctx.api.multiplayer.getRoom(t);return i.ok&&this.ctx.emitter.emit("multiplayer:roomLoaded",i.data),i}async closeRoom(e){if(!e)return n("client","RoomID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.RoomID=e;let i=await this.ctx.api.multiplayer.closeRoom(t);return i.ok&&this.ctx.emitter.emit("multiplayer:roomClosed",i.data),i}async poll(e,t){if(!e)return n("client","RoomID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.LastSeq=t;let r=await this.ctx.api.multiplayer.poll(i);return r.ok&&this.ctx.emitter.emit("multiplayer:polled",r.data),r}async sendSignal(e,t,i,r){if(!e)return n("client","RoomID is required.");if(!t)return n("client","TargetUserID is required.");if(!i)return n("client","SignalKind is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomID=e,s.TargetUserID=t,s.SignalKind=i,s.Payload=r;let a=await this.ctx.api.multiplayer.sendSignal(s);return a.ok&&this.ctx.emitter.emit("multiplayer:signalSent",a.data),a}async sendChat(e,t){if(!e)return n("client","RoomID is required.");if(!t)return n("client","ChatText is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.ChatText=t;let r=await this.ctx.api.multiplayer.sendChat(i);return r.ok&&this.ctx.emitter.emit("multiplayer:chatSent",r.data),r}async setMemberState(e,t,i){if(!e)return n("client","RoomID is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.RoomID=e,r.Ready=t,r.MemberState=i;let s=await this.ctx.api.multiplayer.setMemberState(r);return s.ok&&this.ctx.emitter.emit("multiplayer:memberStateSet",s.data),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var la=zod.z.object({PlatformUserID:zod.z.string().nullish(),PlatformAuthToken:zod.z.string().nullish(),PlatformAuthTokenExpiration:u.nullish(),TitleUserID:zod.z.string(),TitleClientSessionTicket:zod.z.string(),TitleClientSessionTicketExpiration:u}),ze=zod.z.object({IsCompleted:zod.z.boolean().nullish(),ServerTime:u.nullish()}),ua=zod.z.object({Message:zod.z.string(),ExpiresAt:u}),Oe={LoginWithDeviceID:"LoginWithDeviceID",LoginWithTelegram:"LoginWithTelegram",LoginWithEmail:"LoginWithEmail",LoginWithGoogle:"LoginWithGoogle",LoginWithPlatformToken:"LoginWithPlatformToken",LoginWithSsoCode:"LoginWithSsoCode",RegisterWithEmail:"RegisterWithEmail",RequestWalletChallenge:"RequestWalletChallenge",LoginWithWallet:"LoginWithWallet",ForgotPassword:"ForgotPassword",ResetPassword:"ResetPassword"};function O(o,e,t,i){let s=`api/v2/${o&&o.length>0?o:"0"}/Client/${e}/${t}`;return i==null?s:`${s}/${i}`}var er=class{constructor(e){this.ctx=e;}ctx;endpoint(e){return O(this.ctx.settings.titleID,"Authentication",e)}login(e,t){return this.ctx.transport.post(this.endpoint(e),t,la,{ticket:null})}loginWithDeviceID(e){return this.login(Oe.LoginWithDeviceID,e)}loginWithTelegram(e){return this.login(Oe.LoginWithTelegram,e)}loginWithEmail(e){return this.login(Oe.LoginWithEmail,e)}loginWithGoogle(e){return this.login(Oe.LoginWithGoogle,e)}loginWithPlatformToken(e){return this.login(Oe.LoginWithPlatformToken,e)}loginWithSsoCode(e){return this.login(Oe.LoginWithSsoCode,e)}registerWithEmail(e){return this.login(Oe.RegisterWithEmail,e)}requestWalletChallenge(e){return this.ctx.transport.post(this.endpoint(Oe.RequestWalletChallenge),e,ua,{ticket:null})}loginWithWallet(e){return this.login(Oe.LoginWithWallet,e)}forgotPassword(e){return this.ctx.transport.post(this.endpoint(Oe.ForgotPassword),e,ze,{ticket:null})}resetPassword(e){return this.ctx.transport.post(this.endpoint(Oe.ResetPassword),e,ze,{ticket:null})}};var ih={ReturnKey:"ReturnKey",ReturnMarkedKey:"ReturnMarkedKey",ReturnEmpty:"ReturnEmpty"},ca=zod.z.enum(["ReturnKey","ReturnMarkedKey","ReturnEmpty"]),rh=zod.z.object({Locale:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Order:zod.z.number().nullish()}).passthrough(),pa=zod.z.object({IsEnabled:zod.z.boolean().nullish(),DefaultLocale:zod.z.string().nullish(),Locales:zod.z.record(zod.z.string(),rh).nullish(),MissingKeyMode:ca.nullish(),MaxEntriesPerLocale:zod.z.number().nullish(),MaxValueLengthBytes:zod.z.number().nullish()}).passthrough(),sh=zod.z.object({Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),Url:zod.z.string().nullish()}).passthrough(),da=zod.z.object({Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),Url:zod.z.string().nullish(),Fallback:sh.nullish()}).passthrough(),tr={GetLocalizationManifest:"GetLocalizationManifest",GetLocalizationTable:"GetLocalizationTable"},nh=zod.z.object({Locale:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Order:zod.z.number().nullish(),Version:zod.z.number().nullish()}).passthrough(),ha=zod.z.object({IsEnabled:zod.z.boolean().nullish(),DefaultLocale:zod.z.string().nullish(),MissingKeyMode:ca.nullish(),ResolvedLocale:zod.z.string().nullish(),Locales:zod.z.array(nh).nullish()}).passthrough(),ma=zod.z.object({RequestedLocale:zod.z.string().nullish(),Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),NotModified:zod.z.boolean().nullish(),Entries:zod.z.record(zod.z.string(),zod.z.string()).nullish(),FallbackLocale:zod.z.string().nullish(),FallbackVersion:zod.z.number().nullish()}).passthrough();var js=zod.z.object({TitleConfigVersion:zod.z.string().nullish(),TitleConfigUrl:zod.z.string().nullish(),User:zod.z.unknown().nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish(),StateEpoch:zod.z.string().nullish(),Localization:da.nullish()}).passthrough().transform(o=>o),fa=zod.z.object({StateEpoch:zod.z.string().nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough().transform(o=>o),ga=zod.z.object({StateEpoch:zod.z.string().nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish(),User:zod.z.unknown().nullish()}).passthrough().transform(o=>o),Ra=zod.z.object({}).passthrough().transform(o=>o),ya=zod.z.object({}).passthrough().transform(o=>o),Ca=zod.z.object({Today:zod.z.number(),Yesterday:zod.z.number(),CurrentWeek:zod.z.number(),CurrentMonth:zod.z.number(),Total:zod.z.number(),TotalSessions:zod.z.number(),FirstActiveAt:u.nullish(),LastActiveAt:u.nullish(),LongestSessionEverSeconds:zod.z.number().nullish(),CurrentWeekActiveHoursMask:zod.z.number().nullish(),CurrentMonthActiveHoursMask:zod.z.number().nullish(),ReactivationCount:zod.z.number().nullish(),History:zod.z.record(zod.z.string(),zod.z.unknown()).nullish()}).passthrough(),Sa=zod.z.object({Username:zod.z.string()}),Ee={GetClientState:"GetClientState",GetClientStateExcept:"GetClientStateExcept",GetStateVersions:"GetStateVersions",GetUserState:"GetUserState",GetInventory:"GetInventory",GetEventTokens:"GetEventTokens",GetUsageTime:"GetUsageTime",AddUsageTime:"AddUsageTime",DeleteUserAccount:"DeleteUserAccount",ChangeUsername:"ChangeUsername"};var ir=class{constructor(e){this.ctx=e;}ctx;endpoint(e,t){return O(this.ctx.settings.titleID,"User",e,t??"")}getClientState(e){return this.ctx.transport.post(this.endpoint(Ee.GetClientState,e.UserID),e,js,{ticket:e.ClientSessionTicket})}getClientStateExcept(e){return this.ctx.transport.post(this.endpoint(Ee.GetClientStateExcept,e.UserID),e,js,{ticket:e.ClientSessionTicket})}getStateVersions(e){return this.ctx.transport.post(this.endpoint(Ee.GetStateVersions,e.UserID),e,fa,{ticket:e.ClientSessionTicket})}getUserState(e){return this.ctx.transport.post(this.endpoint(Ee.GetUserState,e.UserID),e,ga,{ticket:e.ClientSessionTicket})}getInventory(e){return this.ctx.transport.post(this.endpoint(Ee.GetInventory,e.UserID),e,Ra,{ticket:e.ClientSessionTicket})}getEventTokens(e){return this.ctx.transport.post(this.endpoint(Ee.GetEventTokens,e.UserID),e,ya,{ticket:e.ClientSessionTicket})}getUsageTime(e){return this.ctx.transport.post(this.endpoint(Ee.GetUsageTime,e.UserID),e,Ca,{ticket:e.ClientSessionTicket})}addUsageTime(e){return this.ctx.transport.post(this.endpoint(Ee.AddUsageTime,e.UserID),e,ze,{ticket:e.ClientSessionTicket,silent:true})}deleteUserAccount(e){return this.ctx.transport.post(this.endpoint(Ee.DeleteUserAccount,e.UserID),e,ze,{ticket:e.ClientSessionTicket})}changeUsername(e){return this.ctx.transport.post(this.endpoint(Ee.ChangeUsername,e.UserID),e,Sa,{ticket:e.ClientSessionTicket})}};var rr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Currency",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}convert(e){return this.send(Vi.Convert,e,uo)}cryptoConvert(e){return this.send(Vi.CryptoConvert,e,co)}};var oh=zod.z.object({ItemInstanceID:zod.z.string(),Units:zod.z.number(),Level:zod.z.number()}),Fs=zod.z.object({ServerTimeUtc:u,ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Level:zod.z.number(),Resources:b.nullish(),FodderConsumed:zod.z.array(oh).nullish()}),xa=zod.z.array(re(Fs)),sr={UpgradeLevel:"UpgradeLevel",UpgradeLevelsBatch:"UpgradeLevelsBatch"},ah={FlatCount:"FlatCount",Merge:"Merge",InvestmentRefund:"InvestmentRefund"},lh=zod.z.enum(["FlatCount","Merge","InvestmentRefund"]),uh={ProtectLeveled:"ProtectLeveled",CheapestFirst:"CheapestFirst",ClientSelected:"ClientSelected"},ch=zod.z.enum(["ProtectLeveled","CheapestFirst","ClientSelected"]),ph=zod.z.object({ContractAddress:zod.z.string().nullish(),TokenID:zod.z.string().nullish(),TokenStandard:zod.z.string().nullish()}).passthrough(),dh=zod.z.object({Networks:zod.z.record(zod.z.string(),ph).nullish(),MetadataUrl:zod.z.string().nullish()}).passthrough(),hh=zod.z.object({FlatBonuses:zod.z.record(zod.z.string(),zod.z.number()).nullish(),PercentBonuses:zod.z.record(zod.z.string(),zod.z.number()).nullish(),Power:zod.z.number().nullish()}).passthrough(),mh=zod.z.object({MinCharacterLevel:zod.z.number().nullish(),UseRequirements:zod.z.record(zod.z.string(),zod.z.number()).nullish(),AllowedCharacterIDs:zod.z.array(zod.z.string()).nullish(),AllowedSlotIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),fh=zod.z.object({ValuationMode:lh.nullish(),MergeRatio:zod.z.number().nullish(),Selection:ch.nullish()}).passthrough(),gh=zod.z.object({MaxLevel:zod.z.number().nullish(),PriceOptions:Y.nullish(),CostScalingFactor:zod.z.number().nullish(),FlatScalingFactor:zod.z.number().nullish(),PercentScalingFactor:zod.z.number().nullish(),PowerScalingFactor:zod.z.number().nullish(),Fodder:fh.nullish()}).passthrough(),Rh=zod.z.object({RarityID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),AuthorID:zod.z.string().nullish()}).passthrough(),yh=zod.z.object({ItemID:zod.z.string(),CatalogID:zod.z.string(),ItemClass:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Tags:zod.z.array(zod.z.string()).nullish(),CustomData:zod.z.string().nullish(),IsStackable:zod.z.boolean().nullish(),IsTradable:zod.z.boolean().nullish(),Weight:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),NFT:dh.nullish(),Stats:hh.nullish(),Equipment:mh.nullish(),Upgrade:gh.nullish(),Metadata:Rh.nullish(),ExpirationDurationSeconds:zod.z.number().nullish()}).passthrough(),Ch=zod.z.object({Items:zod.z.record(zod.z.string(),yh).nullish()}).passthrough(),nr=zod.z.object({Catalogs:zod.z.record(zod.z.string(),Ch).nullish()}).passthrough();var or=class{constructor(e){this.ctx=e;}ctx;upgradeLevel(e){let t=O(this.ctx.settings.titleID,"Item",sr.UpgradeLevel,e.UserID??"");return this.ctx.transport.post(t,e,Fs,{ticket:e.ClientSessionTicket})}upgradeLevelsBatch(e){let t=O(this.ctx.settings.titleID,"Item",sr.UpgradeLevelsBatch,e.UserID??"");return this.ctx.transport.post(t,e,xa,{ticket:e.ClientSessionTicket})}};var Vs=zod.z.object({ServerTimeUtc:u,OfferID:zod.z.string(),Count:zod.z.number(),Resources:b.nullish()}),Da=zod.z.array(re(Vs)),Sh=zod.z.object({OfferID:zod.z.string(),TotalPurchases:zod.z.number(),DailyPurchases:zod.z.number(),DailyResetUtc:u,LastPurchasedAt:u}),ba=zod.z.object({Purchases:zod.z.record(zod.z.string(),Sh).nullish()}).passthrough().transform(o=>o),xh=zod.z.object({StartUtc:u.nullish(),EndUtc:u.nullish(),RequiredFlags:zod.z.array(zod.z.string()).nullish()}).passthrough(),Dh=zod.z.object({StoreID:zod.z.string(),Type:zod.z.string().nullish(),Name:zod.z.string().nullish(),Description:zod.z.string().nullish(),Rules:xh.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),bh=zod.z.object({StartUtc:u.nullish(),EndUtc:u.nullish(),Gate:_.nullish(),Limits:ge.nullish()}).passthrough(),zh=zod.z.object({OfferID:zod.z.string(),StoreIDs:zod.z.array(zod.z.string()).nullish(),Name:zod.z.string().nullish(),PriceOptions:Y.nullish(),Rewards:L.nullish(),Rules:bh.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),ar=zod.z.object({Stores:zod.z.record(zod.z.string(),Dh).nullish(),StoreOffers:zod.z.record(zod.z.string(),zh).nullish()}).passthrough(),kt={Purchase:"Purchase",GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",PurchaseBatch:"PurchaseBatch"};var lr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Store",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}purchase(e){return this.send(kt.Purchase,e,Vs)}purchaseBatch(e){return this.send(kt.PurchaseBatch,e,Da)}getDefinitions(e){return this.send(kt.GetDefinitions,e,ar)}getUserState(e){return this.send(kt.GetUserState,e,ba)}};var Th={Consumable:"Consumable",NonConsumable:"NonConsumable",Subscription:"Subscription"},vh=zod.z.enum(["Consumable","NonConsumable","Subscription"]),Ph=zod.z.object({StartUtc:u.nullish(),EndUtc:u.nullish(),Gate:_.nullish(),Limits:ge.nullish()}).passthrough(),Ih=zod.z.object({ProductID:zod.z.string().nullish(),Name:zod.z.string().nullish(),Type:vh.nullish(),Enabled:zod.z.boolean().nullish(),StoreProductIDs:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rewards:L.nullish(),PriceUsdCents:zod.z.number().nullish(),Rules:Ph.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),za=zod.z.object({Enabled:zod.z.boolean().nullish(),Products:zod.z.record(zod.z.string(),Ih).nullish()}).passthrough(),Ta=zod.z.object({ProductID:zod.z.string().nullish(),TotalPurchases:zod.z.number().nullish(),DailyPurchases:zod.z.number().nullish(),DailyResetUtc:u.nullish(),LastPurchasedAt:u.nullish(),Owned:zod.z.boolean().nullish()}).passthrough(),va=zod.z.object({Products:zod.z.record(zod.z.string(),Ta).nullish(),LifetimeSpendUsdCents:zod.z.number().nullish()}).passthrough(),kh={Granted:"Granted",Restored:"Restored",AlreadyProcessed:"AlreadyProcessed"},Mh=zod.z.enum(["Granted","Restored","AlreadyProcessed"]),_s=zod.z.object({ServerTimeUtc:u,Store:Ht.nullish(),ProductID:zod.z.string().nullish(),TransactionID:zod.z.string().nullish(),Status:Mh.nullish(),Granted:zod.z.boolean().nullish(),Quantity:zod.z.number().nullish(),Resources:b.nullish(),ProductState:Ta.nullish()}).passthrough(),Pa=$e(_s),Mt={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ValidatePurchase:"ValidatePurchase",ValidatePurchasesBatch:"ValidatePurchasesBatch"};var ur=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Purchase",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Mt.GetDefinitions,e,za)}getUserState(e){return this.send(Mt.GetUserState,e,va)}validatePurchase(e){return this.send(Mt.ValidatePurchase,e,_s)}validatePurchasesBatch(e){return this.send(Mt.ValidatePurchasesBatch,e,Pa)}};var wh=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),Ia=zod.z.object({Reward:L.nullish(),Weight:zod.z.number().nullish(),AmountRange:wh.nullish()}).passthrough(),wt=zod.z.object({SlotID:zod.z.string().nullish(),MinRolls:zod.z.number().nullish(),MaxRolls:zod.z.number().nullish(),Pool:zod.z.array(Ia).nullish()}).passthrough(),Ot=zod.z.object({RuleID:zod.z.string().nullish(),Threshold:zod.z.number().nullish(),Pool:zod.z.array(Ia).nullish()}).passthrough(),Oh=zod.z.object({RewardSlots:zod.z.array(wt).nullish()}).passthrough(),Ah=zod.z.object({PityRules:zod.z.array(Ot).nullish()}).passthrough(),cr=zod.z.object({SlotPresets:zod.z.record(zod.z.string(),Oh).nullish(),PityPresets:zod.z.record(zod.z.string(),Ah).nullish()}).passthrough();var Uh=zod.z.object({RuleID:zod.z.string(),BoxIndex:zod.z.number().nullish()}),ka=zod.z.object({ServerTimeUtc:u,LootboxID:zod.z.string(),OpenedCount:zod.z.number().nullish(),SelectedOptionID:zod.z.string().nullish(),Resources:b.nullish(),Inventory:ut.nullish(),Results:zod.z.array(b).nullish(),TriggeredPity:zod.z.array(Uh).nullish()}),Bh=zod.z.object({RewardSlots:X.nullish(),PityRules:X.nullish()}).passthrough(),Lh=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),MaxDrops:w.nullish()}).passthrough(),qh=zod.z.object({LootboxID:zod.z.string(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),PriceOptions:Y.nullish(),RewardSlots:zod.z.array(wt).nullish(),PityRules:zod.z.array(Ot).nullish(),Presets:Bh.nullish(),RewardMultiplier:Zt.nullish(),SupplyLimits:zod.z.array(Lh).nullish(),MaxOpenCount:zod.z.number().nullish()}).passthrough(),Ws=zod.z.object({Definitions:zod.z.record(zod.z.string(),qh).nullish(),RewardPools:cr.nullish()}).passthrough(),Ma=zod.z.object({LootboxDefinitions:Ws.nullish()}),pr={GetDefinitions:"GetDefinitions",Open:"Open"};var dr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Lootbox",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(pr.GetDefinitions,e,Ma)}open(e){return this.send(pr.Open,e,ka)}};var Eh=zod.z.object({}).passthrough().transform(o=>o),Gh=zod.z.object({}).passthrough().transform(o=>o),Nh=zod.z.object({}).passthrough().transform(o=>o),jh=zod.z.object({}).passthrough().transform(o=>o),Fh=zod.z.object({}).passthrough().transform(o=>o),wa=zod.z.object({ServerTimeUtc:u,CalendarID:zod.z.string(),DayNumber:zod.z.number().nullish(),DailyState:Eh,Resources:b.nullish()}),Oa=zod.z.object({ServerTimeUtc:u,AccrualID:zod.z.string(),AccruedSeconds:w.nullish(),AppliedRatePerSecond:zod.z.number().nullish(),IdleState:Gh,Resources:b.nullish()}),Aa=zod.z.object({ServerTimeUtc:u,ComebackID:zod.z.string(),ClaimedTierIndex:zod.z.number().nullish(),ComebackState:Nh,Resources:b.nullish()}),Ua=zod.z.object({ServerTimeUtc:u,ClaimID:zod.z.string(),ClaimState:jh,Resources:b.nullish()}),Ba=zod.z.object({Enabled:zod.z.boolean(),Multiplier:zod.z.number().nullish(),Progress:w.nullish(),Source:zod.z.string().nullish(),SourceKey:zod.z.string().nullish()}),Vh=zod.z.object({RewardMode:zod.z.string().nullish(),RewardStackLowerTiers:zod.z.boolean().nullish()}).passthrough(),_h=zod.z.object({DayNumber:zod.z.number().nullish(),Rewards:L.nullish(),IsMilestone:zod.z.boolean().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Wh=zod.z.object({CalendarID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Days:zod.z.array(_h).nullish(),IsLooping:zod.z.boolean().nullish(),MissBehavior:zod.z.string().nullish(),ResetByDays:zod.z.number().nullish(),MissThresholdMultiplier:zod.z.number().nullish(),ClaimMode:zod.z.string().nullish(),ClaimCooldownSeconds:zod.z.number().nullish(),Gate:_.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Qh=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),Kh=zod.z.object({BaseRatePerSecond:zod.z.number().nullish(),PowerCoefficient:zod.z.number().nullish(),BoardRankCoefficient:zod.z.number().nullish(),EquipmentBonusEnabled:zod.z.boolean().nullish(),EquipmentCharacterID:zod.z.string().nullish(),PremiumMultipliers:zod.z.array(Qh).nullish()}).passthrough(),Hh=zod.z.object({MinCharacterLevel:zod.z.number().nullish(),RequirementsCharacterID:zod.z.string().nullish(),Gate:_.nullish(),RequiredItemIDs:zod.z.array(zod.z.string()).nullish(),RequiredEquippedItemIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),$h=zod.z.object({AccrualID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rate:Kh.nullish(),Rewards:L.nullish(),MaxAccumulationSeconds:zod.z.number().nullish(),MinClaimSeconds:zod.z.number().nullish(),Requirements:Hh.nullish(),FirstClaimMode:zod.z.string().nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Zh=zod.z.object({MinAbsenceSeconds:zod.z.number().nullish(),Rewards:L.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Jh=zod.z.object({ComebackID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Tiers:zod.z.array(Zh).nullish(),ClaimCooldownSeconds:zod.z.number().nullish(),ClaimWindowSeconds:zod.z.number().nullish(),TrackPresenceOnRead:zod.z.boolean().nullish(),Gate:_.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Yh=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),CooldownSeconds:zod.z.number().nullish(),MaxClaimsPerWindow:zod.z.number().nullish(),WindowSeconds:zod.z.number().nullish(),TotalClaimLimit:zod.z.number().nullish()}).passthrough(),Xh=zod.z.object({ClaimID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Mode:zod.z.string().nullish(),Rewards:L.nullish(),Limits:ge.nullish(),PremiumLimitOverrides:zod.z.array(Yh).nullish(),Gate:_.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Qs=zod.z.object({TierRewards:Vh.nullish(),MilestoneRewardMultiplier:Zt.nullish(),DailyCalendars:zod.z.record(zod.z.string(),Wh).nullish(),IdleAccruals:zod.z.record(zod.z.string(),$h).nullish(),Comebacks:zod.z.record(zod.z.string(),Jh).nullish(),Claims:zod.z.record(zod.z.string(),Xh).nullish()}).passthrough(),La=zod.z.object({RewardDefinitions:Qs.nullish()}),qa=zod.z.object({Rewards:Fh.nullish()}),st={GetRewardDefinitions:"GetRewardDefinitions",GetUserRewardsState:"GetUserRewardsState",ClaimDailyReward:"ClaimDailyReward",CollectIdleAccrual:"CollectIdleAccrual",ClaimComebackReward:"ClaimComebackReward",ClaimReward:"ClaimReward",ClaimRewardsBatch:"ClaimRewardsBatch",GetMilestoneRewardMultiplier:"GetMilestoneRewardMultiplier"};var hr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Reward",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getRewardDefinitions(e){return this.send(st.GetRewardDefinitions,e,La)}getUserRewardsState(e){return this.send(st.GetUserRewardsState,e,qa)}getMilestoneRewardMultiplier(e){return this.send(st.GetMilestoneRewardMultiplier,e,Ba)}claimDailyReward(e){return this.send(st.ClaimDailyReward,e,wa)}collectIdleAccrual(e){return this.send(st.CollectIdleAccrual,e,Oa)}claimComebackReward(e){return this.send(st.ClaimComebackReward,e,Aa)}claimReward(e){return this.send(st.ClaimReward,e,Ua)}};var mr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Tutorial",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getTutorialDefinitions(e){return this.send(Be.GetTutorialDefinitions,e,jn)}getUserTutorialState(e){return this.send(Be.GetUserTutorialState,e,Vn)}startFlow(e){return this.send(Be.StartFlow,e,lt)}reportStepShown(e){return this.send(Be.ReportStepShown,e,lt)}completeStep(e){return this.send(Be.CompleteStep,e,lt)}completeStepsBatch(e){return this.send(Be.CompleteStepsBatch,e,Wn)}skipStep(e){return this.send(Be.SkipStep,e,lt)}skipFlow(e){return this.send(Be.SkipFlow,e,lt)}claimFlowReward(e){return this.send(Be.ClaimFlowReward,e,_n)}resetFlow(e){return this.send(Be.ResetFlow,e,lt)}};var fr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Localization",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket,throttleKey:t.Locale?`${r}:${t.Locale}`:r})}getLocalizationManifest(e){return this.send(tr.GetLocalizationManifest,e,ha)}getLocalizationTable(e){return this.send(tr.GetLocalizationTable,e,ma)}};var gr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Quest",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getQuestDefinitions(e){return this.send(Ve.GetQuestDefinitions,e,Yt)}getUserQuestState(e){return this.send(Ve.GetUserQuestState,e,kn)}refreshQuestCycles(e){return this.send(Ve.RefreshQuestCycles,e,ze)}claimQuestReward(e){return this.send(Ve.ClaimQuestReward,e,ls)}claimQuestRewardsBatch(e){return this.send(Ve.ClaimQuestRewardsBatch,e,On)}claimMilestoneReward(e){return this.send(Ve.ClaimMilestoneReward,e,us)}claimMilestoneRewardsBatch(e){return this.send(Ve.ClaimMilestoneRewardsBatch,e,An)}claimGroupCompletionReward(e){return this.send(Ve.ClaimGroupCompletionReward,e,Mn)}addQuestProgress(e){return this.send(Ve.AddQuestProgress,e,wn)}};var Ea=zod.z.object({}).passthrough().transform(o=>o);var em=zod.z.object({Order:zod.z.number().nullish(),Type:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),BonusMultiplier:zod.z.number().nullish()}).passthrough(),tm=zod.z.object({Schedule:zod.z.array(em).nullish(),RepeatCycle:zod.z.boolean().nullish(),MaxCycles:zod.z.number().nullish()}).passthrough(),im=zod.z.object({IsActive:zod.z.boolean().nullish(),CurrentPhaseEndUtc:u.nullish(),NextBonusStartUtc:u.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentPhaseIndex:zod.z.number().nullish(),ActiveBonusMultiplier:zod.z.number().nullish()}).passthrough(),rm=zod.z.object({Milestones:X.nullish()}).passthrough(),Ks=zod.z.object({DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Category:zod.z.string().nullish(),Token:ht.nullish(),TokenSources:zod.z.array(Ue).nullish(),ClaimMode:zod.z.string().nullish(),Milestones:zod.z.record(zod.z.string(),De).nullish(),Presets:rm.nullish(),BonusWindow:tm.nullish()}).passthrough(),sm=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Content:Ks.nullish(),ClaimGraceHours:zod.z.number().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),nm=zod.z.object({TimedEventID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Schedule:pe.nullish(),Content:Ks.nullish(),Events:zod.z.array(sm).nullish(),Gate:_.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),om=zod.z.object({MaxConcurrentEvents:zod.z.number().nullish()}).passthrough(),am=zod.z.object({Milestones:zod.z.record(zod.z.string(),at).nullish()}).passthrough(),Rr=zod.z.object({Definitions:zod.z.record(zod.z.string(),nm).nullish(),Settings:om.nullish(),Presets:am.nullish()}).passthrough(),lm=zod.z.object({Type:qt,TimedEventID:zod.z.string(),CurrentChainedEventID:zod.z.string().nullish(),Content:Ks.nullish(),Progress:Ea.nullish(),ComputedStartUtc:u.nullish(),ComputedEndUtc:u.nullish(),CanEarn:zod.z.boolean().nullish(),CanClaim:zod.z.boolean().nullish(),NextMilestone:De.nullish(),BonusWindow:im.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentEventOrder:zod.z.number().nullish(),TotalEventsInChain:zod.z.number().nullish()}).passthrough(),Ga=zod.z.object({ActiveEvents:zod.z.array(lm).nullish()}).passthrough(),Na=zod.z.object({Tokens:zod.z.record(zod.z.string(),Ea).nullish()}),Hs=zod.z.object({Type:qt.nullish(),LteID:zod.z.string().nullish(),Resources:b.nullish()}),$s=zod.z.object({Type:qt.nullish(),LteID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Rewards:b.nullish()}),um=zod.z.object({Type:qt.nullish(),LteID:zod.z.string().nullish(),Resources:b.nullish()}),Zs=zod.z.array(re($s)),ja=zod.z.array(re(Hs)),Fa=zod.z.array(re(um)),Ge={GetActiveEvents:"GetActiveEvents",GrantTokens:"GrantTokens",SpendTokens:"SpendTokens",ClaimMilestone:"ClaimMilestone",GetDefinitions:"GetDefinitions",GetUserLteState:"GetUserLteState",ClaimMilestonesBatch:"ClaimMilestonesBatch",ClaimAllMilestones:"ClaimAllMilestones",SpendTokensBatch:"SpendTokensBatch",GrantTokensBatch:"GrantTokensBatch"};var yr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"TimedEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getActiveEvents(e){return this.send(Ge.GetActiveEvents,e,Ga)}getDefinitions(e){return this.send(Ge.GetDefinitions,e,Rr)}getUserLteState(e){return this.send(Ge.GetUserLteState,e,Na)}grantTokens(e){return this.send(Ge.GrantTokens,e,b)}spendTokens(e){return this.send(Ge.SpendTokens,e,Hs)}claimMilestone(e){return this.send(Ge.ClaimMilestone,e,$s)}claimMilestonesBatch(e){return this.send(Ge.ClaimMilestonesBatch,e,Zs)}claimAllMilestones(e){return this.send(Ge.ClaimAllMilestones,e,Zs)}spendTokensBatch(e){return this.send(Ge.SpendTokensBatch,e,ja)}grantTokensBatch(e){return this.send(Ge.GrantTokensBatch,e,Fa)}};var cm=zod.z.object({UserID:zod.z.string(),Score:w.nullish(),Rank:zod.z.number().nullish(),LastScoreUpdateUtc:u.nullish(),IpHash:zod.z.string().nullish(),PublicProfile:be.nullish(),SeasonTierAtCycleEnd:zod.z.number().nullish()}).passthrough(),jt=zod.z.object({LeaderboardID:zod.z.string(),CycleVersion:zod.z.number().nullish(),TotalParticipants:w.nullish(),CycleEndUtc:u.nullish(),TopUsers:zod.z.array(cm).nullish(),BracketID:zod.z.string().nullish()}),pm=zod.z.object({CycleKey:zod.z.string().nullish(),CycleEndUtc:u.nullish(),ClaimDeadlineUtc:u.nullish(),MilestoneTokensEarned:w.nullish(),ClaimableMilestoneIDs:zod.z.array(zod.z.string()).nullish(),CycleIndex:zod.z.number().nullish(),ChainedEventID:zod.z.string().nullish()}).passthrough(),Cr=zod.z.object({LeaderboardID:zod.z.string(),CurrentScore:w.nullish(),LastKnownRank:zod.z.number().nullish(),HasUnclaimedReward:zod.z.boolean().nullish(),ScoreEarnedThisCycle:w.nullish(),MilestoneTokensEarned:w.nullish(),NextMilestone:De.nullish(),HasUnclaimedMilestone:zod.z.boolean().nullish(),ClaimableGraceCycles:zod.z.array(pm).nullish()}),Sr=zod.z.object({LeaderboardID:zod.z.string(),NewScore:w,CycleVersion:zod.z.number()}),xr=zod.z.object({ServerTimeUtc:u,LeaderboardID:zod.z.string(),Rank:zod.z.number().nullish(),Resources:b.nullish()}),Dr=zod.z.object({ServerTimeUtc:u,LeaderboardID:zod.z.string(),MilestoneID:zod.z.string(),Resources:b.nullish()}),Va=zod.z.array(re(jt)),_a=zod.z.array(re(Cr)),Wa=zod.z.array(re(xr)),Qa=zod.z.array(re(Dr)),Ka=zod.z.array(re(Sr)),dm=zod.z.object({LeaderboardID:zod.z.string(),CycleReward:re(xr).nullish(),Milestones:zod.z.array(re(Dr)).nullish()}),Ha=zod.z.array(dm),hm=zod.z.object({LeaderboardID:zod.z.string(),Leaderboard:re(jt).nullish(),Progress:re(Cr).nullish()}),$a=zod.z.array(hm),mm=zod.z.string(),Za=zod.z.object({Rank:zod.z.string().nullish(),Rewards:L.nullish(),SeasonTierRewards:os.nullish()}).passthrough(),fm=zod.z.object({RankRewards:zod.z.array(Za).nullish()}).passthrough(),gm=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Rm=zod.z.object({Milestones:X.nullish(),RankRewards:X.nullish()}).passthrough(),ym=zod.z.object({LeaderboardID:zod.z.string(),DisplayName:zod.z.string().nullish(),ScoreDisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),IsEnabled:zod.z.boolean().nullish(),ScoreAggregation:mm.nullish(),Schedule:pe.nullish(),ChainEvents:zod.z.array(gm).nullish(),Gate:_.nullish(),TopUsersLimit:zod.z.number().nullish(),MinScoreToEnterTop:zod.z.number().nullish(),BracketSize:zod.z.number().nullish(),LinkedSeasonChainID:zod.z.string().nullish(),RankRewards:zod.z.array(Za).nullish(),Milestones:zod.z.record(zod.z.string(),De).nullish(),Presets:Rm.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneClaimGraceHours:zod.z.number().nullish(),ScoreSources:zod.z.array(Ue).nullish()}).passthrough(),Cm=zod.z.object({Milestones:zod.z.record(zod.z.string(),at).nullish(),RankRewards:zod.z.record(zod.z.string(),fm).nullish()}).passthrough(),br=zod.z.object({Definitions:zod.z.record(zod.z.string(),ym).nullish(),Presets:Cm.nullish()}).passthrough(),xe={GetDefinitions:"GetDefinitions",GetLeaderboard:"GetLeaderboard",GetMyProgress:"GetMyProgress",SubmitScore:"SubmitScore",SubmitScoreFromSource:"SubmitScoreFromSource",ClaimCycleReward:"ClaimCycleReward",ClaimMilestone:"ClaimMilestone",GetFriendsLeaderboard:"GetFriendsLeaderboard",GetLeaderboardsBatch:"GetLeaderboardsBatch",GetProgressBatch:"GetProgressBatch",ClaimCycleRewardsBatch:"ClaimCycleRewardsBatch",ClaimMilestonesBatch:"ClaimMilestonesBatch",SubmitScoresBatch:"SubmitScoresBatch",ClaimAllRewardsBatch:"ClaimAllRewardsBatch",GetOverviewBatch:"GetOverviewBatch"};var zr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Leaderboard",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(xe.GetDefinitions,e,br)}getLeaderboard(e){return this.send(xe.GetLeaderboard,e,jt)}getMyProgress(e){return this.send(xe.GetMyProgress,e,Cr)}submitScore(e){return this.send(xe.SubmitScore,e,Sr)}submitScoreFromSource(e){return this.send(xe.SubmitScoreFromSource,e,Sr)}claimCycleReward(e){return this.send(xe.ClaimCycleReward,e,xr)}claimMilestone(e){return this.send(xe.ClaimMilestone,e,Dr)}getFriendsLeaderboard(e){return this.send(xe.GetFriendsLeaderboard,e,jt)}getLeaderboardsBatch(e){return this.send(xe.GetLeaderboardsBatch,e,Va)}getProgressBatch(e){return this.send(xe.GetProgressBatch,e,_a)}claimCycleRewardsBatch(e){return this.send(xe.ClaimCycleRewardsBatch,e,Wa)}claimMilestonesBatch(e){return this.send(xe.ClaimMilestonesBatch,e,Qa)}submitScoresBatch(e){return this.send(xe.SubmitScoresBatch,e,Ka)}claimAllRewardsBatch(e){return this.send(xe.ClaimAllRewardsBatch,e,Ha)}getOverviewBatch(e){return this.send(xe.GetOverviewBatch,e,$a)}};var Js=zod.z.object({}).passthrough().transform(o=>o),Ja=zod.z.object({SeasonChainID:zod.z.string(),CycleIndex:zod.z.number().nullish(),Season:zod.z.lazy(()=>tl).nullish(),ComputedStartUtc:u.nullish(),ComputedEndUtc:u.nullish(),SecondsRemaining:w.nullish(),UserState:Js.nullish(),NextTier:zod.z.lazy(()=>el).nullish()}).passthrough(),Ya=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),AmountGranted:w.nullish(),NewStatusTokens:w.nullish(),OldTier:zod.z.number().nullish(),NewTier:zod.z.number(),TierUp:zod.z.boolean().nullish()}),Ys=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),TierNumber:zod.z.number(),Resources:b.nullish()}),Xa=$e(Ys);var el=zod.z.object({Tier:zod.z.number().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),RequiredTokens:w.nullish(),TierReachedReward:L.nullish()}).passthrough(),tl=zod.z.object({SeasonID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:w.nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Tiers:zod.z.array(el).nullish(),LinkedCollectionID:zod.z.string().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough();var Sm=zod.z.object({SeasonChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:pe.nullish(),Seasons:zod.z.array(tl).nullish(),GrantTokensAccessMode:zod.z.string().nullish(),Gate:_.nullish()}).passthrough(),Tr=zod.z.object({Chains:zod.z.record(zod.z.string(),Sm).nullish()}).passthrough(),pt={GetDefinitions:"GetDefinitions",GetActiveSeason:"GetActiveSeason",GetUserState:"GetUserState",GrantStatusTokens:"GrantStatusTokens",ClaimTierReward:"ClaimTierReward",ClaimTierRewardsBatch:"ClaimTierRewardsBatch"};var vr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Season",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(pt.GetDefinitions,e,Tr)}getActiveSeason(e){return this.send(pt.GetActiveSeason,e,Ja)}getUserState(e){return this.send(pt.GetUserState,e,Js)}grantStatusTokens(e){return this.send(pt.GrantStatusTokens,e,Ya)}claimTierReward(e){return this.send(pt.ClaimTierReward,e,Ys)}claimTierRewardsBatch(e){return this.send(pt.ClaimTierRewardsBatch,e,Xa)}};var xm={Apple:"Apple",Google:"Google"},il=zod.z.object({}).passthrough().transform(o=>o),Dm=zod.z.object({PremiumID:zod.z.string().nullish(),PurchaseDate:zod.z.string().nullish(),ExpirationDate:zod.z.string().nullish(),TransactionID:zod.z.string().nullish(),IsAutoRenewEnabled:zod.z.boolean().nullish()}).passthrough(),bm=zod.z.object({PremiumID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Tier:zod.z.number().nullish(),DurationDays:zod.z.number().nullish(),TrialDurationDays:zod.z.number().nullish(),PriceOptions:Y.nullish(),AppleProductID:zod.z.string().nullish(),GoogleProductID:zod.z.string().nullish(),Benefits:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Xs=zod.z.object({Definitions:zod.z.record(zod.z.string(),bm).nullish()}).passthrough(),rl=zod.z.object({Premium:Xs.nullish()}),sl=zod.z.object({ServerTimeUtc:u.nullish(),Premium:il.nullish()}),Pr=zod.z.object({ServerTimeUtc:u.nullish(),Premium:il.nullish(),Subscription:Dm.nullish(),Resources:b.nullish()}),ft={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateTrial:"ActivateTrial",PurchaseWithResources:"PurchaseWithResources",PurchaseRealMoney:"PurchaseRealMoney"};var Ir=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Premium",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(ft.GetDefinitions,e,rl)}getUserState(e){return this.send(ft.GetUserState,e,sl)}activateTrial(e){return this.send(ft.ActivateTrial,e,Pr)}purchaseItemOrCurrency(e){return this.send(ft.PurchaseWithResources,e,Pr)}purchaseRealMoney(e){return this.send(ft.PurchaseRealMoney,e,Pr)}};var kr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Character",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getCharacterDefinitions(e){return this.send(Me.GetCharacterDefinitions,e,Wi)}getUserCharacters(e){return this.send(Me.GetUserCharacters,e,Ro)}unlockCharacter(e){return this.send(Me.UnlockCharacter,e,vs)}upgradeStatLevel(e){return this.send(Me.UpgradeStatLevel,e,zs)}upgradeCharacterLevel(e){return this.send(Me.UpgradeCharacterLevel,e,Ts)}equipItems(e){return this.send(Me.EquipItems,e,yo)}unequipItems(e){return this.send(Me.UnequipItems,e,Co)}unequipAllCharacters(e){return this.send(Me.UnequipAllCharacters,e,So)}unlockCharactersBatch(e){return this.send(Me.UnlockCharactersBatch,e,xo)}upgradeCharacterLevelsBatch(e){return this.send(Me.UpgradeCharacterLevelsBatch,e,Do)}upgradeStatLevelsBatch(e){return this.send(Me.UpgradeStatLevelsBatch,e,bo)}};var Mr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Match",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}createMatch(e){return this.send(Je.CreateMatch,e,Ko)}updateMatch(e){return this.send(Je.UpdateMatch,e,Ho)}cancelMatch(e){return this.send(Je.CancelMatch,e,$o)}instantBattle(e){return this.send(Je.InstantBattle,e,Zo)}saveStrategy(e){return this.send(Je.SaveStrategy,e,ze)}getMyMatches(e){return this.send(Je.GetMyMatches,e,As)}getAvailableMatches(e){return this.send(Je.GetAvailableMatches,e,As)}getDefinitions(e){return this.send(Je.GetDefinitions,e,ea)}};var zm={TradeUpRarity:"TradeUpRarity",TradeUpCollection:"TradeUpCollection"},nl=zod.z.enum(["TradeUpRarity","TradeUpCollection"]),Tm=zod.z.object({Index:zod.z.number().nullish(),BurnedItemIDs:zod.z.array(zod.z.string()).nullish(),RolledCollectionID:zod.z.string().nullish(),UsedCollections:zod.z.record(zod.z.string(),zod.z.number()).nullish(),Output:ns.nullish()}),ol=zod.z.object({ServerTimeUtc:u,Type:nl.nullish(),CraftID:zod.z.string(),CraftedCount:zod.z.number().nullish(),SelectedOptionID:zod.z.string().nullish(),InputRarity:zod.z.string().nullish(),OutputRarity:zod.z.string().nullish(),Resources:b.nullish(),Results:zod.z.array(Tm).nullish()}),vm=zod.z.object({CraftID:zod.z.string().nullish(),Type:nl.nullish(),CatalogID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),InputRarityID:zod.z.string().nullish(),OutputRarityID:zod.z.string().nullish(),RequiredItemCount:zod.z.number().nullish(),PriceOptions:Y.nullish()}).passthrough(),en=zod.z.object({Definitions:zod.z.record(zod.z.string(),vm).nullish()}).passthrough(),al=zod.z.object({ServerTimeUtc:u.nullish(),CraftDefinitions:en.nullish()}),wr={GetDefinitions:"GetDefinitions",Craft:"Craft"};var Or=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Craft",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(wr.GetDefinitions,e,al)}craft(e){return this.send(wr.Craft,e,ol)}};var Pm={Pending:"Pending",Accepted:"Accepted",Declined:"Declined",Cancelled:"Cancelled",Expired:"Expired"},Im=zod.z.enum(["Pending","Accepted","Declined","Cancelled","Expired"]),ll=zod.z.object({}).passthrough().transform(o=>o),At=zod.z.object({CollectibleID:zod.z.string(),Rarity:zod.z.number().nullish(),IsSpecial:zod.z.boolean().nullish(),IsDuplicate:zod.z.boolean().nullish(),CollectionCurrencyConverted:zod.z.number().nullish()}),ul=zod.z.object({GrantedCollectibles:zod.z.array(At).nullish(),DuplicateCollectibles:zod.z.array(At).nullish(),CollectionCurrencyEarned:w.nullish()}),cl=zod.z.object({OpenedCount:zod.z.number().nullish(),Packs:zod.z.array(ul).nullish(),GrantedCollectibles:zod.z.array(At).nullish(),DuplicateCollectibles:zod.z.array(At).nullish(),CollectionCurrencyEarned:w.nullish(),NewCollectionCurrencyBalance:w.nullish(),NewlyCompletedSetIDs:zod.z.array(zod.z.string()).nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:b.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),pl=zod.z.object({OpenedCount:zod.z.number().nullish(),Chests:zod.z.array(ul).nullish(),GrantedCollectibles:zod.z.array(At).nullish(),DuplicateCollectibles:zod.z.array(At).nullish(),CollectionCurrencyEarned:w.nullish(),NewCollectionCurrencyBalance:w.nullish(),Resources:b.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),dl=zod.z.object({GrantedCollectibleID:zod.z.string().nullish(),NewlyCompletedSetID:zod.z.string().nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:b.nullish()}),tn=zod.z.object({SetID:zod.z.string(),Resources:b.nullish()}),hl=zod.z.array(re(tn)),ml=zod.z.object({Resources:b.nullish()}),km=zod.z.object({OfferID:zod.z.string(),TitleID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderPublicData:be.nullish(),OfferedCollectibleID:zod.z.string().nullish(),OfferedCollectibleIsSpecial:zod.z.boolean().nullish(),ReceiverUserID:zod.z.string().nullish(),RequestedCollectibleID:zod.z.string().nullish(),RequestedCollectibleIsSpecial:zod.z.boolean().nullish(),Status:Im.nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),RespondedAtUtc:u.nullish(),DeclineReason:zod.z.string().nullish(),IsSpecialTradeEvent:zod.z.boolean().nullish(),SpecialTradeEventID:zod.z.string().nullish()}).passthrough(),fl=zod.z.object({OfferID:zod.z.string(),ExpiresAtUtc:u.nullish(),Resources:b.nullish()}),gl=zod.z.object({OfferID:zod.z.string(),Resources:b.nullish()}),Rl=zod.z.object({OfferID:zod.z.string(),ReceivedCollectibleID:zod.z.string().nullish(),ReceivedIsSpecial:zod.z.boolean().nullish(),SentCollectibleID:zod.z.string().nullish(),SentCollectibleIsSpecial:zod.z.boolean().nullish(),Transfer:zod.z.unknown().nullish()}),yl=zod.z.object({OfferID:zod.z.string(),Resources:b.nullish()}),rn=zod.z.object({Offers:zod.z.array(km).nullish()}),Mm=zod.z.object({CollectibleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rarity:zod.z.number().nullish(),HasSpecialVersion:zod.z.boolean().nullish(),SortOrder:zod.z.number().nullish()}).passthrough(),wm=zod.z.object({SetID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),SortOrder:zod.z.number().nullish(),Collectibles:zod.z.array(Mm).nullish(),SetCompletionReward:L.nullish()}).passthrough(),Om=zod.z.object({CollectionID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),SeasonChainID:zod.z.string().nullish(),Sets:zod.z.array(wm).nullish(),GrandPrize:L.nullish()}).passthrough(),Cl=zod.z.object({BonusRewardSlots:X.nullish(),PityRules:X.nullish()}).passthrough(),Am=zod.z.object({PackTypeID:zod.z.string().nullish(),PriceOptions:Y.nullish(),BonusRewardSlots:zod.z.array(wt).nullish(),PityRules:zod.z.array(Ot).nullish(),Presets:Cl.nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CollectibleCount:zod.z.number().nullish(),MaxOpenCount:zod.z.number().nullish(),GuaranteedMinRarity:zod.z.number().nullish(),GuaranteeMaxRarity:zod.z.boolean().nullish(),RarityWeights:zod.z.record(zod.z.string(),zod.z.number()).nullish(),ColorTier:zod.z.number().nullish()}).passthrough(),Um=zod.z.object({Rarity:zod.z.number().nullish(),CollectionCurrencyGranted:zod.z.number().nullish()}).passthrough(),Bm=zod.z.object({CollectionChestID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CollectionCurrencyCost:zod.z.number().nullish(),MaxOpenCount:zod.z.number().nullish(),MinCollectibleCount:zod.z.number().nullish(),MaxCollectibleCount:zod.z.number().nullish(),GuaranteedMinRarity:zod.z.number().nullish(),BonusRewardSlots:zod.z.array(wt).nullish(),PityRules:zod.z.array(Ot).nullish(),Presets:Cl.nullish(),Tier:zod.z.number().nullish()}).passthrough(),Lm=zod.z.object({SpecialTradeEventID:zod.z.string().nullish(),StartUtc:u.nullish(),EndUtc:u.nullish(),AllowedSpecialCollectibleIDs:zod.z.array(zod.z.string()).nullish(),SpecialTradeEventDailyTradeLimit:zod.z.number().nullish()}).passthrough(),Ar=zod.z.object({Collections:zod.z.record(zod.z.string(),Om).nullish(),PackTypes:zod.z.record(zod.z.string(),Am).nullish(),CollectionChests:zod.z.array(Bm).nullish(),DuplicateConversions:zod.z.array(Um).nullish(),DailyTradeLimit:zod.z.number().nullish(),CollectibleJokerCatalogID:zod.z.string().nullish(),CollectibleJokerItemID:zod.z.string().nullish(),SpecialTradeEvents:zod.z.array(Lm).nullish(),RewardPools:cr.nullish()}).passthrough(),Te={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",OpenPack:"OpenPack",OpenCollectionChest:"OpenCollectionChest",UseCollectibleJoker:"UseCollectibleJoker",ClaimSetReward:"ClaimSetReward",ClaimSetRewardsBatch:"ClaimSetRewardsBatch",ClaimGrandPrize:"ClaimGrandPrize",SendTradeOffer:"SendTradeOffer",CancelTradeOffer:"CancelTradeOffer",AcceptTradeOffer:"AcceptTradeOffer",DeclineTradeOffer:"DeclineTradeOffer",GetMyTradeOffers:"GetMyTradeOffers",GetIncomingTradeOffers:"GetIncomingTradeOffers"};var Ur=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Collection",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Te.GetDefinitions,e,Ar)}getUserState(e){return this.send(Te.GetUserState,e,ll)}openPack(e){return this.send(Te.OpenPack,e,cl)}openCollectionChest(e){return this.send(Te.OpenCollectionChest,e,pl)}useCollectibleJoker(e){return this.send(Te.UseCollectibleJoker,e,dl)}claimSetReward(e){return this.send(Te.ClaimSetReward,e,tn)}claimSetRewardsBatch(e){return this.send(Te.ClaimSetRewardsBatch,e,hl)}claimGrandPrize(e){return this.send(Te.ClaimGrandPrize,e,ml)}sendTradeOffer(e){return this.send(Te.SendTradeOffer,e,fl)}cancelTradeOffer(e){return this.send(Te.CancelTradeOffer,e,gl)}acceptTradeOffer(e){return this.send(Te.AcceptTradeOffer,e,Rl)}declineTradeOffer(e){return this.send(Te.DeclineTradeOffer,e,yl)}getMyTradeOffers(e){return this.send(Te.GetMyTradeOffers,e,rn)}getIncomingTradeOffers(e){return this.send(Te.GetIncomingTradeOffers,e,rn)}};var qm=zod.z.object({}).passthrough().transform(o=>o),Em={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},Gm={Active:"Active",Left:"Left",Replaced:"Replaced"},Nm=zod.z.object({ObjectIndex:zod.z.number().nullish(),ObjectCompletionRewardClaimed:zod.z.boolean().nullish()}).passthrough(),jm=zod.z.object({UserID:zod.z.string().nullish(),PublicData:be.nullish(),BuildObjectsProgress:Nm.nullish(),IsBot:zod.z.boolean().nullish(),SpinsCount:zod.z.number().nullish(),TokensSpent:zod.z.number().nullish(),MemberStatus:zod.z.string().nullish(),GrandPrizeClaimed:zod.z.boolean().nullish(),JoinedAtUtc:u.nullish(),LeftAtUtc:u.nullish()}).passthrough(),Fm=zod.z.object({Index:zod.z.number().nullish(),OwnerUserID:zod.z.string().nullish(),CurrentProgress:zod.z.number().nullish(),MaxProgress:zod.z.number().nullish(),IsCompleted:zod.z.boolean().nullish()}).passthrough(),Vm=zod.z.object({Objects:zod.z.array(Fm).nullish()}).passthrough(),Sl=zod.z.object({GroupID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CoopChainID:zod.z.string().nullish(),CoopEventID:zod.z.string().nullish(),CycleIndex:zod.z.number().nullish(),Members:zod.z.array(jm).nullish(),BuildObjectsState:Vm.nullish(),Status:zod.z.string().nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),Version:zod.z.number().nullish()}).passthrough(),xl=zod.z.object({CoopChainID:zod.z.string()}).passthrough(),_m=zod.z.string(),sn=zod.z.object({DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Weight:zod.z.number().nullish(),MinProgress:zod.z.number().nullish(),MaxProgress:zod.z.number().nullish()}).passthrough(),Wm=zod.z.object({Index:zod.z.number().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),MaxProgress:zod.z.number().nullish(),CompletionReward:L.nullish()}).passthrough(),Qm=zod.z.object({Objects:zod.z.array(Wm).nullish(),PriceOptions:Y.nullish(),SpinnerTable:zod.z.array(sn).nullish(),MaxSpinsPerCall:zod.z.number().nullish()}).passthrough(),Km=zod.z.object({CoopEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),EventType:_m.nullish(),PartnerCount:zod.z.number().nullish(),MatchmakingTimeoutMinutes:zod.z.number().nullish(),MemberGracePeriodMinutes:zod.z.number().nullish(),BuildObjects:Qm.nullish(),GrandPrize:L.nullish()}).passthrough(),Hm=zod.z.object({CoopChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:pe.nullish(),Events:zod.z.array(Km).nullish(),Gate:_.nullish()}).passthrough(),Dl=zod.z.object({ServerTimeUtc:u.nullish(),UserState:qm.nullish(),ActiveGroup:Sl.nullish()}),nn=zod.z.object({ServerTimeUtc:u.nullish(),Group:Sl.nullish(),SecondsRemaining:w.nullish()}),bl=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Resources:b.nullish(),ObjectIndex:zod.z.number().nullish(),Sector:sn.nullish(),RequestedSpins:zod.z.number().nullish(),SpinsUsed:zod.z.number().nullish(),Sectors:zod.z.array(sn).nullish(),ProgressDelta:zod.z.number().nullish(),NewProgress:w.nullish(),MaxProgress:w.nullish(),ObjectCompleted:zod.z.boolean().nullish(),AllObjectsCompleted:zod.z.boolean().nullish()}),on=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),Resources:b.nullish()}),zl=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),Br=zod.z.object({Chains:zod.z.record(zod.z.string(),Hm).nullish()}).passthrough(),We={GetDefinitions:"GetDefinitions",GetActiveEvent:"GetActiveEvent",GetUserState:"GetUserState",GetGroupState:"GetGroupState",JoinOrCreateGroup:"JoinOrCreateGroup",Spin:"Spin",ClaimObjectReward:"ClaimObjectReward",ClaimGrandPrize:"ClaimGrandPrize",LeaveGroup:"LeaveGroup"};var Lr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"CoopEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(We.GetDefinitions,e,Br)}getActiveEvent(e){return this.send(We.GetActiveEvent,e,xl)}getUserState(e){return this.send(We.GetUserState,e,Dl)}getGroupState(e){return this.send(We.GetGroupState,e,nn)}joinOrCreateGroup(e){return this.send(We.JoinOrCreateGroup,e,nn)}spin(e){return this.send(We.Spin,e,bl)}claimObjectReward(e){return this.send(We.ClaimObjectReward,e,on)}claimGrandPrize(e){return this.send(We.ClaimGrandPrize,e,on)}leaveGroup(e){return this.send(We.LeaveGroup,e,zl)}};var $m={Active:"Active",Exhausted:"Exhausted",Expired:"Expired",Dismissed:"Dismissed"},Zm={Locked:"Locked",Available:"Available",InProgress:"InProgress",Completed:"Completed",Hidden:"Hidden"},Jm=zod.z.object({NodeID:zod.z.string().nullish(),Status:zod.z.string().nullish(),ExecutionCount:zod.z.number().nullish(),UnlockedAtUtc:u.nullish(),CompletedAtUtc:u.nullish(),LastExecutedAtUtc:u.nullish(),NextAvailableAtUtc:u.nullish(),LastExecutionRefID:zod.z.string().nullish()}).passthrough(),Ym=zod.z.object({TrackID:zod.z.string().nullish(),CurrentValue:zod.z.number().nullish(),LastUpdatedUtc:u.nullish()}).passthrough(),Tl=zod.z.object({OfferID:zod.z.string().nullish(),InstanceKey:zod.z.string().nullish(),SourceOfferVersion:zod.z.number().nullish(),Status:zod.z.string().nullish(),ActivatedAtUtc:u.nullish(),ExhaustedAtUtc:u.nullish(),ExpiredAtUtc:u.nullish(),DismissedAtUtc:u.nullish(),ShowCount:zod.z.number().nullish(),LastShownAtUtc:u.nullish(),Nodes:zod.z.record(zod.z.string(),Jm).nullish(),Tracks:zod.z.record(zod.z.string(),Ym).nullish(),SelectedChoiceNodeID:zod.z.string().nullish()}).passthrough(),Xm=zod.z.object({SlotID:zod.z.string().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),ActiveOfferID:zod.z.string().nullish(),ActiveOfferStartedAtUtc:u.nullish(),ActiveOfferExpiresAtUtc:u.nullish(),ActiveOffer:Tl.nullish(),NextCycleStartsAtUtc:u.nullish(),LastUpdatedUtc:u.nullish(),DismissSkipAvailableAtUtc:u.nullish(),LastDismissedAtUtc:u.nullish()}).passthrough(),ef=zod.z.object({TotalExecutions:zod.z.number().nullish(),DailyExecutions:zod.z.number().nullish(),DailyResetUtc:u.nullish()}).passthrough(),tf=zod.z.object({TotalActivations:zod.z.number().nullish(),TotalExhausted:zod.z.number().nullish(),TotalExpired:zod.z.number().nullish(),TotalDismissed:zod.z.number().nullish(),TotalShows:zod.z.number().nullish(),LastShownAtUtc:u.nullish(),LastActivatedAtUtc:u.nullish(),LastExhaustedAtUtc:u.nullish(),NodeCounts:zod.z.record(zod.z.string(),ef).nullish()}).passthrough(),rf=zod.z.object({Slots:zod.z.record(zod.z.string(),Xm).nullish(),OfferHistory:zod.z.record(zod.z.string(),tf).nullish(),LastUpdatedUtc:u.nullish()}).passthrough();var sf=zod.z.object({Order:zod.z.number().nullish(),OfferID:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),DelayBeforeActivationSec:zod.z.number().nullish()}).passthrough(),nf=zod.z.object({SlotID:zod.z.string().nullish(),Enabled:zod.z.boolean().nullish(),SortOrder:zod.z.number().nullish(),Queue:zod.z.array(sf).nullish(),Schedule:pe.nullish(),Gate:_.nullish(),AllowDismissSkip:zod.z.boolean().nullish(),DismissSkipDelaySec:zod.z.number().nullish()}).passthrough(),of=zod.z.object({StoreOfferID:zod.z.string().nullish(),BillingProductID:zod.z.string().nullish(),PriceOptions:Y.nullish(),UseExternalRewards:zod.z.boolean().nullish()}).passthrough(),af=zod.z.object({AdPlacementID:zod.z.string().nullish(),ViewsRequiredToComplete:zod.z.number().nullish(),MaxViewsPerActivation:zod.z.number().nullish(),CooldownSecondsBetweenViews:zod.z.number().nullish(),RequireServerVerification:zod.z.boolean().nullish(),GrantRewardsPerView:zod.z.boolean().nullish()}).passthrough(),lf=zod.z.object({Purchase:of.nullish(),RewardedVideo:af.nullish()}).passthrough(),uf=zod.z.object({TrackID:zod.z.string().nullish(),Operator:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),cf=zod.z.object({Milestones:X.nullish()}).passthrough(),pf=zod.z.object({TrackID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),RespectBounds:zod.z.boolean().nullish()}).passthrough(),df=zod.z.object({TrackID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),StartValue:zod.z.number().nullish(),MinValue:zod.z.number().nullish(),MaxValue:zod.z.number().nullish(),ClampToMin:zod.z.boolean().nullish(),ClampToMax:zod.z.boolean().nullish(),HiddenFromUI:zod.z.boolean().nullish()}).passthrough(),hf=zod.z.object({RequiredCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredAnyCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredTracks:zod.z.array(uf).nullish(),VisibleWhileLocked:zod.z.boolean().nullish()}).passthrough(),mf=zod.z.object({NodeID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),Type:zod.z.string().nullish(),Action:lf.nullish(),Grants:L.nullish(),TrackChanges:zod.z.array(pf).nullish(),MilestonePoints:zod.z.number().nullish(),UnlockRules:hf.nullish(),NextNodeIDs:zod.z.array(zod.z.string()).nullish(),ChoiceGroupID:zod.z.string().nullish(),Limits:ge.nullish(),HideWhenCompleted:zod.z.boolean().nullish(),ExhaustOfferOnComplete:zod.z.boolean().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Metadata:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),vl=zod.z.object({OfferID:zod.z.string().nullish(),Version:zod.z.number().nullish(),Enabled:zod.z.boolean().nullish(),GraphMode:zod.z.string().nullish(),Name:zod.z.string().nullish(),Description:zod.z.string().nullish(),RootNodeIDs:zod.z.array(zod.z.string()).nullish(),Nodes:zod.z.array(mf).nullish(),Tracks:zod.z.array(df).nullish(),Milestones:zod.z.record(zod.z.string(),De).nullish(),Presets:cf.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneToken:ht.nullish(),ExhaustedWhenAllTerminalNodesCompleted:zod.z.boolean().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Metadata:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),ff=zod.z.object({Milestones:zod.z.record(zod.z.string(),at).nullish()}).passthrough(),an=zod.z.object({Slots:zod.z.record(zod.z.string(),nf).nullish(),Offers:zod.z.record(zod.z.string(),vl).nullish(),Presets:ff.nullish()}).passthrough(),Pl=zod.z.object({DealOfferDefinitions:an.nullish()}),Il=zod.z.object({DealOffers:rf.nullish()}),gf=zod.z.object({EntityID:zod.z.string().nullish(),TotalEarned:zod.z.number().nullish(),ClaimedIDs:zod.z.array(zod.z.string()).nullish(),ReachedUnclaimedIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),Rf=zod.z.object({SlotID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),OfferDef:vl.nullish(),ActivationState:Tl.nullish(),IsNewActivation:zod.z.boolean().nullish(),ComputedExpiresAtUtc:u.nullish(),Cost:Et.nullish(),Milestone:gf.nullish()}).passthrough(),kl=zod.z.object({Slots:zod.z.array(Rf).nullish()}),Ml=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),NodeID:zod.z.string().nullish(),NodeCompleted:zod.z.boolean().nullish(),OfferExhausted:zod.z.boolean().nullish(),Idempotent:zod.z.boolean().nullish(),Resources:b.nullish()}),wl=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),Resources:b.nullish()}),Ol=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),Resources:b.nullish()}),Al=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:b.nullish()}),Ul=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),ClaimedIDs:zod.z.array(zod.z.string()).nullish(),Rejected:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Resources:b.nullish()}),Ye={GetDefinition:"GetDefinition",GetUserState:"GetUserState",GetActiveDeals:"GetActiveDeals",DismissDeal:"DismissDeal",ExecuteNode:"ExecuteNode",RecordShow:"RecordShow",ClaimMilestone:"ClaimMilestone",ClaimMilestonesBatch:"ClaimMilestonesBatch"};var qr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"DealOffer",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinition(e){return this.send(Ye.GetDefinition,e,Pl)}getUserState(e){return this.send(Ye.GetUserState,e,Il)}getActiveDeals(e){return this.send(Ye.GetActiveDeals,e,kl)}dismissDeal(e){return this.send(Ye.DismissDeal,e,wl)}executeNode(e){return this.send(Ye.ExecuteNode,e,Ml)}recordShow(e){return this.send(Ye.RecordShow,e,Ol)}claimMilestone(e){return this.send(Ye.ClaimMilestone,e,Al)}claimMilestonesBatch(e){return this.send(Ye.ClaimMilestonesBatch,e,Ul)}};var yf=zod.z.object({}).passthrough().transform(o=>o),Cf=zod.z.object({FeatureKey:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Percent:zod.z.number().nullish(),SourceCurrencyID:zod.z.string().nullish(),TargetCurrencyID:zod.z.string().nullish()}).passthrough(),ln=zod.z.object({IsEnabled:zod.z.boolean().nullish(),ActivationReward:L.nullish(),InviteRewards:zod.z.record(zod.z.string(),De).nullish(),SpendRewards:zod.z.array(Cf).nullish()}).passthrough(),Bl=zod.z.object({ReferralDefinitions:ln.nullish()}),Ll=zod.z.object({Referral:yf.nullish()}),ql=zod.z.object({ReferralCode:zod.z.string().nullish(),IsFirstActivation:zod.z.boolean().nullish(),Resources:b.nullish()}),un=zod.z.object({RewardID:zod.z.string().nullish(),Resources:b.nullish()}),El=$e(un),gt={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateReferralCode:"ActivateReferralCode",ClaimInviteReward:"ClaimInviteReward",ClaimInviteRewardsBatch:"ClaimInviteRewardsBatch"};var Er=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Referral",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(gt.GetDefinitions,e,Bl)}getUserState(e){return this.send(gt.GetUserState,e,Ll)}activateReferralCode(e){return this.send(gt.ActivateReferralCode,e,ql)}claimInviteReward(e){return this.send(gt.ClaimInviteReward,e,un)}claimInviteRewardsBatch(e){return this.send(gt.ClaimInviteRewardsBatch,e,El)}};var Sf={RequestSent:"RequestSent",Accepted:"Accepted",Declined:"Declined",Removed:"Removed"},xf={Attack:"Attack",Raid:"Raid",FriendAdd:"FriendAdd"},Gl=zod.z.object({UserID:zod.z.string(),PublicData:be.nullish()}),Df=zod.z.object({OwnerUserID:zod.z.string().nullish(),ActorUserID:zod.z.string().nullish(),ActorProfile:be.nullish(),Type:zod.z.string().nullish(),CreatedAt:u.nullish(),OwnerImpact:b.nullish(),IsBlocked:zod.z.boolean().nullish(),TargetObjectName:zod.z.string().nullish()}).passthrough(),Gr=zod.z.object({Friends:zod.z.array(Gl).nullish()}),bf=zod.z.object({FriendsCount:zod.z.number().nullish(),IncomingRequestsCount:zod.z.number().nullish(),OutgoingRequestsCount:zod.z.number().nullish()}),Ft=zod.z.object({TargetUserID:zod.z.string().nullish(),Status:zod.z.string().nullish(),Target:Gl.nullish(),Counters:bf.nullish()}),Nl=zod.z.object({Events:zod.z.array(Df).nullish()}),Xe={GetFriendsList:"GetFriendsList",GetIncomingRequests:"GetIncomingRequests",GetRecommendedFriends:"GetRecommendedFriends",SendFriendRequest:"SendFriendRequest",AcceptFriendRequest:"AcceptFriendRequest",DeclineFriendRequest:"DeclineFriendRequest",RemoveFriend:"RemoveFriend",GetTimeline:"GetTimeline"};var Nr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Social",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getFriendsList(e){return this.send(Xe.GetFriendsList,e,Gr)}getIncomingRequests(e){return this.send(Xe.GetIncomingRequests,e,Gr)}getRecommendedFriends(e){return this.send(Xe.GetRecommendedFriends,e,Gr)}sendFriendRequest(e){return this.send(Xe.SendFriendRequest,e,Ft)}acceptFriendRequest(e){return this.send(Xe.AcceptFriendRequest,e,Ft)}declineFriendRequest(e){return this.send(Xe.DeclineFriendRequest,e,Ft)}removeFriend(e){return this.send(Xe.RemoveFriend,e,Ft)}getTimeline(e){return this.send(Xe.GetTimeline,e,Nl)}};var zf={Replace:"Replace",Refresh:"Refresh",KeepBest:"KeepBest",Stack:"Stack"};var Ut=zod.z.object({Target:zod.z.string().nullish(),Operation:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),Tf=zod.z.object({BoostID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),PriceOptions:Y.nullish(),Effect:Ut.nullish(),DurationSeconds:zod.z.number().nullish(),Charges:zod.z.number().nullish(),StackingPolicy:zod.z.string().nullish(),MaxActiveInstances:zod.z.number().nullish(),Tags:zod.z.array(zod.z.string()).nullish()}).passthrough(),vf=zod.z.object({ScheduledBoostID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Tags:zod.z.array(zod.z.string()).nullish(),Schedule:pe.nullish(),Effects:zod.z.array(Ut).nullish(),Gate:_.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Pf=zod.z.object({ChainedBoostID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Effects:zod.z.array(Ut).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),If=zod.z.object({ChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Schedule:pe.nullish(),Phases:zod.z.array(Pf).nullish(),Gate:_.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),kf=zod.z.object({TriggeredBoostID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Tags:zod.z.array(zod.z.string()).nullish(),Sources:zod.z.array(Ue).nullish(),Effects:zod.z.array(Ut).nullish(),DurationSeconds:zod.z.number().nullish(),Charges:zod.z.number().nullish(),StackingPolicy:zod.z.string().nullish(),MaxActiveInstances:zod.z.number().nullish(),Gate:_.nullish()}).passthrough(),Mf=zod.z.object({MaxAddPercent:zod.z.number().nullish(),MaxMultiply:zod.z.number().nullish(),MaxAddFlat:zod.z.number().nullish()}).passthrough(),wf=zod.z.object({StackingCaps:zod.z.record(zod.z.string(),Mf).nullish()}).passthrough(),jr=zod.z.object({Definitions:zod.z.record(zod.z.string(),Tf).nullish(),ScheduledBoosts:zod.z.record(zod.z.string(),vf).nullish(),BoostChains:zod.z.record(zod.z.string(),If).nullish(),TriggeredBoosts:zod.z.record(zod.z.string(),kf).nullish(),Settings:wf.nullish()}).passthrough(),jl=zod.z.object({InstanceID:zod.z.string(),BoostID:zod.z.string(),ActivatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),RemainingCharges:zod.z.number().nullish(),EffectSnapshot:Ut.nullish(),SourceType:zod.z.string().nullish(),SourceRef:zod.z.string().nullish()}).passthrough();zod.z.object({Date:u.nullish(),DailyCount:zod.z.number().nullish(),LastFiredUtc:u.nullish()}).passthrough();var Fl=zod.z.object({ServerTimeUtc:u.nullish(),Active:zod.z.record(zod.z.string(),jl).nullish()}),Vl=zod.z.object({ServerTimeUtc:u.nullish(),BoostID:zod.z.string().nullish(),StackingPolicy:zod.z.string().nullish(),ActivatedBoost:jl.nullish(),Resources:b.nullish()}),Of={Scheduled:"Scheduled",Chain:"Chain"},Af=zod.z.object({Kind:zod.z.string().nullish(),SourceID:zod.z.string().nullish(),PhaseID:zod.z.string().nullish(),CycleIndex:zod.z.number().nullish(),PhaseOrder:zod.z.number().nullish(),StartUtc:u.nullish(),EndUtc:u.nullish(),Effects:zod.z.array(Ut).nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),_l=zod.z.object({ServerTimeUtc:u.nullish(),Windows:zod.z.array(Af).nullish()}),Rt={GetDefinitions:"GetDefinitions",GetActive:"GetActive",GetActiveWindows:"GetActiveWindows",Activate:"Activate",CleanupExpired:"CleanupExpired"};var Fr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"TimedBoost",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Rt.GetDefinitions,e,jr)}getActive(e){return this.send(Rt.GetActive,e,Fl)}getActiveWindows(e){return this.send(Rt.GetActiveWindows,e,_l)}activate(e){return this.send(Rt.Activate,e,Vl)}cleanupExpired(e){return this.send(Rt.CleanupExpired,e,ze)}};var Vr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"UserCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getUserCustomDataDefinitions(e){return this.send(_e.GetUserCustomDataDefinitions,e,qi)}getMyUserCustomData(e){return this.send(_e.GetMyUserCustomData,e,ro)}getPublicUserCustomDataOf(e){return this.send(_e.GetPublicUserCustomDataOf,e,Cs)}setPrivateData(e){return this.send(_e.SetPrivateData,e,Ss)}setPublicData(e){return this.send(_e.SetPublicData,e,Ss)}deleteKey(e){return this.send(_e.DeleteKey,e,ze)}batchSet(e){return this.send(_e.BatchSet,e,so)}batchDelete(e){return this.send(_e.BatchDelete,e,no)}batchGetPublicUserCustomDataOf(e){return this.send(_e.BatchGetPublicUserCustomDataOf,e,oo)}};var Uf={Static:"Static",Runtime:"Runtime"},Bf={Public:"Public",Private:"Private"},Lf=zod.z.enum(["Client","Server","System"]),qf=zod.z.enum(["String","Int","Bool","Json"]),Ef=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:u.nullish(),Version:zod.z.number().nullish(),LastWriter:Lf.nullish(),ExpiresAt:u.nullish()}).passthrough(),Wl=zod.z.record(zod.z.string(),Ef),cn=zod.z.object({StaticVersion:zod.z.number().nullish(),RuntimeVersion:zod.z.number().nullish(),Static:Wl.nullish(),Runtime:Wl.nullish(),NotModified:zod.z.boolean().nullish()}),Gf=zod.z.object({KeyID:zod.z.string(),Scope:zod.z.enum(["Static","Runtime"]).nullish(),Bucket:zod.z.enum(["Public","Private"]).nullish(),ValueType:qf.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),_r=zod.z.object({Keys:zod.z.record(zod.z.string(),Gf).nullish(),DefaultMaxValueLengthBytes:zod.z.number().nullish(),DefaultTtlSeconds:zod.z.number().nullish(),MaxKeysPerBucket:zod.z.number().nullish(),MaxTotalSizeBytes:zod.z.number().nullish(),RejectUnregisteredKeys:zod.z.boolean().nullish()}).passthrough(),Vt={GetTitleCustomDataDefinitions:"GetTitleCustomDataDefinitions",GetPublicTitleData:"GetPublicTitleData",GetPublicTitleDataKeys:"GetPublicTitleDataKeys"};var Wr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"TitleCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getTitleCustomDataDefinitions(e){return this.send(Vt.GetTitleCustomDataDefinitions,e,_r)}getPublicTitleData(e){return this.send(Vt.GetPublicTitleData,e,cn)}getPublicTitleDataKeys(e){return this.send(Vt.GetPublicTitleDataKeys,e,cn)}};var Nf={Fast:"Fast",Sequential:"Sequential"},jf={Instant:"Instant",Timed:"Timed"},Ff={Hit:"Hit",Blocked:"Blocked"},Vf=zod.z.object({SlotIndex:zod.z.number(),Level:zod.z.number().nullish(),IsDamaged:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish()}).passthrough(),_f=zod.z.object({Symbol:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),OnOpenBonus:L.nullish(),BonusTag:zod.z.string().nullish()}).passthrough();zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:L.nullish()}).passthrough();zod.z.object({PlayedCount:zod.z.number().nullish(),RewardsClaimedCount:zod.z.number().nullish(),InstantClaimsCount:zod.z.number().nullish(),EarlyClaimsCount:zod.z.number().nullish(),LateClaimsCount:zod.z.number().nullish(),AdViewsTotal:zod.z.number().nullish()}).passthrough();var Ql=zod.z.object({}).passthrough().transform(o=>o),Kl=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),Ie=zod.z.object({Operation:b.nullish(),ScaleWithRollMultiplier:zod.z.boolean().nullish()}).passthrough(),Wf=zod.z.object({Count:zod.z.number().nullish(),Sides:zod.z.number().nullish()}).passthrough(),Qf=zod.z.object({ShieldChance:zod.z.number().nullish(),DamagedBuildingChance:zod.z.number().nullish(),RankMultiplierMin:zod.z.number().nullish(),RankMultiplierMax:zod.z.number().nullish(),RankOffsetMin:zod.z.number().nullish(),RankOffsetMax:zod.z.number().nullish()}).passthrough(),Kf=zod.z.object({CostMatrixTemplatesByID:zod.z.record(zod.z.string(),zod.z.array(zod.z.array(zod.z.number()))).nullish(),PerBoardGrowth:zod.z.number().nullish(),VisualTemplateCycle:zod.z.array(zod.z.string()).nullish(),EconomyScaledResources:fe.nullish(),ScaleRaidStealWithEconomy:zod.z.boolean().nullish(),ScaleAttackRewardWithEconomy:zod.z.boolean().nullish(),AttackValueFromCostMatrix:zod.z.boolean().nullish(),AttackBlockedRewardFactor:zod.z.number().nullish(),ScaleVictimLossWithEconomy:zod.z.boolean().nullish(),ScaleVictimLossWithTier:zod.z.boolean().nullish(),SynthesizedBuildingSlots:zod.z.number().nullish(),SynthesizedBuildingMaxLevel:zod.z.number().nullish()}).passthrough(),Hf=zod.z.object({CostMatrix:zod.z.array(zod.z.array(zod.z.number())).nullish(),PerBoardGrowth:zod.z.number().nullish(),EconomyScale:zod.z.number().nullish(),ScaledResources:fe.nullish()}).passthrough(),Hl=zod.z.object({SlotIndex:zod.z.number().nullish(),Name:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),MaxLevel:zod.z.number().nullish(),MaxLevelReward:L.nullish()}).passthrough(),$f=zod.z.object({Index:zod.z.number().nullish(),Type:zod.z.string().nullish(),CustomTypeID:zod.z.string().nullish(),RandomActionAttackWeight:zod.z.number().nullish(),RandomActionRaidWeight:zod.z.number().nullish(),ChanceTableID:zod.z.string().nullish(),SpecialModeID:zod.z.string().nullish(),Params:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Zf=zod.z.object({Tiles:zod.z.record(zod.z.string(),$f).nullish()}).passthrough(),Jf=zod.z.object({Weight:zod.z.number().nullish(),Bonus:Ie.nullish(),Tag:zod.z.string().nullish()}).passthrough(),Yf=zod.z.object({Weight:zod.z.number().nullish(),Tag:zod.z.string().nullish(),MinBonusCells:zod.z.number().nullish(),MaxBonusCells:zod.z.number().nullish(),BonusPool:zod.z.array(Jf).nullish(),GuaranteedBonus:Ie.nullish(),IsJackpot:zod.z.boolean().nullish(),JackpotFinalMultiplier:zod.z.number().nullish(),JackpotSymbolDistribution:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough(),Xf=zod.z.object({Variants:zod.z.array(Yf).nullish()}).passthrough(),eg=zod.z.object({Weight:zod.z.number().nullish(),OutcomeID:zod.z.string().nullish(),Reward:Ie.nullish(),ForceAction:zod.z.string().nullish(),SpecialModeID:zod.z.string().nullish()}).passthrough(),tg=zod.z.object({Outcomes:zod.z.array(eg).nullish()}).passthrough(),$l=zod.z.object({PerAdMultiplierRange:Kl.nullish(),MaxAdViews:zod.z.number().nullish(),AdCreditCost:zod.z.number().nullish(),FormulaKind:zod.z.string().nullish(),ApplyMultiplierOnEarlyClaim:zod.z.boolean().nullish()}).passthrough(),ig=zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:Ie.nullish()}).passthrough(),rg=zod.z.object({Tiers:zod.z.array(ig).nullish(),BelowFirstTierReward:Ie.nullish()}).passthrough(),sg=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:Ie.nullish(),DurationSeconds:zod.z.number().nullish(),PriceOptions:Y.nullish(),Multipliers:$l.nullish(),Gradation:rg.nullish()}).passthrough(),ng=zod.z.object({Choices:zod.z.array(sg).nullish(),OfferExpireSeconds:zod.z.number().nullish(),ClaimExpireSeconds:zod.z.number().nullish()}).passthrough(),og=zod.z.object({Chance:zod.z.number().nullish(),RequiredOutcome:zod.z.string().nullish(),Reward:Ie.nullish(),Tag:zod.z.string().nullish()}).passthrough(),ag=zod.z.object({OnPassStart:Ie.nullish(),OnTileLanding:zod.z.record(zod.z.string(),Ie).nullish(),OnAttack:zod.z.record(zod.z.string(),Ie).nullish(),OnRaid:zod.z.record(zod.z.string(),Ie).nullish(),OnBuild:Ie.nullish(),OnStageComplete:Ie.nullish(),OnAttackBonusDrops:zod.z.array(og).nullish(),ChanceTablesByID:zod.z.record(zod.z.string(),tg).nullish(),SpecialModesByID:zod.z.record(zod.z.string(),ng).nullish()}).passthrough(),Zl=zod.z.object({BaseAttackReward:L.nullish(),BaseRaidReward:L.nullish(),MaxRollMultiplier:zod.z.number().nullish(),MaxShields:zod.z.number().nullish(),Buildings:zod.z.array(Hl).nullish(),HeistGridBonusConfig:Xf.nullish(),StageOperations:ag.nullish(),TileLandingMultiplier:Kl.nullish(),EconomyOverride:Hf.nullish()}).passthrough(),lg=zod.z.object({Name:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),BoardTemplateID:zod.z.string().nullish(),Buildings:zod.z.array(Hl).nullish(),StageTemplateID:zod.z.string().nullish(),CostMatrixTemplateID:zod.z.string().nullish(),UnitValue:zod.z.number().nullish(),Override:Zl.nullish()}).passthrough(),Qr=zod.z.object({RollCurrencyID:zod.z.string().nullish(),ShieldCurrencyID:zod.z.string().nullish(),RaidMode:zod.z.string().nullish(),AllowedRollMultipliers:zod.z.array(zod.z.number()).nullish(),BoardTemplatesByID:zod.z.record(zod.z.string(),Zf).nullish(),StageTemplatesByID:zod.z.record(zod.z.string(),Zl).nullish(),StagesByLevel:zod.z.record(zod.z.string(),lg).nullish(),SoftCurrencyID:zod.z.string().nullish(),ProceduralEconomy:Kf.nullish(),Dice:Wf.nullish(),Bots:Qf.nullish()}).passthrough(),ug=zod.z.object({IsActive:zod.z.boolean().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),AnchorUtc:u.nullish(),RoundDurationSec:zod.z.number().nullish(),PauseBetweenRoundsSec:zod.z.number().nullish(),MaxRounds:zod.z.number().nullish(),PartnerCount:zod.z.number().nullish(),MatchmakingTimeoutMinutes:zod.z.number().nullish(),MemberGracePeriodMinutes:zod.z.number().nullish(),ContributionMin:zod.z.number().nullish(),ContributionMax:zod.z.number().nullish(),ScaleContributionWithRollMultiplier:zod.z.boolean().nullish(),MaxProgress:zod.z.number().nullish(),Milestones:zod.z.record(zod.z.string(),De).nullish(),GrandPrize:L.nullish()}).passthrough(),Kr=zod.z.object({Board:Qr.nullish(),CommunityChest:ug.nullish()}).passthrough(),cg=zod.z.object({TargetUserID:zod.z.string().nullish(),IsBot:zod.z.boolean().nullish(),PublicData:be.nullish(),TargetBuildingStates:zod.z.array(Vf).nullish(),TargetHasShield:zod.z.boolean().nullish()}).passthrough(),pg=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:Ie.nullish(),DurationSeconds:zod.z.number().nullish(),PriceOptions:Y.nullish(),Multipliers:$l.nullish()}).passthrough(),dg=zod.z.object({ModeID:zod.z.string().nullish(),Choices:zod.z.array(pg).nullish()}).passthrough(),hg=zod.z.object({GroupID:zod.z.string().nullish(),Delta:w.nullish(),NewProgress:w.nullish(),MaxProgress:w.nullish(),UnlockedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),Completed:zod.z.boolean().nullish()}).passthrough(),Jl=zod.z.object({UsedMultiplier:zod.z.number().nullish(),Steps:zod.z.number().nullish(),OldPosition:zod.z.number().nullish(),NewPosition:zod.z.number(),CyclesCompletedDelta:w.nullish(),LandedTileType:zod.z.string().nullish(),Operation:b.nullish(),ActionRequired:zod.z.string().nullish(),ActionData:cg.nullish(),SpecialModeOffer:dg.nullish(),CommunityChestContribution:hg.nullish()}).passthrough(),Yl=zod.z.object({Outcome:zod.z.string().nullish(),IsBotTarget:zod.z.boolean().nullish(),BuildingIndexHit:zod.z.number().nullish(),Operation:b.nullish(),DualResult:dt.nullish()}).passthrough(),pn=zod.z.object({Status:zod.z.string().nullish(),Outcome:zod.z.string().nullish(),FoundSymbol:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),FoundBonus:L.nullish(),OpenedIndex:zod.z.number().nullish(),AttemptsLeft:zod.z.number().nullish(),RaidLayout:zod.z.array(_f).nullish(),HeistVariantTag:zod.z.string().nullish(),IsJackpot:zod.z.boolean().nullish(),Operation:b.nullish(),DualResult:dt.nullish()}).passthrough(),Xl=zod.z.object({BuiltIndex:zod.z.number(),NewLevel:zod.z.number().nullish(),StageComplete:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish(),Operation:b.nullish()}).passthrough(),eu=zod.z.object({Mode:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),Operation:b.nullish(),DurationSeconds:zod.z.number().nullish(),StartedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish()}).passthrough(),tu=zod.z.object({AdViewsUsed:zod.z.number().nullish(),RolledMultiplier:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),RemainingAdViews:zod.z.number().nullish()}).passthrough(),iu=zod.z.object({FinalMultiplier:zod.z.number().nullish(),AdViewsUsed:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),IsEarlyClaim:zod.z.boolean().nullish(),Operation:b.nullish()}).passthrough(),mg={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},ru=zod.z.enum(["Forming","Active","Completed","Failed","Expired"]),fg={Active:"Active",Left:"Left",Replaced:"Replaced"},gg=zod.z.enum(["Active","Left","Replaced"]),Rg=zod.z.object({CurrentProgress:w.nullish(),MaxProgress:w.nullish()}).passthrough(),yg=zod.z.object({UserID:zod.z.string().nullish(),PublicData:be.nullish(),IsBot:zod.z.boolean().nullish(),ContributionPoints:w.nullish(),ClaimedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),GrandPrizeClaimed:zod.z.boolean().nullish(),MemberStatus:gg.nullish(),JoinedAtUtc:u.nullish(),LeftAtUtc:u.nullish()}).passthrough(),su=zod.z.object({GroupID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),Members:zod.z.array(yg).nullish(),SharedProgress:Rg.nullish(),Status:ru.nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),Version:zod.z.number().nullish()}).passthrough(),Cg=zod.z.object({GroupID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),FinalStatus:ru.nullish(),GrandPrizeReceived:zod.z.boolean().nullish(),FinishedAtUtc:u.nullish()}).passthrough(),Sg=zod.z.object({ActiveGroupID:zod.z.string().nullish(),ActiveRoundIndex:zod.z.number().nullish(),History:zod.z.array(Cg).nullish()}).passthrough(),nu=zod.z.object({ServerTimeUtc:u.nullish(),UserState:Sg.nullish(),ActiveGroup:su.nullish(),SecondsRemaining:w.nullish()}),ou=zod.z.object({ServerTimeUtc:u.nullish(),Group:su.nullish(),SecondsRemaining:w.nullish()}),dn=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:b.nullish()}),au=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),Se={GetGameLoops:"GetGameLoops",GetBoardDefinition:"GetBoardDefinition",GetBoardDefinitionForLevel:"GetBoardDefinitionForLevel",GetUserBoardState:"GetUserBoardState",BoardLoopRoll:"BoardLoopRoll",BoardLoopAttack:"BoardLoopAttack",BoardLoopRaid:"BoardLoopRaid",BoardLoopRaidFast:"BoardLoopRaidFast",BoardLoopBuild:"BoardLoopBuild",BoardSpecialChoose:"BoardSpecialChoose",BoardSpecialApplyMultiplier:"BoardSpecialApplyMultiplier",BoardSpecialClaim:"BoardSpecialClaim",GetCommunityChestState:"GetCommunityChestState",JoinOrCreateCommunityChest:"JoinOrCreateCommunityChest",ClaimCommunityChestMilestone:"ClaimCommunityChestMilestone",ClaimCommunityChestGrandPrize:"ClaimCommunityChestGrandPrize",LeaveCommunityChest:"LeaveCommunityChest"};var xg=zod.z.object({VariantID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Weight:zod.z.number().nullish(),IsControl:zod.z.boolean().nullish(),Params:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Dg=zod.z.object({ExperimentID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Schedule:pe.nullish(),Gate:_.nullish(),Variants:zod.z.array(xg).nullish(),Salt:zod.z.string().nullish(),LayerID:zod.z.string().nullish(),StickyAssignment:zod.z.boolean().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),lu=zod.z.object({Experiments:zod.z.record(zod.z.string(),Dg).nullish()}).passthrough();var bg={Mesh:"Mesh",Host:"Host"},hn=zod.z.enum(["Mesh","Host"]),zg={ServerRelay:"ServerRelay",P2P:"P2P"},mn=zod.z.enum(["ServerRelay","P2P"]),Tg={Public:"Public",Private:"Private"},vg=zod.z.enum(["Public","Private"]),Pg={Signal:"Signal",Chat:"Chat",PlayerJoined:"PlayerJoined",PlayerLeft:"PlayerLeft",HostChanged:"HostChanged",RoomClosed:"RoomClosed",MemberState:"MemberState"},Ig=zod.z.enum(["Signal","Chat","PlayerJoined","PlayerLeft","HostChanged","RoomClosed","MemberState"]),uu=zod.z.object({Urls:zod.z.string().nullish(),Username:zod.z.string().nullish(),Credential:zod.z.string().nullish()}).passthrough(),kg=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),cu=zod.z.object({SystemState:kg.nullish(),DefaultTopology:hn.nullish(),AllowCreatorTopologyOverride:zod.z.boolean().nullish(),DefaultChatMode:mn.nullish(),AllowCreatorChatOverride:zod.z.boolean().nullish(),MaxPlayersPerRoom:zod.z.number().nullish(),RoomTtlSeconds:zod.z.number().nullish(),HeartbeatIntervalMs:zod.z.number().nullish(),MemberTimeoutMs:zod.z.number().nullish(),MaxSignalPayloadBytes:zod.z.number().nullish(),MaxChatTextLength:zod.z.number().nullish(),RoomLogCap:zod.z.number().nullish(),IceServers:zod.z.array(uu).nullish()}).passthrough(),Mg=zod.z.object({UserID:zod.z.string().nullish(),Username:zod.z.string().nullish(),AvatarUrl:zod.z.string().nullish(),Level:zod.z.number().nullish(),Power:zod.z.number().nullish(),Ready:zod.z.boolean().nullish(),State:zod.z.record(zod.z.string(),zod.z.string()).nullish(),JoinedAt:zod.z.number().nullish(),IsHost:zod.z.boolean().nullish(),LastSeenMs:zod.z.number().nullish()}).passthrough(),wg=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),Topology:hn.nullish(),ChatMode:mn.nullish(),MaxPlayers:zod.z.number().nullish(),MemberCount:zod.z.number().nullish(),CreatedAt:zod.z.number().nullish()}).passthrough(),Og=zod.z.object({Seq:zod.z.number().nullish(),Type:Ig.nullish(),FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),Kind:zod.z.string().nullish(),Payload:zod.z.string().nullish(),Ts:zod.z.number().nullish()}).passthrough(),Hr=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),OwnerUserID:zod.z.string().nullish(),Topology:hn.nullish(),ChatMode:mn.nullish(),Visibility:vg.nullish(),Status:zod.z.string().nullish(),MaxPlayers:zod.z.number().nullish(),Members:zod.z.array(Mg).nullish(),IceServers:zod.z.array(uu).nullish(),Seq:zod.z.number().nullish()}).passthrough(),fn=zod.z.object({Closed:zod.z.boolean().nullish(),NewHostUserID:zod.z.string().nullish()}).passthrough(),pu=zod.z.object({Rooms:zod.z.array(wg).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}).passthrough(),du=zod.z.object({Envelopes:zod.z.array(Og).nullish(),MaxSeq:zod.z.number().nullish()}).passthrough(),$r=zod.z.object({Seq:zod.z.number().nullish()}).passthrough(),Ne={CreateRoom:"CreateRoom",JoinRoom:"JoinRoom",LeaveRoom:"LeaveRoom",ListRooms:"ListRooms",GetRoom:"GetRoom",CloseRoom:"CloseRoom",Poll:"Poll",SendSignal:"SendSignal",SendChat:"SendChat",SetMemberState:"SetMemberState"};var gn=zod.z.object({TitleCustomData:_r.nullish(),Character:Wi.nullish(),Item:nr.nullish(),Currency:_i.nullish(),Store:ar.nullish(),Lootbox:Ws.nullish(),Quest:Yt.nullish(),TimedEvent:Rr.nullish(),Leaderboard:br.nullish(),Season:Tr.nullish(),Reward:Qs.nullish(),Collection:Ar.nullish(),Craft:en.nullish(),DealOffer:an.nullish(),Premium:Xs.nullish(),TimedBoost:jr.nullish(),CoopEvent:Br.nullish(),GameLoop:Kr.nullish(),Match:Bs.nullish(),Experiment:lu.nullish(),Blockchain:Is.nullish(),Marketplace:Gs.nullish(),Multiplayer:cu.nullish(),UserCustomData:qi.nullish(),Referral:ln.nullish(),Localization:pa.nullish()}).passthrough();var yt={GetTitlePublicConfiguration:"GetTitlePublicConfiguration",GetTitlePublicConfigurationExcept:"GetTitlePublicConfigurationExcept",GetCurrencyDefinitions:"GetCurrencyDefinitions",GetItemDefinitions:"GetItemDefinitions",GetServerTime:"GetServerTime"};var Zr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Title",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getTitlePublicConfiguration(e){return this.send(yt.GetTitlePublicConfiguration,e,gn)}getTitlePublicConfigurationExcept(e){return this.send(yt.GetTitlePublicConfigurationExcept,e,gn)}getCurrencyDefinitions(e){return this.send(yt.GetCurrencyDefinitions,e,_i)}getItemDefinitions(e){return this.send(yt.GetItemDefinitions,e,nr)}getServerTime(e){return this.send(yt.GetServerTime,e,ze)}};var Jr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i,r=false){let s=O(this.ctx.settings.titleID,"GameLoop",e,t.UserID??"");return this.ctx.transport.post(s,t,i,{ticket:t.ClientSessionTicket,silent:r})}getGameLoops(e){return this.send(Se.GetGameLoops,e,Kr)}getBoardDefinition(e,t=false){return this.send(Se.GetBoardDefinition,e,Qr,t)}getBoardDefinitionForLevel(e,t=false){return this.send(Se.GetBoardDefinitionForLevel,e,Qr,t)}getUserBoardState(e){return this.send(Se.GetUserBoardState,e,Ql)}boardLoopRoll(e){return this.send(Se.BoardLoopRoll,e,Jl)}boardLoopAttack(e){return this.send(Se.BoardLoopAttack,e,Yl)}boardLoopRaid(e){return this.send(Se.BoardLoopRaid,e,pn)}boardLoopRaidFast(e){return this.send(Se.BoardLoopRaidFast,e,pn)}boardLoopBuild(e){return this.send(Se.BoardLoopBuild,e,Xl)}boardSpecialChoose(e){return this.send(Se.BoardSpecialChoose,e,eu)}boardSpecialApplyMultiplier(e){return this.send(Se.BoardSpecialApplyMultiplier,e,tu)}boardSpecialClaim(e){return this.send(Se.BoardSpecialClaim,e,iu)}getCommunityChestState(e){return this.send(Se.GetCommunityChestState,e,nu)}joinOrCreateCommunityChest(e){return this.send(Se.JoinOrCreateCommunityChest,e,ou)}claimCommunityChestMilestone(e){return this.send(Se.ClaimCommunityChestMilestone,e,dn)}claimCommunityChestGrandPrize(e){return this.send(Se.ClaimCommunityChestGrandPrize,e,dn)}leaveCommunityChest(e){return this.send(Se.LeaveCommunityChest,e,au)}};var _t=zod.z.lazy(()=>zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null(),zod.z.array(_t),zod.z.record(zod.z.string(),_t)]));var Ug={Live:"Live",Latest:"Latest",Specific:"Specific"},Bg={Debug:"Debug",Info:"Info",Warning:"Warning",Error:"Error"},Lg=zod.z.enum(["Debug","Info","Warning","Error"]),qg={None:"None",Disabled:"Disabled",NoActiveRevision:"NoActiveRevision",RevisionNotFound:"RevisionNotFound",InvalidFieldName:"InvalidFieldName",RateLimited:"RateLimited",HandlerNotFound:"HandlerNotFound",HandlerDisabled:"HandlerDisabled",Timeout:"Timeout",StatementCountExceeded:"StatementCountExceeded",StackOverflow:"StackOverflow",ApiCallLimitExceeded:"ApiCallLimitExceeded",JavaScriptException:"JavaScriptException",ExecutionError:"ExecutionError"},Eg=zod.z.enum(["None","Disabled","NoActiveRevision","RevisionNotFound","InvalidFieldName","RateLimited","HandlerNotFound","HandlerDisabled","Timeout","StatementCountExceeded","StackOverflow","ApiCallLimitExceeded","JavaScriptException","ExecutionError"]),Gg=zod.z.object({Level:Lg,Message:zod.z.string().nullish(),Data:_t.nullish()}),Ng=zod.z.object({Error:Eg,Message:zod.z.string().nullish(),StackTrace:zod.z.string().nullish()}),hu=zod.z.object({FunctionName:zod.z.string().nullish(),Revision:zod.z.number().nullish(),FunctionResult:_t.nullish(),FunctionResultTooLarge:zod.z.boolean().nullish(),Logs:zod.z.array(Gg).nullish(),LogsTooLarge:zod.z.boolean().nullish(),ExecutionTimeSeconds:zod.z.number().nullish(),APIRequestsIssued:zod.z.number().nullish(),Error:Ng.nullish()}),Rn={Execute:"Execute"};var Yr=class{constructor(e){this.ctx=e;}ctx;execute(e){let t=O(this.ctx.settings.titleID,"CloudCode",Rn.Execute,e.UserID??"");return this.ctx.transport.post(t,e,hu,{ticket:e.ClientSessionTicket})}};var Xr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Blockchain",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(we.GetDefinitions,e,Uo)}getUserState(e){return this.send(we.GetUserState,e,Bo)}depositToken(e){return this.send(we.DepositToken,e,Lo)}depositNFT(e){return this.send(we.DepositNFT,e,qo)}requestTokenWithdrawal(e){return this.send(we.RequestTokenWithdrawal,e,Eo)}requestNFTWithdrawal(e){return this.send(we.RequestNFTWithdrawal,e,Go)}getTransactionHistory(e){return this.send(we.GetTransactionHistory,e,No)}retryWithdrawal(e){return this.send(we.RetryWithdrawal,e,jo)}confirmWithdrawal(e){return this.send(we.ConfirmWithdrawal,e,Fo)}donateToDeveloper(e){return this.send(we.DonateToDeveloper,e,ws)}donateToUsersPool(e){return this.send(we.DonateToUsersPool,e,ws)}};var es=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Marketplace",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(ae.GetDefinitions,e,ia)}getGroupedOffers(e){return this.send(ae.GetGroupedOffers,e,ra)}getOffersByItem(e){return this.send(ae.GetOffersByItem,e,Ns)}getOffer(e){return this.send(ae.GetOffer,e,sa)}getBuyOrders(e){return this.send(ae.GetBuyOrders,e,Ns)}getMyState(e){return this.send(ae.GetMyState,e,oa)}getHistory(e){return this.send(ae.GetHistory,e,aa)}createListing(e){return this.send(ae.CreateListing,e,Nt)}cancelListing(e){return this.send(ae.CancelListing,e,qe)}buy(e){return this.send(ae.Buy,e,qe)}marketBuy(e){return this.send(ae.MarketBuy,e,qe)}marketSell(e){return this.send(ae.MarketSell,e,qe)}createAuction(e){return this.send(ae.CreateAuction,e,Nt)}placeBid(e){return this.send(ae.PlaceBid,e,na)}claimAuction(e){return this.send(ae.ClaimAuction,e,qe)}createBuyOrder(e){return this.send(ae.CreateBuyOrder,e,Nt)}cancelBuyOrder(e){return this.send(ae.CancelBuyOrder,e,qe)}fillBuyOrder(e){return this.send(ae.FillBuyOrder,e,qe)}createDirectTrade(e){return this.send(ae.CreateDirectTrade,e,Nt)}respondDirectTrade(e){return this.send(ae.RespondDirectTrade,e,qe)}cancelDirectTrade(e){return this.send(ae.CancelDirectTrade,e,qe)}claimBack(e){return this.send(ae.ClaimBack,e,qe)}};var ts=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Multiplayer",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}createRoom(e){return this.send(Ne.CreateRoom,e,Hr)}joinRoom(e){return this.send(Ne.JoinRoom,e,Hr)}leaveRoom(e){return this.send(Ne.LeaveRoom,e,fn)}listRooms(e){return this.send(Ne.ListRooms,e,pu)}getRoom(e){return this.send(Ne.GetRoom,e,Hr)}closeRoom(e){return this.send(Ne.CloseRoom,e,fn)}poll(e){return this.send(Ne.Poll,e,du)}sendSignal(e){return this.send(Ne.SendSignal,e,$r)}sendChat(e){return this.send(Ne.SendChat,e,$r)}setMemberState(e){return this.send(Ne.SetMemberState,e,$r)}};var is=class{settings;emitter;platform;clientPlatform;transport;fetchImpl;data;authStore;api;auth;userService;currency;item;store;purchase;checkout;lootbox;reward;quest;tutorial;localization;timedEvent;leaderboard;season;premium;character;match;craft;collection;coopEvent;dealOffer;referral;social;timedBoost;userCustomData;titleCustomData;title;gameLoop;cloudCode;blockchain;marketplace;multiplayer;constructor(e){this.settings=Dn(e),this.emitter=new Lt,this.platform=e.platform??new Dt,this.clientPlatform=e.clientPlatform??Tn(),this.fetchImpl=e.fetch??globalThis.fetch.bind(globalThis),this.transport=new ti({baseUrl:this.settings.baseUrl,emitter:this.emitter,fetchImpl:e.fetch,debugLogging:this.settings.debugLogging,throttleMs:e.throttleMs,clientPlatform:this.clientPlatform}),this.data=new ni(this.emitter),this.emitter.on("quest:systemProgress",t=>{this.data.user.patchQuestProgressUpdates(t);}),this.emitter.on("tutorial:systemProgress",t=>{this.data.user.patchTutorialProgress(t);}),this.emitter.on("user:stateVersions",({epoch:t,versions:i})=>{this.userService.noteStateVersions(t,i);}),this.authStore=new oi(this.platform.storage,this.settings.titleID),this.api={authentication:new er(this),user:new ir(this),currency:new rr(this),item:new or(this),store:new lr(this),purchase:new ur(this),lootbox:new dr(this),reward:new hr(this),quest:new gr(this),tutorial:new mr(this),localization:new fr(this),timedEvent:new yr(this),leaderboard:new zr(this),season:new vr(this),premium:new Ir(this),character:new kr(this),match:new Mr(this),craft:new Or(this),collection:new Ur(this),coopEvent:new Lr(this),dealOffer:new qr(this),referral:new Er(this),social:new Nr(this),timedBoost:new Fr(this),userCustomData:new Vr(this),titleCustomData:new Wr(this),title:new Zr(this),gameLoop:new Jr(this),cloudCode:new Yr(this),blockchain:new Xr(this),marketplace:new es(this),multiplayer:new ts(this)},this.userService=new ci(this),this.auth=new ai(this),this.currency=new di(this),this.item=new hi(this),this.store=new mi(this),this.purchase=new fi(this),this.checkout=new gi(this),this.lootbox=new Ri(this),this.reward=new yi(this),this.quest=new Di(this),this.tutorial=new Ci(this),this.localization=new xi(this),this.timedEvent=new bi(this),this.leaderboard=new zi(this),this.season=new Ti(this),this.premium=new vi(this),this.character=new Pi(this),this.match=new Ii(this),this.craft=new ki(this),this.collection=new Mi(this),this.coopEvent=new wi(this),this.dealOffer=new Oi(this),this.referral=new Ai(this),this.social=new Ui(this),this.timedBoost=new Bi(this),this.userCustomData=new Ei(this),this.titleCustomData=new Gi(this),this.title=new Ni(this),this.gameLoop=new ji(this),this.cloudCode=new Fi(this),this.blockchain=new Hi(this),this.marketplace=new Yi(this),this.multiplayer=new Xi(this),this.transport.setSessionRefreshHandler(()=>this.auth.refreshSession());}buildAuthedBaseRequest(){let e=this.auth.context;return {UserID:e?.userID,ClientSessionTicket:e?.clientSessionTicket,BuildKey:this.settings.buildKey,WebAppLink:this.platform.getFullURL(),RelatedEntityID:P()}}};var rs=class{ctx;constructor(e){this.ctx=new is(e);}get titleID(){return this.ctx.settings.titleID}get auth(){return this.ctx.auth}get user(){return this.ctx.userService}get currency(){return this.ctx.currency}get item(){return this.ctx.item}get store(){return this.ctx.store}get purchase(){return this.ctx.purchase}get checkout(){return this.ctx.checkout}get lootbox(){return this.ctx.lootbox}get reward(){return this.ctx.reward}get quest(){return this.ctx.quest}get tutorial(){return this.ctx.tutorial}get localization(){return this.ctx.localization}get timedEvent(){return this.ctx.timedEvent}get leaderboard(){return this.ctx.leaderboard}get season(){return this.ctx.season}get premium(){return this.ctx.premium}get character(){return this.ctx.character}get match(){return this.ctx.match}get craft(){return this.ctx.craft}get collection(){return this.ctx.collection}get coopEvent(){return this.ctx.coopEvent}get dealOffer(){return this.ctx.dealOffer}get referral(){return this.ctx.referral}get social(){return this.ctx.social}get timedBoost(){return this.ctx.timedBoost}get userCustomData(){return this.ctx.userCustomData}get titleCustomData(){return this.ctx.titleCustomData}get title(){return this.ctx.title}get gameLoop(){return this.ctx.gameLoop}get cloudCode(){return this.ctx.cloudCode}get blockchain(){return this.ctx.blockchain}get marketplace(){return this.ctx.marketplace}get multiplayer(){return this.ctx.multiplayer}get data(){return this.ctx.data}get platform(){return this.ctx.platform}on(e,t){return this.ctx.emitter.on(e,t)}once(e,t){return this.ctx.emitter.once(e,t)}off(e,t){this.ctx.emitter.off(e,t);}};function jg(o){return new rs(o)}var mu="idos_sso",fu="state",yn="idos:sso:state",Fg="https://idosgames.com/sso/";function Vg(){if(typeof window>"u")return null;let o=window.location.hash?.startsWith("#")?window.location.hash.slice(1):window.location.hash;if(!o)return null;let e=new URLSearchParams(o),t=e.get(mu);if(!t)return null;let i=e.get(fu)??"",r=Hg();return Zg(e),$g(),r&&i!==r?null:{code:t,state:i}}function _g(o){if(typeof window>"u")return;let e=o.returnTo??Wg(),t=Qg();Kg(t);let i=new URL(o.ssoUrl??Fg);i.searchParams.set("title",o.titleID),i.searchParams.set("return_to",e),i.searchParams.set("state",t),window.location.assign(i.toString());}function Wg(){let{origin:o,pathname:e,search:t}=window.location;return `${o}${e}${t}`}function Qg(){let o=new Uint8Array(16);if(typeof crypto<"u"&&crypto.getRandomValues)crypto.getRandomValues(o);else for(let e=0;e<o.length;e++)o[e]=Math.floor(Math.random()*256);return Array.from(o,e=>e.toString(16).padStart(2,"0")).join("")}function Kg(o){try{window.sessionStorage.setItem(yn,o);}catch{}}function Hg(){try{return window.sessionStorage.getItem(yn)}catch{return null}}function $g(){try{window.sessionStorage.removeItem(yn);}catch{}}function Zg(o){o.delete(mu),o.delete(fu);let e=o.toString(),{pathname:t,search:i}=window.location;window.history.replaceState(null,"",`${t}${i}${e?`#${e}`:""}`);}var Jg={Banner:"Banner",Interstitial:"Interstitial",RewardedVideo:"RewardedVideo",RewardedInterstitial:"RewardedInterstitial",AppOpen:"AppOpen",Native:"Native"},Cn=zod.z.enum(["Banner","Interstitial","RewardedVideo","RewardedInterstitial","AppOpen","Native"]),Yg={Top:"Top",Bottom:"Bottom",Left:"Left",Right:"Right"},Xg=zod.z.enum(["Top","Bottom","Left","Right"]),eR=zod.z.object({PlacementID:zod.z.string().nullish(),Type:Cn.nullish(),Enabled:zod.z.boolean().nullish(),CooldownSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish(),CreditsRewarded:zod.z.number().nullish(),AllowedProviderIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),tR=zod.z.object({DefaultCreditsPerView:zod.z.number().nullish(),MaxCreditsBalance:zod.z.number().nullish(),DailyCreditEarnCap:zod.z.number().nullish(),DailyViewCap:zod.z.number().nullish(),MinSecondsBetweenViews:zod.z.number().nullish()}).passthrough(),iR=zod.z.object({CooldownSeconds:zod.z.number().nullish(),MinSessionTimeBeforeFirstSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),rR=zod.z.object({Enabled:zod.z.boolean().nullish(),Position:Xg.nullish(),RefreshIntervalSeconds:zod.z.number().nullish()}).passthrough(),sR=zod.z.object({Enabled:zod.z.boolean().nullish(),CooldownSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish()}).passthrough(),nR=zod.z.object({MaxImpressionsPerHour:zod.z.number().nullish(),MaxImpressionsPerDay:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),oR=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),DisableInterstitials:zod.z.boolean().nullish(),DisableBanners:zod.z.boolean().nullish(),DisableAppOpen:zod.z.boolean().nullish()}).passthrough(),aR=zod.z.object({RequirePersonalizedAdsConsent:zod.z.boolean().nullish(),RequireTrackingConsent:zod.z.boolean().nullish(),CurrentPolicyVersion:zod.z.string().nullish(),RegulatedRegions:zod.z.array(zod.z.string()).nullish()}).passthrough(),lR=zod.z.object({RequireServerSideVerification:zod.z.boolean().nullish(),PendingRequestTtlSeconds:zod.z.number().nullish(),MaxPendingRequestsPerUser:zod.z.number().nullish(),ProviderPublicKeys:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),uR=zod.z.object({AndroidUnitID:zod.z.string().nullish(),IosUnitID:zod.z.string().nullish(),WebUnitID:zod.z.string().nullish(),Type:Cn.nullish()}).passthrough(),cR=zod.z.object({ProviderID:zod.z.string().nullish(),Enabled:zod.z.boolean().nullish(),Priority:zod.z.number().nullish(),AndroidAppID:zod.z.string().nullish(),IosAppID:zod.z.string().nullish(),WebAppID:zod.z.string().nullish(),Units:zod.z.record(zod.z.string(),uR).nullish()}).passthrough();zod.z.object({Enabled:zod.z.boolean().nullish(),Placements:zod.z.record(zod.z.string(),eR).nullish(),Providers:zod.z.record(zod.z.string(),cR).nullish(),RewardedVideo:tR.nullish(),Interstitial:iR.nullish(),Banner:rR.nullish(),AppOpen:sR.nullish(),FrequencyCapping:nR.nullish(),PremiumAdReductions:zod.z.array(oR).nullish(),Consent:aR.nullish(),Verification:lR.nullish()}).passthrough();var pR=zod.z.object({RewardedVideoCredit:zod.z.number().nullish(),TotalEarned:zod.z.number().nullish(),TotalSpent:zod.z.number().nullish()}).passthrough(),dR=zod.z.object({PlacementID:zod.z.string().nullish(),LastShownAt:u.nullish(),LastCompletedAt:u.nullish(),TotalImpressions:zod.z.number().nullish(),TotalCompletions:zod.z.number().nullish(),ConsecutiveFailures:zod.z.number().nullish()}).passthrough(),hR=zod.z.object({Date:u.nullish(),ImpressionsByPlacement:zod.z.record(zod.z.string(),zod.z.number()).nullish(),CompletionsByPlacement:zod.z.record(zod.z.string(),zod.z.number()).nullish(),TotalImpressions:zod.z.number().nullish(),InterstitialImpressions:zod.z.number().nullish(),RewardedCompletions:zod.z.number().nullish(),AppOpenImpressions:zod.z.number().nullish(),CreditsEarnedToday:zod.z.number().nullish()}).passthrough(),mR=zod.z.object({SessionID:zod.z.string().nullish(),SessionStartAt:u.nullish(),Impressions:zod.z.number().nullish(),InterstitialImpressions:zod.z.number().nullish(),RewardedCompletions:zod.z.number().nullish()}).passthrough(),fR=zod.z.object({PersonalizedAdsConsent:zod.z.boolean().nullish(),TrackingConsent:zod.z.boolean().nullish(),PolicyVersion:zod.z.string().nullish(),Region:zod.z.string().nullish(),ConsentGivenAt:u.nullish(),ConsentRevokedAt:u.nullish()}).passthrough(),gR=zod.z.object({RequestID:zod.z.string().nullish(),PlacementID:zod.z.string().nullish(),ProviderID:zod.z.string().nullish(),Type:Cn.nullish(),IssuedAt:u.nullish(),ExpiresAt:u.nullish(),CreditsToAward:zod.z.number().nullish()}).passthrough(),RR=zod.z.object({InvalidSsvCount:zod.z.number().nullish(),OrphanCompletions:zod.z.number().nullish(),FastCompletions:zod.z.number().nullish(),LastFlaggedAt:u.nullish()}).passthrough();zod.z.object({Credits:pR.nullish(),Placements:zod.z.record(zod.z.string(),dR).nullish(),Daily:hR.nullish(),Session:mR.nullish(),LastImpressionAt:u.nullish(),LastInterstitialAt:u.nullish(),LastRewardedAt:u.nullish(),LastAppOpenAt:u.nullish(),TotalImpressions:zod.z.number().nullish(),TotalRewardedCompletions:zod.z.number().nullish(),AdsDisabledUntil:u.nullish(),Consent:fR.nullish(),PendingRequests:zod.z.record(zod.z.string(),gR).nullish(),FraudFlags:RR.nullish(),UpdatedAt:u.nullish()}).passthrough();var yR={Unread:"Unread",Read:"Read",Deleted:"Deleted",Expired:"Expired"},CR=zod.z.enum(["Unread","Read","Deleted","Expired"]),SR={Admin:"Admin",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season",Collection:"Collection",MilestoneEvent:"MilestoneEvent",PlayerGift:"PlayerGift",Social:"Social",Compensation:"Compensation",Referral:"Referral",Quest:"Quest"},xR=zod.z.enum(["Admin","Leaderboard","CoopEvent","Season","Collection","MilestoneEvent","PlayerGift","Social","Compensation","Referral","Quest"]),DR={Active:"Active",Paused:"Paused",Cancelled:"Cancelled",Completed:"Completed"},bR=zod.z.enum(["Active","Paused","Cancelled","Completed"]),zR=zod.z.object({MessageTypeID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),IconPath:zod.z.string().nullish(),DisplayPriority:zod.z.number().nullish(),ExpirationHours:zod.z.number().nullish(),AutoClaim:zod.z.boolean().nullish(),AllowP2P:zod.z.boolean().nullish(),ShowBadge:zod.z.boolean().nullish()}).passthrough(),TR=zod.z.object({SegmentID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Gate:_.nullish()}).passthrough();zod.z.object({MaxMessagesPerUser:zod.z.number().nullish(),ReadNoRewardRetentionHours:zod.z.number().nullish(),ClaimedRetentionHours:zod.z.number().nullish(),DefaultPageSize:zod.z.number().nullish(),EnableAutoClaim:zod.z.boolean().nullish(),MessageTypes:zod.z.record(zod.z.string(),zR).nullish(),Segments:zod.z.array(TR).nullish(),DailyP2PGiftLimit:zod.z.number().nullish(),MaxRewardsPerP2PMessage:zod.z.number().nullish()}).passthrough();zod.z.object({MessageID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),RecipientUserID:zod.z.string().nullish(),MessageTypeID:zod.z.string().nullish(),Source:xR.nullish(),RelatedEntityID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderPublicData:be.nullish(),Subject:zod.z.string().nullish(),Body:zod.z.string().nullish(),TemplateParams:zod.z.record(zod.z.string(),zod.z.string()).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rewards:L.nullish(),Claimed:zod.z.boolean().nullish(),ClaimedAtUtc:u.nullish(),Status:CR.nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),ReadAtUtc:u.nullish(),BroadcastID:zod.z.string().nullish(),Version:zod.z.number().nullish()}).passthrough();zod.z.object({BroadcastID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),MessageTypeID:zod.z.string().nullish(),Subject:zod.z.string().nullish(),Body:zod.z.string().nullish(),TemplateParams:zod.z.record(zod.z.string(),zod.z.string()).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rewards:L.nullish(),TargetSegmentID:zod.z.string().nullish(),TargetUserIDs:zod.z.array(zod.z.string()).nullish(),StartsAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),CreatedAtUtc:u.nullish(),CreatedByAdminID:zod.z.string().nullish(),AdminComment:zod.z.string().nullish(),Status:bR.nullish(),DeliveredCount:zod.z.number().nullish(),ClaimedCount:zod.z.number().nullish()}).passthrough();zod.z.object({UnreadCount:zod.z.number().nullish(),UnclaimedRewardCount:zod.z.number().nullish(),LastFetchCursor:u.nullish(),ReceivedBroadcastIDs:zod.z.array(zod.z.string()).nullish(),ClaimedBroadcastIDs:zod.z.array(zod.z.string()).nullish(),DailyP2PGiftsSent:zod.z.number().nullish(),DailyGiftsResetDate:u.nullish(),LastOpenedAtUtc:u.nullish(),TotalMessagesReceived:zod.z.number().nullish(),TotalRewardsClaimed:zod.z.number().nullish()}).passthrough();var gu="idos_device_id",ss=class{storage;constructor(e=new St){this.storage=e;}getPlatform(){return "Web"}getFullURL(){return ""}getStartParameter(){return null}getTelegramInitDataRaw(){return null}getDeviceID(){let e=this.storage.getString(gu);return e||(e="noop-device",this.storage.setString(gu,e)),e}getDeviceModel(){return "Noop"}shareLink(){}openInvoice(){}async showAd(){}async copyToClipboard(){}};
|
|
2
|
+
exports.AdType=Jg;exports.AttackOutcome=Ff;exports.AuthType=me;exports.AuthenticationAction=Oe;exports.BannerPosition=Yg;exports.BlockchainAction=we;exports.BlockchainNetworkType=Np;exports.BlockchainOperationCategory=ko;exports.BlockchainTransactionStatus=$p;exports.BlockchainTransactionType=_p;exports.BodyPart=Cd;exports.BoostWindowKind=Of;exports.BroadcastStatus=DR;exports.BrowserPlatformAdapter=Dt;exports.BrowserStorage=Ct;exports.CharacterAction=Me;exports.ClientPlatform=He;exports.CloudCodeAction=Rn;exports.CloudCodeErrorCode=qg;exports.CloudCodeLogLevel=Bg;exports.CloudCodeRevisionSelection=Ug;exports.CollectionAction=Te;exports.CommissionSink=Ed;exports.CommunityChestMemberStatus=fg;exports.CommunityChestStatus=mg;exports.ConversionRateMode=gp;exports.CoopEventAction=We;exports.CoopGroupStatus=Em;exports.CoopMemberStatus=Gm;exports.CraftAction=wr;exports.CraftType=zm;exports.CurrencyAction=Vi;exports.CurrencyStatus=fp;exports.CurrencyType=je;exports.CustomDataBucket=tt;exports.CustomDataValueType=np;exports.CustomDataWriter=tp;exports.DEFAULT_BASE_URL=xn;exports.DealNodeRuntimeStatus=Zm;exports.DealOfferAction=Ye;exports.DealOfferActivationStatus=$m;exports.EnvelopeType=Pg;exports.EventTokenType=Du;exports.FodderSelectionMode=uh;exports.FodderValuationMode=ah;exports.FriendActionStatus=Sf;exports.GameLoopAction=Se;exports.IDosGamesClient=rs;exports.IapProductType=Th;exports.IapPurchaseStatus=kh;exports.IapStoreValues=xu;exports.ItemAction=sr;exports.KycStatus=Wp;exports.KycTier=Kp;exports.LeaderboardAction=xe;exports.LocalizationAction=tr;exports.LocalizationMissingKeyMode=ih;exports.LootboxAction=pr;exports.MailboxMessageSource=SR;exports.MailboxMessageStatus=yR;exports.MarketGoodsType=Ji;exports.MarketOfferStatus=qd;exports.MarketOfferType=Ld;exports.MarketplaceAction=ae;exports.MatchAction=Je;exports.MatchStatus=Sd;exports.MemoryStorage=St;exports.MultiplayerAction=Ne;exports.MultiplayerChatMode=zg;exports.MultiplayerTopology=bg;exports.NoopPlatformAdapter=ss;exports.PremiumAction=ft;exports.PurchaseAction=Mt;exports.QuestAction=Ve;exports.QuestObjectiveSource=Wu;exports.QuestPrerequisiteMode=Ku;exports.QuestStatus=Fu;exports.RaidMode=Nf;exports.ReferralAction=gt;exports.ResourceEntryType=Wt;exports.RewardAction=st;exports.RoomVisibility=Tg;exports.ScheduleMode=bu;exports.SeasonAction=pt;exports.SocialAction=Xe;exports.SpecialChoiceMode=jf;exports.StoreAction=kt;exports.StoreType=xm;exports.TimedBoostAction=Rt;exports.TimedBoostStackingPolicy=zf;exports.TimedEventAction=Ge;exports.TimelineEventType=xf;exports.TitleAction=yt;exports.TitleCustomDataAction=Vt;exports.TitleDataBucket=Bf;exports.TitleDataScope=Uf;exports.TradeOfferStatus=Pm;exports.TransactionDirection=Zp;exports.TutorialAction=Be;exports.TutorialBoardAction=lc;exports.TutorialFlowStatus=nc;exports.TutorialGateMode=ku;exports.TutorialRestartPolicy=rc;exports.TutorialScriptModule=ac;exports.TutorialStepCompletionMode=tc;exports.TypedEmitter=Lt;exports.UserAction=Ee;exports.UserCustomDataAction=_e;exports.WalletLinkType=Fp;exports.beginSsoRedirect=_g;exports.createIDosGamesClient=jg;exports.isFail=Tu;exports.isOk=zu;exports.normalizeBlockchainCategory=Qi;exports.readSsoCodeFromUrl=Vg;exports.zPaymentProof=vp;exports.zPriceOption=fo;exports.zPriceOptions=Y;
|