@everymatrix/casino-engagement-suite-tournament 1.62.2 → 1.62.4

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.
Files changed (43) hide show
  1. package/dist/casino-engagement-suite-tournament/casino-engagement-suite-tournament.esm.js +1 -1
  2. package/dist/casino-engagement-suite-tournament/index.esm.js +1 -1
  3. package/dist/casino-engagement-suite-tournament/p-14ab3c1a.entry.js +1 -0
  4. package/dist/casino-engagement-suite-tournament/p-5f051654.js +15 -0
  5. package/dist/casino-engagement-suite-tournament/{p-bfca9e2a.js → p-c6fe0205.js} +1 -1
  6. package/dist/cjs/{casino-engagement-suite-progress-bar_3.cjs.entry.js → casino-engagement-suite-progress-bar_6.cjs.entry.js} +124 -2
  7. package/dist/cjs/{casino-engagement-suite-tournament-bc4edfdf.js → casino-engagement-suite-tournament-1f1275c4.js} +179 -242
  8. package/dist/cjs/casino-engagement-suite-tournament.cjs.js +2 -2
  9. package/dist/cjs/{index-982cd594.js → index-5e98dd13.js} +4 -3
  10. package/dist/cjs/index.cjs.js +2 -2
  11. package/dist/cjs/loader.cjs.js +2 -2
  12. package/dist/collection/assets/help.svg +10 -0
  13. package/dist/collection/collection-manifest.json +4 -1
  14. package/dist/collection/components/casino-engagement-suite-tournament/casino-engagement-suite-tournament.css +30 -3
  15. package/dist/collection/components/casino-engagement-suite-tournament/casino-engagement-suite-tournament.js +89 -34
  16. package/dist/collection/shared/TournamentDurationTimer.js +92 -0
  17. package/dist/collection/shared/TournamentItem.js +114 -0
  18. package/dist/collection/shared/TournamentItemTitle.js +124 -0
  19. package/dist/collection/shared/icons.js +2 -1
  20. package/dist/collection/shared/renderBar.js +2 -2
  21. package/dist/collection/shared/renders.page.js +6 -79
  22. package/dist/collection/shared/renders.tab.js +2 -2
  23. package/dist/collection/utils/api.apdater.js +8 -0
  24. package/dist/collection/utils/bussiness.js +0 -25
  25. package/dist/collection/utils/message.js +27 -19
  26. package/dist/collection/utils/util.date.js +3 -0
  27. package/dist/esm/{casino-engagement-suite-progress-bar_3.entry.js → casino-engagement-suite-progress-bar_6.entry.js} +123 -3
  28. package/dist/esm/{casino-engagement-suite-tournament-bc5e0906.js → casino-engagement-suite-tournament-54c513f1.js} +162 -231
  29. package/dist/esm/casino-engagement-suite-tournament.js +3 -3
  30. package/dist/esm/{index-ac437a77.js → index-8b5c4b95.js} +4 -3
  31. package/dist/esm/index.js +2 -2
  32. package/dist/esm/loader.js +3 -3
  33. package/dist/types/components/casino-engagement-suite-tournament/casino-engagement-suite-tournament.d.ts +8 -10
  34. package/dist/types/components.d.ts +85 -2
  35. package/dist/types/shared/TournamentDurationTimer.d.ts +15 -0
  36. package/dist/types/shared/TournamentItem.d.ts +46 -0
  37. package/dist/types/shared/TournamentItemTitle.d.ts +47 -0
  38. package/dist/types/utils/bussiness.d.ts +1 -45
  39. package/dist/types/utils/message.d.ts +2 -2
  40. package/dist/types/utils/util.date.d.ts +1 -1
  41. package/package.json +1 -1
  42. package/dist/casino-engagement-suite-tournament/p-67373ab1.entry.js +0 -1
  43. package/dist/casino-engagement-suite-tournament/p-b217e7cc.js +0 -15
@@ -0,0 +1,124 @@
1
+ import { h } from "@stencil/core";
2
+ import { DialogType, TournamentState } from "../utils/types";
3
+ import { renderGradientRoundedButton } from "./GradientRoundedButton";
4
+ import { TRANSLATIONS } from "../utils/translations";
5
+ export class CasinoEngagementSuiteTournamentItemTitle {
6
+ constructor() {
7
+ this.tournament = undefined;
8
+ this.locale = TRANSLATIONS;
9
+ this.isButtonDisabed = false;
10
+ }
11
+ onTournamentChanged(tournament) {
12
+ this.isButtonDisabed = tournament.isActionJoinPending === true;
13
+ }
14
+ onClickItemJoin() {
15
+ if (this.isButtonDisabed) {
16
+ return;
17
+ }
18
+ this.isButtonDisabed = true;
19
+ if (this.tournament.isPlayerAcknowledged) {
20
+ this.unjoinTournamentEvent.emit({ type: DialogType.unjoin, tournament: this.tournament });
21
+ }
22
+ else {
23
+ this.joinTournamentEvent.emit(this.tournament);
24
+ }
25
+ }
26
+ componentDidLoad() {
27
+ this.isButtonDisabed = this.tournament.isActionJoinPending === true;
28
+ }
29
+ render() {
30
+ return (h("div", { key: '5d6eebb15e8e1f1ac635fa90fe69407aab9cf81c', class: "TitleContainer" }, h("div", { key: 'ad7dd682272d822537cd484797b2f5d3825e49c8', class: "Title" }, this.tournament.nameOrTitle), this.tournament.state !== TournamentState.Closed && (h("div", { key: '87e50a538aca5ce7d7b1a659dbe6aa16541194f2' }, renderGradientRoundedButton({
31
+ statedClasses: {
32
+ isHollow: this.tournament.isPlayerAcknowledged,
33
+ isPending: this.isButtonDisabed
34
+ },
35
+ onClick: (e) => {
36
+ e.stopPropagation();
37
+ this.onClickItemJoin();
38
+ },
39
+ innerHTML: this.tournament.isPlayerAcknowledged ? this.locale.Unjoin : this.locale.Join
40
+ })))));
41
+ }
42
+ static get is() { return "casino-engagement-suite-tournament-item-title"; }
43
+ static get properties() {
44
+ return {
45
+ "tournament": {
46
+ "type": "unknown",
47
+ "mutable": false,
48
+ "complexType": {
49
+ "original": "Tournament",
50
+ "resolved": "{ href: string; id: string; nameOrTitle: string; description: string; termsUrl: string; thumbnail: string; thumbnails: []; startTime: Date; endTime: Date; closeTime: Date; exhibitionStartTime: Date; exhibitionEndTime: Date; state: TournamentState; tags: string; minBetCount: number; dataSource: string; scoreCriteria: string; wallets: { code: string; }; prizes: { rank: number; count: number; name: string; }[]; games?: TournamentGame[]; playerEnrolled?: boolean; isPlayerAcknowledged?: boolean; isActionJoinPending?: boolean; isUnjoined?: boolean; }",
51
+ "references": {
52
+ "Tournament": {
53
+ "location": "import",
54
+ "path": "../utils/types",
55
+ "id": "../../../../packages/stencil/casino-engagement-suite-tournament/src/utils/types.ts::Tournament"
56
+ }
57
+ }
58
+ },
59
+ "required": false,
60
+ "optional": false,
61
+ "docs": {
62
+ "tags": [],
63
+ "text": ""
64
+ },
65
+ "defaultValue": "undefined"
66
+ }
67
+ };
68
+ }
69
+ static get states() {
70
+ return {
71
+ "locale": {},
72
+ "isButtonDisabed": {}
73
+ };
74
+ }
75
+ static get events() {
76
+ return [{
77
+ "method": "unjoinTournamentEvent",
78
+ "name": "unjoinTournamentEvent",
79
+ "bubbles": true,
80
+ "cancelable": true,
81
+ "composed": true,
82
+ "docs": {
83
+ "tags": [],
84
+ "text": ""
85
+ },
86
+ "complexType": {
87
+ "original": "Object",
88
+ "resolved": "Object",
89
+ "references": {
90
+ "Object": {
91
+ "location": "global",
92
+ "id": "global::Object"
93
+ }
94
+ }
95
+ }
96
+ }, {
97
+ "method": "joinTournamentEvent",
98
+ "name": "joinTournamentEvent",
99
+ "bubbles": true,
100
+ "cancelable": true,
101
+ "composed": true,
102
+ "docs": {
103
+ "tags": [],
104
+ "text": ""
105
+ },
106
+ "complexType": {
107
+ "original": "Object",
108
+ "resolved": "Object",
109
+ "references": {
110
+ "Object": {
111
+ "location": "global",
112
+ "id": "global::Object"
113
+ }
114
+ }
115
+ }
116
+ }];
117
+ }
118
+ static get watchers() {
119
+ return [{
120
+ "propName": "tournament",
121
+ "methodName": "onTournamentChanged"
122
+ }];
123
+ }
124
+ }
@@ -1,7 +1,8 @@
1
1
  import { h } from "@stencil/core";
2
2
  import reward from "../assets/reward.svg";
3
+ import help from "../assets/help.svg";
3
4
  export const iconClose = h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/close.svg" });
4
- export const iconQuestion = h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/help.svg" });
5
+ export const iconQuestion = h("img", { src: help, alt: "question", class: "Question" });
5
6
  export const iconEyeOpen = h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/eye-open.svg" });
6
7
  export const iconEyeClose = h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/eye-closed.svg" });
7
8
  export const iconBack = h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/back.svg" });
@@ -4,11 +4,11 @@ export const renderCloseBar = (attr) => {
4
4
  const slots = {
5
5
  left,
6
6
  middle,
7
- right,
7
+ right
8
8
  };
9
9
  const getFirstLetterUppercase = (str) => str
10
10
  .split('')
11
11
  .map((letter, index) => index === 0 ? letter.toUpperCase() : letter)
12
12
  .join('');
13
- return (h("div", { class: "WrapperBar" }, Object.keys(slots).map(slotKey => (h("div", { class: "WrapperBar" + getFirstLetterUppercase(slotKey) }, slots[slotKey] || '')))));
13
+ return (h("div", { class: "WrapperBar" }, Object.keys(slots).map(slotKey => (h("div", { class: 'WrapperBar' + getFirstLetterUppercase(slotKey) }, slots[slotKey] || '')))));
14
14
  };
@@ -1,11 +1,6 @@
1
1
  import { h } from "@stencil/core";
2
2
  import { tournamentAdapter } from "../utils/api.apdater";
3
3
  import { classnames } from "../utils/utils";
4
- import { DialogType, LeaderboardPage, TournamentState } from "../utils/types";
5
- import { renderGradientRoundedButton } from "./GradientRoundedButton";
6
- import { iconBack, iconClose, iconQuestion } from "./icons";
7
- import { renderCloseBar } from "./renderBar";
8
- import { renderTimeBar } from "./renders.util";
9
4
  import { Tab } from "../utils/translations";
10
5
  import { messageSender } from "../utils/message";
11
6
  export const page = {
@@ -17,14 +12,10 @@ export const page = {
17
12
  }
18
13
  const { locale } = instance;
19
14
  if (instance.tournamentList.length) {
20
- const onClickListItemChangePage = (tournament) => {
21
- instance.setPage(LeaderboardPage.item, { tournament });
22
- instance.newIdList = instance.newIdList.filter((id) => id !== tournament.id);
23
- };
24
- return renderLeaderboardContainer(instance, h("div", { class: 'Leaderboards Row' }, instance.tournamentList.map((_tournament) => (h("div", { class: classnames('LeaderboardsItem', _tournament.isPlayerAcknowledged ? ' GradientRounded Hollow' : '', _tournament.isUnjoined ? 'Unjoined' : ''), onClick: () => onClickListItemChangePage(_tournament) }, h("div", { class: "LeaderboardsItemContainer" }, renderTitleContainer(instance, _tournament), renderTimeBar(_tournament)), h("div", { class: "LeaderboardLabels" }, instance.newIdList.includes(_tournament.id) && (h("div", { class: "LeaderboardLabel" }, h("span", null, "new")))))))));
15
+ return renderWrapperByPageType(h("div", { class: "Leaderboards ScrollBar Row" }, instance.tournamentList.map((_tournament) => (h("casino-engagement-suite-tournament-item", { tournament: _tournament, isNew: instance.newIdList.includes(_tournament.id) })))));
25
16
  }
26
17
  else {
27
- return renderLeaderboardContainer(instance, h("div", { class: "NoLeaderboards Row" }, h("h3", { class: 'Title' }, locale.NoLeaderboards), h("div", { class: 'message' }, locale.NoLeaderboardsTip)));
18
+ return renderWrapperByPageType(h("div", { class: "NoLeaderboards ScrollBar Row" }, h("h3", { class: "Title" }, locale.NoLeaderboards), h("div", { class: "message" }, locale.NoLeaderboardsTip)));
28
19
  }
29
20
  },
30
21
  item(instance) {
@@ -47,77 +38,13 @@ export const page = {
47
38
  return (h("div", { class: "TabsContainer" }, h("div", { class: "Tabs" }, Object.keys(Tab).map((_tab) => (h("div", { class: classnames({ active: tab === _tab }),
48
39
  onClick: () => onClickTab(_tab) }, locale[_tab]))))));
49
40
  };
50
- return renderLeaderboardContainer(instance, [
51
- renderTitleContainer(instance, instance.tournamentItem),
41
+ return renderWrapperByPageType([
42
+ h("casino-engagement-suite-tournament-item-title", { tournament: instance.tournamentItem }),
52
43
  renderTabs(),
53
44
  h("div", { class: `TableContentWrapper ${instance.tab}` }, instance.renders.tab[instance.tab]())
54
45
  ]);
55
46
  }
56
47
  };
57
- const renderTitleContainer = (instance, tournament) => {
58
- const { locale } = instance;
59
- const onClickItemJoin = (tournament) => {
60
- if (tournament.isPlayerAcknowledged) {
61
- instance.openDialog(DialogType.unjoin, tournament);
62
- }
63
- else {
64
- instance.actionJoin(tournament);
65
- instance.tournamentItem = tournament;
66
- }
67
- };
68
- return (h("div", { class: "TitleContainer" }, h("div", { class: "Title" }, tournament.nameOrTitle), tournament.state !== TournamentState.Closed && (h("div", null, renderGradientRoundedButton({
69
- statedClasses: {
70
- isHollow: tournament.isPlayerAcknowledged,
71
- isPending: tournament.isActionJoinPending
72
- },
73
- onClick: (e) => {
74
- e.stopPropagation();
75
- if (!tournament.isActionJoinPending) {
76
- onClickItemJoin(tournament);
77
- }
78
- },
79
- innerHTML: tournament.isPlayerAcknowledged ? locale.Unjoin : locale.Join
80
- })))));
81
- };
82
- const renderLeaderboardContainer = (instance, render) => {
83
- const { dialog: { isOpen } } = instance;
84
- const renderBar = renderCloseBar({
85
- right: h("span", { onClick: () => instance.closeDialog() }, iconClose)
86
- });
87
- const renderDialogContent = () => {
88
- switch (instance.dialog.type) {
89
- case DialogType.unjoin:
90
- return instance.renders.dialog.unjoin();
91
- case DialogType.tip:
92
- return h("div", { class: "Tip" }, instance.locale.Tip);
93
- case DialogType.error:
94
- return h("div", { class: "Tip Error" }, instance.locale.FailedToJoin);
95
- case DialogType.gift:
96
- return instance.renders.dialog.gift();
97
- }
98
- };
99
- const getWrapperBarData = () => {
100
- const { page, locale } = instance;
101
- switch (page) {
102
- case LeaderboardPage.list:
103
- return {
104
- left: h("span", { onClick: () => instance.openDialog(DialogType.tip), onMouseEnter: () => { instance.showTooltip = true; }, onMouseLeave: () => { instance.showTooltip = false; }, ref: (el) => instance.tooltipIconReference = el }, iconQuestion, instance.renderTooltip()),
105
- middle: locale.Leaderboards
106
- };
107
- case LeaderboardPage.item:
108
- return {
109
- left: h("span", { onClick: () => instance.setPage(LeaderboardPage.list) }, iconBack),
110
- middle: locale.Leaderboards
111
- };
112
- }
113
- };
114
- const renderCloseBarInLayout = () => {
115
- const { left, middle } = getWrapperBarData();
116
- return renderCloseBar({
117
- left,
118
- middle,
119
- right: h("span", { onClick: () => instance.close.emit() }, iconClose)
120
- });
121
- };
122
- return (h("div", { class: `Wrapper ${instance.device}` }, h("div", { class: classnames('WrapperContent', { faded: isOpen }) }, renderCloseBarInLayout(), h("div", { class: "Root" }, h("div", { class: "Main" }, render))), h("div", { class: "WrapperUtil" }, h("dialog", { open: isOpen, style: { 'top': instance.getContainerScrollTop() + 'px' } }, h("div", { class: "GradientRounded Hollow" }, renderBar, isOpen && renderDialogContent())))));
48
+ const renderWrapperByPageType = (render) => {
49
+ return (h("div", { class: "Root" }, h("div", { class: "Main" }, render)));
123
50
  };
@@ -9,7 +9,7 @@ export const tab = {
9
9
  info(instance) {
10
10
  var _a, _b;
11
11
  const { locale, tournamentItem: tournament, isShowInfo } = instance;
12
- return (h("div", { class: "InfoContainer" }, renderTimeBar(tournament), h("section", { class: "ShowInfo", onClick: () => (instance.isShowInfo = !instance.isShowInfo) }, h("div", { class: 'DetailHeader' }, h("span", null, isShowInfo ? iconEyeOpen : iconEyeClose), h("span", null, locale.LeaderboardDetails))), h("div", { class: `ContentScrollContainer ${isShowInfo ? 'expanded' : ''}` }, isShowInfo && (h("section", { class: "Info" }, h("div", { class: 'Description' }, tournament.description), h("div", { class: "Criterias" }, h("div", null, locale.ScoreCriteria, ": ", h("span", null, tournament.scoreCriteria)), h("div", null, locale.MinimumBetCriteria, ": ", h("span", null, tournament.minBetCount))), !!tournament.termsUrl && (h("div", { class: "TC" }, h("a", { href: tournament.termsUrl, target: "_blank" }, locale.TC))))), isTournamentClosed(instance.tournamentItem) && ((_a = instance.leaderboards) === null || _a === void 0 ? void 0 : _a.find((l) => l.isMe)) && (h("section", { class: "ResultPrize", innerHTML: localePostprocess(locale.TipPrize, getResultPrize((_b = instance.leaderboards) === null || _b === void 0 ? void 0 : _b.find((l) => l.isMe))) })), h("section", { class: "PrizesContainer" }, h("div", { class: "PrizesHeader" }, iconReward, h("span", { class: "PrizesText" }, locale.Prizes)), h("div", { class: "Prizes" }, tournament.prizes.map((prize, index) => (h("div", { class: "Prize" }, index + 1, " ", locale.Place, ": ", h("span", { class: "PrizeText" }, prize.name)))))))));
12
+ return (h("div", { class: "InfoContainer" }, renderTimeBar(tournament), h("section", { class: "ShowInfo", onClick: () => (instance.isShowInfo = !instance.isShowInfo) }, h("div", { class: "DetailHeader" }, h("span", null, isShowInfo ? iconEyeOpen : iconEyeClose), h("span", null, locale.LeaderboardDetails))), h("div", { class: `ContentScrollContainer ${isShowInfo ? 'expanded' : ''}` }, isShowInfo && (h("section", { class: "Info" }, h("div", { class: "Description" }, tournament.description), h("div", { class: "Criterias" }, h("div", null, locale.ScoreCriteria, ": ", h("span", null, tournament.scoreCriteria)), h("div", null, locale.MinimumBetCriteria, ": ", h("span", null, tournament.minBetCount))), !!tournament.termsUrl && (h("div", { class: "TC" }, h("a", { href: tournament.termsUrl, target: "_blank" }, locale.TC))))), isTournamentClosed(instance.tournamentItem) && ((_a = instance.leaderboards) === null || _a === void 0 ? void 0 : _a.find((l) => l.isMe)) && (h("section", { class: "ResultPrize", innerHTML: localePostprocess(locale.TipPrize, getResultPrize((_b = instance.leaderboards) === null || _b === void 0 ? void 0 : _b.find((l) => l.isMe))) })), h("section", { class: "PrizesContainer" }, h("div", { class: "PrizesHeader" }, iconReward, h("span", { class: "PrizesText" }, locale.Prizes)), h("div", { class: "Prizes" }, tournament.prizes.map((prize, index) => (h("div", { class: "Prize" }, index + 1, " ", locale.Place, ": ", h("span", { class: "PrizeText" }, prize.name)))))))));
13
13
  },
14
14
  leaderboard(instance) {
15
15
  const { locale, tournamentItem } = instance;
@@ -26,7 +26,7 @@ export const tab = {
26
26
  },
27
27
  games(instance) {
28
28
  var _a;
29
- return (h("div", { class: "Games" }, (_a = instance.tournamentItem.games) === null || _a === void 0 ? void 0 : _a.map((game) => (h("div", { class: 'Game', onClick: () => {
29
+ return (h("div", { class: "Games" }, (_a = instance.tournamentItem.games) === null || _a === void 0 ? void 0 : _a.map((game) => (h("div", { class: `Game ${instance.currentGameId == game.id ? 'Current' : ''}`, onClick: () => {
30
30
  instance.onGameClick(game);
31
31
  } }, h("img", { src: game.defaultThumbnail, alt: "" }))))));
32
32
  }
@@ -24,6 +24,14 @@ export const leaderboardsAdapter = (leaderboardRes) => {
24
24
  if (!item) {
25
25
  return leaderboards;
26
26
  }
27
+ // show current player's rank info at first row if there is no player info in list
28
+ const playerRankIndex = leaderboards.findIndex((leaderboard) => {
29
+ return leaderboard.userId === item.userId;
30
+ });
31
+ playerRankIndex === -1 ? leaderboards = [
32
+ item,
33
+ ...leaderboards,
34
+ ] : {};
27
35
  return leaderboards.map((leaderboard) => {
28
36
  if ((item === null || item === void 0 ? void 0 : item.userId) && item.userId === leaderboard.userId) {
29
37
  return Object.assign(Object.assign({}, leaderboard), { isMe: true });
@@ -1,5 +1,4 @@
1
1
  import { TournamentState } from "./types";
2
- import dateFnsFormat from "date-fns/format";
3
2
  export const getMaxRankStr = (list) => {
4
3
  let itemHaveMaxRank;
5
4
  list.map((item) => {
@@ -27,27 +26,3 @@ export const getMaxRankStr = (list) => {
27
26
  export const isTournamentClosed = (tournament) => {
28
27
  return [TournamentState.Closed, TournamentState.Closing].includes(tournament.state);
29
28
  };
30
- export const getTournamentListByItem = (tournamentList, tournament) => {
31
- return tournamentList.map((_tournament) => {
32
- if (_tournament.id === tournament.id) {
33
- return tournament;
34
- }
35
- else {
36
- return _tournament;
37
- }
38
- });
39
- };
40
- export const getTournamentListParams = (language) => {
41
- return {
42
- 'type': 'InitTournamentList',
43
- 'messageType': 'apiCall',
44
- 'method': 'GET',
45
- 'queryParams': {
46
- 'filter': `PlayerEnrolled=true,ExhibitionEndTime=${dateFnsFormat(new Date(), 'yyyy-MM-ddThh:mm:ssZ')},TicketStatus=active|closed|completed|released`,
47
- 'sortField': 'StartTime',
48
- 'sortOrder': 'asc',
49
- 'pagination': 'limit=50,offset=0',
50
- language
51
- }
52
- };
53
- };
@@ -1,25 +1,16 @@
1
1
  import { leaderboardsAdapter, tournamentAdapter } from "./api.apdater";
2
2
  import { getMaxRankStr } from "./bussiness";
3
- import { DialogType } from "./types";
3
+ import { DialogType, LeaderboardPage } from "./types";
4
4
  export const messageSender = {
5
- InitTournamentList: (queryParams) => {
6
- window.postMessage(Object.assign({ type: 'InitTournamentList' }, queryParams));
7
- },
8
- post: (options) => {
9
- window.postMessage(Object.assign({}, options));
10
- },
11
5
  UpdateSuiteBarState: (labels) => window.postMessage({ type: 'UpdateLeaderboardState', labels }),
12
- JoinTournamentReq: (tournament) => {
13
- var _a, _b;
14
- return window.postMessage({
15
- type: 'JoinTournamentReq',
16
- id: tournament.id,
17
- bonusCode: tournament.id || ((_b = (_a = tournament.wallets) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.code)
18
- });
19
- },
6
+ JoinTournamentReq: (tournament) => window.postMessage({
7
+ type: 'JoinTournamentReq',
8
+ id: tournament.id,
9
+ }),
20
10
  UnjoinTournamentReq: (tournament) => window.postMessage({ type: 'UnjoinTournamentReq', id: tournament.id }),
21
11
  UpdateTournamentsItemReq: (tournament) => window.postMessage({ type: 'UpdateTournamentsItemReq', id: tournament.id }),
22
12
  UpdateLeaderboardsReq: (tournament, query) => window.postMessage({ type: 'UpdateLeaderboardsReq', id: tournament.id, query }),
13
+ UpdateTournamentsPageIsReady: () => window.postMessage({ type: 'TournamentsPageIsReady' }),
23
14
  UpdateLeaderboardsPlayerReq: () => window.postMessage({ type: 'UpdateLeaderboardsPlayerReq' }),
24
15
  GameClickReq: (game) => window.postMessage({ type: 'EngagementSuiteGameRedirect', data: { Slug: game.slug } }),
25
16
  };
@@ -40,6 +31,7 @@ export const messageReceiver = (instance) => {
40
31
  UpdateLeaderboardsRes: (rest) => processLeaderboardTableData(instance, rest),
41
32
  JoinTournamentRes: (rest) => commonJoinRes(instance, rest),
42
33
  UnjoinTournamentRes: (rest) => commonJoinRes(instance, rest),
34
+ TournamentsPageIsReadyRes: (rest) => instance.currentGameId = rest.data.GameId,
43
35
  // listen to LeaderboardLiveEvent event, handle update
44
36
  LeaderboardLiveEvent: (rest) => {
45
37
  handleLeaderboardLiveEvent(instance, rest);
@@ -127,7 +119,10 @@ const showErrorMessage = (instance, type) => {
127
119
  const commonJoinRes = (instance, rest) => {
128
120
  const { success, data } = rest;
129
121
  let tournamentIdx = instance.tournamentList.findIndex((tournament) => tournament.id === (data.tournamentId || data.id || data.bonusCode)), current = instance.tournamentList[tournamentIdx];
130
- current.isActionJoinPending = false;
122
+ if (tournamentIdx == -1) {
123
+ return;
124
+ }
125
+ current = Object.assign(Object.assign({}, current), { isActionJoinPending: false });
131
126
  if (!success) {
132
127
  instance.tournamentList[tournamentIdx] = current;
133
128
  instance.tournamentList = [...instance.tournamentList];
@@ -137,6 +132,15 @@ const commonJoinRes = (instance, rest) => {
137
132
  current = Object.assign(Object.assign({}, current), { isUnjoined: current.isPlayerAcknowledged ? true : false, isPlayerAcknowledged: !!!current.isPlayerAcknowledged });
138
133
  instance.tournamentList[tournamentIdx] = current;
139
134
  instance.tournamentList = [...instance.tournamentList];
135
+ if (instance.page === LeaderboardPage.item) {
136
+ if (current.isUnjoined) {
137
+ instance.setPage(LeaderboardPage.list);
138
+ return;
139
+ }
140
+ else {
141
+ instance.tournamentItem = Object.assign({}, current);
142
+ }
143
+ }
140
144
  if (instance.nextPage) {
141
145
  instance.setPage(instance.nextPage);
142
146
  instance.nextPage = undefined;
@@ -161,10 +165,14 @@ const removeTournament = (instance, tournament) => {
161
165
  };
162
166
  const updateOrAddTournamentToList = (instance, tournament) => {
163
167
  const index = instance.tournamentList.findIndex((_tournament) => _tournament.id === tournament.id);
164
- if (index !== -1) {
165
- instance.tournamentList[index] = tournamentAdapter(tournament);
168
+ if (index === -1) {
169
+ instance.tournamentList = [
170
+ tournamentAdapter(tournament),
171
+ ...instance.tournamentList
172
+ ];
166
173
  }
167
174
  else {
168
- instance.tournamentList = instance.tournamentList.concat(tournamentAdapter(tournament));
175
+ instance.tournamentList[index] = tournamentAdapter(tournament);
176
+ instance.tournamentList = [...instance.tournamentList];
169
177
  }
170
178
  };
@@ -34,6 +34,9 @@ export function getDifference(startDate, endDate) {
34
34
  return formattedDiff;
35
35
  }
36
36
  export function getProgress(startDate, endDate) {
37
+ if (new Date().getTime() >= endDate.getTime()) {
38
+ return 100;
39
+ }
37
40
  return ((100 * (new Date().getTime() - startDate.getTime())) / (endDate.getTime() - startDate.getTime())).toFixed(0);
38
41
  }
39
42
  export function getTimeDifference(startDate, endDate) {
@@ -1,5 +1,6 @@
1
- import { r as registerInstance, h, g as getElement } from './index-ac437a77.js';
2
- export { C as casino_engagement_suite_tournament } from './casino-engagement-suite-tournament-bc5e0906.js';
1
+ import { r as registerInstance, h, g as getElement, c as createEvent } from './index-8b5c4b95.js';
2
+ import { T as TRANSLATIONS, c as classnames, D as DialogType, a as TournamentState, r as renderGradientRoundedButton, L as LeaderboardPage, g as getTimeDifference, b as getProgress, f as formatDate } from './casino-engagement-suite-tournament-54c513f1.js';
3
+ export { C as casino_engagement_suite_tournament } from './casino-engagement-suite-tournament-54c513f1.js';
3
4
 
4
5
  const casinoEngagementSuiteProgressBarCss = ":host{display:block;font-family:inherit}:host(.Desktop) .ProgressBarPercent{font-size:var(--emw--font-size-small, 14px);line-height:14px}@keyframes indeterminate{0%{left:-200%;right:100%}60%{left:110%;right:-10%}to{left:110%;right:-10%}}.ProgressBarBackground{height:8px;background-color:var(--emw--color-gray-300, #666178);border-radius:var(--emw--border-radius-small, 4px);position:relative;overflow:hidden}.ProgressBarLine{position:absolute;left:0;top:0;bottom:0;border-radius:var(--emw--border-radius-small, 4px);background:var(--emw--engagement-suite-gradient-button, linear-gradient(98.25deg, #FF9400 22.48%, #FEF746 131.02%, #FFE24A 131.9%));transition:width ease-out 0.3s}.ProgressBarLine.Indeterminate{animation:indeterminate 1s linear infinite}.ProgressBarInfo{margin-bottom:8px;display:flex;justify-content:space-between;align-items:center}.ProgressBarPercent{font-weight:var(--emw--font-weight-bold, 700);font-size:var(--emw--font-size-x-small, 12px);line-height:12px}.HidePercent .ProgressBarPercent{display:none}.ProgressBar:not(.Disabled) .ProgressBarPercent{background:var(--emw--engagement-suite-gradient-button, linear-gradient(98.25deg, #FF9400 22.48%, #FEF746 131.02%, #FFE24A 131.9%));-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent}.ProgressBar.Disabled .ProgressBarPercent{color:var(--emw--color-gray-300, #666178)}.ProgressBar.Disabled .ProgressBarLine{background:var(--emw--color-background-secondary, #474668)}";
5
6
  const CasinoEngagementSuiteProgressBarStyle0 = casinoEngagementSuiteProgressBarCss;
@@ -65,6 +66,125 @@ const CasinoEngagementSuiteProgressBar = class {
65
66
  };
66
67
  CasinoEngagementSuiteProgressBar.style = CasinoEngagementSuiteProgressBarStyle0;
67
68
 
69
+ const CasinoEngagementSuiteTournamentItem = class {
70
+ constructor(hostRef) {
71
+ registerInstance(this, hostRef);
72
+ this.clickToTournamentDetail = createEvent(this, "clickToTournamentDetail", 7);
73
+ this.tournament = undefined;
74
+ this.isNew = undefined;
75
+ this.locale = TRANSLATIONS;
76
+ }
77
+ handleJoinTournamentEvent(e) {
78
+ if (this.tournament.id === e.detail.id) {
79
+ this.tournament = Object.assign(Object.assign({}, this.tournament), { isActionJoinPending: true });
80
+ }
81
+ }
82
+ handleUnjoinTournamentEvent(e) {
83
+ if (this.tournament.id === e.detail.id) {
84
+ this.tournament = Object.assign(Object.assign({}, this.tournament), { isActionJoinPending: true });
85
+ }
86
+ }
87
+ goToDetail() {
88
+ this.clickToTournamentDetail.emit(this.tournament);
89
+ }
90
+ render() {
91
+ const tournament = this.tournament;
92
+ return (h("div", { key: 'e507da65532f4608aa96c1ebe2e329d332b9c439', class: classnames('LeaderboardsItem', tournament.isPlayerAcknowledged ? ' GradientRounded Hollow' : '', tournament.isUnjoined ? 'Unjoined' : ''), onClick: this.goToDetail.bind(this) }, h("div", { key: 'dc9bd1777858b2a3a57a3f808f734857db9011ee', class: "LeaderboardsItemContainer" }, h("casino-engagement-suite-tournament-item-title", { key: '14cae37fbc9d0f829b85d507ea0e60c95afc7250', tournament: tournament }), h("casino-engagement-suite-tournament-timer", { key: 'd703d03c146592887ea20bdc1289b446399f0870', tournament: tournament })), h("div", { key: '4f2f422965b47c0103ff5dcef8f28dc507491677', class: "LeaderboardLabels" }, this.isNew && (h("div", { key: '3132e3ac8adec5f9ca85d8c14c91801779d8afbf', class: "LeaderboardLabel" }, h("span", { key: 'c148c5fa597b76ff4f23c06b6b3407c06a96bdb7' }, "new"))))));
93
+ }
94
+ };
95
+
96
+ const CasinoEngagementSuiteTournamentItemTitle = class {
97
+ constructor(hostRef) {
98
+ registerInstance(this, hostRef);
99
+ this.unjoinTournamentEvent = createEvent(this, "unjoinTournamentEvent", 7);
100
+ this.joinTournamentEvent = createEvent(this, "joinTournamentEvent", 7);
101
+ this.tournament = undefined;
102
+ this.locale = TRANSLATIONS;
103
+ this.isButtonDisabed = false;
104
+ }
105
+ onTournamentChanged(tournament) {
106
+ this.isButtonDisabed = tournament.isActionJoinPending === true;
107
+ }
108
+ onClickItemJoin() {
109
+ if (this.isButtonDisabed) {
110
+ return;
111
+ }
112
+ this.isButtonDisabed = true;
113
+ if (this.tournament.isPlayerAcknowledged) {
114
+ this.unjoinTournamentEvent.emit({ type: DialogType.unjoin, tournament: this.tournament });
115
+ }
116
+ else {
117
+ this.joinTournamentEvent.emit(this.tournament);
118
+ }
119
+ }
120
+ componentDidLoad() {
121
+ this.isButtonDisabed = this.tournament.isActionJoinPending === true;
122
+ }
123
+ render() {
124
+ return (h("div", { key: '5d6eebb15e8e1f1ac635fa90fe69407aab9cf81c', class: "TitleContainer" }, h("div", { key: 'ad7dd682272d822537cd484797b2f5d3825e49c8', class: "Title" }, this.tournament.nameOrTitle), this.tournament.state !== TournamentState.Closed && (h("div", { key: '87e50a538aca5ce7d7b1a659dbe6aa16541194f2' }, renderGradientRoundedButton({
125
+ statedClasses: {
126
+ isHollow: this.tournament.isPlayerAcknowledged,
127
+ isPending: this.isButtonDisabed
128
+ },
129
+ onClick: (e) => {
130
+ e.stopPropagation();
131
+ this.onClickItemJoin();
132
+ },
133
+ innerHTML: this.tournament.isPlayerAcknowledged ? this.locale.Unjoin : this.locale.Join
134
+ })))));
135
+ }
136
+ static get watchers() { return {
137
+ "tournament": ["onTournamentChanged"]
138
+ }; }
139
+ };
140
+
141
+ const CasinoEngagementSuiteTournamentTimer = class {
142
+ constructor(hostRef) {
143
+ registerInstance(this, hostRef);
144
+ this.tournament = undefined;
145
+ this.time = 0;
146
+ this.timeHolder = undefined;
147
+ this.timeCloak = true;
148
+ }
149
+ containerPageChangeHandler(event) {
150
+ this.timeCloak = event.detail.page === LeaderboardPage.list ||
151
+ event.detail.page === LeaderboardPage.item && this.tournament.id === event.detail.tournamentId;
152
+ }
153
+ setTimeInterval() {
154
+ this.timeHolder = setInterval(() => {
155
+ var _a;
156
+ const timeDifference = getTimeDifference(new Date(), this.tournament.endTime);
157
+ const progress = getProgress(this.tournament.startTime, this.tournament.endTime);
158
+ if (this.timeCloak &&
159
+ ![TournamentState.Closed, TournamentState.Closing].includes((_a = this.tournament) === null || _a === void 0 ? void 0 : _a.state) &&
160
+ (timeDifference != this.lastTimeDiff || progress != this.lastProgress)) {
161
+ this.time++;
162
+ this.lastProgress = progress;
163
+ this.lastTimeDiff = timeDifference;
164
+ }
165
+ }, 2000);
166
+ }
167
+ connectedCallback() {
168
+ this.setTimeInterval();
169
+ }
170
+ disconnectedCallback() {
171
+ clearInterval(this.timeHolder);
172
+ }
173
+ render() {
174
+ return h("section", { key: 'b5d514586445a3acc665fcbbbaa0d139b7b28075', class: "TimeContainer" }, h("div", { key: '2080b18edd157a337d5c7f164d1914e91a95a3f3', class: "Time" }, this.tournament.state === 'Running'
175
+ ? [
176
+ h("div", { class: "Running" }, h("div", null, this.lastTimeDiff), ",", h("div", null, renderGradientRoundedButton({
177
+ statedClasses: {
178
+ isHollow: true,
179
+ isPendding: false
180
+ },
181
+ innerHTML: `${getProgress(this.tournament.startTime, this.tournament.endTime)}%`
182
+ })))
183
+ ]
184
+ : [h("div", { class: "NotRunning" }, formatDate(this.tournament.startTime)), h("div", null, formatDate(this.tournament.endTime))]), h("casino-engagement-suite-progress-bar", { key: 'b841cc70a1307f1175f0748644aaaeee9e1094ff', value: Number(this.lastProgress >= 100 ? 100 : this.lastProgress), "hide-percent": true }));
185
+ }
186
+ };
187
+
68
188
  const mergeTranslations = (url, target) => {
69
189
  return new Promise((resolve) => {
70
190
  fetch(url)
@@ -139,4 +259,4 @@ const GeneralStylingWrapper = class {
139
259
  };
140
260
  GeneralStylingWrapper.style = GeneralStylingWrapperStyle0;
141
261
 
142
- export { CasinoEngagementSuiteProgressBar as casino_engagement_suite_progress_bar, GeneralStylingWrapper as general_styling_wrapper };
262
+ export { CasinoEngagementSuiteProgressBar as casino_engagement_suite_progress_bar, CasinoEngagementSuiteTournamentItem as casino_engagement_suite_tournament_item, CasinoEngagementSuiteTournamentItemTitle as casino_engagement_suite_tournament_item_title, CasinoEngagementSuiteTournamentTimer as casino_engagement_suite_tournament_timer, GeneralStylingWrapper as general_styling_wrapper };