@opexa/portal-sdk 0.0.7 → 0.0.8
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.d.ts +0 -3
- package/dist/index.js +66 -59
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +757 -573
- package/dist/index.mjs.map +1 -1
- package/dist/sdk/index.d.ts +4 -0
- package/dist/{sdk.d.ts → sdk/sdk.d.ts} +38 -2
- package/dist/{session-manager.d.ts → sdk/session-manager.d.ts} +6 -2
- package/dist/{transformer.d.ts → sdk/transformer.d.ts} +1 -1
- package/dist/{types.d.ts → sdk/types.d.ts} +120 -95
- package/dist/services/account.service.d.ts +3 -2
- package/dist/services/auth.service.d.ts +8 -6
- package/dist/services/bet-record.d.ts +1 -7
- package/dist/services/bonus.d.ts +3 -2
- package/dist/services/cashback.d.ts +2 -4
- package/dist/services/deposit.d.ts +8 -17
- package/dist/services/file.d.ts +20 -10
- package/dist/services/file.service.d.ts +1 -1
- package/dist/services/game.d.ts +26 -12
- package/dist/services/game.service.d.ts +3 -2
- package/dist/services/member.d.ts +14 -9
- package/dist/services/platform.d.ts +1 -1
- package/dist/services/points.d.ts +3 -2
- package/dist/services/portal.service.d.ts +1 -1
- package/dist/services/promo.d.ts +2 -4
- package/dist/services/report.service.d.ts +2 -1
- package/dist/services/session.d.ts +64 -9
- package/dist/services/types.d.ts +9 -32
- package/dist/services/wallet.service.d.ts +3 -1
- package/dist/services/withdrawal.d.ts +6 -5
- package/dist/utils/graphql-client.d.ts +4 -11
- package/dist/utils/rest-client.d.ts +34 -0
- package/dist/utils/status-code-to-error.d.ts +3 -0
- package/dist/utils/types.d.ts +25 -3
- package/package.json +12 -12
- package/dist/utils/http-error.d.ts +0 -26
- /package/dist/{logger.d.ts → sdk/logger.d.ts} +0 -0
- /package/dist/{object-id.d.ts → sdk/object-id.d.ts} +0 -0
- /package/dist/{object-type.d.ts → sdk/object-type.d.ts} +0 -0
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(l,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("@opexa/object-id")):typeof define=="function"&&define.amd?define(["exports","@opexa/object-id"],m):(l=typeof globalThis<"u"?globalThis:l||self,m(l.sdk={},l.objectId))})(this,function(l,m){"use strict";var Et=Object.defineProperty;var kt=(l,m,h)=>m in l?Et(l,m,{enumerable:!0,configurable:!0,writable:!0,value:h}):l[m]=h;var c=(l,m,h)=>kt(l,typeof m!="symbol"?m+"":m,h);const h={Account:8,Deposit:9,Withdrawal:14,Verification:15,File:16,GameSession:204,MayaSession:230};function o(i,...e){let t="";for(const[a,r]of i.entries()){const n=e.at(a)??"";t=`${t}${r}${n}`}return t.trim()}const be=o`
|
|
2
2
|
query Announcements($first: Int, $after: Cursor, $filter: AnnouncementFilterInput) {
|
|
3
3
|
announcements(first: $first, after: $after, filter: $filter) {
|
|
4
4
|
edges {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
name
|
|
32
32
|
provider
|
|
33
33
|
}
|
|
34
|
-
`,
|
|
34
|
+
`,Se=o`
|
|
35
35
|
${y}
|
|
36
36
|
|
|
37
37
|
query Game($id: ObjectId!) {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
`,
|
|
44
|
+
`,Ae=o`
|
|
45
45
|
${y}
|
|
46
46
|
|
|
47
47
|
query Games($after: Cursor, $first: Int, $filter: GameFilterInput) {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
`,
|
|
64
|
+
`,Ee=o`
|
|
65
65
|
${y}
|
|
66
66
|
|
|
67
67
|
query GamesByName($search: String!, $filter: GameFilterInput, $first: Int) {
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
...GameFragment
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
`,
|
|
72
|
+
`,ke=o`
|
|
73
73
|
${y}
|
|
74
74
|
|
|
75
75
|
query GameSession($id: ObjectId!) {
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
`,
|
|
89
|
+
`,Ce=o`
|
|
90
90
|
mutation CreateGameSession($input: CreateGameSessionInput!) {
|
|
91
91
|
createGameSession(input: $input) {
|
|
92
92
|
... on GameDoesNotExistError {
|
|
@@ -95,11 +95,11 @@
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
`,
|
|
98
|
+
`,Te=o`
|
|
99
99
|
mutation EndGameSession($input: EndGameSessionInput!) {
|
|
100
100
|
endGameSession(input: $input)
|
|
101
101
|
}
|
|
102
|
-
`,
|
|
102
|
+
`,_e=o`
|
|
103
103
|
${y}
|
|
104
104
|
|
|
105
105
|
query BetRecords($first: Int, $after: Cursor, $filter: BetRecordFilterInput) {
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
`,
|
|
142
|
+
`,ve=o`
|
|
143
143
|
query LatestBetRecords {
|
|
144
144
|
latestBetRecords {
|
|
145
145
|
id
|
|
@@ -159,15 +159,15 @@
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
${y}
|
|
162
|
-
`,
|
|
162
|
+
`,C=o`
|
|
163
163
|
fragment FileFragment on File {
|
|
164
164
|
id
|
|
165
165
|
url
|
|
166
166
|
status
|
|
167
167
|
dateTimeCreated
|
|
168
168
|
}
|
|
169
|
-
`,
|
|
170
|
-
${
|
|
169
|
+
`,M=o`
|
|
170
|
+
${C}
|
|
171
171
|
|
|
172
172
|
query File($id: ObjectId!) {
|
|
173
173
|
node(id: $id) {
|
|
@@ -193,8 +193,8 @@
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
`;const
|
|
197
|
-
${
|
|
196
|
+
`;const N=o`
|
|
197
|
+
${C}
|
|
198
198
|
|
|
199
199
|
fragment CashbackFragment on Cashback {
|
|
200
200
|
id
|
|
@@ -209,16 +209,16 @@
|
|
|
209
209
|
dateTimeCreated
|
|
210
210
|
dateTimeLastUpdated
|
|
211
211
|
}
|
|
212
|
-
`,
|
|
213
|
-
${
|
|
212
|
+
`,De=o`
|
|
213
|
+
${N}
|
|
214
214
|
|
|
215
215
|
query Cashbacks {
|
|
216
216
|
cashbacks {
|
|
217
217
|
...CashbackFragment
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
-
`,
|
|
221
|
-
${
|
|
220
|
+
`,_=o`
|
|
221
|
+
${C}
|
|
222
222
|
|
|
223
223
|
fragment PromoFragment on Promo {
|
|
224
224
|
id
|
|
@@ -236,24 +236,24 @@
|
|
|
236
236
|
dateTimeCreated
|
|
237
237
|
dateTimeLastUpdated
|
|
238
238
|
}
|
|
239
|
-
`,
|
|
240
|
-
${
|
|
239
|
+
`,Me=o`
|
|
240
|
+
${_}
|
|
241
241
|
|
|
242
242
|
query Promos {
|
|
243
243
|
promos {
|
|
244
244
|
...PromoFragment
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
|
-
`,
|
|
248
|
-
${
|
|
247
|
+
`,Ne=o`
|
|
248
|
+
${_}
|
|
249
249
|
|
|
250
250
|
query AvailablePromos($filter: PromoFilterInput) {
|
|
251
251
|
availablePromos(filter: $filter) {
|
|
252
252
|
...PromoFragment
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
|
-
`,
|
|
256
|
-
${
|
|
255
|
+
`,Re=o`
|
|
256
|
+
${_}
|
|
257
257
|
|
|
258
258
|
query Bonus {
|
|
259
259
|
bonus {
|
|
@@ -281,8 +281,8 @@
|
|
|
281
281
|
dateTimeLastUpdated
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
|
-
`,
|
|
285
|
-
${
|
|
284
|
+
`,Ie=o`
|
|
285
|
+
${N}
|
|
286
286
|
|
|
287
287
|
query CashbackBonuses {
|
|
288
288
|
cashbackBonuses {
|
|
@@ -295,7 +295,7 @@
|
|
|
295
295
|
dateTimeLastUpdated
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
-
`,
|
|
298
|
+
`,Ge=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
|
-
`,
|
|
307
|
+
`,Pe=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
|
-
|
|
336
|
+
`,$e=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
|
-
|
|
373
|
+
`,Ue=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
|
-
`,
|
|
410
|
+
`,xe=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
|
-
`,
|
|
447
|
+
`,We=o`
|
|
448
448
|
query Deposit($id: ObjectId!) {
|
|
449
449
|
node(id: $id) {
|
|
450
450
|
... on GCashDeposit {
|
|
@@ -479,25 +479,24 @@
|
|
|
479
479
|
fee
|
|
480
480
|
status
|
|
481
481
|
reference
|
|
482
|
-
checkoutUrl
|
|
483
482
|
dateTimeCreated
|
|
484
483
|
dateTimeLastUpdated
|
|
485
484
|
}
|
|
486
485
|
}
|
|
487
486
|
}
|
|
488
|
-
`,
|
|
487
|
+
`,Be=o`
|
|
489
488
|
query DepositsCount {
|
|
490
489
|
member {
|
|
491
490
|
depositsCount
|
|
492
491
|
}
|
|
493
492
|
}
|
|
494
|
-
`,
|
|
493
|
+
`,Oe=o`
|
|
495
494
|
query Member {
|
|
496
495
|
member {
|
|
497
496
|
dateTimeLastActive
|
|
498
497
|
}
|
|
499
498
|
}
|
|
500
|
-
`,
|
|
499
|
+
`,qe=o`
|
|
501
500
|
query MemberAccount {
|
|
502
501
|
memberAccount: self {
|
|
503
502
|
... on MemberAccount {
|
|
@@ -520,8 +519,8 @@
|
|
|
520
519
|
}
|
|
521
520
|
}
|
|
522
521
|
}
|
|
523
|
-
`,
|
|
524
|
-
${
|
|
522
|
+
`,Fe=o`
|
|
523
|
+
${C}
|
|
525
524
|
|
|
526
525
|
query MemberVerification {
|
|
527
526
|
memberAccount: self {
|
|
@@ -544,7 +543,7 @@
|
|
|
544
543
|
}
|
|
545
544
|
}
|
|
546
545
|
}
|
|
547
|
-
`,
|
|
546
|
+
`,Le=o`
|
|
548
547
|
mutation RegisterMemberAccount(
|
|
549
548
|
$input: RegisterMemberAccountInput!
|
|
550
549
|
$referralCode: String
|
|
@@ -587,7 +586,7 @@
|
|
|
587
586
|
}
|
|
588
587
|
}
|
|
589
588
|
}
|
|
590
|
-
`,
|
|
589
|
+
`,Ve=o`
|
|
591
590
|
mutation UpdateMemberAccount($input: UpdateMemberAccountInput!) {
|
|
592
591
|
updateMemberAccount(input: $input) {
|
|
593
592
|
... on AccountNameNotAvailableError {
|
|
@@ -620,7 +619,7 @@
|
|
|
620
619
|
}
|
|
621
620
|
}
|
|
622
621
|
}
|
|
623
|
-
`,
|
|
622
|
+
`,He=o`
|
|
624
623
|
mutation ResetPassword($input: ResetPasswordInput!, $verificationCode: String) {
|
|
625
624
|
resetPassword(input: $input, verificationCode: $verificationCode) {
|
|
626
625
|
... on AccountNotFoundError {
|
|
@@ -633,11 +632,11 @@
|
|
|
633
632
|
}
|
|
634
633
|
}
|
|
635
634
|
}
|
|
636
|
-
`,
|
|
635
|
+
`,Ye=o`
|
|
637
636
|
mutation DeleteMemberAccount($input: DeleteMemberAccountInput!) {
|
|
638
637
|
deleteMemberAccount(input: $input)
|
|
639
638
|
}
|
|
640
|
-
`,
|
|
639
|
+
`,je=o`
|
|
641
640
|
mutation SendVerificationCode($input: SendVerificationCodeInput!) {
|
|
642
641
|
sendVerificationCode(input: $input) {
|
|
643
642
|
... on InvalidPlatformError {
|
|
@@ -650,7 +649,7 @@
|
|
|
650
649
|
}
|
|
651
650
|
}
|
|
652
651
|
}
|
|
653
|
-
`,
|
|
652
|
+
`,Qe=o`
|
|
654
653
|
mutation VerifyMobileNumber($input: VerifyMobileNumberInput!) {
|
|
655
654
|
verifyMobileNumber(input: $input) {
|
|
656
655
|
... on InvalidSMSVerificationCodeError {
|
|
@@ -663,7 +662,7 @@
|
|
|
663
662
|
}
|
|
664
663
|
}
|
|
665
664
|
}
|
|
666
|
-
`,
|
|
665
|
+
`,Ke=o`
|
|
667
666
|
mutation CreateMemberVerification($input: CreateMemberVerificationInput!) {
|
|
668
667
|
createMemberVerification(input: $input) {
|
|
669
668
|
... on FileDoesNotExistError {
|
|
@@ -680,7 +679,7 @@
|
|
|
680
679
|
}
|
|
681
680
|
}
|
|
682
681
|
}
|
|
683
|
-
`,
|
|
682
|
+
`,ze=o`
|
|
684
683
|
mutation UpdateMemberVerification($input: UpdateMemberVerificationInput!) {
|
|
685
684
|
updateMemberVerification(input: $input) {
|
|
686
685
|
... on FileDoesNotExistError {
|
|
@@ -701,7 +700,7 @@
|
|
|
701
700
|
}
|
|
702
701
|
}
|
|
703
702
|
}
|
|
704
|
-
`,
|
|
703
|
+
`,Je=o`
|
|
705
704
|
query ProfileCompletion {
|
|
706
705
|
profileCompletion {
|
|
707
706
|
completionPercentage
|
|
@@ -712,7 +711,7 @@
|
|
|
712
711
|
accountPassword
|
|
713
712
|
}
|
|
714
713
|
}
|
|
715
|
-
`,
|
|
714
|
+
`,Xe=o`
|
|
716
715
|
fragment DepositGatewaySettingsCoreData on DepositGatewaySettings {
|
|
717
716
|
minimumAmount
|
|
718
717
|
maximumAmount
|
|
@@ -775,16 +774,24 @@
|
|
|
775
774
|
dateTimeCreated
|
|
776
775
|
}
|
|
777
776
|
}
|
|
778
|
-
`,
|
|
777
|
+
`,et=o`
|
|
779
778
|
mutation PointsToCashConversion($input: PointsToCashConversionInput!) {
|
|
780
779
|
pointsToCashConversion(input: $input) {
|
|
781
780
|
... on InsufficientPointsError {
|
|
781
|
+
code: __typename
|
|
782
782
|
message
|
|
783
|
-
__typename
|
|
784
783
|
}
|
|
785
784
|
}
|
|
786
785
|
}
|
|
787
|
-
`,
|
|
786
|
+
`,tt=o`
|
|
787
|
+
query MayaSession($id: ObjectId!) {
|
|
788
|
+
mayaSession(id: $id) {
|
|
789
|
+
id
|
|
790
|
+
member
|
|
791
|
+
dateTimeCreated
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
`,at=o`
|
|
788
795
|
query TransactionRecords($first: Int, $after: Cursor, $filter: TransactionRecordFilter) {
|
|
789
796
|
member {
|
|
790
797
|
transactionRecords(first: $first, after: $after, filter: $filter) {
|
|
@@ -810,7 +817,7 @@
|
|
|
810
817
|
}
|
|
811
818
|
}
|
|
812
819
|
}
|
|
813
|
-
`,
|
|
820
|
+
`,rt=o`
|
|
814
821
|
query Wallet {
|
|
815
822
|
wallet {
|
|
816
823
|
id
|
|
@@ -820,7 +827,7 @@
|
|
|
820
827
|
dateTimeLastUpdated
|
|
821
828
|
}
|
|
822
829
|
}
|
|
823
|
-
`,
|
|
830
|
+
`,nt=o`
|
|
824
831
|
query WithdrawalRecords($first: Int, $after: Cursor, $filter: WithdrawalRecordFilterInput) {
|
|
825
832
|
member {
|
|
826
833
|
withdrawalRecords(first: $first, after: $after, filter: $filter) {
|
|
@@ -887,7 +894,7 @@
|
|
|
887
894
|
}
|
|
888
895
|
}
|
|
889
896
|
}
|
|
890
|
-
`,
|
|
897
|
+
`,st=o`
|
|
891
898
|
mutation CreateGCashWithdrawal($input: CreateGCashWithdrawalInput!) {
|
|
892
899
|
createGCashWithdrawal(input: $input) {
|
|
893
900
|
... on AccountNotVerifiedError {
|
|
@@ -916,7 +923,7 @@
|
|
|
916
923
|
}
|
|
917
924
|
}
|
|
918
925
|
}
|
|
919
|
-
`,
|
|
926
|
+
`,ot=o`
|
|
920
927
|
mutation CreateMayaWithdrawal($input: CreateMayaWithdrawalInput!) {
|
|
921
928
|
createMayaWithdrawal(input: $input) {
|
|
922
929
|
... on AccountNotVerifiedError {
|
|
@@ -945,7 +952,7 @@
|
|
|
945
952
|
}
|
|
946
953
|
}
|
|
947
954
|
}
|
|
948
|
-
`,
|
|
955
|
+
`,it=o`
|
|
949
956
|
mutation CreateMayaAppWithdrawal($input: CreateMayaAppWithdrawalInput!) {
|
|
950
957
|
createMayaAppWithdrawal(input: $input) {
|
|
951
958
|
... on AccountNotVerifiedError {
|
|
@@ -970,7 +977,7 @@
|
|
|
970
977
|
}
|
|
971
978
|
}
|
|
972
979
|
}
|
|
973
|
-
`,
|
|
980
|
+
`,dt=o`
|
|
974
981
|
mutation CreateBankWithdrawal($input: CreateBankWithdrawalInput!) {
|
|
975
982
|
createBankWithdrawal(input: $input) {
|
|
976
983
|
... on MobileNumberNotVerifiedError {
|
|
@@ -999,9 +1006,9 @@
|
|
|
999
1006
|
}
|
|
1000
1007
|
}
|
|
1001
1008
|
}
|
|
1002
|
-
`,
|
|
1009
|
+
`,ct=o`
|
|
1003
1010
|
query RemainingDailyWithdrawalsCount {
|
|
1004
1011
|
remainingDailyWithdrawalsCount
|
|
1005
1012
|
}
|
|
1006
|
-
`;class dt{constructor(e){d(this,"client");this.client=e}async memberAccount(){const e=await this.client.request(Oe);return e.ok?{ok:!0,data:e.data.memberAccount}:e}async registerMemberAccount(e){const t=await this.client.request(Fe,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(Le,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(He,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(Ve,e);return t.ok?t.data.resetPassword?{ok:!1,error:t.data.resetPassword}:{ok:!0}:t}async profileCompletion(){const e=await this.client.request(ze);return e.ok?{ok:!0,data:e.data.profileCompletion}:e}async platform(){return await this.client.request(Je)}async sendVerificationCode(e){const t=await this.client.request(Ye,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(je,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(Qe,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(Ke,e);return t.ok?t.data.updateMemberVerification?{ok:!1,error:t.data.updateMemberVerification}:{ok:!0}:t}async memberVerification(){const e=await this.client.request(qe);return e.ok?{ok:!0,data:e.data.memberAccount.verification}:e}async announcements(e){const t=await this.client.request(ye,e);return t.ok?{ok:!0,data:t.data.announcements}:t}}function w(i,e){const t=k[i]?k[i]:k[500];return{code:t.code,message:e??t.message}}const k={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"},502:{code:"HttpBadGateway",message:"Bad Gateway"},503:{code:"HttpServiceUnavailable",message:"Service Unavailable"},504:{code:"HttpGatewayTimeout",message:"Gateway Timeout"}};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(s=>s.toString(16).padStart(2,"0")).join("")}class ct{constructor(e){d(this,"url");d(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)}`,r=Buffer.from(a).toString("base64");t.set("Authorization",`Basic ${r}`)}if("mobileNumber"in e){const a=`${e.mobileNumber}:${e.verificationCode}`,r=Buffer.from(a).toString("base64");t.set("Authorization",`Basic ${r}`)}try{const a=await fetch(`${this.url}/sessions`,{method:"POST",headers:t}),r=await a.json();return a.status===401||a.status===403?r.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:r}:{ok:!1,error:w(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:w(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:w(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){d(this,"client");this.client=e}async file(e){const t=await this.client.request(_,e);return t.ok?{ok:!0,data:t.data.node}:t}async uploadPrivateImageFile(e){const t=await this.client.upload(_,e);return t.ok?t.data.uploadPrivateImageFile?{ok:!1,error:t.data.uploadPrivateImageFile}:{ok:!0}:t}}class D{constructor(e){d(this,"client");this.client=e}async game(e){const t=await this.client.request(be,e);return t.ok?{ok:!0,data:t.data.node}:t}async games(e){const t=await this.client.request(Se,e);return t.ok?{ok:!0,data:t.data.games}:t}async gamesByName(e){const t=await this.client.request(Ae,e);return t.ok?{ok:!0,data:t.data.gamesByName}:t}async gameSession(e){const t=await this.client.request(Ee,e);return t.ok?{ok:!0,data:t.data.node}:t}async createGameSession(e){const t=await this.client.request(ke,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(Ce,e);return t.ok?t.data.endGameSession?{ok:!0}:{ok:!1,error:{code:"UnknownError",message:"Something went wrong."}}:t}}class ut{constructor(e){d(this,"client");this.client=e}async betRecords(e){const t=await this.client.request(Te,e);return t.ok?{ok:t.ok,data:t.data.member.betRecords}:t}async transactionRecords(e){const t=await this.client.request(et,e);return t.ok?{ok:t.ok,data:t.data.member.transactionRecords}:t}async withdrawalRecords(e){const t=await this.client.request(at,e);return t.ok?{ok:t.ok,data:t.data.member.withdrawalRecords}:t}async depositRecords(e){const t=await this.client.request(Ge,e);return t.ok?{ok:t.ok,data:t.data.member.depositRecords}:t}async depositsCount(){const e=await this.client.request(Ue);return e.ok?{ok:e.ok,data:e.data.member.depositsCount}:e}async member(){const e=await this.client.request(xe);return e.ok?{ok:e.ok,data:e.data.member}:e}}class lt{constructor(e){d(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 D{async promos(){const e=await this.client.request(De);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(Me,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(Ie,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(Ne);return e.ok?{ok:e.ok,data:e.data.bonus}:e}async wallet(){const e=await this.client.request(tt);return e.ok?{ok:e.ok,data:e.data.wallet}:e}async deposit(e){const t=await this.client.request(Be,e);return t.ok?{ok:t.ok,data:t.data.node}:t}async createGCashDeposit(e){const t=await this.client.request(Pe,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($e,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(We,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(rt,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(nt,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(it,e);return t.ok?t.data.createBankWithdrawal?{ok:!1,error:t.data.createBankWithdrawal}:{ok:!0}:t}async remainingDailyWithdrawalsCount(){const e=await this.client.request(st);return e.ok?{ok:e.ok,data:e.data.remainingDailyWithdrawalsCount}:e}async pointsWallet(){const e=await this.client.request(Ze);return e.ok?{ok:e.ok,data:e.data.pointsWallet}:e}async pointsToCashConversion(e){const t=await this.client.request(Xe,e);return t.ok?t.data.pointsToCashConversion?{ok:!1,error:t.data.pointsToCashConversion}:{ok:!0}:t}}class ht{constructor(e){d(this,"client");this.client=e}async latestBetRecords(){const e=await this.client.request(_e);return e.ok?{ok:!0,data:e.data.latestBetRecords}:e}}function C(i){return new Date(i.getTime())}function M(i,e){const t=C(i);return t.setDate(t.getDate()+e),t}function N(i,e){const t=C(i);return t.setMinutes(t.getMinutes()+e),t}function R(i,e){return i.getTime()>e.getTime()}function ft(i){return new Promise(e=>{setTimeout(e,i)})}function I(i,e){const t=C(i);return t.setMinutes(t.getMinutes()-e),t}class wt{constructor(e){d(this,"logger");d(this,"storageKey","session");d(this,"authService");d(this,"_refreshing",!1);this.authService=new ct(e),this.logger=new T({enabled:e.log??!1})}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:N(a,8).getTime(),refreshTokenExpiresAt:I(M(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 ft(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 r=new Date(t.accessTokenExpiresAt),s=new Date(t.refreshTokenExpiresAt);if(R(a,s))return this.logger.warn("Session expired. Logging out.."),window.localStorage.removeItem(this.storageKey),{ok:!1,error:{code:"SessionExpired",message:"Session expired."}};if(R(a,r)){this.logger.info("Refreshing session..."),this.refreshing=!0;const m=await this.authService.refreshSession(t.refreshToken);if(this.refreshing=!1,!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:N(a,8).getTime(),refreshTokenExpiresAt:I(M(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,r,s;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"||((r=e.error)==null?void 0:r.code)==="SessionExpired"||((s=e.error)==null?void 0:s.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 n(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){d(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,r,s,m,p,f,A,h,G,P,$,W,B,U,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,he,fe,we,ge;return{paymentSettings:{minimumFirstDepositAmount:n(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:((r=e.bankDepositGatewaySettings)==null?void 0:r.webEnabled)??!1,mobileWebEnabled:((s=e.bankDepositGatewaySettings)==null?void 0:s.mobileWebEnabled)??!1,minimumAmount:n((m=e.bankDepositGatewaySettings)==null?void 0:m.minimumAmount),maximumAmount:n((p=e.bankDepositGatewaySettings)==null?void 0:p.maximumAmount)},gcash:{androidEnabled:((f=e.gcashDepositGatewaySettings)==null?void 0:f.androidEnabled)??!1,iosEnabled:((A=e.gcashDepositGatewaySettings)==null?void 0:A.iosEnabled)??!1,webEnabled:((h=e.gcashDepositGatewaySettings)==null?void 0:h.webEnabled)??!1,mobileWebEnabled:((G=e.gcashDepositGatewaySettings)==null?void 0:G.mobileWebEnabled)??!1,minimumAmount:n((P=e.gcashDepositGatewaySettings)==null?void 0:P.minimumAmount),maximumAmount:n(($=e.gcashDepositGatewaySettings)==null?void 0:$.maximumAmount)},maya:{androidEnabled:((W=e.mayaDepositGatewaySettings)==null?void 0:W.androidEnabled)??!1,iosEnabled:((B=e.mayaDepositGatewaySettings)==null?void 0:B.iosEnabled)??!1,webEnabled:((U=e.mayaDepositGatewaySettings)==null?void 0:U.webEnabled)??!1,mobileWebEnabled:((x=e.mayaDepositGatewaySettings)==null?void 0:x.mobileWebEnabled)??!1,minimumAmount:n((O=e.mayaDepositGatewaySettings)==null?void 0:O.minimumAmount),maximumAmount:n((q=e.mayaDepositGatewaySettings)==null?void 0:q.maximumAmount)},mayaApp:{androidEnabled:((F=e.mayaAppDepositGatewaySettings)==null?void 0:F.androidEnabled)??!1,iosEnabled:((L=e.mayaAppDepositGatewaySettings)==null?void 0:L.iosEnabled)??!1,webEnabled:((V=e.mayaAppDepositGatewaySettings)==null?void 0:V.webEnabled)??!1,mobileWebEnabled:((H=e.mayaAppDepositGatewaySettings)==null?void 0:H.mobileWebEnabled)??!1,minimumAmount:n((Y=e.mayaAppDepositGatewaySettings)==null?void 0:Y.minimumAmount),maximumAmount:n((j=e.mayaAppDepositGatewaySettings)==null?void 0:j.maximumAmount)}},withdrawalGateway:{bank:{androidEnabled:((Q=e.bankWithdrawalGatewaySettings)==null?void 0:Q.androidEnabled)??!1,iosEnabled:((K=e.bankWithdrawalGatewaySettings)==null?void 0:K.iosEnabled)??!1,webEnabled:((z=e.bankWithdrawalGatewaySettings)==null?void 0:z.webEnabled)??!1,mobileWebEnabled:((J=e.bankWithdrawalGatewaySettings)==null?void 0:J.mobileWebEnabled)??!1,minimumAmount:n((Z=e.bankWithdrawalGatewaySettings)==null?void 0:Z.minimumAmount),maximumAmount:n((X=e.bankWithdrawalGatewaySettings)==null?void 0:X.maximumAmount)},gcash:{androidEnabled:((ee=e.gcashWithdrawalGatewaySettings)==null?void 0:ee.androidEnabled)??!1,iosEnabled:((te=e.gcashWithdrawalGatewaySettings)==null?void 0:te.iosEnabled)??!1,webEnabled:((ae=e.gcashWithdrawalGatewaySettings)==null?void 0:ae.webEnabled)??!1,mobileWebEnabled:((re=e.gcashWithdrawalGatewaySettings)==null?void 0:re.mobileWebEnabled)??!1,minimumAmount:n((ne=e.gcashWithdrawalGatewaySettings)==null?void 0:ne.minimumAmount),maximumAmount:n((oe=e.gcashWithdrawalGatewaySettings)==null?void 0:oe.maximumAmount,1e6)},maya:{androidEnabled:((ie=e.mayaWithdrawalGatewaySettings)==null?void 0:ie.androidEnabled)??!1,iosEnabled:((se=e.mayaWithdrawalGatewaySettings)==null?void 0:se.iosEnabled)??!1,webEnabled:((de=e.mayaWithdrawalGatewaySettings)==null?void 0:de.webEnabled)??!1,mobileWebEnabled:((ce=e.mayaWithdrawalGatewaySettings)==null?void 0:ce.mobileWebEnabled)??!1,minimumAmount:n((me=e.mayaWithdrawalGatewaySettings)==null?void 0:me.minimumAmount),maximumAmount:n((ue=e.mayaWithdrawalGatewaySettings)==null?void 0:ue.maximumAmount)},mayaApp:{androidEnabled:((le=e.mayaAppWithdrawalGatewaySettings)==null?void 0:le.androidEnabled)??!1,iosEnabled:((pe=e.mayaAppWithdrawalGatewaySettings)==null?void 0:pe.iosEnabled)??!1,webEnabled:((he=e.mayaAppWithdrawalGatewaySettings)==null?void 0:he.webEnabled)??!1,mobileWebEnabled:((fe=e.mayaAppWithdrawalGatewaySettings)==null?void 0:fe.mobileWebEnabled)??!1,minimumAmount:n((we=e.mayaAppWithdrawalGatewaySettings)==null?void 0:we.minimumAmount),maximumAmount:n((ge=e.mayaAppWithdrawalGatewaySettings)==null?void 0:ge.maximumAmount,1e6)}}},pointsClubSettings:{multiplier:n(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:n(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:n(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:n(e.amount,0),netAmount:n(e.netAmount,0),fee:n(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:n(e.fee,0),amount:n(e.amount,0),netAmount:n(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:n(e.amount,0),fee:n(e.fee,0),netAmount:n(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:n(e.bet,0),payout:n(e.payout,0),jackpotContribution:n(e.jackpotContribution,0),jackpotPayout:n(e.jackpotPayout,0),winloss:n(e.winloss),validBet:n(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:n((a=e.metadata)==null?void 0:a.validBet)}}}latestBetRecord(e){return{...e,game:this.game(e.game),bet:n(e.bet,0),payout:n(e.payout,0),validBet:n(e.validBet,0),dateTimeSettled:new Date(e.dateTimeSettled),dateTimeCreated:new Date(e.dateTimeCreated)}}transactionRecord(e){return{...e,amount:n(e.amount,0),content:e.content??void 0,currentBalance:n(e.currentBalance,0),dateTimeCreated:new Date(e.dateTimeCreated)}}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:n(e.maximumBonusAmount),minimumBonusAmount:n(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:n(e.deposit.fee,0),amount:n(e.deposit.amount,0),netAmount:n(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:n(e.balance,0),amount:n(e.amount,0),expiration:new Date(e.expiration),turnoverRequirement:n(e.turnoverRequirement,0),currentTurnoverRequirementContribution:n(e.currentTurnoverRequirementContribution,0),currentTurnoverRequirementContributionPercentage:n(e.currentTurnoverRequirementContributionPercentage,0),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}cashbackBonus(e){return{id:e.id,balance:n(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:n(e.points,0),account:e.account,dateTimeCreated:new Date(e.dateTimeCreated)}}}class b{constructor(e,t){d(this,"url");d(this,"options");d(this,"middlewares");var r;const a=new Headers((r=t==null?void 0:t.fetchOptions)==null?void 0:r.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){const a=JSON.stringify({query:e,variables:t}),r=new Headers(this.options.headers);r.set("Content-Type","application/json"),r.set("Accept","application/json");const s=await this.runMiddlewares(new Request(this.url,{...this.options,body:a,headers:r,method:"POST"}));return await this.exec(s)}async upload(e,t){const a=this.createUploadBody(e,t),r=new Headers(this.options.headers);r.set("Accept","application/json"),r.delete("Content-Type");const s=await this.runMiddlewares(new Request(this.url,{...this.options,body:a,headers:r,method:"POST"}));return await this.exec(s)}async exec(e){var t,a,r,s,m;try{const p=await fetch(e);if(!p.ok)return{ok:!1,error:w(p.status)};const f=await p.json(),A=f.data,h=(t=f.errors)==null?void 0:t.at(0);return h?((a=h.extensions)==null?void 0:a.code)==="FORBIDDEN"?{ok:!1,error:w(403,h.message)}:((r=h.extensions)==null?void 0:r.code)==="UNAUTHORIZED"?{ok:!1,error:w(401,h.message)}:((s=h.extensions)==null?void 0:s.code)==="BAD_USER_INPUT"||((m=h.extensions)==null?void 0:m.code)==="BAD_REQUEST"?{ok:!1,error:w(400,h.message)}:{ok:!1,error:w(500,h.message)}:{ok:!0,data:A}}catch{return{ok:!1,error:w(500)}}}async runMiddlewares(e){let t=e.clone();for(const a of this.middlewares)t=await a(t);return t}createUploadBody(e,t){const{files:a,others:r}=this.extractFiles(t),s=new FormData;s.append("operations",JSON.stringify({query:e,variables:t})),Object.entries(r).forEach(([p,f])=>{s.append(p,JSON.stringify(f))});const m={};return Object.keys(a).forEach((p,f)=>{m[f.toString()]=`variables.${p}`}),s.append("map",JSON.stringify(m)),Object.values(a).forEach((p,f)=>{s.append(f.toString(),p)}),s}extractFiles(e){const t={},a={};return Object.entries(e).forEach(([r,s])=>{s instanceof File||s instanceof Blob?t[r]=s:a[r]=s}),{files:t,others:a}}}class yt{constructor(e){d(this,"gameService");d(this,"fileService");d(this,"walletService");d(this,"reportService");d(this,"portalService");d(this,"accountService");d(this,"sessionManager");d(this,"transformer");d(this,"logger");const t=e.environment==="development";this.sessionManager=new wt({...e,url:t?"https://auth.development.opexa.io":"https://auth.opexa.io"});const a={middlewares:[this.authMiddleware],fetchOptions:{headers:{Role:"MEMBER","Platform-Code":e.platform}}};this.gameService=new D(new b(t?"https://game.development.opexa.io/graphql":"https://game.opexa.io/graphql",a)),this.fileService=new mt(new b(t?"https://file.development.opexa.io/graphql":"https://file.opexa.io/graphql",a)),this.walletService=new pt(new b(t?"https://wallet.development.opexa.io/graphql":"https://wallet.opexa.io/graphql",a)),this.reportService=new ut(new b(t?"https://report.development.opexa.io/graphql":"https://report.opexa.io/graphql",a)),this.accountService=new dt(new b(t?"https://account.development.opexa.io/graphql":"https://account.opexa.io/graphql",a)),this.portalService=new ht(new b(t?"https://portal.development.opexa.io/graphql":"https://portal.opexa.io/graphql",a)),this.transformer=new gt(e),this.logger=new T({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 r=null;const s=()=>setTimeout(async()=>{await this.sessionManager.verify()||await a(),r=s()},t);return r=s(),function(){r&&clearTimeout(r)}}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??c.ObjectId.generate(l.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,btag:e.btag},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??c.ObjectId.generate(l.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:r})=>({...this.transformer.transform.announcement(r),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??c.ObjectId.generate(l.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:r})=>({...this.transformer.transform.withdrawalRecord(r),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??c.ObjectId.generate(l.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:r})=>({...this.transformer.transform.depositRecord(r),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:r})=>({...this.transformer.transform.betRecord(r),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:r})=>({...this.transformer.transform.transactionRecord(r),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:r})=>({...this.transformer.transform.game(r),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:r})=>({...this.transformer.transform.game(r),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??c.ObjectId.generate(l.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??c.ObjectId.generate(l.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??c.ObjectId.generate(l.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(u,"ObjectId",{enumerable:!0,get:()=>c.ObjectId}),u.ObjectType=l,u.Sdk=yt,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|
|
1013
|
+
`;class mt{constructor(e){c(this,"client");this.client=e}async memberAccount(){const e=await this.client.request(qe);return e.ok?{ok:!0,data:e.data.memberAccount}:e}async registerMemberAccount(e){const t=await this.client.request(Le,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(Ve,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(Ye,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(He,e);return t.ok?t.data.resetPassword?{ok:!1,error:t.data.resetPassword}:{ok:!0}:t}async profileCompletion(){const e=await this.client.request(Je);return e.ok?{ok:!0,data:e.data.profileCompletion}:e}async platform(){return await this.client.request(Xe)}async sendVerificationCode(e){const t=await this.client.request(je,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(Qe,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(Ke,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(ze,e);return t.ok?t.data.updateMemberVerification?{ok:!1,error:t.data.updateMemberVerification}:{ok:!0}:t}async memberVerification(){const e=await this.client.request(Fe);return e.ok?{ok:!0,data:e.data.memberAccount.verification}:e}async announcements(e){const t=await this.client.request(be,e);return t.ok?{ok:!0,data:t.data.announcements}:t}}function g(i,e){const t=v[i]?v[i]:v[500];return{code:t.code,message:e??t.message}}const v={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"}};class ut{constructor(e,t){c(this,"url");c(this,"options");c(this,"middlewares");var r;const a=new Headers((r=t==null?void 0:t.fetchOptions)==null?void 0:r.headers);a.append("Content-Type","application/json"),this.url=e,this.options={...t==null?void 0:t.fetchOptions,headers:a},this.middlewares=(t==null?void 0:t.middlewares)??[]}async post(e,t){const a=new URL(this.url);a.pathname=e,t!=null&&t.searchParams&&t.searchParams.forEach((d,u)=>{a.searchParams.append(u,d)});const r=t!=null&&t.body?JSON.stringify(t.body):void 0,n=await this.runMiddlewares(new Request(a,{...this.options,body:r,method:"POST"}));t!=null&&t.headers&&new Headers(t.headers).forEach((d,u)=>{n.headers.set(u,d)});try{const d=await fetch(n);return d.ok?{ok:!0,data:await d.json()}:{ok:!1,error:await this.safeToJson(d)??g(d.status)}}catch{return{ok:!1,error:{code:"HttpInternalServerError",message:"Something went wrong."}}}}async get(e,t){const a=new URL(this.url);a.pathname=e,t!=null&&t.searchParams&&t.searchParams.forEach((n,d)=>{a.searchParams.append(d,n)});const r=await this.runMiddlewares(new Request(a,{...this.options,method:"GET"}));t!=null&&t.headers&&new Headers(t.headers).forEach((n,d)=>{r.headers.set(d,n)});try{const n=await fetch(r);return n.ok?{ok:!0,data:await n.json()}:{ok:!1,error:await this.safeToJson(n)??g(n.status)}}catch{return{ok:!1,error:{code:"HttpInternalServerError",message:"Something went wrong."}}}}async delete(e,t){const a=new URL(this.url);a.pathname=e,t!=null&&t.searchParams&&t.searchParams.forEach((n,d)=>{a.searchParams.append(d,n)});const r=await this.runMiddlewares(new Request(a,{...this.options,method:"DELETE"}));t!=null&&t.headers&&new Headers(t.headers).forEach((n,d)=>{r.headers.set(d,n)});try{const n=await fetch(r);return n.ok?{ok:!0}:{ok:!1,error:g(n.status)}}catch{return{ok:!1,error:{code:"HttpInternalServerError",message:"Something went wrong."}}}}async runMiddlewares(e){let t=e.clone();for(const a of this.middlewares)t=await a(t);return t}async safeToJson(e){try{return await e.json()}catch{return null}}}class lt{constructor(e){c(this,"client");this.client=new ut(e.url,{middlewares:[t=>(t.headers.set("Platform-Code",e.platform),t.headers.set("Role","MEMBER"),t)]})}async createSession(e){const t=new Headers;switch(e.type){case"NAME_AND_PASSWORD":{const r=`${e.name}:${e.password}`,n=Buffer.from(r).toString("base64");t.set("Authorization",`Basic ${n}`);break}case"MOBILE_NUMBER":{const r=`${e.mobileNumber}:${e.verificationCode}`,n=Buffer.from(r).toString("base64");t.set("Authorization",`MobileNumberOTP ${n}`);break}case"MAYA":{t.set("Authorization",`Maya ${e.sessionId}`);break}}const a=await this.client.post("/sessions",{headers:t});return a.ok?a:a.error.code==="ACCOUNT_BLACKLISTED"?{ok:!1,error:{code:"AccountBlacklisted",message:"Account is blacklisted"}}:a.error.code==="HttpForbidden"||a.error.code==="HttpUnauthorized"?{ok:!1,error:{code:"AccountNotFound",message:"Invalid credentials."}}:a}async authenticate(e){if(e.type==="SECURITY_QUESTION"){const t=await this.client.post(`/session/${e.token}/authenticate`,{body:{secretAnswer:e.secretAnswer}});return t.ok?t:t.error.code==="HttpForbidden"||t.error.code==="HttpUnauthorized"?{ok:!1,error:{code:"InvalidTokenOrAnswer",message:"Invalid token or secret answer"}}:t}throw new Error("Invalid input 'type'")}async refreshSession(e){const t=await this.client.post("/session:refresh",{headers:{Authorization:`Bearer ${e}`}});return t.ok?t:t.error.code==="ACCOUNT_BLACKLISTED"?{ok:!1,error:{code:"AccountBlacklisted",message:"Account is blacklisted"}}:t.error.code==="HttpForbidden"||t.error.code==="HttpUnauthorized"?{ok:!1,error:{code:"InvalidToken",message:"Invalid token."}}:t}async destroySession(e){return await this.client.delete("/session",{headers:{Authorization:`Bearer ${e}`}})}async verifySession(e){return(await this.client.get("/session",{headers:{Authorization:`Bearer ${e}`}})).ok}}class pt{constructor(e){c(this,"client");this.client=e}async file(e){const t=await this.client.request(M,e);return t.ok?{ok:!0,data:t.data.node}:t}async uploadPrivateImageFile(e){const t=await this.client.upload(M,e);return t.ok?t.data.uploadPrivateImageFile?{ok:!1,error:t.data.uploadPrivateImageFile}:{ok:!0}:t}}class R{constructor(e){c(this,"client");this.client=e}async game(e){const t=await this.client.request(Se,e);return t.ok?{ok:!0,data:t.data.node}:t}async games(e){const t=await this.client.request(Ae,e);return t.ok?{ok:!0,data:t.data.games}:t}async gamesByName(e){const t=await this.client.request(Ee,e);return t.ok?{ok:!0,data:t.data.gamesByName}:t}async gameSession(e){const t=await this.client.request(ke,e);return t.ok?{ok:!0,data:t.data.node}:t}async createGameSession(e){const t=await this.client.request(Ce,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(Te,e);return t.ok?t.data.endGameSession?{ok:!0}:{ok:!1,error:{code:"UnknownError",message:"Something went wrong."}}:t}}class ht{constructor(e){c(this,"client");this.client=e}async betRecords(e){const t=await this.client.request(_e,e);return t.ok?{ok:t.ok,data:t.data.member.betRecords}:t}async transactionRecords(e){const t=await this.client.request(at,e);return t.ok?{ok:t.ok,data:t.data.member.transactionRecords}:t}async withdrawalRecords(e){const t=await this.client.request(nt,e);return t.ok?{ok:t.ok,data:t.data.member.withdrawalRecords}:t}async depositRecords(e){const t=await this.client.request(Pe,e);return t.ok?{ok:t.ok,data:t.data.member.depositRecords}:t}async depositsCount(){const e=await this.client.request(Be);return e.ok?{ok:e.ok,data:e.data.member.depositsCount}:e}async member(){const e=await this.client.request(Oe);return e.ok?{ok:e.ok,data:e.data.member}:e}}class wt{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 ft extends R{async promos(){const e=await this.client.request(Me);return e.ok?{ok:e.ok,data:e.data.promos}:e}async cashbacks(){const e=await this.client.request(De);return e.ok?{ok:e.ok,data:e.data.cashbacks}:e}async availablePromos(e){const t=await this.client.request(Ne,e);return t.ok?{ok:t.ok,data:t.data.availablePromos}:t}async cashbackBonuses(){const e=await this.client.request(Ie);return e.ok?{ok:e.ok,data:e.data.cashbackBonuses}:e}async claimCashbackBonus(e){const t=await this.client.request(Ge,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(Re);return e.ok?{ok:e.ok,data:e.data.bonus}:e}async wallet(){const e=await this.client.request(rt);return e.ok?{ok:e.ok,data:e.data.wallet}:e}async deposit(e){const t=await this.client.request(We,e);return t.ok?{ok:t.ok,data:t.data.node}:t}async createGCashDeposit(e){const t=await this.client.request($e,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(Ue,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(xe,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(st,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(ot,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(it,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(dt,e);return t.ok?t.data.createBankWithdrawal?{ok:!1,error:t.data.createBankWithdrawal}:{ok:!0}:t}async remainingDailyWithdrawalsCount(){const e=await this.client.request(ct);return e.ok?{ok:e.ok,data:e.data.remainingDailyWithdrawalsCount}:e}async pointsWallet(){const e=await this.client.request(Ze);return e.ok?{ok:e.ok,data:e.data.pointsWallet}:e}async pointsToCashConversion(e){const t=await this.client.request(et,e);return t.ok?t.data.pointsToCashConversion?{ok:!1,error:t.data.pointsToCashConversion}:{ok:!0}:t}async mayaSession(e){const t=await this.client.request(tt,e);return t.ok?{ok:t.ok,data:t.data.mayaSession}:t}}class gt{constructor(e){c(this,"client");this.client=e}async latestBetRecords(){const e=await this.client.request(ve);return e.ok?{ok:!0,data:e.data.latestBetRecords}:e}}class b{constructor(e,t){c(this,"url");c(this,"options");c(this,"middlewares");var r;const a=new Headers((r=t==null?void 0:t.fetchOptions)==null?void 0:r.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){const a=JSON.stringify({query:e,variables:t}),r=new Headers(this.options.headers);r.set("Content-Type","application/json"),r.set("Accept","application/json");const n=await this.runMiddlewares(new Request(this.url,{...this.options,body:a,headers:r,method:"POST"}));return await this.exec(n)}async upload(e,t){const a=this.createUploadBody(e,t),r=new Headers(this.options.headers);r.set("Accept","application/json"),r.delete("Content-Type");const n=await this.runMiddlewares(new Request(this.url,{...this.options,body:a,headers:r,method:"POST"}));return await this.exec(n)}async exec(e){var t,a,r,n,d,u;try{const w=await fetch(e);if(!w.ok)return{ok:!1,error:g(w.status)};const k=await w.json(),T=k.data,p=(t=k.errors)==null?void 0:t.at(0);return p?((a=p.extensions)==null?void 0:a.code)==="FORBIDDEN"?{ok:!1,error:g(403,p.message)}:((r=p.extensions)==null?void 0:r.code)==="UNAUTHORIZED"?{ok:!1,error:g(401,p.message)}:((n=p.extensions)==null?void 0:n.code)==="BAD_USER_INPUT"||((d=p.extensions)==null?void 0:d.code)==="BAD_REQUEST"?{ok:!1,error:g(400,p.message)}:((u=p.extensions)==null?void 0:u.code)==="ACCESS_TOKEN_EXPIRED"?{ok:!1,error:{code:"HttpForbidden",message:p.message??"Access token expired."}}:{ok:!1,error:g(500,p.message)}:{ok:!0,data:T}}catch{return{ok:!1,error:g(500)}}}async runMiddlewares(e){let t=e.clone();for(const a of this.middlewares)t=await a(t);return t}createUploadBody(e,t){const{files:a,others:r}=this.extractFiles(t),n=new FormData;n.append("operations",JSON.stringify({query:e,variables:t})),Object.entries(r).forEach(([u,w])=>{n.append(u,JSON.stringify(w))});const d={};return Object.keys(a).forEach((u,w)=>{d[w.toString()]=`variables.${u}`}),n.append("map",JSON.stringify(d)),Object.values(a).forEach((u,w)=>{n.append(w.toString(),u)}),n}extractFiles(e){const t={},a={};return Object.entries(e).forEach(([r,n])=>{n instanceof File||n instanceof Blob?t[r]=n:a[r]=n}),{files:t,others:a}}}async function f(i){const e=new TextEncoder().encode(i),t=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(t)).map(n=>n.toString(16).padStart(2,"0")).join("")}class I{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 D(i){return new Date(i.getTime())}function S(i,e){const t=D(i);return t.setDate(t.getDate()+e),t}function A(i,e){const t=D(i);return t.setMinutes(t.getMinutes()+e),t}function G(i,e){return i.getTime()>e.getTime()}function yt(i){return new Promise(e=>{setTimeout(e,i)})}function E(i,e){const t=D(i);return t.setMinutes(t.getMinutes()-e),t}class bt{constructor(e){c(this,"logger");c(this,"storageKey","session");c(this,"authService");c(this,"_refreshing",!1);this.authService=new lt(e),this.logger=new I({enabled:e.log??!1})}get refreshing(){return this._refreshing}set refreshing(e){this._refreshing=e}async create(e){if(this.isServer)return this.logger.warn("'localStorage' is not available on the server."),{ok:!1,error:{code:"UnknownError",message:"Server sign in is not supported."}};if(e.type==="MAYA"){const r=await this.authService.createSession(e);if(r.ok){const n=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...r.data,maya:!0,accessTokenExpiresAt:A(n,8).getTime(),refreshTokenExpiresAt:E(S(n,30),2).getTime()})),{ok:!0,data:null}}return r}if(e.type==="MOBILE_NUMBER"){const r=await this.authService.createSession(e);if(r.ok){const n=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...r.data,accessTokenExpiresAt:A(n,8).getTime(),refreshTokenExpiresAt:E(S(n,30),2).getTime()})),{ok:!0,data:null}}return r}const t=await this.authService.createSession(e);if(!t.ok)return t;if(t.data.authenticator)return{ok:!0,data:{authenticator:t.data.authenticator}};const a=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...t.data,accessTokenExpiresAt:A(a,8).getTime(),refreshTokenExpiresAt:E(S(a,30),2).getTime()})),{ok:!0,data:null}}async createFromAuthenticator(e){const t=await this.authService.authenticate(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:A(a,8).getTime(),refreshTokenExpiresAt:E(S(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 yt(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 r=new Date(t.accessTokenExpiresAt),n=new Date(t.refreshTokenExpiresAt);if(G(a,n))return this.logger.warn("Session expired. Logging out.."),window.localStorage.removeItem(this.storageKey),{ok:!1,error:{code:"SessionExpired",message:"Session expired."}};if(G(a,r)){this.logger.info("Refreshing session..."),this.refreshing=!0;const d=await this.authService.refreshSession(t.refreshToken);if(this.refreshing=!1,!d.ok)return this.logger.error(`Failed to refresh session: ${d.error.message}`),d.error.code==="InvalidToken"||d.error.code==="AccountBlacklisted"?(window.localStorage.removeItem(this.storageKey),{ok:!1,error:d.error}):(this.logger.warn("Old session returned."),{ok:!0,data:t});this.logger.success("Session refreshed!"),a=new Date,t={...t,...d.data,accessTokenExpiresAt:A(a,8).getTime(),refreshTokenExpiresAt:E(S(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,r,n;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"||((r=e.error)==null?void 0:r.code)==="SessionExpired"||((n=e.error)==null?void 0:n.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 s(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 St{constructor(e){c(this,"staticService");const t=(e==null?void 0:e.environment)==="development";this.staticService=new wt({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,r,n,d,u,w,k,T,p,P,$,U,x,W,B,O,q,F,L,V,H,Y,j,Q,K,z,J,X,Z,ee,te,ae,re,ne,se,oe,ie,de,ce,me,ue,le,pe,he,we,fe,ge,ye;return{paymentSettings:{minimumFirstDepositAmount:s(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:((r=e.bankDepositGatewaySettings)==null?void 0:r.webEnabled)??!1,mobileWebEnabled:((n=e.bankDepositGatewaySettings)==null?void 0:n.mobileWebEnabled)??!1,minimumAmount:s((d=e.bankDepositGatewaySettings)==null?void 0:d.minimumAmount),maximumAmount:s((u=e.bankDepositGatewaySettings)==null?void 0:u.maximumAmount)},gcash:{androidEnabled:((w=e.gcashDepositGatewaySettings)==null?void 0:w.androidEnabled)??!1,iosEnabled:((k=e.gcashDepositGatewaySettings)==null?void 0:k.iosEnabled)??!1,webEnabled:((T=e.gcashDepositGatewaySettings)==null?void 0:T.webEnabled)??!1,mobileWebEnabled:((p=e.gcashDepositGatewaySettings)==null?void 0:p.mobileWebEnabled)??!1,minimumAmount:s((P=e.gcashDepositGatewaySettings)==null?void 0:P.minimumAmount),maximumAmount:s(($=e.gcashDepositGatewaySettings)==null?void 0:$.maximumAmount)},maya:{androidEnabled:((U=e.mayaDepositGatewaySettings)==null?void 0:U.androidEnabled)??!1,iosEnabled:((x=e.mayaDepositGatewaySettings)==null?void 0:x.iosEnabled)??!1,webEnabled:((W=e.mayaDepositGatewaySettings)==null?void 0:W.webEnabled)??!1,mobileWebEnabled:((B=e.mayaDepositGatewaySettings)==null?void 0:B.mobileWebEnabled)??!1,minimumAmount:s((O=e.mayaDepositGatewaySettings)==null?void 0:O.minimumAmount),maximumAmount:s((q=e.mayaDepositGatewaySettings)==null?void 0:q.maximumAmount)},mayaApp:{androidEnabled:((F=e.mayaAppDepositGatewaySettings)==null?void 0:F.androidEnabled)??!1,iosEnabled:((L=e.mayaAppDepositGatewaySettings)==null?void 0:L.iosEnabled)??!1,webEnabled:((V=e.mayaAppDepositGatewaySettings)==null?void 0:V.webEnabled)??!1,mobileWebEnabled:((H=e.mayaAppDepositGatewaySettings)==null?void 0:H.mobileWebEnabled)??!1,minimumAmount:s((Y=e.mayaAppDepositGatewaySettings)==null?void 0:Y.minimumAmount),maximumAmount:s((j=e.mayaAppDepositGatewaySettings)==null?void 0:j.maximumAmount)}},withdrawalGateway:{bank:{androidEnabled:((Q=e.bankWithdrawalGatewaySettings)==null?void 0:Q.androidEnabled)??!1,iosEnabled:((K=e.bankWithdrawalGatewaySettings)==null?void 0:K.iosEnabled)??!1,webEnabled:((z=e.bankWithdrawalGatewaySettings)==null?void 0:z.webEnabled)??!1,mobileWebEnabled:((J=e.bankWithdrawalGatewaySettings)==null?void 0:J.mobileWebEnabled)??!1,minimumAmount:s((X=e.bankWithdrawalGatewaySettings)==null?void 0:X.minimumAmount),maximumAmount:s((Z=e.bankWithdrawalGatewaySettings)==null?void 0:Z.maximumAmount)},gcash:{androidEnabled:((ee=e.gcashWithdrawalGatewaySettings)==null?void 0:ee.androidEnabled)??!1,iosEnabled:((te=e.gcashWithdrawalGatewaySettings)==null?void 0:te.iosEnabled)??!1,webEnabled:((ae=e.gcashWithdrawalGatewaySettings)==null?void 0:ae.webEnabled)??!1,mobileWebEnabled:((re=e.gcashWithdrawalGatewaySettings)==null?void 0:re.mobileWebEnabled)??!1,minimumAmount:s((ne=e.gcashWithdrawalGatewaySettings)==null?void 0:ne.minimumAmount),maximumAmount:s((se=e.gcashWithdrawalGatewaySettings)==null?void 0:se.maximumAmount,1e6)},maya:{androidEnabled:((oe=e.mayaWithdrawalGatewaySettings)==null?void 0:oe.androidEnabled)??!1,iosEnabled:((ie=e.mayaWithdrawalGatewaySettings)==null?void 0:ie.iosEnabled)??!1,webEnabled:((de=e.mayaWithdrawalGatewaySettings)==null?void 0:de.webEnabled)??!1,mobileWebEnabled:((ce=e.mayaWithdrawalGatewaySettings)==null?void 0:ce.mobileWebEnabled)??!1,minimumAmount:s((me=e.mayaWithdrawalGatewaySettings)==null?void 0:me.minimumAmount),maximumAmount:s((ue=e.mayaWithdrawalGatewaySettings)==null?void 0:ue.maximumAmount)},mayaApp:{androidEnabled:((le=e.mayaAppWithdrawalGatewaySettings)==null?void 0:le.androidEnabled)??!1,iosEnabled:((pe=e.mayaAppWithdrawalGatewaySettings)==null?void 0:pe.iosEnabled)??!1,webEnabled:((he=e.mayaAppWithdrawalGatewaySettings)==null?void 0:he.webEnabled)??!1,mobileWebEnabled:((we=e.mayaAppWithdrawalGatewaySettings)==null?void 0:we.mobileWebEnabled)??!1,minimumAmount:s((fe=e.mayaAppWithdrawalGatewaySettings)==null?void 0:fe.minimumAmount),maximumAmount:s((ge=e.mayaAppWithdrawalGatewaySettings)==null?void 0:ge.maximumAmount,1e6)}}},pointsClubSettings:{multiplier:s((ye=e.pointsClubSettings)==null?void 0:ye.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:s(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:s(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:s(e.amount,0),netAmount:s(e.netAmount,0),fee:s(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:s(e.fee,0),amount:s(e.amount,0),netAmount:s(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:s(e.amount,0),fee:s(e.fee,0),netAmount:s(e.netAmount,0),reference:e.reference??void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}betRecord(e){var t;return{...e,bet:s(e.bet,0),payout:s(e.payout,0),jackpotContribution:s(e.jackpotContribution,0),jackpotPayout:s(e.jackpotPayout,0),winloss:s(e.winloss),validBet:s(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}}}latestBetRecord(e){return{...e,game:this.game(e.game),bet:s(e.bet,0),payout:s(e.payout,0),validBet:s(e.validBet,0),dateTimeSettled:new Date(e.dateTimeSettled),dateTimeCreated:new Date(e.dateTimeCreated)}}transactionRecord(e){return{...e,amount:s(e.amount,0),content:e.content??void 0,currentBalance:s(e.currentBalance,0),dateTimeCreated:new Date(e.dateTimeCreated)}}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:s(e.maximumBonusAmount),minimumBonusAmount:s(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:s(e.deposit.fee,0),amount:s(e.deposit.amount,0),netAmount:s(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:s(e.balance,0),amount:s(e.amount,0),expiration:new Date(e.expiration),turnoverRequirement:s(e.turnoverRequirement,0),currentTurnoverRequirementContribution:s(e.currentTurnoverRequirementContribution,0),currentTurnoverRequirementContributionPercentage:s(e.currentTurnoverRequirementContributionPercentage,0),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}cashbackBonus(e){return{id:e.id,balance:s(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:s(e.points,0),account:e.account,dateTimeCreated:new Date(e.dateTimeCreated)}}}class At{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 bt({...e,url:t?"https://auth.development.opexa.io":"https://auth.opexa.io"});const a={middlewares:[this.authMiddleware],fetchOptions:{headers:{Role:"MEMBER","Platform-Code":e.platform}}};this.gameService=new R(new b(t?"https://game.development.opexa.io/graphql":"https://game.opexa.io/graphql",a)),this.fileService=new pt(new b(t?"https://file.development.opexa.io/graphql":"https://file.opexa.io/graphql",a)),this.walletService=new ft(new b(t?"https://wallet.development.opexa.io/graphql":"https://wallet.opexa.io/graphql",a)),this.reportService=new ht(new b(t?"https://report.development.opexa.io/graphql":"https://report.opexa.io/graphql",a)),this.accountService=new mt(new b(t?"https://account.development.opexa.io/graphql":"https://account.opexa.io/graphql",a)),this.portalService=new gt(new b(t?"https://portal.development.opexa.io/graphql":"https://portal.opexa.io/graphql",a)),this.transformer=new St(e),this.logger=new I({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){switch(e.type){case"NAME_AND_PASSWORD":{const t=await this.sessionManager.create({...e,password:await f(e.password)});return t.data?{ok:!0,data:{"2FAEnabled":!0,authenticator:t.data.authenticator}}:{ok:!0,data:{"2FAEnabled":!1}}}default:{const t=await this.sessionManager.create(e);return t.ok?{ok:!0}:t}}}async authenticate(e){switch(e.type){case"SECURITY_QUESTION":return await this.sessionManager.createFromAuthenticator({type:"SECURITY_QUESTION",token:e.token,secretAnswer:await f(e.secretAnswer)});default:return{ok:!1,error:{code:"HttpBadRequest",message:"Invalid input 'type'"}}}}async signOut(){await this.sessionManager.destroy()}watchSession(e){const t=e.interval??3e4,a=e.onInvalid;let r=null;const n=()=>setTimeout(async()=>{await this.sessionManager.verify()||await a(),r=n()},t);return r=n(),function(){r&&clearTimeout(r)}}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(h.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 f(e.password),mobileNumber:this.addAreaCode(e.mobileNumber),domain:e.domain,btag:e.btag},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 f(t.password):void 0,transactionPassword:t.transactionPassword?await f(t.transactionPassword):void 0,...t.mobileNumber&&{mobileNumber:this.addAreaCode(t.mobileNumber)},secretAnswer:t.secretAnswer?await f(t.secretAnswer):void 0}}})}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(h.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 f(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:r})=>({...this.transformer.transform.announcement(r),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(h.Withdrawal).toString();if(e.type==="BANK"){const a=await this.walletService.createBankWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await f(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 f(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 f(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 f(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:r})=>({...this.transformer.transform.withdrawalRecord(r),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(h.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:r})=>({...this.transformer.transform.depositRecord(r),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:r})=>({...this.transformer.transform.betRecord(r),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:r})=>({...this.transformer.transform.transactionRecord(r),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:r})=>({...this.transformer.transform.game(r),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:r})=>({...this.transformer.transform.game(r),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(h.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(h.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(h.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:()=>m.ObjectId}),l.ObjectType=h,l.Sdk=At,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
|
1007
1014
|
//# sourceMappingURL=index.js.map
|