@everymatrix/lottery-game-page 0.1.26 → 1.0.69

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 (115) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/{helper-filters_2.cjs.entry.js → helper-accordion_13.cjs.entry.js} +13401 -9890
  3. package/dist/cjs/helper-pagination.cjs.entry.js +197 -189
  4. package/dist/cjs/index-f3851683.js +1345 -0
  5. package/dist/cjs/loader.cjs.js +7 -13
  6. package/dist/cjs/lottery-game-page.cjs.js +17 -11
  7. package/dist/collection/collection-manifest.json +4 -10
  8. package/dist/collection/components/lottery-game-page/index.js +1 -0
  9. package/dist/collection/components/lottery-game-page/lottery-game-page.css +11 -2
  10. package/dist/collection/components/lottery-game-page/lottery-game-page.js +579 -594
  11. package/dist/collection/utils/locale.utils.js +118 -95
  12. package/dist/collection/utils/utils.js +4 -4
  13. package/dist/esm/app-globals-0f993ce5.js +3 -0
  14. package/dist/esm/{helper-filters_2.entry.js → helper-accordion_13.entry.js} +13391 -9891
  15. package/dist/esm/helper-pagination.entry.js +197 -189
  16. package/dist/esm/index-8248702b.js +1316 -0
  17. package/dist/esm/loader.js +7 -13
  18. package/dist/esm/lottery-game-page.js +14 -11
  19. package/dist/lottery-game-page/lottery-game-page.esm.js +1 -1
  20. package/dist/lottery-game-page/p-46aaa562.entry.js +1 -0
  21. package/dist/lottery-game-page/p-8f2c63c7.js +2 -0
  22. package/dist/lottery-game-page/p-bd89bbf0.entry.js +3567 -0
  23. package/dist/lottery-game-page/p-e1255160.js +1 -0
  24. package/dist/stencil.config.dev.js +17 -0
  25. package/dist/stencil.config.js +12 -36
  26. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/lottery-game-page/.stencil/packages/stencil/lottery-game-page/stencil.config.d.ts +2 -0
  27. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/lottery-game-page/.stencil/packages/stencil/lottery-game-page/stencil.config.dev.d.ts +2 -0
  28. package/dist/types/components/lottery-game-page/index.d.ts +1 -0
  29. package/dist/types/components/lottery-game-page/lottery-game-page.d.ts +99 -90
  30. package/dist/types/components.d.ts +28 -2
  31. package/dist/types/stencil-public-runtime.d.ts +142 -33
  32. package/loader/cdn.js +1 -3
  33. package/loader/index.cjs.js +1 -3
  34. package/loader/index.d.ts +13 -1
  35. package/loader/index.es2017.js +1 -3
  36. package/loader/index.js +1 -3
  37. package/loader/package.json +1 -0
  38. package/package.json +13 -7
  39. package/dist/cjs/helper-accordion.cjs.entry.js +0 -124
  40. package/dist/cjs/helper-modal.cjs.entry.js +0 -76
  41. package/dist/cjs/helper-tab.cjs.entry.js +0 -68
  42. package/dist/cjs/helper-tabs.cjs.entry.js +0 -74
  43. package/dist/cjs/index-cd44e726.js +0 -1324
  44. package/dist/cjs/lottery-bullet_2.cjs.entry.js +0 -270
  45. package/dist/cjs/lottery-draw-results-history.cjs.entry.js +0 -198
  46. package/dist/cjs/lottery-game-details.cjs.entry.js +0 -51
  47. package/dist/cjs/lottery-game-page.cjs.entry.js +0 -427
  48. package/dist/cjs/lottery-ticket-controller.cjs.entry.js +0 -116
  49. package/dist/cjs/lottery-ticket.cjs.entry.js +0 -201
  50. package/dist/collection/components/lottery-game-page/static/chrono_desktop.png +0 -0
  51. package/dist/collection/components/lottery-game-page/static/chrono_lottery_mobile.png +0 -0
  52. package/dist/components/assets/chrono_desktop.png +0 -0
  53. package/dist/components/assets/chrono_lottery_mobile.png +0 -0
  54. package/dist/components/helper-accordion.js +0 -6
  55. package/dist/components/helper-accordion2.js +0 -151
  56. package/dist/components/helper-filters.js +0 -6
  57. package/dist/components/helper-filters2.js +0 -22394
  58. package/dist/components/helper-modal.js +0 -6
  59. package/dist/components/helper-modal2.js +0 -94
  60. package/dist/components/helper-pagination.js +0 -251
  61. package/dist/components/helper-tab.js +0 -6
  62. package/dist/components/helper-tab2.js +0 -87
  63. package/dist/components/helper-tabs.js +0 -6
  64. package/dist/components/helper-tabs2.js +0 -103
  65. package/dist/components/index.d.ts +0 -26
  66. package/dist/components/index.js +0 -1
  67. package/dist/components/lottery-bullet.js +0 -6
  68. package/dist/components/lottery-bullet2.js +0 -92
  69. package/dist/components/lottery-draw-results-history.js +0 -6
  70. package/dist/components/lottery-draw-results-history2.js +0 -256
  71. package/dist/components/lottery-draw-results.js +0 -6
  72. package/dist/components/lottery-draw-results2.js +0 -335
  73. package/dist/components/lottery-game-details.js +0 -6
  74. package/dist/components/lottery-game-details2.js +0 -85
  75. package/dist/components/lottery-game-page.d.ts +0 -11
  76. package/dist/components/lottery-game-page.js +0 -542
  77. package/dist/components/lottery-grid.js +0 -6
  78. package/dist/components/lottery-grid2.js +0 -237
  79. package/dist/components/lottery-ticket-controller.js +0 -6
  80. package/dist/components/lottery-ticket-controller2.js +0 -168
  81. package/dist/components/lottery-ticket.js +0 -6
  82. package/dist/components/lottery-ticket2.js +0 -244
  83. package/dist/esm/helper-accordion.entry.js +0 -120
  84. package/dist/esm/helper-modal.entry.js +0 -72
  85. package/dist/esm/helper-tab.entry.js +0 -64
  86. package/dist/esm/helper-tabs.entry.js +0 -70
  87. package/dist/esm/index-d1baacd4.js +0 -1296
  88. package/dist/esm/lottery-bullet_2.entry.js +0 -265
  89. package/dist/esm/lottery-draw-results-history.entry.js +0 -194
  90. package/dist/esm/lottery-game-details.entry.js +0 -47
  91. package/dist/esm/lottery-game-page.entry.js +0 -423
  92. package/dist/esm/lottery-ticket-controller.entry.js +0 -112
  93. package/dist/esm/lottery-ticket.entry.js +0 -197
  94. package/dist/esm/polyfills/core-js.js +0 -11
  95. package/dist/esm/polyfills/css-shim.js +0 -1
  96. package/dist/esm/polyfills/dom.js +0 -79
  97. package/dist/esm/polyfills/es5-html-element.js +0 -1
  98. package/dist/esm/polyfills/index.js +0 -34
  99. package/dist/esm/polyfills/system.js +0 -6
  100. package/dist/lottery-game-page/p-023325a2.entry.js +0 -1
  101. package/dist/lottery-game-page/p-04fbc8fd.entry.js +0 -1
  102. package/dist/lottery-game-page/p-256b151c.entry.js +0 -1
  103. package/dist/lottery-game-page/p-381b5507.entry.js +0 -1
  104. package/dist/lottery-game-page/p-3f8b6ad9.entry.js +0 -1
  105. package/dist/lottery-game-page/p-4274053c.entry.js +0 -1
  106. package/dist/lottery-game-page/p-4f81cd37.entry.js +0 -1
  107. package/dist/lottery-game-page/p-5c389034.entry.js +0 -1
  108. package/dist/lottery-game-page/p-7d06371e.entry.js +0 -1
  109. package/dist/lottery-game-page/p-ca8430a0.entry.js +0 -2849
  110. package/dist/lottery-game-page/p-d6f76e8d.entry.js +0 -1
  111. package/dist/lottery-game-page/p-e765c7d9.js +0 -1
  112. package/dist/lottery-game-page/p-f6fcc22c.entry.js +0 -1
  113. package/dist/lottery-game-page/static/chrono_desktop.png +0 -0
  114. package/dist/lottery-game-page/static/chrono_lottery_mobile.png +0 -0
  115. package/dist/types/Users/user/workspace/everymatrix/widgets-stencil/packages/lottery-game-page/.stencil/packages/lottery-game-page/stencil.config.d.ts +0 -2
@@ -1,423 +0,0 @@
1
- import { r as registerInstance, g as getAssetPath, h, a as getElement } from './index-d1baacd4.js';
2
-
3
- const DEFAULT_LANGUAGE = 'en';
4
- const SUPPORTED_LANGUAGES = ['ro', 'en', 'fr', 'ar'];
5
- const TRANSLATIONS = {
6
- en: {
7
- error: 'Error',
8
- title: 'Chrono',
9
- backButton: 'Back',
10
- lobbyButton: 'Lobby',
11
- prize: 'Prize',
12
- winUpTo: 'Win up to',
13
- nextDraw: 'Next draw in: ',
14
- buy: 'Buy tickets',
15
- viewLatest: 'View latest results',
16
- createTicket: 'Create Ticket',
17
- modalSuccess: 'Purchase successfully completed!',
18
- deleteTicketModalTitle: 'Delete Ticket',
19
- deleteTicketModalText: 'Are you sure you want to delete this ticket?',
20
- deleteTicketModalCancel: 'Cancel',
21
- deleteTicketModalConfirm: 'Delete',
22
- orderSummaryTitle: 'Order Summary',
23
- orderSummaryTickets: 'Ticket',
24
- orderSummaryTotal: 'Total',
25
- orderSummarySubmit: 'Submit',
26
- lastDrawResultsTitle: 'Last Draw Results',
27
- modalLogin: 'Please login to submit a ticket',
28
- },
29
- ro: {
30
- error: 'Eroare',
31
- title: 'Loto 6/49',
32
- backButton: 'Inapoi',
33
- lobbyButton: 'Lobby',
34
- prize: 'MARELE JACKPOT OMG',
35
- winUpTo: 'Castiga pana la',
36
- nextDraw: 'Urmatoarea extragere:',
37
- buy: 'Cumpara bilet',
38
- viewLatest: 'Ultimile extrageri',
39
- createTicket: 'Creeaza bilet',
40
- modalSuccess: 'Achizitie efectuata cu succes',
41
- deleteTicketModalTitle: 'Sterge biletul',
42
- deleteTicketModalText: 'Esti sigur ca vrei sa stergi acest bilet?',
43
- deleteTicketModalCancel: 'Anuleaza',
44
- deleteTicketModalConfirm: 'Sterge',
45
- orderSummaryTitle: 'Rezumat comanda',
46
- orderSummaryTickets: 'Bilet',
47
- orderSummaryTotal: 'Total',
48
- orderSummarySubmit: 'Trimite',
49
- lastDrawResultsTitle: 'Cele mai recente extrageri',
50
- modalLogin: 'Please login to submit a ticket',
51
- },
52
- fr: {
53
- error: 'Error',
54
- title: 'Chrono',
55
- backButton: 'Back',
56
- lobbyButton: 'Lobby',
57
- prize: 'Prize',
58
- winUpTo: 'Win up to',
59
- nextDraw: 'Next draw in: ',
60
- buy: 'Buy tickets',
61
- viewLatest: 'View latest results',
62
- createTicket: 'Create Ticket',
63
- modalSuccess: 'Purchase successfully completed!',
64
- deleteTicketModalTitle: 'Delete Ticket',
65
- deleteTicketModalText: 'Are you sure you want to delete this ticket?',
66
- deleteTicketModalCancel: 'Cancel',
67
- deleteTicketModalConfirm: 'Delete',
68
- orderSummaryTitle: 'Order Summary',
69
- orderSummaryTickets: 'Ticket',
70
- orderSummaryTotal: 'Total',
71
- orderSummarySubmit: 'Submit',
72
- lastDrawResultsTitle: 'Résultats du dernier tirage',
73
- modalLogin: 'Please login to submit a ticket',
74
- },
75
- ar: {
76
- error: 'خطأ',
77
- title: 'كرونو',
78
- backButton: 'خلف',
79
- lobbyButton: 'ردهة',
80
- prize: 'جائزة',
81
- winUpTo: 'الفوز بما يصل الى',
82
- nextDraw: 'السحب التالي:',
83
- buy: 'اشتري تذاكر',
84
- viewLatest: 'عرض أحدث النتائج',
85
- createTicket: 'إنشاء تذكرة',
86
- modalSuccess: '!سيتم الشراء بنجاح قريبًا',
87
- deleteTicketModalTitle: 'حذف التذكرة',
88
- deleteTicketModalText: 'هل أنت متأكد أنك تريد حذف هذه التذكرة؟',
89
- deleteTicketModalCancel: 'يلغي',
90
- deleteTicketModalConfirm: 'حذف',
91
- orderSummaryTitle: 'ملخص الطلب',
92
- orderSummaryTickets: 'تذكرة',
93
- orderSummaryTotal: 'المجموع',
94
- orderSummarySubmit: 'يُقدِّم',
95
- lastDrawResultsTitle: 'نتائج آخر سحب',
96
- modalLogin: 'الرجاء تسجيل الدخول لتقديم تذكرة'
97
- }
98
- };
99
- const translate = (key, customLang) => {
100
- const lang = customLang;
101
- return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
102
- };
103
-
104
- /**
105
- * @name isMobile
106
- * @description A method that returns if the browser used to access the app is from a mobile device or not
107
- * @param {String} userAgent window.navigator.userAgent
108
- * @returns {Boolean} true or false
109
- */
110
- const isMobile = (userAgent) => {
111
- return !!(userAgent.toLowerCase().match(/android/i) ||
112
- userAgent.toLowerCase().match(/blackberry|bb/i) ||
113
- userAgent.toLowerCase().match(/iphone|ipad|ipod/i) ||
114
- userAgent.toLowerCase().match(/windows phone|windows mobile|iemobile|wpdesktop/i));
115
- };
116
-
117
- const lotteryGamePageCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}.GamePage .GridBanner{background-color:#009993;background-repeat:no-repeat;background-position:center;color:#111;padding:0 20px 10px;height:220px;display:flex;flex-direction:column;justify-content:space-between}.GamePage .GridBanner .BannerButtonsWrapper{display:flex;justify-content:space-between;padding-top:16px}.GamePage .GridBanner .BannerButtonsWrapper .BannerBackButton,.GamePage .GridBanner .BannerButtonsWrapper .BannerLobbyButton{background:#fff;border:1px solid #D4D4D4;border-radius:4px;padding:7px 15px;font-size:12px;text-transform:uppercase;width:80px}.GamePage .GridBanner .GridBannerArea{padding-top:30px;display:flex;flex-direction:column;align-items:center}.GamePage .TotalWinnings{color:#000;font-size:18px;display:flex;flex-direction:row;justify-content:center;align-items:center;gap:10px;text-transform:uppercase}.GamePage .TotalWinnings span{font-size:18px;font-weight:700}.GamePage .NextDraw{color:#00958f;font-size:24px;font-weight:600;margin:0 auto;text-align:center;text-transform:uppercase;display:flex;justify-content:center;align-items:center;flex-direction:column}.GamePage .NextDraw .BannerText{font-weight:400;font-size:18px;text-transform:uppercase;padding:0;margin:15px 0 0 0}.GamePage .NextDraw .BannerCountdown{font-size:22px;color:#00958f;display:flex;gap:20px}.GamePage .Tabs{display:flex;justify-content:center;gap:10px}.GamePage .Tabs .TabButton{border-radius:4px;cursor:pointer;padding:8px 0;width:50%;max-width:200px;border:1px solid #00958f;background:#00958f;color:#fff;font-size:12px;transition:all 0.2s linear;text-transform:uppercase;text-align:center;letter-spacing:0}.GamePage .Tabs .TabButton.Active{color:#00958f;background:#F1F1F1;border:1px solid #F1F1F1}.LastDrawResultsTitle{color:#009993;padding:25px 0 10px 0;text-align:center;border-radius:4px;text-transform:uppercase;font-size:16px;font-weight:600;margin:0}.NextDrawWrapper{padding:10px 15px;background:#F1F1F1;background:linear-gradient(0deg, #f1f1f1 0%, rgba(253, 187, 45, 0) 100%)}.NextDrawWrapper .BannerText{font-size:16px;font-weight:700;text-align:center}.NextDrawWrapper .BannerCountdown{font-size:22px;display:flex;gap:8px;color:#009993;font-weight:bolder;justify-content:center}.GamePageContent{padding:15px;max-width:1200px;margin:0 auto}.GameDetails{padding-bottom:10px;margin-bottom:20px}.CreateNewTicket{background:#004D4A;height:100px;width:100%;display:flex;margin-top:10px;flex-direction:column;justify-content:center;align-items:center}.CreateNewTicket button{cursor:pointer;display:inline-block;border-radius:50%;width:40px;height:40px;margin:5px;border:1px solid #FFF;background:#FFF;color:#004D4A;font-size:12px;transition:all 0.2s linear;text-transform:uppercase;text-align:center;letter-spacing:0}.CreateNewTicket button:hover{background:#F1F1F1}.CreateNewTicket span{display:inline-block;font-size:12px;text-align:center;margin:0 auto;color:#FFF}.OrderSummary{min-width:200px;border-radius:4px;display:flex;flex-direction:column;justify-content:center;margin-top:20px;background:#fff}.OrderSummary .OrderSummaryTitle{font-size:16px;color:#009993;text-transform:uppercase;text-align:center}.OrderSummary .Ticket{display:inline-block;color:#000;font-size:14px;height:50px;border-bottom:solid 1px #D4D4D4;line-height:50px}.OrderSummary .Ticket span{text-align:right}.OrderSummary .Total{display:inline-block;color:#000;font-size:14px;height:50px;line-height:50px}.OrderSummary .Total span{text-align:right}.ButtonWrapper{display:flex;align-items:center;justify-content:center}.ButtonWrapper .Button{cursor:pointer;border-radius:4px;padding:8px 60px;width:max-content;margin:5px;font-size:12px;transition:all 0.2s linear;text-transform:uppercase;text-align:center;letter-spacing:0;background:#009993;border:1px solid #009993;color:#FFF}.ButtonWrapper .Button:hover{background:#00ABA4}.ButtonWrapper .Button.ButtonDisabled{pointer-events:none;background:#ccc;border:1px solid #ccc}.SubmitModalSuccess{text-align:center;font-size:18px;padding:20px}.DeleteTicketModalWrapper{padding:20px;text-align:center}.DeleteTicketModalWrapper .DeleteTicketModalTitle{font-size:16px;color:#00958f;font-weight:400;text-transform:uppercase;margin:20px 0 40px}.DeleteTicketModalWrapper .DeleteTicketModalText{font-size:14px;color:#000;line-height:22px;margin-bottom:40px}.DeleteTicketModalWrapper .DeleteTicketModalButtons{display:flex;gap:10px;justify-content:center}.DeleteTicketModalWrapper .DeleteTicketModalButtons .DeleteTicketModalConfirm{cursor:pointer;border-radius:4px;padding:8px 25px;width:max-content;margin:5px;color:#000;font-size:12px;transition:all 0.2s linear;text-transform:uppercase;text-align:center;letter-spacing:0;background:#FF3D00;border:1px solid #FF3D00;color:#FFF}.DeleteTicketModalWrapper .DeleteTicketModalButtons .DeleteTicketModalConfirm:hover{background:#FF6536;border:1px solid #FF3D00}.DeleteTicketModalWrapper .DeleteTicketModalButtons .DeleteTicketModalCancel{cursor:pointer;width:max-content;border-radius:4px;padding:10px 25px;margin:5px;border:1px solid #00958f;background:#FFF;color:#000;font-size:12px;transition:all 0.2s linear;text-transform:uppercase;text-align:center;letter-spacing:0}.DeleteTicketModalWrapper .DeleteTicketModalButtons .DeleteTicketModalCancel:hover{background:#F1F1F1}@media (min-width: 1200px){.GamePageContent .TicketsWrapper{float:left;width:49%}.GamePageContent .GameDetails{float:right;width:49%}.GamePageContent .OrderSummary{float:right;width:49%}}";
118
-
119
- const LotteryGamePage = class {
120
- constructor(hostRef) {
121
- registerInstance(this, hostRef);
122
- /**
123
- * Language of the widget
124
- */
125
- this.language = 'en';
126
- /**
127
- * Shows the auto-pick button
128
- */
129
- this.autoPick = false;
130
- /**
131
- * Shows the reset button
132
- */
133
- this.resetButton = false;
134
- /**
135
- * Client custom styling via string
136
- */
137
- this.clientStyling = '';
138
- /**
139
- * Client custom styling via url
140
- */
141
- this.clientStylingurl = '';
142
- this.clientStylingUrlContent = '';
143
- this.tickets = [];
144
- this.tabIndex = 0;
145
- this.hasErrors = false;
146
- this.totalAmount = 0;
147
- this.successVisible = false;
148
- this.deleteVisible = false;
149
- this.latestDraw = {};
150
- this.totalWinningsAmount = 0;
151
- this.isLoggedIn = false;
152
- this.loginModalVisible = false;
153
- this.limitStylingAppends = false;
154
- // @TODO fix any type
155
- this.userAgent = window.navigator.userAgent;
156
- this.multiplier = false;
157
- this.quickPick = false;
158
- this.setClientStyling = () => {
159
- let sheet = document.createElement('style');
160
- sheet.innerHTML = this.clientStyling;
161
- this.stylingContainer.prepend(sheet);
162
- };
163
- this.setClientStylingURL = () => {
164
- let url = new URL(this.clientStylingurl);
165
- let cssFile = document.createElement('style');
166
- fetch(url.href)
167
- .then((res) => res.text())
168
- .then((data) => {
169
- this.clientStylingUrlContent = data;
170
- cssFile.innerHTML = data;
171
- setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
172
- })
173
- .catch((err) => {
174
- console.log('error ', err);
175
- });
176
- };
177
- }
178
- // @TODO fix `any` type later, I'm lazy now
179
- handleSessionIdValue() {
180
- this.isLoggedIn = true;
181
- }
182
- connectedCallback() {
183
- this.getGameDetails();
184
- this.getDraws();
185
- if (this.sessionId) {
186
- this.isLoggedIn = true;
187
- }
188
- }
189
- componentDidRender() {
190
- // start custom styling area
191
- if (!this.limitStylingAppends && this.stylingContainer) {
192
- if (this.clientStyling)
193
- this.setClientStyling();
194
- if (this.clientStylingurl)
195
- this.setClientStylingURL();
196
- this.limitStylingAppends = true;
197
- }
198
- // end custom styling area
199
- }
200
- countdownLogic(date) {
201
- if (date) {
202
- this.interval = setInterval(() => {
203
- this.daysRemaining = Math.floor((Date.parse(date) - new Date().getTime()) / (1000 * 60 * 60 * 24));
204
- this.hoursRemaining = Math.floor((Date.parse(date) - new Date().getTime()) / (1000 * 60 * 60) - this.daysRemaining * 24);
205
- this.minutesRemaining = Math.floor((Date.parse(date) - new Date().getTime()) / (1000 * 60) - this.daysRemaining * 24 * 60 - this.hoursRemaining * 60);
206
- this.secondsRemaining = Math.floor((Date.parse(date) - new Date().getTime()) / 1000 - this.daysRemaining * 24 * 60 * 60 - this.hoursRemaining * 60 * 60 - this.minutesRemaining * 60);
207
- }, 1000);
208
- }
209
- }
210
- disconnectedCallback() {
211
- clearInterval(this.interval);
212
- }
213
- getGameDetails() {
214
- let url = new URL(`${this.endpoint}/games/${this.gameId}`);
215
- fetch(url.href)
216
- .then((res) => {
217
- if (res.status >= 300) {
218
- this.hasErrors = true;
219
- throw new Error('There was an error while fetching the data');
220
- }
221
- return res.json();
222
- })
223
- .then((data) => {
224
- this.gameData = data;
225
- this.basicStake = this.gameData.rules.stakes[0].amount;
226
- let draws = this.gameData.draws.filter((item) => !item.winningNumbers);
227
- this.nextDraw = draws[0].id;
228
- this.createNewTicket();
229
- })
230
- .catch((err) => {
231
- this.hasErrors = true;
232
- console.log('Error', err);
233
- });
234
- }
235
- calculateTotalAmount() {
236
- const { currency } = this.gameData.rules.stakes[0];
237
- this.totalAmount = 0;
238
- this.tickets.forEach((item) => {
239
- if (item.completed) {
240
- this.totalAmount += item.amount * item.stake;
241
- }
242
- });
243
- this.currency = currency;
244
- }
245
- // @TODO CustomEvent type
246
- gridFilledHandler(event) {
247
- // @TODO item ts
248
- this.tickets = this.tickets.map((item) => {
249
- if (item.ticketId == event.detail.id) {
250
- let arr = item.selectedNumbers || [];
251
- arr[event.detail.index] = event.detail.selectedNumbers.map((item) => parseInt(item, 10));
252
- return {
253
- gameId: item.gameId,
254
- ticketId: item.ticketId,
255
- completed: true,
256
- amount: event.detail.draws,
257
- stake: item.stake,
258
- selectedNumbers: arr
259
- };
260
- }
261
- return item;
262
- });
263
- this.calculateTotalAmount();
264
- }
265
- // @TODO fix any type
266
- gridDirtyHandler(event) {
267
- // @TODO item ts
268
- this.tickets = this.tickets.map((item) => {
269
- if (item.gameId == event.detail.id) {
270
- return {
271
- gameId: item.gameId,
272
- ticketId: item.ticketId,
273
- completed: false,
274
- amount: item.amount,
275
- stake: item.stake,
276
- grids: []
277
- };
278
- }
279
- return item;
280
- });
281
- }
282
- // @TODO CustomEvent type
283
- deleteTicketHandler(event) {
284
- this.deleteVisible = true;
285
- this.deleteEventData = event;
286
- }
287
- modalCloseEvent() {
288
- this.deleteVisible = false;
289
- this.loginModalVisible = false;
290
- }
291
- stakeChangeHandler(event) {
292
- const { ticketId, stake } = event.detail;
293
- this.tickets[ticketId - 1].stake = stake;
294
- this.calculateTotalAmount();
295
- }
296
- multiplierChangeHandler(event) {
297
- this.multiplier = event.detail;
298
- }
299
- getDraws() {
300
- // append from query param with the current date value in order to get the next draw
301
- let url = new URL(`${this.endpoint}/games/${this.gameId}/draws`);
302
- let drawOptions = {
303
- method: "GET",
304
- headers: {
305
- 'Content-Type': "application/json",
306
- 'Accept': 'application/json',
307
- },
308
- };
309
- fetch(url.href, drawOptions)
310
- .then((response) => {
311
- return response.json();
312
- })
313
- .then((data) => {
314
- var _a, _b;
315
- let upcoming = data.items.filter((item) => {
316
- if (Date.parse(item.date) > new Date().getTime()) {
317
- return !item.winningNumbers;
318
- }
319
- });
320
- let past = data.items.filter((item) => item.winningNumbers);
321
- this.latestDraw = upcoming[0] || {};
322
- this.nextDate = (_a = this.latestDraw) === null || _a === void 0 ? void 0 : _a.date;
323
- this.countdownLogic(this.nextDate || '');
324
- this.lastDrawId = past[past.length - 1].id;
325
- // calculate total winnings
326
- // @TODO fix any type
327
- (_b = this.latestDraw) === null || _b === void 0 ? void 0 : _b.prizes.forEach((element) => {
328
- this.totalWinningsAmount += JSON.parse(element.amount);
329
- });
330
- })
331
- .catch((err) => {
332
- console.log('error ', err);
333
- });
334
- }
335
- ;
336
- // @TODO fix any type
337
- confirmDeleteTicketHandler(event) {
338
- // @TODO fix any type
339
- this.tickets = this.tickets.filter((item) => {
340
- if (item.ticketId == event.detail.ticketId) {
341
- return false;
342
- }
343
- return true;
344
- });
345
- this.calculateTotalAmount();
346
- this.deleteVisible = false;
347
- }
348
- createNewTicket() {
349
- this.tickets = [
350
- ...this.tickets,
351
- { gameId: this.gameId, ticketId: this.tickets.length + 1, completed: false, amount: 1, stake: this.basicStake, grids: [] }
352
- ];
353
- }
354
- showLoginModal() {
355
- this.loginModalVisible = true;
356
- }
357
- submitTickets() {
358
- let url = new URL(`${this.endpoint}/tickets`);
359
- // @TODO Body TS type
360
- let body = {
361
- gameId: this.gameId,
362
- tickets: []
363
- };
364
- this.tickets.forEach((item) => {
365
- body.tickets.push({
366
- startingDrawId: this.nextDraw,
367
- amount: item.stake,
368
- gameId: this.gameId,
369
- currency: this.currency,
370
- selection: item.selectedNumbers,
371
- multiplier: this.multiplier,
372
- drawCount: item.amount,
373
- quickPick: this.quickPick,
374
- });
375
- });
376
- // @TODO Options TS type
377
- let options = {
378
- method: 'POST',
379
- headers: {
380
- 'Content-Type': 'application/json',
381
- 'Accept': 'application/json',
382
- 'Authorization': `Bearer ${this.sessionId}`
383
- },
384
- body: JSON.stringify(body)
385
- };
386
- fetch(url.href, options)
387
- .then((res) => {
388
- if (res.status > 300) {
389
- throw new Error('err');
390
- }
391
- return res.json();
392
- })
393
- .then((data) => {
394
- console.log('data', data);
395
- })
396
- .catch((err) => {
397
- console.log('error ', err);
398
- });
399
- this.successVisible = true;
400
- }
401
- render() {
402
- const backgroundSrc = getAssetPath('./static/chrono_lottery_mobile.png');
403
- const backgroundDesktopSrc = getAssetPath('./static/chrono_desktop.png');
404
- if (this.hasErrors) {
405
- return (h("div", { class: "GamePage" }, h("div", { class: "Title" }, translate('error', this.language))));
406
- }
407
- return (
408
- /* Game details */
409
- h("div", { class: "GamePage", dir: this.language == 'ar' ? 'rtl' : 'ltr', ref: el => this.stylingContainer = el }, h("div", { class: "GridBanner", style: { backgroundImage: isMobile(this.userAgent) ? `url(${backgroundSrc})` : `url(${backgroundDesktopSrc})` } }, h("div", { class: "BannerButtonsWrapper" }, h("button", { class: "BannerBackButton" }, h("span", { class: "BannerBackButtonArrow" }, "\u1438 "), translate('backButton', this.language)), h("button", { class: "BannerLobbyButton" }, translate('lobbyButton', this.language))), h("div", { class: "Tabs" }, h("div", { class: 'TabButton' + (this.tabIndex == 0 ? ' Active' : ''), onClick: () => this.tabIndex = 0 }, translate('buy', this.language)), h("div", { class: 'TabButton' + (this.tabIndex == 1 ? ' Active' : ''), onClick: () => this.tabIndex = 1 }, translate('viewLatest', this.language)))), h("div", { class: "NextDrawWrapper" }, h("div", { class: "TotalWinnings" }, translate('winUpTo', this.language), ": ", h("span", null, "$", this.totalWinningsAmount.toLocaleString('en-US', { maximumFractionDigits: 2 }))), h("div", { class: "NextDraw" }, h("p", { class: "BannerText" }, translate('nextDraw', this.language)), h("div", { class: "BannerCountdown" }, h("span", { class: "CountdownDays" }, this.daysRemaining, "D"), h("span", { class: "CountdownHours" }, this.hoursRemaining, "H"), h("span", { class: "CountdownMinutes" }, this.minutesRemaining, "M"), h("span", { class: "CountdownSeconds" }, this.secondsRemaining, "S")))), this.tabIndex == 0 &&
410
- h("div", { class: "GamePageContent" }, h("div", { class: "GameDetails" }, h("lottery-game-details", { "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent })), h("div", { class: "TicketsWrapper" }, this.tickets.map((item) => h("lottery-ticket-controller", { endpoint: this.endpoint, "ticket-id": item.ticketId, "game-id": item.gameId, collapsed: false, last: true, language: this.language, "auto-pick": this.autoPick, "reset-button": this.resetButton, "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent })), h("div", { class: "CreateNewTicket" }, h("button", { onClick: () => this.createNewTicket() }, "+"), h("span", null, translate('createTicket', this.language)))), h("div", { class: "OrderSummary" }, h("h3", { class: "OrderSummaryTitle" }, translate('orderSummaryTitle', this.language)), h("div", { class: "Ticket" }, translate('orderSummaryTickets', this.language), ": ", h("span", null, this.tickets.length)), h("div", { class: "Total" }, translate('orderSummaryTotal', this.language), ": ", h("span", null, this.totalAmount, " ", this.currency)), h("div", { class: "ButtonWrapper" }, this.isLoggedIn &&
411
- h("span", { class: "Button", onClick: () => this.submitTickets() }, translate('orderSummarySubmit', this.language)), !this.isLoggedIn &&
412
- h("div", null, h("span", { class: "Button", onClick: () => this.showLoginModal() }, translate('orderSummarySubmit', this.language)), h("helper-modal", { "title-modal": "Success", visible: this.loginModalVisible, "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent }, h("p", { class: "SubmitModalSuccess" }, translate('modalLogin', this.language))))))), this.tabIndex == 1 &&
413
- h("div", null, h("h4", { class: "LastDrawResultsTitle" }, translate('lastDrawResultsTitle', this.language)), h("lottery-draw-results", { endpoint: this.endpoint, "game-id": this.gameId, language: this.language, "draw-id": this.lastDrawId, "draw-mode": true, "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent }), h("lottery-draw-results-history", { endpoint: this.endpoint, "game-id": this.gameId, language: this.language, "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent })), h("helper-modal", { "title-modal": "Success", visible: this.successVisible, "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent }, h("p", { class: "SubmitModalSuccess" }, translate('modalSuccess', this.language))), h("helper-modal", { "title-modal": "Delete Ticket", visible: this.deleteVisible, "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent }, h("div", { class: "DeleteTicketModalWrapper" }, h("h3", { class: "DeleteTicketModalTitle" }, translate('deleteTicketModalTitle', this.language)), h("p", { class: "DeleteTicketModalText" }, translate('deleteTicketModalText', this.language)), h("div", { class: "DeleteTicketModalButtons" }, h("button", { class: "DeleteTicketModalCancel", onClick: () => this.modalCloseEvent() }, translate('deleteTicketModalCancel', this.language)), h("button", { class: "DeleteTicketModalConfirm", onClick: () => this.confirmDeleteTicketHandler(this.deleteEventData) }, translate('deleteTicketModalConfirm', this.language)))))));
414
- }
415
- static get assetsDirs() { return ["static"]; }
416
- get element() { return getElement(this); }
417
- static get watchers() { return {
418
- "sessionId": ["handleSessionIdValue"]
419
- }; }
420
- };
421
- LotteryGamePage.style = lotteryGamePageCss;
422
-
423
- export { LotteryGamePage as lottery_game_page };
@@ -1,112 +0,0 @@
1
- import { r as registerInstance, c as createEvent, h } from './index-d1baacd4.js';
2
-
3
- const DEFAULT_LANGUAGE = 'en';
4
- const SUPPORTED_LANGUAGES = ['ro', 'en'];
5
- const TRANSLATIONS = {
6
- en: {
7
- ticket: 'Ticket',
8
- },
9
- ro: {
10
- ticket: 'Bilet',
11
- },
12
- };
13
- const translate = (key, customLang) => {
14
- const lang = customLang;
15
- return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
16
- };
17
-
18
- const lotteryTicketControllerCss = ":host{display:block}";
19
-
20
- const LotteryTicketController = class {
21
- constructor(hostRef) {
22
- registerInstance(this, hostRef);
23
- this.deleteTicketEvent = createEvent(this, "deleteTicket", 7);
24
- /**
25
- * Endpoint URL for the source of data (NorWAy standard)
26
- */
27
- this.endpoint = '';
28
- /**
29
- * Ticket number
30
- */
31
- this.ticketId = 1;
32
- /**
33
- * Activates postMessages as events for actions from the widget
34
- */
35
- this.postMessage = false;
36
- /**
37
- * Name of the event emitter by the action button
38
- */
39
- this.eventName = 'deleteTicketAction';
40
- /**
41
- * Collapsed
42
- */
43
- this.collapsed = true;
44
- /**
45
- * Number of grids?
46
- */
47
- this.numberOfGrids = 1;
48
- /**
49
- * This toggles if the last ticket added should be expanded or not
50
- */
51
- this.last = false;
52
- /**
53
- * Language
54
- */
55
- this.language = 'en';
56
- /**
57
- * Shows the auto-pick button
58
- */
59
- this.autoPick = false;
60
- /**
61
- * Shows the reset button
62
- */
63
- this.resetButton = false;
64
- /**
65
- * Client custom styling via string
66
- */
67
- this.clientStyling = '';
68
- /**
69
- * Client custom styling via url content
70
- */
71
- this.clientStylingUrlContent = '';
72
- this.limitStylingAppends = false;
73
- this.setClientStyling = () => {
74
- let sheet = document.createElement('style');
75
- sheet.innerHTML = this.clientStyling;
76
- this.stylingContainer.prepend(sheet);
77
- };
78
- this.setClientStylingURL = () => {
79
- let cssFile = document.createElement('style');
80
- setTimeout(() => {
81
- cssFile.innerHTML = this.clientStylingUrlContent;
82
- this.stylingContainer.prepend(cssFile);
83
- }, 1);
84
- };
85
- }
86
- // @TODO fix the `any` type
87
- helperAccordionActionHandler() {
88
- if (this.postMessage) {
89
- window.postMessage({ type: this.eventName }, window.location.href);
90
- }
91
- this.deleteTicketEvent.emit({
92
- ticketId: this.ticketId
93
- });
94
- }
95
- componentDidRender() {
96
- // start custom styling area
97
- if (!this.limitStylingAppends && this.stylingContainer) {
98
- if (this.clientStyling)
99
- this.setClientStyling();
100
- if (this.clientStylingUrlContent)
101
- this.setClientStylingURL();
102
- this.limitStylingAppends = true;
103
- }
104
- // end custom styling area
105
- }
106
- render() {
107
- return (h("div", { class: "LotteryTicketControllerContainer", ref: el => this.stylingContainer = el }, h("helper-accordion", { "header-title": `${translate('ticket', this.language)} ${this.ticketId}`, "header-subtitle": this.ticketDescription, footer: true, "delete-tab": true, collapsed: !this.last || this.collapsed, language: this.language, "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent }, h("div", { slot: "accordionContent" }, h("lottery-ticket", { endpoint: this.endpoint, "game-id": this.gameId, "ticket-id": this.ticketId, "number-of-grids": this.numberOfGrids, language: this.language, "reset-button": this.resetButton, "auto-pick": this.autoPick, "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent })))));
108
- }
109
- };
110
- LotteryTicketController.style = lotteryTicketControllerCss;
111
-
112
- export { LotteryTicketController as lottery_ticket_controller };