@jetthai/cuora 1.1.93-cash → 1.1.93

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
@@ -3614,7 +3614,7 @@ var common$1 = {
3614
3614
  getAnnouncements: () => ({ url: 'getAnnouncements', method: 'get', isPublic: true }),
3615
3615
  };
3616
3616
 
3617
- var game = {
3617
+ var game$1 = {
3618
3618
  getGameSHA: () => ({ method: 'get', url: 'game/list/v2/sha' }),
3619
3619
  getOptionMap: (code) => ({ method: 'get', url: 'game/list/v2/options', params: { code } }),
3620
3620
  getGameStatus: () => ({ method: 'get', url: 'game/list/v2/status' }),
@@ -3934,79 +3934,79 @@ var form = {
3934
3934
  upload: (formData) => ({ url: 'upload', method: 'post', params: formData, isFormData: true }),
3935
3935
  };
3936
3936
 
3937
- var index$2 = { activity: api, auth: auth$1, common: common$1, game, mailbox, payment, user, form };
3938
-
3939
- /*! *****************************************************************************
3940
- Copyright (c) Microsoft Corporation.
3941
-
3942
- Permission to use, copy, modify, and/or distribute this software for any
3943
- purpose with or without fee is hereby granted.
3944
-
3945
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
3946
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
3947
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
3948
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
3949
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
3950
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
3951
- PERFORMANCE OF THIS SOFTWARE.
3952
- ***************************************************************************** */
3953
-
3954
- var __assign = function() {
3955
- __assign = Object.assign || function __assign(t) {
3956
- for (var s, i = 1, n = arguments.length; i < n; i++) {
3957
- s = arguments[i];
3958
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
3959
- }
3960
- return t;
3961
- };
3962
- return __assign.apply(this, arguments);
3963
- };
3964
-
3965
- function __rest(s, e) {
3966
- var t = {};
3967
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
3968
- t[p] = s[p];
3969
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
3970
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
3971
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
3972
- t[p[i]] = s[p[i]];
3973
- }
3974
- return t;
3975
- }
3976
-
3977
- function __values(o) {
3978
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
3979
- if (m) return m.call(o);
3980
- if (o && typeof o.length === "number") return {
3981
- next: function () {
3982
- if (o && i >= o.length) o = void 0;
3983
- return { value: o && o[i++], done: !o };
3984
- }
3985
- };
3986
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
3987
- }
3988
-
3989
- function __read(o, n) {
3990
- var m = typeof Symbol === "function" && o[Symbol.iterator];
3991
- if (!m) return o;
3992
- var i = m.call(o), r, ar = [], e;
3993
- try {
3994
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
3995
- }
3996
- catch (error) { e = { error: error }; }
3997
- finally {
3998
- try {
3999
- if (r && !r.done && (m = i["return"])) m.call(i);
4000
- }
4001
- finally { if (e) throw e.error; }
4002
- }
4003
- return ar;
4004
- }
4005
-
4006
- function __spreadArray(to, from) {
4007
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
4008
- to[j] = from[i];
4009
- return to;
3937
+ var index$2 = { activity: api, auth: auth$1, common: common$1, game: game$1, mailbox, payment, user, form };
3938
+
3939
+ /*! *****************************************************************************
3940
+ Copyright (c) Microsoft Corporation.
3941
+
3942
+ Permission to use, copy, modify, and/or distribute this software for any
3943
+ purpose with or without fee is hereby granted.
3944
+
3945
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
3946
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
3947
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
3948
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
3949
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
3950
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
3951
+ PERFORMANCE OF THIS SOFTWARE.
3952
+ ***************************************************************************** */
3953
+
3954
+ var __assign = function() {
3955
+ __assign = Object.assign || function __assign(t) {
3956
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
3957
+ s = arguments[i];
3958
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
3959
+ }
3960
+ return t;
3961
+ };
3962
+ return __assign.apply(this, arguments);
3963
+ };
3964
+
3965
+ function __rest(s, e) {
3966
+ var t = {};
3967
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
3968
+ t[p] = s[p];
3969
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
3970
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
3971
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
3972
+ t[p[i]] = s[p[i]];
3973
+ }
3974
+ return t;
3975
+ }
3976
+
3977
+ function __values(o) {
3978
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
3979
+ if (m) return m.call(o);
3980
+ if (o && typeof o.length === "number") return {
3981
+ next: function () {
3982
+ if (o && i >= o.length) o = void 0;
3983
+ return { value: o && o[i++], done: !o };
3984
+ }
3985
+ };
3986
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
3987
+ }
3988
+
3989
+ function __read(o, n) {
3990
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
3991
+ if (!m) return o;
3992
+ var i = m.call(o), r, ar = [], e;
3993
+ try {
3994
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
3995
+ }
3996
+ catch (error) { e = { error: error }; }
3997
+ finally {
3998
+ try {
3999
+ if (r && !r.done && (m = i["return"])) m.call(i);
4000
+ }
4001
+ finally { if (e) throw e.error; }
4002
+ }
4003
+ return ar;
4004
+ }
4005
+
4006
+ function __spreadArray(to, from) {
4007
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
4008
+ to[j] = from[i];
4009
+ return to;
4010
4010
  }
4011
4011
 
4012
4012
  var STATE_DELIMITER = '.';
@@ -4143,9 +4143,9 @@ function mapFilterValues(collection, iteratee, predicate) {
4143
4143
 
4144
4144
  return result;
4145
4145
  }
4146
- /**
4147
- * Retrieves a value at the given path.
4148
- * @param props The deep path to the prop of the desired value
4146
+ /**
4147
+ * Retrieves a value at the given path.
4148
+ * @param props The deep path to the prop of the desired value
4149
4149
  */
4150
4150
 
4151
4151
  var path = function (props) {
@@ -4174,9 +4174,9 @@ var path = function (props) {
4174
4174
  return result;
4175
4175
  };
4176
4176
  };
4177
- /**
4178
- * Retrieves a value at the given path via the nested accessor prop.
4179
- * @param props The deep path to the prop of the desired value
4177
+ /**
4178
+ * Retrieves a value at the given path via the nested accessor prop.
4179
+ * @param props The deep path to the prop of the desired value
4180
4180
  */
4181
4181
 
4182
4182
  function nestedPath(props, accessorProp) {
@@ -4624,11 +4624,11 @@ function toActivityDefinition(action) {
4624
4624
  type: actionObject.type
4625
4625
  });
4626
4626
  }
4627
- /**
4628
- * Raises an event. This places the event in the internal event queue, so that
4629
- * the event is immediately consumed by the machine in the current step.
4630
- *
4631
- * @param eventType The event to raise.
4627
+ /**
4628
+ * Raises an event. This places the event in the internal event queue, so that
4629
+ * the event is immediately consumed by the machine in the current step.
4630
+ *
4631
+ * @param eventType The event to raise.
4632
4632
  */
4633
4633
 
4634
4634
  function raise(event) {
@@ -4649,15 +4649,15 @@ function resolveRaise(action) {
4649
4649
  _event: toSCXMLEvent(action.event)
4650
4650
  };
4651
4651
  }
4652
- /**
4653
- * Sends an event. This returns an action that will be read by an interpreter to
4654
- * send the event in the next step, after the current step is finished executing.
4655
- *
4656
- * @param event The event to send.
4657
- * @param options Options to pass into the send event:
4658
- * - `id` - The unique send event identifier (used with `cancel()`).
4659
- * - `delay` - The number of milliseconds to delay the sending of the event.
4660
- * - `to` - The target of this event (by default, the machine the event was sent from).
4652
+ /**
4653
+ * Sends an event. This returns an action that will be read by an interpreter to
4654
+ * send the event in the next step, after the current step is finished executing.
4655
+ *
4656
+ * @param event The event to send.
4657
+ * @param options Options to pass into the send event:
4658
+ * - `id` - The unique send event identifier (used with `cancel()`).
4659
+ * - `delay` - The number of milliseconds to delay the sending of the event.
4660
+ * - `to` - The target of this event (by default, the machine the event was sent from).
4661
4661
  */
4662
4662
 
4663
4663
  function send(event, options) {
@@ -4699,12 +4699,12 @@ var resolveLog = function (action, ctx, _event) {
4699
4699
  })
4700
4700
  });
4701
4701
  };
4702
- /**
4703
- * Cancels an in-flight `send(...)` action. A canceled sent action will not
4704
- * be executed, nor will its event be sent, unless it has already been sent
4705
- * (e.g., if `cancel(...)` is called after the `send(...)` action's `delay`).
4706
- *
4707
- * @param sendId The `id` of the `send(...)` action to cancel.
4702
+ /**
4703
+ * Cancels an in-flight `send(...)` action. A canceled sent action will not
4704
+ * be executed, nor will its event be sent, unless it has already been sent
4705
+ * (e.g., if `cancel(...)` is called after the `send(...)` action's `delay`).
4706
+ *
4707
+ * @param sendId The `id` of the `send(...)` action to cancel.
4708
4708
  */
4709
4709
 
4710
4710
  var cancel = function (sendId) {
@@ -4713,10 +4713,10 @@ var cancel = function (sendId) {
4713
4713
  sendId: sendId
4714
4714
  };
4715
4715
  };
4716
- /**
4717
- * Starts an activity.
4718
- *
4719
- * @param activity The activity to start.
4716
+ /**
4717
+ * Starts an activity.
4718
+ *
4719
+ * @param activity The activity to start.
4720
4720
  */
4721
4721
 
4722
4722
  function start(activity) {
@@ -4727,10 +4727,10 @@ function start(activity) {
4727
4727
  exec: undefined
4728
4728
  };
4729
4729
  }
4730
- /**
4731
- * Stops an activity.
4732
- *
4733
- * @param actorRef The activity to stop.
4730
+ /**
4731
+ * Stops an activity.
4732
+ *
4733
+ * @param actorRef The activity to stop.
4734
4734
  */
4735
4735
 
4736
4736
  function stop(actorRef) {
@@ -4752,10 +4752,10 @@ function resolveStop(action, context, _event) {
4752
4752
  };
4753
4753
  return actionObject;
4754
4754
  }
4755
- /**
4756
- * Updates the current context of the machine.
4757
- *
4758
- * @param assignment An object that represents the partial context to update.
4755
+ /**
4756
+ * Updates the current context of the machine.
4757
+ *
4758
+ * @param assignment An object that represents the partial context to update.
4759
4759
  */
4760
4760
 
4761
4761
  var assign = function (assignment) {
@@ -4764,24 +4764,24 @@ var assign = function (assignment) {
4764
4764
  assignment: assignment
4765
4765
  };
4766
4766
  };
4767
- /**
4768
- * Returns an event type that represents an implicit event that
4769
- * is sent after the specified `delay`.
4770
- *
4771
- * @param delayRef The delay in milliseconds
4772
- * @param id The state node ID where this event is handled
4767
+ /**
4768
+ * Returns an event type that represents an implicit event that
4769
+ * is sent after the specified `delay`.
4770
+ *
4771
+ * @param delayRef The delay in milliseconds
4772
+ * @param id The state node ID where this event is handled
4773
4773
  */
4774
4774
 
4775
4775
  function after(delayRef, id) {
4776
4776
  var idSuffix = id ? "#" + id : '';
4777
4777
  return ActionTypes.After + "(" + delayRef + ")" + idSuffix;
4778
4778
  }
4779
- /**
4780
- * Returns an event that represents that a final state node
4781
- * has been reached in the parent state node.
4782
- *
4783
- * @param id The final state node's parent state node `id`
4784
- * @param data The data to pass into the event
4779
+ /**
4780
+ * Returns an event that represents that a final state node
4781
+ * has been reached in the parent state node.
4782
+ *
4783
+ * @param id The final state node's parent state node `id`
4784
+ * @param data The data to pass into the event
4785
4785
  */
4786
4786
 
4787
4787
  function done(id, data) {
@@ -4797,14 +4797,14 @@ function done(id, data) {
4797
4797
 
4798
4798
  return eventObject;
4799
4799
  }
4800
- /**
4801
- * Returns an event that represents that an invoked service has terminated.
4802
- *
4803
- * An invoked service is terminated when it has reached a top-level final state node,
4804
- * but not when it is canceled.
4805
- *
4806
- * @param id The final state node ID
4807
- * @param data The data to pass into the event
4800
+ /**
4801
+ * Returns an event that represents that an invoked service has terminated.
4802
+ *
4803
+ * An invoked service is terminated when it has reached a top-level final state node,
4804
+ * but not when it is canceled.
4805
+ *
4806
+ * @param id The final state node ID
4807
+ * @param data The data to pass into the event
4808
4808
  */
4809
4809
 
4810
4810
  function doneInvoke(id, data) {
@@ -5215,17 +5215,17 @@ var State =
5215
5215
 
5216
5216
  /** @class */
5217
5217
  function () {
5218
- /**
5219
- * Creates a new State instance.
5220
- * @param value The state value
5221
- * @param context The extended state
5222
- * @param historyValue The tree representing historical values of the state nodes
5223
- * @param history The previous state
5224
- * @param actions An array of action objects to execute as side-effects
5225
- * @param activities A mapping of activities and whether they are started (`true`) or stopped (`false`).
5226
- * @param meta
5227
- * @param events Internal event queue. Should be empty with run-to-completion semantics.
5228
- * @param configuration
5218
+ /**
5219
+ * Creates a new State instance.
5220
+ * @param value The state value
5221
+ * @param context The extended state
5222
+ * @param historyValue The tree representing historical values of the state nodes
5223
+ * @param history The previous state
5224
+ * @param actions An array of action objects to execute as side-effects
5225
+ * @param activities A mapping of activities and whether they are started (`true`) or stopped (`false`).
5226
+ * @param meta
5227
+ * @param events Internal event queue. Should be empty with run-to-completion semantics.
5228
+ * @param configuration
5229
5229
  */
5230
5230
  function State(config) {
5231
5231
  var _this = this;
@@ -5261,10 +5261,10 @@ function () {
5261
5261
  }
5262
5262
  });
5263
5263
  }
5264
- /**
5265
- * Creates a new State instance for the given `stateValue` and `context`.
5266
- * @param stateValue
5267
- * @param context
5264
+ /**
5265
+ * Creates a new State instance for the given `stateValue` and `context`.
5266
+ * @param stateValue
5267
+ * @param context
5268
5268
  */
5269
5269
 
5270
5270
 
@@ -5308,19 +5308,19 @@ function () {
5308
5308
  children: {}
5309
5309
  });
5310
5310
  };
5311
- /**
5312
- * Creates a new State instance for the given `config`.
5313
- * @param config The state config
5311
+ /**
5312
+ * Creates a new State instance for the given `config`.
5313
+ * @param config The state config
5314
5314
  */
5315
5315
 
5316
5316
 
5317
5317
  State.create = function (config) {
5318
5318
  return new State(config);
5319
5319
  };
5320
- /**
5321
- * Creates a new `State` instance for the given `stateValue` and `context` with no actions (side-effects).
5322
- * @param stateValue
5323
- * @param context
5320
+ /**
5321
+ * Creates a new `State` instance for the given `stateValue` and `context` with no actions (side-effects).
5322
+ * @param stateValue
5323
+ * @param context
5324
5324
  */
5325
5325
 
5326
5326
 
@@ -5347,10 +5347,10 @@ function () {
5347
5347
 
5348
5348
  return State.from(stateValue, context);
5349
5349
  };
5350
- /**
5351
- * Returns an array of all the string leaf state node paths.
5352
- * @param stateValue
5353
- * @param delimiter The character(s) that separate each subpath in the string state node path.
5350
+ /**
5351
+ * Returns an array of all the string leaf state node paths.
5352
+ * @param stateValue
5353
+ * @param delimiter The character(s) that separate each subpath in the string state node path.
5354
5354
  */
5355
5355
 
5356
5356
 
@@ -5389,28 +5389,28 @@ function () {
5389
5389
  tags: Array.from(tags)
5390
5390
  });
5391
5391
  };
5392
- /**
5393
- * Whether the current state value is a subset of the given parent state value.
5394
- * @param parentStateValue
5392
+ /**
5393
+ * Whether the current state value is a subset of the given parent state value.
5394
+ * @param parentStateValue
5395
5395
  */
5396
5396
 
5397
5397
 
5398
5398
  State.prototype.matches = function (parentStateValue) {
5399
5399
  return matchesState(parentStateValue, this.value);
5400
5400
  };
5401
- /**
5402
- * Whether the current state configuration has a state node with the specified `tag`.
5403
- * @param tag
5401
+ /**
5402
+ * Whether the current state configuration has a state node with the specified `tag`.
5403
+ * @param tag
5404
5404
  */
5405
5405
 
5406
5406
 
5407
5407
  State.prototype.hasTag = function (tag) {
5408
5408
  return this.tags.has(tag);
5409
5409
  };
5410
- /**
5411
- * Determines whether sending the `event` will cause a transition.
5412
- * @param event The event to test
5413
- * @returns Whether the event will cause a transition
5410
+ /**
5411
+ * Determines whether sending the `event` will cause a transition.
5412
+ * @param event The event to test
5413
+ * @returns Whether the event will cause a transition
5414
5414
  */
5415
5415
 
5416
5416
 
@@ -5427,9 +5427,9 @@ function () {
5427
5427
  return State;
5428
5428
  }();
5429
5429
 
5430
- /**
5431
- * Maintains a stack of the current service in scope.
5432
- * This is used to provide the correct service to spawn().
5430
+ /**
5431
+ * Maintains a stack of the current service in scope.
5432
+ * This is used to provide the correct service to spawn().
5433
5433
  */
5434
5434
  var provide = function (service, fn) {
5435
5435
  var result = fn(service);
@@ -5459,11 +5459,11 @@ function createNullActor(id) {
5459
5459
  }
5460
5460
  };
5461
5461
  }
5462
- /**
5463
- * Creates a deferred actor that is able to be invoked given the provided
5464
- * invocation information in its `.meta` value.
5465
- *
5466
- * @param invokeDefinition The meta information needed to invoke the actor.
5462
+ /**
5463
+ * Creates a deferred actor that is able to be invoked given the provided
5464
+ * invocation information in its `.meta` value.
5465
+ *
5466
+ * @param invokeDefinition The meta information needed to invoke the actor.
5467
5467
  */
5468
5468
 
5469
5469
  function createInvocableActor(invokeDefinition, machine, context, _event) {
@@ -5554,12 +5554,12 @@ var StateNode =
5554
5554
  /** @class */
5555
5555
  function () {
5556
5556
  function StateNode(
5557
- /**
5558
- * The raw config used to create the machine.
5557
+ /**
5558
+ * The raw config used to create the machine.
5559
5559
  */
5560
5560
  config, options,
5561
- /**
5562
- * The initial extended state
5561
+ /**
5562
+ * The initial extended state
5563
5563
  */
5564
5564
  _context // TODO: this is unsafe, but we're removing it in v5 anyway
5565
5565
  ) {
@@ -5573,8 +5573,8 @@ function () {
5573
5573
 
5574
5574
  this.config = config;
5575
5575
  this._context = _context;
5576
- /**
5577
- * The order this state node appears. Corresponds to the implicit SCXML document order.
5576
+ /**
5577
+ * The order this state node appears. Corresponds to the implicit SCXML document order.
5578
5578
  */
5579
5579
 
5580
5580
  this.order = -1;
@@ -5709,11 +5709,11 @@ function () {
5709
5709
  return stateNode.on;
5710
5710
  });
5711
5711
  };
5712
- /**
5713
- * Clones this state machine with custom options and context.
5714
- *
5715
- * @param options Options (actions, guards, activities, services) to recursively merge with the existing options.
5716
- * @param context Custom context (will override predefined context)
5712
+ /**
5713
+ * Clones this state machine with custom options and context.
5714
+ *
5715
+ * @param options Options (actions, guards, activities, services) to recursively merge with the existing options.
5716
+ * @param context Custom context (will override predefined context)
5717
5717
  */
5718
5718
 
5719
5719
 
@@ -5732,10 +5732,10 @@ function () {
5732
5732
  delays: __assign(__assign({}, delays), options.delays)
5733
5733
  }, context !== null && context !== void 0 ? context : this.context);
5734
5734
  };
5735
- /**
5736
- * Clones this state machine with custom context.
5737
- *
5738
- * @param context Custom context (will override predefined context, not recursive)
5735
+ /**
5736
+ * Clones this state machine with custom context.
5737
+ *
5738
+ * @param context Custom context (will override predefined context, not recursive)
5739
5739
  */
5740
5740
 
5741
5741
 
@@ -5751,8 +5751,8 @@ function () {
5751
5751
  configurable: true
5752
5752
  });
5753
5753
  Object.defineProperty(StateNode.prototype, "definition", {
5754
- /**
5755
- * The well-structured state node definition.
5754
+ /**
5755
+ * The well-structured state node definition.
5756
5756
  */
5757
5757
  get: function () {
5758
5758
  return {
@@ -5786,8 +5786,8 @@ function () {
5786
5786
  };
5787
5787
 
5788
5788
  Object.defineProperty(StateNode.prototype, "on", {
5789
- /**
5790
- * The mapping of events to transitions.
5789
+ /**
5790
+ * The mapping of events to transitions.
5791
5791
  */
5792
5792
  get: function () {
5793
5793
  if (this.__cache.on) {
@@ -5812,8 +5812,8 @@ function () {
5812
5812
  configurable: true
5813
5813
  });
5814
5814
  Object.defineProperty(StateNode.prototype, "transitions", {
5815
- /**
5816
- * All the transitions that can be taken from this state node.
5815
+ /**
5816
+ * All the transitions that can be taken from this state node.
5817
5817
  */
5818
5818
  get: function () {
5819
5819
  return this.__cache.transitions || (this.__cache.transitions = this.formatTransitions(), this.__cache.transitions);
@@ -5836,8 +5836,8 @@ function () {
5836
5836
  this.__cache.candidates[eventName] = candidates;
5837
5837
  return candidates;
5838
5838
  };
5839
- /**
5840
- * All delayed transitions from the config.
5839
+ /**
5840
+ * All delayed transitions from the config.
5841
5841
  */
5842
5842
 
5843
5843
 
@@ -5889,10 +5889,10 @@ function () {
5889
5889
  });
5890
5890
  });
5891
5891
  };
5892
- /**
5893
- * Returns the state nodes represented by the current state value.
5894
- *
5895
- * @param state The state value or State instance
5892
+ /**
5893
+ * Returns the state nodes represented by the current state value.
5894
+ *
5895
+ * @param state The state value or State instance
5896
5896
  */
5897
5897
 
5898
5898
 
@@ -5923,10 +5923,10 @@ function () {
5923
5923
  return allSubStateNodes.concat(subStateNode);
5924
5924
  }, []));
5925
5925
  };
5926
- /**
5927
- * Returns `true` if this state node explicitly handles the given event.
5928
- *
5929
- * @param event The event in question
5926
+ /**
5927
+ * Returns `true` if this state node explicitly handles the given event.
5928
+ *
5929
+ * @param event The event in question
5930
5930
  */
5931
5931
 
5932
5932
 
@@ -5934,12 +5934,12 @@ function () {
5934
5934
  var eventType = getEventType(event);
5935
5935
  return this.events.includes(eventType);
5936
5936
  };
5937
- /**
5938
- * Resolves the given `state` to a new `State` instance relative to this machine.
5939
- *
5940
- * This ensures that `.events` and `.nextEvents` represent the correct values.
5941
- *
5942
- * @param state The state to resolve
5937
+ /**
5938
+ * Resolves the given `state` to a new `State` instance relative to this machine.
5939
+ *
5940
+ * This ensures that `.events` and `.nextEvents` represent the correct values.
5941
+ *
5942
+ * @param state The state to resolve
5943
5943
  */
5944
5944
 
5945
5945
 
@@ -6157,9 +6157,9 @@ function () {
6157
6157
 
6158
6158
  return nodes;
6159
6159
  };
6160
- /**
6161
- * Whether the given state node "escapes" this state node. If the `stateNode` is equal to or the parent of
6162
- * this state node, it does not escape.
6160
+ /**
6161
+ * Whether the given state node "escapes" this state node. If the `stateNode` is equal to or the parent of
6162
+ * this state node, it does not escape.
6163
6163
  */
6164
6164
 
6165
6165
 
@@ -6284,12 +6284,12 @@ function () {
6284
6284
  var actions = toActionObjects(exitActions.concat(transition.actions).concat(entryActions), this.machine.options.actions);
6285
6285
  return actions;
6286
6286
  };
6287
- /**
6288
- * Determines the next state given the current `state` and sent `event`.
6289
- *
6290
- * @param state The current State instance or state value
6291
- * @param event The event that was sent at the current state
6292
- * @param context The current context (extended state) of the current state
6287
+ /**
6288
+ * Determines the next state given the current `state` and sent `event`.
6289
+ *
6290
+ * @param state The current State instance or state value
6291
+ * @param event The event that was sent at the current state
6292
+ * @param context The current context (extended state) of the current state
6293
6293
  */
6294
6294
 
6295
6295
 
@@ -6482,8 +6482,8 @@ function () {
6482
6482
  })));
6483
6483
  return maybeNextState;
6484
6484
  };
6485
- /**
6486
- * Returns the child state node from its relative `stateKey`, or throws.
6485
+ /**
6486
+ * Returns the child state node from its relative `stateKey`, or throws.
6487
6487
  */
6488
6488
 
6489
6489
 
@@ -6504,10 +6504,10 @@ function () {
6504
6504
 
6505
6505
  return result;
6506
6506
  };
6507
- /**
6508
- * Returns the state node with the given `stateId`, or throws.
6509
- *
6510
- * @param stateId The state ID. The prefix "#" is removed.
6507
+ /**
6508
+ * Returns the state node with the given `stateId`, or throws.
6509
+ *
6510
+ * @param stateId The state ID. The prefix "#" is removed.
6511
6511
  */
6512
6512
 
6513
6513
 
@@ -6526,10 +6526,10 @@ function () {
6526
6526
 
6527
6527
  return stateNode;
6528
6528
  };
6529
- /**
6530
- * Returns the relative state node from the given `statePath`, or throws.
6531
- *
6532
- * @param statePath The string or string array relative path to the state node.
6529
+ /**
6530
+ * Returns the relative state node from the given `statePath`, or throws.
6531
+ *
6532
+ * @param statePath The string or string array relative path to the state node.
6533
6533
  */
6534
6534
 
6535
6535
 
@@ -6557,10 +6557,10 @@ function () {
6557
6557
 
6558
6558
  return currentStateNode;
6559
6559
  };
6560
- /**
6561
- * Resolves a partial state value with its full representation in this machine.
6562
- *
6563
- * @param stateValue The partial state value to resolve.
6560
+ /**
6561
+ * Resolves a partial state value with its full representation in this machine.
6562
+ *
6563
+ * @param stateValue The partial state value to resolve.
6564
6564
  */
6565
6565
 
6566
6566
 
@@ -6664,9 +6664,9 @@ function () {
6664
6664
  };
6665
6665
 
6666
6666
  Object.defineProperty(StateNode.prototype, "initialState", {
6667
- /**
6668
- * The initial State instance, which includes all actions to be executed from
6669
- * entering the initial state.
6667
+ /**
6668
+ * The initial State instance, which includes all actions to be executed from
6669
+ * entering the initial state.
6670
6670
  */
6671
6671
  get: function () {
6672
6672
  this._init(); // TODO: this should be in the constructor (see note in constructor)
@@ -6684,9 +6684,9 @@ function () {
6684
6684
  configurable: true
6685
6685
  });
6686
6686
  Object.defineProperty(StateNode.prototype, "target", {
6687
- /**
6688
- * The target state value of the history state node, if it exists. This represents the
6689
- * default state value to transition to if no history value exists yet.
6687
+ /**
6688
+ * The target state value of the history state node, if it exists. This represents the
6689
+ * default state value to transition to if no history value exists yet.
6690
6690
  */
6691
6691
  get: function () {
6692
6692
  var target;
@@ -6706,12 +6706,12 @@ function () {
6706
6706
  enumerable: false,
6707
6707
  configurable: true
6708
6708
  });
6709
- /**
6710
- * Returns the leaf nodes from a state path relative to this state node.
6711
- *
6712
- * @param relativeStateId The relative state path to retrieve the state nodes
6713
- * @param history The previous state to retrieve history
6714
- * @param resolve Whether state nodes should resolve to initial child state nodes
6709
+ /**
6710
+ * Returns the leaf nodes from a state path relative to this state node.
6711
+ *
6712
+ * @param relativeStateId The relative state path to retrieve the state nodes
6713
+ * @param history The previous state to retrieve history
6714
+ * @param resolve Whether state nodes should resolve to initial child state nodes
6715
6715
  */
6716
6716
 
6717
6717
  StateNode.prototype.getRelativeStateNodes = function (relativeStateId, historyValue, resolve) {
@@ -6744,11 +6744,11 @@ function () {
6744
6744
  enumerable: false,
6745
6745
  configurable: true
6746
6746
  });
6747
- /**
6748
- * Retrieves state nodes from a relative path to this state node.
6749
- *
6750
- * @param relativePath The relative path from this state node
6751
- * @param historyValue
6747
+ /**
6748
+ * Retrieves state nodes from a relative path to this state node.
6749
+ *
6750
+ * @param relativePath The relative path from this state node
6751
+ * @param historyValue
6752
6752
  */
6753
6753
 
6754
6754
  StateNode.prototype.getFromRelativePath = function (relativePath) {
@@ -6796,11 +6796,11 @@ function () {
6796
6796
  })
6797
6797
  };
6798
6798
  };
6799
- /**
6800
- * Resolves to the historical value(s) of the parent state node,
6801
- * represented by state nodes.
6802
- *
6803
- * @param historyValue
6799
+ /**
6800
+ * Resolves to the historical value(s) of the parent state node,
6801
+ * represented by state nodes.
6802
+ *
6803
+ * @param historyValue
6804
6804
  */
6805
6805
 
6806
6806
 
@@ -6832,8 +6832,8 @@ function () {
6832
6832
  };
6833
6833
 
6834
6834
  Object.defineProperty(StateNode.prototype, "stateIds", {
6835
- /**
6836
- * All the state node IDs of this state node and its descendant state nodes.
6835
+ /**
6836
+ * All the state node IDs of this state node and its descendant state nodes.
6837
6837
  */
6838
6838
  get: function () {
6839
6839
  var _this = this;
@@ -6847,8 +6847,8 @@ function () {
6847
6847
  configurable: true
6848
6848
  });
6849
6849
  Object.defineProperty(StateNode.prototype, "events", {
6850
- /**
6851
- * All the event types accepted by this state node and its descendants.
6850
+ /**
6851
+ * All the event types accepted by this state node and its descendants.
6852
6852
  */
6853
6853
  get: function () {
6854
6854
  var e_7, _a, e_8, _b;
@@ -6904,10 +6904,10 @@ function () {
6904
6904
  configurable: true
6905
6905
  });
6906
6906
  Object.defineProperty(StateNode.prototype, "ownEvents", {
6907
- /**
6908
- * All the events that have transitions directly from this state node.
6909
- *
6910
- * Excludes any inert events.
6907
+ /**
6908
+ * All the events that have transitions directly from this state node.
6909
+ *
6910
+ * Excludes any inert events.
6911
6911
  */
6912
6912
  get: function () {
6913
6913
  var events = new Set(this.transitions.filter(function (transition) {
@@ -17162,52 +17162,38 @@ function error () {
17162
17162
  )
17163
17163
  }
17164
17164
 
17165
- const MY_FAVORITE = 'MyFavorite';
17166
- const GAME_SEARCH = 'GameSearch';
17167
-
17168
- var constant = /*#__PURE__*/Object.freeze({
17169
- __proto__: null,
17170
- MY_FAVORITE: MY_FAVORITE,
17171
- GAME_SEARCH: GAME_SEARCH
17172
- });
17165
+ // const UAParser = require('ua-parser-js')
17173
17166
 
17174
- // 對應 intersectionObserver 版本
17175
- function game_v2_1 (request) {
17167
+ function game (request) {
17176
17168
  return createMachine(
17177
17169
  {
17178
17170
  id: 'game',
17179
17171
  type: 'parallel',
17180
17172
  context: {
17181
- base: '/',
17182
- loadable: false,
17183
- isLastPage: false,
17173
+ roomId: null,
17184
17174
  room: null,
17185
- index: -1,
17186
- content: {
17187
- data: [],
17188
- timestamp: null,
17189
- parentCategoryId: null,
17190
- totalPage: 0,
17191
- },
17192
- additionEnable: false,
17193
- addition: {
17194
- data: [],
17195
- timestamp: null,
17196
- totalPage: 0,
17197
- },
17198
- staticData: [],
17175
+ list: [],
17176
+ gameList: [],
17199
17177
  // play params
17200
17178
  game: {
17201
- providerId: null,
17202
- gameId: null,
17203
- gameTypeId: null,
17204
- mappingId: null,
17179
+ provider: null,
17180
+ game_id: null,
17181
+ game_type: null,
17182
+ mapping_id: null,
17205
17183
  portrait: null,
17206
17184
  },
17207
17185
  lang: 'en_US',
17208
17186
  isMobile: new UAParser().getResult().device.type,
17209
17187
  gameURL: null,
17210
- ...oldContext,
17188
+ // game database
17189
+ sha: {
17190
+ category: null,
17191
+ status: null,
17192
+ },
17193
+ isCategoryChanged: false,
17194
+ isStatusChanged: false,
17195
+ statusMap: {},
17196
+ optionMap: {},
17211
17197
  },
17212
17198
  states: {
17213
17199
  flow: {
@@ -17216,19 +17202,12 @@ function game_v2_1 (request) {
17216
17202
  idle: {
17217
17203
  enter: 'clearGameInfo',
17218
17204
  on: {
17219
- SET_STATIC_DATA: {
17220
- actions: 'setStaticData',
17221
- },
17222
- SET_ADDITION_ENABLE: {
17223
- actions: 'setAdditionEnable',
17224
- },
17225
- LOAD: {
17226
- target: 'routing',
17227
- actions: 'setLoadable',
17228
- },
17229
17205
  SET_ROOM: {
17230
- cond: 'isDifferentRoom',
17231
- actions: ['setRoom', 'resetContent'],
17206
+ target: 'loading',
17207
+ actions: 'setRoom',
17208
+ cond: (context, event) => {
17209
+ return context.room?.id !== event.data?.id
17210
+ },
17232
17211
  },
17233
17212
  ENTER_GAME: {
17234
17213
  target: 'connecting',
@@ -17237,29 +17216,17 @@ function game_v2_1 (request) {
17237
17216
  },
17238
17217
  },
17239
17218
  loading: {
17240
- entry: 'increaseIndex',
17241
17219
  invoke: {
17242
- src: 'getPageContent',
17220
+ src: 'getRoomItems',
17243
17221
  onDone: {
17244
- target: 'routing',
17245
- actions: ['appendContent', 'setLastPage'],
17222
+ target: 'idle',
17223
+ actions: 'setList',
17246
17224
  },
17247
17225
  onError: {
17248
17226
  target: 'idle',
17227
+ actions: assign({ list: [] }),
17249
17228
  },
17250
17229
  },
17251
- on: {
17252
- LOAD: { actions: 'setLoadable' },
17253
- },
17254
- },
17255
- routing: {
17256
- always: [
17257
- {
17258
- target: 'loading',
17259
- cond: 'hasNext',
17260
- },
17261
- { target: 'idle' },
17262
- ],
17263
17230
  },
17264
17231
  connecting: {
17265
17232
  invoke: {
@@ -17294,36 +17261,6 @@ function game_v2_1 (request) {
17294
17261
  },
17295
17262
  },
17296
17263
  timer: {
17297
- initial: 'pending',
17298
- states: {
17299
- pending: {
17300
- after: {
17301
- 20000: [
17302
- {
17303
- target: 'updating',
17304
- cond: 'hasRoom',
17305
- },
17306
- {
17307
- target: 'pending',
17308
- },
17309
- ],
17310
- },
17311
- },
17312
- updating: {
17313
- invoke: {
17314
- src: 'updatePageContent',
17315
- onDone: {
17316
- target: 'pending',
17317
- actions: 'swapContent',
17318
- },
17319
- onError: {
17320
- target: 'pending',
17321
- },
17322
- },
17323
- },
17324
- },
17325
- },
17326
- oldTimer: {
17327
17264
  initial: 'fetchingGameSHA',
17328
17265
  states: {
17329
17266
  fetchingGameSHA: {
@@ -17339,7 +17276,11 @@ function game_v2_1 (request) {
17339
17276
  },
17340
17277
  },
17341
17278
  checking: {
17342
- always: [{ target: 'updatingStatus', cond: 'isStatusChanged' }, { target: 'pending' }],
17279
+ always: [
17280
+ { target: 'updatingStatus', cond: 'isStatusChanged' },
17281
+ { target: 'updatingCategory', cond: 'isCategoryChanged' },
17282
+ { target: 'pending' },
17283
+ ],
17343
17284
  },
17344
17285
  updatingStatus: {
17345
17286
  invoke: {
@@ -17357,7 +17298,7 @@ function game_v2_1 (request) {
17357
17298
  invoke: {
17358
17299
  src: 'fetchOption',
17359
17300
  onDone: {
17360
- target: 'pending',
17301
+ target: 'updatingCategory',
17361
17302
  actions: 'mergeOption',
17362
17303
  },
17363
17304
  onError: {
@@ -17365,6 +17306,18 @@ function game_v2_1 (request) {
17365
17306
  },
17366
17307
  },
17367
17308
  },
17309
+ updatingCategory: {
17310
+ invoke: {
17311
+ src: 'getRoomItems',
17312
+ onDone: {
17313
+ target: 'pending',
17314
+ actions: 'setList',
17315
+ },
17316
+ onError: {
17317
+ target: 'pending',
17318
+ },
17319
+ },
17320
+ },
17368
17321
  pending: {
17369
17322
  after: {
17370
17323
  20000: {
@@ -17378,95 +17331,39 @@ function game_v2_1 (request) {
17378
17331
  },
17379
17332
  {
17380
17333
  actions: {
17381
- setStaticData: assign((context, event) => {
17382
- return {
17383
- staticData: event.data,
17384
- }
17385
- }),
17386
- setAdditionEnable: assign((context, event) => {
17387
- return {
17388
- additionEnable: event.data,
17389
- }
17390
- }),
17391
- setLoadable: assign((context, event) => {
17392
- return {
17393
- loadable: event.data,
17394
- }
17395
- }),
17396
- setLastPage: assign((context, event) => {
17397
- const { index, content } = context;
17398
- return {
17399
- isLastPage: index >= content?.totalPage - 1,
17400
- }
17334
+ setRoomId: assign((context, event) => {
17335
+ return { roomId: event.roomId }
17401
17336
  }),
17402
17337
  setRoom: assign((context, event) => {
17403
17338
  return {
17404
17339
  room: event.data,
17340
+ roomId: event.data.id,
17405
17341
  }
17406
17342
  }),
17407
- resetContent: assign((context, event) => {
17408
- console.log('resetContent');
17409
- return {
17410
- loadable: false,
17411
- isLastPage: false,
17412
- index: -1,
17413
- content: {
17414
- data: [],
17415
- timestamp: null,
17416
- parentCategoryId: null,
17417
- totalPage: 0,
17418
- },
17419
- addition: {
17420
- data: [],
17421
- timestamp: null,
17422
- totalPage: 0,
17423
- },
17424
- }
17425
- }),
17426
- appendContent: assign((context, event) => {
17427
- const { room, additionEnable } = context;
17428
- if (room.categoryId === GAME_SEARCH) {
17429
- return
17430
- } else if (additionEnable) {
17431
- const [content, addition] = event.data;
17432
- return {
17433
- content: {
17434
- ...context.content,
17435
- ...content,
17436
- data: context.content.data.concat(content.data),
17437
- },
17438
- addition: {
17439
- ...context.addition,
17440
- ...addition,
17441
- data: context.addition.data.concat(addition.data),
17442
- },
17443
- }
17444
- } else {
17445
- const [content] = event.data;
17446
- return {
17447
- content: {
17448
- ...context.content,
17449
- ...content,
17450
- data: context.content.data.concat(content.data),
17451
- },
17452
- }
17453
- }
17454
- }),
17455
- swapContent: assign((context, event) => {
17456
- const [content, addition] = event.data;
17457
- let result = {};
17458
- if (content?.data?.length) {
17459
- result.content = content;
17460
- }
17461
- if (addition?.data?.length) {
17462
- result.addition = addition;
17463
- }
17464
- return result
17465
- }),
17466
- increaseIndex: assign((context, event) => {
17467
- return {
17468
- index: context.index + 1,
17469
- }
17343
+ setList: assign((context, event) => {
17344
+ const { statusMap, optionMap } = context;
17345
+ const { list = [] } = event.data;
17346
+ const gameList = list
17347
+ .map((item) => {
17348
+ if (item.id) {
17349
+ item.room = true;
17350
+ return item
17351
+ }
17352
+
17353
+ const code = item.g;
17354
+ if (!code || !optionMap[code]) {
17355
+ return
17356
+ }
17357
+
17358
+ return {
17359
+ ...optionMap[code],
17360
+ code,
17361
+ system_enable: statusMap[code][0],
17362
+ }
17363
+ })
17364
+ .filter((item) => item && !item.header)
17365
+ .sort((a, b) => a.system_enable - b.system_enable);
17366
+ return { list, gameList }
17470
17367
  }),
17471
17368
  setGameURL: assign({
17472
17369
  gameURL: (context, event) => {
@@ -17474,67 +17371,812 @@ function game_v2_1 (request) {
17474
17371
  },
17475
17372
  }),
17476
17373
  clearGameInfo: assign((context, event) => {
17477
- return { game: { providerId: null, gameId: null, gameTypeId: null, mappingId: null } }
17374
+ return { game: { provider: null, game_id: null, game_type: null, mapping_id: null } }
17478
17375
  }),
17479
17376
  setGameInfo: assign((context, event) => {
17480
- const { providerId, gameId, gameTypeId, mappingId, portrait } = event.data.game;
17481
- return { game: { providerId, gameId, gameTypeId, mappingId, portrait: portrait ? 1 : 0 } }
17377
+ const { provider, game_id, game_type, mapping_id, portrait } = event.data.game;
17378
+ return { game: { provider, game_id, game_type, mapping_id, portrait } }
17482
17379
  }),
17483
17380
  setLang: assign((context, event) => {
17484
17381
  const lang = event.data.locale.replace('-', '_');
17485
17382
  return { lang }
17486
17383
  }),
17487
- ...oldActions,
17488
- },
17489
- guards: {
17490
- isDifferentRoom: (context, event) => context.room?.categoryId !== event.data?.categoryId,
17491
- hasNext: (context, event) => {
17492
- const { loadable, isLastPage } = context;
17493
- return loadable && !isLastPage
17494
- },
17384
+ setGameSHA: assign((context, event) => {
17385
+ const { sha } = context;
17386
+ const newSha = event.data;
17387
+ return {
17388
+ sha: newSha,
17389
+ isCategoryChanged: !sha.category || sha.category !== newSha.category,
17390
+ isStatusChanged: !sha.status || sha.status !== newSha.status,
17391
+ }
17392
+ }),
17393
+ setStatus: assign((context, event) => {
17394
+ return {
17395
+ statusMap: event.data,
17396
+ }
17397
+ }),
17398
+ mergeOption: assign((context, event) => {
17399
+ const { optionMap } = context;
17400
+ return {
17401
+ optionMap: { ...optionMap, ...event.data },
17402
+ }
17403
+ }),
17404
+ },
17405
+ guards: {
17406
+ isCategoryChanged: (context, event) => context.isCategoryChanged,
17407
+ isStatusChanged: (context, event) => context.isStatusChanged,
17408
+ },
17409
+ services: {
17410
+ getRoomItems: async (context, event) => {
17411
+ return await request.send(game$1.getGameCategory({ id: context.roomId }))
17412
+ },
17413
+ connectGame: async (context, event) => {
17414
+ const { lang, isMobile } = context;
17415
+ const { provider, game_id, game_type, mapping_id } = context.game;
17416
+ const params = {
17417
+ provider_id: provider,
17418
+ game_id: game_id,
17419
+ gametype_id: game_type,
17420
+ mapping_id: mapping_id,
17421
+ is_demo: false,
17422
+ is_mobile: isMobile,
17423
+ lang,
17424
+ return_url: window.location.href,
17425
+ };
17426
+ const { redirect_url } = await request.send(game$1.playGame(params));
17427
+ return { gameURL: redirect_url }
17428
+ },
17429
+ disconnectGame: async (context, event) => {
17430
+ const uid_site = event.data;
17431
+ return await request.send(game$1.logoutGame({ uid_site, provider_id: context.game.provider }))
17432
+ },
17433
+ fetchOption: async (context, event) => {
17434
+ return await request.send(game$1.getOptionMap())
17435
+ },
17436
+ fetchGameSHA: async (context, event) => {
17437
+ return await request.send(game$1.getGameSHA())
17438
+ },
17439
+ fetchStatus: async (context, event) => {
17440
+ return await request.send(game$1.getGameStatus())
17441
+ },
17442
+ },
17443
+ }
17444
+ )
17445
+ }
17446
+
17447
+ const MY_FAVORITE = 'MyFavorite';
17448
+ const GAME_SEARCH = 'GameSearch';
17449
+
17450
+ var constant = /*#__PURE__*/Object.freeze({
17451
+ __proto__: null,
17452
+ MY_FAVORITE: MY_FAVORITE,
17453
+ GAME_SEARCH: GAME_SEARCH
17454
+ });
17455
+
17456
+ function game_v2 (request) {
17457
+ return createMachine(
17458
+ {
17459
+ id: 'game',
17460
+ type: 'parallel',
17461
+ context: {
17462
+ room: null,
17463
+ index: 0,
17464
+ content: {
17465
+ data: [],
17466
+ timestamp: null,
17467
+ parentCategoryId: null,
17468
+ totalPage: 1,
17469
+ },
17470
+ addition: {
17471
+ data: [],
17472
+ timestamp: null,
17473
+ totalPage: 1,
17474
+ },
17475
+ // play params
17476
+ game: {
17477
+ providerId: null,
17478
+ gameId: null,
17479
+ gameTypeId: null,
17480
+ mappingId: null,
17481
+ portrait: null,
17482
+ },
17483
+ lang: 'en_US',
17484
+ isMobile: new UAParser().getResult().device.type,
17485
+ gameURL: null,
17486
+ ...oldContext$1,
17487
+ },
17488
+ states: {
17489
+ flow: {
17490
+ initial: 'idle',
17491
+ states: {
17492
+ idle: {
17493
+ enter: 'clearGameInfo',
17494
+ on: {
17495
+ ENTER_ROOM: {
17496
+ target: 'loading',
17497
+ cond: 'isDifferentRoom',
17498
+ actions: ['setRoom', 'resetContent'],
17499
+ },
17500
+ NEXT_PAGE: {
17501
+ target: 'loading',
17502
+ cond: 'hasNext',
17503
+ actions: 'increaseIndex',
17504
+ },
17505
+ ENTER_GAME: {
17506
+ target: 'connecting',
17507
+ actions: ['setGameInfo', 'setLang'],
17508
+ },
17509
+ },
17510
+ },
17511
+ loading: {
17512
+ invoke: {
17513
+ src: 'getPageContent',
17514
+ onDone: {
17515
+ target: 'idle',
17516
+ actions: 'appendContent',
17517
+ },
17518
+ onError: {
17519
+ target: 'idle',
17520
+ },
17521
+ },
17522
+ },
17523
+ connecting: {
17524
+ invoke: {
17525
+ src: 'connectGame',
17526
+ onDone: {
17527
+ target: 'playing',
17528
+ actions: 'setGameURL',
17529
+ },
17530
+ onError: {
17531
+ target: 'idle',
17532
+ },
17533
+ },
17534
+ },
17535
+ playing: {
17536
+ on: {
17537
+ EXIT_GAME: {
17538
+ target: 'disconnect',
17539
+ },
17540
+ },
17541
+ },
17542
+ disconnect: {
17543
+ invoke: {
17544
+ src: 'disconnectGame',
17545
+ onDone: {
17546
+ target: 'idle',
17547
+ },
17548
+ onError: {
17549
+ target: 'idle',
17550
+ },
17551
+ },
17552
+ },
17553
+ },
17554
+ },
17555
+ timer: {
17556
+ initial: 'pending',
17557
+ states: {
17558
+ pending: {
17559
+ after: {
17560
+ 20000: [
17561
+ {
17562
+ target: 'updating',
17563
+ cond: 'hasRoom',
17564
+ },
17565
+ {
17566
+ target: 'pending',
17567
+ },
17568
+ ],
17569
+ },
17570
+ },
17571
+ updating: {
17572
+ invoke: {
17573
+ src: 'updatePageContent',
17574
+ onDone: {
17575
+ target: 'pending',
17576
+ actions: 'swapContent',
17577
+ },
17578
+ onError: {
17579
+ target: 'pending',
17580
+ },
17581
+ },
17582
+ },
17583
+ },
17584
+ },
17585
+ oldTimer: {
17586
+ initial: 'fetchingGameSHA',
17587
+ states: {
17588
+ fetchingGameSHA: {
17589
+ invoke: {
17590
+ src: 'fetchGameSHA',
17591
+ onDone: {
17592
+ target: 'checking',
17593
+ actions: 'setGameSHA',
17594
+ },
17595
+ onError: {
17596
+ target: 'pending',
17597
+ },
17598
+ },
17599
+ },
17600
+ checking: {
17601
+ always: [{ target: 'updatingStatus', cond: 'isStatusChanged' }, { target: 'pending' }],
17602
+ },
17603
+ updatingStatus: {
17604
+ invoke: {
17605
+ src: 'fetchStatus',
17606
+ onDone: {
17607
+ target: 'updatingOption',
17608
+ actions: ['setStatus'],
17609
+ },
17610
+ onError: {
17611
+ target: 'pending',
17612
+ },
17613
+ },
17614
+ },
17615
+ updatingOption: {
17616
+ invoke: {
17617
+ src: 'fetchOption',
17618
+ onDone: {
17619
+ target: 'pending',
17620
+ actions: 'mergeOption',
17621
+ },
17622
+ onError: {
17623
+ target: 'pending',
17624
+ },
17625
+ },
17626
+ },
17627
+ pending: {
17628
+ after: {
17629
+ 20000: {
17630
+ target: 'fetchingGameSHA',
17631
+ },
17632
+ },
17633
+ },
17634
+ },
17635
+ },
17636
+ },
17637
+ },
17638
+ {
17639
+ actions: {
17640
+ setFavoriteList: assign((context, event) => {
17641
+ return {
17642
+ favoriteList: event.data.data || [],
17643
+ }
17644
+ }),
17645
+ setRoom: assign((context, event) => {
17646
+ return {
17647
+ room: event.data,
17648
+ }
17649
+ }),
17650
+ resetContent: assign((context, event) => {
17651
+ return {
17652
+ index: 0,
17653
+ content: {
17654
+ data: [],
17655
+ timestamp: null,
17656
+ parentCategoryId: null,
17657
+ totalPage: 1,
17658
+ },
17659
+ addition: {
17660
+ data: [],
17661
+ timestamp: null,
17662
+ totalPage: 1,
17663
+ },
17664
+ }
17665
+ }),
17666
+ appendContent: assign((context, event) => {
17667
+ const { room, favoriteList } = context;
17668
+ if (room.categoryId === GAME_SEARCH) {
17669
+ return
17670
+ } else {
17671
+ const [content, addition] = event.data;
17672
+ return {
17673
+ content: {
17674
+ ...context.content,
17675
+ ...content,
17676
+ data: context.content.data.concat(content.data),
17677
+ },
17678
+ addition: {
17679
+ ...context.addition,
17680
+ ...addition,
17681
+ data: context.addition.data.concat(addition.data),
17682
+ },
17683
+ }
17684
+ }
17685
+ }),
17686
+ swapContent: assign((context, event) => {
17687
+ const [content, addition] = event.data;
17688
+ let result = {};
17689
+ if (content?.data?.length) {
17690
+ result.content = content;
17691
+ }
17692
+ if (addition?.data?.length) {
17693
+ result.addition = addition;
17694
+ }
17695
+ return result
17696
+ }),
17697
+ increaseIndex: assign((context, event) => {
17698
+ return {
17699
+ index: context.index + 1,
17700
+ }
17701
+ }),
17702
+ setGameURL: assign({
17703
+ gameURL: (context, event) => {
17704
+ return event.data.gameURL
17705
+ },
17706
+ }),
17707
+ clearGameInfo: assign((context, event) => {
17708
+ return { game: { providerId: null, gameId: null, gameTypeId: null, mappingId: null } }
17709
+ }),
17710
+ setGameInfo: assign((context, event) => {
17711
+ const { providerId, gameId, gameTypeId, mappingId, portrait } = event.data.game;
17712
+ return { game: { providerId, gameId, gameTypeId, mappingId, portrait: portrait ? 1 : 0 } }
17713
+ }),
17714
+ setLang: assign((context, event) => {
17715
+ const lang = event.data.locale.replace('-', '_');
17716
+ return { lang }
17717
+ }),
17718
+ ...oldActions$1,
17719
+ },
17720
+ guards: {
17721
+ isDifferentRoom: (context, event) => context.room?.categoryId !== event.data?.categoryId,
17722
+ hasNext: (context, event) => context.index < context?.content?.totalPage - 1,
17723
+ hasRoom: (context, event) => context.room?.categoryId,
17724
+ ...oldGuards$1,
17725
+ },
17726
+ services: {
17727
+ getPageContent: async (context, event) => {
17728
+ const { room, index } = context;
17729
+ if (room.categoryId === GAME_SEARCH) {
17730
+ return
17731
+ } else {
17732
+ const param = { categoryId: room.categoryId, index };
17733
+ return await Promise.all([request.send(game$1.getListCategory(param)), request.send(game$1.getListAddition(param))])
17734
+ }
17735
+ },
17736
+ updatePageContent: async (context, event) => {
17737
+ const { room, content, index } = context;
17738
+ if (room.categoryId === GAME_SEARCH) {
17739
+ return
17740
+ } else {
17741
+ return await Promise.all([
17742
+ request.send(
17743
+ game$1.getListCategoryByRange({
17744
+ categoryId: room.categoryId,
17745
+ end: index,
17746
+ timestamp: content.timestamp,
17747
+ })
17748
+ ),
17749
+ request.send(
17750
+ game$1.getListAdditionByRange({
17751
+ categoryId: room.categoryId,
17752
+ end: index,
17753
+ timestamp: content.timestamp,
17754
+ })
17755
+ ),
17756
+ ])
17757
+ }
17758
+ },
17759
+ connectGame: async (context, event) => {
17760
+ const { lang, isMobile } = context;
17761
+ const { providerId, gameId, gameTypeId, mappingId } = context.game;
17762
+ const params = {
17763
+ provider_id: providerId,
17764
+ game_id: gameId,
17765
+ gametype_id: gameTypeId,
17766
+ mapping_id: mappingId,
17767
+ is_demo: false,
17768
+ is_mobile: isMobile,
17769
+ lang,
17770
+ return_url: window.location.href,
17771
+ };
17772
+ const { redirect_url } = await request.send(game$1.playGame(params));
17773
+ return { gameURL: redirect_url }
17774
+ },
17775
+ disconnectGame: async (context, event) => {
17776
+ const uid_site = event.data;
17777
+ const provider_id = context.game.providerId;
17778
+ return await request.send(game$1.logoutGame({ uid_site, provider_id }))
17779
+ },
17780
+ ...oldServices$1(request),
17781
+ },
17782
+ }
17783
+ )
17784
+ }
17785
+
17786
+ const oldContext$1 = {
17787
+ sha: {
17788
+ status: null,
17789
+ },
17790
+ isStatusChanged: false,
17791
+ statusMap: {},
17792
+ optionMap: {},
17793
+ };
17794
+
17795
+ const oldActions$1 = {
17796
+ setGameSHA: assign((context, event) => {
17797
+ const { sha } = context;
17798
+ const newSha = event.data;
17799
+ return {
17800
+ sha: newSha,
17801
+ isStatusChanged: !sha.status || sha.status !== newSha.status,
17802
+ }
17803
+ }),
17804
+ setStatus: assign((context, event) => {
17805
+ return {
17806
+ statusMap: event.data,
17807
+ }
17808
+ }),
17809
+ mergeOption: assign((context, event) => {
17810
+ const { optionMap } = context;
17811
+ return {
17812
+ optionMap: { ...optionMap, ...event.data },
17813
+ }
17814
+ }),
17815
+ };
17816
+
17817
+ const oldGuards$1 = {
17818
+ isStatusChanged: (context, event) => context.isStatusChanged,
17819
+ };
17820
+
17821
+ const oldServices$1 = (request) => ({
17822
+ fetchOption: async (context, event) => {
17823
+ return await request.send(game$1.getOptionMap())
17824
+ },
17825
+ fetchGameSHA: async (context, event) => {
17826
+ return await request.send(game$1.getGameSHA())
17827
+ },
17828
+ fetchStatus: async (context, event) => {
17829
+ return await request.send(game$1.getGameStatus())
17830
+ },
17831
+ });
17832
+
17833
+ // 對應 intersectionObserver 版本
17834
+ function game_v2_1 (request) {
17835
+ return createMachine(
17836
+ {
17837
+ id: 'game',
17838
+ type: 'parallel',
17839
+ context: {
17840
+ base: '/',
17841
+ loadable: false,
17842
+ isLastPage: false,
17843
+ room: null,
17844
+ index: -1,
17845
+ content: {
17846
+ data: [],
17847
+ timestamp: null,
17848
+ parentCategoryId: null,
17849
+ totalPage: 0,
17850
+ },
17851
+ additionEnable: false,
17852
+ addition: {
17853
+ data: [],
17854
+ timestamp: null,
17855
+ totalPage: 0,
17856
+ },
17857
+ // play params
17858
+ game: {
17859
+ providerId: null,
17860
+ gameId: null,
17861
+ gameTypeId: null,
17862
+ mappingId: null,
17863
+ portrait: null,
17864
+ },
17865
+ lang: 'en_US',
17866
+ isMobile: new UAParser().getResult().device.type,
17867
+ gameURL: null,
17868
+ ...oldContext,
17869
+ },
17870
+ states: {
17871
+ flow: {
17872
+ initial: 'idle',
17873
+ states: {
17874
+ idle: {
17875
+ enter: 'clearGameInfo',
17876
+ on: {
17877
+ SET_ADDITION_ENABLE: {
17878
+ actions: 'setAdditionEnable',
17879
+ },
17880
+ LOAD: {
17881
+ target: 'routing',
17882
+ actions: 'setLoadable',
17883
+ },
17884
+ SET_ROOM: {
17885
+ cond: 'isDifferentRoom',
17886
+ actions: ['setRoom', 'resetContent'],
17887
+ },
17888
+ ENTER_GAME: {
17889
+ target: 'connecting',
17890
+ actions: ['setGameInfo', 'setLang'],
17891
+ },
17892
+ },
17893
+ },
17894
+ loading: {
17895
+ entry: 'increaseIndex',
17896
+ invoke: {
17897
+ src: 'getPageContent',
17898
+ onDone: {
17899
+ target: 'routing',
17900
+ actions: ['appendContent', 'setLastPage'],
17901
+ },
17902
+ onError: {
17903
+ target: 'idle',
17904
+ },
17905
+ },
17906
+ on: {
17907
+ LOAD: { actions: 'setLoadable' },
17908
+ },
17909
+ },
17910
+ routing: {
17911
+ always: [
17912
+ {
17913
+ target: 'loading',
17914
+ cond: 'hasNext',
17915
+ },
17916
+ { target: 'idle' },
17917
+ ],
17918
+ },
17919
+ connecting: {
17920
+ invoke: {
17921
+ src: 'connectGame',
17922
+ onDone: {
17923
+ target: 'playing',
17924
+ actions: 'setGameURL',
17925
+ },
17926
+ onError: {
17927
+ target: 'idle',
17928
+ },
17929
+ },
17930
+ },
17931
+ playing: {
17932
+ on: {
17933
+ EXIT_GAME: {
17934
+ target: 'disconnect',
17935
+ },
17936
+ },
17937
+ },
17938
+ disconnect: {
17939
+ invoke: {
17940
+ src: 'disconnectGame',
17941
+ onDone: {
17942
+ target: 'idle',
17943
+ },
17944
+ onError: {
17945
+ target: 'idle',
17946
+ },
17947
+ },
17948
+ },
17949
+ },
17950
+ },
17951
+ timer: {
17952
+ initial: 'pending',
17953
+ states: {
17954
+ pending: {
17955
+ after: {
17956
+ 20000: [
17957
+ {
17958
+ target: 'updating',
17959
+ cond: 'hasRoom',
17960
+ },
17961
+ {
17962
+ target: 'pending',
17963
+ },
17964
+ ],
17965
+ },
17966
+ },
17967
+ updating: {
17968
+ invoke: {
17969
+ src: 'updatePageContent',
17970
+ onDone: {
17971
+ target: 'pending',
17972
+ actions: 'swapContent',
17973
+ },
17974
+ onError: {
17975
+ target: 'pending',
17976
+ },
17977
+ },
17978
+ },
17979
+ },
17980
+ },
17981
+ oldTimer: {
17982
+ initial: 'fetchingGameSHA',
17983
+ states: {
17984
+ fetchingGameSHA: {
17985
+ invoke: {
17986
+ src: 'fetchGameSHA',
17987
+ onDone: {
17988
+ target: 'checking',
17989
+ actions: 'setGameSHA',
17990
+ },
17991
+ onError: {
17992
+ target: 'pending',
17993
+ },
17994
+ },
17995
+ },
17996
+ checking: {
17997
+ always: [{ target: 'updatingStatus', cond: 'isStatusChanged' }, { target: 'pending' }],
17998
+ },
17999
+ updatingStatus: {
18000
+ invoke: {
18001
+ src: 'fetchStatus',
18002
+ onDone: {
18003
+ target: 'updatingOption',
18004
+ actions: ['setStatus'],
18005
+ },
18006
+ onError: {
18007
+ target: 'pending',
18008
+ },
18009
+ },
18010
+ },
18011
+ updatingOption: {
18012
+ invoke: {
18013
+ src: 'fetchOption',
18014
+ onDone: {
18015
+ target: 'pending',
18016
+ actions: 'mergeOption',
18017
+ },
18018
+ onError: {
18019
+ target: 'pending',
18020
+ },
18021
+ },
18022
+ },
18023
+ pending: {
18024
+ after: {
18025
+ 20000: {
18026
+ target: 'fetchingGameSHA',
18027
+ },
18028
+ },
18029
+ },
18030
+ },
18031
+ },
18032
+ },
18033
+ },
18034
+ {
18035
+ actions: {
18036
+ setAdditionEnable: assign((context, event) => {
18037
+ return {
18038
+ additionEnable: event.data,
18039
+ }
18040
+ }),
18041
+ setLoadable: assign((context, event) => {
18042
+ return {
18043
+ loadable: event.data,
18044
+ }
18045
+ }),
18046
+ setLastPage: assign((context, event) => {
18047
+ const { index, content } = context;
18048
+ return {
18049
+ isLastPage: index >= content?.totalPage - 1,
18050
+ }
18051
+ }),
18052
+ setFavoriteList: assign((context, event) => {
18053
+ return {
18054
+ favoriteList: event.data.data || [],
18055
+ }
18056
+ }),
18057
+ setRoom: assign((context, event) => {
18058
+ return {
18059
+ room: event.data,
18060
+ }
18061
+ }),
18062
+ resetContent: assign((context, event) => {
18063
+ return {
18064
+ loadable: false,
18065
+ isLastPage: false,
18066
+ index: -1,
18067
+ content: {
18068
+ data: [],
18069
+ timestamp: null,
18070
+ parentCategoryId: null,
18071
+ totalPage: 0,
18072
+ },
18073
+ addition: {
18074
+ data: [],
18075
+ timestamp: null,
18076
+ totalPage: 0,
18077
+ },
18078
+ }
18079
+ }),
18080
+ appendContent: assign((context, event) => {
18081
+ const { room, additionEnable } = context;
18082
+ if (room.categoryId === GAME_SEARCH) {
18083
+ return
18084
+ } else if (additionEnable) {
18085
+ const [content, addition] = event.data;
18086
+ return {
18087
+ content: {
18088
+ ...context.content,
18089
+ ...content,
18090
+ data: context.content.data.concat(content.data),
18091
+ },
18092
+ addition: {
18093
+ ...context.addition,
18094
+ ...addition,
18095
+ data: context.addition.data.concat(addition.data),
18096
+ },
18097
+ }
18098
+ } else {
18099
+ const [content] = event.data;
18100
+ return {
18101
+ content: {
18102
+ ...context.content,
18103
+ ...content,
18104
+ data: context.content.data.concat(content.data),
18105
+ },
18106
+ }
18107
+ }
18108
+ }),
18109
+ swapContent: assign((context, event) => {
18110
+ const [content, addition] = event.data;
18111
+ let result = {};
18112
+ if (content?.data?.length) {
18113
+ result.content = content;
18114
+ }
18115
+ if (addition?.data?.length) {
18116
+ result.addition = addition;
18117
+ }
18118
+ return result
18119
+ }),
18120
+ increaseIndex: assign((context, event) => {
18121
+ return {
18122
+ index: context.index + 1,
18123
+ }
18124
+ }),
18125
+ setGameURL: assign({
18126
+ gameURL: (context, event) => {
18127
+ return event.data.gameURL
18128
+ },
18129
+ }),
18130
+ clearGameInfo: assign((context, event) => {
18131
+ return { game: { providerId: null, gameId: null, gameTypeId: null, mappingId: null } }
18132
+ }),
18133
+ setGameInfo: assign((context, event) => {
18134
+ const { providerId, gameId, gameTypeId, mappingId, portrait } = event.data.game;
18135
+ return { game: { providerId, gameId, gameTypeId, mappingId, portrait: portrait ? 1 : 0 } }
18136
+ }),
18137
+ setLang: assign((context, event) => {
18138
+ const lang = event.data.locale.replace('-', '_');
18139
+ return { lang }
18140
+ }),
18141
+ ...oldActions,
18142
+ },
18143
+ guards: {
18144
+ isDifferentRoom: (context, event) => context.room?.categoryId !== event.data?.categoryId,
18145
+ hasNext: (context, event) => {
18146
+ const { loadable, isLastPage } = context;
18147
+ return loadable && !isLastPage
18148
+ },
17495
18149
  hasRoom: (context, event) => context.room?.categoryId,
17496
18150
  ...oldGuards,
17497
18151
  },
17498
18152
  services: {
17499
18153
  getPageContent: async (context, event) => {
17500
- const { room, index, additionEnable, staticData } = context;
18154
+ const { room, index, additionEnable } = context;
17501
18155
  if (room.categoryId === GAME_SEARCH) {
17502
18156
  return
17503
- } else if (!request.getToken()) {
17504
- const list = staticData.find((data) => data.category == room.categoryId)?.info || [];
17505
-
17506
- return [
17507
- {
17508
- data: list.slice(index * 20, (index + 1) * 20),
17509
- totalPage: Math.ceil(list.length / 20),
17510
- timestamp: Math.floor(Date.now() / 1000),
17511
- },
17512
- ]
17513
18157
  } else if (additionEnable) {
17514
18158
  const param = { categoryId: room.categoryId, index };
17515
- return await Promise.all([request.send(game.getListCategory(param)), request.send(game.getListAddition(param))])
18159
+ return await Promise.all([request.send(game$1.getListCategory(param)), request.send(game$1.getListAddition(param))])
17516
18160
  } else {
17517
18161
  const param = { categoryId: room.categoryId, index };
17518
- return await Promise.all([request.send(game.getListCategory(param))])
18162
+ return await Promise.all([request.send(game$1.getListCategory(param))])
17519
18163
  }
17520
18164
  },
17521
18165
  updatePageContent: async (context, event) => {
17522
18166
  const { room, content, index, additionEnable } = context;
17523
18167
  if (room.categoryId === GAME_SEARCH) {
17524
18168
  return
17525
- } else if (!request.getToken()) {
17526
- return []
17527
18169
  } else if (additionEnable) {
17528
18170
  return await Promise.all([
17529
18171
  request.send(
17530
- game.getListCategoryByRange({
18172
+ game$1.getListCategoryByRange({
17531
18173
  categoryId: room.categoryId,
17532
18174
  end: index,
17533
18175
  timestamp: content.timestamp,
17534
18176
  })
17535
18177
  ),
17536
18178
  request.send(
17537
- game.getListAdditionByRange({
18179
+ game$1.getListAdditionByRange({
17538
18180
  categoryId: room.categoryId,
17539
18181
  end: index,
17540
18182
  timestamp: content.timestamp,
@@ -17544,7 +18186,7 @@ function game_v2_1 (request) {
17544
18186
  } else {
17545
18187
  return await Promise.all([
17546
18188
  request.send(
17547
- game.getListCategoryByRange({
18189
+ game$1.getListCategoryByRange({
17548
18190
  categoryId: room.categoryId,
17549
18191
  end: index,
17550
18192
  timestamp: content.timestamp,
@@ -17567,13 +18209,13 @@ function game_v2_1 (request) {
17567
18209
  lang,
17568
18210
  return_url: returnProviders.includes(providerId) ? `${window.location.origin}${context.base}return` : window.location.href, // For providers to return.
17569
18211
  };
17570
- const { redirect_url } = await request.send(game.playGame(params));
18212
+ const { redirect_url } = await request.send(game$1.playGame(params));
17571
18213
  return { gameURL: redirect_url }
17572
18214
  },
17573
18215
  disconnectGame: async (context, event) => {
17574
18216
  const uid_site = event.data;
17575
18217
  const provider_id = context.game.providerId;
17576
- return await request.send(game.logoutGame({ uid_site, provider_id }))
18218
+ return await request.send(game$1.logoutGame({ uid_site, provider_id }))
17577
18219
  },
17578
18220
  ...oldServices(request),
17579
18221
  },
@@ -17618,26 +18260,137 @@ const oldGuards = {
17618
18260
 
17619
18261
  const oldServices = (request) => ({
17620
18262
  fetchOption: async (context, event) => {
17621
- if (request.getToken()) {
17622
- return await request.send(game.getOptionMap())
17623
- }
18263
+ return await request.send(game$1.getOptionMap())
17624
18264
  },
17625
18265
  fetchGameSHA: async (context, event) => {
17626
- if (request.getToken()) {
17627
- return await request.send(game.getGameSHA())
17628
- } else {
17629
- return {
17630
- status: null,
17631
- }
17632
- }
18266
+ return await request.send(game$1.getGameSHA())
17633
18267
  },
17634
18268
  fetchStatus: async (context, event) => {
17635
- if (request.getToken()) {
17636
- return await request.send(game.getGameStatus())
17637
- }
18269
+ return await request.send(game$1.getGameStatus())
17638
18270
  },
17639
18271
  });
17640
18272
 
18273
+ function game_favorite (request) {
18274
+ return createMachine(
18275
+ {
18276
+ id: 'favorite',
18277
+ type: 'parallel',
18278
+ context: {
18279
+ list: [],
18280
+ },
18281
+ states: {
18282
+ fetching: {
18283
+ initial: 'disable',
18284
+ states: {
18285
+ disable: {},
18286
+ enable: {
18287
+ invoke: {
18288
+ src: 'fetchList',
18289
+ onDone: {
18290
+ actions: 'setList',
18291
+ },
18292
+ onError: {
18293
+ actions: assign({ list: [] }),
18294
+ },
18295
+ },
18296
+ },
18297
+ },
18298
+ },
18299
+ adding: {
18300
+ initial: 'disable',
18301
+ states: {
18302
+ disable: {},
18303
+ enable: {
18304
+ invoke: {
18305
+ src: 'add',
18306
+ onDone: {},
18307
+ onError: {
18308
+ actions: 'removeFromList',
18309
+ },
18310
+ },
18311
+ },
18312
+ },
18313
+ },
18314
+ removing: {
18315
+ initial: 'disable',
18316
+ states: {
18317
+ disable: {},
18318
+ enable: {
18319
+ invoke: {
18320
+ src: 'remove',
18321
+ onDone: {},
18322
+ onError: {
18323
+ actions: 'addToList',
18324
+ },
18325
+ },
18326
+ },
18327
+ },
18328
+ },
18329
+ },
18330
+ on: {
18331
+ FETCH_LIST: {
18332
+ target: 'fetching.enable',
18333
+ },
18334
+ ADD: {
18335
+ target: 'adding.enable',
18336
+ actions: 'addToList',
18337
+ cond: 'isNotExist',
18338
+ },
18339
+ REMOVE: {
18340
+ target: 'removing.enable',
18341
+ actions: 'removeFromList',
18342
+ cond: 'isExist',
18343
+ },
18344
+ },
18345
+ },
18346
+ {
18347
+ actions: {
18348
+ setList: assign((context, event) => {
18349
+ return {
18350
+ list: event.data,
18351
+ }
18352
+ }),
18353
+ addToList: assign((context, event) => {
18354
+ return {
18355
+ list: [...context.list, event.data],
18356
+ }
18357
+ }),
18358
+ removeFromList: assign((context, event) => {
18359
+ return {
18360
+ list: context.list.filter((item) => item !== event.data),
18361
+ }
18362
+ }),
18363
+ },
18364
+ guards: {
18365
+ isExist: (context, event) => context.list.includes(event.data),
18366
+ isNotExist: (context, event) => !context.list.includes(event.data),
18367
+ },
18368
+ services: {
18369
+ add: async (context, event) => {
18370
+ try {
18371
+ return await request.send(game$1.addFavoriteGame(event.data))
18372
+ } catch (error) {
18373
+ throw event.data
18374
+ }
18375
+ },
18376
+ remove: async (context, event) => {
18377
+ try {
18378
+ return await request.send(game$1.removeFavoriteGame(event.data))
18379
+ } catch (error) {
18380
+ throw event.data
18381
+ }
18382
+ },
18383
+ fetchList: async (context, event) => {
18384
+ const main = await request.send(game$1.getGameCategory({}));
18385
+ const room = main.list.find((item) => item.category === 'SYSTEM_MY_FAVORITE');
18386
+ const favorite = await request.send(game$1.getGameCategory({ id: room.id }));
18387
+ return favorite.list.map((item) => item.g)
18388
+ },
18389
+ },
18390
+ }
18391
+ )
18392
+ }
18393
+
17641
18394
  function game_favorite_v2 (request) {
17642
18395
  return createMachine(
17643
18396
  {
@@ -17732,7 +18485,7 @@ function game_favorite_v2 (request) {
17732
18485
  services: {
17733
18486
  add: async (context, event) => {
17734
18487
  try {
17735
- await request.send(game.addListFavorite(event.data.gameCode));
18488
+ await request.send(game$1.addListFavorite(event.data.gameCode));
17736
18489
  return event.data
17737
18490
  } catch (error) {
17738
18491
  throw event.data
@@ -17740,19 +18493,15 @@ function game_favorite_v2 (request) {
17740
18493
  },
17741
18494
  remove: async (context, event) => {
17742
18495
  try {
17743
- await request.send(game.removeListFavorite(event.data.gameCode));
18496
+ await request.send(game$1.removeListFavorite(event.data.gameCode));
17744
18497
  return event.data
17745
18498
  } catch (error) {
17746
18499
  throw event.data
17747
18500
  }
17748
18501
  },
17749
18502
  fetchList: async (context, event) => {
17750
- if (request.getToken()) {
17751
- const { data } = await request.send(game.getListMyFavorite());
17752
- return data
17753
- } else {
17754
- return []
17755
- }
18503
+ const { data } = await request.send(game$1.getListMyFavorite());
18504
+ return data
17756
18505
  },
17757
18506
  },
17758
18507
  }
@@ -17984,17 +18733,17 @@ function game_search (request) {
17984
18733
  services: {
17985
18734
  fetchTags: async (context, event) => {
17986
18735
  const { keyword } = context;
17987
- const { result } = await request.send(game.getGameTags({ q: keyword }));
18736
+ const { result } = await request.send(game$1.getGameTags({ q: keyword }));
17988
18737
  return result
17989
18738
  },
17990
18739
  fetchGames: async (context, event) => {
17991
18740
  const { tagId, tagIndex, keyword, click, clickDefault } = context;
17992
- const { traceId, result } = await request.send(game.getGameSearchList({ id: tagId, index: tagIndex, q: keyword, click, clickDefault }));
18741
+ const { traceId, result } = await request.send(game$1.getGameSearchList({ id: tagId, index: tagIndex, q: keyword, click, clickDefault }));
17993
18742
  return { traceId, result }
17994
18743
  },
17995
18744
  sendTrace: async (context, event) => {
17996
18745
  const { traceId, tagId, tagIndex, gameCode, gameCodeIndex, keyword: query, click, clickDefault } = context;
17997
- return await request.send(game.setGameSearchTrace({ traceId, tagId, tagIndex, gameCode, gameCodeIndex, query, click, clickDefault }))
18746
+ return await request.send(game$1.setGameSearchTrace({ traceId, tagId, tagIndex, gameCode, gameCodeIndex, query, click, clickDefault }))
17998
18747
  },
17999
18748
  },
18000
18749
  }
@@ -18327,16 +19076,16 @@ function game_search_v2 (request) {
18327
19076
  services: {
18328
19077
  fetchTags: async (context, event) => {
18329
19078
  const { keyword } = context;
18330
- const { result } = await request.send(game.getGameTags({ q: keyword }));
19079
+ const { result } = await request.send(game$1.getGameTags({ q: keyword }));
18331
19080
  return result
18332
19081
  },
18333
19082
  fetchInitialData: async (context, event) => {
18334
- const data = await request.send(game.getGameSearchHome());
19083
+ const data = await request.send(game$1.getGameSearchHome());
18335
19084
  return data
18336
19085
  },
18337
19086
  fetchGames: async (context, event) => {
18338
19087
  const { tagId, tagIndex, keyword, click, clickDefault } = context;
18339
- const { traceId, result } = await request.send(game.getGameSearchList({ id: tagId, index: tagIndex, q: keyword, click, clickDefault }));
19088
+ const { traceId, result } = await request.send(game$1.getGameSearchList({ id: tagId, index: tagIndex, q: keyword, click, clickDefault }));
18340
19089
  return { traceId, result }
18341
19090
  },
18342
19091
  sendTrace: async (context, event) => {
@@ -18358,7 +19107,7 @@ function game_search_v2 (request) {
18358
19107
  id = null;
18359
19108
  }
18360
19109
  return await request.send(
18361
- game.setGameSearchTrace({
19110
+ game$1.setGameSearchTrace({
18362
19111
  traceId,
18363
19112
  tagId: id,
18364
19113
  tagIndex,
@@ -18439,12 +19188,12 @@ function game_hot_new (request) {
18439
19188
  },
18440
19189
  services: {
18441
19190
  getRoomItems: async (context, event) => {
18442
- return await request.send(game.getGameCategory({ id: context.roomId }))
19191
+ return await request.send(game$1.getGameCategory({ id: context.roomId }))
18443
19192
  },
18444
19193
  getGames: async (context, event) => {
18445
19194
  const [resHot, resNew] = await Promise.all([
18446
- request.send(game.getGameCategory({ id: context.hot.id })),
18447
- request.send(game.getGameCategory({ id: context.new.id })),
19195
+ request.send(game$1.getGameCategory({ id: context.hot.id })),
19196
+ request.send(game$1.getGameCategory({ id: context.new.id })),
18448
19197
  ]);
18449
19198
  const hotGames = resHot?.list?.map?.((item) => item.g);
18450
19199
  const newGames = resNew?.list?.map?.((item) => item.g);
@@ -19284,7 +20033,7 @@ function side (request) {
19284
20033
  },
19285
20034
  services: {
19286
20035
  getRoomItems: async (context, event) => {
19287
- return await request.send(game.getGameCategory({ id: context.room?.id }))
20036
+ return await request.send(game$1.getGameCategory({ id: context.room?.id }))
19288
20037
  },
19289
20038
  },
19290
20039
  }
@@ -19448,10 +20197,10 @@ function side_v2 (request) {
19448
20197
  },
19449
20198
  services: {
19450
20199
  getMenu: async (context, event) => {
19451
- return await request.send(game.getListRoot())
20200
+ return await request.send(game$1.getListRoot())
19452
20201
  },
19453
20202
  fetchUpdateMenu: async (context, event) => {
19454
- return await request.send(game.getListRoot({ timestamp: context.menu.timestamp }))
20203
+ return await request.send(game$1.getListRoot({ timestamp: context.menu.timestamp }))
19455
20204
  },
19456
20205
  },
19457
20206
  }
@@ -27522,6 +28271,9 @@ var index$1 = {
27522
28271
  common,
27523
28272
  deposit,
27524
28273
  error,
28274
+ game,
28275
+ game_v2,
28276
+ game_favorite,
27525
28277
  game_favorite_v2,
27526
28278
  game_search,
27527
28279
  game_search_v2,
@@ -27576,8 +28328,8 @@ class Request {
27576
28328
  this.axios.interceptors.request.use((axiosConfig) => {
27577
28329
  axiosConfig.headers['X-TH1GAMES-VERSION'] = this.config.version;
27578
28330
  axiosConfig.headers['X-TH1GAMES-PLATFORM'] = this.config.platform;
27579
- if (this.getToken()) {
27580
- axiosConfig.headers.Authorization = this.getToken();
28331
+ if (storage.get(this.key)) {
28332
+ axiosConfig.headers.Authorization = storage.get(this.key);
27581
28333
  }
27582
28334
  return axiosConfig
27583
28335
  });
@@ -27605,7 +28357,7 @@ class Request {
27605
28357
  async send(req, customToken) {
27606
28358
  try {
27607
28359
  const cancelToken = customToken || this.source.token;
27608
- this._checkToken(req);
28360
+ this._checkToken(req, storage.get(this.key));
27609
28361
  const requestConfig = this._createConfig(req, cancelToken);
27610
28362
  const { data } = await this.axios.request(requestConfig);
27611
28363
  return data
@@ -27651,16 +28403,12 @@ class Request {
27651
28403
  }
27652
28404
  }
27653
28405
 
27654
- _checkToken(req) {
27655
- if (!req.isPublic && !this.getToken()) {
28406
+ _checkToken(req, token) {
28407
+ if (!req.isPublic && !token) {
27656
28408
  console.error(req);
27657
28409
  throw { code: 'ERR_A103', url: req.url }
27658
28410
  }
27659
28411
  }
27660
-
27661
- getToken() {
27662
- return storage.get(this.key)
27663
- }
27664
28412
  }
27665
28413
 
27666
28414
  // const urljoin = require('url-join')