@opexa/portal-sdk 0.0.42 → 0.0.44

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(y,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("@opexa/object-id")):typeof define=="function"&&define.amd?define(["exports","@opexa/object-id"],l):(y=typeof globalThis<"u"?globalThis:y||self,l(y.sdk={},y.objectId))})(this,function(y,l){"use strict";var $t=Object.defineProperty;var Ot=(y,l,g)=>l in y?$t(y,l,{enumerable:!0,configurable:!0,writable:!0,value:g}):y[l]=g;var m=(y,l,g)=>Ot(y,typeof l!="symbol"?l+"":l,g);const g={Account:8,Deposit:9,Withdrawal:14,Verification:15,File:16,Game:203,GameSession:204,MayaSession:230};function o(n,...e){let t="";for(const[r,a]of n.entries()){const s=e.at(r)??"";t=`${t}${a}${s}`}return t.trim()}const V=o`
1
+ (function(w,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("@opexa/object-id")):typeof define=="function"&&define.amd?define(["exports","@opexa/object-id"],l):(w=typeof globalThis<"u"?globalThis:w||self,l(w.sdk={},w.objectId))})(this,function(w,l){"use strict";var Ot=Object.defineProperty;var Ut=(w,l,g)=>l in w?Ot(w,l,{enumerable:!0,configurable:!0,writable:!0,value:g}):w[l]=g;var m=(w,l,g)=>Ut(w,typeof l!="symbol"?l+"":l,g);const g={Account:8,Deposit:9,Withdrawal:14,Verification:15,File:16,Game:203,GameSession:204,MayaSession:230};function o(n,...e){let t="";for(const[a,r]of n.entries()){const s=e.at(a)??"";t=`${t}${r}${s}`}return t.trim()}const V=o`
2
2
  fragment FileFragment on File {
3
3
  id
4
4
  url
@@ -140,7 +140,7 @@
140
140
  mutation EndGameSession($input: EndGameSessionInput!) {
141
141
  endGameSession(input: $input)
142
142
  }
143
- `,Ge=o`
143
+ `,xe=o`
144
144
  mutation EndGameSession($input: EndGameSessionInput!) {
145
145
  endGameSession(input: $input) {
146
146
  ... on GameSessionDoesNotExistError {
@@ -154,7 +154,7 @@
154
154
  }
155
155
  }
156
156
  }
157
- `,xe=o`
157
+ `,Ge=o`
158
158
  query Announcements($first: Int, $after: Cursor, $filter: AnnouncementFilterInput) {
159
159
  announcements(first: $first, after: $after, filter: $filter) {
160
160
  edges {
@@ -180,7 +180,7 @@
180
180
  }
181
181
  }
182
182
  }
183
- `,$e=o`
183
+ `,We=o`
184
184
  query WithdrawalRecords($first: Int, $after: Cursor, $filter: WithdrawalRecordFilterInput) {
185
185
  member {
186
186
  withdrawalRecords(first: $first, after: $after, filter: $filter) {
@@ -247,7 +247,7 @@
247
247
  }
248
248
  }
249
249
  }
250
- `,Oe=o`
250
+ `,$e=o`
251
251
  mutation CreateGCashWithdrawal($input: CreateGCashWithdrawalInput!) {
252
252
  createGCashWithdrawal(input: $input) {
253
253
  ... on AccountNotVerifiedError {
@@ -270,7 +270,7 @@
270
270
  }
271
271
  }
272
272
  }
273
- `,We=o`
273
+ `,Oe=o`
274
274
  mutation CreateMayaWithdrawal($input: CreateMayaWithdrawalInput!) {
275
275
  createMayaWithdrawal(input: $input) {
276
276
  ... on AccountNotVerifiedError {
@@ -314,6 +314,26 @@
314
314
  }
315
315
  }
316
316
  `,Be=o`
317
+ mutation CreateMayaAppWithdrawal($input: CreateMayaAppWithdrawalInput!) {
318
+ createMayaAppWithdrawal: createMayaAppWithdrawal_next(input: $input) {
319
+ ... on AccountNotVerifiedError {
320
+ __typename
321
+ }
322
+ ... on InvalidTransactionPasswordError {
323
+ __typename
324
+ }
325
+ ... on InvalidWithdrawalAmountError {
326
+ __typename
327
+ }
328
+ ... on NotEnoughBalanceError {
329
+ __typename
330
+ }
331
+ ... on WithdrawalDailyLimitExceededError {
332
+ __typename
333
+ }
334
+ }
335
+ }
336
+ `,qe=o`
317
337
  mutation CreateBankWithdrawal($input: CreateBankWithdrawalInput!) {
318
338
  createBankWithdrawal(input: $input) {
319
339
  ... on MobileNumberNotVerifiedError {
@@ -336,11 +356,11 @@
336
356
  }
337
357
  }
338
358
  }
339
- `,qe=o`
359
+ `,Fe=o`
340
360
  query RemainingDailyWithdrawalsCount {
341
361
  remainingDailyWithdrawalsCount
342
362
  }
343
- `,Fe=o`
363
+ `,Le=o`
344
364
  query DepositRecords($after: Cursor, $first: Int, $filter: DepositRecordFilterInput) {
345
365
  member {
346
366
  depositRecords(after: $after, first: $first, filter: $filter) {
@@ -369,7 +389,7 @@
369
389
  }
370
390
  }
371
391
  }
372
- `,Le=o`
392
+ `,Ve=o`
373
393
  mutation CreateGCashDeposit($input: CreateGCashDepositInput!) {
374
394
  createGCashDeposit(input: $input) {
375
395
  ... on DepositPromoMaximumAmountExceededError {
@@ -398,7 +418,7 @@
398
418
  }
399
419
  }
400
420
  }
401
- `,Ve=o`
421
+ `,Ye=o`
402
422
  mutation CreateMayaDeposit($input: CreateMayaDepositInput!) {
403
423
  createMayaDeposit(input: $input) {
404
424
  ... on DepositPromoMaximumAmountExceededError {
@@ -427,7 +447,7 @@
427
447
  }
428
448
  }
429
449
  }
430
- `,Ye=o`
450
+ `,je=o`
431
451
  mutation CreateMayaAppDeposit($input: CreateMayaAppDepositInput!) {
432
452
  createMayaAppDeposit(input: $input) {
433
453
  ... on DepositPromoMaximumAmountExceededError {
@@ -456,7 +476,36 @@
456
476
  }
457
477
  }
458
478
  }
459
- `,je=o`
479
+ `,He=o`
480
+ mutation CreateMayaAppDeposit($input: CreateMayaAppDepositInput!) {
481
+ createMayaAppDeposit: createMayaAppDeposit_next(input: $input) {
482
+ ... on DepositPromoMaximumAmountExceededError {
483
+ __typename
484
+ }
485
+ ... on DepositPromoMinimumAmountNotMetError {
486
+ __typename
487
+ }
488
+ ... on HasActiveBonusError {
489
+ __typename
490
+ }
491
+ ... on MaximumDepositAmountExceededError {
492
+ __typename
493
+ }
494
+ ... on MinimumDepositAmountNotMetError {
495
+ __typename
496
+ }
497
+ ... on MinimumFirstDepositAmountNotMetError {
498
+ __typename
499
+ }
500
+ ... on PromoNotEnabledError {
501
+ __typename
502
+ }
503
+ ... on WalletDoesNotExistError {
504
+ __typename
505
+ }
506
+ }
507
+ }
508
+ `,Qe=o`
460
509
  query Deposit($id: ObjectId!) {
461
510
  node(id: $id) {
462
511
  ... on GCashDeposit {
@@ -488,13 +537,13 @@
488
537
  }
489
538
  }
490
539
  }
491
- `,He=o`
540
+ `,Ke=o`
492
541
  query DepositsCount {
493
542
  member {
494
543
  depositsCount
495
544
  }
496
545
  }
497
- `,Qe=o`
546
+ `,ze=o`
498
547
  query BetRecords($first: Int, $after: Cursor, $filter: BetRecordFilterInput) {
499
548
  member {
500
549
  betRecords(first: $first, after: $after, filter: $filter) {
@@ -506,6 +555,7 @@
506
555
  id
507
556
  serialCode
508
557
  game {
558
+ id
509
559
  name
510
560
  type
511
561
  provider
@@ -534,7 +584,7 @@
534
584
  }
535
585
  }
536
586
  }
537
- `,Ke=o`
587
+ `,Je=o`
538
588
  query LatestBetRecords {
539
589
  latestBetRecords {
540
590
  id
@@ -542,6 +592,7 @@
542
592
  name
543
593
  }
544
594
  game {
595
+ id
545
596
  name
546
597
  type
547
598
  provider
@@ -553,7 +604,7 @@
553
604
  dateTimeCreated
554
605
  }
555
606
  }
556
- `,ze=o`
607
+ `,Xe=o`
557
608
  query TransactionRecords($first: Int, $after: Cursor, $filter: TransactionRecordFilter) {
558
609
  member {
559
610
  transactionRecords(first: $first, after: $after, filter: $filter) {
@@ -598,7 +649,7 @@
598
649
  dateTimeCreated
599
650
  dateTimeLastUpdated
600
651
  }
601
- `,Je=o`
652
+ `,Ze=o`
602
653
  ${Y}
603
654
 
604
655
  query Promos {
@@ -606,7 +657,7 @@
606
657
  ...PromoFragment
607
658
  }
608
659
  }
609
- `,Xe=o`
660
+ `,et=o`
610
661
  ${Y}
611
662
 
612
663
  query AvailablePromos($filter: PromoFilterInput) {
@@ -631,7 +682,7 @@
631
682
  dateTimeCreated
632
683
  dateTimeLastUpdated
633
684
  }
634
- `,Ze=o`
685
+ `,tt=o`
635
686
  ${Z}
636
687
 
637
688
  query Cashbacks {
@@ -639,7 +690,7 @@
639
690
  ...CashbackFragment
640
691
  }
641
692
  }
642
- `,et=o`
693
+ `,at=o`
643
694
  ${Y}
644
695
 
645
696
  query Bonus {
@@ -668,7 +719,7 @@
668
719
  dateTimeLastUpdated
669
720
  }
670
721
  }
671
- `,tt=o`
722
+ `,rt=o`
672
723
  ${Z}
673
724
 
674
725
  query CashbackBonuses {
@@ -682,7 +733,7 @@
682
733
  dateTimeLastUpdated
683
734
  }
684
735
  }
685
- `,rt=o`
736
+ `,nt=o`
686
737
  mutation ClaimCashbackBonus($input: ClaimCashbackBonusInput!) {
687
738
  claimCashbackBonus(input: $input) {
688
739
  ... on CashbackBonusDoesNotExistError {
@@ -690,13 +741,13 @@
690
741
  }
691
742
  }
692
743
  }
693
- `,at=o`
744
+ `,ot=o`
694
745
  query Member {
695
746
  member {
696
747
  dateTimeLastActive
697
748
  }
698
749
  }
699
- `,nt=o`
750
+ `,it=o`
700
751
  query MemberAccount {
701
752
  memberAccount: self {
702
753
  ... on MemberAccount {
@@ -720,7 +771,7 @@
720
771
  }
721
772
  }
722
773
  }
723
- `,ot=o`
774
+ `,st=o`
724
775
  ${V}
725
776
 
726
777
  query MemberVerification {
@@ -744,7 +795,7 @@
744
795
  }
745
796
  }
746
797
  }
747
- `,it=o`
798
+ `,ct=o`
748
799
  mutation RegisterMemberAccount(
749
800
  $input: RegisterMemberAccountInput!
750
801
  $referralCode: String
@@ -780,7 +831,7 @@
780
831
  }
781
832
  }
782
833
  }
783
- `,st=o`
834
+ `,mt=o`
784
835
  mutation RegisterMayaMemberAccount($input: RegisterMayaMemberAccountInput!) {
785
836
  registerMayaMemberAccount(input: $input) {
786
837
  ... on AccountNameNotAvailableError {
@@ -788,7 +839,7 @@
788
839
  }
789
840
  }
790
841
  }
791
- `,ct=o`
842
+ `,dt=o`
792
843
  mutation UpdateMemberAccount($input: UpdateMemberAccountInput!) {
793
844
  updateMemberAccount(input: $input) {
794
845
  ... on AccountNameNotAvailableError {
@@ -814,7 +865,7 @@
814
865
  }
815
866
  }
816
867
  }
817
- `,mt=o`
868
+ `,ut=o`
818
869
  mutation ResetPassword($input: ResetPasswordInput!, $verificationCode: String) {
819
870
  resetPassword(input: $input, verificationCode: $verificationCode) {
820
871
  ... on AccountNotFoundError {
@@ -825,11 +876,11 @@
825
876
  }
826
877
  }
827
878
  }
828
- `,dt=o`
879
+ `,lt=o`
829
880
  mutation DeleteMemberAccount($input: DeleteMemberAccountInput!) {
830
881
  deleteMemberAccount(input: $input)
831
882
  }
832
- `,ut=o`
883
+ `,pt=o`
833
884
  mutation VerifyMobileNumber($input: VerifyMobileNumberInput!) {
834
885
  verifyMobileNumber(input: $input) {
835
886
  ... on InvalidSMSVerificationCodeError {
@@ -840,7 +891,7 @@
840
891
  }
841
892
  }
842
893
  }
843
- `,lt=o`
894
+ `,ft=o`
844
895
  mutation CreateMemberVerification($input: CreateMemberVerificationInput!) {
845
896
  createMemberVerification(input: $input) {
846
897
  ... on FileDoesNotExistError {
@@ -854,7 +905,7 @@
854
905
  }
855
906
  }
856
907
  }
857
- `,pt=o`
908
+ `,ht=o`
858
909
  mutation UpdateMemberVerification($input: UpdateMemberVerificationInput!) {
859
910
  updateMemberVerification(input: $input) {
860
911
  ... on FileDoesNotExistError {
@@ -871,7 +922,7 @@
871
922
  }
872
923
  }
873
924
  }
874
- `,ft=o`
925
+ `,yt=o`
875
926
  query ProfileCompletion {
876
927
  profileCompletion {
877
928
  completionPercentage
@@ -882,7 +933,7 @@
882
933
  accountPassword
883
934
  }
884
935
  }
885
- `,ht=o`
936
+ `,wt=o`
886
937
  mutation SendVerificationCode($input: SendVerificationCodeInput!) {
887
938
  sendVerificationCode(input: $input) {
888
939
  ... on InvalidPlatformError {
@@ -893,7 +944,7 @@
893
944
  }
894
945
  }
895
946
  }
896
- `,wt=o`
947
+ `,gt=o`
897
948
  fragment DepositGatewaySettingsCoreData on DepositGatewaySettings {
898
949
  minimumAmount
899
950
  maximumAmount
@@ -947,7 +998,7 @@
947
998
  multiplier
948
999
  }
949
1000
  }
950
- `,yt=o`
1001
+ `,Et=o`
951
1002
  query MayaSession($id: ObjectId!) {
952
1003
  mayaSession(id: $id) {
953
1004
  id
@@ -955,7 +1006,7 @@
955
1006
  dateTimeCreated
956
1007
  }
957
1008
  }
958
- `,gt=o`
1009
+ `,At=o`
959
1010
  mutation ValidateMayaSession {
960
1011
  validateMayaSession: validMayaSession
961
1012
  }
@@ -984,5 +1035,5 @@
984
1035
  }
985
1036
  }
986
1037
  }
987
- `;function u(n){return{name:n,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",AccountBlacklisted:"Account is blacklisted",AccountNotFound:"Account not found",InvalidToken:"Invalid token",InvalidTokenOrSecretAnswer:"Invalid token or secret answer",SessionExpired:"Session expired"}[n]}}class Et{constructor(e){m(this,"client");this.client=e}async memberAccount(){const e=await this.client.request(nt);return e.ok?{ok:!0,data:e.data.memberAccount}:e}async registerMemberAccount(e){const t=await this.client.request(it,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(ct,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(dt,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(mt,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 verifyMobileNumber(e){const t=await this.client.request(ut,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(ot);return e.ok?{ok:!0,data:e.data.memberAccount.verification}:e}async announcements(e){const t=await this.client.request(xe,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}}function w(n,e){const t=j[n]?j[n]:j[500];return{name:t.name,message:e??t.message}}const j={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 bt{constructor(e){m(this,"url");m(this,"platform");this.url=e.url,this.platform=e.platform}async createSession(e){const t=new Headers({"Content-Type":"application/json","Platform-Code":this.platform,Role:"MEMBER"});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");t.set("Authorization",`MobileNumberOTP ${a}`)}e.sessionId&&t.set("Authorization",`Maya ${e.sessionId}`);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("AccountBlacklisted")}:{ok:!1,error:w(r.status)}}catch{return{ok:!1,error:w(500)}}}async authenticate(e){const t=new Headers({"Content-Type":"application/json","Platform-Code":this.platform,Role:"MEMBER"});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("InvalidTokenOrSecretAnswer")}:{ok:!1,error:w(r.status)}}catch{return{ok:!1,error:w(500)}}}throw new Error("Invalid input 'type'")}async refreshSession(e){try{const t=await fetch(`${this.url}/session:refresh`,{method:"POST",headers:{"Content-Type":"application/json","Platform-Code":this.platform,Role:"MEMBER",Authorization:`Bearer ${e}`}}),r=await t.json();return t.ok?{ok:!0,data:r}:r.code==="ACCOUNT_BLACKLISTED"?{ok:!1,error:u("AccountBlacklisted")}:t.status===403||t.status===401?{ok:!1,error:u("InvalidToken")}:{ok:!1,error:w(t.status)}}catch{return{ok:!1,error:w(500)}}}async destroySession(e){try{const t=await fetch(`${this.url}/session`,{method:"DELETE",headers:{"Content-Type":"application/json","Platform-Code":this.platform,Role:"MEMBER",Authorization:`Bearer ${e}`}});return t.ok?{ok:!0}:{ok:!1,error:w(t.status)}}catch{return{ok:!1,error:w(500)}}}async verifySession(e){try{return(await fetch(`${this.url}/session`,{method:"GET",headers:{"Content-Type":"application/json","Platform-Code":this.platform,Role:"MEMBER",Authorization:`Bearer ${e}`}})).ok}catch{return!0}}}class At{constructor(e){m(this,"url");m(this,"siteId");m(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,c,f,p,h,S,d,M,N,I,D,R,P,G,x,$,O,W,U,B,q,F,L;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),(f=(c=e==null?void 0:e.filter)==null?void 0:c.type)!=null&&f.notEqual&&t.set("filter[type][neq]",e.filter.type.notEqual),(h=(p=e==null?void 0:e.filter)==null?void 0:p.type)!=null&&h.in&&t.set("filter[type][in]",e.filter.type.in.join(",")),(d=(S=e==null?void 0:e.filter)==null?void 0:S.type)!=null&&d.notIn&&t.set("filter[type][nin]",e.filter.type.notIn.join(",")),(N=(M=e==null?void 0:e.filter)==null?void 0:M.provider)!=null&&N.equal&&t.set("filter[provider][eq]",e.filter.provider.equal),(D=(I=e==null?void 0:e.filter)==null?void 0:I.provider)!=null&&D.notEqual&&t.set("filter[provider][neq]",e.filter.provider.notEqual),(P=(R=e==null?void 0:e.filter)==null?void 0:R.provider)!=null&&P.in&&t.set("filter[provider][in]",e.filter.provider.in.join(",")),(x=(G=e==null?void 0:e.filter)==null?void 0:G.provider)!=null&&x.notIn&&t.set("filter[provider][nin]",e.filter.provider.notIn.join(",")),(O=($=e==null?void 0:e.filter)==null?void 0:$.tags)!=null&&O.equal&&t.set("filter[tags][eq]",e.filter.tags.equal.toLowerCase()),(U=(W=e==null?void 0:e.filter)==null?void 0:W.tags)!=null&&U.notEqual&&t.set("filter[tags][neq]",e.filter.tags.notEqual.toLowerCase()),(q=(B=e==null?void 0:e.filter)==null?void 0:B.tags)!=null&&q.in&&t.set("filter[tags][in]",e.filter.tags.in.map(A=>A.toLowerCase()).join(",")),(L=(F=e==null?void 0:e.filter)==null?void 0:F.tags)!=null&&L.notIn&&t.set("filter[tags][nin]",e.filter.tags.notIn.map(A=>A.toLowerCase()).join(","));const r=await this.getJson("/games",t);return r.ok?{ok:!0,data:{edges:r.data.data.map(A=>({node:A,cursor:A.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:w(a.status)}}catch{return{ok:!1,error:w(500)}}}}class kt{constructor(e){m(this,"client");this.client=e}async file(e){const t=await this.client.request(ve,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 _t{constructor(e){m(this,"client");this.client=e}async games(e){const t=await this.client.request(K,e);return t.ok?{ok:t.ok,data:t.data.games}:t}async gamesByName(e){const t=await this.client.request(z,e);return t.ok?{ok:t.ok,data:t.data.gamesByName}:t}async gameSession(e){const t=await this.client.request(J,e);return t.ok?{ok:!0,data:t.data.node}:t}async createGameSession(e){const t=await this.client.request(X,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(Ge,e);return t.ok?t.data.endGameSession?{ok:!1,error:u(t.data.endGameSession.__typename)}:{ok:!0}:t}}class Ct{constructor(e){m(this,"client");this.client=e}async latestBetRecords(){const e=await this.client.request(Ke);return e.ok?{ok:!0,data:e.data.latestBetRecords}:e}}class Tt{constructor(e){m(this,"client");this.client=e}async betRecords(e){const t=await this.client.request(Qe,e);return t.ok?{ok:t.ok,data:t.data.member.betRecords}:t}async transactionRecords(e){const t=await this.client.request(ze,e);return t.ok?{ok:t.ok,data:t.data.member.transactionRecords}:t}async withdrawalRecords(e){const t=await this.client.request($e,e);return t.ok?{ok:t.ok,data:t.data.member.withdrawalRecords}:t}async depositRecords(e){const t=await this.client.request(Fe,e);return t.ok?{ok:t.ok,data:t.data.member.depositRecords}:t}async depositsCount(){const e=await this.client.request(He);return e.ok?{ok:e.ok,data:e.data.member.depositsCount}:e}async member(){const e=await this.client.request(at);return e.ok?{ok:e.ok,data:e.data.member}:e}async pointsWalletTransactions(e){const t=await this.client.request(Re,e);return t.ok?{ok:t.ok,data:t.data.member.pointsWalletTransactions}:t}async activityRecords(e){const t=await this.client.request(St,e);return t.ok?{ok:t.ok,data:t.data.member.activityRecords}:t}}class vt{constructor(e){m(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 ee{constructor(e){m(this,"client");this.client=e}async promos(){const e=await this.client.request(Je);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(Xe,e);return t.ok?{ok:t.ok,data:t.data.availablePromos}:t}async cashbackBonuses(){const e=await this.client.request(tt);return e.ok?{ok:e.ok,data:e.data.cashbackBonuses}:e}async claimCashbackBonus(e){const t=await this.client.request(rt,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(et);return e.ok?{ok:e.ok,data:e.data.bonus}:e}async wallet(){const e=await this.client.request(Ne);return e.ok?{ok:e.ok,data:e.data.wallet}:e}async deposit(e){const t=await this.client.request(je,e);return t.ok?{ok:t.ok,data:t.data.node}:t}async createGCashDeposit(e){const t=await this.client.request(Le,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(Ve,e);return t.ok?t.data.createMayaDeposit?{ok:!1,error:u(t.data.createMayaDeposit.__typename)}:{ok:!0}:t}async createMayaAppDeposit(e){const t=await this.client.request(Ye,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(Oe,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(We,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(Ue,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(Be,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(qe);return e.ok?{ok:e.ok,data:e.data.remainingDailyWithdrawalsCount}:e}async pointsWallet(){const e=await this.client.request(Ie);return e.ok?{ok:e.ok,data:e.data.pointsWallet}:e}async pointsToCashConversion(e){const t=await this.client.request(De,e);return t.ok?t.data.pointsToCashConversion?{ok:!1,error:u(t.data.pointsToCashConversion.__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 games(e){const t=await this.client.request(K,e);return t.ok?{ok:t.ok,data:t.data.games}:t}async gamesByName(e){const t=await this.client.request(z,e);return t.ok?{ok:t.ok,data:t.data.gamesByName}:t}async gameSession(e){const t=await this.client.request(J,e);return t.ok?{ok:!0,data:t.data.node}:t}async createGameSession(e){const t=await this.client.request(X,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(Pe,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 Mt(n,e,t){return n<e?e:n>t?t:n}function H(n){return Object.prototype.toString.call(n)==="[object Object]"&&Object(n)===n}function Nt(n){const e=[];function t(r,a=[]){for(const s in r){const c=r[s];H(c)?t(c,[...a,s]):Array.isArray(c)?t(It(c),[...a,s]):e.push({key:[...a,s],value:c})}}return t(n),e}function It(n){return n.reduce((e,t,r)=>(e[r]=t,e),{})}class k{constructor(e,t){m(this,"url");m(this,"options");m(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,c,f;try{const p=await fetch(e);if(!p.ok)return{ok:!1,error:w(p.status)};const h=await p.json(),S=h.data,d=(t=h.errors)==null?void 0:t.at(0);return d?((r=d.extensions)==null?void 0:r.code)==="FORBIDDEN"||((a=d.extensions)==null?void 0:a.code)==="ACCESS_TOKEN_EXPIRED"?{ok:!1,error:w(403,d.message)}:((s=d.extensions)==null?void 0:s.code)==="UNAUTHORIZED"?{ok:!1,error:w(401,d.message)}:((c=d.extensions)==null?void 0:c.code)==="BAD_USER_INPUT"||((f=d.extensions)==null?void 0:f.code)==="BAD_REQUEST"?{ok:!1,error:w(400,d.message)}:{ok:!1,error:w(500,d.message)}:{ok:!0,data:S}}catch{return{ok:!1,error:w(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=Nt(t).filter(c=>c.value instanceof File||c.value instanceof Blob),a=new FormData;a.append("operations",JSON.stringify({query:e,variables:t}));const s={};return r.forEach((c,f)=>{s[f.toString()]=[`variables.${c.key.join(".")}`]}),a.append("map",JSON.stringify(s)),r.forEach((c,f)=>{a.append(f.toString(),c.value)}),a}}function _(n){return n.startsWith("+63")?n:n.startsWith("63")?`+${n}`:n.startsWith("0")?`+63${n.substring(1)}`:`+63${n}`}async function b(n){const e=new TextEncoder().encode(n),t=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(t)).map(s=>s.toString(16).padStart(2,"0")).join("")}class te{constructor(e){m(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 Q(n){return new Date(n.getTime())}function C(n,e){const t=Q(n);return t.setDate(t.getDate()+e),t}function T(n,e){const t=Q(n);return t.setMinutes(t.getMinutes()+e),t}function re(n,e){return n.getTime()>e.getTime()}function ae(n){return new Promise(e=>{setTimeout(e,n)})}function ne(n,e){const{until:t,interval:r=1e3,maxAttempt:a=3}=e;async function s(c,f){const p=f??a,h=await n(...c);return t(h)?h:p>1?(await ae(r*((a-p)/2)),s(c,p-1)):h}return async(...c)=>await s(c)}function v(n,e){const t=Q(n);return t.setMinutes(t.getMinutes()-e),t}class Dt{constructor(e){m(this,"logger");m(this,"storageKey","session");m(this,"authService");m(this,"walletService");m(this,"_refreshing",!1);this.authService=new bt({url:e.authUrl,platform:e.platform}),this.walletService=new ee(new k(e.walletUrl,{middlewares:[t=>(t.headers.set("Platform",e.platform),t.headers.set("Role","MEMBER"),t)]})),this.logger=new te({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 c=await ne(()=>this.walletService.mayaSession({id:e.sessionId}),{until:S=>{var d;return S.ok&&((d=S.data)==null?void 0:d.member)!=null},interval:1e3,maxAttempt:5})();if(!c.ok)return c;if(!((a=c.data)!=null&&a.member))return{ok:!1,error:{name:"HttpForbidden",message:"Forbidden"}};const p=await ne(()=>this.authService.createSession(e),{until:S=>S.ok,interval:1e3,maxAttempt:5})();if(!p.ok)return p;const h=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...p.data,accessTokenExpiresAt:T(h,8).getTime(),refreshTokenExpiresAt:v(C(h,30),2).getTime()})),{ok:!0,data:null}}if(e.type==="MOBILE_NUMBER"){const s=await this.authService.createSession(e);if(s.ok){const c=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...s.data,accessTokenExpiresAt:T(c,8).getTime(),refreshTokenExpiresAt:v(C(c,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:T(r,8).getTime(),refreshTokenExpiresAt:v(C(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:T(r,8).getTime(),refreshTokenExpiresAt:v(C(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 ae(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(re(r,s))return this.logger.warn("Session expired. Logging out.."),window.localStorage.removeItem(this.storageKey),{ok:!1,error:{name:"SessionExpired",message:"Session expired."}};if(re(r,a)){this.logger.info("Refreshing session..."),this.refreshing=!0;const c=await this.authService.refreshSession(t.refreshToken);if(this.refreshing=!1,!c.ok)return this.logger.error(`Failed to refresh session: ${c.error.message}`),c.error.name==="InvalidToken"||c.error.name==="AccountBlacklisted"?(window.localStorage.removeItem(this.storageKey),{ok:!1,error:c.error}):(this.logger.warn("Old session returned."),{ok:!0,data:t});this.logger.success("Session refreshed!"),r=new Date,t={...t,...c.data,accessTokenExpiresAt:T(r,8).getTime(),refreshTokenExpiresAt:v(C(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)==="InvalidToken"||((a=e.error)==null?void 0:a.name)==="SessionExpired"||((s=e.error)==null?void 0:s.name)==="AccountBlacklisted")return!1;if(!e.data)return!0;const t=await this.authService.verifySession(e.data.accessToken);return t||window.localStorage.removeItem(this.storageKey),t}get isServer(){return typeof window>"u"}}function E(n){const e={};for(const t in n){const r=n[t];if(r!==null&&r!==void 0){if(H(r)){e[t]=E(r);continue}if(Array.isArray(r)){e[t]=r.map(a=>H(a)?E(a):a);continue}e[t]=r}}return e}function i(n,e){if(typeof n=="number"&&!Number.isNaN(n))return n;if(typeof n=="string"){const t=Number.parseFloat(n);if(!Number.isNaN(t))return t}return e}class Rt{constructor(e){m(this,"staticService");const t=(e==null?void 0:e.environment)==="development";this.staticService=new vt({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),game__next:this.game__next.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)}}site(e){const t={id:e.id,name:e.name,logo:e.logo??void 0};return E(t)}platform(e){var t,r,a,s,c,f,p,h,S,d,M,N,I,D,R,P,G,x,$,O,W,U,B,q,F,L,A,oe,ie,se,ce,me,de,ue,le,pe,fe,he,we,ye,ge,Se,Ee,be,Ae,ke,_e,Ce,Te;return{paymentSettings:{minimumFirstDepositAmount:i(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:i((c=e.bankDepositGatewaySettings)==null?void 0:c.minimumAmount),maximumAmount:i((f=e.bankDepositGatewaySettings)==null?void 0:f.maximumAmount)},gcash:{androidEnabled:((p=e.gcashDepositGatewaySettings)==null?void 0:p.androidEnabled)??!1,iosEnabled:((h=e.gcashDepositGatewaySettings)==null?void 0:h.iosEnabled)??!1,webEnabled:((S=e.gcashDepositGatewaySettings)==null?void 0:S.webEnabled)??!1,mobileWebEnabled:((d=e.gcashDepositGatewaySettings)==null?void 0:d.mobileWebEnabled)??!1,minimumAmount:i((M=e.gcashDepositGatewaySettings)==null?void 0:M.minimumAmount),maximumAmount:i((N=e.gcashDepositGatewaySettings)==null?void 0:N.maximumAmount)},maya:{androidEnabled:((I=e.mayaDepositGatewaySettings)==null?void 0:I.androidEnabled)??!1,iosEnabled:((D=e.mayaDepositGatewaySettings)==null?void 0:D.iosEnabled)??!1,webEnabled:((R=e.mayaDepositGatewaySettings)==null?void 0:R.webEnabled)??!1,mobileWebEnabled:((P=e.mayaDepositGatewaySettings)==null?void 0:P.mobileWebEnabled)??!1,minimumAmount:i((G=e.mayaDepositGatewaySettings)==null?void 0:G.minimumAmount),maximumAmount:i((x=e.mayaDepositGatewaySettings)==null?void 0:x.maximumAmount)},mayaApp:{androidEnabled:(($=e.mayaAppDepositGatewaySettings)==null?void 0:$.androidEnabled)??!1,iosEnabled:((O=e.mayaAppDepositGatewaySettings)==null?void 0:O.iosEnabled)??!1,webEnabled:((W=e.mayaAppDepositGatewaySettings)==null?void 0:W.webEnabled)??!1,mobileWebEnabled:((U=e.mayaAppDepositGatewaySettings)==null?void 0:U.mobileWebEnabled)??!1,minimumAmount:i((B=e.mayaAppDepositGatewaySettings)==null?void 0:B.minimumAmount),maximumAmount:i((q=e.mayaAppDepositGatewaySettings)==null?void 0:q.maximumAmount)}},withdrawalGateway:{bank:{androidEnabled:((F=e.bankWithdrawalGatewaySettings)==null?void 0:F.androidEnabled)??!1,iosEnabled:((L=e.bankWithdrawalGatewaySettings)==null?void 0:L.iosEnabled)??!1,webEnabled:((A=e.bankWithdrawalGatewaySettings)==null?void 0:A.webEnabled)??!1,mobileWebEnabled:((oe=e.bankWithdrawalGatewaySettings)==null?void 0:oe.mobileWebEnabled)??!1,minimumAmount:i((ie=e.bankWithdrawalGatewaySettings)==null?void 0:ie.minimumAmount),maximumAmount:i((se=e.bankWithdrawalGatewaySettings)==null?void 0:se.maximumAmount)},gcash:{androidEnabled:((ce=e.gcashWithdrawalGatewaySettings)==null?void 0:ce.androidEnabled)??!1,iosEnabled:((me=e.gcashWithdrawalGatewaySettings)==null?void 0:me.iosEnabled)??!1,webEnabled:((de=e.gcashWithdrawalGatewaySettings)==null?void 0:de.webEnabled)??!1,mobileWebEnabled:((ue=e.gcashWithdrawalGatewaySettings)==null?void 0:ue.mobileWebEnabled)??!1,minimumAmount:i((le=e.gcashWithdrawalGatewaySettings)==null?void 0:le.minimumAmount),maximumAmount:i((pe=e.gcashWithdrawalGatewaySettings)==null?void 0:pe.maximumAmount,1e6)},maya:{androidEnabled:((fe=e.mayaWithdrawalGatewaySettings)==null?void 0:fe.androidEnabled)??!1,iosEnabled:((he=e.mayaWithdrawalGatewaySettings)==null?void 0:he.iosEnabled)??!1,webEnabled:((we=e.mayaWithdrawalGatewaySettings)==null?void 0:we.webEnabled)??!1,mobileWebEnabled:((ye=e.mayaWithdrawalGatewaySettings)==null?void 0:ye.mobileWebEnabled)??!1,minimumAmount:i((ge=e.mayaWithdrawalGatewaySettings)==null?void 0:ge.minimumAmount),maximumAmount:i((Se=e.mayaWithdrawalGatewaySettings)==null?void 0:Se.maximumAmount)},mayaApp:{androidEnabled:((Ee=e.mayaAppWithdrawalGatewaySettings)==null?void 0:Ee.androidEnabled)??!1,iosEnabled:((be=e.mayaAppWithdrawalGatewaySettings)==null?void 0:be.iosEnabled)??!1,webEnabled:((Ae=e.mayaAppWithdrawalGatewaySettings)==null?void 0:Ae.webEnabled)??!1,mobileWebEnabled:((ke=e.mayaAppWithdrawalGatewaySettings)==null?void 0:ke.mobileWebEnabled)??!1,minimumAmount:i((_e=e.mayaAppWithdrawalGatewaySettings)==null?void 0:_e.minimumAmount),maximumAmount:i((Ce=e.mayaAppWithdrawalGatewaySettings)==null?void 0:Ce.maximumAmount,1e6)}}},pointsClubSettings:{multiplier:i((Te=e.pointsClubSettings)==null?void 0:Te.multiplier,0)}}}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,dateTimeLastActive:e.dateTimeLastActive?new Date(e.dateTimeLastActive):void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)};return E(t)}wallet(e){return{id:e.id,balance:i(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,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:i(e,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:i(e.amount,0),netAmount:i(e.netAmount,0),fee:i(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 E(t)}deposit(e){const t={id:e.id,type:e.type,status:e.status,checkoutUrl:e.checkoutUrl??void 0};return E(t)}depositRecord(e){const t={id:e.id,type:e.type,status:e.status,amount:i(e.amount,0),fee:i(e.fee,0),netAmount:i(e.netAmount,0),reference:e.reference??void 0,depositNumber:e.depositNumber,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)};return E(t)}betRecord(e){var r;const t={id:e.id,bet:i(e.bet,0),payout:i(e.payout,0),status:e.status,jackpotContribution:i(e.jackpotContribution,0),jackpotPayout:i(e.jackpotPayout,0),winloss:i(e.winloss),validBet:i(e.validBet,0),vendorRoundId:e.vendorRoundId??void 0,game:e.game,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 E(t)}latestBetRecord(e){return{id:e.id,member:e.member,game:e.game,bet:i(e.bet,0),payout:i(e.payout,0),validBet:i(e.validBet,0),dateTimeSettled:new Date(e.dateTimeSettled),dateTimeCreated:new Date(e.dateTimeCreated)}}transactionRecord(e){const t={id:e.id,type:e.type,amount:i(e.amount,0),content:e.content??void 0,currentBalance:i(e.currentBalance,0),referenceNumber:e.referenceNumber,dateTimeCreated:new Date(e.dateTimeCreated)};return E(t)}game(e){return{id:e.id,type:e.type,name:e.name,images:this.staticService.gameThumbnails(e),provider:e.provider}}game__next(e){return{id:e.id,type:e.type,tags:e.tags??[],name:e.name,images:this.staticService.gameThumbnails({id:e.externalId,provider:e.provider}),provider:e.provider,externalId:e.externalId}}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 E(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:i(e.maximumBonusAmount),minimumBonusAmount:i(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,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]=i(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:i(e.deposit.fee,0),amount:i(e.deposit.amount,0),netAmount:i(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:i(e.balance,0),amount:i(e.amount,0),expiration:new Date(e.expiration),turnoverRequirement:i(e.turnoverRequirement,0),currentTurnoverRequirementContribution:i(e.currentTurnoverRequirementContribution,0),currentTurnoverRequirementContributionPercentage:i(e.currentTurnoverRequirementContributionPercentage,0),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)};return E(t)}cashbackBonus(e){return{id:e.id,balance:i(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 E(t)}pointsWallet(e){return{id:e.id,points:i(e.points,0),account:e.account,dateTimeCreated:new Date(e.dateTimeCreated)}}pointsWalletTransaction(e){return{id:e.id,type:e.type,amount:i(e.amount,0),balance:i(e.balance,0),dateTimeCreated:new Date(e.dateTimeCreated)}}activityRecord(e){const t={id:e.id,type:e.type,amount:e.amount?i(e.amount,0):void 0,domain:e.domain??void 0,details:e.details,dateTimeCreated:new Date(e.dateTimeCreated)};return E(t)}}class Pt{constructor(e){m(this,"cmsPortalService");m(this,"gameService");m(this,"fileService");m(this,"walletService");m(this,"accountService");m(this,"reportService");m(this,"portalService");m(this,"sessionManager");m(this,"transformer");m(this,"logger");const t=e.environment==="production";this.transformer=new Rt(e),this.logger=new te({enabled:e.logs??!1});const r=t?"https://auth.opexa.io":"https://auth.development.opexa.io",a=t?"https://wallet.opexa.io/graphql":"https://wallet.development.opexa.io/graphql",s=t?"https://report.opexa.io/graphql":"https://report.development.opexa.io/graphql",c=t?"https://account.opexa.io/graphql":"https://account.development.opexa.io/graphql",f=t?"https://portal.opexa.io/graphql":"https://portal.development.opexa.io/graphql",p=t?"https://file.opexa.io/graphql":"https://file.development.opexa.io/graphql",h=t?"https://game.opexa.io/graphql":"https://game.development.opexa.io/graphql",S=t?"https://portal-api.opexacms.io/v1":"https://portal-api.development.opexacms.io/v1";this.cmsPortalService=new At({url:S,site:e.site,platform:e.sitePlatform}),this.sessionManager=new Dt({authUrl:r,walletUrl:a,platform:e.platform,logs:e.logs});const d={middlewares:[this.authMiddleware],fetchOptions:{headers:{Role:"MEMBER","Platform-Code":e.platform}}};this.gameService=new _t(new k(h,d)),this.fileService=new kt(new k(p,d)),this.walletService=new ee(new k(a,d)),this.accountService=new Et(new k(c,d)),this.reportService=new Tt(new k(s,d)),this.portalService=new Ct(new k(f,d))}get authMiddleware(){return async e=>{this.logger.info("Checking for session");const t=await this.sessionManager.get();return t.data?(e.headers.append("Authorization",`Bearer ${t.data.accessToken}`),this.logger.info("Session found"),this.logger.success("Added 'Authorization' header")):this.logger.info("No session found"),e}}async signIn(e){switch(e.type){case"NAME_AND_PASSWORD":{const t=await this.sessionManager.create({...e,password:await b(e.password)});return t.ok?t.data?{ok:!0,data:{"2FAEnabled":!0,authenticator:t.data.authenticator}}:{ok:!0,data:{"2FAEnabled":!1}}: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 b(e.secretAnswer)});default:return{ok:!1,error:{name:"HttpBadRequest",message:"Invalid input 'type'"}}}}async signOut(){await this.sessionManager.destroy()}watchSession(e){const t=Mt(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 account(){const[e,t]=await Promise.all([this.accountService.memberAccount(),this.reportService.member()]);return e.ok?t.ok?{ok:!0,data:this.transformer.transform.account({...e.data,...t.data})}:{ok:!1,error:t.error}:{ok:!1,error:e.error}}async createAccount(e){const t=e.id??l.ObjectId.generate(g.Account).toString(),r=await this.accountService.registerMemberAccount({input:{id:t,name:e.name,birthDay:typeof e.dateOfBirth=="string"?e.dateOfBirth:e.dateOfBirth.toISOString(),password:await b(e.password),mobileNumber:_(e.mobileNumber),domain:e.domain,btag:e.referralCode},verificationCode:e.verificationCode,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 b(e.password),domain:e.domain}})}async updateAccount(e,t){return await this.accountService.updateMemberAccount({input:{id:e,data:{...t,password:t.password?await b(t.password):void 0,transactionPassword:t.transactionPassword?await b(t.transactionPassword):void 0,...t.mobileNumber&&{mobileNumber:_(t.mobileNumber)},secretAnswer:t.secretAnswer?await b(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??l.ObjectId.generate(g.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:_(e.mobileNumber),newPassword:await b(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:_(e)}})}async wallet(){const e=await this.walletService.wallet();return e.ok?{ok:!0,data:e.data?this.transformer.transform.wallet(e.data):null}:e}async announcements(e){const t=await this.accountService.announcements({...e,filter:{visibility:{in:["MEMBER","GLOBAL"]},activationStartDateTime:{greaterThanOrEqual:new Date}}});return t.ok?{ok:!0,data:{announcements:t.data.edges.map(({cursor: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??l.ObjectId.generate(g.Withdrawal).toString();if(e.type==="BANK"){const r=await this.walletService.createBankWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await b(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 b(e.transactionPassword),recipientMobileNumber:_(e.recipientMobileNumber)}});if(!r.ok)return r}if(e.type==="MAYA"){const r=await this.walletService.createMayaWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await b(e.transactionPassword),recipientMobileNumber:_(e.recipientMobileNumber)}});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 b(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??l.ObjectId.generate(g.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){var r,a;const t=await this.reportService.betRecords({...e,...(e==null?void 0:e.filter)&&{filter:{...e.filter,...((r=e.filter)==null?void 0:r.gameType)&&{game__type:e.filter.gameType},...((a=e.filter)==null?void 0:a.gameProvider)&&{game__provider:e.filter.gameProvider}}}});return t.ok?{ok:!0,data:{betRecords:t.data.edges.map(({cursor:s,node:c})=>({...this.transformer.transform.betRecord(c),cursor:s})),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){return this.game__next(e)}async game__next(e){const t=await this.cmsPortalService.game(e);return t.ok?{ok:!0,data:t.data?this.transformer.transform.game__next(t.data):null}:t}async games(e){const t=await this.walletService.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 games__next(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__next(a),cursor:r})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}async games__legacy(e){const t=await this.gameService.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 gamesByName(e){const t=await this.walletService.gamesByName(e);return t.ok?{ok:!0,data:t.data.map(this.transformer.transform.game)}:t}async gamesByName__legacy(e){const t=await this.gameService.gamesByName(e);return t.ok?{ok:!0,data:t.data.map(this.transformer.transform.game)}:t}async gameSession(e){const t=await this.walletService.gameSession({id:e});return t.ok?{ok:!0,data:t.data?this.transformer.transform.gameSession(t.data):null}:t}async gameSession__legacy(e){const t=await this.gameService.gameSession({id:e});return t.ok?{ok:!0,data:t.data?this.transformer.transform.gameSession(t.data):null}:t}async gameSession__next(e){const t=await this.walletService.gameSession({id:e});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??l.ObjectId.generate(g.GameSession).toString(),r=await this.walletService.createGameSession({input:{id:t,game:e.game}});return r.ok?{ok:!0,data:{id:t}}:r}async createGameSession__legacy(e){const t=e.id??l.ObjectId.generate(g.GameSession).toString(),r=await this.gameService.createGameSession({input:{id:t,game:e.game}});return r.ok?{ok:!0,data:{id:t}}:r}async createGameSession__next(e){const t=e.id??l.ObjectId.generate(g.GameSession).toString();if(e.game.startsWith("SPORTS:")){const f=await l.ObjectId.generateFromKey(g.Game,e.game).then(h=>h.toString()),p=await this.gameService.createGameSession({input:{id:t,game:f}});return p.ok?{ok:!0,data:{id:t}}:p}const r=await this.game__next(e.game);if(!r.data)return{ok:!1,error:{name:"GameDoesNotExistError",message:"Game does not exist"}};const{provider:a,externalId:s}=r.data,c=xt(a)?await this.walletService.createGameSession({input:{id:t,game:s}}):await this.gameService.createGameSession({input:{id:t,game:s}});return c.ok?{ok:!0,data:{id:t}}:c}async endGameSession(e){return await this.walletService.endGameSession({input:{id:e}})}async endGameSession__legacy(e){return await this.gameService.endGameSession({input:{id:e}})}async endGameSession__next(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??l.ObjectId.generate(g.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 pointsToCashConversion(e){return await this.walletService.pointsToCashConversion({input:{amount:e.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}}const Gt=["RTG","DARWIN","DRBINGO","MEGABALL","EVOLUTION","EVOLUTION_NETENT","EVOLUTION_REDTIGER"];function xt(n){return Gt.some(e=>e===n)}Object.defineProperty(y,"ObjectId",{enumerable:!0,get:()=>l.ObjectId}),y.ObjectType=g,y.Sdk=Pt,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
1038
+ `;function d(n){return{name:n,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",AccountBlacklisted:"Account is blacklisted",AccountNotFound:"Account not found",InvalidToken:"Invalid token",InvalidTokenOrSecretAnswer:"Invalid token or secret answer",SessionExpired:"Session expired"}[n]}}class bt{constructor(e){m(this,"client");this.client=e}async memberAccount(){const e=await this.client.request(it);return e.ok?{ok:!0,data:e.data.memberAccount}:e}async registerMemberAccount(e){const t=await this.client.request(ct,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(dt,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(lt,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(ut,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(yt);return e.ok?{ok:!0,data:e.data.profileCompletion}:e}async platform(){return await this.client.request(gt)}async sendVerificationCode(e){const t=await this.client.request(wt,e);return t.ok?t.data.sendVerificationCode?{ok:!1,error:d(t.data.sendVerificationCode.__typename)}:{ok:!0}:t}async verifyMobileNumber(e){const t=await this.client.request(pt,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(ft,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(ht,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(st);return e.ok?{ok:!0,data:e.data.memberAccount.verification}:e}async announcements(e){const t=await this.client.request(Ge,e);return t.ok?{ok:!0,data:t.data.announcements}:t}async registerMayaMemberAccount(e){const t=await this.client.request(mt,e);return t.ok?t.data.registerMayaMemberAccount?{ok:!1,error:d(t.data.registerMayaMemberAccount.__typename)}:{ok:!0}:t}}function y(n,e){const t=j[n]?j[n]:j[500];return{name:t.name,message:e??t.message}}const j={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 kt{constructor(e){m(this,"url");m(this,"platform");this.url=e.url,this.platform=e.platform}async createSession(e){const t=new Headers({"Content-Type":"application/json","Platform-Code":this.platform,Role:"MEMBER"});if(e.name){const a=`${e.name}:${e.password}`,r=Buffer.from(a).toString("base64");t.set("Authorization",`Basic ${r}`)}if(e.mobileNumber){const a=`${e.mobileNumber}:${e.verificationCode}`,r=Buffer.from(a).toString("base64");t.set("Authorization",`MobileNumberOTP ${r}`)}e.sessionId&&t.set("Authorization",`Maya ${e.sessionId}`);try{const a=await fetch(`${this.url}/sessions`,{method:"POST",headers:t}),r=await a.json();return a.ok?{ok:!0,data:r}:r.code==="ACCOUNT_BLACKLISTED"?{ok:!1,error:d("AccountBlacklisted")}:{ok:!1,error:y(a.status)}}catch{return{ok:!1,error:y(500)}}}async authenticate(e){const t=new Headers({"Content-Type":"application/json","Platform-Code":this.platform,Role:"MEMBER"});if(e.type==="SECURITY_QUESTION"){t.set("Authorization",`Bearer ${e.token}`);try{const a=await fetch(`${this.url}/session/${e.token}/authenticate`,{method:"POST",headers:t,body:JSON.stringify({secretAnswer:e.secretAnswer})}),r=await a.json();return a.ok?{ok:!0,data:r}:a.status===401||a.status===403?{ok:!1,error:d("InvalidTokenOrSecretAnswer")}:{ok:!1,error:y(a.status)}}catch{return{ok:!1,error:y(500)}}}throw new Error("Invalid input 'type'")}async refreshSession(e){try{const t=await fetch(`${this.url}/session:refresh`,{method:"POST",headers:{"Content-Type":"application/json","Platform-Code":this.platform,Role:"MEMBER",Authorization:`Bearer ${e}`}}),a=await t.json();return t.ok?{ok:!0,data:a}:a.code==="ACCOUNT_BLACKLISTED"?{ok:!1,error:d("AccountBlacklisted")}:t.status===403||t.status===401?{ok:!1,error:d("InvalidToken")}:{ok:!1,error:y(t.status)}}catch{return{ok:!1,error:y(500)}}}async destroySession(e){try{const t=await fetch(`${this.url}/session`,{method:"DELETE",headers:{"Content-Type":"application/json","Platform-Code":this.platform,Role:"MEMBER",Authorization:`Bearer ${e}`}});return t.ok?{ok:!0}:{ok:!1,error:y(t.status)}}catch{return{ok:!1,error:y(500)}}}async verifySession(e){try{return(await fetch(`${this.url}/session`,{method:"GET",headers:{"Content-Type":"application/json","Platform-Code":this.platform,Role:"MEMBER",Authorization:`Bearer ${e}`}})).ok}catch{return!0}}}class _t{constructor(e){m(this,"url");m(this,"siteId");m(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 r,s,c,f,p,h,E,u,M,N,I,D,R,P,x,G,W,$,O,U,B,q,F,L;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=(r=e==null?void 0:e.filter)==null?void 0:r.type)!=null&&s.equal&&t.set("filter[type][eq]",e.filter.type.equal),(f=(c=e==null?void 0:e.filter)==null?void 0:c.type)!=null&&f.notEqual&&t.set("filter[type][neq]",e.filter.type.notEqual),(h=(p=e==null?void 0:e.filter)==null?void 0:p.type)!=null&&h.in&&t.set("filter[type][in]",e.filter.type.in.join(",")),(u=(E=e==null?void 0:e.filter)==null?void 0:E.type)!=null&&u.notIn&&t.set("filter[type][nin]",e.filter.type.notIn.join(",")),(N=(M=e==null?void 0:e.filter)==null?void 0:M.provider)!=null&&N.equal&&t.set("filter[provider][eq]",e.filter.provider.equal),(D=(I=e==null?void 0:e.filter)==null?void 0:I.provider)!=null&&D.notEqual&&t.set("filter[provider][neq]",e.filter.provider.notEqual),(P=(R=e==null?void 0:e.filter)==null?void 0:R.provider)!=null&&P.in&&t.set("filter[provider][in]",e.filter.provider.in.join(",")),(G=(x=e==null?void 0:e.filter)==null?void 0:x.provider)!=null&&G.notIn&&t.set("filter[provider][nin]",e.filter.provider.notIn.join(",")),($=(W=e==null?void 0:e.filter)==null?void 0:W.tags)!=null&&$.equal&&t.set("filter[tags][eq]",e.filter.tags.equal.toLowerCase()),(U=(O=e==null?void 0:e.filter)==null?void 0:O.tags)!=null&&U.notEqual&&t.set("filter[tags][neq]",e.filter.tags.notEqual.toLowerCase()),(q=(B=e==null?void 0:e.filter)==null?void 0:B.tags)!=null&&q.in&&t.set("filter[tags][in]",e.filter.tags.in.map(b=>b.toLowerCase()).join(",")),(L=(F=e==null?void 0:e.filter)==null?void 0:F.tags)!=null&&L.notIn&&t.set("filter[tags][nin]",e.filter.tags.notIn.map(b=>b.toLowerCase()).join(","));const a=await this.getJson("/games",t);return a.ok?{ok:!0,data:{edges:a.data.data.map(b=>({node:b,cursor:b.cursor})),totalCount:a.data.totalCount??0,pageInfo:{hasNextPage:!!a.data.next,endCursor:a.data.next}}}:a}async game(e){var a;const t=await this.getJson(`/games/${e}`);return((a=t.error)==null?void 0:a.name)==="HttpNotFound"?{ok:!0,data:null}:t.ok?{ok:!0,data:t.data.data}:t}async getJson(e,t){const a=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 r=await fetch(a);return r.ok?{ok:!0,data:await r.json()}:{ok:!1,error:y(r.status)}}catch{return{ok:!1,error:y(500)}}}}class Tt{constructor(e){m(this,"client");this.client=e}async file(e){const t=await this.client.request(ve,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 Ct{constructor(e){m(this,"client");this.client=e}async games(e){const t=await this.client.request(K,e);return t.ok?{ok:t.ok,data:t.data.games}:t}async gamesByName(e){const t=await this.client.request(z,e);return t.ok?{ok:t.ok,data:t.data.gamesByName}:t}async gameSession(e){const t=await this.client.request(J,e);return t.ok?{ok:!0,data:t.data.node}:t}async createGameSession(e){const t=await this.client.request(X,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(xe,e);return t.ok?t.data.endGameSession?{ok:!1,error:d(t.data.endGameSession.__typename)}:{ok:!0}:t}}class vt{constructor(e){m(this,"client");this.client=e}async latestBetRecords(){const e=await this.client.request(Je);return e.ok?{ok:!0,data:e.data.latestBetRecords}:e}}class Mt{constructor(e){m(this,"client");this.client=e}async betRecords(e){const t=await this.client.request(ze,e);return t.ok?{ok:t.ok,data:t.data.member.betRecords}:t}async transactionRecords(e){const t=await this.client.request(Xe,e);return t.ok?{ok:t.ok,data:t.data.member.transactionRecords}:t}async withdrawalRecords(e){const t=await this.client.request(We,e);return t.ok?{ok:t.ok,data:t.data.member.withdrawalRecords}:t}async depositRecords(e){const t=await this.client.request(Le,e);return t.ok?{ok:t.ok,data:t.data.member.depositRecords}:t}async depositsCount(){const e=await this.client.request(Ke);return e.ok?{ok:e.ok,data:e.data.member.depositsCount}:e}async member(){const e=await this.client.request(ot);return e.ok?{ok:e.ok,data:e.data.member}:e}async pointsWalletTransactions(e){const t=await this.client.request(Re,e);return t.ok?{ok:t.ok,data:t.data.member.pointsWalletTransactions}:t}async activityRecords(e){const t=await this.client.request(St,e);return t.ok?{ok:t.ok,data:t.data.member.activityRecords}:t}}class Nt{constructor(e){m(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 ee{constructor(e){m(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(tt);return e.ok?{ok:e.ok,data:e.data.cashbacks}:e}async availablePromos(e){const t=await this.client.request(et,e);return t.ok?{ok:t.ok,data:t.data.availablePromos}:t}async cashbackBonuses(){const e=await this.client.request(rt);return e.ok?{ok:e.ok,data:e.data.cashbackBonuses}:e}async claimCashbackBonus(e){const t=await this.client.request(nt,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(at);return e.ok?{ok:e.ok,data:e.data.bonus}:e}async wallet(){const e=await this.client.request(Ne);return e.ok?{ok:e.ok,data:e.data.wallet}:e}async deposit(e){const t=await this.client.request(Qe,e);return t.ok?{ok:t.ok,data:t.data.node}:t}async createGCashDeposit(e){const t=await this.client.request(Ve,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(Ye,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(je,e);return t.ok?t.data.createMayaAppDeposit?{ok:!1,error:d(t.data.createMayaAppDeposit.__typename)}:{ok:!0}:t}async createMayaAppDeposit__next(e){const t=await this.client.request(He,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($e,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(Oe,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(Ue,e);return t.ok?t.data.createMayaAppWithdrawal?{ok:!1,error:d(t.data.createMayaAppWithdrawal.__typename)}:{ok:!0}:t}async createMayaAppWithdrawal__next(e){const t=await this.client.request(Be,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(qe,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(Fe);return e.ok?{ok:e.ok,data:e.data.remainingDailyWithdrawalsCount}:e}async pointsWallet(){const e=await this.client.request(Ie);return e.ok?{ok:e.ok,data:e.data.pointsWallet}:e}async pointsToCashConversion(e){const t=await this.client.request(De,e);return t.ok?t.data.pointsToCashConversion?{ok:!1,error:d(t.data.pointsToCashConversion.__typename)}:{ok:!0}:t}async mayaSession(e){const t=await this.client.request(Et,e);return t.ok?{ok:t.ok,data:t.data.mayaSession}:t}async games(e){const t=await this.client.request(K,e);return t.ok?{ok:t.ok,data:t.data.games}:t}async gamesByName(e){const t=await this.client.request(z,e);return t.ok?{ok:t.ok,data:t.data.gamesByName}:t}async gameSession(e){const t=await this.client.request(J,e);return t.ok?{ok:!0,data:t.data.node}:t}async createGameSession(e){const t=await this.client.request(X,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(Pe,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(At);return e.ok?e.data.validateMayaSession?{ok:!0}:{ok:!1,error:{name:"UnknownError",message:"Something went wrong."}}:e}}function It(n,e,t){return n<e?e:n>t?t:n}function H(n){return Object.prototype.toString.call(n)==="[object Object]"&&Object(n)===n}function Dt(n){const e=[];function t(a,r=[]){for(const s in a){const c=a[s];H(c)?t(c,[...r,s]):Array.isArray(c)?t(Rt(c),[...r,s]):e.push({key:[...r,s],value:c})}}return t(n),e}function Rt(n){return n.reduce((e,t,a)=>(e[a]=t,e),{})}class k{constructor(e,t){m(this,"url");m(this,"options");m(this,"middlewares");var r;const a=new Headers((r=t==null?void 0:t.fetchOptions)==null?void 0:r.headers);this.url=e,this.options={...t==null?void 0:t.fetchOptions,headers:a},this.middlewares=(t==null?void 0:t.middlewares)??[]}async request(e,t){const a=JSON.stringify({query:e,variables:t}),r=new Headers(this.options.headers);r.set("Content-Type","application/json"),r.set("Accept","application/json");const s=await this.runMiddlewares(new Request(this.url,{...this.options,body:a,headers:r,method:"POST"}));return await this.exec(s)}async upload(e,t){const a=this.createUploadBody(e,t),r=new Headers(this.options.headers);r.delete("Content-Type");const s=await this.runMiddlewares(new Request(this.url,{...this.options,body:a,headers:r,method:"POST"}));return await this.exec(s)}async exec(e){var t,a,r,s,c,f;try{const p=await fetch(e);if(!p.ok)return{ok:!1,error:y(p.status)};const h=await p.json(),E=h.data,u=(t=h.errors)==null?void 0:t.at(0);return u?((a=u.extensions)==null?void 0:a.code)==="FORBIDDEN"||((r=u.extensions)==null?void 0:r.code)==="ACCESS_TOKEN_EXPIRED"?{ok:!1,error:y(403,u.message)}:((s=u.extensions)==null?void 0:s.code)==="UNAUTHORIZED"?{ok:!1,error:y(401,u.message)}:((c=u.extensions)==null?void 0:c.code)==="BAD_USER_INPUT"||((f=u.extensions)==null?void 0:f.code)==="BAD_REQUEST"?{ok:!1,error:y(400,u.message)}:{ok:!1,error:y(500,u.message)}:{ok:!0,data:E}}catch{return{ok:!1,error:y(500)}}}async runMiddlewares(e){let t=e.clone();for(const a of this.middlewares)t=await a(t);return t}createUploadBody(e,t){const a=Dt(t).filter(c=>c.value instanceof File||c.value instanceof Blob),r=new FormData;r.append("operations",JSON.stringify({query:e,variables:t}));const s={};return a.forEach((c,f)=>{s[f.toString()]=[`variables.${c.key.join(".")}`]}),r.append("map",JSON.stringify(s)),a.forEach((c,f)=>{r.append(f.toString(),c.value)}),r}}function _(n){return n.startsWith("+63")?n:n.startsWith("63")?`+${n}`:n.startsWith("0")?`+63${n.substring(1)}`:`+63${n}`}async function A(n){const e=new TextEncoder().encode(n),t=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(t)).map(s=>s.toString(16).padStart(2,"0")).join("")}class te{constructor(e){m(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 Q(n){return new Date(n.getTime())}function T(n,e){const t=Q(n);return t.setDate(t.getDate()+e),t}function C(n,e){const t=Q(n);return t.setMinutes(t.getMinutes()+e),t}function ae(n,e){return n.getTime()>e.getTime()}function re(n){return new Promise(e=>{setTimeout(e,n)})}function ne(n,e){const{until:t,interval:a=1e3,maxAttempt:r=3}=e;async function s(c,f){const p=f??r,h=await n(...c);return t(h)?h:p>1?(await re(a*((r-p)/2)),s(c,p-1)):h}return async(...c)=>await s(c)}function v(n,e){const t=Q(n);return t.setMinutes(t.getMinutes()-e),t}class Pt{constructor(e){m(this,"logger");m(this,"storageKey","session");m(this,"authService");m(this,"walletService");m(this,"_refreshing",!1);this.authService=new kt({url:e.authUrl,platform:e.platform}),this.walletService=new ee(new k(e.walletUrl,{middlewares:[t=>(t.headers.set("Platform",e.platform),t.headers.set("Role","MEMBER"),t)]})),this.logger=new te({enabled:e.logs??!1})}get refreshing(){return this._refreshing}set refreshing(e){this._refreshing=e}async create(e){var r;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 c=await ne(()=>this.walletService.mayaSession({id:e.sessionId}),{until:E=>{var u;return E.ok&&((u=E.data)==null?void 0:u.member)!=null},interval:1e3,maxAttempt:5})();if(!c.ok)return c;if(!((r=c.data)!=null&&r.member))return{ok:!1,error:{name:"HttpForbidden",message:"Forbidden"}};const p=await ne(()=>this.authService.createSession(e),{until:E=>E.ok,interval:1e3,maxAttempt:5})();if(!p.ok)return p;const h=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...p.data,accessTokenExpiresAt:C(h,8).getTime(),refreshTokenExpiresAt:v(T(h,30),2).getTime()})),{ok:!0,data:null}}if(e.type==="MOBILE_NUMBER"){const s=await this.authService.createSession(e);if(s.ok){const c=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...s.data,accessTokenExpiresAt:C(c,8).getTime(),refreshTokenExpiresAt:v(T(c,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 a=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...t.data,accessTokenExpiresAt:C(a,8).getTime(),refreshTokenExpiresAt:v(T(a,30),2).getTime()})),{ok:!0,data:null}}async createFromAuthenticator(e){const t=await this.authService.authenticate(e);if(t.ok){const a=new Date;return this.isServer?this.logger.warn("'localStorage' is not available on the server."):window.localStorage.setItem(this.storageKey,JSON.stringify({...t.data,accessTokenExpiresAt:C(a,8).getTime(),refreshTokenExpiresAt:v(T(a,30),2).getTime()})),{ok:!0}}else return t}async get(){if(this.isServer)return this.logger.warn("'localStorage' is not available on the server."),{ok:!0,data:null};if(this.refreshing)return await re(1e3),await this.get();const e=window.localStorage.getItem(this.storageKey);if(!e)return{ok:!0,data:null};try{let t=JSON.parse(e),a=new Date;const r=new Date(t.accessTokenExpiresAt),s=new Date(t.refreshTokenExpiresAt);if(ae(a,s))return this.logger.warn("Session expired. Logging out.."),window.localStorage.removeItem(this.storageKey),{ok:!1,error:{name:"SessionExpired",message:"Session expired."}};if(ae(a,r)){this.logger.info("Refreshing session..."),this.refreshing=!0;const c=await this.authService.refreshSession(t.refreshToken);if(this.refreshing=!1,!c.ok)return this.logger.error(`Failed to refresh session: ${c.error.message}`),c.error.name==="InvalidToken"||c.error.name==="AccountBlacklisted"?(window.localStorage.removeItem(this.storageKey),{ok:!1,error:c.error}):(this.logger.warn("Old session returned."),{ok:!0,data:t});this.logger.success("Session refreshed!"),a=new Date,t={...t,...c.data,accessTokenExpiresAt:C(a,8).getTime(),refreshTokenExpiresAt:v(T(a,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 a,r,s;if(this.isServer)return this.logger.warn("'localStorage' is not available on the server."),!0;const e=await this.get();if(((a=e.error)==null?void 0:a.name)==="InvalidToken"||((r=e.error)==null?void 0:r.name)==="SessionExpired"||((s=e.error)==null?void 0:s.name)==="AccountBlacklisted")return!1;if(!e.data)return!0;const t=await this.authService.verifySession(e.data.accessToken);return t||window.localStorage.removeItem(this.storageKey),t}get isServer(){return typeof window>"u"}}function S(n){const e={};for(const t in n){const a=n[t];if(a!==null&&a!==void 0){if(H(a)){e[t]=S(a);continue}if(Array.isArray(a)){e[t]=a.map(r=>H(r)?S(r):r);continue}e[t]=a}}return e}function i(n,e){if(typeof n=="number"&&!Number.isNaN(n))return n;if(typeof n=="string"){const t=Number.parseFloat(n);if(!Number.isNaN(t))return t}return e}class xt{constructor(e){m(this,"staticService");const t=(e==null?void 0:e.environment)==="development";this.staticService=new Nt({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),game__next:this.game__next.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)}}site(e){const t={id:e.id,name:e.name,logo:e.logo??void 0};return S(t)}platform(e){var t,a,r,s,c,f,p,h,E,u,M,N,I,D,R,P,x,G,W,$,O,U,B,q,F,L,b,oe,ie,se,ce,me,de,ue,le,pe,fe,he,ye,we,ge,Ee,Ae,Se,be,ke,_e,Te,Ce;return{paymentSettings:{minimumFirstDepositAmount:i(e.minimumFirstDepositAmount),restrictWithdrawalsToVerifiedMembers:e.restrictWithdrawalsToVerifiedMembers,depositGateway:{bank:{androidEnabled:((t=e.bankDepositGatewaySettings)==null?void 0:t.androidEnabled)??!1,iosEnabled:((a=e.bankDepositGatewaySettings)==null?void 0:a.iosEnabled)??!1,webEnabled:((r=e.bankDepositGatewaySettings)==null?void 0:r.webEnabled)??!1,mobileWebEnabled:((s=e.bankDepositGatewaySettings)==null?void 0:s.mobileWebEnabled)??!1,minimumAmount:i((c=e.bankDepositGatewaySettings)==null?void 0:c.minimumAmount),maximumAmount:i((f=e.bankDepositGatewaySettings)==null?void 0:f.maximumAmount)},gcash:{androidEnabled:((p=e.gcashDepositGatewaySettings)==null?void 0:p.androidEnabled)??!1,iosEnabled:((h=e.gcashDepositGatewaySettings)==null?void 0:h.iosEnabled)??!1,webEnabled:((E=e.gcashDepositGatewaySettings)==null?void 0:E.webEnabled)??!1,mobileWebEnabled:((u=e.gcashDepositGatewaySettings)==null?void 0:u.mobileWebEnabled)??!1,minimumAmount:i((M=e.gcashDepositGatewaySettings)==null?void 0:M.minimumAmount),maximumAmount:i((N=e.gcashDepositGatewaySettings)==null?void 0:N.maximumAmount)},maya:{androidEnabled:((I=e.mayaDepositGatewaySettings)==null?void 0:I.androidEnabled)??!1,iosEnabled:((D=e.mayaDepositGatewaySettings)==null?void 0:D.iosEnabled)??!1,webEnabled:((R=e.mayaDepositGatewaySettings)==null?void 0:R.webEnabled)??!1,mobileWebEnabled:((P=e.mayaDepositGatewaySettings)==null?void 0:P.mobileWebEnabled)??!1,minimumAmount:i((x=e.mayaDepositGatewaySettings)==null?void 0:x.minimumAmount),maximumAmount:i((G=e.mayaDepositGatewaySettings)==null?void 0:G.maximumAmount)},mayaApp:{androidEnabled:((W=e.mayaAppDepositGatewaySettings)==null?void 0:W.androidEnabled)??!1,iosEnabled:(($=e.mayaAppDepositGatewaySettings)==null?void 0:$.iosEnabled)??!1,webEnabled:((O=e.mayaAppDepositGatewaySettings)==null?void 0:O.webEnabled)??!1,mobileWebEnabled:((U=e.mayaAppDepositGatewaySettings)==null?void 0:U.mobileWebEnabled)??!1,minimumAmount:i((B=e.mayaAppDepositGatewaySettings)==null?void 0:B.minimumAmount),maximumAmount:i((q=e.mayaAppDepositGatewaySettings)==null?void 0:q.maximumAmount)}},withdrawalGateway:{bank:{androidEnabled:((F=e.bankWithdrawalGatewaySettings)==null?void 0:F.androidEnabled)??!1,iosEnabled:((L=e.bankWithdrawalGatewaySettings)==null?void 0:L.iosEnabled)??!1,webEnabled:((b=e.bankWithdrawalGatewaySettings)==null?void 0:b.webEnabled)??!1,mobileWebEnabled:((oe=e.bankWithdrawalGatewaySettings)==null?void 0:oe.mobileWebEnabled)??!1,minimumAmount:i((ie=e.bankWithdrawalGatewaySettings)==null?void 0:ie.minimumAmount),maximumAmount:i((se=e.bankWithdrawalGatewaySettings)==null?void 0:se.maximumAmount)},gcash:{androidEnabled:((ce=e.gcashWithdrawalGatewaySettings)==null?void 0:ce.androidEnabled)??!1,iosEnabled:((me=e.gcashWithdrawalGatewaySettings)==null?void 0:me.iosEnabled)??!1,webEnabled:((de=e.gcashWithdrawalGatewaySettings)==null?void 0:de.webEnabled)??!1,mobileWebEnabled:((ue=e.gcashWithdrawalGatewaySettings)==null?void 0:ue.mobileWebEnabled)??!1,minimumAmount:i((le=e.gcashWithdrawalGatewaySettings)==null?void 0:le.minimumAmount),maximumAmount:i((pe=e.gcashWithdrawalGatewaySettings)==null?void 0:pe.maximumAmount,1e6)},maya:{androidEnabled:((fe=e.mayaWithdrawalGatewaySettings)==null?void 0:fe.androidEnabled)??!1,iosEnabled:((he=e.mayaWithdrawalGatewaySettings)==null?void 0:he.iosEnabled)??!1,webEnabled:((ye=e.mayaWithdrawalGatewaySettings)==null?void 0:ye.webEnabled)??!1,mobileWebEnabled:((we=e.mayaWithdrawalGatewaySettings)==null?void 0:we.mobileWebEnabled)??!1,minimumAmount:i((ge=e.mayaWithdrawalGatewaySettings)==null?void 0:ge.minimumAmount),maximumAmount:i((Ee=e.mayaWithdrawalGatewaySettings)==null?void 0:Ee.maximumAmount)},mayaApp:{androidEnabled:((Ae=e.mayaAppWithdrawalGatewaySettings)==null?void 0:Ae.androidEnabled)??!1,iosEnabled:((Se=e.mayaAppWithdrawalGatewaySettings)==null?void 0:Se.iosEnabled)??!1,webEnabled:((be=e.mayaAppWithdrawalGatewaySettings)==null?void 0:be.webEnabled)??!1,mobileWebEnabled:((ke=e.mayaAppWithdrawalGatewaySettings)==null?void 0:ke.mobileWebEnabled)??!1,minimumAmount:i((_e=e.mayaAppWithdrawalGatewaySettings)==null?void 0:_e.minimumAmount),maximumAmount:i((Te=e.mayaAppWithdrawalGatewaySettings)==null?void 0:Te.maximumAmount,1e6)}}},pointsClubSettings:{multiplier:i((Ce=e.pointsClubSettings)==null?void 0:Ce.multiplier,0)}}}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,dateTimeLastActive:e.dateTimeLastActive?new Date(e.dateTimeLastActive):void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)};return S(t)}wallet(e){return{id:e.id,balance:i(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,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:i(e,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:i(e.amount,0),netAmount:i(e.netAmount,0),fee:i(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:i(e.amount,0),fee:i(e.fee,0),netAmount:i(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 a;const t={id:e.id,bet:i(e.bet,0),payout:i(e.payout,0),status:e.status,jackpotContribution:i(e.jackpotContribution,0),jackpotPayout:i(e.jackpotPayout,0),winloss:i(e.winloss),validBet:i(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:((a=e.metadata)==null?void 0:a.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:i(e.bet,0),payout:i(e.payout,0),validBet:i(e.validBet,0),dateTimeSettled:new Date(e.dateTimeSettled),dateTimeCreated:new Date(e.dateTimeCreated)}}transactionRecord(e){const t={id:e.id,type:e.type,amount:i(e.amount,0),content:e.content??void 0,currentBalance:i(e.currentBalance,0),referenceNumber:e.referenceNumber,dateTimeCreated:new Date(e.dateTimeCreated)};return S(t)}game(e){return{id:e.id,type:e.type,name:e.name,images:this.staticService.gameThumbnails(e),provider:e.provider}}game__next(e){return{id:e.id,type:e.type,tags:e.tags??[],name:e.name,images:this.staticService.gameThumbnails({id:e.externalId,provider:e.provider}),provider:e.provider,externalId:e.externalId}}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:i(e.maximumBonusAmount),minimumBonusAmount:i(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,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((a,[r,s])=>(a[r]=i(s,0),a),{})}}bonus(e){const t={id:e.id,promo:this.promo(e.promo),deposit:e.deposit?{type:e.deposit.type,status:e.deposit.status,fee:i(e.deposit.fee,0),amount:i(e.deposit.amount,0),netAmount:i(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:i(e.balance,0),amount:i(e.amount,0),expiration:new Date(e.expiration),turnoverRequirement:i(e.turnoverRequirement,0),currentTurnoverRequirementContribution:i(e.currentTurnoverRequirementContribution,0),currentTurnoverRequirementContributionPercentage:i(e.currentTurnoverRequirementContributionPercentage,0),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)};return S(t)}cashbackBonus(e){return{id:e.id,balance:i(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:i(e.points,0),account:e.account,dateTimeCreated:new Date(e.dateTimeCreated)}}pointsWalletTransaction(e){return{id:e.id,type:e.type,amount:i(e.amount,0),balance:i(e.balance,0),dateTimeCreated:new Date(e.dateTimeCreated)}}activityRecord(e){const t={id:e.id,type:e.type,amount:e.amount?i(e.amount,0):void 0,domain:e.domain??void 0,details:e.details,dateTimeCreated:new Date(e.dateTimeCreated)};return S(t)}}class Gt{constructor(e){m(this,"cmsPortalService");m(this,"gameService");m(this,"fileService");m(this,"walletService");m(this,"accountService");m(this,"reportService");m(this,"portalService");m(this,"sessionManager");m(this,"transformer");m(this,"logger");const t=e.environment==="production";this.transformer=new xt(e),this.logger=new te({enabled:e.logs??!1});const a=t?"https://auth.opexa.io":"https://auth.development.opexa.io",r=t?"https://wallet.opexa.io/graphql":"https://wallet.development.opexa.io/graphql",s=t?"https://report.opexa.io/graphql":"https://report.development.opexa.io/graphql",c=t?"https://account.opexa.io/graphql":"https://account.development.opexa.io/graphql",f=t?"https://portal.opexa.io/graphql":"https://portal.development.opexa.io/graphql",p=t?"https://file.opexa.io/graphql":"https://file.development.opexa.io/graphql",h=t?"https://game.opexa.io/graphql":"https://game.development.opexa.io/graphql",E=t?"https://portal-api.opexacms.io/v1":"https://portal-api.development.opexacms.io/v1";this.cmsPortalService=new _t({url:E,site:e.site,platform:e.sitePlatform}),this.sessionManager=new Pt({authUrl:a,walletUrl:r,platform:e.platform,logs:e.logs});const u={middlewares:[this.authMiddleware],fetchOptions:{headers:{Role:"MEMBER","Platform-Code":e.platform}}};this.gameService=new Ct(new k(h,u)),this.fileService=new Tt(new k(p,u)),this.walletService=new ee(new k(r,u)),this.accountService=new bt(new k(c,u)),this.reportService=new Mt(new k(s,u)),this.portalService=new vt(new k(f,u))}get authMiddleware(){return async e=>{this.logger.info("Checking for session");const t=await this.sessionManager.get();return t.data?(e.headers.append("Authorization",`Bearer ${t.data.accessToken}`),this.logger.info("Session found"),this.logger.success("Added 'Authorization' header")):this.logger.info("No session found"),e}}async signIn(e){switch(e.type){case"NAME_AND_PASSWORD":{const t=await this.sessionManager.create({...e,password:await A(e.password)});return t.ok?t.data?{ok:!0,data:{"2FAEnabled":!0,authenticator:t.data.authenticator}}:{ok:!0,data:{"2FAEnabled":!1}}: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=It(e.interval??3e4,3e4,6e4);let a=null;const r=()=>setTimeout(async()=>{await this.sessionManager.verify()||await e.onInvalid(),a=r()},t);return a=r(),function(){a&&clearTimeout(a)}}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 account(){const[e,t]=await Promise.all([this.accountService.memberAccount(),this.reportService.member()]);return e.ok?t.ok?{ok:!0,data:this.transformer.transform.account({...e.data,...t.data})}:{ok:!1,error:t.error}:{ok:!1,error:e.error}}async createAccount(e){const t=e.id??l.ObjectId.generate(g.Account).toString(),a=await this.accountService.registerMemberAccount({input:{id:t,name:e.name,birthDay:typeof e.dateOfBirth=="string"?e.dateOfBirth:e.dateOfBirth.toISOString(),password:await A(e.password),mobileNumber:_(e.mobileNumber),domain:e.domain,btag:e.referralCode},verificationCode:e.verificationCode,reCAPTCHAResponse:e.reCAPTCHAResponse});return a.ok?{ok:!0,data:{id:t}}:a}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.mobileNumber)},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??l.ObjectId.generate(g.Verification).toString(),a=await this.accountService.createMemberVerification({input:{id:t,...e}});return a.ok?{ok:!0,data:{id:t}}:a}async updateVerificationDetails(e,t){return await this.accountService.updateMemberVerification({input:{id:e,data:{...t}}})}async resetPassword(e){return await this.accountService.resetPassword({input:{mobileNumber:_(e.mobileNumber),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:_(e)}})}async wallet(){const e=await this.walletService.wallet();return e.ok?{ok:!0,data:e.data?this.transformer.transform.wallet(e.data):null}:e}async announcements(e){const t=await this.accountService.announcements({...e,filter:{visibility:{in:["MEMBER","GLOBAL"]},activationStartDateTime:{greaterThanOrEqual:new Date}}});return t.ok?{ok:!0,data:{announcements:t.data.edges.map(({cursor:a,node:r})=>({...this.transformer.transform.announcement(r),cursor:a})),totalCount:t.data.totalCount,endCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async createWithdrawal(e){const t=e.id??l.ObjectId.generate(g.Withdrawal).toString();if(e.type==="BANK"){const a=await this.walletService.createBankWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await A(e.transactionPassword)}});if(!a.ok)return a}if(e.type==="GCASH"){const a=await this.walletService.createGCashWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await A(e.transactionPassword),recipientMobileNumber:_(e.recipientMobileNumber)}});if(!a.ok)return a}if(e.type==="MAYA"){const a=await this.walletService.createMayaWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await A(e.transactionPassword),recipientMobileNumber:_(e.recipientMobileNumber)}});if(!a.ok)return a}if(e.type==="MAYA_APP"){const a=await this.walletService.createMayaAppWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await A(e.transactionPassword)}});if(!a.ok)return a}if(e.type==="MAYA_APP [NEXT]"){const a=await this.walletService.createMayaAppWithdrawal__next({input:{id:t,amount:e.amount.toString(),transactionPassword:await A(e.transactionPassword)}});if(!a.ok)return a}return{ok:!0,data:{id:t}}}async withdrawalRecords(e){const t=await this.reportService.withdrawalRecords(e);return t.ok?{ok:!0,data:{withdrawalRecords:t.data.edges.map(({cursor:a,node:r})=>({...this.transformer.transform.withdrawalRecord(r),cursor:a})),totalCount:t.data.totalCount,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??l.ObjectId.generate(g.Deposit).toString();if(e.type==="MAYA"){const a=await this.walletService.createMayaDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!a.ok)return a}if(e.type==="MAYA_APP"){const a=await this.walletService.createMayaAppDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!a.ok)return a}if(e.type==="MAYA_APP [NEXT]"){const a=await this.walletService.createMayaAppDeposit__next({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!a.ok)return a}if(e.type==="GCASH"){const a=await this.walletService.createGCashDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!a.ok)return a}return{ok:!0,data:{id:t}}}async deposit(e){const t=await this.walletService.deposit({id:e});return t.ok?{ok:!0,data:t.data?this.transformer.transform.deposit(t.data):null}:t}async depositRecords(e){const t=await this.reportService.depositRecords(e);return t.ok?{ok:!0,data:{depositRecords:t.data.edges.map(({cursor:a,node:r})=>({...this.transformer.transform.depositRecord(r),cursor:a})),totalCount:t.data.totalCount,endCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async depositsCount(){return await this.reportService.depositsCount()}async betRecords(e){var a,r;const t=await this.reportService.betRecords({...e,...(e==null?void 0:e.filter)&&{filter:{...e.filter,...((a=e.filter)==null?void 0:a.gameType)&&{game__type:e.filter.gameType},...((r=e.filter)==null?void 0:r.gameProvider)&&{game__provider:e.filter.gameProvider}}}});return t.ok?{ok:!0,data:{betRecords:t.data.edges.map(({cursor:s,node:c})=>({...this.transformer.transform.betRecord(c),cursor:s})),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:a,node:r})=>({...this.transformer.transform.transactionRecord(r),cursor:a})),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){return this.game__next(e)}async game__next(e){const t=await this.cmsPortalService.game(e);return t.ok?{ok:!0,data:t.data?this.transformer.transform.game__next(t.data):null}:t}async games(e){const t=await this.walletService.games(e);return t.ok?{ok:!0,data:{games:t.data.edges.map(({cursor:a,node:r})=>({...this.transformer.transform.game(r),cursor:a})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}async games__next(e){const t=await this.cmsPortalService.games(e);return t.ok?{ok:!0,data:{games:t.data.edges.map(({cursor:a,node:r})=>({...this.transformer.transform.game__next(r),cursor:a})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}async games__legacy(e){const t=await this.gameService.games(e);return t.ok?{ok:!0,data:{games:t.data.edges.map(({cursor:a,node:r})=>({...this.transformer.transform.game(r),cursor:a})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}async gamesByName(e){const t=await this.walletService.gamesByName(e);return t.ok?{ok:!0,data:t.data.map(this.transformer.transform.game)}:t}async gamesByName__legacy(e){const t=await this.gameService.gamesByName(e);return t.ok?{ok:!0,data:t.data.map(this.transformer.transform.game)}:t}async gameSession(e){const t=await this.walletService.gameSession({id:e});return t.ok?{ok:!0,data:t.data?this.transformer.transform.gameSession(t.data):null}:t}async gameSession__legacy(e){const t=await this.gameService.gameSession({id:e});return t.ok?{ok:!0,data:t.data?this.transformer.transform.gameSession(t.data):null}:t}async gameSession__next(e){const t=await this.walletService.gameSession({id:e});if(!t.ok)return t;if(t.data)return{ok:!0,data:this.transformer.transform.gameSession(t.data)};const a=await this.gameService.gameSession({id:e});return a.ok?{ok:!0,data:a.data?this.transformer.transform.gameSession(a.data):null}:a}async createGameSession(e){const t=e.id??l.ObjectId.generate(g.GameSession).toString(),a=await this.walletService.createGameSession({input:{id:t,game:e.game}});return a.ok?{ok:!0,data:{id:t}}:a}async createGameSession__legacy(e){const t=e.id??l.ObjectId.generate(g.GameSession).toString(),a=await this.gameService.createGameSession({input:{id:t,game:e.game}});return a.ok?{ok:!0,data:{id:t}}:a}async createGameSession__next(e){const t=e.id??l.ObjectId.generate(g.GameSession).toString();if(e.game.startsWith("SPORTS:")){const f=await l.ObjectId.generateFromKey(g.Game,e.game).then(h=>h.toString()),p=await this.gameService.createGameSession({input:{id:t,game:f}});return p.ok?{ok:!0,data:{id:t}}:p}const a=await this.game__next(e.game);if(!a.data)return{ok:!1,error:{name:"GameDoesNotExistError",message:"Game does not exist"}};const{provider:r,externalId:s}=a.data,c=$t(r)?await this.walletService.createGameSession({input:{id:t,game:s}}):await this.gameService.createGameSession({input:{id:t,game:s}});return c.ok?{ok:!0,data:{id:t}}:c}async endGameSession(e){return await this.walletService.endGameSession({input:{id:e}})}async endGameSession__legacy(e){return await this.gameService.endGameSession({input:{id:e}})}async endGameSession__next(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??l.ObjectId.generate(g.File).toString(),a=await this.fileService.uploadPrivateImageFile({input:{id:t,file:e.file}});return a.ok?{ok:!0,data:{id:t}}:a}async pointsWallet(){const e=await this.walletService.pointsWallet();return e.ok?{ok:!0,data:e.data?this.transformer.transform.pointsWallet(e.data):null}:e}async pointsToCashConversion(e){return await this.walletService.pointsToCashConversion({input:{amount:e.toString()}})}async pointsWalletTransactions(e){const t=await this.reportService.pointsWalletTransactions(e);return t.ok?{ok:!0,data:{pointsWalletTransactions:t.data.edges.map(({cursor:a,node:r})=>({...this.transformer.transform.pointsWalletTransaction(r),cursor:a})),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:a,node:r})=>({...this.transformer.transform.activityRecord(r),cursor:a})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}}const Wt=["RTG","DARWIN","DRBINGO","MEGABALL","EVOLUTION","EVOLUTION_NETENT","EVOLUTION_REDTIGER"];function $t(n){return Wt.some(e=>e===n)}Object.defineProperty(w,"ObjectId",{enumerable:!0,get:()=>l.ObjectId}),w.ObjectType=g,w.Sdk=Gt,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
988
1039
  //# sourceMappingURL=index.js.map