@jetthai/cuora 1.1.45 → 1.1.47

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/bundle.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import payment$1 from '@jetthai/cuora/src/api/payment.js';
2
2
 
3
- var activity$2 = {
3
+ var api = {
4
4
  getActivityTypes: ({ appSecret }) => ({ url: 'activities/types', method: 'get', params: { appSecret } }),
5
5
  getActivityList: ({ appSecret, include = 'cl' }) => ({
6
6
  url: 'activities/list',
@@ -3926,7 +3926,7 @@ var form = {
3926
3926
  upload: (formData) => ({ url: 'upload', method: 'post', params: formData, isFormData: true }),
3927
3927
  };
3928
3928
 
3929
- var index$2 = { activity: activity$2, auth: auth$1, common: common$1, game: game$1, mailbox, payment, user, form };
3929
+ var index$2 = { activity: api, auth: auth$1, common: common$1, game: game$1, mailbox, payment, user, form };
3930
3930
 
3931
3931
  /*! *****************************************************************************
3932
3932
  Copyright (c) Microsoft Corporation.
@@ -7184,12 +7184,12 @@ function continue_deposit_activity (request) {
7184
7184
  services: {
7185
7185
  fetchActivityDetail: async (context, event) => {
7186
7186
  const { activityNo } = context;
7187
- const { data } = await request.send(activity$2.getActivityDetail({ activityNo, appSecret }));
7187
+ const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }));
7188
7188
  return data
7189
7189
  },
7190
7190
  receiveReward: async (context, event) => {
7191
7191
  const { activityNo, receiveNo } = context;
7192
- const { data } = await request.send(activity$2.getReward({ activityNo, receiveNo, appSecret }));
7192
+ const { data } = await request.send(api.getReward({ activityNo, receiveNo, appSecret }));
7193
7193
  return data
7194
7194
  },
7195
7195
  },
@@ -7273,7 +7273,7 @@ function deposit_activity (request) {
7273
7273
  services: {
7274
7274
  fetchActivityDetail: async (context, event) => {
7275
7275
  const { activityNo } = context;
7276
- const { data } = await request.send(activity$2.getActivityDetail({ activityNo, appSecret }));
7276
+ const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }));
7277
7277
  return data
7278
7278
  },
7279
7279
  },
@@ -7445,12 +7445,12 @@ function diamond_shop_activity_fc (request) {
7445
7445
  },
7446
7446
  services: {
7447
7447
  fetchActivityList: async (context, event) => {
7448
- const { data } = await request.send(activity$2.getActivityList({ appSecret }));
7448
+ const { data } = await request.send(api.getActivityList({ appSecret }));
7449
7449
  return data
7450
7450
  },
7451
7451
  fetchActivityDetail: async (context, event) => {
7452
7452
  const { activityNo } = context;
7453
- const { data } = await request.send(activity$2.getActivityDetail({ activityNo, appSecret }));
7453
+ const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }));
7454
7454
  return data
7455
7455
  },
7456
7456
  exchange: async (context, event) => {
@@ -7458,7 +7458,7 @@ function diamond_shop_activity_fc (request) {
7458
7458
  return await Promise.all(
7459
7459
  exchangeList.map((item) =>
7460
7460
  request.send(
7461
- activity$2.exchange({
7461
+ api.exchange({
7462
7462
  exchangeType: 1,
7463
7463
  activityNo,
7464
7464
  exchangeAward: item.award,
@@ -7468,7 +7468,7 @@ function diamond_shop_activity_fc (request) {
7468
7468
  )
7469
7469
  },
7470
7470
  collect: async (context, event) => {
7471
- return await request.send(activity$2.collect({ appSecret }))
7471
+ return await request.send(api.collect({ appSecret }))
7472
7472
  },
7473
7473
  },
7474
7474
  }
@@ -7660,18 +7660,18 @@ function diamond_shop_activity_vn (request) {
7660
7660
  },
7661
7661
  services: {
7662
7662
  fetchActivityList: async (context, event) => {
7663
- const { data } = await request.send(activity$2.getActivityList({ appSecret }));
7663
+ const { data } = await request.send(api.getActivityList({ appSecret }));
7664
7664
  return data
7665
7665
  },
7666
7666
  fetchActivityDetail: async (context, event) => {
7667
7667
  const { activityNo } = context;
7668
- const { data } = await request.send(activity$2.getActivityDetail({ activityNo, appSecret }));
7668
+ const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }));
7669
7669
  return data
7670
7670
  },
7671
7671
  exchange: async (context, event) => {
7672
7672
  const { activityNo } = context;
7673
7673
  return await request.send(
7674
- activity$2.exchange({
7674
+ api.exchange({
7675
7675
  exchangeType: 1,
7676
7676
  activityNo,
7677
7677
  exchangeAward: event.data,
@@ -7679,7 +7679,7 @@ function diamond_shop_activity_vn (request) {
7679
7679
  )
7680
7680
  },
7681
7681
  collect: async (context, event) => {
7682
- return await request.send(activity$2.collect({ appSecret }))
7682
+ return await request.send(api.collect({ appSecret }))
7683
7683
  },
7684
7684
  },
7685
7685
  }
@@ -7860,17 +7860,17 @@ function fafafa_activity (request) {
7860
7860
  services: {
7861
7861
  fetchActivityDetail: async (context, event) => {
7862
7862
  const { activityNo } = context;
7863
- const { data } = await request.send(activity$2.getActivityDetail({ activityNo, appSecret }));
7863
+ const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }));
7864
7864
  return data
7865
7865
  },
7866
7866
  awardPrize: async (context, event) => {
7867
7867
  const { activityNo } = context;
7868
- const { data } = await request.send(activity$2.sentAward({ activityNo, appSecret }));
7868
+ const { data } = await request.send(api.sentAward({ activityNo, appSecret }));
7869
7869
  return data
7870
7870
  },
7871
7871
  receiveReward: async (context, event) => {
7872
7872
  const { activityNo, receiveNo } = context;
7873
- const { data } = await request.send(activity$2.getReward({ activityNo, receiveNo, appSecret }));
7873
+ const { data } = await request.send(api.getReward({ activityNo, receiveNo, appSecret }));
7874
7874
  return data
7875
7875
  },
7876
7876
  },
@@ -7981,7 +7981,7 @@ function invite_friends_activity (request) {
7981
7981
  },
7982
7982
  awardPrize: async (context, event) => {
7983
7983
  const { activityNo, uidSite, bindingCode } = context;
7984
- const { data } = await request.send(activity$2.sentAward({ activityNo, uidSite, affiliateCode: bindingCode, appSecret }));
7984
+ const { data } = await request.send(api.sentAward({ activityNo, uidSite, affiliateCode: bindingCode, appSecret }));
7985
7985
  return data
7986
7986
  },
7987
7987
  },
@@ -8179,7 +8179,7 @@ function affiliate_invite_friends_activity (request) {
8179
8179
  },
8180
8180
  awardPrize: async (context, event) => {
8181
8181
  const { activityNo, uidSite, bindingCode } = context;
8182
- const { data } = await request.send(activity$2.sentAward({ activityNo, uidSite, affiliateCode: bindingCode, appSecret }));
8182
+ const { data } = await request.send(api.sentAward({ activityNo, uidSite, affiliateCode: bindingCode, appSecret }));
8183
8183
  return data
8184
8184
  },
8185
8185
  fetchLevelDownLineList: async (context, event) => {
@@ -8288,7 +8288,7 @@ function ranking_activity (request) {
8288
8288
  services: {
8289
8289
  fetchActivityDetail: async (context, event) => {
8290
8290
  const { activityNo } = context;
8291
- const { data } = await request.send(activity$2.getActivityDetail({ activityNo, appSecret }));
8291
+ const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }));
8292
8292
  return data
8293
8293
  },
8294
8294
  },
@@ -8428,16 +8428,16 @@ function return_bonus_activity (request) {
8428
8428
  services: {
8429
8429
  fetchActivityDetail: async (context, event) => {
8430
8430
  const { activityNo } = context;
8431
- const { data } = await request.send(activity$2.getActivityDetail({ activityNo, appSecret }));
8431
+ const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }));
8432
8432
  return data
8433
8433
  },
8434
8434
  receiveReward: async (context, event) => {
8435
8435
  const { activityNo, receiveNo } = context.rewardList[0];
8436
- const { data } = await request.send(activity$2.getReward({ activityNo, receiveNo, appSecret }));
8436
+ const { data } = await request.send(api.getReward({ activityNo, receiveNo, appSecret }));
8437
8437
  return data
8438
8438
  },
8439
8439
  fetchRewardList: async (context, event) => {
8440
- const { data } = await request.send(activity$2.getRewardList({ appSecret, count: 30 }));
8440
+ const { data } = await request.send(api.getRewardList({ appSecret, count: 30 }));
8441
8441
  return data
8442
8442
  },
8443
8443
  },
@@ -8543,12 +8543,12 @@ function specify_bets_activity (request) {
8543
8543
  services: {
8544
8544
  fetchActivityDetail: async (context, event) => {
8545
8545
  const { activityNo } = context;
8546
- const { data } = await request.send(activity$2.getActivityDetail({ activityNo, appSecret }));
8546
+ const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }));
8547
8547
  return data
8548
8548
  },
8549
8549
  receiveReward: async (context, event) => {
8550
8550
  const { activityNo, receiveNo } = context.activityDetail;
8551
- const { data } = await request.send(activity$2.getReward({ activityNo, receiveNo, appSecret }));
8551
+ const { data } = await request.send(api.getReward({ activityNo, receiveNo, appSecret }));
8552
8552
  return data
8553
8553
  },
8554
8554
  },
@@ -8654,12 +8654,12 @@ function specify_turnover_activity (request) {
8654
8654
  services: {
8655
8655
  fetchActivityDetail: async (context, event) => {
8656
8656
  const { activityNo } = context;
8657
- const { data } = await request.send(activity$2.getActivityDetail({ activityNo, appSecret }));
8657
+ const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }));
8658
8658
  return data
8659
8659
  },
8660
8660
  receiveReward: async (context, event) => {
8661
8661
  const { activityNo, receiveNo } = context.activityDetail;
8662
- const { data } = await request.send(activity$2.getReward({ activityNo, receiveNo, appSecret }));
8662
+ const { data } = await request.send(api.getReward({ activityNo, receiveNo, appSecret }));
8663
8663
  return data
8664
8664
  },
8665
8665
  },
@@ -8801,12 +8801,12 @@ function sign_in_activity (request) {
8801
8801
  services: {
8802
8802
  fetchActivityDetail: async (context, event) => {
8803
8803
  const { activityNo } = context;
8804
- const { data } = await request.send(activity$2.getActivityDetail({ activityNo, appSecret }));
8804
+ const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }));
8805
8805
  return data
8806
8806
  },
8807
8807
  receiveReward: async (context, event) => {
8808
8808
  const { activityNo, receiveNo } = context;
8809
- const { data } = await request.send(activity$2.getReward({ activityNo, receiveNo, appSecret }));
8809
+ const { data } = await request.send(api.getReward({ activityNo, receiveNo, appSecret }));
8810
8810
  return data
8811
8811
  },
8812
8812
  },
@@ -8884,7 +8884,7 @@ function time_bomb_activity (request) {
8884
8884
  services: {
8885
8885
  fetchActivityDetail: async (context, event) => {
8886
8886
  const { activityNo } = context;
8887
- const { data } = await request.send(activity$2.getActivityDetail({ activityNo, appSecret }));
8887
+ const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }));
8888
8888
  return data
8889
8889
  },
8890
8890
  },
@@ -8950,7 +8950,86 @@ function mini_game_activity (request) {
8950
8950
  services: {
8951
8951
  fetchActivityDetail: async (context, event) => {
8952
8952
  const { activityNo } = context;
8953
- const { data } = await request.send(activity$2.getActivityDetail({ activityNo, appSecret }));
8953
+ const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }));
8954
+ return data
8955
+ },
8956
+ },
8957
+ }
8958
+ )
8959
+ }
8960
+
8961
+ function roulette_activity_v2 (request) {
8962
+ const { appSecret } = request.config;
8963
+ return createMachine(
8964
+ {
8965
+ id: 'roulette_activity_v2',
8966
+ context: {
8967
+ activityNo: null,
8968
+ activityDetail: null,
8969
+ duration: null,
8970
+ },
8971
+ initial: 'idle',
8972
+ states: {
8973
+ idle: {
8974
+ on: {
8975
+ SET_ACTIVITY_NO: {
8976
+ target: 'loading',
8977
+ actions: 'setActivityNo',
8978
+ },
8979
+ },
8980
+ },
8981
+ loading: {
8982
+ invoke: {
8983
+ src: 'fetchActivityDetail',
8984
+ onDone: {
8985
+ target: 'loaded',
8986
+ actions: 'setActivityDetail',
8987
+ },
8988
+ onError: {
8989
+ target: 'idle',
8990
+ },
8991
+ },
8992
+ },
8993
+ loaded: {
8994
+ entry: 'setDuration',
8995
+ always: [{ target: 'expired', cond: 'isExpired' }],
8996
+ after: {
8997
+ 1000: {
8998
+ target: 'loaded',
8999
+ },
9000
+ },
9001
+ },
9002
+ expired: {},
9003
+ },
9004
+ },
9005
+ {
9006
+ actions: {
9007
+ setActivityNo: assign((context, event) => {
9008
+ return {
9009
+ activityNo: event.data,
9010
+ }
9011
+ }),
9012
+ setActivityDetail: assign((context, event) => {
9013
+ return {
9014
+ activityDetail: event.data,
9015
+ }
9016
+ }),
9017
+ setDuration: assign((context, event) => {
9018
+ const { activityDetail = {} } = context;
9019
+ return {
9020
+ duration: activityDetail.periodEndTime - new Date().getTime() / 1000,
9021
+ }
9022
+ }),
9023
+ },
9024
+ guards: {
9025
+ isExpired: (context, event) => {
9026
+ return context.duration <= 0
9027
+ },
9028
+ },
9029
+ services: {
9030
+ fetchActivityDetail: async (context, event) => {
9031
+ const { activityNo } = context;
9032
+ const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }));
8954
9033
  return data
8955
9034
  },
8956
9035
  },
@@ -8966,6 +9045,8 @@ function activity$1 (request) {
8966
9045
  initial: 'fetchingActivityList',
8967
9046
  context: {
8968
9047
  tick: 2000,
9048
+ specifyActivities: [29],
9049
+ activitiesDetailList: [],
8969
9050
  activityList: [],
8970
9051
  activityMap: {},
8971
9052
  tournamentList: [],
@@ -8977,23 +9058,49 @@ function activity$1 (request) {
8977
9058
  invoke: {
8978
9059
  src: 'fetchActivityList',
8979
9060
  onDone: {
8980
- target: 'pending',
9061
+ target: 'idle',
8981
9062
  actions: ['setActivityList', 'setTournamentList'],
8982
9063
  },
8983
9064
  onError: {
8984
- target: 'pending',
9065
+ target: 'idle',
8985
9066
  },
8986
9067
  },
8987
9068
  },
8988
- pending: {
8989
- after: {
8990
- TIMEOUT: {
8991
- target: 'fetchingActivityList',
9069
+ idle: {
9070
+ type: 'parallel',
9071
+ states: {
9072
+ activitiesDetail: {
9073
+ initial: 'checking',
9074
+ states: {
9075
+ checking: {
9076
+ always: [{ target: 'fetchActivityDetail', cond: 'hasSpecifyActivities' }, { target: 'end' }],
9077
+ },
9078
+ fetchActivityDetail: {
9079
+ invoke: {
9080
+ src: 'fetchActivitiesDetail',
9081
+ onDone: {
9082
+ target: 'end',
9083
+ actions: 'setActivitiesDetailList',
9084
+ },
9085
+ onError: {
9086
+ target: 'end',
9087
+ },
9088
+ },
9089
+ },
9090
+ end: {},
9091
+ },
8992
9092
  },
8993
- },
8994
- on: {
8995
- SET_UNREAD: {
8996
- actions: 'setUnread',
9093
+ pending: {
9094
+ after: {
9095
+ TIMEOUT: {
9096
+ target: '#activity.fetchingActivityList',
9097
+ },
9098
+ },
9099
+ on: {
9100
+ SET_UNREAD: {
9101
+ actions: 'setUnread',
9102
+ },
9103
+ },
8997
9104
  },
8998
9105
  },
8999
9106
  },
@@ -9025,6 +9132,11 @@ function activity$1 (request) {
9025
9132
  activityList: list,
9026
9133
  }
9027
9134
  }),
9135
+ setActivitiesDetailList: assign((context, event) => {
9136
+ return {
9137
+ activitiesDetailList: event.data.map((item) => item.data),
9138
+ }
9139
+ }),
9028
9140
  setUnread: assign((context, event) => {
9029
9141
  const { uidSite, activityNo, unread } = event.data;
9030
9142
  const list = JSON.parse(JSON.stringify(context.activityList));
@@ -9041,6 +9153,13 @@ function activity$1 (request) {
9041
9153
  }
9042
9154
  }),
9043
9155
  },
9156
+ guards: {
9157
+ hasSpecifyActivities: (context, event) => {
9158
+ const { activityList = [], specifyActivities = [] } = context;
9159
+ const filterActivityList = activityList.filter((activity) => specifyActivities.includes(activity.activityType));
9160
+ return filterActivityList.length > 0
9161
+ },
9162
+ },
9044
9163
  delays: {
9045
9164
  TIMEOUT: (context, event) => {
9046
9165
  const { tick } = context;
@@ -9049,9 +9168,18 @@ function activity$1 (request) {
9049
9168
  },
9050
9169
  services: {
9051
9170
  fetchActivityList: async (context, event) => {
9052
- const { data } = await request.send(activity$2.getActivityList({ appSecret }));
9171
+ const { data } = await request.send(api.getActivityList({ appSecret }));
9053
9172
  return data
9054
9173
  },
9174
+ fetchActivitiesDetail: async (context, event) => {
9175
+ const { activityList = [], specifyActivities = [] } = context;
9176
+ const filterActivityList = activityList.filter((activity) => specifyActivities.includes(activity.activityType));
9177
+ const promiseArray = filterActivityList.map((activity) => {
9178
+ return request.send(api.getActivityDetail({ activityNo: activity.activityNo, appSecret }))
9179
+ });
9180
+ const activitiesDetail = await Promise.all(promiseArray);
9181
+ return activitiesDetail
9182
+ },
9055
9183
  },
9056
9184
  }
9057
9185
  )
@@ -9072,6 +9200,7 @@ var activity = {
9072
9200
  sign_in_activity,
9073
9201
  time_bomb_activity,
9074
9202
  mini_game_activity,
9203
+ roulette_activity_v2,
9075
9204
  activity: activity$1,
9076
9205
  };
9077
9206
 
@@ -12781,7 +12910,7 @@ function inbox (request) {
12781
12910
  fetchMessages: async (context, event) => {
12782
12911
  const { isRewardListEnable, currentTab, inbox } = JSON.parse(JSON.stringify(context));
12783
12912
  if (isRewardListEnable && (currentTab === 'REWARD' || currentTab === 'DIAMOND')) {
12784
- const { data } = await request.send(activity$2.getRewardList({ count: 30, appSecret }));
12913
+ const { data } = await request.send(api.getRewardList({ count: 30, appSecret }));
12785
12914
  inbox[currentTab] = { data, page: 0, totalPage: 1 };
12786
12915
  } else {
12787
12916
  const { page = -1 } = inbox[currentTab] || {};
@@ -13026,12 +13155,12 @@ function reward_fc (request) {
13026
13155
  },
13027
13156
  services: {
13028
13157
  fetchRewardList: async (context, event) => {
13029
- const { data } = await request.send(activity$2.getRewardList({ count: 30, appSecret }));
13158
+ const { data } = await request.send(api.getRewardList({ count: 30, appSecret }));
13030
13159
  return data
13031
13160
  },
13032
13161
  receiveReward: async (context, event) => {
13033
13162
  const { activityNo, receiveNo, attended } = event.data;
13034
- return await request.send(activity$2.getReward({ activityNo, receiveNo, appSecret, attended }))
13163
+ return await request.send(api.getReward({ activityNo, receiveNo, appSecret, attended }))
13035
13164
  },
13036
13165
  },
13037
13166
  }
@@ -13189,9 +13318,9 @@ function reward (request) {
13189
13318
  },
13190
13319
  services: {
13191
13320
  fetchRewardList: async (context, event) => {
13192
- const getRewardAPI = request.send(activity$2.getRewardList({ count: 30, appSecret }));
13193
- const getPointsRewardAPI = request.send(activity$2.getRewardList({ rewardType: 'POINTS', count: 30, appSecret }));
13194
- const getOtherRewardAPI = request.send(activity$2.getRewardList({ rewardType: 'CASH,FREE', count: 30, appSecret }));
13321
+ const getRewardAPI = request.send(api.getRewardList({ count: 30, appSecret }));
13322
+ const getPointsRewardAPI = request.send(api.getRewardList({ rewardType: 'POINTS', count: 30, appSecret }));
13323
+ const getOtherRewardAPI = request.send(api.getRewardList({ rewardType: 'CASH,FREE', count: 30, appSecret }));
13195
13324
  const [otherRewardList, pointsRewardList, rewardList] = await Promise.all([getOtherRewardAPI, getPointsRewardAPI, getRewardAPI]);
13196
13325
  return [otherRewardList, pointsRewardList, rewardList]
13197
13326
  },
@@ -13202,10 +13331,10 @@ function reward (request) {
13202
13331
  },
13203
13332
  receiveReward: async (context, event) => {
13204
13333
  const { activityNo, receiveNo, attended } = event.data;
13205
- return await request.send(activity$2.getReward({ activityNo, receiveNo, appSecret, attended }))
13334
+ return await request.send(api.getReward({ activityNo, receiveNo, appSecret, attended }))
13206
13335
  },
13207
13336
  receiveAllPoints: async (context, event) => {
13208
- return await request.send(activity$2.collect({ collectType: 'collectPoints', appSecret }))
13337
+ return await request.send(api.collect({ collectType: 'collectPoints', appSecret }))
13209
13338
  },
13210
13339
  },
13211
13340
  }
@@ -14831,6 +14960,7 @@ function withdraw_vn (request) {
14831
14960
  maximumWithdrawAmount: 0,
14832
14961
  enableWithdrawAmount: 0,
14833
14962
  enableWithdraw: false,
14963
+ withdrawRules: [],
14834
14964
 
14835
14965
  amount: null,
14836
14966
  bank: null,
@@ -14838,9 +14968,6 @@ function withdraw_vn (request) {
14838
14968
  accountNumber: null,
14839
14969
  holderName: null,
14840
14970
 
14841
- withdrawDistance: null,
14842
- withdrawAmount: null,
14843
-
14844
14971
  // otp
14845
14972
  requestId: null,
14846
14973
  status: null,
@@ -15320,6 +15447,7 @@ function withdraw_crypto (request) {
15320
15447
  maxWithdrawAmount: null,
15321
15448
  availableWithdrawAmount: null,
15322
15449
  enableWithdraw: false,
15450
+ withdrawRules: [],
15323
15451
 
15324
15452
  attachmentType: null, // null | 'withdraw' | 'pool'
15325
15453
 
@@ -15642,13 +15770,28 @@ function withdraw_crypto (request) {
15642
15770
  const { differAmountLimit, enableWithdraw, enableWithdrawAmount, maxWithdrawStatus, maximumWithdrawAmount, minimumWithdrawAmount } =
15643
15771
  event.data?.withdrawRule;
15644
15772
 
15773
+ const withdrawRules = event.data?.withdrawRule?.rules || [];
15774
+ const rules = withdrawRules.filter((rule) => rule.maxWithdrawAmount > 0);
15775
+
15776
+ const { balance } = context;
15777
+ const lastMatchedIndex = findLastIndex_1(rules, (rule) => balance >= rule.greaterEqualThen);
15778
+
15779
+ let maxWithdrawAmount = 0;
15780
+
15781
+ if (lastMatchedIndex > -1) {
15782
+ rules[lastMatchedIndex].match = true;
15783
+ maxWithdrawAmount = rules[lastMatchedIndex].maxWithdrawAmount;
15784
+ } else if (rules.length > 0) {
15785
+ maxWithdrawAmount = rules[0].maxWithdrawAmount;
15786
+ } else {
15787
+ maxWithdrawAmount = balance;
15788
+ }
15789
+
15645
15790
  return {
15646
- // maxWithdrawAmount: maximumWithdrawAmount,
15647
- // availableWithdrawAmount: enableWithdrawAmount,
15648
- maximumWithdrawAmount: +maximumWithdrawAmount,
15791
+ maxWithdrawAmount,
15649
15792
  enableWithdrawAmount: +enableWithdrawAmount,
15650
- amount: +enableWithdrawAmount,
15651
15793
  enableWithdraw,
15794
+ withdrawRules,
15652
15795
  }
15653
15796
 
15654
15797
  // const rules = event.data.rules.filter((rule) => rule.maxWithdrawAmount > 0)
@@ -19961,12 +20104,12 @@ function leaderboard (request) {
19961
20104
  },
19962
20105
  services: {
19963
20106
  fetchActivityList: async (context, event) => {
19964
- const { data } = await request.send(activity$2.getActivityList({ appSecret }));
20107
+ const { data } = await request.send(api.getActivityList({ appSecret }));
19965
20108
  return data
19966
20109
  },
19967
20110
  fetchActivityDetail: async (context, event) => {
19968
20111
  const { activityNo } = context;
19969
- const { data } = await request.send(activity$2.getActivityDetail({ activityNo, appSecret }));
20112
+ const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }));
19970
20113
  return data
19971
20114
  },
19972
20115
  },
@@ -20431,7 +20574,7 @@ function vip_table (request) {
20431
20574
  },
20432
20575
  services: {
20433
20576
  fetchVipTable: async (context, event) => {
20434
- const { viptable = {} } = await request.send(activity$2.getVipTable());
20577
+ const { viptable = {} } = await request.send(api.getVipTable());
20435
20578
  const { data = [] } = viptable;
20436
20579
  data.map((item) => {
20437
20580
  item.title = item.title.toLowerCase();
@@ -20601,6 +20744,275 @@ function promotions (request) {
20601
20744
  )
20602
20745
  }
20603
20746
 
20747
+ function roulette_v2 (request) {
20748
+ const { appSecret } = request.config;
20749
+ return createMachine(
20750
+ {
20751
+ id: 'roulette_v2',
20752
+ context: {
20753
+ tick: 2000,
20754
+ activityNo: null,
20755
+ activityDetail: null,
20756
+ duration: null,
20757
+ spinCount: 0,
20758
+ duration: null,
20759
+ rewardList: [],
20760
+ unCollectRewards: [],
20761
+ unCollectPoints: 0,
20762
+ unCollectPrize: 0,
20763
+ unCollectFree: 0,
20764
+ unCollectCash: 0,
20765
+ latestSpinLeft: 0,
20766
+ spinLeft: 0,
20767
+ spinResult: {},
20768
+ rouletteV2ExchangeAward: [],
20769
+ calculatedNewSpinRewards: [],
20770
+ awardedCashAmount: 0,
20771
+ awardedFreeAmount: 0,
20772
+ awardedPointsAmount: 0,
20773
+ awardedPrizeCount: 0,
20774
+ },
20775
+ initial: 'idle',
20776
+ states: {
20777
+ idle: {
20778
+ on: {
20779
+ SET_ACTIVITY_NO: {
20780
+ target: 'fetching',
20781
+ actions: 'setActivityNo',
20782
+ },
20783
+ },
20784
+ },
20785
+ fetching: {
20786
+ invoke: {
20787
+ src: 'fetchActivityDetail',
20788
+ onDone: {
20789
+ target: 'loaded',
20790
+ actions: ['setInitData', 'setUncollectRewardData'],
20791
+ },
20792
+ onError: {
20793
+ target: 'loaded',
20794
+ },
20795
+ },
20796
+ },
20797
+ loaded: {
20798
+ type: 'parallel',
20799
+ states: {
20800
+ prepare: {
20801
+ initial: 'countdown',
20802
+ states: {
20803
+ countdown: {
20804
+ entry: 'setDuration',
20805
+ always: [{ target: 'expired', cond: 'isExpired' }],
20806
+ after: {
20807
+ 1000: {
20808
+ target: 'countdown',
20809
+ },
20810
+ },
20811
+ },
20812
+ expired: {},
20813
+ },
20814
+ },
20815
+ init: {
20816
+ initial: 'pending',
20817
+ states: {
20818
+ pending: {
20819
+ on: {
20820
+ SPIN: {
20821
+ target: 'spinning',
20822
+ actions: 'setSpinCount',
20823
+ },
20824
+ GET_REWARD: {
20825
+ target: 'awarding',
20826
+ },
20827
+ },
20828
+ },
20829
+ spinning: {
20830
+ invoke: {
20831
+ src: 'exchange',
20832
+ onDone: {
20833
+ target: 'animation',
20834
+ actions: ['setSpinResult', 'setUncollectRewardData'],
20835
+ },
20836
+ onError: {
20837
+ target: 'pending',
20838
+ },
20839
+ },
20840
+ },
20841
+ animation: {
20842
+ on: {
20843
+ FINISHED: {
20844
+ target: 'finished',
20845
+ },
20846
+ },
20847
+ },
20848
+ finished: {
20849
+ after: {
20850
+ 0: {
20851
+ target: 'pending',
20852
+ },
20853
+ },
20854
+ },
20855
+ awarding: {
20856
+ invoke: {
20857
+ src: 'collect',
20858
+ onDone: {
20859
+ target: 'awarded',
20860
+ actions: 'setCollectResult',
20861
+ },
20862
+ onError: {
20863
+ target: 'pending',
20864
+ },
20865
+ },
20866
+ },
20867
+ awarded: {
20868
+ after: {
20869
+ 0: {
20870
+ target: 'pending',
20871
+ },
20872
+ },
20873
+ },
20874
+ },
20875
+ },
20876
+ },
20877
+ },
20878
+ },
20879
+ },
20880
+ {
20881
+ actions: {
20882
+ setActivityNo: assign((context, event) => {
20883
+ return {
20884
+ activityNo: event.data,
20885
+ }
20886
+ }),
20887
+ setInitData: assign((context, event) => {
20888
+ const { rewardList = [], latestSpinLeft = 0, spinLeft = 0, unCollectRewards = [], periodEndTime = '0' } = event.data || {};
20889
+ const combindedRewardList = rewardList.reduce((arr, item, index) => {
20890
+ if (index === 4) {
20891
+ arr.push({ rewardType: 'Spin All', reward: '', withdrawRule: '' });
20892
+ arr.push(item);
20893
+ } else {
20894
+ arr.push(item);
20895
+ }
20896
+ return arr
20897
+ }, []);
20898
+
20899
+ return {
20900
+ activityDetail: event.data,
20901
+ duration: parseInt(`${periodEndTime}`) - new Date().getTime() / 1000,
20902
+ rewardList: combindedRewardList,
20903
+ unCollectRewards,
20904
+ latestSpinLeft,
20905
+ spinLeft,
20906
+ }
20907
+ }),
20908
+ setUncollectRewardData: assign((context, event) => {
20909
+ const { unCollectRewards = [] } = context;
20910
+ let unCollectPoints = 0;
20911
+ let unCollectFree = 0;
20912
+ let unCollectCash = 0;
20913
+ let unCollectPrize = 0;
20914
+
20915
+ unCollectRewards.forEach((item) => {
20916
+ if (item.rewardType === 'POINTS') {
20917
+ unCollectPoints += parseFloat(`${item.reward}`);
20918
+ }
20919
+ if (item.rewardType === 'FREE') {
20920
+ unCollectFree += parseFloat(`${item.reward}`);
20921
+ }
20922
+ if (item.rewardType === 'CASH') {
20923
+ unCollectCash += parseFloat(`${item.reward}`);
20924
+ }
20925
+ if (item.rewardType === 'PRIZE') {
20926
+ unCollectPrize++;
20927
+ }
20928
+ });
20929
+
20930
+ return {
20931
+ unCollectPoints,
20932
+ unCollectPrize,
20933
+ unCollectFree,
20934
+ unCollectCash,
20935
+ }
20936
+ }),
20937
+ setDuration: assign((context, event) => {
20938
+ const { activityDetail = {} } = context;
20939
+ return {
20940
+ duration: activityDetail.periodEndTime - new Date().getTime() / 1000,
20941
+ }
20942
+ }),
20943
+ setSpinCount: assign((context, event) => {
20944
+ return {
20945
+ spinCount: event.data,
20946
+ }
20947
+ }),
20948
+ setSpinResult: assign((context, event) => {
20949
+ const { unCollectRewards = [], newSpinRewards = [], spinLeft = 0 } = JSON.parse(JSON.stringify(event.data || {}));
20950
+ const calculatedNewSpinRewards = newSpinRewards
20951
+ .map((item) => {
20952
+ item.count = 1;
20953
+ return item
20954
+ })
20955
+ .reduce((arr, spin) => {
20956
+ let newIndex = 0;
20957
+ let alreadyHave = false;
20958
+ if (arr.length > 0) {
20959
+ alreadyHave = arr.find((item, index) => {
20960
+ if (item.rewardType === spin.rewardType && item.reward === spin.reward) {
20961
+ newIndex = index;
20962
+ return true
20963
+ } else {
20964
+ return false
20965
+ }
20966
+ });
20967
+ }
20968
+ if (alreadyHave) {
20969
+ arr[newIndex].count++;
20970
+ } else {
20971
+ arr.push(spin);
20972
+ }
20973
+ return arr
20974
+ }, []);
20975
+
20976
+ return {
20977
+ spinResult: event.data,
20978
+ unCollectRewards,
20979
+ calculatedNewSpinRewards,
20980
+ spinLeft,
20981
+ }
20982
+ }),
20983
+ setCollectResult: assign((context, event) => {
20984
+ const { rouletteV2ExchangeAward } = event.data;
20985
+ return {
20986
+ rouletteV2ExchangeAward,
20987
+ unCollectRewards: [],
20988
+ }
20989
+ }),
20990
+ },
20991
+ guards: {
20992
+ isExpired: (context, event) => {
20993
+ return context.duration <= 0
20994
+ },
20995
+ },
20996
+ services: {
20997
+ fetchActivityDetail: async (context, event) => {
20998
+ const { activityNo } = context;
20999
+ const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }));
21000
+ return data
21001
+ },
21002
+ exchange: async (context, event) => {
21003
+ const { activityNo, spinCount } = context;
21004
+ const { data } = await request.send(api.exchange({ activityNo, exchangeType: 3, numberOfTimes: spinCount }));
21005
+ return data
21006
+ },
21007
+ collect: async (context, event) => {
21008
+ const { data } = await request.send(api.collect({ appSecret, collectType: 'roulettev2' }));
21009
+ return data
21010
+ },
21011
+ },
21012
+ }
21013
+ )
21014
+ }
21015
+
20604
21016
  var index$1 = {
20605
21017
  ...activity,
20606
21018
  auth,
@@ -20639,6 +21051,7 @@ var index$1 = {
20639
21051
  auth_otp_v3,
20640
21052
  vip_table,
20641
21053
  promotions,
21054
+ roulette_v2,
20642
21055
  };
20643
21056
 
20644
21057
  // const pickBy = require('lodash/pickBy')