@everymatrix/lottery-oddsbom-latest-result 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.
- package/dist/cjs/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/index-1c32912a.js +1265 -0
- package/dist/cjs/index.cjs.js +10 -0
- package/dist/cjs/loader.cjs.js +15 -0
- package/dist/cjs/lottery-oddsbom-bullet_4.cjs.entry.js +3153 -0
- package/dist/cjs/lottery-oddsbom-latest-result-04622cbf.js +634 -0
- package/dist/cjs/lottery-oddsbom-latest-result.cjs.js +25 -0
- package/dist/collection/collection-manifest.json +31 -0
- package/dist/collection/components/lottery-oddsbom-latest-result/index.js +1 -0
- package/dist/collection/components/lottery-oddsbom-latest-result/lottery-oddsbom-latest-result.css +100 -0
- package/dist/collection/components/lottery-oddsbom-latest-result/lottery-oddsbom-latest-result.js +470 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/models/index.js +1 -0
- package/dist/collection/utils/api.js +36 -0
- package/dist/collection/utils/locale.utils.js +49 -0
- package/dist/collection/utils/utils.js +191 -0
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/index-0068c174.js +1237 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/loader.js +11 -0
- package/dist/esm/lottery-oddsbom-bullet_4.entry.js +3147 -0
- package/dist/esm/lottery-oddsbom-latest-result-825abc49.js +626 -0
- package/dist/esm/lottery-oddsbom-latest-result.js +20 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/lottery-oddsbom-latest-result/app-globals-0f993ce5.js +1 -0
- package/dist/lottery-oddsbom-latest-result/index-0068c174.js +2 -0
- package/dist/lottery-oddsbom-latest-result/index.esm.js +1 -0
- package/dist/lottery-oddsbom-latest-result/lottery-oddsbom-bullet_4.entry.js +1 -0
- package/dist/lottery-oddsbom-latest-result/lottery-oddsbom-latest-result-825abc49.js +1 -0
- package/dist/lottery-oddsbom-latest-result/lottery-oddsbom-latest-result.esm.js +1 -0
- package/dist/stencil.config.dev.js +19 -0
- package/dist/stencil.config.js +19 -0
- package/dist/storybook/main.js +43 -0
- package/dist/storybook/preview.js +9 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-latest-result/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-latest-result/.stencil/packages/stencil/lottery-oddsbom-latest-result/stencil.config.d.ts +2 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-latest-result/.stencil/packages/stencil/lottery-oddsbom-latest-result/stencil.config.dev.d.ts +2 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-latest-result/.stencil/packages/stencil/lottery-oddsbom-latest-result/storybook/main.d.ts +3 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-latest-result/.stencil/packages/stencil/lottery-oddsbom-latest-result/storybook/preview.d.ts +70 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-latest-result/.stencil/tools/plugins/index.d.ts +4 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-latest-result/.stencil/tools/plugins/lazy-load-chunk-plugin.d.ts +12 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-latest-result/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-latest-result/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-latest-result/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
- package/dist/types/components/lottery-oddsbom-latest-result/index.d.ts +1 -0
- package/dist/types/components/lottery-oddsbom-latest-result/lottery-oddsbom-latest-result.d.ts +67 -0
- package/dist/types/components.d.ts +115 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/models/index.d.ts +172 -0
- package/dist/types/stencil-public-runtime.d.ts +1674 -0
- package/dist/types/utils/api.d.ts +14 -0
- package/dist/types/utils/locale.utils.d.ts +3 -0
- package/dist/types/utils/utils.d.ts +8 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/loader/package.json +11 -0
- package/package.json +27 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
2
|
+
const SUPPORTED_LANGUAGES = ['ro', 'en', 'fr', 'ar', 'hr'];
|
|
3
|
+
const TRANSLATIONS = {
|
|
4
|
+
en: {
|
|
5
|
+
weeks: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
|
|
6
|
+
bettingType: 'Betting Type:',
|
|
7
|
+
prizeAllocation: 'Prize Allocation (Turnover: €{turnover})',
|
|
8
|
+
prizes: 'Prizes',
|
|
9
|
+
numberOfWinners: 'Number of Winners',
|
|
10
|
+
prizeMoney: 'Prize Money',
|
|
11
|
+
noLatestResult: 'No latest result.',
|
|
12
|
+
loading: 'Loading....',
|
|
13
|
+
turnover: 'Turnover:',
|
|
14
|
+
winners: 'winners,',
|
|
15
|
+
prize: 'Prize:',
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
export const translate = (key, customLang, replacements) => {
|
|
19
|
+
const lang = customLang;
|
|
20
|
+
let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
21
|
+
if (replacements) {
|
|
22
|
+
Object.keys(replacements).forEach((placeholder) => {
|
|
23
|
+
translation = translation.replace(`{${placeholder}}`, replacements[placeholder]);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return translation;
|
|
27
|
+
};
|
|
28
|
+
export const getTranslations = (data) => {
|
|
29
|
+
Object.keys(data).forEach((item) => {
|
|
30
|
+
for (let key in data[item]) {
|
|
31
|
+
TRANSLATIONS[item][key] = data[item][key];
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
export const resolveTranslationUrl = async (translationUrl) => {
|
|
36
|
+
if (translationUrl) {
|
|
37
|
+
try {
|
|
38
|
+
const response = await fetch(translationUrl);
|
|
39
|
+
if (!response.ok) {
|
|
40
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
41
|
+
}
|
|
42
|
+
const translations = await response.json();
|
|
43
|
+
getTranslations(translations);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
console.error('Failed to fetch or parse translations from URL:', error);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { differenceInMilliseconds } from "date-fns";
|
|
2
|
+
export function format(first, middle, last) {
|
|
3
|
+
return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');
|
|
4
|
+
}
|
|
5
|
+
export const generateUUID = () => {
|
|
6
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
7
|
+
var r = (Math.random() * 16) | 0, v = c == 'x' ? r : (r & 0x3) | 0x8;
|
|
8
|
+
return v.toString(16);
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
export function fetchRequest(url, method = 'GET', body = null, headers = {}) {
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
const uuid = generateUUID();
|
|
14
|
+
const headersOrigin = Object.assign({ 'Content-Type': 'application/json' }, headers);
|
|
15
|
+
if (method !== 'GET' && method !== 'HEAD') {
|
|
16
|
+
headersOrigin['X-Idempotency-Key'] = uuid;
|
|
17
|
+
}
|
|
18
|
+
const options = {
|
|
19
|
+
method,
|
|
20
|
+
headers: headersOrigin,
|
|
21
|
+
body: null
|
|
22
|
+
};
|
|
23
|
+
if (body && method !== 'GET' && method !== 'HEAD') {
|
|
24
|
+
options.body = JSON.stringify(body);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
delete options.body;
|
|
28
|
+
}
|
|
29
|
+
fetch(url, options)
|
|
30
|
+
.then((response) => {
|
|
31
|
+
if (!response.ok) {
|
|
32
|
+
reject(`HTTP error! Status: ${response.status}`);
|
|
33
|
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
34
|
+
}
|
|
35
|
+
return response.json();
|
|
36
|
+
})
|
|
37
|
+
.then((data) => resolve(data))
|
|
38
|
+
.catch((error) => reject(error));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export function toQueryParams(params) {
|
|
42
|
+
function isEmptyValueOfArray(arr) {
|
|
43
|
+
if (arr.length === 0) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
const len = arr.length;
|
|
47
|
+
let count = 0;
|
|
48
|
+
for (let i = 0; i < len; i++) {
|
|
49
|
+
if (isEmptyValue(arr[i])) {
|
|
50
|
+
count++;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (count === len) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
function isEmptyValueOfObject(obj) {
|
|
62
|
+
if (Object.keys(obj).length === 0) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
const len = Object.keys(obj).length;
|
|
66
|
+
let count = 0;
|
|
67
|
+
for (const val of Object.values(obj)) {
|
|
68
|
+
if (isEmptyValue(val)) {
|
|
69
|
+
count++;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (count === len) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
function isEmptyValue(value, allowZero) {
|
|
81
|
+
if (value === null || value === undefined || value === '') {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
else if (value === 0 && allowZero) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
else if (Array.isArray(value)) {
|
|
88
|
+
return isEmptyValueOfArray(value);
|
|
89
|
+
}
|
|
90
|
+
else if (Object.prototype.toString.call(value) === '[object Object]') {
|
|
91
|
+
return isEmptyValueOfObject(value);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
return !value;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const finalParams = {};
|
|
98
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
99
|
+
if (!isEmptyValue(value, true)) {
|
|
100
|
+
finalParams[key] = value;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
const queryString = Object.entries(finalParams)
|
|
104
|
+
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
|
|
105
|
+
.join('&');
|
|
106
|
+
return queryString ? `?${queryString}` : '';
|
|
107
|
+
}
|
|
108
|
+
function transformResults(results) {
|
|
109
|
+
if (results && results.length > 0) {
|
|
110
|
+
return results.map((i) => i === null || i === void 0 ? void 0 : i[0]);
|
|
111
|
+
}
|
|
112
|
+
return [[]];
|
|
113
|
+
}
|
|
114
|
+
export function thousandSeparator(value) {
|
|
115
|
+
if (value === 0) {
|
|
116
|
+
return '0';
|
|
117
|
+
}
|
|
118
|
+
if (!value) {
|
|
119
|
+
return '';
|
|
120
|
+
}
|
|
121
|
+
value = value.toString();
|
|
122
|
+
const parts = value.split('.');
|
|
123
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
124
|
+
return parts.join('.');
|
|
125
|
+
}
|
|
126
|
+
export function changeCurDrawItemByDate(date, drawList) {
|
|
127
|
+
var _a, _b, _c;
|
|
128
|
+
const curDrawItem = drawList.find((i) => i.date === date);
|
|
129
|
+
if (!curDrawItem) {
|
|
130
|
+
// NO DATA
|
|
131
|
+
return Promise.reject();
|
|
132
|
+
}
|
|
133
|
+
const curDrawSelectionBettingType = curDrawItem.winningNumbers[0].winning_type;
|
|
134
|
+
const curDrawSelectionMap = {};
|
|
135
|
+
curDrawItem.winningNumbers.forEach((item) => {
|
|
136
|
+
curDrawSelectionMap[item.winning_type] = transformResults(item.poolGameOutcomes);
|
|
137
|
+
});
|
|
138
|
+
const results = curDrawSelectionMap[curDrawSelectionBettingType];
|
|
139
|
+
const curPrizeMap = {};
|
|
140
|
+
curDrawItem.prizes.forEach((prize) => {
|
|
141
|
+
const winningType = prize.winningType;
|
|
142
|
+
if (!curPrizeMap[winningType]) {
|
|
143
|
+
curPrizeMap[winningType] = [prize];
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
curPrizeMap[winningType].push(prize);
|
|
147
|
+
curPrizeMap[winningType].sort((a, b) => { var _a; return ((_a = b.totalAmount) === null || _a === void 0 ? void 0 : _a.value) - (a === null || a === void 0 ? void 0 : a.totalAmount.value); });
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
const prizes = (((_a = Object.values(curPrizeMap)) === null || _a === void 0 ? void 0 : _a[0]) || []);
|
|
151
|
+
const currency = ((_c = (_b = prizes[0]) === null || _b === void 0 ? void 0 : _b.totalAmount) === null || _c === void 0 ? void 0 : _c.currency) || '';
|
|
152
|
+
const { turnOver, winNumber, winTurnOver } = prizes.reduce((pre, cur) => {
|
|
153
|
+
var _a;
|
|
154
|
+
const { turnOver: _turnOver, winNumber: _winNumber, winTurnOver: _winTurnOver } = pre;
|
|
155
|
+
// FIXME: no turnover
|
|
156
|
+
const turnOver = 0;
|
|
157
|
+
const winNumber = _winNumber + Number(cur === null || cur === void 0 ? void 0 : cur.players);
|
|
158
|
+
const winTurnOver = _turnOver + Number((_a = cur === null || cur === void 0 ? void 0 : cur.totalAmount) === null || _a === void 0 ? void 0 : _a.value);
|
|
159
|
+
return {
|
|
160
|
+
turnOver,
|
|
161
|
+
winNumber,
|
|
162
|
+
winTurnOver
|
|
163
|
+
};
|
|
164
|
+
}, {
|
|
165
|
+
turnOver: 0,
|
|
166
|
+
winNumber: 0,
|
|
167
|
+
winTurnOver: 0
|
|
168
|
+
});
|
|
169
|
+
return Promise.resolve({
|
|
170
|
+
date,
|
|
171
|
+
formattedTurnOver: currency + ' ' + thousandSeparator(turnOver),
|
|
172
|
+
winNumber,
|
|
173
|
+
formattedWinTurnOver: currency + ' ' + thousandSeparator(winTurnOver),
|
|
174
|
+
drawId: curDrawItem.id,
|
|
175
|
+
results
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
export function findLatestDateIdx(dateArr) {
|
|
179
|
+
const currentDate = new Date();
|
|
180
|
+
let closestIndex = 0;
|
|
181
|
+
let minDiff = Infinity;
|
|
182
|
+
dateArr.forEach((dateStr, index) => {
|
|
183
|
+
const date = new Date(dateStr);
|
|
184
|
+
const diff = Math.abs(differenceInMilliseconds(currentDate, date));
|
|
185
|
+
if (diff < minDiff) {
|
|
186
|
+
minDiff = diff;
|
|
187
|
+
closestIndex = index;
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
return closestIndex;
|
|
191
|
+
}
|