@everymatrix/lottery-oddsbom-ticket-bet 0.0.1

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 (76) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/index-b8e9c8e4.js +1327 -0
  3. package/dist/cjs/index.cjs.js +10 -0
  4. package/dist/cjs/loader.cjs.js +15 -0
  5. package/dist/cjs/lottery-oddsbom-bullet_9.cjs.entry.js +1064 -0
  6. package/dist/cjs/lottery-oddsbom-ticket-bet-402dc005.js +10038 -0
  7. package/dist/cjs/lottery-oddsbom-ticket-bet.cjs.js +25 -0
  8. package/dist/collection/collection-manifest.json +36 -0
  9. package/dist/collection/components/lottery-oddsbom-oddschart/lottery-oddsbom-oddschart.css +221 -0
  10. package/dist/collection/components/lottery-oddsbom-oddschart/lottery-oddsbom-oddschart.js +609 -0
  11. package/dist/collection/components/lottery-oddsbom-oddschart-input/lottery-oddsbom-oddschart-input.css +40 -0
  12. package/dist/collection/components/lottery-oddsbom-oddschart-input/lottery-oddsbom-oddschart-input.js +213 -0
  13. package/dist/collection/components/lottery-oddsbom-ticket-bet/index.js +1 -0
  14. package/dist/collection/components/lottery-oddsbom-ticket-bet/lottery-oddsbom-ticket-bet.css +193 -0
  15. package/dist/collection/components/lottery-oddsbom-ticket-bet/lottery-oddsbom-ticket-bet.js +782 -0
  16. package/dist/collection/components/lottery-oddsbom-ticket-board/lottery-oddsbom-ticket-board.css +82 -0
  17. package/dist/collection/components/lottery-oddsbom-ticket-board/lottery-oddsbom-ticket-board.js +350 -0
  18. package/dist/collection/components/lottery-oddsbom-ticket-button/lottery-oddsbom-ticket-button.css +168 -0
  19. package/dist/collection/components/lottery-oddsbom-ticket-button/lottery-oddsbom-ticket-button.js +299 -0
  20. package/dist/collection/components/lottery-oddsbom-ticket-selection/lottery-oddsbom-ticket-selection.css +104 -0
  21. package/dist/collection/components/lottery-oddsbom-ticket-selection/lottery-oddsbom-ticket-selection.js +233 -0
  22. package/dist/collection/index.js +1 -0
  23. package/dist/collection/model/index.type.js +1 -0
  24. package/dist/collection/utils/api.js +10 -0
  25. package/dist/collection/utils/locale.utils.js +73 -0
  26. package/dist/collection/utils/utils.js +200 -0
  27. package/dist/esm/app-globals-0f993ce5.js +3 -0
  28. package/dist/esm/index-9dee9d86.js +1299 -0
  29. package/dist/esm/index.js +2 -0
  30. package/dist/esm/loader.js +11 -0
  31. package/dist/esm/lottery-oddsbom-bullet_9.entry.js +1053 -0
  32. package/dist/esm/lottery-oddsbom-ticket-bet-e46dbb50.js +10026 -0
  33. package/dist/esm/lottery-oddsbom-ticket-bet.js +20 -0
  34. package/dist/index.cjs.js +1 -0
  35. package/dist/index.js +1 -0
  36. package/dist/lottery-oddsbom-ticket-bet/app-globals-0f993ce5.js +1 -0
  37. package/dist/lottery-oddsbom-ticket-bet/index-9dee9d86.js +2 -0
  38. package/dist/lottery-oddsbom-ticket-bet/index.esm.js +1 -0
  39. package/dist/lottery-oddsbom-ticket-bet/lottery-oddsbom-bullet_9.entry.js +1 -0
  40. package/dist/lottery-oddsbom-ticket-bet/lottery-oddsbom-ticket-bet-e46dbb50.js +6657 -0
  41. package/dist/lottery-oddsbom-ticket-bet/lottery-oddsbom-ticket-bet.esm.js +1 -0
  42. package/dist/stencil.config.dev.js +19 -0
  43. package/dist/stencil.config.js +19 -0
  44. package/dist/storybook/main.js +43 -0
  45. package/dist/storybook/preview.js +9 -0
  46. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-ticket-bet/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
  47. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-ticket-bet/.stencil/packages/stencil/lottery-oddsbom-ticket-bet/stencil.config.d.ts +2 -0
  48. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-ticket-bet/.stencil/packages/stencil/lottery-oddsbom-ticket-bet/stencil.config.dev.d.ts +2 -0
  49. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-ticket-bet/.stencil/packages/stencil/lottery-oddsbom-ticket-bet/storybook/main.d.ts +3 -0
  50. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-ticket-bet/.stencil/packages/stencil/lottery-oddsbom-ticket-bet/storybook/preview.d.ts +70 -0
  51. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-ticket-bet/.stencil/tools/plugins/index.d.ts +4 -0
  52. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-ticket-bet/.stencil/tools/plugins/lazy-load-chunk-plugin.d.ts +12 -0
  53. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-ticket-bet/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
  54. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-ticket-bet/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
  55. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-ticket-bet/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
  56. package/dist/types/components/lottery-oddsbom-oddschart/lottery-oddsbom-oddschart.d.ts +51 -0
  57. package/dist/types/components/lottery-oddsbom-oddschart-input/lottery-oddsbom-oddschart-input.d.ts +21 -0
  58. package/dist/types/components/lottery-oddsbom-ticket-bet/index.d.ts +1 -0
  59. package/dist/types/components/lottery-oddsbom-ticket-bet/lottery-oddsbom-ticket-bet.d.ts +95 -0
  60. package/dist/types/components/lottery-oddsbom-ticket-board/lottery-oddsbom-ticket-board.d.ts +51 -0
  61. package/dist/types/components/lottery-oddsbom-ticket-button/lottery-oddsbom-ticket-button.d.ts +40 -0
  62. package/dist/types/components/lottery-oddsbom-ticket-selection/lottery-oddsbom-ticket-selection.d.ts +25 -0
  63. package/dist/types/components.d.ts +298 -0
  64. package/dist/types/index.d.ts +1 -0
  65. package/dist/types/model/index.type.d.ts +198 -0
  66. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  67. package/dist/types/utils/api.d.ts +6 -0
  68. package/dist/types/utils/locale.utils.d.ts +3 -0
  69. package/dist/types/utils/utils.d.ts +17 -0
  70. package/loader/cdn.js +1 -0
  71. package/loader/index.cjs.js +1 -0
  72. package/loader/index.d.ts +24 -0
  73. package/loader/index.es2017.js +1 -0
  74. package/loader/index.js +2 -0
  75. package/loader/package.json +11 -0
  76. package/package.json +27 -0
@@ -0,0 +1,782 @@
1
+ import { h } from "@stencil/core";
2
+ import { setClientStyling, setClientStylingURL, setStreamStyling } from "../../../../../../../../libs/common/src/styling/index";
3
+ import { fetchRequest, generateCombinations, formatDate, showNotification, toQueryParams, formatNumber, thousandSeparator } from "../../utils/utils";
4
+ import "../../../../../lottery-tipping-dialog/dist/types/index";
5
+ import { MAX_DISPLAY_OPTION_NUM } from "../../model/index.type";
6
+ import { isToday } from "date-fns";
7
+ import "../../../../../../../libs/vaadin-facade/index";
8
+ import { translate, resolveTranslationUrl } from "../../utils/locale.utils";
9
+ import { fetchSaleStatistics } from "../../utils/api";
10
+ export class LotteryOddsbomTicketBet {
11
+ constructor() {
12
+ this.onStakeChange = (e) => {
13
+ this.gameInfo = Object.assign(Object.assign({}, this.gameInfo), { stake: e.detail.value });
14
+ };
15
+ this.generateSelection = () => {
16
+ return this.ticketBoardInfo.map((item) => {
17
+ const addArr1 = item.addSelections[0].map((num) => String(num));
18
+ const arr1 = item.selections[0]
19
+ .filter((bullet) => bullet.isSelected)
20
+ .map((bullet) => String(bullet.text))
21
+ .concat(addArr1);
22
+ const addArr2 = item.addSelections[1].map((num) => String(num));
23
+ const arr2 = item.selections[1]
24
+ .filter((bullet) => bullet.isSelected)
25
+ .map((bullet) => String(bullet.text))
26
+ .concat(addArr2);
27
+ const combinations = generateCombinations(arr1, arr2);
28
+ return [[...combinations]];
29
+ });
30
+ };
31
+ this.endpoint = undefined;
32
+ this.endpointTicket = undefined;
33
+ this.endpointLotteryBe = undefined;
34
+ this.gameId = undefined;
35
+ this.sessionId = undefined;
36
+ this.drawId = undefined;
37
+ this.playerId = '';
38
+ this.mbSource = undefined;
39
+ this.clientStyling = undefined;
40
+ this.clientStylingUrl = undefined;
41
+ this.translationUrl = '';
42
+ this.language = 'en';
43
+ this.isLoading = false;
44
+ this.isLoadingOdds = false;
45
+ this.isSubmitLoading = false;
46
+ this.matchInfo = undefined;
47
+ this.ticketBoardInfo = [];
48
+ this.gameConfig = {
49
+ minScore: 0,
50
+ maxScore: 10,
51
+ minCount: 1,
52
+ maxCount: 10,
53
+ stopTime: '',
54
+ gameBackEndId: '',
55
+ stakes: [
56
+ {
57
+ label: '1',
58
+ value: '1'
59
+ }
60
+ ]
61
+ };
62
+ this.addSelectionConfig = {
63
+ needAddMoreBtn: false,
64
+ maxOverScore: 0,
65
+ maxScore: 0
66
+ };
67
+ this.gameInfo = {
68
+ stake: 1,
69
+ quickPick: 2,
70
+ lines: 0
71
+ };
72
+ this.dialogConfig = {
73
+ title: '',
74
+ visible: false
75
+ };
76
+ this.oddsData = {
77
+ highest: '',
78
+ lowest: '',
79
+ filterdOdds: '',
80
+ isSearching: false
81
+ };
82
+ this.oddsInfo = {
83
+ count: 0,
84
+ items: [],
85
+ total: 0
86
+ };
87
+ this.oddsQuery = {
88
+ limit: 10,
89
+ offset: 0,
90
+ ascending: true
91
+ };
92
+ this.saleStatisticsInfo = {};
93
+ }
94
+ handleClientStylingChange(newValue, oldValue) {
95
+ if (newValue != oldValue) {
96
+ setClientStyling(this.stylingContainer, this.clientStyling);
97
+ }
98
+ }
99
+ handleClientStylingUrlChange(newValue, oldValue) {
100
+ if (newValue != oldValue) {
101
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
102
+ }
103
+ }
104
+ handleMbSourceChange(newValue, oldValue) {
105
+ if (newValue != oldValue) {
106
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
107
+ }
108
+ }
109
+ componentWillLoad() {
110
+ if (this.translationUrl) {
111
+ resolveTranslationUrl(this.translationUrl);
112
+ }
113
+ this.initData();
114
+ }
115
+ async initData() {
116
+ await this.fetchGameData();
117
+ await this.fetchOddsData();
118
+ }
119
+ async fetchGameData() {
120
+ this.isLoading = true;
121
+ try {
122
+ await this.getGameConfig();
123
+ await this.getDrawEventData();
124
+ this.initTicketBoard();
125
+ }
126
+ catch (err) {
127
+ }
128
+ finally {
129
+ this.isLoading = false;
130
+ }
131
+ }
132
+ async fetchOddsData() {
133
+ this.isLoadingOdds = true;
134
+ try {
135
+ const res = await this.getOddsData({ ascending: true, limit: 10, offset: 0 });
136
+ this.oddsData.lowest = res.minItem.odds;
137
+ this.oddsData.highest = res.maxItem.odds;
138
+ this.oddsInfo = res;
139
+ }
140
+ catch (err) {
141
+ }
142
+ finally {
143
+ this.isLoadingOdds = false;
144
+ }
145
+ }
146
+ async componentDidLoad() {
147
+ if (this.stylingContainer) {
148
+ if (this.mbSource)
149
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
150
+ if (this.clientStyling)
151
+ setClientStyling(this.stylingContainer, this.clientStyling);
152
+ if (this.clientStylingUrl)
153
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
154
+ }
155
+ }
156
+ disconnectedCallback() {
157
+ this.stylingSubscription && this.stylingSubscription.unsubscribe();
158
+ }
159
+ get canSubmit() {
160
+ return this.ticketBoardInfo.every((ticket) => {
161
+ return ticket.selections.every((selection, idx) => {
162
+ return (selection.filter((bullet) => bullet.isSelected).length + ticket.addSelections[idx].length >=
163
+ this.gameConfig.minCount);
164
+ });
165
+ });
166
+ }
167
+ get oddsChartDialogWidth() {
168
+ var _a;
169
+ if (((_a = this.oddsInfo) === null || _a === void 0 ? void 0 : _a.total) == 0)
170
+ return '480px';
171
+ if (this.ticketBoardInfo.length <= 2)
172
+ return '360px';
173
+ else
174
+ return `${this.ticketBoardInfo.length * 180 + 48}px`;
175
+ }
176
+ formattedStopTime(stopTime) {
177
+ let _temp = '';
178
+ if (!stopTime) {
179
+ return _temp;
180
+ }
181
+ _temp = formatDate({ date: stopTime, format: 'dd/MM/yyyy HH:mm' });
182
+ if (isToday(new Date(stopTime))) {
183
+ _temp = formatDate({ date: stopTime, format: 'HH:mm' });
184
+ }
185
+ return _temp;
186
+ }
187
+ updateBulletDisabledState(ticketBoardInfo, matchIdx, selectionIdx, maxSelected) {
188
+ const targetMatch = ticketBoardInfo[matchIdx];
189
+ const targetSelection = targetMatch.selections[selectionIdx];
190
+ const targetAddSelection = targetMatch.addSelections[selectionIdx];
191
+ const selectedCount = targetSelection.filter((bullet) => bullet.isSelected).length + targetAddSelection.length;
192
+ const updatedSelection = targetSelection.map((bullet) => {
193
+ if (!bullet.isSelected) {
194
+ return Object.assign(Object.assign({}, bullet), { isDisabled: selectedCount === maxSelected });
195
+ }
196
+ return bullet;
197
+ });
198
+ ticketBoardInfo[matchIdx].selections[selectionIdx] = updatedSelection;
199
+ return ticketBoardInfo;
200
+ }
201
+ getMatchCombinationCount(match) {
202
+ const group1Selected = match.selections[0].filter((bullet) => bullet.isSelected).length;
203
+ const group1Add = match.addSelections[0].length;
204
+ const group1Total = group1Selected + group1Add;
205
+ const group2Selected = match.selections[1].filter((bullet) => bullet.isSelected).length;
206
+ const group2Add = match.addSelections[1].length;
207
+ const group2Total = group2Selected + group2Add;
208
+ return group1Total * group2Total;
209
+ }
210
+ calculateTotalLines() {
211
+ if (!this.canSubmit) {
212
+ return 0;
213
+ }
214
+ return this.ticketBoardInfo.reduce((total, match) => {
215
+ const matchCount = this.getMatchCombinationCount(match);
216
+ return total * matchCount;
217
+ }, 1);
218
+ }
219
+ updateLines() {
220
+ const newLines = this.calculateTotalLines();
221
+ this.gameInfo = Object.assign(Object.assign({}, this.gameInfo), { lines: newLines });
222
+ }
223
+ handleTicketBoardInfoChange() {
224
+ this.updateLines();
225
+ }
226
+ handleCanSubmitChange() {
227
+ this.updateLines();
228
+ }
229
+ initTicketBoard() {
230
+ const { minScore, maxScore } = this.gameConfig;
231
+ if (maxScore - minScore + 1 > MAX_DISPLAY_OPTION_NUM) {
232
+ this.addSelectionConfig.needAddMoreBtn = true;
233
+ this.addSelectionConfig.maxOverScore = minScore + MAX_DISPLAY_OPTION_NUM;
234
+ this.addSelectionConfig.maxScore = maxScore;
235
+ }
236
+ this.ticketBoardInfo = this.matchInfo.map((drawEvent) => {
237
+ return {
238
+ matchId: drawEvent.eventId,
239
+ matchName: drawEvent.eventName,
240
+ minScore: 0,
241
+ maxScore: 0,
242
+ selections: [[], []],
243
+ addSelections: [[], []]
244
+ };
245
+ });
246
+ this.ticketBoardInfo = this.ticketBoardInfo.map((ticketBoardItem) => {
247
+ let selection = new Array(maxScore - minScore + 1).fill(0).map((_, idx) => ({
248
+ text: idx + minScore,
249
+ idx,
250
+ isSelected: false,
251
+ isDisabled: false,
252
+ isAddMoreBtn: false
253
+ }));
254
+ if (this.addSelectionConfig.needAddMoreBtn) {
255
+ selection = selection.slice(0, MAX_DISPLAY_OPTION_NUM);
256
+ selection.push({
257
+ text: this.addSelectionConfig.maxOverScore,
258
+ idx: -1,
259
+ isSelected: false,
260
+ isDisabled: false,
261
+ isAddMoreBtn: true
262
+ });
263
+ }
264
+ return Object.assign(Object.assign({}, ticketBoardItem), { minScore,
265
+ maxScore, selections: [selection, selection] });
266
+ });
267
+ }
268
+ async getGameConfig() {
269
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
270
+ try {
271
+ const res = await fetchRequest(`${this.endpoint}/games/${this.gameId}`, 'GET');
272
+ this.rawGameConfig = res;
273
+ console.log('in getgameconfig', res, this.rawGameConfig);
274
+ const { minRow = 0, maxRow = 0 } = (_f = (_e = (_d = (_c = (_b = (_a = res === null || res === void 0 ? void 0 : res.rules) === null || _a === void 0 ? void 0 : _a.poolGame) === null || _b === void 0 ? void 0 : _b.outcomeRanges) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.bettingType) === null || _e === void 0 ? void 0 : _e[0]) !== null && _f !== void 0 ? _f : {};
275
+ const { minCount = 0, maxCount = 0 } = (_m = (_l = (_k = (_j = (_h = (_g = res === null || res === void 0 ? void 0 : res.rules) === null || _g === void 0 ? void 0 : _g.poolGame) === null || _h === void 0 ? void 0 : _h.outcomeRanges) === null || _j === void 0 ? void 0 : _j[0]) === null || _k === void 0 ? void 0 : _k.selectRule) === null || _l === void 0 ? void 0 : _l[0]) !== null && _m !== void 0 ? _m : {};
276
+ const minScore = minRow;
277
+ const maxScore = maxRow;
278
+ this.gameConfig = Object.assign(Object.assign({}, this.gameConfig), { minScore,
279
+ maxScore,
280
+ minCount,
281
+ maxCount, gameBackEndId: res.type });
282
+ this.gameConfig.stakes = res.rules.stakes.map((item) => {
283
+ return { value: item.value, label: item.value };
284
+ });
285
+ this.gameConfig.stopTime = res.currentDraw.wagerCloseTime;
286
+ this.dialogConfig.title = `${res.name} - ${translate('oddsChart', this.language)}`;
287
+ this.updateSaleStatistics();
288
+ }
289
+ catch (e) { }
290
+ }
291
+ async updateSaleStatistics() {
292
+ var _a;
293
+ this.saleStatisticsInfo = await fetchSaleStatistics({
294
+ endpoint: this.endpointLotteryBe,
295
+ gameId: (_a = this.rawGameConfig) === null || _a === void 0 ? void 0 : _a.type,
296
+ drawId: this.drawId
297
+ });
298
+ }
299
+ async getDrawEventData() {
300
+ try {
301
+ const res = await fetchRequest(`${this.endpoint}/games/${this.rawGameConfig.type}/draws/${this.drawId}/findDrawEvents`, 'GET');
302
+ this.matchInfo = res;
303
+ }
304
+ catch (e) { }
305
+ }
306
+ handleOddsBomBulletGroupToggle(event) {
307
+ const { bulletSelctionArr, matchIdx, selectionIdx } = event.detail;
308
+ let newTicketBoardInfo = [...this.ticketBoardInfo];
309
+ newTicketBoardInfo[matchIdx].selections[selectionIdx] = bulletSelctionArr;
310
+ newTicketBoardInfo = this.updateBulletDisabledState(newTicketBoardInfo, matchIdx, selectionIdx, this.gameConfig.maxCount);
311
+ this.ticketBoardInfo = [...newTicketBoardInfo];
312
+ }
313
+ handleOddsBomBulletAddedByMoreBtnDelete(event) {
314
+ const { delText, matchIdx, selectionIdx } = event.detail;
315
+ let newTicketBoardInfo = [...this.ticketBoardInfo];
316
+ newTicketBoardInfo[matchIdx].addSelections[selectionIdx] = newTicketBoardInfo[matchIdx].addSelections[selectionIdx].filter((item) => item !== delText);
317
+ newTicketBoardInfo = this.updateBulletDisabledState(newTicketBoardInfo, matchIdx, selectionIdx, this.gameConfig.maxCount);
318
+ this.ticketBoardInfo = [...newTicketBoardInfo];
319
+ }
320
+ handleOddsBomAddMoreToMatch(event) {
321
+ const { matchIdx, selectionIdx, value } = event.detail;
322
+ let newTicketBoardInfo = [...this.ticketBoardInfo];
323
+ const newAddSelections = [...newTicketBoardInfo[matchIdx].addSelections[selectionIdx], value].sort((a, b) => a - b);
324
+ newTicketBoardInfo[matchIdx].addSelections[selectionIdx] = newAddSelections;
325
+ newTicketBoardInfo = this.updateBulletDisabledState(newTicketBoardInfo, matchIdx, selectionIdx, this.gameConfig.maxCount);
326
+ this.ticketBoardInfo = [...newTicketBoardInfo];
327
+ }
328
+ handleOddsBomBoardClear() {
329
+ this.initTicketBoard();
330
+ }
331
+ handleOddsChartFillIn(event) {
332
+ const { fillInNums } = event.detail;
333
+ const match1FillInNums = fillInNums.map((item) => item.split(':')[0]).map((item) => Number(item));
334
+ const match2FillInNums = fillInNums.map((item) => item.split(':')[1]).map((item) => Number(item));
335
+ let newTicketBoardInfo = [...this.ticketBoardInfo];
336
+ newTicketBoardInfo = this.ticketBoardInfo.map((item, matchIdx) => {
337
+ let addSelction1 = [...item.addSelections[0]];
338
+ let addSelction2 = [...item.addSelections[1]];
339
+ if (match1FillInNums[matchIdx] >= this.addSelectionConfig.maxOverScore) {
340
+ addSelction1 = [...addSelction1, match1FillInNums[matchIdx]];
341
+ }
342
+ if (match2FillInNums[matchIdx] >= this.addSelectionConfig.maxOverScore) {
343
+ addSelction2 = [...addSelction2, match2FillInNums[matchIdx]];
344
+ }
345
+ return Object.assign(Object.assign({}, item), { selections: [
346
+ item.selections[0].map((bullet) => {
347
+ if (match1FillInNums[matchIdx] == Number(bullet.text)) {
348
+ return Object.assign(Object.assign({}, bullet), { isSelected: true });
349
+ }
350
+ return bullet;
351
+ }),
352
+ item.selections[1].map((bullet) => {
353
+ if (match2FillInNums[matchIdx] == Number(bullet.text)) {
354
+ return Object.assign(Object.assign({}, bullet), { isSelected: true });
355
+ }
356
+ return bullet;
357
+ })
358
+ ], addSelections: [addSelction1, addSelction2] });
359
+ });
360
+ this.ticketBoardInfo = [...newTicketBoardInfo];
361
+ }
362
+ async handleSubmit() {
363
+ var _a, _b, _c, _d;
364
+ const selection = this.generateSelection();
365
+ const body = {
366
+ playerId: this.playerId,
367
+ tickets: [
368
+ {
369
+ startingDrawId: (_b = (_a = this.rawGameConfig) === null || _a === void 0 ? void 0 : _a.currentDraw) === null || _b === void 0 ? void 0 : _b.id,
370
+ addon: false,
371
+ amount: String(Number(this.gameInfo.stake) * this.gameInfo.lines),
372
+ currency: this.rawGameConfig.rules.stakes[0].currency,
373
+ selection: [
374
+ {
375
+ poolGameSelections: selection,
376
+ multiplier: false,
377
+ quickPick: false,
378
+ betType: this.rawGameConfig.rules.poolGame.playTypes[0].betTypeId,
379
+ betName: this.rawGameConfig.rules.betTypes[0].name,
380
+ stake: Number(this.gameInfo.stake)
381
+ }
382
+ ],
383
+ multiplier: false,
384
+ multipierNum: 1,
385
+ quickPick: false,
386
+ gameName: this.rawGameConfig.name
387
+ }
388
+ ]
389
+ };
390
+ try {
391
+ this.isSubmitLoading = true;
392
+ const res = await fetchRequest(`${this.endpointTicket}/tickets`, 'POST', body, {
393
+ Authorization: `Bearer ${this.sessionId}`
394
+ });
395
+ if (res.state === 'Error') {
396
+ showNotification({ message: (_d = (_c = res === null || res === void 0 ? void 0 : res.errorDetail) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : 'Fail to purchase ticket.', theme: 'error' });
397
+ }
398
+ else {
399
+ showNotification({ message: translate('ticketSuccess', this.language), theme: 'success' });
400
+ this.updateSaleStatistics();
401
+ }
402
+ this.initTicketBoard();
403
+ }
404
+ catch (e) {
405
+ console.log(e);
406
+ showNotification({ message: e.message, theme: 'error' });
407
+ }
408
+ finally {
409
+ this.isSubmitLoading = false;
410
+ }
411
+ }
412
+ async getOddsData(query) {
413
+ try {
414
+ const { drawId } = this;
415
+ const params = Object.assign({ gameId: this.rawGameConfig.type, drawId }, query);
416
+ return await fetchRequest(`${this.endpointLotteryBe}/api/v1/lottery/core/widget/poolgame/statistic/realtime/odds${toQueryParams(params)}`, 'GET');
417
+ }
418
+ catch (_a) { }
419
+ }
420
+ handleOpenOddsChart() {
421
+ this.dialogConfig = Object.assign(Object.assign({}, this.dialogConfig), { visible: true });
422
+ setTimeout(() => {
423
+ if (this.childRef) {
424
+ this.childRef.initOddsChart();
425
+ }
426
+ else {
427
+ console.warn('childRef is not defined');
428
+ }
429
+ }, 0);
430
+ }
431
+ handleCloseOddsChart() {
432
+ var _a;
433
+ this.dialogConfig = Object.assign(Object.assign({}, this.dialogConfig), { visible: false });
434
+ (_a = this.childRef) === null || _a === void 0 ? void 0 : _a.closeOddsChart();
435
+ this.oddsQuery = Object.assign(Object.assign({}, this.oddsQuery), { limit: 10, offset: 0, ascending: true });
436
+ }
437
+ async handleOddsQueryChange(e) {
438
+ this.isLoadingOdds = true;
439
+ try {
440
+ const curOddsQuery = e.detail;
441
+ this.oddsQuery = Object.assign(Object.assign({}, this.oddsQuery), curOddsQuery);
442
+ this.oddsInfo = await this.getOddsData(this.oddsQuery);
443
+ }
444
+ catch (error) {
445
+ console.error('Failed to fetch odds data:', error);
446
+ }
447
+ finally {
448
+ this.isLoadingOdds = false;
449
+ }
450
+ }
451
+ async handleOddsQueryLineChange(e) {
452
+ var _a, _b;
453
+ this.oddsData = Object.assign(Object.assign({}, this.oddsData), { isSearching: true });
454
+ try {
455
+ const curOddsQuery = e.detail;
456
+ this.oddsQuery = Object.assign(Object.assign({}, this.oddsQuery), curOddsQuery);
457
+ const res = await this.getOddsData(this.oddsQuery);
458
+ this.oddsData.filterdOdds = (_b = (_a = res === null || res === void 0 ? void 0 : res.items) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.odds;
459
+ }
460
+ catch (error) {
461
+ console.error('Failed to fetch odds data:', error);
462
+ }
463
+ finally {
464
+ this.oddsData = Object.assign(Object.assign({}, this.oddsData), { isSearching: false });
465
+ }
466
+ }
467
+ get formattedTurnover() {
468
+ var _a, _b;
469
+ const turnover = (_b = (_a = this.saleStatisticsInfo) === null || _a === void 0 ? void 0 : _a.wagerSegment) === null || _b === void 0 ? void 0 : _b.totalSalesCrossDraw;
470
+ if (turnover === null || turnover === undefined)
471
+ return '';
472
+ const unit = '€';
473
+ return `${unit}${turnover ? thousandSeparator(turnover) : 0}`;
474
+ }
475
+ render() {
476
+ var _a, _b, _c;
477
+ return (h("div", { key: '5e1e0a6e065edc83f9882fb1d062a188c7ec1dfe', class: "oddsbomTicketBet", ref: (el) => (this.stylingContainer = el) }, h("div", { key: 'c8bb06895030f9a98eb569f4bb620865161c2a40', class: "oddsbomTicketBet-banner" }, h("div", { key: 'd94848f9e1bd44c9e48871987c1db6eb9c5036f7', class: "oddsbomTicketBet-banner-title" }, (_a = this.rawGameConfig) === null || _a === void 0 ? void 0 : _a.name), h("div", { key: '0bd4f3ce88e6eb47f0954a699e5b906e0d063140', class: "oddsbomTicketBet-banner-info" }, h("div", { key: '8861fe255797345be626da811ac3c4b012ec7ebd', class: "oddsbomTicketBet-banner-info-stoptime" }, h("span", { key: '093a9080139aea482c6f062440d8c59abc5e7426', style: { fontWeight: 'bold', marginRight: '5px' } }, translate('stopAt', this.language)), h("span", { key: '732790eb3aff1a4ffb3806d1b16859671ef110ad' }, this.formattedStopTime(this.gameConfig.stopTime))), h("div", { key: '39e62a18b9644c23c94df03c45402735dbad2ef9', class: "oddsbomTicketBet-banner-info-turnover" }, h("span", { key: '14c92633246651198d463419f0277a7955702ca6', style: { fontWeight: 'bold', marginRight: '5px' } }, translate('turnover', this.language)), h("span", { key: '9620ae1b0c081c982ea258bf995a255033b2fab4' }, this.formattedTurnover)))), h("div", { key: '81f6d0bbaa6e96e518d367f2e6ea35fd79f428dd', class: "oddsbomTicketBet-content" }, h("div", { key: 'd6afe1f75bf31fa00811e8a12bb1594b9b570962', class: "oddsbomTicketBet-info" }, h("div", { key: 'dac6c5e2d22e993ea5bf98ad51c57c4954e9a4ba', class: "oddsbomTicketBet-info-game" }, h("div", { key: 'a9263b1a50e71a5eb87d828a676f7bd4cd95cffb', class: "oddsbomTicketBet-info--item" }, h("div", { key: '60dcbef471ec43662e87c716f54f7c4028753ae1', class: "oddsbomTicketBet-info--key" }, translate('stakePerLine', this.language)), h("div", { key: '5940e25e8f6735f4425a7ed37966023d8293b24c', class: "oddsbomTicketBet-info--value" }, h("vaadin-select", { key: '102066bc4db5b93a96258f1dc9365f4b1014c022', items: this.gameConfig.stakes, value: this.gameInfo.stake, "on-value-changed": this.onStakeChange.bind(this), "no-vertical-overlap": true, noVerticalOverlap: true })))), h("div", { key: '0bb1ef8c4a4a83a32d768f116f31abda1d2fd5f9', class: "oddsbomTicketBet-info-odds" }, h("div", { key: 'bc9ac4b4d8dfae301f1adcc175e5f6454c597545', class: "oddsbomTicketBet-info--item" }, h("div", { key: '328984e6e06eb394723cfb7367e6fe9d537a059c', class: "oddsbomTicketBet-info--key" }, translate('lowestOdds', this.language)), h("div", { key: '7608a59d710c0277f899596d93958833a29ec35f', class: "oddsbomTicketBet-info--value" }, !this.oddsData.lowest ? '-' : formatNumber(this.oddsData.lowest))), h("div", { key: 'ad834be654d4c9903c95d93712a4da8c78e1d9a7', class: "oddsbomTicketBet-info--item" }, h("div", { key: 'af4248fc5b8366ce124e0c37a826e5ff95bdc88d', class: "oddsbomTicketBet-info--key" }, translate('highestOdds', this.language)), h("div", { key: '5b0fb67de3cf85c0f8feb25f6f6b7d8fcad94b37', class: "oddsbomTicketBet-info--value" }, !this.oddsData.highest ? '-' : formatNumber(this.oddsData.highest))), h("div", { key: 'c67e7fce75e8001becbb30a48d15e6c3ef2f1233', class: "oddsbomTicketBet-info---chart" }, h("lottery-oddsbom-ticket-button", { key: 'd7908a92bad58fb68d7415a8781d19deebe1c241', onClick: this.handleOpenOddsChart.bind(this), text: translate('oddsChart', this.language), variant: "outline", language: this.language, "translation-url": this.translationUrl, "client-styling": this.clientStyling, "client-styling-Url": this.clientStylingUrl })))), h("div", { key: '5a566925de5c1a208d794ca75989a2377edbc858', class: "oddsbomTicketBet-ticketArea" }, h("div", { key: '5e627a176e5698645ab6e17e36c89238fcee71bc', class: "oddsbomTicketBet-ticketArea--left" }, this.isLoading ? (h("div", { class: "loading-wrap" }, h("div", { class: "skeleton-content" }, h("div", { class: "skeleton-item skeleton-animated", style: { height: '32px', width: '94%' } }), h("div", { class: "skeleton-item skeleton-animated", style: { height: '32px', width: '94%' } }), h("div", { class: "skeleton-item skeleton-animated", style: { height: '32px', width: '94%' } }), h("div", { class: "skeleton-item skeleton-animated", style: { height: '32px', width: '94%' } }), h("div", { class: "skeleton-item skeleton-animated", style: { height: '32px', width: '94%' } }), h("div", { class: "skeleton-item skeleton-animated", style: { height: '32px', width: '94%' } }), h("div", { class: "skeleton-item skeleton-animated", style: { height: '32px', width: '94%' } })))) : (h("div", null, h("lottery-oddsbom-ticket-board", { ticketBoardInfo: this.ticketBoardInfo, addSelectionConfig: this.addSelectionConfig, language: this.language, "translation-url": this.translationUrl, "client-styling": this.clientStyling, "client-styling-Url": this.clientStylingUrl })))), h("div", { key: 'ae5e743cdbf5e3d6d0437c52b404bb55e478255e', class: "oddsbomTicketBet-ticketArea--right" }, h("div", { key: 'a1da1765b2aa53eb6d36a35b6c27f7d6eb0e2ab6', class: "oddsbomTicketBet-ticketArea--right-title" }, translate('orderSummary', this.language)), h("div", { key: '0adebc04e81f44067aff4be255b80b91a78a8ae0', class: "oddsbomTicketBet-ticketArea--right-info" }, h("div", { key: '6c3413fc1ee102bd71511468b33d5a0ff992b21b', class: "oddsbomTicketBet-ticketArea--right-ticketCount" }, `${translate('ticket', this.language)}: ${this.gameInfo.lines} ${translate('lines', this.language)} x ${this.gameInfo.stake} ${translate('euro', this.language)}`, ' '), h("div", { key: '34e8024ad809bed294cb581a60607652e6e32fa4', class: "oddsbomTicketBet-ticketArea--right-delimiter" }), h("div", { key: 'ea341ebbd0346a3c0c35ffd6e6e0d4abd9a3fdca', class: "oddsbomTicketBet-ticketArea--right-ticketTotal" }, `${translate('total', this.language)}: ${Number(this.gameInfo.stake) * this.gameInfo.lines} ${translate('euro', this.language)}`), h("div", { key: 'aad84df2f809a9d4a78e1ed1c1d3e5c198267b33', class: "oddsbomTicketBet-ticketArea--right-selection" }, h("lottery-oddsbom-ticket-selection", { key: '48f37706b402c330d64df8e706be59463271319e', ticketBoardInfo: this.ticketBoardInfo, language: this.language }))), h("div", { key: '686c35333a26ec749a809842b7ee22d2f4e27550', class: "oddsbomTicketBet-ticketArea--right-submitBtn" }, h("lottery-oddsbom-ticket-button", { key: 'ea2054dbdc6a5afbe6a0f7e992721453434e4d7f', text: translate('submit', this.language), variant: "primary", size: "large", disabled: !this.canSubmit, loading: this.isSubmitLoading, onClick: this.handleSubmit.bind(this), language: this.language, "translation-url": this.translationUrl, "client-styling": this.clientStyling, "client-styling-Url": this.clientStylingUrl }))))), h("lottery-tipping-dialog", { key: '2dc1050509a5b4a272a0eca9bc276b3e970c22c7', dialogTitle: this.dialogConfig.title, visible: this.dialogConfig.visible, onCancel: this.handleCloseOddsChart.bind(this), showFooter: false, width: this.oddsChartDialogWidth }, h("lottery-oddsbom-oddschart", { key: '7da6bacc7fb19e34ab5e04d7c41f1ee5d2c987eb', ref: (el) => (this.childRef = el), matchInfo: this.matchInfo, oddsInfo: (_b = this.oddsInfo) === null || _b === void 0 ? void 0 : _b.items, curPage: this.oddsQuery.offset / this.oddsQuery.limit, total: (_c = this.oddsInfo) === null || _c === void 0 ? void 0 : _c.total, limit: this.oddsQuery.limit, offset: this.oddsQuery.offset, isLoading: this.isLoadingOdds, isSearching: this.oddsData.isSearching, filterdOdds: this.oddsData.filterdOdds, language: this.language, "translation-url": this.translationUrl, "client-styling": this.clientStyling, "client-styling-Url": this.clientStylingUrl }))));
478
+ }
479
+ static get is() { return "lottery-oddsbom-ticket-bet"; }
480
+ static get encapsulation() { return "shadow"; }
481
+ static get originalStyleUrls() {
482
+ return {
483
+ "$": ["lottery-oddsbom-ticket-bet.scss"]
484
+ };
485
+ }
486
+ static get styleUrls() {
487
+ return {
488
+ "$": ["lottery-oddsbom-ticket-bet.css"]
489
+ };
490
+ }
491
+ static get properties() {
492
+ return {
493
+ "endpoint": {
494
+ "type": "string",
495
+ "mutable": false,
496
+ "complexType": {
497
+ "original": "string",
498
+ "resolved": "string",
499
+ "references": {}
500
+ },
501
+ "required": false,
502
+ "optional": false,
503
+ "docs": {
504
+ "tags": [],
505
+ "text": ""
506
+ },
507
+ "attribute": "endpoint",
508
+ "reflect": true
509
+ },
510
+ "endpointTicket": {
511
+ "type": "string",
512
+ "mutable": false,
513
+ "complexType": {
514
+ "original": "string",
515
+ "resolved": "string",
516
+ "references": {}
517
+ },
518
+ "required": false,
519
+ "optional": false,
520
+ "docs": {
521
+ "tags": [],
522
+ "text": ""
523
+ },
524
+ "attribute": "endpoint-ticket",
525
+ "reflect": true
526
+ },
527
+ "endpointLotteryBe": {
528
+ "type": "string",
529
+ "mutable": false,
530
+ "complexType": {
531
+ "original": "string",
532
+ "resolved": "string",
533
+ "references": {}
534
+ },
535
+ "required": false,
536
+ "optional": false,
537
+ "docs": {
538
+ "tags": [],
539
+ "text": ""
540
+ },
541
+ "attribute": "endpoint-lottery-be",
542
+ "reflect": true
543
+ },
544
+ "gameId": {
545
+ "type": "string",
546
+ "mutable": false,
547
+ "complexType": {
548
+ "original": "string",
549
+ "resolved": "string",
550
+ "references": {}
551
+ },
552
+ "required": false,
553
+ "optional": false,
554
+ "docs": {
555
+ "tags": [],
556
+ "text": ""
557
+ },
558
+ "attribute": "game-id",
559
+ "reflect": true
560
+ },
561
+ "sessionId": {
562
+ "type": "string",
563
+ "mutable": false,
564
+ "complexType": {
565
+ "original": "string",
566
+ "resolved": "string",
567
+ "references": {}
568
+ },
569
+ "required": false,
570
+ "optional": false,
571
+ "docs": {
572
+ "tags": [],
573
+ "text": ""
574
+ },
575
+ "attribute": "session-id",
576
+ "reflect": true
577
+ },
578
+ "drawId": {
579
+ "type": "string",
580
+ "mutable": false,
581
+ "complexType": {
582
+ "original": "string",
583
+ "resolved": "string",
584
+ "references": {}
585
+ },
586
+ "required": false,
587
+ "optional": false,
588
+ "docs": {
589
+ "tags": [],
590
+ "text": ""
591
+ },
592
+ "attribute": "draw-id",
593
+ "reflect": true
594
+ },
595
+ "playerId": {
596
+ "type": "string",
597
+ "mutable": false,
598
+ "complexType": {
599
+ "original": "string",
600
+ "resolved": "string",
601
+ "references": {}
602
+ },
603
+ "required": false,
604
+ "optional": false,
605
+ "docs": {
606
+ "tags": [],
607
+ "text": ""
608
+ },
609
+ "attribute": "player-id",
610
+ "reflect": true,
611
+ "defaultValue": "''"
612
+ },
613
+ "mbSource": {
614
+ "type": "string",
615
+ "mutable": false,
616
+ "complexType": {
617
+ "original": "string",
618
+ "resolved": "string",
619
+ "references": {}
620
+ },
621
+ "required": false,
622
+ "optional": false,
623
+ "docs": {
624
+ "tags": [],
625
+ "text": ""
626
+ },
627
+ "attribute": "mb-source",
628
+ "reflect": true
629
+ },
630
+ "clientStyling": {
631
+ "type": "string",
632
+ "mutable": false,
633
+ "complexType": {
634
+ "original": "string",
635
+ "resolved": "string",
636
+ "references": {}
637
+ },
638
+ "required": false,
639
+ "optional": false,
640
+ "docs": {
641
+ "tags": [],
642
+ "text": ""
643
+ },
644
+ "attribute": "client-styling",
645
+ "reflect": true
646
+ },
647
+ "clientStylingUrl": {
648
+ "type": "string",
649
+ "mutable": false,
650
+ "complexType": {
651
+ "original": "string",
652
+ "resolved": "string",
653
+ "references": {}
654
+ },
655
+ "required": false,
656
+ "optional": false,
657
+ "docs": {
658
+ "tags": [],
659
+ "text": ""
660
+ },
661
+ "attribute": "client-styling-url",
662
+ "reflect": true
663
+ },
664
+ "translationUrl": {
665
+ "type": "string",
666
+ "mutable": false,
667
+ "complexType": {
668
+ "original": "string",
669
+ "resolved": "string",
670
+ "references": {}
671
+ },
672
+ "required": false,
673
+ "optional": false,
674
+ "docs": {
675
+ "tags": [],
676
+ "text": ""
677
+ },
678
+ "attribute": "translation-url",
679
+ "reflect": true,
680
+ "defaultValue": "''"
681
+ },
682
+ "language": {
683
+ "type": "string",
684
+ "mutable": false,
685
+ "complexType": {
686
+ "original": "string",
687
+ "resolved": "string",
688
+ "references": {}
689
+ },
690
+ "required": false,
691
+ "optional": false,
692
+ "docs": {
693
+ "tags": [],
694
+ "text": ""
695
+ },
696
+ "attribute": "language",
697
+ "reflect": true,
698
+ "defaultValue": "'en'"
699
+ }
700
+ };
701
+ }
702
+ static get states() {
703
+ return {
704
+ "isLoading": {},
705
+ "isLoadingOdds": {},
706
+ "isSubmitLoading": {},
707
+ "matchInfo": {},
708
+ "ticketBoardInfo": {},
709
+ "gameConfig": {},
710
+ "addSelectionConfig": {},
711
+ "gameInfo": {},
712
+ "dialogConfig": {},
713
+ "oddsData": {},
714
+ "oddsInfo": {},
715
+ "oddsQuery": {},
716
+ "saleStatisticsInfo": {}
717
+ };
718
+ }
719
+ static get watchers() {
720
+ return [{
721
+ "propName": "clientStyling",
722
+ "methodName": "handleClientStylingChange"
723
+ }, {
724
+ "propName": "clientStylingUrl",
725
+ "methodName": "handleClientStylingUrlChange"
726
+ }, {
727
+ "propName": "mbSource",
728
+ "methodName": "handleMbSourceChange"
729
+ }, {
730
+ "propName": "ticketBoardInfo",
731
+ "methodName": "handleTicketBoardInfoChange"
732
+ }, {
733
+ "propName": "canSubmit",
734
+ "methodName": "handleCanSubmitChange"
735
+ }];
736
+ }
737
+ static get listeners() {
738
+ return [{
739
+ "name": "oddsbomBulletGroupToggle",
740
+ "method": "handleOddsBomBulletGroupToggle",
741
+ "target": undefined,
742
+ "capture": false,
743
+ "passive": false
744
+ }, {
745
+ "name": "oddsbomBulletGroupAddedByMoreBtnDel",
746
+ "method": "handleOddsBomBulletAddedByMoreBtnDelete",
747
+ "target": undefined,
748
+ "capture": false,
749
+ "passive": false
750
+ }, {
751
+ "name": "oddsbomAddMoreToMatch",
752
+ "method": "handleOddsBomAddMoreToMatch",
753
+ "target": undefined,
754
+ "capture": false,
755
+ "passive": false
756
+ }, {
757
+ "name": "oddsbomBoardClear",
758
+ "method": "handleOddsBomBoardClear",
759
+ "target": undefined,
760
+ "capture": false,
761
+ "passive": false
762
+ }, {
763
+ "name": "oddschartFillIn",
764
+ "method": "handleOddsChartFillIn",
765
+ "target": undefined,
766
+ "capture": false,
767
+ "passive": false
768
+ }, {
769
+ "name": "oddsQueryChange",
770
+ "method": "handleOddsQueryChange",
771
+ "target": undefined,
772
+ "capture": false,
773
+ "passive": false
774
+ }, {
775
+ "name": "oddsQueryLineChange",
776
+ "method": "handleOddsQueryLineChange",
777
+ "target": undefined,
778
+ "capture": false,
779
+ "passive": false
780
+ }];
781
+ }
782
+ }