@everymatrix/lottery-ticket-controller 0.1.6 → 0.1.20

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 (40) hide show
  1. package/dist/cjs/helper-accordion_5.cjs.entry.js +661 -0
  2. package/dist/cjs/{index-95915aab.js → index-dd94b8db.js} +17 -0
  3. package/dist/cjs/loader.cjs.js +2 -2
  4. package/dist/cjs/lottery-ticket-controller.cjs.js +2 -2
  5. package/dist/collection/collection-manifest.json +1 -7
  6. package/dist/collection/components/lottery-ticket-controller/lottery-ticket-controller.js +76 -4
  7. package/dist/collection/utils/locale.utils.js +14 -0
  8. package/dist/components/helper-accordion2.js +38 -4
  9. package/dist/components/lottery-bullet2.js +37 -3
  10. package/dist/components/lottery-grid2.js +43 -4
  11. package/dist/components/lottery-ticket-controller.js +52 -3
  12. package/dist/components/lottery-ticket2.js +0 -1
  13. package/dist/esm/helper-accordion_5.entry.js +653 -0
  14. package/dist/esm/{index-e3877ca0.js → index-74cef6d4.js} +17 -0
  15. package/dist/esm/loader.js +2 -2
  16. package/dist/esm/lottery-ticket-controller.js +2 -2
  17. package/dist/lottery-ticket-controller/lottery-ticket-controller.esm.js +1 -1
  18. package/dist/lottery-ticket-controller/p-72e48800.js +1 -0
  19. package/dist/lottery-ticket-controller/p-88036907.entry.js +1 -0
  20. package/dist/stencil.config.js +0 -3
  21. package/dist/types/components/lottery-ticket-controller/lottery-ticket-controller.d.ts +13 -0
  22. package/dist/types/components.d.ts +16 -0
  23. package/dist/types/utils/locale.utils.d.ts +1 -0
  24. package/package.json +6 -2
  25. package/dist/cjs/helper-accordion.cjs.entry.js +0 -92
  26. package/dist/cjs/lottery-bullet.cjs.entry.js +0 -41
  27. package/dist/cjs/lottery-grid.cjs.entry.js +0 -167
  28. package/dist/cjs/lottery-ticket-controller.cjs.entry.js +0 -69
  29. package/dist/cjs/lottery-ticket.cjs.entry.js +0 -169
  30. package/dist/esm/helper-accordion.entry.js +0 -88
  31. package/dist/esm/lottery-bullet.entry.js +0 -37
  32. package/dist/esm/lottery-grid.entry.js +0 -163
  33. package/dist/esm/lottery-ticket-controller.entry.js +0 -65
  34. package/dist/esm/lottery-ticket.entry.js +0 -165
  35. package/dist/lottery-ticket-controller/p-25f1639a.entry.js +0 -1
  36. package/dist/lottery-ticket-controller/p-3971b8e6.js +0 -1
  37. package/dist/lottery-ticket-controller/p-40d1058f.entry.js +0 -1
  38. package/dist/lottery-ticket-controller/p-dc525e6c.entry.js +0 -1
  39. package/dist/lottery-ticket-controller/p-f08b1b06.entry.js +0 -1
  40. package/dist/lottery-ticket-controller/p-f886ec7e.entry.js +0 -1
@@ -0,0 +1,653 @@
1
+ import { r as registerInstance, c as createEvent, h } from './index-74cef6d4.js';
2
+
3
+ const DEFAULT_LANGUAGE$2 = 'en';
4
+ const SUPPORTED_LANGUAGES$2 = ['ro', 'en'];
5
+ const TRANSLATIONS$2 = {
6
+ en: {
7
+ deleteTicket: 'Delete ticket'
8
+ },
9
+ ro: {
10
+ deleteTicket: 'Sterge biletul'
11
+ },
12
+ };
13
+ const translate$2 = (key, customLang) => {
14
+ const lang = customLang;
15
+ return TRANSLATIONS$2[lang !== undefined && SUPPORTED_LANGUAGES$2.includes(lang) ? lang : DEFAULT_LANGUAGE$2][key];
16
+ };
17
+
18
+ const helperAccordionCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}.Header{border-radius:5px;background:#009993;display:flex;gap:30px;border:1px solid #009993;padding:8px 10px;user-select:none;margin-bottom:1px}.Header:hover{background:#00ABA4}.Header .Title,.Header .Subtitle,.Header .Description{margin:0;font-size:14px;color:#fff;text-transform:capitalize}.Header .Expand{margin-left:auto;color:#FFF;width:17px;height:17px;cursor:pointer;text-align:center;transform:rotate(90deg);font-size:20px;user-select:none}.HeaderTicketHistory{border-radius:4px;background:#F1F1F1;display:flex;gap:30px;border:1px solid #009993;padding:8px 10px;user-select:none;margin-bottom:5px}.HeaderTicketHistory:hover{background:#00ABA4}.HeaderTicketHistory .Title,.HeaderTicketHistory .Subtitle,.HeaderTicketHistory .Description{margin:0;font-size:14px;color:#000}.HeaderTicketHistory .Expand{margin-left:auto;color:#FFF;width:17px;height:17px;cursor:pointer;text-align:center;transform:rotate(90deg);font-size:20px;user-select:none}.Content{border-radius:0 0 4px 4px;background:#fff;border:1px solid #009993;padding:10px 15px;user-select:none;color:#000;margin-bottom:10px}.ActionButton{cursor:pointer;display:inline-block;border-radius:4px;margin:20px 0 10px;text-transform:uppercase;font-size:12px;text-align:center;padding:8px 20px;min-width:80px;background:#FF3D00;border:1px solid #FF3D00;color:#FFF}.ActionButton:hover{background:#FF6536;border:1px solid #FF3D00}";
19
+
20
+ const Accordion = class {
21
+ constructor(hostRef) {
22
+ registerInstance(this, hostRef);
23
+ this.accordionEvent = createEvent(this, "helperAccordionAction", 7);
24
+ /**
25
+ * Flag for ticket history
26
+ */
27
+ this.ticketHistoryFlag = false;
28
+ /**
29
+ * Title (top header)
30
+ */
31
+ this.headerTitle = '';
32
+ /**
33
+ * SubTitle (top header)
34
+ */
35
+ this.headerSubtitle = '';
36
+ /**
37
+ * Description
38
+ */
39
+ this.description = '';
40
+ /**
41
+ * Enables footer content
42
+ */
43
+ this.footer = false;
44
+ /**
45
+ * Enables footer button for tab deletion
46
+ */
47
+ this.deleteTab = false;
48
+ /**
49
+ * Activates postMessages as events for actions from the widget
50
+ */
51
+ this.postMessage = false;
52
+ /**
53
+ * Name of the event emitter by the action button
54
+ */
55
+ this.eventName = 'helperAccordionAction';
56
+ /**
57
+ * Collapsed
58
+ */
59
+ this.collapsed = true;
60
+ /**
61
+ * Language
62
+ */
63
+ this.language = 'en';
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
+ connectedCallback() {
88
+ this.showContent = !this.collapsed;
89
+ }
90
+ componentDidRender() {
91
+ // start custom styling area
92
+ if (!this.limitStylingAppends && this.stylingContainer) {
93
+ if (this.clientStyling)
94
+ this.setClientStyling();
95
+ if (this.clientStylingUrlContent)
96
+ this.setClientStylingURL();
97
+ this.limitStylingAppends = true;
98
+ }
99
+ // end custom styling area
100
+ }
101
+ toggleContent() {
102
+ this.showContent = !this.showContent;
103
+ }
104
+ deleteAction() {
105
+ if (this.postMessage) {
106
+ // @TODO maybe change the name type, this one sucks
107
+ window.postMessage({ type: this.eventName }, window.location.href);
108
+ }
109
+ this.accordionEvent.emit();
110
+ }
111
+ render() {
112
+ return (h("div", { class: "Wrapper", ref: el => this.stylingContainer = el }, h("div", { class: this.ticketHistoryFlag === true ? 'HeaderTicketHistory' : 'Header' }, h("p", { class: "Title" }, this.headerTitle), h("p", { class: "Subtitle" }, this.headerSubtitle), h("p", { class: "Subtitle Description" }, this.description), h("span", { class: "Expand", onClick: () => this.toggleContent() }, this.showContent ? '<' : '>')), this.showContent &&
113
+ h("div", null, h("div", { class: "Content" }, h("slot", { name: 'accordionContent' }), this.footer && this.showContent &&
114
+ h("div", null, this.deleteTab &&
115
+ h("span", { class: "ActionButton", onClick: () => this.deleteAction() }, translate$2('deleteTicket', this.language)))))));
116
+ }
117
+ };
118
+ Accordion.style = helperAccordionCss;
119
+
120
+ const lotteryBulletCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}@-webkit-keyframes Circle{0%{-webkit-transform:scale(0.5);transform:scale(0.5)}100%{-webkit-transform:scale(1);transform:scale(1)}}@keyframes Circle{0%{-webkit-transform:scale(0.5);transform:scale(0.5)}100%{-webkit-transform:scale(1);transform:scale(1)}}@-webkit-keyframes hover-rotate{0%{-webkit-transform:scale(1) rotateZ(0);transform:scale(1) rotateZ(0)}50%{-webkit-transform:scale(1.2) rotateZ(180deg);transform:scale(1.22) rotateZ(180deg)}100%{-webkit-transform:scale(1) rotateZ(360deg);transform:scale(1) rotateZ(360deg)}}@keyframes hover-rotate{0%{-webkit-transform:scale(1) rotateZ(0);transform:scale(1) rotateZ(0)}50%{-webkit-transform:scale(1.2) rotateZ(180deg);transform:scale(1.2) rotateZ(180deg)}100%{-webkit-transform:scale(1) rotateZ(360deg);transform:scale(1) rotateZ(360deg)}}@-webkit-keyframes selected-scaleUp{0%{-webkit-transform:scale(0.5);transform:scale(0.5)}100%{-webkit-transform:scale(1.2);transform:scale(1.2)}}@keyframes selected-scaleUp{0%{-webkit-transform:scale(0.5);transform:scale(0.5)}100%{-webkit-transform:scale(1);transform:scale(1)}}.Circle{-webkit-animation:Circle 0.8s cubic-bezier(0.39, 0.575, 0.565, 1) both;animation:Circle 0.8s cubic-bezier(0.39, 0.575, 0.565, 1) both;cursor:pointer;color:#000000;display:block;height:30px;width:30px;margin:0;display:flex;align-items:center;justify-content:center;justify-content:center;align-items:center;border:solid 2px #ffffff;background:radial-gradient(circle at top, white 0%, white 100%);font-weight:bold;border-radius:50%;box-shadow:0 2px 4px 0 rgba(0, 0, 0, 0.5);user-select:none;font-size:16px;line-height:16px;font-weight:600;position:relative}.Circle:hover{-webkit-animation:hover-rotate 0.4s linear both;animation:hover-rotate 0.4s linear both;background:radial-gradient(circle at top, white 0%, #f1f1f1 100%)}.Circle.Selected{-webkit-animation:selected-scaleUp 0.4s cubic-bezier(0.39, 0.575, 0.565, 1) both;animation:selected-scaleUp 0.4s cubic-bezier(0.39, 0.575, 0.565, 1) both;color:#ffffff;background:#9EC258;background:-webkit-radial-gradient(top, #00958f, #004D4A);background:-moz-radial-gradient(top, #00958f, #004D4A);background:radial-gradient(to bottom, #00958f, #004D4A);border:solid 2px #00958f}.Circle.Disabled{-webkit-animation:selected-scaleUp 0.4s cubic-bezier(0.39, 0.575, 0.565, 1) both;animation:selected-scaleUp 0.4s cubic-bezier(0.39, 0.575, 0.565, 1) both;color:#f1f1f1;background:#D4D4D4;border:solid 2px #D4D4D4;cursor:default}.Circle.DisabledSelected{-webkit-animation:selected-scaleUp 0.4s cubic-bezier(0.39, 0.575, 0.565, 1) both;animation:selected-scaleUp 0.4s cubic-bezier(0.39, 0.575, 0.565, 1) both;color:#f1f1f1;background:#9EC258;background:-webkit-radial-gradient(top, #00958f, #004D4A);background:-moz-radial-gradient(top, #00958f, #004D4A);background:radial-gradient(to bottom, #00958f, #004D4A);border:solid 2px #D4D4D4;cursor:default}";
121
+
122
+ const LotteryBullet = class {
123
+ constructor(hostRef) {
124
+ registerInstance(this, hostRef);
125
+ this.bulletEvent = createEvent(this, "lotteryBulletSelection", 7);
126
+ /**
127
+ * Value of the bullet
128
+ */
129
+ this.value = '0';
130
+ /**
131
+ * Marks if the bullet should be selectable
132
+ */
133
+ this.selectable = true;
134
+ /**
135
+ * Marks if the bullet should be selected
136
+ */
137
+ this.isSelected = false;
138
+ /**
139
+ * Client custom styling via string
140
+ */
141
+ this.clientStyling = '';
142
+ /**
143
+ * Client custom styling via url content
144
+ */
145
+ this.clientStylingUrlContent = '';
146
+ this.limitStylingAppends = false;
147
+ this.select = () => {
148
+ if (this.selectable) {
149
+ this.isSelected = !this.isSelected;
150
+ this.bulletEvent.emit({
151
+ value: this.value,
152
+ selected: this.isSelected
153
+ });
154
+ }
155
+ };
156
+ this.setClientStyling = () => {
157
+ let sheet = document.createElement('style');
158
+ sheet.innerHTML = this.clientStyling;
159
+ this.stylingContainer.prepend(sheet);
160
+ };
161
+ this.setClientStylingURL = () => {
162
+ let cssFile = document.createElement('style');
163
+ setTimeout(() => {
164
+ cssFile.innerHTML = this.clientStylingUrlContent;
165
+ this.stylingContainer.prepend(cssFile);
166
+ }, 1);
167
+ };
168
+ }
169
+ componentDidRender() {
170
+ // start custom styling area
171
+ if (!this.limitStylingAppends && this.stylingContainer) {
172
+ if (this.clientStyling)
173
+ this.setClientStyling();
174
+ if (this.clientStylingUrlContent)
175
+ this.setClientStylingURL();
176
+ this.limitStylingAppends = true;
177
+ }
178
+ // end custom styling area
179
+ }
180
+ render() {
181
+ return (h("div", { class: 'Circle ' + (this.selectable ? '' : 'Disabled') + (this.isSelected ? 'Selected' : ''), onClick: () => this.select(), ref: el => this.stylingContainer = el }, this.value));
182
+ }
183
+ };
184
+ LotteryBullet.style = lotteryBulletCss;
185
+
186
+ const lotteryGridCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}.GridContainer{display:flex;flex-direction:column;max-width:1200px}.Grid{margin-top:10px 0 10px 0;display:flex;flex-direction:row;flex-wrap:wrap;gap:20px}.Grid.TicketGrid{gap:5px}";
187
+
188
+ const LotteryGrid = class {
189
+ constructor(hostRef) {
190
+ registerInstance(this, hostRef);
191
+ this.gridFilledEvent = createEvent(this, "gridFilled", 7);
192
+ this.gridDirtyEvent = createEvent(this, "gridDirty", 7);
193
+ /**
194
+ * Number of bullets of grid
195
+ */
196
+ this.totalNumbers = 0;
197
+ /**
198
+ * Number of maximum bullets that can be selected
199
+ */
200
+ this.maximumAllowed = 0;
201
+ /**
202
+ * Minimum allowed of bullets
203
+ */
204
+ this.minimumAllowed = 1;
205
+ /**
206
+ * Allows the user to select numbers on the grid
207
+ */
208
+ this.selectable = true;
209
+ /**
210
+ * Numbers that should be showed as selected on the grid (as a string of those numbers e.g. '1,2,3,4,5,6')
211
+ */
212
+ this.selectedNumbers = '';
213
+ /**
214
+ * Show only selected numbers
215
+ */
216
+ this.displaySelected = false;
217
+ /**
218
+ * Language
219
+ */
220
+ this.language = 'en';
221
+ /**
222
+ * Personalize grid for ticket
223
+ */
224
+ this.gridType = '';
225
+ /**
226
+ * Client custom styling via string
227
+ */
228
+ this.clientStyling = '';
229
+ /**
230
+ * Client custom styling via url content
231
+ */
232
+ this.clientStylingUrlContent = '';
233
+ this.numbers = [];
234
+ this.limitStylingAppends = false;
235
+ this.selectedCounter = 0;
236
+ this.setClientStyling = () => {
237
+ let sheet = document.createElement('style');
238
+ sheet.innerHTML = this.clientStyling;
239
+ this.stylingContainer.prepend(sheet);
240
+ };
241
+ this.setClientStylingURL = () => {
242
+ let cssFile = document.createElement('style');
243
+ setTimeout(() => {
244
+ cssFile.innerHTML = this.clientStylingUrlContent;
245
+ this.stylingContainer.prepend(cssFile);
246
+ }, 1);
247
+ };
248
+ }
249
+ connectedCallback() {
250
+ let selected = [];
251
+ if (this.selectedNumbers.length > 0) {
252
+ selected = this.selectedNumbers.split(',');
253
+ this.selectedCounter = selected.length;
254
+ }
255
+ if (this.displaySelected) {
256
+ selected.forEach((item) => {
257
+ this.numbers.push({
258
+ number: item,
259
+ selected: true,
260
+ selectable: this.selectable
261
+ });
262
+ });
263
+ }
264
+ else {
265
+ [...Array(this.totalNumbers).keys()]
266
+ .map(number => (number + 1).toString())
267
+ .forEach((number) => {
268
+ this.numbers.push({
269
+ number,
270
+ selected: selected.indexOf(number) >= 0 ? true : false,
271
+ selectable: this.selectedCounter == this.maximumAllowed ? false : this.selectable
272
+ });
273
+ });
274
+ }
275
+ }
276
+ componentDidRender() {
277
+ // start custom styling area
278
+ if (!this.limitStylingAppends && this.stylingContainer) {
279
+ if (this.clientStyling)
280
+ this.setClientStyling();
281
+ if (this.clientStylingUrlContent)
282
+ this.setClientStylingURL();
283
+ this.limitStylingAppends = true;
284
+ }
285
+ // end custom styling area
286
+ }
287
+ lotteryBulletSelectionHandler(event) {
288
+ this.numbers = this.numbers.map((item) => {
289
+ if (item.number == event.detail.value) {
290
+ return {
291
+ number: item.number,
292
+ selected: event.detail.selected,
293
+ selectable: item.selectable
294
+ };
295
+ }
296
+ return {
297
+ number: item.number,
298
+ selected: item.selected,
299
+ selectable: item.selectable
300
+ };
301
+ });
302
+ if (event.detail.selected) {
303
+ this.selectedCounter += 1;
304
+ if (this.selectedCounter == this.maximumAllowed) {
305
+ this.numbers = this.numbers.map((item) => {
306
+ return {
307
+ number: item.number,
308
+ selected: item.selected,
309
+ selectable: item.selected ? true : false
310
+ };
311
+ });
312
+ this.gridFilledEvent.emit({
313
+ id: this.ticketId,
314
+ index: this.gridIndex,
315
+ selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
316
+ });
317
+ }
318
+ }
319
+ else {
320
+ if (this.selectedCounter == this.maximumAllowed) {
321
+ this.numbers = this.numbers.map((item) => {
322
+ return {
323
+ number: item.number,
324
+ selected: item.selected,
325
+ selectable: true
326
+ };
327
+ });
328
+ this.gridDirtyEvent.emit({
329
+ id: this.ticketId,
330
+ index: this.gridIndex,
331
+ selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
332
+ });
333
+ }
334
+ this.selectedCounter -= 1;
335
+ }
336
+ }
337
+ async resetSelectionHandler(event) {
338
+ if (event.detail && event.detail == this.ticketId) {
339
+ this.selectedCounter = 0;
340
+ this.numbers = this.numbers.map((item) => {
341
+ return {
342
+ number: item.number,
343
+ selected: false,
344
+ selectable: this.selectable
345
+ };
346
+ });
347
+ this.gridDirtyEvent.emit({
348
+ id: this.ticketId,
349
+ index: this.gridIndex,
350
+ selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
351
+ });
352
+ }
353
+ }
354
+ async autoSelectionHandler(event) {
355
+ if (event.detail && event.detail == this.ticketId) {
356
+ this.resetSelectionHandler(event);
357
+ let array = [...Array(this.totalNumbers).keys()]
358
+ .map(number => number + 1)
359
+ .sort(() => 0.5 - Math.random());
360
+ array = array.slice(0, this.minimumAllowed);
361
+ this.numbers = this.numbers.map((item) => {
362
+ return {
363
+ number: item.number,
364
+ selected: array.indexOf(parseInt(item.number, 10)) >= 0 ? true : false,
365
+ selectable: array.indexOf(parseInt(item.number, 10)) >= 0 ? true : false,
366
+ };
367
+ });
368
+ this.gridFilledEvent.emit({
369
+ id: this.ticketId,
370
+ index: this.gridIndex,
371
+ selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
372
+ });
373
+ this.selectedCounter = this.maximumAllowed;
374
+ }
375
+ }
376
+ render() {
377
+ return (h("div", { class: "GridContainer", ref: el => this.stylingContainer = el }, h("div", { class: this.gridType === 'ticket' ? 'Grid TicketGrid' : 'Grid' }, this.numbers.map((item) => h("div", null, h("lottery-bullet", { value: item.number, selectable: item.selectable, "is-selected": item.selected, "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent }))))));
378
+ }
379
+ };
380
+ LotteryGrid.style = lotteryGridCss;
381
+
382
+ const DEFAULT_LANGUAGE$1 = 'en';
383
+ const SUPPORTED_LANGUAGES$1 = ['ro', 'en'];
384
+ const TRANSLATIONS$1 = {
385
+ en: {
386
+ loading: 'Loading, please wait ...',
387
+ error: 'It was an error while trying to fetch the data',
388
+ grid: 'Grid',
389
+ multiplier: 'Multiplier',
390
+ numberOfDraws: 'Number of draws',
391
+ wagerPerDraw: 'Wager per draw',
392
+ resetButton: 'Reset',
393
+ autoButton: 'I feel lucky'
394
+ },
395
+ ro: {
396
+ loading: 'Se incarca, va rugam asteptati ...',
397
+ error: 'A fost o eroare in timp ce asteptam datele',
398
+ grid: 'Grid',
399
+ multiplier: 'Multiplicator',
400
+ numberOfDraws: 'Numarul de extrageri',
401
+ wagerPerDraw: 'Pariul per extragere',
402
+ resetButton: 'Reseteaza',
403
+ autoButton: 'Ma simt norocos'
404
+ },
405
+ };
406
+ const translate$1 = (key, customLang) => {
407
+ const lang = customLang;
408
+ return TRANSLATIONS$1[lang !== undefined && SUPPORTED_LANGUAGES$1.includes(lang) ? lang : DEFAULT_LANGUAGE$1][key];
409
+ };
410
+
411
+ const lotteryTicketCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}.TicketTitle{font-size:16px;font-weight:bold}.ButtonContainer{display:flex;justify-content:flex-end}.Toggle{cursor:pointer;margin-top:20px;display:inline-block}.ToggleSwitch{display:inline-block;background:#707070;border-radius:16px;width:58px;height:24px;position:relative;vertical-align:middle;transition:background 0.25s}.ToggleSwitch:before,.ToggleSwitch:after{content:\"\"}.ToggleSwitch:before{display:block;background:linear-gradient(to bottom, #fff 0%, #F1F1F1 100%);border-radius:50%;box-shadow:0 0 0 1px rgba(0, 0, 0, 0.25);width:16px;height:16px;position:absolute;top:4px;left:4px;transition:left 0.25s}.Toggle:hover .ToggleSwitch:before{background:linear-gradient(to bottom, #fff 0%, #fff 100%);box-shadow:0 0 0 1px rgba(0, 0, 0, 0.5)}.ToggleCheckbox:checked+.ToggleSwitch{background:#00ABA4}.ToggleCheckbox:checked+.ToggleSwitch:before{left:38px}.ToggleCheckbox{position:absolute;visibility:hidden}.Label{margin-right:5px;position:relative;top:2px;font-size:14px;font-weight:lighter;color:#000}input[type=number]{-webkit-appearance:textfield;-moz-appearance:textfield;appearance:textfield}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none}.NumberInput,.WagerInput{margin-top:10px;display:inline-flex;align-items:center}.NumberInput,.NumberInput *{box-sizing:border-box}.NumberInput button{cursor:pointer;outline:none;-webkit-appearance:none;border:none;align-items:center;justify-content:center;height:20px;position:relative}.NumberInput button:after{display:inline-block;position:absolute;transform:translate(-50%, -50%) rotate(180deg);align-items:center;text-align:center}.NumberInput button.Plus:after{transform:translate(-50%, -50%) rotate(0deg);width:30px;display:inline-flex;align-items:center;text-align:center}.NumberInput input[type=number],.WagerInput input[type=number]{max-width:50px;display:inline-flex;align-items:center;padding:4px 10px;text-align:center}.NumberInput input[type=number] .WagerInputTitle,.WagerInput input[type=number] .WagerInputTitle{font-size:14px;color:#000;padding:10px}.InputDefault{background-color:#F1F1F1;border-radius:4px;padding:5px;border:solid 1px #D4D4D4;color:#707070}.AutoButton{cursor:pointer;display:inline-block;border-radius:4px;padding:8px 20px;width:max-content;margin:5px 0;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}.AutoButton:active{background:#00958f;color:#FFF}.ResetButton{cursor:pointer;display:inline-block;border-radius:4px;padding:8px 20px;width:max-content;margin:5px 0;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}.ResetButton:hover{background:#FF6536;border:1px solid #FF3D00}.TicketGridBullets{background:#f1f1f1;border-radius:4px;padding:20px;margin-top:5px}.TicketGridBullets .TicketGridTitle{margin-top:0px}.Minus{border-radius:4px;width:30px;height:24px !important;margin-right:10px;color:#FFF;background:#009993}.Plus{border-radius:4px;width:30px;height:24px !important;margin-left:10px;color:#FFF;background:#009993}.SelectWrapper{width:auto;padding:5px;margin:0 auto;border:1px solid #ccc;border-radius:5px;position:relative}.SelectButton,.SelectOptions li{display:flex;align-items:center;cursor:pointer}.SelectButton{display:flex;padding:0 5px;border-radius:7px;align-items:center;justify-content:space-between;font-size:14px}.SelectButton span:first-child{padding-right:10px}.SelectExpand{transition:transform 0.3s linear;font-size:12px}.SelectActive .SelectExpand{transform:rotate(180deg)}.SelectContent{display:none;padding:5px;border-radius:7px}.SelectWrapper.SelectActive .SelectContent{width:100%;display:block;position:absolute;left:0;top:32px;padding:0;border:1px solid #ccc;overflow:hidden;background:#fff}.SelectContent .SelectOptions{max-height:100px;margin:0;overflow-y:auto;padding:0}.SelectContent .SelectOptions .SelectedValue{background-color:#009993;color:#fff}.SelectOptions::-webkit-scrollbar{width:7px}.SelectOptions::-webkit-scrollbar-track{background:#f1f1f1;border-radius:25px}.SelectOptions::-webkit-scrollbar-thumb{background:#ccc;border-radius:25px}.SelectOptions li{height:20px;padding:0 13px;font-size:14px}.SelectOptions li:hover{background:#f2f2f2}";
412
+
413
+ const LotteryTicket = class {
414
+ constructor(hostRef) {
415
+ registerInstance(this, hostRef);
416
+ this.ticketCompleted = createEvent(this, "ticketCompleted", 7);
417
+ this.autoSelection = createEvent(this, "autoSelection", 7);
418
+ this.resetSelection = createEvent(this, "resetSelection", 7);
419
+ this.stakeChange = createEvent(this, "stakeChange", 7);
420
+ this.multiplierChange = createEvent(this, "multiplierChange", 7);
421
+ /**
422
+ * Number of grids of a ticket
423
+ */
424
+ this.numberOfGrids = 1;
425
+ /**
426
+ * Option to have the ticket registered for multiple draws
427
+ */
428
+ this.multipleDraws = true;
429
+ /**
430
+ * Shows the reset button
431
+ */
432
+ this.resetButton = false;
433
+ /**
434
+ * Shows the auto-pick button
435
+ */
436
+ this.autoPick = false;
437
+ /**
438
+ * Language
439
+ */
440
+ this.language = 'en';
441
+ this.multiplier = false;
442
+ this.numberOfDraws = 1;
443
+ this.isLoading = true;
444
+ this.hasErrors = false;
445
+ this.ticketDone = false;
446
+ this.isCustomSelect = false;
447
+ this.amountInfo = {};
448
+ }
449
+ /**
450
+ * @TODO find a better way to implement click outside the custom select, so that we don't have to use the 'data-cluster' attribute on each element
451
+ */
452
+ checkForClickOutside(ev) {
453
+ if (ev.composedPath()[0].getAttribute('data-cluster') !== 'SelectComponent') {
454
+ this.isCustomSelect = false;
455
+ }
456
+ }
457
+ connectedCallback() {
458
+ let url = new URL(`${this.endpoint}/games/${this.gameId}`);
459
+ fetch(url.href)
460
+ .then((response) => {
461
+ if (response.ok) {
462
+ return response.json();
463
+ }
464
+ else {
465
+ // Throw error
466
+ this.hasErrors = true;
467
+ }
468
+ })
469
+ .then((data) => {
470
+ this.isLoading = false;
471
+ this.gameData = data;
472
+ this.grids = [...Array(data.rules.boards.length).keys()];
473
+ this.amountInfo = this.gameData.rules.stakes[0]; // initial value for select
474
+ })
475
+ .catch((err) => {
476
+ this.isLoading = false;
477
+ this.hasErrors = true;
478
+ console.error('Error!', err);
479
+ });
480
+ }
481
+ multiplierChangeHandler(e) {
482
+ this.multiplier = e.target ? e.target.checked : false;
483
+ this.multiplierChange.emit(this.multiplier);
484
+ }
485
+ drawsChangeHandler(event) {
486
+ this.ticket = Object.assign(Object.assign({}, this.ticket), { draws: event });
487
+ this.ticketCompleted.emit(this.ticket);
488
+ }
489
+ gridFilledHandler(event) {
490
+ this.ticket = Object.assign(Object.assign({}, event.detail), { draws: this.numberOfDraws });
491
+ this.ticketDone = true;
492
+ this.ticketCompleted.emit(this.ticket);
493
+ }
494
+ toggleAutoSelection() {
495
+ this.ticketDone = true;
496
+ this.autoSelection.emit(this.ticketId);
497
+ }
498
+ toggleResetSelection() {
499
+ this.ticketDone = false;
500
+ this.resetSelection.emit(this.ticketId);
501
+ }
502
+ changeStake(ticketid, amount) {
503
+ this.stakeChange.emit({
504
+ ticketId: ticketid,
505
+ stake: amount
506
+ });
507
+ }
508
+ toggleClass() {
509
+ this.isCustomSelect = !this.isCustomSelect;
510
+ }
511
+ setDropdownItem(item) {
512
+ this.amountInfo = {
513
+ amount: item.amount,
514
+ currency: item.currency
515
+ };
516
+ this.isCustomSelect = false;
517
+ this.changeStake(this.ticketId, item.amount);
518
+ }
519
+ render() {
520
+ if (this.isLoading) {
521
+ return (h("div", null, h("p", null, translate$1('loading', this.language))));
522
+ }
523
+ else {
524
+ if (this.hasErrors) {
525
+ return (h("div", null, h("p", null, translate$1('error', this.language))));
526
+ }
527
+ else {
528
+ const { rules } = this.gameData;
529
+ return (h("div", { class: "TicketContainer" }, h("p", { class: "TicketTitle" }, this.gameData.name), this.resetButton && this.ticketDone &&
530
+ h("div", { class: "ButtonContainer" }, h("a", { class: "ResetButton", onClick: () => this.toggleResetSelection() }, translate$1('resetButton', this.language))), this.autoPick && !this.ticketDone &&
531
+ h("div", { class: "ButtonContainer" }, h("a", { class: "AutoButton", onClick: () => this.toggleAutoSelection() }, translate$1('autoButton', this.language))), this.grids.map((item, index) => h("div", { class: "TicketGridBullets" }, h("p", { class: "TicketGridTitle" }, translate$1('grid', this.language), " ", item), h("lottery-grid", { "grid-index": index, "maximum-allowed": rules.boards[index].maximumAllowed, "minimum-allowed": rules.boards[index].minimumAllowed, "total-numbers": rules.boards[index].totalNumbers, selectable: true, "reset-button": true, "auto-pick": true, "game-id": this.gameId, "ticket-id": this.ticketId, language: this.language }))), rules.multiplier &&
532
+ h("div", null, h("label", { class: "Toggle" }, h("label", { class: "Label" }, translate$1('multiplier', this.language), ": "), h("input", { class: "ToggleCheckbox", type: "checkbox", onInput: (e) => this.multiplierChangeHandler(e) }), h("div", { class: "ToggleSwitch" }))), this.multipleDraws &&
533
+ h("div", { class: "TicketDraws" }, h("label", { class: "Label" }, translate$1('numberOfDraws', this.language), ": "), h("div", { class: "NumberInput" }, h("button", { onClick: () => this.numberOfDraws > 1 ? this.numberOfDraws-- : this.numberOfDraws = 1, class: "Minus" }, "-"), h("input", { class: "InputDefault", min: "1", value: this.numberOfDraws, type: "number" }), h("button", { onClick: () => this.numberOfDraws++, class: "Plus" }, "+"))), h("div", null, h("label", { class: "Label" }, translate$1('wagerPerDraw', this.language), ": "), h("div", { class: "WagerInput" }, rules.stakes.length > 1 ?
534
+ (h("div", { "data-cluster": "SelectComponent", class: this.isCustomSelect ? "SelectWrapper SelectActive" : "SelectWrapper" }, h("div", { "data-cluster": "SelectComponent", class: "SelectButton", onClick: () => this.toggleClass() }, h("span", { "data-cluster": "SelectComponent" }, this.amountInfo.amount, " ", this.amountInfo.currency), h("span", { "data-cluster": "SelectComponent", class: "SelectExpand" }, "\u25BC")), h("div", { "data-cluster": "SelectComponent", class: "SelectContent" }, h("ul", { "data-cluster": "SelectComponent", class: "SelectOptions" }, rules.stakes.map((item) => h("li", { "data-cluster": "SelectComponent", class: this.amountInfo.amount == item.amount ? 'SelectedValue' : '', value: item.amount, onClick: () => this.setDropdownItem(item) }, item.amount, " ", item.currency)))))) : (h("div", null, h("input", { min: "1", value: rules.stakes[0].amount, type: "number", disabled: true }), h("p", { class: "WagerInputTitle" }, rules.stakes[0].currency)))))));
535
+ }
536
+ }
537
+ }
538
+ static get watchers() { return {
539
+ "numberOfDraws": ["drawsChangeHandler"]
540
+ }; }
541
+ };
542
+ LotteryTicket.style = lotteryTicketCss;
543
+
544
+ const DEFAULT_LANGUAGE = 'en';
545
+ const SUPPORTED_LANGUAGES = ['ro', 'en'];
546
+ const TRANSLATIONS = {
547
+ en: {
548
+ ticket: 'Ticket',
549
+ },
550
+ ro: {
551
+ ticket: 'Bilet',
552
+ },
553
+ };
554
+ const translate = (key, customLang) => {
555
+ const lang = customLang;
556
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
557
+ };
558
+
559
+ const lotteryTicketControllerCss = ":host{display:block}";
560
+
561
+ const LotteryTicketController = class {
562
+ constructor(hostRef) {
563
+ registerInstance(this, hostRef);
564
+ this.deleteTicketEvent = createEvent(this, "deleteTicket", 7);
565
+ /**
566
+ * Endpoint URL for the source of data (NorWAy standard)
567
+ */
568
+ this.endpoint = '';
569
+ /**
570
+ * Ticket number
571
+ */
572
+ this.ticketId = 1;
573
+ /**
574
+ * Activates postMessages as events for actions from the widget
575
+ */
576
+ this.postMessage = false;
577
+ /**
578
+ * Name of the event emitter by the action button
579
+ */
580
+ this.eventName = 'deleteTicketAction';
581
+ /**
582
+ * Collapsed
583
+ */
584
+ this.collapsed = true;
585
+ /**
586
+ * Number of grids?
587
+ */
588
+ this.numberOfGrids = 1;
589
+ /**
590
+ * This toggles if the last ticket added should be expanded or not
591
+ */
592
+ this.last = false;
593
+ /**
594
+ * Language
595
+ */
596
+ this.language = 'en';
597
+ /**
598
+ * Shows the auto-pick button
599
+ */
600
+ this.autoPick = false;
601
+ /**
602
+ * Shows the reset button
603
+ */
604
+ this.resetButton = false;
605
+ /**
606
+ * Client custom styling via string
607
+ */
608
+ this.clientStyling = '';
609
+ /**
610
+ * Client custom styling via url content
611
+ */
612
+ this.clientStylingUrlContent = '';
613
+ this.limitStylingAppends = false;
614
+ this.setClientStyling = () => {
615
+ let sheet = document.createElement('style');
616
+ sheet.innerHTML = this.clientStyling;
617
+ this.stylingContainer.prepend(sheet);
618
+ };
619
+ this.setClientStylingURL = () => {
620
+ let cssFile = document.createElement('style');
621
+ setTimeout(() => {
622
+ cssFile.innerHTML = this.clientStylingUrlContent;
623
+ this.stylingContainer.prepend(cssFile);
624
+ }, 1);
625
+ };
626
+ }
627
+ // @TODO fix the `any` type
628
+ helperAccordionActionHandler() {
629
+ if (this.postMessage) {
630
+ window.postMessage({ type: this.eventName }, window.location.href);
631
+ }
632
+ this.deleteTicketEvent.emit({
633
+ ticketId: this.ticketId
634
+ });
635
+ }
636
+ componentDidRender() {
637
+ // start custom styling area
638
+ if (!this.limitStylingAppends && this.stylingContainer) {
639
+ if (this.clientStyling)
640
+ this.setClientStyling();
641
+ if (this.clientStylingUrlContent)
642
+ this.setClientStylingURL();
643
+ this.limitStylingAppends = true;
644
+ }
645
+ // end custom styling area
646
+ }
647
+ render() {
648
+ 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 })))));
649
+ }
650
+ };
651
+ LotteryTicketController.style = lotteryTicketControllerCss;
652
+
653
+ export { Accordion as helper_accordion, LotteryBullet as lottery_bullet, LotteryGrid as lottery_grid, LotteryTicket as lottery_ticket, LotteryTicketController as lottery_ticket_controller };