@idosgames/core 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +869 -666
- package/dist/index.d.ts +869 -666
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var zod=require('zod'),jt=require('decimal.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var jt__default=/*#__PURE__*/_interopDefault(jt);var xt=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();}};var Li="https://api.idosgames.com";function Gi(u){return {titleID:u.titleID,titleTemplateID:u.titleTemplateID??"default",buildKey:u.buildKey??"",baseUrl:(u.baseUrl??Li).replace(/\/+$/,""),devBuild:u.devBuild??false,debugLogging:u.debugLogging??false}}var at=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{}}},lt=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 ut(){return globalThis.Telegram?.WebApp??null}function M(){return crypto.randomUUID()}var Ni="idos_device_id",ct=class{storage;constructor(e=new at){this.storage=e;}getPlatform(){return ut()?.platform??"Web"}getFullURL(){return typeof location<"u"?location.href:""}getStartParameter(){let e=ut()?.initDataUnsafe?.start_param;return typeof e=="string"?e:null}getTelegramInitDataRaw(){let e=ut()?.initData;return e&&e.length>0?e:null}getDeviceID(){let e=this.storage.getString(Ni);return e||(e=M(),this.storage.setString(Ni,e)),e}getDeviceModel(){return typeof navigator<"u"&&navigator.userAgent?navigator.userAgent:"Web"}shareLink(e){let t=ut();if(t?.openTelegramLink){t.openTelegramLink(e);return}typeof window<"u"&&window.open(e,"_blank");}openInvoice(e){let t=ut();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 ji(u){return {ok:true,data:u}}function n(u,e){return {ok:false,reason:u,error:e}}function rl(u){return u.ok}function il(u){return !u.ok}var we={Virtual:"Virtual",Crypto:"Crypto"},pt=zod.z.enum(["Virtual","Crypto"]),nl={Item:"Item",VirtualCurrency:"VirtualCurrency",CryptoCurrency:"CryptoCurrency",UsdCent:"UsdCent"},Ot=zod.z.enum(["Item","VirtualCurrency","CryptoCurrency","UsdCent"]),ol={TimedEvent:"TimedEvent",Quest:"Quest",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season"},Bt=zod.z.enum(["TimedEvent","Quest","Leaderboard","CoopEvent","Season"]),al={Cyclic:"Cyclic",Scheduled:"Scheduled",Chained:"Chained"},Dt=zod.z.enum(["Cyclic","Scheduled","Chained"]),le={None:"None",Device:"Device",Email:"Email",iDosGames:"iDosGames",Facebook:"Facebook",Google:"Google",GooglePlay:"GooglePlay",Telegram:"Telegram",Wallet:"Wallet"};var k=zod.z.union([zod.z.number(),zod.z.string()]).transform((u,e)=>{let t=typeof u=="string"?Number(u):u;return Number.isFinite(t)?Math.trunc(t):(e.addIssue({code:zod.z.ZodIssueCode.custom,message:`Invalid integer amount: ${String(u)}`}),zod.z.NEVER)}),w=zod.z.union([zod.z.number(),zod.z.string()]).transform((u,e)=>{let t=typeof u=="number"?String(u):u.trim();return t===""||Number.isNaN(Number(t))?(e.addIssue({code:zod.z.ZodIssueCode.custom,message:`Invalid decimal: ${String(u)}`}),zod.z.NEVER):t}),a=zod.z.string();var Ur=zod.z.object({Type:Ot.nullish(),CurrencyID:zod.z.string().nullish(),Amount:k.nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish()}),ll=zod.z.object({Type:Bt.nullish(),EntityID:zod.z.string()}),ul=zod.z.object({Address:ll.nullish(),Amount:k.nullish(),Source:zod.z.string().nullish()}),oe=zod.z.object({Entries:zod.z.array(Ur).nullish(),EventTokens:zod.z.array(ul).nullish()}),Fi=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Resources:oe.nullish()}),G=zod.z.object({Standard:oe.nullish(),PremiumBonuses:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(Fi).nullish()}),H=zod.z.object({Standard:oe.nullish(),PremiumDiscounts:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(Fi).nullish()}),x=zod.z.object({Grant:G.nullish(),Consume:H.nullish()}),tt=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:oe.nullish()});var cl=zod.z.object({ExperimentID:zod.z.string().nullish(),Variants:zod.z.array(zod.z.string()).nullish()}).passthrough(),V=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:cl.nullish()}).passthrough();var ce=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 pl=zod.z.object({OffsetSecondsFromParentStart:zod.z.number().nullish(),DurationSeconds:zod.z.number().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),dl=zod.z.object({StartUtc:zod.z.string().nullish(),EndUtc:zod.z.string().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),ml=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 hl=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 We=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:ce.nullish()}).passthrough(),ue=zod.z.object({Mode:zod.z.string().nullish(),IsActive:zod.z.boolean().nullish(),Scheduled:dl.nullish(),Chain:ml.nullish(),Cyclic:hl.nullish(),ActivationTriggers:zod.z.array(We).nullish(),Relative:pl.nullish()}).passthrough();var fl=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Rewards:G.nullish()}).passthrough(),gl=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),wr=zod.z.object({Bundles:zod.z.array(fl).nullish(),Multipliers:zod.z.array(gl).nullish()}).passthrough();var Rl=zod.z.enum(["BoardStageLevel","BoardRank","BoardCyclesCompleted","CharacterLevel","SeasonTier","EventTokenTotalEarned","VirtualCurrencyBalance","PlayerLevel"]);var yl=zod.z.enum(["Tiered","Linear"]);var Cl=zod.z.enum(["Step","Linear"]),Sl=zod.z.object({AtProgress:zod.z.number().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),Ut=zod.z.object({Source:Rl.nullish(),SourceKey:zod.z.string().nullish(),CurveType:yl.nullish(),Tiers:zod.z.array(Sl).nullish(),TierMode:Cl.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:oe.nullish(),ExcludeRewards:oe.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:wr.nullish(),SortOrder:zod.z.number().nullish(),IsFeatured:zod.z.boolean().nullish()}).passthrough(),Ye=zod.z.object({Milestones:zod.z.record(zod.z.string(),ye).nullish()}).passthrough();var pe=zod.z.object({PresetID:zod.z.string().nullish(),Remove:zod.z.array(zod.z.string()).nullish()}).passthrough();var xl=zod.z.object({TargetCurrencyID:zod.z.string().nullish(),Rate:zod.z.number().nullish(),MaxConvertAmount:zod.z.number().nullish()}).passthrough(),st=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:xl.nullish()}).passthrough();var te=u=>zod.z.object({Id:zod.z.string(),Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:u.nullish()}),qt=u=>zod.z.object({ServerTimeUtc:a,Items:zod.z.array(te(u)),Resources:x.nullish()});var Dl={Active:"Active",Completed:"Completed",Claimed:"Claimed",Expired:"Expired"},_i=zod.z.enum(["Active","Completed","Claimed","Expired"]),bl=zod.z.object({}).passthrough().transform(u=>u),zl=zod.z.object({CycleID:zod.z.string(),InstanceKey:zod.z.string().nullish(),PhaseID:zod.z.string().nullish(),CycleIndex:zod.z.number().nullish(),CycleStartUtc:a.nullish(),CycleEndUtc:a.nullish(),PointsTotalEarned:k.nullish(),PointsCurrent:k.nullish(),ClaimedPointMilestoneIDs:zod.z.array(zod.z.string()).nullish()}),qr=zod.z.object({QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),ObjectiveID:zod.z.string().nullish(),NewValue:k.nullish(),ObjectiveCompleted:zod.z.boolean().nullish(),Status:_i}),Wi=zod.z.object({State:bl.nullish(),PointsTracks:zod.z.record(zod.z.string(),zl).nullish()}),Er=zod.z.object({ServerTimeUtc:a,QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),NewStatus:_i.nullish(),Resources:x.nullish()}),Lr=zod.z.object({ServerTimeUtc:a,CycleID:zod.z.string(),MilestoneID:zod.z.string(),PointsTotalEarned:k.nullish(),Resources:x.nullish()}),Vi=zod.z.object({ServerTimeUtc:a,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()}),Qi=zod.z.object({MetricID:zod.z.string(),Updates:zod.z.array(qr).nullish()}),Hi=zod.z.array(te(Er)),Ki=zod.z.array(te(Lr)),vl={ClientApi:"ClientApi",ServerApi:"ServerApi",SystemEvent:"SystemEvent"},Tl=zod.z.enum(["ClientApi","ServerApi","SystemEvent"]),Pl={BlockProgressAndClaim:"BlockProgressAndClaim",BlockClaimOnly:"BlockClaimOnly"},Il=zod.z.enum(["BlockProgressAndClaim","BlockClaimOnly"]),Ml=zod.z.object({ObjectiveID:zod.z.string().nullish(),Source:Tl.nullish(),MaxProgressPerCall:zod.z.number().nullish(),MetricID:zod.z.string().nullish(),Triggers:zod.z.array(We).nullish(),TargetValue:zod.z.number().nullish(),AggregationMethod:zod.z.string().nullish()}).passthrough(),kl=zod.z.object({QuestID:zod.z.string().nullish(),CycleIDs:zod.z.array(zod.z.string()).nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),RequiredQuestIDs:zod.z.array(zod.z.string()).nullish(),PrerequisiteMode:Il.nullish(),PointsReward:zod.z.number().nullish(),Schedule:ue.nullish(),AccrueProgressWhenLocked:zod.z.boolean().nullish(),Gate:V.nullish(),Limits:ce.nullish(),GroupID:zod.z.string().nullish(),PhaseIDs:zod.z.array(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(),Objectives:zod.z.record(zod.z.string(),Ml).nullish(),Reward:G.nullish()}).passthrough(),Al=zod.z.object({CompletionID:zod.z.string().nullish(),GroupID:zod.z.string().nullish(),RequiredCompletedQuests:zod.z.number().nullish(),Gate:V.nullish(),Reward:G.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),$i=zod.z.object({Milestones:pe.nullish()}).passthrough(),Ol=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:V.nullish(),Milestones:zod.z.record(zod.z.string(),ye).nullish(),Presets:$i.nullish(),PointsToken:st.nullish()}).passthrough(),Bl=zod.z.object({Milestones:zod.z.record(zod.z.string(),Ye).nullish()}).passthrough(),Ul=zod.z.object({CycleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:ue.nullish(),Milestones:zod.z.record(zod.z.string(),ye).nullish(),Gate:V.nullish(),PointsToken:st.nullish(),GroupCompletions:zod.z.record(zod.z.string(),Al).nullish(),Phases:zod.z.record(zod.z.string(),Ol).nullish(),Presets:$i.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Et=zod.z.object({Cycles:zod.z.record(zod.z.string(),Ul).nullish(),Quests:zod.z.record(zod.z.string(),kl).nullish(),Presets:Bl.nullish()}).passthrough(),Ee={GetQuestDefinitions:"GetQuestDefinitions",GetUserQuestState:"GetUserQuestState",RefreshQuestCycles:"RefreshQuestCycles",ClaimQuestReward:"ClaimQuestReward",ClaimMilestoneReward:"ClaimMilestoneReward",AddQuestProgress:"AddQuestProgress",ClaimQuestRewardsBatch:"ClaimQuestRewardsBatch",ClaimMilestoneRewardsBatch:"ClaimMilestoneRewardsBatch",ClaimGroupCompletionReward:"ClaimGroupCompletionReward"};var Lt=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 Gt=class{set=new Set;add(e){return this.set.has(e)?false:(this.set.add(e),true)}remove(e){this.set.delete(e);}};function Zi(u){return u===429||u>=500&&u<=599}function Gr(u,e=Math.random){let t=Math.min(500*Math.pow(2,u-1),4e3),s=t*.2*(e()*2-1);return Math.max(50,t+s)}function Nr(u){return new Promise(e=>setTimeout(e,u))}var wl=12e3,ql=zod.z.object({Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:zod.z.unknown().optional(),QuestProgress:zod.z.array(qr).nullish()}).passthrough(),Nt=class{baseUrl;emitter;fetchImpl;debugLogging;throttler;inflight=new Gt;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 Lt(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),m=r.ticket??null,v=r.silent??!1,U=r.timeoutMs??wl,q=r.autoRetry??!0,he=!1,ge=0;for(;;){let Ie;try{Ie=await this.doFetch(i,c,m,U);}catch{if(q&&ge<3){ge++,await Nr(Gr(ge));continue}return this.connectionFailure("Internet Connection Error",v)}let Me=Ie.status;if(Me>=200&&Me<300)return await this.parseSuccess(Ie,s,v,e);if(Me===401){if(!he&&this.sessionRefreshHandler){he=!0;let Ze=null;try{Ze=await this.sessionRefreshHandler();}catch{Ze=null;}if(Ze){m=Ze;continue}}return this.emitter.emit("auth:unauthorized",void 0),n("unauthorized","Unauthorized")}if(Zi(Me)){if(q&&ge<3){ge++,await Nr(Gr(ge));continue}return this.connectionFailure(`Server temporarily unavailable (HTTP ${Me})`,v)}return await this.handleWebError(Ie,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 m={"Content-Type":"application/json"};return s&&(m.Authorization=`Bearer ${s}`),await this.fetchImpl(e,{method:"POST",body:t,headers:m,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 m=ql.safeParse(c);if(!m.success)return this.globalError("Malformed response envelope",s);if(!m.data.Success){let q=m.data.Error??"Server returned Success=false";return s||this.emitter.emit("error:global",q),n("server",q)}let v=m.data.QuestProgress;v&&v.length>0&&this.emitter.emit("quest:systemProgress",v);let U=t.safeParse(m.data.Data);if(!U.success){let q=`Validation error (${r}): ${U.error.message}`;return this.debugLogging&&console.warn("[HttpTransport]",q),s||this.emitter.emit("error:global",q),n("validation",q)}return ji(U.data)}async handleWebError(e,t,s){let r=`HTTP ${t}`;try{let i=await e.text();if(i)try{let m=JSON.parse(i).Error;r=typeof m=="string"&&m.length>0?`HTTP ${t}: ${m}`:`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 mt(u){return (typeof u=="string"?u:u.toISOString()).slice(0,10)}function zt(u){return `${mt(u)}T00:00:00.000Z`}function Yi(u){let e=new Date(u);return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+1)).toISOString()}function Xi(u,e){return new Date(u.getTime()+e*6e4).toISOString()}function en(u,e,t,s){let r={vcChanged:false,ccChanged:false,itemsChanged:false,tokensChanged:false};if(!e)return r;u.InventoryV2??={};let i=u.InventoryV2,c=s.toISOString(),m=new Map,v=new Map,U=new Map,q=new Map,he=new Map,ge=new Map,Ie=new Map,Me=new Map,Ze=e.Grant?.PremiumTiers??[],kt=Ze.length;for(let ee=0;;ee++){let ne,Q;if(ee===0)ne=e.Grant?.Standard?.Entries,Q=false;else if(ee-1<kt)ne=Ze[ee-1]?.Resources?.Entries,Q=false;else if(ee===1+kt)ne=e.Consume?.Standard?.Entries,Q=true;else break;if(ne)for(let N of ne){if(N.Type==null)continue;let _=Math.max(0,N.Amount??0);if(!(_<=0))switch(N.Type){case "VirtualCurrency":{if(!N.CurrencyID)continue;let W=Q?v:m;W.set(N.CurrencyID,(W.get(N.CurrencyID)??0)+_);break}case "CryptoCurrency":{if(!N.CurrencyID)continue;let W=Q?q:U;W.set(N.CurrencyID,(W.get(N.CurrencyID)??new jt__default.default(0)).plus(_));break}case "Item":{if(!N.ItemID)continue;let W=Ll(t,N.CatalogID,N.ItemID),Y=(W?W.IsStackable??true:true)?Q?ge:he:Q?Me:Ie;Y.set(N.ItemID,(Y.get(N.ItemID)??0)+_);break}case "UsdCent":continue}}}if(r.vcChanged=m.size>0||v.size>0,r.vcChanged){i.VirtualCurrencies??={};for(let ee of new Set([...m.keys(),...v.keys()])){let ne=m.get(ee)??0,Q=v.get(ee)??0,N=ne-Q,_=i.VirtualCurrencies[ee];_?(_.Amount+=N,_.UpdatedAt=c,_.Daily&&mt(_.Daily.PeriodStartUtc)===mt(s)?(_.Daily.Earned+=ne,_.Daily.Spent+=Q):_.Daily={PeriodStartUtc:zt(s),Earned:ne,Spent:Q}):i.VirtualCurrencies[ee]={Amount:N,CreatedAt:c,UpdatedAt:c,Daily:{PeriodStartUtc:zt(s),Earned:ne,Spent:Q}};}}if(r.ccChanged=U.size>0||q.size>0,r.ccChanged){i.CryptoCurrencies??={};for(let ee of new Set([...U.keys(),...q.keys()])){let ne=U.get(ee)??new jt__default.default(0),Q=q.get(ee)??new jt__default.default(0),N=ne.minus(Q),_=i.CryptoCurrencies[ee];_?(_.Amount=new jt__default.default(_.Amount).plus(N).toString(),_.UpdatedAt=c):i.CryptoCurrencies[ee]={Amount:N.toString(),Frozen:"0",CreatedAt:c,UpdatedAt:c};}}if(r.itemsChanged=he.size>0||ge.size>0||Ie.size>0||Me.size>0,r.itemsChanged){i.Items??={},i.UnstackableItems??={};let ee=i.UnstackableItems,ne=new Set([...he.keys(),...ge.keys(),...Ie.keys(),...Me.keys()]);for(let Q of ne){let N=(he.get(Q)??0)-(ge.get(Q)??0),_=(Ie.get(Q)??0)-(Me.get(Q)??0),W=N+_,ke=i.Items[Q];ke?(N!==0&&(ke.StackableAmount+=N),_!==0&&(ke.UnstackableAmount+=_),W!==0&&(ke.TotalAmount+=W)):i.Items[Q]={StackableAmount:Math.max(0,N),UnstackableAmount:Math.max(0,_),TotalAmount:Math.max(0,W)};}for(let[Q,N]of Me){if(N<=0)continue;let _=Object.values(ee).filter(W=>W.ItemID===Q&&W.EquippedSlot==null&&(W.ExpiresAt==null||new Date(W.ExpiresAt)>s)).sort(El).slice(0,N).map(W=>W.ItemInstanceID);for(let W of _)delete ee[W];}for(let[Q,N]of Ie){let _=Gl(t,Q);for(let W=0;W<N;W++){let ke=M();ee[ke]={ItemInstanceID:ke,ItemID:Q,CatalogID:_,RemainingUses:1,AcquiredAt:c};}}}u.EventToken??={};let sl=u.EventToken;for(let ee=0;;ee++){let ne,Q;if(ee===0)ne=e.Grant?.Standard?.EventTokens,Q=false;else if(ee-1<kt)ne=Ze[ee-1]?.Resources?.EventTokens,Q=false;else if(ee===1+kt)ne=e.Consume?.Standard?.EventTokens,Q=true;else break;if(!(!ne||ne.length===0))for(let N of ne){let _=N.Address;if(!_||_.Type==null)continue;let W=N.Amount??0;if(W<=0)continue;let ke=Nl(sl,_.Type);if(!ke)continue;let Y=ke[_.EntityID];Y||(Y={},ke[_.EntityID]=Y),Y.Balance??={Current:0,TotalEarned:0,TotalSpent:0},Y.Daily??={Date:zt(s),TotalEarned:0},Y.Meta??={};let St=N.Source&&N.Source.length>0?N.Source:"CustomAction";Q?(Y.Balance.Current-=W,Y.Balance.TotalSpent+=W):(Y.Balance.Current+=W,Y.Balance.TotalEarned+=W,mt(Y.Daily.Date)!==mt(s)&&(Y.Daily={Date:zt(s),TotalEarned:0}),Y.Daily.TotalEarned+=W,Y.Daily.EarnedBySource??={},Y.Daily.EarnedBySource[St]=(Y.Daily.EarnedBySource[St]??0)+W,Y.Daily.TriggersBySource??={},Y.Daily.TriggersBySource[St]=(Y.Daily.TriggersBySource[St]??0)+1,Y.Daily.LastTriggerBySource??={},Y.Daily.LastTriggerBySource[St]=c,Y.Meta.JoinedAtUtc||(Y.Meta.JoinedAtUtc=c),Y.Meta.LastEarnedAtUtc=c),r.tokensChanged=true;}}return r}function El(u,e){return u.AcquiredAt!==e.AcquiredAt?u.AcquiredAt<e.AcquiredAt?-1:1:u.ItemInstanceID===e.ItemInstanceID?0:u.ItemInstanceID<e.ItemInstanceID?-1:1}function Ll(u,e,t){let s=u?.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 Gl(u,e){let t=u?.Catalogs;if(t){for(let[s,r]of Object.entries(t))if(r.Items&&e in r.Items)return s}}function Nl(u,e){switch(e){case "TimedEvent":return u.TimedEvent??={};case "Quest":return u.Quest??={};case "Leaderboard":return u.Leaderboard??={};case "CoopEvent":return u.CoopEvent??={};case "Season":return u.Season??={};default:return null}}function jr(u,e){return u===e||u.startsWith(`${e}:`)}var Ft=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);}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=en(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 jt__default.default?t:new jt__default.default(t),c=s??new Date().toISOString(),m=r[e];m?(m.Amount=new jt__default.default(m.Amount).plus(i).toString(),m.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=Yi(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(jr(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))!jr(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,m={Value:s,UpdatedAt:new Date().toISOString(),Version:r,LastWriter:"Client",ExpiresAt:i??null};if(e==="Private")c.Private??={},c.Private[t]=m;else if(e==="Public")c.Public??={},c.Public[t]=m;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 Ft(e),this.config=new _t;}reset(){this.user.clear(),this.config.applyTitlePublicConfiguration(null);}};var Vt=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 jl(e)?e:le.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 jl(u){return u!==null&&Object.values(le).includes(u)}var Fl=8,_l=100,Wl=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i,tn=["GameLoop"],Qt=class{constructor(e){this.ctx=e;}ctx;authContext=null;refreshing=false;rememberSession=true;sessionAuthType=le.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(le.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(le.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(le.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(le.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(le.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(le.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(le.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 le.Email:return this.loginWithEmail(t,s);case le.Device:case le.None:return this.loginWithDeviceID();case le.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!==le.None?this.sessionAuthType:this.ctx.authStore.lastAuthType;if(e===le.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&&Wl.test(e)}static isValidPasswordLength(e){return e.length>=Fl&&e.length<=_l}keepEmailCredentials(e,t){this.sessionEmail=e,this.sessionPassword=t,this.rememberSession&&this.ctx.authStore.saveEmailAndPassword(e,t);}forgetSession(){this.sessionAuthType=le.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(tn,tn);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 Ht=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:M()}:null}async getClientState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getClientState(e);return t.ok&&this.applyClientState(t.data),t}async getClientStateExcept(e,t){let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.ExcludeFields=e,s.ExcludeTitleFields=t;let r=await this.ctx.api.user.getClientStateExcept(s);return r.ok&&this.applyClientState(r.data,e,t),r}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}applyClientState(e,t,s){let r=t?.includes("GameLoop")===true,i=s?.includes("GameLoop")===true,c=r?this.ctx.data.user.state?.GameLoop:void 0,m=i?this.ctx.data.config.titlePublicConfiguration?.GameLoop:void 0;this.ctx.data.config.applyTitlePublicConfiguration(e.Title),this.ctx.data.user.applyUserState(e.User??{});let v=this.ctx.data.user.state;r&&v&&v.GameLoop==null&&(v.GameLoop=c);let U=this.ctx.data.config.titlePublicConfiguration;i&&U&&U.GameLoop==null&&(U.GameLoop=m),this.ctx.emitter.emit("user:clientStateReceived",e);}};var $t=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===we.Crypto||s===we.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 m={...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}_${M()}`},v=await this.ctx.api.currency.convert(m);if(v.ok){let U=v.data,q={Consume:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:U.SourceID,Amount:U.SourceSpent}]}},Grant:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:U.TargetID,Amount:U.TargetCredited}]}}};this.ctx.data.user.applyResourceOperation(q,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("currency:converted",U);}return v}async cryptoConvert(e,t,s,r,i,c){let m=i instanceof jt__default.default?i:new jt__default.default(i);if(!t)return n("client","SourceID is required.");if(!r)return n("client","TargetID is required.");if(m.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===we.Virtual&&s===we.Virtual)return n("client","cryptoConvert requires at least one crypto side. Use convert for VC\u2194VC.");if(e===we.Virtual&&!m.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:m.toString(),TransactionID:c&&c.length>0?c:`crypto_convert_${e}_${t}_to_${s}_${r}_${M()}`},U=await this.ctx.api.currency.cryptoConvert(v);if(U.ok){let q=U.data,he=[],ge=[];if(q.SourceType===we.Virtual&&he.push({Type:"VirtualCurrency",CurrencyID:q.SourceID,Amount:Math.trunc(Number(q.SourceSpent))}),q.TargetType===we.Virtual&&ge.push({Type:"VirtualCurrency",CurrencyID:q.TargetID,Amount:Math.trunc(Number(q.TargetCredited))}),he.length>0||ge.length>0){let Ie={Consume:he.length>0?{Standard:{Entries:he}}:null,Grant:ge.length>0?{Standard:{Entries:ge}}:null};this.ctx.data.user.applyResourceOperation(Ie,this.ctx.data.config.itemDefinitions);}q.SourceType===we.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(q.SourceID,new jt__default.default(q.SourceSpent).negated(),q.ServerTimeUtc),q.TargetType===we.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(q.TargetID,new jt__default.default(q.TargetCredited),q.ServerTimeUtc),this.ctx.emitter.emit("currency:cryptoConverted",q);}return U}};var Zt=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}_${M()}`};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 Vl="Store",Jt=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}_${M()}`},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(Vl,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 Ql="Lootbox",Yt=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(Ql,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}_${M()}`},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 Hl="Reward";function _r(u){return u.length>0&&!u.includes(".")&&!u.includes("$")}var Xt=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(Hl,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"}_${M()}`},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}_${M()}`},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}_${M()}`},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}_${M()}`},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 Kl="Quest",es=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(Kl,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}_${M()}`},c=await this.ctx.api.quest.claimQuestReward(i);if(c.ok){let m=c.data;this.ctx.data.user.patchQuestStatus(m.QuestID,m.CycleID,"Claimed"),this.ctx.data.user.applyResourceOperation(m.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:rewardClaimed",m);}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}_${M()}`},c=await this.ctx.api.quest.claimMilestoneReward(i);if(c.ok){let m=c.data;this.ctx.data.user.patchMilestoneClaimed(m.CycleID,m.MilestoneID),this.ctx.data.user.applyResourceOperation(m.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:milestoneClaimed",m);}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}_${M()}`},c=await this.ctx.api.quest.claimGroupCompletionReward(i);if(c.ok){let m=c.data;this.ctx.data.user.patchGroupCompletionClaimed(m.CycleID,m.GroupCompletionID),this.ctx.data.user.applyResourceOperation(m.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:groupCompletionClaimed",m);}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 $l="TimedEvent",ts=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($l,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,m=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:m},U=await this.ctx.api.timedEvent.grantTokens(v);return U.ok&&(this.ctx.data.user.applyResourceOperation(U.data,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensGranted",U.data)),U}async spendTokens(e,t,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 Zl="Leaderboard",ss=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(Zl,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},m=await this.ctx.api.leaderboard.submitScoreFromSource(c);if(m.ok){let v=m.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),v.NewScore,v.NewScore,v.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",v);}return m}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 Jl="Season",rs=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(Jl,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}_${M()}`},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}_${M()}`},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 Yl="Premium",is=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(Yl,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 m=c.data;m.Premium&&this.ctx.data.user.applyPremium(m.Premium),this.ctx.data.user.applyResourceOperation(m.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:purchaseCompleted",m);}return c}async purchaseRealMoney(e,t,s,r,i,c,m,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 U={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,Store:s,ProductID:r,ReceiptData:i,PurchaseToken:c,PackageName:m,AppStoreEnvironment:v,RelatedEntityID:`premium_iap_${e}_${t}`},q=await this.ctx.api.premium.purchaseRealMoney(U);if(q.ok){let he=q.data;he.Premium&&this.ctx.data.user.applyPremium(he.Premium),this.ctx.data.user.applyResourceOperation(he.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:realMoneyPurchaseCompleted",he);}return q}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Xl="Character",ns=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(Xl,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}_${M()}`},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}_${M()}`,...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,m=>{m.StatLevels??={},m.StatLevels[c.StatID]=c.StatLevel,c.Power!=null&&(m.Power=c.Power),m.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}_${M()}`,...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 eu="Match",os=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 m={...this.ctx.buildAuthedBaseRequest(),Entry:e,RuleID:t,CharacterID:s,BattleStrategy:r,TargetUserID:i,RelatedEntityID:`pvp_create_${c.userID}_${M()}`},v=await this.ctx.api.match.createMatch(m);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}_${M()}`},m=await this.ctx.api.match.instantBattle(c);if(m.ok){let v=m.data,U=this.ctx.data.config.itemDefinitions;if(v.Resources)this.ctx.data.user.applyResourceOperation(v.Resources,U);else if(v.ResourcesDual){let q=v.ResourcesDual;q.FromUserID===i.userID&&q.FromResult?this.ctx.data.user.applyResourceOperation(q.FromResult,U):q.ToUserID===i.userID&&q.ToResult&&this.ctx.data.user.applyResourceOperation(q.ToResult,U);}this.ctx.emitter.emit("match:instantBattleCompleted",v);}return m}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(eu,t.data),this.ctx.emitter.emit("match:definitionsLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var tu="Craft",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.craft.getDefinitions(e);return t.ok&&t.data.CraftDefinitions&&(this.ctx.data.config.patchSection(tu,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}_${M()}`},m=await this.ctx.api.craft.craft(c);return m.ok&&(this.ctx.data.user.applyResourceOperation(m.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("craft:completed",m.data)),m}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var su="Collection",ls=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(su,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}_${M()}`},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}_${M()}`},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}_${M()}`},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}_${M()}`},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}_${M()}`},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 m=this.ctx.auth.context;if(!m)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_${m.userID}_${r}_${M()}`},U=await this.ctx.api.collection.sendTradeOffer(v);return U.ok&&this.ctx.emitter.emit("collection:tradeOfferSent",U.data),U}async cancelTradeOffer(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),OfferID:e,RelatedEntityID:`trade_cancel_${e}_${M()}`},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}_${M()}`},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}_${M()}`},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 ru="CoopEvent",us=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(ru,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:M()},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",cs=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}_${M()}`},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}_${M()}`},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}_${M()}`},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}_${M()}`},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}_${M()}`},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 nu="Referral",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.referral.getDefinitions(e);return t.ok&&t.data.ReferralDefinitions&&(this.ctx.data.config.patchSection(nu,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 ds=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 ou="TimedBoost";function au(u){return u.length>0&&!u.includes(".")&&!u.includes("$")}var 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.timedBoost.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(ou,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}_${M()}`},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 Ve={Private:"Private",Public:"Public",ReadOnly:"ReadOnly",Internal:"Internal"},lu={Client:"Client",Server:"Server",System:"System"},uu=zod.z.enum(["Client","Server","System"]),cu=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:a.nullish(),Version:zod.z.number().nullish(),LastWriter:uu.nullish(),ExpiresAt:a.nullish()}).passthrough(),hs=zod.z.record(zod.z.string(),cu),sn=zod.z.object({Version:zod.z.number().nullish(),Private:hs.nullish(),Public:hs.nullish(),ReadOnly:hs.nullish()}),Wr=zod.z.object({UserID:zod.z.string().nullish(),Version:zod.z.number().nullish(),Public:hs.nullish()}),Vr=zod.z.object({ServerTimeUtc:a.nullish(),Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:a.nullish()}),pu=zod.z.object({Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:a.nullish()}),rn=zod.z.object({ServerTimeUtc:a.nullish(),Results:zod.z.array(pu).nullish()}),nn=zod.z.object({ServerTimeUtc:a.nullish(),DeletedCount:zod.z.number().nullish()}),on=zod.z.object({Results:zod.z.array(Wr).nullish(),NotFoundUserIDs:zod.z.array(zod.z.string()).nullish()}),du={String:"String",Int:"Int",Bool:"Bool",Json:"Json"},mu=zod.z.enum(["String","Int","Bool","Json"]),hu=zod.z.object({KeyID:zod.z.string(),Bucket:zod.z.string().nullish(),ValueType:mu.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),fs=zod.z.object({Keys:zod.z.record(zod.z.string(),hu).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(),Le={GetUserCustomDataDefinitions:"GetUserCustomDataDefinitions",GetMyUserCustomData:"GetMyUserCustomData",GetPublicUserCustomDataOf:"GetPublicUserCustomDataOf",SetPrivateData:"SetPrivateData",SetPublicData:"SetPublicData",DeleteKey:"DeleteKey",BatchSet:"BatchSet",BatchDelete:"BatchDelete",BatchGetPublicUserCustomDataOf:"BatchGetPublicUserCustomDataOf"};var fu="UserCustomData";function an(u){return u.length>0&&!u.includes(".")&&!u.includes("$")}var gs=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(fu,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,Ve.Private)}async setPublicData(e,t){return this.setData(e,t,Ve.Public)}async setData(e,t,s){let r=e.trim();if(!an(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},m=await(s===Ve.Private?this.ctx.api.userCustomData.setPrivateData(i):this.ctx.api.userCustomData.setPublicData(i));if(m.ok){let v=m.data;this.ctx.data.user.patchUserCustomDataKey(s,v.KeyID,t,v.Version??0,v.ExpiresAt),this.ctx.emitter.emit(s===Ve.Private?"userCustomData:privateDataSet":"userCustomData:publicDataSet",v);}return m}async deleteKey(e,t){let s=e.trim();if(!an(s))return n("client",'KeyID is required and must not contain "." or "$".');if(t!==Ve.Private&&t!==Ve.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??Ve.Private,c=e.find(m=>m.Bucket===i&&m.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 gu="TitleCustomDataDefinitions",ln=50;function Ru(u){return u.length>0&&!u.includes(".")&&!u.includes("$")}function Qr(u){if(u.ExpiresAt==null)return false;let e=Date.parse(u.ExpiresAt);return !Number.isNaN(e)&&e<=Date.now()}function yu(u){let e={};for(let[t,s]of Object.entries(u))Qr(s)||(e[t]=s);return e}var Rs=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(gu,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=>!Ru(i)))return n("client",'KeyID must not contain "." or "$".');if(t.length>ln)return n("client",`At most ${ln} 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&&!Qr(t))return t.Value;let s=this.staticCache[e];if(s?.Value!=null&&!Qr(s))return s.Value}get runtimeVersion(){return this.lastRuntimeVersion}staticCache={};absorb(e){e.Static&&(this.staticCache=e.Static),e.NotModified?(this.runtimeCache=yu(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 ys=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 Cu=15,Su="GameLoop",xu="BoardDefinition",Cs=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(Su,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(xu,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}_${M()}`},r=await this.ctx.api.gameLoop.boardLoopRoll(s);if(r.ok){let i=r.data,c=Xi(new Date,Cu);this.ctx.data.user.patchBoardState(m=>{m.Position=i.NewPosition,m.CyclesCompleted=(m.CyclesCompleted??0)+(i.CyclesCompletedDelta??0),m.LastRollAtUtc=new Date().toISOString(),i.ActionRequired&&i.ActionData?m.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&&(m.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}_${M()}`},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}_${M()}`},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}_${M()}`},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}_${M()}`},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}_${M()}`},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(m=>{m.ChoiceID=e,m.ChosenMode=i.Mode??"Timed",m.StartedAtUtc=i.StartedAtUtc??null,m.DurationSeconds=i.DurationSeconds??null,m.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}_${M()}`},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}_${M()}`},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 Ss=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},m=await this.ctx.api.cloudCode.execute(c);return m.ok&&this.ctx.emitter.emit("cloudCode:executed",m.data),m}};var un=zod.z.object({ServerTimeUtc:a,SourceType:pt,SourceID:zod.z.string(),TargetType:pt,TargetID:zod.z.string(),SourceSpent:k,FeeAmount:k,RateApplied:w,TargetCredited:k}),cn=zod.z.object({ServerTimeUtc:a,SourceType:pt,SourceID:zod.z.string(),TargetType:pt,TargetID:zod.z.string(),SourceSpent:w,FeeAmount:w,RateApplied:w,TargetCredited:w}),xs={Convert:"Convert",CryptoConvert:"CryptoConvert"},Du={Active:"Active",Hidden:"Hidden",Deprecated:"Deprecated",Maintenance:"Maintenance"},pn=zod.z.enum(["Active","Hidden","Deprecated","Maintenance"]),bu={Automatic:"Automatic",Manual:"Manual"},zu=zod.z.enum(["Automatic","Manual"]),vu=zod.z.object({ValueInUSD:w.nullish(),ValueInUSDUpdatedAt:a.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(),Tu=zod.z.object({Rate:zod.z.number().nullish(),Max:zod.z.number().nullish(),Period:zod.z.number().nullish()}).passthrough(),Pu=zod.z.object({IsTradable:zod.z.boolean().nullish(),IsPurchasable:zod.z.boolean().nullish(),IsRefundable:zod.z.boolean().nullish()}).passthrough(),Iu=zod.z.object({TargetCurrencyType:pt.nullish(),TargetCurrencyID:zod.z.string(),Rate:w.nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish(),DailyLimit:zod.z.number().nullish()}).passthrough(),dn=zod.z.object({Enabled:zod.z.boolean().nullish(),RateMode:zu.nullish(),FeePercent:w.nullish(),Targets:zod.z.array(Iu).nullish()}).passthrough(),mn=zod.z.object({CreatedAt:a.nullish(),UpdatedAt:a.nullish()}).passthrough(),Mu=zod.z.object({CurrencyID:zod.z.string(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Economy:vu.nullish(),Recharge:Tu.nullish(),Conversion:dn.nullish(),Permissions:Pu.nullish(),Audit:mn.nullish(),Status:pn.nullish()}).passthrough(),ku=zod.z.object({NetworkID:zod.z.string(),ContractAddress:zod.z.string().nullish(),Decimals:zod.z.number().nullish(),MinDeposit:w.nullish(),MinWithdraw:w.nullish(),WithdrawFee:w.nullish(),DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish()}).passthrough(),Au=zod.z.object({DailyWithdrawUsd:w.nullish(),MonthlyWithdrawUsd:w.nullish(),KycRequiredAboveUsd:w.nullish()}).passthrough(),Ou=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),SpendableInGame:zod.z.boolean().nullish(),ConvertibleToVirtual:zod.z.boolean().nullish()}).passthrough(),Hr=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:w.nullish(),ValueInUSDUpdatedAt:a.nullish(),DeveloperDepositSharePercent:w.nullish(),CommunityMarketingDepositSharePercent:w.nullish(),WithdrawalBurnPercent:w.nullish(),Networks:zod.z.array(ku).nullish(),Limits:Au.nullish(),Permissions:Ou.nullish(),Conversion:dn.nullish(),Audit:mn.nullish(),Status:pn.nullish()}).passthrough(),Ds=zod.z.object({VirtualCurrencies:zod.z.record(zod.z.string(),Mu).nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Hr).nullish()}).passthrough();var hn=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),ItemInstanceID:zod.z.string().nullish(),EquippedAt:a.nullish()}),Kr=zod.z.object({CharacterID:zod.z.string(),Level:zod.z.number().nullish(),Experience:k.nullish(),Power:zod.z.number().nullish(),StatLevels:zod.z.record(zod.z.string(),zod.z.number()).nullish(),Equipment:zod.z.record(zod.z.string(),hn).nullish(),UpdatedAt:a.nullish()}).passthrough(),Bu=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),Uu=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:a,ExpiresAt:a.nullish(),EquippedSlot:Bu.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(u=>u),Xe=zod.z.object({ChangedInstances:zod.z.record(zod.z.string(),Uu).nullish(),RemovedInstanceIDs:zod.z.array(zod.z.string()).nullish()}),fn=zod.z.object({Characters:zod.z.record(zod.z.string(),Kr).nullish()}),$r=zod.z.object({ServerTimeUtc:a,CharacterID:zod.z.string(),StatID:zod.z.string(),StatLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:x.nullish()}),Zr=zod.z.object({ServerTimeUtc:a,CharacterID:zod.z.string(),NewLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:x.nullish()}),gn=zod.z.object({ServerTimeUtc:a,CharacterID:zod.z.string(),Equipment:zod.z.record(zod.z.string(),hn).nullish(),ReplacedInstanceIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:Xe.nullish()}),Rn=zod.z.object({ServerTimeUtc:a,CharacterID:zod.z.string(),ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:Xe.nullish()}),wu=zod.z.object({ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish()}),yn=zod.z.object({ServerTimeUtc:a,Characters:zod.z.record(zod.z.string(),wu).nullish(),Inventory:Xe.nullish()}),Jr=zod.z.object({ServerTimeUtc:a,CharacterID:zod.z.string(),Power:zod.z.number().nullish(),Resources:x.nullish()}),Cn=qt(Jr),Sn=qt(Zr),xn=qt($r),Dn=zod.z.object({RequiredStatID:zod.z.string(),RequiredLevel:zod.z.number()}).passthrough(),bn=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:H.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(Dn).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),zn=zod.z.object({Level:zod.z.number().nullish(),UpgradeCost:H.nullish(),GlobalStatMultiplier:zod.z.number().nullish(),StatMaxLevelMultiplier:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),qu=zod.z.object({SlotID:zod.z.string(),MinCharacterLevel:zod.z.number().nullish(),StatRequirements:zod.z.array(Dn).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(),vn=zod.z.object({Slots:zod.z.record(zod.z.string(),qu).nullish()}).passthrough(),Eu=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(),Lu=zod.z.object({ClassID:zod.z.string().nullish(),RarityID:zod.z.string().nullish(),Tags:zod.z.array(zod.z.string()).nullish()}).passthrough(),Gu=zod.z.object({UnlockedByDefault:zod.z.boolean().nullish(),Cost:H.nullish()}).passthrough(),Nu=zod.z.object({Stats:pe.nullish(),Levels:pe.nullish(),Equipment:pe.nullish()}).passthrough(),ju=zod.z.object({CharacterID:zod.z.string(),Identity:Eu.nullish(),Classification:Lu.nullish(),Unlock:Gu.nullish(),Presets:Nu.nullish(),Equipment:vn.nullish(),Stats:zod.z.record(zod.z.string(),bn).nullish(),Levels:zod.z.record(zod.z.string(),zn).nullish()}).passthrough(),Fu=zod.z.object({Stats:zod.z.record(zod.z.string(),bn).nullish()}).passthrough(),_u=zod.z.object({Levels:zod.z.record(zod.z.string(),zn).nullish()}).passthrough(),Wu=zod.z.object({Equipment:vn.nullish()}).passthrough(),Vu=zod.z.object({Stats:zod.z.record(zod.z.string(),Fu).nullish(),Levels:zod.z.record(zod.z.string(),_u).nullish(),Equipment:zod.z.record(zod.z.string(),Wu).nullish()}).passthrough(),bs=zod.z.object({Definitions:zod.z.record(zod.z.string(),ju).nullish(),Presets:Vu.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 Qu={EVM:"EVM",Solana:"Solana"},Hu=zod.z.enum(["EVM","Solana"]),Ku={AutoLinkedFromTransaction:"AutoLinkedFromTransaction",SignatureVerified:"SignatureVerified",ManuallyLinked:"ManuallyLinked"},$u=zod.z.enum(["AutoLinkedFromTransaction","SignatureVerified","ManuallyLinked"]),Zu={Token:"Token",Nft:"Nft"},Tn=zod.z.enum(["Token","Nft"]),Ju={NotRequested:"NotRequested",Pending:"Pending",Verified:"Verified",Rejected:"Rejected",Expired:"Expired"},Yu=zod.z.enum(["NotRequested","Pending","Verified","Rejected","Expired"]),Xu={None:"None",Tier1:"Tier1",Tier2:"Tier2",Tier3:"Tier3"},ec=zod.z.enum(["None","Tier1","Tier2","Tier3"]),tc={Pending:"Pending",Completed:"Completed",Failed:"Failed",Expired:"Expired",Abandoned:"Abandoned"},Yr=zod.z.enum(["Pending","Completed","Failed","Expired","Abandoned"]),Pn={GameTopUp:"game_topup",CommunityReward:"community_reward"};function zs(u){let e=u?.trim();return e||Pn.GameTopUp}var sc={UsersCryptoWallet:"UsersCryptoWallet",Game:"Game"},In=zod.z.enum(["UsersCryptoWallet","Game"]),rc=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(),Mn=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:Hu.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:Mn.nullish(),NftCollections:zod.z.array(rc).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),nc=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),NftDepositsEnabled:zod.z.boolean().nullish(),NftWithdrawalsEnabled:zod.z.boolean().nullish(),PlatformOverrides:Mn.nullish()}).passthrough(),oc=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"]),lc=zod.z.object({Enabled:zod.z.boolean().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),MinBalance:w.nullish(),BalanceSource:ac.nullish(),DenyMessage:zod.z.string().nullish()}).passthrough(),uc=zod.z.object({Enabled:zod.z.boolean().nullish(),TokenGates:zod.z.array(lc).nullish(),WalletConnectProjectId:zod.z.string().nullish()}).passthrough(),Xr=zod.z.object({SystemState:nc.nullish(),Networks:zod.z.record(zod.z.string(),ic).nullish(),AccountSafety:oc.nullish(),WalletLogin:uc.nullish()}).passthrough(),cc=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),LinkedAt:a.nullish(),LastUsedAt:a.nullish(),LinkType:$u.nullish(),IsSignatureVerified:zod.z.boolean().nullish()}).passthrough(),kn=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Type:Tn.nullish(),NetworkID:zod.z.string().nullish(),AssetID:zod.z.string().nullish(),Amount:w.nullish(),CreatedAt:a.nullish(),ExpiresAt:a.nullish()}).passthrough(),pc=zod.z.object({Status:Yu.nullish(),Tier:ec.nullish(),VerifiedAt:a.nullish(),ExpiresAt:a.nullish(),RejectedAt:a.nullish(),ProviderReference:zod.z.string().nullish(),RejectionReason:zod.z.string().nullish()}).passthrough(),dc=zod.z.object({CurrencyID:zod.z.string().nullish(),Deposits:zod.z.number().nullish(),DepositsVolumeNative:w.nullish(),DepositsVolumeUsd:w.nullish(),Withdrawals:zod.z.number().nullish(),WithdrawalsVolumeNative:w.nullish(),WithdrawalsVolumeUsd:w.nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),FirstDepositAt:a.nullish(),LastDepositAt:a.nullish(),FirstWithdrawalAt:a.nullish(),LastWithdrawalAt:a.nullish()}).passthrough(),mc=zod.z.object({TotalDeposits:zod.z.number().nullish(),TotalWithdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),TotalDepositsVolumeUsd:w.nullish(),TotalWithdrawalsVolumeUsd:w.nullish(),PerCurrency:zod.z.record(zod.z.string(),dc).nullish()}).passthrough(),hc=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:a.nullish(),LastDepositAt:a.nullish(),FirstWithdrawalAt:a.nullish(),LastWithdrawalAt:a.nullish()}).passthrough(),fc=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(),hc).nullish()}).passthrough(),gc=zod.z.object({Tokens:mc.nullish(),Nfts:fc.nullish()}).passthrough(),Rc=zod.z.object({CurrencyID:zod.z.string().nullish(),Balance:w.nullish(),MinBalance:w.nullish()}).passthrough(),yc=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),CheckedAt:a.nullish(),LoggedInAt:a.nullish(),GatePassed:zod.z.boolean().nullish(),GatedBalances:zod.z.array(Rc).nullish()}).passthrough(),Cc=zod.z.object({Version:zod.z.number().nullish(),Stats:gc.nullish(),LinkedWallets:zod.z.record(zod.z.string(),cc).nullish(),LastWalletLogin:yc.nullish(),PendingWithdrawals:zod.z.array(kn).nullish(),Kyc:pc.nullish(),FirstActivityAt:a.nullish(),LastActivityAt:a.nullish(),IsFlagged:zod.z.boolean().nullish(),FlagReason:zod.z.string().nullish()}).passthrough(),Sc=zod.z.object({CurrencyID:zod.z.string(),AmountDelta:w,FrozenDelta:w,UpdatedAt:a}).passthrough(),vs=zod.z.object({CryptoBalances:zod.z.record(zod.z.string(),Sc).nullish(),PendingAdded:kn.nullish(),PendingRemovedIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),xc=zod.z.object({Amount:w,Frozen:w,CreatedAt:a.nullish(),UpdatedAt:a.nullish()}).passthrough().transform(u=>u),Dc=zod.z.object({ID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CreatedAt:a.nullish(),UpdatedAt:a.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:In.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:w.nullish(),Status:Yr.nullish(),SignatureData:zod.z.string().nullish(),CompletedAt:a.nullish(),ExpiresAt:a.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:w.nullish(),NetPayoutAmount:w.nullish()}).passthrough(),bc=zod.z.object({ID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CreatedAt:a.nullish(),UpdatedAt:a.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:In.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:w.nullish(),Status:Yr.nullish(),SignatureData:zod.z.string().nullish(),CompletedAt:a.nullish(),ExpiresAt:a.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(),ei=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(),Signature:zod.z.string().nullish()}).passthrough(),ti=zod.z.object({Mint:zod.z.string().nullish(),WalletAddress:zod.z.string().nullish(),Amount:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),ExpiresAt:zod.z.string().nullish(),ProgramID:zod.z.string().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()}).passthrough(),An=zod.z.object({Blockchain:Xr.nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Hr).nullish()}).passthrough(),On=zod.z.object({State:Cc.nullish(),CryptoBalances:zod.z.record(zod.z.string(),xc).nullish()}).passthrough(),Bn=zod.z.object({ServerTimeUtc:a.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:w.nullish(),AmountUsd:w.nullish(),StateDelta:vs.nullish()}).passthrough(),Un=zod.z.object({ServerTimeUtc:a.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:Xe.nullish()}).passthrough(),wn=zod.z.object({ServerTimeUtc:a.nullish(),TitleTransactionID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:w.nullish(),NetAmountNative:w.nullish(),BurnAmountNative:w.nullish(),AmountUsd:w.nullish(),ExpiresAt:a.nullish(),EvmSignature:ei.nullish(),SolanaSignature:ti.nullish(),StateDelta:vs.nullish()}).passthrough(),qn=zod.z.object({ServerTimeUtc:a.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:a.nullish(),Resources:x.nullish(),EvmSignature:ei.nullish(),SolanaSignature:ti.nullish(),StateDelta:vs.nullish(),Inventory:Xe.nullish()}).passthrough(),En=zod.z.object({TokenTransactions:zod.z.array(Dc).nullish(),NFTTransactions:zod.z.array(bc).nullish()}).passthrough(),si=zod.z.object({ServerTimeUtc:a.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:w.nullish(),AmountUsd:w.nullish(),Target:zod.z.string().nullish()}).passthrough(),Ln=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Kind:Tn.nullish(),EvmSignature:ei.nullish(),SolanaSignature:ti.nullish()}).passthrough(),Gn=zod.z.object({TitleTransactionID:zod.z.string().nullish(),OnChainTxHash:zod.z.string().nullish(),Status:Yr.nullish(),StateDelta:vs.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 zc="Blockchain",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.blockchain.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(zc,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 jt__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=zs(i);let m=await this.ctx.api.blockchain.requestTokenWithdrawal(c);return m.ok&&m.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(m.data.CurrencyID,new jt__default.default(m.data.AmountNative??0).negated(),m.data.ServerTimeUtc??void 0),this.ctx.emitter.emit("blockchain:tokenWithdrawalRequested",m.data)),m}async requestNFTWithdrawal(e,t,s,r,i,c,m){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=zs(i),c!==void 0&&(v.Level=c),m&&(v.ItemInstanceID=m);let U=await this.ctx.api.blockchain.requestNFTWithdrawal(v);return U.ok&&(this.ctx.data.user.applyResourceOperation(U.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("blockchain:nftWithdrawalRequested",U.data)),U}async getTransactionHistory(e=50){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Amount=String(e);let 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 vc={Head:"Head",Torso:"Torso",Legs:"Legs"},Ps=zod.z.enum(["Head","Torso","Legs"]),Tc={Open:"Open",InProgress:"InProgress",Cancelled:"Cancelled",Completed:"Completed"},ri=zod.z.enum(["Open","InProgress","Cancelled","Completed"]),Fn=zod.z.object({AttackTarget:Ps,DefenseTarget:Ps});var Pc=zod.z.enum(["Hit","Critical","Block","Dodge"]),Ic=zod.z.object({RoundIndex:zod.z.number().nullish(),AttackerID:zod.z.string().nullish(),DefenderID:zod.z.string().nullish(),AttackZone:Ps.nullish(),DefenseZone:Ps.nullish(),HitType:Pc.nullish(),DamageDealt:zod.z.number().nullish(),DefenderHpRemaining:zod.z.number().nullish()}).passthrough(),Mc=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(),kc=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:a,ExpiresAt:a.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(u=>u),jn=zod.z.object({UserID:zod.z.string().nullish(),SelectedCharacterID:zod.z.string().nullish(),SelectedCharacter:Kr.nullish(),BattleStrategy:zod.z.array(Fn).nullish(),UnstackableItems:zod.z.record(zod.z.string(),kc).nullish(),Stats:Mc.nullish()}).passthrough(),Ac=zod.z.object({WinnerUserID:zod.z.string().nullish(),LoserUserID:zod.z.string().nullish(),Entry:oe.nullish(),NetReward:oe.nullish(),BattleLog:zod.z.array(Ic).nullish(),IsDraw:zod.z.boolean().nullish(),P1BattleProfile:jn.nullish(),P2BattleProfile:jn.nullish()}).passthrough(),_n=zod.z.object({MatchID:zod.z.string(),TitleID:zod.z.string().nullish(),RuleID:zod.z.string().nullish(),CreatedAt:a.nullish(),CreatorID:zod.z.string().nullish(),CreatorCharacterID:zod.z.string().nullish(),CreatorStrategy:zod.z.array(Fn).nullish(),TargetUserID:zod.z.string().nullish(),Entry:oe.nullish(),CreationCostPaid:oe.nullish(),RefundCreationCostOnCancel:zod.z.boolean().nullish(),JoinedByUserID:zod.z.string().nullish(),JoinedByCharacterID:zod.z.string().nullish(),JoinedAt:a.nullish(),Status:ri.nullish(),WinnerUserID:zod.z.string().nullish(),CompletedAt:a.nullish(),IsRewardDistributed:zod.z.boolean().nullish(),RewardDistributedAt:a.nullish()}).passthrough(),Wn=zod.z.object({Status:ri,MatchID:zod.z.string(),Entry:oe.nullish(),Resources:x.nullish()}),Vn=zod.z.object({Match:_n.nullish()}),Qn=zod.z.object({MatchID:zod.z.string(),Status:ri,Resources:x.nullish()}),Hn=zod.z.object({Battle:Ac.nullish(),Resources:x.nullish(),ResourcesDual:tt.nullish()}),ii=zod.z.object({Matches:zod.z.array(_n).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}),Ne={CreateMatch:"CreateMatch",UpdateMatch:"UpdateMatch",CancelMatch:"CancelMatch",InstantBattle:"InstantBattle",SaveStrategy:"SaveStrategy",GetMyMatches:"GetMyMatches",GetAvailableMatches:"GetAvailableMatches",GetDefinitions:"GetDefinitions"};var Oc=zod.z.enum(["VirtualCurrency","Item","EventToken"]);var Bc=zod.z.enum(["Constant","Stat","RankMultiplier","AllMight","GearFlat","GearPercent"]),Uc=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(),wc=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(),qc=zod.z.object({Source:Bc.nullish(),StatID:zod.z.string().nullish(),Value:zod.z.number().nullish(),OnePlus:zod.z.boolean().nullish()}).passthrough(),Ec=zod.z.object({Coefficient:zod.z.number().nullish(),Factors:zod.z.array(qc).nullish()}).passthrough(),rt=zod.z.object({Terms:zod.z.array(Ec).nullish()}).passthrough(),Lc=zod.z.object({Health:rt.nullish(),Damage:rt.nullish(),Armor:rt.nullish(),AttackSpeed:rt.nullish(),CritChance:rt.nullish(),CritDamage:rt.nullish(),Dodge:rt.nullish()}).passthrough(),Kn=zod.z.object({StatMapping:Uc.nullish(),Combat:wc.nullish(),Formula:Lc.nullish()}).passthrough(),Gc=zod.z.object({BurnRate:zod.z.number().nullish()}).passthrough(),ni=zod.z.object({Kind:Oc.nullish(),CurrencyID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),TokenType:Bt.nullish(),EntityID:zod.z.string().nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish()}).passthrough(),$n=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(ni).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),Zn=zod.z.object({Cost:H.nullish(),RefundCostOnCancel:zod.z.boolean().nullish(),MaxOpenMatches:zod.z.number().nullish(),Limits:ce.nullish(),AllowPrivateMatches:zod.z.boolean().nullish(),MaxMatchesPerOpponentPerDay:zod.z.number().nullish()}).passthrough(),Nc=zod.z.object({RuleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Economy:Gc.nullish(),Entry:$n.nullish(),Creation:Zn.nullish(),Settings:Kn.nullish()}).passthrough(),jc=zod.z.object({Rules:zod.z.record(zod.z.string(),Nc).nullish(),Defaults:Kn.nullish(),EntryDefaults:$n.nullish(),CreationDefaults:Zn.nullish()}).passthrough(),oi=zod.z.object({InstantBattle:jc.nullish()}).passthrough(),Jn=oi;var Fc={Listing:"Listing",Auction:"Auction",BuyOrder:"BuyOrder",DirectTrade:"DirectTrade"},ai=zod.z.enum(["Listing","Auction","BuyOrder","DirectTrade"]),_c={Active:"Active",Completed:"Completed",Cancelled:"Cancelled",Declined:"Declined",Expired:"Expired"},li=zod.z.enum(["Active","Completed","Cancelled","Declined","Expired"]),Wc={Burn:"Burn",Ledger:"Ledger"},Vc=zod.z.enum(["Burn","Ledger"]),Ms={Item:"Item",VirtualCurrency:"VirtualCurrency"},ui=zod.z.enum(["Item","VirtualCurrency"]),Qc=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:k.nullish()}).passthrough(),Hc=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(ni).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),Kc=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:k.nullish(),Sink:Vc.nullish(),LedgerAccountID:zod.z.string().nullish(),PerCatalogOverrides:zod.z.record(zod.z.string(),Qc).nullish(),ApplyToDirectTrades:zod.z.boolean().nullish()}).passthrough(),$c=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(),Zc=zod.z.object({Enabled:zod.z.boolean().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),MaxActiveListings:zod.z.number().nullish(),CreateLimits:ce.nullish(),BuyLimits:ce.nullish(),ListingFee:H.nullish(),RefundListingFeeOnCancel:zod.z.boolean().nullish()}).passthrough(),Jc=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:k.nullish(),BidLimits:ce.nullish()}).passthrough(),Yc=zod.z.object({Enabled:zod.z.boolean().nullish(),MaxActiveOrders:zod.z.number().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),CreateLimits:ce.nullish(),FillLimits:ce.nullish()}).passthrough(),Xc=zod.z.object({Enabled:zod.z.boolean().nullish(),OfferExpirationHours:zod.z.number().nullish(),MaxPendingOutgoing:zod.z.number().nullish(),AllowGifts:zod.z.boolean().nullish(),CreateLimits:ce.nullish()}).passthrough(),ep=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),ci=zod.z.object({Enabled:zod.z.boolean().nullish(),Gate:V.nullish(),Schedule:ue.nullish(),PricePolicy:Hc.nullish(),Commission:Kc.nullish(),Tradability:$c.nullish(),Listings:Zc.nullish(),Auctions:Jc.nullish(),BuyOrders:Yc.nullish(),DirectTrades:Xc.nullish(),Matching:ep.nullish()}).passthrough(),Yn=zod.z.object({BidIndex:zod.z.number().nullish(),UserID:zod.z.string().nullish(),Amount:k.nullish(),Settled:zod.z.boolean().nullish(),SettledAt:a.nullish()}).passthrough(),tp=zod.z.object({BidAxisType:Ot.nullish(),BidCurrencyID:zod.z.string().nullish(),BidCatalogID:zod.z.string().nullish(),BidItemID:zod.z.string().nullish(),StartingBid:k.nullish(),CurrentBid:k.nullish(),CurrentBidderID:zod.z.string().nullish(),BidCount:zod.z.number().nullish(),ExtensionCount:zod.z.number().nullish(),PendingRefunds:zod.z.array(Yn).nullish()}).passthrough(),Is=zod.z.object({LastAt:a.nullish(),DailyCount:zod.z.number().nullish(),DailyResetUtc:a.nullish()}).passthrough(),sp=zod.z.object({Create:Is.nullish(),Buy:Is.nullish(),Sell:Is.nullish(),Bid:Is.nullish()}).passthrough(),rp=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:a,ExpiresAt:a.nullish(),EquippedSlot:rp.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(u=>u),Qe=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:ai.nullish(),Status:li.nullish(),CreatorUserID:zod.z.string().nullish(),CreatorPublicData:Ce.nullish(),TargetUserID:zod.z.string().nullish(),GoodsType:ui.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:k.nullish(),GoodsInstances:zod.z.array(ip).nullish(),Price:oe.nullish(),Auction:tp.nullish(),CreatedAt:a.nullish(),ExpiresAt:a.nullish()}).passthrough(),np=zod.z.object({GoodsType:ui.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),CountsByType:zod.z.record(ai,k).nullish(),ListingCount:k.nullish(),AuctionCount:k.nullish(),BuyOrderCount:k.nullish()}).passthrough(),Xn=zod.z.object({Definitions:ci.nullish(),IsOpenNow:zod.z.boolean().nullish(),GatePassed:zod.z.boolean().nullish()}).passthrough(),pi=zod.z.object({Offers:zod.z.array(Qe).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),eo=zod.z.object({Groups:zod.z.array(np).nullish()}).passthrough(),to=zod.z.object({Offer:Qe.nullish()}).passthrough(),Ae=zod.z.object({OfferID:zod.z.string().nullish(),Status:li.nullish(),Settlement:tt.nullish(),Resources:x.nullish(),CommissionTaken:oe.nullish()}).passthrough(),vt=zod.z.object({OfferID:zod.z.string().nullish(),Offer:Qe.nullish(),Resources:x.nullish(),Matched:zod.z.boolean().nullish(),Settlement:Ae.nullish()}).passthrough(),so=zod.z.object({OfferID:zod.z.string().nullish(),CurrentBid:k.nullish(),BidCount:zod.z.number().nullish(),ExpiresAt:a.nullish(),Resources:x.nullish()}).passthrough(),ro=zod.z.object({MyOffers:zod.z.array(Qe).nullish(),MyLeadingBids:zod.z.array(Qe).nullish(),MyBuyOrders:zod.z.array(Qe).nullish(),IncomingTrades:zod.z.array(Qe).nullish(),OutgoingTrades:zod.z.array(Qe).nullish(),Claimables:zod.z.array(Qe).nullish(),DrainedRefunds:zod.z.array(Yn).nullish(),Limits:sp.nullish()}).passthrough(),op=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:ai.nullish(),FinalStatus:li.nullish(),SellerUserID:zod.z.string().nullish(),BuyerUserID:zod.z.string().nullish(),GoodsType:ui.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:k.nullish(),PricePaid:oe.nullish(),CommissionTaken:oe.nullish(),CompletedAt:a.nullish()}).passthrough(),io=zod.z.object({Entries:zod.z.array(op).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),se={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",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.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 m=this.baseRequest();if(!m)return n("unauthorized","Not logged in.");m.ItemID=e,m.CatalogID=t,m.GoodsAmount=s,m.PriceBundle=r,m.DurationHours=i,m.ItemInstanceIDs=c;let v=await this.ctx.api.marketplace.createListing(m);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,m={}){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=m.bidCurrencyID,v.BidCatalogID=m.bidCatalogID,v.BidItemID=m.bidItemID,v.StartingBid=i,v.DurationHours=c,v.ItemInstanceIDs=m.itemInstanceIDs;let U=await this.ctx.api.marketplace.createAuction(v);return this.applyCreateOfferResult(U,"marketplace:auctionCreated"),U}async placeBid(e,t){if(!e)return n("client","OfferID is required.");if(!t||t<=0)return n("client","BidAmount must be positive.");let 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 m=await this.ctx.api.marketplace.createBuyOrder(c);return this.applyCreateOfferResult(m,"marketplace:buyOrderCreated"),m}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 m=await this.ctx.api.marketplace.createDirectTrade(c);return this.applyCreateOfferResult(m,"marketplace:directTradeCreated"),m}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=Ms.VirtualCurrency,e.GoodsCurrencyID=t.goodsCurrencyID,null):"itemID"in t&&t.itemID&&t.catalogID?(e.GoodsType=Ms.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 As=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 no=zod.z.object({PlatformUserID:zod.z.string().nullish(),PlatformAuthToken:zod.z.string().nullish(),PlatformAuthTokenExpiration:a.nullish(),TitleUserID:zod.z.string(),TitleClientSessionTicket:zod.z.string(),TitleClientSessionTicketExpiration:a}),Se=zod.z.object({IsCompleted:zod.z.boolean().nullish(),ServerTime:a.nullish()}),oo=zod.z.object({Message:zod.z.string(),ExpiresAt:a}),Oe={LoginWithDeviceID:"LoginWithDeviceID",LoginWithTelegram:"LoginWithTelegram",LoginWithEmail:"LoginWithEmail",LoginWithGoogle:"LoginWithGoogle",LoginWithPlatformToken:"LoginWithPlatformToken",RegisterWithEmail:"RegisterWithEmail",RefreshPlatformToken:"RefreshPlatformToken",RequestWalletChallenge:"RequestWalletChallenge",LoginWithWallet:"LoginWithWallet",ForgotPassword:"ForgotPassword",ResetPassword:"ResetPassword"};function O(u,e,t,s){let i=`api/v2/${u&&u.length>0?u:"0"}/Client/${e}/${t}`;return s==null?i:`${i}/${s}`}var Os=class{constructor(e){this.ctx=e;}ctx;endpoint(e){return O(this.ctx.settings.titleID,"Authentication",e)}login(e,t){return this.ctx.transport.post(this.endpoint(e),t,no,{ticket:null})}loginWithDeviceID(e){return this.login(Oe.LoginWithDeviceID,e)}loginWithTelegram(e){return this.login(Oe.LoginWithTelegram,e)}loginWithEmail(e){return this.login(Oe.LoginWithEmail,e)}loginWithGoogle(e){return this.login(Oe.LoginWithGoogle,e)}loginWithPlatformToken(e){return this.login(Oe.LoginWithPlatformToken,e)}registerWithEmail(e){return this.login(Oe.RegisterWithEmail,e)}requestWalletChallenge(e){return this.ctx.transport.post(this.endpoint(Oe.RequestWalletChallenge),e,oo,{ticket:null})}loginWithWallet(e){return this.login(Oe.LoginWithWallet,e)}forgotPassword(e){return this.ctx.transport.post(this.endpoint(Oe.ForgotPassword),e,Se,{ticket:null})}resetPassword(e){return this.ctx.transport.post(this.endpoint(Oe.ResetPassword),e,Se,{ticket:null})}};var di=zod.z.object({Title:zod.z.unknown().nullish(),User:zod.z.unknown().nullish()}).passthrough().transform(u=>u),ao=zod.z.object({}).passthrough().transform(u=>u),lo=zod.z.object({}).passthrough().transform(u=>u),uo=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:a.nullish(),LastActiveAt:a.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(),co=zod.z.object({Username:zod.z.string()}),je={GetClientState:"GetClientState",GetClientStateExcept:"GetClientStateExcept",GetInventory:"GetInventory",GetEventTokens:"GetEventTokens",GetUsageTime:"GetUsageTime",AddUsageTime:"AddUsageTime",DeleteUserAccount:"DeleteUserAccount",ChangeUsername:"ChangeUsername"};var Bs=class{constructor(e){this.ctx=e;}ctx;endpoint(e,t){return O(this.ctx.settings.titleID,"User",e,t??"")}getClientState(e){return this.ctx.transport.post(this.endpoint(je.GetClientState,e.UserID),e,di,{ticket:e.ClientSessionTicket})}getClientStateExcept(e){return this.ctx.transport.post(this.endpoint(je.GetClientStateExcept,e.UserID),e,di,{ticket:e.ClientSessionTicket})}getInventory(e){return this.ctx.transport.post(this.endpoint(je.GetInventory,e.UserID),e,ao,{ticket:e.ClientSessionTicket})}getEventTokens(e){return this.ctx.transport.post(this.endpoint(je.GetEventTokens,e.UserID),e,lo,{ticket:e.ClientSessionTicket})}getUsageTime(e){return this.ctx.transport.post(this.endpoint(je.GetUsageTime,e.UserID),e,uo,{ticket:e.ClientSessionTicket})}addUsageTime(e){return this.ctx.transport.post(this.endpoint(je.AddUsageTime,e.UserID),e,Se,{ticket:e.ClientSessionTicket,silent:true})}deleteUserAccount(e){return this.ctx.transport.post(this.endpoint(je.DeleteUserAccount,e.UserID),e,Se,{ticket:e.ClientSessionTicket})}changeUsername(e){return this.ctx.transport.post(this.endpoint(je.ChangeUsername,e.UserID),e,co,{ticket:e.ClientSessionTicket})}};var Us=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Currency",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}convert(e){return this.send(xs.Convert,e,un)}cryptoConvert(e){return this.send(xs.CryptoConvert,e,cn)}};var lp=zod.z.object({ItemInstanceID:zod.z.string(),Units:zod.z.number(),Level:zod.z.number()}),mi=zod.z.object({ServerTimeUtc:a,ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Level:zod.z.number(),Resources:x.nullish(),FodderConsumed:zod.z.array(lp).nullish()}),po=zod.z.array(te(mi)),ws={UpgradeLevel:"UpgradeLevel",UpgradeLevelsBatch:"UpgradeLevelsBatch"},up={FlatCount:"FlatCount",Merge:"Merge",InvestmentRefund:"InvestmentRefund"},cp=zod.z.enum(["FlatCount","Merge","InvestmentRefund"]),pp={ProtectLeveled:"ProtectLeveled",CheapestFirst:"CheapestFirst",ClientSelected:"ClientSelected"},dp=zod.z.enum(["ProtectLeveled","CheapestFirst","ClientSelected"]),mp=zod.z.object({ContractAddress:zod.z.string().nullish(),TokenID:zod.z.string().nullish(),TokenStandard:zod.z.string().nullish()}).passthrough(),hp=zod.z.object({Networks:zod.z.record(zod.z.string(),mp).nullish(),MetadataUrl:zod.z.string().nullish()}).passthrough(),fp=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(),gp=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(),Rp=zod.z.object({ValuationMode:cp.nullish(),MergeRatio:zod.z.number().nullish(),Selection:dp.nullish()}).passthrough(),yp=zod.z.object({MaxLevel:zod.z.number().nullish(),BaseCostResource:H.nullish(),CostScalingFactor:zod.z.number().nullish(),FlatScalingFactor:zod.z.number().nullish(),PercentScalingFactor:zod.z.number().nullish(),PowerScalingFactor:zod.z.number().nullish(),Fodder:Rp.nullish()}).passthrough(),Cp=zod.z.object({RarityID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),AuthorID:zod.z.string().nullish()}).passthrough(),Sp=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:hp.nullish(),Stats:fp.nullish(),Equipment:gp.nullish(),Upgrade:yp.nullish(),Metadata:Cp.nullish(),ExpirationDurationSeconds:zod.z.number().nullish()}).passthrough(),xp=zod.z.object({Items:zod.z.record(zod.z.string(),Sp).nullish()}).passthrough(),qs=zod.z.object({Catalogs:zod.z.record(zod.z.string(),xp).nullish()}).passthrough();var Es=class{constructor(e){this.ctx=e;}ctx;upgradeLevel(e){let t=O(this.ctx.settings.titleID,"Item",ws.UpgradeLevel,e.UserID??"");return this.ctx.transport.post(t,e,mi,{ticket:e.ClientSessionTicket})}upgradeLevelsBatch(e){let t=O(this.ctx.settings.titleID,"Item",ws.UpgradeLevelsBatch,e.UserID??"");return this.ctx.transport.post(t,e,po,{ticket:e.ClientSessionTicket})}};var hi=zod.z.object({ServerTimeUtc:a,OfferID:zod.z.string(),Count:zod.z.number(),Resources:x.nullish()}),mo=zod.z.array(te(hi)),Dp=zod.z.object({OfferID:zod.z.string(),TotalPurchases:zod.z.number(),DailyPurchases:zod.z.number(),DailyResetUtc:a,LastPurchasedAt:a}),ho=zod.z.object({Purchases:zod.z.record(zod.z.string(),Dp).nullish()}).passthrough().transform(u=>u),bp=zod.z.object({StartUtc:a.nullish(),EndUtc:a.nullish(),RequiredFlags:zod.z.array(zod.z.string()).nullish()}).passthrough(),zp=zod.z.object({StoreID:zod.z.string(),Type:zod.z.string().nullish(),Name:zod.z.string().nullish(),Description:zod.z.string().nullish(),Rules:bp.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),vp=zod.z.object({StartUtc:a.nullish(),EndUtc:a.nullish(),Gate:V.nullish(),Limits:ce.nullish()}).passthrough(),Tp=zod.z.object({OfferID:zod.z.string(),StoreIDs:zod.z.array(zod.z.string()).nullish(),Name:zod.z.string().nullish(),Cost:H.nullish(),Rewards:G.nullish(),Rules:vp.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Ls=zod.z.object({Stores:zod.z.record(zod.z.string(),zp).nullish(),StoreOffers:zod.z.record(zod.z.string(),Tp).nullish()}).passthrough(),ht={Purchase:"Purchase",GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",PurchaseBatch:"PurchaseBatch"};var Gs=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Store",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}purchase(e){return this.send(ht.Purchase,e,hi)}purchaseBatch(e){return this.send(ht.PurchaseBatch,e,mo)}getDefinitions(e){return this.send(ht.GetDefinitions,e,Ls)}getUserState(e){return this.send(ht.GetUserState,e,ho)}};var Pp=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),fo=zod.z.object({Reward:G.nullish(),Weight:zod.z.number().nullish(),AmountRange:Pp.nullish()}).passthrough(),ft=zod.z.object({SlotID:zod.z.string().nullish(),MinRolls:zod.z.number().nullish(),MaxRolls:zod.z.number().nullish(),Pool:zod.z.array(fo).nullish()}).passthrough(),gt=zod.z.object({RuleID:zod.z.string().nullish(),Threshold:zod.z.number().nullish(),Pool:zod.z.array(fo).nullish()}).passthrough(),Ip=zod.z.object({RewardSlots:zod.z.array(ft).nullish()}).passthrough(),Mp=zod.z.object({PityRules:zod.z.array(gt).nullish()}).passthrough(),Ns=zod.z.object({SlotPresets:zod.z.record(zod.z.string(),Ip).nullish(),PityPresets:zod.z.record(zod.z.string(),Mp).nullish()}).passthrough();var kp=zod.z.object({RuleID:zod.z.string(),BoxIndex:zod.z.number().nullish()}),go=zod.z.object({ServerTimeUtc:a,LootboxID:zod.z.string(),OpenedCount:zod.z.number().nullish(),SelectedOptionID:zod.z.number().nullish(),Resources:x.nullish(),Inventory:Xe.nullish(),Results:zod.z.array(x).nullish(),TriggeredPity:zod.z.array(kp).nullish()}),Ap=zod.z.object({PriceOptionID:zod.z.number().nullish(),RequiredResources:H.nullish()}).passthrough(),Op=zod.z.object({RewardSlots:pe.nullish(),PityRules:pe.nullish()}).passthrough(),Bp=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),MaxDrops:k.nullish()}).passthrough(),Up=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(),Ap).nullish(),RewardSlots:zod.z.array(ft).nullish(),PityRules:zod.z.array(gt).nullish(),Presets:Op.nullish(),RewardMultiplier:Ut.nullish(),SupplyLimits:zod.z.array(Bp).nullish()}).passthrough(),fi=zod.z.object({Definitions:zod.z.record(zod.z.string(),Up).nullish(),RewardPools:Ns.nullish()}).passthrough(),Ro=zod.z.object({LootboxDefinitions:fi.nullish()}),js={GetDefinitions:"GetDefinitions",Open:"Open"};var Fs=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Lootbox",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(js.GetDefinitions,e,Ro)}open(e){return this.send(js.Open,e,go)}};var wp=zod.z.object({}).passthrough().transform(u=>u),qp=zod.z.object({}).passthrough().transform(u=>u),Ep=zod.z.object({}).passthrough().transform(u=>u),Lp=zod.z.object({}).passthrough().transform(u=>u),Gp=zod.z.object({}).passthrough().transform(u=>u),yo=zod.z.object({ServerTimeUtc:a,CalendarID:zod.z.string(),DayNumber:zod.z.number().nullish(),DailyState:wp,Resources:x.nullish()}),Co=zod.z.object({ServerTimeUtc:a,AccrualID:zod.z.string(),AccruedSeconds:k.nullish(),AppliedRatePerSecond:zod.z.number().nullish(),IdleState:qp,Resources:x.nullish()}),So=zod.z.object({ServerTimeUtc:a,ComebackID:zod.z.string(),ClaimedTierIndex:zod.z.number().nullish(),ComebackState:Ep,Resources:x.nullish()}),xo=zod.z.object({ServerTimeUtc:a,ClaimID:zod.z.string(),ClaimState:Lp,Resources:x.nullish()}),Do=zod.z.object({Enabled:zod.z.boolean(),Multiplier:zod.z.number().nullish(),Progress:k.nullish(),Source:zod.z.string().nullish(),SourceKey:zod.z.string().nullish()}),Np=zod.z.object({RewardMode:zod.z.string().nullish(),RewardStackLowerTiers:zod.z.boolean().nullish()}).passthrough(),jp=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(),Fp=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(jp).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:V.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),_p=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),Wp=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(_p).nullish()}).passthrough(),Vp=zod.z.object({MinCharacterLevel:zod.z.number().nullish(),RequirementsCharacterID:zod.z.string().nullish(),Gate:V.nullish(),RequiredItemIDs:zod.z.array(zod.z.string()).nullish(),RequiredEquippedItemIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),Qp=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:Wp.nullish(),Rewards:G.nullish(),MaxAccumulationSeconds:zod.z.number().nullish(),MinClaimSeconds:zod.z.number().nullish(),Requirements:Vp.nullish(),FirstClaimMode:zod.z.string().nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Hp=zod.z.object({MinAbsenceSeconds:zod.z.number().nullish(),Rewards:G.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Kp=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(Hp).nullish(),ClaimCooldownSeconds:zod.z.number().nullish(),ClaimWindowSeconds:zod.z.number().nullish(),TrackPresenceOnRead:zod.z.boolean().nullish(),Gate:V.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),$p=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(),Zp=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:ce.nullish(),PremiumLimitOverrides:zod.z.array($p).nullish(),Gate:V.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),gi=zod.z.object({TierRewards:Np.nullish(),MilestoneRewardMultiplier:Ut.nullish(),DailyCalendars:zod.z.record(zod.z.string(),Fp).nullish(),IdleAccruals:zod.z.record(zod.z.string(),Qp).nullish(),Comebacks:zod.z.record(zod.z.string(),Kp).nullish(),Claims:zod.z.record(zod.z.string(),Zp).nullish()}).passthrough(),bo=zod.z.object({RewardDefinitions:gi.nullish()}),zo=zod.z.object({Rewards:Gp.nullish()}),Ke={GetRewardDefinitions:"GetRewardDefinitions",GetUserRewardsState:"GetUserRewardsState",ClaimDailyReward:"ClaimDailyReward",CollectIdleAccrual:"CollectIdleAccrual",ClaimComebackReward:"ClaimComebackReward",ClaimReward:"ClaimReward",ClaimRewardsBatch:"ClaimRewardsBatch",GetMilestoneRewardMultiplier:"GetMilestoneRewardMultiplier"};var _s=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Reward",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getRewardDefinitions(e){return this.send(Ke.GetRewardDefinitions,e,bo)}getUserRewardsState(e){return this.send(Ke.GetUserRewardsState,e,zo)}getMilestoneRewardMultiplier(e){return this.send(Ke.GetMilestoneRewardMultiplier,e,Do)}claimDailyReward(e){return this.send(Ke.ClaimDailyReward,e,yo)}collectIdleAccrual(e){return this.send(Ke.CollectIdleAccrual,e,Co)}claimComebackReward(e){return this.send(Ke.ClaimComebackReward,e,So)}claimReward(e){return this.send(Ke.ClaimReward,e,xo)}};var Ws=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Quest",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getQuestDefinitions(e){return this.send(Ee.GetQuestDefinitions,e,Et)}getUserQuestState(e){return this.send(Ee.GetUserQuestState,e,Wi)}refreshQuestCycles(e){return this.send(Ee.RefreshQuestCycles,e,Se)}claimQuestReward(e){return this.send(Ee.ClaimQuestReward,e,Er)}claimQuestRewardsBatch(e){return this.send(Ee.ClaimQuestRewardsBatch,e,Hi)}claimMilestoneReward(e){return this.send(Ee.ClaimMilestoneReward,e,Lr)}claimMilestoneRewardsBatch(e){return this.send(Ee.ClaimMilestoneRewardsBatch,e,Ki)}claimGroupCompletionReward(e){return this.send(Ee.ClaimGroupCompletionReward,e,Vi)}addQuestProgress(e){return this.send(Ee.AddQuestProgress,e,Qi)}};var vo=zod.z.object({}).passthrough().transform(u=>u);var Jp=zod.z.object({Order:zod.z.number().nullish(),Type:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),BonusMultiplier:zod.z.number().nullish()}).passthrough(),Yp=zod.z.object({Schedule:zod.z.array(Jp).nullish(),RepeatCycle:zod.z.boolean().nullish(),MaxCycles:zod.z.number().nullish()}).passthrough(),Xp=zod.z.object({IsActive:zod.z.boolean().nullish(),CurrentPhaseEndUtc:a.nullish(),NextBonusStartUtc:a.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentPhaseIndex:zod.z.number().nullish(),ActiveBonusMultiplier:zod.z.number().nullish()}).passthrough(),ed=zod.z.object({Milestones:pe.nullish()}).passthrough(),Ri=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:st.nullish(),TokenSources:zod.z.array(We).nullish(),ClaimMode:zod.z.string().nullish(),Milestones:zod.z.record(zod.z.string(),ye).nullish(),Presets:ed.nullish(),BonusWindow:Yp.nullish()}).passthrough(),td=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Content:Ri.nullish(),ClaimGraceHours:zod.z.number().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),sd=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:ue.nullish(),Content:Ri.nullish(),Events:zod.z.array(td).nullish(),Gate:V.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),rd=zod.z.object({MaxConcurrentEvents:zod.z.number().nullish()}).passthrough(),id=zod.z.object({Milestones:zod.z.record(zod.z.string(),Ye).nullish()}).passthrough(),Vs=zod.z.object({Definitions:zod.z.record(zod.z.string(),sd).nullish(),Settings:rd.nullish(),Presets:id.nullish()}).passthrough(),nd=zod.z.object({Type:Dt,TimedEventID:zod.z.string(),CurrentChainedEventID:zod.z.string().nullish(),Content:Ri.nullish(),Progress:vo.nullish(),ComputedStartUtc:a.nullish(),ComputedEndUtc:a.nullish(),CanEarn:zod.z.boolean().nullish(),CanClaim:zod.z.boolean().nullish(),NextMilestone:ye.nullish(),BonusWindow:Xp.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentEventOrder:zod.z.number().nullish(),TotalEventsInChain:zod.z.number().nullish()}).passthrough(),To=zod.z.object({ActiveEvents:zod.z.array(nd).nullish()}).passthrough(),Po=zod.z.object({Tokens:zod.z.record(zod.z.string(),vo).nullish()}),yi=zod.z.object({Type:Dt.nullish(),LteID:zod.z.string().nullish(),Resources:x.nullish()}),Ci=zod.z.object({Type:Dt.nullish(),LteID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Rewards:x.nullish()}),od=zod.z.object({Type:Dt.nullish(),LteID:zod.z.string().nullish(),Resources:x.nullish()}),Si=zod.z.array(te(Ci)),Io=zod.z.array(te(yi)),Mo=zod.z.array(te(od)),Be={GetActiveEvents:"GetActiveEvents",GrantTokens:"GrantTokens",SpendTokens:"SpendTokens",ClaimMilestone:"ClaimMilestone",GetDefinitions:"GetDefinitions",GetUserLteState:"GetUserLteState",ClaimMilestonesBatch:"ClaimMilestonesBatch",ClaimAllMilestones:"ClaimAllMilestones",SpendTokensBatch:"SpendTokensBatch",GrantTokensBatch:"GrantTokensBatch"};var Qs=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"TimedEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getActiveEvents(e){return this.send(Be.GetActiveEvents,e,To)}getDefinitions(e){return this.send(Be.GetDefinitions,e,Vs)}getUserLteState(e){return this.send(Be.GetUserLteState,e,Po)}grantTokens(e){return this.send(Be.GrantTokens,e,x)}spendTokens(e){return this.send(Be.SpendTokens,e,yi)}claimMilestone(e){return this.send(Be.ClaimMilestone,e,Ci)}claimMilestonesBatch(e){return this.send(Be.ClaimMilestonesBatch,e,Si)}claimAllMilestones(e){return this.send(Be.ClaimAllMilestones,e,Si)}spendTokensBatch(e){return this.send(Be.SpendTokensBatch,e,Io)}grantTokensBatch(e){return this.send(Be.GrantTokensBatch,e,Mo)}};var ad=zod.z.object({UserID:zod.z.string(),Score:k.nullish(),Rank:zod.z.number().nullish(),LastScoreUpdateUtc:a.nullish(),IpHash:zod.z.string().nullish(),PublicProfile:Ce.nullish(),SeasonTierAtCycleEnd:zod.z.number().nullish()}).passthrough(),Tt=zod.z.object({LeaderboardID:zod.z.string(),CycleVersion:zod.z.number().nullish(),TotalParticipants:k.nullish(),CycleEndUtc:a.nullish(),TopUsers:zod.z.array(ad).nullish(),BracketID:zod.z.string().nullish()}),ld=zod.z.object({CycleKey:zod.z.string().nullish(),CycleEndUtc:a.nullish(),ClaimDeadlineUtc:a.nullish(),MilestoneTokensEarned:k.nullish(),ClaimableMilestoneIDs:zod.z.array(zod.z.string()).nullish(),CycleIndex:zod.z.number().nullish(),ChainedEventID:zod.z.string().nullish()}).passthrough(),Hs=zod.z.object({LeaderboardID:zod.z.string(),CurrentScore:k.nullish(),LastKnownRank:zod.z.number().nullish(),HasUnclaimedReward:zod.z.boolean().nullish(),ScoreEarnedThisCycle:k.nullish(),MilestoneTokensEarned:k.nullish(),NextMilestone:ye.nullish(),HasUnclaimedMilestone:zod.z.boolean().nullish(),ClaimableGraceCycles:zod.z.array(ld).nullish()}),Ks=zod.z.object({LeaderboardID:zod.z.string(),NewScore:k,CycleVersion:zod.z.number()}),$s=zod.z.object({ServerTimeUtc:a,LeaderboardID:zod.z.string(),Rank:zod.z.number().nullish(),Resources:x.nullish()}),Zs=zod.z.object({ServerTimeUtc:a,LeaderboardID:zod.z.string(),MilestoneID:zod.z.string(),Resources:x.nullish()}),ko=zod.z.array(te(Tt)),Ao=zod.z.array(te(Hs)),Oo=zod.z.array(te($s)),Bo=zod.z.array(te(Zs)),Uo=zod.z.array(te(Ks)),ud=zod.z.object({LeaderboardID:zod.z.string(),CycleReward:te($s).nullish(),Milestones:zod.z.array(te(Zs)).nullish()}),wo=zod.z.array(ud),cd=zod.z.object({LeaderboardID:zod.z.string(),Leaderboard:te(Tt).nullish(),Progress:te(Hs).nullish()}),qo=zod.z.array(cd),pd=zod.z.string(),Eo=zod.z.object({Rank:zod.z.string().nullish(),Rewards:G.nullish(),SeasonTierRewards:wr.nullish()}).passthrough(),dd=zod.z.object({RankRewards:zod.z.array(Eo).nullish()}).passthrough(),md=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),hd=zod.z.object({Milestones:pe.nullish(),RankRewards:pe.nullish()}).passthrough(),fd=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:pd.nullish(),Schedule:ue.nullish(),ChainEvents:zod.z.array(md).nullish(),Gate:V.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(Eo).nullish(),Milestones:zod.z.record(zod.z.string(),ye).nullish(),Presets:hd.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneClaimGraceHours:zod.z.number().nullish(),ScoreSources:zod.z.array(We).nullish()}).passthrough(),gd=zod.z.object({Milestones:zod.z.record(zod.z.string(),Ye).nullish(),RankRewards:zod.z.record(zod.z.string(),dd).nullish()}).passthrough(),Js=zod.z.object({Definitions:zod.z.record(zod.z.string(),fd).nullish(),Presets:gd.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 Ys=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(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,Js)}getLeaderboard(e){return this.send(fe.GetLeaderboard,e,Tt)}getMyProgress(e){return this.send(fe.GetMyProgress,e,Hs)}submitScore(e){return this.send(fe.SubmitScore,e,Ks)}submitScoreFromSource(e){return this.send(fe.SubmitScoreFromSource,e,Ks)}claimCycleReward(e){return this.send(fe.ClaimCycleReward,e,$s)}claimMilestone(e){return this.send(fe.ClaimMilestone,e,Zs)}getFriendsLeaderboard(e){return this.send(fe.GetFriendsLeaderboard,e,Tt)}getLeaderboardsBatch(e){return this.send(fe.GetLeaderboardsBatch,e,ko)}getProgressBatch(e){return this.send(fe.GetProgressBatch,e,Ao)}claimCycleRewardsBatch(e){return this.send(fe.ClaimCycleRewardsBatch,e,Oo)}claimMilestonesBatch(e){return this.send(fe.ClaimMilestonesBatch,e,Bo)}submitScoresBatch(e){return this.send(fe.SubmitScoresBatch,e,Uo)}claimAllRewardsBatch(e){return this.send(fe.ClaimAllRewardsBatch,e,wo)}getOverviewBatch(e){return this.send(fe.GetOverviewBatch,e,qo)}};var xi=zod.z.object({}).passthrough().transform(u=>u),Lo=zod.z.object({SeasonChainID:zod.z.string(),CycleIndex:zod.z.number().nullish(),Season:zod.z.lazy(()=>Fo).nullish(),ComputedStartUtc:a.nullish(),ComputedEndUtc:a.nullish(),SecondsRemaining:k.nullish(),UserState:xi.nullish(),NextTier:zod.z.lazy(()=>jo).nullish()}).passthrough(),Go=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),AmountGranted:k.nullish(),NewStatusTokens:k.nullish(),OldTier:zod.z.number().nullish(),NewTier:zod.z.number(),TierUp:zod.z.boolean().nullish()}),No=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),TierNumber:zod.z.number(),Resources:x.nullish()});var jo=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:k.nullish(),TierReachedReward:G.nullish()}).passthrough(),Fo=zod.z.object({SeasonID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:k.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(jo).nullish(),LinkedCollectionID:zod.z.string().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough();var Rd=zod.z.object({SeasonChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:ue.nullish(),Seasons:zod.z.array(Fo).nullish(),GrantTokensAccessMode:zod.z.string().nullish(),Gate:V.nullish()}).passthrough(),Xs=zod.z.object({Chains:zod.z.record(zod.z.string(),Rd).nullish()}).passthrough(),it={GetDefinitions:"GetDefinitions",GetActiveSeason:"GetActiveSeason",GetUserState:"GetUserState",GrantStatusTokens:"GrantStatusTokens",ClaimTierReward:"ClaimTierReward"};var er=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Season",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(it.GetDefinitions,e,Xs)}getActiveSeason(e){return this.send(it.GetActiveSeason,e,Lo)}getUserState(e){return this.send(it.GetUserState,e,xi)}grantStatusTokens(e){return this.send(it.GrantStatusTokens,e,Go)}claimTierReward(e){return this.send(it.ClaimTierReward,e,No)}};var yd={Apple:"Apple",Google:"Google"},_o=zod.z.object({}).passthrough().transform(u=>u),Cd=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(),Sd=zod.z.object({OptionID:zod.z.string().nullish(),Name:zod.z.string().nullish(),RequiredResources:H.nullish()}).passthrough(),xd=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(),Sd).nullish(),AppleProductID:zod.z.string().nullish(),GoogleProductID:zod.z.string().nullish(),Benefits:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Di=zod.z.object({Definitions:zod.z.record(zod.z.string(),xd).nullish()}).passthrough(),Wo=zod.z.object({Premium:Di.nullish()}),Vo=zod.z.object({ServerTimeUtc:a.nullish(),Premium:_o.nullish()}),tr=zod.z.object({ServerTimeUtc:a.nullish(),Premium:_o.nullish(),Subscription:Cd.nullish(),Resources:x.nullish()}),nt={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateTrial:"ActivateTrial",PurchaseWithResources:"PurchaseWithResources",PurchaseRealMoney:"PurchaseRealMoney"};var sr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Premium",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(nt.GetDefinitions,e,Wo)}getUserState(e){return this.send(nt.GetUserState,e,Vo)}activateTrial(e){return this.send(nt.ActivateTrial,e,tr)}purchaseItemOrCurrency(e){return this.send(nt.PurchaseWithResources,e,tr)}purchaseRealMoney(e){return this.send(nt.PurchaseRealMoney,e,tr)}};var rr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(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,bs)}getUserCharacters(e){return this.send(Te.GetUserCharacters,e,fn)}unlockCharacter(e){return this.send(Te.UnlockCharacter,e,Jr)}upgradeStatLevel(e){return this.send(Te.UpgradeStatLevel,e,$r)}upgradeCharacterLevel(e){return this.send(Te.UpgradeCharacterLevel,e,Zr)}equipItems(e){return this.send(Te.EquipItems,e,gn)}unequipItems(e){return this.send(Te.UnequipItems,e,Rn)}unequipAllCharacters(e){return this.send(Te.UnequipAllCharacters,e,yn)}unlockCharactersBatch(e){return this.send(Te.UnlockCharactersBatch,e,Cn)}upgradeCharacterLevelsBatch(e){return this.send(Te.UpgradeCharacterLevelsBatch,e,Sn)}upgradeStatLevelsBatch(e){return this.send(Te.UpgradeStatLevelsBatch,e,xn)}};var ir=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Match",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}createMatch(e){return this.send(Ne.CreateMatch,e,Wn)}updateMatch(e){return this.send(Ne.UpdateMatch,e,Vn)}cancelMatch(e){return this.send(Ne.CancelMatch,e,Qn)}instantBattle(e){return this.send(Ne.InstantBattle,e,Hn)}saveStrategy(e){return this.send(Ne.SaveStrategy,e,Se)}getMyMatches(e){return this.send(Ne.GetMyMatches,e,ii)}getAvailableMatches(e){return this.send(Ne.GetAvailableMatches,e,ii)}getDefinitions(e){return this.send(Ne.GetDefinitions,e,Jn)}};var Dd={TradeUpRarity:"TradeUpRarity",TradeUpCollection:"TradeUpCollection"},Qo=zod.z.enum(["TradeUpRarity","TradeUpCollection"]),bd=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:Ur.nullish()}),Ho=zod.z.object({ServerTimeUtc:a,Type:Qo.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(bd).nullish()}),zd=zod.z.object({OptionID:zod.z.string().nullish(),RequiredResources:H.nullish()}).passthrough(),vd=zod.z.object({CraftID:zod.z.string().nullish(),Type:Qo.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(),zd).nullish()}).passthrough(),bi=zod.z.object({Definitions:zod.z.record(zod.z.string(),vd).nullish()}).passthrough(),Ko=zod.z.object({ServerTimeUtc:a.nullish(),CraftDefinitions:bi.nullish()}),nr={GetDefinitions:"GetDefinitions",Craft:"Craft"};var or=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Craft",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(nr.GetDefinitions,e,Ko)}craft(e){return this.send(nr.Craft,e,Ho)}};var Td={Pending:"Pending",Accepted:"Accepted",Declined:"Declined",Cancelled:"Cancelled",Expired:"Expired"},Pd=zod.z.enum(["Pending","Accepted","Declined","Cancelled","Expired"]),$o=zod.z.object({}).passthrough().transform(u=>u),ar=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()}),Zo=zod.z.object({GrantedCollectibles:zod.z.array(ar).nullish(),DuplicateCollectibles:zod.z.array(ar).nullish(),CollectionCurrencyEarned:k.nullish(),NewCollectionCurrencyBalance:k.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()}),Jo=zod.z.object({GrantedCollectibles:zod.z.array(ar).nullish(),DuplicateCollectibles:zod.z.array(ar).nullish(),CollectionCurrencyEarned:k.nullish(),NewCollectionCurrencyBalance:k.nullish(),Resources:x.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),Yo=zod.z.object({GrantedCollectibleID:zod.z.string().nullish(),NewlyCompletedSetID:zod.z.string().nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:x.nullish()}),zi=zod.z.object({SetID:zod.z.string(),Resources:x.nullish()}),Xo=zod.z.array(te(zi)),ea=zod.z.object({Resources:x.nullish()}),Id=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:Pd.nullish(),CreatedAtUtc:a.nullish(),ExpiresAtUtc:a.nullish(),RespondedAtUtc:a.nullish(),DeclineReason:zod.z.string().nullish(),IsSpecialTradeEvent:zod.z.boolean().nullish(),SpecialTradeEventID:zod.z.string().nullish()}).passthrough(),ta=zod.z.object({OfferID:zod.z.string(),ExpiresAtUtc:a.nullish(),Resources:x.nullish()}),sa=zod.z.object({OfferID:zod.z.string(),Resources:x.nullish()}),ra=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()}),ia=zod.z.object({OfferID:zod.z.string(),Resources:x.nullish()}),vi=zod.z.object({Offers:zod.z.array(Id).nullish()}),Md=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(),kd=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(Md).nullish(),SetCompletionReward:G.nullish()}).passthrough(),Ad=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(kd).nullish(),GrandPrize:G.nullish()}).passthrough(),na=zod.z.object({BonusRewardSlots:pe.nullish(),PityRules:pe.nullish()}).passthrough(),Od=zod.z.object({PackTypeID:zod.z.string().nullish(),Cost:H.nullish(),BonusRewardSlots:zod.z.array(ft).nullish(),PityRules:zod.z.array(gt).nullish(),Presets:na.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(),Bd=zod.z.object({Rarity:zod.z.number().nullish(),CollectionCurrencyGranted:zod.z.number().nullish()}).passthrough(),Ud=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(ft).nullish(),PityRules:zod.z.array(gt).nullish(),Presets:na.nullish(),Tier:zod.z.number().nullish()}).passthrough(),wd=zod.z.object({SpecialTradeEventID:zod.z.string().nullish(),StartUtc:a.nullish(),EndUtc:a.nullish(),AllowedSpecialCollectibleIDs:zod.z.array(zod.z.string()).nullish(),SpecialTradeEventDailyTradeLimit:zod.z.number().nullish()}).passthrough(),lr=zod.z.object({Collections:zod.z.record(zod.z.string(),Ad).nullish(),PackTypes:zod.z.record(zod.z.string(),Od).nullish(),CollectionChests:zod.z.array(Ud).nullish(),DuplicateConversions:zod.z.array(Bd).nullish(),DailyTradeLimit:zod.z.number().nullish(),CollectibleJokerCatalogID:zod.z.string().nullish(),CollectibleJokerItemID:zod.z.string().nullish(),SpecialTradeEvents:zod.z.array(wd).nullish(),RewardPools:Ns.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 ur=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(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,lr)}getUserState(e){return this.send(xe.GetUserState,e,$o)}openPack(e){return this.send(xe.OpenPack,e,Zo)}openCollectionChest(e){return this.send(xe.OpenCollectionChest,e,Jo)}useCollectibleJoker(e){return this.send(xe.UseCollectibleJoker,e,Yo)}claimSetReward(e){return this.send(xe.ClaimSetReward,e,zi)}claimSetRewardsBatch(e){return this.send(xe.ClaimSetRewardsBatch,e,Xo)}claimGrandPrize(e){return this.send(xe.ClaimGrandPrize,e,ea)}sendTradeOffer(e){return this.send(xe.SendTradeOffer,e,ta)}cancelTradeOffer(e){return this.send(xe.CancelTradeOffer,e,sa)}acceptTradeOffer(e){return this.send(xe.AcceptTradeOffer,e,ra)}declineTradeOffer(e){return this.send(xe.DeclineTradeOffer,e,ia)}getMyTradeOffers(e){return this.send(xe.GetMyTradeOffers,e,vi)}getIncomingTradeOffers(e){return this.send(xe.GetIncomingTradeOffers,e,vi)}};var qd=zod.z.object({}).passthrough().transform(u=>u),Ed={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},Ld={Active:"Active",Left:"Left",Replaced:"Replaced"},Gd=zod.z.object({ObjectIndex:zod.z.number().nullish(),ObjectCompletionRewardClaimed:zod.z.boolean().nullish()}).passthrough(),Nd=zod.z.object({UserID:zod.z.string().nullish(),PublicData:Ce.nullish(),BuildObjectsProgress:Gd.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:a.nullish(),LeftAtUtc:a.nullish()}).passthrough(),jd=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(),Fd=zod.z.object({Objects:zod.z.array(jd).nullish()}).passthrough(),oa=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(Nd).nullish(),BuildObjectsState:Fd.nullish(),Status:zod.z.string().nullish(),CreatedAtUtc:a.nullish(),ExpiresAtUtc:a.nullish(),Version:zod.z.number().nullish()}).passthrough(),aa=zod.z.object({CoopChainID:zod.z.string()}).passthrough(),_d=zod.z.string(),la=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(),Wd=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(),Vd=zod.z.object({Objects:zod.z.array(Wd).nullish(),SpinCost:H.nullish(),SpinnerTable:zod.z.array(la).nullish()}).passthrough(),Qd=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:_d.nullish(),PartnerCount:zod.z.number().nullish(),MatchmakingTimeoutMinutes:zod.z.number().nullish(),MemberGracePeriodMinutes:zod.z.number().nullish(),BuildObjects:Vd.nullish(),GrandPrize:G.nullish()}).passthrough(),Hd=zod.z.object({CoopChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:ue.nullish(),Events:zod.z.array(Qd).nullish(),Gate:V.nullish()}).passthrough(),ua=zod.z.object({ServerTimeUtc:a.nullish(),UserState:qd.nullish(),ActiveGroup:oa.nullish()}),Ti=zod.z.object({ServerTimeUtc:a.nullish(),Group:oa.nullish(),SecondsRemaining:k.nullish()}),ca=zod.z.object({ServerTimeUtc:a.nullish(),GroupID:zod.z.string().nullish(),Resources:x.nullish(),ObjectIndex:zod.z.number().nullish(),Sector:la.nullish(),ProgressDelta:zod.z.number().nullish(),NewProgress:k.nullish(),MaxProgress:k.nullish(),ObjectCompleted:zod.z.boolean().nullish(),AllObjectsCompleted:zod.z.boolean().nullish()}),Pi=zod.z.object({ServerTimeUtc:a.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),Resources:x.nullish()}),pa=zod.z.object({ServerTimeUtc:a.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),cr=zod.z.object({Chains:zod.z.record(zod.z.string(),Hd).nullish()}).passthrough(),Ge={GetDefinitions:"GetDefinitions",GetActiveEvent:"GetActiveEvent",GetUserState:"GetUserState",GetGroupState:"GetGroupState",JoinOrCreateGroup:"JoinOrCreateGroup",Spin:"Spin",ClaimObjectReward:"ClaimObjectReward",ClaimGrandPrize:"ClaimGrandPrize",LeaveGroup:"LeaveGroup"};var pr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"CoopEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ge.GetDefinitions,e,cr)}getActiveEvent(e){return this.send(Ge.GetActiveEvent,e,aa)}getUserState(e){return this.send(Ge.GetUserState,e,ua)}getGroupState(e){return this.send(Ge.GetGroupState,e,Ti)}joinOrCreateGroup(e){return this.send(Ge.JoinOrCreateGroup,e,Ti)}spin(e){return this.send(Ge.Spin,e,ca)}claimObjectReward(e){return this.send(Ge.ClaimObjectReward,e,Pi)}claimGrandPrize(e){return this.send(Ge.ClaimGrandPrize,e,Pi)}leaveGroup(e){return this.send(Ge.LeaveGroup,e,pa)}};var Kd={Active:"Active",Exhausted:"Exhausted",Expired:"Expired",Dismissed:"Dismissed"},$d={Locked:"Locked",Available:"Available",InProgress:"InProgress",Completed:"Completed",Hidden:"Hidden"},Zd=zod.z.object({NodeID:zod.z.string().nullish(),Status:zod.z.string().nullish(),ExecutionCount:zod.z.number().nullish(),UnlockedAtUtc:a.nullish(),CompletedAtUtc:a.nullish(),LastExecutedAtUtc:a.nullish(),NextAvailableAtUtc:a.nullish(),LastExecutionRefID:zod.z.string().nullish()}).passthrough(),Jd=zod.z.object({TrackID:zod.z.string().nullish(),CurrentValue:zod.z.number().nullish(),LastUpdatedUtc:a.nullish()}).passthrough(),da=zod.z.object({OfferID:zod.z.string().nullish(),InstanceKey:zod.z.string().nullish(),SourceOfferVersion:zod.z.number().nullish(),Status:zod.z.string().nullish(),ActivatedAtUtc:a.nullish(),ExhaustedAtUtc:a.nullish(),ExpiredAtUtc:a.nullish(),DismissedAtUtc:a.nullish(),ShowCount:zod.z.number().nullish(),LastShownAtUtc:a.nullish(),Nodes:zod.z.record(zod.z.string(),Zd).nullish(),Tracks:zod.z.record(zod.z.string(),Jd).nullish(),SelectedChoiceNodeID:zod.z.string().nullish()}).passthrough(),Yd=zod.z.object({SlotID:zod.z.string().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),ActiveOfferID:zod.z.string().nullish(),ActiveOfferStartedAtUtc:a.nullish(),ActiveOfferExpiresAtUtc:a.nullish(),ActiveOffer:da.nullish(),NextCycleStartsAtUtc:a.nullish(),LastUpdatedUtc:a.nullish(),DismissSkipAvailableAtUtc:a.nullish(),LastDismissedAtUtc:a.nullish()}).passthrough(),Xd=zod.z.object({TotalExecutions:zod.z.number().nullish(),DailyExecutions:zod.z.number().nullish(),DailyResetUtc:a.nullish()}).passthrough(),em=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:a.nullish(),LastActivatedAtUtc:a.nullish(),LastExhaustedAtUtc:a.nullish(),NodeCounts:zod.z.record(zod.z.string(),Xd).nullish()}).passthrough(),tm=zod.z.object({Slots:zod.z.record(zod.z.string(),Yd).nullish(),OfferHistory:zod.z.record(zod.z.string(),em).nullish(),LastUpdatedUtc:a.nullish()}).passthrough();var sm=zod.z.object({Order:zod.z.number().nullish(),OfferID:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),DelayBeforeActivationSec:zod.z.number().nullish()}).passthrough(),rm=zod.z.object({SlotID:zod.z.string().nullish(),Enabled:zod.z.boolean().nullish(),SortOrder:zod.z.number().nullish(),Queue:zod.z.array(sm).nullish(),Schedule:ue.nullish(),Gate:V.nullish(),AllowDismissSkip:zod.z.boolean().nullish(),DismissSkipDelaySec:zod.z.number().nullish()}).passthrough(),im=zod.z.object({StoreOfferID:zod.z.string().nullish(),BillingProductID:zod.z.string().nullish(),DirectCost:H.nullish(),UseExternalRewards:zod.z.boolean().nullish()}).passthrough(),nm=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(),om=zod.z.object({Purchase:im.nullish(),RewardedVideo:nm.nullish()}).passthrough(),am=zod.z.object({TrackID:zod.z.string().nullish(),Operator:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),lm=zod.z.object({Milestones:pe.nullish()}).passthrough(),um=zod.z.object({TrackID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),RespectBounds:zod.z.boolean().nullish()}).passthrough(),cm=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(),pm=zod.z.object({RequiredCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredAnyCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredTracks:zod.z.array(am).nullish(),VisibleWhileLocked:zod.z.boolean().nullish()}).passthrough(),dm=zod.z.object({NodeID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),Type:zod.z.string().nullish(),Action:om.nullish(),Grants:G.nullish(),TrackChanges:zod.z.array(um).nullish(),MilestonePoints:zod.z.number().nullish(),UnlockRules:pm.nullish(),NextNodeIDs:zod.z.array(zod.z.string()).nullish(),ChoiceGroupID:zod.z.string().nullish(),Limits:ce.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(dm).nullish(),Tracks:zod.z.array(cm).nullish(),Milestones:zod.z.record(zod.z.string(),ye).nullish(),Presets:lm.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneToken:st.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(),mm=zod.z.object({Milestones:zod.z.record(zod.z.string(),Ye).nullish()}).passthrough(),Ii=zod.z.object({Slots:zod.z.record(zod.z.string(),rm).nullish(),Offers:zod.z.record(zod.z.string(),ma).nullish(),Presets:mm.nullish()}).passthrough(),ha=zod.z.object({DealOfferDefinitions:Ii.nullish()}),fa=zod.z.object({DealOffers:tm.nullish()}),hm=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(),fm=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:da.nullish(),IsNewActivation:zod.z.boolean().nullish(),ComputedExpiresAtUtc:a.nullish(),Cost:H.nullish(),Milestone:hm.nullish()}).passthrough(),ga=zod.z.object({Slots:zod.z.array(fm).nullish()}),Ra=zod.z.object({ServerTimeUtc:a.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()}),ya=zod.z.object({ServerTimeUtc:a.nullish(),SlotID:zod.z.string().nullish(),Resources:x.nullish()}),Ca=zod.z.object({ServerTimeUtc:a.nullish(),SlotID:zod.z.string().nullish(),Resources:x.nullish()}),Sa=zod.z.object({ServerTimeUtc:a.nullish(),SlotID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:x.nullish()}),xa=zod.z.object({ServerTimeUtc:a.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 dr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(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,ha)}getUserState(e){return this.send(Fe.GetUserState,e,fa)}getActiveDeals(e){return this.send(Fe.GetActiveDeals,e,ga)}dismissDeal(e){return this.send(Fe.DismissDeal,e,ya)}executeNode(e){return this.send(Fe.ExecuteNode,e,Ra)}recordShow(e){return this.send(Fe.RecordShow,e,Ca)}claimMilestone(e){return this.send(Fe.ClaimMilestone,e,Sa)}claimMilestonesBatch(e){return this.send(Fe.ClaimMilestonesBatch,e,xa)}};var gm=zod.z.object({}).passthrough().transform(u=>u),Rm=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(),Mi=zod.z.object({IsEnabled:zod.z.boolean().nullish(),ActivationReward:G.nullish(),InviteRewards:zod.z.record(zod.z.string(),ye).nullish(),SpendRewards:zod.z.array(Rm).nullish()}).passthrough(),Da=zod.z.object({ReferralDefinitions:Mi.nullish()}),ba=zod.z.object({Referral:gm.nullish()}),za=zod.z.object({ReferralCode:zod.z.string().nullish(),IsFirstActivation:zod.z.boolean().nullish(),Resources:x.nullish()}),va=zod.z.object({RewardID:zod.z.string().nullish(),Resources:x.nullish()}),Rt={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateReferralCode:"ActivateReferralCode",ClaimInviteReward:"ClaimInviteReward"};var mr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Referral",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Rt.GetDefinitions,e,Da)}getUserState(e){return this.send(Rt.GetUserState,e,ba)}activateReferralCode(e){return this.send(Rt.ActivateReferralCode,e,za)}claimInviteReward(e){return this.send(Rt.ClaimInviteReward,e,va)}};var ym={RequestSent:"RequestSent",Accepted:"Accepted",Declined:"Declined",Removed:"Removed"},Cm={Attack:"Attack",Raid:"Raid",FriendAdd:"FriendAdd"},Sm=zod.z.object({UserID:zod.z.string(),PublicData:Ce.nullish()}),xm=zod.z.object({OwnerUserID:zod.z.string().nullish(),ActorUserID:zod.z.string().nullish(),ActorProfile:Ce.nullish(),Type:zod.z.string().nullish(),CreatedAt:a.nullish(),OwnerImpact:x.nullish(),IsBlocked:zod.z.boolean().nullish(),TargetObjectName:zod.z.string().nullish()}).passthrough(),hr=zod.z.object({Friends:zod.z.array(Sm).nullish()}),Pt=zod.z.object({TargetUserID:zod.z.string().nullish(),Status:zod.z.string().nullish()}),Ta=zod.z.object({Events:zod.z.array(xm).nullish()}),_e={GetFriendsList:"GetFriendsList",GetIncomingRequests:"GetIncomingRequests",GetRecommendedFriends:"GetRecommendedFriends",SendFriendRequest:"SendFriendRequest",AcceptFriendRequest:"AcceptFriendRequest",DeclineFriendRequest:"DeclineFriendRequest",RemoveFriend:"RemoveFriend",GetTimeline:"GetTimeline"};var fr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Social",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getFriendsList(e){return this.send(_e.GetFriendsList,e,hr)}getIncomingRequests(e){return this.send(_e.GetIncomingRequests,e,hr)}getRecommendedFriends(e){return this.send(_e.GetRecommendedFriends,e,hr)}sendFriendRequest(e){return this.send(_e.SendFriendRequest,e,Pt)}acceptFriendRequest(e){return this.send(_e.AcceptFriendRequest,e,Pt)}declineFriendRequest(e){return this.send(_e.DeclineFriendRequest,e,Pt)}removeFriend(e){return this.send(_e.RemoveFriend,e,Pt)}getTimeline(e){return this.send(_e.GetTimeline,e,Ta)}};var Dm={Replace:"Replace",Refresh:"Refresh",KeepBest:"KeepBest",Stack:"Stack"};var yt=zod.z.object({Target:zod.z.string().nullish(),Operation:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),bm=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:H.nullish(),Effect:yt.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(),zm=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:ue.nullish(),Effects:zod.z.array(yt).nullish(),Gate:V.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),vm=zod.z.object({ChainedBoostID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Effects:zod.z.array(yt).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Tm=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:ue.nullish(),Phases:zod.z.array(vm).nullish(),Gate:V.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Pm=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(We).nullish(),Effects:zod.z.array(yt).nullish(),DurationSeconds:zod.z.number().nullish(),Charges:zod.z.number().nullish(),StackingPolicy:zod.z.string().nullish(),MaxActiveInstances:zod.z.number().nullish(),Gate:V.nullish()}).passthrough(),Im=zod.z.object({MaxAddPercent:zod.z.number().nullish(),MaxMultiply:zod.z.number().nullish(),MaxAddFlat:zod.z.number().nullish()}).passthrough(),Mm=zod.z.object({StackingCaps:zod.z.record(zod.z.string(),Im).nullish()}).passthrough(),gr=zod.z.object({Definitions:zod.z.record(zod.z.string(),bm).nullish(),ScheduledBoosts:zod.z.record(zod.z.string(),zm).nullish(),BoostChains:zod.z.record(zod.z.string(),Tm).nullish(),TriggeredBoosts:zod.z.record(zod.z.string(),Pm).nullish(),Settings:Mm.nullish()}).passthrough(),Pa=zod.z.object({InstanceID:zod.z.string(),BoostID:zod.z.string(),ActivatedAtUtc:a.nullish(),ExpiresAtUtc:a.nullish(),RemainingCharges:zod.z.number().nullish(),EffectSnapshot:yt.nullish(),SourceType:zod.z.string().nullish(),SourceRef:zod.z.string().nullish()}).passthrough();zod.z.object({Date:a.nullish(),DailyCount:zod.z.number().nullish(),LastFiredUtc:a.nullish()}).passthrough();var Ia=zod.z.object({ServerTimeUtc:a.nullish(),Active:zod.z.record(zod.z.string(),Pa).nullish()}),Ma=zod.z.object({ServerTimeUtc:a.nullish(),BoostID:zod.z.string().nullish(),StackingPolicy:zod.z.string().nullish(),ActivatedBoost:Pa.nullish(),Resources:x.nullish()}),km={Scheduled:"Scheduled",Chain:"Chain"},Am=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:a.nullish(),EndUtc:a.nullish(),Effects:zod.z.array(yt).nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),ka=zod.z.object({ServerTimeUtc:a.nullish(),Windows:zod.z.array(Am).nullish()}),ot={GetDefinitions:"GetDefinitions",GetActive:"GetActive",GetActiveWindows:"GetActiveWindows",Activate:"Activate",CleanupExpired:"CleanupExpired"};var Rr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"TimedBoost",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(ot.GetDefinitions,e,gr)}getActive(e){return this.send(ot.GetActive,e,Ia)}getActiveWindows(e){return this.send(ot.GetActiveWindows,e,ka)}activate(e){return this.send(ot.Activate,e,Ma)}cleanupExpired(e){return this.send(ot.CleanupExpired,e,Se)}};var yr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"UserCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getUserCustomDataDefinitions(e){return this.send(Le.GetUserCustomDataDefinitions,e,fs)}getMyUserCustomData(e){return this.send(Le.GetMyUserCustomData,e,sn)}getPublicUserCustomDataOf(e){return this.send(Le.GetPublicUserCustomDataOf,e,Wr)}setPrivateData(e){return this.send(Le.SetPrivateData,e,Vr)}setPublicData(e){return this.send(Le.SetPublicData,e,Vr)}deleteKey(e){return this.send(Le.DeleteKey,e,Se)}batchSet(e){return this.send(Le.BatchSet,e,rn)}batchDelete(e){return this.send(Le.BatchDelete,e,nn)}batchGetPublicUserCustomDataOf(e){return this.send(Le.BatchGetPublicUserCustomDataOf,e,on)}};var Om={Static:"Static",Runtime:"Runtime"},Bm={Public:"Public",Private:"Private"},Um=zod.z.enum(["Client","Server","System"]),wm=zod.z.enum(["String","Int","Bool","Json"]),qm=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:a.nullish(),Version:zod.z.number().nullish(),LastWriter:Um.nullish(),ExpiresAt:a.nullish()}).passthrough(),Aa=zod.z.record(zod.z.string(),qm),ki=zod.z.object({StaticVersion:zod.z.number().nullish(),RuntimeVersion:zod.z.number().nullish(),Static:Aa.nullish(),Runtime:Aa.nullish(),NotModified:zod.z.boolean().nullish()}),Em=zod.z.object({KeyID:zod.z.string(),Scope:zod.z.enum(["Static","Runtime"]).nullish(),Bucket:zod.z.enum(["Public","Private"]).nullish(),ValueType:wm.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),Cr=zod.z.object({Keys:zod.z.record(zod.z.string(),Em).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(),It={GetTitleCustomDataDefinitions:"GetTitleCustomDataDefinitions",GetPublicTitleData:"GetPublicTitleData",GetPublicTitleDataKeys:"GetPublicTitleDataKeys"};var Sr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"TitleCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getTitleCustomDataDefinitions(e){return this.send(It.GetTitleCustomDataDefinitions,e,Cr)}getPublicTitleData(e){return this.send(It.GetPublicTitleData,e,ki)}getPublicTitleDataKeys(e){return this.send(It.GetPublicTitleDataKeys,e,ki)}};var Lm={Fast:"Fast",Sequential:"Sequential"},Gm={Instant:"Instant",Timed:"Timed"},Nm={Hit:"Hit",Blocked:"Blocked"},jm=zod.z.object({SlotIndex:zod.z.number(),Level:zod.z.number().nullish(),IsDamaged:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish()}).passthrough(),Fm=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 Oa=zod.z.object({}).passthrough().transform(u=>u),Ba=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),ze=zod.z.object({Operation:x.nullish(),ScaleWithRollMultiplier:zod.z.boolean().nullish()}).passthrough(),_m=zod.z.object({Count:zod.z.number().nullish(),Sides:zod.z.number().nullish()}).passthrough(),Wm=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(),Vm=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:oe.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(),Qm=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:oe.nullish()}).passthrough(),Ua=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(),Hm=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(),Km=zod.z.object({Tiles:zod.z.record(zod.z.string(),Hm).nullish()}).passthrough(),$m=zod.z.object({Weight:zod.z.number().nullish(),Bonus:ze.nullish(),Tag:zod.z.string().nullish()}).passthrough(),Zm=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($m).nullish(),GuaranteedBonus:ze.nullish(),IsJackpot:zod.z.boolean().nullish(),JackpotFinalMultiplier:zod.z.number().nullish(),JackpotSymbolDistribution:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough(),Jm=zod.z.object({Variants:zod.z.array(Zm).nullish()}).passthrough(),Ym=zod.z.object({Weight:zod.z.number().nullish(),OutcomeID:zod.z.string().nullish(),Reward:ze.nullish(),ForceAction:zod.z.string().nullish(),SpecialModeID:zod.z.string().nullish()}).passthrough(),Xm=zod.z.object({Outcomes:zod.z.array(Ym).nullish()}).passthrough(),wa=zod.z.object({PerAdMultiplierRange:Ba.nullish(),MaxAdViews:zod.z.number().nullish(),AdCreditCost:zod.z.number().nullish(),FormulaKind:zod.z.string().nullish(),ApplyMultiplierOnEarlyClaim:zod.z.boolean().nullish()}).passthrough(),eh=zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:ze.nullish()}).passthrough(),th=zod.z.object({Tiers:zod.z.array(eh).nullish(),BelowFirstTierReward:ze.nullish()}).passthrough(),sh=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:ze.nullish(),DurationSeconds:zod.z.number().nullish(),EntryCost:H.nullish(),Multipliers:wa.nullish(),Gradation:th.nullish()}).passthrough(),rh=zod.z.object({Choices:zod.z.array(sh).nullish(),OfferExpireSeconds:zod.z.number().nullish(),ClaimExpireSeconds:zod.z.number().nullish()}).passthrough(),ih=zod.z.object({Chance:zod.z.number().nullish(),RequiredOutcome:zod.z.string().nullish(),Reward:ze.nullish(),Tag:zod.z.string().nullish()}).passthrough(),nh=zod.z.object({OnPassStart:ze.nullish(),OnTileLanding:zod.z.record(zod.z.string(),ze).nullish(),OnAttack:zod.z.record(zod.z.string(),ze).nullish(),OnRaid:zod.z.record(zod.z.string(),ze).nullish(),OnBuild:ze.nullish(),OnStageComplete:ze.nullish(),OnAttackBonusDrops:zod.z.array(ih).nullish(),ChanceTablesByID:zod.z.record(zod.z.string(),Xm).nullish(),SpecialModesByID:zod.z.record(zod.z.string(),rh).nullish()}).passthrough(),qa=zod.z.object({BaseAttackReward:G.nullish(),BaseRaidReward:G.nullish(),MaxRollMultiplier:zod.z.number().nullish(),MaxShields:zod.z.number().nullish(),Buildings:zod.z.array(Ua).nullish(),HeistGridBonusConfig:Jm.nullish(),StageOperations:nh.nullish(),TileLandingMultiplier:Ba.nullish(),EconomyOverride:Qm.nullish()}).passthrough(),oh=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(Ua).nullish(),StageTemplateID:zod.z.string().nullish(),CostMatrixTemplateID:zod.z.string().nullish(),UnitValue:zod.z.number().nullish(),Override:qa.nullish()}).passthrough(),xr=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(),Km).nullish(),StageTemplatesByID:zod.z.record(zod.z.string(),qa).nullish(),StagesByLevel:zod.z.record(zod.z.string(),oh).nullish(),SoftCurrencyID:zod.z.string().nullish(),ProceduralEconomy:Vm.nullish(),Dice:_m.nullish(),Bots:Wm.nullish()}).passthrough(),ah=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:a.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(),Dr=zod.z.object({Board:xr.nullish(),CommunityChest:ah.nullish()}).passthrough(),lh=zod.z.object({TargetUserID:zod.z.string().nullish(),IsBot:zod.z.boolean().nullish(),PublicData:Ce.nullish(),TargetBuildingStates:zod.z.array(jm).nullish(),TargetHasShield:zod.z.boolean().nullish()}).passthrough(),uh=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:ze.nullish(),DurationSeconds:zod.z.number().nullish(),EntryCost:H.nullish(),Multipliers:wa.nullish()}).passthrough(),ch=zod.z.object({ModeID:zod.z.string().nullish(),Choices:zod.z.array(uh).nullish()}).passthrough(),ph=zod.z.object({GroupID:zod.z.string().nullish(),Delta:k.nullish(),NewProgress:k.nullish(),MaxProgress:k.nullish(),UnlockedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),Completed:zod.z.boolean().nullish()}).passthrough(),Ea=zod.z.object({UsedMultiplier:zod.z.number().nullish(),Steps:zod.z.number().nullish(),OldPosition:zod.z.number().nullish(),NewPosition:zod.z.number(),CyclesCompletedDelta:k.nullish(),LandedTileType:zod.z.string().nullish(),Operation:x.nullish(),ActionRequired:zod.z.string().nullish(),ActionData:lh.nullish(),SpecialModeOffer:ch.nullish(),CommunityChestContribution:ph.nullish()}).passthrough(),La=zod.z.object({Outcome:zod.z.string().nullish(),IsBotTarget:zod.z.boolean().nullish(),BuildingIndexHit:zod.z.number().nullish(),Operation:x.nullish(),DualResult:tt.nullish()}).passthrough(),Ai=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(Fm).nullish(),HeistVariantTag:zod.z.string().nullish(),IsJackpot:zod.z.boolean().nullish(),Operation:x.nullish(),DualResult:tt.nullish()}).passthrough(),Ga=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(),Na=zod.z.object({Mode:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),Operation:x.nullish(),DurationSeconds:zod.z.number().nullish(),StartedAtUtc:a.nullish(),ExpiresAtUtc:a.nullish()}).passthrough(),ja=zod.z.object({AdViewsUsed:zod.z.number().nullish(),RolledMultiplier:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),RemainingAdViews:zod.z.number().nullish()}).passthrough(),Fa=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(),dh={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},_a=zod.z.enum(["Forming","Active","Completed","Failed","Expired"]),mh={Active:"Active",Left:"Left",Replaced:"Replaced"},hh=zod.z.enum(["Active","Left","Replaced"]),fh=zod.z.object({CurrentProgress:k.nullish(),MaxProgress:k.nullish()}).passthrough(),gh=zod.z.object({UserID:zod.z.string().nullish(),PublicData:Ce.nullish(),IsBot:zod.z.boolean().nullish(),ContributionPoints:k.nullish(),ClaimedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),GrandPrizeClaimed:zod.z.boolean().nullish(),MemberStatus:hh.nullish(),JoinedAtUtc:a.nullish(),LeftAtUtc:a.nullish()}).passthrough(),Wa=zod.z.object({GroupID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),Members:zod.z.array(gh).nullish(),SharedProgress:fh.nullish(),Status:_a.nullish(),CreatedAtUtc:a.nullish(),ExpiresAtUtc:a.nullish(),Version:zod.z.number().nullish()}).passthrough(),Rh=zod.z.object({GroupID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),FinalStatus:_a.nullish(),GrandPrizeReceived:zod.z.boolean().nullish(),FinishedAtUtc:a.nullish()}).passthrough(),yh=zod.z.object({ActiveGroupID:zod.z.string().nullish(),ActiveRoundIndex:zod.z.number().nullish(),History:zod.z.array(Rh).nullish()}).passthrough(),Va=zod.z.object({ServerTimeUtc:a.nullish(),UserState:yh.nullish(),ActiveGroup:Wa.nullish(),SecondsRemaining:k.nullish()}),Qa=zod.z.object({ServerTimeUtc:a.nullish(),Group:Wa.nullish(),SecondsRemaining:k.nullish()}),Oi=zod.z.object({ServerTimeUtc:a.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:x.nullish()}),Ha=zod.z.object({ServerTimeUtc:a.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 Ch=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(),Sh=zod.z.object({ExperimentID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Schedule:ue.nullish(),Gate:V.nullish(),Variants:zod.z.array(Ch).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(),Ka=zod.z.object({Experiments:zod.z.record(zod.z.string(),Sh).nullish()}).passthrough();var xh={Mesh:"Mesh",Host:"Host"},Bi=zod.z.enum(["Mesh","Host"]),Dh={ServerRelay:"ServerRelay",P2P:"P2P"},Ui=zod.z.enum(["ServerRelay","P2P"]),bh={Public:"Public",Private:"Private"},zh=zod.z.enum(["Public","Private"]),vh={Signal:"Signal",Chat:"Chat",PlayerJoined:"PlayerJoined",PlayerLeft:"PlayerLeft",HostChanged:"HostChanged",RoomClosed:"RoomClosed",MemberState:"MemberState"},Th=zod.z.enum(["Signal","Chat","PlayerJoined","PlayerLeft","HostChanged","RoomClosed","MemberState"]),$a=zod.z.object({Urls:zod.z.string().nullish(),Username:zod.z.string().nullish(),Credential:zod.z.string().nullish()}).passthrough(),Ph=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),Za=zod.z.object({SystemState:Ph.nullish(),DefaultTopology:Bi.nullish(),AllowCreatorTopologyOverride:zod.z.boolean().nullish(),DefaultChatMode:Ui.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($a).nullish()}).passthrough(),Ih=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(),Mh=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),Topology:Bi.nullish(),ChatMode:Ui.nullish(),MaxPlayers:zod.z.number().nullish(),MemberCount:zod.z.number().nullish(),CreatedAt:zod.z.number().nullish()}).passthrough(),kh=zod.z.object({Seq:zod.z.number().nullish(),Type:Th.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(),br=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),OwnerUserID:zod.z.string().nullish(),Topology:Bi.nullish(),ChatMode:Ui.nullish(),Visibility:zh.nullish(),Status:zod.z.string().nullish(),MaxPlayers:zod.z.number().nullish(),Members:zod.z.array(Ih).nullish(),IceServers:zod.z.array($a).nullish(),Seq:zod.z.number().nullish()}).passthrough(),wi=zod.z.object({Closed:zod.z.boolean().nullish(),NewHostUserID:zod.z.string().nullish()}).passthrough(),Ja=zod.z.object({Rooms:zod.z.array(Mh).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}).passthrough(),Ya=zod.z.object({Envelopes:zod.z.array(kh).nullish(),MaxSeq:zod.z.number().nullish()}).passthrough(),zr=zod.z.object({Seq:zod.z.number().nullish()}).passthrough(),Ue={CreateRoom:"CreateRoom",JoinRoom:"JoinRoom",LeaveRoom:"LeaveRoom",ListRooms:"ListRooms",GetRoom:"GetRoom",CloseRoom:"CloseRoom",Poll:"Poll",SendSignal:"SendSignal",SendChat:"SendChat",SetMemberState:"SetMemberState"};var Xa=zod.z.object({TitleCustomData:Cr.nullish(),Character:bs.nullish(),Item:qs.nullish(),Currency:Ds.nullish(),Store:Ls.nullish(),Lootbox:fi.nullish(),Quest:Et.nullish(),TimedEvent:Vs.nullish(),Leaderboard:Js.nullish(),Season:Xs.nullish(),Reward:gi.nullish(),Collection:lr.nullish(),Craft:bi.nullish(),DealOffer:Ii.nullish(),Premium:Di.nullish(),TimedBoost:gr.nullish(),CoopEvent:cr.nullish(),GameLoop:Dr.nullish(),Match:oi.nullish(),Experiment:Ka.nullish(),Blockchain:Xr.nullish(),Marketplace:ci.nullish(),Multiplayer:Za.nullish(),UserCustomData:fs.nullish(),Referral:Mi.nullish()}).passthrough();var Ct={GetTitlePublicConfiguration:"GetTitlePublicConfiguration",GetTitlePublicConfigurationExcept:"GetTitlePublicConfigurationExcept",GetCurrencyDefinitions:"GetCurrencyDefinitions",GetItemDefinitions:"GetItemDefinitions",GetServerTime:"GetServerTime"};var vr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Title",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getTitlePublicConfiguration(e){return this.send(Ct.GetTitlePublicConfiguration,e,Xa)}getCurrencyDefinitions(e){return this.send(Ct.GetCurrencyDefinitions,e,Ds)}getItemDefinitions(e){return this.send(Ct.GetItemDefinitions,e,qs)}getServerTime(e){return this.send(Ct.GetServerTime,e,Se)}};var Tr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s,r=false){let i=O(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,Dr)}getBoardDefinition(e,t=false){return this.send(me.GetBoardDefinition,e,xr,t)}getBoardDefinitionForLevel(e,t=false){return this.send(me.GetBoardDefinitionForLevel,e,xr,t)}getUserBoardState(e){return this.send(me.GetUserBoardState,e,Oa)}boardLoopRoll(e){return this.send(me.BoardLoopRoll,e,Ea)}boardLoopAttack(e){return this.send(me.BoardLoopAttack,e,La)}boardLoopRaid(e){return this.send(me.BoardLoopRaid,e,Ai)}boardLoopRaidFast(e){return this.send(me.BoardLoopRaidFast,e,Ai)}boardLoopBuild(e){return this.send(me.BoardLoopBuild,e,Ga)}boardSpecialChoose(e){return this.send(me.BoardSpecialChoose,e,Na)}boardSpecialApplyMultiplier(e){return this.send(me.BoardSpecialApplyMultiplier,e,ja)}boardSpecialClaim(e){return this.send(me.BoardSpecialClaim,e,Fa)}getCommunityChestState(e){return this.send(me.GetCommunityChestState,e,Va)}joinOrCreateCommunityChest(e){return this.send(me.JoinOrCreateCommunityChest,e,Qa)}claimCommunityChestMilestone(e){return this.send(me.ClaimCommunityChestMilestone,e,Oi)}claimCommunityChestGrandPrize(e){return this.send(me.ClaimCommunityChestGrandPrize,e,Oi)}leaveCommunityChest(e){return this.send(me.LeaveCommunityChest,e,Ha)}};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 Oh={Live:"Live",Latest:"Latest",Specific:"Specific"},Bh={Debug:"Debug",Info:"Info",Warning:"Warning",Error:"Error"},Uh=zod.z.enum(["Debug","Info","Warning","Error"]),wh={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"},qh=zod.z.enum(["None","Disabled","NoActiveRevision","RevisionNotFound","InvalidFieldName","RateLimited","HandlerNotFound","HandlerDisabled","Timeout","StatementCountExceeded","StackOverflow","ApiCallLimitExceeded","JavaScriptException","ExecutionError"]),Eh=zod.z.object({Level:Uh,Message:zod.z.string().nullish(),Data:Mt.nullish()}),Lh=zod.z.object({Error:qh,Message:zod.z.string().nullish(),StackTrace:zod.z.string().nullish()}),el=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(Eh).nullish(),LogsTooLarge:zod.z.boolean().nullish(),ExecutionTimeSeconds:zod.z.number().nullish(),APIRequestsIssued:zod.z.number().nullish(),Error:Lh.nullish()}),qi={Execute:"Execute"};var Pr=class{constructor(e){this.ctx=e;}ctx;execute(e){let t=O(this.ctx.settings.titleID,"CloudCode",qi.Execute,e.UserID??"");return this.ctx.transport.post(t,e,el,{ticket:e.ClientSessionTicket})}};var Ir=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(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,An)}getUserState(e){return this.send(Pe.GetUserState,e,On)}depositToken(e){return this.send(Pe.DepositToken,e,Bn)}depositNFT(e){return this.send(Pe.DepositNFT,e,Un)}requestTokenWithdrawal(e){return this.send(Pe.RequestTokenWithdrawal,e,wn)}requestNFTWithdrawal(e){return this.send(Pe.RequestNFTWithdrawal,e,qn)}getTransactionHistory(e){return this.send(Pe.GetTransactionHistory,e,En)}retryWithdrawal(e){return this.send(Pe.RetryWithdrawal,e,Ln)}confirmWithdrawal(e){return this.send(Pe.ConfirmWithdrawal,e,Gn)}donateToDeveloper(e){return this.send(Pe.DonateToDeveloper,e,si)}donateToUsersPool(e){return this.send(Pe.DonateToUsersPool,e,si)}};var Mr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Marketplace",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(se.GetDefinitions,e,Xn)}getGroupedOffers(e){return this.send(se.GetGroupedOffers,e,eo)}getOffersByItem(e){return this.send(se.GetOffersByItem,e,pi)}getOffer(e){return this.send(se.GetOffer,e,to)}getBuyOrders(e){return this.send(se.GetBuyOrders,e,pi)}getMyState(e){return this.send(se.GetMyState,e,ro)}getHistory(e){return this.send(se.GetHistory,e,io)}createListing(e){return this.send(se.CreateListing,e,vt)}cancelListing(e){return this.send(se.CancelListing,e,Ae)}buy(e){return this.send(se.Buy,e,Ae)}marketBuy(e){return this.send(se.MarketBuy,e,Ae)}marketSell(e){return this.send(se.MarketSell,e,Ae)}createAuction(e){return this.send(se.CreateAuction,e,vt)}placeBid(e){return this.send(se.PlaceBid,e,so)}claimAuction(e){return this.send(se.ClaimAuction,e,Ae)}createBuyOrder(e){return this.send(se.CreateBuyOrder,e,vt)}cancelBuyOrder(e){return this.send(se.CancelBuyOrder,e,Ae)}fillBuyOrder(e){return this.send(se.FillBuyOrder,e,Ae)}createDirectTrade(e){return this.send(se.CreateDirectTrade,e,vt)}respondDirectTrade(e){return this.send(se.RespondDirectTrade,e,Ae)}cancelDirectTrade(e){return this.send(se.CancelDirectTrade,e,Ae)}claimBack(e){return this.send(se.ClaimBack,e,Ae)}};var kr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Multiplayer",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}createRoom(e){return this.send(Ue.CreateRoom,e,br)}joinRoom(e){return this.send(Ue.JoinRoom,e,br)}leaveRoom(e){return this.send(Ue.LeaveRoom,e,wi)}listRooms(e){return this.send(Ue.ListRooms,e,Ja)}getRoom(e){return this.send(Ue.GetRoom,e,br)}closeRoom(e){return this.send(Ue.CloseRoom,e,wi)}poll(e){return this.send(Ue.Poll,e,Ya)}sendSignal(e){return this.send(Ue.SendSignal,e,zr)}sendChat(e){return this.send(Ue.SendChat,e,zr)}setMemberState(e){return this.send(Ue.SetMemberState,e,zr)}};var Ar=class{settings;emitter;platform;transport;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=Gi(e),this.emitter=new xt,this.platform=e.platform??new ct,this.transport=new Nt({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.authStore=new Vt(this.platform.storage,this.settings.titleID),this.api={authentication:new Os(this),user:new Bs(this),currency:new Us(this),item:new Es(this),store:new Gs(this),lootbox:new Fs(this),reward:new _s(this),quest:new Ws(this),timedEvent:new Qs(this),leaderboard:new Ys(this),season:new er(this),premium:new sr(this),character:new rr(this),match:new ir(this),craft:new or(this),collection:new ur(this),coopEvent:new pr(this),dealOffer:new dr(this),referral:new mr(this),social:new fr(this),timedBoost:new Rr(this),userCustomData:new yr(this),titleCustomData:new Sr(this),title:new vr(this),gameLoop:new Tr(this),cloudCode:new Pr(this),blockchain:new Ir(this),marketplace:new Mr(this),multiplayer:new kr(this)},this.userService=new Ht(this),this.auth=new Qt(this),this.currency=new $t(this),this.item=new Zt(this),this.store=new Jt(this),this.lootbox=new Yt(this),this.reward=new Xt(this),this.quest=new es(this),this.timedEvent=new ts(this),this.leaderboard=new ss(this),this.season=new rs(this),this.premium=new is(this),this.character=new ns(this),this.match=new os(this),this.craft=new as(this),this.collection=new ls(this),this.coopEvent=new us(this),this.dealOffer=new cs(this),this.referral=new ps(this),this.social=new ds(this),this.timedBoost=new ms(this),this.userCustomData=new gs(this),this.titleCustomData=new Rs(this),this.title=new ys(this),this.gameLoop=new Cs(this),this.cloudCode=new Ss(this),this.blockchain=new Ts(this),this.marketplace=new ks(this),this.multiplayer=new As(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:M()}}};var Or=class{ctx;constructor(e){this.ctx=new Ar(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 Gh(u){return new Or(u)}var Nh={Banner:"Banner",Interstitial:"Interstitial",RewardedVideo:"RewardedVideo",RewardedInterstitial:"RewardedInterstitial",AppOpen:"AppOpen",Native:"Native"},Ei=zod.z.enum(["Banner","Interstitial","RewardedVideo","RewardedInterstitial","AppOpen","Native"]),jh={Top:"Top",Bottom:"Bottom",Left:"Left",Right:"Right"},Fh=zod.z.enum(["Top","Bottom","Left","Right"]),_h=zod.z.object({PlacementID:zod.z.string().nullish(),Type:Ei.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(),Wh=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(),Vh=zod.z.object({CooldownSeconds:zod.z.number().nullish(),MinSessionTimeBeforeFirstSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),Qh=zod.z.object({Enabled:zod.z.boolean().nullish(),Position:Fh.nullish(),RefreshIntervalSeconds:zod.z.number().nullish()}).passthrough(),Hh=zod.z.object({Enabled:zod.z.boolean().nullish(),CooldownSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish()}).passthrough(),Kh=zod.z.object({MaxImpressionsPerHour:zod.z.number().nullish(),MaxImpressionsPerDay:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),$h=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(),Zh=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(),Jh=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(),Yh=zod.z.object({AndroidUnitID:zod.z.string().nullish(),IosUnitID:zod.z.string().nullish(),WebUnitID:zod.z.string().nullish(),Type:Ei.nullish()}).passthrough(),Xh=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(),Yh).nullish()}).passthrough();zod.z.object({Enabled:zod.z.boolean().nullish(),Placements:zod.z.record(zod.z.string(),_h).nullish(),Providers:zod.z.record(zod.z.string(),Xh).nullish(),RewardedVideo:Wh.nullish(),Interstitial:Vh.nullish(),Banner:Qh.nullish(),AppOpen:Hh.nullish(),FrequencyCapping:Kh.nullish(),PremiumAdReductions:zod.z.array($h).nullish(),Consent:Zh.nullish(),Verification:Jh.nullish()}).passthrough();var ef=zod.z.object({RewardedVideoCredit:zod.z.number().nullish(),TotalEarned:zod.z.number().nullish(),TotalSpent:zod.z.number().nullish()}).passthrough(),tf=zod.z.object({PlacementID:zod.z.string().nullish(),LastShownAt:a.nullish(),LastCompletedAt:a.nullish(),TotalImpressions:zod.z.number().nullish(),TotalCompletions:zod.z.number().nullish(),ConsecutiveFailures:zod.z.number().nullish()}).passthrough(),sf=zod.z.object({Date:a.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(),rf=zod.z.object({SessionID:zod.z.string().nullish(),SessionStartAt:a.nullish(),Impressions:zod.z.number().nullish(),InterstitialImpressions:zod.z.number().nullish(),RewardedCompletions:zod.z.number().nullish()}).passthrough(),nf=zod.z.object({PersonalizedAdsConsent:zod.z.boolean().nullish(),TrackingConsent:zod.z.boolean().nullish(),PolicyVersion:zod.z.string().nullish(),Region:zod.z.string().nullish(),ConsentGivenAt:a.nullish(),ConsentRevokedAt:a.nullish()}).passthrough(),of=zod.z.object({RequestID:zod.z.string().nullish(),PlacementID:zod.z.string().nullish(),ProviderID:zod.z.string().nullish(),Type:Ei.nullish(),IssuedAt:a.nullish(),ExpiresAt:a.nullish(),CreditsToAward:zod.z.number().nullish()}).passthrough(),af=zod.z.object({InvalidSsvCount:zod.z.number().nullish(),OrphanCompletions:zod.z.number().nullish(),FastCompletions:zod.z.number().nullish(),LastFlaggedAt:a.nullish()}).passthrough();zod.z.object({Credits:ef.nullish(),Placements:zod.z.record(zod.z.string(),tf).nullish(),Daily:sf.nullish(),Session:rf.nullish(),LastImpressionAt:a.nullish(),LastInterstitialAt:a.nullish(),LastRewardedAt:a.nullish(),LastAppOpenAt:a.nullish(),TotalImpressions:zod.z.number().nullish(),TotalRewardedCompletions:zod.z.number().nullish(),AdsDisabledUntil:a.nullish(),Consent:nf.nullish(),PendingRequests:zod.z.record(zod.z.string(),of).nullish(),FraudFlags:af.nullish(),UpdatedAt:a.nullish()}).passthrough();var lf={Unread:"Unread",Read:"Read",Deleted:"Deleted",Expired:"Expired"},uf=zod.z.enum(["Unread","Read","Deleted","Expired"]),cf={Admin:"Admin",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season",Collection:"Collection",MilestoneEvent:"MilestoneEvent",PlayerGift:"PlayerGift",Social:"Social",Compensation:"Compensation",Referral:"Referral",Quest:"Quest"},pf=zod.z.enum(["Admin","Leaderboard","CoopEvent","Season","Collection","MilestoneEvent","PlayerGift","Social","Compensation","Referral","Quest"]),df={Active:"Active",Paused:"Paused",Cancelled:"Cancelled",Completed:"Completed"},mf=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(),ff=zod.z.object({SegmentID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Gate:V.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(ff).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:pf.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:a.nullish(),Status:uf.nullish(),CreatedAtUtc:a.nullish(),ExpiresAtUtc:a.nullish(),ReadAtUtc:a.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:a.nullish(),ExpiresAtUtc:a.nullish(),CreatedAtUtc:a.nullish(),CreatedByAdminID:zod.z.string().nullish(),AdminComment:zod.z.string().nullish(),Status:mf.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:a.nullish(),ReceivedBroadcastIDs:zod.z.array(zod.z.string()).nullish(),ClaimedBroadcastIDs:zod.z.array(zod.z.string()).nullish(),DailyP2PGiftsSent:zod.z.number().nullish(),DailyGiftsResetDate:a.nullish(),LastOpenedAtUtc:a.nullish(),TotalMessagesReceived:zod.z.number().nullish(),TotalRewardsClaimed:zod.z.number().nullish()}).passthrough();var tl="idos_device_id",Br=class{storage;constructor(e=new lt){this.storage=e;}getPlatform(){return "Web"}getFullURL(){return ""}getStartParameter(){return null}getTelegramInitDataRaw(){return null}getDeviceID(){let e=this.storage.getString(tl);return e||(e="noop-device",this.storage.setString(tl,e)),e}getDeviceModel(){return "Noop"}shareLink(){}openInvoice(){}async showAd(){}async copyToClipboard(){}};
|
|
2
|
-
exports.AdType=
|
|
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 yl(){let a=new Map;return {get:e=>a.get(e)??null,set:(e,t)=>{a.set(e,t);},remove:e=>{a.delete(e);}}}function Wi(){return Cl()??yl()}function Cl(){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 Qi="https://api.idosgames.com";function Hi(a){return {titleID:a.titleID,titleTemplateID:a.titleTemplateID??"default",buildKey:a.buildKey??"",baseUrl:(a.baseUrl??Qi).replace(/\/+$/,""),devBuild:a.devBuild??false,debugLogging:a.debugLogging??false,configStorage:a.configStorage??Wi()}}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 Ki="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(Ki);return e||(e=k(),this.storage.setString(Ki,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 $i(a){return {ok:true,data:a}}function n(a,e){return {ok:false,reason:a,error:e}}function Sl(a){return a.ok}function xl(a){return !a.ok}var qe={Virtual:"Virtual",Crypto:"Crypto"},ht=zod.z.enum(["Virtual","Crypto"]),Dl={Item:"Item",VirtualCurrency:"VirtualCurrency",CryptoCurrency:"CryptoCurrency",UsdCent:"UsdCent"},Ot=zod.z.enum(["Item","VirtualCurrency","CryptoCurrency","UsdCent"]),bl={TimedEvent:"TimedEvent",Quest:"Quest",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season"},wt=zod.z.enum(["TimedEvent","Quest","Leaderboard","CoopEvent","Season"]),vl={Cyclic:"Cyclic",Scheduled:"Scheduled",Chained:"Chained"},vt=zod.z.enum(["Cyclic","Scheduled","Chained"]),ce={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()}),zl=zod.z.object({Type:wt.nullish(),EntityID:zod.z.string()}),Tl=zod.z.object({Address:zl.nullish(),Amount:M.nullish(),Source:zod.z.string().nullish()}),ue=zod.z.object({Entries:zod.z.array(Er).nullish(),EventTokens:zod.z.array(Tl).nullish()}),Zi=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Resources:ue.nullish()}),G=zod.z.object({Standard:ue.nullish(),PremiumBonuses:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(Zi).nullish()}),K=zod.z.object({Standard:ue.nullish(),PremiumDiscounts:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(Zi).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:ue.nullish()});var Pl=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:Pl.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 Il=zod.z.object({OffsetSecondsFromParentStart:zod.z.number().nullish(),DurationSeconds:zod.z.number().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),kl=zod.z.object({StartUtc:zod.z.string().nullish(),EndUtc:zod.z.string().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Ml=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 Al=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:kl.nullish(),Chain:Ml.nullish(),Cyclic:Al.nullish(),ActivationTriggers:zod.z.array(_e).nullish(),Relative:Il.nullish()}).passthrough();var Ul=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Rewards:G.nullish()}).passthrough(),Ol=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(Ul).nullish(),Multipliers:zod.z.array(Ol).nullish()}).passthrough();var wl=zod.z.enum(["BoardStageLevel","BoardRank","BoardCyclesCompleted","CharacterLevel","SeasonTier","EventTokenTotalEarned","VirtualCurrencyBalance","PlayerLevel"]);var Bl=zod.z.enum(["Tiered","Linear"]);var ql=zod.z.enum(["Step","Linear"]),El=zod.z.object({AtProgress:zod.z.number().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),Bt=zod.z.object({Source:wl.nullish(),SourceKey:zod.z.string().nullish(),CurveType:Bl.nullish(),Tiers:zod.z.array(El).nullish(),TierMode:ql.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:ue.nullish(),ExcludeRewards:ue.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 Ll=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:Ll.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 Gl={Active:"Active",Completed:"Completed",Claimed:"Claimed",Expired:"Expired"},Ji=zod.z.enum(["Active","Completed","Claimed","Expired"]),Nl=zod.z.object({}).passthrough().transform(a=>a),jl=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:Ji}),Yi=zod.z.object({State:Nl.nullish(),PointsTracks:zod.z.record(zod.z.string(),jl).nullish()}),Nr=zod.z.object({ServerTimeUtc:l,QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),NewStatus:Ji.nullish(),Resources:x.nullish()}),jr=zod.z.object({ServerTimeUtc:l,CycleID:zod.z.string(),MilestoneID:zod.z.string(),PointsTotalEarned:M.nullish(),Resources:x.nullish()}),Xi=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()}),en=zod.z.object({MetricID:zod.z.string(),Updates:zod.z.array(Gr).nullish()}),tn=zod.z.array(re(Nr)),sn=zod.z.array(re(jr)),Fl={ClientApi:"ClientApi",ServerApi:"ServerApi",SystemEvent:"SystemEvent"},Vl=zod.z.enum(["ClientApi","ServerApi","SystemEvent"]),_l={BlockProgressAndClaim:"BlockProgressAndClaim",BlockClaimOnly:"BlockClaimOnly"},Wl=zod.z.enum(["BlockProgressAndClaim","BlockClaimOnly"]),rn=zod.z.object({ObjectiveID:zod.z.string().nullish(),Source:Vl.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(),Ql=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(),nn=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:Wl.nullish()}).passthrough(),on=zod.z.object({Schedule:pe.nullish(),AccrueProgressWhenLocked:zod.z.boolean().nullish(),Gate:Q.nullish(),Limits:de.nullish()}).passthrough(),an=zod.z.object({Grant:G.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),Hl=zod.z.object({QuestID:zod.z.string().nullish(),Identity:Ql.nullish(),Linking:nn.nullish(),Availability:on.nullish(),Objectives:zod.z.record(zod.z.string(),rn).nullish(),Reward:an.nullish(),Presets:Fr.nullish()}).passthrough(),Kl=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(),$l=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(),Zl=zod.z.object({Milestones:zod.z.record(zod.z.string(),Xe).nullish(),Linking:zod.z.record(zod.z.string(),nn).nullish(),Availability:zod.z.record(zod.z.string(),on).nullish(),Reward:zod.z.record(zod.z.string(),an).nullish(),Objectives:zod.z.record(zod.z.string(),zod.z.record(zod.z.string(),rn)).nullish()}).passthrough(),Jl=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(),Kl).nullish(),Phases:zod.z.record(zod.z.string(),$l).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(),Jl).nullish(),Quests:zod.z.record(zod.z.string(),Hl).nullish(),Presets:Zl.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 ln(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 Yl=12e3,Xl=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??Yl,q=r.autoRetry??!0,se=!1,ge=0;for(;;){let Ie;try{Ie=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 ke=Ie.status;if(ke>=200&&ke<300)return await this.parseSuccess(Ie,s,v,e);if(ke===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(ln(ke)){if(q&&ge<3){ge++,await _r(Vr(ge));continue}return this.connectionFailure(`Server temporarily unavailable (HTTP ${ke})`,v)}return await this.handleWebError(Ie,ke,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=Xl.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 $i(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 cn(a){let e=new Date(a);return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+1)).toISOString()}function pn(a,e){return new Date(a.getTime()+e*6e4).toISOString()}function dn(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,Ie=new Map,ke=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=tu(t,j.CatalogID,j.ItemID),X=(W?W.IsStackable??true:true)?H?ge:se:H?ke:Ie;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||Ie.size>0||ke.size>0,r.itemsChanged){i.Items??={},i.UnstackableItems??={};let te=i.UnstackableItems,le=new Set([...se.keys(),...ge.keys(),...Ie.keys(),...ke.keys()]);for(let H of le){let j=(se.get(H)??0)-(ge.get(H)??0),_=(Ie.get(H)??0)-(ke.get(H)??0),W=j+_,Me=i.Items[H];Me?(j!==0&&(Me.StackableAmount+=j),_!==0&&(Me.UnstackableAmount+=_),W!==0&&(Me.TotalAmount+=W)):i.Items[H]={StackableAmount:Math.max(0,j),UnstackableAmount:Math.max(0,_),TotalAmount:Math.max(0,W)};}for(let[H,j]of ke){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(eu).slice(0,j).map(W=>W.ItemInstanceID);for(let W of _)delete te[W];}for(let[H,j]of Ie){let _=su(t,H);for(let W=0;W<j;W++){let Me=k();te[Me]={ItemInstanceID:Me,ItemID:H,CatalogID:_,RemainingUses:1,AcquiredAt:c};}}}a.EventToken??={};let Rl=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 Me=ru(Rl,_.Type);if(!Me)continue;let X=Me[_.EntityID];X||(X={},Me[_.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 eu(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 tu(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 su(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 ru(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=dn(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=cn(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 iu(e)?e:ce.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 iu(a){return a!==null&&Object.values(ce).includes(a)}var nu=8,ou=100,au=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i,hn=["GameLoop"],Ht=class{constructor(e){this.ctx=e;}ctx;authContext=null;refreshing=false;rememberSession=true;sessionAuthType=ce.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(ce.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(ce.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(ce.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(ce.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(ce.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(ce.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(ce.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 ce.Email:return this.loginWithEmail(t,s);case ce.Device:case ce.None:return this.loginWithDeviceID();case ce.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!==ce.None?this.sessionAuthType:this.ctx.authStore.lastAuthType;if(e===ce.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&&au.test(e)}static isValidPasswordLength(e){return e.length>=nu&&e.length<=ou}keepEmailCredentials(e,t){this.sessionEmail=e,this.sessionPassword=t,this.rememberSession&&this.ctx.authStore.saveEmailAndPassword(e,t);}forgetSession(){this.sessionAuthType=ce.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(hn,hn);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 lu="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:${mn(t)}`:e&&e.length>0?`f:${mn(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 `${lu}:${this.titleId}:${e}`}};function mn(a){return [...a].map(e=>e.toLowerCase()).sort().join(",")}var uu="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 `${uu}:${this.titleId}:${e}`}};function cu(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 pu(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=cu(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=pu(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 fn=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?fn:(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?fn:(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 Ie={Consume:se.length>0?{Standard:{Entries:se}}:null,Grant:ge.length>0?{Standard:{Entries:ge}}:null};this.ctx.data.user.applyResourceOperation(Ie,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 du="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(du,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 hu="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(hu,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 mu="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(mu,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 fu="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(fu,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 gu="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(gu,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 Ru="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(Ru,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 yu="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(yu,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 Cu="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(Cu,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 Su="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(Su,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 xu="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(xu,t.data),this.ctx.emitter.emit("match:definitionsLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Du="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(Du,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 bu="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(bu,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 vu="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(vu,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 zu="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(zu,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 Tu="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(Tu,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 Pu="TimedBoost";function Iu(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(Pu,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(!Iu(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"},ku={Client:"Client",Server:"Server",System:"System"},Mu=zod.z.enum(["Client","Server","System"]),Au=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:l.nullish(),Version:zod.z.number().nullish(),LastWriter:Mu.nullish(),ExpiresAt:l.nullish()}).passthrough(),Rs=zod.z.record(zod.z.string(),Au),gn=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()}),Uu=zod.z.object({Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:l.nullish()}),Rn=zod.z.object({ServerTimeUtc:l.nullish(),Results:zod.z.array(Uu).nullish()}),yn=zod.z.object({ServerTimeUtc:l.nullish(),DeletedCount:zod.z.number().nullish()}),Cn=zod.z.object({Results:zod.z.array(Zr).nullish(),NotFoundUserIDs:zod.z.array(zod.z.string()).nullish()}),Ou={String:"String",Int:"Int",Bool:"Bool",Json:"Json"},wu=zod.z.enum(["String","Int","Bool","Json"]),Bu=zod.z.object({KeyID:zod.z.string(),Bucket:zod.z.string().nullish(),ValueType:wu.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(),Bu).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 qu="UserCustomData";function Sn(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(qu,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(!Sn(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(!Sn(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 Eu="TitleCustomDataDefinitions",xn=50;function Lu(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 Gu(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(Eu,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=>!Lu(i)))return n("client",'KeyID must not contain "." or "$".');if(t.length>xn)return n("client",`At most ${xn} 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=Gu(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 Nu=15,ju="GameLoop",Fu="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(ju,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(Fu,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=pn(new Date,Nu);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 Dn=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}),bn=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"},Vu={Active:"Active",Hidden:"Hidden",Deprecated:"Deprecated",Maintenance:"Maintenance"},vn=zod.z.enum(["Active","Hidden","Deprecated","Maintenance"]),_u={Automatic:"Automatic",Manual:"Manual"},Wu=zod.z.enum(["Automatic","Manual"]),Qu=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(),Hu=zod.z.object({Rate:zod.z.number().nullish(),Max:zod.z.number().nullish(),Period:zod.z.number().nullish()}).passthrough(),Ku=zod.z.object({IsTradable:zod.z.boolean().nullish(),IsPurchasable:zod.z.boolean().nullish(),IsRefundable:zod.z.boolean().nullish()}).passthrough(),$u=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(),zn=zod.z.object({Enabled:zod.z.boolean().nullish(),RateMode:Wu.nullish(),FeePercent:B.nullish(),Targets:zod.z.array($u).nullish()}).passthrough(),Tn=zod.z.object({CreatedAt:l.nullish(),UpdatedAt:l.nullish()}).passthrough(),Zu=zod.z.object({CurrencyID:zod.z.string(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Economy:Qu.nullish(),Recharge:Hu.nullish(),Conversion:zn.nullish(),Permissions:Ku.nullish(),Audit:Tn.nullish(),Status:vn.nullish()}).passthrough(),Ju=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(),Yu=zod.z.object({DailyWithdrawUsd:B.nullish(),MonthlyWithdrawUsd:B.nullish(),KycRequiredAboveUsd:B.nullish()}).passthrough(),Xu=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(Ju).nullish(),Limits:Yu.nullish(),Permissions:Xu.nullish(),Conversion:zn.nullish(),Audit:Tn.nullish(),Status:vn.nullish()}).passthrough(),zs=zod.z.object({VirtualCurrencies:zod.z.record(zod.z.string(),Zu).nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Xr).nullish()}).passthrough();var Pn=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(),Pn).nullish(),UpdatedAt:l.nullish()}).passthrough(),ec=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),tc=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:ec.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(a=>a),et=zod.z.object({ChangedInstances:zod.z.record(zod.z.string(),tc).nullish(),RemovedInstanceIDs:zod.z.array(zod.z.string()).nullish()}),In=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()}),kn=zod.z.object({ServerTimeUtc:l,CharacterID:zod.z.string(),Equipment:zod.z.record(zod.z.string(),Pn).nullish(),ReplacedInstanceIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:et.nullish()}),Mn=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()}),sc=zod.z.object({ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish()}),An=zod.z.object({ServerTimeUtc:l,Characters:zod.z.record(zod.z.string(),sc).nullish(),Inventory:et.nullish()}),ri=zod.z.object({ServerTimeUtc:l,CharacterID:zod.z.string(),Power:zod.z.number().nullish(),Resources:x.nullish()}),Un=Et(ri),On=Et(si),wn=Et(ti),Bn=zod.z.object({RequiredStatID:zod.z.string(),RequiredLevel:zod.z.number()}).passthrough(),qn=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(Bn).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),En=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(),rc=zod.z.object({SlotID:zod.z.string(),MinCharacterLevel:zod.z.number().nullish(),StatRequirements:zod.z.array(Bn).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(),Ln=zod.z.object({Slots:zod.z.record(zod.z.string(),rc).nullish()}).passthrough(),ic=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(),nc=zod.z.object({ClassID:zod.z.string().nullish(),RarityID:zod.z.string().nullish(),Tags:zod.z.array(zod.z.string()).nullish()}).passthrough(),oc=zod.z.object({UnlockedByDefault:zod.z.boolean().nullish(),Cost:K.nullish()}).passthrough(),ac=zod.z.object({Stats:ne.nullish(),Levels:ne.nullish(),Equipment:ne.nullish()}).passthrough(),lc=zod.z.object({CharacterID:zod.z.string(),Identity:ic.nullish(),Classification:nc.nullish(),Unlock:oc.nullish(),Presets:ac.nullish(),Equipment:Ln.nullish(),Stats:zod.z.record(zod.z.string(),qn).nullish(),Levels:zod.z.record(zod.z.string(),En).nullish()}).passthrough(),uc=zod.z.object({Stats:zod.z.record(zod.z.string(),qn).nullish()}).passthrough(),cc=zod.z.object({Levels:zod.z.record(zod.z.string(),En).nullish()}).passthrough(),pc=zod.z.object({Equipment:Ln.nullish()}).passthrough(),dc=zod.z.object({Stats:zod.z.record(zod.z.string(),uc).nullish(),Levels:zod.z.record(zod.z.string(),cc).nullish(),Equipment:zod.z.record(zod.z.string(),pc).nullish()}).passthrough(),Ts=zod.z.object({Definitions:zod.z.record(zod.z.string(),lc).nullish(),Presets:dc.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 hc={EVM:"EVM",Solana:"Solana"},mc=zod.z.enum(["EVM","Solana"]),fc={AutoLinkedFromTransaction:"AutoLinkedFromTransaction",SignatureVerified:"SignatureVerified",ManuallyLinked:"ManuallyLinked"},gc=zod.z.enum(["AutoLinkedFromTransaction","SignatureVerified","ManuallyLinked"]),Rc={Token:"Token",Nft:"Nft"},Gn=zod.z.enum(["Token","Nft"]),yc={NotRequested:"NotRequested",Pending:"Pending",Verified:"Verified",Rejected:"Rejected",Expired:"Expired"},Cc=zod.z.enum(["NotRequested","Pending","Verified","Rejected","Expired"]),Sc={None:"None",Tier1:"Tier1",Tier2:"Tier2",Tier3:"Tier3"},xc=zod.z.enum(["None","Tier1","Tier2","Tier3"]),Dc={Pending:"Pending",Completed:"Completed",Failed:"Failed",Expired:"Expired",Abandoned:"Abandoned"},ii=zod.z.enum(["Pending","Completed","Failed","Expired","Abandoned"]),Nn={GameTopUp:"game_topup",CommunityReward:"community_reward"};function Ps(a){let e=a?.trim();return e||Nn.GameTopUp}var bc={UsersCryptoWallet:"UsersCryptoWallet",Game:"Game"},jn=zod.z.enum(["UsersCryptoWallet","Game"]),vc=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(),Fn=zod.z.object({Ios:zod.z.boolean().nullish(),Android:zod.z.boolean().nullish(),Web:zod.z.boolean().nullish()}).passthrough(),zc=zod.z.object({NetworkID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Type:mc.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:Fn.nullish(),NftCollections:zod.z.array(vc).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Tc=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),NftDepositsEnabled:zod.z.boolean().nullish(),NftWithdrawalsEnabled:zod.z.boolean().nullish(),PlatformOverrides:Fn.nullish()}).passthrough(),Pc=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 Ic=zod.z.enum(["OnChain","Combined"]),kc=zod.z.object({Enabled:zod.z.boolean().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),MinBalance:B.nullish(),BalanceSource:Ic.nullish(),DenyMessage:zod.z.string().nullish()}).passthrough(),Mc=zod.z.object({Enabled:zod.z.boolean().nullish(),TokenGates:zod.z.array(kc).nullish(),WalletConnectProjectId:zod.z.string().nullish()}).passthrough(),ni=zod.z.object({SystemState:Tc.nullish(),Networks:zod.z.record(zod.z.string(),zc).nullish(),AccountSafety:Pc.nullish(),WalletLogin:Mc.nullish()}).passthrough(),Ac=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),LinkedAt:l.nullish(),LastUsedAt:l.nullish(),LinkType:gc.nullish(),IsSignatureVerified:zod.z.boolean().nullish()}).passthrough(),Vn=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Type:Gn.nullish(),NetworkID:zod.z.string().nullish(),AssetID:zod.z.string().nullish(),Amount:B.nullish(),CreatedAt:l.nullish(),ExpiresAt:l.nullish()}).passthrough(),Uc=zod.z.object({Status:Cc.nullish(),Tier:xc.nullish(),VerifiedAt:l.nullish(),ExpiresAt:l.nullish(),RejectedAt:l.nullish(),ProviderReference:zod.z.string().nullish(),RejectionReason:zod.z.string().nullish()}).passthrough(),Oc=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(),wc=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(),Oc).nullish()}).passthrough(),Bc=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(),qc=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(),Bc).nullish()}).passthrough(),Ec=zod.z.object({Tokens:wc.nullish(),Nfts:qc.nullish()}).passthrough(),Lc=zod.z.object({CurrencyID:zod.z.string().nullish(),Balance:B.nullish(),MinBalance:B.nullish()}).passthrough(),Gc=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(Lc).nullish()}).passthrough(),Nc=zod.z.object({Version:zod.z.number().nullish(),Stats:Ec.nullish(),LinkedWallets:zod.z.record(zod.z.string(),Ac).nullish(),LastWalletLogin:Gc.nullish(),PendingWithdrawals:zod.z.array(Vn).nullish(),Kyc:Uc.nullish(),FirstActivityAt:l.nullish(),LastActivityAt:l.nullish(),IsFlagged:zod.z.boolean().nullish(),FlagReason:zod.z.string().nullish()}).passthrough(),jc=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(),jc).nullish(),PendingAdded:Vn.nullish(),PendingRemovedIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),Fc=zod.z.object({Amount:B,Frozen:B,CreatedAt:l.nullish(),UpdatedAt:l.nullish()}).passthrough().transform(a=>a),Vc=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:jn.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(),_c=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:jn.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(),_n=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(_n).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(_n).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(),Wn=zod.z.object({Blockchain:ni.nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Xr).nullish()}).passthrough(),Qn=zod.z.object({State:Nc.nullish(),CryptoBalances:zod.z.record(zod.z.string(),Fc).nullish()}).passthrough(),Hn=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(),Kn=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(),$n=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(),Zn=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(),Jn=zod.z.object({TokenTransactions:zod.z.array(Vc).nullish(),NFTTransactions:zod.z.array(_c).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(),Yn=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Kind:Gn.nullish(),EvmSignature:oi.nullish(),SolanaSignature:ai.nullish()}).passthrough(),Xn=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 Wc="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(Wc,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 Qc={Head:"Head",Torso:"Torso",Legs:"Legs"},Ms=zod.z.enum(["Head","Torso","Legs"]),Hc={Open:"Open",InProgress:"InProgress",Cancelled:"Cancelled",Completed:"Completed"},ui=zod.z.enum(["Open","InProgress","Cancelled","Completed"]),so=zod.z.object({AttackTarget:Ms,DefenseTarget:Ms});var Kc=zod.z.enum(["Hit","Critical","Block","Dodge"]),$c=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:Kc.nullish(),DamageDealt:zod.z.number().nullish(),DefenderHpRemaining:zod.z.number().nullish()}).passthrough(),Zc=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(),Jc=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),to=zod.z.object({UserID:zod.z.string().nullish(),SelectedCharacterID:zod.z.string().nullish(),SelectedCharacter:ei.nullish(),BattleStrategy:zod.z.array(so).nullish(),UnstackableItems:zod.z.record(zod.z.string(),Jc).nullish(),Stats:Zc.nullish()}).passthrough(),Yc=zod.z.object({WinnerUserID:zod.z.string().nullish(),LoserUserID:zod.z.string().nullish(),Entry:ue.nullish(),NetReward:ue.nullish(),BattleLog:zod.z.array($c).nullish(),IsDraw:zod.z.boolean().nullish(),P1BattleProfile:to.nullish(),P2BattleProfile:to.nullish()}).passthrough(),ro=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(so).nullish(),TargetUserID:zod.z.string().nullish(),Entry:ue.nullish(),CreationCostPaid:ue.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(),io=zod.z.object({Status:ui,MatchID:zod.z.string(),Entry:ue.nullish(),Resources:x.nullish()}),no=zod.z.object({Match:ro.nullish()}),oo=zod.z.object({MatchID:zod.z.string(),Status:ui,Resources:x.nullish()}),ao=zod.z.object({Battle:Yc.nullish(),Resources:x.nullish(),ResourcesDual:st.nullish()}),ci=zod.z.object({Matches:zod.z.array(ro).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 Xc=zod.z.enum(["VirtualCurrency","Item","EventToken"]);var ep=zod.z.enum(["Constant","Stat","RankMultiplier","AllMight","GearFlat","GearPercent"]),tp=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(),sp=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(),rp=zod.z.object({Source:ep.nullish(),StatID:zod.z.string().nullish(),Value:zod.z.number().nullish(),OnePlus:zod.z.boolean().nullish()}).passthrough(),ip=zod.z.object({Coefficient:zod.z.number().nullish(),Factors:zod.z.array(rp).nullish()}).passthrough(),it=zod.z.object({Terms:zod.z.array(ip).nullish()}).passthrough(),np=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(),lo=zod.z.object({StatMapping:tp.nullish(),Combat:sp.nullish(),Formula:np.nullish()}).passthrough(),op=zod.z.object({BurnRate:zod.z.number().nullish()}).passthrough(),pi=zod.z.object({Kind:Xc.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(),uo=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(),co=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(),ap=zod.z.object({RuleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Economy:op.nullish(),Entry:uo.nullish(),Creation:co.nullish(),Settings:lo.nullish()}).passthrough(),lp=zod.z.object({Rules:zod.z.record(zod.z.string(),ap).nullish(),Defaults:lo.nullish(),EntryDefaults:uo.nullish(),CreationDefaults:co.nullish()}).passthrough(),di=zod.z.object({InstantBattle:lp.nullish()}).passthrough(),po=di;var up={Listing:"Listing",Auction:"Auction",BuyOrder:"BuyOrder",DirectTrade:"DirectTrade"},hi=zod.z.enum(["Listing","Auction","BuyOrder","DirectTrade"]),cp={Active:"Active",Completed:"Completed",Cancelled:"Cancelled",Declined:"Declined",Expired:"Expired"},mi=zod.z.enum(["Active","Completed","Cancelled","Declined","Expired"]),pp={Burn:"Burn",Ledger:"Ledger"},dp=zod.z.enum(["Burn","Ledger"]),Us={Item:"Item",VirtualCurrency:"VirtualCurrency"},fi=zod.z.enum(["Item","VirtualCurrency"]),hp=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:M.nullish()}).passthrough(),mp=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(),fp=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:M.nullish(),Sink:dp.nullish(),LedgerAccountID:zod.z.string().nullish(),PerCatalogOverrides:zod.z.record(zod.z.string(),hp).nullish(),ApplyToDirectTrades:zod.z.boolean().nullish()}).passthrough(),gp=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(),Rp=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(),yp=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(),Cp=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(),Sp=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(),xp=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:mp.nullish(),Commission:fp.nullish(),Tradability:gp.nullish(),Listings:Rp.nullish(),Auctions:yp.nullish(),BuyOrders:Cp.nullish(),DirectTrades:Sp.nullish(),Matching:xp.nullish()}).passthrough(),ho=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(),Dp=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(ho).nullish()}).passthrough(),As=zod.z.object({LastAt:l.nullish(),DailyCount:zod.z.number().nullish(),DailyResetUtc:l.nullish()}).passthrough(),bp=zod.z.object({Create:As.nullish(),Buy:As.nullish(),Sell:As.nullish(),Bid:As.nullish()}).passthrough(),vp=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),zp=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:vp.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(zp).nullish(),Price:ue.nullish(),Auction:Dp.nullish(),CreatedAt:l.nullish(),ExpiresAt:l.nullish()}).passthrough(),Tp=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(),mo=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(),fo=zod.z.object({Groups:zod.z.array(Tp).nullish()}).passthrough(),go=zod.z.object({Offer:He.nullish()}).passthrough(),Ae=zod.z.object({OfferID:zod.z.string().nullish(),Status:mi.nullish(),Settlement:st.nullish(),Resources:x.nullish(),CommissionTaken:ue.nullish()}).passthrough(),Tt=zod.z.object({OfferID:zod.z.string().nullish(),Offer:He.nullish(),Resources:x.nullish(),Matched:zod.z.boolean().nullish(),Settlement:Ae.nullish()}).passthrough(),Ro=zod.z.object({OfferID:zod.z.string().nullish(),CurrentBid:M.nullish(),BidCount:zod.z.number().nullish(),ExpiresAt:l.nullish(),Resources:x.nullish()}).passthrough(),yo=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(ho).nullish(),Limits:bp.nullish()}).passthrough(),Pp=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:ue.nullish(),CommissionTaken:ue.nullish(),CompletedAt:l.nullish()}).passthrough(),Co=zod.z.object({Entries:zod.z.array(Pp).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 Ip="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(Ip,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 So=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()}),xo=zod.z.object({Message:zod.z.string(),ExpiresAt:l}),Ue={LoginWithDeviceID:"LoginWithDeviceID",LoginWithTelegram:"LoginWithTelegram",LoginWithEmail:"LoginWithEmail",LoginWithGoogle:"LoginWithGoogle",LoginWithPlatformToken:"LoginWithPlatformToken",RegisterWithEmail:"RegisterWithEmail",RefreshPlatformToken:"RefreshPlatformToken",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,So,{ticket:null})}loginWithDeviceID(e){return this.login(Ue.LoginWithDeviceID,e)}loginWithTelegram(e){return this.login(Ue.LoginWithTelegram,e)}loginWithEmail(e){return this.login(Ue.LoginWithEmail,e)}loginWithGoogle(e){return this.login(Ue.LoginWithGoogle,e)}loginWithPlatformToken(e){return this.login(Ue.LoginWithPlatformToken,e)}registerWithEmail(e){return this.login(Ue.RegisterWithEmail,e)}requestWalletChallenge(e){return this.ctx.transport.post(this.endpoint(Ue.RequestWalletChallenge),e,xo,{ticket:null})}loginWithWallet(e){return this.login(Ue.LoginWithWallet,e)}forgotPassword(e){return this.ctx.transport.post(this.endpoint(Ue.ForgotPassword),e,Se,{ticket:null})}resetPassword(e){return this.ctx.transport.post(this.endpoint(Ue.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),Do=zod.z.object({StateEpoch:zod.z.string().nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).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(),User:zod.z.unknown().nullish()}).passthrough().transform(a=>a),vo=zod.z.object({}).passthrough().transform(a=>a),zo=zod.z.object({}).passthrough().transform(a=>a),To=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(),Po=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,Do,{ticket:e.ClientSessionTicket})}getUserState(e){return this.ctx.transport.post(this.endpoint(Oe.GetUserState,e.UserID),e,bo,{ticket:e.ClientSessionTicket})}getInventory(e){return this.ctx.transport.post(this.endpoint(Oe.GetInventory,e.UserID),e,vo,{ticket:e.ClientSessionTicket})}getEventTokens(e){return this.ctx.transport.post(this.endpoint(Oe.GetEventTokens,e.UserID),e,zo,{ticket:e.ClientSessionTicket})}getUsageTime(e){return this.ctx.transport.post(this.endpoint(Oe.GetUsageTime,e.UserID),e,To,{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,Po,{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,Dn)}cryptoConvert(e){return this.send(vs.CryptoConvert,e,bn)}};var kp=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(kp).nullish()}),Io=zod.z.array(re(Ci)),Ls={UpgradeLevel:"UpgradeLevel",UpgradeLevelsBatch:"UpgradeLevelsBatch"},Mp={FlatCount:"FlatCount",Merge:"Merge",InvestmentRefund:"InvestmentRefund"},Ap=zod.z.enum(["FlatCount","Merge","InvestmentRefund"]),Up={ProtectLeveled:"ProtectLeveled",CheapestFirst:"CheapestFirst",ClientSelected:"ClientSelected"},Op=zod.z.enum(["ProtectLeveled","CheapestFirst","ClientSelected"]),wp=zod.z.object({ContractAddress:zod.z.string().nullish(),TokenID:zod.z.string().nullish(),TokenStandard:zod.z.string().nullish()}).passthrough(),Bp=zod.z.object({Networks:zod.z.record(zod.z.string(),wp).nullish(),MetadataUrl:zod.z.string().nullish()}).passthrough(),qp=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(),Ep=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(),Lp=zod.z.object({ValuationMode:Ap.nullish(),MergeRatio:zod.z.number().nullish(),Selection:Op.nullish()}).passthrough(),Gp=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:Lp.nullish()}).passthrough(),Np=zod.z.object({RarityID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),AuthorID:zod.z.string().nullish()}).passthrough(),jp=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:Bp.nullish(),Stats:qp.nullish(),Equipment:Ep.nullish(),Upgrade:Gp.nullish(),Metadata:Np.nullish(),ExpirationDurationSeconds:zod.z.number().nullish()}).passthrough(),Fp=zod.z.object({Items:zod.z.record(zod.z.string(),jp).nullish()}).passthrough(),Gs=zod.z.object({Catalogs:zod.z.record(zod.z.string(),Fp).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,Io,{ticket:e.ClientSessionTicket})}};var Si=zod.z.object({ServerTimeUtc:l,OfferID:zod.z.string(),Count:zod.z.number(),Resources:x.nullish()}),ko=zod.z.array(re(Si)),Vp=zod.z.object({OfferID:zod.z.string(),TotalPurchases:zod.z.number(),DailyPurchases:zod.z.number(),DailyResetUtc:l,LastPurchasedAt:l}),Mo=zod.z.object({Purchases:zod.z.record(zod.z.string(),Vp).nullish()}).passthrough().transform(a=>a),_p=zod.z.object({StartUtc:l.nullish(),EndUtc:l.nullish(),RequiredFlags:zod.z.array(zod.z.string()).nullish()}).passthrough(),Wp=zod.z.object({StoreID:zod.z.string(),Type:zod.z.string().nullish(),Name:zod.z.string().nullish(),Description:zod.z.string().nullish(),Rules:_p.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Qp=zod.z.object({StartUtc:l.nullish(),EndUtc:l.nullish(),Gate:Q.nullish(),Limits:de.nullish()}).passthrough(),Hp=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:Qp.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),js=zod.z.object({Stores:zod.z.record(zod.z.string(),Wp).nullish(),StoreOffers:zod.z.record(zod.z.string(),Hp).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,ko)}getDefinitions(e){return this.send(Rt.GetDefinitions,e,js)}getUserState(e){return this.send(Rt.GetUserState,e,Mo)}};var Kp=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),Ao=zod.z.object({Reward:G.nullish(),Weight:zod.z.number().nullish(),AmountRange:Kp.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(Ao).nullish()}).passthrough(),Ct=zod.z.object({RuleID:zod.z.string().nullish(),Threshold:zod.z.number().nullish(),Pool:zod.z.array(Ao).nullish()}).passthrough(),$p=zod.z.object({RewardSlots:zod.z.array(yt).nullish()}).passthrough(),Zp=zod.z.object({PityRules:zod.z.array(Ct).nullish()}).passthrough(),Vs=zod.z.object({SlotPresets:zod.z.record(zod.z.string(),$p).nullish(),PityPresets:zod.z.record(zod.z.string(),Zp).nullish()}).passthrough();var Jp=zod.z.object({RuleID:zod.z.string(),BoxIndex:zod.z.number().nullish()}),Uo=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(Jp).nullish()}),Yp=zod.z.object({PriceOptionID:zod.z.number().nullish(),RequiredResources:K.nullish()}).passthrough(),Xp=zod.z.object({RewardSlots:ne.nullish(),PityRules:ne.nullish()}).passthrough(),ed=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),MaxDrops:M.nullish()}).passthrough(),td=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(),Yp).nullish(),RewardSlots:zod.z.array(yt).nullish(),PityRules:zod.z.array(Ct).nullish(),Presets:Xp.nullish(),RewardMultiplier:Bt.nullish(),SupplyLimits:zod.z.array(ed).nullish()}).passthrough(),xi=zod.z.object({Definitions:zod.z.record(zod.z.string(),td).nullish(),RewardPools:Vs.nullish()}).passthrough(),Oo=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,Oo)}open(e){return this.send(_s.Open,e,Uo)}};var sd=zod.z.object({}).passthrough().transform(a=>a),rd=zod.z.object({}).passthrough().transform(a=>a),id=zod.z.object({}).passthrough().transform(a=>a),nd=zod.z.object({}).passthrough().transform(a=>a),od=zod.z.object({}).passthrough().transform(a=>a),wo=zod.z.object({ServerTimeUtc:l,CalendarID:zod.z.string(),DayNumber:zod.z.number().nullish(),DailyState:sd,Resources:x.nullish()}),Bo=zod.z.object({ServerTimeUtc:l,AccrualID:zod.z.string(),AccruedSeconds:M.nullish(),AppliedRatePerSecond:zod.z.number().nullish(),IdleState:rd,Resources:x.nullish()}),qo=zod.z.object({ServerTimeUtc:l,ComebackID:zod.z.string(),ClaimedTierIndex:zod.z.number().nullish(),ComebackState:id,Resources:x.nullish()}),Eo=zod.z.object({ServerTimeUtc:l,ClaimID:zod.z.string(),ClaimState:nd,Resources:x.nullish()}),Lo=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()}),ad=zod.z.object({RewardMode:zod.z.string().nullish(),RewardStackLowerTiers:zod.z.boolean().nullish()}).passthrough(),ld=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(),ud=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(ld).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(),cd=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),pd=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(cd).nullish()}).passthrough(),dd=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(),hd=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:pd.nullish(),Rewards:G.nullish(),MaxAccumulationSeconds:zod.z.number().nullish(),MinClaimSeconds:zod.z.number().nullish(),Requirements:dd.nullish(),FirstClaimMode:zod.z.string().nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),md=zod.z.object({MinAbsenceSeconds:zod.z.number().nullish(),Rewards:G.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),fd=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(md).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(),gd=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(),Rd=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(gd).nullish(),Gate:Q.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Di=zod.z.object({TierRewards:ad.nullish(),MilestoneRewardMultiplier:Bt.nullish(),DailyCalendars:zod.z.record(zod.z.string(),ud).nullish(),IdleAccruals:zod.z.record(zod.z.string(),hd).nullish(),Comebacks:zod.z.record(zod.z.string(),fd).nullish(),Claims:zod.z.record(zod.z.string(),Rd).nullish()}).passthrough(),Go=zod.z.object({RewardDefinitions:Di.nullish()}),No=zod.z.object({Rewards:od.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,Go)}getUserRewardsState(e){return this.send($e.GetUserRewardsState,e,No)}getMilestoneRewardMultiplier(e){return this.send($e.GetMilestoneRewardMultiplier,e,Lo)}claimDailyReward(e){return this.send($e.ClaimDailyReward,e,wo)}collectIdleAccrual(e){return this.send($e.CollectIdleAccrual,e,Bo)}claimComebackReward(e){return this.send($e.ClaimComebackReward,e,qo)}claimReward(e){return this.send($e.ClaimReward,e,Eo)}};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,Yi)}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,tn)}claimMilestoneReward(e){return this.send(Le.ClaimMilestoneReward,e,jr)}claimMilestoneRewardsBatch(e){return this.send(Le.ClaimMilestoneRewardsBatch,e,sn)}claimGroupCompletionReward(e){return this.send(Le.ClaimGroupCompletionReward,e,Xi)}addQuestProgress(e){return this.send(Le.AddQuestProgress,e,en)}};var jo=zod.z.object({}).passthrough().transform(a=>a);var yd=zod.z.object({Order:zod.z.number().nullish(),Type:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),BonusMultiplier:zod.z.number().nullish()}).passthrough(),Cd=zod.z.object({Schedule:zod.z.array(yd).nullish(),RepeatCycle:zod.z.boolean().nullish(),MaxCycles:zod.z.number().nullish()}).passthrough(),Sd=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(),xd=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:xd.nullish(),BonusWindow:Cd.nullish()}).passthrough(),Dd=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(),bd=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(Dd).nullish(),Gate:Q.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),vd=zod.z.object({MaxConcurrentEvents:zod.z.number().nullish()}).passthrough(),zd=zod.z.object({Milestones:zod.z.record(zod.z.string(),Xe).nullish()}).passthrough(),Ks=zod.z.object({Definitions:zod.z.record(zod.z.string(),bd).nullish(),Settings:vd.nullish(),Presets:zd.nullish()}).passthrough(),Td=zod.z.object({Type:vt,TimedEventID:zod.z.string(),CurrentChainedEventID:zod.z.string().nullish(),Content:bi.nullish(),Progress:jo.nullish(),ComputedStartUtc:l.nullish(),ComputedEndUtc:l.nullish(),CanEarn:zod.z.boolean().nullish(),CanClaim:zod.z.boolean().nullish(),NextMilestone:ye.nullish(),BonusWindow:Sd.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentEventOrder:zod.z.number().nullish(),TotalEventsInChain:zod.z.number().nullish()}).passthrough(),Fo=zod.z.object({ActiveEvents:zod.z.array(Td).nullish()}).passthrough(),Vo=zod.z.object({Tokens:zod.z.record(zod.z.string(),jo).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()}),Pd=zod.z.object({Type:vt.nullish(),LteID:zod.z.string().nullish(),Resources:x.nullish()}),Ti=zod.z.array(re(zi)),_o=zod.z.array(re(vi)),Wo=zod.z.array(re(Pd)),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,Fo)}getDefinitions(e){return this.send(we.GetDefinitions,e,Ks)}getUserLteState(e){return this.send(we.GetUserLteState,e,Vo)}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,_o)}grantTokensBatch(e){return this.send(we.GrantTokensBatch,e,Wo)}};var Id=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(Id).nullish(),BracketID:zod.z.string().nullish()}),kd=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(kd).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()}),Qo=zod.z.array(re(Pt)),Ho=zod.z.array(re(Zs)),Ko=zod.z.array(re(Ys)),$o=zod.z.array(re(Xs)),Zo=zod.z.array(re(Js)),Md=zod.z.object({LeaderboardID:zod.z.string(),CycleReward:re(Ys).nullish(),Milestones:zod.z.array(re(Xs)).nullish()}),Jo=zod.z.array(Md),Ad=zod.z.object({LeaderboardID:zod.z.string(),Leaderboard:re(Pt).nullish(),Progress:re(Zs).nullish()}),Yo=zod.z.array(Ad),Ud=zod.z.string(),Xo=zod.z.object({Rank:zod.z.string().nullish(),Rewards:G.nullish(),SeasonTierRewards:Lr.nullish()}).passthrough(),Od=zod.z.object({RankRewards:zod.z.array(Xo).nullish()}).passthrough(),wd=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Bd=zod.z.object({Milestones:ne.nullish(),RankRewards:ne.nullish()}).passthrough(),qd=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:Ud.nullish(),Schedule:pe.nullish(),ChainEvents:zod.z.array(wd).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(Xo).nullish(),Milestones:zod.z.record(zod.z.string(),ye).nullish(),Presets:Bd.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneClaimGraceHours:zod.z.number().nullish(),ScoreSources:zod.z.array(_e).nullish()}).passthrough(),Ed=zod.z.object({Milestones:zod.z.record(zod.z.string(),Xe).nullish(),RankRewards:zod.z.record(zod.z.string(),Od).nullish()}).passthrough(),er=zod.z.object({Definitions:zod.z.record(zod.z.string(),qd).nullish(),Presets:Ed.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,Qo)}getProgressBatch(e){return this.send(fe.GetProgressBatch,e,Ho)}claimCycleRewardsBatch(e){return this.send(fe.ClaimCycleRewardsBatch,e,Ko)}claimMilestonesBatch(e){return this.send(fe.ClaimMilestonesBatch,e,$o)}submitScoresBatch(e){return this.send(fe.SubmitScoresBatch,e,Zo)}claimAllRewardsBatch(e){return this.send(fe.ClaimAllRewardsBatch,e,Jo)}getOverviewBatch(e){return this.send(fe.GetOverviewBatch,e,Yo)}};var Pi=zod.z.object({}).passthrough().transform(a=>a),ea=zod.z.object({SeasonChainID:zod.z.string(),CycleIndex:zod.z.number().nullish(),Season:zod.z.lazy(()=>ia).nullish(),ComputedStartUtc:l.nullish(),ComputedEndUtc:l.nullish(),SecondsRemaining:M.nullish(),UserState:Pi.nullish(),NextTier:zod.z.lazy(()=>ra).nullish()}).passthrough(),ta=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()}),sa=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),TierNumber:zod.z.number(),Resources:x.nullish()});var ra=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(),ia=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(ra).nullish(),LinkedCollectionID:zod.z.string().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough();var Ld=zod.z.object({SeasonChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:pe.nullish(),Seasons:zod.z.array(ia).nullish(),GrantTokensAccessMode:zod.z.string().nullish(),Gate:Q.nullish()}).passthrough(),sr=zod.z.object({Chains:zod.z.record(zod.z.string(),Ld).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,ea)}getUserState(e){return this.send(nt.GetUserState,e,Pi)}grantStatusTokens(e){return this.send(nt.GrantStatusTokens,e,ta)}claimTierReward(e){return this.send(nt.ClaimTierReward,e,sa)}};var Gd={Apple:"Apple",Google:"Google"},na=zod.z.object({}).passthrough().transform(a=>a),Nd=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(),jd=zod.z.object({OptionID:zod.z.string().nullish(),Name:zod.z.string().nullish(),RequiredResources:K.nullish()}).passthrough(),Fd=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(),jd).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(),Fd).nullish()}).passthrough(),oa=zod.z.object({Premium:Ii.nullish()}),aa=zod.z.object({ServerTimeUtc:l.nullish(),Premium:na.nullish()}),ir=zod.z.object({ServerTimeUtc:l.nullish(),Premium:na.nullish(),Subscription:Nd.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,oa)}getUserState(e){return this.send(ot.GetUserState,e,aa)}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,In)}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,kn)}unequipItems(e){return this.send(Te.UnequipItems,e,Mn)}unequipAllCharacters(e){return this.send(Te.UnequipAllCharacters,e,An)}unlockCharactersBatch(e){return this.send(Te.UnlockCharactersBatch,e,Un)}upgradeCharacterLevelsBatch(e){return this.send(Te.UpgradeCharacterLevelsBatch,e,On)}upgradeStatLevelsBatch(e){return this.send(Te.UpgradeStatLevelsBatch,e,wn)}};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,io)}updateMatch(e){return this.send(je.UpdateMatch,e,no)}cancelMatch(e){return this.send(je.CancelMatch,e,oo)}instantBattle(e){return this.send(je.InstantBattle,e,ao)}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,po)}};var Vd={TradeUpRarity:"TradeUpRarity",TradeUpCollection:"TradeUpCollection"},la=zod.z.enum(["TradeUpRarity","TradeUpCollection"]),_d=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()}),ua=zod.z.object({ServerTimeUtc:l,Type:la.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(_d).nullish()}),Wd=zod.z.object({OptionID:zod.z.string().nullish(),RequiredResources:K.nullish()}).passthrough(),Qd=zod.z.object({CraftID:zod.z.string().nullish(),Type:la.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(),Wd).nullish()}).passthrough(),ki=zod.z.object({Definitions:zod.z.record(zod.z.string(),Qd).nullish()}).passthrough(),ca=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,ca)}craft(e){return this.send(lr.Craft,e,ua)}};var Hd={Pending:"Pending",Accepted:"Accepted",Declined:"Declined",Cancelled:"Cancelled",Expired:"Expired"},Kd=zod.z.enum(["Pending","Accepted","Declined","Cancelled","Expired"]),pa=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()}),da=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()}),ha=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()}),ma=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()}),fa=zod.z.array(re(Mi)),ga=zod.z.object({Resources:x.nullish()}),$d=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:Kd.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(),Ra=zod.z.object({OfferID:zod.z.string(),ExpiresAtUtc:l.nullish(),Resources:x.nullish()}),ya=zod.z.object({OfferID:zod.z.string(),Resources:x.nullish()}),Ca=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()}),Sa=zod.z.object({OfferID:zod.z.string(),Resources:x.nullish()}),Ai=zod.z.object({Offers:zod.z.array($d).nullish()}),Zd=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(),Jd=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(Zd).nullish(),SetCompletionReward:G.nullish()}).passthrough(),Yd=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(Jd).nullish(),GrandPrize:G.nullish()}).passthrough(),xa=zod.z.object({BonusRewardSlots:ne.nullish(),PityRules:ne.nullish()}).passthrough(),Xd=zod.z.object({PackTypeID:zod.z.string().nullish(),Cost:K.nullish(),BonusRewardSlots:zod.z.array(yt).nullish(),PityRules:zod.z.array(Ct).nullish(),Presets:xa.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(),eh=zod.z.object({Rarity:zod.z.number().nullish(),CollectionCurrencyGranted:zod.z.number().nullish()}).passthrough(),th=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:xa.nullish(),Tier:zod.z.number().nullish()}).passthrough(),sh=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(),Yd).nullish(),PackTypes:zod.z.record(zod.z.string(),Xd).nullish(),CollectionChests:zod.z.array(th).nullish(),DuplicateConversions:zod.z.array(eh).nullish(),DailyTradeLimit:zod.z.number().nullish(),CollectibleJokerCatalogID:zod.z.string().nullish(),CollectibleJokerItemID:zod.z.string().nullish(),SpecialTradeEvents:zod.z.array(sh).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,pa)}openPack(e){return this.send(xe.OpenPack,e,da)}openCollectionChest(e){return this.send(xe.OpenCollectionChest,e,ha)}useCollectibleJoker(e){return this.send(xe.UseCollectibleJoker,e,ma)}claimSetReward(e){return this.send(xe.ClaimSetReward,e,Mi)}claimSetRewardsBatch(e){return this.send(xe.ClaimSetRewardsBatch,e,fa)}claimGrandPrize(e){return this.send(xe.ClaimGrandPrize,e,ga)}sendTradeOffer(e){return this.send(xe.SendTradeOffer,e,Ra)}cancelTradeOffer(e){return this.send(xe.CancelTradeOffer,e,ya)}acceptTradeOffer(e){return this.send(xe.AcceptTradeOffer,e,Ca)}declineTradeOffer(e){return this.send(xe.DeclineTradeOffer,e,Sa)}getMyTradeOffers(e){return this.send(xe.GetMyTradeOffers,e,Ai)}getIncomingTradeOffers(e){return this.send(xe.GetIncomingTradeOffers,e,Ai)}};var rh=zod.z.object({}).passthrough().transform(a=>a),ih={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},nh={Active:"Active",Left:"Left",Replaced:"Replaced"},oh=zod.z.object({ObjectIndex:zod.z.number().nullish(),ObjectCompletionRewardClaimed:zod.z.boolean().nullish()}).passthrough(),ah=zod.z.object({UserID:zod.z.string().nullish(),PublicData:Ce.nullish(),BuildObjectsProgress:oh.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(),lh=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(),uh=zod.z.object({Objects:zod.z.array(lh).nullish()}).passthrough(),Da=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(ah).nullish(),BuildObjectsState:uh.nullish(),Status:zod.z.string().nullish(),CreatedAtUtc:l.nullish(),ExpiresAtUtc:l.nullish(),Version:zod.z.number().nullish()}).passthrough(),ba=zod.z.object({CoopChainID:zod.z.string()}).passthrough(),ch=zod.z.string(),va=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(),ph=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(),dh=zod.z.object({Objects:zod.z.array(ph).nullish(),SpinCost:K.nullish(),SpinnerTable:zod.z.array(va).nullish()}).passthrough(),hh=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:ch.nullish(),PartnerCount:zod.z.number().nullish(),MatchmakingTimeoutMinutes:zod.z.number().nullish(),MemberGracePeriodMinutes:zod.z.number().nullish(),BuildObjects:dh.nullish(),GrandPrize:G.nullish()}).passthrough(),mh=zod.z.object({CoopChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:pe.nullish(),Events:zod.z.array(hh).nullish(),Gate:Q.nullish()}).passthrough(),za=zod.z.object({ServerTimeUtc:l.nullish(),UserState:rh.nullish(),ActiveGroup:Da.nullish()}),Ui=zod.z.object({ServerTimeUtc:l.nullish(),Group:Da.nullish(),SecondsRemaining:M.nullish()}),Ta=zod.z.object({ServerTimeUtc:l.nullish(),GroupID:zod.z.string().nullish(),Resources:x.nullish(),ObjectIndex:zod.z.number().nullish(),Sector:va.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()}),Pa=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(),mh).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,ba)}getUserState(e){return this.send(Ne.GetUserState,e,za)}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,Ta)}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,Pa)}};var fh={Active:"Active",Exhausted:"Exhausted",Expired:"Expired",Dismissed:"Dismissed"},gh={Locked:"Locked",Available:"Available",InProgress:"InProgress",Completed:"Completed",Hidden:"Hidden"},Rh=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(),yh=zod.z.object({TrackID:zod.z.string().nullish(),CurrentValue:zod.z.number().nullish(),LastUpdatedUtc:l.nullish()}).passthrough(),Ia=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(),Rh).nullish(),Tracks:zod.z.record(zod.z.string(),yh).nullish(),SelectedChoiceNodeID:zod.z.string().nullish()}).passthrough(),Ch=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:Ia.nullish(),NextCycleStartsAtUtc:l.nullish(),LastUpdatedUtc:l.nullish(),DismissSkipAvailableAtUtc:l.nullish(),LastDismissedAtUtc:l.nullish()}).passthrough(),Sh=zod.z.object({TotalExecutions:zod.z.number().nullish(),DailyExecutions:zod.z.number().nullish(),DailyResetUtc:l.nullish()}).passthrough(),xh=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(),Sh).nullish()}).passthrough(),Dh=zod.z.object({Slots:zod.z.record(zod.z.string(),Ch).nullish(),OfferHistory:zod.z.record(zod.z.string(),xh).nullish(),LastUpdatedUtc:l.nullish()}).passthrough();var bh=zod.z.object({Order:zod.z.number().nullish(),OfferID:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),DelayBeforeActivationSec:zod.z.number().nullish()}).passthrough(),vh=zod.z.object({SlotID:zod.z.string().nullish(),Enabled:zod.z.boolean().nullish(),SortOrder:zod.z.number().nullish(),Queue:zod.z.array(bh).nullish(),Schedule:pe.nullish(),Gate:Q.nullish(),AllowDismissSkip:zod.z.boolean().nullish(),DismissSkipDelaySec:zod.z.number().nullish()}).passthrough(),zh=zod.z.object({StoreOfferID:zod.z.string().nullish(),BillingProductID:zod.z.string().nullish(),DirectCost:K.nullish(),UseExternalRewards:zod.z.boolean().nullish()}).passthrough(),Th=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(),Ph=zod.z.object({Purchase:zh.nullish(),RewardedVideo:Th.nullish()}).passthrough(),Ih=zod.z.object({TrackID:zod.z.string().nullish(),Operator:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),kh=zod.z.object({Milestones:ne.nullish()}).passthrough(),Mh=zod.z.object({TrackID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),RespectBounds:zod.z.boolean().nullish()}).passthrough(),Ah=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(),Uh=zod.z.object({RequiredCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredAnyCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredTracks:zod.z.array(Ih).nullish(),VisibleWhileLocked:zod.z.boolean().nullish()}).passthrough(),Oh=zod.z.object({NodeID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),Type:zod.z.string().nullish(),Action:Ph.nullish(),Grants:G.nullish(),TrackChanges:zod.z.array(Mh).nullish(),MilestonePoints:zod.z.number().nullish(),UnlockRules:Uh.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(),ka=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(Oh).nullish(),Tracks:zod.z.array(Ah).nullish(),Milestones:zod.z.record(zod.z.string(),ye).nullish(),Presets:kh.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(),wh=zod.z.object({Milestones:zod.z.record(zod.z.string(),Xe).nullish()}).passthrough(),wi=zod.z.object({Slots:zod.z.record(zod.z.string(),vh).nullish(),Offers:zod.z.record(zod.z.string(),ka).nullish(),Presets:wh.nullish()}).passthrough(),Ma=zod.z.object({DealOfferDefinitions:wi.nullish()}),Aa=zod.z.object({DealOffers:Dh.nullish()}),Bh=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(),qh=zod.z.object({SlotID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),OfferDef:ka.nullish(),ActivationState:Ia.nullish(),IsNewActivation:zod.z.boolean().nullish(),ComputedExpiresAtUtc:l.nullish(),Cost:K.nullish(),Milestone:Bh.nullish()}).passthrough(),Ua=zod.z.object({Slots:zod.z.array(qh).nullish()}),Oa=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()}),wa=zod.z.object({ServerTimeUtc:l.nullish(),SlotID:zod.z.string().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(),MilestoneID:zod.z.string().nullish(),Resources:x.nullish()}),Ea=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,Ma)}getUserState(e){return this.send(Fe.GetUserState,e,Aa)}getActiveDeals(e){return this.send(Fe.GetActiveDeals,e,Ua)}dismissDeal(e){return this.send(Fe.DismissDeal,e,wa)}executeNode(e){return this.send(Fe.ExecuteNode,e,Oa)}recordShow(e){return this.send(Fe.RecordShow,e,Ba)}claimMilestone(e){return this.send(Fe.ClaimMilestone,e,qa)}claimMilestonesBatch(e){return this.send(Fe.ClaimMilestonesBatch,e,Ea)}};var Eh=zod.z.object({}).passthrough().transform(a=>a),Lh=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(Lh).nullish()}).passthrough(),La=zod.z.object({ReferralDefinitions:Bi.nullish()}),Ga=zod.z.object({Referral:Eh.nullish()}),Na=zod.z.object({ReferralCode:zod.z.string().nullish(),IsFirstActivation:zod.z.boolean().nullish(),Resources:x.nullish()}),ja=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,La)}getUserState(e){return this.send(St.GetUserState,e,Ga)}activateReferralCode(e){return this.send(St.ActivateReferralCode,e,Na)}claimInviteReward(e){return this.send(St.ClaimInviteReward,e,ja)}};var Gh={RequestSent:"RequestSent",Accepted:"Accepted",Declined:"Declined",Removed:"Removed"},Nh={Attack:"Attack",Raid:"Raid",FriendAdd:"FriendAdd"},jh=zod.z.object({UserID:zod.z.string(),PublicData:Ce.nullish()}),Fh=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(jh).nullish()}),It=zod.z.object({TargetUserID:zod.z.string().nullish(),Status:zod.z.string().nullish()}),Fa=zod.z.object({Events:zod.z.array(Fh).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,Fa)}};var Vh={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(),_h=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(),Wh=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(),Qh=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(),Hh=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(Qh).nullish(),Gate:Q.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Kh=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(),$h=zod.z.object({MaxAddPercent:zod.z.number().nullish(),MaxMultiply:zod.z.number().nullish(),MaxAddFlat:zod.z.number().nullish()}).passthrough(),Zh=zod.z.object({StackingCaps:zod.z.record(zod.z.string(),$h).nullish()}).passthrough(),Cr=zod.z.object({Definitions:zod.z.record(zod.z.string(),_h).nullish(),ScheduledBoosts:zod.z.record(zod.z.string(),Wh).nullish(),BoostChains:zod.z.record(zod.z.string(),Hh).nullish(),TriggeredBoosts:zod.z.record(zod.z.string(),Kh).nullish(),Settings:Zh.nullish()}).passthrough(),Va=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 _a=zod.z.object({ServerTimeUtc:l.nullish(),Active:zod.z.record(zod.z.string(),Va).nullish()}),Wa=zod.z.object({ServerTimeUtc:l.nullish(),BoostID:zod.z.string().nullish(),StackingPolicy:zod.z.string().nullish(),ActivatedBoost:Va.nullish(),Resources:x.nullish()}),Jh={Scheduled:"Scheduled",Chain:"Chain"},Yh=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(),Qa=zod.z.object({ServerTimeUtc:l.nullish(),Windows:zod.z.array(Yh).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,_a)}getActiveWindows(e){return this.send(at.GetActiveWindows,e,Qa)}activate(e){return this.send(at.Activate,e,Wa)}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,gn)}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,Rn)}batchDelete(e){return this.send(Ge.BatchDelete,e,yn)}batchGetPublicUserCustomDataOf(e){return this.send(Ge.BatchGetPublicUserCustomDataOf,e,Cn)}};var Xh={Static:"Static",Runtime:"Runtime"},em={Public:"Public",Private:"Private"},tm=zod.z.enum(["Client","Server","System"]),sm=zod.z.enum(["String","Int","Bool","Json"]),rm=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:l.nullish(),Version:zod.z.number().nullish(),LastWriter:tm.nullish(),ExpiresAt:l.nullish()}).passthrough(),Ha=zod.z.record(zod.z.string(),rm),qi=zod.z.object({StaticVersion:zod.z.number().nullish(),RuntimeVersion:zod.z.number().nullish(),Static:Ha.nullish(),Runtime:Ha.nullish(),NotModified:zod.z.boolean().nullish()}),im=zod.z.object({KeyID:zod.z.string(),Scope:zod.z.enum(["Static","Runtime"]).nullish(),Bucket:zod.z.enum(["Public","Private"]).nullish(),ValueType:sm.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(),im).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 nm={Fast:"Fast",Sequential:"Sequential"},om={Instant:"Instant",Timed:"Timed"},am={Hit:"Hit",Blocked:"Blocked"},lm=zod.z.object({SlotIndex:zod.z.number(),Level:zod.z.number().nullish(),IsDamaged:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish()}).passthrough(),um=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 Ka=zod.z.object({}).passthrough().transform(a=>a),$a=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(),cm=zod.z.object({Count:zod.z.number().nullish(),Sides:zod.z.number().nullish()}).passthrough(),pm=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(),dm=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:ue.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(),hm=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:ue.nullish()}).passthrough(),Za=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(),mm=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(),fm=zod.z.object({Tiles:zod.z.record(zod.z.string(),mm).nullish()}).passthrough(),gm=zod.z.object({Weight:zod.z.number().nullish(),Bonus:ve.nullish(),Tag:zod.z.string().nullish()}).passthrough(),Rm=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(gm).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(),ym=zod.z.object({Variants:zod.z.array(Rm).nullish()}).passthrough(),Cm=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(),Sm=zod.z.object({Outcomes:zod.z.array(Cm).nullish()}).passthrough(),Ja=zod.z.object({PerAdMultiplierRange:$a.nullish(),MaxAdViews:zod.z.number().nullish(),AdCreditCost:zod.z.number().nullish(),FormulaKind:zod.z.string().nullish(),ApplyMultiplierOnEarlyClaim:zod.z.boolean().nullish()}).passthrough(),xm=zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:ve.nullish()}).passthrough(),Dm=zod.z.object({Tiers:zod.z.array(xm).nullish(),BelowFirstTierReward:ve.nullish()}).passthrough(),bm=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:Ja.nullish(),Gradation:Dm.nullish()}).passthrough(),vm=zod.z.object({Choices:zod.z.array(bm).nullish(),OfferExpireSeconds:zod.z.number().nullish(),ClaimExpireSeconds:zod.z.number().nullish()}).passthrough(),zm=zod.z.object({Chance:zod.z.number().nullish(),RequiredOutcome:zod.z.string().nullish(),Reward:ve.nullish(),Tag:zod.z.string().nullish()}).passthrough(),Tm=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(zm).nullish(),ChanceTablesByID:zod.z.record(zod.z.string(),Sm).nullish(),SpecialModesByID:zod.z.record(zod.z.string(),vm).nullish()}).passthrough(),Ya=zod.z.object({BaseAttackReward:G.nullish(),BaseRaidReward:G.nullish(),MaxRollMultiplier:zod.z.number().nullish(),MaxShields:zod.z.number().nullish(),Buildings:zod.z.array(Za).nullish(),HeistGridBonusConfig:ym.nullish(),StageOperations:Tm.nullish(),TileLandingMultiplier:$a.nullish(),EconomyOverride:hm.nullish()}).passthrough(),Pm=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(Za).nullish(),StageTemplateID:zod.z.string().nullish(),CostMatrixTemplateID:zod.z.string().nullish(),UnitValue:zod.z.number().nullish(),Override:Ya.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(),fm).nullish(),StageTemplatesByID:zod.z.record(zod.z.string(),Ya).nullish(),StagesByLevel:zod.z.record(zod.z.string(),Pm).nullish(),SoftCurrencyID:zod.z.string().nullish(),ProceduralEconomy:dm.nullish(),Dice:cm.nullish(),Bots:pm.nullish()}).passthrough(),Im=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:Im.nullish()}).passthrough(),km=zod.z.object({TargetUserID:zod.z.string().nullish(),IsBot:zod.z.boolean().nullish(),PublicData:Ce.nullish(),TargetBuildingStates:zod.z.array(lm).nullish(),TargetHasShield:zod.z.boolean().nullish()}).passthrough(),Mm=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:Ja.nullish()}).passthrough(),Am=zod.z.object({ModeID:zod.z.string().nullish(),Choices:zod.z.array(Mm).nullish()}).passthrough(),Um=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(),Xa=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:km.nullish(),SpecialModeOffer:Am.nullish(),CommunityChestContribution:Um.nullish()}).passthrough(),el=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(um).nullish(),HeistVariantTag:zod.z.string().nullish(),IsJackpot:zod.z.boolean().nullish(),Operation:x.nullish(),DualResult:st.nullish()}).passthrough(),tl=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(),sl=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(),rl=zod.z.object({AdViewsUsed:zod.z.number().nullish(),RolledMultiplier:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),RemainingAdViews:zod.z.number().nullish()}).passthrough(),il=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(),Om={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},nl=zod.z.enum(["Forming","Active","Completed","Failed","Expired"]),wm={Active:"Active",Left:"Left",Replaced:"Replaced"},Bm=zod.z.enum(["Active","Left","Replaced"]),qm=zod.z.object({CurrentProgress:M.nullish(),MaxProgress:M.nullish()}).passthrough(),Em=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:Bm.nullish(),JoinedAtUtc:l.nullish(),LeftAtUtc:l.nullish()}).passthrough(),ol=zod.z.object({GroupID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),Members:zod.z.array(Em).nullish(),SharedProgress:qm.nullish(),Status:nl.nullish(),CreatedAtUtc:l.nullish(),ExpiresAtUtc:l.nullish(),Version:zod.z.number().nullish()}).passthrough(),Lm=zod.z.object({GroupID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),FinalStatus:nl.nullish(),GrandPrizeReceived:zod.z.boolean().nullish(),FinishedAtUtc:l.nullish()}).passthrough(),Gm=zod.z.object({ActiveGroupID:zod.z.string().nullish(),ActiveRoundIndex:zod.z.number().nullish(),History:zod.z.array(Lm).nullish()}).passthrough(),al=zod.z.object({ServerTimeUtc:l.nullish(),UserState:Gm.nullish(),ActiveGroup:ol.nullish(),SecondsRemaining:M.nullish()}),ll=zod.z.object({ServerTimeUtc:l.nullish(),Group:ol.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()}),ul=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 Nm=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(),jm=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(Nm).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(),cl=zod.z.object({Experiments:zod.z.record(zod.z.string(),jm).nullish()}).passthrough();var Fm={Mesh:"Mesh",Host:"Host"},Gi=zod.z.enum(["Mesh","Host"]),Vm={ServerRelay:"ServerRelay",P2P:"P2P"},Ni=zod.z.enum(["ServerRelay","P2P"]),_m={Public:"Public",Private:"Private"},Wm=zod.z.enum(["Public","Private"]),Qm={Signal:"Signal",Chat:"Chat",PlayerJoined:"PlayerJoined",PlayerLeft:"PlayerLeft",HostChanged:"HostChanged",RoomClosed:"RoomClosed",MemberState:"MemberState"},Hm=zod.z.enum(["Signal","Chat","PlayerJoined","PlayerLeft","HostChanged","RoomClosed","MemberState"]),pl=zod.z.object({Urls:zod.z.string().nullish(),Username:zod.z.string().nullish(),Credential:zod.z.string().nullish()}).passthrough(),Km=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),dl=zod.z.object({SystemState:Km.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(pl).nullish()}).passthrough(),$m=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(),Zm=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(),Jm=zod.z.object({Seq:zod.z.number().nullish(),Type:Hm.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:Wm.nullish(),Status:zod.z.string().nullish(),MaxPlayers:zod.z.number().nullish(),Members:zod.z.array($m).nullish(),IceServers:zod.z.array(pl).nullish(),Seq:zod.z.number().nullish()}).passthrough(),ji=zod.z.object({Closed:zod.z.boolean().nullish(),NewHostUserID:zod.z.string().nullish()}).passthrough(),hl=zod.z.object({Rooms:zod.z.array(Zm).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}).passthrough(),ml=zod.z.object({Envelopes:zod.z.array(Jm).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:cl.nullish(),Blockchain:ni.nullish(),Marketplace:gi.nullish(),Multiplayer:dl.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,Ka)}boardLoopRoll(e){return this.send(me.BoardLoopRoll,e,Xa)}boardLoopAttack(e){return this.send(me.BoardLoopAttack,e,el)}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,tl)}boardSpecialChoose(e){return this.send(me.BoardSpecialChoose,e,sl)}boardSpecialApplyMultiplier(e){return this.send(me.BoardSpecialApplyMultiplier,e,rl)}boardSpecialClaim(e){return this.send(me.BoardSpecialClaim,e,il)}getCommunityChestState(e){return this.send(me.GetCommunityChestState,e,al)}joinOrCreateCommunityChest(e){return this.send(me.JoinOrCreateCommunityChest,e,ll)}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,ul)}};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 Xm={Live:"Live",Latest:"Latest",Specific:"Specific"},ef={Debug:"Debug",Info:"Info",Warning:"Warning",Error:"Error"},tf=zod.z.enum(["Debug","Info","Warning","Error"]),sf={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"},rf=zod.z.enum(["None","Disabled","NoActiveRevision","RevisionNotFound","InvalidFieldName","RateLimited","HandlerNotFound","HandlerDisabled","Timeout","StatementCountExceeded","StackOverflow","ApiCallLimitExceeded","JavaScriptException","ExecutionError"]),nf=zod.z.object({Level:tf,Message:zod.z.string().nullish(),Data:Mt.nullish()}),of=zod.z.object({Error:rf,Message:zod.z.string().nullish(),StackTrace:zod.z.string().nullish()}),fl=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(nf).nullish(),LogsTooLarge:zod.z.boolean().nullish(),ExecutionTimeSeconds:zod.z.number().nullish(),APIRequestsIssued:zod.z.number().nullish(),Error:of.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,fl,{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,Wn)}getUserState(e){return this.send(Pe.GetUserState,e,Qn)}depositToken(e){return this.send(Pe.DepositToken,e,Hn)}depositNFT(e){return this.send(Pe.DepositNFT,e,Kn)}requestTokenWithdrawal(e){return this.send(Pe.RequestTokenWithdrawal,e,$n)}requestNFTWithdrawal(e){return this.send(Pe.RequestNFTWithdrawal,e,Zn)}getTransactionHistory(e){return this.send(Pe.GetTransactionHistory,e,Jn)}retryWithdrawal(e){return this.send(Pe.RetryWithdrawal,e,Yn)}confirmWithdrawal(e){return this.send(Pe.ConfirmWithdrawal,e,Xn)}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,mo)}getGroupedOffers(e){return this.send(ie.GetGroupedOffers,e,fo)}getOffersByItem(e){return this.send(ie.GetOffersByItem,e,Ri)}getOffer(e){return this.send(ie.GetOffer,e,go)}getBuyOrders(e){return this.send(ie.GetBuyOrders,e,Ri)}getMyState(e){return this.send(ie.GetMyState,e,yo)}getHistory(e){return this.send(ie.GetHistory,e,Co)}createListing(e){return this.send(ie.CreateListing,e,Tt)}cancelListing(e){return this.send(ie.CancelListing,e,Ae)}buy(e){return this.send(ie.Buy,e,Ae)}marketBuy(e){return this.send(ie.MarketBuy,e,Ae)}marketSell(e){return this.send(ie.MarketSell,e,Ae)}createAuction(e){return this.send(ie.CreateAuction,e,Tt)}placeBid(e){return this.send(ie.PlaceBid,e,Ro)}claimAuction(e){return this.send(ie.ClaimAuction,e,Ae)}createBuyOrder(e){return this.send(ie.CreateBuyOrder,e,Tt)}cancelBuyOrder(e){return this.send(ie.CancelBuyOrder,e,Ae)}fillBuyOrder(e){return this.send(ie.FillBuyOrder,e,Ae)}createDirectTrade(e){return this.send(ie.CreateDirectTrade,e,Tt)}respondDirectTrade(e){return this.send(ie.RespondDirectTrade,e,Ae)}cancelDirectTrade(e){return this.send(ie.CancelDirectTrade,e,Ae)}claimBack(e){return this.send(ie.ClaimBack,e,Ae)}};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,hl)}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,ml)}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=Hi(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 af(a){return new Br(a)}var lf={Banner:"Banner",Interstitial:"Interstitial",RewardedVideo:"RewardedVideo",RewardedInterstitial:"RewardedInterstitial",AppOpen:"AppOpen",Native:"Native"},_i=zod.z.enum(["Banner","Interstitial","RewardedVideo","RewardedInterstitial","AppOpen","Native"]),uf={Top:"Top",Bottom:"Bottom",Left:"Left",Right:"Right"},cf=zod.z.enum(["Top","Bottom","Left","Right"]),pf=zod.z.object({PlacementID:zod.z.string().nullish(),Type:_i.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(),df=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(),hf=zod.z.object({CooldownSeconds:zod.z.number().nullish(),MinSessionTimeBeforeFirstSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),mf=zod.z.object({Enabled:zod.z.boolean().nullish(),Position:cf.nullish(),RefreshIntervalSeconds:zod.z.number().nullish()}).passthrough(),ff=zod.z.object({Enabled:zod.z.boolean().nullish(),CooldownSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish()}).passthrough(),gf=zod.z.object({MaxImpressionsPerHour:zod.z.number().nullish(),MaxImpressionsPerDay:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),Rf=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(),yf=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(),Cf=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(),Sf=zod.z.object({AndroidUnitID:zod.z.string().nullish(),IosUnitID:zod.z.string().nullish(),WebUnitID:zod.z.string().nullish(),Type:_i.nullish()}).passthrough(),xf=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(),Sf).nullish()}).passthrough();zod.z.object({Enabled:zod.z.boolean().nullish(),Placements:zod.z.record(zod.z.string(),pf).nullish(),Providers:zod.z.record(zod.z.string(),xf).nullish(),RewardedVideo:df.nullish(),Interstitial:hf.nullish(),Banner:mf.nullish(),AppOpen:ff.nullish(),FrequencyCapping:gf.nullish(),PremiumAdReductions:zod.z.array(Rf).nullish(),Consent:yf.nullish(),Verification:Cf.nullish()}).passthrough();var Df=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(),vf=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(),zf=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(),Tf=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(),Pf=zod.z.object({RequestID:zod.z.string().nullish(),PlacementID:zod.z.string().nullish(),ProviderID:zod.z.string().nullish(),Type:_i.nullish(),IssuedAt:l.nullish(),ExpiresAt:l.nullish(),CreditsToAward:zod.z.number().nullish()}).passthrough(),If=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:Df.nullish(),Placements:zod.z.record(zod.z.string(),bf).nullish(),Daily:vf.nullish(),Session:zf.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:Tf.nullish(),PendingRequests:zod.z.record(zod.z.string(),Pf).nullish(),FraudFlags:If.nullish(),UpdatedAt:l.nullish()}).passthrough();var kf={Unread:"Unread",Read:"Read",Deleted:"Deleted",Expired:"Expired"},Mf=zod.z.enum(["Unread","Read","Deleted","Expired"]),Af={Admin:"Admin",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season",Collection:"Collection",MilestoneEvent:"MilestoneEvent",PlayerGift:"PlayerGift",Social:"Social",Compensation:"Compensation",Referral:"Referral",Quest:"Quest"},Uf=zod.z.enum(["Admin","Leaderboard","CoopEvent","Season","Collection","MilestoneEvent","PlayerGift","Social","Compensation","Referral","Quest"]),Of={Active:"Active",Paused:"Paused",Cancelled:"Cancelled",Completed:"Completed"},wf=zod.z.enum(["Active","Paused","Cancelled","Completed"]),Bf=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(),qf=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(),Bf).nullish(),Segments:zod.z.array(qf).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:Uf.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:Mf.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:wf.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 gl="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(gl);return e||(e="noop-device",this.storage.setString(gl,e)),e}getDeviceModel(){return "Noop"}shareLink(){}openInvoice(){}async showAd(){}async copyToClipboard(){}};
|
|
2
|
+
exports.AdType=lf;exports.AttackOutcome=am;exports.AuthType=ce;exports.AuthenticationAction=Ue;exports.BannerPosition=uf;exports.BlockchainAction=Pe;exports.BlockchainNetworkType=hc;exports.BlockchainOperationCategory=Nn;exports.BlockchainTransactionStatus=Dc;exports.BlockchainTransactionType=Rc;exports.BodyPart=Qc;exports.BoostWindowKind=Jh;exports.BroadcastStatus=Of;exports.BrowserPlatformAdapter=dt;exports.BrowserStorage=ut;exports.CharacterAction=Te;exports.CloudCodeAction=Vi;exports.CloudCodeErrorCode=sf;exports.CloudCodeLogLevel=ef;exports.CloudCodeRevisionSelection=Xm;exports.CollectionAction=xe;exports.CommissionSink=pp;exports.CommunityChestMemberStatus=wm;exports.CommunityChestStatus=Om;exports.ConversionRateMode=_u;exports.CoopEventAction=Ne;exports.CoopGroupStatus=ih;exports.CoopMemberStatus=nh;exports.CraftAction=lr;exports.CraftType=Vd;exports.CurrencyAction=vs;exports.CurrencyStatus=Vu;exports.CurrencyType=qe;exports.CustomDataBucket=Qe;exports.CustomDataValueType=Ou;exports.CustomDataWriter=ku;exports.DEFAULT_BASE_URL=Qi;exports.DealNodeRuntimeStatus=gh;exports.DealOfferAction=Fe;exports.DealOfferActivationStatus=fh;exports.EnvelopeType=Qm;exports.EventTokenType=bl;exports.FodderSelectionMode=Up;exports.FodderValuationMode=Mp;exports.FriendActionStatus=Gh;exports.GameLoopAction=me;exports.IDosGamesClient=Br;exports.ItemAction=Ls;exports.KycStatus=yc;exports.KycTier=Sc;exports.LeaderboardAction=fe;exports.LootboxAction=_s;exports.MailboxMessageSource=Af;exports.MailboxMessageStatus=kf;exports.MarketGoodsType=Us;exports.MarketOfferStatus=cp;exports.MarketOfferType=up;exports.MarketplaceAction=ie;exports.MatchAction=je;exports.MatchStatus=Hc;exports.MemoryStorage=ct;exports.MultiplayerAction=Be;exports.MultiplayerChatMode=Vm;exports.MultiplayerTopology=Fm;exports.NoopPlatformAdapter=qr;exports.PremiumAction=ot;exports.QuestAction=Le;exports.QuestObjectiveSource=Fl;exports.QuestPrerequisiteMode=_l;exports.QuestStatus=Gl;exports.RaidMode=nm;exports.ReferralAction=St;exports.ResourceEntryType=Dl;exports.RewardAction=$e;exports.RoomVisibility=_m;exports.ScheduleMode=vl;exports.SeasonAction=nt;exports.SocialAction=Ve;exports.SpecialChoiceMode=om;exports.StoreAction=Rt;exports.StoreType=Gd;exports.TimedBoostAction=at;exports.TimedBoostStackingPolicy=Vh;exports.TimedEventAction=we;exports.TimelineEventType=Nh;exports.TitleAction=lt;exports.TitleCustomDataAction=kt;exports.TitleDataBucket=em;exports.TitleDataScope=Xh;exports.TradeOfferStatus=Hd;exports.TransactionDirection=bc;exports.TypedEmitter=bt;exports.UserAction=Oe;exports.UserCustomDataAction=Ge;exports.WalletLinkType=fc;exports.createIDosGamesClient=af;exports.isFail=xl;exports.isOk=Sl;exports.normalizeBlockchainCategory=Ps;
|