keeperboard 2.1.0 → 2.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.mjs CHANGED
@@ -1,901 +1 @@
1
- // src/types.ts
2
- var KeeperBoardError = class extends Error {
3
- constructor(message, code, statusCode) {
4
- super(message);
5
- this.code = code;
6
- this.statusCode = statusCode;
7
- this.name = "KeeperBoardError";
8
- }
9
- };
10
-
11
- // src/KeeperBoardClient.ts
12
- var _KeeperBoardClient = class _KeeperBoardClient {
13
- constructor(config) {
14
- const url = config.apiUrl ?? _KeeperBoardClient.DEFAULT_API_URL;
15
- this.apiUrl = url.replace(/\/$/, "");
16
- this.apiKey = config.apiKey;
17
- this.defaultLeaderboard = config.defaultLeaderboard;
18
- }
19
- // ============================================
20
- // SCORE SUBMISSION
21
- // ============================================
22
- /**
23
- * Submit a score. Only updates if the new score is higher than the existing one.
24
- *
25
- * @example
26
- * const result = await client.submitScore({
27
- * playerGuid: 'abc-123',
28
- * playerName: 'ACE',
29
- * score: 1500,
30
- * });
31
- * console.log(result.rank, result.isNewHighScore);
32
- */
33
- async submitScore(options) {
34
- const leaderboard = options.leaderboard ?? this.defaultLeaderboard;
35
- const params = new URLSearchParams();
36
- if (leaderboard) params.set("leaderboard", leaderboard);
37
- const url = `${this.apiUrl}/api/v1/scores${params.toString() ? "?" + params.toString() : ""}`;
38
- const body = {
39
- player_guid: options.playerGuid,
40
- player_name: options.playerName,
41
- score: options.score,
42
- ...options.metadata && { metadata: options.metadata }
43
- };
44
- const raw = await this.request(url, {
45
- method: "POST",
46
- body: JSON.stringify(body)
47
- });
48
- return this.mapScoreResponse(raw);
49
- }
50
- // ============================================
51
- // LEADERBOARD
52
- // ============================================
53
- /**
54
- * Get a leaderboard. Supports pagination and version-based lookups for
55
- * time-based boards.
56
- *
57
- * @example
58
- * // Top 10 on default board
59
- * const lb = await client.getLeaderboard();
60
- *
61
- * // Top 25 on a specific board
62
- * const lb = await client.getLeaderboard({ leaderboard: 'Weekly', limit: 25 });
63
- *
64
- * // Historical version
65
- * const lb = await client.getLeaderboard({ leaderboard: 'Weekly', version: 3 });
66
- */
67
- async getLeaderboard(options) {
68
- const leaderboard = options?.leaderboard ?? this.defaultLeaderboard;
69
- const limit = options?.limit ?? 10;
70
- const offset = options?.offset ?? 0;
71
- const params = new URLSearchParams();
72
- params.set("limit", String(Math.min(limit, 100)));
73
- params.set("offset", String(offset));
74
- if (leaderboard) params.set("leaderboard", leaderboard);
75
- if (options?.version !== void 0) params.set("version", String(options.version));
76
- const url = `${this.apiUrl}/api/v1/leaderboard?${params.toString()}`;
77
- const raw = await this.request(url, { method: "GET" });
78
- return this.mapLeaderboardResponse(raw);
79
- }
80
- // ============================================
81
- // PLAYER
82
- // ============================================
83
- /**
84
- * Get a player's rank and score. Returns `null` if the player has no score.
85
- *
86
- * @example
87
- * const player = await client.getPlayerRank({ playerGuid: 'abc-123' });
88
- * if (player) console.log(`Rank #${player.rank}`);
89
- */
90
- async getPlayerRank(options) {
91
- const leaderboard = options.leaderboard ?? this.defaultLeaderboard;
92
- const params = new URLSearchParams();
93
- if (leaderboard) params.set("leaderboard", leaderboard);
94
- const url = `${this.apiUrl}/api/v1/player/${encodeURIComponent(options.playerGuid)}${params.toString() ? "?" + params.toString() : ""}`;
95
- try {
96
- const raw = await this.request(url, { method: "GET" });
97
- return this.mapPlayerResponse(raw);
98
- } catch (error) {
99
- if (error instanceof KeeperBoardError && error.code === "NOT_FOUND") {
100
- return null;
101
- }
102
- throw error;
103
- }
104
- }
105
- /**
106
- * Update a player's display name.
107
- *
108
- * @example
109
- * const player = await client.updatePlayerName({
110
- * playerGuid: 'abc-123',
111
- * newName: 'MAVERICK',
112
- * });
113
- */
114
- async updatePlayerName(options) {
115
- const leaderboard = options.leaderboard ?? this.defaultLeaderboard;
116
- const params = new URLSearchParams();
117
- if (leaderboard) params.set("leaderboard", leaderboard);
118
- const url = `${this.apiUrl}/api/v1/player/${encodeURIComponent(options.playerGuid)}${params.toString() ? "?" + params.toString() : ""}`;
119
- const raw = await this.request(url, {
120
- method: "PUT",
121
- body: JSON.stringify({ player_name: options.newName })
122
- });
123
- return this.mapPlayerResponse(raw);
124
- }
125
- // ============================================
126
- // CLAIM (for migrated scores)
127
- // ============================================
128
- /**
129
- * Claim a migrated score by matching player name.
130
- * Used when scores were imported without player GUIDs.
131
- */
132
- async claimScore(options) {
133
- const leaderboard = options.leaderboard ?? this.defaultLeaderboard;
134
- const params = new URLSearchParams();
135
- if (leaderboard) params.set("leaderboard", leaderboard);
136
- const url = `${this.apiUrl}/api/v1/claim${params.toString() ? "?" + params.toString() : ""}`;
137
- const raw = await this.request(url, {
138
- method: "POST",
139
- body: JSON.stringify({
140
- player_guid: options.playerGuid,
141
- player_name: options.playerName
142
- })
143
- });
144
- return this.mapClaimResponse(raw);
145
- }
146
- // ============================================
147
- // HEALTH CHECK
148
- // ============================================
149
- /**
150
- * Check if the API is healthy. Does not require an API key.
151
- */
152
- async healthCheck() {
153
- const url = `${this.apiUrl}/api/v1/health`;
154
- const response = await fetch(url, {
155
- method: "GET",
156
- headers: { Accept: "application/json" }
157
- });
158
- const json = await response.json();
159
- if (!json.success) {
160
- throw new KeeperBoardError(json.error, json.code, response.status);
161
- }
162
- return json.data;
163
- }
164
- // ============================================
165
- // RESPONSE MAPPERS (snake_case → camelCase)
166
- // ============================================
167
- mapScoreResponse(raw) {
168
- return {
169
- id: raw.id,
170
- playerGuid: raw.player_guid,
171
- playerName: raw.player_name,
172
- score: raw.score,
173
- rank: raw.rank,
174
- isNewHighScore: raw.is_new_high_score
175
- };
176
- }
177
- mapLeaderboardResponse(raw) {
178
- return {
179
- entries: raw.entries.map((e) => ({
180
- rank: e.rank,
181
- playerGuid: e.player_guid,
182
- playerName: e.player_name,
183
- score: e.score
184
- })),
185
- totalCount: raw.total_count,
186
- resetSchedule: raw.reset_schedule,
187
- version: raw.version,
188
- oldestVersion: raw.oldest_version,
189
- nextReset: raw.next_reset
190
- };
191
- }
192
- mapPlayerResponse(raw) {
193
- return {
194
- id: raw.id,
195
- playerGuid: raw.player_guid,
196
- playerName: raw.player_name,
197
- score: raw.score,
198
- rank: raw.rank
199
- };
200
- }
201
- mapClaimResponse(raw) {
202
- return {
203
- claimed: raw.claimed,
204
- score: raw.score,
205
- rank: raw.rank,
206
- playerName: raw.player_name
207
- };
208
- }
209
- // ============================================
210
- // INTERNAL
211
- // ============================================
212
- async request(url, options) {
213
- const headers = {
214
- "Content-Type": "application/json",
215
- Accept: "application/json",
216
- "X-API-Key": this.apiKey
217
- };
218
- const response = await fetch(url, {
219
- ...options,
220
- headers: { ...headers, ...options.headers || {} }
221
- });
222
- const json = await response.json();
223
- if (!json.success) {
224
- throw new KeeperBoardError(json.error, json.code, response.status);
225
- }
226
- return json.data;
227
- }
228
- };
229
- _KeeperBoardClient.DEFAULT_API_URL = "https://keeperboard.vercel.app";
230
- var KeeperBoardClient = _KeeperBoardClient;
231
-
232
- // src/nameGenerator.ts
233
- var MAX_BASE_LENGTH = 10;
234
- var ADJECTIVES = [
235
- "Arcane",
236
- "Astro",
237
- "Blazing",
238
- "Bouncy",
239
- "Brassy",
240
- "Brisk",
241
- "Bubbly",
242
- "Chaotic",
243
- "Cheeky",
244
- "Chill",
245
- "Chunky",
246
- "Cloaked",
247
- "Cosmic",
248
- "Crimson",
249
- "Crispy",
250
- "Dashing",
251
- "Dizzy",
252
- "Dynamic",
253
- "Electric",
254
- "Epic",
255
- "Feisty",
256
- "Fiery",
257
- "Flashy",
258
- "Frosty",
259
- "Funky",
260
- "Furious",
261
- "Galactic",
262
- "Glitchy",
263
- "Golden",
264
- "Goofy",
265
- "Gritty",
266
- "Groovy",
267
- "Hyper",
268
- "Icy",
269
- "Inky",
270
- "Jazzy",
271
- "Jolly",
272
- "Jumpy",
273
- "Laser",
274
- "Legendary",
275
- "Loud",
276
- "Lucky",
277
- "Lunar",
278
- "Madcap",
279
- "Magic",
280
- "Majestic",
281
- "Meteor",
282
- "Mighty",
283
- "Minty",
284
- "Mystic",
285
- "Neon",
286
- "Nimble",
287
- "Nova",
288
- "Nuclear",
289
- "Omega",
290
- "Orbital",
291
- "Peppy",
292
- "Phantom",
293
- "Pixel",
294
- "Plasma",
295
- "Polished",
296
- "Primal",
297
- "Quantum",
298
- "Quick",
299
- "Radiant",
300
- "Rampaging",
301
- "Razor",
302
- "Rebel",
303
- "Retro",
304
- "Rogue",
305
- "Rowdy",
306
- "Savage",
307
- "Shadow",
308
- "Shiny",
309
- "Silly",
310
- "Sketchy",
311
- "Skybound",
312
- "Slick",
313
- "Snappy",
314
- "Solar",
315
- "Sonic",
316
- "Sparky",
317
- "Speedy",
318
- "Spiky",
319
- "Starry",
320
- "Stealthy",
321
- "Stormy",
322
- "Supreme",
323
- "Swift",
324
- "Thunder",
325
- "Turbo",
326
- "Twilight",
327
- "Ultra",
328
- "Vibrant",
329
- "Warped",
330
- "Wicked",
331
- "Wild",
332
- "Wizard",
333
- "Zappy",
334
- "Zesty"
335
- ];
336
- var NOUNS = [
337
- "Aardvark",
338
- "Asteroid",
339
- "Badger",
340
- "Bandit",
341
- "Banshee",
342
- "Beacon",
343
- "Beetle",
344
- "Blaster",
345
- "Blob",
346
- "Boomer",
347
- "Bot",
348
- "Brawler",
349
- "Buccaneer",
350
- "Buffalo",
351
- "Cannon",
352
- "Captain",
353
- "Caribou",
354
- "Charger",
355
- "Cheetah",
356
- "Chimera",
357
- "Cobra",
358
- "Comet",
359
- "Cosmonaut",
360
- "Cougar",
361
- "Coyote",
362
- "Cyborg",
363
- "Dagger",
364
- "Defender",
365
- "Dino",
366
- "Dragon",
367
- "Drifter",
368
- "Drone",
369
- "Duck",
370
- "Eagle",
371
- "Eel",
372
- "Falcon",
373
- "Ferret",
374
- "Fireball",
375
- "Fox",
376
- "Fury",
377
- "Gazelle",
378
- "Ghost",
379
- "Gizmo",
380
- "Gladiator",
381
- "Goblin",
382
- "Griffin",
383
- "Hammer",
384
- "Hawk",
385
- "Hero",
386
- "Hydra",
387
- "Iguana",
388
- "Jaguar",
389
- "Jester",
390
- "Jetpack",
391
- "Jinx",
392
- "Kangaroo",
393
- "Katana",
394
- "Kraken",
395
- "Lancer",
396
- "Laser",
397
- "Legend",
398
- "Lemur",
399
- "Leopard",
400
- "Lion",
401
- "Luchador",
402
- "Lynx",
403
- "Maverick",
404
- "Meteor",
405
- "Monkey",
406
- "Monsoon",
407
- "Moose",
408
- "Ninja",
409
- "Nova",
410
- "Octopus",
411
- "Oracle",
412
- "Otter",
413
- "Panther",
414
- "Phoenix",
415
- "Pirate",
416
- "Pixel",
417
- "Puma",
418
- "Quasar",
419
- "Racer",
420
- "Raptor",
421
- "Raven",
422
- "Reactor",
423
- "Rocket",
424
- "Ronin",
425
- "Saber",
426
- "Scorpion",
427
- "Shark",
428
- "Spartan",
429
- "Sphinx",
430
- "Sprinter",
431
- "Stallion",
432
- "Tiger",
433
- "Titan",
434
- "Viking",
435
- "Viper",
436
- "Wizard"
437
- ];
438
- function generatePlayerName() {
439
- const adjective = ADJECTIVES[Math.floor(Math.random() * ADJECTIVES.length)];
440
- const noun = NOUNS[Math.floor(Math.random() * NOUNS.length)];
441
- const number = Math.floor(Math.random() * 99) + 1;
442
- const base = (adjective + noun).slice(0, MAX_BASE_LENGTH);
443
- return `${base}${number}`;
444
- }
445
-
446
- // src/PlayerIdentity.ts
447
- var DEFAULT_KEY_PREFIX = "keeperboard_";
448
- var PlayerIdentity = class {
449
- constructor(config = {}) {
450
- this.keyPrefix = config.keyPrefix ?? DEFAULT_KEY_PREFIX;
451
- this.guidKey = `${this.keyPrefix}player_guid`;
452
- this.nameKey = `${this.keyPrefix}player_name`;
453
- this.nameAutoKey = `${this.keyPrefix}player_name_auto`;
454
- }
455
- /**
456
- * Get the stored player GUID, or null if none exists.
457
- */
458
- getPlayerGuid() {
459
- if (typeof window === "undefined" || !window.localStorage) {
460
- return null;
461
- }
462
- return localStorage.getItem(this.guidKey);
463
- }
464
- /**
465
- * Set the player GUID in localStorage.
466
- */
467
- setPlayerGuid(guid) {
468
- if (typeof window === "undefined" || !window.localStorage) {
469
- return;
470
- }
471
- localStorage.setItem(this.guidKey, guid);
472
- }
473
- /**
474
- * Get the stored player GUID, creating one if it doesn't exist.
475
- * Uses crypto.randomUUID() for generating new GUIDs.
476
- */
477
- getOrCreatePlayerGuid() {
478
- let guid = this.getPlayerGuid();
479
- if (!guid) {
480
- guid = this.generateUUID();
481
- this.setPlayerGuid(guid);
482
- }
483
- return guid;
484
- }
485
- /**
486
- * Get the stored player name, or null if none exists.
487
- */
488
- getPlayerName() {
489
- if (typeof window === "undefined" || !window.localStorage) {
490
- return null;
491
- }
492
- return localStorage.getItem(this.nameKey);
493
- }
494
- /**
495
- * Set the player name in localStorage.
496
- */
497
- setPlayerName(name) {
498
- if (typeof window === "undefined" || !window.localStorage) {
499
- return;
500
- }
501
- localStorage.setItem(this.nameKey, name);
502
- localStorage.removeItem(this.nameAutoKey);
503
- }
504
- /**
505
- * Get the stored player name, creating an auto-generated one if it doesn't exist.
506
- * Uses AdjectiveNounNumber pattern (e.g., ArcaneBlob99).
507
- */
508
- getOrCreatePlayerName() {
509
- let name = this.getPlayerName();
510
- if (!name) {
511
- name = generatePlayerName();
512
- if (typeof window !== "undefined" && window.localStorage) {
513
- localStorage.setItem(this.nameKey, name);
514
- localStorage.setItem(this.nameAutoKey, "true");
515
- }
516
- }
517
- return name;
518
- }
519
- /**
520
- * Check if the current player name was auto-generated (vs explicitly set by user).
521
- */
522
- isAutoGeneratedName() {
523
- if (typeof window === "undefined" || !window.localStorage) {
524
- return false;
525
- }
526
- return localStorage.getItem(this.nameAutoKey) === "true";
527
- }
528
- /**
529
- * Clear all stored player identity data.
530
- */
531
- clear() {
532
- if (typeof window === "undefined" || !window.localStorage) {
533
- return;
534
- }
535
- localStorage.removeItem(this.guidKey);
536
- localStorage.removeItem(this.nameKey);
537
- localStorage.removeItem(this.nameAutoKey);
538
- }
539
- /**
540
- * Check if player identity is stored.
541
- */
542
- hasIdentity() {
543
- return this.getPlayerGuid() !== null;
544
- }
545
- /**
546
- * Generate a UUID v4.
547
- * Uses crypto.randomUUID() if available, otherwise falls back to a manual implementation.
548
- */
549
- generateUUID() {
550
- if (typeof crypto !== "undefined" && crypto.randomUUID) {
551
- return crypto.randomUUID();
552
- }
553
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
554
- const r = Math.random() * 16 | 0;
555
- const v = c === "x" ? r : r & 3 | 8;
556
- return v.toString(16);
557
- });
558
- }
559
- };
560
-
561
- // src/Cache.ts
562
- var Cache = class {
563
- constructor(ttlMs) {
564
- this.fetchedAt = 0;
565
- this.inflight = null;
566
- this.pendingRefresh = null;
567
- this.ttlMs = ttlMs;
568
- }
569
- /**
570
- * Get cached value if fresh, otherwise fetch via the provided function.
571
- * Deduplicates concurrent calls — only one fetch runs at a time.
572
- */
573
- async getOrFetch(fetchFn) {
574
- if (this.isFresh()) {
575
- return this.data;
576
- }
577
- if (this.inflight) {
578
- return this.inflight;
579
- }
580
- this.inflight = fetchFn().then((result) => {
581
- this.data = result;
582
- this.fetchedAt = Date.now();
583
- this.inflight = null;
584
- return result;
585
- }).catch((err) => {
586
- this.inflight = null;
587
- throw err;
588
- });
589
- return this.inflight;
590
- }
591
- /**
592
- * Trigger a background refresh without awaiting the result.
593
- * Returns immediately. If a fetch is already in flight, schedules
594
- * the refresh to run after the current one completes.
595
- */
596
- refreshInBackground(fetchFn) {
597
- if (this.inflight) {
598
- this.pendingRefresh = fetchFn;
599
- return;
600
- }
601
- this.startBackgroundFetch(fetchFn);
602
- }
603
- startBackgroundFetch(fetchFn) {
604
- this.inflight = fetchFn().then((result) => {
605
- this.data = result;
606
- this.fetchedAt = Date.now();
607
- this.inflight = null;
608
- if (this.pendingRefresh) {
609
- const pending = this.pendingRefresh;
610
- this.pendingRefresh = null;
611
- this.startBackgroundFetch(pending);
612
- }
613
- return result;
614
- }).catch((err) => {
615
- this.inflight = null;
616
- this.pendingRefresh = null;
617
- throw err;
618
- });
619
- this.inflight.catch(() => {
620
- });
621
- }
622
- /** Invalidate the cache, forcing the next getOrFetch to re-fetch. */
623
- invalidate() {
624
- this.fetchedAt = 0;
625
- }
626
- /** Get the cached value without fetching. Returns undefined if empty or stale. */
627
- get() {
628
- return this.isFresh() ? this.data : void 0;
629
- }
630
- /** Get the cached value even if stale. Returns undefined only if never fetched. */
631
- getStale() {
632
- return this.data;
633
- }
634
- /** Check if the cache has fresh (non-expired) data. */
635
- isFresh() {
636
- return this.data !== void 0 && Date.now() - this.fetchedAt < this.ttlMs;
637
- }
638
- };
639
-
640
- // src/RetryQueue.ts
641
- var DEFAULT_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
642
- var RetryQueue = class {
643
- constructor(storageKey, maxAgeMs = DEFAULT_MAX_AGE_MS) {
644
- this.storageKey = storageKey;
645
- this.maxAgeMs = maxAgeMs;
646
- }
647
- /** Save a failed score for later retry. */
648
- save(score, metadata) {
649
- try {
650
- const pending = { score, metadata, timestamp: Date.now() };
651
- localStorage.setItem(this.storageKey, JSON.stringify(pending));
652
- } catch {
653
- }
654
- }
655
- /**
656
- * Get the pending score, or null if none exists or it has expired.
657
- * Automatically clears expired entries.
658
- */
659
- get() {
660
- try {
661
- const raw = localStorage.getItem(this.storageKey);
662
- if (!raw) return null;
663
- const pending = JSON.parse(raw);
664
- if (Date.now() - pending.timestamp > this.maxAgeMs) {
665
- this.clear();
666
- return null;
667
- }
668
- return { score: pending.score, metadata: pending.metadata };
669
- } catch {
670
- return null;
671
- }
672
- }
673
- /** Check if there's a pending score. */
674
- hasPending() {
675
- return this.get() !== null;
676
- }
677
- /** Clear the pending score. */
678
- clear() {
679
- try {
680
- localStorage.removeItem(this.storageKey);
681
- } catch {
682
- }
683
- }
684
- };
685
-
686
- // src/validation.ts
687
- var DEFAULTS = {
688
- minLength: 2,
689
- maxLength: 12,
690
- allowedPattern: /[^A-Za-z0-9_]/g
691
- };
692
- function validateName(input, options) {
693
- const opts = { ...DEFAULTS, ...options };
694
- let name = input.trim();
695
- const pattern = options?.allowedPattern ?? /[^A-Za-z0-9_]/g;
696
- name = name.replace(pattern, "");
697
- name = name.substring(0, opts.maxLength);
698
- if (name.length < opts.minLength) {
699
- return null;
700
- }
701
- return name;
702
- }
703
-
704
- // src/KeeperBoardSession.ts
705
- var KeeperBoardSession = class {
706
- constructor(config) {
707
- this.cachedLimit = 0;
708
- // Track the limit used for cached data
709
- this.isSubmitting = false;
710
- this.client = new KeeperBoardClient({
711
- apiKey: config.apiKey,
712
- defaultLeaderboard: config.leaderboard,
713
- apiUrl: config.apiUrl
714
- });
715
- this.identity = new PlayerIdentity(config.identity);
716
- this.leaderboard = config.leaderboard;
717
- this.cache = config.cache ? new Cache(config.cache.ttlMs) : null;
718
- this.retryQueue = config.retry ? new RetryQueue(
719
- `keeperboard_retry_${config.leaderboard}`,
720
- config.retry.maxAgeMs
721
- ) : null;
722
- }
723
- // ============================================
724
- // IDENTITY
725
- // ============================================
726
- /** Get or create a persistent player GUID. */
727
- getPlayerGuid() {
728
- return this.identity.getOrCreatePlayerGuid();
729
- }
730
- /** Get the stored player name, auto-generating one if none exists. */
731
- getPlayerName() {
732
- return this.identity.getOrCreatePlayerName();
733
- }
734
- /** Store a player name locally. Does NOT update the server — call updatePlayerName() for that. */
735
- setPlayerName(name) {
736
- this.identity.setPlayerName(name);
737
- }
738
- /** Check if the player has explicitly set a name (vs auto-generated). */
739
- hasExplicitPlayerName() {
740
- return this.identity.getPlayerName() !== null && !this.identity.isAutoGeneratedName();
741
- }
742
- /** Validate a name using configurable rules. Returns sanitized string or null. */
743
- validateName(input, options) {
744
- return validateName(input, options);
745
- }
746
- // ============================================
747
- // CORE API
748
- // ============================================
749
- /**
750
- * Submit a score. Identity and leaderboard are auto-injected.
751
- * Returns a discriminated union: `{ success: true, rank, isNewHighScore }` or `{ success: false, error }`.
752
- *
753
- * If retry is enabled, failed submissions are saved to localStorage for later retry.
754
- * Prevents concurrent double-submissions.
755
- */
756
- async submitScore(score, metadata) {
757
- if (this.isSubmitting) {
758
- return { success: false, error: "Submission in progress" };
759
- }
760
- this.isSubmitting = true;
761
- try {
762
- const result = await this.client.submitScore({
763
- playerGuid: this.getPlayerGuid(),
764
- playerName: this.getPlayerName(),
765
- score,
766
- metadata
767
- });
768
- this.retryQueue?.clear();
769
- if (this.cache) {
770
- this.cache.invalidate();
771
- this.cachedLimit = 0;
772
- this.cache.refreshInBackground(() => this.fetchSnapshot());
773
- }
774
- return {
775
- success: true,
776
- rank: result.rank,
777
- isNewHighScore: result.isNewHighScore
778
- };
779
- } catch (error) {
780
- const errorCode = error instanceof KeeperBoardError ? error.code : void 0;
781
- if (errorCode !== "PROFANITY_DETECTED") {
782
- this.retryQueue?.save(score, metadata);
783
- }
784
- return {
785
- success: false,
786
- error: error instanceof Error ? error.message : "Unknown error",
787
- errorCode
788
- };
789
- } finally {
790
- this.isSubmitting = false;
791
- }
792
- }
793
- /**
794
- * Get a combined snapshot: leaderboard entries (with `isCurrentPlayer` flag)
795
- * plus the current player's rank if they're outside the top N.
796
- *
797
- * Uses cache if enabled and fresh. If a larger limit is requested than
798
- * what's cached, the cache is invalidated and fresh data is fetched.
799
- */
800
- async getSnapshot(options) {
801
- const limit = options?.limit ?? 10;
802
- if (this.cache) {
803
- if (limit > this.cachedLimit) {
804
- this.cache.invalidate();
805
- }
806
- const result = await this.cache.getOrFetch(() => this.fetchSnapshot(limit));
807
- this.cachedLimit = limit;
808
- return result;
809
- }
810
- return this.fetchSnapshot(limit);
811
- }
812
- /**
813
- * Update the player's name on the server and locally.
814
- * Returns `{ success: true }` on success, or `{ success: false, error, errorCode }` on failure.
815
- */
816
- async updatePlayerName(newName) {
817
- try {
818
- await this.client.updatePlayerName({
819
- playerGuid: this.getPlayerGuid(),
820
- newName
821
- });
822
- this.identity.setPlayerName(newName);
823
- if (this.cache) {
824
- this.cache.invalidate();
825
- this.cachedLimit = 0;
826
- }
827
- return { success: true };
828
- } catch (error) {
829
- const errorCode = error instanceof KeeperBoardError ? error.code : void 0;
830
- return {
831
- success: false,
832
- error: error instanceof Error ? error.message : "Unknown error",
833
- errorCode
834
- };
835
- }
836
- }
837
- /**
838
- * Retry submitting a pending score (from a previous failed submission).
839
- * Call this on app startup.
840
- */
841
- async retryPendingScore() {
842
- const pending = this.retryQueue?.get();
843
- if (!pending) return null;
844
- const result = await this.submitScore(pending.score, pending.metadata);
845
- if (result.success) {
846
- this.retryQueue?.clear();
847
- }
848
- return result;
849
- }
850
- /** Check if there's a pending score in the retry queue. */
851
- hasPendingScore() {
852
- return this.retryQueue?.hasPending() ?? false;
853
- }
854
- /**
855
- * Pre-fetch snapshot data in the background for instant display later.
856
- * No-op if cache is disabled or already fresh.
857
- */
858
- prefetch() {
859
- if (!this.cache) return;
860
- if (this.cache.isFresh()) return;
861
- this.cache.refreshInBackground(() => this.fetchSnapshot());
862
- }
863
- /** Escape hatch: access the underlying KeeperBoardClient. */
864
- getClient() {
865
- return this.client;
866
- }
867
- // ============================================
868
- // INTERNAL
869
- // ============================================
870
- async fetchSnapshot(limit = 10) {
871
- const playerGuid = this.getPlayerGuid();
872
- const [leaderboard, playerRank] = await Promise.all([
873
- this.client.getLeaderboard({ limit }),
874
- this.client.getPlayerRank({ playerGuid })
875
- ]);
876
- const entries = leaderboard.entries.map((e) => ({
877
- rank: e.rank,
878
- playerGuid: e.playerGuid,
879
- playerName: e.playerName,
880
- score: e.score,
881
- isCurrentPlayer: e.playerGuid === playerGuid
882
- }));
883
- const playerInEntries = entries.some((e) => e.isCurrentPlayer);
884
- const effectivePlayerRank = playerRank && !playerInEntries ? playerRank : null;
885
- return {
886
- entries,
887
- totalCount: leaderboard.totalCount,
888
- playerRank: effectivePlayerRank
889
- };
890
- }
891
- };
892
- export {
893
- Cache,
894
- KeeperBoardClient,
895
- KeeperBoardError,
896
- KeeperBoardSession,
897
- PlayerIdentity,
898
- RetryQueue,
899
- generatePlayerName,
900
- validateName
901
- };
1
+ const _0x8bb8a=_0x33e2;(function(_0x2de8f2,_0x4f0b68){const _0x340034=_0x33e2,_0x458e25=_0x2de8f2();while(!![]){try{const _0x38385d=parseInt(_0x340034(0x227))/(-0x2442+-0x9f8+0x2e3b)*(parseInt(_0x340034(0x2fc))/(-0x1b27+0x22*0x6a+0xd15*0x1))+-parseInt(_0x340034(0x1fe))/(-0xe7+-0x6fa+-0x14*-0x65)*(-parseInt(_0x340034(0x30a))/(-0x15c1+0x1*0x2cb+-0x97d*-0x2))+-parseInt(_0x340034(0x203))/(0x2699+-0xc23*-0x1+-0x32b7)+parseInt(_0x340034(0x29a))/(0x653*-0x3+-0x1*-0x24a+0x10b5)*(-parseInt(_0x340034(0x2f4))/(0x444+0x26b1+-0x2aee))+-parseInt(_0x340034(0x1f6))/(-0xbc0+0x2*-0x544+0x1650)*(-parseInt(_0x340034(0x32b))/(-0x22b3+0xbd1+-0x1*-0x16eb))+-parseInt(_0x340034(0x287))/(0x5*-0x4ab+0x1*0xb82+-0x3*-0x3f5)*(-parseInt(_0x340034(0x2dd))/(-0x1408+0x218d+0x1e*-0x73))+-parseInt(_0x340034(0x280))/(0x160f+-0xb19+-0xaea);if(_0x38385d===_0x4f0b68)break;else _0x458e25['push'](_0x458e25['shift']());}catch(_0x317566){_0x458e25['push'](_0x458e25['shift']());}}}(_0x460c,-0x8b809*0x1+0xf945c+0x1d72a));var d=class extends Error{constructor(_0x2ff32b,_0x8c960e,_0x454312){const _0x3e81be=_0x33e2;super(_0x2ff32b),this['code']=_0x8c960e,this[_0x3e81be(0x2f5)]=_0x454312,this[_0x3e81be(0x33d)]=_0x3e81be(0x207);}};function _0x460c(){const _0x4efb62=['Dg9tDhjPBMC','z2v0ugXHEwvYtMfTzq','qMXVyG','y2HHCKnVzgvbDa','CgXHEwvYx25HBwu','qMfUzgL0','CMfUzg9T','AKjmqvK','ufjprKfosvrzx0rfvevdveve','zgvMyxvSDeXLywrLCMjVyxjK','r29SzgvU','AwzVzMK','rwXLy3rYAwm','yKXNB0C','zgf0yq','BMv4Df9YzxnLDa','mJyXnJq2n3vsshH1DW','C3rHDhvZq29Kzq','C3rVCMfNzuTLEq','qMfUC2HLzq','rNvYAw91CW','tgvTDxi','BgvHzgvYyM9HCMq','BMfTzuf1Dg9lzxK','mZy2ntC0tvreCgzP','BwfWugXHEwvYuMvZCg9UC2u','tgLVBG','q3jPBxnVBG','zuDqCxK','zw50CMLLCW','A2vLCgvYyM9HCMrFCMv0CNLF','s1bMvgO','rNvUA3K','z29Ku2m','BgLTAxq','r2XHzgLHDg9Y','CgXHEwvYr3vPza','thvJA3K','mJC0nZzowvnXrLq','tg91za','AxnFBMv3x2HPz2HFC2nVCMu','whv4EgS','twfNAwm','twfQzxn0Awm','v2LJA2vK','C3rHCNrLzf9HDa','C3rHCNrcywnRz3jVDw5KrMv0y2G','yxbWBgLJyxrPB24VANnVBG','l2fWAs92ms9SzwfKzxjIB2fYzd8','v29lD3O','r2PSC1y','q2HHB3rPyW','r0vu','z2v0t3jdCMvHDgvqBgf5zxjhDwLK','y2fJAgvKtgLTAxq','DhjPBq','CMv0CNLrDwv1zq','qxn0zxjVAwq','ywXS','uNngEMG','zMv0y2HLzef0','vevVueK','Bwf4qwDLtxm','ug9SAxnOzwq','zMLUAxnOuNvU','zMXVB3i','AgfZugvUzgLUzW','tevyz3i','vgH1BMrLCG','qNjHD2XLCG','qwfYzhzHCMS','mZy3otm3munRvfbVuq','CNvUx2LK','Cwn0Cei','uMvHy3rVCG','uKjNzfe','z2v0ugXHEwvYr3vPza','z2v0','AgvHzgvYCW','t21Lz2e','tM8Gywn0AxzLihj1BI4Gq2fSBcbZDgfYDfj1BIGPigzPCNn0lG','BwDwuLi','DKXOqLK','A2vLCgvYyM9HCMrF','rwvS','sw5REq','q2fWDgfPBG','u3vIBwLZC2LVBIbPBIbWCM9NCMvZCW','z2v0q3vYCMvUDfj1BKLK','BMfTzq','se1bqW','shDZBuG','CMvTB3zLsxrLBq','rhjPzNrLCG','q291z2fY','Awz5u2K','q295B3rL','vMLRAw5N','DMvYC2LVBG','vhDPBgLNAhq','BwvZC2fNzq','C2f2zq','tgvNzw5K','Aw52ywXPzgf0zq','Dhj1zq','AgfZrxHWBgLJAxrqBgf5zxjoyw1L','vu1frfi','C2v0ugXHEwvYr3vPza','AxngCMvZAa','C2LNBG','B2zMC2v0','y2XHAw1ty29Yzq','AxnbDxrVr2vUzxjHDgvKtMfTzq','rfHOyuW','AgvHBhrOq2HLy2S','Dg90ywXdB3vUDa','z2v0t3jdCMvHDgvqBgf5zxjoyw1L','rMfSy29U','DvHpyvi','Ewvjv1m','qu1jyvu','l2fWAs92ms9Zy29Yzxm','q2HLzwT5','DwHhq3i','vgL0yw4','zNjVBq','uhzzDhi','uMv0CM8','swD1yw5H','qNvJy2fUzwvY','y2XPzw50','CgXHEwvYx2D1Awq','qM9VBwvY','rM94','C1vzBKW','DhrStxm','zxHWAxjLC19HDa','BwfWu2nVCMvszxnWB25Zzq','r3jVB3z5','rMvPC3r5','ugnKC0u','rMjdr1G','q2H1BMT5','qMfKz2vY','DKLeufe','BfrgAhy','ohvcs01KsW','rMLLCNK','r3jPzMzPBG','CMvXDwvZDa','tLHzuNm','ugvWChK','z2v0t3jgzxrJAa','ugfUDgHLCG','ndi2A3LuB0vw','ugHVzw5PEa','AuDlwLO','Chzdzw4','BMfTzuTLEq','nJKYnJG1tereBwDA','qNjHC3n5','zxjYB3i','C29Tzq','s2vLCgvYqM9HCMrfCNjVCG','ELPHCw8','ANz1Cuu','q1HJDe0','CgXHEwvYx25HBwvFyxv0BW','l2fWAs92ms9JBgfPBq','rKLvCLm','z3vPzeTLEq','rwrKAgW','C29oyKK','rhLUyw1PyW','u2fIzxi','CMv2zxjZzq','uMfWDg9Y','C3rHCNrsDw4','ufvu','shLKCMe','sNvTChK','AwrLBNrPDhK','AgfZswrLBNrPDhK','uM9NDwu','EhH4EhH4EhGTEhH4Ec00EhH4lxL4EhGTEhH4EhH4EhH4EhH4','revgqvvmvf9bueLFvvjm','Aw5MBgLNAhq','vwrxExe','z1bVEMy','y2fJAgu','C2XPy2u','y2XHAw1Lza','uM9JA2v0','qMXHEMLUzW','zevcrw8','m0TuCvnIrq','u3rLywX0AhK','sLP5AKe','AgfZqwn0AxzLuNvU','r2HVC3q','D1nUDMy','C3rYAw5NAwz5','AxnozxDiAwDOu2nVCMu','thvUyxi','BvPTq2C','rgfZAgLUzW','s2f0yw5H','rNvYEq','txLZDgLJ','u3bPA3K','u2nVCNbPB24','uxjYDwe','C3rHDhvZ','t1nArfm','u2HHzg93','u25HChb5','wgTOvMC','vxrqy00','DgLTzxn0yw1W','sujHq2u','rMvYCMv0','tgvNzw5Kyxj5','tgfUy2vY','DLbuBw8','BwLU','vw5RBM93BIbLCNjVCG','BwfW','D2Tsvgy','u3rVCM15','C3vIDgXL','BM93','wMvZDhK','DxbKyxrLugXHEwvYtMfTzq','BwfWtgvHzgvYyM9HCMrszxnWB25Zzq','CMfUAW','tw9VC2u','uu5wvKy','A2DnDg8','q29ICMe','CMvWBgfJzq','BMv3tMfTzq','tw9UC29VBG','BwfWu3rHCNrsDw5szxnWB25Zzq','uM9UAw4','AxntDwjTAxr0Aw5N','ANnVBG','C2nVCMu','rLrbyuu','CM94Bhu','u29UAwm','z2vUzxjHDgvvvuLe','A2v5uhjLzML4','qNjPC2S','rwfNBgu','l2fWAs92ms9WBgf5zxiV','u3bOAw54','r2XPDgnOEq','Bg9JywXtDg9YywDL','ChvZAa','BwfWrMLUAxnOuNvUuMvZCg9UC2u','zw5JB2rL','tMvVBG','t3jIAxrHBa','u29Syxi','CfPpqKm','u3vWCMvTzq','DezPDeK','Aw1WB3j0s2v5','s3jHA2vU','zg51DM0','u3rHBgXPB24','yxbPs2v5','y29Kzq','sMLUEa','rgL6ENK','CMvMCMvZAeLUqMfJA2DYB3vUza','tMLUAMe','CMv0CNLqzw5KAw5Nu2nVCMu','BgvUz3rO','uwHIze0','q29ZBw9Uyxv0','sgfTBwvY','uMLAA3y','Ahr0Chm6lY9RzwvWzxjIB2fYzc52zxjJzwWUyxbW','mtC4mJa2otzsCuPlsM0','CMfUzg9Tvvvjra','zMv0y2HtBMfWC2HVDa','C2LNBMLUz1nLy3jLDa','CMvZzxrFC2nOzwr1Bgu','CMv0CNK','qMXHC3rLCG','nJmZntm1me9gqNDQEa','v2L6yxjK','yxbPvxjS','r0vWA3q','DgHLBG','u3bLzwr5','C3vIBwL0u2nVCMu','Du9Xq2O','CgvUzgLUz1jLzNjLC2G','vM15sgu','BwfWq2XHAw1szxnWB25Zzq','uMf6B3i','CgfYC2u','zNjVBunOyxjdB2rL','Dg90ywXFy291BNq','Bu1jDwK','z2v0tgvHzgvYyM9HCMq','tNvJBgvHCG','sMv0CgfJAW','nKvmB3bRyq','ywPdDw4','rMLYzwjHBgW','uwD4Bei','DMHlrfG','AeX3yNe','y3vYCMvUDfj1BKLK','Bwf4tgvUz3rO','qMvHy29U','z2v0sxrLBq','uLH6vLO','tgfZzxi','ue9tva','l2fWAs92ms9OzwfSDgG','ug9qEfG','uhvTyq','z2v0ugXHEwvYuMfUAW','u2LSBhK','u3bHCNrHBG','u3bYAw50zxi','v2LSza','sxfWywm','vhvYyM8','D012EhO','uwnsvgG','tM92yq','ugL4zwW','uxvHC2fY','u2XPy2S','wMfWChK','q2fUBM9U','C2v0ugXHEwvYtMfTzq','q29ZBwLJ','sM9SBhK','C2v0','qNvMzMfSBW','vujeqK4','ywXSB3DLzfbHDhrLCM4','t2n0B3b1CW','C0jPyKu','vMLICMfUDa','ufDkEeO','twv0zw9Y','C2v0sxrLBq','se1uCNu','q2HHCMDLCG','u2TLDgnOEq','wc1tAwDUyxr1CMu','AuHmsLO','z2v0q2XPzw50','Agf2quO','twfKy2fW','y2f0y2G','t3r0zxi','y2XLyxi','u0Hblti1nG','Bwv0ywrHDge','CgXHEwvYtMfTzq','r2f6zwXSzq','CNvUswq','r1LNs0i','s2fUz2fYB28','uMf2zw4','BwLUtgvUz3rO','r2Tuy2G','B0r1tvO','l2fWAs92ms9YDw5Zl2zPBMLZAa','mtf3Eu5yrKO','uxvPy2S','sMvZDgvY','AM9PBG','u3rHCNj5','C3vJy2vZCW','yu1zz0C'];_0x460c=function(){return _0x4efb62;};return _0x460c();}function _0x33e2(_0x43be26,_0x5d9876){_0x43be26=_0x43be26-(0x2*0xfe1+-0x2558+0x757);const _0x32d8f7=_0x460c();let _0x11b849=_0x32d8f7[_0x43be26];if(_0x33e2['VmhgZT']===undefined){var _0x26173c=function(_0x24f7aa){const _0x3ceb0e='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x23aff6='',_0x579b11='';for(let _0x28accb=0x1424+0x11*0xd+-0x1501*0x1,_0x4b2cc2,_0xea0e7,_0x24fef0=-0xe9*-0x17+0x497+-0x1986;_0xea0e7=_0x24f7aa['charAt'](_0x24fef0++);~_0xea0e7&&(_0x4b2cc2=_0x28accb%(-0x12*-0xce+-0x1*0x12a+-0xd4e)?_0x4b2cc2*(-0x6d*0x2c+-0x163c+0x2*0x149c)+_0xea0e7:_0xea0e7,_0x28accb++%(-0x6ff+-0x19e2+-0x191*-0x15))?_0x23aff6+=String['fromCharCode'](-0x1*-0x1f2f+0x1*-0x1d9+-0x5*0x5ab&_0x4b2cc2>>(-(-0x1*-0xa7b+0x689*-0x5+0x196*0xe)*_0x28accb&0x2b*-0x32+0x113e+-0x8d2)):0x304+0x19e4+0x2e4*-0xa){_0xea0e7=_0x3ceb0e['indexOf'](_0xea0e7);}for(let _0x1e3ecb=0x55*-0x7+0x1*0x1f9f+-0x1d4c,_0x58e7d1=_0x23aff6['length'];_0x1e3ecb<_0x58e7d1;_0x1e3ecb++){_0x579b11+='%'+('00'+_0x23aff6['charCodeAt'](_0x1e3ecb)['toString'](-0x1fa5+-0x1aab+0x1d30*0x2))['slice'](-(-0xa91+-0x25bb+0x304e));}return decodeURIComponent(_0x579b11);};_0x33e2['nJCWpv']=_0x26173c,_0x33e2['idMOUT']={},_0x33e2['VmhgZT']=!![];}const _0x548d98=_0x32d8f7[0x59*-0x8+0x76*-0x37+0x22a*0xd],_0x41d748=_0x43be26+_0x548d98,_0x43c588=_0x33e2['idMOUT'][_0x41d748];return!_0x43c588?(_0x11b849=_0x33e2['nJCWpv'](_0x11b849),_0x33e2['idMOUT'][_0x41d748]=_0x11b849):_0x11b849=_0x43c588,_0x11b849;}async function R(_0x98e64d,_0x20d389){const _0xb7daf0=_0x33e2,_0x3b3f7a={'ESncX':function(_0x448d01,_0x399a13){return _0x448d01-_0x399a13;},'wkRTf':function(_0x386aab,_0x27f48a){return _0x386aab===_0x27f48a;},'dEBEo':_0xb7daf0(0x321),'sBibE':_0xb7daf0(0x2af),'VmyHe':function(_0xc79722,_0x46fe8b){return _0xc79722%_0x46fe8b;},'iJUwW':function(_0x3ee461,_0x5cc2b2){return _0x3ee461^_0x5cc2b2;},'vhKDX':'raw','mMIui':_0xb7daf0(0x2d1),'GEpkt':_0xb7daf0(0x1d1),'GjlsV':_0xb7daf0(0x33e),'soNbI':function(_0x48dd49,_0x2499e5){return _0x48dd49!==_0x2499e5;},'qctpB':function(_0x3ae6e7,_0x5e24c0){return _0x3ae6e7(_0x5e24c0);},'JvkrX':function(_0x58873b,_0x29ada0){return _0x58873b^_0x29ada0;},'kgMto':function(_0x35ed1d,_0x2cfc35){return _0x35ed1d^_0x2cfc35;},'ifofi':function(_0x55ac74,_0xdb9f1a){return _0x55ac74(_0xdb9f1a);}};let _0xbc31ba=new TextEncoder(),_0x52f18b=await crypto[_0xb7daf0(0x249)][_0xb7daf0(0x26f)](_0x3b3f7a['vhKDX'],_0xbc31ba['encode'](_0x20d389),{'name':_0xb7daf0(0x33e),'hash':_0x3b3f7a[_0xb7daf0(0x296)]},!(0x5*0x60+-0x25b9*-0x1+0x7*-0x5a8),[_0x3b3f7a[_0xb7daf0(0x28a)]]),_0x405521=await crypto[_0xb7daf0(0x249)][_0xb7daf0(0x1d1)](_0x3b3f7a[_0xb7daf0(0x316)],_0x52f18b,_0xbc31ba[_0xb7daf0(0x268)](_0x98e64d[_0xb7daf0(0x308)]['slice'](0x1360+-0x13a+-0x1226,0x1*0x24d3+0x19b7+-0x3e82*0x1))),_0x5c20b0=await crypto[_0xb7daf0(0x249)][_0xb7daf0(0x26f)](_0x3b3f7a[_0xb7daf0(0x29e)],_0x405521,{'name':_0x3b3f7a['GjlsV'],'hash':'SHA-256'},!(0x9e3*-0x3+0x7a*0x1b+0x10cc),[_0x3b3f7a[_0xb7daf0(0x28a)]]),_0x2ffa35=[_0x98e64d['playerGuid']];_0x98e64d[_0xb7daf0(0x2d5)]&&_0x2ffa35[_0xb7daf0(0x266)](_0x98e64d[_0xb7daf0(0x2d5)]['split']('')[_0xb7daf0(0x213)]()[_0xb7daf0(0x2e0)]('')),_0x3b3f7a[_0xb7daf0(0x210)](_0x98e64d[_0xb7daf0(0x25a)],void(0x1*-0x126b+-0x18c5+0x2b30))&&_0x2ffa35['push'](_0x3b3f7a[_0xb7daf0(0x32d)](String,_0x3b3f7a['JvkrX'](_0x98e64d[_0xb7daf0(0x25a)],0xe7b3+0x5998+-0x825c))),_0x2ffa35[_0xb7daf0(0x266)](_0x3b3f7a['qctpB'](String,_0x3b3f7a[_0xb7daf0(0x251)](_0x98e64d[_0xb7daf0(0x23e)],-0x134b8+0x10784*0x1+-0x3*-0x594b)));let _0x3c1f27=_0x2ffa35['join']('::'),_0x1ad0c2=await crypto[_0xb7daf0(0x249)]['sign'](_0x3b3f7a[_0xb7daf0(0x316)],_0x5c20b0,_0xbc31ba['encode'](_0x3c1f27)),_0x3078d1=Array[_0xb7daf0(0x1e1)](new Uint8Array(_0x1ad0c2))[_0xb7daf0(0x246)](_0x10a26c=>_0x10a26c[_0xb7daf0(0x2e4)](0x13de+-0xcc8+-0x706)['padStart'](-0x194a+0x2154+0x4*-0x202,'0'))['join'](''),_0x1dab86=String(_0x98e64d[_0xb7daf0(0x23e)]),_0x516f9c=_0x3078d1['split']('')[_0xb7daf0(0x246)]((_0x13e887,_0xdcd20a)=>{const _0xfb3f5a=_0xb7daf0,_0x2e7fca={'EGKdR':function(_0x261400,_0x9118ab){return _0x3b3f7a['ESncX'](_0x261400,_0x9118ab);}};if(_0x3b3f7a[_0xfb3f5a(0x247)](_0x3b3f7a[_0xfb3f5a(0x226)],_0x3b3f7a[_0xfb3f5a(0x2c1)]))try{let _0x3f8641=_0x3fe153[_0xfb3f5a(0x2a3)](this[_0xfb3f5a(0x2f6)]);if(!_0x3f8641)return null;let _0x188f8b=_0x347b2a['parse'](_0x3f8641);return _0x2e7fca['EGKdR'](_0x25a55b[_0xfb3f5a(0x24a)](),_0x188f8b[_0xfb3f5a(0x23e)])>this['maxAgeMs']?(this[_0xfb3f5a(0x2d0)](),null):{'score':_0x188f8b[_0xfb3f5a(0x25a)],'metadata':_0x188f8b[_0xfb3f5a(0x2d2)]};}catch{return null;}else{let _0x4e1e70=_0x1dab86[_0x3b3f7a[_0xfb3f5a(0x290)](_0xdcd20a,_0x1dab86['length'])];return String[_0xfb3f5a(0x294)](_0x3b3f7a['iJUwW'](_0x13e887['charCodeAt'](-0x30e+-0x212d+0x7*0x52d),_0x4e1e70[_0xfb3f5a(0x2e7)](0x1*-0x20a7+0x2470+-0x3c9)));}})[_0xb7daf0(0x2e0)]('');return _0x3b3f7a[_0xb7daf0(0x2ef)](btoa,_0x516f9c)['replace'](/\+/g,'-')[_0xb7daf0(0x253)](/\//g,'_')[_0xb7daf0(0x253)](/=/g,'');}var y=class y{constructor(_0x2aae2c){const _0x1a24ff=_0x33e2;let _0x20d6df=_0x2aae2c[_0x1a24ff(0x289)]??y[_0x1a24ff(0x21d)];this[_0x1a24ff(0x289)]=_0x20d6df[_0x1a24ff(0x253)](/\/$/,''),this['apiKey']=_0x2aae2c['apiKey'],this['defaultLeaderboard']=_0x2aae2c[_0x1a24ff(0x2ed)],this[_0x1a24ff(0x283)]=_0x2aae2c[_0x1a24ff(0x283)];}async['submitScore'](_0xb8de30){const _0x15293c=_0x33e2,_0x387e53={'bLgoG':function(_0x24cfef,_0x2bb47d){return _0x24cfef+_0x2bb47d;},'uYuSB':_0x15293c(0x2a6)};let _0x83a6b1=_0xb8de30[_0x15293c(0x2fa)]??this[_0x15293c(0x2ed)],_0x372e3a=new URLSearchParams();_0x83a6b1&&_0x372e3a[_0x15293c(0x2bc)](_0x15293c(0x2fa),_0x83a6b1);let _0x371dce=this[_0x15293c(0x289)]+_0x15293c(0x1dd)+(_0x372e3a[_0x15293c(0x2e4)]()?_0x387e53[_0x15293c(0x2f1)]('?',_0x372e3a['toString']()):''),_0x2d60dd={'player_guid':_0xb8de30[_0x15293c(0x308)],'player_name':_0xb8de30[_0x15293c(0x2d3)],'score':_0xb8de30[_0x15293c(0x25a)],..._0xb8de30[_0x15293c(0x2d2)]&&{'metadata':_0xb8de30[_0x15293c(0x2d2)]}},_0x48b4a0=await this[_0x15293c(0x1f9)](_0x371dce,{'method':_0x387e53['uYuSB'],'body':JSON[_0x15293c(0x22d)](_0x2d60dd)});return this[_0x15293c(0x1ed)](_0x48b4a0);}async[_0x8bb8a(0x297)](_0x37a9f2){const _0xa7af97=_0x8bb8a,_0x1c08bf={'SRKYo':_0xa7af97(0x306),'vPTmo':function(_0x1e9a4a,_0x26e693){return _0x1e9a4a(_0x26e693);},'HMTru':function(_0x10ad93,_0x428c88){return _0x10ad93!==_0x428c88;},'jvuqE':_0xa7af97(0x1c6),'UtPcM':_0xa7af97(0x318)};let _0x48b7bd=_0x37a9f2?.[_0xa7af97(0x2fa)]??this[_0xa7af97(0x2ed)],_0x1ddbb9=_0x37a9f2?.[_0xa7af97(0x306)]??-0x223e+0x786+0x1ac2,_0x31c84c=_0x37a9f2?.['offset']??0x336*0x7+0x3e7+0x1a61*-0x1,_0x290719=new URLSearchParams();_0x290719[_0xa7af97(0x2bc)](_0x1c08bf['SRKYo'],String(Math[_0xa7af97(0x244)](_0x1ddbb9,0x23c6+-0x1af*0x13+-0xb*0x4f))),_0x290719['set'](_0xa7af97(0x1d2),_0x1c08bf[_0xa7af97(0x243)](String,_0x31c84c)),_0x48b7bd&&_0x290719[_0xa7af97(0x2bc)](_0xa7af97(0x2fa),_0x48b7bd),_0x1c08bf[_0xa7af97(0x2c6)](_0x37a9f2?.[_0xa7af97(0x1c6)],void(-0x1*-0x151c+-0xb05+0x1*-0xa17))&&_0x290719[_0xa7af97(0x2bc)](_0x1c08bf[_0xa7af97(0x209)],_0x1c08bf[_0xa7af97(0x243)](String,_0x37a9f2[_0xa7af97(0x1c6)]));let _0x427283=this['apiUrl']+_0xa7af97(0x314)+_0x290719[_0xa7af97(0x2e4)](),_0x5afd56=await this['request'](_0x427283,{'method':_0x1c08bf[_0xa7af97(0x23d)]});return this[_0xa7af97(0x24d)](_0x5afd56);}async['getPlayerRank'](_0x424a50){const _0x38ab1e=_0x8bb8a,_0x458b3d={'hYlMs':function(_0x6d3056,_0x5acd95){return _0x6d3056*_0x5acd95;},'gVUpy':function(_0x56e839,_0x27e8ff){return _0x56e839+_0x27e8ff;},'havAJ':function(_0x1c3632,_0x178840){return _0x1c3632+_0x178840;},'ifySi':_0x38ab1e(0x2fa),'GkTch':function(_0x5dc10d,_0x16d0dc){return _0x5dc10d+_0x16d0dc;},'kEWCd':_0x38ab1e(0x1df),'yZiLi':_0x38ab1e(0x318),'rBnVa':function(_0x51764e,_0x3329c0){return _0x51764e===_0x3329c0;}};let _0x502744=_0x424a50[_0x38ab1e(0x2fa)]??this[_0x38ab1e(0x2ed)],_0xd49e02=new URLSearchParams();_0x502744&&_0xd49e02[_0x38ab1e(0x2bc)](_0x458b3d[_0x38ab1e(0x1c3)],_0x502744);let _0x1ba99f=this[_0x38ab1e(0x289)]+_0x38ab1e(0x262)+encodeURIComponent(_0x424a50['playerGuid'])+(_0xd49e02[_0x38ab1e(0x2e4)]()?_0x458b3d[_0x38ab1e(0x2da)]('?',_0xd49e02[_0x38ab1e(0x2e4)]()):'');try{if(_0x458b3d['kEWCd']!==_0x38ab1e(0x1df)){let _0x36dc2a=_0x28accb[_0x4b2cc2[_0x38ab1e(0x325)](_0x458b3d['hYlMs'](_0xea0e7[_0x38ab1e(0x2ea)](),_0x24fef0[_0x38ab1e(0x27a)]))],_0x2d7bd2=_0x1e3ecb[_0x58e7d1[_0x38ab1e(0x325)](_0x35635d[_0x38ab1e(0x2ea)]()*_0x1afc1c[_0x38ab1e(0x27a)])],_0x4ce487=_0x458b3d['gVUpy'](_0x2d5c66[_0x38ab1e(0x325)](_0x108f28[_0x38ab1e(0x2ea)]()*(0x959*-0x4+-0x1*0x1d1b+0x42e2)),-0x1*-0x210d+-0x100*-0x21+-0xb02*0x6);return''+_0x458b3d[_0x38ab1e(0x2cc)](_0x36dc2a,_0x2d7bd2)[_0x38ab1e(0x222)](-0x1*-0xfd1+0x2285+-0x3256,-0x22c3+-0xd0c+0x9*0x551)+_0x4ce487;}else{let _0x1a6d8a=await this['request'](_0x1ba99f,{'method':_0x458b3d['yZiLi']});return this['mapPlayerResponse'](_0x1a6d8a);}}catch(_0x540aee){if(_0x540aee instanceof d&&_0x458b3d['rBnVa'](_0x540aee['code'],'NOT_FOUND'))return null;throw _0x540aee;}}async[_0x8bb8a(0x24c)](_0x5691eb){const _0x288f00=_0x8bb8a,_0x30a73c={'UBDBN':_0x288f00(0x2fa),'UMEDR':function(_0x312755,_0x9cc1b4){return _0x312755(_0x9cc1b4);},'FbCGX':function(_0x496651,_0x34ab6d){return _0x496651+_0x34ab6d;},'vIDPQ':_0x288f00(0x216)};let _0x38009a=_0x5691eb[_0x288f00(0x2fa)]??this['defaultLeaderboard'],_0x4ba83e=new URLSearchParams();_0x38009a&&_0x4ba83e[_0x288f00(0x2bc)](_0x30a73c[_0x288f00(0x2be)],_0x38009a);let _0x2c72ea=this[_0x288f00(0x289)]+_0x288f00(0x262)+_0x30a73c[_0x288f00(0x1ce)](encodeURIComponent,_0x5691eb[_0x288f00(0x308)])+(_0x4ba83e[_0x288f00(0x2e4)]()?_0x30a73c[_0x288f00(0x1f1)]('?',_0x4ba83e[_0x288f00(0x2e4)]()):''),_0x5de169=await this[_0x288f00(0x1f9)](_0x2c72ea,{'method':_0x30a73c[_0x288f00(0x1f4)],'body':JSON[_0x288f00(0x22d)]({'player_name':_0x5691eb[_0x288f00(0x254)]})});return this['mapPlayerResponse'](_0x5de169);}async[_0x8bb8a(0x1d3)](_0xeb43dd){const _0x5db910=_0x8bb8a,_0x5b886d={'oDuMZ':'leaderboard','biaiD':function(_0x2d1cc1,_0x9275ed){return _0x2d1cc1+_0x9275ed;},'RsFzh':_0x5db910(0x2a6)};let _0x13d2a0=_0xeb43dd['leaderboard']??this[_0x5db910(0x2ed)],_0x4bc009=new URLSearchParams();_0x13d2a0&&_0x4bc009[_0x5db910(0x2bc)](_0x5b886d[_0x5db910(0x2db)],_0x13d2a0);let _0x21f7bf=this[_0x5db910(0x289)]+_0x5db910(0x20c)+(_0x4bc009[_0x5db910(0x2e4)]()?_0x5b886d['biaiD']('?',_0x4bc009[_0x5db910(0x2e4)]()):''),_0x50eda5=await this[_0x5db910(0x1f9)](_0x21f7bf,{'method':_0x5b886d[_0x5db910(0x31f)],'body':JSON[_0x5db910(0x22d)]({'player_guid':_0xeb43dd['playerGuid'],'player_name':_0xeb43dd[_0x5db910(0x2d3)]})});return this[_0x5db910(0x291)](_0x50eda5);}async[_0x8bb8a(0x1d6)](){const _0x5e8b9a=_0x8bb8a,_0x3452e9={'PFbIY':'GET','HwsmH':_0x5e8b9a(0x313)};let _0x31ac63=this[_0x5e8b9a(0x289)]+_0x5e8b9a(0x2a7),_0x32ed42=await fetch(_0x31ac63,{'method':_0x3452e9['PFbIY'],'headers':{'Accept':_0x3452e9[_0x5e8b9a(0x33f)]}}),_0x3c20d0=await _0x32ed42[_0x5e8b9a(0x259)]();if(!_0x3c20d0[_0x5e8b9a(0x2e2)])throw new d(_0x3c20d0[_0x5e8b9a(0x205)],_0x3c20d0[_0x5e8b9a(0x274)],_0x32ed42['status']);return _0x3c20d0[_0x5e8b9a(0x2f2)];}async[_0x8bb8a(0x215)](_0x43f4b4){const _0x4a0505=_0x8bb8a,_0x4f277d={'pvCen':'leaderboard','RwMuv':function(_0x4835ce,_0x167e65,_0x46fa63){return _0x4835ce(_0x167e65,_0x46fa63);},'hLwbq':'X-Signature','lTFhv':_0x4a0505(0x2a6)};let _0x5e8a25=_0x43f4b4[_0x4a0505(0x2fa)]??this[_0x4a0505(0x2ed)],_0x32c9a2=new URLSearchParams();_0x5e8a25&&_0x32c9a2[_0x4a0505(0x2bc)](_0x4f277d[_0x4a0505(0x201)],_0x5e8a25);let _0x39e208=this[_0x4a0505(0x289)]+'/api/v1/runs/start'+(_0x32c9a2[_0x4a0505(0x2e4)]()?'?'+_0x32c9a2['toString']():''),_0x5163ae=Date[_0x4a0505(0x24a)](),_0x4e7ecf={'player_guid':_0x43f4b4[_0x4a0505(0x308)],'timestamp':_0x5163ae},_0x51fcc5={};if(this[_0x4a0505(0x283)]){let _0x2c994d=await _0x4f277d['RwMuv'](R,{'playerGuid':_0x43f4b4[_0x4a0505(0x308)],'timestamp':_0x5163ae},this[_0x4a0505(0x283)]);_0x51fcc5[_0x4f277d[_0x4a0505(0x29f)]]=_0x2c994d;}let _0x4da998=await this[_0x4a0505(0x1f9)](_0x39e208,{'method':_0x4f277d[_0x4a0505(0x1f5)],'body':JSON[_0x4a0505(0x22d)](_0x4e7ecf),'headers':_0x51fcc5});return this['mapStartRunResponse'](_0x4da998);}async[_0x8bb8a(0x324)](_0x399031){const _0xfb590d=_0x8bb8a,_0x17ae98={'gPozf':'leaderboard','roxlu':function(_0x20ae41,_0x496aec,_0x3be5f4){return _0x20ae41(_0x496aec,_0x3be5f4);}};let _0x3850ca=_0x399031[_0xfb590d(0x2fa)]??this[_0xfb590d(0x2ed)],_0x22d8f1=new URLSearchParams();_0x3850ca&&_0x22d8f1[_0xfb590d(0x2bc)](_0x17ae98[_0xfb590d(0x220)],_0x3850ca);let _0x4d65dd=this[_0xfb590d(0x289)]+_0xfb590d(0x2dc)+(_0x22d8f1[_0xfb590d(0x2e4)]()?'?'+_0x22d8f1['toString']():''),_0x41f5f3=Date['now'](),_0xa78e0a={'run_id':_0x399031[_0xfb590d(0x2d5)],'player_guid':_0x399031['playerGuid'],'player_name':_0x399031[_0xfb590d(0x2d3)],'score':_0x399031[_0xfb590d(0x25a)],'timestamp':_0x41f5f3,..._0x399031[_0xfb590d(0x2d2)]&&{'metadata':_0x399031[_0xfb590d(0x2d2)]}},_0x7c0f18={};if(this[_0xfb590d(0x283)]){let _0x1f90e5=await _0x17ae98[_0xfb590d(0x25c)](R,{'playerGuid':_0x399031[_0xfb590d(0x308)],'timestamp':_0x41f5f3,'score':_0x399031['score'],'runId':_0x399031[_0xfb590d(0x2d5)]},this[_0xfb590d(0x283)]);_0x7c0f18[_0xfb590d(0x2c9)]=_0x1f90e5;}let _0xc0350f=await this[_0xfb590d(0x1f9)](_0x4d65dd,{'method':_0xfb590d(0x2a6),'body':JSON['stringify'](_0xa78e0a),'headers':_0x7c0f18});return this[_0xfb590d(0x267)](_0xc0350f);}[_0x8bb8a(0x1ed)](_0x388c9c){const _0x49daa1=_0x8bb8a;return{'id':_0x388c9c['id'],'playerGuid':_0x388c9c[_0x49daa1(0x1e7)],'playerName':_0x388c9c[_0x49daa1(0x2e8)],'score':_0x388c9c['score'],'rank':_0x388c9c[_0x49daa1(0x24e)],'isNewHighScore':_0x388c9c[_0x49daa1(0x30c)]};}[_0x8bb8a(0x24d)](_0x334154){const _0x1af2df=_0x8bb8a;return{'entries':_0x334154[_0x1af2df(0x301)][_0x1af2df(0x246)](_0x19c67c=>({'rank':_0x19c67c['rank'],'playerGuid':_0x19c67c[_0x1af2df(0x1e7)],'playerName':_0x19c67c[_0x1af2df(0x2e8)],'score':_0x19c67c[_0x1af2df(0x25a)]})),'totalCount':_0x334154[_0x1af2df(0x295)],'resetSchedule':_0x334154[_0x1af2df(0x284)],'version':_0x334154[_0x1af2df(0x1c6)],'oldestVersion':_0x334154['oldest_version'],'nextReset':_0x334154[_0x1af2df(0x2f3)]};}[_0x8bb8a(0x2fd)](_0x8963e1){const _0x54dd48=_0x8bb8a;return{'id':_0x8963e1['id'],'playerGuid':_0x8963e1[_0x54dd48(0x1e7)],'playerName':_0x8963e1[_0x54dd48(0x2e8)],'score':_0x8963e1[_0x54dd48(0x25a)],'rank':_0x8963e1[_0x54dd48(0x24e)]};}[_0x8bb8a(0x291)](_0x420595){const _0x9568f0=_0x8bb8a;return{'claimed':_0x420595[_0x9568f0(0x223)],'score':_0x420595[_0x9568f0(0x25a)],'rank':_0x420595[_0x9568f0(0x24e)],'playerName':_0x420595[_0x9568f0(0x2e8)]};}[_0x8bb8a(0x256)](_0x731005){const _0x2f1795=_0x8bb8a;return{'runId':_0x731005[_0x2f1795(0x32c)],'startedAt':_0x731005[_0x2f1795(0x311)],'expiresAt':_0x731005[_0x2f1795(0x1ec)]};}[_0x8bb8a(0x267)](_0x5671f1){const _0x54c43d=_0x8bb8a;return{'scoreId':_0x5671f1['score_id'],'rank':_0x5671f1['rank'],'isNewHighScore':_0x5671f1[_0x54c43d(0x30c)]};}async[_0x8bb8a(0x1f9)](_0x5265e7,_0x55a3ee){const _0x28c950=_0x8bb8a,_0x2091dd={'RBgdQ':_0x28c950(0x313),'QhbdM':function(_0xa995b1,_0x31db60,_0x53d756){return _0xa995b1(_0x31db60,_0x53d756);}};let _0x234f9f={'Content-Type':_0x2091dd[_0x28c950(0x32f)],'Accept':_0x2091dd[_0x28c950(0x32f)],'X-API-Key':this[_0x28c950(0x273)]},_0x3efc7a=await _0x2091dd[_0x28c950(0x27b)](fetch,_0x5265e7,{..._0x55a3ee,'headers':{..._0x234f9f,..._0x55a3ee[_0x28c950(0x332)]||{}}}),_0x136106=await _0x3efc7a[_0x28c950(0x259)]();if(!_0x136106['success'])throw new d(_0x136106['error'],_0x136106['code'],_0x3efc7a[_0x28c950(0x238)]);return _0x136106['data'];}};y[_0x8bb8a(0x21d)]=_0x8bb8a(0x27f);var c=y,x=['Arcane','Astro',_0x8bb8a(0x225),'Bouncy',_0x8bb8a(0x204),_0x8bb8a(0x260),'Bubbly',_0x8bb8a(0x317),_0x8bb8a(0x1de),'Chill',_0x8bb8a(0x1f2),'Cloaked',_0x8bb8a(0x2ba),_0x8bb8a(0x2ff),'Crispy',_0x8bb8a(0x231),_0x8bb8a(0x276),_0x8bb8a(0x211),_0x8bb8a(0x2f0),'Epic',_0x8bb8a(0x1ef),_0x8bb8a(0x1f7),'Flashy','Frosty',_0x8bb8a(0x304),_0x8bb8a(0x2f8),'Galactic',_0x8bb8a(0x264),_0x8bb8a(0x2ee),'Goofy','Gritty',_0x8bb8a(0x1ee),'Hyper','Icy',_0x8bb8a(0x339),'Jazzy',_0x8bb8a(0x2bb),_0x8bb8a(0x218),'Laser',_0x8bb8a(0x241),_0x8bb8a(0x30b),_0x8bb8a(0x309),_0x8bb8a(0x22f),_0x8bb8a(0x2cd),_0x8bb8a(0x30e),_0x8bb8a(0x30f),_0x8bb8a(0x2c4),'Mighty','Minty',_0x8bb8a(0x234),_0x8bb8a(0x269),'Nimble',_0x8bb8a(0x2b3),_0x8bb8a(0x298),_0x8bb8a(0x333),_0x8bb8a(0x26a),_0x8bb8a(0x1fb),'Phantom',_0x8bb8a(0x2b4),'Plasma',_0x8bb8a(0x323),'Primal','Quantum',_0x8bb8a(0x2de),'Radiant','Rampaging',_0x8bb8a(0x292),'Rebel',_0x8bb8a(0x1e3),_0x8bb8a(0x21b),'Rowdy','Savage',_0x8bb8a(0x23a),'Shiny',_0x8bb8a(0x2ab),_0x8bb8a(0x2c8),'Skybound',_0x8bb8a(0x2b6),_0x8bb8a(0x23b),_0x8bb8a(0x26b),_0x8bb8a(0x25d),'Sparky',_0x8bb8a(0x28c),_0x8bb8a(0x235),_0x8bb8a(0x2e1),_0x8bb8a(0x228),_0x8bb8a(0x248),_0x8bb8a(0x26d),'Swift',_0x8bb8a(0x328),_0x8bb8a(0x2b0),_0x8bb8a(0x1c7),'Ultra',_0x8bb8a(0x2c2),'Warped',_0x8bb8a(0x310),_0x8bb8a(0x2ae),_0x8bb8a(0x288),_0x8bb8a(0x2b7),_0x8bb8a(0x24b)],A=[_0x8bb8a(0x32a),_0x8bb8a(0x31d),_0x8bb8a(0x1f3),_0x8bb8a(0x2e9),_0x8bb8a(0x2f7),_0x8bb8a(0x2a2),'Beetle',_0x8bb8a(0x286),_0x8bb8a(0x2e6),_0x8bb8a(0x1e8),'Bot',_0x8bb8a(0x329),_0x8bb8a(0x1e5),_0x8bb8a(0x2bd),_0x8bb8a(0x2b8),_0x8bb8a(0x33a),'Caribou',_0x8bb8a(0x2c7),'Cheetah','Chimera',_0x8bb8a(0x252),'Comet',_0x8bb8a(0x27c),_0x8bb8a(0x1c2),_0x8bb8a(0x1c4),'Cyborg','Dagger','Defender','Dino','Dragon',_0x8bb8a(0x1c1),'Drone','Duck',_0x8bb8a(0x261),_0x8bb8a(0x338),_0x8bb8a(0x1d9),_0x8bb8a(0x240),_0x8bb8a(0x29c),_0x8bb8a(0x1e9),_0x8bb8a(0x233),_0x8bb8a(0x2d4),_0x8bb8a(0x22b),'Gizmo',_0x8bb8a(0x307),'Goblin',_0x8bb8a(0x1f8),_0x8bb8a(0x27d),'Hawk','Hero',_0x8bb8a(0x217),_0x8bb8a(0x1e4),'Jaguar',_0x8bb8a(0x2df),_0x8bb8a(0x299),_0x8bb8a(0x275),_0x8bb8a(0x2d7),_0x8bb8a(0x232),_0x8bb8a(0x270),_0x8bb8a(0x242),_0x8bb8a(0x2a5),_0x8bb8a(0x1ca),_0x8bb8a(0x2f9),'Leopard',_0x8bb8a(0x2fe),'Luchador','Lynx','Maverick','Meteor','Monkey',_0x8bb8a(0x255),_0x8bb8a(0x24f),_0x8bb8a(0x278),'Nova',_0x8bb8a(0x2c0),'Oracle',_0x8bb8a(0x2cf),_0x8bb8a(0x1fd),_0x8bb8a(0x1ff),'Pirate',_0x8bb8a(0x2b4),_0x8bb8a(0x2a9),_0x8bb8a(0x2b5),'Racer',_0x8bb8a(0x214),_0x8bb8a(0x2d8),_0x8bb8a(0x32e),_0x8bb8a(0x224),_0x8bb8a(0x257),_0x8bb8a(0x212),_0x8bb8a(0x236),'Shark',_0x8bb8a(0x2ac),_0x8bb8a(0x263),_0x8bb8a(0x2ad),_0x8bb8a(0x272),'Tiger',_0x8bb8a(0x1e0),_0x8bb8a(0x1c5),'Viper',_0x8bb8a(0x288)];function f(){const _0x4db979=_0x8bb8a,_0x4cf9de={'WoKwz':function(_0x32d17f,_0x3f2c1a){return _0x32d17f*_0x3f2c1a;},'cZjeg':function(_0x307d64,_0x1b3b34){return _0x307d64+_0x1b3b34;},'qjcVH':function(_0x1806b1,_0x3a96dd){return _0x1806b1*_0x3a96dd;}};let _0xe1421c=x[Math[_0x4db979(0x325)](Math[_0x4db979(0x2ea)]()*x[_0x4db979(0x27a)])],_0x1a804d=A[Math[_0x4db979(0x325)](_0x4cf9de[_0x4db979(0x315)](Math[_0x4db979(0x2ea)](),A[_0x4db979(0x27a)]))],_0x113ebe=_0x4cf9de['cZjeg'](Math[_0x4db979(0x325)](_0x4cf9de['qjcVH'](Math[_0x4db979(0x2ea)](),0x1*-0xb66+-0xacf*0x3+-0x2*-0x161b)),0x1035+-0x6ee*-0x1+-0x1722);return''+(_0xe1421c+_0x1a804d)[_0x4db979(0x222)](-0x892+-0x3b*-0x23+-0x81*-0x1,0x52d+-0x7*0x3c0+0x151d)+_0x113ebe;}var N=_0x8bb8a(0x337),p=class{constructor(_0x2b0daa={}){const _0x29c19d=_0x8bb8a;this[_0x29c19d(0x25f)]=_0x2b0daa[_0x29c19d(0x25f)]??N,this[_0x29c19d(0x20e)]=this['keyPrefix']+_0x29c19d(0x1e7),this[_0x29c19d(0x202)]=this[_0x29c19d(0x25f)]+_0x29c19d(0x2e8),this['nameAutoKey']=this[_0x29c19d(0x25f)]+_0x29c19d(0x20b);}[_0x8bb8a(0x330)](){const _0x57d178=_0x8bb8a,_0x16732e={'FTAaE':function(_0x4b4410,_0x2192e7){return _0x4b4410>_0x2192e7;}};return _0x16732e[_0x57d178(0x25b)](typeof window,'u')||!window[_0x57d178(0x265)]?null:localStorage[_0x57d178(0x2a3)](this[_0x57d178(0x20e)]);}['setPlayerGuid'](_0x58ec36){const _0x5aaa79=_0x8bb8a,_0x2f8bc7={'ailRi':function(_0x2c43d5,_0x2aa979){return _0x2c43d5>_0x2aa979;}};_0x2f8bc7['ailRi'](typeof window,'u')||!window[_0x5aaa79(0x265)]||localStorage[_0x5aaa79(0x2c5)](this[_0x5aaa79(0x20e)],_0x58ec36);}[_0x8bb8a(0x319)](){const _0x1507dd=_0x8bb8a;let _0x4e48e4=this[_0x1507dd(0x330)]();return _0x4e48e4||(_0x4e48e4=this[_0x1507dd(0x25e)](),this[_0x1507dd(0x1cf)](_0x4e48e4)),_0x4e48e4;}[_0x8bb8a(0x2e5)](){const _0x5f3f03=_0x8bb8a,_0x27916d={'godSc':function(_0x5655cc,_0xf4dbfe){return _0x5655cc>_0xf4dbfe;}};return _0x27916d[_0x5f3f03(0x305)](typeof window,'u')||!window['localStorage']?null:localStorage[_0x5f3f03(0x2a3)](this[_0x5f3f03(0x202)]);}[_0x8bb8a(0x2b9)](_0x2bd312){const _0x59d98e=_0x8bb8a,_0x1b9adc={'wtbUX':function(_0x6de400,_0x3e71a2){return _0x6de400>_0x3e71a2;}};_0x1b9adc['wtbUX'](typeof window,'u')||!window[_0x59d98e(0x265)]||(localStorage[_0x59d98e(0x2c5)](this[_0x59d98e(0x202)],_0x2bd312),localStorage['removeItem'](this[_0x59d98e(0x2fb)]));}[_0x8bb8a(0x1d8)](){const _0x1743cc=_0x8bb8a,_0x3e16={'QgxlB':function(_0x4fa6ec){return _0x4fa6ec();},'mgVRR':function(_0x148340,_0x1d354e){return _0x148340<_0x1d354e;},'lgcXw':_0x1743cc(0x1cc)};let _0x4cc9e3=this['getPlayerName']();return _0x4cc9e3||(_0x4cc9e3=_0x3e16[_0x1743cc(0x29d)](f),_0x3e16[_0x1743cc(0x335)](typeof window,'u')&&window['localStorage']&&(localStorage[_0x1743cc(0x2c5)](this[_0x1743cc(0x202)],_0x4cc9e3),localStorage[_0x1743cc(0x2c5)](this['nameAutoKey'],_0x3e16['lgcXw']))),_0x4cc9e3;}[_0x8bb8a(0x1d4)](){const _0x8620f8=_0x8bb8a,_0x491057={'PWJxJ':function(_0x13cb8e,_0x2f12e2){return _0x13cb8e===_0x2f12e2;}};return typeof window>'u'||!window[_0x8620f8(0x265)]?!(-0x5a6+0x1*-0x1727+0x1cce):_0x491057[_0x8620f8(0x2c3)](localStorage['getItem'](this[_0x8620f8(0x2fb)]),'true');}['clear'](){const _0x5363a5=_0x8bb8a,_0x5ae33a={'DfAPO':function(_0x3eae05,_0x2fc47d){return _0x3eae05>_0x2fc47d;}};_0x5ae33a['DfAPO'](typeof window,'u')||!window['localStorage']||(localStorage[_0x5363a5(0x340)](this[_0x5363a5(0x20e)]),localStorage[_0x5363a5(0x340)](this[_0x5363a5(0x202)]),localStorage[_0x5363a5(0x340)](this[_0x5363a5(0x2fb)]));}[_0x8bb8a(0x21a)](){const _0x56f9e6=_0x8bb8a,_0x429ac8={'XbqiB':function(_0xe076ec,_0xdbd8a6){return _0xe076ec!==_0xdbd8a6;}};return _0x429ac8['XbqiB'](this[_0x56f9e6(0x330)](),null);}[_0x8bb8a(0x25e)](){const _0x271693=_0x8bb8a,_0x31d458={'QNVVF':function(_0x5ba273,_0x50f11a){return _0x5ba273!==_0x50f11a;},'nijTO':'OXtuM','GYgKB':_0x271693(0x20d),'AMIaU':function(_0x587844,_0x2dbf3a){return _0x587844|_0x2dbf3a;},'MhrMZ':function(_0x14b54f,_0x79020c){return _0x14b54f*_0x79020c;},'QcRTh':function(_0x32a509,_0x449fcf){return _0x32a509&_0x449fcf;},'ajCun':function(_0x29a65b,_0x131ca7){return _0x29a65b<_0x131ca7;},'yhSMO':_0x271693(0x21c)};return _0x31d458[_0x271693(0x29b)](typeof crypto,'u')&&crypto['randomUUID']?crypto[_0x271693(0x281)]():_0x31d458['yhSMO'][_0x271693(0x253)](/[xy]/g,_0x534d8d=>{const _0x33b6c8=_0x271693;if(_0x31d458[_0x33b6c8(0x250)](_0x31d458['nijTO'],_0x31d458[_0x33b6c8(0x2d6)])){let _0x33c272=_0x31d458['AMIaU'](_0x31d458['MhrMZ'](Math[_0x33b6c8(0x2ea)](),-0x152c*-0x1+-0x9*-0x10c+-0x1e88),-0x13c4+-0xe*-0x153+0x2*0x9d);return(_0x534d8d==='x'?_0x33c272:_0x31d458[_0x33b6c8(0x1dc)](_0x31d458[_0x33b6c8(0x2b2)](_0x33c272,0x1*0x2495+-0x1534+-0xf5e),-0x25*0xdf+-0xd91*0x1+0x2dd4))[_0x33b6c8(0x2e4)](0x75*0x3d+-0x123e+-0x993*0x1);}else return{'id':_0x52d764['id'],'playerGuid':_0x36730e[_0x33b6c8(0x1e7)],'playerName':_0x355965[_0x33b6c8(0x2e8)],'score':_0x1288fc[_0x33b6c8(0x25a)],'rank':_0x910cb7[_0x33b6c8(0x24e)]};});}},h=class{constructor(_0x95552){const _0x17cf13=_0x8bb8a;this[_0x17cf13(0x320)]=0xa3*-0x11+-0x216d+0x2c40,this['inflight']=null,this[_0x17cf13(0x28f)]=null,this[_0x17cf13(0x1eb)]=_0x95552;}async[_0x8bb8a(0x1fc)](_0x512fd9){const _0xe41431=_0x8bb8a,_0x342459={'RiZkv':function(_0x5629a1,_0x3827e1){return _0x5629a1!==_0x3827e1;},'dnuvm':_0xe41431(0x336),'JZyjA':_0xe41431(0x23c)};return this[_0xe41431(0x1d0)]()?this['data']:this[_0xe41431(0x21e)]?this[_0xe41431(0x21e)]:(this['inflight']=_0x512fd9()[_0xe41431(0x28b)](_0x5ed102=>(this['data']=_0x5ed102,this[_0xe41431(0x320)]=Date['now'](),this[_0xe41431(0x21e)]=null,_0x5ed102))[_0xe41431(0x2ce)](_0x271b4d=>{const _0x54d35e=_0xe41431;if(_0x342459[_0x54d35e(0x27e)](_0x342459[_0x54d35e(0x271)],_0x342459[_0x54d35e(0x229)]))throw this['inflight']=null,_0x271b4d;else return this[_0x54d35e(0x219)][_0x54d35e(0x1d8)]();}),this[_0xe41431(0x21e)]);}[_0x8bb8a(0x277)](_0x169c20){const _0x2d1202=_0x8bb8a;if(this[_0x2d1202(0x21e)]){this[_0x2d1202(0x28f)]=_0x169c20;return;}this[_0x2d1202(0x312)](_0x169c20);}[_0x8bb8a(0x312)](_0x1d9679){const _0x2da4e1=_0x8bb8a,_0x4c09c3={'OSZDS':function(_0x5492ef,_0x1e3908){return _0x5492ef===_0x1e3908;},'aMYgG':_0x2da4e1(0x26e),'wSnvf':'SHmZU','fbKEU':_0x2da4e1(0x20a),'wMvxz':function(_0xaa3116){return _0xaa3116();}};this[_0x2da4e1(0x21e)]=_0x4c09c3[_0x2da4e1(0x2b1)](_0x1d9679)[_0x2da4e1(0x28b)](_0x55f9cc=>{const _0x1f7146=_0x2da4e1;if(_0x4c09c3[_0x1f7146(0x239)](_0x4c09c3[_0x1f7146(0x2e3)],_0x1f7146(0x26e))){if(this['data']=_0x55f9cc,this['fetchedAt']=Date[_0x1f7146(0x24a)](),this[_0x1f7146(0x21e)]=null,this['pendingRefresh']){if(_0x4c09c3[_0x1f7146(0x239)](_0x4c09c3[_0x1f7146(0x22c)],_0x4c09c3['fbKEU']))return null;else{let _0x15bbf1=this['pendingRefresh'];this[_0x1f7146(0x28f)]=null,this[_0x1f7146(0x312)](_0x15bbf1);}}return _0x55f9cc;}else throw this[_0x1f7146(0x21e)]=null,_0x4f6d81;})['catch'](_0x1d852b=>{const _0x32568d=_0x2da4e1;throw this[_0x32568d(0x21e)]=null,this[_0x32568d(0x28f)]=null,_0x1d852b;}),this['inflight']['catch'](()=>{});}[_0x8bb8a(0x1cb)](){const _0x2f271b=_0x8bb8a;this[_0x2f271b(0x320)]=-0x2*0x10dd+-0x19b4+0x3b6e*0x1;}['get'](){const _0x3de701=_0x8bb8a;return this['isFresh']()?this[_0x3de701(0x2f2)]:void(-0x7ab*0x1+0x17a*-0xc+0x1963);}['getStale'](){const _0x91a0e=_0x8bb8a;return this[_0x91a0e(0x2f2)];}[_0x8bb8a(0x1d0)](){const _0x24d7ed=_0x8bb8a,_0x250554={'jBLAY':function(_0x20b7cf,_0x171a13){return _0x20b7cf!==_0x171a13;},'GjlcA':function(_0x51c56a,_0x2619ef){return _0x51c56a<_0x2619ef;}};return _0x250554[_0x24d7ed(0x2eb)](this[_0x24d7ed(0x2f2)],void(0x349*-0x6+-0xa67+-0xd*-0x251))&&_0x250554['GjlcA'](Date[_0x24d7ed(0x24a)]()-this[_0x24d7ed(0x320)],this[_0x24d7ed(0x1eb)]);}},m=class{constructor(_0x5daac0,_0x3b1820=0x360ac56+0x11*0x217cf2+-0xc*0x9a25e){const _0x1bb81c=_0x8bb8a;this[_0x1bb81c(0x2f6)]=_0x5daac0,this[_0x1bb81c(0x322)]=_0x3b1820;}[_0x8bb8a(0x1c9)](_0x23c12b,_0x4243bc){const _0x2dc266=_0x8bb8a,_0x20e6a9={'yeIWS':function(_0x9825e9,_0x36e0da,_0x4ec3e9){return _0x9825e9(_0x36e0da,_0x4ec3e9);},'sUYnL':function(_0x31134a,_0x21c0a2){return _0x31134a!==_0x21c0a2;},'yqWmk':_0x2dc266(0x1e2),'RXzVZ':'Pvteg'};try{if(_0x20e6a9[_0x2dc266(0x1ea)](_0x20e6a9['yqWmk'],_0x20e6a9[_0x2dc266(0x2a4)])){let _0x36d461={'score':_0x23c12b,'metadata':_0x4243bc,'timestamp':Date['now']()};localStorage[_0x2dc266(0x2c5)](this['storageKey'],JSON['stringify'](_0x36d461));}else return _0x20e6a9[_0x2dc266(0x1db)](_0xebc18f,_0x4623eb,_0x59603b);}catch{}}[_0x8bb8a(0x331)](){const _0x1110e3=_0x8bb8a,_0x253a5d={'iGKZZ':function(_0x3d4ec0,_0x5bdfcb){return _0x3d4ec0>_0x5bdfcb;},'NXYRs':_0x1110e3(0x230),'PoPxX':_0x1110e3(0x21f),'DXhaL':function(_0x5a6e0e,_0x4cb0d4){return _0x5a6e0e>_0x4cb0d4;},'IBaCe':function(_0x3cf12f,_0x4ddc10){return _0x3cf12f-_0x4ddc10;},'iHLJZ':_0x1110e3(0x1f0)};try{if(_0x253a5d[_0x1110e3(0x1fa)]===_0x253a5d[_0x1110e3(0x2a8)])return{'runId':_0x10bf52[_0x1110e3(0x32c)],'startedAt':_0x48a986[_0x1110e3(0x311)],'expiresAt':_0x4cb14c[_0x1110e3(0x1ec)]};else{let _0x33b0c6=localStorage[_0x1110e3(0x2a3)](this[_0x1110e3(0x2f6)]);if(!_0x33b0c6)return null;let _0x1133ad=JSON[_0x1110e3(0x293)](_0x33b0c6);return _0x253a5d[_0x1110e3(0x1d5)](_0x253a5d[_0x1110e3(0x23f)](Date[_0x1110e3(0x24a)](),_0x1133ad[_0x1110e3(0x23e)]),this['maxAgeMs'])?(this[_0x1110e3(0x2d0)](),null):{'score':_0x1133ad[_0x1110e3(0x25a)],'metadata':_0x1133ad[_0x1110e3(0x2d2)]};}}catch{if('PcdsE'===_0x253a5d[_0x1110e3(0x2ca)])return null;else BVRHTJ[_0x1110e3(0x200)](typeof _0x1745c4,'u')||!_0x16e551[_0x1110e3(0x265)]||(_0x34d1fc[_0x1110e3(0x340)](this[_0x1110e3(0x20e)]),_0x438fb2[_0x1110e3(0x340)](this[_0x1110e3(0x202)]),_0x52f0ad['removeItem'](this[_0x1110e3(0x2fb)]));}}['hasPending'](){return this['get']()!==null;}[_0x8bb8a(0x2d0)](){const _0x9d8cfe=_0x8bb8a;try{localStorage['removeItem'](this[_0x9d8cfe(0x2f6)]);}catch{}}},k={'minLength':0x2,'maxLength':0xc,'allowedPattern':/[^A-Za-z0-9_ ]/g};function S(_0x478b37,_0x5f4cc1){const _0x527d65=_0x8bb8a,_0x1f3a21={'Xuxxk':function(_0x423694,_0x1e99a6){return _0x423694<_0x1e99a6;}};let _0xac3ad1={...k,..._0x5f4cc1},_0x1e5155=_0x478b37[_0x527d65(0x31b)](),_0x20c575=_0x5f4cc1?.[_0x527d65(0x2bf)]??/[^A-Za-z0-9_ ]/g;return _0x1e5155=_0x1e5155[_0x527d65(0x253)](_0x20c575,''),_0x1e5155=_0x1e5155[_0x527d65(0x253)](/ +/g,'\x20')[_0x527d65(0x31b)](),_0x1e5155=_0x1e5155['substring'](-0x25a4+0x1*0xe5d+-0x1*-0x1747,_0xac3ad1[_0x527d65(0x2a1)]),_0x1f3a21[_0x527d65(0x30d)](_0x1e5155[_0x527d65(0x27a)],_0xac3ad1[_0x527d65(0x2d9)])?null:_0x1e5155;}var b=class{constructor(_0x4d42c2){const _0x408ce9=_0x8bb8a;this[_0x408ce9(0x31a)]=0x20a2+0x1c1+0x2263*-0x1,this[_0x408ce9(0x258)]=!(0x1f49+0xb99+-0x1*0x2ae1),this['currentRunId']=null,(this[_0x408ce9(0x1e6)]=new c({'apiKey':_0x4d42c2[_0x408ce9(0x273)],'defaultLeaderboard':_0x4d42c2['leaderboard'],'signingSecret':_0x4d42c2[_0x408ce9(0x283)],'apiUrl':_0x4d42c2[_0x408ce9(0x289)]}),this[_0x408ce9(0x219)]=new p(_0x4d42c2[_0x408ce9(0x219)]),this[_0x408ce9(0x2fa)]=_0x4d42c2[_0x408ce9(0x2fa)],this[_0x408ce9(0x221)]=_0x4d42c2[_0x408ce9(0x221)]?new h(_0x4d42c2[_0x408ce9(0x221)][_0x408ce9(0x1eb)]):null,this[_0x408ce9(0x31c)]=_0x4d42c2[_0x408ce9(0x285)]?new m(_0x408ce9(0x302)+_0x4d42c2[_0x408ce9(0x2fa)],_0x4d42c2[_0x408ce9(0x285)][_0x408ce9(0x322)]):null);}['getPlayerGuid'](){const _0x4cd51c=_0x8bb8a;return this[_0x4cd51c(0x219)]['getOrCreatePlayerGuid']();}['getPlayerName'](){const _0x4d52f8=_0x8bb8a;return this[_0x4d52f8(0x219)]['getOrCreatePlayerName']();}[_0x8bb8a(0x2b9)](_0x365a05){const _0x46ae7a=_0x8bb8a;this[_0x46ae7a(0x219)][_0x46ae7a(0x2b9)](_0x365a05);}[_0x8bb8a(0x1cd)](){const _0x5223a6=_0x8bb8a;return this[_0x5223a6(0x219)][_0x5223a6(0x2e5)]()!==null&&!this['identity']['isAutoGeneratedName']();}['validateName'](_0x44ded9,_0x3d6e52){return S(_0x44ded9,_0x3d6e52);}async[_0x8bb8a(0x28d)](_0x5591d5,_0xdf5eed){const _0x41ad06=_0x8bb8a,_0x28e44b={'uOqCj':_0x41ad06(0x33b),'uXOaR':function(_0x58d3c9,_0x3f4cd4){return _0x58d3c9 instanceof _0x3f4cd4;},'Eddhl':_0x41ad06(0x2ec),'pZOBC':_0x41ad06(0x245)};if(this[_0x41ad06(0x258)])return{'success':!(-0x11b5+0x1*-0xf13+0x20c9),'error':_0x28e44b[_0x41ad06(0x28e)]};this[_0x41ad06(0x258)]=!(0xa7*-0xd+-0x5db+-0xa*-0x16f);try{let _0x533617=await this[_0x41ad06(0x1e6)]['submitScore']({'playerGuid':this[_0x41ad06(0x330)](),'playerName':this[_0x41ad06(0x2e5)](),'score':_0x5591d5,'metadata':_0xdf5eed});return this[_0x41ad06(0x31c)]?.['clear'](),this[_0x41ad06(0x221)]&&(this[_0x41ad06(0x221)][_0x41ad06(0x1cb)](),this['cachedLimit']=0x31a+-0xfdc+0xcc2,this[_0x41ad06(0x221)][_0x41ad06(0x277)](()=>this['fetchSnapshot']())),{'success':!(0x1*-0x170d+-0x19e8+0x53*0x97),'rank':_0x533617[_0x41ad06(0x24e)],'isNewHighScore':_0x533617[_0x41ad06(0x22e)]};}catch(_0x4723d6){let _0x14fdfc=_0x28e44b['uXOaR'](_0x4723d6,d)?_0x4723d6[_0x41ad06(0x274)]:void(0x5*0x5a4+-0x1de3*0x1+0x1af);return _0x14fdfc!==_0x28e44b[_0x41ad06(0x20f)]&&this['retryQueue']?.[_0x41ad06(0x1c9)](_0x5591d5,_0xdf5eed),{'success':!(0x1d*-0x66+-0x2612+0x31a1),'error':_0x28e44b[_0x41ad06(0x1da)](_0x4723d6,Error)?_0x4723d6[_0x41ad06(0x1c8)]:_0x28e44b[_0x41ad06(0x26c)],'errorCode':_0x14fdfc};}finally{this[_0x41ad06(0x258)]=!(-0x18cb+0x4e3*-0x6+0x361e);}}async[_0x8bb8a(0x215)](){const _0x27af3e=_0x8bb8a;let _0x37c6e6=await this[_0x27af3e(0x1e6)][_0x27af3e(0x215)]({'playerGuid':this[_0x27af3e(0x330)]()});return this[_0x27af3e(0x2a0)]=_0x37c6e6[_0x27af3e(0x2d5)],_0x37c6e6;}async[_0x8bb8a(0x324)](_0x7b0203,_0xcb5320){const _0x298669=_0x8bb8a;if(!this[_0x298669(0x2a0)])throw new Error(_0x298669(0x334));let _0x48ad67=await this[_0x298669(0x1e6)]['finishRun']({'runId':this[_0x298669(0x2a0)],'playerGuid':this[_0x298669(0x330)](),'playerName':this['getPlayerName'](),'score':_0x7b0203,'metadata':_0xcb5320});return this[_0x298669(0x2a0)]=null,this[_0x298669(0x221)]&&(this['cache'][_0x298669(0x1cb)](),this[_0x298669(0x31a)]=0xa04+-0x589+0x1f*-0x25,this[_0x298669(0x221)]['refreshInBackground'](()=>this[_0x298669(0x282)]())),_0x48ad67;}[_0x8bb8a(0x22a)](){const _0x198a97=_0x8bb8a,_0x59cfb5={'eGPqy':function(_0x2e39b4,_0x48afb4){return _0x2e39b4!==_0x48afb4;}};return _0x59cfb5[_0x198a97(0x300)](this[_0x198a97(0x2a0)],null);}[_0x8bb8a(0x33c)](){const _0x5cb96d=_0x8bb8a;return this[_0x5cb96d(0x2a0)];}async['getSnapshot'](_0x169920){const _0x1aad5c=_0x8bb8a,_0x1c60ca={'LEXgr':function(_0x49dc01,_0x84e641){return _0x49dc01>_0x84e641;}};let _0x4b91ec=_0x169920?.[_0x1aad5c(0x306)]??0xd*-0x106+0x58b+0x7cd*0x1;if(this[_0x1aad5c(0x221)]){_0x1c60ca[_0x1aad5c(0x327)](_0x4b91ec,this[_0x1aad5c(0x31a)])&&this[_0x1aad5c(0x221)][_0x1aad5c(0x1cb)]();let _0x1cf910=await this['cache'][_0x1aad5c(0x1fc)](()=>this['fetchSnapshot'](_0x4b91ec));return this[_0x1aad5c(0x31a)]=_0x4b91ec,_0x1cf910;}return this[_0x1aad5c(0x282)](_0x4b91ec);}async['updatePlayerName'](_0x4d8586){const _0x4cab6c=_0x8bb8a,_0x359ef5={'Qrrua':function(_0x5b9d0b,_0x276139){return _0x5b9d0b instanceof _0x276139;},'KPfTj':function(_0x28fdd1,_0x155b49){return _0x28fdd1 instanceof _0x155b49;},'zZaqo':'Unknown\x20error'};try{return await this[_0x4cab6c(0x1e6)][_0x4cab6c(0x24c)]({'playerGuid':this['getPlayerGuid'](),'newName':_0x4d8586}),this['identity'][_0x4cab6c(0x2b9)](_0x4d8586),this[_0x4cab6c(0x221)]&&(this['cache'][_0x4cab6c(0x1cb)](),this[_0x4cab6c(0x31a)]=0xbca+-0x19ba+-0xdf*-0x10),{'success':!(-0x1a37*-0x1+-0x25f2*0x1+0xbbb)};}catch(_0x5a60f7){let _0x2dc5f8=_0x359ef5[_0x4cab6c(0x237)](_0x5a60f7,d)?_0x5a60f7[_0x4cab6c(0x274)]:void(-0x150*-0x13+-0x11*-0x8c+-0x223c);return{'success':!(-0x78*0x3b+0x1b*0x1a+-0x1*-0x18eb),'error':_0x359ef5[_0x4cab6c(0x303)](_0x5a60f7,Error)?_0x5a60f7[_0x4cab6c(0x1c8)]:_0x359ef5[_0x4cab6c(0x208)],'errorCode':_0x2dc5f8};}}async[_0x8bb8a(0x279)](){const _0x258ac3=_0x8bb8a;let _0x46123b=this[_0x258ac3(0x31c)]?.[_0x258ac3(0x331)]();if(!_0x46123b)return null;let _0x59d7b2=await this['submitScore'](_0x46123b[_0x258ac3(0x25a)],_0x46123b[_0x258ac3(0x2d2)]);return _0x59d7b2[_0x258ac3(0x2e2)]&&this['retryQueue']?.[_0x258ac3(0x2d0)](),_0x59d7b2;}['hasPendingScore'](){const _0x3ab4f1=_0x8bb8a;return this[_0x3ab4f1(0x31c)]?.[_0x3ab4f1(0x326)]()??!(0x1b7a+-0x8d0+-0x12a9);}['prefetch'](){const _0x5d5687=_0x8bb8a;this['cache']&&(this[_0x5d5687(0x221)][_0x5d5687(0x1d0)]()||this[_0x5d5687(0x221)][_0x5d5687(0x277)](()=>this[_0x5d5687(0x282)]()));}[_0x8bb8a(0x2cb)](){const _0x4c481e=_0x8bb8a;return this[_0x4c481e(0x1e6)];}async['fetchSnapshot'](_0x572bf7=-0x2*0x716+0x125*0x6+0xa*0xbc){const _0x5901e3=_0x8bb8a;let _0x439eed=this[_0x5901e3(0x330)](),[_0x342e32,_0x617146]=await Promise[_0x5901e3(0x31e)]([this[_0x5901e3(0x1e6)][_0x5901e3(0x297)]({'limit':_0x572bf7}),this['client'][_0x5901e3(0x2aa)]({'playerGuid':_0x439eed})]),_0x331dae=_0x342e32[_0x5901e3(0x301)][_0x5901e3(0x246)](_0x280b06=>({'rank':_0x280b06[_0x5901e3(0x24e)],'playerGuid':_0x280b06[_0x5901e3(0x308)],'playerName':_0x280b06[_0x5901e3(0x2d3)],'score':_0x280b06[_0x5901e3(0x25a)],'isCurrentPlayer':_0x280b06[_0x5901e3(0x308)]===_0x439eed})),_0x194921=_0x331dae[_0x5901e3(0x206)](_0x53a8ee=>_0x53a8ee['isCurrentPlayer']),_0x59f979=_0x617146&&!_0x194921?_0x617146:null;return{'entries':_0x331dae,'totalCount':_0x342e32[_0x5901e3(0x1d7)],'playerRank':_0x59f979};}};export{h as Cache,c as KeeperBoardClient,d as KeeperBoardError,b as KeeperBoardSession,p as PlayerIdentity,m as RetryQueue,f as generatePlayerName,S as validateName};