@streamlayer/react 1.1.7 → 1.3.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/lib/es/app.js DELETED
@@ -1,958 +0,0 @@
1
- var fe = Object.defineProperty;
2
- var ke = (e, s, n) => s in e ? fe(e, s, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[s] = n;
3
- var m = (e, s, n) => ke(e, typeof s != "symbol" ? s + "" : s, n);
4
- import { jsx as t, jsxs as g, Fragment as D } from "react/jsx-runtime";
5
- import { a4 as P, u, F as ye, s as h, T as re, i as Ne, p as be, b as Se, N as Ie, k as Ee, M as Ae, g as Ce, h as we, C as $e, j as Le, O as le, m as q, l as De, n as Te, o as Oe, q as de, r as xe, t as Re, v as Ve, w as M, x as Pe, y as ce, z as U, A as qe, B as G, I as O, c as pe, E as _e, G as Fe, H as Qe, e as Ke, J as x, K as H, P as Me, R as Ue, U as ze, a as ue, W as Be, X as We, L as _, $ as Ge, f as F, a0 as He, a1 as je, Y as Xe, Z as Ye, _ as Ze, a5 as Je, a2 as he, a3 as j } from "./index2.js";
6
- import { createContext as es, useContext as z, useRef as L, useState as E, useEffect as k, useTransition as ss, lazy as ns, useMemo as w, Suspense as ts, forwardRef as os, useLayoutEffect as is, useCallback as V } from "react";
7
- import { C, c as X, Q as R, S as $ } from "./useStreamLayerApp2.js";
8
- window.dispatchEvent(new CustomEvent("grpc_devtools_loaded"));
9
- function as(e) {
10
- return e instanceof DOMException && // everything except Firefox
11
- (e.code === 22 || // Firefox
12
- e.code === 1014 || // test name field too, because code might not be present
13
- // everything except Firefox
14
- e.name === "QuotaExceededError" || // Firefox
15
- e.name === "NS_ERROR_DOM_QUOTA_REACHED");
16
- }
17
- class rs {
18
- constructor(s = "main", n = window.localStorage) {
19
- m(this, "delimiter", ":");
20
- m(this, "prefix");
21
- m(this, "storage");
22
- m(this, "clear", () => {
23
- for (const s in window.localStorage)
24
- s.startsWith(this.prefix) && this.storage.removeItem(s);
25
- });
26
- m(this, "generateKey", (s) => `${this.prefix}${this.delimiter}${s.join(this.delimiter)}`);
27
- m(this, "write", (...s) => {
28
- const n = s.pop() || "", o = this.generateKey(s);
29
- try {
30
- this.storage.setItem(o, n);
31
- } catch (a) {
32
- as(a) && this.storage === window.sessionStorage && (window.sessionStorage.removeItem("slstreamlogs"), this.storage.setItem(o, n));
33
- }
34
- });
35
- m(this, "read", (...s) => {
36
- const n = this.storage.getItem(this.generateKey(s));
37
- return n === null ? void 0 : n;
38
- });
39
- m(this, "remove", (...s) => {
40
- this.storage.removeItem(this.generateKey(s));
41
- });
42
- this.prefix = `sl-sdk${this.delimiter}${s}`, this.storage = n;
43
- }
44
- }
45
- var Y;
46
- (function(e) {
47
- e.Init = "init", e.Ready = "ready", e.Connecting = "connecting", e.Connected = "connected", e.Disconnected = "disconnected", e.Failed = "failed", e.Reconnect = "reconnect", e.Reconnecting = "reconnecting";
48
- })(Y || (Y = {}));
49
- C.Unknown, C.Internal, C.DeadlineExceeded, C.ResourceExhausted, C.FailedPrecondition, C.Unavailable, C.DataLoss;
50
- P("grpc:retry");
51
- X(10, { description: "Number of attempts to retry" }), X(3e4, { description: "Max delay between retries in milliseconds" });
52
- var I;
53
- (function(e) {
54
- e.SCHEMA = "schema", e.EXTERNAL_TOKEN = "eToken", e.TOKEN = "token";
55
- })(I || (I = {}));
56
- class ls extends rs {
57
- constructor() {
58
- super("user");
59
- // Schema
60
- m(this, "setSchema", (n) => {
61
- this.write(I.SCHEMA, n);
62
- });
63
- m(this, "getSchema", () => this.read(I.SCHEMA));
64
- // Token
65
- m(this, "setToken", (n) => {
66
- this.write(I.TOKEN, n);
67
- });
68
- m(this, "getToken", () => this.read(I.TOKEN));
69
- // External Token
70
- m(this, "setExternalToken", (n) => {
71
- this.write(I.EXTERNAL_TOKEN, n);
72
- });
73
- m(this, "getExternalToken", () => this.read(I.EXTERNAL_TOKEN));
74
- m(this, "removeToken", () => {
75
- this.remove(I.TOKEN);
76
- });
77
- }
78
- }
79
- var Z;
80
- (function(e) {
81
- e.DISABLED = "disabled", e.INITIALIZATION = "initialization", e.READY = "ready", e.FAILED = "failed", e.SUSPENDED = "suspended";
82
- })(Z || (Z = {}));
83
- P("deep_link");
84
- P("bypass");
85
- new ls();
86
- P("video_player");
87
- var J;
88
- (function(e) {
89
- e.SHOWED = "showed";
90
- })(J || (J = {}));
91
- var ee;
92
- (function(e) {
93
- e.ALLOWED = "allowed", e.DISALLOWED = "disallowed";
94
- })(ee || (ee = {}));
95
- var se;
96
- (function(e) {
97
- e.UNKNOWN = "unknown", e.ALREADY_VOTED = "already_voted";
98
- })(se || (se = {}));
99
- var ne;
100
- (function(e) {
101
- e.ONBOARDING = "onboarding", e.ONBOARDING_IO = "onboarding_io";
102
- })(ne || (ne = {}));
103
- var te;
104
- (function(e) {
105
- e.Unset = "unset", e.Required = "required", e.Optional = "optional", e.Completed = "completed", e.Disabled = "disabled", e.Unavailable = "unavailable";
106
- })(te || (te = {}));
107
- R.POLL, R.PREDICTION, R.TRIVIA;
108
- const ds = {
109
- [$.GAMES]: !0
110
- }, Q = /* @__PURE__ */ h("div")({
111
- name: "LoadingContainer",
112
- class: "lclc0ej",
113
- propsAsIs: !1
114
- }), cs = ({
115
- feature: e,
116
- sdk: s,
117
- children: n,
118
- className: o,
119
- noWait: a
120
- }) => {
121
- const r = u(e.status), l = u(s.sdkStore.slStreamId);
122
- if (!a) {
123
- if (l != null && l.loading && !l.data)
124
- return /* @__PURE__ */ t(Q, {
125
- className: o,
126
- children: "Event is loading..."
127
- });
128
- if (!(l != null && l.data))
129
- return /* @__PURE__ */ t(Q, {
130
- className: o,
131
- children: "Event is forbidden..."
132
- });
133
- if (r !== ye.Ready)
134
- return /* @__PURE__ */ t(Q, {
135
- className: o,
136
- children: "Wait feature..."
137
- });
138
- }
139
- return n;
140
- }, ve = es({
141
- sdk: null
142
- }), B = () => z(ve), ps = /* @__PURE__ */ h("div")({
143
- name: "QuestionContainer",
144
- class: "q14ckf9e",
145
- propsAsIs: !1
146
- }), us = ({
147
- openedQuestion: e
148
- }) => {
149
- var s, n;
150
- const {
151
- sdk: o
152
- } = B();
153
- return ((s = e == null ? void 0 : e.attributes) == null ? void 0 : s.attributes.case) === "insight" ? /* @__PURE__ */ t(be, {
154
- ...e.attributes.attributes.value,
155
- controlVideo: o == null ? void 0 : o.controlVideoPlayer
156
- }) : ((n = e == null ? void 0 : e.attributes) == null ? void 0 : n.attributes.case) === "tweet" ? /* @__PURE__ */ t(Se, {
157
- ...e.attributes.attributes.value,
158
- controlVideo: o == null ? void 0 : o.controlVideoPlayer
159
- }) : null;
160
- }, hs = ({
161
- extendedQuestion: e,
162
- vote: s,
163
- close: n
164
- }) => {
165
- const {
166
- loading: o,
167
- data: a
168
- } = e;
169
- return a ? /* @__PURE__ */ t(Ie, {
170
- vote: s,
171
- close: n,
172
- openedQuestion: a,
173
- isLoading: !!o
174
- }) : /* @__PURE__ */ t(Ee, {});
175
- }, vs = ({
176
- gamification: e,
177
- hideSponsor: s,
178
- className: n,
179
- hideHeader: o
180
- }) => {
181
- var a, r, l;
182
- const d = u(e.openedQuestion.$store), i = u(e.openedQuestion.$extendedStore);
183
- if (!d)
184
- return null;
185
- const c = d.type;
186
- return /* @__PURE__ */ g(ps, {
187
- className: n,
188
- children: [!o && /* @__PURE__ */ t(re, {
189
- close: e.closeQuestion,
190
- type: ((a = d.attributes) == null ? void 0 : a.type) || R.UNSET
191
- }), c === "question" && /* @__PURE__ */ t(hs, {
192
- vote: e.submitAnswer,
193
- close: e.closeQuestion,
194
- extendedQuestion: i
195
- }), c !== "question" && /* @__PURE__ */ t(us, {
196
- openedQuestion: d
197
- }), !s && /* @__PURE__ */ t(Ne, {
198
- sponsorLogo: (l = (r = i.data) == null ? void 0 : r.sponsorship) == null ? void 0 : l.logo
199
- })]
200
- });
201
- }, ms = /* @__PURE__ */ h("div")({
202
- name: "InviteFriendsContainer",
203
- class: "i1c9dygq",
204
- propsAsIs: !1
205
- }), gs = ({
206
- deepLink: e
207
- }) => /* @__PURE__ */ t(ms, {
208
- children: /* @__PURE__ */ t(Ae, {
209
- inviteLink: e,
210
- inviteCardTitle: "It’s More Fun With Friends",
211
- inviteCardSubtext: "Invite and compete against your friends for the top spot on the leaderboard."
212
- })
213
- }), fs = /* @__PURE__ */ h("div")({
214
- name: "InviteLinkContainer",
215
- class: "i1odbhm4",
216
- propsAsIs: !1
217
- }), ks = ({
218
- gamification: e,
219
- scrollNode: s,
220
- scrollStore: n
221
- }) => {
222
- const o = L(null), {
223
- data: a,
224
- hasMore: r,
225
- loading: l,
226
- key: d
227
- } = u(e.leaderboardList.$store), {
228
- data: i
229
- } = u(e.deepLink.$store), [c, p] = Ce(o);
230
- return !a.length && !l ? /* @__PURE__ */ t(gs, {
231
- deepLink: i
232
- }) : /* @__PURE__ */ g(D, {
233
- children: [/* @__PURE__ */ t(we, {
234
- items: a,
235
- scrollNode: s,
236
- scrollStore: n,
237
- fetchMore: e.leaderboardList.fetchMore,
238
- hasMore: r,
239
- openItemDetail: e.openUser,
240
- currentUserId: e.currentUserId.get()
241
- }, d), i && /* @__PURE__ */ t(fs, {
242
- ref: o,
243
- children: /* @__PURE__ */ t($e, {
244
- onClick: () => c(i),
245
- title: "Invite Friends",
246
- description: "Challenge them now!"
247
- })
248
- }), p]
249
- });
250
- }, ys = ({ store: e, openQuestion: s }) => {
251
- const { sdk: n } = B(), o = u(e);
252
- return /* @__PURE__ */ t(Le, { openQuestion: s, questions: o.data, controlVideo: n == null ? void 0 : n.controlVideoPlayer });
253
- }, Ns = ({ userSummary: e }) => {
254
- var s;
255
- const [n, o] = E(void 0);
256
- return k(() => {
257
- const a = e.$store.subscribe((r) => {
258
- r && o(r);
259
- });
260
- return () => {
261
- a();
262
- };
263
- }, [e]), /* @__PURE__ */ t(le, { loading: !(n != null && n.summary), ...n == null ? void 0 : n.summary, successRate: (s = n == null ? void 0 : n.percentage) == null ? void 0 : s.correct });
264
- }, bs = ({ gamification: e, className: s, scrollStore: n, scrollNode: o, appNode: a, style: r, responsiveStore: l }) => {
265
- const { tabsShown: d } = u(n, { keys: ["tabsShown"] }), [i, c] = E(q.HOME), [, p] = ss(), { sdkInDesktopView: v, screen: f } = u(l, { keys: ["sdkInDesktopView"] }), N = (S) => {
266
- p(() => {
267
- var y;
268
- c(S), v === !1 && (((y = a.current) == null ? void 0 : y.getBoundingClientRect().y) || 0) < 0 && M(a, f.size, { behavior: "instant" });
269
- });
270
- };
271
- k(() => n.subscribe((S) => {
272
- if (S.scrollPosition === 0) {
273
- n.setKey("tabsShown", !0);
274
- return;
275
- }
276
- l.get().sdkInDesktopView ? n.setKey("tabsShown", S.scrollDirection === "backward") : n.setKey("tabsShown", S.scrollDirection === "forward");
277
- }), [n, l]);
278
- let b = "0px";
279
- return v ? b = d ? "0px" : "calc(8px - var(--header-height) - var(--header-offset))" : b = d ? "calc(var(--header-height) + var(--header-offset) - 2px)" : "0px", /* @__PURE__ */ g(De, { className: s, style: r, children: [
280
- /* @__PURE__ */ t(
281
- Te,
282
- {
283
- style: {
284
- top: b
285
- },
286
- children: /* @__PURE__ */ t(Oe, { activePage: i, toggleActivePage: N })
287
- }
288
- ),
289
- i === q.HOME && /* @__PURE__ */ g(D, { children: [
290
- /* @__PURE__ */ t(de, { style: { paddingTop: "8px" }, children: /* @__PURE__ */ t(xe, { children: /* @__PURE__ */ t(Ns, { userSummary: e.userSummary }) }) }),
291
- /* @__PURE__ */ t(Re, { style: { flex: 1 }, children: /* @__PURE__ */ t(ys, { openQuestion: e.openQuestion, store: e.feedList.getStore() }) })
292
- ] }),
293
- i === q.LEADERBOARD && /* @__PURE__ */ t(Ve, { children: /* @__PURE__ */ t(ks, { scrollStore: n, scrollNode: o, gamification: e }) })
294
- ] });
295
- }, Ss = () => U, oe = /* @__PURE__ */ h(Ss())({
296
- name: "OpenedContainer",
297
- class: "ouvguos",
298
- propsAsIs: !0
299
- }), Is = /* @__PURE__ */ h("div")({
300
- name: "UserContainer",
301
- class: "u1eu4lbg",
302
- propsAsIs: !1
303
- }), Es = ({
304
- correct: e,
305
- incorrect: s
306
- }) => {
307
- const n = e + s;
308
- return n === 0 ? 0 : Math.round(e / n * 100);
309
- }, gn = ({
310
- gamification: e,
311
- scrollStore: s,
312
- className: n,
313
- appNode: o,
314
- scrollNode: a,
315
- responsiveStore: r
316
- }) => /* @__PURE__ */ t(bs, {
317
- appNode: o,
318
- scrollStore: s,
319
- scrollNode: a,
320
- className: n,
321
- gamification: e,
322
- responsiveStore: r
323
- }), As = ({
324
- gamification: e,
325
- className: s,
326
- appNode: n,
327
- responsiveStore: o
328
- }) => {
329
- const a = u(e.openedQuestion.$store), r = u(e.openedUser), {
330
- sdkInDesktopView: l
331
- } = u(o, {
332
- keys: ["sdkInDesktopView"]
333
- }), {
334
- hiding: d,
335
- onAnimationEnd: i
336
- } = Pe();
337
- if (!n.current || !a && !r)
338
- return null;
339
- const c = a ? /* @__PURE__ */ t(oe, {
340
- className: s,
341
- hiding: d,
342
- onAnimationEnd: i,
343
- children: /* @__PURE__ */ t(vs, {
344
- gamification: e
345
- })
346
- }) : r ? /* @__PURE__ */ t(oe, {
347
- className: s,
348
- hiding: d,
349
- onAnimationEnd: i,
350
- children: /* @__PURE__ */ g(Is, {
351
- children: [/* @__PURE__ */ t(re, {
352
- label: "Friend's Rank",
353
- close: e.closeUser
354
- }), /* @__PURE__ */ t(de, {
355
- children: /* @__PURE__ */ t(le, {
356
- ...r,
357
- successRate: Es(r)
358
- })
359
- })]
360
- })
361
- }) : null;
362
- return /* @__PURE__ */ t(ce, {
363
- container: n,
364
- useContainer: !l,
365
- children: c
366
- });
367
- }, Cs = ns(() => import("./gamification-feature.js")), ws = ({ sdk: e, feature: s, className: n, scrollStore: o, appNode: a, scrollNode: r, responsiveStore: l }) => {
368
- const d = w(() => s && s.featureConfig.get().type === $.GAMES ? /* @__PURE__ */ t(cs, { className: n, sdk: e, feature: s, children: /* @__PURE__ */ t(
369
- Cs,
370
- {
371
- appNode: a,
372
- scrollStore: o,
373
- scrollNode: r,
374
- className: n,
375
- responsiveStore: l,
376
- gamification: s
377
- }
378
- ) }) : null, [e, s, n, l, o, r, a]);
379
- return /* @__PURE__ */ t(
380
- ts,
381
- {
382
- fallback: /* @__PURE__ */ t("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", width: "100%", height: "100%" }, children: "page loading..." }),
383
- children: d
384
- }
385
- );
386
- }, $s = ({ feature: e, className: s, appNode: n, responsiveStore: o }) => e && e.featureConfig.get().type === $.GAMES ? /* @__PURE__ */ t(
387
- As,
388
- {
389
- className: s,
390
- appNode: n,
391
- responsiveStore: o,
392
- gamification: e
393
- }
394
- ) : null, Ls = () => pe, Ds = /* @__PURE__ */ h(Ls())({
395
- name: "ButtonIcon",
396
- class: "b11wpe79",
397
- propsAsIs: !0
398
- }), Ts = os(({
399
- sdk: e,
400
- className: s
401
- }, n) => {
402
- const o = u(e.sdkStore.organizationSettings), a = u(e.sdkStore.streamSettings), r = u(e.getActiveFeature()), l = w(() => {
403
- const i = (a == null ? void 0 : a.data) || (o == null ? void 0 : o.data);
404
- return i != null && i.overlays ? i.overlays : [];
405
- }, [o, a]), d = w(() => [...l.filter(({
406
- enableSdkButton: i,
407
- type: c
408
- }) => c === $.GAMES || i).map((i) => ({
409
- id: i.type,
410
- onClick: () => e.openFeature(i.type),
411
- disabled: !(i.type in ds),
412
- label: i.name,
413
- icon: /* @__PURE__ */ t("img", {
414
- src: i.icon,
415
- alt: ""
416
- }),
417
- /** multiplied by 10 to add the ability to insert custom buttons between our buttons */
418
- position: i.position * 10
419
- }))].sort((i, c) => i.position - c.position), [l, e]);
420
- return /* @__PURE__ */ g(qe, {
421
- className: s,
422
- children: [d.length !== 0 && /* @__PURE__ */ t(G, {
423
- children: [/* @__PURE__ */ t(O, {
424
- id: "Channels",
425
- onClick: () => e.closeFeature(),
426
- label: "Channels",
427
- active: r === 0
428
- }, "Channels"), ...d.map((i) => i.id === $.GAMES ? /* @__PURE__ */ t(O, {
429
- ...i,
430
- active: i.id === r,
431
- label: "StreamLayer +",
432
- id: "featuredGroups",
433
- icon: /* @__PURE__ */ t(Ds, {
434
- name: "icon-btn-feature-groups",
435
- "data-selected": i.id === r
436
- })
437
- }, i.id) : /* @__PURE__ */ t(O, {
438
- ...i,
439
- icon: void 0,
440
- active: i.id === r
441
- }, i.id))]
442
- }), !d.length && /* @__PURE__ */ t(G, {
443
- children: [/* @__PURE__ */ t(O, {
444
- id: "empty",
445
- label: "No Features...",
446
- active: !1,
447
- disabled: !0
448
- }, "empty")]
449
- }), /* @__PURE__ */ t("div", {
450
- ref: n
451
- })]
452
- });
453
- }), Os = /* @__PURE__ */ h("div")({
454
- name: "Container",
455
- class: "c1qjj4d4",
456
- propsAsIs: !1
457
- }), xs = /* @__PURE__ */ h("div")({
458
- name: "CloseIconWrap",
459
- class: "c1lg6b8a",
460
- propsAsIs: !1
461
- }), Rs = () => pe, Vs = /* @__PURE__ */ h(Rs())({
462
- name: "CloseIcon",
463
- class: "c159el66",
464
- propsAsIs: !0
465
- }), Ps = /* @__PURE__ */ h("div")({
466
- name: "Title",
467
- class: "t16xmufv",
468
- propsAsIs: !1
469
- }), qs = /* @__PURE__ */ h("img")({
470
- name: "SponsorLogo",
471
- class: "s83lc21",
472
- propsAsIs: !1
473
- }), _s = /* @__PURE__ */ h("div")({
474
- name: "PresentsTitle",
475
- class: "p1p7igia",
476
- propsAsIs: !1
477
- }), Fs = /* @__PURE__ */ h("div")({
478
- name: "Subtitle",
479
- class: "s1eftsbu",
480
- propsAsIs: !1
481
- }), Qs = /* @__PURE__ */ h("div")({
482
- name: "Description",
483
- class: "d8uezec",
484
- propsAsIs: !1
485
- }), Ks = /* @__PURE__ */ h("button")({
486
- name: "ActionButton",
487
- class: "a1h1bk90",
488
- propsAsIs: !1
489
- }), ie = ({ close: e, action: s, onboarding: n }) => {
490
- var o, a, r, l, d, i, c, p;
491
- return /* @__PURE__ */ g(Os, { children: [
492
- /* @__PURE__ */ t(xs, { onClick: e, children: /* @__PURE__ */ t(Vs, { name: "icon-cross" }) }),
493
- ((a = (o = n == null ? void 0 : n.titleCard) == null ? void 0 : o.media) == null ? void 0 : a.sponsorLogo) && /* @__PURE__ */ g(Ps, { children: [
494
- /* @__PURE__ */ t(qs, { alt: "sponsor-logo", src: (l = (r = n == null ? void 0 : n.titleCard) == null ? void 0 : r.media) == null ? void 0 : l.sponsorLogo }),
495
- /* @__PURE__ */ t(_s, { children: "PRESENTS" })
496
- ] }),
497
- ((d = n == null ? void 0 : n.titleCard) == null ? void 0 : d.title) && /* @__PURE__ */ t(Fs, { children: (i = n == null ? void 0 : n.titleCard) == null ? void 0 : i.title }),
498
- ((c = n == null ? void 0 : n.titleCard) == null ? void 0 : c.subtitle) && /* @__PURE__ */ t(Qs, { children: (p = n == null ? void 0 : n.titleCard) == null ? void 0 : p.subtitle }),
499
- /* @__PURE__ */ t(Ks, { onClick: s, children: "Play Now" })
500
- ] });
501
- }, K = [{
502
- graphicSrc: "https://cdn.streamlayer.io/assets/sdk-web/onboarding-steps/step_0.png",
503
- tagline: "",
504
- headline: /* @__PURE__ */ g(D, {
505
- children: ["Welcome to ", /* @__PURE__ */ t("br", {}), " StreamLayer +"]
506
- })
507
- }, {
508
- graphicSrc: "https://cdn.streamlayer.io/assets/sdk-web/onboarding-steps/step_2.png",
509
- headline: "Get real-time insights"
510
- }, {
511
- graphicSrc: "https://cdn.streamlayer.io/assets/sdk-web/onboarding-steps/step_3.png",
512
- headline: "Predictions, trivia & polls synced to match play"
513
- }, {
514
- graphicSrc: "https://cdn.streamlayer.io/assets/sdk-web/onboarding-steps/step_4.png",
515
- headline: "Win points for every answer you get right"
516
- }, {
517
- graphicSrc: "https://cdn.streamlayer.io/assets/sdk-web/onboarding-steps/step_5.png",
518
- headline: "Compete against friends on the leaderboard"
519
- }], Ms = /* @__PURE__ */ h("div")({
520
- name: "OnboardingContainer",
521
- class: "o1xni1kr",
522
- propsAsIs: !1
523
- }), Us = () => U, zs = /* @__PURE__ */ h(Us())({
524
- name: "OnboardingNotificationContainer",
525
- class: "o1vnouv7",
526
- propsAsIs: !0
527
- }), ae = /* @__PURE__ */ h("div")({
528
- name: "InnerContainer",
529
- class: "i59uefw",
530
- propsAsIs: !1
531
- }), Bs = ({
532
- deepLink: e,
533
- onboardingOpts: s,
534
- notification: n,
535
- gamification: o,
536
- loading: a,
537
- sdk: r
538
- }) => {
539
- var l, d, i, c, p, v, f;
540
- const N = u(o.friends.getStore()), [b, S] = E(void 0), y = w(() => {
541
- var A, T;
542
- const W = r.getInviter();
543
- return W ? (T = (A = N.data) == null ? void 0 : A.find(({
544
- slId: ge
545
- }) => ge === W)) == null ? void 0 : T.name : "";
546
- }, [N.data, r]);
547
- return k(() => {
548
- const A = e.$store.subscribe((T) => {
549
- T && S(T.data);
550
- });
551
- return () => {
552
- A();
553
- };
554
- }, [e.$store]), /* @__PURE__ */ t(Ms, {
555
- children: /* @__PURE__ */ t(Fe, {
556
- loading: a,
557
- rules: [{
558
- label: "Answer as many questions as you like.",
559
- icon: "icon-btn-feature-groups"
560
- }, {
561
- label: "Win points for each correct trivia or prediction answer.",
562
- icon: "icon-thumb-up"
563
- }, {
564
- label: "Top the leader board and best your friends.",
565
- icon: "icon-trophy"
566
- }],
567
- rulesBtnLabel: (l = s.rules) == null ? void 0 : l.buttonLabel,
568
- rulesTitle: (d = s.rules) == null ? void 0 : d.heading,
569
- termsTitle: "Terms and Conditions",
570
- termsText: (i = s.rules) == null ? void 0 : i.terms,
571
- steps: K,
572
- primaryColor: (c = s.inviteCard) == null ? void 0 : c.iconColor,
573
- inviteLink: b,
574
- inviteCardTitle: (p = s.inviteCard) == null ? void 0 : p.heading,
575
- inviteCardSubtext: (v = s.inviteCard) == null ? void 0 : v.subtext,
576
- inviteCardBtnLabel: (f = s.inviteCard) == null ? void 0 : f.buttonLabel,
577
- onClose: () => {
578
- var A;
579
- (A = n.close) == null || A.call(n);
580
- },
581
- gamification: o,
582
- sdk: r,
583
- inviterName: y
584
- })
585
- });
586
- }, Ws = ({
587
- sdk: e,
588
- notification: s,
589
- saveHeight: n,
590
- style: o,
591
- appNode: a,
592
- sdkInDesktopView: r,
593
- responsiveStore: l
594
- }) => {
595
- const d = L(null), i = s.data.onboarding, [c, p] = E(i == null ? void 0 : i.instantOpen), v = e.getFeature($.GAMES), f = w(() => K == null ? void 0 : K.map(({
596
- graphicSrc: y
597
- }) => y), []), {
598
- screen: N
599
- } = u(l, {
600
- keys: ["screen"]
601
- });
602
- is(() => {
603
- var y;
604
- n(((y = d.current) == null ? void 0 : y.getBoundingClientRect().height) || 0);
605
- }, [n]);
606
- const {
607
- loading: b,
608
- throttled: S
609
- } = _e(f);
610
- return c && v && i && a.current && !S ? /* @__PURE__ */ t(ce, {
611
- container: a,
612
- useContainer: !r,
613
- children: /* @__PURE__ */ t(Bs, {
614
- notification: s,
615
- setOpened: p,
616
- gamification: v,
617
- onboardingOpts: i,
618
- deepLink: v.deepLink,
619
- loading: b,
620
- renderToNode: a,
621
- sdk: e
622
- })
623
- }) : /* @__PURE__ */ g(D, {
624
- children: [/* @__PURE__ */ t(ae, {
625
- ref: d,
626
- style: {
627
- position: "absolute",
628
- visibility: "hidden"
629
- },
630
- children: /* @__PURE__ */ t(ie, {
631
- close: () => {
632
- },
633
- action: () => {
634
- },
635
- onboarding: i
636
- })
637
- }), /* @__PURE__ */ t(zs, {
638
- style: o,
639
- hiding: s.hiding,
640
- children: /* @__PURE__ */ t(ae, {
641
- children: /* @__PURE__ */ t(ie, {
642
- close: s.close,
643
- action: () => {
644
- var y;
645
- p(!0), (((y = a.current) == null ? void 0 : y.getBoundingClientRect().y) || 0) < 0 && M(a, N.size, {
646
- behavior: "smooth"
647
- });
648
- },
649
- onboarding: i
650
- })
651
- })
652
- })]
653
- });
654
- }, Gs = () => U, Hs = /* @__PURE__ */ h(Gs())({
655
- name: "Container",
656
- class: "c8ol1ve",
657
- propsAsIs: !0
658
- }), me = /* @__PURE__ */ h("div")({
659
- name: "InnerContainer",
660
- class: "iqfywam",
661
- propsAsIs: !1
662
- }), js = () => me, Xs = /* @__PURE__ */ h(js())({
663
- name: "HiddenContainer",
664
- class: "hokmtod",
665
- propsAsIs: !0
666
- }), Ys = /* @__PURE__ */ h("div")({
667
- name: "NotificationRefreshing",
668
- class: "n192d1q8",
669
- propsAsIs: !1
670
- }), Zs = () => Qe, Js = /* @__PURE__ */ h(Zs())({
671
- name: "Pill",
672
- class: "p1lha68t",
673
- propsAsIs: !0
674
- }), en = (e) => {
675
- const [s, n] = E(0), o = L(null), a = V((l) => {
676
- o.current = l;
677
- }, []);
678
- k(() => {
679
- var l;
680
- const d = (l = o.current) == null ? void 0 : l.getBoundingClientRect();
681
- d && n(d.height);
682
- }, [e]);
683
- const r = V((l) => {
684
- n(l);
685
- }, []);
686
- return [a, s, r];
687
- }, sn = ({
688
- sdk: e,
689
- notification: s,
690
- appNode: n,
691
- responsiveStore: o
692
- }) => {
693
- var a, r;
694
- const {
695
- sdkInDesktopView: l
696
- } = u(o, {
697
- keys: ["sdkInDesktopView"]
698
- }), {
699
- sdk: d
700
- } = B(), [i, c, p] = en(s.id);
701
- return s.type === x.QUESTION ? /* @__PURE__ */ g(D, {
702
- children: [/* @__PURE__ */ t(Xs, {
703
- ref: i,
704
- children: /* @__PURE__ */ t(H, {
705
- ...s
706
- })
707
- }), /* @__PURE__ */ g(Hs, {
708
- style: {
709
- height: s.hiding ? 0 : c
710
- },
711
- hiding: s.hiding,
712
- children: [/* @__PURE__ */ t(me, {
713
- style: {
714
- height: "100%"
715
- },
716
- children: /* @__PURE__ */ t(H, {
717
- ...s,
718
- controlVideo: d == null ? void 0 : d.controlVideoPlayer
719
- })
720
- }), /* @__PURE__ */ t(Ys, {}, s.id)]
721
- })]
722
- }) : s.type === x.QUESTION_RESOLVED && (r = (a = s.data) == null ? void 0 : a.question) != null && r.predictionResult ? /* @__PURE__ */ t(Me, {
723
- style: {
724
- height: s.hiding ? 0 : c
725
- },
726
- saveHeight: p,
727
- close: s.close,
728
- hiding: s.hiding,
729
- ...s.data.question
730
- }) : s.type === x.ONBOARDING ? /* @__PURE__ */ t(Ws, {
731
- style: {
732
- height: s.hiding ? 0 : c
733
- },
734
- saveHeight: p,
735
- sdk: e,
736
- notification: s,
737
- sdkInDesktopView: l,
738
- appNode: n,
739
- responsiveStore: o
740
- }) : null;
741
- }, nn = "p7vfi6t", tn = ({
742
- pill: e,
743
- setPill: s,
744
- appNode: n,
745
- headerNode: o,
746
- scrollNode: a,
747
- responsiveStore: r,
748
- scrollStore: l
749
- }) => {
750
- var d, i;
751
- const {
752
- screen: c
753
- } = u(r, {
754
- keys: ["screen"]
755
- }), {
756
- tabsShown: p,
757
- scrollPosition: v
758
- } = u(l, {
759
- keys: ["tabsShown", "scrollPosition"]
760
- });
761
- k(() => {
762
- r.get().sdkInDesktopView ? v < 50 && s(null) : v > -50 && s(null);
763
- }, [v, r, s]);
764
- const f = r.get().sdkInDesktopView ? n : o;
765
- return !e || !f.current ? null : Ue.createPortal(/* @__PURE__ */ t(Js, {
766
- title: e.type === x.QUESTION_RESOLVED ? "Prediction result" : `New ${((i = ze[(d = e.data) == null ? void 0 : d.questionType]) == null ? void 0 : i.label) || "notification"}`,
767
- onClick: () => {
768
- var N;
769
- r.get().sdkInDesktopView ? (N = a.current) == null || N.scrollTo({
770
- top: 0,
771
- behavior: "smooth"
772
- }) : M(n, c.size, {
773
- behavior: "smooth"
774
- }), s(null);
775
- },
776
- className: ue(p && nn, "sl-pill-button")
777
- }), f.current);
778
- }, on = ({
779
- sdk: e,
780
- headerNode: s,
781
- scrollNode: n,
782
- responsiveStore: o,
783
- appNode: a,
784
- scrollStore: r
785
- }) => {
786
- const [l] = E(e.getNotificationsStore()), d = u(l), [i, c] = E(null), p = w(() => e.getActiveNotification(), [e, d]);
787
- return k(() => {
788
- p && Ke.emit("notification", {
789
- action: "rendered",
790
- payload: {
791
- questionId: p.data.questionId,
792
- questionType: p.data.questionType
793
- }
794
- });
795
- }, [p]), k(() => {
796
- p && (o.get().sdkInDesktopView || o.get().sdkInView) && (!o.get().sdkInDesktopView && o.get().sdkInView && c(p), o.get().sdkInDesktopView && window.requestAnimationFrame(() => {
797
- r.get().scrollPosition !== 0 && c(p);
798
- }));
799
- }, [p]), k(() => {
800
- p || c(null);
801
- }, [p]), /* @__PURE__ */ g(D, {
802
- children: [!i && p && /* @__PURE__ */ t(sn, {
803
- headerNode: s,
804
- appNode: a,
805
- sdk: e,
806
- notification: p,
807
- responsiveStore: o
808
- }), i && /* @__PURE__ */ t(tn, {
809
- pill: i,
810
- setPill: c,
811
- appNode: a,
812
- notification: p,
813
- headerNode: s,
814
- scrollNode: n,
815
- scrollStore: r,
816
- responsiveStore: o
817
- })]
818
- });
819
- }, an = (e) => {
820
- const s = L(""), [n, o] = E(!1), a = u(e.status), r = u(e.sdkStore.slStreamId), l = u(e.userId()), d = u(e.getActiveFeature()), i = a === "ready" && !!r.data;
821
- k(() => {
822
- const v = e.getFeature($.GAMES);
823
- v && (v.closeQuestion(), v.closeUser());
824
- }, [d, e]);
825
- const c = V(
826
- (v) => {
827
- s.current = v, o(!0), e.initializeApp({ skipOrganizationSettings: !0 }).then(({ enabled: f, err: N }) => {
828
- if (!N && f) {
829
- e.isUserAuthorized().then((b) => {
830
- b || e.disableApp();
831
- });
832
- return;
833
- }
834
- });
835
- },
836
- [e]
837
- ), p = V(() => {
838
- o(!1), e.disableApp();
839
- }, [e]);
840
- return k(() => {
841
- if (!l) {
842
- i && e.disableApp();
843
- return;
844
- }
845
- if (l && s.current && n) {
846
- e.initializeApp({ skipOrganizationSettings: !0 }).then(() => {
847
- e.createEventSession(s.current);
848
- });
849
- return;
850
- }
851
- }, [l]), k(() => () => {
852
- o(!1), e.disableApp();
853
- }, [o, e]), {
854
- sdkEnabled: n,
855
- sdkReady: i,
856
- activateEventWithId: c,
857
- deactivate: p,
858
- isLogged: !!l
859
- };
860
- }, rn = ({ sdk: e, className: s, scrollStore: n, appNode: o, scrollNode: a, responsiveStore: r }) => {
861
- const [, l] = je(e);
862
- return /* @__PURE__ */ t(
863
- ws,
864
- {
865
- className: s,
866
- scrollNode: a,
867
- appNode: o,
868
- scrollStore: n,
869
- feature: l,
870
- responsiveStore: r,
871
- sdk: e
872
- }
873
- );
874
- }, ln = ({ sdk: e, className: s, appNode: n, responsiveStore: o }) => {
875
- const a = u(e.featuresList.getStore());
876
- return a ? Array.from(a, (r) => {
877
- const l = e.getFeature(r);
878
- return l ? /* @__PURE__ */ t(
879
- $s,
880
- {
881
- className: s,
882
- appNode: n,
883
- feature: l,
884
- responsiveStore: o,
885
- sdk: e
886
- },
887
- r
888
- ) : null;
889
- }) : null;
890
- }, dn = ({ sdk: e, event: s }) => {
891
- const n = L(null), o = L(null), [a] = Be(n), [r, l] = We(n, a), { sdkEnabled: d, sdkReady: i, activateEventWithId: c, deactivate: p, isLogged: v } = an(e);
892
- k(() => {
893
- s ? (e.createEventSession(s), c(s)) : p();
894
- }, [s, c, p, e]), _(n, { enabled: d, event: "click", listener: Xe }), _(r, {
895
- enabled: d,
896
- event: "scrollend",
897
- listener: Ye,
898
- useDomNode: !0
899
- }), _(r, {
900
- enabled: d,
901
- event: "click",
902
- listener: Ze,
903
- useDomNode: !0
904
- });
905
- const f = w(() => ({ sdk: e }), [e]);
906
- return k(() => {
907
- import("./gamification-feature.js");
908
- }, []), /* @__PURE__ */ t(ve.Provider, { value: f, children: /* @__PURE__ */ g(Ge, { ref: n, children: [
909
- d && /* @__PURE__ */ t(Ts, { className: F, sdk: e, ref: o }),
910
- /* @__PURE__ */ g(He, { className: "sl-hide-on-modal", ref: r, "data-nav": d.toString(), children: [
911
- i && /* @__PURE__ */ t(
912
- on,
913
- {
914
- sdk: e,
915
- scrollNode: r,
916
- headerNode: o,
917
- appNode: n,
918
- scrollStore: l,
919
- responsiveStore: a
920
- }
921
- ),
922
- i && /* @__PURE__ */ t(
923
- rn,
924
- {
925
- scrollStore: l,
926
- responsiveStore: a,
927
- scrollNode: r,
928
- appNode: n,
929
- className: F,
930
- sdk: e
931
- }
932
- ),
933
- i && /* @__PURE__ */ t(ln, { responsiveStore: a, appNode: n, className: F, sdk: e })
934
- ] }),
935
- d && !v && /* @__PURE__ */ t(
936
- "div",
937
- {
938
- style: { display: "flex", alignItems: "center", justifyContent: "center", width: "100%", height: "100%" },
939
- children: "You are not logged in."
940
- }
941
- )
942
- ] }) });
943
- }, cn = ({ children: e, customTheme: s, style: n }) => /* @__PURE__ */ t("div", { className: "StreamLayerSDKTheme", children: /* @__PURE__ */ t("div", { className: ue(Je, s), style: n, children: e }) }), fn = () => {
944
- const { sdk: e } = z(he);
945
- return e;
946
- }, kn = ({ event: e }) => {
947
- const { sdk: s, status: n } = z(he);
948
- if (n === j.UNSET)
949
- throw new Error("Wrap app in `StreamLayerProvider`");
950
- return n === j.CONNECTED ? /* @__PURE__ */ t("div", { className: "StreamLayerSDK", children: "wait" }) : s === null ? /* @__PURE__ */ t("div", { className: "StreamLayerSDK", children: "sdk not initialized" }) : /* @__PURE__ */ t("div", { className: "StreamLayerSDK", children: /* @__PURE__ */ t(cn, { children: /* @__PURE__ */ t(dn, { sdk: s, event: e }) }) });
951
- };
952
- export {
953
- gn as E,
954
- an as F,
955
- kn as S,
956
- cn as d,
957
- fn as u
958
- };