@opexa/portal-sdk 0.0.96 → 0.0.97

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(b,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("@opexa/object-id")):typeof define=="function"&&define.amd?define(["exports","@opexa/object-id"],h):(b=typeof globalThis<"u"?globalThis:b||self,h(b.sdk={},b.objectId))})(this,function(b,h){"use strict";var zt=Object.defineProperty;var Jt=(b,h,E)=>h in b?zt(b,h,{enumerable:!0,configurable:!0,writable:!0,value:E}):b[h]=E;var c=(b,h,E)=>Jt(b,typeof h!="symbol"?h+"":h,E);const E={Account:8,Deposit:9,Withdrawal:14,Verification:15,File:16,Game:203,GameSession:204,MayaSession:230};function o(i,...e){let t="";for(const[r,a]of i.entries()){const s=e.at(r)??"";t=`${t}${a}${s}`}return t.trim()}const ue=o`
1
+ (function(b,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("@opexa/object-id")):typeof define=="function"&&define.amd?define(["exports","@opexa/object-id"],h):(b=typeof globalThis<"u"?globalThis:b||self,h(b.sdk={},b.objectId))})(this,function(b,h){"use strict";var Xt=Object.defineProperty;var Zt=(b,h,E)=>h in b?Xt(b,h,{enumerable:!0,configurable:!0,writable:!0,value:E}):b[h]=E;var c=(b,h,E)=>Zt(b,typeof h!="symbol"?h+"":h,E);const E={Account:8,Deposit:9,Withdrawal:14,Verification:15,File:16,Game:203,GameSession:204,MayaSession:230};function o(i,...e){let t="";for(const[r,a]of i.entries()){const s=e.at(r)??"";t=`${t}${a}${s}`}return t.trim()}const de=o`
2
2
  fragment FileFragment on File {
3
3
  id
4
4
  url
@@ -6,7 +6,7 @@
6
6
  dateTimeCreated
7
7
  }
8
8
  `,Te=o`
9
- ${ue}
9
+ ${de}
10
10
 
11
11
  query File($id: ObjectId!) {
12
12
  node(id: $id) {
@@ -164,7 +164,7 @@
164
164
  }
165
165
  }
166
166
  }
167
- `,Ge=o`
167
+ `,Pe=o`
168
168
  query WithdrawalRecords($first: Int, $after: Cursor, $filter: WithdrawalRecordFilterInput) {
169
169
  member {
170
170
  withdrawalRecords(first: $first, after: $after, filter: $filter) {
@@ -231,7 +231,7 @@
231
231
  }
232
232
  }
233
233
  }
234
- `,Pe=o`
234
+ `,Ge=o`
235
235
  mutation CreateGCashWithdrawal($input: CreateGCashWithdrawalInput!) {
236
236
  createGCashWithdrawal(input: $input) {
237
237
  ... on AccountNotVerifiedError {
@@ -254,7 +254,7 @@
254
254
  }
255
255
  }
256
256
  }
257
- `,We=o`
257
+ `,xe=o`
258
258
  mutation CreateMayaWithdrawal($input: CreateMayaWithdrawalInput!) {
259
259
  createMayaWithdrawal(input: $input) {
260
260
  ... on AccountNotVerifiedError {
@@ -277,7 +277,7 @@
277
277
  }
278
278
  }
279
279
  }
280
- `,xe=o`
280
+ `,Oe=o`
281
281
  mutation CreateMayaAppWithdrawal($input: CreateMayaAppWithdrawalInput!) {
282
282
  createMayaAppWithdrawal(input: $input) {
283
283
  ... on AccountNotVerifiedError {
@@ -297,7 +297,7 @@
297
297
  }
298
298
  }
299
299
  }
300
- `,$e=o`
300
+ `,We=o`
301
301
  mutation CreateBankWithdrawal($input: CreateBankWithdrawalInput!) {
302
302
  createBankWithdrawal(input: $input) {
303
303
  ... on MobileNumberNotVerifiedError {
@@ -320,11 +320,11 @@
320
320
  }
321
321
  }
322
322
  }
323
- `,Ue=o`
323
+ `,$e=o`
324
324
  query RemainingDailyWithdrawalsCount {
325
325
  remainingDailyWithdrawalsCount
326
326
  }
327
- `,Oe=o`
327
+ `,Ue=o`
328
328
  query DepositRecords($after: Cursor, $first: Int, $filter: DepositRecordFilterInput) {
329
329
  member {
330
330
  depositRecords(after: $after, first: $first, filter: $filter) {
@@ -441,6 +441,64 @@
441
441
  }
442
442
  }
443
443
  `,Le=o`
444
+ mutation CreateAIOQRPHDeposit($input: CreateAIOQRPHDepositInput!) {
445
+ createAIOQRPHDeposit(input: $input) {
446
+ ... on DepositPromoMaximumAmountExceededError {
447
+ __typename
448
+ }
449
+ ... on DepositPromoMinimumAmountNotMetError {
450
+ __typename
451
+ }
452
+ ... on HasActiveBonusError {
453
+ __typename
454
+ }
455
+ ... on MaximumDepositAmountExceededError {
456
+ __typename
457
+ }
458
+ ... on MinimumDepositAmountNotMetError {
459
+ __typename
460
+ }
461
+ ... on MinimumFirstDepositAmountNotMetError {
462
+ __typename
463
+ }
464
+ ... on PromoNotEnabledError {
465
+ __typename
466
+ }
467
+ ... on WalletDoesNotExistError {
468
+ __typename
469
+ }
470
+ }
471
+ }
472
+ `,Ve=o`
473
+ mutation CreateAIOOnlineBankDeposit($input: CreateAIOOnlineBankDepositInput!) {
474
+ createAIOOnlineBankDeposit(input: $input) {
475
+ ... on DepositPromoMaximumAmountExceededError {
476
+ __typename
477
+ }
478
+ ... on DepositPromoMinimumAmountNotMetError {
479
+ __typename
480
+ }
481
+ ... on HasActiveBonusError {
482
+ __typename
483
+ }
484
+ ... on MaximumDepositAmountExceededError {
485
+ __typename
486
+ }
487
+ ... on MinimumDepositAmountNotMetError {
488
+ __typename
489
+ }
490
+ ... on MinimumFirstDepositAmountNotMetError {
491
+ __typename
492
+ }
493
+ ... on PromoNotEnabledError {
494
+ __typename
495
+ }
496
+ ... on WalletDoesNotExistError {
497
+ __typename
498
+ }
499
+ }
500
+ }
501
+ `,He=o`
444
502
  query Deposit($id: ObjectId!) {
445
503
  node(id: $id) {
446
504
  ... on GCashDeposit {
@@ -470,15 +528,27 @@
470
528
  type
471
529
  status
472
530
  }
531
+ ... on QRPHDeposit {
532
+ id
533
+ type
534
+ status
535
+ qrCode
536
+ }
537
+ ... on OnlineBankDeposit {
538
+ id
539
+ type
540
+ status
541
+ vca
542
+ }
473
543
  }
474
544
  }
475
- `,Ve=o`
545
+ `,Ye=o`
476
546
  query DepositsCount {
477
547
  member {
478
548
  depositsCount
479
549
  }
480
550
  }
481
- `,He=o`
551
+ `,je=o`
482
552
  query BetRecords($first: Int, $after: Cursor, $filter: BetRecordFilterInput) {
483
553
  member {
484
554
  betRecords(first: $first, after: $after, filter: $filter) {
@@ -519,7 +589,7 @@
519
589
  }
520
590
  }
521
591
  }
522
- `,Ye=o`
592
+ `,Qe=o`
523
593
  query LatestBetRecords {
524
594
  latestBetRecords {
525
595
  id
@@ -539,7 +609,7 @@
539
609
  dateTimeCreated
540
610
  }
541
611
  }
542
- `,je=o`
612
+ `,Ke=o`
543
613
  query TransactionRecords($first: Int, $after: Cursor, $filter: TransactionRecordFilter) {
544
614
  member {
545
615
  transactionRecords(first: $first, after: $after, filter: $filter) {
@@ -566,7 +636,7 @@
566
636
  }
567
637
  }
568
638
  `,le=o`
569
- ${ue}
639
+ ${de}
570
640
 
571
641
  fragment PromoFragment on Promo {
572
642
  id
@@ -584,7 +654,7 @@
584
654
  dateTimeCreated
585
655
  dateTimeLastUpdated
586
656
  }
587
- `,Qe=o`
657
+ `,ze=o`
588
658
  ${le}
589
659
 
590
660
  query Promos {
@@ -592,7 +662,7 @@
592
662
  ...PromoFragment
593
663
  }
594
664
  }
595
- `,Ke=o`
665
+ `,Je=o`
596
666
  ${le}
597
667
 
598
668
  query AvailablePromos($filter: PromoFilterInput) {
@@ -600,8 +670,8 @@
600
670
  ...PromoFragment
601
671
  }
602
672
  }
603
- `,Se=o`
604
- ${ue}
673
+ `,Ae=o`
674
+ ${de}
605
675
 
606
676
  fragment CashbackFragment on Cashback {
607
677
  id
@@ -619,15 +689,15 @@
619
689
  dateTimeCreated
620
690
  dateTimeLastUpdated
621
691
  }
622
- `,ze=o`
623
- ${Se}
692
+ `,Xe=o`
693
+ ${Ae}
624
694
 
625
695
  query Cashbacks {
626
696
  cashbacks {
627
697
  ...CashbackFragment
628
698
  }
629
699
  }
630
- `,Je=o`
700
+ `,Ze=o`
631
701
  ${le}
632
702
 
633
703
  query Bonus {
@@ -656,8 +726,8 @@
656
726
  dateTimeLastUpdated
657
727
  }
658
728
  }
659
- `,Xe=o`
660
- ${Se}
729
+ `,et=o`
730
+ ${Ae}
661
731
 
662
732
  query CashbackBonuses {
663
733
  cashbackBonuses {
@@ -671,7 +741,7 @@
671
741
  dateTimeLastUpdated
672
742
  }
673
743
  }
674
- `,Ze=o`
744
+ `,tt=o`
675
745
  mutation ClaimCashbackBonus($input: ClaimCashbackBonusInput!) {
676
746
  claimCashbackBonus(input: $input) {
677
747
  ... on CashbackBonusDoesNotExistError {
@@ -685,7 +755,7 @@
685
755
  dateTimeLastActive
686
756
  }
687
757
  }
688
- `;const et=o`
758
+ `;const rt=o`
689
759
  query MemberAccount {
690
760
  memberAccount: self {
691
761
  ... on MemberAccount {
@@ -709,8 +779,8 @@
709
779
  }
710
780
  }
711
781
  }
712
- `,tt=o`
713
- ${ue}
782
+ `,at=o`
783
+ ${de}
714
784
 
715
785
  query MemberVerification {
716
786
  memberAccount: self {
@@ -734,7 +804,7 @@
734
804
  }
735
805
  }
736
806
  }
737
- `,rt=o`
807
+ `,nt=o`
738
808
  mutation RegisterMemberAccount(
739
809
  $input: RegisterMemberAccountInput!
740
810
  $referralCode: String
@@ -770,7 +840,7 @@
770
840
  }
771
841
  }
772
842
  }
773
- `,at=o`
843
+ `,it=o`
774
844
  mutation RegisterMemberAccountViaMobile(
775
845
  $input: RegisterMemberAccountViaMobileInput!
776
846
  $referralCode: String
@@ -797,7 +867,7 @@
797
867
  }
798
868
  }
799
869
  }
800
- `,nt=o`
870
+ `,ot=o`
801
871
  mutation RegisterMemberAccount(
802
872
  $input: RegisterMemberAccountInput_next!
803
873
  $reCAPTCHAResponse: String
@@ -829,7 +899,7 @@
829
899
  }
830
900
  }
831
901
  }
832
- `,it=o`
902
+ `,st=o`
833
903
  mutation RegisterMayaMemberAccount($input: RegisterMayaMemberAccountInput!) {
834
904
  registerMayaMemberAccount(input: $input) {
835
905
  ... on AccountNameNotAvailableError {
@@ -837,7 +907,7 @@
837
907
  }
838
908
  }
839
909
  }
840
- `,ot=o`
910
+ `,mt=o`
841
911
  mutation UpdateMemberAccount($input: UpdateMemberAccountInput!) {
842
912
  updateMemberAccount(input: $input) {
843
913
  ... on AccountNameNotAvailableError {
@@ -863,7 +933,7 @@
863
933
  }
864
934
  }
865
935
  }
866
- `,st=o`
936
+ `,ct=o`
867
937
  mutation ResetPassword($input: ResetPasswordInput!, $verificationCode: String) {
868
938
  resetPassword(input: $input, verificationCode: $verificationCode) {
869
939
  ... on AccountNotFoundError {
@@ -874,11 +944,11 @@
874
944
  }
875
945
  }
876
946
  }
877
- `,mt=o`
947
+ `,ut=o`
878
948
  mutation DeleteMemberAccount($input: DeleteMemberAccountInput!) {
879
949
  deleteMemberAccount(input: $input)
880
950
  }
881
- `,ct=o`
951
+ `,dt=o`
882
952
  mutation VerifyMobileNumber($input: VerifyMobileNumberInput!) {
883
953
  verifyMobileNumber(input: $input) {
884
954
  ... on InvalidSMSVerificationCodeError {
@@ -889,7 +959,7 @@
889
959
  }
890
960
  }
891
961
  }
892
- `,dt=o`
962
+ `,lt=o`
893
963
  mutation CreateMemberVerification($input: CreateMemberVerificationInput!) {
894
964
  createMemberVerification(input: $input) {
895
965
  ... on FileDoesNotExistError {
@@ -903,7 +973,7 @@
903
973
  }
904
974
  }
905
975
  }
906
- `,ut=o`
976
+ `,pt=o`
907
977
  mutation UpdateMemberVerification($input: UpdateMemberVerificationInput!) {
908
978
  updateMemberVerification(input: $input) {
909
979
  ... on FileDoesNotExistError {
@@ -920,7 +990,7 @@
920
990
  }
921
991
  }
922
992
  }
923
- `,lt=o`
993
+ `,ft=o`
924
994
  query ProfileCompletion {
925
995
  profileCompletion {
926
996
  completionPercentage
@@ -931,7 +1001,7 @@
931
1001
  accountPassword
932
1002
  }
933
1003
  }
934
- `,pt=o`
1004
+ `,ht=o`
935
1005
  mutation SendVerificationCode($input: SendVerificationCodeInput!) {
936
1006
  sendVerificationCode(input: $input) {
937
1007
  ... on InvalidPlatformError {
@@ -942,7 +1012,7 @@
942
1012
  }
943
1013
  }
944
1014
  }
945
- `,ft=o`
1015
+ `,wt=o`
946
1016
  fragment DepositGatewaySettingsCoreData on DepositGatewaySettings {
947
1017
  minimumAmount
948
1018
  maximumAmount
@@ -998,12 +1068,12 @@
998
1068
  multiplier
999
1069
  }
1000
1070
  }
1001
- `,ht=o`
1071
+ `,yt=o`
1002
1072
  query Platform {
1003
1073
  timezone
1004
1074
  currency
1005
1075
  }
1006
- `,wt=o`
1076
+ `,gt=o`
1007
1077
  fragment DepositGatewaySettingsCoreData on DepositGatewaySettings {
1008
1078
  minimumAmount
1009
1079
  maximumAmount
@@ -1054,7 +1124,7 @@
1054
1124
  ...WithdrawalGatewaySettingsCoreData
1055
1125
  }
1056
1126
  }
1057
- `,yt=o`
1127
+ `,bt=o`
1058
1128
  query MayaSession($id: ObjectId!) {
1059
1129
  mayaSession(id: $id) {
1060
1130
  id
@@ -1062,11 +1132,11 @@
1062
1132
  dateTimeCreated
1063
1133
  }
1064
1134
  }
1065
- `,gt=o`
1135
+ `,Et=o`
1066
1136
  mutation ValidateMayaSession {
1067
1137
  validateMayaSession: validMayaSession
1068
1138
  }
1069
- `,bt=o`
1139
+ `,At=o`
1070
1140
  query ActivityRecords($after: Cursor, $first: Int, $filter: ActivityRecordsFilterInput) {
1071
1141
  member {
1072
1142
  activityRecords(after: $after, first: $first, filter: $filter) {
@@ -1091,11 +1161,11 @@
1091
1161
  }
1092
1162
  }
1093
1163
  }
1094
- `,Et=o`
1164
+ `,St=o`
1095
1165
  query ReferralCode {
1096
1166
  referralCode
1097
1167
  }
1098
- `,St=o`
1168
+ `,kt=o`
1099
1169
  mutation UpdateReferralCode($input: UpdateReferralCodeInput!) {
1100
1170
  updateReferralCode(input: $input) {
1101
1171
  ... on ReferralCodeNotAvailableError {
@@ -1121,7 +1191,7 @@
1121
1191
  commission
1122
1192
  dateTimeCreated
1123
1193
  }
1124
- `,At=o`
1194
+ `,Ct=o`
1125
1195
  query Referrals($first: Int, $after: Cursor, $filter: ReferralFilterInput) {
1126
1196
  member {
1127
1197
  referrals(first: $first, after: $after, filter: $filter) {
@@ -1143,7 +1213,7 @@
1143
1213
  }
1144
1214
 
1145
1215
  ${pe}
1146
- `,kt=o`
1216
+ `,_t=o`
1147
1217
  query UplinesByName($search: String!, $first: Int) {
1148
1218
  uplinesByName(search: $search, first: $first) {
1149
1219
  ...ReferralFragment
@@ -1151,7 +1221,7 @@
1151
1221
  }
1152
1222
 
1153
1223
  ${pe}
1154
- `,Ct=o`
1224
+ `,Tt=o`
1155
1225
  query DownlinesByName($search: String!, $first: Int) {
1156
1226
  downlinesByName(search: $search, first: $first) {
1157
1227
  ...ReferralFragment
@@ -1159,7 +1229,7 @@
1159
1229
  }
1160
1230
 
1161
1231
  ${pe}
1162
- `,_t=o`
1232
+ `,Mt=o`
1163
1233
  query ReferralCommission {
1164
1234
  member {
1165
1235
  referralCommission {
@@ -1178,13 +1248,13 @@
1178
1248
  }
1179
1249
  }
1180
1250
  }
1181
- `,Tt=o`
1251
+ `,vt=o`
1182
1252
  query PointsClubSettings {
1183
1253
  pointsClubSettings {
1184
1254
  multiplier
1185
1255
  }
1186
1256
  }
1187
- `,Mt=o`
1257
+ `,Rt=o`
1188
1258
  query Messages($first: Int, $after: Cursor, $filter: MessageFilterInput) {
1189
1259
  messages(first: $first, after: $after, filter: $filter) {
1190
1260
  edges {
@@ -1212,19 +1282,19 @@
1212
1282
  }
1213
1283
  }
1214
1284
  }
1215
- `,vt=o`
1285
+ `,Nt=o`
1216
1286
  query UnreadMessagesCount($filter: MessageFilterInput) {
1217
1287
  messages(filter: $filter) {
1218
1288
  totalCount
1219
1289
  }
1220
1290
  }
1221
- `,Rt=o`
1291
+ `,Dt=o`
1222
1292
  mutation MarkMessageAsRead($id: ObjectId!) {
1223
1293
  markMessageAsRead(id: $id)
1224
1294
  }
1225
- `,Nt=o`
1295
+ `,It=o`
1226
1296
  mutation MarkAllMessageAsRead {
1227
1297
  markAllMessageAsRead
1228
1298
  }
1229
- `;function d(i){return{name:i,message:{AccountNameNotAvailableError:"Username is no longer available",AccountNotFoundError:"Account does not exist",AccountNotVerifiedError:"Account is not verified",CashbackBonusDoesNotExistError:"Cashback bonus does not exists",DepositPromoMaximumAmountExceededError:"Deposit amount exceeds maximum amount",DepositPromoMinimumAmountNotMetError:"Deposit amount does not meet minimum amount",EmailAddressNotAvailableError:"Email is no longer available",FileDoesNotExistError:"File does not exist",FileFormatNotSupportedError:"File format is not supported",FileNameTooLongError:"File name is too long",FileNotReadyError:"File is not yet ready",FileSizeTooBigError:"File size is too big",GameDoesNotExistError:"Game does not exist",HasActiveBonusError:"Account has active bonus",InsufficientPointsError:"Insufficient points",InvalidPlatformError:"Invalid platform",InvalidReCAPTCHAResponseError:"Invalid reCAPTCHA",InvalidSMSVerificationCodeError:"Invalid SMS verification code",InvalidTransactionPasswordError:"Invalid transaction password",InvalidVerificationCodeError:"Invalid verification code",InvalidWithdrawalAmountError:"Invalid withdrawal amount",MaximumDepositAmountExceededError:"Maximum deposit amount exceeded",MemberVerificationAlreadyApprovedError:"Member verification is already approved",MemberVerificationAlreadyExistsError:"Member verification already exists",MemberVerificationDoesNotExistError:"Member verification does not exist",MinimumAgeRequirementError:"Minimum age requirement not met",MinimumDepositAmountNotMetError:"Minimum deposit amount not met",MinimumFirstDepositAmountNotMetError:"Minimum first deposit amount not met",MobileNumberAlreadyVerifiedError:"Mobile number is already verified",MobileNumberNotAvailableError:"Mobile number is no longer available",MobileNumberNotVerifiedError:"Mobile number is not verified",NickNameNotAvailableError:"Nickname is no longer available",NotEnoughBalanceError:"Insufficient balance",NotReadyToSendVerficationCodeError:"Not ready to send verification code",PromoNotEnabledError:"Promo is not enabled",RealNameAlreadySetError:"Real name is already set",ValidIdAlreadySetError:"Valid ID is already set",WalletDoesNotExistError:"Wallet does not exist",WithdrawalDailyLimitExceededError:"Daily withdrawal limit exceeded",GameProviderError:"Game provider error",GameSessionAlreadyClosedError:"Game session is already closed",GameSessionDoesNotExistError:"Game session does not exist",ReferralCodeNotAvailableError:"Referral code is no longer available",AccountBlacklistedError:"Account is blacklisted",InvalidTokenError:"Invalid token",InvalidTokenOrSecretAnswerError:"Invalid token or secret answer",SessionExpiredError:"Session expired",RateLimitExceededError:"Maximum number of requests reached"}[i]}}class Dt{constructor(e){c(this,"client");this.client=e}async memberAccount(){const e=await this.client.request(et);return e.ok?{ok:!0,data:e.data.memberAccount}:e}async registerMemberAccount(e){const t=await this.client.request(rt,e);return t.ok?t.data.registerMemberAccount?{ok:!1,error:d(t.data.registerMemberAccount.__typename)}:{ok:!0}:t}async registerMemberAccountViaMobile(e){const t=await this.client.request(at,e);return t.ok?t.data.registerMemberAccountViaMobile?{ok:!1,error:d(t.data.registerMemberAccountViaMobile.__typename)}:{ok:!0}:t}async registerMemberAccount__next(e){const t=await this.client.request(nt,e);return t.ok?t.data.registerMemberAccount?{ok:!1,error:d(t.data.registerMemberAccount.__typename)}:{ok:!0}:t}async updateMemberAccount(e){const t=await this.client.request(ot,e);return t.ok?t.data.updateMemberAccount?{ok:!1,error:d(t.data.updateMemberAccount.__typename)}:{ok:!0}:t}async deleteMemberAccount(e){const t=await this.client.request(mt,e);return t.ok?t.data.deleteMemberAccount?{ok:!0}:{ok:!1,error:{name:"UnknownError",message:"Something went wrong."}}:t}async resetPassword(e){const t=await this.client.request(st,e);return t.ok?t.data.resetPassword?{ok:!1,error:d(t.data.resetPassword.__typename)}:{ok:!0}:t}async profileCompletion(){const e=await this.client.request(lt);return e.ok?{ok:!0,data:e.data.profileCompletion}:e}async platform(){return await this.client.request(ft)}async sendVerificationCode(e){const t=await this.client.request(pt,e);return t.ok?t.data.sendVerificationCode?{ok:!1,error:d(t.data.sendVerificationCode.__typename)}:{ok:!0}:t}async paymentSettings(){return await this.client.request(wt)}async verifyMobileNumber(e){const t=await this.client.request(ct,e);return t.ok?t.data.verifyMobileNumber?{ok:!1,error:d(t.data.verifyMobileNumber.__typename)}:{ok:!0}:t}async createMemberVerification(e){const t=await this.client.request(dt,e);return t.ok?t.data.createMemberVerification?{ok:!1,error:d(t.data.createMemberVerification.__typename)}:{ok:!0}:t}async updateMemberVerification(e){const t=await this.client.request(ut,e);return t.ok?t.data.updateMemberVerification?{ok:!1,error:d(t.data.updateMemberVerification.__typename)}:{ok:!0}:t}async memberVerification(){const e=await this.client.request(tt);return e.ok?{ok:!0,data:e.data.memberAccount.verification}:e}async announcements(e){const t=await this.client.request(Ie,e);return t.ok?{ok:!0,data:t.data.announcements}:t}async registerMayaMemberAccount(e){const t=await this.client.request(it,e);return t.ok?t.data.registerMayaMemberAccount?{ok:!1,error:d(t.data.registerMayaMemberAccount.__typename)}:{ok:!0}:t}async referralCode(){const e=await this.client.request(Et);return e.ok?{ok:!0,data:e.data.referralCode}:e}async updateReferralCode(e){const t=await this.client.request(St,e);return t.ok?t.data.updateReferralCode?{ok:!1,error:d(t.data.updateReferralCode.__typename)}:{ok:!0}:t}async pointsClubSettings(){const e=await this.client.request(Tt);return e.ok?{ok:!0,data:e.data.pointsClubSettings}:e}}function y(i,e){const t=fe[i]?fe[i]:fe[500];return{name:t.name,message:e??t.message}}const fe={400:{name:"HttpBadRequest",message:"Bad Request"},401:{name:"HttpUnauthorized",message:"Unauthorized"},403:{name:"HttpForbidden",message:"Forbidden"},404:{name:"HttpNotFound",message:"Not Found"},408:{name:"HttpRequestTimeout",message:"Request Timeout"},429:{name:"HttpTooManyRequests",message:"Too Many Requests"},500:{name:"HttpInternalServerError",message:"Internal Server Error"}};class It{constructor(e){c(this,"url");c(this,"platform");this.url=e.url,this.platform=e.platform}get headers(){const e=new Headers;return e.append("Accept","application/json, text/plain"),e.append("Content-Type","application/json"),e.append("Platform-Code",this.platform),e.append("Role","MEMBER"),e}async createSession(e){const t=new Headers(this.headers);if(e.name){const r=`${e.name}:${e.password}`,a=Buffer.from(r).toString("base64");t.set("Authorization",`Basic ${a}`)}if(e.mobileNumber){const r=`${e.mobileNumber}:${e.verificationCode}`,a=Buffer.from(r).toString("base64");console.log(`MobileNumberOTP ${a}`),t.set("Authorization",`MobileNumberOTP ${a}`)}e.sessionId&&t.set("Authorization",`MayaSession ${e.sessionId}`),e.token&&t.set("Authorization",`Token ${e.token}`);try{const r=await fetch(`${this.url}/sessions`,{method:"POST",headers:t}),a=await r.json();return r.ok?{ok:!0,data:a}:a.code==="ACCOUNT_BLACKLISTED"?{ok:!1,error:d("AccountBlacklistedError")}:{ok:!1,error:y(r.status)}}catch{return{ok:!1,error:y(500)}}}async authenticate(e){const t=new Headers(this.headers);if(e.type==="SECURITY_QUESTION"){t.set("Authorization",`Bearer ${e.token}`);try{const r=await fetch(`${this.url}/session/${e.token}/authenticate`,{method:"POST",headers:t,body:JSON.stringify({secretAnswer:e.secretAnswer})}),a=await r.json();return r.ok?{ok:!0,data:a}:r.status===401||r.status===403?{ok:!1,error:d("InvalidTokenOrSecretAnswerError")}:{ok:!1,error:y(r.status)}}catch{return{ok:!1,error:y(500)}}}throw new Error("Invalid input 'type'")}async refreshSession(e){const t=new Headers(this.headers);t.append("Authorization",`Bearer ${e}`);try{const r=await fetch(`${this.url}/session:refresh`,{method:"POST",headers:t}),a=await r.json();return r.ok?{ok:!0,data:a}:a.code==="ACCOUNT_BLACKLISTED"?{ok:!1,error:d("AccountBlacklistedError")}:r.status===403||r.status===401?{ok:!1,error:d("InvalidTokenError")}:{ok:!1,error:y(r.status)}}catch{return{ok:!1,error:y(500)}}}async destroySession(e){const t=new Headers(this.headers);t.append("Authorization",`Bearer ${e}`);try{const r=await fetch(`${this.url}/session`,{method:"DELETE",headers:t});return r.ok?{ok:!0}:{ok:!1,error:y(r.status)}}catch{return{ok:!1,error:y(500)}}}async verifySession(e){const t=new Headers(this.headers);t.append("Authorization",`Bearer ${e}`);try{return(await fetch(`${this.url}/session`,{method:"GET",headers:t})).ok}catch{return!0}}async sendVerificationCode(e){if(e.channel==="EMAIL")throw new Error("Email channel is not yet supported");function t(r){switch(r){case"MEMBER_NOT_FOUND":return"AccountNotFoundError";case"RATE_LIMIT_REACH":return"RateLimitExceededError";case"NOT_READY_TO_SEND_VERIFICATION_ERROR":return"NotReadyToSendVerficationCodeError";default:return null}}try{const r=await fetch(`${this.url}/otps`,{method:"POST",headers:this.headers,body:JSON.stringify(e)});if(r.status===403){const a=await r.json(),s=t(a.message);return s?{ok:!1,error:d(s)}:{ok:!1,error:y(r.status,a.message)}}return r.ok?{ok:!0}:{ok:!1,error:y(r.status)}}catch{return{ok:!1,error:y(500)}}}}class Gt{constructor(e){c(this,"url");c(this,"siteId");c(this,"platformId");this.url=e.url,this.siteId=e.site,this.platformId=e.platform}async self(){const e=await this.getJson(`/sites/${this.siteId}`);return e.ok?{ok:!0,data:e.data.data}:e}async games(e){var a,s,m,u,p,f,w,l,M,v,R,N,D,I,g,G,P,C,W,x,$,U,_,O;const t=new URLSearchParams;e!=null&&e.first&&t.set("first",e.first.toString()),e!=null&&e.after&&t.set("after",e.after),e!=null&&e.search&&t.set("search",e.search),(s=(a=e==null?void 0:e.filter)==null?void 0:a.type)!=null&&s.equal&&t.set("filter[type][eq]",e.filter.type.equal),(u=(m=e==null?void 0:e.filter)==null?void 0:m.type)!=null&&u.notEqual&&t.set("filter[type][neq]",e.filter.type.notEqual),(f=(p=e==null?void 0:e.filter)==null?void 0:p.type)!=null&&f.in&&t.set("filter[type][in]",e.filter.type.in.join(",")),(l=(w=e==null?void 0:e.filter)==null?void 0:w.type)!=null&&l.notIn&&t.set("filter[type][nin]",e.filter.type.notIn.join(",")),(v=(M=e==null?void 0:e.filter)==null?void 0:M.provider)!=null&&v.equal&&t.set("filter[provider][eq]",e.filter.provider.equal),(N=(R=e==null?void 0:e.filter)==null?void 0:R.provider)!=null&&N.notEqual&&t.set("filter[provider][neq]",e.filter.provider.notEqual),(I=(D=e==null?void 0:e.filter)==null?void 0:D.provider)!=null&&I.in&&t.set("filter[provider][in]",e.filter.provider.in.join(",")),(G=(g=e==null?void 0:e.filter)==null?void 0:g.provider)!=null&&G.notIn&&t.set("filter[provider][nin]",e.filter.provider.notIn.join(",")),(C=(P=e==null?void 0:e.filter)==null?void 0:P.tags)!=null&&C.equal&&t.set("filter[tags][eq]",e.filter.tags.equal.toLowerCase()),(x=(W=e==null?void 0:e.filter)==null?void 0:W.tags)!=null&&x.notEqual&&t.set("filter[tags][neq]",e.filter.tags.notEqual.toLowerCase()),(U=($=e==null?void 0:e.filter)==null?void 0:$.tags)!=null&&U.in&&t.set("filter[tags][in]",e.filter.tags.in.map(k=>k.toLowerCase()).join(",")),(O=(_=e==null?void 0:e.filter)==null?void 0:_.tags)!=null&&O.notIn&&t.set("filter[tags][nin]",e.filter.tags.notIn.map(k=>k.toLowerCase()).join(","));const r=await this.getJson("/games",t);return r.ok?{ok:!0,data:{edges:r.data.data.map(k=>({node:k,cursor:k.cursor})),totalCount:r.data.totalCount??0,pageInfo:{hasNextPage:!!r.data.next,endCursor:r.data.next}}}:r}async game(e){var r;const t=await this.getJson(`/games/${e}`);return((r=t.error)==null?void 0:r.name)==="HttpNotFound"?{ok:!0,data:null}:t.ok?{ok:!0,data:t.data.data}:t}async getJson(e,t){const r=new Request(`${this.url}${e}?${(t==null?void 0:t.toString())??""}`,{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json","Site-ID":this.siteId,"Platform-ID":this.platformId}});try{const a=await fetch(r);return a.ok?{ok:!0,data:await a.json()}:{ok:!1,error:y(a.status)}}catch{return{ok:!1,error:y(500)}}}}class Pt{constructor(e){c(this,"client");this.client=e}async file(e){const t=await this.client.request(Te,e);return t.ok?{ok:!0,data:t.data.node}:t}async uploadPrivateImageFile(e){const t=await this.client.upload(Me,e);return t.ok?t.data.uploadPrivateImageFile?{ok:!1,error:d(t.data.uploadPrivateImageFile.__typename)}:{ok:!0}:t}}class Wt{constructor(e){c(this,"client");this.client=e}async gameSession(e){const t=await this.client.request(ge.legacy,e);return t.ok?{ok:!0,data:t.data.node?{...t.data.node,game:t.data.node.game.id}:null}:t}async createGameSession(e){const t=await this.client.request(be,e);return t.ok?t.data.createGameSession?{ok:!1,error:d(t.data.createGameSession.__typename)}:{ok:!0}:t}async endGameSession(e){const t=await this.client.request(Ee.legacy,e);return t.ok?t.data.endGameSession?{ok:!1,error:{name:"UnknownError",message:"Something went wrong."}}:{ok:!0}:t}}class xt{constructor(e){c(this,"client");this.client=e}async latestBetRecords(){const e=await this.client.request(Ye);return e.ok?{ok:!0,data:e.data.latestBetRecords}:e}async platform(){const e=await this.client.request(ht);return e.ok?{ok:!0,data:e.data}:e}}class $t{constructor(e){c(this,"client");this.client=e}async betRecords(e){const t=await this.client.request(He,e);return t.ok?{ok:t.ok,data:t.data.member.betRecords}:t}async transactionRecords(e){const t=await this.client.request(je,e);return t.ok?{ok:t.ok,data:t.data.member.transactionRecords}:t}async withdrawalRecords(e){const t=await this.client.request(Ge,e);return t.ok?{ok:t.ok,data:t.data.member.withdrawalRecords}:t}async depositRecords(e){const t=await this.client.request(Oe,e);return t.ok?{ok:t.ok,data:t.data.member.depositRecords}:t}async depositsCount(){const e=await this.client.request(Ve);return e.ok?{ok:e.ok,data:e.data.member.depositsCount}:e}async pointsWalletTransactions(e){const t=await this.client.request(De,e);return t.ok?{ok:t.ok,data:t.data.member.pointsWalletTransactions}:t}async activityRecords(e){const t=await this.client.request(bt,e);return t.ok?{ok:t.ok,data:t.data.member.activityRecords}:t}async referrals(e){const t=await this.client.request(At,e);return t.ok?{ok:t.ok,data:t.data.member.referrals}:t}async referralCommission(){const e=await this.client.request(_t);return e.ok?{ok:e.ok,data:e.data.member.referralCommission}:e}async uplinesByName(e){const t=await this.client.request(kt,e);return t.ok?{ok:t.ok,data:t.data.uplinesByName}:t}async downlinesByName(e){const t=await this.client.request(Ct,e);return t.ok?{ok:t.ok,data:t.data.downlinesByName}:t}}class Ut{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 Ot{constructor(e){c(this,"client");this.client=e}async messages(e){const t=await this.client.request(Mt,e);return t.ok?{ok:t.ok,data:t.data.messages}:t}async unreadMessagesCount(e){const t=await this.client.request(vt,{...e,filter:{...e==null?void 0:e.filter,markedAsRead:{equal:!1}}});return t.ok?{ok:t.ok,data:t.data.messages.totalCount}:t}async markMessageAsRead(e){const t=await this.client.request(Rt,e);return t.ok?t.data.markMessageAsRead?{ok:!0}:{ok:!1,error:{name:"UnknownError",message:"Something went wrong."}}:t}async markAllMessageAsRead(){const e=await this.client.request(Nt);return e.ok?e.data.markAllMessageAsRead?{ok:!0}:{ok:!1,error:{name:"UnknownError",message:"Something went wrong."}}:e}}class Bt{constructor(e){c(this,"client");this.client=e}async promos(){const e=await this.client.request(Qe);return e.ok?{ok:e.ok,data:e.data.promos}:e}async cashbacks(){const e=await this.client.request(ze);return e.ok?{ok:e.ok,data:e.data.cashbacks}:e}async availablePromos(e){const t=await this.client.request(Ke,e);return t.ok?{ok:t.ok,data:t.data.availablePromos}:t}async cashbackBonuses(){const e=await this.client.request(Xe);return e.ok?{ok:e.ok,data:e.data.cashbackBonuses}:e}async claimCashbackBonus(e){const t=await this.client.request(Ze,e);return t.ok?t.data.claimCashbackBonus?{ok:!1,error:d(t.data.claimCashbackBonus.__typename)}:{ok:!0}:{ok:t.ok,error:t.error}}async bonus(){const e=await this.client.request(Je);return e.ok?{ok:e.ok,data:e.data.bonus}:e}async wallet(){const e=await this.client.request(ve);return e.ok?{ok:e.ok,data:e.data.wallet}:e}async deposit(e){const t=await this.client.request(Le,e);return t.ok?{ok:t.ok,data:t.data.node}:t}async createGCashDeposit(e){const t=await this.client.request(Be,e);return t.ok?t.data.createGCashDeposit?{ok:!1,error:d(t.data.createGCashDeposit.__typename)}:{ok:!0}:t}async createMayaDeposit(e){const t=await this.client.request(qe,e);return t.ok?t.data.createMayaDeposit?{ok:!1,error:d(t.data.createMayaDeposit.__typename)}:{ok:!0}:t}async createMayaAppDeposit(e){const t=await this.client.request(Fe,e);return t.ok?t.data.createMayaAppDeposit?{ok:!1,error:d(t.data.createMayaAppDeposit.__typename)}:{ok:!0}:t}async createGCashWithdrawal(e){const t=await this.client.request(Pe,e);return t.ok?t.data.createGCashWithdrawal?{ok:!1,error:d(t.data.createGCashWithdrawal.__typename)}:{ok:!0}:t}async createMayaWithdrawal(e){const t=await this.client.request(We,e);return t.ok?t.data.createMayaWithdrawal?{ok:!1,error:d(t.data.createMayaWithdrawal.__typename)}:{ok:!0}:t}async createMayaAppWithdrawal(e){const t=await this.client.request(xe,e);return t.ok?t.data.createMayaAppWithdrawal?{ok:!1,error:d(t.data.createMayaAppWithdrawal.__typename)}:{ok:!0}:t}async createBankWithdrawal(e){const t=await this.client.request($e,e);return t.ok?t.data.createBankWithdrawal?{ok:!1,error:d(t.data.createBankWithdrawal.__typename)}:{ok:!0}:t}async remainingDailyWithdrawalsCount(){const e=await this.client.request(Ue);return e.ok?{ok:e.ok,data:e.data.remainingDailyWithdrawalsCount}:e}async pointsWallet(){const e=await this.client.request(Re);return e.ok?{ok:e.ok,data:e.data.pointsWallet}:e}async redeemPointsToCash(e){const t=await this.client.request(Ne,e);return t.ok?t.data.redeemPointsToCash?{ok:!1,error:d(t.data.redeemPointsToCash.__typename)}:{ok:!0}:t}async mayaSession(e){const t=await this.client.request(yt,e);return t.ok?{ok:t.ok,data:t.data.mayaSession}:t}async gameSession(e){const t=await this.client.request(ge.current,e);return t.ok?{ok:!0,data:t.data.node}:t}async createGameSession(e){const t=await this.client.request(be,e);return t.ok?t.data.createGameSession?{ok:!1,error:d(t.data.createGameSession.__typename)}:{ok:!0}:t}async endGameSession(e){const t=await this.client.request(Ee.current,e);return t.ok?t.data.endGameSession?{ok:!0}:{ok:!1,error:{name:"UnknownError",message:"Something went wrong."}}:t}async validateMayaSession(){const e=await this.client.request(gt);return e.ok?e.data.validateMayaSession?{ok:!0}:{ok:!1,error:{name:"UnknownError",message:"Something went wrong."}}:e}}function he(i){return new Date(i.getTime())}function B(i,e){const t=he(i);return t.setMinutes(t.getMinutes()+e),t}function we(i,e){return i.getTime()>e.getTime()}class qt{constructor(e){c(this,"config");c(this,"cache");this.cache={},this.config={cacheTime:5,...e}}set(e,t){const r=B(new Date,this.config.cacheTime);this.cache[e]={value:t,validUntil:r}}get(e){const t=this.cache[e];return!t||we(new Date,t.validUntil)?null:t.value}}function Ft(i,e,t){return i<e?e:i>t?t:i}function ye(i){return Object.prototype.toString.call(i)==="[object Object]"&&Object(i)===i}function Lt(i){const e=[];function t(r,a=[]){for(const s in r){const m=r[s];ye(m)?t(m,[...a,s]):Array.isArray(m)?t(Vt(m),[...a,s]):e.push({key:[...a,s],value:m})}}return t(i),e}function Vt(i){return i.reduce((e,t,r)=>(e[r]=t,e),{})}class q{constructor(e,t){c(this,"url");c(this,"options");c(this,"middlewares");var a;const r=new Headers((a=t==null?void 0:t.fetchOptions)==null?void 0:a.headers);this.url=e,this.options={...t==null?void 0:t.fetchOptions,headers:r},this.middlewares=(t==null?void 0:t.middlewares)??[]}async request(e,t){const r=JSON.stringify({query:e,variables:t}),a=new Headers(this.options.headers);a.set("Content-Type","application/json"),a.set("Accept","application/json");const s=await this.runMiddlewares(new Request(this.url,{...this.options,body:r,headers:a,method:"POST"}));return await this.exec(s)}async upload(e,t){const r=this.createUploadBody(e,t),a=new Headers(this.options.headers);a.delete("Content-Type");const s=await this.runMiddlewares(new Request(this.url,{...this.options,body:r,headers:a,method:"POST"}));return await this.exec(s)}async exec(e){var t,r,a,s,m,u;try{const p=await fetch(e);if(!p.ok)return{ok:!1,error:y(p.status)};const f=await p.json(),w=f.data,l=(t=f.errors)==null?void 0:t.at(0);return l?((r=l.extensions)==null?void 0:r.code)==="FORBIDDEN"||((a=l.extensions)==null?void 0:a.code)==="ACCESS_TOKEN_EXPIRED"?{ok:!1,error:y(403,l.message)}:((s=l.extensions)==null?void 0:s.code)==="UNAUTHORIZED"?{ok:!1,error:y(401,l.message)}:((m=l.extensions)==null?void 0:m.code)==="BAD_USER_INPUT"||((u=l.extensions)==null?void 0:u.code)==="BAD_REQUEST"?{ok:!1,error:y(400,l.message)}:{ok:!1,error:y(500,l.message)}:{ok:!0,data:w}}catch{return{ok:!1,error:y(500)}}}async runMiddlewares(e){let t=e.clone();for(const r of this.middlewares)t=await r(t);return t}createUploadBody(e,t){const r=Lt(t).filter(m=>m.value instanceof File||m.value instanceof Blob),a=new FormData;a.append("operations",JSON.stringify({query:e,variables:t}));const s={};return r.forEach((m,u)=>{s[u.toString()]=[`variables.${m.key.join(".")}`]}),a.append("map",JSON.stringify(s)),r.forEach((m,u)=>{a.append(u.toString(),m.value)}),a}}function Ht(i){return i==="INR"?"en-IN":i==="MYR"?"en-MY":i==="IDR"?"en-ID":i==="USD"?"en-US":"en-PH"}function Yt(i){return i==="en-IN"?"+91":i==="en-MY"?"+60":i==="en-ID"?"+62":i==="en-US"?"+1":"+63"}function T(i,e){const t=Yt(e);return i.startsWith(t)?i:i.startsWith(t.substring(1))?`+${i}`:i.startsWith("0")?`${t}${i.substring(1)}`:`${t}${i}`}async function S(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 Ae{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 F(i,e){const t=he(i);return t.setDate(t.getDate()+e),t}function ke(i){return new Promise(e=>{setTimeout(e,i)})}function Ce(i,e){const{until:t,interval:r=1e3,maxAttempt:a=3}=e;async function s(m,u){const p=u??a,f=await i(...m);return t(f)?f:p>1?(await ke(r*((a-p)/2)),s(m,p-1)):f}return async(...m)=>await s(m)}function L(i,e){const t=he(i);return t.setMinutes(t.getMinutes()-e),t}class jt{constructor(e){c(this,"logger");c(this,"storageKey","session");c(this,"authService");c(this,"walletService");c(this,"_refreshing",!1);this.authService=e.authService,this.walletService=e.walletService,this.logger=new Ae({enabled:e.logs??!1})}get refreshing(){return this._refreshing}set refreshing(e){this._refreshing=e}async create(e){var a;if(this.isServer)return this.logger.warn("'localStorage' is not available on the server."),{ok:!1,error:{name:"UnknownError",message:"Server sign in is not supported."}};if(e.type==="MAYA"){const m=await Ce(()=>this.walletService.mayaSession({id:e.sessionId}),{until:w=>{var l;return w.ok&&((l=w.data)==null?void 0:l.member)!=null},interval:1e3,maxAttempt:5})();if(!m.ok)return m;if(!((a=m.data)!=null&&a.member))return{ok:!1,error:{name:"HttpForbidden",message:"Forbidden"}};const p=await Ce(()=>this.authService.createSession(e),{until:w=>w.ok,interval:1e3,maxAttempt:5})();if(!p.ok)return p;const f=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...p.data,accessTokenExpiresAt:B(f,8).getTime(),refreshTokenExpiresAt:L(F(f,30),2).getTime()})),{ok:!0,data:null}}if(e.type==="MOBILE_NUMBER"){const s=await this.authService.createSession(e);if(s.ok){const m=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...s.data,accessTokenExpiresAt:B(m,8).getTime(),refreshTokenExpiresAt:L(F(m,30),2).getTime()})),{ok:!0,data:null}}return s}if(e.type==="TOKEN"){const s=await this.authService.createSession({token:e.token});if(s.ok){const m=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...s.data,accessTokenExpiresAt:B(m,8).getTime(),refreshTokenExpiresAt:L(F(m,30),2).getTime()})),{ok:!0,data:null}}return s}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 r=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...t.data,accessTokenExpiresAt:B(r,8).getTime(),refreshTokenExpiresAt:L(F(r,30),2).getTime()})),{ok:!0,data:null}}async createFromAuthenticator(e){const t=await this.authService.authenticate(e);if(t.ok){const r=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:B(r,8).getTime(),refreshTokenExpiresAt:L(F(r,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 ke(1e3),await this.get();const e=window.localStorage.getItem(this.storageKey);if(!e)return{ok:!0,data:null};try{let t=JSON.parse(e),r=new Date;const a=new Date(t.accessTokenExpiresAt),s=new Date(t.refreshTokenExpiresAt);if(we(r,s))return this.logger.warn("Session expired. Logging out.."),window.localStorage.removeItem(this.storageKey),{ok:!1,error:{name:"SessionExpiredError",message:"Session expired."}};if(we(r,a)){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.name==="InvalidTokenError"||m.error.name==="AccountBlacklistedError"?(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!"),r=new Date,t={...t,...m.data,accessTokenExpiresAt:B(r,8).getTime(),refreshTokenExpiresAt:L(F(r,30),2).getTime()},window.localStorage.setItem(this.storageKey,JSON.stringify(t))}return{ok:!0,data:t}}catch{return{ok:!1,error:{name:"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 r,a,s;if(this.isServer)return this.logger.warn("'localStorage' is not available on the server."),!0;const e=await this.get();if(((r=e.error)==null?void 0:r.name)==="InvalidTokenError"||((a=e.error)==null?void 0:a.name)==="SessionExpiredError"||((s=e.error)==null?void 0:s.name)==="AccountBlacklistedError")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 A(i){const e={};for(const t in i){const r=i[t];if(r!==null&&r!==void 0){if(ye(r)){e[t]=A(r);continue}if(Array.isArray(r)){e[t]=r.map(a=>ye(a)?A(a):a);continue}e[t]=r}}return e}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 Qt{constructor(e){c(this,"staticService");const t=(e==null?void 0:e.environment)==="development";this.staticService=new Ut({url:t?"https://static.development.opexa.io":"https://static.opexa.io"})}get transform(){return{site:this.site.bind(this),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),pointsWalletTransaction:this.pointsWalletTransaction.bind(this),activityRecord:this.activityRecord.bind(this),referral:this.referral.bind(this),referralCommission:this.referralCommission.bind(this),platform__next:this.platform__next.bind(this),pointsClubSettings:this.pointsClubSettings.bind(this),paymentSettings:this.paymentSettings.bind(this),message:this.message.bind(this)}}site(e){const t={id:e.id,name:e.name,logo:e.logo??void 0,fields:e.config.fields};return A(t)}platform(e){var t,r,a,s,m,u,p,f,w,l,M,v,R,N,D,I,g,G,P,C,W,x,$,U,_,O,k,V,H,Y,j,Q,K,z,J,X,Z,ee,te,re,ae,ne,ie,oe,se,me,ce,de,_e;return{timezone:e.timezone,currency:e.currency,paymentSettings:{minimumFirstDepositAmount:n(e.minimumFirstDepositAmount),restrictWithdrawalsToVerifiedMembers:e.restrictWithdrawalsToVerifiedMembers,depositGateway:{bank:{androidEnabled:((t=e.bankDepositGatewaySettings)==null?void 0:t.androidEnabled)??!1,iosEnabled:((r=e.bankDepositGatewaySettings)==null?void 0:r.iosEnabled)??!1,webEnabled:((a=e.bankDepositGatewaySettings)==null?void 0:a.webEnabled)??!1,mobileWebEnabled:((s=e.bankDepositGatewaySettings)==null?void 0:s.mobileWebEnabled)??!1,minimumAmount:n((m=e.bankDepositGatewaySettings)==null?void 0:m.minimumAmount),maximumAmount:n((u=e.bankDepositGatewaySettings)==null?void 0:u.maximumAmount)},gcash:{androidEnabled:((p=e.gcashDepositGatewaySettings)==null?void 0:p.androidEnabled)??!1,iosEnabled:((f=e.gcashDepositGatewaySettings)==null?void 0:f.iosEnabled)??!1,webEnabled:((w=e.gcashDepositGatewaySettings)==null?void 0:w.webEnabled)??!1,mobileWebEnabled:((l=e.gcashDepositGatewaySettings)==null?void 0:l.mobileWebEnabled)??!1,minimumAmount:n((M=e.gcashDepositGatewaySettings)==null?void 0:M.minimumAmount),maximumAmount:n((v=e.gcashDepositGatewaySettings)==null?void 0:v.maximumAmount)},maya:{androidEnabled:((R=e.mayaDepositGatewaySettings)==null?void 0:R.androidEnabled)??!1,iosEnabled:((N=e.mayaDepositGatewaySettings)==null?void 0:N.iosEnabled)??!1,webEnabled:((D=e.mayaDepositGatewaySettings)==null?void 0:D.webEnabled)??!1,mobileWebEnabled:((I=e.mayaDepositGatewaySettings)==null?void 0:I.mobileWebEnabled)??!1,minimumAmount:n((g=e.mayaDepositGatewaySettings)==null?void 0:g.minimumAmount),maximumAmount:n((G=e.mayaDepositGatewaySettings)==null?void 0:G.maximumAmount)},mayaApp:{androidEnabled:((P=e.mayaAppDepositGatewaySettings)==null?void 0:P.androidEnabled)??!1,iosEnabled:((C=e.mayaAppDepositGatewaySettings)==null?void 0:C.iosEnabled)??!1,webEnabled:((W=e.mayaAppDepositGatewaySettings)==null?void 0:W.webEnabled)??!1,mobileWebEnabled:((x=e.mayaAppDepositGatewaySettings)==null?void 0:x.mobileWebEnabled)??!1,minimumAmount:n(($=e.mayaAppDepositGatewaySettings)==null?void 0:$.minimumAmount),maximumAmount:n((U=e.mayaAppDepositGatewaySettings)==null?void 0:U.maximumAmount)}},withdrawalGateway:{bank:{androidEnabled:((_=e.bankWithdrawalGatewaySettings)==null?void 0:_.androidEnabled)??!1,iosEnabled:((O=e.bankWithdrawalGatewaySettings)==null?void 0:O.iosEnabled)??!1,webEnabled:((k=e.bankWithdrawalGatewaySettings)==null?void 0:k.webEnabled)??!1,mobileWebEnabled:((V=e.bankWithdrawalGatewaySettings)==null?void 0:V.mobileWebEnabled)??!1,minimumAmount:n((H=e.bankWithdrawalGatewaySettings)==null?void 0:H.minimumAmount),maximumAmount:n((Y=e.bankWithdrawalGatewaySettings)==null?void 0:Y.maximumAmount)},gcash:{androidEnabled:((j=e.gcashWithdrawalGatewaySettings)==null?void 0:j.androidEnabled)??!1,iosEnabled:((Q=e.gcashWithdrawalGatewaySettings)==null?void 0:Q.iosEnabled)??!1,webEnabled:((K=e.gcashWithdrawalGatewaySettings)==null?void 0:K.webEnabled)??!1,mobileWebEnabled:((z=e.gcashWithdrawalGatewaySettings)==null?void 0:z.mobileWebEnabled)??!1,minimumAmount:n((J=e.gcashWithdrawalGatewaySettings)==null?void 0:J.minimumAmount),maximumAmount:n((X=e.gcashWithdrawalGatewaySettings)==null?void 0:X.maximumAmount,1e6)},maya:{androidEnabled:((Z=e.mayaWithdrawalGatewaySettings)==null?void 0:Z.androidEnabled)??!1,iosEnabled:((ee=e.mayaWithdrawalGatewaySettings)==null?void 0:ee.iosEnabled)??!1,webEnabled:((te=e.mayaWithdrawalGatewaySettings)==null?void 0:te.webEnabled)??!1,mobileWebEnabled:((re=e.mayaWithdrawalGatewaySettings)==null?void 0:re.mobileWebEnabled)??!1,minimumAmount:n((ae=e.mayaWithdrawalGatewaySettings)==null?void 0:ae.minimumAmount),maximumAmount:n((ne=e.mayaWithdrawalGatewaySettings)==null?void 0:ne.maximumAmount)},mayaApp:{androidEnabled:((ie=e.mayaAppWithdrawalGatewaySettings)==null?void 0:ie.androidEnabled)??!1,iosEnabled:((oe=e.mayaAppWithdrawalGatewaySettings)==null?void 0:oe.iosEnabled)??!1,webEnabled:((se=e.mayaAppWithdrawalGatewaySettings)==null?void 0:se.webEnabled)??!1,mobileWebEnabled:((me=e.mayaAppWithdrawalGatewaySettings)==null?void 0:me.mobileWebEnabled)??!1,minimumAmount:n((ce=e.mayaAppWithdrawalGatewaySettings)==null?void 0:ce.minimumAmount),maximumAmount:n((de=e.mayaAppWithdrawalGatewaySettings)==null?void 0:de.maximumAmount,1e6)}}},pointsClubSettings:{multiplier:n((_e=e.pointsClubSettings)==null?void 0:_e.multiplier,0)}}}platform__next(e){return{currency:e.currency,timezone:e.timezone,locale:Ht(e.currency)}}pointsClubSettings(e){return{multiplier:n(e.multiplier,0)}}paymentSettings(e){var t,r,a,s,m,u,p,f,w,l,M,v,R,N,D,I,g,G,P,C,W,x,$,U,_,O,k,V,H,Y,j,Q,K,z,J,X,Z,ee,te,re,ae,ne,ie,oe,se,me,ce,de;return{minimumFirstDepositAmount:n(e.minimumFirstDepositAmount),restrictWithdrawalsToVerifiedMembers:e.restrictWithdrawalsToVerifiedMembers,depositGateway:{bank:{androidEnabled:((t=e.bankDepositGatewaySettings)==null?void 0:t.androidEnabled)??!1,iosEnabled:((r=e.bankDepositGatewaySettings)==null?void 0:r.iosEnabled)??!1,webEnabled:((a=e.bankDepositGatewaySettings)==null?void 0:a.webEnabled)??!1,mobileWebEnabled:((s=e.bankDepositGatewaySettings)==null?void 0:s.mobileWebEnabled)??!1,minimumAmount:n((m=e.bankDepositGatewaySettings)==null?void 0:m.minimumAmount),maximumAmount:n((u=e.bankDepositGatewaySettings)==null?void 0:u.maximumAmount)},gcash:{androidEnabled:((p=e.gcashDepositGatewaySettings)==null?void 0:p.androidEnabled)??!1,iosEnabled:((f=e.gcashDepositGatewaySettings)==null?void 0:f.iosEnabled)??!1,webEnabled:((w=e.gcashDepositGatewaySettings)==null?void 0:w.webEnabled)??!1,mobileWebEnabled:((l=e.gcashDepositGatewaySettings)==null?void 0:l.mobileWebEnabled)??!1,minimumAmount:n((M=e.gcashDepositGatewaySettings)==null?void 0:M.minimumAmount),maximumAmount:n((v=e.gcashDepositGatewaySettings)==null?void 0:v.maximumAmount)},maya:{androidEnabled:((R=e.mayaDepositGatewaySettings)==null?void 0:R.androidEnabled)??!1,iosEnabled:((N=e.mayaDepositGatewaySettings)==null?void 0:N.iosEnabled)??!1,webEnabled:((D=e.mayaDepositGatewaySettings)==null?void 0:D.webEnabled)??!1,mobileWebEnabled:((I=e.mayaDepositGatewaySettings)==null?void 0:I.mobileWebEnabled)??!1,minimumAmount:n((g=e.mayaDepositGatewaySettings)==null?void 0:g.minimumAmount),maximumAmount:n((G=e.mayaDepositGatewaySettings)==null?void 0:G.maximumAmount)},mayaApp:{androidEnabled:((P=e.mayaAppDepositGatewaySettings)==null?void 0:P.androidEnabled)??!1,iosEnabled:((C=e.mayaAppDepositGatewaySettings)==null?void 0:C.iosEnabled)??!1,webEnabled:((W=e.mayaAppDepositGatewaySettings)==null?void 0:W.webEnabled)??!1,mobileWebEnabled:((x=e.mayaAppDepositGatewaySettings)==null?void 0:x.mobileWebEnabled)??!1,minimumAmount:n(($=e.mayaAppDepositGatewaySettings)==null?void 0:$.minimumAmount),maximumAmount:n((U=e.mayaAppDepositGatewaySettings)==null?void 0:U.maximumAmount)}},withdrawalGateway:{bank:{androidEnabled:((_=e.bankWithdrawalGatewaySettings)==null?void 0:_.androidEnabled)??!1,iosEnabled:((O=e.bankWithdrawalGatewaySettings)==null?void 0:O.iosEnabled)??!1,webEnabled:((k=e.bankWithdrawalGatewaySettings)==null?void 0:k.webEnabled)??!1,mobileWebEnabled:((V=e.bankWithdrawalGatewaySettings)==null?void 0:V.mobileWebEnabled)??!1,minimumAmount:n((H=e.bankWithdrawalGatewaySettings)==null?void 0:H.minimumAmount),maximumAmount:n((Y=e.bankWithdrawalGatewaySettings)==null?void 0:Y.maximumAmount)},gcash:{androidEnabled:((j=e.gcashWithdrawalGatewaySettings)==null?void 0:j.androidEnabled)??!1,iosEnabled:((Q=e.gcashWithdrawalGatewaySettings)==null?void 0:Q.iosEnabled)??!1,webEnabled:((K=e.gcashWithdrawalGatewaySettings)==null?void 0:K.webEnabled)??!1,mobileWebEnabled:((z=e.gcashWithdrawalGatewaySettings)==null?void 0:z.mobileWebEnabled)??!1,minimumAmount:n((J=e.gcashWithdrawalGatewaySettings)==null?void 0:J.minimumAmount),maximumAmount:n((X=e.gcashWithdrawalGatewaySettings)==null?void 0:X.maximumAmount,1e6)},maya:{androidEnabled:((Z=e.mayaWithdrawalGatewaySettings)==null?void 0:Z.androidEnabled)??!1,iosEnabled:((ee=e.mayaWithdrawalGatewaySettings)==null?void 0:ee.iosEnabled)??!1,webEnabled:((te=e.mayaWithdrawalGatewaySettings)==null?void 0:te.webEnabled)??!1,mobileWebEnabled:((re=e.mayaWithdrawalGatewaySettings)==null?void 0:re.mobileWebEnabled)??!1,minimumAmount:n((ae=e.mayaWithdrawalGatewaySettings)==null?void 0:ae.minimumAmount),maximumAmount:n((ne=e.mayaWithdrawalGatewaySettings)==null?void 0:ne.maximumAmount)},mayaApp:{androidEnabled:((ie=e.mayaAppWithdrawalGatewaySettings)==null?void 0:ie.androidEnabled)??!1,iosEnabled:((oe=e.mayaAppWithdrawalGatewaySettings)==null?void 0:oe.iosEnabled)??!1,webEnabled:((se=e.mayaAppWithdrawalGatewaySettings)==null?void 0:se.webEnabled)??!1,mobileWebEnabled:((me=e.mayaAppWithdrawalGatewaySettings)==null?void 0:me.mobileWebEnabled)??!1,minimumAmount:n((ce=e.mayaAppWithdrawalGatewaySettings)==null?void 0:ce.minimumAmount),maximumAmount:n((de=e.mayaAppWithdrawalGatewaySettings)==null?void 0:de.maximumAmount,1e6)}}}}account(e){const t={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,secretAnswerSubmitted:e.secretAnswerSubmitted??!1,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)};return A(t)}wallet(e){return{id:e.id,balance:n(e.balance,0),currency:e.currency,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}verificationDetails(e){return{id:e.id,status:e.status,address:e.address,permanentAddress:e.permanentAddress,nationality:e.nationality,natureOfWork:e.natureOfWork,placeOfBirth:e.placeOfBirth,sourceOfIncome:e.sourceOfIncome,selfieImage:this.file(e.selfieImage),idFrontImage:this.file(e.idFrontImage)}}profileCompletion(e){return{accountPassword:e.accountPassword??!1,accountVerification:e.accountVerification??!1,mobileNumberVerification:e.mobileNumberVerification??!1,personalInformation:e.personalInformation??!1,transactionPassword:e.transactionPassword??!1,completionPercentage:n(e.completionPercentage,0)}}announcement(e){return{id:e.id,type:e.type,title:e.title,status:e.status,message:e.message,activationEndDateTime:new Date(e.activationEndDateTime),activationStartDateTime:new Date(e.activationStartDateTime),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}withdrawalRecord(e){const t={id:e.id,type:e.type,bank:e.bank,status:e.status,amount:n(e.amount,0),netAmount:n(e.netAmount,0),fee:n(e.fee,0),reference:e.reference??void 0,withdrawalNumber:e.withdrawalNumber,recipientMobileNumber:e.recipientMobileNumber??void 0,dateTimeConfirmed:e.dateTimeConfirmed?new Date(e.dateTimeConfirmed):void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)};return A(t)}deposit(e){const t={id:e.id,type:e.type,status:e.status,checkoutUrl:e.checkoutUrl??void 0};return A(t)}depositRecord(e){const t={id:e.id,type:e.type,status:e.status,amount:n(e.amount,0),fee:n(e.fee,0),netAmount:n(e.netAmount,0),reference:e.reference??void 0,depositNumber:e.depositNumber,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)};return A(t)}betRecord(e){var r;const t={id:e.id,bet:n(e.bet,0),payout:n(e.payout,0),status:e.status,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:{name:e.game.name,type:e.game.type,images:this.staticService.gameThumbnails(e.game),provider:e.game.provider},serialCode:e.serialCode,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:((r=e.metadata)==null?void 0:r.odds)??void 0}};return A(t)}latestBetRecord(e){return{id:e.id,member:e.member,game:{name:e.game.name,type:e.game.type,images:this.staticService.gameThumbnails(e.game),provider:e.game.provider},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){const t={id:e.id,type:e.type,amount:n(e.amount,0),content:e.content??void 0,currentBalance:n(e.currentBalance,0),referenceNumber:e.referenceNumber,dateTimeCreated:new Date(e.dateTimeCreated)};return A(t)}game(e){return{id:e.id,type:e.type,tags:e.tags??[],name:e.name,images:[e.customImage,e.image].filter(Boolean),provider:e.provider,reference:e.reference}}gameSession(e){const t={id:e.id,status:e.status,launchUrl:e.launchUrl??void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)};return A(t)}promo(e){return{id:e.id,type:e.type,name:e.name,status:e.status,description:e.description,banner:this.file(e.banner),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{id:e.id,name:e.name,description:e.description,status:e.status,minimumCashback:n(e.minimumCashback,0),maximumMonthlyCashback:n(e.maximumMonthlyCashback),banner:this.file(e.banner),activationEndDateTime:new Date(e.activationEndDateTime),activationStartDateTime:new Date(e.activationStartDateTime),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated),turnoverContributionPercentagePerGameProvider:Object.entries(e.turnoverContributionPercentagePerGameProvider).reduce((r,[a,s])=>(r[a]=n(s,0),r),{})}}bonus(e){const t={id:e.id,promo:this.promo(e.promo),deposit:e.deposit?{type:e.deposit.type,status:e.deposit.status,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)};return A(t)}cashbackBonus(e){return{id:e.id,total:n(e.total,0),balance:n(e.balance,0),cashback:this.cashback(e.cashback),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}file(e){const t={id:e.id,url:e.url??void 0,status:e.status,dateTimeCreated:new Date(e.dateTimeCreated)};return A(t)}pointsWallet(e){return{id:e.id,points:n(e.points,0),account:e.account,dateTimeCreated:new Date(e.dateTimeCreated)}}pointsWalletTransaction(e){return{id:e.id,type:e.type,amount:n(e.amount,0),balance:n(e.balance,0),dateTimeCreated:new Date(e.dateTimeCreated)}}activityRecord(e){const t={id:e.id,type:e.type,amount:e.amount?n(e.amount,0):void 0,domain:e.domain??void 0,details:e.details,dateTimeCreated:new Date(e.dateTimeCreated)};return A(t)}referral(e){return{id:e.id,level:e.level,upline:e.upline,downline:e.downline,turnover:n(e.turnover,0),commission:n(e.commission,0),dateTimeCreated:new Date(e.dateTimeCreated)}}referralCommission(e){return{id:e.id,commission:n(e.commission,0),level1Commission:n(e.level1Commission,0),level2Commission:n(e.level2Commission,0),level3Commission:n(e.level3Commission,0),referralsCount:e.referralsCount,level1ReferralsCount:e.level1ReferralsCount,level2ReferralsCount:e.level2ReferralsCount,level3ReferralsCount:e.level3ReferralsCount,referralCode:e.referralCode,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}message(e){return{id:e.id,logo:e.logo,title:e.title,popup:e.popup,content:e.content,actions:e.actions,markedAsRead:e.markedAsRead,dateTimeCreated:new Date(e.dateTimeCreated)}}}class Kt{constructor(e){c(this,"cmsPortalService");c(this,"authService");c(this,"gameService");c(this,"fileService");c(this,"walletService");c(this,"accountService");c(this,"reportService");c(this,"portalService");c(this,"triggerService");c(this,"sessionManager");c(this,"transformer");c(this,"logger");c(this,"cache");const{site:t,sitePlatform:r,platform:a,environment:s,logs:m}=e,u=s==="production";this.transformer=new Qt({environment:s}),this.logger=new Ae({enabled:m??!1});const p=u?"https://auth.opexa.io":"https://auth.development.opexa.io",f=u?"https://wallet.opexa.io/graphql":"https://wallet.development.opexa.io/graphql",w=u?"https://report.opexa.io/graphql":"https://report.development.opexa.io/graphql",l=u?"https://account.opexa.io/graphql":"https://account.development.opexa.io/graphql",M=u?"https://portal.opexa.io/graphql":"https://portal.development.opexa.io/graphql",v=u?"https://file.opexa.io/graphql":"https://file.development.opexa.io/graphql",R=u?"https://game.opexa.io/graphql":"https://game.development.opexa.io/graphql",N=u?"https://trigger.opexa.io/graphql":"https://trigger.development.opexa.io/graphql",D="https://portal-api.opexacms.io/v1",I=new Gt({url:D,site:t,platform:r}),g={middlewares:[this.authMiddleware],fetchOptions:{headers:{Role:"MEMBER","Platform-Code":a}}},G=new Wt(new q(R,g)),P=new Pt(new q(v,g)),C=new Bt(new q(f,g)),W=new Dt(new q(l,g)),x=new $t(new q(w,g)),$=new xt(new q(M,g)),U=new Ot(new q(N,g)),_=new It({url:p,platform:a}),O=new jt({logs:m,authService:_,walletService:C});this.authService=_,this.gameService=G,this.fileService=P,this.walletService=C,this.accountService=W,this.reportService=x,this.portalService=$,this.triggerService=U,this.sessionManager=O,this.cmsPortalService=I,this.cache=new qt}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}}get locale(){return new Promise(e=>{const t="locale",r=this.cache.get(t);if(r)return e(r);this.platform__next().then(a=>{a.ok?(this.cache.set(t,a.data.locale),e(a.data.locale)):(this.logger.warn("Failed to fetch currency. Using 'PH' as fallback"),e("en-PH"))})})}async signIn(e){switch(e.type){case"NAME_AND_PASSWORD":{const t=await this.sessionManager.create({...e,password:await S(e.password)});return t.ok?t.data?{ok:!0,data:{"2FAEnabled":!0,authenticator:t.data.authenticator}}:{ok:!0,data:{"2FAEnabled":!1}}:t}case"TOKEN":{const t=await this.sessionManager.create({type:"TOKEN",token:e.token});return t.ok?{ok:!0}:t}case"MOBILE_NUMBER":{const t=await this.sessionManager.create({type:"MOBILE_NUMBER",mobileNumber:T(e.mobileNumber,await this.locale),verificationCode:e.verificationCode});return t.ok?{ok:!0}:t}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 S(e.secretAnswer)});default:return{ok:!1,error:{name:"HttpBadRequest",message:"Invalid input 'type'"}}}}async signOut(){await this.sessionManager.destroy()}watchSession(e){const t=Ft(e.interval??3e4,3e4,6e4);let r=null;const a=()=>setTimeout(async()=>{await this.sessionManager.verify()||await e.onInvalid(),r=a()},t);return r=a(),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 validateMayaSession(){return await this.walletService.validateMayaSession()}async site(){const e=await this.cmsPortalService.self();return e.ok?{ok:!0,data:this.transformer.transform.site(e.data)}:e}async platform(){const e=await this.accountService.platform();return e.ok?{ok:!0,data:this.transformer.transform.platform(e.data)}:e}async platform__next(){const e=await this.portalService.platform();return e.ok?{ok:!0,data:this.transformer.transform.platform__next(e.data)}:e}async paymentSettings(){const e=await this.accountService.paymentSettings();return e.ok?{ok:!0,data:this.transformer.transform.paymentSettings(e.data)}:e}async account(){const e=await this.accountService.memberAccount();return e.ok?{ok:!0,data:this.transformer.transform.account(e.data)}:e}async createAccount(e){const t=e.id??h.ObjectId.generate(E.Account).toString(),r=await this.accountService.registerMemberAccount({input:{id:t,btag:e.btag,name:e.name,domain:e.domain,birthDay:typeof e.dateOfBirth=="string"?e.dateOfBirth:e.dateOfBirth.toISOString(),password:await S(e.password),mobileNumber:T(e.mobileNumber,await this.locale)},referralCode:e.referralCode,verificationCode:e.verificationCode,reCAPTCHAResponse:e.reCAPTCHAResponse});return r.ok?{ok:!0,data:{id:t}}:r}async createAccount__next(e){const t=e.id??h.ObjectId.generate(E.Account).toString();if(e.type==="MOBILE_NUMBER"){const a=await this.accountService.registerMemberAccountViaMobile({input:{id:t,mobileNumber:T(e.mobileNumber,await this.locale)},referralCode:e.referralCode,reCAPTCHAResponse:e.reCAPTCHAResponse,verificationCode:e.verificationCode});return a.ok?{ok:!0,data:{id:t}}:a}const r=await this.accountService.registerMemberAccount__next({input:{id:t,name:e.name,password:await S(e.password),mobileNumber:e.mobileNumber?T(e.mobileNumber,await this.locale):void 0},reCAPTCHAResponse:e.reCAPTCHAResponse});return r.ok?{ok:!0,data:{id:t}}:r}async registerMayaAccount(e){return await this.accountService.registerMayaMemberAccount({input:{name:e.name,password:await S(e.password),domain:e.domain}})}async updateAccount(e,t){return await this.accountService.updateMemberAccount({input:{id:e,data:{...t,password:t.password?await S(t.password):void 0,transactionPassword:t.transactionPassword?await S(t.transactionPassword):void 0,...t.mobileNumber&&{mobileNumber:T(t.mobileNumber,await this.locale)},secretAnswer:t.secretAnswer?await S(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??h.ObjectId.generate(E.Verification).toString(),r=await this.accountService.createMemberVerification({input:{id:t,...e}});return r.ok?{ok:!0,data:{id:t}}:r}async updateVerificationDetails(e,t){return await this.accountService.updateMemberVerification({input:{id:e,data:{...t}}})}async resetPassword(e){return await this.accountService.resetPassword({input:{mobileNumber:T(e.mobileNumber,await this.locale),newPassword:await S(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:T(e,await this.locale)}})}async sendVerificationCode__next(e){if(e.type==="SMS")return this.authService.sendVerificationCode({channel:"SMS",recipient:T(e.mobileNumber,await this.locale),...e.strict&&{verificationType:"MEMBER"}});throw new Error("'Email' verification code is not yet supported")}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:{...e==null?void 0:e.filter,visibility:{in:["MEMBER","GLOBAL"]}}});return t.ok?{ok:!0,data:{announcements:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.announcement(a),cursor:r})),totalCount:t.data.totalCount,endCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async createWithdrawal(e){const t=e.id??h.ObjectId.generate(E.Withdrawal).toString();if(e.type==="BANK"){const r=await this.walletService.createBankWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await S(e.transactionPassword)}});if(!r.ok)return r}if(e.type==="GCASH"){const r=await this.walletService.createGCashWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await S(e.transactionPassword),recipientMobileNumber:T(e.recipientMobileNumber,await this.locale)}});if(!r.ok)return r}if(e.type==="MAYA"){const r=await this.walletService.createMayaWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await S(e.transactionPassword),recipientMobileNumber:T(e.recipientMobileNumber,await this.locale)}});if(!r.ok)return r}if(e.type==="MAYA_APP"){const r=await this.walletService.createMayaAppWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await S(e.transactionPassword)}});if(!r.ok)return r}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:r,node:a})=>({...this.transformer.transform.withdrawalRecord(a),cursor:r})),totalCount:t.data.totalCount,endCursor: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??h.ObjectId.generate(E.Deposit).toString();if(e.type==="MAYA"){const r=await this.walletService.createMayaDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!r.ok)return r}if(e.type==="MAYA_APP"){const r=await this.walletService.createMayaAppDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!r.ok)return r}if(e.type==="GCASH"){const r=await this.walletService.createGCashDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!r.ok)return r}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:r,node:a})=>({...this.transformer.transform.depositRecord(a),cursor:r})),totalCount:t.data.totalCount,endCursor: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,...(e==null?void 0:e.filter)&&{filter:{...e.filter.status&&{status:e.filter.status},...e.filter.serialCode&&{serialCode:e.filter.serialCode},...e.filter.vendorRoundId&&{vendorRoundId:e.filter.vendorRoundId},...e.filter.gameType&&{game__type:e.filter.gameType},...e.filter.gameProvider&&{game__provider:e.filter.gameProvider},...e.filter.dateTimeCreated&&{dateTimeCreated:e.filter.dateTimeCreated}}}});return t.ok?{ok:!0,data:{betRecords:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.betRecord(a),cursor:r})),totalCount:t.data.totalCount,endCursor: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:r,node:a})=>({...this.transformer.transform.transactionRecord(a),cursor:r})),totalCount:t.data.totalCount,endCursor: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 game(e){const t=await this.cmsPortalService.game(e);return t.ok?{ok:!0,data:t.data?this.transformer.transform.game(t.data):null}:t}async games(e){const t=await this.cmsPortalService.games(e);return t.ok?{ok:!0,data:{games:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.game(a),cursor:r})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}async gameSession(e){const t=await this.walletService.gameSession({id:e});if(!t.ok)return t;if(t.data)return{ok:!0,data:this.transformer.transform.gameSession(t.data)};const r=await this.gameService.gameSession({id:e});return r.ok?{ok:!0,data:r.data?this.transformer.transform.gameSession(r.data):null}:r}async createGameSession(e){const t=e.id??h.ObjectId.generate(E.GameSession).toString();if(e.game.startsWith("SPORTS:")){const f=await h.ObjectId.generateFromKey(E.Game,e.game).then(l=>l.toString()),w=await this.gameService.createGameSession({input:{id:t,game:f}});return w.ok?{ok:!0,data:{id:t}}:w}const a=await this.game(e.game);if(!a.data)return{ok:!1,error:{name:"GameDoesNotExistError",message:"Game does not exist"}};const{provider:s,reference:m}=a.data,p=["RTG","DARWIN","DRBINGO","MEGABALL","EVOLUTION","EVOLUTION_NETENT","EVOLUTION_REDTIGER"].includes(s)?await this.walletService.createGameSession({input:{id:t,game:m}}):await this.gameService.createGameSession({input:{id:t,game:m}});return p.ok?{ok:!0,data:{id:t}}:p}async endGameSession(e){const t=await this.walletService.endGameSession({input:{id:e}});return t.ok?t:await this.gameService.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??h.ObjectId.generate(E.File).toString(),r=await this.fileService.uploadPrivateImageFile({input:{id:t,file:e.file}});return r.ok?{ok:!0,data:{id:t}}:r}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 redeemPoints(e){return await this.walletService.redeemPointsToCash({input:{amount:e.amount.toString()}})}async pointsWalletTransactions(e){const t=await this.reportService.pointsWalletTransactions(e);return t.ok?{ok:!0,data:{pointsWalletTransactions:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.pointsWalletTransaction(a),cursor:r})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}async activityRecords(e){const t=await this.reportService.activityRecords(e);return t.ok?{ok:!0,data:{activityRecords:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.activityRecord(a),cursor:r})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}async referralCode(){const e=await this.accountService.referralCode();return e.ok?{ok:!0,data:e.data??null}:e}async updateReferralCode(e){return await this.accountService.updateReferralCode({input:e})}async referrals(e){const t=await this.reportService.referrals(e);return t.ok?{ok:!0,data:{referrals:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.referral(a),cursor:r})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}async referralCommission(){const e=await this.reportService.referralCommission();return e.ok?{ok:!0,data:e.data?this.transformer.transform.referralCommission(e.data):null}:e}async uplinesByName(e){const t=await this.reportService.uplinesByName(e);return t.ok?{ok:!0,data:t.data.map(this.transformer.transform.referral)}:t}async downlinesByName(e){const t=await this.reportService.downlinesByName(e);return t.ok?{ok:!0,data:t.data.map(this.transformer.transform.referral)}:t}async pointsClubSettings(){const e=await this.accountService.pointsClubSettings();return e.ok?{ok:!0,data:e.data?this.transformer.transform.pointsClubSettings(e.data):null}:e}async messages(e){const t=await this.triggerService.messages(e);return t.ok?{ok:!0,data:{messages:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.message(a),cursor:r})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}async unreadMessagesCount(e){return await this.triggerService.unreadMessagesCount(e)}async markMessageAsRead(e){return await this.triggerService.markMessageAsRead({id:e})}async markAllMessageAsRead(){return await this.triggerService.markAllMessageAsRead()}}Object.defineProperty(b,"ObjectId",{enumerable:!0,get:()=>h.ObjectId}),b.ObjectType=E,b.Sdk=Kt,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
1299
+ `;function u(i){return{name:i,message:{AccountNameNotAvailableError:"Username is no longer available",AccountNotFoundError:"Account does not exist",AccountNotVerifiedError:"Account is not verified",CashbackBonusDoesNotExistError:"Cashback bonus does not exists",DepositPromoMaximumAmountExceededError:"Deposit amount exceeds maximum amount",DepositPromoMinimumAmountNotMetError:"Deposit amount does not meet minimum amount",EmailAddressNotAvailableError:"Email is no longer available",FileDoesNotExistError:"File does not exist",FileFormatNotSupportedError:"File format is not supported",FileNameTooLongError:"File name is too long",FileNotReadyError:"File is not yet ready",FileSizeTooBigError:"File size is too big",GameDoesNotExistError:"Game does not exist",HasActiveBonusError:"Account has active bonus",InsufficientPointsError:"Insufficient points",InvalidPlatformError:"Invalid platform",InvalidReCAPTCHAResponseError:"Invalid reCAPTCHA",InvalidSMSVerificationCodeError:"Invalid SMS verification code",InvalidTransactionPasswordError:"Invalid transaction password",InvalidVerificationCodeError:"Invalid verification code",InvalidWithdrawalAmountError:"Invalid withdrawal amount",MaximumDepositAmountExceededError:"Maximum deposit amount exceeded",MemberVerificationAlreadyApprovedError:"Member verification is already approved",MemberVerificationAlreadyExistsError:"Member verification already exists",MemberVerificationDoesNotExistError:"Member verification does not exist",MinimumAgeRequirementError:"Minimum age requirement not met",MinimumDepositAmountNotMetError:"Minimum deposit amount not met",MinimumFirstDepositAmountNotMetError:"Minimum first deposit amount not met",MobileNumberAlreadyVerifiedError:"Mobile number is already verified",MobileNumberNotAvailableError:"Mobile number is no longer available",MobileNumberNotVerifiedError:"Mobile number is not verified",NickNameNotAvailableError:"Nickname is no longer available",NotEnoughBalanceError:"Insufficient balance",NotReadyToSendVerficationCodeError:"Not ready to send verification code",PromoNotEnabledError:"Promo is not enabled",RealNameAlreadySetError:"Real name is already set",ValidIdAlreadySetError:"Valid ID is already set",WalletDoesNotExistError:"Wallet does not exist",WithdrawalDailyLimitExceededError:"Daily withdrawal limit exceeded",GameProviderError:"Game provider error",GameSessionAlreadyClosedError:"Game session is already closed",GameSessionDoesNotExistError:"Game session does not exist",ReferralCodeNotAvailableError:"Referral code is no longer available",AccountBlacklistedError:"Account is blacklisted",InvalidTokenError:"Invalid token",InvalidTokenOrSecretAnswerError:"Invalid token or secret answer",SessionExpiredError:"Session expired",RateLimitExceededError:"Maximum number of requests reached"}[i]}}class Pt{constructor(e){c(this,"client");this.client=e}async memberAccount(){const e=await this.client.request(rt);return e.ok?{ok:!0,data:e.data.memberAccount}:e}async registerMemberAccount(e){const t=await this.client.request(nt,e);return t.ok?t.data.registerMemberAccount?{ok:!1,error:u(t.data.registerMemberAccount.__typename)}:{ok:!0}:t}async registerMemberAccountViaMobile(e){const t=await this.client.request(it,e);return t.ok?t.data.registerMemberAccountViaMobile?{ok:!1,error:u(t.data.registerMemberAccountViaMobile.__typename)}:{ok:!0}:t}async registerMemberAccount__next(e){const t=await this.client.request(ot,e);return t.ok?t.data.registerMemberAccount?{ok:!1,error:u(t.data.registerMemberAccount.__typename)}:{ok:!0}:t}async updateMemberAccount(e){const t=await this.client.request(mt,e);return t.ok?t.data.updateMemberAccount?{ok:!1,error:u(t.data.updateMemberAccount.__typename)}:{ok:!0}:t}async deleteMemberAccount(e){const t=await this.client.request(ut,e);return t.ok?t.data.deleteMemberAccount?{ok:!0}:{ok:!1,error:{name:"UnknownError",message:"Something went wrong."}}:t}async resetPassword(e){const t=await this.client.request(ct,e);return t.ok?t.data.resetPassword?{ok:!1,error:u(t.data.resetPassword.__typename)}:{ok:!0}:t}async profileCompletion(){const e=await this.client.request(ft);return e.ok?{ok:!0,data:e.data.profileCompletion}:e}async platform(){return await this.client.request(wt)}async sendVerificationCode(e){const t=await this.client.request(ht,e);return t.ok?t.data.sendVerificationCode?{ok:!1,error:u(t.data.sendVerificationCode.__typename)}:{ok:!0}:t}async paymentSettings(){return await this.client.request(gt)}async verifyMobileNumber(e){const t=await this.client.request(dt,e);return t.ok?t.data.verifyMobileNumber?{ok:!1,error:u(t.data.verifyMobileNumber.__typename)}:{ok:!0}:t}async createMemberVerification(e){const t=await this.client.request(lt,e);return t.ok?t.data.createMemberVerification?{ok:!1,error:u(t.data.createMemberVerification.__typename)}:{ok:!0}:t}async updateMemberVerification(e){const t=await this.client.request(pt,e);return t.ok?t.data.updateMemberVerification?{ok:!1,error:u(t.data.updateMemberVerification.__typename)}:{ok:!0}:t}async memberVerification(){const e=await this.client.request(at);return e.ok?{ok:!0,data:e.data.memberAccount.verification}:e}async announcements(e){const t=await this.client.request(Ie,e);return t.ok?{ok:!0,data:t.data.announcements}:t}async registerMayaMemberAccount(e){const t=await this.client.request(st,e);return t.ok?t.data.registerMayaMemberAccount?{ok:!1,error:u(t.data.registerMayaMemberAccount.__typename)}:{ok:!0}:t}async referralCode(){const e=await this.client.request(St);return e.ok?{ok:!0,data:e.data.referralCode}:e}async updateReferralCode(e){const t=await this.client.request(kt,e);return t.ok?t.data.updateReferralCode?{ok:!1,error:u(t.data.updateReferralCode.__typename)}:{ok:!0}:t}async pointsClubSettings(){const e=await this.client.request(vt);return e.ok?{ok:!0,data:e.data.pointsClubSettings}:e}}function y(i,e){const t=fe[i]?fe[i]:fe[500];return{name:t.name,message:e??t.message}}const fe={400:{name:"HttpBadRequest",message:"Bad Request"},401:{name:"HttpUnauthorized",message:"Unauthorized"},403:{name:"HttpForbidden",message:"Forbidden"},404:{name:"HttpNotFound",message:"Not Found"},408:{name:"HttpRequestTimeout",message:"Request Timeout"},429:{name:"HttpTooManyRequests",message:"Too Many Requests"},500:{name:"HttpInternalServerError",message:"Internal Server Error"}};class Gt{constructor(e){c(this,"url");c(this,"platform");this.url=e.url,this.platform=e.platform}get headers(){const e=new Headers;return e.append("Accept","application/json, text/plain"),e.append("Content-Type","application/json"),e.append("Platform-Code",this.platform),e.append("Role","MEMBER"),e}async createSession(e){const t=new Headers(this.headers);if(e.name){const r=`${e.name}:${e.password}`,a=Buffer.from(r).toString("base64");t.set("Authorization",`Basic ${a}`)}if(e.mobileNumber){const r=`${e.mobileNumber}:${e.verificationCode}`,a=Buffer.from(r).toString("base64");console.log(`MobileNumberOTP ${a}`),t.set("Authorization",`MobileNumberOTP ${a}`)}e.sessionId&&t.set("Authorization",`MayaSession ${e.sessionId}`),e.token&&t.set("Authorization",`Token ${e.token}`);try{const r=await fetch(`${this.url}/sessions`,{method:"POST",headers:t}),a=await r.json();return r.ok?{ok:!0,data:a}:a.code==="ACCOUNT_BLACKLISTED"?{ok:!1,error:u("AccountBlacklistedError")}:{ok:!1,error:y(r.status)}}catch{return{ok:!1,error:y(500)}}}async authenticate(e){const t=new Headers(this.headers);if(e.type==="SECURITY_QUESTION"){t.set("Authorization",`Bearer ${e.token}`);try{const r=await fetch(`${this.url}/session/${e.token}/authenticate`,{method:"POST",headers:t,body:JSON.stringify({secretAnswer:e.secretAnswer})}),a=await r.json();return r.ok?{ok:!0,data:a}:r.status===401||r.status===403?{ok:!1,error:u("InvalidTokenOrSecretAnswerError")}:{ok:!1,error:y(r.status)}}catch{return{ok:!1,error:y(500)}}}throw new Error("Invalid input 'type'")}async refreshSession(e){const t=new Headers(this.headers);t.append("Authorization",`Bearer ${e}`);try{const r=await fetch(`${this.url}/session:refresh`,{method:"POST",headers:t}),a=await r.json();return r.ok?{ok:!0,data:a}:a.code==="ACCOUNT_BLACKLISTED"?{ok:!1,error:u("AccountBlacklistedError")}:r.status===403||r.status===401?{ok:!1,error:u("InvalidTokenError")}:{ok:!1,error:y(r.status)}}catch{return{ok:!1,error:y(500)}}}async destroySession(e){const t=new Headers(this.headers);t.append("Authorization",`Bearer ${e}`);try{const r=await fetch(`${this.url}/session`,{method:"DELETE",headers:t});return r.ok?{ok:!0}:{ok:!1,error:y(r.status)}}catch{return{ok:!1,error:y(500)}}}async verifySession(e){const t=new Headers(this.headers);t.append("Authorization",`Bearer ${e}`);try{return(await fetch(`${this.url}/session`,{method:"GET",headers:t})).ok}catch{return!0}}async sendVerificationCode(e){if(e.channel==="EMAIL")throw new Error("Email channel is not yet supported");function t(r){switch(r){case"MEMBER_NOT_FOUND":return"AccountNotFoundError";case"RATE_LIMIT_REACH":return"RateLimitExceededError";case"NOT_READY_TO_SEND_VERIFICATION_ERROR":return"NotReadyToSendVerficationCodeError";default:return null}}try{const r=await fetch(`${this.url}/otps`,{method:"POST",headers:this.headers,body:JSON.stringify(e)});if(r.status===403){const a=await r.json(),s=t(a.message);return s?{ok:!1,error:u(s)}:{ok:!1,error:y(r.status,a.message)}}return r.ok?{ok:!0}:{ok:!1,error:y(r.status)}}catch{return{ok:!1,error:y(500)}}}}class xt{constructor(e){c(this,"url");c(this,"siteId");c(this,"platformId");this.url=e.url,this.siteId=e.site,this.platformId=e.platform}async self(){const e=await this.getJson(`/sites/${this.siteId}`);return e.ok?{ok:!0,data:e.data.data}:e}async games(e){var a,s,m,d,p,f,w,l,M,v,R,N,D,I,g,P,G,C,x,O,W,$,_,U;const t=new URLSearchParams;e!=null&&e.first&&t.set("first",e.first.toString()),e!=null&&e.after&&t.set("after",e.after),e!=null&&e.search&&t.set("search",e.search),(s=(a=e==null?void 0:e.filter)==null?void 0:a.type)!=null&&s.equal&&t.set("filter[type][eq]",e.filter.type.equal),(d=(m=e==null?void 0:e.filter)==null?void 0:m.type)!=null&&d.notEqual&&t.set("filter[type][neq]",e.filter.type.notEqual),(f=(p=e==null?void 0:e.filter)==null?void 0:p.type)!=null&&f.in&&t.set("filter[type][in]",e.filter.type.in.join(",")),(l=(w=e==null?void 0:e.filter)==null?void 0:w.type)!=null&&l.notIn&&t.set("filter[type][nin]",e.filter.type.notIn.join(",")),(v=(M=e==null?void 0:e.filter)==null?void 0:M.provider)!=null&&v.equal&&t.set("filter[provider][eq]",e.filter.provider.equal),(N=(R=e==null?void 0:e.filter)==null?void 0:R.provider)!=null&&N.notEqual&&t.set("filter[provider][neq]",e.filter.provider.notEqual),(I=(D=e==null?void 0:e.filter)==null?void 0:D.provider)!=null&&I.in&&t.set("filter[provider][in]",e.filter.provider.in.join(",")),(P=(g=e==null?void 0:e.filter)==null?void 0:g.provider)!=null&&P.notIn&&t.set("filter[provider][nin]",e.filter.provider.notIn.join(",")),(C=(G=e==null?void 0:e.filter)==null?void 0:G.tags)!=null&&C.equal&&t.set("filter[tags][eq]",e.filter.tags.equal.toLowerCase()),(O=(x=e==null?void 0:e.filter)==null?void 0:x.tags)!=null&&O.notEqual&&t.set("filter[tags][neq]",e.filter.tags.notEqual.toLowerCase()),($=(W=e==null?void 0:e.filter)==null?void 0:W.tags)!=null&&$.in&&t.set("filter[tags][in]",e.filter.tags.in.map(k=>k.toLowerCase()).join(",")),(U=(_=e==null?void 0:e.filter)==null?void 0:_.tags)!=null&&U.notIn&&t.set("filter[tags][nin]",e.filter.tags.notIn.map(k=>k.toLowerCase()).join(","));const r=await this.getJson("/games",t);return r.ok?{ok:!0,data:{edges:r.data.data.map(k=>({node:k,cursor:k.cursor})),totalCount:r.data.totalCount??0,pageInfo:{hasNextPage:!!r.data.next,endCursor:r.data.next}}}:r}async game(e){var r;const t=await this.getJson(`/games/${e}`);return((r=t.error)==null?void 0:r.name)==="HttpNotFound"?{ok:!0,data:null}:t.ok?{ok:!0,data:t.data.data}:t}async getJson(e,t){const r=new Request(`${this.url}${e}?${(t==null?void 0:t.toString())??""}`,{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json","Site-ID":this.siteId,"Platform-ID":this.platformId}});try{const a=await fetch(r);return a.ok?{ok:!0,data:await a.json()}:{ok:!1,error:y(a.status)}}catch{return{ok:!1,error:y(500)}}}}class Ot{constructor(e){c(this,"client");this.client=e}async file(e){const t=await this.client.request(Te,e);return t.ok?{ok:!0,data:t.data.node}:t}async uploadPrivateImageFile(e){const t=await this.client.upload(Me,e);return t.ok?t.data.uploadPrivateImageFile?{ok:!1,error:u(t.data.uploadPrivateImageFile.__typename)}:{ok:!0}:t}}class Wt{constructor(e){c(this,"client");this.client=e}async gameSession(e){const t=await this.client.request(ge.legacy,e);return t.ok?{ok:!0,data:t.data.node?{...t.data.node,game:t.data.node.game.id}:null}:t}async createGameSession(e){const t=await this.client.request(be,e);return t.ok?t.data.createGameSession?{ok:!1,error:u(t.data.createGameSession.__typename)}:{ok:!0}:t}async endGameSession(e){const t=await this.client.request(Ee.legacy,e);return t.ok?t.data.endGameSession?{ok:!1,error:{name:"UnknownError",message:"Something went wrong."}}:{ok:!0}:t}}class $t{constructor(e){c(this,"client");this.client=e}async latestBetRecords(){const e=await this.client.request(Qe);return e.ok?{ok:!0,data:e.data.latestBetRecords}:e}async platform(){const e=await this.client.request(yt);return e.ok?{ok:!0,data:e.data}:e}}class Ut{constructor(e){c(this,"client");this.client=e}async betRecords(e){const t=await this.client.request(je,e);return t.ok?{ok:t.ok,data:t.data.member.betRecords}:t}async transactionRecords(e){const t=await this.client.request(Ke,e);return t.ok?{ok:t.ok,data:t.data.member.transactionRecords}:t}async withdrawalRecords(e){const t=await this.client.request(Pe,e);return t.ok?{ok:t.ok,data:t.data.member.withdrawalRecords}:t}async depositRecords(e){const t=await this.client.request(Ue,e);return t.ok?{ok:t.ok,data:t.data.member.depositRecords}:t}async depositsCount(){const e=await this.client.request(Ye);return e.ok?{ok:e.ok,data:e.data.member.depositsCount}:e}async pointsWalletTransactions(e){const t=await this.client.request(De,e);return t.ok?{ok:t.ok,data:t.data.member.pointsWalletTransactions}:t}async activityRecords(e){const t=await this.client.request(At,e);return t.ok?{ok:t.ok,data:t.data.member.activityRecords}:t}async referrals(e){const t=await this.client.request(Ct,e);return t.ok?{ok:t.ok,data:t.data.member.referrals}:t}async referralCommission(){const e=await this.client.request(Mt);return e.ok?{ok:e.ok,data:e.data.member.referralCommission}:e}async uplinesByName(e){const t=await this.client.request(_t,e);return t.ok?{ok:t.ok,data:t.data.uplinesByName}:t}async downlinesByName(e){const t=await this.client.request(Tt,e);return t.ok?{ok:t.ok,data:t.data.downlinesByName}:t}}class Bt{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 qt{constructor(e){c(this,"client");this.client=e}async messages(e){const t=await this.client.request(Rt,e);return t.ok?{ok:t.ok,data:t.data.messages}:t}async unreadMessagesCount(e){const t=await this.client.request(Nt,{...e,filter:{...e==null?void 0:e.filter,markedAsRead:{equal:!1}}});return t.ok?{ok:t.ok,data:t.data.messages.totalCount}:t}async markMessageAsRead(e){const t=await this.client.request(Dt,e);return t.ok?t.data.markMessageAsRead?{ok:!0}:{ok:!1,error:{name:"UnknownError",message:"Something went wrong."}}:t}async markAllMessageAsRead(){const e=await this.client.request(It);return e.ok?e.data.markAllMessageAsRead?{ok:!0}:{ok:!1,error:{name:"UnknownError",message:"Something went wrong."}}:e}}class Ft{constructor(e){c(this,"client");this.client=e}async promos(){const e=await this.client.request(ze);return e.ok?{ok:e.ok,data:e.data.promos}:e}async cashbacks(){const e=await this.client.request(Xe);return e.ok?{ok:e.ok,data:e.data.cashbacks}:e}async availablePromos(e){const t=await this.client.request(Je,e);return t.ok?{ok:t.ok,data:t.data.availablePromos}:t}async cashbackBonuses(){const e=await this.client.request(et);return e.ok?{ok:e.ok,data:e.data.cashbackBonuses}:e}async claimCashbackBonus(e){const t=await this.client.request(tt,e);return t.ok?t.data.claimCashbackBonus?{ok:!1,error:u(t.data.claimCashbackBonus.__typename)}:{ok:!0}:{ok:t.ok,error:t.error}}async bonus(){const e=await this.client.request(Ze);return e.ok?{ok:e.ok,data:e.data.bonus}:e}async wallet(){const e=await this.client.request(ve);return e.ok?{ok:e.ok,data:e.data.wallet}:e}async deposit(e){const t=await this.client.request(He,e);return t.ok?{ok:t.ok,data:t.data.node}:t}async createGCashDeposit(e){const t=await this.client.request(Be,e);return t.ok?t.data.createGCashDeposit?{ok:!1,error:u(t.data.createGCashDeposit.__typename)}:{ok:!0}:t}async createMayaDeposit(e){const t=await this.client.request(qe,e);return t.ok?t.data.createMayaDeposit?{ok:!1,error:u(t.data.createMayaDeposit.__typename)}:{ok:!0}:t}async createAIOQRPHDeposit(e){const t=await this.client.request(Le,e);return t.ok?t.data.createAIOQRPHDeposit?{ok:!1,error:u(t.data.createAIOQRPHDeposit.__typename)}:{ok:!0}:t}async createAIOOnlineBankDeposit(e){const t=await this.client.request(Ve,e);return t.ok?t.data.createAIOOnlineBankDeposit?{ok:!1,error:u(t.data.createAIOOnlineBankDeposit.__typename)}:{ok:!0}:t}async createMayaAppDeposit(e){const t=await this.client.request(Fe,e);return t.ok?t.data.createMayaAppDeposit?{ok:!1,error:u(t.data.createMayaAppDeposit.__typename)}:{ok:!0}:t}async createGCashWithdrawal(e){const t=await this.client.request(Ge,e);return t.ok?t.data.createGCashWithdrawal?{ok:!1,error:u(t.data.createGCashWithdrawal.__typename)}:{ok:!0}:t}async createMayaWithdrawal(e){const t=await this.client.request(xe,e);return t.ok?t.data.createMayaWithdrawal?{ok:!1,error:u(t.data.createMayaWithdrawal.__typename)}:{ok:!0}:t}async createMayaAppWithdrawal(e){const t=await this.client.request(Oe,e);return t.ok?t.data.createMayaAppWithdrawal?{ok:!1,error:u(t.data.createMayaAppWithdrawal.__typename)}:{ok:!0}:t}async createBankWithdrawal(e){const t=await this.client.request(We,e);return t.ok?t.data.createBankWithdrawal?{ok:!1,error:u(t.data.createBankWithdrawal.__typename)}:{ok:!0}:t}async remainingDailyWithdrawalsCount(){const e=await this.client.request($e);return e.ok?{ok:e.ok,data:e.data.remainingDailyWithdrawalsCount}:e}async pointsWallet(){const e=await this.client.request(Re);return e.ok?{ok:e.ok,data:e.data.pointsWallet}:e}async redeemPointsToCash(e){const t=await this.client.request(Ne,e);return t.ok?t.data.redeemPointsToCash?{ok:!1,error:u(t.data.redeemPointsToCash.__typename)}:{ok:!0}:t}async mayaSession(e){const t=await this.client.request(bt,e);return t.ok?{ok:t.ok,data:t.data.mayaSession}:t}async gameSession(e){const t=await this.client.request(ge.current,e);return t.ok?{ok:!0,data:t.data.node}:t}async createGameSession(e){const t=await this.client.request(be,e);return t.ok?t.data.createGameSession?{ok:!1,error:u(t.data.createGameSession.__typename)}:{ok:!0}:t}async endGameSession(e){const t=await this.client.request(Ee.current,e);return t.ok?t.data.endGameSession?{ok:!0}:{ok:!1,error:{name:"UnknownError",message:"Something went wrong."}}:t}async validateMayaSession(){const e=await this.client.request(Et);return e.ok?e.data.validateMayaSession?{ok:!0}:{ok:!1,error:{name:"UnknownError",message:"Something went wrong."}}:e}}function he(i){return new Date(i.getTime())}function B(i,e){const t=he(i);return t.setMinutes(t.getMinutes()+e),t}function we(i,e){return i.getTime()>e.getTime()}class Lt{constructor(e){c(this,"config");c(this,"cache");this.cache={},this.config={cacheTime:5,...e}}set(e,t){const r=B(new Date,this.config.cacheTime);this.cache[e]={value:t,validUntil:r}}get(e){const t=this.cache[e];return!t||we(new Date,t.validUntil)?null:t.value}}function Vt(i,e,t){return i<e?e:i>t?t:i}function ye(i){return Object.prototype.toString.call(i)==="[object Object]"&&Object(i)===i}function Ht(i){const e=[];function t(r,a=[]){for(const s in r){const m=r[s];ye(m)?t(m,[...a,s]):Array.isArray(m)?t(Yt(m),[...a,s]):e.push({key:[...a,s],value:m})}}return t(i),e}function Yt(i){return i.reduce((e,t,r)=>(e[r]=t,e),{})}class q{constructor(e,t){c(this,"url");c(this,"options");c(this,"middlewares");var a;const r=new Headers((a=t==null?void 0:t.fetchOptions)==null?void 0:a.headers);this.url=e,this.options={...t==null?void 0:t.fetchOptions,headers:r},this.middlewares=(t==null?void 0:t.middlewares)??[]}async request(e,t){const r=JSON.stringify({query:e,variables:t}),a=new Headers(this.options.headers);a.set("Content-Type","application/json"),a.set("Accept","application/json");const s=await this.runMiddlewares(new Request(this.url,{...this.options,body:r,headers:a,method:"POST"}));return await this.exec(s)}async upload(e,t){const r=this.createUploadBody(e,t),a=new Headers(this.options.headers);a.delete("Content-Type");const s=await this.runMiddlewares(new Request(this.url,{...this.options,body:r,headers:a,method:"POST"}));return await this.exec(s)}async exec(e){var t,r,a,s,m,d;try{const p=await fetch(e);if(!p.ok)return{ok:!1,error:y(p.status)};const f=await p.json(),w=f.data,l=(t=f.errors)==null?void 0:t.at(0);return l?((r=l.extensions)==null?void 0:r.code)==="FORBIDDEN"||((a=l.extensions)==null?void 0:a.code)==="ACCESS_TOKEN_EXPIRED"?{ok:!1,error:y(403,l.message)}:((s=l.extensions)==null?void 0:s.code)==="UNAUTHORIZED"?{ok:!1,error:y(401,l.message)}:((m=l.extensions)==null?void 0:m.code)==="BAD_USER_INPUT"||((d=l.extensions)==null?void 0:d.code)==="BAD_REQUEST"?{ok:!1,error:y(400,l.message)}:{ok:!1,error:y(500,l.message)}:{ok:!0,data:w}}catch{return{ok:!1,error:y(500)}}}async runMiddlewares(e){let t=e.clone();for(const r of this.middlewares)t=await r(t);return t}createUploadBody(e,t){const r=Ht(t).filter(m=>m.value instanceof File||m.value instanceof Blob),a=new FormData;a.append("operations",JSON.stringify({query:e,variables:t}));const s={};return r.forEach((m,d)=>{s[d.toString()]=[`variables.${m.key.join(".")}`]}),a.append("map",JSON.stringify(s)),r.forEach((m,d)=>{a.append(d.toString(),m.value)}),a}}function jt(i){return i==="INR"?"en-IN":i==="MYR"?"en-MY":i==="IDR"?"en-ID":i==="USD"?"en-US":"en-PH"}function Qt(i){return i==="en-IN"?"+91":i==="en-MY"?"+60":i==="en-ID"?"+62":i==="en-US"?"+1":"+63"}function T(i,e){const t=Qt(e);return i.startsWith(t)?i:i.startsWith(t.substring(1))?`+${i}`:i.startsWith("0")?`${t}${i.substring(1)}`:`${t}${i}`}async function A(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 Se{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 F(i,e){const t=he(i);return t.setDate(t.getDate()+e),t}function ke(i){return new Promise(e=>{setTimeout(e,i)})}function Ce(i,e){const{until:t,interval:r=1e3,maxAttempt:a=3}=e;async function s(m,d){const p=d??a,f=await i(...m);return t(f)?f:p>1?(await ke(r*((a-p)/2)),s(m,p-1)):f}return async(...m)=>await s(m)}function L(i,e){const t=he(i);return t.setMinutes(t.getMinutes()-e),t}class Kt{constructor(e){c(this,"logger");c(this,"storageKey","session");c(this,"authService");c(this,"walletService");c(this,"_refreshing",!1);this.authService=e.authService,this.walletService=e.walletService,this.logger=new Se({enabled:e.logs??!1})}get refreshing(){return this._refreshing}set refreshing(e){this._refreshing=e}async create(e){var a;if(this.isServer)return this.logger.warn("'localStorage' is not available on the server."),{ok:!1,error:{name:"UnknownError",message:"Server sign in is not supported."}};if(e.type==="MAYA"){const m=await Ce(()=>this.walletService.mayaSession({id:e.sessionId}),{until:w=>{var l;return w.ok&&((l=w.data)==null?void 0:l.member)!=null},interval:1e3,maxAttempt:5})();if(!m.ok)return m;if(!((a=m.data)!=null&&a.member))return{ok:!1,error:{name:"HttpForbidden",message:"Forbidden"}};const p=await Ce(()=>this.authService.createSession(e),{until:w=>w.ok,interval:1e3,maxAttempt:5})();if(!p.ok)return p;const f=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...p.data,accessTokenExpiresAt:B(f,8).getTime(),refreshTokenExpiresAt:L(F(f,30),2).getTime()})),{ok:!0,data:null}}if(e.type==="MOBILE_NUMBER"){const s=await this.authService.createSession(e);if(s.ok){const m=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...s.data,accessTokenExpiresAt:B(m,8).getTime(),refreshTokenExpiresAt:L(F(m,30),2).getTime()})),{ok:!0,data:null}}return s}if(e.type==="TOKEN"){const s=await this.authService.createSession({token:e.token});if(s.ok){const m=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...s.data,accessTokenExpiresAt:B(m,8).getTime(),refreshTokenExpiresAt:L(F(m,30),2).getTime()})),{ok:!0,data:null}}return s}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 r=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...t.data,accessTokenExpiresAt:B(r,8).getTime(),refreshTokenExpiresAt:L(F(r,30),2).getTime()})),{ok:!0,data:null}}async createFromAuthenticator(e){const t=await this.authService.authenticate(e);if(t.ok){const r=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:B(r,8).getTime(),refreshTokenExpiresAt:L(F(r,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 ke(1e3),await this.get();const e=window.localStorage.getItem(this.storageKey);if(!e)return{ok:!0,data:null};try{let t=JSON.parse(e),r=new Date;const a=new Date(t.accessTokenExpiresAt),s=new Date(t.refreshTokenExpiresAt);if(we(r,s))return this.logger.warn("Session expired. Logging out.."),window.localStorage.removeItem(this.storageKey),{ok:!1,error:{name:"SessionExpiredError",message:"Session expired."}};if(we(r,a)){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.name==="InvalidTokenError"||m.error.name==="AccountBlacklistedError"?(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!"),r=new Date,t={...t,...m.data,accessTokenExpiresAt:B(r,8).getTime(),refreshTokenExpiresAt:L(F(r,30),2).getTime()},window.localStorage.setItem(this.storageKey,JSON.stringify(t))}return{ok:!0,data:t}}catch{return{ok:!1,error:{name:"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 r,a,s;if(this.isServer)return this.logger.warn("'localStorage' is not available on the server."),!0;const e=await this.get();if(((r=e.error)==null?void 0:r.name)==="InvalidTokenError"||((a=e.error)==null?void 0:a.name)==="SessionExpiredError"||((s=e.error)==null?void 0:s.name)==="AccountBlacklistedError")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){const e={};for(const t in i){const r=i[t];if(r!==null&&r!==void 0){if(ye(r)){e[t]=S(r);continue}if(Array.isArray(r)){e[t]=r.map(a=>ye(a)?S(a):a);continue}e[t]=r}}return e}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 zt{constructor(e){c(this,"staticService");const t=(e==null?void 0:e.environment)==="development";this.staticService=new Bt({url:t?"https://static.development.opexa.io":"https://static.opexa.io"})}get transform(){return{site:this.site.bind(this),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),pointsWalletTransaction:this.pointsWalletTransaction.bind(this),activityRecord:this.activityRecord.bind(this),referral:this.referral.bind(this),referralCommission:this.referralCommission.bind(this),platform__next:this.platform__next.bind(this),pointsClubSettings:this.pointsClubSettings.bind(this),paymentSettings:this.paymentSettings.bind(this),message:this.message.bind(this)}}site(e){const t={id:e.id,name:e.name,logo:e.logo??void 0,fields:e.config.fields};return S(t)}platform(e){var t,r,a,s,m,d,p,f,w,l,M,v,R,N,D,I,g,P,G,C,x,O,W,$,_,U,k,V,H,Y,j,Q,K,z,J,X,Z,ee,te,re,ae,ne,ie,oe,se,me,ce,ue,_e;return{timezone:e.timezone,currency:e.currency,paymentSettings:{minimumFirstDepositAmount:n(e.minimumFirstDepositAmount),restrictWithdrawalsToVerifiedMembers:e.restrictWithdrawalsToVerifiedMembers,depositGateway:{bank:{androidEnabled:((t=e.bankDepositGatewaySettings)==null?void 0:t.androidEnabled)??!1,iosEnabled:((r=e.bankDepositGatewaySettings)==null?void 0:r.iosEnabled)??!1,webEnabled:((a=e.bankDepositGatewaySettings)==null?void 0:a.webEnabled)??!1,mobileWebEnabled:((s=e.bankDepositGatewaySettings)==null?void 0:s.mobileWebEnabled)??!1,minimumAmount:n((m=e.bankDepositGatewaySettings)==null?void 0:m.minimumAmount),maximumAmount:n((d=e.bankDepositGatewaySettings)==null?void 0:d.maximumAmount)},gcash:{androidEnabled:((p=e.gcashDepositGatewaySettings)==null?void 0:p.androidEnabled)??!1,iosEnabled:((f=e.gcashDepositGatewaySettings)==null?void 0:f.iosEnabled)??!1,webEnabled:((w=e.gcashDepositGatewaySettings)==null?void 0:w.webEnabled)??!1,mobileWebEnabled:((l=e.gcashDepositGatewaySettings)==null?void 0:l.mobileWebEnabled)??!1,minimumAmount:n((M=e.gcashDepositGatewaySettings)==null?void 0:M.minimumAmount),maximumAmount:n((v=e.gcashDepositGatewaySettings)==null?void 0:v.maximumAmount)},maya:{androidEnabled:((R=e.mayaDepositGatewaySettings)==null?void 0:R.androidEnabled)??!1,iosEnabled:((N=e.mayaDepositGatewaySettings)==null?void 0:N.iosEnabled)??!1,webEnabled:((D=e.mayaDepositGatewaySettings)==null?void 0:D.webEnabled)??!1,mobileWebEnabled:((I=e.mayaDepositGatewaySettings)==null?void 0:I.mobileWebEnabled)??!1,minimumAmount:n((g=e.mayaDepositGatewaySettings)==null?void 0:g.minimumAmount),maximumAmount:n((P=e.mayaDepositGatewaySettings)==null?void 0:P.maximumAmount)},mayaApp:{androidEnabled:((G=e.mayaAppDepositGatewaySettings)==null?void 0:G.androidEnabled)??!1,iosEnabled:((C=e.mayaAppDepositGatewaySettings)==null?void 0:C.iosEnabled)??!1,webEnabled:((x=e.mayaAppDepositGatewaySettings)==null?void 0:x.webEnabled)??!1,mobileWebEnabled:((O=e.mayaAppDepositGatewaySettings)==null?void 0:O.mobileWebEnabled)??!1,minimumAmount:n((W=e.mayaAppDepositGatewaySettings)==null?void 0:W.minimumAmount),maximumAmount:n(($=e.mayaAppDepositGatewaySettings)==null?void 0:$.maximumAmount)}},withdrawalGateway:{bank:{androidEnabled:((_=e.bankWithdrawalGatewaySettings)==null?void 0:_.androidEnabled)??!1,iosEnabled:((U=e.bankWithdrawalGatewaySettings)==null?void 0:U.iosEnabled)??!1,webEnabled:((k=e.bankWithdrawalGatewaySettings)==null?void 0:k.webEnabled)??!1,mobileWebEnabled:((V=e.bankWithdrawalGatewaySettings)==null?void 0:V.mobileWebEnabled)??!1,minimumAmount:n((H=e.bankWithdrawalGatewaySettings)==null?void 0:H.minimumAmount),maximumAmount:n((Y=e.bankWithdrawalGatewaySettings)==null?void 0:Y.maximumAmount)},gcash:{androidEnabled:((j=e.gcashWithdrawalGatewaySettings)==null?void 0:j.androidEnabled)??!1,iosEnabled:((Q=e.gcashWithdrawalGatewaySettings)==null?void 0:Q.iosEnabled)??!1,webEnabled:((K=e.gcashWithdrawalGatewaySettings)==null?void 0:K.webEnabled)??!1,mobileWebEnabled:((z=e.gcashWithdrawalGatewaySettings)==null?void 0:z.mobileWebEnabled)??!1,minimumAmount:n((J=e.gcashWithdrawalGatewaySettings)==null?void 0:J.minimumAmount),maximumAmount:n((X=e.gcashWithdrawalGatewaySettings)==null?void 0:X.maximumAmount,1e6)},maya:{androidEnabled:((Z=e.mayaWithdrawalGatewaySettings)==null?void 0:Z.androidEnabled)??!1,iosEnabled:((ee=e.mayaWithdrawalGatewaySettings)==null?void 0:ee.iosEnabled)??!1,webEnabled:((te=e.mayaWithdrawalGatewaySettings)==null?void 0:te.webEnabled)??!1,mobileWebEnabled:((re=e.mayaWithdrawalGatewaySettings)==null?void 0:re.mobileWebEnabled)??!1,minimumAmount:n((ae=e.mayaWithdrawalGatewaySettings)==null?void 0:ae.minimumAmount),maximumAmount:n((ne=e.mayaWithdrawalGatewaySettings)==null?void 0:ne.maximumAmount)},mayaApp:{androidEnabled:((ie=e.mayaAppWithdrawalGatewaySettings)==null?void 0:ie.androidEnabled)??!1,iosEnabled:((oe=e.mayaAppWithdrawalGatewaySettings)==null?void 0:oe.iosEnabled)??!1,webEnabled:((se=e.mayaAppWithdrawalGatewaySettings)==null?void 0:se.webEnabled)??!1,mobileWebEnabled:((me=e.mayaAppWithdrawalGatewaySettings)==null?void 0:me.mobileWebEnabled)??!1,minimumAmount:n((ce=e.mayaAppWithdrawalGatewaySettings)==null?void 0:ce.minimumAmount),maximumAmount:n((ue=e.mayaAppWithdrawalGatewaySettings)==null?void 0:ue.maximumAmount,1e6)}}},pointsClubSettings:{multiplier:n((_e=e.pointsClubSettings)==null?void 0:_e.multiplier,0)}}}platform__next(e){return{currency:e.currency,timezone:e.timezone,locale:jt(e.currency)}}pointsClubSettings(e){return{multiplier:n(e.multiplier,0)}}paymentSettings(e){var t,r,a,s,m,d,p,f,w,l,M,v,R,N,D,I,g,P,G,C,x,O,W,$,_,U,k,V,H,Y,j,Q,K,z,J,X,Z,ee,te,re,ae,ne,ie,oe,se,me,ce,ue;return{minimumFirstDepositAmount:n(e.minimumFirstDepositAmount),restrictWithdrawalsToVerifiedMembers:e.restrictWithdrawalsToVerifiedMembers,depositGateway:{bank:{androidEnabled:((t=e.bankDepositGatewaySettings)==null?void 0:t.androidEnabled)??!1,iosEnabled:((r=e.bankDepositGatewaySettings)==null?void 0:r.iosEnabled)??!1,webEnabled:((a=e.bankDepositGatewaySettings)==null?void 0:a.webEnabled)??!1,mobileWebEnabled:((s=e.bankDepositGatewaySettings)==null?void 0:s.mobileWebEnabled)??!1,minimumAmount:n((m=e.bankDepositGatewaySettings)==null?void 0:m.minimumAmount),maximumAmount:n((d=e.bankDepositGatewaySettings)==null?void 0:d.maximumAmount)},gcash:{androidEnabled:((p=e.gcashDepositGatewaySettings)==null?void 0:p.androidEnabled)??!1,iosEnabled:((f=e.gcashDepositGatewaySettings)==null?void 0:f.iosEnabled)??!1,webEnabled:((w=e.gcashDepositGatewaySettings)==null?void 0:w.webEnabled)??!1,mobileWebEnabled:((l=e.gcashDepositGatewaySettings)==null?void 0:l.mobileWebEnabled)??!1,minimumAmount:n((M=e.gcashDepositGatewaySettings)==null?void 0:M.minimumAmount),maximumAmount:n((v=e.gcashDepositGatewaySettings)==null?void 0:v.maximumAmount)},maya:{androidEnabled:((R=e.mayaDepositGatewaySettings)==null?void 0:R.androidEnabled)??!1,iosEnabled:((N=e.mayaDepositGatewaySettings)==null?void 0:N.iosEnabled)??!1,webEnabled:((D=e.mayaDepositGatewaySettings)==null?void 0:D.webEnabled)??!1,mobileWebEnabled:((I=e.mayaDepositGatewaySettings)==null?void 0:I.mobileWebEnabled)??!1,minimumAmount:n((g=e.mayaDepositGatewaySettings)==null?void 0:g.minimumAmount),maximumAmount:n((P=e.mayaDepositGatewaySettings)==null?void 0:P.maximumAmount)},mayaApp:{androidEnabled:((G=e.mayaAppDepositGatewaySettings)==null?void 0:G.androidEnabled)??!1,iosEnabled:((C=e.mayaAppDepositGatewaySettings)==null?void 0:C.iosEnabled)??!1,webEnabled:((x=e.mayaAppDepositGatewaySettings)==null?void 0:x.webEnabled)??!1,mobileWebEnabled:((O=e.mayaAppDepositGatewaySettings)==null?void 0:O.mobileWebEnabled)??!1,minimumAmount:n((W=e.mayaAppDepositGatewaySettings)==null?void 0:W.minimumAmount),maximumAmount:n(($=e.mayaAppDepositGatewaySettings)==null?void 0:$.maximumAmount)}},withdrawalGateway:{bank:{androidEnabled:((_=e.bankWithdrawalGatewaySettings)==null?void 0:_.androidEnabled)??!1,iosEnabled:((U=e.bankWithdrawalGatewaySettings)==null?void 0:U.iosEnabled)??!1,webEnabled:((k=e.bankWithdrawalGatewaySettings)==null?void 0:k.webEnabled)??!1,mobileWebEnabled:((V=e.bankWithdrawalGatewaySettings)==null?void 0:V.mobileWebEnabled)??!1,minimumAmount:n((H=e.bankWithdrawalGatewaySettings)==null?void 0:H.minimumAmount),maximumAmount:n((Y=e.bankWithdrawalGatewaySettings)==null?void 0:Y.maximumAmount)},gcash:{androidEnabled:((j=e.gcashWithdrawalGatewaySettings)==null?void 0:j.androidEnabled)??!1,iosEnabled:((Q=e.gcashWithdrawalGatewaySettings)==null?void 0:Q.iosEnabled)??!1,webEnabled:((K=e.gcashWithdrawalGatewaySettings)==null?void 0:K.webEnabled)??!1,mobileWebEnabled:((z=e.gcashWithdrawalGatewaySettings)==null?void 0:z.mobileWebEnabled)??!1,minimumAmount:n((J=e.gcashWithdrawalGatewaySettings)==null?void 0:J.minimumAmount),maximumAmount:n((X=e.gcashWithdrawalGatewaySettings)==null?void 0:X.maximumAmount,1e6)},maya:{androidEnabled:((Z=e.mayaWithdrawalGatewaySettings)==null?void 0:Z.androidEnabled)??!1,iosEnabled:((ee=e.mayaWithdrawalGatewaySettings)==null?void 0:ee.iosEnabled)??!1,webEnabled:((te=e.mayaWithdrawalGatewaySettings)==null?void 0:te.webEnabled)??!1,mobileWebEnabled:((re=e.mayaWithdrawalGatewaySettings)==null?void 0:re.mobileWebEnabled)??!1,minimumAmount:n((ae=e.mayaWithdrawalGatewaySettings)==null?void 0:ae.minimumAmount),maximumAmount:n((ne=e.mayaWithdrawalGatewaySettings)==null?void 0:ne.maximumAmount)},mayaApp:{androidEnabled:((ie=e.mayaAppWithdrawalGatewaySettings)==null?void 0:ie.androidEnabled)??!1,iosEnabled:((oe=e.mayaAppWithdrawalGatewaySettings)==null?void 0:oe.iosEnabled)??!1,webEnabled:((se=e.mayaAppWithdrawalGatewaySettings)==null?void 0:se.webEnabled)??!1,mobileWebEnabled:((me=e.mayaAppWithdrawalGatewaySettings)==null?void 0:me.mobileWebEnabled)??!1,minimumAmount:n((ce=e.mayaAppWithdrawalGatewaySettings)==null?void 0:ce.minimumAmount),maximumAmount:n((ue=e.mayaAppWithdrawalGatewaySettings)==null?void 0:ue.maximumAmount,1e6)}}}}account(e){const t={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,secretAnswerSubmitted:e.secretAnswerSubmitted??!1,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)};return S(t)}wallet(e){return{id:e.id,balance:n(e.balance,0),currency:e.currency,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}verificationDetails(e){return{id:e.id,status:e.status,address:e.address,permanentAddress:e.permanentAddress,nationality:e.nationality,natureOfWork:e.natureOfWork,placeOfBirth:e.placeOfBirth,sourceOfIncome:e.sourceOfIncome,selfieImage:this.file(e.selfieImage),idFrontImage:this.file(e.idFrontImage)}}profileCompletion(e){return{accountPassword:e.accountPassword??!1,accountVerification:e.accountVerification??!1,mobileNumberVerification:e.mobileNumberVerification??!1,personalInformation:e.personalInformation??!1,transactionPassword:e.transactionPassword??!1,completionPercentage:n(e.completionPercentage,0)}}announcement(e){return{id:e.id,type:e.type,title:e.title,status:e.status,message:e.message,activationEndDateTime:new Date(e.activationEndDateTime),activationStartDateTime:new Date(e.activationStartDateTime),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}withdrawalRecord(e){const t={id:e.id,type:e.type,bank:e.bank,status:e.status,amount:n(e.amount,0),netAmount:n(e.netAmount,0),fee:n(e.fee,0),reference:e.reference??void 0,withdrawalNumber:e.withdrawalNumber,recipientMobileNumber:e.recipientMobileNumber??void 0,dateTimeConfirmed:e.dateTimeConfirmed?new Date(e.dateTimeConfirmed):void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)};return S(t)}deposit(e){const t={id:e.id,type:e.type,status:e.status,checkoutUrl:e.checkoutUrl??void 0};return S(t)}depositRecord(e){const t={id:e.id,type:e.type,status:e.status,amount:n(e.amount,0),fee:n(e.fee,0),netAmount:n(e.netAmount,0),reference:e.reference??void 0,depositNumber:e.depositNumber,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)};return S(t)}betRecord(e){var r;const t={id:e.id,bet:n(e.bet,0),payout:n(e.payout,0),status:e.status,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:{name:e.game.name,type:e.game.type,images:this.staticService.gameThumbnails(e.game),provider:e.game.provider},serialCode:e.serialCode,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:((r=e.metadata)==null?void 0:r.odds)??void 0}};return S(t)}latestBetRecord(e){return{id:e.id,member:e.member,game:{name:e.game.name,type:e.game.type,images:this.staticService.gameThumbnails(e.game),provider:e.game.provider},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){const t={id:e.id,type:e.type,amount:n(e.amount,0),content:e.content??void 0,currentBalance:n(e.currentBalance,0),referenceNumber:e.referenceNumber,dateTimeCreated:new Date(e.dateTimeCreated)};return S(t)}game(e){return{id:e.id,type:e.type,tags:e.tags??[],name:e.name,images:[e.customImage,e.image].filter(Boolean),provider:e.provider,reference:e.reference}}gameSession(e){const t={id:e.id,status:e.status,launchUrl:e.launchUrl??void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)};return S(t)}promo(e){return{id:e.id,type:e.type,name:e.name,status:e.status,description:e.description,banner:this.file(e.banner),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{id:e.id,name:e.name,description:e.description,status:e.status,minimumCashback:n(e.minimumCashback,0),maximumMonthlyCashback:n(e.maximumMonthlyCashback),banner:this.file(e.banner),activationEndDateTime:new Date(e.activationEndDateTime),activationStartDateTime:new Date(e.activationStartDateTime),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated),turnoverContributionPercentagePerGameProvider:Object.entries(e.turnoverContributionPercentagePerGameProvider).reduce((r,[a,s])=>(r[a]=n(s,0),r),{})}}bonus(e){const t={id:e.id,promo:this.promo(e.promo),deposit:e.deposit?{type:e.deposit.type,status:e.deposit.status,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)};return S(t)}cashbackBonus(e){return{id:e.id,total:n(e.total,0),balance:n(e.balance,0),cashback:this.cashback(e.cashback),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}file(e){const t={id:e.id,url:e.url??void 0,status:e.status,dateTimeCreated:new Date(e.dateTimeCreated)};return S(t)}pointsWallet(e){return{id:e.id,points:n(e.points,0),account:e.account,dateTimeCreated:new Date(e.dateTimeCreated)}}pointsWalletTransaction(e){return{id:e.id,type:e.type,amount:n(e.amount,0),balance:n(e.balance,0),dateTimeCreated:new Date(e.dateTimeCreated)}}activityRecord(e){const t={id:e.id,type:e.type,amount:e.amount?n(e.amount,0):void 0,domain:e.domain??void 0,details:e.details,dateTimeCreated:new Date(e.dateTimeCreated)};return S(t)}referral(e){return{id:e.id,level:e.level,upline:e.upline,downline:e.downline,turnover:n(e.turnover,0),commission:n(e.commission,0),dateTimeCreated:new Date(e.dateTimeCreated)}}referralCommission(e){return{id:e.id,commission:n(e.commission,0),level1Commission:n(e.level1Commission,0),level2Commission:n(e.level2Commission,0),level3Commission:n(e.level3Commission,0),referralsCount:e.referralsCount,level1ReferralsCount:e.level1ReferralsCount,level2ReferralsCount:e.level2ReferralsCount,level3ReferralsCount:e.level3ReferralsCount,referralCode:e.referralCode,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}message(e){return{id:e.id,logo:e.logo,title:e.title,popup:e.popup,content:e.content,actions:e.actions,markedAsRead:e.markedAsRead,dateTimeCreated:new Date(e.dateTimeCreated)}}}class Jt{constructor(e){c(this,"cmsPortalService");c(this,"authService");c(this,"gameService");c(this,"fileService");c(this,"walletService");c(this,"accountService");c(this,"reportService");c(this,"portalService");c(this,"triggerService");c(this,"sessionManager");c(this,"transformer");c(this,"logger");c(this,"cache");const{site:t,sitePlatform:r,platform:a,environment:s,logs:m}=e,d=s==="production";this.transformer=new zt({environment:s}),this.logger=new Se({enabled:m??!1});const p=d?"https://auth.opexa.io":"https://auth.development.opexa.io",f=d?"https://wallet.opexa.io/graphql":"https://wallet.development.opexa.io/graphql",w=d?"https://report.opexa.io/graphql":"https://report.development.opexa.io/graphql",l=d?"https://account.opexa.io/graphql":"https://account.development.opexa.io/graphql",M=d?"https://portal.opexa.io/graphql":"https://portal.development.opexa.io/graphql",v=d?"https://file.opexa.io/graphql":"https://file.development.opexa.io/graphql",R=d?"https://game.opexa.io/graphql":"https://game.development.opexa.io/graphql",N=d?"https://trigger.opexa.io/graphql":"https://trigger.development.opexa.io/graphql",D="https://portal-api.opexacms.io/v1",I=new xt({url:D,site:t,platform:r}),g={middlewares:[this.authMiddleware],fetchOptions:{headers:{Role:"MEMBER","Platform-Code":a}}},P=new Wt(new q(R,g)),G=new Ot(new q(v,g)),C=new Ft(new q(f,g)),x=new Pt(new q(l,g)),O=new Ut(new q(w,g)),W=new $t(new q(M,g)),$=new qt(new q(N,g)),_=new Gt({url:p,platform:a}),U=new Kt({logs:m,authService:_,walletService:C});this.authService=_,this.gameService=P,this.fileService=G,this.walletService=C,this.accountService=x,this.reportService=O,this.portalService=W,this.triggerService=$,this.sessionManager=U,this.cmsPortalService=I,this.cache=new Lt}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}}get locale(){return new Promise(e=>{const t="locale",r=this.cache.get(t);if(r)return e(r);this.platform__next().then(a=>{a.ok?(this.cache.set(t,a.data.locale),e(a.data.locale)):(this.logger.warn("Failed to fetch currency. Using 'PH' as fallback"),e("en-PH"))})})}async signIn(e){switch(e.type){case"NAME_AND_PASSWORD":{const t=await this.sessionManager.create({...e,password:await A(e.password)});return t.ok?t.data?{ok:!0,data:{"2FAEnabled":!0,authenticator:t.data.authenticator}}:{ok:!0,data:{"2FAEnabled":!1}}:t}case"TOKEN":{const t=await this.sessionManager.create({type:"TOKEN",token:e.token});return t.ok?{ok:!0}:t}case"MOBILE_NUMBER":{const t=await this.sessionManager.create({type:"MOBILE_NUMBER",mobileNumber:T(e.mobileNumber,await this.locale),verificationCode:e.verificationCode});return t.ok?{ok:!0}:t}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 A(e.secretAnswer)});default:return{ok:!1,error:{name:"HttpBadRequest",message:"Invalid input 'type'"}}}}async signOut(){await this.sessionManager.destroy()}watchSession(e){const t=Vt(e.interval??3e4,3e4,6e4);let r=null;const a=()=>setTimeout(async()=>{await this.sessionManager.verify()||await e.onInvalid(),r=a()},t);return r=a(),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 validateMayaSession(){return await this.walletService.validateMayaSession()}async site(){const e=await this.cmsPortalService.self();return e.ok?{ok:!0,data:this.transformer.transform.site(e.data)}:e}async platform(){const e=await this.accountService.platform();return e.ok?{ok:!0,data:this.transformer.transform.platform(e.data)}:e}async platform__next(){const e=await this.portalService.platform();return e.ok?{ok:!0,data:this.transformer.transform.platform__next(e.data)}:e}async paymentSettings(){const e=await this.accountService.paymentSettings();return e.ok?{ok:!0,data:this.transformer.transform.paymentSettings(e.data)}:e}async account(){const e=await this.accountService.memberAccount();return e.ok?{ok:!0,data:this.transformer.transform.account(e.data)}:e}async createAccount(e){const t=e.id??h.ObjectId.generate(E.Account).toString(),r=await this.accountService.registerMemberAccount({input:{id:t,btag:e.btag,name:e.name,domain:e.domain,birthDay:typeof e.dateOfBirth=="string"?e.dateOfBirth:e.dateOfBirth.toISOString(),password:await A(e.password),mobileNumber:T(e.mobileNumber,await this.locale)},referralCode:e.referralCode,verificationCode:e.verificationCode,reCAPTCHAResponse:e.reCAPTCHAResponse});return r.ok?{ok:!0,data:{id:t}}:r}async createAccount__next(e){const t=e.id??h.ObjectId.generate(E.Account).toString();if(e.type==="MOBILE_NUMBER"){const a=await this.accountService.registerMemberAccountViaMobile({input:{id:t,mobileNumber:T(e.mobileNumber,await this.locale)},referralCode:e.referralCode,reCAPTCHAResponse:e.reCAPTCHAResponse,verificationCode:e.verificationCode});return a.ok?{ok:!0,data:{id:t}}:a}const r=await this.accountService.registerMemberAccount__next({input:{id:t,name:e.name,password:await A(e.password),mobileNumber:e.mobileNumber?T(e.mobileNumber,await this.locale):void 0},reCAPTCHAResponse:e.reCAPTCHAResponse});return r.ok?{ok:!0,data:{id:t}}:r}async registerMayaAccount(e){return await this.accountService.registerMayaMemberAccount({input:{name:e.name,password:await A(e.password),domain:e.domain}})}async updateAccount(e,t){return await this.accountService.updateMemberAccount({input:{id:e,data:{...t,password:t.password?await A(t.password):void 0,transactionPassword:t.transactionPassword?await A(t.transactionPassword):void 0,...t.mobileNumber&&{mobileNumber:T(t.mobileNumber,await this.locale)},secretAnswer:t.secretAnswer?await A(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??h.ObjectId.generate(E.Verification).toString(),r=await this.accountService.createMemberVerification({input:{id:t,...e}});return r.ok?{ok:!0,data:{id:t}}:r}async updateVerificationDetails(e,t){return await this.accountService.updateMemberVerification({input:{id:e,data:{...t}}})}async resetPassword(e){return await this.accountService.resetPassword({input:{mobileNumber:T(e.mobileNumber,await this.locale),newPassword:await A(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:T(e,await this.locale)}})}async sendVerificationCode__next(e){if(e.type==="SMS")return this.authService.sendVerificationCode({channel:"SMS",recipient:T(e.mobileNumber,await this.locale),...e.strict&&{verificationType:"MEMBER"}});throw new Error("'Email' verification code is not yet supported")}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:{...e==null?void 0:e.filter,visibility:{in:["MEMBER","GLOBAL"]}}});return t.ok?{ok:!0,data:{announcements:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.announcement(a),cursor:r})),totalCount:t.data.totalCount,endCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async createWithdrawal(e){const t=e.id??h.ObjectId.generate(E.Withdrawal).toString();if(e.type==="BANK"){const r=await this.walletService.createBankWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await A(e.transactionPassword)}});if(!r.ok)return r}if(e.type==="GCASH"){const r=await this.walletService.createGCashWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await A(e.transactionPassword),recipientMobileNumber:T(e.recipientMobileNumber,await this.locale)}});if(!r.ok)return r}if(e.type==="MAYA"){const r=await this.walletService.createMayaWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await A(e.transactionPassword),recipientMobileNumber:T(e.recipientMobileNumber,await this.locale)}});if(!r.ok)return r}if(e.type==="MAYA_APP"){const r=await this.walletService.createMayaAppWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await A(e.transactionPassword)}});if(!r.ok)return r}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:r,node:a})=>({...this.transformer.transform.withdrawalRecord(a),cursor:r})),totalCount:t.data.totalCount,endCursor: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??h.ObjectId.generate(E.Deposit).toString();if(e.type==="MAYA"){const r=await this.walletService.createMayaDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!r.ok)return r}if(e.type==="MAYA_APP"){const r=await this.walletService.createMayaAppDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!r.ok)return r}if(e.type==="GCASH"){const r=await this.walletService.createGCashDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!r.ok)return r}if(e.type==="AIO_ONLINE_BANK"){const r=await this.walletService.createAIOOnlineBankDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!r.ok)return r}if(e.type==="AIO_QRPH"){const r=await this.walletService.createAIOQRPHDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!r.ok)return r}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:r,node:a})=>({...this.transformer.transform.depositRecord(a),cursor:r})),totalCount:t.data.totalCount,endCursor: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,...(e==null?void 0:e.filter)&&{filter:{...e.filter.status&&{status:e.filter.status},...e.filter.serialCode&&{serialCode:e.filter.serialCode},...e.filter.vendorRoundId&&{vendorRoundId:e.filter.vendorRoundId},...e.filter.gameType&&{game__type:e.filter.gameType},...e.filter.gameProvider&&{game__provider:e.filter.gameProvider},...e.filter.dateTimeCreated&&{dateTimeCreated:e.filter.dateTimeCreated}}}});return t.ok?{ok:!0,data:{betRecords:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.betRecord(a),cursor:r})),totalCount:t.data.totalCount,endCursor: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:r,node:a})=>({...this.transformer.transform.transactionRecord(a),cursor:r})),totalCount:t.data.totalCount,endCursor: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 game(e){const t=await this.cmsPortalService.game(e);return t.ok?{ok:!0,data:t.data?this.transformer.transform.game(t.data):null}:t}async games(e){const t=await this.cmsPortalService.games(e);return t.ok?{ok:!0,data:{games:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.game(a),cursor:r})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}async gameSession(e){const t=await this.walletService.gameSession({id:e});if(!t.ok)return t;if(t.data)return{ok:!0,data:this.transformer.transform.gameSession(t.data)};const r=await this.gameService.gameSession({id:e});return r.ok?{ok:!0,data:r.data?this.transformer.transform.gameSession(r.data):null}:r}async createGameSession(e){const t=e.id??h.ObjectId.generate(E.GameSession).toString();if(e.game.startsWith("SPORTS:")){const f=await h.ObjectId.generateFromKey(E.Game,e.game).then(l=>l.toString()),w=await this.gameService.createGameSession({input:{id:t,game:f}});return w.ok?{ok:!0,data:{id:t}}:w}const a=await this.game(e.game);if(!a.data)return{ok:!1,error:{name:"GameDoesNotExistError",message:"Game does not exist"}};const{provider:s,reference:m}=a.data,p=["RTG","DARWIN","DRBINGO","MEGABALL","EVOLUTION","EVOLUTION_NETENT","EVOLUTION_REDTIGER"].includes(s)?await this.walletService.createGameSession({input:{id:t,game:m}}):await this.gameService.createGameSession({input:{id:t,game:m}});return p.ok?{ok:!0,data:{id:t}}:p}async endGameSession(e){const t=await this.walletService.endGameSession({input:{id:e}});return t.ok?t:await this.gameService.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??h.ObjectId.generate(E.File).toString(),r=await this.fileService.uploadPrivateImageFile({input:{id:t,file:e.file}});return r.ok?{ok:!0,data:{id:t}}:r}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 redeemPoints(e){return await this.walletService.redeemPointsToCash({input:{amount:e.amount.toString()}})}async pointsWalletTransactions(e){const t=await this.reportService.pointsWalletTransactions(e);return t.ok?{ok:!0,data:{pointsWalletTransactions:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.pointsWalletTransaction(a),cursor:r})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}async activityRecords(e){const t=await this.reportService.activityRecords(e);return t.ok?{ok:!0,data:{activityRecords:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.activityRecord(a),cursor:r})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}async referralCode(){const e=await this.accountService.referralCode();return e.ok?{ok:!0,data:e.data??null}:e}async updateReferralCode(e){return await this.accountService.updateReferralCode({input:e})}async referrals(e){const t=await this.reportService.referrals(e);return t.ok?{ok:!0,data:{referrals:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.referral(a),cursor:r})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}async referralCommission(){const e=await this.reportService.referralCommission();return e.ok?{ok:!0,data:e.data?this.transformer.transform.referralCommission(e.data):null}:e}async uplinesByName(e){const t=await this.reportService.uplinesByName(e);return t.ok?{ok:!0,data:t.data.map(this.transformer.transform.referral)}:t}async downlinesByName(e){const t=await this.reportService.downlinesByName(e);return t.ok?{ok:!0,data:t.data.map(this.transformer.transform.referral)}:t}async pointsClubSettings(){const e=await this.accountService.pointsClubSettings();return e.ok?{ok:!0,data:e.data?this.transformer.transform.pointsClubSettings(e.data):null}:e}async messages(e){const t=await this.triggerService.messages(e);return t.ok?{ok:!0,data:{messages:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.message(a),cursor:r})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}async unreadMessagesCount(e){return await this.triggerService.unreadMessagesCount(e)}async markMessageAsRead(e){return await this.triggerService.markMessageAsRead({id:e})}async markAllMessageAsRead(){return await this.triggerService.markAllMessageAsRead()}}Object.defineProperty(b,"ObjectId",{enumerable:!0,get:()=>h.ObjectId}),b.ObjectType=E,b.Sdk=Jt,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
1230
1300
  //# sourceMappingURL=index.js.map