@idosgames/core 0.10.1 → 0.11.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 CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var zod=require('zod'),ci=require('decimal.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ci__default=/*#__PURE__*/_interopDefault(ci);var Nt=class{listeners=new Map;on(e,t){let i=this.listeners.get(e);return i||(i=new Set,this.listeners.set(e,i)),i.add(t),()=>{this.off(e,t);}}once(e,t){let i=this.on(e,r=>{i(),t(r);});return i}off(e,t){let i=this.listeners.get(e);i&&(i.delete(t),i.size===0&&this.listeners.delete(e));}emit(e,t){let i=this.listeners.get(e);if(i)for(let r of [...i])r(t);}removeAllListeners(){this.listeners.clear();}};function Nu(){let o=new Map;return {get:e=>o.get(e)??null,set:(e,t)=>{o.set(e,t);},remove:e=>{o.delete(e);}}}function In(){return ju()??Nu()}function ju(){try{let o=globalThis.localStorage;if(!o)return null;let e="__idos_probe__";return o.setItem(e,"1"),o.removeItem(e),{get:t=>{try{return o.getItem(t)}catch{return null}},set:(t,i)=>{try{o.setItem(t,i);}catch{try{o.removeItem(t);}catch{}}},remove:t=>{try{o.removeItem(t);}catch{}}}}catch{return null}}var kn="https://api.idosgames.com";function Mn(o){return {titleID:o.titleID,titleTemplateID:o.titleTemplateID??"default",buildKey:o.buildKey??"",baseUrl:(o.baseUrl??kn).replace(/\/+$/,""),devBuild:o.devBuild??false,debugLogging:o.debugLogging??false,configStorage:o.configStorage??In(),locale:o.locale??Fu(),appVersion:o.appVersion??""}}function Fu(){try{return globalThis.navigator?.language??""}catch{return ""}}var Dt=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{}}},vt=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 zt(){return globalThis.Telegram?.WebApp??null}function P(){return crypto.randomUUID()}var wn="idos_device_id",Tt=class{storage;constructor(e=new Dt){this.storage=e;}getPlatform(){return zt()?.platform??"Web"}getFullURL(){return typeof location<"u"?location.href:""}getStartParameter(){let e=zt()?.initDataUnsafe?.start_param;return typeof e=="string"?e:null}getReferrer(){if(typeof document>"u")return null;let e=document.referrer;return e&&e.length>0?e:null}getTelegramInitDataRaw(){let e=zt()?.initData;return e&&e.length>0?e:null}getDeviceID(){let e=this.storage.getString(wn);return e||(e=P(),this.storage.setString(wn,e)),e}getDeviceModel(){return typeof navigator<"u"&&navigator.userAgent?navigator.userAgent:"Web"}shareLink(e){let t=zt();if(t?.openTelegramLink){t.openTelegramLink(e);return}typeof window<"u"&&window.open(e,"_blank");}openInvoice(e){let t=zt();if(t?.openInvoice){t.openInvoice(e);return}typeof window<"u"&&window.open(e,"_blank");}async showAd(e){let t=globalThis;typeof t.showAd=="function"&&await t.showAd(e);}async copyToClipboard(e){typeof navigator<"u"&&navigator.clipboard&&await navigator.clipboard.writeText(e);}};var ds="idos_acq",An=["gclid","fbclid","ttclid","msclkid","yclid"],Vu=["ref","r"],_u=["ref_","ref-","ref=","r_","r-"];var ft=class{constructor(e){this.platform=e;}platform;capture(){let e=this.readFromEnvironment();Wu(e)&&this.store({signal:e,capturedAt:Date.now()});}buildForLogin(e){let t=this.read(),i=t?{...t.signal}:{},r=Hu(this.platform.getDeviceModel());return r&&(i.OsVersion=r),e&&(i.AppVersion=e),Object.keys(i).length>0?i:void 0}clear(){this.platform.storage.remove(ds);}static detectDevicePlatform(e){let t=(e||"").toLowerCase();return t.includes("android")?"Android":/iphone|ipad|ipod/.test(t)?"iOS":"Web"}static parseReferralCode(e){if(!e)return null;let t=e.trim();if(!t)return null;if(t.includes("://")||t.includes("?")){let i=Bn(Un(t));if(i)return i}return Yt(t)}readFromEnvironment(){let e={},t=Un(this.platform.getFullURL());mt(e,"UtmSource",t.get("utm_source")),mt(e,"UtmMedium",t.get("utm_medium")),mt(e,"UtmCampaign",t.get("utm_campaign")),mt(e,"UtmTerm",t.get("utm_term")),mt(e,"UtmContent",t.get("utm_content")),mt(e,"ClaimToken",t.get("idos_click"));for(let M of An){let q=t.get(M);if(q){e.ClickID=q;break}}let i=this.platform.getStartParameter()??"",r=Ku(i);if(r){for(let M of Qu)mt(e,M,r.get(Ln[M])??null);for(let M of An){let q=r.get(M);if(q){e.ClickID=q;break}}}let s=Yt(r?r.get("ref")??r.get("r")??"":i),a=Bn(t),p=s||a;p&&(e.ReferralCode=p,e.ChannelHint=s?"telegram":"query");let x=this.platform.getReferrer?.();return x&&(e.Referrer=x),e}read(){try{let e=this.platform.storage.getString(ds);if(!e)return null;let t=JSON.parse(e);return !t?.signal||typeof t.capturedAt!="number"?null:Date.now()-t.capturedAt>2592e6?(this.clear(),null):t}catch{return null}}store(e){try{this.platform.storage.setString(ds,JSON.stringify(e));}catch{}}};function Wu(o){return !!(o.UtmSource||o.UtmMedium||o.UtmCampaign||o.ClickID||o.Referrer||o.ReferralCode||o.ClaimToken)}function mt(o,e,t){t&&(o[e]=t);}var On="a1_",Ln={UtmSource:"utm_source",UtmMedium:"utm_medium",UtmCampaign:"utm_campaign",UtmTerm:"utm_term",UtmContent:"utm_content"},Qu=Object.keys(Ln);function Ku(o){let e=(o||"").trim();if(!e.startsWith(On))return null;let t=e.slice(On.length);if(!t)return null;try{let i=t.replace(/-/g,"+").replace(/_/g,"/"),r=atob(i+"=".repeat((4-i.length%4)%4)),s=Uint8Array.from(r,x=>x.charCodeAt(0)),a=new TextDecoder().decode(s),p=new URLSearchParams(a);return [...p.keys()].length>0?p:null}catch{return null}}function Un(o){try{let e=o.indexOf("?");return new URLSearchParams(e>=0?o.slice(e):"")}catch{return new URLSearchParams}}function Bn(o){for(let e of Vu){let t=o.get(e);if(t)return Yt(t)}return null}function Yt(o){let e=(o||"").trim();if(!e)return null;for(let t of _u)if(e.toLowerCase().startsWith(t)){e=e.slice(t.length).trim();break}return e||null}function Hu(o){let e=o||"",t=/android\s+(\d+)/i.exec(e);if(t)return t[1];let i=/(?:iphone )?os\s+(\d+)[._]/i.exec(e);if(i)return i[1]}var qn="idos_usage_pending",En="idos_usage_session",Gn="idos_usage_closed_session",Nn="idos_usage_new_session",jn="idos_usage_last_activity",jt=class{constructor(e){this.ctx=e;}ctx;pendingSeconds=0;currentSessionSeconds=0;pendingClosedSessionSeconds=0;isNewSessionPending=false;lastTickAt=0;suspendedAt=null;countingPaused=false;timer=null;started=false;flushing=false;start(){this.started||typeof window>"u"||(this.started=true,this.restore(),this.lastTickAt=Date.now(),this.countingPaused=typeof document<"u"&&document.visibilityState==="hidden",this.timer=setInterval(()=>this.tick(),200*1e3),window.addEventListener("visibilitychange",this.onVisibilityChange),window.addEventListener("pagehide",this.onPageHide));}async stop(){this.started&&(this.started=false,this.timer&&(clearInterval(this.timer),this.timer=null),typeof window<"u"&&(window.removeEventListener("visibilitychange",this.onVisibilityChange),window.removeEventListener("pagehide",this.onPageHide)),this.accumulate(),this.closeCurrentSession(false),await this.flush());}onVisibilityChange=()=>{if(!(typeof document>"u")){if(document.visibilityState==="hidden"){this.accumulate(),this.countingPaused=true,this.suspendedAt=Date.now(),this.flush();return}this.countingPaused=false,this.suspendedAt!==null&&((Date.now()-this.suspendedAt)/1e3>=300&&this.closeCurrentSession(true),this.suspendedAt=null),this.lastTickAt=Date.now();}};onPageHide=()=>{this.accumulate(),this.persist(),this.flush();};tick(){this.accumulate(),this.flush();}accumulate(){let e=Date.now(),t=Math.floor((e-this.lastTickAt)/1e3);this.lastTickAt=e,!(t<=0)&&(this.countingPaused||(this.pendingSeconds+=t,this.currentSessionSeconds+=t,this.persist()));}closeCurrentSession(e){let t=Math.floor(this.currentSessionSeconds);t>0&&(this.pendingClosedSessionSeconds=Math.max(this.pendingClosedSessionSeconds,t)),this.currentSessionSeconds=0,e&&(this.isNewSessionPending=true),this.persist();}async flush(){if(this.flushing||this.pendingSeconds<=0&&this.pendingClosedSessionSeconds<=0&&!this.isNewSessionPending)return;let e=this.pendingSeconds,t=this.pendingClosedSessionSeconds,i=this.isNewSessionPending;this.flushing=true,this.pendingSeconds=0,this.pendingClosedSessionSeconds=0,this.isNewSessionPending=false,this.persist();try{(await this.ctx.userService.addUsageTime(e,i,t)).ok||(this.pendingSeconds+=e,this.pendingClosedSessionSeconds=Math.max(this.pendingClosedSessionSeconds,t),this.isNewSessionPending||=i,this.persist());}catch{this.pendingSeconds+=e,this.pendingClosedSessionSeconds=Math.max(this.pendingClosedSessionSeconds,t),this.isNewSessionPending||=i,this.persist();}finally{this.flushing=false;}}restore(){this.pendingSeconds=this.readNumber(qn),this.currentSessionSeconds=this.readNumber(En),this.pendingClosedSessionSeconds=this.readNumber(Gn),this.isNewSessionPending=this.readNumber(Nn)!==0;let e=this.readNumber(jn);this.currentSessionSeconds>0&&e>0&&(Date.now()-e)/1e3>=300&&(this.pendingClosedSessionSeconds=Math.max(this.pendingClosedSessionSeconds,Math.floor(this.currentSessionSeconds)),this.currentSessionSeconds=0);}persist(){this.writeNumber(qn,this.pendingSeconds),this.writeNumber(En,this.currentSessionSeconds),this.writeNumber(Gn,this.pendingClosedSessionSeconds),this.writeNumber(Nn,this.isNewSessionPending?1:0),this.writeNumber(jn,Date.now());}readNumber(e){let t=this.ctx.platform.storage.getString(e),i=t?Number(t):0;return Number.isFinite(i)&&i>0?i:0}writeNumber(e,t){try{this.ctx.platform.storage.setString(e,String(Math.floor(t)));}catch{}}};var _e={Virtual:"Virtual",Crypto:"Crypto"},It=zod.z.enum(["Virtual","Crypto"]).catch("Virtual"),Xt={Item:"Item",VirtualCurrency:"VirtualCurrency",CryptoCurrency:"CryptoCurrency",RewardedVideoCredit:"RewardedVideoCredit",Purchase:"Purchase"},ei=zod.z.enum(["Item","VirtualCurrency","CryptoCurrency","RewardedVideoCredit","Purchase"]).catch("Item"),Ye={Unknown:"Unknown",Web:"Web",Android:"Android",Ios:"Ios"},ti=zod.z.enum(["Unknown","Web","Android","Ios"]).catch("Unknown"),$u={GooglePlay:"GooglePlay",AppleAppStore:"AppleAppStore"},ii=zod.z.enum(["GooglePlay","AppleAppStore"]).catch("GooglePlay"),Zu={TimedEvent:"TimedEvent",Quest:"Quest",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season"},ri=zod.z.enum(["TimedEvent","Quest","Leaderboard","CoopEvent","Season"]).catch("TimedEvent"),Ju={Cyclic:"Cyclic",Scheduled:"Scheduled",Chained:"Chained"},Ft=zod.z.enum(["Cyclic","Scheduled","Chained"]).catch("Cyclic"),Re={None:"None",Device:"Device",Email:"Email",iDosGames:"iDosGames",Facebook:"Facebook",Google:"Google",GooglePlay:"GooglePlay",Telegram:"Telegram",Wallet:"Wallet"};function Vn(){let o=globalThis,e=o.Capacitor?.getPlatform?.();if(e)return Fn(e);let t=o.cordova?.platformId;return t?Fn(t):o.navigator?.userAgent??""?Ye.Web:Ye.Unknown}function Fn(o){let e=o.toLowerCase();return e==="android"?Ye.Android:e==="ios"?Ye.Ios:e==="web"?Ye.Web:Ye.Unknown}function Vt(o){return {ok:true,data:o}}function n(o,e){return {ok:false,reason:o,error:e}}function Yu(o){return o.ok}function Xu(o){return !o.ok}var w=zod.z.union([zod.z.number(),zod.z.string()]).transform((o,e)=>{let t=typeof o=="string"?Number(o):o;return Number.isFinite(t)?Math.trunc(t):(e.addIssue({code:zod.z.ZodIssueCode.custom,message:`Invalid integer amount: ${String(o)}`}),zod.z.NEVER)}),E=zod.z.union([zod.z.number(),zod.z.string()]).transform((o,e)=>{let t=typeof o=="number"?String(o):o.trim();return t===""||Number.isNaN(Number(t))?(e.addIssue({code:zod.z.ZodIssueCode.custom,message:`Invalid decimal: ${String(o)}`}),zod.z.NEVER):t}),u=zod.z.string();var hs=zod.z.object({Type:ei.nullish(),CurrencyID:zod.z.string().nullish(),Amount:w.nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),ProductID:zod.z.string().nullish()}),ec=zod.z.object({Type:ri.nullish(),EntityID:zod.z.string()}),tc=zod.z.object({Address:ec.nullish(),Amount:w.nullish(),Source:zod.z.string().nullish()}),ge=zod.z.object({Entries:zod.z.array(hs).nullish(),EventTokens:zod.z.array(tc).nullish()}),_n=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Resources:ge.nullish()}),L=zod.z.object({Standard:ge.nullish(),PremiumBonuses:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(_n).nullish()}),_t=zod.z.object({Standard:ge.nullish(),PremiumDiscounts:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(_n).nullish()}),D=zod.z.object({Grant:L.nullish(),Consume:_t.nullish()}),gt=zod.z.object({FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),FromResult:D.nullish(),ToResult:D.nullish()});zod.z.object({FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),Transferred:ge.nullish()});var ic=zod.z.object({ExperimentID:zod.z.string().nullish(),Variants:zod.z.array(zod.z.string()).nullish()}).passthrough(),rc={Completed:"Completed",Started:"Started",StepReached:"StepReached"},sc=zod.z.object({FlowIDs:zod.z.array(zod.z.string()).nullish(),Mode:zod.z.enum(["Completed","Started","StepReached"]).catch("Completed").nullish(),StepID:zod.z.string().nullish(),Negate:zod.z.boolean().nullish(),SkippedCountsAsCompleted:zod.z.boolean().nullish()}).passthrough(),W=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:ic.nullish(),Tutorial:sc.nullish(),Platforms:zod.z.array(ti).nullish()}).passthrough();var ue=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 nc=zod.z.object({OffsetSecondsFromParentStart:zod.z.number().nullish(),DurationSeconds:zod.z.number().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),oc=zod.z.object({StartUtc:zod.z.string().nullish(),EndUtc:zod.z.string().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),ac=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 lc=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 Le=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:ue.nullish()}).passthrough(),de=zod.z.object({Mode:zod.z.string().nullish(),IsActive:zod.z.boolean().nullish(),Scheduled:oc.nullish(),Chain:ac.nullish(),Cyclic:lc.nullish(),ActivationTriggers:zod.z.array(Le).nullish(),Relative:nc.nullish()}).passthrough();var uc={Flat:"Flat",PerStep:"PerStep",PerStepRate:"PerStepRate",Geometric:"Geometric",Table:"Table",TableAbsolute:"TableAbsolute"},cc=zod.z.enum(["Flat","PerStep","PerStepRate","Geometric","Table","TableAbsolute"]).catch("Flat"),pc={Step:"Step",Linear:"Linear",Geometric:"Geometric"},dc=zod.z.enum(["Step","Linear","Geometric"]).catch("Step"),hc=zod.z.object({AtStep:zod.z.number().nullish(),Value:zod.z.number().nullish()}).passthrough(),xe=zod.z.object({Base:zod.z.number().nullish(),Shape:cc.nullish(),PerStep:zod.z.number().nullish(),PerStepRate:zod.z.number().nullish(),GrowthRate:zod.z.number().nullish(),Points:zod.z.array(hc).nullish(),Interpolation:dc.nullish(),TailGrowthRate:zod.z.number().nullish(),MinResult:zod.z.number().nullish(),MaxResult:zod.z.number().nullish()}).passthrough();var mc=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Rewards:L.nullish()}).passthrough(),fc=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),ms=zod.z.object({Bundles:zod.z.array(mc).nullish(),Multipliers:zod.z.array(fc).nullish()}).passthrough();var gc=zod.z.enum(["BoardStageLevel","BoardRank","BoardCyclesCompleted","CharacterLevel","SeasonTier","EventTokenTotalEarned","VirtualCurrencyBalance","PlayerLevel"]).catch("BoardStageLevel"),si=zod.z.object({Source:gc.nullish(),SourceKey:zod.z.string().nullish(),Curve:xe.nullish(),Anchor:zod.z.number().nullish(),IncludeRewards:ge.nullish(),ExcludeRewards:ge.nullish()}).passthrough(),ve=zod.z.object({MilestoneID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),RequiredProgress:zod.z.number().nullish(),Rewards:L.nullish(),BonusRewards:L.nullish(),SeasonTierRewards:ms.nullish(),SortOrder:zod.z.number().nullish(),IsFeatured:zod.z.boolean().nullish()}).passthrough(),ut=zod.z.object({Milestones:zod.z.record(zod.z.string(),ve).nullish()}).passthrough();var Y=zod.z.object({PresetID:zod.z.string().nullish(),Remove:zod.z.array(zod.z.string()).nullish()}).passthrough();var Rc=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:Rc.nullish()}).passthrough();var re=o=>zod.z.object({Id:zod.z.string(),Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:o.nullish()}),Xe=o=>zod.z.object({ServerTimeUtc:u,Items:zod.z.array(re(o)),Resources:D.nullish()});var yc={Active:"Active",Completed:"Completed",Claimed:"Claimed",Expired:"Expired"},Wn=zod.z.enum(["Active","Completed","Claimed","Expired"]).catch("Active"),Cc=zod.z.object({}).passthrough().transform(o=>o),Sc=zod.z.object({CycleID:zod.z.string(),InstanceKey:zod.z.string().nullish(),PhaseID:zod.z.string().nullish(),CycleIndex:zod.z.number().nullish(),CycleStartUtc:u.nullish(),CycleEndUtc:u.nullish(),PointsTotalEarned:w.nullish(),PointsCurrent:w.nullish(),ClaimedPointMilestoneIDs:zod.z.array(zod.z.string()).nullish()}),fs=zod.z.object({QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),ObjectiveID:zod.z.string().nullish(),NewValue:w.nullish(),ObjectiveCompleted:zod.z.boolean().nullish(),Status:Wn}),Qn=zod.z.object({State:Cc.nullish(),PointsTracks:zod.z.record(zod.z.string(),Sc).nullish()}),gs=zod.z.object({ServerTimeUtc:u,QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),NewStatus:Wn.nullish(),Resources:D.nullish()}),Rs=zod.z.object({ServerTimeUtc:u,CycleID:zod.z.string(),MilestoneID:zod.z.string(),PointsTotalEarned:w.nullish(),Resources:D.nullish()}),Kn=zod.z.object({ServerTimeUtc:u,CycleID:zod.z.string(),GroupCompletionID:zod.z.string(),GroupID:zod.z.string().nullish(),CompletedGroupQuests:zod.z.number().nullish(),RequiredGroupQuests:zod.z.number().nullish(),Resources:D.nullish()}),Hn=zod.z.object({MetricID:zod.z.string(),Updates:zod.z.array(fs).nullish()}),$n=zod.z.array(re(gs)),Zn=zod.z.array(re(Rs)),xc={ClientApi:"ClientApi",ServerApi:"ServerApi",SystemEvent:"SystemEvent"},bc=zod.z.enum(["ClientApi","ServerApi","SystemEvent"]).catch("ClientApi"),Dc={BlockProgressAndClaim:"BlockProgressAndClaim",BlockClaimOnly:"BlockClaimOnly"},vc=zod.z.enum(["BlockProgressAndClaim","BlockClaimOnly"]).catch("BlockProgressAndClaim"),Jn=zod.z.object({ObjectiveID:zod.z.string().nullish(),Source:bc.nullish(),MaxProgressPerCall:zod.z.number().nullish(),MetricID:zod.z.string().nullish(),Triggers:zod.z.array(Le).nullish(),TargetValue:zod.z.number().nullish(),AggregationMethod:zod.z.string().nullish()}).passthrough(),ys=zod.z.object({Milestones:Y.nullish(),Linking:Y.nullish(),Availability:Y.nullish(),Reward:Y.nullish(),Objectives:Y.nullish()}).passthrough(),zc=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(),Yn=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:vc.nullish()}).passthrough(),Xn=zod.z.object({Schedule:de.nullish(),AccrueProgressWhenLocked:zod.z.boolean().nullish(),Gate:W.nullish(),Limits:ue.nullish()}).passthrough(),eo=zod.z.object({Grant:L.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),Tc=zod.z.object({QuestID:zod.z.string().nullish(),Identity:zc.nullish(),Linking:Yn.nullish(),Availability:Xn.nullish(),Objectives:zod.z.record(zod.z.string(),Jn).nullish(),Reward:eo.nullish(),Presets:ys.nullish()}).passthrough(),Pc=zod.z.object({CompletionID:zod.z.string().nullish(),GroupID:zod.z.string().nullish(),RequiredCompletedQuests:zod.z.number().nullish(),Gate:W.nullish(),Reward:L.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),Ic=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:W.nullish(),Milestones:zod.z.record(zod.z.string(),ve).nullish(),Presets:ys.nullish(),PointsToken:Rt.nullish()}).passthrough(),kc=zod.z.object({Milestones:zod.z.record(zod.z.string(),ut).nullish(),Linking:zod.z.record(zod.z.string(),Yn).nullish(),Availability:zod.z.record(zod.z.string(),Xn).nullish(),Reward:zod.z.record(zod.z.string(),eo).nullish(),Objectives:zod.z.record(zod.z.string(),zod.z.record(zod.z.string(),Jn)).nullish()}).passthrough(),Mc=zod.z.object({CycleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:de.nullish(),Milestones:zod.z.record(zod.z.string(),ve).nullish(),Gate:W.nullish(),PointsToken:Rt.nullish(),GroupCompletions:zod.z.record(zod.z.string(),Pc).nullish(),Phases:zod.z.record(zod.z.string(),Ic).nullish(),Presets:ys.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),oi=zod.z.object({Cycles:zod.z.record(zod.z.string(),Mc).nullish(),Quests:zod.z.record(zod.z.string(),Tc).nullish(),Presets:kc.nullish()}).passthrough(),Qe={GetQuestDefinitions:"GetQuestDefinitions",GetUserQuestState:"GetUserQuestState",RefreshQuestCycles:"RefreshQuestCycles",ClaimQuestReward:"ClaimQuestReward",ClaimMilestoneReward:"ClaimMilestoneReward",AddQuestProgress:"AddQuestProgress",ClaimQuestRewardsBatch:"ClaimQuestRewardsBatch",ClaimMilestoneRewardsBatch:"ClaimMilestoneRewardsBatch",ClaimGroupCompletionReward:"ClaimGroupCompletionReward"};var wc={ClientAck:"ClientAck",SystemEvent:"SystemEvent",Auto:"Auto",Composite:"Composite"},Ac=zod.z.enum(["ClientAck","SystemEvent","Auto","Composite"]).catch("ClientAck"),Oc={Never:"Never",OnRequest:"OnRequest",Always:"Always"},Uc=zod.z.enum(["Never","OnRequest","Always"]).catch("Never"),Bc={NotStarted:"NotStarted",InProgress:"InProgress",Completed:"Completed",Skipped:"Skipped",Expired:"Expired"},Lc=zod.z.enum(["NotStarted","InProgress","Completed","Skipped","Expired"]).catch("NotStarted"),qc={GameLoop:"GameLoop"},Ec={Raid:"Raid",Attack:"Attack"},Gc=zod.z.object({Title:zod.z.string().nullish(),TitleKey:zod.z.string().nullish(),Body:zod.z.string().nullish(),BodyKey:zod.z.string().nullish(),AnchorID:zod.z.string().nullish(),HighlightTarget:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),UiHint:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Nc=zod.z.object({Mode:Ac.nullish(),Triggers:zod.z.array(Le).nullish(),TargetValue:zod.z.number().nullish(),RequireAllTriggers:zod.z.boolean().nullish()}).passthrough(),jc=zod.z.object({Grant:L.nullish(),UnlockFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),Fc=zod.z.object({TileType:zod.z.string().nullish(),TileIndex:zod.z.number().nullish(),ChanceOutcomeID:zod.z.string().nullish(),RandomActionType:zod.z.enum(["Raid","Attack"]).catch("Raid").nullish()}).passthrough(),Vc=zod.z.object({Module:zod.z.enum(["GameLoop"]).catch("GameLoop").nullish(),Board:Fc.nullish(),MaxUses:zod.z.number().nullish()}).passthrough(),_c=zod.z.object({Skippable:zod.z.boolean().nullish(),TimeoutSeconds:zod.z.number().nullish()}).passthrough(),Cs=zod.z.object({StepID:zod.z.string().nullish(),Order:zod.z.number().nullish(),Identity:Gc.nullish(),Completion:Nc.nullish(),Effects:jc.nullish(),Script:Vc.nullish(),Policy:_c.nullish()}).passthrough(),Wc=zod.z.object({DisplayName:zod.z.string().nullish(),DisplayNameKey:zod.z.string().nullish(),Description:zod.z.string().nullish(),DescriptionKey:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),to=zod.z.object({Schedule:de.nullish(),Gate:W.nullish(),RequiredFlowIDs:zod.z.array(zod.z.string()).nullish(),AutoStart:zod.z.boolean().nullish(),StartTrigger:Le.nullish()}).passthrough(),io=zod.z.object({Skippable:zod.z.boolean().nullish(),SkippableFromOrder:zod.z.number().nullish(),RestartPolicy:Uc.nullish(),ExpireAfterSeconds:zod.z.number().nullish(),IsBlocking:zod.z.boolean().nullish(),UnlockFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),ro=zod.z.object({Grant:L.nullish(),AutoClaim:zod.z.boolean().nullish()}).passthrough(),Qc=zod.z.object({Availability:Y.nullish(),Policy:Y.nullish(),Reward:Y.nullish(),Steps:Y.nullish()}).passthrough(),Kc=zod.z.object({FlowID:zod.z.string().nullish(),Identity:Wc.nullish(),Availability:to.nullish(),Policy:io.nullish(),Steps:zod.z.record(zod.z.string(),Cs).nullish(),Reward:ro.nullish(),Presets:Qc.nullish()}).passthrough(),Hc=zod.z.object({BlockingFlowIDs:zod.z.array(zod.z.string()).nullish(),BlockedModules:zod.z.array(zod.z.string()).nullish(),BlockedActions:zod.z.record(zod.z.string(),zod.z.array(zod.z.string())).nullish(),BlockBeforeStart:zod.z.boolean().nullish(),SkipLiftsBlock:zod.z.boolean().nullish()}).passthrough(),$c=zod.z.object({IsEnabled:zod.z.boolean().nullish(),MaxActiveFlows:zod.z.number().nullish(),Blocking:Hc.nullish()}).passthrough(),Zc=zod.z.object({Availability:zod.z.record(zod.z.string(),to).nullish(),Policy:zod.z.record(zod.z.string(),io).nullish(),Reward:zod.z.record(zod.z.string(),ro).nullish(),Steps:zod.z.record(zod.z.string(),zod.z.record(zod.z.string(),Cs)).nullish()}).passthrough(),so=zod.z.object({Flows:zod.z.record(zod.z.string(),Kc).nullish(),Settings:$c.nullish(),Presets:Zc.nullish()}).passthrough(),Jc=zod.z.object({}).passthrough().transform(o=>o),no=zod.z.object({FlowID:zod.z.string(),Status:Lc,CurrentStepID:zod.z.string().nullish(),CurrentStep:Cs.nullish(),TotalSteps:zod.z.number(),CompletedSteps:zod.z.number(),CanSkip:zod.z.boolean(),RewardClaimed:zod.z.boolean(),RewardPending:zod.z.boolean(),VariantID:zod.z.string().nullish()}).passthrough(),oo=zod.z.object({State:Jc.nullish(),Flows:zod.z.array(no).nullish(),UnlockedFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),ct=zod.z.object({Flow:no.nullish()}).passthrough(),ao=zod.z.object({FlowID:zod.z.string().nullish(),Granted:D.nullish()}).passthrough(),lo=zod.z.array(re(ct)),uo=zod.z.object({FlowID:zod.z.string(),StepID:zod.z.string(),Progress:zod.z.number(),Target:zod.z.number(),Completed:zod.z.boolean()}).passthrough(),qe={GetTutorialDefinitions:"GetTutorialDefinitions",GetUserTutorialState:"GetUserTutorialState",StartFlow:"StartFlow",ReportStepShown:"ReportStepShown",CompleteStep:"CompleteStep",CompleteStepsBatch:"CompleteStepsBatch",SkipStep:"SkipStep",SkipFlow:"SkipFlow",ClaimFlowReward:"ClaimFlowReward",ResetFlow:"ResetFlow"};var ai=class{constructor(e=600,t=()=>Date.now()){this.windowMs=e;this.now=t;}windowMs;now;last=new Map;tryAcquire(e){if(this.windowMs<=0)return true;let t=this.now(),i=this.last.get(e);return i!==void 0&&t-i<this.windowMs?false:(this.last.set(e,t),true)}reset(){this.last.clear();}};var li=class{set=new Set;add(e){return this.set.has(e)?false:(this.set.add(e),true)}remove(e){this.set.delete(e);}};function co(o){return o===429||o>=500&&o<=599}function Ss(o,e=Math.random){let t=Math.min(500*Math.pow(2,o-1),4e3),i=t*.2*(e()*2-1);return Math.max(50,t+i)}function xs(o){return new Promise(e=>setTimeout(e,o))}var Yc=12e3,Xc=zod.z.object({Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:zod.z.unknown().optional(),QuestProgress:zod.z.array(fs).nullish(),TutorialProgress:zod.z.array(uo).nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish(),StateEpoch:zod.z.string().nullish()}).passthrough(),ui=class{baseUrl;emitter;fetchImpl;debugLogging;throttler;clientPlatform;inflight=new li;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 ai(e.throttleMs),this.clientPlatform=e.clientPlatform??Ye.Unknown;}setSessionRefreshHandler(e){this.sessionRefreshHandler=e;}async post(e,t,i,r={}){let s=r.throttleKey??e;if(!this.throttler.tryAcquire(s))return n("throttled","Throttled");if(!this.inflight.add(s))return n("throttled","Duplicate request skipped");this.raiseBusy();try{let a=`${this.baseUrl}/${e}`,p=JSON.stringify(t),x=r.ticket??null,M=r.silent??!1,q=r.timeoutMs??Yc,me=r.autoRetry??!0,ye=!1,ke=0;for(;;){let Ze;try{Ze=await this.doFetch(a,p,x,q);}catch{if(me&&ke<3){ke++,await xs(Ss(ke));continue}return this.connectionFailure("Internet Connection Error",M)}let Je=Ze.status;if(Je>=200&&Je<300)return await this.parseSuccess(Ze,i,M,e);if(Je===401){if(!ye&&this.sessionRefreshHandler){ye=!0;let rt=null;try{rt=await this.sessionRefreshHandler();}catch{rt=null;}if(rt){x=rt;continue}}return this.emitter.emit("auth:unauthorized",void 0),n("unauthorized","Unauthorized")}if(co(Je)){if(me&&ke<3){ke++,await xs(Ss(ke));continue}return this.connectionFailure(`Server temporarily unavailable (HTTP ${Je})`,M)}return await this.handleWebError(Ze,Je,M)}}finally{this.inflight.remove(s),this.lowerBusy();}}async doFetch(e,t,i,r){let s=new AbortController,a=setTimeout(()=>{s.abort();},r);try{let p={"Content-Type":"application/json","X-IG-Platform":this.clientPlatform};return i&&(p.Authorization=`Bearer ${i}`),await this.fetchImpl(e,{method:"POST",body:t,headers:p,signal:s.signal})}finally{clearTimeout(a);}}async parseSuccess(e,t,i,r){let s;try{s=await e.text();}catch{return this.globalError("Failed to read response body",i)}let a;try{a=JSON.parse(s);}catch{return this.globalError("JSON Parse Error",i)}let p=Xc.safeParse(a);if(!p.success)return this.globalError("Malformed response envelope",i);if(!p.data.Success){let ye=p.data.Error??"Server returned Success=false";return i||this.emitter.emit("error:global",ye),n("server",ye)}let x=p.data.QuestProgress;x&&x.length>0&&this.emitter.emit("quest:systemProgress",x);let M=p.data.TutorialProgress;M&&M.length>0&&this.emitter.emit("tutorial:systemProgress",M);let q=p.data.StateVersions;q&&Object.keys(q).length>0&&this.emitter.emit("user:stateVersions",{epoch:p.data.StateEpoch??null,versions:q});let me=t.safeParse(p.data.Data);if(!me.success){let ye=`Validation error (${r}): ${me.error.message}`;return this.debugLogging&&console.warn("[HttpTransport]",ye),i||this.emitter.emit("error:global",ye),n("validation",ye)}return Vt(me.data)}async handleWebError(e,t,i){let r=`HTTP ${t}`;try{let s=await e.text();if(s)try{let p=JSON.parse(s).Error;r=typeof p=="string"&&p.length>0?`HTTP ${t}: ${p}`:`HTTP ${t}: ${s}`;}catch{r=`HTTP ${t}: ${s}`;}}catch{}return i||this.emitter.emit("error:global",r),n("server",r)}connectionFailure(e,t){return t||this.emitter.emit("error:connection",e),n("connection",e)}globalError(e,t){return t||this.emitter.emit("error:global",e),n("server",e)}raiseBusy(){this.inFlightRequests++,this.inFlightRequests===1&&this.emitter.emit("transport:busy",true);}lowerBusy(){this.inFlightRequests>0&&(this.inFlightRequests--,this.inFlightRequests===0&&this.emitter.emit("transport:busy",false));}};function Mt(o){return (typeof o=="string"?o:o.toISOString()).slice(0,10)}function Wt(o){return `${Mt(o)}T00:00:00.000Z`}function ho(o){let e=new Date(o);return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+1)).toISOString()}function mo(o,e){return new Date(o.getTime()+e*6e4).toISOString()}function fo(o,e,t,i){let r={vcChanged:false,ccChanged:false,itemsChanged:false,tokensChanged:false};if(!e)return r;o.InventoryV2??={};let s=o.InventoryV2,a=i.toISOString(),p=new Map,x=new Map,M=new Map,q=new Map,me=new Map,ye=new Map,ke=new Map,Ze=new Map,Je=e.Grant?.PremiumTiers??[],rt=Je.length;for(let ne=0;;ne++){let fe,$;if(ne===0)fe=e.Grant?.Standard?.Entries,$=false;else if(ne-1<rt)fe=Je[ne-1]?.Resources?.Entries,$=false;else if(ne===1+rt)fe=e.Consume?.Standard?.Entries,$=true;else break;if(fe)for(let _ of fe){if(_.Type==null)continue;let K=Math.max(0,_.Amount??0);if(!(K<=0))switch(_.Type){case "VirtualCurrency":{if(!_.CurrencyID)continue;let H=$?x:p;H.set(_.CurrencyID,(H.get(_.CurrencyID)??0)+K);break}case "CryptoCurrency":{if(!_.CurrencyID)continue;let H=$?q:M;H.set(_.CurrencyID,(H.get(_.CurrencyID)??new ci__default.default(0)).plus(K));break}case "Item":{if(!_.ItemID)continue;let H=tp(t,_.CatalogID,_.ItemID),X=(H?H.IsStackable??true:true)?$?ye:me:$?Ze:ke;X.set(_.ItemID,(X.get(_.ItemID)??0)+K);break}case "Purchase":case "RewardedVideoCredit":continue}}}if(r.vcChanged=p.size>0||x.size>0,r.vcChanged){s.VirtualCurrencies??={};for(let ne of new Set([...p.keys(),...x.keys()])){let fe=p.get(ne)??0,$=x.get(ne)??0,_=fe-$,K=s.VirtualCurrencies[ne];K?(K.Amount+=_,K.UpdatedAt=a,K.Daily&&Mt(K.Daily.PeriodStartUtc)===Mt(i)?(K.Daily.Earned+=fe,K.Daily.Spent+=$):K.Daily={PeriodStartUtc:Wt(i),Earned:fe,Spent:$}):s.VirtualCurrencies[ne]={Amount:_,CreatedAt:a,UpdatedAt:a,Daily:{PeriodStartUtc:Wt(i),Earned:fe,Spent:$}};}}if(r.ccChanged=M.size>0||q.size>0,r.ccChanged){s.CryptoCurrencies??={};for(let ne of new Set([...M.keys(),...q.keys()])){let fe=M.get(ne)??new ci__default.default(0),$=q.get(ne)??new ci__default.default(0),_=fe.minus($),K=s.CryptoCurrencies[ne];K?(K.Amount=new ci__default.default(K.Amount).plus(_).toString(),K.UpdatedAt=a):s.CryptoCurrencies[ne]={Amount:_.toString(),Frozen:"0",CreatedAt:a,UpdatedAt:a};}}if(r.itemsChanged=me.size>0||ye.size>0||ke.size>0||Ze.size>0,r.itemsChanged){s.Items??={},s.UnstackableItems??={};let ne=s.UnstackableItems,fe=new Set([...me.keys(),...ye.keys(),...ke.keys(),...Ze.keys()]);for(let $ of fe){let _=(me.get($)??0)-(ye.get($)??0),K=(ke.get($)??0)-(Ze.get($)??0),H=_+K,Be=s.Items[$];Be?(_!==0&&(Be.StackableAmount+=_),K!==0&&(Be.UnstackableAmount+=K),H!==0&&(Be.TotalAmount+=H)):s.Items[$]={StackableAmount:Math.max(0,_),UnstackableAmount:Math.max(0,K),TotalAmount:Math.max(0,H)};}for(let[$,_]of Ze){if(_<=0)continue;let K=Object.values(ne).filter(H=>H.ItemID===$&&H.EquippedSlot==null&&(H.ExpiresAt==null||new Date(H.ExpiresAt)>i)).sort(ep).slice(0,_).map(H=>H.ItemInstanceID);for(let H of K)delete ne[H];}for(let[$,_]of ke){let K=ip(t,$);for(let H=0;H<_;H++){let Be=P();ne[Be]={ItemInstanceID:Be,ItemID:$,CatalogID:K,RemainingUses:1,AcquiredAt:a};}}}o.EventToken??={};let Gu=o.EventToken;for(let ne=0;;ne++){let fe,$;if(ne===0)fe=e.Grant?.Standard?.EventTokens,$=false;else if(ne-1<rt)fe=Je[ne-1]?.Resources?.EventTokens,$=false;else if(ne===1+rt)fe=e.Consume?.Standard?.EventTokens,$=true;else break;if(!(!fe||fe.length===0))for(let _ of fe){let K=_.Address;if(!K||K.Type==null)continue;let H=_.Amount??0;if(H<=0)continue;let Be=rp(Gu,K.Type);if(!Be)continue;let X=Be[K.EntityID];X||(X={},Be[K.EntityID]=X),X.Balance??={Current:0,TotalEarned:0,TotalSpent:0},X.Daily??={Date:Wt(i),TotalEarned:0},X.Meta??={};let Gt=_.Source&&_.Source.length>0?_.Source:"CustomAction";$?(X.Balance.Current-=H,X.Balance.TotalSpent+=H):(X.Balance.Current+=H,X.Balance.TotalEarned+=H,Mt(X.Daily.Date)!==Mt(i)&&(X.Daily={Date:Wt(i),TotalEarned:0}),X.Daily.TotalEarned+=H,X.Daily.EarnedBySource??={},X.Daily.EarnedBySource[Gt]=(X.Daily.EarnedBySource[Gt]??0)+H,X.Daily.TriggersBySource??={},X.Daily.TriggersBySource[Gt]=(X.Daily.TriggersBySource[Gt]??0)+1,X.Daily.LastTriggerBySource??={},X.Daily.LastTriggerBySource[Gt]=a,X.Meta.JoinedAtUtc||(X.Meta.JoinedAtUtc=a),X.Meta.LastEarnedAtUtc=a),r.tokensChanged=true;}}return r}function ep(o,e){return o.AcquiredAt!==e.AcquiredAt?o.AcquiredAt<e.AcquiredAt?-1:1:o.ItemInstanceID===e.ItemInstanceID?0:o.ItemInstanceID<e.ItemInstanceID?-1:1}function tp(o,e,t){let i=o?.Catalogs;if(i){if(e){let r=i[e]?.Items?.[t];if(r)return r}for(let r of Object.values(i)){let s=r.Items?.[t];if(s)return s}}}function ip(o,e){let t=o?.Catalogs;if(t){for(let[i,r]of Object.entries(t))if(r.Items&&e in r.Items)return i}}function rp(o,e){switch(e){case "TimedEvent":return o.TimedEvent??={};case "Quest":return o.Quest??={};case "Leaderboard":return o.Leaderboard??={};case "CoopEvent":return o.CoopEvent??={};case "Season":return o.Season??={};default:return null}}function bs(o,e){return o===e||o.startsWith(`${e}:`)}var pi=class{constructor(e){this.emitter=e;}emitter;currentState={};activeEventsCache=null;get state(){return this.currentState}getCachedActiveEvents(){return this.activeEventsCache}clear(){this.currentState=null,this.emitter.emit("user:anyUpdated",void 0);}applyUserState(e){this.currentState=e,this.emitter.emit("user:stateUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyUserStateContainers(e,t){if(t.length!==0){this.currentState??={};for(let i of t)this.currentState[i]=e[i];this.emitter.emit("user:stateUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}}applyInventory(e){this.currentState??={},this.currentState.InventoryV2=e,this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyVirtualCurrency(e){this.currentState??={},this.currentState.InventoryV2??={},this.currentState.InventoryV2.VirtualCurrencies=e,this.emitter.emit("user:virtualCurrencyUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyResourceOperation(e,t,i=new Date){if(!this.currentState)return;let r=fo(this.currentState,e,t,i);r.vcChanged&&this.emitter.emit("user:virtualCurrencyUpdated",void 0),(r.vcChanged||r.ccChanged||r.itemsChanged)&&this.emitter.emit("user:inventoryUpdated",void 0),r.tokensChanged&&this.emitter.emit("user:eventTokenUpdated",void 0),(r.vcChanged||r.ccChanged||r.itemsChanged||r.tokensChanged)&&this.emitter.emit("user:anyUpdated",void 0);}patchCryptoCurrencyDelta(e,t,i){if(!e||!this.currentState)return;this.currentState.InventoryV2??={},this.currentState.InventoryV2.CryptoCurrencies??={};let r=this.currentState.InventoryV2.CryptoCurrencies,s=t instanceof ci__default.default?t:new ci__default.default(t),a=i??new Date().toISOString(),p=r[e];p?(p.Amount=new ci__default.default(p.Amount).plus(s).toString(),p.UpdatedAt=a):r[e]={Amount:s.toString(),Frozen:"0",CreatedAt:a,UpdatedAt:a},this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyStore(e){this.currentState??={},this.currentState.Store=e??{},this.emitter.emit("user:storeUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchStorePurchase(e,t,i){if(!e||t<1||!this.currentState)return;this.currentState.Store??={},this.currentState.Store.Purchases??={};let r=this.currentState.Store.Purchases,s=r[e];s||(s={OfferID:e,TotalPurchases:0,DailyPurchases:0,DailyResetUtc:"",LastPurchasedAt:""},r[e]=s),s.TotalPurchases+=t,s.LastPurchasedAt=i,i>=s.DailyResetUtc?(s.DailyPurchases=t,s.DailyResetUtc=ho(i)):s.DailyPurchases+=t,this.emitter.emit("user:storeUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyLootboxPityTriggers(e,t,i){if(!e||i<=0)return;this.currentState??={};let r=this.currentState.Lootbox??={};if(r.Pity??={},t){let s=new Date().toISOString();for(let a of t)a.RuleID&&(r.Pity[`${e}:${a.RuleID}`]={OpensSinceLastTrigger:0,LastTriggeredAtUtc:s});}this.emitter.emit("user:lootboxUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyReward(e){this.currentState??={},this.currentState.Reward=e??{},this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchDailyCalendarState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.DailyCalendars??={},this.currentState.Reward.DailyCalendars[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchIdleAccrualState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.IdleAccruals??={},this.currentState.Reward.IdleAccruals[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchComebackState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.Comebacks??={},this.currentState.Reward.Comebacks[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchClaimRewardState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.Claims??={},this.currentState.Reward.Claims[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyQuest(e){this.currentState??={},this.currentState.Quest=e??{},this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchQuestStatus(e,t,i){if(!e)return;this.currentState??={},this.currentState.Quest??={};let r=this.currentState.Quest;if(t){r.Cycles??={};let s=r.Cycles[t];if(!s)return;s.Quests??={};let a=s.Quests[e]??={QuestID:e,Status:i};a.Status=i,i==="Claimed"&&(a.ClaimedAtUtc??=new Date().toISOString());}else {r.PermanentQuests??={};let s=r.PermanentQuests[e]??={QuestID:e,Status:i};s.Status=i,i==="Claimed"&&(s.ClaimedAtUtc??=new Date().toISOString());}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchMilestoneClaimed(e,t){if(!e||!t)return;let i=this.getQuestPointsProgress(e);i&&(i.Milestone??={},this.markMilestoneClaimed(i.Milestone,t),this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchQuestPointsTracks(e){if(!e)return;this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.Quest??={};let t=this.currentState.EventToken.Quest;for(let i of Object.values(e)){if(!i.CycleID)continue;let r=i.InstanceKey?`${i.CycleID}:${i.InstanceKey}`:i.CycleID,s=t[r]??={};s.Balance??={Current:0,TotalEarned:0,TotalSpent:0},s.Balance.Current=i.PointsCurrent??0,s.Balance.TotalEarned=i.PointsTotalEarned??0,s.Milestone??={};for(let a of i.ClaimedPointMilestoneIDs??[])this.markMilestoneClaimed(s.Milestone,a);}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchGroupCompletionClaimed(e,t){if(!e||!t)return;this.currentState??={},this.currentState.Quest??={},this.currentState.Quest.Cycles??={};let i=this.currentState.Quest.Cycles[e];i&&(i.ClaimedGroupCompletionIDs??=[],i.ClaimedGroupCompletionIDs.includes(t)||i.ClaimedGroupCompletionIDs.push(t),this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyTutorial(e){this.currentState??={},this.currentState.Tutorial=e??{},this.emitter.emit("user:tutorialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchTutorialFlow(e){if(!e?.FlowID)return;this.currentState??={},this.currentState.Tutorial??={};let t=this.currentState.Tutorial;t.Flows??={};let i=t.Flows[e.FlowID]??={FlowID:e.FlowID};i.Status=e.Status,i.CurrentStepID=e.CurrentStepID??null,i.RewardClaimed=e.RewardClaimed,e.VariantID!==void 0&&(i.VariantID=e.VariantID),this.emitter.emit("user:tutorialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchTutorialProgress(e){if(!e||e.length===0)return;this.currentState??={},this.currentState.Tutorial??={};let t=this.currentState.Tutorial;t.Flows??={};for(let i of e){if(!i.FlowID||!i.StepID)continue;let r=t.Flows[i.FlowID]??={FlowID:i.FlowID,Status:"InProgress"};r.Steps??={};let s=r.Steps[i.StepID]??={StepID:i.StepID};s.Progress=i.Progress,i.Completed&&(s.CompletedAtUtc??=new Date().toISOString(),r.CurrentStepID===i.StepID&&(r.CurrentStepID=null));}this.emitter.emit("user:tutorialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchQuestProgressUpdates(e){if(!e||e.length===0)return;this.currentState??={},this.currentState.Quest??={};let t=this.currentState.Quest;for(let i of e){if(!i.QuestID)continue;let r;if(!i.CycleID)t.PermanentQuests??={},r=t.PermanentQuests[i.QuestID]??={QuestID:i.QuestID,Status:i.Status};else {t.Cycles??={};let s=t.Cycles[i.CycleID];if(!s)continue;s.Quests??={},r=s.Quests[i.QuestID]??={QuestID:i.QuestID,Status:i.Status};}if(r.Status=i.Status,i.ObjectiveID){r.Objectives??={};let s=r.Objectives[i.ObjectiveID]??={ObjectiveID:i.ObjectiveID,CurrentValue:0,Completed:false};s.CurrentValue=i.NewValue??0,i.ObjectiveCompleted&&(s.Completed=true,s.CompletedAtUtc??=new Date().toISOString());}i.Status==="Completed"&&(r.CompletedAtUtc??=new Date().toISOString());}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}getQuestPointsProgress(e){if(!e)return null;let t=this.currentState?.EventToken?.Quest;if(!t)return null;for(let[i,r]of Object.entries(t))if(bs(i,e)&&r)return r;return null}applyActiveEvents(e){this.activeEventsCache=e??{},this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyUserLteState(e){e&&(this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.TimedEvent=e.Tokens??{},this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchTimedEventMilestoneClaimed(e,t,i){if(!(!t||!i)){this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.TimedEvent??={};for(let[r,s]of Object.entries(this.currentState.EventToken.TimedEvent))!bs(r,t)||!s||this.markMilestoneClaimed(s.Milestone??(s.Milestone={}),i);this.patchActiveEventMilestoneClaimed(e,t,i),this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}}patchActiveEventMilestoneClaimed(e,t,i){let r=this.activeEventsCache?.ActiveEvents;if(r)for(let s of r)s.Type!==e||s.TimedEventID!==t||(s.Progress??={},this.markMilestoneClaimed(s.Progress.Milestone??(s.Progress.Milestone={}),i));}markMilestoneClaimed(e,t){e.Claims??={};let i=e.Claims[t]??={};i.ClaimedAt??=new Date().toISOString(),i.Unlocked=false;}patchLeaderboardMyProgress(e,t){if(!e||!t)return;let i=this.ensureLeaderboardProgress(e);i.CurrentScore=t.CurrentScore??0,i.LastKnownRank=t.LastKnownRank??0,i.ScoreEarnedThisCycle=t.ScoreEarnedThisCycle??0,i.UnclaimedRewardCycleVersion=t.HasUnclaimedReward?Math.max(1,i.UnclaimedRewardCycleVersion??0):0,this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchLeaderboardScoreSubmitted(e,t,i,r){if(!e)return;let s=this.ensureLeaderboardProgress(e);(s.ScoreCycleVersion??0)<r&&(s.ScoreEarnedThisCycle=0,s.ClaimedMilestoneIDs=[],s.BracketID=null),s.CurrentScore=t,s.ScoreEarnedThisCycle=(s.ScoreEarnedThisCycle??0)+i,s.ScoreCycleVersion=r,s.LastScoreSubmitUtc=new Date().toISOString(),this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchLeaderboardCycleRewardClaimed(e){if(!e)return;let t=this.currentState?.Leaderboard?.ProgressByCycle?.[e];t&&(t.UnclaimedRewardCycleVersion=0,this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchLeaderboardMilestoneClaimed(e,t){if(!e||!t)return;let i=this.ensureLeaderboardProgress(e);i.ClaimedMilestoneIDs??=[],i.ClaimedMilestoneIDs.includes(t)||i.ClaimedMilestoneIDs.push(t),this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureLeaderboardProgress(e){this.currentState??={},this.currentState.Leaderboard??={},this.currentState.Leaderboard.ProgressByCycle??={};let t=this.currentState.Leaderboard.ProgressByCycle,i=t[e];return i||(i={CurrentScore:0,ScoreEarnedThisCycle:0,ScoreCycleVersion:0,UnclaimedRewardCycleVersion:0,LastKnownRank:0},t[e]=i),i}applySeasonsState(e){this.currentState??={},this.currentState.Season=e??{},this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSeasonState(e,t){!e||!t||(this.currentState??={},this.currentState.Season??={},this.currentState.Season.States??={},this.currentState.Season.States[e]=t,this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchSeasonCurrentTier(e,t){if(!e)return;let i=this.ensureSeasonState(e);i.CurrentTier=t,this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSeasonClaimedTier(e,t){if(!e)return;let i=this.ensureSeasonState(e);i.ClaimedTierRewards??=[],i.ClaimedTierRewards.includes(t)||i.ClaimedTierRewards.push(t),this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureSeasonState(e){this.currentState??={},this.currentState.Season??={},this.currentState.Season.States??={};let t=this.currentState.Season.States,i=t[e];return i||(i={SeasonChainID:e},t[e]=i),i}applyPremium(e){this.currentState??={},this.currentState.Premium=e??{},this.emitter.emit("user:premiumUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCharacter(e){this.currentState??={},this.currentState.Character??={},this.currentState.Character.Characters=e??{},this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCharacter(e,t){if(!e)return;this.currentState??={},this.currentState.Character??={},this.currentState.Character.Characters??={};let i=this.currentState.Character.Characters,r=i[e];r||(r={CharacterID:e},i[e]=r),t(r),this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCharacterEquipment(e,t,i){if(!e||!t)return;let r=this.currentState?.Character?.Characters?.[e];r&&(r.Equipment??={},i===null?delete r.Equipment[t]:r.Equipment[t]=i,this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyInventoryDelta(e){if(!e)return;this.currentState??={},this.currentState.InventoryV2??={},this.currentState.InventoryV2.UnstackableItems??={};let t=this.currentState.InventoryV2.UnstackableItems,i=false;for(let[r,s]of Object.entries(e.ChangedInstances??{}))t[r]=s,i=true;for(let r of e.RemovedInstanceIDs??[])r in t&&(delete t[r],i=true);i&&(this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyMatch(e){this.currentState??={},this.currentState.Match=e??{},this.emitter.emit("user:matchUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchMatchStrategy(e){e&&(this.currentState??={},this.currentState.Match??={},this.currentState.Match.PvPBattleStrategy=e,this.emitter.emit("user:matchUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyCollection(e){this.currentState??={},this.currentState.Collection=e??{},this.emitter.emit("user:collectionUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCoopEvent(e){this.currentState??={},this.currentState.CoopEvent=e??{MyObjectIndex:-1},this.emitter.emit("user:coopEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCoopEventActiveGroup(e,t,i){this.currentState??={};let r=this.currentState.CoopEvent??={MyObjectIndex:-1};r.ActiveGroupID=e,r.ActiveCoopEventID=t,r.MyObjectIndex=i,this.emitter.emit("user:coopEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyDealOffer(e){this.currentState??={},this.currentState.DealOffer=e??{},this.emitter.emit("user:dealOfferUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyReferral(e){this.currentState??={},this.currentState.Referral=e??{},this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchReferralSubscription(e){e&&(this.currentState??={},this.currentState.Referral??={},this.currentState.Referral.SubscribedToUserID=e,this.currentState.Referral.PendingActivationReward=false,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);}applySocialOutgoingRequests(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.OutgoingRequests=(e??[]).map(t=>t.UserID),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applySocialTimeline(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.Timeline=e??[],this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialAddOutgoingRequest(e){if(!e)return;let t=this.ensureSocial();t.OutgoingRequests??=[],t.OutgoingRequests.includes(e)||t.OutgoingRequests.push(e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialAcceptFriend(e){if(!e)return;let t=this.ensureSocial();t.IncomingRequests=(t.IncomingRequests??[]).filter(i=>i!==e),t.Accepted??=[],t.Accepted.includes(e)||t.Accepted.push(e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialRemoveIncomingRequest(e){if(!e)return;let t=this.ensureSocial();t.IncomingRequests=(t.IncomingRequests??[]).filter(i=>i!==e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialRemoveFriend(e){if(!e)return;let t=this.ensureSocial();t.Accepted=(t.Accepted??[]).filter(i=>i!==e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureSocial(){return this.currentState??={},this.currentState.Social??={},this.currentState.Social}applyTimedBoost(e){this.currentState??={},this.currentState.TimedBoost=e??{},this.emitter.emit("user:timedBoostUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchActiveTimedBoost(e,t){this.currentState??={},this.currentState.TimedBoost??={},this.currentState.TimedBoost.Active??={};let i=this.currentState.TimedBoost.Active;if(t==="Replace"||t==="KeepBest")for(let r of Object.keys(i)){let s=i[r];s&&s.BoostID===e.BoostID&&r!==e.InstanceID&&delete i[r];}i[e.InstanceID]=e,this.emitter.emit("user:timedBoostUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyUserCustomData(e){this.currentState??={},this.currentState.CustomData??={};let t=this.currentState.CustomData;t.Version=e.Version??0,t.Private=e.Private??{},t.Public=e.Public??{},t.ReadOnly=e.ReadOnly??{},this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchUserCustomDataKey(e,t,i,r,s){if(!t)return;this.currentState??={},this.currentState.CustomData??={};let a=this.currentState.CustomData,p={Value:i,UpdatedAt:new Date().toISOString(),Version:r,LastWriter:"Client",ExpiresAt:s??null};if(e==="Private")a.Private??={},a.Private[t]=p;else if(e==="Public")a.Public??={},a.Public[t]=p;else return;a.Version=(a.Version??0)+1,this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}removeUserCustomDataKey(e,t){if(!t||!this.currentState?.CustomData)return;let i=this.currentState.CustomData;if(e==="Private")i.Private&&delete i.Private[t];else if(e==="Public")i.Public&&delete i.Public[t];else return;this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyBoardState(e){this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.Board=e??{},this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCommunityChestUserState(e){this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.CommunityChest=e??{},this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardState(e){let t=this.ensureBoard();e(t),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardBuilding(e,t){if(e<0)return;let i=this.ensureBoard();i.BuildingStates??=[];let r=i.BuildingStates.find(s=>s.SlotIndex===e);r||(r={SlotIndex:e},i.BuildingStates.push(r)),t(r),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardPendingRaidLayout(e,t){let r=this.ensureBoard().Pending;r&&(e&&(r.RaidLayout=e),t>=0&&(r.OpenedIndices??=[],r.OpenedIndices.includes(t)||r.OpenedIndices.push(t)),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchBoardSpecialPending(e){let i=this.ensureBoard().Pending;!i||i.Type.toUpperCase()!=="SPECIAL"||(i.Special??={},e(i.Special),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}clearBoardPending(){let e=this.currentState?.GameLoop?.Board;!e||!e.Pending||(e.Pending=null,this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}ensureBoard(){return this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.Board??={},this.currentState.GameLoop.Board}applyBlockchainState(e,t){this.currentState??={},this.currentState.Blockchain=e??{},t&&(this.currentState.InventoryV2??={},this.currentState.InventoryV2.CryptoCurrencies=t),this.emitter.emit("user:blockchainUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyMarketplaceState(e){this.currentState??={},this.currentState.Marketplace=e??{},this.emitter.emit("user:marketplaceUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}getVirtualCurrencyAmount(e){return this.currentState?.InventoryV2?.VirtualCurrencies?.[e]?.Amount??0}getCryptoCurrencyAmount(e){return this.currentState?.InventoryV2?.CryptoCurrencies?.[e]?.Amount??"0"}};var di=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 hi=class{user;config;constructor(e){this.user=new pi(e),this.config=new di;}reset(){this.user.clear(),this.config.applyTitlePublicConfiguration(null);}};var mi=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 sp(e)?e:Re.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 sp(o){return o!==null&&Object.values(Re).includes(o)}var np=8,op=100,ap=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i,go=["GameLoop"],fi=class{constructor(e){this.ctx=e;}ctx;authContext=null;refreshing=false;rememberSession=true;sessionAuthType=Re.None;sessionEmail="";sessionPassword="";pendingRegistration=null;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(),Attribution:this.ctx.acquisition.buildForLogin(this.ctx.settings.appVersion)}}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(Re.Device)):t}async loginWithTelegram(){this.ctx.emitter.emit("auth:requestSent",void 0);let e=this.ctx.platform.getTelegramInitDataRaw();if(!e)return n("client","Telegram initData is not available.");let t=this.baseRequest();t.TelegramInitData=e;let i=await this.ctx.api.authentication.loginWithTelegram(t);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(Re.Telegram)):i}async loginWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();i.Email=e,i.Password=t;let r=await this.ctx.api.authentication.loginWithEmail(i);if(!r.ok)return r;this.applyAuthContext(r.data);let s=await this.fetchAndApplyClientState(Re.Email);return s.ok&&this.keepEmailCredentials(e,t),s}async registerWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();i.Email=e,i.Password=t,i.DeviceID=this.ctx.platform.getDeviceID(),i.Device=this.ctx.platform.getDeviceModel(),i.Platform=this.ctx.platform.getPlatform();let r=await this.ctx.api.authentication.registerWithEmail(i);return r.ok?(this.pendingRegistration={email:e,password:t},Vt({codeTtlMinutes:r.data.CodeTtlMinutes??0,resendCooldownSeconds:r.data.ResendCooldownSeconds??0})):r}async confirmEmailRegistration(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();i.Email=e,i.VerificationCode=t;let r=await this.ctx.api.authentication.confirmEmailRegistration(i);if(!r.ok)return r;this.applyAuthContext(r.data);let s=await this.fetchAndApplyClientState(Re.Email);return s.ok&&this.pendingRegistration?.email===e&&this.keepEmailCredentials(e,this.pendingRegistration.password),this.pendingRegistration=null,s}async resendVerificationCode(e){let t=this.baseRequest();t.Email=e;let i=await this.ctx.api.authentication.resendVerificationCode(t);return i.ok?Vt(void 0):i}async loginWithGoogle(e){this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.GoogleIDToken=e;let i=await this.ctx.api.authentication.loginWithGoogle(t);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(Re.Google)):i}async requestWalletChallenge(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();return i.WalletAddress=e,i.NetworkID=t,this.ctx.api.authentication.requestWalletChallenge(i)}async loginWithWallet(e,t,i){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();r.WalletAddress=e,r.NetworkID=t,r.WalletSignature=i,r.Platform=this.ctx.platform.getPlatform(),r.Device=this.ctx.platform.getDeviceModel(),r.DeviceID=this.ctx.platform.getDeviceID();let s=await this.ctx.api.authentication.loginWithWallet(r);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(Re.Wallet)):s}async loginWithSsoCode(e){if(!e)return n("client","SSO code is null or empty.");this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.SsoCode=e,t.DeviceID=this.ctx.platform.getDeviceID(),t.Device=this.ctx.platform.getDeviceModel(),t.Platform=this.ctx.platform.getPlatform();let i=await this.ctx.api.authentication.loginWithSsoCode(t);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(Re.iDosGames)):i}async forgotPassword(e){this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();return t.Email=e,this.ctx.api.authentication.forgotPassword(t)}async resetPassword(e,t,i){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();return r.Email=e,r.ResetToken=t,r.Password=i,this.ctx.api.authentication.resetPassword(r)}autoLogin(){return this.replay(this.ctx.authStore.lastAuthType,this.ctx.authStore.savedEmail,this.ctx.authStore.savedPassword)}replay(e,t,i){switch(e){case Re.Email:return this.loginWithEmail(t,i);case Re.Device:case Re.None:return this.loginWithDeviceID();case Re.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!==Re.None?this.sessionAuthType:this.ctx.authStore.lastAuthType;if(e===Re.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&&ap.test(e)}static isValidPasswordLength(e){return e.length>=np&&e.length<=op}keepEmailCredentials(e,t){this.sessionEmail=e,this.sessionPassword=t,this.rememberSession&&this.ctx.authStore.saveEmailAndPassword(e,t);}forgetSession(){this.sessionAuthType=Re.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(go,go);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 lp="idos:cfg",wt=class{constructor(e,t){this.storage=e;this.titleId=t;}storage;titleId;static scopeOf(e,t){return t&&t.length>0?`x:${Ro(t)}`:e&&e.length>0?`f:${Ro(e)}`:t?"x:":"f:"}async read(e){try{let t=await this.storage.get(this.keyOf(e));if(!t)return null;let i=JSON.parse(t);return !i||typeof i!="object"||typeof i.v!="string"||!i.c?null:i}catch{return null}}async write(e,t,i){try{let r={v:t,c:i};await this.storage.set(this.keyOf(e),JSON.stringify(r));}catch{}}async clear(e){try{await this.storage.remove(this.keyOf(e));}catch{}}keyOf(e){return `${lp}:${this.titleId}:${e}`}};function Ro(o){return [...o].map(e=>e.toLowerCase()).sort().join(",")}var yo="idos:loc",At=class{constructor(e,t){this.storage=e;this.titleId=t;}storage;titleId;async read(e){try{let t=await this.storage.get(this.keyOf(e));if(!t)return null;let i=JSON.parse(t);return !i||typeof i!="object"||typeof i.v!="number"||!i.t||typeof i.t!="object"?null:i}catch{return null}}async write(e,t,i){try{let r={v:t,t:i};await this.storage.set(this.keyOf(e),JSON.stringify(r)),await this.noteVersion(e,t);}catch{}}async readVersions(){try{let e=await this.storage.get(this.versionsKey());if(!e)return {};let t=JSON.parse(e);if(!t||typeof t!="object")return {};let i={};for(let[r,s]of Object.entries(t))typeof s=="number"&&s>0&&(i[r]=s);return i}catch{return {}}}async noteVersion(e,t){let i=await this.readVersions();i[e]!==t&&(i[e]=t,await this.storage.set(this.versionsKey(),JSON.stringify(i)));}keyOf(e){return `${yo}:${this.titleId}:${e}`}versionsKey(){return `${yo}:${this.titleId}:versions`}};var up="idos:state",gi=class{constructor(e,t){this.storage=e;this.titleId=t;}storage;titleId;async read(e){if(!e)return null;try{let t=await this.storage.get(this.keyOf(e));if(!t)return null;let i=JSON.parse(t);return !i||typeof i!="object"||typeof i.e!="string"||!i.v||!i.s?null:i}catch{return null}}async write(e,t,i,r){if(!(!e||!t))try{let s={e:t,v:i,s:r};await this.storage.set(this.keyOf(e),JSON.stringify(s));}catch{}}keyOf(e){return `${up}:${this.titleId}:${e}`}};function cp(o,e){if(!o)return;let t=new Set((e??[]).map(r=>r.trim().toLowerCase()));if(t.size===0)return o;let i={};for(let[r,s]of Object.entries(o))t.has(r.toLowerCase())||(i[r]=s);return i}function vs(o,e,t,i){let r={...o??{}};if(!e||!t||!i)return r;for(let[s,a]of Object.entries(t))i[s]===a&&s in e&&(r[s]=e[s]);return r}function pp(o){return {...o??{}}}function zs(o){return typeof o.StateEpoch=="string"&&o.StateEpoch.length>0?o.StateEpoch:null}var Ri=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=cp(this.versions,e);return t&&Object.keys(t).length>0?t:void 0}noteMutation(e,t){if(!e||e!==this.epoch){e&&e!==this.epoch&&this.reset(e);return}for(let[i,r]of Object.entries(t)){let s=this.versions[i];s!==void 0&&r===s+1?this.versions[i]=r:delete this.versions[i],this.dirty=true;}}afterFullRead(e,t){e!==this.epoch&&this.reset(e),this.versions=pp(t),this.dirty=true;}afterSliceRead(e,t){e!==this.epoch&&this.reset(e);for(let[i,r]of Object.entries(t??{}))this.versions[i]=r;this.dirty=true;}async flush(e,t){!this.dirty||!this.epoch||!e||(this.state=t??{},this.dirty=false,await this.cache.write(e,this.epoch,this.versions,this.state));}reset(e){this.epoch=e,this.versions={},this.state=null,this.dirty=true;}};var Co=n("server","Title configuration is unavailable (CDN and API both failed)."),yi=class{constructor(e){this.ctx=e;}ctx;baseRequest(){let e=this.ctx.auth.context;return e?{UserID:e.userID,ClientSessionTicket:e.clientSessionTicket,BuildKey:this.ctx.settings.buildKey,WebAppLink:this.ctx.platform.getFullURL(),RelatedEntityID:P()}:null}get configCache(){return this.cache??=new wt(this.ctx.settings.configStorage,this.ctx.settings.titleID)}cache;get localizationCache(){return this.locCache??=new At(this.ctx.settings.configStorage,this.ctx.settings.titleID)}locCache;get stateStore(){return this.versionStore??=new Ri(new gi(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=wt.scopeOf(e.TitleFields,null),i=await this.configCache.read(t);i&&(e.KnownTitleConfigVersion=i.v),await this.prepareLocalization(e);let r=await this.prepareStateHandshake(e,null),s=await this.ctx.api.user.getClientState(e);if(!s.ok)return s;let a=await this.resolveTitleConfig(s.data,t,i,{Fields:e.TitleFields});return a==null?Co:(this.finishStateHandshake(s.data,r),await this.applyClientState(s.data,a,void 0,void 0),await this.applyLocalization(s.data.Localization),await this.flushState(r),s)}async prepareStateHandshake(e,t){let i=this.ctx.auth.context?.userID;if(!i)return {userId:null,cached:null,sent:void 0};await this.stateStore.load(i),await this.stateStore.flush(i,this.ctx.data.user.state);let r=this.stateStore.versionsFor(t);if(r){e.KnownStateVersions=r;let s=this.stateStore.currentEpoch;s&&(e.KnownStateEpoch=s);}return {userId:i,cached:this.stateStore.cachedState,sent:r}}finishStateHandshake(e,t){let i=vs(e.User,t.cached,t.sent,e.StateVersions);e.User=i;let r=zs(e);!r||!t.userId||this.stateStore.afterFullRead(r,e.StateVersions);}async resolveTitleConfig(e,t,i,r){let s=e.TitleConfigVersion;if(i&&s&&i.v===s)return i.c;if(e.TitleConfigUrl){let p=await this.fetchConfigFromCdn(e.TitleConfigUrl);if(p!=null)return s&&await this.configCache.write(t,s,p),p}let a=await this.fetchConfigFromApi(r);return a!=null?(s&&await this.configCache.write(t,s,a),a):i?.c??null}async fetchConfigFromCdn(e){try{let t=await this.ctx.fetchImpl(e);if(!t.ok)return null;let i=await t.json();return i&&typeof i=="object"?i:null}catch{return null}}async fetchConfigFromApi(e){let t=this.baseRequest();if(!t)return null;let i={...t,...e},r=e.ExcludeFields?await this.ctx.api.title.getTitlePublicConfigurationExcept(i):await this.ctx.api.title.getTitlePublicConfiguration(i);return r.ok?r.data:null}async getClientStateExcept(e,t){let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.ExcludeFields=e,i.ExcludeTitleFields=t;let r=wt.scopeOf(null,t??[]),s=await this.configCache.read(r);s&&(i.KnownTitleConfigVersion=s.v),await this.prepareLocalization(i);let a=await this.prepareStateHandshake(i,e??null),p=await this.ctx.api.user.getClientStateExcept(i);if(!p.ok)return p;let x=await this.resolveTitleConfig(p.data,r,s,{ExcludeFields:t??[]});return x==null?Co:(this.finishStateHandshake(p.data,a),await this.applyClientState(p.data,x,e,t),await this.applyLocalization(p.data.Localization),await this.flushState(a),p)}async prepareLocalization(e){let t=this.ctx.localization.locale??this.ctx.settings.locale;t&&(e.Locale=t);let i=await this.localizationCache.readVersions();Object.keys(i).length>0&&(e.KnownLocalizationVersions=i);}async applyLocalization(e){if(!e){this.ctx.localization.applyState(null,{table:null,fallbackTable:null});return}let t=await this.resolveLocalizationTable({Locale:e.Locale,Version:e.Version,Url:e.Url}),i=e.Fallback?await this.resolveLocalizationTable(e.Fallback):null;this.ctx.localization.applyState(e,{table:t,fallbackTable:i});}async resolveLocalizationTable(e){let t=e.Locale??null,i=e.Version??0;if(!t)return null;let r=await this.localizationCache.read(t);if(i<=0)return r?.t??null;if(r&&r.v===i)return r.t;if(e.Url){let a=await this.fetchLocalizationFromCdn(e.Url);if(a!=null)return await this.localizationCache.write(t,i,a),a}let s=await this.fetchLocalizationFromApi(t,r?.v??0);return s??r?.t??null}async fetchLocalizationFromCdn(e){try{let t=await this.ctx.fetchImpl(e);if(!t.ok)return null;let i=await t.json();return i&&typeof i=="object"?i:null}catch{return null}}async fetchLocalizationFromApi(e,t){let i=this.baseRequest();if(!i)return null;let r=await this.ctx.api.localization.getLocalizationTable({...i,Locale:e,KnownVersion:t});if(!r.ok)return null;let s=r.data;if(s.NotModified)return null;let a=s.Entries??{},p=s.Version??0,x=s.Locale??e;return p>0&&await this.localizationCache.write(x,p,a),a}async getStateVersions(e){let t=this.baseRequest();return t?(e&&e.length>0&&(t.Fields=e),this.ctx.api.user.getStateVersions(t)):n("unauthorized","Not logged in.")}async getUserState(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&e.length>0&&(t.Fields=e);let i=await this.prepareStateHandshake(t,null),r=await this.ctx.api.user.getUserState(t);if(!r.ok)return r;let s=vs(r.data.User,i.cached,i.sent,r.data.StateVersions);r.data.User=s;let a=Object.keys(r.data.StateVersions??{});this.ctx.data.user.applyUserStateContainers(s,a);let p=zs(r.data);return p&&(this.stateStore.afterSliceRead(p,r.data.StateVersions),await this.flushState(i)),r}async flushState(e){e.userId&&await this.stateStore.flush(e.userId,this.ctx.data.user.state);}async getUserInventory(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getInventory(e);return t.ok&&(this.ctx.data.user.applyInventory(t.data),this.ctx.emitter.emit("user:inventoryReceived",t.data)),t}async getEventTokens(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getEventTokens(e);return t.ok&&this.ctx.emitter.emit("user:eventTokensReceived",t.data),t}async getUsageTime(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getUsageTime(e);return t.ok&&this.ctx.emitter.emit("user:usageTimeReceived",t.data),t}async addUsageTime(e,t,i){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.UsageTime=e,r.IsNewSession=t,r.SessionDurationSeconds=i;let s=await this.ctx.api.user.addUsageTime(r);return s.ok&&this.ctx.emitter.emit("user:usageTimeAdded",s.data),s}async deleteUserAccount(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.deleteUserAccount(e);return t.ok&&this.ctx.emitter.emit("user:accountDeleted",t.data),t}async changeUsername(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Username=e;let i=await this.ctx.api.user.changeUsername(t);return i.ok&&this.ctx.emitter.emit("user:usernameChanged",i.data),i}async applyClientState(e,t,i,r){let s=i?.includes("GameLoop")===true,a=r?.includes("GameLoop")===true,p=s?this.ctx.data.user.state?.GameLoop:void 0,x=a?this.ctx.data.config.titlePublicConfiguration?.GameLoop:void 0;this.ctx.data.config.applyTitlePublicConfiguration(t),this.ctx.data.user.applyUserState(e.User??{});let M=this.ctx.data.user.state;s&&M&&M.GameLoop==null&&(M.GameLoop=p);let q=this.ctx.data.config.titlePublicConfiguration;a&&q&&q.GameLoop==null&&(q.GameLoop=x),this.ctx.emitter.emit("user:clientStateReceived",e);}};var Si=class{constructor(e){this.ctx=e;}ctx;async convert(e,t,i,r,s,a){if(!t)return n("client","SourceID is required.");if(!r)return n("client","TargetID is required.");if(s<=0)return n("client","Amount must be positive.");if(e===i&&t===r)return n("client","Source and target must differ.");if(e===_e.Crypto||i===_e.Crypto)return n("client","Convert supports VC\u2194VC only. Use cryptoConvert for crypto.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let p={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:i,TargetID:r,SourceAmount:String(Math.trunc(s)),TransactionID:a&&a.length>0?a:`convert_${e}_${t}_to_${i}_${r}_${P()}`},x=await this.ctx.api.currency.convert(p);if(x.ok){let M=x.data,q={Consume:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:M.SourceID,Amount:M.SourceSpent}]}},Grant:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:M.TargetID,Amount:M.TargetCredited}]}}};this.ctx.data.user.applyResourceOperation(q,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("currency:converted",M);}return x}async cryptoConvert(e,t,i,r,s,a){let p=s instanceof ci__default.default?s:new ci__default.default(s);if(!t)return n("client","SourceID is required.");if(!r)return n("client","TargetID is required.");if(p.lte(0))return n("client","SourceAmount must be a positive decimal.");if(e===i&&t===r)return n("client","Source and target must differ.");if(e===_e.Virtual&&i===_e.Virtual)return n("client","cryptoConvert requires at least one crypto side. Use convert for VC\u2194VC.");if(e===_e.Virtual&&!p.isInteger())return n("client","Virtual currency source amount must be integer.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let x={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:i,TargetID:r,SourceAmount:p.toString(),TransactionID:a&&a.length>0?a:`crypto_convert_${e}_${t}_to_${i}_${r}_${P()}`},M=await this.ctx.api.currency.cryptoConvert(x);if(M.ok){let q=M.data,me=[],ye=[];if(q.SourceType===_e.Virtual&&me.push({Type:"VirtualCurrency",CurrencyID:q.SourceID,Amount:Math.trunc(Number(q.SourceSpent))}),q.TargetType===_e.Virtual&&ye.push({Type:"VirtualCurrency",CurrencyID:q.TargetID,Amount:Math.trunc(Number(q.TargetCredited))}),me.length>0||ye.length>0){let ke={Consume:me.length>0?{Standard:{Entries:me}}:null,Grant:ye.length>0?{Standard:{Entries:ye}}:null};this.ctx.data.user.applyResourceOperation(ke,this.ctx.data.config.itemDefinitions);}q.SourceType===_e.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(q.SourceID,new ci__default.default(q.SourceSpent).negated(),q.ServerTimeUtc),q.TargetType===_e.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(q.TargetID,new ci__default.default(q.TargetCredited),q.ServerTimeUtc),this.ctx.emitter.emit("currency:cryptoConverted",q);}return M}};var xi=class{constructor(e){this.ctx=e;}ctx;async upgradeLevel(e,t,i){let r=e.trim();if(!r)return n("client","ItemInstanceID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),ItemInstanceID:r,SelectedOptionID:i,RelatedEntityID:`upgrade_item_${r}_${P()}`};t&&t.length>0&&(s.FodderInstanceIDs=[...t]);let a=await this.ctx.api.item.upgradeLevel(s);return a.ok&&(await this.ctx.userService.getUserInventory(),this.ctx.emitter.emit("item:levelUpgraded",a.data)),a}async upgradeLevelsBatch(e){if(!e||e.length===0)return n("client","upgrades is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Upgrades:e},i=await this.ctx.api.item.upgradeLevelsBatch(t);return i.ok&&(await this.ctx.userService.getUserInventory(),this.ctx.emitter.emit("item:levelsUpgradedBatch",i.data)),i}};var dp="Store",bi=class{constructor(e){this.ctx=e;}ctx;async purchase(e,t=1,i){if(!e)return n("client","OfferID is required.");if(t<1)return n("client","Count must be at least 1.");let r=this.ctx.auth.context;if(!r)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),OfferID:e,Count:t,SelectedOptionID:i?.selectedOptionID,Payment:i?.payment,RelatedEntityID:`store_buy_${e}_${r.userID}_${P()}`},a=await this.ctx.api.store.purchase(s);if(a.ok){let p=a.data;this.ctx.data.user.patchStorePurchase(e,t,p.ServerTimeUtc),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("store:offerPurchased",p);}return a}async purchaseBatch(e){if(!e||e.length===0)return n("client","purchases is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Purchases:e},i=await this.ctx.api.store.purchaseBatch(t);if(i.ok){let r=false;for(let s of i.data)!s.Success||!s.Data||!s.Data.OfferID||(this.ctx.data.user.patchStorePurchase(s.Data.OfferID,s.Data.Count,s.Data.ServerTimeUtc),!r&&s.Data.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("store:offersPurchasedBatch",i.data);}return i}async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.store.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(dp,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 Di=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let e={...this.ctx.buildAuthedBaseRequest()};return this.ctx.api.purchase.getDefinitions(e)}async getUserState(){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let e={...this.ctx.buildAuthedBaseRequest()};return this.ctx.api.purchase.getUserState(e)}async validatePurchase(e,t,i){if(!t)return n("client","Receipt is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),Store:e,Receipt:t,Signature:i?.signature,ProductID:i?.productID,TransactionID:i?.transactionID},s=await this.ctx.api.purchase.validatePurchase(r);return s.ok&&s.data.Granted&&this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),s}async validatePurchasesBatch(e){if(!e||e.length===0)return n("client","receipts is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Receipts:e};return this.ctx.api.purchase.validatePurchasesBatch(t)}};var vi=class{constructor(e){this.ctx=e;}ctx;get platform(){return this.ctx.clientPlatform}availableOptions(e){return e?Object.entries(e).filter(([,t])=>t!=null).map(([t,i])=>({...i,OptionID:i.OptionID||t})).filter(t=>this.isAvailable(t)).sort((t,i)=>(t.OptionID??"").localeCompare(i.OptionID??"")):[]}isAvailable(e){if(!e)return false;let t=e.AllowedPlatforms;return !t||t.length===0?true:t.includes(this.platform)}requirementOf(e){let t=this.storeProductOf(e.Cost);return t?{option:e,kind:"store",productID:t}:{option:e,kind:"resources",shortfall:this.cryptoShortfallOf(e.Cost)??void 0}}storeProductOf(e){let t=e?.Standard?.Entries;if(!t)return null;for(let i of t)if(i?.Type===Xt.Purchase&&i.ProductID)return i.ProductID;return null}cryptoShortfallOf(e){let t=e?.Standard?.Entries;if(!t)return null;for(let i of t){if(i?.Type!==Xt.CryptoCurrency||!i.CurrencyID)continue;let r=Number(i.Amount??0);if(!(r>0))continue;let s=this.cryptoBalance(i.CurrencyID);return s>=r?null:{currencyID:i.CurrencyID,required:r,available:s,missing:r-s}}return null}cryptoBalance(e){let i=this.ctx.data.user.state?.InventoryV2?.CryptoCurrencies?.[e];return Number(i?.Amount??0)}};var hp="Lootbox",zi=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.lootbox.getDefinitions(e);if(t.ok){let i=t.data.LootboxDefinitions;i&&(this.ctx.data.config.patchSection(hp,i),this.ctx.emitter.emit("lootbox:definitionsLoaded",i));}return t}async open(e,t,i,r){if(!e)return n("client","LootboxID is required.");if(t<1)return n("client","Count must be at least 1.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),LootboxID:e,Count:t,SelectedOptionID:i,Payment:r,RelatedEntityID:`lootbox_${e}_${i??"default"}_${P()}`},a=await this.ctx.api.lootbox.open(s);if(a.ok){let p=a.data;p.TriggeredPity&&p.TriggeredPity.length>0&&this.ctx.data.user.applyLootboxPityTriggers(e,p.TriggeredPity,t),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.data.user.applyInventoryDelta(p.Inventory),this.ctx.emitter.emit("lootbox:opened",p);}return a}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var mp="Reward";function Ts(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var Ti=class{constructor(e){this.ctx=e;}ctx;multiplier=1;multiplierEnabled=false;get milestoneRewardMultiplier(){return this.multiplier}get milestoneRewardMultiplierEnabled(){return this.multiplierEnabled}async getRewardDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.reward.getRewardDefinitions(e);if(t.ok){let i=t.data.RewardDefinitions;i&&(this.ctx.data.config.patchSection(mp,i),this.ctx.emitter.emit("reward:definitionsLoaded",i));}return t}async getUserRewardsState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.reward.getUserRewardsState(e);return t.ok&&t.data.Rewards&&(this.ctx.data.user.applyReward(t.data.Rewards),this.ctx.emitter.emit("reward:userStateLoaded",t.data.Rewards)),t}async getMilestoneRewardMultiplier(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.reward.getMilestoneRewardMultiplier(e);if(t.ok){let i=t.data;this.multiplierEnabled=i.Enabled,this.multiplier=i.Enabled?i.Multiplier??1:1,this.ctx.emitter.emit("reward:milestoneMultiplierLoaded",i);}return t}async claimDailyReward(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CalendarID:e,RelatedEntityID:`dailyreward_${t.userID}_${e??"default"}_${P()}`},r=await this.ctx.api.reward.claimDailyReward(i);if(r.ok){let s=r.data;this.ctx.data.user.patchDailyCalendarState(s.CalendarID,s.DailyState),this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:dailyClaimed",s);}return r}async collectIdleAccrual(e){if(!Ts(e))return n("client",'AccrualID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),AccrualID:e,RelatedEntityID:`idle_collect_${e}_${P()}`},i=await this.ctx.api.reward.collectIdleAccrual(t);if(i.ok){let r=i.data;this.ctx.data.user.patchIdleAccrualState(r.AccrualID,r.IdleState),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:idleCollected",r);}return i}async claimComebackReward(e){if(!Ts(e))return n("client",'ComebackID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),ComebackID:e,RelatedEntityID:`comeback_claim_${e}_${P()}`},i=await this.ctx.api.reward.claimComebackReward(t);if(i.ok){let r=i.data;this.ctx.data.user.patchComebackState(r.ComebackID,r.ComebackState),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:comebackClaimed",r);}return i}async claimReward(e){if(!Ts(e))return n("client",'ClaimID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),ClaimID:e,RelatedEntityID:`reward_claim_${e}_${P()}`},i=await this.ctx.api.reward.claimReward(t);if(i.ok){let r=i.data;this.ctx.data.user.patchClaimRewardState(r.ClaimID,r.ClaimState),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:claimed",r);}return i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var fp="Tutorial",Pi=class{constructor(e){this.ctx=e;}ctx;async getTutorialDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.tutorial.getTutorialDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(fp,t.data),this.ctx.emitter.emit("tutorial:definitionsLoaded",t.data)),t}async getUserTutorialState(e=true){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.AutoStart=e;let i=await this.ctx.api.tutorial.getUserTutorialState(t);if(i.ok){let r=i.data.State??{};this.ctx.data.user.applyTutorial(r),this.ctx.emitter.emit("tutorial:userStateLoaded",i.data);}return i}async startFlow(e){return this.flowCall(e,t=>this.ctx.api.tutorial.startFlow(t),{event:"tutorial:flowStarted"})}async reportStepShown(e,t){return this.stepCall(e,t,i=>this.ctx.api.tutorial.reportStepShown(i))}async completeStep(e,t){return this.stepCall(e,t,i=>this.ctx.api.tutorial.completeStep(i),{relatedEntityID:`tutorial_step_${e}_${t}_${P()}`})}async completeStepsBatch(e,t){let i=e?.trim();if(!i)return n("client","FlowID is required.");if(!t||t.length===0)return n("client","stepIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),FlowID:i,StepIDs:t,RelatedEntityID:`tutorial_batch_${i}_${P()}`},s=await this.ctx.api.tutorial.completeStepsBatch(r);return s.ok&&(await this.refreshAfterMutation(),this.ctx.emitter.emit("tutorial:stepsCompletedBatch",s.data)),s}async skipStep(e,t){return this.stepCall(e,t,i=>this.ctx.api.tutorial.skipStep(i))}async skipFlow(e){return this.flowCall(e,t=>this.ctx.api.tutorial.skipFlow(t),{event:"tutorial:flowSkipped"})}async claimFlowReward(e){let t=e?.trim();if(!t)return n("client","FlowID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),FlowID:t,RelatedEntityID:`tutorial_claim_${t}_${P()}`},r=await this.ctx.api.tutorial.claimFlowReward(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Granted,this.ctx.data.config.itemDefinitions),await this.refreshAfterMutation(),this.ctx.emitter.emit("tutorial:rewardClaimed",r.data)),r}async resetFlow(e){return this.flowCall(e,t=>this.ctx.api.tutorial.resetFlow(t),{event:"tutorial:flowReset"})}async flowCall(e,t,i){let r=e?.trim();if(!r)return n("client","FlowID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),FlowID:r},a=await t(s);return a.ok&&(this.applyFlowView(a.data),this.ctx.emitter.emit(i.event,a.data)),a}async stepCall(e,t,i,r){let s=e?.trim(),a=t?.trim();if(!s)return n("client","FlowID is required.");if(!a)return n("client","StepID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let p={...this.ctx.buildAuthedBaseRequest(),FlowID:s,StepID:a};r?.relatedEntityID&&(p.RelatedEntityID=r.relatedEntityID);let x=await i(p);return x.ok&&(this.applyFlowView(x.data),this.ctx.emitter.emit("tutorial:stepChanged",x.data)),x}applyFlowView(e){e?.Flow&&this.ctx.data.user.patchTutorialFlow(e.Flow);}async refreshAfterMutation(){await this.getUserTutorialState(false).catch(()=>{});}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ii=Object.freeze({}),ki=class{constructor(e){this.ctx=e;}ctx;table={...Ii};fallbackTable=null;currentLocale=null;currentFallbackLocale=null;pluralRules=null;get cache(){return this.tableCache??=new At(this.ctx.settings.configStorage,this.ctx.settings.titleID)}tableCache;get locale(){return this.currentLocale}get fallbackLocale(){return this.currentFallbackLocale}get locales(){let e=this.ctx.data.config.titlePublicConfiguration?.Localization??null;return e?.Locales?Object.entries(e.Locales).filter(([,t])=>t?.IsEnabled!==false).map(([t,i])=>({Locale:i?.Locale??t,DisplayName:i?.DisplayName??null,Order:i?.Order??0})).sort((t,i)=>(t.Order??0)-(i.Order??0)):[]}has(e){return this.lookup(e)!==void 0}t(e,t){if(!e)return "";let i=this.resolveKey(e,t),r=this.lookup(i)??this.lookup(e);return r===void 0?this.onMissing(e):t?gp(r,t):r}applyState(e,t){if(!e){this.reset();return}let i=e.Locale??null;this.table=t.table??{...Ii},this.fallbackTable=t.fallbackTable,this.currentFallbackLocale=e.Fallback?.Locale??null,this.setLocaleInternal(i),this.ctx.emitter.emit("localization:changed",{locale:i,fallbackLocale:this.currentFallbackLocale,entryCount:Object.keys(this.table).length});}async setLocale(e){if(!this.baseRequest())return n("unauthorized","Not logged in.");let i=await this.loadTableFromApi(e);if(!i.ok)return i;let{locale:r,table:s,fallbackLocale:a}=i.data,p=null;if(a){let x=await this.loadTableFromApi(a);x.ok&&(p=x.data.table);}return this.table=s,this.fallbackTable=p,this.currentFallbackLocale=a,this.setLocaleInternal(r),this.ctx.emitter.emit("localization:changed",{locale:r,fallbackLocale:a,entryCount:Object.keys(s).length}),{ok:true,data:r}}async getManifest(){let e=this.baseRequest();return e?(e.Locale=this.currentLocale??this.ctx.settings.locale,this.ctx.api.localization.getLocalizationManifest(e)):n("unauthorized","Not logged in.")}reset(){this.table={...Ii},this.fallbackTable=null,this.currentFallbackLocale=null,this.setLocaleInternal(null);}setLocaleInternal(e){this.currentLocale=e,this.pluralRules=null;}baseRequest(){let e=this.ctx.auth.context;return e?{UserID:e.userID,ClientSessionTicket:e.clientSessionTicket,BuildKey:this.ctx.settings.buildKey,RelatedEntityID:P()}:null}async loadTableFromApi(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Locale=e;let i=await this.cache.read(So(e));i&&(t.KnownVersion=i.v);let r=await this.ctx.api.localization.getLocalizationTable(t);if(!r.ok)return r;let s=r.data,a=s.Locale??So(e),p=s.Version??0;if(s.NotModified){let M=i??await this.cache.read(a);return {ok:true,data:{locale:a,table:M?.t??{...Ii},fallbackLocale:s.FallbackLocale??null}}}let x=s.Entries??{};return p>0&&await this.cache.write(a,p,x),{ok:true,data:{locale:a,table:x,fallbackLocale:s.FallbackLocale??null}}}lookup(e){let t=this.table[e];return t!==void 0?t:this.fallbackTable?.[e]}resolveKey(e,t){let i=t?.count;if(typeof i!="number")return e;let r=this.pluralCategory(i),s=`${e}.${r}`;if(this.lookup(s)!==void 0)return s;let a=`${e}.other`;return this.lookup(a)!==void 0?a:e}pluralCategory(e){try{return this.pluralRules??=new Intl.PluralRules(this.currentLocale??void 0),this.pluralRules.select(e)}catch{return "other"}}onMissing(e){let t=this.ctx.data.config.titlePublicConfiguration?.Localization?.MissingKeyMode??"ReturnKey";return t==="ReturnEmpty"?"":t==="ReturnMarkedKey"?`\u27E6${e}\u27E7`:e}};function gp(o,e){return o.replace(/\{(\w+)\}/g,(t,i)=>{let r=e[i];return r===void 0?t:String(r)})}function So(o){return o.trim().replace(/_/g,"-").toLowerCase()}var Rp="Quest",Mi=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(Rp,t.data),this.ctx.emitter.emit("quest:definitionsLoaded",t.data)),t}async getUserQuestState(e=true){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.AutoRefreshCycles=e;let i=await this.ctx.api.quest.getUserQuestState(t);if(i.ok){let r=i.data.State??{};this.ctx.data.user.applyQuest(r),this.ctx.data.user.patchQuestPointsTracks(i.data.PointsTracks),this.ctx.emitter.emit("quest:userStateLoaded",r);}return i}async refreshQuestCycles(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.quest.refreshQuestCycles(e);return t.ok&&this.ctx.emitter.emit("quest:cyclesRefreshed",void 0),t}async claimQuestReward(e,t){let i=e.trim();if(!i)return n("client","QuestID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r=t&&t.trim().length>0?t.trim():void 0,s={...this.ctx.buildAuthedBaseRequest(),QuestID:i,CycleID:r,RelatedEntityID:`quest_claim_${r??""}_${i}_${P()}`},a=await this.ctx.api.quest.claimQuestReward(s);if(a.ok){let p=a.data;this.ctx.data.user.patchQuestStatus(p.QuestID,p.CycleID,"Claimed"),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:rewardClaimed",p);}return a}async claimQuestRewardsBatch(e){if(!e||e.length===0)return n("client","quests is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Quests:e},i=await this.ctx.api.quest.claimQuestRewardsBatch(t);if(i.ok){let r=false;for(let s of i.data)!s.Success||!s.Data||(this.ctx.data.user.patchQuestStatus(s.Data.QuestID,s.Data.CycleID,"Claimed"),!r&&s.Data.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("quest:rewardsClaimedBatch",i.data);}return i}async claimMilestoneReward(e,t){let i=e.trim(),r=t.trim();if(!i||!r)return n("client","CycleID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CycleID:i,MilestoneID:r,RelatedEntityID:`milestone_claim_${i}_${r}_${P()}`},a=await this.ctx.api.quest.claimMilestoneReward(s);if(a.ok){let p=a.data;this.ctx.data.user.patchMilestoneClaimed(p.CycleID,p.MilestoneID),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:milestoneClaimed",p);}return a}async claimMilestoneRewardsBatch(e){if(!e||e.length===0)return n("client","milestones is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Milestones:e},i=await this.ctx.api.quest.claimMilestoneRewardsBatch(t);if(i.ok){let r=false;for(let s of i.data)!s.Success||!s.Data||(this.ctx.data.user.patchMilestoneClaimed(s.Data.CycleID,s.Data.MilestoneID),!r&&s.Data.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("quest:milestonesClaimedBatch",i.data);}return i}async claimGroupCompletionReward(e,t){let i=e.trim(),r=t.trim();if(!i||!r)return n("client","CycleID and GroupCompletionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CycleID:i,GroupCompletionID:r,RelatedEntityID:`group_completion_${i}_${r}_${P()}`},a=await this.ctx.api.quest.claimGroupCompletionReward(s);if(a.ok){let p=a.data;this.ctx.data.user.patchGroupCompletionClaimed(p.CycleID,p.GroupCompletionID),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:groupCompletionClaimed",p);}return a}async addQuestProgress(e,t){let i=e.trim();if(!i)return n("client","MetricID is required.");if(t<0)return n("client","ProgressValue must be >= 0.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),MetricID:i,ProgressValue:t},s=await this.ctx.api.quest.addQuestProgress(r);return s.ok&&(this.ctx.data.user.patchQuestProgressUpdates(s.data.Updates),this.ctx.emitter.emit("quest:progressAdded",s.data)),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var yp="TimedEvent",wi=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(yp,t.data),this.ctx.emitter.emit("timedEvent:definitionsLoaded",t.data)),t}async getUserLteState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedEvent.getUserLteState(e);return t.ok&&(this.ctx.data.user.applyUserLteState(t.data),this.ctx.emitter.emit("timedEvent:userStateLoaded",t.data)),t}async grantTokens(e,t,i,r,s,a,p=1){if(!t)return n("client","LteID is required.");if(!i)return n("client","SourceType is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let x={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,SourceType:i,Outcome:r,AmountOverride:s,SourceParams:a,RollMultiplier:p},M=await this.ctx.api.timedEvent.grantTokens(x);return M.ok&&(this.ctx.data.user.applyResourceOperation(M.data,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensGranted",M.data)),M}async spendTokens(e,t,i){if(!t)return n("client","LteID is required.");if(i<=0)return n("client","SpendAmount must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,SpendAmount:i},s=await this.ctx.api.timedEvent.spendTokens(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensSpent",s.data)),s}async claimMilestone(e,t,i){if(!t||!i)return n("client","LteID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,MilestoneID:i},s=await this.ctx.api.timedEvent.claimMilestone(r);if(s.ok){let a=s.data;this.ctx.data.user.applyResourceOperation(a.Rewards,this.ctx.data.config.itemDefinitions),this.ctx.data.user.patchTimedEventMilestoneClaimed(e,t,i),this.ctx.emitter.emit("timedEvent:milestoneClaimed",a);}return s}async claimMilestonesBatch(e){if(!e||e.length===0)return n("client","milestones is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Milestones:e},i=await this.ctx.api.timedEvent.claimMilestonesBatch(t);return i.ok&&(this.applyMilestoneClaimBatch(i.data),this.ctx.emitter.emit("timedEvent:milestonesClaimedBatch",i.data)),i}async claimAllMilestones(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&e.length>0&&(t.Events=e);let i=await this.ctx.api.timedEvent.claimAllMilestones(t);return i.ok&&(this.applyMilestoneClaimBatch(i.data),this.ctx.emitter.emit("timedEvent:allMilestonesClaimed",i.data)),i}async spendTokensBatch(e){if(!e||e.length===0)return n("client","spends is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Spends:e},i=await this.ctx.api.timedEvent.spendTokensBatch(t);if(i.ok){let r=false;for(let s of i.data)!r&&s.Success&&s.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("timedEvent:tokensSpentBatch",i.data);}return i}async grantTokensBatch(e){if(!e||e.length===0)return n("client","grants is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Grants:e},i=await this.ctx.api.timedEvent.grantTokensBatch(t);if(i.ok){let r=false;for(let s of i.data)!r&&s.Success&&s.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("timedEvent:tokensGrantedBatch",i.data);}return i}applyMilestoneClaimBatch(e){let t=false;for(let i of e){if(!i.Success||!i.Data)continue;let r=i.Data;r.Type&&r.LteID&&r.MilestoneID&&this.ctx.data.user.patchTimedEventMilestoneClaimed(r.Type,r.LteID,r.MilestoneID),!t&&r.Rewards&&(this.ctx.data.user.applyResourceOperation(r.Rewards,this.ctx.data.config.itemDefinitions),t=true);}}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Cp="Leaderboard",Ai=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(Cp,t.data),this.ctx.emitter.emit("leaderboard:definitionsLoaded",t.data)),t}async getLeaderboard(e){if(!e)return n("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardID=e;let i=await this.ctx.api.leaderboard.getLeaderboard(t);return i.ok&&this.ctx.emitter.emit("leaderboard:loaded",i.data),i}async getMyProgress(e){if(!e)return n("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardID=e;let i=await this.ctx.api.leaderboard.getMyProgress(t);return i.ok&&(this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(e),i.data),this.ctx.emitter.emit("leaderboard:myProgressLoaded",i.data)),i}async submitScore(e,t){if(!e)return n("client","LeaderboardID is required.");if(t<=0)return n("client","Score must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,Score:t},r=await this.ctx.api.leaderboard.submitScore(i);if(r.ok){let s=r.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),s.NewScore,t,s.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",s);}return r}async submitScoreFromSource(e,t,i,r,s=1){if(!e)return n("client","LeaderboardID is required.");if(!t)return n("client","SourceType is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,SourceType:t,Outcome:i,Params:r,RollMultiplier:s},p=await this.ctx.api.leaderboard.submitScoreFromSource(a);if(p.ok){let x=p.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),x.NewScore,x.NewScore,x.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",x);}return p}async claimCycleReward(e){if(!e)return n("client","LeaderboardID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e},i=await this.ctx.api.leaderboard.claimCycleReward(t);if(i.ok){let r=i.data;this.ctx.data.user.patchLeaderboardCycleRewardClaimed(this.cycleDocID(e)),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("leaderboard:cycleRewardClaimed",r);}return i}async claimMilestone(e,t){if(!e||!t)return n("client","LeaderboardID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,MilestoneID:t},r=await this.ctx.api.leaderboard.claimMilestone(i);if(r.ok){let s=r.data;this.ctx.data.user.patchLeaderboardMilestoneClaimed(this.cycleDocID(e),t),this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("leaderboard:milestoneClaimed",s);}return r}async getFriendsLeaderboard(e){if(!e)return n("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardID=e;let i=await this.ctx.api.leaderboard.getFriendsLeaderboard(t);return i.ok&&this.ctx.emitter.emit("leaderboard:friendsLoaded",i.data),i}async getLeaderboardsBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardIDs=e;let i=await this.ctx.api.leaderboard.getLeaderboardsBatch(t);return i.ok&&this.ctx.emitter.emit("leaderboard:loadedBatch",i.data),i}async getProgressBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardIDs=e;let i=await this.ctx.api.leaderboard.getProgressBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(r.Data.LeaderboardID),r.Data);this.ctx.emitter.emit("leaderboard:myProgressLoadedBatch",i.data);}return i}async claimCycleRewardsBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardIDs:e},i=await this.ctx.api.leaderboard.claimCycleRewardsBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||(this.ctx.data.user.patchLeaderboardCycleRewardClaimed(this.cycleDocID(r.Data.LeaderboardID)),r.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.Data.Resources,this.ctx.data.config.itemDefinitions));this.ctx.emitter.emit("leaderboard:cycleRewardsClaimedBatch",i.data);}return i}async claimMilestonesBatch(e){if(!e||e.length===0)return n("client","milestones is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Milestones:e},i=await this.ctx.api.leaderboard.claimMilestonesBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||(this.ctx.data.user.patchLeaderboardMilestoneClaimed(this.cycleDocID(r.Data.LeaderboardID),r.Data.MilestoneID),r.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.Data.Resources,this.ctx.data.config.itemDefinitions));this.ctx.emitter.emit("leaderboard:milestonesClaimedBatch",i.data);}return i}async submitScoresBatch(e){if(!e||e.length===0)return n("client","scores is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Scores:e},i=await this.ctx.api.leaderboard.submitScoresBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(r.Data.LeaderboardID),r.Data.NewScore,r.Data.NewScore,r.Data.CycleVersion);this.ctx.emitter.emit("leaderboard:scoresSubmittedBatch",i.data);}return i}async claimAllRewardsBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardIDs:e},i=await this.ctx.api.leaderboard.claimAllRewardsBatch(t);if(i.ok){for(let r of i.data){let s=this.cycleDocID(r.LeaderboardID);r.CycleReward?.Success&&r.CycleReward.Data&&(this.ctx.data.user.patchLeaderboardCycleRewardClaimed(s),r.CycleReward.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.CycleReward.Data.Resources,this.ctx.data.config.itemDefinitions));for(let a of r.Milestones??[])!a.Success||!a.Data||(this.ctx.data.user.patchLeaderboardMilestoneClaimed(s,a.Data.MilestoneID),a.Data.Resources&&this.ctx.data.user.applyResourceOperation(a.Data.Resources,this.ctx.data.config.itemDefinitions));}this.ctx.emitter.emit("leaderboard:allRewardsClaimedBatch",i.data);}return i}async getOverviewBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardIDs=e;let i=await this.ctx.api.leaderboard.getOverviewBatch(t);if(i.ok){for(let r of i.data)r.Progress?.Success&&r.Progress.Data&&this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(r.LeaderboardID),r.Progress.Data);this.ctx.emitter.emit("leaderboard:overviewLoadedBatch",i.data);}return i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Sp="Season",Oi=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(Sp,t.data),this.ctx.emitter.emit("season:definitionsLoaded",t.data)),t}async getActiveSeason(e){if(!e)return n("client","SeasonChainID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.SeasonChainID=e;let i=await this.ctx.api.season.getActiveSeason(t);return i.ok&&(i.data.UserState&&this.ctx.data.user.patchSeasonState(e,i.data.UserState),this.ctx.emitter.emit("season:activeLoaded",i.data)),i}async getUserState(e){if(!e)return n("client","SeasonChainID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.SeasonChainID=e;let i=await this.ctx.api.season.getUserState(t);return i.ok&&(this.ctx.data.user.patchSeasonState(e,i.data),this.ctx.emitter.emit("season:userStateLoaded",i.data)),i}async grantStatusTokens(e,t){if(!e)return n("client","SeasonChainID is required.");if(t<=0)return n("client","Amount must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,Amount:t,RelatedEntityID:`season_grant_${e}_${P()}`},r=await this.ctx.api.season.grantStatusTokens(i);return r.ok&&(this.ctx.data.user.patchSeasonCurrentTier(e,r.data.NewTier),this.ctx.emitter.emit("season:statusTokensGranted",r.data)),r}async claimTierReward(e,t){if(!e)return n("client","SeasonChainID is required.");if(t<=0)return n("client","TierNumber must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,TierNumber:t,RelatedEntityID:`season_tier_${e}_t${t}_${P()}`},r=await this.ctx.api.season.claimTierReward(i);if(r.ok){let s=r.data;this.ctx.data.user.patchSeasonClaimedTier(e,t),this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("season:tierRewardClaimed",s);}return r}async claimTierRewardsBatch(e,t){if(!e)return n("client","SeasonChainID is required.");let i=(t??[]).filter(a=>a>0);if(i.length===0)return n("client","TierNumbers is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,TierNumbers:i,RelatedEntityID:`season_tier_batch_${e}_${P()}`},s=await this.ctx.api.season.claimTierRewardsBatch(r);if(s.ok){let a=s.data;for(let p of a.Items??[]){let x=p.Data?.TierNumber;p.Success&&typeof x=="number"&&this.ctx.data.user.patchSeasonClaimedTier(e,x);}this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("season:tierRewardsBatchClaimed",a);}return s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var xp="Premium",Ui=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(xp,t.data.Premium),this.ctx.emitter.emit("premium:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.premium.getUserState(e);return t.ok&&t.data.Premium&&(this.ctx.data.user.applyPremium(t.data.Premium),this.ctx.emitter.emit("premium:stateLoaded",t.data)),t}async activateTrial(e,t){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,RelatedEntityID:`premium_trial_${e}_${t}`},r=await this.ctx.api.premium.activateTrial(i);return r.ok&&(r.data.Premium&&this.ctx.data.user.applyPremium(r.data.Premium),this.ctx.emitter.emit("premium:trialActivated",r.data)),r}async purchaseItemOrCurrency(e,t,i="Default",r=1){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,SelectedOptionID:i,Count:r,RelatedEntityID:`premium_purchase_${e}_${t}`},a=await this.ctx.api.premium.purchaseItemOrCurrency(s);if(a.ok){let p=a.data;p.Premium&&this.ctx.data.user.applyPremium(p.Premium),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:purchaseCompleted",p);}return a}async purchaseRealMoney(e,t,i,r,s,a,p,x){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!r||!s)return n("client","ProductID and ReceiptData are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let M={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,Store:i,ProductID:r,ReceiptData:s,PurchaseToken:a,PackageName:p,AppStoreEnvironment:x,RelatedEntityID:`premium_iap_${e}_${t}`},q=await this.ctx.api.premium.purchaseRealMoney(M);if(q.ok){let me=q.data;me.Premium&&this.ctx.data.user.applyPremium(me.Premium),this.ctx.data.user.applyResourceOperation(me.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:realMoneyPurchaseCompleted",me);}return q}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var bp="Character",Bi=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(bp,t.data),this.ctx.emitter.emit("character:definitionsLoaded",t.data)),t}async getUserCharacters(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.character.getUserCharacters(e);if(t.ok){let i=t.data.Characters??{};this.ctx.data.user.applyCharacter(i),this.ctx.emitter.emit("character:userCharactersLoaded",i);}return t}async unlockCharacter(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,SelectedOptionID:t?.selectedOptionID,Payment:t?.payment,RelatedEntityID:`unlock_char_${e}_${P()}`},r=await this.ctx.api.character.unlockCharacter(i);if(r.ok){let s=r.data;this.ctx.data.user.patchCharacter(s.CharacterID,a=>{a.StatLevels??={},a.Equipment??={},s.Power!=null&&(a.Power=s.Power),a.UpdatedAt=s.ServerTimeUtc;}),this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:unlocked",s);}return r}async upgradeStatLevel(e,t,i){if(!e||!t)return n("client","CharacterID and StatID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,StatID:t,RelatedEntityID:`upgrade_stat_${e}_${t}_${P()}`,...i?.levels!=null?{Levels:i.levels}:{},...i?.targetLevel!=null?{TargetLevel:i.targetLevel}:{}},s=await this.ctx.api.character.upgradeStatLevel(r);if(s.ok){let a=s.data;this.ctx.data.user.patchCharacter(a.CharacterID,p=>{p.StatLevels??={},p.StatLevels[a.StatID]=a.StatLevel,a.Power!=null&&(p.Power=a.Power),p.UpdatedAt=a.ServerTimeUtc;}),this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:statLevelUpgraded",a);}return s}async upgradeCharacterLevel(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,RelatedEntityID:`upgrade_char_${e}_${P()}`,...t?.levels!=null?{Levels:t.levels}:{},...t?.targetLevel!=null?{TargetLevel:t.targetLevel}:{}},r=await this.ctx.api.character.upgradeCharacterLevel(i);if(r.ok){let s=r.data;this.ctx.data.user.patchCharacter(s.CharacterID,a=>{a.Level=s.NewLevel,s.Power!=null&&(a.Power=s.Power),a.UpdatedAt=s.ServerTimeUtc,s.NewLevel===1&&(a.StatLevels??={},a.Equipment??={});}),this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:levelUpgraded",s);}return r}async equipItems(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,ItemsToEquip:t},r=await this.ctx.api.character.equipItems(i);return r.ok&&(this.applyEquipChangesLocally(e,r.data),this.ctx.emitter.emit("character:itemsEquipped",r.data)),r}async unequipItems(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,UnequipSlotIDs:t},r=await this.ctx.api.character.unequipItems(i);if(r.ok){let s=r.data;this.applyUnequipChangesLocally(e,s),this.ctx.emitter.emit("character:itemsUnequipped",{characterID:e,slotIDs:s.ClearedSlotIDs??[],power:s.Power??null});}return r}async unequipAllCharacters(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.character.unequipAllCharacters(e);return t.ok&&(this.applyUnequipAllLocally(t.data),this.ctx.emitter.emit("character:allUnequipped",t.data)),t}async unlockCharactersBatch(e){if(!e||e.length===0)return n("client","characterIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),UnlockCharacterIDs:e},i=await this.ctx.api.character.unlockCharactersBatch(t);return i.ok&&(this.applyBatchResults(i.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,s=>{s.StatLevels??={},s.Equipment??={},r.Power!=null&&(s.Power=r.Power),s.UpdatedAt=r.ServerTimeUtc;});}),this.ctx.emitter.emit("character:charactersUnlocked",i.data)),i}async upgradeCharacterLevelsBatch(e){if(!e||e.length===0)return n("client","upgrades is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LevelUpgrades:e},i=await this.ctx.api.character.upgradeCharacterLevelsBatch(t);return i.ok&&(this.applyBatchResults(i.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,s=>{s.Level=r.NewLevel,r.Power!=null&&(s.Power=r.Power),s.UpdatedAt=r.ServerTimeUtc,r.NewLevel===1&&(s.StatLevels??={},s.Equipment??={});});}),this.ctx.emitter.emit("character:levelsUpgraded",i.data)),i}async upgradeStatLevelsBatch(e){if(!e||e.length===0)return n("client","upgrades is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),StatUpgrades:e},i=await this.ctx.api.character.upgradeStatLevelsBatch(t);return i.ok&&(this.applyBatchResults(i.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,s=>{s.StatLevels??={},s.StatLevels[r.StatID]=r.StatLevel,r.Power!=null&&(s.Power=r.Power),s.UpdatedAt=r.ServerTimeUtc;});}),this.ctx.emitter.emit("character:statLevelsUpgraded",i.data)),i}applyBatchResults(e,t){e.Resources&&this.ctx.data.user.applyResourceOperation(e.Resources,this.ctx.data.config.itemDefinitions);for(let i of e.Items??[])!i.Success||!i.Data||t(i.Data);}applyInventoryDelta(e){this.ctx.data.user.applyInventoryDelta(e);}applyEquipChangesLocally(e,t){let i=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let[r,s]of Object.entries(t.Equipment??{}))i.patchCharacterEquipment(e,r,s);i.patchCharacter(e,r=>{t.Power!=null&&(r.Power=t.Power),r.UpdatedAt=t.ServerTimeUtc;});}applyUnequipChangesLocally(e,t){let i=t.ClearedSlotIDs??[];if(i.length===0&&t.Power==null)return;let r=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let s of i)r.patchCharacterEquipment(e,s,null);r.patchCharacter(e,s=>{t.Power!=null&&(s.Power=t.Power),s.UpdatedAt=t.ServerTimeUtc;});}applyUnequipAllLocally(e){let t=this.ctx.data.user;this.applyInventoryDelta(e.Inventory);for(let[i,r]of Object.entries(e.Characters??{})){for(let s of r.ClearedSlotIDs??[])t.patchCharacterEquipment(i,s,null);t.patchCharacter(i,s=>{r.Power!=null&&(s.Power=r.Power),s.UpdatedAt=e.ServerTimeUtc;});}}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Dp="Match",Li=class{constructor(e){this.ctx=e;}ctx;async createMatch(e,t,i,r,s,a){let p=this.ctx.auth.context;if(!p)return n("unauthorized","Not logged in.");let x={...this.ctx.buildAuthedBaseRequest(),Entry:e,RuleID:t,CharacterID:i,BattleStrategy:r,TargetUserID:s,SelectedOptionID:a,RelatedEntityID:`pvp_create_${p.userID}_${P()}`},M=await this.ctx.api.match.createMatch(x);return M.ok&&(this.ctx.data.user.applyResourceOperation(M.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:created",M.data)),M}async updateMatch(e,t={}){if(!e)return n("client","MatchID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),MatchID:e,TargetUserID:t.targetUserID,ClearTargetUser:t.clearTargetUser,RuleID:t.ruleID,CharacterID:t.characterID,BattleStrategy:t.battleStrategy},r=await this.ctx.api.match.updateMatch(i);return r.ok&&this.ctx.emitter.emit("match:updated",r.data),r}async cancelMatch(e){if(!e)return n("client","MatchID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),MatchID:e},i=await this.ctx.api.match.cancelMatch(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:cancelled",i.data)),i}async instantBattle(e,t,i,r){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),MatchID:e,RuleID:t,CharacterID:i,BattleStrategy:r,RelatedEntityID:`pvp_battle_${e}_${P()}`},p=await this.ctx.api.match.instantBattle(a);if(p.ok){let x=p.data,M=this.ctx.data.config.itemDefinitions;if(x.Resources)this.ctx.data.user.applyResourceOperation(x.Resources,M);else if(x.ResourcesDual){let q=x.ResourcesDual;q.FromUserID===s.userID&&q.FromResult?this.ctx.data.user.applyResourceOperation(q.FromResult,M):q.ToUserID===s.userID&&q.ToResult&&this.ctx.data.user.applyResourceOperation(q.ToResult,M);}this.ctx.emitter.emit("match:instantBattleCompleted",x);}return p}async saveStrategy(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BattleStrategy:e},i=await this.ctx.api.match.saveStrategy(t);return i.ok&&(this.ctx.data.user.patchMatchStrategy(e),this.ctx.emitter.emit("match:strategySaved",e)),i}async getMyMatches(e=0,t=20,i){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.Statuses=i;let s=await this.ctx.api.match.getMyMatches(r);return s.ok&&this.ctx.emitter.emit("match:myMatchesLoaded",s.data),s}async getAvailableMatches(e=0,t=20,i=false){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.OnlyPublic=i;let s=await this.ctx.api.match.getAvailableMatches(r);return s.ok&&this.ctx.emitter.emit("match:availableMatchesLoaded",s.data),s}async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.match.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Dp,t.data),this.ctx.emitter.emit("match:definitionsLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var vp="Craft",qi=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(vp,t.data.CraftDefinitions),this.ctx.emitter.emit("craft:definitionsLoaded",t.data.CraftDefinitions)),t}async craft(e,t,i=1,r){if(!e)return n("client","CraftID is required.");let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),CraftID:e,InputItemIDs:t,Count:i,SelectedOptionID:r,RelatedEntityID:`craft_${e}_${s.userID}_${P()}`},p=await this.ctx.api.craft.craft(a);return p.ok&&(this.ctx.data.user.applyResourceOperation(p.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("craft:completed",p.data)),p}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var zp="Collection",Ei=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.collection.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(zp,t.data),this.ctx.emitter.emit("collection:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.collection.getUserState(e);return t.ok&&(this.ctx.data.user.applyCollection(t.data),this.ctx.emitter.emit("collection:userStateLoaded",t.data)),t}async openPack(e,t,i=1,r){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,PackTypeID:t,Count:i,SelectedOptionID:r?.selectedOptionID,Payment:r?.payment,RelatedEntityID:`open_pack_${e}_${t}_${s.userID}_${P()}`},p=await this.ctx.api.collection.openPack(a);return p.ok&&(this.ctx.data.user.applyResourceOperation(p.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:packOpened",p.data)),p}async openCollectionChest(e,t,i=1){let r=this.ctx.auth.context;if(!r)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectionChestID:t,Count:i,RelatedEntityID:`open_chest_${e}_${t}_${r.userID}_${P()}`},a=await this.ctx.api.collection.openCollectionChest(s);return a.ok&&(this.ctx.data.user.applyResourceOperation(a.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:chestOpened",a.data)),a}async useCollectibleJoker(e,t){let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:false,RelatedEntityID:`use_joker_${e}_${t}_${i.userID}_${P()}`},s=await this.ctx.api.collection.useCollectibleJoker(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:jokerUsed",s.data)),s}async claimSetReward(e,t){let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,SetID:t,RelatedEntityID:`claim_set_${e}_${t}_${i.userID}_${P()}`},s=await this.ctx.api.collection.claimSetReward(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:setRewardClaimed",s.data)),s}async claimSetRewardsBatch(e){if(!e||e.length===0)return n("client","sets is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Sets:e},i=await this.ctx.api.collection.claimSetRewardsBatch(t);if(i.ok){let r=false;for(let s of i.data)!r&&s.Success&&s.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("collection:setRewardsClaimedBatch",i.data);}return i}async claimGrandPrize(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,RelatedEntityID:`grand_prize_${e}_${t.userID}_${P()}`},r=await this.ctx.api.collection.claimGrandPrize(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:grandPrizeClaimed",r.data)),r}async sendTradeOffer(e,t,i,r,s,a=false){let p=this.ctx.auth.context;if(!p)return n("unauthorized","Not logged in.");let x={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:i,ReceiverUserID:r,RequestedCollectibleID:s,RequestedCollectibleIsSpecial:a,RelatedEntityID:`trade_send_${p.userID}_${r}_${P()}`},M=await this.ctx.api.collection.sendTradeOffer(x);return M.ok&&this.ctx.emitter.emit("collection:tradeOfferSent",M.data),M}async cancelTradeOffer(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),OfferID:e,RelatedEntityID:`trade_cancel_${e}_${P()}`},i=await this.ctx.api.collection.cancelTradeOffer(t);return i.ok&&this.ctx.emitter.emit("collection:tradeOfferCancelled",i.data),i}async acceptTradeOffer(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),OfferID:e,RelatedEntityID:`trade_accept_${e}_${P()}`},i=await this.ctx.api.collection.acceptTradeOffer(t);return i.ok&&this.ctx.emitter.emit("collection:tradeOfferAccepted",i.data),i}async declineTradeOffer(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),OfferID:e,RelatedEntityID:`trade_decline_${e}_${P()}`},i=await this.ctx.api.collection.declineTradeOffer(t);return i.ok&&this.ctx.emitter.emit("collection:tradeOfferDeclined",i.data),i}async getMyTradeOffers(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CollectionID=e;let i=await this.ctx.api.collection.getMyTradeOffers(t);return i.ok&&this.ctx.emitter.emit("collection:myTradeOffersLoaded",i.data),i}async getIncomingTradeOffers(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CollectionID=e;let i=await this.ctx.api.collection.getIncomingTradeOffers(t);return i.ok&&this.ctx.emitter.emit("collection:incomingTradeOffersLoaded",i.data),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Tp="CoopEvent",Gi=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.coopEvent.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Tp,t.data),this.ctx.emitter.emit("coopEvent:definitionsLoaded",t.data)),t}async getActiveEvent(e){if(!e)return n("client","CoopChainID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CoopChainID=e;let i=await this.ctx.api.coopEvent.getActiveEvent(t);return i.ok&&this.ctx.emitter.emit("coopEvent:activeEventLoaded",i.data),i}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.coopEvent.getUserState(e);return t.ok&&(this.ctx.data.user.applyCoopEvent(t.data.UserState??null),this.ctx.emitter.emit("coopEvent:userStateLoaded",t.data)),t}async getGroupState(e){if(!e)return n("client","GroupID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.GroupID=e;let i=await this.ctx.api.coopEvent.getGroupState(t);return i.ok&&this.ctx.emitter.emit("coopEvent:groupStateLoaded",i.data),i}async joinOrCreateGroup(e){if(!e)return n("client","CoopChainID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),CoopChainID:e},i=await this.ctx.api.coopEvent.joinOrCreateGroup(t);if(i.ok){let r=i.data.Group;r&&this.ctx.data.user.patchCoopEventActiveGroup(r.GroupID??null,r.CoopEventID??null,-1),this.ctx.emitter.emit("coopEvent:groupJoined",i.data);}return i}async spin(e,t,i=1,r){if(!e||!t)return n("client","CoopChainID and GroupID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CoopChainID:e,GroupID:t,Count:i,SelectedOptionID:r,RelatedEntityID:P()},a=await this.ctx.api.coopEvent.spin(s);return a.ok&&(this.ctx.data.user.applyResourceOperation(a.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("coopEvent:spinCompleted",a.data)),a}async claimObjectReward(e){if(!e)return n("client","GroupID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.coopEvent.claimObjectReward(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("coopEvent:objectRewardClaimed",i.data)),i}async claimGrandPrize(e){if(!e)return n("client","GroupID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.coopEvent.claimGrandPrize(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:grandPrizeClaimed",i.data)),i}async leaveGroup(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.coopEvent.leaveGroup(t);return i.ok&&(this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:groupLeft",i.data)),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Pp="DealOffer",Ni=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(Pp,t.data.DealOfferDefinitions),this.ctx.emitter.emit("dealOffer:definitionLoaded",t.data.DealOfferDefinitions)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.dealOffer.getUserState(e);return t.ok&&t.data.DealOffers&&(this.ctx.data.user.applyDealOffer(t.data.DealOffers),this.ctx.emitter.emit("dealOffer:userStateLoaded",t.data.DealOffers)),t}async getActiveDeals(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.dealOffer.getActiveDeals(e);return t.ok&&this.ctx.emitter.emit("dealOffer:activeDealsLoaded",t.data),t}async dismissDeal(e){if(!e)return n("client","SlotID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),SlotID:e,RelatedEntityID:`deal_dismiss_${e}_${P()}`},i=await this.ctx.api.dealOffer.dismissDeal(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:dealDismissed",i.data)),i}async executeNode(e,t,i,r){if(!e||!t)return n("client","SlotID and NodeID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s=i&&i.trim().length>0?i.trim():void 0,a={...this.ctx.buildAuthedBaseRequest(),SlotID:e,NodeID:t,SelectedOptionID:r?.selectedOptionID,Payment:r?.payment,RelatedEntityID:s??`deal_exec_${e}_${t}_${P()}`},p=await this.ctx.api.dealOffer.executeNode(a);return p.ok&&(p.data.Idempotent||this.ctx.data.user.applyResourceOperation(p.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:nodeExecuted",p.data)),p}async recordShow(e){if(!e)return n("client","SlotID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),SlotID:e,RelatedEntityID:`deal_show_${e}_${P()}`},i=await this.ctx.api.dealOffer.recordShow(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:showRecorded",i.data)),i}async claimMilestone(e,t){if(!e||!t)return n("client","SlotID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneID:t,RelatedEntityID:`deal_milestone_${e}_${t}_${P()}`},r=await this.ctx.api.dealOffer.claimMilestone(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:milestoneClaimed",r.data)),r}async claimMilestonesBatch(e,t){if(!e)return n("client","SlotID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i=[...new Set(t.map(a=>a.trim()).filter(a=>a.length>0))],r={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneIDs:i,RelatedEntityID:`deal_milestone_batch_${e}_${P()}`},s=await this.ctx.api.dealOffer.claimMilestonesBatch(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:milestonesBatchClaimed",s.data)),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ip="Referral",ji=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(Ip,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=ft.parseReferralCode(e)?.toUpperCase();if(!t)return n("client","ReferralCode is required.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),ReferralCode:t,RelatedEntityID:`referral_activation_${i.userID}`},s=await this.ctx.api.referral.activateReferralCode(r);if(s.ok){let a=s.data;a.ReferrerUserID&&this.ctx.data.user.patchReferralSubscription(a.ReferrerUserID),this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:codeActivated",a);}return s}async claimInviteReward(e){let t=e.trim();if(!t)return n("client","InviteRewardID is required.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),InviteRewardID:t,RelatedEntityID:`referral_invite_${t}_${i.userID}`},s=await this.ctx.api.referral.claimInviteReward(r);if(s.ok){let a=s.data;a.RewardID&&this.ctx.data.user.patchReferralInviteRewardClaimed(a.RewardID),this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:inviteRewardClaimed",a);}return s}async claimInviteRewardsBatch(e){let t=(e??[]).map(a=>a?.trim()).filter(Boolean);if(t.length===0)return n("client","InviteRewardIDs is required.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),InviteRewardIDs:t,RelatedEntityID:`referral_invite_batch_${t.join("_")}_${i.userID}`},s=await this.ctx.api.referral.claimInviteRewardsBatch(r);if(s.ok){let a=s.data;for(let p of a.Items??[])p.Success&&p.Id&&this.ctx.data.user.patchReferralInviteRewardClaimed(p.Id);this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:inviteRewardsBatchClaimed",a);}return s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Fi=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 getOutgoingRequests(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getOutgoingRequests(e);return t.ok&&(this.ctx.data.user.applySocialOutgoingRequests(t.data.Friends),this.ctx.emitter.emit("social:outgoingRequestsLoaded",t.data)),t}async getRecommendedFriends(e=5){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Limit=e;let i=await this.ctx.api.social.getRecommendedFriends(t);return i.ok&&this.ctx.emitter.emit("social:recommendedFriendsLoaded",i.data),i}async sendFriendRequest(e){if(!e)return n("client","TargetUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.sendFriendRequest(t);return i.ok&&(this.ctx.data.user.patchSocialAddOutgoingRequest(e),this.ctx.emitter.emit("social:friendRequestSent",i.data)),i}async acceptFriendRequest(e){if(!e)return n("client","RequesterUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.acceptFriendRequest(t);return i.ok&&(this.ctx.data.user.patchSocialAcceptFriend(e),this.ctx.emitter.emit("social:friendRequestAccepted",i.data)),i}async declineFriendRequest(e){if(!e)return n("client","RequesterUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.declineFriendRequest(t);return i.ok&&(this.ctx.data.user.patchSocialRemoveIncomingRequest(e),this.ctx.emitter.emit("social:friendRequestDeclined",i.data)),i}async removeFriend(e){if(!e)return n("client","FriendUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.removeFriend(t);return i.ok&&(this.ctx.data.user.patchSocialRemoveFriend(e),this.ctx.emitter.emit("social:friendRemoved",i.data)),i}async getTimeline(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getTimeline(e);return t.ok&&(this.ctx.data.user.applySocialTimeline(t.data.Events),this.ctx.emitter.emit("social:timelineLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var kp="TimedBoost";function Mp(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var Vi=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(kp,t.data),this.ctx.emitter.emit("timedBoost:definitionsLoaded",t.data)),t}async getActive(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.getActive(e);return t.ok&&(this.ctx.data.user.applyTimedBoost({Active:t.data.Active??{}}),this.ctx.emitter.emit("timedBoost:activeLoaded",t.data)),t}async getActiveWindows(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.getActiveWindows(e);return t.ok&&this.ctx.emitter.emit("timedBoost:activeWindowsLoaded",t.data),t}async activate(e,t){let i=e.trim();if(!Mp(i))return n("client",'BoostID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),BoostID:i,SelectedOptionID:t?.selectedOptionID,Payment:t?.payment,RelatedEntityID:`timed_boost_activate_${i}_${P()}`},s=await this.ctx.api.timedBoost.activate(r);if(s.ok){let a=s.data;if(a.ActivatedBoost){let p=a.StackingPolicy??"Replace";this.ctx.data.user.patchActiveTimedBoost(a.ActivatedBoost,p);}this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedBoost:activated",a);}return s}async cleanupExpired(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.cleanupExpired(e);return t.ok&&(await this.getActive(),this.ctx.emitter.emit("timedBoost:expiredCleaned",void 0)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var st={Private:"Private",Public:"Public",ReadOnly:"ReadOnly",Internal:"Internal"},wp={Client:"Client",Server:"Server",System:"System"},Ap=zod.z.enum(["Client","Server","System"]).catch("Client"),Op=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:u.nullish(),Version:zod.z.number().nullish(),LastWriter:Ap.nullish(),ExpiresAt:u.nullish()}).passthrough(),_i=zod.z.record(zod.z.string(),Op),xo=zod.z.object({Version:zod.z.number().nullish(),Private:_i.nullish(),Public:_i.nullish(),ReadOnly:_i.nullish()}),Ps=zod.z.object({UserID:zod.z.string().nullish(),Version:zod.z.number().nullish(),Public:_i.nullish()}),Is=zod.z.object({ServerTimeUtc:u.nullish(),Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:u.nullish()}),Up=zod.z.object({Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:u.nullish()}),bo=zod.z.object({ServerTimeUtc:u.nullish(),Results:zod.z.array(Up).nullish()}),Do=zod.z.object({ServerTimeUtc:u.nullish(),DeletedCount:zod.z.number().nullish()}),vo=zod.z.object({Results:zod.z.array(Ps).nullish(),NotFoundUserIDs:zod.z.array(zod.z.string()).nullish()}),Bp={String:"String",Int:"Int",Bool:"Bool",Json:"Json"},Lp=zod.z.enum(["String","Int","Bool","Json"]).catch("String"),qp=zod.z.object({KeyID:zod.z.string(),Bucket:zod.z.string().nullish(),ValueType:Lp.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),Wi=zod.z.object({Keys:zod.z.record(zod.z.string(),qp).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(),Ke={GetUserCustomDataDefinitions:"GetUserCustomDataDefinitions",GetMyUserCustomData:"GetMyUserCustomData",GetPublicUserCustomDataOf:"GetPublicUserCustomDataOf",SetPrivateData:"SetPrivateData",SetPublicData:"SetPublicData",DeleteKey:"DeleteKey",BatchSet:"BatchSet",BatchDelete:"BatchDelete",BatchGetPublicUserCustomDataOf:"BatchGetPublicUserCustomDataOf"};var Ep="UserCustomData";function zo(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var Qi=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(Ep,t.data),this.ctx.emitter.emit("userCustomData:definitionsLoaded",t.data)),t}async getMyUserCustomData(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.userCustomData.getMyUserCustomData(e);return t.ok&&(this.ctx.data.user.applyUserCustomData(t.data),this.ctx.emitter.emit("userCustomData:myDataLoaded",t.data)),t}async getPublicUserCustomDataOf(e){let t=e.trim();if(!t)return n("client","TargetUserID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.TargetUserID=t;let r=await this.ctx.api.userCustomData.getPublicUserCustomDataOf(i);return r.ok&&this.ctx.emitter.emit("userCustomData:publicDataLoaded",r.data),r}async setPrivateData(e,t){return this.setData(e,t,st.Private)}async setPublicData(e,t){return this.setData(e,t,st.Public)}async setData(e,t,i){let r=e.trim();if(!zo(r))return n("client",'KeyID is required and must not contain "." or "$".');if(t==null)return n("client","Value is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),KeyID:r,Value:t},p=await(i===st.Private?this.ctx.api.userCustomData.setPrivateData(s):this.ctx.api.userCustomData.setPublicData(s));if(p.ok){let x=p.data;this.ctx.data.user.patchUserCustomDataKey(i,x.KeyID,t,x.Version??0,x.ExpiresAt),this.ctx.emitter.emit(i===st.Private?"userCustomData:privateDataSet":"userCustomData:publicDataSet",x);}return p}async deleteKey(e,t){let i=e.trim();if(!zo(i))return n("client",'KeyID is required and must not contain "." or "$".');if(t!==st.Private&&t!==st.Public)return n("client","Only Private or Public keys can be deleted.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),KeyID:i,Bucket:t},s=await this.ctx.api.userCustomData.deleteKey(r);return s.ok&&(this.ctx.data.user.removeUserCustomDataKey(t,i),this.ctx.emitter.emit("userCustomData:keyDeleted",void 0)),s}async batchSet(e){if(!e.length)return n("client","At least one item is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BatchSetItems:e},i=await this.ctx.api.userCustomData.batchSet(t);if(i.ok){for(let r of i.data.Results??[]){let s=r.Bucket??st.Private,a=e.find(p=>p.Bucket===s&&p.KeyID===r.KeyID);a&&this.ctx.data.user.patchUserCustomDataKey(s,r.KeyID,a.Value,r.Version??0,r.ExpiresAt);}this.ctx.emitter.emit("userCustomData:batchSet",i.data);}return i}async batchDelete(e){if(!e.length)return n("client","At least one item is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BatchDeleteItems:e},i=await this.ctx.api.userCustomData.batchDelete(t);if(i.ok){for(let r of e)this.ctx.data.user.removeUserCustomDataKey(r.Bucket,r.KeyID.trim());this.ctx.emitter.emit("userCustomData:batchDeleted",i.data);}return i}async batchGetPublicUserCustomDataOf(e){if(!e.length)return n("client","At least one target user id is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.TargetUserIDs=e;let i=await this.ctx.api.userCustomData.batchGetPublicUserCustomDataOf(t);return i.ok&&this.ctx.emitter.emit("userCustomData:batchPublicDataLoaded",i.data),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Gp="TitleCustomDataDefinitions",To=50;function Np(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}function ks(o){if(o.ExpiresAt==null)return false;let e=Date.parse(o.ExpiresAt);return !Number.isNaN(e)&&e<=Date.now()}function jp(o){let e={};for(let[t,i]of Object.entries(o))ks(i)||(e[t]=i);return e}var Ki=class{constructor(e){this.ctx=e;}ctx;lastRuntimeVersion=null;runtimeCache={};async getTitleCustomDataDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.titleCustomData.getTitleCustomDataDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Gp,t.data),this.ctx.emitter.emit("titleCustomData:definitionsLoaded",t.data)),t}async getPublicTitleData(e=true){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&this.lastRuntimeVersion!=null&&(t.KnownRuntimeVersion=this.lastRuntimeVersion);let i=await this.ctx.api.titleCustomData.getPublicTitleData(t);return i.ok&&this.absorb(i.data),i}async getPublicTitleDataKeys(e){let t=e.map(s=>s.trim()).filter(s=>s.length>0);if(!t.length)return n("client","At least one KeyID is required.");if(t.some(s=>!Np(s)))return n("client",'KeyID must not contain "." or "$".');if(t.length>To)return n("client",`At most ${To} keys per call \u2014 request them in chunks.`);let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.KeyIDs=t;let r=await this.ctx.api.titleCustomData.getPublicTitleDataKeys(i);return r.ok&&this.ctx.emitter.emit("titleCustomData:publicDataLoaded",r.data),r}getValue(e){let t=this.runtimeCache[e];if(t?.Value!=null&&!ks(t))return t.Value;let i=this.staticCache[e];if(i?.Value!=null&&!ks(i))return i.Value}get runtimeVersion(){return this.lastRuntimeVersion}staticCache={};absorb(e){e.Static&&(this.staticCache=e.Static),e.NotModified?(this.runtimeCache=jp(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 Hi=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 Fp=15,Vp="GameLoop",_p="BoardDefinition",$i=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(Vp,t.data),this.ctx.emitter.emit("gameLoop:gameLoopsLoaded",t.data)),t}async getBoardDefinition(e=false){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");let i=await this.ctx.api.gameLoop.getBoardDefinition(t,e);return i.ok&&(this.ctx.data.config.patchSection(_p,i.data),this.ctx.emitter.emit("gameLoop:boardDefinitionLoaded",i.data)),i}async getBoardDefinitionForLevel(e,t=false){if(e<=0)return n("client","stageLevel must be > 0.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.StageLevel=e;let r=await this.ctx.api.gameLoop.getBoardDefinitionForLevel(i,t);return r.ok&&this.ctx.emitter.emit("gameLoop:boardDefinitionForLevelLoaded",r.data),r}async getUserBoardState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.gameLoop.getUserBoardState(e);return t.ok&&(this.ctx.data.user.applyBoardState(t.data),this.ctx.emitter.emit("gameLoop:boardStateLoaded",t.data)),t}async boardLoopRoll(e=1){if(e<1)return n("client","rollMultiplier must be >= 1.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),RollMultiplier:e,RelatedEntityID:`roll_${t.userID}_${P()}`},r=await this.ctx.api.gameLoop.boardLoopRoll(i);if(r.ok){let s=r.data,a=mo(new Date,Fp);this.ctx.data.user.patchBoardState(p=>{p.Position=s.NewPosition,p.CyclesCompleted=(p.CyclesCompleted??0)+(s.CyclesCompletedDelta??0),p.LastRollAtUtc=new Date().toISOString(),s.ActionRequired&&s.ActionData?p.Pending={Type:s.ActionRequired,TargetUserID:s.ActionData.TargetUserID,TargetPublicData:s.ActionData.PublicData,TargetBuildingStates:s.ActionData.TargetBuildingStates??void 0,TargetHasShield:s.ActionData.TargetHasShield??void 0,RollMultiplier:s.UsedMultiplier??1,ExpiresAtUtc:a}:s.SpecialModeOffer&&(p.Pending={Type:"SPECIAL",RollMultiplier:s.UsedMultiplier??1,ExpiresAtUtc:a,Special:{ModeID:s.SpecialModeOffer.ModeID??void 0,Choices:s.SpecialModeOffer.Choices??void 0}});}),s.Operation&&this.ctx.data.user.applyResourceOperation(s.Operation,this.itemDefs),s.ActionRequired==="RAID"&&await this.getUserBoardState(),this.ctx.emitter.emit("gameLoop:boardRolled",s);}return r}async boardLoopAttack(e=-1){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`attack_${t.userID}_${P()}`},r=await this.ctx.api.gameLoop.boardLoopAttack(i);if(r.ok){let s=r.data;this.ctx.data.user.clearBoardPending(),s.IsBotTarget&&s.Operation?this.ctx.data.user.applyResourceOperation(s.Operation,this.itemDefs):!s.IsBotTarget&&s.DualResult?.FromResult&&this.ctx.data.user.applyResourceOperation(s.DualResult.FromResult,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardAttacked",s);}else await this.getUserBoardState();return r}async boardLoopRaid(e,t){if(e<0||e>11)return n("client","digIndex must be between 0 and 11.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),DigIndex:e,RelatedEntityID:t??`raid_${i.userID}_${P()}`},s=await this.ctx.api.gameLoop.boardLoopRaid(r);if(s.ok){let a=s.data;a.Status==="CONTINUE"?this.ctx.data.user.patchBoardPendingRaidLayout(a.RaidLayout,a.OpenedIndex??-1):(this.ctx.data.user.clearBoardPending(),this.applyRaidResources(a)),this.ctx.emitter.emit("gameLoop:boardRaided",a);}else await this.getUserBoardState();return s}async boardLoopRaidFast(e){if(!e.length)return n("client","digIndices must not be empty.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),DigIndices:e,RelatedEntityID:`raidfast_${t.userID}_${P()}`},r=await this.ctx.api.gameLoop.boardLoopRaidFast(i);if(r.ok){let s=r.data;s.Status!=="CONTINUE"&&(this.ctx.data.user.clearBoardPending(),this.applyRaidResources(s)),this.ctx.emitter.emit("gameLoop:boardRaidedFast",s);}else await this.getUserBoardState();return r}async boardLoopBuild(e){if(e<0)return n("client","buildingIndex must be >= 0.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`build_${t.userID}_${e}_${P()}`},r=await this.ctx.api.gameLoop.boardLoopBuild(i);if(r.ok){let s=r.data;s.StageComplete?this.ctx.data.user.patchBoardState(a=>{a.StageLevel=(a.StageLevel??1)+1,a.Position=0,a.Pending=null,a.BuildingStates=null;}):this.ctx.data.user.patchBoardBuilding(s.BuiltIndex,a=>{s.NewLevel!=null&&(a.Level=s.NewLevel),a.IsDamaged=false,s.MaxLevelRewardClaimed&&(a.MaxLevelRewardClaimed=true);}),s.Operation&&this.ctx.data.user.applyResourceOperation(s.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardBuilt",s);}return r}async boardSpecialChoose(e,t){if(!e)return n("client","choiceID must not be empty.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),ChoiceID:e,SelectedOptionID:t,RelatedEntityID:`special_choose_${i.userID}_${P()}`},s=await this.ctx.api.gameLoop.boardSpecialChoose(r);if(s.ok){let a=s.data;a.Mode==="Instant"||a.Mode===0?this.ctx.data.user.clearBoardPending():this.ctx.data.user.patchBoardSpecialPending(x=>{x.ChoiceID=e,x.ChosenMode=a.Mode??"Timed",x.StartedAtUtc=a.StartedAtUtc??null,x.DurationSeconds=a.DurationSeconds??null,x.AdViewsUsed=0;}),a.Operation&&this.ctx.data.user.applyResourceOperation(a.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialChose",a);}return s}async boardSpecialApplyMultiplier(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:e??`special_ad_${t.userID}_${P()}`},r=await this.ctx.api.gameLoop.boardSpecialApplyMultiplier(i);if(r.ok){let s=r.data;this.ctx.data.user.patchBoardSpecialPending(a=>{a.AdViewsUsed=s.AdViewsUsed??0,a.AccumulatedMultiplier=s.AccumulatedMultiplier??0;}),this.ctx.emitter.emit("gameLoop:boardSpecialApplyMultiplier",s);}return r}async boardSpecialClaim(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:`special_claim_${t.userID}_${P()}`,...e&&Object.keys(e).length>0?{RunStats:e}:{}},r=await this.ctx.api.gameLoop.boardSpecialClaim(i);if(r.ok){let s=r.data;this.ctx.data.user.clearBoardPending(),s.Operation&&this.ctx.data.user.applyResourceOperation(s.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialClaimed",s);}return r}async getCommunityChestState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.gameLoop.getCommunityChestState(e);return t.ok&&(this.ctx.data.user.applyCommunityChestUserState(t.data.UserState??null),this.ctx.emitter.emit("gameLoop:communityChestStateLoaded",t.data)),t}async joinOrCreateCommunityChest(){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let e={...this.ctx.buildAuthedBaseRequest()},t=await this.ctx.api.gameLoop.joinOrCreateCommunityChest(e);if(t.ok){let i=t.data.Group;i?.GroupID&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:i.GroupID,ActiveRoundIndex:i.RoundIndex??void 0}),this.ctx.emitter.emit("gameLoop:communityChestJoined",t.data);}return t}async claimCommunityChestMilestone(e,t){if(!e)return n("client","milestoneID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),MilestoneID:e,GroupID:t},r=await this.ctx.api.gameLoop.claimCommunityChestMilestone(i);return r.ok&&(r.data.Resources&&this.ctx.data.user.applyResourceOperation(r.data.Resources,this.itemDefs),this.ctx.emitter.emit("gameLoop:communityChestMilestoneClaimed",r.data)),r}async claimCommunityChestGrandPrize(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.gameLoop.claimCommunityChestGrandPrize(t);return i.ok&&(i.data.Resources&&this.ctx.data.user.applyResourceOperation(i.data.Resources,this.itemDefs),this.ctx.emitter.emit("gameLoop:communityChestGrandPrizeClaimed",i.data)),i}async leaveCommunityChest(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.gameLoop.leaveCommunityChest(t);return i.ok&&(i.data.Success&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:void 0,ActiveRoundIndex:-1}),this.ctx.emitter.emit("gameLoop:communityChestLeft",i.data)),i}applyRaidResources(e){e.Operation?this.ctx.data.user.applyResourceOperation(e.Operation,this.itemDefs):e.DualResult?.FromResult&&this.ctx.data.user.applyResourceOperation(e.DualResult.FromResult,this.itemDefs);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Zi=class{constructor(e){this.ctx=e;}ctx;async execute(e,t,i,r){let s=e.trim();if(!s)return n("client","FunctionName is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),FunctionName:s,FunctionParameter:t,RevisionSelection:i,SpecificRevision:r},p=await this.ctx.api.cloudCode.execute(a);return p.ok&&this.ctx.emitter.emit("cloudCode:executed",p.data),p}};var Po=zod.z.object({ServerTimeUtc:u,SourceType:It,SourceID:zod.z.string(),TargetType:It,TargetID:zod.z.string(),SourceSpent:w,FeeAmount:w,RateApplied:E,TargetCredited:w}),Io=zod.z.object({ServerTimeUtc:u,SourceType:It,SourceID:zod.z.string(),TargetType:It,TargetID:zod.z.string(),SourceSpent:E,FeeAmount:E,RateApplied:E,TargetCredited:E}),Ji={Convert:"Convert",CryptoConvert:"CryptoConvert"},Wp={Active:"Active",Hidden:"Hidden",Deprecated:"Deprecated",Maintenance:"Maintenance"},ko=zod.z.enum(["Active","Hidden","Deprecated","Maintenance"]).catch("Active"),Qp={Automatic:"Automatic",Manual:"Manual"},Kp=zod.z.enum(["Automatic","Manual"]).catch("Automatic"),Hp=zod.z.object({ValueInUSD:E.nullish(),ValueInUSDUpdatedAt:u.nullish(),InitialDeposit:zod.z.number().nullish(),MinBalance:zod.z.number().nullish(),MaxBalance:zod.z.number().nullish(),DailyEarnLimit:zod.z.number().nullish(),DailySpendLimit:zod.z.number().nullish()}).passthrough(),$p=zod.z.object({Rate:zod.z.number().nullish(),Max:zod.z.number().nullish(),Period:zod.z.number().nullish()}).passthrough(),Zp=zod.z.object({IsTradable:zod.z.boolean().nullish(),IsPurchasable:zod.z.boolean().nullish(),IsRefundable:zod.z.boolean().nullish()}).passthrough(),Jp=zod.z.object({TargetCurrencyType:It.nullish(),TargetCurrencyID:zod.z.string(),Rate:E.nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish(),DailyLimit:zod.z.number().nullish()}).passthrough(),Mo=zod.z.object({Enabled:zod.z.boolean().nullish(),RateMode:Kp.nullish(),FeePercent:E.nullish(),Targets:zod.z.array(Jp).nullish()}).passthrough(),wo=zod.z.object({CreatedAt:u.nullish(),UpdatedAt:u.nullish()}).passthrough(),Yp=zod.z.object({CurrencyID:zod.z.string(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Economy:Hp.nullish(),Recharge:$p.nullish(),Conversion:Mo.nullish(),Permissions:Zp.nullish(),Audit:wo.nullish(),Status:ko.nullish()}).passthrough(),Xp=zod.z.object({NetworkID:zod.z.string(),ContractAddress:zod.z.string().nullish(),Decimals:zod.z.number().nullish(),MinDeposit:E.nullish(),MinWithdraw:E.nullish(),WithdrawFee:E.nullish(),DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish()}).passthrough(),ed=zod.z.object({DailyWithdrawUsd:E.nullish(),MonthlyWithdrawUsd:E.nullish(),KycRequiredAboveUsd:E.nullish()}).passthrough(),td=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),SpendableInGame:zod.z.boolean().nullish(),ConvertibleToVirtual:zod.z.boolean().nullish()}).passthrough(),Ms=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:E.nullish(),ValueInUSDUpdatedAt:u.nullish(),DeveloperDepositSharePercent:E.nullish(),CommunityMarketingDepositSharePercent:E.nullish(),WithdrawalBurnPercent:E.nullish(),Networks:zod.z.array(Xp).nullish(),Limits:ed.nullish(),Permissions:td.nullish(),Conversion:Mo.nullish(),Audit:wo.nullish(),Status:ko.nullish()}).passthrough(),Yi=zod.z.object({VirtualCurrencies:zod.z.record(zod.z.string(),Yp).nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Ms).nullish()}).passthrough();var Ao=zod.z.object({OptionID:zod.z.string().nullish(),Name:zod.z.string().nullish(),Cost:_t.nullish(),AllowedPlatforms:zod.z.array(ti).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),J=zod.z.record(zod.z.string(),Ao),id=zod.z.object({Store:ii,Receipt:zod.z.string(),Signature:zod.z.string().nullish()}).passthrough();var Oo=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),ItemInstanceID:zod.z.string().nullish(),EquippedAt:u.nullish()}),ws=zod.z.object({CharacterID:zod.z.string(),Level:zod.z.number().nullish(),Experience:w.nullish(),Power:zod.z.number().nullish(),StatLevels:zod.z.record(zod.z.string(),zod.z.number()).nullish(),Equipment:zod.z.record(zod.z.string(),Oo).nullish(),UpdatedAt:u.nullish()}).passthrough(),rd=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),sd=zod.z.object({ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Quantity:zod.z.number().nullish(),RemainingUses:zod.z.number().nullish(),Level:zod.z.number().nullish(),AcquiredAt:u,ExpiresAt:u.nullish(),EquippedSlot:rd.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(o=>o),pt=zod.z.object({ChangedInstances:zod.z.record(zod.z.string(),sd).nullish(),RemovedInstanceIDs:zod.z.array(zod.z.string()).nullish()}),Uo=zod.z.object({Characters:zod.z.record(zod.z.string(),ws).nullish()}),As=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),StatID:zod.z.string(),StatLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:D.nullish()}),Os=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),NewLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:D.nullish()}),Bo=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),Equipment:zod.z.record(zod.z.string(),Oo).nullish(),ReplacedInstanceIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:pt.nullish()}),Lo=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:pt.nullish()}),nd=zod.z.object({ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish()}),qo=zod.z.object({ServerTimeUtc:u,Characters:zod.z.record(zod.z.string(),nd).nullish(),Inventory:pt.nullish()}),Us=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),Power:zod.z.number().nullish(),Resources:D.nullish()}),Eo=Xe(Us),Go=Xe(Os),No=Xe(As),jo=zod.z.object({RequiredStatID:zod.z.string(),RequiredLevel:zod.z.number()}).passthrough(),Fo=zod.z.object({StatID:zod.z.string(),TypeID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),MaxLevel:zod.z.number().nullish(),Weight:zod.z.number().nullish(),PriceOptions:J.nullish(),CostCurve:xe.nullish(),BaseStatValue:zod.z.number().nullish(),ValueCurve:xe.nullish(),RankCurve:xe.nullish(),Requirements:zod.z.array(jo).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),od=zod.z.object({SlotID:zod.z.string(),MinCharacterLevel:zod.z.number().nullish(),StatRequirements:zod.z.array(jo).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(),Vo=zod.z.object({Slots:zod.z.record(zod.z.string(),od).nullish()}).passthrough(),ad=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(),ld=zod.z.object({ClassID:zod.z.string().nullish(),RarityID:zod.z.string().nullish(),Tags:zod.z.array(zod.z.string()).nullish()}).passthrough(),ud=zod.z.object({UnlockedByDefault:zod.z.boolean().nullish(),PriceOptions:J.nullish()}).passthrough(),cd=zod.z.object({Stats:Y.nullish(),Levels:Y.nullish(),Equipment:Y.nullish()}).passthrough(),_o=zod.z.object({MaxRank:zod.z.number().nullish(),FirstPaidRank:zod.z.number().nullish(),PriceOptions:J.nullish(),CostCurve:xe.nullish()}).passthrough(),pd=zod.z.object({CharacterID:zod.z.string(),Identity:ad.nullish(),Classification:ld.nullish(),Unlock:ud.nullish(),Presets:cd.nullish(),Equipment:Vo.nullish(),Stats:zod.z.record(zod.z.string(),Fo).nullish(),RankLadder:_o.nullish(),RankStatCurve:xe.nullish(),StatMaxLevelCurve:xe.nullish()}).passthrough(),dd=zod.z.object({Stats:zod.z.record(zod.z.string(),Fo).nullish()}).passthrough(),hd=zod.z.object({RankLadder:_o.nullish()}).passthrough(),md=zod.z.object({Equipment:Vo.nullish()}).passthrough(),fd=zod.z.object({Stats:zod.z.record(zod.z.string(),dd).nullish(),Levels:zod.z.record(zod.z.string(),hd).nullish(),Equipment:zod.z.record(zod.z.string(),md).nullish()}).passthrough(),Xi=zod.z.object({Definitions:zod.z.record(zod.z.string(),pd).nullish(),Presets:fd.nullish()}).passthrough(),Oe={GetCharacterDefinitions:"GetCharacterDefinitions",GetUserCharacters:"GetUserCharacters",UnlockCharacter:"UnlockCharacter",UpgradeStatLevel:"UpgradeStatLevel",UpgradeCharacterLevel:"UpgradeCharacterLevel",EquipItems:"EquipItems",UnequipItems:"UnequipItems",UnequipAllCharacters:"UnequipAllCharacters",UnlockCharactersBatch:"UnlockCharactersBatch",UpgradeCharacterLevelsBatch:"UpgradeCharacterLevelsBatch",UpgradeStatLevelsBatch:"UpgradeStatLevelsBatch"};var gd={EVM:"EVM",Solana:"Solana"},Rd=zod.z.enum(["EVM","Solana"]).catch("EVM"),yd={AutoLinkedFromTransaction:"AutoLinkedFromTransaction",SignatureVerified:"SignatureVerified",ManuallyLinked:"ManuallyLinked"},Cd=zod.z.enum(["AutoLinkedFromTransaction","SignatureVerified","ManuallyLinked"]).catch("AutoLinkedFromTransaction"),Sd={Token:"Token",Nft:"Nft"},Wo=zod.z.enum(["Token","Nft"]).catch("Token"),xd={NotRequested:"NotRequested",Pending:"Pending",Verified:"Verified",Rejected:"Rejected",Expired:"Expired"},bd=zod.z.enum(["NotRequested","Pending","Verified","Rejected","Expired"]).catch("NotRequested"),Dd={None:"None",Tier1:"Tier1",Tier2:"Tier2",Tier3:"Tier3"},vd=zod.z.enum(["None","Tier1","Tier2","Tier3"]).catch("None"),zd={Pending:"Pending",Completed:"Completed",Failed:"Failed",Expired:"Expired",Abandoned:"Abandoned"},Bs=zod.z.enum(["Pending","Completed","Failed","Expired","Abandoned"]).catch("Pending"),Qo={GameTopUp:"game_topup",CommunityReward:"community_reward"};function er(o){let e=o?.trim();return e||Qo.GameTopUp}var Td={UsersCryptoWallet:"UsersCryptoWallet",Game:"Game"},Ko=zod.z.enum(["UsersCryptoWallet","Game"]).catch("UsersCryptoWallet"),Pd=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(),Ho=zod.z.object({Ios:zod.z.boolean().nullish(),Android:zod.z.boolean().nullish(),Web:zod.z.boolean().nullish()}).passthrough(),Id=zod.z.object({NetworkID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Type:Rd.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:Ho.nullish(),NftCollections:zod.z.array(Pd).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),kd=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),NftDepositsEnabled:zod.z.boolean().nullish(),NftWithdrawalsEnabled:zod.z.boolean().nullish(),PlatformOverrides:Ho.nullish()}).passthrough(),Md=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 wd=zod.z.enum(["OnChain","Combined"]).catch("OnChain"),Ad=zod.z.object({Enabled:zod.z.boolean().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),MinBalance:E.nullish(),BalanceSource:wd.nullish(),DenyMessage:zod.z.string().nullish()}).passthrough(),Od=zod.z.object({Enabled:zod.z.boolean().nullish(),TokenGates:zod.z.array(Ad).nullish(),WalletConnectProjectId:zod.z.string().nullish()}).passthrough(),Ls=zod.z.object({SystemState:kd.nullish(),Networks:zod.z.record(zod.z.string(),Id).nullish(),AccountSafety:Md.nullish(),WalletLogin:Od.nullish()}).passthrough(),Ud=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),LinkedAt:u.nullish(),LastUsedAt:u.nullish(),LinkType:Cd.nullish(),IsSignatureVerified:zod.z.boolean().nullish()}).passthrough(),$o=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Type:Wo.nullish(),NetworkID:zod.z.string().nullish(),AssetID:zod.z.string().nullish(),Amount:E.nullish(),CreatedAt:u.nullish(),ExpiresAt:u.nullish()}).passthrough(),Bd=zod.z.object({Status:bd.nullish(),Tier:vd.nullish(),VerifiedAt:u.nullish(),ExpiresAt:u.nullish(),RejectedAt:u.nullish(),ProviderReference:zod.z.string().nullish(),RejectionReason:zod.z.string().nullish()}).passthrough(),Ld=zod.z.object({CurrencyID:zod.z.string().nullish(),Deposits:zod.z.number().nullish(),DepositsVolumeNative:E.nullish(),DepositsVolumeUsd:E.nullish(),Withdrawals:zod.z.number().nullish(),WithdrawalsVolumeNative:E.nullish(),WithdrawalsVolumeUsd:E.nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),FirstDepositAt:u.nullish(),LastDepositAt:u.nullish(),FirstWithdrawalAt:u.nullish(),LastWithdrawalAt:u.nullish()}).passthrough(),qd=zod.z.object({TotalDeposits:zod.z.number().nullish(),TotalWithdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),TotalDepositsVolumeUsd:E.nullish(),TotalWithdrawalsVolumeUsd:E.nullish(),PerCurrency:zod.z.record(zod.z.string(),Ld).nullish()}).passthrough(),Ed=zod.z.object({NetworkID:zod.z.string().nullish(),ItemCatalogID:zod.z.string().nullish(),Deposits:zod.z.number().nullish(),Withdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),FirstDepositAt:u.nullish(),LastDepositAt:u.nullish(),FirstWithdrawalAt:u.nullish(),LastWithdrawalAt:u.nullish()}).passthrough(),Gd=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(),Ed).nullish()}).passthrough(),Nd=zod.z.object({Tokens:qd.nullish(),Nfts:Gd.nullish()}).passthrough(),jd=zod.z.object({CurrencyID:zod.z.string().nullish(),Balance:E.nullish(),MinBalance:E.nullish()}).passthrough(),Fd=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),CheckedAt:u.nullish(),LoggedInAt:u.nullish(),GatePassed:zod.z.boolean().nullish(),GatedBalances:zod.z.array(jd).nullish()}).passthrough(),Vd=zod.z.object({Version:zod.z.number().nullish(),Stats:Nd.nullish(),LinkedWallets:zod.z.record(zod.z.string(),Ud).nullish(),LastWalletLogin:Fd.nullish(),PendingWithdrawals:zod.z.array($o).nullish(),Kyc:Bd.nullish(),FirstActivityAt:u.nullish(),LastActivityAt:u.nullish(),IsFlagged:zod.z.boolean().nullish(),FlagReason:zod.z.string().nullish()}).passthrough(),_d=zod.z.object({CurrencyID:zod.z.string(),AmountDelta:E,FrozenDelta:E,UpdatedAt:u}).passthrough(),tr=zod.z.object({CryptoBalances:zod.z.record(zod.z.string(),_d).nullish(),PendingAdded:$o.nullish(),PendingRemovedIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),Wd=zod.z.object({Amount:E,Frozen:E,CreatedAt:u.nullish(),UpdatedAt:u.nullish()}).passthrough().transform(o=>o),Qd=zod.z.object({ID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CreatedAt:u.nullish(),UpdatedAt:u.nullish(),UserID:zod.z.string().nullish(),TransactionHash:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ChainType:zod.z.string().nullish(),ChainID:zod.z.number().nullish(),Direction:Ko.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:E.nullish(),Status:Bs.nullish(),SignatureData:zod.z.string().nullish(),CompletedAt:u.nullish(),ExpiresAt:u.nullish(),FailReason:zod.z.string().nullish(),Reason:zod.z.string().nullish(),Category:zod.z.string().nullish(),TokenID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountUsd:E.nullish(),NetPayoutAmount:E.nullish()}).passthrough(),Kd=zod.z.object({ID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CreatedAt:u.nullish(),UpdatedAt:u.nullish(),UserID:zod.z.string().nullish(),TransactionHash:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ChainType:zod.z.string().nullish(),ChainID:zod.z.number().nullish(),Direction:Ko.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:E.nullish(),Status:Bs.nullish(),SignatureData:zod.z.string().nullish(),CompletedAt:u.nullish(),ExpiresAt:u.nullish(),FailReason:zod.z.string().nullish(),Reason:zod.z.string().nullish(),Category:zod.z.string().nullish(),NFTID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),SkinID:zod.z.string().nullish()}).passthrough(),Zo=zod.z.object({To:zod.z.string().nullish(),Amount:zod.z.union([zod.z.string(),zod.z.number()]).nullish()}).passthrough(),qs=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(Zo).nullish(),Signature:zod.z.string().nullish()}).passthrough(),Es=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(Zo).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(),Jo=zod.z.object({Blockchain:Ls.nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Ms).nullish()}).passthrough(),Yo=zod.z.object({State:Vd.nullish(),CryptoBalances:zod.z.record(zod.z.string(),Wd).nullish()}).passthrough(),Xo=zod.z.object({ServerTimeUtc:u.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:E.nullish(),AmountUsd:E.nullish(),StateDelta:tr.nullish()}).passthrough(),ea=zod.z.object({ServerTimeUtc:u.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),NftTokenID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),Resources:D.nullish(),Inventory:pt.nullish()}).passthrough(),ta=zod.z.object({ServerTimeUtc:u.nullish(),TitleTransactionID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:E.nullish(),NetAmountNative:E.nullish(),BurnAmountNative:E.nullish(),AmountUsd:E.nullish(),ExpiresAt:u.nullish(),EvmSignature:qs.nullish(),SolanaSignature:Es.nullish(),StateDelta:tr.nullish()}).passthrough(),ia=zod.z.object({ServerTimeUtc:u.nullish(),TitleTransactionID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),NftTokenID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),ExpiresAt:u.nullish(),Resources:D.nullish(),EvmSignature:qs.nullish(),SolanaSignature:Es.nullish(),StateDelta:tr.nullish(),Inventory:pt.nullish()}).passthrough(),ra=zod.z.object({TokenTransactions:zod.z.array(Qd).nullish(),NFTTransactions:zod.z.array(Kd).nullish()}).passthrough(),Gs=zod.z.object({ServerTimeUtc:u.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:E.nullish(),AmountUsd:E.nullish(),Target:zod.z.string().nullish()}).passthrough(),sa=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Kind:Wo.nullish(),EvmSignature:qs.nullish(),SolanaSignature:Es.nullish()}).passthrough(),na=zod.z.object({TitleTransactionID:zod.z.string().nullish(),OnChainTxHash:zod.z.string().nullish(),Status:Bs.nullish(),StateDelta:tr.nullish()}).passthrough(),Ue={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",DepositToken:"DepositToken",DepositNFT:"DepositNFT",RequestTokenWithdrawal:"RequestTokenWithdrawal",RequestNFTWithdrawal:"RequestNFTWithdrawal",GetTransactionHistory:"GetTransactionHistory",RetryWithdrawal:"RetryWithdrawal",ConfirmWithdrawal:"ConfirmWithdrawal",DonateToDeveloper:"DonateToDeveloper",DonateToUsersPool:"DonateToUsersPool"};var Hd="Blockchain",ir=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(Hd,t.data.Blockchain),this.ctx.emitter.emit("blockchain:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.blockchain.getUserState(e);return t.ok&&(this.ctx.data.user.applyBlockchainState(t.data.State??null,t.data.CryptoBalances),this.ctx.emitter.emit("blockchain:userStateLoaded",t.data)),t}async depositToken(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.NetworkID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.depositToken(i);return r.ok&&r.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(r.data.CurrencyID,new ci__default.default(r.data.AmountNative??0),r.data.ServerTimeUtc??void 0),this.ctx.emitter.emit("blockchain:tokenDeposited",r.data)),r}async depositNFT(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.NetworkID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.depositNFT(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("blockchain:nftDeposited",r.data)),r}async requestTokenWithdrawal(e,t,i,r,s){if(!e)return n("client","CurrencyID is required.");if(!t)return n("client","NetworkID is required.");if(!i)return n("client","WalletAddress is required.");if(!r)return n("client","Amount is required.");let a=this.baseRequest();if(!a)return n("unauthorized","Not logged in.");a.CurrencyID=e,a.NetworkID=t,a.WalletAddress=i,a.Amount=r,a.Category=er(s);let p=await this.ctx.api.blockchain.requestTokenWithdrawal(a);return p.ok&&p.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(p.data.CurrencyID,new ci__default.default(p.data.AmountNative??0).negated(),p.data.ServerTimeUtc??void 0),this.ctx.emitter.emit("blockchain:tokenWithdrawalRequested",p.data)),p}async requestNFTWithdrawal(e,t,i,r,s,a,p){if(!e)return n("client","ItemID is required.");if(!t)return n("client","NetworkID is required.");if(!i)return n("client","WalletAddress is required.");if(!r)return n("client","Amount is required.");let x=this.baseRequest();if(!x)return n("unauthorized","Not logged in.");x.ItemID=e,x.NetworkID=t,x.WalletAddress=i,x.Amount=r,x.Category=er(s),a!==void 0&&(x.Level=a),p&&(x.ItemInstanceID=p);let M=await this.ctx.api.blockchain.requestNFTWithdrawal(x);return M.ok&&(this.ctx.data.user.applyResourceOperation(M.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("blockchain:nftWithdrawalRequested",M.data)),M}async getTransactionHistory(e=50){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Amount=String(e);let i=await this.ctx.api.blockchain.getTransactionHistory(t);return i.ok&&this.ctx.emitter.emit("blockchain:transactionHistoryLoaded",i.data),i}async retryWithdrawal(e){if(!e)return n("client","TitleTransactionID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.TitleTransactionID=e;let i=await this.ctx.api.blockchain.retryWithdrawal(t);return i.ok&&this.ctx.emitter.emit("blockchain:withdrawalRetried",i.data),i}async confirmWithdrawal(e,t){if(!e)return n("client","TitleTransactionID is required.");if(!t)return n("client","On-chain TransactionHash is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.TitleTransactionID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.confirmWithdrawal(i);return r.ok&&this.ctx.emitter.emit("blockchain:withdrawalConfirmed",r.data),r}async donateToDeveloper(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.NetworkID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.donateToDeveloper(i);return r.ok&&this.ctx.emitter.emit("blockchain:donatedToDeveloper",r.data),r}async donateToUsersPool(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.NetworkID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.donateToUsersPool(i);return r.ok&&this.ctx.emitter.emit("blockchain:donatedToUsersPool",r.data),r}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var ze=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 $d={Head:"Head",Torso:"Torso",Legs:"Legs"},rr=zod.z.enum(["Head","Torso","Legs"]).catch("Head"),Zd={Open:"Open",InProgress:"InProgress",Cancelled:"Cancelled",Completed:"Completed"},Ns=zod.z.enum(["Open","InProgress","Cancelled","Completed"]).catch("Open"),la=zod.z.object({AttackTarget:rr,DefenseTarget:rr});var Jd=zod.z.enum(["Hit","Critical","Block","Dodge"]).catch("Hit"),Yd=zod.z.object({RoundIndex:zod.z.number().nullish(),AttackerID:zod.z.string().nullish(),DefenderID:zod.z.string().nullish(),AttackZone:rr.nullish(),DefenseZone:rr.nullish(),HitType:Jd.nullish(),DamageDealt:zod.z.number().nullish(),DefenderHpRemaining:zod.z.number().nullish()}).passthrough(),Xd=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(),eh=zod.z.object({ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Quantity:zod.z.number().nullish(),RemainingUses:zod.z.number().nullish(),Level:zod.z.number().nullish(),AcquiredAt:u,ExpiresAt:u.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(o=>o),aa=zod.z.object({UserID:zod.z.string().nullish(),SelectedCharacterID:zod.z.string().nullish(),SelectedCharacter:ws.nullish(),BattleStrategy:zod.z.array(la).nullish(),UnstackableItems:zod.z.record(zod.z.string(),eh).nullish(),Stats:Xd.nullish()}).passthrough(),th=zod.z.object({WinnerUserID:zod.z.string().nullish(),LoserUserID:zod.z.string().nullish(),Entry:ge.nullish(),NetReward:ge.nullish(),BattleLog:zod.z.array(Yd).nullish(),IsDraw:zod.z.boolean().nullish(),P1BattleProfile:aa.nullish(),P2BattleProfile:aa.nullish()}).passthrough(),ua=zod.z.object({MatchID:zod.z.string(),TitleID:zod.z.string().nullish(),RuleID:zod.z.string().nullish(),CreatedAt:u.nullish(),CreatorID:zod.z.string().nullish(),CreatorCharacterID:zod.z.string().nullish(),CreatorStrategy:zod.z.array(la).nullish(),TargetUserID:zod.z.string().nullish(),Entry:ge.nullish(),CreationCostPaid:ge.nullish(),RefundCreationCostOnCancel:zod.z.boolean().nullish(),JoinedByUserID:zod.z.string().nullish(),JoinedByCharacterID:zod.z.string().nullish(),JoinedAt:u.nullish(),Status:Ns.nullish(),WinnerUserID:zod.z.string().nullish(),CompletedAt:u.nullish(),IsRewardDistributed:zod.z.boolean().nullish(),RewardDistributedAt:u.nullish()}).passthrough(),ca=zod.z.object({Status:Ns,MatchID:zod.z.string(),Entry:ge.nullish(),Resources:D.nullish()}),pa=zod.z.object({Match:ua.nullish()}),da=zod.z.object({MatchID:zod.z.string(),Status:Ns,Resources:D.nullish()}),ha=zod.z.object({Battle:th.nullish(),Resources:D.nullish(),ResourcesDual:gt.nullish()}),js=zod.z.object({Matches:zod.z.array(ua).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}),tt={CreateMatch:"CreateMatch",UpdateMatch:"UpdateMatch",CancelMatch:"CancelMatch",InstantBattle:"InstantBattle",SaveStrategy:"SaveStrategy",GetMyMatches:"GetMyMatches",GetAvailableMatches:"GetAvailableMatches",GetDefinitions:"GetDefinitions"};var ih=zod.z.enum(["VirtualCurrency","Item","EventToken"]).catch("VirtualCurrency");var rh=zod.z.enum(["Constant","Variable","Curve"]).catch("Constant"),sh=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(),nh=zod.z.enum(["Flat","PercentReduction"]).catch("Flat"),oh=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(),ArmorMode:nh.nullish(),MaxArmorReduction:zod.z.number().nullish()}).passthrough(),ah=zod.z.object({Kind:rh.nullish(),Constant:zod.z.number().nullish(),VariableID:zod.z.string().nullish(),Argument:zod.z.string().nullish(),Curve:xe.nullish(),OnePlus:zod.z.boolean().nullish()}).passthrough(),lh=zod.z.object({Coefficient:zod.z.number().nullish(),Factors:zod.z.array(ah).nullish()}).passthrough(),yt=zod.z.object({Terms:zod.z.array(lh).nullish()}).passthrough(),uh=zod.z.object({Health:yt.nullish(),Damage:yt.nullish(),Armor:yt.nullish(),AttackSpeed:yt.nullish(),CritChance:yt.nullish(),CritDamage:yt.nullish(),Dodge:yt.nullish()}).passthrough(),ma=zod.z.object({StatMapping:sh.nullish(),Combat:oh.nullish(),Formula:uh.nullish()}).passthrough(),ch=zod.z.object({BurnRate:zod.z.number().nullish()}).passthrough(),Fs=zod.z.object({Kind:ih.nullish(),CurrencyID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),TokenType:ri.nullish(),EntityID:zod.z.string().nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish()}).passthrough(),fa=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(Fs).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),ga=zod.z.object({PriceOptions:J.nullish(),RefundCostOnCancel:zod.z.boolean().nullish(),MaxOpenMatches:zod.z.number().nullish(),Limits:ue.nullish(),AllowPrivateMatches:zod.z.boolean().nullish(),MaxMatchesPerOpponentPerDay:zod.z.number().nullish()}).passthrough(),ph=zod.z.object({RuleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Economy:ch.nullish(),Entry:fa.nullish(),Creation:ga.nullish(),Settings:ma.nullish()}).passthrough(),dh=zod.z.object({Rules:zod.z.record(zod.z.string(),ph).nullish(),Defaults:ma.nullish(),EntryDefaults:fa.nullish(),CreationDefaults:ga.nullish()}).passthrough(),Vs=zod.z.object({InstantBattle:dh.nullish()}).passthrough(),Ra=Vs;var hh={Listing:"Listing",Auction:"Auction",BuyOrder:"BuyOrder",DirectTrade:"DirectTrade"},_s=zod.z.enum(["Listing","Auction","BuyOrder","DirectTrade"]).catch("Listing"),mh={Active:"Active",Completed:"Completed",Cancelled:"Cancelled",Declined:"Declined",Expired:"Expired"},Ws=zod.z.enum(["Active","Completed","Cancelled","Declined","Expired"]).catch("Active"),fh={Burn:"Burn",Ledger:"Ledger"},gh=zod.z.enum(["Burn","Ledger"]).catch("Burn"),nr={Item:"Item",VirtualCurrency:"VirtualCurrency"},Qs=zod.z.enum(["Item","VirtualCurrency"]).catch("Item"),Rh=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:w.nullish()}).passthrough(),yh=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(Fs).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),Ch=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:w.nullish(),Sink:gh.nullish(),LedgerAccountID:zod.z.string().nullish(),PerCatalogOverrides:zod.z.record(zod.z.string(),Rh).nullish(),ApplyToDirectTrades:zod.z.boolean().nullish()}).passthrough(),Sh=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(),xh=zod.z.object({Enabled:zod.z.boolean().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),MaxActiveListings:zod.z.number().nullish(),CreateLimits:ue.nullish(),BuyLimits:ue.nullish(),ListingFeeOptions:J.nullish(),RefundListingFeeOnCancel:zod.z.boolean().nullish()}).passthrough(),bh=zod.z.object({Enabled:zod.z.boolean().nullish(),MinDurationHours:zod.z.number().nullish(),MaxDurationHours:zod.z.number().nullish(),AntiSnipeWindowSeconds:zod.z.number().nullish(),AntiSnipeExtensionSeconds:zod.z.number().nullish(),MaxAntiSnipeExtensions:zod.z.number().nullish(),MinBidStepPercent:zod.z.number().nullish(),MinBidStepAbsolute:w.nullish(),BidLimits:ue.nullish()}).passthrough(),Dh=zod.z.object({Enabled:zod.z.boolean().nullish(),MaxActiveOrders:zod.z.number().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),CreateLimits:ue.nullish(),FillLimits:ue.nullish()}).passthrough(),vh=zod.z.object({Enabled:zod.z.boolean().nullish(),OfferExpirationHours:zod.z.number().nullish(),MaxPendingOutgoing:zod.z.number().nullish(),AllowGifts:zod.z.boolean().nullish(),CreateLimits:ue.nullish()}).passthrough(),zh=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),Ks=zod.z.object({Enabled:zod.z.boolean().nullish(),Gate:W.nullish(),Schedule:de.nullish(),PricePolicy:yh.nullish(),Commission:Ch.nullish(),Tradability:Sh.nullish(),Listings:xh.nullish(),Auctions:bh.nullish(),BuyOrders:Dh.nullish(),DirectTrades:vh.nullish(),Matching:zh.nullish()}).passthrough(),ya=zod.z.object({BidIndex:zod.z.number().nullish(),UserID:zod.z.string().nullish(),Amount:w.nullish(),Settled:zod.z.boolean().nullish(),SettledAt:u.nullish()}).passthrough(),Th=zod.z.object({BidAxisType:ei.nullish(),BidCurrencyID:zod.z.string().nullish(),BidCatalogID:zod.z.string().nullish(),BidItemID:zod.z.string().nullish(),StartingBid:w.nullish(),CurrentBid:w.nullish(),CurrentBidderID:zod.z.string().nullish(),BidCount:zod.z.number().nullish(),ExtensionCount:zod.z.number().nullish(),PendingRefunds:zod.z.array(ya).nullish()}).passthrough(),sr=zod.z.object({LastAt:u.nullish(),DailyCount:zod.z.number().nullish(),DailyResetUtc:u.nullish()}).passthrough(),Ph=zod.z.object({Create:sr.nullish(),Buy:sr.nullish(),Sell:sr.nullish(),Bid:sr.nullish()}).passthrough(),Ih=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),kh=zod.z.object({ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Quantity:zod.z.number().nullish(),RemainingUses:zod.z.number().nullish(),Level:zod.z.number().nullish(),AcquiredAt:u,ExpiresAt:u.nullish(),EquippedSlot:Ih.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(o=>o),nt=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:_s.nullish(),Status:Ws.nullish(),CreatorUserID:zod.z.string().nullish(),CreatorPublicData:ze.nullish(),TargetUserID:zod.z.string().nullish(),GoodsType:Qs.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:w.nullish(),GoodsInstances:zod.z.array(kh).nullish(),Price:ge.nullish(),Auction:Th.nullish(),CreatedAt:u.nullish(),ExpiresAt:u.nullish()}).passthrough(),Mh=zod.z.object({GoodsType:Qs.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),CountsByType:zod.z.record(_s,w).nullish(),ListingCount:w.nullish(),AuctionCount:w.nullish(),BuyOrderCount:w.nullish()}).passthrough(),Ca=zod.z.object({Definitions:Ks.nullish(),IsOpenNow:zod.z.boolean().nullish(),GatePassed:zod.z.boolean().nullish()}).passthrough(),Hs=zod.z.object({Offers:zod.z.array(nt).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),Sa=zod.z.object({Groups:zod.z.array(Mh).nullish()}).passthrough(),xa=zod.z.object({Offer:nt.nullish()}).passthrough(),Ge=zod.z.object({OfferID:zod.z.string().nullish(),Status:Ws.nullish(),Settlement:gt.nullish(),Resources:D.nullish(),CommissionTaken:ge.nullish()}).passthrough(),Qt=zod.z.object({OfferID:zod.z.string().nullish(),Offer:nt.nullish(),Resources:D.nullish(),Matched:zod.z.boolean().nullish(),Settlement:Ge.nullish()}).passthrough(),ba=zod.z.object({OfferID:zod.z.string().nullish(),CurrentBid:w.nullish(),BidCount:zod.z.number().nullish(),ExpiresAt:u.nullish(),Resources:D.nullish()}).passthrough(),Da=zod.z.object({MyOffers:zod.z.array(nt).nullish(),MyLeadingBids:zod.z.array(nt).nullish(),MyBuyOrders:zod.z.array(nt).nullish(),IncomingTrades:zod.z.array(nt).nullish(),OutgoingTrades:zod.z.array(nt).nullish(),Claimables:zod.z.array(nt).nullish(),DrainedRefunds:zod.z.array(ya).nullish(),Limits:Ph.nullish()}).passthrough(),wh=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:_s.nullish(),FinalStatus:Ws.nullish(),SellerUserID:zod.z.string().nullish(),BuyerUserID:zod.z.string().nullish(),GoodsType:Qs.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:w.nullish(),PricePaid:ge.nullish(),CommissionTaken:ge.nullish(),CompletedAt:u.nullish()}).passthrough(),va=zod.z.object({Entries:zod.z.array(wh).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),ae={GetDefinitions:"GetDefinitions",GetGroupedOffers:"GetGroupedOffers",GetOffersByItem:"GetOffersByItem",GetOffer:"GetOffer",GetBuyOrders:"GetBuyOrders",GetMyState:"GetMyState",GetHistory:"GetHistory",CreateListing:"CreateListing",CancelListing:"CancelListing",Buy:"Buy",MarketBuy:"MarketBuy",MarketSell:"MarketSell",CreateAuction:"CreateAuction",PlaceBid:"PlaceBid",ClaimAuction:"ClaimAuction",CreateBuyOrder:"CreateBuyOrder",CancelBuyOrder:"CancelBuyOrder",FillBuyOrder:"FillBuyOrder",CreateDirectTrade:"CreateDirectTrade",RespondDirectTrade:"RespondDirectTrade",CancelDirectTrade:"CancelDirectTrade",ClaimBack:"ClaimBack"};var Ah="Marketplace",or=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(Ah,t.data.Definitions),this.ctx.emitter.emit("marketplace:definitionsLoaded",t.data)),t}async getGroupedOffers(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.marketplace.getGroupedOffers(e);return t.ok&&this.ctx.emitter.emit("marketplace:groupedOffersLoaded",t.data),t}async getOffersByItem(e,t,i,r=20){if(!e)return n("client","ItemID is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.ItemID=e,s.OfferTypeFilter=t,s.ContinuationToken=i,s.PageSize=r;let a=await this.ctx.api.marketplace.getOffersByItem(s);return a.ok&&this.ctx.emitter.emit("marketplace:offersByItemLoaded",a.data),a}async getOffer(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.getOffer(t);return i.ok&&this.ctx.emitter.emit("marketplace:offerLoaded",i.data),i}async getBuyOrders(e,t,i=20){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.ItemID=e,r.ContinuationToken=t,r.PageSize=i;let s=await this.ctx.api.marketplace.getBuyOrders(r);return s.ok&&this.ctx.emitter.emit("marketplace:buyOrdersLoaded",s.data),s}async getMyState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.marketplace.getMyState(e);return t.ok&&(this.ctx.data.user.applyMarketplaceState(t.data.Limits??null),this.ctx.emitter.emit("marketplace:myStateLoaded",t.data)),t}async getHistory(e,t=20){let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.ContinuationToken=e,i.PageSize=t;let r=await this.ctx.api.marketplace.getHistory(i);return r.ok&&this.ctx.emitter.emit("marketplace:historyLoaded",r.data),r}async createListing(e,t,i,r,s,a,p){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");if(!r)return n("client","PriceBundle is required.");let x=this.baseRequest();if(!x)return n("unauthorized","Not logged in.");x.ItemID=e,x.CatalogID=t,x.GoodsAmount=i,x.PriceBundle=r,x.DurationHours=s,x.ItemInstanceIDs=a,x.SelectedOptionID=p;let M=await this.ctx.api.marketplace.createListing(x);return this.applyCreateOfferResult(M,"marketplace:listingCreated"),M}async cancelListing(e){return this.cancelOffer(e,t=>this.ctx.api.marketplace.cancelListing(t),"marketplace:listingCancelled")}async buy(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.buy(t);return i.ok&&(this.applyDualPartySettlement(i.data.Settlement),this.ctx.emitter.emit("marketplace:bought",i.data)),i}async marketBuy(e,t,i){if(!e||e<=0)return n("client","GoodsAmount must be positive.");if(!t)return n("client","PriceBundle is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");let s=this.applyGoodsSelector(r,i);if(s)return s;r.GoodsAmount=e,r.PriceBundle=t;let a=await this.ctx.api.marketplace.marketBuy(r);return a.ok&&(this.applyDualPartySettlement(a.data.Settlement),this.ctx.emitter.emit("marketplace:marketBought",a.data)),a}async marketSell(e,t,i){if(!e||e<=0)return n("client","GoodsAmount must be positive.");if(!t)return n("client","PriceBundle is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");let s=this.applyGoodsSelector(r,i);if(s)return s;r.GoodsAmount=e,r.PriceBundle=t;let a=await this.ctx.api.marketplace.marketSell(r);return a.ok&&(this.applyDualPartySettlement(a.data.Settlement),this.ctx.emitter.emit("marketplace:marketSold",a.data)),a}async createAuction(e,t,i,r,s,a,p={}){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");let x=this.baseRequest();if(!x)return n("unauthorized","Not logged in.");x.ItemID=e,x.CatalogID=t,x.GoodsAmount=i,x.BidAxisType=r,x.BidCurrencyID=p.bidCurrencyID,x.BidCatalogID=p.bidCatalogID,x.BidItemID=p.bidItemID,x.StartingBid=s,x.DurationHours=a,x.ItemInstanceIDs=p.itemInstanceIDs,x.SelectedOptionID=p.selectedOptionID;let M=await this.ctx.api.marketplace.createAuction(x);return this.applyCreateOfferResult(M,"marketplace:auctionCreated"),M}async placeBid(e,t){if(!e)return n("client","OfferID is required.");if(!t||t<=0)return n("client","BidAmount must be positive.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.OfferID=e,i.BidAmount=t;let r=await this.ctx.api.marketplace.placeBid(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:bidPlaced",r.data)),r}async claimAuction(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.claimAuction(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:auctionClaimed",i.data)),i}async createBuyOrder(e,t,i,r,s){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");if(!r)return n("client","PriceBundle is required.");let a=this.baseRequest();if(!a)return n("unauthorized","Not logged in.");a.ItemID=e,a.CatalogID=t,a.GoodsAmount=i,a.PriceBundle=r,a.DurationHours=s;let p=await this.ctx.api.marketplace.createBuyOrder(a);return this.applyCreateOfferResult(p,"marketplace:buyOrderCreated"),p}async cancelBuyOrder(e){return this.cancelOffer(e,t=>this.ctx.api.marketplace.cancelBuyOrder(t),"marketplace:buyOrderCancelled")}async fillBuyOrder(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.fillBuyOrder(t);return i.ok&&(this.applyDualPartySettlement(i.data.Settlement),this.ctx.emitter.emit("marketplace:buyOrderFilled",i.data)),i}async createDirectTrade(e,t,i,r,s){if(!e)return n("client","TargetUserID is required.");if(!t)return n("client","CatalogID is required.");if(!i)return n("client","ItemID is required.");let a=this.baseRequest();if(!a)return n("unauthorized","Not logged in.");a.TargetUserID=e,a.CatalogID=t,a.ItemID=i,a.ItemInstanceIDs=r,a.RequestedBundle=s;let p=await this.ctx.api.marketplace.createDirectTrade(a);return this.applyCreateOfferResult(p,"marketplace:directTradeCreated"),p}async respondDirectTrade(e,t){if(!e)return n("client","OfferID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.OfferID=e,i.Accept=t;let r=await this.ctx.api.marketplace.respondDirectTrade(i);return r.ok&&(t&&(r.data.Settlement?this.applyDualPartySettlement(r.data.Settlement):r.data.Resources&&this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions)),this.ctx.emitter.emit("marketplace:directTradeResponded",r.data)),r}async cancelDirectTrade(e){return this.cancelOffer(e,t=>this.ctx.api.marketplace.cancelDirectTrade(t),"marketplace:directTradeCancelled")}async claimBack(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.claimBack(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:claimedBack",i.data)),i}async cancelOffer(e,t,i){if(!e)return n("client","OfferID is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.OfferID=e;let s=await t(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit(i,s.data)),s}applyCreateOfferResult(e,t){e.ok&&(e.data.Matched&&e.data.Settlement?this.applyDualPartySettlement(e.data.Settlement.Settlement):this.ctx.data.user.applyResourceOperation(e.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit(t,e.data));}applyGoodsSelector(e,t){return "goodsCurrencyID"in t&&t.goodsCurrencyID?(e.GoodsType=nr.VirtualCurrency,e.GoodsCurrencyID=t.goodsCurrencyID,null):"itemID"in t&&t.itemID&&t.catalogID?(e.GoodsType=nr.Item,e.ItemID=t.itemID,e.CatalogID=t.catalogID,null):n("client","Either itemID+catalogID or goodsCurrencyID is required.")}applyDualPartySettlement(e){let t=this.ctx.auth.context?.userID;if(!e||!t)return;let i=this.ctx.data.config.itemDefinitions;e.FromUserID===t&&e.FromResult?this.ctx.data.user.applyResourceOperation(e.FromResult,i):e.ToUserID===t&&e.ToResult&&this.ctx.data.user.applyResourceOperation(e.ToResult,i);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var ar=class{constructor(e){this.ctx=e;}ctx;async createRoom(e,t={}){if(!e)return n("client","RoomName is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomName=e,i.Topology=t.topology,i.ChatMode=t.chatMode,i.MaxPlayers=t.maxPlayers,i.Visibility=t.visibility,i.JoinCode=t.joinCode;let r=await this.ctx.api.multiplayer.createRoom(i);return r.ok&&this.ctx.emitter.emit("multiplayer:roomCreated",r.data),r}async joinRoom(e,t){if(!e)return n("client","RoomID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.JoinCode=t;let r=await this.ctx.api.multiplayer.joinRoom(i);return r.ok&&this.ctx.emitter.emit("multiplayer:roomJoined",r.data),r}async leaveRoom(e){if(!e)return n("client","RoomID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.RoomID=e;let i=await this.ctx.api.multiplayer.leaveRoom(t);return i.ok&&this.ctx.emitter.emit("multiplayer:roomLeft",i.data),i}async listRooms(e=0,t=20){let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.Page=e,i.PageSize=t;let r=await this.ctx.api.multiplayer.listRooms(i);return r.ok&&this.ctx.emitter.emit("multiplayer:roomsListed",r.data),r}async getRoom(e){if(!e)return n("client","RoomID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.RoomID=e;let i=await this.ctx.api.multiplayer.getRoom(t);return i.ok&&this.ctx.emitter.emit("multiplayer:roomLoaded",i.data),i}async closeRoom(e){if(!e)return n("client","RoomID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.RoomID=e;let i=await this.ctx.api.multiplayer.closeRoom(t);return i.ok&&this.ctx.emitter.emit("multiplayer:roomClosed",i.data),i}async poll(e,t){if(!e)return n("client","RoomID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.LastSeq=t;let r=await this.ctx.api.multiplayer.poll(i);return r.ok&&this.ctx.emitter.emit("multiplayer:polled",r.data),r}async sendSignal(e,t,i,r){if(!e)return n("client","RoomID is required.");if(!t)return n("client","TargetUserID is required.");if(!i)return n("client","SignalKind is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomID=e,s.TargetUserID=t,s.SignalKind=i,s.Payload=r;let a=await this.ctx.api.multiplayer.sendSignal(s);return a.ok&&this.ctx.emitter.emit("multiplayer:signalSent",a.data),a}async sendChat(e,t){if(!e)return n("client","RoomID is required.");if(!t)return n("client","ChatText is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.ChatText=t;let r=await this.ctx.api.multiplayer.sendChat(i);return r.ok&&this.ctx.emitter.emit("multiplayer:chatSent",r.data),r}async setMemberState(e,t,i){if(!e)return n("client","RoomID is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.RoomID=e,r.Ready=t,r.MemberState=i;let s=await this.ctx.api.multiplayer.setMemberState(r);return s.ok&&this.ctx.emitter.emit("multiplayer:memberStateSet",s.data),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var za=zod.z.object({PlatformUserID:zod.z.string().nullish(),PlatformAuthToken:zod.z.string().nullish(),PlatformAuthTokenExpiration:u.nullish(),TitleUserID:zod.z.string(),TitleClientSessionTicket:zod.z.string(),TitleClientSessionTicketExpiration:u}),Ta=zod.z.object({CodeTtlMinutes:zod.z.number().nullish(),ResendCooldownSeconds:zod.z.number().nullish()}),be=zod.z.object({IsCompleted:zod.z.boolean().nullish(),ServerTime:u.nullish()}),Pa=zod.z.object({Message:zod.z.string(),ExpiresAt:u}),we={LoginWithDeviceID:"LoginWithDeviceID",LoginWithTelegram:"LoginWithTelegram",LoginWithEmail:"LoginWithEmail",LoginWithGoogle:"LoginWithGoogle",LoginWithSsoCode:"LoginWithSsoCode",RegisterWithEmail:"RegisterWithEmail",ConfirmEmailRegistration:"ConfirmEmailRegistration",ResendVerificationCode:"ResendVerificationCode",RequestWalletChallenge:"RequestWalletChallenge",LoginWithWallet:"LoginWithWallet",ForgotPassword:"ForgotPassword",ResetPassword:"ResetPassword"};function O(o,e,t,i){let s=`api/v2/${o&&o.length>0?o:"0"}/Client/${e}/${t}`;return i==null?s:`${s}/${i}`}var lr=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,za,{ticket:null})}loginWithDeviceID(e){return this.login(we.LoginWithDeviceID,e)}loginWithTelegram(e){return this.login(we.LoginWithTelegram,e)}loginWithEmail(e){return this.login(we.LoginWithEmail,e)}loginWithGoogle(e){return this.login(we.LoginWithGoogle,e)}loginWithSsoCode(e){return this.login(we.LoginWithSsoCode,e)}registerWithEmail(e){return this.ctx.transport.post(this.endpoint(we.RegisterWithEmail),e,Ta,{ticket:null})}confirmEmailRegistration(e){return this.login(we.ConfirmEmailRegistration,e)}resendVerificationCode(e){return this.ctx.transport.post(this.endpoint(we.ResendVerificationCode),e,be,{ticket:null})}requestWalletChallenge(e){return this.ctx.transport.post(this.endpoint(we.RequestWalletChallenge),e,Pa,{ticket:null})}loginWithWallet(e){return this.login(we.LoginWithWallet,e)}forgotPassword(e){return this.ctx.transport.post(this.endpoint(we.ForgotPassword),e,be,{ticket:null})}resetPassword(e){return this.ctx.transport.post(this.endpoint(we.ResetPassword),e,be,{ticket:null})}};var Oh={ReturnKey:"ReturnKey",ReturnMarkedKey:"ReturnMarkedKey",ReturnEmpty:"ReturnEmpty"},Ia=zod.z.enum(["ReturnKey","ReturnMarkedKey","ReturnEmpty"]).catch("ReturnKey"),Uh=zod.z.object({Locale:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Order:zod.z.number().nullish()}).passthrough(),ka=zod.z.object({IsEnabled:zod.z.boolean().nullish(),DefaultLocale:zod.z.string().nullish(),Locales:zod.z.record(zod.z.string(),Uh).nullish(),MissingKeyMode:Ia.nullish(),MaxEntriesPerLocale:zod.z.number().nullish(),MaxValueLengthBytes:zod.z.number().nullish()}).passthrough(),Bh=zod.z.object({Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),Url:zod.z.string().nullish()}).passthrough(),Ma=zod.z.object({Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),Url:zod.z.string().nullish(),Fallback:Bh.nullish()}).passthrough(),ur={GetLocalizationManifest:"GetLocalizationManifest",GetLocalizationTable:"GetLocalizationTable"},Lh=zod.z.object({Locale:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Order:zod.z.number().nullish(),Version:zod.z.number().nullish()}).passthrough(),wa=zod.z.object({IsEnabled:zod.z.boolean().nullish(),DefaultLocale:zod.z.string().nullish(),MissingKeyMode:Ia.nullish(),ResolvedLocale:zod.z.string().nullish(),Locales:zod.z.array(Lh).nullish()}).passthrough(),Aa=zod.z.object({RequestedLocale:zod.z.string().nullish(),Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),NotModified:zod.z.boolean().nullish(),Entries:zod.z.record(zod.z.string(),zod.z.string()).nullish(),FallbackLocale:zod.z.string().nullish(),FallbackVersion:zod.z.number().nullish()}).passthrough();var $s=zod.z.object({TitleConfigVersion:zod.z.string().nullish(),TitleConfigUrl:zod.z.string().nullish(),User:zod.z.unknown().nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish(),StateEpoch:zod.z.string().nullish(),Localization:Ma.nullish()}).passthrough().transform(o=>o),Oa=zod.z.object({StateEpoch:zod.z.string().nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough().transform(o=>o),Ua=zod.z.object({StateEpoch:zod.z.string().nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish(),User:zod.z.unknown().nullish()}).passthrough().transform(o=>o),Ba=zod.z.object({}).passthrough().transform(o=>o),La=zod.z.object({}).passthrough().transform(o=>o),qa=zod.z.object({Today:zod.z.number(),Yesterday:zod.z.number(),CurrentWeek:zod.z.number(),CurrentMonth:zod.z.number(),Total:zod.z.number(),TotalSessions:zod.z.number(),FirstActiveAt:u.nullish(),LastActiveAt:u.nullish(),LongestSessionEverSeconds:zod.z.number().nullish(),CurrentWeekActiveHoursMask:zod.z.number().nullish(),CurrentMonthActiveHoursMask:zod.z.number().nullish(),ReactivationCount:zod.z.number().nullish(),History:zod.z.record(zod.z.string(),zod.z.unknown()).nullish()}).passthrough(),Ea=zod.z.object({Username:zod.z.string()}),je={GetClientState:"GetClientState",GetClientStateExcept:"GetClientStateExcept",GetStateVersions:"GetStateVersions",GetUserState:"GetUserState",GetInventory:"GetInventory",GetEventTokens:"GetEventTokens",GetUsageTime:"GetUsageTime",AddUsageTime:"AddUsageTime",DeleteUserAccount:"DeleteUserAccount",ChangeUsername:"ChangeUsername"};var cr=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,$s,{ticket:e.ClientSessionTicket})}getClientStateExcept(e){return this.ctx.transport.post(this.endpoint(je.GetClientStateExcept,e.UserID),e,$s,{ticket:e.ClientSessionTicket})}getStateVersions(e){return this.ctx.transport.post(this.endpoint(je.GetStateVersions,e.UserID),e,Oa,{ticket:e.ClientSessionTicket})}getUserState(e){return this.ctx.transport.post(this.endpoint(je.GetUserState,e.UserID),e,Ua,{ticket:e.ClientSessionTicket})}getInventory(e){return this.ctx.transport.post(this.endpoint(je.GetInventory,e.UserID),e,Ba,{ticket:e.ClientSessionTicket})}getEventTokens(e){return this.ctx.transport.post(this.endpoint(je.GetEventTokens,e.UserID),e,La,{ticket:e.ClientSessionTicket})}getUsageTime(e){return this.ctx.transport.post(this.endpoint(je.GetUsageTime,e.UserID),e,qa,{ticket:e.ClientSessionTicket})}addUsageTime(e){return this.ctx.transport.post(this.endpoint(je.AddUsageTime,e.UserID),e,be,{ticket:e.ClientSessionTicket,silent:true})}deleteUserAccount(e){return this.ctx.transport.post(this.endpoint(je.DeleteUserAccount,e.UserID),e,be,{ticket:e.ClientSessionTicket})}changeUsername(e){return this.ctx.transport.post(this.endpoint(je.ChangeUsername,e.UserID),e,Ea,{ticket:e.ClientSessionTicket})}};var pr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Currency",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}convert(e){return this.send(Ji.Convert,e,Po)}cryptoConvert(e){return this.send(Ji.CryptoConvert,e,Io)}};var qh=zod.z.object({ItemInstanceID:zod.z.string(),Units:zod.z.number(),Level:zod.z.number()}),Zs=zod.z.object({ServerTimeUtc:u,ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Level:zod.z.number(),Resources:D.nullish(),FodderConsumed:zod.z.array(qh).nullish()}),Ga=zod.z.array(re(Zs)),dr={UpgradeLevel:"UpgradeLevel",UpgradeLevelsBatch:"UpgradeLevelsBatch"},Eh={FlatCount:"FlatCount",Merge:"Merge",InvestmentRefund:"InvestmentRefund"},Gh=zod.z.enum(["FlatCount","Merge","InvestmentRefund"]).catch("FlatCount"),Nh={ProtectLeveled:"ProtectLeveled",CheapestFirst:"CheapestFirst",ClientSelected:"ClientSelected",SameLevelOnly:"SameLevelOnly"},jh=zod.z.enum(["ProtectLeveled","CheapestFirst","ClientSelected","SameLevelOnly"]).catch("ProtectLeveled"),Fh=zod.z.object({ContractAddress:zod.z.string().nullish(),TokenID:zod.z.string().nullish(),TokenStandard:zod.z.string().nullish()}).passthrough(),Vh=zod.z.object({Networks:zod.z.record(zod.z.string(),Fh).nullish(),MetadataUrl:zod.z.string().nullish()}).passthrough(),_h=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(),Wh=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(),Qh=zod.z.object({ValuationMode:Gh.nullish(),WeightCurve:xe.nullish(),Selection:jh.nullish()}).passthrough(),Kh=zod.z.object({MaxLevel:zod.z.number().nullish(),PriceOptions:J.nullish(),CostCurve:xe.nullish(),FlatBonusCurve:xe.nullish(),PercentBonusCurve:xe.nullish(),PowerCurve:xe.nullish(),Fodder:Qh.nullish()}).passthrough(),Hh=zod.z.object({RarityID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),AuthorID:zod.z.string().nullish()}).passthrough(),$h=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:Vh.nullish(),Stats:_h.nullish(),Equipment:Wh.nullish(),Upgrade:Kh.nullish(),Metadata:Hh.nullish(),ExpirationDurationSeconds:zod.z.number().nullish()}).passthrough(),Zh=zod.z.object({Items:zod.z.record(zod.z.string(),$h).nullish()}).passthrough(),hr=zod.z.object({Catalogs:zod.z.record(zod.z.string(),Zh).nullish()}).passthrough();var mr=class{constructor(e){this.ctx=e;}ctx;upgradeLevel(e){let t=O(this.ctx.settings.titleID,"Item",dr.UpgradeLevel,e.UserID??"");return this.ctx.transport.post(t,e,Zs,{ticket:e.ClientSessionTicket})}upgradeLevelsBatch(e){let t=O(this.ctx.settings.titleID,"Item",dr.UpgradeLevelsBatch,e.UserID??"");return this.ctx.transport.post(t,e,Ga,{ticket:e.ClientSessionTicket})}};var Js=zod.z.object({ServerTimeUtc:u,OfferID:zod.z.string(),Count:zod.z.number(),Resources:D.nullish()}),Na=zod.z.array(re(Js)),Jh=zod.z.object({OfferID:zod.z.string(),TotalPurchases:zod.z.number(),DailyPurchases:zod.z.number(),DailyResetUtc:u,LastPurchasedAt:u}),ja=zod.z.object({Purchases:zod.z.record(zod.z.string(),Jh).nullish()}).passthrough().transform(o=>o),Yh=zod.z.object({StartUtc:u.nullish(),EndUtc:u.nullish(),RequiredFlags:zod.z.array(zod.z.string()).nullish()}).passthrough(),Xh=zod.z.object({StoreID:zod.z.string(),Type:zod.z.string().nullish(),Name:zod.z.string().nullish(),Description:zod.z.string().nullish(),Rules:Yh.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),em=zod.z.object({StartUtc:u.nullish(),EndUtc:u.nullish(),Gate:W.nullish(),Limits:ue.nullish()}).passthrough(),tm=zod.z.object({OfferID:zod.z.string(),StoreIDs:zod.z.array(zod.z.string()).nullish(),Name:zod.z.string().nullish(),PriceOptions:J.nullish(),Rewards:L.nullish(),Rules:em.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),fr=zod.z.object({Stores:zod.z.record(zod.z.string(),Xh).nullish(),StoreOffers:zod.z.record(zod.z.string(),tm).nullish()}).passthrough(),Ot={Purchase:"Purchase",GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",PurchaseBatch:"PurchaseBatch"};var gr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Store",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}purchase(e){return this.send(Ot.Purchase,e,Js)}purchaseBatch(e){return this.send(Ot.PurchaseBatch,e,Na)}getDefinitions(e){return this.send(Ot.GetDefinitions,e,fr)}getUserState(e){return this.send(Ot.GetUserState,e,ja)}};var im={Consumable:"Consumable",NonConsumable:"NonConsumable",Subscription:"Subscription"},rm=zod.z.enum(["Consumable","NonConsumable","Subscription"]).catch("Consumable"),sm=zod.z.object({StartUtc:u.nullish(),EndUtc:u.nullish(),Gate:W.nullish(),Limits:ue.nullish()}).passthrough(),nm=zod.z.object({ResourceAction:zod.z.string().nullish(),RevokeEntitlement:zod.z.boolean().nullish(),BlockFuturePurchases:zod.z.boolean().nullish()}).passthrough(),om=zod.z.object({ProductID:zod.z.string().nullish(),Name:zod.z.string().nullish(),Type:rm.nullish(),Enabled:zod.z.boolean().nullish(),StoreProductIDs:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rewards:L.nullish(),PriceUsdCents:zod.z.number().nullish(),Rules:sm.nullish(),Refund:nm.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Fa=zod.z.object({Enabled:zod.z.boolean().nullish(),Products:zod.z.record(zod.z.string(),om).nullish()}).passthrough(),Va=zod.z.object({ProductID:zod.z.string().nullish(),TotalPurchases:zod.z.number().nullish(),DailyPurchases:zod.z.number().nullish(),DailyResetUtc:u.nullish(),LastPurchasedAt:u.nullish(),Owned:zod.z.boolean().nullish(),Refunded:zod.z.boolean().nullish(),PurchaseBlocked:zod.z.boolean().nullish()}).passthrough(),_a=zod.z.object({Products:zod.z.record(zod.z.string(),Va).nullish(),LifetimeSpendUsdCents:zod.z.number().nullish()}).passthrough(),am={Granted:"Granted",Restored:"Restored",AlreadyProcessed:"AlreadyProcessed"},lm=zod.z.enum(["Granted","Restored","AlreadyProcessed"]).catch("Granted"),Ys=zod.z.object({ServerTimeUtc:u,Store:ii.nullish(),ProductID:zod.z.string().nullish(),TransactionID:zod.z.string().nullish(),Status:lm.nullish(),Granted:zod.z.boolean().nullish(),Quantity:zod.z.number().nullish(),Resources:D.nullish(),ProductState:Va.nullish()}).passthrough(),Wa=Xe(Ys),Ut={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ValidatePurchase:"ValidatePurchase",ValidatePurchasesBatch:"ValidatePurchasesBatch"};var Rr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Purchase",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ut.GetDefinitions,e,Fa)}getUserState(e){return this.send(Ut.GetUserState,e,_a)}validatePurchase(e){return this.send(Ut.ValidatePurchase,e,Ys)}validatePurchasesBatch(e){return this.send(Ut.ValidatePurchasesBatch,e,Wa)}};var um=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),Qa=zod.z.object({Reward:L.nullish(),Weight:zod.z.number().nullish(),AmountRange:um.nullish()}).passthrough(),Bt=zod.z.object({SlotID:zod.z.string().nullish(),MinRolls:zod.z.number().nullish(),MaxRolls:zod.z.number().nullish(),Pool:zod.z.array(Qa).nullish()}).passthrough(),Lt=zod.z.object({RuleID:zod.z.string().nullish(),Threshold:zod.z.number().nullish(),Pool:zod.z.array(Qa).nullish()}).passthrough(),cm=zod.z.object({RewardSlots:zod.z.array(Bt).nullish()}).passthrough(),pm=zod.z.object({PityRules:zod.z.array(Lt).nullish()}).passthrough(),yr=zod.z.object({SlotPresets:zod.z.record(zod.z.string(),cm).nullish(),PityPresets:zod.z.record(zod.z.string(),pm).nullish()}).passthrough();var dm=zod.z.object({RuleID:zod.z.string(),BoxIndex:zod.z.number().nullish()}),Ka=zod.z.object({ServerTimeUtc:u,LootboxID:zod.z.string(),OpenedCount:zod.z.number().nullish(),SelectedOptionID:zod.z.string().nullish(),Resources:D.nullish(),Inventory:pt.nullish(),Results:zod.z.array(D).nullish(),TriggeredPity:zod.z.array(dm).nullish()}),hm=zod.z.object({RewardSlots:Y.nullish(),PityRules:Y.nullish()}).passthrough(),mm=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),MaxDrops:w.nullish()}).passthrough(),fm=zod.z.object({LootboxID:zod.z.string(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),PriceOptions:J.nullish(),RewardSlots:zod.z.array(Bt).nullish(),PityRules:zod.z.array(Lt).nullish(),Presets:hm.nullish(),RewardMultiplier:si.nullish(),SupplyLimits:zod.z.array(mm).nullish(),MaxOpenCount:zod.z.number().nullish()}).passthrough(),Xs=zod.z.object({Definitions:zod.z.record(zod.z.string(),fm).nullish(),RewardPools:yr.nullish()}).passthrough(),Ha=zod.z.object({LootboxDefinitions:Xs.nullish()}),Cr={GetDefinitions:"GetDefinitions",Open:"Open"};var Sr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Lootbox",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Cr.GetDefinitions,e,Ha)}open(e){return this.send(Cr.Open,e,Ka)}};var gm=zod.z.object({}).passthrough().transform(o=>o),Rm=zod.z.object({}).passthrough().transform(o=>o),ym=zod.z.object({}).passthrough().transform(o=>o),Cm=zod.z.object({}).passthrough().transform(o=>o),Sm=zod.z.object({}).passthrough().transform(o=>o),$a=zod.z.object({ServerTimeUtc:u,CalendarID:zod.z.string(),DayNumber:zod.z.number().nullish(),DailyState:gm,Resources:D.nullish()}),Za=zod.z.object({ServerTimeUtc:u,AccrualID:zod.z.string(),AccruedSeconds:w.nullish(),AppliedRatePerSecond:zod.z.number().nullish(),IdleState:Rm,Resources:D.nullish()}),Ja=zod.z.object({ServerTimeUtc:u,ComebackID:zod.z.string(),ClaimedTierIndex:zod.z.number().nullish(),ComebackState:ym,Resources:D.nullish()}),Ya=zod.z.object({ServerTimeUtc:u,ClaimID:zod.z.string(),ClaimState:Cm,Resources:D.nullish()}),Xa=zod.z.object({Enabled:zod.z.boolean(),Multiplier:zod.z.number().nullish(),Progress:w.nullish(),Source:zod.z.string().nullish(),SourceKey:zod.z.string().nullish()}),xm=zod.z.object({RewardMode:zod.z.string().nullish(),RewardStackLowerTiers:zod.z.boolean().nullish()}).passthrough(),bm=zod.z.object({DayNumber:zod.z.number().nullish(),Rewards:L.nullish(),IsMilestone:zod.z.boolean().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Dm=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(bm).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:W.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),vm=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),zm=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(vm).nullish()}).passthrough(),Tm=zod.z.object({MinCharacterLevel:zod.z.number().nullish(),RequirementsCharacterID:zod.z.string().nullish(),Gate:W.nullish(),RequiredItemIDs:zod.z.array(zod.z.string()).nullish(),RequiredEquippedItemIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),Pm=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:zm.nullish(),Rewards:L.nullish(),MaxAccumulationSeconds:zod.z.number().nullish(),MinClaimSeconds:zod.z.number().nullish(),Requirements:Tm.nullish(),FirstClaimMode:zod.z.string().nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Im=zod.z.object({MinAbsenceSeconds:zod.z.number().nullish(),Rewards:L.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),km=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(Im).nullish(),ClaimCooldownSeconds:zod.z.number().nullish(),ClaimWindowSeconds:zod.z.number().nullish(),TrackPresenceOnRead:zod.z.boolean().nullish(),Gate:W.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Mm=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(),wm=zod.z.object({ClaimID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Mode:zod.z.string().nullish(),Rewards:L.nullish(),Limits:ue.nullish(),PremiumLimitOverrides:zod.z.array(Mm).nullish(),Gate:W.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),en=zod.z.object({TierRewards:xm.nullish(),MilestoneRewardMultiplier:si.nullish(),DailyCalendars:zod.z.record(zod.z.string(),Dm).nullish(),IdleAccruals:zod.z.record(zod.z.string(),Pm).nullish(),Comebacks:zod.z.record(zod.z.string(),km).nullish(),Claims:zod.z.record(zod.z.string(),wm).nullish()}).passthrough(),el=zod.z.object({RewardDefinitions:en.nullish()}),tl=zod.z.object({Rewards:Sm.nullish()}),ot={GetRewardDefinitions:"GetRewardDefinitions",GetUserRewardsState:"GetUserRewardsState",ClaimDailyReward:"ClaimDailyReward",CollectIdleAccrual:"CollectIdleAccrual",ClaimComebackReward:"ClaimComebackReward",ClaimReward:"ClaimReward",ClaimRewardsBatch:"ClaimRewardsBatch",GetMilestoneRewardMultiplier:"GetMilestoneRewardMultiplier"};var xr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Reward",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getRewardDefinitions(e){return this.send(ot.GetRewardDefinitions,e,el)}getUserRewardsState(e){return this.send(ot.GetUserRewardsState,e,tl)}getMilestoneRewardMultiplier(e){return this.send(ot.GetMilestoneRewardMultiplier,e,Xa)}claimDailyReward(e){return this.send(ot.ClaimDailyReward,e,$a)}collectIdleAccrual(e){return this.send(ot.CollectIdleAccrual,e,Za)}claimComebackReward(e){return this.send(ot.ClaimComebackReward,e,Ja)}claimReward(e){return this.send(ot.ClaimReward,e,Ya)}};var br=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Tutorial",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getTutorialDefinitions(e){return this.send(qe.GetTutorialDefinitions,e,so)}getUserTutorialState(e){return this.send(qe.GetUserTutorialState,e,oo)}startFlow(e){return this.send(qe.StartFlow,e,ct)}reportStepShown(e){return this.send(qe.ReportStepShown,e,ct)}completeStep(e){return this.send(qe.CompleteStep,e,ct)}completeStepsBatch(e){return this.send(qe.CompleteStepsBatch,e,lo)}skipStep(e){return this.send(qe.SkipStep,e,ct)}skipFlow(e){return this.send(qe.SkipFlow,e,ct)}claimFlowReward(e){return this.send(qe.ClaimFlowReward,e,ao)}resetFlow(e){return this.send(qe.ResetFlow,e,ct)}};var Dr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Localization",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket,throttleKey:t.Locale?`${r}:${t.Locale}`:r})}getLocalizationManifest(e){return this.send(ur.GetLocalizationManifest,e,wa)}getLocalizationTable(e){return this.send(ur.GetLocalizationTable,e,Aa)}};var vr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Quest",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getQuestDefinitions(e){return this.send(Qe.GetQuestDefinitions,e,oi)}getUserQuestState(e){return this.send(Qe.GetUserQuestState,e,Qn)}refreshQuestCycles(e){return this.send(Qe.RefreshQuestCycles,e,be)}claimQuestReward(e){return this.send(Qe.ClaimQuestReward,e,gs)}claimQuestRewardsBatch(e){return this.send(Qe.ClaimQuestRewardsBatch,e,$n)}claimMilestoneReward(e){return this.send(Qe.ClaimMilestoneReward,e,Rs)}claimMilestoneRewardsBatch(e){return this.send(Qe.ClaimMilestoneRewardsBatch,e,Zn)}claimGroupCompletionReward(e){return this.send(Qe.ClaimGroupCompletionReward,e,Kn)}addQuestProgress(e){return this.send(Qe.AddQuestProgress,e,Hn)}};var il=zod.z.object({}).passthrough().transform(o=>o);var Am=zod.z.object({Order:zod.z.number().nullish(),Type:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),BonusMultiplier:zod.z.number().nullish()}).passthrough(),Om=zod.z.object({Schedule:zod.z.array(Am).nullish(),RepeatCycle:zod.z.boolean().nullish(),MaxCycles:zod.z.number().nullish()}).passthrough(),Um=zod.z.object({IsActive:zod.z.boolean().nullish(),CurrentPhaseEndUtc:u.nullish(),NextBonusStartUtc:u.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentPhaseIndex:zod.z.number().nullish(),ActiveBonusMultiplier:zod.z.number().nullish()}).passthrough(),Bm=zod.z.object({Milestones:Y.nullish()}).passthrough(),tn=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(Le).nullish(),ClaimMode:zod.z.string().nullish(),Milestones:zod.z.record(zod.z.string(),ve).nullish(),Presets:Bm.nullish(),BonusWindow:Om.nullish()}).passthrough(),Lm=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Content:tn.nullish(),ClaimGraceHours:zod.z.number().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),qm=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:de.nullish(),Content:tn.nullish(),Events:zod.z.array(Lm).nullish(),Gate:W.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Em=zod.z.object({MaxConcurrentEvents:zod.z.number().nullish()}).passthrough(),Gm=zod.z.object({Milestones:zod.z.record(zod.z.string(),ut).nullish()}).passthrough(),zr=zod.z.object({Definitions:zod.z.record(zod.z.string(),qm).nullish(),Settings:Em.nullish(),Presets:Gm.nullish()}).passthrough(),Nm=zod.z.object({Type:Ft,TimedEventID:zod.z.string(),CurrentChainedEventID:zod.z.string().nullish(),Content:tn.nullish(),Progress:il.nullish(),ComputedStartUtc:u.nullish(),ComputedEndUtc:u.nullish(),CanEarn:zod.z.boolean().nullish(),CanClaim:zod.z.boolean().nullish(),NextMilestone:ve.nullish(),BonusWindow:Um.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentEventOrder:zod.z.number().nullish(),TotalEventsInChain:zod.z.number().nullish()}).passthrough(),rl=zod.z.object({ActiveEvents:zod.z.array(Nm).nullish()}).passthrough(),sl=zod.z.object({Tokens:zod.z.record(zod.z.string(),il).nullish()}),rn=zod.z.object({Type:Ft.nullish(),LteID:zod.z.string().nullish(),Resources:D.nullish()}),sn=zod.z.object({Type:Ft.nullish(),LteID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Rewards:D.nullish()}),jm=zod.z.object({Type:Ft.nullish(),LteID:zod.z.string().nullish(),Resources:D.nullish()}),nn=zod.z.array(re(sn)),nl=zod.z.array(re(rn)),ol=zod.z.array(re(jm)),Fe={GetActiveEvents:"GetActiveEvents",GrantTokens:"GrantTokens",SpendTokens:"SpendTokens",ClaimMilestone:"ClaimMilestone",GetDefinitions:"GetDefinitions",GetUserLteState:"GetUserLteState",ClaimMilestonesBatch:"ClaimMilestonesBatch",ClaimAllMilestones:"ClaimAllMilestones",SpendTokensBatch:"SpendTokensBatch",GrantTokensBatch:"GrantTokensBatch"};var Tr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"TimedEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getActiveEvents(e){return this.send(Fe.GetActiveEvents,e,rl)}getDefinitions(e){return this.send(Fe.GetDefinitions,e,zr)}getUserLteState(e){return this.send(Fe.GetUserLteState,e,sl)}grantTokens(e){return this.send(Fe.GrantTokens,e,D)}spendTokens(e){return this.send(Fe.SpendTokens,e,rn)}claimMilestone(e){return this.send(Fe.ClaimMilestone,e,sn)}claimMilestonesBatch(e){return this.send(Fe.ClaimMilestonesBatch,e,nn)}claimAllMilestones(e){return this.send(Fe.ClaimAllMilestones,e,nn)}spendTokensBatch(e){return this.send(Fe.SpendTokensBatch,e,nl)}grantTokensBatch(e){return this.send(Fe.GrantTokensBatch,e,ol)}};var Fm=zod.z.object({UserID:zod.z.string(),Score:w.nullish(),Rank:zod.z.number().nullish(),LastScoreUpdateUtc:u.nullish(),IpHash:zod.z.string().nullish(),PublicProfile:ze.nullish(),SeasonTierAtCycleEnd:zod.z.number().nullish()}).passthrough(),Kt=zod.z.object({LeaderboardID:zod.z.string(),CycleVersion:zod.z.number().nullish(),TotalParticipants:w.nullish(),CycleEndUtc:u.nullish(),TopUsers:zod.z.array(Fm).nullish(),BracketID:zod.z.string().nullish()}),Vm=zod.z.object({CycleKey:zod.z.string().nullish(),CycleEndUtc:u.nullish(),ClaimDeadlineUtc:u.nullish(),MilestoneTokensEarned:w.nullish(),ClaimableMilestoneIDs:zod.z.array(zod.z.string()).nullish(),CycleIndex:zod.z.number().nullish(),ChainedEventID:zod.z.string().nullish()}).passthrough(),Pr=zod.z.object({LeaderboardID:zod.z.string(),CurrentScore:w.nullish(),LastKnownRank:zod.z.number().nullish(),HasUnclaimedReward:zod.z.boolean().nullish(),ScoreEarnedThisCycle:w.nullish(),MilestoneTokensEarned:w.nullish(),NextMilestone:ve.nullish(),HasUnclaimedMilestone:zod.z.boolean().nullish(),ClaimableGraceCycles:zod.z.array(Vm).nullish()}),Ir=zod.z.object({LeaderboardID:zod.z.string(),NewScore:w,CycleVersion:zod.z.number()}),kr=zod.z.object({ServerTimeUtc:u,LeaderboardID:zod.z.string(),Rank:zod.z.number().nullish(),Resources:D.nullish()}),Mr=zod.z.object({ServerTimeUtc:u,LeaderboardID:zod.z.string(),MilestoneID:zod.z.string(),Resources:D.nullish()}),al=zod.z.array(re(Kt)),ll=zod.z.array(re(Pr)),ul=zod.z.array(re(kr)),cl=zod.z.array(re(Mr)),pl=zod.z.array(re(Ir)),_m=zod.z.object({LeaderboardID:zod.z.string(),CycleReward:re(kr).nullish(),Milestones:zod.z.array(re(Mr)).nullish()}),dl=zod.z.array(_m),Wm=zod.z.object({LeaderboardID:zod.z.string(),Leaderboard:re(Kt).nullish(),Progress:re(Pr).nullish()}),hl=zod.z.array(Wm),Qm=zod.z.string(),ml=zod.z.object({Rank:zod.z.string().nullish(),Rewards:L.nullish(),SeasonTierRewards:ms.nullish()}).passthrough(),Km=zod.z.object({RankRewards:zod.z.array(ml).nullish()}).passthrough(),Hm=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),$m=zod.z.object({Milestones:Y.nullish(),RankRewards:Y.nullish()}).passthrough(),Zm=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:Qm.nullish(),Schedule:de.nullish(),ChainEvents:zod.z.array(Hm).nullish(),Gate:W.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(ml).nullish(),Milestones:zod.z.record(zod.z.string(),ve).nullish(),Presets:$m.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneClaimGraceHours:zod.z.number().nullish(),ScoreSources:zod.z.array(Le).nullish()}).passthrough(),Jm=zod.z.object({Milestones:zod.z.record(zod.z.string(),ut).nullish(),RankRewards:zod.z.record(zod.z.string(),Km).nullish()}).passthrough(),wr=zod.z.object({Definitions:zod.z.record(zod.z.string(),Zm).nullish(),Presets:Jm.nullish()}).passthrough(),De={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 Ar=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Leaderboard",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(De.GetDefinitions,e,wr)}getLeaderboard(e){return this.send(De.GetLeaderboard,e,Kt)}getMyProgress(e){return this.send(De.GetMyProgress,e,Pr)}submitScore(e){return this.send(De.SubmitScore,e,Ir)}submitScoreFromSource(e){return this.send(De.SubmitScoreFromSource,e,Ir)}claimCycleReward(e){return this.send(De.ClaimCycleReward,e,kr)}claimMilestone(e){return this.send(De.ClaimMilestone,e,Mr)}getFriendsLeaderboard(e){return this.send(De.GetFriendsLeaderboard,e,Kt)}getLeaderboardsBatch(e){return this.send(De.GetLeaderboardsBatch,e,al)}getProgressBatch(e){return this.send(De.GetProgressBatch,e,ll)}claimCycleRewardsBatch(e){return this.send(De.ClaimCycleRewardsBatch,e,ul)}claimMilestonesBatch(e){return this.send(De.ClaimMilestonesBatch,e,cl)}submitScoresBatch(e){return this.send(De.SubmitScoresBatch,e,pl)}claimAllRewardsBatch(e){return this.send(De.ClaimAllRewardsBatch,e,dl)}getOverviewBatch(e){return this.send(De.GetOverviewBatch,e,hl)}};var on=zod.z.object({}).passthrough().transform(o=>o),fl=zod.z.object({SeasonChainID:zod.z.string(),CycleIndex:zod.z.number().nullish(),Season:zod.z.lazy(()=>Cl).nullish(),ComputedStartUtc:u.nullish(),ComputedEndUtc:u.nullish(),SecondsRemaining:w.nullish(),UserState:on.nullish(),NextTier:zod.z.lazy(()=>yl).nullish()}).passthrough(),gl=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),AmountGranted:w.nullish(),NewStatusTokens:w.nullish(),OldTier:zod.z.number().nullish(),NewTier:zod.z.number(),TierUp:zod.z.boolean().nullish()}),an=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),TierNumber:zod.z.number(),Resources:D.nullish()}),Rl=Xe(an);var yl=zod.z.object({Tier:zod.z.number().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),RequiredTokens:w.nullish(),TierReachedReward:L.nullish()}).passthrough(),Cl=zod.z.object({SeasonID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:w.nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Tiers:zod.z.array(yl).nullish(),LinkedCollectionID:zod.z.string().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough();var Ym=zod.z.object({SeasonChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:de.nullish(),Seasons:zod.z.array(Cl).nullish(),GrantTokensAccessMode:zod.z.string().nullish(),Gate:W.nullish()}).passthrough(),Or=zod.z.object({Chains:zod.z.record(zod.z.string(),Ym).nullish()}).passthrough(),ht={GetDefinitions:"GetDefinitions",GetActiveSeason:"GetActiveSeason",GetUserState:"GetUserState",GrantStatusTokens:"GrantStatusTokens",ClaimTierReward:"ClaimTierReward",ClaimTierRewardsBatch:"ClaimTierRewardsBatch"};var Ur=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Season",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(ht.GetDefinitions,e,Or)}getActiveSeason(e){return this.send(ht.GetActiveSeason,e,fl)}getUserState(e){return this.send(ht.GetUserState,e,on)}grantStatusTokens(e){return this.send(ht.GrantStatusTokens,e,gl)}claimTierReward(e){return this.send(ht.ClaimTierReward,e,an)}claimTierRewardsBatch(e){return this.send(ht.ClaimTierRewardsBatch,e,Rl)}};var Xm={Apple:"Apple",Google:"Google"},Sl=zod.z.object({}).passthrough().transform(o=>o),ef=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(),tf=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:J.nullish(),Benefits:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),ln=zod.z.object({Definitions:zod.z.record(zod.z.string(),tf).nullish()}).passthrough(),xl=zod.z.object({Premium:ln.nullish()}),bl=zod.z.object({ServerTimeUtc:u.nullish(),Premium:Sl.nullish()}),Br=zod.z.object({ServerTimeUtc:u.nullish(),Premium:Sl.nullish(),Subscription:ef.nullish(),Resources:D.nullish()}),Ct={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateTrial:"ActivateTrial",PurchaseWithResources:"PurchaseWithResources",PurchaseRealMoney:"PurchaseRealMoney"};var Lr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Premium",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ct.GetDefinitions,e,xl)}getUserState(e){return this.send(Ct.GetUserState,e,bl)}activateTrial(e){return this.send(Ct.ActivateTrial,e,Br)}purchaseItemOrCurrency(e){return this.send(Ct.PurchaseWithResources,e,Br)}purchaseRealMoney(e){return this.send(Ct.PurchaseRealMoney,e,Br)}};var qr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Character",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getCharacterDefinitions(e){return this.send(Oe.GetCharacterDefinitions,e,Xi)}getUserCharacters(e){return this.send(Oe.GetUserCharacters,e,Uo)}unlockCharacter(e){return this.send(Oe.UnlockCharacter,e,Us)}upgradeStatLevel(e){return this.send(Oe.UpgradeStatLevel,e,As)}upgradeCharacterLevel(e){return this.send(Oe.UpgradeCharacterLevel,e,Os)}equipItems(e){return this.send(Oe.EquipItems,e,Bo)}unequipItems(e){return this.send(Oe.UnequipItems,e,Lo)}unequipAllCharacters(e){return this.send(Oe.UnequipAllCharacters,e,qo)}unlockCharactersBatch(e){return this.send(Oe.UnlockCharactersBatch,e,Eo)}upgradeCharacterLevelsBatch(e){return this.send(Oe.UpgradeCharacterLevelsBatch,e,Go)}upgradeStatLevelsBatch(e){return this.send(Oe.UpgradeStatLevelsBatch,e,No)}};var Er=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Match",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}createMatch(e){return this.send(tt.CreateMatch,e,ca)}updateMatch(e){return this.send(tt.UpdateMatch,e,pa)}cancelMatch(e){return this.send(tt.CancelMatch,e,da)}instantBattle(e){return this.send(tt.InstantBattle,e,ha)}saveStrategy(e){return this.send(tt.SaveStrategy,e,be)}getMyMatches(e){return this.send(tt.GetMyMatches,e,js)}getAvailableMatches(e){return this.send(tt.GetAvailableMatches,e,js)}getDefinitions(e){return this.send(tt.GetDefinitions,e,Ra)}};var rf={TradeUpRarity:"TradeUpRarity",TradeUpCollection:"TradeUpCollection"},Dl=zod.z.enum(["TradeUpRarity","TradeUpCollection"]).catch("TradeUpRarity"),sf=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:hs.nullish()}),vl=zod.z.object({ServerTimeUtc:u,Type:Dl.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:D.nullish(),Results:zod.z.array(sf).nullish()}),nf=zod.z.object({CraftID:zod.z.string().nullish(),Type:Dl.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:J.nullish()}).passthrough(),un=zod.z.object({Definitions:zod.z.record(zod.z.string(),nf).nullish()}).passthrough(),zl=zod.z.object({ServerTimeUtc:u.nullish(),CraftDefinitions:un.nullish()}),Gr={GetDefinitions:"GetDefinitions",Craft:"Craft"};var Nr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Craft",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Gr.GetDefinitions,e,zl)}craft(e){return this.send(Gr.Craft,e,vl)}};var of={Pending:"Pending",Accepted:"Accepted",Declined:"Declined",Cancelled:"Cancelled",Expired:"Expired"},af=zod.z.enum(["Pending","Accepted","Declined","Cancelled","Expired"]).catch("Pending"),Tl=zod.z.object({}).passthrough().transform(o=>o),qt=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()}),Pl=zod.z.object({GrantedCollectibles:zod.z.array(qt).nullish(),DuplicateCollectibles:zod.z.array(qt).nullish(),CollectionCurrencyEarned:w.nullish()}),Il=zod.z.object({OpenedCount:zod.z.number().nullish(),Packs:zod.z.array(Pl).nullish(),GrantedCollectibles:zod.z.array(qt).nullish(),DuplicateCollectibles:zod.z.array(qt).nullish(),CollectionCurrencyEarned:w.nullish(),NewCollectionCurrencyBalance:w.nullish(),NewlyCompletedSetIDs:zod.z.array(zod.z.string()).nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:D.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),kl=zod.z.object({OpenedCount:zod.z.number().nullish(),Chests:zod.z.array(Pl).nullish(),GrantedCollectibles:zod.z.array(qt).nullish(),DuplicateCollectibles:zod.z.array(qt).nullish(),CollectionCurrencyEarned:w.nullish(),NewCollectionCurrencyBalance:w.nullish(),Resources:D.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),Ml=zod.z.object({GrantedCollectibleID:zod.z.string().nullish(),NewlyCompletedSetID:zod.z.string().nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:D.nullish()}),cn=zod.z.object({SetID:zod.z.string(),Resources:D.nullish()}),wl=zod.z.array(re(cn)),Al=zod.z.object({Resources:D.nullish()}),lf=zod.z.object({OfferID:zod.z.string(),TitleID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderPublicData:ze.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:af.nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),RespondedAtUtc:u.nullish(),DeclineReason:zod.z.string().nullish(),IsSpecialTradeEvent:zod.z.boolean().nullish(),SpecialTradeEventID:zod.z.string().nullish()}).passthrough(),Ol=zod.z.object({OfferID:zod.z.string(),ExpiresAtUtc:u.nullish(),Resources:D.nullish()}),Ul=zod.z.object({OfferID:zod.z.string(),Resources:D.nullish()}),Bl=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()}),Ll=zod.z.object({OfferID:zod.z.string(),Resources:D.nullish()}),pn=zod.z.object({Offers:zod.z.array(lf).nullish()}),uf=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(),cf=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(uf).nullish(),SetCompletionReward:L.nullish()}).passthrough(),pf=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(cf).nullish(),GrandPrize:L.nullish()}).passthrough(),ql=zod.z.object({BonusRewardSlots:Y.nullish(),PityRules:Y.nullish()}).passthrough(),df=zod.z.object({PackTypeID:zod.z.string().nullish(),PriceOptions:J.nullish(),BonusRewardSlots:zod.z.array(Bt).nullish(),PityRules:zod.z.array(Lt).nullish(),Presets:ql.nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CollectibleCount:zod.z.number().nullish(),MaxOpenCount:zod.z.number().nullish(),GuaranteedMinRarity:zod.z.number().nullish(),GuaranteeMaxRarity:zod.z.boolean().nullish(),RarityWeights:zod.z.record(zod.z.string(),zod.z.number()).nullish(),ColorTier:zod.z.number().nullish()}).passthrough(),hf=zod.z.object({Rarity:zod.z.number().nullish(),CollectionCurrencyGranted:zod.z.number().nullish()}).passthrough(),mf=zod.z.object({CollectionChestID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CollectionCurrencyCost:zod.z.number().nullish(),MaxOpenCount:zod.z.number().nullish(),MinCollectibleCount:zod.z.number().nullish(),MaxCollectibleCount:zod.z.number().nullish(),GuaranteedMinRarity:zod.z.number().nullish(),BonusRewardSlots:zod.z.array(Bt).nullish(),PityRules:zod.z.array(Lt).nullish(),Presets:ql.nullish(),Tier:zod.z.number().nullish()}).passthrough(),ff=zod.z.object({SpecialTradeEventID:zod.z.string().nullish(),StartUtc:u.nullish(),EndUtc:u.nullish(),AllowedSpecialCollectibleIDs:zod.z.array(zod.z.string()).nullish(),SpecialTradeEventDailyTradeLimit:zod.z.number().nullish()}).passthrough(),jr=zod.z.object({Collections:zod.z.record(zod.z.string(),pf).nullish(),PackTypes:zod.z.record(zod.z.string(),df).nullish(),CollectionChests:zod.z.array(mf).nullish(),DuplicateConversions:zod.z.array(hf).nullish(),DailyTradeLimit:zod.z.number().nullish(),CollectibleJokerCatalogID:zod.z.string().nullish(),CollectibleJokerItemID:zod.z.string().nullish(),SpecialTradeEvents:zod.z.array(ff).nullish(),RewardPools:yr.nullish()}).passthrough(),Te={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",OpenPack:"OpenPack",OpenCollectionChest:"OpenCollectionChest",UseCollectibleJoker:"UseCollectibleJoker",ClaimSetReward:"ClaimSetReward",ClaimSetRewardsBatch:"ClaimSetRewardsBatch",ClaimGrandPrize:"ClaimGrandPrize",SendTradeOffer:"SendTradeOffer",CancelTradeOffer:"CancelTradeOffer",AcceptTradeOffer:"AcceptTradeOffer",DeclineTradeOffer:"DeclineTradeOffer",GetMyTradeOffers:"GetMyTradeOffers",GetIncomingTradeOffers:"GetIncomingTradeOffers"};var Fr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Collection",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Te.GetDefinitions,e,jr)}getUserState(e){return this.send(Te.GetUserState,e,Tl)}openPack(e){return this.send(Te.OpenPack,e,Il)}openCollectionChest(e){return this.send(Te.OpenCollectionChest,e,kl)}useCollectibleJoker(e){return this.send(Te.UseCollectibleJoker,e,Ml)}claimSetReward(e){return this.send(Te.ClaimSetReward,e,cn)}claimSetRewardsBatch(e){return this.send(Te.ClaimSetRewardsBatch,e,wl)}claimGrandPrize(e){return this.send(Te.ClaimGrandPrize,e,Al)}sendTradeOffer(e){return this.send(Te.SendTradeOffer,e,Ol)}cancelTradeOffer(e){return this.send(Te.CancelTradeOffer,e,Ul)}acceptTradeOffer(e){return this.send(Te.AcceptTradeOffer,e,Bl)}declineTradeOffer(e){return this.send(Te.DeclineTradeOffer,e,Ll)}getMyTradeOffers(e){return this.send(Te.GetMyTradeOffers,e,pn)}getIncomingTradeOffers(e){return this.send(Te.GetIncomingTradeOffers,e,pn)}};var gf=zod.z.object({}).passthrough().transform(o=>o),Rf={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},yf={Active:"Active",Left:"Left",Replaced:"Replaced"},Cf=zod.z.object({ObjectIndex:zod.z.number().nullish(),ObjectCompletionRewardClaimed:zod.z.boolean().nullish()}).passthrough(),Sf=zod.z.object({UserID:zod.z.string().nullish(),PublicData:ze.nullish(),BuildObjectsProgress:Cf.nullish(),IsBot:zod.z.boolean().nullish(),SpinsCount:zod.z.number().nullish(),TokensSpent:zod.z.number().nullish(),MemberStatus:zod.z.string().nullish(),GrandPrizeClaimed:zod.z.boolean().nullish(),JoinedAtUtc:u.nullish(),LeftAtUtc:u.nullish()}).passthrough(),xf=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(),bf=zod.z.object({Objects:zod.z.array(xf).nullish()}).passthrough(),El=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(Sf).nullish(),BuildObjectsState:bf.nullish(),Status:zod.z.string().nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),Version:zod.z.number().nullish()}).passthrough(),Gl=zod.z.object({CoopChainID:zod.z.string()}).passthrough(),Df=zod.z.string(),dn=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(),vf=zod.z.object({Index:zod.z.number().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),MaxProgress:zod.z.number().nullish(),CompletionReward:L.nullish()}).passthrough(),zf=zod.z.object({Objects:zod.z.array(vf).nullish(),PriceOptions:J.nullish(),SpinnerTable:zod.z.array(dn).nullish(),MaxSpinsPerCall:zod.z.number().nullish()}).passthrough(),Tf=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:Df.nullish(),PartnerCount:zod.z.number().nullish(),MatchmakingTimeoutMinutes:zod.z.number().nullish(),MemberGracePeriodMinutes:zod.z.number().nullish(),BuildObjects:zf.nullish(),GrandPrize:L.nullish()}).passthrough(),Pf=zod.z.object({CoopChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:de.nullish(),Events:zod.z.array(Tf).nullish(),Gate:W.nullish()}).passthrough(),Nl=zod.z.object({ServerTimeUtc:u.nullish(),UserState:gf.nullish(),ActiveGroup:El.nullish()}),hn=zod.z.object({ServerTimeUtc:u.nullish(),Group:El.nullish(),SecondsRemaining:w.nullish()}),jl=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Resources:D.nullish(),ObjectIndex:zod.z.number().nullish(),Sector:dn.nullish(),RequestedSpins:zod.z.number().nullish(),SpinsUsed:zod.z.number().nullish(),Sectors:zod.z.array(dn).nullish(),ProgressDelta:zod.z.number().nullish(),NewProgress:w.nullish(),MaxProgress:w.nullish(),ObjectCompleted:zod.z.boolean().nullish(),AllObjectsCompleted:zod.z.boolean().nullish()}),mn=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),Resources:D.nullish()}),Fl=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),Vr=zod.z.object({Chains:zod.z.record(zod.z.string(),Pf).nullish()}).passthrough(),He={GetDefinitions:"GetDefinitions",GetActiveEvent:"GetActiveEvent",GetUserState:"GetUserState",GetGroupState:"GetGroupState",JoinOrCreateGroup:"JoinOrCreateGroup",Spin:"Spin",ClaimObjectReward:"ClaimObjectReward",ClaimGrandPrize:"ClaimGrandPrize",LeaveGroup:"LeaveGroup"};var _r=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"CoopEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(He.GetDefinitions,e,Vr)}getActiveEvent(e){return this.send(He.GetActiveEvent,e,Gl)}getUserState(e){return this.send(He.GetUserState,e,Nl)}getGroupState(e){return this.send(He.GetGroupState,e,hn)}joinOrCreateGroup(e){return this.send(He.JoinOrCreateGroup,e,hn)}spin(e){return this.send(He.Spin,e,jl)}claimObjectReward(e){return this.send(He.ClaimObjectReward,e,mn)}claimGrandPrize(e){return this.send(He.ClaimGrandPrize,e,mn)}leaveGroup(e){return this.send(He.LeaveGroup,e,Fl)}};var If={Active:"Active",Exhausted:"Exhausted",Expired:"Expired",Dismissed:"Dismissed"},kf={Locked:"Locked",Available:"Available",InProgress:"InProgress",Completed:"Completed",Hidden:"Hidden"},Mf=zod.z.object({NodeID:zod.z.string().nullish(),Status:zod.z.string().nullish(),ExecutionCount:zod.z.number().nullish(),UnlockedAtUtc:u.nullish(),CompletedAtUtc:u.nullish(),LastExecutedAtUtc:u.nullish(),NextAvailableAtUtc:u.nullish(),LastExecutionRefID:zod.z.string().nullish()}).passthrough(),wf=zod.z.object({TrackID:zod.z.string().nullish(),CurrentValue:zod.z.number().nullish(),LastUpdatedUtc:u.nullish()}).passthrough(),Vl=zod.z.object({OfferID:zod.z.string().nullish(),InstanceKey:zod.z.string().nullish(),SourceOfferVersion:zod.z.number().nullish(),Status:zod.z.string().nullish(),ActivatedAtUtc:u.nullish(),ExhaustedAtUtc:u.nullish(),ExpiredAtUtc:u.nullish(),DismissedAtUtc:u.nullish(),ShowCount:zod.z.number().nullish(),LastShownAtUtc:u.nullish(),Nodes:zod.z.record(zod.z.string(),Mf).nullish(),Tracks:zod.z.record(zod.z.string(),wf).nullish(),SelectedChoiceNodeID:zod.z.string().nullish()}).passthrough(),Af=zod.z.object({SlotID:zod.z.string().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),ActiveOfferID:zod.z.string().nullish(),ActiveOfferStartedAtUtc:u.nullish(),ActiveOfferExpiresAtUtc:u.nullish(),ActiveOffer:Vl.nullish(),NextCycleStartsAtUtc:u.nullish(),LastUpdatedUtc:u.nullish(),DismissSkipAvailableAtUtc:u.nullish(),LastDismissedAtUtc:u.nullish()}).passthrough(),Of=zod.z.object({TotalExecutions:zod.z.number().nullish(),DailyExecutions:zod.z.number().nullish(),DailyResetUtc:u.nullish()}).passthrough(),Uf=zod.z.object({TotalActivations:zod.z.number().nullish(),TotalExhausted:zod.z.number().nullish(),TotalExpired:zod.z.number().nullish(),TotalDismissed:zod.z.number().nullish(),TotalShows:zod.z.number().nullish(),LastShownAtUtc:u.nullish(),LastActivatedAtUtc:u.nullish(),LastExhaustedAtUtc:u.nullish(),NodeCounts:zod.z.record(zod.z.string(),Of).nullish()}).passthrough(),Bf=zod.z.object({Slots:zod.z.record(zod.z.string(),Af).nullish(),OfferHistory:zod.z.record(zod.z.string(),Uf).nullish(),LastUpdatedUtc:u.nullish()}).passthrough();var Lf=zod.z.object({Order:zod.z.number().nullish(),OfferID:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),DelayBeforeActivationSec:zod.z.number().nullish()}).passthrough(),qf=zod.z.object({SlotID:zod.z.string().nullish(),Enabled:zod.z.boolean().nullish(),SortOrder:zod.z.number().nullish(),Queue:zod.z.array(Lf).nullish(),Schedule:de.nullish(),Gate:W.nullish(),AllowDismissSkip:zod.z.boolean().nullish(),DismissSkipDelaySec:zod.z.number().nullish()}).passthrough(),Ef=zod.z.object({StoreOfferID:zod.z.string().nullish(),BillingProductID:zod.z.string().nullish(),PriceOptions:J.nullish(),UseExternalRewards:zod.z.boolean().nullish()}).passthrough(),Gf=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(),Nf=zod.z.object({Purchase:Ef.nullish(),RewardedVideo:Gf.nullish()}).passthrough(),jf=zod.z.object({TrackID:zod.z.string().nullish(),Operator:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),Ff=zod.z.object({Milestones:Y.nullish()}).passthrough(),Vf=zod.z.object({TrackID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),RespectBounds:zod.z.boolean().nullish()}).passthrough(),_f=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(),Wf=zod.z.object({RequiredCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredAnyCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredTracks:zod.z.array(jf).nullish(),VisibleWhileLocked:zod.z.boolean().nullish()}).passthrough(),Qf=zod.z.object({NodeID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),Type:zod.z.string().nullish(),Action:Nf.nullish(),Grants:L.nullish(),TrackChanges:zod.z.array(Vf).nullish(),MilestonePoints:zod.z.number().nullish(),UnlockRules:Wf.nullish(),NextNodeIDs:zod.z.array(zod.z.string()).nullish(),ChoiceGroupID:zod.z.string().nullish(),Limits:ue.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(),_l=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(Qf).nullish(),Tracks:zod.z.array(_f).nullish(),Milestones:zod.z.record(zod.z.string(),ve).nullish(),Presets:Ff.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(),Kf=zod.z.object({Milestones:zod.z.record(zod.z.string(),ut).nullish()}).passthrough(),fn=zod.z.object({Slots:zod.z.record(zod.z.string(),qf).nullish(),Offers:zod.z.record(zod.z.string(),_l).nullish(),Presets:Kf.nullish()}).passthrough(),Wl=zod.z.object({DealOfferDefinitions:fn.nullish()}),Ql=zod.z.object({DealOffers:Bf.nullish()}),Hf=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(),$f=zod.z.object({SlotID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),OfferDef:_l.nullish(),ActivationState:Vl.nullish(),IsNewActivation:zod.z.boolean().nullish(),ComputedExpiresAtUtc:u.nullish(),Cost:_t.nullish(),Milestone:Hf.nullish()}).passthrough(),Kl=zod.z.object({Slots:zod.z.array($f).nullish()}),Hl=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),NodeID:zod.z.string().nullish(),NodeCompleted:zod.z.boolean().nullish(),OfferExhausted:zod.z.boolean().nullish(),Idempotent:zod.z.boolean().nullish(),Resources:D.nullish()}),$l=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),Resources:D.nullish()}),Zl=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),Resources:D.nullish()}),Jl=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:D.nullish()}),Yl=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),ClaimedIDs:zod.z.array(zod.z.string()).nullish(),Rejected:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Resources:D.nullish()}),it={GetDefinition:"GetDefinition",GetUserState:"GetUserState",GetActiveDeals:"GetActiveDeals",DismissDeal:"DismissDeal",ExecuteNode:"ExecuteNode",RecordShow:"RecordShow",ClaimMilestone:"ClaimMilestone",ClaimMilestonesBatch:"ClaimMilestonesBatch"};var Wr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"DealOffer",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinition(e){return this.send(it.GetDefinition,e,Wl)}getUserState(e){return this.send(it.GetUserState,e,Ql)}getActiveDeals(e){return this.send(it.GetActiveDeals,e,Kl)}dismissDeal(e){return this.send(it.DismissDeal,e,$l)}executeNode(e){return this.send(it.ExecuteNode,e,Hl)}recordShow(e){return this.send(it.RecordShow,e,Zl)}claimMilestone(e){return this.send(it.ClaimMilestone,e,Jl)}claimMilestonesBatch(e){return this.send(it.ClaimMilestonesBatch,e,Yl)}};var Zf=zod.z.object({}).passthrough().transform(o=>o),Jf=zod.z.object({FeatureKey:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Rate:zod.z.number().nullish(),Basis:zod.z.string().nullish(),SourceCurrencyID:zod.z.string().nullish(),TargetCurrencyID:zod.z.string().nullish(),MinSourceAmount:zod.z.number().nullish(),MaxRewardPerOperation:zod.z.number().nullish(),Limits:ue.nullish()}).passthrough(),gn=zod.z.object({IsEnabled:zod.z.boolean().nullish(),ActivationReward:L.nullish(),InviteRewards:zod.z.record(zod.z.string(),ve).nullish(),SpendRewards:zod.z.array(Jf).nullish()}).passthrough(),Xl=zod.z.object({ReferralDefinitions:gn.nullish()}).passthrough(),eu=zod.z.object({Referral:Zf.nullish(),InviteUrl:zod.z.string().nullish()}).passthrough(),tu=zod.z.object({ReferralCode:zod.z.string().nullish(),ReferrerUserID:zod.z.string().nullish(),IsFirstActivation:zod.z.boolean().nullish(),Resources:D.nullish()}).passthrough(),Rn=zod.z.object({RewardID:zod.z.string().nullish(),Resources:D.nullish()}).passthrough(),iu=Xe(Rn),St={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateReferralCode:"ActivateReferralCode",ClaimInviteReward:"ClaimInviteReward",ClaimInviteRewardsBatch:"ClaimInviteRewardsBatch"};var Qr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Referral",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(St.GetDefinitions,e,Xl)}getUserState(e){return this.send(St.GetUserState,e,eu)}activateReferralCode(e){return this.send(St.ActivateReferralCode,e,tu)}claimInviteReward(e){return this.send(St.ClaimInviteReward,e,Rn)}claimInviteRewardsBatch(e){return this.send(St.ClaimInviteRewardsBatch,e,iu)}};var Yf={RequestSent:"RequestSent",Accepted:"Accepted",Declined:"Declined",Removed:"Removed"},Xf={Attack:"Attack",Raid:"Raid",FriendAdd:"FriendAdd"},ru=zod.z.object({UserID:zod.z.string(),PublicData:ze.nullish()}),eg=zod.z.object({OwnerUserID:zod.z.string().nullish(),ActorUserID:zod.z.string().nullish(),ActorProfile:ze.nullish(),Type:zod.z.string().nullish(),CreatedAt:u.nullish(),OwnerImpact:D.nullish(),IsBlocked:zod.z.boolean().nullish(),TargetObjectName:zod.z.string().nullish()}).passthrough(),Ht=zod.z.object({Friends:zod.z.array(ru).nullish()}),tg=zod.z.object({FriendsCount:zod.z.number().nullish(),IncomingRequestsCount:zod.z.number().nullish(),OutgoingRequestsCount:zod.z.number().nullish()}),$t=zod.z.object({TargetUserID:zod.z.string().nullish(),Status:zod.z.string().nullish(),Target:ru.nullish(),Counters:tg.nullish()}),su=zod.z.object({Events:zod.z.array(eg).nullish()}),$e={GetFriendsList:"GetFriendsList",GetIncomingRequests:"GetIncomingRequests",GetOutgoingRequests:"GetOutgoingRequests",GetRecommendedFriends:"GetRecommendedFriends",SendFriendRequest:"SendFriendRequest",AcceptFriendRequest:"AcceptFriendRequest",DeclineFriendRequest:"DeclineFriendRequest",RemoveFriend:"RemoveFriend",GetTimeline:"GetTimeline"};var Kr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Social",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getFriendsList(e){return this.send($e.GetFriendsList,e,Ht)}getIncomingRequests(e){return this.send($e.GetIncomingRequests,e,Ht)}getOutgoingRequests(e){return this.send($e.GetOutgoingRequests,e,Ht)}getRecommendedFriends(e){return this.send($e.GetRecommendedFriends,e,Ht)}sendFriendRequest(e){return this.send($e.SendFriendRequest,e,$t)}acceptFriendRequest(e){return this.send($e.AcceptFriendRequest,e,$t)}declineFriendRequest(e){return this.send($e.DeclineFriendRequest,e,$t)}removeFriend(e){return this.send($e.RemoveFriend,e,$t)}getTimeline(e){return this.send($e.GetTimeline,e,su)}};var ig={Replace:"Replace",Refresh:"Refresh",KeepBest:"KeepBest",Stack:"Stack"};var Et=zod.z.object({Target:zod.z.string().nullish(),Operation:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),rg=zod.z.object({BoostID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),PriceOptions:J.nullish(),Effect:Et.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(),sg=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:de.nullish(),Effects:zod.z.array(Et).nullish(),Gate:W.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),ng=zod.z.object({ChainedBoostID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Effects:zod.z.array(Et).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),og=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:de.nullish(),Phases:zod.z.array(ng).nullish(),Gate:W.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),ag=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(Le).nullish(),Effects:zod.z.array(Et).nullish(),DurationSeconds:zod.z.number().nullish(),Charges:zod.z.number().nullish(),StackingPolicy:zod.z.string().nullish(),MaxActiveInstances:zod.z.number().nullish(),Gate:W.nullish()}).passthrough(),lg=zod.z.object({MaxAddPercent:zod.z.number().nullish(),MaxMultiply:zod.z.number().nullish(),MaxAddFlat:zod.z.number().nullish()}).passthrough(),ug=zod.z.object({StackingCaps:zod.z.record(zod.z.string(),lg).nullish()}).passthrough(),Hr=zod.z.object({Definitions:zod.z.record(zod.z.string(),rg).nullish(),ScheduledBoosts:zod.z.record(zod.z.string(),sg).nullish(),BoostChains:zod.z.record(zod.z.string(),og).nullish(),TriggeredBoosts:zod.z.record(zod.z.string(),ag).nullish(),Settings:ug.nullish()}).passthrough(),nu=zod.z.object({InstanceID:zod.z.string(),BoostID:zod.z.string(),ActivatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),RemainingCharges:zod.z.number().nullish(),EffectSnapshot:Et.nullish(),SourceType:zod.z.string().nullish(),SourceRef:zod.z.string().nullish()}).passthrough();zod.z.object({Date:u.nullish(),DailyCount:zod.z.number().nullish(),LastFiredUtc:u.nullish()}).passthrough();var ou=zod.z.object({ServerTimeUtc:u.nullish(),Active:zod.z.record(zod.z.string(),nu).nullish()}),au=zod.z.object({ServerTimeUtc:u.nullish(),BoostID:zod.z.string().nullish(),StackingPolicy:zod.z.string().nullish(),ActivatedBoost:nu.nullish(),Resources:D.nullish()}),cg={Scheduled:"Scheduled",Chain:"Chain"},pg=zod.z.object({Kind:zod.z.string().nullish(),SourceID:zod.z.string().nullish(),PhaseID:zod.z.string().nullish(),CycleIndex:zod.z.number().nullish(),PhaseOrder:zod.z.number().nullish(),StartUtc:u.nullish(),EndUtc:u.nullish(),Effects:zod.z.array(Et).nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),lu=zod.z.object({ServerTimeUtc:u.nullish(),Windows:zod.z.array(pg).nullish()}),xt={GetDefinitions:"GetDefinitions",GetActive:"GetActive",GetActiveWindows:"GetActiveWindows",Activate:"Activate",CleanupExpired:"CleanupExpired"};var $r=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"TimedBoost",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(xt.GetDefinitions,e,Hr)}getActive(e){return this.send(xt.GetActive,e,ou)}getActiveWindows(e){return this.send(xt.GetActiveWindows,e,lu)}activate(e){return this.send(xt.Activate,e,au)}cleanupExpired(e){return this.send(xt.CleanupExpired,e,be)}};var Zr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"UserCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getUserCustomDataDefinitions(e){return this.send(Ke.GetUserCustomDataDefinitions,e,Wi)}getMyUserCustomData(e){return this.send(Ke.GetMyUserCustomData,e,xo)}getPublicUserCustomDataOf(e){return this.send(Ke.GetPublicUserCustomDataOf,e,Ps)}setPrivateData(e){return this.send(Ke.SetPrivateData,e,Is)}setPublicData(e){return this.send(Ke.SetPublicData,e,Is)}deleteKey(e){return this.send(Ke.DeleteKey,e,be)}batchSet(e){return this.send(Ke.BatchSet,e,bo)}batchDelete(e){return this.send(Ke.BatchDelete,e,Do)}batchGetPublicUserCustomDataOf(e){return this.send(Ke.BatchGetPublicUserCustomDataOf,e,vo)}};var dg={Static:"Static",Runtime:"Runtime"},hg={Public:"Public",Private:"Private"},mg=zod.z.enum(["Client","Server","System"]).catch("Client"),fg=zod.z.enum(["String","Int","Bool","Json"]).catch("String"),gg=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:u.nullish(),Version:zod.z.number().nullish(),LastWriter:mg.nullish(),ExpiresAt:u.nullish()}).passthrough(),uu=zod.z.record(zod.z.string(),gg),yn=zod.z.object({StaticVersion:zod.z.number().nullish(),RuntimeVersion:zod.z.number().nullish(),Static:uu.nullish(),Runtime:uu.nullish(),NotModified:zod.z.boolean().nullish()}),Rg=zod.z.object({KeyID:zod.z.string(),Scope:zod.z.enum(["Static","Runtime"]).catch("Static").nullish(),Bucket:zod.z.enum(["Public","Private"]).catch("Public").nullish(),ValueType:fg.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),Jr=zod.z.object({Keys:zod.z.record(zod.z.string(),Rg).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(),Zt={GetTitleCustomDataDefinitions:"GetTitleCustomDataDefinitions",GetPublicTitleData:"GetPublicTitleData",GetPublicTitleDataKeys:"GetPublicTitleDataKeys"};var Yr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"TitleCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getTitleCustomDataDefinitions(e){return this.send(Zt.GetTitleCustomDataDefinitions,e,Jr)}getPublicTitleData(e){return this.send(Zt.GetPublicTitleData,e,yn)}getPublicTitleDataKeys(e){return this.send(Zt.GetPublicTitleDataKeys,e,yn)}};var yg={Fast:"Fast",Sequential:"Sequential"},Cg={Instant:"Instant",Timed:"Timed"};var Sg={Hit:"Hit",Blocked:"Blocked"},xg=zod.z.object({SlotIndex:zod.z.number(),Level:zod.z.number().nullish(),IsDamaged:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish()}).passthrough(),bg=zod.z.object({Symbol:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),OnOpenBonus:L.nullish(),BonusTag:zod.z.string().nullish()}).passthrough();zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:L.nullish()}).passthrough();var Dg=zod.z.object({RequiredValue:zod.z.number().nullish(),Reward:L.nullish()}).passthrough(),vg=zod.z.object({Reward:L.nullish(),MetricPerReward:zod.z.number().nullish(),MaxRewardUnits:zod.z.number().nullish()}).passthrough();zod.z.object({MetricID:zod.z.string().nullish(),MaxValuePerClaim:zod.z.number().nullish(),TierMode:zod.z.string().nullish(),ApplyClaimMultiplier:zod.z.boolean().nullish(),Tiers:zod.z.array(Dg).nullish(),Rate:vg.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 cu=zod.z.object({}).passthrough().transform(o=>o),pu=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),Pe=zod.z.object({Operation:D.nullish(),ScaleWithRollMultiplier:zod.z.boolean().nullish()}).passthrough(),zg=zod.z.object({Count:zod.z.number().nullish(),Sides:zod.z.number().nullish()}).passthrough(),Tg=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(),Pg=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:ge.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(),Ig=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:ge.nullish()}).passthrough(),du=zod.z.object({SlotIndex:zod.z.number().nullish(),Name:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),MaxLevel:zod.z.number().nullish(),MaxLevelReward:L.nullish()}).passthrough(),kg=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(),Mg=zod.z.object({Tiles:zod.z.record(zod.z.string(),kg).nullish()}).passthrough(),wg=zod.z.object({Weight:zod.z.number().nullish(),Bonus:Pe.nullish(),Tag:zod.z.string().nullish()}).passthrough(),Ag=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(wg).nullish(),GuaranteedBonus:Pe.nullish(),IsJackpot:zod.z.boolean().nullish(),JackpotFinalMultiplier:zod.z.number().nullish(),JackpotSymbolDistribution:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough(),Og=zod.z.object({Variants:zod.z.array(Ag).nullish()}).passthrough(),Ug=zod.z.object({Weight:zod.z.number().nullish(),OutcomeID:zod.z.string().nullish(),Reward:Pe.nullish(),ForceAction:zod.z.string().nullish(),SpecialModeID:zod.z.string().nullish()}).passthrough(),Bg=zod.z.object({Outcomes:zod.z.array(Ug).nullish()}).passthrough(),hu=zod.z.object({PerAdMultiplierRange:pu.nullish(),MaxAdViews:zod.z.number().nullish(),AdCreditCost:zod.z.number().nullish(),FormulaKind:zod.z.string().nullish(),ApplyMultiplierOnEarlyClaim:zod.z.boolean().nullish()}).passthrough(),Lg=zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:Pe.nullish()}).passthrough(),qg=zod.z.object({Tiers:zod.z.array(Lg).nullish(),TierMode:zod.z.string().nullish(),BelowFirstTierReward:Pe.nullish()}).passthrough(),Eg=zod.z.object({RequiredValue:zod.z.number().nullish(),Reward:Pe.nullish()}).passthrough(),Gg=zod.z.object({Reward:Pe.nullish(),MetricPerReward:zod.z.number().nullish(),MaxRewardUnits:zod.z.number().nullish()}).passthrough(),Ng=zod.z.object({MetricID:zod.z.string().nullish(),MaxValuePerClaim:zod.z.number().nullish(),TierMode:zod.z.string().nullish(),ApplyClaimMultiplier:zod.z.boolean().nullish(),Tiers:zod.z.array(Eg).nullish(),Rate:Gg.nullish()}).passthrough(),mu=zod.z.object({MetricsByID:zod.z.record(zod.z.string(),Ng).nullish()}).passthrough(),jg=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:Pe.nullish(),DurationSeconds:zod.z.number().nullish(),PriceOptions:J.nullish(),Multipliers:hu.nullish(),Gradation:qg.nullish(),RunStats:mu.nullish()}).passthrough(),Fg=zod.z.object({Choices:zod.z.array(jg).nullish(),OfferExpireSeconds:zod.z.number().nullish(),ClaimExpireSeconds:zod.z.number().nullish()}).passthrough(),Vg=zod.z.object({Chance:zod.z.number().nullish(),RequiredOutcome:zod.z.string().nullish(),Reward:Pe.nullish(),Tag:zod.z.string().nullish()}).passthrough(),_g=zod.z.object({OnPassStart:Pe.nullish(),OnTileLanding:zod.z.record(zod.z.string(),Pe).nullish(),OnAttack:zod.z.record(zod.z.string(),Pe).nullish(),OnRaid:zod.z.record(zod.z.string(),Pe).nullish(),OnBuild:Pe.nullish(),OnStageComplete:Pe.nullish(),OnAttackBonusDrops:zod.z.array(Vg).nullish(),ChanceTablesByID:zod.z.record(zod.z.string(),Bg).nullish(),SpecialModesByID:zod.z.record(zod.z.string(),Fg).nullish()}).passthrough(),fu=zod.z.object({BaseAttackReward:L.nullish(),BaseRaidReward:L.nullish(),MaxRollMultiplier:zod.z.number().nullish(),MaxShields:zod.z.number().nullish(),Buildings:zod.z.array(du).nullish(),HeistGridBonusConfig:Og.nullish(),StageOperations:_g.nullish(),TileLandingMultiplier:pu.nullish(),EconomyOverride:Ig.nullish()}).passthrough(),Wg=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(du).nullish(),StageTemplateID:zod.z.string().nullish(),CostMatrixTemplateID:zod.z.string().nullish(),UnitValue:zod.z.number().nullish(),Override:fu.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(),Mg).nullish(),StageTemplatesByID:zod.z.record(zod.z.string(),fu).nullish(),StagesByLevel:zod.z.record(zod.z.string(),Wg).nullish(),SoftCurrencyID:zod.z.string().nullish(),ProceduralEconomy:Pg.nullish(),Dice:zg.nullish(),Bots:Tg.nullish()}).passthrough(),Qg=zod.z.object({IsActive:zod.z.boolean().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),AnchorUtc:u.nullish(),RoundDurationSec:zod.z.number().nullish(),PauseBetweenRoundsSec:zod.z.number().nullish(),MaxRounds:zod.z.number().nullish(),PartnerCount:zod.z.number().nullish(),MatchmakingTimeoutMinutes:zod.z.number().nullish(),MemberGracePeriodMinutes:zod.z.number().nullish(),ContributionMin:zod.z.number().nullish(),ContributionMax:zod.z.number().nullish(),ScaleContributionWithRollMultiplier:zod.z.boolean().nullish(),MaxProgress:zod.z.number().nullish(),Milestones:zod.z.record(zod.z.string(),ve).nullish(),GrandPrize:L.nullish()}).passthrough(),es=zod.z.object({Board:Xr.nullish(),CommunityChest:Qg.nullish()}).passthrough(),Kg=zod.z.object({TargetUserID:zod.z.string().nullish(),IsBot:zod.z.boolean().nullish(),PublicData:ze.nullish(),TargetBuildingStates:zod.z.array(xg).nullish(),TargetHasShield:zod.z.boolean().nullish()}).passthrough(),Hg=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:Pe.nullish(),DurationSeconds:zod.z.number().nullish(),PriceOptions:J.nullish(),Multipliers:hu.nullish(),RunStats:mu.nullish()}).passthrough(),$g=zod.z.object({ModeID:zod.z.string().nullish(),Choices:zod.z.array(Hg).nullish()}).passthrough(),Zg=zod.z.object({GroupID:zod.z.string().nullish(),Delta:w.nullish(),NewProgress:w.nullish(),MaxProgress:w.nullish(),UnlockedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),Completed:zod.z.boolean().nullish()}).passthrough(),gu=zod.z.object({UsedMultiplier:zod.z.number().nullish(),Steps:zod.z.number().nullish(),DiceValues:zod.z.array(zod.z.number()).nullish(),OldPosition:zod.z.number().nullish(),NewPosition:zod.z.number(),CyclesCompletedDelta:w.nullish(),LandedTileType:zod.z.string().nullish(),Operation:D.nullish(),ActionRequired:zod.z.string().nullish(),ActionData:Kg.nullish(),SpecialModeOffer:$g.nullish(),CommunityChestContribution:Zg.nullish()}).passthrough(),Ru=zod.z.object({Outcome:zod.z.string().nullish(),IsBotTarget:zod.z.boolean().nullish(),BuildingIndexHit:zod.z.number().nullish(),Operation:D.nullish(),DualResult:gt.nullish()}).passthrough(),Cn=zod.z.object({Status:zod.z.string().nullish(),Outcome:zod.z.string().nullish(),FoundSymbol:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),FoundBonus:L.nullish(),OpenedIndex:zod.z.number().nullish(),AttemptsLeft:zod.z.number().nullish(),RaidLayout:zod.z.array(bg).nullish(),HeistVariantTag:zod.z.string().nullish(),IsJackpot:zod.z.boolean().nullish(),Operation:D.nullish(),DualResult:gt.nullish()}).passthrough(),yu=zod.z.object({BuiltIndex:zod.z.number(),NewLevel:zod.z.number().nullish(),StageComplete:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish(),Operation:D.nullish()}).passthrough(),Cu=zod.z.object({Mode:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),Operation:D.nullish(),DurationSeconds:zod.z.number().nullish(),StartedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish()}).passthrough(),Su=zod.z.object({AdViewsUsed:zod.z.number().nullish(),RolledMultiplier:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),RemainingAdViews:zod.z.number().nullish()}).passthrough(),Jg=zod.z.object({MetricID:zod.z.string().nullish(),ReachedTierIndex:zod.z.number().nullish(),RequiredValue:zod.z.number().nullish(),RewardUnits:zod.z.number().nullish()}).passthrough(),xu=zod.z.object({FinalMultiplier:zod.z.number().nullish(),AdViewsUsed:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),IsEarlyClaim:zod.z.boolean().nullish(),ReachedTierIndex:zod.z.number().nullish(),Operation:D.nullish(),AcceptedRunStats:zod.z.record(zod.z.string(),zod.z.number()).nullish(),RunStatAwards:zod.z.array(Jg).nullish(),RunStatsClamped:zod.z.boolean().nullish(),RunStatGrant:L.nullish()}).passthrough(),Yg={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},bu=zod.z.enum(["Forming","Active","Completed","Failed","Expired"]).catch("Forming"),Xg={Active:"Active",Left:"Left",Replaced:"Replaced"},eR=zod.z.enum(["Active","Left","Replaced"]).catch("Active"),tR=zod.z.object({CurrentProgress:w.nullish(),MaxProgress:w.nullish()}).passthrough(),iR=zod.z.object({UserID:zod.z.string().nullish(),PublicData:ze.nullish(),IsBot:zod.z.boolean().nullish(),ContributionPoints:w.nullish(),ClaimedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),GrandPrizeClaimed:zod.z.boolean().nullish(),MemberStatus:eR.nullish(),JoinedAtUtc:u.nullish(),LeftAtUtc:u.nullish()}).passthrough(),Du=zod.z.object({GroupID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),Members:zod.z.array(iR).nullish(),SharedProgress:tR.nullish(),Status:bu.nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),Version:zod.z.number().nullish()}).passthrough(),rR=zod.z.object({GroupID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),FinalStatus:bu.nullish(),GrandPrizeReceived:zod.z.boolean().nullish(),FinishedAtUtc:u.nullish()}).passthrough(),sR=zod.z.object({ActiveGroupID:zod.z.string().nullish(),ActiveRoundIndex:zod.z.number().nullish(),History:zod.z.array(rR).nullish()}).passthrough(),vu=zod.z.object({ServerTimeUtc:u.nullish(),UserState:sR.nullish(),ActiveGroup:Du.nullish(),SecondsRemaining:w.nullish()}),zu=zod.z.object({ServerTimeUtc:u.nullish(),Group:Du.nullish(),SecondsRemaining:w.nullish()}),Sn=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:D.nullish()}),Tu=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),Se={GetGameLoops:"GetGameLoops",GetBoardDefinition:"GetBoardDefinition",GetBoardDefinitionForLevel:"GetBoardDefinitionForLevel",GetUserBoardState:"GetUserBoardState",BoardLoopRoll:"BoardLoopRoll",BoardLoopAttack:"BoardLoopAttack",BoardLoopRaid:"BoardLoopRaid",BoardLoopRaidFast:"BoardLoopRaidFast",BoardLoopBuild:"BoardLoopBuild",BoardSpecialChoose:"BoardSpecialChoose",BoardSpecialApplyMultiplier:"BoardSpecialApplyMultiplier",BoardSpecialClaim:"BoardSpecialClaim",GetCommunityChestState:"GetCommunityChestState",JoinOrCreateCommunityChest:"JoinOrCreateCommunityChest",ClaimCommunityChestMilestone:"ClaimCommunityChestMilestone",ClaimCommunityChestGrandPrize:"ClaimCommunityChestGrandPrize",LeaveCommunityChest:"LeaveCommunityChest"};var nR=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(),oR=zod.z.object({ExperimentID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Schedule:de.nullish(),Gate:W.nullish(),Variants:zod.z.array(nR).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(),Pu=zod.z.object({Experiments:zod.z.record(zod.z.string(),oR).nullish()}).passthrough();var aR={Mesh:"Mesh",Host:"Host"},xn=zod.z.enum(["Mesh","Host"]).catch("Mesh"),lR={ServerRelay:"ServerRelay",P2P:"P2P"},bn=zod.z.enum(["ServerRelay","P2P"]).catch("ServerRelay"),uR={Public:"Public",Private:"Private"},cR=zod.z.enum(["Public","Private"]).catch("Public"),pR={Signal:"Signal",Chat:"Chat",PlayerJoined:"PlayerJoined",PlayerLeft:"PlayerLeft",HostChanged:"HostChanged",RoomClosed:"RoomClosed",MemberState:"MemberState"},dR=zod.z.enum(["Signal","Chat","PlayerJoined","PlayerLeft","HostChanged","RoomClosed","MemberState"]).catch("Signal"),Iu=zod.z.object({Urls:zod.z.string().nullish(),Username:zod.z.string().nullish(),Credential:zod.z.string().nullish()}).passthrough(),hR=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),ku=zod.z.object({SystemState:hR.nullish(),DefaultTopology:xn.nullish(),AllowCreatorTopologyOverride:zod.z.boolean().nullish(),DefaultChatMode:bn.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(Iu).nullish()}).passthrough(),mR=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(),fR=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),Topology:xn.nullish(),ChatMode:bn.nullish(),MaxPlayers:zod.z.number().nullish(),MemberCount:zod.z.number().nullish(),CreatedAt:zod.z.number().nullish()}).passthrough(),gR=zod.z.object({Seq:zod.z.number().nullish(),Type:dR.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(),ts=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),OwnerUserID:zod.z.string().nullish(),Topology:xn.nullish(),ChatMode:bn.nullish(),Visibility:cR.nullish(),Status:zod.z.string().nullish(),MaxPlayers:zod.z.number().nullish(),Members:zod.z.array(mR).nullish(),IceServers:zod.z.array(Iu).nullish(),Seq:zod.z.number().nullish()}).passthrough(),Dn=zod.z.object({Closed:zod.z.boolean().nullish(),NewHostUserID:zod.z.string().nullish()}).passthrough(),Mu=zod.z.object({Rooms:zod.z.array(fR).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}).passthrough(),wu=zod.z.object({Envelopes:zod.z.array(gR).nullish(),MaxSeq:zod.z.number().nullish()}).passthrough(),is=zod.z.object({Seq:zod.z.number().nullish()}).passthrough(),Ve={CreateRoom:"CreateRoom",JoinRoom:"JoinRoom",LeaveRoom:"LeaveRoom",ListRooms:"ListRooms",GetRoom:"GetRoom",CloseRoom:"CloseRoom",Poll:"Poll",SendSignal:"SendSignal",SendChat:"SendChat",SetMemberState:"SetMemberState"};var vn=zod.z.object({TitleCustomData:Jr.nullish(),Character:Xi.nullish(),Item:hr.nullish(),Currency:Yi.nullish(),Store:fr.nullish(),Lootbox:Xs.nullish(),Quest:oi.nullish(),TimedEvent:zr.nullish(),Leaderboard:wr.nullish(),Season:Or.nullish(),Reward:en.nullish(),Collection:jr.nullish(),Craft:un.nullish(),DealOffer:fn.nullish(),Premium:ln.nullish(),TimedBoost:Hr.nullish(),CoopEvent:Vr.nullish(),GameLoop:es.nullish(),Match:Vs.nullish(),Experiment:Pu.nullish(),Blockchain:Ls.nullish(),Marketplace:Ks.nullish(),Multiplayer:ku.nullish(),UserCustomData:Wi.nullish(),Referral:gn.nullish(),Localization:ka.nullish()}).passthrough();var bt={GetTitlePublicConfiguration:"GetTitlePublicConfiguration",GetTitlePublicConfigurationExcept:"GetTitlePublicConfigurationExcept",GetCurrencyDefinitions:"GetCurrencyDefinitions",GetItemDefinitions:"GetItemDefinitions",GetServerTime:"GetServerTime"};var rs=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Title",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getTitlePublicConfiguration(e){return this.send(bt.GetTitlePublicConfiguration,e,vn)}getTitlePublicConfigurationExcept(e){return this.send(bt.GetTitlePublicConfigurationExcept,e,vn)}getCurrencyDefinitions(e){return this.send(bt.GetCurrencyDefinitions,e,Yi)}getItemDefinitions(e){return this.send(bt.GetItemDefinitions,e,hr)}getServerTime(e){return this.send(bt.GetServerTime,e,be)}};var ss=class{constructor(e){this.ctx=e;}ctx;send(e,t,i,r=false){let s=O(this.ctx.settings.titleID,"GameLoop",e,t.UserID??"");return this.ctx.transport.post(s,t,i,{ticket:t.ClientSessionTicket,silent:r})}getGameLoops(e){return this.send(Se.GetGameLoops,e,es)}getBoardDefinition(e,t=false){return this.send(Se.GetBoardDefinition,e,Xr,t)}getBoardDefinitionForLevel(e,t=false){return this.send(Se.GetBoardDefinitionForLevel,e,Xr,t)}getUserBoardState(e){return this.send(Se.GetUserBoardState,e,cu)}boardLoopRoll(e){return this.send(Se.BoardLoopRoll,e,gu)}boardLoopAttack(e){return this.send(Se.BoardLoopAttack,e,Ru)}boardLoopRaid(e){return this.send(Se.BoardLoopRaid,e,Cn)}boardLoopRaidFast(e){return this.send(Se.BoardLoopRaidFast,e,Cn)}boardLoopBuild(e){return this.send(Se.BoardLoopBuild,e,yu)}boardSpecialChoose(e){return this.send(Se.BoardSpecialChoose,e,Cu)}boardSpecialApplyMultiplier(e){return this.send(Se.BoardSpecialApplyMultiplier,e,Su)}boardSpecialClaim(e){return this.send(Se.BoardSpecialClaim,e,xu)}getCommunityChestState(e){return this.send(Se.GetCommunityChestState,e,vu)}joinOrCreateCommunityChest(e){return this.send(Se.JoinOrCreateCommunityChest,e,zu)}claimCommunityChestMilestone(e){return this.send(Se.ClaimCommunityChestMilestone,e,Sn)}claimCommunityChestGrandPrize(e){return this.send(Se.ClaimCommunityChestGrandPrize,e,Sn)}leaveCommunityChest(e){return this.send(Se.LeaveCommunityChest,e,Tu)}};var Jt=zod.z.lazy(()=>zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null(),zod.z.array(Jt),zod.z.record(zod.z.string(),Jt)]));var yR={Live:"Live",Latest:"Latest",Specific:"Specific"},CR={Debug:"Debug",Info:"Info",Warning:"Warning",Error:"Error"},SR=zod.z.enum(["Debug","Info","Warning","Error"]).catch("Debug"),xR={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"},bR=zod.z.enum(["None","Disabled","NoActiveRevision","RevisionNotFound","InvalidFieldName","RateLimited","HandlerNotFound","HandlerDisabled","Timeout","StatementCountExceeded","StackOverflow","ApiCallLimitExceeded","JavaScriptException","ExecutionError"]).catch("None"),DR=zod.z.object({Level:SR,Message:zod.z.string().nullish(),Data:Jt.nullish()}),vR=zod.z.object({Error:bR,Message:zod.z.string().nullish(),StackTrace:zod.z.string().nullish()}),Au=zod.z.object({FunctionName:zod.z.string().nullish(),Revision:zod.z.number().nullish(),FunctionResult:Jt.nullish(),FunctionResultTooLarge:zod.z.boolean().nullish(),Logs:zod.z.array(DR).nullish(),LogsTooLarge:zod.z.boolean().nullish(),ExecutionTimeSeconds:zod.z.number().nullish(),APIRequestsIssued:zod.z.number().nullish(),Error:vR.nullish()}),zn={Execute:"Execute"};var ns=class{constructor(e){this.ctx=e;}ctx;execute(e){let t=O(this.ctx.settings.titleID,"CloudCode",zn.Execute,e.UserID??"");return this.ctx.transport.post(t,e,Au,{ticket:e.ClientSessionTicket})}};var os=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Blockchain",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ue.GetDefinitions,e,Jo)}getUserState(e){return this.send(Ue.GetUserState,e,Yo)}depositToken(e){return this.send(Ue.DepositToken,e,Xo)}depositNFT(e){return this.send(Ue.DepositNFT,e,ea)}requestTokenWithdrawal(e){return this.send(Ue.RequestTokenWithdrawal,e,ta)}requestNFTWithdrawal(e){return this.send(Ue.RequestNFTWithdrawal,e,ia)}getTransactionHistory(e){return this.send(Ue.GetTransactionHistory,e,ra)}retryWithdrawal(e){return this.send(Ue.RetryWithdrawal,e,sa)}confirmWithdrawal(e){return this.send(Ue.ConfirmWithdrawal,e,na)}donateToDeveloper(e){return this.send(Ue.DonateToDeveloper,e,Gs)}donateToUsersPool(e){return this.send(Ue.DonateToUsersPool,e,Gs)}};var as=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Marketplace",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(ae.GetDefinitions,e,Ca)}getGroupedOffers(e){return this.send(ae.GetGroupedOffers,e,Sa)}getOffersByItem(e){return this.send(ae.GetOffersByItem,e,Hs)}getOffer(e){return this.send(ae.GetOffer,e,xa)}getBuyOrders(e){return this.send(ae.GetBuyOrders,e,Hs)}getMyState(e){return this.send(ae.GetMyState,e,Da)}getHistory(e){return this.send(ae.GetHistory,e,va)}createListing(e){return this.send(ae.CreateListing,e,Qt)}cancelListing(e){return this.send(ae.CancelListing,e,Ge)}buy(e){return this.send(ae.Buy,e,Ge)}marketBuy(e){return this.send(ae.MarketBuy,e,Ge)}marketSell(e){return this.send(ae.MarketSell,e,Ge)}createAuction(e){return this.send(ae.CreateAuction,e,Qt)}placeBid(e){return this.send(ae.PlaceBid,e,ba)}claimAuction(e){return this.send(ae.ClaimAuction,e,Ge)}createBuyOrder(e){return this.send(ae.CreateBuyOrder,e,Qt)}cancelBuyOrder(e){return this.send(ae.CancelBuyOrder,e,Ge)}fillBuyOrder(e){return this.send(ae.FillBuyOrder,e,Ge)}createDirectTrade(e){return this.send(ae.CreateDirectTrade,e,Qt)}respondDirectTrade(e){return this.send(ae.RespondDirectTrade,e,Ge)}cancelDirectTrade(e){return this.send(ae.CancelDirectTrade,e,Ge)}claimBack(e){return this.send(ae.ClaimBack,e,Ge)}};var ls=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Multiplayer",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}createRoom(e){return this.send(Ve.CreateRoom,e,ts)}joinRoom(e){return this.send(Ve.JoinRoom,e,ts)}leaveRoom(e){return this.send(Ve.LeaveRoom,e,Dn)}listRooms(e){return this.send(Ve.ListRooms,e,Mu)}getRoom(e){return this.send(Ve.GetRoom,e,ts)}closeRoom(e){return this.send(Ve.CloseRoom,e,Dn)}poll(e){return this.send(Ve.Poll,e,wu)}sendSignal(e){return this.send(Ve.SendSignal,e,is)}sendChat(e){return this.send(Ve.SendChat,e,is)}setMemberState(e){return this.send(Ve.SetMemberState,e,is)}};var us=class{settings;emitter;platform;acquisition;playtime;clientPlatform;transport;fetchImpl;data;authStore;api;auth;userService;currency;item;store;purchase;checkout;lootbox;reward;quest;tutorial;localization;timedEvent;leaderboard;season;premium;character;match;craft;collection;coopEvent;dealOffer;referral;social;timedBoost;userCustomData;titleCustomData;title;gameLoop;cloudCode;blockchain;marketplace;multiplayer;constructor(e){this.settings=Mn(e),this.emitter=new Nt,this.platform=e.platform??new Tt,this.clientPlatform=e.clientPlatform??Vn(),this.acquisition=new ft(this.platform),this.acquisition.capture(),this.playtime=new jt(this),this.emitter.on("auth:loggedIn",()=>{this.playtime.start(),this.acquisition.clear();}),this.emitter.on("auth:loggedOut",()=>{this.playtime.stop();}),this.fetchImpl=e.fetch??globalThis.fetch.bind(globalThis),this.transport=new ui({baseUrl:this.settings.baseUrl,emitter:this.emitter,fetchImpl:e.fetch,debugLogging:this.settings.debugLogging,throttleMs:e.throttleMs,clientPlatform:this.clientPlatform}),this.data=new hi(this.emitter),this.emitter.on("quest:systemProgress",t=>{this.data.user.patchQuestProgressUpdates(t);}),this.emitter.on("tutorial:systemProgress",t=>{this.data.user.patchTutorialProgress(t);}),this.emitter.on("user:stateVersions",({epoch:t,versions:i})=>{this.userService.noteStateVersions(t,i);}),this.authStore=new mi(this.platform.storage,this.settings.titleID),this.api={authentication:new lr(this),user:new cr(this),currency:new pr(this),item:new mr(this),store:new gr(this),purchase:new Rr(this),lootbox:new Sr(this),reward:new xr(this),quest:new vr(this),tutorial:new br(this),localization:new Dr(this),timedEvent:new Tr(this),leaderboard:new Ar(this),season:new Ur(this),premium:new Lr(this),character:new qr(this),match:new Er(this),craft:new Nr(this),collection:new Fr(this),coopEvent:new _r(this),dealOffer:new Wr(this),referral:new Qr(this),social:new Kr(this),timedBoost:new $r(this),userCustomData:new Zr(this),titleCustomData:new Yr(this),title:new rs(this),gameLoop:new ss(this),cloudCode:new ns(this),blockchain:new os(this),marketplace:new as(this),multiplayer:new ls(this)},this.userService=new yi(this),this.auth=new fi(this),this.currency=new Si(this),this.item=new xi(this),this.store=new bi(this),this.purchase=new Di(this),this.checkout=new vi(this),this.lootbox=new zi(this),this.reward=new Ti(this),this.quest=new Mi(this),this.tutorial=new Pi(this),this.localization=new ki(this),this.timedEvent=new wi(this),this.leaderboard=new Ai(this),this.season=new Oi(this),this.premium=new Ui(this),this.character=new Bi(this),this.match=new Li(this),this.craft=new qi(this),this.collection=new Ei(this),this.coopEvent=new Gi(this),this.dealOffer=new Ni(this),this.referral=new ji(this),this.social=new Fi(this),this.timedBoost=new Vi(this),this.userCustomData=new Qi(this),this.titleCustomData=new Ki(this),this.title=new Hi(this),this.gameLoop=new $i(this),this.cloudCode=new Zi(this),this.blockchain=new ir(this),this.marketplace=new or(this),this.multiplayer=new ar(this),this.transport.setSessionRefreshHandler(()=>this.auth.refreshSession());}buildAuthedBaseRequest(){let e=this.auth.context;return {UserID:e?.userID,ClientSessionTicket:e?.clientSessionTicket,BuildKey:this.settings.buildKey,WebAppLink:this.platform.getFullURL(),RelatedEntityID:P()}}};var cs=class{ctx;constructor(e){this.ctx=new us(e);}get titleID(){return this.ctx.settings.titleID}get auth(){return this.ctx.auth}get user(){return this.ctx.userService}get currency(){return this.ctx.currency}get item(){return this.ctx.item}get store(){return this.ctx.store}get purchase(){return this.ctx.purchase}get checkout(){return this.ctx.checkout}get lootbox(){return this.ctx.lootbox}get reward(){return this.ctx.reward}get quest(){return this.ctx.quest}get tutorial(){return this.ctx.tutorial}get localization(){return this.ctx.localization}get timedEvent(){return this.ctx.timedEvent}get leaderboard(){return this.ctx.leaderboard}get season(){return this.ctx.season}get premium(){return this.ctx.premium}get character(){return this.ctx.character}get match(){return this.ctx.match}get craft(){return this.ctx.craft}get collection(){return this.ctx.collection}get coopEvent(){return this.ctx.coopEvent}get dealOffer(){return this.ctx.dealOffer}get referral(){return this.ctx.referral}get social(){return this.ctx.social}get timedBoost(){return this.ctx.timedBoost}get userCustomData(){return this.ctx.userCustomData}get titleCustomData(){return this.ctx.titleCustomData}get title(){return this.ctx.title}get gameLoop(){return this.ctx.gameLoop}get cloudCode(){return this.ctx.cloudCode}get blockchain(){return this.ctx.blockchain}get marketplace(){return this.ctx.marketplace}get multiplayer(){return this.ctx.multiplayer}get data(){return this.ctx.data}get platform(){return this.ctx.platform}on(e,t){return this.ctx.emitter.on(e,t)}once(e,t){return this.ctx.emitter.once(e,t)}off(e,t){this.ctx.emitter.off(e,t);}};function zR(o){return new cs(o)}var Ou="idos_sso",Uu="state",Tn="idos:sso:state",TR="https://idosgames.com/sso/";function PR(){if(typeof window>"u")return null;let o=window.location.hash?.startsWith("#")?window.location.hash.slice(1):window.location.hash;if(!o)return null;let e=new URLSearchParams(o),t=e.get(Ou);if(!t)return null;let i=e.get(Uu)??"",r=AR();return UR(e),OR(),r&&i!==r?null:{code:t,state:i}}function IR(o){if(typeof window>"u")return;let e=o.returnTo??kR(),t=MR();wR(t);let i=new URL(o.ssoUrl??TR);i.searchParams.set("title",o.titleID),i.searchParams.set("return_to",e),i.searchParams.set("state",t),window.location.assign(i.toString());}function kR(){let{origin:o,pathname:e,search:t}=window.location;return `${o}${e}${t}`}function MR(){let o=new Uint8Array(16);if(typeof crypto<"u"&&crypto.getRandomValues)crypto.getRandomValues(o);else for(let e=0;e<o.length;e++)o[e]=Math.floor(Math.random()*256);return Array.from(o,e=>e.toString(16).padStart(2,"0")).join("")}function wR(o){try{window.sessionStorage.setItem(Tn,o);}catch{}}function AR(){try{return window.sessionStorage.getItem(Tn)}catch{return null}}function OR(){try{window.sessionStorage.removeItem(Tn);}catch{}}function UR(o){o.delete(Ou),o.delete(Uu);let e=o.toString(),{pathname:t,search:i}=window.location;window.history.replaceState(null,"",`${t}${i}${e?`#${e}`:""}`);}function BR(o,e){return !!o?.Claims?.[e]?.ClaimedAt}function LR(o){let e=o?.Claims;return e?Object.keys(e).filter(t=>!!e[t]?.ClaimedAt):[]}function qR(o,e){return o?.Claims?.[e]?.PremiumTiers??[]}function Lu(o,e,t,i=1){if(!o)return e;let r=o.Base??e,s=Math.max(0,t-i),a;switch(o.Shape??"Flat"){case "PerStep":a=r+(o.PerStep??0)*s;break;case "PerStepRate":a=r*(1+(o.PerStepRate??0)*s);break;case "Geometric":a=r*Math.pow(1+(o.GrowthRate??0),s);break;case "Table":a=r*Bu(o,t,1);break;case "TableAbsolute":a=Bu(o,t,r);break;default:a=r;break}return Number.isNaN(a)?r:(o.MinResult!=null&&a<o.MinResult&&(a=o.MinResult),o.MaxResult!=null&&a>o.MaxResult&&(a=o.MaxResult),a)}function ER(o,e,t=1){return Lu(o,1,e,t)}function GR(o){if(!o)return false;switch(o.Shape??"Flat"){case "PerStep":return (o.PerStep??0)!==0;case "PerStepRate":return (o.PerStepRate??0)!==0;case "Geometric":return (o.GrowthRate??0)!==0;case "Table":case "TableAbsolute":return qu(o.Points).length>0;default:return o.MinResult!=null||o.MaxResult!=null}}function NR(o){if(Number.isNaN(o)||o<=0)return 0;if(!Number.isFinite(o))return Number.MAX_SAFE_INTEGER;let e=Math.round(o);return Math.abs(o-e)<=1e-9*Math.max(1,Math.abs(o))?e:Math.ceil(o)}function qu(o){if(!o)return [];let e=[];for(let t of o)t?.AtStep==null||t.Value==null||e.push({AtStep:t.AtStep,Value:t.Value});return e}function Bu(o,e,t){let i=qu(o.Points);if(i.length===0)return t;let r=null,s=null,a=null;for(let p of i)(a===null||p.AtStep>a.AtStep)&&(a=p),p.AtStep<=e&&(r===null||p.AtStep>=r.AtStep)&&(r=p),p.AtStep>e&&(s===null||p.AtStep<s.AtStep)&&(s=p);if(r===null)return t;if(s===null){let p=o.TailGrowthRate??0;return p===0?a.Value:a.Value*Math.pow(1+p,e-a.AtStep)}switch(o.Interpolation??"Step"){case "Linear":{let p=(e-r.AtStep)/(s.AtStep-r.AtStep);return r.Value+p*(s.Value-r.Value)}case "Geometric":{if(r.Value<=0||s.Value<=0){let x=(e-r.AtStep)/(s.AtStep-r.AtStep);return r.Value+x*(s.Value-r.Value)}let p=(e-r.AtStep)/(s.AtStep-r.AtStep);return r.Value*Math.pow(s.Value/r.Value,p)}default:return r.Value}}var jR={Banner:"Banner",Interstitial:"Interstitial",RewardedVideo:"RewardedVideo",RewardedInterstitial:"RewardedInterstitial",AppOpen:"AppOpen",Native:"Native"},Pn=zod.z.enum(["Banner","Interstitial","RewardedVideo","RewardedInterstitial","AppOpen","Native"]).catch("Banner"),FR={Top:"Top",Bottom:"Bottom",Left:"Left",Right:"Right"},VR=zod.z.enum(["Top","Bottom","Left","Right"]).catch("Top"),_R=zod.z.object({PlacementID:zod.z.string().nullish(),Type:Pn.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(),WR=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(),QR=zod.z.object({CooldownSeconds:zod.z.number().nullish(),MinSessionTimeBeforeFirstSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),KR=zod.z.object({Enabled:zod.z.boolean().nullish(),Position:VR.nullish(),RefreshIntervalSeconds:zod.z.number().nullish()}).passthrough(),HR=zod.z.object({Enabled:zod.z.boolean().nullish(),CooldownSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish()}).passthrough(),$R=zod.z.object({MaxImpressionsPerHour:zod.z.number().nullish(),MaxImpressionsPerDay:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),ZR=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(),JR=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(),YR=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(),XR=zod.z.object({AndroidUnitID:zod.z.string().nullish(),IosUnitID:zod.z.string().nullish(),WebUnitID:zod.z.string().nullish(),Type:Pn.nullish()}).passthrough(),ey={AppLovinMax:"AppLovinMax",LevelPlay:"LevelPlay"},ty=zod.z.enum(["AppLovinMax","LevelPlay"]).catch("AppLovinMax"),iy=zod.z.object({ProviderID:zod.z.string().nullish(),Kind:ty.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(),XR).nullish()}).passthrough();zod.z.object({Enabled:zod.z.boolean().nullish(),Placements:zod.z.record(zod.z.string(),_R).nullish(),Providers:zod.z.record(zod.z.string(),iy).nullish(),RewardedVideo:WR.nullish(),Interstitial:QR.nullish(),Banner:KR.nullish(),AppOpen:HR.nullish(),FrequencyCapping:$R.nullish(),PremiumAdReductions:zod.z.array(ZR).nullish(),Consent:JR.nullish(),Verification:YR.nullish()}).passthrough();var ry=zod.z.object({RewardedVideoCredit:zod.z.number().nullish(),TotalEarned:zod.z.number().nullish(),TotalSpent:zod.z.number().nullish()}).passthrough(),sy=zod.z.object({PlacementID:zod.z.string().nullish(),LastShownAt:u.nullish(),LastCompletedAt:u.nullish(),TotalImpressions:zod.z.number().nullish(),TotalCompletions:zod.z.number().nullish(),ConsecutiveFailures:zod.z.number().nullish()}).passthrough(),ny=zod.z.object({Date:u.nullish(),ImpressionsByPlacement:zod.z.record(zod.z.string(),zod.z.number()).nullish(),CompletionsByPlacement:zod.z.record(zod.z.string(),zod.z.number()).nullish(),TotalImpressions:zod.z.number().nullish(),InterstitialImpressions:zod.z.number().nullish(),RewardedCompletions:zod.z.number().nullish(),AppOpenImpressions:zod.z.number().nullish(),CreditsEarnedToday:zod.z.number().nullish()}).passthrough(),oy=zod.z.object({SessionID:zod.z.string().nullish(),SessionStartAt:u.nullish(),Impressions:zod.z.number().nullish(),InterstitialImpressions:zod.z.number().nullish(),RewardedCompletions:zod.z.number().nullish()}).passthrough(),ay=zod.z.object({PersonalizedAdsConsent:zod.z.boolean().nullish(),TrackingConsent:zod.z.boolean().nullish(),PolicyVersion:zod.z.string().nullish(),Region:zod.z.string().nullish(),ConsentGivenAt:u.nullish(),ConsentRevokedAt:u.nullish()}).passthrough(),ly=zod.z.object({RequestID:zod.z.string().nullish(),PlacementID:zod.z.string().nullish(),ProviderID:zod.z.string().nullish(),Type:Pn.nullish(),IssuedAt:u.nullish(),ExpiresAt:u.nullish(),CreditsToAward:zod.z.number().nullish()}).passthrough(),uy=zod.z.object({InvalidSsvCount:zod.z.number().nullish(),OrphanCompletions:zod.z.number().nullish(),FastCompletions:zod.z.number().nullish(),LastFlaggedAt:u.nullish()}).passthrough();zod.z.object({Credits:ry.nullish(),Placements:zod.z.record(zod.z.string(),sy).nullish(),Daily:ny.nullish(),Session:oy.nullish(),LastImpressionAt:u.nullish(),LastInterstitialAt:u.nullish(),LastRewardedAt:u.nullish(),LastAppOpenAt:u.nullish(),TotalImpressions:zod.z.number().nullish(),TotalRewardedCompletions:zod.z.number().nullish(),AdsDisabledUntil:u.nullish(),Consent:ay.nullish(),PendingRequests:zod.z.record(zod.z.string(),ly).nullish(),FraudFlags:uy.nullish(),UpdatedAt:u.nullish()}).passthrough();var cy={Unread:"Unread",Read:"Read",Deleted:"Deleted",Expired:"Expired"},py=zod.z.enum(["Unread","Read","Deleted","Expired"]).catch("Unread"),dy={Admin:"Admin",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season",Collection:"Collection",MilestoneEvent:"MilestoneEvent",PlayerGift:"PlayerGift",Social:"Social",Compensation:"Compensation",Referral:"Referral",Quest:"Quest"},hy=zod.z.enum(["Admin","Leaderboard","CoopEvent","Season","Collection","MilestoneEvent","PlayerGift","Social","Compensation","Referral","Quest"]).catch("Admin"),my={Active:"Active",Paused:"Paused",Cancelled:"Cancelled",Completed:"Completed"},fy=zod.z.enum(["Active","Paused","Cancelled","Completed"]).catch("Active"),gy=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(),Ry=zod.z.object({SegmentID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Gate:W.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(),gy).nullish(),Segments:zod.z.array(Ry).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:hy.nullish(),RelatedEntityID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderPublicData:ze.nullish(),Subject:zod.z.string().nullish(),Body:zod.z.string().nullish(),TemplateParams:zod.z.record(zod.z.string(),zod.z.string()).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rewards:L.nullish(),Claimed:zod.z.boolean().nullish(),ClaimedAtUtc:u.nullish(),Status:py.nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),ReadAtUtc:u.nullish(),BroadcastID:zod.z.string().nullish(),Version:zod.z.number().nullish()}).passthrough();zod.z.object({BroadcastID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),MessageTypeID:zod.z.string().nullish(),Subject:zod.z.string().nullish(),Body:zod.z.string().nullish(),TemplateParams:zod.z.record(zod.z.string(),zod.z.string()).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rewards:L.nullish(),TargetSegmentID:zod.z.string().nullish(),TargetUserIDs:zod.z.array(zod.z.string()).nullish(),StartsAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),CreatedAtUtc:u.nullish(),CreatedByAdminID:zod.z.string().nullish(),AdminComment:zod.z.string().nullish(),Status:fy.nullish(),DeliveredCount:zod.z.number().nullish(),ClaimedCount:zod.z.number().nullish()}).passthrough();zod.z.object({UnreadCount:zod.z.number().nullish(),UnclaimedRewardCount:zod.z.number().nullish(),LastFetchCursor:u.nullish(),ReceivedBroadcastIDs:zod.z.array(zod.z.string()).nullish(),ClaimedBroadcastIDs:zod.z.array(zod.z.string()).nullish(),DailyP2PGiftsSent:zod.z.number().nullish(),DailyGiftsResetDate:u.nullish(),LastOpenedAtUtc:u.nullish(),TotalMessagesReceived:zod.z.number().nullish(),TotalRewardsClaimed:zod.z.number().nullish()}).passthrough();var Eu="idos_device_id",ps=class{storage;constructor(e=new vt){this.storage=e;}getPlatform(){return "Web"}getFullURL(){return ""}getStartParameter(){return null}getTelegramInitDataRaw(){return null}getDeviceID(){let e=this.storage.getString(Eu);return e||(e="noop-device",this.storage.setString(Eu,e)),e}getDeviceModel(){return "Noop"}shareLink(){}openInvoice(){}async showAd(){}async copyToClipboard(){}};
2
- exports.AcquisitionCapture=ft;exports.AdProviderKind=ey;exports.AdType=jR;exports.AttackOutcome=Sg;exports.AuthType=Re;exports.AuthenticationAction=we;exports.BannerPosition=FR;exports.BlockchainAction=Ue;exports.BlockchainNetworkType=gd;exports.BlockchainOperationCategory=Qo;exports.BlockchainTransactionStatus=zd;exports.BlockchainTransactionType=Sd;exports.BodyPart=$d;exports.BoostWindowKind=cg;exports.BroadcastStatus=my;exports.BrowserPlatformAdapter=Tt;exports.BrowserStorage=Dt;exports.CharacterAction=Oe;exports.ClientPlatform=Ye;exports.CloudCodeAction=zn;exports.CloudCodeErrorCode=xR;exports.CloudCodeLogLevel=CR;exports.CloudCodeRevisionSelection=yR;exports.CollectionAction=Te;exports.CommissionSink=fh;exports.CommunityChestMemberStatus=Xg;exports.CommunityChestStatus=Yg;exports.ConversionRateMode=Qp;exports.CoopEventAction=He;exports.CoopGroupStatus=Rf;exports.CoopMemberStatus=yf;exports.CraftAction=Gr;exports.CraftType=rf;exports.CurrencyAction=Ji;exports.CurrencyStatus=Wp;exports.CurrencyType=_e;exports.CurveInterpolation=pc;exports.CurveShape=uc;exports.CustomDataBucket=st;exports.CustomDataValueType=Bp;exports.CustomDataWriter=wp;exports.DEFAULT_BASE_URL=kn;exports.DealNodeRuntimeStatus=kf;exports.DealOfferAction=it;exports.DealOfferActivationStatus=If;exports.EnvelopeType=pR;exports.EventTokenType=Zu;exports.FodderSelectionMode=Nh;exports.FodderValuationMode=Eh;exports.FriendActionStatus=Yf;exports.GameLoopAction=Se;exports.IDosGamesClient=cs;exports.IapProductType=im;exports.IapPurchaseStatus=am;exports.IapStoreValues=$u;exports.ItemAction=dr;exports.KycStatus=xd;exports.KycTier=Dd;exports.LeaderboardAction=De;exports.LocalizationAction=ur;exports.LocalizationMissingKeyMode=Oh;exports.LootboxAction=Cr;exports.MailboxMessageSource=dy;exports.MailboxMessageStatus=cy;exports.MarketGoodsType=nr;exports.MarketOfferStatus=mh;exports.MarketOfferType=hh;exports.MarketplaceAction=ae;exports.MatchAction=tt;exports.MatchStatus=Zd;exports.MemoryStorage=vt;exports.MultiplayerAction=Ve;exports.MultiplayerChatMode=lR;exports.MultiplayerTopology=aR;exports.NoopPlatformAdapter=ps;exports.PlaytimeTracker=jt;exports.PremiumAction=Ct;exports.PurchaseAction=Ut;exports.QuestAction=Qe;exports.QuestObjectiveSource=xc;exports.QuestPrerequisiteMode=Dc;exports.QuestStatus=yc;exports.RaidMode=yg;exports.ReferralAction=St;exports.ResourceEntryType=Xt;exports.RewardAction=ot;exports.RoomVisibility=uR;exports.ScheduleMode=Ju;exports.SeasonAction=ht;exports.SocialAction=$e;exports.SpecialChoiceMode=Cg;exports.StoreAction=Ot;exports.StoreType=Xm;exports.TimedBoostAction=xt;exports.TimedBoostStackingPolicy=ig;exports.TimedEventAction=Fe;exports.TimelineEventType=Xf;exports.TitleAction=bt;exports.TitleCustomDataAction=Zt;exports.TitleDataBucket=hg;exports.TitleDataScope=dg;exports.TradeOfferStatus=of;exports.TransactionDirection=Td;exports.TutorialAction=qe;exports.TutorialBoardAction=Ec;exports.TutorialFlowStatus=Bc;exports.TutorialGateMode=rc;exports.TutorialRestartPolicy=Oc;exports.TutorialScriptModule=qc;exports.TutorialStepCompletionMode=wc;exports.TypedEmitter=Nt;exports.UserAction=je;exports.UserCustomDataAction=Ke;exports.WalletLinkType=yd;exports.beginSsoRedirect=IR;exports.claimedMilestoneIDs=LR;exports.createIDosGamesClient=zR;exports.curveMultiplier=ER;exports.evaluateCurve=Lu;exports.grantedPremiumTiers=qR;exports.isCurveConfigured=GR;exports.isFail=Xu;exports.isMilestoneClaimed=BR;exports.isOk=Yu;exports.normalizeBlockchainCategory=er;exports.readSsoCodeFromUrl=PR;exports.roundAmount=NR;exports.zPaymentProof=id;exports.zPriceOption=Ao;exports.zPriceOptions=J;
1
+ 'use strict';var zod=require('zod'),Ci=require('decimal.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Ci__default=/*#__PURE__*/_interopDefault(Ci);var Jt=class{listeners=new Map;on(e,t){let i=this.listeners.get(e);return i||(i=new Set,this.listeners.set(e,i)),i.add(t),()=>{this.off(e,t);}}once(e,t){let i=this.on(e,r=>{i(),t(r);});return i}off(e,t){let i=this.listeners.get(e);i&&(i.delete(t),i.size===0&&this.listeners.delete(e));}emit(e,t){let i=this.listeners.get(e);if(i)for(let r of [...i])r(t);}removeAllListeners(){this.listeners.clear();}};function qc(){let o=new Map;return {get:e=>o.get(e)??null,set:(e,t)=>{o.set(e,t);},remove:e=>{o.delete(e);}}}function $n(){return Ec()??qc()}function Ec(){try{let o=globalThis.localStorage;if(!o)return null;let e="__idos_probe__";return o.setItem(e,"1"),o.removeItem(e),{get:t=>{try{return o.getItem(t)}catch{return null}},set:(t,i)=>{try{o.setItem(t,i);}catch{try{o.removeItem(t);}catch{}}},remove:t=>{try{o.removeItem(t);}catch{}}}}catch{return null}}var Zn="https://api.idosgames.com";function Jn(o){return {titleID:o.titleID,titleTemplateID:o.titleTemplateID??"default",buildKey:o.buildKey??"",baseUrl:(o.baseUrl??Zn).replace(/\/+$/,""),devBuild:o.devBuild??false,debugLogging:o.debugLogging??false,configStorage:o.configStorage??$n(),locale:o.locale??Gc(),appVersion:o.appVersion??""}}function Gc(){try{return globalThis.navigator?.language??""}catch{return ""}}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{}}},Ot=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 Yn="idos_device_id",Bt=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}getReferrer(){if(typeof document>"u")return null;let e=document.referrer;return e&&e.length>0?e:null}getTelegramInitDataRaw(){let e=Ut()?.initData;return e&&e.length>0?e:null}getDeviceID(){let e=this.storage.getString(Yn);return e||(e=M(),this.storage.setString(Yn,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);}};var ks="idos_acq",Xn=["gclid","fbclid","ttclid","msclkid","yclid"],Nc=["ref","r"],jc=["ref_","ref-","ref=","r_","r-"];var bt=class{constructor(e){this.platform=e;}platform;capture(){let e=this.readFromEnvironment();Fc(e)&&this.store({signal:e,capturedAt:Date.now()});}buildForLogin(e){let t=this.read(),i=t?{...t.signal}:{},r=Wc(this.platform.getDeviceModel());return r&&(i.OsVersion=r),e&&(i.AppVersion=e),Object.keys(i).length>0?i:void 0}clear(){this.platform.storage.remove(ks);}static detectDevicePlatform(e){let t=(e||"").toLowerCase();return t.includes("android")?"Android":/iphone|ipad|ipod/.test(t)?"iOS":"Web"}static parseReferralCode(e){if(!e)return null;let t=e.trim();if(!t)return null;if(t.includes("://")||t.includes("?")){let i=io(to(t));if(i)return i}return ai(t)}readFromEnvironment(){let e={},t=to(this.platform.getFullURL());xt(e,"UtmSource",t.get("utm_source")),xt(e,"UtmMedium",t.get("utm_medium")),xt(e,"UtmCampaign",t.get("utm_campaign")),xt(e,"UtmTerm",t.get("utm_term")),xt(e,"UtmContent",t.get("utm_content")),xt(e,"ClaimToken",t.get("idos_click"));for(let k of Xn){let N=t.get(k);if(N){e.ClickID=N;break}}let i=this.platform.getStartParameter()??"",r=_c(i);if(r){for(let k of Vc)xt(e,k,r.get(ro[k])??null);for(let k of Xn){let N=r.get(k);if(N){e.ClickID=N;break}}}let s=ai(r?r.get("ref")??r.get("r")??"":i),a=io(t),p=s||a;p&&(e.ReferralCode=p,e.ChannelHint=s?"telegram":"query");let x=this.platform.getReferrer?.();return x&&(e.Referrer=x),e}read(){try{let e=this.platform.storage.getString(ks);if(!e)return null;let t=JSON.parse(e);return !t?.signal||typeof t.capturedAt!="number"?null:Date.now()-t.capturedAt>2592e6?(this.clear(),null):t}catch{return null}}store(e){try{this.platform.storage.setString(ks,JSON.stringify(e));}catch{}}};function Fc(o){return !!(o.UtmSource||o.UtmMedium||o.UtmCampaign||o.ClickID||o.Referrer||o.ReferralCode||o.ClaimToken)}function xt(o,e,t){t&&(o[e]=t);}var eo="a1_",ro={UtmSource:"utm_source",UtmMedium:"utm_medium",UtmCampaign:"utm_campaign",UtmTerm:"utm_term",UtmContent:"utm_content"},Vc=Object.keys(ro);function _c(o){let e=(o||"").trim();if(!e.startsWith(eo))return null;let t=e.slice(eo.length);if(!t)return null;try{let i=t.replace(/-/g,"+").replace(/_/g,"/"),r=atob(i+"=".repeat((4-i.length%4)%4)),s=Uint8Array.from(r,x=>x.charCodeAt(0)),a=new TextDecoder().decode(s),p=new URLSearchParams(a);return [...p.keys()].length>0?p:null}catch{return null}}function to(o){try{let e=o.indexOf("?");return new URLSearchParams(e>=0?o.slice(e):"")}catch{return new URLSearchParams}}function io(o){for(let e of Nc){let t=o.get(e);if(t)return ai(t)}return null}function ai(o){let e=(o||"").trim();if(!e)return null;for(let t of jc)if(e.toLowerCase().startsWith(t)){e=e.slice(t.length).trim();break}return e||null}function Wc(o){let e=o||"",t=/android\s+(\d+)/i.exec(e);if(t)return t[1];let i=/(?:iphone )?os\s+(\d+)[._]/i.exec(e);if(i)return i[1]}var so="idos_usage_pending",no="idos_usage_session",oo="idos_usage_closed_session",ao="idos_usage_new_session",lo="idos_usage_last_activity",Yt=class{constructor(e){this.ctx=e;}ctx;pendingSeconds=0;currentSessionSeconds=0;pendingClosedSessionSeconds=0;isNewSessionPending=false;lastTickAt=0;suspendedAt=null;countingPaused=false;timer=null;started=false;flushing=false;start(){this.started||typeof window>"u"||(this.started=true,this.restore(),this.lastTickAt=Date.now(),this.countingPaused=typeof document<"u"&&document.visibilityState==="hidden",this.timer=setInterval(()=>this.tick(),200*1e3),window.addEventListener("visibilitychange",this.onVisibilityChange),window.addEventListener("pagehide",this.onPageHide));}async stop(){this.started&&(this.started=false,this.timer&&(clearInterval(this.timer),this.timer=null),typeof window<"u"&&(window.removeEventListener("visibilitychange",this.onVisibilityChange),window.removeEventListener("pagehide",this.onPageHide)),this.accumulate(),this.closeCurrentSession(false),await this.flush());}onVisibilityChange=()=>{if(!(typeof document>"u")){if(document.visibilityState==="hidden"){this.accumulate(),this.countingPaused=true,this.suspendedAt=Date.now(),this.flush();return}this.countingPaused=false,this.suspendedAt!==null&&((Date.now()-this.suspendedAt)/1e3>=1800&&this.closeCurrentSession(true),this.suspendedAt=null),this.lastTickAt=Date.now();}};onPageHide=()=>{this.accumulate(),this.persist(),this.flush();};tick(){this.accumulate(),this.flush();}accumulate(){let e=Date.now(),t=Math.floor((e-this.lastTickAt)/1e3);this.lastTickAt=e,!(t<=0)&&(this.countingPaused||(this.pendingSeconds+=t,this.currentSessionSeconds+=t,this.persist()));}closeCurrentSession(e){let t=Math.floor(this.currentSessionSeconds);t>0&&(this.pendingClosedSessionSeconds=Math.max(this.pendingClosedSessionSeconds,t)),this.currentSessionSeconds=0,e&&(this.isNewSessionPending=true),this.persist();}async flush(){if(this.flushing||this.pendingSeconds<=0&&this.pendingClosedSessionSeconds<=0&&!this.isNewSessionPending)return;let e=this.pendingSeconds,t=this.pendingClosedSessionSeconds,i=this.isNewSessionPending;this.flushing=true,this.pendingSeconds=0,this.pendingClosedSessionSeconds=0,this.isNewSessionPending=false,this.persist();try{(await this.ctx.userService.addUsageTime(e,i,t)).ok||(this.pendingSeconds+=e,this.pendingClosedSessionSeconds=Math.max(this.pendingClosedSessionSeconds,t),this.isNewSessionPending||=i,this.persist());}catch{this.pendingSeconds+=e,this.pendingClosedSessionSeconds=Math.max(this.pendingClosedSessionSeconds,t),this.isNewSessionPending||=i,this.persist();}finally{this.flushing=false;}}restore(){this.pendingSeconds=this.readNumber(so),this.currentSessionSeconds=this.readNumber(no),this.pendingClosedSessionSeconds=this.readNumber(oo),this.isNewSessionPending=this.readNumber(ao)!==0;let e=this.readNumber(lo);this.currentSessionSeconds>0&&e>0&&(Date.now()-e)/1e3>=1800&&(this.pendingClosedSessionSeconds=Math.max(this.pendingClosedSessionSeconds,Math.floor(this.currentSessionSeconds)),this.currentSessionSeconds=0);}persist(){this.writeNumber(so,this.pendingSeconds),this.writeNumber(no,this.currentSessionSeconds),this.writeNumber(oo,this.pendingClosedSessionSeconds),this.writeNumber(ao,this.isNewSessionPending?1:0),this.writeNumber(lo,Date.now());}readNumber(e){let t=this.ctx.platform.storage.getString(e),i=t?Number(t):0;return Number.isFinite(i)&&i>0?i:0}writeNumber(e,t){try{this.ctx.platform.storage.setString(e,String(Math.floor(t)));}catch{}}};var He={Virtual:"Virtual",Crypto:"Crypto"},qt=zod.z.enum(["Virtual","Crypto"]).catch("Virtual"),li={Item:"Item",VirtualCurrency:"VirtualCurrency",CryptoCurrency:"CryptoCurrency",RewardedVideoCredit:"RewardedVideoCredit",Purchase:"Purchase"},ui=zod.z.enum(["Item","VirtualCurrency","CryptoCurrency","RewardedVideoCredit","Purchase"]).catch("Item"),it={Unknown:"Unknown",Web:"Web",Android:"Android",Ios:"Ios"},ci=zod.z.enum(["Unknown","Web","Android","Ios"]).catch("Unknown"),Qc={GooglePlay:"GooglePlay",AppleAppStore:"AppleAppStore"},pi=zod.z.enum(["GooglePlay","AppleAppStore"]).catch("GooglePlay"),Kc={TimedEvent:"TimedEvent",Quest:"Quest",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season"},di=zod.z.enum(["TimedEvent","Quest","Leaderboard","CoopEvent","Season"]).catch("TimedEvent"),Hc={Cyclic:"Cyclic",Scheduled:"Scheduled",Chained:"Chained"},Xt=zod.z.enum(["Cyclic","Scheduled","Chained"]).catch("Cyclic"),Ce={None:"None",Device:"Device",Email:"Email",iDosGames:"iDosGames",Facebook:"Facebook",Google:"Google",GooglePlay:"GooglePlay",Telegram:"Telegram",Wallet:"Wallet"};function co(){let o=globalThis,e=o.Capacitor?.getPlatform?.();if(e)return uo(e);let t=o.cordova?.platformId;return t?uo(t):o.navigator?.userAgent??""?it.Web:it.Unknown}function uo(o){let e=o.toLowerCase();return e==="android"?it.Android:e==="ios"?it.Ios:e==="web"?it.Web:it.Unknown}function mt(o){return {ok:true,data:o}}function n(o,e){return {ok:false,reason:o,error:e}}function $c(o){return o.ok}function Zc(o){return !o.ok}var B=zod.z.union([zod.z.number(),zod.z.string()]).transform((o,e)=>{let t=typeof o=="string"?Number(o):o;return Number.isFinite(t)?Math.trunc(t):(e.addIssue({code:zod.z.ZodIssueCode.custom,message:`Invalid integer amount: ${String(o)}`}),zod.z.NEVER)}),j=zod.z.union([zod.z.number(),zod.z.string()]).transform((o,e)=>{let t=typeof o=="number"?String(o):o.trim();return t===""||Number.isNaN(Number(t))?(e.addIssue({code:zod.z.ZodIssueCode.custom,message:`Invalid decimal: ${String(o)}`}),zod.z.NEVER):t}),u=zod.z.string();var ws=zod.z.object({Type:ui.nullish(),CurrencyID:zod.z.string().nullish(),Amount:B.nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),ProductID:zod.z.string().nullish()}),Jc=zod.z.object({Type:di.nullish(),EntityID:zod.z.string()}),Yc=zod.z.object({Address:Jc.nullish(),Amount:B.nullish(),Source:zod.z.string().nullish()}),Re=zod.z.object({Entries:zod.z.array(ws).nullish(),EventTokens:zod.z.array(Yc).nullish()}),po=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Resources:Re.nullish()}),G=zod.z.object({Standard:Re.nullish(),PremiumBonuses:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(po).nullish()}),lt=zod.z.object({Standard:Re.nullish(),PremiumDiscounts:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(po).nullish()}),v=zod.z.object({Grant:G.nullish(),Consume:lt.nullish()}),Dt=zod.z.object({FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),FromResult:v.nullish(),ToResult:v.nullish()});zod.z.object({FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),Transferred:Re.nullish()});var Xc=zod.z.object({ExperimentID:zod.z.string().nullish(),Variants:zod.z.array(zod.z.string()).nullish()}).passthrough(),ep={Completed:"Completed",Started:"Started",StepReached:"StepReached"},tp=zod.z.object({FlowIDs:zod.z.array(zod.z.string()).nullish(),Mode:zod.z.enum(["Completed","Started","StepReached"]).catch("Completed").nullish(),StepID:zod.z.string().nullish(),Negate:zod.z.boolean().nullish(),SkippedCountsAsCompleted:zod.z.boolean().nullish()}).passthrough(),_=zod.z.object({Segments:zod.z.array(zod.z.string()).nullish(),MinPremiumTier:zod.z.number().nullish(),RequiredPremiumIDs:zod.z.array(zod.z.string()).nullish(),MinLevel:zod.z.number().nullish(),MaxLevel:zod.z.number().nullish(),Countries:zod.z.array(zod.z.string()).nullish(),RegisteredWithinDays:zod.z.number().nullish(),ActiveWithinDays:zod.z.number().nullish(),Experiment:Xc.nullish(),Tutorial:tp.nullish(),Platforms:zod.z.array(ci).nullish()}).passthrough();var ie=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 ip=zod.z.object({OffsetSecondsFromParentStart:zod.z.number().nullish(),DurationSeconds:zod.z.number().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),rp=zod.z.object({StartUtc:zod.z.string().nullish(),EndUtc:zod.z.string().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),sp=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 np=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 Ne=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:ie.nullish()}).passthrough(),re=zod.z.object({Mode:zod.z.string().nullish(),IsActive:zod.z.boolean().nullish(),Scheduled:rp.nullish(),Chain:sp.nullish(),Cyclic:np.nullish(),ActivationTriggers:zod.z.array(Ne).nullish(),Relative:ip.nullish()}).passthrough();var op={Flat:"Flat",PerStep:"PerStep",PerStepRate:"PerStepRate",Geometric:"Geometric",Table:"Table",TableAbsolute:"TableAbsolute"},ap=zod.z.enum(["Flat","PerStep","PerStepRate","Geometric","Table","TableAbsolute"]).catch("Flat"),lp={Step:"Step",Linear:"Linear",Geometric:"Geometric"},up=zod.z.enum(["Step","Linear","Geometric"]).catch("Step"),cp=zod.z.object({AtStep:zod.z.number().nullish(),Value:zod.z.number().nullish()}).passthrough(),Pe=zod.z.object({Base:zod.z.number().nullish(),Shape:ap.nullish(),PerStep:zod.z.number().nullish(),PerStepRate:zod.z.number().nullish(),GrowthRate:zod.z.number().nullish(),Points:zod.z.array(cp).nullish(),Interpolation:up.nullish(),TailGrowthRate:zod.z.number().nullish(),MinResult:zod.z.number().nullish(),MaxResult:zod.z.number().nullish()}).passthrough();var pp=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Rewards:G.nullish()}).passthrough(),dp=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),Ms=zod.z.object({Bundles:zod.z.array(pp).nullish(),Multipliers:zod.z.array(dp).nullish()}).passthrough();var hp=zod.z.enum(["BoardStageLevel","BoardRank","BoardCyclesCompleted","CharacterLevel","SeasonTier","EventTokenTotalEarned","VirtualCurrencyBalance","PlayerLevel"]).catch("BoardStageLevel"),hi=zod.z.object({Source:hp.nullish(),SourceKey:zod.z.string().nullish(),Curve:Pe.nullish(),Anchor:zod.z.number().nullish(),IncludeRewards:Re.nullish(),ExcludeRewards:Re.nullish()}).passthrough(),Te=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:Ms.nullish(),SortOrder:zod.z.number().nullish(),IsFeatured:zod.z.boolean().nullish()}).passthrough(),Et=zod.z.object({Milestones:zod.z.record(zod.z.string(),Te).nullish()}).passthrough();var K=zod.z.object({PresetID:zod.z.string().nullish(),Remove:zod.z.array(zod.z.string()).nullish()}).passthrough();var mp=zod.z.object({TargetCurrencyID:zod.z.string().nullish(),Rate:zod.z.number().nullish(),MaxConvertAmount:zod.z.number().nullish()}).passthrough(),zt=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:mp.nullish()}).passthrough();var ae=o=>zod.z.object({Id:zod.z.string(),Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:o.nullish()}),rt=o=>zod.z.object({ServerTimeUtc:u,Items:zod.z.array(ae(o)),Resources:v.nullish()});var fp={Active:"Active",Completed:"Completed",Claimed:"Claimed",Expired:"Expired"},ho=zod.z.enum(["Active","Completed","Claimed","Expired"]).catch("Active"),gp=zod.z.object({}).passthrough().transform(o=>o),yp=zod.z.object({CycleID:zod.z.string(),InstanceKey:zod.z.string().nullish(),PhaseID:zod.z.string().nullish(),CycleIndex:zod.z.number().nullish(),CycleStartUtc:u.nullish(),CycleEndUtc:u.nullish(),PointsTotalEarned:B.nullish(),PointsCurrent:B.nullish(),ClaimedPointMilestoneIDs:zod.z.array(zod.z.string()).nullish()}),As=zod.z.object({QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),ObjectiveID:zod.z.string().nullish(),NewValue:B.nullish(),ObjectiveCompleted:zod.z.boolean().nullish(),Status:ho}),mo=zod.z.object({State:gp.nullish(),PointsTracks:zod.z.record(zod.z.string(),yp).nullish()}),Os=zod.z.object({ServerTimeUtc:u,QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),NewStatus:ho.nullish(),Resources:v.nullish()}),Us=zod.z.object({ServerTimeUtc:u,CycleID:zod.z.string(),MilestoneID:zod.z.string(),PointsTotalEarned:B.nullish(),Resources:v.nullish()}),fo=zod.z.object({ServerTimeUtc:u,CycleID:zod.z.string(),GroupCompletionID:zod.z.string(),GroupID:zod.z.string().nullish(),CompletedGroupQuests:zod.z.number().nullish(),RequiredGroupQuests:zod.z.number().nullish(),Resources:v.nullish()}),go=zod.z.object({MetricID:zod.z.string(),Updates:zod.z.array(As).nullish()}),yo=zod.z.array(ae(Os)),Ro=zod.z.array(ae(Us)),Rp={ClientApi:"ClientApi",ServerApi:"ServerApi",SystemEvent:"SystemEvent"},Cp=zod.z.enum(["ClientApi","ServerApi","SystemEvent"]).catch("ClientApi"),Sp={BlockProgressAndClaim:"BlockProgressAndClaim",BlockClaimOnly:"BlockClaimOnly"},xp=zod.z.enum(["BlockProgressAndClaim","BlockClaimOnly"]).catch("BlockProgressAndClaim"),Co=zod.z.object({ObjectiveID:zod.z.string().nullish(),Source:Cp.nullish(),MaxProgressPerCall:zod.z.number().nullish(),MetricID:zod.z.string().nullish(),Triggers:zod.z.array(Ne).nullish(),TargetValue:zod.z.number().nullish(),AggregationMethod:zod.z.string().nullish()}).passthrough(),Bs=zod.z.object({Milestones:K.nullish(),Linking:K.nullish(),Availability:K.nullish(),Reward:K.nullish(),Objectives:K.nullish()}).passthrough(),bp=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(),So=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:xp.nullish()}).passthrough(),xo=zod.z.object({Schedule:re.nullish(),AccrueProgressWhenLocked:zod.z.boolean().nullish(),Gate:_.nullish(),Limits:ie.nullish()}).passthrough(),bo=zod.z.object({Grant:G.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),Dp=zod.z.object({QuestID:zod.z.string().nullish(),Identity:bp.nullish(),Linking:So.nullish(),Availability:xo.nullish(),Objectives:zod.z.record(zod.z.string(),Co).nullish(),Reward:bo.nullish(),Presets:Bs.nullish()}).passthrough(),zp=zod.z.object({CompletionID:zod.z.string().nullish(),GroupID:zod.z.string().nullish(),RequiredCompletedQuests:zod.z.number().nullish(),Gate:_.nullish(),Reward:G.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),Pp=zod.z.object({PhaseID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Gate:_.nullish(),Milestones:zod.z.record(zod.z.string(),Te).nullish(),Presets:Bs.nullish(),PointsToken:zt.nullish()}).passthrough(),vp=zod.z.object({Milestones:zod.z.record(zod.z.string(),Et).nullish(),Linking:zod.z.record(zod.z.string(),So).nullish(),Availability:zod.z.record(zod.z.string(),xo).nullish(),Reward:zod.z.record(zod.z.string(),bo).nullish(),Objectives:zod.z.record(zod.z.string(),zod.z.record(zod.z.string(),Co)).nullish()}).passthrough(),Tp=zod.z.object({CycleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:re.nullish(),Milestones:zod.z.record(zod.z.string(),Te).nullish(),Gate:_.nullish(),PointsToken:zt.nullish(),GroupCompletions:zod.z.record(zod.z.string(),zp).nullish(),Phases:zod.z.record(zod.z.string(),Pp).nullish(),Presets:Bs.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),fi=zod.z.object({Cycles:zod.z.record(zod.z.string(),Tp).nullish(),Quests:zod.z.record(zod.z.string(),Dp).nullish(),Presets:vp.nullish()}).passthrough(),Ze={GetQuestDefinitions:"GetQuestDefinitions",GetUserQuestState:"GetUserQuestState",RefreshQuestCycles:"RefreshQuestCycles",ClaimQuestReward:"ClaimQuestReward",ClaimMilestoneReward:"ClaimMilestoneReward",AddQuestProgress:"AddQuestProgress",ClaimQuestRewardsBatch:"ClaimQuestRewardsBatch",ClaimMilestoneRewardsBatch:"ClaimMilestoneRewardsBatch",ClaimGroupCompletionReward:"ClaimGroupCompletionReward"};var Ip={ClientAck:"ClientAck",SystemEvent:"SystemEvent",Auto:"Auto",Composite:"Composite"},kp=zod.z.enum(["ClientAck","SystemEvent","Auto","Composite"]).catch("ClientAck"),wp={Never:"Never",OnRequest:"OnRequest",Always:"Always"},Mp=zod.z.enum(["Never","OnRequest","Always"]).catch("Never"),Ap={NotStarted:"NotStarted",InProgress:"InProgress",Completed:"Completed",Skipped:"Skipped",Expired:"Expired"},Op=zod.z.enum(["NotStarted","InProgress","Completed","Skipped","Expired"]).catch("NotStarted"),Up={GameLoop:"GameLoop"},Bp={Raid:"Raid",Attack:"Attack"},Lp=zod.z.object({Title:zod.z.string().nullish(),TitleKey:zod.z.string().nullish(),Body:zod.z.string().nullish(),BodyKey:zod.z.string().nullish(),AnchorID:zod.z.string().nullish(),HighlightTarget:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),UiHint:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),qp=zod.z.object({Mode:kp.nullish(),Triggers:zod.z.array(Ne).nullish(),TargetValue:zod.z.number().nullish(),RequireAllTriggers:zod.z.boolean().nullish()}).passthrough(),Ep=zod.z.object({Grant:G.nullish(),UnlockFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),Gp=zod.z.object({TileType:zod.z.string().nullish(),TileIndex:zod.z.number().nullish(),ChanceOutcomeID:zod.z.string().nullish(),RandomActionType:zod.z.enum(["Raid","Attack"]).catch("Raid").nullish()}).passthrough(),Np=zod.z.object({Module:zod.z.enum(["GameLoop"]).catch("GameLoop").nullish(),Board:Gp.nullish(),MaxUses:zod.z.number().nullish()}).passthrough(),jp=zod.z.object({Skippable:zod.z.boolean().nullish(),TimeoutSeconds:zod.z.number().nullish()}).passthrough(),Ls=zod.z.object({StepID:zod.z.string().nullish(),Order:zod.z.number().nullish(),Identity:Lp.nullish(),Completion:qp.nullish(),Effects:Ep.nullish(),Script:Np.nullish(),Policy:jp.nullish()}).passthrough(),Fp=zod.z.object({DisplayName:zod.z.string().nullish(),DisplayNameKey:zod.z.string().nullish(),Description:zod.z.string().nullish(),DescriptionKey:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Do=zod.z.object({Schedule:re.nullish(),Gate:_.nullish(),RequiredFlowIDs:zod.z.array(zod.z.string()).nullish(),AutoStart:zod.z.boolean().nullish(),StartTrigger:Ne.nullish()}).passthrough(),zo=zod.z.object({Skippable:zod.z.boolean().nullish(),SkippableFromOrder:zod.z.number().nullish(),RestartPolicy:Mp.nullish(),ExpireAfterSeconds:zod.z.number().nullish(),IsBlocking:zod.z.boolean().nullish(),UnlockFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),Po=zod.z.object({Grant:G.nullish(),AutoClaim:zod.z.boolean().nullish()}).passthrough(),Vp=zod.z.object({Availability:K.nullish(),Policy:K.nullish(),Reward:K.nullish(),Steps:K.nullish()}).passthrough(),_p=zod.z.object({FlowID:zod.z.string().nullish(),Identity:Fp.nullish(),Availability:Do.nullish(),Policy:zo.nullish(),Steps:zod.z.record(zod.z.string(),Ls).nullish(),Reward:Po.nullish(),Presets:Vp.nullish()}).passthrough(),Wp=zod.z.object({BlockingFlowIDs:zod.z.array(zod.z.string()).nullish(),BlockedModules:zod.z.array(zod.z.string()).nullish(),BlockedActions:zod.z.record(zod.z.string(),zod.z.array(zod.z.string())).nullish(),BlockBeforeStart:zod.z.boolean().nullish(),SkipLiftsBlock:zod.z.boolean().nullish()}).passthrough(),Qp=zod.z.object({IsEnabled:zod.z.boolean().nullish(),MaxActiveFlows:zod.z.number().nullish(),Blocking:Wp.nullish()}).passthrough(),Kp=zod.z.object({Availability:zod.z.record(zod.z.string(),Do).nullish(),Policy:zod.z.record(zod.z.string(),zo).nullish(),Reward:zod.z.record(zod.z.string(),Po).nullish(),Steps:zod.z.record(zod.z.string(),zod.z.record(zod.z.string(),Ls)).nullish()}).passthrough(),vo=zod.z.object({Flows:zod.z.record(zod.z.string(),_p).nullish(),Settings:Qp.nullish(),Presets:Kp.nullish()}).passthrough(),Hp=zod.z.object({}).passthrough().transform(o=>o),To=zod.z.object({FlowID:zod.z.string(),Status:Op,CurrentStepID:zod.z.string().nullish(),CurrentStep:Ls.nullish(),TotalSteps:zod.z.number(),CompletedSteps:zod.z.number(),CanSkip:zod.z.boolean(),RewardClaimed:zod.z.boolean(),RewardPending:zod.z.boolean(),VariantID:zod.z.string().nullish()}).passthrough(),Io=zod.z.object({State:Hp.nullish(),Flows:zod.z.array(To).nullish(),UnlockedFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),gt=zod.z.object({Flow:To.nullish()}).passthrough(),ko=zod.z.object({FlowID:zod.z.string().nullish(),Granted:v.nullish()}).passthrough(),wo=zod.z.array(ae(gt)),Mo=zod.z.object({FlowID:zod.z.string(),StepID:zod.z.string(),Progress:zod.z.number(),Target:zod.z.number(),Completed:zod.z.boolean()}).passthrough(),je={GetTutorialDefinitions:"GetTutorialDefinitions",GetUserTutorialState:"GetUserTutorialState",StartFlow:"StartFlow",ReportStepShown:"ReportStepShown",CompleteStep:"CompleteStep",CompleteStepsBatch:"CompleteStepsBatch",SkipStep:"SkipStep",SkipFlow:"SkipFlow",ClaimFlowReward:"ClaimFlowReward",ResetFlow:"ResetFlow"};var gi=class{constructor(e=600,t=()=>Date.now()){this.windowMs=e;this.now=t;}windowMs;now;last=new Map;tryAcquire(e){if(this.windowMs<=0)return true;let t=this.now(),i=this.last.get(e);return i!==void 0&&t-i<this.windowMs?false:(this.last.set(e,t),true)}reset(){this.last.clear();}};var yi=class{set=new Set;add(e){return this.set.has(e)?false:(this.set.add(e),true)}remove(e){this.set.delete(e);}};function Ao(o){return o===429||o>=500&&o<=599}function qs(o,e=Math.random){let t=Math.min(500*Math.pow(2,o-1),4e3),i=t*.2*(e()*2-1);return Math.max(50,t+i)}function Es(o){return new Promise(e=>setTimeout(e,o))}var $p=12e3,Zp=zod.z.object({Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:zod.z.unknown().optional(),QuestProgress:zod.z.array(As).nullish(),TutorialProgress:zod.z.array(Mo).nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish(),StateEpoch:zod.z.string().nullish()}).passthrough(),Ri=class{baseUrl;emitter;fetchImpl;debugLogging;throttler;clientPlatform;inflight=new yi;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 gi(e.throttleMs),this.clientPlatform=e.clientPlatform??it.Unknown;}setSessionRefreshHandler(e){this.sessionRefreshHandler=e;}async post(e,t,i,r={}){let s=r.throttleKey??e;if(!this.throttler.tryAcquire(s))return n("throttled","Throttled");if(!this.inflight.add(s))return n("throttled","Duplicate request skipped");this.raiseBusy();try{let a=`${this.baseUrl}/${e}`,p=JSON.stringify(t),x=r.ticket??null,k=r.silent??!1,N=r.timeoutMs??$p,ge=r.autoRetry??!0,xe=!1,Ae=0;for(;;){let et;try{et=await this.doFetch(a,p,x,N);}catch{if(ge&&Ae<3){Ae++,await Es(qs(Ae));continue}return this.connectionFailure("Internet Connection Error",k)}let tt=et.status;if(tt>=200&&tt<300)return await this.parseSuccess(et,i,k,e);if(tt===401){if(!xe&&this.sessionRefreshHandler){xe=!0;let at=null;try{at=await this.sessionRefreshHandler();}catch{at=null;}if(at){x=at;continue}}return this.emitter.emit("auth:unauthorized",void 0),n("unauthorized","Unauthorized")}if(Ao(tt)){if(ge&&Ae<3){Ae++,await Es(qs(Ae));continue}return this.connectionFailure(`Server temporarily unavailable (HTTP ${tt})`,k)}return await this.handleWebError(et,tt,k)}}finally{this.inflight.remove(s),this.lowerBusy();}}async doFetch(e,t,i,r){let s=new AbortController,a=setTimeout(()=>{s.abort();},r);try{let p={"Content-Type":"application/json","X-IG-Platform":this.clientPlatform};return i&&(p.Authorization=`Bearer ${i}`),await this.fetchImpl(e,{method:"POST",body:t,headers:p,signal:s.signal})}finally{clearTimeout(a);}}async parseSuccess(e,t,i,r){let s;try{s=await e.text();}catch{return this.globalError("Failed to read response body",i)}let a;try{a=JSON.parse(s);}catch{return this.globalError("JSON Parse Error",i)}let p=Zp.safeParse(a);if(!p.success)return this.globalError("Malformed response envelope",i);if(!p.data.Success){let xe=p.data.Error??"Server returned Success=false";return i||this.emitter.emit("error:global",xe),n("server",xe)}let x=p.data.QuestProgress;x&&x.length>0&&this.emitter.emit("quest:systemProgress",x);let k=p.data.TutorialProgress;k&&k.length>0&&this.emitter.emit("tutorial:systemProgress",k);let N=p.data.StateVersions;N&&Object.keys(N).length>0&&this.emitter.emit("user:stateVersions",{epoch:p.data.StateEpoch??null,versions:N});let ge=t.safeParse(p.data.Data);if(!ge.success){let xe=`Validation error (${r}): ${ge.error.message}`;return this.debugLogging&&console.warn("[HttpTransport]",xe),i||this.emitter.emit("error:global",xe),n("validation",xe)}return mt(ge.data)}async handleWebError(e,t,i){let r=`HTTP ${t}`;try{let s=await e.text();if(s)try{let p=JSON.parse(s).Error;r=typeof p=="string"&&p.length>0?`HTTP ${t}: ${p}`:`HTTP ${t}: ${s}`;}catch{r=`HTTP ${t}: ${s}`;}}catch{}return i||this.emitter.emit("error:global",r),n("server",r)}connectionFailure(e,t){return t||this.emitter.emit("error:connection",e),n("connection",e)}globalError(e,t){return t||this.emitter.emit("error:global",e),n("server",e)}raiseBusy(){this.inFlightRequests++,this.inFlightRequests===1&&this.emitter.emit("transport:busy",true);}lowerBusy(){this.inFlightRequests>0&&(this.inFlightRequests--,this.inFlightRequests===0&&this.emitter.emit("transport:busy",false));}};function Nt(o){return (typeof o=="string"?o:o.toISOString()).slice(0,10)}function ei(o){return `${Nt(o)}T00:00:00.000Z`}function Uo(o){let e=new Date(o);return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+1)).toISOString()}function Bo(o,e){return new Date(o.getTime()+e*6e4).toISOString()}function Lo(o,e,t,i){let r={vcChanged:false,ccChanged:false,itemsChanged:false,tokensChanged:false};if(!e)return r;o.InventoryV2??={};let s=o.InventoryV2,a=i.toISOString(),p=new Map,x=new Map,k=new Map,N=new Map,ge=new Map,xe=new Map,Ae=new Map,et=new Map,tt=e.Grant?.PremiumTiers??[],at=tt.length;for(let ue=0;;ue++){let ye,Y;if(ue===0)ye=e.Grant?.Standard?.Entries,Y=false;else if(ue-1<at)ye=tt[ue-1]?.Resources?.Entries,Y=false;else if(ue===1+at)ye=e.Consume?.Standard?.Entries,Y=true;else break;if(ye)for(let $ of ye){if($.Type==null)continue;let Z=Math.max(0,$.Amount??0);if(!(Z<=0))switch($.Type){case "VirtualCurrency":{if(!$.CurrencyID)continue;let J=Y?x:p;J.set($.CurrencyID,(J.get($.CurrencyID)??0)+Z);break}case "CryptoCurrency":{if(!$.CurrencyID)continue;let J=Y?N:k;J.set($.CurrencyID,(J.get($.CurrencyID)??new Ci__default.default(0)).plus(Z));break}case "Item":{if(!$.ItemID)continue;let J=Yp(t,$.CatalogID,$.ItemID),te=(J?J.IsStackable??true:true)?Y?xe:ge:Y?et:Ae;te.set($.ItemID,(te.get($.ItemID)??0)+Z);break}case "Purchase":case "RewardedVideoCredit":continue}}}if(r.vcChanged=p.size>0||x.size>0,r.vcChanged){s.VirtualCurrencies??={};for(let ue of new Set([...p.keys(),...x.keys()])){let ye=p.get(ue)??0,Y=x.get(ue)??0,$=ye-Y,Z=s.VirtualCurrencies[ue];Z?(Z.Amount+=$,Z.UpdatedAt=a,Z.Daily&&Nt(Z.Daily.PeriodStartUtc)===Nt(i)?(Z.Daily.Earned+=ye,Z.Daily.Spent+=Y):Z.Daily={PeriodStartUtc:ei(i),Earned:ye,Spent:Y}):s.VirtualCurrencies[ue]={Amount:$,CreatedAt:a,UpdatedAt:a,Daily:{PeriodStartUtc:ei(i),Earned:ye,Spent:Y}};}}if(r.ccChanged=k.size>0||N.size>0,r.ccChanged){s.CryptoCurrencies??={};for(let ue of new Set([...k.keys(),...N.keys()])){let ye=k.get(ue)??new Ci__default.default(0),Y=N.get(ue)??new Ci__default.default(0),$=ye.minus(Y),Z=s.CryptoCurrencies[ue];Z?(Z.Amount=new Ci__default.default(Z.Amount).plus($).toString(),Z.UpdatedAt=a):s.CryptoCurrencies[ue]={Amount:$.toString(),Frozen:"0",CreatedAt:a,UpdatedAt:a};}}if(r.itemsChanged=ge.size>0||xe.size>0||Ae.size>0||et.size>0,r.itemsChanged){s.Items??={},s.UnstackableItems??={};let ue=s.UnstackableItems,ye=new Set([...ge.keys(),...xe.keys(),...Ae.keys(),...et.keys()]);for(let Y of ye){let $=(ge.get(Y)??0)-(xe.get(Y)??0),Z=(Ae.get(Y)??0)-(et.get(Y)??0),J=$+Z,Ge=s.Items[Y];Ge?($!==0&&(Ge.StackableAmount+=$),Z!==0&&(Ge.UnstackableAmount+=Z),J!==0&&(Ge.TotalAmount+=J)):s.Items[Y]={StackableAmount:Math.max(0,$),UnstackableAmount:Math.max(0,Z),TotalAmount:Math.max(0,J)};}for(let[Y,$]of et){if($<=0)continue;let Z=Object.values(ue).filter(J=>J.ItemID===Y&&J.EquippedSlot==null&&(J.ExpiresAt==null||new Date(J.ExpiresAt)>i)).sort(Jp).slice(0,$).map(J=>J.ItemInstanceID);for(let J of Z)delete ue[J];}for(let[Y,$]of Ae){let Z=Xp(t,Y);for(let J=0;J<$;J++){let Ge=M();ue[Ge]={ItemInstanceID:Ge,ItemID:Y,CatalogID:Z,RemainingUses:1,AcquiredAt:a};}}}o.EventToken??={};let Lc=o.EventToken;for(let ue=0;;ue++){let ye,Y;if(ue===0)ye=e.Grant?.Standard?.EventTokens,Y=false;else if(ue-1<at)ye=tt[ue-1]?.Resources?.EventTokens,Y=false;else if(ue===1+at)ye=e.Consume?.Standard?.EventTokens,Y=true;else break;if(!(!ye||ye.length===0))for(let $ of ye){let Z=$.Address;if(!Z||Z.Type==null)continue;let J=$.Amount??0;if(J<=0)continue;let Ge=ed(Lc,Z.Type);if(!Ge)continue;let te=Ge[Z.EntityID];te||(te={},Ge[Z.EntityID]=te),te.Balance??={Current:0,TotalEarned:0,TotalSpent:0},te.Daily??={Date:ei(i),TotalEarned:0},te.Meta??={};let Zt=$.Source&&$.Source.length>0?$.Source:"CustomAction";Y?(te.Balance.Current-=J,te.Balance.TotalSpent+=J):(te.Balance.Current+=J,te.Balance.TotalEarned+=J,Nt(te.Daily.Date)!==Nt(i)&&(te.Daily={Date:ei(i),TotalEarned:0}),te.Daily.TotalEarned+=J,te.Daily.EarnedBySource??={},te.Daily.EarnedBySource[Zt]=(te.Daily.EarnedBySource[Zt]??0)+J,te.Daily.TriggersBySource??={},te.Daily.TriggersBySource[Zt]=(te.Daily.TriggersBySource[Zt]??0)+1,te.Daily.LastTriggerBySource??={},te.Daily.LastTriggerBySource[Zt]=a,te.Meta.JoinedAtUtc||(te.Meta.JoinedAtUtc=a),te.Meta.LastEarnedAtUtc=a),r.tokensChanged=true;}}return r}function Jp(o,e){return o.AcquiredAt!==e.AcquiredAt?o.AcquiredAt<e.AcquiredAt?-1:1:o.ItemInstanceID===e.ItemInstanceID?0:o.ItemInstanceID<e.ItemInstanceID?-1:1}function Yp(o,e,t){let i=o?.Catalogs;if(i){if(e){let r=i[e]?.Items?.[t];if(r)return r}for(let r of Object.values(i)){let s=r.Items?.[t];if(s)return s}}}function Xp(o,e){let t=o?.Catalogs;if(t){for(let[i,r]of Object.entries(t))if(r.Items&&e in r.Items)return i}}function ed(o,e){switch(e){case "TimedEvent":return o.TimedEvent??={};case "Quest":return o.Quest??={};case "Leaderboard":return o.Leaderboard??={};case "CoopEvent":return o.CoopEvent??={};case "Season":return o.Season??={};default:return null}}function Gs(o,e){return o===e||o.startsWith(`${e}:`)}var Si=class{constructor(e){this.emitter=e;}emitter;currentState={};activeEventsCache=null;get state(){return this.currentState}getCachedActiveEvents(){return this.activeEventsCache}clear(){this.currentState=null,this.emitter.emit("user:anyUpdated",void 0);}applyUserState(e){this.currentState=e,this.emitter.emit("user:stateUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyUserStateContainers(e,t){if(t.length!==0){this.currentState??={};for(let i of t)this.currentState[i]=e[i];this.emitter.emit("user:stateUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}}applyInventory(e){this.currentState??={},this.currentState.InventoryV2=e,this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyVirtualCurrency(e){this.currentState??={},this.currentState.InventoryV2??={},this.currentState.InventoryV2.VirtualCurrencies=e,this.emitter.emit("user:virtualCurrencyUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyResourceOperation(e,t,i=new Date){if(!this.currentState)return;let r=Lo(this.currentState,e,t,i);r.vcChanged&&this.emitter.emit("user:virtualCurrencyUpdated",void 0),(r.vcChanged||r.ccChanged||r.itemsChanged)&&this.emitter.emit("user:inventoryUpdated",void 0),r.tokensChanged&&this.emitter.emit("user:eventTokenUpdated",void 0),(r.vcChanged||r.ccChanged||r.itemsChanged||r.tokensChanged)&&this.emitter.emit("user:anyUpdated",void 0);}patchCryptoCurrencyDelta(e,t,i){if(!e||!this.currentState)return;this.currentState.InventoryV2??={},this.currentState.InventoryV2.CryptoCurrencies??={};let r=this.currentState.InventoryV2.CryptoCurrencies,s=t instanceof Ci__default.default?t:new Ci__default.default(t),a=i??new Date().toISOString(),p=r[e];p?(p.Amount=new Ci__default.default(p.Amount).plus(s).toString(),p.UpdatedAt=a):r[e]={Amount:s.toString(),Frozen:"0",CreatedAt:a,UpdatedAt:a},this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyStore(e){this.currentState??={},this.currentState.Store=e??{},this.emitter.emit("user:storeUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchStorePurchase(e,t,i){if(!e||t<1||!this.currentState)return;this.currentState.Store??={},this.currentState.Store.Purchases??={};let r=this.currentState.Store.Purchases,s=r[e];s||(s={OfferID:e,TotalPurchases:0,DailyPurchases:0,DailyResetUtc:"",LastPurchasedAt:""},r[e]=s),s.TotalPurchases+=t,s.LastPurchasedAt=i,i>=s.DailyResetUtc?(s.DailyPurchases=t,s.DailyResetUtc=Uo(i)):s.DailyPurchases+=t,this.emitter.emit("user:storeUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyLootboxPityTriggers(e,t,i){if(!e||i<=0)return;this.currentState??={};let r=this.currentState.Lootbox??={};if(r.Pity??={},t){let s=new Date().toISOString();for(let a of t)a.RuleID&&(r.Pity[`${e}:${a.RuleID}`]={OpensSinceLastTrigger:0,LastTriggeredAtUtc:s});}this.emitter.emit("user:lootboxUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyReward(e){this.currentState??={},this.currentState.Reward=e??{},this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchDailyCalendarState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.DailyCalendars??={},this.currentState.Reward.DailyCalendars[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchIdleAccrualState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.IdleAccruals??={},this.currentState.Reward.IdleAccruals[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchComebackState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.Comebacks??={},this.currentState.Reward.Comebacks[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchClaimRewardState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.Claims??={},this.currentState.Reward.Claims[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyQuest(e){this.currentState??={},this.currentState.Quest=e??{},this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchQuestStatus(e,t,i){if(!e)return;this.currentState??={},this.currentState.Quest??={};let r=this.currentState.Quest;if(t){r.Cycles??={};let s=r.Cycles[t];if(!s)return;s.Quests??={};let a=s.Quests[e]??={QuestID:e,Status:i};a.Status=i,i==="Claimed"&&(a.ClaimedAtUtc??=new Date().toISOString());}else {r.PermanentQuests??={};let s=r.PermanentQuests[e]??={QuestID:e,Status:i};s.Status=i,i==="Claimed"&&(s.ClaimedAtUtc??=new Date().toISOString());}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchMilestoneClaimed(e,t){if(!e||!t)return;let i=this.getQuestPointsProgress(e);i&&(i.Milestone??={},this.markMilestoneClaimed(i.Milestone,t),this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchQuestPointsTracks(e){if(!e)return;this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.Quest??={};let t=this.currentState.EventToken.Quest;for(let i of Object.values(e)){if(!i.CycleID)continue;let r=i.InstanceKey?`${i.CycleID}:${i.InstanceKey}`:i.CycleID,s=t[r]??={};s.Balance??={Current:0,TotalEarned:0,TotalSpent:0},s.Balance.Current=i.PointsCurrent??0,s.Balance.TotalEarned=i.PointsTotalEarned??0,s.Milestone??={};for(let a of i.ClaimedPointMilestoneIDs??[])this.markMilestoneClaimed(s.Milestone,a);}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchGroupCompletionClaimed(e,t){if(!e||!t)return;this.currentState??={},this.currentState.Quest??={},this.currentState.Quest.Cycles??={};let i=this.currentState.Quest.Cycles[e];i&&(i.ClaimedGroupCompletionIDs??=[],i.ClaimedGroupCompletionIDs.includes(t)||i.ClaimedGroupCompletionIDs.push(t),this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyTutorial(e){this.currentState??={},this.currentState.Tutorial=e??{},this.emitter.emit("user:tutorialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchTutorialFlow(e){if(!e?.FlowID)return;this.currentState??={},this.currentState.Tutorial??={};let t=this.currentState.Tutorial;t.Flows??={};let i=t.Flows[e.FlowID]??={FlowID:e.FlowID};i.Status=e.Status,i.CurrentStepID=e.CurrentStepID??null,i.RewardClaimed=e.RewardClaimed,e.VariantID!==void 0&&(i.VariantID=e.VariantID),this.emitter.emit("user:tutorialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchTutorialProgress(e){if(!e||e.length===0)return;this.currentState??={},this.currentState.Tutorial??={};let t=this.currentState.Tutorial;t.Flows??={};for(let i of e){if(!i.FlowID||!i.StepID)continue;let r=t.Flows[i.FlowID]??={FlowID:i.FlowID,Status:"InProgress"};r.Steps??={};let s=r.Steps[i.StepID]??={StepID:i.StepID};s.Progress=i.Progress,i.Completed&&(s.CompletedAtUtc??=new Date().toISOString(),r.CurrentStepID===i.StepID&&(r.CurrentStepID=null));}this.emitter.emit("user:tutorialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchQuestProgressUpdates(e){if(!e||e.length===0)return;this.currentState??={},this.currentState.Quest??={};let t=this.currentState.Quest;for(let i of e){if(!i.QuestID)continue;let r;if(!i.CycleID)t.PermanentQuests??={},r=t.PermanentQuests[i.QuestID]??={QuestID:i.QuestID,Status:i.Status};else {t.Cycles??={};let s=t.Cycles[i.CycleID];if(!s)continue;s.Quests??={},r=s.Quests[i.QuestID]??={QuestID:i.QuestID,Status:i.Status};}if(r.Status=i.Status,i.ObjectiveID){r.Objectives??={};let s=r.Objectives[i.ObjectiveID]??={ObjectiveID:i.ObjectiveID,CurrentValue:0,Completed:false};s.CurrentValue=i.NewValue??0,i.ObjectiveCompleted&&(s.Completed=true,s.CompletedAtUtc??=new Date().toISOString());}i.Status==="Completed"&&(r.CompletedAtUtc??=new Date().toISOString());}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}getQuestPointsProgress(e){if(!e)return null;let t=this.currentState?.EventToken?.Quest;if(!t)return null;for(let[i,r]of Object.entries(t))if(Gs(i,e)&&r)return r;return null}applyActiveEvents(e){this.activeEventsCache=e??{},this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyUserLteState(e){e&&(this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.TimedEvent=e.Tokens??{},this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchTimedEventMilestoneClaimed(e,t,i){if(!(!t||!i)){this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.TimedEvent??={};for(let[r,s]of Object.entries(this.currentState.EventToken.TimedEvent))!Gs(r,t)||!s||this.markMilestoneClaimed(s.Milestone??(s.Milestone={}),i);this.patchActiveEventMilestoneClaimed(e,t,i),this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}}patchActiveEventMilestoneClaimed(e,t,i){let r=this.activeEventsCache?.ActiveEvents;if(r)for(let s of r)s.Type!==e||s.TimedEventID!==t||(s.Progress??={},this.markMilestoneClaimed(s.Progress.Milestone??(s.Progress.Milestone={}),i));}markMilestoneClaimed(e,t){e.Claims??={};let i=e.Claims[t]??={};i.ClaimedAt??=new Date().toISOString(),i.Unlocked=false;}patchLeaderboardMyProgress(e,t){if(!e||!t)return;let i=this.ensureLeaderboardProgress(e);i.CurrentScore=t.CurrentScore??0,i.LastKnownRank=t.LastKnownRank??0,i.ScoreEarnedThisCycle=t.ScoreEarnedThisCycle??0,i.UnclaimedRewardCycleVersion=t.HasUnclaimedReward?Math.max(1,i.UnclaimedRewardCycleVersion??0):0,this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchLeaderboardScoreSubmitted(e,t,i,r){if(!e)return;let s=this.ensureLeaderboardProgress(e);(s.ScoreCycleVersion??0)<r&&(s.ScoreEarnedThisCycle=0,s.ClaimedMilestoneIDs=[],s.BracketID=null),s.CurrentScore=t,s.ScoreEarnedThisCycle=(s.ScoreEarnedThisCycle??0)+i,s.ScoreCycleVersion=r,s.LastScoreSubmitUtc=new Date().toISOString(),this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchLeaderboardCycleRewardClaimed(e){if(!e)return;let t=this.currentState?.Leaderboard?.ProgressByCycle?.[e];t&&(t.UnclaimedRewardCycleVersion=0,this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchLeaderboardMilestoneClaimed(e,t){if(!e||!t)return;let i=this.ensureLeaderboardProgress(e);i.ClaimedMilestoneIDs??=[],i.ClaimedMilestoneIDs.includes(t)||i.ClaimedMilestoneIDs.push(t),this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureLeaderboardProgress(e){this.currentState??={},this.currentState.Leaderboard??={},this.currentState.Leaderboard.ProgressByCycle??={};let t=this.currentState.Leaderboard.ProgressByCycle,i=t[e];return i||(i={CurrentScore:0,ScoreEarnedThisCycle:0,ScoreCycleVersion:0,UnclaimedRewardCycleVersion:0,LastKnownRank:0},t[e]=i),i}applySeasonsState(e){this.currentState??={},this.currentState.Season=e??{},this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSeasonState(e,t){!e||!t||(this.currentState??={},this.currentState.Season??={},this.currentState.Season.States??={},this.currentState.Season.States[e]=t,this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchSeasonCurrentTier(e,t){if(!e)return;let i=this.ensureSeasonState(e);i.CurrentTier=t,this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSeasonClaimedTier(e,t){if(!e)return;let i=this.ensureSeasonState(e);i.ClaimedTierRewards??=[],i.ClaimedTierRewards.includes(t)||i.ClaimedTierRewards.push(t),this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureSeasonState(e){this.currentState??={},this.currentState.Season??={},this.currentState.Season.States??={};let t=this.currentState.Season.States,i=t[e];return i||(i={SeasonChainID:e},t[e]=i),i}applyPremium(e){this.currentState??={},this.currentState.Premium=e??{},this.emitter.emit("user:premiumUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCharacter(e){this.currentState??={},this.currentState.Character??={},this.currentState.Character.Characters=e??{},this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCharacter(e,t){if(!e)return;this.currentState??={},this.currentState.Character??={},this.currentState.Character.Characters??={};let i=this.currentState.Character.Characters,r=i[e];r||(r={CharacterID:e},i[e]=r),t(r),this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCharacterEquipment(e,t,i){if(!e||!t)return;let r=this.currentState?.Character?.Characters?.[e];r&&(r.Equipment??={},i===null?delete r.Equipment[t]:r.Equipment[t]=i,this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyInventoryDelta(e){if(!e)return;this.currentState??={},this.currentState.InventoryV2??={},this.currentState.InventoryV2.UnstackableItems??={};let t=this.currentState.InventoryV2.UnstackableItems,i=false;for(let[r,s]of Object.entries(e.ChangedInstances??{}))t[r]=s,i=true;for(let r of e.RemovedInstanceIDs??[])r in t&&(delete t[r],i=true);i&&(this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyMatch(e){this.currentState??={},this.currentState.Match=e??{},this.emitter.emit("user:matchUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchMatchStrategy(e){e&&(this.currentState??={},this.currentState.Match??={},this.currentState.Match.PvPBattleStrategy=e,this.emitter.emit("user:matchUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyCollection(e){this.currentState??={},this.currentState.Collection=e??{},this.emitter.emit("user:collectionUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCoopEvent(e){this.currentState??={},this.currentState.CoopEvent=e??{MyObjectIndex:-1},this.emitter.emit("user:coopEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCoopEventActiveGroup(e,t,i){this.currentState??={};let r=this.currentState.CoopEvent??={MyObjectIndex:-1};r.ActiveGroupID=e,r.ActiveCoopEventID=t,r.MyObjectIndex=i,this.emitter.emit("user:coopEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyDealOffer(e){this.currentState??={},this.currentState.DealOffer=e??{},this.emitter.emit("user:dealOfferUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyReferral(e){this.currentState??={},this.currentState.Referral=e??{},this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchReferralSubscription(e){e&&(this.currentState??={},this.currentState.Referral??={},this.currentState.Referral.SubscribedToUserID=e,this.currentState.Referral.PendingActivationReward=false,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);}applySocialOutgoingRequests(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.OutgoingRequests=(e??[]).map(t=>t.UserID),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applySocialTimeline(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.Timeline=e??[],this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialAddOutgoingRequest(e){if(!e)return;let t=this.ensureSocial();t.OutgoingRequests??=[],t.OutgoingRequests.includes(e)||t.OutgoingRequests.push(e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialAcceptFriend(e){if(!e)return;let t=this.ensureSocial();t.IncomingRequests=(t.IncomingRequests??[]).filter(i=>i!==e),t.Accepted??=[],t.Accepted.includes(e)||t.Accepted.push(e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialRemoveIncomingRequest(e){if(!e)return;let t=this.ensureSocial();t.IncomingRequests=(t.IncomingRequests??[]).filter(i=>i!==e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialRemoveFriend(e){if(!e)return;let t=this.ensureSocial();t.Accepted=(t.Accepted??[]).filter(i=>i!==e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureSocial(){return this.currentState??={},this.currentState.Social??={},this.currentState.Social}applyTimedBoost(e){this.currentState??={},this.currentState.TimedBoost=e??{},this.emitter.emit("user:timedBoostUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchActiveTimedBoost(e,t){this.currentState??={},this.currentState.TimedBoost??={},this.currentState.TimedBoost.Active??={};let i=this.currentState.TimedBoost.Active;if(t==="Replace"||t==="KeepBest")for(let r of Object.keys(i)){let s=i[r];s&&s.BoostID===e.BoostID&&r!==e.InstanceID&&delete i[r];}i[e.InstanceID]=e,this.emitter.emit("user:timedBoostUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyUserCustomData(e){this.currentState??={},this.currentState.CustomData??={};let t=this.currentState.CustomData;t.Version=e.Version??0,t.Private=e.Private??{},t.Public=e.Public??{},t.ReadOnly=e.ReadOnly??{},this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchUserCustomDataKey(e,t,i,r,s){if(!t)return;this.currentState??={},this.currentState.CustomData??={};let a=this.currentState.CustomData,p={Value:i,UpdatedAt:new Date().toISOString(),Version:r,LastWriter:"Client",ExpiresAt:s??null};if(e==="Private")a.Private??={},a.Private[t]=p;else if(e==="Public")a.Public??={},a.Public[t]=p;else return;a.Version=(a.Version??0)+1,this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}removeUserCustomDataKey(e,t){if(!t||!this.currentState?.CustomData)return;let i=this.currentState.CustomData;if(e==="Private")i.Private&&delete i.Private[t];else if(e==="Public")i.Public&&delete i.Public[t];else return;this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyBoardState(e){this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.Board=e??{},this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCommunityChestUserState(e){this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.CommunityChest=e??{},this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardState(e){let t=this.ensureBoard();e(t),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardBuilding(e,t){if(e<0)return;let i=this.ensureBoard();i.BuildingStates??=[];let r=i.BuildingStates.find(s=>s.SlotIndex===e);r||(r={SlotIndex:e},i.BuildingStates.push(r)),t(r),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardPendingRaidLayout(e,t){let r=this.ensureBoard().Pending;r&&(e&&(r.RaidLayout=e),t>=0&&(r.OpenedIndices??=[],r.OpenedIndices.includes(t)||r.OpenedIndices.push(t)),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchBoardSpecialPending(e){let i=this.ensureBoard().Pending;!i||i.Type.toUpperCase()!=="SPECIAL"||(i.Special??={},e(i.Special),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}clearBoardPending(){let e=this.currentState?.GameLoop?.Board;!e||!e.Pending||(e.Pending=null,this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}ensureBoard(){return this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.Board??={},this.currentState.GameLoop.Board}applyBlockchainState(e,t){this.currentState??={},this.currentState.Blockchain=e??{},t&&(this.currentState.InventoryV2??={},this.currentState.InventoryV2.CryptoCurrencies=t),this.emitter.emit("user:blockchainUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyMarketplaceState(e){this.currentState??={},this.currentState.Marketplace=e??{},this.emitter.emit("user:marketplaceUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}getVirtualCurrencyAmount(e){return this.currentState?.InventoryV2?.VirtualCurrencies?.[e]?.Amount??0}getCryptoCurrencyAmount(e){return this.currentState?.InventoryV2?.CryptoCurrencies?.[e]?.Amount??"0"}};var xi=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 bi=class{user;config;constructor(e){this.user=new Si(e),this.config=new xi;}reset(){this.user.clear(),this.config.applyTitlePublicConfiguration(null);}};var Di=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 td(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 td(o){return o!==null&&Object.values(Ce).includes(o)}var id=8,rd=100,sd=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i,qo=["GameLoop"],zi=class{constructor(e){this.ctx=e;}ctx;authContext=null;refreshing=false;rememberSession=true;sessionAuthType=Ce.None;sessionEmail="";sessionPassword="";pendingRegistration=null;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(),Attribution:this.ctx.acquisition.buildForLogin(this.ctx.settings.appVersion)}}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 i=await this.ctx.api.authentication.loginWithTelegram(t);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(Ce.Telegram)):i}async loginWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();i.Email=e,i.Password=t;let r=await this.ctx.api.authentication.loginWithEmail(i);if(!r.ok)return r;this.applyAuthContext(r.data);let s=await this.fetchAndApplyClientState(Ce.Email);return s.ok&&this.keepEmailCredentials(e,t),s}async registerWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();i.Email=e,i.Password=t,i.DeviceID=this.ctx.platform.getDeviceID(),i.Device=this.ctx.platform.getDeviceModel(),i.Platform=this.ctx.platform.getPlatform();let r=await this.ctx.api.authentication.registerWithEmail(i);return r.ok?(this.pendingRegistration={email:e,password:t},mt({codeTtlMinutes:r.data.CodeTtlMinutes??0,resendCooldownSeconds:r.data.ResendCooldownSeconds??0})):r}async confirmEmailRegistration(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();i.Email=e,i.VerificationCode=t;let r=await this.ctx.api.authentication.confirmEmailRegistration(i);if(!r.ok)return r;this.applyAuthContext(r.data);let s=await this.fetchAndApplyClientState(Ce.Email);return s.ok&&this.pendingRegistration?.email===e&&this.keepEmailCredentials(e,this.pendingRegistration.password),this.pendingRegistration=null,s}async resendVerificationCode(e){let t=this.baseRequest();t.Email=e;let i=await this.ctx.api.authentication.resendVerificationCode(t);return i.ok?mt(void 0):i}async loginWithGoogle(e){this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.GoogleIDToken=e;let i=await this.ctx.api.authentication.loginWithGoogle(t);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(Ce.Google)):i}async requestWalletChallenge(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();return i.WalletAddress=e,i.NetworkID=t,this.ctx.api.authentication.requestWalletChallenge(i)}async loginWithWallet(e,t,i){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();r.WalletAddress=e,r.NetworkID=t,r.WalletSignature=i,r.Platform=this.ctx.platform.getPlatform(),r.Device=this.ctx.platform.getDeviceModel(),r.DeviceID=this.ctx.platform.getDeviceID();let s=await this.ctx.api.authentication.loginWithWallet(r);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(Ce.Wallet)):s}async loginWithSsoCode(e){if(!e)return n("client","SSO code is null or empty.");this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.SsoCode=e,t.DeviceID=this.ctx.platform.getDeviceID(),t.Device=this.ctx.platform.getDeviceModel(),t.Platform=this.ctx.platform.getPlatform();let i=await this.ctx.api.authentication.loginWithSsoCode(t);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(Ce.iDosGames)):i}async forgotPassword(e){this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();return t.Email=e,this.ctx.api.authentication.forgotPassword(t)}async resetPassword(e,t,i){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();return r.Email=e,r.ResetToken=t,r.Password=i,this.ctx.api.authentication.resetPassword(r)}autoLogin(){return this.replay(this.ctx.authStore.lastAuthType,this.ctx.authStore.savedEmail,this.ctx.authStore.savedPassword)}replay(e,t,i){switch(e){case Ce.Email:return this.loginWithEmail(t,i);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&&sd.test(e)}static isValidPasswordLength(e){return e.length>=id&&e.length<=rd}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(qo,qo);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 nd="idos:cfg",jt=class{constructor(e,t){this.storage=e;this.titleId=t;}storage;titleId;static scopeOf(e,t){return t&&t.length>0?`x:${Eo(t)}`:e&&e.length>0?`f:${Eo(e)}`:t?"x:":"f:"}async read(e){try{let t=await this.storage.get(this.keyOf(e));if(!t)return null;let i=JSON.parse(t);return !i||typeof i!="object"||typeof i.v!="string"||!i.c?null:i}catch{return null}}async write(e,t,i){try{let r={v:t,c:i};await this.storage.set(this.keyOf(e),JSON.stringify(r));}catch{}}async clear(e){try{await this.storage.remove(this.keyOf(e));}catch{}}keyOf(e){return `${nd}:${this.titleId}:${e}`}};function Eo(o){return [...o].map(e=>e.toLowerCase()).sort().join(",")}var Go="idos:loc",Ft=class{constructor(e,t){this.storage=e;this.titleId=t;}storage;titleId;async read(e){try{let t=await this.storage.get(this.keyOf(e));if(!t)return null;let i=JSON.parse(t);return !i||typeof i!="object"||typeof i.v!="number"||!i.t||typeof i.t!="object"?null:i}catch{return null}}async write(e,t,i){try{let r={v:t,t:i};await this.storage.set(this.keyOf(e),JSON.stringify(r)),await this.noteVersion(e,t);}catch{}}async readVersions(){try{let e=await this.storage.get(this.versionsKey());if(!e)return {};let t=JSON.parse(e);if(!t||typeof t!="object")return {};let i={};for(let[r,s]of Object.entries(t))typeof s=="number"&&s>0&&(i[r]=s);return i}catch{return {}}}async noteVersion(e,t){let i=await this.readVersions();i[e]!==t&&(i[e]=t,await this.storage.set(this.versionsKey(),JSON.stringify(i)));}keyOf(e){return `${Go}:${this.titleId}:${e}`}versionsKey(){return `${Go}:${this.titleId}:versions`}};var od="idos:state",Pi=class{constructor(e,t){this.storage=e;this.titleId=t;}storage;titleId;async read(e){if(!e)return null;try{let t=await this.storage.get(this.keyOf(e));if(!t)return null;let i=JSON.parse(t);return !i||typeof i!="object"||typeof i.e!="string"||!i.v||!i.s?null:i}catch{return null}}async write(e,t,i,r){if(!(!e||!t))try{let s={e:t,v:i,s:r};await this.storage.set(this.keyOf(e),JSON.stringify(s));}catch{}}keyOf(e){return `${od}:${this.titleId}:${e}`}};function ad(o,e){if(!o)return;let t=new Set((e??[]).map(r=>r.trim().toLowerCase()));if(t.size===0)return o;let i={};for(let[r,s]of Object.entries(o))t.has(r.toLowerCase())||(i[r]=s);return i}function js(o,e,t,i){let r={...o??{}};if(!e||!t||!i)return r;for(let[s,a]of Object.entries(t))i[s]===a&&s in e&&(r[s]=e[s]);return r}function ld(o){return {...o??{}}}function Fs(o){return typeof o.StateEpoch=="string"&&o.StateEpoch.length>0?o.StateEpoch:null}var vi=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=ad(this.versions,e);return t&&Object.keys(t).length>0?t:void 0}noteMutation(e,t){if(!e||e!==this.epoch){e&&e!==this.epoch&&this.reset(e);return}for(let[i,r]of Object.entries(t)){let s=this.versions[i];s!==void 0&&r===s+1?this.versions[i]=r:delete this.versions[i],this.dirty=true;}}afterFullRead(e,t){e!==this.epoch&&this.reset(e),this.versions=ld(t),this.dirty=true;}afterSliceRead(e,t){e!==this.epoch&&this.reset(e);for(let[i,r]of Object.entries(t??{}))this.versions[i]=r;this.dirty=true;}async flush(e,t){!this.dirty||!this.epoch||!e||(this.state=t??{},this.dirty=false,await this.cache.write(e,this.epoch,this.versions,this.state));}reset(e){this.epoch=e,this.versions={},this.state=null,this.dirty=true;}};var No=n("server","Title configuration is unavailable (CDN and API both failed)."),Ti=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}get configCache(){return this.cache??=new jt(this.ctx.settings.configStorage,this.ctx.settings.titleID)}cache;get localizationCache(){return this.locCache??=new Ft(this.ctx.settings.configStorage,this.ctx.settings.titleID)}locCache;get stateStore(){return this.versionStore??=new vi(new Pi(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=jt.scopeOf(e.TitleFields,null),i=await this.configCache.read(t);i&&(e.KnownTitleConfigVersion=i.v),await this.prepareLocalization(e);let r=await this.prepareStateHandshake(e,null),s=await this.ctx.api.user.getClientState(e);if(!s.ok)return s;let a=await this.resolveTitleConfig(s.data,t,i,{Fields:e.TitleFields});return a==null?No:(this.finishStateHandshake(s.data,r),await this.applyClientState(s.data,a,void 0,void 0),await this.applyLocalization(s.data.Localization),await this.flushState(r),s)}async prepareStateHandshake(e,t){let i=this.ctx.auth.context?.userID;if(!i)return {userId:null,cached:null,sent:void 0};await this.stateStore.load(i),await this.stateStore.flush(i,this.ctx.data.user.state);let r=this.stateStore.versionsFor(t);if(r){e.KnownStateVersions=r;let s=this.stateStore.currentEpoch;s&&(e.KnownStateEpoch=s);}return {userId:i,cached:this.stateStore.cachedState,sent:r}}finishStateHandshake(e,t){let i=js(e.User,t.cached,t.sent,e.StateVersions);e.User=i;let r=Fs(e);!r||!t.userId||this.stateStore.afterFullRead(r,e.StateVersions);}async resolveTitleConfig(e,t,i,r){let s=e.TitleConfigVersion;if(i&&s&&i.v===s)return i.c;if(e.TitleConfigUrl){let p=await this.fetchConfigFromCdn(e.TitleConfigUrl);if(p!=null)return s&&await this.configCache.write(t,s,p),p}let a=await this.fetchConfigFromApi(r);return a!=null?(s&&await this.configCache.write(t,s,a),a):i?.c??null}async fetchConfigFromCdn(e){try{let t=await this.ctx.fetchImpl(e);if(!t.ok)return null;let i=await t.json();return i&&typeof i=="object"?i:null}catch{return null}}async fetchConfigFromApi(e){let t=this.baseRequest();if(!t)return null;let i={...t,...e},r=e.ExcludeFields?await this.ctx.api.title.getTitlePublicConfigurationExcept(i):await this.ctx.api.title.getTitlePublicConfiguration(i);return r.ok?r.data:null}async getClientStateExcept(e,t){let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.ExcludeFields=e,i.ExcludeTitleFields=t;let r=jt.scopeOf(null,t??[]),s=await this.configCache.read(r);s&&(i.KnownTitleConfigVersion=s.v),await this.prepareLocalization(i);let a=await this.prepareStateHandshake(i,e??null),p=await this.ctx.api.user.getClientStateExcept(i);if(!p.ok)return p;let x=await this.resolveTitleConfig(p.data,r,s,{ExcludeFields:t??[]});return x==null?No:(this.finishStateHandshake(p.data,a),await this.applyClientState(p.data,x,e,t),await this.applyLocalization(p.data.Localization),await this.flushState(a),p)}async prepareLocalization(e){let t=this.ctx.localization.locale??this.ctx.settings.locale;t&&(e.Locale=t);let i=await this.localizationCache.readVersions();Object.keys(i).length>0&&(e.KnownLocalizationVersions=i);}async applyLocalization(e){if(!e){this.ctx.localization.applyState(null,{table:null,fallbackTable:null});return}let t=await this.resolveLocalizationTable({Locale:e.Locale,Version:e.Version,Url:e.Url}),i=e.Fallback?await this.resolveLocalizationTable(e.Fallback):null;this.ctx.localization.applyState(e,{table:t,fallbackTable:i});}async resolveLocalizationTable(e){let t=e.Locale??null,i=e.Version??0;if(!t)return null;let r=await this.localizationCache.read(t);if(i<=0)return r?.t??null;if(r&&r.v===i)return r.t;if(e.Url){let a=await this.fetchLocalizationFromCdn(e.Url);if(a!=null)return await this.localizationCache.write(t,i,a),a}let s=await this.fetchLocalizationFromApi(t,r?.v??0);return s??r?.t??null}async fetchLocalizationFromCdn(e){try{let t=await this.ctx.fetchImpl(e);if(!t.ok)return null;let i=await t.json();return i&&typeof i=="object"?i:null}catch{return null}}async fetchLocalizationFromApi(e,t){let i=this.baseRequest();if(!i)return null;let r=await this.ctx.api.localization.getLocalizationTable({...i,Locale:e,KnownVersion:t});if(!r.ok)return null;let s=r.data;if(s.NotModified)return null;let a=s.Entries??{},p=s.Version??0,x=s.Locale??e;return p>0&&await this.localizationCache.write(x,p,a),a}async getStateVersions(e){let t=this.baseRequest();return t?(e&&e.length>0&&(t.Fields=e),this.ctx.api.user.getStateVersions(t)):n("unauthorized","Not logged in.")}async getUserState(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&e.length>0&&(t.Fields=e);let i=await this.prepareStateHandshake(t,null),r=await this.ctx.api.user.getUserState(t);if(!r.ok)return r;let s=js(r.data.User,i.cached,i.sent,r.data.StateVersions);r.data.User=s;let a=Object.keys(r.data.StateVersions??{});this.ctx.data.user.applyUserStateContainers(s,a);let p=Fs(r.data);return p&&(this.stateStore.afterSliceRead(p,r.data.StateVersions),await this.flushState(i)),r}async flushState(e){e.userId&&await this.stateStore.flush(e.userId,this.ctx.data.user.state);}async getUserInventory(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getInventory(e);return t.ok&&(this.ctx.data.user.applyInventory(t.data),this.ctx.emitter.emit("user:inventoryReceived",t.data)),t}async getEventTokens(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getEventTokens(e);return t.ok&&this.ctx.emitter.emit("user:eventTokensReceived",t.data),t}async getUsageTime(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getUsageTime(e);return t.ok&&this.ctx.emitter.emit("user:usageTimeReceived",t.data),t}async addUsageTime(e,t,i){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.UsageTime=e,r.IsNewSession=t,r.SessionDurationSeconds=i;let s=await this.ctx.api.user.addUsageTime(r);return s.ok&&this.ctx.emitter.emit("user:usageTimeAdded",s.data),s}async deleteUserAccount(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.deleteUserAccount(e);return t.ok&&this.ctx.emitter.emit("user:accountDeleted",t.data),t}async changeUsername(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Username=e;let i=await this.ctx.api.user.changeUsername(t);return i.ok&&this.ctx.emitter.emit("user:usernameChanged",i.data),i}async applyClientState(e,t,i,r){let s=i?.includes("GameLoop")===true,a=r?.includes("GameLoop")===true,p=s?this.ctx.data.user.state?.GameLoop:void 0,x=a?this.ctx.data.config.titlePublicConfiguration?.GameLoop:void 0;this.ctx.data.config.applyTitlePublicConfiguration(t),this.ctx.data.user.applyUserState(e.User??{});let k=this.ctx.data.user.state;s&&k&&k.GameLoop==null&&(k.GameLoop=p);let N=this.ctx.data.config.titlePublicConfiguration;a&&N&&N.GameLoop==null&&(N.GameLoop=x),this.ctx.emitter.emit("user:clientStateReceived",e);}};var ki=class{constructor(e){this.ctx=e;}ctx;async convert(e,t,i,r,s,a){if(!t)return n("client","SourceID is required.");if(!r)return n("client","TargetID is required.");if(s<=0)return n("client","Amount must be positive.");if(e===i&&t===r)return n("client","Source and target must differ.");if(e===He.Crypto||i===He.Crypto)return n("client","Convert supports VC\u2194VC only. Use cryptoConvert for crypto.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let p={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:i,TargetID:r,SourceAmount:String(Math.trunc(s)),TransactionID:a&&a.length>0?a:`convert_${e}_${t}_to_${i}_${r}_${M()}`},x=await this.ctx.api.currency.convert(p);if(x.ok){let k=x.data,N={Consume:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:k.SourceID,Amount:k.SourceSpent}]}},Grant:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:k.TargetID,Amount:k.TargetCredited}]}}};this.ctx.data.user.applyResourceOperation(N,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("currency:converted",k);}return x}async cryptoConvert(e,t,i,r,s,a){let p=s instanceof Ci__default.default?s:new Ci__default.default(s);if(!t)return n("client","SourceID is required.");if(!r)return n("client","TargetID is required.");if(p.lte(0))return n("client","SourceAmount must be a positive decimal.");if(e===i&&t===r)return n("client","Source and target must differ.");if(e===He.Virtual&&i===He.Virtual)return n("client","cryptoConvert requires at least one crypto side. Use convert for VC\u2194VC.");if(e===He.Virtual&&!p.isInteger())return n("client","Virtual currency source amount must be integer.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let x={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:i,TargetID:r,SourceAmount:p.toString(),TransactionID:a&&a.length>0?a:`crypto_convert_${e}_${t}_to_${i}_${r}_${M()}`},k=await this.ctx.api.currency.cryptoConvert(x);if(k.ok){let N=k.data,ge=[],xe=[];if(N.SourceType===He.Virtual&&ge.push({Type:"VirtualCurrency",CurrencyID:N.SourceID,Amount:Math.trunc(Number(N.SourceSpent))}),N.TargetType===He.Virtual&&xe.push({Type:"VirtualCurrency",CurrencyID:N.TargetID,Amount:Math.trunc(Number(N.TargetCredited))}),ge.length>0||xe.length>0){let Ae={Consume:ge.length>0?{Standard:{Entries:ge}}:null,Grant:xe.length>0?{Standard:{Entries:xe}}:null};this.ctx.data.user.applyResourceOperation(Ae,this.ctx.data.config.itemDefinitions);}N.SourceType===He.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(N.SourceID,new Ci__default.default(N.SourceSpent).negated(),N.ServerTimeUtc),N.TargetType===He.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(N.TargetID,new Ci__default.default(N.TargetCredited),N.ServerTimeUtc),this.ctx.emitter.emit("currency:cryptoConverted",N);}return k}};var wi=class{constructor(e){this.ctx=e;}ctx;async upgradeLevel(e,t,i){let r=e.trim();if(!r)return n("client","ItemInstanceID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),ItemInstanceID:r,SelectedOptionID:i,RelatedEntityID:`upgrade_item_${r}_${M()}`};t&&t.length>0&&(s.FodderInstanceIDs=[...t]);let a=await this.ctx.api.item.upgradeLevel(s);return a.ok&&(await this.ctx.userService.getUserInventory(),this.ctx.emitter.emit("item:levelUpgraded",a.data)),a}async upgradeLevelsBatch(e){if(!e||e.length===0)return n("client","upgrades is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Upgrades:e},i=await this.ctx.api.item.upgradeLevelsBatch(t);return i.ok&&(await this.ctx.userService.getUserInventory(),this.ctx.emitter.emit("item:levelsUpgradedBatch",i.data)),i}};var ud="Store",Mi=class{constructor(e){this.ctx=e;}ctx;storefront=null;storefrontLoadedAt=0;async purchase(e,t=1,i){if(!e)return n("client","OfferID is required.");if(t<1)return n("client","Count must be at least 1.");let r=this.ctx.auth.context;if(!r)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),OfferID:e,Count:t,SelectedOptionID:i?.selectedOptionID,Payment:i?.payment,StoreID:i?.slot?.storeID,SectionID:i?.slot?.sectionID,SlotID:i?.slot?.slotID,RelatedEntityID:`store_buy_${e}_${r.userID}_${M()}`},a=await this.ctx.api.store.purchase(s);if(a.ok){let p=a.data;this.ctx.data.user.patchStorePurchase(e,t,p.ServerTimeUtc),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("store:offerPurchased",p);}return a}async purchaseBatch(e){if(!e||e.length===0)return n("client","purchases is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Purchases:e},i=await this.ctx.api.store.purchaseBatch(t);if(i.ok){let r=false;for(let s of i.data)!s.Success||!s.Data||!s.Data.OfferID||(this.ctx.data.user.patchStorePurchase(s.Data.OfferID,s.Data.Count,s.Data.ServerTimeUtc),!r&&s.Data.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("store:offersPurchasedBatch",i.data);}return i}async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.store.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(ud,t.data),this.ctx.emitter.emit("store:definitionsLoaded",t.data)),t}async getStorefront(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.store.getStorefront(e);return t.ok&&(this.storefront=t.data,this.storefrontLoadedAt=Date.now(),this.ctx.emitter.emit("store:storefrontLoaded",t.data)),t}get cachedStorefront(){return this.storefront}nextRefreshAtUtc(){let e=null;for(let t of this.storefront?.Stores??[])for(let i of t.Sections??[])for(let r of i.Slots??[]){let s=r.RefreshesAtUtc;s&&(e===null||Date.parse(s)<Date.parse(e))&&(e=s);}return e}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 Ai=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let e={...this.ctx.buildAuthedBaseRequest()};return this.ctx.api.purchase.getDefinitions(e)}async getUserState(){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let e={...this.ctx.buildAuthedBaseRequest()};return this.ctx.api.purchase.getUserState(e)}async validatePurchase(e,t,i){if(!t)return n("client","Receipt is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),Store:e,Receipt:t,Signature:i?.signature,ProductID:i?.productID,TransactionID:i?.transactionID},s=await this.ctx.api.purchase.validatePurchase(r);return s.ok&&s.data.Granted&&this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),s}async validatePurchasesBatch(e){if(!e||e.length===0)return n("client","receipts is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Receipts:e};return this.ctx.api.purchase.validatePurchasesBatch(t)}};var Oi=class{constructor(e){this.ctx=e;}ctx;get platform(){return this.ctx.clientPlatform}availableOptions(e){return e?Object.entries(e).filter(([,t])=>t!=null).map(([t,i])=>({...i,OptionID:i.OptionID||t})).filter(t=>this.isAvailable(t)).sort((t,i)=>(t.OptionID??"").localeCompare(i.OptionID??"")):[]}isAvailable(e){if(!e)return false;let t=e.AllowedPlatforms;return !t||t.length===0?true:t.includes(this.platform)}requirementOf(e){let t=this.storeProductOf(e.Cost);return t?{option:e,kind:"store",productID:t}:{option:e,kind:"resources",shortfall:this.cryptoShortfallOf(e.Cost)??void 0}}storeProductOf(e){let t=e?.Standard?.Entries;if(!t)return null;for(let i of t)if(i?.Type===li.Purchase&&i.ProductID)return i.ProductID;return null}cryptoShortfallOf(e){let t=e?.Standard?.Entries;if(!t)return null;for(let i of t){if(i?.Type!==li.CryptoCurrency||!i.CurrencyID)continue;let r=Number(i.Amount??0);if(!(r>0))continue;let s=this.cryptoBalance(i.CurrencyID);return s>=r?null:{currencyID:i.CurrencyID,required:r,available:s,missing:r-s}}return null}cryptoBalance(e){let i=this.ctx.data.user.state?.InventoryV2?.CryptoCurrencies?.[e];return Number(i?.Amount??0)}};var cd="Lootbox",Ui=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.lootbox.getDefinitions(e);if(t.ok){let i=t.data.LootboxDefinitions;i&&(this.ctx.data.config.patchSection(cd,i),this.ctx.emitter.emit("lootbox:definitionsLoaded",i));}return t}async open(e,t,i,r){if(!e)return n("client","LootboxID is required.");if(t<1)return n("client","Count must be at least 1.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),LootboxID:e,Count:t,SelectedOptionID:i,Payment:r,RelatedEntityID:`lootbox_${e}_${i??"default"}_${M()}`},a=await this.ctx.api.lootbox.open(s);if(a.ok){let p=a.data;p.TriggeredPity&&p.TriggeredPity.length>0&&this.ctx.data.user.applyLootboxPityTriggers(e,p.TriggeredPity,t),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.data.user.applyInventoryDelta(p.Inventory),this.ctx.emitter.emit("lootbox:opened",p);}return a}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var pd="Reward";function Vs(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var Bi=class{constructor(e){this.ctx=e;}ctx;multiplier=1;multiplierEnabled=false;get milestoneRewardMultiplier(){return this.multiplier}get milestoneRewardMultiplierEnabled(){return this.multiplierEnabled}async getRewardDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.reward.getRewardDefinitions(e);if(t.ok){let i=t.data.RewardDefinitions;i&&(this.ctx.data.config.patchSection(pd,i),this.ctx.emitter.emit("reward:definitionsLoaded",i));}return t}async getUserRewardsState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.reward.getUserRewardsState(e);return t.ok&&t.data.Rewards&&(this.ctx.data.user.applyReward(t.data.Rewards),this.ctx.emitter.emit("reward:userStateLoaded",t.data.Rewards)),t}async getMilestoneRewardMultiplier(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.reward.getMilestoneRewardMultiplier(e);if(t.ok){let i=t.data;this.multiplierEnabled=i.Enabled,this.multiplier=i.Enabled?i.Multiplier??1:1,this.ctx.emitter.emit("reward:milestoneMultiplierLoaded",i);}return t}async claimDailyReward(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CalendarID:e,RelatedEntityID:`dailyreward_${t.userID}_${e??"default"}_${M()}`},r=await this.ctx.api.reward.claimDailyReward(i);if(r.ok){let s=r.data;this.ctx.data.user.patchDailyCalendarState(s.CalendarID,s.DailyState),this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:dailyClaimed",s);}return r}async collectIdleAccrual(e){if(!Vs(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()}`},i=await this.ctx.api.reward.collectIdleAccrual(t);if(i.ok){let r=i.data;this.ctx.data.user.patchIdleAccrualState(r.AccrualID,r.IdleState),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:idleCollected",r);}return i}async claimComebackReward(e){if(!Vs(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()}`},i=await this.ctx.api.reward.claimComebackReward(t);if(i.ok){let r=i.data;this.ctx.data.user.patchComebackState(r.ComebackID,r.ComebackState),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:comebackClaimed",r);}return i}async claimReward(e){if(!Vs(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()}`},i=await this.ctx.api.reward.claimReward(t);if(i.ok){let r=i.data;this.ctx.data.user.patchClaimRewardState(r.ClaimID,r.ClaimState),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:claimed",r);}return i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var dd="Tutorial",Li=class{constructor(e){this.ctx=e;}ctx;async getTutorialDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.tutorial.getTutorialDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(dd,t.data),this.ctx.emitter.emit("tutorial:definitionsLoaded",t.data)),t}async getUserTutorialState(e=true){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.AutoStart=e;let i=await this.ctx.api.tutorial.getUserTutorialState(t);if(i.ok){let r=i.data.State??{};this.ctx.data.user.applyTutorial(r),this.ctx.emitter.emit("tutorial:userStateLoaded",i.data);}return i}async startFlow(e){return this.flowCall(e,t=>this.ctx.api.tutorial.startFlow(t),{event:"tutorial:flowStarted"})}async reportStepShown(e,t){return this.stepCall(e,t,i=>this.ctx.api.tutorial.reportStepShown(i))}async completeStep(e,t){return this.stepCall(e,t,i=>this.ctx.api.tutorial.completeStep(i),{relatedEntityID:`tutorial_step_${e}_${t}_${M()}`})}async completeStepsBatch(e,t){let i=e?.trim();if(!i)return n("client","FlowID is required.");if(!t||t.length===0)return n("client","stepIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),FlowID:i,StepIDs:t,RelatedEntityID:`tutorial_batch_${i}_${M()}`},s=await this.ctx.api.tutorial.completeStepsBatch(r);return s.ok&&(await this.refreshAfterMutation(),this.ctx.emitter.emit("tutorial:stepsCompletedBatch",s.data)),s}async skipStep(e,t){return this.stepCall(e,t,i=>this.ctx.api.tutorial.skipStep(i))}async skipFlow(e){return this.flowCall(e,t=>this.ctx.api.tutorial.skipFlow(t),{event:"tutorial:flowSkipped"})}async claimFlowReward(e){let t=e?.trim();if(!t)return n("client","FlowID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),FlowID:t,RelatedEntityID:`tutorial_claim_${t}_${M()}`},r=await this.ctx.api.tutorial.claimFlowReward(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Granted,this.ctx.data.config.itemDefinitions),await this.refreshAfterMutation(),this.ctx.emitter.emit("tutorial:rewardClaimed",r.data)),r}async resetFlow(e){return this.flowCall(e,t=>this.ctx.api.tutorial.resetFlow(t),{event:"tutorial:flowReset"})}async flowCall(e,t,i){let r=e?.trim();if(!r)return n("client","FlowID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),FlowID:r},a=await t(s);return a.ok&&(this.applyFlowView(a.data),this.ctx.emitter.emit(i.event,a.data)),a}async stepCall(e,t,i,r){let s=e?.trim(),a=t?.trim();if(!s)return n("client","FlowID is required.");if(!a)return n("client","StepID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let p={...this.ctx.buildAuthedBaseRequest(),FlowID:s,StepID:a};r?.relatedEntityID&&(p.RelatedEntityID=r.relatedEntityID);let x=await i(p);return x.ok&&(this.applyFlowView(x.data),this.ctx.emitter.emit("tutorial:stepChanged",x.data)),x}applyFlowView(e){e?.Flow&&this.ctx.data.user.patchTutorialFlow(e.Flow);}async refreshAfterMutation(){await this.getUserTutorialState(false).catch(()=>{});}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var qi=class{constructor(e){this.ctx=e;}ctx;async getState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.communityMarketing.getCommunityMarketingState(e);return t.ok&&this.ctx.emitter.emit("communityMarketing:stateLoaded",t.data),t}async getEarnings(e=0){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e>0&&(t.Limit=e);let i=await this.ctx.api.communityMarketing.getEarnings(t);return i.ok&&this.ctx.emitter.emit("communityMarketing:earningsLoaded",i.data),i}async claim(e){if(!e)return n("client","campaignID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CampaignID=e;let i=await this.ctx.api.communityMarketing.claim(t);return i.ok&&this.ctx.emitter.emit("communityMarketing:claimed",i.data),i}async withdrawCryptoReward(e,t,i){if(!e)return n("client","campaignID is required.");if(!t)return n("client","walletAddress is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.CampaignID=e,r.WalletAddress=t,i&&(r.Amount=i);let s=await this.ctx.api.communityMarketing.withdrawCryptoReward(r);return s.ok&&this.ctx.emitter.emit("communityMarketing:withdrawn",s.data),s}async checkJoinEligibility(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.communityMarketing.checkJoinEligibility(e);return t.ok&&this.ctx.emitter.emit("communityMarketing:eligibilityChecked",t.data),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var hd="Chat",Ei=class{constructor(e){this.ctx=e;}ctx;cursors=new Map;async getChatDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.chat.getChatDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(hd,t.data),this.ctx.emitter.emit("chat:definitionsLoaded",t.data)),t}async getChannels(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&(t.Locale=e);let i=await this.ctx.api.chat.getChannels(t);return i.ok&&this.ctx.emitter.emit("chat:channelsLoaded",i.data),i}async poll(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&(t.Locale=e),this.cursors.size>0&&(t.Cursors=[...this.cursors.values()]);let i=await this.ctx.api.chat.poll(t);if(!i.ok)return i;for(let r of i.data.Rooms??[])r.NextCursor&&r.RoomID&&this.cursors.set(r.RoomID,r.NextCursor),r.Messages&&r.Messages.length>0&&this.ctx.emitter.emit("chat:messages",r);return i}async getHistory(e,t,i){let r=this.baseRequest();return r?(r.RoomID=e,t&&(r.Before=t),i&&(r.Limit=i),this.ctx.api.chat.getHistory(r)):n("unauthorized","Not logged in.")}async sendMessage(e,t,i){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.ChannelID=e,r.Text=t,i&&(r.Locale=i);let s=await this.ctx.api.chat.sendMessage(r);return s.ok&&this.ctx.emitter.emit("chat:sent",s.data),s}async sendDirect(e,t){let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.Text=t;let r=await this.ctx.api.chat.sendMessage(i);return r.ok&&this.ctx.emitter.emit("chat:sent",r.data),r}async openDirectChannel(e){let t=this.baseRequest();return t?(t.TargetUserID=e,this.ctx.api.chat.openDirectChannel(t)):n("unauthorized","Not logged in.")}async getConversations(){let e=this.baseRequest();return e?this.ctx.api.chat.getConversations(e):n("unauthorized","Not logged in.")}async markRead(e,t){let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.Cursors=[t??this.cursors.get(e)??{RoomID:e}];let r=await this.ctx.api.chat.markRead(i);return r.ok&&this.ctx.emitter.emit("chat:read",{roomID:e}),r}async joinChannel(e){let t=this.baseRequest();return t?(t.ChannelID=e,this.ctx.api.chat.joinChannel(t)):n("unauthorized","Not logged in.")}async leaveChannel(e){let t=this.baseRequest();return t?(t.ChannelID=e,this.ctx.api.chat.leaveChannel(t)):n("unauthorized","Not logged in.")}async reportMessage(e,t,i,r){let s=this.baseRequest();return s?(s.RoomID=e,s.MessageID=t,s.Reason=i,r&&(s.Comment=r),this.ctx.api.chat.reportMessage(s)):n("unauthorized","Not logged in.")}async ignoreUser(e){let t=this.baseRequest();return t?(t.TargetUserID=e,this.ctx.api.chat.ignoreUser(t)):n("unauthorized","Not logged in.")}async unignoreUser(e){let t=this.baseRequest();return t?(t.TargetUserID=e,this.ctx.api.chat.unignoreUser(t)):n("unauthorized","Not logged in.")}resetCursors(){this.cursors.clear();}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var md={WebPush:"WebPush",Fcm:"Fcm",Apns:"Apns"},fd=zod.z.enum(["WebPush","Fcm","Apns"]).catch("WebPush"),gd={Player:"player",Title:"title",Creator:"creator"},Vt={GetPushConfig:"GetPushConfig",SubscribePush:"SubscribePush",UnsubscribePush:"UnsubscribePush",GetPushSubscriptions:"GetPushSubscriptions"},jo=zod.z.object({Configured:zod.z.boolean().nullish(),PublicKey:zod.z.string().nullish()}).passthrough(),yd=zod.z.object({TitleID:zod.z.string().nullish(),Topic:zod.z.string().nullish()}).passthrough(),_s=zod.z.object({EndpointHash:zod.z.string().nullish(),Transport:fd.nullish(),Locale:zod.z.string().nullish(),Topics:zod.z.array(yd).nullish()}).passthrough(),Fo=zod.z.object({Configured:zod.z.boolean().nullish(),Subscriptions:zod.z.array(_s).nullish()}).passthrough(),ut={Unsupported:"unsupported",Idle:"idle",Subscribed:"subscribed",Blocked:"blocked",Embedded:"embedded"};var Rd="IDOS_PLATFORM_PUSH_REQUEST",Cd="IDOS_PLATFORM_PUSH_RESPONSE",Vo=["https://idosgames.com","https://www.idosgames.com"];function _o(o){if(typeof window>"u"||window.self===window.top)return Promise.resolve(false);let e=window.parent;if(!e)return Promise.resolve(false);let t=`push-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`;return new Promise(i=>{let r=false,s=x=>{r||(r=true,window.removeEventListener("message",a),clearTimeout(p),i(x));},a=x=>{let k=x?.data;!k||k.type!==Cd||k.requestId!==t||Vo.includes(x.origin)&&s(k.ok===true);},p=setTimeout(()=>s(false),12e4);window.addEventListener("message",a);for(let x of Vo)try{e.postMessage({type:Rd,requestId:t,titleID:o},x);}catch{}})}var Gi=class{constructor(e){this.ctx=e;}ctx;cachedConfig=null;async getConfig(e=false){if(!e&&this.cachedConfig)return this.cachedConfig;let t=this.baseRequest();if(!t)return {Configured:false,PublicKey:null};let i=await this.ctx.api.push.getPushConfig(t),r=i.ok?i.data:{Configured:false,PublicKey:null};return this.cachedConfig=r,i.ok&&this.ctx.emitter.emit("push:configLoaded",r),r}async getState(){let e=await this.getConfig();if(!e.Configured||!e.PublicKey)return ut.Unsupported;if(this.isEmbedded())return ut.Embedded;if(!this.isSupported())return ut.Unsupported;let t=Notification.permission;return t==="denied"?ut.Blocked:t!=="granted"?ut.Idle:await(await navigator.serviceWorker.getRegistration())?.pushManager.getSubscription()?ut.Subscribed:ut.Idle}async subscribe(e={}){let t=await this.getConfig();if(!t.Configured||!t.PublicKey)return n("client","Push notifications are not available for this title.");if(this.isEmbedded())return await _o(this.ctx.settings.titleID)?mt({Where:"portal",Subscription:null}):n("client","The portal did not complete the subscription.");if(!this.isSupported())return n("client","This browser has no Push API.");let i=await Notification.requestPermission();if(i!=="granted")return n("client",i==="denied"?"The player blocked notifications for this site.":"The player dismissed the permission prompt.");let r=await navigator.serviceWorker.register(e.swPath??"./sw.js");await navigator.serviceWorker.ready;let a=await r.pushManager.getSubscription()??await r.pushManager.subscribe({userVisibleOnly:true,applicationServerKey:Sd(t.PublicKey)}),p=this.baseRequest();if(!p)return n("unauthorized","Not logged in.");let x=a.toJSON();p.PushEndpoint=x.endpoint,p.PushP256dh=x.keys?.p256dh,p.PushAuth=x.keys?.auth,p.PushTransport="WebPush",p.PushLocale=e.locale??navigator.language,p.PushTimezoneOffsetMinutes=-new Date().getTimezoneOffset();let k=await this.ctx.api.push.subscribePush(p);return k.ok?(this.ctx.emitter.emit("push:subscribed",k.data),mt({Where:"game",Subscription:k.data})):k}async unsubscribe(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");if(this.isSupported()){let r=await(await navigator.serviceWorker.getRegistration())?.pushManager.getSubscription();r&&(e.PushEndpoint=r.endpoint,await r.unsubscribe());}if(!e.PushEndpoint)return n("client","This browser has no push subscription to remove.");let t=await this.ctx.api.push.unsubscribePush(e);return t.ok&&this.ctx.emitter.emit("push:unsubscribed",void 0),t}async getSubscriptions(){let e=this.baseRequest();return e?await this.ctx.api.push.getPushSubscriptions(e):n("unauthorized","Not logged in.")}async unsubscribeByHash(e){if(!e)return n("client","endpointHash is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.PushEndpointHash=e;let i=await this.ctx.api.push.unsubscribePush(t);return i.ok&&this.ctx.emitter.emit("push:unsubscribed",void 0),i}isSupported(){return typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window}isEmbedded(){return typeof window<"u"&&window.self!==window.top}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};function Sd(o){let e=o.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(o.length/4)*4,"="),t=atob(e),i=new ArrayBuffer(t.length),r=new Uint8Array(i);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);return i}var Ni=Object.freeze({}),ji=class{constructor(e){this.ctx=e;}ctx;table={...Ni};fallbackTable=null;currentLocale=null;currentFallbackLocale=null;pluralRules=null;get cache(){return this.tableCache??=new Ft(this.ctx.settings.configStorage,this.ctx.settings.titleID)}tableCache;get locale(){return this.currentLocale}get fallbackLocale(){return this.currentFallbackLocale}get locales(){let e=this.ctx.data.config.titlePublicConfiguration?.Localization??null;return e?.Locales?Object.entries(e.Locales).filter(([,t])=>t?.IsEnabled!==false).map(([t,i])=>({Locale:i?.Locale??t,DisplayName:i?.DisplayName??null,Order:i?.Order??0})).sort((t,i)=>(t.Order??0)-(i.Order??0)):[]}has(e){return this.lookup(e)!==void 0}t(e,t){if(!e)return "";let i=this.resolveKey(e,t),r=this.lookup(i)??this.lookup(e);return r===void 0?this.onMissing(e):t?xd(r,t):r}applyState(e,t){if(!e){this.reset();return}let i=e.Locale??null;this.table=t.table??{...Ni},this.fallbackTable=t.fallbackTable,this.currentFallbackLocale=e.Fallback?.Locale??null,this.setLocaleInternal(i),this.ctx.emitter.emit("localization:changed",{locale:i,fallbackLocale:this.currentFallbackLocale,entryCount:Object.keys(this.table).length});}async setLocale(e){if(!this.baseRequest())return n("unauthorized","Not logged in.");let i=await this.loadTableFromApi(e);if(!i.ok)return i;let{locale:r,table:s,fallbackLocale:a}=i.data,p=null;if(a){let x=await this.loadTableFromApi(a);x.ok&&(p=x.data.table);}return this.table=s,this.fallbackTable=p,this.currentFallbackLocale=a,this.setLocaleInternal(r),this.ctx.emitter.emit("localization:changed",{locale:r,fallbackLocale:a,entryCount:Object.keys(s).length}),{ok:true,data:r}}async getManifest(){let e=this.baseRequest();return e?(e.Locale=this.currentLocale??this.ctx.settings.locale,this.ctx.api.localization.getLocalizationManifest(e)):n("unauthorized","Not logged in.")}reset(){this.table={...Ni},this.fallbackTable=null,this.currentFallbackLocale=null,this.setLocaleInternal(null);}setLocaleInternal(e){this.currentLocale=e,this.pluralRules=null;}baseRequest(){let e=this.ctx.auth.context;return e?{UserID:e.userID,ClientSessionTicket:e.clientSessionTicket,BuildKey:this.ctx.settings.buildKey,RelatedEntityID:M()}:null}async loadTableFromApi(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Locale=e;let i=await this.cache.read(Wo(e));i&&(t.KnownVersion=i.v);let r=await this.ctx.api.localization.getLocalizationTable(t);if(!r.ok)return r;let s=r.data,a=s.Locale??Wo(e),p=s.Version??0;if(s.NotModified){let k=i??await this.cache.read(a);return {ok:true,data:{locale:a,table:k?.t??{...Ni},fallbackLocale:s.FallbackLocale??null}}}let x=s.Entries??{};return p>0&&await this.cache.write(a,p,x),{ok:true,data:{locale:a,table:x,fallbackLocale:s.FallbackLocale??null}}}lookup(e){let t=this.table[e];return t!==void 0?t:this.fallbackTable?.[e]}resolveKey(e,t){let i=t?.count;if(typeof i!="number")return e;let r=this.pluralCategory(i),s=`${e}.${r}`;if(this.lookup(s)!==void 0)return s;let a=`${e}.other`;return this.lookup(a)!==void 0?a:e}pluralCategory(e){try{return this.pluralRules??=new Intl.PluralRules(this.currentLocale??void 0),this.pluralRules.select(e)}catch{return "other"}}onMissing(e){let t=this.ctx.data.config.titlePublicConfiguration?.Localization?.MissingKeyMode??"ReturnKey";return t==="ReturnEmpty"?"":t==="ReturnMarkedKey"?`\u27E6${e}\u27E7`:e}};function xd(o,e){return o.replace(/\{(\w+)\}/g,(t,i)=>{let r=e[i];return r===void 0?t:String(r)})}function Wo(o){return o.trim().replace(/_/g,"-").toLowerCase()}var bd="Quest",Fi=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(bd,t.data),this.ctx.emitter.emit("quest:definitionsLoaded",t.data)),t}async getUserQuestState(e=true){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.AutoRefreshCycles=e;let i=await this.ctx.api.quest.getUserQuestState(t);if(i.ok){let r=i.data.State??{};this.ctx.data.user.applyQuest(r),this.ctx.data.user.patchQuestPointsTracks(i.data.PointsTracks),this.ctx.emitter.emit("quest:userStateLoaded",r);}return i}async refreshQuestCycles(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.quest.refreshQuestCycles(e);return t.ok&&this.ctx.emitter.emit("quest:cyclesRefreshed",void 0),t}async claimQuestReward(e,t){let i=e.trim();if(!i)return n("client","QuestID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r=t&&t.trim().length>0?t.trim():void 0,s={...this.ctx.buildAuthedBaseRequest(),QuestID:i,CycleID:r,RelatedEntityID:`quest_claim_${r??""}_${i}_${M()}`},a=await this.ctx.api.quest.claimQuestReward(s);if(a.ok){let p=a.data;this.ctx.data.user.patchQuestStatus(p.QuestID,p.CycleID,"Claimed"),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:rewardClaimed",p);}return a}async claimQuestRewardsBatch(e){if(!e||e.length===0)return n("client","quests is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Quests:e},i=await this.ctx.api.quest.claimQuestRewardsBatch(t);if(i.ok){let r=false;for(let s of i.data)!s.Success||!s.Data||(this.ctx.data.user.patchQuestStatus(s.Data.QuestID,s.Data.CycleID,"Claimed"),!r&&s.Data.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("quest:rewardsClaimedBatch",i.data);}return i}async claimMilestoneReward(e,t){let i=e.trim(),r=t.trim();if(!i||!r)return n("client","CycleID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CycleID:i,MilestoneID:r,RelatedEntityID:`milestone_claim_${i}_${r}_${M()}`},a=await this.ctx.api.quest.claimMilestoneReward(s);if(a.ok){let p=a.data;this.ctx.data.user.patchMilestoneClaimed(p.CycleID,p.MilestoneID),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:milestoneClaimed",p);}return a}async claimMilestoneRewardsBatch(e){if(!e||e.length===0)return n("client","milestones is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Milestones:e},i=await this.ctx.api.quest.claimMilestoneRewardsBatch(t);if(i.ok){let r=false;for(let s of i.data)!s.Success||!s.Data||(this.ctx.data.user.patchMilestoneClaimed(s.Data.CycleID,s.Data.MilestoneID),!r&&s.Data.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("quest:milestonesClaimedBatch",i.data);}return i}async claimGroupCompletionReward(e,t){let i=e.trim(),r=t.trim();if(!i||!r)return n("client","CycleID and GroupCompletionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CycleID:i,GroupCompletionID:r,RelatedEntityID:`group_completion_${i}_${r}_${M()}`},a=await this.ctx.api.quest.claimGroupCompletionReward(s);if(a.ok){let p=a.data;this.ctx.data.user.patchGroupCompletionClaimed(p.CycleID,p.GroupCompletionID),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:groupCompletionClaimed",p);}return a}async addQuestProgress(e,t){let i=e.trim();if(!i)return n("client","MetricID is required.");if(t<0)return n("client","ProgressValue must be >= 0.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),MetricID:i,ProgressValue:t},s=await this.ctx.api.quest.addQuestProgress(r);return s.ok&&(this.ctx.data.user.patchQuestProgressUpdates(s.data.Updates),this.ctx.emitter.emit("quest:progressAdded",s.data)),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Dd="TimedEvent",Vi=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(Dd,t.data),this.ctx.emitter.emit("timedEvent:definitionsLoaded",t.data)),t}async getUserLteState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedEvent.getUserLteState(e);return t.ok&&(this.ctx.data.user.applyUserLteState(t.data),this.ctx.emitter.emit("timedEvent:userStateLoaded",t.data)),t}async grantTokens(e,t,i,r,s,a,p=1){if(!t)return n("client","LteID is required.");if(!i)return n("client","SourceType is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let x={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,SourceType:i,Outcome:r,AmountOverride:s,SourceParams:a,RollMultiplier:p},k=await this.ctx.api.timedEvent.grantTokens(x);return k.ok&&(this.ctx.data.user.applyResourceOperation(k.data,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensGranted",k.data)),k}async spendTokens(e,t,i){if(!t)return n("client","LteID is required.");if(i<=0)return n("client","SpendAmount must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,SpendAmount:i},s=await this.ctx.api.timedEvent.spendTokens(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensSpent",s.data)),s}async claimMilestone(e,t,i){if(!t||!i)return n("client","LteID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,MilestoneID:i},s=await this.ctx.api.timedEvent.claimMilestone(r);if(s.ok){let a=s.data;this.ctx.data.user.applyResourceOperation(a.Rewards,this.ctx.data.config.itemDefinitions),this.ctx.data.user.patchTimedEventMilestoneClaimed(e,t,i),this.ctx.emitter.emit("timedEvent:milestoneClaimed",a);}return s}async claimMilestonesBatch(e){if(!e||e.length===0)return n("client","milestones is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Milestones:e},i=await this.ctx.api.timedEvent.claimMilestonesBatch(t);return i.ok&&(this.applyMilestoneClaimBatch(i.data),this.ctx.emitter.emit("timedEvent:milestonesClaimedBatch",i.data)),i}async claimAllMilestones(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&e.length>0&&(t.Events=e);let i=await this.ctx.api.timedEvent.claimAllMilestones(t);return i.ok&&(this.applyMilestoneClaimBatch(i.data),this.ctx.emitter.emit("timedEvent:allMilestonesClaimed",i.data)),i}async spendTokensBatch(e){if(!e||e.length===0)return n("client","spends is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Spends:e},i=await this.ctx.api.timedEvent.spendTokensBatch(t);if(i.ok){let r=false;for(let s of i.data)!r&&s.Success&&s.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("timedEvent:tokensSpentBatch",i.data);}return i}async grantTokensBatch(e){if(!e||e.length===0)return n("client","grants is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Grants:e},i=await this.ctx.api.timedEvent.grantTokensBatch(t);if(i.ok){let r=false;for(let s of i.data)!r&&s.Success&&s.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("timedEvent:tokensGrantedBatch",i.data);}return i}applyMilestoneClaimBatch(e){let t=false;for(let i of e){if(!i.Success||!i.Data)continue;let r=i.Data;r.Type&&r.LteID&&r.MilestoneID&&this.ctx.data.user.patchTimedEventMilestoneClaimed(r.Type,r.LteID,r.MilestoneID),!t&&r.Rewards&&(this.ctx.data.user.applyResourceOperation(r.Rewards,this.ctx.data.config.itemDefinitions),t=true);}}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var zd="Leaderboard",_i=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(zd,t.data),this.ctx.emitter.emit("leaderboard:definitionsLoaded",t.data)),t}async getLeaderboard(e){if(!e)return n("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardID=e;let i=await this.ctx.api.leaderboard.getLeaderboard(t);return i.ok&&this.ctx.emitter.emit("leaderboard:loaded",i.data),i}async getMyProgress(e){if(!e)return n("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardID=e;let i=await this.ctx.api.leaderboard.getMyProgress(t);return i.ok&&(this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(e),i.data),this.ctx.emitter.emit("leaderboard:myProgressLoaded",i.data)),i}async submitScore(e,t){if(!e)return n("client","LeaderboardID is required.");if(t<=0)return n("client","Score must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,Score:t},r=await this.ctx.api.leaderboard.submitScore(i);if(r.ok){let s=r.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),s.NewScore,t,s.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",s);}return r}async submitScoreFromSource(e,t,i,r,s=1){if(!e)return n("client","LeaderboardID is required.");if(!t)return n("client","SourceType is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,SourceType:t,Outcome:i,Params:r,RollMultiplier:s},p=await this.ctx.api.leaderboard.submitScoreFromSource(a);if(p.ok){let x=p.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),x.NewScore,x.NewScore,x.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",x);}return p}async claimCycleReward(e){if(!e)return n("client","LeaderboardID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e},i=await this.ctx.api.leaderboard.claimCycleReward(t);if(i.ok){let r=i.data;this.ctx.data.user.patchLeaderboardCycleRewardClaimed(this.cycleDocID(e)),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("leaderboard:cycleRewardClaimed",r);}return i}async claimMilestone(e,t){if(!e||!t)return n("client","LeaderboardID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,MilestoneID:t},r=await this.ctx.api.leaderboard.claimMilestone(i);if(r.ok){let s=r.data;this.ctx.data.user.patchLeaderboardMilestoneClaimed(this.cycleDocID(e),t),this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("leaderboard:milestoneClaimed",s);}return r}async getFriendsLeaderboard(e){if(!e)return n("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardID=e;let i=await this.ctx.api.leaderboard.getFriendsLeaderboard(t);return i.ok&&this.ctx.emitter.emit("leaderboard:friendsLoaded",i.data),i}async getLeaderboardsBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardIDs=e;let i=await this.ctx.api.leaderboard.getLeaderboardsBatch(t);return i.ok&&this.ctx.emitter.emit("leaderboard:loadedBatch",i.data),i}async getProgressBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardIDs=e;let i=await this.ctx.api.leaderboard.getProgressBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(r.Data.LeaderboardID),r.Data);this.ctx.emitter.emit("leaderboard:myProgressLoadedBatch",i.data);}return i}async claimCycleRewardsBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardIDs:e},i=await this.ctx.api.leaderboard.claimCycleRewardsBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||(this.ctx.data.user.patchLeaderboardCycleRewardClaimed(this.cycleDocID(r.Data.LeaderboardID)),r.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.Data.Resources,this.ctx.data.config.itemDefinitions));this.ctx.emitter.emit("leaderboard:cycleRewardsClaimedBatch",i.data);}return i}async claimMilestonesBatch(e){if(!e||e.length===0)return n("client","milestones is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Milestones:e},i=await this.ctx.api.leaderboard.claimMilestonesBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||(this.ctx.data.user.patchLeaderboardMilestoneClaimed(this.cycleDocID(r.Data.LeaderboardID),r.Data.MilestoneID),r.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.Data.Resources,this.ctx.data.config.itemDefinitions));this.ctx.emitter.emit("leaderboard:milestonesClaimedBatch",i.data);}return i}async submitScoresBatch(e){if(!e||e.length===0)return n("client","scores is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Scores:e},i=await this.ctx.api.leaderboard.submitScoresBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(r.Data.LeaderboardID),r.Data.NewScore,r.Data.NewScore,r.Data.CycleVersion);this.ctx.emitter.emit("leaderboard:scoresSubmittedBatch",i.data);}return i}async claimAllRewardsBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardIDs:e},i=await this.ctx.api.leaderboard.claimAllRewardsBatch(t);if(i.ok){for(let r of i.data){let s=this.cycleDocID(r.LeaderboardID);r.CycleReward?.Success&&r.CycleReward.Data&&(this.ctx.data.user.patchLeaderboardCycleRewardClaimed(s),r.CycleReward.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.CycleReward.Data.Resources,this.ctx.data.config.itemDefinitions));for(let a of r.Milestones??[])!a.Success||!a.Data||(this.ctx.data.user.patchLeaderboardMilestoneClaimed(s,a.Data.MilestoneID),a.Data.Resources&&this.ctx.data.user.applyResourceOperation(a.Data.Resources,this.ctx.data.config.itemDefinitions));}this.ctx.emitter.emit("leaderboard:allRewardsClaimedBatch",i.data);}return i}async getOverviewBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardIDs=e;let i=await this.ctx.api.leaderboard.getOverviewBatch(t);if(i.ok){for(let r of i.data)r.Progress?.Success&&r.Progress.Data&&this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(r.LeaderboardID),r.Progress.Data);this.ctx.emitter.emit("leaderboard:overviewLoadedBatch",i.data);}return i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Pd="Season",Wi=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.season.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Pd,t.data),this.ctx.emitter.emit("season:definitionsLoaded",t.data)),t}async getActiveSeason(e){if(!e)return n("client","SeasonChainID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.SeasonChainID=e;let i=await this.ctx.api.season.getActiveSeason(t);return i.ok&&(i.data.UserState&&this.ctx.data.user.patchSeasonState(e,i.data.UserState),this.ctx.emitter.emit("season:activeLoaded",i.data)),i}async getUserState(e){if(!e)return n("client","SeasonChainID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.SeasonChainID=e;let i=await this.ctx.api.season.getUserState(t);return i.ok&&(this.ctx.data.user.patchSeasonState(e,i.data),this.ctx.emitter.emit("season:userStateLoaded",i.data)),i}async grantStatusTokens(e,t){if(!e)return n("client","SeasonChainID is required.");if(t<=0)return n("client","Amount must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,Amount:t,RelatedEntityID:`season_grant_${e}_${M()}`},r=await this.ctx.api.season.grantStatusTokens(i);return r.ok&&(this.ctx.data.user.patchSeasonCurrentTier(e,r.data.NewTier),this.ctx.emitter.emit("season:statusTokensGranted",r.data)),r}async claimTierReward(e,t){if(!e)return n("client","SeasonChainID is required.");if(t<=0)return n("client","TierNumber must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,TierNumber:t,RelatedEntityID:`season_tier_${e}_t${t}_${M()}`},r=await this.ctx.api.season.claimTierReward(i);if(r.ok){let s=r.data;this.ctx.data.user.patchSeasonClaimedTier(e,t),this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("season:tierRewardClaimed",s);}return r}async claimTierRewardsBatch(e,t){if(!e)return n("client","SeasonChainID is required.");let i=(t??[]).filter(a=>a>0);if(i.length===0)return n("client","TierNumbers is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,TierNumbers:i,RelatedEntityID:`season_tier_batch_${e}_${M()}`},s=await this.ctx.api.season.claimTierRewardsBatch(r);if(s.ok){let a=s.data;for(let p of a.Items??[]){let x=p.Data?.TierNumber;p.Success&&typeof x=="number"&&this.ctx.data.user.patchSeasonClaimedTier(e,x);}this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("season:tierRewardsBatchClaimed",a);}return s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var vd="Premium",Qi=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(vd,t.data.Premium),this.ctx.emitter.emit("premium:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.premium.getUserState(e);return t.ok&&t.data.Premium&&(this.ctx.data.user.applyPremium(t.data.Premium),this.ctx.emitter.emit("premium:stateLoaded",t.data)),t}async activateTrial(e,t){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,RelatedEntityID:`premium_trial_${e}_${t}`},r=await this.ctx.api.premium.activateTrial(i);return r.ok&&(r.data.Premium&&this.ctx.data.user.applyPremium(r.data.Premium),this.ctx.emitter.emit("premium:trialActivated",r.data)),r}async purchaseItemOrCurrency(e,t,i="Default",r=1){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,SelectedOptionID:i,Count:r,RelatedEntityID:`premium_purchase_${e}_${t}`},a=await this.ctx.api.premium.purchaseItemOrCurrency(s);if(a.ok){let p=a.data;p.Premium&&this.ctx.data.user.applyPremium(p.Premium),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:purchaseCompleted",p);}return a}async purchaseRealMoney(e,t,i,r,s,a,p,x){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!r||!s)return n("client","ProductID and ReceiptData are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let k={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,Store:i,ProductID:r,ReceiptData:s,PurchaseToken:a,PackageName:p,AppStoreEnvironment:x,RelatedEntityID:`premium_iap_${e}_${t}`},N=await this.ctx.api.premium.purchaseRealMoney(k);if(N.ok){let ge=N.data;ge.Premium&&this.ctx.data.user.applyPremium(ge.Premium),this.ctx.data.user.applyResourceOperation(ge.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:realMoneyPurchaseCompleted",ge);}return N}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Td="Character",Ki=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(Td,t.data),this.ctx.emitter.emit("character:definitionsLoaded",t.data)),t}async getUserCharacters(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.character.getUserCharacters(e);if(t.ok){let i=t.data.Characters??{};this.ctx.data.user.applyCharacter(i),this.ctx.emitter.emit("character:userCharactersLoaded",i);}return t}async unlockCharacter(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,SelectedOptionID:t?.selectedOptionID,Payment:t?.payment,RelatedEntityID:`unlock_char_${e}_${M()}`},r=await this.ctx.api.character.unlockCharacter(i);if(r.ok){let s=r.data;this.ctx.data.user.patchCharacter(s.CharacterID,a=>{a.StatLevels??={},a.Equipment??={},s.Power!=null&&(a.Power=s.Power),a.UpdatedAt=s.ServerTimeUtc;}),this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:unlocked",s);}return r}async upgradeStatLevel(e,t,i){if(!e||!t)return n("client","CharacterID and StatID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,StatID:t,RelatedEntityID:`upgrade_stat_${e}_${t}_${M()}`,...i?.levels!=null?{Levels:i.levels}:{},...i?.targetLevel!=null?{TargetLevel:i.targetLevel}:{}},s=await this.ctx.api.character.upgradeStatLevel(r);if(s.ok){let a=s.data;this.ctx.data.user.patchCharacter(a.CharacterID,p=>{p.StatLevels??={},p.StatLevels[a.StatID]=a.StatLevel,a.Power!=null&&(p.Power=a.Power),p.UpdatedAt=a.ServerTimeUtc;}),this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:statLevelUpgraded",a);}return s}async upgradeCharacterLevel(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,RelatedEntityID:`upgrade_char_${e}_${M()}`,...t?.levels!=null?{Levels:t.levels}:{},...t?.targetLevel!=null?{TargetLevel:t.targetLevel}:{}},r=await this.ctx.api.character.upgradeCharacterLevel(i);if(r.ok){let s=r.data;this.ctx.data.user.patchCharacter(s.CharacterID,a=>{a.Level=s.NewLevel,s.Power!=null&&(a.Power=s.Power),a.UpdatedAt=s.ServerTimeUtc,s.NewLevel===1&&(a.StatLevels??={},a.Equipment??={});}),this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:levelUpgraded",s);}return r}async equipItems(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,ItemsToEquip:t},r=await this.ctx.api.character.equipItems(i);return r.ok&&(this.applyEquipChangesLocally(e,r.data),this.ctx.emitter.emit("character:itemsEquipped",r.data)),r}async unequipItems(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,UnequipSlotIDs:t},r=await this.ctx.api.character.unequipItems(i);if(r.ok){let s=r.data;this.applyUnequipChangesLocally(e,s),this.ctx.emitter.emit("character:itemsUnequipped",{characterID:e,slotIDs:s.ClearedSlotIDs??[],power:s.Power??null});}return r}async unequipAllCharacters(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.character.unequipAllCharacters(e);return t.ok&&(this.applyUnequipAllLocally(t.data),this.ctx.emitter.emit("character:allUnequipped",t.data)),t}async unlockCharactersBatch(e){if(!e||e.length===0)return n("client","characterIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),UnlockCharacterIDs:e},i=await this.ctx.api.character.unlockCharactersBatch(t);return i.ok&&(this.applyBatchResults(i.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,s=>{s.StatLevels??={},s.Equipment??={},r.Power!=null&&(s.Power=r.Power),s.UpdatedAt=r.ServerTimeUtc;});}),this.ctx.emitter.emit("character:charactersUnlocked",i.data)),i}async upgradeCharacterLevelsBatch(e){if(!e||e.length===0)return n("client","upgrades is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LevelUpgrades:e},i=await this.ctx.api.character.upgradeCharacterLevelsBatch(t);return i.ok&&(this.applyBatchResults(i.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,s=>{s.Level=r.NewLevel,r.Power!=null&&(s.Power=r.Power),s.UpdatedAt=r.ServerTimeUtc,r.NewLevel===1&&(s.StatLevels??={},s.Equipment??={});});}),this.ctx.emitter.emit("character:levelsUpgraded",i.data)),i}async upgradeStatLevelsBatch(e){if(!e||e.length===0)return n("client","upgrades is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),StatUpgrades:e},i=await this.ctx.api.character.upgradeStatLevelsBatch(t);return i.ok&&(this.applyBatchResults(i.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,s=>{s.StatLevels??={},s.StatLevels[r.StatID]=r.StatLevel,r.Power!=null&&(s.Power=r.Power),s.UpdatedAt=r.ServerTimeUtc;});}),this.ctx.emitter.emit("character:statLevelsUpgraded",i.data)),i}applyBatchResults(e,t){e.Resources&&this.ctx.data.user.applyResourceOperation(e.Resources,this.ctx.data.config.itemDefinitions);for(let i of e.Items??[])!i.Success||!i.Data||t(i.Data);}applyInventoryDelta(e){this.ctx.data.user.applyInventoryDelta(e);}applyEquipChangesLocally(e,t){let i=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let[r,s]of Object.entries(t.Equipment??{}))i.patchCharacterEquipment(e,r,s);i.patchCharacter(e,r=>{t.Power!=null&&(r.Power=t.Power),r.UpdatedAt=t.ServerTimeUtc;});}applyUnequipChangesLocally(e,t){let i=t.ClearedSlotIDs??[];if(i.length===0&&t.Power==null)return;let r=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let s of i)r.patchCharacterEquipment(e,s,null);r.patchCharacter(e,s=>{t.Power!=null&&(s.Power=t.Power),s.UpdatedAt=t.ServerTimeUtc;});}applyUnequipAllLocally(e){let t=this.ctx.data.user;this.applyInventoryDelta(e.Inventory);for(let[i,r]of Object.entries(e.Characters??{})){for(let s of r.ClearedSlotIDs??[])t.patchCharacterEquipment(i,s,null);t.patchCharacter(i,s=>{r.Power!=null&&(s.Power=r.Power),s.UpdatedAt=e.ServerTimeUtc;});}}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Id="Match",Hi=class{constructor(e){this.ctx=e;}ctx;async createMatch(e,t,i,r,s,a){let p=this.ctx.auth.context;if(!p)return n("unauthorized","Not logged in.");let x={...this.ctx.buildAuthedBaseRequest(),Entry:e,RuleID:t,CharacterID:i,BattleStrategy:r,TargetUserID:s,SelectedOptionID:a,RelatedEntityID:`pvp_create_${p.userID}_${M()}`},k=await this.ctx.api.match.createMatch(x);return k.ok&&(this.ctx.data.user.applyResourceOperation(k.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:created",k.data)),k}async updateMatch(e,t={}){if(!e)return n("client","MatchID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),MatchID:e,TargetUserID:t.targetUserID,ClearTargetUser:t.clearTargetUser,RuleID:t.ruleID,CharacterID:t.characterID,BattleStrategy:t.battleStrategy},r=await this.ctx.api.match.updateMatch(i);return r.ok&&this.ctx.emitter.emit("match:updated",r.data),r}async cancelMatch(e){if(!e)return n("client","MatchID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),MatchID:e},i=await this.ctx.api.match.cancelMatch(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:cancelled",i.data)),i}async instantBattle(e,t,i,r){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),MatchID:e,RuleID:t,CharacterID:i,BattleStrategy:r,RelatedEntityID:`pvp_battle_${e}_${M()}`},p=await this.ctx.api.match.instantBattle(a);if(p.ok){let x=p.data,k=this.ctx.data.config.itemDefinitions;if(x.Resources)this.ctx.data.user.applyResourceOperation(x.Resources,k);else if(x.ResourcesDual){let N=x.ResourcesDual;N.FromUserID===s.userID&&N.FromResult?this.ctx.data.user.applyResourceOperation(N.FromResult,k):N.ToUserID===s.userID&&N.ToResult&&this.ctx.data.user.applyResourceOperation(N.ToResult,k);}this.ctx.emitter.emit("match:instantBattleCompleted",x);}return p}async saveStrategy(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BattleStrategy:e},i=await this.ctx.api.match.saveStrategy(t);return i.ok&&(this.ctx.data.user.patchMatchStrategy(e),this.ctx.emitter.emit("match:strategySaved",e)),i}async getMyMatches(e=0,t=20,i){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.Statuses=i;let s=await this.ctx.api.match.getMyMatches(r);return s.ok&&this.ctx.emitter.emit("match:myMatchesLoaded",s.data),s}async getAvailableMatches(e=0,t=20,i=false){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.OnlyPublic=i;let s=await this.ctx.api.match.getAvailableMatches(r);return s.ok&&this.ctx.emitter.emit("match:availableMatchesLoaded",s.data),s}async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.match.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Id,t.data),this.ctx.emitter.emit("match:definitionsLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var kd="Craft",$i=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(kd,t.data.CraftDefinitions),this.ctx.emitter.emit("craft:definitionsLoaded",t.data.CraftDefinitions)),t}async craft(e,t,i=1,r){if(!e)return n("client","CraftID is required.");let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),CraftID:e,InputItemIDs:t,Count:i,SelectedOptionID:r,RelatedEntityID:`craft_${e}_${s.userID}_${M()}`},p=await this.ctx.api.craft.craft(a);return p.ok&&(this.ctx.data.user.applyResourceOperation(p.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("craft:completed",p.data)),p}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var wd="Collection",Zi=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(wd,t.data),this.ctx.emitter.emit("collection:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.collection.getUserState(e);return t.ok&&(this.ctx.data.user.applyCollection(t.data),this.ctx.emitter.emit("collection:userStateLoaded",t.data)),t}async openPack(e,t,i=1,r){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,PackTypeID:t,Count:i,SelectedOptionID:r?.selectedOptionID,Payment:r?.payment,RelatedEntityID:`open_pack_${e}_${t}_${s.userID}_${M()}`},p=await this.ctx.api.collection.openPack(a);return p.ok&&(this.ctx.data.user.applyResourceOperation(p.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:packOpened",p.data)),p}async openCollectionChest(e,t,i=1){let r=this.ctx.auth.context;if(!r)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectionChestID:t,Count:i,RelatedEntityID:`open_chest_${e}_${t}_${r.userID}_${M()}`},a=await this.ctx.api.collection.openCollectionChest(s);return a.ok&&(this.ctx.data.user.applyResourceOperation(a.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:chestOpened",a.data)),a}async useCollectibleJoker(e,t){let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:false,RelatedEntityID:`use_joker_${e}_${t}_${i.userID}_${M()}`},s=await this.ctx.api.collection.useCollectibleJoker(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:jokerUsed",s.data)),s}async claimSetReward(e,t){let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,SetID:t,RelatedEntityID:`claim_set_${e}_${t}_${i.userID}_${M()}`},s=await this.ctx.api.collection.claimSetReward(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:setRewardClaimed",s.data)),s}async claimSetRewardsBatch(e){if(!e||e.length===0)return n("client","sets is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Sets:e},i=await this.ctx.api.collection.claimSetRewardsBatch(t);if(i.ok){let r=false;for(let s of i.data)!r&&s.Success&&s.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("collection:setRewardsClaimedBatch",i.data);}return i}async claimGrandPrize(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,RelatedEntityID:`grand_prize_${e}_${t.userID}_${M()}`},r=await this.ctx.api.collection.claimGrandPrize(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:grandPrizeClaimed",r.data)),r}async sendTradeOffer(e,t,i,r,s,a=false){let p=this.ctx.auth.context;if(!p)return n("unauthorized","Not logged in.");let x={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:i,ReceiverUserID:r,RequestedCollectibleID:s,RequestedCollectibleIsSpecial:a,RelatedEntityID:`trade_send_${p.userID}_${r}_${M()}`},k=await this.ctx.api.collection.sendTradeOffer(x);return k.ok&&this.ctx.emitter.emit("collection:tradeOfferSent",k.data),k}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()}`},i=await this.ctx.api.collection.cancelTradeOffer(t);return i.ok&&this.ctx.emitter.emit("collection:tradeOfferCancelled",i.data),i}async acceptTradeOffer(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),OfferID:e,RelatedEntityID:`trade_accept_${e}_${M()}`},i=await this.ctx.api.collection.acceptTradeOffer(t);return i.ok&&this.ctx.emitter.emit("collection:tradeOfferAccepted",i.data),i}async declineTradeOffer(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),OfferID:e,RelatedEntityID:`trade_decline_${e}_${M()}`},i=await this.ctx.api.collection.declineTradeOffer(t);return i.ok&&this.ctx.emitter.emit("collection:tradeOfferDeclined",i.data),i}async getMyTradeOffers(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CollectionID=e;let i=await this.ctx.api.collection.getMyTradeOffers(t);return i.ok&&this.ctx.emitter.emit("collection:myTradeOffersLoaded",i.data),i}async getIncomingTradeOffers(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CollectionID=e;let i=await this.ctx.api.collection.getIncomingTradeOffers(t);return i.ok&&this.ctx.emitter.emit("collection:incomingTradeOffersLoaded",i.data),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Md="CoopEvent",Ji=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(Md,t.data),this.ctx.emitter.emit("coopEvent:definitionsLoaded",t.data)),t}async getActiveEvent(e){if(!e)return n("client","CoopChainID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CoopChainID=e;let i=await this.ctx.api.coopEvent.getActiveEvent(t);return i.ok&&this.ctx.emitter.emit("coopEvent:activeEventLoaded",i.data),i}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.coopEvent.getUserState(e);return t.ok&&(this.ctx.data.user.applyCoopEvent(t.data.UserState??null),this.ctx.emitter.emit("coopEvent:userStateLoaded",t.data)),t}async getGroupState(e){if(!e)return n("client","GroupID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.GroupID=e;let i=await this.ctx.api.coopEvent.getGroupState(t);return i.ok&&this.ctx.emitter.emit("coopEvent:groupStateLoaded",i.data),i}async joinOrCreateGroup(e){if(!e)return n("client","CoopChainID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),CoopChainID:e},i=await this.ctx.api.coopEvent.joinOrCreateGroup(t);if(i.ok){let r=i.data.Group;r&&this.ctx.data.user.patchCoopEventActiveGroup(r.GroupID??null,r.CoopEventID??null,-1),this.ctx.emitter.emit("coopEvent:groupJoined",i.data);}return i}async spin(e,t,i=1,r){if(!e||!t)return n("client","CoopChainID and GroupID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CoopChainID:e,GroupID:t,Count:i,SelectedOptionID:r,RelatedEntityID:M()},a=await this.ctx.api.coopEvent.spin(s);return a.ok&&(this.ctx.data.user.applyResourceOperation(a.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("coopEvent:spinCompleted",a.data)),a}async claimObjectReward(e){if(!e)return n("client","GroupID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.coopEvent.claimObjectReward(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("coopEvent:objectRewardClaimed",i.data)),i}async claimGrandPrize(e){if(!e)return n("client","GroupID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.coopEvent.claimGrandPrize(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:grandPrizeClaimed",i.data)),i}async leaveGroup(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.coopEvent.leaveGroup(t);return i.ok&&(this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:groupLeft",i.data)),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ad="DealOffer",Yi=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(Ad,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()}`},i=await this.ctx.api.dealOffer.dismissDeal(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:dealDismissed",i.data)),i}async executeNode(e,t,i,r){if(!e||!t)return n("client","SlotID and NodeID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s=i&&i.trim().length>0?i.trim():void 0,a={...this.ctx.buildAuthedBaseRequest(),SlotID:e,NodeID:t,SelectedOptionID:r?.selectedOptionID,Payment:r?.payment,RelatedEntityID:s??`deal_exec_${e}_${t}_${M()}`},p=await this.ctx.api.dealOffer.executeNode(a);return p.ok&&(p.data.Idempotent||this.ctx.data.user.applyResourceOperation(p.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:nodeExecuted",p.data)),p}async recordShow(e){if(!e)return n("client","SlotID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),SlotID:e,RelatedEntityID:`deal_show_${e}_${M()}`},i=await this.ctx.api.dealOffer.recordShow(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:showRecorded",i.data)),i}async claimMilestone(e,t){if(!e||!t)return n("client","SlotID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneID:t,RelatedEntityID:`deal_milestone_${e}_${t}_${M()}`},r=await this.ctx.api.dealOffer.claimMilestone(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:milestoneClaimed",r.data)),r}async claimMilestonesBatch(e,t){if(!e)return n("client","SlotID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i=[...new Set(t.map(a=>a.trim()).filter(a=>a.length>0))],r={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneIDs:i,RelatedEntityID:`deal_milestone_batch_${e}_${M()}`},s=await this.ctx.api.dealOffer.claimMilestonesBatch(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:milestonesBatchClaimed",s.data)),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Od="Referral",Xi=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.referral.getDefinitions(e);return t.ok&&t.data.ReferralDefinitions&&(this.ctx.data.config.patchSection(Od,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=bt.parseReferralCode(e)?.toUpperCase();if(!t)return n("client","ReferralCode is required.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),ReferralCode:t,RelatedEntityID:`referral_activation_${i.userID}`},s=await this.ctx.api.referral.activateReferralCode(r);if(s.ok){let a=s.data;a.ReferrerUserID&&this.ctx.data.user.patchReferralSubscription(a.ReferrerUserID),this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:codeActivated",a);}return s}async claimInviteReward(e){let t=e.trim();if(!t)return n("client","InviteRewardID is required.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),InviteRewardID:t,RelatedEntityID:`referral_invite_${t}_${i.userID}`},s=await this.ctx.api.referral.claimInviteReward(r);if(s.ok){let a=s.data;a.RewardID&&this.ctx.data.user.patchReferralInviteRewardClaimed(a.RewardID),this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:inviteRewardClaimed",a);}return s}async claimInviteRewardsBatch(e){let t=(e??[]).map(a=>a?.trim()).filter(Boolean);if(t.length===0)return n("client","InviteRewardIDs is required.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),InviteRewardIDs:t,RelatedEntityID:`referral_invite_batch_${t.join("_")}_${i.userID}`},s=await this.ctx.api.referral.claimInviteRewardsBatch(r);if(s.ok){let a=s.data;for(let p of a.Items??[])p.Success&&p.Id&&this.ctx.data.user.patchReferralInviteRewardClaimed(p.Id);this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:inviteRewardsBatchClaimed",a);}return s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var er=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 getOutgoingRequests(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getOutgoingRequests(e);return t.ok&&(this.ctx.data.user.applySocialOutgoingRequests(t.data.Friends),this.ctx.emitter.emit("social:outgoingRequestsLoaded",t.data)),t}async getRecommendedFriends(e=5){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Limit=e;let i=await this.ctx.api.social.getRecommendedFriends(t);return i.ok&&this.ctx.emitter.emit("social:recommendedFriendsLoaded",i.data),i}async sendFriendRequest(e){if(!e)return n("client","TargetUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.sendFriendRequest(t);return i.ok&&(this.ctx.data.user.patchSocialAddOutgoingRequest(e),this.ctx.emitter.emit("social:friendRequestSent",i.data)),i}async acceptFriendRequest(e){if(!e)return n("client","RequesterUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.acceptFriendRequest(t);return i.ok&&(this.ctx.data.user.patchSocialAcceptFriend(e),this.ctx.emitter.emit("social:friendRequestAccepted",i.data)),i}async declineFriendRequest(e){if(!e)return n("client","RequesterUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.declineFriendRequest(t);return i.ok&&(this.ctx.data.user.patchSocialRemoveIncomingRequest(e),this.ctx.emitter.emit("social:friendRequestDeclined",i.data)),i}async removeFriend(e){if(!e)return n("client","FriendUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.removeFriend(t);return i.ok&&(this.ctx.data.user.patchSocialRemoveFriend(e),this.ctx.emitter.emit("social:friendRemoved",i.data)),i}async getTimeline(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getTimeline(e);return t.ok&&(this.ctx.data.user.applySocialTimeline(t.data.Events),this.ctx.emitter.emit("social:timelineLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ud="TimedBoost";function Bd(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var tr=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(Ud,t.data),this.ctx.emitter.emit("timedBoost:definitionsLoaded",t.data)),t}async getActive(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.getActive(e);return t.ok&&(this.ctx.data.user.applyTimedBoost({Active:t.data.Active??{}}),this.ctx.emitter.emit("timedBoost:activeLoaded",t.data)),t}async getActiveWindows(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.getActiveWindows(e);return t.ok&&this.ctx.emitter.emit("timedBoost:activeWindowsLoaded",t.data),t}async activate(e,t){let i=e.trim();if(!Bd(i))return n("client",'BoostID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),BoostID:i,SelectedOptionID:t?.selectedOptionID,Payment:t?.payment,RelatedEntityID:`timed_boost_activate_${i}_${M()}`},s=await this.ctx.api.timedBoost.activate(r);if(s.ok){let a=s.data;if(a.ActivatedBoost){let p=a.StackingPolicy??"Replace";this.ctx.data.user.patchActiveTimedBoost(a.ActivatedBoost,p);}this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedBoost:activated",a);}return s}async cleanupExpired(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.cleanupExpired(e);return t.ok&&(await this.getActive(),this.ctx.emitter.emit("timedBoost:expiredCleaned",void 0)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var ct={Private:"Private",Public:"Public",ReadOnly:"ReadOnly",Internal:"Internal"},Ld={Client:"Client",Server:"Server",System:"System"},qd=zod.z.enum(["Client","Server","System"]).catch("Client"),Ed=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:u.nullish(),Version:zod.z.number().nullish(),LastWriter:qd.nullish(),ExpiresAt:u.nullish()}).passthrough(),ir=zod.z.record(zod.z.string(),Ed),Qo=zod.z.object({Version:zod.z.number().nullish(),Private:ir.nullish(),Public:ir.nullish(),ReadOnly:ir.nullish()}),Ws=zod.z.object({UserID:zod.z.string().nullish(),Version:zod.z.number().nullish(),Public:ir.nullish()}),Qs=zod.z.object({ServerTimeUtc:u.nullish(),Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:u.nullish()}),Gd=zod.z.object({Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:u.nullish()}),Ko=zod.z.object({ServerTimeUtc:u.nullish(),Results:zod.z.array(Gd).nullish()}),Ho=zod.z.object({ServerTimeUtc:u.nullish(),DeletedCount:zod.z.number().nullish()}),$o=zod.z.object({Results:zod.z.array(Ws).nullish(),NotFoundUserIDs:zod.z.array(zod.z.string()).nullish()}),Nd={String:"String",Int:"Int",Bool:"Bool",Json:"Json"},jd=zod.z.enum(["String","Int","Bool","Json"]).catch("String"),Fd=zod.z.object({KeyID:zod.z.string(),Bucket:zod.z.string().nullish(),ValueType:jd.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),rr=zod.z.object({Keys:zod.z.record(zod.z.string(),Fd).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(),Je={GetUserCustomDataDefinitions:"GetUserCustomDataDefinitions",GetMyUserCustomData:"GetMyUserCustomData",GetPublicUserCustomDataOf:"GetPublicUserCustomDataOf",SetPrivateData:"SetPrivateData",SetPublicData:"SetPublicData",DeleteKey:"DeleteKey",BatchSet:"BatchSet",BatchDelete:"BatchDelete",BatchGetPublicUserCustomDataOf:"BatchGetPublicUserCustomDataOf"};var Vd="UserCustomData";function Zo(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var sr=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(Vd,t.data),this.ctx.emitter.emit("userCustomData:definitionsLoaded",t.data)),t}async getMyUserCustomData(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.userCustomData.getMyUserCustomData(e);return t.ok&&(this.ctx.data.user.applyUserCustomData(t.data),this.ctx.emitter.emit("userCustomData:myDataLoaded",t.data)),t}async getPublicUserCustomDataOf(e){let t=e.trim();if(!t)return n("client","TargetUserID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.TargetUserID=t;let r=await this.ctx.api.userCustomData.getPublicUserCustomDataOf(i);return r.ok&&this.ctx.emitter.emit("userCustomData:publicDataLoaded",r.data),r}async setPrivateData(e,t){return this.setData(e,t,ct.Private)}async setPublicData(e,t){return this.setData(e,t,ct.Public)}async setData(e,t,i){let r=e.trim();if(!Zo(r))return n("client",'KeyID is required and must not contain "." or "$".');if(t==null)return n("client","Value is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),KeyID:r,Value:t},p=await(i===ct.Private?this.ctx.api.userCustomData.setPrivateData(s):this.ctx.api.userCustomData.setPublicData(s));if(p.ok){let x=p.data;this.ctx.data.user.patchUserCustomDataKey(i,x.KeyID,t,x.Version??0,x.ExpiresAt),this.ctx.emitter.emit(i===ct.Private?"userCustomData:privateDataSet":"userCustomData:publicDataSet",x);}return p}async deleteKey(e,t){let i=e.trim();if(!Zo(i))return n("client",'KeyID is required and must not contain "." or "$".');if(t!==ct.Private&&t!==ct.Public)return n("client","Only Private or Public keys can be deleted.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),KeyID:i,Bucket:t},s=await this.ctx.api.userCustomData.deleteKey(r);return s.ok&&(this.ctx.data.user.removeUserCustomDataKey(t,i),this.ctx.emitter.emit("userCustomData:keyDeleted",void 0)),s}async batchSet(e){if(!e.length)return n("client","At least one item is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BatchSetItems:e},i=await this.ctx.api.userCustomData.batchSet(t);if(i.ok){for(let r of i.data.Results??[]){let s=r.Bucket??ct.Private,a=e.find(p=>p.Bucket===s&&p.KeyID===r.KeyID);a&&this.ctx.data.user.patchUserCustomDataKey(s,r.KeyID,a.Value,r.Version??0,r.ExpiresAt);}this.ctx.emitter.emit("userCustomData:batchSet",i.data);}return i}async batchDelete(e){if(!e.length)return n("client","At least one item is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BatchDeleteItems:e},i=await this.ctx.api.userCustomData.batchDelete(t);if(i.ok){for(let r of e)this.ctx.data.user.removeUserCustomDataKey(r.Bucket,r.KeyID.trim());this.ctx.emitter.emit("userCustomData:batchDeleted",i.data);}return i}async batchGetPublicUserCustomDataOf(e){if(!e.length)return n("client","At least one target user id is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.TargetUserIDs=e;let i=await this.ctx.api.userCustomData.batchGetPublicUserCustomDataOf(t);return i.ok&&this.ctx.emitter.emit("userCustomData:batchPublicDataLoaded",i.data),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var _d="TitleCustomDataDefinitions",Jo=50;function Wd(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}function Ks(o){if(o.ExpiresAt==null)return false;let e=Date.parse(o.ExpiresAt);return !Number.isNaN(e)&&e<=Date.now()}function Qd(o){let e={};for(let[t,i]of Object.entries(o))Ks(i)||(e[t]=i);return e}var nr=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(_d,t.data),this.ctx.emitter.emit("titleCustomData:definitionsLoaded",t.data)),t}async getPublicTitleData(e=true){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&this.lastRuntimeVersion!=null&&(t.KnownRuntimeVersion=this.lastRuntimeVersion);let i=await this.ctx.api.titleCustomData.getPublicTitleData(t);return i.ok&&this.absorb(i.data),i}async getPublicTitleDataKeys(e){let t=e.map(s=>s.trim()).filter(s=>s.length>0);if(!t.length)return n("client","At least one KeyID is required.");if(t.some(s=>!Wd(s)))return n("client",'KeyID must not contain "." or "$".');if(t.length>Jo)return n("client",`At most ${Jo} keys per call \u2014 request them in chunks.`);let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.KeyIDs=t;let r=await this.ctx.api.titleCustomData.getPublicTitleDataKeys(i);return r.ok&&this.ctx.emitter.emit("titleCustomData:publicDataLoaded",r.data),r}getValue(e){let t=this.runtimeCache[e];if(t?.Value!=null&&!Ks(t))return t.Value;let i=this.staticCache[e];if(i?.Value!=null&&!Ks(i))return i.Value}get runtimeVersion(){return this.lastRuntimeVersion}staticCache={};absorb(e){e.Static&&(this.staticCache=e.Static),e.NotModified?(this.runtimeCache=Qd(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 or=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 Kd=15,Hd="GameLoop",$d="BoardDefinition",ar=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(Hd,t.data),this.ctx.emitter.emit("gameLoop:gameLoopsLoaded",t.data)),t}async getBoardDefinition(e=false){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");let i=await this.ctx.api.gameLoop.getBoardDefinition(t,e);return i.ok&&(this.ctx.data.config.patchSection($d,i.data),this.ctx.emitter.emit("gameLoop:boardDefinitionLoaded",i.data)),i}async getBoardDefinitionForLevel(e,t=false){if(e<=0)return n("client","stageLevel must be > 0.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.StageLevel=e;let r=await this.ctx.api.gameLoop.getBoardDefinitionForLevel(i,t);return r.ok&&this.ctx.emitter.emit("gameLoop:boardDefinitionForLevelLoaded",r.data),r}async getUserBoardState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.gameLoop.getUserBoardState(e);return t.ok&&(this.ctx.data.user.applyBoardState(t.data),this.ctx.emitter.emit("gameLoop:boardStateLoaded",t.data)),t}async boardLoopRoll(e=1){if(e<1)return n("client","rollMultiplier must be >= 1.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),RollMultiplier:e,RelatedEntityID:`roll_${t.userID}_${M()}`},r=await this.ctx.api.gameLoop.boardLoopRoll(i);if(r.ok){let s=r.data,a=Bo(new Date,Kd);this.ctx.data.user.patchBoardState(p=>{p.Position=s.NewPosition,p.CyclesCompleted=(p.CyclesCompleted??0)+(s.CyclesCompletedDelta??0),p.LastRollAtUtc=new Date().toISOString(),s.ActionRequired&&s.ActionData?p.Pending={Type:s.ActionRequired,TargetUserID:s.ActionData.TargetUserID,TargetPublicData:s.ActionData.PublicData,TargetBuildingStates:s.ActionData.TargetBuildingStates??void 0,TargetHasShield:s.ActionData.TargetHasShield??void 0,RollMultiplier:s.UsedMultiplier??1,ExpiresAtUtc:a}:s.SpecialModeOffer&&(p.Pending={Type:"SPECIAL",RollMultiplier:s.UsedMultiplier??1,ExpiresAtUtc:a,Special:{ModeID:s.SpecialModeOffer.ModeID??void 0,Choices:s.SpecialModeOffer.Choices??void 0}});}),s.Operation&&this.ctx.data.user.applyResourceOperation(s.Operation,this.itemDefs),s.ActionRequired==="RAID"&&await this.getUserBoardState(),this.ctx.emitter.emit("gameLoop:boardRolled",s);}return r}async boardLoopAttack(e=-1){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`attack_${t.userID}_${M()}`},r=await this.ctx.api.gameLoop.boardLoopAttack(i);if(r.ok){let s=r.data;this.ctx.data.user.clearBoardPending(),s.IsBotTarget&&s.Operation?this.ctx.data.user.applyResourceOperation(s.Operation,this.itemDefs):!s.IsBotTarget&&s.DualResult?.FromResult&&this.ctx.data.user.applyResourceOperation(s.DualResult.FromResult,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardAttacked",s);}else await this.getUserBoardState();return r}async boardLoopRaid(e,t){if(e<0||e>11)return n("client","digIndex must be between 0 and 11.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),DigIndex:e,RelatedEntityID:t??`raid_${i.userID}_${M()}`},s=await this.ctx.api.gameLoop.boardLoopRaid(r);if(s.ok){let a=s.data;a.Status==="CONTINUE"?this.ctx.data.user.patchBoardPendingRaidLayout(a.RaidLayout,a.OpenedIndex??-1):(this.ctx.data.user.clearBoardPending(),this.applyRaidResources(a)),this.ctx.emitter.emit("gameLoop:boardRaided",a);}else await this.getUserBoardState();return s}async boardLoopRaidFast(e){if(!e.length)return n("client","digIndices must not be empty.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),DigIndices:e,RelatedEntityID:`raidfast_${t.userID}_${M()}`},r=await this.ctx.api.gameLoop.boardLoopRaidFast(i);if(r.ok){let s=r.data;s.Status!=="CONTINUE"&&(this.ctx.data.user.clearBoardPending(),this.applyRaidResources(s)),this.ctx.emitter.emit("gameLoop:boardRaidedFast",s);}else await this.getUserBoardState();return r}async boardLoopBuild(e){if(e<0)return n("client","buildingIndex must be >= 0.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`build_${t.userID}_${e}_${M()}`},r=await this.ctx.api.gameLoop.boardLoopBuild(i);if(r.ok){let s=r.data;s.StageComplete?this.ctx.data.user.patchBoardState(a=>{a.StageLevel=(a.StageLevel??1)+1,a.Position=0,a.Pending=null,a.BuildingStates=null;}):this.ctx.data.user.patchBoardBuilding(s.BuiltIndex,a=>{s.NewLevel!=null&&(a.Level=s.NewLevel),a.IsDamaged=false,s.MaxLevelRewardClaimed&&(a.MaxLevelRewardClaimed=true);}),s.Operation&&this.ctx.data.user.applyResourceOperation(s.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardBuilt",s);}return r}async boardSpecialChoose(e,t){if(!e)return n("client","choiceID must not be empty.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),ChoiceID:e,SelectedOptionID:t,RelatedEntityID:`special_choose_${i.userID}_${M()}`},s=await this.ctx.api.gameLoop.boardSpecialChoose(r);if(s.ok){let a=s.data;a.Mode==="Instant"||a.Mode===0?this.ctx.data.user.clearBoardPending():this.ctx.data.user.patchBoardSpecialPending(x=>{x.ChoiceID=e,x.ChosenMode=a.Mode??"Timed",x.StartedAtUtc=a.StartedAtUtc??null,x.DurationSeconds=a.DurationSeconds??null,x.AdViewsUsed=0;}),a.Operation&&this.ctx.data.user.applyResourceOperation(a.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialChose",a);}return s}async boardSpecialApplyMultiplier(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:e??`special_ad_${t.userID}_${M()}`},r=await this.ctx.api.gameLoop.boardSpecialApplyMultiplier(i);if(r.ok){let s=r.data;this.ctx.data.user.patchBoardSpecialPending(a=>{a.AdViewsUsed=s.AdViewsUsed??0,a.AccumulatedMultiplier=s.AccumulatedMultiplier??0;}),this.ctx.emitter.emit("gameLoop:boardSpecialApplyMultiplier",s);}return r}async boardSpecialClaim(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:`special_claim_${t.userID}_${M()}`,...e&&Object.keys(e).length>0?{RunStats:e}:{}},r=await this.ctx.api.gameLoop.boardSpecialClaim(i);if(r.ok){let s=r.data;this.ctx.data.user.clearBoardPending(),s.Operation&&this.ctx.data.user.applyResourceOperation(s.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialClaimed",s);}return r}async getCommunityChestState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.gameLoop.getCommunityChestState(e);return t.ok&&(this.ctx.data.user.applyCommunityChestUserState(t.data.UserState??null),this.ctx.emitter.emit("gameLoop:communityChestStateLoaded",t.data)),t}async joinOrCreateCommunityChest(){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let e={...this.ctx.buildAuthedBaseRequest()},t=await this.ctx.api.gameLoop.joinOrCreateCommunityChest(e);if(t.ok){let i=t.data.Group;i?.GroupID&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:i.GroupID,ActiveRoundIndex:i.RoundIndex??void 0}),this.ctx.emitter.emit("gameLoop:communityChestJoined",t.data);}return t}async claimCommunityChestMilestone(e,t){if(!e)return n("client","milestoneID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),MilestoneID:e,GroupID:t},r=await this.ctx.api.gameLoop.claimCommunityChestMilestone(i);return r.ok&&(r.data.Resources&&this.ctx.data.user.applyResourceOperation(r.data.Resources,this.itemDefs),this.ctx.emitter.emit("gameLoop:communityChestMilestoneClaimed",r.data)),r}async claimCommunityChestGrandPrize(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.gameLoop.claimCommunityChestGrandPrize(t);return i.ok&&(i.data.Resources&&this.ctx.data.user.applyResourceOperation(i.data.Resources,this.itemDefs),this.ctx.emitter.emit("gameLoop:communityChestGrandPrizeClaimed",i.data)),i}async leaveCommunityChest(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.gameLoop.leaveCommunityChest(t);return i.ok&&(i.data.Success&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:void 0,ActiveRoundIndex:-1}),this.ctx.emitter.emit("gameLoop:communityChestLeft",i.data)),i}applyRaidResources(e){e.Operation?this.ctx.data.user.applyResourceOperation(e.Operation,this.itemDefs):e.DualResult?.FromResult&&this.ctx.data.user.applyResourceOperation(e.DualResult.FromResult,this.itemDefs);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var lr=class{constructor(e){this.ctx=e;}ctx;async execute(e,t,i,r){let s=e.trim();if(!s)return n("client","FunctionName is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),FunctionName:s,FunctionParameter:t,RevisionSelection:i,SpecificRevision:r},p=await this.ctx.api.cloudCode.execute(a);return p.ok&&this.ctx.emitter.emit("cloudCode:executed",p.data),p}};var Yo=zod.z.object({ServerTimeUtc:u,SourceType:qt,SourceID:zod.z.string(),TargetType:qt,TargetID:zod.z.string(),SourceSpent:B,FeeAmount:B,RateApplied:j,TargetCredited:B}),Xo=zod.z.object({ServerTimeUtc:u,SourceType:qt,SourceID:zod.z.string(),TargetType:qt,TargetID:zod.z.string(),SourceSpent:j,FeeAmount:j,RateApplied:j,TargetCredited:j}),ur={Convert:"Convert",CryptoConvert:"CryptoConvert"},Zd={Active:"Active",Hidden:"Hidden",Deprecated:"Deprecated",Maintenance:"Maintenance"},ea=zod.z.enum(["Active","Hidden","Deprecated","Maintenance"]).catch("Active"),Jd={Automatic:"Automatic",Manual:"Manual"},Yd=zod.z.enum(["Automatic","Manual"]).catch("Automatic"),Xd=zod.z.object({ValueInUSD:j.nullish(),ValueInUSDUpdatedAt:u.nullish(),InitialDeposit:zod.z.number().nullish(),MinBalance:zod.z.number().nullish(),MaxBalance:zod.z.number().nullish(),DailyEarnLimit:zod.z.number().nullish(),DailySpendLimit:zod.z.number().nullish()}).passthrough(),eh=zod.z.object({Rate:zod.z.number().nullish(),Max:zod.z.number().nullish(),Period:zod.z.number().nullish()}).passthrough(),th=zod.z.object({IsTradable:zod.z.boolean().nullish(),IsPurchasable:zod.z.boolean().nullish(),IsRefundable:zod.z.boolean().nullish()}).passthrough(),ih=zod.z.object({TargetCurrencyType:qt.nullish(),TargetCurrencyID:zod.z.string(),Rate:j.nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish(),DailyLimit:zod.z.number().nullish()}).passthrough(),ta=zod.z.object({Enabled:zod.z.boolean().nullish(),RateMode:Yd.nullish(),Fee:zod.z.number().nullish(),Targets:zod.z.array(ih).nullish()}).passthrough(),ia=zod.z.object({CreatedAt:u.nullish(),UpdatedAt:u.nullish()}).passthrough(),rh=zod.z.object({CurrencyID:zod.z.string(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Economy:Xd.nullish(),Recharge:eh.nullish(),Conversion:ta.nullish(),Permissions:th.nullish(),Audit:ia.nullish(),Status:ea.nullish()}).passthrough(),sh=zod.z.object({NetworkID:zod.z.string(),ContractAddress:zod.z.string().nullish(),Decimals:zod.z.number().nullish(),MinWithdraw:j.nullish(),DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish()}).passthrough(),nh=zod.z.object({DailyWithdrawUsd:j.nullish(),MonthlyWithdrawUsd:j.nullish(),KycRequiredAboveUsd:j.nullish()}).passthrough(),oh=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),SpendableInGame:zod.z.boolean().nullish(),ConvertibleToVirtual:zod.z.boolean().nullish()}).passthrough(),Hs=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:j.nullish(),ValueInUSDUpdatedAt:u.nullish(),DeveloperDepositSharePercent:j.nullish(),CommunityMarketingDepositSharePercent:j.nullish(),WithdrawalBurnPercent:j.nullish(),Networks:zod.z.array(sh).nullish(),Limits:nh.nullish(),Permissions:oh.nullish(),Conversion:ta.nullish(),Audit:ia.nullish(),Status:ea.nullish()}).passthrough(),cr=zod.z.object({VirtualCurrencies:zod.z.record(zod.z.string(),rh).nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Hs).nullish()}).passthrough();var ra=zod.z.object({OptionID:zod.z.string().nullish(),Name:zod.z.string().nullish(),Cost:lt.nullish(),AllowedPlatforms:zod.z.array(ci).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),ee=zod.z.record(zod.z.string(),ra),ah=zod.z.object({Store:pi,Receipt:zod.z.string(),Signature:zod.z.string().nullish()}).passthrough();var sa=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),ItemInstanceID:zod.z.string().nullish(),EquippedAt:u.nullish()}),$s=zod.z.object({CharacterID:zod.z.string(),Level:zod.z.number().nullish(),Experience:B.nullish(),Power:zod.z.number().nullish(),StatLevels:zod.z.record(zod.z.string(),zod.z.number()).nullish(),Equipment:zod.z.record(zod.z.string(),sa).nullish(),UpdatedAt:u.nullish()}).passthrough(),lh=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),uh=zod.z.object({ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Quantity:zod.z.number().nullish(),RemainingUses:zod.z.number().nullish(),Level:zod.z.number().nullish(),AcquiredAt:u,ExpiresAt:u.nullish(),EquippedSlot:lh.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(o=>o),yt=zod.z.object({ChangedInstances:zod.z.record(zod.z.string(),uh).nullish(),RemovedInstanceIDs:zod.z.array(zod.z.string()).nullish()}),na=zod.z.object({Characters:zod.z.record(zod.z.string(),$s).nullish()}),Zs=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),StatID:zod.z.string(),StatLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:v.nullish()}),Js=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),NewLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:v.nullish()}),oa=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),Equipment:zod.z.record(zod.z.string(),sa).nullish(),ReplacedInstanceIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:yt.nullish()}),aa=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:yt.nullish()}),ch=zod.z.object({ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish()}),la=zod.z.object({ServerTimeUtc:u,Characters:zod.z.record(zod.z.string(),ch).nullish(),Inventory:yt.nullish()}),Ys=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),Power:zod.z.number().nullish(),Resources:v.nullish()}),ua=rt(Ys),ca=rt(Js),pa=rt(Zs),da=zod.z.object({RequiredStatID:zod.z.string(),RequiredLevel:zod.z.number()}).passthrough(),ha=zod.z.object({StatID:zod.z.string(),TypeID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),MaxLevel:zod.z.number().nullish(),Weight:zod.z.number().nullish(),PriceOptions:ee.nullish(),CostCurve:Pe.nullish(),BaseStatValue:zod.z.number().nullish(),ValueCurve:Pe.nullish(),RankCurve:Pe.nullish(),Requirements:zod.z.array(da).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),ph=zod.z.object({SlotID:zod.z.string(),MinCharacterLevel:zod.z.number().nullish(),StatRequirements:zod.z.array(da).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(),ma=zod.z.object({Slots:zod.z.record(zod.z.string(),ph).nullish()}).passthrough(),dh=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(),hh=zod.z.object({ClassID:zod.z.string().nullish(),RarityID:zod.z.string().nullish(),Tags:zod.z.array(zod.z.string()).nullish()}).passthrough(),mh=zod.z.object({UnlockedByDefault:zod.z.boolean().nullish(),PriceOptions:ee.nullish()}).passthrough(),fh=zod.z.object({Stats:K.nullish(),Levels:K.nullish(),Equipment:K.nullish()}).passthrough(),fa=zod.z.object({MaxRank:zod.z.number().nullish(),FirstPaidRank:zod.z.number().nullish(),PriceOptions:ee.nullish(),CostCurve:Pe.nullish()}).passthrough(),gh=zod.z.object({CharacterID:zod.z.string(),Identity:dh.nullish(),Classification:hh.nullish(),Unlock:mh.nullish(),Presets:fh.nullish(),Equipment:ma.nullish(),Stats:zod.z.record(zod.z.string(),ha).nullish(),RankLadder:fa.nullish(),RankStatCurve:Pe.nullish(),StatMaxLevelCurve:Pe.nullish()}).passthrough(),yh=zod.z.object({Stats:zod.z.record(zod.z.string(),ha).nullish()}).passthrough(),Rh=zod.z.object({RankLadder:fa.nullish()}).passthrough(),Ch=zod.z.object({Equipment:ma.nullish()}).passthrough(),Sh=zod.z.object({Stats:zod.z.record(zod.z.string(),yh).nullish(),Levels:zod.z.record(zod.z.string(),Rh).nullish(),Equipment:zod.z.record(zod.z.string(),Ch).nullish()}).passthrough(),pr=zod.z.object({Definitions:zod.z.record(zod.z.string(),gh).nullish(),Presets:Sh.nullish()}).passthrough(),qe={GetCharacterDefinitions:"GetCharacterDefinitions",GetUserCharacters:"GetUserCharacters",UnlockCharacter:"UnlockCharacter",UpgradeStatLevel:"UpgradeStatLevel",UpgradeCharacterLevel:"UpgradeCharacterLevel",EquipItems:"EquipItems",UnequipItems:"UnequipItems",UnequipAllCharacters:"UnequipAllCharacters",UnlockCharactersBatch:"UnlockCharactersBatch",UpgradeCharacterLevelsBatch:"UpgradeCharacterLevelsBatch",UpgradeStatLevelsBatch:"UpgradeStatLevelsBatch"};var xh={EVM:"EVM",Solana:"Solana"},bh=zod.z.enum(["EVM","Solana"]).catch("EVM"),Dh={AutoLinkedFromTransaction:"AutoLinkedFromTransaction",SignatureVerified:"SignatureVerified",ManuallyLinked:"ManuallyLinked"},zh=zod.z.enum(["AutoLinkedFromTransaction","SignatureVerified","ManuallyLinked"]).catch("AutoLinkedFromTransaction"),Ph={Token:"Token",Nft:"Nft"},ga=zod.z.enum(["Token","Nft"]).catch("Token"),vh={NotRequested:"NotRequested",Pending:"Pending",Verified:"Verified",Rejected:"Rejected",Expired:"Expired"},Th=zod.z.enum(["NotRequested","Pending","Verified","Rejected","Expired"]).catch("NotRequested"),Ih={None:"None",Tier1:"Tier1",Tier2:"Tier2",Tier3:"Tier3"},kh=zod.z.enum(["None","Tier1","Tier2","Tier3"]).catch("None"),wh={Pending:"Pending",Completed:"Completed",Failed:"Failed",Expired:"Expired",Abandoned:"Abandoned"},Xs=zod.z.enum(["Pending","Completed","Failed","Expired","Abandoned"]).catch("Pending"),ya={GameTopUp:"game_topup",CommunityReward:"community_reward"};function dr(o){let e=o?.trim();return e||ya.GameTopUp}var Mh={UsersCryptoWallet:"UsersCryptoWallet",Game:"Game"},Ra=zod.z.enum(["UsersCryptoWallet","Game"]).catch("UsersCryptoWallet"),Ah=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(),Ca=zod.z.object({Ios:zod.z.boolean().nullish(),Android:zod.z.boolean().nullish(),Web:zod.z.boolean().nullish()}).passthrough(),Oh=zod.z.object({NetworkID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Type:bh.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:Ca.nullish(),NftCollections:zod.z.array(Ah).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Uh=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),NftDepositsEnabled:zod.z.boolean().nullish(),NftWithdrawalsEnabled:zod.z.boolean().nullish(),PlatformOverrides:Ca.nullish()}).passthrough(),Bh=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 Lh=zod.z.enum(["OnChain","Combined"]).catch("OnChain"),qh=zod.z.object({Enabled:zod.z.boolean().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),MinBalance:j.nullish(),BalanceSource:Lh.nullish(),DenyMessage:zod.z.string().nullish()}).passthrough(),Eh=zod.z.object({Enabled:zod.z.boolean().nullish(),TokenGates:zod.z.array(qh).nullish(),WalletConnectProjectId:zod.z.string().nullish()}).passthrough(),en=zod.z.object({SystemState:Uh.nullish(),Networks:zod.z.record(zod.z.string(),Oh).nullish(),AccountSafety:Bh.nullish(),WalletLogin:Eh.nullish()}).passthrough(),Gh=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),LinkedAt:u.nullish(),LastUsedAt:u.nullish(),LinkType:zh.nullish(),IsSignatureVerified:zod.z.boolean().nullish()}).passthrough(),Sa=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Type:ga.nullish(),NetworkID:zod.z.string().nullish(),AssetID:zod.z.string().nullish(),Amount:j.nullish(),CreatedAt:u.nullish(),ExpiresAt:u.nullish()}).passthrough(),Nh=zod.z.object({Status:Th.nullish(),Tier:kh.nullish(),VerifiedAt:u.nullish(),ExpiresAt:u.nullish(),RejectedAt:u.nullish(),ProviderReference:zod.z.string().nullish(),RejectionReason:zod.z.string().nullish()}).passthrough(),jh=zod.z.object({CurrencyID:zod.z.string().nullish(),Deposits:zod.z.number().nullish(),DepositsVolumeNative:j.nullish(),DepositsVolumeUsd:j.nullish(),Withdrawals:zod.z.number().nullish(),WithdrawalsVolumeNative:j.nullish(),WithdrawalsVolumeUsd:j.nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),FirstDepositAt:u.nullish(),LastDepositAt:u.nullish(),FirstWithdrawalAt:u.nullish(),LastWithdrawalAt:u.nullish()}).passthrough(),Fh=zod.z.object({TotalDeposits:zod.z.number().nullish(),TotalWithdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),TotalDepositsVolumeUsd:j.nullish(),TotalWithdrawalsVolumeUsd:j.nullish(),PerCurrency:zod.z.record(zod.z.string(),jh).nullish()}).passthrough(),Vh=zod.z.object({NetworkID:zod.z.string().nullish(),ItemCatalogID:zod.z.string().nullish(),Deposits:zod.z.number().nullish(),Withdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),FirstDepositAt:u.nullish(),LastDepositAt:u.nullish(),FirstWithdrawalAt:u.nullish(),LastWithdrawalAt:u.nullish()}).passthrough(),_h=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(),Vh).nullish()}).passthrough(),Wh=zod.z.object({Tokens:Fh.nullish(),Nfts:_h.nullish()}).passthrough(),Qh=zod.z.object({CurrencyID:zod.z.string().nullish(),Balance:j.nullish(),MinBalance:j.nullish()}).passthrough(),Kh=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),CheckedAt:u.nullish(),LoggedInAt:u.nullish(),GatePassed:zod.z.boolean().nullish(),GatedBalances:zod.z.array(Qh).nullish()}).passthrough(),Hh=zod.z.object({Version:zod.z.number().nullish(),Stats:Wh.nullish(),LinkedWallets:zod.z.record(zod.z.string(),Gh).nullish(),LastWalletLogin:Kh.nullish(),PendingWithdrawals:zod.z.array(Sa).nullish(),Kyc:Nh.nullish(),FirstActivityAt:u.nullish(),LastActivityAt:u.nullish(),IsFlagged:zod.z.boolean().nullish(),FlagReason:zod.z.string().nullish()}).passthrough(),$h=zod.z.object({CurrencyID:zod.z.string(),AmountDelta:j,FrozenDelta:j,UpdatedAt:u}).passthrough(),hr=zod.z.object({CryptoBalances:zod.z.record(zod.z.string(),$h).nullish(),PendingAdded:Sa.nullish(),PendingRemovedIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),Zh=zod.z.object({Amount:j,Frozen:j,CreatedAt:u.nullish(),UpdatedAt:u.nullish()}).passthrough().transform(o=>o),Jh=zod.z.object({ID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CreatedAt:u.nullish(),UpdatedAt:u.nullish(),UserID:zod.z.string().nullish(),TransactionHash:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ChainType:zod.z.string().nullish(),ChainID:zod.z.number().nullish(),Direction:Ra.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:j.nullish(),Status:Xs.nullish(),SignatureData:zod.z.string().nullish(),CompletedAt:u.nullish(),ExpiresAt:u.nullish(),FailReason:zod.z.string().nullish(),Reason:zod.z.string().nullish(),Category:zod.z.string().nullish(),TokenID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountUsd:j.nullish(),NetPayoutAmount:j.nullish()}).passthrough(),Yh=zod.z.object({ID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CreatedAt:u.nullish(),UpdatedAt:u.nullish(),UserID:zod.z.string().nullish(),TransactionHash:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ChainType:zod.z.string().nullish(),ChainID:zod.z.number().nullish(),Direction:Ra.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:j.nullish(),Status:Xs.nullish(),SignatureData:zod.z.string().nullish(),CompletedAt:u.nullish(),ExpiresAt:u.nullish(),FailReason:zod.z.string().nullish(),Reason:zod.z.string().nullish(),Category:zod.z.string().nullish(),NFTID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),SkinID:zod.z.string().nullish()}).passthrough(),xa=zod.z.object({To:zod.z.string().nullish(),Amount:zod.z.union([zod.z.string(),zod.z.number()]).nullish()}).passthrough(),tn=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(xa).nullish(),Signature:zod.z.string().nullish()}).passthrough(),rn=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(xa).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(),ba=zod.z.object({Blockchain:en.nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Hs).nullish()}).passthrough(),Da=zod.z.object({State:Hh.nullish(),CryptoBalances:zod.z.record(zod.z.string(),Zh).nullish()}).passthrough(),za=zod.z.object({ServerTimeUtc:u.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:j.nullish(),AmountUsd:j.nullish(),StateDelta:hr.nullish()}).passthrough(),Pa=zod.z.object({ServerTimeUtc:u.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),NftTokenID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),Resources:v.nullish(),Inventory:yt.nullish()}).passthrough(),va=zod.z.object({ServerTimeUtc:u.nullish(),TitleTransactionID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:j.nullish(),NetAmountNative:j.nullish(),BurnAmountNative:j.nullish(),AmountUsd:j.nullish(),ExpiresAt:u.nullish(),EvmSignature:tn.nullish(),SolanaSignature:rn.nullish(),StateDelta:hr.nullish()}).passthrough(),Ta=zod.z.object({ServerTimeUtc:u.nullish(),TitleTransactionID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),NftTokenID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),ExpiresAt:u.nullish(),Resources:v.nullish(),EvmSignature:tn.nullish(),SolanaSignature:rn.nullish(),StateDelta:hr.nullish(),Inventory:yt.nullish()}).passthrough(),Ia=zod.z.object({TokenTransactions:zod.z.array(Jh).nullish(),NFTTransactions:zod.z.array(Yh).nullish()}).passthrough(),sn=zod.z.object({ServerTimeUtc:u.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:j.nullish(),AmountUsd:j.nullish(),Target:zod.z.string().nullish()}).passthrough(),ka=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Kind:ga.nullish(),EvmSignature:tn.nullish(),SolanaSignature:rn.nullish()}).passthrough(),wa=zod.z.object({TitleTransactionID:zod.z.string().nullish(),OnChainTxHash:zod.z.string().nullish(),Status:Xs.nullish(),StateDelta:hr.nullish()}).passthrough(),Ee={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",DepositToken:"DepositToken",DepositNFT:"DepositNFT",RequestTokenWithdrawal:"RequestTokenWithdrawal",RequestNFTWithdrawal:"RequestNFTWithdrawal",GetTransactionHistory:"GetTransactionHistory",RetryWithdrawal:"RetryWithdrawal",ConfirmWithdrawal:"ConfirmWithdrawal",DonateToDeveloper:"DonateToDeveloper",DonateToUsersPool:"DonateToUsersPool"};var Xh="Blockchain",mr=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(Xh,t.data.Blockchain),this.ctx.emitter.emit("blockchain:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.blockchain.getUserState(e);return t.ok&&(this.ctx.data.user.applyBlockchainState(t.data.State??null,t.data.CryptoBalances),this.ctx.emitter.emit("blockchain:userStateLoaded",t.data)),t}async depositToken(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.NetworkID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.depositToken(i);return r.ok&&r.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(r.data.CurrencyID,new Ci__default.default(r.data.AmountNative??0),r.data.ServerTimeUtc??void 0),this.ctx.emitter.emit("blockchain:tokenDeposited",r.data)),r}async depositNFT(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.NetworkID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.depositNFT(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("blockchain:nftDeposited",r.data)),r}async requestTokenWithdrawal(e,t,i,r,s){if(!e)return n("client","CurrencyID is required.");if(!t)return n("client","NetworkID is required.");if(!i)return n("client","WalletAddress is required.");if(!r)return n("client","Amount is required.");let a=this.baseRequest();if(!a)return n("unauthorized","Not logged in.");a.CurrencyID=e,a.NetworkID=t,a.WalletAddress=i,a.Amount=r,a.Category=dr(s);let p=await this.ctx.api.blockchain.requestTokenWithdrawal(a);return p.ok&&p.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(p.data.CurrencyID,new Ci__default.default(p.data.AmountNative??0).negated(),p.data.ServerTimeUtc??void 0),this.ctx.emitter.emit("blockchain:tokenWithdrawalRequested",p.data)),p}async requestNFTWithdrawal(e,t,i,r,s,a,p){if(!e)return n("client","ItemID is required.");if(!t)return n("client","NetworkID is required.");if(!i)return n("client","WalletAddress is required.");if(!r)return n("client","Amount is required.");let x=this.baseRequest();if(!x)return n("unauthorized","Not logged in.");x.ItemID=e,x.NetworkID=t,x.WalletAddress=i,x.Amount=r,x.Category=dr(s),a!==void 0&&(x.Level=a),p&&(x.ItemInstanceID=p);let k=await this.ctx.api.blockchain.requestNFTWithdrawal(x);return k.ok&&(this.ctx.data.user.applyResourceOperation(k.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("blockchain:nftWithdrawalRequested",k.data)),k}async getTransactionHistory(e=50){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Amount=String(e);let i=await this.ctx.api.blockchain.getTransactionHistory(t);return i.ok&&this.ctx.emitter.emit("blockchain:transactionHistoryLoaded",i.data),i}async retryWithdrawal(e){if(!e)return n("client","TitleTransactionID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.TitleTransactionID=e;let i=await this.ctx.api.blockchain.retryWithdrawal(t);return i.ok&&this.ctx.emitter.emit("blockchain:withdrawalRetried",i.data),i}async confirmWithdrawal(e,t){if(!e)return n("client","TitleTransactionID is required.");if(!t)return n("client","On-chain TransactionHash is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.TitleTransactionID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.confirmWithdrawal(i);return r.ok&&this.ctx.emitter.emit("blockchain:withdrawalConfirmed",r.data),r}async donateToDeveloper(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.NetworkID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.donateToDeveloper(i);return r.ok&&this.ctx.emitter.emit("blockchain:donatedToDeveloper",r.data),r}async donateToUsersPool(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.NetworkID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.donateToUsersPool(i);return r.ok&&this.ctx.emitter.emit("blockchain:donatedToUsersPool",r.data),r}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Se=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 em={Head:"Head",Torso:"Torso",Legs:"Legs"},fr=zod.z.enum(["Head","Torso","Legs"]).catch("Head"),tm={Open:"Open",InProgress:"InProgress",Cancelled:"Cancelled",Completed:"Completed"},nn=zod.z.enum(["Open","InProgress","Cancelled","Completed"]).catch("Open"),Oa=zod.z.object({AttackTarget:fr,DefenseTarget:fr});var im=zod.z.enum(["Hit","Critical","Block","Dodge"]).catch("Hit"),rm=zod.z.object({RoundIndex:zod.z.number().nullish(),AttackerID:zod.z.string().nullish(),DefenderID:zod.z.string().nullish(),AttackZone:fr.nullish(),DefenseZone:fr.nullish(),HitType:im.nullish(),DamageDealt:zod.z.number().nullish(),DefenderHpRemaining:zod.z.number().nullish()}).passthrough(),sm=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(),nm=zod.z.object({ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Quantity:zod.z.number().nullish(),RemainingUses:zod.z.number().nullish(),Level:zod.z.number().nullish(),AcquiredAt:u,ExpiresAt:u.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(o=>o),Aa=zod.z.object({UserID:zod.z.string().nullish(),SelectedCharacterID:zod.z.string().nullish(),SelectedCharacter:$s.nullish(),BattleStrategy:zod.z.array(Oa).nullish(),UnstackableItems:zod.z.record(zod.z.string(),nm).nullish(),Stats:sm.nullish()}).passthrough(),om=zod.z.object({WinnerUserID:zod.z.string().nullish(),LoserUserID:zod.z.string().nullish(),Entry:Re.nullish(),NetReward:Re.nullish(),BattleLog:zod.z.array(rm).nullish(),IsDraw:zod.z.boolean().nullish(),P1BattleProfile:Aa.nullish(),P2BattleProfile:Aa.nullish()}).passthrough(),Ua=zod.z.object({MatchID:zod.z.string(),TitleID:zod.z.string().nullish(),RuleID:zod.z.string().nullish(),CreatedAt:u.nullish(),CreatorID:zod.z.string().nullish(),CreatorCharacterID:zod.z.string().nullish(),CreatorStrategy:zod.z.array(Oa).nullish(),TargetUserID:zod.z.string().nullish(),Entry:Re.nullish(),CreationCostPaid:Re.nullish(),RefundCreationCostOnCancel:zod.z.boolean().nullish(),JoinedByUserID:zod.z.string().nullish(),JoinedByCharacterID:zod.z.string().nullish(),JoinedAt:u.nullish(),Status:nn.nullish(),WinnerUserID:zod.z.string().nullish(),CompletedAt:u.nullish(),IsRewardDistributed:zod.z.boolean().nullish(),RewardDistributedAt:u.nullish()}).passthrough(),Ba=zod.z.object({Status:nn,MatchID:zod.z.string(),Entry:Re.nullish(),Resources:v.nullish()}),La=zod.z.object({Match:Ua.nullish()}),qa=zod.z.object({MatchID:zod.z.string(),Status:nn,Resources:v.nullish()}),Ea=zod.z.object({Battle:om.nullish(),Resources:v.nullish(),ResourcesDual:Dt.nullish()}),on=zod.z.object({Matches:zod.z.array(Ua).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}),nt={CreateMatch:"CreateMatch",UpdateMatch:"UpdateMatch",CancelMatch:"CancelMatch",InstantBattle:"InstantBattle",SaveStrategy:"SaveStrategy",GetMyMatches:"GetMyMatches",GetAvailableMatches:"GetAvailableMatches",GetDefinitions:"GetDefinitions"};var am=zod.z.enum(["VirtualCurrency","Item","EventToken"]).catch("VirtualCurrency");var lm=zod.z.enum(["Constant","Variable","Curve"]).catch("Constant"),um=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(),cm=zod.z.enum(["Flat","PercentReduction"]).catch("Flat"),pm=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(),ArmorMode:cm.nullish(),MaxArmorReduction:zod.z.number().nullish()}).passthrough(),dm=zod.z.object({Kind:lm.nullish(),Constant:zod.z.number().nullish(),VariableID:zod.z.string().nullish(),Argument:zod.z.string().nullish(),Curve:Pe.nullish(),OnePlus:zod.z.boolean().nullish()}).passthrough(),hm=zod.z.object({Coefficient:zod.z.number().nullish(),Factors:zod.z.array(dm).nullish()}).passthrough(),Pt=zod.z.object({Terms:zod.z.array(hm).nullish()}).passthrough(),mm=zod.z.object({Health:Pt.nullish(),Damage:Pt.nullish(),Armor:Pt.nullish(),AttackSpeed:Pt.nullish(),CritChance:Pt.nullish(),CritDamage:Pt.nullish(),Dodge:Pt.nullish()}).passthrough(),Ga=zod.z.object({StatMapping:um.nullish(),Combat:pm.nullish(),Formula:mm.nullish()}).passthrough(),fm=zod.z.object({BurnRate:zod.z.number().nullish()}).passthrough(),an=zod.z.object({Kind:am.nullish(),CurrencyID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),TokenType:di.nullish(),EntityID:zod.z.string().nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish()}).passthrough(),Na=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(an).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),ja=zod.z.object({PriceOptions:ee.nullish(),RefundCostOnCancel:zod.z.boolean().nullish(),MaxOpenMatches:zod.z.number().nullish(),Limits:ie.nullish(),AllowPrivateMatches:zod.z.boolean().nullish(),MaxMatchesPerOpponentPerDay:zod.z.number().nullish()}).passthrough(),gm=zod.z.object({RuleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Economy:fm.nullish(),Entry:Na.nullish(),Creation:ja.nullish(),Settings:Ga.nullish()}).passthrough(),ym=zod.z.object({Rules:zod.z.record(zod.z.string(),gm).nullish(),Defaults:Ga.nullish(),EntryDefaults:Na.nullish(),CreationDefaults:ja.nullish()}).passthrough(),ln=zod.z.object({InstantBattle:ym.nullish()}).passthrough(),Fa=ln;var Rm={Listing:"Listing",Auction:"Auction",BuyOrder:"BuyOrder",DirectTrade:"DirectTrade"},un=zod.z.enum(["Listing","Auction","BuyOrder","DirectTrade"]).catch("Listing"),Cm={Active:"Active",Completed:"Completed",Cancelled:"Cancelled",Declined:"Declined",Expired:"Expired"},cn=zod.z.enum(["Active","Completed","Cancelled","Declined","Expired"]).catch("Active"),Sm={Burn:"Burn",Ledger:"Ledger"},xm=zod.z.enum(["Burn","Ledger"]).catch("Burn"),yr={Item:"Item",VirtualCurrency:"VirtualCurrency"},pn=zod.z.enum(["Item","VirtualCurrency"]).catch("Item"),bm=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:B.nullish()}).passthrough(),Dm=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(an).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),zm=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:B.nullish(),Sink:xm.nullish(),LedgerAccountID:zod.z.string().nullish(),PerCatalogOverrides:zod.z.record(zod.z.string(),bm).nullish(),ApplyToDirectTrades:zod.z.boolean().nullish()}).passthrough(),Pm=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(),vm=zod.z.object({Enabled:zod.z.boolean().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),MaxActiveListings:zod.z.number().nullish(),CreateLimits:ie.nullish(),BuyLimits:ie.nullish(),ListingFeeOptions:ee.nullish(),RefundListingFeeOnCancel:zod.z.boolean().nullish()}).passthrough(),Tm=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:B.nullish(),BidLimits:ie.nullish()}).passthrough(),Im=zod.z.object({Enabled:zod.z.boolean().nullish(),MaxActiveOrders:zod.z.number().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),CreateLimits:ie.nullish(),FillLimits:ie.nullish()}).passthrough(),km=zod.z.object({Enabled:zod.z.boolean().nullish(),OfferExpirationHours:zod.z.number().nullish(),MaxPendingOutgoing:zod.z.number().nullish(),AllowGifts:zod.z.boolean().nullish(),CreateLimits:ie.nullish()}).passthrough(),wm=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),dn=zod.z.object({Enabled:zod.z.boolean().nullish(),Gate:_.nullish(),Schedule:re.nullish(),PricePolicy:Dm.nullish(),Commission:zm.nullish(),Tradability:Pm.nullish(),Listings:vm.nullish(),Auctions:Tm.nullish(),BuyOrders:Im.nullish(),DirectTrades:km.nullish(),Matching:wm.nullish()}).passthrough(),Va=zod.z.object({BidIndex:zod.z.number().nullish(),UserID:zod.z.string().nullish(),Amount:B.nullish(),Settled:zod.z.boolean().nullish(),SettledAt:u.nullish()}).passthrough(),Mm=zod.z.object({BidAxisType:ui.nullish(),BidCurrencyID:zod.z.string().nullish(),BidCatalogID:zod.z.string().nullish(),BidItemID:zod.z.string().nullish(),StartingBid:B.nullish(),CurrentBid:B.nullish(),CurrentBidderID:zod.z.string().nullish(),BidCount:zod.z.number().nullish(),ExtensionCount:zod.z.number().nullish(),PendingRefunds:zod.z.array(Va).nullish()}).passthrough(),gr=zod.z.object({LastAt:u.nullish(),DailyCount:zod.z.number().nullish(),DailyResetUtc:u.nullish()}).passthrough(),Am=zod.z.object({Create:gr.nullish(),Buy:gr.nullish(),Sell:gr.nullish(),Bid:gr.nullish()}).passthrough(),Om=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),Um=zod.z.object({ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Quantity:zod.z.number().nullish(),RemainingUses:zod.z.number().nullish(),Level:zod.z.number().nullish(),AcquiredAt:u,ExpiresAt:u.nullish(),EquippedSlot:Om.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(o=>o),pt=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:un.nullish(),Status:cn.nullish(),CreatorUserID:zod.z.string().nullish(),CreatorPublicData:Se.nullish(),TargetUserID:zod.z.string().nullish(),GoodsType:pn.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:B.nullish(),GoodsInstances:zod.z.array(Um).nullish(),Price:Re.nullish(),Auction:Mm.nullish(),CreatedAt:u.nullish(),ExpiresAt:u.nullish()}).passthrough(),Bm=zod.z.object({GoodsType:pn.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),CountsByType:zod.z.record(un,B).nullish(),ListingCount:B.nullish(),AuctionCount:B.nullish(),BuyOrderCount:B.nullish()}).passthrough(),_a=zod.z.object({Definitions:dn.nullish(),IsOpenNow:zod.z.boolean().nullish(),GatePassed:zod.z.boolean().nullish()}).passthrough(),hn=zod.z.object({Offers:zod.z.array(pt).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),Wa=zod.z.object({Groups:zod.z.array(Bm).nullish()}).passthrough(),Qa=zod.z.object({Offer:pt.nullish()}).passthrough(),Ve=zod.z.object({OfferID:zod.z.string().nullish(),Status:cn.nullish(),Settlement:Dt.nullish(),Resources:v.nullish(),CommissionTaken:Re.nullish()}).passthrough(),ti=zod.z.object({OfferID:zod.z.string().nullish(),Offer:pt.nullish(),Resources:v.nullish(),Matched:zod.z.boolean().nullish(),Settlement:Ve.nullish()}).passthrough(),Ka=zod.z.object({OfferID:zod.z.string().nullish(),CurrentBid:B.nullish(),BidCount:zod.z.number().nullish(),ExpiresAt:u.nullish(),Resources:v.nullish()}).passthrough(),Ha=zod.z.object({MyOffers:zod.z.array(pt).nullish(),MyLeadingBids:zod.z.array(pt).nullish(),MyBuyOrders:zod.z.array(pt).nullish(),IncomingTrades:zod.z.array(pt).nullish(),OutgoingTrades:zod.z.array(pt).nullish(),Claimables:zod.z.array(pt).nullish(),DrainedRefunds:zod.z.array(Va).nullish(),Limits:Am.nullish()}).passthrough(),Lm=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:un.nullish(),FinalStatus:cn.nullish(),SellerUserID:zod.z.string().nullish(),BuyerUserID:zod.z.string().nullish(),GoodsType:pn.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:B.nullish(),PricePaid:Re.nullish(),CommissionTaken:Re.nullish(),CompletedAt:u.nullish()}).passthrough(),$a=zod.z.object({Entries:zod.z.array(Lm).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),pe={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 qm="Marketplace",Rr=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(qm,t.data.Definitions),this.ctx.emitter.emit("marketplace:definitionsLoaded",t.data)),t}async getGroupedOffers(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.marketplace.getGroupedOffers(e);return t.ok&&this.ctx.emitter.emit("marketplace:groupedOffersLoaded",t.data),t}async getOffersByItem(e,t,i,r=20){if(!e)return n("client","ItemID is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.ItemID=e,s.OfferTypeFilter=t,s.ContinuationToken=i,s.PageSize=r;let a=await this.ctx.api.marketplace.getOffersByItem(s);return a.ok&&this.ctx.emitter.emit("marketplace:offersByItemLoaded",a.data),a}async getOffer(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.getOffer(t);return i.ok&&this.ctx.emitter.emit("marketplace:offerLoaded",i.data),i}async getBuyOrders(e,t,i=20){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.ItemID=e,r.ContinuationToken=t,r.PageSize=i;let s=await this.ctx.api.marketplace.getBuyOrders(r);return s.ok&&this.ctx.emitter.emit("marketplace:buyOrdersLoaded",s.data),s}async getMyState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.marketplace.getMyState(e);return t.ok&&(this.ctx.data.user.applyMarketplaceState(t.data.Limits??null),this.ctx.emitter.emit("marketplace:myStateLoaded",t.data)),t}async getHistory(e,t=20){let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.ContinuationToken=e,i.PageSize=t;let r=await this.ctx.api.marketplace.getHistory(i);return r.ok&&this.ctx.emitter.emit("marketplace:historyLoaded",r.data),r}async createListing(e,t,i,r,s,a,p){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");if(!r)return n("client","PriceBundle is required.");let x=this.baseRequest();if(!x)return n("unauthorized","Not logged in.");x.ItemID=e,x.CatalogID=t,x.GoodsAmount=i,x.PriceBundle=r,x.DurationHours=s,x.ItemInstanceIDs=a,x.SelectedOptionID=p;let k=await this.ctx.api.marketplace.createListing(x);return this.applyCreateOfferResult(k,"marketplace:listingCreated"),k}async cancelListing(e){return this.cancelOffer(e,t=>this.ctx.api.marketplace.cancelListing(t),"marketplace:listingCancelled")}async buy(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.buy(t);return i.ok&&(this.applyDualPartySettlement(i.data.Settlement),this.ctx.emitter.emit("marketplace:bought",i.data)),i}async marketBuy(e,t,i){if(!e||e<=0)return n("client","GoodsAmount must be positive.");if(!t)return n("client","PriceBundle is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");let s=this.applyGoodsSelector(r,i);if(s)return s;r.GoodsAmount=e,r.PriceBundle=t;let a=await this.ctx.api.marketplace.marketBuy(r);return a.ok&&(this.applyDualPartySettlement(a.data.Settlement),this.ctx.emitter.emit("marketplace:marketBought",a.data)),a}async marketSell(e,t,i){if(!e||e<=0)return n("client","GoodsAmount must be positive.");if(!t)return n("client","PriceBundle is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");let s=this.applyGoodsSelector(r,i);if(s)return s;r.GoodsAmount=e,r.PriceBundle=t;let a=await this.ctx.api.marketplace.marketSell(r);return a.ok&&(this.applyDualPartySettlement(a.data.Settlement),this.ctx.emitter.emit("marketplace:marketSold",a.data)),a}async createAuction(e,t,i,r,s,a,p={}){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");let x=this.baseRequest();if(!x)return n("unauthorized","Not logged in.");x.ItemID=e,x.CatalogID=t,x.GoodsAmount=i,x.BidAxisType=r,x.BidCurrencyID=p.bidCurrencyID,x.BidCatalogID=p.bidCatalogID,x.BidItemID=p.bidItemID,x.StartingBid=s,x.DurationHours=a,x.ItemInstanceIDs=p.itemInstanceIDs,x.SelectedOptionID=p.selectedOptionID;let k=await this.ctx.api.marketplace.createAuction(x);return this.applyCreateOfferResult(k,"marketplace:auctionCreated"),k}async placeBid(e,t){if(!e)return n("client","OfferID is required.");if(!t||t<=0)return n("client","BidAmount must be positive.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.OfferID=e,i.BidAmount=t;let r=await this.ctx.api.marketplace.placeBid(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:bidPlaced",r.data)),r}async claimAuction(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.claimAuction(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:auctionClaimed",i.data)),i}async createBuyOrder(e,t,i,r,s){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");if(!r)return n("client","PriceBundle is required.");let a=this.baseRequest();if(!a)return n("unauthorized","Not logged in.");a.ItemID=e,a.CatalogID=t,a.GoodsAmount=i,a.PriceBundle=r,a.DurationHours=s;let p=await this.ctx.api.marketplace.createBuyOrder(a);return this.applyCreateOfferResult(p,"marketplace:buyOrderCreated"),p}async cancelBuyOrder(e){return this.cancelOffer(e,t=>this.ctx.api.marketplace.cancelBuyOrder(t),"marketplace:buyOrderCancelled")}async fillBuyOrder(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.fillBuyOrder(t);return i.ok&&(this.applyDualPartySettlement(i.data.Settlement),this.ctx.emitter.emit("marketplace:buyOrderFilled",i.data)),i}async createDirectTrade(e,t,i,r,s){if(!e)return n("client","TargetUserID is required.");if(!t)return n("client","CatalogID is required.");if(!i)return n("client","ItemID is required.");let a=this.baseRequest();if(!a)return n("unauthorized","Not logged in.");a.TargetUserID=e,a.CatalogID=t,a.ItemID=i,a.ItemInstanceIDs=r,a.RequestedBundle=s;let p=await this.ctx.api.marketplace.createDirectTrade(a);return this.applyCreateOfferResult(p,"marketplace:directTradeCreated"),p}async respondDirectTrade(e,t){if(!e)return n("client","OfferID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.OfferID=e,i.Accept=t;let r=await this.ctx.api.marketplace.respondDirectTrade(i);return r.ok&&(t&&(r.data.Settlement?this.applyDualPartySettlement(r.data.Settlement):r.data.Resources&&this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions)),this.ctx.emitter.emit("marketplace:directTradeResponded",r.data)),r}async cancelDirectTrade(e){return this.cancelOffer(e,t=>this.ctx.api.marketplace.cancelDirectTrade(t),"marketplace:directTradeCancelled")}async claimBack(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.claimBack(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:claimedBack",i.data)),i}async cancelOffer(e,t,i){if(!e)return n("client","OfferID is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.OfferID=e;let s=await t(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit(i,s.data)),s}applyCreateOfferResult(e,t){e.ok&&(e.data.Matched&&e.data.Settlement?this.applyDualPartySettlement(e.data.Settlement.Settlement):this.ctx.data.user.applyResourceOperation(e.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit(t,e.data));}applyGoodsSelector(e,t){return "goodsCurrencyID"in t&&t.goodsCurrencyID?(e.GoodsType=yr.VirtualCurrency,e.GoodsCurrencyID=t.goodsCurrencyID,null):"itemID"in t&&t.itemID&&t.catalogID?(e.GoodsType=yr.Item,e.ItemID=t.itemID,e.CatalogID=t.catalogID,null):n("client","Either itemID+catalogID or goodsCurrencyID is required.")}applyDualPartySettlement(e){let t=this.ctx.auth.context?.userID;if(!e||!t)return;let i=this.ctx.data.config.itemDefinitions;e.FromUserID===t&&e.FromResult?this.ctx.data.user.applyResourceOperation(e.FromResult,i):e.ToUserID===t&&e.ToResult&&this.ctx.data.user.applyResourceOperation(e.ToResult,i);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Cr=class{constructor(e){this.ctx=e;}ctx;async createRoom(e,t={}){if(!e)return n("client","RoomName is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomName=e,i.Topology=t.topology,i.ChatMode=t.chatMode,i.MaxPlayers=t.maxPlayers,i.Visibility=t.visibility,i.JoinCode=t.joinCode;let r=await this.ctx.api.multiplayer.createRoom(i);return r.ok&&this.ctx.emitter.emit("multiplayer:roomCreated",r.data),r}async joinRoom(e,t){if(!e)return n("client","RoomID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.JoinCode=t;let r=await this.ctx.api.multiplayer.joinRoom(i);return r.ok&&this.ctx.emitter.emit("multiplayer:roomJoined",r.data),r}async leaveRoom(e){if(!e)return n("client","RoomID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.RoomID=e;let i=await this.ctx.api.multiplayer.leaveRoom(t);return i.ok&&this.ctx.emitter.emit("multiplayer:roomLeft",i.data),i}async listRooms(e=0,t=20){let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.Page=e,i.PageSize=t;let r=await this.ctx.api.multiplayer.listRooms(i);return r.ok&&this.ctx.emitter.emit("multiplayer:roomsListed",r.data),r}async getRoom(e){if(!e)return n("client","RoomID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.RoomID=e;let i=await this.ctx.api.multiplayer.getRoom(t);return i.ok&&this.ctx.emitter.emit("multiplayer:roomLoaded",i.data),i}async closeRoom(e){if(!e)return n("client","RoomID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.RoomID=e;let i=await this.ctx.api.multiplayer.closeRoom(t);return i.ok&&this.ctx.emitter.emit("multiplayer:roomClosed",i.data),i}async poll(e,t){if(!e)return n("client","RoomID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.LastSeq=t;let r=await this.ctx.api.multiplayer.poll(i);return r.ok&&this.ctx.emitter.emit("multiplayer:polled",r.data),r}async sendSignal(e,t,i,r){if(!e)return n("client","RoomID is required.");if(!t)return n("client","TargetUserID is required.");if(!i)return n("client","SignalKind is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomID=e,s.TargetUserID=t,s.SignalKind=i,s.Payload=r;let a=await this.ctx.api.multiplayer.sendSignal(s);return a.ok&&this.ctx.emitter.emit("multiplayer:signalSent",a.data),a}async sendChat(e,t){if(!e)return n("client","RoomID is required.");if(!t)return n("client","ChatText is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.ChatText=t;let r=await this.ctx.api.multiplayer.sendChat(i);return r.ok&&this.ctx.emitter.emit("multiplayer:chatSent",r.data),r}async setMemberState(e,t,i){if(!e)return n("client","RoomID is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.RoomID=e,r.Ready=t,r.MemberState=i;let s=await this.ctx.api.multiplayer.setMemberState(r);return s.ok&&this.ctx.emitter.emit("multiplayer:memberStateSet",s.data),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Za=zod.z.object({PlatformUserID:zod.z.string().nullish(),PlatformAuthToken:zod.z.string().nullish(),PlatformAuthTokenExpiration:u.nullish(),TitleUserID:zod.z.string(),TitleClientSessionTicket:zod.z.string(),TitleClientSessionTicketExpiration:u}),Ja=zod.z.object({CodeTtlMinutes:zod.z.number().nullish(),ResendCooldownSeconds:zod.z.number().nullish()}),be=zod.z.object({IsCompleted:zod.z.boolean().nullish(),ServerTime:u.nullish()}),Ya=zod.z.object({Message:zod.z.string(),ExpiresAt:u}),Be={LoginWithDeviceID:"LoginWithDeviceID",LoginWithTelegram:"LoginWithTelegram",LoginWithEmail:"LoginWithEmail",LoginWithGoogle:"LoginWithGoogle",LoginWithSsoCode:"LoginWithSsoCode",RegisterWithEmail:"RegisterWithEmail",ConfirmEmailRegistration:"ConfirmEmailRegistration",ResendVerificationCode:"ResendVerificationCode",RequestWalletChallenge:"RequestWalletChallenge",LoginWithWallet:"LoginWithWallet",ForgotPassword:"ForgotPassword",ResetPassword:"ResetPassword"};function O(o,e,t,i){let s=`api/v2/${o&&o.length>0?o:"0"}/Client/${e}/${t}`;return i==null?s:`${s}/${i}`}var Sr=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,Za,{ticket:null})}loginWithDeviceID(e){return this.login(Be.LoginWithDeviceID,e)}loginWithTelegram(e){return this.login(Be.LoginWithTelegram,e)}loginWithEmail(e){return this.login(Be.LoginWithEmail,e)}loginWithGoogle(e){return this.login(Be.LoginWithGoogle,e)}loginWithSsoCode(e){return this.login(Be.LoginWithSsoCode,e)}registerWithEmail(e){return this.ctx.transport.post(this.endpoint(Be.RegisterWithEmail),e,Ja,{ticket:null})}confirmEmailRegistration(e){return this.login(Be.ConfirmEmailRegistration,e)}resendVerificationCode(e){return this.ctx.transport.post(this.endpoint(Be.ResendVerificationCode),e,be,{ticket:null})}requestWalletChallenge(e){return this.ctx.transport.post(this.endpoint(Be.RequestWalletChallenge),e,Ya,{ticket:null})}loginWithWallet(e){return this.login(Be.LoginWithWallet,e)}forgotPassword(e){return this.ctx.transport.post(this.endpoint(Be.ForgotPassword),e,be,{ticket:null})}resetPassword(e){return this.ctx.transport.post(this.endpoint(Be.ResetPassword),e,be,{ticket:null})}};var Em={ReturnKey:"ReturnKey",ReturnMarkedKey:"ReturnMarkedKey",ReturnEmpty:"ReturnEmpty"},Xa=zod.z.enum(["ReturnKey","ReturnMarkedKey","ReturnEmpty"]).catch("ReturnKey"),Gm=zod.z.object({Locale:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Order:zod.z.number().nullish()}).passthrough(),el=zod.z.object({IsEnabled:zod.z.boolean().nullish(),DefaultLocale:zod.z.string().nullish(),Locales:zod.z.record(zod.z.string(),Gm).nullish(),MissingKeyMode:Xa.nullish(),MaxEntriesPerLocale:zod.z.number().nullish(),MaxValueLengthBytes:zod.z.number().nullish()}).passthrough(),Nm=zod.z.object({Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),Url:zod.z.string().nullish()}).passthrough(),tl=zod.z.object({Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),Url:zod.z.string().nullish(),Fallback:Nm.nullish()}).passthrough(),xr={GetLocalizationManifest:"GetLocalizationManifest",GetLocalizationTable:"GetLocalizationTable"},jm=zod.z.object({Locale:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Order:zod.z.number().nullish(),Version:zod.z.number().nullish()}).passthrough(),il=zod.z.object({IsEnabled:zod.z.boolean().nullish(),DefaultLocale:zod.z.string().nullish(),MissingKeyMode:Xa.nullish(),ResolvedLocale:zod.z.string().nullish(),Locales:zod.z.array(jm).nullish()}).passthrough(),rl=zod.z.object({RequestedLocale:zod.z.string().nullish(),Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),NotModified:zod.z.boolean().nullish(),Entries:zod.z.record(zod.z.string(),zod.z.string()).nullish(),FallbackLocale:zod.z.string().nullish(),FallbackVersion:zod.z.number().nullish()}).passthrough();var mn=zod.z.object({TitleConfigVersion:zod.z.string().nullish(),TitleConfigUrl:zod.z.string().nullish(),User:zod.z.unknown().nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish(),StateEpoch:zod.z.string().nullish(),Localization:tl.nullish()}).passthrough().transform(o=>o),sl=zod.z.object({StateEpoch:zod.z.string().nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough().transform(o=>o),nl=zod.z.object({StateEpoch:zod.z.string().nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish(),User:zod.z.unknown().nullish()}).passthrough().transform(o=>o),ol=zod.z.object({}).passthrough().transform(o=>o),al=zod.z.object({}).passthrough().transform(o=>o),ll=zod.z.object({Today:zod.z.number(),Yesterday:zod.z.number(),CurrentWeek:zod.z.number(),CurrentMonth:zod.z.number(),Total:zod.z.number(),TotalSessions:zod.z.number(),FirstActiveAt:u.nullish(),LastActiveAt:u.nullish(),LongestSessionEverSeconds:zod.z.number().nullish(),CurrentWeekActiveHoursMask:zod.z.number().nullish(),CurrentMonthActiveHoursMask:zod.z.number().nullish(),ReactivationCount:zod.z.number().nullish(),History:zod.z.record(zod.z.string(),zod.z.unknown()).nullish()}).passthrough(),ul=zod.z.object({Username:zod.z.string()}),We={GetClientState:"GetClientState",GetClientStateExcept:"GetClientStateExcept",GetStateVersions:"GetStateVersions",GetUserState:"GetUserState",GetInventory:"GetInventory",GetEventTokens:"GetEventTokens",GetUsageTime:"GetUsageTime",AddUsageTime:"AddUsageTime",DeleteUserAccount:"DeleteUserAccount",ChangeUsername:"ChangeUsername"};var br=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(We.GetClientState,e.UserID),e,mn,{ticket:e.ClientSessionTicket})}getClientStateExcept(e){return this.ctx.transport.post(this.endpoint(We.GetClientStateExcept,e.UserID),e,mn,{ticket:e.ClientSessionTicket})}getStateVersions(e){return this.ctx.transport.post(this.endpoint(We.GetStateVersions,e.UserID),e,sl,{ticket:e.ClientSessionTicket})}getUserState(e){return this.ctx.transport.post(this.endpoint(We.GetUserState,e.UserID),e,nl,{ticket:e.ClientSessionTicket})}getInventory(e){return this.ctx.transport.post(this.endpoint(We.GetInventory,e.UserID),e,ol,{ticket:e.ClientSessionTicket})}getEventTokens(e){return this.ctx.transport.post(this.endpoint(We.GetEventTokens,e.UserID),e,al,{ticket:e.ClientSessionTicket})}getUsageTime(e){return this.ctx.transport.post(this.endpoint(We.GetUsageTime,e.UserID),e,ll,{ticket:e.ClientSessionTicket})}addUsageTime(e){return this.ctx.transport.post(this.endpoint(We.AddUsageTime,e.UserID),e,be,{ticket:e.ClientSessionTicket,silent:true})}deleteUserAccount(e){return this.ctx.transport.post(this.endpoint(We.DeleteUserAccount,e.UserID),e,be,{ticket:e.ClientSessionTicket})}changeUsername(e){return this.ctx.transport.post(this.endpoint(We.ChangeUsername,e.UserID),e,ul,{ticket:e.ClientSessionTicket})}};var Dr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Currency",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}convert(e){return this.send(ur.Convert,e,Yo)}cryptoConvert(e){return this.send(ur.CryptoConvert,e,Xo)}};var Fm=zod.z.object({ItemInstanceID:zod.z.string(),Units:zod.z.number(),Level:zod.z.number()}),fn=zod.z.object({ServerTimeUtc:u,ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Level:zod.z.number(),Resources:v.nullish(),FodderConsumed:zod.z.array(Fm).nullish()}),cl=zod.z.array(ae(fn)),zr={UpgradeLevel:"UpgradeLevel",UpgradeLevelsBatch:"UpgradeLevelsBatch"},Vm={FlatCount:"FlatCount",Merge:"Merge",InvestmentRefund:"InvestmentRefund"},_m=zod.z.enum(["FlatCount","Merge","InvestmentRefund"]).catch("FlatCount"),Wm={ProtectLeveled:"ProtectLeveled",CheapestFirst:"CheapestFirst",ClientSelected:"ClientSelected",SameLevelOnly:"SameLevelOnly"},Qm=zod.z.enum(["ProtectLeveled","CheapestFirst","ClientSelected","SameLevelOnly"]).catch("ProtectLeveled"),Km=zod.z.object({ContractAddress:zod.z.string().nullish(),TokenID:zod.z.string().nullish(),TokenStandard:zod.z.string().nullish()}).passthrough(),Hm=zod.z.object({Networks:zod.z.record(zod.z.string(),Km).nullish(),MetadataUrl:zod.z.string().nullish()}).passthrough(),$m=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(),Zm=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(),Jm=zod.z.object({ValuationMode:_m.nullish(),WeightCurve:Pe.nullish(),Selection:Qm.nullish()}).passthrough(),Ym=zod.z.object({MaxLevel:zod.z.number().nullish(),PriceOptions:ee.nullish(),CostCurve:Pe.nullish(),FlatBonusCurve:Pe.nullish(),PercentBonusCurve:Pe.nullish(),PowerCurve:Pe.nullish(),Fodder:Jm.nullish()}).passthrough(),Xm=zod.z.object({RarityID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),AuthorID:zod.z.string().nullish()}).passthrough(),ef=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:Hm.nullish(),Stats:$m.nullish(),Equipment:Zm.nullish(),Upgrade:Ym.nullish(),Metadata:Xm.nullish(),ExpirationDurationSeconds:zod.z.number().nullish()}).passthrough(),tf=zod.z.object({Items:zod.z.record(zod.z.string(),ef).nullish()}).passthrough(),Pr=zod.z.object({Catalogs:zod.z.record(zod.z.string(),tf).nullish()}).passthrough();var vr=class{constructor(e){this.ctx=e;}ctx;upgradeLevel(e){let t=O(this.ctx.settings.titleID,"Item",zr.UpgradeLevel,e.UserID??"");return this.ctx.transport.post(t,e,fn,{ticket:e.ClientSessionTicket})}upgradeLevelsBatch(e){let t=O(this.ctx.settings.titleID,"Item",zr.UpgradeLevelsBatch,e.UserID??"");return this.ctx.transport.post(t,e,cl,{ticket:e.ClientSessionTicket})}};var gn=zod.z.object({ServerTimeUtc:u,OfferID:zod.z.string(),Count:zod.z.number(),Resources:v.nullish()}),pl=zod.z.array(ae(gn)),rf=zod.z.object({OfferID:zod.z.string(),TotalPurchases:zod.z.number(),DailyPurchases:zod.z.number(),DailyResetUtc:u,LastPurchasedAt:u}),sf=zod.z.object({SlotKey:zod.z.string(),InstanceKey:zod.z.string(),OfferID:zod.z.string().nullish(),Purchases:zod.z.number(),LastPurchasedAt:u}),dl=zod.z.object({Purchases:zod.z.record(zod.z.string(),rf).nullish(),Rotations:zod.z.record(zod.z.string(),sf).nullish()}).passthrough().transform(o=>o),Ct=zod.z.object({DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),Tags: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()}).passthrough(),yn=zod.z.object({Schedule:re.nullish(),Gate:_.nullish()}).passthrough(),nf={Fixed:"Fixed",Title:"Title",Player:"Player"},of=zod.z.object({OfferID:zod.z.string().nullish(),Weight:zod.z.number().nullish(),Gate:_.nullish()}).passthrough(),af=zod.z.object({Mode:zod.z.string().nullish(),OfferID:zod.z.string().nullish(),Pool:zod.z.array(of).nullish(),Salt:zod.z.string().nullish(),PerInstanceCap:zod.z.number().nullish()}).passthrough(),lf=zod.z.object({SlotID:zod.z.string().nullish(),Identity:Ct.nullish(),Availability:yn.nullish(),Rotation:af.nullish()}).passthrough(),uf=zod.z.object({SectionID:zod.z.string().nullish(),Identity:Ct.nullish(),Availability:yn.nullish(),Slots:zod.z.record(zod.z.string(),lf).nullish(),UniqueOffersInSection:zod.z.boolean().nullish()}).passthrough(),cf=zod.z.object({Sections:zod.z.record(zod.z.string(),uf).nullish()}).passthrough(),pf=zod.z.object({StoreID:zod.z.string().nullish(),Identity:Ct.nullish(),Availability:yn.nullish(),Layout:cf.nullish()}).passthrough(),df=zod.z.object({Options:ee.nullish(),CompareAt:zod.z.record(zod.z.string(),lt).nullish()}).passthrough(),hf=zod.z.object({Grant:G.nullish()}).passthrough(),mf=zod.z.object({Schedule:re.nullish(),Gate:_.nullish(),Limits:ie.nullish()}).passthrough(),ff=zod.z.object({OfferID:zod.z.string().nullish(),Identity:Ct.nullish(),Pricing:df.nullish(),Reward:hf.nullish(),Availability:mf.nullish()}).passthrough(),Tr=zod.z.object({Stores:zod.z.record(zod.z.string(),pf).nullish(),StoreOffers:zod.z.record(zod.z.string(),ff).nullish()}).passthrough(),gf=zod.z.object({PurchasedTotal:zod.z.number(),PurchasedToday:zod.z.number(),PurchasedThisRotation:zod.z.number(),RemainingTotal:zod.z.number().nullish(),RemainingToday:zod.z.number().nullish(),IsFirstPurchaseAvailable:zod.z.boolean(),SoldOut:zod.z.boolean(),AvailableAtUtc:u.nullish()}).passthrough(),yf=zod.z.object({OptionID:zod.z.string(),Name:zod.z.string().nullish(),Cost:lt.nullish(),CompareAtCost:lt.nullish(),DiscountPercent:zod.z.number().nullish(),IsFree:zod.z.boolean(),IsAdPaid:zod.z.boolean(),IsStorePaid:zod.z.boolean(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Rf=zod.z.object({OfferID:zod.z.string(),Identity:Ct.nullish(),PriceOptions:zod.z.array(yf).nullish(),Rewards:G.nullish(),State:gf.nullish()}).passthrough(),Cf=zod.z.object({SlotID:zod.z.string(),Identity:Ct.nullish(),SortOrder:zod.z.number(),RotationMode:zod.z.string().nullish(),RotationInstanceKey:zod.z.string().nullish(),RefreshesAtUtc:u.nullish(),RemainingThisRotation:zod.z.number().nullish(),Offer:Rf.nullish()}).passthrough(),Sf=zod.z.object({SectionID:zod.z.string(),Identity:Ct.nullish(),SortOrder:zod.z.number(),Slots:zod.z.array(Cf).nullish()}).passthrough(),xf=zod.z.object({StoreID:zod.z.string(),Identity:Ct.nullish(),SortOrder:zod.z.number(),ScheduleInstanceKey:zod.z.string().nullish(),ExpiresAtUtc:u.nullish(),Sections:zod.z.array(Sf).nullish()}).passthrough(),hl=zod.z.object({ServerTimeUtc:u,Stores:zod.z.array(xf).nullish(),AdCreditBalance:zod.z.number()}).passthrough(),vt={Purchase:"Purchase",GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",PurchaseBatch:"PurchaseBatch",GetStorefront:"GetStorefront"},bf="OFFER_NOT_IN_ROTATION";var Ir=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Store",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}purchase(e){return this.send(vt.Purchase,e,gn)}purchaseBatch(e){return this.send(vt.PurchaseBatch,e,pl)}getDefinitions(e){return this.send(vt.GetDefinitions,e,Tr)}getUserState(e){return this.send(vt.GetUserState,e,dl)}getStorefront(e){return this.send(vt.GetStorefront,e,hl)}};var Df={Consumable:"Consumable",NonConsumable:"NonConsumable",Subscription:"Subscription"},zf=zod.z.enum(["Consumable","NonConsumable","Subscription"]).catch("Consumable"),Pf=zod.z.object({StartUtc:u.nullish(),EndUtc:u.nullish(),Gate:_.nullish(),Limits:ie.nullish()}).passthrough(),vf=zod.z.object({ResourceAction:zod.z.string().nullish(),RevokeEntitlement:zod.z.boolean().nullish(),BlockFuturePurchases:zod.z.boolean().nullish()}).passthrough(),Tf=zod.z.object({ProductID:zod.z.string().nullish(),Name:zod.z.string().nullish(),Type:zf.nullish(),Enabled:zod.z.boolean().nullish(),StoreProductIDs:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rewards:G.nullish(),PriceUsdCents:zod.z.number().nullish(),Rules:Pf.nullish(),Refund:vf.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),ml=zod.z.object({Enabled:zod.z.boolean().nullish(),Products:zod.z.record(zod.z.string(),Tf).nullish()}).passthrough(),fl=zod.z.object({ProductID:zod.z.string().nullish(),TotalPurchases:zod.z.number().nullish(),DailyPurchases:zod.z.number().nullish(),DailyResetUtc:u.nullish(),LastPurchasedAt:u.nullish(),Owned:zod.z.boolean().nullish(),Refunded:zod.z.boolean().nullish(),PurchaseBlocked:zod.z.boolean().nullish()}).passthrough(),gl=zod.z.object({Products:zod.z.record(zod.z.string(),fl).nullish(),LifetimeSpendUsdCents:zod.z.number().nullish()}).passthrough(),If={Granted:"Granted",Restored:"Restored",AlreadyProcessed:"AlreadyProcessed"},kf=zod.z.enum(["Granted","Restored","AlreadyProcessed"]).catch("Granted"),Rn=zod.z.object({ServerTimeUtc:u,Store:pi.nullish(),ProductID:zod.z.string().nullish(),TransactionID:zod.z.string().nullish(),Status:kf.nullish(),Granted:zod.z.boolean().nullish(),Quantity:zod.z.number().nullish(),Resources:v.nullish(),ProductState:fl.nullish()}).passthrough(),yl=rt(Rn),_t={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ValidatePurchase:"ValidatePurchase",ValidatePurchasesBatch:"ValidatePurchasesBatch"};var kr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Purchase",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(_t.GetDefinitions,e,ml)}getUserState(e){return this.send(_t.GetUserState,e,gl)}validatePurchase(e){return this.send(_t.ValidatePurchase,e,Rn)}validatePurchasesBatch(e){return this.send(_t.ValidatePurchasesBatch,e,yl)}};var wf=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),Rl=zod.z.object({Reward:G.nullish(),Weight:zod.z.number().nullish(),AmountRange:wf.nullish()}).passthrough(),Wt=zod.z.object({SlotID:zod.z.string().nullish(),MinRolls:zod.z.number().nullish(),MaxRolls:zod.z.number().nullish(),Pool:zod.z.array(Rl).nullish()}).passthrough(),Qt=zod.z.object({RuleID:zod.z.string().nullish(),Threshold:zod.z.number().nullish(),Pool:zod.z.array(Rl).nullish()}).passthrough(),Mf=zod.z.object({RewardSlots:zod.z.array(Wt).nullish()}).passthrough(),Af=zod.z.object({PityRules:zod.z.array(Qt).nullish()}).passthrough(),wr=zod.z.object({SlotPresets:zod.z.record(zod.z.string(),Mf).nullish(),PityPresets:zod.z.record(zod.z.string(),Af).nullish()}).passthrough();var Of=zod.z.object({RuleID:zod.z.string(),BoxIndex:zod.z.number().nullish()}),Cl=zod.z.object({ServerTimeUtc:u,LootboxID:zod.z.string(),OpenedCount:zod.z.number().nullish(),SelectedOptionID:zod.z.string().nullish(),Resources:v.nullish(),Inventory:yt.nullish(),Results:zod.z.array(v).nullish(),TriggeredPity:zod.z.array(Of).nullish()}),Uf=zod.z.object({RewardSlots:K.nullish(),PityRules:K.nullish()}).passthrough(),Bf=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),MaxDrops:B.nullish()}).passthrough(),Lf=zod.z.object({LootboxID:zod.z.string(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),PriceOptions:ee.nullish(),RewardSlots:zod.z.array(Wt).nullish(),PityRules:zod.z.array(Qt).nullish(),Presets:Uf.nullish(),RewardMultiplier:hi.nullish(),SupplyLimits:zod.z.array(Bf).nullish(),MaxOpenCount:zod.z.number().nullish()}).passthrough(),Cn=zod.z.object({Definitions:zod.z.record(zod.z.string(),Lf).nullish(),RewardPools:wr.nullish()}).passthrough(),Sl=zod.z.object({LootboxDefinitions:Cn.nullish()}),Mr={GetDefinitions:"GetDefinitions",Open:"Open"};var Ar=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Lootbox",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Mr.GetDefinitions,e,Sl)}open(e){return this.send(Mr.Open,e,Cl)}};var qf=zod.z.object({}).passthrough().transform(o=>o),Ef=zod.z.object({}).passthrough().transform(o=>o),Gf=zod.z.object({}).passthrough().transform(o=>o),Nf=zod.z.object({}).passthrough().transform(o=>o),jf=zod.z.object({}).passthrough().transform(o=>o),xl=zod.z.object({ServerTimeUtc:u,CalendarID:zod.z.string(),DayNumber:zod.z.number().nullish(),DailyState:qf,Resources:v.nullish()}),bl=zod.z.object({ServerTimeUtc:u,AccrualID:zod.z.string(),AccruedSeconds:B.nullish(),AppliedRatePerSecond:zod.z.number().nullish(),IdleState:Ef,Resources:v.nullish()}),Dl=zod.z.object({ServerTimeUtc:u,ComebackID:zod.z.string(),ClaimedTierIndex:zod.z.number().nullish(),ComebackState:Gf,Resources:v.nullish()}),zl=zod.z.object({ServerTimeUtc:u,ClaimID:zod.z.string(),ClaimState:Nf,Resources:v.nullish()}),Pl=zod.z.object({Enabled:zod.z.boolean(),Multiplier:zod.z.number().nullish(),Progress:B.nullish(),Source:zod.z.string().nullish(),SourceKey:zod.z.string().nullish()}),Ff=zod.z.object({RewardMode:zod.z.string().nullish(),RewardStackLowerTiers:zod.z.boolean().nullish()}).passthrough(),Vf=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(),_f=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(Vf).nullish(),IsLooping:zod.z.boolean().nullish(),MissBehavior:zod.z.string().nullish(),ResetByDays:zod.z.number().nullish(),MissThresholdMultiplier:zod.z.number().nullish(),ClaimMode:zod.z.string().nullish(),ClaimCooldownSeconds:zod.z.number().nullish(),Gate:_.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Wf=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),Qf=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(Wf).nullish()}).passthrough(),Kf=zod.z.object({MinCharacterLevel:zod.z.number().nullish(),RequirementsCharacterID:zod.z.string().nullish(),Gate:_.nullish(),RequiredItemIDs:zod.z.array(zod.z.string()).nullish(),RequiredEquippedItemIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),Hf=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:Qf.nullish(),Rewards:G.nullish(),MaxAccumulationSeconds:zod.z.number().nullish(),MinClaimSeconds:zod.z.number().nullish(),Requirements:Kf.nullish(),FirstClaimMode:zod.z.string().nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),$f=zod.z.object({MinAbsenceSeconds:zod.z.number().nullish(),Rewards:G.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Zf=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($f).nullish(),ClaimCooldownSeconds:zod.z.number().nullish(),ClaimWindowSeconds:zod.z.number().nullish(),TrackPresenceOnRead:zod.z.boolean().nullish(),Gate:_.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Jf=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(),Yf=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:ie.nullish(),PremiumLimitOverrides:zod.z.array(Jf).nullish(),Gate:_.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Sn=zod.z.object({TierRewards:Ff.nullish(),MilestoneRewardMultiplier:hi.nullish(),DailyCalendars:zod.z.record(zod.z.string(),_f).nullish(),IdleAccruals:zod.z.record(zod.z.string(),Hf).nullish(),Comebacks:zod.z.record(zod.z.string(),Zf).nullish(),Claims:zod.z.record(zod.z.string(),Yf).nullish()}).passthrough(),vl=zod.z.object({RewardDefinitions:Sn.nullish()}),Tl=zod.z.object({Rewards:jf.nullish()}),dt={GetRewardDefinitions:"GetRewardDefinitions",GetUserRewardsState:"GetUserRewardsState",ClaimDailyReward:"ClaimDailyReward",CollectIdleAccrual:"CollectIdleAccrual",ClaimComebackReward:"ClaimComebackReward",ClaimReward:"ClaimReward",ClaimRewardsBatch:"ClaimRewardsBatch",GetMilestoneRewardMultiplier:"GetMilestoneRewardMultiplier"};var Or=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Reward",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getRewardDefinitions(e){return this.send(dt.GetRewardDefinitions,e,vl)}getUserRewardsState(e){return this.send(dt.GetUserRewardsState,e,Tl)}getMilestoneRewardMultiplier(e){return this.send(dt.GetMilestoneRewardMultiplier,e,Pl)}claimDailyReward(e){return this.send(dt.ClaimDailyReward,e,xl)}collectIdleAccrual(e){return this.send(dt.CollectIdleAccrual,e,bl)}claimComebackReward(e){return this.send(dt.ClaimComebackReward,e,Dl)}claimReward(e){return this.send(dt.ClaimReward,e,zl)}};var Ur=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Tutorial",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getTutorialDefinitions(e){return this.send(je.GetTutorialDefinitions,e,vo)}getUserTutorialState(e){return this.send(je.GetUserTutorialState,e,Io)}startFlow(e){return this.send(je.StartFlow,e,gt)}reportStepShown(e){return this.send(je.ReportStepShown,e,gt)}completeStep(e){return this.send(je.CompleteStep,e,gt)}completeStepsBatch(e){return this.send(je.CompleteStepsBatch,e,wo)}skipStep(e){return this.send(je.SkipStep,e,gt)}skipFlow(e){return this.send(je.SkipFlow,e,gt)}claimFlowReward(e){return this.send(je.ClaimFlowReward,e,ko)}resetFlow(e){return this.send(je.ResetFlow,e,gt)}};var Xf={Open:"Open",Application:"Application"},eg=zod.z.enum(["Open","Application"]).catch("Open"),tg={Pending:"Pending",Approved:"Approved",Rejected:"Rejected",Suspended:"Suspended",Left:"Left"},Il=zod.z.enum(["Pending","Approved","Rejected","Suspended","Left"]).catch("Pending"),ig={VirtualCurrency:"VirtualCurrency",CryptoCurrency:"CryptoCurrency"},xn=zod.z.enum(["VirtualCurrency","CryptoCurrency"]).catch("VirtualCurrency"),rg={Views:"Views",Likes:"Likes",Comments:"Comments",Shares:"Shares"};zod.z.enum(["Views","Likes","Comments","Shares"]).catch("Views");var Tt={GetCommunityMarketingState:"GetCommunityMarketingState",GetEarnings:"GetEarnings",Claim:"Claim",WithdrawCryptoReward:"WithdrawCryptoReward",CheckJoinEligibility:"CheckJoinEligibility"},sg=zod.z.object({CampaignID:zod.z.string().nullish(),DisplayNameKey:zod.z.string().nullish(),DescriptionKey:zod.z.string().nullish(),IconPath:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),IsRunning:zod.z.boolean().nullish()}).passthrough(),kl=zod.z.object({IsEnabled:zod.z.boolean().nullish(),CreatorPortalUrl:zod.z.string().nullish(),ParticipationMode:eg.nullish(),IsCreator:zod.z.boolean().nullish(),CreatorStatus:Il.nullish(),VerificationCode:zod.z.string().nullish(),TeamID:zod.z.string().nullish(),Campaigns:zod.z.array(sg).nullish()}).passthrough(),ng=zod.z.object({Earned:zod.z.number().nullish(),Mature:zod.z.number().nullish(),CountedMetrics:zod.z.record(zod.z.string(),zod.z.number()).nullish(),ReachedMilestones:zod.z.array(zod.z.string()).nullish(),CappedBySubmissionLimit:zod.z.boolean().nullish(),CappedByCreatorLimit:zod.z.boolean().nullish()}).passthrough(),og=zod.z.object({CampaignID:zod.z.string().nullish(),CurrencyKind:xn.nullish(),CurrencyID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),Earned:zod.z.number().nullish(),Mature:zod.z.number().nullish(),Granted:zod.z.number().nullish(),Paid:zod.z.number().nullish(),Overpaid:zod.z.number().nullish(),Claimable:zod.z.number().nullish(),BySubmission:zod.z.record(zod.z.string(),ng).nullish(),ComputedAt:zod.z.string().nullish()}).passthrough(),ag=zod.z.object({PayoutID:zod.z.string().nullish(),CampaignID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),CurrencyID:zod.z.string().nullish(),CurrencyKind:xn.nullish(),NetworkID:zod.z.string().nullish(),PaidAt:zod.z.string().nullish()}).passthrough(),wl=zod.z.object({ServerTimeUtc:zod.z.string().nullish(),HoldDays:zod.z.number().nullish(),Campaigns:zod.z.array(og).nullish(),Payouts:zod.z.array(ag).nullish()}).passthrough(),Ml=zod.z.object({CampaignID:zod.z.string().nullish(),PayoutID:zod.z.string().nullish(),Claimed:zod.z.number().nullish(),CurrencyID:zod.z.string().nullish(),CurrencyKind:xn.nullish(),NetworkID:zod.z.string().nullish(),RemainingFraction:zod.z.number().nullish(),IdempotentReplay:zod.z.boolean().nullish(),Message:zod.z.string().nullish()}).passthrough(),lg=zod.z.object({To:zod.z.string().nullish(),Amount:zod.z.string().nullish()}).passthrough(),ug=zod.z.object({ContractAddress:zod.z.string().nullish(),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(),Signature: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(lg).nullish()}).passthrough(),cg=zod.z.object({Kind:zod.z.string().nullish(),Target:zod.z.string().nullish(),Required:zod.z.number().nullish(),Actual:zod.z.number().nullish(),Passed:zod.z.boolean().nullish()}).passthrough(),Al=zod.z.object({Passed:zod.z.boolean().nullish(),Approved:zod.z.boolean().nullish(),Status:Il.nullish(),WalletMissing:zod.z.boolean().nullish(),WalletConnectAllowed:zod.z.boolean().nullish(),Conditions:zod.z.array(cg).nullish()}).passthrough(),pg=zod.z.object({To:zod.z.string().nullish(),Amount:zod.z.union([zod.z.string(),zod.z.number()]).nullish()}).passthrough(),dg=zod.z.object({ProgramID:zod.z.string().nullish(),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(),SignatureEpoch:zod.z.string().nullish(),Domain:zod.z.string().nullish(),Splits:zod.z.array(pg).nullish(),SignatureHex:zod.z.string().nullish(),Ed25519PublicKey:zod.z.string().nullish(),Ed25519Message:zod.z.string().nullish(),SigIxIndex:zod.z.number().nullish(),UserID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),Category:zod.z.string().nullish()}).passthrough(),Ol=zod.z.object({ServerTimeUtc:zod.z.string().nullish(),TitleTransactionID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ChainID:zod.z.number().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:zod.z.number().nullish(),NetAmountNative:zod.z.number().nullish(),BurnAmountNative:zod.z.number().nullish(),AmountUsd:zod.z.number().nullish(),ExpiresAt:zod.z.string().nullish(),EvmSignature:ug.nullish(),SolanaSignature:dg.nullish()}).passthrough();var Br=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"CommunityMarketing",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getCommunityMarketingState(e){return this.send(Tt.GetCommunityMarketingState,e,kl)}getEarnings(e){return this.send(Tt.GetEarnings,e,wl)}claim(e){return this.send(Tt.Claim,e,Ml)}checkJoinEligibility(e){return this.send(Tt.CheckJoinEligibility,e,Al)}withdrawCryptoReward(e){return this.send(Tt.WithdrawCryptoReward,e,Ol)}};var hg={Global:"Global",Announcement:"Announcement",Group:"Group"},Bl=zod.z.enum(["Global","Announcement","Group"]).catch("Global"),mg={None:"None",Language:"Language",Region:"Region"},fg=zod.z.enum(["None","Language","Region"]).catch("None"),gg={Anyone:"Anyone",Friends:"Friends"},yg=zod.z.enum(["Anyone","Friends"]).catch("Anyone"),Rg={Reject:"Reject",Mask:"Mask"},Cg=zod.z.enum(["Reject","Mask"]).catch("Reject"),Sg={Player:"Player",Publisher:"Publisher",System:"System"},xg=zod.z.enum(["Player","Publisher","System"]).catch("Player"),bg={Spam:"Spam",Abuse:"Abuse",Scam:"Scam",Inappropriate:"Inappropriate",Other:"Other"};zod.z.enum(["Spam","Abuse","Scam","Inappropriate","Other"]).catch("Other");var Dg=zod.z.object({DisplayNameKey:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),IconPath:zod.z.string().nullish(),JoinedByDefault:zod.z.boolean().nullish()}).passthrough(),Ll=zod.z.object({Gate:_.nullish(),Schedule:re.nullish()}).passthrough(),ql=zod.z.object({Gate:_.nullish(),Limits:ie.nullish(),MaxLength:zod.z.number().nullish()}).passthrough(),El=zod.z.object({HotTailSize:zod.z.number().nullish(),HistoryHours:zod.z.number().nullish()}).passthrough(),zg=zod.z.object({Availability:K.nullish(),Write:K.nullish(),Retention:K.nullish()}).passthrough(),Pg=zod.z.object({ChannelID:zod.z.string().nullish(),Identity:Dg.nullish(),Type:Bl.nullish(),GroupSource:zod.z.string().nullish(),Partitioning:fg.nullish(),Capacity:zod.z.number().nullish(),Availability:Ll.nullish(),Write:ql.nullish(),Retention:El.nullish(),Presets:zg.nullish()}).passthrough(),vg=zod.z.object({IsEnabled:zod.z.boolean().nullish(),Gate:_.nullish(),WhoCanMessage:yg.nullish(),Limits:ie.nullish(),MaxLength:zod.z.number().nullish(),HistoryHours:zod.z.number().nullish(),MaxConversations:zod.z.number().nullish()}).passthrough(),Tg=zod.z.object({BlockedTerms:zod.z.array(zod.z.string()).nullish(),BlockedTermAction:Cg.nullish(),MaxIgnoreListSize:zod.z.number().nullish(),ReportsEnabled:zod.z.boolean().nullish(),ReportLimits:ie.nullish()}).passthrough(),Ig=zod.z.object({MinIntervalSeconds:zod.z.number().nullish(),MaxMessagesPerPoll:zod.z.number().nullish(),MaxHistoryPageSize:zod.z.number().nullish()}).passthrough(),kg=zod.z.object({Availability:zod.z.record(zod.z.string(),Ll).nullish(),Write:zod.z.record(zod.z.string(),ql).nullish(),Retention:zod.z.record(zod.z.string(),El).nullish()}).passthrough(),Gl=zod.z.object({IsEnabled:zod.z.boolean().nullish(),Channels:zod.z.record(zod.z.string(),Pg).nullish(),Direct:vg.nullish(),Moderation:Tg.nullish(),Polling:Ig.nullish(),Presets:kg.nullish()}).passthrough(),wg=zod.z.object({LastReadAt:zod.z.string().nullish(),LastReadMessageID:zod.z.string().nullish(),Left:zod.z.boolean().nullish()}).passthrough(),Ul=zod.z.object({LastAt:zod.z.string().nullish(),DailyCount:zod.z.number().nullish(),DailyResetUtc:zod.z.string().nullish(),TotalCount:zod.z.number().nullish(),LastTextHash:zod.z.string().nullish()}).passthrough();zod.z.object({MutedUntil:zod.z.string().nullish(),MuteReason:zod.z.string().nullish(),Ignored:zod.z.array(zod.z.string()).nullish(),Channels:zod.z.record(zod.z.string(),wg).nullish(),Limits:zod.z.record(zod.z.string(),Ul).nullish(),ReportLimits:Ul.nullish()}).passthrough();var bn=zod.z.object({RoomID:zod.z.string().nullish(),SentAt:zod.z.string().nullish(),MessageID:zod.z.string().nullish()}).passthrough(),Lr=zod.z.object({RoomID:zod.z.string().nullish(),ChannelID:zod.z.string().nullish(),MessageID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderProfile:Se.nullish(),AuthorType:xg.nullish(),Text:zod.z.string().nullish(),SentAt:zod.z.string().nullish()}).passthrough(),Mg=zod.z.object({ChannelID:zod.z.string().nullish(),RoomID:zod.z.string().nullish(),DisplayNameKey:zod.z.string().nullish(),IconPath:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),Type:Bl.nullish(),CanWrite:zod.z.boolean().nullish(),WriteBlockedReason:zod.z.string().nullish(),SlowModeSeconds:zod.z.number().nullish(),MaxLength:zod.z.number().nullish(),UnreadCount:zod.z.number().nullish(),LastReadAt:zod.z.string().nullish()}).passthrough(),Nl=zod.z.object({Channels:zod.z.array(Mg).nullish(),PollIntervalSeconds:zod.z.number().nullish(),MutedUntil:zod.z.string().nullish(),MuteReason:zod.z.string().nullish()}).passthrough(),Ag=zod.z.object({RoomID:zod.z.string().nullish(),Messages:zod.z.array(Lr).nullish(),NextCursor:bn.nullish(),UnreadCount:zod.z.number().nullish(),ServedFromDatabase:zod.z.boolean().nullish()}).passthrough(),jl=zod.z.object({Rooms:zod.z.array(Ag).nullish(),PollIntervalSeconds:zod.z.number().nullish()}).passthrough(),Fl=zod.z.object({RoomID:zod.z.string().nullish(),Messages:zod.z.array(Lr).nullish(),NextBefore:bn.nullish()}).passthrough(),Vl=zod.z.object({Message:Lr.nullish(),Moderated:zod.z.boolean().nullish()}).passthrough(),_l=zod.z.object({RoomID:zod.z.string().nullish(),PeerUserID:zod.z.string().nullish(),PeerProfile:Se.nullish(),MaxLength:zod.z.number().nullish()}).passthrough(),Og=zod.z.object({RoomID:zod.z.string().nullish(),PeerUserID:zod.z.string().nullish(),PeerProfile:Se.nullish(),LastMessage:Lr.nullish(),UnreadCount:zod.z.number().nullish(),LastReadAt:zod.z.string().nullish()}).passthrough(),Wl=zod.z.object({Conversations:zod.z.array(Og).nullish()}).passthrough(),Kt=zod.z.object({Ignored:zod.z.array(zod.z.string()).nullish(),Cursor:bn.nullish(),Joined:zod.z.boolean().nullish()}).passthrough(),Ql=zod.z.object({ReportID:zod.z.string().nullish(),AlreadyReported:zod.z.boolean().nullish()}).passthrough(),we={GetChatDefinitions:"GetChatDefinitions",GetChannels:"GetChannels",Poll:"Poll",GetHistory:"GetHistory",GetConversations:"GetConversations",SendMessage:"SendMessage",OpenDirectChannel:"OpenDirectChannel",MarkRead:"MarkRead",JoinChannel:"JoinChannel",LeaveChannel:"LeaveChannel",ReportMessage:"ReportMessage",IgnoreUser:"IgnoreUser",UnignoreUser:"UnignoreUser"};var qr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Chat",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getChatDefinitions(e){return this.send(we.GetChatDefinitions,e,Gl)}getChannels(e){return this.send(we.GetChannels,e,Nl)}poll(e){return this.send(we.Poll,e,jl)}getHistory(e){return this.send(we.GetHistory,e,Fl)}getConversations(e){return this.send(we.GetConversations,e,Wl)}sendMessage(e){return this.send(we.SendMessage,e,Vl)}openDirectChannel(e){return this.send(we.OpenDirectChannel,e,_l)}markRead(e){return this.send(we.MarkRead,e,Kt)}joinChannel(e){return this.send(we.JoinChannel,e,Kt)}leaveChannel(e){return this.send(we.LeaveChannel,e,Kt)}reportMessage(e){return this.send(we.ReportMessage,e,Ql)}ignoreUser(e){return this.send(we.IgnoreUser,e,Kt)}unignoreUser(e){return this.send(we.UnignoreUser,e,Kt)}};var Er=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Push",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getPushConfig(e){return this.send(Vt.GetPushConfig,e,jo)}subscribePush(e){return this.send(Vt.SubscribePush,e,_s)}unsubscribePush(e){return this.send(Vt.UnsubscribePush,e,be)}getPushSubscriptions(e){return this.send(Vt.GetPushSubscriptions,e,Fo)}};var Gr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Localization",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket,throttleKey:t.Locale?`${r}:${t.Locale}`:r})}getLocalizationManifest(e){return this.send(xr.GetLocalizationManifest,e,il)}getLocalizationTable(e){return this.send(xr.GetLocalizationTable,e,rl)}};var Nr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Quest",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getQuestDefinitions(e){return this.send(Ze.GetQuestDefinitions,e,fi)}getUserQuestState(e){return this.send(Ze.GetUserQuestState,e,mo)}refreshQuestCycles(e){return this.send(Ze.RefreshQuestCycles,e,be)}claimQuestReward(e){return this.send(Ze.ClaimQuestReward,e,Os)}claimQuestRewardsBatch(e){return this.send(Ze.ClaimQuestRewardsBatch,e,yo)}claimMilestoneReward(e){return this.send(Ze.ClaimMilestoneReward,e,Us)}claimMilestoneRewardsBatch(e){return this.send(Ze.ClaimMilestoneRewardsBatch,e,Ro)}claimGroupCompletionReward(e){return this.send(Ze.ClaimGroupCompletionReward,e,fo)}addQuestProgress(e){return this.send(Ze.AddQuestProgress,e,go)}};var Kl=zod.z.object({}).passthrough().transform(o=>o);var Ug=zod.z.object({Order:zod.z.number().nullish(),Type:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),BonusMultiplier:zod.z.number().nullish()}).passthrough(),Bg=zod.z.object({Schedule:zod.z.array(Ug).nullish(),RepeatCycle:zod.z.boolean().nullish(),MaxCycles:zod.z.number().nullish()}).passthrough(),Lg=zod.z.object({IsActive:zod.z.boolean().nullish(),CurrentPhaseEndUtc:u.nullish(),NextBonusStartUtc:u.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentPhaseIndex:zod.z.number().nullish(),ActiveBonusMultiplier:zod.z.number().nullish()}).passthrough(),qg=zod.z.object({Milestones:K.nullish()}).passthrough(),Dn=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:zt.nullish(),TokenSources:zod.z.array(Ne).nullish(),ClaimMode:zod.z.string().nullish(),Milestones:zod.z.record(zod.z.string(),Te).nullish(),Presets:qg.nullish(),BonusWindow:Bg.nullish()}).passthrough(),Eg=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Content:Dn.nullish(),ClaimGraceHours:zod.z.number().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Gg=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:re.nullish(),Content:Dn.nullish(),Events:zod.z.array(Eg).nullish(),Gate:_.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Ng=zod.z.object({MaxConcurrentEvents:zod.z.number().nullish()}).passthrough(),jg=zod.z.object({Milestones:zod.z.record(zod.z.string(),Et).nullish()}).passthrough(),jr=zod.z.object({Definitions:zod.z.record(zod.z.string(),Gg).nullish(),Settings:Ng.nullish(),Presets:jg.nullish()}).passthrough(),Fg=zod.z.object({Type:Xt,TimedEventID:zod.z.string(),CurrentChainedEventID:zod.z.string().nullish(),Content:Dn.nullish(),Progress:Kl.nullish(),ComputedStartUtc:u.nullish(),ComputedEndUtc:u.nullish(),CanEarn:zod.z.boolean().nullish(),CanClaim:zod.z.boolean().nullish(),NextMilestone:Te.nullish(),BonusWindow:Lg.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentEventOrder:zod.z.number().nullish(),TotalEventsInChain:zod.z.number().nullish()}).passthrough(),Hl=zod.z.object({ActiveEvents:zod.z.array(Fg).nullish()}).passthrough(),$l=zod.z.object({Tokens:zod.z.record(zod.z.string(),Kl).nullish()}),zn=zod.z.object({Type:Xt.nullish(),LteID:zod.z.string().nullish(),Resources:v.nullish()}),Pn=zod.z.object({Type:Xt.nullish(),LteID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Rewards:v.nullish()}),Vg=zod.z.object({Type:Xt.nullish(),LteID:zod.z.string().nullish(),Resources:v.nullish()}),vn=zod.z.array(ae(Pn)),Zl=zod.z.array(ae(zn)),Jl=zod.z.array(ae(Vg)),Qe={GetActiveEvents:"GetActiveEvents",GrantTokens:"GrantTokens",SpendTokens:"SpendTokens",ClaimMilestone:"ClaimMilestone",GetDefinitions:"GetDefinitions",GetUserLteState:"GetUserLteState",ClaimMilestonesBatch:"ClaimMilestonesBatch",ClaimAllMilestones:"ClaimAllMilestones",SpendTokensBatch:"SpendTokensBatch",GrantTokensBatch:"GrantTokensBatch"};var Fr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"TimedEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getActiveEvents(e){return this.send(Qe.GetActiveEvents,e,Hl)}getDefinitions(e){return this.send(Qe.GetDefinitions,e,jr)}getUserLteState(e){return this.send(Qe.GetUserLteState,e,$l)}grantTokens(e){return this.send(Qe.GrantTokens,e,v)}spendTokens(e){return this.send(Qe.SpendTokens,e,zn)}claimMilestone(e){return this.send(Qe.ClaimMilestone,e,Pn)}claimMilestonesBatch(e){return this.send(Qe.ClaimMilestonesBatch,e,vn)}claimAllMilestones(e){return this.send(Qe.ClaimAllMilestones,e,vn)}spendTokensBatch(e){return this.send(Qe.SpendTokensBatch,e,Zl)}grantTokensBatch(e){return this.send(Qe.GrantTokensBatch,e,Jl)}};var _g=zod.z.object({UserID:zod.z.string(),Score:B.nullish(),Rank:zod.z.number().nullish(),LastScoreUpdateUtc:u.nullish(),IpHash:zod.z.string().nullish(),PublicProfile:Se.nullish(),SeasonTierAtCycleEnd:zod.z.number().nullish()}).passthrough(),ii=zod.z.object({LeaderboardID:zod.z.string(),CycleVersion:zod.z.number().nullish(),TotalParticipants:B.nullish(),CycleEndUtc:u.nullish(),TopUsers:zod.z.array(_g).nullish(),BracketID:zod.z.string().nullish()}),Wg=zod.z.object({CycleKey:zod.z.string().nullish(),CycleEndUtc:u.nullish(),ClaimDeadlineUtc:u.nullish(),MilestoneTokensEarned:B.nullish(),ClaimableMilestoneIDs:zod.z.array(zod.z.string()).nullish(),CycleIndex:zod.z.number().nullish(),ChainedEventID:zod.z.string().nullish()}).passthrough(),Vr=zod.z.object({LeaderboardID:zod.z.string(),CurrentScore:B.nullish(),LastKnownRank:zod.z.number().nullish(),HasUnclaimedReward:zod.z.boolean().nullish(),ScoreEarnedThisCycle:B.nullish(),MilestoneTokensEarned:B.nullish(),NextMilestone:Te.nullish(),HasUnclaimedMilestone:zod.z.boolean().nullish(),ClaimableGraceCycles:zod.z.array(Wg).nullish()}),_r=zod.z.object({LeaderboardID:zod.z.string(),NewScore:B,CycleVersion:zod.z.number()}),Wr=zod.z.object({ServerTimeUtc:u,LeaderboardID:zod.z.string(),Rank:zod.z.number().nullish(),Resources:v.nullish()}),Qr=zod.z.object({ServerTimeUtc:u,LeaderboardID:zod.z.string(),MilestoneID:zod.z.string(),Resources:v.nullish()}),Yl=zod.z.array(ae(ii)),Xl=zod.z.array(ae(Vr)),eu=zod.z.array(ae(Wr)),tu=zod.z.array(ae(Qr)),iu=zod.z.array(ae(_r)),Qg=zod.z.object({LeaderboardID:zod.z.string(),CycleReward:ae(Wr).nullish(),Milestones:zod.z.array(ae(Qr)).nullish()}),ru=zod.z.array(Qg),Kg=zod.z.object({LeaderboardID:zod.z.string(),Leaderboard:ae(ii).nullish(),Progress:ae(Vr).nullish()}),su=zod.z.array(Kg),Hg=zod.z.string(),nu=zod.z.object({Rank:zod.z.string().nullish(),Rewards:G.nullish(),SeasonTierRewards:Ms.nullish()}).passthrough(),$g=zod.z.object({RankRewards:zod.z.array(nu).nullish()}).passthrough(),Zg=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Jg=zod.z.object({Milestones:K.nullish(),RankRewards:K.nullish()}).passthrough(),Yg=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:Hg.nullish(),Schedule:re.nullish(),ChainEvents:zod.z.array(Zg).nullish(),Gate:_.nullish(),TopUsersLimit:zod.z.number().nullish(),MinScoreToEnterTop:zod.z.number().nullish(),BracketSize:zod.z.number().nullish(),LinkedSeasonChainID:zod.z.string().nullish(),RankRewards:zod.z.array(nu).nullish(),Milestones:zod.z.record(zod.z.string(),Te).nullish(),Presets:Jg.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneClaimGraceHours:zod.z.number().nullish(),ScoreSources:zod.z.array(Ne).nullish()}).passthrough(),Xg=zod.z.object({Milestones:zod.z.record(zod.z.string(),Et).nullish(),RankRewards:zod.z.record(zod.z.string(),$g).nullish()}).passthrough(),Kr=zod.z.object({Definitions:zod.z.record(zod.z.string(),Yg).nullish(),Presets:Xg.nullish()}).passthrough(),ve={GetDefinitions:"GetDefinitions",GetLeaderboard:"GetLeaderboard",GetMyProgress:"GetMyProgress",SubmitScore:"SubmitScore",SubmitScoreFromSource:"SubmitScoreFromSource",ClaimCycleReward:"ClaimCycleReward",ClaimMilestone:"ClaimMilestone",GetFriendsLeaderboard:"GetFriendsLeaderboard",GetLeaderboardsBatch:"GetLeaderboardsBatch",GetProgressBatch:"GetProgressBatch",ClaimCycleRewardsBatch:"ClaimCycleRewardsBatch",ClaimMilestonesBatch:"ClaimMilestonesBatch",SubmitScoresBatch:"SubmitScoresBatch",ClaimAllRewardsBatch:"ClaimAllRewardsBatch",GetOverviewBatch:"GetOverviewBatch"};var Hr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Leaderboard",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(ve.GetDefinitions,e,Kr)}getLeaderboard(e){return this.send(ve.GetLeaderboard,e,ii)}getMyProgress(e){return this.send(ve.GetMyProgress,e,Vr)}submitScore(e){return this.send(ve.SubmitScore,e,_r)}submitScoreFromSource(e){return this.send(ve.SubmitScoreFromSource,e,_r)}claimCycleReward(e){return this.send(ve.ClaimCycleReward,e,Wr)}claimMilestone(e){return this.send(ve.ClaimMilestone,e,Qr)}getFriendsLeaderboard(e){return this.send(ve.GetFriendsLeaderboard,e,ii)}getLeaderboardsBatch(e){return this.send(ve.GetLeaderboardsBatch,e,Yl)}getProgressBatch(e){return this.send(ve.GetProgressBatch,e,Xl)}claimCycleRewardsBatch(e){return this.send(ve.ClaimCycleRewardsBatch,e,eu)}claimMilestonesBatch(e){return this.send(ve.ClaimMilestonesBatch,e,tu)}submitScoresBatch(e){return this.send(ve.SubmitScoresBatch,e,iu)}claimAllRewardsBatch(e){return this.send(ve.ClaimAllRewardsBatch,e,ru)}getOverviewBatch(e){return this.send(ve.GetOverviewBatch,e,su)}};var Tn=zod.z.object({}).passthrough().transform(o=>o),ou=zod.z.object({SeasonChainID:zod.z.string(),CycleIndex:zod.z.number().nullish(),Season:zod.z.lazy(()=>cu).nullish(),ComputedStartUtc:u.nullish(),ComputedEndUtc:u.nullish(),SecondsRemaining:B.nullish(),UserState:Tn.nullish(),NextTier:zod.z.lazy(()=>uu).nullish()}).passthrough(),au=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),AmountGranted:B.nullish(),NewStatusTokens:B.nullish(),OldTier:zod.z.number().nullish(),NewTier:zod.z.number(),TierUp:zod.z.boolean().nullish()}),In=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),TierNumber:zod.z.number(),Resources:v.nullish()}),lu=rt(In);var uu=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:B.nullish(),TierReachedReward:G.nullish()}).passthrough(),cu=zod.z.object({SeasonID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:B.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(uu).nullish(),LinkedCollectionID:zod.z.string().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough();var ey=zod.z.object({SeasonChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:re.nullish(),Seasons:zod.z.array(cu).nullish(),GrantTokensAccessMode:zod.z.string().nullish(),Gate:_.nullish()}).passthrough(),$r=zod.z.object({Chains:zod.z.record(zod.z.string(),ey).nullish()}).passthrough(),St={GetDefinitions:"GetDefinitions",GetActiveSeason:"GetActiveSeason",GetUserState:"GetUserState",GrantStatusTokens:"GrantStatusTokens",ClaimTierReward:"ClaimTierReward",ClaimTierRewardsBatch:"ClaimTierRewardsBatch"};var Zr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Season",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(St.GetDefinitions,e,$r)}getActiveSeason(e){return this.send(St.GetActiveSeason,e,ou)}getUserState(e){return this.send(St.GetUserState,e,Tn)}grantStatusTokens(e){return this.send(St.GrantStatusTokens,e,au)}claimTierReward(e){return this.send(St.ClaimTierReward,e,In)}claimTierRewardsBatch(e){return this.send(St.ClaimTierRewardsBatch,e,lu)}};var ty={Apple:"Apple",Google:"Google"},pu=zod.z.object({}).passthrough().transform(o=>o),iy=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(),ry=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:ee.nullish(),Benefits:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),kn=zod.z.object({Definitions:zod.z.record(zod.z.string(),ry).nullish()}).passthrough(),du=zod.z.object({Premium:kn.nullish()}),hu=zod.z.object({ServerTimeUtc:u.nullish(),Premium:pu.nullish()}),Jr=zod.z.object({ServerTimeUtc:u.nullish(),Premium:pu.nullish(),Subscription:iy.nullish(),Resources:v.nullish()}),It={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateTrial:"ActivateTrial",PurchaseWithResources:"PurchaseWithResources",PurchaseRealMoney:"PurchaseRealMoney"};var Yr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Premium",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(It.GetDefinitions,e,du)}getUserState(e){return this.send(It.GetUserState,e,hu)}activateTrial(e){return this.send(It.ActivateTrial,e,Jr)}purchaseItemOrCurrency(e){return this.send(It.PurchaseWithResources,e,Jr)}purchaseRealMoney(e){return this.send(It.PurchaseRealMoney,e,Jr)}};var Xr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Character",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getCharacterDefinitions(e){return this.send(qe.GetCharacterDefinitions,e,pr)}getUserCharacters(e){return this.send(qe.GetUserCharacters,e,na)}unlockCharacter(e){return this.send(qe.UnlockCharacter,e,Ys)}upgradeStatLevel(e){return this.send(qe.UpgradeStatLevel,e,Zs)}upgradeCharacterLevel(e){return this.send(qe.UpgradeCharacterLevel,e,Js)}equipItems(e){return this.send(qe.EquipItems,e,oa)}unequipItems(e){return this.send(qe.UnequipItems,e,aa)}unequipAllCharacters(e){return this.send(qe.UnequipAllCharacters,e,la)}unlockCharactersBatch(e){return this.send(qe.UnlockCharactersBatch,e,ua)}upgradeCharacterLevelsBatch(e){return this.send(qe.UpgradeCharacterLevelsBatch,e,ca)}upgradeStatLevelsBatch(e){return this.send(qe.UpgradeStatLevelsBatch,e,pa)}};var es=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Match",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}createMatch(e){return this.send(nt.CreateMatch,e,Ba)}updateMatch(e){return this.send(nt.UpdateMatch,e,La)}cancelMatch(e){return this.send(nt.CancelMatch,e,qa)}instantBattle(e){return this.send(nt.InstantBattle,e,Ea)}saveStrategy(e){return this.send(nt.SaveStrategy,e,be)}getMyMatches(e){return this.send(nt.GetMyMatches,e,on)}getAvailableMatches(e){return this.send(nt.GetAvailableMatches,e,on)}getDefinitions(e){return this.send(nt.GetDefinitions,e,Fa)}};var sy={TradeUpRarity:"TradeUpRarity",TradeUpCollection:"TradeUpCollection"},mu=zod.z.enum(["TradeUpRarity","TradeUpCollection"]).catch("TradeUpRarity"),ny=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:ws.nullish()}),fu=zod.z.object({ServerTimeUtc:u,Type:mu.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:v.nullish(),Results:zod.z.array(ny).nullish()}),oy=zod.z.object({CraftID:zod.z.string().nullish(),Type:mu.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:ee.nullish()}).passthrough(),wn=zod.z.object({Definitions:zod.z.record(zod.z.string(),oy).nullish()}).passthrough(),gu=zod.z.object({ServerTimeUtc:u.nullish(),CraftDefinitions:wn.nullish()}),ts={GetDefinitions:"GetDefinitions",Craft:"Craft"};var is=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Craft",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(ts.GetDefinitions,e,gu)}craft(e){return this.send(ts.Craft,e,fu)}};var ay={Pending:"Pending",Accepted:"Accepted",Declined:"Declined",Cancelled:"Cancelled",Expired:"Expired"},ly=zod.z.enum(["Pending","Accepted","Declined","Cancelled","Expired"]).catch("Pending"),yu=zod.z.object({}).passthrough().transform(o=>o),Ht=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()}),Ru=zod.z.object({GrantedCollectibles:zod.z.array(Ht).nullish(),DuplicateCollectibles:zod.z.array(Ht).nullish(),CollectionCurrencyEarned:B.nullish()}),Cu=zod.z.object({OpenedCount:zod.z.number().nullish(),Packs:zod.z.array(Ru).nullish(),GrantedCollectibles:zod.z.array(Ht).nullish(),DuplicateCollectibles:zod.z.array(Ht).nullish(),CollectionCurrencyEarned:B.nullish(),NewCollectionCurrencyBalance:B.nullish(),NewlyCompletedSetIDs:zod.z.array(zod.z.string()).nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:v.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),Su=zod.z.object({OpenedCount:zod.z.number().nullish(),Chests:zod.z.array(Ru).nullish(),GrantedCollectibles:zod.z.array(Ht).nullish(),DuplicateCollectibles:zod.z.array(Ht).nullish(),CollectionCurrencyEarned:B.nullish(),NewCollectionCurrencyBalance:B.nullish(),Resources:v.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),xu=zod.z.object({GrantedCollectibleID:zod.z.string().nullish(),NewlyCompletedSetID:zod.z.string().nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:v.nullish()}),Mn=zod.z.object({SetID:zod.z.string(),Resources:v.nullish()}),bu=zod.z.array(ae(Mn)),Du=zod.z.object({Resources:v.nullish()}),uy=zod.z.object({OfferID:zod.z.string(),TitleID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderPublicData:Se.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:ly.nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),RespondedAtUtc:u.nullish(),DeclineReason:zod.z.string().nullish(),IsSpecialTradeEvent:zod.z.boolean().nullish(),SpecialTradeEventID:zod.z.string().nullish()}).passthrough(),zu=zod.z.object({OfferID:zod.z.string(),ExpiresAtUtc:u.nullish(),Resources:v.nullish()}),Pu=zod.z.object({OfferID:zod.z.string(),Resources:v.nullish()}),vu=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()}),Tu=zod.z.object({OfferID:zod.z.string(),Resources:v.nullish()}),An=zod.z.object({Offers:zod.z.array(uy).nullish()}),cy=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(),py=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(cy).nullish(),SetCompletionReward:G.nullish()}).passthrough(),dy=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(py).nullish(),GrandPrize:G.nullish()}).passthrough(),Iu=zod.z.object({BonusRewardSlots:K.nullish(),PityRules:K.nullish()}).passthrough(),hy=zod.z.object({PackTypeID:zod.z.string().nullish(),PriceOptions:ee.nullish(),BonusRewardSlots:zod.z.array(Wt).nullish(),PityRules:zod.z.array(Qt).nullish(),Presets:Iu.nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CollectibleCount:zod.z.number().nullish(),MaxOpenCount:zod.z.number().nullish(),GuaranteedMinRarity:zod.z.number().nullish(),GuaranteeMaxRarity:zod.z.boolean().nullish(),RarityWeights:zod.z.record(zod.z.string(),zod.z.number()).nullish(),ColorTier:zod.z.number().nullish()}).passthrough(),my=zod.z.object({Rarity:zod.z.number().nullish(),CollectionCurrencyGranted:zod.z.number().nullish()}).passthrough(),fy=zod.z.object({CollectionChestID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CollectionCurrencyCost:zod.z.number().nullish(),MaxOpenCount:zod.z.number().nullish(),MinCollectibleCount:zod.z.number().nullish(),MaxCollectibleCount:zod.z.number().nullish(),GuaranteedMinRarity:zod.z.number().nullish(),BonusRewardSlots:zod.z.array(Wt).nullish(),PityRules:zod.z.array(Qt).nullish(),Presets:Iu.nullish(),Tier:zod.z.number().nullish()}).passthrough(),gy=zod.z.object({SpecialTradeEventID:zod.z.string().nullish(),StartUtc:u.nullish(),EndUtc:u.nullish(),AllowedSpecialCollectibleIDs:zod.z.array(zod.z.string()).nullish(),SpecialTradeEventDailyTradeLimit:zod.z.number().nullish()}).passthrough(),rs=zod.z.object({Collections:zod.z.record(zod.z.string(),dy).nullish(),PackTypes:zod.z.record(zod.z.string(),hy).nullish(),CollectionChests:zod.z.array(fy).nullish(),DuplicateConversions:zod.z.array(my).nullish(),DailyTradeLimit:zod.z.number().nullish(),CollectibleJokerCatalogID:zod.z.string().nullish(),CollectibleJokerItemID:zod.z.string().nullish(),SpecialTradeEvents:zod.z.array(gy).nullish(),RewardPools:wr.nullish()}).passthrough(),Ie={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 ss=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Collection",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ie.GetDefinitions,e,rs)}getUserState(e){return this.send(Ie.GetUserState,e,yu)}openPack(e){return this.send(Ie.OpenPack,e,Cu)}openCollectionChest(e){return this.send(Ie.OpenCollectionChest,e,Su)}useCollectibleJoker(e){return this.send(Ie.UseCollectibleJoker,e,xu)}claimSetReward(e){return this.send(Ie.ClaimSetReward,e,Mn)}claimSetRewardsBatch(e){return this.send(Ie.ClaimSetRewardsBatch,e,bu)}claimGrandPrize(e){return this.send(Ie.ClaimGrandPrize,e,Du)}sendTradeOffer(e){return this.send(Ie.SendTradeOffer,e,zu)}cancelTradeOffer(e){return this.send(Ie.CancelTradeOffer,e,Pu)}acceptTradeOffer(e){return this.send(Ie.AcceptTradeOffer,e,vu)}declineTradeOffer(e){return this.send(Ie.DeclineTradeOffer,e,Tu)}getMyTradeOffers(e){return this.send(Ie.GetMyTradeOffers,e,An)}getIncomingTradeOffers(e){return this.send(Ie.GetIncomingTradeOffers,e,An)}};var yy=zod.z.object({}).passthrough().transform(o=>o),Ry={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},Cy={Active:"Active",Left:"Left",Replaced:"Replaced"},Sy=zod.z.object({ObjectIndex:zod.z.number().nullish(),ObjectCompletionRewardClaimed:zod.z.boolean().nullish()}).passthrough(),xy=zod.z.object({UserID:zod.z.string().nullish(),PublicData:Se.nullish(),BuildObjectsProgress:Sy.nullish(),IsBot:zod.z.boolean().nullish(),SpinsCount:zod.z.number().nullish(),TokensSpent:zod.z.number().nullish(),MemberStatus:zod.z.string().nullish(),GrandPrizeClaimed:zod.z.boolean().nullish(),JoinedAtUtc:u.nullish(),LeftAtUtc:u.nullish()}).passthrough(),by=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(),Dy=zod.z.object({Objects:zod.z.array(by).nullish()}).passthrough(),ku=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(xy).nullish(),BuildObjectsState:Dy.nullish(),Status:zod.z.string().nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),Version:zod.z.number().nullish()}).passthrough(),wu=zod.z.object({CoopChainID:zod.z.string()}).passthrough(),zy=zod.z.string(),On=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(),Py=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(),vy=zod.z.object({Objects:zod.z.array(Py).nullish(),PriceOptions:ee.nullish(),SpinnerTable:zod.z.array(On).nullish(),MaxSpinsPerCall:zod.z.number().nullish()}).passthrough(),Ty=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:zy.nullish(),PartnerCount:zod.z.number().nullish(),MatchmakingTimeoutMinutes:zod.z.number().nullish(),MemberGracePeriodMinutes:zod.z.number().nullish(),BuildObjects:vy.nullish(),GrandPrize:G.nullish()}).passthrough(),Iy=zod.z.object({CoopChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:re.nullish(),Events:zod.z.array(Ty).nullish(),Gate:_.nullish()}).passthrough(),Mu=zod.z.object({ServerTimeUtc:u.nullish(),UserState:yy.nullish(),ActiveGroup:ku.nullish()}),Un=zod.z.object({ServerTimeUtc:u.nullish(),Group:ku.nullish(),SecondsRemaining:B.nullish()}),Au=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Resources:v.nullish(),ObjectIndex:zod.z.number().nullish(),Sector:On.nullish(),RequestedSpins:zod.z.number().nullish(),SpinsUsed:zod.z.number().nullish(),Sectors:zod.z.array(On).nullish(),ProgressDelta:zod.z.number().nullish(),NewProgress:B.nullish(),MaxProgress:B.nullish(),ObjectCompleted:zod.z.boolean().nullish(),AllObjectsCompleted:zod.z.boolean().nullish()}),Bn=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),Resources:v.nullish()}),Ou=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),ns=zod.z.object({Chains:zod.z.record(zod.z.string(),Iy).nullish()}).passthrough(),Ye={GetDefinitions:"GetDefinitions",GetActiveEvent:"GetActiveEvent",GetUserState:"GetUserState",GetGroupState:"GetGroupState",JoinOrCreateGroup:"JoinOrCreateGroup",Spin:"Spin",ClaimObjectReward:"ClaimObjectReward",ClaimGrandPrize:"ClaimGrandPrize",LeaveGroup:"LeaveGroup"};var os=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"CoopEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ye.GetDefinitions,e,ns)}getActiveEvent(e){return this.send(Ye.GetActiveEvent,e,wu)}getUserState(e){return this.send(Ye.GetUserState,e,Mu)}getGroupState(e){return this.send(Ye.GetGroupState,e,Un)}joinOrCreateGroup(e){return this.send(Ye.JoinOrCreateGroup,e,Un)}spin(e){return this.send(Ye.Spin,e,Au)}claimObjectReward(e){return this.send(Ye.ClaimObjectReward,e,Bn)}claimGrandPrize(e){return this.send(Ye.ClaimGrandPrize,e,Bn)}leaveGroup(e){return this.send(Ye.LeaveGroup,e,Ou)}};var ky={Active:"Active",Exhausted:"Exhausted",Expired:"Expired",Dismissed:"Dismissed"},wy={Locked:"Locked",Available:"Available",InProgress:"InProgress",Completed:"Completed",Hidden:"Hidden"},My=zod.z.object({NodeID:zod.z.string().nullish(),Status:zod.z.string().nullish(),ExecutionCount:zod.z.number().nullish(),UnlockedAtUtc:u.nullish(),CompletedAtUtc:u.nullish(),LastExecutedAtUtc:u.nullish(),NextAvailableAtUtc:u.nullish(),LastExecutionRefID:zod.z.string().nullish()}).passthrough(),Ay=zod.z.object({TrackID:zod.z.string().nullish(),CurrentValue:zod.z.number().nullish(),LastUpdatedUtc:u.nullish()}).passthrough(),Uu=zod.z.object({OfferID:zod.z.string().nullish(),InstanceKey:zod.z.string().nullish(),SourceOfferVersion:zod.z.number().nullish(),Status:zod.z.string().nullish(),ActivatedAtUtc:u.nullish(),ExhaustedAtUtc:u.nullish(),ExpiredAtUtc:u.nullish(),DismissedAtUtc:u.nullish(),ShowCount:zod.z.number().nullish(),LastShownAtUtc:u.nullish(),Nodes:zod.z.record(zod.z.string(),My).nullish(),Tracks:zod.z.record(zod.z.string(),Ay).nullish(),SelectedChoiceNodeID:zod.z.string().nullish()}).passthrough(),Oy=zod.z.object({SlotID:zod.z.string().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),ActiveOfferID:zod.z.string().nullish(),ActiveOfferStartedAtUtc:u.nullish(),ActiveOfferExpiresAtUtc:u.nullish(),ActiveOffer:Uu.nullish(),NextCycleStartsAtUtc:u.nullish(),LastUpdatedUtc:u.nullish(),DismissSkipAvailableAtUtc:u.nullish(),LastDismissedAtUtc:u.nullish()}).passthrough(),Uy=zod.z.object({TotalExecutions:zod.z.number().nullish(),DailyExecutions:zod.z.number().nullish(),DailyResetUtc:u.nullish()}).passthrough(),By=zod.z.object({TotalActivations:zod.z.number().nullish(),TotalExhausted:zod.z.number().nullish(),TotalExpired:zod.z.number().nullish(),TotalDismissed:zod.z.number().nullish(),TotalShows:zod.z.number().nullish(),LastShownAtUtc:u.nullish(),LastActivatedAtUtc:u.nullish(),LastExhaustedAtUtc:u.nullish(),NodeCounts:zod.z.record(zod.z.string(),Uy).nullish()}).passthrough(),Ly=zod.z.object({Slots:zod.z.record(zod.z.string(),Oy).nullish(),OfferHistory:zod.z.record(zod.z.string(),By).nullish(),LastUpdatedUtc:u.nullish()}).passthrough(),qy={Purchase:"Purchase",FreeClaim:"FreeClaim",RewardedVideo:"RewardedVideo",Info:"Info"},Ey={Eq:"Eq",Gte:"Gte",Lte:"Lte"},Gy=zod.z.object({Order:zod.z.number().nullish(),OfferID:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),DelayBeforeActivationSec:zod.z.number().nullish()}).passthrough(),as=zod.z.object({DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),Tags: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()}).passthrough(),Bu=zod.z.object({Schedule:re.nullish(),Gate:_.nullish()}).passthrough(),Lu=zod.z.object({AllowDismissSkip:zod.z.boolean().nullish(),DismissSkipDelaySec:zod.z.number().nullish()}).passthrough(),Ny=zod.z.object({Identity:K.nullish(),Availability:K.nullish(),Behaviour:K.nullish()}).passthrough(),jy=zod.z.object({SlotID:zod.z.string().nullish(),Enabled:zod.z.boolean().nullish(),Identity:as.nullish(),Availability:Bu.nullish(),Behaviour:Lu.nullish(),Queue:zod.z.array(Gy).nullish(),Presets:Ny.nullish()}).passthrough(),Fy=zod.z.object({ViewsRequiredToComplete:zod.z.number().nullish(),MaxViewsPerActivation:zod.z.number().nullish(),GrantRewardsPerView:zod.z.boolean().nullish()}).passthrough(),Vy=zod.z.object({RewardedVideo:Fy.nullish()}).passthrough(),_y=zod.z.object({TrackID:zod.z.string().nullish(),Operator:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),Wy=zod.z.object({Identity:K.nullish(),Graph:K.nullish(),Milestones:K.nullish()}).passthrough(),Qy=zod.z.object({Identity:K.nullish(),Pricing:K.nullish(),Reward:K.nullish()}).passthrough(),Ky=zod.z.object({TrackID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),RespectBounds:zod.z.boolean().nullish()}).passthrough(),Hy=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(),$y=zod.z.object({RequiredCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredAnyCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredTracks:zod.z.array(_y).nullish(),VisibleWhileLocked:zod.z.boolean().nullish()}).passthrough(),qu=zod.z.object({Options:ee.nullish()}).passthrough(),Eu=zod.z.object({Grants:G.nullish(),TrackChanges:zod.z.array(Ky).nullish(),MilestonePoints:zod.z.number().nullish()}).passthrough(),Zy=zod.z.object({NodeID:zod.z.string().nullish(),Type:zod.z.string().nullish(),Identity:as.nullish(),Pricing:qu.nullish(),Reward:Eu.nullish(),Action:Vy.nullish(),UnlockRules:$y.nullish(),NextNodeIDs:zod.z.array(zod.z.string()).nullish(),ChoiceGroupID:zod.z.string().nullish(),Limits:ie.nullish(),HideWhenCompleted:zod.z.boolean().nullish(),ExhaustOfferOnComplete:zod.z.boolean().nullish(),Presets:Qy.nullish()}).passthrough(),Gu=zod.z.object({RootNodeIDs:zod.z.array(zod.z.string()).nullish(),Nodes:zod.z.array(Zy).nullish(),Tracks:zod.z.array(Hy).nullish(),ExhaustedWhenAllTerminalNodesCompleted:zod.z.boolean().nullish()}).passthrough(),Nu=zod.z.object({Milestones:zod.z.record(zod.z.string(),Te).nullish(),ClaimMode:zod.z.string().nullish(),Token:zt.nullish()}).passthrough(),ju=zod.z.object({OfferID:zod.z.string().nullish(),Version:zod.z.number().nullish(),Enabled:zod.z.boolean().nullish(),Identity:as.nullish(),Graph:Gu.nullish(),Milestones:Nu.nullish(),Presets:Wy.nullish()}).passthrough(),Jy=zod.z.object({Identity:zod.z.record(zod.z.string(),as).nullish(),Availability:zod.z.record(zod.z.string(),Bu).nullish(),Behaviour:zod.z.record(zod.z.string(),Lu).nullish(),Graph:zod.z.record(zod.z.string(),Gu).nullish(),Milestones:zod.z.record(zod.z.string(),Nu).nullish(),Pricing:zod.z.record(zod.z.string(),qu).nullish(),Reward:zod.z.record(zod.z.string(),Eu).nullish()}).passthrough(),Ln=zod.z.object({Slots:zod.z.record(zod.z.string(),jy).nullish(),Offers:zod.z.record(zod.z.string(),ju).nullish(),Presets:Jy.nullish()}).passthrough(),Fu=zod.z.object({DealOfferDefinitions:Ln.nullish()}),Vu=zod.z.object({DealOffers:Ly.nullish()}),Yy=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(),Xy=zod.z.object({SlotID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),OfferDef:ju.nullish(),ActivationState:Uu.nullish(),IsNewActivation:zod.z.boolean().nullish(),ComputedExpiresAtUtc:u.nullish(),Cost:lt.nullish(),Milestone:Yy.nullish()}).passthrough(),_u=zod.z.object({Slots:zod.z.array(Xy).nullish()}),Wu=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),NodeID:zod.z.string().nullish(),NodeCompleted:zod.z.boolean().nullish(),OfferExhausted:zod.z.boolean().nullish(),Idempotent:zod.z.boolean().nullish(),Resources:v.nullish()}),Qu=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),Resources:v.nullish()}),Ku=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),Resources:v.nullish()}),Hu=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:v.nullish()}),$u=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),ClaimedIDs:zod.z.array(zod.z.string()).nullish(),Rejected:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Resources:v.nullish()}),ot={GetDefinition:"GetDefinition",GetUserState:"GetUserState",GetActiveDeals:"GetActiveDeals",DismissDeal:"DismissDeal",ExecuteNode:"ExecuteNode",RecordShow:"RecordShow",ClaimMilestone:"ClaimMilestone",ClaimMilestonesBatch:"ClaimMilestonesBatch"};var ls=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"DealOffer",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinition(e){return this.send(ot.GetDefinition,e,Fu)}getUserState(e){return this.send(ot.GetUserState,e,Vu)}getActiveDeals(e){return this.send(ot.GetActiveDeals,e,_u)}dismissDeal(e){return this.send(ot.DismissDeal,e,Qu)}executeNode(e){return this.send(ot.ExecuteNode,e,Wu)}recordShow(e){return this.send(ot.RecordShow,e,Ku)}claimMilestone(e){return this.send(ot.ClaimMilestone,e,Hu)}claimMilestonesBatch(e){return this.send(ot.ClaimMilestonesBatch,e,$u)}};var eR=zod.z.object({}).passthrough().transform(o=>o),tR=zod.z.object({FeatureKey:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Rate:zod.z.number().nullish(),Basis:zod.z.string().nullish(),SourceCurrencyID:zod.z.string().nullish(),TargetCurrencyID:zod.z.string().nullish(),MinSourceAmount:zod.z.number().nullish(),MaxRewardPerOperation:zod.z.number().nullish(),Limits:ie.nullish()}).passthrough(),qn=zod.z.object({IsEnabled:zod.z.boolean().nullish(),ActivationReward:G.nullish(),InviteRewards:zod.z.record(zod.z.string(),Te).nullish(),SpendRewards:zod.z.array(tR).nullish()}).passthrough(),Zu=zod.z.object({ReferralDefinitions:qn.nullish()}).passthrough(),Ju=zod.z.object({Referral:eR.nullish(),InviteUrl:zod.z.string().nullish()}).passthrough(),Yu=zod.z.object({ReferralCode:zod.z.string().nullish(),ReferrerUserID:zod.z.string().nullish(),IsFirstActivation:zod.z.boolean().nullish(),Resources:v.nullish()}).passthrough(),En=zod.z.object({RewardID:zod.z.string().nullish(),Resources:v.nullish()}).passthrough(),Xu=rt(En),kt={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateReferralCode:"ActivateReferralCode",ClaimInviteReward:"ClaimInviteReward",ClaimInviteRewardsBatch:"ClaimInviteRewardsBatch"};var us=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Referral",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(kt.GetDefinitions,e,Zu)}getUserState(e){return this.send(kt.GetUserState,e,Ju)}activateReferralCode(e){return this.send(kt.ActivateReferralCode,e,Yu)}claimInviteReward(e){return this.send(kt.ClaimInviteReward,e,En)}claimInviteRewardsBatch(e){return this.send(kt.ClaimInviteRewardsBatch,e,Xu)}};var iR={RequestSent:"RequestSent",Accepted:"Accepted",Declined:"Declined",Removed:"Removed"},rR={Attack:"Attack",Raid:"Raid",FriendAdd:"FriendAdd"},ec=zod.z.object({UserID:zod.z.string(),PublicData:Se.nullish()}),sR=zod.z.object({OwnerUserID:zod.z.string().nullish(),ActorUserID:zod.z.string().nullish(),ActorProfile:Se.nullish(),Type:zod.z.string().nullish(),CreatedAt:u.nullish(),OwnerImpact:v.nullish(),IsBlocked:zod.z.boolean().nullish(),TargetObjectName:zod.z.string().nullish()}).passthrough(),ri=zod.z.object({Friends:zod.z.array(ec).nullish()}),nR=zod.z.object({FriendsCount:zod.z.number().nullish(),IncomingRequestsCount:zod.z.number().nullish(),OutgoingRequestsCount:zod.z.number().nullish()}),si=zod.z.object({TargetUserID:zod.z.string().nullish(),Status:zod.z.string().nullish(),Target:ec.nullish(),Counters:nR.nullish()}),tc=zod.z.object({Events:zod.z.array(sR).nullish()}),Xe={GetFriendsList:"GetFriendsList",GetIncomingRequests:"GetIncomingRequests",GetOutgoingRequests:"GetOutgoingRequests",GetRecommendedFriends:"GetRecommendedFriends",SendFriendRequest:"SendFriendRequest",AcceptFriendRequest:"AcceptFriendRequest",DeclineFriendRequest:"DeclineFriendRequest",RemoveFriend:"RemoveFriend",GetTimeline:"GetTimeline"};var cs=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Social",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getFriendsList(e){return this.send(Xe.GetFriendsList,e,ri)}getIncomingRequests(e){return this.send(Xe.GetIncomingRequests,e,ri)}getOutgoingRequests(e){return this.send(Xe.GetOutgoingRequests,e,ri)}getRecommendedFriends(e){return this.send(Xe.GetRecommendedFriends,e,ri)}sendFriendRequest(e){return this.send(Xe.SendFriendRequest,e,si)}acceptFriendRequest(e){return this.send(Xe.AcceptFriendRequest,e,si)}declineFriendRequest(e){return this.send(Xe.DeclineFriendRequest,e,si)}removeFriend(e){return this.send(Xe.RemoveFriend,e,si)}getTimeline(e){return this.send(Xe.GetTimeline,e,tc)}};var oR={Replace:"Replace",Refresh:"Refresh",KeepBest:"KeepBest",Stack:"Stack"};var $t=zod.z.object({Target:zod.z.string().nullish(),Operation:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),aR=zod.z.object({BoostID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),PriceOptions:ee.nullish(),Effect:$t.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(),lR=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:re.nullish(),Effects:zod.z.array($t).nullish(),Gate:_.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),uR=zod.z.object({ChainedBoostID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Effects:zod.z.array($t).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),cR=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:re.nullish(),Phases:zod.z.array(uR).nullish(),Gate:_.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),pR=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(Ne).nullish(),Effects:zod.z.array($t).nullish(),DurationSeconds:zod.z.number().nullish(),Charges:zod.z.number().nullish(),StackingPolicy:zod.z.string().nullish(),MaxActiveInstances:zod.z.number().nullish(),Gate:_.nullish()}).passthrough(),dR=zod.z.object({MaxAddPercent:zod.z.number().nullish(),MaxMultiply:zod.z.number().nullish(),MaxAddFlat:zod.z.number().nullish()}).passthrough(),hR=zod.z.object({StackingCaps:zod.z.record(zod.z.string(),dR).nullish()}).passthrough(),ps=zod.z.object({Definitions:zod.z.record(zod.z.string(),aR).nullish(),ScheduledBoosts:zod.z.record(zod.z.string(),lR).nullish(),BoostChains:zod.z.record(zod.z.string(),cR).nullish(),TriggeredBoosts:zod.z.record(zod.z.string(),pR).nullish(),Settings:hR.nullish()}).passthrough(),ic=zod.z.object({InstanceID:zod.z.string(),BoostID:zod.z.string(),ActivatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),RemainingCharges:zod.z.number().nullish(),EffectSnapshot:$t.nullish(),SourceType:zod.z.string().nullish(),SourceRef:zod.z.string().nullish()}).passthrough();zod.z.object({Date:u.nullish(),DailyCount:zod.z.number().nullish(),LastFiredUtc:u.nullish()}).passthrough();var rc=zod.z.object({ServerTimeUtc:u.nullish(),Active:zod.z.record(zod.z.string(),ic).nullish()}),sc=zod.z.object({ServerTimeUtc:u.nullish(),BoostID:zod.z.string().nullish(),StackingPolicy:zod.z.string().nullish(),ActivatedBoost:ic.nullish(),Resources:v.nullish()}),mR={Scheduled:"Scheduled",Chain:"Chain"},fR=zod.z.object({Kind:zod.z.string().nullish(),SourceID:zod.z.string().nullish(),PhaseID:zod.z.string().nullish(),CycleIndex:zod.z.number().nullish(),PhaseOrder:zod.z.number().nullish(),StartUtc:u.nullish(),EndUtc:u.nullish(),Effects:zod.z.array($t).nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),nc=zod.z.object({ServerTimeUtc:u.nullish(),Windows:zod.z.array(fR).nullish()}),wt={GetDefinitions:"GetDefinitions",GetActive:"GetActive",GetActiveWindows:"GetActiveWindows",Activate:"Activate",CleanupExpired:"CleanupExpired"};var ds=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"TimedBoost",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(wt.GetDefinitions,e,ps)}getActive(e){return this.send(wt.GetActive,e,rc)}getActiveWindows(e){return this.send(wt.GetActiveWindows,e,nc)}activate(e){return this.send(wt.Activate,e,sc)}cleanupExpired(e){return this.send(wt.CleanupExpired,e,be)}};var hs=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"UserCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getUserCustomDataDefinitions(e){return this.send(Je.GetUserCustomDataDefinitions,e,rr)}getMyUserCustomData(e){return this.send(Je.GetMyUserCustomData,e,Qo)}getPublicUserCustomDataOf(e){return this.send(Je.GetPublicUserCustomDataOf,e,Ws)}setPrivateData(e){return this.send(Je.SetPrivateData,e,Qs)}setPublicData(e){return this.send(Je.SetPublicData,e,Qs)}deleteKey(e){return this.send(Je.DeleteKey,e,be)}batchSet(e){return this.send(Je.BatchSet,e,Ko)}batchDelete(e){return this.send(Je.BatchDelete,e,Ho)}batchGetPublicUserCustomDataOf(e){return this.send(Je.BatchGetPublicUserCustomDataOf,e,$o)}};var gR={Static:"Static",Runtime:"Runtime"},yR={Public:"Public",Private:"Private"},RR=zod.z.enum(["Client","Server","System"]).catch("Client"),CR=zod.z.enum(["String","Int","Bool","Json"]).catch("String"),SR=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:u.nullish(),Version:zod.z.number().nullish(),LastWriter:RR.nullish(),ExpiresAt:u.nullish()}).passthrough(),oc=zod.z.record(zod.z.string(),SR),Gn=zod.z.object({StaticVersion:zod.z.number().nullish(),RuntimeVersion:zod.z.number().nullish(),Static:oc.nullish(),Runtime:oc.nullish(),NotModified:zod.z.boolean().nullish()}),xR=zod.z.object({KeyID:zod.z.string(),Scope:zod.z.enum(["Static","Runtime"]).catch("Static").nullish(),Bucket:zod.z.enum(["Public","Private"]).catch("Public").nullish(),ValueType:CR.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),ms=zod.z.object({Keys:zod.z.record(zod.z.string(),xR).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(),ni={GetTitleCustomDataDefinitions:"GetTitleCustomDataDefinitions",GetPublicTitleData:"GetPublicTitleData",GetPublicTitleDataKeys:"GetPublicTitleDataKeys"};var fs=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"TitleCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getTitleCustomDataDefinitions(e){return this.send(ni.GetTitleCustomDataDefinitions,e,ms)}getPublicTitleData(e){return this.send(ni.GetPublicTitleData,e,Gn)}getPublicTitleDataKeys(e){return this.send(ni.GetPublicTitleDataKeys,e,Gn)}};var bR={Fast:"Fast",Sequential:"Sequential"},DR={Instant:"Instant",Timed:"Timed"};var zR={Hit:"Hit",Blocked:"Blocked"},PR=zod.z.object({SlotIndex:zod.z.number(),Level:zod.z.number().nullish(),IsDamaged:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish()}).passthrough(),vR=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();var TR=zod.z.object({RequiredValue:zod.z.number().nullish(),Reward:G.nullish()}).passthrough(),IR=zod.z.object({Reward:G.nullish(),MetricPerReward:zod.z.number().nullish(),MaxRewardUnits:zod.z.number().nullish()}).passthrough();zod.z.object({MetricID:zod.z.string().nullish(),MaxValuePerClaim:zod.z.number().nullish(),TierMode:zod.z.string().nullish(),ApplyClaimMultiplier:zod.z.boolean().nullish(),Tiers:zod.z.array(TR).nullish(),Rate:IR.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 ac=zod.z.object({}).passthrough().transform(o=>o),lc=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),ke=zod.z.object({Operation:v.nullish(),ScaleWithRollMultiplier:zod.z.boolean().nullish()}).passthrough(),kR=zod.z.object({Count:zod.z.number().nullish(),Sides:zod.z.number().nullish()}).passthrough(),wR=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(),MR=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:Re.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(),AR=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:Re.nullish()}).passthrough(),uc=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(),OR=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(),UR=zod.z.object({Tiles:zod.z.record(zod.z.string(),OR).nullish()}).passthrough(),BR=zod.z.object({Weight:zod.z.number().nullish(),Bonus:ke.nullish(),Tag:zod.z.string().nullish()}).passthrough(),LR=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(BR).nullish(),GuaranteedBonus:ke.nullish(),IsJackpot:zod.z.boolean().nullish(),JackpotFinalMultiplier:zod.z.number().nullish(),JackpotSymbolDistribution:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough(),qR=zod.z.object({Variants:zod.z.array(LR).nullish()}).passthrough(),ER=zod.z.object({Weight:zod.z.number().nullish(),OutcomeID:zod.z.string().nullish(),Reward:ke.nullish(),ForceAction:zod.z.string().nullish(),SpecialModeID:zod.z.string().nullish()}).passthrough(),GR=zod.z.object({Outcomes:zod.z.array(ER).nullish()}).passthrough(),cc=zod.z.object({PerAdMultiplierRange:lc.nullish(),MaxAdViews:zod.z.number().nullish(),AdCreditCost:zod.z.number().nullish(),FormulaKind:zod.z.string().nullish(),ApplyMultiplierOnEarlyClaim:zod.z.boolean().nullish()}).passthrough(),NR=zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:ke.nullish()}).passthrough(),jR=zod.z.object({Tiers:zod.z.array(NR).nullish(),TierMode:zod.z.string().nullish(),BelowFirstTierReward:ke.nullish()}).passthrough(),FR=zod.z.object({RequiredValue:zod.z.number().nullish(),Reward:ke.nullish()}).passthrough(),VR=zod.z.object({Reward:ke.nullish(),MetricPerReward:zod.z.number().nullish(),MaxRewardUnits:zod.z.number().nullish()}).passthrough(),_R=zod.z.object({MetricID:zod.z.string().nullish(),MaxValuePerClaim:zod.z.number().nullish(),TierMode:zod.z.string().nullish(),ApplyClaimMultiplier:zod.z.boolean().nullish(),Tiers:zod.z.array(FR).nullish(),Rate:VR.nullish()}).passthrough(),pc=zod.z.object({MetricsByID:zod.z.record(zod.z.string(),_R).nullish()}).passthrough(),WR=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:ke.nullish(),DurationSeconds:zod.z.number().nullish(),PriceOptions:ee.nullish(),Multipliers:cc.nullish(),Gradation:jR.nullish(),RunStats:pc.nullish()}).passthrough(),QR=zod.z.object({Choices:zod.z.array(WR).nullish(),OfferExpireSeconds:zod.z.number().nullish(),ClaimExpireSeconds:zod.z.number().nullish()}).passthrough(),KR=zod.z.object({Chance:zod.z.number().nullish(),RequiredOutcome:zod.z.string().nullish(),Reward:ke.nullish(),Tag:zod.z.string().nullish()}).passthrough(),HR=zod.z.object({OnPassStart:ke.nullish(),OnTileLanding:zod.z.record(zod.z.string(),ke).nullish(),OnAttack:zod.z.record(zod.z.string(),ke).nullish(),OnRaid:zod.z.record(zod.z.string(),ke).nullish(),OnBuild:ke.nullish(),OnStageComplete:ke.nullish(),OnAttackBonusDrops:zod.z.array(KR).nullish(),ChanceTablesByID:zod.z.record(zod.z.string(),GR).nullish(),SpecialModesByID:zod.z.record(zod.z.string(),QR).nullish()}).passthrough(),dc=zod.z.object({BaseAttackReward:G.nullish(),BaseRaidReward:G.nullish(),MaxRollMultiplier:zod.z.number().nullish(),MaxShields:zod.z.number().nullish(),Buildings:zod.z.array(uc).nullish(),HeistGridBonusConfig:qR.nullish(),StageOperations:HR.nullish(),TileLandingMultiplier:lc.nullish(),EconomyOverride:AR.nullish()}).passthrough(),$R=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(uc).nullish(),StageTemplateID:zod.z.string().nullish(),CostMatrixTemplateID:zod.z.string().nullish(),UnitValue:zod.z.number().nullish(),Override:dc.nullish()}).passthrough(),gs=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(),UR).nullish(),StageTemplatesByID:zod.z.record(zod.z.string(),dc).nullish(),StagesByLevel:zod.z.record(zod.z.string(),$R).nullish(),SoftCurrencyID:zod.z.string().nullish(),ProceduralEconomy:MR.nullish(),Dice:kR.nullish(),Bots:wR.nullish()}).passthrough(),ZR=zod.z.object({IsActive:zod.z.boolean().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),AnchorUtc:u.nullish(),RoundDurationSec:zod.z.number().nullish(),PauseBetweenRoundsSec:zod.z.number().nullish(),MaxRounds:zod.z.number().nullish(),PartnerCount:zod.z.number().nullish(),MatchmakingTimeoutMinutes:zod.z.number().nullish(),MemberGracePeriodMinutes:zod.z.number().nullish(),ContributionMin:zod.z.number().nullish(),ContributionMax:zod.z.number().nullish(),ScaleContributionWithRollMultiplier:zod.z.boolean().nullish(),MaxProgress:zod.z.number().nullish(),Milestones:zod.z.record(zod.z.string(),Te).nullish(),GrandPrize:G.nullish()}).passthrough(),ys=zod.z.object({Board:gs.nullish(),CommunityChest:ZR.nullish()}).passthrough(),JR=zod.z.object({TargetUserID:zod.z.string().nullish(),IsBot:zod.z.boolean().nullish(),PublicData:Se.nullish(),TargetBuildingStates:zod.z.array(PR).nullish(),TargetHasShield:zod.z.boolean().nullish()}).passthrough(),YR=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:ke.nullish(),DurationSeconds:zod.z.number().nullish(),PriceOptions:ee.nullish(),Multipliers:cc.nullish(),RunStats:pc.nullish()}).passthrough(),XR=zod.z.object({ModeID:zod.z.string().nullish(),Choices:zod.z.array(YR).nullish()}).passthrough(),eC=zod.z.object({GroupID:zod.z.string().nullish(),Delta:B.nullish(),NewProgress:B.nullish(),MaxProgress:B.nullish(),UnlockedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),Completed:zod.z.boolean().nullish()}).passthrough(),hc=zod.z.object({UsedMultiplier:zod.z.number().nullish(),Steps:zod.z.number().nullish(),DiceValues:zod.z.array(zod.z.number()).nullish(),OldPosition:zod.z.number().nullish(),NewPosition:zod.z.number(),CyclesCompletedDelta:B.nullish(),LandedTileType:zod.z.string().nullish(),Operation:v.nullish(),ActionRequired:zod.z.string().nullish(),ActionData:JR.nullish(),SpecialModeOffer:XR.nullish(),CommunityChestContribution:eC.nullish()}).passthrough(),mc=zod.z.object({Outcome:zod.z.string().nullish(),IsBotTarget:zod.z.boolean().nullish(),BuildingIndexHit:zod.z.number().nullish(),Operation:v.nullish(),DualResult:Dt.nullish()}).passthrough(),Nn=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(vR).nullish(),HeistVariantTag:zod.z.string().nullish(),IsJackpot:zod.z.boolean().nullish(),Operation:v.nullish(),DualResult:Dt.nullish()}).passthrough(),fc=zod.z.object({BuiltIndex:zod.z.number(),NewLevel:zod.z.number().nullish(),StageComplete:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish(),Operation:v.nullish()}).passthrough(),gc=zod.z.object({Mode:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),Operation:v.nullish(),DurationSeconds:zod.z.number().nullish(),StartedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish()}).passthrough(),yc=zod.z.object({AdViewsUsed:zod.z.number().nullish(),RolledMultiplier:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),RemainingAdViews:zod.z.number().nullish()}).passthrough(),tC=zod.z.object({MetricID:zod.z.string().nullish(),ReachedTierIndex:zod.z.number().nullish(),RequiredValue:zod.z.number().nullish(),RewardUnits:zod.z.number().nullish()}).passthrough(),Rc=zod.z.object({FinalMultiplier:zod.z.number().nullish(),AdViewsUsed:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),IsEarlyClaim:zod.z.boolean().nullish(),ReachedTierIndex:zod.z.number().nullish(),Operation:v.nullish(),AcceptedRunStats:zod.z.record(zod.z.string(),zod.z.number()).nullish(),RunStatAwards:zod.z.array(tC).nullish(),RunStatsClamped:zod.z.boolean().nullish(),RunStatGrant:G.nullish()}).passthrough(),iC={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},Cc=zod.z.enum(["Forming","Active","Completed","Failed","Expired"]).catch("Forming"),rC={Active:"Active",Left:"Left",Replaced:"Replaced"},sC=zod.z.enum(["Active","Left","Replaced"]).catch("Active"),nC=zod.z.object({CurrentProgress:B.nullish(),MaxProgress:B.nullish()}).passthrough(),oC=zod.z.object({UserID:zod.z.string().nullish(),PublicData:Se.nullish(),IsBot:zod.z.boolean().nullish(),ContributionPoints:B.nullish(),ClaimedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),GrandPrizeClaimed:zod.z.boolean().nullish(),MemberStatus:sC.nullish(),JoinedAtUtc:u.nullish(),LeftAtUtc:u.nullish()}).passthrough(),Sc=zod.z.object({GroupID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),Members:zod.z.array(oC).nullish(),SharedProgress:nC.nullish(),Status:Cc.nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),Version:zod.z.number().nullish()}).passthrough(),aC=zod.z.object({GroupID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),FinalStatus:Cc.nullish(),GrandPrizeReceived:zod.z.boolean().nullish(),FinishedAtUtc:u.nullish()}).passthrough(),lC=zod.z.object({ActiveGroupID:zod.z.string().nullish(),ActiveRoundIndex:zod.z.number().nullish(),History:zod.z.array(aC).nullish()}).passthrough(),xc=zod.z.object({ServerTimeUtc:u.nullish(),UserState:lC.nullish(),ActiveGroup:Sc.nullish(),SecondsRemaining:B.nullish()}),bc=zod.z.object({ServerTimeUtc:u.nullish(),Group:Sc.nullish(),SecondsRemaining:B.nullish()}),jn=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:v.nullish()}),Dc=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),ze={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 uC=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(),cC=zod.z.object({ExperimentID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Schedule:re.nullish(),Gate:_.nullish(),Variants:zod.z.array(uC).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(),zc=zod.z.object({Experiments:zod.z.record(zod.z.string(),cC).nullish()}).passthrough();var pC={Mesh:"Mesh",Host:"Host"},Fn=zod.z.enum(["Mesh","Host"]).catch("Mesh"),dC={ServerRelay:"ServerRelay",P2P:"P2P"},Vn=zod.z.enum(["ServerRelay","P2P"]).catch("ServerRelay"),hC={Public:"Public",Private:"Private"},mC=zod.z.enum(["Public","Private"]).catch("Public"),fC={Signal:"Signal",Chat:"Chat",PlayerJoined:"PlayerJoined",PlayerLeft:"PlayerLeft",HostChanged:"HostChanged",RoomClosed:"RoomClosed",MemberState:"MemberState"},gC=zod.z.enum(["Signal","Chat","PlayerJoined","PlayerLeft","HostChanged","RoomClosed","MemberState"]).catch("Signal"),Pc=zod.z.object({Urls:zod.z.string().nullish(),Username:zod.z.string().nullish(),Credential:zod.z.string().nullish()}).passthrough(),yC=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),vc=zod.z.object({SystemState:yC.nullish(),DefaultTopology:Fn.nullish(),AllowCreatorTopologyOverride:zod.z.boolean().nullish(),DefaultChatMode:Vn.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(Pc).nullish()}).passthrough(),RC=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(),CC=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),Topology:Fn.nullish(),ChatMode:Vn.nullish(),MaxPlayers:zod.z.number().nullish(),MemberCount:zod.z.number().nullish(),CreatedAt:zod.z.number().nullish()}).passthrough(),SC=zod.z.object({Seq:zod.z.number().nullish(),Type:gC.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(),Rs=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),OwnerUserID:zod.z.string().nullish(),Topology:Fn.nullish(),ChatMode:Vn.nullish(),Visibility:mC.nullish(),Status:zod.z.string().nullish(),MaxPlayers:zod.z.number().nullish(),Members:zod.z.array(RC).nullish(),IceServers:zod.z.array(Pc).nullish(),Seq:zod.z.number().nullish()}).passthrough(),_n=zod.z.object({Closed:zod.z.boolean().nullish(),NewHostUserID:zod.z.string().nullish()}).passthrough(),Tc=zod.z.object({Rooms:zod.z.array(CC).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}).passthrough(),Ic=zod.z.object({Envelopes:zod.z.array(SC).nullish(),MaxSeq:zod.z.number().nullish()}).passthrough(),Cs=zod.z.object({Seq:zod.z.number().nullish()}).passthrough(),Ke={CreateRoom:"CreateRoom",JoinRoom:"JoinRoom",LeaveRoom:"LeaveRoom",ListRooms:"ListRooms",GetRoom:"GetRoom",CloseRoom:"CloseRoom",Poll:"Poll",SendSignal:"SendSignal",SendChat:"SendChat",SetMemberState:"SetMemberState"};var Wn=zod.z.object({TitleCustomData:ms.nullish(),Character:pr.nullish(),Item:Pr.nullish(),Currency:cr.nullish(),Store:Tr.nullish(),Lootbox:Cn.nullish(),Quest:fi.nullish(),TimedEvent:jr.nullish(),Leaderboard:Kr.nullish(),Season:$r.nullish(),Reward:Sn.nullish(),Collection:rs.nullish(),Craft:wn.nullish(),DealOffer:Ln.nullish(),Premium:kn.nullish(),TimedBoost:ps.nullish(),CoopEvent:ns.nullish(),GameLoop:ys.nullish(),Match:ln.nullish(),Experiment:zc.nullish(),Blockchain:en.nullish(),Marketplace:dn.nullish(),Multiplayer:vc.nullish(),UserCustomData:rr.nullish(),Referral:qn.nullish(),Localization:el.nullish()}).passthrough();var Mt={GetTitlePublicConfiguration:"GetTitlePublicConfiguration",GetTitlePublicConfigurationExcept:"GetTitlePublicConfigurationExcept",GetCurrencyDefinitions:"GetCurrencyDefinitions",GetItemDefinitions:"GetItemDefinitions",GetServerTime:"GetServerTime"};var Ss=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Title",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getTitlePublicConfiguration(e){return this.send(Mt.GetTitlePublicConfiguration,e,Wn)}getTitlePublicConfigurationExcept(e){return this.send(Mt.GetTitlePublicConfigurationExcept,e,Wn)}getCurrencyDefinitions(e){return this.send(Mt.GetCurrencyDefinitions,e,cr)}getItemDefinitions(e){return this.send(Mt.GetItemDefinitions,e,Pr)}getServerTime(e){return this.send(Mt.GetServerTime,e,be)}};var xs=class{constructor(e){this.ctx=e;}ctx;send(e,t,i,r=false){let s=O(this.ctx.settings.titleID,"GameLoop",e,t.UserID??"");return this.ctx.transport.post(s,t,i,{ticket:t.ClientSessionTicket,silent:r})}getGameLoops(e){return this.send(ze.GetGameLoops,e,ys)}getBoardDefinition(e,t=false){return this.send(ze.GetBoardDefinition,e,gs,t)}getBoardDefinitionForLevel(e,t=false){return this.send(ze.GetBoardDefinitionForLevel,e,gs,t)}getUserBoardState(e){return this.send(ze.GetUserBoardState,e,ac)}boardLoopRoll(e){return this.send(ze.BoardLoopRoll,e,hc)}boardLoopAttack(e){return this.send(ze.BoardLoopAttack,e,mc)}boardLoopRaid(e){return this.send(ze.BoardLoopRaid,e,Nn)}boardLoopRaidFast(e){return this.send(ze.BoardLoopRaidFast,e,Nn)}boardLoopBuild(e){return this.send(ze.BoardLoopBuild,e,fc)}boardSpecialChoose(e){return this.send(ze.BoardSpecialChoose,e,gc)}boardSpecialApplyMultiplier(e){return this.send(ze.BoardSpecialApplyMultiplier,e,yc)}boardSpecialClaim(e){return this.send(ze.BoardSpecialClaim,e,Rc)}getCommunityChestState(e){return this.send(ze.GetCommunityChestState,e,xc)}joinOrCreateCommunityChest(e){return this.send(ze.JoinOrCreateCommunityChest,e,bc)}claimCommunityChestMilestone(e){return this.send(ze.ClaimCommunityChestMilestone,e,jn)}claimCommunityChestGrandPrize(e){return this.send(ze.ClaimCommunityChestGrandPrize,e,jn)}leaveCommunityChest(e){return this.send(ze.LeaveCommunityChest,e,Dc)}};var oi=zod.z.lazy(()=>zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null(),zod.z.array(oi),zod.z.record(zod.z.string(),oi)]));var bC={Live:"Live",Latest:"Latest",Specific:"Specific"},DC={Debug:"Debug",Info:"Info",Warning:"Warning",Error:"Error"},zC=zod.z.enum(["Debug","Info","Warning","Error"]).catch("Debug"),PC={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"},vC=zod.z.enum(["None","Disabled","NoActiveRevision","RevisionNotFound","InvalidFieldName","RateLimited","HandlerNotFound","HandlerDisabled","Timeout","StatementCountExceeded","StackOverflow","ApiCallLimitExceeded","JavaScriptException","ExecutionError"]).catch("None"),TC=zod.z.object({Level:zC,Message:zod.z.string().nullish(),Data:oi.nullish()}),IC=zod.z.object({Error:vC,Message:zod.z.string().nullish(),StackTrace:zod.z.string().nullish()}),kc=zod.z.object({FunctionName:zod.z.string().nullish(),Revision:zod.z.number().nullish(),FunctionResult:oi.nullish(),FunctionResultTooLarge:zod.z.boolean().nullish(),Logs:zod.z.array(TC).nullish(),LogsTooLarge:zod.z.boolean().nullish(),ExecutionTimeSeconds:zod.z.number().nullish(),APIRequestsIssued:zod.z.number().nullish(),Error:IC.nullish()}),Qn={Execute:"Execute"};var bs=class{constructor(e){this.ctx=e;}ctx;execute(e){let t=O(this.ctx.settings.titleID,"CloudCode",Qn.Execute,e.UserID??"");return this.ctx.transport.post(t,e,kc,{ticket:e.ClientSessionTicket})}};var Ds=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Blockchain",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ee.GetDefinitions,e,ba)}getUserState(e){return this.send(Ee.GetUserState,e,Da)}depositToken(e){return this.send(Ee.DepositToken,e,za)}depositNFT(e){return this.send(Ee.DepositNFT,e,Pa)}requestTokenWithdrawal(e){return this.send(Ee.RequestTokenWithdrawal,e,va)}requestNFTWithdrawal(e){return this.send(Ee.RequestNFTWithdrawal,e,Ta)}getTransactionHistory(e){return this.send(Ee.GetTransactionHistory,e,Ia)}retryWithdrawal(e){return this.send(Ee.RetryWithdrawal,e,ka)}confirmWithdrawal(e){return this.send(Ee.ConfirmWithdrawal,e,wa)}donateToDeveloper(e){return this.send(Ee.DonateToDeveloper,e,sn)}donateToUsersPool(e){return this.send(Ee.DonateToUsersPool,e,sn)}};var zs=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Marketplace",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(pe.GetDefinitions,e,_a)}getGroupedOffers(e){return this.send(pe.GetGroupedOffers,e,Wa)}getOffersByItem(e){return this.send(pe.GetOffersByItem,e,hn)}getOffer(e){return this.send(pe.GetOffer,e,Qa)}getBuyOrders(e){return this.send(pe.GetBuyOrders,e,hn)}getMyState(e){return this.send(pe.GetMyState,e,Ha)}getHistory(e){return this.send(pe.GetHistory,e,$a)}createListing(e){return this.send(pe.CreateListing,e,ti)}cancelListing(e){return this.send(pe.CancelListing,e,Ve)}buy(e){return this.send(pe.Buy,e,Ve)}marketBuy(e){return this.send(pe.MarketBuy,e,Ve)}marketSell(e){return this.send(pe.MarketSell,e,Ve)}createAuction(e){return this.send(pe.CreateAuction,e,ti)}placeBid(e){return this.send(pe.PlaceBid,e,Ka)}claimAuction(e){return this.send(pe.ClaimAuction,e,Ve)}createBuyOrder(e){return this.send(pe.CreateBuyOrder,e,ti)}cancelBuyOrder(e){return this.send(pe.CancelBuyOrder,e,Ve)}fillBuyOrder(e){return this.send(pe.FillBuyOrder,e,Ve)}createDirectTrade(e){return this.send(pe.CreateDirectTrade,e,ti)}respondDirectTrade(e){return this.send(pe.RespondDirectTrade,e,Ve)}cancelDirectTrade(e){return this.send(pe.CancelDirectTrade,e,Ve)}claimBack(e){return this.send(pe.ClaimBack,e,Ve)}};var Ps=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Multiplayer",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}createRoom(e){return this.send(Ke.CreateRoom,e,Rs)}joinRoom(e){return this.send(Ke.JoinRoom,e,Rs)}leaveRoom(e){return this.send(Ke.LeaveRoom,e,_n)}listRooms(e){return this.send(Ke.ListRooms,e,Tc)}getRoom(e){return this.send(Ke.GetRoom,e,Rs)}closeRoom(e){return this.send(Ke.CloseRoom,e,_n)}poll(e){return this.send(Ke.Poll,e,Ic)}sendSignal(e){return this.send(Ke.SendSignal,e,Cs)}sendChat(e){return this.send(Ke.SendChat,e,Cs)}setMemberState(e){return this.send(Ke.SetMemberState,e,Cs)}};var vs=class{settings;emitter;platform;acquisition;playtime;clientPlatform;transport;fetchImpl;data;authStore;api;auth;userService;currency;item;store;purchase;checkout;lootbox;reward;quest;tutorial;communityMarketing;chat;push;localization;timedEvent;leaderboard;season;premium;character;match;craft;collection;coopEvent;dealOffer;referral;social;timedBoost;userCustomData;titleCustomData;title;gameLoop;cloudCode;blockchain;marketplace;multiplayer;constructor(e){this.settings=Jn(e),this.emitter=new Jt,this.platform=e.platform??new Bt,this.clientPlatform=e.clientPlatform??co(),this.acquisition=new bt(this.platform),this.acquisition.capture(),this.playtime=new Yt(this),this.emitter.on("auth:loggedIn",()=>{this.playtime.start(),this.acquisition.clear();}),this.emitter.on("auth:loggedOut",()=>{this.playtime.stop();}),this.fetchImpl=e.fetch??globalThis.fetch.bind(globalThis),this.transport=new Ri({baseUrl:this.settings.baseUrl,emitter:this.emitter,fetchImpl:e.fetch,debugLogging:this.settings.debugLogging,throttleMs:e.throttleMs,clientPlatform:this.clientPlatform}),this.data=new bi(this.emitter),this.emitter.on("quest:systemProgress",t=>{this.data.user.patchQuestProgressUpdates(t);}),this.emitter.on("tutorial:systemProgress",t=>{this.data.user.patchTutorialProgress(t);}),this.emitter.on("user:stateVersions",({epoch:t,versions:i})=>{this.userService.noteStateVersions(t,i);}),this.authStore=new Di(this.platform.storage,this.settings.titleID),this.api={authentication:new Sr(this),user:new br(this),currency:new Dr(this),item:new vr(this),store:new Ir(this),purchase:new kr(this),lootbox:new Ar(this),reward:new Or(this),quest:new Nr(this),tutorial:new Ur(this),communityMarketing:new Br(this),chat:new qr(this),push:new Er(this),localization:new Gr(this),timedEvent:new Fr(this),leaderboard:new Hr(this),season:new Zr(this),premium:new Yr(this),character:new Xr(this),match:new es(this),craft:new is(this),collection:new ss(this),coopEvent:new os(this),dealOffer:new ls(this),referral:new us(this),social:new cs(this),timedBoost:new ds(this),userCustomData:new hs(this),titleCustomData:new fs(this),title:new Ss(this),gameLoop:new xs(this),cloudCode:new bs(this),blockchain:new Ds(this),marketplace:new zs(this),multiplayer:new Ps(this)},this.userService=new Ti(this),this.auth=new zi(this),this.currency=new ki(this),this.item=new wi(this),this.store=new Mi(this),this.purchase=new Ai(this),this.checkout=new Oi(this),this.lootbox=new Ui(this),this.reward=new Bi(this),this.quest=new Fi(this),this.tutorial=new Li(this),this.communityMarketing=new qi(this),this.chat=new Ei(this),this.push=new Gi(this),this.localization=new ji(this),this.timedEvent=new Vi(this),this.leaderboard=new _i(this),this.season=new Wi(this),this.premium=new Qi(this),this.character=new Ki(this),this.match=new Hi(this),this.craft=new $i(this),this.collection=new Zi(this),this.coopEvent=new Ji(this),this.dealOffer=new Yi(this),this.referral=new Xi(this),this.social=new er(this),this.timedBoost=new tr(this),this.userCustomData=new sr(this),this.titleCustomData=new nr(this),this.title=new or(this),this.gameLoop=new ar(this),this.cloudCode=new lr(this),this.blockchain=new mr(this),this.marketplace=new Rr(this),this.multiplayer=new Cr(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 Ts=class{ctx;constructor(e){this.ctx=new vs(e);}get titleID(){return this.ctx.settings.titleID}get auth(){return this.ctx.auth}get user(){return this.ctx.userService}get currency(){return this.ctx.currency}get item(){return this.ctx.item}get store(){return this.ctx.store}get purchase(){return this.ctx.purchase}get checkout(){return this.ctx.checkout}get lootbox(){return this.ctx.lootbox}get reward(){return this.ctx.reward}get quest(){return this.ctx.quest}get tutorial(){return this.ctx.tutorial}get communityMarketing(){return this.ctx.communityMarketing}get chat(){return this.ctx.chat}get push(){return this.ctx.push}get localization(){return this.ctx.localization}get timedEvent(){return this.ctx.timedEvent}get leaderboard(){return this.ctx.leaderboard}get season(){return this.ctx.season}get premium(){return this.ctx.premium}get character(){return this.ctx.character}get match(){return this.ctx.match}get craft(){return this.ctx.craft}get collection(){return this.ctx.collection}get coopEvent(){return this.ctx.coopEvent}get dealOffer(){return this.ctx.dealOffer}get referral(){return this.ctx.referral}get social(){return this.ctx.social}get timedBoost(){return this.ctx.timedBoost}get userCustomData(){return this.ctx.userCustomData}get titleCustomData(){return this.ctx.titleCustomData}get title(){return this.ctx.title}get gameLoop(){return this.ctx.gameLoop}get cloudCode(){return this.ctx.cloudCode}get blockchain(){return this.ctx.blockchain}get marketplace(){return this.ctx.marketplace}get multiplayer(){return this.ctx.multiplayer}get data(){return this.ctx.data}get platform(){return this.ctx.platform}on(e,t){return this.ctx.emitter.on(e,t)}once(e,t){return this.ctx.emitter.once(e,t)}off(e,t){this.ctx.emitter.off(e,t);}};function kC(o){return new Ts(o)}var wc="idos_sso",Mc="state",Kn="idos:sso:state",wC="https://idosgames.com/sso/";function MC(){if(typeof window>"u")return null;let o=window.location.hash?.startsWith("#")?window.location.hash.slice(1):window.location.hash;if(!o)return null;let e=new URLSearchParams(o),t=e.get(wc);if(!t)return null;let i=e.get(Mc)??"",r=LC();return EC(e),qC(),r&&i!==r?null:{code:t,state:i}}function AC(o){if(typeof window>"u")return;let e=o.returnTo??OC(),t=UC();BC(t);let i=new URL(o.ssoUrl??wC);i.searchParams.set("title",o.titleID),i.searchParams.set("return_to",e),i.searchParams.set("state",t),window.location.assign(i.toString());}function OC(){let{origin:o,pathname:e,search:t}=window.location;return `${o}${e}${t}`}function UC(){let o=new Uint8Array(16);if(typeof crypto<"u"&&crypto.getRandomValues)crypto.getRandomValues(o);else for(let e=0;e<o.length;e++)o[e]=Math.floor(Math.random()*256);return Array.from(o,e=>e.toString(16).padStart(2,"0")).join("")}function BC(o){try{window.sessionStorage.setItem(Kn,o);}catch{}}function LC(){try{return window.sessionStorage.getItem(Kn)}catch{return null}}function qC(){try{window.sessionStorage.removeItem(Kn);}catch{}}function EC(o){o.delete(wc),o.delete(Mc);let e=o.toString(),{pathname:t,search:i}=window.location;window.history.replaceState(null,"",`${t}${i}${e?`#${e}`:""}`);}function GC(o,e){return !!o?.Claims?.[e]?.ClaimedAt}function NC(o){let e=o?.Claims;return e?Object.keys(e).filter(t=>!!e[t]?.ClaimedAt):[]}function jC(o,e){return o?.Claims?.[e]?.PremiumTiers??[]}function Oc(o,e,t,i=1){if(!o)return e;let r=o.Base??e,s=Math.max(0,t-i),a;switch(o.Shape??"Flat"){case "PerStep":a=r+(o.PerStep??0)*s;break;case "PerStepRate":a=r*(1+(o.PerStepRate??0)*s);break;case "Geometric":a=r*Math.pow(1+(o.GrowthRate??0),s);break;case "Table":a=r*Ac(o,t,1);break;case "TableAbsolute":a=Ac(o,t,r);break;default:a=r;break}return Number.isNaN(a)?r:(o.MinResult!=null&&a<o.MinResult&&(a=o.MinResult),o.MaxResult!=null&&a>o.MaxResult&&(a=o.MaxResult),a)}function FC(o,e,t=1){return Oc(o,1,e,t)}function VC(o){if(!o)return false;switch(o.Shape??"Flat"){case "PerStep":return (o.PerStep??0)!==0;case "PerStepRate":return (o.PerStepRate??0)!==0;case "Geometric":return (o.GrowthRate??0)!==0;case "Table":case "TableAbsolute":return Uc(o.Points).length>0;default:return o.MinResult!=null||o.MaxResult!=null}}function _C(o){if(Number.isNaN(o)||o<=0)return 0;if(!Number.isFinite(o))return Number.MAX_SAFE_INTEGER;let e=Math.round(o);return Math.abs(o-e)<=1e-9*Math.max(1,Math.abs(o))?e:Math.ceil(o)}function Uc(o){if(!o)return [];let e=[];for(let t of o)t?.AtStep==null||t.Value==null||e.push({AtStep:t.AtStep,Value:t.Value});return e}function Ac(o,e,t){let i=Uc(o.Points);if(i.length===0)return t;let r=null,s=null,a=null;for(let p of i)(a===null||p.AtStep>a.AtStep)&&(a=p),p.AtStep<=e&&(r===null||p.AtStep>=r.AtStep)&&(r=p),p.AtStep>e&&(s===null||p.AtStep<s.AtStep)&&(s=p);if(r===null)return t;if(s===null){let p=o.TailGrowthRate??0;return p===0?a.Value:a.Value*Math.pow(1+p,e-a.AtStep)}switch(o.Interpolation??"Step"){case "Linear":{let p=(e-r.AtStep)/(s.AtStep-r.AtStep);return r.Value+p*(s.Value-r.Value)}case "Geometric":{if(r.Value<=0||s.Value<=0){let x=(e-r.AtStep)/(s.AtStep-r.AtStep);return r.Value+x*(s.Value-r.Value)}let p=(e-r.AtStep)/(s.AtStep-r.AtStep);return r.Value*Math.pow(s.Value/r.Value,p)}default:return r.Value}}var WC={Banner:"Banner",Interstitial:"Interstitial",RewardedVideo:"RewardedVideo",RewardedInterstitial:"RewardedInterstitial",AppOpen:"AppOpen",Native:"Native"},Hn=zod.z.enum(["Banner","Interstitial","RewardedVideo","RewardedInterstitial","AppOpen","Native"]).catch("Banner"),QC={Top:"Top",Bottom:"Bottom",Left:"Left",Right:"Right"},KC=zod.z.enum(["Top","Bottom","Left","Right"]).catch("Top"),HC=zod.z.object({PlacementID:zod.z.string().nullish(),Type:Hn.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(),$C=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(),ZC=zod.z.object({CooldownSeconds:zod.z.number().nullish(),MinSessionTimeBeforeFirstSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),JC=zod.z.object({Enabled:zod.z.boolean().nullish(),Position:KC.nullish(),RefreshIntervalSeconds:zod.z.number().nullish()}).passthrough(),YC=zod.z.object({Enabled:zod.z.boolean().nullish(),CooldownSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish()}).passthrough(),XC=zod.z.object({MaxImpressionsPerHour:zod.z.number().nullish(),MaxImpressionsPerDay:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),eS=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(),tS=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(),iS=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(),rS=zod.z.object({AndroidUnitID:zod.z.string().nullish(),IosUnitID:zod.z.string().nullish(),WebUnitID:zod.z.string().nullish(),Type:Hn.nullish()}).passthrough(),sS={AppLovinMax:"AppLovinMax",LevelPlay:"LevelPlay"},nS=zod.z.enum(["AppLovinMax","LevelPlay"]).catch("AppLovinMax"),oS=zod.z.object({ProviderID:zod.z.string().nullish(),Kind:nS.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(),rS).nullish()}).passthrough();zod.z.object({Enabled:zod.z.boolean().nullish(),Placements:zod.z.record(zod.z.string(),HC).nullish(),Providers:zod.z.record(zod.z.string(),oS).nullish(),RewardedVideo:$C.nullish(),Interstitial:ZC.nullish(),Banner:JC.nullish(),AppOpen:YC.nullish(),FrequencyCapping:XC.nullish(),PremiumAdReductions:zod.z.array(eS).nullish(),Consent:tS.nullish(),Verification:iS.nullish()}).passthrough();var aS=zod.z.object({RewardedVideoCredit:zod.z.number().nullish(),TotalEarned:zod.z.number().nullish(),TotalSpent:zod.z.number().nullish()}).passthrough(),lS=zod.z.object({PlacementID:zod.z.string().nullish(),LastShownAt:u.nullish(),LastCompletedAt:u.nullish(),TotalImpressions:zod.z.number().nullish(),TotalCompletions:zod.z.number().nullish(),ConsecutiveFailures:zod.z.number().nullish()}).passthrough(),uS=zod.z.object({Date:u.nullish(),ImpressionsByPlacement:zod.z.record(zod.z.string(),zod.z.number()).nullish(),CompletionsByPlacement:zod.z.record(zod.z.string(),zod.z.number()).nullish(),TotalImpressions:zod.z.number().nullish(),InterstitialImpressions:zod.z.number().nullish(),RewardedCompletions:zod.z.number().nullish(),AppOpenImpressions:zod.z.number().nullish(),CreditsEarnedToday:zod.z.number().nullish()}).passthrough(),cS=zod.z.object({SessionID:zod.z.string().nullish(),SessionStartAt:u.nullish(),Impressions:zod.z.number().nullish(),InterstitialImpressions:zod.z.number().nullish(),RewardedCompletions:zod.z.number().nullish()}).passthrough(),pS=zod.z.object({PersonalizedAdsConsent:zod.z.boolean().nullish(),TrackingConsent:zod.z.boolean().nullish(),PolicyVersion:zod.z.string().nullish(),Region:zod.z.string().nullish(),ConsentGivenAt:u.nullish(),ConsentRevokedAt:u.nullish()}).passthrough(),dS=zod.z.object({RequestID:zod.z.string().nullish(),PlacementID:zod.z.string().nullish(),ProviderID:zod.z.string().nullish(),Type:Hn.nullish(),IssuedAt:u.nullish(),ExpiresAt:u.nullish(),CreditsToAward:zod.z.number().nullish()}).passthrough(),hS=zod.z.object({InvalidSsvCount:zod.z.number().nullish(),OrphanCompletions:zod.z.number().nullish(),FastCompletions:zod.z.number().nullish(),LastFlaggedAt:u.nullish()}).passthrough();zod.z.object({Credits:aS.nullish(),Placements:zod.z.record(zod.z.string(),lS).nullish(),Daily:uS.nullish(),Session:cS.nullish(),LastImpressionAt:u.nullish(),LastInterstitialAt:u.nullish(),LastRewardedAt:u.nullish(),LastAppOpenAt:u.nullish(),TotalImpressions:zod.z.number().nullish(),TotalRewardedCompletions:zod.z.number().nullish(),AdsDisabledUntil:u.nullish(),Consent:pS.nullish(),PendingRequests:zod.z.record(zod.z.string(),dS).nullish(),FraudFlags:hS.nullish(),UpdatedAt:u.nullish()}).passthrough();var mS={Unread:"Unread",Read:"Read",Deleted:"Deleted",Expired:"Expired"},fS=zod.z.enum(["Unread","Read","Deleted","Expired"]).catch("Unread"),gS={Admin:"Admin",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season",Collection:"Collection",MilestoneEvent:"MilestoneEvent",PlayerGift:"PlayerGift",Social:"Social",Compensation:"Compensation",Referral:"Referral",Quest:"Quest"},yS=zod.z.enum(["Admin","Leaderboard","CoopEvent","Season","Collection","MilestoneEvent","PlayerGift","Social","Compensation","Referral","Quest"]).catch("Admin"),RS={Active:"Active",Paused:"Paused",Cancelled:"Cancelled",Completed:"Completed"},CS=zod.z.enum(["Active","Paused","Cancelled","Completed"]).catch("Active"),SS=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(),xS=zod.z.object({SegmentID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Gate:_.nullish()}).passthrough();zod.z.object({MaxMessagesPerUser:zod.z.number().nullish(),ReadNoRewardRetentionHours:zod.z.number().nullish(),ClaimedRetentionHours:zod.z.number().nullish(),DefaultPageSize:zod.z.number().nullish(),EnableAutoClaim:zod.z.boolean().nullish(),MessageTypes:zod.z.record(zod.z.string(),SS).nullish(),Segments:zod.z.array(xS).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:yS.nullish(),RelatedEntityID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderPublicData:Se.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:u.nullish(),Status:fS.nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),ReadAtUtc:u.nullish(),BroadcastID:zod.z.string().nullish(),Version:zod.z.number().nullish()}).passthrough();zod.z.object({BroadcastID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),MessageTypeID:zod.z.string().nullish(),Subject:zod.z.string().nullish(),Body:zod.z.string().nullish(),TemplateParams:zod.z.record(zod.z.string(),zod.z.string()).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rewards:G.nullish(),TargetSegmentID:zod.z.string().nullish(),TargetUserIDs:zod.z.array(zod.z.string()).nullish(),StartsAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),CreatedAtUtc:u.nullish(),CreatedByAdminID:zod.z.string().nullish(),AdminComment:zod.z.string().nullish(),Status:CS.nullish(),DeliveredCount:zod.z.number().nullish(),ClaimedCount:zod.z.number().nullish()}).passthrough();zod.z.object({UnreadCount:zod.z.number().nullish(),UnclaimedRewardCount:zod.z.number().nullish(),LastFetchCursor:u.nullish(),ReceivedBroadcastIDs:zod.z.array(zod.z.string()).nullish(),ClaimedBroadcastIDs:zod.z.array(zod.z.string()).nullish(),DailyP2PGiftsSent:zod.z.number().nullish(),DailyGiftsResetDate:u.nullish(),LastOpenedAtUtc:u.nullish(),TotalMessagesReceived:zod.z.number().nullish(),TotalRewardsClaimed:zod.z.number().nullish()}).passthrough();var Bc="idos_device_id",Is=class{storage;constructor(e=new Ot){this.storage=e;}getPlatform(){return "Web"}getFullURL(){return ""}getStartParameter(){return null}getTelegramInitDataRaw(){return null}getDeviceID(){let e=this.storage.getString(Bc);return e||(e="noop-device",this.storage.setString(Bc,e)),e}getDeviceModel(){return "Noop"}shareLink(){}openInvoice(){}async showAd(){}async copyToClipboard(){}};
2
+ exports.AcquisitionCapture=bt;exports.AdProviderKind=sS;exports.AdType=WC;exports.AttackOutcome=zR;exports.AuthType=Ce;exports.AuthenticationAction=Be;exports.BannerPosition=QC;exports.BlockchainAction=Ee;exports.BlockchainNetworkType=xh;exports.BlockchainOperationCategory=ya;exports.BlockchainTransactionStatus=wh;exports.BlockchainTransactionType=Ph;exports.BodyPart=em;exports.BoostWindowKind=mR;exports.BroadcastStatus=RS;exports.BrowserPlatformAdapter=Bt;exports.BrowserStorage=At;exports.CharacterAction=qe;exports.ChatAction=we;exports.ChatAuthorType=Sg;exports.ChatBlockedTermAction=Rg;exports.ChatChannelType=hg;exports.ChatDirectAudience=gg;exports.ChatPartitioning=mg;exports.ChatReportReason=bg;exports.ClientPlatform=it;exports.CloudCodeAction=Qn;exports.CloudCodeErrorCode=PC;exports.CloudCodeLogLevel=DC;exports.CloudCodeRevisionSelection=bC;exports.CollectionAction=Ie;exports.CommissionSink=Sm;exports.CommunityChestMemberStatus=rC;exports.CommunityChestStatus=iC;exports.CommunityCreatorStatus=tg;exports.CommunityMarketingAction=Tt;exports.CommunityMetricKind=rg;exports.CommunityParticipationMode=Xf;exports.CommunityPayoutCurrencyKind=ig;exports.ConversionRateMode=Jd;exports.CoopEventAction=Ye;exports.CoopGroupStatus=Ry;exports.CoopMemberStatus=Cy;exports.CraftAction=ts;exports.CraftType=sy;exports.CurrencyAction=ur;exports.CurrencyStatus=Zd;exports.CurrencyType=He;exports.CurveInterpolation=lp;exports.CurveShape=op;exports.CustomDataBucket=ct;exports.CustomDataValueType=Nd;exports.CustomDataWriter=Ld;exports.DEFAULT_BASE_URL=Zn;exports.DealComparisonOperator=Ey;exports.DealNodeRuntimeStatus=wy;exports.DealNodeType=qy;exports.DealOfferAction=ot;exports.DealOfferActivationStatus=ky;exports.EnvelopeType=fC;exports.EventTokenType=Kc;exports.FodderSelectionMode=Wm;exports.FodderValuationMode=Vm;exports.FriendActionStatus=iR;exports.GameLoopAction=ze;exports.IDosGamesClient=Ts;exports.IapProductType=Df;exports.IapPurchaseStatus=If;exports.IapStoreValues=Qc;exports.ItemAction=zr;exports.KycStatus=vh;exports.KycTier=Ih;exports.LeaderboardAction=ve;exports.LocalizationAction=xr;exports.LocalizationMissingKeyMode=Em;exports.LootboxAction=Mr;exports.MailboxMessageSource=gS;exports.MailboxMessageStatus=mS;exports.MarketGoodsType=yr;exports.MarketOfferStatus=Cm;exports.MarketOfferType=Rm;exports.MarketplaceAction=pe;exports.MatchAction=nt;exports.MatchStatus=tm;exports.MemoryStorage=Ot;exports.MultiplayerAction=Ke;exports.MultiplayerChatMode=dC;exports.MultiplayerTopology=pC;exports.NoopPlatformAdapter=Is;exports.OFFER_NOT_IN_ROTATION=bf;exports.PlaytimeTracker=Yt;exports.PremiumAction=It;exports.PurchaseAction=_t;exports.PushAction=Vt;exports.PushPermissionState=ut;exports.PushTopic=gd;exports.PushTransport=md;exports.QuestAction=Ze;exports.QuestObjectiveSource=Rp;exports.QuestPrerequisiteMode=Sp;exports.QuestStatus=fp;exports.RaidMode=bR;exports.ReferralAction=kt;exports.ResourceEntryType=li;exports.RewardAction=dt;exports.RoomVisibility=hC;exports.ScheduleMode=Hc;exports.SeasonAction=St;exports.SocialAction=Xe;exports.SpecialChoiceMode=DR;exports.StoreAction=vt;exports.StoreRotationMode=nf;exports.StoreType=ty;exports.TimedBoostAction=wt;exports.TimedBoostStackingPolicy=oR;exports.TimedEventAction=Qe;exports.TimelineEventType=rR;exports.TitleAction=Mt;exports.TitleCustomDataAction=ni;exports.TitleDataBucket=yR;exports.TitleDataScope=gR;exports.TradeOfferStatus=ay;exports.TransactionDirection=Mh;exports.TutorialAction=je;exports.TutorialBoardAction=Bp;exports.TutorialFlowStatus=Ap;exports.TutorialGateMode=ep;exports.TutorialRestartPolicy=wp;exports.TutorialScriptModule=Up;exports.TutorialStepCompletionMode=Ip;exports.TypedEmitter=Jt;exports.UserAction=We;exports.UserCustomDataAction=Je;exports.WalletLinkType=Dh;exports.beginSsoRedirect=AC;exports.claimedMilestoneIDs=NC;exports.createIDosGamesClient=kC;exports.curveMultiplier=FC;exports.evaluateCurve=Oc;exports.grantedPremiumTiers=jC;exports.isCurveConfigured=VC;exports.isFail=Zc;exports.isMilestoneClaimed=GC;exports.isOk=$c;exports.normalizeBlockchainCategory=dr;exports.readSsoCodeFromUrl=MC;exports.roundAmount=_C;exports.zPaymentProof=ah;exports.zPriceOption=ra;exports.zPriceOptions=ee;