xstate 5.0.0-alpha.6 → 5.0.0-beta.7
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/actions/dist/xstate-actions.cjs.dev.js +1 -1
- package/actions/dist/xstate-actions.cjs.prod.js +1 -1
- package/actions/dist/xstate-actions.esm.js +1 -1
- package/actions/dist/xstate-actions.umd.min.js.map +1 -1
- package/actors/dist/xstate-actors.cjs.dev.js +1 -1
- package/actors/dist/xstate-actors.cjs.prod.js +1 -1
- package/actors/dist/xstate-actors.esm.js +1 -1
- package/actors/dist/xstate-actors.umd.min.js.map +1 -1
- package/dist/{actions-bf7bb1c5.cjs.dev.js → actions-0fcf4fd9.cjs.dev.js} +6 -6
- package/dist/{actions-c46e4911.cjs.prod.js → actions-a1a641d3.cjs.prod.js} +6 -6
- package/dist/{actions-41b74cdc.esm.js → actions-b334e916.esm.js} +6 -6
- package/dist/declarations/src/types.d.ts +2 -2
- package/dist/xstate.cjs.dev.js +3 -3
- package/dist/xstate.cjs.prod.js +3 -3
- package/dist/xstate.esm.js +4 -4
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/guards/dist/xstate-guards.cjs.dev.js +1 -1
- package/guards/dist/xstate-guards.cjs.prod.js +1 -1
- package/guards/dist/xstate-guards.esm.js +1 -1
- package/guards/dist/xstate-guards.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -2291,9 +2291,9 @@ function getDelayedTransitions(stateNode) {
|
|
|
2291
2291
|
});
|
|
2292
2292
|
}
|
|
2293
2293
|
function formatTransition(stateNode, transitionConfig) {
|
|
2294
|
-
var _transitionConfig$
|
|
2294
|
+
var _transitionConfig$ree;
|
|
2295
2295
|
var normalizedTarget = normalizeTarget(transitionConfig.target);
|
|
2296
|
-
var
|
|
2296
|
+
var reenter = (_transitionConfig$ree = transitionConfig.reenter) !== null && _transitionConfig$ree !== void 0 ? _transitionConfig$ree : false;
|
|
2297
2297
|
var guards = stateNode.machine.options.guards;
|
|
2298
2298
|
var target = resolveTarget(stateNode, normalizedTarget);
|
|
2299
2299
|
|
|
@@ -2308,7 +2308,7 @@ function formatTransition(stateNode, transitionConfig) {
|
|
|
2308
2308
|
}) : undefined,
|
|
2309
2309
|
target: target,
|
|
2310
2310
|
source: stateNode,
|
|
2311
|
-
|
|
2311
|
+
reenter: reenter,
|
|
2312
2312
|
eventType: transitionConfig.event,
|
|
2313
2313
|
toJSON: function toJSON() {
|
|
2314
2314
|
return _objectSpread2(_objectSpread2({}, transition), {}, {
|
|
@@ -2395,7 +2395,7 @@ function formatInitialTransition(stateNode, _target) {
|
|
|
2395
2395
|
source: stateNode,
|
|
2396
2396
|
actions: [],
|
|
2397
2397
|
eventType: null,
|
|
2398
|
-
|
|
2398
|
+
reenter: false,
|
|
2399
2399
|
target: resolvedTarget,
|
|
2400
2400
|
toJSON: function toJSON() {
|
|
2401
2401
|
return _objectSpread2(_objectSpread2({}, transition), {}, {
|
|
@@ -2818,7 +2818,7 @@ function getTransitionDomain(transition, historyValue) {
|
|
|
2818
2818
|
if (!targetStates) {
|
|
2819
2819
|
return null;
|
|
2820
2820
|
}
|
|
2821
|
-
if (!transition.
|
|
2821
|
+
if (!transition.reenter && transition.source.type !== 'parallel' && targetStates.every(function (targetStateNode) {
|
|
2822
2822
|
return isDescendant(targetStateNode, transition.source);
|
|
2823
2823
|
})) {
|
|
2824
2824
|
return transition.source;
|
|
@@ -2888,7 +2888,7 @@ function microstep(transitions, currentState, actorCtx, scxmlEvent) {
|
|
|
2888
2888
|
var microstate = microstepProcedure(currentState._initial ? [{
|
|
2889
2889
|
target: _toConsumableArray(currentState.configuration).filter(isAtomicStateNode),
|
|
2890
2890
|
source: machine.root,
|
|
2891
|
-
|
|
2891
|
+
reenter: true,
|
|
2892
2892
|
actions: [],
|
|
2893
2893
|
eventType: null,
|
|
2894
2894
|
toJSON: null // TODO: fix
|
|
@@ -2264,9 +2264,9 @@ function getDelayedTransitions(stateNode) {
|
|
|
2264
2264
|
});
|
|
2265
2265
|
}
|
|
2266
2266
|
function formatTransition(stateNode, transitionConfig) {
|
|
2267
|
-
var _transitionConfig$
|
|
2267
|
+
var _transitionConfig$ree;
|
|
2268
2268
|
var normalizedTarget = normalizeTarget(transitionConfig.target);
|
|
2269
|
-
var
|
|
2269
|
+
var reenter = (_transitionConfig$ree = transitionConfig.reenter) !== null && _transitionConfig$ree !== void 0 ? _transitionConfig$ree : false;
|
|
2270
2270
|
var guards = stateNode.machine.options.guards;
|
|
2271
2271
|
var target = resolveTarget(stateNode, normalizedTarget);
|
|
2272
2272
|
var transition = _objectSpread2(_objectSpread2({}, transitionConfig), {}, {
|
|
@@ -2276,7 +2276,7 @@ function formatTransition(stateNode, transitionConfig) {
|
|
|
2276
2276
|
}) : undefined,
|
|
2277
2277
|
target: target,
|
|
2278
2278
|
source: stateNode,
|
|
2279
|
-
|
|
2279
|
+
reenter: reenter,
|
|
2280
2280
|
eventType: transitionConfig.event,
|
|
2281
2281
|
toJSON: function toJSON() {
|
|
2282
2282
|
return _objectSpread2(_objectSpread2({}, transition), {}, {
|
|
@@ -2363,7 +2363,7 @@ function formatInitialTransition(stateNode, _target) {
|
|
|
2363
2363
|
source: stateNode,
|
|
2364
2364
|
actions: [],
|
|
2365
2365
|
eventType: null,
|
|
2366
|
-
|
|
2366
|
+
reenter: false,
|
|
2367
2367
|
target: resolvedTarget,
|
|
2368
2368
|
toJSON: function toJSON() {
|
|
2369
2369
|
return _objectSpread2(_objectSpread2({}, transition), {}, {
|
|
@@ -2786,7 +2786,7 @@ function getTransitionDomain(transition, historyValue) {
|
|
|
2786
2786
|
if (!targetStates) {
|
|
2787
2787
|
return null;
|
|
2788
2788
|
}
|
|
2789
|
-
if (!transition.
|
|
2789
|
+
if (!transition.reenter && transition.source.type !== 'parallel' && targetStates.every(function (targetStateNode) {
|
|
2790
2790
|
return isDescendant(targetStateNode, transition.source);
|
|
2791
2791
|
})) {
|
|
2792
2792
|
return transition.source;
|
|
@@ -2856,7 +2856,7 @@ function microstep(transitions, currentState, actorCtx, scxmlEvent) {
|
|
|
2856
2856
|
var microstate = microstepProcedure(currentState._initial ? [{
|
|
2857
2857
|
target: _toConsumableArray(currentState.configuration).filter(isAtomicStateNode),
|
|
2858
2858
|
source: machine.root,
|
|
2859
|
-
|
|
2859
|
+
reenter: true,
|
|
2860
2860
|
actions: [],
|
|
2861
2861
|
eventType: null,
|
|
2862
2862
|
toJSON: null // TODO: fix
|
|
@@ -2323,9 +2323,9 @@ function getDelayedTransitions(stateNode) {
|
|
|
2323
2323
|
});
|
|
2324
2324
|
}
|
|
2325
2325
|
function formatTransition(stateNode, transitionConfig) {
|
|
2326
|
-
var _transitionConfig$
|
|
2326
|
+
var _transitionConfig$ree;
|
|
2327
2327
|
var normalizedTarget = normalizeTarget(transitionConfig.target);
|
|
2328
|
-
var
|
|
2328
|
+
var reenter = (_transitionConfig$ree = transitionConfig.reenter) !== null && _transitionConfig$ree !== void 0 ? _transitionConfig$ree : false;
|
|
2329
2329
|
var guards = stateNode.machine.options.guards;
|
|
2330
2330
|
var target = resolveTarget(stateNode, normalizedTarget);
|
|
2331
2331
|
|
|
@@ -2340,7 +2340,7 @@ function formatTransition(stateNode, transitionConfig) {
|
|
|
2340
2340
|
}) : undefined,
|
|
2341
2341
|
target: target,
|
|
2342
2342
|
source: stateNode,
|
|
2343
|
-
|
|
2343
|
+
reenter: reenter,
|
|
2344
2344
|
eventType: transitionConfig.event,
|
|
2345
2345
|
toJSON: function toJSON() {
|
|
2346
2346
|
return _objectSpread2(_objectSpread2({}, transition), {}, {
|
|
@@ -2427,7 +2427,7 @@ function formatInitialTransition(stateNode, _target) {
|
|
|
2427
2427
|
source: stateNode,
|
|
2428
2428
|
actions: [],
|
|
2429
2429
|
eventType: null,
|
|
2430
|
-
|
|
2430
|
+
reenter: false,
|
|
2431
2431
|
target: resolvedTarget,
|
|
2432
2432
|
toJSON: function toJSON() {
|
|
2433
2433
|
return _objectSpread2(_objectSpread2({}, transition), {}, {
|
|
@@ -2850,7 +2850,7 @@ function getTransitionDomain(transition, historyValue) {
|
|
|
2850
2850
|
if (!targetStates) {
|
|
2851
2851
|
return null;
|
|
2852
2852
|
}
|
|
2853
|
-
if (!transition.
|
|
2853
|
+
if (!transition.reenter && transition.source.type !== 'parallel' && targetStates.every(function (targetStateNode) {
|
|
2854
2854
|
return isDescendant(targetStateNode, transition.source);
|
|
2855
2855
|
})) {
|
|
2856
2856
|
return transition.source;
|
|
@@ -2920,7 +2920,7 @@ function microstep(transitions, currentState, actorCtx, scxmlEvent) {
|
|
|
2920
2920
|
var microstate = microstepProcedure(currentState._initial ? [{
|
|
2921
2921
|
target: _toConsumableArray(currentState.configuration).filter(isAtomicStateNode),
|
|
2922
2922
|
source: machine.root,
|
|
2923
|
-
|
|
2923
|
+
reenter: true,
|
|
2924
2924
|
actions: [],
|
|
2925
2925
|
eventType: null,
|
|
2926
2926
|
toJSON: null // TODO: fix
|
|
@@ -161,7 +161,7 @@ export type TransitionTarget = SingleOrArray<string>;
|
|
|
161
161
|
export interface TransitionConfig<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject = TExpressionEvent, TAction extends ParameterizedObject = ParameterizedObject> {
|
|
162
162
|
guard?: GuardConfig<TContext, TExpressionEvent>;
|
|
163
163
|
actions?: BaseActions<TContext, TExpressionEvent, TEvent, TAction>;
|
|
164
|
-
|
|
164
|
+
reenter?: boolean;
|
|
165
165
|
target?: TransitionTarget | undefined;
|
|
166
166
|
meta?: Record<string, any>;
|
|
167
167
|
description?: string;
|
|
@@ -731,7 +731,7 @@ export interface TransitionDefinition<TContext extends MachineContext, TEvent ex
|
|
|
731
731
|
target: Array<StateNode<TContext, TEvent>> | undefined;
|
|
732
732
|
source: StateNode<TContext, TEvent>;
|
|
733
733
|
actions: BaseActionObject[];
|
|
734
|
-
|
|
734
|
+
reenter: boolean;
|
|
735
735
|
guard?: GuardDefinition<TContext, TEvent>;
|
|
736
736
|
eventType: TEvent['type'] | '*';
|
|
737
737
|
toJSON: () => {
|
package/dist/xstate.cjs.dev.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var actors_dist_xstateActors = require('./actions-
|
|
5
|
+
var actors_dist_xstateActors = require('./actions-0fcf4fd9.cjs.dev.js');
|
|
6
6
|
require('./index-ebaab3c9.cjs.dev.js');
|
|
7
7
|
|
|
8
8
|
function pure(getActions) {
|
|
@@ -176,7 +176,7 @@ var StateNode = /*#__PURE__*/function () {
|
|
|
176
176
|
source: this,
|
|
177
177
|
actions: this.initial.actions,
|
|
178
178
|
eventType: null,
|
|
179
|
-
|
|
179
|
+
reenter: false,
|
|
180
180
|
toJSON: function toJSON() {
|
|
181
181
|
return {
|
|
182
182
|
target: _this3.initial.target.map(function (t) {
|
|
@@ -400,7 +400,7 @@ var StateNode = /*#__PURE__*/function () {
|
|
|
400
400
|
key: "ownEvents",
|
|
401
401
|
get: function get() {
|
|
402
402
|
var events = new Set(this.transitions.filter(function (transition) {
|
|
403
|
-
return !(!transition.target && !transition.actions.length && !transition.
|
|
403
|
+
return !(!transition.target && !transition.actions.length && !transition.reenter);
|
|
404
404
|
}).map(function (transition) {
|
|
405
405
|
return transition.eventType;
|
|
406
406
|
}));
|
package/dist/xstate.cjs.prod.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var actors_dist_xstateActors = require('./actions-
|
|
5
|
+
var actors_dist_xstateActors = require('./actions-a1a641d3.cjs.prod.js');
|
|
6
6
|
require('../dev/dist/xstate-dev.cjs.prod.js');
|
|
7
7
|
|
|
8
8
|
function pure(getActions) {
|
|
@@ -176,7 +176,7 @@ var StateNode = /*#__PURE__*/function () {
|
|
|
176
176
|
source: this,
|
|
177
177
|
actions: this.initial.actions,
|
|
178
178
|
eventType: null,
|
|
179
|
-
|
|
179
|
+
reenter: false,
|
|
180
180
|
toJSON: function toJSON() {
|
|
181
181
|
return {
|
|
182
182
|
target: _this3.initial.target.map(function (t) {
|
|
@@ -400,7 +400,7 @@ var StateNode = /*#__PURE__*/function () {
|
|
|
400
400
|
key: "ownEvents",
|
|
401
401
|
get: function get() {
|
|
402
402
|
var events = new Set(this.transitions.filter(function (transition) {
|
|
403
|
-
return !(!transition.target && !transition.actions.length && !transition.
|
|
403
|
+
return !(!transition.target && !transition.actions.length && !transition.reenter);
|
|
404
404
|
}).map(function (transition) {
|
|
405
405
|
return transition.eventType;
|
|
406
406
|
}));
|
package/dist/xstate.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as createDynamicAction, p as pure$1, t as toArray, a as toActionObjects, _ as _createClass, f as formatTransitions, b as toTransitionConfigArray, N as NULL_EVENT, d as formatTransition, m as mapValues, e as memo, g as _createForOfIteratorHelper, h as evaluateGuard, i as _toConsumableArray, j as flatten, k as _classCallCheck, l as _defineProperty, n as createInvokeId, o as toInvokeConfig, q as _objectSpread2, r as invoke, s as _objectWithoutProperties, u as getDelayedTransitions, v as formatInitialTransition, w as getCandidates, x as isString, y as createSpawner, z as createInitEvent, A as getConfiguration, B as getStateNodes, C as resolveStateValue, D as isInFinalState, S as State, E as toSCXMLEvent, F as isSCXMLErrorEvent, G as macrostep, H as transitionNode, I as _slicedToArray, J as getInitialConfiguration, K as resolveActionsAndContext, L as microstep, M as error, O as isStateId, P as getStateNodeByPath, Q as getPersistedState, R as resolveReferencedActor, T as interpret, U as STATE_DELIMITER, V as initEvent, W as matchesState, X as raise, Y as send, Z as sendParent, $ as sendTo, a0 as log, a1 as cancel, a2 as stop, a3 as assign, a4 as after, a5 as done, a6 as respond, a7 as forwardTo, a8 as escalate, a9 as choose } from './actions-
|
|
2
|
-
export { af as ActionTypes, aa as Interpreter, ab as InterpreterStatus, ag as SpecialTargets, S as State, a3 as assign, ac as doneInvoke, a7 as forwardTo, B as getStateNodes, T as interpret, W as matchesState, ad as pathToStateValue, Y as send, Z as sendParent, $ as sendTo, ae as toObserver, E as toSCXMLEvent } from './actions-
|
|
1
|
+
import { c as createDynamicAction, p as pure$1, t as toArray, a as toActionObjects, _ as _createClass, f as formatTransitions, b as toTransitionConfigArray, N as NULL_EVENT, d as formatTransition, m as mapValues, e as memo, g as _createForOfIteratorHelper, h as evaluateGuard, i as _toConsumableArray, j as flatten, k as _classCallCheck, l as _defineProperty, n as createInvokeId, o as toInvokeConfig, q as _objectSpread2, r as invoke, s as _objectWithoutProperties, u as getDelayedTransitions, v as formatInitialTransition, w as getCandidates, x as isString, y as createSpawner, z as createInitEvent, A as getConfiguration, B as getStateNodes, C as resolveStateValue, D as isInFinalState, S as State, E as toSCXMLEvent, F as isSCXMLErrorEvent, G as macrostep, H as transitionNode, I as _slicedToArray, J as getInitialConfiguration, K as resolveActionsAndContext, L as microstep, M as error, O as isStateId, P as getStateNodeByPath, Q as getPersistedState, R as resolveReferencedActor, T as interpret, U as STATE_DELIMITER, V as initEvent, W as matchesState, X as raise, Y as send, Z as sendParent, $ as sendTo, a0 as log, a1 as cancel, a2 as stop, a3 as assign, a4 as after, a5 as done, a6 as respond, a7 as forwardTo, a8 as escalate, a9 as choose } from './actions-b334e916.esm.js';
|
|
2
|
+
export { af as ActionTypes, aa as Interpreter, ab as InterpreterStatus, ag as SpecialTargets, S as State, a3 as assign, ac as doneInvoke, a7 as forwardTo, B as getStateNodes, T as interpret, W as matchesState, ad as pathToStateValue, Y as send, Z as sendParent, $ as sendTo, ae as toObserver, E as toSCXMLEvent } from './actions-b334e916.esm.js';
|
|
3
3
|
import './index-50bd0aff.esm.js';
|
|
4
4
|
|
|
5
5
|
function pure(getActions) {
|
|
@@ -173,7 +173,7 @@ var StateNode = /*#__PURE__*/function () {
|
|
|
173
173
|
source: this,
|
|
174
174
|
actions: this.initial.actions,
|
|
175
175
|
eventType: null,
|
|
176
|
-
|
|
176
|
+
reenter: false,
|
|
177
177
|
toJSON: function toJSON() {
|
|
178
178
|
return {
|
|
179
179
|
target: _this3.initial.target.map(function (t) {
|
|
@@ -397,7 +397,7 @@ var StateNode = /*#__PURE__*/function () {
|
|
|
397
397
|
key: "ownEvents",
|
|
398
398
|
get: function get() {
|
|
399
399
|
var events = new Set(this.transitions.filter(function (transition) {
|
|
400
|
-
return !(!transition.target && !transition.actions.length && !transition.
|
|
400
|
+
return !(!transition.target && !transition.actions.length && !transition.reenter);
|
|
401
401
|
}).map(function (transition) {
|
|
402
402
|
return transition.eventType;
|
|
403
403
|
}));
|
package/dist/xstate.umd.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).XState={})}(this,(function(t){"use strict";var e,n;(e=t.ActionTypes||(t.ActionTypes={})).Stop="xstate.stop",e.Raise="xstate.raise",e.Send="xstate.send",e.Cancel="xstate.cancel",e.Assign="xstate.assign",e.After="xstate.after",e.DoneState="done.state",e.DoneInvoke="done.invoke",e.Log="xstate.log",e.Init="xstate.init",e.Invoke="xstate.invoke",e.ErrorExecution="error.execution",e.ErrorCommunication="error.communication",e.ErrorPlatform="error.platform",e.ErrorCustom="xstate.error",e.Pure="xstate.pure",e.Choose="xstate.choose",(n=t.SpecialTargets||(t.SpecialTargets={})).Parent="#_parent",n.Internal="#_internal";var r=t.ActionTypes.Stop,i=t.ActionTypes.Raise,o=t.ActionTypes.Send,a=t.ActionTypes.Cancel,s=t.ActionTypes.Assign,u=(t.ActionTypes.After,t.ActionTypes.DoneState,t.ActionTypes.Log),c=t.ActionTypes.Init,l=t.ActionTypes.Invoke,f=t.ActionTypes.ErrorExecution,v=t.ActionTypes.ErrorPlatform,h=t.ActionTypes.ErrorCustom,d=t.ActionTypes.Choose,p=t.ActionTypes.Pure;function y(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}function m(t,e,n){return(e=y(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function g(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function b(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?g(Object(n),!0).forEach((function(e){m(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):g(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function _(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function x(t,e){if(t){if("string"==typeof t)return _(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_(t,e):void 0}}function S(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,i=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(t,e)||x(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function k(t){return function(t){if(Array.isArray(t))return _(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||x(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=x(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function E(t){return(E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var T="*";function I(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".",r=j(t,n),i=j(e,n);return J(i)?!!J(r)&&i===r:J(r)?r in i:Object.keys(r).every((function(t){return t in i&&I(r[t],i[t])}))}function O(t,e){try{return Q(t)?t:t.toString().split(e)}catch(e){throw new Error("'".concat(t,"' is not a valid state path."))}}function j(t,e){return"object"===E(n=t)&&"value"in n&&"context"in n&&"event"in n&&"_event"in n?t.value:Q(t)?A(t):"string"!=typeof t?t:A(O(t,e));var n}function A(t){if(1===t.length)return t[0];for(var e={},n=e,r=0;r<t.length-1;r++)r===t.length-2?n[t[r]]=t[r+1]:(n[t[r]]={},n=n[t[r]]);return e}function C(t,e){for(var n={},r=Object.keys(t),i=0;i<r.length;i++){var o=r[i];n[o]=e(t[o],o,t,i)}return n}function P(t){var e;return(e=[]).concat.apply(e,k(t))}function M(t){return Q(t)?t:[t]}function N(t){return void 0===t?[]:M(t)}function D(t,e,n){if(R(t))return t({context:e,event:n.data});for(var r={},i={context:e,event:n.data},o=0,a=Object.keys(t);o<a.length;o++){var s=a[o],u=t[s];R(u)?r[s]=u(i):r[s]=u}return r}function Q(t){return Array.isArray(t)}function R(t){return"function"==typeof t}function J(t){return"string"==typeof t}function V(t){return"string"==typeof t.name&&(t.name===f||t.name.startsWith(v))}function B(t,e){return function(t){return"$$type"in t&&"scxml"===t.$$type}(t)?t:b({name:t.type,data:t,$$type:"scxml",type:"external"},e)}function $(t,e){return M(e).map((function(e){return void 0===e||"string"==typeof e?{target:e,event:t}:b(b({},e),{},{event:t})}))}function z(t){if(void 0!==t&&""!==t)return N(t)}function U(t,e,n){var r=function(){},i="object"===E(t),o=i?t:null;return{next:((i?t.next:t)||r).bind(o),error:((i?t.error:e)||r).bind(o),complete:((i?t.complete:n)||r).bind(o)}}function W(t){return t?"transition"in t?{src:t,input:void 0}:t:void 0}function q(t,e){return{type:t.type,params:t.params,resolve:e}}function L(t){return"object"===E(t)&&null!==t&&"resolve"in t}function X(e,n){return q({type:o,params:{to:n?n.to:void 0,delay:n?n.delay:void 0,event:e,id:n&&void 0!==n.id?n.id:R(e)?e.name:e.type}},(function(r,i){var a,s,u=i.actorContext,c=i.state,l={to:n?n.to:void 0,delay:n?n.delay:void 0,event:e,id:n&&void 0!==n.id?n.id:R(e)?e.name:e.type},f={context:c.context,event:r.data,_event:r,self:null!==(a=null==u?void 0:u.self)&&void 0!==a?a:null,system:null==u?void 0:u.system},v=c.machine.options.delays,d=B(R(e)?e(f):e);if(J(l.delay)){var p=v&&v[l.delay];s=R(p)?p(f):p}else s=R(l.delay)?l.delay(f):l.delay;var y,m=R(l.to)?l.to(f):l.to;if("string"==typeof m){if(!(y=m===t.SpecialTargets.Parent?null==u?void 0:u.self._parent:m===t.SpecialTargets.Internal?null==u?void 0:u.self:m.startsWith("#_")?c.children[m.slice(2)]:c.children[m]))throw new Error("Unable to send event to actor '".concat(m,"' from machine '").concat(c.machine.id,"'."))}else y=m||(null==u?void 0:u.self);var g={type:o,params:b(b({},l),{},{to:y,_event:d,event:d.data,delay:s,internal:m===t.SpecialTargets.Internal}),execute:function(t){var e=g;if("number"!=typeof e.params.delay){var n=e.params.to,r=e.params._event;t.defer((function(){var e=t.self,i=b(b({},r),{},{name:r.name===h?"".concat(he(e.id)):r.name,origin:e});n.send(i)}))}else t.self.delaySend(e)}};return[c,g]}))}function G(e,n){return X(e,b(b({},n),{},{to:t.SpecialTargets.Parent}))}function F(t,e){if("production"!==process.env.NODE_END&&(!t||"function"==typeof t)){var n=t;t=function(){var t="function"==typeof n?n.apply(void 0,arguments):n;if(!t)throw new Error("Attempted to forward event to undefined actor. This risks an infinite loop in the sender.");return t}}return X((function(t){return t.event}),b(b({},e),{},{to:t}))}function H(t,e,n){return X(e,b(b({},n),{},{to:t}))}function K(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Y(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,y(r.key),r)}}function Z(t,e,n){return e&&Y(t.prototype,e),n&&Y(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}var tt=function(){function t(e){K(this,t),this._process=e,m(this,"_active",!1),m(this,"_current",null),m(this,"_last",null)}return Z(t,[{key:"start",value:function(){this._active=!0,this.flush()}},{key:"clear",value:function(){this._current&&(this._current.next=null,this._last=this._current)}},{key:"prepend",value:function(t){this._current?this._current={value:t,next:this._current}:this.enqueue(t)}},{key:"enqueue",value:function(t){var e={value:t,next:null};if(this._current)return this._last.next=e,void(this._last=e);this._current=e,this._last=e,this._active&&this.flush()}},{key:"flush",value:function(){for(;this._current;){var t=this._current;this._process(t.value),t===this._current&&(this._current=this._current.next)}this._last=null}}]),t}(),et="function"==typeof Symbol&&Symbol.observable||"@@observable",nt="xstate.stop";function rt(){var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:window;if(t.__xstate__)return t.__xstate__}var it,ot=function(t){var e=rt();e&&e.register(t)};(it=t.InterpreterStatus||(t.InterpreterStatus={}))[it.NotStarted=0]="NotStarted",it[it.Running=1]="Running",it[it.Stopped=2]="Stopped";var at={deferEvents:!0,clock:{setTimeout:function(t){function e(e,n){return t.apply(this,arguments)}return e.toString=function(){return t.toString()},e}((function(t,e){return setTimeout(t,e)})),clearTimeout:function(t){function e(e){return t.apply(this,arguments)}return e.toString=function(){return t.toString()},e}((function(t){return clearTimeout(t)}))},logger:console.log.bind(console),devTools:!1},st=function(){function e(n,r){var i,o=this;K(this,e),this.behavior=n,m(this,"_state",void 0),m(this,"clock",void 0),m(this,"options",void 0),m(this,"id",void 0),m(this,"mailbox",new tt(this._process.bind(this))),m(this,"delayedEventsMap",{}),m(this,"observers",new Set),m(this,"logger",void 0),m(this,"status",t.InterpreterStatus.NotStarted),m(this,"_parent",void 0),m(this,"ref",void 0),m(this,"_actorContext",void 0),m(this,"_systemId",void 0),m(this,"sessionId",void 0),m(this,"system",void 0),m(this,"_doneEvent",void 0),m(this,"src",void 0),m(this,"_deferred",[]);var a,s,u,c,l=b(b({},at),r),f=l.clock,v=l.logger,h=l.parent,d=l.id,p=l.systemId;this.system=null!==(i=null==h?void 0:h.system)&&void 0!==i?i:(a=0,s=new Map,u=new Map,c=new WeakMap,{_bookId:function(){return"x:".concat(a++)},_register:function(t,e){return s.set(t,e),t},_unregister:function(t){s.delete(t.sessionId);var e=c.get(t);void 0!==e&&(u.delete(e),c.delete(t))},get:function(t){return u.get(t)},_set:function(t,e){var n=u.get(t);if(n&&n!==e)throw new Error("Actor with system ID '".concat(t,"' already exists."));u.set(t,e),c.set(e,t)}}),p&&(this._systemId=p,this.system._set(p,this)),this.sessionId=this.system._bookId(),this.id=null!=d?d:this.sessionId,this.logger=v,this.clock=f,this._parent=h,this.options=l,this.src=l.src,this.ref=this,this._actorContext={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:function(t){o._deferred.push(t)},system:this.system,stopChild:function(t){if(t._parent!==o)throw new Error("Cannot stop child actor ".concat(t.id," of ").concat(o.id," because it is not a child"));t._stop()}},this.send=this.send.bind(this),this._initState()}return Z(e,[{key:"_initState",value:function(){var t;this._state=this.options.state?this.behavior.restoreState?this.behavior.restoreState(this.options.state,this._actorContext):this.options.state:this.behavior.getInitialState(this._actorContext,null===(t=this.options)||void 0===t?void 0:t.input)}},{key:"update",value:function(t){var e,n,r,i;this._state=t;for(var o,a=this.getSnapshot();o=this._deferred.shift();)o(t);var s,u=w(this.observers);try{for(u.s();!(s=u.n()).done;){var c,l=s.value;null===(c=l.next)||void 0===c||c.call(l,a)}}catch(t){u.e(t)}finally{u.f()}var f=null===(e=(n=this.behavior).getStatus)||void 0===e?void 0:e.call(n,t);switch(null==f?void 0:f.status){case"done":this._doneEvent=ve(this.id,f.data),null===(r=this._parent)||void 0===r||r.send(B(this._doneEvent,{origin:this,invokeid:this.id})),this._stopProcedure();break;case"error":null===(i=this._parent)||void 0===i||i.send(B(he(this.id,f.data),{origin:this}));var v,h=w(this.observers);try{for(h.s();!(v=h.n()).done;){var d,p=v.value;null===(d=p.error)||void 0===d||d.call(p,f.data)}}catch(t){h.e(t)}finally{h.f()}}}},{key:"subscribe",value:function(e,n,r){var i,o=this,a=U(e,n,r);(this.observers.add(a),this.status===t.InterpreterStatus.Stopped)&&(null===(i=a.complete)||void 0===i||i.call(a),this.observers.delete(a));return{unsubscribe:function(){o.observers.delete(a)}}}},{key:"onDone",value:function(e){var n=this;return this.status===t.InterpreterStatus.Stopped&&this._doneEvent?e(this._doneEvent):this.observers.add({complete:function(){n._doneEvent&&e(n._doneEvent)}}),this}},{key:"start",value:function(){return this.status===t.InterpreterStatus.Running||(this.system._register(this.sessionId,this),this._systemId&&this.system._set(this._systemId,this),this.status=t.InterpreterStatus.Running,this.behavior.start&&this.behavior.start(this._state,this._actorContext),this.update(this._state),this.options.devTools&&this.attachDevTools(),this.mailbox.start()),this}},{key:"_process",value:function(t){try{var e=this.behavior.transition(this._state,t,this._actorContext);this.update(e),t.name===nt&&this._stopProcedure()}catch(t){if(!(this.observers.size>0))throw t;this.observers.forEach((function(e){var n;null===(n=e.error)||void 0===n||n.call(e,t)})),this.stop()}}},{key:"_stop",value:function(){return this.status===t.InterpreterStatus.Stopped?this:(this.mailbox.clear(),this.status===t.InterpreterStatus.NotStarted?(this.status=t.InterpreterStatus.Stopped,this):(this.mailbox.enqueue(B({type:nt})),this))}},{key:"stop",value:function(){if(this._parent)throw new Error("A non-root actor cannot be stopped directly.");return this._stop()}},{key:"_complete",value:function(){var t,e=w(this.observers);try{for(e.s();!(t=e.n()).done;){var n,r=t.value;null===(n=r.complete)||void 0===n||n.call(r)}}catch(t){e.e(t)}finally{e.f()}this.observers.clear()}},{key:"_stopProcedure",value:function(){if(this._complete(),this.status!==t.InterpreterStatus.Running)return this;for(var e=0,n=Object.keys(this.delayedEventsMap);e<n.length;e++){var r=n[e];this.clock.clearTimeout(this.delayedEventsMap[r])}return this.mailbox.clear(),this.mailbox=new tt(this._process.bind(this)),this.status=t.InterpreterStatus.Stopped,this.system._unregister(this),this}},{key:"send",value:function(e){var n=B(e);if(this.status!==t.InterpreterStatus.Stopped){if(this.status!==t.InterpreterStatus.Running&&!this.options.deferEvents)throw new Error('Event "'.concat(n.name,'" was sent to uninitialized actor "').concat(this.id,'". Make sure .start() is called for this actor, or set { deferEvents: true } in the actor options.\nEvent: ').concat(JSON.stringify(n.data)));this.mailbox.enqueue(n)}}},{key:"delaySend",value:function(t){var e=this;this.delayedEventsMap[t.params.id]=this.clock.setTimeout((function(){"to"in t.params&&t.params.to?t.params.to.send(t.params._event):e.send(t.params._event)}),t.params.delay)}},{key:"cancel",value:function(t){this.clock.clearTimeout(this.delayedEventsMap[t]),delete this.delayedEventsMap[t]}},{key:"attachDevTools",value:function(){var t=this.options.devTools;t&&("function"==typeof t?t:ot)(this)}},{key:"toJSON",value:function(){return{id:this.id}}},{key:"getPersistedState",value:function(){var t,e;return null===(t=(e=this.behavior).getPersistedState)||void 0===t?void 0:t.call(e,this._state)}},{key:et,value:function(){return this}},{key:"getSnapshot",value:function(){return this.behavior.getSnapshot?this.behavior.getSnapshot(this._state):this._state}}]),e}();function ut(t,e){return new st(t,e)}function ct(e){var n=e;return q({type:r,params:{actor:n}},(function(e,r){var i=r.state,o=R(n)?n({context:i.context,event:e.data}):n,a="string"==typeof o?i.children[o]:o;return[i,{type:"xstate.stop",params:{actor:a},execute:function(e){a&&(a.status===t.InterpreterStatus.Running?e.defer((function(){e.stopChild(a)})):e.stopChild(a))}}]}))}var lt=function(t){return{context:t.context,event:t.event}};function ft(t){return q({type:a,params:{sendId:t}},(function(e,n){var r,i=n.state,o=n.actorContext,a=R(t)?t({context:i.context,event:e.data,_event:e,self:null!==(r=null==o?void 0:o.self)&&void 0!==r?r:{},system:null==o?void 0:o.system}):t;return[i,{type:"xstate.cancel",params:{sendId:a},execute:function(t){t.self.cancel(a)}}]}))}function vt(t,e){if(null==t)return{};var n,r,i=function(t,e){if(null==t)return{};var n,r,i={},o=Object.keys(t);for(r=0;r<o.length;r++)n=o[r],e.indexOf(n)>=0||(i[n]=t[n]);return i}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(r=0;r<o.length;r++)n=o[r],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}var ht=new WeakMap;function dt(t,e,n){var r=ht.get(t);return r?e in r||(r[e]=n()):(r=m({},e,n()),ht.set(t,r)),r[e]}function pt(t,e,n,r){var i,o,a,s=r.machine,u=null!==(i=null==s||null===(o=s.options)||void 0===o||null===(a=o.guards)||void 0===a?void 0:a[t.type])&&void 0!==i?i:t.predicate;if(!u)throw new Error("Guard '".concat(t.type,"' is not implemented.'."));return u({context:e,event:n.data,state:r,guard:t,_event:n,evaluate:pt})}function yt(t,e){var n;return J(t)?{type:t,predicate:(null==e?void 0:e(t))||void 0,params:{type:t}}:R(t)?{type:t.name,predicate:t,params:{type:t.name,name:t.name}}:{type:t.type,params:t.params||t,children:null===(n=t.children)||void 0===n?void 0:n.map((function(t){return yt(t,e)})),predicate:(null==e?void 0:e(t.type))||t.predicate}}var mt=function(t){return"atomic"===t.type||"final"===t.type};function gt(t){return Object.values(t.states).filter((function(t){return"history"!==t.type}))}function bt(t,e){for(var n=[],r=t.parent;r&&r!==e;)n.push(r),r=r.parent;return n}function _t(t){var e,n=new Set(t),r=new Set(t),i=St(r),o=w(n);try{for(o.s();!(e=o.n()).done;){var a=e.value;if("compound"!==a.type||i.get(a)&&i.get(a).length){if("parallel"===a.type){var s,u=w(gt(a));try{for(u.s();!(s=u.n()).done;){var c=s.value;if("history"!==c.type&&!r.has(c))for(var l=0,f=At(c);l<f.length;l++){var v=f[l];r.add(v)}}}catch(t){u.e(t)}finally{u.f()}}}else At(a).forEach((function(t){return r.add(t)}))}}catch(t){o.e(t)}finally{o.f()}var h,d=w(r);try{for(d.s();!(h=d.n()).done;)for(var p=h.value.parent;p;)r.add(p),p=p.parent}catch(t){d.e(t)}finally{d.f()}return r}function xt(t,e){var n=e.get(t);if(!n)return{};if("compound"===t.type){var r=n[0];if(!r)return{};if(mt(r))return r.key}var i,o={},a=w(n);try{for(a.s();!(i=a.n()).done;){var s=i.value;o[s.key]=xt(s,e)}}catch(t){a.e(t)}finally{a.f()}return o}function St(t){var e,n=new Map,r=w(t);try{for(r.s();!(e=r.n()).done;){var i=e.value;n.has(i)||n.set(i,[]),i.parent&&(n.has(i.parent)||n.set(i.parent,[]),n.get(i.parent).push(i))}}catch(t){r.e(t)}finally{r.f()}return n}function kt(t,e){return xt(t,St(_t(e)))}function wt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t[0].machine.root;return"compound"===e.type?gt(e).some((function(e){return"final"===e.type&&t.includes(e)})):"parallel"===e.type&>(e).every((function(e){return wt(t,e)}))}var Et=function(t){return"#"===t[0]};function Tt(t,e){var n,r=z(e.target),i=null!==(n=e.external)&&void 0!==n&&n,o=t.machine.options.guards,a=It(t,r),s=b(b({},e),{},{actions:ce(N(e.actions)),guard:e.guard?yt(e.guard,(function(t){return o[t]})):void 0,target:a,source:t,external:i,eventType:e.event,toJSON:function(){return b(b({},s),{},{source:"#".concat(t.id),target:a?a.map((function(t){return"#".concat(t.id)})):void 0})}});return s}function It(t,e){if(void 0!==e)return e.map((function(e){if(!J(e))return e;if(Et(e))return t.machine.getStateNodeById(e);var n=e[0]===t.machine.delimiter;if(n&&!t.parent)return Pt(t,e.slice(1));var r=n?t.key+e:e;if(!t.parent)throw new Error('Invalid target: "'.concat(e,'" is not a valid target from the root node. Did you mean ".').concat(e,'"?'));try{return Pt(t.parent,r)}catch(e){throw new Error("Invalid transition definition for state node '".concat(t.id,"':\n").concat(e.message))}}))}function Ot(t){var e=z(t.target);return e?e.map((function(e){return"string"==typeof e?Pt(t.parent,e):e})):t.parent.initial.target}function jt(t){return"history"===t.type}function At(t){var e=new Set;return function n(r){if(!e.has(r))if(e.add(r),"compound"===r.type){var i,o=w(r.initial.target);try{for(o.s();!(i=o.n()).done;){var a,s=i.value,u=w(bt(s,t));try{for(u.s();!(a=u.n()).done;){var c=a.value;e.add(c)}}catch(t){u.e(t)}finally{u.f()}n(s)}}catch(t){o.e(t)}finally{o.f()}}else if("parallel"===r.type){var l,f=w(gt(r));try{for(f.s();!(l=f.n()).done;){n(l.value)}}catch(t){f.e(t)}finally{f.f()}}}(t),k(e)}function Ct(t,e){if(Et(e))return t.machine.getStateNodeById(e);if(!t.states)throw new Error("Unable to retrieve child state '".concat(e,"' from '").concat(t.id,"'; no child states exist."));var n=t.states[e];if(!n)throw new Error("Child state '".concat(e,"' does not exist on '").concat(t.id,"'"));return n}function Pt(t,e){if("string"==typeof e&&Et(e))try{return t.machine.getStateNodeById(e)}catch(t){}for(var n=O(e,t.machine.delimiter).slice(),r=t;n.length;){var i=n.shift();if(!i.length)break;r=Ct(r,i)}return r}function Mt(t,e){var n=e instanceof ne?e.value:j(e,t.machine.delimiter);if(J(n))return[t,t.states[n]];var r=Object.keys(n),i=r.map((function(e){return Ct(t,e)})).filter(Boolean);return[t.machine.root,t].concat(i,r.reduce((function(e,r){var i=Ct(t,r);if(!i)return e;var o=Mt(i,n[r]);return e.concat(o)}),[]))}function Nt(t,e,n,r){return J(e)?function(t,e,n,r){var i=Ct(t,e).next(n,r);return i&&i.length?i:t.next(n,r)}(t,e,n,r):1===Object.keys(e).length?function(t,e,n,r){var i=Object.keys(e),o=Nt(Ct(t,i[0]),e[i[0]],n,r);return o&&o.length?o:t.next(n,r)}(t,e,n,r):function(t,e,n,r){for(var i=[],o=0,a=Object.keys(e);o<a.length;o++){var s=a[o],u=e[s];if(u){var c=Nt(Ct(t,s),u,n,r);c&&i.push.apply(i,k(c))}}return i.length?i:t.next(n,r)}(t,e,n,r)}function Dt(t,e){for(var n=t;n.parent&&n.parent!==e;)n=n.parent;return n.parent===e}function Qt(t){for(var e=[],n=t.parent;n;)e.unshift(n),n=n.parent;return e}function Rt(t,e){var n,r=new Set(t),i=new Set(e),o=w(r);try{for(o.s();!(n=o.n()).done;){var a=n.value;if(i.has(a))return!0}}catch(t){o.e(t)}finally{o.f()}var s,u=w(i);try{for(u.s();!(s=u.n()).done;){var c=s.value;if(r.has(c))return!0}}catch(t){u.e(t)}finally{u.f()}return!1}function Jt(t,e,n){var r,i=new Set,o=w(t);try{for(o.s();!(r=o.n()).done;){var a,s=r.value,u=!1,c=new Set,l=w(i);try{for(l.s();!(a=l.n()).done;){var f=a.value;if(Rt($t([s],e,n),$t([f],e,n))){if(!Dt(s.source,f.source)){u=!0;break}c.add(f)}}}catch(t){l.e(t)}finally{l.f()}if(!u){var v,h=w(c);try{for(h.s();!(v=h.n()).done;){var d=v.value;i.delete(d)}}catch(t){h.e(t)}finally{h.f()}i.add(s)}}}catch(t){o.e(t)}finally{o.f()}return Array.from(i)}function Vt(t,e){if(!t.target)return[];var n,r=new Set,i=w(t.target);try{for(i.s();!(n=i.n()).done;){var o=n.value;if(jt(o))if(e[o.id]){var a,s=w(e[o.id]);try{for(s.s();!(a=s.n()).done;){var u=a.value;r.add(u)}}catch(t){s.e(t)}finally{s.f()}}else{var c,l=w(Vt({target:Ot(o)},e));try{for(l.s();!(c=l.n()).done;){var f=c.value;r.add(f)}}catch(t){l.e(t)}finally{l.f()}}else r.add(o)}}catch(t){i.e(t)}finally{i.f()}return k(r)}function Bt(t,e){var n=Vt(t,e);return n?!t.external&&"compound"===t.source.type&&n.every((function(e){return Dt(e,t.source)}))?t.source:function(t){var e,n=Qt(S(t,1)[0]),r=[],i=w(t);try{var o=function(){var t=Qt(e.value);r=n.filter((function(e){return t.includes(e)})),n=r,r=[]};for(i.s();!(e=i.n()).done;)o()}catch(t){i.e(t)}finally{i.f()}return n[n.length-1]}(n.concat(t.source)):null}function $t(t,e,n){var r,i=new Set,o=w(t);try{for(o.s();!(r=o.n()).done;){var a,s=r.value;if(null!==(a=s.target)&&void 0!==a&&a.length){var u,c=Bt(s,n),l=w(e);try{for(l.s();!(u=l.n()).done;){var f=u.value;Dt(f,c)&&i.add(f)}}catch(t){l.e(t)}finally{l.f()}}}}catch(t){o.e(t)}finally{o.f()}return k(i)}function zt(t,e,n,i){var o=e.machine,a=e._initial||t.length>0,s=new Set(e.configuration);if(!e._initial&&!a){var u=re(e,{_event:i,actions:[],transitions:[]});return u.changed=!1,u}var c=function(t,e,n,r,i){var o=e.machine,a=[],s=b({},e.historyValue),u=Jt(t,n,s),c=k(e._internalQueue);e._initial||function(t,e,n,r){var i=$t(t,e,n);i.sort((function(t,e){return e.order-t.order}));var o,a=w(i);try{var s=function(){var t,r,i=o.value,a=w((r=i,Object.keys(r.states).map((function(t){return r.states[t]})).filter((function(t){return"history"===t.type}))));try{for(a.s();!(t=a.n()).done;){var s=t.value,u=void 0;u="deep"===s.history?function(t){return mt(t)&&Dt(t,i)}:function(t){return t.parent===i},n[s.id]=Array.from(e).filter(u)}}catch(t){a.e(t)}finally{a.f()}};for(a.s();!(o=a.n()).done;)s()}catch(t){a.e(t)}finally{a.f()}var u,c=w(i);try{for(c.s();!(u=c.n()).done;){var l=u.value;r.push.apply(r,k(l.exit.flat()).concat(k(l.invoke.map((function(t){return ct(t.id)}))))),e.delete(l)}}catch(t){c.e(t)}finally{c.f()}}(u,n,s,a);a.push.apply(a,k(u.flatMap((function(t){return t.actions})))),Ut(u,n,a,c,e,s);var l=k(n),f=wt(l);if(f){var v=l.sort((function(t,e){return e.order-t.order})).flatMap((function(t){return t.exit}));a.push.apply(a,k(v))}try{var h=Xt(a,r,e,i).nextState,d=f?function(t,e,n){var r=t[0].machine,i=t.find((function(t){return"final"===t.type&&t.parent===r.root}));return i&&i.output?D(i.output,e,n):void 0}(l,h.context,r):void 0;return c.push.apply(c,k(h._internalQueue)),re(e,{actions:h.actions,configuration:l,historyValue:s,_internalQueue:c,context:h.context,_event:r,done:f,output:d,children:h.children})}catch(t){if(o.config.scxml)return re(e,{actions:[],configuration:Array.from(n),historyValue:s,_internalQueue:[B({type:"error.execution"})],context:e.context});throw t}}(e._initial?[{target:k(e.configuration).filter(mt),source:o.root,external:!0,actions:[],eventType:null,toJSON:null}]:t,e,s,i,n),f=c.context,v=re(c,{value:{},transitions:t,children:function(t,e){var n,i=b({},t.children),o=w(e);try{for(o.s();!(n=o.n()).done;){var a=n.value;if(a.type===l&&a.params.ref){var s=a.params.ref;s&&(i[s.id]=s)}else if(a.type===r){var u=a.params.actor;u&&delete i[u.id]}}}catch(t){o.e(t)}finally{o.f()}return i}(e,c.actions)});return v.changed=e._initial?void 0:!Zt(v.value,e.value)||v.actions.length>0||f!==e.context,v}function Ut(t,e,n,r,i,o){var a=new Set,s=new Set;Wt(t,o,s,a),i._initial&&s.add(i.machine.root);var u,c=w(k(a).sort((function(t,e){return t.order-e.order})));try{for(c.s();!(u=c.n()).done;){var l=u.value;e.add(l);var f,v=w(l.invoke);try{for(v.s();!(f=v.n()).done;){var h=f.value;n.push(ie(h))}}catch(t){v.e(t)}finally{v.f()}if(n.push.apply(n,k(l.entry)),s.has(l)){var d,p=w(s);try{for(p.s();!(d=p.n()).done;){var y=d.value.initial.actions;n.push.apply(n,k(y))}}catch(t){p.e(t)}finally{p.f()}}if("final"===l.type){var m=l.parent;if(!m.parent)continue;if(r.push(B(fe(m.id,l.output?D(l.output,i.context,i._event):void 0))),m.parent){var g=m.parent;"parallel"===g.type&>(g).every((function(t){return wt(k(e),t)}))&&r.push(B(fe(g.id)))}}}}catch(t){c.e(t)}finally{c.f()}}function Wt(t,e,n,r){var i,o=w(t);try{for(o.s();!(i=o.n()).done;){var a,s=i.value,u=w(s.target||[]);try{for(u.s();!(a=u.n()).done;){qt(a.value,e,n,r)}}catch(t){u.e(t)}finally{u.f()}var c,l=Bt(s,e),f=w(Vt(s,e));try{for(f.s();!(c=f.n()).done;){Lt(c.value,l,r,e,n)}}catch(t){f.e(t)}finally{f.f()}}}catch(t){o.e(t)}finally{o.f()}}function qt(t,e,n,r){if(jt(t))if(e[t.id]){var i,o=e[t.id],a=w(o);try{for(a.s();!(i=a.n()).done;){qt(i.value,e,n,r)}}catch(t){a.e(t)}finally{a.f()}var s,u=w(o);try{for(u.s();!(s=u.n()).done;){Lt(s.value,t.parent,r,e,n);var c,l=w(n);try{for(l.s();!(c=l.n()).done;){var f=c.value;n.add(f)}}catch(t){l.e(t)}finally{l.f()}}}catch(t){u.e(t)}finally{u.f()}}else{var v,h=Ot(t),d=w(h);try{for(d.s();!(v=d.n()).done;){qt(v.value,e,n,r)}}catch(t){d.e(t)}finally{d.f()}var p,y=w(h);try{for(y.s();!(p=y.n()).done;){Lt(p.value,t,r,e,n);var m,g=w(n);try{for(g.s();!(m=g.n()).done;){var b=m.value;n.add(b)}}catch(t){g.e(t)}finally{g.f()}}}catch(t){y.e(t)}finally{y.f()}}else if(r.add(t),"compound"===t.type){n.add(t);var _,x=t.initial.target,S=w(x);try{for(S.s();!(_=S.n()).done;){qt(_.value,e,n,r)}}catch(t){S.e(t)}finally{S.f()}var E,T=w(x);try{for(T.s();!(E=T.n()).done;){Lt(E.value,t,r,e,n)}}catch(t){T.e(t)}finally{T.f()}}else if("parallel"===t.type){var I,O=w(gt(t).filter((function(t){return!jt(t)})));try{var j=function(){var t=I.value;k(r).some((function(e){return Dt(e,t)}))||qt(t,e,n,r)};for(O.s();!(I=O.n()).done;)j()}catch(t){O.e(t)}finally{O.f()}}}function Lt(t,e,n,r,i){var o,a=w(bt(t,e));try{for(a.s();!(o=a.n()).done;){var s=o.value;if(n.add(s),"parallel"===s.type){var u,c=w(gt(s).filter((function(t){return!jt(t)})));try{var l=function(){var t=u.value;k(n).some((function(e){return Dt(e,t)}))||qt(t,r,i,n)};for(c.s();!(u=c.n()).done;)l()}catch(t){c.e(t)}finally{c.f()}}}}catch(t){a.e(t)}finally{a.f()}}function Xt(e,n,r,a){var s=r.machine,u=[],c=[],l=r;function f(e){var n;(u.push(e),(null==a?void 0:a.self.status)===t.InterpreterStatus.Running)&&(null===(n=e.execute)||void 0===n||n.call(e,a),delete e.execute)}function v(t){var e=function(t,e){if(L(t))return t;var n,r=e[t.type];return"function"==typeof r?q({type:"xstate.function",params:null!==(n=t.params)&&void 0!==n?n:{}},(function(e,n){var i=n.state,o={type:t.type,params:t.params,execute:function(t){return r({context:i.context,event:i.event,action:o,_event:i._event,system:t.system,self:t.self})}};return[i,o]})):r||t}(t,s.options.actions);if(L(e)){var r,u=S(e.resolve(n,{state:l,action:t,actorContext:a}),2),h=u[0],d=u[1],y=null===(r=d.params)||void 0===r?void 0:r.actions;return l=h,(d.type===i||d.type===o&&d.params.internal)&&"number"!=typeof d.params.delay&&c.push(d),d.type!==p&&f(d),void ce(y).forEach(v)}f(e)}var h,d=w(e);try{for(d.s();!(h=d.n()).done;){v(h.value)}}catch(t){d.e(t)}finally{d.f()}return{nextState:re(l,{actions:u,_internalQueue:c.map((function(t){return t.params._event}))})}}function Gt(t,e,n){var r=t,i=[];if((null==e?void 0:e.name)===nt)return r=Ft(e,r,n),i.push(r),{state:r,microstates:i};e.name!==c&&(r=zt(Ht(e,r),t,n,e),i.push(r));for(;!r.done;){var o=Kt(r);if(0===o.length){if(r.configuration.some((function(t){return t.always}))&&(r.transitions=[]),!r._internalQueue.length)break;var a,s=r.actions,u=r._internalQueue[0];(r=zt(Ht(u,r),r,n,u))._internalQueue.shift(),(a=r.actions).unshift.apply(a,k(s)),i.push(r)}if(o.length){var l,f=r.actions;(l=(r=zt(o,r,n,r._event)).actions).unshift.apply(l,k(f)),i.push(r)}}return r.done&&Ft(r._event,r,n),{state:r,microstates:i}}function Ft(t,e,n){var r,i=[],o=w(e.configuration.sort((function(t,e){return e.order-t.order})));try{for(o.s();!(r=o.n()).done;){var a=r.value;i.push.apply(i,k(a.exit))}}catch(t){o.e(t)}finally{o.f()}for(var s=0,u=Object.values(e.children);s<u.length;s++){var c=u[s];i.push(ct(c))}return Xt(i,t,e,n).nextState}function Ht(t,e){return e.machine.getTransitionData(e,t)}function Kt(t){var e,n=new Set,r=w(t.configuration.filter(mt));try{for(r.s();!(e=r.n()).done;){var i,o=e.value,a=w([o].concat(bt(o,null)));try{t:for(a.s();!(i=a.n()).done;){var s=i.value;if(s.always){var u,c=w(s.always);try{for(c.s();!(u=c.n()).done;){var l=u.value;if(void 0===l.guard||pt(l.guard,t.context,t._event,t)){n.add(l);break t}}}catch(t){c.e(t)}finally{c.f()}}}}catch(t){a.e(t)}finally{a.f()}}}catch(t){r.e(t)}finally{r.f()}return Jt(Array.from(n),new Set(t.configuration),t.historyValue)}function Yt(t,e){return kt(t,k(_t(Mt(t,e))))}function Zt(t,e){if(t===e)return!0;if(void 0===t||void 0===e)return!1;if(J(t)||J(e))return t===e;var n=Object.keys(t),r=Object.keys(e);return n.length===r.length&&n.every((function(n){return Zt(t[n],e[n])}))}var te=["configuration","transitions","tags","machine"],ee=["configuration","transitions","tags","machine","children"],ne=function(){function t(e,n){var r,i,o,a;K(this,t),this.machine=n,m(this,"tags",void 0),m(this,"value",void 0),m(this,"done",void 0),m(this,"output",void 0),m(this,"context",void 0),m(this,"historyValue",{}),m(this,"actions",[]),m(this,"event",void 0),m(this,"_internalQueue",void 0),m(this,"_event",void 0),m(this,"_initial",!1),m(this,"changed",void 0),m(this,"configuration",void 0),m(this,"transitions",void 0),m(this,"children",void 0),this.context=e.context,this._event=e._event,this._internalQueue=null!==(r=e._internalQueue)&&void 0!==r?r:[],this.event=this._event.data,this.historyValue=e.historyValue||{},this.actions=null!==(i=e.actions)&&void 0!==i?i:[],this.matches=this.matches.bind(this),this.toStrings=this.toStrings.bind(this),this.configuration=null!==(o=e.configuration)&&void 0!==o?o:Array.from(_t(Mt(n.root,e.value))),this.transitions=e.transitions,this.children=e.children,this.value=kt(n.root,this.configuration),this.tags=new Set(P(this.configuration.map((function(t){return t.tags})))),this.done=null!==(a=e.done)&&void 0!==a&&a,this.output=e.output}return Z(t,[{key:"toStrings",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.value,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:".";if(J(e))return[e];var r=Object.keys(e);return r.concat.apply(r,k(r.map((function(r){return t.toStrings(e[r],n).map((function(t){return r+n+t}))}))))}},{key:"toJSON",value:function(){this.configuration,this.transitions;var t=this.tags;this.machine;return b(b({},vt(this,te)),{},{tags:Array.from(t),meta:this.meta})}},{key:"matches",value:function(t){return I(t,this.value)}},{key:"hasTag",value:function(t){return this.tags.has(t)}},{key:"can",value:function(t){this.machine;var e=this.machine.getTransitionData(this,B(t));return!(null==e||!e.length)&&e.some((function(t){return void 0!==t.target||t.actions.length}))}},{key:"nextEvents",get:function(){var t=this;return dt(this,"nextEvents",(function(){return k(new Set(P(k(t.configuration.map((function(t){return t.ownEvents}))))))}))}},{key:"meta",get:function(){return this.configuration.reduce((function(t,e){return void 0!==e.meta&&(t[e.id]=e.meta),t}),{})}}],[{key:"from",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;if(e instanceof t)return e.context!==n?new t({value:e.value,context:n,_event:e._event,actions:[],meta:{},configuration:[],transitions:[],children:{}},r):e;var i=de({}),o=_t(Mt(r.root,e));return new t({value:e,context:n,_event:i,actions:[],meta:void 0,configuration:Array.from(o),transitions:[],children:{}},r)}}]),t}();function re(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new ne(b(b({},t),e),t.machine)}function ie(e){return q({type:l,params:e},(function(n,r){var i,o,a=r.state,s=r.actorContext,u=l,c=e.id,f=e.src;if((o=f)&&"object"===E(o)&&"function"==typeof o.send)i={type:u,params:b(b({},e),{},{ref:f})};else{var v=W(a.machine.options.actors[f]);if(v){var h="input"in e?e.input:v.input,d=ut(v.src,{id:c,src:f,parent:null==s?void 0:s.self,systemId:e.systemId,input:"function"==typeof h?h({context:a.context,event:n.data,self:null==s?void 0:s.self}):h});i={type:u,params:b(b({},e),{},{ref:d})}}else i={type:u,params:e}}var p=i.params.ref,y=re(a,{children:b(b({},a.children),{},m({},c,p))});return i.execute=function(e){var n=e.self,r=i.params,o=r.id;r.ref&&e.defer((function(){if(p.status!==t.InterpreterStatus.Stopped)try{var e;null===(e=p.start)||void 0===e||e.call(p)}catch(t){return void n.send(he(o,t))}}))},[y,i]}))}function oe(t,e,n,r,i){return function(o){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(J(o)){var s=W(e.options.actors[o]);if(s){var u,c=null!==(u=a.id)&&void 0!==u?u:"anon",l="input"in a?a.input:s.input,f=ut(s.src,{id:c,parent:t,input:"function"==typeof l?l({context:n,event:r.data,self:t}):l});return i.push(ie({id:f.id,src:f,ref:f,meta:void 0,input:l})),f}throw new Error("Behavior '".concat(o,"' not implemented in machine '").concat(e.id,"'"))}var v=ut(o,{id:a.id||"anonymous",parent:t,input:a.input});return i.push(ie({src:v,ref:v,id:v.id,meta:void 0,input:a.input})),v}}function ae(t){return q({type:s,params:{assignment:t}},(function(e,n){var r,i=n.state,o=n.action,a=n.actorContext,u=[];if(!i.context)throw new Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");var c={context:i.context,event:e.data,action:o,_event:e,spawn:oe(null==a?void 0:a.self,i.machine,i.context,e,u),self:null!==(r=null==a?void 0:a.self)&&void 0!==r?r:{},system:null==a?void 0:a.system},l={};if(R(t))l=t(c);else for(var f=0,v=Object.keys(t);f<v.length;f++){var h=v[f],d=t[h];l[h]=R(d)?d(c):d}var p=Object.assign({},i.context,l);return[re(i,{context:p}),{type:s,params:{context:p,actions:u}}]}))}var se=B({type:c});function ue(t){if(L(t))return t;if("string"==typeof t)return{type:t,params:{}};if("function"==typeof t){var e="xstate.function";return q({type:e,params:{}},(function(n,r){var i=r.state,o={type:e,params:{function:t},execute:function(e){return t({context:i.context,event:n.data,action:o,_event:n,self:e.self,system:e.system})}};return[i,o]}))}return t}var ce=function(t){return t?(Q(t)?t:[t]).map(ue):[]};function le(e,n){var r=n?"#".concat(n):"";return"".concat(t.ActionTypes.After,"(").concat(e,")").concat(r)}function fe(e,n){var r="".concat(t.ActionTypes.DoneState,".").concat(e),i={type:r,output:n,toString:function(){return r}};return i}function ve(e,n){var r="".concat(t.ActionTypes.DoneInvoke,".").concat(e),i={type:r,output:n,toString:function(){return r}};return i}function he(e,n){var r="".concat(t.ActionTypes.ErrorPlatform,".").concat(e),i={type:r,data:n,toString:function(){return r}};return i}function de(t){return B({type:c,input:t})}var pe=["onDone","onError"],ye={},me=function(){function t(e,n){var r=this;if(K(this,t),this.config=e,m(this,"key",void 0),m(this,"id",void 0),m(this,"type",void 0),m(this,"path",void 0),m(this,"states",void 0),m(this,"history",void 0),m(this,"entry",void 0),m(this,"exit",void 0),m(this,"parent",void 0),m(this,"machine",void 0),m(this,"meta",void 0),m(this,"output",void 0),m(this,"order",-1),m(this,"description",void 0),m(this,"tags",[]),m(this,"transitions",void 0),m(this,"always",void 0),this.parent=n._parent,this.key=n._key,this.machine=n._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id].concat(k(this.path)).join(this.machine.delimiter),this.type=this.config.type||(this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.description=this.config.description,this.order=this.machine.idMap.size,this.machine.idMap.set(this.id,this),this.states=this.config.states?C(this.config.states,(function(e,n){return new t(e,{_parent:r,_key:n,_machine:r.machine})})):ye,"compound"===this.type&&!this.config.initial)throw new Error('No initial state specified for compound state node "#'.concat(this.id,'". Try adding { initial: "').concat(Object.keys(this.states)[0],'" } to the state config.'));this.history=!0===this.config.history?"shallow":this.config.history||!1,this.entry=ce(this.config.entry),this.exit=ce(this.config.exit),this.meta=this.config.meta,this.output="final"===this.type?this.config.output:void 0,this.tags=N(e.tags)}return Z(t,[{key:"_initialize",value:function(){var t=this;this.transitions=function(t){var e=[];if(Array.isArray(t.config.on))e.push.apply(e,k(t.config.on));else if(t.config.on){for(var n=t.config.on,r=n[T],i=void 0===r?[]:r,o=vt(n,[T].map(y)),a=0,s=Object.keys(o);a<s.length;a++){var u=s[a];if(""===u)throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');var c=$(u,o[u]);e.push.apply(e,k(c))}e.push.apply(e,k($(T,i)))}var l,f=t.config.onDone?$(String(fe(t.id)),t.config.onDone):[],v=t.invoke.flatMap((function(t){var e=[];return t.onDone&&e.push.apply(e,k($("done.invoke.".concat(t.id),t.onDone))),t.onError&&e.push.apply(e,k($("error.platform.".concat(t.id),t.onError))),t.onSnapshot&&e.push.apply(e,k($("xstate.snapshot.".concat(t.id),t.onSnapshot))),e})),h=t.after,d=[].concat(k(f),k(v),e).flatMap((function(e){return N(e).map((function(e){return Tt(t,e)}))})),p=w(h);try{for(p.s();!(l=p.n()).done;){var m=l.value;d.push(m)}}catch(t){p.e(t)}finally{p.f()}return d}(this),this.config.always&&(this.always=$("",this.config.always).map((function(e){return Tt(t,e)}))),Object.keys(this.states).forEach((function(e){t.states[e]._initialize()}))}},{key:"definition",get:function(){var t=this;return{id:this.id,key:this.key,version:this.machine.version,type:this.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions,eventType:null,external:!1,toJSON:function(){return{target:t.initial.target.map((function(t){return"#".concat(t.id)})),source:"#".concat(t.id),actions:t.initial.actions,eventType:null}}}:void 0,history:this.history,states:C(this.states,(function(t){return t.definition})),on:this.on,transitions:this.transitions,entry:this.entry,exit:this.exit,meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}},{key:"toJSON",value:function(){return this.definition}},{key:"invoke",get:function(){var t=this;return dt(this,"invoke",(function(){return N(t.config.invoke).map((function(e,n){var r,i,o=(r=t.id,i=n,"".concat(r,":invocation[").concat(i,"]")),a=function(t,e){if("object"===E(t)){if("src"in t)return t;if("transition"in t)return{id:e,src:t}}return{id:e,src:t}}(e,o),s=a.id||o,u=a.src,c=a.systemId,f=J(u)||"type"in u?u:s;return t.machine.options.actors[s]||"string"==typeof u||"type"in u||(t.machine.options.actors=b(b({},t.machine.options.actors),{},m({},s,u))),b(b({type:l},a),{},{src:f,id:s,systemId:c,toJSON:function(){a.onDone,a.onError;return b(b({},vt(a,pe)),{},{type:l,src:f,id:s})}})}))}))}},{key:"on",get:function(){var t=this;return dt(this,"on",(function(){return t.transitions.reduce((function(t,e){return t[e.eventType]=t[e.eventType]||[],t[e.eventType].push(e),t}),{})}))}},{key:"after",get:function(){var t=this;return dt(this,"delayedTransitions",(function(){return function(t){var e=t.config.after;if(!e)return[];var n=function(e,n){var r=le(R(e)?"".concat(t.id,":delay[").concat(n,"]"):e,t.id);return t.entry.push(X({type:r},{delay:e})),t.exit.push(ft(r)),r};return(Q(e)?e.map((function(t,e){var r=n(t.delay,e);return b(b({},t),{},{event:r})})):Object.keys(e).flatMap((function(t,r){var i=e[t],o=J(i)?{target:i}:i,a=isNaN(+t)?t:+t,s=n(a,r);return N(o).map((function(t){return b(b({},t),{},{event:s,delay:a})}))}))).map((function(e){var n=e.delay;return b(b({},Tt(t,e)),{},{delay:n})}))}(t)}))}},{key:"initial",get:function(){var t=this;return dt(this,"initial",(function(){return function(t,e){if(J(e)||Q(e)){var n=N(e).map((function(e){var n=J(e)?Et(e)?t.machine.getStateNodeById(e):t.states[e]:e;if(!n)throw new Error('Initial state node "'.concat(e,'" not found on parent state node #').concat(t.id));if(!Dt(n,t))throw new Error("Invalid initial target: state node #".concat(n.id," is not a descendant of #").concat(t.id));return n})),r=It(t,n),i={source:t,actions:[],eventType:null,external:!1,target:r,toJSON:function(){return b(b({},i),{},{source:"#".concat(t.id),target:r?r.map((function(t){return"#".concat(t.id)})):void 0})}};return i}return Tt(t,{target:N(e.target).map((function(e){return J(e)?Et(e)?e:"".concat(t.machine.delimiter).concat(e):e})),actions:e.actions,event:null})}(t,t.config.initial||[])}))}},{key:"handles",value:function(t){return this.events.includes(t.type)}},{key:"next",value:function(t,e){var n,r,i=this,o=e.name,a=[],s=w(dt(this,"candidates-".concat(o.toString()),(function(){return function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return t.transitions.filter((function(t){var r=t.eventType;if(r===e)return!0;if(r===T)return!0;if(!n&&!r.endsWith(".*"))return!1;for(var i=r.split("."),o=e.split("."),a=0;a<i.length;a++){var s=i[a],u=o[a];if("*"===s)return a===i.length-1;if(s!==u)return!1}return!0}))}(i,o,i.machine.config.scxml)})));try{for(s.s();!(r=s.n()).done;){var u=r.value,c=u.guard,l=t.context,f=!1;try{f=!c||pt(c,l,e,t)}catch(t){throw new Error("Unable to evaluate guard '".concat(c.type,"' in transition for event '").concat(o,"' in state node '").concat(this.id,"':\n").concat(t.message))}if(f){a.push.apply(a,k(u.actions)),n=u;break}}}catch(t){s.e(t)}finally{s.f()}return n?[n]:void 0}},{key:"target",get:function(){if("history"===this.type)return this.config.target}},{key:"stateIds",get:function(){var t=this,e=P(Object.keys(this.states).map((function(e){return t.states[e].stateIds})));return[this.id].concat(e)}},{key:"events",get:function(){var t=this;return dt(this,"events",(function(){var e=t.states,n=new Set(t.ownEvents);if(e)for(var r=0,i=Object.keys(e);r<i.length;r++){var o=e[i[r]];if(o.states){var a,s=w(o.events);try{for(s.s();!(a=s.n()).done;){var u=a.value;n.add("".concat(u))}}catch(t){s.e(t)}finally{s.f()}}}return Array.from(n)}))}},{key:"ownEvents",get:function(){var t=new Set(this.transitions.filter((function(t){return!(!t.target&&!t.actions.length&&!t.external)})).map((function(t){return t.eventType})));return Array.from(t)}}]),t}();var ge=function(){function t(e,n){var r;K(this,t),this.config=e,m(this,"version",void 0),m(this,"delimiter",void 0),m(this,"options",void 0),m(this,"schema",void 0),m(this,"__xstatenode",!0),m(this,"idMap",new Map),m(this,"root",void 0),m(this,"id",void 0),m(this,"states",void 0),m(this,"events",void 0),m(this,"__TContext",void 0),m(this,"__TEvent",void 0),m(this,"__TAction",void 0),m(this,"__TActorMap",void 0),m(this,"__TResolvedTypesMeta",void 0),this.id=e.id||"(machine)",this.options=Object.assign({actions:{},actors:{},delays:{},guards:{},context:{}},n),this.delimiter=this.config.delimiter||".",this.version=this.config.version,this.schema=null!==(r=this.config.schema)&&void 0!==r?r:{},this.transition=this.transition.bind(this),this.root=new me(e,{_key:this.id,_machine:this}),this.root._initialize(),this.states=this.root.states,this.events=this.root.events}return Z(t,[{key:"getContext",value:function(t){return this.getContextAndActions(void 0,t)[0]}},{key:"getContextAndActions",value:function(t,e){var n=[],r=this.config.context;return[("function"==typeof r?r({spawn:oe(null==t?void 0:t.self,this,void 0,de(e),n),input:e}):r)||{},n]}},{key:"provide",value:function(e){var n=this.options,r=n.actions,i=n.guards,o=n.actors,a=n.delays;return new t(this.config,{actions:b(b({},r),e.actions),guards:b(b({},i),e.guards),actors:b(b({},o),e.actors),delays:b(b({},a),e.delays)})}},{key:"resolveState",value:function(t){var e=_t(Mt(this.root,t.value)),n=Array.from(e);return this.createState(b(b({},t),{},{value:Yt(this.root,t.value),configuration:n,done:wt(n)}))}},{key:"resolveStateValue",value:function(t){var e=Yt(this.root,t),n=this.getContext();return this.resolveState(ne.from(e,n,this))}},{key:"transition",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.initialState,e=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,r=t instanceof ne?t:this.resolveStateValue(t),i=B(e);if(V(i)&&!r.nextEvents.some((function(t){return t===i.name})))throw i.data.data;var o=Gt(r,i,n),a=o.state;return a}},{key:"microstep",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.initialState,e=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,r=B(e),i=Gt(t,r,n),o=i.microstates;return o}},{key:"getTransitionData",value:function(t,e){return Nt(this.root,t.value,t,e)||[]}},{key:"getPreInitialState",value:function(t,e){var n,r=S(this.getContextAndActions(t,e),2),i=r[0],o=r[1],a=function(t){var e=[],n=t.initial,r=new Set;Wt([n],{},new Set([t]),r);var i,o=w(k(r).sort((function(t,e){return t.order-e.order})));try{for(o.s();!(i=o.n()).done;){var a=i.value;e.push(a)}}catch(t){o.e(t)}finally{o.f()}return e}(this.root),s=this.resolveState(this.createState({value:{},context:i,_event:de({}),actions:[],meta:void 0,configuration:a,transitions:[],children:{}}));if(s._initial=!0,(n=s.actions).unshift.apply(n,k(o)),t){var u=Xt(o,se,s,t).nextState;s.children=u.children,s.actions=u.actions}return s}},{key:"initialState",get:function(){return this.getInitialState()}},{key:"getInitialState",value:function(t,e){var n,r=de(e),i=this.getPreInitialState(t,e),o=zt([],i,t,r);return(n=o.actions).unshift.apply(n,k(i.actions)),Gt(o,r,t).state}},{key:"start",value:function(t,e){t.actions.forEach((function(t){var n;null===(n=t.execute)||void 0===n||n.call(t,e)})),Object.values(t.children).forEach((function(t){if(0===t.status)try{var n;null===(n=t.start)||void 0===n||n.call(t)}catch(n){e.self.send(he(t.id,n))}}))}},{key:"getStateNodeById",value:function(t){var e=t.split(this.delimiter),n=e.slice(1),r=Et(e[0])?e[0].slice("#".length):e[0],i=this.idMap.get(r);if(!i)throw new Error("Child state node '#".concat(r,"' does not exist on machine '").concat(this.id,"'"));return Pt(i,n)}},{key:"definition",get:function(){return b({context:this.getContext()},this.root.definition)}},{key:"toJSON",value:function(){return this.definition}},{key:"getPersistedState",value:function(t){return function(t){t.configuration,t.transitions,t.tags,t.machine;var e=t.children,n=vt(t,ee),r={};for(var i in e){var o,a;r[i]={state:null===(o=(a=e[i]).getPersistedState)||void 0===o?void 0:o.call(a),src:e[i].src}}return b(b({},n),{},{children:r})}(t)}},{key:"createState",value:function(t){var e=t instanceof ne?t:new ne(t,this);return Xt(e.actions,e._event,e,void 0).nextState}},{key:"getStatus",value:function(t){return t.done?{status:"done",data:t.output}:{status:"active"}}},{key:"restoreState",value:function(t,e){var n=this,r={};Object.keys(t.children).forEach((function(i){var o,a,s=t.children[i],u=s.state,c=s.src,l=c?null===(o=W(n.options.actors[c]))||void 0===o?void 0:o.src:void 0;if(l){var f=ut(l,{id:i,state:null===(a=l.restoreState)||void 0===a?void 0:a.call(l,u,e)});r[i]=f}}));var i=this.createState(new ne(b(b({},t),{},{children:r}),this));return i.configuration.forEach((function(t){t.invoke&&t.invoke.forEach((function(t){var i=t.id,o=t.src;if(!r[i]){var a=W(n.options.actors[o]);if(a){var s=ut(a.src,{id:i,parent:null==e?void 0:e.self,input:"input"in t?t.input:a.input});r[i]=s}}}))})),i.actions=[],i}}]),t}();function be(t){return t}var _e=be,xe=function(){function t(){K(this,t),m(this,"timeouts",new Map),m(this,"_now",0),m(this,"_id",0)}return Z(t,[{key:"now",value:function(){return this._now}},{key:"getId",value:function(){return this._id++}},{key:"setTimeout",value:function(t,e){var n=this.getId();return this.timeouts.set(n,{start:this.now(),timeout:e,fn:t}),n}},{key:"clearTimeout",value:function(t){this.timeouts.delete(t)}},{key:"set",value:function(t){if(this._now>t)throw new Error("Unable to travel back in time");this._now=t,this.flushTimeouts()}},{key:"flushTimeouts",value:function(){var t=this;k(this.timeouts).sort((function(t,e){var n=S(t,2),r=(n[0],n[1]),i=S(e,2),o=(i[0],i[1]),a=r.start+r.timeout;return o.start+o.timeout>a?-1:1})).forEach((function(e){var n=S(e,2),r=n[0],i=n[1];t.now()-i.start>=i.timeout&&(t.timeouts.delete(r),i.fn.call(null))}))}},{key:"increment",value:function(t){this._now+=t,this.flushTimeouts()}}]),t}(),Se={raise:function(t,e){return q({type:i,params:{delay:e?e.delay:void 0,event:t,id:e&&void 0!==e.id?e.id:"function"==typeof t?t.name:t.type}},(function(n,r){var o,a,s=r.state,u=r.actorContext,c={delay:e?e.delay:void 0,event:t,id:e&&void 0!==e.id?e.id:"function"==typeof t?t.name:t.type},l={context:s.context,event:n.data,_event:n,self:null!==(o=null==u?void 0:u.self)&&void 0!==o?o:{},system:null==u?void 0:u.system},f=s.machine.options.delays,v=B("function"==typeof t?t(l):t);if("string"==typeof c.delay){var h=f&&f[c.delay];a="function"==typeof h?h(l):h}else a="function"==typeof c.delay?c.delay(l):c.delay;var d={type:i,params:b(b({},c),{},{_event:v,event:v.data,delay:a}),execute:function(t){"number"!=typeof d.params.delay||t.self.delaySend(d)}};return[s,d]}))},send:X,sendParent:G,sendTo:H,log:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:lt,e=arguments.length>1?arguments[1]:void 0;return q({type:u,params:{label:e,expr:t}},(function(n,r){var i,o=r.state,a=r.actorContext,s="function"==typeof t?t({context:o.context,event:n.data,_event:n,self:null!==(i=null==a?void 0:a.self)&&void 0!==i?i:{},system:null==a?void 0:a.system}):t;return[o,{type:"xstate.log",params:{label:e,value:s},execute:function(t){var n,r;e?null===(n=t.logger)||void 0===n||n.call(t,e,s):null===(r=t.logger)||void 0===r||r.call(t,s)}}]}))},cancel:ft,stop:ct,assign:ae,after:le,done:fe,respond:function(t,e){return X(t,b(b({},e),{},{to:function(t){return t._event.origin}}))},forwardTo:F,escalate:function(e,n){return G((function(t){return{type:h,data:R(e)?e(t):e}}),b(b({},n),{},{to:t.SpecialTargets.Parent}))},choose:function(t){return q({type:d,params:{guards:t}},(function(e,n){var r,i=n.state,o=null===(r=t.find((function(t){var n=t.guard&&yt(t.guard,(function(t){return i.machine.options.guards[t]}));return!n||pt(n,i.context,e,i)})))||void 0===r?void 0:r.actions;return[i,{type:d,params:{actions:ce(o)}}]}))},pure:function(t){return q({type:p,params:{get:t}},(function(e,n){var r,i=n.state;return[i,{type:p,params:{actions:null!==(r=N(ce(t({context:i.context,event:e.data}))))&&void 0!==r?r:[]}}]}))}};t.Interpreter=st,t.SimulatedClock=xe,t.State=ne,t.StateMachine=ge,t.StateNode=me,t.actions=Se,t.assign=ae,t.createMachine=function(t,e){return new ge(t,e)},t.createSchema=be,t.doneInvoke=ve,t.forwardTo=F,t.getStateNodes=Mt,t.interpret=ut,t.mapState=function(t,e){for(var n,r=0,i=Object.keys(t);r<i.length;r++){var o=i[r];I(o,e)&&(!n||e.length>n.length)&&(n=o)}return t[n]},t.matchesState=I,t.pathToStateValue=A,t.send=X,t.sendParent=G,t.sendTo=H,t.t=_e,t.toObserver=U,t.toSCXMLEvent=B,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).XState={})}(this,(function(t){"use strict";var e,n;(e=t.ActionTypes||(t.ActionTypes={})).Stop="xstate.stop",e.Raise="xstate.raise",e.Send="xstate.send",e.Cancel="xstate.cancel",e.Assign="xstate.assign",e.After="xstate.after",e.DoneState="done.state",e.DoneInvoke="done.invoke",e.Log="xstate.log",e.Init="xstate.init",e.Invoke="xstate.invoke",e.ErrorExecution="error.execution",e.ErrorCommunication="error.communication",e.ErrorPlatform="error.platform",e.ErrorCustom="xstate.error",e.Pure="xstate.pure",e.Choose="xstate.choose",(n=t.SpecialTargets||(t.SpecialTargets={})).Parent="#_parent",n.Internal="#_internal";var r=t.ActionTypes.Stop,i=t.ActionTypes.Raise,o=t.ActionTypes.Send,a=t.ActionTypes.Cancel,s=t.ActionTypes.Assign,u=(t.ActionTypes.After,t.ActionTypes.DoneState,t.ActionTypes.Log),c=t.ActionTypes.Init,l=t.ActionTypes.Invoke,f=t.ActionTypes.ErrorExecution,v=t.ActionTypes.ErrorPlatform,h=t.ActionTypes.ErrorCustom,d=t.ActionTypes.Choose,p=t.ActionTypes.Pure;function y(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}function m(t,e,n){return(e=y(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function g(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function b(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?g(Object(n),!0).forEach((function(e){m(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):g(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function _(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function S(t,e){if(t){if("string"==typeof t)return _(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_(t,e):void 0}}function x(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,i=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(t,e)||S(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function k(t){return function(t){if(Array.isArray(t))return _(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||S(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=S(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function E(t){return(E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var T="*";function I(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".",r=j(t,n),i=j(e,n);return J(i)?!!J(r)&&i===r:J(r)?r in i:Object.keys(r).every((function(t){return t in i&&I(r[t],i[t])}))}function O(t,e){try{return Q(t)?t:t.toString().split(e)}catch(e){throw new Error("'".concat(t,"' is not a valid state path."))}}function j(t,e){return"object"===E(n=t)&&"value"in n&&"context"in n&&"event"in n&&"_event"in n?t.value:Q(t)?A(t):"string"!=typeof t?t:A(O(t,e));var n}function A(t){if(1===t.length)return t[0];for(var e={},n=e,r=0;r<t.length-1;r++)r===t.length-2?n[t[r]]=t[r+1]:(n[t[r]]={},n=n[t[r]]);return e}function C(t,e){for(var n={},r=Object.keys(t),i=0;i<r.length;i++){var o=r[i];n[o]=e(t[o],o,t,i)}return n}function P(t){var e;return(e=[]).concat.apply(e,k(t))}function M(t){return Q(t)?t:[t]}function N(t){return void 0===t?[]:M(t)}function D(t,e,n){if(R(t))return t({context:e,event:n.data});for(var r={},i={context:e,event:n.data},o=0,a=Object.keys(t);o<a.length;o++){var s=a[o],u=t[s];R(u)?r[s]=u(i):r[s]=u}return r}function Q(t){return Array.isArray(t)}function R(t){return"function"==typeof t}function J(t){return"string"==typeof t}function V(t){return"string"==typeof t.name&&(t.name===f||t.name.startsWith(v))}function B(t,e){return function(t){return"$$type"in t&&"scxml"===t.$$type}(t)?t:b({name:t.type,data:t,$$type:"scxml",type:"external"},e)}function $(t,e){return M(e).map((function(e){return void 0===e||"string"==typeof e?{target:e,event:t}:b(b({},e),{},{event:t})}))}function z(t){if(void 0!==t&&""!==t)return N(t)}function U(t,e,n){var r=function(){},i="object"===E(t),o=i?t:null;return{next:((i?t.next:t)||r).bind(o),error:((i?t.error:e)||r).bind(o),complete:((i?t.complete:n)||r).bind(o)}}function W(t){return t?"transition"in t?{src:t,input:void 0}:t:void 0}function q(t,e){return{type:t.type,params:t.params,resolve:e}}function L(t){return"object"===E(t)&&null!==t&&"resolve"in t}function X(e,n){return q({type:o,params:{to:n?n.to:void 0,delay:n?n.delay:void 0,event:e,id:n&&void 0!==n.id?n.id:R(e)?e.name:e.type}},(function(r,i){var a,s,u=i.actorContext,c=i.state,l={to:n?n.to:void 0,delay:n?n.delay:void 0,event:e,id:n&&void 0!==n.id?n.id:R(e)?e.name:e.type},f={context:c.context,event:r.data,_event:r,self:null!==(a=null==u?void 0:u.self)&&void 0!==a?a:null,system:null==u?void 0:u.system},v=c.machine.options.delays,d=B(R(e)?e(f):e);if(J(l.delay)){var p=v&&v[l.delay];s=R(p)?p(f):p}else s=R(l.delay)?l.delay(f):l.delay;var y,m=R(l.to)?l.to(f):l.to;if("string"==typeof m){if(!(y=m===t.SpecialTargets.Parent?null==u?void 0:u.self._parent:m===t.SpecialTargets.Internal?null==u?void 0:u.self:m.startsWith("#_")?c.children[m.slice(2)]:c.children[m]))throw new Error("Unable to send event to actor '".concat(m,"' from machine '").concat(c.machine.id,"'."))}else y=m||(null==u?void 0:u.self);var g={type:o,params:b(b({},l),{},{to:y,_event:d,event:d.data,delay:s,internal:m===t.SpecialTargets.Internal}),execute:function(t){var e=g;if("number"!=typeof e.params.delay){var n=e.params.to,r=e.params._event;t.defer((function(){var e=t.self,i=b(b({},r),{},{name:r.name===h?"".concat(he(e.id)):r.name,origin:e});n.send(i)}))}else t.self.delaySend(e)}};return[c,g]}))}function G(e,n){return X(e,b(b({},n),{},{to:t.SpecialTargets.Parent}))}function F(t,e){if("production"!==process.env.NODE_END&&(!t||"function"==typeof t)){var n=t;t=function(){var t="function"==typeof n?n.apply(void 0,arguments):n;if(!t)throw new Error("Attempted to forward event to undefined actor. This risks an infinite loop in the sender.");return t}}return X((function(t){return t.event}),b(b({},e),{},{to:t}))}function H(t,e,n){return X(e,b(b({},n),{},{to:t}))}function K(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Y(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,y(r.key),r)}}function Z(t,e,n){return e&&Y(t.prototype,e),n&&Y(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}var tt=function(){function t(e){K(this,t),this._process=e,m(this,"_active",!1),m(this,"_current",null),m(this,"_last",null)}return Z(t,[{key:"start",value:function(){this._active=!0,this.flush()}},{key:"clear",value:function(){this._current&&(this._current.next=null,this._last=this._current)}},{key:"prepend",value:function(t){this._current?this._current={value:t,next:this._current}:this.enqueue(t)}},{key:"enqueue",value:function(t){var e={value:t,next:null};if(this._current)return this._last.next=e,void(this._last=e);this._current=e,this._last=e,this._active&&this.flush()}},{key:"flush",value:function(){for(;this._current;){var t=this._current;this._process(t.value),t===this._current&&(this._current=this._current.next)}this._last=null}}]),t}(),et="function"==typeof Symbol&&Symbol.observable||"@@observable",nt="xstate.stop";function rt(){var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:window;if(t.__xstate__)return t.__xstate__}var it,ot=function(t){var e=rt();e&&e.register(t)};(it=t.InterpreterStatus||(t.InterpreterStatus={}))[it.NotStarted=0]="NotStarted",it[it.Running=1]="Running",it[it.Stopped=2]="Stopped";var at={deferEvents:!0,clock:{setTimeout:function(t){function e(e,n){return t.apply(this,arguments)}return e.toString=function(){return t.toString()},e}((function(t,e){return setTimeout(t,e)})),clearTimeout:function(t){function e(e){return t.apply(this,arguments)}return e.toString=function(){return t.toString()},e}((function(t){return clearTimeout(t)}))},logger:console.log.bind(console),devTools:!1},st=function(){function e(n,r){var i,o=this;K(this,e),this.behavior=n,m(this,"_state",void 0),m(this,"clock",void 0),m(this,"options",void 0),m(this,"id",void 0),m(this,"mailbox",new tt(this._process.bind(this))),m(this,"delayedEventsMap",{}),m(this,"observers",new Set),m(this,"logger",void 0),m(this,"status",t.InterpreterStatus.NotStarted),m(this,"_parent",void 0),m(this,"ref",void 0),m(this,"_actorContext",void 0),m(this,"_systemId",void 0),m(this,"sessionId",void 0),m(this,"system",void 0),m(this,"_doneEvent",void 0),m(this,"src",void 0),m(this,"_deferred",[]);var a,s,u,c,l=b(b({},at),r),f=l.clock,v=l.logger,h=l.parent,d=l.id,p=l.systemId;this.system=null!==(i=null==h?void 0:h.system)&&void 0!==i?i:(a=0,s=new Map,u=new Map,c=new WeakMap,{_bookId:function(){return"x:".concat(a++)},_register:function(t,e){return s.set(t,e),t},_unregister:function(t){s.delete(t.sessionId);var e=c.get(t);void 0!==e&&(u.delete(e),c.delete(t))},get:function(t){return u.get(t)},_set:function(t,e){var n=u.get(t);if(n&&n!==e)throw new Error("Actor with system ID '".concat(t,"' already exists."));u.set(t,e),c.set(e,t)}}),p&&(this._systemId=p,this.system._set(p,this)),this.sessionId=this.system._bookId(),this.id=null!=d?d:this.sessionId,this.logger=v,this.clock=f,this._parent=h,this.options=l,this.src=l.src,this.ref=this,this._actorContext={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:function(t){o._deferred.push(t)},system:this.system,stopChild:function(t){if(t._parent!==o)throw new Error("Cannot stop child actor ".concat(t.id," of ").concat(o.id," because it is not a child"));t._stop()}},this.send=this.send.bind(this),this._initState()}return Z(e,[{key:"_initState",value:function(){var t;this._state=this.options.state?this.behavior.restoreState?this.behavior.restoreState(this.options.state,this._actorContext):this.options.state:this.behavior.getInitialState(this._actorContext,null===(t=this.options)||void 0===t?void 0:t.input)}},{key:"update",value:function(t){var e,n,r,i;this._state=t;for(var o,a=this.getSnapshot();o=this._deferred.shift();)o(t);var s,u=w(this.observers);try{for(u.s();!(s=u.n()).done;){var c,l=s.value;null===(c=l.next)||void 0===c||c.call(l,a)}}catch(t){u.e(t)}finally{u.f()}var f=null===(e=(n=this.behavior).getStatus)||void 0===e?void 0:e.call(n,t);switch(null==f?void 0:f.status){case"done":this._doneEvent=ve(this.id,f.data),null===(r=this._parent)||void 0===r||r.send(B(this._doneEvent,{origin:this,invokeid:this.id})),this._stopProcedure();break;case"error":null===(i=this._parent)||void 0===i||i.send(B(he(this.id,f.data),{origin:this}));var v,h=w(this.observers);try{for(h.s();!(v=h.n()).done;){var d,p=v.value;null===(d=p.error)||void 0===d||d.call(p,f.data)}}catch(t){h.e(t)}finally{h.f()}}}},{key:"subscribe",value:function(e,n,r){var i,o=this,a=U(e,n,r);(this.observers.add(a),this.status===t.InterpreterStatus.Stopped)&&(null===(i=a.complete)||void 0===i||i.call(a),this.observers.delete(a));return{unsubscribe:function(){o.observers.delete(a)}}}},{key:"onDone",value:function(e){var n=this;return this.status===t.InterpreterStatus.Stopped&&this._doneEvent?e(this._doneEvent):this.observers.add({complete:function(){n._doneEvent&&e(n._doneEvent)}}),this}},{key:"start",value:function(){return this.status===t.InterpreterStatus.Running||(this.system._register(this.sessionId,this),this._systemId&&this.system._set(this._systemId,this),this.status=t.InterpreterStatus.Running,this.behavior.start&&this.behavior.start(this._state,this._actorContext),this.update(this._state),this.options.devTools&&this.attachDevTools(),this.mailbox.start()),this}},{key:"_process",value:function(t){try{var e=this.behavior.transition(this._state,t,this._actorContext);this.update(e),t.name===nt&&this._stopProcedure()}catch(t){if(!(this.observers.size>0))throw t;this.observers.forEach((function(e){var n;null===(n=e.error)||void 0===n||n.call(e,t)})),this.stop()}}},{key:"_stop",value:function(){return this.status===t.InterpreterStatus.Stopped?this:(this.mailbox.clear(),this.status===t.InterpreterStatus.NotStarted?(this.status=t.InterpreterStatus.Stopped,this):(this.mailbox.enqueue(B({type:nt})),this))}},{key:"stop",value:function(){if(this._parent)throw new Error("A non-root actor cannot be stopped directly.");return this._stop()}},{key:"_complete",value:function(){var t,e=w(this.observers);try{for(e.s();!(t=e.n()).done;){var n,r=t.value;null===(n=r.complete)||void 0===n||n.call(r)}}catch(t){e.e(t)}finally{e.f()}this.observers.clear()}},{key:"_stopProcedure",value:function(){if(this._complete(),this.status!==t.InterpreterStatus.Running)return this;for(var e=0,n=Object.keys(this.delayedEventsMap);e<n.length;e++){var r=n[e];this.clock.clearTimeout(this.delayedEventsMap[r])}return this.mailbox.clear(),this.mailbox=new tt(this._process.bind(this)),this.status=t.InterpreterStatus.Stopped,this.system._unregister(this),this}},{key:"send",value:function(e){var n=B(e);if(this.status!==t.InterpreterStatus.Stopped){if(this.status!==t.InterpreterStatus.Running&&!this.options.deferEvents)throw new Error('Event "'.concat(n.name,'" was sent to uninitialized actor "').concat(this.id,'". Make sure .start() is called for this actor, or set { deferEvents: true } in the actor options.\nEvent: ').concat(JSON.stringify(n.data)));this.mailbox.enqueue(n)}}},{key:"delaySend",value:function(t){var e=this;this.delayedEventsMap[t.params.id]=this.clock.setTimeout((function(){"to"in t.params&&t.params.to?t.params.to.send(t.params._event):e.send(t.params._event)}),t.params.delay)}},{key:"cancel",value:function(t){this.clock.clearTimeout(this.delayedEventsMap[t]),delete this.delayedEventsMap[t]}},{key:"attachDevTools",value:function(){var t=this.options.devTools;t&&("function"==typeof t?t:ot)(this)}},{key:"toJSON",value:function(){return{id:this.id}}},{key:"getPersistedState",value:function(){var t,e;return null===(t=(e=this.behavior).getPersistedState)||void 0===t?void 0:t.call(e,this._state)}},{key:et,value:function(){return this}},{key:"getSnapshot",value:function(){return this.behavior.getSnapshot?this.behavior.getSnapshot(this._state):this._state}}]),e}();function ut(t,e){return new st(t,e)}function ct(e){var n=e;return q({type:r,params:{actor:n}},(function(e,r){var i=r.state,o=R(n)?n({context:i.context,event:e.data}):n,a="string"==typeof o?i.children[o]:o;return[i,{type:"xstate.stop",params:{actor:a},execute:function(e){a&&(a.status===t.InterpreterStatus.Running?e.defer((function(){e.stopChild(a)})):e.stopChild(a))}}]}))}var lt=function(t){return{context:t.context,event:t.event}};function ft(t){return q({type:a,params:{sendId:t}},(function(e,n){var r,i=n.state,o=n.actorContext,a=R(t)?t({context:i.context,event:e.data,_event:e,self:null!==(r=null==o?void 0:o.self)&&void 0!==r?r:{},system:null==o?void 0:o.system}):t;return[i,{type:"xstate.cancel",params:{sendId:a},execute:function(t){t.self.cancel(a)}}]}))}function vt(t,e){if(null==t)return{};var n,r,i=function(t,e){if(null==t)return{};var n,r,i={},o=Object.keys(t);for(r=0;r<o.length;r++)n=o[r],e.indexOf(n)>=0||(i[n]=t[n]);return i}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(r=0;r<o.length;r++)n=o[r],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}var ht=new WeakMap;function dt(t,e,n){var r=ht.get(t);return r?e in r||(r[e]=n()):(r=m({},e,n()),ht.set(t,r)),r[e]}function pt(t,e,n,r){var i,o,a,s=r.machine,u=null!==(i=null==s||null===(o=s.options)||void 0===o||null===(a=o.guards)||void 0===a?void 0:a[t.type])&&void 0!==i?i:t.predicate;if(!u)throw new Error("Guard '".concat(t.type,"' is not implemented.'."));return u({context:e,event:n.data,state:r,guard:t,_event:n,evaluate:pt})}function yt(t,e){var n;return J(t)?{type:t,predicate:(null==e?void 0:e(t))||void 0,params:{type:t}}:R(t)?{type:t.name,predicate:t,params:{type:t.name,name:t.name}}:{type:t.type,params:t.params||t,children:null===(n=t.children)||void 0===n?void 0:n.map((function(t){return yt(t,e)})),predicate:(null==e?void 0:e(t.type))||t.predicate}}var mt=function(t){return"atomic"===t.type||"final"===t.type};function gt(t){return Object.values(t.states).filter((function(t){return"history"!==t.type}))}function bt(t,e){for(var n=[],r=t.parent;r&&r!==e;)n.push(r),r=r.parent;return n}function _t(t){var e,n=new Set(t),r=new Set(t),i=xt(r),o=w(n);try{for(o.s();!(e=o.n()).done;){var a=e.value;if("compound"!==a.type||i.get(a)&&i.get(a).length){if("parallel"===a.type){var s,u=w(gt(a));try{for(u.s();!(s=u.n()).done;){var c=s.value;if("history"!==c.type&&!r.has(c))for(var l=0,f=At(c);l<f.length;l++){var v=f[l];r.add(v)}}}catch(t){u.e(t)}finally{u.f()}}}else At(a).forEach((function(t){return r.add(t)}))}}catch(t){o.e(t)}finally{o.f()}var h,d=w(r);try{for(d.s();!(h=d.n()).done;)for(var p=h.value.parent;p;)r.add(p),p=p.parent}catch(t){d.e(t)}finally{d.f()}return r}function St(t,e){var n=e.get(t);if(!n)return{};if("compound"===t.type){var r=n[0];if(!r)return{};if(mt(r))return r.key}var i,o={},a=w(n);try{for(a.s();!(i=a.n()).done;){var s=i.value;o[s.key]=St(s,e)}}catch(t){a.e(t)}finally{a.f()}return o}function xt(t){var e,n=new Map,r=w(t);try{for(r.s();!(e=r.n()).done;){var i=e.value;n.has(i)||n.set(i,[]),i.parent&&(n.has(i.parent)||n.set(i.parent,[]),n.get(i.parent).push(i))}}catch(t){r.e(t)}finally{r.f()}return n}function kt(t,e){return St(t,xt(_t(e)))}function wt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t[0].machine.root;return"compound"===e.type?gt(e).some((function(e){return"final"===e.type&&t.includes(e)})):"parallel"===e.type&>(e).every((function(e){return wt(t,e)}))}var Et=function(t){return"#"===t[0]};function Tt(t,e){var n,r=z(e.target),i=null!==(n=e.reenter)&&void 0!==n&&n,o=t.machine.options.guards,a=It(t,r),s=b(b({},e),{},{actions:ce(N(e.actions)),guard:e.guard?yt(e.guard,(function(t){return o[t]})):void 0,target:a,source:t,reenter:i,eventType:e.event,toJSON:function(){return b(b({},s),{},{source:"#".concat(t.id),target:a?a.map((function(t){return"#".concat(t.id)})):void 0})}});return s}function It(t,e){if(void 0!==e)return e.map((function(e){if(!J(e))return e;if(Et(e))return t.machine.getStateNodeById(e);var n=e[0]===t.machine.delimiter;if(n&&!t.parent)return Pt(t,e.slice(1));var r=n?t.key+e:e;if(!t.parent)throw new Error('Invalid target: "'.concat(e,'" is not a valid target from the root node. Did you mean ".').concat(e,'"?'));try{return Pt(t.parent,r)}catch(e){throw new Error("Invalid transition definition for state node '".concat(t.id,"':\n").concat(e.message))}}))}function Ot(t){var e=z(t.target);return e?e.map((function(e){return"string"==typeof e?Pt(t.parent,e):e})):t.parent.initial.target}function jt(t){return"history"===t.type}function At(t){var e=new Set;return function n(r){if(!e.has(r))if(e.add(r),"compound"===r.type){var i,o=w(r.initial.target);try{for(o.s();!(i=o.n()).done;){var a,s=i.value,u=w(bt(s,t));try{for(u.s();!(a=u.n()).done;){var c=a.value;e.add(c)}}catch(t){u.e(t)}finally{u.f()}n(s)}}catch(t){o.e(t)}finally{o.f()}}else if("parallel"===r.type){var l,f=w(gt(r));try{for(f.s();!(l=f.n()).done;){n(l.value)}}catch(t){f.e(t)}finally{f.f()}}}(t),k(e)}function Ct(t,e){if(Et(e))return t.machine.getStateNodeById(e);if(!t.states)throw new Error("Unable to retrieve child state '".concat(e,"' from '").concat(t.id,"'; no child states exist."));var n=t.states[e];if(!n)throw new Error("Child state '".concat(e,"' does not exist on '").concat(t.id,"'"));return n}function Pt(t,e){if("string"==typeof e&&Et(e))try{return t.machine.getStateNodeById(e)}catch(t){}for(var n=O(e,t.machine.delimiter).slice(),r=t;n.length;){var i=n.shift();if(!i.length)break;r=Ct(r,i)}return r}function Mt(t,e){var n=e instanceof ne?e.value:j(e,t.machine.delimiter);if(J(n))return[t,t.states[n]];var r=Object.keys(n),i=r.map((function(e){return Ct(t,e)})).filter(Boolean);return[t.machine.root,t].concat(i,r.reduce((function(e,r){var i=Ct(t,r);if(!i)return e;var o=Mt(i,n[r]);return e.concat(o)}),[]))}function Nt(t,e,n,r){return J(e)?function(t,e,n,r){var i=Ct(t,e).next(n,r);return i&&i.length?i:t.next(n,r)}(t,e,n,r):1===Object.keys(e).length?function(t,e,n,r){var i=Object.keys(e),o=Nt(Ct(t,i[0]),e[i[0]],n,r);return o&&o.length?o:t.next(n,r)}(t,e,n,r):function(t,e,n,r){for(var i=[],o=0,a=Object.keys(e);o<a.length;o++){var s=a[o],u=e[s];if(u){var c=Nt(Ct(t,s),u,n,r);c&&i.push.apply(i,k(c))}}return i.length?i:t.next(n,r)}(t,e,n,r)}function Dt(t,e){for(var n=t;n.parent&&n.parent!==e;)n=n.parent;return n.parent===e}function Qt(t){for(var e=[],n=t.parent;n;)e.unshift(n),n=n.parent;return e}function Rt(t,e){var n,r=new Set(t),i=new Set(e),o=w(r);try{for(o.s();!(n=o.n()).done;){var a=n.value;if(i.has(a))return!0}}catch(t){o.e(t)}finally{o.f()}var s,u=w(i);try{for(u.s();!(s=u.n()).done;){var c=s.value;if(r.has(c))return!0}}catch(t){u.e(t)}finally{u.f()}return!1}function Jt(t,e,n){var r,i=new Set,o=w(t);try{for(o.s();!(r=o.n()).done;){var a,s=r.value,u=!1,c=new Set,l=w(i);try{for(l.s();!(a=l.n()).done;){var f=a.value;if(Rt($t([s],e,n),$t([f],e,n))){if(!Dt(s.source,f.source)){u=!0;break}c.add(f)}}}catch(t){l.e(t)}finally{l.f()}if(!u){var v,h=w(c);try{for(h.s();!(v=h.n()).done;){var d=v.value;i.delete(d)}}catch(t){h.e(t)}finally{h.f()}i.add(s)}}}catch(t){o.e(t)}finally{o.f()}return Array.from(i)}function Vt(t,e){if(!t.target)return[];var n,r=new Set,i=w(t.target);try{for(i.s();!(n=i.n()).done;){var o=n.value;if(jt(o))if(e[o.id]){var a,s=w(e[o.id]);try{for(s.s();!(a=s.n()).done;){var u=a.value;r.add(u)}}catch(t){s.e(t)}finally{s.f()}}else{var c,l=w(Vt({target:Ot(o)},e));try{for(l.s();!(c=l.n()).done;){var f=c.value;r.add(f)}}catch(t){l.e(t)}finally{l.f()}}else r.add(o)}}catch(t){i.e(t)}finally{i.f()}return k(r)}function Bt(t,e){var n=Vt(t,e);return n?!t.reenter&&"parallel"!==t.source.type&&n.every((function(e){return Dt(e,t.source)}))?t.source:function(t){var e,n=Qt(x(t,1)[0]),r=[],i=w(t);try{var o=function(){var t=Qt(e.value);r=n.filter((function(e){return t.includes(e)})),n=r,r=[]};for(i.s();!(e=i.n()).done;)o()}catch(t){i.e(t)}finally{i.f()}return n[n.length-1]}(n.concat(t.source)):null}function $t(t,e,n){var r,i=new Set,o=w(t);try{for(o.s();!(r=o.n()).done;){var a,s=r.value;if(null!==(a=s.target)&&void 0!==a&&a.length){var u,c=Bt(s,n),l=w(e);try{for(l.s();!(u=l.n()).done;){var f=u.value;Dt(f,c)&&i.add(f)}}catch(t){l.e(t)}finally{l.f()}}}}catch(t){o.e(t)}finally{o.f()}return k(i)}function zt(t,e,n,i){var o=e.machine,a=e._initial||t.length>0,s=new Set(e.configuration);if(!e._initial&&!a){var u=re(e,{_event:i,actions:[],transitions:[]});return u.changed=!1,u}var c=function(t,e,n,r,i){var o=e.machine,a=[],s=b({},e.historyValue),u=Jt(t,n,s),c=k(e._internalQueue);e._initial||function(t,e,n,r){var i=$t(t,e,n);i.sort((function(t,e){return e.order-t.order}));var o,a=w(i);try{var s=function(){var t,r,i=o.value,a=w((r=i,Object.keys(r.states).map((function(t){return r.states[t]})).filter((function(t){return"history"===t.type}))));try{for(a.s();!(t=a.n()).done;){var s=t.value,u=void 0;u="deep"===s.history?function(t){return mt(t)&&Dt(t,i)}:function(t){return t.parent===i},n[s.id]=Array.from(e).filter(u)}}catch(t){a.e(t)}finally{a.f()}};for(a.s();!(o=a.n()).done;)s()}catch(t){a.e(t)}finally{a.f()}var u,c=w(i);try{for(c.s();!(u=c.n()).done;){var l=u.value;r.push.apply(r,k(l.exit.flat()).concat(k(l.invoke.map((function(t){return ct(t.id)}))))),e.delete(l)}}catch(t){c.e(t)}finally{c.f()}}(u,n,s,a);a.push.apply(a,k(u.flatMap((function(t){return t.actions})))),Ut(u,n,a,c,e,s);var l=k(n),f=wt(l);if(f){var v=l.sort((function(t,e){return e.order-t.order})).flatMap((function(t){return t.exit}));a.push.apply(a,k(v))}try{var h=Xt(a,r,e,i).nextState,d=f?function(t,e,n){var r=t[0].machine,i=t.find((function(t){return"final"===t.type&&t.parent===r.root}));return i&&i.output?D(i.output,e,n):void 0}(l,h.context,r):void 0;return c.push.apply(c,k(h._internalQueue)),re(e,{actions:h.actions,configuration:l,historyValue:s,_internalQueue:c,context:h.context,_event:r,done:f,output:d,children:h.children})}catch(t){if(o.config.scxml)return re(e,{actions:[],configuration:Array.from(n),historyValue:s,_internalQueue:[B({type:"error.execution"})],context:e.context});throw t}}(e._initial?[{target:k(e.configuration).filter(mt),source:o.root,reenter:!0,actions:[],eventType:null,toJSON:null}]:t,e,s,i,n),f=c.context,v=re(c,{value:{},transitions:t,children:function(t,e){var n,i=b({},t.children),o=w(e);try{for(o.s();!(n=o.n()).done;){var a=n.value;if(a.type===l&&a.params.ref){var s=a.params.ref;s&&(i[s.id]=s)}else if(a.type===r){var u=a.params.actor;u&&delete i[u.id]}}}catch(t){o.e(t)}finally{o.f()}return i}(e,c.actions)});return v.changed=e._initial?void 0:!Zt(v.value,e.value)||v.actions.length>0||f!==e.context,v}function Ut(t,e,n,r,i,o){var a=new Set,s=new Set;Wt(t,o,s,a),i._initial&&s.add(i.machine.root);var u,c=w(k(a).sort((function(t,e){return t.order-e.order})));try{for(c.s();!(u=c.n()).done;){var l=u.value;e.add(l);var f,v=w(l.invoke);try{for(v.s();!(f=v.n()).done;){var h=f.value;n.push(ie(h))}}catch(t){v.e(t)}finally{v.f()}if(n.push.apply(n,k(l.entry)),s.has(l)){var d,p=w(s);try{for(p.s();!(d=p.n()).done;){var y=d.value.initial.actions;n.push.apply(n,k(y))}}catch(t){p.e(t)}finally{p.f()}}if("final"===l.type){var m=l.parent;if(!m.parent)continue;if(r.push(B(fe(m.id,l.output?D(l.output,i.context,i._event):void 0))),m.parent){var g=m.parent;"parallel"===g.type&>(g).every((function(t){return wt(k(e),t)}))&&r.push(B(fe(g.id)))}}}}catch(t){c.e(t)}finally{c.f()}}function Wt(t,e,n,r){var i,o=w(t);try{for(o.s();!(i=o.n()).done;){var a,s=i.value,u=w(s.target||[]);try{for(u.s();!(a=u.n()).done;){qt(a.value,e,n,r)}}catch(t){u.e(t)}finally{u.f()}var c,l=Bt(s,e),f=w(Vt(s,e));try{for(f.s();!(c=f.n()).done;){Lt(c.value,l,r,e,n)}}catch(t){f.e(t)}finally{f.f()}}}catch(t){o.e(t)}finally{o.f()}}function qt(t,e,n,r){if(jt(t))if(e[t.id]){var i,o=e[t.id],a=w(o);try{for(a.s();!(i=a.n()).done;){qt(i.value,e,n,r)}}catch(t){a.e(t)}finally{a.f()}var s,u=w(o);try{for(u.s();!(s=u.n()).done;){Lt(s.value,t.parent,r,e,n);var c,l=w(n);try{for(l.s();!(c=l.n()).done;){var f=c.value;n.add(f)}}catch(t){l.e(t)}finally{l.f()}}}catch(t){u.e(t)}finally{u.f()}}else{var v,h=Ot(t),d=w(h);try{for(d.s();!(v=d.n()).done;){qt(v.value,e,n,r)}}catch(t){d.e(t)}finally{d.f()}var p,y=w(h);try{for(y.s();!(p=y.n()).done;){Lt(p.value,t,r,e,n);var m,g=w(n);try{for(g.s();!(m=g.n()).done;){var b=m.value;n.add(b)}}catch(t){g.e(t)}finally{g.f()}}}catch(t){y.e(t)}finally{y.f()}}else if(r.add(t),"compound"===t.type){n.add(t);var _,S=t.initial.target,x=w(S);try{for(x.s();!(_=x.n()).done;){qt(_.value,e,n,r)}}catch(t){x.e(t)}finally{x.f()}var E,T=w(S);try{for(T.s();!(E=T.n()).done;){Lt(E.value,t,r,e,n)}}catch(t){T.e(t)}finally{T.f()}}else if("parallel"===t.type){var I,O=w(gt(t).filter((function(t){return!jt(t)})));try{var j=function(){var t=I.value;k(r).some((function(e){return Dt(e,t)}))||qt(t,e,n,r)};for(O.s();!(I=O.n()).done;)j()}catch(t){O.e(t)}finally{O.f()}}}function Lt(t,e,n,r,i){var o,a=w(bt(t,e));try{for(a.s();!(o=a.n()).done;){var s=o.value;if(n.add(s),"parallel"===s.type){var u,c=w(gt(s).filter((function(t){return!jt(t)})));try{var l=function(){var t=u.value;k(n).some((function(e){return Dt(e,t)}))||qt(t,r,i,n)};for(c.s();!(u=c.n()).done;)l()}catch(t){c.e(t)}finally{c.f()}}}}catch(t){a.e(t)}finally{a.f()}}function Xt(e,n,r,a){var s=r.machine,u=[],c=[],l=r;function f(e){var n;(u.push(e),(null==a?void 0:a.self.status)===t.InterpreterStatus.Running)&&(null===(n=e.execute)||void 0===n||n.call(e,a),delete e.execute)}function v(t){var e=function(t,e){if(L(t))return t;var n,r=e[t.type];return"function"==typeof r?q({type:"xstate.function",params:null!==(n=t.params)&&void 0!==n?n:{}},(function(e,n){var i=n.state,o={type:t.type,params:t.params,execute:function(t){return r({context:i.context,event:i.event,action:o,_event:i._event,system:t.system,self:t.self})}};return[i,o]})):r||t}(t,s.options.actions);if(L(e)){var r,u=x(e.resolve(n,{state:l,action:t,actorContext:a}),2),h=u[0],d=u[1],y=null===(r=d.params)||void 0===r?void 0:r.actions;return l=h,(d.type===i||d.type===o&&d.params.internal)&&"number"!=typeof d.params.delay&&c.push(d),d.type!==p&&f(d),void ce(y).forEach(v)}f(e)}var h,d=w(e);try{for(d.s();!(h=d.n()).done;){v(h.value)}}catch(t){d.e(t)}finally{d.f()}return{nextState:re(l,{actions:u,_internalQueue:c.map((function(t){return t.params._event}))})}}function Gt(t,e,n){var r=t,i=[];if((null==e?void 0:e.name)===nt)return r=Ft(e,r,n),i.push(r),{state:r,microstates:i};e.name!==c&&(r=zt(Ht(e,r),t,n,e),i.push(r));for(;!r.done;){var o=Kt(r);if(0===o.length){if(r.configuration.some((function(t){return t.always}))&&(r.transitions=[]),!r._internalQueue.length)break;var a,s=r.actions,u=r._internalQueue[0];(r=zt(Ht(u,r),r,n,u))._internalQueue.shift(),(a=r.actions).unshift.apply(a,k(s)),i.push(r)}if(o.length){var l,f=r.actions;(l=(r=zt(o,r,n,r._event)).actions).unshift.apply(l,k(f)),i.push(r)}}return r.done&&Ft(r._event,r,n),{state:r,microstates:i}}function Ft(t,e,n){var r,i=[],o=w(e.configuration.sort((function(t,e){return e.order-t.order})));try{for(o.s();!(r=o.n()).done;){var a=r.value;i.push.apply(i,k(a.exit))}}catch(t){o.e(t)}finally{o.f()}for(var s=0,u=Object.values(e.children);s<u.length;s++){var c=u[s];i.push(ct(c))}return Xt(i,t,e,n).nextState}function Ht(t,e){return e.machine.getTransitionData(e,t)}function Kt(t){var e,n=new Set,r=w(t.configuration.filter(mt));try{for(r.s();!(e=r.n()).done;){var i,o=e.value,a=w([o].concat(bt(o,null)));try{t:for(a.s();!(i=a.n()).done;){var s=i.value;if(s.always){var u,c=w(s.always);try{for(c.s();!(u=c.n()).done;){var l=u.value;if(void 0===l.guard||pt(l.guard,t.context,t._event,t)){n.add(l);break t}}}catch(t){c.e(t)}finally{c.f()}}}}catch(t){a.e(t)}finally{a.f()}}}catch(t){r.e(t)}finally{r.f()}return Jt(Array.from(n),new Set(t.configuration),t.historyValue)}function Yt(t,e){return kt(t,k(_t(Mt(t,e))))}function Zt(t,e){if(t===e)return!0;if(void 0===t||void 0===e)return!1;if(J(t)||J(e))return t===e;var n=Object.keys(t),r=Object.keys(e);return n.length===r.length&&n.every((function(n){return Zt(t[n],e[n])}))}var te=["configuration","transitions","tags","machine"],ee=["configuration","transitions","tags","machine","children"],ne=function(){function t(e,n){var r,i,o,a;K(this,t),this.machine=n,m(this,"tags",void 0),m(this,"value",void 0),m(this,"done",void 0),m(this,"output",void 0),m(this,"context",void 0),m(this,"historyValue",{}),m(this,"actions",[]),m(this,"event",void 0),m(this,"_internalQueue",void 0),m(this,"_event",void 0),m(this,"_initial",!1),m(this,"changed",void 0),m(this,"configuration",void 0),m(this,"transitions",void 0),m(this,"children",void 0),this.context=e.context,this._event=e._event,this._internalQueue=null!==(r=e._internalQueue)&&void 0!==r?r:[],this.event=this._event.data,this.historyValue=e.historyValue||{},this.actions=null!==(i=e.actions)&&void 0!==i?i:[],this.matches=this.matches.bind(this),this.toStrings=this.toStrings.bind(this),this.configuration=null!==(o=e.configuration)&&void 0!==o?o:Array.from(_t(Mt(n.root,e.value))),this.transitions=e.transitions,this.children=e.children,this.value=kt(n.root,this.configuration),this.tags=new Set(P(this.configuration.map((function(t){return t.tags})))),this.done=null!==(a=e.done)&&void 0!==a&&a,this.output=e.output}return Z(t,[{key:"toStrings",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.value,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:".";if(J(e))return[e];var r=Object.keys(e);return r.concat.apply(r,k(r.map((function(r){return t.toStrings(e[r],n).map((function(t){return r+n+t}))}))))}},{key:"toJSON",value:function(){this.configuration,this.transitions;var t=this.tags;this.machine;return b(b({},vt(this,te)),{},{tags:Array.from(t),meta:this.meta})}},{key:"matches",value:function(t){return I(t,this.value)}},{key:"hasTag",value:function(t){return this.tags.has(t)}},{key:"can",value:function(t){this.machine;var e=this.machine.getTransitionData(this,B(t));return!(null==e||!e.length)&&e.some((function(t){return void 0!==t.target||t.actions.length}))}},{key:"nextEvents",get:function(){var t=this;return dt(this,"nextEvents",(function(){return k(new Set(P(k(t.configuration.map((function(t){return t.ownEvents}))))))}))}},{key:"meta",get:function(){return this.configuration.reduce((function(t,e){return void 0!==e.meta&&(t[e.id]=e.meta),t}),{})}}],[{key:"from",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;if(e instanceof t)return e.context!==n?new t({value:e.value,context:n,_event:e._event,actions:[],meta:{},configuration:[],transitions:[],children:{}},r):e;var i=de({}),o=_t(Mt(r.root,e));return new t({value:e,context:n,_event:i,actions:[],meta:void 0,configuration:Array.from(o),transitions:[],children:{}},r)}}]),t}();function re(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new ne(b(b({},t),e),t.machine)}function ie(e){return q({type:l,params:e},(function(n,r){var i,o,a=r.state,s=r.actorContext,u=l,c=e.id,f=e.src;if((o=f)&&"object"===E(o)&&"function"==typeof o.send)i={type:u,params:b(b({},e),{},{ref:f})};else{var v=W(a.machine.options.actors[f]);if(v){var h="input"in e?e.input:v.input,d=ut(v.src,{id:c,src:f,parent:null==s?void 0:s.self,systemId:e.systemId,input:"function"==typeof h?h({context:a.context,event:n.data,self:null==s?void 0:s.self}):h});i={type:u,params:b(b({},e),{},{ref:d})}}else i={type:u,params:e}}var p=i.params.ref,y=re(a,{children:b(b({},a.children),{},m({},c,p))});return i.execute=function(e){var n=e.self,r=i.params,o=r.id;r.ref&&e.defer((function(){if(p.status!==t.InterpreterStatus.Stopped)try{var e;null===(e=p.start)||void 0===e||e.call(p)}catch(t){return void n.send(he(o,t))}}))},[y,i]}))}function oe(t,e,n,r,i){return function(o){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(J(o)){var s=W(e.options.actors[o]);if(s){var u,c=null!==(u=a.id)&&void 0!==u?u:"anon",l="input"in a?a.input:s.input,f=ut(s.src,{id:c,parent:t,input:"function"==typeof l?l({context:n,event:r.data,self:t}):l});return i.push(ie({id:f.id,src:f,ref:f,meta:void 0,input:l})),f}throw new Error("Behavior '".concat(o,"' not implemented in machine '").concat(e.id,"'"))}var v=ut(o,{id:a.id||"anonymous",parent:t,input:a.input});return i.push(ie({src:v,ref:v,id:v.id,meta:void 0,input:a.input})),v}}function ae(t){return q({type:s,params:{assignment:t}},(function(e,n){var r,i=n.state,o=n.action,a=n.actorContext,u=[];if(!i.context)throw new Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");var c={context:i.context,event:e.data,action:o,_event:e,spawn:oe(null==a?void 0:a.self,i.machine,i.context,e,u),self:null!==(r=null==a?void 0:a.self)&&void 0!==r?r:{},system:null==a?void 0:a.system},l={};if(R(t))l=t(c);else for(var f=0,v=Object.keys(t);f<v.length;f++){var h=v[f],d=t[h];l[h]=R(d)?d(c):d}var p=Object.assign({},i.context,l);return[re(i,{context:p}),{type:s,params:{context:p,actions:u}}]}))}var se=B({type:c});function ue(t){if(L(t))return t;if("string"==typeof t)return{type:t,params:{}};if("function"==typeof t){var e="xstate.function";return q({type:e,params:{}},(function(n,r){var i=r.state,o={type:e,params:{function:t},execute:function(e){return t({context:i.context,event:n.data,action:o,_event:n,self:e.self,system:e.system})}};return[i,o]}))}return t}var ce=function(t){return t?(Q(t)?t:[t]).map(ue):[]};function le(e,n){var r=n?"#".concat(n):"";return"".concat(t.ActionTypes.After,"(").concat(e,")").concat(r)}function fe(e,n){var r="".concat(t.ActionTypes.DoneState,".").concat(e),i={type:r,output:n,toString:function(){return r}};return i}function ve(e,n){var r="".concat(t.ActionTypes.DoneInvoke,".").concat(e),i={type:r,output:n,toString:function(){return r}};return i}function he(e,n){var r="".concat(t.ActionTypes.ErrorPlatform,".").concat(e),i={type:r,data:n,toString:function(){return r}};return i}function de(t){return B({type:c,input:t})}var pe=["onDone","onError"],ye={},me=function(){function t(e,n){var r=this;if(K(this,t),this.config=e,m(this,"key",void 0),m(this,"id",void 0),m(this,"type",void 0),m(this,"path",void 0),m(this,"states",void 0),m(this,"history",void 0),m(this,"entry",void 0),m(this,"exit",void 0),m(this,"parent",void 0),m(this,"machine",void 0),m(this,"meta",void 0),m(this,"output",void 0),m(this,"order",-1),m(this,"description",void 0),m(this,"tags",[]),m(this,"transitions",void 0),m(this,"always",void 0),this.parent=n._parent,this.key=n._key,this.machine=n._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id].concat(k(this.path)).join(this.machine.delimiter),this.type=this.config.type||(this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.description=this.config.description,this.order=this.machine.idMap.size,this.machine.idMap.set(this.id,this),this.states=this.config.states?C(this.config.states,(function(e,n){return new t(e,{_parent:r,_key:n,_machine:r.machine})})):ye,"compound"===this.type&&!this.config.initial)throw new Error('No initial state specified for compound state node "#'.concat(this.id,'". Try adding { initial: "').concat(Object.keys(this.states)[0],'" } to the state config.'));this.history=!0===this.config.history?"shallow":this.config.history||!1,this.entry=ce(this.config.entry),this.exit=ce(this.config.exit),this.meta=this.config.meta,this.output="final"===this.type?this.config.output:void 0,this.tags=N(e.tags)}return Z(t,[{key:"_initialize",value:function(){var t=this;this.transitions=function(t){var e=[];if(Array.isArray(t.config.on))e.push.apply(e,k(t.config.on));else if(t.config.on){for(var n=t.config.on,r=n[T],i=void 0===r?[]:r,o=vt(n,[T].map(y)),a=0,s=Object.keys(o);a<s.length;a++){var u=s[a];if(""===u)throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');var c=$(u,o[u]);e.push.apply(e,k(c))}e.push.apply(e,k($(T,i)))}var l,f=t.config.onDone?$(String(fe(t.id)),t.config.onDone):[],v=t.invoke.flatMap((function(t){var e=[];return t.onDone&&e.push.apply(e,k($("done.invoke.".concat(t.id),t.onDone))),t.onError&&e.push.apply(e,k($("error.platform.".concat(t.id),t.onError))),t.onSnapshot&&e.push.apply(e,k($("xstate.snapshot.".concat(t.id),t.onSnapshot))),e})),h=t.after,d=[].concat(k(f),k(v),e).flatMap((function(e){return N(e).map((function(e){return Tt(t,e)}))})),p=w(h);try{for(p.s();!(l=p.n()).done;){var m=l.value;d.push(m)}}catch(t){p.e(t)}finally{p.f()}return d}(this),this.config.always&&(this.always=$("",this.config.always).map((function(e){return Tt(t,e)}))),Object.keys(this.states).forEach((function(e){t.states[e]._initialize()}))}},{key:"definition",get:function(){var t=this;return{id:this.id,key:this.key,version:this.machine.version,type:this.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions,eventType:null,reenter:!1,toJSON:function(){return{target:t.initial.target.map((function(t){return"#".concat(t.id)})),source:"#".concat(t.id),actions:t.initial.actions,eventType:null}}}:void 0,history:this.history,states:C(this.states,(function(t){return t.definition})),on:this.on,transitions:this.transitions,entry:this.entry,exit:this.exit,meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}},{key:"toJSON",value:function(){return this.definition}},{key:"invoke",get:function(){var t=this;return dt(this,"invoke",(function(){return N(t.config.invoke).map((function(e,n){var r,i,o=(r=t.id,i=n,"".concat(r,":invocation[").concat(i,"]")),a=function(t,e){if("object"===E(t)){if("src"in t)return t;if("transition"in t)return{id:e,src:t}}return{id:e,src:t}}(e,o),s=a.id||o,u=a.src,c=a.systemId,f=J(u)||"type"in u?u:s;return t.machine.options.actors[s]||"string"==typeof u||"type"in u||(t.machine.options.actors=b(b({},t.machine.options.actors),{},m({},s,u))),b(b({type:l},a),{},{src:f,id:s,systemId:c,toJSON:function(){a.onDone,a.onError;return b(b({},vt(a,pe)),{},{type:l,src:f,id:s})}})}))}))}},{key:"on",get:function(){var t=this;return dt(this,"on",(function(){return t.transitions.reduce((function(t,e){return t[e.eventType]=t[e.eventType]||[],t[e.eventType].push(e),t}),{})}))}},{key:"after",get:function(){var t=this;return dt(this,"delayedTransitions",(function(){return function(t){var e=t.config.after;if(!e)return[];var n=function(e,n){var r=le(R(e)?"".concat(t.id,":delay[").concat(n,"]"):e,t.id);return t.entry.push(X({type:r},{delay:e})),t.exit.push(ft(r)),r};return(Q(e)?e.map((function(t,e){var r=n(t.delay,e);return b(b({},t),{},{event:r})})):Object.keys(e).flatMap((function(t,r){var i=e[t],o=J(i)?{target:i}:i,a=isNaN(+t)?t:+t,s=n(a,r);return N(o).map((function(t){return b(b({},t),{},{event:s,delay:a})}))}))).map((function(e){var n=e.delay;return b(b({},Tt(t,e)),{},{delay:n})}))}(t)}))}},{key:"initial",get:function(){var t=this;return dt(this,"initial",(function(){return function(t,e){if(J(e)||Q(e)){var n=N(e).map((function(e){var n=J(e)?Et(e)?t.machine.getStateNodeById(e):t.states[e]:e;if(!n)throw new Error('Initial state node "'.concat(e,'" not found on parent state node #').concat(t.id));if(!Dt(n,t))throw new Error("Invalid initial target: state node #".concat(n.id," is not a descendant of #").concat(t.id));return n})),r=It(t,n),i={source:t,actions:[],eventType:null,reenter:!1,target:r,toJSON:function(){return b(b({},i),{},{source:"#".concat(t.id),target:r?r.map((function(t){return"#".concat(t.id)})):void 0})}};return i}return Tt(t,{target:N(e.target).map((function(e){return J(e)?Et(e)?e:"".concat(t.machine.delimiter).concat(e):e})),actions:e.actions,event:null})}(t,t.config.initial||[])}))}},{key:"handles",value:function(t){return this.events.includes(t.type)}},{key:"next",value:function(t,e){var n,r,i=this,o=e.name,a=[],s=w(dt(this,"candidates-".concat(o.toString()),(function(){return function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return t.transitions.filter((function(t){var r=t.eventType;if(r===e)return!0;if(r===T)return!0;if(!n&&!r.endsWith(".*"))return!1;for(var i=r.split("."),o=e.split("."),a=0;a<i.length;a++){var s=i[a],u=o[a];if("*"===s)return a===i.length-1;if(s!==u)return!1}return!0}))}(i,o,i.machine.config.scxml)})));try{for(s.s();!(r=s.n()).done;){var u=r.value,c=u.guard,l=t.context,f=!1;try{f=!c||pt(c,l,e,t)}catch(t){throw new Error("Unable to evaluate guard '".concat(c.type,"' in transition for event '").concat(o,"' in state node '").concat(this.id,"':\n").concat(t.message))}if(f){a.push.apply(a,k(u.actions)),n=u;break}}}catch(t){s.e(t)}finally{s.f()}return n?[n]:void 0}},{key:"target",get:function(){if("history"===this.type)return this.config.target}},{key:"stateIds",get:function(){var t=this,e=P(Object.keys(this.states).map((function(e){return t.states[e].stateIds})));return[this.id].concat(e)}},{key:"events",get:function(){var t=this;return dt(this,"events",(function(){var e=t.states,n=new Set(t.ownEvents);if(e)for(var r=0,i=Object.keys(e);r<i.length;r++){var o=e[i[r]];if(o.states){var a,s=w(o.events);try{for(s.s();!(a=s.n()).done;){var u=a.value;n.add("".concat(u))}}catch(t){s.e(t)}finally{s.f()}}}return Array.from(n)}))}},{key:"ownEvents",get:function(){var t=new Set(this.transitions.filter((function(t){return!(!t.target&&!t.actions.length&&!t.reenter)})).map((function(t){return t.eventType})));return Array.from(t)}}]),t}();var ge=function(){function t(e,n){var r;K(this,t),this.config=e,m(this,"version",void 0),m(this,"delimiter",void 0),m(this,"options",void 0),m(this,"schema",void 0),m(this,"__xstatenode",!0),m(this,"idMap",new Map),m(this,"root",void 0),m(this,"id",void 0),m(this,"states",void 0),m(this,"events",void 0),m(this,"__TContext",void 0),m(this,"__TEvent",void 0),m(this,"__TAction",void 0),m(this,"__TActorMap",void 0),m(this,"__TResolvedTypesMeta",void 0),this.id=e.id||"(machine)",this.options=Object.assign({actions:{},actors:{},delays:{},guards:{},context:{}},n),this.delimiter=this.config.delimiter||".",this.version=this.config.version,this.schema=null!==(r=this.config.schema)&&void 0!==r?r:{},this.transition=this.transition.bind(this),this.root=new me(e,{_key:this.id,_machine:this}),this.root._initialize(),this.states=this.root.states,this.events=this.root.events}return Z(t,[{key:"getContext",value:function(t){return this.getContextAndActions(void 0,t)[0]}},{key:"getContextAndActions",value:function(t,e){var n=[],r=this.config.context;return[("function"==typeof r?r({spawn:oe(null==t?void 0:t.self,this,void 0,de(e),n),input:e}):r)||{},n]}},{key:"provide",value:function(e){var n=this.options,r=n.actions,i=n.guards,o=n.actors,a=n.delays;return new t(this.config,{actions:b(b({},r),e.actions),guards:b(b({},i),e.guards),actors:b(b({},o),e.actors),delays:b(b({},a),e.delays)})}},{key:"resolveState",value:function(t){var e=_t(Mt(this.root,t.value)),n=Array.from(e);return this.createState(b(b({},t),{},{value:Yt(this.root,t.value),configuration:n,done:wt(n)}))}},{key:"resolveStateValue",value:function(t){var e=Yt(this.root,t),n=this.getContext();return this.resolveState(ne.from(e,n,this))}},{key:"transition",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.initialState,e=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,r=t instanceof ne?t:this.resolveStateValue(t),i=B(e);if(V(i)&&!r.nextEvents.some((function(t){return t===i.name})))throw i.data.data;var o=Gt(r,i,n),a=o.state;return a}},{key:"microstep",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.initialState,e=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,r=B(e),i=Gt(t,r,n),o=i.microstates;return o}},{key:"getTransitionData",value:function(t,e){return Nt(this.root,t.value,t,e)||[]}},{key:"getPreInitialState",value:function(t,e){var n,r=x(this.getContextAndActions(t,e),2),i=r[0],o=r[1],a=function(t){var e=[],n=t.initial,r=new Set;Wt([n],{},new Set([t]),r);var i,o=w(k(r).sort((function(t,e){return t.order-e.order})));try{for(o.s();!(i=o.n()).done;){var a=i.value;e.push(a)}}catch(t){o.e(t)}finally{o.f()}return e}(this.root),s=this.resolveState(this.createState({value:{},context:i,_event:de({}),actions:[],meta:void 0,configuration:a,transitions:[],children:{}}));if(s._initial=!0,(n=s.actions).unshift.apply(n,k(o)),t){var u=Xt(o,se,s,t).nextState;s.children=u.children,s.actions=u.actions}return s}},{key:"initialState",get:function(){return this.getInitialState()}},{key:"getInitialState",value:function(t,e){var n,r=de(e),i=this.getPreInitialState(t,e),o=zt([],i,t,r);return(n=o.actions).unshift.apply(n,k(i.actions)),Gt(o,r,t).state}},{key:"start",value:function(t,e){t.actions.forEach((function(t){var n;null===(n=t.execute)||void 0===n||n.call(t,e)})),Object.values(t.children).forEach((function(t){if(0===t.status)try{var n;null===(n=t.start)||void 0===n||n.call(t)}catch(n){e.self.send(he(t.id,n))}}))}},{key:"getStateNodeById",value:function(t){var e=t.split(this.delimiter),n=e.slice(1),r=Et(e[0])?e[0].slice("#".length):e[0],i=this.idMap.get(r);if(!i)throw new Error("Child state node '#".concat(r,"' does not exist on machine '").concat(this.id,"'"));return Pt(i,n)}},{key:"definition",get:function(){return b({context:this.getContext()},this.root.definition)}},{key:"toJSON",value:function(){return this.definition}},{key:"getPersistedState",value:function(t){return function(t){t.configuration,t.transitions,t.tags,t.machine;var e=t.children,n=vt(t,ee),r={};for(var i in e){var o,a;r[i]={state:null===(o=(a=e[i]).getPersistedState)||void 0===o?void 0:o.call(a),src:e[i].src}}return b(b({},n),{},{children:r})}(t)}},{key:"createState",value:function(t){var e=t instanceof ne?t:new ne(t,this);return Xt(e.actions,e._event,e,void 0).nextState}},{key:"getStatus",value:function(t){return t.done?{status:"done",data:t.output}:{status:"active"}}},{key:"restoreState",value:function(t,e){var n=this,r={};Object.keys(t.children).forEach((function(i){var o,a,s=t.children[i],u=s.state,c=s.src,l=c?null===(o=W(n.options.actors[c]))||void 0===o?void 0:o.src:void 0;if(l){var f=ut(l,{id:i,state:null===(a=l.restoreState)||void 0===a?void 0:a.call(l,u,e)});r[i]=f}}));var i=this.createState(new ne(b(b({},t),{},{children:r}),this));return i.configuration.forEach((function(t){t.invoke&&t.invoke.forEach((function(t){var i=t.id,o=t.src;if(!r[i]){var a=W(n.options.actors[o]);if(a){var s=ut(a.src,{id:i,parent:null==e?void 0:e.self,input:"input"in t?t.input:a.input});r[i]=s}}}))})),i.actions=[],i}}]),t}();function be(t){return t}var _e=be,Se=function(){function t(){K(this,t),m(this,"timeouts",new Map),m(this,"_now",0),m(this,"_id",0)}return Z(t,[{key:"now",value:function(){return this._now}},{key:"getId",value:function(){return this._id++}},{key:"setTimeout",value:function(t,e){var n=this.getId();return this.timeouts.set(n,{start:this.now(),timeout:e,fn:t}),n}},{key:"clearTimeout",value:function(t){this.timeouts.delete(t)}},{key:"set",value:function(t){if(this._now>t)throw new Error("Unable to travel back in time");this._now=t,this.flushTimeouts()}},{key:"flushTimeouts",value:function(){var t=this;k(this.timeouts).sort((function(t,e){var n=x(t,2),r=(n[0],n[1]),i=x(e,2),o=(i[0],i[1]),a=r.start+r.timeout;return o.start+o.timeout>a?-1:1})).forEach((function(e){var n=x(e,2),r=n[0],i=n[1];t.now()-i.start>=i.timeout&&(t.timeouts.delete(r),i.fn.call(null))}))}},{key:"increment",value:function(t){this._now+=t,this.flushTimeouts()}}]),t}(),xe={raise:function(t,e){return q({type:i,params:{delay:e?e.delay:void 0,event:t,id:e&&void 0!==e.id?e.id:"function"==typeof t?t.name:t.type}},(function(n,r){var o,a,s=r.state,u=r.actorContext,c={delay:e?e.delay:void 0,event:t,id:e&&void 0!==e.id?e.id:"function"==typeof t?t.name:t.type},l={context:s.context,event:n.data,_event:n,self:null!==(o=null==u?void 0:u.self)&&void 0!==o?o:{},system:null==u?void 0:u.system},f=s.machine.options.delays,v=B("function"==typeof t?t(l):t);if("string"==typeof c.delay){var h=f&&f[c.delay];a="function"==typeof h?h(l):h}else a="function"==typeof c.delay?c.delay(l):c.delay;var d={type:i,params:b(b({},c),{},{_event:v,event:v.data,delay:a}),execute:function(t){"number"!=typeof d.params.delay||t.self.delaySend(d)}};return[s,d]}))},send:X,sendParent:G,sendTo:H,log:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:lt,e=arguments.length>1?arguments[1]:void 0;return q({type:u,params:{label:e,expr:t}},(function(n,r){var i,o=r.state,a=r.actorContext,s="function"==typeof t?t({context:o.context,event:n.data,_event:n,self:null!==(i=null==a?void 0:a.self)&&void 0!==i?i:{},system:null==a?void 0:a.system}):t;return[o,{type:"xstate.log",params:{label:e,value:s},execute:function(t){var n,r;e?null===(n=t.logger)||void 0===n||n.call(t,e,s):null===(r=t.logger)||void 0===r||r.call(t,s)}}]}))},cancel:ft,stop:ct,assign:ae,after:le,done:fe,respond:function(t,e){return X(t,b(b({},e),{},{to:function(t){return t._event.origin}}))},forwardTo:F,escalate:function(e,n){return G((function(t){return{type:h,data:R(e)?e(t):e}}),b(b({},n),{},{to:t.SpecialTargets.Parent}))},choose:function(t){return q({type:d,params:{guards:t}},(function(e,n){var r,i=n.state,o=null===(r=t.find((function(t){var n=t.guard&&yt(t.guard,(function(t){return i.machine.options.guards[t]}));return!n||pt(n,i.context,e,i)})))||void 0===r?void 0:r.actions;return[i,{type:d,params:{actions:ce(o)}}]}))},pure:function(t){return q({type:p,params:{get:t}},(function(e,n){var r,i=n.state;return[i,{type:p,params:{actions:null!==(r=N(ce(t({context:i.context,event:e.data}))))&&void 0!==r?r:[]}}]}))}};t.Interpreter=st,t.SimulatedClock=Se,t.State=ne,t.StateMachine=ge,t.StateNode=me,t.actions=xe,t.assign=ae,t.createMachine=function(t,e){return new ge(t,e)},t.createSchema=be,t.doneInvoke=ve,t.forwardTo=F,t.getStateNodes=Mt,t.interpret=ut,t.mapState=function(t,e){for(var n,r=0,i=Object.keys(t);r<i.length;r++){var o=i[r];I(o,e)&&(!n||e.length>n.length)&&(n=o)}return t[n]},t.matchesState=I,t.pathToStateValue=A,t.send=X,t.sendParent=G,t.sendTo=H,t.t=_e,t.toObserver=U,t.toSCXMLEvent=B,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
2
2
|
//# sourceMappingURL=xstate.umd.min.js.map
|