@opexa/portal-sdk 0.0.3 → 0.0.5
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/index.js +59 -59
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +123 -98
- package/dist/index.mjs.map +1 -1
- package/dist/sdk.d.ts +1 -1
- package/dist/{graphql → services}/file.service.d.ts +1 -2
- package/dist/{session-service.d.ts → session-manager.d.ts} +6 -3
- package/dist/transformer.d.ts +1 -1
- package/dist/types.d.ts +1 -5
- package/dist/utils/sleep.d.ts +1 -0
- package/package.json +2 -2
- /package/dist/{graphql → services}/account.service.d.ts +0 -0
- /package/dist/{graphql → services}/announcement.d.ts +0 -0
- /package/dist/{graphql → services}/auth.service.d.ts +0 -0
- /package/dist/{graphql → services}/bet-record.d.ts +0 -0
- /package/dist/{graphql → services}/bonus.d.ts +0 -0
- /package/dist/{graphql → services}/cashback.d.ts +0 -0
- /package/dist/{graphql → services}/deposit.d.ts +0 -0
- /package/dist/{graphql → services}/file.d.ts +0 -0
- /package/dist/{graphql → services}/game.d.ts +0 -0
- /package/dist/{graphql → services}/game.service.d.ts +0 -0
- /package/dist/{graphql → services}/index.d.ts +0 -0
- /package/dist/{graphql → services}/member.d.ts +0 -0
- /package/dist/{graphql → services}/platform.d.ts +0 -0
- /package/dist/{graphql → services}/points.d.ts +0 -0
- /package/dist/{graphql → services}/portal.service.d.ts +0 -0
- /package/dist/{graphql → services}/promo.d.ts +0 -0
- /package/dist/{graphql → services}/report.service.d.ts +0 -0
- /package/dist/{graphql → services}/session.d.ts +0 -0
- /package/dist/{graphql → services}/static.service.d.ts +0 -0
- /package/dist/{graphql → services}/transaction.d.ts +0 -0
- /package/dist/{graphql → services}/types.d.ts +0 -0
- /package/dist/{graphql → services}/wallet.d.ts +0 -0
- /package/dist/{graphql → services}/wallet.service.d.ts +0 -0
- /package/dist/{graphql → services}/withdrawal.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(p,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("@opexa/object-id")):typeof define=="function"&&define.amd?define(["exports","@opexa/object-id"],m):(p=typeof globalThis<"u"?globalThis:p||self,m(p.sdk={},p.objectId))})(this,function(p,m){"use strict";var bt=Object.defineProperty;var St=(p,m,w)=>m in p?bt(p,m,{enumerable:!0,configurable:!0,writable:!0,value:w}):p[m]=w;var c=(p,m,w)=>St(p,typeof m!="symbol"?m+"":m,w);const w={Account:8,Deposit:9,Withdrawal:14,Verification:15,File:16,GameSession:204,MayaSession:230};class C{constructor(e){c(this,"enabled");this.enabled=(e==null?void 0:e.enabled)??!0}info(e){this.enabled&&console.log(`\x1B[34m[info] ${e}`)}warn(e){this.enabled&&console.log(`\x1B[33m[warn] ${e}`)}error(e){this.enabled&&console.log(`\x1B[31m[error] ${e}`)}success(e){this.enabled&&console.log(`\x1B[32m[success] ${e}`)}}function o(i,...e){let t="";for(const[a,n]of i.entries()){const d=e.at(a)??"";t=`${t}${n}${d}`}return t.trim()}const ge=o`
|
|
2
2
|
query Announcements($first: Int, $after: Cursor, $filter: AnnouncementFilterInput) {
|
|
3
3
|
announcements(first: $first, after: $after, filter: $filter) {
|
|
4
4
|
edges {
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
`,
|
|
27
|
+
`,b=o`
|
|
28
28
|
fragment GameFragment on Game {
|
|
29
29
|
id
|
|
30
30
|
type
|
|
31
31
|
name
|
|
32
32
|
provider
|
|
33
33
|
}
|
|
34
|
-
`,ye=
|
|
35
|
-
${
|
|
34
|
+
`,ye=o`
|
|
35
|
+
${b}
|
|
36
36
|
|
|
37
37
|
query Game($id: ObjectId!) {
|
|
38
38
|
node(id: $id) {
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
`,be=
|
|
45
|
-
${
|
|
44
|
+
`,be=o`
|
|
45
|
+
${b}
|
|
46
46
|
|
|
47
47
|
query Games($after: Cursor, $first: Int, $filter: GameFilterInput) {
|
|
48
48
|
games(after: $after, first: $first, filter: $filter) {
|
|
@@ -61,16 +61,16 @@
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
`,Se=
|
|
65
|
-
${
|
|
64
|
+
`,Se=o`
|
|
65
|
+
${b}
|
|
66
66
|
|
|
67
67
|
query GamesByName($search: String!, $filter: GameFilterInput, $first: Int) {
|
|
68
68
|
gamesByName(search: $search, filter: $filter, first: $first) {
|
|
69
69
|
...GameFragment
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
`,Ae=
|
|
73
|
-
${
|
|
72
|
+
`,Ae=o`
|
|
73
|
+
${b}
|
|
74
74
|
|
|
75
75
|
query GameSession($id: ObjectId!) {
|
|
76
76
|
node(id: $id) {
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
`,Ee=
|
|
89
|
+
`,Ee=o`
|
|
90
90
|
mutation CreateGameSession($input: CreateGameSessionInput!) {
|
|
91
91
|
createGameSession(input: $input) {
|
|
92
92
|
... on GameDoesNotExistError {
|
|
@@ -95,12 +95,12 @@
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
`,ke=
|
|
98
|
+
`,ke=o`
|
|
99
99
|
mutation EndGameSession($input: EndGameSessionInput!) {
|
|
100
100
|
endGameSession(input: $input)
|
|
101
101
|
}
|
|
102
|
-
`,Ce=
|
|
103
|
-
${
|
|
102
|
+
`,Ce=o`
|
|
103
|
+
${b}
|
|
104
104
|
|
|
105
105
|
query BetRecords($first: Int, $after: Cursor, $filter: BetRecordFilterInput) {
|
|
106
106
|
member {
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
`,Te=
|
|
142
|
+
`,Te=o`
|
|
143
143
|
query LatestBetRecords {
|
|
144
144
|
latestBetRecords {
|
|
145
145
|
id
|
|
@@ -158,15 +158,15 @@
|
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
${
|
|
162
|
-
`,A=
|
|
161
|
+
${b}
|
|
162
|
+
`,A=o`
|
|
163
163
|
fragment FileFragment on File {
|
|
164
164
|
id
|
|
165
165
|
url
|
|
166
166
|
status
|
|
167
167
|
dateTimeCreated
|
|
168
168
|
}
|
|
169
|
-
`,
|
|
169
|
+
`,T=o`
|
|
170
170
|
${A}
|
|
171
171
|
|
|
172
172
|
query File($id: ObjectId!) {
|
|
@@ -176,7 +176,7 @@
|
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
-
`;
|
|
179
|
+
`;o`
|
|
180
180
|
mutation UploadPrivateImageFile($input: UploadFileInput!) {
|
|
181
181
|
uploadPrivateImageFile(input: $input) {
|
|
182
182
|
... on FileFormatNotSupportedError {
|
|
@@ -193,7 +193,7 @@
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
`;const
|
|
196
|
+
`;const _=o`
|
|
197
197
|
${A}
|
|
198
198
|
|
|
199
199
|
fragment CashbackFragment on Cashback {
|
|
@@ -209,15 +209,15 @@
|
|
|
209
209
|
dateTimeCreated
|
|
210
210
|
dateTimeLastUpdated
|
|
211
211
|
}
|
|
212
|
-
`,
|
|
213
|
-
${
|
|
212
|
+
`,_e=o`
|
|
213
|
+
${_}
|
|
214
214
|
|
|
215
215
|
query Cashbacks {
|
|
216
216
|
cashbacks {
|
|
217
217
|
...CashbackFragment
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
-
`,E=
|
|
220
|
+
`,E=o`
|
|
221
221
|
${A}
|
|
222
222
|
|
|
223
223
|
fragment PromoFragment on Promo {
|
|
@@ -236,7 +236,7 @@
|
|
|
236
236
|
dateTimeCreated
|
|
237
237
|
dateTimeLastUpdated
|
|
238
238
|
}
|
|
239
|
-
`,
|
|
239
|
+
`,ve=o`
|
|
240
240
|
${E}
|
|
241
241
|
|
|
242
242
|
query Promos {
|
|
@@ -244,7 +244,7 @@
|
|
|
244
244
|
...PromoFragment
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
|
-
`,De=
|
|
247
|
+
`,De=o`
|
|
248
248
|
${E}
|
|
249
249
|
|
|
250
250
|
query AvailablePromos($filter: PromoFilterInput) {
|
|
@@ -252,7 +252,7 @@
|
|
|
252
252
|
...PromoFragment
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
|
-
`,Me=
|
|
255
|
+
`,Me=o`
|
|
256
256
|
${E}
|
|
257
257
|
|
|
258
258
|
query Bonus {
|
|
@@ -281,8 +281,8 @@
|
|
|
281
281
|
dateTimeLastUpdated
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
|
-
`,Re=
|
|
285
|
-
${
|
|
284
|
+
`,Re=o`
|
|
285
|
+
${_}
|
|
286
286
|
|
|
287
287
|
query CashbackBonuses {
|
|
288
288
|
cashbackBonuses {
|
|
@@ -295,7 +295,7 @@
|
|
|
295
295
|
dateTimeLastUpdated
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
-
`,Ne=
|
|
298
|
+
`,Ne=o`
|
|
299
299
|
mutation ClaimCashbackBonus($input: ClaimCashbackBonusInput!) {
|
|
300
300
|
claimCashbackBonus(input: $input) {
|
|
301
301
|
... on CashbackBonusDoesNotExistError {
|
|
@@ -304,7 +304,7 @@
|
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
|
-
`,Ie=
|
|
307
|
+
`,Ie=o`
|
|
308
308
|
query DepositRecords($after: Cursor, $first: Int, $filter: DepositRecordFilterInput) {
|
|
309
309
|
member {
|
|
310
310
|
depositRecords(after: $after, first: $first, filter: $filter) {
|
|
@@ -333,7 +333,7 @@
|
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
`,Ge=
|
|
336
|
+
`,Ge=o`
|
|
337
337
|
mutation CreateGCashDeposit($input: CreateGCashDepositInput!) {
|
|
338
338
|
createGCashDeposit(input: $input) {
|
|
339
339
|
... on DepositPromoMaximumAmountExceededError {
|
|
@@ -370,7 +370,7 @@
|
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
372
|
}
|
|
373
|
-
`,Pe=
|
|
373
|
+
`,Pe=o`
|
|
374
374
|
mutation CreateMayaDeposit($input: CreateMayaDepositInput!) {
|
|
375
375
|
createMayaDeposit(input: $input) {
|
|
376
376
|
... on DepositPromoMaximumAmountExceededError {
|
|
@@ -407,7 +407,7 @@
|
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
|
-
`,$e=
|
|
410
|
+
`,$e=o`
|
|
411
411
|
mutation CreateMayaAppDeposit($input: CreateMayaAppDepositInput!) {
|
|
412
412
|
createMayaAppDeposit(input: $input) {
|
|
413
413
|
... on DepositPromoMaximumAmountExceededError {
|
|
@@ -444,7 +444,7 @@
|
|
|
444
444
|
}
|
|
445
445
|
}
|
|
446
446
|
}
|
|
447
|
-
`,Ue=
|
|
447
|
+
`,Ue=o`
|
|
448
448
|
query Deposit($id: ObjectId!) {
|
|
449
449
|
node(id: $id) {
|
|
450
450
|
... on GCashDeposit {
|
|
@@ -485,19 +485,19 @@
|
|
|
485
485
|
}
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
|
-
`,We=
|
|
488
|
+
`,We=o`
|
|
489
489
|
query DepositsCount {
|
|
490
490
|
member {
|
|
491
491
|
depositsCount
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
|
-
`,Be=
|
|
494
|
+
`,Be=o`
|
|
495
495
|
query Member {
|
|
496
496
|
member {
|
|
497
497
|
dateTimeLastActive
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
|
-
`,xe=
|
|
500
|
+
`,xe=o`
|
|
501
501
|
query MemberAccount {
|
|
502
502
|
memberAccount: self {
|
|
503
503
|
... on MemberAccount {
|
|
@@ -520,7 +520,7 @@
|
|
|
520
520
|
}
|
|
521
521
|
}
|
|
522
522
|
}
|
|
523
|
-
`,Oe=
|
|
523
|
+
`,Oe=o`
|
|
524
524
|
${A}
|
|
525
525
|
|
|
526
526
|
query MemberVerification {
|
|
@@ -544,7 +544,7 @@
|
|
|
544
544
|
}
|
|
545
545
|
}
|
|
546
546
|
}
|
|
547
|
-
`,qe=
|
|
547
|
+
`,qe=o`
|
|
548
548
|
mutation RegisterMemberAccount(
|
|
549
549
|
$input: RegisterMemberAccountInput!
|
|
550
550
|
$referralCode: String
|
|
@@ -587,7 +587,7 @@
|
|
|
587
587
|
}
|
|
588
588
|
}
|
|
589
589
|
}
|
|
590
|
-
`,Fe=
|
|
590
|
+
`,Fe=o`
|
|
591
591
|
mutation UpdateMemberAccount($input: UpdateMemberAccountInput!) {
|
|
592
592
|
updateMemberAccount(input: $input) {
|
|
593
593
|
... on AccountNameNotAvailableError {
|
|
@@ -620,7 +620,7 @@
|
|
|
620
620
|
}
|
|
621
621
|
}
|
|
622
622
|
}
|
|
623
|
-
`,Le=
|
|
623
|
+
`,Le=o`
|
|
624
624
|
mutation ResetPassword($input: ResetPasswordInput!, $verificationCode: String) {
|
|
625
625
|
resetPassword(input: $input, verificationCode: $verificationCode) {
|
|
626
626
|
... on AccountNotFoundError {
|
|
@@ -633,11 +633,11 @@
|
|
|
633
633
|
}
|
|
634
634
|
}
|
|
635
635
|
}
|
|
636
|
-
`,Ve=
|
|
636
|
+
`,Ve=o`
|
|
637
637
|
mutation DeleteMemberAccount($input: DeleteMemberAccountInput!) {
|
|
638
638
|
deleteMemberAccount(input: $input)
|
|
639
639
|
}
|
|
640
|
-
`,He=
|
|
640
|
+
`,He=o`
|
|
641
641
|
mutation SendVerificationCode($input: SendVerificationCodeInput!) {
|
|
642
642
|
sendVerificationCode(input: $input) {
|
|
643
643
|
... on InvalidPlatformError {
|
|
@@ -650,7 +650,7 @@
|
|
|
650
650
|
}
|
|
651
651
|
}
|
|
652
652
|
}
|
|
653
|
-
`,Ye=
|
|
653
|
+
`,Ye=o`
|
|
654
654
|
mutation VerifyMobileNumber($input: VerifyMobileNumberInput!) {
|
|
655
655
|
verifyMobileNumber(input: $input) {
|
|
656
656
|
... on InvalidSMSVerificationCodeError {
|
|
@@ -663,7 +663,7 @@
|
|
|
663
663
|
}
|
|
664
664
|
}
|
|
665
665
|
}
|
|
666
|
-
`,je=
|
|
666
|
+
`,je=o`
|
|
667
667
|
mutation CreateMemberVerification($input: CreateMemberVerificationInput!) {
|
|
668
668
|
createMemberVerification(input: $input) {
|
|
669
669
|
... on FileDoesNotExistError {
|
|
@@ -680,7 +680,7 @@
|
|
|
680
680
|
}
|
|
681
681
|
}
|
|
682
682
|
}
|
|
683
|
-
`,Qe=
|
|
683
|
+
`,Qe=o`
|
|
684
684
|
mutation UpdateMemberVerification($input: UpdateMemberVerificationInput!) {
|
|
685
685
|
updateMemberVerification(input: $input) {
|
|
686
686
|
... on FileDoesNotExistError {
|
|
@@ -701,7 +701,7 @@
|
|
|
701
701
|
}
|
|
702
702
|
}
|
|
703
703
|
}
|
|
704
|
-
`,Ke=
|
|
704
|
+
`,Ke=o`
|
|
705
705
|
query ProfileCompletion {
|
|
706
706
|
profileCompletion {
|
|
707
707
|
completionPercentage
|
|
@@ -712,7 +712,7 @@
|
|
|
712
712
|
accountPassword
|
|
713
713
|
}
|
|
714
714
|
}
|
|
715
|
-
`,ze=
|
|
715
|
+
`,ze=o`
|
|
716
716
|
fragment DepositGatewaySettingsCoreData on DepositGatewaySettings {
|
|
717
717
|
minimumAmount
|
|
718
718
|
maximumAmount
|
|
@@ -766,7 +766,7 @@
|
|
|
766
766
|
multiplier
|
|
767
767
|
}
|
|
768
768
|
}
|
|
769
|
-
`,Je=
|
|
769
|
+
`,Je=o`
|
|
770
770
|
query PointsWallet {
|
|
771
771
|
pointsWallet {
|
|
772
772
|
id
|
|
@@ -775,7 +775,7 @@
|
|
|
775
775
|
dateTimeCreated
|
|
776
776
|
}
|
|
777
777
|
}
|
|
778
|
-
`,Ze=
|
|
778
|
+
`,Ze=o`
|
|
779
779
|
mutation PointsToCashConversion($input: PointsToCashConversionInput!) {
|
|
780
780
|
pointsToCashConversion(input: $input) {
|
|
781
781
|
... on InsufficientPointsError {
|
|
@@ -784,7 +784,7 @@
|
|
|
784
784
|
}
|
|
785
785
|
}
|
|
786
786
|
}
|
|
787
|
-
`,Xe=
|
|
787
|
+
`,Xe=o`
|
|
788
788
|
query TransactionRecords($first: Int, $after: Cursor, $filter: TransactionRecordFilter) {
|
|
789
789
|
member {
|
|
790
790
|
transactionRecords(first: $first, after: $after, filter: $filter) {
|
|
@@ -810,7 +810,7 @@
|
|
|
810
810
|
}
|
|
811
811
|
}
|
|
812
812
|
}
|
|
813
|
-
`,et=
|
|
813
|
+
`,et=o`
|
|
814
814
|
query Wallet {
|
|
815
815
|
wallet {
|
|
816
816
|
id
|
|
@@ -820,7 +820,7 @@
|
|
|
820
820
|
dateTimeLastUpdated
|
|
821
821
|
}
|
|
822
822
|
}
|
|
823
|
-
`,tt=
|
|
823
|
+
`,tt=o`
|
|
824
824
|
query WithdrawalRecords($first: Int, $after: Cursor, $filter: WithdrawalRecordFilterInput) {
|
|
825
825
|
member {
|
|
826
826
|
withdrawalRecords(first: $first, after: $after, filter: $filter) {
|
|
@@ -887,7 +887,7 @@
|
|
|
887
887
|
}
|
|
888
888
|
}
|
|
889
889
|
}
|
|
890
|
-
`,at=
|
|
890
|
+
`,at=o`
|
|
891
891
|
mutation CreateGCashWithdrawal($input: CreateGCashWithdrawalInput!) {
|
|
892
892
|
createGCashWithdrawal(input: $input) {
|
|
893
893
|
... on AccountNotVerifiedError {
|
|
@@ -916,7 +916,7 @@
|
|
|
916
916
|
}
|
|
917
917
|
}
|
|
918
918
|
}
|
|
919
|
-
`,rt=
|
|
919
|
+
`,rt=o`
|
|
920
920
|
mutation CreateMayaWithdrawal($input: CreateMayaWithdrawalInput!) {
|
|
921
921
|
createMayaWithdrawal(input: $input) {
|
|
922
922
|
... on AccountNotVerifiedError {
|
|
@@ -945,7 +945,7 @@
|
|
|
945
945
|
}
|
|
946
946
|
}
|
|
947
947
|
}
|
|
948
|
-
`,
|
|
948
|
+
`,nt=o`
|
|
949
949
|
mutation CreateMayaAppWithdrawal($input: CreateMayaAppWithdrawalInput!) {
|
|
950
950
|
createMayaAppWithdrawal(input: $input) {
|
|
951
951
|
... on AccountNotVerifiedError {
|
|
@@ -970,7 +970,7 @@
|
|
|
970
970
|
}
|
|
971
971
|
}
|
|
972
972
|
}
|
|
973
|
-
`,
|
|
973
|
+
`,ot=o`
|
|
974
974
|
mutation CreateBankWithdrawal($input: CreateBankWithdrawalInput!) {
|
|
975
975
|
createBankWithdrawal(input: $input) {
|
|
976
976
|
... on MobileNumberNotVerifiedError {
|
|
@@ -999,9 +999,9 @@
|
|
|
999
999
|
}
|
|
1000
1000
|
}
|
|
1001
1001
|
}
|
|
1002
|
-
`,it=
|
|
1002
|
+
`,it=o`
|
|
1003
1003
|
query RemainingDailyWithdrawalsCount {
|
|
1004
1004
|
remainingDailyWithdrawalsCount
|
|
1005
1005
|
}
|
|
1006
|
-
`;class st{constructor(e){c(this,"client");this.client=e}async memberAccount(){const e=await this.client.request(xe);return e.ok?{ok:!0,data:e.data.memberAccount}:e}async registerMemberAccount(e){const t=await this.client.request(qe,e);return t.ok?t.data.registerMemberAccount?{ok:!1,error:t.data.registerMemberAccount}:{ok:!0}:t}async updateMemberAccount(e){const t=await this.client.request(Fe,e);return t.ok?t.data.updateMemberAccount?{ok:!1,error:t.data.updateMemberAccount}:{ok:!0}:t}async deleteMemberAccount(e){const t=await this.client.request(Ve,e);return t.ok?t.data.deleteMemberAccount?{ok:!0}:{ok:!1,error:{code:"UnknownError",message:"Something went wrong."}}:t}async resetPassword(e){const t=await this.client.request(Le,e);return t.ok?t.data.resetPassword?{ok:!1,error:t.data.resetPassword}:{ok:!0}:t}async profileCompletion(){const e=await this.client.request(Ke);return e.ok?{ok:!0,data:e.data.profileCompletion}:e}async platform(){return await this.client.request(ze)}async sendVerificationCode(e){const t=await this.client.request(He,e);return t.ok?t.data.sendVerificationCode?{ok:!1,error:t.data.sendVerificationCode}:{ok:!0}:t}async verifyMobileNumber(e){const t=await this.client.request(Ye,e);return t.ok?t.data.verifyMobileNumber?{ok:!1,error:t.data.verifyMobileNumber}:{ok:!0}:t}async createMemberVerification(e){const t=await this.client.request(je,e);return t.ok?t.data.createMemberVerification?{ok:!1,error:t.data.createMemberVerification}:{ok:!0}:t}async updateMemberVerification(e){const t=await this.client.request(Qe,e);return t.ok?t.data.updateMemberVerification?{ok:!1,error:t.data.updateMemberVerification}:{ok:!0}:t}async memberVerification(){const e=await this.client.request(Oe);return e.ok?{ok:!0,data:e.data.memberAccount.verification}:e}async announcements(e){const t=await this.client.request(ge,e);return t.ok?{ok:!0,data:t.data.announcements}:t}}function h(i,e){const t=dt[i];return{code:t.code,message:e??t.message}}const dt={400:{code:"HttpBadRequest",message:"Bad Request"},401:{code:"HttpUnauthorized",message:"Unauthorized"},403:{code:"HttpForbidden",message:"Forbidden"},404:{code:"HttpNotFound",message:"Not Found"},408:{code:"HttpRequestTimeout",message:"Request Timeout"},429:{code:"HttpTooManyRequests",message:"Too Many Requests"},500:{code:"HttpInternalServerError",message:"Internal Server Error"},503:{code:"HttpServiceUnavailable",message:"Service Unavailable"}};async function g(i){const e=new TextEncoder().encode(i),t=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(t)).map(d=>d.toString(16).padStart(2,"0")).join("")}class ct{constructor(e){c(this,"url");c(this,"platform");this.url=e.url,this.platform=e.platform}async createSession(e){const t=new Headers;if(t.set("Content-Type","application/json"),t.set("Platform-Code",this.platform),t.set("Role","MEMBER"),"name"in e){const a=`${e.name}:${await g(e.password)}`,o=Buffer.from(a).toString("base64");t.set("Authorization",`Basic ${o}`)}if("mobileNumber"in e){const a=`${e.mobileNumber}:${e.verificationCode}`,o=Buffer.from(a).toString("base64");t.set("Authorization",`Basic ${o}`)}try{const a=await fetch(`${this.url}/sessions`,{method:"POST",headers:t}),o=await a.json();return a.status===401||a.status===403?o.code==="ACCOUNT_BLACKLISTED"?{ok:!1,error:{code:"AccountBlacklisted",message:"Account is blacklisted"}}:{ok:!1,error:{code:"AccountNotFound",message:"Account not found."}}:a.ok?{ok:!0,data:o}:{ok:!1,error:h(a.status)}}catch{return{ok:!1,error:{code:"UnknownError",message:"Something went wrong."}}}}async refreshSession(e){try{const t=await fetch(`${this.url}/session:refresh`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`,"Platform-Code":this.platform,Role:"MEMBER"}}),a=await t.json();return t.status===401||t.status===403?a.code==="ACCOUNT_BLACKLISTED"?{ok:!1,error:{code:"AccountBlacklisted",message:"Account is blacklisted"}}:{ok:!1,error:{code:"InvalidToken",message:"Invalid token."}}:t.ok?{ok:!0,data:a}:{ok:!1,error:h(t.status)}}catch{return{ok:!1,error:{code:"UnknownError",message:"Something went wrong."}}}}async destroySession(e){try{const t=await fetch(`${this.url}/session`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`,"Platform-Code":this.platform,Role:"MEMBER"}});return t.ok?{ok:!0}:{ok:!1,error:h(t.status)}}catch{return{ok:!1,error:{code:"UnknownError",message:"Something went wrong."}}}}async verifySession(e){try{const t=await fetch(`${this.url}/session`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`,"Platform-Code":this.platform,Role:"MEMBER"}});if(t.status===403||t.status===401)return!1}catch{}return!0}}class mt{constructor(e){c(this,"client");this.client=e}async file(e){const t=await this.client.request(C,e);return t.ok?{ok:!0,data:t.data.node}:t}async uploadPrivateImageFile(e){const t=await this.client.upload(C,e);return t.ok?t.data.uploadPrivateImageFile?{ok:!1,error:t.data.uploadPrivateImageFile}:{ok:!0}:t}}class v{constructor(e){c(this,"client");this.client=e}async game(e){const t=await this.client.request(ye,e);return t.ok?{ok:!0,data:t.data.node}:t}async games(e){const t=await this.client.request(be,e);return t.ok?{ok:!0,data:t.data.games}:t}async gamesByName(e){const t=await this.client.request(Se,e);return t.ok?{ok:!0,data:t.data.gamesByName}:t}async gameSession(e){const t=await this.client.request(Ae,e);return t.ok?{ok:!0,data:t.data.node}:t}async createGameSession(e){const t=await this.client.request(Ee,e);return t.ok?t.data.createGameSession?{ok:!1,error:t.data.createGameSession}:{ok:!0}:t}async endGameSession(e){const t=await this.client.request(ke,e);return t.ok?t.data.endGameSession?{ok:!0}:{ok:!1,error:{code:"UnknownError",message:"Something went wrong."}}:t}}class ut{constructor(e){c(this,"client");this.client=e}async betRecords(e){const t=await this.client.request(Ce,e);return t.ok?{ok:t.ok,data:t.data.member.betRecords}:t}async transactionRecords(e){const t=await this.client.request(Xe,e);return t.ok?{ok:t.ok,data:t.data.member.transactionRecords}:t}async withdrawalRecords(e){const t=await this.client.request(tt,e);return t.ok?{ok:t.ok,data:t.data.member.withdrawalRecords}:t}async depositRecords(e){const t=await this.client.request(Ie,e);return t.ok?{ok:t.ok,data:t.data.member.depositRecords}:t}async depositsCount(){const e=await this.client.request(We);return e.ok?{ok:e.ok,data:e.data.member.depositsCount}:e}async member(){const e=await this.client.request(Be);return e.ok?{ok:e.ok,data:e.data.member}:e}}class lt{constructor(e){c(this,"url");this.url=e.url}gameThumbnails(e){return[`${this.url}/images/${e.provider.toLowerCase()}/thumbnail-${e.id}.webp`,`${this.url}/images/${e.provider.toLowerCase()}/thumbnail-${e.provider.toLowerCase()}.webp`]}}class pt extends v{async promos(){const e=await this.client.request(_e);return e.ok?{ok:e.ok,data:e.data.promos}:e}async cashbacks(){const e=await this.client.request(ve);return e.ok?{ok:e.ok,data:e.data.cashbacks}:e}async availablePromos(e){const t=await this.client.request(De,e);return t.ok?{ok:t.ok,data:t.data.availablePromos}:t}async cashbackBonuses(){const e=await this.client.request(Re);return e.ok?{ok:e.ok,data:e.data.cashbackBonuses}:e}async claimCashbackBonus(e){const t=await this.client.request(Ne,e);return t.ok?t.data.claimCashbackBonus?{ok:!1,error:t.data.claimCashbackBonus}:{ok:!0}:{ok:t.ok,error:t.error}}async bonus(){const e=await this.client.request(Me);return e.ok?{ok:e.ok,data:e.data.bonus}:e}async wallet(){const e=await this.client.request(et);return e.ok?{ok:e.ok,data:e.data.wallet}:e}async deposit(e){const t=await this.client.request(Ue,e);return t.ok?{ok:t.ok,data:t.data.node}:t}async createGCashDeposit(e){const t=await this.client.request(Ge,e);return t.ok?t.data.createGCashDeposit?{ok:!1,error:t.data.createGCashDeposit}:{ok:!0}:t}async createMayaDeposit(e){const t=await this.client.request(Pe,e);return t.ok?t.data.createMayaDeposit?{ok:!1,error:t.data.createMayaDeposit}:{ok:!0}:t}async createMayaAppDeposit(e){const t=await this.client.request($e,e);return t.ok?t.data.createMayaAppDeposit?{ok:!1,error:t.data.createMayaAppDeposit}:{ok:!0}:t}async createGCashWithdrawal(e){const t=await this.client.request(at,e);return t.ok?t.data.createGCashWithdrawal?{ok:!1,error:t.data.createGCashWithdrawal}:{ok:!0}:t}async createMayaWithdrawal(e){const t=await this.client.request(rt,e);return t.ok?t.data.createMayaWithdrawal?{ok:!1,error:t.data.createMayaWithdrawal}:{ok:!0}:t}async createMayaAppWithdrawal(e){const t=await this.client.request(ot,e);return t.ok?t.data.createMayaAppWithdrawal?{ok:!1,error:t.data.createMayaAppWithdrawal}:{ok:!0}:t}async createBankWithdrawal(e){const t=await this.client.request(nt,e);return t.ok?t.data.createBankWithdrawal?{ok:!1,error:t.data.createBankWithdrawal}:{ok:!0}:t}async remainingDailyWithdrawalsCount(){const e=await this.client.request(it);return e.ok?{ok:e.ok,data:e.data.remainingDailyWithdrawalsCount}:e}async pointsWallet(){const e=await this.client.request(Je);return e.ok?{ok:e.ok,data:e.data.pointsWallet}:e}async pointsToCashConversion(e){const t=await this.client.request(Ze,e);return t.ok?t.data.pointsToCashConversion?{ok:!1,error:t.data.pointsToCashConversion}:{ok:!0}:t}}class ft{constructor(e){c(this,"client");this.client=e}async latestBetRecords(){const e=await this.client.request(Te);return e.ok?{ok:!0,data:e.data.latestBetRecords}:e}}class _{constructor(e){c(this,"enabled");this.enabled=(e==null?void 0:e.enabled)??!0}info(e){this.enabled&&console.log(`\x1B[34m[info] ${e}`)}warn(e){this.enabled&&console.log(`\x1B[33m[warn] ${e}`)}error(e){this.enabled&&console.log(`\x1B[31m[error] ${e}`)}success(e){this.enabled&&console.log(`\x1B[32m[success] ${e}`)}}function k(i){return new Date(i.getTime())}function D(i,e){const t=k(i);return t.setDate(t.getDate()+e),t}function M(i,e){const t=k(i);return t.setMinutes(t.getMinutes()+e),t}function R(i,e){return i.getTime()>e.getTime()}function N(i,e){const t=k(i);return t.setMinutes(t.getMinutes()-e),t}class ht{constructor(e){c(this,"logger");c(this,"storageKey","session");c(this,"authService");this.logger=new _,this.authService=new ct(e)}async create(e){const t=await this.authService.createSession(e);if(t.ok){const a=new Date;return this.isServer?this.logger.warn("'localStorage' is not available on the server."):window.localStorage.setItem(this.storageKey,JSON.stringify({...t.data,accessTokenExpiresAt:M(a,8).getTime(),refreshTokenExpiresAt:N(D(a,30),2).getTime()})),{ok:!0}}else return t}async session(){if(this.isServer)return this.logger.warn("'localStorage' is not available on the server."),{ok:!0,data:null};const e=window.localStorage.getItem(this.storageKey);if(!e)return{ok:!0,data:null};try{let t=JSON.parse(e),a=new Date;const o=new Date(t.accessTokenExpiresAt),d=new Date(t.refreshTokenExpiresAt);if(R(a,d))return this.logger.warn("Session expired. Logging out.."),window.localStorage.removeItem(this.storageKey),{ok:!1,error:{code:"SessionExpired",message:"Session expired."}};if(R(a,o)){const m=await this.authService.refreshSession(t.refreshToken);if(this.logger.info("Refreshing session..."),!m.ok)return this.logger.error(`Failed to refresh session: ${m.error.message}`),m.error.code==="InvalidToken"||m.error.code==="AccountBlacklisted"?(window.localStorage.removeItem(this.storageKey),{ok:!1,error:m.error}):(this.logger.warn("Old session returned."),{ok:!0,data:t});this.logger.success("Session refreshed!"),a=new Date,t={...t,...m.data,accessTokenExpiresAt:M(a,8).getTime(),refreshTokenExpiresAt:N(D(a,30),2).getTime()},window.localStorage.setItem(this.storageKey,JSON.stringify(t))}return{ok:!0,data:t}}catch{return{ok:!1,error:{code:"UnknownError",message:"Something went wrong."}}}}async destroy(){var t;if(this.isServer){this.logger.warn("'localStorage' is not available on the server.");return}const e=await this.session();(t=e.data)!=null&&t.accessToken&&await this.authService.destroySession(e.data.accessToken),window.localStorage.removeItem(this.storageKey)}async verify(){var a,o,d;if(this.isServer)return this.logger.warn("'localStorage' is not available on the server."),!0;const e=await this.session();if(((a=e.error)==null?void 0:a.code)==="InvalidToken"||((o=e.error)==null?void 0:o.code)==="SessionExpired"||((d=e.error)==null?void 0:d.code)==="AccountBlacklisted")return!1;if(!e.data)return!0;const t=await this.authService.verifySession(e.data.accessToken);return t||window.localStorage.removeItem(this.storageKey),t}get isServer(){return typeof window>"u"}}function r(i,e){if(typeof i=="number"&&!Number.isNaN(i))return i;if(typeof i=="string"){const t=Number.parseFloat(i);if(!Number.isNaN(t))return t}return e}class wt{constructor(e){c(this,"staticService");const t=(e==null?void 0:e.environment)==="development";this.staticService=new lt({url:t?"https://static.development.opexa.io/graphql":"https://static.opexa.io/graphql"})}get transform(){return{platform:this.platform.bind(this),account:this.account.bind(this),wallet:this.wallet.bind(this),verificationDetails:this.verificationDetails.bind(this),profileCompletion:this.profileCompletion.bind(this),announcement:this.announcement.bind(this),withdrawalRecord:this.withdrawalRecord.bind(this),deposit:this.deposit.bind(this),depositRecord:this.depositRecord.bind(this),betRecord:this.betRecord.bind(this),latestBetRecord:this.latestBetRecord.bind(this),transactionRecord:this.transactionRecord.bind(this),game:this.game.bind(this),gameSession:this.gameSession.bind(this),promo:this.promo.bind(this),cashback:this.cashback.bind(this),bonus:this.bonus.bind(this),cashbackBonus:this.cashbackBonus.bind(this),file:this.file.bind(this),pointsWallet:this.pointsWallet.bind(this)}}platform(e){var t,a,o,d,m,p,w,s,b,I,G,P,$,U,W,B,x,O,q,F,L,V,H,Y,j,Q,K,z,J,Z,X,ee,te,ae,re,oe,ne,ie,se,de,ce,me,ue,le,pe,fe,he,we;return{paymentSettings:{minimumFirstDepositAmount:r(e.minimumFirstDepositAmount),restrictWithdrawalsToVerifiedMembers:e.restrictWithdrawalsToVerifiedMembers,depositGateway:{bank:{androidEnabled:((t=e.bankDepositGatewaySettings)==null?void 0:t.androidEnabled)??!1,iosEnabled:((a=e.bankDepositGatewaySettings)==null?void 0:a.iosEnabled)??!1,webEnabled:((o=e.bankDepositGatewaySettings)==null?void 0:o.webEnabled)??!1,mobileWebEnabled:((d=e.bankDepositGatewaySettings)==null?void 0:d.mobileWebEnabled)??!1,minimumAmount:r((m=e.bankDepositGatewaySettings)==null?void 0:m.minimumAmount),maximumAmount:r((p=e.bankDepositGatewaySettings)==null?void 0:p.maximumAmount)},gcash:{androidEnabled:((w=e.gcashDepositGatewaySettings)==null?void 0:w.androidEnabled)??!1,iosEnabled:((s=e.gcashDepositGatewaySettings)==null?void 0:s.iosEnabled)??!1,webEnabled:((b=e.gcashDepositGatewaySettings)==null?void 0:b.webEnabled)??!1,mobileWebEnabled:((I=e.gcashDepositGatewaySettings)==null?void 0:I.mobileWebEnabled)??!1,minimumAmount:r((G=e.gcashDepositGatewaySettings)==null?void 0:G.minimumAmount),maximumAmount:r((P=e.gcashDepositGatewaySettings)==null?void 0:P.maximumAmount)},maya:{androidEnabled:(($=e.mayaDepositGatewaySettings)==null?void 0:$.androidEnabled)??!1,iosEnabled:((U=e.mayaDepositGatewaySettings)==null?void 0:U.iosEnabled)??!1,webEnabled:((W=e.mayaDepositGatewaySettings)==null?void 0:W.webEnabled)??!1,mobileWebEnabled:((B=e.mayaDepositGatewaySettings)==null?void 0:B.mobileWebEnabled)??!1,minimumAmount:r((x=e.mayaDepositGatewaySettings)==null?void 0:x.minimumAmount),maximumAmount:r((O=e.mayaDepositGatewaySettings)==null?void 0:O.maximumAmount)},mayaApp:{androidEnabled:((q=e.mayaAppDepositGatewaySettings)==null?void 0:q.androidEnabled)??!1,iosEnabled:((F=e.mayaAppDepositGatewaySettings)==null?void 0:F.iosEnabled)??!1,webEnabled:((L=e.mayaAppDepositGatewaySettings)==null?void 0:L.webEnabled)??!1,mobileWebEnabled:((V=e.mayaAppDepositGatewaySettings)==null?void 0:V.mobileWebEnabled)??!1,minimumAmount:r((H=e.mayaAppDepositGatewaySettings)==null?void 0:H.minimumAmount),maximumAmount:r((Y=e.mayaAppDepositGatewaySettings)==null?void 0:Y.maximumAmount)}},withdrawalGateway:{bank:{androidEnabled:((j=e.bankWithdrawalGatewaySettings)==null?void 0:j.androidEnabled)??!1,iosEnabled:((Q=e.bankWithdrawalGatewaySettings)==null?void 0:Q.iosEnabled)??!1,webEnabled:((K=e.bankWithdrawalGatewaySettings)==null?void 0:K.webEnabled)??!1,mobileWebEnabled:((z=e.bankWithdrawalGatewaySettings)==null?void 0:z.mobileWebEnabled)??!1,minimumAmount:r((J=e.bankWithdrawalGatewaySettings)==null?void 0:J.minimumAmount),maximumAmount:r((Z=e.bankWithdrawalGatewaySettings)==null?void 0:Z.maximumAmount)},gcash:{androidEnabled:((X=e.gcashWithdrawalGatewaySettings)==null?void 0:X.androidEnabled)??!1,iosEnabled:((ee=e.gcashWithdrawalGatewaySettings)==null?void 0:ee.iosEnabled)??!1,webEnabled:((te=e.gcashWithdrawalGatewaySettings)==null?void 0:te.webEnabled)??!1,mobileWebEnabled:((ae=e.gcashWithdrawalGatewaySettings)==null?void 0:ae.mobileWebEnabled)??!1,minimumAmount:r((re=e.gcashWithdrawalGatewaySettings)==null?void 0:re.minimumAmount),maximumAmount:r((oe=e.gcashWithdrawalGatewaySettings)==null?void 0:oe.maximumAmount,1e6)},maya:{androidEnabled:((ne=e.mayaWithdrawalGatewaySettings)==null?void 0:ne.androidEnabled)??!1,iosEnabled:((ie=e.mayaWithdrawalGatewaySettings)==null?void 0:ie.iosEnabled)??!1,webEnabled:((se=e.mayaWithdrawalGatewaySettings)==null?void 0:se.webEnabled)??!1,mobileWebEnabled:((de=e.mayaWithdrawalGatewaySettings)==null?void 0:de.mobileWebEnabled)??!1,minimumAmount:r((ce=e.mayaWithdrawalGatewaySettings)==null?void 0:ce.minimumAmount),maximumAmount:r((me=e.mayaWithdrawalGatewaySettings)==null?void 0:me.maximumAmount)},mayaApp:{androidEnabled:((ue=e.mayaAppWithdrawalGatewaySettings)==null?void 0:ue.androidEnabled)??!1,iosEnabled:((le=e.mayaAppWithdrawalGatewaySettings)==null?void 0:le.iosEnabled)??!1,webEnabled:((pe=e.mayaAppWithdrawalGatewaySettings)==null?void 0:pe.webEnabled)??!1,mobileWebEnabled:((fe=e.mayaAppWithdrawalGatewaySettings)==null?void 0:fe.mobileWebEnabled)??!1,minimumAmount:r((he=e.mayaAppWithdrawalGatewaySettings)==null?void 0:he.minimumAmount),maximumAmount:r((we=e.mayaAppWithdrawalGatewaySettings)==null?void 0:we.maximumAmount,1e6)}}},pointsClubSettings:{multiplier:r(e.pointsClubSettings.multiplier,0)}}}account(e){return{id:e.id,name:e.name,status:e.status,verified:e.verified,nickName:e.nickName??void 0,realName:e.realName??void 0,dateOfBirth:e.birthDay?new Date(e.birthDay):void 0,emailAddress:e.emailAddress??void 0,mobileNumber:e.mobileNumber??void 0,mobileNumberVerified:e.mobileNumberVerified??!1,mobileNumberVerificationRequired:e.mobileNumberVerificationRequired??!1,validId:e.validId??void 0,verificationStatus:e.verificationStatus,transactionPassword:e.transactionPassword,dateTimeLastActive:e.dateTimeLastActive?new Date(e.dateTimeLastActive):void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}wallet(e){return{...e,balance:r(e.balance,0),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}verificationDetails(e){return{...e,idFrontImage:{...e.idFrontImage,url:e.idFrontImage.url??void 0,dateTimeCreated:new Date(e.idFrontImage.dateTimeCreated)},selfieImage:{...e.selfieImage,url:e.selfieImage.url??void 0,dateTimeCreated:new Date(e.selfieImage.dateTimeCreated)}}}profileCompletion(e){return{...e,completionPercentage:r(e,0)}}announcement(e){return{...e,activationEndDateTime:new Date(e.activationEndDateTime),activationStartDateTime:new Date(e.activationStartDateTime),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}withdrawalRecord(e){return{...e,amount:r(e.amount,0),netAmount:r(e.netAmount,0),fee:r(e.fee,0),reference:e.reference??void 0,bank:e.bank??void 0,recipientMobileNumber:e.recipientMobileNumber??void 0,dateTimeConfirmed:e.dateTimeConfirmed?new Date(e.dateTimeConfirmed):void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}deposit(e){return{...e,fee:r(e.fee,0),amount:r(e.amount,0),netAmount:r(e.netAmount,0),reference:e.reference??void 0,checkoutUrl:e.checkoutUrl??void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}depositRecord(e){return{...e,amount:r(e.amount,0),fee:r(e.fee,0),netAmount:r(e.netAmount,0),reference:e.reference??void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}betRecord(e){var t,a;return{...e,bet:r(e.bet,0),payout:r(e.payout,0),jackpotContribution:r(e.jackpotContribution,0),jackpotPayout:r(e.jackpotPayout,0),winloss:r(e.winloss),validBet:r(e.validBet,0),vendorRoundId:e.vendorRoundId??void 0,game:this.game(e.game),dateTimeSettled:e.dateTimeSettled?new Date(e.dateTimeSettled):void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated),betContent:e.betContent??void 0,contestName:e.contestName??void 0,externalCategory:e.externalCategory??void 0,metadata:{odds:((t=e.metadata)==null?void 0:t.odds)??void 0,validBet:r((a=e.metadata)==null?void 0:a.validBet)}}}latestBetRecord(e){return{...e,game:this.game(e.game),bet:r(e.bet,0),payout:r(e.payout,0),validBet:r(e.validBet,0),dateTimeSettled:new Date(e.dateTimeSettled),dateTimeCreated:new Date(e.dateTimeCreated)}}transactionRecord(e){return{...e,amount:r(e.amount,0),content:e.content??void 0,currentBalance:r(e.currentBalance,0),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}game(e){const t=this.staticService.gameThumbnails(e);return{...e,images:t,get image(){return console.warn("'game.image' is deprecated and will be removed in next version.","Please use 'game.images' instead."),t[0]}}}gameSession(e){return{...e,game:this.game(e.game),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}promo(e){return{...e,banner:{...e.banner,dateTimeCreated:new Date(e.banner.dateTimeCreated)},maximumBonusAmount:r(e.maximumBonusAmount),minimumBonusAmount:r(e.minimumBonusAmount),activationEndDateTime:new Date(e.activationEndDateTime),activationStartDateTime:new Date(e.activationStartDateTime),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}cashback(e){return{...e,banner:{...e.banner,dateTimeCreated:new Date(e.banner.dateTimeCreated)},activationEndDateTime:new Date(e.activationEndDateTime),activationStartDateTime:new Date(e.activationStartDateTime),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}bonus(e){return{...e,promo:this.promo(e.promo),deposit:e.deposit?{...e.deposit,fee:r(e.deposit.fee,0),amount:r(e.deposit.amount,0),netAmount:r(e.deposit.netAmount,0),reference:e.deposit.reference??void 0,dateTimeCreated:new Date(e.deposit.dateTimeCreated),dateTimeLastUpdated:new Date(e.deposit.dateTimeLastUpdated)}:void 0,balance:r(e.balance,0),amount:r(e.amount,0),expiration:new Date(e.expiration),turnoverRequirement:r(e.turnoverRequirement,0),currentTurnoverRequirementContribution:r(e.currentTurnoverRequirementContribution,0),currentTurnoverRequirementContributionPercentage:r(e.currentTurnoverRequirementContributionPercentage,0),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}cashbackBonus(e){return{id:e.id,balance:r(e.balance,0),cashback:this.cashback(e.cashback),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}file(e){return{...e,url:e.url??void 0,dateTimeCreated:new Date(e.dateTimeCreated)}}pointsWallet(e){return{id:e.id,points:r(e.points,0),account:e.account,dateTimeCreated:new Date(e.dateTimeCreated)}}}class y{constructor(e,t){c(this,"url");c(this,"options");c(this,"middlewares");var o;const a=new Headers((o=t==null?void 0:t.fetchOptions)==null?void 0:o.headers);this.url=e,this.options={...t==null?void 0:t.fetchOptions,headers:a},this.middlewares=(t==null?void 0:t.middlewares)??[]}async request(e,t){var b;const a=JSON.stringify({query:e,variables:t}),o=new Headers(this.options.headers);o.set("Content-Type","application/json"),o.set("Accept","application/json");const d=await this.runMiddlewares(new Request(this.url,{...this.options,body:a,headers:o,method:"POST"})),m=await fetch(d);if(!m.ok)return{ok:!1,error:h(m.status)};const p=await m.json(),w=p.data,s=(b=p.errors)==null?void 0:b.at(0);return(s==null?void 0:s.extensions.code)==="FORBIDDEN"?{ok:!1,error:h(403,s.message)}:(s==null?void 0:s.extensions.code)==="UNAUTHORIZED"?{ok:!1,error:h(401,s.message)}:(s==null?void 0:s.extensions.code)==="BAD_USER_INPUT"?{ok:!1,error:h(400,s.message)}:(s==null?void 0:s.extensions.code)==="INTERNAL_SERVER_ERROR"?{ok:!1,error:h(500,s.message)}:{ok:!0,data:w}}async upload(e,t){var b;const a=y.createUploadBody(e,t),o=new Headers(this.options.headers);o.set("Accept","application/json"),o.delete("Content-Type");const d=await this.runMiddlewares(new Request(this.url,{...this.options,body:a,headers:o,method:"POST"})),m=await fetch(d);if(!m.ok)return{ok:!1,error:h(m.status)};const p=await m.json(),w=p.data,s=(b=p.errors)==null?void 0:b.at(0);return(s==null?void 0:s.extensions.code)==="FORBIDDEN"?{ok:!1,error:h(403)}:(s==null?void 0:s.extensions.code)==="UNAUTHORIZED"?{ok:!1,error:h(401)}:(s==null?void 0:s.extensions.code)==="BAD_USER_INPUT"?{ok:!1,error:h(400)}:(s==null?void 0:s.extensions.code)==="INTERNAL_SERVER_ERROR"?{ok:!1,error:h(500,s.message)}:{ok:!0,data:w}}async runMiddlewares(e){let t=e.clone();for(const a of this.middlewares)t=await a(t);return t}static createUploadBody(e,t){const{files:a,others:o}=y.extractFiles(t),d=new FormData;d.append("operations",JSON.stringify({query:e,variables:t})),Object.entries(o).forEach(([p,w])=>{d.append(p,JSON.stringify(w))});const m={};return Object.keys(a).forEach((p,w)=>{m[w.toString()]=`variables.${p}`}),d.append("map",JSON.stringify(m)),Object.values(a).forEach((p,w)=>{d.append(w.toString(),p)}),d}static extractFiles(e){const t={},a={};return Object.entries(e).forEach(([o,d])=>{d instanceof File||d instanceof Blob?t[o]=d:a[o]=d}),{files:t,others:a}}}class gt{constructor(e){c(this,"gameService");c(this,"fileService");c(this,"walletService");c(this,"reportService");c(this,"portalService");c(this,"accountService");c(this,"sessionService");c(this,"transformer");c(this,"logger");const t=e.environment==="development";this.sessionService=new ht({url:t?"https://auth.development.opexa.io":"https://auth.opexa.io",platform:e.platform});const a={middlewares:[this.authMiddleware],fetchOptions:{headers:{Role:"MEMBER","Platform-Code":e.platform}}};this.gameService=new v(new y(t?"https://game.development.opexa.io/graphql":"https://game.opexa.io/graphql",a)),this.fileService=new mt(new y(t?"https://file.development.opexa.io/graphql":"https://file.opexa.io/graphql",a)),this.walletService=new pt(new y(t?"https://wallet.development.opexa.io/graphql":"https://wallet.opexa.io/graphql",a)),this.reportService=new ut(new y(t?"https://report.development.opexa.io/graphql":"https://report.opexa.io/graphql",a)),this.accountService=new st(new y(t?"https://account.development.opexa.io/graphql":"https://account.opexa.io/graphql",a)),this.portalService=new ft(new y(t?"https://portal.development.opexa.io/graphql":"https://portal.opexa.io/graphql",a)),this.transformer=new wt(e),this.logger=new _({enabled:e.log??!1})}get authMiddleware(){return async e=>{this.logger.info("Checking for session");const t=await this.sessionService.session();return t.data?(e.headers.append("Authorization",`Bearer ${t.data.accessToken}`),this.logger.info("Session found"),this.logger.success("Added 'Authorization' header")):this.logger.info("No session found"),e}}async signIn(e){const t=await this.sessionService.create(e);return t.ok?{ok:!0}:t}async signOut(){await this.sessionService.destroy()}watchSession(e){const t=e.interval??3e4,a=e.onInvalid;let o=null;const d=()=>setTimeout(async()=>{await this.sessionService.verify()||await a(),o=d()},t);return o=d(),function(){o&&clearTimeout(o)}}async session(){const e=await this.sessionService.session();return e.ok?{ok:!0,data:e.data?{id:e.data.session.id,dateTimeCreated:new Date(e.data.session.dateTimeCreated)}:null}:e}async platform(){const e=await this.accountService.platform();return e.ok?{ok:!0,data:this.transformer.transform.platform(e.data)}:e}async account(){const[e,t]=await Promise.all([this.accountService.memberAccount(),this.reportService.member()]);return e.ok?t.ok?{ok:!0,data:this.transformer.transform.account({...e.data,...t.data})}:{ok:!1,error:t.error}:{ok:!1,error:e.error}}async createAccount(e){const t=e.id??u.ObjectId.generate(f.Account).toString(),a=await this.accountService.registerMemberAccount({input:{id:t,name:e.name,birthDay:typeof e.dateOfBirth=="string"?e.dateOfBirth:e.dateOfBirth.toISOString(),password:await g(e.password),mobileNumber:this.addAreaCode(e.mobileNumber),domain:e.domain},verificationCode:e.verificationCode,reCAPTCHAResponse:e.reCAPTCHAResponse});return a.ok?{ok:!0,data:{id:t}}:a}async updateAccount(e,t){return await this.accountService.updateMemberAccount({input:{id:e,data:{...t,password:t.password?await g(t.password):void 0,transactionPassword:t.transactionPassword?await g(t.transactionPassword):void 0,...t.mobileNumber&&{mobileNumber:this.addAreaCode(t.mobileNumber)}}}})}async deleteAccount(e){return await this.accountService.deleteMemberAccount({input:{id:e}})}async verificationDetails(){const e=await this.accountService.memberVerification();return e.ok?{ok:!0,data:e.data?this.transformer.transform.verificationDetails(e.data):null}:e}async submitVerificationDetails(e){const t=e.id??u.ObjectId.generate(f.Verification).toString(),a=await this.accountService.createMemberVerification({input:{id:t,...e}});return a.ok?{ok:!0,data:{id:t}}:a}async updateVerificationDetails(e,t){return await this.accountService.updateMemberVerification({input:{id:e,data:{...t}}})}async resetPassword(e){return await this.accountService.resetPassword({input:{mobileNumber:this.addAreaCode(e.mobileNumber),newPassword:await g(e.newPassword)},verificationCode:e.verificationCode})}async verifyMobileNumber(e){return await this.accountService.verifyMobileNumber({input:{verificationCode:e}})}async profileCompletion(){const e=await this.accountService.profileCompletion();return e.ok?{ok:!0,data:this.transformer.transform.profileCompletion(e.data)}:e}async sendVerificationCode(e){return await this.accountService.sendVerificationCode({input:{channel:"SMS",recipient:this.addAreaCode(e)}})}async wallet(){const e=await this.walletService.wallet();return e.ok?{ok:!0,data:e.data?this.transformer.transform.wallet(e.data):null}:e}async announcements(e){const t=await this.accountService.announcements({...e,filter:{visibility:{in:["MEMBER","GLOBAL"]},activationStartDateTime:{greaterThanOrEqual:new Date}}});return t.ok?{ok:!0,data:{announcements:t.data.edges.map(({cursor:a,node:o})=>({...this.transformer.transform.announcement(o),cursor:a})),totalCount:t.data.totalCount,nextCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async createWithdrawal(e){const t=e.id??u.ObjectId.generate(f.Withdrawal).toString();if(e.type==="BANK"){const a=await this.walletService.createBankWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await g(e.transactionPassword)}});if(!a.ok)return a}if(e.type==="GCASH"){const a=await this.walletService.createGCashWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await g(e.transactionPassword),recipientMobileNumber:this.addAreaCode(e.recipientMobileNumber)}});if(!a.ok)return a}if(e.type==="MAYA"){const a=await this.walletService.createMayaWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await g(e.transactionPassword),recipientMobileNumber:this.addAreaCode(e.recipientMobileNumber)}});if(!a.ok)return a}if(e.type==="MAYA_APP"){const a=await this.walletService.createMayaAppWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await g(e.transactionPassword)}});if(!a.ok)return a}return{ok:!0,data:{id:t}}}async withdrawalRecords(e){const t=await this.reportService.withdrawalRecords(e);return t.ok?{ok:!0,data:{withdrawalRecords:t.data.edges.map(({cursor:a,node:o})=>({...this.transformer.transform.withdrawalRecord(o),cursor:a})),totalCount:t.data.totalCount,nextCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async remainingDailyWithdrawalsCount(){return await this.walletService.remainingDailyWithdrawalsCount()}async createDeposit(e){const t=e.id??u.ObjectId.generate(f.Deposit).toString();if(e.type==="MAYA"){const a=await this.walletService.createMayaDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!a.ok)return a}if(e.type==="MAYA_APP"){const a=await this.walletService.createMayaAppDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!a.ok)return a}if(e.type==="GCASH"){const a=await this.walletService.createGCashDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!a.ok)return a}return{ok:!0,data:{id:t}}}async deposit(e){const t=await this.walletService.deposit({id:e});return t.ok?{ok:!0,data:t.data?this.transformer.transform.deposit(t.data):null}:t}async depositRecords(e){const t=await this.reportService.depositRecords(e);return t.ok?{ok:!0,data:{depositRecords:t.data.edges.map(({cursor:a,node:o})=>({...this.transformer.transform.depositRecord(o),cursor:a})),totalCount:t.data.totalCount,nextCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async depositsCount(){return await this.reportService.depositsCount()}async betRecords(e){const t=await this.reportService.betRecords(e);return t.ok?{ok:!0,data:{betRecords:t.data.edges.map(({cursor:a,node:o})=>({...this.transformer.transform.betRecord(o),cursor:a})),totalCount:t.data.totalCount,nextCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async latestBetRecords(){const e=await this.portalService.latestBetRecords();return e.ok?{ok:!0,data:e.data.map(this.transformer.transform.latestBetRecord)}:e}async transactionRecords(e){const t=await this.reportService.transactionRecords(e);return t.ok?{ok:!0,data:{transactionRecords:t.data.edges.map(({cursor:a,node:o})=>({...this.transformer.transform.transactionRecord(o),cursor:a})),totalCount:t.data.totalCount,nextCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async promos(){const e=await this.walletService.promos();return e.ok?{ok:!0,data:e.data.map(this.transformer.transform.promo)}:e}async availablePromos(){const e=await this.walletService.availablePromos();return e.ok?{ok:!0,data:e.data.map(this.transformer.transform.promo)}:e}async cashbacks(){const e=await this.walletService.cashbacks();return e.ok?{ok:!0,data:e.data.map(this.transformer.transform.cashback)}:e}async bonus(){const e=await this.walletService.bonus();return e.ok?{ok:!0,data:e.data?this.transformer.transform.bonus(e.data):null}:e}async cashbackBonuses(){const e=await this.walletService.cashbackBonuses();return e.ok?{ok:!0,data:e.data.map(this.transformer.transform.cashbackBonus)}:e}async claimCashbackBonus(e){return await this.walletService.claimCashbackBonus({input:{id:e}})}async games(e){const t=await this.gameService.games(e);return t.ok?{ok:!0,data:{games:t.data.edges.map(({cursor:a,node:o})=>({...this.transformer.transform.game(o),cursor:a})),totalCount:t.data.totalCount,nextCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async gamesByName(e){const t=await this.gameService.gamesByName(e);return t.ok?{ok:!0,data:t.data.map(this.transformer.transform.game)}:t}async gamesByName__next(e){const t=await this.walletService.gamesByName(e);return t.ok?{ok:!0,data:t.data.map(this.transformer.transform.game)}:t}async games__next(e){const t=await this.walletService.games(e);return t.ok?{ok:!0,data:{games:t.data.edges.map(({cursor:a,node:o})=>({...this.transformer.transform.game(o),cursor:a})),totalCount:t.data.totalCount,nextCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async createGameSession(e){const t=e.id??u.ObjectId.generate(f.GameSession).toString(),a=await this.gameService.createGameSession({input:{id:t,game:e.game}});return a.ok?{ok:!0,data:{id:t}}:a}async createGameSession__next(e){const t=e.id??u.ObjectId.generate(f.GameSession).toString(),a=await this.walletService.createGameSession({input:{id:t,game:e.game}});return a.ok?{ok:!0,data:{id:t}}:a}async gameSession(e){const t=await this.gameService.gameSession({id:e});return t.ok?{ok:!0,data:t.data?this.transformer.transform.gameSession(t.data):null}:t}async gameSession__next(e){const t=await this.walletService.gameSession({id:e});return t.ok?{ok:!0,data:t.data?this.transformer.transform.gameSession(t.data):null}:t}async endGameSession(e){return await this.gameService.endGameSession({input:{id:e}})}async endGameSession__next(e){return await this.walletService.endGameSession({input:{id:e}})}async file(e){const t=await this.fileService.file({id:e});return t.ok?{ok:!0,data:t.data?this.transformer.transform.file(t.data):null}:t}async uploadImageFile(e){const t=e.id??u.ObjectId.generate(f.File).toString(),a=await this.fileService.uploadPrivateImageFile({input:{id:t,file:e.file}});return a.ok?{ok:!0,data:{id:t}}:a}async pointsWallet(){const e=await this.walletService.pointsWallet();return e.ok?{ok:!0,data:e.data?this.transformer.transform.pointsWallet(e.data):null}:e}async pointsToCashConversion(e){return await this.walletService.pointsToCashConversion({input:{amount:e.toString()}})}addAreaCode(e){return e.startsWith("+63")?e:e.startsWith("63")?`+${e}`:e.startsWith("0")?`+63${e.substring(1)}`:`+63${e}`}}Object.defineProperty(l,"ObjectId",{enumerable:!0,get:()=>u.ObjectId}),l.ObjectType=f,l.Sdk=gt,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
|
1006
|
+
`;class st{constructor(e){c(this,"client");this.client=e}async memberAccount(){const e=await this.client.request(xe);return e.ok?{ok:!0,data:e.data.memberAccount}:e}async registerMemberAccount(e){const t=await this.client.request(qe,e);return t.ok?t.data.registerMemberAccount?{ok:!1,error:t.data.registerMemberAccount}:{ok:!0}:t}async updateMemberAccount(e){const t=await this.client.request(Fe,e);return t.ok?t.data.updateMemberAccount?{ok:!1,error:t.data.updateMemberAccount}:{ok:!0}:t}async deleteMemberAccount(e){const t=await this.client.request(Ve,e);return t.ok?t.data.deleteMemberAccount?{ok:!0}:{ok:!1,error:{code:"UnknownError",message:"Something went wrong."}}:t}async resetPassword(e){const t=await this.client.request(Le,e);return t.ok?t.data.resetPassword?{ok:!1,error:t.data.resetPassword}:{ok:!0}:t}async profileCompletion(){const e=await this.client.request(Ke);return e.ok?{ok:!0,data:e.data.profileCompletion}:e}async platform(){return await this.client.request(ze)}async sendVerificationCode(e){const t=await this.client.request(He,e);return t.ok?t.data.sendVerificationCode?{ok:!1,error:t.data.sendVerificationCode}:{ok:!0}:t}async verifyMobileNumber(e){const t=await this.client.request(Ye,e);return t.ok?t.data.verifyMobileNumber?{ok:!1,error:t.data.verifyMobileNumber}:{ok:!0}:t}async createMemberVerification(e){const t=await this.client.request(je,e);return t.ok?t.data.createMemberVerification?{ok:!1,error:t.data.createMemberVerification}:{ok:!0}:t}async updateMemberVerification(e){const t=await this.client.request(Qe,e);return t.ok?t.data.updateMemberVerification?{ok:!1,error:t.data.updateMemberVerification}:{ok:!0}:t}async memberVerification(){const e=await this.client.request(Oe);return e.ok?{ok:!0,data:e.data.memberAccount.verification}:e}async announcements(e){const t=await this.client.request(ge,e);return t.ok?{ok:!0,data:t.data.announcements}:t}}function f(i,e){const t=dt[i];return{code:t.code,message:e??t.message}}const dt={400:{code:"HttpBadRequest",message:"Bad Request"},401:{code:"HttpUnauthorized",message:"Unauthorized"},403:{code:"HttpForbidden",message:"Forbidden"},404:{code:"HttpNotFound",message:"Not Found"},408:{code:"HttpRequestTimeout",message:"Request Timeout"},429:{code:"HttpTooManyRequests",message:"Too Many Requests"},500:{code:"HttpInternalServerError",message:"Internal Server Error"},503:{code:"HttpServiceUnavailable",message:"Service Unavailable"}};async function g(i){const e=new TextEncoder().encode(i),t=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(t)).map(d=>d.toString(16).padStart(2,"0")).join("")}class ct{constructor(e){c(this,"url");c(this,"platform");this.url=e.url,this.platform=e.platform}async createSession(e){const t=new Headers;if(t.set("Content-Type","application/json"),t.set("Platform-Code",this.platform),t.set("Role","MEMBER"),"name"in e){const a=`${e.name}:${await g(e.password)}`,n=Buffer.from(a).toString("base64");t.set("Authorization",`Basic ${n}`)}if("mobileNumber"in e){const a=`${e.mobileNumber}:${e.verificationCode}`,n=Buffer.from(a).toString("base64");t.set("Authorization",`Basic ${n}`)}try{const a=await fetch(`${this.url}/sessions`,{method:"POST",headers:t}),n=await a.json();return a.status===401||a.status===403?n.code==="ACCOUNT_BLACKLISTED"?{ok:!1,error:{code:"AccountBlacklisted",message:"Account is blacklisted"}}:{ok:!1,error:{code:"AccountNotFound",message:"Account not found."}}:a.ok?{ok:!0,data:n}:{ok:!1,error:f(a.status)}}catch{return{ok:!1,error:{code:"UnknownError",message:"Something went wrong."}}}}async refreshSession(e){try{const t=await fetch(`${this.url}/session:refresh`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`,"Platform-Code":this.platform,Role:"MEMBER"}}),a=await t.json();return t.status===401||t.status===403?a.code==="ACCOUNT_BLACKLISTED"?{ok:!1,error:{code:"AccountBlacklisted",message:"Account is blacklisted"}}:{ok:!1,error:{code:"InvalidToken",message:"Invalid token."}}:t.ok?{ok:!0,data:a}:{ok:!1,error:f(t.status)}}catch{return{ok:!1,error:{code:"UnknownError",message:"Something went wrong."}}}}async destroySession(e){try{const t=await fetch(`${this.url}/session`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`,"Platform-Code":this.platform,Role:"MEMBER"}});return t.ok?{ok:!0}:{ok:!1,error:f(t.status)}}catch{return{ok:!1,error:{code:"UnknownError",message:"Something went wrong."}}}}async verifySession(e){try{const t=await fetch(`${this.url}/session`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`,"Platform-Code":this.platform,Role:"MEMBER"}});if(t.status===403||t.status===401)return!1}catch{}return!0}}class mt{constructor(e){c(this,"client");this.client=e}async file(e){const t=await this.client.request(T,e);return t.ok?{ok:!0,data:t.data.node}:t}async uploadPrivateImageFile(e){const t=await this.client.upload(T,e);return t.ok?t.data.uploadPrivateImageFile?{ok:!1,error:t.data.uploadPrivateImageFile}:{ok:!0}:t}}class v{constructor(e){c(this,"client");this.client=e}async game(e){const t=await this.client.request(ye,e);return t.ok?{ok:!0,data:t.data.node}:t}async games(e){const t=await this.client.request(be,e);return t.ok?{ok:!0,data:t.data.games}:t}async gamesByName(e){const t=await this.client.request(Se,e);return t.ok?{ok:!0,data:t.data.gamesByName}:t}async gameSession(e){const t=await this.client.request(Ae,e);return t.ok?{ok:!0,data:t.data.node}:t}async createGameSession(e){const t=await this.client.request(Ee,e);return t.ok?t.data.createGameSession?{ok:!1,error:t.data.createGameSession}:{ok:!0}:t}async endGameSession(e){const t=await this.client.request(ke,e);return t.ok?t.data.endGameSession?{ok:!0}:{ok:!1,error:{code:"UnknownError",message:"Something went wrong."}}:t}}class ut{constructor(e){c(this,"client");this.client=e}async betRecords(e){const t=await this.client.request(Ce,e);return t.ok?{ok:t.ok,data:t.data.member.betRecords}:t}async transactionRecords(e){const t=await this.client.request(Xe,e);return t.ok?{ok:t.ok,data:t.data.member.transactionRecords}:t}async withdrawalRecords(e){const t=await this.client.request(tt,e);return t.ok?{ok:t.ok,data:t.data.member.withdrawalRecords}:t}async depositRecords(e){const t=await this.client.request(Ie,e);return t.ok?{ok:t.ok,data:t.data.member.depositRecords}:t}async depositsCount(){const e=await this.client.request(We);return e.ok?{ok:e.ok,data:e.data.member.depositsCount}:e}async member(){const e=await this.client.request(Be);return e.ok?{ok:e.ok,data:e.data.member}:e}}class lt{constructor(e){c(this,"url");this.url=e.url}gameThumbnails(e){return[`${this.url}/images/${e.provider.toLowerCase()}/thumbnail-${e.id}.webp`,`${this.url}/images/${e.provider.toLowerCase()}/thumbnail-${e.provider.toLowerCase()}.webp`]}}class pt extends v{async promos(){const e=await this.client.request(ve);return e.ok?{ok:e.ok,data:e.data.promos}:e}async cashbacks(){const e=await this.client.request(_e);return e.ok?{ok:e.ok,data:e.data.cashbacks}:e}async availablePromos(e){const t=await this.client.request(De,e);return t.ok?{ok:t.ok,data:t.data.availablePromos}:t}async cashbackBonuses(){const e=await this.client.request(Re);return e.ok?{ok:e.ok,data:e.data.cashbackBonuses}:e}async claimCashbackBonus(e){const t=await this.client.request(Ne,e);return t.ok?t.data.claimCashbackBonus?{ok:!1,error:t.data.claimCashbackBonus}:{ok:!0}:{ok:t.ok,error:t.error}}async bonus(){const e=await this.client.request(Me);return e.ok?{ok:e.ok,data:e.data.bonus}:e}async wallet(){const e=await this.client.request(et);return e.ok?{ok:e.ok,data:e.data.wallet}:e}async deposit(e){const t=await this.client.request(Ue,e);return t.ok?{ok:t.ok,data:t.data.node}:t}async createGCashDeposit(e){const t=await this.client.request(Ge,e);return t.ok?t.data.createGCashDeposit?{ok:!1,error:t.data.createGCashDeposit}:{ok:!0}:t}async createMayaDeposit(e){const t=await this.client.request(Pe,e);return t.ok?t.data.createMayaDeposit?{ok:!1,error:t.data.createMayaDeposit}:{ok:!0}:t}async createMayaAppDeposit(e){const t=await this.client.request($e,e);return t.ok?t.data.createMayaAppDeposit?{ok:!1,error:t.data.createMayaAppDeposit}:{ok:!0}:t}async createGCashWithdrawal(e){const t=await this.client.request(at,e);return t.ok?t.data.createGCashWithdrawal?{ok:!1,error:t.data.createGCashWithdrawal}:{ok:!0}:t}async createMayaWithdrawal(e){const t=await this.client.request(rt,e);return t.ok?t.data.createMayaWithdrawal?{ok:!1,error:t.data.createMayaWithdrawal}:{ok:!0}:t}async createMayaAppWithdrawal(e){const t=await this.client.request(nt,e);return t.ok?t.data.createMayaAppWithdrawal?{ok:!1,error:t.data.createMayaAppWithdrawal}:{ok:!0}:t}async createBankWithdrawal(e){const t=await this.client.request(ot,e);return t.ok?t.data.createBankWithdrawal?{ok:!1,error:t.data.createBankWithdrawal}:{ok:!0}:t}async remainingDailyWithdrawalsCount(){const e=await this.client.request(it);return e.ok?{ok:e.ok,data:e.data.remainingDailyWithdrawalsCount}:e}async pointsWallet(){const e=await this.client.request(Je);return e.ok?{ok:e.ok,data:e.data.pointsWallet}:e}async pointsToCashConversion(e){const t=await this.client.request(Ze,e);return t.ok?t.data.pointsToCashConversion?{ok:!1,error:t.data.pointsToCashConversion}:{ok:!0}:t}}class ft{constructor(e){c(this,"client");this.client=e}async latestBetRecords(){const e=await this.client.request(Te);return e.ok?{ok:!0,data:e.data.latestBetRecords}:e}}function k(i){return new Date(i.getTime())}function D(i,e){const t=k(i);return t.setDate(t.getDate()+e),t}function M(i,e){const t=k(i);return t.setMinutes(t.getMinutes()+e),t}function R(i,e){return i.getTime()>e.getTime()}function ht(i){return new Promise(e=>{setTimeout(e,i)})}function N(i,e){const t=k(i);return t.setMinutes(t.getMinutes()-e),t}class wt{constructor(e){c(this,"logger");c(this,"storageKey","session");c(this,"authService");c(this,"_refreshing",!1);this.logger=new C,this.authService=new ct(e)}get refreshing(){return this._refreshing}set refreshing(e){this._refreshing=e}async create(e){const t=await this.authService.createSession(e);if(t.ok){const a=new Date;return this.isServer?this.logger.warn("'localStorage' is not available on the server."):window.localStorage.setItem(this.storageKey,JSON.stringify({...t.data,accessTokenExpiresAt:M(a,8).getTime(),refreshTokenExpiresAt:N(D(a,30),2).getTime()})),{ok:!0}}else return t}async get(){if(this.isServer)return this.logger.warn("'localStorage' is not available on the server."),{ok:!0,data:null};if(this.refreshing)return await ht(1e3),await this.get();const e=window.localStorage.getItem(this.storageKey);if(!e)return{ok:!0,data:null};try{let t=JSON.parse(e),a=new Date;const n=new Date(t.accessTokenExpiresAt),d=new Date(t.refreshTokenExpiresAt);if(R(a,d))return this.logger.warn("Session expired. Logging out.."),window.localStorage.removeItem(this.storageKey),{ok:!1,error:{code:"SessionExpired",message:"Session expired."}};if(R(a,n)){this.logger.info("Refreshing session..."),this.refreshing=!0;const u=await this.authService.refreshSession(t.refreshToken);if(this.refreshing=!1,!u.ok)return this.logger.error(`Failed to refresh session: ${u.error.message}`),u.error.code==="InvalidToken"||u.error.code==="AccountBlacklisted"?(window.localStorage.removeItem(this.storageKey),{ok:!1,error:u.error}):(this.logger.warn("Old session returned."),{ok:!0,data:t});this.logger.success("Session refreshed!"),a=new Date,t={...t,...u.data,accessTokenExpiresAt:M(a,8).getTime(),refreshTokenExpiresAt:N(D(a,30),2).getTime()},window.localStorage.setItem(this.storageKey,JSON.stringify(t))}return{ok:!0,data:t}}catch{return{ok:!1,error:{code:"UnknownError",message:"Something went wrong."}}}}async destroy(){var t;if(this.isServer){this.logger.warn("'localStorage' is not available on the server.");return}const e=await this.get();(t=e.data)!=null&&t.accessToken&&await this.authService.destroySession(e.data.accessToken),window.localStorage.removeItem(this.storageKey)}async verify(){var a,n,d;if(this.isServer)return this.logger.warn("'localStorage' is not available on the server."),!0;const e=await this.get();if(((a=e.error)==null?void 0:a.code)==="InvalidToken"||((n=e.error)==null?void 0:n.code)==="SessionExpired"||((d=e.error)==null?void 0:d.code)==="AccountBlacklisted")return!1;if(!e.data)return!0;const t=await this.authService.verifySession(e.data.accessToken);return t||window.localStorage.removeItem(this.storageKey),t}get isServer(){return typeof window>"u"}}function r(i,e){if(typeof i=="number"&&!Number.isNaN(i))return i;if(typeof i=="string"){const t=Number.parseFloat(i);if(!Number.isNaN(t))return t}return e}class gt{constructor(e){c(this,"staticService");const t=(e==null?void 0:e.environment)==="development";this.staticService=new lt({url:t?"https://static.development.opexa.io/graphql":"https://static.opexa.io/graphql"})}get transform(){return{platform:this.platform.bind(this),account:this.account.bind(this),wallet:this.wallet.bind(this),verificationDetails:this.verificationDetails.bind(this),profileCompletion:this.profileCompletion.bind(this),announcement:this.announcement.bind(this),withdrawalRecord:this.withdrawalRecord.bind(this),deposit:this.deposit.bind(this),depositRecord:this.depositRecord.bind(this),betRecord:this.betRecord.bind(this),latestBetRecord:this.latestBetRecord.bind(this),transactionRecord:this.transactionRecord.bind(this),game:this.game.bind(this),gameSession:this.gameSession.bind(this),promo:this.promo.bind(this),cashback:this.cashback.bind(this),bonus:this.bonus.bind(this),cashbackBonus:this.cashbackBonus.bind(this),file:this.file.bind(this),pointsWallet:this.pointsWallet.bind(this)}}platform(e){var t,a,n,d,u,l,h,S,s,I,G,P,$,U,W,B,x,O,q,F,L,V,H,Y,j,Q,K,z,J,Z,X,ee,te,ae,re,ne,oe,ie,se,de,ce,me,ue,le,pe,fe,he,we;return{paymentSettings:{minimumFirstDepositAmount:r(e.minimumFirstDepositAmount),restrictWithdrawalsToVerifiedMembers:e.restrictWithdrawalsToVerifiedMembers,depositGateway:{bank:{androidEnabled:((t=e.bankDepositGatewaySettings)==null?void 0:t.androidEnabled)??!1,iosEnabled:((a=e.bankDepositGatewaySettings)==null?void 0:a.iosEnabled)??!1,webEnabled:((n=e.bankDepositGatewaySettings)==null?void 0:n.webEnabled)??!1,mobileWebEnabled:((d=e.bankDepositGatewaySettings)==null?void 0:d.mobileWebEnabled)??!1,minimumAmount:r((u=e.bankDepositGatewaySettings)==null?void 0:u.minimumAmount),maximumAmount:r((l=e.bankDepositGatewaySettings)==null?void 0:l.maximumAmount)},gcash:{androidEnabled:((h=e.gcashDepositGatewaySettings)==null?void 0:h.androidEnabled)??!1,iosEnabled:((S=e.gcashDepositGatewaySettings)==null?void 0:S.iosEnabled)??!1,webEnabled:((s=e.gcashDepositGatewaySettings)==null?void 0:s.webEnabled)??!1,mobileWebEnabled:((I=e.gcashDepositGatewaySettings)==null?void 0:I.mobileWebEnabled)??!1,minimumAmount:r((G=e.gcashDepositGatewaySettings)==null?void 0:G.minimumAmount),maximumAmount:r((P=e.gcashDepositGatewaySettings)==null?void 0:P.maximumAmount)},maya:{androidEnabled:(($=e.mayaDepositGatewaySettings)==null?void 0:$.androidEnabled)??!1,iosEnabled:((U=e.mayaDepositGatewaySettings)==null?void 0:U.iosEnabled)??!1,webEnabled:((W=e.mayaDepositGatewaySettings)==null?void 0:W.webEnabled)??!1,mobileWebEnabled:((B=e.mayaDepositGatewaySettings)==null?void 0:B.mobileWebEnabled)??!1,minimumAmount:r((x=e.mayaDepositGatewaySettings)==null?void 0:x.minimumAmount),maximumAmount:r((O=e.mayaDepositGatewaySettings)==null?void 0:O.maximumAmount)},mayaApp:{androidEnabled:((q=e.mayaAppDepositGatewaySettings)==null?void 0:q.androidEnabled)??!1,iosEnabled:((F=e.mayaAppDepositGatewaySettings)==null?void 0:F.iosEnabled)??!1,webEnabled:((L=e.mayaAppDepositGatewaySettings)==null?void 0:L.webEnabled)??!1,mobileWebEnabled:((V=e.mayaAppDepositGatewaySettings)==null?void 0:V.mobileWebEnabled)??!1,minimumAmount:r((H=e.mayaAppDepositGatewaySettings)==null?void 0:H.minimumAmount),maximumAmount:r((Y=e.mayaAppDepositGatewaySettings)==null?void 0:Y.maximumAmount)}},withdrawalGateway:{bank:{androidEnabled:((j=e.bankWithdrawalGatewaySettings)==null?void 0:j.androidEnabled)??!1,iosEnabled:((Q=e.bankWithdrawalGatewaySettings)==null?void 0:Q.iosEnabled)??!1,webEnabled:((K=e.bankWithdrawalGatewaySettings)==null?void 0:K.webEnabled)??!1,mobileWebEnabled:((z=e.bankWithdrawalGatewaySettings)==null?void 0:z.mobileWebEnabled)??!1,minimumAmount:r((J=e.bankWithdrawalGatewaySettings)==null?void 0:J.minimumAmount),maximumAmount:r((Z=e.bankWithdrawalGatewaySettings)==null?void 0:Z.maximumAmount)},gcash:{androidEnabled:((X=e.gcashWithdrawalGatewaySettings)==null?void 0:X.androidEnabled)??!1,iosEnabled:((ee=e.gcashWithdrawalGatewaySettings)==null?void 0:ee.iosEnabled)??!1,webEnabled:((te=e.gcashWithdrawalGatewaySettings)==null?void 0:te.webEnabled)??!1,mobileWebEnabled:((ae=e.gcashWithdrawalGatewaySettings)==null?void 0:ae.mobileWebEnabled)??!1,minimumAmount:r((re=e.gcashWithdrawalGatewaySettings)==null?void 0:re.minimumAmount),maximumAmount:r((ne=e.gcashWithdrawalGatewaySettings)==null?void 0:ne.maximumAmount,1e6)},maya:{androidEnabled:((oe=e.mayaWithdrawalGatewaySettings)==null?void 0:oe.androidEnabled)??!1,iosEnabled:((ie=e.mayaWithdrawalGatewaySettings)==null?void 0:ie.iosEnabled)??!1,webEnabled:((se=e.mayaWithdrawalGatewaySettings)==null?void 0:se.webEnabled)??!1,mobileWebEnabled:((de=e.mayaWithdrawalGatewaySettings)==null?void 0:de.mobileWebEnabled)??!1,minimumAmount:r((ce=e.mayaWithdrawalGatewaySettings)==null?void 0:ce.minimumAmount),maximumAmount:r((me=e.mayaWithdrawalGatewaySettings)==null?void 0:me.maximumAmount)},mayaApp:{androidEnabled:((ue=e.mayaAppWithdrawalGatewaySettings)==null?void 0:ue.androidEnabled)??!1,iosEnabled:((le=e.mayaAppWithdrawalGatewaySettings)==null?void 0:le.iosEnabled)??!1,webEnabled:((pe=e.mayaAppWithdrawalGatewaySettings)==null?void 0:pe.webEnabled)??!1,mobileWebEnabled:((fe=e.mayaAppWithdrawalGatewaySettings)==null?void 0:fe.mobileWebEnabled)??!1,minimumAmount:r((he=e.mayaAppWithdrawalGatewaySettings)==null?void 0:he.minimumAmount),maximumAmount:r((we=e.mayaAppWithdrawalGatewaySettings)==null?void 0:we.maximumAmount,1e6)}}},pointsClubSettings:{multiplier:r(e.pointsClubSettings.multiplier,0)}}}account(e){return{id:e.id,name:e.name,status:e.status,verified:e.verified,nickName:e.nickName??void 0,realName:e.realName??void 0,dateOfBirth:e.birthDay?new Date(e.birthDay):void 0,emailAddress:e.emailAddress??void 0,mobileNumber:e.mobileNumber??void 0,mobileNumberVerified:e.mobileNumberVerified??!1,mobileNumberVerificationRequired:e.mobileNumberVerificationRequired??!1,validId:e.validId??void 0,verificationStatus:e.verificationStatus,transactionPassword:e.transactionPassword,dateTimeLastActive:e.dateTimeLastActive?new Date(e.dateTimeLastActive):void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}wallet(e){return{...e,balance:r(e.balance,0),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}verificationDetails(e){return{...e,idFrontImage:{...e.idFrontImage,url:e.idFrontImage.url??void 0,dateTimeCreated:new Date(e.idFrontImage.dateTimeCreated)},selfieImage:{...e.selfieImage,url:e.selfieImage.url??void 0,dateTimeCreated:new Date(e.selfieImage.dateTimeCreated)}}}profileCompletion(e){return{...e,completionPercentage:r(e,0)}}announcement(e){return{...e,activationEndDateTime:new Date(e.activationEndDateTime),activationStartDateTime:new Date(e.activationStartDateTime),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}withdrawalRecord(e){return{...e,amount:r(e.amount,0),netAmount:r(e.netAmount,0),fee:r(e.fee,0),reference:e.reference??void 0,bank:e.bank??void 0,recipientMobileNumber:e.recipientMobileNumber??void 0,dateTimeConfirmed:e.dateTimeConfirmed?new Date(e.dateTimeConfirmed):void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}deposit(e){return{...e,fee:r(e.fee,0),amount:r(e.amount,0),netAmount:r(e.netAmount,0),reference:e.reference??void 0,checkoutUrl:e.checkoutUrl??void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}depositRecord(e){return{...e,amount:r(e.amount,0),fee:r(e.fee,0),netAmount:r(e.netAmount,0),reference:e.reference??void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}betRecord(e){var t,a;return{...e,bet:r(e.bet,0),payout:r(e.payout,0),jackpotContribution:r(e.jackpotContribution,0),jackpotPayout:r(e.jackpotPayout,0),winloss:r(e.winloss),validBet:r(e.validBet,0),vendorRoundId:e.vendorRoundId??void 0,game:this.game(e.game),dateTimeSettled:e.dateTimeSettled?new Date(e.dateTimeSettled):void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated),betContent:e.betContent??void 0,contestName:e.contestName??void 0,externalCategory:e.externalCategory??void 0,metadata:{odds:((t=e.metadata)==null?void 0:t.odds)??void 0,validBet:r((a=e.metadata)==null?void 0:a.validBet)}}}latestBetRecord(e){return{...e,game:this.game(e.game),bet:r(e.bet,0),payout:r(e.payout,0),validBet:r(e.validBet,0),dateTimeSettled:new Date(e.dateTimeSettled),dateTimeCreated:new Date(e.dateTimeCreated)}}transactionRecord(e){return{...e,amount:r(e.amount,0),content:e.content??void 0,currentBalance:r(e.currentBalance,0),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}game(e){const t=this.staticService.gameThumbnails(e);return{...e,images:t}}gameSession(e){return{...e,game:this.game(e.game),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}promo(e){return{...e,banner:{...e.banner,dateTimeCreated:new Date(e.banner.dateTimeCreated)},maximumBonusAmount:r(e.maximumBonusAmount),minimumBonusAmount:r(e.minimumBonusAmount),activationEndDateTime:new Date(e.activationEndDateTime),activationStartDateTime:new Date(e.activationStartDateTime),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}cashback(e){return{...e,banner:{...e.banner,dateTimeCreated:new Date(e.banner.dateTimeCreated)},activationEndDateTime:new Date(e.activationEndDateTime),activationStartDateTime:new Date(e.activationStartDateTime),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}bonus(e){return{...e,promo:this.promo(e.promo),deposit:e.deposit?{...e.deposit,fee:r(e.deposit.fee,0),amount:r(e.deposit.amount,0),netAmount:r(e.deposit.netAmount,0),reference:e.deposit.reference??void 0,dateTimeCreated:new Date(e.deposit.dateTimeCreated),dateTimeLastUpdated:new Date(e.deposit.dateTimeLastUpdated)}:void 0,balance:r(e.balance,0),amount:r(e.amount,0),expiration:new Date(e.expiration),turnoverRequirement:r(e.turnoverRequirement,0),currentTurnoverRequirementContribution:r(e.currentTurnoverRequirementContribution,0),currentTurnoverRequirementContributionPercentage:r(e.currentTurnoverRequirementContributionPercentage,0),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}cashbackBonus(e){return{id:e.id,balance:r(e.balance,0),cashback:this.cashback(e.cashback),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}file(e){return{...e,url:e.url??void 0,dateTimeCreated:new Date(e.dateTimeCreated)}}pointsWallet(e){return{id:e.id,points:r(e.points,0),account:e.account,dateTimeCreated:new Date(e.dateTimeCreated)}}}class y{constructor(e,t){c(this,"url");c(this,"options");c(this,"middlewares");var n;const a=new Headers((n=t==null?void 0:t.fetchOptions)==null?void 0:n.headers);this.url=e,this.options={...t==null?void 0:t.fetchOptions,headers:a},this.middlewares=(t==null?void 0:t.middlewares)??[]}async request(e,t){var u;const a=JSON.stringify({query:e,variables:t}),n=new Headers(this.options.headers);n.set("Content-Type","application/json"),n.set("Accept","application/json");const d=await this.runMiddlewares(new Request(this.url,{...this.options,body:a,headers:n,method:"POST"}));try{const l=await fetch(d);if(!l.ok)return{ok:!1,error:f(l.status)};const h=await l.json(),S=h.data,s=(u=h.errors)==null?void 0:u.at(0);return(s==null?void 0:s.extensions.code)==="FORBIDDEN"?{ok:!1,error:f(403,s.message)}:(s==null?void 0:s.extensions.code)==="UNAUTHORIZED"?{ok:!1,error:f(401,s.message)}:(s==null?void 0:s.extensions.code)==="BAD_USER_INPUT"?{ok:!1,error:f(400,s.message)}:(s==null?void 0:s.extensions.code)==="INTERNAL_SERVER_ERROR"?{ok:!1,error:f(500,s.message)}:{ok:!0,data:S}}catch{return{ok:!1,error:f(500)}}}async upload(e,t){var u;const a=y.createUploadBody(e,t),n=new Headers(this.options.headers);n.set("Accept","application/json"),n.delete("Content-Type");const d=await this.runMiddlewares(new Request(this.url,{...this.options,body:a,headers:n,method:"POST"}));try{const l=await fetch(d);if(!l.ok)return{ok:!1,error:f(l.status)};const h=await l.json(),S=h.data,s=(u=h.errors)==null?void 0:u.at(0);return(s==null?void 0:s.extensions.code)==="FORBIDDEN"?{ok:!1,error:f(403)}:(s==null?void 0:s.extensions.code)==="UNAUTHORIZED"?{ok:!1,error:f(401)}:(s==null?void 0:s.extensions.code)==="BAD_USER_INPUT"?{ok:!1,error:f(400)}:(s==null?void 0:s.extensions.code)==="INTERNAL_SERVER_ERROR"?{ok:!1,error:f(500,s.message)}:{ok:!0,data:S}}catch{return{ok:!1,error:f(500)}}}async runMiddlewares(e){let t=e.clone();for(const a of this.middlewares)t=await a(t);return t}static createUploadBody(e,t){const{files:a,others:n}=y.extractFiles(t),d=new FormData;d.append("operations",JSON.stringify({query:e,variables:t})),Object.entries(n).forEach(([l,h])=>{d.append(l,JSON.stringify(h))});const u={};return Object.keys(a).forEach((l,h)=>{u[h.toString()]=`variables.${l}`}),d.append("map",JSON.stringify(u)),Object.values(a).forEach((l,h)=>{d.append(h.toString(),l)}),d}static extractFiles(e){const t={},a={};return Object.entries(e).forEach(([n,d])=>{d instanceof File||d instanceof Blob?t[n]=d:a[n]=d}),{files:t,others:a}}}class yt{constructor(e){c(this,"gameService");c(this,"fileService");c(this,"walletService");c(this,"reportService");c(this,"portalService");c(this,"accountService");c(this,"sessionManager");c(this,"transformer");c(this,"logger");const t=e.environment==="development";this.sessionManager=new wt({url:t?"https://auth.development.opexa.io":"https://auth.opexa.io",platform:e.platform});const a={middlewares:[this.authMiddleware],fetchOptions:{headers:{Role:"MEMBER","Platform-Code":e.platform}}};this.gameService=new v(new y(t?"https://game.development.opexa.io/graphql":"https://game.opexa.io/graphql",a)),this.fileService=new mt(new y(t?"https://file.development.opexa.io/graphql":"https://file.opexa.io/graphql",a)),this.walletService=new pt(new y(t?"https://wallet.development.opexa.io/graphql":"https://wallet.opexa.io/graphql",a)),this.reportService=new ut(new y(t?"https://report.development.opexa.io/graphql":"https://report.opexa.io/graphql",a)),this.accountService=new st(new y(t?"https://account.development.opexa.io/graphql":"https://account.opexa.io/graphql",a)),this.portalService=new ft(new y(t?"https://portal.development.opexa.io/graphql":"https://portal.opexa.io/graphql",a)),this.transformer=new gt(e),this.logger=new C({enabled:e.log??!1})}get authMiddleware(){return async e=>{this.logger.info("Checking for session");const t=await this.sessionManager.get();return t.data?(e.headers.append("Authorization",`Bearer ${t.data.accessToken}`),this.logger.info("Session found"),this.logger.success("Added 'Authorization' header")):this.logger.info("No session found"),e}}async signIn(e){const t=await this.sessionManager.create(e);return t.ok?{ok:!0}:t}async signOut(){await this.sessionManager.destroy()}watchSession(e){const t=e.interval??3e4,a=e.onInvalid;let n=null;const d=()=>setTimeout(async()=>{await this.sessionManager.verify()||await a(),n=d()},t);return n=d(),function(){n&&clearTimeout(n)}}async session(){const e=await this.sessionManager.get();return e.ok?{ok:!0,data:e.data?{id:e.data.session.id,dateTimeCreated:new Date(e.data.session.dateTimeCreated)}:null}:e}async platform(){const e=await this.accountService.platform();return e.ok?{ok:!0,data:this.transformer.transform.platform(e.data)}:e}async account(){const[e,t]=await Promise.all([this.accountService.memberAccount(),this.reportService.member()]);return e.ok?t.ok?{ok:!0,data:this.transformer.transform.account({...e.data,...t.data})}:{ok:!1,error:t.error}:{ok:!1,error:e.error}}async createAccount(e){const t=e.id??m.ObjectId.generate(w.Account).toString(),a=await this.accountService.registerMemberAccount({input:{id:t,name:e.name,birthDay:typeof e.dateOfBirth=="string"?e.dateOfBirth:e.dateOfBirth.toISOString(),password:await g(e.password),mobileNumber:this.addAreaCode(e.mobileNumber),domain:e.domain},verificationCode:e.verificationCode,reCAPTCHAResponse:e.reCAPTCHAResponse});return a.ok?{ok:!0,data:{id:t}}:a}async updateAccount(e,t){return await this.accountService.updateMemberAccount({input:{id:e,data:{...t,password:t.password?await g(t.password):void 0,transactionPassword:t.transactionPassword?await g(t.transactionPassword):void 0,...t.mobileNumber&&{mobileNumber:this.addAreaCode(t.mobileNumber)}}}})}async deleteAccount(e){return await this.accountService.deleteMemberAccount({input:{id:e}})}async verificationDetails(){const e=await this.accountService.memberVerification();return e.ok?{ok:!0,data:e.data?this.transformer.transform.verificationDetails(e.data):null}:e}async submitVerificationDetails(e){const t=e.id??m.ObjectId.generate(w.Verification).toString(),a=await this.accountService.createMemberVerification({input:{id:t,...e}});return a.ok?{ok:!0,data:{id:t}}:a}async updateVerificationDetails(e,t){return await this.accountService.updateMemberVerification({input:{id:e,data:{...t}}})}async resetPassword(e){return await this.accountService.resetPassword({input:{mobileNumber:this.addAreaCode(e.mobileNumber),newPassword:await g(e.newPassword)},verificationCode:e.verificationCode})}async verifyMobileNumber(e){return await this.accountService.verifyMobileNumber({input:{verificationCode:e}})}async profileCompletion(){const e=await this.accountService.profileCompletion();return e.ok?{ok:!0,data:this.transformer.transform.profileCompletion(e.data)}:e}async sendVerificationCode(e){return await this.accountService.sendVerificationCode({input:{channel:"SMS",recipient:this.addAreaCode(e)}})}async wallet(){const e=await this.walletService.wallet();return e.ok?{ok:!0,data:e.data?this.transformer.transform.wallet(e.data):null}:e}async announcements(e){const t=await this.accountService.announcements({...e,filter:{visibility:{in:["MEMBER","GLOBAL"]},activationStartDateTime:{greaterThanOrEqual:new Date}}});return t.ok?{ok:!0,data:{announcements:t.data.edges.map(({cursor:a,node:n})=>({...this.transformer.transform.announcement(n),cursor:a})),totalCount:t.data.totalCount,nextCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async createWithdrawal(e){const t=e.id??m.ObjectId.generate(w.Withdrawal).toString();if(e.type==="BANK"){const a=await this.walletService.createBankWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await g(e.transactionPassword)}});if(!a.ok)return a}if(e.type==="GCASH"){const a=await this.walletService.createGCashWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await g(e.transactionPassword),recipientMobileNumber:this.addAreaCode(e.recipientMobileNumber)}});if(!a.ok)return a}if(e.type==="MAYA"){const a=await this.walletService.createMayaWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await g(e.transactionPassword),recipientMobileNumber:this.addAreaCode(e.recipientMobileNumber)}});if(!a.ok)return a}if(e.type==="MAYA_APP"){const a=await this.walletService.createMayaAppWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await g(e.transactionPassword)}});if(!a.ok)return a}return{ok:!0,data:{id:t}}}async withdrawalRecords(e){const t=await this.reportService.withdrawalRecords(e);return t.ok?{ok:!0,data:{withdrawalRecords:t.data.edges.map(({cursor:a,node:n})=>({...this.transformer.transform.withdrawalRecord(n),cursor:a})),totalCount:t.data.totalCount,nextCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async remainingDailyWithdrawalsCount(){return await this.walletService.remainingDailyWithdrawalsCount()}async createDeposit(e){const t=e.id??m.ObjectId.generate(w.Deposit).toString();if(e.type==="MAYA"){const a=await this.walletService.createMayaDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!a.ok)return a}if(e.type==="MAYA_APP"){const a=await this.walletService.createMayaAppDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!a.ok)return a}if(e.type==="GCASH"){const a=await this.walletService.createGCashDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!a.ok)return a}return{ok:!0,data:{id:t}}}async deposit(e){const t=await this.walletService.deposit({id:e});return t.ok?{ok:!0,data:t.data?this.transformer.transform.deposit(t.data):null}:t}async depositRecords(e){const t=await this.reportService.depositRecords(e);return t.ok?{ok:!0,data:{depositRecords:t.data.edges.map(({cursor:a,node:n})=>({...this.transformer.transform.depositRecord(n),cursor:a})),totalCount:t.data.totalCount,nextCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async depositsCount(){return await this.reportService.depositsCount()}async betRecords(e){const t=await this.reportService.betRecords(e);return t.ok?{ok:!0,data:{betRecords:t.data.edges.map(({cursor:a,node:n})=>({...this.transformer.transform.betRecord(n),cursor:a})),totalCount:t.data.totalCount,nextCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async latestBetRecords(){const e=await this.portalService.latestBetRecords();return e.ok?{ok:!0,data:e.data.map(this.transformer.transform.latestBetRecord)}:e}async transactionRecords(e){const t=await this.reportService.transactionRecords(e);return t.ok?{ok:!0,data:{transactionRecords:t.data.edges.map(({cursor:a,node:n})=>({...this.transformer.transform.transactionRecord(n),cursor:a})),totalCount:t.data.totalCount,nextCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async promos(){const e=await this.walletService.promos();return e.ok?{ok:!0,data:e.data.map(this.transformer.transform.promo)}:e}async availablePromos(){const e=await this.walletService.availablePromos();return e.ok?{ok:!0,data:e.data.map(this.transformer.transform.promo)}:e}async cashbacks(){const e=await this.walletService.cashbacks();return e.ok?{ok:!0,data:e.data.map(this.transformer.transform.cashback)}:e}async bonus(){const e=await this.walletService.bonus();return e.ok?{ok:!0,data:e.data?this.transformer.transform.bonus(e.data):null}:e}async cashbackBonuses(){const e=await this.walletService.cashbackBonuses();return e.ok?{ok:!0,data:e.data.map(this.transformer.transform.cashbackBonus)}:e}async claimCashbackBonus(e){return await this.walletService.claimCashbackBonus({input:{id:e}})}async games(e){const t=await this.gameService.games(e);return t.ok?{ok:!0,data:{games:t.data.edges.map(({cursor:a,node:n})=>({...this.transformer.transform.game(n),cursor:a})),totalCount:t.data.totalCount,nextCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async gamesByName(e){const t=await this.gameService.gamesByName(e);return t.ok?{ok:!0,data:t.data.map(this.transformer.transform.game)}:t}async gamesByName__next(e){const t=await this.walletService.gamesByName(e);return t.ok?{ok:!0,data:t.data.map(this.transformer.transform.game)}:t}async games__next(e){const t=await this.walletService.games(e);return t.ok?{ok:!0,data:{games:t.data.edges.map(({cursor:a,node:n})=>({...this.transformer.transform.game(n),cursor:a})),totalCount:t.data.totalCount,nextCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async createGameSession(e){const t=e.id??m.ObjectId.generate(w.GameSession).toString(),a=await this.gameService.createGameSession({input:{id:t,game:e.game}});return a.ok?{ok:!0,data:{id:t}}:a}async createGameSession__next(e){const t=e.id??m.ObjectId.generate(w.GameSession).toString(),a=await this.walletService.createGameSession({input:{id:t,game:e.game}});return a.ok?{ok:!0,data:{id:t}}:a}async gameSession(e){const t=await this.gameService.gameSession({id:e});return t.ok?{ok:!0,data:t.data?this.transformer.transform.gameSession(t.data):null}:t}async gameSession__next(e){const t=await this.walletService.gameSession({id:e});return t.ok?{ok:!0,data:t.data?this.transformer.transform.gameSession(t.data):null}:t}async endGameSession(e){return await this.gameService.endGameSession({input:{id:e}})}async endGameSession__next(e){return await this.walletService.endGameSession({input:{id:e}})}async file(e){const t=await this.fileService.file({id:e});return t.ok?{ok:!0,data:t.data?this.transformer.transform.file(t.data):null}:t}async uploadImageFile(e){const t=e.id??m.ObjectId.generate(w.File).toString(),a=await this.fileService.uploadPrivateImageFile({input:{id:t,file:e.file}});return a.ok?{ok:!0,data:{id:t}}:a}async pointsWallet(){const e=await this.walletService.pointsWallet();return e.ok?{ok:!0,data:e.data?this.transformer.transform.pointsWallet(e.data):null}:e}async pointsToCashConversion(e){return await this.walletService.pointsToCashConversion({input:{amount:e.toString()}})}addAreaCode(e){return e.startsWith("+63")?e:e.startsWith("63")?`+${e}`:e.startsWith("0")?`+63${e.substring(1)}`:`+63${e}`}}Object.defineProperty(p,"ObjectId",{enumerable:!0,get:()=>m.ObjectId}),p.ObjectType=w,p.Sdk=yt,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|
|
1007
1007
|
//# sourceMappingURL=index.js.map
|