@idosgames/core 0.1.5 → 0.2.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'),Ut=require('decimal.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Ut__default=/*#__PURE__*/_interopDefault(Ut);var xt=class{listeners=new Map;on(e,t){let s=this.listeners.get(e);return s||(s=new Set,this.listeners.set(e,s)),s.add(t),()=>{this.off(e,t);}}once(e,t){let s=this.on(e,r=>{s(),t(r);});return s}off(e,t){let s=this.listeners.get(e);s&&(s.delete(t),s.size===0&&this.listeners.delete(e));}emit(e,t){let s=this.listeners.get(e);if(s)for(let r of [...s])r(t);}removeAllListeners(){this.listeners.clear();}};var Oi="https://api.idosgames.com";function Ui(c){return {titleID:c.titleID,titleTemplateID:c.titleTemplateID??"default",buildKey:c.buildKey??"",baseUrl:(c.baseUrl??Oi).replace(/\/+$/,""),devBuild:c.devBuild??false,debugLogging:c.debugLogging??false}}var ot=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{}}},at=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 lt(){return globalThis.Telegram?.WebApp??null}function M(){return crypto.randomUUID()}var Bi="idos_device_id",ut=class{storage;constructor(e=new ot){this.storage=e;}getPlatform(){return lt()?.platform??"Web"}getFullURL(){return typeof location<"u"?location.href:""}getStartParameter(){let e=lt()?.initDataUnsafe?.start_param;return typeof e=="string"?e:null}getTelegramInitDataRaw(){let e=lt()?.initData;return e&&e.length>0?e:null}getDeviceID(){let e=this.storage.getString(Bi);return e||(e=M(),this.storage.setString(Bi,e)),e}getDeviceModel(){return typeof navigator<"u"&&navigator.userAgent?navigator.userAgent:"Web"}shareLink(e){let t=lt();if(t?.openTelegramLink){t.openTelegramLink(e);return}typeof window<"u"&&window.open(e,"_blank");}openInvoice(e){let t=lt();if(t?.openInvoice){t.openInvoice(e);return}typeof window<"u"&&window.open(e,"_blank");}async showAd(e){let t=globalThis;typeof t.showAd=="function"&&await t.showAd(e);}async copyToClipboard(e){typeof navigator<"u"&&navigator.clipboard&&await navigator.clipboard.writeText(e);}};function wi(c){return {ok:true,data:c}}function n(c,e){return {ok:false,reason:c,error:e}}function Ka(c){return c.ok}function Za(c){return !c.ok}var Mt=class{constructor(e=600,t=()=>Date.now()){this.windowMs=e;this.now=t;}windowMs;now;last=new Map;tryAcquire(e){if(this.windowMs<=0)return true;let t=this.now(),s=this.last.get(e);return s!==void 0&&t-s<this.windowMs?false:(this.last.set(e,t),true)}reset(){this.last.clear();}};var kt=class{set=new Set;add(e){return this.set.has(e)?false:(this.set.add(e),true)}remove(e){this.set.delete(e);}};function qi(c){return c===429||c>=500&&c<=599}function kr(c,e=Math.random){let t=Math.min(500*Math.pow(2,c-1),4e3),s=t*.2*(e()*2-1);return Math.max(50,t+s)}function Ar(c){return new Promise(e=>setTimeout(e,c))}var Ja=12e3,Ya=zod.z.object({Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:zod.z.unknown().optional()}).passthrough(),Ot=class{baseUrl;emitter;fetchImpl;debugLogging;throttler;inflight=new kt;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 Mt(e.throttleMs);}setSessionRefreshHandler(e){this.sessionRefreshHandler=e;}async post(e,t,s,r={}){if(!this.throttler.tryAcquire(e))return n("throttled","Throttled");if(!this.inflight.add(e))return n("throttled","Duplicate request skipped");this.raiseBusy();try{let i=`${this.baseUrl}/${e}`,u=JSON.stringify(t),m=r.ticket??null,z=r.silent??!1,B=r.timeoutMs??Ja,G=r.autoRetry??!0,de=!1,fe=0;for(;;){let Ie;try{Ie=await this.doFetch(i,u,m,B);}catch{if(G&&fe<3){fe++,await Ar(kr(fe));continue}return this.connectionFailure("Internet Connection Error",z)}let Pe=Ie.status;if(Pe>=200&&Pe<300)return await this.parseSuccess(Ie,s,z,e);if(Pe===401){if(!de&&this.sessionRefreshHandler){de=!0;let Ke=null;try{Ke=await this.sessionRefreshHandler();}catch{Ke=null;}if(Ke){m=Ke;continue}}return this.emitter.emit("auth:unauthorized",void 0),n("unauthorized","Unauthorized")}if(qi(Pe)){if(G&&fe<3){fe++,await Ar(kr(fe));continue}return this.connectionFailure(`Server temporarily unavailable (HTTP ${Pe})`,z)}return await this.handleWebError(Ie,Pe,z)}}finally{this.inflight.remove(e),this.lowerBusy();}}async doFetch(e,t,s,r){let i=new AbortController,u=setTimeout(()=>{i.abort();},r);try{let m={"Content-Type":"application/json"};return s&&(m.Authorization=`Bearer ${s}`),await this.fetchImpl(e,{method:"POST",body:t,headers:m,signal:i.signal})}finally{clearTimeout(u);}}async parseSuccess(e,t,s,r){let i;try{i=await e.text();}catch{return this.globalError("Failed to read response body",s)}let u;try{u=JSON.parse(i);}catch{return this.globalError("JSON Parse Error",s)}let m=Ya.safeParse(u);if(!m.success)return this.globalError("Malformed response envelope",s);if(!m.data.Success){let B=m.data.Error??"Server returned Success=false";return s||this.emitter.emit("error:global",B),n("server",B)}let z=t.safeParse(m.data.Data);if(!z.success){let B=`Validation error (${r}): ${z.error.message}`;return this.debugLogging&&console.warn("[HttpTransport]",B),s||this.emitter.emit("error:global",B),n("validation",B)}return wi(z.data)}async handleWebError(e,t,s){let r=`HTTP ${t}`;try{let i=await e.text();if(i)try{let m=JSON.parse(i).Error;r=typeof m=="string"&&m.length>0?`HTTP ${t}: ${m}`:`HTTP ${t}: ${i}`;}catch{r=`HTTP ${t}: ${i}`;}}catch{}return s||this.emitter.emit("error:global",r),n("server",r)}connectionFailure(e,t){return t||this.emitter.emit("error:connection",e),n("connection",e)}globalError(e,t){return t||this.emitter.emit("error:global",e),n("server",e)}raiseBusy(){this.inFlightRequests++,this.inFlightRequests===1&&this.emitter.emit("transport:busy",true);}lowerBusy(){this.inFlightRequests>0&&(this.inFlightRequests--,this.inFlightRequests===0&&this.emitter.emit("transport:busy",false));}};function ct(c){return (typeof c=="string"?c:c.toISOString()).slice(0,10)}function Dt(c){return `${ct(c)}T00:00:00.000Z`}function Li(c){let e=new Date(c);return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+1)).toISOString()}function Gi(c,e){return new Date(c.getTime()+e*6e4).toISOString()}function Ni(c,e,t,s){let r={vcChanged:false,ccChanged:false,itemsChanged:false,tokensChanged:false};if(!e)return r;c.InventoryV2??={};let i=c.InventoryV2,u=s.toISOString(),m=new Map,z=new Map,B=new Map,G=new Map,de=new Map,fe=new Map,Ie=new Map,Pe=new Map,Ke=e.Grant?.PremiumTiers??[],Pt=Ke.length;for(let X=0;;X++){let ie,V;if(X===0)ie=e.Grant?.Standard?.Entries,V=false;else if(X-1<Pt)ie=Ke[X-1]?.Resources?.Entries,V=false;else if(X===1+Pt)ie=e.Consume?.Standard?.Entries,V=true;else break;if(ie)for(let N of ie){if(N.Type==null)continue;let _=Math.max(0,N.Amount??0);if(!(_<=0))switch(N.Type){case "VirtualCurrency":{if(!N.CurrencyID)continue;let W=V?z:m;W.set(N.CurrencyID,(W.get(N.CurrencyID)??0)+_);break}case "CryptoCurrency":{if(!N.CurrencyID)continue;let W=V?G:B;W.set(N.CurrencyID,(W.get(N.CurrencyID)??new Ut__default.default(0)).plus(_));break}case "Item":{if(!N.ItemID)continue;let W=el(t,N.CatalogID,N.ItemID),Y=(W?W.IsStackable??true:true)?V?fe:de:V?Pe:Ie;Y.set(N.ItemID,(Y.get(N.ItemID)??0)+_);break}case "UsdCent":continue}}}if(r.vcChanged=m.size>0||z.size>0,r.vcChanged){i.VirtualCurrencies??={};for(let X of new Set([...m.keys(),...z.keys()])){let ie=m.get(X)??0,V=z.get(X)??0,N=ie-V,_=i.VirtualCurrencies[X];_?(_.Amount+=N,_.UpdatedAt=u,_.Daily&&ct(_.Daily.PeriodStartUtc)===ct(s)?(_.Daily.Earned+=ie,_.Daily.Spent+=V):_.Daily={PeriodStartUtc:Dt(s),Earned:ie,Spent:V}):i.VirtualCurrencies[X]={Amount:N,CreatedAt:u,UpdatedAt:u,Daily:{PeriodStartUtc:Dt(s),Earned:ie,Spent:V}};}}if(r.ccChanged=B.size>0||G.size>0,r.ccChanged){i.CryptoCurrencies??={};for(let X of new Set([...B.keys(),...G.keys()])){let ie=B.get(X)??new Ut__default.default(0),V=G.get(X)??new Ut__default.default(0),N=ie.minus(V),_=i.CryptoCurrencies[X];_?(_.Amount=new Ut__default.default(_.Amount).plus(N).toString(),_.UpdatedAt=u):i.CryptoCurrencies[X]={Amount:N.toString(),Frozen:"0",CreatedAt:u,UpdatedAt:u};}}if(r.itemsChanged=de.size>0||fe.size>0||Ie.size>0||Pe.size>0,r.itemsChanged){i.Items??={},i.UnstackableItems??={};let X=i.UnstackableItems,ie=new Set([...de.keys(),...fe.keys(),...Ie.keys(),...Pe.keys()]);for(let V of ie){let N=(de.get(V)??0)-(fe.get(V)??0),_=(Ie.get(V)??0)-(Pe.get(V)??0),W=N+_,Me=i.Items[V];Me?(N!==0&&(Me.StackableAmount+=N),_!==0&&(Me.UnstackableAmount+=_),W!==0&&(Me.TotalAmount+=W)):i.Items[V]={StackableAmount:Math.max(0,N),UnstackableAmount:Math.max(0,_),TotalAmount:Math.max(0,W)};}for(let[V,N]of Pe){if(N<=0)continue;let _=Object.values(X).filter(W=>W.ItemID===V&&W.EquippedSlot==null&&(W.ExpiresAt==null||new Date(W.ExpiresAt)>s)).sort(Xa).slice(0,N).map(W=>W.ItemInstanceID);for(let W of _)delete X[W];}for(let[V,N]of Ie){let _=tl(t,V);for(let W=0;W<N;W++){let Me=M();X[Me]={ItemInstanceID:Me,ItemID:V,CatalogID:_,RemainingUses:1,AcquiredAt:u};}}}c.EventToken??={};let $a=c.EventToken;for(let X=0;;X++){let ie,V;if(X===0)ie=e.Grant?.Standard?.EventTokens,V=false;else if(X-1<Pt)ie=Ke[X-1]?.Resources?.EventTokens,V=false;else if(X===1+Pt)ie=e.Consume?.Standard?.EventTokens,V=true;else break;if(!(!ie||ie.length===0))for(let N of ie){let _=N.Address;if(!_||_.Type==null)continue;let W=N.Amount??0;if(W<=0)continue;let Me=sl($a,_.Type);if(!Me)continue;let Y=Me[_.EntityID];Y||(Y={},Me[_.EntityID]=Y),Y.Balance??={Current:0,TotalEarned:0,TotalSpent:0},Y.Daily??={Date:Dt(s),TotalEarned:0},Y.Meta??={};let St=N.Source&&N.Source.length>0?N.Source:"CustomAction";V?(Y.Balance.Current-=W,Y.Balance.TotalSpent+=W):(Y.Balance.Current+=W,Y.Balance.TotalEarned+=W,ct(Y.Daily.Date)!==ct(s)&&(Y.Daily={Date:Dt(s),TotalEarned:0}),Y.Daily.TotalEarned+=W,Y.Daily.EarnedBySource??={},Y.Daily.EarnedBySource[St]=(Y.Daily.EarnedBySource[St]??0)+W,Y.Daily.TriggersBySource??={},Y.Daily.TriggersBySource[St]=(Y.Daily.TriggersBySource[St]??0)+1,Y.Daily.LastTriggerBySource??={},Y.Daily.LastTriggerBySource[St]=u,Y.Meta.JoinedAtUtc||(Y.Meta.JoinedAtUtc=u),Y.Meta.LastEarnedAtUtc=u),r.tokensChanged=true;}}return r}function Xa(c,e){return c.AcquiredAt!==e.AcquiredAt?c.AcquiredAt<e.AcquiredAt?-1:1:c.ItemInstanceID===e.ItemInstanceID?0:c.ItemInstanceID<e.ItemInstanceID?-1:1}function el(c,e,t){let s=c?.Catalogs;if(s){if(e){let r=s[e]?.Items?.[t];if(r)return r}for(let r of Object.values(s)){let i=r.Items?.[t];if(i)return i}}}function tl(c,e){let t=c?.Catalogs;if(t){for(let[s,r]of Object.entries(t))if(r.Items&&e in r.Items)return s}}function sl(c,e){switch(e){case "TimedEvent":return c.TimedEvent??={};case "Quest":return c.Quest??={};case "Leaderboard":return c.Leaderboard??={};case "CoopEvent":return c.CoopEvent??={};case "Season":return c.Season??={};default:return null}}function Or(c,e){return c===e||c.startsWith(`${e}:`)}var Bt=class{constructor(e){this.emitter=e;}emitter;currentState={};activeEventsCache=null;get state(){return this.currentState}getCachedActiveEvents(){return this.activeEventsCache}clear(){this.currentState=null,this.emitter.emit("user:anyUpdated",void 0);}applyUserState(e){this.currentState=e,this.emitter.emit("user:stateUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyInventory(e){this.currentState??={},this.currentState.InventoryV2=e,this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyVirtualCurrency(e){this.currentState??={},this.currentState.InventoryV2??={},this.currentState.InventoryV2.VirtualCurrencies=e,this.emitter.emit("user:virtualCurrencyUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyResourceOperation(e,t,s=new Date){if(!this.currentState)return;let r=Ni(this.currentState,e,t,s);r.vcChanged&&this.emitter.emit("user:virtualCurrencyUpdated",void 0),(r.vcChanged||r.ccChanged||r.itemsChanged)&&this.emitter.emit("user:inventoryUpdated",void 0),r.tokensChanged&&this.emitter.emit("user:eventTokenUpdated",void 0),(r.vcChanged||r.ccChanged||r.itemsChanged||r.tokensChanged)&&this.emitter.emit("user:anyUpdated",void 0);}patchCryptoCurrencyDelta(e,t,s){if(!e||!this.currentState)return;this.currentState.InventoryV2??={},this.currentState.InventoryV2.CryptoCurrencies??={};let r=this.currentState.InventoryV2.CryptoCurrencies,i=t instanceof Ut__default.default?t:new Ut__default.default(t),u=s??new Date().toISOString(),m=r[e];m?(m.Amount=new Ut__default.default(m.Amount).plus(i).toString(),m.UpdatedAt=u):r[e]={Amount:i.toString(),Frozen:"0",CreatedAt:u,UpdatedAt:u},this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyStore(e){this.currentState??={},this.currentState.Store=e??{},this.emitter.emit("user:storeUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchStorePurchase(e,t,s){if(!e||t<1||!this.currentState)return;this.currentState.Store??={},this.currentState.Store.Purchases??={};let r=this.currentState.Store.Purchases,i=r[e];i||(i={OfferID:e,TotalPurchases:0,DailyPurchases:0,DailyResetUtc:"",LastPurchasedAt:""},r[e]=i),i.TotalPurchases+=t,i.LastPurchasedAt=s,s>=i.DailyResetUtc?(i.DailyPurchases=t,i.DailyResetUtc=Li(s)):i.DailyPurchases+=t,this.emitter.emit("user:storeUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyLootboxPityTriggers(e,t,s){if(!e||s<=0)return;this.currentState??={};let r=this.currentState.Lootbox??={};if(r.Pity??={},t){let i=new Date().toISOString();for(let u of t)u.RuleID&&(r.Pity[`${e}:${u.RuleID}`]={OpensSinceLastTrigger:0,LastTriggeredAtUtc:i});}this.emitter.emit("user:lootboxUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyReward(e){this.currentState??={},this.currentState.Reward=e??{},this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchDailyCalendarState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.DailyCalendars??={},this.currentState.Reward.DailyCalendars[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchIdleAccrualState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.IdleAccruals??={},this.currentState.Reward.IdleAccruals[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchComebackState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.Comebacks??={},this.currentState.Reward.Comebacks[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchClaimRewardState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.Claims??={},this.currentState.Reward.Claims[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyQuest(e){this.currentState??={},this.currentState.Quest=e??{},this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchQuestStatus(e,t,s){if(!e)return;this.currentState??={},this.currentState.Quest??={};let r=this.currentState.Quest;if(t){r.Cycles??={};let i=r.Cycles[t];if(!i)return;i.Quests??={};let u=i.Quests[e]??={QuestID:e,Status:s};u.Status=s,s==="Claimed"&&(u.ClaimedAtUtc??=new Date().toISOString());}else {r.PermanentQuests??={};let i=r.PermanentQuests[e]??={QuestID:e,Status:s};i.Status=s,s==="Claimed"&&(i.ClaimedAtUtc??=new Date().toISOString());}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchMilestoneClaimed(e,t){if(!e||!t)return;let s=this.getQuestPointsProgress(e);s&&(s.Milestone??={},s.Milestone.ClaimedIDs??=[],s.Milestone.ClaimedIDs.includes(t)||s.Milestone.ClaimedIDs.push(t),this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchQuestPointsTracks(e){if(!e)return;this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.Quest??={};let t=this.currentState.EventToken.Quest;for(let s of Object.values(e)){if(!s.CycleID)continue;let r=s.InstanceKey?`${s.CycleID}:${s.InstanceKey}`:s.CycleID,i=t[r]??={};i.Balance??={Current:0,TotalEarned:0,TotalSpent:0},i.Balance.Current=s.PointsCurrent??0,i.Balance.TotalEarned=s.PointsTotalEarned??0,i.Milestone??={},i.Milestone.ClaimedIDs=s.ClaimedPointMilestoneIDs??[];}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchGroupCompletionClaimed(e,t){if(!e||!t)return;this.currentState??={},this.currentState.Quest??={},this.currentState.Quest.Cycles??={};let s=this.currentState.Quest.Cycles[e];s&&(s.ClaimedGroupCompletionIDs??=[],s.ClaimedGroupCompletionIDs.includes(t)||s.ClaimedGroupCompletionIDs.push(t),this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchQuestProgressUpdates(e){if(!e||e.length===0)return;this.currentState??={},this.currentState.Quest??={};let t=this.currentState.Quest;for(let s of e){if(!s.QuestID)continue;let r;if(!s.CycleID)t.PermanentQuests??={},r=t.PermanentQuests[s.QuestID]??={QuestID:s.QuestID,Status:s.Status};else {t.Cycles??={};let i=t.Cycles[s.CycleID];if(!i)continue;i.Quests??={},r=i.Quests[s.QuestID]??={QuestID:s.QuestID,Status:s.Status};}if(r.Status=s.Status,s.ObjectiveID){r.Objectives??={};let i=r.Objectives[s.ObjectiveID]??={ObjectiveID:s.ObjectiveID,CurrentValue:0,Completed:false};i.CurrentValue=s.NewValue??0,s.ObjectiveCompleted&&(i.Completed=true,i.CompletedAtUtc??=new Date().toISOString());}s.Status==="Completed"&&(r.CompletedAtUtc??=new Date().toISOString());}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}getQuestPointsProgress(e){if(!e)return null;let t=this.currentState?.EventToken?.Quest;if(!t)return null;for(let[s,r]of Object.entries(t))if(Or(s,e)&&r)return r;return null}applyActiveEvents(e){this.activeEventsCache=e??{},this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyUserLteState(e){e&&(this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.TimedEvent=e.Tokens??{},this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchTimedEventMilestoneClaimed(e,t,s){if(!(!t||!s)){this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.TimedEvent??={};for(let[r,i]of Object.entries(this.currentState.EventToken.TimedEvent))!Or(r,t)||!i||this.markMilestoneClaimed(i.Milestone??(i.Milestone={}),s);this.patchActiveEventMilestoneClaimed(e,t,s),this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}}patchActiveEventMilestoneClaimed(e,t,s){let r=this.activeEventsCache?.ActiveEvents;if(r)for(let i of r)i.Type!==e||i.TimedEventID!==t||(i.Progress??={},this.markMilestoneClaimed(i.Progress.Milestone??(i.Progress.Milestone={}),s));}markMilestoneClaimed(e,t){if(e.ClaimedIDs??=[],e.ClaimedIDs.includes(t)||e.ClaimedIDs.push(t),e.UnlockedIDs){let s=e.UnlockedIDs.indexOf(t);s>=0&&e.UnlockedIDs.splice(s,1);}}patchLeaderboardMyProgress(e,t){if(!e||!t)return;let s=this.ensureLeaderboardProgress(e);s.CurrentScore=t.CurrentScore??0,s.LastKnownRank=t.LastKnownRank??0,s.ScoreEarnedThisCycle=t.ScoreEarnedThisCycle??0,s.UnclaimedRewardCycleVersion=t.HasUnclaimedReward?Math.max(1,s.UnclaimedRewardCycleVersion??0):0,this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchLeaderboardScoreSubmitted(e,t,s,r){if(!e)return;let i=this.ensureLeaderboardProgress(e);(i.ScoreCycleVersion??0)<r&&(i.ScoreEarnedThisCycle=0,i.ClaimedMilestoneIDs=[],i.BracketID=null),i.CurrentScore=t,i.ScoreEarnedThisCycle=(i.ScoreEarnedThisCycle??0)+s,i.ScoreCycleVersion=r,i.LastScoreSubmitUtc=new Date().toISOString(),this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchLeaderboardCycleRewardClaimed(e){if(!e)return;let t=this.currentState?.Leaderboard?.ProgressByCycle?.[e];t&&(t.UnclaimedRewardCycleVersion=0,this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchLeaderboardMilestoneClaimed(e,t){if(!e||!t)return;let s=this.ensureLeaderboardProgress(e);s.ClaimedMilestoneIDs??=[],s.ClaimedMilestoneIDs.includes(t)||s.ClaimedMilestoneIDs.push(t),this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureLeaderboardProgress(e){this.currentState??={},this.currentState.Leaderboard??={},this.currentState.Leaderboard.ProgressByCycle??={};let t=this.currentState.Leaderboard.ProgressByCycle,s=t[e];return s||(s={CurrentScore:0,ScoreEarnedThisCycle:0,ScoreCycleVersion:0,UnclaimedRewardCycleVersion:0,LastKnownRank:0},t[e]=s),s}applySeasonsState(e){this.currentState??={},this.currentState.Season=e??{},this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSeasonState(e,t){!e||!t||(this.currentState??={},this.currentState.Season??={},this.currentState.Season.States??={},this.currentState.Season.States[e]=t,this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchSeasonCurrentTier(e,t){if(!e)return;let s=this.ensureSeasonState(e);s.CurrentTier=t,this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSeasonClaimedTier(e,t){if(!e)return;let s=this.ensureSeasonState(e);s.ClaimedTierRewards??=[],s.ClaimedTierRewards.includes(t)||s.ClaimedTierRewards.push(t),this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureSeasonState(e){this.currentState??={},this.currentState.Season??={},this.currentState.Season.States??={};let t=this.currentState.Season.States,s=t[e];return s||(s={SeasonChainID:e},t[e]=s),s}applyPremium(e){this.currentState??={},this.currentState.Premium=e??{},this.emitter.emit("user:premiumUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCharacter(e){this.currentState??={},this.currentState.Character??={},this.currentState.Character.Characters=e??{},this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCharacter(e,t){if(!e)return;this.currentState??={},this.currentState.Character??={},this.currentState.Character.Characters??={};let s=this.currentState.Character.Characters,r=s[e];r||(r={CharacterID:e},s[e]=r),t(r),this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCharacterEquipment(e,t,s){if(!e||!t)return;let r=this.currentState?.Character?.Characters?.[e];r&&(r.Equipment??={},s===null?delete r.Equipment[t]:r.Equipment[t]=s,this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyInventoryDelta(e){if(!e)return;this.currentState??={},this.currentState.InventoryV2??={},this.currentState.InventoryV2.UnstackableItems??={};let t=this.currentState.InventoryV2.UnstackableItems,s=false;for(let[r,i]of Object.entries(e.ChangedInstances??{}))t[r]=i,s=true;for(let r of e.RemovedInstanceIDs??[])r in t&&(delete t[r],s=true);s&&(this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyMatch(e){this.currentState??={},this.currentState.Match=e??{},this.emitter.emit("user:matchUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchMatchStrategy(e){e&&(this.currentState??={},this.currentState.Match??={},this.currentState.Match.PvPBattleStrategy=e,this.emitter.emit("user:matchUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyCollection(e){this.currentState??={},this.currentState.Collection=e??{},this.emitter.emit("user:collectionUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCoopEvent(e){this.currentState??={},this.currentState.CoopEvent=e??{MyObjectIndex:-1},this.emitter.emit("user:coopEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCoopEventActiveGroup(e,t,s){this.currentState??={};let r=this.currentState.CoopEvent??={MyObjectIndex:-1};r.ActiveGroupID=e,r.ActiveCoopEventID=t,r.MyObjectIndex=s,this.emitter.emit("user:coopEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyDealOffer(e){this.currentState??={},this.currentState.DealOffer=e??{},this.emitter.emit("user:dealOfferUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyReferral(e){this.currentState??={},this.currentState.Referral=e??{},this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchReferralSubscription(e){e&&(this.currentState??={},this.currentState.Referral??={},this.currentState.Referral.SubscribedToUserID=e,this.currentState.Referral.UpdatedAt=new Date().toISOString(),this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchReferralInviteRewardClaimed(e){e&&(this.currentState??={},this.currentState.Referral??={},this.currentState.Referral.InviteRewardStates??={},this.currentState.Referral.InviteRewardStates[e]={RewardID:e,IsClaimed:true,ClaimedAt:new Date().toISOString()},this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applySocialFriendsList(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.Accepted=(e??[]).map(t=>t.UserID),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applySocialIncomingRequests(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.IncomingRequests=(e??[]).map(t=>t.UserID),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applySocialTimeline(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.Timeline=e??[],this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialAddOutgoingRequest(e){if(!e)return;let t=this.ensureSocial();t.OutgoingRequests??=[],t.OutgoingRequests.includes(e)||t.OutgoingRequests.push(e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialAcceptFriend(e){if(!e)return;let t=this.ensureSocial();t.IncomingRequests=(t.IncomingRequests??[]).filter(s=>s!==e),t.Accepted??=[],t.Accepted.includes(e)||t.Accepted.push(e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialRemoveIncomingRequest(e){if(!e)return;let t=this.ensureSocial();t.IncomingRequests=(t.IncomingRequests??[]).filter(s=>s!==e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialRemoveFriend(e){if(!e)return;let t=this.ensureSocial();t.Accepted=(t.Accepted??[]).filter(s=>s!==e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureSocial(){return this.currentState??={},this.currentState.Social??={},this.currentState.Social}applyTimedBoost(e){this.currentState??={},this.currentState.TimedBoost=e??{},this.emitter.emit("user:timedBoostUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchActiveTimedBoost(e,t){this.currentState??={},this.currentState.TimedBoost??={},this.currentState.TimedBoost.Active??={};let s=this.currentState.TimedBoost.Active;if(t==="Replace"||t==="KeepBest")for(let r of Object.keys(s)){let i=s[r];i&&i.BoostID===e.BoostID&&r!==e.InstanceID&&delete s[r];}s[e.InstanceID]=e,this.emitter.emit("user:timedBoostUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyUserCustomData(e){this.currentState??={},this.currentState.CustomData??={};let t=this.currentState.CustomData;t.Version=e.Version??0,t.Private=e.Private??{},t.Public=e.Public??{},t.ReadOnly=e.ReadOnly??{},this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchUserCustomDataKey(e,t,s,r,i){if(!t)return;this.currentState??={},this.currentState.CustomData??={};let u=this.currentState.CustomData,m={Value:s,UpdatedAt:new Date().toISOString(),Version:r,LastWriter:"Client",ExpiresAt:i??null};if(e==="Private")u.Private??={},u.Private[t]=m;else if(e==="Public")u.Public??={},u.Public[t]=m;else return;u.Version=(u.Version??0)+1,this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}removeUserCustomDataKey(e,t){if(!t||!this.currentState?.CustomData)return;let s=this.currentState.CustomData;if(e==="Private")s.Private&&delete s.Private[t];else if(e==="Public")s.Public&&delete s.Public[t];else return;this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyBoardState(e){this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.Board=e??{},this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCommunityChestUserState(e){this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.CommunityChest=e??{},this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardState(e){let t=this.ensureBoard();e(t),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardBuilding(e,t){if(e<0)return;let s=this.ensureBoard();s.BuildingStates??=[];let r=s.BuildingStates.find(i=>i.SlotIndex===e);r||(r={SlotIndex:e},s.BuildingStates.push(r)),t(r),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardPendingRaidLayout(e,t){let r=this.ensureBoard().Pending;r&&(e&&(r.RaidLayout=e),t>=0&&(r.OpenedIndices??=[],r.OpenedIndices.includes(t)||r.OpenedIndices.push(t)),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchBoardSpecialPending(e){let s=this.ensureBoard().Pending;!s||s.Type.toUpperCase()!=="SPECIAL"||(s.Special??={},e(s.Special),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}clearBoardPending(){let e=this.currentState?.GameLoop?.Board;!e||!e.Pending||(e.Pending=null,this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}ensureBoard(){return this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.Board??={},this.currentState.GameLoop.Board}applyBlockchainState(e,t){this.currentState??={},this.currentState.Blockchain=e??{},t&&(this.currentState.InventoryV2??={},this.currentState.InventoryV2.CryptoCurrencies=t),this.emitter.emit("user:blockchainUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyMarketplaceState(e){this.currentState??={},this.currentState.Marketplace=e??{},this.emitter.emit("user:marketplaceUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}getVirtualCurrencyAmount(e){return this.currentState?.InventoryV2?.VirtualCurrencies?.[e]?.Amount??0}getCryptoCurrencyAmount(e){return this.currentState?.InventoryV2?.CryptoCurrencies?.[e]?.Amount??"0"}};var wt=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 qt=class{user;config;constructor(e){this.user=new Bt(e),this.config=new wt;}reset(){this.user.clear(),this.config.applyTitlePublicConfiguration(null);}};var we={Virtual:"Virtual",Crypto:"Crypto"},pt=zod.z.enum(["Virtual","Crypto"]),rl={Item:"Item",VirtualCurrency:"VirtualCurrency",CryptoCurrency:"CryptoCurrency",UsdCent:"UsdCent"},Lt=zod.z.enum(["Item","VirtualCurrency","CryptoCurrency","UsdCent"]),il={TimedEvent:"TimedEvent",Quest:"Quest",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season"},Gt=zod.z.enum(["TimedEvent","Quest","Leaderboard","CoopEvent","Season"]),nl={Cyclic:"Cyclic",Scheduled:"Scheduled",Chained:"Chained"},bt=zod.z.enum(["Cyclic","Scheduled","Chained"]),ae={None:"None",Device:"Device",Email:"Email",iDosGames:"iDosGames",Facebook:"Facebook",Google:"Google",GooglePlay:"GooglePlay",Telegram:"Telegram",Wallet:"Wallet"};var Nt=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 ol(e)?e:ae.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 ol(c){return c!==null&&Object.values(ae).includes(c)}var al=8,ll=100,ul=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i,ji=["GameLoop"],jt=class{constructor(e){this.ctx=e;}ctx;authContext=null;refreshing=false;rememberSession=true;sessionAuthType=ae.None;sessionEmail="";sessionPassword="";get context(){return this.authContext}get isLoggedIn(){return this.authContext!==null&&this.authContext.userID.length>0&&this.authContext.clientSessionTicket.length>0}get lastAuthType(){return this.ctx.authStore.lastAuthType}setRememberSession(e){this.rememberSession=e;}get remembersSession(){return this.rememberSession}baseRequest(){return {BuildKey:this.ctx.settings.buildKey,WebAppLink:this.ctx.platform.getFullURL()}}async loginWithDeviceID(){this.ctx.emitter.emit("auth:requestSent",void 0);let e=this.baseRequest();e.DeviceID=this.ctx.platform.getDeviceID(),e.Device=this.ctx.platform.getDeviceModel(),e.Platform=this.ctx.platform.getPlatform();let t=await this.ctx.api.authentication.loginWithDeviceID(e);return t.ok?(this.applyAuthContext(t.data),this.fetchAndApplyClientState(ae.Device)):t}async loginWithTelegram(){this.ctx.emitter.emit("auth:requestSent",void 0);let e=this.ctx.platform.getTelegramInitDataRaw();if(!e)return n("client","Telegram initData is not available.");let t=this.baseRequest();t.TelegramInitData=e;let s=await this.ctx.api.authentication.loginWithTelegram(t);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(ae.Telegram)):s}async loginWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let s=this.baseRequest();s.Email=e,s.Password=t;let r=await this.ctx.api.authentication.loginWithEmail(s);if(!r.ok)return r;this.applyAuthContext(r.data);let i=await this.fetchAndApplyClientState(ae.Email);return i.ok&&this.keepEmailCredentials(e,t),i}async registerWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let s=this.baseRequest();s.Email=e,s.Password=t,s.DeviceID=this.ctx.platform.getDeviceID(),s.Device=this.ctx.platform.getDeviceModel(),s.Platform=this.ctx.platform.getPlatform();let r=await this.ctx.api.authentication.registerWithEmail(s);if(!r.ok)return r;this.applyAuthContext(r.data);let i=await this.fetchAndApplyClientState(ae.Email);return i.ok&&this.keepEmailCredentials(e,t),i}async loginWithGoogle(e){this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.GoogleIDToken=e;let s=await this.ctx.api.authentication.loginWithGoogle(t);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(ae.Google)):s}async requestWalletChallenge(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let s=this.baseRequest();return s.WalletAddress=e,s.NetworkID=t,this.ctx.api.authentication.requestWalletChallenge(s)}async loginWithWallet(e,t,s){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();r.WalletAddress=e,r.NetworkID=t,r.WalletSignature=s,r.Platform=this.ctx.platform.getPlatform(),r.Device=this.ctx.platform.getDeviceModel(),r.DeviceID=this.ctx.platform.getDeviceID();let i=await this.ctx.api.authentication.loginWithWallet(r);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(ae.Wallet)):i}async loginWithPlatformToken(e){if(!e)return n("client","AuthToken is null or empty.");this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.PlatformAuthToken=e,t.DeviceID=this.ctx.platform.getDeviceID(),t.Device=this.ctx.platform.getDeviceModel(),t.Platform=this.ctx.platform.getPlatform();let s=await this.ctx.api.authentication.loginWithPlatformToken(t);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(ae.iDosGames)):s}async forgotPassword(e){this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();return t.Email=e,this.ctx.api.authentication.forgotPassword(t)}async resetPassword(e,t,s){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();return r.Email=e,r.ResetToken=t,r.Password=s,this.ctx.api.authentication.resetPassword(r)}autoLogin(){return this.replay(this.ctx.authStore.lastAuthType,this.ctx.authStore.savedEmail,this.ctx.authStore.savedPassword)}replay(e,t,s){switch(e){case ae.Email:return this.loginWithEmail(t,s);case ae.Device:case ae.None:return this.loginWithDeviceID();case ae.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!==ae.None?this.sessionAuthType:this.ctx.authStore.lastAuthType;if(e===ae.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&&ul.test(e)}static isValidPasswordLength(e){return e.length>=al&&e.length<=ll}keepEmailCredentials(e,t){this.sessionEmail=e,this.sessionPassword=t,this.rememberSession&&this.ctx.authStore.saveEmailAndPassword(e,t);}forgetSession(){this.sessionAuthType=ae.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(ji,ji);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 Ft=class{constructor(e){this.ctx=e;}ctx;baseRequest(){let e=this.ctx.auth.context;return e?{UserID:e.userID,ClientSessionTicket:e.clientSessionTicket,BuildKey:this.ctx.settings.buildKey,WebAppLink:this.ctx.platform.getFullURL(),RelatedEntityID:M()}:null}async getClientState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getClientState(e);return t.ok&&this.applyClientState(t.data),t}async getClientStateExcept(e,t){let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.ExcludeFields=e,s.ExcludeTitleFields=t;let r=await this.ctx.api.user.getClientStateExcept(s);return r.ok&&this.applyClientState(r.data,e,t),r}async getUserInventory(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getInventory(e);return t.ok&&(this.ctx.data.user.applyInventory(t.data),this.ctx.emitter.emit("user:inventoryReceived",t.data)),t}async getEventTokens(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getEventTokens(e);return t.ok&&this.ctx.emitter.emit("user:eventTokensReceived",t.data),t}async getUsageTime(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getUsageTime(e);return t.ok&&this.ctx.emitter.emit("user:usageTimeReceived",t.data),t}async addUsageTime(e,t,s){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.UsageTime=e,r.IsNewSession=t,r.SessionDurationSeconds=s;let i=await this.ctx.api.user.addUsageTime(r);return i.ok&&this.ctx.emitter.emit("user:usageTimeAdded",i.data),i}async deleteUserAccount(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.deleteUserAccount(e);return t.ok&&this.ctx.emitter.emit("user:accountDeleted",t.data),t}async changeUsername(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Username=e;let s=await this.ctx.api.user.changeUsername(t);return s.ok&&this.ctx.emitter.emit("user:usernameChanged",s.data),s}applyClientState(e,t,s){let r=t?.includes("GameLoop")===true,i=s?.includes("GameLoop")===true,u=r?this.ctx.data.user.state?.GameLoop:void 0,m=i?this.ctx.data.config.titlePublicConfiguration?.GameLoop:void 0;this.ctx.data.config.applyTitlePublicConfiguration(e.Title),this.ctx.data.user.applyUserState(e.User??{});let z=this.ctx.data.user.state;r&&z&&z.GameLoop==null&&(z.GameLoop=u);let B=this.ctx.data.config.titlePublicConfiguration;i&&B&&B.GameLoop==null&&(B.GameLoop=m),this.ctx.emitter.emit("user:clientStateReceived",e);}};var Wt=class{constructor(e){this.ctx=e;}ctx;async convert(e,t,s,r,i,u){if(!t)return n("client","SourceID is required.");if(!r)return n("client","TargetID is required.");if(i<=0)return n("client","Amount must be positive.");if(e===s&&t===r)return n("client","Source and target must differ.");if(e===we.Crypto||s===we.Crypto)return n("client","Convert supports VC\u2194VC only. Use cryptoConvert for crypto.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let m={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:s,TargetID:r,SourceAmount:String(Math.trunc(i)),TransactionID:u&&u.length>0?u:`convert_${e}_${t}_to_${s}_${r}_${M()}`},z=await this.ctx.api.currency.convert(m);if(z.ok){let B=z.data,G={Consume:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:B.SourceID,Amount:B.SourceSpent}]}},Grant:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:B.TargetID,Amount:B.TargetCredited}]}}};this.ctx.data.user.applyResourceOperation(G,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("currency:converted",B);}return z}async cryptoConvert(e,t,s,r,i,u){let m=i instanceof Ut__default.default?i:new Ut__default.default(i);if(!t)return n("client","SourceID is required.");if(!r)return n("client","TargetID is required.");if(m.lte(0))return n("client","SourceAmount must be a positive decimal.");if(e===s&&t===r)return n("client","Source and target must differ.");if(e===we.Virtual&&s===we.Virtual)return n("client","cryptoConvert requires at least one crypto side. Use convert for VC\u2194VC.");if(e===we.Virtual&&!m.isInteger())return n("client","Virtual currency source amount must be integer.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let z={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:s,TargetID:r,SourceAmount:m.toString(),TransactionID:u&&u.length>0?u:`crypto_convert_${e}_${t}_to_${s}_${r}_${M()}`},B=await this.ctx.api.currency.cryptoConvert(z);if(B.ok){let G=B.data,de=[],fe=[];if(G.SourceType===we.Virtual&&de.push({Type:"VirtualCurrency",CurrencyID:G.SourceID,Amount:Math.trunc(Number(G.SourceSpent))}),G.TargetType===we.Virtual&&fe.push({Type:"VirtualCurrency",CurrencyID:G.TargetID,Amount:Math.trunc(Number(G.TargetCredited))}),de.length>0||fe.length>0){let Ie={Consume:de.length>0?{Standard:{Entries:de}}:null,Grant:fe.length>0?{Standard:{Entries:fe}}:null};this.ctx.data.user.applyResourceOperation(Ie,this.ctx.data.config.itemDefinitions);}G.SourceType===we.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(G.SourceID,new Ut__default.default(G.SourceSpent).negated(),G.ServerTimeUtc),G.TargetType===we.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(G.TargetID,new Ut__default.default(G.TargetCredited),G.ServerTimeUtc),this.ctx.emitter.emit("currency:cryptoConverted",G);}return B}};var Vt=class{constructor(e){this.ctx=e;}ctx;async upgradeLevel(e,t){let s=e.trim();if(!s)return n("client","ItemInstanceID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),ItemInstanceID:s,RelatedEntityID:`upgrade_item_${s}_${M()}`};t&&t.length>0&&(r.FodderInstanceIDs=[...t]);let i=await this.ctx.api.item.upgradeLevel(r);return i.ok&&(await this.ctx.userService.getUserInventory(),this.ctx.emitter.emit("item:levelUpgraded",i.data)),i}async upgradeLevelsBatch(e){if(!e||e.length===0)return n("client","upgrades is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Upgrades:e},s=await this.ctx.api.item.upgradeLevelsBatch(t);return s.ok&&(await this.ctx.userService.getUserInventory(),this.ctx.emitter.emit("item:levelsUpgradedBatch",s.data)),s}};var cl="Store",Qt=class{constructor(e){this.ctx=e;}ctx;async purchase(e,t=1){if(!e)return n("client","OfferID is required.");if(t<1)return n("client","Count must be at least 1.");let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),OfferID:e,Count:t,RelatedEntityID:`store_buy_${e}_${s.userID}_${M()}`},i=await this.ctx.api.store.purchase(r);if(i.ok){let u=i.data;this.ctx.data.user.patchStorePurchase(e,t,u.ServerTimeUtc),this.ctx.data.user.applyResourceOperation(u.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("store:offerPurchased",u);}return i}async purchaseBatch(e){if(!e||e.length===0)return n("client","purchases is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Purchases:e},s=await this.ctx.api.store.purchaseBatch(t);if(s.ok){let r=false;for(let i of s.data)!i.Success||!i.Data||!i.Data.OfferID||(this.ctx.data.user.patchStorePurchase(i.Data.OfferID,i.Data.Count,i.Data.ServerTimeUtc),!r&&i.Data.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("store:offersPurchasedBatch",s.data);}return s}async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.store.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(cl,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 pl="Lootbox",Ht=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.lootbox.getDefinitions(e);if(t.ok){let s=t.data.LootboxDefinitions;s&&(this.ctx.data.config.patchSection(pl,s),this.ctx.emitter.emit("lootbox:definitionsLoaded",s));}return t}async open(e,t,s){if(!e)return n("client","LootboxID is required.");if(t<1)return n("client","Count must be at least 1.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),LootboxID:e,Count:t,SelectedOptionID:s,RelatedEntityID:`lootbox_${e}_${s}_${M()}`},i=await this.ctx.api.lootbox.open(r);if(i.ok){let u=i.data;u.TriggeredPity&&u.TriggeredPity.length>0&&this.ctx.data.user.applyLootboxPityTriggers(e,u.TriggeredPity,t),this.ctx.data.user.applyResourceOperation(u.Resources,this.ctx.data.config.itemDefinitions),this.ctx.data.user.applyInventoryDelta(u.Inventory),this.ctx.emitter.emit("lootbox:opened",u);}return i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var dl="Reward";function Br(c){return c.length>0&&!c.includes(".")&&!c.includes("$")}var $t=class{constructor(e){this.ctx=e;}ctx;multiplier=1;multiplierEnabled=false;get milestoneRewardMultiplier(){return this.multiplier}get milestoneRewardMultiplierEnabled(){return this.multiplierEnabled}async getRewardDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.reward.getRewardDefinitions(e);if(t.ok){let s=t.data.RewardDefinitions;s&&(this.ctx.data.config.patchSection(dl,s),this.ctx.emitter.emit("reward:definitionsLoaded",s));}return t}async getUserRewardsState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.reward.getUserRewardsState(e);return t.ok&&t.data.Rewards&&(this.ctx.data.user.applyReward(t.data.Rewards),this.ctx.emitter.emit("reward:userStateLoaded",t.data.Rewards)),t}async getMilestoneRewardMultiplier(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.reward.getMilestoneRewardMultiplier(e);if(t.ok){let s=t.data;this.multiplierEnabled=s.Enabled,this.multiplier=s.Enabled?s.Multiplier??1:1,this.ctx.emitter.emit("reward:milestoneMultiplierLoaded",s);}return t}async claimDailyReward(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CalendarID:e,RelatedEntityID:`dailyreward_${t.userID}_${e??"default"}_${M()}`},r=await this.ctx.api.reward.claimDailyReward(s);if(r.ok){let i=r.data;this.ctx.data.user.patchDailyCalendarState(i.CalendarID,i.DailyState),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:dailyClaimed",i);}return r}async collectIdleAccrual(e){if(!Br(e))return n("client",'AccrualID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),AccrualID:e,RelatedEntityID:`idle_collect_${e}_${M()}`},s=await this.ctx.api.reward.collectIdleAccrual(t);if(s.ok){let r=s.data;this.ctx.data.user.patchIdleAccrualState(r.AccrualID,r.IdleState),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:idleCollected",r);}return s}async claimComebackReward(e){if(!Br(e))return n("client",'ComebackID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),ComebackID:e,RelatedEntityID:`comeback_claim_${e}_${M()}`},s=await this.ctx.api.reward.claimComebackReward(t);if(s.ok){let r=s.data;this.ctx.data.user.patchComebackState(r.ComebackID,r.ComebackState),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:comebackClaimed",r);}return s}async claimReward(e){if(!Br(e))return n("client",'ClaimID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),ClaimID:e,RelatedEntityID:`reward_claim_${e}_${M()}`},s=await this.ctx.api.reward.claimReward(t);if(s.ok){let r=s.data;this.ctx.data.user.patchClaimRewardState(r.ClaimID,r.ClaimState),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:claimed",r);}return s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var ml="Quest",Kt=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(ml,t.data),this.ctx.emitter.emit("quest:definitionsLoaded",t.data)),t}async getUserQuestState(e=true){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.AutoRefreshCycles=e;let s=await this.ctx.api.quest.getUserQuestState(t);if(s.ok){let r=s.data.State??{};this.ctx.data.user.applyQuest(r),this.ctx.data.user.patchQuestPointsTracks(s.data.PointsTracks),this.ctx.emitter.emit("quest:userStateLoaded",r);}return s}async refreshQuestCycles(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.quest.refreshQuestCycles(e);return t.ok&&this.ctx.emitter.emit("quest:cyclesRefreshed",void 0),t}async claimQuestReward(e,t){let s=e.trim();if(!s)return n("client","QuestID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r=t&&t.trim().length>0?t.trim():void 0,i={...this.ctx.buildAuthedBaseRequest(),QuestID:s,CycleID:r,RelatedEntityID:`quest_claim_${r??""}_${s}_${M()}`},u=await this.ctx.api.quest.claimQuestReward(i);if(u.ok){let m=u.data;this.ctx.data.user.patchQuestStatus(m.QuestID,m.CycleID,"Claimed"),this.ctx.data.user.applyResourceOperation(m.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:rewardClaimed",m);}return u}async claimQuestRewardsBatch(e){if(!e||e.length===0)return n("client","quests is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Quests:e},s=await this.ctx.api.quest.claimQuestRewardsBatch(t);if(s.ok){let r=false;for(let i of s.data)!i.Success||!i.Data||(this.ctx.data.user.patchQuestStatus(i.Data.QuestID,i.Data.CycleID,"Claimed"),!r&&i.Data.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("quest:rewardsClaimedBatch",s.data);}return s}async claimMilestoneReward(e,t){let s=e.trim(),r=t.trim();if(!s||!r)return n("client","CycleID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CycleID:s,MilestoneID:r,RelatedEntityID:`milestone_claim_${s}_${r}_${M()}`},u=await this.ctx.api.quest.claimMilestoneReward(i);if(u.ok){let m=u.data;this.ctx.data.user.patchMilestoneClaimed(m.CycleID,m.MilestoneID),this.ctx.data.user.applyResourceOperation(m.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:milestoneClaimed",m);}return u}async claimMilestoneRewardsBatch(e){if(!e||e.length===0)return n("client","milestones is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Milestones:e},s=await this.ctx.api.quest.claimMilestoneRewardsBatch(t);if(s.ok){let r=false;for(let i of s.data)!i.Success||!i.Data||(this.ctx.data.user.patchMilestoneClaimed(i.Data.CycleID,i.Data.MilestoneID),!r&&i.Data.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("quest:milestonesClaimedBatch",s.data);}return s}async claimGroupCompletionReward(e,t){let s=e.trim(),r=t.trim();if(!s||!r)return n("client","CycleID and GroupCompletionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CycleID:s,GroupCompletionID:r,RelatedEntityID:`group_completion_${s}_${r}_${M()}`},u=await this.ctx.api.quest.claimGroupCompletionReward(i);if(u.ok){let m=u.data;this.ctx.data.user.patchGroupCompletionClaimed(m.CycleID,m.GroupCompletionID),this.ctx.data.user.applyResourceOperation(m.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:groupCompletionClaimed",m);}return u}async addQuestProgress(e,t){let s=e.trim();if(!s)return n("client","MetricID is required.");if(t<0)return n("client","ProgressValue must be >= 0.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),MetricID:s,ProgressValue:t},i=await this.ctx.api.quest.addQuestProgress(r);return i.ok&&(this.ctx.data.user.patchQuestProgressUpdates(i.data.Updates),this.ctx.emitter.emit("quest:progressAdded",i.data)),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var hl="TimedEvent",Zt=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(hl,t.data),this.ctx.emitter.emit("timedEvent:definitionsLoaded",t.data)),t}async getUserLteState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedEvent.getUserLteState(e);return t.ok&&(this.ctx.data.user.applyUserLteState(t.data),this.ctx.emitter.emit("timedEvent:userStateLoaded",t.data)),t}async grantTokens(e,t,s,r,i,u,m=1){if(!t)return n("client","LteID is required.");if(!s)return n("client","SourceType is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let z={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,SourceType:s,Outcome:r,AmountOverride:i,SourceParams:u,RollMultiplier:m},B=await this.ctx.api.timedEvent.grantTokens(z);return B.ok&&(this.ctx.data.user.applyResourceOperation(B.data,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensGranted",B.data)),B}async spendTokens(e,t,s){if(!t)return n("client","LteID is required.");if(s<=0)return n("client","SpendAmount must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,SpendAmount:s},i=await this.ctx.api.timedEvent.spendTokens(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensSpent",i.data)),i}async claimMilestone(e,t,s){if(!t||!s)return n("client","LteID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,MilestoneID:s},i=await this.ctx.api.timedEvent.claimMilestone(r);if(i.ok){let u=i.data;this.ctx.data.user.applyResourceOperation(u.Rewards,this.ctx.data.config.itemDefinitions),this.ctx.data.user.patchTimedEventMilestoneClaimed(e,t,s),this.ctx.emitter.emit("timedEvent:milestoneClaimed",u);}return i}async claimMilestonesBatch(e){if(!e||e.length===0)return n("client","milestones is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Milestones:e},s=await this.ctx.api.timedEvent.claimMilestonesBatch(t);return s.ok&&(this.applyMilestoneClaimBatch(s.data),this.ctx.emitter.emit("timedEvent:milestonesClaimedBatch",s.data)),s}async claimAllMilestones(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&e.length>0&&(t.Events=e);let s=await this.ctx.api.timedEvent.claimAllMilestones(t);return s.ok&&(this.applyMilestoneClaimBatch(s.data),this.ctx.emitter.emit("timedEvent:allMilestonesClaimed",s.data)),s}async spendTokensBatch(e){if(!e||e.length===0)return n("client","spends is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Spends:e},s=await this.ctx.api.timedEvent.spendTokensBatch(t);if(s.ok){let r=false;for(let i of s.data)!r&&i.Success&&i.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("timedEvent:tokensSpentBatch",s.data);}return s}async grantTokensBatch(e){if(!e||e.length===0)return n("client","grants is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Grants:e},s=await this.ctx.api.timedEvent.grantTokensBatch(t);if(s.ok){let r=false;for(let i of s.data)!r&&i.Success&&i.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("timedEvent:tokensGrantedBatch",s.data);}return s}applyMilestoneClaimBatch(e){let t=false;for(let s of e){if(!s.Success||!s.Data)continue;let r=s.Data;r.Type&&r.LteID&&r.MilestoneID&&this.ctx.data.user.patchTimedEventMilestoneClaimed(r.Type,r.LteID,r.MilestoneID),!t&&r.Rewards&&(this.ctx.data.user.applyResourceOperation(r.Rewards,this.ctx.data.config.itemDefinitions),t=true);}}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var fl="Leaderboard",Jt=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(fl,t.data),this.ctx.emitter.emit("leaderboard:definitionsLoaded",t.data)),t}async getLeaderboard(e){if(!e)return n("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardID=e;let s=await this.ctx.api.leaderboard.getLeaderboard(t);return s.ok&&this.ctx.emitter.emit("leaderboard:loaded",s.data),s}async getMyProgress(e){if(!e)return n("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardID=e;let s=await this.ctx.api.leaderboard.getMyProgress(t);return s.ok&&(this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(e),s.data),this.ctx.emitter.emit("leaderboard:myProgressLoaded",s.data)),s}async submitScore(e,t){if(!e)return n("client","LeaderboardID is required.");if(t<=0)return n("client","Score must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,Score:t},r=await this.ctx.api.leaderboard.submitScore(s);if(r.ok){let i=r.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),i.NewScore,t,i.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",i);}return r}async submitScoreFromSource(e,t,s,r,i=1){if(!e)return n("client","LeaderboardID is required.");if(!t)return n("client","SourceType is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let u={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,SourceType:t,Outcome:s,Params:r,RollMultiplier:i},m=await this.ctx.api.leaderboard.submitScoreFromSource(u);if(m.ok){let z=m.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),z.NewScore,z.NewScore,z.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",z);}return m}async claimCycleReward(e){if(!e)return n("client","LeaderboardID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e},s=await this.ctx.api.leaderboard.claimCycleReward(t);if(s.ok){let r=s.data;this.ctx.data.user.patchLeaderboardCycleRewardClaimed(this.cycleDocID(e)),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("leaderboard:cycleRewardClaimed",r);}return s}async claimMilestone(e,t){if(!e||!t)return n("client","LeaderboardID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,MilestoneID:t},r=await this.ctx.api.leaderboard.claimMilestone(s);if(r.ok){let i=r.data;this.ctx.data.user.patchLeaderboardMilestoneClaimed(this.cycleDocID(e),t),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("leaderboard:milestoneClaimed",i);}return r}async getFriendsLeaderboard(e){if(!e)return n("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardID=e;let s=await this.ctx.api.leaderboard.getFriendsLeaderboard(t);return s.ok&&this.ctx.emitter.emit("leaderboard:friendsLoaded",s.data),s}async getLeaderboardsBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardIDs=e;let s=await this.ctx.api.leaderboard.getLeaderboardsBatch(t);return s.ok&&this.ctx.emitter.emit("leaderboard:loadedBatch",s.data),s}async getProgressBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardIDs=e;let s=await this.ctx.api.leaderboard.getProgressBatch(t);if(s.ok){for(let r of s.data)!r.Success||!r.Data||this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(r.Data.LeaderboardID),r.Data);this.ctx.emitter.emit("leaderboard:myProgressLoadedBatch",s.data);}return s}async claimCycleRewardsBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardIDs:e},s=await this.ctx.api.leaderboard.claimCycleRewardsBatch(t);if(s.ok){for(let r of s.data)!r.Success||!r.Data||(this.ctx.data.user.patchLeaderboardCycleRewardClaimed(this.cycleDocID(r.Data.LeaderboardID)),r.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.Data.Resources,this.ctx.data.config.itemDefinitions));this.ctx.emitter.emit("leaderboard:cycleRewardsClaimedBatch",s.data);}return s}async claimMilestonesBatch(e){if(!e||e.length===0)return n("client","milestones is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Milestones:e},s=await this.ctx.api.leaderboard.claimMilestonesBatch(t);if(s.ok){for(let r of s.data)!r.Success||!r.Data||(this.ctx.data.user.patchLeaderboardMilestoneClaimed(this.cycleDocID(r.Data.LeaderboardID),r.Data.MilestoneID),r.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.Data.Resources,this.ctx.data.config.itemDefinitions));this.ctx.emitter.emit("leaderboard:milestonesClaimedBatch",s.data);}return s}async submitScoresBatch(e){if(!e||e.length===0)return n("client","scores is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Scores:e},s=await this.ctx.api.leaderboard.submitScoresBatch(t);if(s.ok){for(let r of s.data)!r.Success||!r.Data||this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(r.Data.LeaderboardID),r.Data.NewScore,r.Data.NewScore,r.Data.CycleVersion);this.ctx.emitter.emit("leaderboard:scoresSubmittedBatch",s.data);}return s}async claimAllRewardsBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardIDs:e},s=await this.ctx.api.leaderboard.claimAllRewardsBatch(t);if(s.ok){for(let r of s.data){let i=this.cycleDocID(r.LeaderboardID);r.CycleReward?.Success&&r.CycleReward.Data&&(this.ctx.data.user.patchLeaderboardCycleRewardClaimed(i),r.CycleReward.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.CycleReward.Data.Resources,this.ctx.data.config.itemDefinitions));for(let u of r.Milestones??[])!u.Success||!u.Data||(this.ctx.data.user.patchLeaderboardMilestoneClaimed(i,u.Data.MilestoneID),u.Data.Resources&&this.ctx.data.user.applyResourceOperation(u.Data.Resources,this.ctx.data.config.itemDefinitions));}this.ctx.emitter.emit("leaderboard:allRewardsClaimedBatch",s.data);}return s}async getOverviewBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardIDs=e;let s=await this.ctx.api.leaderboard.getOverviewBatch(t);if(s.ok){for(let r of s.data)r.Progress?.Success&&r.Progress.Data&&this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(r.LeaderboardID),r.Progress.Data);this.ctx.emitter.emit("leaderboard:overviewLoadedBatch",s.data);}return s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Rl="Season",Yt=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.season.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Rl,t.data),this.ctx.emitter.emit("season:definitionsLoaded",t.data)),t}async getActiveSeason(e){if(!e)return n("client","SeasonChainID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.SeasonChainID=e;let s=await this.ctx.api.season.getActiveSeason(t);return s.ok&&(s.data.UserState&&this.ctx.data.user.patchSeasonState(e,s.data.UserState),this.ctx.emitter.emit("season:activeLoaded",s.data)),s}async getUserState(e){if(!e)return n("client","SeasonChainID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.SeasonChainID=e;let s=await this.ctx.api.season.getUserState(t);return s.ok&&(this.ctx.data.user.patchSeasonState(e,s.data),this.ctx.emitter.emit("season:userStateLoaded",s.data)),s}async grantStatusTokens(e,t){if(!e)return n("client","SeasonChainID is required.");if(t<=0)return n("client","Amount must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,Amount:t,RelatedEntityID:`season_grant_${e}_${M()}`},r=await this.ctx.api.season.grantStatusTokens(s);return r.ok&&(this.ctx.data.user.patchSeasonCurrentTier(e,r.data.NewTier),this.ctx.emitter.emit("season:statusTokensGranted",r.data)),r}async claimTierReward(e,t){if(!e)return n("client","SeasonChainID is required.");if(t<=0)return n("client","TierNumber must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,TierNumber:t,RelatedEntityID:`season_tier_${e}_t${t}_${M()}`},r=await this.ctx.api.season.claimTierReward(s);if(r.ok){let i=r.data;this.ctx.data.user.patchSeasonClaimedTier(e,t),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("season:tierRewardClaimed",i);}return r}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var gl="Premium",Xt=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(gl,t.data.Premium),this.ctx.emitter.emit("premium:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.premium.getUserState(e);return t.ok&&t.data.Premium&&(this.ctx.data.user.applyPremium(t.data.Premium),this.ctx.emitter.emit("premium:stateLoaded",t.data)),t}async activateTrial(e,t){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,RelatedEntityID:`premium_trial_${e}_${t}`},r=await this.ctx.api.premium.activateTrial(s);return r.ok&&(r.data.Premium&&this.ctx.data.user.applyPremium(r.data.Premium),this.ctx.emitter.emit("premium:trialActivated",r.data)),r}async purchaseItemOrCurrency(e,t,s="Default",r=1){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,SelectedOptionID:s,Count:r,RelatedEntityID:`premium_purchase_${e}_${t}`},u=await this.ctx.api.premium.purchaseItemOrCurrency(i);if(u.ok){let m=u.data;m.Premium&&this.ctx.data.user.applyPremium(m.Premium),this.ctx.data.user.applyResourceOperation(m.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:purchaseCompleted",m);}return u}async purchaseRealMoney(e,t,s,r,i,u,m,z){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!r||!i)return n("client","ProductID and ReceiptData are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let B={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,Store:s,ProductID:r,ReceiptData:i,PurchaseToken:u,PackageName:m,AppStoreEnvironment:z,RelatedEntityID:`premium_iap_${e}_${t}`},G=await this.ctx.api.premium.purchaseRealMoney(B);if(G.ok){let de=G.data;de.Premium&&this.ctx.data.user.applyPremium(de.Premium),this.ctx.data.user.applyResourceOperation(de.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:realMoneyPurchaseCompleted",de);}return G}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var yl="Character",es=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(yl,t.data),this.ctx.emitter.emit("character:definitionsLoaded",t.data)),t}async getUserCharacters(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.character.getUserCharacters(e);if(t.ok){let s=t.data.Characters??{};this.ctx.data.user.applyCharacter(s),this.ctx.emitter.emit("character:userCharactersLoaded",s);}return t}async unlockCharacter(e){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,RelatedEntityID:`unlock_char_${e}_${M()}`},s=await this.ctx.api.character.unlockCharacter(t);if(s.ok){let r=s.data;this.ctx.data.user.patchCharacter(r.CharacterID,i=>{i.StatLevels??={},i.Equipment??={},r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=r.ServerTimeUtc;}),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:unlocked",r);}return s}async upgradeStatLevel(e,t,s){if(!e||!t)return n("client","CharacterID and StatID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,StatID:t,RelatedEntityID:`upgrade_stat_${e}_${t}_${M()}`,...s?.levels!=null?{Levels:s.levels}:{},...s?.targetLevel!=null?{TargetLevel:s.targetLevel}:{}},i=await this.ctx.api.character.upgradeStatLevel(r);if(i.ok){let u=i.data;this.ctx.data.user.patchCharacter(u.CharacterID,m=>{m.StatLevels??={},m.StatLevels[u.StatID]=u.StatLevel,u.Power!=null&&(m.Power=u.Power),m.UpdatedAt=u.ServerTimeUtc;}),this.ctx.data.user.applyResourceOperation(u.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:statLevelUpgraded",u);}return i}async upgradeCharacterLevel(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,RelatedEntityID:`upgrade_char_${e}_${M()}`,...t?.levels!=null?{Levels:t.levels}:{},...t?.targetLevel!=null?{TargetLevel:t.targetLevel}:{}},r=await this.ctx.api.character.upgradeCharacterLevel(s);if(r.ok){let i=r.data;this.ctx.data.user.patchCharacter(i.CharacterID,u=>{u.Level=i.NewLevel,i.Power!=null&&(u.Power=i.Power),u.UpdatedAt=i.ServerTimeUtc,i.NewLevel===1&&(u.StatLevels??={},u.Equipment??={});}),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:levelUpgraded",i);}return r}async equipItems(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,ItemsToEquip:t},r=await this.ctx.api.character.equipItems(s);return r.ok&&(this.applyEquipChangesLocally(e,r.data),this.ctx.emitter.emit("character:itemsEquipped",r.data)),r}async unequipItems(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,UnequipSlotIDs:t},r=await this.ctx.api.character.unequipItems(s);if(r.ok){let i=r.data;this.applyUnequipChangesLocally(e,i),this.ctx.emitter.emit("character:itemsUnequipped",{characterID:e,slotIDs:i.ClearedSlotIDs??[],power:i.Power??null});}return r}async unequipAllCharacters(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.character.unequipAllCharacters(e);return t.ok&&(this.applyUnequipAllLocally(t.data),this.ctx.emitter.emit("character:allUnequipped",t.data)),t}async unlockCharactersBatch(e){if(!e||e.length===0)return n("client","characterIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),UnlockCharacterIDs:e},s=await this.ctx.api.character.unlockCharactersBatch(t);return s.ok&&(this.applyBatchResults(s.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,i=>{i.StatLevels??={},i.Equipment??={},r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=r.ServerTimeUtc;});}),this.ctx.emitter.emit("character:charactersUnlocked",s.data)),s}async upgradeCharacterLevelsBatch(e){if(!e||e.length===0)return n("client","upgrades is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LevelUpgrades:e},s=await this.ctx.api.character.upgradeCharacterLevelsBatch(t);return s.ok&&(this.applyBatchResults(s.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,i=>{i.Level=r.NewLevel,r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=r.ServerTimeUtc,r.NewLevel===1&&(i.StatLevels??={},i.Equipment??={});});}),this.ctx.emitter.emit("character:levelsUpgraded",s.data)),s}async upgradeStatLevelsBatch(e){if(!e||e.length===0)return n("client","upgrades is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),StatUpgrades:e},s=await this.ctx.api.character.upgradeStatLevelsBatch(t);return s.ok&&(this.applyBatchResults(s.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,i=>{i.StatLevels??={},i.StatLevels[r.StatID]=r.StatLevel,r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=r.ServerTimeUtc;});}),this.ctx.emitter.emit("character:statLevelsUpgraded",s.data)),s}applyBatchResults(e,t){e.Resources&&this.ctx.data.user.applyResourceOperation(e.Resources,this.ctx.data.config.itemDefinitions);for(let s of e.Items??[])!s.Success||!s.Data||t(s.Data);}applyInventoryDelta(e){this.ctx.data.user.applyInventoryDelta(e);}applyEquipChangesLocally(e,t){let s=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let[r,i]of Object.entries(t.Equipment??{}))s.patchCharacterEquipment(e,r,i);s.patchCharacter(e,r=>{t.Power!=null&&(r.Power=t.Power),r.UpdatedAt=t.ServerTimeUtc;});}applyUnequipChangesLocally(e,t){let s=t.ClearedSlotIDs??[];if(s.length===0&&t.Power==null)return;let r=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let i of s)r.patchCharacterEquipment(e,i,null);r.patchCharacter(e,i=>{t.Power!=null&&(i.Power=t.Power),i.UpdatedAt=t.ServerTimeUtc;});}applyUnequipAllLocally(e){let t=this.ctx.data.user;this.applyInventoryDelta(e.Inventory);for(let[s,r]of Object.entries(e.Characters??{})){for(let i of r.ClearedSlotIDs??[])t.patchCharacterEquipment(s,i,null);t.patchCharacter(s,i=>{r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=e.ServerTimeUtc;});}}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Cl="Match",ts=class{constructor(e){this.ctx=e;}ctx;async createMatch(e,t,s,r,i){let u=this.ctx.auth.context;if(!u)return n("unauthorized","Not logged in.");let m={...this.ctx.buildAuthedBaseRequest(),Entry:e,RuleID:t,CharacterID:s,BattleStrategy:r,TargetUserID:i,RelatedEntityID:`pvp_create_${u.userID}_${M()}`},z=await this.ctx.api.match.createMatch(m);return z.ok&&(this.ctx.data.user.applyResourceOperation(z.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:created",z.data)),z}async updateMatch(e,t={}){if(!e)return n("client","MatchID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),MatchID:e,TargetUserID:t.targetUserID,ClearTargetUser:t.clearTargetUser,RuleID:t.ruleID,CharacterID:t.characterID,BattleStrategy:t.battleStrategy},r=await this.ctx.api.match.updateMatch(s);return r.ok&&this.ctx.emitter.emit("match:updated",r.data),r}async cancelMatch(e){if(!e)return n("client","MatchID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),MatchID:e},s=await this.ctx.api.match.cancelMatch(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:cancelled",s.data)),s}async instantBattle(e,t,s,r){let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let u={...this.ctx.buildAuthedBaseRequest(),MatchID:e,RuleID:t,CharacterID:s,BattleStrategy:r,RelatedEntityID:`pvp_battle_${e}_${M()}`},m=await this.ctx.api.match.instantBattle(u);if(m.ok){let z=m.data,B=this.ctx.data.config.itemDefinitions;if(z.Resources)this.ctx.data.user.applyResourceOperation(z.Resources,B);else if(z.ResourcesDual){let G=z.ResourcesDual;G.FromUserID===i.userID&&G.FromResult?this.ctx.data.user.applyResourceOperation(G.FromResult,B):G.ToUserID===i.userID&&G.ToResult&&this.ctx.data.user.applyResourceOperation(G.ToResult,B);}this.ctx.emitter.emit("match:instantBattleCompleted",z);}return m}async saveStrategy(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BattleStrategy:e},s=await this.ctx.api.match.saveStrategy(t);return s.ok&&(this.ctx.data.user.patchMatchStrategy(e),this.ctx.emitter.emit("match:strategySaved",e)),s}async getMyMatches(e=0,t=20,s){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.Statuses=s;let i=await this.ctx.api.match.getMyMatches(r);return i.ok&&this.ctx.emitter.emit("match:myMatchesLoaded",i.data),i}async getAvailableMatches(e=0,t=20,s=false){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.OnlyPublic=s;let i=await this.ctx.api.match.getAvailableMatches(r);return i.ok&&this.ctx.emitter.emit("match:availableMatchesLoaded",i.data),i}async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.match.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Cl,t.data),this.ctx.emitter.emit("match:definitionsLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Sl="Craft",ss=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(Sl,t.data.CraftDefinitions),this.ctx.emitter.emit("craft:definitionsLoaded",t.data.CraftDefinitions)),t}async craft(e,t,s=1,r){if(!e)return n("client","CraftID is required.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let u={...this.ctx.buildAuthedBaseRequest(),CraftID:e,InputItemIDs:t,Count:s,SelectedOptionID:r,RelatedEntityID:`craft_${e}_${i.userID}_${M()}`},m=await this.ctx.api.craft.craft(u);return m.ok&&(this.ctx.data.user.applyResourceOperation(m.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("craft:completed",m.data)),m}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var xl="Collection",rs=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.collection.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(xl,t.data),this.ctx.emitter.emit("collection:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.collection.getUserState(e);return t.ok&&(this.ctx.data.user.applyCollection(t.data),this.ctx.emitter.emit("collection:userStateLoaded",t.data)),t}async openPack(e,t){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,PackTypeID:t,RelatedEntityID:`open_pack_${e}_${t}_${s.userID}_${M()}`},i=await this.ctx.api.collection.openPack(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:packOpened",i.data)),i}async openCollectionChest(e,t){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectionChestID:t,RelatedEntityID:`open_chest_${e}_${t}_${s.userID}_${M()}`},i=await this.ctx.api.collection.openCollectionChest(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:chestOpened",i.data)),i}async useCollectibleJoker(e,t){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:false,RelatedEntityID:`use_joker_${e}_${t}_${s.userID}_${M()}`},i=await this.ctx.api.collection.useCollectibleJoker(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:jokerUsed",i.data)),i}async claimSetReward(e,t){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,SetID:t,RelatedEntityID:`claim_set_${e}_${t}_${s.userID}_${M()}`},i=await this.ctx.api.collection.claimSetReward(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:setRewardClaimed",i.data)),i}async claimSetRewardsBatch(e){if(!e||e.length===0)return n("client","sets is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Sets:e},s=await this.ctx.api.collection.claimSetRewardsBatch(t);if(s.ok){let r=false;for(let i of s.data)!r&&i.Success&&i.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("collection:setRewardsClaimedBatch",s.data);}return s}async claimGrandPrize(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,RelatedEntityID:`grand_prize_${e}_${t.userID}_${M()}`},r=await this.ctx.api.collection.claimGrandPrize(s);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:grandPrizeClaimed",r.data)),r}async sendTradeOffer(e,t,s,r,i,u=false){let m=this.ctx.auth.context;if(!m)return n("unauthorized","Not logged in.");let z={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:s,ReceiverUserID:r,RequestedCollectibleID:i,RequestedCollectibleIsSpecial:u,RelatedEntityID:`trade_send_${m.userID}_${r}_${M()}`},B=await this.ctx.api.collection.sendTradeOffer(z);return B.ok&&this.ctx.emitter.emit("collection:tradeOfferSent",B.data),B}async cancelTradeOffer(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),OfferID:e,RelatedEntityID:`trade_cancel_${e}_${M()}`},s=await this.ctx.api.collection.cancelTradeOffer(t);return s.ok&&this.ctx.emitter.emit("collection:tradeOfferCancelled",s.data),s}async acceptTradeOffer(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),OfferID:e,RelatedEntityID:`trade_accept_${e}_${M()}`},s=await this.ctx.api.collection.acceptTradeOffer(t);return s.ok&&this.ctx.emitter.emit("collection:tradeOfferAccepted",s.data),s}async declineTradeOffer(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),OfferID:e,RelatedEntityID:`trade_decline_${e}_${M()}`},s=await this.ctx.api.collection.declineTradeOffer(t);return s.ok&&this.ctx.emitter.emit("collection:tradeOfferDeclined",s.data),s}async getMyTradeOffers(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CollectionID=e;let s=await this.ctx.api.collection.getMyTradeOffers(t);return s.ok&&this.ctx.emitter.emit("collection:myTradeOffersLoaded",s.data),s}async getIncomingTradeOffers(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CollectionID=e;let s=await this.ctx.api.collection.getIncomingTradeOffers(t);return s.ok&&this.ctx.emitter.emit("collection:incomingTradeOffersLoaded",s.data),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Dl="CoopEvent",is=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.coopEvent.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Dl,t.data),this.ctx.emitter.emit("coopEvent:definitionsLoaded",t.data)),t}async getActiveEvent(e){if(!e)return n("client","CoopChainID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CoopChainID=e;let s=await this.ctx.api.coopEvent.getActiveEvent(t);return s.ok&&this.ctx.emitter.emit("coopEvent:activeEventLoaded",s.data),s}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.coopEvent.getUserState(e);return t.ok&&(this.ctx.data.user.applyCoopEvent(t.data.UserState??null),this.ctx.emitter.emit("coopEvent:userStateLoaded",t.data)),t}async getGroupState(e){if(!e)return n("client","GroupID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.GroupID=e;let s=await this.ctx.api.coopEvent.getGroupState(t);return s.ok&&this.ctx.emitter.emit("coopEvent:groupStateLoaded",s.data),s}async joinOrCreateGroup(e){if(!e)return n("client","CoopChainID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),CoopChainID:e},s=await this.ctx.api.coopEvent.joinOrCreateGroup(t);if(s.ok){let r=s.data.Group;r&&this.ctx.data.user.patchCoopEventActiveGroup(r.GroupID??null,r.CoopEventID??null,-1),this.ctx.emitter.emit("coopEvent:groupJoined",s.data);}return s}async spin(e,t){if(!e||!t)return n("client","CoopChainID and GroupID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CoopChainID:e,GroupID:t,RelatedEntityID:M()},r=await this.ctx.api.coopEvent.spin(s);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("coopEvent:spinCompleted",r.data)),r}async claimObjectReward(e){if(!e)return n("client","GroupID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},s=await this.ctx.api.coopEvent.claimObjectReward(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("coopEvent:objectRewardClaimed",s.data)),s}async claimGrandPrize(e){if(!e)return n("client","GroupID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},s=await this.ctx.api.coopEvent.claimGrandPrize(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:grandPrizeClaimed",s.data)),s}async leaveGroup(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},s=await this.ctx.api.coopEvent.leaveGroup(t);return s.ok&&(this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:groupLeft",s.data)),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var bl="DealOffer",ns=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(bl,t.data.DealOfferDefinitions),this.ctx.emitter.emit("dealOffer:definitionLoaded",t.data.DealOfferDefinitions)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.dealOffer.getUserState(e);return t.ok&&t.data.DealOffers&&(this.ctx.data.user.applyDealOffer(t.data.DealOffers),this.ctx.emitter.emit("dealOffer:userStateLoaded",t.data.DealOffers)),t}async getActiveDeals(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.dealOffer.getActiveDeals(e);return t.ok&&this.ctx.emitter.emit("dealOffer:activeDealsLoaded",t.data),t}async dismissDeal(e){if(!e)return n("client","SlotID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),SlotID:e,RelatedEntityID:`deal_dismiss_${e}_${M()}`},s=await this.ctx.api.dealOffer.dismissDeal(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:dealDismissed",s.data)),s}async executeNode(e,t,s){if(!e||!t)return n("client","SlotID and NodeID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r=s&&s.trim().length>0?s.trim():void 0,i={...this.ctx.buildAuthedBaseRequest(),SlotID:e,NodeID:t,RelatedEntityID:r??`deal_exec_${e}_${t}_${M()}`},u=await this.ctx.api.dealOffer.executeNode(i);return u.ok&&(u.data.Idempotent||this.ctx.data.user.applyResourceOperation(u.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:nodeExecuted",u.data)),u}async recordShow(e){if(!e)return n("client","SlotID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),SlotID:e,RelatedEntityID:`deal_show_${e}_${M()}`},s=await this.ctx.api.dealOffer.recordShow(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:showRecorded",s.data)),s}async claimMilestone(e,t){if(!e||!t)return n("client","SlotID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneID:t,RelatedEntityID:`deal_milestone_${e}_${t}_${M()}`},r=await this.ctx.api.dealOffer.claimMilestone(s);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:milestoneClaimed",r.data)),r}async claimMilestonesBatch(e,t){if(!e)return n("client","SlotID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s=[...new Set(t.map(u=>u.trim()).filter(u=>u.length>0))],r={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneIDs:s,RelatedEntityID:`deal_milestone_batch_${e}_${M()}`},i=await this.ctx.api.dealOffer.claimMilestonesBatch(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:milestonesBatchClaimed",i.data)),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var zl="Referral",os=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.referral.getDefinitions(e);return t.ok&&t.data.ReferralDefinitions&&(this.ctx.data.config.patchSection(zl,t.data.ReferralDefinitions),this.ctx.emitter.emit("referral:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.referral.getUserState(e);return t.ok&&t.data.Referral&&(this.ctx.data.user.applyReferral(t.data.Referral),this.ctx.emitter.emit("referral:userStateLoaded",t.data)),t}async activateReferralCode(e){let t=e.trim().toUpperCase();if(!t)return n("client","ReferralCode is required.");let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),ReferralCode:t,RelatedEntityID:`referral_activation_${s.userID}`},i=await this.ctx.api.referral.activateReferralCode(r);if(i.ok){let u=i.data;u.ReferralCode&&this.ctx.data.user.patchReferralSubscription(u.ReferralCode),this.ctx.data.user.applyResourceOperation(u.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:codeActivated",u);}return i}async claimInviteReward(e){let t=e.trim();if(!t)return n("client","InviteRewardID is required.");let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),InviteRewardID:t,RelatedEntityID:`referral_invite_${t}_${s.userID}`},i=await this.ctx.api.referral.claimInviteReward(r);if(i.ok){let u=i.data;u.RewardID&&this.ctx.data.user.patchReferralInviteRewardClaimed(u.RewardID),this.ctx.data.user.applyResourceOperation(u.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:inviteRewardClaimed",u);}return i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var as=class{constructor(e){this.ctx=e;}ctx;async getFriendsList(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getFriendsList(e);return t.ok&&(this.ctx.data.user.applySocialFriendsList(t.data.Friends),this.ctx.emitter.emit("social:friendsListLoaded",t.data)),t}async getIncomingRequests(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getIncomingRequests(e);return t.ok&&(this.ctx.data.user.applySocialIncomingRequests(t.data.Friends),this.ctx.emitter.emit("social:incomingRequestsLoaded",t.data)),t}async getRecommendedFriends(e=5){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Limit=e;let s=await this.ctx.api.social.getRecommendedFriends(t);return s.ok&&this.ctx.emitter.emit("social:recommendedFriendsLoaded",s.data),s}async sendFriendRequest(e){if(!e)return n("client","TargetUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},s=await this.ctx.api.social.sendFriendRequest(t);return s.ok&&(this.ctx.data.user.patchSocialAddOutgoingRequest(e),this.ctx.emitter.emit("social:friendRequestSent",s.data)),s}async acceptFriendRequest(e){if(!e)return n("client","RequesterUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},s=await this.ctx.api.social.acceptFriendRequest(t);return s.ok&&(this.ctx.data.user.patchSocialAcceptFriend(e),this.ctx.emitter.emit("social:friendRequestAccepted",s.data)),s}async declineFriendRequest(e){if(!e)return n("client","RequesterUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},s=await this.ctx.api.social.declineFriendRequest(t);return s.ok&&(this.ctx.data.user.patchSocialRemoveIncomingRequest(e),this.ctx.emitter.emit("social:friendRequestDeclined",s.data)),s}async removeFriend(e){if(!e)return n("client","FriendUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},s=await this.ctx.api.social.removeFriend(t);return s.ok&&(this.ctx.data.user.patchSocialRemoveFriend(e),this.ctx.emitter.emit("social:friendRemoved",s.data)),s}async getTimeline(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getTimeline(e);return t.ok&&(this.ctx.data.user.applySocialTimeline(t.data.Events),this.ctx.emitter.emit("social:timelineLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var vl="TimedBoost";function Tl(c){return c.length>0&&!c.includes(".")&&!c.includes("$")}var ls=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(vl,t.data),this.ctx.emitter.emit("timedBoost:definitionsLoaded",t.data)),t}async getActive(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.getActive(e);return t.ok&&(this.ctx.data.user.applyTimedBoost({Active:t.data.Active??{}}),this.ctx.emitter.emit("timedBoost:activeLoaded",t.data)),t}async getActiveWindows(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.getActiveWindows(e);return t.ok&&this.ctx.emitter.emit("timedBoost:activeWindowsLoaded",t.data),t}async activate(e){let t=e.trim();if(!Tl(t))return n("client",'BoostID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),BoostID:t,RelatedEntityID:`timed_boost_activate_${t}_${M()}`},r=await this.ctx.api.timedBoost.activate(s);if(r.ok){let i=r.data;if(i.ActivatedBoost){let u=i.StackingPolicy??"Replace";this.ctx.data.user.patchActiveTimedBoost(i.ActivatedBoost,u);}this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedBoost:activated",i);}return r}async cleanupExpired(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.cleanupExpired(e);return t.ok&&(await this.getActive(),this.ctx.emitter.emit("timedBoost:expiredCleaned",void 0)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var k=zod.z.union([zod.z.number(),zod.z.string()]).transform((c,e)=>{let t=typeof c=="string"?Number(c):c;return Number.isFinite(t)?Math.trunc(t):(e.addIssue({code:zod.z.ZodIssueCode.custom,message:`Invalid integer amount: ${String(c)}`}),zod.z.NEVER)}),w=zod.z.union([zod.z.number(),zod.z.string()]).transform((c,e)=>{let t=typeof c=="number"?String(c):c.trim();return t===""||Number.isNaN(Number(t))?(e.addIssue({code:zod.z.ZodIssueCode.custom,message:`Invalid decimal: ${String(c)}`}),zod.z.NEVER):t}),a=zod.z.string();var We={Private:"Private",Public:"Public",ReadOnly:"ReadOnly",Internal:"Internal"},Il={Client:"Client",Server:"Server",System:"System"},Pl=zod.z.enum(["Client","Server","System"]),Ml=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:a.nullish(),Version:zod.z.number().nullish(),LastWriter:Pl.nullish(),ExpiresAt:a.nullish()}).passthrough(),us=zod.z.record(zod.z.string(),Ml),Fi=zod.z.object({Version:zod.z.number().nullish(),Private:us.nullish(),Public:us.nullish(),ReadOnly:us.nullish()}),wr=zod.z.object({UserID:zod.z.string().nullish(),Version:zod.z.number().nullish(),Public:us.nullish()}),qr=zod.z.object({ServerTimeUtc:a.nullish(),Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:a.nullish()}),kl=zod.z.object({Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:a.nullish()}),_i=zod.z.object({ServerTimeUtc:a.nullish(),Results:zod.z.array(kl).nullish()}),Wi=zod.z.object({ServerTimeUtc:a.nullish(),DeletedCount:zod.z.number().nullish()}),Vi=zod.z.object({Results:zod.z.array(wr).nullish(),NotFoundUserIDs:zod.z.array(zod.z.string()).nullish()}),Al={String:"String",Int:"Int",Bool:"Bool",Json:"Json"},Ol=zod.z.enum(["String","Int","Bool","Json"]),Ul=zod.z.object({KeyID:zod.z.string(),Bucket:zod.z.string().nullish(),ValueType:Ol.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),cs=zod.z.object({Keys:zod.z.record(zod.z.string(),Ul).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(),Ee={GetUserCustomDataDefinitions:"GetUserCustomDataDefinitions",GetMyUserCustomData:"GetMyUserCustomData",GetPublicUserCustomDataOf:"GetPublicUserCustomDataOf",SetPrivateData:"SetPrivateData",SetPublicData:"SetPublicData",DeleteKey:"DeleteKey",BatchSet:"BatchSet",BatchDelete:"BatchDelete",BatchGetPublicUserCustomDataOf:"BatchGetPublicUserCustomDataOf"};var Bl="UserCustomData";function Qi(c){return c.length>0&&!c.includes(".")&&!c.includes("$")}var ps=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(Bl,t.data),this.ctx.emitter.emit("userCustomData:definitionsLoaded",t.data)),t}async getMyUserCustomData(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.userCustomData.getMyUserCustomData(e);return t.ok&&(this.ctx.data.user.applyUserCustomData(t.data),this.ctx.emitter.emit("userCustomData:myDataLoaded",t.data)),t}async getPublicUserCustomDataOf(e){let t=e.trim();if(!t)return n("client","TargetUserID is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.TargetUserID=t;let r=await this.ctx.api.userCustomData.getPublicUserCustomDataOf(s);return r.ok&&this.ctx.emitter.emit("userCustomData:publicDataLoaded",r.data),r}async setPrivateData(e,t){return this.setData(e,t,We.Private)}async setPublicData(e,t){return this.setData(e,t,We.Public)}async setData(e,t,s){let r=e.trim();if(!Qi(r))return n("client",'KeyID is required and must not contain "." or "$".');if(t==null)return n("client","Value is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),KeyID:r,Value:t},m=await(s===We.Private?this.ctx.api.userCustomData.setPrivateData(i):this.ctx.api.userCustomData.setPublicData(i));if(m.ok){let z=m.data;this.ctx.data.user.patchUserCustomDataKey(s,z.KeyID,t,z.Version??0,z.ExpiresAt),this.ctx.emitter.emit(s===We.Private?"userCustomData:privateDataSet":"userCustomData:publicDataSet",z);}return m}async deleteKey(e,t){let s=e.trim();if(!Qi(s))return n("client",'KeyID is required and must not contain "." or "$".');if(t!==We.Private&&t!==We.Public)return n("client","Only Private or Public keys can be deleted.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),KeyID:s,Bucket:t},i=await this.ctx.api.userCustomData.deleteKey(r);return i.ok&&(this.ctx.data.user.removeUserCustomDataKey(t,s),this.ctx.emitter.emit("userCustomData:keyDeleted",void 0)),i}async batchSet(e){if(!e.length)return n("client","At least one item is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BatchSetItems:e},s=await this.ctx.api.userCustomData.batchSet(t);if(s.ok){for(let r of s.data.Results??[]){let i=r.Bucket??We.Private,u=e.find(m=>m.Bucket===i&&m.KeyID===r.KeyID);u&&this.ctx.data.user.patchUserCustomDataKey(i,r.KeyID,u.Value,r.Version??0,r.ExpiresAt);}this.ctx.emitter.emit("userCustomData:batchSet",s.data);}return s}async batchDelete(e){if(!e.length)return n("client","At least one item is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BatchDeleteItems:e},s=await this.ctx.api.userCustomData.batchDelete(t);if(s.ok){for(let r of e)this.ctx.data.user.removeUserCustomDataKey(r.Bucket,r.KeyID.trim());this.ctx.emitter.emit("userCustomData:batchDeleted",s.data);}return s}async batchGetPublicUserCustomDataOf(e){if(!e.length)return n("client","At least one target user id is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.TargetUserIDs=e;let s=await this.ctx.api.userCustomData.batchGetPublicUserCustomDataOf(t);return s.ok&&this.ctx.emitter.emit("userCustomData:batchPublicDataLoaded",s.data),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var wl="TitleCustomData",ds=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 getPublicTitleCustomData(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.title.getPublicTitleCustomData(e);return t.ok&&(this.ctx.data.config.patchSection(wl,t.data),this.ctx.emitter.emit("title:publicCustomDataReceived",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 ql=15,El="GameLoop",Ll="BoardDefinition",ms=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(El,t.data),this.ctx.emitter.emit("gameLoop:gameLoopsLoaded",t.data)),t}async getBoardDefinition(e=false){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");let s=await this.ctx.api.gameLoop.getBoardDefinition(t,e);return s.ok&&(this.ctx.data.config.patchSection(Ll,s.data),this.ctx.emitter.emit("gameLoop:boardDefinitionLoaded",s.data)),s}async getBoardDefinitionForLevel(e,t=false){if(e<=0)return n("client","stageLevel must be > 0.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.StageLevel=e;let r=await this.ctx.api.gameLoop.getBoardDefinitionForLevel(s,t);return r.ok&&this.ctx.emitter.emit("gameLoop:boardDefinitionForLevelLoaded",r.data),r}async getUserBoardState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.gameLoop.getUserBoardState(e);return t.ok&&(this.ctx.data.user.applyBoardState(t.data),this.ctx.emitter.emit("gameLoop:boardStateLoaded",t.data)),t}async boardLoopRoll(e=1){if(e<1)return n("client","rollMultiplier must be >= 1.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),RollMultiplier:e,RelatedEntityID:`roll_${t.userID}_${M()}`},r=await this.ctx.api.gameLoop.boardLoopRoll(s);if(r.ok){let i=r.data,u=Gi(new Date,ql);this.ctx.data.user.patchBoardState(m=>{m.Position=i.NewPosition,m.CyclesCompleted=(m.CyclesCompleted??0)+(i.CyclesCompletedDelta??0),m.LastRollAtUtc=new Date().toISOString(),i.ActionRequired&&i.ActionData?m.Pending={Type:i.ActionRequired,TargetUserID:i.ActionData.TargetUserID,TargetPublicData:i.ActionData.PublicData,TargetBuildingStates:i.ActionData.TargetBuildingStates??void 0,TargetHasShield:i.ActionData.TargetHasShield??void 0,RollMultiplier:i.UsedMultiplier??1,ExpiresAtUtc:u}:i.SpecialModeOffer&&(m.Pending={Type:"SPECIAL",RollMultiplier:i.UsedMultiplier??1,ExpiresAtUtc:u,Special:{ModeID:i.SpecialModeOffer.ModeID??void 0,Choices:i.SpecialModeOffer.Choices??void 0}});}),i.Operation&&this.ctx.data.user.applyResourceOperation(i.Operation,this.itemDefs),i.ActionRequired==="RAID"&&await this.getUserBoardState(),this.ctx.emitter.emit("gameLoop:boardRolled",i);}return r}async boardLoopAttack(e=-1){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`attack_${t.userID}_${M()}`},r=await this.ctx.api.gameLoop.boardLoopAttack(s);if(r.ok){let i=r.data;this.ctx.data.user.clearBoardPending(),i.IsBotTarget&&i.Operation?this.ctx.data.user.applyResourceOperation(i.Operation,this.itemDefs):!i.IsBotTarget&&i.DualResult?.FromResult&&this.ctx.data.user.applyResourceOperation(i.DualResult.FromResult,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardAttacked",i);}else await this.getUserBoardState();return r}async boardLoopRaid(e,t){if(e<0||e>11)return n("client","digIndex must be between 0 and 11.");let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),DigIndex:e,RelatedEntityID:t??`raid_${s.userID}_${M()}`},i=await this.ctx.api.gameLoop.boardLoopRaid(r);if(i.ok){let u=i.data;u.Status==="CONTINUE"?this.ctx.data.user.patchBoardPendingRaidLayout(u.RaidLayout,u.OpenedIndex??-1):(this.ctx.data.user.clearBoardPending(),this.applyRaidResources(u)),this.ctx.emitter.emit("gameLoop:boardRaided",u);}else await this.getUserBoardState();return i}async boardLoopRaidFast(e){if(!e.length)return n("client","digIndices must not be empty.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),DigIndices:e,RelatedEntityID:`raidfast_${t.userID}_${M()}`},r=await this.ctx.api.gameLoop.boardLoopRaidFast(s);if(r.ok){let i=r.data;i.Status!=="CONTINUE"&&(this.ctx.data.user.clearBoardPending(),this.applyRaidResources(i)),this.ctx.emitter.emit("gameLoop:boardRaidedFast",i);}else await this.getUserBoardState();return r}async boardLoopBuild(e){if(e<0)return n("client","buildingIndex must be >= 0.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`build_${t.userID}_${e}_${M()}`},r=await this.ctx.api.gameLoop.boardLoopBuild(s);if(r.ok){let i=r.data;i.StageComplete?this.ctx.data.user.patchBoardState(u=>{u.StageLevel=(u.StageLevel??1)+1,u.Position=0,u.Pending=null,u.BuildingStates=null;}):this.ctx.data.user.patchBoardBuilding(i.BuiltIndex,u=>{i.NewLevel!=null&&(u.Level=i.NewLevel),u.IsDamaged=false,i.MaxLevelRewardClaimed&&(u.MaxLevelRewardClaimed=true);}),i.Operation&&this.ctx.data.user.applyResourceOperation(i.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardBuilt",i);}return r}async boardSpecialChoose(e){if(!e)return n("client","choiceID must not be empty.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),ChoiceID:e,RelatedEntityID:`special_choose_${t.userID}_${M()}`},r=await this.ctx.api.gameLoop.boardSpecialChoose(s);if(r.ok){let i=r.data;i.Mode==="Instant"||i.Mode===0?this.ctx.data.user.clearBoardPending():this.ctx.data.user.patchBoardSpecialPending(m=>{m.ChoiceID=e,m.ChosenMode=i.Mode??"Timed",m.StartedAtUtc=i.StartedAtUtc??null,m.DurationSeconds=i.DurationSeconds??null,m.AdViewsUsed=0;}),i.Operation&&this.ctx.data.user.applyResourceOperation(i.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialChose",i);}return r}async boardSpecialApplyMultiplier(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:e??`special_ad_${t.userID}_${M()}`},r=await this.ctx.api.gameLoop.boardSpecialApplyMultiplier(s);if(r.ok){let i=r.data;this.ctx.data.user.patchBoardSpecialPending(u=>{u.AdViewsUsed=i.AdViewsUsed??0,u.AccumulatedMultiplier=i.AccumulatedMultiplier??0;}),this.ctx.emitter.emit("gameLoop:boardSpecialApplyMultiplier",i);}return r}async boardSpecialClaim(){let e=this.ctx.auth.context;if(!e)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:`special_claim_${e.userID}_${M()}`},s=await this.ctx.api.gameLoop.boardSpecialClaim(t);if(s.ok){let r=s.data;this.ctx.data.user.clearBoardPending(),r.Operation&&this.ctx.data.user.applyResourceOperation(r.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialClaimed",r);}return s}async getCommunityChestState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.gameLoop.getCommunityChestState(e);return t.ok&&(this.ctx.data.user.applyCommunityChestUserState(t.data.UserState??null),this.ctx.emitter.emit("gameLoop:communityChestStateLoaded",t.data)),t}async joinOrCreateCommunityChest(){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let e={...this.ctx.buildAuthedBaseRequest()},t=await this.ctx.api.gameLoop.joinOrCreateCommunityChest(e);if(t.ok){let s=t.data.Group;s?.GroupID&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:s.GroupID,ActiveRoundIndex:s.RoundIndex??void 0}),this.ctx.emitter.emit("gameLoop:communityChestJoined",t.data);}return t}async claimCommunityChestMilestone(e,t){if(!e)return n("client","milestoneID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),MilestoneID:e,GroupID:t},r=await this.ctx.api.gameLoop.claimCommunityChestMilestone(s);return r.ok&&(r.data.Resources&&this.ctx.data.user.applyResourceOperation(r.data.Resources,this.itemDefs),this.ctx.emitter.emit("gameLoop:communityChestMilestoneClaimed",r.data)),r}async claimCommunityChestGrandPrize(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},s=await this.ctx.api.gameLoop.claimCommunityChestGrandPrize(t);return s.ok&&(s.data.Resources&&this.ctx.data.user.applyResourceOperation(s.data.Resources,this.itemDefs),this.ctx.emitter.emit("gameLoop:communityChestGrandPrizeClaimed",s.data)),s}async leaveCommunityChest(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},s=await this.ctx.api.gameLoop.leaveCommunityChest(t);return s.ok&&(s.data.Success&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:void 0,ActiveRoundIndex:-1}),this.ctx.emitter.emit("gameLoop:communityChestLeft",s.data)),s}applyRaidResources(e){e.Operation?this.ctx.data.user.applyResourceOperation(e.Operation,this.itemDefs):e.DualResult?.FromResult&&this.ctx.data.user.applyResourceOperation(e.DualResult.FromResult,this.itemDefs);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var hs=class{constructor(e){this.ctx=e;}ctx;async execute(e,t,s,r){let i=e.trim();if(!i)return n("client","FunctionName is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let u={...this.ctx.buildAuthedBaseRequest(),FunctionName:i,FunctionParameter:t,RevisionSelection:s,SpecificRevision:r},m=await this.ctx.api.cloudCode.execute(u);return m.ok&&this.ctx.emitter.emit("cloudCode:executed",m.data),m}};var Er=zod.z.object({Type:Lt.nullish(),CurrencyID:zod.z.string().nullish(),Amount:k.nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish()}),Gl=zod.z.object({Type:Gt.nullish(),EntityID:zod.z.string()}),Nl=zod.z.object({Address:Gl.nullish(),Amount:k.nullish(),Source:zod.z.string().nullish()}),ne=zod.z.object({Entries:zod.z.array(Er).nullish(),EventTokens:zod.z.array(Nl).nullish()}),Hi=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Resources:ne.nullish()}),L=zod.z.object({Standard:ne.nullish(),PremiumBonuses:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(Hi).nullish()}),Q=zod.z.object({Standard:ne.nullish(),PremiumDiscounts:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(Hi).nullish()}),S=zod.z.object({Grant:L.nullish(),Consume:Q.nullish()}),Xe=zod.z.object({FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),FromResult:S.nullish(),ToResult:S.nullish()});zod.z.object({FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),Transferred:ne.nullish()});var $i=zod.z.object({ServerTimeUtc:a,SourceType:pt,SourceID:zod.z.string(),TargetType:pt,TargetID:zod.z.string(),SourceSpent:k,FeeAmount:k,RateApplied:w,TargetCredited:k}),Ki=zod.z.object({ServerTimeUtc:a,SourceType:pt,SourceID:zod.z.string(),TargetType:pt,TargetID:zod.z.string(),SourceSpent:w,FeeAmount:w,RateApplied:w,TargetCredited:w}),fs={Convert:"Convert",CryptoConvert:"CryptoConvert"},jl={Active:"Active",Hidden:"Hidden",Deprecated:"Deprecated",Maintenance:"Maintenance"},Zi=zod.z.enum(["Active","Hidden","Deprecated","Maintenance"]),Fl={Automatic:"Automatic",Manual:"Manual"},_l=zod.z.enum(["Automatic","Manual"]),Wl=zod.z.object({ValueInUSD:w.nullish(),ValueInUSDUpdatedAt:a.nullish(),InitialDeposit:zod.z.number().nullish(),MinBalance:zod.z.number().nullish(),MaxBalance:zod.z.number().nullish(),DailyEarnLimit:zod.z.number().nullish(),DailySpendLimit:zod.z.number().nullish()}).passthrough(),Vl=zod.z.object({Rate:zod.z.number().nullish(),Max:zod.z.number().nullish(),Period:zod.z.number().nullish()}).passthrough(),Ql=zod.z.object({IsTradable:zod.z.boolean().nullish(),IsPurchasable:zod.z.boolean().nullish(),IsRefundable:zod.z.boolean().nullish()}).passthrough(),Hl=zod.z.object({TargetCurrencyType:pt.nullish(),TargetCurrencyID:zod.z.string(),Rate:w.nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish(),DailyLimit:zod.z.number().nullish()}).passthrough(),Ji=zod.z.object({Enabled:zod.z.boolean().nullish(),RateMode:_l.nullish(),FeePercent:w.nullish(),Targets:zod.z.array(Hl).nullish()}).passthrough(),Yi=zod.z.object({CreatedAt:a.nullish(),UpdatedAt:a.nullish()}).passthrough(),$l=zod.z.object({CurrencyID:zod.z.string(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Economy:Wl.nullish(),Recharge:Vl.nullish(),Conversion:Ji.nullish(),Permissions:Ql.nullish(),Audit:Yi.nullish(),Status:Zi.nullish()}).passthrough(),Kl=zod.z.object({NetworkID:zod.z.string(),ContractAddress:zod.z.string().nullish(),Decimals:zod.z.number().nullish(),MinDeposit:w.nullish(),MinWithdraw:w.nullish(),WithdrawFee:w.nullish(),DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish()}).passthrough(),Zl=zod.z.object({DailyWithdrawUsd:w.nullish(),MonthlyWithdrawUsd:w.nullish(),KycRequiredAboveUsd:w.nullish()}).passthrough(),Jl=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),SpendableInGame:zod.z.boolean().nullish(),ConvertibleToVirtual:zod.z.boolean().nullish()}).passthrough(),Lr=zod.z.object({CurrencyID:zod.z.string(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),DisplayDecimals:zod.z.number().nullish(),ValueInUSD:w.nullish(),ValueInUSDUpdatedAt:a.nullish(),DeveloperDepositSharePercent:w.nullish(),CommunityMarketingDepositSharePercent:w.nullish(),WithdrawalBurnPercent:w.nullish(),Networks:zod.z.array(Kl).nullish(),Limits:Zl.nullish(),Permissions:Jl.nullish(),Conversion:Ji.nullish(),Audit:Yi.nullish(),Status:Zi.nullish()}).passthrough(),Rs=zod.z.object({VirtualCurrencies:zod.z.record(zod.z.string(),$l).nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Lr).nullish()}).passthrough();var ee=c=>zod.z.object({Id:zod.z.string(),Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:c.nullish()}),gs=c=>zod.z.object({ServerTimeUtc:a,Items:zod.z.array(ee(c)),Resources:S.nullish()});var me=zod.z.object({PresetID:zod.z.string().nullish(),Remove:zod.z.array(zod.z.string()).nullish()}).passthrough();var Xi=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),ItemInstanceID:zod.z.string().nullish(),EquippedAt:a.nullish()}),Gr=zod.z.object({CharacterID:zod.z.string(),Level:zod.z.number().nullish(),Experience:k.nullish(),Power:zod.z.number().nullish(),StatLevels:zod.z.record(zod.z.string(),zod.z.number()).nullish(),Equipment:zod.z.record(zod.z.string(),Xi).nullish(),UpdatedAt:a.nullish()}).passthrough(),Yl=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),Xl=zod.z.object({ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Quantity:zod.z.number().nullish(),RemainingUses:zod.z.number().nullish(),Level:zod.z.number().nullish(),AcquiredAt:a,ExpiresAt:a.nullish(),EquippedSlot:Yl.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(c=>c),Ze=zod.z.object({ChangedInstances:zod.z.record(zod.z.string(),Xl).nullish(),RemovedInstanceIDs:zod.z.array(zod.z.string()).nullish()}),en=zod.z.object({Characters:zod.z.record(zod.z.string(),Gr).nullish()}),Nr=zod.z.object({ServerTimeUtc:a,CharacterID:zod.z.string(),StatID:zod.z.string(),StatLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:S.nullish()}),jr=zod.z.object({ServerTimeUtc:a,CharacterID:zod.z.string(),NewLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:S.nullish()}),tn=zod.z.object({ServerTimeUtc:a,CharacterID:zod.z.string(),Equipment:zod.z.record(zod.z.string(),Xi).nullish(),ReplacedInstanceIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:Ze.nullish()}),sn=zod.z.object({ServerTimeUtc:a,CharacterID:zod.z.string(),ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:Ze.nullish()}),eu=zod.z.object({ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish()}),rn=zod.z.object({ServerTimeUtc:a,Characters:zod.z.record(zod.z.string(),eu).nullish(),Inventory:Ze.nullish()}),Fr=zod.z.object({ServerTimeUtc:a,CharacterID:zod.z.string(),Power:zod.z.number().nullish(),Resources:S.nullish()}),nn=gs(Fr),on=gs(jr),an=gs(Nr),ln=zod.z.object({RequiredStatID:zod.z.string(),RequiredLevel:zod.z.number()}).passthrough(),un=zod.z.object({StatID:zod.z.string(),TypeID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),MaxLevel:zod.z.number().nullish(),Weight:zod.z.number().nullish(),BaseCostResource:Q.nullish(),CostScalingFactor:zod.z.number().nullish(),BaseStatValue:zod.z.number().nullish(),StatScalingFactor:zod.z.number().nullish(),CharacterLevelScalingFactor:zod.z.number().nullish(),Requirements:zod.z.array(ln).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),cn=zod.z.object({Level:zod.z.number().nullish(),UpgradeCost:Q.nullish(),GlobalStatMultiplier:zod.z.number().nullish(),StatMaxLevelMultiplier:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),tu=zod.z.object({SlotID:zod.z.string(),MinCharacterLevel:zod.z.number().nullish(),StatRequirements:zod.z.array(ln).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(),pn=zod.z.object({Slots:zod.z.record(zod.z.string(),tu).nullish()}).passthrough(),su=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(),ru=zod.z.object({ClassID:zod.z.string().nullish(),RarityID:zod.z.string().nullish(),Tags:zod.z.array(zod.z.string()).nullish()}).passthrough(),iu=zod.z.object({UnlockedByDefault:zod.z.boolean().nullish(),Cost:Q.nullish()}).passthrough(),nu=zod.z.object({Stats:me.nullish(),Levels:me.nullish(),Equipment:me.nullish()}).passthrough(),ou=zod.z.object({CharacterID:zod.z.string(),Identity:su.nullish(),Classification:ru.nullish(),Unlock:iu.nullish(),Presets:nu.nullish(),Equipment:pn.nullish(),Stats:zod.z.record(zod.z.string(),un).nullish(),Levels:zod.z.record(zod.z.string(),cn).nullish()}).passthrough(),au=zod.z.object({Stats:zod.z.record(zod.z.string(),un).nullish()}).passthrough(),lu=zod.z.object({Levels:zod.z.record(zod.z.string(),cn).nullish()}).passthrough(),uu=zod.z.object({Equipment:pn.nullish()}).passthrough(),cu=zod.z.object({Stats:zod.z.record(zod.z.string(),au).nullish(),Levels:zod.z.record(zod.z.string(),lu).nullish(),Equipment:zod.z.record(zod.z.string(),uu).nullish()}).passthrough(),Cs=zod.z.object({Definitions:zod.z.record(zod.z.string(),ou).nullish(),Presets:cu.nullish()}).passthrough(),ze={GetCharacterDefinitions:"GetCharacterDefinitions",GetUserCharacters:"GetUserCharacters",UnlockCharacter:"UnlockCharacter",UpgradeStatLevel:"UpgradeStatLevel",UpgradeCharacterLevel:"UpgradeCharacterLevel",EquipItems:"EquipItems",UnequipItems:"UnequipItems",UnequipAllCharacters:"UnequipAllCharacters",UnlockCharactersBatch:"UnlockCharactersBatch",UpgradeCharacterLevelsBatch:"UpgradeCharacterLevelsBatch",UpgradeStatLevelsBatch:"UpgradeStatLevelsBatch"};var pu={EVM:"EVM",Solana:"Solana"},du=zod.z.enum(["EVM","Solana"]),mu={AutoLinkedFromTransaction:"AutoLinkedFromTransaction",SignatureVerified:"SignatureVerified",ManuallyLinked:"ManuallyLinked"},hu=zod.z.enum(["AutoLinkedFromTransaction","SignatureVerified","ManuallyLinked"]),fu={Token:"Token",Nft:"Nft"},dn=zod.z.enum(["Token","Nft"]),Ru={NotRequested:"NotRequested",Pending:"Pending",Verified:"Verified",Rejected:"Rejected",Expired:"Expired"},gu=zod.z.enum(["NotRequested","Pending","Verified","Rejected","Expired"]),yu={None:"None",Tier1:"Tier1",Tier2:"Tier2",Tier3:"Tier3"},Cu=zod.z.enum(["None","Tier1","Tier2","Tier3"]),Su={Pending:"Pending",Completed:"Completed",Failed:"Failed",Expired:"Expired",Abandoned:"Abandoned"},_r=zod.z.enum(["Pending","Completed","Failed","Expired","Abandoned"]),mn={GameTopUp:"game_topup",CommunityReward:"community_reward"};function Ss(c){let e=c?.trim();return e||mn.GameTopUp}var xu={UsersCryptoWallet:"UsersCryptoWallet",Game:"Game"},hn=zod.z.enum(["UsersCryptoWallet","Game"]),Du=zod.z.object({ContractAddress:zod.z.string().nullish(),ItemCatalogID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish()}).passthrough(),fn=zod.z.object({Ios:zod.z.boolean().nullish(),Android:zod.z.boolean().nullish(),Web:zod.z.boolean().nullish()}).passthrough(),bu=zod.z.object({NetworkID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Type:du.nullish(),ChainID:zod.z.number().nullish(),ChainTicker:zod.z.string().nullish(),RewardPoolAddress:zod.z.string().nullish(),VaultDepositAddress:zod.z.string().nullish(),ChainConfigVersion:zod.z.number().nullish(),RequiredConfirmations:zod.z.number().nullish(),DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),NftDepositsEnabled:zod.z.boolean().nullish(),NftWithdrawalsEnabled:zod.z.boolean().nullish(),PlatformOverrides:fn.nullish(),NftCollections:zod.z.array(Du).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),zu=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),NftDepositsEnabled:zod.z.boolean().nullish(),NftWithdrawalsEnabled:zod.z.boolean().nullish(),PlatformOverrides:fn.nullish()}).passthrough(),vu=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 Tu=zod.z.enum(["OnChain","Combined"]),Iu=zod.z.object({Enabled:zod.z.boolean().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),MinBalance:w.nullish(),BalanceSource:Tu.nullish(),DenyMessage:zod.z.string().nullish()}).passthrough(),Pu=zod.z.object({Enabled:zod.z.boolean().nullish(),TokenGates:zod.z.array(Iu).nullish(),WalletConnectProjectId:zod.z.string().nullish()}).passthrough(),Wr=zod.z.object({SystemState:zu.nullish(),Networks:zod.z.record(zod.z.string(),bu).nullish(),AccountSafety:vu.nullish(),WalletLogin:Pu.nullish()}).passthrough(),Mu=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),LinkedAt:a.nullish(),LastUsedAt:a.nullish(),LinkType:hu.nullish(),IsSignatureVerified:zod.z.boolean().nullish()}).passthrough(),Rn=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Type:dn.nullish(),NetworkID:zod.z.string().nullish(),AssetID:zod.z.string().nullish(),Amount:w.nullish(),CreatedAt:a.nullish(),ExpiresAt:a.nullish()}).passthrough(),ku=zod.z.object({Status:gu.nullish(),Tier:Cu.nullish(),VerifiedAt:a.nullish(),ExpiresAt:a.nullish(),RejectedAt:a.nullish(),ProviderReference:zod.z.string().nullish(),RejectionReason:zod.z.string().nullish()}).passthrough(),Au=zod.z.object({CurrencyID:zod.z.string().nullish(),Deposits:zod.z.number().nullish(),DepositsVolumeNative:w.nullish(),DepositsVolumeUsd:w.nullish(),Withdrawals:zod.z.number().nullish(),WithdrawalsVolumeNative:w.nullish(),WithdrawalsVolumeUsd:w.nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),FirstDepositAt:a.nullish(),LastDepositAt:a.nullish(),FirstWithdrawalAt:a.nullish(),LastWithdrawalAt:a.nullish()}).passthrough(),Ou=zod.z.object({TotalDeposits:zod.z.number().nullish(),TotalWithdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),TotalDepositsVolumeUsd:w.nullish(),TotalWithdrawalsVolumeUsd:w.nullish(),PerCurrency:zod.z.record(zod.z.string(),Au).nullish()}).passthrough(),Uu=zod.z.object({NetworkID:zod.z.string().nullish(),ItemCatalogID:zod.z.string().nullish(),Deposits:zod.z.number().nullish(),Withdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),FirstDepositAt:a.nullish(),LastDepositAt:a.nullish(),FirstWithdrawalAt:a.nullish(),LastWithdrawalAt:a.nullish()}).passthrough(),Bu=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(),Uu).nullish()}).passthrough(),wu=zod.z.object({Tokens:Ou.nullish(),Nfts:Bu.nullish()}).passthrough(),qu=zod.z.object({CurrencyID:zod.z.string().nullish(),Balance:w.nullish(),MinBalance:w.nullish()}).passthrough(),Eu=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),CheckedAt:a.nullish(),LoggedInAt:a.nullish(),GatePassed:zod.z.boolean().nullish(),GatedBalances:zod.z.array(qu).nullish()}).passthrough(),Lu=zod.z.object({Version:zod.z.number().nullish(),Stats:wu.nullish(),LinkedWallets:zod.z.record(zod.z.string(),Mu).nullish(),LastWalletLogin:Eu.nullish(),PendingWithdrawals:zod.z.array(Rn).nullish(),Kyc:ku.nullish(),FirstActivityAt:a.nullish(),LastActivityAt:a.nullish(),IsFlagged:zod.z.boolean().nullish(),FlagReason:zod.z.string().nullish()}).passthrough(),Gu=zod.z.object({CurrencyID:zod.z.string(),AmountDelta:w,FrozenDelta:w,UpdatedAt:a}).passthrough(),xs=zod.z.object({CryptoBalances:zod.z.record(zod.z.string(),Gu).nullish(),PendingAdded:Rn.nullish(),PendingRemovedIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),Nu=zod.z.object({Amount:w,Frozen:w,CreatedAt:a.nullish(),UpdatedAt:a.nullish()}).passthrough().transform(c=>c),ju=zod.z.object({ID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CreatedAt:a.nullish(),UpdatedAt:a.nullish(),UserID:zod.z.string().nullish(),TransactionHash:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ChainType:zod.z.string().nullish(),ChainID:zod.z.number().nullish(),Direction:hn.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:w.nullish(),Status:_r.nullish(),SignatureData:zod.z.string().nullish(),CompletedAt:a.nullish(),ExpiresAt:a.nullish(),FailReason:zod.z.string().nullish(),Reason:zod.z.string().nullish(),Category:zod.z.string().nullish(),TokenID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountUsd:w.nullish(),NetPayoutAmount:w.nullish()}).passthrough(),Fu=zod.z.object({ID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CreatedAt:a.nullish(),UpdatedAt:a.nullish(),UserID:zod.z.string().nullish(),TransactionHash:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ChainType:zod.z.string().nullish(),ChainID:zod.z.number().nullish(),Direction:hn.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:w.nullish(),Status:_r.nullish(),SignatureData:zod.z.string().nullish(),CompletedAt:a.nullish(),ExpiresAt:a.nullish(),FailReason:zod.z.string().nullish(),Reason:zod.z.string().nullish(),Category:zod.z.string().nullish(),NFTID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),SkinID:zod.z.string().nullish()}).passthrough(),Vr=zod.z.object({TokenAddress:zod.z.string().nullish(),WalletAddress:zod.z.string().nullish(),Amount:zod.z.string().nullish(),BurnAmount:zod.z.string().nullish(),TokenId:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),ContractAddress:zod.z.string().nullish(),UserID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),Category:zod.z.string().nullish(),Deadline:zod.z.string().nullish(),Signature:zod.z.string().nullish()}).passthrough(),Qr=zod.z.object({Mint:zod.z.string().nullish(),WalletAddress:zod.z.string().nullish(),Amount:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),ExpiresAt:zod.z.string().nullish(),ProgramID:zod.z.string().nullish(),SignatureHex:zod.z.string().nullish(),SigIxIndex:zod.z.number().nullish(),Ed25519PublicKey:zod.z.string().nullish(),Ed25519Message:zod.z.string().nullish(),UserID:zod.z.string().nullish()}).passthrough(),gn=zod.z.object({Blockchain:Wr.nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Lr).nullish()}).passthrough(),yn=zod.z.object({State:Lu.nullish(),CryptoBalances:zod.z.record(zod.z.string(),Nu).nullish()}).passthrough(),Cn=zod.z.object({ServerTimeUtc:a.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:w.nullish(),AmountUsd:w.nullish(),StateDelta:xs.nullish()}).passthrough(),Sn=zod.z.object({ServerTimeUtc:a.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),NftTokenID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),Resources:S.nullish(),Inventory:Ze.nullish()}).passthrough(),xn=zod.z.object({ServerTimeUtc:a.nullish(),TitleTransactionID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:w.nullish(),NetAmountNative:w.nullish(),BurnAmountNative:w.nullish(),AmountUsd:w.nullish(),ExpiresAt:a.nullish(),EvmSignature:Vr.nullish(),SolanaSignature:Qr.nullish(),StateDelta:xs.nullish()}).passthrough(),Dn=zod.z.object({ServerTimeUtc:a.nullish(),TitleTransactionID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),NftTokenID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),ExpiresAt:a.nullish(),Resources:S.nullish(),EvmSignature:Vr.nullish(),SolanaSignature:Qr.nullish(),StateDelta:xs.nullish(),Inventory:Ze.nullish()}).passthrough(),bn=zod.z.object({TokenTransactions:zod.z.array(ju).nullish(),NFTTransactions:zod.z.array(Fu).nullish()}).passthrough(),Hr=zod.z.object({ServerTimeUtc:a.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:w.nullish(),AmountUsd:w.nullish(),Target:zod.z.string().nullish()}).passthrough(),zn=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Kind:dn.nullish(),EvmSignature:Vr.nullish(),SolanaSignature:Qr.nullish()}).passthrough(),vn=zod.z.object({TitleTransactionID:zod.z.string().nullish(),OnChainTxHash:zod.z.string().nullish(),Status:_r.nullish(),StateDelta:xs.nullish()}).passthrough(),ve={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",DepositToken:"DepositToken",DepositNFT:"DepositNFT",RequestTokenWithdrawal:"RequestTokenWithdrawal",RequestNFTWithdrawal:"RequestNFTWithdrawal",GetTransactionHistory:"GetTransactionHistory",RetryWithdrawal:"RetryWithdrawal",ConfirmWithdrawal:"ConfirmWithdrawal",DonateToDeveloper:"DonateToDeveloper",DonateToUsersPool:"DonateToUsersPool"};var _u="Blockchain",Ds=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.blockchain.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(_u,t.data.Blockchain),this.ctx.emitter.emit("blockchain:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.blockchain.getUserState(e);return t.ok&&(this.ctx.data.user.applyBlockchainState(t.data.State??null,t.data.CryptoBalances),this.ctx.emitter.emit("blockchain:userStateLoaded",t.data)),t}async depositToken(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.NetworkID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.depositToken(s);return r.ok&&r.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(r.data.CurrencyID,new Ut__default.default(r.data.AmountNative??0),r.data.ServerTimeUtc??void 0),this.ctx.emitter.emit("blockchain:tokenDeposited",r.data)),r}async depositNFT(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.NetworkID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.depositNFT(s);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("blockchain:nftDeposited",r.data)),r}async requestTokenWithdrawal(e,t,s,r,i){if(!e)return n("client","CurrencyID is required.");if(!t)return n("client","NetworkID is required.");if(!s)return n("client","WalletAddress is required.");if(!r)return n("client","Amount is required.");let u=this.baseRequest();if(!u)return n("unauthorized","Not logged in.");u.CurrencyID=e,u.NetworkID=t,u.WalletAddress=s,u.Amount=r,u.Category=Ss(i);let m=await this.ctx.api.blockchain.requestTokenWithdrawal(u);return m.ok&&m.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(m.data.CurrencyID,new Ut__default.default(m.data.AmountNative??0).negated(),m.data.ServerTimeUtc??void 0),this.ctx.emitter.emit("blockchain:tokenWithdrawalRequested",m.data)),m}async requestNFTWithdrawal(e,t,s,r,i,u,m){if(!e)return n("client","ItemID is required.");if(!t)return n("client","NetworkID is required.");if(!s)return n("client","WalletAddress is required.");if(!r)return n("client","Amount is required.");let z=this.baseRequest();if(!z)return n("unauthorized","Not logged in.");z.ItemID=e,z.NetworkID=t,z.WalletAddress=s,z.Amount=r,z.Category=Ss(i),u!==void 0&&(z.Level=u),m&&(z.ItemInstanceID=m);let B=await this.ctx.api.blockchain.requestNFTWithdrawal(z);return B.ok&&(this.ctx.data.user.applyResourceOperation(B.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("blockchain:nftWithdrawalRequested",B.data)),B}async getTransactionHistory(e=50){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Amount=String(e);let s=await this.ctx.api.blockchain.getTransactionHistory(t);return s.ok&&this.ctx.emitter.emit("blockchain:transactionHistoryLoaded",s.data),s}async retryWithdrawal(e){if(!e)return n("client","TitleTransactionID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.TitleTransactionID=e;let s=await this.ctx.api.blockchain.retryWithdrawal(t);return s.ok&&this.ctx.emitter.emit("blockchain:withdrawalRetried",s.data),s}async confirmWithdrawal(e,t){if(!e)return n("client","TitleTransactionID is required.");if(!t)return n("client","On-chain TransactionHash is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.TitleTransactionID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.confirmWithdrawal(s);return r.ok&&this.ctx.emitter.emit("blockchain:withdrawalConfirmed",r.data),r}async donateToDeveloper(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.NetworkID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.donateToDeveloper(s);return r.ok&&this.ctx.emitter.emit("blockchain:donatedToDeveloper",r.data),r}async donateToUsersPool(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.NetworkID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.donateToUsersPool(s);return r.ok&&this.ctx.emitter.emit("blockchain:donatedToUsersPool",r.data),r}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Wu=zod.z.object({ExperimentID:zod.z.string().nullish(),Variants:zod.z.array(zod.z.string()).nullish()}).passthrough(),H=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:Wu.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 Vu=zod.z.object({OffsetSecondsFromParentStart:zod.z.number().nullish(),DurationSeconds:zod.z.number().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Qu=zod.z.object({StartUtc:zod.z.string().nullish(),EndUtc:zod.z.string().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Hu=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 $u=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 et=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(),le=zod.z.object({Mode:zod.z.string().nullish(),IsActive:zod.z.boolean().nullish(),Scheduled:Qu.nullish(),Chain:Hu.nullish(),Cyclic:$u.nullish(),ActivationTriggers:zod.z.array(et).nullish(),Relative:Vu.nullish()}).passthrough();var ge=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 Ku={Head:"Head",Torso:"Torso",Legs:"Legs"},bs=zod.z.enum(["Head","Torso","Legs"]),Zu={Open:"Open",InProgress:"InProgress",Cancelled:"Cancelled",Completed:"Completed"},$r=zod.z.enum(["Open","InProgress","Cancelled","Completed"]),Pn=zod.z.object({AttackTarget:bs,DefenseTarget:bs});var Ju=zod.z.enum(["Hit","Critical","Block","Dodge"]),Yu=zod.z.object({RoundIndex:zod.z.number().nullish(),AttackerID:zod.z.string().nullish(),DefenderID:zod.z.string().nullish(),AttackZone:bs.nullish(),DefenseZone:bs.nullish(),HitType:Ju.nullish(),DamageDealt:zod.z.number().nullish(),DefenderHpRemaining:zod.z.number().nullish()}).passthrough(),Xu=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(),ec=zod.z.object({ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Quantity:zod.z.number().nullish(),RemainingUses:zod.z.number().nullish(),Level:zod.z.number().nullish(),AcquiredAt:a,ExpiresAt:a.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(c=>c),In=zod.z.object({UserID:zod.z.string().nullish(),SelectedCharacterID:zod.z.string().nullish(),SelectedCharacter:Gr.nullish(),BattleStrategy:zod.z.array(Pn).nullish(),UnstackableItems:zod.z.record(zod.z.string(),ec).nullish(),Stats:Xu.nullish()}).passthrough(),tc=zod.z.object({WinnerUserID:zod.z.string().nullish(),LoserUserID:zod.z.string().nullish(),Entry:ne.nullish(),NetReward:ne.nullish(),BattleLog:zod.z.array(Yu).nullish(),IsDraw:zod.z.boolean().nullish(),P1BattleProfile:In.nullish(),P2BattleProfile:In.nullish()}).passthrough(),Mn=zod.z.object({MatchID:zod.z.string(),TitleID:zod.z.string().nullish(),RuleID:zod.z.string().nullish(),CreatedAt:a.nullish(),CreatorID:zod.z.string().nullish(),CreatorCharacterID:zod.z.string().nullish(),CreatorStrategy:zod.z.array(Pn).nullish(),TargetUserID:zod.z.string().nullish(),Entry:ne.nullish(),CreationCostPaid:ne.nullish(),RefundCreationCostOnCancel:zod.z.boolean().nullish(),JoinedByUserID:zod.z.string().nullish(),JoinedByCharacterID:zod.z.string().nullish(),JoinedAt:a.nullish(),Status:$r.nullish(),WinnerUserID:zod.z.string().nullish(),CompletedAt:a.nullish(),IsRewardDistributed:zod.z.boolean().nullish(),RewardDistributedAt:a.nullish()}).passthrough(),kn=zod.z.object({Status:$r,MatchID:zod.z.string(),Entry:ne.nullish(),Resources:S.nullish()}),An=zod.z.object({Match:Mn.nullish()}),On=zod.z.object({MatchID:zod.z.string(),Status:$r,Resources:S.nullish()}),Un=zod.z.object({Battle:tc.nullish(),Resources:S.nullish(),ResourcesDual:Xe.nullish()}),Kr=zod.z.object({Matches:zod.z.array(Mn).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}),Ne={CreateMatch:"CreateMatch",UpdateMatch:"UpdateMatch",CancelMatch:"CancelMatch",InstantBattle:"InstantBattle",SaveStrategy:"SaveStrategy",GetMyMatches:"GetMyMatches",GetAvailableMatches:"GetAvailableMatches",GetDefinitions:"GetDefinitions"};var sc=zod.z.enum(["VirtualCurrency","Item","EventToken"]);var rc=zod.z.enum(["Constant","Stat","RankMultiplier","AllMight","GearFlat","GearPercent"]),ic=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(),nc=zod.z.object({MaxRounds:zod.z.number().nullish(),BlockDamageMultiplier:zod.z.number().nullish(),MinHitDamage:zod.z.number().nullish(),DefaultCritMultiplier:zod.z.number().nullish(),MaxCritChance:zod.z.number().nullish(),MaxDodgeChance:zod.z.number().nullish()}).passthrough(),oc=zod.z.object({Source:rc.nullish(),StatID:zod.z.string().nullish(),Value:zod.z.number().nullish(),OnePlus:zod.z.boolean().nullish()}).passthrough(),ac=zod.z.object({Coefficient:zod.z.number().nullish(),Factors:zod.z.array(oc).nullish()}).passthrough(),tt=zod.z.object({Terms:zod.z.array(ac).nullish()}).passthrough(),lc=zod.z.object({Health:tt.nullish(),Damage:tt.nullish(),Armor:tt.nullish(),AttackSpeed:tt.nullish(),CritChance:tt.nullish(),CritDamage:tt.nullish(),Dodge:tt.nullish()}).passthrough(),Bn=zod.z.object({StatMapping:ic.nullish(),Combat:nc.nullish(),Formula:lc.nullish()}).passthrough(),uc=zod.z.object({BurnRate:zod.z.number().nullish()}).passthrough(),Zr=zod.z.object({Kind:sc.nullish(),CurrencyID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),TokenType:Gt.nullish(),EntityID:zod.z.string().nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish()}).passthrough(),wn=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(Zr).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),qn=zod.z.object({Cost:Q.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(),cc=zod.z.object({RuleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Economy:uc.nullish(),Entry:wn.nullish(),Creation:qn.nullish(),Settings:Bn.nullish()}).passthrough(),pc=zod.z.object({Rules:zod.z.record(zod.z.string(),cc).nullish(),Defaults:Bn.nullish(),EntryDefaults:wn.nullish(),CreationDefaults:qn.nullish()}).passthrough(),Jr=zod.z.object({InstantBattle:pc.nullish()}).passthrough(),En=Jr;var dc={Listing:"Listing",Auction:"Auction",BuyOrder:"BuyOrder",DirectTrade:"DirectTrade"},Yr=zod.z.enum(["Listing","Auction","BuyOrder","DirectTrade"]),mc={Active:"Active",Completed:"Completed",Cancelled:"Cancelled",Declined:"Declined",Expired:"Expired"},Xr=zod.z.enum(["Active","Completed","Cancelled","Declined","Expired"]),hc={Burn:"Burn",Ledger:"Ledger"},fc=zod.z.enum(["Burn","Ledger"]),vs={Item:"Item",VirtualCurrency:"VirtualCurrency"},ei=zod.z.enum(["Item","VirtualCurrency"]),Rc=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:k.nullish()}).passthrough(),gc=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(Zr).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),yc=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:k.nullish(),Sink:fc.nullish(),LedgerAccountID:zod.z.string().nullish(),PerCatalogOverrides:zod.z.record(zod.z.string(),Rc).nullish(),ApplyToDirectTrades:zod.z.boolean().nullish()}).passthrough(),Cc=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(),Sc=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(),ListingFee:Q.nullish(),RefundListingFeeOnCancel:zod.z.boolean().nullish()}).passthrough(),xc=zod.z.object({Enabled:zod.z.boolean().nullish(),MinDurationHours:zod.z.number().nullish(),MaxDurationHours:zod.z.number().nullish(),AntiSnipeWindowSeconds:zod.z.number().nullish(),AntiSnipeExtensionSeconds:zod.z.number().nullish(),MaxAntiSnipeExtensions:zod.z.number().nullish(),MinBidStepPercent:zod.z.number().nullish(),MinBidStepAbsolute:k.nullish(),BidLimits:ue.nullish()}).passthrough(),Dc=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(),bc=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(),zc=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),ti=zod.z.object({Enabled:zod.z.boolean().nullish(),Gate:H.nullish(),Schedule:le.nullish(),PricePolicy:gc.nullish(),Commission:yc.nullish(),Tradability:Cc.nullish(),Listings:Sc.nullish(),Auctions:xc.nullish(),BuyOrders:Dc.nullish(),DirectTrades:bc.nullish(),Matching:zc.nullish()}).passthrough(),Ln=zod.z.object({BidIndex:zod.z.number().nullish(),UserID:zod.z.string().nullish(),Amount:k.nullish(),Settled:zod.z.boolean().nullish(),SettledAt:a.nullish()}).passthrough(),vc=zod.z.object({BidAxisType:Lt.nullish(),BidCurrencyID:zod.z.string().nullish(),BidCatalogID:zod.z.string().nullish(),BidItemID:zod.z.string().nullish(),StartingBid:k.nullish(),CurrentBid:k.nullish(),CurrentBidderID:zod.z.string().nullish(),BidCount:zod.z.number().nullish(),ExtensionCount:zod.z.number().nullish(),PendingRefunds:zod.z.array(Ln).nullish()}).passthrough(),zs=zod.z.object({LastAt:a.nullish(),DailyCount:zod.z.number().nullish(),DailyResetUtc:a.nullish()}).passthrough(),Tc=zod.z.object({Create:zs.nullish(),Buy:zs.nullish(),Sell:zs.nullish(),Bid:zs.nullish()}).passthrough(),Ic=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),Pc=zod.z.object({ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Quantity:zod.z.number().nullish(),RemainingUses:zod.z.number().nullish(),Level:zod.z.number().nullish(),AcquiredAt:a,ExpiresAt:a.nullish(),EquippedSlot:Ic.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(c=>c),Ve=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:Yr.nullish(),Status:Xr.nullish(),CreatorUserID:zod.z.string().nullish(),CreatorPublicData:ge.nullish(),TargetUserID:zod.z.string().nullish(),GoodsType:ei.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:k.nullish(),GoodsInstances:zod.z.array(Pc).nullish(),Price:ne.nullish(),Auction:vc.nullish(),CreatedAt:a.nullish(),ExpiresAt:a.nullish()}).passthrough(),Mc=zod.z.object({GoodsType:ei.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),CountsByType:zod.z.record(Yr,k).nullish(),ListingCount:k.nullish(),AuctionCount:k.nullish(),BuyOrderCount:k.nullish()}).passthrough(),Gn=zod.z.object({Definitions:ti.nullish(),IsOpenNow:zod.z.boolean().nullish(),GatePassed:zod.z.boolean().nullish()}).passthrough(),si=zod.z.object({Offers:zod.z.array(Ve).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),Nn=zod.z.object({Groups:zod.z.array(Mc).nullish()}).passthrough(),jn=zod.z.object({Offer:Ve.nullish()}).passthrough(),ke=zod.z.object({OfferID:zod.z.string().nullish(),Status:Xr.nullish(),Settlement:Xe.nullish(),Resources:S.nullish(),CommissionTaken:ne.nullish()}).passthrough(),zt=zod.z.object({OfferID:zod.z.string().nullish(),Offer:Ve.nullish(),Resources:S.nullish(),Matched:zod.z.boolean().nullish(),Settlement:ke.nullish()}).passthrough(),Fn=zod.z.object({OfferID:zod.z.string().nullish(),CurrentBid:k.nullish(),BidCount:zod.z.number().nullish(),ExpiresAt:a.nullish(),Resources:S.nullish()}).passthrough(),_n=zod.z.object({MyOffers:zod.z.array(Ve).nullish(),MyLeadingBids:zod.z.array(Ve).nullish(),MyBuyOrders:zod.z.array(Ve).nullish(),IncomingTrades:zod.z.array(Ve).nullish(),OutgoingTrades:zod.z.array(Ve).nullish(),Claimables:zod.z.array(Ve).nullish(),DrainedRefunds:zod.z.array(Ln).nullish(),Limits:Tc.nullish()}).passthrough(),kc=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:Yr.nullish(),FinalStatus:Xr.nullish(),SellerUserID:zod.z.string().nullish(),BuyerUserID:zod.z.string().nullish(),GoodsType:ei.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:k.nullish(),PricePaid:ne.nullish(),CommissionTaken:ne.nullish(),CompletedAt:a.nullish()}).passthrough(),Wn=zod.z.object({Entries:zod.z.array(kc).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),te={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 Ac="Marketplace",Ts=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.marketplace.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Ac,t.data.Definitions),this.ctx.emitter.emit("marketplace:definitionsLoaded",t.data)),t}async getGroupedOffers(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.marketplace.getGroupedOffers(e);return t.ok&&this.ctx.emitter.emit("marketplace:groupedOffersLoaded",t.data),t}async getOffersByItem(e,t,s,r=20){if(!e)return n("client","ItemID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.ItemID=e,i.OfferTypeFilter=t,i.ContinuationToken=s,i.PageSize=r;let u=await this.ctx.api.marketplace.getOffersByItem(i);return u.ok&&this.ctx.emitter.emit("marketplace:offersByItemLoaded",u.data),u}async getOffer(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let s=await this.ctx.api.marketplace.getOffer(t);return s.ok&&this.ctx.emitter.emit("marketplace:offerLoaded",s.data),s}async getBuyOrders(e,t,s=20){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.ItemID=e,r.ContinuationToken=t,r.PageSize=s;let i=await this.ctx.api.marketplace.getBuyOrders(r);return i.ok&&this.ctx.emitter.emit("marketplace:buyOrdersLoaded",i.data),i}async getMyState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.marketplace.getMyState(e);return t.ok&&(this.ctx.data.user.applyMarketplaceState(t.data.Limits??null),this.ctx.emitter.emit("marketplace:myStateLoaded",t.data)),t}async getHistory(e,t=20){let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.ContinuationToken=e,s.PageSize=t;let r=await this.ctx.api.marketplace.getHistory(s);return r.ok&&this.ctx.emitter.emit("marketplace:historyLoaded",r.data),r}async createListing(e,t,s,r,i,u){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");if(!r)return n("client","PriceBundle is required.");let m=this.baseRequest();if(!m)return n("unauthorized","Not logged in.");m.ItemID=e,m.CatalogID=t,m.GoodsAmount=s,m.PriceBundle=r,m.DurationHours=i,m.ItemInstanceIDs=u;let z=await this.ctx.api.marketplace.createListing(m);return this.applyCreateOfferResult(z,"marketplace:listingCreated"),z}async cancelListing(e){return this.cancelOffer(e,t=>this.ctx.api.marketplace.cancelListing(t),"marketplace:listingCancelled")}async buy(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let s=await this.ctx.api.marketplace.buy(t);return s.ok&&(this.applyDualPartySettlement(s.data.Settlement),this.ctx.emitter.emit("marketplace:bought",s.data)),s}async marketBuy(e,t,s){if(!e||e<=0)return n("client","GoodsAmount must be positive.");if(!t)return n("client","PriceBundle is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");let i=this.applyGoodsSelector(r,s);if(i)return i;r.GoodsAmount=e,r.PriceBundle=t;let u=await this.ctx.api.marketplace.marketBuy(r);return u.ok&&(this.applyDualPartySettlement(u.data.Settlement),this.ctx.emitter.emit("marketplace:marketBought",u.data)),u}async marketSell(e,t,s){if(!e||e<=0)return n("client","GoodsAmount must be positive.");if(!t)return n("client","PriceBundle is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");let i=this.applyGoodsSelector(r,s);if(i)return i;r.GoodsAmount=e,r.PriceBundle=t;let u=await this.ctx.api.marketplace.marketSell(r);return u.ok&&(this.applyDualPartySettlement(u.data.Settlement),this.ctx.emitter.emit("marketplace:marketSold",u.data)),u}async createAuction(e,t,s,r,i,u,m={}){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");let z=this.baseRequest();if(!z)return n("unauthorized","Not logged in.");z.ItemID=e,z.CatalogID=t,z.GoodsAmount=s,z.BidAxisType=r,z.BidCurrencyID=m.bidCurrencyID,z.BidCatalogID=m.bidCatalogID,z.BidItemID=m.bidItemID,z.StartingBid=i,z.DurationHours=u,z.ItemInstanceIDs=m.itemInstanceIDs;let B=await this.ctx.api.marketplace.createAuction(z);return this.applyCreateOfferResult(B,"marketplace:auctionCreated"),B}async placeBid(e,t){if(!e)return n("client","OfferID is required.");if(!t||t<=0)return n("client","BidAmount must be positive.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.OfferID=e,s.BidAmount=t;let r=await this.ctx.api.marketplace.placeBid(s);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:bidPlaced",r.data)),r}async claimAuction(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let s=await this.ctx.api.marketplace.claimAuction(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:auctionClaimed",s.data)),s}async createBuyOrder(e,t,s,r,i){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");if(!r)return n("client","PriceBundle is required.");let u=this.baseRequest();if(!u)return n("unauthorized","Not logged in.");u.ItemID=e,u.CatalogID=t,u.GoodsAmount=s,u.PriceBundle=r,u.DurationHours=i;let m=await this.ctx.api.marketplace.createBuyOrder(u);return this.applyCreateOfferResult(m,"marketplace:buyOrderCreated"),m}async cancelBuyOrder(e){return this.cancelOffer(e,t=>this.ctx.api.marketplace.cancelBuyOrder(t),"marketplace:buyOrderCancelled")}async fillBuyOrder(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let s=await this.ctx.api.marketplace.fillBuyOrder(t);return s.ok&&(this.applyDualPartySettlement(s.data.Settlement),this.ctx.emitter.emit("marketplace:buyOrderFilled",s.data)),s}async createDirectTrade(e,t,s,r,i){if(!e)return n("client","TargetUserID is required.");if(!t)return n("client","CatalogID is required.");if(!s)return n("client","ItemID is required.");let u=this.baseRequest();if(!u)return n("unauthorized","Not logged in.");u.TargetUserID=e,u.CatalogID=t,u.ItemID=s,u.ItemInstanceIDs=r,u.RequestedBundle=i;let m=await this.ctx.api.marketplace.createDirectTrade(u);return this.applyCreateOfferResult(m,"marketplace:directTradeCreated"),m}async respondDirectTrade(e,t){if(!e)return n("client","OfferID is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.OfferID=e,s.Accept=t;let r=await this.ctx.api.marketplace.respondDirectTrade(s);return r.ok&&(t&&(r.data.Settlement?this.applyDualPartySettlement(r.data.Settlement):r.data.Resources&&this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions)),this.ctx.emitter.emit("marketplace:directTradeResponded",r.data)),r}async cancelDirectTrade(e){return this.cancelOffer(e,t=>this.ctx.api.marketplace.cancelDirectTrade(t),"marketplace:directTradeCancelled")}async claimBack(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let s=await this.ctx.api.marketplace.claimBack(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:claimedBack",s.data)),s}async cancelOffer(e,t,s){if(!e)return n("client","OfferID is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.OfferID=e;let i=await t(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit(s,i.data)),i}applyCreateOfferResult(e,t){e.ok&&(e.data.Matched&&e.data.Settlement?this.applyDualPartySettlement(e.data.Settlement.Settlement):this.ctx.data.user.applyResourceOperation(e.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit(t,e.data));}applyGoodsSelector(e,t){return "goodsCurrencyID"in t&&t.goodsCurrencyID?(e.GoodsType=vs.VirtualCurrency,e.GoodsCurrencyID=t.goodsCurrencyID,null):"itemID"in t&&t.itemID&&t.catalogID?(e.GoodsType=vs.Item,e.ItemID=t.itemID,e.CatalogID=t.catalogID,null):n("client","Either itemID+catalogID or goodsCurrencyID is required.")}applyDualPartySettlement(e){let t=this.ctx.auth.context?.userID;if(!e||!t)return;let s=this.ctx.data.config.itemDefinitions;e.FromUserID===t&&e.FromResult?this.ctx.data.user.applyResourceOperation(e.FromResult,s):e.ToUserID===t&&e.ToResult&&this.ctx.data.user.applyResourceOperation(e.ToResult,s);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Is=class{constructor(e){this.ctx=e;}ctx;async createRoom(e,t={}){if(!e)return n("client","RoomName is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomName=e,s.Topology=t.topology,s.ChatMode=t.chatMode,s.MaxPlayers=t.maxPlayers,s.Visibility=t.visibility,s.JoinCode=t.joinCode;let r=await this.ctx.api.multiplayer.createRoom(s);return r.ok&&this.ctx.emitter.emit("multiplayer:roomCreated",r.data),r}async joinRoom(e,t){if(!e)return n("client","RoomID is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomID=e,s.JoinCode=t;let r=await this.ctx.api.multiplayer.joinRoom(s);return r.ok&&this.ctx.emitter.emit("multiplayer:roomJoined",r.data),r}async leaveRoom(e){if(!e)return n("client","RoomID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.RoomID=e;let s=await this.ctx.api.multiplayer.leaveRoom(t);return s.ok&&this.ctx.emitter.emit("multiplayer:roomLeft",s.data),s}async listRooms(e=0,t=20){let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.Page=e,s.PageSize=t;let r=await this.ctx.api.multiplayer.listRooms(s);return r.ok&&this.ctx.emitter.emit("multiplayer:roomsListed",r.data),r}async getRoom(e){if(!e)return n("client","RoomID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.RoomID=e;let s=await this.ctx.api.multiplayer.getRoom(t);return s.ok&&this.ctx.emitter.emit("multiplayer:roomLoaded",s.data),s}async closeRoom(e){if(!e)return n("client","RoomID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.RoomID=e;let s=await this.ctx.api.multiplayer.closeRoom(t);return s.ok&&this.ctx.emitter.emit("multiplayer:roomClosed",s.data),s}async poll(e,t){if(!e)return n("client","RoomID is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomID=e,s.LastSeq=t;let r=await this.ctx.api.multiplayer.poll(s);return r.ok&&this.ctx.emitter.emit("multiplayer:polled",r.data),r}async sendSignal(e,t,s,r){if(!e)return n("client","RoomID is required.");if(!t)return n("client","TargetUserID is required.");if(!s)return n("client","SignalKind is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.TargetUserID=t,i.SignalKind=s,i.Payload=r;let u=await this.ctx.api.multiplayer.sendSignal(i);return u.ok&&this.ctx.emitter.emit("multiplayer:signalSent",u.data),u}async sendChat(e,t){if(!e)return n("client","RoomID is required.");if(!t)return n("client","ChatText is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomID=e,s.ChatText=t;let r=await this.ctx.api.multiplayer.sendChat(s);return r.ok&&this.ctx.emitter.emit("multiplayer:chatSent",r.data),r}async setMemberState(e,t,s){if(!e)return n("client","RoomID is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.RoomID=e,r.Ready=t,r.MemberState=s;let i=await this.ctx.api.multiplayer.setMemberState(r);return i.ok&&this.ctx.emitter.emit("multiplayer:memberStateSet",i.data),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Vn=zod.z.object({PlatformUserID:zod.z.string().nullish(),PlatformAuthToken:zod.z.string().nullish(),PlatformAuthTokenExpiration:a.nullish(),TitleUserID:zod.z.string(),TitleClientSessionTicket:zod.z.string(),TitleClientSessionTicketExpiration:a}),ye=zod.z.object({IsCompleted:zod.z.boolean().nullish(),ServerTime:a.nullish()}),Qn=zod.z.object({Message:zod.z.string(),ExpiresAt:a}),Ae={LoginWithDeviceID:"LoginWithDeviceID",LoginWithTelegram:"LoginWithTelegram",LoginWithEmail:"LoginWithEmail",LoginWithGoogle:"LoginWithGoogle",LoginWithPlatformToken:"LoginWithPlatformToken",RegisterWithEmail:"RegisterWithEmail",RefreshPlatformToken:"RefreshPlatformToken",RequestWalletChallenge:"RequestWalletChallenge",LoginWithWallet:"LoginWithWallet",ForgotPassword:"ForgotPassword",ResetPassword:"ResetPassword"};function O(c,e,t,s){let i=`api/v2/${c&&c.length>0?c:"0"}/Client/${e}/${t}`;return s==null?i:`${i}/${s}`}var Ps=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,Vn,{ticket:null})}loginWithDeviceID(e){return this.login(Ae.LoginWithDeviceID,e)}loginWithTelegram(e){return this.login(Ae.LoginWithTelegram,e)}loginWithEmail(e){return this.login(Ae.LoginWithEmail,e)}loginWithGoogle(e){return this.login(Ae.LoginWithGoogle,e)}loginWithPlatformToken(e){return this.login(Ae.LoginWithPlatformToken,e)}registerWithEmail(e){return this.login(Ae.RegisterWithEmail,e)}requestWalletChallenge(e){return this.ctx.transport.post(this.endpoint(Ae.RequestWalletChallenge),e,Qn,{ticket:null})}loginWithWallet(e){return this.login(Ae.LoginWithWallet,e)}forgotPassword(e){return this.ctx.transport.post(this.endpoint(Ae.ForgotPassword),e,ye,{ticket:null})}resetPassword(e){return this.ctx.transport.post(this.endpoint(Ae.ResetPassword),e,ye,{ticket:null})}};var ri=zod.z.object({Title:zod.z.unknown().nullish(),User:zod.z.unknown().nullish()}).passthrough().transform(c=>c),Hn=zod.z.object({}).passthrough().transform(c=>c),$n=zod.z.object({}).passthrough().transform(c=>c),Kn=zod.z.object({Today:zod.z.number(),Yesterday:zod.z.number(),CurrentWeek:zod.z.number(),CurrentMonth:zod.z.number(),Total:zod.z.number(),TotalSessions:zod.z.number(),FirstActiveAt:a.nullish(),LastActiveAt:a.nullish(),LongestSessionEverSeconds:zod.z.number().nullish(),CurrentWeekActiveHoursMask:zod.z.number().nullish(),CurrentMonthActiveHoursMask:zod.z.number().nullish(),ReactivationCount:zod.z.number().nullish(),History:zod.z.record(zod.z.string(),zod.z.unknown()).nullish()}).passthrough(),Zn=zod.z.object({Username:zod.z.string()}),je={GetClientState:"GetClientState",GetClientStateExcept:"GetClientStateExcept",GetInventory:"GetInventory",GetEventTokens:"GetEventTokens",GetUsageTime:"GetUsageTime",AddUsageTime:"AddUsageTime",DeleteUserAccount:"DeleteUserAccount",ChangeUsername:"ChangeUsername"};var Ms=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,ri,{ticket:e.ClientSessionTicket})}getClientStateExcept(e){return this.ctx.transport.post(this.endpoint(je.GetClientStateExcept,e.UserID),e,ri,{ticket:e.ClientSessionTicket})}getInventory(e){return this.ctx.transport.post(this.endpoint(je.GetInventory,e.UserID),e,Hn,{ticket:e.ClientSessionTicket})}getEventTokens(e){return this.ctx.transport.post(this.endpoint(je.GetEventTokens,e.UserID),e,$n,{ticket:e.ClientSessionTicket})}getUsageTime(e){return this.ctx.transport.post(this.endpoint(je.GetUsageTime,e.UserID),e,Kn,{ticket:e.ClientSessionTicket})}addUsageTime(e){return this.ctx.transport.post(this.endpoint(je.AddUsageTime,e.UserID),e,ye,{ticket:e.ClientSessionTicket,silent:true})}deleteUserAccount(e){return this.ctx.transport.post(this.endpoint(je.DeleteUserAccount,e.UserID),e,ye,{ticket:e.ClientSessionTicket})}changeUsername(e){return this.ctx.transport.post(this.endpoint(je.ChangeUsername,e.UserID),e,Zn,{ticket:e.ClientSessionTicket})}};var ks=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Currency",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}convert(e){return this.send(fs.Convert,e,$i)}cryptoConvert(e){return this.send(fs.CryptoConvert,e,Ki)}};var Oc=zod.z.object({ItemInstanceID:zod.z.string(),Units:zod.z.number(),Level:zod.z.number()}),ii=zod.z.object({ServerTimeUtc:a,ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Level:zod.z.number(),Resources:S.nullish(),FodderConsumed:zod.z.array(Oc).nullish()}),Jn=zod.z.array(ee(ii)),As={UpgradeLevel:"UpgradeLevel",UpgradeLevelsBatch:"UpgradeLevelsBatch"},Uc={FlatCount:"FlatCount",Merge:"Merge",InvestmentRefund:"InvestmentRefund"},Bc=zod.z.enum(["FlatCount","Merge","InvestmentRefund"]),wc={ProtectLeveled:"ProtectLeveled",CheapestFirst:"CheapestFirst",ClientSelected:"ClientSelected"},qc=zod.z.enum(["ProtectLeveled","CheapestFirst","ClientSelected"]),Ec=zod.z.object({ContractAddress:zod.z.string().nullish(),TokenID:zod.z.string().nullish(),TokenStandard:zod.z.string().nullish()}).passthrough(),Lc=zod.z.object({Networks:zod.z.record(zod.z.string(),Ec).nullish(),MetadataUrl:zod.z.string().nullish()}).passthrough(),Gc=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(),Nc=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(),jc=zod.z.object({ValuationMode:Bc.nullish(),MergeRatio:zod.z.number().nullish(),Selection:qc.nullish()}).passthrough(),Fc=zod.z.object({MaxLevel:zod.z.number().nullish(),BaseCostResource:Q.nullish(),CostScalingFactor:zod.z.number().nullish(),FlatScalingFactor:zod.z.number().nullish(),PercentScalingFactor:zod.z.number().nullish(),PowerScalingFactor:zod.z.number().nullish(),Fodder:jc.nullish()}).passthrough(),_c=zod.z.object({RarityID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),AuthorID:zod.z.string().nullish()}).passthrough(),Wc=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:Lc.nullish(),Stats:Gc.nullish(),Equipment:Nc.nullish(),Upgrade:Fc.nullish(),Metadata:_c.nullish(),ExpirationDurationSeconds:zod.z.number().nullish()}).passthrough(),Vc=zod.z.object({Items:zod.z.record(zod.z.string(),Wc).nullish()}).passthrough(),Os=zod.z.object({Catalogs:zod.z.record(zod.z.string(),Vc).nullish()}).passthrough();var Us=class{constructor(e){this.ctx=e;}ctx;upgradeLevel(e){let t=O(this.ctx.settings.titleID,"Item",As.UpgradeLevel,e.UserID??"");return this.ctx.transport.post(t,e,ii,{ticket:e.ClientSessionTicket})}upgradeLevelsBatch(e){let t=O(this.ctx.settings.titleID,"Item",As.UpgradeLevelsBatch,e.UserID??"");return this.ctx.transport.post(t,e,Jn,{ticket:e.ClientSessionTicket})}};var ni=zod.z.object({ServerTimeUtc:a,OfferID:zod.z.string(),Count:zod.z.number(),Resources:S.nullish()}),Yn=zod.z.array(ee(ni)),Qc=zod.z.object({OfferID:zod.z.string(),TotalPurchases:zod.z.number(),DailyPurchases:zod.z.number(),DailyResetUtc:a,LastPurchasedAt:a}),Xn=zod.z.object({Purchases:zod.z.record(zod.z.string(),Qc).nullish()}).passthrough().transform(c=>c),Hc=zod.z.object({StartUtc:a.nullish(),EndUtc:a.nullish(),RequiredFlags:zod.z.array(zod.z.string()).nullish()}).passthrough(),$c=zod.z.object({StoreID:zod.z.string(),Type:zod.z.string().nullish(),Name:zod.z.string().nullish(),Description:zod.z.string().nullish(),Rules:Hc.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Kc=zod.z.object({StartUtc:a.nullish(),EndUtc:a.nullish(),Gate:H.nullish(),Limits:ue.nullish()}).passthrough(),Zc=zod.z.object({OfferID:zod.z.string(),StoreIDs:zod.z.array(zod.z.string()).nullish(),Name:zod.z.string().nullish(),Cost:Q.nullish(),Rewards:L.nullish(),Rules:Kc.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Bs=zod.z.object({Stores:zod.z.record(zod.z.string(),$c).nullish(),StoreOffers:zod.z.record(zod.z.string(),Zc).nullish()}).passthrough(),mt={Purchase:"Purchase",GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",PurchaseBatch:"PurchaseBatch"};var ws=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Store",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}purchase(e){return this.send(mt.Purchase,e,ni)}purchaseBatch(e){return this.send(mt.PurchaseBatch,e,Yn)}getDefinitions(e){return this.send(mt.GetDefinitions,e,Bs)}getUserState(e){return this.send(mt.GetUserState,e,Xn)}};var Jc=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),eo=zod.z.object({Reward:L.nullish(),Weight:zod.z.number().nullish(),AmountRange:Jc.nullish()}).passthrough(),ht=zod.z.object({SlotID:zod.z.string().nullish(),MinRolls:zod.z.number().nullish(),MaxRolls:zod.z.number().nullish(),Pool:zod.z.array(eo).nullish()}).passthrough(),ft=zod.z.object({RuleID:zod.z.string().nullish(),Threshold:zod.z.number().nullish(),Pool:zod.z.array(eo).nullish()}).passthrough(),Yc=zod.z.object({RewardSlots:zod.z.array(ht).nullish()}).passthrough(),Xc=zod.z.object({PityRules:zod.z.array(ft).nullish()}).passthrough(),qs=zod.z.object({SlotPresets:zod.z.record(zod.z.string(),Yc).nullish(),PityPresets:zod.z.record(zod.z.string(),Xc).nullish()}).passthrough();var ep=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Rewards:L.nullish()}).passthrough(),tp=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),oi=zod.z.object({Bundles:zod.z.array(ep).nullish(),Multipliers:zod.z.array(tp).nullish()}).passthrough();var sp=zod.z.enum(["BoardStageLevel","BoardRank","BoardCyclesCompleted","CharacterLevel","SeasonTier","EventTokenTotalEarned","VirtualCurrencyBalance","PlayerLevel"]);var rp=zod.z.enum(["Tiered","Linear"]);var ip=zod.z.enum(["Step","Linear"]),np=zod.z.object({AtProgress:zod.z.number().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),Es=zod.z.object({Source:sp.nullish(),SourceKey:zod.z.string().nullish(),CurveType:rp.nullish(),Tiers:zod.z.array(np).nullish(),TierMode:ip.nullish(),BaseMultiplier:zod.z.number().nullish(),PerUnit:zod.z.number().nullish(),Anchor:zod.z.number().nullish(),MinMultiplier:zod.z.number().nullish(),MaxMultiplier:zod.z.number().nullish(),IncludeRewards:ne.nullish(),ExcludeRewards:ne.nullish()}).passthrough(),Se=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:oi.nullish(),SortOrder:zod.z.number().nullish(),IsFeatured:zod.z.boolean().nullish()}).passthrough(),Rt=zod.z.object({Milestones:zod.z.record(zod.z.string(),Se).nullish()}).passthrough();var op=zod.z.object({RuleID:zod.z.string(),BoxIndex:zod.z.number().nullish()}),to=zod.z.object({ServerTimeUtc:a,LootboxID:zod.z.string(),OpenedCount:zod.z.number().nullish(),SelectedOptionID:zod.z.number().nullish(),Resources:S.nullish(),Inventory:Ze.nullish(),Results:zod.z.array(S).nullish(),TriggeredPity:zod.z.array(op).nullish()}),ap=zod.z.object({PriceOptionID:zod.z.number().nullish(),RequiredResources:Q.nullish()}).passthrough(),lp=zod.z.object({RewardSlots:me.nullish(),PityRules:me.nullish()}).passthrough(),up=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),MaxDrops:k.nullish()}).passthrough(),cp=zod.z.object({LootboxID:zod.z.string(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),PriceOptions:zod.z.record(zod.z.string(),ap).nullish(),RewardSlots:zod.z.array(ht).nullish(),PityRules:zod.z.array(ft).nullish(),Presets:lp.nullish(),RewardMultiplier:Es.nullish(),SupplyLimits:zod.z.array(up).nullish()}).passthrough(),ai=zod.z.object({Definitions:zod.z.record(zod.z.string(),cp).nullish(),RewardPools:qs.nullish()}).passthrough(),so=zod.z.object({LootboxDefinitions:ai.nullish()}),Ls={GetDefinitions:"GetDefinitions",Open:"Open"};var Gs=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Lootbox",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ls.GetDefinitions,e,so)}open(e){return this.send(Ls.Open,e,to)}};var pp=zod.z.object({}).passthrough().transform(c=>c),dp=zod.z.object({}).passthrough().transform(c=>c),mp=zod.z.object({}).passthrough().transform(c=>c),hp=zod.z.object({}).passthrough().transform(c=>c),fp=zod.z.object({}).passthrough().transform(c=>c),ro=zod.z.object({ServerTimeUtc:a,CalendarID:zod.z.string(),DayNumber:zod.z.number().nullish(),DailyState:pp,Resources:S.nullish()}),io=zod.z.object({ServerTimeUtc:a,AccrualID:zod.z.string(),AccruedSeconds:k.nullish(),AppliedRatePerSecond:zod.z.number().nullish(),IdleState:dp,Resources:S.nullish()}),no=zod.z.object({ServerTimeUtc:a,ComebackID:zod.z.string(),ClaimedTierIndex:zod.z.number().nullish(),ComebackState:mp,Resources:S.nullish()}),oo=zod.z.object({ServerTimeUtc:a,ClaimID:zod.z.string(),ClaimState:hp,Resources:S.nullish()}),ao=zod.z.object({Enabled:zod.z.boolean(),Multiplier:zod.z.number().nullish(),Progress:k.nullish(),Source:zod.z.string().nullish(),SourceKey:zod.z.string().nullish()}),Rp=zod.z.object({RewardMode:zod.z.string().nullish(),RewardStackLowerTiers:zod.z.boolean().nullish()}).passthrough(),gp=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(),yp=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(gp).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:H.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Cp=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),Sp=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(Cp).nullish()}).passthrough(),xp=zod.z.object({MinCharacterLevel:zod.z.number().nullish(),RequirementsCharacterID:zod.z.string().nullish(),Gate:H.nullish(),RequiredItemIDs:zod.z.array(zod.z.string()).nullish(),RequiredEquippedItemIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),Dp=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:Sp.nullish(),Rewards:L.nullish(),MaxAccumulationSeconds:zod.z.number().nullish(),MinClaimSeconds:zod.z.number().nullish(),Requirements:xp.nullish(),FirstClaimMode:zod.z.string().nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),bp=zod.z.object({MinAbsenceSeconds:zod.z.number().nullish(),Rewards:L.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),zp=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(bp).nullish(),ClaimCooldownSeconds:zod.z.number().nullish(),ClaimWindowSeconds:zod.z.number().nullish(),TrackPresenceOnRead:zod.z.boolean().nullish(),Gate:H.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),vp=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(),Tp=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(vp).nullish(),Gate:H.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),li=zod.z.object({TierRewards:Rp.nullish(),MilestoneRewardMultiplier:Es.nullish(),DailyCalendars:zod.z.record(zod.z.string(),yp).nullish(),IdleAccruals:zod.z.record(zod.z.string(),Dp).nullish(),Comebacks:zod.z.record(zod.z.string(),zp).nullish(),Claims:zod.z.record(zod.z.string(),Tp).nullish()}).passthrough(),lo=zod.z.object({RewardDefinitions:li.nullish()}),uo=zod.z.object({Rewards:fp.nullish()}),He={GetRewardDefinitions:"GetRewardDefinitions",GetUserRewardsState:"GetUserRewardsState",ClaimDailyReward:"ClaimDailyReward",CollectIdleAccrual:"CollectIdleAccrual",ClaimComebackReward:"ClaimComebackReward",ClaimReward:"ClaimReward",ClaimRewardsBatch:"ClaimRewardsBatch",GetMilestoneRewardMultiplier:"GetMilestoneRewardMultiplier"};var Ns=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Reward",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getRewardDefinitions(e){return this.send(He.GetRewardDefinitions,e,lo)}getUserRewardsState(e){return this.send(He.GetUserRewardsState,e,uo)}getMilestoneRewardMultiplier(e){return this.send(He.GetMilestoneRewardMultiplier,e,ao)}claimDailyReward(e){return this.send(He.ClaimDailyReward,e,ro)}collectIdleAccrual(e){return this.send(He.CollectIdleAccrual,e,io)}claimComebackReward(e){return this.send(He.ClaimComebackReward,e,no)}claimReward(e){return this.send(He.ClaimReward,e,oo)}};var Ip=zod.z.object({TargetCurrencyID:zod.z.string().nullish(),Rate:zod.z.number().nullish(),MaxConvertAmount:zod.z.number().nullish()}).passthrough(),gt=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:Ip.nullish()}).passthrough();var Pp={Active:"Active",Completed:"Completed",Claimed:"Claimed",Expired:"Expired"},co=zod.z.enum(["Active","Completed","Claimed","Expired"]),Mp=zod.z.object({}).passthrough().transform(c=>c),kp=zod.z.object({CycleID:zod.z.string(),InstanceKey:zod.z.string().nullish(),CycleStartUtc:a.nullish(),CycleEndUtc:a.nullish(),PointsTotalEarned:k.nullish(),PointsCurrent:k.nullish(),ClaimedPointMilestoneIDs:zod.z.array(zod.z.string()).nullish()}),Ap=zod.z.object({QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),ObjectiveID:zod.z.string().nullish(),NewValue:k.nullish(),ObjectiveCompleted:zod.z.boolean().nullish(),Status:co}),po=zod.z.object({State:Mp.nullish(),PointsTracks:zod.z.record(zod.z.string(),kp).nullish()}),ui=zod.z.object({ServerTimeUtc:a,QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),NewStatus:co.nullish(),Resources:S.nullish()}),ci=zod.z.object({ServerTimeUtc:a,CycleID:zod.z.string(),MilestoneID:zod.z.string(),PointsTotalEarned:k.nullish(),Resources:S.nullish()}),mo=zod.z.object({ServerTimeUtc:a,CycleID:zod.z.string(),GroupCompletionID:zod.z.string(),GroupID:zod.z.string().nullish(),CompletedGroupQuests:zod.z.number().nullish(),RequiredGroupQuests:zod.z.number().nullish(),Resources:S.nullish()}),ho=zod.z.object({MetricID:zod.z.string(),Updates:zod.z.array(Ap).nullish()}),fo=zod.z.array(ee(ui)),Ro=zod.z.array(ee(ci)),Op={ClientApi:"ClientApi",ServerApi:"ServerApi",SystemEvent:"SystemEvent"},Up=zod.z.enum(["ClientApi","ServerApi","SystemEvent"]),Bp={BlockProgressAndClaim:"BlockProgressAndClaim",BlockClaimOnly:"BlockClaimOnly"},wp=zod.z.enum(["BlockProgressAndClaim","BlockClaimOnly"]),qp=zod.z.object({ObjectiveID:zod.z.string().nullish(),Source:Up.nullish(),MaxProgressPerCall:zod.z.number().nullish(),MetricID:zod.z.string().nullish(),TargetValue:zod.z.number().nullish(),AggregationMethod:zod.z.string().nullish(),Filters:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Ep=zod.z.object({QuestID:zod.z.string().nullish(),CycleIDs:zod.z.array(zod.z.string()).nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),RequiredQuestIDs:zod.z.array(zod.z.string()).nullish(),PrerequisiteMode:wp.nullish(),PointsReward:zod.z.number().nullish(),Schedule:le.nullish(),AccrueProgressWhenLocked:zod.z.boolean().nullish(),Gate:H.nullish(),Limits:ue.nullish(),GroupID:zod.z.string().nullish(),Objectives:zod.z.record(zod.z.string(),qp).nullish(),Reward:L.nullish()}).passthrough(),Lp=zod.z.object({CompletionID:zod.z.string().nullish(),GroupID:zod.z.string().nullish(),RequiredCompletedQuests:zod.z.number().nullish(),Gate:H.nullish(),Reward:L.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),Gp=zod.z.object({CycleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:le.nullish(),Milestones:zod.z.record(zod.z.string(),Se).nullish(),Gate:H.nullish(),PointsToken:gt.nullish(),GroupCompletions:zod.z.record(zod.z.string(),Lp).nullish()}).passthrough(),js=zod.z.object({Cycles:zod.z.record(zod.z.string(),Gp).nullish(),Quests:zod.z.record(zod.z.string(),Ep).nullish()}).passthrough(),Le={GetQuestDefinitions:"GetQuestDefinitions",GetUserQuestState:"GetUserQuestState",RefreshQuestCycles:"RefreshQuestCycles",ClaimQuestReward:"ClaimQuestReward",ClaimMilestoneReward:"ClaimMilestoneReward",AddQuestProgress:"AddQuestProgress",ClaimQuestRewardsBatch:"ClaimQuestRewardsBatch",ClaimMilestoneRewardsBatch:"ClaimMilestoneRewardsBatch",ClaimGroupCompletionReward:"ClaimGroupCompletionReward"};var Fs=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Quest",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getQuestDefinitions(e){return this.send(Le.GetQuestDefinitions,e,js)}getUserQuestState(e){return this.send(Le.GetUserQuestState,e,po)}refreshQuestCycles(e){return this.send(Le.RefreshQuestCycles,e,ye)}claimQuestReward(e){return this.send(Le.ClaimQuestReward,e,ui)}claimQuestRewardsBatch(e){return this.send(Le.ClaimQuestRewardsBatch,e,fo)}claimMilestoneReward(e){return this.send(Le.ClaimMilestoneReward,e,ci)}claimMilestoneRewardsBatch(e){return this.send(Le.ClaimMilestoneRewardsBatch,e,Ro)}claimGroupCompletionReward(e){return this.send(Le.ClaimGroupCompletionReward,e,mo)}addQuestProgress(e){return this.send(Le.AddQuestProgress,e,ho)}};var go=zod.z.object({}).passthrough().transform(c=>c);var Np=zod.z.object({Order:zod.z.number().nullish(),Type:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),BonusMultiplier:zod.z.number().nullish()}).passthrough(),jp=zod.z.object({Schedule:zod.z.array(Np).nullish(),RepeatCycle:zod.z.boolean().nullish(),MaxCycles:zod.z.number().nullish()}).passthrough(),Fp=zod.z.object({IsActive:zod.z.boolean().nullish(),CurrentPhaseEndUtc:a.nullish(),NextBonusStartUtc:a.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentPhaseIndex:zod.z.number().nullish(),ActiveBonusMultiplier:zod.z.number().nullish()}).passthrough(),_p=zod.z.object({Milestones:me.nullish()}).passthrough(),pi=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:gt.nullish(),TokenSources:zod.z.array(et).nullish(),ClaimMode:zod.z.string().nullish(),Milestones:zod.z.record(zod.z.string(),Se).nullish(),Presets:_p.nullish(),BonusWindow:jp.nullish()}).passthrough(),Wp=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Content:pi.nullish(),ClaimGraceHours:zod.z.number().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Vp=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:le.nullish(),Content:pi.nullish(),Events:zod.z.array(Wp).nullish(),Gate:H.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Qp=zod.z.object({MaxConcurrentEvents:zod.z.number().nullish()}).passthrough(),Hp=zod.z.object({Milestones:zod.z.record(zod.z.string(),Rt).nullish()}).passthrough(),_s=zod.z.object({Definitions:zod.z.record(zod.z.string(),Vp).nullish(),Settings:Qp.nullish(),Presets:Hp.nullish()}).passthrough(),$p=zod.z.object({Type:bt,TimedEventID:zod.z.string(),CurrentChainedEventID:zod.z.string().nullish(),Content:pi.nullish(),Progress:go.nullish(),ComputedStartUtc:a.nullish(),ComputedEndUtc:a.nullish(),CanEarn:zod.z.boolean().nullish(),CanClaim:zod.z.boolean().nullish(),NextMilestone:Se.nullish(),BonusWindow:Fp.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentEventOrder:zod.z.number().nullish(),TotalEventsInChain:zod.z.number().nullish()}).passthrough(),yo=zod.z.object({ActiveEvents:zod.z.array($p).nullish()}).passthrough(),Co=zod.z.object({Tokens:zod.z.record(zod.z.string(),go).nullish()}),di=zod.z.object({Type:bt.nullish(),LteID:zod.z.string().nullish(),Resources:S.nullish()}),mi=zod.z.object({Type:bt.nullish(),LteID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Rewards:S.nullish()}),Kp=zod.z.object({Type:bt.nullish(),LteID:zod.z.string().nullish(),Resources:S.nullish()}),hi=zod.z.array(ee(mi)),So=zod.z.array(ee(di)),xo=zod.z.array(ee(Kp)),Oe={GetActiveEvents:"GetActiveEvents",GrantTokens:"GrantTokens",SpendTokens:"SpendTokens",ClaimMilestone:"ClaimMilestone",GetDefinitions:"GetDefinitions",GetUserLteState:"GetUserLteState",ClaimMilestonesBatch:"ClaimMilestonesBatch",ClaimAllMilestones:"ClaimAllMilestones",SpendTokensBatch:"SpendTokensBatch",GrantTokensBatch:"GrantTokensBatch"};var Ws=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"TimedEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getActiveEvents(e){return this.send(Oe.GetActiveEvents,e,yo)}getDefinitions(e){return this.send(Oe.GetDefinitions,e,_s)}getUserLteState(e){return this.send(Oe.GetUserLteState,e,Co)}grantTokens(e){return this.send(Oe.GrantTokens,e,S)}spendTokens(e){return this.send(Oe.SpendTokens,e,di)}claimMilestone(e){return this.send(Oe.ClaimMilestone,e,mi)}claimMilestonesBatch(e){return this.send(Oe.ClaimMilestonesBatch,e,hi)}claimAllMilestones(e){return this.send(Oe.ClaimAllMilestones,e,hi)}spendTokensBatch(e){return this.send(Oe.SpendTokensBatch,e,So)}grantTokensBatch(e){return this.send(Oe.GrantTokensBatch,e,xo)}};var Zp=zod.z.object({UserID:zod.z.string(),Score:k.nullish(),Rank:zod.z.number().nullish(),LastScoreUpdateUtc:a.nullish(),IpHash:zod.z.string().nullish(),PublicProfile:ge.nullish(),SeasonTierAtCycleEnd:zod.z.number().nullish()}).passthrough(),vt=zod.z.object({LeaderboardID:zod.z.string(),CycleVersion:zod.z.number().nullish(),TotalParticipants:k.nullish(),CycleEndUtc:a.nullish(),TopUsers:zod.z.array(Zp).nullish(),BracketID:zod.z.string().nullish()}),Jp=zod.z.object({CycleKey:zod.z.string().nullish(),CycleEndUtc:a.nullish(),ClaimDeadlineUtc:a.nullish(),MilestoneTokensEarned:k.nullish(),ClaimableMilestoneIDs:zod.z.array(zod.z.string()).nullish(),CycleIndex:zod.z.number().nullish(),ChainedEventID:zod.z.string().nullish()}).passthrough(),Vs=zod.z.object({LeaderboardID:zod.z.string(),CurrentScore:k.nullish(),LastKnownRank:zod.z.number().nullish(),HasUnclaimedReward:zod.z.boolean().nullish(),ScoreEarnedThisCycle:k.nullish(),MilestoneTokensEarned:k.nullish(),NextMilestone:Se.nullish(),HasUnclaimedMilestone:zod.z.boolean().nullish(),ClaimableGraceCycles:zod.z.array(Jp).nullish()}),Qs=zod.z.object({LeaderboardID:zod.z.string(),NewScore:k,CycleVersion:zod.z.number()}),Hs=zod.z.object({ServerTimeUtc:a,LeaderboardID:zod.z.string(),Rank:zod.z.number().nullish(),Resources:S.nullish()}),$s=zod.z.object({ServerTimeUtc:a,LeaderboardID:zod.z.string(),MilestoneID:zod.z.string(),Resources:S.nullish()}),Do=zod.z.array(ee(vt)),bo=zod.z.array(ee(Vs)),zo=zod.z.array(ee(Hs)),vo=zod.z.array(ee($s)),To=zod.z.array(ee(Qs)),Yp=zod.z.object({LeaderboardID:zod.z.string(),CycleReward:ee(Hs).nullish(),Milestones:zod.z.array(ee($s)).nullish()}),Io=zod.z.array(Yp),Xp=zod.z.object({LeaderboardID:zod.z.string(),Leaderboard:ee(vt).nullish(),Progress:ee(Vs).nullish()}),Po=zod.z.array(Xp),ed=zod.z.string(),Mo=zod.z.object({Rank:zod.z.string().nullish(),Rewards:L.nullish(),SeasonTierRewards:oi.nullish()}).passthrough(),td=zod.z.object({RankRewards:zod.z.array(Mo).nullish()}).passthrough(),sd=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),rd=zod.z.object({Milestones:me.nullish(),RankRewards:me.nullish()}).passthrough(),id=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:ed.nullish(),Schedule:le.nullish(),ChainEvents:zod.z.array(sd).nullish(),Gate:H.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(Mo).nullish(),Milestones:zod.z.record(zod.z.string(),Se).nullish(),Presets:rd.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneClaimGraceHours:zod.z.number().nullish(),ScoreSources:zod.z.array(et).nullish()}).passthrough(),nd=zod.z.object({Milestones:zod.z.record(zod.z.string(),Rt).nullish(),RankRewards:zod.z.record(zod.z.string(),td).nullish()}).passthrough(),Ks=zod.z.object({Definitions:zod.z.record(zod.z.string(),id).nullish(),Presets:nd.nullish()}).passthrough(),he={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 Zs=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Leaderboard",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(he.GetDefinitions,e,Ks)}getLeaderboard(e){return this.send(he.GetLeaderboard,e,vt)}getMyProgress(e){return this.send(he.GetMyProgress,e,Vs)}submitScore(e){return this.send(he.SubmitScore,e,Qs)}submitScoreFromSource(e){return this.send(he.SubmitScoreFromSource,e,Qs)}claimCycleReward(e){return this.send(he.ClaimCycleReward,e,Hs)}claimMilestone(e){return this.send(he.ClaimMilestone,e,$s)}getFriendsLeaderboard(e){return this.send(he.GetFriendsLeaderboard,e,vt)}getLeaderboardsBatch(e){return this.send(he.GetLeaderboardsBatch,e,Do)}getProgressBatch(e){return this.send(he.GetProgressBatch,e,bo)}claimCycleRewardsBatch(e){return this.send(he.ClaimCycleRewardsBatch,e,zo)}claimMilestonesBatch(e){return this.send(he.ClaimMilestonesBatch,e,vo)}submitScoresBatch(e){return this.send(he.SubmitScoresBatch,e,To)}claimAllRewardsBatch(e){return this.send(he.ClaimAllRewardsBatch,e,Io)}getOverviewBatch(e){return this.send(he.GetOverviewBatch,e,Po)}};var fi=zod.z.object({}).passthrough().transform(c=>c),ko=zod.z.object({SeasonChainID:zod.z.string(),CycleIndex:zod.z.number().nullish(),Season:zod.z.lazy(()=>Bo).nullish(),ComputedStartUtc:a.nullish(),ComputedEndUtc:a.nullish(),SecondsRemaining:k.nullish(),UserState:fi.nullish(),NextTier:zod.z.lazy(()=>Uo).nullish()}).passthrough(),Ao=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),AmountGranted:k.nullish(),NewStatusTokens:k.nullish(),OldTier:zod.z.number().nullish(),NewTier:zod.z.number(),TierUp:zod.z.boolean().nullish()}),Oo=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),TierNumber:zod.z.number(),Resources:S.nullish()});var Uo=zod.z.object({Tier:zod.z.number().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),RequiredTokens:k.nullish(),TierReachedReward:L.nullish()}).passthrough(),Bo=zod.z.object({SeasonID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:k.nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Tiers:zod.z.array(Uo).nullish(),LinkedCollectionID:zod.z.string().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough();var od=zod.z.object({SeasonChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:le.nullish(),Seasons:zod.z.array(Bo).nullish(),GrantTokensAccessMode:zod.z.string().nullish(),Gate:H.nullish()}).passthrough(),Js=zod.z.object({Chains:zod.z.record(zod.z.string(),od).nullish()}).passthrough(),st={GetDefinitions:"GetDefinitions",GetActiveSeason:"GetActiveSeason",GetUserState:"GetUserState",GrantStatusTokens:"GrantStatusTokens",ClaimTierReward:"ClaimTierReward"};var Ys=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Season",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(st.GetDefinitions,e,Js)}getActiveSeason(e){return this.send(st.GetActiveSeason,e,ko)}getUserState(e){return this.send(st.GetUserState,e,fi)}grantStatusTokens(e){return this.send(st.GrantStatusTokens,e,Ao)}claimTierReward(e){return this.send(st.ClaimTierReward,e,Oo)}};var ad={Apple:"Apple",Google:"Google"},wo=zod.z.object({}).passthrough().transform(c=>c),ld=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(),ud=zod.z.object({OptionID:zod.z.string().nullish(),Name:zod.z.string().nullish(),RequiredResources:Q.nullish()}).passthrough(),cd=zod.z.object({PremiumID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Tier:zod.z.number().nullish(),DurationDays:zod.z.number().nullish(),TrialDurationDays:zod.z.number().nullish(),PriceOptions:zod.z.record(zod.z.string(),ud).nullish(),AppleProductID:zod.z.string().nullish(),GoogleProductID:zod.z.string().nullish(),Benefits:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Ri=zod.z.object({Definitions:zod.z.record(zod.z.string(),cd).nullish()}).passthrough(),qo=zod.z.object({Premium:Ri.nullish()}),Eo=zod.z.object({ServerTimeUtc:a.nullish(),Premium:wo.nullish()}),Xs=zod.z.object({ServerTimeUtc:a.nullish(),Premium:wo.nullish(),Subscription:ld.nullish(),Resources:S.nullish()}),rt={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateTrial:"ActivateTrial",PurchaseWithResources:"PurchaseWithResources",PurchaseRealMoney:"PurchaseRealMoney"};var er=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Premium",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(rt.GetDefinitions,e,qo)}getUserState(e){return this.send(rt.GetUserState,e,Eo)}activateTrial(e){return this.send(rt.ActivateTrial,e,Xs)}purchaseItemOrCurrency(e){return this.send(rt.PurchaseWithResources,e,Xs)}purchaseRealMoney(e){return this.send(rt.PurchaseRealMoney,e,Xs)}};var tr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Character",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getCharacterDefinitions(e){return this.send(ze.GetCharacterDefinitions,e,Cs)}getUserCharacters(e){return this.send(ze.GetUserCharacters,e,en)}unlockCharacter(e){return this.send(ze.UnlockCharacter,e,Fr)}upgradeStatLevel(e){return this.send(ze.UpgradeStatLevel,e,Nr)}upgradeCharacterLevel(e){return this.send(ze.UpgradeCharacterLevel,e,jr)}equipItems(e){return this.send(ze.EquipItems,e,tn)}unequipItems(e){return this.send(ze.UnequipItems,e,sn)}unequipAllCharacters(e){return this.send(ze.UnequipAllCharacters,e,rn)}unlockCharactersBatch(e){return this.send(ze.UnlockCharactersBatch,e,nn)}upgradeCharacterLevelsBatch(e){return this.send(ze.UpgradeCharacterLevelsBatch,e,on)}upgradeStatLevelsBatch(e){return this.send(ze.UpgradeStatLevelsBatch,e,an)}};var sr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Match",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}createMatch(e){return this.send(Ne.CreateMatch,e,kn)}updateMatch(e){return this.send(Ne.UpdateMatch,e,An)}cancelMatch(e){return this.send(Ne.CancelMatch,e,On)}instantBattle(e){return this.send(Ne.InstantBattle,e,Un)}saveStrategy(e){return this.send(Ne.SaveStrategy,e,ye)}getMyMatches(e){return this.send(Ne.GetMyMatches,e,Kr)}getAvailableMatches(e){return this.send(Ne.GetAvailableMatches,e,Kr)}getDefinitions(e){return this.send(Ne.GetDefinitions,e,En)}};var pd={TradeUpRarity:"TradeUpRarity",TradeUpCollection:"TradeUpCollection"},Lo=zod.z.enum(["TradeUpRarity","TradeUpCollection"]),dd=zod.z.object({Index:zod.z.number().nullish(),BurnedItemIDs:zod.z.array(zod.z.string()).nullish(),RolledCollectionID:zod.z.string().nullish(),UsedCollections:zod.z.record(zod.z.string(),zod.z.number()).nullish(),Output:Er.nullish()}),Go=zod.z.object({ServerTimeUtc:a,Type:Lo.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:S.nullish(),Results:zod.z.array(dd).nullish()}),md=zod.z.object({OptionID:zod.z.string().nullish(),RequiredResources:Q.nullish()}).passthrough(),hd=zod.z.object({CraftID:zod.z.string().nullish(),Type:Lo.nullish(),CatalogID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),InputRarityID:zod.z.string().nullish(),OutputRarityID:zod.z.string().nullish(),RequiredItemCount:zod.z.number().nullish(),PriceOptions:zod.z.record(zod.z.string(),md).nullish()}).passthrough(),gi=zod.z.object({Definitions:zod.z.record(zod.z.string(),hd).nullish()}).passthrough(),No=zod.z.object({ServerTimeUtc:a.nullish(),CraftDefinitions:gi.nullish()}),rr={GetDefinitions:"GetDefinitions",Craft:"Craft"};var ir=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Craft",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(rr.GetDefinitions,e,No)}craft(e){return this.send(rr.Craft,e,Go)}};var fd={Pending:"Pending",Accepted:"Accepted",Declined:"Declined",Cancelled:"Cancelled",Expired:"Expired"},Rd=zod.z.enum(["Pending","Accepted","Declined","Cancelled","Expired"]),jo=zod.z.object({}).passthrough().transform(c=>c),nr=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()}),Fo=zod.z.object({GrantedCollectibles:zod.z.array(nr).nullish(),DuplicateCollectibles:zod.z.array(nr).nullish(),CollectionCurrencyEarned:k.nullish(),NewCollectionCurrencyBalance:k.nullish(),NewlyCompletedSetIDs:zod.z.array(zod.z.string()).nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:S.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),_o=zod.z.object({GrantedCollectibles:zod.z.array(nr).nullish(),DuplicateCollectibles:zod.z.array(nr).nullish(),CollectionCurrencyEarned:k.nullish(),NewCollectionCurrencyBalance:k.nullish(),Resources:S.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),Wo=zod.z.object({GrantedCollectibleID:zod.z.string().nullish(),NewlyCompletedSetID:zod.z.string().nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:S.nullish()}),yi=zod.z.object({SetID:zod.z.string(),Resources:S.nullish()}),Vo=zod.z.array(ee(yi)),Qo=zod.z.object({Resources:S.nullish()}),gd=zod.z.object({OfferID:zod.z.string(),TitleID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderPublicData:ge.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:Rd.nullish(),CreatedAtUtc:a.nullish(),ExpiresAtUtc:a.nullish(),RespondedAtUtc:a.nullish(),DeclineReason:zod.z.string().nullish(),IsSpecialTradeEvent:zod.z.boolean().nullish(),SpecialTradeEventID:zod.z.string().nullish()}).passthrough(),Ho=zod.z.object({OfferID:zod.z.string(),ExpiresAtUtc:a.nullish(),Resources:S.nullish()}),$o=zod.z.object({OfferID:zod.z.string(),Resources:S.nullish()}),Ko=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()}),Zo=zod.z.object({OfferID:zod.z.string(),Resources:S.nullish()}),Ci=zod.z.object({Offers:zod.z.array(gd).nullish()}),yd=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(),Cd=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(yd).nullish(),SetCompletionReward:L.nullish()}).passthrough(),Sd=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(Cd).nullish(),GrandPrize:L.nullish()}).passthrough(),Jo=zod.z.object({BonusRewardSlots:me.nullish(),PityRules:me.nullish()}).passthrough(),xd=zod.z.object({PackTypeID:zod.z.string().nullish(),Cost:Q.nullish(),BonusRewardSlots:zod.z.array(ht).nullish(),PityRules:zod.z.array(ft).nullish(),Presets:Jo.nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CollectibleCount:zod.z.number().nullish(),GuaranteedMinRarity:zod.z.number().nullish(),GuaranteeMaxRarity:zod.z.boolean().nullish(),RarityWeights:zod.z.record(zod.z.string(),zod.z.number()).nullish(),ColorTier:zod.z.number().nullish()}).passthrough(),Dd=zod.z.object({Rarity:zod.z.number().nullish(),CollectionCurrencyGranted:zod.z.number().nullish()}).passthrough(),bd=zod.z.object({CollectionChestID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CollectionCurrencyCost:zod.z.number().nullish(),MinCollectibleCount:zod.z.number().nullish(),MaxCollectibleCount:zod.z.number().nullish(),GuaranteedMinRarity:zod.z.number().nullish(),BonusRewardSlots:zod.z.array(ht).nullish(),PityRules:zod.z.array(ft).nullish(),Presets:Jo.nullish(),Tier:zod.z.number().nullish()}).passthrough(),zd=zod.z.object({SpecialTradeEventID:zod.z.string().nullish(),StartUtc:a.nullish(),EndUtc:a.nullish(),AllowedSpecialCollectibleIDs:zod.z.array(zod.z.string()).nullish(),SpecialTradeEventDailyTradeLimit:zod.z.number().nullish()}).passthrough(),or=zod.z.object({Collections:zod.z.record(zod.z.string(),Sd).nullish(),PackTypes:zod.z.record(zod.z.string(),xd).nullish(),CollectionChests:zod.z.array(bd).nullish(),DuplicateConversions:zod.z.array(Dd).nullish(),DailyTradeLimit:zod.z.number().nullish(),CollectibleJokerCatalogID:zod.z.string().nullish(),CollectibleJokerItemID:zod.z.string().nullish(),SpecialTradeEvents:zod.z.array(zd).nullish(),RewardPools:qs.nullish()}).passthrough(),Ce={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 ar=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Collection",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ce.GetDefinitions,e,or)}getUserState(e){return this.send(Ce.GetUserState,e,jo)}openPack(e){return this.send(Ce.OpenPack,e,Fo)}openCollectionChest(e){return this.send(Ce.OpenCollectionChest,e,_o)}useCollectibleJoker(e){return this.send(Ce.UseCollectibleJoker,e,Wo)}claimSetReward(e){return this.send(Ce.ClaimSetReward,e,yi)}claimSetRewardsBatch(e){return this.send(Ce.ClaimSetRewardsBatch,e,Vo)}claimGrandPrize(e){return this.send(Ce.ClaimGrandPrize,e,Qo)}sendTradeOffer(e){return this.send(Ce.SendTradeOffer,e,Ho)}cancelTradeOffer(e){return this.send(Ce.CancelTradeOffer,e,$o)}acceptTradeOffer(e){return this.send(Ce.AcceptTradeOffer,e,Ko)}declineTradeOffer(e){return this.send(Ce.DeclineTradeOffer,e,Zo)}getMyTradeOffers(e){return this.send(Ce.GetMyTradeOffers,e,Ci)}getIncomingTradeOffers(e){return this.send(Ce.GetIncomingTradeOffers,e,Ci)}};var vd=zod.z.object({}).passthrough().transform(c=>c),Td={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},Id={Active:"Active",Left:"Left",Replaced:"Replaced"},Pd=zod.z.object({ObjectIndex:zod.z.number().nullish(),ObjectCompletionRewardClaimed:zod.z.boolean().nullish()}).passthrough(),Md=zod.z.object({UserID:zod.z.string().nullish(),PublicData:ge.nullish(),BuildObjectsProgress:Pd.nullish(),IsBot:zod.z.boolean().nullish(),SpinsCount:zod.z.number().nullish(),TokensSpent:zod.z.number().nullish(),MemberStatus:zod.z.string().nullish(),GrandPrizeClaimed:zod.z.boolean().nullish(),JoinedAtUtc:a.nullish(),LeftAtUtc:a.nullish()}).passthrough(),kd=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(),Ad=zod.z.object({Objects:zod.z.array(kd).nullish()}).passthrough(),Yo=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(Md).nullish(),BuildObjectsState:Ad.nullish(),Status:zod.z.string().nullish(),CreatedAtUtc:a.nullish(),ExpiresAtUtc:a.nullish(),Version:zod.z.number().nullish()}).passthrough(),Xo=zod.z.object({CoopChainID:zod.z.string()}).passthrough(),Od=zod.z.string(),ea=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(),Ud=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(),Bd=zod.z.object({Objects:zod.z.array(Ud).nullish(),SpinCost:Q.nullish(),SpinnerTable:zod.z.array(ea).nullish()}).passthrough(),wd=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:Od.nullish(),PartnerCount:zod.z.number().nullish(),MatchmakingTimeoutMinutes:zod.z.number().nullish(),MemberGracePeriodMinutes:zod.z.number().nullish(),BuildObjects:Bd.nullish(),GrandPrize:L.nullish()}).passthrough(),qd=zod.z.object({CoopChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:le.nullish(),Events:zod.z.array(wd).nullish(),Gate:H.nullish()}).passthrough(),ta=zod.z.object({ServerTimeUtc:a.nullish(),UserState:vd.nullish(),ActiveGroup:Yo.nullish()}),Si=zod.z.object({ServerTimeUtc:a.nullish(),Group:Yo.nullish(),SecondsRemaining:k.nullish()}),sa=zod.z.object({ServerTimeUtc:a.nullish(),GroupID:zod.z.string().nullish(),Resources:S.nullish(),ObjectIndex:zod.z.number().nullish(),Sector:ea.nullish(),ProgressDelta:zod.z.number().nullish(),NewProgress:k.nullish(),MaxProgress:k.nullish(),ObjectCompleted:zod.z.boolean().nullish(),AllObjectsCompleted:zod.z.boolean().nullish()}),xi=zod.z.object({ServerTimeUtc:a.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),Resources:S.nullish()}),ra=zod.z.object({ServerTimeUtc:a.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),lr=zod.z.object({Chains:zod.z.record(zod.z.string(),qd).nullish()}).passthrough(),Ge={GetDefinitions:"GetDefinitions",GetActiveEvent:"GetActiveEvent",GetUserState:"GetUserState",GetGroupState:"GetGroupState",JoinOrCreateGroup:"JoinOrCreateGroup",Spin:"Spin",ClaimObjectReward:"ClaimObjectReward",ClaimGrandPrize:"ClaimGrandPrize",LeaveGroup:"LeaveGroup"};var ur=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"CoopEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ge.GetDefinitions,e,lr)}getActiveEvent(e){return this.send(Ge.GetActiveEvent,e,Xo)}getUserState(e){return this.send(Ge.GetUserState,e,ta)}getGroupState(e){return this.send(Ge.GetGroupState,e,Si)}joinOrCreateGroup(e){return this.send(Ge.JoinOrCreateGroup,e,Si)}spin(e){return this.send(Ge.Spin,e,sa)}claimObjectReward(e){return this.send(Ge.ClaimObjectReward,e,xi)}claimGrandPrize(e){return this.send(Ge.ClaimGrandPrize,e,xi)}leaveGroup(e){return this.send(Ge.LeaveGroup,e,ra)}};var Ed={Active:"Active",Exhausted:"Exhausted",Expired:"Expired",Dismissed:"Dismissed"},Ld={Locked:"Locked",Available:"Available",InProgress:"InProgress",Completed:"Completed",Hidden:"Hidden"},Gd=zod.z.object({NodeID:zod.z.string().nullish(),Status:zod.z.string().nullish(),ExecutionCount:zod.z.number().nullish(),UnlockedAtUtc:a.nullish(),CompletedAtUtc:a.nullish(),LastExecutedAtUtc:a.nullish(),NextAvailableAtUtc:a.nullish(),LastExecutionRefID:zod.z.string().nullish()}).passthrough(),Nd=zod.z.object({TrackID:zod.z.string().nullish(),CurrentValue:zod.z.number().nullish(),LastUpdatedUtc:a.nullish()}).passthrough(),ia=zod.z.object({OfferID:zod.z.string().nullish(),InstanceKey:zod.z.string().nullish(),SourceOfferVersion:zod.z.number().nullish(),Status:zod.z.string().nullish(),ActivatedAtUtc:a.nullish(),ExhaustedAtUtc:a.nullish(),ExpiredAtUtc:a.nullish(),DismissedAtUtc:a.nullish(),ShowCount:zod.z.number().nullish(),LastShownAtUtc:a.nullish(),Nodes:zod.z.record(zod.z.string(),Gd).nullish(),Tracks:zod.z.record(zod.z.string(),Nd).nullish(),SelectedChoiceNodeID:zod.z.string().nullish()}).passthrough(),jd=zod.z.object({SlotID:zod.z.string().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),ActiveOfferID:zod.z.string().nullish(),ActiveOfferStartedAtUtc:a.nullish(),ActiveOfferExpiresAtUtc:a.nullish(),ActiveOffer:ia.nullish(),NextCycleStartsAtUtc:a.nullish(),LastUpdatedUtc:a.nullish(),DismissSkipAvailableAtUtc:a.nullish(),LastDismissedAtUtc:a.nullish()}).passthrough(),Fd=zod.z.object({TotalExecutions:zod.z.number().nullish(),DailyExecutions:zod.z.number().nullish(),DailyResetUtc:a.nullish()}).passthrough(),_d=zod.z.object({TotalActivations:zod.z.number().nullish(),TotalExhausted:zod.z.number().nullish(),TotalExpired:zod.z.number().nullish(),TotalDismissed:zod.z.number().nullish(),TotalShows:zod.z.number().nullish(),LastShownAtUtc:a.nullish(),LastActivatedAtUtc:a.nullish(),LastExhaustedAtUtc:a.nullish(),NodeCounts:zod.z.record(zod.z.string(),Fd).nullish()}).passthrough(),Wd=zod.z.object({Slots:zod.z.record(zod.z.string(),jd).nullish(),OfferHistory:zod.z.record(zod.z.string(),_d).nullish(),LastUpdatedUtc:a.nullish()}).passthrough();var Vd=zod.z.object({Order:zod.z.number().nullish(),OfferID:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),DelayBeforeActivationSec:zod.z.number().nullish()}).passthrough(),Qd=zod.z.object({SlotID:zod.z.string().nullish(),Enabled:zod.z.boolean().nullish(),SortOrder:zod.z.number().nullish(),Queue:zod.z.array(Vd).nullish(),Schedule:le.nullish(),Gate:H.nullish(),AllowDismissSkip:zod.z.boolean().nullish(),DismissSkipDelaySec:zod.z.number().nullish()}).passthrough(),Hd=zod.z.object({StoreOfferID:zod.z.string().nullish(),BillingProductID:zod.z.string().nullish(),DirectCost:Q.nullish(),UseExternalRewards:zod.z.boolean().nullish()}).passthrough(),$d=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(),Kd=zod.z.object({Purchase:Hd.nullish(),RewardedVideo:$d.nullish()}).passthrough(),Zd=zod.z.object({TrackID:zod.z.string().nullish(),Operator:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),Jd=zod.z.object({Milestones:me.nullish()}).passthrough(),Yd=zod.z.object({TrackID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),RespectBounds:zod.z.boolean().nullish()}).passthrough(),Xd=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(),em=zod.z.object({RequiredCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredAnyCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredTracks:zod.z.array(Zd).nullish(),VisibleWhileLocked:zod.z.boolean().nullish()}).passthrough(),tm=zod.z.object({NodeID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),Type:zod.z.string().nullish(),Action:Kd.nullish(),Grants:L.nullish(),TrackChanges:zod.z.array(Yd).nullish(),MilestonePoints:zod.z.number().nullish(),UnlockRules:em.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(),na=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(tm).nullish(),Tracks:zod.z.array(Xd).nullish(),Milestones:zod.z.record(zod.z.string(),Se).nullish(),Presets:Jd.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneToken:gt.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(),sm=zod.z.object({Milestones:zod.z.record(zod.z.string(),Rt).nullish()}).passthrough(),Di=zod.z.object({Slots:zod.z.record(zod.z.string(),Qd).nullish(),Offers:zod.z.record(zod.z.string(),na).nullish(),Presets:sm.nullish()}).passthrough(),oa=zod.z.object({DealOfferDefinitions:Di.nullish()}),aa=zod.z.object({DealOffers:Wd.nullish()}),rm=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(),im=zod.z.object({SlotID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),OfferDef:na.nullish(),ActivationState:ia.nullish(),IsNewActivation:zod.z.boolean().nullish(),ComputedExpiresAtUtc:a.nullish(),Cost:Q.nullish(),Milestone:rm.nullish()}).passthrough(),la=zod.z.object({Slots:zod.z.array(im).nullish()}),ua=zod.z.object({ServerTimeUtc:a.nullish(),SlotID:zod.z.string().nullish(),NodeID:zod.z.string().nullish(),NodeCompleted:zod.z.boolean().nullish(),OfferExhausted:zod.z.boolean().nullish(),Idempotent:zod.z.boolean().nullish(),Resources:S.nullish()}),ca=zod.z.object({ServerTimeUtc:a.nullish(),SlotID:zod.z.string().nullish(),Resources:S.nullish()}),pa=zod.z.object({ServerTimeUtc:a.nullish(),SlotID:zod.z.string().nullish(),Resources:S.nullish()}),da=zod.z.object({ServerTimeUtc:a.nullish(),SlotID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:S.nullish()}),ma=zod.z.object({ServerTimeUtc:a.nullish(),SlotID:zod.z.string().nullish(),ClaimedIDs:zod.z.array(zod.z.string()).nullish(),Rejected:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Resources:S.nullish()}),Fe={GetDefinition:"GetDefinition",GetUserState:"GetUserState",GetActiveDeals:"GetActiveDeals",DismissDeal:"DismissDeal",ExecuteNode:"ExecuteNode",RecordShow:"RecordShow",ClaimMilestone:"ClaimMilestone",ClaimMilestonesBatch:"ClaimMilestonesBatch"};var cr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"DealOffer",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinition(e){return this.send(Fe.GetDefinition,e,oa)}getUserState(e){return this.send(Fe.GetUserState,e,aa)}getActiveDeals(e){return this.send(Fe.GetActiveDeals,e,la)}dismissDeal(e){return this.send(Fe.DismissDeal,e,ca)}executeNode(e){return this.send(Fe.ExecuteNode,e,ua)}recordShow(e){return this.send(Fe.RecordShow,e,pa)}claimMilestone(e){return this.send(Fe.ClaimMilestone,e,da)}claimMilestonesBatch(e){return this.send(Fe.ClaimMilestonesBatch,e,ma)}};var nm=zod.z.object({}).passthrough().transform(c=>c),om=zod.z.object({FeatureKey:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Percent:zod.z.number().nullish(),SourceCurrencyID:zod.z.string().nullish(),TargetCurrencyID:zod.z.string().nullish()}).passthrough(),bi=zod.z.object({IsEnabled:zod.z.boolean().nullish(),ActivationReward:L.nullish(),InviteRewards:zod.z.record(zod.z.string(),Se).nullish(),SpendRewards:zod.z.array(om).nullish()}).passthrough(),ha=zod.z.object({ReferralDefinitions:bi.nullish()}),fa=zod.z.object({Referral:nm.nullish()}),Ra=zod.z.object({ReferralCode:zod.z.string().nullish(),IsFirstActivation:zod.z.boolean().nullish(),Resources:S.nullish()}),ga=zod.z.object({RewardID:zod.z.string().nullish(),Resources:S.nullish()}),yt={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateReferralCode:"ActivateReferralCode",ClaimInviteReward:"ClaimInviteReward"};var pr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Referral",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(yt.GetDefinitions,e,ha)}getUserState(e){return this.send(yt.GetUserState,e,fa)}activateReferralCode(e){return this.send(yt.ActivateReferralCode,e,Ra)}claimInviteReward(e){return this.send(yt.ClaimInviteReward,e,ga)}};var am={RequestSent:"RequestSent",Accepted:"Accepted",Declined:"Declined",Removed:"Removed"},lm={Attack:"Attack",Raid:"Raid",FriendAdd:"FriendAdd"},um=zod.z.object({UserID:zod.z.string(),PublicData:ge.nullish()}),cm=zod.z.object({OwnerUserID:zod.z.string().nullish(),ActorUserID:zod.z.string().nullish(),ActorProfile:ge.nullish(),Type:zod.z.string().nullish(),CreatedAt:a.nullish(),OwnerImpact:S.nullish(),IsBlocked:zod.z.boolean().nullish(),TargetObjectName:zod.z.string().nullish()}).passthrough(),dr=zod.z.object({Friends:zod.z.array(um).nullish()}),Tt=zod.z.object({TargetUserID:zod.z.string().nullish(),Status:zod.z.string().nullish()}),ya=zod.z.object({Events:zod.z.array(cm).nullish()}),_e={GetFriendsList:"GetFriendsList",GetIncomingRequests:"GetIncomingRequests",GetRecommendedFriends:"GetRecommendedFriends",SendFriendRequest:"SendFriendRequest",AcceptFriendRequest:"AcceptFriendRequest",DeclineFriendRequest:"DeclineFriendRequest",RemoveFriend:"RemoveFriend",GetTimeline:"GetTimeline"};var mr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Social",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getFriendsList(e){return this.send(_e.GetFriendsList,e,dr)}getIncomingRequests(e){return this.send(_e.GetIncomingRequests,e,dr)}getRecommendedFriends(e){return this.send(_e.GetRecommendedFriends,e,dr)}sendFriendRequest(e){return this.send(_e.SendFriendRequest,e,Tt)}acceptFriendRequest(e){return this.send(_e.AcceptFriendRequest,e,Tt)}declineFriendRequest(e){return this.send(_e.DeclineFriendRequest,e,Tt)}removeFriend(e){return this.send(_e.RemoveFriend,e,Tt)}getTimeline(e){return this.send(_e.GetTimeline,e,ya)}};var pm={Replace:"Replace",Refresh:"Refresh",KeepBest:"KeepBest",Stack:"Stack"};var Ct=zod.z.object({Target:zod.z.string().nullish(),Operation:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),dm=zod.z.object({BoostID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),ActivationCost:Q.nullish(),Effect:Ct.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(),mm=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:le.nullish(),Effects:zod.z.array(Ct).nullish(),Gate:H.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),hm=zod.z.object({ChainedBoostID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Effects:zod.z.array(Ct).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),fm=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:le.nullish(),Phases:zod.z.array(hm).nullish(),Gate:H.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Rm=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(et).nullish(),Effects:zod.z.array(Ct).nullish(),DurationSeconds:zod.z.number().nullish(),Charges:zod.z.number().nullish(),StackingPolicy:zod.z.string().nullish(),MaxActiveInstances:zod.z.number().nullish(),Gate:H.nullish()}).passthrough(),gm=zod.z.object({MaxAddPercent:zod.z.number().nullish(),MaxMultiply:zod.z.number().nullish(),MaxAddFlat:zod.z.number().nullish()}).passthrough(),ym=zod.z.object({StackingCaps:zod.z.record(zod.z.string(),gm).nullish()}).passthrough(),hr=zod.z.object({Definitions:zod.z.record(zod.z.string(),dm).nullish(),ScheduledBoosts:zod.z.record(zod.z.string(),mm).nullish(),BoostChains:zod.z.record(zod.z.string(),fm).nullish(),TriggeredBoosts:zod.z.record(zod.z.string(),Rm).nullish(),Settings:ym.nullish()}).passthrough(),Ca=zod.z.object({InstanceID:zod.z.string(),BoostID:zod.z.string(),ActivatedAtUtc:a.nullish(),ExpiresAtUtc:a.nullish(),RemainingCharges:zod.z.number().nullish(),EffectSnapshot:Ct.nullish(),SourceType:zod.z.string().nullish(),SourceRef:zod.z.string().nullish()}).passthrough();zod.z.object({Date:a.nullish(),DailyCount:zod.z.number().nullish(),LastFiredUtc:a.nullish()}).passthrough();var Sa=zod.z.object({ServerTimeUtc:a.nullish(),Active:zod.z.record(zod.z.string(),Ca).nullish()}),xa=zod.z.object({ServerTimeUtc:a.nullish(),BoostID:zod.z.string().nullish(),StackingPolicy:zod.z.string().nullish(),ActivatedBoost:Ca.nullish(),Resources:S.nullish()}),Cm={Scheduled:"Scheduled",Chain:"Chain"},Sm=zod.z.object({Kind:zod.z.string().nullish(),SourceID:zod.z.string().nullish(),PhaseID:zod.z.string().nullish(),CycleIndex:zod.z.number().nullish(),PhaseOrder:zod.z.number().nullish(),StartUtc:a.nullish(),EndUtc:a.nullish(),Effects:zod.z.array(Ct).nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Da=zod.z.object({ServerTimeUtc:a.nullish(),Windows:zod.z.array(Sm).nullish()}),it={GetDefinitions:"GetDefinitions",GetActive:"GetActive",GetActiveWindows:"GetActiveWindows",Activate:"Activate",CleanupExpired:"CleanupExpired"};var fr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"TimedBoost",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(it.GetDefinitions,e,hr)}getActive(e){return this.send(it.GetActive,e,Sa)}getActiveWindows(e){return this.send(it.GetActiveWindows,e,Da)}activate(e){return this.send(it.Activate,e,xa)}cleanupExpired(e){return this.send(it.CleanupExpired,e,ye)}};var Rr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"UserCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getUserCustomDataDefinitions(e){return this.send(Ee.GetUserCustomDataDefinitions,e,cs)}getMyUserCustomData(e){return this.send(Ee.GetMyUserCustomData,e,Fi)}getPublicUserCustomDataOf(e){return this.send(Ee.GetPublicUserCustomDataOf,e,wr)}setPrivateData(e){return this.send(Ee.SetPrivateData,e,qr)}setPublicData(e){return this.send(Ee.SetPublicData,e,qr)}deleteKey(e){return this.send(Ee.DeleteKey,e,ye)}batchSet(e){return this.send(Ee.BatchSet,e,_i)}batchDelete(e){return this.send(Ee.BatchDelete,e,Wi)}batchGetPublicUserCustomDataOf(e){return this.send(Ee.BatchGetPublicUserCustomDataOf,e,Vi)}};var xm={Fast:"Fast",Sequential:"Sequential"},Dm={Instant:"Instant",Timed:"Timed"},bm={Hit:"Hit",Blocked:"Blocked"},zm=zod.z.object({SlotIndex:zod.z.number(),Level:zod.z.number().nullish(),IsDamaged:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish()}).passthrough(),vm=zod.z.object({Symbol:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),OnOpenBonus:L.nullish(),BonusTag:zod.z.string().nullish()}).passthrough();zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:L.nullish()}).passthrough();zod.z.object({PlayedCount:zod.z.number().nullish(),RewardsClaimedCount:zod.z.number().nullish(),InstantClaimsCount:zod.z.number().nullish(),EarlyClaimsCount:zod.z.number().nullish(),LateClaimsCount:zod.z.number().nullish(),AdViewsTotal:zod.z.number().nullish()}).passthrough();var ba=zod.z.object({}).passthrough().transform(c=>c),za=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),be=zod.z.object({Operation:S.nullish(),ScaleWithRollMultiplier:zod.z.boolean().nullish()}).passthrough(),Tm=zod.z.object({Count:zod.z.number().nullish(),Sides:zod.z.number().nullish()}).passthrough(),Im=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(),Pm=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:ne.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(),Mm=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:ne.nullish()}).passthrough(),va=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(),km=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(),Am=zod.z.object({Tiles:zod.z.record(zod.z.string(),km).nullish()}).passthrough(),Om=zod.z.object({Weight:zod.z.number().nullish(),Bonus:be.nullish(),Tag:zod.z.string().nullish()}).passthrough(),Um=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(Om).nullish(),GuaranteedBonus:be.nullish(),IsJackpot:zod.z.boolean().nullish(),JackpotFinalMultiplier:zod.z.number().nullish(),JackpotSymbolDistribution:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough(),Bm=zod.z.object({Variants:zod.z.array(Um).nullish()}).passthrough(),wm=zod.z.object({Weight:zod.z.number().nullish(),OutcomeID:zod.z.string().nullish(),Reward:be.nullish(),ForceAction:zod.z.string().nullish(),SpecialModeID:zod.z.string().nullish()}).passthrough(),qm=zod.z.object({Outcomes:zod.z.array(wm).nullish()}).passthrough(),Ta=zod.z.object({PerAdMultiplierRange:za.nullish(),MaxAdViews:zod.z.number().nullish(),AdCreditCost:zod.z.number().nullish(),FormulaKind:zod.z.string().nullish(),ApplyMultiplierOnEarlyClaim:zod.z.boolean().nullish()}).passthrough(),Em=zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:be.nullish()}).passthrough(),Lm=zod.z.object({Tiers:zod.z.array(Em).nullish(),BelowFirstTierReward:be.nullish()}).passthrough(),Gm=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:be.nullish(),DurationSeconds:zod.z.number().nullish(),EntryCost:Q.nullish(),Multipliers:Ta.nullish(),Gradation:Lm.nullish()}).passthrough(),Nm=zod.z.object({Choices:zod.z.array(Gm).nullish(),OfferExpireSeconds:zod.z.number().nullish(),ClaimExpireSeconds:zod.z.number().nullish()}).passthrough(),jm=zod.z.object({Chance:zod.z.number().nullish(),RequiredOutcome:zod.z.string().nullish(),Reward:be.nullish(),Tag:zod.z.string().nullish()}).passthrough(),Fm=zod.z.object({OnPassStart:be.nullish(),OnTileLanding:zod.z.record(zod.z.string(),be).nullish(),OnAttack:zod.z.record(zod.z.string(),be).nullish(),OnRaid:zod.z.record(zod.z.string(),be).nullish(),OnBuild:be.nullish(),OnStageComplete:be.nullish(),OnAttackBonusDrops:zod.z.array(jm).nullish(),ChanceTablesByID:zod.z.record(zod.z.string(),qm).nullish(),SpecialModesByID:zod.z.record(zod.z.string(),Nm).nullish()}).passthrough(),Ia=zod.z.object({BaseAttackReward:L.nullish(),BaseRaidReward:L.nullish(),MaxRollMultiplier:zod.z.number().nullish(),MaxShields:zod.z.number().nullish(),Buildings:zod.z.array(va).nullish(),HeistGridBonusConfig:Bm.nullish(),StageOperations:Fm.nullish(),TileLandingMultiplier:za.nullish(),EconomyOverride:Mm.nullish()}).passthrough(),_m=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(va).nullish(),StageTemplateID:zod.z.string().nullish(),CostMatrixTemplateID:zod.z.string().nullish(),UnitValue:zod.z.number().nullish(),Override:Ia.nullish()}).passthrough(),gr=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(),Am).nullish(),StageTemplatesByID:zod.z.record(zod.z.string(),Ia).nullish(),StagesByLevel:zod.z.record(zod.z.string(),_m).nullish(),SoftCurrencyID:zod.z.string().nullish(),ProceduralEconomy:Pm.nullish(),Dice:Tm.nullish(),Bots:Im.nullish()}).passthrough(),Wm=zod.z.object({IsActive:zod.z.boolean().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),AnchorUtc:a.nullish(),RoundDurationSec:zod.z.number().nullish(),PauseBetweenRoundsSec:zod.z.number().nullish(),MaxRounds:zod.z.number().nullish(),PartnerCount:zod.z.number().nullish(),MatchmakingTimeoutMinutes:zod.z.number().nullish(),MemberGracePeriodMinutes:zod.z.number().nullish(),ContributionMin:zod.z.number().nullish(),ContributionMax:zod.z.number().nullish(),ScaleContributionWithRollMultiplier:zod.z.boolean().nullish(),MaxProgress:zod.z.number().nullish(),Milestones:zod.z.record(zod.z.string(),Se).nullish(),GrandPrize:L.nullish()}).passthrough(),yr=zod.z.object({Board:gr.nullish(),CommunityChest:Wm.nullish()}).passthrough(),Vm=zod.z.object({TargetUserID:zod.z.string().nullish(),IsBot:zod.z.boolean().nullish(),PublicData:ge.nullish(),TargetBuildingStates:zod.z.array(zm).nullish(),TargetHasShield:zod.z.boolean().nullish()}).passthrough(),Qm=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:be.nullish(),DurationSeconds:zod.z.number().nullish(),EntryCost:Q.nullish(),Multipliers:Ta.nullish()}).passthrough(),Hm=zod.z.object({ModeID:zod.z.string().nullish(),Choices:zod.z.array(Qm).nullish()}).passthrough(),$m=zod.z.object({GroupID:zod.z.string().nullish(),Delta:k.nullish(),NewProgress:k.nullish(),MaxProgress:k.nullish(),UnlockedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),Completed:zod.z.boolean().nullish()}).passthrough(),Pa=zod.z.object({UsedMultiplier:zod.z.number().nullish(),Steps:zod.z.number().nullish(),OldPosition:zod.z.number().nullish(),NewPosition:zod.z.number(),CyclesCompletedDelta:k.nullish(),LandedTileType:zod.z.string().nullish(),Operation:S.nullish(),ActionRequired:zod.z.string().nullish(),ActionData:Vm.nullish(),SpecialModeOffer:Hm.nullish(),CommunityChestContribution:$m.nullish()}).passthrough(),Ma=zod.z.object({Outcome:zod.z.string().nullish(),IsBotTarget:zod.z.boolean().nullish(),BuildingIndexHit:zod.z.number().nullish(),Operation:S.nullish(),DualResult:Xe.nullish()}).passthrough(),zi=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(vm).nullish(),HeistVariantTag:zod.z.string().nullish(),IsJackpot:zod.z.boolean().nullish(),Operation:S.nullish(),DualResult:Xe.nullish()}).passthrough(),ka=zod.z.object({BuiltIndex:zod.z.number(),NewLevel:zod.z.number().nullish(),StageComplete:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish(),Operation:S.nullish()}).passthrough(),Aa=zod.z.object({Mode:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),Operation:S.nullish(),DurationSeconds:zod.z.number().nullish(),StartedAtUtc:a.nullish(),ExpiresAtUtc:a.nullish()}).passthrough(),Oa=zod.z.object({AdViewsUsed:zod.z.number().nullish(),RolledMultiplier:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),RemainingAdViews:zod.z.number().nullish()}).passthrough(),Ua=zod.z.object({FinalMultiplier:zod.z.number().nullish(),AdViewsUsed:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),IsEarlyClaim:zod.z.boolean().nullish(),Operation:S.nullish()}).passthrough(),Km={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},Ba=zod.z.enum(["Forming","Active","Completed","Failed","Expired"]),Zm={Active:"Active",Left:"Left",Replaced:"Replaced"},Jm=zod.z.enum(["Active","Left","Replaced"]),Ym=zod.z.object({CurrentProgress:k.nullish(),MaxProgress:k.nullish()}).passthrough(),Xm=zod.z.object({UserID:zod.z.string().nullish(),PublicData:ge.nullish(),IsBot:zod.z.boolean().nullish(),ContributionPoints:k.nullish(),ClaimedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),GrandPrizeClaimed:zod.z.boolean().nullish(),MemberStatus:Jm.nullish(),JoinedAtUtc:a.nullish(),LeftAtUtc:a.nullish()}).passthrough(),wa=zod.z.object({GroupID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),Members:zod.z.array(Xm).nullish(),SharedProgress:Ym.nullish(),Status:Ba.nullish(),CreatedAtUtc:a.nullish(),ExpiresAtUtc:a.nullish(),Version:zod.z.number().nullish()}).passthrough(),eh=zod.z.object({GroupID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),FinalStatus:Ba.nullish(),GrandPrizeReceived:zod.z.boolean().nullish(),FinishedAtUtc:a.nullish()}).passthrough(),th=zod.z.object({ActiveGroupID:zod.z.string().nullish(),ActiveRoundIndex:zod.z.number().nullish(),History:zod.z.array(eh).nullish()}).passthrough(),qa=zod.z.object({ServerTimeUtc:a.nullish(),UserState:th.nullish(),ActiveGroup:wa.nullish(),SecondsRemaining:k.nullish()}),Ea=zod.z.object({ServerTimeUtc:a.nullish(),Group:wa.nullish(),SecondsRemaining:k.nullish()}),vi=zod.z.object({ServerTimeUtc:a.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:S.nullish()}),La=zod.z.object({ServerTimeUtc:a.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),pe={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 sh=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(),rh=zod.z.object({ExperimentID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Schedule:le.nullish(),Gate:H.nullish(),Variants:zod.z.array(sh).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(),Ga=zod.z.object({Experiments:zod.z.record(zod.z.string(),rh).nullish()}).passthrough();var ih={Mesh:"Mesh",Host:"Host"},Ti=zod.z.enum(["Mesh","Host"]),nh={ServerRelay:"ServerRelay",P2P:"P2P"},Ii=zod.z.enum(["ServerRelay","P2P"]),oh={Public:"Public",Private:"Private"},ah=zod.z.enum(["Public","Private"]),lh={Signal:"Signal",Chat:"Chat",PlayerJoined:"PlayerJoined",PlayerLeft:"PlayerLeft",HostChanged:"HostChanged",RoomClosed:"RoomClosed",MemberState:"MemberState"},uh=zod.z.enum(["Signal","Chat","PlayerJoined","PlayerLeft","HostChanged","RoomClosed","MemberState"]),Na=zod.z.object({Urls:zod.z.string().nullish(),Username:zod.z.string().nullish(),Credential:zod.z.string().nullish()}).passthrough(),ch=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),ja=zod.z.object({SystemState:ch.nullish(),DefaultTopology:Ti.nullish(),AllowCreatorTopologyOverride:zod.z.boolean().nullish(),DefaultChatMode:Ii.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(Na).nullish()}).passthrough(),ph=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(),dh=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),Topology:Ti.nullish(),ChatMode:Ii.nullish(),MaxPlayers:zod.z.number().nullish(),MemberCount:zod.z.number().nullish(),CreatedAt:zod.z.number().nullish()}).passthrough(),mh=zod.z.object({Seq:zod.z.number().nullish(),Type:uh.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(),Cr=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),OwnerUserID:zod.z.string().nullish(),Topology:Ti.nullish(),ChatMode:Ii.nullish(),Visibility:ah.nullish(),Status:zod.z.string().nullish(),MaxPlayers:zod.z.number().nullish(),Members:zod.z.array(ph).nullish(),IceServers:zod.z.array(Na).nullish(),Seq:zod.z.number().nullish()}).passthrough(),Pi=zod.z.object({Closed:zod.z.boolean().nullish(),NewHostUserID:zod.z.string().nullish()}).passthrough(),Fa=zod.z.object({Rooms:zod.z.array(dh).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}).passthrough(),_a=zod.z.object({Envelopes:zod.z.array(mh).nullish(),MaxSeq:zod.z.number().nullish()}).passthrough(),Sr=zod.z.object({Seq:zod.z.number().nullish()}).passthrough(),Ue={CreateRoom:"CreateRoom",JoinRoom:"JoinRoom",LeaveRoom:"LeaveRoom",ListRooms:"ListRooms",GetRoom:"GetRoom",CloseRoom:"CloseRoom",Poll:"Poll",SendSignal:"SendSignal",SendChat:"SendChat",SetMemberState:"SetMemberState"};var Mi=zod.z.object({Data:zod.z.string().nullish(),SchemaVersion:zod.z.number().nullish(),UpdatedAt:a.nullish()}),hh=zod.z.object({PublicData:zod.z.record(zod.z.string(),Mi).nullish(),PrivateData:zod.z.record(zod.z.string(),Mi).nullish()}),Wa=zod.z.object({TitleCustomData:hh.nullish(),Character:Cs.nullish(),Item:Os.nullish(),Currency:Rs.nullish(),Store:Bs.nullish(),Lootbox:ai.nullish(),Quest:js.nullish(),TimedEvent:_s.nullish(),Leaderboard:Ks.nullish(),Season:Js.nullish(),Reward:li.nullish(),Collection:or.nullish(),Craft:gi.nullish(),DealOffer:Di.nullish(),Premium:Ri.nullish(),TimedBoost:hr.nullish(),CoopEvent:lr.nullish(),GameLoop:yr.nullish(),Match:Jr.nullish(),Experiment:Ga.nullish(),Blockchain:Wr.nullish(),Marketplace:ti.nullish(),Multiplayer:ja.nullish(),UserCustomData:cs.nullish(),Referral:bi.nullish()}).passthrough(),Va=zod.z.object({PublicData:zod.z.record(zod.z.string(),Mi).nullish()});var nt={GetTitlePublicConfiguration:"GetTitlePublicConfiguration",GetTitlePublicConfigurationExcept:"GetTitlePublicConfigurationExcept",GetPublicCustomTitleData:"GetPublicCustomTitleData",GetCurrencyDefinitions:"GetCurrencyDefinitions",GetItemDefinitions:"GetItemDefinitions",GetServerTime:"GetServerTime"};var xr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Title",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getTitlePublicConfiguration(e){return this.send(nt.GetTitlePublicConfiguration,e,Wa)}getPublicTitleCustomData(e){return this.send(nt.GetPublicCustomTitleData,e,Va)}getCurrencyDefinitions(e){return this.send(nt.GetCurrencyDefinitions,e,Rs)}getItemDefinitions(e){return this.send(nt.GetItemDefinitions,e,Os)}getServerTime(e){return this.send(nt.GetServerTime,e,ye)}};var Dr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s,r=false){let i=O(this.ctx.settings.titleID,"GameLoop",e,t.UserID??"");return this.ctx.transport.post(i,t,s,{ticket:t.ClientSessionTicket,silent:r})}getGameLoops(e){return this.send(pe.GetGameLoops,e,yr)}getBoardDefinition(e,t=false){return this.send(pe.GetBoardDefinition,e,gr,t)}getBoardDefinitionForLevel(e,t=false){return this.send(pe.GetBoardDefinitionForLevel,e,gr,t)}getUserBoardState(e){return this.send(pe.GetUserBoardState,e,ba)}boardLoopRoll(e){return this.send(pe.BoardLoopRoll,e,Pa)}boardLoopAttack(e){return this.send(pe.BoardLoopAttack,e,Ma)}boardLoopRaid(e){return this.send(pe.BoardLoopRaid,e,zi)}boardLoopRaidFast(e){return this.send(pe.BoardLoopRaidFast,e,zi)}boardLoopBuild(e){return this.send(pe.BoardLoopBuild,e,ka)}boardSpecialChoose(e){return this.send(pe.BoardSpecialChoose,e,Aa)}boardSpecialApplyMultiplier(e){return this.send(pe.BoardSpecialApplyMultiplier,e,Oa)}boardSpecialClaim(e){return this.send(pe.BoardSpecialClaim,e,Ua)}getCommunityChestState(e){return this.send(pe.GetCommunityChestState,e,qa)}joinOrCreateCommunityChest(e){return this.send(pe.JoinOrCreateCommunityChest,e,Ea)}claimCommunityChestMilestone(e){return this.send(pe.ClaimCommunityChestMilestone,e,vi)}claimCommunityChestGrandPrize(e){return this.send(pe.ClaimCommunityChestGrandPrize,e,vi)}leaveCommunityChest(e){return this.send(pe.LeaveCommunityChest,e,La)}};var It=zod.z.lazy(()=>zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null(),zod.z.array(It),zod.z.record(zod.z.string(),It)]));var fh={Live:"Live",Latest:"Latest",Specific:"Specific"},Rh={Debug:"Debug",Info:"Info",Warning:"Warning",Error:"Error"},gh=zod.z.enum(["Debug","Info","Warning","Error"]),yh={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"},Ch=zod.z.enum(["None","Disabled","NoActiveRevision","RevisionNotFound","InvalidFieldName","RateLimited","HandlerNotFound","HandlerDisabled","Timeout","StatementCountExceeded","StackOverflow","ApiCallLimitExceeded","JavaScriptException","ExecutionError"]),Sh=zod.z.object({Level:gh,Message:zod.z.string().nullish(),Data:It.nullish()}),xh=zod.z.object({Error:Ch,Message:zod.z.string().nullish(),StackTrace:zod.z.string().nullish()}),Qa=zod.z.object({FunctionName:zod.z.string().nullish(),Revision:zod.z.number().nullish(),FunctionResult:It.nullish(),FunctionResultTooLarge:zod.z.boolean().nullish(),Logs:zod.z.array(Sh).nullish(),LogsTooLarge:zod.z.boolean().nullish(),ExecutionTimeSeconds:zod.z.number().nullish(),APIRequestsIssued:zod.z.number().nullish(),Error:xh.nullish()}),ki={Execute:"Execute"};var br=class{constructor(e){this.ctx=e;}ctx;execute(e){let t=O(this.ctx.settings.titleID,"CloudCode",ki.Execute,e.UserID??"");return this.ctx.transport.post(t,e,Qa,{ticket:e.ClientSessionTicket})}};var zr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Blockchain",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(ve.GetDefinitions,e,gn)}getUserState(e){return this.send(ve.GetUserState,e,yn)}depositToken(e){return this.send(ve.DepositToken,e,Cn)}depositNFT(e){return this.send(ve.DepositNFT,e,Sn)}requestTokenWithdrawal(e){return this.send(ve.RequestTokenWithdrawal,e,xn)}requestNFTWithdrawal(e){return this.send(ve.RequestNFTWithdrawal,e,Dn)}getTransactionHistory(e){return this.send(ve.GetTransactionHistory,e,bn)}retryWithdrawal(e){return this.send(ve.RetryWithdrawal,e,zn)}confirmWithdrawal(e){return this.send(ve.ConfirmWithdrawal,e,vn)}donateToDeveloper(e){return this.send(ve.DonateToDeveloper,e,Hr)}donateToUsersPool(e){return this.send(ve.DonateToUsersPool,e,Hr)}};var vr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Marketplace",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(te.GetDefinitions,e,Gn)}getGroupedOffers(e){return this.send(te.GetGroupedOffers,e,Nn)}getOffersByItem(e){return this.send(te.GetOffersByItem,e,si)}getOffer(e){return this.send(te.GetOffer,e,jn)}getBuyOrders(e){return this.send(te.GetBuyOrders,e,si)}getMyState(e){return this.send(te.GetMyState,e,_n)}getHistory(e){return this.send(te.GetHistory,e,Wn)}createListing(e){return this.send(te.CreateListing,e,zt)}cancelListing(e){return this.send(te.CancelListing,e,ke)}buy(e){return this.send(te.Buy,e,ke)}marketBuy(e){return this.send(te.MarketBuy,e,ke)}marketSell(e){return this.send(te.MarketSell,e,ke)}createAuction(e){return this.send(te.CreateAuction,e,zt)}placeBid(e){return this.send(te.PlaceBid,e,Fn)}claimAuction(e){return this.send(te.ClaimAuction,e,ke)}createBuyOrder(e){return this.send(te.CreateBuyOrder,e,zt)}cancelBuyOrder(e){return this.send(te.CancelBuyOrder,e,ke)}fillBuyOrder(e){return this.send(te.FillBuyOrder,e,ke)}createDirectTrade(e){return this.send(te.CreateDirectTrade,e,zt)}respondDirectTrade(e){return this.send(te.RespondDirectTrade,e,ke)}cancelDirectTrade(e){return this.send(te.CancelDirectTrade,e,ke)}claimBack(e){return this.send(te.ClaimBack,e,ke)}};var Tr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Multiplayer",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}createRoom(e){return this.send(Ue.CreateRoom,e,Cr)}joinRoom(e){return this.send(Ue.JoinRoom,e,Cr)}leaveRoom(e){return this.send(Ue.LeaveRoom,e,Pi)}listRooms(e){return this.send(Ue.ListRooms,e,Fa)}getRoom(e){return this.send(Ue.GetRoom,e,Cr)}closeRoom(e){return this.send(Ue.CloseRoom,e,Pi)}poll(e){return this.send(Ue.Poll,e,_a)}sendSignal(e){return this.send(Ue.SendSignal,e,Sr)}sendChat(e){return this.send(Ue.SendChat,e,Sr)}setMemberState(e){return this.send(Ue.SetMemberState,e,Sr)}};var Ir=class{settings;emitter;platform;transport;data;authStore;api;auth;userService;currency;item;store;lootbox;reward;quest;timedEvent;leaderboard;season;premium;character;match;craft;collection;coopEvent;dealOffer;referral;social;timedBoost;userCustomData;title;gameLoop;cloudCode;blockchain;marketplace;multiplayer;constructor(e){this.settings=Ui(e),this.emitter=new xt,this.platform=e.platform??new ut,this.transport=new Ot({baseUrl:this.settings.baseUrl,emitter:this.emitter,fetchImpl:e.fetch,debugLogging:this.settings.debugLogging,throttleMs:e.throttleMs}),this.data=new qt(this.emitter),this.authStore=new Nt(this.platform.storage,this.settings.titleID),this.api={authentication:new Ps(this),user:new Ms(this),currency:new ks(this),item:new Us(this),store:new ws(this),lootbox:new Gs(this),reward:new Ns(this),quest:new Fs(this),timedEvent:new Ws(this),leaderboard:new Zs(this),season:new Ys(this),premium:new er(this),character:new tr(this),match:new sr(this),craft:new ir(this),collection:new ar(this),coopEvent:new ur(this),dealOffer:new cr(this),referral:new pr(this),social:new mr(this),timedBoost:new fr(this),userCustomData:new Rr(this),title:new xr(this),gameLoop:new Dr(this),cloudCode:new br(this),blockchain:new zr(this),marketplace:new vr(this),multiplayer:new Tr(this)},this.userService=new Ft(this),this.auth=new jt(this),this.currency=new Wt(this),this.item=new Vt(this),this.store=new Qt(this),this.lootbox=new Ht(this),this.reward=new $t(this),this.quest=new Kt(this),this.timedEvent=new Zt(this),this.leaderboard=new Jt(this),this.season=new Yt(this),this.premium=new Xt(this),this.character=new es(this),this.match=new ts(this),this.craft=new ss(this),this.collection=new rs(this),this.coopEvent=new is(this),this.dealOffer=new ns(this),this.referral=new os(this),this.social=new as(this),this.timedBoost=new ls(this),this.userCustomData=new ps(this),this.title=new ds(this),this.gameLoop=new ms(this),this.cloudCode=new hs(this),this.blockchain=new Ds(this),this.marketplace=new Ts(this),this.multiplayer=new Is(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 Pr=class{ctx;constructor(e){this.ctx=new Ir(e);}get titleID(){return this.ctx.settings.titleID}get auth(){return this.ctx.auth}get user(){return this.ctx.userService}get currency(){return this.ctx.currency}get item(){return this.ctx.item}get store(){return this.ctx.store}get lootbox(){return this.ctx.lootbox}get reward(){return this.ctx.reward}get quest(){return this.ctx.quest}get timedEvent(){return this.ctx.timedEvent}get leaderboard(){return this.ctx.leaderboard}get season(){return this.ctx.season}get premium(){return this.ctx.premium}get character(){return this.ctx.character}get match(){return this.ctx.match}get craft(){return this.ctx.craft}get collection(){return this.ctx.collection}get coopEvent(){return this.ctx.coopEvent}get dealOffer(){return this.ctx.dealOffer}get referral(){return this.ctx.referral}get social(){return this.ctx.social}get timedBoost(){return this.ctx.timedBoost}get userCustomData(){return this.ctx.userCustomData}get 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 Dh(c){return new Pr(c)}var bh={Banner:"Banner",Interstitial:"Interstitial",RewardedVideo:"RewardedVideo",RewardedInterstitial:"RewardedInterstitial",AppOpen:"AppOpen",Native:"Native"},Ai=zod.z.enum(["Banner","Interstitial","RewardedVideo","RewardedInterstitial","AppOpen","Native"]),zh={Top:"Top",Bottom:"Bottom",Left:"Left",Right:"Right"},vh=zod.z.enum(["Top","Bottom","Left","Right"]),Th=zod.z.object({PlacementID:zod.z.string().nullish(),Type:Ai.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(),Ih=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(),Ph=zod.z.object({CooldownSeconds:zod.z.number().nullish(),MinSessionTimeBeforeFirstSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),Mh=zod.z.object({Enabled:zod.z.boolean().nullish(),Position:vh.nullish(),RefreshIntervalSeconds:zod.z.number().nullish()}).passthrough(),kh=zod.z.object({Enabled:zod.z.boolean().nullish(),CooldownSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish()}).passthrough(),Ah=zod.z.object({MaxImpressionsPerHour:zod.z.number().nullish(),MaxImpressionsPerDay:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),Oh=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(),Uh=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(),Bh=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(),wh=zod.z.object({AndroidUnitID:zod.z.string().nullish(),IosUnitID:zod.z.string().nullish(),WebUnitID:zod.z.string().nullish(),Type:Ai.nullish()}).passthrough(),qh=zod.z.object({ProviderID:zod.z.string().nullish(),Enabled:zod.z.boolean().nullish(),Priority:zod.z.number().nullish(),AndroidAppID:zod.z.string().nullish(),IosAppID:zod.z.string().nullish(),WebAppID:zod.z.string().nullish(),Units:zod.z.record(zod.z.string(),wh).nullish()}).passthrough();zod.z.object({Enabled:zod.z.boolean().nullish(),Placements:zod.z.record(zod.z.string(),Th).nullish(),Providers:zod.z.record(zod.z.string(),qh).nullish(),RewardedVideo:Ih.nullish(),Interstitial:Ph.nullish(),Banner:Mh.nullish(),AppOpen:kh.nullish(),FrequencyCapping:Ah.nullish(),PremiumAdReductions:zod.z.array(Oh).nullish(),Consent:Uh.nullish(),Verification:Bh.nullish()}).passthrough();var Eh=zod.z.object({RewardedVideoCredit:zod.z.number().nullish(),TotalEarned:zod.z.number().nullish(),TotalSpent:zod.z.number().nullish()}).passthrough(),Lh=zod.z.object({PlacementID:zod.z.string().nullish(),LastShownAt:a.nullish(),LastCompletedAt:a.nullish(),TotalImpressions:zod.z.number().nullish(),TotalCompletions:zod.z.number().nullish(),ConsecutiveFailures:zod.z.number().nullish()}).passthrough(),Gh=zod.z.object({Date:a.nullish(),ImpressionsByPlacement:zod.z.record(zod.z.string(),zod.z.number()).nullish(),CompletionsByPlacement:zod.z.record(zod.z.string(),zod.z.number()).nullish(),TotalImpressions:zod.z.number().nullish(),InterstitialImpressions:zod.z.number().nullish(),RewardedCompletions:zod.z.number().nullish(),AppOpenImpressions:zod.z.number().nullish(),CreditsEarnedToday:zod.z.number().nullish()}).passthrough(),Nh=zod.z.object({SessionID:zod.z.string().nullish(),SessionStartAt:a.nullish(),Impressions:zod.z.number().nullish(),InterstitialImpressions:zod.z.number().nullish(),RewardedCompletions:zod.z.number().nullish()}).passthrough(),jh=zod.z.object({PersonalizedAdsConsent:zod.z.boolean().nullish(),TrackingConsent:zod.z.boolean().nullish(),PolicyVersion:zod.z.string().nullish(),Region:zod.z.string().nullish(),ConsentGivenAt:a.nullish(),ConsentRevokedAt:a.nullish()}).passthrough(),Fh=zod.z.object({RequestID:zod.z.string().nullish(),PlacementID:zod.z.string().nullish(),ProviderID:zod.z.string().nullish(),Type:Ai.nullish(),IssuedAt:a.nullish(),ExpiresAt:a.nullish(),CreditsToAward:zod.z.number().nullish()}).passthrough(),_h=zod.z.object({InvalidSsvCount:zod.z.number().nullish(),OrphanCompletions:zod.z.number().nullish(),FastCompletions:zod.z.number().nullish(),LastFlaggedAt:a.nullish()}).passthrough();zod.z.object({Credits:Eh.nullish(),Placements:zod.z.record(zod.z.string(),Lh).nullish(),Daily:Gh.nullish(),Session:Nh.nullish(),LastImpressionAt:a.nullish(),LastInterstitialAt:a.nullish(),LastRewardedAt:a.nullish(),LastAppOpenAt:a.nullish(),TotalImpressions:zod.z.number().nullish(),TotalRewardedCompletions:zod.z.number().nullish(),AdsDisabledUntil:a.nullish(),Consent:jh.nullish(),PendingRequests:zod.z.record(zod.z.string(),Fh).nullish(),FraudFlags:_h.nullish(),UpdatedAt:a.nullish()}).passthrough();var Wh={Unread:"Unread",Read:"Read",Deleted:"Deleted",Expired:"Expired"},Vh=zod.z.enum(["Unread","Read","Deleted","Expired"]),Qh={Admin:"Admin",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season",Collection:"Collection",MilestoneEvent:"MilestoneEvent",PlayerGift:"PlayerGift",Social:"Social",Compensation:"Compensation",Referral:"Referral",Quest:"Quest"},Hh=zod.z.enum(["Admin","Leaderboard","CoopEvent","Season","Collection","MilestoneEvent","PlayerGift","Social","Compensation","Referral","Quest"]),$h={Active:"Active",Paused:"Paused",Cancelled:"Cancelled",Completed:"Completed"},Kh=zod.z.enum(["Active","Paused","Cancelled","Completed"]),Zh=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(),Jh=zod.z.object({SegmentID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Gate:H.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(),Zh).nullish(),Segments:zod.z.array(Jh).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:Hh.nullish(),RelatedEntityID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderPublicData:ge.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:a.nullish(),Status:Vh.nullish(),CreatedAtUtc:a.nullish(),ExpiresAtUtc:a.nullish(),ReadAtUtc:a.nullish(),BroadcastID:zod.z.string().nullish(),Version:zod.z.number().nullish()}).passthrough();zod.z.object({BroadcastID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),MessageTypeID:zod.z.string().nullish(),Subject:zod.z.string().nullish(),Body:zod.z.string().nullish(),TemplateParams:zod.z.record(zod.z.string(),zod.z.string()).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rewards:L.nullish(),TargetSegmentID:zod.z.string().nullish(),TargetUserIDs:zod.z.array(zod.z.string()).nullish(),StartsAtUtc:a.nullish(),ExpiresAtUtc:a.nullish(),CreatedAtUtc:a.nullish(),CreatedByAdminID:zod.z.string().nullish(),AdminComment:zod.z.string().nullish(),Status:Kh.nullish(),DeliveredCount:zod.z.number().nullish(),ClaimedCount:zod.z.number().nullish()}).passthrough();zod.z.object({UnreadCount:zod.z.number().nullish(),UnclaimedRewardCount:zod.z.number().nullish(),LastFetchCursor:a.nullish(),ReceivedBroadcastIDs:zod.z.array(zod.z.string()).nullish(),ClaimedBroadcastIDs:zod.z.array(zod.z.string()).nullish(),DailyP2PGiftsSent:zod.z.number().nullish(),DailyGiftsResetDate:a.nullish(),LastOpenedAtUtc:a.nullish(),TotalMessagesReceived:zod.z.number().nullish(),TotalRewardsClaimed:zod.z.number().nullish()}).passthrough();var Ha="idos_device_id",Mr=class{storage;constructor(e=new at){this.storage=e;}getPlatform(){return "Web"}getFullURL(){return ""}getStartParameter(){return null}getTelegramInitDataRaw(){return null}getDeviceID(){let e=this.storage.getString(Ha);return e||(e="noop-device",this.storage.setString(Ha,e)),e}getDeviceModel(){return "Noop"}shareLink(){}openInvoice(){}async showAd(){}async copyToClipboard(){}};
2
- exports.AdType=bh;exports.AttackOutcome=bm;exports.AuthType=ae;exports.AuthenticationAction=Ae;exports.BannerPosition=zh;exports.BlockchainAction=ve;exports.BlockchainNetworkType=pu;exports.BlockchainOperationCategory=mn;exports.BlockchainTransactionStatus=Su;exports.BlockchainTransactionType=fu;exports.BodyPart=Ku;exports.BoostWindowKind=Cm;exports.BroadcastStatus=$h;exports.BrowserPlatformAdapter=ut;exports.BrowserStorage=ot;exports.CharacterAction=ze;exports.CloudCodeAction=ki;exports.CloudCodeErrorCode=yh;exports.CloudCodeLogLevel=Rh;exports.CloudCodeRevisionSelection=fh;exports.CollectionAction=Ce;exports.CommissionSink=hc;exports.CommunityChestMemberStatus=Zm;exports.CommunityChestStatus=Km;exports.ConversionRateMode=Fl;exports.CoopEventAction=Ge;exports.CoopGroupStatus=Td;exports.CoopMemberStatus=Id;exports.CraftAction=rr;exports.CraftType=pd;exports.CurrencyAction=fs;exports.CurrencyStatus=jl;exports.CurrencyType=we;exports.CustomDataBucket=We;exports.CustomDataValueType=Al;exports.CustomDataWriter=Il;exports.DEFAULT_BASE_URL=Oi;exports.DealNodeRuntimeStatus=Ld;exports.DealOfferAction=Fe;exports.DealOfferActivationStatus=Ed;exports.EnvelopeType=lh;exports.EventTokenType=il;exports.FodderSelectionMode=wc;exports.FodderValuationMode=Uc;exports.FriendActionStatus=am;exports.GameLoopAction=pe;exports.IDosGamesClient=Pr;exports.ItemAction=As;exports.KycStatus=Ru;exports.KycTier=yu;exports.LeaderboardAction=he;exports.LootboxAction=Ls;exports.MailboxMessageSource=Qh;exports.MailboxMessageStatus=Wh;exports.MarketGoodsType=vs;exports.MarketOfferStatus=mc;exports.MarketOfferType=dc;exports.MarketplaceAction=te;exports.MatchAction=Ne;exports.MatchStatus=Zu;exports.MemoryStorage=at;exports.MultiplayerAction=Ue;exports.MultiplayerChatMode=nh;exports.MultiplayerTopology=ih;exports.NoopPlatformAdapter=Mr;exports.PremiumAction=rt;exports.QuestAction=Le;exports.QuestObjectiveSource=Op;exports.QuestPrerequisiteMode=Bp;exports.QuestStatus=Pp;exports.RaidMode=xm;exports.ReferralAction=yt;exports.ResourceEntryType=rl;exports.RewardAction=He;exports.RoomVisibility=oh;exports.ScheduleMode=nl;exports.SeasonAction=st;exports.SocialAction=_e;exports.SpecialChoiceMode=Dm;exports.StoreAction=mt;exports.StoreType=ad;exports.TimedBoostAction=it;exports.TimedBoostStackingPolicy=pm;exports.TimedEventAction=Oe;exports.TimelineEventType=lm;exports.TitleAction=nt;exports.TradeOfferStatus=fd;exports.TransactionDirection=xu;exports.TypedEmitter=xt;exports.UserAction=je;exports.UserCustomDataAction=Ee;exports.WalletLinkType=mu;exports.createIDosGamesClient=Dh;exports.isFail=Za;exports.isOk=Ka;exports.normalizeBlockchainCategory=Ss;
1
+ 'use strict';var zod=require('zod'),jt=require('decimal.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var jt__default=/*#__PURE__*/_interopDefault(jt);var xt=class{listeners=new Map;on(e,t){let s=this.listeners.get(e);return s||(s=new Set,this.listeners.set(e,s)),s.add(t),()=>{this.off(e,t);}}once(e,t){let s=this.on(e,r=>{s(),t(r);});return s}off(e,t){let s=this.listeners.get(e);s&&(s.delete(t),s.size===0&&this.listeners.delete(e));}emit(e,t){let s=this.listeners.get(e);if(s)for(let r of [...s])r(t);}removeAllListeners(){this.listeners.clear();}};var Li="https://api.idosgames.com";function Gi(u){return {titleID:u.titleID,titleTemplateID:u.titleTemplateID??"default",buildKey:u.buildKey??"",baseUrl:(u.baseUrl??Li).replace(/\/+$/,""),devBuild:u.devBuild??false,debugLogging:u.debugLogging??false}}var at=class{getString(e){if(typeof localStorage>"u")return null;try{return localStorage.getItem(e)}catch{return null}}setString(e,t){if(!(typeof localStorage>"u"))try{localStorage.setItem(e,t);}catch{}}remove(e){if(!(typeof localStorage>"u"))try{localStorage.removeItem(e);}catch{}}},lt=class{map=new Map;getString(e){return this.map.get(e)??null}setString(e,t){this.map.set(e,t);}remove(e){this.map.delete(e);}};function ut(){return globalThis.Telegram?.WebApp??null}function M(){return crypto.randomUUID()}var Ni="idos_device_id",ct=class{storage;constructor(e=new at){this.storage=e;}getPlatform(){return ut()?.platform??"Web"}getFullURL(){return typeof location<"u"?location.href:""}getStartParameter(){let e=ut()?.initDataUnsafe?.start_param;return typeof e=="string"?e:null}getTelegramInitDataRaw(){let e=ut()?.initData;return e&&e.length>0?e:null}getDeviceID(){let e=this.storage.getString(Ni);return e||(e=M(),this.storage.setString(Ni,e)),e}getDeviceModel(){return typeof navigator<"u"&&navigator.userAgent?navigator.userAgent:"Web"}shareLink(e){let t=ut();if(t?.openTelegramLink){t.openTelegramLink(e);return}typeof window<"u"&&window.open(e,"_blank");}openInvoice(e){let t=ut();if(t?.openInvoice){t.openInvoice(e);return}typeof window<"u"&&window.open(e,"_blank");}async showAd(e){let t=globalThis;typeof t.showAd=="function"&&await t.showAd(e);}async copyToClipboard(e){typeof navigator<"u"&&navigator.clipboard&&await navigator.clipboard.writeText(e);}};function ji(u){return {ok:true,data:u}}function n(u,e){return {ok:false,reason:u,error:e}}function rl(u){return u.ok}function il(u){return !u.ok}var we={Virtual:"Virtual",Crypto:"Crypto"},pt=zod.z.enum(["Virtual","Crypto"]),nl={Item:"Item",VirtualCurrency:"VirtualCurrency",CryptoCurrency:"CryptoCurrency",UsdCent:"UsdCent"},Ot=zod.z.enum(["Item","VirtualCurrency","CryptoCurrency","UsdCent"]),ol={TimedEvent:"TimedEvent",Quest:"Quest",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season"},Bt=zod.z.enum(["TimedEvent","Quest","Leaderboard","CoopEvent","Season"]),al={Cyclic:"Cyclic",Scheduled:"Scheduled",Chained:"Chained"},Dt=zod.z.enum(["Cyclic","Scheduled","Chained"]),le={None:"None",Device:"Device",Email:"Email",iDosGames:"iDosGames",Facebook:"Facebook",Google:"Google",GooglePlay:"GooglePlay",Telegram:"Telegram",Wallet:"Wallet"};var k=zod.z.union([zod.z.number(),zod.z.string()]).transform((u,e)=>{let t=typeof u=="string"?Number(u):u;return Number.isFinite(t)?Math.trunc(t):(e.addIssue({code:zod.z.ZodIssueCode.custom,message:`Invalid integer amount: ${String(u)}`}),zod.z.NEVER)}),w=zod.z.union([zod.z.number(),zod.z.string()]).transform((u,e)=>{let t=typeof u=="number"?String(u):u.trim();return t===""||Number.isNaN(Number(t))?(e.addIssue({code:zod.z.ZodIssueCode.custom,message:`Invalid decimal: ${String(u)}`}),zod.z.NEVER):t}),a=zod.z.string();var Ur=zod.z.object({Type:Ot.nullish(),CurrencyID:zod.z.string().nullish(),Amount:k.nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish()}),ll=zod.z.object({Type:Bt.nullish(),EntityID:zod.z.string()}),ul=zod.z.object({Address:ll.nullish(),Amount:k.nullish(),Source:zod.z.string().nullish()}),oe=zod.z.object({Entries:zod.z.array(Ur).nullish(),EventTokens:zod.z.array(ul).nullish()}),Fi=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Resources:oe.nullish()}),G=zod.z.object({Standard:oe.nullish(),PremiumBonuses:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(Fi).nullish()}),H=zod.z.object({Standard:oe.nullish(),PremiumDiscounts:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(Fi).nullish()}),x=zod.z.object({Grant:G.nullish(),Consume:H.nullish()}),tt=zod.z.object({FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),FromResult:x.nullish(),ToResult:x.nullish()});zod.z.object({FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),Transferred:oe.nullish()});var cl=zod.z.object({ExperimentID:zod.z.string().nullish(),Variants:zod.z.array(zod.z.string()).nullish()}).passthrough(),V=zod.z.object({Segments:zod.z.array(zod.z.string()).nullish(),MinPremiumTier:zod.z.number().nullish(),RequiredPremiumIDs:zod.z.array(zod.z.string()).nullish(),MinLevel:zod.z.number().nullish(),MaxLevel:zod.z.number().nullish(),Countries:zod.z.array(zod.z.string()).nullish(),RegisteredWithinDays:zod.z.number().nullish(),ActiveWithinDays:zod.z.number().nullish(),Experiment:cl.nullish()}).passthrough();var ce=zod.z.object({TotalCap:zod.z.number().nullish(),DailyCap:zod.z.number().nullish(),DailyWeightCap:zod.z.number().nullish(),PerActivationCap:zod.z.number().nullish(),CooldownSeconds:zod.z.number().nullish(),MaxPerWindow:zod.z.number().nullish(),WindowSeconds:zod.z.number().nullish()}).passthrough();var pl=zod.z.object({OffsetSecondsFromParentStart:zod.z.number().nullish(),DurationSeconds:zod.z.number().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),dl=zod.z.object({StartUtc:zod.z.string().nullish(),EndUtc:zod.z.string().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),ml=zod.z.object({AnchorUtc:zod.z.string().nullish(),MaxCycles:zod.z.number().nullish(),PauseBetweenPhasesSec:zod.z.number().nullish(),PauseBetweenCyclesSec:zod.z.number().nullish()}).passthrough();zod.z.object({PhaseID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough();var hl=zod.z.object({Reset:zod.z.string().nullish(),IntervalSeconds:zod.z.number().nullish(),AnchorUtc:zod.z.string().nullish(),PauseBetweenCyclesSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough();zod.z.object({SourceType:zod.z.string().nullish(),TileType:zod.z.string().nullish(),TileIndex:zod.z.number().nullish(),ChanceOutcomeID:zod.z.string().nullish(),Outcome:zod.z.string().nullish(),Params:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough();var We=zod.z.object({SourceType:zod.z.string().nullish(),BaseWeight:zod.z.number().nullish(),ScaleWithRollMultiplier:zod.z.boolean().nullish(),TileTypeFilter:zod.z.array(zod.z.string()).nullish(),TileIndexFilter:zod.z.array(zod.z.number()).nullish(),ChanceOutcomeFilter:zod.z.array(zod.z.string()).nullish(),OutcomeFilter:zod.z.array(zod.z.string()).nullish(),Params:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Limits:ce.nullish()}).passthrough(),ue=zod.z.object({Mode:zod.z.string().nullish(),IsActive:zod.z.boolean().nullish(),Scheduled:dl.nullish(),Chain:ml.nullish(),Cyclic:hl.nullish(),ActivationTriggers:zod.z.array(We).nullish(),Relative:pl.nullish()}).passthrough();var fl=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Rewards:G.nullish()}).passthrough(),gl=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),wr=zod.z.object({Bundles:zod.z.array(fl).nullish(),Multipliers:zod.z.array(gl).nullish()}).passthrough();var Rl=zod.z.enum(["BoardStageLevel","BoardRank","BoardCyclesCompleted","CharacterLevel","SeasonTier","EventTokenTotalEarned","VirtualCurrencyBalance","PlayerLevel"]);var yl=zod.z.enum(["Tiered","Linear"]);var Cl=zod.z.enum(["Step","Linear"]),Sl=zod.z.object({AtProgress:zod.z.number().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),Ut=zod.z.object({Source:Rl.nullish(),SourceKey:zod.z.string().nullish(),CurveType:yl.nullish(),Tiers:zod.z.array(Sl).nullish(),TierMode:Cl.nullish(),BaseMultiplier:zod.z.number().nullish(),PerUnit:zod.z.number().nullish(),Anchor:zod.z.number().nullish(),MinMultiplier:zod.z.number().nullish(),MaxMultiplier:zod.z.number().nullish(),IncludeRewards:oe.nullish(),ExcludeRewards:oe.nullish()}).passthrough(),ye=zod.z.object({MilestoneID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),RequiredProgress:zod.z.number().nullish(),Rewards:G.nullish(),BonusRewards:G.nullish(),SeasonTierRewards:wr.nullish(),SortOrder:zod.z.number().nullish(),IsFeatured:zod.z.boolean().nullish()}).passthrough(),Ye=zod.z.object({Milestones:zod.z.record(zod.z.string(),ye).nullish()}).passthrough();var pe=zod.z.object({PresetID:zod.z.string().nullish(),Remove:zod.z.array(zod.z.string()).nullish()}).passthrough();var xl=zod.z.object({TargetCurrencyID:zod.z.string().nullish(),Rate:zod.z.number().nullish(),MaxConvertAmount:zod.z.number().nullish()}).passthrough(),st=zod.z.object({DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),MaxBalance:zod.z.number().nullish(),MaxPerGrant:zod.z.number().nullish(),DailyEarnCap:zod.z.number().nullish(),BurnOnEventEnd:zod.z.boolean().nullish(),BurnConversion:xl.nullish()}).passthrough();var te=u=>zod.z.object({Id:zod.z.string(),Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:u.nullish()}),qt=u=>zod.z.object({ServerTimeUtc:a,Items:zod.z.array(te(u)),Resources:x.nullish()});var Dl={Active:"Active",Completed:"Completed",Claimed:"Claimed",Expired:"Expired"},_i=zod.z.enum(["Active","Completed","Claimed","Expired"]),bl=zod.z.object({}).passthrough().transform(u=>u),zl=zod.z.object({CycleID:zod.z.string(),InstanceKey:zod.z.string().nullish(),PhaseID:zod.z.string().nullish(),CycleIndex:zod.z.number().nullish(),CycleStartUtc:a.nullish(),CycleEndUtc:a.nullish(),PointsTotalEarned:k.nullish(),PointsCurrent:k.nullish(),ClaimedPointMilestoneIDs:zod.z.array(zod.z.string()).nullish()}),qr=zod.z.object({QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),ObjectiveID:zod.z.string().nullish(),NewValue:k.nullish(),ObjectiveCompleted:zod.z.boolean().nullish(),Status:_i}),Wi=zod.z.object({State:bl.nullish(),PointsTracks:zod.z.record(zod.z.string(),zl).nullish()}),Er=zod.z.object({ServerTimeUtc:a,QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),NewStatus:_i.nullish(),Resources:x.nullish()}),Lr=zod.z.object({ServerTimeUtc:a,CycleID:zod.z.string(),MilestoneID:zod.z.string(),PointsTotalEarned:k.nullish(),Resources:x.nullish()}),Vi=zod.z.object({ServerTimeUtc:a,CycleID:zod.z.string(),GroupCompletionID:zod.z.string(),GroupID:zod.z.string().nullish(),CompletedGroupQuests:zod.z.number().nullish(),RequiredGroupQuests:zod.z.number().nullish(),Resources:x.nullish()}),Qi=zod.z.object({MetricID:zod.z.string(),Updates:zod.z.array(qr).nullish()}),Hi=zod.z.array(te(Er)),Ki=zod.z.array(te(Lr)),vl={ClientApi:"ClientApi",ServerApi:"ServerApi",SystemEvent:"SystemEvent"},Tl=zod.z.enum(["ClientApi","ServerApi","SystemEvent"]),Pl={BlockProgressAndClaim:"BlockProgressAndClaim",BlockClaimOnly:"BlockClaimOnly"},Il=zod.z.enum(["BlockProgressAndClaim","BlockClaimOnly"]),Ml=zod.z.object({ObjectiveID:zod.z.string().nullish(),Source:Tl.nullish(),MaxProgressPerCall:zod.z.number().nullish(),MetricID:zod.z.string().nullish(),Triggers:zod.z.array(We).nullish(),TargetValue:zod.z.number().nullish(),AggregationMethod:zod.z.string().nullish()}).passthrough(),kl=zod.z.object({QuestID:zod.z.string().nullish(),CycleIDs:zod.z.array(zod.z.string()).nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),RequiredQuestIDs:zod.z.array(zod.z.string()).nullish(),PrerequisiteMode:Il.nullish(),PointsReward:zod.z.number().nullish(),Schedule:ue.nullish(),AccrueProgressWhenLocked:zod.z.boolean().nullish(),Gate:V.nullish(),Limits:ce.nullish(),GroupID:zod.z.string().nullish(),PhaseIDs:zod.z.array(zod.z.string()).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Objectives:zod.z.record(zod.z.string(),Ml).nullish(),Reward:G.nullish()}).passthrough(),Al=zod.z.object({CompletionID:zod.z.string().nullish(),GroupID:zod.z.string().nullish(),RequiredCompletedQuests:zod.z.number().nullish(),Gate:V.nullish(),Reward:G.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),$i=zod.z.object({Milestones:pe.nullish()}).passthrough(),Ol=zod.z.object({PhaseID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Gate:V.nullish(),Milestones:zod.z.record(zod.z.string(),ye).nullish(),Presets:$i.nullish(),PointsToken:st.nullish()}).passthrough(),Bl=zod.z.object({Milestones:zod.z.record(zod.z.string(),Ye).nullish()}).passthrough(),Ul=zod.z.object({CycleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:ue.nullish(),Milestones:zod.z.record(zod.z.string(),ye).nullish(),Gate:V.nullish(),PointsToken:st.nullish(),GroupCompletions:zod.z.record(zod.z.string(),Al).nullish(),Phases:zod.z.record(zod.z.string(),Ol).nullish(),Presets:$i.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Et=zod.z.object({Cycles:zod.z.record(zod.z.string(),Ul).nullish(),Quests:zod.z.record(zod.z.string(),kl).nullish(),Presets:Bl.nullish()}).passthrough(),Ee={GetQuestDefinitions:"GetQuestDefinitions",GetUserQuestState:"GetUserQuestState",RefreshQuestCycles:"RefreshQuestCycles",ClaimQuestReward:"ClaimQuestReward",ClaimMilestoneReward:"ClaimMilestoneReward",AddQuestProgress:"AddQuestProgress",ClaimQuestRewardsBatch:"ClaimQuestRewardsBatch",ClaimMilestoneRewardsBatch:"ClaimMilestoneRewardsBatch",ClaimGroupCompletionReward:"ClaimGroupCompletionReward"};var Lt=class{constructor(e=600,t=()=>Date.now()){this.windowMs=e;this.now=t;}windowMs;now;last=new Map;tryAcquire(e){if(this.windowMs<=0)return true;let t=this.now(),s=this.last.get(e);return s!==void 0&&t-s<this.windowMs?false:(this.last.set(e,t),true)}reset(){this.last.clear();}};var Gt=class{set=new Set;add(e){return this.set.has(e)?false:(this.set.add(e),true)}remove(e){this.set.delete(e);}};function Zi(u){return u===429||u>=500&&u<=599}function Gr(u,e=Math.random){let t=Math.min(500*Math.pow(2,u-1),4e3),s=t*.2*(e()*2-1);return Math.max(50,t+s)}function Nr(u){return new Promise(e=>setTimeout(e,u))}var wl=12e3,ql=zod.z.object({Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:zod.z.unknown().optional(),QuestProgress:zod.z.array(qr).nullish()}).passthrough(),Nt=class{baseUrl;emitter;fetchImpl;debugLogging;throttler;inflight=new Gt;inFlightRequests=0;sessionRefreshHandler=null;constructor(e){this.baseUrl=e.baseUrl,this.emitter=e.emitter,this.fetchImpl=e.fetchImpl??globalThis.fetch.bind(globalThis),this.debugLogging=e.debugLogging??false,this.throttler=new Lt(e.throttleMs);}setSessionRefreshHandler(e){this.sessionRefreshHandler=e;}async post(e,t,s,r={}){if(!this.throttler.tryAcquire(e))return n("throttled","Throttled");if(!this.inflight.add(e))return n("throttled","Duplicate request skipped");this.raiseBusy();try{let i=`${this.baseUrl}/${e}`,c=JSON.stringify(t),m=r.ticket??null,v=r.silent??!1,U=r.timeoutMs??wl,q=r.autoRetry??!0,he=!1,ge=0;for(;;){let Ie;try{Ie=await this.doFetch(i,c,m,U);}catch{if(q&&ge<3){ge++,await Nr(Gr(ge));continue}return this.connectionFailure("Internet Connection Error",v)}let Me=Ie.status;if(Me>=200&&Me<300)return await this.parseSuccess(Ie,s,v,e);if(Me===401){if(!he&&this.sessionRefreshHandler){he=!0;let Ze=null;try{Ze=await this.sessionRefreshHandler();}catch{Ze=null;}if(Ze){m=Ze;continue}}return this.emitter.emit("auth:unauthorized",void 0),n("unauthorized","Unauthorized")}if(Zi(Me)){if(q&&ge<3){ge++,await Nr(Gr(ge));continue}return this.connectionFailure(`Server temporarily unavailable (HTTP ${Me})`,v)}return await this.handleWebError(Ie,Me,v)}}finally{this.inflight.remove(e),this.lowerBusy();}}async doFetch(e,t,s,r){let i=new AbortController,c=setTimeout(()=>{i.abort();},r);try{let m={"Content-Type":"application/json"};return s&&(m.Authorization=`Bearer ${s}`),await this.fetchImpl(e,{method:"POST",body:t,headers:m,signal:i.signal})}finally{clearTimeout(c);}}async parseSuccess(e,t,s,r){let i;try{i=await e.text();}catch{return this.globalError("Failed to read response body",s)}let c;try{c=JSON.parse(i);}catch{return this.globalError("JSON Parse Error",s)}let m=ql.safeParse(c);if(!m.success)return this.globalError("Malformed response envelope",s);if(!m.data.Success){let q=m.data.Error??"Server returned Success=false";return s||this.emitter.emit("error:global",q),n("server",q)}let v=m.data.QuestProgress;v&&v.length>0&&this.emitter.emit("quest:systemProgress",v);let U=t.safeParse(m.data.Data);if(!U.success){let q=`Validation error (${r}): ${U.error.message}`;return this.debugLogging&&console.warn("[HttpTransport]",q),s||this.emitter.emit("error:global",q),n("validation",q)}return ji(U.data)}async handleWebError(e,t,s){let r=`HTTP ${t}`;try{let i=await e.text();if(i)try{let m=JSON.parse(i).Error;r=typeof m=="string"&&m.length>0?`HTTP ${t}: ${m}`:`HTTP ${t}: ${i}`;}catch{r=`HTTP ${t}: ${i}`;}}catch{}return s||this.emitter.emit("error:global",r),n("server",r)}connectionFailure(e,t){return t||this.emitter.emit("error:connection",e),n("connection",e)}globalError(e,t){return t||this.emitter.emit("error:global",e),n("server",e)}raiseBusy(){this.inFlightRequests++,this.inFlightRequests===1&&this.emitter.emit("transport:busy",true);}lowerBusy(){this.inFlightRequests>0&&(this.inFlightRequests--,this.inFlightRequests===0&&this.emitter.emit("transport:busy",false));}};function mt(u){return (typeof u=="string"?u:u.toISOString()).slice(0,10)}function zt(u){return `${mt(u)}T00:00:00.000Z`}function Yi(u){let e=new Date(u);return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+1)).toISOString()}function Xi(u,e){return new Date(u.getTime()+e*6e4).toISOString()}function en(u,e,t,s){let r={vcChanged:false,ccChanged:false,itemsChanged:false,tokensChanged:false};if(!e)return r;u.InventoryV2??={};let i=u.InventoryV2,c=s.toISOString(),m=new Map,v=new Map,U=new Map,q=new Map,he=new Map,ge=new Map,Ie=new Map,Me=new Map,Ze=e.Grant?.PremiumTiers??[],kt=Ze.length;for(let ee=0;;ee++){let ne,Q;if(ee===0)ne=e.Grant?.Standard?.Entries,Q=false;else if(ee-1<kt)ne=Ze[ee-1]?.Resources?.Entries,Q=false;else if(ee===1+kt)ne=e.Consume?.Standard?.Entries,Q=true;else break;if(ne)for(let N of ne){if(N.Type==null)continue;let _=Math.max(0,N.Amount??0);if(!(_<=0))switch(N.Type){case "VirtualCurrency":{if(!N.CurrencyID)continue;let W=Q?v:m;W.set(N.CurrencyID,(W.get(N.CurrencyID)??0)+_);break}case "CryptoCurrency":{if(!N.CurrencyID)continue;let W=Q?q:U;W.set(N.CurrencyID,(W.get(N.CurrencyID)??new jt__default.default(0)).plus(_));break}case "Item":{if(!N.ItemID)continue;let W=Ll(t,N.CatalogID,N.ItemID),Y=(W?W.IsStackable??true:true)?Q?ge:he:Q?Me:Ie;Y.set(N.ItemID,(Y.get(N.ItemID)??0)+_);break}case "UsdCent":continue}}}if(r.vcChanged=m.size>0||v.size>0,r.vcChanged){i.VirtualCurrencies??={};for(let ee of new Set([...m.keys(),...v.keys()])){let ne=m.get(ee)??0,Q=v.get(ee)??0,N=ne-Q,_=i.VirtualCurrencies[ee];_?(_.Amount+=N,_.UpdatedAt=c,_.Daily&&mt(_.Daily.PeriodStartUtc)===mt(s)?(_.Daily.Earned+=ne,_.Daily.Spent+=Q):_.Daily={PeriodStartUtc:zt(s),Earned:ne,Spent:Q}):i.VirtualCurrencies[ee]={Amount:N,CreatedAt:c,UpdatedAt:c,Daily:{PeriodStartUtc:zt(s),Earned:ne,Spent:Q}};}}if(r.ccChanged=U.size>0||q.size>0,r.ccChanged){i.CryptoCurrencies??={};for(let ee of new Set([...U.keys(),...q.keys()])){let ne=U.get(ee)??new jt__default.default(0),Q=q.get(ee)??new jt__default.default(0),N=ne.minus(Q),_=i.CryptoCurrencies[ee];_?(_.Amount=new jt__default.default(_.Amount).plus(N).toString(),_.UpdatedAt=c):i.CryptoCurrencies[ee]={Amount:N.toString(),Frozen:"0",CreatedAt:c,UpdatedAt:c};}}if(r.itemsChanged=he.size>0||ge.size>0||Ie.size>0||Me.size>0,r.itemsChanged){i.Items??={},i.UnstackableItems??={};let ee=i.UnstackableItems,ne=new Set([...he.keys(),...ge.keys(),...Ie.keys(),...Me.keys()]);for(let Q of ne){let N=(he.get(Q)??0)-(ge.get(Q)??0),_=(Ie.get(Q)??0)-(Me.get(Q)??0),W=N+_,ke=i.Items[Q];ke?(N!==0&&(ke.StackableAmount+=N),_!==0&&(ke.UnstackableAmount+=_),W!==0&&(ke.TotalAmount+=W)):i.Items[Q]={StackableAmount:Math.max(0,N),UnstackableAmount:Math.max(0,_),TotalAmount:Math.max(0,W)};}for(let[Q,N]of Me){if(N<=0)continue;let _=Object.values(ee).filter(W=>W.ItemID===Q&&W.EquippedSlot==null&&(W.ExpiresAt==null||new Date(W.ExpiresAt)>s)).sort(El).slice(0,N).map(W=>W.ItemInstanceID);for(let W of _)delete ee[W];}for(let[Q,N]of Ie){let _=Gl(t,Q);for(let W=0;W<N;W++){let ke=M();ee[ke]={ItemInstanceID:ke,ItemID:Q,CatalogID:_,RemainingUses:1,AcquiredAt:c};}}}u.EventToken??={};let sl=u.EventToken;for(let ee=0;;ee++){let ne,Q;if(ee===0)ne=e.Grant?.Standard?.EventTokens,Q=false;else if(ee-1<kt)ne=Ze[ee-1]?.Resources?.EventTokens,Q=false;else if(ee===1+kt)ne=e.Consume?.Standard?.EventTokens,Q=true;else break;if(!(!ne||ne.length===0))for(let N of ne){let _=N.Address;if(!_||_.Type==null)continue;let W=N.Amount??0;if(W<=0)continue;let ke=Nl(sl,_.Type);if(!ke)continue;let Y=ke[_.EntityID];Y||(Y={},ke[_.EntityID]=Y),Y.Balance??={Current:0,TotalEarned:0,TotalSpent:0},Y.Daily??={Date:zt(s),TotalEarned:0},Y.Meta??={};let St=N.Source&&N.Source.length>0?N.Source:"CustomAction";Q?(Y.Balance.Current-=W,Y.Balance.TotalSpent+=W):(Y.Balance.Current+=W,Y.Balance.TotalEarned+=W,mt(Y.Daily.Date)!==mt(s)&&(Y.Daily={Date:zt(s),TotalEarned:0}),Y.Daily.TotalEarned+=W,Y.Daily.EarnedBySource??={},Y.Daily.EarnedBySource[St]=(Y.Daily.EarnedBySource[St]??0)+W,Y.Daily.TriggersBySource??={},Y.Daily.TriggersBySource[St]=(Y.Daily.TriggersBySource[St]??0)+1,Y.Daily.LastTriggerBySource??={},Y.Daily.LastTriggerBySource[St]=c,Y.Meta.JoinedAtUtc||(Y.Meta.JoinedAtUtc=c),Y.Meta.LastEarnedAtUtc=c),r.tokensChanged=true;}}return r}function El(u,e){return u.AcquiredAt!==e.AcquiredAt?u.AcquiredAt<e.AcquiredAt?-1:1:u.ItemInstanceID===e.ItemInstanceID?0:u.ItemInstanceID<e.ItemInstanceID?-1:1}function Ll(u,e,t){let s=u?.Catalogs;if(s){if(e){let r=s[e]?.Items?.[t];if(r)return r}for(let r of Object.values(s)){let i=r.Items?.[t];if(i)return i}}}function Gl(u,e){let t=u?.Catalogs;if(t){for(let[s,r]of Object.entries(t))if(r.Items&&e in r.Items)return s}}function Nl(u,e){switch(e){case "TimedEvent":return u.TimedEvent??={};case "Quest":return u.Quest??={};case "Leaderboard":return u.Leaderboard??={};case "CoopEvent":return u.CoopEvent??={};case "Season":return u.Season??={};default:return null}}function jr(u,e){return u===e||u.startsWith(`${e}:`)}var Ft=class{constructor(e){this.emitter=e;}emitter;currentState={};activeEventsCache=null;get state(){return this.currentState}getCachedActiveEvents(){return this.activeEventsCache}clear(){this.currentState=null,this.emitter.emit("user:anyUpdated",void 0);}applyUserState(e){this.currentState=e,this.emitter.emit("user:stateUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyInventory(e){this.currentState??={},this.currentState.InventoryV2=e,this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyVirtualCurrency(e){this.currentState??={},this.currentState.InventoryV2??={},this.currentState.InventoryV2.VirtualCurrencies=e,this.emitter.emit("user:virtualCurrencyUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyResourceOperation(e,t,s=new Date){if(!this.currentState)return;let r=en(this.currentState,e,t,s);r.vcChanged&&this.emitter.emit("user:virtualCurrencyUpdated",void 0),(r.vcChanged||r.ccChanged||r.itemsChanged)&&this.emitter.emit("user:inventoryUpdated",void 0),r.tokensChanged&&this.emitter.emit("user:eventTokenUpdated",void 0),(r.vcChanged||r.ccChanged||r.itemsChanged||r.tokensChanged)&&this.emitter.emit("user:anyUpdated",void 0);}patchCryptoCurrencyDelta(e,t,s){if(!e||!this.currentState)return;this.currentState.InventoryV2??={},this.currentState.InventoryV2.CryptoCurrencies??={};let r=this.currentState.InventoryV2.CryptoCurrencies,i=t instanceof jt__default.default?t:new jt__default.default(t),c=s??new Date().toISOString(),m=r[e];m?(m.Amount=new jt__default.default(m.Amount).plus(i).toString(),m.UpdatedAt=c):r[e]={Amount:i.toString(),Frozen:"0",CreatedAt:c,UpdatedAt:c},this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyStore(e){this.currentState??={},this.currentState.Store=e??{},this.emitter.emit("user:storeUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchStorePurchase(e,t,s){if(!e||t<1||!this.currentState)return;this.currentState.Store??={},this.currentState.Store.Purchases??={};let r=this.currentState.Store.Purchases,i=r[e];i||(i={OfferID:e,TotalPurchases:0,DailyPurchases:0,DailyResetUtc:"",LastPurchasedAt:""},r[e]=i),i.TotalPurchases+=t,i.LastPurchasedAt=s,s>=i.DailyResetUtc?(i.DailyPurchases=t,i.DailyResetUtc=Yi(s)):i.DailyPurchases+=t,this.emitter.emit("user:storeUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyLootboxPityTriggers(e,t,s){if(!e||s<=0)return;this.currentState??={};let r=this.currentState.Lootbox??={};if(r.Pity??={},t){let i=new Date().toISOString();for(let c of t)c.RuleID&&(r.Pity[`${e}:${c.RuleID}`]={OpensSinceLastTrigger:0,LastTriggeredAtUtc:i});}this.emitter.emit("user:lootboxUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyReward(e){this.currentState??={},this.currentState.Reward=e??{},this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchDailyCalendarState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.DailyCalendars??={},this.currentState.Reward.DailyCalendars[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchIdleAccrualState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.IdleAccruals??={},this.currentState.Reward.IdleAccruals[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchComebackState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.Comebacks??={},this.currentState.Reward.Comebacks[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchClaimRewardState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.Claims??={},this.currentState.Reward.Claims[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyQuest(e){this.currentState??={},this.currentState.Quest=e??{},this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchQuestStatus(e,t,s){if(!e)return;this.currentState??={},this.currentState.Quest??={};let r=this.currentState.Quest;if(t){r.Cycles??={};let i=r.Cycles[t];if(!i)return;i.Quests??={};let c=i.Quests[e]??={QuestID:e,Status:s};c.Status=s,s==="Claimed"&&(c.ClaimedAtUtc??=new Date().toISOString());}else {r.PermanentQuests??={};let i=r.PermanentQuests[e]??={QuestID:e,Status:s};i.Status=s,s==="Claimed"&&(i.ClaimedAtUtc??=new Date().toISOString());}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchMilestoneClaimed(e,t){if(!e||!t)return;let s=this.getQuestPointsProgress(e);s&&(s.Milestone??={},s.Milestone.ClaimedIDs??=[],s.Milestone.ClaimedIDs.includes(t)||s.Milestone.ClaimedIDs.push(t),this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchQuestPointsTracks(e){if(!e)return;this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.Quest??={};let t=this.currentState.EventToken.Quest;for(let s of Object.values(e)){if(!s.CycleID)continue;let r=s.InstanceKey?`${s.CycleID}:${s.InstanceKey}`:s.CycleID,i=t[r]??={};i.Balance??={Current:0,TotalEarned:0,TotalSpent:0},i.Balance.Current=s.PointsCurrent??0,i.Balance.TotalEarned=s.PointsTotalEarned??0,i.Milestone??={},i.Milestone.ClaimedIDs=s.ClaimedPointMilestoneIDs??[];}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchGroupCompletionClaimed(e,t){if(!e||!t)return;this.currentState??={},this.currentState.Quest??={},this.currentState.Quest.Cycles??={};let s=this.currentState.Quest.Cycles[e];s&&(s.ClaimedGroupCompletionIDs??=[],s.ClaimedGroupCompletionIDs.includes(t)||s.ClaimedGroupCompletionIDs.push(t),this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchQuestProgressUpdates(e){if(!e||e.length===0)return;this.currentState??={},this.currentState.Quest??={};let t=this.currentState.Quest;for(let s of e){if(!s.QuestID)continue;let r;if(!s.CycleID)t.PermanentQuests??={},r=t.PermanentQuests[s.QuestID]??={QuestID:s.QuestID,Status:s.Status};else {t.Cycles??={};let i=t.Cycles[s.CycleID];if(!i)continue;i.Quests??={},r=i.Quests[s.QuestID]??={QuestID:s.QuestID,Status:s.Status};}if(r.Status=s.Status,s.ObjectiveID){r.Objectives??={};let i=r.Objectives[s.ObjectiveID]??={ObjectiveID:s.ObjectiveID,CurrentValue:0,Completed:false};i.CurrentValue=s.NewValue??0,s.ObjectiveCompleted&&(i.Completed=true,i.CompletedAtUtc??=new Date().toISOString());}s.Status==="Completed"&&(r.CompletedAtUtc??=new Date().toISOString());}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}getQuestPointsProgress(e){if(!e)return null;let t=this.currentState?.EventToken?.Quest;if(!t)return null;for(let[s,r]of Object.entries(t))if(jr(s,e)&&r)return r;return null}applyActiveEvents(e){this.activeEventsCache=e??{},this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyUserLteState(e){e&&(this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.TimedEvent=e.Tokens??{},this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchTimedEventMilestoneClaimed(e,t,s){if(!(!t||!s)){this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.TimedEvent??={};for(let[r,i]of Object.entries(this.currentState.EventToken.TimedEvent))!jr(r,t)||!i||this.markMilestoneClaimed(i.Milestone??(i.Milestone={}),s);this.patchActiveEventMilestoneClaimed(e,t,s),this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}}patchActiveEventMilestoneClaimed(e,t,s){let r=this.activeEventsCache?.ActiveEvents;if(r)for(let i of r)i.Type!==e||i.TimedEventID!==t||(i.Progress??={},this.markMilestoneClaimed(i.Progress.Milestone??(i.Progress.Milestone={}),s));}markMilestoneClaimed(e,t){if(e.ClaimedIDs??=[],e.ClaimedIDs.includes(t)||e.ClaimedIDs.push(t),e.UnlockedIDs){let s=e.UnlockedIDs.indexOf(t);s>=0&&e.UnlockedIDs.splice(s,1);}}patchLeaderboardMyProgress(e,t){if(!e||!t)return;let s=this.ensureLeaderboardProgress(e);s.CurrentScore=t.CurrentScore??0,s.LastKnownRank=t.LastKnownRank??0,s.ScoreEarnedThisCycle=t.ScoreEarnedThisCycle??0,s.UnclaimedRewardCycleVersion=t.HasUnclaimedReward?Math.max(1,s.UnclaimedRewardCycleVersion??0):0,this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchLeaderboardScoreSubmitted(e,t,s,r){if(!e)return;let i=this.ensureLeaderboardProgress(e);(i.ScoreCycleVersion??0)<r&&(i.ScoreEarnedThisCycle=0,i.ClaimedMilestoneIDs=[],i.BracketID=null),i.CurrentScore=t,i.ScoreEarnedThisCycle=(i.ScoreEarnedThisCycle??0)+s,i.ScoreCycleVersion=r,i.LastScoreSubmitUtc=new Date().toISOString(),this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchLeaderboardCycleRewardClaimed(e){if(!e)return;let t=this.currentState?.Leaderboard?.ProgressByCycle?.[e];t&&(t.UnclaimedRewardCycleVersion=0,this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchLeaderboardMilestoneClaimed(e,t){if(!e||!t)return;let s=this.ensureLeaderboardProgress(e);s.ClaimedMilestoneIDs??=[],s.ClaimedMilestoneIDs.includes(t)||s.ClaimedMilestoneIDs.push(t),this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureLeaderboardProgress(e){this.currentState??={},this.currentState.Leaderboard??={},this.currentState.Leaderboard.ProgressByCycle??={};let t=this.currentState.Leaderboard.ProgressByCycle,s=t[e];return s||(s={CurrentScore:0,ScoreEarnedThisCycle:0,ScoreCycleVersion:0,UnclaimedRewardCycleVersion:0,LastKnownRank:0},t[e]=s),s}applySeasonsState(e){this.currentState??={},this.currentState.Season=e??{},this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSeasonState(e,t){!e||!t||(this.currentState??={},this.currentState.Season??={},this.currentState.Season.States??={},this.currentState.Season.States[e]=t,this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchSeasonCurrentTier(e,t){if(!e)return;let s=this.ensureSeasonState(e);s.CurrentTier=t,this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSeasonClaimedTier(e,t){if(!e)return;let s=this.ensureSeasonState(e);s.ClaimedTierRewards??=[],s.ClaimedTierRewards.includes(t)||s.ClaimedTierRewards.push(t),this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureSeasonState(e){this.currentState??={},this.currentState.Season??={},this.currentState.Season.States??={};let t=this.currentState.Season.States,s=t[e];return s||(s={SeasonChainID:e},t[e]=s),s}applyPremium(e){this.currentState??={},this.currentState.Premium=e??{},this.emitter.emit("user:premiumUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCharacter(e){this.currentState??={},this.currentState.Character??={},this.currentState.Character.Characters=e??{},this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCharacter(e,t){if(!e)return;this.currentState??={},this.currentState.Character??={},this.currentState.Character.Characters??={};let s=this.currentState.Character.Characters,r=s[e];r||(r={CharacterID:e},s[e]=r),t(r),this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCharacterEquipment(e,t,s){if(!e||!t)return;let r=this.currentState?.Character?.Characters?.[e];r&&(r.Equipment??={},s===null?delete r.Equipment[t]:r.Equipment[t]=s,this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyInventoryDelta(e){if(!e)return;this.currentState??={},this.currentState.InventoryV2??={},this.currentState.InventoryV2.UnstackableItems??={};let t=this.currentState.InventoryV2.UnstackableItems,s=false;for(let[r,i]of Object.entries(e.ChangedInstances??{}))t[r]=i,s=true;for(let r of e.RemovedInstanceIDs??[])r in t&&(delete t[r],s=true);s&&(this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyMatch(e){this.currentState??={},this.currentState.Match=e??{},this.emitter.emit("user:matchUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchMatchStrategy(e){e&&(this.currentState??={},this.currentState.Match??={},this.currentState.Match.PvPBattleStrategy=e,this.emitter.emit("user:matchUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyCollection(e){this.currentState??={},this.currentState.Collection=e??{},this.emitter.emit("user:collectionUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCoopEvent(e){this.currentState??={},this.currentState.CoopEvent=e??{MyObjectIndex:-1},this.emitter.emit("user:coopEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCoopEventActiveGroup(e,t,s){this.currentState??={};let r=this.currentState.CoopEvent??={MyObjectIndex:-1};r.ActiveGroupID=e,r.ActiveCoopEventID=t,r.MyObjectIndex=s,this.emitter.emit("user:coopEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyDealOffer(e){this.currentState??={},this.currentState.DealOffer=e??{},this.emitter.emit("user:dealOfferUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyReferral(e){this.currentState??={},this.currentState.Referral=e??{},this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchReferralSubscription(e){e&&(this.currentState??={},this.currentState.Referral??={},this.currentState.Referral.SubscribedToUserID=e,this.currentState.Referral.UpdatedAt=new Date().toISOString(),this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchReferralInviteRewardClaimed(e){e&&(this.currentState??={},this.currentState.Referral??={},this.currentState.Referral.InviteRewardStates??={},this.currentState.Referral.InviteRewardStates[e]={RewardID:e,IsClaimed:true,ClaimedAt:new Date().toISOString()},this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applySocialFriendsList(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.Accepted=(e??[]).map(t=>t.UserID),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applySocialIncomingRequests(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.IncomingRequests=(e??[]).map(t=>t.UserID),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applySocialTimeline(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.Timeline=e??[],this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialAddOutgoingRequest(e){if(!e)return;let t=this.ensureSocial();t.OutgoingRequests??=[],t.OutgoingRequests.includes(e)||t.OutgoingRequests.push(e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialAcceptFriend(e){if(!e)return;let t=this.ensureSocial();t.IncomingRequests=(t.IncomingRequests??[]).filter(s=>s!==e),t.Accepted??=[],t.Accepted.includes(e)||t.Accepted.push(e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialRemoveIncomingRequest(e){if(!e)return;let t=this.ensureSocial();t.IncomingRequests=(t.IncomingRequests??[]).filter(s=>s!==e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialRemoveFriend(e){if(!e)return;let t=this.ensureSocial();t.Accepted=(t.Accepted??[]).filter(s=>s!==e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureSocial(){return this.currentState??={},this.currentState.Social??={},this.currentState.Social}applyTimedBoost(e){this.currentState??={},this.currentState.TimedBoost=e??{},this.emitter.emit("user:timedBoostUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchActiveTimedBoost(e,t){this.currentState??={},this.currentState.TimedBoost??={},this.currentState.TimedBoost.Active??={};let s=this.currentState.TimedBoost.Active;if(t==="Replace"||t==="KeepBest")for(let r of Object.keys(s)){let i=s[r];i&&i.BoostID===e.BoostID&&r!==e.InstanceID&&delete s[r];}s[e.InstanceID]=e,this.emitter.emit("user:timedBoostUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyUserCustomData(e){this.currentState??={},this.currentState.CustomData??={};let t=this.currentState.CustomData;t.Version=e.Version??0,t.Private=e.Private??{},t.Public=e.Public??{},t.ReadOnly=e.ReadOnly??{},this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchUserCustomDataKey(e,t,s,r,i){if(!t)return;this.currentState??={},this.currentState.CustomData??={};let c=this.currentState.CustomData,m={Value:s,UpdatedAt:new Date().toISOString(),Version:r,LastWriter:"Client",ExpiresAt:i??null};if(e==="Private")c.Private??={},c.Private[t]=m;else if(e==="Public")c.Public??={},c.Public[t]=m;else return;c.Version=(c.Version??0)+1,this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}removeUserCustomDataKey(e,t){if(!t||!this.currentState?.CustomData)return;let s=this.currentState.CustomData;if(e==="Private")s.Private&&delete s.Private[t];else if(e==="Public")s.Public&&delete s.Public[t];else return;this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyBoardState(e){this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.Board=e??{},this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCommunityChestUserState(e){this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.CommunityChest=e??{},this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardState(e){let t=this.ensureBoard();e(t),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardBuilding(e,t){if(e<0)return;let s=this.ensureBoard();s.BuildingStates??=[];let r=s.BuildingStates.find(i=>i.SlotIndex===e);r||(r={SlotIndex:e},s.BuildingStates.push(r)),t(r),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardPendingRaidLayout(e,t){let r=this.ensureBoard().Pending;r&&(e&&(r.RaidLayout=e),t>=0&&(r.OpenedIndices??=[],r.OpenedIndices.includes(t)||r.OpenedIndices.push(t)),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchBoardSpecialPending(e){let s=this.ensureBoard().Pending;!s||s.Type.toUpperCase()!=="SPECIAL"||(s.Special??={},e(s.Special),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}clearBoardPending(){let e=this.currentState?.GameLoop?.Board;!e||!e.Pending||(e.Pending=null,this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}ensureBoard(){return this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.Board??={},this.currentState.GameLoop.Board}applyBlockchainState(e,t){this.currentState??={},this.currentState.Blockchain=e??{},t&&(this.currentState.InventoryV2??={},this.currentState.InventoryV2.CryptoCurrencies=t),this.emitter.emit("user:blockchainUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyMarketplaceState(e){this.currentState??={},this.currentState.Marketplace=e??{},this.emitter.emit("user:marketplaceUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}getVirtualCurrencyAmount(e){return this.currentState?.InventoryV2?.VirtualCurrencies?.[e]?.Amount??0}getCryptoCurrencyAmount(e){return this.currentState?.InventoryV2?.CryptoCurrencies?.[e]?.Amount??"0"}};var _t=class{config=null;sections=new Map;itemDefs;currencyDefs;get titlePublicConfiguration(){return this.config}patchSection(e,t){this.sections.set(e,t);}getSection(e){return this.sections.get(e)}applyTitlePublicConfiguration(e){this.config=e&&typeof e=="object"?e:null;}get itemDefinitions(){return this.itemDefs??this.config?.Item??void 0}applyItemDefinitions(e){this.itemDefs=e;}get currencyDefinitions(){return this.currencyDefs??this.config?.Currency??void 0}applyCurrencyDefinitions(e){this.currencyDefs=e;}};var Wt=class{user;config;constructor(e){this.user=new Ft(e),this.config=new _t;}reset(){this.user.clear(),this.config.applyTitlePublicConfiguration(null);}};var Vt=class{constructor(e,t){this.storage=e;this.authTypeKey=`Saved_AuthType_${t}`,this.emailKey=`Saved_Auth_Email_${t}`,this.passwordKey=`Saved_Auth_Password_${t}`;}storage;authTypeKey;emailKey;passwordKey;get lastAuthType(){let e=this.storage.getString(this.authTypeKey);return jl(e)?e:le.None}saveAuthType(e){this.storage.setString(this.authTypeKey,e);}get savedEmail(){return this.storage.getString(this.emailKey)??""}get savedPassword(){return this.storage.getString(this.passwordKey)??""}saveEmailAndPassword(e,t){this.storage.setString(this.emailKey,e),this.storage.setString(this.passwordKey,t);}clear(){this.storage.remove(this.authTypeKey),this.storage.remove(this.emailKey),this.storage.remove(this.passwordKey);}};function jl(u){return u!==null&&Object.values(le).includes(u)}var Fl=8,_l=100,Wl=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i,tn=["GameLoop"],Qt=class{constructor(e){this.ctx=e;}ctx;authContext=null;refreshing=false;rememberSession=true;sessionAuthType=le.None;sessionEmail="";sessionPassword="";get context(){return this.authContext}get isLoggedIn(){return this.authContext!==null&&this.authContext.userID.length>0&&this.authContext.clientSessionTicket.length>0}get lastAuthType(){return this.ctx.authStore.lastAuthType}setRememberSession(e){this.rememberSession=e;}get remembersSession(){return this.rememberSession}baseRequest(){return {BuildKey:this.ctx.settings.buildKey,WebAppLink:this.ctx.platform.getFullURL()}}async loginWithDeviceID(){this.ctx.emitter.emit("auth:requestSent",void 0);let e=this.baseRequest();e.DeviceID=this.ctx.platform.getDeviceID(),e.Device=this.ctx.platform.getDeviceModel(),e.Platform=this.ctx.platform.getPlatform();let t=await this.ctx.api.authentication.loginWithDeviceID(e);return t.ok?(this.applyAuthContext(t.data),this.fetchAndApplyClientState(le.Device)):t}async loginWithTelegram(){this.ctx.emitter.emit("auth:requestSent",void 0);let e=this.ctx.platform.getTelegramInitDataRaw();if(!e)return n("client","Telegram initData is not available.");let t=this.baseRequest();t.TelegramInitData=e;let s=await this.ctx.api.authentication.loginWithTelegram(t);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(le.Telegram)):s}async loginWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let s=this.baseRequest();s.Email=e,s.Password=t;let r=await this.ctx.api.authentication.loginWithEmail(s);if(!r.ok)return r;this.applyAuthContext(r.data);let i=await this.fetchAndApplyClientState(le.Email);return i.ok&&this.keepEmailCredentials(e,t),i}async registerWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let s=this.baseRequest();s.Email=e,s.Password=t,s.DeviceID=this.ctx.platform.getDeviceID(),s.Device=this.ctx.platform.getDeviceModel(),s.Platform=this.ctx.platform.getPlatform();let r=await this.ctx.api.authentication.registerWithEmail(s);if(!r.ok)return r;this.applyAuthContext(r.data);let i=await this.fetchAndApplyClientState(le.Email);return i.ok&&this.keepEmailCredentials(e,t),i}async loginWithGoogle(e){this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.GoogleIDToken=e;let s=await this.ctx.api.authentication.loginWithGoogle(t);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(le.Google)):s}async requestWalletChallenge(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let s=this.baseRequest();return s.WalletAddress=e,s.NetworkID=t,this.ctx.api.authentication.requestWalletChallenge(s)}async loginWithWallet(e,t,s){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();r.WalletAddress=e,r.NetworkID=t,r.WalletSignature=s,r.Platform=this.ctx.platform.getPlatform(),r.Device=this.ctx.platform.getDeviceModel(),r.DeviceID=this.ctx.platform.getDeviceID();let i=await this.ctx.api.authentication.loginWithWallet(r);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(le.Wallet)):i}async loginWithPlatformToken(e){if(!e)return n("client","AuthToken is null or empty.");this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.PlatformAuthToken=e,t.DeviceID=this.ctx.platform.getDeviceID(),t.Device=this.ctx.platform.getDeviceModel(),t.Platform=this.ctx.platform.getPlatform();let s=await this.ctx.api.authentication.loginWithPlatformToken(t);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(le.iDosGames)):s}async forgotPassword(e){this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();return t.Email=e,this.ctx.api.authentication.forgotPassword(t)}async resetPassword(e,t,s){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();return r.Email=e,r.ResetToken=t,r.Password=s,this.ctx.api.authentication.resetPassword(r)}autoLogin(){return this.replay(this.ctx.authStore.lastAuthType,this.ctx.authStore.savedEmail,this.ctx.authStore.savedPassword)}replay(e,t,s){switch(e){case le.Email:return this.loginWithEmail(t,s);case le.Device:case le.None:return this.loginWithDeviceID();case le.Telegram:return this.loginWithTelegram();default:return Promise.resolve(n("client",`Cannot auto-login: last session used "${e}", which requires a fresh token from the platform SDK. Obtain a new token and call the matching login method (e.g. loginWithGoogle) instead of autoLogin().`))}}async refreshSession(){if(this.refreshing)return null;let e=this.sessionAuthType!==le.None?this.sessionAuthType:this.ctx.authStore.lastAuthType;if(e===le.None)return null;this.refreshing=true;try{return (await this.replay(e,this.sessionEmail||this.ctx.authStore.savedEmail,this.sessionPassword||this.ctx.authStore.savedPassword)).ok&&this.authContext?this.authContext.clientSessionTicket:null}catch{return null}finally{this.refreshing=false;}}logout(){this.authContext=null,this.forgetSession(),this.ctx.authStore.clear(),this.ctx.data.reset(),this.ctx.emitter.emit("auth:loggedOut",void 0);}static isValidEmail(e){return e.length>0&&Wl.test(e)}static isValidPasswordLength(e){return e.length>=Fl&&e.length<=_l}keepEmailCredentials(e,t){this.sessionEmail=e,this.sessionPassword=t,this.rememberSession&&this.ctx.authStore.saveEmailAndPassword(e,t);}forgetSession(){this.sessionAuthType=le.None,this.sessionEmail="",this.sessionPassword="";}applyAuthContext(e){this.authContext={userID:e.TitleUserID,clientSessionTicket:e.TitleClientSessionTicket,clientSessionTicketExpiration:e.TitleClientSessionTicketExpiration,platformUserID:e.PlatformUserID??void 0,platformAuthToken:e.PlatformAuthToken??void 0,platformAuthTokenExpiration:e.PlatformAuthTokenExpiration??void 0};}async fetchAndApplyClientState(e){let t=await this.ctx.userService.getClientStateExcept(tn,tn);return t.ok&&(this.sessionAuthType=e,this.rememberSession?this.ctx.authStore.saveAuthType(e):this.ctx.authStore.clear(),this.ctx.emitter.emit("auth:loggedIn",void 0)),t}};var Ht=class{constructor(e){this.ctx=e;}ctx;baseRequest(){let e=this.ctx.auth.context;return e?{UserID:e.userID,ClientSessionTicket:e.clientSessionTicket,BuildKey:this.ctx.settings.buildKey,WebAppLink:this.ctx.platform.getFullURL(),RelatedEntityID:M()}:null}async getClientState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getClientState(e);return t.ok&&this.applyClientState(t.data),t}async getClientStateExcept(e,t){let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.ExcludeFields=e,s.ExcludeTitleFields=t;let r=await this.ctx.api.user.getClientStateExcept(s);return r.ok&&this.applyClientState(r.data,e,t),r}async getUserInventory(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getInventory(e);return t.ok&&(this.ctx.data.user.applyInventory(t.data),this.ctx.emitter.emit("user:inventoryReceived",t.data)),t}async getEventTokens(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getEventTokens(e);return t.ok&&this.ctx.emitter.emit("user:eventTokensReceived",t.data),t}async getUsageTime(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getUsageTime(e);return t.ok&&this.ctx.emitter.emit("user:usageTimeReceived",t.data),t}async addUsageTime(e,t,s){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.UsageTime=e,r.IsNewSession=t,r.SessionDurationSeconds=s;let i=await this.ctx.api.user.addUsageTime(r);return i.ok&&this.ctx.emitter.emit("user:usageTimeAdded",i.data),i}async deleteUserAccount(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.deleteUserAccount(e);return t.ok&&this.ctx.emitter.emit("user:accountDeleted",t.data),t}async changeUsername(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Username=e;let s=await this.ctx.api.user.changeUsername(t);return s.ok&&this.ctx.emitter.emit("user:usernameChanged",s.data),s}applyClientState(e,t,s){let r=t?.includes("GameLoop")===true,i=s?.includes("GameLoop")===true,c=r?this.ctx.data.user.state?.GameLoop:void 0,m=i?this.ctx.data.config.titlePublicConfiguration?.GameLoop:void 0;this.ctx.data.config.applyTitlePublicConfiguration(e.Title),this.ctx.data.user.applyUserState(e.User??{});let v=this.ctx.data.user.state;r&&v&&v.GameLoop==null&&(v.GameLoop=c);let U=this.ctx.data.config.titlePublicConfiguration;i&&U&&U.GameLoop==null&&(U.GameLoop=m),this.ctx.emitter.emit("user:clientStateReceived",e);}};var $t=class{constructor(e){this.ctx=e;}ctx;async convert(e,t,s,r,i,c){if(!t)return n("client","SourceID is required.");if(!r)return n("client","TargetID is required.");if(i<=0)return n("client","Amount must be positive.");if(e===s&&t===r)return n("client","Source and target must differ.");if(e===we.Crypto||s===we.Crypto)return n("client","Convert supports VC\u2194VC only. Use cryptoConvert for crypto.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let m={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:s,TargetID:r,SourceAmount:String(Math.trunc(i)),TransactionID:c&&c.length>0?c:`convert_${e}_${t}_to_${s}_${r}_${M()}`},v=await this.ctx.api.currency.convert(m);if(v.ok){let U=v.data,q={Consume:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:U.SourceID,Amount:U.SourceSpent}]}},Grant:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:U.TargetID,Amount:U.TargetCredited}]}}};this.ctx.data.user.applyResourceOperation(q,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("currency:converted",U);}return v}async cryptoConvert(e,t,s,r,i,c){let m=i instanceof jt__default.default?i:new jt__default.default(i);if(!t)return n("client","SourceID is required.");if(!r)return n("client","TargetID is required.");if(m.lte(0))return n("client","SourceAmount must be a positive decimal.");if(e===s&&t===r)return n("client","Source and target must differ.");if(e===we.Virtual&&s===we.Virtual)return n("client","cryptoConvert requires at least one crypto side. Use convert for VC\u2194VC.");if(e===we.Virtual&&!m.isInteger())return n("client","Virtual currency source amount must be integer.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let v={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:s,TargetID:r,SourceAmount:m.toString(),TransactionID:c&&c.length>0?c:`crypto_convert_${e}_${t}_to_${s}_${r}_${M()}`},U=await this.ctx.api.currency.cryptoConvert(v);if(U.ok){let q=U.data,he=[],ge=[];if(q.SourceType===we.Virtual&&he.push({Type:"VirtualCurrency",CurrencyID:q.SourceID,Amount:Math.trunc(Number(q.SourceSpent))}),q.TargetType===we.Virtual&&ge.push({Type:"VirtualCurrency",CurrencyID:q.TargetID,Amount:Math.trunc(Number(q.TargetCredited))}),he.length>0||ge.length>0){let Ie={Consume:he.length>0?{Standard:{Entries:he}}:null,Grant:ge.length>0?{Standard:{Entries:ge}}:null};this.ctx.data.user.applyResourceOperation(Ie,this.ctx.data.config.itemDefinitions);}q.SourceType===we.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(q.SourceID,new jt__default.default(q.SourceSpent).negated(),q.ServerTimeUtc),q.TargetType===we.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(q.TargetID,new jt__default.default(q.TargetCredited),q.ServerTimeUtc),this.ctx.emitter.emit("currency:cryptoConverted",q);}return U}};var Zt=class{constructor(e){this.ctx=e;}ctx;async upgradeLevel(e,t){let s=e.trim();if(!s)return n("client","ItemInstanceID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),ItemInstanceID:s,RelatedEntityID:`upgrade_item_${s}_${M()}`};t&&t.length>0&&(r.FodderInstanceIDs=[...t]);let i=await this.ctx.api.item.upgradeLevel(r);return i.ok&&(await this.ctx.userService.getUserInventory(),this.ctx.emitter.emit("item:levelUpgraded",i.data)),i}async upgradeLevelsBatch(e){if(!e||e.length===0)return n("client","upgrades is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Upgrades:e},s=await this.ctx.api.item.upgradeLevelsBatch(t);return s.ok&&(await this.ctx.userService.getUserInventory(),this.ctx.emitter.emit("item:levelsUpgradedBatch",s.data)),s}};var Vl="Store",Jt=class{constructor(e){this.ctx=e;}ctx;async purchase(e,t=1){if(!e)return n("client","OfferID is required.");if(t<1)return n("client","Count must be at least 1.");let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),OfferID:e,Count:t,RelatedEntityID:`store_buy_${e}_${s.userID}_${M()}`},i=await this.ctx.api.store.purchase(r);if(i.ok){let c=i.data;this.ctx.data.user.patchStorePurchase(e,t,c.ServerTimeUtc),this.ctx.data.user.applyResourceOperation(c.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("store:offerPurchased",c);}return i}async purchaseBatch(e){if(!e||e.length===0)return n("client","purchases is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Purchases:e},s=await this.ctx.api.store.purchaseBatch(t);if(s.ok){let r=false;for(let i of s.data)!i.Success||!i.Data||!i.Data.OfferID||(this.ctx.data.user.patchStorePurchase(i.Data.OfferID,i.Data.Count,i.Data.ServerTimeUtc),!r&&i.Data.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("store:offersPurchasedBatch",s.data);}return s}async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.store.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Vl,t.data),this.ctx.emitter.emit("store:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.store.getUserState(e);return t.ok&&(this.ctx.data.user.applyStore(t.data),this.ctx.emitter.emit("store:userStateLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ql="Lootbox",Yt=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.lootbox.getDefinitions(e);if(t.ok){let s=t.data.LootboxDefinitions;s&&(this.ctx.data.config.patchSection(Ql,s),this.ctx.emitter.emit("lootbox:definitionsLoaded",s));}return t}async open(e,t,s){if(!e)return n("client","LootboxID is required.");if(t<1)return n("client","Count must be at least 1.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),LootboxID:e,Count:t,SelectedOptionID:s,RelatedEntityID:`lootbox_${e}_${s}_${M()}`},i=await this.ctx.api.lootbox.open(r);if(i.ok){let c=i.data;c.TriggeredPity&&c.TriggeredPity.length>0&&this.ctx.data.user.applyLootboxPityTriggers(e,c.TriggeredPity,t),this.ctx.data.user.applyResourceOperation(c.Resources,this.ctx.data.config.itemDefinitions),this.ctx.data.user.applyInventoryDelta(c.Inventory),this.ctx.emitter.emit("lootbox:opened",c);}return i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Hl="Reward";function _r(u){return u.length>0&&!u.includes(".")&&!u.includes("$")}var Xt=class{constructor(e){this.ctx=e;}ctx;multiplier=1;multiplierEnabled=false;get milestoneRewardMultiplier(){return this.multiplier}get milestoneRewardMultiplierEnabled(){return this.multiplierEnabled}async getRewardDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.reward.getRewardDefinitions(e);if(t.ok){let s=t.data.RewardDefinitions;s&&(this.ctx.data.config.patchSection(Hl,s),this.ctx.emitter.emit("reward:definitionsLoaded",s));}return t}async getUserRewardsState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.reward.getUserRewardsState(e);return t.ok&&t.data.Rewards&&(this.ctx.data.user.applyReward(t.data.Rewards),this.ctx.emitter.emit("reward:userStateLoaded",t.data.Rewards)),t}async getMilestoneRewardMultiplier(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.reward.getMilestoneRewardMultiplier(e);if(t.ok){let s=t.data;this.multiplierEnabled=s.Enabled,this.multiplier=s.Enabled?s.Multiplier??1:1,this.ctx.emitter.emit("reward:milestoneMultiplierLoaded",s);}return t}async claimDailyReward(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CalendarID:e,RelatedEntityID:`dailyreward_${t.userID}_${e??"default"}_${M()}`},r=await this.ctx.api.reward.claimDailyReward(s);if(r.ok){let i=r.data;this.ctx.data.user.patchDailyCalendarState(i.CalendarID,i.DailyState),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:dailyClaimed",i);}return r}async collectIdleAccrual(e){if(!_r(e))return n("client",'AccrualID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),AccrualID:e,RelatedEntityID:`idle_collect_${e}_${M()}`},s=await this.ctx.api.reward.collectIdleAccrual(t);if(s.ok){let r=s.data;this.ctx.data.user.patchIdleAccrualState(r.AccrualID,r.IdleState),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:idleCollected",r);}return s}async claimComebackReward(e){if(!_r(e))return n("client",'ComebackID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),ComebackID:e,RelatedEntityID:`comeback_claim_${e}_${M()}`},s=await this.ctx.api.reward.claimComebackReward(t);if(s.ok){let r=s.data;this.ctx.data.user.patchComebackState(r.ComebackID,r.ComebackState),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:comebackClaimed",r);}return s}async claimReward(e){if(!_r(e))return n("client",'ClaimID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),ClaimID:e,RelatedEntityID:`reward_claim_${e}_${M()}`},s=await this.ctx.api.reward.claimReward(t);if(s.ok){let r=s.data;this.ctx.data.user.patchClaimRewardState(r.ClaimID,r.ClaimState),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:claimed",r);}return s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Kl="Quest",es=class{constructor(e){this.ctx=e;}ctx;async getQuestDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.quest.getQuestDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Kl,t.data),this.ctx.emitter.emit("quest:definitionsLoaded",t.data)),t}async getUserQuestState(e=true){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.AutoRefreshCycles=e;let s=await this.ctx.api.quest.getUserQuestState(t);if(s.ok){let r=s.data.State??{};this.ctx.data.user.applyQuest(r),this.ctx.data.user.patchQuestPointsTracks(s.data.PointsTracks),this.ctx.emitter.emit("quest:userStateLoaded",r);}return s}async refreshQuestCycles(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.quest.refreshQuestCycles(e);return t.ok&&this.ctx.emitter.emit("quest:cyclesRefreshed",void 0),t}async claimQuestReward(e,t){let s=e.trim();if(!s)return n("client","QuestID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r=t&&t.trim().length>0?t.trim():void 0,i={...this.ctx.buildAuthedBaseRequest(),QuestID:s,CycleID:r,RelatedEntityID:`quest_claim_${r??""}_${s}_${M()}`},c=await this.ctx.api.quest.claimQuestReward(i);if(c.ok){let m=c.data;this.ctx.data.user.patchQuestStatus(m.QuestID,m.CycleID,"Claimed"),this.ctx.data.user.applyResourceOperation(m.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:rewardClaimed",m);}return c}async claimQuestRewardsBatch(e){if(!e||e.length===0)return n("client","quests is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Quests:e},s=await this.ctx.api.quest.claimQuestRewardsBatch(t);if(s.ok){let r=false;for(let i of s.data)!i.Success||!i.Data||(this.ctx.data.user.patchQuestStatus(i.Data.QuestID,i.Data.CycleID,"Claimed"),!r&&i.Data.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("quest:rewardsClaimedBatch",s.data);}return s}async claimMilestoneReward(e,t){let s=e.trim(),r=t.trim();if(!s||!r)return n("client","CycleID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CycleID:s,MilestoneID:r,RelatedEntityID:`milestone_claim_${s}_${r}_${M()}`},c=await this.ctx.api.quest.claimMilestoneReward(i);if(c.ok){let m=c.data;this.ctx.data.user.patchMilestoneClaimed(m.CycleID,m.MilestoneID),this.ctx.data.user.applyResourceOperation(m.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:milestoneClaimed",m);}return c}async claimMilestoneRewardsBatch(e){if(!e||e.length===0)return n("client","milestones is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Milestones:e},s=await this.ctx.api.quest.claimMilestoneRewardsBatch(t);if(s.ok){let r=false;for(let i of s.data)!i.Success||!i.Data||(this.ctx.data.user.patchMilestoneClaimed(i.Data.CycleID,i.Data.MilestoneID),!r&&i.Data.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("quest:milestonesClaimedBatch",s.data);}return s}async claimGroupCompletionReward(e,t){let s=e.trim(),r=t.trim();if(!s||!r)return n("client","CycleID and GroupCompletionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CycleID:s,GroupCompletionID:r,RelatedEntityID:`group_completion_${s}_${r}_${M()}`},c=await this.ctx.api.quest.claimGroupCompletionReward(i);if(c.ok){let m=c.data;this.ctx.data.user.patchGroupCompletionClaimed(m.CycleID,m.GroupCompletionID),this.ctx.data.user.applyResourceOperation(m.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:groupCompletionClaimed",m);}return c}async addQuestProgress(e,t){let s=e.trim();if(!s)return n("client","MetricID is required.");if(t<0)return n("client","ProgressValue must be >= 0.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),MetricID:s,ProgressValue:t},i=await this.ctx.api.quest.addQuestProgress(r);return i.ok&&(this.ctx.data.user.patchQuestProgressUpdates(i.data.Updates),this.ctx.emitter.emit("quest:progressAdded",i.data)),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var $l="TimedEvent",ts=class{constructor(e){this.ctx=e;}ctx;async getActiveEvents(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedEvent.getActiveEvents(e);return t.ok&&(this.ctx.data.user.applyActiveEvents(t.data),this.ctx.emitter.emit("timedEvent:activeEventsLoaded",t.data)),t}async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedEvent.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection($l,t.data),this.ctx.emitter.emit("timedEvent:definitionsLoaded",t.data)),t}async getUserLteState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedEvent.getUserLteState(e);return t.ok&&(this.ctx.data.user.applyUserLteState(t.data),this.ctx.emitter.emit("timedEvent:userStateLoaded",t.data)),t}async grantTokens(e,t,s,r,i,c,m=1){if(!t)return n("client","LteID is required.");if(!s)return n("client","SourceType is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let v={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,SourceType:s,Outcome:r,AmountOverride:i,SourceParams:c,RollMultiplier:m},U=await this.ctx.api.timedEvent.grantTokens(v);return U.ok&&(this.ctx.data.user.applyResourceOperation(U.data,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensGranted",U.data)),U}async spendTokens(e,t,s){if(!t)return n("client","LteID is required.");if(s<=0)return n("client","SpendAmount must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,SpendAmount:s},i=await this.ctx.api.timedEvent.spendTokens(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensSpent",i.data)),i}async claimMilestone(e,t,s){if(!t||!s)return n("client","LteID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,MilestoneID:s},i=await this.ctx.api.timedEvent.claimMilestone(r);if(i.ok){let c=i.data;this.ctx.data.user.applyResourceOperation(c.Rewards,this.ctx.data.config.itemDefinitions),this.ctx.data.user.patchTimedEventMilestoneClaimed(e,t,s),this.ctx.emitter.emit("timedEvent:milestoneClaimed",c);}return i}async claimMilestonesBatch(e){if(!e||e.length===0)return n("client","milestones is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Milestones:e},s=await this.ctx.api.timedEvent.claimMilestonesBatch(t);return s.ok&&(this.applyMilestoneClaimBatch(s.data),this.ctx.emitter.emit("timedEvent:milestonesClaimedBatch",s.data)),s}async claimAllMilestones(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&e.length>0&&(t.Events=e);let s=await this.ctx.api.timedEvent.claimAllMilestones(t);return s.ok&&(this.applyMilestoneClaimBatch(s.data),this.ctx.emitter.emit("timedEvent:allMilestonesClaimed",s.data)),s}async spendTokensBatch(e){if(!e||e.length===0)return n("client","spends is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Spends:e},s=await this.ctx.api.timedEvent.spendTokensBatch(t);if(s.ok){let r=false;for(let i of s.data)!r&&i.Success&&i.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("timedEvent:tokensSpentBatch",s.data);}return s}async grantTokensBatch(e){if(!e||e.length===0)return n("client","grants is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Grants:e},s=await this.ctx.api.timedEvent.grantTokensBatch(t);if(s.ok){let r=false;for(let i of s.data)!r&&i.Success&&i.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("timedEvent:tokensGrantedBatch",s.data);}return s}applyMilestoneClaimBatch(e){let t=false;for(let s of e){if(!s.Success||!s.Data)continue;let r=s.Data;r.Type&&r.LteID&&r.MilestoneID&&this.ctx.data.user.patchTimedEventMilestoneClaimed(r.Type,r.LteID,r.MilestoneID),!t&&r.Rewards&&(this.ctx.data.user.applyResourceOperation(r.Rewards,this.ctx.data.config.itemDefinitions),t=true);}}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Zl="Leaderboard",ss=class{constructor(e){this.ctx=e;}ctx;cycleDocID(e){return `${this.ctx.settings.titleID}_${e}`}async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.leaderboard.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Zl,t.data),this.ctx.emitter.emit("leaderboard:definitionsLoaded",t.data)),t}async getLeaderboard(e){if(!e)return n("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardID=e;let s=await this.ctx.api.leaderboard.getLeaderboard(t);return s.ok&&this.ctx.emitter.emit("leaderboard:loaded",s.data),s}async getMyProgress(e){if(!e)return n("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardID=e;let s=await this.ctx.api.leaderboard.getMyProgress(t);return s.ok&&(this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(e),s.data),this.ctx.emitter.emit("leaderboard:myProgressLoaded",s.data)),s}async submitScore(e,t){if(!e)return n("client","LeaderboardID is required.");if(t<=0)return n("client","Score must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,Score:t},r=await this.ctx.api.leaderboard.submitScore(s);if(r.ok){let i=r.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),i.NewScore,t,i.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",i);}return r}async submitScoreFromSource(e,t,s,r,i=1){if(!e)return n("client","LeaderboardID is required.");if(!t)return n("client","SourceType is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let c={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,SourceType:t,Outcome:s,Params:r,RollMultiplier:i},m=await this.ctx.api.leaderboard.submitScoreFromSource(c);if(m.ok){let v=m.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),v.NewScore,v.NewScore,v.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",v);}return m}async claimCycleReward(e){if(!e)return n("client","LeaderboardID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e},s=await this.ctx.api.leaderboard.claimCycleReward(t);if(s.ok){let r=s.data;this.ctx.data.user.patchLeaderboardCycleRewardClaimed(this.cycleDocID(e)),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("leaderboard:cycleRewardClaimed",r);}return s}async claimMilestone(e,t){if(!e||!t)return n("client","LeaderboardID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,MilestoneID:t},r=await this.ctx.api.leaderboard.claimMilestone(s);if(r.ok){let i=r.data;this.ctx.data.user.patchLeaderboardMilestoneClaimed(this.cycleDocID(e),t),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("leaderboard:milestoneClaimed",i);}return r}async getFriendsLeaderboard(e){if(!e)return n("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardID=e;let s=await this.ctx.api.leaderboard.getFriendsLeaderboard(t);return s.ok&&this.ctx.emitter.emit("leaderboard:friendsLoaded",s.data),s}async getLeaderboardsBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardIDs=e;let s=await this.ctx.api.leaderboard.getLeaderboardsBatch(t);return s.ok&&this.ctx.emitter.emit("leaderboard:loadedBatch",s.data),s}async getProgressBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardIDs=e;let s=await this.ctx.api.leaderboard.getProgressBatch(t);if(s.ok){for(let r of s.data)!r.Success||!r.Data||this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(r.Data.LeaderboardID),r.Data);this.ctx.emitter.emit("leaderboard:myProgressLoadedBatch",s.data);}return s}async claimCycleRewardsBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardIDs:e},s=await this.ctx.api.leaderboard.claimCycleRewardsBatch(t);if(s.ok){for(let r of s.data)!r.Success||!r.Data||(this.ctx.data.user.patchLeaderboardCycleRewardClaimed(this.cycleDocID(r.Data.LeaderboardID)),r.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.Data.Resources,this.ctx.data.config.itemDefinitions));this.ctx.emitter.emit("leaderboard:cycleRewardsClaimedBatch",s.data);}return s}async claimMilestonesBatch(e){if(!e||e.length===0)return n("client","milestones is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Milestones:e},s=await this.ctx.api.leaderboard.claimMilestonesBatch(t);if(s.ok){for(let r of s.data)!r.Success||!r.Data||(this.ctx.data.user.patchLeaderboardMilestoneClaimed(this.cycleDocID(r.Data.LeaderboardID),r.Data.MilestoneID),r.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.Data.Resources,this.ctx.data.config.itemDefinitions));this.ctx.emitter.emit("leaderboard:milestonesClaimedBatch",s.data);}return s}async submitScoresBatch(e){if(!e||e.length===0)return n("client","scores is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Scores:e},s=await this.ctx.api.leaderboard.submitScoresBatch(t);if(s.ok){for(let r of s.data)!r.Success||!r.Data||this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(r.Data.LeaderboardID),r.Data.NewScore,r.Data.NewScore,r.Data.CycleVersion);this.ctx.emitter.emit("leaderboard:scoresSubmittedBatch",s.data);}return s}async claimAllRewardsBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardIDs:e},s=await this.ctx.api.leaderboard.claimAllRewardsBatch(t);if(s.ok){for(let r of s.data){let i=this.cycleDocID(r.LeaderboardID);r.CycleReward?.Success&&r.CycleReward.Data&&(this.ctx.data.user.patchLeaderboardCycleRewardClaimed(i),r.CycleReward.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.CycleReward.Data.Resources,this.ctx.data.config.itemDefinitions));for(let c of r.Milestones??[])!c.Success||!c.Data||(this.ctx.data.user.patchLeaderboardMilestoneClaimed(i,c.Data.MilestoneID),c.Data.Resources&&this.ctx.data.user.applyResourceOperation(c.Data.Resources,this.ctx.data.config.itemDefinitions));}this.ctx.emitter.emit("leaderboard:allRewardsClaimedBatch",s.data);}return s}async getOverviewBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardIDs=e;let s=await this.ctx.api.leaderboard.getOverviewBatch(t);if(s.ok){for(let r of s.data)r.Progress?.Success&&r.Progress.Data&&this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(r.LeaderboardID),r.Progress.Data);this.ctx.emitter.emit("leaderboard:overviewLoadedBatch",s.data);}return s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Jl="Season",rs=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.season.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Jl,t.data),this.ctx.emitter.emit("season:definitionsLoaded",t.data)),t}async getActiveSeason(e){if(!e)return n("client","SeasonChainID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.SeasonChainID=e;let s=await this.ctx.api.season.getActiveSeason(t);return s.ok&&(s.data.UserState&&this.ctx.data.user.patchSeasonState(e,s.data.UserState),this.ctx.emitter.emit("season:activeLoaded",s.data)),s}async getUserState(e){if(!e)return n("client","SeasonChainID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.SeasonChainID=e;let s=await this.ctx.api.season.getUserState(t);return s.ok&&(this.ctx.data.user.patchSeasonState(e,s.data),this.ctx.emitter.emit("season:userStateLoaded",s.data)),s}async grantStatusTokens(e,t){if(!e)return n("client","SeasonChainID is required.");if(t<=0)return n("client","Amount must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,Amount:t,RelatedEntityID:`season_grant_${e}_${M()}`},r=await this.ctx.api.season.grantStatusTokens(s);return r.ok&&(this.ctx.data.user.patchSeasonCurrentTier(e,r.data.NewTier),this.ctx.emitter.emit("season:statusTokensGranted",r.data)),r}async claimTierReward(e,t){if(!e)return n("client","SeasonChainID is required.");if(t<=0)return n("client","TierNumber must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,TierNumber:t,RelatedEntityID:`season_tier_${e}_t${t}_${M()}`},r=await this.ctx.api.season.claimTierReward(s);if(r.ok){let i=r.data;this.ctx.data.user.patchSeasonClaimedTier(e,t),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("season:tierRewardClaimed",i);}return r}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Yl="Premium",is=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.premium.getDefinitions(e);return t.ok&&t.data.Premium&&(this.ctx.data.config.patchSection(Yl,t.data.Premium),this.ctx.emitter.emit("premium:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.premium.getUserState(e);return t.ok&&t.data.Premium&&(this.ctx.data.user.applyPremium(t.data.Premium),this.ctx.emitter.emit("premium:stateLoaded",t.data)),t}async activateTrial(e,t){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,RelatedEntityID:`premium_trial_${e}_${t}`},r=await this.ctx.api.premium.activateTrial(s);return r.ok&&(r.data.Premium&&this.ctx.data.user.applyPremium(r.data.Premium),this.ctx.emitter.emit("premium:trialActivated",r.data)),r}async purchaseItemOrCurrency(e,t,s="Default",r=1){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,SelectedOptionID:s,Count:r,RelatedEntityID:`premium_purchase_${e}_${t}`},c=await this.ctx.api.premium.purchaseItemOrCurrency(i);if(c.ok){let m=c.data;m.Premium&&this.ctx.data.user.applyPremium(m.Premium),this.ctx.data.user.applyResourceOperation(m.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:purchaseCompleted",m);}return c}async purchaseRealMoney(e,t,s,r,i,c,m,v){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!r||!i)return n("client","ProductID and ReceiptData are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let U={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,Store:s,ProductID:r,ReceiptData:i,PurchaseToken:c,PackageName:m,AppStoreEnvironment:v,RelatedEntityID:`premium_iap_${e}_${t}`},q=await this.ctx.api.premium.purchaseRealMoney(U);if(q.ok){let he=q.data;he.Premium&&this.ctx.data.user.applyPremium(he.Premium),this.ctx.data.user.applyResourceOperation(he.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:realMoneyPurchaseCompleted",he);}return q}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Xl="Character",ns=class{constructor(e){this.ctx=e;}ctx;async getCharacterDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.character.getCharacterDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Xl,t.data),this.ctx.emitter.emit("character:definitionsLoaded",t.data)),t}async getUserCharacters(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.character.getUserCharacters(e);if(t.ok){let s=t.data.Characters??{};this.ctx.data.user.applyCharacter(s),this.ctx.emitter.emit("character:userCharactersLoaded",s);}return t}async unlockCharacter(e){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,RelatedEntityID:`unlock_char_${e}_${M()}`},s=await this.ctx.api.character.unlockCharacter(t);if(s.ok){let r=s.data;this.ctx.data.user.patchCharacter(r.CharacterID,i=>{i.StatLevels??={},i.Equipment??={},r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=r.ServerTimeUtc;}),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:unlocked",r);}return s}async upgradeStatLevel(e,t,s){if(!e||!t)return n("client","CharacterID and StatID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,StatID:t,RelatedEntityID:`upgrade_stat_${e}_${t}_${M()}`,...s?.levels!=null?{Levels:s.levels}:{},...s?.targetLevel!=null?{TargetLevel:s.targetLevel}:{}},i=await this.ctx.api.character.upgradeStatLevel(r);if(i.ok){let c=i.data;this.ctx.data.user.patchCharacter(c.CharacterID,m=>{m.StatLevels??={},m.StatLevels[c.StatID]=c.StatLevel,c.Power!=null&&(m.Power=c.Power),m.UpdatedAt=c.ServerTimeUtc;}),this.ctx.data.user.applyResourceOperation(c.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:statLevelUpgraded",c);}return i}async upgradeCharacterLevel(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,RelatedEntityID:`upgrade_char_${e}_${M()}`,...t?.levels!=null?{Levels:t.levels}:{},...t?.targetLevel!=null?{TargetLevel:t.targetLevel}:{}},r=await this.ctx.api.character.upgradeCharacterLevel(s);if(r.ok){let i=r.data;this.ctx.data.user.patchCharacter(i.CharacterID,c=>{c.Level=i.NewLevel,i.Power!=null&&(c.Power=i.Power),c.UpdatedAt=i.ServerTimeUtc,i.NewLevel===1&&(c.StatLevels??={},c.Equipment??={});}),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:levelUpgraded",i);}return r}async equipItems(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,ItemsToEquip:t},r=await this.ctx.api.character.equipItems(s);return r.ok&&(this.applyEquipChangesLocally(e,r.data),this.ctx.emitter.emit("character:itemsEquipped",r.data)),r}async unequipItems(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,UnequipSlotIDs:t},r=await this.ctx.api.character.unequipItems(s);if(r.ok){let i=r.data;this.applyUnequipChangesLocally(e,i),this.ctx.emitter.emit("character:itemsUnequipped",{characterID:e,slotIDs:i.ClearedSlotIDs??[],power:i.Power??null});}return r}async unequipAllCharacters(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.character.unequipAllCharacters(e);return t.ok&&(this.applyUnequipAllLocally(t.data),this.ctx.emitter.emit("character:allUnequipped",t.data)),t}async unlockCharactersBatch(e){if(!e||e.length===0)return n("client","characterIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),UnlockCharacterIDs:e},s=await this.ctx.api.character.unlockCharactersBatch(t);return s.ok&&(this.applyBatchResults(s.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,i=>{i.StatLevels??={},i.Equipment??={},r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=r.ServerTimeUtc;});}),this.ctx.emitter.emit("character:charactersUnlocked",s.data)),s}async upgradeCharacterLevelsBatch(e){if(!e||e.length===0)return n("client","upgrades is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LevelUpgrades:e},s=await this.ctx.api.character.upgradeCharacterLevelsBatch(t);return s.ok&&(this.applyBatchResults(s.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,i=>{i.Level=r.NewLevel,r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=r.ServerTimeUtc,r.NewLevel===1&&(i.StatLevels??={},i.Equipment??={});});}),this.ctx.emitter.emit("character:levelsUpgraded",s.data)),s}async upgradeStatLevelsBatch(e){if(!e||e.length===0)return n("client","upgrades is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),StatUpgrades:e},s=await this.ctx.api.character.upgradeStatLevelsBatch(t);return s.ok&&(this.applyBatchResults(s.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,i=>{i.StatLevels??={},i.StatLevels[r.StatID]=r.StatLevel,r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=r.ServerTimeUtc;});}),this.ctx.emitter.emit("character:statLevelsUpgraded",s.data)),s}applyBatchResults(e,t){e.Resources&&this.ctx.data.user.applyResourceOperation(e.Resources,this.ctx.data.config.itemDefinitions);for(let s of e.Items??[])!s.Success||!s.Data||t(s.Data);}applyInventoryDelta(e){this.ctx.data.user.applyInventoryDelta(e);}applyEquipChangesLocally(e,t){let s=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let[r,i]of Object.entries(t.Equipment??{}))s.patchCharacterEquipment(e,r,i);s.patchCharacter(e,r=>{t.Power!=null&&(r.Power=t.Power),r.UpdatedAt=t.ServerTimeUtc;});}applyUnequipChangesLocally(e,t){let s=t.ClearedSlotIDs??[];if(s.length===0&&t.Power==null)return;let r=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let i of s)r.patchCharacterEquipment(e,i,null);r.patchCharacter(e,i=>{t.Power!=null&&(i.Power=t.Power),i.UpdatedAt=t.ServerTimeUtc;});}applyUnequipAllLocally(e){let t=this.ctx.data.user;this.applyInventoryDelta(e.Inventory);for(let[s,r]of Object.entries(e.Characters??{})){for(let i of r.ClearedSlotIDs??[])t.patchCharacterEquipment(s,i,null);t.patchCharacter(s,i=>{r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=e.ServerTimeUtc;});}}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var eu="Match",os=class{constructor(e){this.ctx=e;}ctx;async createMatch(e,t,s,r,i){let c=this.ctx.auth.context;if(!c)return n("unauthorized","Not logged in.");let m={...this.ctx.buildAuthedBaseRequest(),Entry:e,RuleID:t,CharacterID:s,BattleStrategy:r,TargetUserID:i,RelatedEntityID:`pvp_create_${c.userID}_${M()}`},v=await this.ctx.api.match.createMatch(m);return v.ok&&(this.ctx.data.user.applyResourceOperation(v.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:created",v.data)),v}async updateMatch(e,t={}){if(!e)return n("client","MatchID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),MatchID:e,TargetUserID:t.targetUserID,ClearTargetUser:t.clearTargetUser,RuleID:t.ruleID,CharacterID:t.characterID,BattleStrategy:t.battleStrategy},r=await this.ctx.api.match.updateMatch(s);return r.ok&&this.ctx.emitter.emit("match:updated",r.data),r}async cancelMatch(e){if(!e)return n("client","MatchID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),MatchID:e},s=await this.ctx.api.match.cancelMatch(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:cancelled",s.data)),s}async instantBattle(e,t,s,r){let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let c={...this.ctx.buildAuthedBaseRequest(),MatchID:e,RuleID:t,CharacterID:s,BattleStrategy:r,RelatedEntityID:`pvp_battle_${e}_${M()}`},m=await this.ctx.api.match.instantBattle(c);if(m.ok){let v=m.data,U=this.ctx.data.config.itemDefinitions;if(v.Resources)this.ctx.data.user.applyResourceOperation(v.Resources,U);else if(v.ResourcesDual){let q=v.ResourcesDual;q.FromUserID===i.userID&&q.FromResult?this.ctx.data.user.applyResourceOperation(q.FromResult,U):q.ToUserID===i.userID&&q.ToResult&&this.ctx.data.user.applyResourceOperation(q.ToResult,U);}this.ctx.emitter.emit("match:instantBattleCompleted",v);}return m}async saveStrategy(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BattleStrategy:e},s=await this.ctx.api.match.saveStrategy(t);return s.ok&&(this.ctx.data.user.patchMatchStrategy(e),this.ctx.emitter.emit("match:strategySaved",e)),s}async getMyMatches(e=0,t=20,s){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.Statuses=s;let i=await this.ctx.api.match.getMyMatches(r);return i.ok&&this.ctx.emitter.emit("match:myMatchesLoaded",i.data),i}async getAvailableMatches(e=0,t=20,s=false){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.OnlyPublic=s;let i=await this.ctx.api.match.getAvailableMatches(r);return i.ok&&this.ctx.emitter.emit("match:availableMatchesLoaded",i.data),i}async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.match.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(eu,t.data),this.ctx.emitter.emit("match:definitionsLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var tu="Craft",as=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.craft.getDefinitions(e);return t.ok&&t.data.CraftDefinitions&&(this.ctx.data.config.patchSection(tu,t.data.CraftDefinitions),this.ctx.emitter.emit("craft:definitionsLoaded",t.data.CraftDefinitions)),t}async craft(e,t,s=1,r){if(!e)return n("client","CraftID is required.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let c={...this.ctx.buildAuthedBaseRequest(),CraftID:e,InputItemIDs:t,Count:s,SelectedOptionID:r,RelatedEntityID:`craft_${e}_${i.userID}_${M()}`},m=await this.ctx.api.craft.craft(c);return m.ok&&(this.ctx.data.user.applyResourceOperation(m.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("craft:completed",m.data)),m}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var su="Collection",ls=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.collection.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(su,t.data),this.ctx.emitter.emit("collection:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.collection.getUserState(e);return t.ok&&(this.ctx.data.user.applyCollection(t.data),this.ctx.emitter.emit("collection:userStateLoaded",t.data)),t}async openPack(e,t){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,PackTypeID:t,RelatedEntityID:`open_pack_${e}_${t}_${s.userID}_${M()}`},i=await this.ctx.api.collection.openPack(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:packOpened",i.data)),i}async openCollectionChest(e,t){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectionChestID:t,RelatedEntityID:`open_chest_${e}_${t}_${s.userID}_${M()}`},i=await this.ctx.api.collection.openCollectionChest(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:chestOpened",i.data)),i}async useCollectibleJoker(e,t){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:false,RelatedEntityID:`use_joker_${e}_${t}_${s.userID}_${M()}`},i=await this.ctx.api.collection.useCollectibleJoker(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:jokerUsed",i.data)),i}async claimSetReward(e,t){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,SetID:t,RelatedEntityID:`claim_set_${e}_${t}_${s.userID}_${M()}`},i=await this.ctx.api.collection.claimSetReward(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:setRewardClaimed",i.data)),i}async claimSetRewardsBatch(e){if(!e||e.length===0)return n("client","sets is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Sets:e},s=await this.ctx.api.collection.claimSetRewardsBatch(t);if(s.ok){let r=false;for(let i of s.data)!r&&i.Success&&i.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("collection:setRewardsClaimedBatch",s.data);}return s}async claimGrandPrize(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,RelatedEntityID:`grand_prize_${e}_${t.userID}_${M()}`},r=await this.ctx.api.collection.claimGrandPrize(s);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:grandPrizeClaimed",r.data)),r}async sendTradeOffer(e,t,s,r,i,c=false){let m=this.ctx.auth.context;if(!m)return n("unauthorized","Not logged in.");let v={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:s,ReceiverUserID:r,RequestedCollectibleID:i,RequestedCollectibleIsSpecial:c,RelatedEntityID:`trade_send_${m.userID}_${r}_${M()}`},U=await this.ctx.api.collection.sendTradeOffer(v);return U.ok&&this.ctx.emitter.emit("collection:tradeOfferSent",U.data),U}async cancelTradeOffer(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),OfferID:e,RelatedEntityID:`trade_cancel_${e}_${M()}`},s=await this.ctx.api.collection.cancelTradeOffer(t);return s.ok&&this.ctx.emitter.emit("collection:tradeOfferCancelled",s.data),s}async acceptTradeOffer(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),OfferID:e,RelatedEntityID:`trade_accept_${e}_${M()}`},s=await this.ctx.api.collection.acceptTradeOffer(t);return s.ok&&this.ctx.emitter.emit("collection:tradeOfferAccepted",s.data),s}async declineTradeOffer(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),OfferID:e,RelatedEntityID:`trade_decline_${e}_${M()}`},s=await this.ctx.api.collection.declineTradeOffer(t);return s.ok&&this.ctx.emitter.emit("collection:tradeOfferDeclined",s.data),s}async getMyTradeOffers(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CollectionID=e;let s=await this.ctx.api.collection.getMyTradeOffers(t);return s.ok&&this.ctx.emitter.emit("collection:myTradeOffersLoaded",s.data),s}async getIncomingTradeOffers(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CollectionID=e;let s=await this.ctx.api.collection.getIncomingTradeOffers(t);return s.ok&&this.ctx.emitter.emit("collection:incomingTradeOffersLoaded",s.data),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var ru="CoopEvent",us=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.coopEvent.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(ru,t.data),this.ctx.emitter.emit("coopEvent:definitionsLoaded",t.data)),t}async getActiveEvent(e){if(!e)return n("client","CoopChainID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CoopChainID=e;let s=await this.ctx.api.coopEvent.getActiveEvent(t);return s.ok&&this.ctx.emitter.emit("coopEvent:activeEventLoaded",s.data),s}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.coopEvent.getUserState(e);return t.ok&&(this.ctx.data.user.applyCoopEvent(t.data.UserState??null),this.ctx.emitter.emit("coopEvent:userStateLoaded",t.data)),t}async getGroupState(e){if(!e)return n("client","GroupID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.GroupID=e;let s=await this.ctx.api.coopEvent.getGroupState(t);return s.ok&&this.ctx.emitter.emit("coopEvent:groupStateLoaded",s.data),s}async joinOrCreateGroup(e){if(!e)return n("client","CoopChainID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),CoopChainID:e},s=await this.ctx.api.coopEvent.joinOrCreateGroup(t);if(s.ok){let r=s.data.Group;r&&this.ctx.data.user.patchCoopEventActiveGroup(r.GroupID??null,r.CoopEventID??null,-1),this.ctx.emitter.emit("coopEvent:groupJoined",s.data);}return s}async spin(e,t){if(!e||!t)return n("client","CoopChainID and GroupID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CoopChainID:e,GroupID:t,RelatedEntityID:M()},r=await this.ctx.api.coopEvent.spin(s);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("coopEvent:spinCompleted",r.data)),r}async claimObjectReward(e){if(!e)return n("client","GroupID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},s=await this.ctx.api.coopEvent.claimObjectReward(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("coopEvent:objectRewardClaimed",s.data)),s}async claimGrandPrize(e){if(!e)return n("client","GroupID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},s=await this.ctx.api.coopEvent.claimGrandPrize(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:grandPrizeClaimed",s.data)),s}async leaveGroup(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},s=await this.ctx.api.coopEvent.leaveGroup(t);return s.ok&&(this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:groupLeft",s.data)),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var iu="DealOffer",cs=class{constructor(e){this.ctx=e;}ctx;async getDefinition(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.dealOffer.getDefinition(e);return t.ok&&t.data.DealOfferDefinitions&&(this.ctx.data.config.patchSection(iu,t.data.DealOfferDefinitions),this.ctx.emitter.emit("dealOffer:definitionLoaded",t.data.DealOfferDefinitions)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.dealOffer.getUserState(e);return t.ok&&t.data.DealOffers&&(this.ctx.data.user.applyDealOffer(t.data.DealOffers),this.ctx.emitter.emit("dealOffer:userStateLoaded",t.data.DealOffers)),t}async getActiveDeals(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.dealOffer.getActiveDeals(e);return t.ok&&this.ctx.emitter.emit("dealOffer:activeDealsLoaded",t.data),t}async dismissDeal(e){if(!e)return n("client","SlotID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),SlotID:e,RelatedEntityID:`deal_dismiss_${e}_${M()}`},s=await this.ctx.api.dealOffer.dismissDeal(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:dealDismissed",s.data)),s}async executeNode(e,t,s){if(!e||!t)return n("client","SlotID and NodeID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r=s&&s.trim().length>0?s.trim():void 0,i={...this.ctx.buildAuthedBaseRequest(),SlotID:e,NodeID:t,RelatedEntityID:r??`deal_exec_${e}_${t}_${M()}`},c=await this.ctx.api.dealOffer.executeNode(i);return c.ok&&(c.data.Idempotent||this.ctx.data.user.applyResourceOperation(c.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:nodeExecuted",c.data)),c}async recordShow(e){if(!e)return n("client","SlotID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),SlotID:e,RelatedEntityID:`deal_show_${e}_${M()}`},s=await this.ctx.api.dealOffer.recordShow(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:showRecorded",s.data)),s}async claimMilestone(e,t){if(!e||!t)return n("client","SlotID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneID:t,RelatedEntityID:`deal_milestone_${e}_${t}_${M()}`},r=await this.ctx.api.dealOffer.claimMilestone(s);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:milestoneClaimed",r.data)),r}async claimMilestonesBatch(e,t){if(!e)return n("client","SlotID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s=[...new Set(t.map(c=>c.trim()).filter(c=>c.length>0))],r={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneIDs:s,RelatedEntityID:`deal_milestone_batch_${e}_${M()}`},i=await this.ctx.api.dealOffer.claimMilestonesBatch(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:milestonesBatchClaimed",i.data)),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var nu="Referral",ps=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.referral.getDefinitions(e);return t.ok&&t.data.ReferralDefinitions&&(this.ctx.data.config.patchSection(nu,t.data.ReferralDefinitions),this.ctx.emitter.emit("referral:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.referral.getUserState(e);return t.ok&&t.data.Referral&&(this.ctx.data.user.applyReferral(t.data.Referral),this.ctx.emitter.emit("referral:userStateLoaded",t.data)),t}async activateReferralCode(e){let t=e.trim().toUpperCase();if(!t)return n("client","ReferralCode is required.");let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),ReferralCode:t,RelatedEntityID:`referral_activation_${s.userID}`},i=await this.ctx.api.referral.activateReferralCode(r);if(i.ok){let c=i.data;c.ReferralCode&&this.ctx.data.user.patchReferralSubscription(c.ReferralCode),this.ctx.data.user.applyResourceOperation(c.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:codeActivated",c);}return i}async claimInviteReward(e){let t=e.trim();if(!t)return n("client","InviteRewardID is required.");let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),InviteRewardID:t,RelatedEntityID:`referral_invite_${t}_${s.userID}`},i=await this.ctx.api.referral.claimInviteReward(r);if(i.ok){let c=i.data;c.RewardID&&this.ctx.data.user.patchReferralInviteRewardClaimed(c.RewardID),this.ctx.data.user.applyResourceOperation(c.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:inviteRewardClaimed",c);}return i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var ds=class{constructor(e){this.ctx=e;}ctx;async getFriendsList(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getFriendsList(e);return t.ok&&(this.ctx.data.user.applySocialFriendsList(t.data.Friends),this.ctx.emitter.emit("social:friendsListLoaded",t.data)),t}async getIncomingRequests(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getIncomingRequests(e);return t.ok&&(this.ctx.data.user.applySocialIncomingRequests(t.data.Friends),this.ctx.emitter.emit("social:incomingRequestsLoaded",t.data)),t}async getRecommendedFriends(e=5){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Limit=e;let s=await this.ctx.api.social.getRecommendedFriends(t);return s.ok&&this.ctx.emitter.emit("social:recommendedFriendsLoaded",s.data),s}async sendFriendRequest(e){if(!e)return n("client","TargetUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},s=await this.ctx.api.social.sendFriendRequest(t);return s.ok&&(this.ctx.data.user.patchSocialAddOutgoingRequest(e),this.ctx.emitter.emit("social:friendRequestSent",s.data)),s}async acceptFriendRequest(e){if(!e)return n("client","RequesterUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},s=await this.ctx.api.social.acceptFriendRequest(t);return s.ok&&(this.ctx.data.user.patchSocialAcceptFriend(e),this.ctx.emitter.emit("social:friendRequestAccepted",s.data)),s}async declineFriendRequest(e){if(!e)return n("client","RequesterUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},s=await this.ctx.api.social.declineFriendRequest(t);return s.ok&&(this.ctx.data.user.patchSocialRemoveIncomingRequest(e),this.ctx.emitter.emit("social:friendRequestDeclined",s.data)),s}async removeFriend(e){if(!e)return n("client","FriendUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},s=await this.ctx.api.social.removeFriend(t);return s.ok&&(this.ctx.data.user.patchSocialRemoveFriend(e),this.ctx.emitter.emit("social:friendRemoved",s.data)),s}async getTimeline(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getTimeline(e);return t.ok&&(this.ctx.data.user.applySocialTimeline(t.data.Events),this.ctx.emitter.emit("social:timelineLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var ou="TimedBoost";function au(u){return u.length>0&&!u.includes(".")&&!u.includes("$")}var ms=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(ou,t.data),this.ctx.emitter.emit("timedBoost:definitionsLoaded",t.data)),t}async getActive(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.getActive(e);return t.ok&&(this.ctx.data.user.applyTimedBoost({Active:t.data.Active??{}}),this.ctx.emitter.emit("timedBoost:activeLoaded",t.data)),t}async getActiveWindows(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.getActiveWindows(e);return t.ok&&this.ctx.emitter.emit("timedBoost:activeWindowsLoaded",t.data),t}async activate(e){let t=e.trim();if(!au(t))return n("client",'BoostID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),BoostID:t,RelatedEntityID:`timed_boost_activate_${t}_${M()}`},r=await this.ctx.api.timedBoost.activate(s);if(r.ok){let i=r.data;if(i.ActivatedBoost){let c=i.StackingPolicy??"Replace";this.ctx.data.user.patchActiveTimedBoost(i.ActivatedBoost,c);}this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedBoost:activated",i);}return r}async cleanupExpired(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.cleanupExpired(e);return t.ok&&(await this.getActive(),this.ctx.emitter.emit("timedBoost:expiredCleaned",void 0)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ve={Private:"Private",Public:"Public",ReadOnly:"ReadOnly",Internal:"Internal"},lu={Client:"Client",Server:"Server",System:"System"},uu=zod.z.enum(["Client","Server","System"]),cu=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:a.nullish(),Version:zod.z.number().nullish(),LastWriter:uu.nullish(),ExpiresAt:a.nullish()}).passthrough(),hs=zod.z.record(zod.z.string(),cu),sn=zod.z.object({Version:zod.z.number().nullish(),Private:hs.nullish(),Public:hs.nullish(),ReadOnly:hs.nullish()}),Wr=zod.z.object({UserID:zod.z.string().nullish(),Version:zod.z.number().nullish(),Public:hs.nullish()}),Vr=zod.z.object({ServerTimeUtc:a.nullish(),Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:a.nullish()}),pu=zod.z.object({Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:a.nullish()}),rn=zod.z.object({ServerTimeUtc:a.nullish(),Results:zod.z.array(pu).nullish()}),nn=zod.z.object({ServerTimeUtc:a.nullish(),DeletedCount:zod.z.number().nullish()}),on=zod.z.object({Results:zod.z.array(Wr).nullish(),NotFoundUserIDs:zod.z.array(zod.z.string()).nullish()}),du={String:"String",Int:"Int",Bool:"Bool",Json:"Json"},mu=zod.z.enum(["String","Int","Bool","Json"]),hu=zod.z.object({KeyID:zod.z.string(),Bucket:zod.z.string().nullish(),ValueType:mu.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),fs=zod.z.object({Keys:zod.z.record(zod.z.string(),hu).nullish(),DefaultMaxValueLengthBytes:zod.z.number().nullish(),DefaultTtlSeconds:zod.z.number().nullish(),MaxKeysPerBucket:zod.z.number().nullish(),MaxTotalSizeBytes:zod.z.number().nullish(),RejectUnregisteredKeys:zod.z.boolean().nullish()}).passthrough(),Le={GetUserCustomDataDefinitions:"GetUserCustomDataDefinitions",GetMyUserCustomData:"GetMyUserCustomData",GetPublicUserCustomDataOf:"GetPublicUserCustomDataOf",SetPrivateData:"SetPrivateData",SetPublicData:"SetPublicData",DeleteKey:"DeleteKey",BatchSet:"BatchSet",BatchDelete:"BatchDelete",BatchGetPublicUserCustomDataOf:"BatchGetPublicUserCustomDataOf"};var fu="UserCustomData";function an(u){return u.length>0&&!u.includes(".")&&!u.includes("$")}var gs=class{constructor(e){this.ctx=e;}ctx;async getUserCustomDataDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.userCustomData.getUserCustomDataDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(fu,t.data),this.ctx.emitter.emit("userCustomData:definitionsLoaded",t.data)),t}async getMyUserCustomData(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.userCustomData.getMyUserCustomData(e);return t.ok&&(this.ctx.data.user.applyUserCustomData(t.data),this.ctx.emitter.emit("userCustomData:myDataLoaded",t.data)),t}async getPublicUserCustomDataOf(e){let t=e.trim();if(!t)return n("client","TargetUserID is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.TargetUserID=t;let r=await this.ctx.api.userCustomData.getPublicUserCustomDataOf(s);return r.ok&&this.ctx.emitter.emit("userCustomData:publicDataLoaded",r.data),r}async setPrivateData(e,t){return this.setData(e,t,Ve.Private)}async setPublicData(e,t){return this.setData(e,t,Ve.Public)}async setData(e,t,s){let r=e.trim();if(!an(r))return n("client",'KeyID is required and must not contain "." or "$".');if(t==null)return n("client","Value is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),KeyID:r,Value:t},m=await(s===Ve.Private?this.ctx.api.userCustomData.setPrivateData(i):this.ctx.api.userCustomData.setPublicData(i));if(m.ok){let v=m.data;this.ctx.data.user.patchUserCustomDataKey(s,v.KeyID,t,v.Version??0,v.ExpiresAt),this.ctx.emitter.emit(s===Ve.Private?"userCustomData:privateDataSet":"userCustomData:publicDataSet",v);}return m}async deleteKey(e,t){let s=e.trim();if(!an(s))return n("client",'KeyID is required and must not contain "." or "$".');if(t!==Ve.Private&&t!==Ve.Public)return n("client","Only Private or Public keys can be deleted.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),KeyID:s,Bucket:t},i=await this.ctx.api.userCustomData.deleteKey(r);return i.ok&&(this.ctx.data.user.removeUserCustomDataKey(t,s),this.ctx.emitter.emit("userCustomData:keyDeleted",void 0)),i}async batchSet(e){if(!e.length)return n("client","At least one item is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BatchSetItems:e},s=await this.ctx.api.userCustomData.batchSet(t);if(s.ok){for(let r of s.data.Results??[]){let i=r.Bucket??Ve.Private,c=e.find(m=>m.Bucket===i&&m.KeyID===r.KeyID);c&&this.ctx.data.user.patchUserCustomDataKey(i,r.KeyID,c.Value,r.Version??0,r.ExpiresAt);}this.ctx.emitter.emit("userCustomData:batchSet",s.data);}return s}async batchDelete(e){if(!e.length)return n("client","At least one item is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BatchDeleteItems:e},s=await this.ctx.api.userCustomData.batchDelete(t);if(s.ok){for(let r of e)this.ctx.data.user.removeUserCustomDataKey(r.Bucket,r.KeyID.trim());this.ctx.emitter.emit("userCustomData:batchDeleted",s.data);}return s}async batchGetPublicUserCustomDataOf(e){if(!e.length)return n("client","At least one target user id is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.TargetUserIDs=e;let s=await this.ctx.api.userCustomData.batchGetPublicUserCustomDataOf(t);return s.ok&&this.ctx.emitter.emit("userCustomData:batchPublicDataLoaded",s.data),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var gu="TitleCustomDataDefinitions",ln=50;function Ru(u){return u.length>0&&!u.includes(".")&&!u.includes("$")}function Qr(u){if(u.ExpiresAt==null)return false;let e=Date.parse(u.ExpiresAt);return !Number.isNaN(e)&&e<=Date.now()}function yu(u){let e={};for(let[t,s]of Object.entries(u))Qr(s)||(e[t]=s);return e}var Rs=class{constructor(e){this.ctx=e;}ctx;lastRuntimeVersion=null;runtimeCache={};async getTitleCustomDataDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.titleCustomData.getTitleCustomDataDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(gu,t.data),this.ctx.emitter.emit("titleCustomData:definitionsLoaded",t.data)),t}async getPublicTitleData(e=true){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&this.lastRuntimeVersion!=null&&(t.KnownRuntimeVersion=this.lastRuntimeVersion);let s=await this.ctx.api.titleCustomData.getPublicTitleData(t);return s.ok&&this.absorb(s.data),s}async getPublicTitleDataKeys(e){let t=e.map(i=>i.trim()).filter(i=>i.length>0);if(!t.length)return n("client","At least one KeyID is required.");if(t.some(i=>!Ru(i)))return n("client",'KeyID must not contain "." or "$".');if(t.length>ln)return n("client",`At most ${ln} keys per call \u2014 request them in chunks.`);let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.KeyIDs=t;let r=await this.ctx.api.titleCustomData.getPublicTitleDataKeys(s);return r.ok&&this.ctx.emitter.emit("titleCustomData:publicDataLoaded",r.data),r}getValue(e){let t=this.runtimeCache[e];if(t?.Value!=null&&!Qr(t))return t.Value;let s=this.staticCache[e];if(s?.Value!=null&&!Qr(s))return s.Value}get runtimeVersion(){return this.lastRuntimeVersion}staticCache={};absorb(e){e.Static&&(this.staticCache=e.Static),e.NotModified?(this.runtimeCache=yu(this.runtimeCache),e.Runtime=this.runtimeCache):e.Runtime&&(this.runtimeCache=e.Runtime),e.RuntimeVersion!=null&&(this.lastRuntimeVersion=e.RuntimeVersion),this.ctx.emitter.emit("titleCustomData:publicDataLoaded",e);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var ys=class{constructor(e){this.ctx=e;}ctx;async getTitlePublicConfiguration(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.title.getTitlePublicConfiguration(e);return t.ok&&(this.ctx.data.config.applyTitlePublicConfiguration(t.data),this.ctx.emitter.emit("title:publicConfigurationReceived",t.data)),t}async getCurrencyDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.title.getCurrencyDefinitions(e);return t.ok&&(this.ctx.data.config.applyCurrencyDefinitions(t.data),this.ctx.emitter.emit("title:currencyDefinitionsReceived",t.data)),t}async getItemDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.title.getItemDefinitions(e);return t.ok&&(this.ctx.data.config.applyItemDefinitions(t.data),this.ctx.emitter.emit("title:itemDefinitionsReceived",t.data)),t}async getServerTime(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.title.getServerTime(e);return t.ok&&this.ctx.emitter.emit("title:serverTimeReceived",t.data),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Cu=15,Su="GameLoop",xu="BoardDefinition",Cs=class{constructor(e){this.ctx=e;}ctx;get itemDefs(){return this.ctx.data.config.itemDefinitions}async getGameLoops(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.gameLoop.getGameLoops(e);return t.ok&&(this.ctx.data.config.patchSection(Su,t.data),this.ctx.emitter.emit("gameLoop:gameLoopsLoaded",t.data)),t}async getBoardDefinition(e=false){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");let s=await this.ctx.api.gameLoop.getBoardDefinition(t,e);return s.ok&&(this.ctx.data.config.patchSection(xu,s.data),this.ctx.emitter.emit("gameLoop:boardDefinitionLoaded",s.data)),s}async getBoardDefinitionForLevel(e,t=false){if(e<=0)return n("client","stageLevel must be > 0.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.StageLevel=e;let r=await this.ctx.api.gameLoop.getBoardDefinitionForLevel(s,t);return r.ok&&this.ctx.emitter.emit("gameLoop:boardDefinitionForLevelLoaded",r.data),r}async getUserBoardState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.gameLoop.getUserBoardState(e);return t.ok&&(this.ctx.data.user.applyBoardState(t.data),this.ctx.emitter.emit("gameLoop:boardStateLoaded",t.data)),t}async boardLoopRoll(e=1){if(e<1)return n("client","rollMultiplier must be >= 1.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),RollMultiplier:e,RelatedEntityID:`roll_${t.userID}_${M()}`},r=await this.ctx.api.gameLoop.boardLoopRoll(s);if(r.ok){let i=r.data,c=Xi(new Date,Cu);this.ctx.data.user.patchBoardState(m=>{m.Position=i.NewPosition,m.CyclesCompleted=(m.CyclesCompleted??0)+(i.CyclesCompletedDelta??0),m.LastRollAtUtc=new Date().toISOString(),i.ActionRequired&&i.ActionData?m.Pending={Type:i.ActionRequired,TargetUserID:i.ActionData.TargetUserID,TargetPublicData:i.ActionData.PublicData,TargetBuildingStates:i.ActionData.TargetBuildingStates??void 0,TargetHasShield:i.ActionData.TargetHasShield??void 0,RollMultiplier:i.UsedMultiplier??1,ExpiresAtUtc:c}:i.SpecialModeOffer&&(m.Pending={Type:"SPECIAL",RollMultiplier:i.UsedMultiplier??1,ExpiresAtUtc:c,Special:{ModeID:i.SpecialModeOffer.ModeID??void 0,Choices:i.SpecialModeOffer.Choices??void 0}});}),i.Operation&&this.ctx.data.user.applyResourceOperation(i.Operation,this.itemDefs),i.ActionRequired==="RAID"&&await this.getUserBoardState(),this.ctx.emitter.emit("gameLoop:boardRolled",i);}return r}async boardLoopAttack(e=-1){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`attack_${t.userID}_${M()}`},r=await this.ctx.api.gameLoop.boardLoopAttack(s);if(r.ok){let i=r.data;this.ctx.data.user.clearBoardPending(),i.IsBotTarget&&i.Operation?this.ctx.data.user.applyResourceOperation(i.Operation,this.itemDefs):!i.IsBotTarget&&i.DualResult?.FromResult&&this.ctx.data.user.applyResourceOperation(i.DualResult.FromResult,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardAttacked",i);}else await this.getUserBoardState();return r}async boardLoopRaid(e,t){if(e<0||e>11)return n("client","digIndex must be between 0 and 11.");let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),DigIndex:e,RelatedEntityID:t??`raid_${s.userID}_${M()}`},i=await this.ctx.api.gameLoop.boardLoopRaid(r);if(i.ok){let c=i.data;c.Status==="CONTINUE"?this.ctx.data.user.patchBoardPendingRaidLayout(c.RaidLayout,c.OpenedIndex??-1):(this.ctx.data.user.clearBoardPending(),this.applyRaidResources(c)),this.ctx.emitter.emit("gameLoop:boardRaided",c);}else await this.getUserBoardState();return i}async boardLoopRaidFast(e){if(!e.length)return n("client","digIndices must not be empty.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),DigIndices:e,RelatedEntityID:`raidfast_${t.userID}_${M()}`},r=await this.ctx.api.gameLoop.boardLoopRaidFast(s);if(r.ok){let i=r.data;i.Status!=="CONTINUE"&&(this.ctx.data.user.clearBoardPending(),this.applyRaidResources(i)),this.ctx.emitter.emit("gameLoop:boardRaidedFast",i);}else await this.getUserBoardState();return r}async boardLoopBuild(e){if(e<0)return n("client","buildingIndex must be >= 0.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`build_${t.userID}_${e}_${M()}`},r=await this.ctx.api.gameLoop.boardLoopBuild(s);if(r.ok){let i=r.data;i.StageComplete?this.ctx.data.user.patchBoardState(c=>{c.StageLevel=(c.StageLevel??1)+1,c.Position=0,c.Pending=null,c.BuildingStates=null;}):this.ctx.data.user.patchBoardBuilding(i.BuiltIndex,c=>{i.NewLevel!=null&&(c.Level=i.NewLevel),c.IsDamaged=false,i.MaxLevelRewardClaimed&&(c.MaxLevelRewardClaimed=true);}),i.Operation&&this.ctx.data.user.applyResourceOperation(i.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardBuilt",i);}return r}async boardSpecialChoose(e){if(!e)return n("client","choiceID must not be empty.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),ChoiceID:e,RelatedEntityID:`special_choose_${t.userID}_${M()}`},r=await this.ctx.api.gameLoop.boardSpecialChoose(s);if(r.ok){let i=r.data;i.Mode==="Instant"||i.Mode===0?this.ctx.data.user.clearBoardPending():this.ctx.data.user.patchBoardSpecialPending(m=>{m.ChoiceID=e,m.ChosenMode=i.Mode??"Timed",m.StartedAtUtc=i.StartedAtUtc??null,m.DurationSeconds=i.DurationSeconds??null,m.AdViewsUsed=0;}),i.Operation&&this.ctx.data.user.applyResourceOperation(i.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialChose",i);}return r}async boardSpecialApplyMultiplier(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:e??`special_ad_${t.userID}_${M()}`},r=await this.ctx.api.gameLoop.boardSpecialApplyMultiplier(s);if(r.ok){let i=r.data;this.ctx.data.user.patchBoardSpecialPending(c=>{c.AdViewsUsed=i.AdViewsUsed??0,c.AccumulatedMultiplier=i.AccumulatedMultiplier??0;}),this.ctx.emitter.emit("gameLoop:boardSpecialApplyMultiplier",i);}return r}async boardSpecialClaim(){let e=this.ctx.auth.context;if(!e)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:`special_claim_${e.userID}_${M()}`},s=await this.ctx.api.gameLoop.boardSpecialClaim(t);if(s.ok){let r=s.data;this.ctx.data.user.clearBoardPending(),r.Operation&&this.ctx.data.user.applyResourceOperation(r.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialClaimed",r);}return s}async getCommunityChestState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.gameLoop.getCommunityChestState(e);return t.ok&&(this.ctx.data.user.applyCommunityChestUserState(t.data.UserState??null),this.ctx.emitter.emit("gameLoop:communityChestStateLoaded",t.data)),t}async joinOrCreateCommunityChest(){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let e={...this.ctx.buildAuthedBaseRequest()},t=await this.ctx.api.gameLoop.joinOrCreateCommunityChest(e);if(t.ok){let s=t.data.Group;s?.GroupID&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:s.GroupID,ActiveRoundIndex:s.RoundIndex??void 0}),this.ctx.emitter.emit("gameLoop:communityChestJoined",t.data);}return t}async claimCommunityChestMilestone(e,t){if(!e)return n("client","milestoneID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),MilestoneID:e,GroupID:t},r=await this.ctx.api.gameLoop.claimCommunityChestMilestone(s);return r.ok&&(r.data.Resources&&this.ctx.data.user.applyResourceOperation(r.data.Resources,this.itemDefs),this.ctx.emitter.emit("gameLoop:communityChestMilestoneClaimed",r.data)),r}async claimCommunityChestGrandPrize(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},s=await this.ctx.api.gameLoop.claimCommunityChestGrandPrize(t);return s.ok&&(s.data.Resources&&this.ctx.data.user.applyResourceOperation(s.data.Resources,this.itemDefs),this.ctx.emitter.emit("gameLoop:communityChestGrandPrizeClaimed",s.data)),s}async leaveCommunityChest(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},s=await this.ctx.api.gameLoop.leaveCommunityChest(t);return s.ok&&(s.data.Success&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:void 0,ActiveRoundIndex:-1}),this.ctx.emitter.emit("gameLoop:communityChestLeft",s.data)),s}applyRaidResources(e){e.Operation?this.ctx.data.user.applyResourceOperation(e.Operation,this.itemDefs):e.DualResult?.FromResult&&this.ctx.data.user.applyResourceOperation(e.DualResult.FromResult,this.itemDefs);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ss=class{constructor(e){this.ctx=e;}ctx;async execute(e,t,s,r){let i=e.trim();if(!i)return n("client","FunctionName is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let c={...this.ctx.buildAuthedBaseRequest(),FunctionName:i,FunctionParameter:t,RevisionSelection:s,SpecificRevision:r},m=await this.ctx.api.cloudCode.execute(c);return m.ok&&this.ctx.emitter.emit("cloudCode:executed",m.data),m}};var un=zod.z.object({ServerTimeUtc:a,SourceType:pt,SourceID:zod.z.string(),TargetType:pt,TargetID:zod.z.string(),SourceSpent:k,FeeAmount:k,RateApplied:w,TargetCredited:k}),cn=zod.z.object({ServerTimeUtc:a,SourceType:pt,SourceID:zod.z.string(),TargetType:pt,TargetID:zod.z.string(),SourceSpent:w,FeeAmount:w,RateApplied:w,TargetCredited:w}),xs={Convert:"Convert",CryptoConvert:"CryptoConvert"},Du={Active:"Active",Hidden:"Hidden",Deprecated:"Deprecated",Maintenance:"Maintenance"},pn=zod.z.enum(["Active","Hidden","Deprecated","Maintenance"]),bu={Automatic:"Automatic",Manual:"Manual"},zu=zod.z.enum(["Automatic","Manual"]),vu=zod.z.object({ValueInUSD:w.nullish(),ValueInUSDUpdatedAt:a.nullish(),InitialDeposit:zod.z.number().nullish(),MinBalance:zod.z.number().nullish(),MaxBalance:zod.z.number().nullish(),DailyEarnLimit:zod.z.number().nullish(),DailySpendLimit:zod.z.number().nullish()}).passthrough(),Tu=zod.z.object({Rate:zod.z.number().nullish(),Max:zod.z.number().nullish(),Period:zod.z.number().nullish()}).passthrough(),Pu=zod.z.object({IsTradable:zod.z.boolean().nullish(),IsPurchasable:zod.z.boolean().nullish(),IsRefundable:zod.z.boolean().nullish()}).passthrough(),Iu=zod.z.object({TargetCurrencyType:pt.nullish(),TargetCurrencyID:zod.z.string(),Rate:w.nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish(),DailyLimit:zod.z.number().nullish()}).passthrough(),dn=zod.z.object({Enabled:zod.z.boolean().nullish(),RateMode:zu.nullish(),FeePercent:w.nullish(),Targets:zod.z.array(Iu).nullish()}).passthrough(),mn=zod.z.object({CreatedAt:a.nullish(),UpdatedAt:a.nullish()}).passthrough(),Mu=zod.z.object({CurrencyID:zod.z.string(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Economy:vu.nullish(),Recharge:Tu.nullish(),Conversion:dn.nullish(),Permissions:Pu.nullish(),Audit:mn.nullish(),Status:pn.nullish()}).passthrough(),ku=zod.z.object({NetworkID:zod.z.string(),ContractAddress:zod.z.string().nullish(),Decimals:zod.z.number().nullish(),MinDeposit:w.nullish(),MinWithdraw:w.nullish(),WithdrawFee:w.nullish(),DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish()}).passthrough(),Au=zod.z.object({DailyWithdrawUsd:w.nullish(),MonthlyWithdrawUsd:w.nullish(),KycRequiredAboveUsd:w.nullish()}).passthrough(),Ou=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),SpendableInGame:zod.z.boolean().nullish(),ConvertibleToVirtual:zod.z.boolean().nullish()}).passthrough(),Hr=zod.z.object({CurrencyID:zod.z.string(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),DisplayDecimals:zod.z.number().nullish(),ValueInUSD:w.nullish(),ValueInUSDUpdatedAt:a.nullish(),DeveloperDepositSharePercent:w.nullish(),CommunityMarketingDepositSharePercent:w.nullish(),WithdrawalBurnPercent:w.nullish(),Networks:zod.z.array(ku).nullish(),Limits:Au.nullish(),Permissions:Ou.nullish(),Conversion:dn.nullish(),Audit:mn.nullish(),Status:pn.nullish()}).passthrough(),Ds=zod.z.object({VirtualCurrencies:zod.z.record(zod.z.string(),Mu).nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Hr).nullish()}).passthrough();var hn=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),ItemInstanceID:zod.z.string().nullish(),EquippedAt:a.nullish()}),Kr=zod.z.object({CharacterID:zod.z.string(),Level:zod.z.number().nullish(),Experience:k.nullish(),Power:zod.z.number().nullish(),StatLevels:zod.z.record(zod.z.string(),zod.z.number()).nullish(),Equipment:zod.z.record(zod.z.string(),hn).nullish(),UpdatedAt:a.nullish()}).passthrough(),Bu=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),Uu=zod.z.object({ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Quantity:zod.z.number().nullish(),RemainingUses:zod.z.number().nullish(),Level:zod.z.number().nullish(),AcquiredAt:a,ExpiresAt:a.nullish(),EquippedSlot:Bu.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(u=>u),Xe=zod.z.object({ChangedInstances:zod.z.record(zod.z.string(),Uu).nullish(),RemovedInstanceIDs:zod.z.array(zod.z.string()).nullish()}),fn=zod.z.object({Characters:zod.z.record(zod.z.string(),Kr).nullish()}),$r=zod.z.object({ServerTimeUtc:a,CharacterID:zod.z.string(),StatID:zod.z.string(),StatLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:x.nullish()}),Zr=zod.z.object({ServerTimeUtc:a,CharacterID:zod.z.string(),NewLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:x.nullish()}),gn=zod.z.object({ServerTimeUtc:a,CharacterID:zod.z.string(),Equipment:zod.z.record(zod.z.string(),hn).nullish(),ReplacedInstanceIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:Xe.nullish()}),Rn=zod.z.object({ServerTimeUtc:a,CharacterID:zod.z.string(),ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:Xe.nullish()}),wu=zod.z.object({ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish()}),yn=zod.z.object({ServerTimeUtc:a,Characters:zod.z.record(zod.z.string(),wu).nullish(),Inventory:Xe.nullish()}),Jr=zod.z.object({ServerTimeUtc:a,CharacterID:zod.z.string(),Power:zod.z.number().nullish(),Resources:x.nullish()}),Cn=qt(Jr),Sn=qt(Zr),xn=qt($r),Dn=zod.z.object({RequiredStatID:zod.z.string(),RequiredLevel:zod.z.number()}).passthrough(),bn=zod.z.object({StatID:zod.z.string(),TypeID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),MaxLevel:zod.z.number().nullish(),Weight:zod.z.number().nullish(),BaseCostResource:H.nullish(),CostScalingFactor:zod.z.number().nullish(),BaseStatValue:zod.z.number().nullish(),StatScalingFactor:zod.z.number().nullish(),CharacterLevelScalingFactor:zod.z.number().nullish(),Requirements:zod.z.array(Dn).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),zn=zod.z.object({Level:zod.z.number().nullish(),UpgradeCost:H.nullish(),GlobalStatMultiplier:zod.z.number().nullish(),StatMaxLevelMultiplier:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),qu=zod.z.object({SlotID:zod.z.string(),MinCharacterLevel:zod.z.number().nullish(),StatRequirements:zod.z.array(Dn).nullish(),AllowedRarityIDs:zod.z.array(zod.z.string()).nullish(),AllowedItemTags:zod.z.array(zod.z.string()).nullish(),MinItemLevel:zod.z.number().nullish(),MaxItemLevel:zod.z.number().nullish()}).passthrough(),vn=zod.z.object({Slots:zod.z.record(zod.z.string(),qu).nullish()}).passthrough(),Eu=zod.z.object({DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Lore:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Lu=zod.z.object({ClassID:zod.z.string().nullish(),RarityID:zod.z.string().nullish(),Tags:zod.z.array(zod.z.string()).nullish()}).passthrough(),Gu=zod.z.object({UnlockedByDefault:zod.z.boolean().nullish(),Cost:H.nullish()}).passthrough(),Nu=zod.z.object({Stats:pe.nullish(),Levels:pe.nullish(),Equipment:pe.nullish()}).passthrough(),ju=zod.z.object({CharacterID:zod.z.string(),Identity:Eu.nullish(),Classification:Lu.nullish(),Unlock:Gu.nullish(),Presets:Nu.nullish(),Equipment:vn.nullish(),Stats:zod.z.record(zod.z.string(),bn).nullish(),Levels:zod.z.record(zod.z.string(),zn).nullish()}).passthrough(),Fu=zod.z.object({Stats:zod.z.record(zod.z.string(),bn).nullish()}).passthrough(),_u=zod.z.object({Levels:zod.z.record(zod.z.string(),zn).nullish()}).passthrough(),Wu=zod.z.object({Equipment:vn.nullish()}).passthrough(),Vu=zod.z.object({Stats:zod.z.record(zod.z.string(),Fu).nullish(),Levels:zod.z.record(zod.z.string(),_u).nullish(),Equipment:zod.z.record(zod.z.string(),Wu).nullish()}).passthrough(),bs=zod.z.object({Definitions:zod.z.record(zod.z.string(),ju).nullish(),Presets:Vu.nullish()}).passthrough(),Te={GetCharacterDefinitions:"GetCharacterDefinitions",GetUserCharacters:"GetUserCharacters",UnlockCharacter:"UnlockCharacter",UpgradeStatLevel:"UpgradeStatLevel",UpgradeCharacterLevel:"UpgradeCharacterLevel",EquipItems:"EquipItems",UnequipItems:"UnequipItems",UnequipAllCharacters:"UnequipAllCharacters",UnlockCharactersBatch:"UnlockCharactersBatch",UpgradeCharacterLevelsBatch:"UpgradeCharacterLevelsBatch",UpgradeStatLevelsBatch:"UpgradeStatLevelsBatch"};var Qu={EVM:"EVM",Solana:"Solana"},Hu=zod.z.enum(["EVM","Solana"]),Ku={AutoLinkedFromTransaction:"AutoLinkedFromTransaction",SignatureVerified:"SignatureVerified",ManuallyLinked:"ManuallyLinked"},$u=zod.z.enum(["AutoLinkedFromTransaction","SignatureVerified","ManuallyLinked"]),Zu={Token:"Token",Nft:"Nft"},Tn=zod.z.enum(["Token","Nft"]),Ju={NotRequested:"NotRequested",Pending:"Pending",Verified:"Verified",Rejected:"Rejected",Expired:"Expired"},Yu=zod.z.enum(["NotRequested","Pending","Verified","Rejected","Expired"]),Xu={None:"None",Tier1:"Tier1",Tier2:"Tier2",Tier3:"Tier3"},ec=zod.z.enum(["None","Tier1","Tier2","Tier3"]),tc={Pending:"Pending",Completed:"Completed",Failed:"Failed",Expired:"Expired",Abandoned:"Abandoned"},Yr=zod.z.enum(["Pending","Completed","Failed","Expired","Abandoned"]),Pn={GameTopUp:"game_topup",CommunityReward:"community_reward"};function zs(u){let e=u?.trim();return e||Pn.GameTopUp}var sc={UsersCryptoWallet:"UsersCryptoWallet",Game:"Game"},In=zod.z.enum(["UsersCryptoWallet","Game"]),rc=zod.z.object({ContractAddress:zod.z.string().nullish(),ItemCatalogID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish()}).passthrough(),Mn=zod.z.object({Ios:zod.z.boolean().nullish(),Android:zod.z.boolean().nullish(),Web:zod.z.boolean().nullish()}).passthrough(),ic=zod.z.object({NetworkID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Type:Hu.nullish(),ChainID:zod.z.number().nullish(),ChainTicker:zod.z.string().nullish(),RewardPoolAddress:zod.z.string().nullish(),VaultDepositAddress:zod.z.string().nullish(),ChainConfigVersion:zod.z.number().nullish(),RequiredConfirmations:zod.z.number().nullish(),DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),NftDepositsEnabled:zod.z.boolean().nullish(),NftWithdrawalsEnabled:zod.z.boolean().nullish(),PlatformOverrides:Mn.nullish(),NftCollections:zod.z.array(rc).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),nc=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),NftDepositsEnabled:zod.z.boolean().nullish(),NftWithdrawalsEnabled:zod.z.boolean().nullish(),PlatformOverrides:Mn.nullish()}).passthrough(),oc=zod.z.object({MinAccountAgeDays:zod.z.number().nullish(),MultiAccountCheckEnabled:zod.z.boolean().nullish(),BanOnSharedWithdrawalAddress:zod.z.boolean().nullish(),PendingWithdrawalTtlHours:zod.z.number().nullish()}).passthrough();var ac=zod.z.enum(["OnChain","Combined"]),lc=zod.z.object({Enabled:zod.z.boolean().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),MinBalance:w.nullish(),BalanceSource:ac.nullish(),DenyMessage:zod.z.string().nullish()}).passthrough(),uc=zod.z.object({Enabled:zod.z.boolean().nullish(),TokenGates:zod.z.array(lc).nullish(),WalletConnectProjectId:zod.z.string().nullish()}).passthrough(),Xr=zod.z.object({SystemState:nc.nullish(),Networks:zod.z.record(zod.z.string(),ic).nullish(),AccountSafety:oc.nullish(),WalletLogin:uc.nullish()}).passthrough(),cc=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),LinkedAt:a.nullish(),LastUsedAt:a.nullish(),LinkType:$u.nullish(),IsSignatureVerified:zod.z.boolean().nullish()}).passthrough(),kn=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Type:Tn.nullish(),NetworkID:zod.z.string().nullish(),AssetID:zod.z.string().nullish(),Amount:w.nullish(),CreatedAt:a.nullish(),ExpiresAt:a.nullish()}).passthrough(),pc=zod.z.object({Status:Yu.nullish(),Tier:ec.nullish(),VerifiedAt:a.nullish(),ExpiresAt:a.nullish(),RejectedAt:a.nullish(),ProviderReference:zod.z.string().nullish(),RejectionReason:zod.z.string().nullish()}).passthrough(),dc=zod.z.object({CurrencyID:zod.z.string().nullish(),Deposits:zod.z.number().nullish(),DepositsVolumeNative:w.nullish(),DepositsVolumeUsd:w.nullish(),Withdrawals:zod.z.number().nullish(),WithdrawalsVolumeNative:w.nullish(),WithdrawalsVolumeUsd:w.nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),FirstDepositAt:a.nullish(),LastDepositAt:a.nullish(),FirstWithdrawalAt:a.nullish(),LastWithdrawalAt:a.nullish()}).passthrough(),mc=zod.z.object({TotalDeposits:zod.z.number().nullish(),TotalWithdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),TotalDepositsVolumeUsd:w.nullish(),TotalWithdrawalsVolumeUsd:w.nullish(),PerCurrency:zod.z.record(zod.z.string(),dc).nullish()}).passthrough(),hc=zod.z.object({NetworkID:zod.z.string().nullish(),ItemCatalogID:zod.z.string().nullish(),Deposits:zod.z.number().nullish(),Withdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),FirstDepositAt:a.nullish(),LastDepositAt:a.nullish(),FirstWithdrawalAt:a.nullish(),LastWithdrawalAt:a.nullish()}).passthrough(),fc=zod.z.object({TotalDeposits:zod.z.number().nullish(),TotalWithdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),PerCollection:zod.z.record(zod.z.string(),hc).nullish()}).passthrough(),gc=zod.z.object({Tokens:mc.nullish(),Nfts:fc.nullish()}).passthrough(),Rc=zod.z.object({CurrencyID:zod.z.string().nullish(),Balance:w.nullish(),MinBalance:w.nullish()}).passthrough(),yc=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),CheckedAt:a.nullish(),LoggedInAt:a.nullish(),GatePassed:zod.z.boolean().nullish(),GatedBalances:zod.z.array(Rc).nullish()}).passthrough(),Cc=zod.z.object({Version:zod.z.number().nullish(),Stats:gc.nullish(),LinkedWallets:zod.z.record(zod.z.string(),cc).nullish(),LastWalletLogin:yc.nullish(),PendingWithdrawals:zod.z.array(kn).nullish(),Kyc:pc.nullish(),FirstActivityAt:a.nullish(),LastActivityAt:a.nullish(),IsFlagged:zod.z.boolean().nullish(),FlagReason:zod.z.string().nullish()}).passthrough(),Sc=zod.z.object({CurrencyID:zod.z.string(),AmountDelta:w,FrozenDelta:w,UpdatedAt:a}).passthrough(),vs=zod.z.object({CryptoBalances:zod.z.record(zod.z.string(),Sc).nullish(),PendingAdded:kn.nullish(),PendingRemovedIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),xc=zod.z.object({Amount:w,Frozen:w,CreatedAt:a.nullish(),UpdatedAt:a.nullish()}).passthrough().transform(u=>u),Dc=zod.z.object({ID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CreatedAt:a.nullish(),UpdatedAt:a.nullish(),UserID:zod.z.string().nullish(),TransactionHash:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ChainType:zod.z.string().nullish(),ChainID:zod.z.number().nullish(),Direction:In.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:w.nullish(),Status:Yr.nullish(),SignatureData:zod.z.string().nullish(),CompletedAt:a.nullish(),ExpiresAt:a.nullish(),FailReason:zod.z.string().nullish(),Reason:zod.z.string().nullish(),Category:zod.z.string().nullish(),TokenID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountUsd:w.nullish(),NetPayoutAmount:w.nullish()}).passthrough(),bc=zod.z.object({ID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CreatedAt:a.nullish(),UpdatedAt:a.nullish(),UserID:zod.z.string().nullish(),TransactionHash:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ChainType:zod.z.string().nullish(),ChainID:zod.z.number().nullish(),Direction:In.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:w.nullish(),Status:Yr.nullish(),SignatureData:zod.z.string().nullish(),CompletedAt:a.nullish(),ExpiresAt:a.nullish(),FailReason:zod.z.string().nullish(),Reason:zod.z.string().nullish(),Category:zod.z.string().nullish(),NFTID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),SkinID:zod.z.string().nullish()}).passthrough(),ei=zod.z.object({TokenAddress:zod.z.string().nullish(),WalletAddress:zod.z.string().nullish(),Amount:zod.z.string().nullish(),BurnAmount:zod.z.string().nullish(),TokenId:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),ContractAddress:zod.z.string().nullish(),UserID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),Category:zod.z.string().nullish(),Deadline:zod.z.string().nullish(),Signature:zod.z.string().nullish()}).passthrough(),ti=zod.z.object({Mint:zod.z.string().nullish(),WalletAddress:zod.z.string().nullish(),Amount:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),ExpiresAt:zod.z.string().nullish(),ProgramID:zod.z.string().nullish(),SignatureHex:zod.z.string().nullish(),SigIxIndex:zod.z.number().nullish(),Ed25519PublicKey:zod.z.string().nullish(),Ed25519Message:zod.z.string().nullish(),UserID:zod.z.string().nullish()}).passthrough(),An=zod.z.object({Blockchain:Xr.nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Hr).nullish()}).passthrough(),On=zod.z.object({State:Cc.nullish(),CryptoBalances:zod.z.record(zod.z.string(),xc).nullish()}).passthrough(),Bn=zod.z.object({ServerTimeUtc:a.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:w.nullish(),AmountUsd:w.nullish(),StateDelta:vs.nullish()}).passthrough(),Un=zod.z.object({ServerTimeUtc:a.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),NftTokenID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),Resources:x.nullish(),Inventory:Xe.nullish()}).passthrough(),wn=zod.z.object({ServerTimeUtc:a.nullish(),TitleTransactionID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:w.nullish(),NetAmountNative:w.nullish(),BurnAmountNative:w.nullish(),AmountUsd:w.nullish(),ExpiresAt:a.nullish(),EvmSignature:ei.nullish(),SolanaSignature:ti.nullish(),StateDelta:vs.nullish()}).passthrough(),qn=zod.z.object({ServerTimeUtc:a.nullish(),TitleTransactionID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),NftTokenID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),ExpiresAt:a.nullish(),Resources:x.nullish(),EvmSignature:ei.nullish(),SolanaSignature:ti.nullish(),StateDelta:vs.nullish(),Inventory:Xe.nullish()}).passthrough(),En=zod.z.object({TokenTransactions:zod.z.array(Dc).nullish(),NFTTransactions:zod.z.array(bc).nullish()}).passthrough(),si=zod.z.object({ServerTimeUtc:a.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:w.nullish(),AmountUsd:w.nullish(),Target:zod.z.string().nullish()}).passthrough(),Ln=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Kind:Tn.nullish(),EvmSignature:ei.nullish(),SolanaSignature:ti.nullish()}).passthrough(),Gn=zod.z.object({TitleTransactionID:zod.z.string().nullish(),OnChainTxHash:zod.z.string().nullish(),Status:Yr.nullish(),StateDelta:vs.nullish()}).passthrough(),Pe={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",DepositToken:"DepositToken",DepositNFT:"DepositNFT",RequestTokenWithdrawal:"RequestTokenWithdrawal",RequestNFTWithdrawal:"RequestNFTWithdrawal",GetTransactionHistory:"GetTransactionHistory",RetryWithdrawal:"RetryWithdrawal",ConfirmWithdrawal:"ConfirmWithdrawal",DonateToDeveloper:"DonateToDeveloper",DonateToUsersPool:"DonateToUsersPool"};var zc="Blockchain",Ts=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.blockchain.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(zc,t.data.Blockchain),this.ctx.emitter.emit("blockchain:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.blockchain.getUserState(e);return t.ok&&(this.ctx.data.user.applyBlockchainState(t.data.State??null,t.data.CryptoBalances),this.ctx.emitter.emit("blockchain:userStateLoaded",t.data)),t}async depositToken(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.NetworkID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.depositToken(s);return r.ok&&r.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(r.data.CurrencyID,new jt__default.default(r.data.AmountNative??0),r.data.ServerTimeUtc??void 0),this.ctx.emitter.emit("blockchain:tokenDeposited",r.data)),r}async depositNFT(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.NetworkID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.depositNFT(s);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("blockchain:nftDeposited",r.data)),r}async requestTokenWithdrawal(e,t,s,r,i){if(!e)return n("client","CurrencyID is required.");if(!t)return n("client","NetworkID is required.");if(!s)return n("client","WalletAddress is required.");if(!r)return n("client","Amount is required.");let c=this.baseRequest();if(!c)return n("unauthorized","Not logged in.");c.CurrencyID=e,c.NetworkID=t,c.WalletAddress=s,c.Amount=r,c.Category=zs(i);let m=await this.ctx.api.blockchain.requestTokenWithdrawal(c);return m.ok&&m.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(m.data.CurrencyID,new jt__default.default(m.data.AmountNative??0).negated(),m.data.ServerTimeUtc??void 0),this.ctx.emitter.emit("blockchain:tokenWithdrawalRequested",m.data)),m}async requestNFTWithdrawal(e,t,s,r,i,c,m){if(!e)return n("client","ItemID is required.");if(!t)return n("client","NetworkID is required.");if(!s)return n("client","WalletAddress is required.");if(!r)return n("client","Amount is required.");let v=this.baseRequest();if(!v)return n("unauthorized","Not logged in.");v.ItemID=e,v.NetworkID=t,v.WalletAddress=s,v.Amount=r,v.Category=zs(i),c!==void 0&&(v.Level=c),m&&(v.ItemInstanceID=m);let U=await this.ctx.api.blockchain.requestNFTWithdrawal(v);return U.ok&&(this.ctx.data.user.applyResourceOperation(U.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("blockchain:nftWithdrawalRequested",U.data)),U}async getTransactionHistory(e=50){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Amount=String(e);let s=await this.ctx.api.blockchain.getTransactionHistory(t);return s.ok&&this.ctx.emitter.emit("blockchain:transactionHistoryLoaded",s.data),s}async retryWithdrawal(e){if(!e)return n("client","TitleTransactionID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.TitleTransactionID=e;let s=await this.ctx.api.blockchain.retryWithdrawal(t);return s.ok&&this.ctx.emitter.emit("blockchain:withdrawalRetried",s.data),s}async confirmWithdrawal(e,t){if(!e)return n("client","TitleTransactionID is required.");if(!t)return n("client","On-chain TransactionHash is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.TitleTransactionID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.confirmWithdrawal(s);return r.ok&&this.ctx.emitter.emit("blockchain:withdrawalConfirmed",r.data),r}async donateToDeveloper(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.NetworkID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.donateToDeveloper(s);return r.ok&&this.ctx.emitter.emit("blockchain:donatedToDeveloper",r.data),r}async donateToUsersPool(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.NetworkID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.donateToUsersPool(s);return r.ok&&this.ctx.emitter.emit("blockchain:donatedToUsersPool",r.data),r}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ce=zod.z.object({Username:zod.z.string().nullish(),Country:zod.z.string().nullish(),AvatarUrl:zod.z.string().nullish(),Premium:zod.z.boolean().nullish(),Level:zod.z.number().nullish(),Power:zod.z.number().nullish(),BoardRank:zod.z.number().nullish()}).passthrough();var vc={Head:"Head",Torso:"Torso",Legs:"Legs"},Ps=zod.z.enum(["Head","Torso","Legs"]),Tc={Open:"Open",InProgress:"InProgress",Cancelled:"Cancelled",Completed:"Completed"},ri=zod.z.enum(["Open","InProgress","Cancelled","Completed"]),Fn=zod.z.object({AttackTarget:Ps,DefenseTarget:Ps});var Pc=zod.z.enum(["Hit","Critical","Block","Dodge"]),Ic=zod.z.object({RoundIndex:zod.z.number().nullish(),AttackerID:zod.z.string().nullish(),DefenderID:zod.z.string().nullish(),AttackZone:Ps.nullish(),DefenseZone:Ps.nullish(),HitType:Pc.nullish(),DamageDealt:zod.z.number().nullish(),DefenderHpRemaining:zod.z.number().nullish()}).passthrough(),Mc=zod.z.object({MaxHp:zod.z.number().nullish(),CurrentHp:zod.z.number().nullish(),Damage:zod.z.number().nullish(),AttackSpeed:zod.z.number().nullish(),CritChance:zod.z.number().nullish(),CritMultiplier:zod.z.number().nullish(),Armor:zod.z.number().nullish(),DodgeChance:zod.z.number().nullish()}).passthrough(),kc=zod.z.object({ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Quantity:zod.z.number().nullish(),RemainingUses:zod.z.number().nullish(),Level:zod.z.number().nullish(),AcquiredAt:a,ExpiresAt:a.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(u=>u),jn=zod.z.object({UserID:zod.z.string().nullish(),SelectedCharacterID:zod.z.string().nullish(),SelectedCharacter:Kr.nullish(),BattleStrategy:zod.z.array(Fn).nullish(),UnstackableItems:zod.z.record(zod.z.string(),kc).nullish(),Stats:Mc.nullish()}).passthrough(),Ac=zod.z.object({WinnerUserID:zod.z.string().nullish(),LoserUserID:zod.z.string().nullish(),Entry:oe.nullish(),NetReward:oe.nullish(),BattleLog:zod.z.array(Ic).nullish(),IsDraw:zod.z.boolean().nullish(),P1BattleProfile:jn.nullish(),P2BattleProfile:jn.nullish()}).passthrough(),_n=zod.z.object({MatchID:zod.z.string(),TitleID:zod.z.string().nullish(),RuleID:zod.z.string().nullish(),CreatedAt:a.nullish(),CreatorID:zod.z.string().nullish(),CreatorCharacterID:zod.z.string().nullish(),CreatorStrategy:zod.z.array(Fn).nullish(),TargetUserID:zod.z.string().nullish(),Entry:oe.nullish(),CreationCostPaid:oe.nullish(),RefundCreationCostOnCancel:zod.z.boolean().nullish(),JoinedByUserID:zod.z.string().nullish(),JoinedByCharacterID:zod.z.string().nullish(),JoinedAt:a.nullish(),Status:ri.nullish(),WinnerUserID:zod.z.string().nullish(),CompletedAt:a.nullish(),IsRewardDistributed:zod.z.boolean().nullish(),RewardDistributedAt:a.nullish()}).passthrough(),Wn=zod.z.object({Status:ri,MatchID:zod.z.string(),Entry:oe.nullish(),Resources:x.nullish()}),Vn=zod.z.object({Match:_n.nullish()}),Qn=zod.z.object({MatchID:zod.z.string(),Status:ri,Resources:x.nullish()}),Hn=zod.z.object({Battle:Ac.nullish(),Resources:x.nullish(),ResourcesDual:tt.nullish()}),ii=zod.z.object({Matches:zod.z.array(_n).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}),Ne={CreateMatch:"CreateMatch",UpdateMatch:"UpdateMatch",CancelMatch:"CancelMatch",InstantBattle:"InstantBattle",SaveStrategy:"SaveStrategy",GetMyMatches:"GetMyMatches",GetAvailableMatches:"GetAvailableMatches",GetDefinitions:"GetDefinitions"};var Oc=zod.z.enum(["VirtualCurrency","Item","EventToken"]);var Bc=zod.z.enum(["Constant","Stat","RankMultiplier","AllMight","GearFlat","GearPercent"]),Uc=zod.z.object({HealthStatID:zod.z.string().nullish(),DamageStatID:zod.z.string().nullish(),ArmorStatID:zod.z.string().nullish(),AttackSpeedStatID:zod.z.string().nullish(),CritChanceStatID:zod.z.string().nullish(),CritDamageStatID:zod.z.string().nullish(),DodgeStatID:zod.z.string().nullish(),AllMightStatID:zod.z.string().nullish()}).passthrough(),wc=zod.z.object({MaxRounds:zod.z.number().nullish(),BlockDamageMultiplier:zod.z.number().nullish(),MinHitDamage:zod.z.number().nullish(),DefaultCritMultiplier:zod.z.number().nullish(),MaxCritChance:zod.z.number().nullish(),MaxDodgeChance:zod.z.number().nullish()}).passthrough(),qc=zod.z.object({Source:Bc.nullish(),StatID:zod.z.string().nullish(),Value:zod.z.number().nullish(),OnePlus:zod.z.boolean().nullish()}).passthrough(),Ec=zod.z.object({Coefficient:zod.z.number().nullish(),Factors:zod.z.array(qc).nullish()}).passthrough(),rt=zod.z.object({Terms:zod.z.array(Ec).nullish()}).passthrough(),Lc=zod.z.object({Health:rt.nullish(),Damage:rt.nullish(),Armor:rt.nullish(),AttackSpeed:rt.nullish(),CritChance:rt.nullish(),CritDamage:rt.nullish(),Dodge:rt.nullish()}).passthrough(),Kn=zod.z.object({StatMapping:Uc.nullish(),Combat:wc.nullish(),Formula:Lc.nullish()}).passthrough(),Gc=zod.z.object({BurnRate:zod.z.number().nullish()}).passthrough(),ni=zod.z.object({Kind:Oc.nullish(),CurrencyID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),TokenType:Bt.nullish(),EntityID:zod.z.string().nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish()}).passthrough(),$n=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(ni).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),Zn=zod.z.object({Cost:H.nullish(),RefundCostOnCancel:zod.z.boolean().nullish(),MaxOpenMatches:zod.z.number().nullish(),Limits:ce.nullish(),AllowPrivateMatches:zod.z.boolean().nullish(),MaxMatchesPerOpponentPerDay:zod.z.number().nullish()}).passthrough(),Nc=zod.z.object({RuleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Economy:Gc.nullish(),Entry:$n.nullish(),Creation:Zn.nullish(),Settings:Kn.nullish()}).passthrough(),jc=zod.z.object({Rules:zod.z.record(zod.z.string(),Nc).nullish(),Defaults:Kn.nullish(),EntryDefaults:$n.nullish(),CreationDefaults:Zn.nullish()}).passthrough(),oi=zod.z.object({InstantBattle:jc.nullish()}).passthrough(),Jn=oi;var Fc={Listing:"Listing",Auction:"Auction",BuyOrder:"BuyOrder",DirectTrade:"DirectTrade"},ai=zod.z.enum(["Listing","Auction","BuyOrder","DirectTrade"]),_c={Active:"Active",Completed:"Completed",Cancelled:"Cancelled",Declined:"Declined",Expired:"Expired"},li=zod.z.enum(["Active","Completed","Cancelled","Declined","Expired"]),Wc={Burn:"Burn",Ledger:"Ledger"},Vc=zod.z.enum(["Burn","Ledger"]),Ms={Item:"Item",VirtualCurrency:"VirtualCurrency"},ui=zod.z.enum(["Item","VirtualCurrency"]),Qc=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:k.nullish()}).passthrough(),Hc=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(ni).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),Kc=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:k.nullish(),Sink:Vc.nullish(),LedgerAccountID:zod.z.string().nullish(),PerCatalogOverrides:zod.z.record(zod.z.string(),Qc).nullish(),ApplyToDirectTrades:zod.z.boolean().nullish()}).passthrough(),$c=zod.z.object({AllowedCatalogIDs:zod.z.array(zod.z.string()).nullish(),DeniedCatalogIDs:zod.z.array(zod.z.string()).nullish(),DeniedItemIDs:zod.z.array(zod.z.string()).nullish(),AllowUnstackableWithState:zod.z.boolean().nullish()}).passthrough(),Zc=zod.z.object({Enabled:zod.z.boolean().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),MaxActiveListings:zod.z.number().nullish(),CreateLimits:ce.nullish(),BuyLimits:ce.nullish(),ListingFee:H.nullish(),RefundListingFeeOnCancel:zod.z.boolean().nullish()}).passthrough(),Jc=zod.z.object({Enabled:zod.z.boolean().nullish(),MinDurationHours:zod.z.number().nullish(),MaxDurationHours:zod.z.number().nullish(),AntiSnipeWindowSeconds:zod.z.number().nullish(),AntiSnipeExtensionSeconds:zod.z.number().nullish(),MaxAntiSnipeExtensions:zod.z.number().nullish(),MinBidStepPercent:zod.z.number().nullish(),MinBidStepAbsolute:k.nullish(),BidLimits:ce.nullish()}).passthrough(),Yc=zod.z.object({Enabled:zod.z.boolean().nullish(),MaxActiveOrders:zod.z.number().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),CreateLimits:ce.nullish(),FillLimits:ce.nullish()}).passthrough(),Xc=zod.z.object({Enabled:zod.z.boolean().nullish(),OfferExpirationHours:zod.z.number().nullish(),MaxPendingOutgoing:zod.z.number().nullish(),AllowGifts:zod.z.boolean().nullish(),CreateLimits:ce.nullish()}).passthrough(),ep=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),ci=zod.z.object({Enabled:zod.z.boolean().nullish(),Gate:V.nullish(),Schedule:ue.nullish(),PricePolicy:Hc.nullish(),Commission:Kc.nullish(),Tradability:$c.nullish(),Listings:Zc.nullish(),Auctions:Jc.nullish(),BuyOrders:Yc.nullish(),DirectTrades:Xc.nullish(),Matching:ep.nullish()}).passthrough(),Yn=zod.z.object({BidIndex:zod.z.number().nullish(),UserID:zod.z.string().nullish(),Amount:k.nullish(),Settled:zod.z.boolean().nullish(),SettledAt:a.nullish()}).passthrough(),tp=zod.z.object({BidAxisType:Ot.nullish(),BidCurrencyID:zod.z.string().nullish(),BidCatalogID:zod.z.string().nullish(),BidItemID:zod.z.string().nullish(),StartingBid:k.nullish(),CurrentBid:k.nullish(),CurrentBidderID:zod.z.string().nullish(),BidCount:zod.z.number().nullish(),ExtensionCount:zod.z.number().nullish(),PendingRefunds:zod.z.array(Yn).nullish()}).passthrough(),Is=zod.z.object({LastAt:a.nullish(),DailyCount:zod.z.number().nullish(),DailyResetUtc:a.nullish()}).passthrough(),sp=zod.z.object({Create:Is.nullish(),Buy:Is.nullish(),Sell:Is.nullish(),Bid:Is.nullish()}).passthrough(),rp=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),ip=zod.z.object({ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Quantity:zod.z.number().nullish(),RemainingUses:zod.z.number().nullish(),Level:zod.z.number().nullish(),AcquiredAt:a,ExpiresAt:a.nullish(),EquippedSlot:rp.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(u=>u),Qe=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:ai.nullish(),Status:li.nullish(),CreatorUserID:zod.z.string().nullish(),CreatorPublicData:Ce.nullish(),TargetUserID:zod.z.string().nullish(),GoodsType:ui.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:k.nullish(),GoodsInstances:zod.z.array(ip).nullish(),Price:oe.nullish(),Auction:tp.nullish(),CreatedAt:a.nullish(),ExpiresAt:a.nullish()}).passthrough(),np=zod.z.object({GoodsType:ui.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),CountsByType:zod.z.record(ai,k).nullish(),ListingCount:k.nullish(),AuctionCount:k.nullish(),BuyOrderCount:k.nullish()}).passthrough(),Xn=zod.z.object({Definitions:ci.nullish(),IsOpenNow:zod.z.boolean().nullish(),GatePassed:zod.z.boolean().nullish()}).passthrough(),pi=zod.z.object({Offers:zod.z.array(Qe).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),eo=zod.z.object({Groups:zod.z.array(np).nullish()}).passthrough(),to=zod.z.object({Offer:Qe.nullish()}).passthrough(),Ae=zod.z.object({OfferID:zod.z.string().nullish(),Status:li.nullish(),Settlement:tt.nullish(),Resources:x.nullish(),CommissionTaken:oe.nullish()}).passthrough(),vt=zod.z.object({OfferID:zod.z.string().nullish(),Offer:Qe.nullish(),Resources:x.nullish(),Matched:zod.z.boolean().nullish(),Settlement:Ae.nullish()}).passthrough(),so=zod.z.object({OfferID:zod.z.string().nullish(),CurrentBid:k.nullish(),BidCount:zod.z.number().nullish(),ExpiresAt:a.nullish(),Resources:x.nullish()}).passthrough(),ro=zod.z.object({MyOffers:zod.z.array(Qe).nullish(),MyLeadingBids:zod.z.array(Qe).nullish(),MyBuyOrders:zod.z.array(Qe).nullish(),IncomingTrades:zod.z.array(Qe).nullish(),OutgoingTrades:zod.z.array(Qe).nullish(),Claimables:zod.z.array(Qe).nullish(),DrainedRefunds:zod.z.array(Yn).nullish(),Limits:sp.nullish()}).passthrough(),op=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:ai.nullish(),FinalStatus:li.nullish(),SellerUserID:zod.z.string().nullish(),BuyerUserID:zod.z.string().nullish(),GoodsType:ui.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:k.nullish(),PricePaid:oe.nullish(),CommissionTaken:oe.nullish(),CompletedAt:a.nullish()}).passthrough(),io=zod.z.object({Entries:zod.z.array(op).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),se={GetDefinitions:"GetDefinitions",GetGroupedOffers:"GetGroupedOffers",GetOffersByItem:"GetOffersByItem",GetOffer:"GetOffer",GetBuyOrders:"GetBuyOrders",GetMyState:"GetMyState",GetHistory:"GetHistory",CreateListing:"CreateListing",CancelListing:"CancelListing",Buy:"Buy",MarketBuy:"MarketBuy",MarketSell:"MarketSell",CreateAuction:"CreateAuction",PlaceBid:"PlaceBid",ClaimAuction:"ClaimAuction",CreateBuyOrder:"CreateBuyOrder",CancelBuyOrder:"CancelBuyOrder",FillBuyOrder:"FillBuyOrder",CreateDirectTrade:"CreateDirectTrade",RespondDirectTrade:"RespondDirectTrade",CancelDirectTrade:"CancelDirectTrade",ClaimBack:"ClaimBack"};var ap="Marketplace",ks=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.marketplace.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(ap,t.data.Definitions),this.ctx.emitter.emit("marketplace:definitionsLoaded",t.data)),t}async getGroupedOffers(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.marketplace.getGroupedOffers(e);return t.ok&&this.ctx.emitter.emit("marketplace:groupedOffersLoaded",t.data),t}async getOffersByItem(e,t,s,r=20){if(!e)return n("client","ItemID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.ItemID=e,i.OfferTypeFilter=t,i.ContinuationToken=s,i.PageSize=r;let c=await this.ctx.api.marketplace.getOffersByItem(i);return c.ok&&this.ctx.emitter.emit("marketplace:offersByItemLoaded",c.data),c}async getOffer(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let s=await this.ctx.api.marketplace.getOffer(t);return s.ok&&this.ctx.emitter.emit("marketplace:offerLoaded",s.data),s}async getBuyOrders(e,t,s=20){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.ItemID=e,r.ContinuationToken=t,r.PageSize=s;let i=await this.ctx.api.marketplace.getBuyOrders(r);return i.ok&&this.ctx.emitter.emit("marketplace:buyOrdersLoaded",i.data),i}async getMyState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.marketplace.getMyState(e);return t.ok&&(this.ctx.data.user.applyMarketplaceState(t.data.Limits??null),this.ctx.emitter.emit("marketplace:myStateLoaded",t.data)),t}async getHistory(e,t=20){let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.ContinuationToken=e,s.PageSize=t;let r=await this.ctx.api.marketplace.getHistory(s);return r.ok&&this.ctx.emitter.emit("marketplace:historyLoaded",r.data),r}async createListing(e,t,s,r,i,c){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");if(!r)return n("client","PriceBundle is required.");let m=this.baseRequest();if(!m)return n("unauthorized","Not logged in.");m.ItemID=e,m.CatalogID=t,m.GoodsAmount=s,m.PriceBundle=r,m.DurationHours=i,m.ItemInstanceIDs=c;let v=await this.ctx.api.marketplace.createListing(m);return this.applyCreateOfferResult(v,"marketplace:listingCreated"),v}async cancelListing(e){return this.cancelOffer(e,t=>this.ctx.api.marketplace.cancelListing(t),"marketplace:listingCancelled")}async buy(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let s=await this.ctx.api.marketplace.buy(t);return s.ok&&(this.applyDualPartySettlement(s.data.Settlement),this.ctx.emitter.emit("marketplace:bought",s.data)),s}async marketBuy(e,t,s){if(!e||e<=0)return n("client","GoodsAmount must be positive.");if(!t)return n("client","PriceBundle is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");let i=this.applyGoodsSelector(r,s);if(i)return i;r.GoodsAmount=e,r.PriceBundle=t;let c=await this.ctx.api.marketplace.marketBuy(r);return c.ok&&(this.applyDualPartySettlement(c.data.Settlement),this.ctx.emitter.emit("marketplace:marketBought",c.data)),c}async marketSell(e,t,s){if(!e||e<=0)return n("client","GoodsAmount must be positive.");if(!t)return n("client","PriceBundle is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");let i=this.applyGoodsSelector(r,s);if(i)return i;r.GoodsAmount=e,r.PriceBundle=t;let c=await this.ctx.api.marketplace.marketSell(r);return c.ok&&(this.applyDualPartySettlement(c.data.Settlement),this.ctx.emitter.emit("marketplace:marketSold",c.data)),c}async createAuction(e,t,s,r,i,c,m={}){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");let v=this.baseRequest();if(!v)return n("unauthorized","Not logged in.");v.ItemID=e,v.CatalogID=t,v.GoodsAmount=s,v.BidAxisType=r,v.BidCurrencyID=m.bidCurrencyID,v.BidCatalogID=m.bidCatalogID,v.BidItemID=m.bidItemID,v.StartingBid=i,v.DurationHours=c,v.ItemInstanceIDs=m.itemInstanceIDs;let U=await this.ctx.api.marketplace.createAuction(v);return this.applyCreateOfferResult(U,"marketplace:auctionCreated"),U}async placeBid(e,t){if(!e)return n("client","OfferID is required.");if(!t||t<=0)return n("client","BidAmount must be positive.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.OfferID=e,s.BidAmount=t;let r=await this.ctx.api.marketplace.placeBid(s);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:bidPlaced",r.data)),r}async claimAuction(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let s=await this.ctx.api.marketplace.claimAuction(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:auctionClaimed",s.data)),s}async createBuyOrder(e,t,s,r,i){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");if(!r)return n("client","PriceBundle is required.");let c=this.baseRequest();if(!c)return n("unauthorized","Not logged in.");c.ItemID=e,c.CatalogID=t,c.GoodsAmount=s,c.PriceBundle=r,c.DurationHours=i;let m=await this.ctx.api.marketplace.createBuyOrder(c);return this.applyCreateOfferResult(m,"marketplace:buyOrderCreated"),m}async cancelBuyOrder(e){return this.cancelOffer(e,t=>this.ctx.api.marketplace.cancelBuyOrder(t),"marketplace:buyOrderCancelled")}async fillBuyOrder(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let s=await this.ctx.api.marketplace.fillBuyOrder(t);return s.ok&&(this.applyDualPartySettlement(s.data.Settlement),this.ctx.emitter.emit("marketplace:buyOrderFilled",s.data)),s}async createDirectTrade(e,t,s,r,i){if(!e)return n("client","TargetUserID is required.");if(!t)return n("client","CatalogID is required.");if(!s)return n("client","ItemID is required.");let c=this.baseRequest();if(!c)return n("unauthorized","Not logged in.");c.TargetUserID=e,c.CatalogID=t,c.ItemID=s,c.ItemInstanceIDs=r,c.RequestedBundle=i;let m=await this.ctx.api.marketplace.createDirectTrade(c);return this.applyCreateOfferResult(m,"marketplace:directTradeCreated"),m}async respondDirectTrade(e,t){if(!e)return n("client","OfferID is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.OfferID=e,s.Accept=t;let r=await this.ctx.api.marketplace.respondDirectTrade(s);return r.ok&&(t&&(r.data.Settlement?this.applyDualPartySettlement(r.data.Settlement):r.data.Resources&&this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions)),this.ctx.emitter.emit("marketplace:directTradeResponded",r.data)),r}async cancelDirectTrade(e){return this.cancelOffer(e,t=>this.ctx.api.marketplace.cancelDirectTrade(t),"marketplace:directTradeCancelled")}async claimBack(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let s=await this.ctx.api.marketplace.claimBack(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:claimedBack",s.data)),s}async cancelOffer(e,t,s){if(!e)return n("client","OfferID is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.OfferID=e;let i=await t(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit(s,i.data)),i}applyCreateOfferResult(e,t){e.ok&&(e.data.Matched&&e.data.Settlement?this.applyDualPartySettlement(e.data.Settlement.Settlement):this.ctx.data.user.applyResourceOperation(e.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit(t,e.data));}applyGoodsSelector(e,t){return "goodsCurrencyID"in t&&t.goodsCurrencyID?(e.GoodsType=Ms.VirtualCurrency,e.GoodsCurrencyID=t.goodsCurrencyID,null):"itemID"in t&&t.itemID&&t.catalogID?(e.GoodsType=Ms.Item,e.ItemID=t.itemID,e.CatalogID=t.catalogID,null):n("client","Either itemID+catalogID or goodsCurrencyID is required.")}applyDualPartySettlement(e){let t=this.ctx.auth.context?.userID;if(!e||!t)return;let s=this.ctx.data.config.itemDefinitions;e.FromUserID===t&&e.FromResult?this.ctx.data.user.applyResourceOperation(e.FromResult,s):e.ToUserID===t&&e.ToResult&&this.ctx.data.user.applyResourceOperation(e.ToResult,s);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var As=class{constructor(e){this.ctx=e;}ctx;async createRoom(e,t={}){if(!e)return n("client","RoomName is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomName=e,s.Topology=t.topology,s.ChatMode=t.chatMode,s.MaxPlayers=t.maxPlayers,s.Visibility=t.visibility,s.JoinCode=t.joinCode;let r=await this.ctx.api.multiplayer.createRoom(s);return r.ok&&this.ctx.emitter.emit("multiplayer:roomCreated",r.data),r}async joinRoom(e,t){if(!e)return n("client","RoomID is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomID=e,s.JoinCode=t;let r=await this.ctx.api.multiplayer.joinRoom(s);return r.ok&&this.ctx.emitter.emit("multiplayer:roomJoined",r.data),r}async leaveRoom(e){if(!e)return n("client","RoomID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.RoomID=e;let s=await this.ctx.api.multiplayer.leaveRoom(t);return s.ok&&this.ctx.emitter.emit("multiplayer:roomLeft",s.data),s}async listRooms(e=0,t=20){let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.Page=e,s.PageSize=t;let r=await this.ctx.api.multiplayer.listRooms(s);return r.ok&&this.ctx.emitter.emit("multiplayer:roomsListed",r.data),r}async getRoom(e){if(!e)return n("client","RoomID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.RoomID=e;let s=await this.ctx.api.multiplayer.getRoom(t);return s.ok&&this.ctx.emitter.emit("multiplayer:roomLoaded",s.data),s}async closeRoom(e){if(!e)return n("client","RoomID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.RoomID=e;let s=await this.ctx.api.multiplayer.closeRoom(t);return s.ok&&this.ctx.emitter.emit("multiplayer:roomClosed",s.data),s}async poll(e,t){if(!e)return n("client","RoomID is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomID=e,s.LastSeq=t;let r=await this.ctx.api.multiplayer.poll(s);return r.ok&&this.ctx.emitter.emit("multiplayer:polled",r.data),r}async sendSignal(e,t,s,r){if(!e)return n("client","RoomID is required.");if(!t)return n("client","TargetUserID is required.");if(!s)return n("client","SignalKind is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.TargetUserID=t,i.SignalKind=s,i.Payload=r;let c=await this.ctx.api.multiplayer.sendSignal(i);return c.ok&&this.ctx.emitter.emit("multiplayer:signalSent",c.data),c}async sendChat(e,t){if(!e)return n("client","RoomID is required.");if(!t)return n("client","ChatText is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomID=e,s.ChatText=t;let r=await this.ctx.api.multiplayer.sendChat(s);return r.ok&&this.ctx.emitter.emit("multiplayer:chatSent",r.data),r}async setMemberState(e,t,s){if(!e)return n("client","RoomID is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.RoomID=e,r.Ready=t,r.MemberState=s;let i=await this.ctx.api.multiplayer.setMemberState(r);return i.ok&&this.ctx.emitter.emit("multiplayer:memberStateSet",i.data),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var no=zod.z.object({PlatformUserID:zod.z.string().nullish(),PlatformAuthToken:zod.z.string().nullish(),PlatformAuthTokenExpiration:a.nullish(),TitleUserID:zod.z.string(),TitleClientSessionTicket:zod.z.string(),TitleClientSessionTicketExpiration:a}),Se=zod.z.object({IsCompleted:zod.z.boolean().nullish(),ServerTime:a.nullish()}),oo=zod.z.object({Message:zod.z.string(),ExpiresAt:a}),Oe={LoginWithDeviceID:"LoginWithDeviceID",LoginWithTelegram:"LoginWithTelegram",LoginWithEmail:"LoginWithEmail",LoginWithGoogle:"LoginWithGoogle",LoginWithPlatformToken:"LoginWithPlatformToken",RegisterWithEmail:"RegisterWithEmail",RefreshPlatformToken:"RefreshPlatformToken",RequestWalletChallenge:"RequestWalletChallenge",LoginWithWallet:"LoginWithWallet",ForgotPassword:"ForgotPassword",ResetPassword:"ResetPassword"};function O(u,e,t,s){let i=`api/v2/${u&&u.length>0?u:"0"}/Client/${e}/${t}`;return s==null?i:`${i}/${s}`}var Os=class{constructor(e){this.ctx=e;}ctx;endpoint(e){return O(this.ctx.settings.titleID,"Authentication",e)}login(e,t){return this.ctx.transport.post(this.endpoint(e),t,no,{ticket:null})}loginWithDeviceID(e){return this.login(Oe.LoginWithDeviceID,e)}loginWithTelegram(e){return this.login(Oe.LoginWithTelegram,e)}loginWithEmail(e){return this.login(Oe.LoginWithEmail,e)}loginWithGoogle(e){return this.login(Oe.LoginWithGoogle,e)}loginWithPlatformToken(e){return this.login(Oe.LoginWithPlatformToken,e)}registerWithEmail(e){return this.login(Oe.RegisterWithEmail,e)}requestWalletChallenge(e){return this.ctx.transport.post(this.endpoint(Oe.RequestWalletChallenge),e,oo,{ticket:null})}loginWithWallet(e){return this.login(Oe.LoginWithWallet,e)}forgotPassword(e){return this.ctx.transport.post(this.endpoint(Oe.ForgotPassword),e,Se,{ticket:null})}resetPassword(e){return this.ctx.transport.post(this.endpoint(Oe.ResetPassword),e,Se,{ticket:null})}};var di=zod.z.object({Title:zod.z.unknown().nullish(),User:zod.z.unknown().nullish()}).passthrough().transform(u=>u),ao=zod.z.object({}).passthrough().transform(u=>u),lo=zod.z.object({}).passthrough().transform(u=>u),uo=zod.z.object({Today:zod.z.number(),Yesterday:zod.z.number(),CurrentWeek:zod.z.number(),CurrentMonth:zod.z.number(),Total:zod.z.number(),TotalSessions:zod.z.number(),FirstActiveAt:a.nullish(),LastActiveAt:a.nullish(),LongestSessionEverSeconds:zod.z.number().nullish(),CurrentWeekActiveHoursMask:zod.z.number().nullish(),CurrentMonthActiveHoursMask:zod.z.number().nullish(),ReactivationCount:zod.z.number().nullish(),History:zod.z.record(zod.z.string(),zod.z.unknown()).nullish()}).passthrough(),co=zod.z.object({Username:zod.z.string()}),je={GetClientState:"GetClientState",GetClientStateExcept:"GetClientStateExcept",GetInventory:"GetInventory",GetEventTokens:"GetEventTokens",GetUsageTime:"GetUsageTime",AddUsageTime:"AddUsageTime",DeleteUserAccount:"DeleteUserAccount",ChangeUsername:"ChangeUsername"};var Bs=class{constructor(e){this.ctx=e;}ctx;endpoint(e,t){return O(this.ctx.settings.titleID,"User",e,t??"")}getClientState(e){return this.ctx.transport.post(this.endpoint(je.GetClientState,e.UserID),e,di,{ticket:e.ClientSessionTicket})}getClientStateExcept(e){return this.ctx.transport.post(this.endpoint(je.GetClientStateExcept,e.UserID),e,di,{ticket:e.ClientSessionTicket})}getInventory(e){return this.ctx.transport.post(this.endpoint(je.GetInventory,e.UserID),e,ao,{ticket:e.ClientSessionTicket})}getEventTokens(e){return this.ctx.transport.post(this.endpoint(je.GetEventTokens,e.UserID),e,lo,{ticket:e.ClientSessionTicket})}getUsageTime(e){return this.ctx.transport.post(this.endpoint(je.GetUsageTime,e.UserID),e,uo,{ticket:e.ClientSessionTicket})}addUsageTime(e){return this.ctx.transport.post(this.endpoint(je.AddUsageTime,e.UserID),e,Se,{ticket:e.ClientSessionTicket,silent:true})}deleteUserAccount(e){return this.ctx.transport.post(this.endpoint(je.DeleteUserAccount,e.UserID),e,Se,{ticket:e.ClientSessionTicket})}changeUsername(e){return this.ctx.transport.post(this.endpoint(je.ChangeUsername,e.UserID),e,co,{ticket:e.ClientSessionTicket})}};var Us=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Currency",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}convert(e){return this.send(xs.Convert,e,un)}cryptoConvert(e){return this.send(xs.CryptoConvert,e,cn)}};var lp=zod.z.object({ItemInstanceID:zod.z.string(),Units:zod.z.number(),Level:zod.z.number()}),mi=zod.z.object({ServerTimeUtc:a,ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Level:zod.z.number(),Resources:x.nullish(),FodderConsumed:zod.z.array(lp).nullish()}),po=zod.z.array(te(mi)),ws={UpgradeLevel:"UpgradeLevel",UpgradeLevelsBatch:"UpgradeLevelsBatch"},up={FlatCount:"FlatCount",Merge:"Merge",InvestmentRefund:"InvestmentRefund"},cp=zod.z.enum(["FlatCount","Merge","InvestmentRefund"]),pp={ProtectLeveled:"ProtectLeveled",CheapestFirst:"CheapestFirst",ClientSelected:"ClientSelected"},dp=zod.z.enum(["ProtectLeveled","CheapestFirst","ClientSelected"]),mp=zod.z.object({ContractAddress:zod.z.string().nullish(),TokenID:zod.z.string().nullish(),TokenStandard:zod.z.string().nullish()}).passthrough(),hp=zod.z.object({Networks:zod.z.record(zod.z.string(),mp).nullish(),MetadataUrl:zod.z.string().nullish()}).passthrough(),fp=zod.z.object({FlatBonuses:zod.z.record(zod.z.string(),zod.z.number()).nullish(),PercentBonuses:zod.z.record(zod.z.string(),zod.z.number()).nullish(),Power:zod.z.number().nullish()}).passthrough(),gp=zod.z.object({MinCharacterLevel:zod.z.number().nullish(),UseRequirements:zod.z.record(zod.z.string(),zod.z.number()).nullish(),AllowedCharacterIDs:zod.z.array(zod.z.string()).nullish(),AllowedSlotIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),Rp=zod.z.object({ValuationMode:cp.nullish(),MergeRatio:zod.z.number().nullish(),Selection:dp.nullish()}).passthrough(),yp=zod.z.object({MaxLevel:zod.z.number().nullish(),BaseCostResource:H.nullish(),CostScalingFactor:zod.z.number().nullish(),FlatScalingFactor:zod.z.number().nullish(),PercentScalingFactor:zod.z.number().nullish(),PowerScalingFactor:zod.z.number().nullish(),Fodder:Rp.nullish()}).passthrough(),Cp=zod.z.object({RarityID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),AuthorID:zod.z.string().nullish()}).passthrough(),Sp=zod.z.object({ItemID:zod.z.string(),CatalogID:zod.z.string(),ItemClass:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Tags:zod.z.array(zod.z.string()).nullish(),CustomData:zod.z.string().nullish(),IsStackable:zod.z.boolean().nullish(),IsTradable:zod.z.boolean().nullish(),Weight:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),NFT:hp.nullish(),Stats:fp.nullish(),Equipment:gp.nullish(),Upgrade:yp.nullish(),Metadata:Cp.nullish(),ExpirationDurationSeconds:zod.z.number().nullish()}).passthrough(),xp=zod.z.object({Items:zod.z.record(zod.z.string(),Sp).nullish()}).passthrough(),qs=zod.z.object({Catalogs:zod.z.record(zod.z.string(),xp).nullish()}).passthrough();var Es=class{constructor(e){this.ctx=e;}ctx;upgradeLevel(e){let t=O(this.ctx.settings.titleID,"Item",ws.UpgradeLevel,e.UserID??"");return this.ctx.transport.post(t,e,mi,{ticket:e.ClientSessionTicket})}upgradeLevelsBatch(e){let t=O(this.ctx.settings.titleID,"Item",ws.UpgradeLevelsBatch,e.UserID??"");return this.ctx.transport.post(t,e,po,{ticket:e.ClientSessionTicket})}};var hi=zod.z.object({ServerTimeUtc:a,OfferID:zod.z.string(),Count:zod.z.number(),Resources:x.nullish()}),mo=zod.z.array(te(hi)),Dp=zod.z.object({OfferID:zod.z.string(),TotalPurchases:zod.z.number(),DailyPurchases:zod.z.number(),DailyResetUtc:a,LastPurchasedAt:a}),ho=zod.z.object({Purchases:zod.z.record(zod.z.string(),Dp).nullish()}).passthrough().transform(u=>u),bp=zod.z.object({StartUtc:a.nullish(),EndUtc:a.nullish(),RequiredFlags:zod.z.array(zod.z.string()).nullish()}).passthrough(),zp=zod.z.object({StoreID:zod.z.string(),Type:zod.z.string().nullish(),Name:zod.z.string().nullish(),Description:zod.z.string().nullish(),Rules:bp.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),vp=zod.z.object({StartUtc:a.nullish(),EndUtc:a.nullish(),Gate:V.nullish(),Limits:ce.nullish()}).passthrough(),Tp=zod.z.object({OfferID:zod.z.string(),StoreIDs:zod.z.array(zod.z.string()).nullish(),Name:zod.z.string().nullish(),Cost:H.nullish(),Rewards:G.nullish(),Rules:vp.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Ls=zod.z.object({Stores:zod.z.record(zod.z.string(),zp).nullish(),StoreOffers:zod.z.record(zod.z.string(),Tp).nullish()}).passthrough(),ht={Purchase:"Purchase",GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",PurchaseBatch:"PurchaseBatch"};var Gs=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Store",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}purchase(e){return this.send(ht.Purchase,e,hi)}purchaseBatch(e){return this.send(ht.PurchaseBatch,e,mo)}getDefinitions(e){return this.send(ht.GetDefinitions,e,Ls)}getUserState(e){return this.send(ht.GetUserState,e,ho)}};var Pp=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),fo=zod.z.object({Reward:G.nullish(),Weight:zod.z.number().nullish(),AmountRange:Pp.nullish()}).passthrough(),ft=zod.z.object({SlotID:zod.z.string().nullish(),MinRolls:zod.z.number().nullish(),MaxRolls:zod.z.number().nullish(),Pool:zod.z.array(fo).nullish()}).passthrough(),gt=zod.z.object({RuleID:zod.z.string().nullish(),Threshold:zod.z.number().nullish(),Pool:zod.z.array(fo).nullish()}).passthrough(),Ip=zod.z.object({RewardSlots:zod.z.array(ft).nullish()}).passthrough(),Mp=zod.z.object({PityRules:zod.z.array(gt).nullish()}).passthrough(),Ns=zod.z.object({SlotPresets:zod.z.record(zod.z.string(),Ip).nullish(),PityPresets:zod.z.record(zod.z.string(),Mp).nullish()}).passthrough();var kp=zod.z.object({RuleID:zod.z.string(),BoxIndex:zod.z.number().nullish()}),go=zod.z.object({ServerTimeUtc:a,LootboxID:zod.z.string(),OpenedCount:zod.z.number().nullish(),SelectedOptionID:zod.z.number().nullish(),Resources:x.nullish(),Inventory:Xe.nullish(),Results:zod.z.array(x).nullish(),TriggeredPity:zod.z.array(kp).nullish()}),Ap=zod.z.object({PriceOptionID:zod.z.number().nullish(),RequiredResources:H.nullish()}).passthrough(),Op=zod.z.object({RewardSlots:pe.nullish(),PityRules:pe.nullish()}).passthrough(),Bp=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),MaxDrops:k.nullish()}).passthrough(),Up=zod.z.object({LootboxID:zod.z.string(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),PriceOptions:zod.z.record(zod.z.string(),Ap).nullish(),RewardSlots:zod.z.array(ft).nullish(),PityRules:zod.z.array(gt).nullish(),Presets:Op.nullish(),RewardMultiplier:Ut.nullish(),SupplyLimits:zod.z.array(Bp).nullish()}).passthrough(),fi=zod.z.object({Definitions:zod.z.record(zod.z.string(),Up).nullish(),RewardPools:Ns.nullish()}).passthrough(),Ro=zod.z.object({LootboxDefinitions:fi.nullish()}),js={GetDefinitions:"GetDefinitions",Open:"Open"};var Fs=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Lootbox",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(js.GetDefinitions,e,Ro)}open(e){return this.send(js.Open,e,go)}};var wp=zod.z.object({}).passthrough().transform(u=>u),qp=zod.z.object({}).passthrough().transform(u=>u),Ep=zod.z.object({}).passthrough().transform(u=>u),Lp=zod.z.object({}).passthrough().transform(u=>u),Gp=zod.z.object({}).passthrough().transform(u=>u),yo=zod.z.object({ServerTimeUtc:a,CalendarID:zod.z.string(),DayNumber:zod.z.number().nullish(),DailyState:wp,Resources:x.nullish()}),Co=zod.z.object({ServerTimeUtc:a,AccrualID:zod.z.string(),AccruedSeconds:k.nullish(),AppliedRatePerSecond:zod.z.number().nullish(),IdleState:qp,Resources:x.nullish()}),So=zod.z.object({ServerTimeUtc:a,ComebackID:zod.z.string(),ClaimedTierIndex:zod.z.number().nullish(),ComebackState:Ep,Resources:x.nullish()}),xo=zod.z.object({ServerTimeUtc:a,ClaimID:zod.z.string(),ClaimState:Lp,Resources:x.nullish()}),Do=zod.z.object({Enabled:zod.z.boolean(),Multiplier:zod.z.number().nullish(),Progress:k.nullish(),Source:zod.z.string().nullish(),SourceKey:zod.z.string().nullish()}),Np=zod.z.object({RewardMode:zod.z.string().nullish(),RewardStackLowerTiers:zod.z.boolean().nullish()}).passthrough(),jp=zod.z.object({DayNumber:zod.z.number().nullish(),Rewards:G.nullish(),IsMilestone:zod.z.boolean().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Fp=zod.z.object({CalendarID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Days:zod.z.array(jp).nullish(),IsLooping:zod.z.boolean().nullish(),MissBehavior:zod.z.string().nullish(),ResetByDays:zod.z.number().nullish(),MissThresholdMultiplier:zod.z.number().nullish(),ClaimMode:zod.z.string().nullish(),ClaimCooldownSeconds:zod.z.number().nullish(),Gate:V.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),_p=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),Wp=zod.z.object({BaseRatePerSecond:zod.z.number().nullish(),PowerCoefficient:zod.z.number().nullish(),BoardRankCoefficient:zod.z.number().nullish(),EquipmentBonusEnabled:zod.z.boolean().nullish(),EquipmentCharacterID:zod.z.string().nullish(),PremiumMultipliers:zod.z.array(_p).nullish()}).passthrough(),Vp=zod.z.object({MinCharacterLevel:zod.z.number().nullish(),RequirementsCharacterID:zod.z.string().nullish(),Gate:V.nullish(),RequiredItemIDs:zod.z.array(zod.z.string()).nullish(),RequiredEquippedItemIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),Qp=zod.z.object({AccrualID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rate:Wp.nullish(),Rewards:G.nullish(),MaxAccumulationSeconds:zod.z.number().nullish(),MinClaimSeconds:zod.z.number().nullish(),Requirements:Vp.nullish(),FirstClaimMode:zod.z.string().nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Hp=zod.z.object({MinAbsenceSeconds:zod.z.number().nullish(),Rewards:G.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Kp=zod.z.object({ComebackID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Tiers:zod.z.array(Hp).nullish(),ClaimCooldownSeconds:zod.z.number().nullish(),ClaimWindowSeconds:zod.z.number().nullish(),TrackPresenceOnRead:zod.z.boolean().nullish(),Gate:V.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),$p=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),CooldownSeconds:zod.z.number().nullish(),MaxClaimsPerWindow:zod.z.number().nullish(),WindowSeconds:zod.z.number().nullish(),TotalClaimLimit:zod.z.number().nullish()}).passthrough(),Zp=zod.z.object({ClaimID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Mode:zod.z.string().nullish(),Rewards:G.nullish(),Limits:ce.nullish(),PremiumLimitOverrides:zod.z.array($p).nullish(),Gate:V.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),gi=zod.z.object({TierRewards:Np.nullish(),MilestoneRewardMultiplier:Ut.nullish(),DailyCalendars:zod.z.record(zod.z.string(),Fp).nullish(),IdleAccruals:zod.z.record(zod.z.string(),Qp).nullish(),Comebacks:zod.z.record(zod.z.string(),Kp).nullish(),Claims:zod.z.record(zod.z.string(),Zp).nullish()}).passthrough(),bo=zod.z.object({RewardDefinitions:gi.nullish()}),zo=zod.z.object({Rewards:Gp.nullish()}),Ke={GetRewardDefinitions:"GetRewardDefinitions",GetUserRewardsState:"GetUserRewardsState",ClaimDailyReward:"ClaimDailyReward",CollectIdleAccrual:"CollectIdleAccrual",ClaimComebackReward:"ClaimComebackReward",ClaimReward:"ClaimReward",ClaimRewardsBatch:"ClaimRewardsBatch",GetMilestoneRewardMultiplier:"GetMilestoneRewardMultiplier"};var _s=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Reward",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getRewardDefinitions(e){return this.send(Ke.GetRewardDefinitions,e,bo)}getUserRewardsState(e){return this.send(Ke.GetUserRewardsState,e,zo)}getMilestoneRewardMultiplier(e){return this.send(Ke.GetMilestoneRewardMultiplier,e,Do)}claimDailyReward(e){return this.send(Ke.ClaimDailyReward,e,yo)}collectIdleAccrual(e){return this.send(Ke.CollectIdleAccrual,e,Co)}claimComebackReward(e){return this.send(Ke.ClaimComebackReward,e,So)}claimReward(e){return this.send(Ke.ClaimReward,e,xo)}};var Ws=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Quest",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getQuestDefinitions(e){return this.send(Ee.GetQuestDefinitions,e,Et)}getUserQuestState(e){return this.send(Ee.GetUserQuestState,e,Wi)}refreshQuestCycles(e){return this.send(Ee.RefreshQuestCycles,e,Se)}claimQuestReward(e){return this.send(Ee.ClaimQuestReward,e,Er)}claimQuestRewardsBatch(e){return this.send(Ee.ClaimQuestRewardsBatch,e,Hi)}claimMilestoneReward(e){return this.send(Ee.ClaimMilestoneReward,e,Lr)}claimMilestoneRewardsBatch(e){return this.send(Ee.ClaimMilestoneRewardsBatch,e,Ki)}claimGroupCompletionReward(e){return this.send(Ee.ClaimGroupCompletionReward,e,Vi)}addQuestProgress(e){return this.send(Ee.AddQuestProgress,e,Qi)}};var vo=zod.z.object({}).passthrough().transform(u=>u);var Jp=zod.z.object({Order:zod.z.number().nullish(),Type:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),BonusMultiplier:zod.z.number().nullish()}).passthrough(),Yp=zod.z.object({Schedule:zod.z.array(Jp).nullish(),RepeatCycle:zod.z.boolean().nullish(),MaxCycles:zod.z.number().nullish()}).passthrough(),Xp=zod.z.object({IsActive:zod.z.boolean().nullish(),CurrentPhaseEndUtc:a.nullish(),NextBonusStartUtc:a.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentPhaseIndex:zod.z.number().nullish(),ActiveBonusMultiplier:zod.z.number().nullish()}).passthrough(),ed=zod.z.object({Milestones:pe.nullish()}).passthrough(),Ri=zod.z.object({DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Category:zod.z.string().nullish(),Token:st.nullish(),TokenSources:zod.z.array(We).nullish(),ClaimMode:zod.z.string().nullish(),Milestones:zod.z.record(zod.z.string(),ye).nullish(),Presets:ed.nullish(),BonusWindow:Yp.nullish()}).passthrough(),td=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Content:Ri.nullish(),ClaimGraceHours:zod.z.number().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),sd=zod.z.object({TimedEventID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Schedule:ue.nullish(),Content:Ri.nullish(),Events:zod.z.array(td).nullish(),Gate:V.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),rd=zod.z.object({MaxConcurrentEvents:zod.z.number().nullish()}).passthrough(),id=zod.z.object({Milestones:zod.z.record(zod.z.string(),Ye).nullish()}).passthrough(),Vs=zod.z.object({Definitions:zod.z.record(zod.z.string(),sd).nullish(),Settings:rd.nullish(),Presets:id.nullish()}).passthrough(),nd=zod.z.object({Type:Dt,TimedEventID:zod.z.string(),CurrentChainedEventID:zod.z.string().nullish(),Content:Ri.nullish(),Progress:vo.nullish(),ComputedStartUtc:a.nullish(),ComputedEndUtc:a.nullish(),CanEarn:zod.z.boolean().nullish(),CanClaim:zod.z.boolean().nullish(),NextMilestone:ye.nullish(),BonusWindow:Xp.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentEventOrder:zod.z.number().nullish(),TotalEventsInChain:zod.z.number().nullish()}).passthrough(),To=zod.z.object({ActiveEvents:zod.z.array(nd).nullish()}).passthrough(),Po=zod.z.object({Tokens:zod.z.record(zod.z.string(),vo).nullish()}),yi=zod.z.object({Type:Dt.nullish(),LteID:zod.z.string().nullish(),Resources:x.nullish()}),Ci=zod.z.object({Type:Dt.nullish(),LteID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Rewards:x.nullish()}),od=zod.z.object({Type:Dt.nullish(),LteID:zod.z.string().nullish(),Resources:x.nullish()}),Si=zod.z.array(te(Ci)),Io=zod.z.array(te(yi)),Mo=zod.z.array(te(od)),Be={GetActiveEvents:"GetActiveEvents",GrantTokens:"GrantTokens",SpendTokens:"SpendTokens",ClaimMilestone:"ClaimMilestone",GetDefinitions:"GetDefinitions",GetUserLteState:"GetUserLteState",ClaimMilestonesBatch:"ClaimMilestonesBatch",ClaimAllMilestones:"ClaimAllMilestones",SpendTokensBatch:"SpendTokensBatch",GrantTokensBatch:"GrantTokensBatch"};var Qs=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"TimedEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getActiveEvents(e){return this.send(Be.GetActiveEvents,e,To)}getDefinitions(e){return this.send(Be.GetDefinitions,e,Vs)}getUserLteState(e){return this.send(Be.GetUserLteState,e,Po)}grantTokens(e){return this.send(Be.GrantTokens,e,x)}spendTokens(e){return this.send(Be.SpendTokens,e,yi)}claimMilestone(e){return this.send(Be.ClaimMilestone,e,Ci)}claimMilestonesBatch(e){return this.send(Be.ClaimMilestonesBatch,e,Si)}claimAllMilestones(e){return this.send(Be.ClaimAllMilestones,e,Si)}spendTokensBatch(e){return this.send(Be.SpendTokensBatch,e,Io)}grantTokensBatch(e){return this.send(Be.GrantTokensBatch,e,Mo)}};var ad=zod.z.object({UserID:zod.z.string(),Score:k.nullish(),Rank:zod.z.number().nullish(),LastScoreUpdateUtc:a.nullish(),IpHash:zod.z.string().nullish(),PublicProfile:Ce.nullish(),SeasonTierAtCycleEnd:zod.z.number().nullish()}).passthrough(),Tt=zod.z.object({LeaderboardID:zod.z.string(),CycleVersion:zod.z.number().nullish(),TotalParticipants:k.nullish(),CycleEndUtc:a.nullish(),TopUsers:zod.z.array(ad).nullish(),BracketID:zod.z.string().nullish()}),ld=zod.z.object({CycleKey:zod.z.string().nullish(),CycleEndUtc:a.nullish(),ClaimDeadlineUtc:a.nullish(),MilestoneTokensEarned:k.nullish(),ClaimableMilestoneIDs:zod.z.array(zod.z.string()).nullish(),CycleIndex:zod.z.number().nullish(),ChainedEventID:zod.z.string().nullish()}).passthrough(),Hs=zod.z.object({LeaderboardID:zod.z.string(),CurrentScore:k.nullish(),LastKnownRank:zod.z.number().nullish(),HasUnclaimedReward:zod.z.boolean().nullish(),ScoreEarnedThisCycle:k.nullish(),MilestoneTokensEarned:k.nullish(),NextMilestone:ye.nullish(),HasUnclaimedMilestone:zod.z.boolean().nullish(),ClaimableGraceCycles:zod.z.array(ld).nullish()}),Ks=zod.z.object({LeaderboardID:zod.z.string(),NewScore:k,CycleVersion:zod.z.number()}),$s=zod.z.object({ServerTimeUtc:a,LeaderboardID:zod.z.string(),Rank:zod.z.number().nullish(),Resources:x.nullish()}),Zs=zod.z.object({ServerTimeUtc:a,LeaderboardID:zod.z.string(),MilestoneID:zod.z.string(),Resources:x.nullish()}),ko=zod.z.array(te(Tt)),Ao=zod.z.array(te(Hs)),Oo=zod.z.array(te($s)),Bo=zod.z.array(te(Zs)),Uo=zod.z.array(te(Ks)),ud=zod.z.object({LeaderboardID:zod.z.string(),CycleReward:te($s).nullish(),Milestones:zod.z.array(te(Zs)).nullish()}),wo=zod.z.array(ud),cd=zod.z.object({LeaderboardID:zod.z.string(),Leaderboard:te(Tt).nullish(),Progress:te(Hs).nullish()}),qo=zod.z.array(cd),pd=zod.z.string(),Eo=zod.z.object({Rank:zod.z.string().nullish(),Rewards:G.nullish(),SeasonTierRewards:wr.nullish()}).passthrough(),dd=zod.z.object({RankRewards:zod.z.array(Eo).nullish()}).passthrough(),md=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),hd=zod.z.object({Milestones:pe.nullish(),RankRewards:pe.nullish()}).passthrough(),fd=zod.z.object({LeaderboardID:zod.z.string(),DisplayName:zod.z.string().nullish(),ScoreDisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),IsEnabled:zod.z.boolean().nullish(),ScoreAggregation:pd.nullish(),Schedule:ue.nullish(),ChainEvents:zod.z.array(md).nullish(),Gate:V.nullish(),TopUsersLimit:zod.z.number().nullish(),MinScoreToEnterTop:zod.z.number().nullish(),BracketSize:zod.z.number().nullish(),LinkedSeasonChainID:zod.z.string().nullish(),RankRewards:zod.z.array(Eo).nullish(),Milestones:zod.z.record(zod.z.string(),ye).nullish(),Presets:hd.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneClaimGraceHours:zod.z.number().nullish(),ScoreSources:zod.z.array(We).nullish()}).passthrough(),gd=zod.z.object({Milestones:zod.z.record(zod.z.string(),Ye).nullish(),RankRewards:zod.z.record(zod.z.string(),dd).nullish()}).passthrough(),Js=zod.z.object({Definitions:zod.z.record(zod.z.string(),fd).nullish(),Presets:gd.nullish()}).passthrough(),fe={GetDefinitions:"GetDefinitions",GetLeaderboard:"GetLeaderboard",GetMyProgress:"GetMyProgress",SubmitScore:"SubmitScore",SubmitScoreFromSource:"SubmitScoreFromSource",ClaimCycleReward:"ClaimCycleReward",ClaimMilestone:"ClaimMilestone",GetFriendsLeaderboard:"GetFriendsLeaderboard",GetLeaderboardsBatch:"GetLeaderboardsBatch",GetProgressBatch:"GetProgressBatch",ClaimCycleRewardsBatch:"ClaimCycleRewardsBatch",ClaimMilestonesBatch:"ClaimMilestonesBatch",SubmitScoresBatch:"SubmitScoresBatch",ClaimAllRewardsBatch:"ClaimAllRewardsBatch",GetOverviewBatch:"GetOverviewBatch"};var Ys=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Leaderboard",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(fe.GetDefinitions,e,Js)}getLeaderboard(e){return this.send(fe.GetLeaderboard,e,Tt)}getMyProgress(e){return this.send(fe.GetMyProgress,e,Hs)}submitScore(e){return this.send(fe.SubmitScore,e,Ks)}submitScoreFromSource(e){return this.send(fe.SubmitScoreFromSource,e,Ks)}claimCycleReward(e){return this.send(fe.ClaimCycleReward,e,$s)}claimMilestone(e){return this.send(fe.ClaimMilestone,e,Zs)}getFriendsLeaderboard(e){return this.send(fe.GetFriendsLeaderboard,e,Tt)}getLeaderboardsBatch(e){return this.send(fe.GetLeaderboardsBatch,e,ko)}getProgressBatch(e){return this.send(fe.GetProgressBatch,e,Ao)}claimCycleRewardsBatch(e){return this.send(fe.ClaimCycleRewardsBatch,e,Oo)}claimMilestonesBatch(e){return this.send(fe.ClaimMilestonesBatch,e,Bo)}submitScoresBatch(e){return this.send(fe.SubmitScoresBatch,e,Uo)}claimAllRewardsBatch(e){return this.send(fe.ClaimAllRewardsBatch,e,wo)}getOverviewBatch(e){return this.send(fe.GetOverviewBatch,e,qo)}};var xi=zod.z.object({}).passthrough().transform(u=>u),Lo=zod.z.object({SeasonChainID:zod.z.string(),CycleIndex:zod.z.number().nullish(),Season:zod.z.lazy(()=>Fo).nullish(),ComputedStartUtc:a.nullish(),ComputedEndUtc:a.nullish(),SecondsRemaining:k.nullish(),UserState:xi.nullish(),NextTier:zod.z.lazy(()=>jo).nullish()}).passthrough(),Go=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),AmountGranted:k.nullish(),NewStatusTokens:k.nullish(),OldTier:zod.z.number().nullish(),NewTier:zod.z.number(),TierUp:zod.z.boolean().nullish()}),No=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),TierNumber:zod.z.number(),Resources:x.nullish()});var jo=zod.z.object({Tier:zod.z.number().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),RequiredTokens:k.nullish(),TierReachedReward:G.nullish()}).passthrough(),Fo=zod.z.object({SeasonID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:k.nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Tiers:zod.z.array(jo).nullish(),LinkedCollectionID:zod.z.string().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough();var Rd=zod.z.object({SeasonChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:ue.nullish(),Seasons:zod.z.array(Fo).nullish(),GrantTokensAccessMode:zod.z.string().nullish(),Gate:V.nullish()}).passthrough(),Xs=zod.z.object({Chains:zod.z.record(zod.z.string(),Rd).nullish()}).passthrough(),it={GetDefinitions:"GetDefinitions",GetActiveSeason:"GetActiveSeason",GetUserState:"GetUserState",GrantStatusTokens:"GrantStatusTokens",ClaimTierReward:"ClaimTierReward"};var er=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Season",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(it.GetDefinitions,e,Xs)}getActiveSeason(e){return this.send(it.GetActiveSeason,e,Lo)}getUserState(e){return this.send(it.GetUserState,e,xi)}grantStatusTokens(e){return this.send(it.GrantStatusTokens,e,Go)}claimTierReward(e){return this.send(it.ClaimTierReward,e,No)}};var yd={Apple:"Apple",Google:"Google"},_o=zod.z.object({}).passthrough().transform(u=>u),Cd=zod.z.object({PremiumID:zod.z.string().nullish(),PurchaseDate:zod.z.string().nullish(),ExpirationDate:zod.z.string().nullish(),TransactionID:zod.z.string().nullish(),IsAutoRenewEnabled:zod.z.boolean().nullish()}).passthrough(),Sd=zod.z.object({OptionID:zod.z.string().nullish(),Name:zod.z.string().nullish(),RequiredResources:H.nullish()}).passthrough(),xd=zod.z.object({PremiumID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Tier:zod.z.number().nullish(),DurationDays:zod.z.number().nullish(),TrialDurationDays:zod.z.number().nullish(),PriceOptions:zod.z.record(zod.z.string(),Sd).nullish(),AppleProductID:zod.z.string().nullish(),GoogleProductID:zod.z.string().nullish(),Benefits:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Di=zod.z.object({Definitions:zod.z.record(zod.z.string(),xd).nullish()}).passthrough(),Wo=zod.z.object({Premium:Di.nullish()}),Vo=zod.z.object({ServerTimeUtc:a.nullish(),Premium:_o.nullish()}),tr=zod.z.object({ServerTimeUtc:a.nullish(),Premium:_o.nullish(),Subscription:Cd.nullish(),Resources:x.nullish()}),nt={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateTrial:"ActivateTrial",PurchaseWithResources:"PurchaseWithResources",PurchaseRealMoney:"PurchaseRealMoney"};var sr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Premium",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(nt.GetDefinitions,e,Wo)}getUserState(e){return this.send(nt.GetUserState,e,Vo)}activateTrial(e){return this.send(nt.ActivateTrial,e,tr)}purchaseItemOrCurrency(e){return this.send(nt.PurchaseWithResources,e,tr)}purchaseRealMoney(e){return this.send(nt.PurchaseRealMoney,e,tr)}};var rr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Character",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getCharacterDefinitions(e){return this.send(Te.GetCharacterDefinitions,e,bs)}getUserCharacters(e){return this.send(Te.GetUserCharacters,e,fn)}unlockCharacter(e){return this.send(Te.UnlockCharacter,e,Jr)}upgradeStatLevel(e){return this.send(Te.UpgradeStatLevel,e,$r)}upgradeCharacterLevel(e){return this.send(Te.UpgradeCharacterLevel,e,Zr)}equipItems(e){return this.send(Te.EquipItems,e,gn)}unequipItems(e){return this.send(Te.UnequipItems,e,Rn)}unequipAllCharacters(e){return this.send(Te.UnequipAllCharacters,e,yn)}unlockCharactersBatch(e){return this.send(Te.UnlockCharactersBatch,e,Cn)}upgradeCharacterLevelsBatch(e){return this.send(Te.UpgradeCharacterLevelsBatch,e,Sn)}upgradeStatLevelsBatch(e){return this.send(Te.UpgradeStatLevelsBatch,e,xn)}};var ir=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Match",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}createMatch(e){return this.send(Ne.CreateMatch,e,Wn)}updateMatch(e){return this.send(Ne.UpdateMatch,e,Vn)}cancelMatch(e){return this.send(Ne.CancelMatch,e,Qn)}instantBattle(e){return this.send(Ne.InstantBattle,e,Hn)}saveStrategy(e){return this.send(Ne.SaveStrategy,e,Se)}getMyMatches(e){return this.send(Ne.GetMyMatches,e,ii)}getAvailableMatches(e){return this.send(Ne.GetAvailableMatches,e,ii)}getDefinitions(e){return this.send(Ne.GetDefinitions,e,Jn)}};var Dd={TradeUpRarity:"TradeUpRarity",TradeUpCollection:"TradeUpCollection"},Qo=zod.z.enum(["TradeUpRarity","TradeUpCollection"]),bd=zod.z.object({Index:zod.z.number().nullish(),BurnedItemIDs:zod.z.array(zod.z.string()).nullish(),RolledCollectionID:zod.z.string().nullish(),UsedCollections:zod.z.record(zod.z.string(),zod.z.number()).nullish(),Output:Ur.nullish()}),Ho=zod.z.object({ServerTimeUtc:a,Type:Qo.nullish(),CraftID:zod.z.string(),CraftedCount:zod.z.number().nullish(),SelectedOptionID:zod.z.string().nullish(),InputRarity:zod.z.string().nullish(),OutputRarity:zod.z.string().nullish(),Resources:x.nullish(),Results:zod.z.array(bd).nullish()}),zd=zod.z.object({OptionID:zod.z.string().nullish(),RequiredResources:H.nullish()}).passthrough(),vd=zod.z.object({CraftID:zod.z.string().nullish(),Type:Qo.nullish(),CatalogID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),InputRarityID:zod.z.string().nullish(),OutputRarityID:zod.z.string().nullish(),RequiredItemCount:zod.z.number().nullish(),PriceOptions:zod.z.record(zod.z.string(),zd).nullish()}).passthrough(),bi=zod.z.object({Definitions:zod.z.record(zod.z.string(),vd).nullish()}).passthrough(),Ko=zod.z.object({ServerTimeUtc:a.nullish(),CraftDefinitions:bi.nullish()}),nr={GetDefinitions:"GetDefinitions",Craft:"Craft"};var or=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Craft",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(nr.GetDefinitions,e,Ko)}craft(e){return this.send(nr.Craft,e,Ho)}};var Td={Pending:"Pending",Accepted:"Accepted",Declined:"Declined",Cancelled:"Cancelled",Expired:"Expired"},Pd=zod.z.enum(["Pending","Accepted","Declined","Cancelled","Expired"]),$o=zod.z.object({}).passthrough().transform(u=>u),ar=zod.z.object({CollectibleID:zod.z.string(),Rarity:zod.z.number().nullish(),IsSpecial:zod.z.boolean().nullish(),IsDuplicate:zod.z.boolean().nullish(),CollectionCurrencyConverted:zod.z.number().nullish()}),Zo=zod.z.object({GrantedCollectibles:zod.z.array(ar).nullish(),DuplicateCollectibles:zod.z.array(ar).nullish(),CollectionCurrencyEarned:k.nullish(),NewCollectionCurrencyBalance:k.nullish(),NewlyCompletedSetIDs:zod.z.array(zod.z.string()).nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:x.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),Jo=zod.z.object({GrantedCollectibles:zod.z.array(ar).nullish(),DuplicateCollectibles:zod.z.array(ar).nullish(),CollectionCurrencyEarned:k.nullish(),NewCollectionCurrencyBalance:k.nullish(),Resources:x.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),Yo=zod.z.object({GrantedCollectibleID:zod.z.string().nullish(),NewlyCompletedSetID:zod.z.string().nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:x.nullish()}),zi=zod.z.object({SetID:zod.z.string(),Resources:x.nullish()}),Xo=zod.z.array(te(zi)),ea=zod.z.object({Resources:x.nullish()}),Id=zod.z.object({OfferID:zod.z.string(),TitleID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderPublicData:Ce.nullish(),OfferedCollectibleID:zod.z.string().nullish(),OfferedCollectibleIsSpecial:zod.z.boolean().nullish(),ReceiverUserID:zod.z.string().nullish(),RequestedCollectibleID:zod.z.string().nullish(),RequestedCollectibleIsSpecial:zod.z.boolean().nullish(),Status:Pd.nullish(),CreatedAtUtc:a.nullish(),ExpiresAtUtc:a.nullish(),RespondedAtUtc:a.nullish(),DeclineReason:zod.z.string().nullish(),IsSpecialTradeEvent:zod.z.boolean().nullish(),SpecialTradeEventID:zod.z.string().nullish()}).passthrough(),ta=zod.z.object({OfferID:zod.z.string(),ExpiresAtUtc:a.nullish(),Resources:x.nullish()}),sa=zod.z.object({OfferID:zod.z.string(),Resources:x.nullish()}),ra=zod.z.object({OfferID:zod.z.string(),ReceivedCollectibleID:zod.z.string().nullish(),ReceivedIsSpecial:zod.z.boolean().nullish(),SentCollectibleID:zod.z.string().nullish(),SentCollectibleIsSpecial:zod.z.boolean().nullish(),Transfer:zod.z.unknown().nullish()}),ia=zod.z.object({OfferID:zod.z.string(),Resources:x.nullish()}),vi=zod.z.object({Offers:zod.z.array(Id).nullish()}),Md=zod.z.object({CollectibleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rarity:zod.z.number().nullish(),HasSpecialVersion:zod.z.boolean().nullish(),SortOrder:zod.z.number().nullish()}).passthrough(),kd=zod.z.object({SetID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),SortOrder:zod.z.number().nullish(),Collectibles:zod.z.array(Md).nullish(),SetCompletionReward:G.nullish()}).passthrough(),Ad=zod.z.object({CollectionID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),SeasonChainID:zod.z.string().nullish(),Sets:zod.z.array(kd).nullish(),GrandPrize:G.nullish()}).passthrough(),na=zod.z.object({BonusRewardSlots:pe.nullish(),PityRules:pe.nullish()}).passthrough(),Od=zod.z.object({PackTypeID:zod.z.string().nullish(),Cost:H.nullish(),BonusRewardSlots:zod.z.array(ft).nullish(),PityRules:zod.z.array(gt).nullish(),Presets:na.nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CollectibleCount:zod.z.number().nullish(),GuaranteedMinRarity:zod.z.number().nullish(),GuaranteeMaxRarity:zod.z.boolean().nullish(),RarityWeights:zod.z.record(zod.z.string(),zod.z.number()).nullish(),ColorTier:zod.z.number().nullish()}).passthrough(),Bd=zod.z.object({Rarity:zod.z.number().nullish(),CollectionCurrencyGranted:zod.z.number().nullish()}).passthrough(),Ud=zod.z.object({CollectionChestID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CollectionCurrencyCost:zod.z.number().nullish(),MinCollectibleCount:zod.z.number().nullish(),MaxCollectibleCount:zod.z.number().nullish(),GuaranteedMinRarity:zod.z.number().nullish(),BonusRewardSlots:zod.z.array(ft).nullish(),PityRules:zod.z.array(gt).nullish(),Presets:na.nullish(),Tier:zod.z.number().nullish()}).passthrough(),wd=zod.z.object({SpecialTradeEventID:zod.z.string().nullish(),StartUtc:a.nullish(),EndUtc:a.nullish(),AllowedSpecialCollectibleIDs:zod.z.array(zod.z.string()).nullish(),SpecialTradeEventDailyTradeLimit:zod.z.number().nullish()}).passthrough(),lr=zod.z.object({Collections:zod.z.record(zod.z.string(),Ad).nullish(),PackTypes:zod.z.record(zod.z.string(),Od).nullish(),CollectionChests:zod.z.array(Ud).nullish(),DuplicateConversions:zod.z.array(Bd).nullish(),DailyTradeLimit:zod.z.number().nullish(),CollectibleJokerCatalogID:zod.z.string().nullish(),CollectibleJokerItemID:zod.z.string().nullish(),SpecialTradeEvents:zod.z.array(wd).nullish(),RewardPools:Ns.nullish()}).passthrough(),xe={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",OpenPack:"OpenPack",OpenCollectionChest:"OpenCollectionChest",UseCollectibleJoker:"UseCollectibleJoker",ClaimSetReward:"ClaimSetReward",ClaimSetRewardsBatch:"ClaimSetRewardsBatch",ClaimGrandPrize:"ClaimGrandPrize",SendTradeOffer:"SendTradeOffer",CancelTradeOffer:"CancelTradeOffer",AcceptTradeOffer:"AcceptTradeOffer",DeclineTradeOffer:"DeclineTradeOffer",GetMyTradeOffers:"GetMyTradeOffers",GetIncomingTradeOffers:"GetIncomingTradeOffers"};var ur=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Collection",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(xe.GetDefinitions,e,lr)}getUserState(e){return this.send(xe.GetUserState,e,$o)}openPack(e){return this.send(xe.OpenPack,e,Zo)}openCollectionChest(e){return this.send(xe.OpenCollectionChest,e,Jo)}useCollectibleJoker(e){return this.send(xe.UseCollectibleJoker,e,Yo)}claimSetReward(e){return this.send(xe.ClaimSetReward,e,zi)}claimSetRewardsBatch(e){return this.send(xe.ClaimSetRewardsBatch,e,Xo)}claimGrandPrize(e){return this.send(xe.ClaimGrandPrize,e,ea)}sendTradeOffer(e){return this.send(xe.SendTradeOffer,e,ta)}cancelTradeOffer(e){return this.send(xe.CancelTradeOffer,e,sa)}acceptTradeOffer(e){return this.send(xe.AcceptTradeOffer,e,ra)}declineTradeOffer(e){return this.send(xe.DeclineTradeOffer,e,ia)}getMyTradeOffers(e){return this.send(xe.GetMyTradeOffers,e,vi)}getIncomingTradeOffers(e){return this.send(xe.GetIncomingTradeOffers,e,vi)}};var qd=zod.z.object({}).passthrough().transform(u=>u),Ed={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},Ld={Active:"Active",Left:"Left",Replaced:"Replaced"},Gd=zod.z.object({ObjectIndex:zod.z.number().nullish(),ObjectCompletionRewardClaimed:zod.z.boolean().nullish()}).passthrough(),Nd=zod.z.object({UserID:zod.z.string().nullish(),PublicData:Ce.nullish(),BuildObjectsProgress:Gd.nullish(),IsBot:zod.z.boolean().nullish(),SpinsCount:zod.z.number().nullish(),TokensSpent:zod.z.number().nullish(),MemberStatus:zod.z.string().nullish(),GrandPrizeClaimed:zod.z.boolean().nullish(),JoinedAtUtc:a.nullish(),LeftAtUtc:a.nullish()}).passthrough(),jd=zod.z.object({Index:zod.z.number().nullish(),OwnerUserID:zod.z.string().nullish(),CurrentProgress:zod.z.number().nullish(),MaxProgress:zod.z.number().nullish(),IsCompleted:zod.z.boolean().nullish()}).passthrough(),Fd=zod.z.object({Objects:zod.z.array(jd).nullish()}).passthrough(),oa=zod.z.object({GroupID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CoopChainID:zod.z.string().nullish(),CoopEventID:zod.z.string().nullish(),CycleIndex:zod.z.number().nullish(),Members:zod.z.array(Nd).nullish(),BuildObjectsState:Fd.nullish(),Status:zod.z.string().nullish(),CreatedAtUtc:a.nullish(),ExpiresAtUtc:a.nullish(),Version:zod.z.number().nullish()}).passthrough(),aa=zod.z.object({CoopChainID:zod.z.string()}).passthrough(),_d=zod.z.string(),la=zod.z.object({DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Weight:zod.z.number().nullish(),MinProgress:zod.z.number().nullish(),MaxProgress:zod.z.number().nullish()}).passthrough(),Wd=zod.z.object({Index:zod.z.number().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),MaxProgress:zod.z.number().nullish(),CompletionReward:G.nullish()}).passthrough(),Vd=zod.z.object({Objects:zod.z.array(Wd).nullish(),SpinCost:H.nullish(),SpinnerTable:zod.z.array(la).nullish()}).passthrough(),Qd=zod.z.object({CoopEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),EventType:_d.nullish(),PartnerCount:zod.z.number().nullish(),MatchmakingTimeoutMinutes:zod.z.number().nullish(),MemberGracePeriodMinutes:zod.z.number().nullish(),BuildObjects:Vd.nullish(),GrandPrize:G.nullish()}).passthrough(),Hd=zod.z.object({CoopChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:ue.nullish(),Events:zod.z.array(Qd).nullish(),Gate:V.nullish()}).passthrough(),ua=zod.z.object({ServerTimeUtc:a.nullish(),UserState:qd.nullish(),ActiveGroup:oa.nullish()}),Ti=zod.z.object({ServerTimeUtc:a.nullish(),Group:oa.nullish(),SecondsRemaining:k.nullish()}),ca=zod.z.object({ServerTimeUtc:a.nullish(),GroupID:zod.z.string().nullish(),Resources:x.nullish(),ObjectIndex:zod.z.number().nullish(),Sector:la.nullish(),ProgressDelta:zod.z.number().nullish(),NewProgress:k.nullish(),MaxProgress:k.nullish(),ObjectCompleted:zod.z.boolean().nullish(),AllObjectsCompleted:zod.z.boolean().nullish()}),Pi=zod.z.object({ServerTimeUtc:a.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),Resources:x.nullish()}),pa=zod.z.object({ServerTimeUtc:a.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),cr=zod.z.object({Chains:zod.z.record(zod.z.string(),Hd).nullish()}).passthrough(),Ge={GetDefinitions:"GetDefinitions",GetActiveEvent:"GetActiveEvent",GetUserState:"GetUserState",GetGroupState:"GetGroupState",JoinOrCreateGroup:"JoinOrCreateGroup",Spin:"Spin",ClaimObjectReward:"ClaimObjectReward",ClaimGrandPrize:"ClaimGrandPrize",LeaveGroup:"LeaveGroup"};var pr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"CoopEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ge.GetDefinitions,e,cr)}getActiveEvent(e){return this.send(Ge.GetActiveEvent,e,aa)}getUserState(e){return this.send(Ge.GetUserState,e,ua)}getGroupState(e){return this.send(Ge.GetGroupState,e,Ti)}joinOrCreateGroup(e){return this.send(Ge.JoinOrCreateGroup,e,Ti)}spin(e){return this.send(Ge.Spin,e,ca)}claimObjectReward(e){return this.send(Ge.ClaimObjectReward,e,Pi)}claimGrandPrize(e){return this.send(Ge.ClaimGrandPrize,e,Pi)}leaveGroup(e){return this.send(Ge.LeaveGroup,e,pa)}};var Kd={Active:"Active",Exhausted:"Exhausted",Expired:"Expired",Dismissed:"Dismissed"},$d={Locked:"Locked",Available:"Available",InProgress:"InProgress",Completed:"Completed",Hidden:"Hidden"},Zd=zod.z.object({NodeID:zod.z.string().nullish(),Status:zod.z.string().nullish(),ExecutionCount:zod.z.number().nullish(),UnlockedAtUtc:a.nullish(),CompletedAtUtc:a.nullish(),LastExecutedAtUtc:a.nullish(),NextAvailableAtUtc:a.nullish(),LastExecutionRefID:zod.z.string().nullish()}).passthrough(),Jd=zod.z.object({TrackID:zod.z.string().nullish(),CurrentValue:zod.z.number().nullish(),LastUpdatedUtc:a.nullish()}).passthrough(),da=zod.z.object({OfferID:zod.z.string().nullish(),InstanceKey:zod.z.string().nullish(),SourceOfferVersion:zod.z.number().nullish(),Status:zod.z.string().nullish(),ActivatedAtUtc:a.nullish(),ExhaustedAtUtc:a.nullish(),ExpiredAtUtc:a.nullish(),DismissedAtUtc:a.nullish(),ShowCount:zod.z.number().nullish(),LastShownAtUtc:a.nullish(),Nodes:zod.z.record(zod.z.string(),Zd).nullish(),Tracks:zod.z.record(zod.z.string(),Jd).nullish(),SelectedChoiceNodeID:zod.z.string().nullish()}).passthrough(),Yd=zod.z.object({SlotID:zod.z.string().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),ActiveOfferID:zod.z.string().nullish(),ActiveOfferStartedAtUtc:a.nullish(),ActiveOfferExpiresAtUtc:a.nullish(),ActiveOffer:da.nullish(),NextCycleStartsAtUtc:a.nullish(),LastUpdatedUtc:a.nullish(),DismissSkipAvailableAtUtc:a.nullish(),LastDismissedAtUtc:a.nullish()}).passthrough(),Xd=zod.z.object({TotalExecutions:zod.z.number().nullish(),DailyExecutions:zod.z.number().nullish(),DailyResetUtc:a.nullish()}).passthrough(),em=zod.z.object({TotalActivations:zod.z.number().nullish(),TotalExhausted:zod.z.number().nullish(),TotalExpired:zod.z.number().nullish(),TotalDismissed:zod.z.number().nullish(),TotalShows:zod.z.number().nullish(),LastShownAtUtc:a.nullish(),LastActivatedAtUtc:a.nullish(),LastExhaustedAtUtc:a.nullish(),NodeCounts:zod.z.record(zod.z.string(),Xd).nullish()}).passthrough(),tm=zod.z.object({Slots:zod.z.record(zod.z.string(),Yd).nullish(),OfferHistory:zod.z.record(zod.z.string(),em).nullish(),LastUpdatedUtc:a.nullish()}).passthrough();var sm=zod.z.object({Order:zod.z.number().nullish(),OfferID:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),DelayBeforeActivationSec:zod.z.number().nullish()}).passthrough(),rm=zod.z.object({SlotID:zod.z.string().nullish(),Enabled:zod.z.boolean().nullish(),SortOrder:zod.z.number().nullish(),Queue:zod.z.array(sm).nullish(),Schedule:ue.nullish(),Gate:V.nullish(),AllowDismissSkip:zod.z.boolean().nullish(),DismissSkipDelaySec:zod.z.number().nullish()}).passthrough(),im=zod.z.object({StoreOfferID:zod.z.string().nullish(),BillingProductID:zod.z.string().nullish(),DirectCost:H.nullish(),UseExternalRewards:zod.z.boolean().nullish()}).passthrough(),nm=zod.z.object({AdPlacementID:zod.z.string().nullish(),ViewsRequiredToComplete:zod.z.number().nullish(),MaxViewsPerActivation:zod.z.number().nullish(),CooldownSecondsBetweenViews:zod.z.number().nullish(),RequireServerVerification:zod.z.boolean().nullish(),GrantRewardsPerView:zod.z.boolean().nullish()}).passthrough(),om=zod.z.object({Purchase:im.nullish(),RewardedVideo:nm.nullish()}).passthrough(),am=zod.z.object({TrackID:zod.z.string().nullish(),Operator:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),lm=zod.z.object({Milestones:pe.nullish()}).passthrough(),um=zod.z.object({TrackID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),RespectBounds:zod.z.boolean().nullish()}).passthrough(),cm=zod.z.object({TrackID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),StartValue:zod.z.number().nullish(),MinValue:zod.z.number().nullish(),MaxValue:zod.z.number().nullish(),ClampToMin:zod.z.boolean().nullish(),ClampToMax:zod.z.boolean().nullish(),HiddenFromUI:zod.z.boolean().nullish()}).passthrough(),pm=zod.z.object({RequiredCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredAnyCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredTracks:zod.z.array(am).nullish(),VisibleWhileLocked:zod.z.boolean().nullish()}).passthrough(),dm=zod.z.object({NodeID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),Type:zod.z.string().nullish(),Action:om.nullish(),Grants:G.nullish(),TrackChanges:zod.z.array(um).nullish(),MilestonePoints:zod.z.number().nullish(),UnlockRules:pm.nullish(),NextNodeIDs:zod.z.array(zod.z.string()).nullish(),ChoiceGroupID:zod.z.string().nullish(),Limits:ce.nullish(),HideWhenCompleted:zod.z.boolean().nullish(),ExhaustOfferOnComplete:zod.z.boolean().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Metadata:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),ma=zod.z.object({OfferID:zod.z.string().nullish(),Version:zod.z.number().nullish(),Enabled:zod.z.boolean().nullish(),GraphMode:zod.z.string().nullish(),Name:zod.z.string().nullish(),Description:zod.z.string().nullish(),RootNodeIDs:zod.z.array(zod.z.string()).nullish(),Nodes:zod.z.array(dm).nullish(),Tracks:zod.z.array(cm).nullish(),Milestones:zod.z.record(zod.z.string(),ye).nullish(),Presets:lm.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneToken:st.nullish(),ExhaustedWhenAllTerminalNodesCompleted:zod.z.boolean().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Metadata:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),mm=zod.z.object({Milestones:zod.z.record(zod.z.string(),Ye).nullish()}).passthrough(),Ii=zod.z.object({Slots:zod.z.record(zod.z.string(),rm).nullish(),Offers:zod.z.record(zod.z.string(),ma).nullish(),Presets:mm.nullish()}).passthrough(),ha=zod.z.object({DealOfferDefinitions:Ii.nullish()}),fa=zod.z.object({DealOffers:tm.nullish()}),hm=zod.z.object({EntityID:zod.z.string().nullish(),TotalEarned:zod.z.number().nullish(),ClaimedIDs:zod.z.array(zod.z.string()).nullish(),ReachedUnclaimedIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),fm=zod.z.object({SlotID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),OfferDef:ma.nullish(),ActivationState:da.nullish(),IsNewActivation:zod.z.boolean().nullish(),ComputedExpiresAtUtc:a.nullish(),Cost:H.nullish(),Milestone:hm.nullish()}).passthrough(),ga=zod.z.object({Slots:zod.z.array(fm).nullish()}),Ra=zod.z.object({ServerTimeUtc:a.nullish(),SlotID:zod.z.string().nullish(),NodeID:zod.z.string().nullish(),NodeCompleted:zod.z.boolean().nullish(),OfferExhausted:zod.z.boolean().nullish(),Idempotent:zod.z.boolean().nullish(),Resources:x.nullish()}),ya=zod.z.object({ServerTimeUtc:a.nullish(),SlotID:zod.z.string().nullish(),Resources:x.nullish()}),Ca=zod.z.object({ServerTimeUtc:a.nullish(),SlotID:zod.z.string().nullish(),Resources:x.nullish()}),Sa=zod.z.object({ServerTimeUtc:a.nullish(),SlotID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:x.nullish()}),xa=zod.z.object({ServerTimeUtc:a.nullish(),SlotID:zod.z.string().nullish(),ClaimedIDs:zod.z.array(zod.z.string()).nullish(),Rejected:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Resources:x.nullish()}),Fe={GetDefinition:"GetDefinition",GetUserState:"GetUserState",GetActiveDeals:"GetActiveDeals",DismissDeal:"DismissDeal",ExecuteNode:"ExecuteNode",RecordShow:"RecordShow",ClaimMilestone:"ClaimMilestone",ClaimMilestonesBatch:"ClaimMilestonesBatch"};var dr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"DealOffer",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinition(e){return this.send(Fe.GetDefinition,e,ha)}getUserState(e){return this.send(Fe.GetUserState,e,fa)}getActiveDeals(e){return this.send(Fe.GetActiveDeals,e,ga)}dismissDeal(e){return this.send(Fe.DismissDeal,e,ya)}executeNode(e){return this.send(Fe.ExecuteNode,e,Ra)}recordShow(e){return this.send(Fe.RecordShow,e,Ca)}claimMilestone(e){return this.send(Fe.ClaimMilestone,e,Sa)}claimMilestonesBatch(e){return this.send(Fe.ClaimMilestonesBatch,e,xa)}};var gm=zod.z.object({}).passthrough().transform(u=>u),Rm=zod.z.object({FeatureKey:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Percent:zod.z.number().nullish(),SourceCurrencyID:zod.z.string().nullish(),TargetCurrencyID:zod.z.string().nullish()}).passthrough(),Mi=zod.z.object({IsEnabled:zod.z.boolean().nullish(),ActivationReward:G.nullish(),InviteRewards:zod.z.record(zod.z.string(),ye).nullish(),SpendRewards:zod.z.array(Rm).nullish()}).passthrough(),Da=zod.z.object({ReferralDefinitions:Mi.nullish()}),ba=zod.z.object({Referral:gm.nullish()}),za=zod.z.object({ReferralCode:zod.z.string().nullish(),IsFirstActivation:zod.z.boolean().nullish(),Resources:x.nullish()}),va=zod.z.object({RewardID:zod.z.string().nullish(),Resources:x.nullish()}),Rt={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateReferralCode:"ActivateReferralCode",ClaimInviteReward:"ClaimInviteReward"};var mr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Referral",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Rt.GetDefinitions,e,Da)}getUserState(e){return this.send(Rt.GetUserState,e,ba)}activateReferralCode(e){return this.send(Rt.ActivateReferralCode,e,za)}claimInviteReward(e){return this.send(Rt.ClaimInviteReward,e,va)}};var ym={RequestSent:"RequestSent",Accepted:"Accepted",Declined:"Declined",Removed:"Removed"},Cm={Attack:"Attack",Raid:"Raid",FriendAdd:"FriendAdd"},Sm=zod.z.object({UserID:zod.z.string(),PublicData:Ce.nullish()}),xm=zod.z.object({OwnerUserID:zod.z.string().nullish(),ActorUserID:zod.z.string().nullish(),ActorProfile:Ce.nullish(),Type:zod.z.string().nullish(),CreatedAt:a.nullish(),OwnerImpact:x.nullish(),IsBlocked:zod.z.boolean().nullish(),TargetObjectName:zod.z.string().nullish()}).passthrough(),hr=zod.z.object({Friends:zod.z.array(Sm).nullish()}),Pt=zod.z.object({TargetUserID:zod.z.string().nullish(),Status:zod.z.string().nullish()}),Ta=zod.z.object({Events:zod.z.array(xm).nullish()}),_e={GetFriendsList:"GetFriendsList",GetIncomingRequests:"GetIncomingRequests",GetRecommendedFriends:"GetRecommendedFriends",SendFriendRequest:"SendFriendRequest",AcceptFriendRequest:"AcceptFriendRequest",DeclineFriendRequest:"DeclineFriendRequest",RemoveFriend:"RemoveFriend",GetTimeline:"GetTimeline"};var fr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Social",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getFriendsList(e){return this.send(_e.GetFriendsList,e,hr)}getIncomingRequests(e){return this.send(_e.GetIncomingRequests,e,hr)}getRecommendedFriends(e){return this.send(_e.GetRecommendedFriends,e,hr)}sendFriendRequest(e){return this.send(_e.SendFriendRequest,e,Pt)}acceptFriendRequest(e){return this.send(_e.AcceptFriendRequest,e,Pt)}declineFriendRequest(e){return this.send(_e.DeclineFriendRequest,e,Pt)}removeFriend(e){return this.send(_e.RemoveFriend,e,Pt)}getTimeline(e){return this.send(_e.GetTimeline,e,Ta)}};var Dm={Replace:"Replace",Refresh:"Refresh",KeepBest:"KeepBest",Stack:"Stack"};var yt=zod.z.object({Target:zod.z.string().nullish(),Operation:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),bm=zod.z.object({BoostID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),ActivationCost:H.nullish(),Effect:yt.nullish(),DurationSeconds:zod.z.number().nullish(),Charges:zod.z.number().nullish(),StackingPolicy:zod.z.string().nullish(),MaxActiveInstances:zod.z.number().nullish(),Tags:zod.z.array(zod.z.string()).nullish()}).passthrough(),zm=zod.z.object({ScheduledBoostID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Tags:zod.z.array(zod.z.string()).nullish(),Schedule:ue.nullish(),Effects:zod.z.array(yt).nullish(),Gate:V.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),vm=zod.z.object({ChainedBoostID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Effects:zod.z.array(yt).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Tm=zod.z.object({ChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Schedule:ue.nullish(),Phases:zod.z.array(vm).nullish(),Gate:V.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Pm=zod.z.object({TriggeredBoostID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Tags:zod.z.array(zod.z.string()).nullish(),Sources:zod.z.array(We).nullish(),Effects:zod.z.array(yt).nullish(),DurationSeconds:zod.z.number().nullish(),Charges:zod.z.number().nullish(),StackingPolicy:zod.z.string().nullish(),MaxActiveInstances:zod.z.number().nullish(),Gate:V.nullish()}).passthrough(),Im=zod.z.object({MaxAddPercent:zod.z.number().nullish(),MaxMultiply:zod.z.number().nullish(),MaxAddFlat:zod.z.number().nullish()}).passthrough(),Mm=zod.z.object({StackingCaps:zod.z.record(zod.z.string(),Im).nullish()}).passthrough(),gr=zod.z.object({Definitions:zod.z.record(zod.z.string(),bm).nullish(),ScheduledBoosts:zod.z.record(zod.z.string(),zm).nullish(),BoostChains:zod.z.record(zod.z.string(),Tm).nullish(),TriggeredBoosts:zod.z.record(zod.z.string(),Pm).nullish(),Settings:Mm.nullish()}).passthrough(),Pa=zod.z.object({InstanceID:zod.z.string(),BoostID:zod.z.string(),ActivatedAtUtc:a.nullish(),ExpiresAtUtc:a.nullish(),RemainingCharges:zod.z.number().nullish(),EffectSnapshot:yt.nullish(),SourceType:zod.z.string().nullish(),SourceRef:zod.z.string().nullish()}).passthrough();zod.z.object({Date:a.nullish(),DailyCount:zod.z.number().nullish(),LastFiredUtc:a.nullish()}).passthrough();var Ia=zod.z.object({ServerTimeUtc:a.nullish(),Active:zod.z.record(zod.z.string(),Pa).nullish()}),Ma=zod.z.object({ServerTimeUtc:a.nullish(),BoostID:zod.z.string().nullish(),StackingPolicy:zod.z.string().nullish(),ActivatedBoost:Pa.nullish(),Resources:x.nullish()}),km={Scheduled:"Scheduled",Chain:"Chain"},Am=zod.z.object({Kind:zod.z.string().nullish(),SourceID:zod.z.string().nullish(),PhaseID:zod.z.string().nullish(),CycleIndex:zod.z.number().nullish(),PhaseOrder:zod.z.number().nullish(),StartUtc:a.nullish(),EndUtc:a.nullish(),Effects:zod.z.array(yt).nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),ka=zod.z.object({ServerTimeUtc:a.nullish(),Windows:zod.z.array(Am).nullish()}),ot={GetDefinitions:"GetDefinitions",GetActive:"GetActive",GetActiveWindows:"GetActiveWindows",Activate:"Activate",CleanupExpired:"CleanupExpired"};var Rr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"TimedBoost",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(ot.GetDefinitions,e,gr)}getActive(e){return this.send(ot.GetActive,e,Ia)}getActiveWindows(e){return this.send(ot.GetActiveWindows,e,ka)}activate(e){return this.send(ot.Activate,e,Ma)}cleanupExpired(e){return this.send(ot.CleanupExpired,e,Se)}};var yr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"UserCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getUserCustomDataDefinitions(e){return this.send(Le.GetUserCustomDataDefinitions,e,fs)}getMyUserCustomData(e){return this.send(Le.GetMyUserCustomData,e,sn)}getPublicUserCustomDataOf(e){return this.send(Le.GetPublicUserCustomDataOf,e,Wr)}setPrivateData(e){return this.send(Le.SetPrivateData,e,Vr)}setPublicData(e){return this.send(Le.SetPublicData,e,Vr)}deleteKey(e){return this.send(Le.DeleteKey,e,Se)}batchSet(e){return this.send(Le.BatchSet,e,rn)}batchDelete(e){return this.send(Le.BatchDelete,e,nn)}batchGetPublicUserCustomDataOf(e){return this.send(Le.BatchGetPublicUserCustomDataOf,e,on)}};var Om={Static:"Static",Runtime:"Runtime"},Bm={Public:"Public",Private:"Private"},Um=zod.z.enum(["Client","Server","System"]),wm=zod.z.enum(["String","Int","Bool","Json"]),qm=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:a.nullish(),Version:zod.z.number().nullish(),LastWriter:Um.nullish(),ExpiresAt:a.nullish()}).passthrough(),Aa=zod.z.record(zod.z.string(),qm),ki=zod.z.object({StaticVersion:zod.z.number().nullish(),RuntimeVersion:zod.z.number().nullish(),Static:Aa.nullish(),Runtime:Aa.nullish(),NotModified:zod.z.boolean().nullish()}),Em=zod.z.object({KeyID:zod.z.string(),Scope:zod.z.enum(["Static","Runtime"]).nullish(),Bucket:zod.z.enum(["Public","Private"]).nullish(),ValueType:wm.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),Cr=zod.z.object({Keys:zod.z.record(zod.z.string(),Em).nullish(),DefaultMaxValueLengthBytes:zod.z.number().nullish(),DefaultTtlSeconds:zod.z.number().nullish(),MaxKeysPerBucket:zod.z.number().nullish(),MaxTotalSizeBytes:zod.z.number().nullish(),RejectUnregisteredKeys:zod.z.boolean().nullish()}).passthrough(),It={GetTitleCustomDataDefinitions:"GetTitleCustomDataDefinitions",GetPublicTitleData:"GetPublicTitleData",GetPublicTitleDataKeys:"GetPublicTitleDataKeys"};var Sr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"TitleCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getTitleCustomDataDefinitions(e){return this.send(It.GetTitleCustomDataDefinitions,e,Cr)}getPublicTitleData(e){return this.send(It.GetPublicTitleData,e,ki)}getPublicTitleDataKeys(e){return this.send(It.GetPublicTitleDataKeys,e,ki)}};var Lm={Fast:"Fast",Sequential:"Sequential"},Gm={Instant:"Instant",Timed:"Timed"},Nm={Hit:"Hit",Blocked:"Blocked"},jm=zod.z.object({SlotIndex:zod.z.number(),Level:zod.z.number().nullish(),IsDamaged:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish()}).passthrough(),Fm=zod.z.object({Symbol:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),OnOpenBonus:G.nullish(),BonusTag:zod.z.string().nullish()}).passthrough();zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:G.nullish()}).passthrough();zod.z.object({PlayedCount:zod.z.number().nullish(),RewardsClaimedCount:zod.z.number().nullish(),InstantClaimsCount:zod.z.number().nullish(),EarlyClaimsCount:zod.z.number().nullish(),LateClaimsCount:zod.z.number().nullish(),AdViewsTotal:zod.z.number().nullish()}).passthrough();var Oa=zod.z.object({}).passthrough().transform(u=>u),Ba=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),ze=zod.z.object({Operation:x.nullish(),ScaleWithRollMultiplier:zod.z.boolean().nullish()}).passthrough(),_m=zod.z.object({Count:zod.z.number().nullish(),Sides:zod.z.number().nullish()}).passthrough(),Wm=zod.z.object({ShieldChance:zod.z.number().nullish(),DamagedBuildingChance:zod.z.number().nullish(),RankMultiplierMin:zod.z.number().nullish(),RankMultiplierMax:zod.z.number().nullish(),RankOffsetMin:zod.z.number().nullish(),RankOffsetMax:zod.z.number().nullish()}).passthrough(),Vm=zod.z.object({CostMatrixTemplatesByID:zod.z.record(zod.z.string(),zod.z.array(zod.z.array(zod.z.number()))).nullish(),PerBoardGrowth:zod.z.number().nullish(),VisualTemplateCycle:zod.z.array(zod.z.string()).nullish(),EconomyScaledResources:oe.nullish(),ScaleRaidStealWithEconomy:zod.z.boolean().nullish(),ScaleAttackRewardWithEconomy:zod.z.boolean().nullish(),AttackValueFromCostMatrix:zod.z.boolean().nullish(),AttackBlockedRewardFactor:zod.z.number().nullish(),ScaleVictimLossWithEconomy:zod.z.boolean().nullish(),ScaleVictimLossWithTier:zod.z.boolean().nullish(),SynthesizedBuildingSlots:zod.z.number().nullish(),SynthesizedBuildingMaxLevel:zod.z.number().nullish()}).passthrough(),Qm=zod.z.object({CostMatrix:zod.z.array(zod.z.array(zod.z.number())).nullish(),PerBoardGrowth:zod.z.number().nullish(),EconomyScale:zod.z.number().nullish(),ScaledResources:oe.nullish()}).passthrough(),Ua=zod.z.object({SlotIndex:zod.z.number().nullish(),Name:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),MaxLevel:zod.z.number().nullish(),MaxLevelReward:G.nullish()}).passthrough(),Hm=zod.z.object({Index:zod.z.number().nullish(),Type:zod.z.string().nullish(),CustomTypeID:zod.z.string().nullish(),RandomActionAttackWeight:zod.z.number().nullish(),RandomActionRaidWeight:zod.z.number().nullish(),ChanceTableID:zod.z.string().nullish(),SpecialModeID:zod.z.string().nullish(),Params:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Km=zod.z.object({Tiles:zod.z.record(zod.z.string(),Hm).nullish()}).passthrough(),$m=zod.z.object({Weight:zod.z.number().nullish(),Bonus:ze.nullish(),Tag:zod.z.string().nullish()}).passthrough(),Zm=zod.z.object({Weight:zod.z.number().nullish(),Tag:zod.z.string().nullish(),MinBonusCells:zod.z.number().nullish(),MaxBonusCells:zod.z.number().nullish(),BonusPool:zod.z.array($m).nullish(),GuaranteedBonus:ze.nullish(),IsJackpot:zod.z.boolean().nullish(),JackpotFinalMultiplier:zod.z.number().nullish(),JackpotSymbolDistribution:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough(),Jm=zod.z.object({Variants:zod.z.array(Zm).nullish()}).passthrough(),Ym=zod.z.object({Weight:zod.z.number().nullish(),OutcomeID:zod.z.string().nullish(),Reward:ze.nullish(),ForceAction:zod.z.string().nullish(),SpecialModeID:zod.z.string().nullish()}).passthrough(),Xm=zod.z.object({Outcomes:zod.z.array(Ym).nullish()}).passthrough(),wa=zod.z.object({PerAdMultiplierRange:Ba.nullish(),MaxAdViews:zod.z.number().nullish(),AdCreditCost:zod.z.number().nullish(),FormulaKind:zod.z.string().nullish(),ApplyMultiplierOnEarlyClaim:zod.z.boolean().nullish()}).passthrough(),eh=zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:ze.nullish()}).passthrough(),th=zod.z.object({Tiers:zod.z.array(eh).nullish(),BelowFirstTierReward:ze.nullish()}).passthrough(),sh=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:ze.nullish(),DurationSeconds:zod.z.number().nullish(),EntryCost:H.nullish(),Multipliers:wa.nullish(),Gradation:th.nullish()}).passthrough(),rh=zod.z.object({Choices:zod.z.array(sh).nullish(),OfferExpireSeconds:zod.z.number().nullish(),ClaimExpireSeconds:zod.z.number().nullish()}).passthrough(),ih=zod.z.object({Chance:zod.z.number().nullish(),RequiredOutcome:zod.z.string().nullish(),Reward:ze.nullish(),Tag:zod.z.string().nullish()}).passthrough(),nh=zod.z.object({OnPassStart:ze.nullish(),OnTileLanding:zod.z.record(zod.z.string(),ze).nullish(),OnAttack:zod.z.record(zod.z.string(),ze).nullish(),OnRaid:zod.z.record(zod.z.string(),ze).nullish(),OnBuild:ze.nullish(),OnStageComplete:ze.nullish(),OnAttackBonusDrops:zod.z.array(ih).nullish(),ChanceTablesByID:zod.z.record(zod.z.string(),Xm).nullish(),SpecialModesByID:zod.z.record(zod.z.string(),rh).nullish()}).passthrough(),qa=zod.z.object({BaseAttackReward:G.nullish(),BaseRaidReward:G.nullish(),MaxRollMultiplier:zod.z.number().nullish(),MaxShields:zod.z.number().nullish(),Buildings:zod.z.array(Ua).nullish(),HeistGridBonusConfig:Jm.nullish(),StageOperations:nh.nullish(),TileLandingMultiplier:Ba.nullish(),EconomyOverride:Qm.nullish()}).passthrough(),oh=zod.z.object({Name:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),BoardTemplateID:zod.z.string().nullish(),Buildings:zod.z.array(Ua).nullish(),StageTemplateID:zod.z.string().nullish(),CostMatrixTemplateID:zod.z.string().nullish(),UnitValue:zod.z.number().nullish(),Override:qa.nullish()}).passthrough(),xr=zod.z.object({RollCurrencyID:zod.z.string().nullish(),ShieldCurrencyID:zod.z.string().nullish(),RaidMode:zod.z.string().nullish(),AllowedRollMultipliers:zod.z.array(zod.z.number()).nullish(),BoardTemplatesByID:zod.z.record(zod.z.string(),Km).nullish(),StageTemplatesByID:zod.z.record(zod.z.string(),qa).nullish(),StagesByLevel:zod.z.record(zod.z.string(),oh).nullish(),SoftCurrencyID:zod.z.string().nullish(),ProceduralEconomy:Vm.nullish(),Dice:_m.nullish(),Bots:Wm.nullish()}).passthrough(),ah=zod.z.object({IsActive:zod.z.boolean().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),AnchorUtc:a.nullish(),RoundDurationSec:zod.z.number().nullish(),PauseBetweenRoundsSec:zod.z.number().nullish(),MaxRounds:zod.z.number().nullish(),PartnerCount:zod.z.number().nullish(),MatchmakingTimeoutMinutes:zod.z.number().nullish(),MemberGracePeriodMinutes:zod.z.number().nullish(),ContributionMin:zod.z.number().nullish(),ContributionMax:zod.z.number().nullish(),ScaleContributionWithRollMultiplier:zod.z.boolean().nullish(),MaxProgress:zod.z.number().nullish(),Milestones:zod.z.record(zod.z.string(),ye).nullish(),GrandPrize:G.nullish()}).passthrough(),Dr=zod.z.object({Board:xr.nullish(),CommunityChest:ah.nullish()}).passthrough(),lh=zod.z.object({TargetUserID:zod.z.string().nullish(),IsBot:zod.z.boolean().nullish(),PublicData:Ce.nullish(),TargetBuildingStates:zod.z.array(jm).nullish(),TargetHasShield:zod.z.boolean().nullish()}).passthrough(),uh=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:ze.nullish(),DurationSeconds:zod.z.number().nullish(),EntryCost:H.nullish(),Multipliers:wa.nullish()}).passthrough(),ch=zod.z.object({ModeID:zod.z.string().nullish(),Choices:zod.z.array(uh).nullish()}).passthrough(),ph=zod.z.object({GroupID:zod.z.string().nullish(),Delta:k.nullish(),NewProgress:k.nullish(),MaxProgress:k.nullish(),UnlockedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),Completed:zod.z.boolean().nullish()}).passthrough(),Ea=zod.z.object({UsedMultiplier:zod.z.number().nullish(),Steps:zod.z.number().nullish(),OldPosition:zod.z.number().nullish(),NewPosition:zod.z.number(),CyclesCompletedDelta:k.nullish(),LandedTileType:zod.z.string().nullish(),Operation:x.nullish(),ActionRequired:zod.z.string().nullish(),ActionData:lh.nullish(),SpecialModeOffer:ch.nullish(),CommunityChestContribution:ph.nullish()}).passthrough(),La=zod.z.object({Outcome:zod.z.string().nullish(),IsBotTarget:zod.z.boolean().nullish(),BuildingIndexHit:zod.z.number().nullish(),Operation:x.nullish(),DualResult:tt.nullish()}).passthrough(),Ai=zod.z.object({Status:zod.z.string().nullish(),Outcome:zod.z.string().nullish(),FoundSymbol:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),FoundBonus:G.nullish(),OpenedIndex:zod.z.number().nullish(),AttemptsLeft:zod.z.number().nullish(),RaidLayout:zod.z.array(Fm).nullish(),HeistVariantTag:zod.z.string().nullish(),IsJackpot:zod.z.boolean().nullish(),Operation:x.nullish(),DualResult:tt.nullish()}).passthrough(),Ga=zod.z.object({BuiltIndex:zod.z.number(),NewLevel:zod.z.number().nullish(),StageComplete:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish(),Operation:x.nullish()}).passthrough(),Na=zod.z.object({Mode:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),Operation:x.nullish(),DurationSeconds:zod.z.number().nullish(),StartedAtUtc:a.nullish(),ExpiresAtUtc:a.nullish()}).passthrough(),ja=zod.z.object({AdViewsUsed:zod.z.number().nullish(),RolledMultiplier:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),RemainingAdViews:zod.z.number().nullish()}).passthrough(),Fa=zod.z.object({FinalMultiplier:zod.z.number().nullish(),AdViewsUsed:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),IsEarlyClaim:zod.z.boolean().nullish(),Operation:x.nullish()}).passthrough(),dh={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},_a=zod.z.enum(["Forming","Active","Completed","Failed","Expired"]),mh={Active:"Active",Left:"Left",Replaced:"Replaced"},hh=zod.z.enum(["Active","Left","Replaced"]),fh=zod.z.object({CurrentProgress:k.nullish(),MaxProgress:k.nullish()}).passthrough(),gh=zod.z.object({UserID:zod.z.string().nullish(),PublicData:Ce.nullish(),IsBot:zod.z.boolean().nullish(),ContributionPoints:k.nullish(),ClaimedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),GrandPrizeClaimed:zod.z.boolean().nullish(),MemberStatus:hh.nullish(),JoinedAtUtc:a.nullish(),LeftAtUtc:a.nullish()}).passthrough(),Wa=zod.z.object({GroupID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),Members:zod.z.array(gh).nullish(),SharedProgress:fh.nullish(),Status:_a.nullish(),CreatedAtUtc:a.nullish(),ExpiresAtUtc:a.nullish(),Version:zod.z.number().nullish()}).passthrough(),Rh=zod.z.object({GroupID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),FinalStatus:_a.nullish(),GrandPrizeReceived:zod.z.boolean().nullish(),FinishedAtUtc:a.nullish()}).passthrough(),yh=zod.z.object({ActiveGroupID:zod.z.string().nullish(),ActiveRoundIndex:zod.z.number().nullish(),History:zod.z.array(Rh).nullish()}).passthrough(),Va=zod.z.object({ServerTimeUtc:a.nullish(),UserState:yh.nullish(),ActiveGroup:Wa.nullish(),SecondsRemaining:k.nullish()}),Qa=zod.z.object({ServerTimeUtc:a.nullish(),Group:Wa.nullish(),SecondsRemaining:k.nullish()}),Oi=zod.z.object({ServerTimeUtc:a.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:x.nullish()}),Ha=zod.z.object({ServerTimeUtc:a.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),me={GetGameLoops:"GetGameLoops",GetBoardDefinition:"GetBoardDefinition",GetBoardDefinitionForLevel:"GetBoardDefinitionForLevel",GetUserBoardState:"GetUserBoardState",BoardLoopRoll:"BoardLoopRoll",BoardLoopAttack:"BoardLoopAttack",BoardLoopRaid:"BoardLoopRaid",BoardLoopRaidFast:"BoardLoopRaidFast",BoardLoopBuild:"BoardLoopBuild",BoardSpecialChoose:"BoardSpecialChoose",BoardSpecialApplyMultiplier:"BoardSpecialApplyMultiplier",BoardSpecialClaim:"BoardSpecialClaim",GetCommunityChestState:"GetCommunityChestState",JoinOrCreateCommunityChest:"JoinOrCreateCommunityChest",ClaimCommunityChestMilestone:"ClaimCommunityChestMilestone",ClaimCommunityChestGrandPrize:"ClaimCommunityChestGrandPrize",LeaveCommunityChest:"LeaveCommunityChest"};var Ch=zod.z.object({VariantID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Weight:zod.z.number().nullish(),IsControl:zod.z.boolean().nullish(),Params:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Sh=zod.z.object({ExperimentID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Schedule:ue.nullish(),Gate:V.nullish(),Variants:zod.z.array(Ch).nullish(),Salt:zod.z.string().nullish(),LayerID:zod.z.string().nullish(),StickyAssignment:zod.z.boolean().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Ka=zod.z.object({Experiments:zod.z.record(zod.z.string(),Sh).nullish()}).passthrough();var xh={Mesh:"Mesh",Host:"Host"},Bi=zod.z.enum(["Mesh","Host"]),Dh={ServerRelay:"ServerRelay",P2P:"P2P"},Ui=zod.z.enum(["ServerRelay","P2P"]),bh={Public:"Public",Private:"Private"},zh=zod.z.enum(["Public","Private"]),vh={Signal:"Signal",Chat:"Chat",PlayerJoined:"PlayerJoined",PlayerLeft:"PlayerLeft",HostChanged:"HostChanged",RoomClosed:"RoomClosed",MemberState:"MemberState"},Th=zod.z.enum(["Signal","Chat","PlayerJoined","PlayerLeft","HostChanged","RoomClosed","MemberState"]),$a=zod.z.object({Urls:zod.z.string().nullish(),Username:zod.z.string().nullish(),Credential:zod.z.string().nullish()}).passthrough(),Ph=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),Za=zod.z.object({SystemState:Ph.nullish(),DefaultTopology:Bi.nullish(),AllowCreatorTopologyOverride:zod.z.boolean().nullish(),DefaultChatMode:Ui.nullish(),AllowCreatorChatOverride:zod.z.boolean().nullish(),MaxPlayersPerRoom:zod.z.number().nullish(),RoomTtlSeconds:zod.z.number().nullish(),HeartbeatIntervalMs:zod.z.number().nullish(),MemberTimeoutMs:zod.z.number().nullish(),MaxSignalPayloadBytes:zod.z.number().nullish(),MaxChatTextLength:zod.z.number().nullish(),RoomLogCap:zod.z.number().nullish(),IceServers:zod.z.array($a).nullish()}).passthrough(),Ih=zod.z.object({UserID:zod.z.string().nullish(),Username:zod.z.string().nullish(),AvatarUrl:zod.z.string().nullish(),Level:zod.z.number().nullish(),Power:zod.z.number().nullish(),Ready:zod.z.boolean().nullish(),State:zod.z.record(zod.z.string(),zod.z.string()).nullish(),JoinedAt:zod.z.number().nullish(),IsHost:zod.z.boolean().nullish(),LastSeenMs:zod.z.number().nullish()}).passthrough(),Mh=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),Topology:Bi.nullish(),ChatMode:Ui.nullish(),MaxPlayers:zod.z.number().nullish(),MemberCount:zod.z.number().nullish(),CreatedAt:zod.z.number().nullish()}).passthrough(),kh=zod.z.object({Seq:zod.z.number().nullish(),Type:Th.nullish(),FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),Kind:zod.z.string().nullish(),Payload:zod.z.string().nullish(),Ts:zod.z.number().nullish()}).passthrough(),br=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),OwnerUserID:zod.z.string().nullish(),Topology:Bi.nullish(),ChatMode:Ui.nullish(),Visibility:zh.nullish(),Status:zod.z.string().nullish(),MaxPlayers:zod.z.number().nullish(),Members:zod.z.array(Ih).nullish(),IceServers:zod.z.array($a).nullish(),Seq:zod.z.number().nullish()}).passthrough(),wi=zod.z.object({Closed:zod.z.boolean().nullish(),NewHostUserID:zod.z.string().nullish()}).passthrough(),Ja=zod.z.object({Rooms:zod.z.array(Mh).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}).passthrough(),Ya=zod.z.object({Envelopes:zod.z.array(kh).nullish(),MaxSeq:zod.z.number().nullish()}).passthrough(),zr=zod.z.object({Seq:zod.z.number().nullish()}).passthrough(),Ue={CreateRoom:"CreateRoom",JoinRoom:"JoinRoom",LeaveRoom:"LeaveRoom",ListRooms:"ListRooms",GetRoom:"GetRoom",CloseRoom:"CloseRoom",Poll:"Poll",SendSignal:"SendSignal",SendChat:"SendChat",SetMemberState:"SetMemberState"};var Xa=zod.z.object({TitleCustomData:Cr.nullish(),Character:bs.nullish(),Item:qs.nullish(),Currency:Ds.nullish(),Store:Ls.nullish(),Lootbox:fi.nullish(),Quest:Et.nullish(),TimedEvent:Vs.nullish(),Leaderboard:Js.nullish(),Season:Xs.nullish(),Reward:gi.nullish(),Collection:lr.nullish(),Craft:bi.nullish(),DealOffer:Ii.nullish(),Premium:Di.nullish(),TimedBoost:gr.nullish(),CoopEvent:cr.nullish(),GameLoop:Dr.nullish(),Match:oi.nullish(),Experiment:Ka.nullish(),Blockchain:Xr.nullish(),Marketplace:ci.nullish(),Multiplayer:Za.nullish(),UserCustomData:fs.nullish(),Referral:Mi.nullish()}).passthrough();var Ct={GetTitlePublicConfiguration:"GetTitlePublicConfiguration",GetTitlePublicConfigurationExcept:"GetTitlePublicConfigurationExcept",GetCurrencyDefinitions:"GetCurrencyDefinitions",GetItemDefinitions:"GetItemDefinitions",GetServerTime:"GetServerTime"};var vr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Title",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getTitlePublicConfiguration(e){return this.send(Ct.GetTitlePublicConfiguration,e,Xa)}getCurrencyDefinitions(e){return this.send(Ct.GetCurrencyDefinitions,e,Ds)}getItemDefinitions(e){return this.send(Ct.GetItemDefinitions,e,qs)}getServerTime(e){return this.send(Ct.GetServerTime,e,Se)}};var Tr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s,r=false){let i=O(this.ctx.settings.titleID,"GameLoop",e,t.UserID??"");return this.ctx.transport.post(i,t,s,{ticket:t.ClientSessionTicket,silent:r})}getGameLoops(e){return this.send(me.GetGameLoops,e,Dr)}getBoardDefinition(e,t=false){return this.send(me.GetBoardDefinition,e,xr,t)}getBoardDefinitionForLevel(e,t=false){return this.send(me.GetBoardDefinitionForLevel,e,xr,t)}getUserBoardState(e){return this.send(me.GetUserBoardState,e,Oa)}boardLoopRoll(e){return this.send(me.BoardLoopRoll,e,Ea)}boardLoopAttack(e){return this.send(me.BoardLoopAttack,e,La)}boardLoopRaid(e){return this.send(me.BoardLoopRaid,e,Ai)}boardLoopRaidFast(e){return this.send(me.BoardLoopRaidFast,e,Ai)}boardLoopBuild(e){return this.send(me.BoardLoopBuild,e,Ga)}boardSpecialChoose(e){return this.send(me.BoardSpecialChoose,e,Na)}boardSpecialApplyMultiplier(e){return this.send(me.BoardSpecialApplyMultiplier,e,ja)}boardSpecialClaim(e){return this.send(me.BoardSpecialClaim,e,Fa)}getCommunityChestState(e){return this.send(me.GetCommunityChestState,e,Va)}joinOrCreateCommunityChest(e){return this.send(me.JoinOrCreateCommunityChest,e,Qa)}claimCommunityChestMilestone(e){return this.send(me.ClaimCommunityChestMilestone,e,Oi)}claimCommunityChestGrandPrize(e){return this.send(me.ClaimCommunityChestGrandPrize,e,Oi)}leaveCommunityChest(e){return this.send(me.LeaveCommunityChest,e,Ha)}};var Mt=zod.z.lazy(()=>zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null(),zod.z.array(Mt),zod.z.record(zod.z.string(),Mt)]));var Oh={Live:"Live",Latest:"Latest",Specific:"Specific"},Bh={Debug:"Debug",Info:"Info",Warning:"Warning",Error:"Error"},Uh=zod.z.enum(["Debug","Info","Warning","Error"]),wh={None:"None",Disabled:"Disabled",NoActiveRevision:"NoActiveRevision",RevisionNotFound:"RevisionNotFound",InvalidFieldName:"InvalidFieldName",RateLimited:"RateLimited",HandlerNotFound:"HandlerNotFound",HandlerDisabled:"HandlerDisabled",Timeout:"Timeout",StatementCountExceeded:"StatementCountExceeded",StackOverflow:"StackOverflow",ApiCallLimitExceeded:"ApiCallLimitExceeded",JavaScriptException:"JavaScriptException",ExecutionError:"ExecutionError"},qh=zod.z.enum(["None","Disabled","NoActiveRevision","RevisionNotFound","InvalidFieldName","RateLimited","HandlerNotFound","HandlerDisabled","Timeout","StatementCountExceeded","StackOverflow","ApiCallLimitExceeded","JavaScriptException","ExecutionError"]),Eh=zod.z.object({Level:Uh,Message:zod.z.string().nullish(),Data:Mt.nullish()}),Lh=zod.z.object({Error:qh,Message:zod.z.string().nullish(),StackTrace:zod.z.string().nullish()}),el=zod.z.object({FunctionName:zod.z.string().nullish(),Revision:zod.z.number().nullish(),FunctionResult:Mt.nullish(),FunctionResultTooLarge:zod.z.boolean().nullish(),Logs:zod.z.array(Eh).nullish(),LogsTooLarge:zod.z.boolean().nullish(),ExecutionTimeSeconds:zod.z.number().nullish(),APIRequestsIssued:zod.z.number().nullish(),Error:Lh.nullish()}),qi={Execute:"Execute"};var Pr=class{constructor(e){this.ctx=e;}ctx;execute(e){let t=O(this.ctx.settings.titleID,"CloudCode",qi.Execute,e.UserID??"");return this.ctx.transport.post(t,e,el,{ticket:e.ClientSessionTicket})}};var Ir=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Blockchain",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Pe.GetDefinitions,e,An)}getUserState(e){return this.send(Pe.GetUserState,e,On)}depositToken(e){return this.send(Pe.DepositToken,e,Bn)}depositNFT(e){return this.send(Pe.DepositNFT,e,Un)}requestTokenWithdrawal(e){return this.send(Pe.RequestTokenWithdrawal,e,wn)}requestNFTWithdrawal(e){return this.send(Pe.RequestNFTWithdrawal,e,qn)}getTransactionHistory(e){return this.send(Pe.GetTransactionHistory,e,En)}retryWithdrawal(e){return this.send(Pe.RetryWithdrawal,e,Ln)}confirmWithdrawal(e){return this.send(Pe.ConfirmWithdrawal,e,Gn)}donateToDeveloper(e){return this.send(Pe.DonateToDeveloper,e,si)}donateToUsersPool(e){return this.send(Pe.DonateToUsersPool,e,si)}};var Mr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Marketplace",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(se.GetDefinitions,e,Xn)}getGroupedOffers(e){return this.send(se.GetGroupedOffers,e,eo)}getOffersByItem(e){return this.send(se.GetOffersByItem,e,pi)}getOffer(e){return this.send(se.GetOffer,e,to)}getBuyOrders(e){return this.send(se.GetBuyOrders,e,pi)}getMyState(e){return this.send(se.GetMyState,e,ro)}getHistory(e){return this.send(se.GetHistory,e,io)}createListing(e){return this.send(se.CreateListing,e,vt)}cancelListing(e){return this.send(se.CancelListing,e,Ae)}buy(e){return this.send(se.Buy,e,Ae)}marketBuy(e){return this.send(se.MarketBuy,e,Ae)}marketSell(e){return this.send(se.MarketSell,e,Ae)}createAuction(e){return this.send(se.CreateAuction,e,vt)}placeBid(e){return this.send(se.PlaceBid,e,so)}claimAuction(e){return this.send(se.ClaimAuction,e,Ae)}createBuyOrder(e){return this.send(se.CreateBuyOrder,e,vt)}cancelBuyOrder(e){return this.send(se.CancelBuyOrder,e,Ae)}fillBuyOrder(e){return this.send(se.FillBuyOrder,e,Ae)}createDirectTrade(e){return this.send(se.CreateDirectTrade,e,vt)}respondDirectTrade(e){return this.send(se.RespondDirectTrade,e,Ae)}cancelDirectTrade(e){return this.send(se.CancelDirectTrade,e,Ae)}claimBack(e){return this.send(se.ClaimBack,e,Ae)}};var kr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Multiplayer",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}createRoom(e){return this.send(Ue.CreateRoom,e,br)}joinRoom(e){return this.send(Ue.JoinRoom,e,br)}leaveRoom(e){return this.send(Ue.LeaveRoom,e,wi)}listRooms(e){return this.send(Ue.ListRooms,e,Ja)}getRoom(e){return this.send(Ue.GetRoom,e,br)}closeRoom(e){return this.send(Ue.CloseRoom,e,wi)}poll(e){return this.send(Ue.Poll,e,Ya)}sendSignal(e){return this.send(Ue.SendSignal,e,zr)}sendChat(e){return this.send(Ue.SendChat,e,zr)}setMemberState(e){return this.send(Ue.SetMemberState,e,zr)}};var Ar=class{settings;emitter;platform;transport;data;authStore;api;auth;userService;currency;item;store;lootbox;reward;quest;timedEvent;leaderboard;season;premium;character;match;craft;collection;coopEvent;dealOffer;referral;social;timedBoost;userCustomData;titleCustomData;title;gameLoop;cloudCode;blockchain;marketplace;multiplayer;constructor(e){this.settings=Gi(e),this.emitter=new xt,this.platform=e.platform??new ct,this.transport=new Nt({baseUrl:this.settings.baseUrl,emitter:this.emitter,fetchImpl:e.fetch,debugLogging:this.settings.debugLogging,throttleMs:e.throttleMs}),this.data=new Wt(this.emitter),this.emitter.on("quest:systemProgress",t=>{this.data.user.patchQuestProgressUpdates(t);}),this.authStore=new Vt(this.platform.storage,this.settings.titleID),this.api={authentication:new Os(this),user:new Bs(this),currency:new Us(this),item:new Es(this),store:new Gs(this),lootbox:new Fs(this),reward:new _s(this),quest:new Ws(this),timedEvent:new Qs(this),leaderboard:new Ys(this),season:new er(this),premium:new sr(this),character:new rr(this),match:new ir(this),craft:new or(this),collection:new ur(this),coopEvent:new pr(this),dealOffer:new dr(this),referral:new mr(this),social:new fr(this),timedBoost:new Rr(this),userCustomData:new yr(this),titleCustomData:new Sr(this),title:new vr(this),gameLoop:new Tr(this),cloudCode:new Pr(this),blockchain:new Ir(this),marketplace:new Mr(this),multiplayer:new kr(this)},this.userService=new Ht(this),this.auth=new Qt(this),this.currency=new $t(this),this.item=new Zt(this),this.store=new Jt(this),this.lootbox=new Yt(this),this.reward=new Xt(this),this.quest=new es(this),this.timedEvent=new ts(this),this.leaderboard=new ss(this),this.season=new rs(this),this.premium=new is(this),this.character=new ns(this),this.match=new os(this),this.craft=new as(this),this.collection=new ls(this),this.coopEvent=new us(this),this.dealOffer=new cs(this),this.referral=new ps(this),this.social=new ds(this),this.timedBoost=new ms(this),this.userCustomData=new gs(this),this.titleCustomData=new Rs(this),this.title=new ys(this),this.gameLoop=new Cs(this),this.cloudCode=new Ss(this),this.blockchain=new Ts(this),this.marketplace=new ks(this),this.multiplayer=new As(this),this.transport.setSessionRefreshHandler(()=>this.auth.refreshSession());}buildAuthedBaseRequest(){let e=this.auth.context;return {UserID:e?.userID,ClientSessionTicket:e?.clientSessionTicket,BuildKey:this.settings.buildKey,WebAppLink:this.platform.getFullURL(),RelatedEntityID:M()}}};var Or=class{ctx;constructor(e){this.ctx=new Ar(e);}get titleID(){return this.ctx.settings.titleID}get auth(){return this.ctx.auth}get user(){return this.ctx.userService}get currency(){return this.ctx.currency}get item(){return this.ctx.item}get store(){return this.ctx.store}get lootbox(){return this.ctx.lootbox}get reward(){return this.ctx.reward}get quest(){return this.ctx.quest}get timedEvent(){return this.ctx.timedEvent}get leaderboard(){return this.ctx.leaderboard}get season(){return this.ctx.season}get premium(){return this.ctx.premium}get character(){return this.ctx.character}get match(){return this.ctx.match}get craft(){return this.ctx.craft}get collection(){return this.ctx.collection}get coopEvent(){return this.ctx.coopEvent}get dealOffer(){return this.ctx.dealOffer}get referral(){return this.ctx.referral}get social(){return this.ctx.social}get timedBoost(){return this.ctx.timedBoost}get userCustomData(){return this.ctx.userCustomData}get titleCustomData(){return this.ctx.titleCustomData}get title(){return this.ctx.title}get gameLoop(){return this.ctx.gameLoop}get cloudCode(){return this.ctx.cloudCode}get blockchain(){return this.ctx.blockchain}get marketplace(){return this.ctx.marketplace}get multiplayer(){return this.ctx.multiplayer}get data(){return this.ctx.data}get platform(){return this.ctx.platform}on(e,t){return this.ctx.emitter.on(e,t)}once(e,t){return this.ctx.emitter.once(e,t)}off(e,t){this.ctx.emitter.off(e,t);}};function Gh(u){return new Or(u)}var Nh={Banner:"Banner",Interstitial:"Interstitial",RewardedVideo:"RewardedVideo",RewardedInterstitial:"RewardedInterstitial",AppOpen:"AppOpen",Native:"Native"},Ei=zod.z.enum(["Banner","Interstitial","RewardedVideo","RewardedInterstitial","AppOpen","Native"]),jh={Top:"Top",Bottom:"Bottom",Left:"Left",Right:"Right"},Fh=zod.z.enum(["Top","Bottom","Left","Right"]),_h=zod.z.object({PlacementID:zod.z.string().nullish(),Type:Ei.nullish(),Enabled:zod.z.boolean().nullish(),CooldownSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish(),CreditsRewarded:zod.z.number().nullish(),AllowedProviderIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),Wh=zod.z.object({DefaultCreditsPerView:zod.z.number().nullish(),MaxCreditsBalance:zod.z.number().nullish(),DailyCreditEarnCap:zod.z.number().nullish(),DailyViewCap:zod.z.number().nullish(),MinSecondsBetweenViews:zod.z.number().nullish()}).passthrough(),Vh=zod.z.object({CooldownSeconds:zod.z.number().nullish(),MinSessionTimeBeforeFirstSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),Qh=zod.z.object({Enabled:zod.z.boolean().nullish(),Position:Fh.nullish(),RefreshIntervalSeconds:zod.z.number().nullish()}).passthrough(),Hh=zod.z.object({Enabled:zod.z.boolean().nullish(),CooldownSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish()}).passthrough(),Kh=zod.z.object({MaxImpressionsPerHour:zod.z.number().nullish(),MaxImpressionsPerDay:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),$h=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),DisableInterstitials:zod.z.boolean().nullish(),DisableBanners:zod.z.boolean().nullish(),DisableAppOpen:zod.z.boolean().nullish()}).passthrough(),Zh=zod.z.object({RequirePersonalizedAdsConsent:zod.z.boolean().nullish(),RequireTrackingConsent:zod.z.boolean().nullish(),CurrentPolicyVersion:zod.z.string().nullish(),RegulatedRegions:zod.z.array(zod.z.string()).nullish()}).passthrough(),Jh=zod.z.object({RequireServerSideVerification:zod.z.boolean().nullish(),PendingRequestTtlSeconds:zod.z.number().nullish(),MaxPendingRequestsPerUser:zod.z.number().nullish(),ProviderPublicKeys:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Yh=zod.z.object({AndroidUnitID:zod.z.string().nullish(),IosUnitID:zod.z.string().nullish(),WebUnitID:zod.z.string().nullish(),Type:Ei.nullish()}).passthrough(),Xh=zod.z.object({ProviderID:zod.z.string().nullish(),Enabled:zod.z.boolean().nullish(),Priority:zod.z.number().nullish(),AndroidAppID:zod.z.string().nullish(),IosAppID:zod.z.string().nullish(),WebAppID:zod.z.string().nullish(),Units:zod.z.record(zod.z.string(),Yh).nullish()}).passthrough();zod.z.object({Enabled:zod.z.boolean().nullish(),Placements:zod.z.record(zod.z.string(),_h).nullish(),Providers:zod.z.record(zod.z.string(),Xh).nullish(),RewardedVideo:Wh.nullish(),Interstitial:Vh.nullish(),Banner:Qh.nullish(),AppOpen:Hh.nullish(),FrequencyCapping:Kh.nullish(),PremiumAdReductions:zod.z.array($h).nullish(),Consent:Zh.nullish(),Verification:Jh.nullish()}).passthrough();var ef=zod.z.object({RewardedVideoCredit:zod.z.number().nullish(),TotalEarned:zod.z.number().nullish(),TotalSpent:zod.z.number().nullish()}).passthrough(),tf=zod.z.object({PlacementID:zod.z.string().nullish(),LastShownAt:a.nullish(),LastCompletedAt:a.nullish(),TotalImpressions:zod.z.number().nullish(),TotalCompletions:zod.z.number().nullish(),ConsecutiveFailures:zod.z.number().nullish()}).passthrough(),sf=zod.z.object({Date:a.nullish(),ImpressionsByPlacement:zod.z.record(zod.z.string(),zod.z.number()).nullish(),CompletionsByPlacement:zod.z.record(zod.z.string(),zod.z.number()).nullish(),TotalImpressions:zod.z.number().nullish(),InterstitialImpressions:zod.z.number().nullish(),RewardedCompletions:zod.z.number().nullish(),AppOpenImpressions:zod.z.number().nullish(),CreditsEarnedToday:zod.z.number().nullish()}).passthrough(),rf=zod.z.object({SessionID:zod.z.string().nullish(),SessionStartAt:a.nullish(),Impressions:zod.z.number().nullish(),InterstitialImpressions:zod.z.number().nullish(),RewardedCompletions:zod.z.number().nullish()}).passthrough(),nf=zod.z.object({PersonalizedAdsConsent:zod.z.boolean().nullish(),TrackingConsent:zod.z.boolean().nullish(),PolicyVersion:zod.z.string().nullish(),Region:zod.z.string().nullish(),ConsentGivenAt:a.nullish(),ConsentRevokedAt:a.nullish()}).passthrough(),of=zod.z.object({RequestID:zod.z.string().nullish(),PlacementID:zod.z.string().nullish(),ProviderID:zod.z.string().nullish(),Type:Ei.nullish(),IssuedAt:a.nullish(),ExpiresAt:a.nullish(),CreditsToAward:zod.z.number().nullish()}).passthrough(),af=zod.z.object({InvalidSsvCount:zod.z.number().nullish(),OrphanCompletions:zod.z.number().nullish(),FastCompletions:zod.z.number().nullish(),LastFlaggedAt:a.nullish()}).passthrough();zod.z.object({Credits:ef.nullish(),Placements:zod.z.record(zod.z.string(),tf).nullish(),Daily:sf.nullish(),Session:rf.nullish(),LastImpressionAt:a.nullish(),LastInterstitialAt:a.nullish(),LastRewardedAt:a.nullish(),LastAppOpenAt:a.nullish(),TotalImpressions:zod.z.number().nullish(),TotalRewardedCompletions:zod.z.number().nullish(),AdsDisabledUntil:a.nullish(),Consent:nf.nullish(),PendingRequests:zod.z.record(zod.z.string(),of).nullish(),FraudFlags:af.nullish(),UpdatedAt:a.nullish()}).passthrough();var lf={Unread:"Unread",Read:"Read",Deleted:"Deleted",Expired:"Expired"},uf=zod.z.enum(["Unread","Read","Deleted","Expired"]),cf={Admin:"Admin",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season",Collection:"Collection",MilestoneEvent:"MilestoneEvent",PlayerGift:"PlayerGift",Social:"Social",Compensation:"Compensation",Referral:"Referral",Quest:"Quest"},pf=zod.z.enum(["Admin","Leaderboard","CoopEvent","Season","Collection","MilestoneEvent","PlayerGift","Social","Compensation","Referral","Quest"]),df={Active:"Active",Paused:"Paused",Cancelled:"Cancelled",Completed:"Completed"},mf=zod.z.enum(["Active","Paused","Cancelled","Completed"]),hf=zod.z.object({MessageTypeID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),IconPath:zod.z.string().nullish(),DisplayPriority:zod.z.number().nullish(),ExpirationHours:zod.z.number().nullish(),AutoClaim:zod.z.boolean().nullish(),AllowP2P:zod.z.boolean().nullish(),ShowBadge:zod.z.boolean().nullish()}).passthrough(),ff=zod.z.object({SegmentID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Gate:V.nullish()}).passthrough();zod.z.object({MaxMessagesPerUser:zod.z.number().nullish(),ReadNoRewardRetentionHours:zod.z.number().nullish(),ClaimedRetentionHours:zod.z.number().nullish(),DefaultPageSize:zod.z.number().nullish(),EnableAutoClaim:zod.z.boolean().nullish(),MessageTypes:zod.z.record(zod.z.string(),hf).nullish(),Segments:zod.z.array(ff).nullish(),DailyP2PGiftLimit:zod.z.number().nullish(),MaxRewardsPerP2PMessage:zod.z.number().nullish()}).passthrough();zod.z.object({MessageID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),RecipientUserID:zod.z.string().nullish(),MessageTypeID:zod.z.string().nullish(),Source:pf.nullish(),RelatedEntityID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderPublicData:Ce.nullish(),Subject:zod.z.string().nullish(),Body:zod.z.string().nullish(),TemplateParams:zod.z.record(zod.z.string(),zod.z.string()).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rewards:G.nullish(),Claimed:zod.z.boolean().nullish(),ClaimedAtUtc:a.nullish(),Status:uf.nullish(),CreatedAtUtc:a.nullish(),ExpiresAtUtc:a.nullish(),ReadAtUtc:a.nullish(),BroadcastID:zod.z.string().nullish(),Version:zod.z.number().nullish()}).passthrough();zod.z.object({BroadcastID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),MessageTypeID:zod.z.string().nullish(),Subject:zod.z.string().nullish(),Body:zod.z.string().nullish(),TemplateParams:zod.z.record(zod.z.string(),zod.z.string()).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rewards:G.nullish(),TargetSegmentID:zod.z.string().nullish(),TargetUserIDs:zod.z.array(zod.z.string()).nullish(),StartsAtUtc:a.nullish(),ExpiresAtUtc:a.nullish(),CreatedAtUtc:a.nullish(),CreatedByAdminID:zod.z.string().nullish(),AdminComment:zod.z.string().nullish(),Status:mf.nullish(),DeliveredCount:zod.z.number().nullish(),ClaimedCount:zod.z.number().nullish()}).passthrough();zod.z.object({UnreadCount:zod.z.number().nullish(),UnclaimedRewardCount:zod.z.number().nullish(),LastFetchCursor:a.nullish(),ReceivedBroadcastIDs:zod.z.array(zod.z.string()).nullish(),ClaimedBroadcastIDs:zod.z.array(zod.z.string()).nullish(),DailyP2PGiftsSent:zod.z.number().nullish(),DailyGiftsResetDate:a.nullish(),LastOpenedAtUtc:a.nullish(),TotalMessagesReceived:zod.z.number().nullish(),TotalRewardsClaimed:zod.z.number().nullish()}).passthrough();var tl="idos_device_id",Br=class{storage;constructor(e=new lt){this.storage=e;}getPlatform(){return "Web"}getFullURL(){return ""}getStartParameter(){return null}getTelegramInitDataRaw(){return null}getDeviceID(){let e=this.storage.getString(tl);return e||(e="noop-device",this.storage.setString(tl,e)),e}getDeviceModel(){return "Noop"}shareLink(){}openInvoice(){}async showAd(){}async copyToClipboard(){}};
2
+ exports.AdType=Nh;exports.AttackOutcome=Nm;exports.AuthType=le;exports.AuthenticationAction=Oe;exports.BannerPosition=jh;exports.BlockchainAction=Pe;exports.BlockchainNetworkType=Qu;exports.BlockchainOperationCategory=Pn;exports.BlockchainTransactionStatus=tc;exports.BlockchainTransactionType=Zu;exports.BodyPart=vc;exports.BoostWindowKind=km;exports.BroadcastStatus=df;exports.BrowserPlatformAdapter=ct;exports.BrowserStorage=at;exports.CharacterAction=Te;exports.CloudCodeAction=qi;exports.CloudCodeErrorCode=wh;exports.CloudCodeLogLevel=Bh;exports.CloudCodeRevisionSelection=Oh;exports.CollectionAction=xe;exports.CommissionSink=Wc;exports.CommunityChestMemberStatus=mh;exports.CommunityChestStatus=dh;exports.ConversionRateMode=bu;exports.CoopEventAction=Ge;exports.CoopGroupStatus=Ed;exports.CoopMemberStatus=Ld;exports.CraftAction=nr;exports.CraftType=Dd;exports.CurrencyAction=xs;exports.CurrencyStatus=Du;exports.CurrencyType=we;exports.CustomDataBucket=Ve;exports.CustomDataValueType=du;exports.CustomDataWriter=lu;exports.DEFAULT_BASE_URL=Li;exports.DealNodeRuntimeStatus=$d;exports.DealOfferAction=Fe;exports.DealOfferActivationStatus=Kd;exports.EnvelopeType=vh;exports.EventTokenType=ol;exports.FodderSelectionMode=pp;exports.FodderValuationMode=up;exports.FriendActionStatus=ym;exports.GameLoopAction=me;exports.IDosGamesClient=Or;exports.ItemAction=ws;exports.KycStatus=Ju;exports.KycTier=Xu;exports.LeaderboardAction=fe;exports.LootboxAction=js;exports.MailboxMessageSource=cf;exports.MailboxMessageStatus=lf;exports.MarketGoodsType=Ms;exports.MarketOfferStatus=_c;exports.MarketOfferType=Fc;exports.MarketplaceAction=se;exports.MatchAction=Ne;exports.MatchStatus=Tc;exports.MemoryStorage=lt;exports.MultiplayerAction=Ue;exports.MultiplayerChatMode=Dh;exports.MultiplayerTopology=xh;exports.NoopPlatformAdapter=Br;exports.PremiumAction=nt;exports.QuestAction=Ee;exports.QuestObjectiveSource=vl;exports.QuestPrerequisiteMode=Pl;exports.QuestStatus=Dl;exports.RaidMode=Lm;exports.ReferralAction=Rt;exports.ResourceEntryType=nl;exports.RewardAction=Ke;exports.RoomVisibility=bh;exports.ScheduleMode=al;exports.SeasonAction=it;exports.SocialAction=_e;exports.SpecialChoiceMode=Gm;exports.StoreAction=ht;exports.StoreType=yd;exports.TimedBoostAction=ot;exports.TimedBoostStackingPolicy=Dm;exports.TimedEventAction=Be;exports.TimelineEventType=Cm;exports.TitleAction=Ct;exports.TitleCustomDataAction=It;exports.TitleDataBucket=Bm;exports.TitleDataScope=Om;exports.TradeOfferStatus=Td;exports.TransactionDirection=sc;exports.TypedEmitter=xt;exports.UserAction=je;exports.UserCustomDataAction=Le;exports.WalletLinkType=Ku;exports.createIDosGamesClient=Gh;exports.isFail=il;exports.isOk=rl;exports.normalizeBlockchainCategory=zs;