@idosgames/core 0.5.0 → 0.5.1
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/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var zod=require('zod'),Ft=require('decimal.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Ft__default=/*#__PURE__*/_interopDefault(Ft);var bt=class{listeners=new Map;on(e,t){let s=this.listeners.get(e);return s||(s=new Set,this.listeners.set(e,s)),s.add(t),()=>{this.off(e,t);}}once(e,t){let s=this.on(e,r=>{s(),t(r);});return s}off(e,t){let s=this.listeners.get(e);s&&(s.delete(t),s.size===0&&this.listeners.delete(e));}emit(e,t){let s=this.listeners.get(e);if(s)for(let r of [...s])r(t);}removeAllListeners(){this.listeners.clear();}};function xl(){let a=new Map;return {get:e=>a.get(e)??null,set:(e,t)=>{a.set(e,t);},remove:e=>{a.delete(e);}}}function Qi(){return Dl()??xl()}function Dl(){try{let a=globalThis.localStorage;if(!a)return null;let e="__idos_probe__";return a.setItem(e,"1"),a.removeItem(e),{get:t=>{try{return a.getItem(t)}catch{return null}},set:(t,s)=>{try{a.setItem(t,s);}catch{try{a.removeItem(t);}catch{}}},remove:t=>{try{a.removeItem(t);}catch{}}}}catch{return null}}var Hi="https://api.idosgames.com";function Ki(a){return {titleID:a.titleID,titleTemplateID:a.titleTemplateID??"default",buildKey:a.buildKey??"",baseUrl:(a.baseUrl??Hi).replace(/\/+$/,""),devBuild:a.devBuild??false,debugLogging:a.debugLogging??false,configStorage:a.configStorage??Qi()}}var ut=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{}}},ct=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 pt(){return globalThis.Telegram?.WebApp??null}function k(){return crypto.randomUUID()}var $i="idos_device_id",dt=class{storage;constructor(e=new ut){this.storage=e;}getPlatform(){return pt()?.platform??"Web"}getFullURL(){return typeof location<"u"?location.href:""}getStartParameter(){let e=pt()?.initDataUnsafe?.start_param;return typeof e=="string"?e:null}getTelegramInitDataRaw(){let e=pt()?.initData;return e&&e.length>0?e:null}getDeviceID(){let e=this.storage.getString($i);return e||(e=k(),this.storage.setString($i,e)),e}getDeviceModel(){return typeof navigator<"u"&&navigator.userAgent?navigator.userAgent:"Web"}shareLink(e){let t=pt();if(t?.openTelegramLink){t.openTelegramLink(e);return}typeof window<"u"&&window.open(e,"_blank");}openInvoice(e){let t=pt();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 Zi(a){return {ok:true,data:a}}function n(a,e){return {ok:false,reason:a,error:e}}function bl(a){return a.ok}function vl(a){return !a.ok}var qe={Virtual:"Virtual",Crypto:"Crypto"},ht=zod.z.enum(["Virtual","Crypto"]),zl={Item:"Item",VirtualCurrency:"VirtualCurrency",CryptoCurrency:"CryptoCurrency",UsdCent:"UsdCent"},Ot=zod.z.enum(["Item","VirtualCurrency","CryptoCurrency","UsdCent"]),Tl={TimedEvent:"TimedEvent",Quest:"Quest",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season"},wt=zod.z.enum(["TimedEvent","Quest","Leaderboard","CoopEvent","Season"]),Pl={Cyclic:"Cyclic",Scheduled:"Scheduled",Chained:"Chained"},vt=zod.z.enum(["Cyclic","Scheduled","Chained"]),ue={None:"None",Device:"Device",Email:"Email",iDosGames:"iDosGames",Facebook:"Facebook",Google:"Google",GooglePlay:"GooglePlay",Telegram:"Telegram",Wallet:"Wallet"};var M=zod.z.union([zod.z.number(),zod.z.string()]).transform((a,e)=>{let t=typeof a=="string"?Number(a):a;return Number.isFinite(t)?Math.trunc(t):(e.addIssue({code:zod.z.ZodIssueCode.custom,message:`Invalid integer amount: ${String(a)}`}),zod.z.NEVER)}),B=zod.z.union([zod.z.number(),zod.z.string()]).transform((a,e)=>{let t=typeof a=="number"?String(a):a.trim();return t===""||Number.isNaN(Number(t))?(e.addIssue({code:zod.z.ZodIssueCode.custom,message:`Invalid decimal: ${String(a)}`}),zod.z.NEVER):t}),l=zod.z.string();var Er=zod.z.object({Type:Ot.nullish(),CurrencyID:zod.z.string().nullish(),Amount:M.nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish()}),Il=zod.z.object({Type:wt.nullish(),EntityID:zod.z.string()}),kl=zod.z.object({Address:Il.nullish(),Amount:M.nullish(),Source:zod.z.string().nullish()}),ce=zod.z.object({Entries:zod.z.array(Er).nullish(),EventTokens:zod.z.array(kl).nullish()}),Ji=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Resources:ce.nullish()}),G=zod.z.object({Standard:ce.nullish(),PremiumBonuses:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(Ji).nullish()}),K=zod.z.object({Standard:ce.nullish(),PremiumDiscounts:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(Ji).nullish()}),x=zod.z.object({Grant:G.nullish(),Consume:K.nullish()}),st=zod.z.object({FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),FromResult:x.nullish(),ToResult:x.nullish()});zod.z.object({FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),Transferred:ce.nullish()});var Ml=zod.z.object({ExperimentID:zod.z.string().nullish(),Variants:zod.z.array(zod.z.string()).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:Ml.nullish()}).passthrough();var de=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 Al=zod.z.object({OffsetSecondsFromParentStart:zod.z.number().nullish(),DurationSeconds:zod.z.number().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Ul=zod.z.object({StartUtc:zod.z.string().nullish(),EndUtc:zod.z.string().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Ol=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 wl=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 _e=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:de.nullish()}).passthrough(),pe=zod.z.object({Mode:zod.z.string().nullish(),IsActive:zod.z.boolean().nullish(),Scheduled:Ul.nullish(),Chain:Ol.nullish(),Cyclic:wl.nullish(),ActivationTriggers:zod.z.array(_e).nullish(),Relative:Al.nullish()}).passthrough();var Bl=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Rewards:G.nullish()}).passthrough(),ql=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),Lr=zod.z.object({Bundles:zod.z.array(Bl).nullish(),Multipliers:zod.z.array(ql).nullish()}).passthrough();var El=zod.z.enum(["BoardStageLevel","BoardRank","BoardCyclesCompleted","CharacterLevel","SeasonTier","EventTokenTotalEarned","VirtualCurrencyBalance","PlayerLevel"]);var Ll=zod.z.enum(["Tiered","Linear"]);var Gl=zod.z.enum(["Step","Linear"]),Nl=zod.z.object({AtProgress:zod.z.number().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),Bt=zod.z.object({Source:El.nullish(),SourceKey:zod.z.string().nullish(),CurveType:Ll.nullish(),Tiers:zod.z.array(Nl).nullish(),TierMode:Gl.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:ce.nullish(),ExcludeRewards:ce.nullish()}).passthrough(),ye=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:G.nullish(),BonusRewards:G.nullish(),SeasonTierRewards:Lr.nullish(),SortOrder:zod.z.number().nullish(),IsFeatured:zod.z.boolean().nullish()}).passthrough(),Xe=zod.z.object({Milestones:zod.z.record(zod.z.string(),ye).nullish()}).passthrough();var ne=zod.z.object({PresetID:zod.z.string().nullish(),Remove:zod.z.array(zod.z.string()).nullish()}).passthrough();var jl=zod.z.object({TargetCurrencyID:zod.z.string().nullish(),Rate:zod.z.number().nullish(),MaxConvertAmount:zod.z.number().nullish()}).passthrough(),rt=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:jl.nullish()}).passthrough();var re=a=>zod.z.object({Id:zod.z.string(),Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:a.nullish()}),Et=a=>zod.z.object({ServerTimeUtc:l,Items:zod.z.array(re(a)),Resources:x.nullish()});var Fl={Active:"Active",Completed:"Completed",Claimed:"Claimed",Expired:"Expired"},Yi=zod.z.enum(["Active","Completed","Claimed","Expired"]),Vl=zod.z.object({}).passthrough().transform(a=>a),_l=zod.z.object({CycleID:zod.z.string(),InstanceKey:zod.z.string().nullish(),PhaseID:zod.z.string().nullish(),CycleIndex:zod.z.number().nullish(),CycleStartUtc:l.nullish(),CycleEndUtc:l.nullish(),PointsTotalEarned:M.nullish(),PointsCurrent:M.nullish(),ClaimedPointMilestoneIDs:zod.z.array(zod.z.string()).nullish()}),Gr=zod.z.object({QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),ObjectiveID:zod.z.string().nullish(),NewValue:M.nullish(),ObjectiveCompleted:zod.z.boolean().nullish(),Status:Yi}),Xi=zod.z.object({State:Vl.nullish(),PointsTracks:zod.z.record(zod.z.string(),_l).nullish()}),Nr=zod.z.object({ServerTimeUtc:l,QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),NewStatus:Yi.nullish(),Resources:x.nullish()}),jr=zod.z.object({ServerTimeUtc:l,CycleID:zod.z.string(),MilestoneID:zod.z.string(),PointsTotalEarned:M.nullish(),Resources:x.nullish()}),en=zod.z.object({ServerTimeUtc:l,CycleID:zod.z.string(),GroupCompletionID:zod.z.string(),GroupID:zod.z.string().nullish(),CompletedGroupQuests:zod.z.number().nullish(),RequiredGroupQuests:zod.z.number().nullish(),Resources:x.nullish()}),tn=zod.z.object({MetricID:zod.z.string(),Updates:zod.z.array(Gr).nullish()}),sn=zod.z.array(re(Nr)),rn=zod.z.array(re(jr)),Wl={ClientApi:"ClientApi",ServerApi:"ServerApi",SystemEvent:"SystemEvent"},Ql=zod.z.enum(["ClientApi","ServerApi","SystemEvent"]),Hl={BlockProgressAndClaim:"BlockProgressAndClaim",BlockClaimOnly:"BlockClaimOnly"},Kl=zod.z.enum(["BlockProgressAndClaim","BlockClaimOnly"]),nn=zod.z.object({ObjectiveID:zod.z.string().nullish(),Source:Ql.nullish(),MaxProgressPerCall:zod.z.number().nullish(),MetricID:zod.z.string().nullish(),Triggers:zod.z.array(_e).nullish(),TargetValue:zod.z.number().nullish(),AggregationMethod:zod.z.string().nullish()}).passthrough(),Fr=zod.z.object({Milestones:ne.nullish(),Linking:ne.nullish(),Availability:ne.nullish(),Reward:ne.nullish(),Objectives:ne.nullish()}).passthrough(),$l=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(),on=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:Kl.nullish()}).passthrough(),an=zod.z.object({Schedule:pe.nullish(),AccrueProgressWhenLocked:zod.z.boolean().nullish(),Gate:Q.nullish(),Limits:de.nullish()}).passthrough(),ln=zod.z.object({Grant:G.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),Zl=zod.z.object({QuestID:zod.z.string().nullish(),Identity:$l.nullish(),Linking:on.nullish(),Availability:an.nullish(),Objectives:zod.z.record(zod.z.string(),nn).nullish(),Reward:ln.nullish(),Presets:Fr.nullish()}).passthrough(),Jl=zod.z.object({CompletionID:zod.z.string().nullish(),GroupID:zod.z.string().nullish(),RequiredCompletedQuests:zod.z.number().nullish(),Gate:Q.nullish(),Reward:G.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),Yl=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(),ye).nullish(),Presets:Fr.nullish(),PointsToken:rt.nullish()}).passthrough(),Xl=zod.z.object({Milestones:zod.z.record(zod.z.string(),Xe).nullish(),Linking:zod.z.record(zod.z.string(),on).nullish(),Availability:zod.z.record(zod.z.string(),an).nullish(),Reward:zod.z.record(zod.z.string(),ln).nullish(),Objectives:zod.z.record(zod.z.string(),zod.z.record(zod.z.string(),nn)).nullish()}).passthrough(),eu=zod.z.object({CycleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:pe.nullish(),Milestones:zod.z.record(zod.z.string(),ye).nullish(),Gate:Q.nullish(),PointsToken:rt.nullish(),GroupCompletions:zod.z.record(zod.z.string(),Jl).nullish(),Phases:zod.z.record(zod.z.string(),Yl).nullish(),Presets:Fr.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Lt=zod.z.object({Cycles:zod.z.record(zod.z.string(),eu).nullish(),Quests:zod.z.record(zod.z.string(),Zl).nullish(),Presets:Xl.nullish()}).passthrough(),Le={GetQuestDefinitions:"GetQuestDefinitions",GetUserQuestState:"GetUserQuestState",RefreshQuestCycles:"RefreshQuestCycles",ClaimQuestReward:"ClaimQuestReward",ClaimMilestoneReward:"ClaimMilestoneReward",AddQuestProgress:"AddQuestProgress",ClaimQuestRewardsBatch:"ClaimQuestRewardsBatch",ClaimMilestoneRewardsBatch:"ClaimMilestoneRewardsBatch",ClaimGroupCompletionReward:"ClaimGroupCompletionReward"};var Gt=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(),s=this.last.get(e);return s!==void 0&&t-s<this.windowMs?false:(this.last.set(e,t),true)}reset(){this.last.clear();}};var Nt=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(a){return a===429||a>=500&&a<=599}function Vr(a,e=Math.random){let t=Math.min(500*Math.pow(2,a-1),4e3),s=t*.2*(e()*2-1);return Math.max(50,t+s)}function _r(a){return new Promise(e=>setTimeout(e,a))}var tu=12e3,su=zod.z.object({Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:zod.z.unknown().optional(),QuestProgress:zod.z.array(Gr).nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish(),StateEpoch:zod.z.string().nullish()}).passthrough(),jt=class{baseUrl;emitter;fetchImpl;debugLogging;throttler;inflight=new Nt;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 Gt(e.throttleMs);}setSessionRefreshHandler(e){this.sessionRefreshHandler=e;}async post(e,t,s,r={}){if(!this.throttler.tryAcquire(e))return n("throttled","Throttled");if(!this.inflight.add(e))return n("throttled","Duplicate request skipped");this.raiseBusy();try{let i=`${this.baseUrl}/${e}`,c=JSON.stringify(t),d=r.ticket??null,v=r.silent??!1,w=r.timeoutMs??tu,q=r.autoRetry??!0,se=!1,ge=0;for(;;){let ke;try{ke=await this.doFetch(i,c,d,w);}catch{if(q&&ge<3){ge++,await _r(Vr(ge));continue}return this.connectionFailure("Internet Connection Error",v)}let Me=ke.status;if(Me>=200&&Me<300)return await this.parseSuccess(ke,s,v,e);if(Me===401){if(!se&&this.sessionRefreshHandler){se=!0;let Je=null;try{Je=await this.sessionRefreshHandler();}catch{Je=null;}if(Je){d=Je;continue}}return this.emitter.emit("auth:unauthorized",void 0),n("unauthorized","Unauthorized")}if(un(Me)){if(q&&ge<3){ge++,await _r(Vr(ge));continue}return this.connectionFailure(`Server temporarily unavailable (HTTP ${Me})`,v)}return await this.handleWebError(ke,Me,v)}}finally{this.inflight.remove(e),this.lowerBusy();}}async doFetch(e,t,s,r){let i=new AbortController,c=setTimeout(()=>{i.abort();},r);try{let d={"Content-Type":"application/json"};return s&&(d.Authorization=`Bearer ${s}`),await this.fetchImpl(e,{method:"POST",body:t,headers:d,signal:i.signal})}finally{clearTimeout(c);}}async parseSuccess(e,t,s,r){let i;try{i=await e.text();}catch{return this.globalError("Failed to read response body",s)}let c;try{c=JSON.parse(i);}catch{return this.globalError("JSON Parse Error",s)}let d=su.safeParse(c);if(!d.success)return this.globalError("Malformed response envelope",s);if(!d.data.Success){let se=d.data.Error??"Server returned Success=false";return s||this.emitter.emit("error:global",se),n("server",se)}let v=d.data.QuestProgress;v&&v.length>0&&this.emitter.emit("quest:systemProgress",v);let w=d.data.StateVersions;w&&Object.keys(w).length>0&&this.emitter.emit("user:stateVersions",{epoch:d.data.StateEpoch??null,versions:w});let q=t.safeParse(d.data.Data);if(!q.success){let se=`Validation error (${r}): ${q.error.message}`;return this.debugLogging&&console.warn("[HttpTransport]",se),s||this.emitter.emit("error:global",se),n("validation",se)}return Zi(q.data)}async handleWebError(e,t,s){let r=`HTTP ${t}`;try{let i=await e.text();if(i)try{let d=JSON.parse(i).Error;r=typeof d=="string"&&d.length>0?`HTTP ${t}: ${d}`:`HTTP ${t}: ${i}`;}catch{r=`HTTP ${t}: ${i}`;}}catch{}return s||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 ft(a){return (typeof a=="string"?a:a.toISOString()).slice(0,10)}function zt(a){return `${ft(a)}T00:00:00.000Z`}function pn(a){let e=new Date(a);return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+1)).toISOString()}function dn(a,e){return new Date(a.getTime()+e*6e4).toISOString()}function hn(a,e,t,s){let r={vcChanged:false,ccChanged:false,itemsChanged:false,tokensChanged:false};if(!e)return r;a.InventoryV2??={};let i=a.InventoryV2,c=s.toISOString(),d=new Map,v=new Map,w=new Map,q=new Map,se=new Map,ge=new Map,ke=new Map,Me=new Map,Je=e.Grant?.PremiumTiers??[],At=Je.length;for(let te=0;;te++){let le,H;if(te===0)le=e.Grant?.Standard?.Entries,H=false;else if(te-1<At)le=Je[te-1]?.Resources?.Entries,H=false;else if(te===1+At)le=e.Consume?.Standard?.Entries,H=true;else break;if(le)for(let j of le){if(j.Type==null)continue;let _=Math.max(0,j.Amount??0);if(!(_<=0))switch(j.Type){case "VirtualCurrency":{if(!j.CurrencyID)continue;let W=H?v:d;W.set(j.CurrencyID,(W.get(j.CurrencyID)??0)+_);break}case "CryptoCurrency":{if(!j.CurrencyID)continue;let W=H?q:w;W.set(j.CurrencyID,(W.get(j.CurrencyID)??new Ft__default.default(0)).plus(_));break}case "Item":{if(!j.ItemID)continue;let W=iu(t,j.CatalogID,j.ItemID),X=(W?W.IsStackable??true:true)?H?ge:se:H?Me:ke;X.set(j.ItemID,(X.get(j.ItemID)??0)+_);break}case "UsdCent":continue}}}if(r.vcChanged=d.size>0||v.size>0,r.vcChanged){i.VirtualCurrencies??={};for(let te of new Set([...d.keys(),...v.keys()])){let le=d.get(te)??0,H=v.get(te)??0,j=le-H,_=i.VirtualCurrencies[te];_?(_.Amount+=j,_.UpdatedAt=c,_.Daily&&ft(_.Daily.PeriodStartUtc)===ft(s)?(_.Daily.Earned+=le,_.Daily.Spent+=H):_.Daily={PeriodStartUtc:zt(s),Earned:le,Spent:H}):i.VirtualCurrencies[te]={Amount:j,CreatedAt:c,UpdatedAt:c,Daily:{PeriodStartUtc:zt(s),Earned:le,Spent:H}};}}if(r.ccChanged=w.size>0||q.size>0,r.ccChanged){i.CryptoCurrencies??={};for(let te of new Set([...w.keys(),...q.keys()])){let le=w.get(te)??new Ft__default.default(0),H=q.get(te)??new Ft__default.default(0),j=le.minus(H),_=i.CryptoCurrencies[te];_?(_.Amount=new Ft__default.default(_.Amount).plus(j).toString(),_.UpdatedAt=c):i.CryptoCurrencies[te]={Amount:j.toString(),Frozen:"0",CreatedAt:c,UpdatedAt:c};}}if(r.itemsChanged=se.size>0||ge.size>0||ke.size>0||Me.size>0,r.itemsChanged){i.Items??={},i.UnstackableItems??={};let te=i.UnstackableItems,le=new Set([...se.keys(),...ge.keys(),...ke.keys(),...Me.keys()]);for(let H of le){let j=(se.get(H)??0)-(ge.get(H)??0),_=(ke.get(H)??0)-(Me.get(H)??0),W=j+_,Ae=i.Items[H];Ae?(j!==0&&(Ae.StackableAmount+=j),_!==0&&(Ae.UnstackableAmount+=_),W!==0&&(Ae.TotalAmount+=W)):i.Items[H]={StackableAmount:Math.max(0,j),UnstackableAmount:Math.max(0,_),TotalAmount:Math.max(0,W)};}for(let[H,j]of Me){if(j<=0)continue;let _=Object.values(te).filter(W=>W.ItemID===H&&W.EquippedSlot==null&&(W.ExpiresAt==null||new Date(W.ExpiresAt)>s)).sort(ru).slice(0,j).map(W=>W.ItemInstanceID);for(let W of _)delete te[W];}for(let[H,j]of ke){let _=nu(t,H);for(let W=0;W<j;W++){let Ae=k();te[Ae]={ItemInstanceID:Ae,ItemID:H,CatalogID:_,RemainingUses:1,AcquiredAt:c};}}}a.EventToken??={};let Sl=a.EventToken;for(let te=0;;te++){let le,H;if(te===0)le=e.Grant?.Standard?.EventTokens,H=false;else if(te-1<At)le=Je[te-1]?.Resources?.EventTokens,H=false;else if(te===1+At)le=e.Consume?.Standard?.EventTokens,H=true;else break;if(!(!le||le.length===0))for(let j of le){let _=j.Address;if(!_||_.Type==null)continue;let W=j.Amount??0;if(W<=0)continue;let Ae=ou(Sl,_.Type);if(!Ae)continue;let X=Ae[_.EntityID];X||(X={},Ae[_.EntityID]=X),X.Balance??={Current:0,TotalEarned:0,TotalSpent:0},X.Daily??={Date:zt(s),TotalEarned:0},X.Meta??={};let Dt=j.Source&&j.Source.length>0?j.Source:"CustomAction";H?(X.Balance.Current-=W,X.Balance.TotalSpent+=W):(X.Balance.Current+=W,X.Balance.TotalEarned+=W,ft(X.Daily.Date)!==ft(s)&&(X.Daily={Date:zt(s),TotalEarned:0}),X.Daily.TotalEarned+=W,X.Daily.EarnedBySource??={},X.Daily.EarnedBySource[Dt]=(X.Daily.EarnedBySource[Dt]??0)+W,X.Daily.TriggersBySource??={},X.Daily.TriggersBySource[Dt]=(X.Daily.TriggersBySource[Dt]??0)+1,X.Daily.LastTriggerBySource??={},X.Daily.LastTriggerBySource[Dt]=c,X.Meta.JoinedAtUtc||(X.Meta.JoinedAtUtc=c),X.Meta.LastEarnedAtUtc=c),r.tokensChanged=true;}}return r}function ru(a,e){return a.AcquiredAt!==e.AcquiredAt?a.AcquiredAt<e.AcquiredAt?-1:1:a.ItemInstanceID===e.ItemInstanceID?0:a.ItemInstanceID<e.ItemInstanceID?-1:1}function iu(a,e,t){let s=a?.Catalogs;if(s){if(e){let r=s[e]?.Items?.[t];if(r)return r}for(let r of Object.values(s)){let i=r.Items?.[t];if(i)return i}}}function nu(a,e){let t=a?.Catalogs;if(t){for(let[s,r]of Object.entries(t))if(r.Items&&e in r.Items)return s}}function ou(a,e){switch(e){case "TimedEvent":return a.TimedEvent??={};case "Quest":return a.Quest??={};case "Leaderboard":return a.Leaderboard??={};case "CoopEvent":return a.CoopEvent??={};case "Season":return a.Season??={};default:return null}}function Wr(a,e){return a===e||a.startsWith(`${e}:`)}var Vt=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 s of t)this.currentState[s]=e[s];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,s=new Date){if(!this.currentState)return;let r=hn(this.currentState,e,t,s);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,s){if(!e||!this.currentState)return;this.currentState.InventoryV2??={},this.currentState.InventoryV2.CryptoCurrencies??={};let r=this.currentState.InventoryV2.CryptoCurrencies,i=t instanceof Ft__default.default?t:new Ft__default.default(t),c=s??new Date().toISOString(),d=r[e];d?(d.Amount=new Ft__default.default(d.Amount).plus(i).toString(),d.UpdatedAt=c):r[e]={Amount:i.toString(),Frozen:"0",CreatedAt:c,UpdatedAt:c},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,s){if(!e||t<1||!this.currentState)return;this.currentState.Store??={},this.currentState.Store.Purchases??={};let r=this.currentState.Store.Purchases,i=r[e];i||(i={OfferID:e,TotalPurchases:0,DailyPurchases:0,DailyResetUtc:"",LastPurchasedAt:""},r[e]=i),i.TotalPurchases+=t,i.LastPurchasedAt=s,s>=i.DailyResetUtc?(i.DailyPurchases=t,i.DailyResetUtc=pn(s)):i.DailyPurchases+=t,this.emitter.emit("user:storeUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyLootboxPityTriggers(e,t,s){if(!e||s<=0)return;this.currentState??={};let r=this.currentState.Lootbox??={};if(r.Pity??={},t){let i=new Date().toISOString();for(let c of t)c.RuleID&&(r.Pity[`${e}:${c.RuleID}`]={OpensSinceLastTrigger:0,LastTriggeredAtUtc:i});}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,s){if(!e)return;this.currentState??={},this.currentState.Quest??={};let r=this.currentState.Quest;if(t){r.Cycles??={};let i=r.Cycles[t];if(!i)return;i.Quests??={};let c=i.Quests[e]??={QuestID:e,Status:s};c.Status=s,s==="Claimed"&&(c.ClaimedAtUtc??=new Date().toISOString());}else {r.PermanentQuests??={};let i=r.PermanentQuests[e]??={QuestID:e,Status:s};i.Status=s,s==="Claimed"&&(i.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 s=this.getQuestPointsProgress(e);s&&(s.Milestone??={},s.Milestone.ClaimedIDs??=[],s.Milestone.ClaimedIDs.includes(t)||s.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 s of Object.values(e)){if(!s.CycleID)continue;let r=s.InstanceKey?`${s.CycleID}:${s.InstanceKey}`:s.CycleID,i=t[r]??={};i.Balance??={Current:0,TotalEarned:0,TotalSpent:0},i.Balance.Current=s.PointsCurrent??0,i.Balance.TotalEarned=s.PointsTotalEarned??0,i.Milestone??={},i.Milestone.ClaimedIDs=s.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 s=this.currentState.Quest.Cycles[e];s&&(s.ClaimedGroupCompletionIDs??=[],s.ClaimedGroupCompletionIDs.includes(t)||s.ClaimedGroupCompletionIDs.push(t),this.emitter.emit("user:questUpdated",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 s of e){if(!s.QuestID)continue;let r;if(!s.CycleID)t.PermanentQuests??={},r=t.PermanentQuests[s.QuestID]??={QuestID:s.QuestID,Status:s.Status};else {t.Cycles??={};let i=t.Cycles[s.CycleID];if(!i)continue;i.Quests??={},r=i.Quests[s.QuestID]??={QuestID:s.QuestID,Status:s.Status};}if(r.Status=s.Status,s.ObjectiveID){r.Objectives??={};let i=r.Objectives[s.ObjectiveID]??={ObjectiveID:s.ObjectiveID,CurrentValue:0,Completed:false};i.CurrentValue=s.NewValue??0,s.ObjectiveCompleted&&(i.Completed=true,i.CompletedAtUtc??=new Date().toISOString());}s.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[s,r]of Object.entries(t))if(Wr(s,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,s){if(!(!t||!s)){this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.TimedEvent??={};for(let[r,i]of Object.entries(this.currentState.EventToken.TimedEvent))!Wr(r,t)||!i||this.markMilestoneClaimed(i.Milestone??(i.Milestone={}),s);this.patchActiveEventMilestoneClaimed(e,t,s),this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}}patchActiveEventMilestoneClaimed(e,t,s){let r=this.activeEventsCache?.ActiveEvents;if(r)for(let i of r)i.Type!==e||i.TimedEventID!==t||(i.Progress??={},this.markMilestoneClaimed(i.Progress.Milestone??(i.Progress.Milestone={}),s));}markMilestoneClaimed(e,t){if(e.ClaimedIDs??=[],e.ClaimedIDs.includes(t)||e.ClaimedIDs.push(t),e.UnlockedIDs){let s=e.UnlockedIDs.indexOf(t);s>=0&&e.UnlockedIDs.splice(s,1);}}patchLeaderboardMyProgress(e,t){if(!e||!t)return;let s=this.ensureLeaderboardProgress(e);s.CurrentScore=t.CurrentScore??0,s.LastKnownRank=t.LastKnownRank??0,s.ScoreEarnedThisCycle=t.ScoreEarnedThisCycle??0,s.UnclaimedRewardCycleVersion=t.HasUnclaimedReward?Math.max(1,s.UnclaimedRewardCycleVersion??0):0,this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchLeaderboardScoreSubmitted(e,t,s,r){if(!e)return;let i=this.ensureLeaderboardProgress(e);(i.ScoreCycleVersion??0)<r&&(i.ScoreEarnedThisCycle=0,i.ClaimedMilestoneIDs=[],i.BracketID=null),i.CurrentScore=t,i.ScoreEarnedThisCycle=(i.ScoreEarnedThisCycle??0)+s,i.ScoreCycleVersion=r,i.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 s=this.ensureLeaderboardProgress(e);s.ClaimedMilestoneIDs??=[],s.ClaimedMilestoneIDs.includes(t)||s.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,s=t[e];return s||(s={CurrentScore:0,ScoreEarnedThisCycle:0,ScoreCycleVersion:0,UnclaimedRewardCycleVersion:0,LastKnownRank:0},t[e]=s),s}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 s=this.ensureSeasonState(e);s.CurrentTier=t,this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSeasonClaimedTier(e,t){if(!e)return;let s=this.ensureSeasonState(e);s.ClaimedTierRewards??=[],s.ClaimedTierRewards.includes(t)||s.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,s=t[e];return s||(s={SeasonChainID:e},t[e]=s),s}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 s=this.currentState.Character.Characters,r=s[e];r||(r={CharacterID:e},s[e]=r),t(r),this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCharacterEquipment(e,t,s){if(!e||!t)return;let r=this.currentState?.Character?.Characters?.[e];r&&(r.Equipment??={},s===null?delete r.Equipment[t]:r.Equipment[t]=s,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,s=false;for(let[r,i]of Object.entries(e.ChangedInstances??{}))t[r]=i,s=true;for(let r of e.RemovedInstanceIDs??[])r in t&&(delete t[r],s=true);s&&(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,s){this.currentState??={};let r=this.currentState.CoopEvent??={MyObjectIndex:-1};r.ActiveGroupID=e,r.ActiveCoopEventID=t,r.MyObjectIndex=s,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(s=>s!==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(s=>s!==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(s=>s!==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 s=this.currentState.TimedBoost.Active;if(t==="Replace"||t==="KeepBest")for(let r of Object.keys(s)){let i=s[r];i&&i.BoostID===e.BoostID&&r!==e.InstanceID&&delete s[r];}s[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,s,r,i){if(!t)return;this.currentState??={},this.currentState.CustomData??={};let c=this.currentState.CustomData,d={Value:s,UpdatedAt:new Date().toISOString(),Version:r,LastWriter:"Client",ExpiresAt:i??null};if(e==="Private")c.Private??={},c.Private[t]=d;else if(e==="Public")c.Public??={},c.Public[t]=d;else return;c.Version=(c.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 s=this.currentState.CustomData;if(e==="Private")s.Private&&delete s.Private[t];else if(e==="Public")s.Public&&delete s.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 s=this.ensureBoard();s.BuildingStates??=[];let r=s.BuildingStates.find(i=>i.SlotIndex===e);r||(r={SlotIndex:e},s.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 s=this.ensureBoard().Pending;!s||s.Type.toUpperCase()!=="SPECIAL"||(s.Special??={},e(s.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 _t=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 Wt=class{user;config;constructor(e){this.user=new Vt(e),this.config=new _t;}reset(){this.user.clear(),this.config.applyTitlePublicConfiguration(null);}};var Qt=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 au(e)?e:ue.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 au(a){return a!==null&&Object.values(ue).includes(a)}var lu=8,uu=100,cu=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i,mn=["GameLoop"],Ht=class{constructor(e){this.ctx=e;}ctx;authContext=null;refreshing=false;rememberSession=true;sessionAuthType=ue.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(ue.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 s=await this.ctx.api.authentication.loginWithTelegram(t);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(ue.Telegram)):s}async loginWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let s=this.baseRequest();s.Email=e,s.Password=t;let r=await this.ctx.api.authentication.loginWithEmail(s);if(!r.ok)return r;this.applyAuthContext(r.data);let i=await this.fetchAndApplyClientState(ue.Email);return i.ok&&this.keepEmailCredentials(e,t),i}async registerWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let s=this.baseRequest();s.Email=e,s.Password=t,s.DeviceID=this.ctx.platform.getDeviceID(),s.Device=this.ctx.platform.getDeviceModel(),s.Platform=this.ctx.platform.getPlatform();let r=await this.ctx.api.authentication.registerWithEmail(s);if(!r.ok)return r;this.applyAuthContext(r.data);let i=await this.fetchAndApplyClientState(ue.Email);return i.ok&&this.keepEmailCredentials(e,t),i}async loginWithGoogle(e){this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.GoogleIDToken=e;let s=await this.ctx.api.authentication.loginWithGoogle(t);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(ue.Google)):s}async requestWalletChallenge(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let s=this.baseRequest();return s.WalletAddress=e,s.NetworkID=t,this.ctx.api.authentication.requestWalletChallenge(s)}async loginWithWallet(e,t,s){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();r.WalletAddress=e,r.NetworkID=t,r.WalletSignature=s,r.Platform=this.ctx.platform.getPlatform(),r.Device=this.ctx.platform.getDeviceModel(),r.DeviceID=this.ctx.platform.getDeviceID();let i=await this.ctx.api.authentication.loginWithWallet(r);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(ue.Wallet)):i}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 s=await this.ctx.api.authentication.loginWithPlatformToken(t);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(ue.iDosGames)):s}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 s=await this.ctx.api.authentication.loginWithSsoCode(t);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(ue.iDosGames)):s}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,s){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();return r.Email=e,r.ResetToken=t,r.Password=s,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,s){switch(e){case ue.Email:return this.loginWithEmail(t,s);case ue.Device:case ue.None:return this.loginWithDeviceID();case ue.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!==ue.None?this.sessionAuthType:this.ctx.authStore.lastAuthType;if(e===ue.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&&cu.test(e)}static isValidPasswordLength(e){return e.length>=lu&&e.length<=uu}keepEmailCredentials(e,t){this.sessionEmail=e,this.sessionPassword=t,this.rememberSession&&this.ctx.authStore.saveEmailAndPassword(e,t);}forgetSession(){this.sessionAuthType=ue.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(mn,mn);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 pu="idos:cfg",gt=class{constructor(e,t){this.storage=e;this.titleId=t;}storage;titleId;static scopeOf(e,t){return t&&t.length>0?`x:${fn(t)}`:e&&e.length>0?`f:${fn(e)}`:t?"x:":"f:"}async read(e){try{let t=await this.storage.get(this.keyOf(e));if(!t)return null;let s=JSON.parse(t);return !s||typeof s!="object"||typeof s.v!="string"||!s.c?null:s}catch{return null}}async write(e,t,s){try{let r={v:t,c:s};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 `${pu}:${this.titleId}:${e}`}};function fn(a){return [...a].map(e=>e.toLowerCase()).sort().join(",")}var du="idos:state",Kt=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 s=JSON.parse(t);return !s||typeof s!="object"||typeof s.e!="string"||!s.v||!s.s?null:s}catch{return null}}async write(e,t,s,r){if(!(!e||!t))try{let i={e:t,v:s,s:r};await this.storage.set(this.keyOf(e),JSON.stringify(i));}catch{}}keyOf(e){return `${du}:${this.titleId}:${e}`}};function hu(a,e){if(!a)return;let t=new Set((e??[]).map(r=>r.trim().toLowerCase()));if(t.size===0)return a;let s={};for(let[r,i]of Object.entries(a))t.has(r.toLowerCase())||(s[r]=i);return s}function Hr(a,e,t,s){let r={...a??{}};if(!e||!t||!s)return r;for(let[i,c]of Object.entries(t))s[i]===c&&i in e&&(r[i]=e[i]);return r}function mu(a){return {...a??{}}}function Kr(a){return typeof a.StateEpoch=="string"&&a.StateEpoch.length>0?a.StateEpoch:null}var $t=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=hu(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[s,r]of Object.entries(t)){let i=this.versions[s];i!==void 0&&r===i+1?this.versions[s]=r:delete this.versions[s],this.dirty=true;}}afterFullRead(e,t){e!==this.epoch&&this.reset(e),this.versions=mu(t),this.dirty=true;}afterSliceRead(e,t){e!==this.epoch&&this.reset(e);for(let[s,r]of Object.entries(t??{}))this.versions[s]=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 gn=n("server","Title configuration is unavailable (CDN and API both failed)."),Zt=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:k()}:null}get configCache(){return this.cache??=new gt(this.ctx.settings.configStorage,this.ctx.settings.titleID)}cache;get stateStore(){return this.versionStore??=new $t(new Kt(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=gt.scopeOf(e.TitleFields,null),s=await this.configCache.read(t);s&&(e.KnownTitleConfigVersion=s.v);let r=await this.prepareStateHandshake(e,null),i=await this.ctx.api.user.getClientState(e);if(!i.ok)return i;let c=await this.resolveTitleConfig(i.data,t,s,{Fields:e.TitleFields});return c==null?gn:(this.finishStateHandshake(i.data,r),await this.applyClientState(i.data,c,void 0,void 0),await this.flushState(r),i)}async prepareStateHandshake(e,t){let s=this.ctx.auth.context?.userID;if(!s)return {userId:null,cached:null,sent:void 0};await this.stateStore.load(s),await this.stateStore.flush(s,this.ctx.data.user.state);let r=this.stateStore.versionsFor(t);if(r){e.KnownStateVersions=r;let i=this.stateStore.currentEpoch;i&&(e.KnownStateEpoch=i);}return {userId:s,cached:this.stateStore.cachedState,sent:r}}finishStateHandshake(e,t){let s=Hr(e.User,t.cached,t.sent,e.StateVersions);e.User=s;let r=Kr(e);!r||!t.userId||this.stateStore.afterFullRead(r,e.StateVersions);}async resolveTitleConfig(e,t,s,r){let i=e.TitleConfigVersion;if(s&&i&&s.v===i)return s.c;if(e.TitleConfigUrl){let d=await this.fetchConfigFromCdn(e.TitleConfigUrl);if(d!=null)return i&&await this.configCache.write(t,i,d),d}let c=await this.fetchConfigFromApi(r);return c!=null?(i&&await this.configCache.write(t,i,c),c):s?.c??null}async fetchConfigFromCdn(e){try{let t=await this.ctx.fetchImpl(e);if(!t.ok)return null;let s=await t.json();return s&&typeof s=="object"?s:null}catch{return null}}async fetchConfigFromApi(e){let t=this.baseRequest();if(!t)return null;let s={...t,...e},r=e.ExcludeFields?await this.ctx.api.title.getTitlePublicConfigurationExcept(s):await this.ctx.api.title.getTitlePublicConfiguration(s);return r.ok?r.data:null}async getClientStateExcept(e,t){let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.ExcludeFields=e,s.ExcludeTitleFields=t;let r=gt.scopeOf(null,t??[]),i=await this.configCache.read(r);i&&(s.KnownTitleConfigVersion=i.v);let c=await this.prepareStateHandshake(s,e??null),d=await this.ctx.api.user.getClientStateExcept(s);if(!d.ok)return d;let v=await this.resolveTitleConfig(d.data,r,i,{ExcludeFields:t??[]});return v==null?gn:(this.finishStateHandshake(d.data,c),await this.applyClientState(d.data,v,e,t),await this.flushState(c),d)}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 s=await this.prepareStateHandshake(t,null),r=await this.ctx.api.user.getUserState(t);if(!r.ok)return r;let i=Hr(r.data.User,s.cached,s.sent,r.data.StateVersions);r.data.User=i;let c=Object.keys(r.data.StateVersions??{});this.ctx.data.user.applyUserStateContainers(i,c);let d=Kr(r.data);return d&&(this.stateStore.afterSliceRead(d,r.data.StateVersions),await this.flushState(s)),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,s){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.UsageTime=e,r.IsNewSession=t,r.SessionDurationSeconds=s;let i=await this.ctx.api.user.addUsageTime(r);return i.ok&&this.ctx.emitter.emit("user:usageTimeAdded",i.data),i}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 s=await this.ctx.api.user.changeUsername(t);return s.ok&&this.ctx.emitter.emit("user:usernameChanged",s.data),s}async applyClientState(e,t,s,r){let i=s?.includes("GameLoop")===true,c=r?.includes("GameLoop")===true,d=i?this.ctx.data.user.state?.GameLoop:void 0,v=c?this.ctx.data.config.titlePublicConfiguration?.GameLoop:void 0;this.ctx.data.config.applyTitlePublicConfiguration(t),this.ctx.data.user.applyUserState(e.User??{});let w=this.ctx.data.user.state;i&&w&&w.GameLoop==null&&(w.GameLoop=d);let q=this.ctx.data.config.titlePublicConfiguration;c&&q&&q.GameLoop==null&&(q.GameLoop=v),this.ctx.emitter.emit("user:clientStateReceived",e);}};var Yt=class{constructor(e){this.ctx=e;}ctx;async convert(e,t,s,r,i,c){if(!t)return n("client","SourceID is required.");if(!r)return n("client","TargetID is required.");if(i<=0)return n("client","Amount must be positive.");if(e===s&&t===r)return n("client","Source and target must differ.");if(e===qe.Crypto||s===qe.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 d={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:s,TargetID:r,SourceAmount:String(Math.trunc(i)),TransactionID:c&&c.length>0?c:`convert_${e}_${t}_to_${s}_${r}_${k()}`},v=await this.ctx.api.currency.convert(d);if(v.ok){let w=v.data,q={Consume:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:w.SourceID,Amount:w.SourceSpent}]}},Grant:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:w.TargetID,Amount:w.TargetCredited}]}}};this.ctx.data.user.applyResourceOperation(q,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("currency:converted",w);}return v}async cryptoConvert(e,t,s,r,i,c){let d=i instanceof Ft__default.default?i:new Ft__default.default(i);if(!t)return n("client","SourceID is required.");if(!r)return n("client","TargetID is required.");if(d.lte(0))return n("client","SourceAmount must be a positive decimal.");if(e===s&&t===r)return n("client","Source and target must differ.");if(e===qe.Virtual&&s===qe.Virtual)return n("client","cryptoConvert requires at least one crypto side. Use convert for VC\u2194VC.");if(e===qe.Virtual&&!d.isInteger())return n("client","Virtual currency source amount must be integer.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let v={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:s,TargetID:r,SourceAmount:d.toString(),TransactionID:c&&c.length>0?c:`crypto_convert_${e}_${t}_to_${s}_${r}_${k()}`},w=await this.ctx.api.currency.cryptoConvert(v);if(w.ok){let q=w.data,se=[],ge=[];if(q.SourceType===qe.Virtual&&se.push({Type:"VirtualCurrency",CurrencyID:q.SourceID,Amount:Math.trunc(Number(q.SourceSpent))}),q.TargetType===qe.Virtual&&ge.push({Type:"VirtualCurrency",CurrencyID:q.TargetID,Amount:Math.trunc(Number(q.TargetCredited))}),se.length>0||ge.length>0){let ke={Consume:se.length>0?{Standard:{Entries:se}}:null,Grant:ge.length>0?{Standard:{Entries:ge}}:null};this.ctx.data.user.applyResourceOperation(ke,this.ctx.data.config.itemDefinitions);}q.SourceType===qe.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(q.SourceID,new Ft__default.default(q.SourceSpent).negated(),q.ServerTimeUtc),q.TargetType===qe.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(q.TargetID,new Ft__default.default(q.TargetCredited),q.ServerTimeUtc),this.ctx.emitter.emit("currency:cryptoConverted",q);}return w}};var Xt=class{constructor(e){this.ctx=e;}ctx;async upgradeLevel(e,t){let s=e.trim();if(!s)return n("client","ItemInstanceID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),ItemInstanceID:s,RelatedEntityID:`upgrade_item_${s}_${k()}`};t&&t.length>0&&(r.FodderInstanceIDs=[...t]);let i=await this.ctx.api.item.upgradeLevel(r);return i.ok&&(await this.ctx.userService.getUserInventory(),this.ctx.emitter.emit("item:levelUpgraded",i.data)),i}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},s=await this.ctx.api.item.upgradeLevelsBatch(t);return s.ok&&(await this.ctx.userService.getUserInventory(),this.ctx.emitter.emit("item:levelsUpgradedBatch",s.data)),s}};var fu="Store",es=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 s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),OfferID:e,Count:t,RelatedEntityID:`store_buy_${e}_${s.userID}_${k()}`},i=await this.ctx.api.store.purchase(r);if(i.ok){let c=i.data;this.ctx.data.user.patchStorePurchase(e,t,c.ServerTimeUtc),this.ctx.data.user.applyResourceOperation(c.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("store:offerPurchased",c);}return i}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},s=await this.ctx.api.store.purchaseBatch(t);if(s.ok){let r=false;for(let i of s.data)!i.Success||!i.Data||!i.Data.OfferID||(this.ctx.data.user.patchStorePurchase(i.Data.OfferID,i.Data.Count,i.Data.ServerTimeUtc),!r&&i.Data.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("store:offersPurchasedBatch",s.data);}return s}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(fu,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 gu="Lootbox",ts=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 s=t.data.LootboxDefinitions;s&&(this.ctx.data.config.patchSection(gu,s),this.ctx.emitter.emit("lootbox:definitionsLoaded",s));}return t}async open(e,t,s){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:s,RelatedEntityID:`lootbox_${e}_${s}_${k()}`},i=await this.ctx.api.lootbox.open(r);if(i.ok){let c=i.data;c.TriggeredPity&&c.TriggeredPity.length>0&&this.ctx.data.user.applyLootboxPityTriggers(e,c.TriggeredPity,t),this.ctx.data.user.applyResourceOperation(c.Resources,this.ctx.data.config.itemDefinitions),this.ctx.data.user.applyInventoryDelta(c.Inventory),this.ctx.emitter.emit("lootbox:opened",c);}return i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ru="Reward";function $r(a){return a.length>0&&!a.includes(".")&&!a.includes("$")}var ss=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 s=t.data.RewardDefinitions;s&&(this.ctx.data.config.patchSection(Ru,s),this.ctx.emitter.emit("reward:definitionsLoaded",s));}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 s=t.data;this.multiplierEnabled=s.Enabled,this.multiplier=s.Enabled?s.Multiplier??1:1,this.ctx.emitter.emit("reward:milestoneMultiplierLoaded",s);}return t}async claimDailyReward(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CalendarID:e,RelatedEntityID:`dailyreward_${t.userID}_${e??"default"}_${k()}`},r=await this.ctx.api.reward.claimDailyReward(s);if(r.ok){let i=r.data;this.ctx.data.user.patchDailyCalendarState(i.CalendarID,i.DailyState),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:dailyClaimed",i);}return r}async collectIdleAccrual(e){if(!$r(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}_${k()}`},s=await this.ctx.api.reward.collectIdleAccrual(t);if(s.ok){let r=s.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 s}async claimComebackReward(e){if(!$r(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}_${k()}`},s=await this.ctx.api.reward.claimComebackReward(t);if(s.ok){let r=s.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 s}async claimReward(e){if(!$r(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}_${k()}`},s=await this.ctx.api.reward.claimReward(t);if(s.ok){let r=s.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 s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var yu="Quest",rs=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(yu,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 s=await this.ctx.api.quest.getUserQuestState(t);if(s.ok){let r=s.data.State??{};this.ctx.data.user.applyQuest(r),this.ctx.data.user.patchQuestPointsTracks(s.data.PointsTracks),this.ctx.emitter.emit("quest:userStateLoaded",r);}return s}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 s=e.trim();if(!s)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,i={...this.ctx.buildAuthedBaseRequest(),QuestID:s,CycleID:r,RelatedEntityID:`quest_claim_${r??""}_${s}_${k()}`},c=await this.ctx.api.quest.claimQuestReward(i);if(c.ok){let d=c.data;this.ctx.data.user.patchQuestStatus(d.QuestID,d.CycleID,"Claimed"),this.ctx.data.user.applyResourceOperation(d.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:rewardClaimed",d);}return c}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},s=await this.ctx.api.quest.claimQuestRewardsBatch(t);if(s.ok){let r=false;for(let i of s.data)!i.Success||!i.Data||(this.ctx.data.user.patchQuestStatus(i.Data.QuestID,i.Data.CycleID,"Claimed"),!r&&i.Data.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("quest:rewardsClaimedBatch",s.data);}return s}async claimMilestoneReward(e,t){let s=e.trim(),r=t.trim();if(!s||!r)return n("client","CycleID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CycleID:s,MilestoneID:r,RelatedEntityID:`milestone_claim_${s}_${r}_${k()}`},c=await this.ctx.api.quest.claimMilestoneReward(i);if(c.ok){let d=c.data;this.ctx.data.user.patchMilestoneClaimed(d.CycleID,d.MilestoneID),this.ctx.data.user.applyResourceOperation(d.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:milestoneClaimed",d);}return c}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},s=await this.ctx.api.quest.claimMilestoneRewardsBatch(t);if(s.ok){let r=false;for(let i of s.data)!i.Success||!i.Data||(this.ctx.data.user.patchMilestoneClaimed(i.Data.CycleID,i.Data.MilestoneID),!r&&i.Data.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("quest:milestonesClaimedBatch",s.data);}return s}async claimGroupCompletionReward(e,t){let s=e.trim(),r=t.trim();if(!s||!r)return n("client","CycleID and GroupCompletionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CycleID:s,GroupCompletionID:r,RelatedEntityID:`group_completion_${s}_${r}_${k()}`},c=await this.ctx.api.quest.claimGroupCompletionReward(i);if(c.ok){let d=c.data;this.ctx.data.user.patchGroupCompletionClaimed(d.CycleID,d.GroupCompletionID),this.ctx.data.user.applyResourceOperation(d.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:groupCompletionClaimed",d);}return c}async addQuestProgress(e,t){let s=e.trim();if(!s)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:s,ProgressValue:t},i=await this.ctx.api.quest.addQuestProgress(r);return i.ok&&(this.ctx.data.user.patchQuestProgressUpdates(i.data.Updates),this.ctx.emitter.emit("quest:progressAdded",i.data)),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Cu="TimedEvent",is=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(Cu,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,s,r,i,c,d=1){if(!t)return n("client","LteID is required.");if(!s)return n("client","SourceType is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let v={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,SourceType:s,Outcome:r,AmountOverride:i,SourceParams:c,RollMultiplier:d},w=await this.ctx.api.timedEvent.grantTokens(v);return w.ok&&(this.ctx.data.user.applyResourceOperation(w.data,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensGranted",w.data)),w}async spendTokens(e,t,s){if(!t)return n("client","LteID is required.");if(s<=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:s},i=await this.ctx.api.timedEvent.spendTokens(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensSpent",i.data)),i}async claimMilestone(e,t,s){if(!t||!s)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:s},i=await this.ctx.api.timedEvent.claimMilestone(r);if(i.ok){let c=i.data;this.ctx.data.user.applyResourceOperation(c.Rewards,this.ctx.data.config.itemDefinitions),this.ctx.data.user.patchTimedEventMilestoneClaimed(e,t,s),this.ctx.emitter.emit("timedEvent:milestoneClaimed",c);}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},s=await this.ctx.api.timedEvent.claimMilestonesBatch(t);return s.ok&&(this.applyMilestoneClaimBatch(s.data),this.ctx.emitter.emit("timedEvent:milestonesClaimedBatch",s.data)),s}async claimAllMilestones(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&e.length>0&&(t.Events=e);let s=await this.ctx.api.timedEvent.claimAllMilestones(t);return s.ok&&(this.applyMilestoneClaimBatch(s.data),this.ctx.emitter.emit("timedEvent:allMilestonesClaimed",s.data)),s}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},s=await this.ctx.api.timedEvent.spendTokensBatch(t);if(s.ok){let r=false;for(let i of s.data)!r&&i.Success&&i.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("timedEvent:tokensSpentBatch",s.data);}return s}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},s=await this.ctx.api.timedEvent.grantTokensBatch(t);if(s.ok){let r=false;for(let i of s.data)!r&&i.Success&&i.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("timedEvent:tokensGrantedBatch",s.data);}return s}applyMilestoneClaimBatch(e){let t=false;for(let s of e){if(!s.Success||!s.Data)continue;let r=s.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 Su="Leaderboard",ns=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(Su,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 s=await this.ctx.api.leaderboard.getLeaderboard(t);return s.ok&&this.ctx.emitter.emit("leaderboard:loaded",s.data),s}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 s=await this.ctx.api.leaderboard.getMyProgress(t);return s.ok&&(this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(e),s.data),this.ctx.emitter.emit("leaderboard:myProgressLoaded",s.data)),s}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 s={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,Score:t},r=await this.ctx.api.leaderboard.submitScore(s);if(r.ok){let i=r.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),i.NewScore,t,i.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",i);}return r}async submitScoreFromSource(e,t,s,r,i=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 c={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,SourceType:t,Outcome:s,Params:r,RollMultiplier:i},d=await this.ctx.api.leaderboard.submitScoreFromSource(c);if(d.ok){let v=d.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),v.NewScore,v.NewScore,v.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",v);}return d}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},s=await this.ctx.api.leaderboard.claimCycleReward(t);if(s.ok){let r=s.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 s}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 s={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,MilestoneID:t},r=await this.ctx.api.leaderboard.claimMilestone(s);if(r.ok){let i=r.data;this.ctx.data.user.patchLeaderboardMilestoneClaimed(this.cycleDocID(e),t),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("leaderboard:milestoneClaimed",i);}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 s=await this.ctx.api.leaderboard.getFriendsLeaderboard(t);return s.ok&&this.ctx.emitter.emit("leaderboard:friendsLoaded",s.data),s}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 s=await this.ctx.api.leaderboard.getLeaderboardsBatch(t);return s.ok&&this.ctx.emitter.emit("leaderboard:loadedBatch",s.data),s}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 s=await this.ctx.api.leaderboard.getProgressBatch(t);if(s.ok){for(let r of s.data)!r.Success||!r.Data||this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(r.Data.LeaderboardID),r.Data);this.ctx.emitter.emit("leaderboard:myProgressLoadedBatch",s.data);}return s}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},s=await this.ctx.api.leaderboard.claimCycleRewardsBatch(t);if(s.ok){for(let r of s.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",s.data);}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},s=await this.ctx.api.leaderboard.claimMilestonesBatch(t);if(s.ok){for(let r of s.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",s.data);}return s}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},s=await this.ctx.api.leaderboard.submitScoresBatch(t);if(s.ok){for(let r of s.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",s.data);}return s}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},s=await this.ctx.api.leaderboard.claimAllRewardsBatch(t);if(s.ok){for(let r of s.data){let i=this.cycleDocID(r.LeaderboardID);r.CycleReward?.Success&&r.CycleReward.Data&&(this.ctx.data.user.patchLeaderboardCycleRewardClaimed(i),r.CycleReward.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.CycleReward.Data.Resources,this.ctx.data.config.itemDefinitions));for(let c of r.Milestones??[])!c.Success||!c.Data||(this.ctx.data.user.patchLeaderboardMilestoneClaimed(i,c.Data.MilestoneID),c.Data.Resources&&this.ctx.data.user.applyResourceOperation(c.Data.Resources,this.ctx.data.config.itemDefinitions));}this.ctx.emitter.emit("leaderboard:allRewardsClaimedBatch",s.data);}return s}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 s=await this.ctx.api.leaderboard.getOverviewBatch(t);if(s.ok){for(let r of s.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",s.data);}return s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var xu="Season",os=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(xu,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 s=await this.ctx.api.season.getActiveSeason(t);return s.ok&&(s.data.UserState&&this.ctx.data.user.patchSeasonState(e,s.data.UserState),this.ctx.emitter.emit("season:activeLoaded",s.data)),s}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 s=await this.ctx.api.season.getUserState(t);return s.ok&&(this.ctx.data.user.patchSeasonState(e,s.data),this.ctx.emitter.emit("season:userStateLoaded",s.data)),s}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 s={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,Amount:t,RelatedEntityID:`season_grant_${e}_${k()}`},r=await this.ctx.api.season.grantStatusTokens(s);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 s={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,TierNumber:t,RelatedEntityID:`season_tier_${e}_t${t}_${k()}`},r=await this.ctx.api.season.claimTierReward(s);if(r.ok){let i=r.data;this.ctx.data.user.patchSeasonClaimedTier(e,t),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("season:tierRewardClaimed",i);}return r}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Du="Premium",as=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(Du,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 s={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,RelatedEntityID:`premium_trial_${e}_${t}`},r=await this.ctx.api.premium.activateTrial(s);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,s="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 i={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,SelectedOptionID:s,Count:r,RelatedEntityID:`premium_purchase_${e}_${t}`},c=await this.ctx.api.premium.purchaseItemOrCurrency(i);if(c.ok){let d=c.data;d.Premium&&this.ctx.data.user.applyPremium(d.Premium),this.ctx.data.user.applyResourceOperation(d.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:purchaseCompleted",d);}return c}async purchaseRealMoney(e,t,s,r,i,c,d,v){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!r||!i)return n("client","ProductID and ReceiptData are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let w={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,Store:s,ProductID:r,ReceiptData:i,PurchaseToken:c,PackageName:d,AppStoreEnvironment:v,RelatedEntityID:`premium_iap_${e}_${t}`},q=await this.ctx.api.premium.purchaseRealMoney(w);if(q.ok){let se=q.data;se.Premium&&this.ctx.data.user.applyPremium(se.Premium),this.ctx.data.user.applyResourceOperation(se.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:realMoneyPurchaseCompleted",se);}return q}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var bu="Character",ls=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(bu,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 s=t.data.Characters??{};this.ctx.data.user.applyCharacter(s),this.ctx.emitter.emit("character:userCharactersLoaded",s);}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}_${k()}`},s=await this.ctx.api.character.unlockCharacter(t);if(s.ok){let r=s.data;this.ctx.data.user.patchCharacter(r.CharacterID,i=>{i.StatLevels??={},i.Equipment??={},r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=r.ServerTimeUtc;}),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:unlocked",r);}return s}async upgradeStatLevel(e,t,s){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}_${k()}`,...s?.levels!=null?{Levels:s.levels}:{},...s?.targetLevel!=null?{TargetLevel:s.targetLevel}:{}},i=await this.ctx.api.character.upgradeStatLevel(r);if(i.ok){let c=i.data;this.ctx.data.user.patchCharacter(c.CharacterID,d=>{d.StatLevels??={},d.StatLevels[c.StatID]=c.StatLevel,c.Power!=null&&(d.Power=c.Power),d.UpdatedAt=c.ServerTimeUtc;}),this.ctx.data.user.applyResourceOperation(c.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:statLevelUpgraded",c);}return i}async upgradeCharacterLevel(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,RelatedEntityID:`upgrade_char_${e}_${k()}`,...t?.levels!=null?{Levels:t.levels}:{},...t?.targetLevel!=null?{TargetLevel:t.targetLevel}:{}},r=await this.ctx.api.character.upgradeCharacterLevel(s);if(r.ok){let i=r.data;this.ctx.data.user.patchCharacter(i.CharacterID,c=>{c.Level=i.NewLevel,i.Power!=null&&(c.Power=i.Power),c.UpdatedAt=i.ServerTimeUtc,i.NewLevel===1&&(c.StatLevels??={},c.Equipment??={});}),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:levelUpgraded",i);}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 s={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,ItemsToEquip:t},r=await this.ctx.api.character.equipItems(s);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 s={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,UnequipSlotIDs:t},r=await this.ctx.api.character.unequipItems(s);if(r.ok){let i=r.data;this.applyUnequipChangesLocally(e,i),this.ctx.emitter.emit("character:itemsUnequipped",{characterID:e,slotIDs:i.ClearedSlotIDs??[],power:i.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},s=await this.ctx.api.character.unlockCharactersBatch(t);return s.ok&&(this.applyBatchResults(s.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,i=>{i.StatLevels??={},i.Equipment??={},r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=r.ServerTimeUtc;});}),this.ctx.emitter.emit("character:charactersUnlocked",s.data)),s}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},s=await this.ctx.api.character.upgradeCharacterLevelsBatch(t);return s.ok&&(this.applyBatchResults(s.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,i=>{i.Level=r.NewLevel,r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=r.ServerTimeUtc,r.NewLevel===1&&(i.StatLevels??={},i.Equipment??={});});}),this.ctx.emitter.emit("character:levelsUpgraded",s.data)),s}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},s=await this.ctx.api.character.upgradeStatLevelsBatch(t);return s.ok&&(this.applyBatchResults(s.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,i=>{i.StatLevels??={},i.StatLevels[r.StatID]=r.StatLevel,r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=r.ServerTimeUtc;});}),this.ctx.emitter.emit("character:statLevelsUpgraded",s.data)),s}applyBatchResults(e,t){e.Resources&&this.ctx.data.user.applyResourceOperation(e.Resources,this.ctx.data.config.itemDefinitions);for(let s of e.Items??[])!s.Success||!s.Data||t(s.Data);}applyInventoryDelta(e){this.ctx.data.user.applyInventoryDelta(e);}applyEquipChangesLocally(e,t){let s=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let[r,i]of Object.entries(t.Equipment??{}))s.patchCharacterEquipment(e,r,i);s.patchCharacter(e,r=>{t.Power!=null&&(r.Power=t.Power),r.UpdatedAt=t.ServerTimeUtc;});}applyUnequipChangesLocally(e,t){let s=t.ClearedSlotIDs??[];if(s.length===0&&t.Power==null)return;let r=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let i of s)r.patchCharacterEquipment(e,i,null);r.patchCharacter(e,i=>{t.Power!=null&&(i.Power=t.Power),i.UpdatedAt=t.ServerTimeUtc;});}applyUnequipAllLocally(e){let t=this.ctx.data.user;this.applyInventoryDelta(e.Inventory);for(let[s,r]of Object.entries(e.Characters??{})){for(let i of r.ClearedSlotIDs??[])t.patchCharacterEquipment(s,i,null);t.patchCharacter(s,i=>{r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=e.ServerTimeUtc;});}}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var vu="Match",us=class{constructor(e){this.ctx=e;}ctx;async createMatch(e,t,s,r,i){let c=this.ctx.auth.context;if(!c)return n("unauthorized","Not logged in.");let d={...this.ctx.buildAuthedBaseRequest(),Entry:e,RuleID:t,CharacterID:s,BattleStrategy:r,TargetUserID:i,RelatedEntityID:`pvp_create_${c.userID}_${k()}`},v=await this.ctx.api.match.createMatch(d);return v.ok&&(this.ctx.data.user.applyResourceOperation(v.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:created",v.data)),v}async updateMatch(e,t={}){if(!e)return n("client","MatchID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...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(s);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},s=await this.ctx.api.match.cancelMatch(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:cancelled",s.data)),s}async instantBattle(e,t,s,r){let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let c={...this.ctx.buildAuthedBaseRequest(),MatchID:e,RuleID:t,CharacterID:s,BattleStrategy:r,RelatedEntityID:`pvp_battle_${e}_${k()}`},d=await this.ctx.api.match.instantBattle(c);if(d.ok){let v=d.data,w=this.ctx.data.config.itemDefinitions;if(v.Resources)this.ctx.data.user.applyResourceOperation(v.Resources,w);else if(v.ResourcesDual){let q=v.ResourcesDual;q.FromUserID===i.userID&&q.FromResult?this.ctx.data.user.applyResourceOperation(q.FromResult,w):q.ToUserID===i.userID&&q.ToResult&&this.ctx.data.user.applyResourceOperation(q.ToResult,w);}this.ctx.emitter.emit("match:instantBattleCompleted",v);}return d}async saveStrategy(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BattleStrategy:e},s=await this.ctx.api.match.saveStrategy(t);return s.ok&&(this.ctx.data.user.patchMatchStrategy(e),this.ctx.emitter.emit("match:strategySaved",e)),s}async getMyMatches(e=0,t=20,s){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.Statuses=s;let i=await this.ctx.api.match.getMyMatches(r);return i.ok&&this.ctx.emitter.emit("match:myMatchesLoaded",i.data),i}async getAvailableMatches(e=0,t=20,s=false){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.OnlyPublic=s;let i=await this.ctx.api.match.getAvailableMatches(r);return i.ok&&this.ctx.emitter.emit("match:availableMatchesLoaded",i.data),i}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(vu,t.data),this.ctx.emitter.emit("match:definitionsLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var zu="Craft",cs=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(zu,t.data.CraftDefinitions),this.ctx.emitter.emit("craft:definitionsLoaded",t.data.CraftDefinitions)),t}async craft(e,t,s=1,r){if(!e)return n("client","CraftID is required.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let c={...this.ctx.buildAuthedBaseRequest(),CraftID:e,InputItemIDs:t,Count:s,SelectedOptionID:r,RelatedEntityID:`craft_${e}_${i.userID}_${k()}`},d=await this.ctx.api.craft.craft(c);return d.ok&&(this.ctx.data.user.applyResourceOperation(d.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("craft:completed",d.data)),d}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Tu="Collection",ps=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(Tu,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){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,PackTypeID:t,RelatedEntityID:`open_pack_${e}_${t}_${s.userID}_${k()}`},i=await this.ctx.api.collection.openPack(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:packOpened",i.data)),i}async openCollectionChest(e,t){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectionChestID:t,RelatedEntityID:`open_chest_${e}_${t}_${s.userID}_${k()}`},i=await this.ctx.api.collection.openCollectionChest(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:chestOpened",i.data)),i}async useCollectibleJoker(e,t){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:false,RelatedEntityID:`use_joker_${e}_${t}_${s.userID}_${k()}`},i=await this.ctx.api.collection.useCollectibleJoker(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:jokerUsed",i.data)),i}async claimSetReward(e,t){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,SetID:t,RelatedEntityID:`claim_set_${e}_${t}_${s.userID}_${k()}`},i=await this.ctx.api.collection.claimSetReward(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:setRewardClaimed",i.data)),i}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},s=await this.ctx.api.collection.claimSetRewardsBatch(t);if(s.ok){let r=false;for(let i of s.data)!r&&i.Success&&i.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("collection:setRewardsClaimedBatch",s.data);}return s}async claimGrandPrize(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,RelatedEntityID:`grand_prize_${e}_${t.userID}_${k()}`},r=await this.ctx.api.collection.claimGrandPrize(s);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,s,r,i,c=false){let d=this.ctx.auth.context;if(!d)return n("unauthorized","Not logged in.");let v={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:s,ReceiverUserID:r,RequestedCollectibleID:i,RequestedCollectibleIsSpecial:c,RelatedEntityID:`trade_send_${d.userID}_${r}_${k()}`},w=await this.ctx.api.collection.sendTradeOffer(v);return w.ok&&this.ctx.emitter.emit("collection:tradeOfferSent",w.data),w}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}_${k()}`},s=await this.ctx.api.collection.cancelTradeOffer(t);return s.ok&&this.ctx.emitter.emit("collection:tradeOfferCancelled",s.data),s}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}_${k()}`},s=await this.ctx.api.collection.acceptTradeOffer(t);return s.ok&&this.ctx.emitter.emit("collection:tradeOfferAccepted",s.data),s}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}_${k()}`},s=await this.ctx.api.collection.declineTradeOffer(t);return s.ok&&this.ctx.emitter.emit("collection:tradeOfferDeclined",s.data),s}async getMyTradeOffers(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CollectionID=e;let s=await this.ctx.api.collection.getMyTradeOffers(t);return s.ok&&this.ctx.emitter.emit("collection:myTradeOffersLoaded",s.data),s}async getIncomingTradeOffers(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CollectionID=e;let s=await this.ctx.api.collection.getIncomingTradeOffers(t);return s.ok&&this.ctx.emitter.emit("collection:incomingTradeOffersLoaded",s.data),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Pu="CoopEvent",ds=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(Pu,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 s=await this.ctx.api.coopEvent.getActiveEvent(t);return s.ok&&this.ctx.emitter.emit("coopEvent:activeEventLoaded",s.data),s}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 s=await this.ctx.api.coopEvent.getGroupState(t);return s.ok&&this.ctx.emitter.emit("coopEvent:groupStateLoaded",s.data),s}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},s=await this.ctx.api.coopEvent.joinOrCreateGroup(t);if(s.ok){let r=s.data.Group;r&&this.ctx.data.user.patchCoopEventActiveGroup(r.GroupID??null,r.CoopEventID??null,-1),this.ctx.emitter.emit("coopEvent:groupJoined",s.data);}return s}async spin(e,t){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,RelatedEntityID:k()},r=await this.ctx.api.coopEvent.spin(s);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("coopEvent:spinCompleted",r.data)),r}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},s=await this.ctx.api.coopEvent.claimObjectReward(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("coopEvent:objectRewardClaimed",s.data)),s}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},s=await this.ctx.api.coopEvent.claimGrandPrize(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:grandPrizeClaimed",s.data)),s}async leaveGroup(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},s=await this.ctx.api.coopEvent.leaveGroup(t);return s.ok&&(this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:groupLeft",s.data)),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Iu="DealOffer",hs=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(Iu,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}_${k()}`},s=await this.ctx.api.dealOffer.dismissDeal(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:dealDismissed",s.data)),s}async executeNode(e,t,s){if(!e||!t)return n("client","SlotID and NodeID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r=s&&s.trim().length>0?s.trim():void 0,i={...this.ctx.buildAuthedBaseRequest(),SlotID:e,NodeID:t,RelatedEntityID:r??`deal_exec_${e}_${t}_${k()}`},c=await this.ctx.api.dealOffer.executeNode(i);return c.ok&&(c.data.Idempotent||this.ctx.data.user.applyResourceOperation(c.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:nodeExecuted",c.data)),c}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}_${k()}`},s=await this.ctx.api.dealOffer.recordShow(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:showRecorded",s.data)),s}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 s={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneID:t,RelatedEntityID:`deal_milestone_${e}_${t}_${k()}`},r=await this.ctx.api.dealOffer.claimMilestone(s);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 s=[...new Set(t.map(c=>c.trim()).filter(c=>c.length>0))],r={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneIDs:s,RelatedEntityID:`deal_milestone_batch_${e}_${k()}`},i=await this.ctx.api.dealOffer.claimMilestonesBatch(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:milestonesBatchClaimed",i.data)),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var ku="Referral",ms=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(ku,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 s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),ReferralCode:t,RelatedEntityID:`referral_activation_${s.userID}`},i=await this.ctx.api.referral.activateReferralCode(r);if(i.ok){let c=i.data;c.ReferralCode&&this.ctx.data.user.patchReferralSubscription(c.ReferralCode),this.ctx.data.user.applyResourceOperation(c.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:codeActivated",c);}return i}async claimInviteReward(e){let t=e.trim();if(!t)return n("client","InviteRewardID is required.");let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),InviteRewardID:t,RelatedEntityID:`referral_invite_${t}_${s.userID}`},i=await this.ctx.api.referral.claimInviteReward(r);if(i.ok){let c=i.data;c.RewardID&&this.ctx.data.user.patchReferralInviteRewardClaimed(c.RewardID),this.ctx.data.user.applyResourceOperation(c.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:inviteRewardClaimed",c);}return i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var fs=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 s=await this.ctx.api.social.getRecommendedFriends(t);return s.ok&&this.ctx.emitter.emit("social:recommendedFriendsLoaded",s.data),s}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},s=await this.ctx.api.social.sendFriendRequest(t);return s.ok&&(this.ctx.data.user.patchSocialAddOutgoingRequest(e),this.ctx.emitter.emit("social:friendRequestSent",s.data)),s}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},s=await this.ctx.api.social.acceptFriendRequest(t);return s.ok&&(this.ctx.data.user.patchSocialAcceptFriend(e),this.ctx.emitter.emit("social:friendRequestAccepted",s.data)),s}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},s=await this.ctx.api.social.declineFriendRequest(t);return s.ok&&(this.ctx.data.user.patchSocialRemoveIncomingRequest(e),this.ctx.emitter.emit("social:friendRequestDeclined",s.data)),s}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},s=await this.ctx.api.social.removeFriend(t);return s.ok&&(this.ctx.data.user.patchSocialRemoveFriend(e),this.ctx.emitter.emit("social:friendRemoved",s.data)),s}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 Mu="TimedBoost";function Au(a){return a.length>0&&!a.includes(".")&&!a.includes("$")}var gs=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(Mu,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(!Au(t))return n("client",'BoostID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),BoostID:t,RelatedEntityID:`timed_boost_activate_${t}_${k()}`},r=await this.ctx.api.timedBoost.activate(s);if(r.ok){let i=r.data;if(i.ActivatedBoost){let c=i.StackingPolicy??"Replace";this.ctx.data.user.patchActiveTimedBoost(i.ActivatedBoost,c);}this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedBoost:activated",i);}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 Qe={Private:"Private",Public:"Public",ReadOnly:"ReadOnly",Internal:"Internal"},Uu={Client:"Client",Server:"Server",System:"System"},Ou=zod.z.enum(["Client","Server","System"]),wu=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:l.nullish(),Version:zod.z.number().nullish(),LastWriter:Ou.nullish(),ExpiresAt:l.nullish()}).passthrough(),Rs=zod.z.record(zod.z.string(),wu),Rn=zod.z.object({Version:zod.z.number().nullish(),Private:Rs.nullish(),Public:Rs.nullish(),ReadOnly:Rs.nullish()}),Zr=zod.z.object({UserID:zod.z.string().nullish(),Version:zod.z.number().nullish(),Public:Rs.nullish()}),Jr=zod.z.object({ServerTimeUtc:l.nullish(),Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:l.nullish()}),Bu=zod.z.object({Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:l.nullish()}),yn=zod.z.object({ServerTimeUtc:l.nullish(),Results:zod.z.array(Bu).nullish()}),Cn=zod.z.object({ServerTimeUtc:l.nullish(),DeletedCount:zod.z.number().nullish()}),Sn=zod.z.object({Results:zod.z.array(Zr).nullish(),NotFoundUserIDs:zod.z.array(zod.z.string()).nullish()}),qu={String:"String",Int:"Int",Bool:"Bool",Json:"Json"},Eu=zod.z.enum(["String","Int","Bool","Json"]),Lu=zod.z.object({KeyID:zod.z.string(),Bucket:zod.z.string().nullish(),ValueType:Eu.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),ys=zod.z.object({Keys:zod.z.record(zod.z.string(),Lu).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(),Ge={GetUserCustomDataDefinitions:"GetUserCustomDataDefinitions",GetMyUserCustomData:"GetMyUserCustomData",GetPublicUserCustomDataOf:"GetPublicUserCustomDataOf",SetPrivateData:"SetPrivateData",SetPublicData:"SetPublicData",DeleteKey:"DeleteKey",BatchSet:"BatchSet",BatchDelete:"BatchDelete",BatchGetPublicUserCustomDataOf:"BatchGetPublicUserCustomDataOf"};var Gu="UserCustomData";function xn(a){return a.length>0&&!a.includes(".")&&!a.includes("$")}var Cs=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(Gu,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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.TargetUserID=t;let r=await this.ctx.api.userCustomData.getPublicUserCustomDataOf(s);return r.ok&&this.ctx.emitter.emit("userCustomData:publicDataLoaded",r.data),r}async setPrivateData(e,t){return this.setData(e,t,Qe.Private)}async setPublicData(e,t){return this.setData(e,t,Qe.Public)}async setData(e,t,s){let r=e.trim();if(!xn(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 i={...this.ctx.buildAuthedBaseRequest(),KeyID:r,Value:t},d=await(s===Qe.Private?this.ctx.api.userCustomData.setPrivateData(i):this.ctx.api.userCustomData.setPublicData(i));if(d.ok){let v=d.data;this.ctx.data.user.patchUserCustomDataKey(s,v.KeyID,t,v.Version??0,v.ExpiresAt),this.ctx.emitter.emit(s===Qe.Private?"userCustomData:privateDataSet":"userCustomData:publicDataSet",v);}return d}async deleteKey(e,t){let s=e.trim();if(!xn(s))return n("client",'KeyID is required and must not contain "." or "$".');if(t!==Qe.Private&&t!==Qe.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:s,Bucket:t},i=await this.ctx.api.userCustomData.deleteKey(r);return i.ok&&(this.ctx.data.user.removeUserCustomDataKey(t,s),this.ctx.emitter.emit("userCustomData:keyDeleted",void 0)),i}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},s=await this.ctx.api.userCustomData.batchSet(t);if(s.ok){for(let r of s.data.Results??[]){let i=r.Bucket??Qe.Private,c=e.find(d=>d.Bucket===i&&d.KeyID===r.KeyID);c&&this.ctx.data.user.patchUserCustomDataKey(i,r.KeyID,c.Value,r.Version??0,r.ExpiresAt);}this.ctx.emitter.emit("userCustomData:batchSet",s.data);}return s}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},s=await this.ctx.api.userCustomData.batchDelete(t);if(s.ok){for(let r of e)this.ctx.data.user.removeUserCustomDataKey(r.Bucket,r.KeyID.trim());this.ctx.emitter.emit("userCustomData:batchDeleted",s.data);}return s}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 s=await this.ctx.api.userCustomData.batchGetPublicUserCustomDataOf(t);return s.ok&&this.ctx.emitter.emit("userCustomData:batchPublicDataLoaded",s.data),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Nu="TitleCustomDataDefinitions",Dn=50;function ju(a){return a.length>0&&!a.includes(".")&&!a.includes("$")}function Yr(a){if(a.ExpiresAt==null)return false;let e=Date.parse(a.ExpiresAt);return !Number.isNaN(e)&&e<=Date.now()}function Fu(a){let e={};for(let[t,s]of Object.entries(a))Yr(s)||(e[t]=s);return e}var Ss=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(Nu,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 s=await this.ctx.api.titleCustomData.getPublicTitleData(t);return s.ok&&this.absorb(s.data),s}async getPublicTitleDataKeys(e){let t=e.map(i=>i.trim()).filter(i=>i.length>0);if(!t.length)return n("client","At least one KeyID is required.");if(t.some(i=>!ju(i)))return n("client",'KeyID must not contain "." or "$".');if(t.length>Dn)return n("client",`At most ${Dn} keys per call \u2014 request them in chunks.`);let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.KeyIDs=t;let r=await this.ctx.api.titleCustomData.getPublicTitleDataKeys(s);return r.ok&&this.ctx.emitter.emit("titleCustomData:publicDataLoaded",r.data),r}getValue(e){let t=this.runtimeCache[e];if(t?.Value!=null&&!Yr(t))return t.Value;let s=this.staticCache[e];if(s?.Value!=null&&!Yr(s))return s.Value}get runtimeVersion(){return this.lastRuntimeVersion}staticCache={};absorb(e){e.Static&&(this.staticCache=e.Static),e.NotModified?(this.runtimeCache=Fu(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 xs=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 Vu=15,_u="GameLoop",Wu="BoardDefinition",Ds=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(_u,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 s=await this.ctx.api.gameLoop.getBoardDefinition(t,e);return s.ok&&(this.ctx.data.config.patchSection(Wu,s.data),this.ctx.emitter.emit("gameLoop:boardDefinitionLoaded",s.data)),s}async getBoardDefinitionForLevel(e,t=false){if(e<=0)return n("client","stageLevel must be > 0.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.StageLevel=e;let r=await this.ctx.api.gameLoop.getBoardDefinitionForLevel(s,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 s={...this.ctx.buildAuthedBaseRequest(),RollMultiplier:e,RelatedEntityID:`roll_${t.userID}_${k()}`},r=await this.ctx.api.gameLoop.boardLoopRoll(s);if(r.ok){let i=r.data,c=dn(new Date,Vu);this.ctx.data.user.patchBoardState(d=>{d.Position=i.NewPosition,d.CyclesCompleted=(d.CyclesCompleted??0)+(i.CyclesCompletedDelta??0),d.LastRollAtUtc=new Date().toISOString(),i.ActionRequired&&i.ActionData?d.Pending={Type:i.ActionRequired,TargetUserID:i.ActionData.TargetUserID,TargetPublicData:i.ActionData.PublicData,TargetBuildingStates:i.ActionData.TargetBuildingStates??void 0,TargetHasShield:i.ActionData.TargetHasShield??void 0,RollMultiplier:i.UsedMultiplier??1,ExpiresAtUtc:c}:i.SpecialModeOffer&&(d.Pending={Type:"SPECIAL",RollMultiplier:i.UsedMultiplier??1,ExpiresAtUtc:c,Special:{ModeID:i.SpecialModeOffer.ModeID??void 0,Choices:i.SpecialModeOffer.Choices??void 0}});}),i.Operation&&this.ctx.data.user.applyResourceOperation(i.Operation,this.itemDefs),i.ActionRequired==="RAID"&&await this.getUserBoardState(),this.ctx.emitter.emit("gameLoop:boardRolled",i);}return r}async boardLoopAttack(e=-1){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`attack_${t.userID}_${k()}`},r=await this.ctx.api.gameLoop.boardLoopAttack(s);if(r.ok){let i=r.data;this.ctx.data.user.clearBoardPending(),i.IsBotTarget&&i.Operation?this.ctx.data.user.applyResourceOperation(i.Operation,this.itemDefs):!i.IsBotTarget&&i.DualResult?.FromResult&&this.ctx.data.user.applyResourceOperation(i.DualResult.FromResult,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardAttacked",i);}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 s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),DigIndex:e,RelatedEntityID:t??`raid_${s.userID}_${k()}`},i=await this.ctx.api.gameLoop.boardLoopRaid(r);if(i.ok){let c=i.data;c.Status==="CONTINUE"?this.ctx.data.user.patchBoardPendingRaidLayout(c.RaidLayout,c.OpenedIndex??-1):(this.ctx.data.user.clearBoardPending(),this.applyRaidResources(c)),this.ctx.emitter.emit("gameLoop:boardRaided",c);}else await this.getUserBoardState();return i}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 s={...this.ctx.buildAuthedBaseRequest(),DigIndices:e,RelatedEntityID:`raidfast_${t.userID}_${k()}`},r=await this.ctx.api.gameLoop.boardLoopRaidFast(s);if(r.ok){let i=r.data;i.Status!=="CONTINUE"&&(this.ctx.data.user.clearBoardPending(),this.applyRaidResources(i)),this.ctx.emitter.emit("gameLoop:boardRaidedFast",i);}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 s={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`build_${t.userID}_${e}_${k()}`},r=await this.ctx.api.gameLoop.boardLoopBuild(s);if(r.ok){let i=r.data;i.StageComplete?this.ctx.data.user.patchBoardState(c=>{c.StageLevel=(c.StageLevel??1)+1,c.Position=0,c.Pending=null,c.BuildingStates=null;}):this.ctx.data.user.patchBoardBuilding(i.BuiltIndex,c=>{i.NewLevel!=null&&(c.Level=i.NewLevel),c.IsDamaged=false,i.MaxLevelRewardClaimed&&(c.MaxLevelRewardClaimed=true);}),i.Operation&&this.ctx.data.user.applyResourceOperation(i.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardBuilt",i);}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 s={...this.ctx.buildAuthedBaseRequest(),ChoiceID:e,RelatedEntityID:`special_choose_${t.userID}_${k()}`},r=await this.ctx.api.gameLoop.boardSpecialChoose(s);if(r.ok){let i=r.data;i.Mode==="Instant"||i.Mode===0?this.ctx.data.user.clearBoardPending():this.ctx.data.user.patchBoardSpecialPending(d=>{d.ChoiceID=e,d.ChosenMode=i.Mode??"Timed",d.StartedAtUtc=i.StartedAtUtc??null,d.DurationSeconds=i.DurationSeconds??null,d.AdViewsUsed=0;}),i.Operation&&this.ctx.data.user.applyResourceOperation(i.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialChose",i);}return r}async boardSpecialApplyMultiplier(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:e??`special_ad_${t.userID}_${k()}`},r=await this.ctx.api.gameLoop.boardSpecialApplyMultiplier(s);if(r.ok){let i=r.data;this.ctx.data.user.patchBoardSpecialPending(c=>{c.AdViewsUsed=i.AdViewsUsed??0,c.AccumulatedMultiplier=i.AccumulatedMultiplier??0;}),this.ctx.emitter.emit("gameLoop:boardSpecialApplyMultiplier",i);}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}_${k()}`},s=await this.ctx.api.gameLoop.boardSpecialClaim(t);if(s.ok){let r=s.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 s}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 s=t.data.Group;s?.GroupID&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:s.GroupID,ActiveRoundIndex:s.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 s={...this.ctx.buildAuthedBaseRequest(),MilestoneID:e,GroupID:t},r=await this.ctx.api.gameLoop.claimCommunityChestMilestone(s);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},s=await this.ctx.api.gameLoop.claimCommunityChestGrandPrize(t);return s.ok&&(s.data.Resources&&this.ctx.data.user.applyResourceOperation(s.data.Resources,this.itemDefs),this.ctx.emitter.emit("gameLoop:communityChestGrandPrizeClaimed",s.data)),s}async leaveCommunityChest(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},s=await this.ctx.api.gameLoop.leaveCommunityChest(t);return s.ok&&(s.data.Success&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:void 0,ActiveRoundIndex:-1}),this.ctx.emitter.emit("gameLoop:communityChestLeft",s.data)),s}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 bs=class{constructor(e){this.ctx=e;}ctx;async execute(e,t,s,r){let i=e.trim();if(!i)return n("client","FunctionName is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let c={...this.ctx.buildAuthedBaseRequest(),FunctionName:i,FunctionParameter:t,RevisionSelection:s,SpecificRevision:r},d=await this.ctx.api.cloudCode.execute(c);return d.ok&&this.ctx.emitter.emit("cloudCode:executed",d.data),d}};var bn=zod.z.object({ServerTimeUtc:l,SourceType:ht,SourceID:zod.z.string(),TargetType:ht,TargetID:zod.z.string(),SourceSpent:M,FeeAmount:M,RateApplied:B,TargetCredited:M}),vn=zod.z.object({ServerTimeUtc:l,SourceType:ht,SourceID:zod.z.string(),TargetType:ht,TargetID:zod.z.string(),SourceSpent:B,FeeAmount:B,RateApplied:B,TargetCredited:B}),vs={Convert:"Convert",CryptoConvert:"CryptoConvert"},Qu={Active:"Active",Hidden:"Hidden",Deprecated:"Deprecated",Maintenance:"Maintenance"},zn=zod.z.enum(["Active","Hidden","Deprecated","Maintenance"]),Hu={Automatic:"Automatic",Manual:"Manual"},Ku=zod.z.enum(["Automatic","Manual"]),$u=zod.z.object({ValueInUSD:B.nullish(),ValueInUSDUpdatedAt:l.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(),Zu=zod.z.object({Rate:zod.z.number().nullish(),Max:zod.z.number().nullish(),Period:zod.z.number().nullish()}).passthrough(),Ju=zod.z.object({IsTradable:zod.z.boolean().nullish(),IsPurchasable:zod.z.boolean().nullish(),IsRefundable:zod.z.boolean().nullish()}).passthrough(),Yu=zod.z.object({TargetCurrencyType:ht.nullish(),TargetCurrencyID:zod.z.string(),Rate:B.nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish(),DailyLimit:zod.z.number().nullish()}).passthrough(),Tn=zod.z.object({Enabled:zod.z.boolean().nullish(),RateMode:Ku.nullish(),FeePercent:B.nullish(),Targets:zod.z.array(Yu).nullish()}).passthrough(),Pn=zod.z.object({CreatedAt:l.nullish(),UpdatedAt:l.nullish()}).passthrough(),Xu=zod.z.object({CurrencyID:zod.z.string(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Economy:$u.nullish(),Recharge:Zu.nullish(),Conversion:Tn.nullish(),Permissions:Ju.nullish(),Audit:Pn.nullish(),Status:zn.nullish()}).passthrough(),ec=zod.z.object({NetworkID:zod.z.string(),ContractAddress:zod.z.string().nullish(),Decimals:zod.z.number().nullish(),MinDeposit:B.nullish(),MinWithdraw:B.nullish(),WithdrawFee:B.nullish(),DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish()}).passthrough(),tc=zod.z.object({DailyWithdrawUsd:B.nullish(),MonthlyWithdrawUsd:B.nullish(),KycRequiredAboveUsd:B.nullish()}).passthrough(),sc=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),SpendableInGame:zod.z.boolean().nullish(),ConvertibleToVirtual:zod.z.boolean().nullish()}).passthrough(),Xr=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:B.nullish(),ValueInUSDUpdatedAt:l.nullish(),DeveloperDepositSharePercent:B.nullish(),CommunityMarketingDepositSharePercent:B.nullish(),WithdrawalBurnPercent:B.nullish(),Networks:zod.z.array(ec).nullish(),Limits:tc.nullish(),Permissions:sc.nullish(),Conversion:Tn.nullish(),Audit:Pn.nullish(),Status:zn.nullish()}).passthrough(),zs=zod.z.object({VirtualCurrencies:zod.z.record(zod.z.string(),Xu).nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Xr).nullish()}).passthrough();var In=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),ItemInstanceID:zod.z.string().nullish(),EquippedAt:l.nullish()}),ei=zod.z.object({CharacterID:zod.z.string(),Level:zod.z.number().nullish(),Experience:M.nullish(),Power:zod.z.number().nullish(),StatLevels:zod.z.record(zod.z.string(),zod.z.number()).nullish(),Equipment:zod.z.record(zod.z.string(),In).nullish(),UpdatedAt:l.nullish()}).passthrough(),rc=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),ic=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:l,ExpiresAt:l.nullish(),EquippedSlot:rc.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(a=>a),et=zod.z.object({ChangedInstances:zod.z.record(zod.z.string(),ic).nullish(),RemovedInstanceIDs:zod.z.array(zod.z.string()).nullish()}),kn=zod.z.object({Characters:zod.z.record(zod.z.string(),ei).nullish()}),ti=zod.z.object({ServerTimeUtc:l,CharacterID:zod.z.string(),StatID:zod.z.string(),StatLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:x.nullish()}),si=zod.z.object({ServerTimeUtc:l,CharacterID:zod.z.string(),NewLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:x.nullish()}),Mn=zod.z.object({ServerTimeUtc:l,CharacterID:zod.z.string(),Equipment:zod.z.record(zod.z.string(),In).nullish(),ReplacedInstanceIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:et.nullish()}),An=zod.z.object({ServerTimeUtc:l,CharacterID:zod.z.string(),ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:et.nullish()}),nc=zod.z.object({ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish()}),Un=zod.z.object({ServerTimeUtc:l,Characters:zod.z.record(zod.z.string(),nc).nullish(),Inventory:et.nullish()}),ri=zod.z.object({ServerTimeUtc:l,CharacterID:zod.z.string(),Power:zod.z.number().nullish(),Resources:x.nullish()}),On=Et(ri),wn=Et(si),Bn=Et(ti),qn=zod.z.object({RequiredStatID:zod.z.string(),RequiredLevel:zod.z.number()}).passthrough(),En=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:K.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(qn).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Ln=zod.z.object({Level:zod.z.number().nullish(),UpgradeCost:K.nullish(),GlobalStatMultiplier:zod.z.number().nullish(),StatMaxLevelMultiplier:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),oc=zod.z.object({SlotID:zod.z.string(),MinCharacterLevel:zod.z.number().nullish(),StatRequirements:zod.z.array(qn).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(),Gn=zod.z.object({Slots:zod.z.record(zod.z.string(),oc).nullish()}).passthrough(),ac=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(),lc=zod.z.object({ClassID:zod.z.string().nullish(),RarityID:zod.z.string().nullish(),Tags:zod.z.array(zod.z.string()).nullish()}).passthrough(),uc=zod.z.object({UnlockedByDefault:zod.z.boolean().nullish(),Cost:K.nullish()}).passthrough(),cc=zod.z.object({Stats:ne.nullish(),Levels:ne.nullish(),Equipment:ne.nullish()}).passthrough(),pc=zod.z.object({CharacterID:zod.z.string(),Identity:ac.nullish(),Classification:lc.nullish(),Unlock:uc.nullish(),Presets:cc.nullish(),Equipment:Gn.nullish(),Stats:zod.z.record(zod.z.string(),En).nullish(),Levels:zod.z.record(zod.z.string(),Ln).nullish()}).passthrough(),dc=zod.z.object({Stats:zod.z.record(zod.z.string(),En).nullish()}).passthrough(),hc=zod.z.object({Levels:zod.z.record(zod.z.string(),Ln).nullish()}).passthrough(),mc=zod.z.object({Equipment:Gn.nullish()}).passthrough(),fc=zod.z.object({Stats:zod.z.record(zod.z.string(),dc).nullish(),Levels:zod.z.record(zod.z.string(),hc).nullish(),Equipment:zod.z.record(zod.z.string(),mc).nullish()}).passthrough(),Ts=zod.z.object({Definitions:zod.z.record(zod.z.string(),pc).nullish(),Presets:fc.nullish()}).passthrough(),Te={GetCharacterDefinitions:"GetCharacterDefinitions",GetUserCharacters:"GetUserCharacters",UnlockCharacter:"UnlockCharacter",UpgradeStatLevel:"UpgradeStatLevel",UpgradeCharacterLevel:"UpgradeCharacterLevel",EquipItems:"EquipItems",UnequipItems:"UnequipItems",UnequipAllCharacters:"UnequipAllCharacters",UnlockCharactersBatch:"UnlockCharactersBatch",UpgradeCharacterLevelsBatch:"UpgradeCharacterLevelsBatch",UpgradeStatLevelsBatch:"UpgradeStatLevelsBatch"};var gc={EVM:"EVM",Solana:"Solana"},Rc=zod.z.enum(["EVM","Solana"]),yc={AutoLinkedFromTransaction:"AutoLinkedFromTransaction",SignatureVerified:"SignatureVerified",ManuallyLinked:"ManuallyLinked"},Cc=zod.z.enum(["AutoLinkedFromTransaction","SignatureVerified","ManuallyLinked"]),Sc={Token:"Token",Nft:"Nft"},Nn=zod.z.enum(["Token","Nft"]),xc={NotRequested:"NotRequested",Pending:"Pending",Verified:"Verified",Rejected:"Rejected",Expired:"Expired"},Dc=zod.z.enum(["NotRequested","Pending","Verified","Rejected","Expired"]),bc={None:"None",Tier1:"Tier1",Tier2:"Tier2",Tier3:"Tier3"},vc=zod.z.enum(["None","Tier1","Tier2","Tier3"]),zc={Pending:"Pending",Completed:"Completed",Failed:"Failed",Expired:"Expired",Abandoned:"Abandoned"},ii=zod.z.enum(["Pending","Completed","Failed","Expired","Abandoned"]),jn={GameTopUp:"game_topup",CommunityReward:"community_reward"};function Ps(a){let e=a?.trim();return e||jn.GameTopUp}var Tc={UsersCryptoWallet:"UsersCryptoWallet",Game:"Game"},Fn=zod.z.enum(["UsersCryptoWallet","Game"]),Pc=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(),Vn=zod.z.object({Ios:zod.z.boolean().nullish(),Android:zod.z.boolean().nullish(),Web:zod.z.boolean().nullish()}).passthrough(),Ic=zod.z.object({NetworkID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Type:Rc.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:Vn.nullish(),NftCollections:zod.z.array(Pc).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),kc=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),NftDepositsEnabled:zod.z.boolean().nullish(),NftWithdrawalsEnabled:zod.z.boolean().nullish(),PlatformOverrides:Vn.nullish()}).passthrough(),Mc=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 Ac=zod.z.enum(["OnChain","Combined"]),Uc=zod.z.object({Enabled:zod.z.boolean().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),MinBalance:B.nullish(),BalanceSource:Ac.nullish(),DenyMessage:zod.z.string().nullish()}).passthrough(),Oc=zod.z.object({Enabled:zod.z.boolean().nullish(),TokenGates:zod.z.array(Uc).nullish(),WalletConnectProjectId:zod.z.string().nullish()}).passthrough(),ni=zod.z.object({SystemState:kc.nullish(),Networks:zod.z.record(zod.z.string(),Ic).nullish(),AccountSafety:Mc.nullish(),WalletLogin:Oc.nullish()}).passthrough(),wc=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),LinkedAt:l.nullish(),LastUsedAt:l.nullish(),LinkType:Cc.nullish(),IsSignatureVerified:zod.z.boolean().nullish()}).passthrough(),_n=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Type:Nn.nullish(),NetworkID:zod.z.string().nullish(),AssetID:zod.z.string().nullish(),Amount:B.nullish(),CreatedAt:l.nullish(),ExpiresAt:l.nullish()}).passthrough(),Bc=zod.z.object({Status:Dc.nullish(),Tier:vc.nullish(),VerifiedAt:l.nullish(),ExpiresAt:l.nullish(),RejectedAt:l.nullish(),ProviderReference:zod.z.string().nullish(),RejectionReason:zod.z.string().nullish()}).passthrough(),qc=zod.z.object({CurrencyID:zod.z.string().nullish(),Deposits:zod.z.number().nullish(),DepositsVolumeNative:B.nullish(),DepositsVolumeUsd:B.nullish(),Withdrawals:zod.z.number().nullish(),WithdrawalsVolumeNative:B.nullish(),WithdrawalsVolumeUsd:B.nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),FirstDepositAt:l.nullish(),LastDepositAt:l.nullish(),FirstWithdrawalAt:l.nullish(),LastWithdrawalAt:l.nullish()}).passthrough(),Ec=zod.z.object({TotalDeposits:zod.z.number().nullish(),TotalWithdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),TotalDepositsVolumeUsd:B.nullish(),TotalWithdrawalsVolumeUsd:B.nullish(),PerCurrency:zod.z.record(zod.z.string(),qc).nullish()}).passthrough(),Lc=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:l.nullish(),LastDepositAt:l.nullish(),FirstWithdrawalAt:l.nullish(),LastWithdrawalAt:l.nullish()}).passthrough(),Gc=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(),Lc).nullish()}).passthrough(),Nc=zod.z.object({Tokens:Ec.nullish(),Nfts:Gc.nullish()}).passthrough(),jc=zod.z.object({CurrencyID:zod.z.string().nullish(),Balance:B.nullish(),MinBalance:B.nullish()}).passthrough(),Fc=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),CheckedAt:l.nullish(),LoggedInAt:l.nullish(),GatePassed:zod.z.boolean().nullish(),GatedBalances:zod.z.array(jc).nullish()}).passthrough(),Vc=zod.z.object({Version:zod.z.number().nullish(),Stats:Nc.nullish(),LinkedWallets:zod.z.record(zod.z.string(),wc).nullish(),LastWalletLogin:Fc.nullish(),PendingWithdrawals:zod.z.array(_n).nullish(),Kyc:Bc.nullish(),FirstActivityAt:l.nullish(),LastActivityAt:l.nullish(),IsFlagged:zod.z.boolean().nullish(),FlagReason:zod.z.string().nullish()}).passthrough(),_c=zod.z.object({CurrencyID:zod.z.string(),AmountDelta:B,FrozenDelta:B,UpdatedAt:l}).passthrough(),Is=zod.z.object({CryptoBalances:zod.z.record(zod.z.string(),_c).nullish(),PendingAdded:_n.nullish(),PendingRemovedIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),Wc=zod.z.object({Amount:B,Frozen:B,CreatedAt:l.nullish(),UpdatedAt:l.nullish()}).passthrough().transform(a=>a),Qc=zod.z.object({ID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CreatedAt:l.nullish(),UpdatedAt:l.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:Fn.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:B.nullish(),Status:ii.nullish(),SignatureData:zod.z.string().nullish(),CompletedAt:l.nullish(),ExpiresAt:l.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:B.nullish(),NetPayoutAmount:B.nullish()}).passthrough(),Hc=zod.z.object({ID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CreatedAt:l.nullish(),UpdatedAt:l.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:Fn.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:B.nullish(),Status:ii.nullish(),SignatureData:zod.z.string().nullish(),CompletedAt:l.nullish(),ExpiresAt:l.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(),Wn=zod.z.object({To:zod.z.string().nullish(),Amount:zod.z.union([zod.z.string(),zod.z.number()]).nullish()}).passthrough(),oi=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(Wn).nullish(),Signature:zod.z.string().nullish()}).passthrough(),ai=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(Wn).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(),Qn=zod.z.object({Blockchain:ni.nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Xr).nullish()}).passthrough(),Hn=zod.z.object({State:Vc.nullish(),CryptoBalances:zod.z.record(zod.z.string(),Wc).nullish()}).passthrough(),Kn=zod.z.object({ServerTimeUtc:l.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:B.nullish(),AmountUsd:B.nullish(),StateDelta:Is.nullish()}).passthrough(),$n=zod.z.object({ServerTimeUtc:l.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:x.nullish(),Inventory:et.nullish()}).passthrough(),Zn=zod.z.object({ServerTimeUtc:l.nullish(),TitleTransactionID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:B.nullish(),NetAmountNative:B.nullish(),BurnAmountNative:B.nullish(),AmountUsd:B.nullish(),ExpiresAt:l.nullish(),EvmSignature:oi.nullish(),SolanaSignature:ai.nullish(),StateDelta:Is.nullish()}).passthrough(),Jn=zod.z.object({ServerTimeUtc:l.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:l.nullish(),Resources:x.nullish(),EvmSignature:oi.nullish(),SolanaSignature:ai.nullish(),StateDelta:Is.nullish(),Inventory:et.nullish()}).passthrough(),Yn=zod.z.object({TokenTransactions:zod.z.array(Qc).nullish(),NFTTransactions:zod.z.array(Hc).nullish()}).passthrough(),li=zod.z.object({ServerTimeUtc:l.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:B.nullish(),AmountUsd:B.nullish(),Target:zod.z.string().nullish()}).passthrough(),Xn=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Kind:Nn.nullish(),EvmSignature:oi.nullish(),SolanaSignature:ai.nullish()}).passthrough(),eo=zod.z.object({TitleTransactionID:zod.z.string().nullish(),OnChainTxHash:zod.z.string().nullish(),Status:ii.nullish(),StateDelta:Is.nullish()}).passthrough(),Pe={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",DepositToken:"DepositToken",DepositNFT:"DepositNFT",RequestTokenWithdrawal:"RequestTokenWithdrawal",RequestNFTWithdrawal:"RequestNFTWithdrawal",GetTransactionHistory:"GetTransactionHistory",RetryWithdrawal:"RetryWithdrawal",ConfirmWithdrawal:"ConfirmWithdrawal",DonateToDeveloper:"DonateToDeveloper",DonateToUsersPool:"DonateToUsersPool"};var Kc="Blockchain",ks=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(Kc,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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.NetworkID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.depositToken(s);return r.ok&&r.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(r.data.CurrencyID,new Ft__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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.NetworkID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.depositNFT(s);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,s,r,i){if(!e)return n("client","CurrencyID is required.");if(!t)return n("client","NetworkID is required.");if(!s)return n("client","WalletAddress is required.");if(!r)return n("client","Amount is required.");let c=this.baseRequest();if(!c)return n("unauthorized","Not logged in.");c.CurrencyID=e,c.NetworkID=t,c.WalletAddress=s,c.Amount=r,c.Category=Ps(i);let d=await this.ctx.api.blockchain.requestTokenWithdrawal(c);return d.ok&&d.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(d.data.CurrencyID,new Ft__default.default(d.data.AmountNative??0).negated(),d.data.ServerTimeUtc??void 0),this.ctx.emitter.emit("blockchain:tokenWithdrawalRequested",d.data)),d}async requestNFTWithdrawal(e,t,s,r,i,c,d){if(!e)return n("client","ItemID is required.");if(!t)return n("client","NetworkID is required.");if(!s)return n("client","WalletAddress is required.");if(!r)return n("client","Amount is required.");let v=this.baseRequest();if(!v)return n("unauthorized","Not logged in.");v.ItemID=e,v.NetworkID=t,v.WalletAddress=s,v.Amount=r,v.Category=Ps(i),c!==void 0&&(v.Level=c),d&&(v.ItemInstanceID=d);let w=await this.ctx.api.blockchain.requestNFTWithdrawal(v);return w.ok&&(this.ctx.data.user.applyResourceOperation(w.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("blockchain:nftWithdrawalRequested",w.data)),w}async getTransactionHistory(e=50){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Amount=String(e);let s=await this.ctx.api.blockchain.getTransactionHistory(t);return s.ok&&this.ctx.emitter.emit("blockchain:transactionHistoryLoaded",s.data),s}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 s=await this.ctx.api.blockchain.retryWithdrawal(t);return s.ok&&this.ctx.emitter.emit("blockchain:withdrawalRetried",s.data),s}async confirmWithdrawal(e,t){if(!e)return n("client","TitleTransactionID is required.");if(!t)return n("client","On-chain TransactionHash is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.TitleTransactionID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.confirmWithdrawal(s);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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.NetworkID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.donateToDeveloper(s);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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.NetworkID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.donateToUsersPool(s);return r.ok&&this.ctx.emitter.emit("blockchain:donatedToUsersPool",r.data),r}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ce=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 $c={Head:"Head",Torso:"Torso",Legs:"Legs"},Ms=zod.z.enum(["Head","Torso","Legs"]),Zc={Open:"Open",InProgress:"InProgress",Cancelled:"Cancelled",Completed:"Completed"},ui=zod.z.enum(["Open","InProgress","Cancelled","Completed"]),ro=zod.z.object({AttackTarget:Ms,DefenseTarget:Ms});var Jc=zod.z.enum(["Hit","Critical","Block","Dodge"]),Yc=zod.z.object({RoundIndex:zod.z.number().nullish(),AttackerID:zod.z.string().nullish(),DefenderID:zod.z.string().nullish(),AttackZone:Ms.nullish(),DefenseZone:Ms.nullish(),HitType:Jc.nullish(),DamageDealt:zod.z.number().nullish(),DefenderHpRemaining:zod.z.number().nullish()}).passthrough(),Xc=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(),ep=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:l,ExpiresAt:l.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(a=>a),so=zod.z.object({UserID:zod.z.string().nullish(),SelectedCharacterID:zod.z.string().nullish(),SelectedCharacter:ei.nullish(),BattleStrategy:zod.z.array(ro).nullish(),UnstackableItems:zod.z.record(zod.z.string(),ep).nullish(),Stats:Xc.nullish()}).passthrough(),tp=zod.z.object({WinnerUserID:zod.z.string().nullish(),LoserUserID:zod.z.string().nullish(),Entry:ce.nullish(),NetReward:ce.nullish(),BattleLog:zod.z.array(Yc).nullish(),IsDraw:zod.z.boolean().nullish(),P1BattleProfile:so.nullish(),P2BattleProfile:so.nullish()}).passthrough(),io=zod.z.object({MatchID:zod.z.string(),TitleID:zod.z.string().nullish(),RuleID:zod.z.string().nullish(),CreatedAt:l.nullish(),CreatorID:zod.z.string().nullish(),CreatorCharacterID:zod.z.string().nullish(),CreatorStrategy:zod.z.array(ro).nullish(),TargetUserID:zod.z.string().nullish(),Entry:ce.nullish(),CreationCostPaid:ce.nullish(),RefundCreationCostOnCancel:zod.z.boolean().nullish(),JoinedByUserID:zod.z.string().nullish(),JoinedByCharacterID:zod.z.string().nullish(),JoinedAt:l.nullish(),Status:ui.nullish(),WinnerUserID:zod.z.string().nullish(),CompletedAt:l.nullish(),IsRewardDistributed:zod.z.boolean().nullish(),RewardDistributedAt:l.nullish()}).passthrough(),no=zod.z.object({Status:ui,MatchID:zod.z.string(),Entry:ce.nullish(),Resources:x.nullish()}),oo=zod.z.object({Match:io.nullish()}),ao=zod.z.object({MatchID:zod.z.string(),Status:ui,Resources:x.nullish()}),lo=zod.z.object({Battle:tp.nullish(),Resources:x.nullish(),ResourcesDual:st.nullish()}),ci=zod.z.object({Matches:zod.z.array(io).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 sp=zod.z.enum(["VirtualCurrency","Item","EventToken"]);var rp=zod.z.enum(["Constant","Stat","RankMultiplier","AllMight","GearFlat","GearPercent"]),ip=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(),np=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(),op=zod.z.object({Source:rp.nullish(),StatID:zod.z.string().nullish(),Value:zod.z.number().nullish(),OnePlus:zod.z.boolean().nullish()}).passthrough(),ap=zod.z.object({Coefficient:zod.z.number().nullish(),Factors:zod.z.array(op).nullish()}).passthrough(),it=zod.z.object({Terms:zod.z.array(ap).nullish()}).passthrough(),lp=zod.z.object({Health:it.nullish(),Damage:it.nullish(),Armor:it.nullish(),AttackSpeed:it.nullish(),CritChance:it.nullish(),CritDamage:it.nullish(),Dodge:it.nullish()}).passthrough(),uo=zod.z.object({StatMapping:ip.nullish(),Combat:np.nullish(),Formula:lp.nullish()}).passthrough(),up=zod.z.object({BurnRate:zod.z.number().nullish()}).passthrough(),pi=zod.z.object({Kind:sp.nullish(),CurrencyID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),TokenType:wt.nullish(),EntityID:zod.z.string().nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish()}).passthrough(),co=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(pi).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),po=zod.z.object({Cost:K.nullish(),RefundCostOnCancel:zod.z.boolean().nullish(),MaxOpenMatches:zod.z.number().nullish(),Limits:de.nullish(),AllowPrivateMatches:zod.z.boolean().nullish(),MaxMatchesPerOpponentPerDay:zod.z.number().nullish()}).passthrough(),cp=zod.z.object({RuleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Economy:up.nullish(),Entry:co.nullish(),Creation:po.nullish(),Settings:uo.nullish()}).passthrough(),pp=zod.z.object({Rules:zod.z.record(zod.z.string(),cp).nullish(),Defaults:uo.nullish(),EntryDefaults:co.nullish(),CreationDefaults:po.nullish()}).passthrough(),di=zod.z.object({InstantBattle:pp.nullish()}).passthrough(),ho=di;var dp={Listing:"Listing",Auction:"Auction",BuyOrder:"BuyOrder",DirectTrade:"DirectTrade"},hi=zod.z.enum(["Listing","Auction","BuyOrder","DirectTrade"]),hp={Active:"Active",Completed:"Completed",Cancelled:"Cancelled",Declined:"Declined",Expired:"Expired"},mi=zod.z.enum(["Active","Completed","Cancelled","Declined","Expired"]),mp={Burn:"Burn",Ledger:"Ledger"},fp=zod.z.enum(["Burn","Ledger"]),Us={Item:"Item",VirtualCurrency:"VirtualCurrency"},fi=zod.z.enum(["Item","VirtualCurrency"]),gp=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:M.nullish()}).passthrough(),Rp=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(pi).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),yp=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:M.nullish(),Sink:fp.nullish(),LedgerAccountID:zod.z.string().nullish(),PerCatalogOverrides:zod.z.record(zod.z.string(),gp).nullish(),ApplyToDirectTrades:zod.z.boolean().nullish()}).passthrough(),Cp=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(),Sp=zod.z.object({Enabled:zod.z.boolean().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),MaxActiveListings:zod.z.number().nullish(),CreateLimits:de.nullish(),BuyLimits:de.nullish(),ListingFee:K.nullish(),RefundListingFeeOnCancel:zod.z.boolean().nullish()}).passthrough(),xp=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:M.nullish(),BidLimits:de.nullish()}).passthrough(),Dp=zod.z.object({Enabled:zod.z.boolean().nullish(),MaxActiveOrders:zod.z.number().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),CreateLimits:de.nullish(),FillLimits:de.nullish()}).passthrough(),bp=zod.z.object({Enabled:zod.z.boolean().nullish(),OfferExpirationHours:zod.z.number().nullish(),MaxPendingOutgoing:zod.z.number().nullish(),AllowGifts:zod.z.boolean().nullish(),CreateLimits:de.nullish()}).passthrough(),vp=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),gi=zod.z.object({Enabled:zod.z.boolean().nullish(),Gate:Q.nullish(),Schedule:pe.nullish(),PricePolicy:Rp.nullish(),Commission:yp.nullish(),Tradability:Cp.nullish(),Listings:Sp.nullish(),Auctions:xp.nullish(),BuyOrders:Dp.nullish(),DirectTrades:bp.nullish(),Matching:vp.nullish()}).passthrough(),mo=zod.z.object({BidIndex:zod.z.number().nullish(),UserID:zod.z.string().nullish(),Amount:M.nullish(),Settled:zod.z.boolean().nullish(),SettledAt:l.nullish()}).passthrough(),zp=zod.z.object({BidAxisType:Ot.nullish(),BidCurrencyID:zod.z.string().nullish(),BidCatalogID:zod.z.string().nullish(),BidItemID:zod.z.string().nullish(),StartingBid:M.nullish(),CurrentBid:M.nullish(),CurrentBidderID:zod.z.string().nullish(),BidCount:zod.z.number().nullish(),ExtensionCount:zod.z.number().nullish(),PendingRefunds:zod.z.array(mo).nullish()}).passthrough(),As=zod.z.object({LastAt:l.nullish(),DailyCount:zod.z.number().nullish(),DailyResetUtc:l.nullish()}).passthrough(),Tp=zod.z.object({Create:As.nullish(),Buy:As.nullish(),Sell:As.nullish(),Bid:As.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:l,ExpiresAt:l.nullish(),EquippedSlot:Pp.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(a=>a),He=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:hi.nullish(),Status:mi.nullish(),CreatorUserID:zod.z.string().nullish(),CreatorPublicData:Ce.nullish(),TargetUserID:zod.z.string().nullish(),GoodsType:fi.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:M.nullish(),GoodsInstances:zod.z.array(Ip).nullish(),Price:ce.nullish(),Auction:zp.nullish(),CreatedAt:l.nullish(),ExpiresAt:l.nullish()}).passthrough(),kp=zod.z.object({GoodsType:fi.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),CountsByType:zod.z.record(hi,M).nullish(),ListingCount:M.nullish(),AuctionCount:M.nullish(),BuyOrderCount:M.nullish()}).passthrough(),fo=zod.z.object({Definitions:gi.nullish(),IsOpenNow:zod.z.boolean().nullish(),GatePassed:zod.z.boolean().nullish()}).passthrough(),Ri=zod.z.object({Offers:zod.z.array(He).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),go=zod.z.object({Groups:zod.z.array(kp).nullish()}).passthrough(),Ro=zod.z.object({Offer:He.nullish()}).passthrough(),Ue=zod.z.object({OfferID:zod.z.string().nullish(),Status:mi.nullish(),Settlement:st.nullish(),Resources:x.nullish(),CommissionTaken:ce.nullish()}).passthrough(),Tt=zod.z.object({OfferID:zod.z.string().nullish(),Offer:He.nullish(),Resources:x.nullish(),Matched:zod.z.boolean().nullish(),Settlement:Ue.nullish()}).passthrough(),yo=zod.z.object({OfferID:zod.z.string().nullish(),CurrentBid:M.nullish(),BidCount:zod.z.number().nullish(),ExpiresAt:l.nullish(),Resources:x.nullish()}).passthrough(),Co=zod.z.object({MyOffers:zod.z.array(He).nullish(),MyLeadingBids:zod.z.array(He).nullish(),MyBuyOrders:zod.z.array(He).nullish(),IncomingTrades:zod.z.array(He).nullish(),OutgoingTrades:zod.z.array(He).nullish(),Claimables:zod.z.array(He).nullish(),DrainedRefunds:zod.z.array(mo).nullish(),Limits:Tp.nullish()}).passthrough(),Mp=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:hi.nullish(),FinalStatus:mi.nullish(),SellerUserID:zod.z.string().nullish(),BuyerUserID:zod.z.string().nullish(),GoodsType:fi.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:M.nullish(),PricePaid:ce.nullish(),CommissionTaken:ce.nullish(),CompletedAt:l.nullish()}).passthrough(),So=zod.z.object({Entries:zod.z.array(Mp).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),ie={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 Ap="Marketplace",Os=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(Ap,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,s,r=20){if(!e)return n("client","ItemID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.ItemID=e,i.OfferTypeFilter=t,i.ContinuationToken=s,i.PageSize=r;let c=await this.ctx.api.marketplace.getOffersByItem(i);return c.ok&&this.ctx.emitter.emit("marketplace:offersByItemLoaded",c.data),c}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 s=await this.ctx.api.marketplace.getOffer(t);return s.ok&&this.ctx.emitter.emit("marketplace:offerLoaded",s.data),s}async getBuyOrders(e,t,s=20){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.ItemID=e,r.ContinuationToken=t,r.PageSize=s;let i=await this.ctx.api.marketplace.getBuyOrders(r);return i.ok&&this.ctx.emitter.emit("marketplace:buyOrdersLoaded",i.data),i}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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.ContinuationToken=e,s.PageSize=t;let r=await this.ctx.api.marketplace.getHistory(s);return r.ok&&this.ctx.emitter.emit("marketplace:historyLoaded",r.data),r}async createListing(e,t,s,r,i,c){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=s,d.PriceBundle=r,d.DurationHours=i,d.ItemInstanceIDs=c;let v=await this.ctx.api.marketplace.createListing(d);return this.applyCreateOfferResult(v,"marketplace:listingCreated"),v}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 s=await this.ctx.api.marketplace.buy(t);return s.ok&&(this.applyDualPartySettlement(s.data.Settlement),this.ctx.emitter.emit("marketplace:bought",s.data)),s}async marketBuy(e,t,s){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 i=this.applyGoodsSelector(r,s);if(i)return i;r.GoodsAmount=e,r.PriceBundle=t;let c=await this.ctx.api.marketplace.marketBuy(r);return c.ok&&(this.applyDualPartySettlement(c.data.Settlement),this.ctx.emitter.emit("marketplace:marketBought",c.data)),c}async marketSell(e,t,s){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 i=this.applyGoodsSelector(r,s);if(i)return i;r.GoodsAmount=e,r.PriceBundle=t;let c=await this.ctx.api.marketplace.marketSell(r);return c.ok&&(this.applyDualPartySettlement(c.data.Settlement),this.ctx.emitter.emit("marketplace:marketSold",c.data)),c}async createAuction(e,t,s,r,i,c,d={}){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");let v=this.baseRequest();if(!v)return n("unauthorized","Not logged in.");v.ItemID=e,v.CatalogID=t,v.GoodsAmount=s,v.BidAxisType=r,v.BidCurrencyID=d.bidCurrencyID,v.BidCatalogID=d.bidCatalogID,v.BidItemID=d.bidItemID,v.StartingBid=i,v.DurationHours=c,v.ItemInstanceIDs=d.itemInstanceIDs;let w=await this.ctx.api.marketplace.createAuction(v);return this.applyCreateOfferResult(w,"marketplace:auctionCreated"),w}async placeBid(e,t){if(!e)return n("client","OfferID is required.");if(!t||t<=0)return n("client","BidAmount must be positive.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.OfferID=e,s.BidAmount=t;let r=await this.ctx.api.marketplace.placeBid(s);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 s=await this.ctx.api.marketplace.claimAuction(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:auctionClaimed",s.data)),s}async createBuyOrder(e,t,s,r,i){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 c=this.baseRequest();if(!c)return n("unauthorized","Not logged in.");c.ItemID=e,c.CatalogID=t,c.GoodsAmount=s,c.PriceBundle=r,c.DurationHours=i;let d=await this.ctx.api.marketplace.createBuyOrder(c);return this.applyCreateOfferResult(d,"marketplace:buyOrderCreated"),d}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 s=await this.ctx.api.marketplace.fillBuyOrder(t);return s.ok&&(this.applyDualPartySettlement(s.data.Settlement),this.ctx.emitter.emit("marketplace:buyOrderFilled",s.data)),s}async createDirectTrade(e,t,s,r,i){if(!e)return n("client","TargetUserID is required.");if(!t)return n("client","CatalogID is required.");if(!s)return n("client","ItemID is required.");let c=this.baseRequest();if(!c)return n("unauthorized","Not logged in.");c.TargetUserID=e,c.CatalogID=t,c.ItemID=s,c.ItemInstanceIDs=r,c.RequestedBundle=i;let d=await this.ctx.api.marketplace.createDirectTrade(c);return this.applyCreateOfferResult(d,"marketplace:directTradeCreated"),d}async respondDirectTrade(e,t){if(!e)return n("client","OfferID is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.OfferID=e,s.Accept=t;let r=await this.ctx.api.marketplace.respondDirectTrade(s);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 s=await this.ctx.api.marketplace.claimBack(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:claimedBack",s.data)),s}async cancelOffer(e,t,s){if(!e)return n("client","OfferID is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.OfferID=e;let i=await t(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit(s,i.data)),i}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=Us.VirtualCurrency,e.GoodsCurrencyID=t.goodsCurrencyID,null):"itemID"in t&&t.itemID&&t.catalogID?(e.GoodsType=Us.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 s=this.ctx.data.config.itemDefinitions;e.FromUserID===t&&e.FromResult?this.ctx.data.user.applyResourceOperation(e.FromResult,s):e.ToUserID===t&&e.ToResult&&this.ctx.data.user.applyResourceOperation(e.ToResult,s);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var ws=class{constructor(e){this.ctx=e;}ctx;async createRoom(e,t={}){if(!e)return n("client","RoomName is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomName=e,s.Topology=t.topology,s.ChatMode=t.chatMode,s.MaxPlayers=t.maxPlayers,s.Visibility=t.visibility,s.JoinCode=t.joinCode;let r=await this.ctx.api.multiplayer.createRoom(s);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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomID=e,s.JoinCode=t;let r=await this.ctx.api.multiplayer.joinRoom(s);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 s=await this.ctx.api.multiplayer.leaveRoom(t);return s.ok&&this.ctx.emitter.emit("multiplayer:roomLeft",s.data),s}async listRooms(e=0,t=20){let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.Page=e,s.PageSize=t;let r=await this.ctx.api.multiplayer.listRooms(s);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 s=await this.ctx.api.multiplayer.getRoom(t);return s.ok&&this.ctx.emitter.emit("multiplayer:roomLoaded",s.data),s}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 s=await this.ctx.api.multiplayer.closeRoom(t);return s.ok&&this.ctx.emitter.emit("multiplayer:roomClosed",s.data),s}async poll(e,t){if(!e)return n("client","RoomID is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomID=e,s.LastSeq=t;let r=await this.ctx.api.multiplayer.poll(s);return r.ok&&this.ctx.emitter.emit("multiplayer:polled",r.data),r}async sendSignal(e,t,s,r){if(!e)return n("client","RoomID is required.");if(!t)return n("client","TargetUserID is required.");if(!s)return n("client","SignalKind is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.TargetUserID=t,i.SignalKind=s,i.Payload=r;let c=await this.ctx.api.multiplayer.sendSignal(i);return c.ok&&this.ctx.emitter.emit("multiplayer:signalSent",c.data),c}async sendChat(e,t){if(!e)return n("client","RoomID is required.");if(!t)return n("client","ChatText is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomID=e,s.ChatText=t;let r=await this.ctx.api.multiplayer.sendChat(s);return r.ok&&this.ctx.emitter.emit("multiplayer:chatSent",r.data),r}async setMemberState(e,t,s){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=s;let i=await this.ctx.api.multiplayer.setMemberState(r);return i.ok&&this.ctx.emitter.emit("multiplayer:memberStateSet",i.data),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var xo=zod.z.object({PlatformUserID:zod.z.string().nullish(),PlatformAuthToken:zod.z.string().nullish(),PlatformAuthTokenExpiration:l.nullish(),TitleUserID:zod.z.string(),TitleClientSessionTicket:zod.z.string(),TitleClientSessionTicketExpiration:l}),Se=zod.z.object({IsCompleted:zod.z.boolean().nullish(),ServerTime:l.nullish()}),Do=zod.z.object({Message:zod.z.string(),ExpiresAt:l}),Ie={LoginWithDeviceID:"LoginWithDeviceID",LoginWithTelegram:"LoginWithTelegram",LoginWithEmail:"LoginWithEmail",LoginWithGoogle:"LoginWithGoogle",LoginWithPlatformToken:"LoginWithPlatformToken",LoginWithSsoCode:"LoginWithSsoCode",RegisterWithEmail:"RegisterWithEmail",RequestWalletChallenge:"RequestWalletChallenge",LoginWithWallet:"LoginWithWallet",ForgotPassword:"ForgotPassword",ResetPassword:"ResetPassword"};function U(a,e,t,s){let i=`api/v2/${a&&a.length>0?a:"0"}/Client/${e}/${t}`;return s==null?i:`${i}/${s}`}var Bs=class{constructor(e){this.ctx=e;}ctx;endpoint(e){return U(this.ctx.settings.titleID,"Authentication",e)}login(e,t){return this.ctx.transport.post(this.endpoint(e),t,xo,{ticket:null})}loginWithDeviceID(e){return this.login(Ie.LoginWithDeviceID,e)}loginWithTelegram(e){return this.login(Ie.LoginWithTelegram,e)}loginWithEmail(e){return this.login(Ie.LoginWithEmail,e)}loginWithGoogle(e){return this.login(Ie.LoginWithGoogle,e)}loginWithPlatformToken(e){return this.login(Ie.LoginWithPlatformToken,e)}loginWithSsoCode(e){return this.login(Ie.LoginWithSsoCode,e)}registerWithEmail(e){return this.login(Ie.RegisterWithEmail,e)}requestWalletChallenge(e){return this.ctx.transport.post(this.endpoint(Ie.RequestWalletChallenge),e,Do,{ticket:null})}loginWithWallet(e){return this.login(Ie.LoginWithWallet,e)}forgotPassword(e){return this.ctx.transport.post(this.endpoint(Ie.ForgotPassword),e,Se,{ticket:null})}resetPassword(e){return this.ctx.transport.post(this.endpoint(Ie.ResetPassword),e,Se,{ticket:null})}};var yi=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()}).passthrough().transform(a=>a),bo=zod.z.object({StateEpoch:zod.z.string().nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough().transform(a=>a),vo=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(a=>a),zo=zod.z.object({}).passthrough().transform(a=>a),To=zod.z.object({}).passthrough().transform(a=>a),Po=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:l.nullish(),LastActiveAt:l.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(),Io=zod.z.object({Username:zod.z.string()}),Oe={GetClientState:"GetClientState",GetClientStateExcept:"GetClientStateExcept",GetStateVersions:"GetStateVersions",GetUserState:"GetUserState",GetInventory:"GetInventory",GetEventTokens:"GetEventTokens",GetUsageTime:"GetUsageTime",AddUsageTime:"AddUsageTime",DeleteUserAccount:"DeleteUserAccount",ChangeUsername:"ChangeUsername"};var qs=class{constructor(e){this.ctx=e;}ctx;endpoint(e,t){return U(this.ctx.settings.titleID,"User",e,t??"")}getClientState(e){return this.ctx.transport.post(this.endpoint(Oe.GetClientState,e.UserID),e,yi,{ticket:e.ClientSessionTicket})}getClientStateExcept(e){return this.ctx.transport.post(this.endpoint(Oe.GetClientStateExcept,e.UserID),e,yi,{ticket:e.ClientSessionTicket})}getStateVersions(e){return this.ctx.transport.post(this.endpoint(Oe.GetStateVersions,e.UserID),e,bo,{ticket:e.ClientSessionTicket})}getUserState(e){return this.ctx.transport.post(this.endpoint(Oe.GetUserState,e.UserID),e,vo,{ticket:e.ClientSessionTicket})}getInventory(e){return this.ctx.transport.post(this.endpoint(Oe.GetInventory,e.UserID),e,zo,{ticket:e.ClientSessionTicket})}getEventTokens(e){return this.ctx.transport.post(this.endpoint(Oe.GetEventTokens,e.UserID),e,To,{ticket:e.ClientSessionTicket})}getUsageTime(e){return this.ctx.transport.post(this.endpoint(Oe.GetUsageTime,e.UserID),e,Po,{ticket:e.ClientSessionTicket})}addUsageTime(e){return this.ctx.transport.post(this.endpoint(Oe.AddUsageTime,e.UserID),e,Se,{ticket:e.ClientSessionTicket,silent:true})}deleteUserAccount(e){return this.ctx.transport.post(this.endpoint(Oe.DeleteUserAccount,e.UserID),e,Se,{ticket:e.ClientSessionTicket})}changeUsername(e){return this.ctx.transport.post(this.endpoint(Oe.ChangeUsername,e.UserID),e,Io,{ticket:e.ClientSessionTicket})}};var Es=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Currency",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}convert(e){return this.send(vs.Convert,e,bn)}cryptoConvert(e){return this.send(vs.CryptoConvert,e,vn)}};var Up=zod.z.object({ItemInstanceID:zod.z.string(),Units:zod.z.number(),Level:zod.z.number()}),Ci=zod.z.object({ServerTimeUtc:l,ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Level:zod.z.number(),Resources:x.nullish(),FodderConsumed:zod.z.array(Up).nullish()}),ko=zod.z.array(re(Ci)),Ls={UpgradeLevel:"UpgradeLevel",UpgradeLevelsBatch:"UpgradeLevelsBatch"},Op={FlatCount:"FlatCount",Merge:"Merge",InvestmentRefund:"InvestmentRefund"},wp=zod.z.enum(["FlatCount","Merge","InvestmentRefund"]),Bp={ProtectLeveled:"ProtectLeveled",CheapestFirst:"CheapestFirst",ClientSelected:"ClientSelected"},qp=zod.z.enum(["ProtectLeveled","CheapestFirst","ClientSelected"]),Ep=zod.z.object({ContractAddress:zod.z.string().nullish(),TokenID:zod.z.string().nullish(),TokenStandard:zod.z.string().nullish()}).passthrough(),Lp=zod.z.object({Networks:zod.z.record(zod.z.string(),Ep).nullish(),MetadataUrl:zod.z.string().nullish()}).passthrough(),Gp=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(),Np=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(),jp=zod.z.object({ValuationMode:wp.nullish(),MergeRatio:zod.z.number().nullish(),Selection:qp.nullish()}).passthrough(),Fp=zod.z.object({MaxLevel:zod.z.number().nullish(),BaseCostResource:K.nullish(),CostScalingFactor:zod.z.number().nullish(),FlatScalingFactor:zod.z.number().nullish(),PercentScalingFactor:zod.z.number().nullish(),PowerScalingFactor:zod.z.number().nullish(),Fodder:jp.nullish()}).passthrough(),Vp=zod.z.object({RarityID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),AuthorID:zod.z.string().nullish()}).passthrough(),_p=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:Lp.nullish(),Stats:Gp.nullish(),Equipment:Np.nullish(),Upgrade:Fp.nullish(),Metadata:Vp.nullish(),ExpirationDurationSeconds:zod.z.number().nullish()}).passthrough(),Wp=zod.z.object({Items:zod.z.record(zod.z.string(),_p).nullish()}).passthrough(),Gs=zod.z.object({Catalogs:zod.z.record(zod.z.string(),Wp).nullish()}).passthrough();var Ns=class{constructor(e){this.ctx=e;}ctx;upgradeLevel(e){let t=U(this.ctx.settings.titleID,"Item",Ls.UpgradeLevel,e.UserID??"");return this.ctx.transport.post(t,e,Ci,{ticket:e.ClientSessionTicket})}upgradeLevelsBatch(e){let t=U(this.ctx.settings.titleID,"Item",Ls.UpgradeLevelsBatch,e.UserID??"");return this.ctx.transport.post(t,e,ko,{ticket:e.ClientSessionTicket})}};var Si=zod.z.object({ServerTimeUtc:l,OfferID:zod.z.string(),Count:zod.z.number(),Resources:x.nullish()}),Mo=zod.z.array(re(Si)),Qp=zod.z.object({OfferID:zod.z.string(),TotalPurchases:zod.z.number(),DailyPurchases:zod.z.number(),DailyResetUtc:l,LastPurchasedAt:l}),Ao=zod.z.object({Purchases:zod.z.record(zod.z.string(),Qp).nullish()}).passthrough().transform(a=>a),Hp=zod.z.object({StartUtc:l.nullish(),EndUtc:l.nullish(),RequiredFlags:zod.z.array(zod.z.string()).nullish()}).passthrough(),Kp=zod.z.object({StoreID:zod.z.string(),Type:zod.z.string().nullish(),Name:zod.z.string().nullish(),Description:zod.z.string().nullish(),Rules:Hp.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),$p=zod.z.object({StartUtc:l.nullish(),EndUtc:l.nullish(),Gate:Q.nullish(),Limits:de.nullish()}).passthrough(),Zp=zod.z.object({OfferID:zod.z.string(),StoreIDs:zod.z.array(zod.z.string()).nullish(),Name:zod.z.string().nullish(),Cost:K.nullish(),Rewards:G.nullish(),Rules:$p.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),js=zod.z.object({Stores:zod.z.record(zod.z.string(),Kp).nullish(),StoreOffers:zod.z.record(zod.z.string(),Zp).nullish()}).passthrough(),Rt={Purchase:"Purchase",GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",PurchaseBatch:"PurchaseBatch"};var Fs=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Store",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}purchase(e){return this.send(Rt.Purchase,e,Si)}purchaseBatch(e){return this.send(Rt.PurchaseBatch,e,Mo)}getDefinitions(e){return this.send(Rt.GetDefinitions,e,js)}getUserState(e){return this.send(Rt.GetUserState,e,Ao)}};var Jp=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),Uo=zod.z.object({Reward:G.nullish(),Weight:zod.z.number().nullish(),AmountRange:Jp.nullish()}).passthrough(),yt=zod.z.object({SlotID:zod.z.string().nullish(),MinRolls:zod.z.number().nullish(),MaxRolls:zod.z.number().nullish(),Pool:zod.z.array(Uo).nullish()}).passthrough(),Ct=zod.z.object({RuleID:zod.z.string().nullish(),Threshold:zod.z.number().nullish(),Pool:zod.z.array(Uo).nullish()}).passthrough(),Yp=zod.z.object({RewardSlots:zod.z.array(yt).nullish()}).passthrough(),Xp=zod.z.object({PityRules:zod.z.array(Ct).nullish()}).passthrough(),Vs=zod.z.object({SlotPresets:zod.z.record(zod.z.string(),Yp).nullish(),PityPresets:zod.z.record(zod.z.string(),Xp).nullish()}).passthrough();var ed=zod.z.object({RuleID:zod.z.string(),BoxIndex:zod.z.number().nullish()}),Oo=zod.z.object({ServerTimeUtc:l,LootboxID:zod.z.string(),OpenedCount:zod.z.number().nullish(),SelectedOptionID:zod.z.number().nullish(),Resources:x.nullish(),Inventory:et.nullish(),Results:zod.z.array(x).nullish(),TriggeredPity:zod.z.array(ed).nullish()}),td=zod.z.object({PriceOptionID:zod.z.number().nullish(),RequiredResources:K.nullish()}).passthrough(),sd=zod.z.object({RewardSlots:ne.nullish(),PityRules:ne.nullish()}).passthrough(),rd=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),MaxDrops:M.nullish()}).passthrough(),id=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(),td).nullish(),RewardSlots:zod.z.array(yt).nullish(),PityRules:zod.z.array(Ct).nullish(),Presets:sd.nullish(),RewardMultiplier:Bt.nullish(),SupplyLimits:zod.z.array(rd).nullish()}).passthrough(),xi=zod.z.object({Definitions:zod.z.record(zod.z.string(),id).nullish(),RewardPools:Vs.nullish()}).passthrough(),wo=zod.z.object({LootboxDefinitions:xi.nullish()}),_s={GetDefinitions:"GetDefinitions",Open:"Open"};var Ws=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Lootbox",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(_s.GetDefinitions,e,wo)}open(e){return this.send(_s.Open,e,Oo)}};var nd=zod.z.object({}).passthrough().transform(a=>a),od=zod.z.object({}).passthrough().transform(a=>a),ad=zod.z.object({}).passthrough().transform(a=>a),ld=zod.z.object({}).passthrough().transform(a=>a),ud=zod.z.object({}).passthrough().transform(a=>a),Bo=zod.z.object({ServerTimeUtc:l,CalendarID:zod.z.string(),DayNumber:zod.z.number().nullish(),DailyState:nd,Resources:x.nullish()}),qo=zod.z.object({ServerTimeUtc:l,AccrualID:zod.z.string(),AccruedSeconds:M.nullish(),AppliedRatePerSecond:zod.z.number().nullish(),IdleState:od,Resources:x.nullish()}),Eo=zod.z.object({ServerTimeUtc:l,ComebackID:zod.z.string(),ClaimedTierIndex:zod.z.number().nullish(),ComebackState:ad,Resources:x.nullish()}),Lo=zod.z.object({ServerTimeUtc:l,ClaimID:zod.z.string(),ClaimState:ld,Resources:x.nullish()}),Go=zod.z.object({Enabled:zod.z.boolean(),Multiplier:zod.z.number().nullish(),Progress:M.nullish(),Source:zod.z.string().nullish(),SourceKey:zod.z.string().nullish()}),cd=zod.z.object({RewardMode:zod.z.string().nullish(),RewardStackLowerTiers:zod.z.boolean().nullish()}).passthrough(),pd=zod.z.object({DayNumber:zod.z.number().nullish(),Rewards:G.nullish(),IsMilestone:zod.z.boolean().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),dd=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(pd).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(),hd=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),md=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(hd).nullish()}).passthrough(),fd=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(),gd=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:md.nullish(),Rewards:G.nullish(),MaxAccumulationSeconds:zod.z.number().nullish(),MinClaimSeconds:zod.z.number().nullish(),Requirements:fd.nullish(),FirstClaimMode:zod.z.string().nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Rd=zod.z.object({MinAbsenceSeconds:zod.z.number().nullish(),Rewards:G.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),yd=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(Rd).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(),Cd=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(),Sd=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:G.nullish(),Limits:de.nullish(),PremiumLimitOverrides:zod.z.array(Cd).nullish(),Gate:Q.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Di=zod.z.object({TierRewards:cd.nullish(),MilestoneRewardMultiplier:Bt.nullish(),DailyCalendars:zod.z.record(zod.z.string(),dd).nullish(),IdleAccruals:zod.z.record(zod.z.string(),gd).nullish(),Comebacks:zod.z.record(zod.z.string(),yd).nullish(),Claims:zod.z.record(zod.z.string(),Sd).nullish()}).passthrough(),No=zod.z.object({RewardDefinitions:Di.nullish()}),jo=zod.z.object({Rewards:ud.nullish()}),$e={GetRewardDefinitions:"GetRewardDefinitions",GetUserRewardsState:"GetUserRewardsState",ClaimDailyReward:"ClaimDailyReward",CollectIdleAccrual:"CollectIdleAccrual",ClaimComebackReward:"ClaimComebackReward",ClaimReward:"ClaimReward",ClaimRewardsBatch:"ClaimRewardsBatch",GetMilestoneRewardMultiplier:"GetMilestoneRewardMultiplier"};var Qs=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Reward",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getRewardDefinitions(e){return this.send($e.GetRewardDefinitions,e,No)}getUserRewardsState(e){return this.send($e.GetUserRewardsState,e,jo)}getMilestoneRewardMultiplier(e){return this.send($e.GetMilestoneRewardMultiplier,e,Go)}claimDailyReward(e){return this.send($e.ClaimDailyReward,e,Bo)}collectIdleAccrual(e){return this.send($e.CollectIdleAccrual,e,qo)}claimComebackReward(e){return this.send($e.ClaimComebackReward,e,Eo)}claimReward(e){return this.send($e.ClaimReward,e,Lo)}};var Hs=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Quest",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getQuestDefinitions(e){return this.send(Le.GetQuestDefinitions,e,Lt)}getUserQuestState(e){return this.send(Le.GetUserQuestState,e,Xi)}refreshQuestCycles(e){return this.send(Le.RefreshQuestCycles,e,Se)}claimQuestReward(e){return this.send(Le.ClaimQuestReward,e,Nr)}claimQuestRewardsBatch(e){return this.send(Le.ClaimQuestRewardsBatch,e,sn)}claimMilestoneReward(e){return this.send(Le.ClaimMilestoneReward,e,jr)}claimMilestoneRewardsBatch(e){return this.send(Le.ClaimMilestoneRewardsBatch,e,rn)}claimGroupCompletionReward(e){return this.send(Le.ClaimGroupCompletionReward,e,en)}addQuestProgress(e){return this.send(Le.AddQuestProgress,e,tn)}};var Fo=zod.z.object({}).passthrough().transform(a=>a);var xd=zod.z.object({Order:zod.z.number().nullish(),Type:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),BonusMultiplier:zod.z.number().nullish()}).passthrough(),Dd=zod.z.object({Schedule:zod.z.array(xd).nullish(),RepeatCycle:zod.z.boolean().nullish(),MaxCycles:zod.z.number().nullish()}).passthrough(),bd=zod.z.object({IsActive:zod.z.boolean().nullish(),CurrentPhaseEndUtc:l.nullish(),NextBonusStartUtc:l.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentPhaseIndex:zod.z.number().nullish(),ActiveBonusMultiplier:zod.z.number().nullish()}).passthrough(),vd=zod.z.object({Milestones:ne.nullish()}).passthrough(),bi=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:rt.nullish(),TokenSources:zod.z.array(_e).nullish(),ClaimMode:zod.z.string().nullish(),Milestones:zod.z.record(zod.z.string(),ye).nullish(),Presets:vd.nullish(),BonusWindow:Dd.nullish()}).passthrough(),zd=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Content:bi.nullish(),ClaimGraceHours:zod.z.number().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Td=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:bi.nullish(),Events:zod.z.array(zd).nullish(),Gate:Q.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Pd=zod.z.object({MaxConcurrentEvents:zod.z.number().nullish()}).passthrough(),Id=zod.z.object({Milestones:zod.z.record(zod.z.string(),Xe).nullish()}).passthrough(),Ks=zod.z.object({Definitions:zod.z.record(zod.z.string(),Td).nullish(),Settings:Pd.nullish(),Presets:Id.nullish()}).passthrough(),kd=zod.z.object({Type:vt,TimedEventID:zod.z.string(),CurrentChainedEventID:zod.z.string().nullish(),Content:bi.nullish(),Progress:Fo.nullish(),ComputedStartUtc:l.nullish(),ComputedEndUtc:l.nullish(),CanEarn:zod.z.boolean().nullish(),CanClaim:zod.z.boolean().nullish(),NextMilestone:ye.nullish(),BonusWindow:bd.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentEventOrder:zod.z.number().nullish(),TotalEventsInChain:zod.z.number().nullish()}).passthrough(),Vo=zod.z.object({ActiveEvents:zod.z.array(kd).nullish()}).passthrough(),_o=zod.z.object({Tokens:zod.z.record(zod.z.string(),Fo).nullish()}),vi=zod.z.object({Type:vt.nullish(),LteID:zod.z.string().nullish(),Resources:x.nullish()}),zi=zod.z.object({Type:vt.nullish(),LteID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Rewards:x.nullish()}),Md=zod.z.object({Type:vt.nullish(),LteID:zod.z.string().nullish(),Resources:x.nullish()}),Ti=zod.z.array(re(zi)),Wo=zod.z.array(re(vi)),Qo=zod.z.array(re(Md)),we={GetActiveEvents:"GetActiveEvents",GrantTokens:"GrantTokens",SpendTokens:"SpendTokens",ClaimMilestone:"ClaimMilestone",GetDefinitions:"GetDefinitions",GetUserLteState:"GetUserLteState",ClaimMilestonesBatch:"ClaimMilestonesBatch",ClaimAllMilestones:"ClaimAllMilestones",SpendTokensBatch:"SpendTokensBatch",GrantTokensBatch:"GrantTokensBatch"};var $s=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"TimedEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getActiveEvents(e){return this.send(we.GetActiveEvents,e,Vo)}getDefinitions(e){return this.send(we.GetDefinitions,e,Ks)}getUserLteState(e){return this.send(we.GetUserLteState,e,_o)}grantTokens(e){return this.send(we.GrantTokens,e,x)}spendTokens(e){return this.send(we.SpendTokens,e,vi)}claimMilestone(e){return this.send(we.ClaimMilestone,e,zi)}claimMilestonesBatch(e){return this.send(we.ClaimMilestonesBatch,e,Ti)}claimAllMilestones(e){return this.send(we.ClaimAllMilestones,e,Ti)}spendTokensBatch(e){return this.send(we.SpendTokensBatch,e,Wo)}grantTokensBatch(e){return this.send(we.GrantTokensBatch,e,Qo)}};var Ad=zod.z.object({UserID:zod.z.string(),Score:M.nullish(),Rank:zod.z.number().nullish(),LastScoreUpdateUtc:l.nullish(),IpHash:zod.z.string().nullish(),PublicProfile:Ce.nullish(),SeasonTierAtCycleEnd:zod.z.number().nullish()}).passthrough(),Pt=zod.z.object({LeaderboardID:zod.z.string(),CycleVersion:zod.z.number().nullish(),TotalParticipants:M.nullish(),CycleEndUtc:l.nullish(),TopUsers:zod.z.array(Ad).nullish(),BracketID:zod.z.string().nullish()}),Ud=zod.z.object({CycleKey:zod.z.string().nullish(),CycleEndUtc:l.nullish(),ClaimDeadlineUtc:l.nullish(),MilestoneTokensEarned:M.nullish(),ClaimableMilestoneIDs:zod.z.array(zod.z.string()).nullish(),CycleIndex:zod.z.number().nullish(),ChainedEventID:zod.z.string().nullish()}).passthrough(),Zs=zod.z.object({LeaderboardID:zod.z.string(),CurrentScore:M.nullish(),LastKnownRank:zod.z.number().nullish(),HasUnclaimedReward:zod.z.boolean().nullish(),ScoreEarnedThisCycle:M.nullish(),MilestoneTokensEarned:M.nullish(),NextMilestone:ye.nullish(),HasUnclaimedMilestone:zod.z.boolean().nullish(),ClaimableGraceCycles:zod.z.array(Ud).nullish()}),Js=zod.z.object({LeaderboardID:zod.z.string(),NewScore:M,CycleVersion:zod.z.number()}),Ys=zod.z.object({ServerTimeUtc:l,LeaderboardID:zod.z.string(),Rank:zod.z.number().nullish(),Resources:x.nullish()}),Xs=zod.z.object({ServerTimeUtc:l,LeaderboardID:zod.z.string(),MilestoneID:zod.z.string(),Resources:x.nullish()}),Ho=zod.z.array(re(Pt)),Ko=zod.z.array(re(Zs)),$o=zod.z.array(re(Ys)),Zo=zod.z.array(re(Xs)),Jo=zod.z.array(re(Js)),Od=zod.z.object({LeaderboardID:zod.z.string(),CycleReward:re(Ys).nullish(),Milestones:zod.z.array(re(Xs)).nullish()}),Yo=zod.z.array(Od),wd=zod.z.object({LeaderboardID:zod.z.string(),Leaderboard:re(Pt).nullish(),Progress:re(Zs).nullish()}),Xo=zod.z.array(wd),Bd=zod.z.string(),ea=zod.z.object({Rank:zod.z.string().nullish(),Rewards:G.nullish(),SeasonTierRewards:Lr.nullish()}).passthrough(),qd=zod.z.object({RankRewards:zod.z.array(ea).nullish()}).passthrough(),Ed=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Ld=zod.z.object({Milestones:ne.nullish(),RankRewards:ne.nullish()}).passthrough(),Gd=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:Bd.nullish(),Schedule:pe.nullish(),ChainEvents:zod.z.array(Ed).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(ea).nullish(),Milestones:zod.z.record(zod.z.string(),ye).nullish(),Presets:Ld.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneClaimGraceHours:zod.z.number().nullish(),ScoreSources:zod.z.array(_e).nullish()}).passthrough(),Nd=zod.z.object({Milestones:zod.z.record(zod.z.string(),Xe).nullish(),RankRewards:zod.z.record(zod.z.string(),qd).nullish()}).passthrough(),er=zod.z.object({Definitions:zod.z.record(zod.z.string(),Gd).nullish(),Presets:Nd.nullish()}).passthrough(),fe={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 tr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Leaderboard",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(fe.GetDefinitions,e,er)}getLeaderboard(e){return this.send(fe.GetLeaderboard,e,Pt)}getMyProgress(e){return this.send(fe.GetMyProgress,e,Zs)}submitScore(e){return this.send(fe.SubmitScore,e,Js)}submitScoreFromSource(e){return this.send(fe.SubmitScoreFromSource,e,Js)}claimCycleReward(e){return this.send(fe.ClaimCycleReward,e,Ys)}claimMilestone(e){return this.send(fe.ClaimMilestone,e,Xs)}getFriendsLeaderboard(e){return this.send(fe.GetFriendsLeaderboard,e,Pt)}getLeaderboardsBatch(e){return this.send(fe.GetLeaderboardsBatch,e,Ho)}getProgressBatch(e){return this.send(fe.GetProgressBatch,e,Ko)}claimCycleRewardsBatch(e){return this.send(fe.ClaimCycleRewardsBatch,e,$o)}claimMilestonesBatch(e){return this.send(fe.ClaimMilestonesBatch,e,Zo)}submitScoresBatch(e){return this.send(fe.SubmitScoresBatch,e,Jo)}claimAllRewardsBatch(e){return this.send(fe.ClaimAllRewardsBatch,e,Yo)}getOverviewBatch(e){return this.send(fe.GetOverviewBatch,e,Xo)}};var Pi=zod.z.object({}).passthrough().transform(a=>a),ta=zod.z.object({SeasonChainID:zod.z.string(),CycleIndex:zod.z.number().nullish(),Season:zod.z.lazy(()=>na).nullish(),ComputedStartUtc:l.nullish(),ComputedEndUtc:l.nullish(),SecondsRemaining:M.nullish(),UserState:Pi.nullish(),NextTier:zod.z.lazy(()=>ia).nullish()}).passthrough(),sa=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),AmountGranted:M.nullish(),NewStatusTokens:M.nullish(),OldTier:zod.z.number().nullish(),NewTier:zod.z.number(),TierUp:zod.z.boolean().nullish()}),ra=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),TierNumber:zod.z.number(),Resources:x.nullish()});var ia=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:M.nullish(),TierReachedReward:G.nullish()}).passthrough(),na=zod.z.object({SeasonID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:M.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(ia).nullish(),LinkedCollectionID:zod.z.string().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough();var jd=zod.z.object({SeasonChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:pe.nullish(),Seasons:zod.z.array(na).nullish(),GrantTokensAccessMode:zod.z.string().nullish(),Gate:Q.nullish()}).passthrough(),sr=zod.z.object({Chains:zod.z.record(zod.z.string(),jd).nullish()}).passthrough(),nt={GetDefinitions:"GetDefinitions",GetActiveSeason:"GetActiveSeason",GetUserState:"GetUserState",GrantStatusTokens:"GrantStatusTokens",ClaimTierReward:"ClaimTierReward"};var rr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Season",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(nt.GetDefinitions,e,sr)}getActiveSeason(e){return this.send(nt.GetActiveSeason,e,ta)}getUserState(e){return this.send(nt.GetUserState,e,Pi)}grantStatusTokens(e){return this.send(nt.GrantStatusTokens,e,sa)}claimTierReward(e){return this.send(nt.ClaimTierReward,e,ra)}};var Fd={Apple:"Apple",Google:"Google"},oa=zod.z.object({}).passthrough().transform(a=>a),Vd=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(),_d=zod.z.object({OptionID:zod.z.string().nullish(),Name:zod.z.string().nullish(),RequiredResources:K.nullish()}).passthrough(),Wd=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(),_d).nullish(),AppleProductID:zod.z.string().nullish(),GoogleProductID:zod.z.string().nullish(),Benefits:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Ii=zod.z.object({Definitions:zod.z.record(zod.z.string(),Wd).nullish()}).passthrough(),aa=zod.z.object({Premium:Ii.nullish()}),la=zod.z.object({ServerTimeUtc:l.nullish(),Premium:oa.nullish()}),ir=zod.z.object({ServerTimeUtc:l.nullish(),Premium:oa.nullish(),Subscription:Vd.nullish(),Resources:x.nullish()}),ot={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateTrial:"ActivateTrial",PurchaseWithResources:"PurchaseWithResources",PurchaseRealMoney:"PurchaseRealMoney"};var nr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Premium",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(ot.GetDefinitions,e,aa)}getUserState(e){return this.send(ot.GetUserState,e,la)}activateTrial(e){return this.send(ot.ActivateTrial,e,ir)}purchaseItemOrCurrency(e){return this.send(ot.PurchaseWithResources,e,ir)}purchaseRealMoney(e){return this.send(ot.PurchaseRealMoney,e,ir)}};var or=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Character",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getCharacterDefinitions(e){return this.send(Te.GetCharacterDefinitions,e,Ts)}getUserCharacters(e){return this.send(Te.GetUserCharacters,e,kn)}unlockCharacter(e){return this.send(Te.UnlockCharacter,e,ri)}upgradeStatLevel(e){return this.send(Te.UpgradeStatLevel,e,ti)}upgradeCharacterLevel(e){return this.send(Te.UpgradeCharacterLevel,e,si)}equipItems(e){return this.send(Te.EquipItems,e,Mn)}unequipItems(e){return this.send(Te.UnequipItems,e,An)}unequipAllCharacters(e){return this.send(Te.UnequipAllCharacters,e,Un)}unlockCharactersBatch(e){return this.send(Te.UnlockCharactersBatch,e,On)}upgradeCharacterLevelsBatch(e){return this.send(Te.UpgradeCharacterLevelsBatch,e,wn)}upgradeStatLevelsBatch(e){return this.send(Te.UpgradeStatLevelsBatch,e,Bn)}};var ar=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Match",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}createMatch(e){return this.send(je.CreateMatch,e,no)}updateMatch(e){return this.send(je.UpdateMatch,e,oo)}cancelMatch(e){return this.send(je.CancelMatch,e,ao)}instantBattle(e){return this.send(je.InstantBattle,e,lo)}saveStrategy(e){return this.send(je.SaveStrategy,e,Se)}getMyMatches(e){return this.send(je.GetMyMatches,e,ci)}getAvailableMatches(e){return this.send(je.GetAvailableMatches,e,ci)}getDefinitions(e){return this.send(je.GetDefinitions,e,ho)}};var Qd={TradeUpRarity:"TradeUpRarity",TradeUpCollection:"TradeUpCollection"},ua=zod.z.enum(["TradeUpRarity","TradeUpCollection"]),Hd=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:Er.nullish()}),ca=zod.z.object({ServerTimeUtc:l,Type:ua.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:x.nullish(),Results:zod.z.array(Hd).nullish()}),Kd=zod.z.object({OptionID:zod.z.string().nullish(),RequiredResources:K.nullish()}).passthrough(),$d=zod.z.object({CraftID:zod.z.string().nullish(),Type:ua.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(),Kd).nullish()}).passthrough(),ki=zod.z.object({Definitions:zod.z.record(zod.z.string(),$d).nullish()}).passthrough(),pa=zod.z.object({ServerTimeUtc:l.nullish(),CraftDefinitions:ki.nullish()}),lr={GetDefinitions:"GetDefinitions",Craft:"Craft"};var ur=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Craft",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(lr.GetDefinitions,e,pa)}craft(e){return this.send(lr.Craft,e,ca)}};var Zd={Pending:"Pending",Accepted:"Accepted",Declined:"Declined",Cancelled:"Cancelled",Expired:"Expired"},Jd=zod.z.enum(["Pending","Accepted","Declined","Cancelled","Expired"]),da=zod.z.object({}).passthrough().transform(a=>a),cr=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()}),ha=zod.z.object({GrantedCollectibles:zod.z.array(cr).nullish(),DuplicateCollectibles:zod.z.array(cr).nullish(),CollectionCurrencyEarned:M.nullish(),NewCollectionCurrencyBalance:M.nullish(),NewlyCompletedSetIDs:zod.z.array(zod.z.string()).nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:x.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),ma=zod.z.object({GrantedCollectibles:zod.z.array(cr).nullish(),DuplicateCollectibles:zod.z.array(cr).nullish(),CollectionCurrencyEarned:M.nullish(),NewCollectionCurrencyBalance:M.nullish(),Resources:x.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),fa=zod.z.object({GrantedCollectibleID:zod.z.string().nullish(),NewlyCompletedSetID:zod.z.string().nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:x.nullish()}),Mi=zod.z.object({SetID:zod.z.string(),Resources:x.nullish()}),ga=zod.z.array(re(Mi)),Ra=zod.z.object({Resources:x.nullish()}),Yd=zod.z.object({OfferID:zod.z.string(),TitleID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderPublicData:Ce.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:Jd.nullish(),CreatedAtUtc:l.nullish(),ExpiresAtUtc:l.nullish(),RespondedAtUtc:l.nullish(),DeclineReason:zod.z.string().nullish(),IsSpecialTradeEvent:zod.z.boolean().nullish(),SpecialTradeEventID:zod.z.string().nullish()}).passthrough(),ya=zod.z.object({OfferID:zod.z.string(),ExpiresAtUtc:l.nullish(),Resources:x.nullish()}),Ca=zod.z.object({OfferID:zod.z.string(),Resources:x.nullish()}),Sa=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:x.nullish()}),Ai=zod.z.object({Offers:zod.z.array(Yd).nullish()}),Xd=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(),eh=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(Xd).nullish(),SetCompletionReward:G.nullish()}).passthrough(),th=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(eh).nullish(),GrandPrize:G.nullish()}).passthrough(),Da=zod.z.object({BonusRewardSlots:ne.nullish(),PityRules:ne.nullish()}).passthrough(),sh=zod.z.object({PackTypeID:zod.z.string().nullish(),Cost:K.nullish(),BonusRewardSlots:zod.z.array(yt).nullish(),PityRules:zod.z.array(Ct).nullish(),Presets:Da.nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CollectibleCount: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(),rh=zod.z.object({Rarity:zod.z.number().nullish(),CollectionCurrencyGranted:zod.z.number().nullish()}).passthrough(),ih=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(),MinCollectibleCount:zod.z.number().nullish(),MaxCollectibleCount:zod.z.number().nullish(),GuaranteedMinRarity:zod.z.number().nullish(),BonusRewardSlots:zod.z.array(yt).nullish(),PityRules:zod.z.array(Ct).nullish(),Presets:Da.nullish(),Tier:zod.z.number().nullish()}).passthrough(),nh=zod.z.object({SpecialTradeEventID:zod.z.string().nullish(),StartUtc:l.nullish(),EndUtc:l.nullish(),AllowedSpecialCollectibleIDs:zod.z.array(zod.z.string()).nullish(),SpecialTradeEventDailyTradeLimit:zod.z.number().nullish()}).passthrough(),pr=zod.z.object({Collections:zod.z.record(zod.z.string(),th).nullish(),PackTypes:zod.z.record(zod.z.string(),sh).nullish(),CollectionChests:zod.z.array(ih).nullish(),DuplicateConversions:zod.z.array(rh).nullish(),DailyTradeLimit:zod.z.number().nullish(),CollectibleJokerCatalogID:zod.z.string().nullish(),CollectibleJokerItemID:zod.z.string().nullish(),SpecialTradeEvents:zod.z.array(nh).nullish(),RewardPools:Vs.nullish()}).passthrough(),xe={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 dr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Collection",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(xe.GetDefinitions,e,pr)}getUserState(e){return this.send(xe.GetUserState,e,da)}openPack(e){return this.send(xe.OpenPack,e,ha)}openCollectionChest(e){return this.send(xe.OpenCollectionChest,e,ma)}useCollectibleJoker(e){return this.send(xe.UseCollectibleJoker,e,fa)}claimSetReward(e){return this.send(xe.ClaimSetReward,e,Mi)}claimSetRewardsBatch(e){return this.send(xe.ClaimSetRewardsBatch,e,ga)}claimGrandPrize(e){return this.send(xe.ClaimGrandPrize,e,Ra)}sendTradeOffer(e){return this.send(xe.SendTradeOffer,e,ya)}cancelTradeOffer(e){return this.send(xe.CancelTradeOffer,e,Ca)}acceptTradeOffer(e){return this.send(xe.AcceptTradeOffer,e,Sa)}declineTradeOffer(e){return this.send(xe.DeclineTradeOffer,e,xa)}getMyTradeOffers(e){return this.send(xe.GetMyTradeOffers,e,Ai)}getIncomingTradeOffers(e){return this.send(xe.GetIncomingTradeOffers,e,Ai)}};var oh=zod.z.object({}).passthrough().transform(a=>a),ah={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},lh={Active:"Active",Left:"Left",Replaced:"Replaced"},uh=zod.z.object({ObjectIndex:zod.z.number().nullish(),ObjectCompletionRewardClaimed:zod.z.boolean().nullish()}).passthrough(),ch=zod.z.object({UserID:zod.z.string().nullish(),PublicData:Ce.nullish(),BuildObjectsProgress:uh.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:l.nullish(),LeftAtUtc:l.nullish()}).passthrough(),ph=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(),dh=zod.z.object({Objects:zod.z.array(ph).nullish()}).passthrough(),ba=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(ch).nullish(),BuildObjectsState:dh.nullish(),Status:zod.z.string().nullish(),CreatedAtUtc:l.nullish(),ExpiresAtUtc:l.nullish(),Version:zod.z.number().nullish()}).passthrough(),va=zod.z.object({CoopChainID:zod.z.string()}).passthrough(),hh=zod.z.string(),za=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(),mh=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:G.nullish()}).passthrough(),fh=zod.z.object({Objects:zod.z.array(mh).nullish(),SpinCost:K.nullish(),SpinnerTable:zod.z.array(za).nullish()}).passthrough(),gh=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:hh.nullish(),PartnerCount:zod.z.number().nullish(),MatchmakingTimeoutMinutes:zod.z.number().nullish(),MemberGracePeriodMinutes:zod.z.number().nullish(),BuildObjects:fh.nullish(),GrandPrize:G.nullish()}).passthrough(),Rh=zod.z.object({CoopChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:pe.nullish(),Events:zod.z.array(gh).nullish(),Gate:Q.nullish()}).passthrough(),Ta=zod.z.object({ServerTimeUtc:l.nullish(),UserState:oh.nullish(),ActiveGroup:ba.nullish()}),Ui=zod.z.object({ServerTimeUtc:l.nullish(),Group:ba.nullish(),SecondsRemaining:M.nullish()}),Pa=zod.z.object({ServerTimeUtc:l.nullish(),GroupID:zod.z.string().nullish(),Resources:x.nullish(),ObjectIndex:zod.z.number().nullish(),Sector:za.nullish(),ProgressDelta:zod.z.number().nullish(),NewProgress:M.nullish(),MaxProgress:M.nullish(),ObjectCompleted:zod.z.boolean().nullish(),AllObjectsCompleted:zod.z.boolean().nullish()}),Oi=zod.z.object({ServerTimeUtc:l.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),Resources:x.nullish()}),Ia=zod.z.object({ServerTimeUtc:l.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),hr=zod.z.object({Chains:zod.z.record(zod.z.string(),Rh).nullish()}).passthrough(),Ne={GetDefinitions:"GetDefinitions",GetActiveEvent:"GetActiveEvent",GetUserState:"GetUserState",GetGroupState:"GetGroupState",JoinOrCreateGroup:"JoinOrCreateGroup",Spin:"Spin",ClaimObjectReward:"ClaimObjectReward",ClaimGrandPrize:"ClaimGrandPrize",LeaveGroup:"LeaveGroup"};var mr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"CoopEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ne.GetDefinitions,e,hr)}getActiveEvent(e){return this.send(Ne.GetActiveEvent,e,va)}getUserState(e){return this.send(Ne.GetUserState,e,Ta)}getGroupState(e){return this.send(Ne.GetGroupState,e,Ui)}joinOrCreateGroup(e){return this.send(Ne.JoinOrCreateGroup,e,Ui)}spin(e){return this.send(Ne.Spin,e,Pa)}claimObjectReward(e){return this.send(Ne.ClaimObjectReward,e,Oi)}claimGrandPrize(e){return this.send(Ne.ClaimGrandPrize,e,Oi)}leaveGroup(e){return this.send(Ne.LeaveGroup,e,Ia)}};var yh={Active:"Active",Exhausted:"Exhausted",Expired:"Expired",Dismissed:"Dismissed"},Ch={Locked:"Locked",Available:"Available",InProgress:"InProgress",Completed:"Completed",Hidden:"Hidden"},Sh=zod.z.object({NodeID:zod.z.string().nullish(),Status:zod.z.string().nullish(),ExecutionCount:zod.z.number().nullish(),UnlockedAtUtc:l.nullish(),CompletedAtUtc:l.nullish(),LastExecutedAtUtc:l.nullish(),NextAvailableAtUtc:l.nullish(),LastExecutionRefID:zod.z.string().nullish()}).passthrough(),xh=zod.z.object({TrackID:zod.z.string().nullish(),CurrentValue:zod.z.number().nullish(),LastUpdatedUtc:l.nullish()}).passthrough(),ka=zod.z.object({OfferID:zod.z.string().nullish(),InstanceKey:zod.z.string().nullish(),SourceOfferVersion:zod.z.number().nullish(),Status:zod.z.string().nullish(),ActivatedAtUtc:l.nullish(),ExhaustedAtUtc:l.nullish(),ExpiredAtUtc:l.nullish(),DismissedAtUtc:l.nullish(),ShowCount:zod.z.number().nullish(),LastShownAtUtc:l.nullish(),Nodes:zod.z.record(zod.z.string(),Sh).nullish(),Tracks:zod.z.record(zod.z.string(),xh).nullish(),SelectedChoiceNodeID:zod.z.string().nullish()}).passthrough(),Dh=zod.z.object({SlotID:zod.z.string().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),ActiveOfferID:zod.z.string().nullish(),ActiveOfferStartedAtUtc:l.nullish(),ActiveOfferExpiresAtUtc:l.nullish(),ActiveOffer:ka.nullish(),NextCycleStartsAtUtc:l.nullish(),LastUpdatedUtc:l.nullish(),DismissSkipAvailableAtUtc:l.nullish(),LastDismissedAtUtc:l.nullish()}).passthrough(),bh=zod.z.object({TotalExecutions:zod.z.number().nullish(),DailyExecutions:zod.z.number().nullish(),DailyResetUtc:l.nullish()}).passthrough(),vh=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:l.nullish(),LastActivatedAtUtc:l.nullish(),LastExhaustedAtUtc:l.nullish(),NodeCounts:zod.z.record(zod.z.string(),bh).nullish()}).passthrough(),zh=zod.z.object({Slots:zod.z.record(zod.z.string(),Dh).nullish(),OfferHistory:zod.z.record(zod.z.string(),vh).nullish(),LastUpdatedUtc:l.nullish()}).passthrough();var Th=zod.z.object({Order:zod.z.number().nullish(),OfferID:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),DelayBeforeActivationSec:zod.z.number().nullish()}).passthrough(),Ph=zod.z.object({SlotID:zod.z.string().nullish(),Enabled:zod.z.boolean().nullish(),SortOrder:zod.z.number().nullish(),Queue:zod.z.array(Th).nullish(),Schedule:pe.nullish(),Gate:Q.nullish(),AllowDismissSkip:zod.z.boolean().nullish(),DismissSkipDelaySec:zod.z.number().nullish()}).passthrough(),Ih=zod.z.object({StoreOfferID:zod.z.string().nullish(),BillingProductID:zod.z.string().nullish(),DirectCost:K.nullish(),UseExternalRewards:zod.z.boolean().nullish()}).passthrough(),kh=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(),Mh=zod.z.object({Purchase:Ih.nullish(),RewardedVideo:kh.nullish()}).passthrough(),Ah=zod.z.object({TrackID:zod.z.string().nullish(),Operator:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),Uh=zod.z.object({Milestones:ne.nullish()}).passthrough(),Oh=zod.z.object({TrackID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),RespectBounds:zod.z.boolean().nullish()}).passthrough(),wh=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(),Bh=zod.z.object({RequiredCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredAnyCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredTracks:zod.z.array(Ah).nullish(),VisibleWhileLocked:zod.z.boolean().nullish()}).passthrough(),qh=zod.z.object({NodeID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),Type:zod.z.string().nullish(),Action:Mh.nullish(),Grants:G.nullish(),TrackChanges:zod.z.array(Oh).nullish(),MilestonePoints:zod.z.number().nullish(),UnlockRules:Bh.nullish(),NextNodeIDs:zod.z.array(zod.z.string()).nullish(),ChoiceGroupID:zod.z.string().nullish(),Limits:de.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(),Ma=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(qh).nullish(),Tracks:zod.z.array(wh).nullish(),Milestones:zod.z.record(zod.z.string(),ye).nullish(),Presets:Uh.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneToken:rt.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(),Eh=zod.z.object({Milestones:zod.z.record(zod.z.string(),Xe).nullish()}).passthrough(),wi=zod.z.object({Slots:zod.z.record(zod.z.string(),Ph).nullish(),Offers:zod.z.record(zod.z.string(),Ma).nullish(),Presets:Eh.nullish()}).passthrough(),Aa=zod.z.object({DealOfferDefinitions:wi.nullish()}),Ua=zod.z.object({DealOffers:zh.nullish()}),Lh=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(),Gh=zod.z.object({SlotID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),OfferDef:Ma.nullish(),ActivationState:ka.nullish(),IsNewActivation:zod.z.boolean().nullish(),ComputedExpiresAtUtc:l.nullish(),Cost:K.nullish(),Milestone:Lh.nullish()}).passthrough(),Oa=zod.z.object({Slots:zod.z.array(Gh).nullish()}),wa=zod.z.object({ServerTimeUtc:l.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:x.nullish()}),Ba=zod.z.object({ServerTimeUtc:l.nullish(),SlotID:zod.z.string().nullish(),Resources:x.nullish()}),qa=zod.z.object({ServerTimeUtc:l.nullish(),SlotID:zod.z.string().nullish(),Resources:x.nullish()}),Ea=zod.z.object({ServerTimeUtc:l.nullish(),SlotID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:x.nullish()}),La=zod.z.object({ServerTimeUtc:l.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:x.nullish()}),Fe={GetDefinition:"GetDefinition",GetUserState:"GetUserState",GetActiveDeals:"GetActiveDeals",DismissDeal:"DismissDeal",ExecuteNode:"ExecuteNode",RecordShow:"RecordShow",ClaimMilestone:"ClaimMilestone",ClaimMilestonesBatch:"ClaimMilestonesBatch"};var fr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"DealOffer",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinition(e){return this.send(Fe.GetDefinition,e,Aa)}getUserState(e){return this.send(Fe.GetUserState,e,Ua)}getActiveDeals(e){return this.send(Fe.GetActiveDeals,e,Oa)}dismissDeal(e){return this.send(Fe.DismissDeal,e,Ba)}executeNode(e){return this.send(Fe.ExecuteNode,e,wa)}recordShow(e){return this.send(Fe.RecordShow,e,qa)}claimMilestone(e){return this.send(Fe.ClaimMilestone,e,Ea)}claimMilestonesBatch(e){return this.send(Fe.ClaimMilestonesBatch,e,La)}};var Nh=zod.z.object({}).passthrough().transform(a=>a),jh=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(),Bi=zod.z.object({IsEnabled:zod.z.boolean().nullish(),ActivationReward:G.nullish(),InviteRewards:zod.z.record(zod.z.string(),ye).nullish(),SpendRewards:zod.z.array(jh).nullish()}).passthrough(),Ga=zod.z.object({ReferralDefinitions:Bi.nullish()}),Na=zod.z.object({Referral:Nh.nullish()}),ja=zod.z.object({ReferralCode:zod.z.string().nullish(),IsFirstActivation:zod.z.boolean().nullish(),Resources:x.nullish()}),Fa=zod.z.object({RewardID:zod.z.string().nullish(),Resources:x.nullish()}),St={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateReferralCode:"ActivateReferralCode",ClaimInviteReward:"ClaimInviteReward"};var gr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Referral",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(St.GetDefinitions,e,Ga)}getUserState(e){return this.send(St.GetUserState,e,Na)}activateReferralCode(e){return this.send(St.ActivateReferralCode,e,ja)}claimInviteReward(e){return this.send(St.ClaimInviteReward,e,Fa)}};var Fh={RequestSent:"RequestSent",Accepted:"Accepted",Declined:"Declined",Removed:"Removed"},Vh={Attack:"Attack",Raid:"Raid",FriendAdd:"FriendAdd"},_h=zod.z.object({UserID:zod.z.string(),PublicData:Ce.nullish()}),Wh=zod.z.object({OwnerUserID:zod.z.string().nullish(),ActorUserID:zod.z.string().nullish(),ActorProfile:Ce.nullish(),Type:zod.z.string().nullish(),CreatedAt:l.nullish(),OwnerImpact:x.nullish(),IsBlocked:zod.z.boolean().nullish(),TargetObjectName:zod.z.string().nullish()}).passthrough(),Rr=zod.z.object({Friends:zod.z.array(_h).nullish()}),It=zod.z.object({TargetUserID:zod.z.string().nullish(),Status:zod.z.string().nullish()}),Va=zod.z.object({Events:zod.z.array(Wh).nullish()}),Ve={GetFriendsList:"GetFriendsList",GetIncomingRequests:"GetIncomingRequests",GetRecommendedFriends:"GetRecommendedFriends",SendFriendRequest:"SendFriendRequest",AcceptFriendRequest:"AcceptFriendRequest",DeclineFriendRequest:"DeclineFriendRequest",RemoveFriend:"RemoveFriend",GetTimeline:"GetTimeline"};var yr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Social",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getFriendsList(e){return this.send(Ve.GetFriendsList,e,Rr)}getIncomingRequests(e){return this.send(Ve.GetIncomingRequests,e,Rr)}getRecommendedFriends(e){return this.send(Ve.GetRecommendedFriends,e,Rr)}sendFriendRequest(e){return this.send(Ve.SendFriendRequest,e,It)}acceptFriendRequest(e){return this.send(Ve.AcceptFriendRequest,e,It)}declineFriendRequest(e){return this.send(Ve.DeclineFriendRequest,e,It)}removeFriend(e){return this.send(Ve.RemoveFriend,e,It)}getTimeline(e){return this.send(Ve.GetTimeline,e,Va)}};var Qh={Replace:"Replace",Refresh:"Refresh",KeepBest:"KeepBest",Stack:"Stack"};var xt=zod.z.object({Target:zod.z.string().nullish(),Operation:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),Hh=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:K.nullish(),Effect:xt.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(),Kh=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(xt).nullish(),Gate:Q.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),$h=zod.z.object({ChainedBoostID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Effects:zod.z.array(xt).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Zh=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($h).nullish(),Gate:Q.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Jh=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(_e).nullish(),Effects:zod.z.array(xt).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(),Yh=zod.z.object({MaxAddPercent:zod.z.number().nullish(),MaxMultiply:zod.z.number().nullish(),MaxAddFlat:zod.z.number().nullish()}).passthrough(),Xh=zod.z.object({StackingCaps:zod.z.record(zod.z.string(),Yh).nullish()}).passthrough(),Cr=zod.z.object({Definitions:zod.z.record(zod.z.string(),Hh).nullish(),ScheduledBoosts:zod.z.record(zod.z.string(),Kh).nullish(),BoostChains:zod.z.record(zod.z.string(),Zh).nullish(),TriggeredBoosts:zod.z.record(zod.z.string(),Jh).nullish(),Settings:Xh.nullish()}).passthrough(),_a=zod.z.object({InstanceID:zod.z.string(),BoostID:zod.z.string(),ActivatedAtUtc:l.nullish(),ExpiresAtUtc:l.nullish(),RemainingCharges:zod.z.number().nullish(),EffectSnapshot:xt.nullish(),SourceType:zod.z.string().nullish(),SourceRef:zod.z.string().nullish()}).passthrough();zod.z.object({Date:l.nullish(),DailyCount:zod.z.number().nullish(),LastFiredUtc:l.nullish()}).passthrough();var Wa=zod.z.object({ServerTimeUtc:l.nullish(),Active:zod.z.record(zod.z.string(),_a).nullish()}),Qa=zod.z.object({ServerTimeUtc:l.nullish(),BoostID:zod.z.string().nullish(),StackingPolicy:zod.z.string().nullish(),ActivatedBoost:_a.nullish(),Resources:x.nullish()}),em={Scheduled:"Scheduled",Chain:"Chain"},tm=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:l.nullish(),EndUtc:l.nullish(),Effects:zod.z.array(xt).nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Ha=zod.z.object({ServerTimeUtc:l.nullish(),Windows:zod.z.array(tm).nullish()}),at={GetDefinitions:"GetDefinitions",GetActive:"GetActive",GetActiveWindows:"GetActiveWindows",Activate:"Activate",CleanupExpired:"CleanupExpired"};var Sr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"TimedBoost",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(at.GetDefinitions,e,Cr)}getActive(e){return this.send(at.GetActive,e,Wa)}getActiveWindows(e){return this.send(at.GetActiveWindows,e,Ha)}activate(e){return this.send(at.Activate,e,Qa)}cleanupExpired(e){return this.send(at.CleanupExpired,e,Se)}};var xr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"UserCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getUserCustomDataDefinitions(e){return this.send(Ge.GetUserCustomDataDefinitions,e,ys)}getMyUserCustomData(e){return this.send(Ge.GetMyUserCustomData,e,Rn)}getPublicUserCustomDataOf(e){return this.send(Ge.GetPublicUserCustomDataOf,e,Zr)}setPrivateData(e){return this.send(Ge.SetPrivateData,e,Jr)}setPublicData(e){return this.send(Ge.SetPublicData,e,Jr)}deleteKey(e){return this.send(Ge.DeleteKey,e,Se)}batchSet(e){return this.send(Ge.BatchSet,e,yn)}batchDelete(e){return this.send(Ge.BatchDelete,e,Cn)}batchGetPublicUserCustomDataOf(e){return this.send(Ge.BatchGetPublicUserCustomDataOf,e,Sn)}};var sm={Static:"Static",Runtime:"Runtime"},rm={Public:"Public",Private:"Private"},im=zod.z.enum(["Client","Server","System"]),nm=zod.z.enum(["String","Int","Bool","Json"]),om=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:l.nullish(),Version:zod.z.number().nullish(),LastWriter:im.nullish(),ExpiresAt:l.nullish()}).passthrough(),Ka=zod.z.record(zod.z.string(),om),qi=zod.z.object({StaticVersion:zod.z.number().nullish(),RuntimeVersion:zod.z.number().nullish(),Static:Ka.nullish(),Runtime:Ka.nullish(),NotModified:zod.z.boolean().nullish()}),am=zod.z.object({KeyID:zod.z.string(),Scope:zod.z.enum(["Static","Runtime"]).nullish(),Bucket:zod.z.enum(["Public","Private"]).nullish(),ValueType:nm.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),Dr=zod.z.object({Keys:zod.z.record(zod.z.string(),am).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(),kt={GetTitleCustomDataDefinitions:"GetTitleCustomDataDefinitions",GetPublicTitleData:"GetPublicTitleData",GetPublicTitleDataKeys:"GetPublicTitleDataKeys"};var br=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"TitleCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getTitleCustomDataDefinitions(e){return this.send(kt.GetTitleCustomDataDefinitions,e,Dr)}getPublicTitleData(e){return this.send(kt.GetPublicTitleData,e,qi)}getPublicTitleDataKeys(e){return this.send(kt.GetPublicTitleDataKeys,e,qi)}};var lm={Fast:"Fast",Sequential:"Sequential"},um={Instant:"Instant",Timed:"Timed"},cm={Hit:"Hit",Blocked:"Blocked"},pm=zod.z.object({SlotIndex:zod.z.number(),Level:zod.z.number().nullish(),IsDamaged:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish()}).passthrough(),dm=zod.z.object({Symbol:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),OnOpenBonus:G.nullish(),BonusTag:zod.z.string().nullish()}).passthrough();zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:G.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 $a=zod.z.object({}).passthrough().transform(a=>a),Za=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),ve=zod.z.object({Operation:x.nullish(),ScaleWithRollMultiplier:zod.z.boolean().nullish()}).passthrough(),hm=zod.z.object({Count:zod.z.number().nullish(),Sides:zod.z.number().nullish()}).passthrough(),mm=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(),fm=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:ce.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(),gm=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:ce.nullish()}).passthrough(),Ja=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:G.nullish()}).passthrough(),Rm=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(),ym=zod.z.object({Tiles:zod.z.record(zod.z.string(),Rm).nullish()}).passthrough(),Cm=zod.z.object({Weight:zod.z.number().nullish(),Bonus:ve.nullish(),Tag:zod.z.string().nullish()}).passthrough(),Sm=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(Cm).nullish(),GuaranteedBonus:ve.nullish(),IsJackpot:zod.z.boolean().nullish(),JackpotFinalMultiplier:zod.z.number().nullish(),JackpotSymbolDistribution:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough(),xm=zod.z.object({Variants:zod.z.array(Sm).nullish()}).passthrough(),Dm=zod.z.object({Weight:zod.z.number().nullish(),OutcomeID:zod.z.string().nullish(),Reward:ve.nullish(),ForceAction:zod.z.string().nullish(),SpecialModeID:zod.z.string().nullish()}).passthrough(),bm=zod.z.object({Outcomes:zod.z.array(Dm).nullish()}).passthrough(),Ya=zod.z.object({PerAdMultiplierRange:Za.nullish(),MaxAdViews:zod.z.number().nullish(),AdCreditCost:zod.z.number().nullish(),FormulaKind:zod.z.string().nullish(),ApplyMultiplierOnEarlyClaim:zod.z.boolean().nullish()}).passthrough(),vm=zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:ve.nullish()}).passthrough(),zm=zod.z.object({Tiers:zod.z.array(vm).nullish(),BelowFirstTierReward:ve.nullish()}).passthrough(),Tm=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:ve.nullish(),DurationSeconds:zod.z.number().nullish(),EntryCost:K.nullish(),Multipliers:Ya.nullish(),Gradation:zm.nullish()}).passthrough(),Pm=zod.z.object({Choices:zod.z.array(Tm).nullish(),OfferExpireSeconds:zod.z.number().nullish(),ClaimExpireSeconds:zod.z.number().nullish()}).passthrough(),Im=zod.z.object({Chance:zod.z.number().nullish(),RequiredOutcome:zod.z.string().nullish(),Reward:ve.nullish(),Tag:zod.z.string().nullish()}).passthrough(),km=zod.z.object({OnPassStart:ve.nullish(),OnTileLanding:zod.z.record(zod.z.string(),ve).nullish(),OnAttack:zod.z.record(zod.z.string(),ve).nullish(),OnRaid:zod.z.record(zod.z.string(),ve).nullish(),OnBuild:ve.nullish(),OnStageComplete:ve.nullish(),OnAttackBonusDrops:zod.z.array(Im).nullish(),ChanceTablesByID:zod.z.record(zod.z.string(),bm).nullish(),SpecialModesByID:zod.z.record(zod.z.string(),Pm).nullish()}).passthrough(),Xa=zod.z.object({BaseAttackReward:G.nullish(),BaseRaidReward:G.nullish(),MaxRollMultiplier:zod.z.number().nullish(),MaxShields:zod.z.number().nullish(),Buildings:zod.z.array(Ja).nullish(),HeistGridBonusConfig:xm.nullish(),StageOperations:km.nullish(),TileLandingMultiplier:Za.nullish(),EconomyOverride:gm.nullish()}).passthrough(),Mm=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(Ja).nullish(),StageTemplateID:zod.z.string().nullish(),CostMatrixTemplateID:zod.z.string().nullish(),UnitValue:zod.z.number().nullish(),Override:Xa.nullish()}).passthrough(),vr=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(),ym).nullish(),StageTemplatesByID:zod.z.record(zod.z.string(),Xa).nullish(),StagesByLevel:zod.z.record(zod.z.string(),Mm).nullish(),SoftCurrencyID:zod.z.string().nullish(),ProceduralEconomy:fm.nullish(),Dice:hm.nullish(),Bots:mm.nullish()}).passthrough(),Am=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:l.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(),ye).nullish(),GrandPrize:G.nullish()}).passthrough(),zr=zod.z.object({Board:vr.nullish(),CommunityChest:Am.nullish()}).passthrough(),Um=zod.z.object({TargetUserID:zod.z.string().nullish(),IsBot:zod.z.boolean().nullish(),PublicData:Ce.nullish(),TargetBuildingStates:zod.z.array(pm).nullish(),TargetHasShield:zod.z.boolean().nullish()}).passthrough(),Om=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:ve.nullish(),DurationSeconds:zod.z.number().nullish(),EntryCost:K.nullish(),Multipliers:Ya.nullish()}).passthrough(),wm=zod.z.object({ModeID:zod.z.string().nullish(),Choices:zod.z.array(Om).nullish()}).passthrough(),Bm=zod.z.object({GroupID:zod.z.string().nullish(),Delta:M.nullish(),NewProgress:M.nullish(),MaxProgress:M.nullish(),UnlockedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),Completed:zod.z.boolean().nullish()}).passthrough(),el=zod.z.object({UsedMultiplier:zod.z.number().nullish(),Steps:zod.z.number().nullish(),OldPosition:zod.z.number().nullish(),NewPosition:zod.z.number(),CyclesCompletedDelta:M.nullish(),LandedTileType:zod.z.string().nullish(),Operation:x.nullish(),ActionRequired:zod.z.string().nullish(),ActionData:Um.nullish(),SpecialModeOffer:wm.nullish(),CommunityChestContribution:Bm.nullish()}).passthrough(),tl=zod.z.object({Outcome:zod.z.string().nullish(),IsBotTarget:zod.z.boolean().nullish(),BuildingIndexHit:zod.z.number().nullish(),Operation:x.nullish(),DualResult:st.nullish()}).passthrough(),Ei=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:G.nullish(),OpenedIndex:zod.z.number().nullish(),AttemptsLeft:zod.z.number().nullish(),RaidLayout:zod.z.array(dm).nullish(),HeistVariantTag:zod.z.string().nullish(),IsJackpot:zod.z.boolean().nullish(),Operation:x.nullish(),DualResult:st.nullish()}).passthrough(),sl=zod.z.object({BuiltIndex:zod.z.number(),NewLevel:zod.z.number().nullish(),StageComplete:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish(),Operation:x.nullish()}).passthrough(),rl=zod.z.object({Mode:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),Operation:x.nullish(),DurationSeconds:zod.z.number().nullish(),StartedAtUtc:l.nullish(),ExpiresAtUtc:l.nullish()}).passthrough(),il=zod.z.object({AdViewsUsed:zod.z.number().nullish(),RolledMultiplier:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),RemainingAdViews:zod.z.number().nullish()}).passthrough(),nl=zod.z.object({FinalMultiplier:zod.z.number().nullish(),AdViewsUsed:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),IsEarlyClaim:zod.z.boolean().nullish(),Operation:x.nullish()}).passthrough(),qm={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},ol=zod.z.enum(["Forming","Active","Completed","Failed","Expired"]),Em={Active:"Active",Left:"Left",Replaced:"Replaced"},Lm=zod.z.enum(["Active","Left","Replaced"]),Gm=zod.z.object({CurrentProgress:M.nullish(),MaxProgress:M.nullish()}).passthrough(),Nm=zod.z.object({UserID:zod.z.string().nullish(),PublicData:Ce.nullish(),IsBot:zod.z.boolean().nullish(),ContributionPoints:M.nullish(),ClaimedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),GrandPrizeClaimed:zod.z.boolean().nullish(),MemberStatus:Lm.nullish(),JoinedAtUtc:l.nullish(),LeftAtUtc:l.nullish()}).passthrough(),al=zod.z.object({GroupID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),Members:zod.z.array(Nm).nullish(),SharedProgress:Gm.nullish(),Status:ol.nullish(),CreatedAtUtc:l.nullish(),ExpiresAtUtc:l.nullish(),Version:zod.z.number().nullish()}).passthrough(),jm=zod.z.object({GroupID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),FinalStatus:ol.nullish(),GrandPrizeReceived:zod.z.boolean().nullish(),FinishedAtUtc:l.nullish()}).passthrough(),Fm=zod.z.object({ActiveGroupID:zod.z.string().nullish(),ActiveRoundIndex:zod.z.number().nullish(),History:zod.z.array(jm).nullish()}).passthrough(),ll=zod.z.object({ServerTimeUtc:l.nullish(),UserState:Fm.nullish(),ActiveGroup:al.nullish(),SecondsRemaining:M.nullish()}),ul=zod.z.object({ServerTimeUtc:l.nullish(),Group:al.nullish(),SecondsRemaining:M.nullish()}),Li=zod.z.object({ServerTimeUtc:l.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:x.nullish()}),cl=zod.z.object({ServerTimeUtc:l.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),me={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 Vm=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(),_m=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:Q.nullish(),Variants:zod.z.array(Vm).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(),pl=zod.z.object({Experiments:zod.z.record(zod.z.string(),_m).nullish()}).passthrough();var Wm={Mesh:"Mesh",Host:"Host"},Gi=zod.z.enum(["Mesh","Host"]),Qm={ServerRelay:"ServerRelay",P2P:"P2P"},Ni=zod.z.enum(["ServerRelay","P2P"]),Hm={Public:"Public",Private:"Private"},Km=zod.z.enum(["Public","Private"]),$m={Signal:"Signal",Chat:"Chat",PlayerJoined:"PlayerJoined",PlayerLeft:"PlayerLeft",HostChanged:"HostChanged",RoomClosed:"RoomClosed",MemberState:"MemberState"},Zm=zod.z.enum(["Signal","Chat","PlayerJoined","PlayerLeft","HostChanged","RoomClosed","MemberState"]),dl=zod.z.object({Urls:zod.z.string().nullish(),Username:zod.z.string().nullish(),Credential:zod.z.string().nullish()}).passthrough(),Jm=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),hl=zod.z.object({SystemState:Jm.nullish(),DefaultTopology:Gi.nullish(),AllowCreatorTopologyOverride:zod.z.boolean().nullish(),DefaultChatMode:Ni.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(dl).nullish()}).passthrough(),Ym=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(),Xm=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),Topology:Gi.nullish(),ChatMode:Ni.nullish(),MaxPlayers:zod.z.number().nullish(),MemberCount:zod.z.number().nullish(),CreatedAt:zod.z.number().nullish()}).passthrough(),ef=zod.z.object({Seq:zod.z.number().nullish(),Type:Zm.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(),Tr=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),OwnerUserID:zod.z.string().nullish(),Topology:Gi.nullish(),ChatMode:Ni.nullish(),Visibility:Km.nullish(),Status:zod.z.string().nullish(),MaxPlayers:zod.z.number().nullish(),Members:zod.z.array(Ym).nullish(),IceServers:zod.z.array(dl).nullish(),Seq:zod.z.number().nullish()}).passthrough(),ji=zod.z.object({Closed:zod.z.boolean().nullish(),NewHostUserID:zod.z.string().nullish()}).passthrough(),ml=zod.z.object({Rooms:zod.z.array(Xm).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}).passthrough(),fl=zod.z.object({Envelopes:zod.z.array(ef).nullish(),MaxSeq:zod.z.number().nullish()}).passthrough(),Pr=zod.z.object({Seq:zod.z.number().nullish()}).passthrough(),Be={CreateRoom:"CreateRoom",JoinRoom:"JoinRoom",LeaveRoom:"LeaveRoom",ListRooms:"ListRooms",GetRoom:"GetRoom",CloseRoom:"CloseRoom",Poll:"Poll",SendSignal:"SendSignal",SendChat:"SendChat",SetMemberState:"SetMemberState"};var Fi=zod.z.object({TitleCustomData:Dr.nullish(),Character:Ts.nullish(),Item:Gs.nullish(),Currency:zs.nullish(),Store:js.nullish(),Lootbox:xi.nullish(),Quest:Lt.nullish(),TimedEvent:Ks.nullish(),Leaderboard:er.nullish(),Season:sr.nullish(),Reward:Di.nullish(),Collection:pr.nullish(),Craft:ki.nullish(),DealOffer:wi.nullish(),Premium:Ii.nullish(),TimedBoost:Cr.nullish(),CoopEvent:hr.nullish(),GameLoop:zr.nullish(),Match:di.nullish(),Experiment:pl.nullish(),Blockchain:ni.nullish(),Marketplace:gi.nullish(),Multiplayer:hl.nullish(),UserCustomData:ys.nullish(),Referral:Bi.nullish()}).passthrough();var lt={GetTitlePublicConfiguration:"GetTitlePublicConfiguration",GetTitlePublicConfigurationExcept:"GetTitlePublicConfigurationExcept",GetCurrencyDefinitions:"GetCurrencyDefinitions",GetItemDefinitions:"GetItemDefinitions",GetServerTime:"GetServerTime"};var Ir=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Title",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getTitlePublicConfiguration(e){return this.send(lt.GetTitlePublicConfiguration,e,Fi)}getTitlePublicConfigurationExcept(e){return this.send(lt.GetTitlePublicConfigurationExcept,e,Fi)}getCurrencyDefinitions(e){return this.send(lt.GetCurrencyDefinitions,e,zs)}getItemDefinitions(e){return this.send(lt.GetItemDefinitions,e,Gs)}getServerTime(e){return this.send(lt.GetServerTime,e,Se)}};var kr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s,r=false){let i=U(this.ctx.settings.titleID,"GameLoop",e,t.UserID??"");return this.ctx.transport.post(i,t,s,{ticket:t.ClientSessionTicket,silent:r})}getGameLoops(e){return this.send(me.GetGameLoops,e,zr)}getBoardDefinition(e,t=false){return this.send(me.GetBoardDefinition,e,vr,t)}getBoardDefinitionForLevel(e,t=false){return this.send(me.GetBoardDefinitionForLevel,e,vr,t)}getUserBoardState(e){return this.send(me.GetUserBoardState,e,$a)}boardLoopRoll(e){return this.send(me.BoardLoopRoll,e,el)}boardLoopAttack(e){return this.send(me.BoardLoopAttack,e,tl)}boardLoopRaid(e){return this.send(me.BoardLoopRaid,e,Ei)}boardLoopRaidFast(e){return this.send(me.BoardLoopRaidFast,e,Ei)}boardLoopBuild(e){return this.send(me.BoardLoopBuild,e,sl)}boardSpecialChoose(e){return this.send(me.BoardSpecialChoose,e,rl)}boardSpecialApplyMultiplier(e){return this.send(me.BoardSpecialApplyMultiplier,e,il)}boardSpecialClaim(e){return this.send(me.BoardSpecialClaim,e,nl)}getCommunityChestState(e){return this.send(me.GetCommunityChestState,e,ll)}joinOrCreateCommunityChest(e){return this.send(me.JoinOrCreateCommunityChest,e,ul)}claimCommunityChestMilestone(e){return this.send(me.ClaimCommunityChestMilestone,e,Li)}claimCommunityChestGrandPrize(e){return this.send(me.ClaimCommunityChestGrandPrize,e,Li)}leaveCommunityChest(e){return this.send(me.LeaveCommunityChest,e,cl)}};var Mt=zod.z.lazy(()=>zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null(),zod.z.array(Mt),zod.z.record(zod.z.string(),Mt)]));var sf={Live:"Live",Latest:"Latest",Specific:"Specific"},rf={Debug:"Debug",Info:"Info",Warning:"Warning",Error:"Error"},nf=zod.z.enum(["Debug","Info","Warning","Error"]),of={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"},af=zod.z.enum(["None","Disabled","NoActiveRevision","RevisionNotFound","InvalidFieldName","RateLimited","HandlerNotFound","HandlerDisabled","Timeout","StatementCountExceeded","StackOverflow","ApiCallLimitExceeded","JavaScriptException","ExecutionError"]),lf=zod.z.object({Level:nf,Message:zod.z.string().nullish(),Data:Mt.nullish()}),uf=zod.z.object({Error:af,Message:zod.z.string().nullish(),StackTrace:zod.z.string().nullish()}),gl=zod.z.object({FunctionName:zod.z.string().nullish(),Revision:zod.z.number().nullish(),FunctionResult:Mt.nullish(),FunctionResultTooLarge:zod.z.boolean().nullish(),Logs:zod.z.array(lf).nullish(),LogsTooLarge:zod.z.boolean().nullish(),ExecutionTimeSeconds:zod.z.number().nullish(),APIRequestsIssued:zod.z.number().nullish(),Error:uf.nullish()}),Vi={Execute:"Execute"};var Mr=class{constructor(e){this.ctx=e;}ctx;execute(e){let t=U(this.ctx.settings.titleID,"CloudCode",Vi.Execute,e.UserID??"");return this.ctx.transport.post(t,e,gl,{ticket:e.ClientSessionTicket})}};var Ar=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Blockchain",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Pe.GetDefinitions,e,Qn)}getUserState(e){return this.send(Pe.GetUserState,e,Hn)}depositToken(e){return this.send(Pe.DepositToken,e,Kn)}depositNFT(e){return this.send(Pe.DepositNFT,e,$n)}requestTokenWithdrawal(e){return this.send(Pe.RequestTokenWithdrawal,e,Zn)}requestNFTWithdrawal(e){return this.send(Pe.RequestNFTWithdrawal,e,Jn)}getTransactionHistory(e){return this.send(Pe.GetTransactionHistory,e,Yn)}retryWithdrawal(e){return this.send(Pe.RetryWithdrawal,e,Xn)}confirmWithdrawal(e){return this.send(Pe.ConfirmWithdrawal,e,eo)}donateToDeveloper(e){return this.send(Pe.DonateToDeveloper,e,li)}donateToUsersPool(e){return this.send(Pe.DonateToUsersPool,e,li)}};var Ur=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Marketplace",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(ie.GetDefinitions,e,fo)}getGroupedOffers(e){return this.send(ie.GetGroupedOffers,e,go)}getOffersByItem(e){return this.send(ie.GetOffersByItem,e,Ri)}getOffer(e){return this.send(ie.GetOffer,e,Ro)}getBuyOrders(e){return this.send(ie.GetBuyOrders,e,Ri)}getMyState(e){return this.send(ie.GetMyState,e,Co)}getHistory(e){return this.send(ie.GetHistory,e,So)}createListing(e){return this.send(ie.CreateListing,e,Tt)}cancelListing(e){return this.send(ie.CancelListing,e,Ue)}buy(e){return this.send(ie.Buy,e,Ue)}marketBuy(e){return this.send(ie.MarketBuy,e,Ue)}marketSell(e){return this.send(ie.MarketSell,e,Ue)}createAuction(e){return this.send(ie.CreateAuction,e,Tt)}placeBid(e){return this.send(ie.PlaceBid,e,yo)}claimAuction(e){return this.send(ie.ClaimAuction,e,Ue)}createBuyOrder(e){return this.send(ie.CreateBuyOrder,e,Tt)}cancelBuyOrder(e){return this.send(ie.CancelBuyOrder,e,Ue)}fillBuyOrder(e){return this.send(ie.FillBuyOrder,e,Ue)}createDirectTrade(e){return this.send(ie.CreateDirectTrade,e,Tt)}respondDirectTrade(e){return this.send(ie.RespondDirectTrade,e,Ue)}cancelDirectTrade(e){return this.send(ie.CancelDirectTrade,e,Ue)}claimBack(e){return this.send(ie.ClaimBack,e,Ue)}};var Or=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Multiplayer",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}createRoom(e){return this.send(Be.CreateRoom,e,Tr)}joinRoom(e){return this.send(Be.JoinRoom,e,Tr)}leaveRoom(e){return this.send(Be.LeaveRoom,e,ji)}listRooms(e){return this.send(Be.ListRooms,e,ml)}getRoom(e){return this.send(Be.GetRoom,e,Tr)}closeRoom(e){return this.send(Be.CloseRoom,e,ji)}poll(e){return this.send(Be.Poll,e,fl)}sendSignal(e){return this.send(Be.SendSignal,e,Pr)}sendChat(e){return this.send(Be.SendChat,e,Pr)}setMemberState(e){return this.send(Be.SetMemberState,e,Pr)}};var wr=class{settings;emitter;platform;transport;fetchImpl;data;authStore;api;auth;userService;currency;item;store;lootbox;reward;quest;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=Ki(e),this.emitter=new bt,this.platform=e.platform??new dt,this.fetchImpl=e.fetch??globalThis.fetch.bind(globalThis),this.transport=new jt({baseUrl:this.settings.baseUrl,emitter:this.emitter,fetchImpl:e.fetch,debugLogging:this.settings.debugLogging,throttleMs:e.throttleMs}),this.data=new Wt(this.emitter),this.emitter.on("quest:systemProgress",t=>{this.data.user.patchQuestProgressUpdates(t);}),this.emitter.on("user:stateVersions",({epoch:t,versions:s})=>{this.userService.noteStateVersions(t,s);}),this.authStore=new Qt(this.platform.storage,this.settings.titleID),this.api={authentication:new Bs(this),user:new qs(this),currency:new Es(this),item:new Ns(this),store:new Fs(this),lootbox:new Ws(this),reward:new Qs(this),quest:new Hs(this),timedEvent:new $s(this),leaderboard:new tr(this),season:new rr(this),premium:new nr(this),character:new or(this),match:new ar(this),craft:new ur(this),collection:new dr(this),coopEvent:new mr(this),dealOffer:new fr(this),referral:new gr(this),social:new yr(this),timedBoost:new Sr(this),userCustomData:new xr(this),titleCustomData:new br(this),title:new Ir(this),gameLoop:new kr(this),cloudCode:new Mr(this),blockchain:new Ar(this),marketplace:new Ur(this),multiplayer:new Or(this)},this.userService=new Zt(this),this.auth=new Ht(this),this.currency=new Yt(this),this.item=new Xt(this),this.store=new es(this),this.lootbox=new ts(this),this.reward=new ss(this),this.quest=new rs(this),this.timedEvent=new is(this),this.leaderboard=new ns(this),this.season=new os(this),this.premium=new as(this),this.character=new ls(this),this.match=new us(this),this.craft=new cs(this),this.collection=new ps(this),this.coopEvent=new ds(this),this.dealOffer=new hs(this),this.referral=new ms(this),this.social=new fs(this),this.timedBoost=new gs(this),this.userCustomData=new Cs(this),this.titleCustomData=new Ss(this),this.title=new xs(this),this.gameLoop=new Ds(this),this.cloudCode=new bs(this),this.blockchain=new ks(this),this.marketplace=new Os(this),this.multiplayer=new ws(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:k()}}};var Br=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 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 cf(a){return new Br(a)}var Rl="idos_sso",yl="state",_i="idos:sso:state",pf="https://idosgames.com/sso";function df(){if(typeof window>"u")return null;let a=window.location.hash?.startsWith("#")?window.location.hash.slice(1):window.location.hash;if(!a)return null;let e=new URLSearchParams(a),t=e.get(Rl);if(!t)return null;let s=e.get(yl)??"",r=Rf();return Cf(e),yf(),r&&s!==r?null:{code:t,state:s}}function hf(a){if(typeof window>"u")return;let e=a.returnTo??mf(),t=ff();gf(t);let s=new URL(a.ssoUrl??pf);s.searchParams.set("title",a.titleID),s.searchParams.set("return_to",e),s.searchParams.set("state",t),window.location.assign(s.toString());}function mf(){let{origin:a,pathname:e,search:t}=window.location;return `${a}${e}${t}`}function ff(){let a=new Uint8Array(16);if(typeof crypto<"u"&&crypto.getRandomValues)crypto.getRandomValues(a);else for(let e=0;e<a.length;e++)a[e]=Math.floor(Math.random()*256);return Array.from(a,e=>e.toString(16).padStart(2,"0")).join("")}function gf(a){try{window.sessionStorage.setItem(_i,a);}catch{}}function Rf(){try{return window.sessionStorage.getItem(_i)}catch{return null}}function yf(){try{window.sessionStorage.removeItem(_i);}catch{}}function Cf(a){a.delete(Rl),a.delete(yl);let e=a.toString(),{pathname:t,search:s}=window.location;window.history.replaceState(null,"",`${t}${s}${e?`#${e}`:""}`);}var Sf={Banner:"Banner",Interstitial:"Interstitial",RewardedVideo:"RewardedVideo",RewardedInterstitial:"RewardedInterstitial",AppOpen:"AppOpen",Native:"Native"},Wi=zod.z.enum(["Banner","Interstitial","RewardedVideo","RewardedInterstitial","AppOpen","Native"]),xf={Top:"Top",Bottom:"Bottom",Left:"Left",Right:"Right"},Df=zod.z.enum(["Top","Bottom","Left","Right"]),bf=zod.z.object({PlacementID:zod.z.string().nullish(),Type:Wi.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(),vf=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(),zf=zod.z.object({CooldownSeconds:zod.z.number().nullish(),MinSessionTimeBeforeFirstSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),Tf=zod.z.object({Enabled:zod.z.boolean().nullish(),Position:Df.nullish(),RefreshIntervalSeconds:zod.z.number().nullish()}).passthrough(),Pf=zod.z.object({Enabled:zod.z.boolean().nullish(),CooldownSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish()}).passthrough(),If=zod.z.object({MaxImpressionsPerHour:zod.z.number().nullish(),MaxImpressionsPerDay:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),kf=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(),Mf=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(),Af=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(),Uf=zod.z.object({AndroidUnitID:zod.z.string().nullish(),IosUnitID:zod.z.string().nullish(),WebUnitID:zod.z.string().nullish(),Type:Wi.nullish()}).passthrough(),Of=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(),Uf).nullish()}).passthrough();zod.z.object({Enabled:zod.z.boolean().nullish(),Placements:zod.z.record(zod.z.string(),bf).nullish(),Providers:zod.z.record(zod.z.string(),Of).nullish(),RewardedVideo:vf.nullish(),Interstitial:zf.nullish(),Banner:Tf.nullish(),AppOpen:Pf.nullish(),FrequencyCapping:If.nullish(),PremiumAdReductions:zod.z.array(kf).nullish(),Consent:Mf.nullish(),Verification:Af.nullish()}).passthrough();var wf=zod.z.object({RewardedVideoCredit:zod.z.number().nullish(),TotalEarned:zod.z.number().nullish(),TotalSpent:zod.z.number().nullish()}).passthrough(),Bf=zod.z.object({PlacementID:zod.z.string().nullish(),LastShownAt:l.nullish(),LastCompletedAt:l.nullish(),TotalImpressions:zod.z.number().nullish(),TotalCompletions:zod.z.number().nullish(),ConsecutiveFailures:zod.z.number().nullish()}).passthrough(),qf=zod.z.object({Date:l.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(),Ef=zod.z.object({SessionID:zod.z.string().nullish(),SessionStartAt:l.nullish(),Impressions:zod.z.number().nullish(),InterstitialImpressions:zod.z.number().nullish(),RewardedCompletions:zod.z.number().nullish()}).passthrough(),Lf=zod.z.object({PersonalizedAdsConsent:zod.z.boolean().nullish(),TrackingConsent:zod.z.boolean().nullish(),PolicyVersion:zod.z.string().nullish(),Region:zod.z.string().nullish(),ConsentGivenAt:l.nullish(),ConsentRevokedAt:l.nullish()}).passthrough(),Gf=zod.z.object({RequestID:zod.z.string().nullish(),PlacementID:zod.z.string().nullish(),ProviderID:zod.z.string().nullish(),Type:Wi.nullish(),IssuedAt:l.nullish(),ExpiresAt:l.nullish(),CreditsToAward:zod.z.number().nullish()}).passthrough(),Nf=zod.z.object({InvalidSsvCount:zod.z.number().nullish(),OrphanCompletions:zod.z.number().nullish(),FastCompletions:zod.z.number().nullish(),LastFlaggedAt:l.nullish()}).passthrough();zod.z.object({Credits:wf.nullish(),Placements:zod.z.record(zod.z.string(),Bf).nullish(),Daily:qf.nullish(),Session:Ef.nullish(),LastImpressionAt:l.nullish(),LastInterstitialAt:l.nullish(),LastRewardedAt:l.nullish(),LastAppOpenAt:l.nullish(),TotalImpressions:zod.z.number().nullish(),TotalRewardedCompletions:zod.z.number().nullish(),AdsDisabledUntil:l.nullish(),Consent:Lf.nullish(),PendingRequests:zod.z.record(zod.z.string(),Gf).nullish(),FraudFlags:Nf.nullish(),UpdatedAt:l.nullish()}).passthrough();var jf={Unread:"Unread",Read:"Read",Deleted:"Deleted",Expired:"Expired"},Ff=zod.z.enum(["Unread","Read","Deleted","Expired"]),Vf={Admin:"Admin",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season",Collection:"Collection",MilestoneEvent:"MilestoneEvent",PlayerGift:"PlayerGift",Social:"Social",Compensation:"Compensation",Referral:"Referral",Quest:"Quest"},_f=zod.z.enum(["Admin","Leaderboard","CoopEvent","Season","Collection","MilestoneEvent","PlayerGift","Social","Compensation","Referral","Quest"]),Wf={Active:"Active",Paused:"Paused",Cancelled:"Cancelled",Completed:"Completed"},Qf=zod.z.enum(["Active","Paused","Cancelled","Completed"]),Hf=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(),Kf=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(),Hf).nullish(),Segments:zod.z.array(Kf).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:_f.nullish(),RelatedEntityID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderPublicData:Ce.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:G.nullish(),Claimed:zod.z.boolean().nullish(),ClaimedAtUtc:l.nullish(),Status:Ff.nullish(),CreatedAtUtc:l.nullish(),ExpiresAtUtc:l.nullish(),ReadAtUtc:l.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:G.nullish(),TargetSegmentID:zod.z.string().nullish(),TargetUserIDs:zod.z.array(zod.z.string()).nullish(),StartsAtUtc:l.nullish(),ExpiresAtUtc:l.nullish(),CreatedAtUtc:l.nullish(),CreatedByAdminID:zod.z.string().nullish(),AdminComment:zod.z.string().nullish(),Status:Qf.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:l.nullish(),ReceivedBroadcastIDs:zod.z.array(zod.z.string()).nullish(),ClaimedBroadcastIDs:zod.z.array(zod.z.string()).nullish(),DailyP2PGiftsSent:zod.z.number().nullish(),DailyGiftsResetDate:l.nullish(),LastOpenedAtUtc:l.nullish(),TotalMessagesReceived:zod.z.number().nullish(),TotalRewardsClaimed:zod.z.number().nullish()}).passthrough();var Cl="idos_device_id",qr=class{storage;constructor(e=new ct){this.storage=e;}getPlatform(){return "Web"}getFullURL(){return ""}getStartParameter(){return null}getTelegramInitDataRaw(){return null}getDeviceID(){let e=this.storage.getString(Cl);return e||(e="noop-device",this.storage.setString(Cl,e)),e}getDeviceModel(){return "Noop"}shareLink(){}openInvoice(){}async showAd(){}async copyToClipboard(){}};
|
|
1
|
+
'use strict';var zod=require('zod'),Ft=require('decimal.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Ft__default=/*#__PURE__*/_interopDefault(Ft);var bt=class{listeners=new Map;on(e,t){let s=this.listeners.get(e);return s||(s=new Set,this.listeners.set(e,s)),s.add(t),()=>{this.off(e,t);}}once(e,t){let s=this.on(e,r=>{s(),t(r);});return s}off(e,t){let s=this.listeners.get(e);s&&(s.delete(t),s.size===0&&this.listeners.delete(e));}emit(e,t){let s=this.listeners.get(e);if(s)for(let r of [...s])r(t);}removeAllListeners(){this.listeners.clear();}};function xl(){let a=new Map;return {get:e=>a.get(e)??null,set:(e,t)=>{a.set(e,t);},remove:e=>{a.delete(e);}}}function Qi(){return Dl()??xl()}function Dl(){try{let a=globalThis.localStorage;if(!a)return null;let e="__idos_probe__";return a.setItem(e,"1"),a.removeItem(e),{get:t=>{try{return a.getItem(t)}catch{return null}},set:(t,s)=>{try{a.setItem(t,s);}catch{try{a.removeItem(t);}catch{}}},remove:t=>{try{a.removeItem(t);}catch{}}}}catch{return null}}var Hi="https://api.idosgames.com";function Ki(a){return {titleID:a.titleID,titleTemplateID:a.titleTemplateID??"default",buildKey:a.buildKey??"",baseUrl:(a.baseUrl??Hi).replace(/\/+$/,""),devBuild:a.devBuild??false,debugLogging:a.debugLogging??false,configStorage:a.configStorage??Qi()}}var ut=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{}}},ct=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 pt(){return globalThis.Telegram?.WebApp??null}function k(){return crypto.randomUUID()}var $i="idos_device_id",dt=class{storage;constructor(e=new ut){this.storage=e;}getPlatform(){return pt()?.platform??"Web"}getFullURL(){return typeof location<"u"?location.href:""}getStartParameter(){let e=pt()?.initDataUnsafe?.start_param;return typeof e=="string"?e:null}getTelegramInitDataRaw(){let e=pt()?.initData;return e&&e.length>0?e:null}getDeviceID(){let e=this.storage.getString($i);return e||(e=k(),this.storage.setString($i,e)),e}getDeviceModel(){return typeof navigator<"u"&&navigator.userAgent?navigator.userAgent:"Web"}shareLink(e){let t=pt();if(t?.openTelegramLink){t.openTelegramLink(e);return}typeof window<"u"&&window.open(e,"_blank");}openInvoice(e){let t=pt();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 Zi(a){return {ok:true,data:a}}function n(a,e){return {ok:false,reason:a,error:e}}function bl(a){return a.ok}function vl(a){return !a.ok}var qe={Virtual:"Virtual",Crypto:"Crypto"},ht=zod.z.enum(["Virtual","Crypto"]),zl={Item:"Item",VirtualCurrency:"VirtualCurrency",CryptoCurrency:"CryptoCurrency",UsdCent:"UsdCent"},Ot=zod.z.enum(["Item","VirtualCurrency","CryptoCurrency","UsdCent"]),Tl={TimedEvent:"TimedEvent",Quest:"Quest",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season"},wt=zod.z.enum(["TimedEvent","Quest","Leaderboard","CoopEvent","Season"]),Pl={Cyclic:"Cyclic",Scheduled:"Scheduled",Chained:"Chained"},vt=zod.z.enum(["Cyclic","Scheduled","Chained"]),ue={None:"None",Device:"Device",Email:"Email",iDosGames:"iDosGames",Facebook:"Facebook",Google:"Google",GooglePlay:"GooglePlay",Telegram:"Telegram",Wallet:"Wallet"};var M=zod.z.union([zod.z.number(),zod.z.string()]).transform((a,e)=>{let t=typeof a=="string"?Number(a):a;return Number.isFinite(t)?Math.trunc(t):(e.addIssue({code:zod.z.ZodIssueCode.custom,message:`Invalid integer amount: ${String(a)}`}),zod.z.NEVER)}),B=zod.z.union([zod.z.number(),zod.z.string()]).transform((a,e)=>{let t=typeof a=="number"?String(a):a.trim();return t===""||Number.isNaN(Number(t))?(e.addIssue({code:zod.z.ZodIssueCode.custom,message:`Invalid decimal: ${String(a)}`}),zod.z.NEVER):t}),l=zod.z.string();var Er=zod.z.object({Type:Ot.nullish(),CurrencyID:zod.z.string().nullish(),Amount:M.nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish()}),Il=zod.z.object({Type:wt.nullish(),EntityID:zod.z.string()}),kl=zod.z.object({Address:Il.nullish(),Amount:M.nullish(),Source:zod.z.string().nullish()}),ce=zod.z.object({Entries:zod.z.array(Er).nullish(),EventTokens:zod.z.array(kl).nullish()}),Ji=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Resources:ce.nullish()}),G=zod.z.object({Standard:ce.nullish(),PremiumBonuses:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(Ji).nullish()}),K=zod.z.object({Standard:ce.nullish(),PremiumDiscounts:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(Ji).nullish()}),x=zod.z.object({Grant:G.nullish(),Consume:K.nullish()}),st=zod.z.object({FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),FromResult:x.nullish(),ToResult:x.nullish()});zod.z.object({FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),Transferred:ce.nullish()});var Ml=zod.z.object({ExperimentID:zod.z.string().nullish(),Variants:zod.z.array(zod.z.string()).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:Ml.nullish()}).passthrough();var de=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 Al=zod.z.object({OffsetSecondsFromParentStart:zod.z.number().nullish(),DurationSeconds:zod.z.number().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Ul=zod.z.object({StartUtc:zod.z.string().nullish(),EndUtc:zod.z.string().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Ol=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 wl=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 _e=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:de.nullish()}).passthrough(),pe=zod.z.object({Mode:zod.z.string().nullish(),IsActive:zod.z.boolean().nullish(),Scheduled:Ul.nullish(),Chain:Ol.nullish(),Cyclic:wl.nullish(),ActivationTriggers:zod.z.array(_e).nullish(),Relative:Al.nullish()}).passthrough();var Bl=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Rewards:G.nullish()}).passthrough(),ql=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),Lr=zod.z.object({Bundles:zod.z.array(Bl).nullish(),Multipliers:zod.z.array(ql).nullish()}).passthrough();var El=zod.z.enum(["BoardStageLevel","BoardRank","BoardCyclesCompleted","CharacterLevel","SeasonTier","EventTokenTotalEarned","VirtualCurrencyBalance","PlayerLevel"]);var Ll=zod.z.enum(["Tiered","Linear"]);var Gl=zod.z.enum(["Step","Linear"]),Nl=zod.z.object({AtProgress:zod.z.number().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),Bt=zod.z.object({Source:El.nullish(),SourceKey:zod.z.string().nullish(),CurveType:Ll.nullish(),Tiers:zod.z.array(Nl).nullish(),TierMode:Gl.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:ce.nullish(),ExcludeRewards:ce.nullish()}).passthrough(),ye=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:G.nullish(),BonusRewards:G.nullish(),SeasonTierRewards:Lr.nullish(),SortOrder:zod.z.number().nullish(),IsFeatured:zod.z.boolean().nullish()}).passthrough(),Xe=zod.z.object({Milestones:zod.z.record(zod.z.string(),ye).nullish()}).passthrough();var ne=zod.z.object({PresetID:zod.z.string().nullish(),Remove:zod.z.array(zod.z.string()).nullish()}).passthrough();var jl=zod.z.object({TargetCurrencyID:zod.z.string().nullish(),Rate:zod.z.number().nullish(),MaxConvertAmount:zod.z.number().nullish()}).passthrough(),rt=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:jl.nullish()}).passthrough();var re=a=>zod.z.object({Id:zod.z.string(),Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:a.nullish()}),Et=a=>zod.z.object({ServerTimeUtc:l,Items:zod.z.array(re(a)),Resources:x.nullish()});var Fl={Active:"Active",Completed:"Completed",Claimed:"Claimed",Expired:"Expired"},Yi=zod.z.enum(["Active","Completed","Claimed","Expired"]),Vl=zod.z.object({}).passthrough().transform(a=>a),_l=zod.z.object({CycleID:zod.z.string(),InstanceKey:zod.z.string().nullish(),PhaseID:zod.z.string().nullish(),CycleIndex:zod.z.number().nullish(),CycleStartUtc:l.nullish(),CycleEndUtc:l.nullish(),PointsTotalEarned:M.nullish(),PointsCurrent:M.nullish(),ClaimedPointMilestoneIDs:zod.z.array(zod.z.string()).nullish()}),Gr=zod.z.object({QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),ObjectiveID:zod.z.string().nullish(),NewValue:M.nullish(),ObjectiveCompleted:zod.z.boolean().nullish(),Status:Yi}),Xi=zod.z.object({State:Vl.nullish(),PointsTracks:zod.z.record(zod.z.string(),_l).nullish()}),Nr=zod.z.object({ServerTimeUtc:l,QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),NewStatus:Yi.nullish(),Resources:x.nullish()}),jr=zod.z.object({ServerTimeUtc:l,CycleID:zod.z.string(),MilestoneID:zod.z.string(),PointsTotalEarned:M.nullish(),Resources:x.nullish()}),en=zod.z.object({ServerTimeUtc:l,CycleID:zod.z.string(),GroupCompletionID:zod.z.string(),GroupID:zod.z.string().nullish(),CompletedGroupQuests:zod.z.number().nullish(),RequiredGroupQuests:zod.z.number().nullish(),Resources:x.nullish()}),tn=zod.z.object({MetricID:zod.z.string(),Updates:zod.z.array(Gr).nullish()}),sn=zod.z.array(re(Nr)),rn=zod.z.array(re(jr)),Wl={ClientApi:"ClientApi",ServerApi:"ServerApi",SystemEvent:"SystemEvent"},Ql=zod.z.enum(["ClientApi","ServerApi","SystemEvent"]),Hl={BlockProgressAndClaim:"BlockProgressAndClaim",BlockClaimOnly:"BlockClaimOnly"},Kl=zod.z.enum(["BlockProgressAndClaim","BlockClaimOnly"]),nn=zod.z.object({ObjectiveID:zod.z.string().nullish(),Source:Ql.nullish(),MaxProgressPerCall:zod.z.number().nullish(),MetricID:zod.z.string().nullish(),Triggers:zod.z.array(_e).nullish(),TargetValue:zod.z.number().nullish(),AggregationMethod:zod.z.string().nullish()}).passthrough(),Fr=zod.z.object({Milestones:ne.nullish(),Linking:ne.nullish(),Availability:ne.nullish(),Reward:ne.nullish(),Objectives:ne.nullish()}).passthrough(),$l=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(),on=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:Kl.nullish()}).passthrough(),an=zod.z.object({Schedule:pe.nullish(),AccrueProgressWhenLocked:zod.z.boolean().nullish(),Gate:Q.nullish(),Limits:de.nullish()}).passthrough(),ln=zod.z.object({Grant:G.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),Zl=zod.z.object({QuestID:zod.z.string().nullish(),Identity:$l.nullish(),Linking:on.nullish(),Availability:an.nullish(),Objectives:zod.z.record(zod.z.string(),nn).nullish(),Reward:ln.nullish(),Presets:Fr.nullish()}).passthrough(),Jl=zod.z.object({CompletionID:zod.z.string().nullish(),GroupID:zod.z.string().nullish(),RequiredCompletedQuests:zod.z.number().nullish(),Gate:Q.nullish(),Reward:G.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),Yl=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(),ye).nullish(),Presets:Fr.nullish(),PointsToken:rt.nullish()}).passthrough(),Xl=zod.z.object({Milestones:zod.z.record(zod.z.string(),Xe).nullish(),Linking:zod.z.record(zod.z.string(),on).nullish(),Availability:zod.z.record(zod.z.string(),an).nullish(),Reward:zod.z.record(zod.z.string(),ln).nullish(),Objectives:zod.z.record(zod.z.string(),zod.z.record(zod.z.string(),nn)).nullish()}).passthrough(),eu=zod.z.object({CycleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:pe.nullish(),Milestones:zod.z.record(zod.z.string(),ye).nullish(),Gate:Q.nullish(),PointsToken:rt.nullish(),GroupCompletions:zod.z.record(zod.z.string(),Jl).nullish(),Phases:zod.z.record(zod.z.string(),Yl).nullish(),Presets:Fr.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Lt=zod.z.object({Cycles:zod.z.record(zod.z.string(),eu).nullish(),Quests:zod.z.record(zod.z.string(),Zl).nullish(),Presets:Xl.nullish()}).passthrough(),Le={GetQuestDefinitions:"GetQuestDefinitions",GetUserQuestState:"GetUserQuestState",RefreshQuestCycles:"RefreshQuestCycles",ClaimQuestReward:"ClaimQuestReward",ClaimMilestoneReward:"ClaimMilestoneReward",AddQuestProgress:"AddQuestProgress",ClaimQuestRewardsBatch:"ClaimQuestRewardsBatch",ClaimMilestoneRewardsBatch:"ClaimMilestoneRewardsBatch",ClaimGroupCompletionReward:"ClaimGroupCompletionReward"};var Gt=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(),s=this.last.get(e);return s!==void 0&&t-s<this.windowMs?false:(this.last.set(e,t),true)}reset(){this.last.clear();}};var Nt=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(a){return a===429||a>=500&&a<=599}function Vr(a,e=Math.random){let t=Math.min(500*Math.pow(2,a-1),4e3),s=t*.2*(e()*2-1);return Math.max(50,t+s)}function _r(a){return new Promise(e=>setTimeout(e,a))}var tu=12e3,su=zod.z.object({Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:zod.z.unknown().optional(),QuestProgress:zod.z.array(Gr).nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish(),StateEpoch:zod.z.string().nullish()}).passthrough(),jt=class{baseUrl;emitter;fetchImpl;debugLogging;throttler;inflight=new Nt;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 Gt(e.throttleMs);}setSessionRefreshHandler(e){this.sessionRefreshHandler=e;}async post(e,t,s,r={}){if(!this.throttler.tryAcquire(e))return n("throttled","Throttled");if(!this.inflight.add(e))return n("throttled","Duplicate request skipped");this.raiseBusy();try{let i=`${this.baseUrl}/${e}`,c=JSON.stringify(t),d=r.ticket??null,v=r.silent??!1,w=r.timeoutMs??tu,q=r.autoRetry??!0,se=!1,ge=0;for(;;){let ke;try{ke=await this.doFetch(i,c,d,w);}catch{if(q&&ge<3){ge++,await _r(Vr(ge));continue}return this.connectionFailure("Internet Connection Error",v)}let Me=ke.status;if(Me>=200&&Me<300)return await this.parseSuccess(ke,s,v,e);if(Me===401){if(!se&&this.sessionRefreshHandler){se=!0;let Je=null;try{Je=await this.sessionRefreshHandler();}catch{Je=null;}if(Je){d=Je;continue}}return this.emitter.emit("auth:unauthorized",void 0),n("unauthorized","Unauthorized")}if(un(Me)){if(q&&ge<3){ge++,await _r(Vr(ge));continue}return this.connectionFailure(`Server temporarily unavailable (HTTP ${Me})`,v)}return await this.handleWebError(ke,Me,v)}}finally{this.inflight.remove(e),this.lowerBusy();}}async doFetch(e,t,s,r){let i=new AbortController,c=setTimeout(()=>{i.abort();},r);try{let d={"Content-Type":"application/json"};return s&&(d.Authorization=`Bearer ${s}`),await this.fetchImpl(e,{method:"POST",body:t,headers:d,signal:i.signal})}finally{clearTimeout(c);}}async parseSuccess(e,t,s,r){let i;try{i=await e.text();}catch{return this.globalError("Failed to read response body",s)}let c;try{c=JSON.parse(i);}catch{return this.globalError("JSON Parse Error",s)}let d=su.safeParse(c);if(!d.success)return this.globalError("Malformed response envelope",s);if(!d.data.Success){let se=d.data.Error??"Server returned Success=false";return s||this.emitter.emit("error:global",se),n("server",se)}let v=d.data.QuestProgress;v&&v.length>0&&this.emitter.emit("quest:systemProgress",v);let w=d.data.StateVersions;w&&Object.keys(w).length>0&&this.emitter.emit("user:stateVersions",{epoch:d.data.StateEpoch??null,versions:w});let q=t.safeParse(d.data.Data);if(!q.success){let se=`Validation error (${r}): ${q.error.message}`;return this.debugLogging&&console.warn("[HttpTransport]",se),s||this.emitter.emit("error:global",se),n("validation",se)}return Zi(q.data)}async handleWebError(e,t,s){let r=`HTTP ${t}`;try{let i=await e.text();if(i)try{let d=JSON.parse(i).Error;r=typeof d=="string"&&d.length>0?`HTTP ${t}: ${d}`:`HTTP ${t}: ${i}`;}catch{r=`HTTP ${t}: ${i}`;}}catch{}return s||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 ft(a){return (typeof a=="string"?a:a.toISOString()).slice(0,10)}function zt(a){return `${ft(a)}T00:00:00.000Z`}function pn(a){let e=new Date(a);return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+1)).toISOString()}function dn(a,e){return new Date(a.getTime()+e*6e4).toISOString()}function hn(a,e,t,s){let r={vcChanged:false,ccChanged:false,itemsChanged:false,tokensChanged:false};if(!e)return r;a.InventoryV2??={};let i=a.InventoryV2,c=s.toISOString(),d=new Map,v=new Map,w=new Map,q=new Map,se=new Map,ge=new Map,ke=new Map,Me=new Map,Je=e.Grant?.PremiumTiers??[],At=Je.length;for(let te=0;;te++){let le,H;if(te===0)le=e.Grant?.Standard?.Entries,H=false;else if(te-1<At)le=Je[te-1]?.Resources?.Entries,H=false;else if(te===1+At)le=e.Consume?.Standard?.Entries,H=true;else break;if(le)for(let j of le){if(j.Type==null)continue;let _=Math.max(0,j.Amount??0);if(!(_<=0))switch(j.Type){case "VirtualCurrency":{if(!j.CurrencyID)continue;let W=H?v:d;W.set(j.CurrencyID,(W.get(j.CurrencyID)??0)+_);break}case "CryptoCurrency":{if(!j.CurrencyID)continue;let W=H?q:w;W.set(j.CurrencyID,(W.get(j.CurrencyID)??new Ft__default.default(0)).plus(_));break}case "Item":{if(!j.ItemID)continue;let W=iu(t,j.CatalogID,j.ItemID),X=(W?W.IsStackable??true:true)?H?ge:se:H?Me:ke;X.set(j.ItemID,(X.get(j.ItemID)??0)+_);break}case "UsdCent":continue}}}if(r.vcChanged=d.size>0||v.size>0,r.vcChanged){i.VirtualCurrencies??={};for(let te of new Set([...d.keys(),...v.keys()])){let le=d.get(te)??0,H=v.get(te)??0,j=le-H,_=i.VirtualCurrencies[te];_?(_.Amount+=j,_.UpdatedAt=c,_.Daily&&ft(_.Daily.PeriodStartUtc)===ft(s)?(_.Daily.Earned+=le,_.Daily.Spent+=H):_.Daily={PeriodStartUtc:zt(s),Earned:le,Spent:H}):i.VirtualCurrencies[te]={Amount:j,CreatedAt:c,UpdatedAt:c,Daily:{PeriodStartUtc:zt(s),Earned:le,Spent:H}};}}if(r.ccChanged=w.size>0||q.size>0,r.ccChanged){i.CryptoCurrencies??={};for(let te of new Set([...w.keys(),...q.keys()])){let le=w.get(te)??new Ft__default.default(0),H=q.get(te)??new Ft__default.default(0),j=le.minus(H),_=i.CryptoCurrencies[te];_?(_.Amount=new Ft__default.default(_.Amount).plus(j).toString(),_.UpdatedAt=c):i.CryptoCurrencies[te]={Amount:j.toString(),Frozen:"0",CreatedAt:c,UpdatedAt:c};}}if(r.itemsChanged=se.size>0||ge.size>0||ke.size>0||Me.size>0,r.itemsChanged){i.Items??={},i.UnstackableItems??={};let te=i.UnstackableItems,le=new Set([...se.keys(),...ge.keys(),...ke.keys(),...Me.keys()]);for(let H of le){let j=(se.get(H)??0)-(ge.get(H)??0),_=(ke.get(H)??0)-(Me.get(H)??0),W=j+_,Ae=i.Items[H];Ae?(j!==0&&(Ae.StackableAmount+=j),_!==0&&(Ae.UnstackableAmount+=_),W!==0&&(Ae.TotalAmount+=W)):i.Items[H]={StackableAmount:Math.max(0,j),UnstackableAmount:Math.max(0,_),TotalAmount:Math.max(0,W)};}for(let[H,j]of Me){if(j<=0)continue;let _=Object.values(te).filter(W=>W.ItemID===H&&W.EquippedSlot==null&&(W.ExpiresAt==null||new Date(W.ExpiresAt)>s)).sort(ru).slice(0,j).map(W=>W.ItemInstanceID);for(let W of _)delete te[W];}for(let[H,j]of ke){let _=nu(t,H);for(let W=0;W<j;W++){let Ae=k();te[Ae]={ItemInstanceID:Ae,ItemID:H,CatalogID:_,RemainingUses:1,AcquiredAt:c};}}}a.EventToken??={};let Sl=a.EventToken;for(let te=0;;te++){let le,H;if(te===0)le=e.Grant?.Standard?.EventTokens,H=false;else if(te-1<At)le=Je[te-1]?.Resources?.EventTokens,H=false;else if(te===1+At)le=e.Consume?.Standard?.EventTokens,H=true;else break;if(!(!le||le.length===0))for(let j of le){let _=j.Address;if(!_||_.Type==null)continue;let W=j.Amount??0;if(W<=0)continue;let Ae=ou(Sl,_.Type);if(!Ae)continue;let X=Ae[_.EntityID];X||(X={},Ae[_.EntityID]=X),X.Balance??={Current:0,TotalEarned:0,TotalSpent:0},X.Daily??={Date:zt(s),TotalEarned:0},X.Meta??={};let Dt=j.Source&&j.Source.length>0?j.Source:"CustomAction";H?(X.Balance.Current-=W,X.Balance.TotalSpent+=W):(X.Balance.Current+=W,X.Balance.TotalEarned+=W,ft(X.Daily.Date)!==ft(s)&&(X.Daily={Date:zt(s),TotalEarned:0}),X.Daily.TotalEarned+=W,X.Daily.EarnedBySource??={},X.Daily.EarnedBySource[Dt]=(X.Daily.EarnedBySource[Dt]??0)+W,X.Daily.TriggersBySource??={},X.Daily.TriggersBySource[Dt]=(X.Daily.TriggersBySource[Dt]??0)+1,X.Daily.LastTriggerBySource??={},X.Daily.LastTriggerBySource[Dt]=c,X.Meta.JoinedAtUtc||(X.Meta.JoinedAtUtc=c),X.Meta.LastEarnedAtUtc=c),r.tokensChanged=true;}}return r}function ru(a,e){return a.AcquiredAt!==e.AcquiredAt?a.AcquiredAt<e.AcquiredAt?-1:1:a.ItemInstanceID===e.ItemInstanceID?0:a.ItemInstanceID<e.ItemInstanceID?-1:1}function iu(a,e,t){let s=a?.Catalogs;if(s){if(e){let r=s[e]?.Items?.[t];if(r)return r}for(let r of Object.values(s)){let i=r.Items?.[t];if(i)return i}}}function nu(a,e){let t=a?.Catalogs;if(t){for(let[s,r]of Object.entries(t))if(r.Items&&e in r.Items)return s}}function ou(a,e){switch(e){case "TimedEvent":return a.TimedEvent??={};case "Quest":return a.Quest??={};case "Leaderboard":return a.Leaderboard??={};case "CoopEvent":return a.CoopEvent??={};case "Season":return a.Season??={};default:return null}}function Wr(a,e){return a===e||a.startsWith(`${e}:`)}var Vt=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 s of t)this.currentState[s]=e[s];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,s=new Date){if(!this.currentState)return;let r=hn(this.currentState,e,t,s);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,s){if(!e||!this.currentState)return;this.currentState.InventoryV2??={},this.currentState.InventoryV2.CryptoCurrencies??={};let r=this.currentState.InventoryV2.CryptoCurrencies,i=t instanceof Ft__default.default?t:new Ft__default.default(t),c=s??new Date().toISOString(),d=r[e];d?(d.Amount=new Ft__default.default(d.Amount).plus(i).toString(),d.UpdatedAt=c):r[e]={Amount:i.toString(),Frozen:"0",CreatedAt:c,UpdatedAt:c},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,s){if(!e||t<1||!this.currentState)return;this.currentState.Store??={},this.currentState.Store.Purchases??={};let r=this.currentState.Store.Purchases,i=r[e];i||(i={OfferID:e,TotalPurchases:0,DailyPurchases:0,DailyResetUtc:"",LastPurchasedAt:""},r[e]=i),i.TotalPurchases+=t,i.LastPurchasedAt=s,s>=i.DailyResetUtc?(i.DailyPurchases=t,i.DailyResetUtc=pn(s)):i.DailyPurchases+=t,this.emitter.emit("user:storeUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyLootboxPityTriggers(e,t,s){if(!e||s<=0)return;this.currentState??={};let r=this.currentState.Lootbox??={};if(r.Pity??={},t){let i=new Date().toISOString();for(let c of t)c.RuleID&&(r.Pity[`${e}:${c.RuleID}`]={OpensSinceLastTrigger:0,LastTriggeredAtUtc:i});}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,s){if(!e)return;this.currentState??={},this.currentState.Quest??={};let r=this.currentState.Quest;if(t){r.Cycles??={};let i=r.Cycles[t];if(!i)return;i.Quests??={};let c=i.Quests[e]??={QuestID:e,Status:s};c.Status=s,s==="Claimed"&&(c.ClaimedAtUtc??=new Date().toISOString());}else {r.PermanentQuests??={};let i=r.PermanentQuests[e]??={QuestID:e,Status:s};i.Status=s,s==="Claimed"&&(i.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 s=this.getQuestPointsProgress(e);s&&(s.Milestone??={},s.Milestone.ClaimedIDs??=[],s.Milestone.ClaimedIDs.includes(t)||s.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 s of Object.values(e)){if(!s.CycleID)continue;let r=s.InstanceKey?`${s.CycleID}:${s.InstanceKey}`:s.CycleID,i=t[r]??={};i.Balance??={Current:0,TotalEarned:0,TotalSpent:0},i.Balance.Current=s.PointsCurrent??0,i.Balance.TotalEarned=s.PointsTotalEarned??0,i.Milestone??={},i.Milestone.ClaimedIDs=s.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 s=this.currentState.Quest.Cycles[e];s&&(s.ClaimedGroupCompletionIDs??=[],s.ClaimedGroupCompletionIDs.includes(t)||s.ClaimedGroupCompletionIDs.push(t),this.emitter.emit("user:questUpdated",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 s of e){if(!s.QuestID)continue;let r;if(!s.CycleID)t.PermanentQuests??={},r=t.PermanentQuests[s.QuestID]??={QuestID:s.QuestID,Status:s.Status};else {t.Cycles??={};let i=t.Cycles[s.CycleID];if(!i)continue;i.Quests??={},r=i.Quests[s.QuestID]??={QuestID:s.QuestID,Status:s.Status};}if(r.Status=s.Status,s.ObjectiveID){r.Objectives??={};let i=r.Objectives[s.ObjectiveID]??={ObjectiveID:s.ObjectiveID,CurrentValue:0,Completed:false};i.CurrentValue=s.NewValue??0,s.ObjectiveCompleted&&(i.Completed=true,i.CompletedAtUtc??=new Date().toISOString());}s.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[s,r]of Object.entries(t))if(Wr(s,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,s){if(!(!t||!s)){this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.TimedEvent??={};for(let[r,i]of Object.entries(this.currentState.EventToken.TimedEvent))!Wr(r,t)||!i||this.markMilestoneClaimed(i.Milestone??(i.Milestone={}),s);this.patchActiveEventMilestoneClaimed(e,t,s),this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}}patchActiveEventMilestoneClaimed(e,t,s){let r=this.activeEventsCache?.ActiveEvents;if(r)for(let i of r)i.Type!==e||i.TimedEventID!==t||(i.Progress??={},this.markMilestoneClaimed(i.Progress.Milestone??(i.Progress.Milestone={}),s));}markMilestoneClaimed(e,t){if(e.ClaimedIDs??=[],e.ClaimedIDs.includes(t)||e.ClaimedIDs.push(t),e.UnlockedIDs){let s=e.UnlockedIDs.indexOf(t);s>=0&&e.UnlockedIDs.splice(s,1);}}patchLeaderboardMyProgress(e,t){if(!e||!t)return;let s=this.ensureLeaderboardProgress(e);s.CurrentScore=t.CurrentScore??0,s.LastKnownRank=t.LastKnownRank??0,s.ScoreEarnedThisCycle=t.ScoreEarnedThisCycle??0,s.UnclaimedRewardCycleVersion=t.HasUnclaimedReward?Math.max(1,s.UnclaimedRewardCycleVersion??0):0,this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchLeaderboardScoreSubmitted(e,t,s,r){if(!e)return;let i=this.ensureLeaderboardProgress(e);(i.ScoreCycleVersion??0)<r&&(i.ScoreEarnedThisCycle=0,i.ClaimedMilestoneIDs=[],i.BracketID=null),i.CurrentScore=t,i.ScoreEarnedThisCycle=(i.ScoreEarnedThisCycle??0)+s,i.ScoreCycleVersion=r,i.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 s=this.ensureLeaderboardProgress(e);s.ClaimedMilestoneIDs??=[],s.ClaimedMilestoneIDs.includes(t)||s.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,s=t[e];return s||(s={CurrentScore:0,ScoreEarnedThisCycle:0,ScoreCycleVersion:0,UnclaimedRewardCycleVersion:0,LastKnownRank:0},t[e]=s),s}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 s=this.ensureSeasonState(e);s.CurrentTier=t,this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSeasonClaimedTier(e,t){if(!e)return;let s=this.ensureSeasonState(e);s.ClaimedTierRewards??=[],s.ClaimedTierRewards.includes(t)||s.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,s=t[e];return s||(s={SeasonChainID:e},t[e]=s),s}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 s=this.currentState.Character.Characters,r=s[e];r||(r={CharacterID:e},s[e]=r),t(r),this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCharacterEquipment(e,t,s){if(!e||!t)return;let r=this.currentState?.Character?.Characters?.[e];r&&(r.Equipment??={},s===null?delete r.Equipment[t]:r.Equipment[t]=s,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,s=false;for(let[r,i]of Object.entries(e.ChangedInstances??{}))t[r]=i,s=true;for(let r of e.RemovedInstanceIDs??[])r in t&&(delete t[r],s=true);s&&(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,s){this.currentState??={};let r=this.currentState.CoopEvent??={MyObjectIndex:-1};r.ActiveGroupID=e,r.ActiveCoopEventID=t,r.MyObjectIndex=s,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(s=>s!==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(s=>s!==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(s=>s!==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 s=this.currentState.TimedBoost.Active;if(t==="Replace"||t==="KeepBest")for(let r of Object.keys(s)){let i=s[r];i&&i.BoostID===e.BoostID&&r!==e.InstanceID&&delete s[r];}s[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,s,r,i){if(!t)return;this.currentState??={},this.currentState.CustomData??={};let c=this.currentState.CustomData,d={Value:s,UpdatedAt:new Date().toISOString(),Version:r,LastWriter:"Client",ExpiresAt:i??null};if(e==="Private")c.Private??={},c.Private[t]=d;else if(e==="Public")c.Public??={},c.Public[t]=d;else return;c.Version=(c.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 s=this.currentState.CustomData;if(e==="Private")s.Private&&delete s.Private[t];else if(e==="Public")s.Public&&delete s.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 s=this.ensureBoard();s.BuildingStates??=[];let r=s.BuildingStates.find(i=>i.SlotIndex===e);r||(r={SlotIndex:e},s.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 s=this.ensureBoard().Pending;!s||s.Type.toUpperCase()!=="SPECIAL"||(s.Special??={},e(s.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 _t=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 Wt=class{user;config;constructor(e){this.user=new Vt(e),this.config=new _t;}reset(){this.user.clear(),this.config.applyTitlePublicConfiguration(null);}};var Qt=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 au(e)?e:ue.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 au(a){return a!==null&&Object.values(ue).includes(a)}var lu=8,uu=100,cu=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i,mn=["GameLoop"],Ht=class{constructor(e){this.ctx=e;}ctx;authContext=null;refreshing=false;rememberSession=true;sessionAuthType=ue.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(ue.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 s=await this.ctx.api.authentication.loginWithTelegram(t);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(ue.Telegram)):s}async loginWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let s=this.baseRequest();s.Email=e,s.Password=t;let r=await this.ctx.api.authentication.loginWithEmail(s);if(!r.ok)return r;this.applyAuthContext(r.data);let i=await this.fetchAndApplyClientState(ue.Email);return i.ok&&this.keepEmailCredentials(e,t),i}async registerWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let s=this.baseRequest();s.Email=e,s.Password=t,s.DeviceID=this.ctx.platform.getDeviceID(),s.Device=this.ctx.platform.getDeviceModel(),s.Platform=this.ctx.platform.getPlatform();let r=await this.ctx.api.authentication.registerWithEmail(s);if(!r.ok)return r;this.applyAuthContext(r.data);let i=await this.fetchAndApplyClientState(ue.Email);return i.ok&&this.keepEmailCredentials(e,t),i}async loginWithGoogle(e){this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.GoogleIDToken=e;let s=await this.ctx.api.authentication.loginWithGoogle(t);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(ue.Google)):s}async requestWalletChallenge(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let s=this.baseRequest();return s.WalletAddress=e,s.NetworkID=t,this.ctx.api.authentication.requestWalletChallenge(s)}async loginWithWallet(e,t,s){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();r.WalletAddress=e,r.NetworkID=t,r.WalletSignature=s,r.Platform=this.ctx.platform.getPlatform(),r.Device=this.ctx.platform.getDeviceModel(),r.DeviceID=this.ctx.platform.getDeviceID();let i=await this.ctx.api.authentication.loginWithWallet(r);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(ue.Wallet)):i}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 s=await this.ctx.api.authentication.loginWithPlatformToken(t);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(ue.iDosGames)):s}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 s=await this.ctx.api.authentication.loginWithSsoCode(t);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(ue.iDosGames)):s}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,s){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();return r.Email=e,r.ResetToken=t,r.Password=s,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,s){switch(e){case ue.Email:return this.loginWithEmail(t,s);case ue.Device:case ue.None:return this.loginWithDeviceID();case ue.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!==ue.None?this.sessionAuthType:this.ctx.authStore.lastAuthType;if(e===ue.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&&cu.test(e)}static isValidPasswordLength(e){return e.length>=lu&&e.length<=uu}keepEmailCredentials(e,t){this.sessionEmail=e,this.sessionPassword=t,this.rememberSession&&this.ctx.authStore.saveEmailAndPassword(e,t);}forgetSession(){this.sessionAuthType=ue.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(mn,mn);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 pu="idos:cfg",gt=class{constructor(e,t){this.storage=e;this.titleId=t;}storage;titleId;static scopeOf(e,t){return t&&t.length>0?`x:${fn(t)}`:e&&e.length>0?`f:${fn(e)}`:t?"x:":"f:"}async read(e){try{let t=await this.storage.get(this.keyOf(e));if(!t)return null;let s=JSON.parse(t);return !s||typeof s!="object"||typeof s.v!="string"||!s.c?null:s}catch{return null}}async write(e,t,s){try{let r={v:t,c:s};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 `${pu}:${this.titleId}:${e}`}};function fn(a){return [...a].map(e=>e.toLowerCase()).sort().join(",")}var du="idos:state",Kt=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 s=JSON.parse(t);return !s||typeof s!="object"||typeof s.e!="string"||!s.v||!s.s?null:s}catch{return null}}async write(e,t,s,r){if(!(!e||!t))try{let i={e:t,v:s,s:r};await this.storage.set(this.keyOf(e),JSON.stringify(i));}catch{}}keyOf(e){return `${du}:${this.titleId}:${e}`}};function hu(a,e){if(!a)return;let t=new Set((e??[]).map(r=>r.trim().toLowerCase()));if(t.size===0)return a;let s={};for(let[r,i]of Object.entries(a))t.has(r.toLowerCase())||(s[r]=i);return s}function Hr(a,e,t,s){let r={...a??{}};if(!e||!t||!s)return r;for(let[i,c]of Object.entries(t))s[i]===c&&i in e&&(r[i]=e[i]);return r}function mu(a){return {...a??{}}}function Kr(a){return typeof a.StateEpoch=="string"&&a.StateEpoch.length>0?a.StateEpoch:null}var $t=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=hu(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[s,r]of Object.entries(t)){let i=this.versions[s];i!==void 0&&r===i+1?this.versions[s]=r:delete this.versions[s],this.dirty=true;}}afterFullRead(e,t){e!==this.epoch&&this.reset(e),this.versions=mu(t),this.dirty=true;}afterSliceRead(e,t){e!==this.epoch&&this.reset(e);for(let[s,r]of Object.entries(t??{}))this.versions[s]=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 gn=n("server","Title configuration is unavailable (CDN and API both failed)."),Zt=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:k()}:null}get configCache(){return this.cache??=new gt(this.ctx.settings.configStorage,this.ctx.settings.titleID)}cache;get stateStore(){return this.versionStore??=new $t(new Kt(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=gt.scopeOf(e.TitleFields,null),s=await this.configCache.read(t);s&&(e.KnownTitleConfigVersion=s.v);let r=await this.prepareStateHandshake(e,null),i=await this.ctx.api.user.getClientState(e);if(!i.ok)return i;let c=await this.resolveTitleConfig(i.data,t,s,{Fields:e.TitleFields});return c==null?gn:(this.finishStateHandshake(i.data,r),await this.applyClientState(i.data,c,void 0,void 0),await this.flushState(r),i)}async prepareStateHandshake(e,t){let s=this.ctx.auth.context?.userID;if(!s)return {userId:null,cached:null,sent:void 0};await this.stateStore.load(s),await this.stateStore.flush(s,this.ctx.data.user.state);let r=this.stateStore.versionsFor(t);if(r){e.KnownStateVersions=r;let i=this.stateStore.currentEpoch;i&&(e.KnownStateEpoch=i);}return {userId:s,cached:this.stateStore.cachedState,sent:r}}finishStateHandshake(e,t){let s=Hr(e.User,t.cached,t.sent,e.StateVersions);e.User=s;let r=Kr(e);!r||!t.userId||this.stateStore.afterFullRead(r,e.StateVersions);}async resolveTitleConfig(e,t,s,r){let i=e.TitleConfigVersion;if(s&&i&&s.v===i)return s.c;if(e.TitleConfigUrl){let d=await this.fetchConfigFromCdn(e.TitleConfigUrl);if(d!=null)return i&&await this.configCache.write(t,i,d),d}let c=await this.fetchConfigFromApi(r);return c!=null?(i&&await this.configCache.write(t,i,c),c):s?.c??null}async fetchConfigFromCdn(e){try{let t=await this.ctx.fetchImpl(e);if(!t.ok)return null;let s=await t.json();return s&&typeof s=="object"?s:null}catch{return null}}async fetchConfigFromApi(e){let t=this.baseRequest();if(!t)return null;let s={...t,...e},r=e.ExcludeFields?await this.ctx.api.title.getTitlePublicConfigurationExcept(s):await this.ctx.api.title.getTitlePublicConfiguration(s);return r.ok?r.data:null}async getClientStateExcept(e,t){let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.ExcludeFields=e,s.ExcludeTitleFields=t;let r=gt.scopeOf(null,t??[]),i=await this.configCache.read(r);i&&(s.KnownTitleConfigVersion=i.v);let c=await this.prepareStateHandshake(s,e??null),d=await this.ctx.api.user.getClientStateExcept(s);if(!d.ok)return d;let v=await this.resolveTitleConfig(d.data,r,i,{ExcludeFields:t??[]});return v==null?gn:(this.finishStateHandshake(d.data,c),await this.applyClientState(d.data,v,e,t),await this.flushState(c),d)}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 s=await this.prepareStateHandshake(t,null),r=await this.ctx.api.user.getUserState(t);if(!r.ok)return r;let i=Hr(r.data.User,s.cached,s.sent,r.data.StateVersions);r.data.User=i;let c=Object.keys(r.data.StateVersions??{});this.ctx.data.user.applyUserStateContainers(i,c);let d=Kr(r.data);return d&&(this.stateStore.afterSliceRead(d,r.data.StateVersions),await this.flushState(s)),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,s){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.UsageTime=e,r.IsNewSession=t,r.SessionDurationSeconds=s;let i=await this.ctx.api.user.addUsageTime(r);return i.ok&&this.ctx.emitter.emit("user:usageTimeAdded",i.data),i}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 s=await this.ctx.api.user.changeUsername(t);return s.ok&&this.ctx.emitter.emit("user:usernameChanged",s.data),s}async applyClientState(e,t,s,r){let i=s?.includes("GameLoop")===true,c=r?.includes("GameLoop")===true,d=i?this.ctx.data.user.state?.GameLoop:void 0,v=c?this.ctx.data.config.titlePublicConfiguration?.GameLoop:void 0;this.ctx.data.config.applyTitlePublicConfiguration(t),this.ctx.data.user.applyUserState(e.User??{});let w=this.ctx.data.user.state;i&&w&&w.GameLoop==null&&(w.GameLoop=d);let q=this.ctx.data.config.titlePublicConfiguration;c&&q&&q.GameLoop==null&&(q.GameLoop=v),this.ctx.emitter.emit("user:clientStateReceived",e);}};var Yt=class{constructor(e){this.ctx=e;}ctx;async convert(e,t,s,r,i,c){if(!t)return n("client","SourceID is required.");if(!r)return n("client","TargetID is required.");if(i<=0)return n("client","Amount must be positive.");if(e===s&&t===r)return n("client","Source and target must differ.");if(e===qe.Crypto||s===qe.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 d={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:s,TargetID:r,SourceAmount:String(Math.trunc(i)),TransactionID:c&&c.length>0?c:`convert_${e}_${t}_to_${s}_${r}_${k()}`},v=await this.ctx.api.currency.convert(d);if(v.ok){let w=v.data,q={Consume:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:w.SourceID,Amount:w.SourceSpent}]}},Grant:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:w.TargetID,Amount:w.TargetCredited}]}}};this.ctx.data.user.applyResourceOperation(q,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("currency:converted",w);}return v}async cryptoConvert(e,t,s,r,i,c){let d=i instanceof Ft__default.default?i:new Ft__default.default(i);if(!t)return n("client","SourceID is required.");if(!r)return n("client","TargetID is required.");if(d.lte(0))return n("client","SourceAmount must be a positive decimal.");if(e===s&&t===r)return n("client","Source and target must differ.");if(e===qe.Virtual&&s===qe.Virtual)return n("client","cryptoConvert requires at least one crypto side. Use convert for VC\u2194VC.");if(e===qe.Virtual&&!d.isInteger())return n("client","Virtual currency source amount must be integer.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let v={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:s,TargetID:r,SourceAmount:d.toString(),TransactionID:c&&c.length>0?c:`crypto_convert_${e}_${t}_to_${s}_${r}_${k()}`},w=await this.ctx.api.currency.cryptoConvert(v);if(w.ok){let q=w.data,se=[],ge=[];if(q.SourceType===qe.Virtual&&se.push({Type:"VirtualCurrency",CurrencyID:q.SourceID,Amount:Math.trunc(Number(q.SourceSpent))}),q.TargetType===qe.Virtual&&ge.push({Type:"VirtualCurrency",CurrencyID:q.TargetID,Amount:Math.trunc(Number(q.TargetCredited))}),se.length>0||ge.length>0){let ke={Consume:se.length>0?{Standard:{Entries:se}}:null,Grant:ge.length>0?{Standard:{Entries:ge}}:null};this.ctx.data.user.applyResourceOperation(ke,this.ctx.data.config.itemDefinitions);}q.SourceType===qe.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(q.SourceID,new Ft__default.default(q.SourceSpent).negated(),q.ServerTimeUtc),q.TargetType===qe.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(q.TargetID,new Ft__default.default(q.TargetCredited),q.ServerTimeUtc),this.ctx.emitter.emit("currency:cryptoConverted",q);}return w}};var Xt=class{constructor(e){this.ctx=e;}ctx;async upgradeLevel(e,t){let s=e.trim();if(!s)return n("client","ItemInstanceID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),ItemInstanceID:s,RelatedEntityID:`upgrade_item_${s}_${k()}`};t&&t.length>0&&(r.FodderInstanceIDs=[...t]);let i=await this.ctx.api.item.upgradeLevel(r);return i.ok&&(await this.ctx.userService.getUserInventory(),this.ctx.emitter.emit("item:levelUpgraded",i.data)),i}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},s=await this.ctx.api.item.upgradeLevelsBatch(t);return s.ok&&(await this.ctx.userService.getUserInventory(),this.ctx.emitter.emit("item:levelsUpgradedBatch",s.data)),s}};var fu="Store",es=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 s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),OfferID:e,Count:t,RelatedEntityID:`store_buy_${e}_${s.userID}_${k()}`},i=await this.ctx.api.store.purchase(r);if(i.ok){let c=i.data;this.ctx.data.user.patchStorePurchase(e,t,c.ServerTimeUtc),this.ctx.data.user.applyResourceOperation(c.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("store:offerPurchased",c);}return i}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},s=await this.ctx.api.store.purchaseBatch(t);if(s.ok){let r=false;for(let i of s.data)!i.Success||!i.Data||!i.Data.OfferID||(this.ctx.data.user.patchStorePurchase(i.Data.OfferID,i.Data.Count,i.Data.ServerTimeUtc),!r&&i.Data.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("store:offersPurchasedBatch",s.data);}return s}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(fu,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 gu="Lootbox",ts=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 s=t.data.LootboxDefinitions;s&&(this.ctx.data.config.patchSection(gu,s),this.ctx.emitter.emit("lootbox:definitionsLoaded",s));}return t}async open(e,t,s){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:s,RelatedEntityID:`lootbox_${e}_${s}_${k()}`},i=await this.ctx.api.lootbox.open(r);if(i.ok){let c=i.data;c.TriggeredPity&&c.TriggeredPity.length>0&&this.ctx.data.user.applyLootboxPityTriggers(e,c.TriggeredPity,t),this.ctx.data.user.applyResourceOperation(c.Resources,this.ctx.data.config.itemDefinitions),this.ctx.data.user.applyInventoryDelta(c.Inventory),this.ctx.emitter.emit("lootbox:opened",c);}return i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ru="Reward";function $r(a){return a.length>0&&!a.includes(".")&&!a.includes("$")}var ss=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 s=t.data.RewardDefinitions;s&&(this.ctx.data.config.patchSection(Ru,s),this.ctx.emitter.emit("reward:definitionsLoaded",s));}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 s=t.data;this.multiplierEnabled=s.Enabled,this.multiplier=s.Enabled?s.Multiplier??1:1,this.ctx.emitter.emit("reward:milestoneMultiplierLoaded",s);}return t}async claimDailyReward(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CalendarID:e,RelatedEntityID:`dailyreward_${t.userID}_${e??"default"}_${k()}`},r=await this.ctx.api.reward.claimDailyReward(s);if(r.ok){let i=r.data;this.ctx.data.user.patchDailyCalendarState(i.CalendarID,i.DailyState),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:dailyClaimed",i);}return r}async collectIdleAccrual(e){if(!$r(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}_${k()}`},s=await this.ctx.api.reward.collectIdleAccrual(t);if(s.ok){let r=s.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 s}async claimComebackReward(e){if(!$r(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}_${k()}`},s=await this.ctx.api.reward.claimComebackReward(t);if(s.ok){let r=s.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 s}async claimReward(e){if(!$r(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}_${k()}`},s=await this.ctx.api.reward.claimReward(t);if(s.ok){let r=s.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 s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var yu="Quest",rs=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(yu,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 s=await this.ctx.api.quest.getUserQuestState(t);if(s.ok){let r=s.data.State??{};this.ctx.data.user.applyQuest(r),this.ctx.data.user.patchQuestPointsTracks(s.data.PointsTracks),this.ctx.emitter.emit("quest:userStateLoaded",r);}return s}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 s=e.trim();if(!s)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,i={...this.ctx.buildAuthedBaseRequest(),QuestID:s,CycleID:r,RelatedEntityID:`quest_claim_${r??""}_${s}_${k()}`},c=await this.ctx.api.quest.claimQuestReward(i);if(c.ok){let d=c.data;this.ctx.data.user.patchQuestStatus(d.QuestID,d.CycleID,"Claimed"),this.ctx.data.user.applyResourceOperation(d.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:rewardClaimed",d);}return c}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},s=await this.ctx.api.quest.claimQuestRewardsBatch(t);if(s.ok){let r=false;for(let i of s.data)!i.Success||!i.Data||(this.ctx.data.user.patchQuestStatus(i.Data.QuestID,i.Data.CycleID,"Claimed"),!r&&i.Data.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("quest:rewardsClaimedBatch",s.data);}return s}async claimMilestoneReward(e,t){let s=e.trim(),r=t.trim();if(!s||!r)return n("client","CycleID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CycleID:s,MilestoneID:r,RelatedEntityID:`milestone_claim_${s}_${r}_${k()}`},c=await this.ctx.api.quest.claimMilestoneReward(i);if(c.ok){let d=c.data;this.ctx.data.user.patchMilestoneClaimed(d.CycleID,d.MilestoneID),this.ctx.data.user.applyResourceOperation(d.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:milestoneClaimed",d);}return c}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},s=await this.ctx.api.quest.claimMilestoneRewardsBatch(t);if(s.ok){let r=false;for(let i of s.data)!i.Success||!i.Data||(this.ctx.data.user.patchMilestoneClaimed(i.Data.CycleID,i.Data.MilestoneID),!r&&i.Data.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("quest:milestonesClaimedBatch",s.data);}return s}async claimGroupCompletionReward(e,t){let s=e.trim(),r=t.trim();if(!s||!r)return n("client","CycleID and GroupCompletionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CycleID:s,GroupCompletionID:r,RelatedEntityID:`group_completion_${s}_${r}_${k()}`},c=await this.ctx.api.quest.claimGroupCompletionReward(i);if(c.ok){let d=c.data;this.ctx.data.user.patchGroupCompletionClaimed(d.CycleID,d.GroupCompletionID),this.ctx.data.user.applyResourceOperation(d.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:groupCompletionClaimed",d);}return c}async addQuestProgress(e,t){let s=e.trim();if(!s)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:s,ProgressValue:t},i=await this.ctx.api.quest.addQuestProgress(r);return i.ok&&(this.ctx.data.user.patchQuestProgressUpdates(i.data.Updates),this.ctx.emitter.emit("quest:progressAdded",i.data)),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Cu="TimedEvent",is=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(Cu,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,s,r,i,c,d=1){if(!t)return n("client","LteID is required.");if(!s)return n("client","SourceType is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let v={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,SourceType:s,Outcome:r,AmountOverride:i,SourceParams:c,RollMultiplier:d},w=await this.ctx.api.timedEvent.grantTokens(v);return w.ok&&(this.ctx.data.user.applyResourceOperation(w.data,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensGranted",w.data)),w}async spendTokens(e,t,s){if(!t)return n("client","LteID is required.");if(s<=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:s},i=await this.ctx.api.timedEvent.spendTokens(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensSpent",i.data)),i}async claimMilestone(e,t,s){if(!t||!s)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:s},i=await this.ctx.api.timedEvent.claimMilestone(r);if(i.ok){let c=i.data;this.ctx.data.user.applyResourceOperation(c.Rewards,this.ctx.data.config.itemDefinitions),this.ctx.data.user.patchTimedEventMilestoneClaimed(e,t,s),this.ctx.emitter.emit("timedEvent:milestoneClaimed",c);}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},s=await this.ctx.api.timedEvent.claimMilestonesBatch(t);return s.ok&&(this.applyMilestoneClaimBatch(s.data),this.ctx.emitter.emit("timedEvent:milestonesClaimedBatch",s.data)),s}async claimAllMilestones(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&e.length>0&&(t.Events=e);let s=await this.ctx.api.timedEvent.claimAllMilestones(t);return s.ok&&(this.applyMilestoneClaimBatch(s.data),this.ctx.emitter.emit("timedEvent:allMilestonesClaimed",s.data)),s}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},s=await this.ctx.api.timedEvent.spendTokensBatch(t);if(s.ok){let r=false;for(let i of s.data)!r&&i.Success&&i.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("timedEvent:tokensSpentBatch",s.data);}return s}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},s=await this.ctx.api.timedEvent.grantTokensBatch(t);if(s.ok){let r=false;for(let i of s.data)!r&&i.Success&&i.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("timedEvent:tokensGrantedBatch",s.data);}return s}applyMilestoneClaimBatch(e){let t=false;for(let s of e){if(!s.Success||!s.Data)continue;let r=s.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 Su="Leaderboard",ns=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(Su,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 s=await this.ctx.api.leaderboard.getLeaderboard(t);return s.ok&&this.ctx.emitter.emit("leaderboard:loaded",s.data),s}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 s=await this.ctx.api.leaderboard.getMyProgress(t);return s.ok&&(this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(e),s.data),this.ctx.emitter.emit("leaderboard:myProgressLoaded",s.data)),s}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 s={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,Score:t},r=await this.ctx.api.leaderboard.submitScore(s);if(r.ok){let i=r.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),i.NewScore,t,i.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",i);}return r}async submitScoreFromSource(e,t,s,r,i=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 c={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,SourceType:t,Outcome:s,Params:r,RollMultiplier:i},d=await this.ctx.api.leaderboard.submitScoreFromSource(c);if(d.ok){let v=d.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),v.NewScore,v.NewScore,v.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",v);}return d}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},s=await this.ctx.api.leaderboard.claimCycleReward(t);if(s.ok){let r=s.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 s}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 s={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,MilestoneID:t},r=await this.ctx.api.leaderboard.claimMilestone(s);if(r.ok){let i=r.data;this.ctx.data.user.patchLeaderboardMilestoneClaimed(this.cycleDocID(e),t),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("leaderboard:milestoneClaimed",i);}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 s=await this.ctx.api.leaderboard.getFriendsLeaderboard(t);return s.ok&&this.ctx.emitter.emit("leaderboard:friendsLoaded",s.data),s}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 s=await this.ctx.api.leaderboard.getLeaderboardsBatch(t);return s.ok&&this.ctx.emitter.emit("leaderboard:loadedBatch",s.data),s}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 s=await this.ctx.api.leaderboard.getProgressBatch(t);if(s.ok){for(let r of s.data)!r.Success||!r.Data||this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(r.Data.LeaderboardID),r.Data);this.ctx.emitter.emit("leaderboard:myProgressLoadedBatch",s.data);}return s}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},s=await this.ctx.api.leaderboard.claimCycleRewardsBatch(t);if(s.ok){for(let r of s.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",s.data);}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},s=await this.ctx.api.leaderboard.claimMilestonesBatch(t);if(s.ok){for(let r of s.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",s.data);}return s}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},s=await this.ctx.api.leaderboard.submitScoresBatch(t);if(s.ok){for(let r of s.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",s.data);}return s}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},s=await this.ctx.api.leaderboard.claimAllRewardsBatch(t);if(s.ok){for(let r of s.data){let i=this.cycleDocID(r.LeaderboardID);r.CycleReward?.Success&&r.CycleReward.Data&&(this.ctx.data.user.patchLeaderboardCycleRewardClaimed(i),r.CycleReward.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.CycleReward.Data.Resources,this.ctx.data.config.itemDefinitions));for(let c of r.Milestones??[])!c.Success||!c.Data||(this.ctx.data.user.patchLeaderboardMilestoneClaimed(i,c.Data.MilestoneID),c.Data.Resources&&this.ctx.data.user.applyResourceOperation(c.Data.Resources,this.ctx.data.config.itemDefinitions));}this.ctx.emitter.emit("leaderboard:allRewardsClaimedBatch",s.data);}return s}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 s=await this.ctx.api.leaderboard.getOverviewBatch(t);if(s.ok){for(let r of s.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",s.data);}return s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var xu="Season",os=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(xu,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 s=await this.ctx.api.season.getActiveSeason(t);return s.ok&&(s.data.UserState&&this.ctx.data.user.patchSeasonState(e,s.data.UserState),this.ctx.emitter.emit("season:activeLoaded",s.data)),s}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 s=await this.ctx.api.season.getUserState(t);return s.ok&&(this.ctx.data.user.patchSeasonState(e,s.data),this.ctx.emitter.emit("season:userStateLoaded",s.data)),s}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 s={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,Amount:t,RelatedEntityID:`season_grant_${e}_${k()}`},r=await this.ctx.api.season.grantStatusTokens(s);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 s={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,TierNumber:t,RelatedEntityID:`season_tier_${e}_t${t}_${k()}`},r=await this.ctx.api.season.claimTierReward(s);if(r.ok){let i=r.data;this.ctx.data.user.patchSeasonClaimedTier(e,t),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("season:tierRewardClaimed",i);}return r}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Du="Premium",as=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(Du,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 s={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,RelatedEntityID:`premium_trial_${e}_${t}`},r=await this.ctx.api.premium.activateTrial(s);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,s="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 i={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,SelectedOptionID:s,Count:r,RelatedEntityID:`premium_purchase_${e}_${t}`},c=await this.ctx.api.premium.purchaseItemOrCurrency(i);if(c.ok){let d=c.data;d.Premium&&this.ctx.data.user.applyPremium(d.Premium),this.ctx.data.user.applyResourceOperation(d.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:purchaseCompleted",d);}return c}async purchaseRealMoney(e,t,s,r,i,c,d,v){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!r||!i)return n("client","ProductID and ReceiptData are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let w={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,Store:s,ProductID:r,ReceiptData:i,PurchaseToken:c,PackageName:d,AppStoreEnvironment:v,RelatedEntityID:`premium_iap_${e}_${t}`},q=await this.ctx.api.premium.purchaseRealMoney(w);if(q.ok){let se=q.data;se.Premium&&this.ctx.data.user.applyPremium(se.Premium),this.ctx.data.user.applyResourceOperation(se.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:realMoneyPurchaseCompleted",se);}return q}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var bu="Character",ls=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(bu,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 s=t.data.Characters??{};this.ctx.data.user.applyCharacter(s),this.ctx.emitter.emit("character:userCharactersLoaded",s);}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}_${k()}`},s=await this.ctx.api.character.unlockCharacter(t);if(s.ok){let r=s.data;this.ctx.data.user.patchCharacter(r.CharacterID,i=>{i.StatLevels??={},i.Equipment??={},r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=r.ServerTimeUtc;}),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:unlocked",r);}return s}async upgradeStatLevel(e,t,s){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}_${k()}`,...s?.levels!=null?{Levels:s.levels}:{},...s?.targetLevel!=null?{TargetLevel:s.targetLevel}:{}},i=await this.ctx.api.character.upgradeStatLevel(r);if(i.ok){let c=i.data;this.ctx.data.user.patchCharacter(c.CharacterID,d=>{d.StatLevels??={},d.StatLevels[c.StatID]=c.StatLevel,c.Power!=null&&(d.Power=c.Power),d.UpdatedAt=c.ServerTimeUtc;}),this.ctx.data.user.applyResourceOperation(c.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:statLevelUpgraded",c);}return i}async upgradeCharacterLevel(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,RelatedEntityID:`upgrade_char_${e}_${k()}`,...t?.levels!=null?{Levels:t.levels}:{},...t?.targetLevel!=null?{TargetLevel:t.targetLevel}:{}},r=await this.ctx.api.character.upgradeCharacterLevel(s);if(r.ok){let i=r.data;this.ctx.data.user.patchCharacter(i.CharacterID,c=>{c.Level=i.NewLevel,i.Power!=null&&(c.Power=i.Power),c.UpdatedAt=i.ServerTimeUtc,i.NewLevel===1&&(c.StatLevels??={},c.Equipment??={});}),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:levelUpgraded",i);}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 s={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,ItemsToEquip:t},r=await this.ctx.api.character.equipItems(s);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 s={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,UnequipSlotIDs:t},r=await this.ctx.api.character.unequipItems(s);if(r.ok){let i=r.data;this.applyUnequipChangesLocally(e,i),this.ctx.emitter.emit("character:itemsUnequipped",{characterID:e,slotIDs:i.ClearedSlotIDs??[],power:i.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},s=await this.ctx.api.character.unlockCharactersBatch(t);return s.ok&&(this.applyBatchResults(s.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,i=>{i.StatLevels??={},i.Equipment??={},r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=r.ServerTimeUtc;});}),this.ctx.emitter.emit("character:charactersUnlocked",s.data)),s}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},s=await this.ctx.api.character.upgradeCharacterLevelsBatch(t);return s.ok&&(this.applyBatchResults(s.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,i=>{i.Level=r.NewLevel,r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=r.ServerTimeUtc,r.NewLevel===1&&(i.StatLevels??={},i.Equipment??={});});}),this.ctx.emitter.emit("character:levelsUpgraded",s.data)),s}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},s=await this.ctx.api.character.upgradeStatLevelsBatch(t);return s.ok&&(this.applyBatchResults(s.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,i=>{i.StatLevels??={},i.StatLevels[r.StatID]=r.StatLevel,r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=r.ServerTimeUtc;});}),this.ctx.emitter.emit("character:statLevelsUpgraded",s.data)),s}applyBatchResults(e,t){e.Resources&&this.ctx.data.user.applyResourceOperation(e.Resources,this.ctx.data.config.itemDefinitions);for(let s of e.Items??[])!s.Success||!s.Data||t(s.Data);}applyInventoryDelta(e){this.ctx.data.user.applyInventoryDelta(e);}applyEquipChangesLocally(e,t){let s=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let[r,i]of Object.entries(t.Equipment??{}))s.patchCharacterEquipment(e,r,i);s.patchCharacter(e,r=>{t.Power!=null&&(r.Power=t.Power),r.UpdatedAt=t.ServerTimeUtc;});}applyUnequipChangesLocally(e,t){let s=t.ClearedSlotIDs??[];if(s.length===0&&t.Power==null)return;let r=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let i of s)r.patchCharacterEquipment(e,i,null);r.patchCharacter(e,i=>{t.Power!=null&&(i.Power=t.Power),i.UpdatedAt=t.ServerTimeUtc;});}applyUnequipAllLocally(e){let t=this.ctx.data.user;this.applyInventoryDelta(e.Inventory);for(let[s,r]of Object.entries(e.Characters??{})){for(let i of r.ClearedSlotIDs??[])t.patchCharacterEquipment(s,i,null);t.patchCharacter(s,i=>{r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=e.ServerTimeUtc;});}}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var vu="Match",us=class{constructor(e){this.ctx=e;}ctx;async createMatch(e,t,s,r,i){let c=this.ctx.auth.context;if(!c)return n("unauthorized","Not logged in.");let d={...this.ctx.buildAuthedBaseRequest(),Entry:e,RuleID:t,CharacterID:s,BattleStrategy:r,TargetUserID:i,RelatedEntityID:`pvp_create_${c.userID}_${k()}`},v=await this.ctx.api.match.createMatch(d);return v.ok&&(this.ctx.data.user.applyResourceOperation(v.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:created",v.data)),v}async updateMatch(e,t={}){if(!e)return n("client","MatchID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...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(s);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},s=await this.ctx.api.match.cancelMatch(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:cancelled",s.data)),s}async instantBattle(e,t,s,r){let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let c={...this.ctx.buildAuthedBaseRequest(),MatchID:e,RuleID:t,CharacterID:s,BattleStrategy:r,RelatedEntityID:`pvp_battle_${e}_${k()}`},d=await this.ctx.api.match.instantBattle(c);if(d.ok){let v=d.data,w=this.ctx.data.config.itemDefinitions;if(v.Resources)this.ctx.data.user.applyResourceOperation(v.Resources,w);else if(v.ResourcesDual){let q=v.ResourcesDual;q.FromUserID===i.userID&&q.FromResult?this.ctx.data.user.applyResourceOperation(q.FromResult,w):q.ToUserID===i.userID&&q.ToResult&&this.ctx.data.user.applyResourceOperation(q.ToResult,w);}this.ctx.emitter.emit("match:instantBattleCompleted",v);}return d}async saveStrategy(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BattleStrategy:e},s=await this.ctx.api.match.saveStrategy(t);return s.ok&&(this.ctx.data.user.patchMatchStrategy(e),this.ctx.emitter.emit("match:strategySaved",e)),s}async getMyMatches(e=0,t=20,s){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.Statuses=s;let i=await this.ctx.api.match.getMyMatches(r);return i.ok&&this.ctx.emitter.emit("match:myMatchesLoaded",i.data),i}async getAvailableMatches(e=0,t=20,s=false){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.OnlyPublic=s;let i=await this.ctx.api.match.getAvailableMatches(r);return i.ok&&this.ctx.emitter.emit("match:availableMatchesLoaded",i.data),i}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(vu,t.data),this.ctx.emitter.emit("match:definitionsLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var zu="Craft",cs=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(zu,t.data.CraftDefinitions),this.ctx.emitter.emit("craft:definitionsLoaded",t.data.CraftDefinitions)),t}async craft(e,t,s=1,r){if(!e)return n("client","CraftID is required.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let c={...this.ctx.buildAuthedBaseRequest(),CraftID:e,InputItemIDs:t,Count:s,SelectedOptionID:r,RelatedEntityID:`craft_${e}_${i.userID}_${k()}`},d=await this.ctx.api.craft.craft(c);return d.ok&&(this.ctx.data.user.applyResourceOperation(d.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("craft:completed",d.data)),d}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Tu="Collection",ps=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(Tu,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){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,PackTypeID:t,RelatedEntityID:`open_pack_${e}_${t}_${s.userID}_${k()}`},i=await this.ctx.api.collection.openPack(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:packOpened",i.data)),i}async openCollectionChest(e,t){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectionChestID:t,RelatedEntityID:`open_chest_${e}_${t}_${s.userID}_${k()}`},i=await this.ctx.api.collection.openCollectionChest(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:chestOpened",i.data)),i}async useCollectibleJoker(e,t){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:false,RelatedEntityID:`use_joker_${e}_${t}_${s.userID}_${k()}`},i=await this.ctx.api.collection.useCollectibleJoker(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:jokerUsed",i.data)),i}async claimSetReward(e,t){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,SetID:t,RelatedEntityID:`claim_set_${e}_${t}_${s.userID}_${k()}`},i=await this.ctx.api.collection.claimSetReward(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:setRewardClaimed",i.data)),i}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},s=await this.ctx.api.collection.claimSetRewardsBatch(t);if(s.ok){let r=false;for(let i of s.data)!r&&i.Success&&i.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("collection:setRewardsClaimedBatch",s.data);}return s}async claimGrandPrize(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,RelatedEntityID:`grand_prize_${e}_${t.userID}_${k()}`},r=await this.ctx.api.collection.claimGrandPrize(s);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,s,r,i,c=false){let d=this.ctx.auth.context;if(!d)return n("unauthorized","Not logged in.");let v={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:s,ReceiverUserID:r,RequestedCollectibleID:i,RequestedCollectibleIsSpecial:c,RelatedEntityID:`trade_send_${d.userID}_${r}_${k()}`},w=await this.ctx.api.collection.sendTradeOffer(v);return w.ok&&this.ctx.emitter.emit("collection:tradeOfferSent",w.data),w}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}_${k()}`},s=await this.ctx.api.collection.cancelTradeOffer(t);return s.ok&&this.ctx.emitter.emit("collection:tradeOfferCancelled",s.data),s}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}_${k()}`},s=await this.ctx.api.collection.acceptTradeOffer(t);return s.ok&&this.ctx.emitter.emit("collection:tradeOfferAccepted",s.data),s}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}_${k()}`},s=await this.ctx.api.collection.declineTradeOffer(t);return s.ok&&this.ctx.emitter.emit("collection:tradeOfferDeclined",s.data),s}async getMyTradeOffers(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CollectionID=e;let s=await this.ctx.api.collection.getMyTradeOffers(t);return s.ok&&this.ctx.emitter.emit("collection:myTradeOffersLoaded",s.data),s}async getIncomingTradeOffers(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CollectionID=e;let s=await this.ctx.api.collection.getIncomingTradeOffers(t);return s.ok&&this.ctx.emitter.emit("collection:incomingTradeOffersLoaded",s.data),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Pu="CoopEvent",ds=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(Pu,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 s=await this.ctx.api.coopEvent.getActiveEvent(t);return s.ok&&this.ctx.emitter.emit("coopEvent:activeEventLoaded",s.data),s}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 s=await this.ctx.api.coopEvent.getGroupState(t);return s.ok&&this.ctx.emitter.emit("coopEvent:groupStateLoaded",s.data),s}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},s=await this.ctx.api.coopEvent.joinOrCreateGroup(t);if(s.ok){let r=s.data.Group;r&&this.ctx.data.user.patchCoopEventActiveGroup(r.GroupID??null,r.CoopEventID??null,-1),this.ctx.emitter.emit("coopEvent:groupJoined",s.data);}return s}async spin(e,t){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,RelatedEntityID:k()},r=await this.ctx.api.coopEvent.spin(s);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("coopEvent:spinCompleted",r.data)),r}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},s=await this.ctx.api.coopEvent.claimObjectReward(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("coopEvent:objectRewardClaimed",s.data)),s}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},s=await this.ctx.api.coopEvent.claimGrandPrize(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:grandPrizeClaimed",s.data)),s}async leaveGroup(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},s=await this.ctx.api.coopEvent.leaveGroup(t);return s.ok&&(this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:groupLeft",s.data)),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Iu="DealOffer",hs=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(Iu,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}_${k()}`},s=await this.ctx.api.dealOffer.dismissDeal(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:dealDismissed",s.data)),s}async executeNode(e,t,s){if(!e||!t)return n("client","SlotID and NodeID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r=s&&s.trim().length>0?s.trim():void 0,i={...this.ctx.buildAuthedBaseRequest(),SlotID:e,NodeID:t,RelatedEntityID:r??`deal_exec_${e}_${t}_${k()}`},c=await this.ctx.api.dealOffer.executeNode(i);return c.ok&&(c.data.Idempotent||this.ctx.data.user.applyResourceOperation(c.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:nodeExecuted",c.data)),c}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}_${k()}`},s=await this.ctx.api.dealOffer.recordShow(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:showRecorded",s.data)),s}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 s={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneID:t,RelatedEntityID:`deal_milestone_${e}_${t}_${k()}`},r=await this.ctx.api.dealOffer.claimMilestone(s);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 s=[...new Set(t.map(c=>c.trim()).filter(c=>c.length>0))],r={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneIDs:s,RelatedEntityID:`deal_milestone_batch_${e}_${k()}`},i=await this.ctx.api.dealOffer.claimMilestonesBatch(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:milestonesBatchClaimed",i.data)),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var ku="Referral",ms=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(ku,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 s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),ReferralCode:t,RelatedEntityID:`referral_activation_${s.userID}`},i=await this.ctx.api.referral.activateReferralCode(r);if(i.ok){let c=i.data;c.ReferralCode&&this.ctx.data.user.patchReferralSubscription(c.ReferralCode),this.ctx.data.user.applyResourceOperation(c.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:codeActivated",c);}return i}async claimInviteReward(e){let t=e.trim();if(!t)return n("client","InviteRewardID is required.");let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),InviteRewardID:t,RelatedEntityID:`referral_invite_${t}_${s.userID}`},i=await this.ctx.api.referral.claimInviteReward(r);if(i.ok){let c=i.data;c.RewardID&&this.ctx.data.user.patchReferralInviteRewardClaimed(c.RewardID),this.ctx.data.user.applyResourceOperation(c.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:inviteRewardClaimed",c);}return i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var fs=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 s=await this.ctx.api.social.getRecommendedFriends(t);return s.ok&&this.ctx.emitter.emit("social:recommendedFriendsLoaded",s.data),s}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},s=await this.ctx.api.social.sendFriendRequest(t);return s.ok&&(this.ctx.data.user.patchSocialAddOutgoingRequest(e),this.ctx.emitter.emit("social:friendRequestSent",s.data)),s}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},s=await this.ctx.api.social.acceptFriendRequest(t);return s.ok&&(this.ctx.data.user.patchSocialAcceptFriend(e),this.ctx.emitter.emit("social:friendRequestAccepted",s.data)),s}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},s=await this.ctx.api.social.declineFriendRequest(t);return s.ok&&(this.ctx.data.user.patchSocialRemoveIncomingRequest(e),this.ctx.emitter.emit("social:friendRequestDeclined",s.data)),s}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},s=await this.ctx.api.social.removeFriend(t);return s.ok&&(this.ctx.data.user.patchSocialRemoveFriend(e),this.ctx.emitter.emit("social:friendRemoved",s.data)),s}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 Mu="TimedBoost";function Au(a){return a.length>0&&!a.includes(".")&&!a.includes("$")}var gs=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(Mu,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(!Au(t))return n("client",'BoostID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),BoostID:t,RelatedEntityID:`timed_boost_activate_${t}_${k()}`},r=await this.ctx.api.timedBoost.activate(s);if(r.ok){let i=r.data;if(i.ActivatedBoost){let c=i.StackingPolicy??"Replace";this.ctx.data.user.patchActiveTimedBoost(i.ActivatedBoost,c);}this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedBoost:activated",i);}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 Qe={Private:"Private",Public:"Public",ReadOnly:"ReadOnly",Internal:"Internal"},Uu={Client:"Client",Server:"Server",System:"System"},Ou=zod.z.enum(["Client","Server","System"]),wu=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:l.nullish(),Version:zod.z.number().nullish(),LastWriter:Ou.nullish(),ExpiresAt:l.nullish()}).passthrough(),Rs=zod.z.record(zod.z.string(),wu),Rn=zod.z.object({Version:zod.z.number().nullish(),Private:Rs.nullish(),Public:Rs.nullish(),ReadOnly:Rs.nullish()}),Zr=zod.z.object({UserID:zod.z.string().nullish(),Version:zod.z.number().nullish(),Public:Rs.nullish()}),Jr=zod.z.object({ServerTimeUtc:l.nullish(),Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:l.nullish()}),Bu=zod.z.object({Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:l.nullish()}),yn=zod.z.object({ServerTimeUtc:l.nullish(),Results:zod.z.array(Bu).nullish()}),Cn=zod.z.object({ServerTimeUtc:l.nullish(),DeletedCount:zod.z.number().nullish()}),Sn=zod.z.object({Results:zod.z.array(Zr).nullish(),NotFoundUserIDs:zod.z.array(zod.z.string()).nullish()}),qu={String:"String",Int:"Int",Bool:"Bool",Json:"Json"},Eu=zod.z.enum(["String","Int","Bool","Json"]),Lu=zod.z.object({KeyID:zod.z.string(),Bucket:zod.z.string().nullish(),ValueType:Eu.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),ys=zod.z.object({Keys:zod.z.record(zod.z.string(),Lu).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(),Ge={GetUserCustomDataDefinitions:"GetUserCustomDataDefinitions",GetMyUserCustomData:"GetMyUserCustomData",GetPublicUserCustomDataOf:"GetPublicUserCustomDataOf",SetPrivateData:"SetPrivateData",SetPublicData:"SetPublicData",DeleteKey:"DeleteKey",BatchSet:"BatchSet",BatchDelete:"BatchDelete",BatchGetPublicUserCustomDataOf:"BatchGetPublicUserCustomDataOf"};var Gu="UserCustomData";function xn(a){return a.length>0&&!a.includes(".")&&!a.includes("$")}var Cs=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(Gu,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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.TargetUserID=t;let r=await this.ctx.api.userCustomData.getPublicUserCustomDataOf(s);return r.ok&&this.ctx.emitter.emit("userCustomData:publicDataLoaded",r.data),r}async setPrivateData(e,t){return this.setData(e,t,Qe.Private)}async setPublicData(e,t){return this.setData(e,t,Qe.Public)}async setData(e,t,s){let r=e.trim();if(!xn(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 i={...this.ctx.buildAuthedBaseRequest(),KeyID:r,Value:t},d=await(s===Qe.Private?this.ctx.api.userCustomData.setPrivateData(i):this.ctx.api.userCustomData.setPublicData(i));if(d.ok){let v=d.data;this.ctx.data.user.patchUserCustomDataKey(s,v.KeyID,t,v.Version??0,v.ExpiresAt),this.ctx.emitter.emit(s===Qe.Private?"userCustomData:privateDataSet":"userCustomData:publicDataSet",v);}return d}async deleteKey(e,t){let s=e.trim();if(!xn(s))return n("client",'KeyID is required and must not contain "." or "$".');if(t!==Qe.Private&&t!==Qe.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:s,Bucket:t},i=await this.ctx.api.userCustomData.deleteKey(r);return i.ok&&(this.ctx.data.user.removeUserCustomDataKey(t,s),this.ctx.emitter.emit("userCustomData:keyDeleted",void 0)),i}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},s=await this.ctx.api.userCustomData.batchSet(t);if(s.ok){for(let r of s.data.Results??[]){let i=r.Bucket??Qe.Private,c=e.find(d=>d.Bucket===i&&d.KeyID===r.KeyID);c&&this.ctx.data.user.patchUserCustomDataKey(i,r.KeyID,c.Value,r.Version??0,r.ExpiresAt);}this.ctx.emitter.emit("userCustomData:batchSet",s.data);}return s}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},s=await this.ctx.api.userCustomData.batchDelete(t);if(s.ok){for(let r of e)this.ctx.data.user.removeUserCustomDataKey(r.Bucket,r.KeyID.trim());this.ctx.emitter.emit("userCustomData:batchDeleted",s.data);}return s}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 s=await this.ctx.api.userCustomData.batchGetPublicUserCustomDataOf(t);return s.ok&&this.ctx.emitter.emit("userCustomData:batchPublicDataLoaded",s.data),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Nu="TitleCustomDataDefinitions",Dn=50;function ju(a){return a.length>0&&!a.includes(".")&&!a.includes("$")}function Yr(a){if(a.ExpiresAt==null)return false;let e=Date.parse(a.ExpiresAt);return !Number.isNaN(e)&&e<=Date.now()}function Fu(a){let e={};for(let[t,s]of Object.entries(a))Yr(s)||(e[t]=s);return e}var Ss=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(Nu,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 s=await this.ctx.api.titleCustomData.getPublicTitleData(t);return s.ok&&this.absorb(s.data),s}async getPublicTitleDataKeys(e){let t=e.map(i=>i.trim()).filter(i=>i.length>0);if(!t.length)return n("client","At least one KeyID is required.");if(t.some(i=>!ju(i)))return n("client",'KeyID must not contain "." or "$".');if(t.length>Dn)return n("client",`At most ${Dn} keys per call \u2014 request them in chunks.`);let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.KeyIDs=t;let r=await this.ctx.api.titleCustomData.getPublicTitleDataKeys(s);return r.ok&&this.ctx.emitter.emit("titleCustomData:publicDataLoaded",r.data),r}getValue(e){let t=this.runtimeCache[e];if(t?.Value!=null&&!Yr(t))return t.Value;let s=this.staticCache[e];if(s?.Value!=null&&!Yr(s))return s.Value}get runtimeVersion(){return this.lastRuntimeVersion}staticCache={};absorb(e){e.Static&&(this.staticCache=e.Static),e.NotModified?(this.runtimeCache=Fu(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 xs=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 Vu=15,_u="GameLoop",Wu="BoardDefinition",Ds=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(_u,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 s=await this.ctx.api.gameLoop.getBoardDefinition(t,e);return s.ok&&(this.ctx.data.config.patchSection(Wu,s.data),this.ctx.emitter.emit("gameLoop:boardDefinitionLoaded",s.data)),s}async getBoardDefinitionForLevel(e,t=false){if(e<=0)return n("client","stageLevel must be > 0.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.StageLevel=e;let r=await this.ctx.api.gameLoop.getBoardDefinitionForLevel(s,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 s={...this.ctx.buildAuthedBaseRequest(),RollMultiplier:e,RelatedEntityID:`roll_${t.userID}_${k()}`},r=await this.ctx.api.gameLoop.boardLoopRoll(s);if(r.ok){let i=r.data,c=dn(new Date,Vu);this.ctx.data.user.patchBoardState(d=>{d.Position=i.NewPosition,d.CyclesCompleted=(d.CyclesCompleted??0)+(i.CyclesCompletedDelta??0),d.LastRollAtUtc=new Date().toISOString(),i.ActionRequired&&i.ActionData?d.Pending={Type:i.ActionRequired,TargetUserID:i.ActionData.TargetUserID,TargetPublicData:i.ActionData.PublicData,TargetBuildingStates:i.ActionData.TargetBuildingStates??void 0,TargetHasShield:i.ActionData.TargetHasShield??void 0,RollMultiplier:i.UsedMultiplier??1,ExpiresAtUtc:c}:i.SpecialModeOffer&&(d.Pending={Type:"SPECIAL",RollMultiplier:i.UsedMultiplier??1,ExpiresAtUtc:c,Special:{ModeID:i.SpecialModeOffer.ModeID??void 0,Choices:i.SpecialModeOffer.Choices??void 0}});}),i.Operation&&this.ctx.data.user.applyResourceOperation(i.Operation,this.itemDefs),i.ActionRequired==="RAID"&&await this.getUserBoardState(),this.ctx.emitter.emit("gameLoop:boardRolled",i);}return r}async boardLoopAttack(e=-1){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`attack_${t.userID}_${k()}`},r=await this.ctx.api.gameLoop.boardLoopAttack(s);if(r.ok){let i=r.data;this.ctx.data.user.clearBoardPending(),i.IsBotTarget&&i.Operation?this.ctx.data.user.applyResourceOperation(i.Operation,this.itemDefs):!i.IsBotTarget&&i.DualResult?.FromResult&&this.ctx.data.user.applyResourceOperation(i.DualResult.FromResult,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardAttacked",i);}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 s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),DigIndex:e,RelatedEntityID:t??`raid_${s.userID}_${k()}`},i=await this.ctx.api.gameLoop.boardLoopRaid(r);if(i.ok){let c=i.data;c.Status==="CONTINUE"?this.ctx.data.user.patchBoardPendingRaidLayout(c.RaidLayout,c.OpenedIndex??-1):(this.ctx.data.user.clearBoardPending(),this.applyRaidResources(c)),this.ctx.emitter.emit("gameLoop:boardRaided",c);}else await this.getUserBoardState();return i}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 s={...this.ctx.buildAuthedBaseRequest(),DigIndices:e,RelatedEntityID:`raidfast_${t.userID}_${k()}`},r=await this.ctx.api.gameLoop.boardLoopRaidFast(s);if(r.ok){let i=r.data;i.Status!=="CONTINUE"&&(this.ctx.data.user.clearBoardPending(),this.applyRaidResources(i)),this.ctx.emitter.emit("gameLoop:boardRaidedFast",i);}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 s={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`build_${t.userID}_${e}_${k()}`},r=await this.ctx.api.gameLoop.boardLoopBuild(s);if(r.ok){let i=r.data;i.StageComplete?this.ctx.data.user.patchBoardState(c=>{c.StageLevel=(c.StageLevel??1)+1,c.Position=0,c.Pending=null,c.BuildingStates=null;}):this.ctx.data.user.patchBoardBuilding(i.BuiltIndex,c=>{i.NewLevel!=null&&(c.Level=i.NewLevel),c.IsDamaged=false,i.MaxLevelRewardClaimed&&(c.MaxLevelRewardClaimed=true);}),i.Operation&&this.ctx.data.user.applyResourceOperation(i.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardBuilt",i);}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 s={...this.ctx.buildAuthedBaseRequest(),ChoiceID:e,RelatedEntityID:`special_choose_${t.userID}_${k()}`},r=await this.ctx.api.gameLoop.boardSpecialChoose(s);if(r.ok){let i=r.data;i.Mode==="Instant"||i.Mode===0?this.ctx.data.user.clearBoardPending():this.ctx.data.user.patchBoardSpecialPending(d=>{d.ChoiceID=e,d.ChosenMode=i.Mode??"Timed",d.StartedAtUtc=i.StartedAtUtc??null,d.DurationSeconds=i.DurationSeconds??null,d.AdViewsUsed=0;}),i.Operation&&this.ctx.data.user.applyResourceOperation(i.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialChose",i);}return r}async boardSpecialApplyMultiplier(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:e??`special_ad_${t.userID}_${k()}`},r=await this.ctx.api.gameLoop.boardSpecialApplyMultiplier(s);if(r.ok){let i=r.data;this.ctx.data.user.patchBoardSpecialPending(c=>{c.AdViewsUsed=i.AdViewsUsed??0,c.AccumulatedMultiplier=i.AccumulatedMultiplier??0;}),this.ctx.emitter.emit("gameLoop:boardSpecialApplyMultiplier",i);}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}_${k()}`},s=await this.ctx.api.gameLoop.boardSpecialClaim(t);if(s.ok){let r=s.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 s}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 s=t.data.Group;s?.GroupID&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:s.GroupID,ActiveRoundIndex:s.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 s={...this.ctx.buildAuthedBaseRequest(),MilestoneID:e,GroupID:t},r=await this.ctx.api.gameLoop.claimCommunityChestMilestone(s);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},s=await this.ctx.api.gameLoop.claimCommunityChestGrandPrize(t);return s.ok&&(s.data.Resources&&this.ctx.data.user.applyResourceOperation(s.data.Resources,this.itemDefs),this.ctx.emitter.emit("gameLoop:communityChestGrandPrizeClaimed",s.data)),s}async leaveCommunityChest(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},s=await this.ctx.api.gameLoop.leaveCommunityChest(t);return s.ok&&(s.data.Success&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:void 0,ActiveRoundIndex:-1}),this.ctx.emitter.emit("gameLoop:communityChestLeft",s.data)),s}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 bs=class{constructor(e){this.ctx=e;}ctx;async execute(e,t,s,r){let i=e.trim();if(!i)return n("client","FunctionName is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let c={...this.ctx.buildAuthedBaseRequest(),FunctionName:i,FunctionParameter:t,RevisionSelection:s,SpecificRevision:r},d=await this.ctx.api.cloudCode.execute(c);return d.ok&&this.ctx.emitter.emit("cloudCode:executed",d.data),d}};var bn=zod.z.object({ServerTimeUtc:l,SourceType:ht,SourceID:zod.z.string(),TargetType:ht,TargetID:zod.z.string(),SourceSpent:M,FeeAmount:M,RateApplied:B,TargetCredited:M}),vn=zod.z.object({ServerTimeUtc:l,SourceType:ht,SourceID:zod.z.string(),TargetType:ht,TargetID:zod.z.string(),SourceSpent:B,FeeAmount:B,RateApplied:B,TargetCredited:B}),vs={Convert:"Convert",CryptoConvert:"CryptoConvert"},Qu={Active:"Active",Hidden:"Hidden",Deprecated:"Deprecated",Maintenance:"Maintenance"},zn=zod.z.enum(["Active","Hidden","Deprecated","Maintenance"]),Hu={Automatic:"Automatic",Manual:"Manual"},Ku=zod.z.enum(["Automatic","Manual"]),$u=zod.z.object({ValueInUSD:B.nullish(),ValueInUSDUpdatedAt:l.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(),Zu=zod.z.object({Rate:zod.z.number().nullish(),Max:zod.z.number().nullish(),Period:zod.z.number().nullish()}).passthrough(),Ju=zod.z.object({IsTradable:zod.z.boolean().nullish(),IsPurchasable:zod.z.boolean().nullish(),IsRefundable:zod.z.boolean().nullish()}).passthrough(),Yu=zod.z.object({TargetCurrencyType:ht.nullish(),TargetCurrencyID:zod.z.string(),Rate:B.nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish(),DailyLimit:zod.z.number().nullish()}).passthrough(),Tn=zod.z.object({Enabled:zod.z.boolean().nullish(),RateMode:Ku.nullish(),FeePercent:B.nullish(),Targets:zod.z.array(Yu).nullish()}).passthrough(),Pn=zod.z.object({CreatedAt:l.nullish(),UpdatedAt:l.nullish()}).passthrough(),Xu=zod.z.object({CurrencyID:zod.z.string(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Economy:$u.nullish(),Recharge:Zu.nullish(),Conversion:Tn.nullish(),Permissions:Ju.nullish(),Audit:Pn.nullish(),Status:zn.nullish()}).passthrough(),ec=zod.z.object({NetworkID:zod.z.string(),ContractAddress:zod.z.string().nullish(),Decimals:zod.z.number().nullish(),MinDeposit:B.nullish(),MinWithdraw:B.nullish(),WithdrawFee:B.nullish(),DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish()}).passthrough(),tc=zod.z.object({DailyWithdrawUsd:B.nullish(),MonthlyWithdrawUsd:B.nullish(),KycRequiredAboveUsd:B.nullish()}).passthrough(),sc=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),SpendableInGame:zod.z.boolean().nullish(),ConvertibleToVirtual:zod.z.boolean().nullish()}).passthrough(),Xr=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:B.nullish(),ValueInUSDUpdatedAt:l.nullish(),DeveloperDepositSharePercent:B.nullish(),CommunityMarketingDepositSharePercent:B.nullish(),WithdrawalBurnPercent:B.nullish(),Networks:zod.z.array(ec).nullish(),Limits:tc.nullish(),Permissions:sc.nullish(),Conversion:Tn.nullish(),Audit:Pn.nullish(),Status:zn.nullish()}).passthrough(),zs=zod.z.object({VirtualCurrencies:zod.z.record(zod.z.string(),Xu).nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Xr).nullish()}).passthrough();var In=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),ItemInstanceID:zod.z.string().nullish(),EquippedAt:l.nullish()}),ei=zod.z.object({CharacterID:zod.z.string(),Level:zod.z.number().nullish(),Experience:M.nullish(),Power:zod.z.number().nullish(),StatLevels:zod.z.record(zod.z.string(),zod.z.number()).nullish(),Equipment:zod.z.record(zod.z.string(),In).nullish(),UpdatedAt:l.nullish()}).passthrough(),rc=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),ic=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:l,ExpiresAt:l.nullish(),EquippedSlot:rc.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(a=>a),et=zod.z.object({ChangedInstances:zod.z.record(zod.z.string(),ic).nullish(),RemovedInstanceIDs:zod.z.array(zod.z.string()).nullish()}),kn=zod.z.object({Characters:zod.z.record(zod.z.string(),ei).nullish()}),ti=zod.z.object({ServerTimeUtc:l,CharacterID:zod.z.string(),StatID:zod.z.string(),StatLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:x.nullish()}),si=zod.z.object({ServerTimeUtc:l,CharacterID:zod.z.string(),NewLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:x.nullish()}),Mn=zod.z.object({ServerTimeUtc:l,CharacterID:zod.z.string(),Equipment:zod.z.record(zod.z.string(),In).nullish(),ReplacedInstanceIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:et.nullish()}),An=zod.z.object({ServerTimeUtc:l,CharacterID:zod.z.string(),ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:et.nullish()}),nc=zod.z.object({ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish()}),Un=zod.z.object({ServerTimeUtc:l,Characters:zod.z.record(zod.z.string(),nc).nullish(),Inventory:et.nullish()}),ri=zod.z.object({ServerTimeUtc:l,CharacterID:zod.z.string(),Power:zod.z.number().nullish(),Resources:x.nullish()}),On=Et(ri),wn=Et(si),Bn=Et(ti),qn=zod.z.object({RequiredStatID:zod.z.string(),RequiredLevel:zod.z.number()}).passthrough(),En=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:K.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(qn).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Ln=zod.z.object({Level:zod.z.number().nullish(),UpgradeCost:K.nullish(),GlobalStatMultiplier:zod.z.number().nullish(),StatMaxLevelMultiplier:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),oc=zod.z.object({SlotID:zod.z.string(),MinCharacterLevel:zod.z.number().nullish(),StatRequirements:zod.z.array(qn).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(),Gn=zod.z.object({Slots:zod.z.record(zod.z.string(),oc).nullish()}).passthrough(),ac=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(),lc=zod.z.object({ClassID:zod.z.string().nullish(),RarityID:zod.z.string().nullish(),Tags:zod.z.array(zod.z.string()).nullish()}).passthrough(),uc=zod.z.object({UnlockedByDefault:zod.z.boolean().nullish(),Cost:K.nullish()}).passthrough(),cc=zod.z.object({Stats:ne.nullish(),Levels:ne.nullish(),Equipment:ne.nullish()}).passthrough(),pc=zod.z.object({CharacterID:zod.z.string(),Identity:ac.nullish(),Classification:lc.nullish(),Unlock:uc.nullish(),Presets:cc.nullish(),Equipment:Gn.nullish(),Stats:zod.z.record(zod.z.string(),En).nullish(),Levels:zod.z.record(zod.z.string(),Ln).nullish()}).passthrough(),dc=zod.z.object({Stats:zod.z.record(zod.z.string(),En).nullish()}).passthrough(),hc=zod.z.object({Levels:zod.z.record(zod.z.string(),Ln).nullish()}).passthrough(),mc=zod.z.object({Equipment:Gn.nullish()}).passthrough(),fc=zod.z.object({Stats:zod.z.record(zod.z.string(),dc).nullish(),Levels:zod.z.record(zod.z.string(),hc).nullish(),Equipment:zod.z.record(zod.z.string(),mc).nullish()}).passthrough(),Ts=zod.z.object({Definitions:zod.z.record(zod.z.string(),pc).nullish(),Presets:fc.nullish()}).passthrough(),Te={GetCharacterDefinitions:"GetCharacterDefinitions",GetUserCharacters:"GetUserCharacters",UnlockCharacter:"UnlockCharacter",UpgradeStatLevel:"UpgradeStatLevel",UpgradeCharacterLevel:"UpgradeCharacterLevel",EquipItems:"EquipItems",UnequipItems:"UnequipItems",UnequipAllCharacters:"UnequipAllCharacters",UnlockCharactersBatch:"UnlockCharactersBatch",UpgradeCharacterLevelsBatch:"UpgradeCharacterLevelsBatch",UpgradeStatLevelsBatch:"UpgradeStatLevelsBatch"};var gc={EVM:"EVM",Solana:"Solana"},Rc=zod.z.enum(["EVM","Solana"]),yc={AutoLinkedFromTransaction:"AutoLinkedFromTransaction",SignatureVerified:"SignatureVerified",ManuallyLinked:"ManuallyLinked"},Cc=zod.z.enum(["AutoLinkedFromTransaction","SignatureVerified","ManuallyLinked"]),Sc={Token:"Token",Nft:"Nft"},Nn=zod.z.enum(["Token","Nft"]),xc={NotRequested:"NotRequested",Pending:"Pending",Verified:"Verified",Rejected:"Rejected",Expired:"Expired"},Dc=zod.z.enum(["NotRequested","Pending","Verified","Rejected","Expired"]),bc={None:"None",Tier1:"Tier1",Tier2:"Tier2",Tier3:"Tier3"},vc=zod.z.enum(["None","Tier1","Tier2","Tier3"]),zc={Pending:"Pending",Completed:"Completed",Failed:"Failed",Expired:"Expired",Abandoned:"Abandoned"},ii=zod.z.enum(["Pending","Completed","Failed","Expired","Abandoned"]),jn={GameTopUp:"game_topup",CommunityReward:"community_reward"};function Ps(a){let e=a?.trim();return e||jn.GameTopUp}var Tc={UsersCryptoWallet:"UsersCryptoWallet",Game:"Game"},Fn=zod.z.enum(["UsersCryptoWallet","Game"]),Pc=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(),Vn=zod.z.object({Ios:zod.z.boolean().nullish(),Android:zod.z.boolean().nullish(),Web:zod.z.boolean().nullish()}).passthrough(),Ic=zod.z.object({NetworkID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Type:Rc.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:Vn.nullish(),NftCollections:zod.z.array(Pc).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),kc=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),NftDepositsEnabled:zod.z.boolean().nullish(),NftWithdrawalsEnabled:zod.z.boolean().nullish(),PlatformOverrides:Vn.nullish()}).passthrough(),Mc=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 Ac=zod.z.enum(["OnChain","Combined"]),Uc=zod.z.object({Enabled:zod.z.boolean().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),MinBalance:B.nullish(),BalanceSource:Ac.nullish(),DenyMessage:zod.z.string().nullish()}).passthrough(),Oc=zod.z.object({Enabled:zod.z.boolean().nullish(),TokenGates:zod.z.array(Uc).nullish(),WalletConnectProjectId:zod.z.string().nullish()}).passthrough(),ni=zod.z.object({SystemState:kc.nullish(),Networks:zod.z.record(zod.z.string(),Ic).nullish(),AccountSafety:Mc.nullish(),WalletLogin:Oc.nullish()}).passthrough(),wc=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),LinkedAt:l.nullish(),LastUsedAt:l.nullish(),LinkType:Cc.nullish(),IsSignatureVerified:zod.z.boolean().nullish()}).passthrough(),_n=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Type:Nn.nullish(),NetworkID:zod.z.string().nullish(),AssetID:zod.z.string().nullish(),Amount:B.nullish(),CreatedAt:l.nullish(),ExpiresAt:l.nullish()}).passthrough(),Bc=zod.z.object({Status:Dc.nullish(),Tier:vc.nullish(),VerifiedAt:l.nullish(),ExpiresAt:l.nullish(),RejectedAt:l.nullish(),ProviderReference:zod.z.string().nullish(),RejectionReason:zod.z.string().nullish()}).passthrough(),qc=zod.z.object({CurrencyID:zod.z.string().nullish(),Deposits:zod.z.number().nullish(),DepositsVolumeNative:B.nullish(),DepositsVolumeUsd:B.nullish(),Withdrawals:zod.z.number().nullish(),WithdrawalsVolumeNative:B.nullish(),WithdrawalsVolumeUsd:B.nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),FirstDepositAt:l.nullish(),LastDepositAt:l.nullish(),FirstWithdrawalAt:l.nullish(),LastWithdrawalAt:l.nullish()}).passthrough(),Ec=zod.z.object({TotalDeposits:zod.z.number().nullish(),TotalWithdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),TotalDepositsVolumeUsd:B.nullish(),TotalWithdrawalsVolumeUsd:B.nullish(),PerCurrency:zod.z.record(zod.z.string(),qc).nullish()}).passthrough(),Lc=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:l.nullish(),LastDepositAt:l.nullish(),FirstWithdrawalAt:l.nullish(),LastWithdrawalAt:l.nullish()}).passthrough(),Gc=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(),Lc).nullish()}).passthrough(),Nc=zod.z.object({Tokens:Ec.nullish(),Nfts:Gc.nullish()}).passthrough(),jc=zod.z.object({CurrencyID:zod.z.string().nullish(),Balance:B.nullish(),MinBalance:B.nullish()}).passthrough(),Fc=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),CheckedAt:l.nullish(),LoggedInAt:l.nullish(),GatePassed:zod.z.boolean().nullish(),GatedBalances:zod.z.array(jc).nullish()}).passthrough(),Vc=zod.z.object({Version:zod.z.number().nullish(),Stats:Nc.nullish(),LinkedWallets:zod.z.record(zod.z.string(),wc).nullish(),LastWalletLogin:Fc.nullish(),PendingWithdrawals:zod.z.array(_n).nullish(),Kyc:Bc.nullish(),FirstActivityAt:l.nullish(),LastActivityAt:l.nullish(),IsFlagged:zod.z.boolean().nullish(),FlagReason:zod.z.string().nullish()}).passthrough(),_c=zod.z.object({CurrencyID:zod.z.string(),AmountDelta:B,FrozenDelta:B,UpdatedAt:l}).passthrough(),Is=zod.z.object({CryptoBalances:zod.z.record(zod.z.string(),_c).nullish(),PendingAdded:_n.nullish(),PendingRemovedIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),Wc=zod.z.object({Amount:B,Frozen:B,CreatedAt:l.nullish(),UpdatedAt:l.nullish()}).passthrough().transform(a=>a),Qc=zod.z.object({ID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CreatedAt:l.nullish(),UpdatedAt:l.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:Fn.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:B.nullish(),Status:ii.nullish(),SignatureData:zod.z.string().nullish(),CompletedAt:l.nullish(),ExpiresAt:l.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:B.nullish(),NetPayoutAmount:B.nullish()}).passthrough(),Hc=zod.z.object({ID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CreatedAt:l.nullish(),UpdatedAt:l.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:Fn.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:B.nullish(),Status:ii.nullish(),SignatureData:zod.z.string().nullish(),CompletedAt:l.nullish(),ExpiresAt:l.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(),Wn=zod.z.object({To:zod.z.string().nullish(),Amount:zod.z.union([zod.z.string(),zod.z.number()]).nullish()}).passthrough(),oi=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(Wn).nullish(),Signature:zod.z.string().nullish()}).passthrough(),ai=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(Wn).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(),Qn=zod.z.object({Blockchain:ni.nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Xr).nullish()}).passthrough(),Hn=zod.z.object({State:Vc.nullish(),CryptoBalances:zod.z.record(zod.z.string(),Wc).nullish()}).passthrough(),Kn=zod.z.object({ServerTimeUtc:l.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:B.nullish(),AmountUsd:B.nullish(),StateDelta:Is.nullish()}).passthrough(),$n=zod.z.object({ServerTimeUtc:l.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:x.nullish(),Inventory:et.nullish()}).passthrough(),Zn=zod.z.object({ServerTimeUtc:l.nullish(),TitleTransactionID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:B.nullish(),NetAmountNative:B.nullish(),BurnAmountNative:B.nullish(),AmountUsd:B.nullish(),ExpiresAt:l.nullish(),EvmSignature:oi.nullish(),SolanaSignature:ai.nullish(),StateDelta:Is.nullish()}).passthrough(),Jn=zod.z.object({ServerTimeUtc:l.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:l.nullish(),Resources:x.nullish(),EvmSignature:oi.nullish(),SolanaSignature:ai.nullish(),StateDelta:Is.nullish(),Inventory:et.nullish()}).passthrough(),Yn=zod.z.object({TokenTransactions:zod.z.array(Qc).nullish(),NFTTransactions:zod.z.array(Hc).nullish()}).passthrough(),li=zod.z.object({ServerTimeUtc:l.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:B.nullish(),AmountUsd:B.nullish(),Target:zod.z.string().nullish()}).passthrough(),Xn=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Kind:Nn.nullish(),EvmSignature:oi.nullish(),SolanaSignature:ai.nullish()}).passthrough(),eo=zod.z.object({TitleTransactionID:zod.z.string().nullish(),OnChainTxHash:zod.z.string().nullish(),Status:ii.nullish(),StateDelta:Is.nullish()}).passthrough(),Pe={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",DepositToken:"DepositToken",DepositNFT:"DepositNFT",RequestTokenWithdrawal:"RequestTokenWithdrawal",RequestNFTWithdrawal:"RequestNFTWithdrawal",GetTransactionHistory:"GetTransactionHistory",RetryWithdrawal:"RetryWithdrawal",ConfirmWithdrawal:"ConfirmWithdrawal",DonateToDeveloper:"DonateToDeveloper",DonateToUsersPool:"DonateToUsersPool"};var Kc="Blockchain",ks=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(Kc,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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.NetworkID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.depositToken(s);return r.ok&&r.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(r.data.CurrencyID,new Ft__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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.NetworkID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.depositNFT(s);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,s,r,i){if(!e)return n("client","CurrencyID is required.");if(!t)return n("client","NetworkID is required.");if(!s)return n("client","WalletAddress is required.");if(!r)return n("client","Amount is required.");let c=this.baseRequest();if(!c)return n("unauthorized","Not logged in.");c.CurrencyID=e,c.NetworkID=t,c.WalletAddress=s,c.Amount=r,c.Category=Ps(i);let d=await this.ctx.api.blockchain.requestTokenWithdrawal(c);return d.ok&&d.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(d.data.CurrencyID,new Ft__default.default(d.data.AmountNative??0).negated(),d.data.ServerTimeUtc??void 0),this.ctx.emitter.emit("blockchain:tokenWithdrawalRequested",d.data)),d}async requestNFTWithdrawal(e,t,s,r,i,c,d){if(!e)return n("client","ItemID is required.");if(!t)return n("client","NetworkID is required.");if(!s)return n("client","WalletAddress is required.");if(!r)return n("client","Amount is required.");let v=this.baseRequest();if(!v)return n("unauthorized","Not logged in.");v.ItemID=e,v.NetworkID=t,v.WalletAddress=s,v.Amount=r,v.Category=Ps(i),c!==void 0&&(v.Level=c),d&&(v.ItemInstanceID=d);let w=await this.ctx.api.blockchain.requestNFTWithdrawal(v);return w.ok&&(this.ctx.data.user.applyResourceOperation(w.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("blockchain:nftWithdrawalRequested",w.data)),w}async getTransactionHistory(e=50){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Amount=String(e);let s=await this.ctx.api.blockchain.getTransactionHistory(t);return s.ok&&this.ctx.emitter.emit("blockchain:transactionHistoryLoaded",s.data),s}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 s=await this.ctx.api.blockchain.retryWithdrawal(t);return s.ok&&this.ctx.emitter.emit("blockchain:withdrawalRetried",s.data),s}async confirmWithdrawal(e,t){if(!e)return n("client","TitleTransactionID is required.");if(!t)return n("client","On-chain TransactionHash is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.TitleTransactionID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.confirmWithdrawal(s);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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.NetworkID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.donateToDeveloper(s);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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.NetworkID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.donateToUsersPool(s);return r.ok&&this.ctx.emitter.emit("blockchain:donatedToUsersPool",r.data),r}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ce=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 $c={Head:"Head",Torso:"Torso",Legs:"Legs"},Ms=zod.z.enum(["Head","Torso","Legs"]),Zc={Open:"Open",InProgress:"InProgress",Cancelled:"Cancelled",Completed:"Completed"},ui=zod.z.enum(["Open","InProgress","Cancelled","Completed"]),ro=zod.z.object({AttackTarget:Ms,DefenseTarget:Ms});var Jc=zod.z.enum(["Hit","Critical","Block","Dodge"]),Yc=zod.z.object({RoundIndex:zod.z.number().nullish(),AttackerID:zod.z.string().nullish(),DefenderID:zod.z.string().nullish(),AttackZone:Ms.nullish(),DefenseZone:Ms.nullish(),HitType:Jc.nullish(),DamageDealt:zod.z.number().nullish(),DefenderHpRemaining:zod.z.number().nullish()}).passthrough(),Xc=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(),ep=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:l,ExpiresAt:l.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(a=>a),so=zod.z.object({UserID:zod.z.string().nullish(),SelectedCharacterID:zod.z.string().nullish(),SelectedCharacter:ei.nullish(),BattleStrategy:zod.z.array(ro).nullish(),UnstackableItems:zod.z.record(zod.z.string(),ep).nullish(),Stats:Xc.nullish()}).passthrough(),tp=zod.z.object({WinnerUserID:zod.z.string().nullish(),LoserUserID:zod.z.string().nullish(),Entry:ce.nullish(),NetReward:ce.nullish(),BattleLog:zod.z.array(Yc).nullish(),IsDraw:zod.z.boolean().nullish(),P1BattleProfile:so.nullish(),P2BattleProfile:so.nullish()}).passthrough(),io=zod.z.object({MatchID:zod.z.string(),TitleID:zod.z.string().nullish(),RuleID:zod.z.string().nullish(),CreatedAt:l.nullish(),CreatorID:zod.z.string().nullish(),CreatorCharacterID:zod.z.string().nullish(),CreatorStrategy:zod.z.array(ro).nullish(),TargetUserID:zod.z.string().nullish(),Entry:ce.nullish(),CreationCostPaid:ce.nullish(),RefundCreationCostOnCancel:zod.z.boolean().nullish(),JoinedByUserID:zod.z.string().nullish(),JoinedByCharacterID:zod.z.string().nullish(),JoinedAt:l.nullish(),Status:ui.nullish(),WinnerUserID:zod.z.string().nullish(),CompletedAt:l.nullish(),IsRewardDistributed:zod.z.boolean().nullish(),RewardDistributedAt:l.nullish()}).passthrough(),no=zod.z.object({Status:ui,MatchID:zod.z.string(),Entry:ce.nullish(),Resources:x.nullish()}),oo=zod.z.object({Match:io.nullish()}),ao=zod.z.object({MatchID:zod.z.string(),Status:ui,Resources:x.nullish()}),lo=zod.z.object({Battle:tp.nullish(),Resources:x.nullish(),ResourcesDual:st.nullish()}),ci=zod.z.object({Matches:zod.z.array(io).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 sp=zod.z.enum(["VirtualCurrency","Item","EventToken"]);var rp=zod.z.enum(["Constant","Stat","RankMultiplier","AllMight","GearFlat","GearPercent"]),ip=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(),np=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(),op=zod.z.object({Source:rp.nullish(),StatID:zod.z.string().nullish(),Value:zod.z.number().nullish(),OnePlus:zod.z.boolean().nullish()}).passthrough(),ap=zod.z.object({Coefficient:zod.z.number().nullish(),Factors:zod.z.array(op).nullish()}).passthrough(),it=zod.z.object({Terms:zod.z.array(ap).nullish()}).passthrough(),lp=zod.z.object({Health:it.nullish(),Damage:it.nullish(),Armor:it.nullish(),AttackSpeed:it.nullish(),CritChance:it.nullish(),CritDamage:it.nullish(),Dodge:it.nullish()}).passthrough(),uo=zod.z.object({StatMapping:ip.nullish(),Combat:np.nullish(),Formula:lp.nullish()}).passthrough(),up=zod.z.object({BurnRate:zod.z.number().nullish()}).passthrough(),pi=zod.z.object({Kind:sp.nullish(),CurrencyID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),TokenType:wt.nullish(),EntityID:zod.z.string().nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish()}).passthrough(),co=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(pi).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),po=zod.z.object({Cost:K.nullish(),RefundCostOnCancel:zod.z.boolean().nullish(),MaxOpenMatches:zod.z.number().nullish(),Limits:de.nullish(),AllowPrivateMatches:zod.z.boolean().nullish(),MaxMatchesPerOpponentPerDay:zod.z.number().nullish()}).passthrough(),cp=zod.z.object({RuleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Economy:up.nullish(),Entry:co.nullish(),Creation:po.nullish(),Settings:uo.nullish()}).passthrough(),pp=zod.z.object({Rules:zod.z.record(zod.z.string(),cp).nullish(),Defaults:uo.nullish(),EntryDefaults:co.nullish(),CreationDefaults:po.nullish()}).passthrough(),di=zod.z.object({InstantBattle:pp.nullish()}).passthrough(),ho=di;var dp={Listing:"Listing",Auction:"Auction",BuyOrder:"BuyOrder",DirectTrade:"DirectTrade"},hi=zod.z.enum(["Listing","Auction","BuyOrder","DirectTrade"]),hp={Active:"Active",Completed:"Completed",Cancelled:"Cancelled",Declined:"Declined",Expired:"Expired"},mi=zod.z.enum(["Active","Completed","Cancelled","Declined","Expired"]),mp={Burn:"Burn",Ledger:"Ledger"},fp=zod.z.enum(["Burn","Ledger"]),Us={Item:"Item",VirtualCurrency:"VirtualCurrency"},fi=zod.z.enum(["Item","VirtualCurrency"]),gp=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:M.nullish()}).passthrough(),Rp=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(pi).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),yp=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:M.nullish(),Sink:fp.nullish(),LedgerAccountID:zod.z.string().nullish(),PerCatalogOverrides:zod.z.record(zod.z.string(),gp).nullish(),ApplyToDirectTrades:zod.z.boolean().nullish()}).passthrough(),Cp=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(),Sp=zod.z.object({Enabled:zod.z.boolean().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),MaxActiveListings:zod.z.number().nullish(),CreateLimits:de.nullish(),BuyLimits:de.nullish(),ListingFee:K.nullish(),RefundListingFeeOnCancel:zod.z.boolean().nullish()}).passthrough(),xp=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:M.nullish(),BidLimits:de.nullish()}).passthrough(),Dp=zod.z.object({Enabled:zod.z.boolean().nullish(),MaxActiveOrders:zod.z.number().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),CreateLimits:de.nullish(),FillLimits:de.nullish()}).passthrough(),bp=zod.z.object({Enabled:zod.z.boolean().nullish(),OfferExpirationHours:zod.z.number().nullish(),MaxPendingOutgoing:zod.z.number().nullish(),AllowGifts:zod.z.boolean().nullish(),CreateLimits:de.nullish()}).passthrough(),vp=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),gi=zod.z.object({Enabled:zod.z.boolean().nullish(),Gate:Q.nullish(),Schedule:pe.nullish(),PricePolicy:Rp.nullish(),Commission:yp.nullish(),Tradability:Cp.nullish(),Listings:Sp.nullish(),Auctions:xp.nullish(),BuyOrders:Dp.nullish(),DirectTrades:bp.nullish(),Matching:vp.nullish()}).passthrough(),mo=zod.z.object({BidIndex:zod.z.number().nullish(),UserID:zod.z.string().nullish(),Amount:M.nullish(),Settled:zod.z.boolean().nullish(),SettledAt:l.nullish()}).passthrough(),zp=zod.z.object({BidAxisType:Ot.nullish(),BidCurrencyID:zod.z.string().nullish(),BidCatalogID:zod.z.string().nullish(),BidItemID:zod.z.string().nullish(),StartingBid:M.nullish(),CurrentBid:M.nullish(),CurrentBidderID:zod.z.string().nullish(),BidCount:zod.z.number().nullish(),ExtensionCount:zod.z.number().nullish(),PendingRefunds:zod.z.array(mo).nullish()}).passthrough(),As=zod.z.object({LastAt:l.nullish(),DailyCount:zod.z.number().nullish(),DailyResetUtc:l.nullish()}).passthrough(),Tp=zod.z.object({Create:As.nullish(),Buy:As.nullish(),Sell:As.nullish(),Bid:As.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:l,ExpiresAt:l.nullish(),EquippedSlot:Pp.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(a=>a),He=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:hi.nullish(),Status:mi.nullish(),CreatorUserID:zod.z.string().nullish(),CreatorPublicData:Ce.nullish(),TargetUserID:zod.z.string().nullish(),GoodsType:fi.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:M.nullish(),GoodsInstances:zod.z.array(Ip).nullish(),Price:ce.nullish(),Auction:zp.nullish(),CreatedAt:l.nullish(),ExpiresAt:l.nullish()}).passthrough(),kp=zod.z.object({GoodsType:fi.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),CountsByType:zod.z.record(hi,M).nullish(),ListingCount:M.nullish(),AuctionCount:M.nullish(),BuyOrderCount:M.nullish()}).passthrough(),fo=zod.z.object({Definitions:gi.nullish(),IsOpenNow:zod.z.boolean().nullish(),GatePassed:zod.z.boolean().nullish()}).passthrough(),Ri=zod.z.object({Offers:zod.z.array(He).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),go=zod.z.object({Groups:zod.z.array(kp).nullish()}).passthrough(),Ro=zod.z.object({Offer:He.nullish()}).passthrough(),Ue=zod.z.object({OfferID:zod.z.string().nullish(),Status:mi.nullish(),Settlement:st.nullish(),Resources:x.nullish(),CommissionTaken:ce.nullish()}).passthrough(),Tt=zod.z.object({OfferID:zod.z.string().nullish(),Offer:He.nullish(),Resources:x.nullish(),Matched:zod.z.boolean().nullish(),Settlement:Ue.nullish()}).passthrough(),yo=zod.z.object({OfferID:zod.z.string().nullish(),CurrentBid:M.nullish(),BidCount:zod.z.number().nullish(),ExpiresAt:l.nullish(),Resources:x.nullish()}).passthrough(),Co=zod.z.object({MyOffers:zod.z.array(He).nullish(),MyLeadingBids:zod.z.array(He).nullish(),MyBuyOrders:zod.z.array(He).nullish(),IncomingTrades:zod.z.array(He).nullish(),OutgoingTrades:zod.z.array(He).nullish(),Claimables:zod.z.array(He).nullish(),DrainedRefunds:zod.z.array(mo).nullish(),Limits:Tp.nullish()}).passthrough(),Mp=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:hi.nullish(),FinalStatus:mi.nullish(),SellerUserID:zod.z.string().nullish(),BuyerUserID:zod.z.string().nullish(),GoodsType:fi.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:M.nullish(),PricePaid:ce.nullish(),CommissionTaken:ce.nullish(),CompletedAt:l.nullish()}).passthrough(),So=zod.z.object({Entries:zod.z.array(Mp).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),ie={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 Ap="Marketplace",Os=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(Ap,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,s,r=20){if(!e)return n("client","ItemID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.ItemID=e,i.OfferTypeFilter=t,i.ContinuationToken=s,i.PageSize=r;let c=await this.ctx.api.marketplace.getOffersByItem(i);return c.ok&&this.ctx.emitter.emit("marketplace:offersByItemLoaded",c.data),c}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 s=await this.ctx.api.marketplace.getOffer(t);return s.ok&&this.ctx.emitter.emit("marketplace:offerLoaded",s.data),s}async getBuyOrders(e,t,s=20){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.ItemID=e,r.ContinuationToken=t,r.PageSize=s;let i=await this.ctx.api.marketplace.getBuyOrders(r);return i.ok&&this.ctx.emitter.emit("marketplace:buyOrdersLoaded",i.data),i}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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.ContinuationToken=e,s.PageSize=t;let r=await this.ctx.api.marketplace.getHistory(s);return r.ok&&this.ctx.emitter.emit("marketplace:historyLoaded",r.data),r}async createListing(e,t,s,r,i,c){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=s,d.PriceBundle=r,d.DurationHours=i,d.ItemInstanceIDs=c;let v=await this.ctx.api.marketplace.createListing(d);return this.applyCreateOfferResult(v,"marketplace:listingCreated"),v}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 s=await this.ctx.api.marketplace.buy(t);return s.ok&&(this.applyDualPartySettlement(s.data.Settlement),this.ctx.emitter.emit("marketplace:bought",s.data)),s}async marketBuy(e,t,s){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 i=this.applyGoodsSelector(r,s);if(i)return i;r.GoodsAmount=e,r.PriceBundle=t;let c=await this.ctx.api.marketplace.marketBuy(r);return c.ok&&(this.applyDualPartySettlement(c.data.Settlement),this.ctx.emitter.emit("marketplace:marketBought",c.data)),c}async marketSell(e,t,s){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 i=this.applyGoodsSelector(r,s);if(i)return i;r.GoodsAmount=e,r.PriceBundle=t;let c=await this.ctx.api.marketplace.marketSell(r);return c.ok&&(this.applyDualPartySettlement(c.data.Settlement),this.ctx.emitter.emit("marketplace:marketSold",c.data)),c}async createAuction(e,t,s,r,i,c,d={}){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");let v=this.baseRequest();if(!v)return n("unauthorized","Not logged in.");v.ItemID=e,v.CatalogID=t,v.GoodsAmount=s,v.BidAxisType=r,v.BidCurrencyID=d.bidCurrencyID,v.BidCatalogID=d.bidCatalogID,v.BidItemID=d.bidItemID,v.StartingBid=i,v.DurationHours=c,v.ItemInstanceIDs=d.itemInstanceIDs;let w=await this.ctx.api.marketplace.createAuction(v);return this.applyCreateOfferResult(w,"marketplace:auctionCreated"),w}async placeBid(e,t){if(!e)return n("client","OfferID is required.");if(!t||t<=0)return n("client","BidAmount must be positive.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.OfferID=e,s.BidAmount=t;let r=await this.ctx.api.marketplace.placeBid(s);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 s=await this.ctx.api.marketplace.claimAuction(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:auctionClaimed",s.data)),s}async createBuyOrder(e,t,s,r,i){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 c=this.baseRequest();if(!c)return n("unauthorized","Not logged in.");c.ItemID=e,c.CatalogID=t,c.GoodsAmount=s,c.PriceBundle=r,c.DurationHours=i;let d=await this.ctx.api.marketplace.createBuyOrder(c);return this.applyCreateOfferResult(d,"marketplace:buyOrderCreated"),d}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 s=await this.ctx.api.marketplace.fillBuyOrder(t);return s.ok&&(this.applyDualPartySettlement(s.data.Settlement),this.ctx.emitter.emit("marketplace:buyOrderFilled",s.data)),s}async createDirectTrade(e,t,s,r,i){if(!e)return n("client","TargetUserID is required.");if(!t)return n("client","CatalogID is required.");if(!s)return n("client","ItemID is required.");let c=this.baseRequest();if(!c)return n("unauthorized","Not logged in.");c.TargetUserID=e,c.CatalogID=t,c.ItemID=s,c.ItemInstanceIDs=r,c.RequestedBundle=i;let d=await this.ctx.api.marketplace.createDirectTrade(c);return this.applyCreateOfferResult(d,"marketplace:directTradeCreated"),d}async respondDirectTrade(e,t){if(!e)return n("client","OfferID is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.OfferID=e,s.Accept=t;let r=await this.ctx.api.marketplace.respondDirectTrade(s);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 s=await this.ctx.api.marketplace.claimBack(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:claimedBack",s.data)),s}async cancelOffer(e,t,s){if(!e)return n("client","OfferID is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.OfferID=e;let i=await t(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit(s,i.data)),i}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=Us.VirtualCurrency,e.GoodsCurrencyID=t.goodsCurrencyID,null):"itemID"in t&&t.itemID&&t.catalogID?(e.GoodsType=Us.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 s=this.ctx.data.config.itemDefinitions;e.FromUserID===t&&e.FromResult?this.ctx.data.user.applyResourceOperation(e.FromResult,s):e.ToUserID===t&&e.ToResult&&this.ctx.data.user.applyResourceOperation(e.ToResult,s);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var ws=class{constructor(e){this.ctx=e;}ctx;async createRoom(e,t={}){if(!e)return n("client","RoomName is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomName=e,s.Topology=t.topology,s.ChatMode=t.chatMode,s.MaxPlayers=t.maxPlayers,s.Visibility=t.visibility,s.JoinCode=t.joinCode;let r=await this.ctx.api.multiplayer.createRoom(s);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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomID=e,s.JoinCode=t;let r=await this.ctx.api.multiplayer.joinRoom(s);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 s=await this.ctx.api.multiplayer.leaveRoom(t);return s.ok&&this.ctx.emitter.emit("multiplayer:roomLeft",s.data),s}async listRooms(e=0,t=20){let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.Page=e,s.PageSize=t;let r=await this.ctx.api.multiplayer.listRooms(s);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 s=await this.ctx.api.multiplayer.getRoom(t);return s.ok&&this.ctx.emitter.emit("multiplayer:roomLoaded",s.data),s}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 s=await this.ctx.api.multiplayer.closeRoom(t);return s.ok&&this.ctx.emitter.emit("multiplayer:roomClosed",s.data),s}async poll(e,t){if(!e)return n("client","RoomID is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomID=e,s.LastSeq=t;let r=await this.ctx.api.multiplayer.poll(s);return r.ok&&this.ctx.emitter.emit("multiplayer:polled",r.data),r}async sendSignal(e,t,s,r){if(!e)return n("client","RoomID is required.");if(!t)return n("client","TargetUserID is required.");if(!s)return n("client","SignalKind is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.TargetUserID=t,i.SignalKind=s,i.Payload=r;let c=await this.ctx.api.multiplayer.sendSignal(i);return c.ok&&this.ctx.emitter.emit("multiplayer:signalSent",c.data),c}async sendChat(e,t){if(!e)return n("client","RoomID is required.");if(!t)return n("client","ChatText is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomID=e,s.ChatText=t;let r=await this.ctx.api.multiplayer.sendChat(s);return r.ok&&this.ctx.emitter.emit("multiplayer:chatSent",r.data),r}async setMemberState(e,t,s){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=s;let i=await this.ctx.api.multiplayer.setMemberState(r);return i.ok&&this.ctx.emitter.emit("multiplayer:memberStateSet",i.data),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var xo=zod.z.object({PlatformUserID:zod.z.string().nullish(),PlatformAuthToken:zod.z.string().nullish(),PlatformAuthTokenExpiration:l.nullish(),TitleUserID:zod.z.string(),TitleClientSessionTicket:zod.z.string(),TitleClientSessionTicketExpiration:l}),Se=zod.z.object({IsCompleted:zod.z.boolean().nullish(),ServerTime:l.nullish()}),Do=zod.z.object({Message:zod.z.string(),ExpiresAt:l}),Ie={LoginWithDeviceID:"LoginWithDeviceID",LoginWithTelegram:"LoginWithTelegram",LoginWithEmail:"LoginWithEmail",LoginWithGoogle:"LoginWithGoogle",LoginWithPlatformToken:"LoginWithPlatformToken",LoginWithSsoCode:"LoginWithSsoCode",RegisterWithEmail:"RegisterWithEmail",RequestWalletChallenge:"RequestWalletChallenge",LoginWithWallet:"LoginWithWallet",ForgotPassword:"ForgotPassword",ResetPassword:"ResetPassword"};function U(a,e,t,s){let i=`api/v2/${a&&a.length>0?a:"0"}/Client/${e}/${t}`;return s==null?i:`${i}/${s}`}var Bs=class{constructor(e){this.ctx=e;}ctx;endpoint(e){return U(this.ctx.settings.titleID,"Authentication",e)}login(e,t){return this.ctx.transport.post(this.endpoint(e),t,xo,{ticket:null})}loginWithDeviceID(e){return this.login(Ie.LoginWithDeviceID,e)}loginWithTelegram(e){return this.login(Ie.LoginWithTelegram,e)}loginWithEmail(e){return this.login(Ie.LoginWithEmail,e)}loginWithGoogle(e){return this.login(Ie.LoginWithGoogle,e)}loginWithPlatformToken(e){return this.login(Ie.LoginWithPlatformToken,e)}loginWithSsoCode(e){return this.login(Ie.LoginWithSsoCode,e)}registerWithEmail(e){return this.login(Ie.RegisterWithEmail,e)}requestWalletChallenge(e){return this.ctx.transport.post(this.endpoint(Ie.RequestWalletChallenge),e,Do,{ticket:null})}loginWithWallet(e){return this.login(Ie.LoginWithWallet,e)}forgotPassword(e){return this.ctx.transport.post(this.endpoint(Ie.ForgotPassword),e,Se,{ticket:null})}resetPassword(e){return this.ctx.transport.post(this.endpoint(Ie.ResetPassword),e,Se,{ticket:null})}};var yi=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()}).passthrough().transform(a=>a),bo=zod.z.object({StateEpoch:zod.z.string().nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough().transform(a=>a),vo=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(a=>a),zo=zod.z.object({}).passthrough().transform(a=>a),To=zod.z.object({}).passthrough().transform(a=>a),Po=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:l.nullish(),LastActiveAt:l.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(),Io=zod.z.object({Username:zod.z.string()}),Oe={GetClientState:"GetClientState",GetClientStateExcept:"GetClientStateExcept",GetStateVersions:"GetStateVersions",GetUserState:"GetUserState",GetInventory:"GetInventory",GetEventTokens:"GetEventTokens",GetUsageTime:"GetUsageTime",AddUsageTime:"AddUsageTime",DeleteUserAccount:"DeleteUserAccount",ChangeUsername:"ChangeUsername"};var qs=class{constructor(e){this.ctx=e;}ctx;endpoint(e,t){return U(this.ctx.settings.titleID,"User",e,t??"")}getClientState(e){return this.ctx.transport.post(this.endpoint(Oe.GetClientState,e.UserID),e,yi,{ticket:e.ClientSessionTicket})}getClientStateExcept(e){return this.ctx.transport.post(this.endpoint(Oe.GetClientStateExcept,e.UserID),e,yi,{ticket:e.ClientSessionTicket})}getStateVersions(e){return this.ctx.transport.post(this.endpoint(Oe.GetStateVersions,e.UserID),e,bo,{ticket:e.ClientSessionTicket})}getUserState(e){return this.ctx.transport.post(this.endpoint(Oe.GetUserState,e.UserID),e,vo,{ticket:e.ClientSessionTicket})}getInventory(e){return this.ctx.transport.post(this.endpoint(Oe.GetInventory,e.UserID),e,zo,{ticket:e.ClientSessionTicket})}getEventTokens(e){return this.ctx.transport.post(this.endpoint(Oe.GetEventTokens,e.UserID),e,To,{ticket:e.ClientSessionTicket})}getUsageTime(e){return this.ctx.transport.post(this.endpoint(Oe.GetUsageTime,e.UserID),e,Po,{ticket:e.ClientSessionTicket})}addUsageTime(e){return this.ctx.transport.post(this.endpoint(Oe.AddUsageTime,e.UserID),e,Se,{ticket:e.ClientSessionTicket,silent:true})}deleteUserAccount(e){return this.ctx.transport.post(this.endpoint(Oe.DeleteUserAccount,e.UserID),e,Se,{ticket:e.ClientSessionTicket})}changeUsername(e){return this.ctx.transport.post(this.endpoint(Oe.ChangeUsername,e.UserID),e,Io,{ticket:e.ClientSessionTicket})}};var Es=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Currency",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}convert(e){return this.send(vs.Convert,e,bn)}cryptoConvert(e){return this.send(vs.CryptoConvert,e,vn)}};var Up=zod.z.object({ItemInstanceID:zod.z.string(),Units:zod.z.number(),Level:zod.z.number()}),Ci=zod.z.object({ServerTimeUtc:l,ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Level:zod.z.number(),Resources:x.nullish(),FodderConsumed:zod.z.array(Up).nullish()}),ko=zod.z.array(re(Ci)),Ls={UpgradeLevel:"UpgradeLevel",UpgradeLevelsBatch:"UpgradeLevelsBatch"},Op={FlatCount:"FlatCount",Merge:"Merge",InvestmentRefund:"InvestmentRefund"},wp=zod.z.enum(["FlatCount","Merge","InvestmentRefund"]),Bp={ProtectLeveled:"ProtectLeveled",CheapestFirst:"CheapestFirst",ClientSelected:"ClientSelected"},qp=zod.z.enum(["ProtectLeveled","CheapestFirst","ClientSelected"]),Ep=zod.z.object({ContractAddress:zod.z.string().nullish(),TokenID:zod.z.string().nullish(),TokenStandard:zod.z.string().nullish()}).passthrough(),Lp=zod.z.object({Networks:zod.z.record(zod.z.string(),Ep).nullish(),MetadataUrl:zod.z.string().nullish()}).passthrough(),Gp=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(),Np=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(),jp=zod.z.object({ValuationMode:wp.nullish(),MergeRatio:zod.z.number().nullish(),Selection:qp.nullish()}).passthrough(),Fp=zod.z.object({MaxLevel:zod.z.number().nullish(),BaseCostResource:K.nullish(),CostScalingFactor:zod.z.number().nullish(),FlatScalingFactor:zod.z.number().nullish(),PercentScalingFactor:zod.z.number().nullish(),PowerScalingFactor:zod.z.number().nullish(),Fodder:jp.nullish()}).passthrough(),Vp=zod.z.object({RarityID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),AuthorID:zod.z.string().nullish()}).passthrough(),_p=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:Lp.nullish(),Stats:Gp.nullish(),Equipment:Np.nullish(),Upgrade:Fp.nullish(),Metadata:Vp.nullish(),ExpirationDurationSeconds:zod.z.number().nullish()}).passthrough(),Wp=zod.z.object({Items:zod.z.record(zod.z.string(),_p).nullish()}).passthrough(),Gs=zod.z.object({Catalogs:zod.z.record(zod.z.string(),Wp).nullish()}).passthrough();var Ns=class{constructor(e){this.ctx=e;}ctx;upgradeLevel(e){let t=U(this.ctx.settings.titleID,"Item",Ls.UpgradeLevel,e.UserID??"");return this.ctx.transport.post(t,e,Ci,{ticket:e.ClientSessionTicket})}upgradeLevelsBatch(e){let t=U(this.ctx.settings.titleID,"Item",Ls.UpgradeLevelsBatch,e.UserID??"");return this.ctx.transport.post(t,e,ko,{ticket:e.ClientSessionTicket})}};var Si=zod.z.object({ServerTimeUtc:l,OfferID:zod.z.string(),Count:zod.z.number(),Resources:x.nullish()}),Mo=zod.z.array(re(Si)),Qp=zod.z.object({OfferID:zod.z.string(),TotalPurchases:zod.z.number(),DailyPurchases:zod.z.number(),DailyResetUtc:l,LastPurchasedAt:l}),Ao=zod.z.object({Purchases:zod.z.record(zod.z.string(),Qp).nullish()}).passthrough().transform(a=>a),Hp=zod.z.object({StartUtc:l.nullish(),EndUtc:l.nullish(),RequiredFlags:zod.z.array(zod.z.string()).nullish()}).passthrough(),Kp=zod.z.object({StoreID:zod.z.string(),Type:zod.z.string().nullish(),Name:zod.z.string().nullish(),Description:zod.z.string().nullish(),Rules:Hp.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),$p=zod.z.object({StartUtc:l.nullish(),EndUtc:l.nullish(),Gate:Q.nullish(),Limits:de.nullish()}).passthrough(),Zp=zod.z.object({OfferID:zod.z.string(),StoreIDs:zod.z.array(zod.z.string()).nullish(),Name:zod.z.string().nullish(),Cost:K.nullish(),Rewards:G.nullish(),Rules:$p.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),js=zod.z.object({Stores:zod.z.record(zod.z.string(),Kp).nullish(),StoreOffers:zod.z.record(zod.z.string(),Zp).nullish()}).passthrough(),Rt={Purchase:"Purchase",GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",PurchaseBatch:"PurchaseBatch"};var Fs=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Store",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}purchase(e){return this.send(Rt.Purchase,e,Si)}purchaseBatch(e){return this.send(Rt.PurchaseBatch,e,Mo)}getDefinitions(e){return this.send(Rt.GetDefinitions,e,js)}getUserState(e){return this.send(Rt.GetUserState,e,Ao)}};var Jp=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),Uo=zod.z.object({Reward:G.nullish(),Weight:zod.z.number().nullish(),AmountRange:Jp.nullish()}).passthrough(),yt=zod.z.object({SlotID:zod.z.string().nullish(),MinRolls:zod.z.number().nullish(),MaxRolls:zod.z.number().nullish(),Pool:zod.z.array(Uo).nullish()}).passthrough(),Ct=zod.z.object({RuleID:zod.z.string().nullish(),Threshold:zod.z.number().nullish(),Pool:zod.z.array(Uo).nullish()}).passthrough(),Yp=zod.z.object({RewardSlots:zod.z.array(yt).nullish()}).passthrough(),Xp=zod.z.object({PityRules:zod.z.array(Ct).nullish()}).passthrough(),Vs=zod.z.object({SlotPresets:zod.z.record(zod.z.string(),Yp).nullish(),PityPresets:zod.z.record(zod.z.string(),Xp).nullish()}).passthrough();var ed=zod.z.object({RuleID:zod.z.string(),BoxIndex:zod.z.number().nullish()}),Oo=zod.z.object({ServerTimeUtc:l,LootboxID:zod.z.string(),OpenedCount:zod.z.number().nullish(),SelectedOptionID:zod.z.number().nullish(),Resources:x.nullish(),Inventory:et.nullish(),Results:zod.z.array(x).nullish(),TriggeredPity:zod.z.array(ed).nullish()}),td=zod.z.object({PriceOptionID:zod.z.number().nullish(),RequiredResources:K.nullish()}).passthrough(),sd=zod.z.object({RewardSlots:ne.nullish(),PityRules:ne.nullish()}).passthrough(),rd=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),MaxDrops:M.nullish()}).passthrough(),id=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(),td).nullish(),RewardSlots:zod.z.array(yt).nullish(),PityRules:zod.z.array(Ct).nullish(),Presets:sd.nullish(),RewardMultiplier:Bt.nullish(),SupplyLimits:zod.z.array(rd).nullish()}).passthrough(),xi=zod.z.object({Definitions:zod.z.record(zod.z.string(),id).nullish(),RewardPools:Vs.nullish()}).passthrough(),wo=zod.z.object({LootboxDefinitions:xi.nullish()}),_s={GetDefinitions:"GetDefinitions",Open:"Open"};var Ws=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Lootbox",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(_s.GetDefinitions,e,wo)}open(e){return this.send(_s.Open,e,Oo)}};var nd=zod.z.object({}).passthrough().transform(a=>a),od=zod.z.object({}).passthrough().transform(a=>a),ad=zod.z.object({}).passthrough().transform(a=>a),ld=zod.z.object({}).passthrough().transform(a=>a),ud=zod.z.object({}).passthrough().transform(a=>a),Bo=zod.z.object({ServerTimeUtc:l,CalendarID:zod.z.string(),DayNumber:zod.z.number().nullish(),DailyState:nd,Resources:x.nullish()}),qo=zod.z.object({ServerTimeUtc:l,AccrualID:zod.z.string(),AccruedSeconds:M.nullish(),AppliedRatePerSecond:zod.z.number().nullish(),IdleState:od,Resources:x.nullish()}),Eo=zod.z.object({ServerTimeUtc:l,ComebackID:zod.z.string(),ClaimedTierIndex:zod.z.number().nullish(),ComebackState:ad,Resources:x.nullish()}),Lo=zod.z.object({ServerTimeUtc:l,ClaimID:zod.z.string(),ClaimState:ld,Resources:x.nullish()}),Go=zod.z.object({Enabled:zod.z.boolean(),Multiplier:zod.z.number().nullish(),Progress:M.nullish(),Source:zod.z.string().nullish(),SourceKey:zod.z.string().nullish()}),cd=zod.z.object({RewardMode:zod.z.string().nullish(),RewardStackLowerTiers:zod.z.boolean().nullish()}).passthrough(),pd=zod.z.object({DayNumber:zod.z.number().nullish(),Rewards:G.nullish(),IsMilestone:zod.z.boolean().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),dd=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(pd).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(),hd=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),md=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(hd).nullish()}).passthrough(),fd=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(),gd=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:md.nullish(),Rewards:G.nullish(),MaxAccumulationSeconds:zod.z.number().nullish(),MinClaimSeconds:zod.z.number().nullish(),Requirements:fd.nullish(),FirstClaimMode:zod.z.string().nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Rd=zod.z.object({MinAbsenceSeconds:zod.z.number().nullish(),Rewards:G.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),yd=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(Rd).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(),Cd=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(),Sd=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:G.nullish(),Limits:de.nullish(),PremiumLimitOverrides:zod.z.array(Cd).nullish(),Gate:Q.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Di=zod.z.object({TierRewards:cd.nullish(),MilestoneRewardMultiplier:Bt.nullish(),DailyCalendars:zod.z.record(zod.z.string(),dd).nullish(),IdleAccruals:zod.z.record(zod.z.string(),gd).nullish(),Comebacks:zod.z.record(zod.z.string(),yd).nullish(),Claims:zod.z.record(zod.z.string(),Sd).nullish()}).passthrough(),No=zod.z.object({RewardDefinitions:Di.nullish()}),jo=zod.z.object({Rewards:ud.nullish()}),$e={GetRewardDefinitions:"GetRewardDefinitions",GetUserRewardsState:"GetUserRewardsState",ClaimDailyReward:"ClaimDailyReward",CollectIdleAccrual:"CollectIdleAccrual",ClaimComebackReward:"ClaimComebackReward",ClaimReward:"ClaimReward",ClaimRewardsBatch:"ClaimRewardsBatch",GetMilestoneRewardMultiplier:"GetMilestoneRewardMultiplier"};var Qs=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Reward",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getRewardDefinitions(e){return this.send($e.GetRewardDefinitions,e,No)}getUserRewardsState(e){return this.send($e.GetUserRewardsState,e,jo)}getMilestoneRewardMultiplier(e){return this.send($e.GetMilestoneRewardMultiplier,e,Go)}claimDailyReward(e){return this.send($e.ClaimDailyReward,e,Bo)}collectIdleAccrual(e){return this.send($e.CollectIdleAccrual,e,qo)}claimComebackReward(e){return this.send($e.ClaimComebackReward,e,Eo)}claimReward(e){return this.send($e.ClaimReward,e,Lo)}};var Hs=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Quest",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getQuestDefinitions(e){return this.send(Le.GetQuestDefinitions,e,Lt)}getUserQuestState(e){return this.send(Le.GetUserQuestState,e,Xi)}refreshQuestCycles(e){return this.send(Le.RefreshQuestCycles,e,Se)}claimQuestReward(e){return this.send(Le.ClaimQuestReward,e,Nr)}claimQuestRewardsBatch(e){return this.send(Le.ClaimQuestRewardsBatch,e,sn)}claimMilestoneReward(e){return this.send(Le.ClaimMilestoneReward,e,jr)}claimMilestoneRewardsBatch(e){return this.send(Le.ClaimMilestoneRewardsBatch,e,rn)}claimGroupCompletionReward(e){return this.send(Le.ClaimGroupCompletionReward,e,en)}addQuestProgress(e){return this.send(Le.AddQuestProgress,e,tn)}};var Fo=zod.z.object({}).passthrough().transform(a=>a);var xd=zod.z.object({Order:zod.z.number().nullish(),Type:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),BonusMultiplier:zod.z.number().nullish()}).passthrough(),Dd=zod.z.object({Schedule:zod.z.array(xd).nullish(),RepeatCycle:zod.z.boolean().nullish(),MaxCycles:zod.z.number().nullish()}).passthrough(),bd=zod.z.object({IsActive:zod.z.boolean().nullish(),CurrentPhaseEndUtc:l.nullish(),NextBonusStartUtc:l.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentPhaseIndex:zod.z.number().nullish(),ActiveBonusMultiplier:zod.z.number().nullish()}).passthrough(),vd=zod.z.object({Milestones:ne.nullish()}).passthrough(),bi=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:rt.nullish(),TokenSources:zod.z.array(_e).nullish(),ClaimMode:zod.z.string().nullish(),Milestones:zod.z.record(zod.z.string(),ye).nullish(),Presets:vd.nullish(),BonusWindow:Dd.nullish()}).passthrough(),zd=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Content:bi.nullish(),ClaimGraceHours:zod.z.number().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Td=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:bi.nullish(),Events:zod.z.array(zd).nullish(),Gate:Q.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Pd=zod.z.object({MaxConcurrentEvents:zod.z.number().nullish()}).passthrough(),Id=zod.z.object({Milestones:zod.z.record(zod.z.string(),Xe).nullish()}).passthrough(),Ks=zod.z.object({Definitions:zod.z.record(zod.z.string(),Td).nullish(),Settings:Pd.nullish(),Presets:Id.nullish()}).passthrough(),kd=zod.z.object({Type:vt,TimedEventID:zod.z.string(),CurrentChainedEventID:zod.z.string().nullish(),Content:bi.nullish(),Progress:Fo.nullish(),ComputedStartUtc:l.nullish(),ComputedEndUtc:l.nullish(),CanEarn:zod.z.boolean().nullish(),CanClaim:zod.z.boolean().nullish(),NextMilestone:ye.nullish(),BonusWindow:bd.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentEventOrder:zod.z.number().nullish(),TotalEventsInChain:zod.z.number().nullish()}).passthrough(),Vo=zod.z.object({ActiveEvents:zod.z.array(kd).nullish()}).passthrough(),_o=zod.z.object({Tokens:zod.z.record(zod.z.string(),Fo).nullish()}),vi=zod.z.object({Type:vt.nullish(),LteID:zod.z.string().nullish(),Resources:x.nullish()}),zi=zod.z.object({Type:vt.nullish(),LteID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Rewards:x.nullish()}),Md=zod.z.object({Type:vt.nullish(),LteID:zod.z.string().nullish(),Resources:x.nullish()}),Ti=zod.z.array(re(zi)),Wo=zod.z.array(re(vi)),Qo=zod.z.array(re(Md)),we={GetActiveEvents:"GetActiveEvents",GrantTokens:"GrantTokens",SpendTokens:"SpendTokens",ClaimMilestone:"ClaimMilestone",GetDefinitions:"GetDefinitions",GetUserLteState:"GetUserLteState",ClaimMilestonesBatch:"ClaimMilestonesBatch",ClaimAllMilestones:"ClaimAllMilestones",SpendTokensBatch:"SpendTokensBatch",GrantTokensBatch:"GrantTokensBatch"};var $s=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"TimedEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getActiveEvents(e){return this.send(we.GetActiveEvents,e,Vo)}getDefinitions(e){return this.send(we.GetDefinitions,e,Ks)}getUserLteState(e){return this.send(we.GetUserLteState,e,_o)}grantTokens(e){return this.send(we.GrantTokens,e,x)}spendTokens(e){return this.send(we.SpendTokens,e,vi)}claimMilestone(e){return this.send(we.ClaimMilestone,e,zi)}claimMilestonesBatch(e){return this.send(we.ClaimMilestonesBatch,e,Ti)}claimAllMilestones(e){return this.send(we.ClaimAllMilestones,e,Ti)}spendTokensBatch(e){return this.send(we.SpendTokensBatch,e,Wo)}grantTokensBatch(e){return this.send(we.GrantTokensBatch,e,Qo)}};var Ad=zod.z.object({UserID:zod.z.string(),Score:M.nullish(),Rank:zod.z.number().nullish(),LastScoreUpdateUtc:l.nullish(),IpHash:zod.z.string().nullish(),PublicProfile:Ce.nullish(),SeasonTierAtCycleEnd:zod.z.number().nullish()}).passthrough(),Pt=zod.z.object({LeaderboardID:zod.z.string(),CycleVersion:zod.z.number().nullish(),TotalParticipants:M.nullish(),CycleEndUtc:l.nullish(),TopUsers:zod.z.array(Ad).nullish(),BracketID:zod.z.string().nullish()}),Ud=zod.z.object({CycleKey:zod.z.string().nullish(),CycleEndUtc:l.nullish(),ClaimDeadlineUtc:l.nullish(),MilestoneTokensEarned:M.nullish(),ClaimableMilestoneIDs:zod.z.array(zod.z.string()).nullish(),CycleIndex:zod.z.number().nullish(),ChainedEventID:zod.z.string().nullish()}).passthrough(),Zs=zod.z.object({LeaderboardID:zod.z.string(),CurrentScore:M.nullish(),LastKnownRank:zod.z.number().nullish(),HasUnclaimedReward:zod.z.boolean().nullish(),ScoreEarnedThisCycle:M.nullish(),MilestoneTokensEarned:M.nullish(),NextMilestone:ye.nullish(),HasUnclaimedMilestone:zod.z.boolean().nullish(),ClaimableGraceCycles:zod.z.array(Ud).nullish()}),Js=zod.z.object({LeaderboardID:zod.z.string(),NewScore:M,CycleVersion:zod.z.number()}),Ys=zod.z.object({ServerTimeUtc:l,LeaderboardID:zod.z.string(),Rank:zod.z.number().nullish(),Resources:x.nullish()}),Xs=zod.z.object({ServerTimeUtc:l,LeaderboardID:zod.z.string(),MilestoneID:zod.z.string(),Resources:x.nullish()}),Ho=zod.z.array(re(Pt)),Ko=zod.z.array(re(Zs)),$o=zod.z.array(re(Ys)),Zo=zod.z.array(re(Xs)),Jo=zod.z.array(re(Js)),Od=zod.z.object({LeaderboardID:zod.z.string(),CycleReward:re(Ys).nullish(),Milestones:zod.z.array(re(Xs)).nullish()}),Yo=zod.z.array(Od),wd=zod.z.object({LeaderboardID:zod.z.string(),Leaderboard:re(Pt).nullish(),Progress:re(Zs).nullish()}),Xo=zod.z.array(wd),Bd=zod.z.string(),ea=zod.z.object({Rank:zod.z.string().nullish(),Rewards:G.nullish(),SeasonTierRewards:Lr.nullish()}).passthrough(),qd=zod.z.object({RankRewards:zod.z.array(ea).nullish()}).passthrough(),Ed=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Ld=zod.z.object({Milestones:ne.nullish(),RankRewards:ne.nullish()}).passthrough(),Gd=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:Bd.nullish(),Schedule:pe.nullish(),ChainEvents:zod.z.array(Ed).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(ea).nullish(),Milestones:zod.z.record(zod.z.string(),ye).nullish(),Presets:Ld.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneClaimGraceHours:zod.z.number().nullish(),ScoreSources:zod.z.array(_e).nullish()}).passthrough(),Nd=zod.z.object({Milestones:zod.z.record(zod.z.string(),Xe).nullish(),RankRewards:zod.z.record(zod.z.string(),qd).nullish()}).passthrough(),er=zod.z.object({Definitions:zod.z.record(zod.z.string(),Gd).nullish(),Presets:Nd.nullish()}).passthrough(),fe={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 tr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Leaderboard",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(fe.GetDefinitions,e,er)}getLeaderboard(e){return this.send(fe.GetLeaderboard,e,Pt)}getMyProgress(e){return this.send(fe.GetMyProgress,e,Zs)}submitScore(e){return this.send(fe.SubmitScore,e,Js)}submitScoreFromSource(e){return this.send(fe.SubmitScoreFromSource,e,Js)}claimCycleReward(e){return this.send(fe.ClaimCycleReward,e,Ys)}claimMilestone(e){return this.send(fe.ClaimMilestone,e,Xs)}getFriendsLeaderboard(e){return this.send(fe.GetFriendsLeaderboard,e,Pt)}getLeaderboardsBatch(e){return this.send(fe.GetLeaderboardsBatch,e,Ho)}getProgressBatch(e){return this.send(fe.GetProgressBatch,e,Ko)}claimCycleRewardsBatch(e){return this.send(fe.ClaimCycleRewardsBatch,e,$o)}claimMilestonesBatch(e){return this.send(fe.ClaimMilestonesBatch,e,Zo)}submitScoresBatch(e){return this.send(fe.SubmitScoresBatch,e,Jo)}claimAllRewardsBatch(e){return this.send(fe.ClaimAllRewardsBatch,e,Yo)}getOverviewBatch(e){return this.send(fe.GetOverviewBatch,e,Xo)}};var Pi=zod.z.object({}).passthrough().transform(a=>a),ta=zod.z.object({SeasonChainID:zod.z.string(),CycleIndex:zod.z.number().nullish(),Season:zod.z.lazy(()=>na).nullish(),ComputedStartUtc:l.nullish(),ComputedEndUtc:l.nullish(),SecondsRemaining:M.nullish(),UserState:Pi.nullish(),NextTier:zod.z.lazy(()=>ia).nullish()}).passthrough(),sa=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),AmountGranted:M.nullish(),NewStatusTokens:M.nullish(),OldTier:zod.z.number().nullish(),NewTier:zod.z.number(),TierUp:zod.z.boolean().nullish()}),ra=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),TierNumber:zod.z.number(),Resources:x.nullish()});var ia=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:M.nullish(),TierReachedReward:G.nullish()}).passthrough(),na=zod.z.object({SeasonID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:M.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(ia).nullish(),LinkedCollectionID:zod.z.string().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough();var jd=zod.z.object({SeasonChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:pe.nullish(),Seasons:zod.z.array(na).nullish(),GrantTokensAccessMode:zod.z.string().nullish(),Gate:Q.nullish()}).passthrough(),sr=zod.z.object({Chains:zod.z.record(zod.z.string(),jd).nullish()}).passthrough(),nt={GetDefinitions:"GetDefinitions",GetActiveSeason:"GetActiveSeason",GetUserState:"GetUserState",GrantStatusTokens:"GrantStatusTokens",ClaimTierReward:"ClaimTierReward"};var rr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Season",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(nt.GetDefinitions,e,sr)}getActiveSeason(e){return this.send(nt.GetActiveSeason,e,ta)}getUserState(e){return this.send(nt.GetUserState,e,Pi)}grantStatusTokens(e){return this.send(nt.GrantStatusTokens,e,sa)}claimTierReward(e){return this.send(nt.ClaimTierReward,e,ra)}};var Fd={Apple:"Apple",Google:"Google"},oa=zod.z.object({}).passthrough().transform(a=>a),Vd=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(),_d=zod.z.object({OptionID:zod.z.string().nullish(),Name:zod.z.string().nullish(),RequiredResources:K.nullish()}).passthrough(),Wd=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(),_d).nullish(),AppleProductID:zod.z.string().nullish(),GoogleProductID:zod.z.string().nullish(),Benefits:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Ii=zod.z.object({Definitions:zod.z.record(zod.z.string(),Wd).nullish()}).passthrough(),aa=zod.z.object({Premium:Ii.nullish()}),la=zod.z.object({ServerTimeUtc:l.nullish(),Premium:oa.nullish()}),ir=zod.z.object({ServerTimeUtc:l.nullish(),Premium:oa.nullish(),Subscription:Vd.nullish(),Resources:x.nullish()}),ot={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateTrial:"ActivateTrial",PurchaseWithResources:"PurchaseWithResources",PurchaseRealMoney:"PurchaseRealMoney"};var nr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Premium",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(ot.GetDefinitions,e,aa)}getUserState(e){return this.send(ot.GetUserState,e,la)}activateTrial(e){return this.send(ot.ActivateTrial,e,ir)}purchaseItemOrCurrency(e){return this.send(ot.PurchaseWithResources,e,ir)}purchaseRealMoney(e){return this.send(ot.PurchaseRealMoney,e,ir)}};var or=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Character",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getCharacterDefinitions(e){return this.send(Te.GetCharacterDefinitions,e,Ts)}getUserCharacters(e){return this.send(Te.GetUserCharacters,e,kn)}unlockCharacter(e){return this.send(Te.UnlockCharacter,e,ri)}upgradeStatLevel(e){return this.send(Te.UpgradeStatLevel,e,ti)}upgradeCharacterLevel(e){return this.send(Te.UpgradeCharacterLevel,e,si)}equipItems(e){return this.send(Te.EquipItems,e,Mn)}unequipItems(e){return this.send(Te.UnequipItems,e,An)}unequipAllCharacters(e){return this.send(Te.UnequipAllCharacters,e,Un)}unlockCharactersBatch(e){return this.send(Te.UnlockCharactersBatch,e,On)}upgradeCharacterLevelsBatch(e){return this.send(Te.UpgradeCharacterLevelsBatch,e,wn)}upgradeStatLevelsBatch(e){return this.send(Te.UpgradeStatLevelsBatch,e,Bn)}};var ar=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Match",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}createMatch(e){return this.send(je.CreateMatch,e,no)}updateMatch(e){return this.send(je.UpdateMatch,e,oo)}cancelMatch(e){return this.send(je.CancelMatch,e,ao)}instantBattle(e){return this.send(je.InstantBattle,e,lo)}saveStrategy(e){return this.send(je.SaveStrategy,e,Se)}getMyMatches(e){return this.send(je.GetMyMatches,e,ci)}getAvailableMatches(e){return this.send(je.GetAvailableMatches,e,ci)}getDefinitions(e){return this.send(je.GetDefinitions,e,ho)}};var Qd={TradeUpRarity:"TradeUpRarity",TradeUpCollection:"TradeUpCollection"},ua=zod.z.enum(["TradeUpRarity","TradeUpCollection"]),Hd=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:Er.nullish()}),ca=zod.z.object({ServerTimeUtc:l,Type:ua.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:x.nullish(),Results:zod.z.array(Hd).nullish()}),Kd=zod.z.object({OptionID:zod.z.string().nullish(),RequiredResources:K.nullish()}).passthrough(),$d=zod.z.object({CraftID:zod.z.string().nullish(),Type:ua.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(),Kd).nullish()}).passthrough(),ki=zod.z.object({Definitions:zod.z.record(zod.z.string(),$d).nullish()}).passthrough(),pa=zod.z.object({ServerTimeUtc:l.nullish(),CraftDefinitions:ki.nullish()}),lr={GetDefinitions:"GetDefinitions",Craft:"Craft"};var ur=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Craft",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(lr.GetDefinitions,e,pa)}craft(e){return this.send(lr.Craft,e,ca)}};var Zd={Pending:"Pending",Accepted:"Accepted",Declined:"Declined",Cancelled:"Cancelled",Expired:"Expired"},Jd=zod.z.enum(["Pending","Accepted","Declined","Cancelled","Expired"]),da=zod.z.object({}).passthrough().transform(a=>a),cr=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()}),ha=zod.z.object({GrantedCollectibles:zod.z.array(cr).nullish(),DuplicateCollectibles:zod.z.array(cr).nullish(),CollectionCurrencyEarned:M.nullish(),NewCollectionCurrencyBalance:M.nullish(),NewlyCompletedSetIDs:zod.z.array(zod.z.string()).nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:x.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),ma=zod.z.object({GrantedCollectibles:zod.z.array(cr).nullish(),DuplicateCollectibles:zod.z.array(cr).nullish(),CollectionCurrencyEarned:M.nullish(),NewCollectionCurrencyBalance:M.nullish(),Resources:x.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),fa=zod.z.object({GrantedCollectibleID:zod.z.string().nullish(),NewlyCompletedSetID:zod.z.string().nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:x.nullish()}),Mi=zod.z.object({SetID:zod.z.string(),Resources:x.nullish()}),ga=zod.z.array(re(Mi)),Ra=zod.z.object({Resources:x.nullish()}),Yd=zod.z.object({OfferID:zod.z.string(),TitleID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderPublicData:Ce.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:Jd.nullish(),CreatedAtUtc:l.nullish(),ExpiresAtUtc:l.nullish(),RespondedAtUtc:l.nullish(),DeclineReason:zod.z.string().nullish(),IsSpecialTradeEvent:zod.z.boolean().nullish(),SpecialTradeEventID:zod.z.string().nullish()}).passthrough(),ya=zod.z.object({OfferID:zod.z.string(),ExpiresAtUtc:l.nullish(),Resources:x.nullish()}),Ca=zod.z.object({OfferID:zod.z.string(),Resources:x.nullish()}),Sa=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:x.nullish()}),Ai=zod.z.object({Offers:zod.z.array(Yd).nullish()}),Xd=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(),eh=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(Xd).nullish(),SetCompletionReward:G.nullish()}).passthrough(),th=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(eh).nullish(),GrandPrize:G.nullish()}).passthrough(),Da=zod.z.object({BonusRewardSlots:ne.nullish(),PityRules:ne.nullish()}).passthrough(),sh=zod.z.object({PackTypeID:zod.z.string().nullish(),Cost:K.nullish(),BonusRewardSlots:zod.z.array(yt).nullish(),PityRules:zod.z.array(Ct).nullish(),Presets:Da.nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CollectibleCount: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(),rh=zod.z.object({Rarity:zod.z.number().nullish(),CollectionCurrencyGranted:zod.z.number().nullish()}).passthrough(),ih=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(),MinCollectibleCount:zod.z.number().nullish(),MaxCollectibleCount:zod.z.number().nullish(),GuaranteedMinRarity:zod.z.number().nullish(),BonusRewardSlots:zod.z.array(yt).nullish(),PityRules:zod.z.array(Ct).nullish(),Presets:Da.nullish(),Tier:zod.z.number().nullish()}).passthrough(),nh=zod.z.object({SpecialTradeEventID:zod.z.string().nullish(),StartUtc:l.nullish(),EndUtc:l.nullish(),AllowedSpecialCollectibleIDs:zod.z.array(zod.z.string()).nullish(),SpecialTradeEventDailyTradeLimit:zod.z.number().nullish()}).passthrough(),pr=zod.z.object({Collections:zod.z.record(zod.z.string(),th).nullish(),PackTypes:zod.z.record(zod.z.string(),sh).nullish(),CollectionChests:zod.z.array(ih).nullish(),DuplicateConversions:zod.z.array(rh).nullish(),DailyTradeLimit:zod.z.number().nullish(),CollectibleJokerCatalogID:zod.z.string().nullish(),CollectibleJokerItemID:zod.z.string().nullish(),SpecialTradeEvents:zod.z.array(nh).nullish(),RewardPools:Vs.nullish()}).passthrough(),xe={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 dr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Collection",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(xe.GetDefinitions,e,pr)}getUserState(e){return this.send(xe.GetUserState,e,da)}openPack(e){return this.send(xe.OpenPack,e,ha)}openCollectionChest(e){return this.send(xe.OpenCollectionChest,e,ma)}useCollectibleJoker(e){return this.send(xe.UseCollectibleJoker,e,fa)}claimSetReward(e){return this.send(xe.ClaimSetReward,e,Mi)}claimSetRewardsBatch(e){return this.send(xe.ClaimSetRewardsBatch,e,ga)}claimGrandPrize(e){return this.send(xe.ClaimGrandPrize,e,Ra)}sendTradeOffer(e){return this.send(xe.SendTradeOffer,e,ya)}cancelTradeOffer(e){return this.send(xe.CancelTradeOffer,e,Ca)}acceptTradeOffer(e){return this.send(xe.AcceptTradeOffer,e,Sa)}declineTradeOffer(e){return this.send(xe.DeclineTradeOffer,e,xa)}getMyTradeOffers(e){return this.send(xe.GetMyTradeOffers,e,Ai)}getIncomingTradeOffers(e){return this.send(xe.GetIncomingTradeOffers,e,Ai)}};var oh=zod.z.object({}).passthrough().transform(a=>a),ah={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},lh={Active:"Active",Left:"Left",Replaced:"Replaced"},uh=zod.z.object({ObjectIndex:zod.z.number().nullish(),ObjectCompletionRewardClaimed:zod.z.boolean().nullish()}).passthrough(),ch=zod.z.object({UserID:zod.z.string().nullish(),PublicData:Ce.nullish(),BuildObjectsProgress:uh.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:l.nullish(),LeftAtUtc:l.nullish()}).passthrough(),ph=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(),dh=zod.z.object({Objects:zod.z.array(ph).nullish()}).passthrough(),ba=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(ch).nullish(),BuildObjectsState:dh.nullish(),Status:zod.z.string().nullish(),CreatedAtUtc:l.nullish(),ExpiresAtUtc:l.nullish(),Version:zod.z.number().nullish()}).passthrough(),va=zod.z.object({CoopChainID:zod.z.string()}).passthrough(),hh=zod.z.string(),za=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(),mh=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:G.nullish()}).passthrough(),fh=zod.z.object({Objects:zod.z.array(mh).nullish(),SpinCost:K.nullish(),SpinnerTable:zod.z.array(za).nullish()}).passthrough(),gh=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:hh.nullish(),PartnerCount:zod.z.number().nullish(),MatchmakingTimeoutMinutes:zod.z.number().nullish(),MemberGracePeriodMinutes:zod.z.number().nullish(),BuildObjects:fh.nullish(),GrandPrize:G.nullish()}).passthrough(),Rh=zod.z.object({CoopChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:pe.nullish(),Events:zod.z.array(gh).nullish(),Gate:Q.nullish()}).passthrough(),Ta=zod.z.object({ServerTimeUtc:l.nullish(),UserState:oh.nullish(),ActiveGroup:ba.nullish()}),Ui=zod.z.object({ServerTimeUtc:l.nullish(),Group:ba.nullish(),SecondsRemaining:M.nullish()}),Pa=zod.z.object({ServerTimeUtc:l.nullish(),GroupID:zod.z.string().nullish(),Resources:x.nullish(),ObjectIndex:zod.z.number().nullish(),Sector:za.nullish(),ProgressDelta:zod.z.number().nullish(),NewProgress:M.nullish(),MaxProgress:M.nullish(),ObjectCompleted:zod.z.boolean().nullish(),AllObjectsCompleted:zod.z.boolean().nullish()}),Oi=zod.z.object({ServerTimeUtc:l.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),Resources:x.nullish()}),Ia=zod.z.object({ServerTimeUtc:l.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),hr=zod.z.object({Chains:zod.z.record(zod.z.string(),Rh).nullish()}).passthrough(),Ne={GetDefinitions:"GetDefinitions",GetActiveEvent:"GetActiveEvent",GetUserState:"GetUserState",GetGroupState:"GetGroupState",JoinOrCreateGroup:"JoinOrCreateGroup",Spin:"Spin",ClaimObjectReward:"ClaimObjectReward",ClaimGrandPrize:"ClaimGrandPrize",LeaveGroup:"LeaveGroup"};var mr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"CoopEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ne.GetDefinitions,e,hr)}getActiveEvent(e){return this.send(Ne.GetActiveEvent,e,va)}getUserState(e){return this.send(Ne.GetUserState,e,Ta)}getGroupState(e){return this.send(Ne.GetGroupState,e,Ui)}joinOrCreateGroup(e){return this.send(Ne.JoinOrCreateGroup,e,Ui)}spin(e){return this.send(Ne.Spin,e,Pa)}claimObjectReward(e){return this.send(Ne.ClaimObjectReward,e,Oi)}claimGrandPrize(e){return this.send(Ne.ClaimGrandPrize,e,Oi)}leaveGroup(e){return this.send(Ne.LeaveGroup,e,Ia)}};var yh={Active:"Active",Exhausted:"Exhausted",Expired:"Expired",Dismissed:"Dismissed"},Ch={Locked:"Locked",Available:"Available",InProgress:"InProgress",Completed:"Completed",Hidden:"Hidden"},Sh=zod.z.object({NodeID:zod.z.string().nullish(),Status:zod.z.string().nullish(),ExecutionCount:zod.z.number().nullish(),UnlockedAtUtc:l.nullish(),CompletedAtUtc:l.nullish(),LastExecutedAtUtc:l.nullish(),NextAvailableAtUtc:l.nullish(),LastExecutionRefID:zod.z.string().nullish()}).passthrough(),xh=zod.z.object({TrackID:zod.z.string().nullish(),CurrentValue:zod.z.number().nullish(),LastUpdatedUtc:l.nullish()}).passthrough(),ka=zod.z.object({OfferID:zod.z.string().nullish(),InstanceKey:zod.z.string().nullish(),SourceOfferVersion:zod.z.number().nullish(),Status:zod.z.string().nullish(),ActivatedAtUtc:l.nullish(),ExhaustedAtUtc:l.nullish(),ExpiredAtUtc:l.nullish(),DismissedAtUtc:l.nullish(),ShowCount:zod.z.number().nullish(),LastShownAtUtc:l.nullish(),Nodes:zod.z.record(zod.z.string(),Sh).nullish(),Tracks:zod.z.record(zod.z.string(),xh).nullish(),SelectedChoiceNodeID:zod.z.string().nullish()}).passthrough(),Dh=zod.z.object({SlotID:zod.z.string().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),ActiveOfferID:zod.z.string().nullish(),ActiveOfferStartedAtUtc:l.nullish(),ActiveOfferExpiresAtUtc:l.nullish(),ActiveOffer:ka.nullish(),NextCycleStartsAtUtc:l.nullish(),LastUpdatedUtc:l.nullish(),DismissSkipAvailableAtUtc:l.nullish(),LastDismissedAtUtc:l.nullish()}).passthrough(),bh=zod.z.object({TotalExecutions:zod.z.number().nullish(),DailyExecutions:zod.z.number().nullish(),DailyResetUtc:l.nullish()}).passthrough(),vh=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:l.nullish(),LastActivatedAtUtc:l.nullish(),LastExhaustedAtUtc:l.nullish(),NodeCounts:zod.z.record(zod.z.string(),bh).nullish()}).passthrough(),zh=zod.z.object({Slots:zod.z.record(zod.z.string(),Dh).nullish(),OfferHistory:zod.z.record(zod.z.string(),vh).nullish(),LastUpdatedUtc:l.nullish()}).passthrough();var Th=zod.z.object({Order:zod.z.number().nullish(),OfferID:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),DelayBeforeActivationSec:zod.z.number().nullish()}).passthrough(),Ph=zod.z.object({SlotID:zod.z.string().nullish(),Enabled:zod.z.boolean().nullish(),SortOrder:zod.z.number().nullish(),Queue:zod.z.array(Th).nullish(),Schedule:pe.nullish(),Gate:Q.nullish(),AllowDismissSkip:zod.z.boolean().nullish(),DismissSkipDelaySec:zod.z.number().nullish()}).passthrough(),Ih=zod.z.object({StoreOfferID:zod.z.string().nullish(),BillingProductID:zod.z.string().nullish(),DirectCost:K.nullish(),UseExternalRewards:zod.z.boolean().nullish()}).passthrough(),kh=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(),Mh=zod.z.object({Purchase:Ih.nullish(),RewardedVideo:kh.nullish()}).passthrough(),Ah=zod.z.object({TrackID:zod.z.string().nullish(),Operator:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),Uh=zod.z.object({Milestones:ne.nullish()}).passthrough(),Oh=zod.z.object({TrackID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),RespectBounds:zod.z.boolean().nullish()}).passthrough(),wh=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(),Bh=zod.z.object({RequiredCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredAnyCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredTracks:zod.z.array(Ah).nullish(),VisibleWhileLocked:zod.z.boolean().nullish()}).passthrough(),qh=zod.z.object({NodeID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),Type:zod.z.string().nullish(),Action:Mh.nullish(),Grants:G.nullish(),TrackChanges:zod.z.array(Oh).nullish(),MilestonePoints:zod.z.number().nullish(),UnlockRules:Bh.nullish(),NextNodeIDs:zod.z.array(zod.z.string()).nullish(),ChoiceGroupID:zod.z.string().nullish(),Limits:de.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(),Ma=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(qh).nullish(),Tracks:zod.z.array(wh).nullish(),Milestones:zod.z.record(zod.z.string(),ye).nullish(),Presets:Uh.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneToken:rt.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(),Eh=zod.z.object({Milestones:zod.z.record(zod.z.string(),Xe).nullish()}).passthrough(),wi=zod.z.object({Slots:zod.z.record(zod.z.string(),Ph).nullish(),Offers:zod.z.record(zod.z.string(),Ma).nullish(),Presets:Eh.nullish()}).passthrough(),Aa=zod.z.object({DealOfferDefinitions:wi.nullish()}),Ua=zod.z.object({DealOffers:zh.nullish()}),Lh=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(),Gh=zod.z.object({SlotID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),OfferDef:Ma.nullish(),ActivationState:ka.nullish(),IsNewActivation:zod.z.boolean().nullish(),ComputedExpiresAtUtc:l.nullish(),Cost:K.nullish(),Milestone:Lh.nullish()}).passthrough(),Oa=zod.z.object({Slots:zod.z.array(Gh).nullish()}),wa=zod.z.object({ServerTimeUtc:l.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:x.nullish()}),Ba=zod.z.object({ServerTimeUtc:l.nullish(),SlotID:zod.z.string().nullish(),Resources:x.nullish()}),qa=zod.z.object({ServerTimeUtc:l.nullish(),SlotID:zod.z.string().nullish(),Resources:x.nullish()}),Ea=zod.z.object({ServerTimeUtc:l.nullish(),SlotID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:x.nullish()}),La=zod.z.object({ServerTimeUtc:l.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:x.nullish()}),Fe={GetDefinition:"GetDefinition",GetUserState:"GetUserState",GetActiveDeals:"GetActiveDeals",DismissDeal:"DismissDeal",ExecuteNode:"ExecuteNode",RecordShow:"RecordShow",ClaimMilestone:"ClaimMilestone",ClaimMilestonesBatch:"ClaimMilestonesBatch"};var fr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"DealOffer",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinition(e){return this.send(Fe.GetDefinition,e,Aa)}getUserState(e){return this.send(Fe.GetUserState,e,Ua)}getActiveDeals(e){return this.send(Fe.GetActiveDeals,e,Oa)}dismissDeal(e){return this.send(Fe.DismissDeal,e,Ba)}executeNode(e){return this.send(Fe.ExecuteNode,e,wa)}recordShow(e){return this.send(Fe.RecordShow,e,qa)}claimMilestone(e){return this.send(Fe.ClaimMilestone,e,Ea)}claimMilestonesBatch(e){return this.send(Fe.ClaimMilestonesBatch,e,La)}};var Nh=zod.z.object({}).passthrough().transform(a=>a),jh=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(),Bi=zod.z.object({IsEnabled:zod.z.boolean().nullish(),ActivationReward:G.nullish(),InviteRewards:zod.z.record(zod.z.string(),ye).nullish(),SpendRewards:zod.z.array(jh).nullish()}).passthrough(),Ga=zod.z.object({ReferralDefinitions:Bi.nullish()}),Na=zod.z.object({Referral:Nh.nullish()}),ja=zod.z.object({ReferralCode:zod.z.string().nullish(),IsFirstActivation:zod.z.boolean().nullish(),Resources:x.nullish()}),Fa=zod.z.object({RewardID:zod.z.string().nullish(),Resources:x.nullish()}),St={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateReferralCode:"ActivateReferralCode",ClaimInviteReward:"ClaimInviteReward"};var gr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Referral",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(St.GetDefinitions,e,Ga)}getUserState(e){return this.send(St.GetUserState,e,Na)}activateReferralCode(e){return this.send(St.ActivateReferralCode,e,ja)}claimInviteReward(e){return this.send(St.ClaimInviteReward,e,Fa)}};var Fh={RequestSent:"RequestSent",Accepted:"Accepted",Declined:"Declined",Removed:"Removed"},Vh={Attack:"Attack",Raid:"Raid",FriendAdd:"FriendAdd"},_h=zod.z.object({UserID:zod.z.string(),PublicData:Ce.nullish()}),Wh=zod.z.object({OwnerUserID:zod.z.string().nullish(),ActorUserID:zod.z.string().nullish(),ActorProfile:Ce.nullish(),Type:zod.z.string().nullish(),CreatedAt:l.nullish(),OwnerImpact:x.nullish(),IsBlocked:zod.z.boolean().nullish(),TargetObjectName:zod.z.string().nullish()}).passthrough(),Rr=zod.z.object({Friends:zod.z.array(_h).nullish()}),It=zod.z.object({TargetUserID:zod.z.string().nullish(),Status:zod.z.string().nullish()}),Va=zod.z.object({Events:zod.z.array(Wh).nullish()}),Ve={GetFriendsList:"GetFriendsList",GetIncomingRequests:"GetIncomingRequests",GetRecommendedFriends:"GetRecommendedFriends",SendFriendRequest:"SendFriendRequest",AcceptFriendRequest:"AcceptFriendRequest",DeclineFriendRequest:"DeclineFriendRequest",RemoveFriend:"RemoveFriend",GetTimeline:"GetTimeline"};var yr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Social",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getFriendsList(e){return this.send(Ve.GetFriendsList,e,Rr)}getIncomingRequests(e){return this.send(Ve.GetIncomingRequests,e,Rr)}getRecommendedFriends(e){return this.send(Ve.GetRecommendedFriends,e,Rr)}sendFriendRequest(e){return this.send(Ve.SendFriendRequest,e,It)}acceptFriendRequest(e){return this.send(Ve.AcceptFriendRequest,e,It)}declineFriendRequest(e){return this.send(Ve.DeclineFriendRequest,e,It)}removeFriend(e){return this.send(Ve.RemoveFriend,e,It)}getTimeline(e){return this.send(Ve.GetTimeline,e,Va)}};var Qh={Replace:"Replace",Refresh:"Refresh",KeepBest:"KeepBest",Stack:"Stack"};var xt=zod.z.object({Target:zod.z.string().nullish(),Operation:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),Hh=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:K.nullish(),Effect:xt.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(),Kh=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(xt).nullish(),Gate:Q.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),$h=zod.z.object({ChainedBoostID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Effects:zod.z.array(xt).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Zh=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($h).nullish(),Gate:Q.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Jh=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(_e).nullish(),Effects:zod.z.array(xt).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(),Yh=zod.z.object({MaxAddPercent:zod.z.number().nullish(),MaxMultiply:zod.z.number().nullish(),MaxAddFlat:zod.z.number().nullish()}).passthrough(),Xh=zod.z.object({StackingCaps:zod.z.record(zod.z.string(),Yh).nullish()}).passthrough(),Cr=zod.z.object({Definitions:zod.z.record(zod.z.string(),Hh).nullish(),ScheduledBoosts:zod.z.record(zod.z.string(),Kh).nullish(),BoostChains:zod.z.record(zod.z.string(),Zh).nullish(),TriggeredBoosts:zod.z.record(zod.z.string(),Jh).nullish(),Settings:Xh.nullish()}).passthrough(),_a=zod.z.object({InstanceID:zod.z.string(),BoostID:zod.z.string(),ActivatedAtUtc:l.nullish(),ExpiresAtUtc:l.nullish(),RemainingCharges:zod.z.number().nullish(),EffectSnapshot:xt.nullish(),SourceType:zod.z.string().nullish(),SourceRef:zod.z.string().nullish()}).passthrough();zod.z.object({Date:l.nullish(),DailyCount:zod.z.number().nullish(),LastFiredUtc:l.nullish()}).passthrough();var Wa=zod.z.object({ServerTimeUtc:l.nullish(),Active:zod.z.record(zod.z.string(),_a).nullish()}),Qa=zod.z.object({ServerTimeUtc:l.nullish(),BoostID:zod.z.string().nullish(),StackingPolicy:zod.z.string().nullish(),ActivatedBoost:_a.nullish(),Resources:x.nullish()}),em={Scheduled:"Scheduled",Chain:"Chain"},tm=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:l.nullish(),EndUtc:l.nullish(),Effects:zod.z.array(xt).nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Ha=zod.z.object({ServerTimeUtc:l.nullish(),Windows:zod.z.array(tm).nullish()}),at={GetDefinitions:"GetDefinitions",GetActive:"GetActive",GetActiveWindows:"GetActiveWindows",Activate:"Activate",CleanupExpired:"CleanupExpired"};var Sr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"TimedBoost",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(at.GetDefinitions,e,Cr)}getActive(e){return this.send(at.GetActive,e,Wa)}getActiveWindows(e){return this.send(at.GetActiveWindows,e,Ha)}activate(e){return this.send(at.Activate,e,Qa)}cleanupExpired(e){return this.send(at.CleanupExpired,e,Se)}};var xr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"UserCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getUserCustomDataDefinitions(e){return this.send(Ge.GetUserCustomDataDefinitions,e,ys)}getMyUserCustomData(e){return this.send(Ge.GetMyUserCustomData,e,Rn)}getPublicUserCustomDataOf(e){return this.send(Ge.GetPublicUserCustomDataOf,e,Zr)}setPrivateData(e){return this.send(Ge.SetPrivateData,e,Jr)}setPublicData(e){return this.send(Ge.SetPublicData,e,Jr)}deleteKey(e){return this.send(Ge.DeleteKey,e,Se)}batchSet(e){return this.send(Ge.BatchSet,e,yn)}batchDelete(e){return this.send(Ge.BatchDelete,e,Cn)}batchGetPublicUserCustomDataOf(e){return this.send(Ge.BatchGetPublicUserCustomDataOf,e,Sn)}};var sm={Static:"Static",Runtime:"Runtime"},rm={Public:"Public",Private:"Private"},im=zod.z.enum(["Client","Server","System"]),nm=zod.z.enum(["String","Int","Bool","Json"]),om=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:l.nullish(),Version:zod.z.number().nullish(),LastWriter:im.nullish(),ExpiresAt:l.nullish()}).passthrough(),Ka=zod.z.record(zod.z.string(),om),qi=zod.z.object({StaticVersion:zod.z.number().nullish(),RuntimeVersion:zod.z.number().nullish(),Static:Ka.nullish(),Runtime:Ka.nullish(),NotModified:zod.z.boolean().nullish()}),am=zod.z.object({KeyID:zod.z.string(),Scope:zod.z.enum(["Static","Runtime"]).nullish(),Bucket:zod.z.enum(["Public","Private"]).nullish(),ValueType:nm.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),Dr=zod.z.object({Keys:zod.z.record(zod.z.string(),am).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(),kt={GetTitleCustomDataDefinitions:"GetTitleCustomDataDefinitions",GetPublicTitleData:"GetPublicTitleData",GetPublicTitleDataKeys:"GetPublicTitleDataKeys"};var br=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"TitleCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getTitleCustomDataDefinitions(e){return this.send(kt.GetTitleCustomDataDefinitions,e,Dr)}getPublicTitleData(e){return this.send(kt.GetPublicTitleData,e,qi)}getPublicTitleDataKeys(e){return this.send(kt.GetPublicTitleDataKeys,e,qi)}};var lm={Fast:"Fast",Sequential:"Sequential"},um={Instant:"Instant",Timed:"Timed"},cm={Hit:"Hit",Blocked:"Blocked"},pm=zod.z.object({SlotIndex:zod.z.number(),Level:zod.z.number().nullish(),IsDamaged:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish()}).passthrough(),dm=zod.z.object({Symbol:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),OnOpenBonus:G.nullish(),BonusTag:zod.z.string().nullish()}).passthrough();zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:G.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 $a=zod.z.object({}).passthrough().transform(a=>a),Za=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),ve=zod.z.object({Operation:x.nullish(),ScaleWithRollMultiplier:zod.z.boolean().nullish()}).passthrough(),hm=zod.z.object({Count:zod.z.number().nullish(),Sides:zod.z.number().nullish()}).passthrough(),mm=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(),fm=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:ce.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(),gm=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:ce.nullish()}).passthrough(),Ja=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:G.nullish()}).passthrough(),Rm=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(),ym=zod.z.object({Tiles:zod.z.record(zod.z.string(),Rm).nullish()}).passthrough(),Cm=zod.z.object({Weight:zod.z.number().nullish(),Bonus:ve.nullish(),Tag:zod.z.string().nullish()}).passthrough(),Sm=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(Cm).nullish(),GuaranteedBonus:ve.nullish(),IsJackpot:zod.z.boolean().nullish(),JackpotFinalMultiplier:zod.z.number().nullish(),JackpotSymbolDistribution:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough(),xm=zod.z.object({Variants:zod.z.array(Sm).nullish()}).passthrough(),Dm=zod.z.object({Weight:zod.z.number().nullish(),OutcomeID:zod.z.string().nullish(),Reward:ve.nullish(),ForceAction:zod.z.string().nullish(),SpecialModeID:zod.z.string().nullish()}).passthrough(),bm=zod.z.object({Outcomes:zod.z.array(Dm).nullish()}).passthrough(),Ya=zod.z.object({PerAdMultiplierRange:Za.nullish(),MaxAdViews:zod.z.number().nullish(),AdCreditCost:zod.z.number().nullish(),FormulaKind:zod.z.string().nullish(),ApplyMultiplierOnEarlyClaim:zod.z.boolean().nullish()}).passthrough(),vm=zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:ve.nullish()}).passthrough(),zm=zod.z.object({Tiers:zod.z.array(vm).nullish(),BelowFirstTierReward:ve.nullish()}).passthrough(),Tm=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:ve.nullish(),DurationSeconds:zod.z.number().nullish(),EntryCost:K.nullish(),Multipliers:Ya.nullish(),Gradation:zm.nullish()}).passthrough(),Pm=zod.z.object({Choices:zod.z.array(Tm).nullish(),OfferExpireSeconds:zod.z.number().nullish(),ClaimExpireSeconds:zod.z.number().nullish()}).passthrough(),Im=zod.z.object({Chance:zod.z.number().nullish(),RequiredOutcome:zod.z.string().nullish(),Reward:ve.nullish(),Tag:zod.z.string().nullish()}).passthrough(),km=zod.z.object({OnPassStart:ve.nullish(),OnTileLanding:zod.z.record(zod.z.string(),ve).nullish(),OnAttack:zod.z.record(zod.z.string(),ve).nullish(),OnRaid:zod.z.record(zod.z.string(),ve).nullish(),OnBuild:ve.nullish(),OnStageComplete:ve.nullish(),OnAttackBonusDrops:zod.z.array(Im).nullish(),ChanceTablesByID:zod.z.record(zod.z.string(),bm).nullish(),SpecialModesByID:zod.z.record(zod.z.string(),Pm).nullish()}).passthrough(),Xa=zod.z.object({BaseAttackReward:G.nullish(),BaseRaidReward:G.nullish(),MaxRollMultiplier:zod.z.number().nullish(),MaxShields:zod.z.number().nullish(),Buildings:zod.z.array(Ja).nullish(),HeistGridBonusConfig:xm.nullish(),StageOperations:km.nullish(),TileLandingMultiplier:Za.nullish(),EconomyOverride:gm.nullish()}).passthrough(),Mm=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(Ja).nullish(),StageTemplateID:zod.z.string().nullish(),CostMatrixTemplateID:zod.z.string().nullish(),UnitValue:zod.z.number().nullish(),Override:Xa.nullish()}).passthrough(),vr=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(),ym).nullish(),StageTemplatesByID:zod.z.record(zod.z.string(),Xa).nullish(),StagesByLevel:zod.z.record(zod.z.string(),Mm).nullish(),SoftCurrencyID:zod.z.string().nullish(),ProceduralEconomy:fm.nullish(),Dice:hm.nullish(),Bots:mm.nullish()}).passthrough(),Am=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:l.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(),ye).nullish(),GrandPrize:G.nullish()}).passthrough(),zr=zod.z.object({Board:vr.nullish(),CommunityChest:Am.nullish()}).passthrough(),Um=zod.z.object({TargetUserID:zod.z.string().nullish(),IsBot:zod.z.boolean().nullish(),PublicData:Ce.nullish(),TargetBuildingStates:zod.z.array(pm).nullish(),TargetHasShield:zod.z.boolean().nullish()}).passthrough(),Om=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:ve.nullish(),DurationSeconds:zod.z.number().nullish(),EntryCost:K.nullish(),Multipliers:Ya.nullish()}).passthrough(),wm=zod.z.object({ModeID:zod.z.string().nullish(),Choices:zod.z.array(Om).nullish()}).passthrough(),Bm=zod.z.object({GroupID:zod.z.string().nullish(),Delta:M.nullish(),NewProgress:M.nullish(),MaxProgress:M.nullish(),UnlockedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),Completed:zod.z.boolean().nullish()}).passthrough(),el=zod.z.object({UsedMultiplier:zod.z.number().nullish(),Steps:zod.z.number().nullish(),OldPosition:zod.z.number().nullish(),NewPosition:zod.z.number(),CyclesCompletedDelta:M.nullish(),LandedTileType:zod.z.string().nullish(),Operation:x.nullish(),ActionRequired:zod.z.string().nullish(),ActionData:Um.nullish(),SpecialModeOffer:wm.nullish(),CommunityChestContribution:Bm.nullish()}).passthrough(),tl=zod.z.object({Outcome:zod.z.string().nullish(),IsBotTarget:zod.z.boolean().nullish(),BuildingIndexHit:zod.z.number().nullish(),Operation:x.nullish(),DualResult:st.nullish()}).passthrough(),Ei=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:G.nullish(),OpenedIndex:zod.z.number().nullish(),AttemptsLeft:zod.z.number().nullish(),RaidLayout:zod.z.array(dm).nullish(),HeistVariantTag:zod.z.string().nullish(),IsJackpot:zod.z.boolean().nullish(),Operation:x.nullish(),DualResult:st.nullish()}).passthrough(),sl=zod.z.object({BuiltIndex:zod.z.number(),NewLevel:zod.z.number().nullish(),StageComplete:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish(),Operation:x.nullish()}).passthrough(),rl=zod.z.object({Mode:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),Operation:x.nullish(),DurationSeconds:zod.z.number().nullish(),StartedAtUtc:l.nullish(),ExpiresAtUtc:l.nullish()}).passthrough(),il=zod.z.object({AdViewsUsed:zod.z.number().nullish(),RolledMultiplier:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),RemainingAdViews:zod.z.number().nullish()}).passthrough(),nl=zod.z.object({FinalMultiplier:zod.z.number().nullish(),AdViewsUsed:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),IsEarlyClaim:zod.z.boolean().nullish(),Operation:x.nullish()}).passthrough(),qm={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},ol=zod.z.enum(["Forming","Active","Completed","Failed","Expired"]),Em={Active:"Active",Left:"Left",Replaced:"Replaced"},Lm=zod.z.enum(["Active","Left","Replaced"]),Gm=zod.z.object({CurrentProgress:M.nullish(),MaxProgress:M.nullish()}).passthrough(),Nm=zod.z.object({UserID:zod.z.string().nullish(),PublicData:Ce.nullish(),IsBot:zod.z.boolean().nullish(),ContributionPoints:M.nullish(),ClaimedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),GrandPrizeClaimed:zod.z.boolean().nullish(),MemberStatus:Lm.nullish(),JoinedAtUtc:l.nullish(),LeftAtUtc:l.nullish()}).passthrough(),al=zod.z.object({GroupID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),Members:zod.z.array(Nm).nullish(),SharedProgress:Gm.nullish(),Status:ol.nullish(),CreatedAtUtc:l.nullish(),ExpiresAtUtc:l.nullish(),Version:zod.z.number().nullish()}).passthrough(),jm=zod.z.object({GroupID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),FinalStatus:ol.nullish(),GrandPrizeReceived:zod.z.boolean().nullish(),FinishedAtUtc:l.nullish()}).passthrough(),Fm=zod.z.object({ActiveGroupID:zod.z.string().nullish(),ActiveRoundIndex:zod.z.number().nullish(),History:zod.z.array(jm).nullish()}).passthrough(),ll=zod.z.object({ServerTimeUtc:l.nullish(),UserState:Fm.nullish(),ActiveGroup:al.nullish(),SecondsRemaining:M.nullish()}),ul=zod.z.object({ServerTimeUtc:l.nullish(),Group:al.nullish(),SecondsRemaining:M.nullish()}),Li=zod.z.object({ServerTimeUtc:l.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:x.nullish()}),cl=zod.z.object({ServerTimeUtc:l.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),me={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 Vm=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(),_m=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:Q.nullish(),Variants:zod.z.array(Vm).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(),pl=zod.z.object({Experiments:zod.z.record(zod.z.string(),_m).nullish()}).passthrough();var Wm={Mesh:"Mesh",Host:"Host"},Gi=zod.z.enum(["Mesh","Host"]),Qm={ServerRelay:"ServerRelay",P2P:"P2P"},Ni=zod.z.enum(["ServerRelay","P2P"]),Hm={Public:"Public",Private:"Private"},Km=zod.z.enum(["Public","Private"]),$m={Signal:"Signal",Chat:"Chat",PlayerJoined:"PlayerJoined",PlayerLeft:"PlayerLeft",HostChanged:"HostChanged",RoomClosed:"RoomClosed",MemberState:"MemberState"},Zm=zod.z.enum(["Signal","Chat","PlayerJoined","PlayerLeft","HostChanged","RoomClosed","MemberState"]),dl=zod.z.object({Urls:zod.z.string().nullish(),Username:zod.z.string().nullish(),Credential:zod.z.string().nullish()}).passthrough(),Jm=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),hl=zod.z.object({SystemState:Jm.nullish(),DefaultTopology:Gi.nullish(),AllowCreatorTopologyOverride:zod.z.boolean().nullish(),DefaultChatMode:Ni.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(dl).nullish()}).passthrough(),Ym=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(),Xm=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),Topology:Gi.nullish(),ChatMode:Ni.nullish(),MaxPlayers:zod.z.number().nullish(),MemberCount:zod.z.number().nullish(),CreatedAt:zod.z.number().nullish()}).passthrough(),ef=zod.z.object({Seq:zod.z.number().nullish(),Type:Zm.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(),Tr=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),OwnerUserID:zod.z.string().nullish(),Topology:Gi.nullish(),ChatMode:Ni.nullish(),Visibility:Km.nullish(),Status:zod.z.string().nullish(),MaxPlayers:zod.z.number().nullish(),Members:zod.z.array(Ym).nullish(),IceServers:zod.z.array(dl).nullish(),Seq:zod.z.number().nullish()}).passthrough(),ji=zod.z.object({Closed:zod.z.boolean().nullish(),NewHostUserID:zod.z.string().nullish()}).passthrough(),ml=zod.z.object({Rooms:zod.z.array(Xm).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}).passthrough(),fl=zod.z.object({Envelopes:zod.z.array(ef).nullish(),MaxSeq:zod.z.number().nullish()}).passthrough(),Pr=zod.z.object({Seq:zod.z.number().nullish()}).passthrough(),Be={CreateRoom:"CreateRoom",JoinRoom:"JoinRoom",LeaveRoom:"LeaveRoom",ListRooms:"ListRooms",GetRoom:"GetRoom",CloseRoom:"CloseRoom",Poll:"Poll",SendSignal:"SendSignal",SendChat:"SendChat",SetMemberState:"SetMemberState"};var Fi=zod.z.object({TitleCustomData:Dr.nullish(),Character:Ts.nullish(),Item:Gs.nullish(),Currency:zs.nullish(),Store:js.nullish(),Lootbox:xi.nullish(),Quest:Lt.nullish(),TimedEvent:Ks.nullish(),Leaderboard:er.nullish(),Season:sr.nullish(),Reward:Di.nullish(),Collection:pr.nullish(),Craft:ki.nullish(),DealOffer:wi.nullish(),Premium:Ii.nullish(),TimedBoost:Cr.nullish(),CoopEvent:hr.nullish(),GameLoop:zr.nullish(),Match:di.nullish(),Experiment:pl.nullish(),Blockchain:ni.nullish(),Marketplace:gi.nullish(),Multiplayer:hl.nullish(),UserCustomData:ys.nullish(),Referral:Bi.nullish()}).passthrough();var lt={GetTitlePublicConfiguration:"GetTitlePublicConfiguration",GetTitlePublicConfigurationExcept:"GetTitlePublicConfigurationExcept",GetCurrencyDefinitions:"GetCurrencyDefinitions",GetItemDefinitions:"GetItemDefinitions",GetServerTime:"GetServerTime"};var Ir=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Title",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getTitlePublicConfiguration(e){return this.send(lt.GetTitlePublicConfiguration,e,Fi)}getTitlePublicConfigurationExcept(e){return this.send(lt.GetTitlePublicConfigurationExcept,e,Fi)}getCurrencyDefinitions(e){return this.send(lt.GetCurrencyDefinitions,e,zs)}getItemDefinitions(e){return this.send(lt.GetItemDefinitions,e,Gs)}getServerTime(e){return this.send(lt.GetServerTime,e,Se)}};var kr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s,r=false){let i=U(this.ctx.settings.titleID,"GameLoop",e,t.UserID??"");return this.ctx.transport.post(i,t,s,{ticket:t.ClientSessionTicket,silent:r})}getGameLoops(e){return this.send(me.GetGameLoops,e,zr)}getBoardDefinition(e,t=false){return this.send(me.GetBoardDefinition,e,vr,t)}getBoardDefinitionForLevel(e,t=false){return this.send(me.GetBoardDefinitionForLevel,e,vr,t)}getUserBoardState(e){return this.send(me.GetUserBoardState,e,$a)}boardLoopRoll(e){return this.send(me.BoardLoopRoll,e,el)}boardLoopAttack(e){return this.send(me.BoardLoopAttack,e,tl)}boardLoopRaid(e){return this.send(me.BoardLoopRaid,e,Ei)}boardLoopRaidFast(e){return this.send(me.BoardLoopRaidFast,e,Ei)}boardLoopBuild(e){return this.send(me.BoardLoopBuild,e,sl)}boardSpecialChoose(e){return this.send(me.BoardSpecialChoose,e,rl)}boardSpecialApplyMultiplier(e){return this.send(me.BoardSpecialApplyMultiplier,e,il)}boardSpecialClaim(e){return this.send(me.BoardSpecialClaim,e,nl)}getCommunityChestState(e){return this.send(me.GetCommunityChestState,e,ll)}joinOrCreateCommunityChest(e){return this.send(me.JoinOrCreateCommunityChest,e,ul)}claimCommunityChestMilestone(e){return this.send(me.ClaimCommunityChestMilestone,e,Li)}claimCommunityChestGrandPrize(e){return this.send(me.ClaimCommunityChestGrandPrize,e,Li)}leaveCommunityChest(e){return this.send(me.LeaveCommunityChest,e,cl)}};var Mt=zod.z.lazy(()=>zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null(),zod.z.array(Mt),zod.z.record(zod.z.string(),Mt)]));var sf={Live:"Live",Latest:"Latest",Specific:"Specific"},rf={Debug:"Debug",Info:"Info",Warning:"Warning",Error:"Error"},nf=zod.z.enum(["Debug","Info","Warning","Error"]),of={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"},af=zod.z.enum(["None","Disabled","NoActiveRevision","RevisionNotFound","InvalidFieldName","RateLimited","HandlerNotFound","HandlerDisabled","Timeout","StatementCountExceeded","StackOverflow","ApiCallLimitExceeded","JavaScriptException","ExecutionError"]),lf=zod.z.object({Level:nf,Message:zod.z.string().nullish(),Data:Mt.nullish()}),uf=zod.z.object({Error:af,Message:zod.z.string().nullish(),StackTrace:zod.z.string().nullish()}),gl=zod.z.object({FunctionName:zod.z.string().nullish(),Revision:zod.z.number().nullish(),FunctionResult:Mt.nullish(),FunctionResultTooLarge:zod.z.boolean().nullish(),Logs:zod.z.array(lf).nullish(),LogsTooLarge:zod.z.boolean().nullish(),ExecutionTimeSeconds:zod.z.number().nullish(),APIRequestsIssued:zod.z.number().nullish(),Error:uf.nullish()}),Vi={Execute:"Execute"};var Mr=class{constructor(e){this.ctx=e;}ctx;execute(e){let t=U(this.ctx.settings.titleID,"CloudCode",Vi.Execute,e.UserID??"");return this.ctx.transport.post(t,e,gl,{ticket:e.ClientSessionTicket})}};var Ar=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Blockchain",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Pe.GetDefinitions,e,Qn)}getUserState(e){return this.send(Pe.GetUserState,e,Hn)}depositToken(e){return this.send(Pe.DepositToken,e,Kn)}depositNFT(e){return this.send(Pe.DepositNFT,e,$n)}requestTokenWithdrawal(e){return this.send(Pe.RequestTokenWithdrawal,e,Zn)}requestNFTWithdrawal(e){return this.send(Pe.RequestNFTWithdrawal,e,Jn)}getTransactionHistory(e){return this.send(Pe.GetTransactionHistory,e,Yn)}retryWithdrawal(e){return this.send(Pe.RetryWithdrawal,e,Xn)}confirmWithdrawal(e){return this.send(Pe.ConfirmWithdrawal,e,eo)}donateToDeveloper(e){return this.send(Pe.DonateToDeveloper,e,li)}donateToUsersPool(e){return this.send(Pe.DonateToUsersPool,e,li)}};var Ur=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Marketplace",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(ie.GetDefinitions,e,fo)}getGroupedOffers(e){return this.send(ie.GetGroupedOffers,e,go)}getOffersByItem(e){return this.send(ie.GetOffersByItem,e,Ri)}getOffer(e){return this.send(ie.GetOffer,e,Ro)}getBuyOrders(e){return this.send(ie.GetBuyOrders,e,Ri)}getMyState(e){return this.send(ie.GetMyState,e,Co)}getHistory(e){return this.send(ie.GetHistory,e,So)}createListing(e){return this.send(ie.CreateListing,e,Tt)}cancelListing(e){return this.send(ie.CancelListing,e,Ue)}buy(e){return this.send(ie.Buy,e,Ue)}marketBuy(e){return this.send(ie.MarketBuy,e,Ue)}marketSell(e){return this.send(ie.MarketSell,e,Ue)}createAuction(e){return this.send(ie.CreateAuction,e,Tt)}placeBid(e){return this.send(ie.PlaceBid,e,yo)}claimAuction(e){return this.send(ie.ClaimAuction,e,Ue)}createBuyOrder(e){return this.send(ie.CreateBuyOrder,e,Tt)}cancelBuyOrder(e){return this.send(ie.CancelBuyOrder,e,Ue)}fillBuyOrder(e){return this.send(ie.FillBuyOrder,e,Ue)}createDirectTrade(e){return this.send(ie.CreateDirectTrade,e,Tt)}respondDirectTrade(e){return this.send(ie.RespondDirectTrade,e,Ue)}cancelDirectTrade(e){return this.send(ie.CancelDirectTrade,e,Ue)}claimBack(e){return this.send(ie.ClaimBack,e,Ue)}};var Or=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Multiplayer",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}createRoom(e){return this.send(Be.CreateRoom,e,Tr)}joinRoom(e){return this.send(Be.JoinRoom,e,Tr)}leaveRoom(e){return this.send(Be.LeaveRoom,e,ji)}listRooms(e){return this.send(Be.ListRooms,e,ml)}getRoom(e){return this.send(Be.GetRoom,e,Tr)}closeRoom(e){return this.send(Be.CloseRoom,e,ji)}poll(e){return this.send(Be.Poll,e,fl)}sendSignal(e){return this.send(Be.SendSignal,e,Pr)}sendChat(e){return this.send(Be.SendChat,e,Pr)}setMemberState(e){return this.send(Be.SetMemberState,e,Pr)}};var wr=class{settings;emitter;platform;transport;fetchImpl;data;authStore;api;auth;userService;currency;item;store;lootbox;reward;quest;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=Ki(e),this.emitter=new bt,this.platform=e.platform??new dt,this.fetchImpl=e.fetch??globalThis.fetch.bind(globalThis),this.transport=new jt({baseUrl:this.settings.baseUrl,emitter:this.emitter,fetchImpl:e.fetch,debugLogging:this.settings.debugLogging,throttleMs:e.throttleMs}),this.data=new Wt(this.emitter),this.emitter.on("quest:systemProgress",t=>{this.data.user.patchQuestProgressUpdates(t);}),this.emitter.on("user:stateVersions",({epoch:t,versions:s})=>{this.userService.noteStateVersions(t,s);}),this.authStore=new Qt(this.platform.storage,this.settings.titleID),this.api={authentication:new Bs(this),user:new qs(this),currency:new Es(this),item:new Ns(this),store:new Fs(this),lootbox:new Ws(this),reward:new Qs(this),quest:new Hs(this),timedEvent:new $s(this),leaderboard:new tr(this),season:new rr(this),premium:new nr(this),character:new or(this),match:new ar(this),craft:new ur(this),collection:new dr(this),coopEvent:new mr(this),dealOffer:new fr(this),referral:new gr(this),social:new yr(this),timedBoost:new Sr(this),userCustomData:new xr(this),titleCustomData:new br(this),title:new Ir(this),gameLoop:new kr(this),cloudCode:new Mr(this),blockchain:new Ar(this),marketplace:new Ur(this),multiplayer:new Or(this)},this.userService=new Zt(this),this.auth=new Ht(this),this.currency=new Yt(this),this.item=new Xt(this),this.store=new es(this),this.lootbox=new ts(this),this.reward=new ss(this),this.quest=new rs(this),this.timedEvent=new is(this),this.leaderboard=new ns(this),this.season=new os(this),this.premium=new as(this),this.character=new ls(this),this.match=new us(this),this.craft=new cs(this),this.collection=new ps(this),this.coopEvent=new ds(this),this.dealOffer=new hs(this),this.referral=new ms(this),this.social=new fs(this),this.timedBoost=new gs(this),this.userCustomData=new Cs(this),this.titleCustomData=new Ss(this),this.title=new xs(this),this.gameLoop=new Ds(this),this.cloudCode=new bs(this),this.blockchain=new ks(this),this.marketplace=new Os(this),this.multiplayer=new ws(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:k()}}};var Br=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 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 cf(a){return new Br(a)}var Rl="idos_sso",yl="state",_i="idos:sso:state",pf="https://idosgames.com/sso/";function df(){if(typeof window>"u")return null;let a=window.location.hash?.startsWith("#")?window.location.hash.slice(1):window.location.hash;if(!a)return null;let e=new URLSearchParams(a),t=e.get(Rl);if(!t)return null;let s=e.get(yl)??"",r=Rf();return Cf(e),yf(),r&&s!==r?null:{code:t,state:s}}function hf(a){if(typeof window>"u")return;let e=a.returnTo??mf(),t=ff();gf(t);let s=new URL(a.ssoUrl??pf);s.searchParams.set("title",a.titleID),s.searchParams.set("return_to",e),s.searchParams.set("state",t),window.location.assign(s.toString());}function mf(){let{origin:a,pathname:e,search:t}=window.location;return `${a}${e}${t}`}function ff(){let a=new Uint8Array(16);if(typeof crypto<"u"&&crypto.getRandomValues)crypto.getRandomValues(a);else for(let e=0;e<a.length;e++)a[e]=Math.floor(Math.random()*256);return Array.from(a,e=>e.toString(16).padStart(2,"0")).join("")}function gf(a){try{window.sessionStorage.setItem(_i,a);}catch{}}function Rf(){try{return window.sessionStorage.getItem(_i)}catch{return null}}function yf(){try{window.sessionStorage.removeItem(_i);}catch{}}function Cf(a){a.delete(Rl),a.delete(yl);let e=a.toString(),{pathname:t,search:s}=window.location;window.history.replaceState(null,"",`${t}${s}${e?`#${e}`:""}`);}var Sf={Banner:"Banner",Interstitial:"Interstitial",RewardedVideo:"RewardedVideo",RewardedInterstitial:"RewardedInterstitial",AppOpen:"AppOpen",Native:"Native"},Wi=zod.z.enum(["Banner","Interstitial","RewardedVideo","RewardedInterstitial","AppOpen","Native"]),xf={Top:"Top",Bottom:"Bottom",Left:"Left",Right:"Right"},Df=zod.z.enum(["Top","Bottom","Left","Right"]),bf=zod.z.object({PlacementID:zod.z.string().nullish(),Type:Wi.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(),vf=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(),zf=zod.z.object({CooldownSeconds:zod.z.number().nullish(),MinSessionTimeBeforeFirstSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),Tf=zod.z.object({Enabled:zod.z.boolean().nullish(),Position:Df.nullish(),RefreshIntervalSeconds:zod.z.number().nullish()}).passthrough(),Pf=zod.z.object({Enabled:zod.z.boolean().nullish(),CooldownSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish()}).passthrough(),If=zod.z.object({MaxImpressionsPerHour:zod.z.number().nullish(),MaxImpressionsPerDay:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),kf=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(),Mf=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(),Af=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(),Uf=zod.z.object({AndroidUnitID:zod.z.string().nullish(),IosUnitID:zod.z.string().nullish(),WebUnitID:zod.z.string().nullish(),Type:Wi.nullish()}).passthrough(),Of=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(),Uf).nullish()}).passthrough();zod.z.object({Enabled:zod.z.boolean().nullish(),Placements:zod.z.record(zod.z.string(),bf).nullish(),Providers:zod.z.record(zod.z.string(),Of).nullish(),RewardedVideo:vf.nullish(),Interstitial:zf.nullish(),Banner:Tf.nullish(),AppOpen:Pf.nullish(),FrequencyCapping:If.nullish(),PremiumAdReductions:zod.z.array(kf).nullish(),Consent:Mf.nullish(),Verification:Af.nullish()}).passthrough();var wf=zod.z.object({RewardedVideoCredit:zod.z.number().nullish(),TotalEarned:zod.z.number().nullish(),TotalSpent:zod.z.number().nullish()}).passthrough(),Bf=zod.z.object({PlacementID:zod.z.string().nullish(),LastShownAt:l.nullish(),LastCompletedAt:l.nullish(),TotalImpressions:zod.z.number().nullish(),TotalCompletions:zod.z.number().nullish(),ConsecutiveFailures:zod.z.number().nullish()}).passthrough(),qf=zod.z.object({Date:l.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(),Ef=zod.z.object({SessionID:zod.z.string().nullish(),SessionStartAt:l.nullish(),Impressions:zod.z.number().nullish(),InterstitialImpressions:zod.z.number().nullish(),RewardedCompletions:zod.z.number().nullish()}).passthrough(),Lf=zod.z.object({PersonalizedAdsConsent:zod.z.boolean().nullish(),TrackingConsent:zod.z.boolean().nullish(),PolicyVersion:zod.z.string().nullish(),Region:zod.z.string().nullish(),ConsentGivenAt:l.nullish(),ConsentRevokedAt:l.nullish()}).passthrough(),Gf=zod.z.object({RequestID:zod.z.string().nullish(),PlacementID:zod.z.string().nullish(),ProviderID:zod.z.string().nullish(),Type:Wi.nullish(),IssuedAt:l.nullish(),ExpiresAt:l.nullish(),CreditsToAward:zod.z.number().nullish()}).passthrough(),Nf=zod.z.object({InvalidSsvCount:zod.z.number().nullish(),OrphanCompletions:zod.z.number().nullish(),FastCompletions:zod.z.number().nullish(),LastFlaggedAt:l.nullish()}).passthrough();zod.z.object({Credits:wf.nullish(),Placements:zod.z.record(zod.z.string(),Bf).nullish(),Daily:qf.nullish(),Session:Ef.nullish(),LastImpressionAt:l.nullish(),LastInterstitialAt:l.nullish(),LastRewardedAt:l.nullish(),LastAppOpenAt:l.nullish(),TotalImpressions:zod.z.number().nullish(),TotalRewardedCompletions:zod.z.number().nullish(),AdsDisabledUntil:l.nullish(),Consent:Lf.nullish(),PendingRequests:zod.z.record(zod.z.string(),Gf).nullish(),FraudFlags:Nf.nullish(),UpdatedAt:l.nullish()}).passthrough();var jf={Unread:"Unread",Read:"Read",Deleted:"Deleted",Expired:"Expired"},Ff=zod.z.enum(["Unread","Read","Deleted","Expired"]),Vf={Admin:"Admin",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season",Collection:"Collection",MilestoneEvent:"MilestoneEvent",PlayerGift:"PlayerGift",Social:"Social",Compensation:"Compensation",Referral:"Referral",Quest:"Quest"},_f=zod.z.enum(["Admin","Leaderboard","CoopEvent","Season","Collection","MilestoneEvent","PlayerGift","Social","Compensation","Referral","Quest"]),Wf={Active:"Active",Paused:"Paused",Cancelled:"Cancelled",Completed:"Completed"},Qf=zod.z.enum(["Active","Paused","Cancelled","Completed"]),Hf=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(),Kf=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(),Hf).nullish(),Segments:zod.z.array(Kf).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:_f.nullish(),RelatedEntityID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderPublicData:Ce.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:G.nullish(),Claimed:zod.z.boolean().nullish(),ClaimedAtUtc:l.nullish(),Status:Ff.nullish(),CreatedAtUtc:l.nullish(),ExpiresAtUtc:l.nullish(),ReadAtUtc:l.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:G.nullish(),TargetSegmentID:zod.z.string().nullish(),TargetUserIDs:zod.z.array(zod.z.string()).nullish(),StartsAtUtc:l.nullish(),ExpiresAtUtc:l.nullish(),CreatedAtUtc:l.nullish(),CreatedByAdminID:zod.z.string().nullish(),AdminComment:zod.z.string().nullish(),Status:Qf.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:l.nullish(),ReceivedBroadcastIDs:zod.z.array(zod.z.string()).nullish(),ClaimedBroadcastIDs:zod.z.array(zod.z.string()).nullish(),DailyP2PGiftsSent:zod.z.number().nullish(),DailyGiftsResetDate:l.nullish(),LastOpenedAtUtc:l.nullish(),TotalMessagesReceived:zod.z.number().nullish(),TotalRewardsClaimed:zod.z.number().nullish()}).passthrough();var Cl="idos_device_id",qr=class{storage;constructor(e=new ct){this.storage=e;}getPlatform(){return "Web"}getFullURL(){return ""}getStartParameter(){return null}getTelegramInitDataRaw(){return null}getDeviceID(){let e=this.storage.getString(Cl);return e||(e="noop-device",this.storage.setString(Cl,e)),e}getDeviceModel(){return "Noop"}shareLink(){}openInvoice(){}async showAd(){}async copyToClipboard(){}};
|
|
2
2
|
exports.AdType=Sf;exports.AttackOutcome=cm;exports.AuthType=ue;exports.AuthenticationAction=Ie;exports.BannerPosition=xf;exports.BlockchainAction=Pe;exports.BlockchainNetworkType=gc;exports.BlockchainOperationCategory=jn;exports.BlockchainTransactionStatus=zc;exports.BlockchainTransactionType=Sc;exports.BodyPart=$c;exports.BoostWindowKind=em;exports.BroadcastStatus=Wf;exports.BrowserPlatformAdapter=dt;exports.BrowserStorage=ut;exports.CharacterAction=Te;exports.CloudCodeAction=Vi;exports.CloudCodeErrorCode=of;exports.CloudCodeLogLevel=rf;exports.CloudCodeRevisionSelection=sf;exports.CollectionAction=xe;exports.CommissionSink=mp;exports.CommunityChestMemberStatus=Em;exports.CommunityChestStatus=qm;exports.ConversionRateMode=Hu;exports.CoopEventAction=Ne;exports.CoopGroupStatus=ah;exports.CoopMemberStatus=lh;exports.CraftAction=lr;exports.CraftType=Qd;exports.CurrencyAction=vs;exports.CurrencyStatus=Qu;exports.CurrencyType=qe;exports.CustomDataBucket=Qe;exports.CustomDataValueType=qu;exports.CustomDataWriter=Uu;exports.DEFAULT_BASE_URL=Hi;exports.DealNodeRuntimeStatus=Ch;exports.DealOfferAction=Fe;exports.DealOfferActivationStatus=yh;exports.EnvelopeType=$m;exports.EventTokenType=Tl;exports.FodderSelectionMode=Bp;exports.FodderValuationMode=Op;exports.FriendActionStatus=Fh;exports.GameLoopAction=me;exports.IDosGamesClient=Br;exports.ItemAction=Ls;exports.KycStatus=xc;exports.KycTier=bc;exports.LeaderboardAction=fe;exports.LootboxAction=_s;exports.MailboxMessageSource=Vf;exports.MailboxMessageStatus=jf;exports.MarketGoodsType=Us;exports.MarketOfferStatus=hp;exports.MarketOfferType=dp;exports.MarketplaceAction=ie;exports.MatchAction=je;exports.MatchStatus=Zc;exports.MemoryStorage=ct;exports.MultiplayerAction=Be;exports.MultiplayerChatMode=Qm;exports.MultiplayerTopology=Wm;exports.NoopPlatformAdapter=qr;exports.PremiumAction=ot;exports.QuestAction=Le;exports.QuestObjectiveSource=Wl;exports.QuestPrerequisiteMode=Hl;exports.QuestStatus=Fl;exports.RaidMode=lm;exports.ReferralAction=St;exports.ResourceEntryType=zl;exports.RewardAction=$e;exports.RoomVisibility=Hm;exports.ScheduleMode=Pl;exports.SeasonAction=nt;exports.SocialAction=Ve;exports.SpecialChoiceMode=um;exports.StoreAction=Rt;exports.StoreType=Fd;exports.TimedBoostAction=at;exports.TimedBoostStackingPolicy=Qh;exports.TimedEventAction=we;exports.TimelineEventType=Vh;exports.TitleAction=lt;exports.TitleCustomDataAction=kt;exports.TitleDataBucket=rm;exports.TitleDataScope=sm;exports.TradeOfferStatus=Zd;exports.TransactionDirection=Tc;exports.TypedEmitter=bt;exports.UserAction=Oe;exports.UserCustomDataAction=Ge;exports.WalletLinkType=yc;exports.beginSsoRedirect=hf;exports.createIDosGamesClient=cf;exports.isFail=vl;exports.isOk=bl;exports.normalizeBlockchainCategory=Ps;exports.readSsoCodeFromUrl=df;
|