web-sdk-wrapper 2.0.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.
@@ -0,0 +1,687 @@
1
+ var m = Object.defineProperty;
2
+ var f = (s, e, a) => e in s ? m(s, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : s[e] = a;
3
+ var t = (s, e, a) => f(s, typeof e != "symbol" ? e + "" : e, a);
4
+ class c {
5
+ constructor() {
6
+ /** @type {string} */
7
+ t(this, "name", "Unknown");
8
+ /**
9
+ * @type {{
10
+ * ads: boolean,
11
+ * interstitialAds: boolean,
12
+ * rewardedAds: boolean,
13
+ * bannerAds: boolean,
14
+ * accounts: boolean,
15
+ * tokens: boolean
16
+ * }}
17
+ */
18
+ t(this, "capabilities", {
19
+ ads: !1,
20
+ interstitialAds: !1,
21
+ rewardedAds: !1,
22
+ bannerAds: !1,
23
+ accounts: !1,
24
+ tokens: !1
25
+ });
26
+ /** @type {string[]} SDK script URLs to load before init */
27
+ t(this, "scriptSources", []);
28
+ /** @type {boolean} If true, adapter is disabled when debug=true */
29
+ t(this, "requiresProduction", !1);
30
+ /** @type {any} Reference to the loaded SDK object. Set in init(). */
31
+ t(this, "_sdk", null);
32
+ /** @type {boolean} Whether a gameplay session is active */
33
+ t(this, "_gameplayStarted", !1);
34
+ }
35
+ // ========================
36
+ // Lifecycle
37
+ // ========================
38
+ /**
39
+ * Called before scripts are loaded. Use for early DOM setup or config.
40
+ * @param {{ debug: boolean, data: Object }} options
41
+ * @returns {Promise<void>}
42
+ */
43
+ async preInit(e) {
44
+ }
45
+ /**
46
+ * Called after scripts are loaded. Initialize the SDK here.
47
+ * @param {{ debug: boolean, data: Object }} options
48
+ * @returns {Promise<void>}
49
+ */
50
+ async init(e) {
51
+ }
52
+ /** Called when the game starts loading. */
53
+ onLoadingStart() {
54
+ }
55
+ /** Called when the game finishes loading. */
56
+ onLoadingEnd() {
57
+ }
58
+ /**
59
+ * Handles duplicate-call gating for gameplay start.
60
+ * Do NOT override this — override onGameplayStart() instead.
61
+ */
62
+ maybeGameplayStart() {
63
+ this._gameplayStarted || (this._gameplayStarted = !0, this.onGameplayStart());
64
+ }
65
+ /**
66
+ * Handles duplicate-call gating for gameplay stop.
67
+ * Do NOT override this — override onGameplayStop() instead.
68
+ */
69
+ maybeGameplayStop() {
70
+ this._gameplayStarted && (this._gameplayStarted = !1, this.onGameplayStop());
71
+ }
72
+ /**
73
+ * Called when a gameplay session starts.
74
+ * Only called if not already in a gameplay session (gated by maybeGameplayStart).
75
+ * Override this freely — no need to call super.
76
+ */
77
+ onGameplayStart() {
78
+ }
79
+ /**
80
+ * Called when a gameplay session stops.
81
+ * Only called if currently in a gameplay session (gated by maybeGameplayStop).
82
+ * Override this freely — no need to call super.
83
+ */
84
+ onGameplayStop() {
85
+ }
86
+ /**
87
+ * Called when a level starts.
88
+ * @param {string|number} level
89
+ */
90
+ onLevelStart(e) {
91
+ }
92
+ /**
93
+ * Called when a level is replayed.
94
+ * @param {string|number} level
95
+ */
96
+ onReplayLevel(e) {
97
+ }
98
+ // ========================
99
+ // Ads
100
+ // ========================
101
+ /**
102
+ * Show an interstitial ad.
103
+ * @returns {Promise<boolean>} Whether the ad was shown successfully
104
+ */
105
+ async showInterstitial() {
106
+ return !1;
107
+ }
108
+ /**
109
+ * Show a rewarded ad.
110
+ * @param {string} [size] - Ad size hint (e.g. "small", "medium")
111
+ * @returns {Promise<boolean>} Whether the reward was earned
112
+ */
113
+ async showRewarded(e) {
114
+ return !0;
115
+ }
116
+ // ========================
117
+ // Accounts
118
+ // ========================
119
+ /**
120
+ * Log in via the platform's auth system.
121
+ * @returns {Promise<any>}
122
+ */
123
+ login() {
124
+ return Promise.reject(new Error("Accounts not supported"));
125
+ }
126
+ /**
127
+ * Get the currently logged-in user.
128
+ * @returns {Promise<any>}
129
+ */
130
+ getUser() {
131
+ return Promise.resolve(null);
132
+ }
133
+ /**
134
+ * Get an auth token for the current user.
135
+ * @returns {Promise<string|null>}
136
+ */
137
+ getToken() {
138
+ return Promise.resolve(null);
139
+ }
140
+ // ========================
141
+ // Misc
142
+ // ========================
143
+ /**
144
+ * Track an analytics event.
145
+ * @param {string} category
146
+ * @param {string} action
147
+ * @param {string} [label]
148
+ */
149
+ trackEvent(e, a, n) {
150
+ }
151
+ /**
152
+ * Open an external link. Default: window.open.
153
+ * @param {string} url
154
+ */
155
+ openExternalLink(e) {
156
+ window.open(e, "_blank");
157
+ }
158
+ }
159
+ class _ extends c {
160
+ constructor() {
161
+ super(...arguments);
162
+ t(this, "name", "Poki");
163
+ t(this, "capabilities", {
164
+ ads: !0,
165
+ interstitialAds: !0,
166
+ rewardedAds: !0,
167
+ bannerAds: !1,
168
+ accounts: !0,
169
+ tokens: !0
170
+ });
171
+ t(this, "scriptSources", ["https://game-cdn.poki.com/scripts/v2/poki-sdk.js"]);
172
+ t(this, "requiresProduction", !1);
173
+ t(this, "_lastBeaconTime", 0);
174
+ t(this, "_maxBeacons", 6);
175
+ t(this, "_beaconInterval", 60);
176
+ t(this, "_gameId", null);
177
+ t(this, "_doBeacon", !1);
178
+ }
179
+ /**
180
+ * Send a beacon to Poki's level data endpoint.
181
+ * @param {string} type
182
+ */
183
+ _beacon(a) {
184
+ if (!this._gameId || !this._doBeacon) return;
185
+ const n = Date.now();
186
+ n - this._lastBeaconTime < this._beaconInterval * 1e3 || this._maxBeacons <= 0 || (this._lastBeaconTime = n, this._maxBeacons--, navigator.sendBeacon(`https://leveldata.poki.io/${a}`, this._gameId));
187
+ }
188
+ async init(a) {
189
+ this._sdk = globalThis.PokiSDK, this._sdk.setDebug(a.debug), await this._sdk.init().catch(() => {
190
+ });
191
+ const n = a.data || {};
192
+ this._gameId = n.poki_gameId, this._doBeacon = n.poki_doBeacon, this._maxBeacons = n.poki_maxBeacons || 6, this._beaconInterval = n.poki_beaconInterval || 60;
193
+ }
194
+ onLoadingStart() {
195
+ this._sdk.gameLoadingStart();
196
+ }
197
+ onLoadingEnd() {
198
+ this._sdk.gameLoadingFinished(), this._beacon("loadingEnd");
199
+ }
200
+ onGameplayStart() {
201
+ this._beacon("gameplayStart"), this._sdk.gameplayStart();
202
+ }
203
+ onGameplayStop() {
204
+ this._beacon("gameplayStop"), this._sdk.gameplayStop();
205
+ }
206
+ async showInterstitial() {
207
+ return this._beacon("interstitial"), await this._sdk.commercialBreak(), !0;
208
+ }
209
+ async showRewarded(a = "small") {
210
+ return this._beacon("rewarded"), await this._sdk.rewardedBreak({ size: a });
211
+ }
212
+ login() {
213
+ return this._sdk.login();
214
+ }
215
+ getUser() {
216
+ return this._sdk.getUser();
217
+ }
218
+ getToken() {
219
+ return this._sdk.getToken();
220
+ }
221
+ trackEvent(a, n, i) {
222
+ this._beacon(`${a}_${n}`), this._sdk.measure(a, n, i);
223
+ }
224
+ openExternalLink(a) {
225
+ this._sdk && this._sdk.openExternalLink ? this._sdk.openExternalLink(a) : super.openExternalLink(a);
226
+ }
227
+ }
228
+ class g extends c {
229
+ constructor() {
230
+ super(...arguments);
231
+ t(this, "name", "CrazyGames");
232
+ t(this, "capabilities", {
233
+ ads: !0,
234
+ interstitialAds: !0,
235
+ rewardedAds: !0,
236
+ bannerAds: !0,
237
+ accounts: !1,
238
+ tokens: !1
239
+ });
240
+ t(this, "scriptSources", ["https://sdk.crazygames.com/crazygames-sdk-v1.js"]);
241
+ t(this, "requiresProduction", !1);
242
+ /** @type {string|null} Tracks which ad type was last requested */
243
+ t(this, "_lastRequestedAd", null);
244
+ /** @type {function|null} Resolve function for the current ad promise */
245
+ t(this, "_adResolve", null);
246
+ }
247
+ async init(a) {
248
+ var n, i;
249
+ this._sdk = (i = (n = globalThis == null ? void 0 : globalThis.CrazyGames) == null ? void 0 : n.CrazySDK) == null ? void 0 : i.getInstance(), await new Promise((r) => {
250
+ this._sdk.addEventListener("adblockDetectionExecuted", () => {
251
+ r();
252
+ }), this._sdk.init();
253
+ }), this._sdk.addEventListener("adFinished", () => {
254
+ this._adResolve && (this._adResolve(!0), this._adResolve = null);
255
+ }), this._sdk.addEventListener("adError", () => {
256
+ this._adResolve && (this._adResolve(!1), this._adResolve = null);
257
+ });
258
+ }
259
+ onGameplayStart() {
260
+ this._sdk.gameplayStart();
261
+ }
262
+ onGameplayStop() {
263
+ this._sdk.gameplayStop();
264
+ }
265
+ async showInterstitial() {
266
+ return new Promise((a) => {
267
+ this._adResolve = a, this._lastRequestedAd = "interstitial", this._sdk.requestAd("midgame");
268
+ });
269
+ }
270
+ async showRewarded() {
271
+ return new Promise((a) => {
272
+ this._adResolve = a, this._lastRequestedAd = "rewarded", this._sdk.requestAd("rewarded");
273
+ });
274
+ }
275
+ }
276
+ class y extends c {
277
+ constructor() {
278
+ super(...arguments);
279
+ t(this, "name", "CoolMathGames");
280
+ t(this, "capabilities", {
281
+ ads: !0,
282
+ interstitialAds: !0,
283
+ rewardedAds: !1,
284
+ bannerAds: !1,
285
+ accounts: !1,
286
+ tokens: !1
287
+ });
288
+ t(this, "scriptSources", [
289
+ "https://www.coolmathgames.com/sites/default/files/cmg-ads.js"
290
+ ]);
291
+ t(this, "requiresProduction", !0);
292
+ /** @type {function|null} */
293
+ t(this, "_adResolve", null);
294
+ }
295
+ async init(a) {
296
+ document.addEventListener("adBreakComplete", () => {
297
+ this._adResolve && (this._adResolve(!0), this._adResolve = null);
298
+ });
299
+ }
300
+ onGameplayStart() {
301
+ parent.cmgGameEvent("start");
302
+ }
303
+ onLevelStart(a) {
304
+ parent.cmgGameEvent("start", a.toString());
305
+ }
306
+ onReplayLevel(a) {
307
+ parent.cmgGameEvent("replay", a.toString());
308
+ }
309
+ async showInterstitial() {
310
+ return new Promise((a) => {
311
+ this._adResolve = a, window.cmgAdBreak();
312
+ });
313
+ }
314
+ }
315
+ class k extends c {
316
+ constructor() {
317
+ super(...arguments);
318
+ t(this, "name", "HoodaMath");
319
+ }
320
+ // All defaults — no ads, no accounts, just openExternalLink from base class.
321
+ }
322
+ class b extends c {
323
+ constructor() {
324
+ super(...arguments);
325
+ t(this, "name", "FreezeNova");
326
+ t(this, "capabilities", {
327
+ ads: !0,
328
+ interstitialAds: !0,
329
+ rewardedAds: !0,
330
+ bannerAds: !1,
331
+ accounts: !1,
332
+ tokens: !1
333
+ });
334
+ t(this, "scriptSources", [
335
+ 'https://universal.wgplayer.com/tag/?lh="+window.location.hostname+"&wp="+window.location.pathname+"&ws="+window.location.search'
336
+ ]);
337
+ t(this, "requiresProduction", !0);
338
+ /** @type {function|null} */
339
+ t(this, "_adResolve", null);
340
+ }
341
+ async init(a) {
342
+ const n = a.data || {};
343
+ window.SubmitLeaderboardScore = function(r) {
344
+ }, window.InitExternEval = function() {
345
+ window.firstInit == null ? window.firstInit = 1 : window.ExternEval();
346
+ }, window.TakeReward = function() {
347
+ window.adReward = 0;
348
+ }, window.RewardErrorHandled = function() {
349
+ window.rewardError = 0;
350
+ }, window.InitApi = function(r) {
351
+ const d = Math.round(Date.now() / 1e3);
352
+ window.callTime = d - 181;
353
+ }, window.ExternEval = function() {
354
+ const r = Math.round(Date.now() / 1e3);
355
+ if (window.callTime != null && r - window.callTime > 180 && (window.callTime = r, typeof preroll < "u" && window[preroll.config.loaderObjectName] != null)) {
356
+ window.adRunning = 1;
357
+ try {
358
+ window[preroll.config.loaderObjectName].refetchAd(
359
+ window.ExternEvalResumeGame
360
+ );
361
+ } catch (d) {
362
+ console.log(d.message), window.ExternEvalResumeGame();
363
+ }
364
+ }
365
+ }, window.ExternEvalResumeGame = function() {
366
+ window.adRunning = 0;
367
+ }, window.PreloadRewarded = function() {
368
+ if (window.rewardedCallbacks == null) {
369
+ window.rewardedCallbacks = !0;
370
+ try {
371
+ window[window.preroll.config.loaderObjectName].registerRewardCallbacks({
372
+ onReady: window.RewardedReady,
373
+ onSuccess: window.RewardedSuccess,
374
+ onFail: window.RewardedFail
375
+ });
376
+ } catch (r) {
377
+ console.log(r.message);
378
+ }
379
+ }
380
+ }, window.ShowRewarded = function() {
381
+ if (typeof preroll < "u" && window[preroll.config.loaderObjectName] != null) {
382
+ window.canReward = 0, window.adRunning = 1;
383
+ try {
384
+ window[preroll.config.loaderObjectName].showRewardAd();
385
+ } catch (r) {
386
+ console.log(r.message), window.adRunning = 0;
387
+ }
388
+ }
389
+ }, window.RewardedReady = function() {
390
+ window.rewardedCount == null ? (window.rewardedCount = 1, window.canReward = 1) : (window.rewardedCount = window.rewardedCount + 1, setTimeout(function() {
391
+ window.canReward = 1;
392
+ }, 3e4));
393
+ };
394
+ const i = this;
395
+ window.RewardedSuccess = function() {
396
+ window.adRunning = 0, window.adReward = 1, i._adResolve && (i._adResolve(!0), i._adResolve = null);
397
+ }, window.RewardedFail = function() {
398
+ window.adRunning = 0, i._adResolve && (i._adResolve(!1), i._adResolve = null);
399
+ }, window.OpenLink = function() {
400
+ }, window.adRunning = 0, window.adRunningRewarded = 0, window.adReward = 0, window.rewardError = 0, window.canReward = 0, window.callTime = 0, window.adPlatform = 4, window.myLeaderboardScore = 0, window.gameLang = "en", window.InitApi(n.freezeNova_id || 0);
401
+ }
402
+ async showInterstitial() {
403
+ return new Promise((a) => {
404
+ this._adResolve = a, window.PreloadRewarded(), window.ShowRewarded();
405
+ });
406
+ }
407
+ async showRewarded() {
408
+ return new Promise((a) => {
409
+ this._adResolve = a, window.PreloadRewarded(), window.ShowRewarded();
410
+ });
411
+ }
412
+ }
413
+ class S extends c {
414
+ constructor() {
415
+ super(...arguments);
416
+ t(this, "name", "Xiaomi");
417
+ t(this, "capabilities", {
418
+ ads: !0,
419
+ interstitialAds: !0,
420
+ rewardedAds: !0,
421
+ bannerAds: !1,
422
+ accounts: !1,
423
+ tokens: !1
424
+ });
425
+ // Scripts are loaded manually in preInit, not via the standard loader
426
+ t(this, "scriptSources", []);
427
+ t(this, "requiresProduction", !0);
428
+ /** @type {function|null} */
429
+ t(this, "_adBreak", null);
430
+ }
431
+ async preInit(a) {
432
+ const n = a.data || {}, i = document.createElement("script");
433
+ i.async = !0, i.setAttribute("data-ad-frequency-hint", "30s"), i.src = `https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-${n.xiaomi_publisherId}`, i.setAttribute("crossorigin", "anonymous"), a.debug && i.setAttribute("data-adbreak-test", "on"), window.adsbygoogle = window.adsbygoogle || [], window.adConfig = function(r) {
434
+ adsbygoogle.push(r);
435
+ }, window.adBreak = window.adConfig, this._adBreak = window.adBreak, document.body.appendChild(i), await new Promise((r) => {
436
+ i.onload = () => {
437
+ if (n.xiaomi_bannerEnabled) {
438
+ const d = document.createElement("ins");
439
+ d.className = "adsbygoogle", d.style.display = "block", d.setAttribute(
440
+ "data-ad-client",
441
+ `ca-${n.xiaomi_publisherId}`
442
+ ), d.setAttribute("data-ad-slot", n.xiaomi_dataAdSlot), d.setAttribute("data-ad-format", "auto"), d.setAttribute("data-full-width-responsive", "true");
443
+ const o = n.xiaomi_bannerConainerId || "adSpace";
444
+ let w = document.getElementById(o);
445
+ w || (w = document.createElement("div"), w.id = o, document.body.appendChild(w)), w.appendChild(d), (adsbygoogle = window.adsbygoogle || []).push({});
446
+ }
447
+ r();
448
+ };
449
+ });
450
+ }
451
+ onLoadingStart() {
452
+ try {
453
+ funmax && funmax.loadStart();
454
+ } catch {
455
+ console.error("funmax not found");
456
+ }
457
+ }
458
+ onLoadingEnd() {
459
+ try {
460
+ funmax && funmax.loadReady();
461
+ } catch {
462
+ console.error("funmax not found");
463
+ }
464
+ }
465
+ async showInterstitial() {
466
+ return new Promise((a) => {
467
+ this._adBreak({
468
+ type: "next",
469
+ name: "interstitial",
470
+ beforeAd: () => {
471
+ },
472
+ adBreakDone: () => {
473
+ a(!0);
474
+ }
475
+ });
476
+ });
477
+ }
478
+ async showRewarded() {
479
+ return new Promise((a) => {
480
+ let n = !1;
481
+ this._adBreak({
482
+ type: "reward",
483
+ name: "rewarded",
484
+ beforeAd: () => {
485
+ },
486
+ adBreakDone: () => {
487
+ a(n);
488
+ },
489
+ beforeReward: (i) => {
490
+ i();
491
+ },
492
+ adDismissed: () => {
493
+ n = !1;
494
+ },
495
+ adViewed: () => {
496
+ n = !0;
497
+ }
498
+ });
499
+ });
500
+ }
501
+ }
502
+ const h = {
503
+ Poki: _,
504
+ CrazyGames: g,
505
+ CoolMathGames: y,
506
+ HoodaMath: k,
507
+ FreezeNova: b,
508
+ Xiaomi: S
509
+ }, x = Object.keys(h), p = /* @__PURE__ */ new Map();
510
+ function R(s) {
511
+ if (p.has(s)) return p.get(s);
512
+ const e = new Promise((a, n) => {
513
+ const i = document.createElement("script");
514
+ i.src = s, i.onload = () => a(), i.onerror = () => n(new Error(`Failed to load script: ${s}`)), document.head.appendChild(i);
515
+ });
516
+ return p.set(s, e), e;
517
+ }
518
+ const l = {};
519
+ function v(s, e, { once: a = !1 } = {}) {
520
+ l[s] = l[s] || [], l[s].push({ fn: e, once: a });
521
+ }
522
+ function u(s, ...e) {
523
+ (l[s] || []).forEach((a) => {
524
+ a.fn(...e);
525
+ }), l[s] = (l[s] || []).filter((a) => !a.once);
526
+ }
527
+ function L() {
528
+ const s = document.createElement("style");
529
+ s.innerHTML = `
530
+ canvas {
531
+ user-select: none !important;
532
+ -webkit-user-select: none !important;
533
+ -moz-user-select: none !important;
534
+ -ms-user-select: none !important;
535
+ }`, document.head.appendChild(s), window.addEventListener("keydown", (e) => {
536
+ ["ArrowDown", "ArrowUp", " "].includes(e.key) && e.preventDefault();
537
+ }), window.addEventListener("wheel", (e) => e.preventDefault(), {
538
+ passive: !1
539
+ });
540
+ }
541
+ class A {
542
+ constructor() {
543
+ /** @type {import('./networks/base.js').NetworkAdapter|null} */
544
+ t(this, "_adapter", null);
545
+ /** @type {boolean} */
546
+ t(this, "_enabled", !1);
547
+ }
548
+ get enabled() {
549
+ return this._enabled;
550
+ }
551
+ get currentSdk() {
552
+ return this._adapter;
553
+ }
554
+ /**
555
+ * Initialize the wrapper with a specific network.
556
+ * @param {string} name - Network name (case-insensitive)
557
+ * @param {boolean} [debug=false]
558
+ * @param {Object} [data={}] - Network-specific configuration
559
+ * @returns {Promise<void>}
560
+ */
561
+ async init(e, a = !1, n = {}) {
562
+ const i = Object.keys(h).find(
563
+ (o) => o.toLowerCase() === e.toLowerCase()
564
+ ), r = i ? h[i] : null;
565
+ if (!r || (this._adapter = new r(), this._adapter.requiresProduction && a))
566
+ return;
567
+ this._enabled = !0;
568
+ const d = { debug: a, data: n };
569
+ await this._adapter.preInit(d);
570
+ for (const o of this._adapter.scriptSources)
571
+ await R(o);
572
+ await this._adapter.init(d), this.loadingStart();
573
+ }
574
+ loadingStart() {
575
+ this._adapter && this._adapter.onLoadingStart();
576
+ }
577
+ loadingEnd() {
578
+ this._adapter && this._adapter.onLoadingEnd();
579
+ }
580
+ gameplayStart() {
581
+ this._adapter && this._adapter.maybeGameplayStart();
582
+ }
583
+ gameplayStop() {
584
+ this._adapter && this._adapter.maybeGameplayStop();
585
+ }
586
+ levelStart(e) {
587
+ this._adapter && this._adapter.onLevelStart(e);
588
+ }
589
+ replayLevel(e) {
590
+ this._adapter && this._adapter.onReplayLevel(e);
591
+ }
592
+ onUnlockAllLevels(e) {
593
+ window.unlockAllLevels = e;
594
+ }
595
+ /**
596
+ * Show an interstitial ad. Auto-pauses/resumes gameplay.
597
+ * @returns {Promise<boolean>}
598
+ */
599
+ async interstitial() {
600
+ var n;
601
+ if (!((n = this._adapter) != null && n.capabilities.interstitialAds))
602
+ return u("adStarted", "interstitial"), !1;
603
+ const e = this._adapter._gameplayStarted;
604
+ e && this.gameplayStop(), u("adStarted", "interstitial");
605
+ const a = await this._adapter.showInterstitial();
606
+ return e && this.gameplayStart(), a;
607
+ }
608
+ /**
609
+ * Show a rewarded ad. Auto-pauses/resumes gameplay.
610
+ * @param {string} [size]
611
+ * @returns {Promise<boolean>}
612
+ */
613
+ async rewarded(e) {
614
+ var i;
615
+ if (!((i = this._adapter) != null && i.capabilities.rewardedAds))
616
+ return u("adStarted", "rewarded"), !0;
617
+ const a = this._adapter._gameplayStarted;
618
+ a && this.gameplayStop(), u("adStarted", "rewarded");
619
+ const n = await this._adapter.showRewarded(e);
620
+ return a && this.gameplayStart(), n;
621
+ }
622
+ /**
623
+ * Register a callback for when an ad starts.
624
+ * @param {function} fn
625
+ */
626
+ onAdStarted(e) {
627
+ v("adStarted", e);
628
+ }
629
+ /** @returns {number} 1 if ads supported, 0 otherwise */
630
+ hasAds() {
631
+ var e;
632
+ return (e = this._adapter) != null && e.capabilities.ads ? 1 : 0;
633
+ }
634
+ /** @returns {number} 1 if interstitial ads supported, 0 otherwise */
635
+ hasInterstitialAds() {
636
+ var e;
637
+ return (e = this._adapter) != null && e.capabilities.interstitialAds ? 1 : 0;
638
+ }
639
+ /** @returns {number} 1 if rewarded ads supported, 0 otherwise */
640
+ hasRewardedAds() {
641
+ var e;
642
+ return (e = this._adapter) != null && e.capabilities.rewardedAds ? 1 : 0;
643
+ }
644
+ /**
645
+ * Track an analytics event.
646
+ * @param {{ category: string, action: string, label?: string }} event
647
+ */
648
+ analyticsEvent({ category: e, action: a, label: n }) {
649
+ this._adapter && this._adapter.trackEvent(e, a, n);
650
+ }
651
+ login() {
652
+ var e;
653
+ return (e = this._adapter) != null && e.capabilities.accounts ? this._adapter.login() : Promise.reject(new Error("Accounts not supported"));
654
+ }
655
+ getUser() {
656
+ var e;
657
+ return (e = this._adapter) != null && e.capabilities.accounts ? this._adapter.getUser() : Promise.resolve(null);
658
+ }
659
+ getToken() {
660
+ var e;
661
+ return (e = this._adapter) != null && e.capabilities.tokens ? this._adapter.getToken() : Promise.resolve(null);
662
+ }
663
+ /** @returns {number} 1 if accounts supported, 0 otherwise */
664
+ hasAccounts() {
665
+ var e;
666
+ return (e = this._adapter) != null && e.capabilities.accounts ? 1 : 0;
667
+ }
668
+ /** @returns {number} 1 if tokens supported, 0 otherwise */
669
+ hasToken() {
670
+ var e;
671
+ return (e = this._adapter) != null && e.capabilities.tokens ? 1 : 0;
672
+ }
673
+ openExternalLink(e) {
674
+ if (!this._adapter || !this._enabled) {
675
+ window.open(e, "_blank");
676
+ return;
677
+ }
678
+ this._adapter.openExternalLink(e);
679
+ }
680
+ }
681
+ const I = new A();
682
+ export {
683
+ c as NetworkAdapter,
684
+ I as default,
685
+ x as networks,
686
+ L as preventWeirdInputs
687
+ };