xstate 5.0.0-beta.46 → 5.0.0-beta.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/dist/xstate-actions.cjs.js +4 -3
- package/actions/dist/xstate-actions.cjs.mjs +3 -2
- package/actions/dist/xstate-actions.development.cjs.js +4 -3
- package/actions/dist/xstate-actions.development.cjs.mjs +3 -2
- package/actions/dist/xstate-actions.development.esm.js +2 -2
- package/actions/dist/xstate-actions.esm.js +2 -2
- package/actions/dist/xstate-actions.umd.min.js +1 -1
- package/actions/dist/xstate-actions.umd.min.js.map +1 -1
- package/actors/dist/xstate-actors.cjs.js +1 -1
- package/actors/dist/xstate-actors.development.cjs.js +1 -1
- package/actors/dist/xstate-actors.development.esm.js +1 -1
- package/actors/dist/xstate-actors.esm.js +1 -1
- package/dist/declarations/src/actions/{spawn.d.ts → spawnChild.d.ts} +1 -1
- package/dist/declarations/src/actions/{stop.d.ts → stopChild.d.ts} +8 -2
- package/dist/declarations/src/actions.d.ts +2 -2
- package/dist/{raise-fa23c2b9.development.esm.js → raise-156f5f68.development.esm.js} +25 -18
- package/dist/{raise-a1d3d7e9.cjs.js → raise-7af24c22.cjs.js} +26 -18
- package/dist/{raise-a9e7e31c.development.cjs.js → raise-7dc97582.development.cjs.js} +26 -18
- package/dist/{raise-1682abb7.esm.js → raise-91ec8b4f.esm.js} +25 -18
- package/dist/{send-2fa3a204.cjs.js → send-401f5c30.cjs.js} +1 -1
- package/dist/{send-9acdf858.development.esm.js → send-7489590c.development.esm.js} +1 -1
- package/dist/{send-5b256a89.development.cjs.js → send-bc0d3e22.development.cjs.js} +1 -1
- package/dist/{send-a237e4e8.esm.js → send-ed326064.esm.js} +1 -1
- package/dist/xstate.cjs.js +4 -3
- package/dist/xstate.cjs.mjs +2 -1
- package/dist/xstate.development.cjs.js +4 -3
- package/dist/xstate.development.cjs.mjs +2 -1
- package/dist/xstate.development.esm.js +4 -4
- 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.js +1 -1
- package/guards/dist/xstate-guards.development.cjs.js +1 -1
- package/guards/dist/xstate-guards.development.esm.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
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";class e{constructor(t){this._process=t,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(t){const 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()}flush(){for(;this._current;){const t=this._current;this._process(t.value),this._current=t.next}this._last=null}}const s=".",n="",i="",o="xstate.init",r="xstate.error",a="xstate.stop";function c(t,e){return{type:`xstate.done.state.${t}`,output:e}}function u(t,e){return{type:`xstate.error.actor.${t}`,data:e}}function f(t){return{type:o,input:t}}function h(){const t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:window;if(t.__xstate__)return t.__xstate__}const d=t=>{const e=h();e&&e.register(t)};function p(t){setTimeout((()=>{throw t}))}const l="function"==typeof Symbol&&Symbol.observable||"@@observable";let y=0;function g(t,e){const s=m(t),n=m(e);return"string"==typeof n?"string"==typeof s&&n===s:"string"==typeof s?s in n:Object.keys(s).every((t=>t in n&&g(s[t],n[t])))}function v(t){try{return k(t)?t:t.split(s)}catch(e){throw new Error(`'${t}' is not a valid state path.`)}}function m(t){if(Rt(t))return t.value;if("string"!=typeof t)return t;return _(v(t))}function _(t){if(1===t.length)return t[0];const e={};let s=e;for(let e=0;e<t.length-1;e++)if(e===t.length-2)s[t[e]]=t[e+1];else{const n=s;s={},n[t[e]]=s}return e}function S(t,e){const s={},n=Object.keys(t);for(let i=0;i<n.length;i++){const o=n[i];s[o]=e(t[o],o,t,i)}return s}function x(t){return[].concat(...t)}function b(t){return k(t)?t:[t]}function w(t){return void 0===t?[]:b(t)}function $(t,e,s,n){return"function"==typeof t?t({context:e,event:s,self:n}):t}function k(t){return Array.isArray(t)}function I(t){return b(t).map((t=>void 0===t||"string"==typeof t?{target:t}:t))}function E(t){if(void 0!==t&&t!==n)return w(t)}function T(t,e,s){const n="object"==typeof t,i=n?t:void 0;return{next:(n?t.next:t)?.bind(i),error:(n?t.error:e)?.bind(i),complete:(n?t.complete:s)?.bind(i)}}function O(t,e){return`${t}[${e}]`}function j(t,e){if(e.startsWith("xstate#")){const[,s]=e.match(/\[(\d+)\]$/),n=t.getStateNodeById(e.slice(7,-(s.length+2))).config.invoke;return(Array.isArray(n)?n[s]:n).src}return t.implementations.actors[e]}function M(t){return[...new Set(x([...t._nodes.map((t=>t.ownEvents))]))]}const N=1;let A=function(t){return t[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped",t}({});const P={clock:{setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t)},logger:console.log.bind(console),devTools:!1};class R{constructor(t,s){this.logic=t,this._state=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new e(this._process.bind(this)),this.delayedEventsMap={},this.observers=new Set,this.logger=void 0,this._processingStatus=A.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this._systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];const n={...P,...s},{clock:i,logger:o,parent:r,syncSnapshot:a,id:c,systemId:u,inspect:f}=n;this.system=r?.system??function(t){const e=new Map,s=new Map,n=new WeakMap,i=new Set,o={_bookId:()=>"x:"+y++,_register:(t,s)=>(e.set(t,s),t),_unregister:t=>{e.delete(t.sessionId);const i=n.get(t);void 0!==i&&(s.delete(i),n.delete(t))},get:t=>s.get(t),_set:(t,e)=>{const i=s.get(t);if(i&&i!==e)throw new Error(`Actor with system ID '${t}' already exists.`);s.set(t,e),n.set(e,t)},inspect:t=>{i.add(t)},_sendInspectionEvent:e=>{const s={...e,rootId:t.sessionId};i.forEach((t=>t.next?.(s)))},_relay:(t,e,s)=>{o._sendInspectionEvent({type:"@xstate.event",sourceRef:t,actorRef:e,event:s}),e._send(s)}};return o}(this),f&&!r&&this.system.inspect(T(f)),this.sessionId=this.system._bookId(),this.id=c??this.sessionId,this.logger=o,this.clock=i,this._parent=r,this._syncSnapshot=a,this.options=n,this.src=n.src??t,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:t=>{this._deferred.push(t)},system:this.system,stopChild:t=>{if(t._parent!==this)throw new Error(`Cannot stop child actor ${t.id} of ${this.id} because it is not a child`);t._stop()}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),u&&(this._systemId=u,this.system._set(u,this)),this._initState(s?.state),u&&"active"!==this._state.status&&this.system._unregister(this)}_initState(t){this._state=t?this.logic.restoreState?this.logic.restoreState(t,this._actorScope):t:this.logic.getInitialState(this._actorScope,this.options?.input)}update(t,e){let s;for(this._state=t;s=this._deferred.shift();)s();for(const e of this.observers)try{e.next?.(t)}catch(t){p(t)}switch(this._state.status){case"done":this._stopProcedure(),this._complete(),this._doneEvent=(n=this.id,i=this._state.output,{type:`xstate.done.actor.${n}`,output:i}),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case"error":this._stopProcedure(),this._error(this._state.error),this._parent&&this.system._relay(this,this._parent,u(this.id,this._state.error))}var n,i;this.system._sendInspectionEvent({type:"@xstate.snapshot",actorRef:this,event:e,snapshot:t})}subscribe(t,e,s){const n=T(t,e,s);if(this._processingStatus!==A.Stopped)this.observers.add(n);else try{n.complete?.()}catch(t){p(t)}return{unsubscribe:()=>{this.observers.delete(n)}}}start(){if(this._processingStatus===A.Running)return this;this._syncSnapshot&&this.subscribe({next:t=>{"active"===t.status&&this._parent.send({type:`xstate.snapshot.${this.id}`,snapshot:t})},error:()=>{}}),this.system._register(this.sessionId,this),this._systemId&&this.system._set(this._systemId,this),this._processingStatus=A.Running;const t=f(this.options.input);this.system._sendInspectionEvent({type:"@xstate.event",sourceRef:this._parent,actorRef:this,event:t});switch(this._state.status){case"done":this.update(this._state,t);case"error":return this}if(this.logic.start)try{this.logic.start(this._state,this._actorScope)}catch(t){return this._stopProcedure(),this._error(t),this._parent?.send(u(this.id,t)),this}return this.update(this._state,t),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(t){let e,s;try{e=this.logic.transition(this._state,t,this._actorScope)}catch(t){s={err:t}}if(s){const{err:t}=s;return this._stopProcedure(),this._error(t),void this._parent?.send(u(this.id,t))}this.update(e,t),t.type===a&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===A.Stopped?this:(this.mailbox.clear(),this._processingStatus===A.NotStarted?(this._processingStatus=A.Stopped,this):(this.mailbox.enqueue({type:a}),this))}stop(){if(this._parent)throw new Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){for(const t of this.observers)try{t.complete?.()}catch(t){p(t)}this.observers.clear()}_error(t){if(!this.observers.size)return void(this._parent||p(t));let e=!1;for(const s of this.observers){const n=s.error;e||=!n;try{n?.(t)}catch(t){p(t)}}this.observers.clear(),e&&p(t)}_stopProcedure(){if(this._processingStatus!==A.Running)return this;for(const t of Object.keys(this.delayedEventsMap))this.clock.clearTimeout(this.delayedEventsMap[t]);return this.mailbox.clear(),this.mailbox=new e(this._process.bind(this)),this._processingStatus=A.Stopped,this.system._unregister(this),this}_send(t){this._processingStatus!==A.Stopped&&this.mailbox.enqueue(t)}send(t){this.system._relay(void 0,this,t)}delaySend(t){const{event:e,id:s,delay:n}=t,i=this.clock.setTimeout((()=>{this.system._relay(this,t.to??this,e)}),n);s&&(this.delayedEventsMap[s]=i)}cancel(t){this.clock.clearTimeout(this.delayedEventsMap[t]),delete this.delayedEventsMap[t]}attachDevTools(){const{devTools:t}=this.options;if(t){("function"==typeof t?t:d)(this)}}toJSON(){return{xstate$$type:N,id:this.id}}getPersistedState(t){return this.logic.getPersistedState(this._state,t)}[l](){return this}getSnapshot(){return this._state}}function D(t,e){return new R(t,e)}const J=D;function V(t,e,s,n,{sendId:i}){return[e,"function"==typeof i?i(s,n):i]}function C(t,e){t.self.cancel(e)}function B(t){function e(t,e){}return e.type="xstate.cancel",e.sendId=t,e.resolve=V,e.execute=C,e}function z(t,e,s,n,{id:i,systemId:o,src:r,input:a,syncSnapshot:c}){const u="string"==typeof r?j(e.machine,r):r,f="function"==typeof i?i(s):i;let h;return u&&(h=D(u,{id:f,src:r,parent:t?.self,syncSnapshot:c,systemId:o,input:"function"==typeof a?a({context:e.context,event:s.event,self:t?.self}):a})),[Wt(e,{children:{...e.children,[f]:h}}),{id:i,actorRef:h}]}function W(t,{id:e,actorRef:s}){s&&t.defer((()=>{if(s._processingStatus!==A.Stopped)try{s.start?.()}catch(s){return void t.self.send(u(e,s))}}))}function U(...[t,{id:e,systemId:s,input:n,syncSnapshot:i=!1}={}]){function o(t,e){}return o.type="xstate.spawn",o.id=e,o.systemId=s,o.src=t,o.input=n,o.syncSnapshot=i,o.resolve=z,o.execute=W,o}function q(t,e,s,n,{actorRef:i}){const o="function"==typeof i?i(s,n):i,r="string"==typeof o?e.children[o]:o;let a=e.children;return r&&(a={...a},delete a[r.id]),[Wt(e,{children:a}),r]}function Q(t,e){e&&(t.system._unregister(e),e._processingStatus===A.Running?t.defer((()=>{t.stopChild(e)})):t.stopChild(e))}function F(t){function e(t,e){}return e.type="xstate.stop",e.actorRef=t,e.resolve=q,e.execute=Q,e}function G(t,e,{stateValue:s}){if("string"==typeof s&&rt(s)){const e=t.machine.getStateNodeById(s);return t._nodes.some((t=>t===e))}return t.matches(s)}function X(t,{context:e,event:s},{guards:n}){return!L(n[0],e,s,t)}function H(t,{context:e,event:s},{guards:n}){return n.every((n=>L(n,e,s,t)))}function K(t,{context:e,event:s},{guards:n}){return n.some((n=>L(n,e,s,t)))}function L(t,e,s,n){const{machine:i}=n,o="function"==typeof t,r=o?t:i.implementations.guards["string"==typeof t?t:t.type];if(!o&&!r)throw new Error(`Guard '${"string"==typeof t?t:t.type}' is not implemented.'.`);if("function"!=typeof r)return L(r,e,s,n);const a={context:e,event:s},c=o||"string"==typeof t?void 0:"params"in t?"function"==typeof t.params?t.params({context:e,event:s}):t.params:void 0;if(!("check"in r))return r(a,c);return r.check(n,a,r)}const Y=t=>"atomic"===t.type||"final"===t.type;function Z(t){return Object.values(t.states).filter((t=>"history"!==t.type))}function tt(t,e){const s=[];if(e===t)return s;let n=t.parent;for(;n&&n!==e;)s.push(n),n=n.parent;return s}function et(t){const e=new Set(t),s=nt(e);for(const t of e)if("compound"!==t.type||s.get(t)&&s.get(t).length){if("parallel"===t.type)for(const s of Z(t))if("history"!==s.type&&!e.has(s)){const t=ht(s);for(const s of t)e.add(s)}}else ht(t).forEach((t=>e.add(t)));for(const t of e){let s=t.parent;for(;s;)e.add(s),s=s.parent}return e}function st(t,e){const s=e.get(t);if(!s)return{};if("compound"===t.type){const t=s[0];if(!t)return{};if(Y(t))return t.key}const n={};for(const t of s)n[t.key]=st(t,e);return n}function nt(t){const e=new Map;for(const s of t)e.has(s)||e.set(s,[]),s.parent&&(e.has(s.parent)||e.set(s.parent,[]),e.get(s.parent).push(s));return e}function it(t,e){return st(t,nt(et(e)))}function ot(t,e){return"compound"===e.type?Z(e).some((e=>"final"===e.type&&t.has(e))):"parallel"===e.type?Z(e).every((e=>ot(t,e))):"final"===e.type}const rt=t=>"#"===t[0];function at(t){const e=t.config.after;if(!e)return[];return Object.keys(e).flatMap(((s,n)=>{const i=e[s],o="string"==typeof i?{target:i}:i,r=isNaN(+s)?s:+s,a=((e,s)=>{const n=(o="function"==typeof e?`${t.id}:delay[${s}]`:e,r=t.id,{type:`xstate.after(${o})${r?`#${r}`:""}`}),i=n.type;var o,r;return t.entry.push(Zt(n,{id:i,delay:e})),t.exit.push(B(i)),i})(r,n);return w(o).map((t=>({...t,event:a,delay:r})))})).map((e=>{const{delay:s}=e;return{...ct(t,e.event,e),delay:s}}))}function ct(t,e,n){const i=E(n.target),o=n.reenter??!1,r=function(t,e){if(void 0===e)return;return e.map((e=>{if("string"!=typeof e)return e;if(rt(e))return t.machine.getStateNodeById(e);const n=e[0]===s;if(n&&!t.parent)return lt(t,e.slice(1));const i=n?t.key+e:e;if(!t.parent)throw new Error(`Invalid target: "${e}" is not a valid target from the root node. Did you mean ".${e}"?`);try{return lt(t.parent,i)}catch(e){throw new Error(`Invalid transition definition for state node '${t.id}':\n${e.message}`)}}))}(t,i),a={...n,actions:w(n.actions),guard:n.guard,target:r,source:t,reenter:o,eventType:e,toJSON:()=>({...a,source:`#${t.id}`,target:r?r.map((t=>`#${t.id}`)):void 0})};return a}function ut(t){const e=E(t.config.target);return e?{target:e.map((e=>"string"==typeof e?lt(t.parent,e):e))}:t.parent.initial}function ft(t){return"history"===t.type}function ht(t){const e=dt(t);for(const s of e)for(const n of tt(s,t))e.add(n);return e}function dt(t){const e=new Set;return function t(s){if(!e.has(s))if(e.add(s),"compound"===s.type)t(s.initial.target[0]);else if("parallel"===s.type)for(const e of Z(s))t(e)}(t),e}function pt(t,e){if(rt(e))return t.machine.getStateNodeById(e);if(!t.states)throw new Error(`Unable to retrieve child state '${e}' from '${t.id}'; no child states exist.`);const s=t.states[e];if(!s)throw new Error(`Child state '${e}' does not exist on '${t.id}'`);return s}function lt(t,e){if("string"==typeof e&&rt(e))try{return t.machine.getStateNodeById(e)}catch(t){}const s=v(e).slice();let n=t;for(;s.length;){const t=s.shift();if(!t.length)break;n=pt(n,t)}return n}function yt(t,e){if("string"==typeof e)return[t,t.states[e]];const s=Object.keys(e),n=s.map((e=>pt(t,e))).filter(Boolean);return[t.machine.root,t].concat(n,s.reduce(((s,n)=>{const i=pt(t,n);if(!i)return s;const o=yt(i,e[n]);return s.concat(o)}),[]))}function gt(t,e,s,n){return"string"==typeof e?function(t,e,s,n){const i=pt(t,e).next(s,n);return i&&i.length?i:t.next(s,n)}(t,e,s,n):1===Object.keys(e).length?function(t,e,s,n){const i=Object.keys(e),o=gt(pt(t,i[0]),e[i[0]],s,n);return o&&o.length?o:t.next(s,n)}(t,e,s,n):function(t,e,s,n){const i=[];for(const o of Object.keys(e)){const r=e[o];if(!r)continue;const a=gt(pt(t,o),r,s,n);a&&i.push(...a)}return i.length?i:t.next(s,n)}(t,e,s,n)}function vt(t){return Object.keys(t.states).map((e=>t.states[e])).filter((t=>"history"===t.type))}function mt(t,e){let s=t;for(;s.parent&&s.parent!==e;)s=s.parent;return s.parent===e}function _t(t,e){const s=new Set(t),n=new Set(e);for(const t of s)if(n.has(t))return!0;for(const t of n)if(s.has(t))return!0;return!1}function St(t,e,s){const n=new Set;for(const i of t){let t=!1;const o=new Set;for(const r of n)if(_t(wt([i],e,s),wt([r],e,s))){if(!mt(i.source,r.source)){t=!0;break}o.add(r)}if(!t){for(const t of o)n.delete(t);n.add(i)}}return Array.from(n)}function xt(t,e){if(!t.target)return[];const s=new Set;for(const n of t.target)if(ft(n))if(e[n.id])for(const t of e[n.id])s.add(t);else for(const t of xt(ut(n),e))s.add(t);else s.add(n);return[...s]}function bt(t,e){const s=xt(t,e);if(!s)return;if(!t.reenter&&s.every((e=>e===t.source||mt(e,t.source))))return t.source;const n=function(t){const[e,...s]=t;for(const t of tt(e,void 0))if(s.every((e=>mt(e,t))))return t}(s.concat(t.source));return n||(t.reenter?void 0:t.source.machine.root)}function wt(t,e,s){const n=new Set;for(const i of t)if(i.target?.length){const t=bt(i,s);i.reenter&&i.source===t&&n.add(t);for(const s of e)mt(s,t)&&n.add(s)}return[...n]}function $t(t,e,s,n,i,o){if(!t.length)return e;const r=new Set(e._nodes);let a=e.historyValue;const u=St(t,r,a);let f=e;i||([f,a]=function(t,e,s,n,i,o,r){let a=t;const c=wt(n,i,o);let u;c.sort(((t,e)=>e.order-t.order));for(const t of c)for(const e of vt(t)){let s;s="deep"===e.history?e=>Y(e)&&mt(e,t):e=>e.parent===t,u??={...o},u[e.id]=Array.from(i).filter(s)}for(const t of c)a=jt(a,e,s,[...t.exit,...t.invoke.map((t=>F(t.id)))],r),i.delete(t);return[a,u||o]}(f,n,s,u,r,a,o)),f=jt(f,n,s,u.flatMap((t=>t.actions)),o),f=function(t,e,s,n,i,o,r,a){let u=t;const f=new Set,h=new Set;(function(t,e,s,n){for(const i of t){const t=bt(i,e);for(const o of i.target||[])ft(o)||i.source===o&&i.source===t&&!i.reenter||(n.add(o),s.add(o)),It(o,e,s,n);const o=xt(i,e);for(const r of o){const o=tt(r,t);"parallel"===t?.type&&o.push(t),Et(n,e,s,o,!i.source.parent&&i.reenter?void 0:t)}}})(n,r,h,f),a&&h.add(t.machine.root);const d=new Set;for(const t of[...f].sort(((t,e)=>t.order-e.order))){i.add(t);const n=[];n.push(...t.entry);for(const e of t.invoke)n.push(U(e.src,{...e,syncSnapshot:!!e.onSnapshot}));if(h.has(t)){const e=t.initial.actions;n.push(...e)}if(u=jt(u,e,s,n,o,t.invoke.map((t=>t.id))),"final"===t.type){const n=t.parent;let r="parallel"===n?.type?n:n?.parent,a=r||t;for("compound"===n?.type&&o.push(c(n.id,t.output?$(t.output,u.context,e,s.self):void 0));"parallel"===r?.type&&!d.has(r)&&ot(i,r);)d.add(r),o.push(c(r.id)),a=r,r=r.parent;if(r)continue;u=Wt(u,{status:"done",output:kt(u,e,s,u.machine.root,a)})}}return u}(f,n,s,u,r,o,a,i);const h=[...r];"done"===f.status&&(f=jt(f,n,s,h.sort(((t,e)=>e.order-t.order)).flatMap((t=>t.exit)),o));try{return a===e.historyValue&&function(t,e){if(t.length!==e.size)return!1;for(const s of t)if(!e.has(s))return!1;return!0}(e._nodes,r)?f:Wt(f,{_nodes:h,historyValue:a})}catch(t){throw t}}function kt(t,e,s,n,i){if(!n.output)return;const o=c(i.id,i.output&&i.parent?$(i.output,t.context,e,s.self):void 0);return $(n.output,t.context,o,s.self)}function It(t,e,s,n){if(ft(t))if(e[t.id]){const i=e[t.id];for(const t of i)n.add(t),It(t,e,s,n);for(const o of i)Tt(o,t.parent,n,e,s)}else{const i=ut(t);for(const o of i.target)n.add(o),i===t.parent?.initial&&s.add(t.parent),It(o,e,s,n);for(const o of i.target)Tt(o,t,n,e,s)}else if("compound"===t.type){const[i]=t.initial.target;ft(i)||(n.add(i),s.add(i)),It(i,e,s,n),Tt(i,t,n,e,s)}else if("parallel"===t.type)for(const i of Z(t).filter((t=>!ft(t))))[...n].some((t=>mt(t,i)))||(ft(i)||(n.add(i),s.add(i)),It(i,e,s,n))}function Et(t,e,s,n,i){for(const o of n)if(i&&!mt(o,i)||t.add(o),"parallel"===o.type)for(const n of Z(o).filter((t=>!ft(t))))[...t].some((t=>mt(t,n)))||(t.add(n),It(n,e,s,t))}function Tt(t,e,s,n,i){Et(s,n,i,tt(t,e))}function Ot(t,e,s,n,i,o){const{machine:r}=t;let a=t;for(const t of n){const n="function"==typeof t,c=n?t:r.implementations.actions["string"==typeof t?t:t.type];if(!c)continue;const u={context:a.context,event:e,self:s?.self,system:s?.system},f=n||"string"==typeof t?void 0:"params"in t?"function"==typeof t.params?t.params({context:a.context,event:e}):t.params:void 0;if(!("resolve"in c)){s?.self._processingStatus===A.Running?c(u,f):s?.defer((()=>{c(u,f)}));continue}const h=c,[d,p,l]=h.resolve(s,a,u,f,c,i);a=d,"retryResolve"in h&&o?.push([h,p]),"execute"in h&&(s?.self._processingStatus===A.Running?h.execute(s,p):s?.defer(h.execute.bind(null,s,p))),l&&(a=Ot(a,e,s,l,i,o))}return a}function jt(t,e,s,n,i,o){const r=o?[]:void 0,a=Ot(t,e,s,n,{internalQueue:i,deferredActorIds:o},r);return r?.forEach((([t,e])=>{t.retryResolve(s,a,e)})),a}function Mt(t,e,s,n=[]){let i=t;const r=[];if(e.type===a)return i=Wt(Nt(i,e,s),{status:"stopped"}),r.push(i),{state:i,microstates:r};let c=e;if(c.type!==o){i=$t(At(c,i),t,s,c,!1,n),r.push(i)}let u=!0;for(;"active"===i.status;){let t=u?Pt(i,c):[];const e=t.length?i:void 0;if(!t.length){if(!n.length)break;c=n.shift(),t=At(c,i)}i=$t(t,i,s,c,!1,n),u=i!==e,r.push(i)}return"active"!==i.status&&Nt(i,c,s),{state:i,microstates:r}}function Nt(t,e,s){return jt(t,e,s,Object.values(t.children).map((t=>F(t))),[])}function At(t,e){return e.machine.getTransitionData(e,t)}function Pt(t,e){const s=new Set,n=t._nodes.filter(Y);for(const i of n)t:for(const n of[i].concat(tt(i,void 0)))if(n.always)for(const i of n.always)if(void 0===i.guard||L(i.guard,t.context,e,t)){s.add(i);break t}return St(Array.from(s),new Set(t._nodes),t.historyValue)}function Rt(t){return!!t&&"object"==typeof t&&"machine"in t&&"value"in t}const Dt=function(t){return g(t,this.value)},Jt=function(t){return this.tags.has(t)},Vt=function(t){const e=this.machine.getTransitionData(this,t);return!!e?.length&&e.some((t=>void 0!==t.target||t.actions.length))},Ct=function(){const{_nodes:t,tags:e,machine:s,getMeta:n,toJSON:i,can:o,hasTag:r,matches:a,...c}=this;return{...c,tags:Array.from(e)}},Bt=function(){return this._nodes.reduce(((t,e)=>(void 0!==e.meta&&(t[e.id]=e.meta),t)),{})};function zt(t,e){return{status:t.status,output:t.output,error:t.error,machine:e,context:t.context,_nodes:t._nodes,value:it(e.root,t._nodes),tags:new Set(x(t._nodes.map((t=>t.tags)))),children:t.children,historyValue:t.historyValue||{},matches:Dt,hasTag:Jt,can:Vt,getMeta:Bt,toJSON:Ct}}function Wt(t,e={}){return zt({...t,...e},t.machine)}function Ut(t){let e;for(const s in t){const n=t[s];if(n&&"object"==typeof n)if("sessionId"in n&&"send"in n&&"ref"in n)e??=Array.isArray(t)?t.slice():{...t},e[s]={xstate$$type:N,id:n.id};else{const i=Ut(n);i!==n&&(e??=Array.isArray(t)?t.slice():{...t},e[s]=i)}}return e??t}function qt(t,{machine:e,context:s},n,i){return(o,r)=>{const a=((o,r={})=>{const{systemId:a,input:c}=r;if("string"==typeof o){const u=j(e,o);if(!u)throw new Error(`Actor logic '${o}' not implemented in machine '${e.id}'`);const f=D(u,{id:r.id,parent:t.self,syncSnapshot:r.syncSnapshot,input:"function"==typeof c?c({context:s,event:n,self:t.self}):c,src:o,systemId:a});return i[f.id]=f,f}return D(o,{id:r.id,parent:t.self,syncSnapshot:r.syncSnapshot,input:r.input,src:o,systemId:a})})(o,r);return i[a.id]=a,t.defer((()=>{if(a._processingStatus!==A.Stopped)try{a.start?.()}catch(e){return void t.self.send(u(a.id,e))}})),a}}function Qt(t,e,s,n,{assignment:i}){if(!e.context)throw new Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");const o={},r={context:e.context,event:s.event,spawn:qt(t,e,s.event,o),self:t?.self,system:t?.system};let a={};if("function"==typeof i)a=i(r,n);else for(const t of Object.keys(i)){const e=i[t];a[t]="function"==typeof e?e(r,n):e}return[Wt(e,{context:Object.assign({},e.context,a),children:Object.keys(o).length?{...e.children,...o}:e.children})]}function Ft(t){function e(t,e){}return e.type="xstate.assign",e.assignment=t,e.resolve=Qt,e}function Gt(t,e,s,n,{branches:i}){const o=i.find((t=>!t.guard||L(t.guard,e.context,s.event,e)))?.actions;return[e,void 0,w(o)]}function Xt(t,e,s,n,{value:i,label:o}){return[e,{value:"function"==typeof i?i(s,n):i,label:o}]}function Ht({logger:t},{value:e,label:s}){s?t(s,e):t(e)}function Kt(t,e,s,n,{get:i}){return[e,void 0,w(i({context:s.context,event:s.event}))]}function Lt(t,e,s,n,{event:i,id:o,delay:r},{internalQueue:a}){const c=e.machine.implementations.delays;if("string"==typeof i)throw new Error(`Only event objects may be used with raise; use raise({ type: "${i}" }) instead`);const u="function"==typeof i?i(s,n):i;let f;if("string"==typeof r){const t=c&&c[r];f="function"==typeof t?t(s,n):t}else f="function"==typeof r?r(s,n):r;return"number"!=typeof f&&a.push(u),[e,{event:u,id:o,delay:f}]}function Yt(t,e){"number"!=typeof e.delay||t.self.delaySend(e)}function Zt(t,e){function s(t,e){}return s.type="xstate.raise",s.event=t,s.id=e?.id,s.delay=e?.delay,s.resolve=Lt,s.execute=Yt,s}let te=function(t){return t.Parent="#_parent",t.Internal="#_internal",t}({});function ee(t,e,s,n,{to:i,event:o,id:r,delay:a},c){const u=e.machine.implementations.delays;if("string"==typeof o)throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${o}" }) instead`);const f="function"==typeof o?o(s,n):o;let h;if("string"==typeof a){const t=u&&u[a];h="function"==typeof t?t(s,n):t}else h="function"==typeof a?a(s,n):a;const d="function"==typeof i?i(s,n):i;let p;if("string"==typeof d){if(p=d===te.Parent?t?.self._parent:d===te.Internal?t?.self:d.startsWith("#_")?e.children[d.slice(2)]:c.deferredActorIds?.includes(d)?d:e.children[d],!p)throw new Error(`Unable to send event to actor '${d}' from machine '${e.machine.id}'.`)}else p=d||t?.self;return[e,{to:p,event:f,id:r,delay:h}]}function se(t,e,s){"string"==typeof s.to&&(s.to=e.children[s.to])}function ne(t,e){"number"!=typeof e.delay?t.defer((()=>{const{to:s,event:n}=e;t?.system._relay(t.self,s,n.type===r?u(t.self.id,n.data):n)})):t.self.delaySend(e)}function ie(t,e,s){function n(t,e){}return n.type="xstate.sendTo",n.to=t,n.event=e,n.id=s?.id,n.delay=s?.delay,n.resolve=ee,n.retryResolve=se,n.execute=ne,n}function oe(t,e){return ie(te.Parent,t,e)}function re(t,e){return{config:t,transition:(e,s,n)=>({...e,context:t(e.context,s,n)}),getInitialState:(t,s)=>({status:"active",output:void 0,error:void 0,context:"function"==typeof e?e({input:s}):e}),getPersistedState:t=>t,restoreState:t=>t}}const ae="$$xstate.resolve",ce="$$xstate.reject";const ue=re((t=>{}),void 0);const fe=new WeakMap;function he(t,e,s){let n=fe.get(t);return n?e in n||(n[e]=s()):(n={[e]:s()},fe.set(t,n)),n[e]}const de={},pe=t=>"string"==typeof t?{type:t}:"function"==typeof t?"resolve"in t?{type:t.type}:{type:t.name}:t;class le{constructor(t,e){if(this.config=t,this.key=void 0,this.id=void 0,this.type=void 0,this.path=void 0,this.states=void 0,this.history=void 0,this.entry=void 0,this.exit=void 0,this.parent=void 0,this.machine=void 0,this.meta=void 0,this.output=void 0,this.order=-1,this.description=void 0,this.tags=[],this.transitions=void 0,this.always=void 0,this.parent=e._parent,this.key=e._key,this.machine=e._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(s),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?S(this.config.states,((t,e)=>new le(t,{_parent:this,_key:e,_machine:this.machine}))):de,"compound"===this.type&&!this.config.initial)throw new Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);this.history=!0===this.config.history?"shallow":this.config.history||!1,this.entry=w(this.config.entry).slice(),this.exit=w(this.config.exit).slice(),this.meta=this.config.meta,this.output="final"!==this.type&&this.parent?void 0:this.config.output,this.tags=w(t.tags).slice()}_initialize(){this.transitions=function(t){const e=new Map;if(t.config.on)for(const s of Object.keys(t.config.on)){if(s===i)throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');const n=t.config.on[s];e.set(s,I(n).map((e=>ct(t,s,e))))}if(t.config.onDone){const s=`xstate.done.state.${t.id}`;e.set(s,I(t.config.onDone).map((e=>ct(t,s,e))))}for(const s of t.invoke){if(s.onDone){const n=`xstate.done.actor.${s.id}`;e.set(n,I(s.onDone).map((e=>ct(t,n,e))))}if(s.onError){const n=`xstate.error.actor.${s.id}`;e.set(n,I(s.onError).map((e=>ct(t,n,e))))}if(s.onSnapshot){const n=`xstate.snapshot.${s.id}`;e.set(n,I(s.onSnapshot).map((e=>ct(t,n,e))))}}for(const s of t.after){let t=e.get(s.eventType);t||(t=[],e.set(s.eventType,t)),t.push(s)}return e}(this),this.config.always&&(this.always=I(this.config.always).map((t=>ct(this,i,t)))),Object.keys(this.states).forEach((t=>{this.states[t]._initialize()}))}get definition(){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.map(pe),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map((t=>`#${t.id}`)),source:`#${this.id}`,actions:this.initial.actions.map(pe),eventType:null})}:void 0,history:this.history,states:S(this.states,(t=>t.definition)),on:this.on,transitions:[...this.transitions.values()].flat().map((t=>({...t,actions:t.actions.map(pe)}))),entry:this.entry.map(pe),exit:this.exit.map(pe),meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}toJSON(){return this.definition}get invoke(){return he(this,"invoke",(()=>w(this.config.invoke).map(((t,e)=>{const{src:s,systemId:n}=t,i=t.id||O(this.id,e),o="string"==typeof s?s:`xstate#${O(this.id,e)}`;return{...t,src:o,id:i,systemId:n,toJSON(){const{onDone:e,onError:s,...n}=t;return{...n,type:"xstate.invoke",src:o,id:i}}}}))))}get on(){return he(this,"on",(()=>[...this.transitions].flatMap((([t,e])=>e.map((e=>[t,e])))).reduce(((t,[e,s])=>(t[e]=t[e]||[],t[e].push(s),t)),{})))}get after(){return he(this,"delayedTransitions",(()=>at(this)))}get initial(){return he(this,"initial",(()=>function(t,e){const s="string"==typeof e?t.states[e]:e?t.states[e.target]:void 0;if(!s&&e)throw new Error(`Initial state node "${e}" not found on parent state node #${t.id}`);const n={source:t,actions:e&&"string"!=typeof e?w(e.actions):[],eventType:null,reenter:!1,target:s?[s]:[],toJSON:()=>({...n,source:`#${t.id}`,target:s?[`#${s.id}`]:[]})};return n}(this,this.config.initial)))}next(t,e){const s=e.type,n=[];let i;const o=he(this,`candidates-${s}`,(()=>{return e=s,(t=this).transitions.get(e)||[...t.transitions.keys()].filter((t=>{if("*"===t)return!0;if(!t.endsWith(".*"))return!1;const s=t.split("."),n=e.split(".");for(let t=0;t<s.length;t++){const e=s[t],i=n[t];if("*"===e)return t===s.length-1;if(e!==i)return!1}return!0})).sort(((t,e)=>e.length-t.length)).flatMap((e=>t.transitions.get(e)));var t,e}));for(const r of o){const{guard:o}=r,a=t.context;let c=!1;try{c=!o||L(o,a,e,t)}catch(t){const e="string"==typeof o?o:"object"==typeof o?o.type:void 0;throw new Error(`Unable to evaluate guard ${e?`'${e}' `:""}in transition for event '${s}' in state node '${this.id}':\n${t.message}`)}if(c){n.push(...r.actions),i=r;break}}return i?[i]:void 0}get events(){return he(this,"events",(()=>{const{states:t}=this,e=new Set(this.ownEvents);if(t)for(const s of Object.keys(t)){const n=t[s];if(n.states)for(const t of n.events)e.add(`${t}`)}return Array.from(e)}))}get ownEvents(){const t=new Set([...this.transitions.keys()].filter((t=>this.transitions.get(t).some((t=>!(!t.target&&!t.actions.length&&!t.reenter))))));return Array.from(t)}}class ye{constructor(t,e){this.config=t,this.version=void 0,this.implementations=void 0,this.types=void 0,this.__xstatenode=!0,this.idMap=new Map,this.root=void 0,this.id=void 0,this.states=void 0,this.events=void 0,this.__TResolvedTypesMeta=void 0,this.id=t.id||"(machine)",this.implementations={actors:e?.actors??{},actions:e?.actions??{},delays:e?.delays??{},guards:e?.guards??{}},this.version=this.config.version,this.types=this.config.types??{},this.transition=this.transition.bind(this),this.getInitialState=this.getInitialState.bind(this),this.restoreState=this.restoreState.bind(this),this.start=this.start.bind(this),this.root=new le(t,{_key:this.id,_machine:this}),this.root._initialize(),this.states=this.root.states,this.events=this.root.events}provide(t){const{actions:e,guards:s,actors:n,delays:i}=this.implementations;return new ye(this.config,{actions:{...e,...t.actions},guards:{...s,...t.guards},actors:{...n,...t.actors},delays:{...i,...t.delays}})}resolveState(t){const e=(s=this.root,n=t.value,it(s,[...et(yt(s,n))]));var s,n;const i=et(yt(this.root,e));return zt({_nodes:[...i],context:t.context||{},children:{},status:ot(i,this.root)?"done":t.status||"active",output:t.output,error:t.error,historyValue:t.historyValue},this)}transition(t,e,s){if(function(t){return t.type.startsWith("xstate.error.actor")}(e)&&!M(t).some((t=>t===e.type)))return Wt(t,{status:"error",error:e.data});const{state:n}=Mt(t,e,s);return n}microstep(t,e,s){return Mt(t,e,s).microstates}getTransitionData(t,e){return gt(this.root,t.value,t,e)||[]}getPreInitialState(t,e,s){const{context:n}=this.config,i=zt({context:"function"!=typeof n&&n?n:{},_nodes:[this.root],children:{},status:"active"},this);if("function"==typeof n){const o=({spawn:t,event:e})=>n({spawn:t,input:e.input});return jt(i,e,t,[Ft(o)],s)}return i}getInitialState(t,e){const s=f(e),n=[],i=this.getPreInitialState(t,s,n),o=$t([{target:[...dt(this.root)],source:this.root,reenter:!0,actions:[],eventType:null,toJSON:null}],i,t,s,!0,n),{state:r}=Mt(o,s,t,n);return r}start(t){Object.values(t.children).forEach((t=>{"active"===t.getSnapshot().status&&t.start()}))}getStateNodeById(t){const e=t.split(s),n=e.slice(1),i=rt(e[0])?e[0].slice(1):e[0],o=this.idMap.get(i);if(!o)throw new Error(`Child state node '#${i}' does not exist on machine '${this.id}'`);return lt(o,n)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedState(t,e){return function(t,e){const{_nodes:s,tags:n,machine:i,children:o,context:r,can:a,hasTag:c,matches:u,getMeta:f,toJSON:h,...d}=t,p={};for(const t in o){const s=o[t];p[t]={state:s.getPersistedState(e),src:s.src,systemId:s._systemId,syncSnapshot:s._syncSnapshot}}return{...d,context:Ut(r),children:p}}(t,e)}restoreState(t,e){const s={},n=t.children;Object.keys(n).forEach((t=>{const i=n[t],o=i.state,r=i.src,a="string"==typeof r?j(this,r):r;if(!a)return;const c=D(a,{id:t,parent:e?.self,syncSnapshot:i.syncSnapshot,state:o,src:r,systemId:i.systemId});s[t]=c}));const i=zt({...t,children:s,_nodes:Array.from(et(yt(this.root,t.value)))},this);let o=new Set;return function t(e,s){if(!o.has(e)){o.add(e);for(let n in e){const i=e[n];if(i&&"object"==typeof i){if("xstate$$type"in i&&i.xstate$$type===N){e[n]=s[i.id];continue}t(i,s)}}}}(i.context,s),i}}const ge={timeout:1/0};function ve(t,e){return new ye(t,e)}t.Actor=R,t.SimulatedClock=class{constructor(){this.timeouts=new Map,this._now=0,this._id=0}now(){return this._now}getId(){return this._id++}setTimeout(t,e){const s=this.getId();return this.timeouts.set(s,{start:this.now(),timeout:e,fn:t}),s}clearTimeout(t){this.timeouts.delete(t)}set(t){if(this._now>t)throw new Error("Unable to travel back in time");this._now=t,this.flushTimeouts()}flushTimeouts(){[...this.timeouts].sort((([t,e],[s,n])=>{const i=e.start+e.timeout;return n.start+n.timeout>i?-1:1})).forEach((([t,e])=>{this.now()-e.start>=e.timeout&&(this.timeouts.delete(t),e.fn.call(null))}))}increment(t){this._now+=t,this.flushTimeouts()}},t.SpecialTargets=te,t.StateMachine=ye,t.StateNode=le,t.__unsafe_getAllOwnEventDescriptors=M,t.and=function(t){function e(t,e){return!1}return e.check=H,e.guards=t,e},t.assign=Ft,t.cancel=B,t.choose=function(t){function e(t,e){}return e.type="xstate.choose",e.branches=t,e.resolve=Gt,e},t.createActor=D,t.createEmptyActor=function(){return D(ue)},t.createMachine=ve,t.escalate=function(t,e){return oe((e=>({type:r,data:"function"==typeof t?t(e):t})),e)},t.forwardTo=function(t,e){return ie(t,(({event:t})=>t),e)},t.fromCallback=function(t){return{config:t,start:(t,{self:e,system:s})=>{s._relay(e,e,{type:"xstate.create"})},transition:(e,s,{self:n,system:i})=>{if("xstate.create"===s.type){const s=t=>{"stopped"!==e.status&&n._parent&&i._relay(n,n._parent,t)},o=t=>{e._receivers.add(t)};return e._dispose=t({input:e.input,system:i,self:n,sendBack:s,receive:o}),e}return s.type===a?("function"==typeof(e={...e,status:"stopped",error:void 0})._dispose&&e._dispose(),e):(e._receivers.forEach((t=>t(s))),e)},getInitialState:(t,e)=>({status:"active",output:void 0,error:void 0,input:e,_receivers:new Set,_dispose:void 0}),getPersistedState:({_dispose:t,_receivers:e,...s})=>s,restoreState:t=>({_receivers:new Set,_dispose:void 0,...t})}},t.fromEventObservable=function(t){const e="$$xstate.error",s="$$xstate.complete";return{config:t,transition:(t,n)=>{if("active"!==t.status)return t;switch(n.type){case e:return{...t,status:"error",error:n.data,input:void 0,_subscription:void 0};case s:return{...t,status:"done",input:void 0,_subscription:void 0};case a:return t._subscription.unsubscribe(),{...t,status:"stopped",input:void 0,_subscription:void 0};default:return t}},getInitialState:(t,e)=>({status:"active",output:void 0,error:void 0,context:void 0,input:e,_subscription:void 0}),start:(n,{self:i,system:o})=>{"done"!==n.status&&(n._subscription=t({input:n.input,system:o,self:i}).subscribe({next:t=>{i._parent&&o._relay(i,i._parent,t)},error:t=>{o._relay(i,i,{type:e,data:t})},complete:()=>{o._relay(i,i,{type:s})}}))},getPersistedState:({_subscription:t,...e})=>e,restoreState:t=>({...t,_subscription:void 0})}},t.fromObservable=function(t){const e="$$xstate.next",s="$$xstate.error",n="$$xstate.complete";return{config:t,transition:(t,i,{self:o,id:r,defer:c,system:u})=>{if("active"!==t.status)return t;switch(i.type){case e:return{...t,context:i.data};case s:return{...t,status:"error",error:i.data,input:void 0,_subscription:void 0};case n:return{...t,status:"done",input:void 0,_subscription:void 0};case a:return t._subscription.unsubscribe(),{...t,status:"stopped",input:void 0,_subscription:void 0};default:return t}},getInitialState:(t,e)=>({status:"active",output:void 0,error:void 0,context:void 0,input:e,_subscription:void 0}),start:(i,{self:o,system:r})=>{"done"!==i.status&&(i._subscription=t({input:i.input,system:r,self:o}).subscribe({next:t=>{r._relay(o,o,{type:e,data:t})},error:t=>{r._relay(o,o,{type:s,data:t})},complete:()=>{r._relay(o,o,{type:n})}}))},getPersistedState:({_subscription:t,...e})=>e,restoreState:t=>({...t,_subscription:void 0})}},t.fromPromise=function(t){return{config:t,transition:(t,e)=>{if("active"!==t.status)return t;switch(e.type){case ae:{const s=e.data;return{...t,status:"done",output:s,input:void 0}}case ce:return{...t,status:"error",error:e.data,input:void 0};case a:return{...t,status:"stopped",input:void 0};default:return t}},start:(e,{self:s,system:n})=>{if("active"!==e.status)return;Promise.resolve(t({input:e.input,system:n,self:s})).then((t=>{"active"===s.getSnapshot().status&&n._relay(s,s,{type:ae,data:t})}),(t=>{"active"===s.getSnapshot().status&&n._relay(s,s,{type:ce,data:t})}))},getInitialState:(t,e)=>({status:"active",output:void 0,error:void 0,input:e}),getPersistedState:t=>t,restoreState:t=>t}},t.fromTransition=re,t.getStateNodes=yt,t.interpret=J,t.isMachineSnapshot=Rt,t.log=function(t=(({context:t,event:e})=>({context:t,event:e})),e){function s(t,e){}return s.type="xstate.log",s.value=t,s.label=e,s.resolve=Xt,s.execute=Ht,s},t.matchesState=g,t.not=function(t){function e(t,e){return!1}return e.check=X,e.guards=[t],e},t.or=function(t){function e(t,e){return!1}return e.check=K,e.guards=t,e},t.pathToStateValue=_,t.pure=function(t){function e(t,e){}return e.type="xstate.pure",e.get=t,e.resolve=Kt,e},t.raise=Zt,t.sendParent=oe,t.sendTo=ie,t.setup=function({actors:t,actions:e,guards:s,delays:n}){return{createMachine:i=>ve(i,{actors:t,actions:e,guards:s,delays:n})}},t.spawn=U,t.stateIn=function(t){function e(t,e){return!1}return e.check=G,e.stateValue=t,e},t.stop=F,t.toObserver=T,t.waitFor=function(t,e,s){const n={...ge,...s};return new Promise(((s,i)=>{let o=!1;const r=n.timeout===1/0?void 0:setTimeout((()=>{u.unsubscribe(),i(new Error(`Timeout of ${n.timeout} ms exceeded`))}),n.timeout),a=()=>{clearTimeout(r),o=!0,u?.unsubscribe()};function c(t){e(t)&&(a(),s(t))}let u;c(t.getSnapshot()),o||(u=t.subscribe({next:c,error:t=>{a(),i(t)},complete:()=>{a(),i(new Error("Actor terminated without satisfying predicate"))}}),o&&u.unsubscribe())}))},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";class e{constructor(t){this._process=t,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(t){const 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()}flush(){for(;this._current;){const t=this._current;this._process(t.value),this._current=t.next}this._last=null}}const s=".",n="",i="",o="xstate.init",r="xstate.error",a="xstate.stop";function c(t,e){return{type:`xstate.done.state.${t}`,output:e}}function u(t,e){return{type:`xstate.error.actor.${t}`,data:e}}function h(t){return{type:o,input:t}}function f(){const t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:window;if(t.__xstate__)return t.__xstate__}const d=t=>{const e=f();e&&e.register(t)};function p(t){setTimeout((()=>{throw t}))}const l="function"==typeof Symbol&&Symbol.observable||"@@observable";let y=0;function g(t,e){const s=m(t),n=m(e);return"string"==typeof n?"string"==typeof s&&n===s:"string"==typeof s?s in n:Object.keys(s).every((t=>t in n&&g(s[t],n[t])))}function v(t){try{return k(t)?t:t.split(s)}catch(e){throw new Error(`'${t}' is not a valid state path.`)}}function m(t){if(Ct(t))return t.value;if("string"!=typeof t)return t;return _(v(t))}function _(t){if(1===t.length)return t[0];const e={};let s=e;for(let e=0;e<t.length-1;e++)if(e===t.length-2)s[t[e]]=t[e+1];else{const n=s;s={},n[t[e]]=s}return e}function S(t,e){const s={},n=Object.keys(t);for(let i=0;i<n.length;i++){const o=n[i];s[o]=e(t[o],o,t,i)}return s}function x(t){return[].concat(...t)}function b(t){return k(t)?t:[t]}function w(t){return void 0===t?[]:b(t)}function $(t,e,s,n){return"function"==typeof t?t({context:e,event:s,self:n}):t}function k(t){return Array.isArray(t)}function I(t){return b(t).map((t=>void 0===t||"string"==typeof t?{target:t}:t))}function E(t){if(void 0!==t&&t!==n)return w(t)}function T(t,e,s){const n="object"==typeof t,i=n?t:void 0;return{next:(n?t.next:t)?.bind(i),error:(n?t.error:e)?.bind(i),complete:(n?t.complete:s)?.bind(i)}}function O(t,e){return`${t}[${e}]`}function j(t,e){if(e.startsWith("xstate#")){const[,s]=e.match(/\[(\d+)\]$/),n=t.getStateNodeById(e.slice(7,-(s.length+2))).config.invoke;return(Array.isArray(n)?n[s]:n).src}return t.implementations.actors[e]}function M(t){return[...new Set(x([...t._nodes.map((t=>t.ownEvents))]))]}const N=1;let A=function(t){return t[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped",t}({});const P={clock:{setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t)},logger:console.log.bind(console),devTools:!1};class R{constructor(t,s){this.logic=t,this._state=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new e(this._process.bind(this)),this.delayedEventsMap={},this.observers=new Set,this.logger=void 0,this._processingStatus=A.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this._systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];const n={...P,...s},{clock:i,logger:o,parent:r,syncSnapshot:a,id:c,systemId:u,inspect:h}=n;this.system=r?.system??function(t){const e=new Map,s=new Map,n=new WeakMap,i=new Set,o={_bookId:()=>"x:"+y++,_register:(t,s)=>(e.set(t,s),t),_unregister:t=>{e.delete(t.sessionId);const i=n.get(t);void 0!==i&&(s.delete(i),n.delete(t))},get:t=>s.get(t),_set:(t,e)=>{const i=s.get(t);if(i&&i!==e)throw new Error(`Actor with system ID '${t}' already exists.`);s.set(t,e),n.set(e,t)},inspect:t=>{i.add(t)},_sendInspectionEvent:e=>{const s={...e,rootId:t.sessionId};i.forEach((t=>t.next?.(s)))},_relay:(t,e,s)=>{o._sendInspectionEvent({type:"@xstate.event",sourceRef:t,actorRef:e,event:s}),e._send(s)}};return o}(this),h&&!r&&this.system.inspect(T(h)),this.sessionId=this.system._bookId(),this.id=c??this.sessionId,this.logger=o,this.clock=i,this._parent=r,this._syncSnapshot=a,this.options=n,this.src=n.src??t,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:t=>{this._deferred.push(t)},system:this.system,stopChild:t=>{if(t._parent!==this)throw new Error(`Cannot stop child actor ${t.id} of ${this.id} because it is not a child`);t._stop()}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),u&&(this._systemId=u,this.system._set(u,this)),this._initState(s?.state),u&&"active"!==this._state.status&&this.system._unregister(this)}_initState(t){this._state=t?this.logic.restoreState?this.logic.restoreState(t,this._actorScope):t:this.logic.getInitialState(this._actorScope,this.options?.input)}update(t,e){let s;for(this._state=t;s=this._deferred.shift();)s();for(const e of this.observers)try{e.next?.(t)}catch(t){p(t)}switch(this._state.status){case"done":this._stopProcedure(),this._complete(),this._doneEvent=(n=this.id,i=this._state.output,{type:`xstate.done.actor.${n}`,output:i}),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case"error":this._stopProcedure(),this._error(this._state.error),this._parent&&this.system._relay(this,this._parent,u(this.id,this._state.error))}var n,i;this.system._sendInspectionEvent({type:"@xstate.snapshot",actorRef:this,event:e,snapshot:t})}subscribe(t,e,s){const n=T(t,e,s);if(this._processingStatus!==A.Stopped)this.observers.add(n);else try{n.complete?.()}catch(t){p(t)}return{unsubscribe:()=>{this.observers.delete(n)}}}start(){if(this._processingStatus===A.Running)return this;this._syncSnapshot&&this.subscribe({next:t=>{"active"===t.status&&this._parent.send({type:`xstate.snapshot.${this.id}`,snapshot:t})},error:()=>{}}),this.system._register(this.sessionId,this),this._systemId&&this.system._set(this._systemId,this),this._processingStatus=A.Running;const t=h(this.options.input);this.system._sendInspectionEvent({type:"@xstate.event",sourceRef:this._parent,actorRef:this,event:t});switch(this._state.status){case"done":this.update(this._state,t);case"error":return this}if(this.logic.start)try{this.logic.start(this._state,this._actorScope)}catch(t){return this._stopProcedure(),this._error(t),this._parent?.send(u(this.id,t)),this}return this.update(this._state,t),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(t){let e,s;try{e=this.logic.transition(this._state,t,this._actorScope)}catch(t){s={err:t}}if(s){const{err:t}=s;return this._stopProcedure(),this._error(t),void this._parent?.send(u(this.id,t))}this.update(e,t),t.type===a&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===A.Stopped?this:(this.mailbox.clear(),this._processingStatus===A.NotStarted?(this._processingStatus=A.Stopped,this):(this.mailbox.enqueue({type:a}),this))}stop(){if(this._parent)throw new Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){for(const t of this.observers)try{t.complete?.()}catch(t){p(t)}this.observers.clear()}_error(t){if(!this.observers.size)return void(this._parent||p(t));let e=!1;for(const s of this.observers){const n=s.error;e||=!n;try{n?.(t)}catch(t){p(t)}}this.observers.clear(),e&&p(t)}_stopProcedure(){if(this._processingStatus!==A.Running)return this;for(const t of Object.keys(this.delayedEventsMap))this.clock.clearTimeout(this.delayedEventsMap[t]);return this.mailbox.clear(),this.mailbox=new e(this._process.bind(this)),this._processingStatus=A.Stopped,this.system._unregister(this),this}_send(t){this._processingStatus!==A.Stopped&&this.mailbox.enqueue(t)}send(t){this.system._relay(void 0,this,t)}delaySend(t){const{event:e,id:s,delay:n}=t,i=this.clock.setTimeout((()=>{this.system._relay(this,t.to??this,e)}),n);s&&(this.delayedEventsMap[s]=i)}cancel(t){this.clock.clearTimeout(this.delayedEventsMap[t]),delete this.delayedEventsMap[t]}attachDevTools(){const{devTools:t}=this.options;if(t){("function"==typeof t?t:d)(this)}}toJSON(){return{xstate$$type:N,id:this.id}}getPersistedState(t){return this.logic.getPersistedState(this._state,t)}[l](){return this}getSnapshot(){return this._state}}function C(t,e){return new R(t,e)}const D=C;function J(t,e,s,n,{sendId:i}){return[e,"function"==typeof i?i(s,n):i]}function V(t,e){t.self.cancel(e)}function B(t){function e(t,e){}return e.type="xstate.cancel",e.sendId=t,e.resolve=J,e.execute=V,e}function z(t,e,s,n,{id:i,systemId:o,src:r,input:a,syncSnapshot:c}){const u="string"==typeof r?j(e.machine,r):r,h="function"==typeof i?i(s):i;let f;return u&&(f=C(u,{id:h,src:r,parent:t?.self,syncSnapshot:c,systemId:o,input:"function"==typeof a?a({context:e.context,event:s.event,self:t?.self}):a})),[Ut(e,{children:{...e.children,[h]:f}}),{id:i,actorRef:f}]}function W(t,{id:e,actorRef:s}){s&&t.defer((()=>{if(s._processingStatus!==A.Stopped)try{s.start?.()}catch(s){return void t.self.send(u(e,s))}}))}function U(...[t,{id:e,systemId:s,input:n,syncSnapshot:i=!1}={}]){function o(t,e){}return o.type="xstate.spawnChild",o.id=e,o.systemId=s,o.src=t,o.input=n,o.syncSnapshot=i,o.resolve=z,o.execute=W,o}function q(t,e,s,n,{actorRef:i}){const o="function"==typeof i?i(s,n):i,r="string"==typeof o?e.children[o]:o;let a=e.children;return r&&(a={...a},delete a[r.id]),[Ut(e,{children:a}),r]}function Q(t,e){e&&(t.system._unregister(e),e._processingStatus===A.Running?t.defer((()=>{t.stopChild(e)})):t.stopChild(e))}function F(t){function e(t,e){}return e.type="xstate.stopChild",e.actorRef=t,e.resolve=q,e.execute=Q,e}const G=F;function X(t,e,{stateValue:s}){if("string"==typeof s&&at(s)){const e=t.machine.getStateNodeById(s);return t._nodes.some((t=>t===e))}return t.matches(s)}function H(t,{context:e,event:s},{guards:n}){return!Y(n[0],e,s,t)}function K(t,{context:e,event:s},{guards:n}){return n.every((n=>Y(n,e,s,t)))}function L(t,{context:e,event:s},{guards:n}){return n.some((n=>Y(n,e,s,t)))}function Y(t,e,s,n){const{machine:i}=n,o="function"==typeof t,r=o?t:i.implementations.guards["string"==typeof t?t:t.type];if(!o&&!r)throw new Error(`Guard '${"string"==typeof t?t:t.type}' is not implemented.'.`);if("function"!=typeof r)return Y(r,e,s,n);const a={context:e,event:s},c=o||"string"==typeof t?void 0:"params"in t?"function"==typeof t.params?t.params({context:e,event:s}):t.params:void 0;if(!("check"in r))return r(a,c);return r.check(n,a,r)}const Z=t=>"atomic"===t.type||"final"===t.type;function tt(t){return Object.values(t.states).filter((t=>"history"!==t.type))}function et(t,e){const s=[];if(e===t)return s;let n=t.parent;for(;n&&n!==e;)s.push(n),n=n.parent;return s}function st(t){const e=new Set(t),s=it(e);for(const t of e)if("compound"!==t.type||s.get(t)&&s.get(t).length){if("parallel"===t.type)for(const s of tt(t))if("history"!==s.type&&!e.has(s)){const t=dt(s);for(const s of t)e.add(s)}}else dt(t).forEach((t=>e.add(t)));for(const t of e){let s=t.parent;for(;s;)e.add(s),s=s.parent}return e}function nt(t,e){const s=e.get(t);if(!s)return{};if("compound"===t.type){const t=s[0];if(!t)return{};if(Z(t))return t.key}const n={};for(const t of s)n[t.key]=nt(t,e);return n}function it(t){const e=new Map;for(const s of t)e.has(s)||e.set(s,[]),s.parent&&(e.has(s.parent)||e.set(s.parent,[]),e.get(s.parent).push(s));return e}function ot(t,e){return nt(t,it(st(e)))}function rt(t,e){return"compound"===e.type?tt(e).some((e=>"final"===e.type&&t.has(e))):"parallel"===e.type?tt(e).every((e=>rt(t,e))):"final"===e.type}const at=t=>"#"===t[0];function ct(t){const e=t.config.after;if(!e)return[];return Object.keys(e).flatMap(((s,n)=>{const i=e[s],o="string"==typeof i?{target:i}:i,r=isNaN(+s)?s:+s,a=((e,s)=>{const n=(o="function"==typeof e?`${t.id}:delay[${s}]`:e,r=t.id,{type:`xstate.after(${o})${r?`#${r}`:""}`}),i=n.type;var o,r;return t.entry.push(te(n,{id:i,delay:e})),t.exit.push(B(i)),i})(r,n);return w(o).map((t=>({...t,event:a,delay:r})))})).map((e=>{const{delay:s}=e;return{...ut(t,e.event,e),delay:s}}))}function ut(t,e,n){const i=E(n.target),o=n.reenter??!1,r=function(t,e){if(void 0===e)return;return e.map((e=>{if("string"!=typeof e)return e;if(at(e))return t.machine.getStateNodeById(e);const n=e[0]===s;if(n&&!t.parent)return yt(t,e.slice(1));const i=n?t.key+e:e;if(!t.parent)throw new Error(`Invalid target: "${e}" is not a valid target from the root node. Did you mean ".${e}"?`);try{return yt(t.parent,i)}catch(e){throw new Error(`Invalid transition definition for state node '${t.id}':\n${e.message}`)}}))}(t,i),a={...n,actions:w(n.actions),guard:n.guard,target:r,source:t,reenter:o,eventType:e,toJSON:()=>({...a,source:`#${t.id}`,target:r?r.map((t=>`#${t.id}`)):void 0})};return a}function ht(t){const e=E(t.config.target);return e?{target:e.map((e=>"string"==typeof e?yt(t.parent,e):e))}:t.parent.initial}function ft(t){return"history"===t.type}function dt(t){const e=pt(t);for(const s of e)for(const n of et(s,t))e.add(n);return e}function pt(t){const e=new Set;return function t(s){if(!e.has(s))if(e.add(s),"compound"===s.type)t(s.initial.target[0]);else if("parallel"===s.type)for(const e of tt(s))t(e)}(t),e}function lt(t,e){if(at(e))return t.machine.getStateNodeById(e);if(!t.states)throw new Error(`Unable to retrieve child state '${e}' from '${t.id}'; no child states exist.`);const s=t.states[e];if(!s)throw new Error(`Child state '${e}' does not exist on '${t.id}'`);return s}function yt(t,e){if("string"==typeof e&&at(e))try{return t.machine.getStateNodeById(e)}catch(t){}const s=v(e).slice();let n=t;for(;s.length;){const t=s.shift();if(!t.length)break;n=lt(n,t)}return n}function gt(t,e){if("string"==typeof e)return[t,t.states[e]];const s=Object.keys(e),n=s.map((e=>lt(t,e))).filter(Boolean);return[t.machine.root,t].concat(n,s.reduce(((s,n)=>{const i=lt(t,n);if(!i)return s;const o=gt(i,e[n]);return s.concat(o)}),[]))}function vt(t,e,s,n){return"string"==typeof e?function(t,e,s,n){const i=lt(t,e).next(s,n);return i&&i.length?i:t.next(s,n)}(t,e,s,n):1===Object.keys(e).length?function(t,e,s,n){const i=Object.keys(e),o=vt(lt(t,i[0]),e[i[0]],s,n);return o&&o.length?o:t.next(s,n)}(t,e,s,n):function(t,e,s,n){const i=[];for(const o of Object.keys(e)){const r=e[o];if(!r)continue;const a=vt(lt(t,o),r,s,n);a&&i.push(...a)}return i.length?i:t.next(s,n)}(t,e,s,n)}function mt(t){return Object.keys(t.states).map((e=>t.states[e])).filter((t=>"history"===t.type))}function _t(t,e){let s=t;for(;s.parent&&s.parent!==e;)s=s.parent;return s.parent===e}function St(t,e){const s=new Set(t),n=new Set(e);for(const t of s)if(n.has(t))return!0;for(const t of n)if(s.has(t))return!0;return!1}function xt(t,e,s){const n=new Set;for(const i of t){let t=!1;const o=new Set;for(const r of n)if(St($t([i],e,s),$t([r],e,s))){if(!_t(i.source,r.source)){t=!0;break}o.add(r)}if(!t){for(const t of o)n.delete(t);n.add(i)}}return Array.from(n)}function bt(t,e){if(!t.target)return[];const s=new Set;for(const n of t.target)if(ft(n))if(e[n.id])for(const t of e[n.id])s.add(t);else for(const t of bt(ht(n),e))s.add(t);else s.add(n);return[...s]}function wt(t,e){const s=bt(t,e);if(!s)return;if(!t.reenter&&s.every((e=>e===t.source||_t(e,t.source))))return t.source;const n=function(t){const[e,...s]=t;for(const t of et(e,void 0))if(s.every((e=>_t(e,t))))return t}(s.concat(t.source));return n||(t.reenter?void 0:t.source.machine.root)}function $t(t,e,s){const n=new Set;for(const i of t)if(i.target?.length){const t=wt(i,s);i.reenter&&i.source===t&&n.add(t);for(const s of e)_t(s,t)&&n.add(s)}return[...n]}function kt(t,e,s,n,i,o){if(!t.length)return e;const r=new Set(e._nodes);let a=e.historyValue;const u=xt(t,r,a);let h=e;i||([h,a]=function(t,e,s,n,i,o,r){let a=t;const c=$t(n,i,o);let u;c.sort(((t,e)=>e.order-t.order));for(const t of c)for(const e of mt(t)){let s;s="deep"===e.history?e=>Z(e)&&_t(e,t):e=>e.parent===t,u??={...o},u[e.id]=Array.from(i).filter(s)}for(const t of c)a=Mt(a,e,s,[...t.exit,...t.invoke.map((t=>F(t.id)))],r),i.delete(t);return[a,u||o]}(h,n,s,u,r,a,o)),h=Mt(h,n,s,u.flatMap((t=>t.actions)),o),h=function(t,e,s,n,i,o,r,a){let u=t;const h=new Set,f=new Set;(function(t,e,s,n){for(const i of t){const t=wt(i,e);for(const o of i.target||[])ft(o)||i.source===o&&i.source===t&&!i.reenter||(n.add(o),s.add(o)),Et(o,e,s,n);const o=bt(i,e);for(const r of o){const o=et(r,t);"parallel"===t?.type&&o.push(t),Tt(n,e,s,o,!i.source.parent&&i.reenter?void 0:t)}}})(n,r,f,h),a&&f.add(t.machine.root);const d=new Set;for(const t of[...h].sort(((t,e)=>t.order-e.order))){i.add(t);const n=[];n.push(...t.entry);for(const e of t.invoke)n.push(U(e.src,{...e,syncSnapshot:!!e.onSnapshot}));if(f.has(t)){const e=t.initial.actions;n.push(...e)}if(u=Mt(u,e,s,n,o,t.invoke.map((t=>t.id))),"final"===t.type){const n=t.parent;let r="parallel"===n?.type?n:n?.parent,a=r||t;for("compound"===n?.type&&o.push(c(n.id,t.output?$(t.output,u.context,e,s.self):void 0));"parallel"===r?.type&&!d.has(r)&&rt(i,r);)d.add(r),o.push(c(r.id)),a=r,r=r.parent;if(r)continue;u=Ut(u,{status:"done",output:It(u,e,s,u.machine.root,a)})}}return u}(h,n,s,u,r,o,a,i);const f=[...r];"done"===h.status&&(h=Mt(h,n,s,f.sort(((t,e)=>e.order-t.order)).flatMap((t=>t.exit)),o));try{return a===e.historyValue&&function(t,e){if(t.length!==e.size)return!1;for(const s of t)if(!e.has(s))return!1;return!0}(e._nodes,r)?h:Ut(h,{_nodes:f,historyValue:a})}catch(t){throw t}}function It(t,e,s,n,i){if(!n.output)return;const o=c(i.id,i.output&&i.parent?$(i.output,t.context,e,s.self):void 0);return $(n.output,t.context,o,s.self)}function Et(t,e,s,n){if(ft(t))if(e[t.id]){const i=e[t.id];for(const t of i)n.add(t),Et(t,e,s,n);for(const o of i)Ot(o,t.parent,n,e,s)}else{const i=ht(t);for(const o of i.target)n.add(o),i===t.parent?.initial&&s.add(t.parent),Et(o,e,s,n);for(const o of i.target)Ot(o,t,n,e,s)}else if("compound"===t.type){const[i]=t.initial.target;ft(i)||(n.add(i),s.add(i)),Et(i,e,s,n),Ot(i,t,n,e,s)}else if("parallel"===t.type)for(const i of tt(t).filter((t=>!ft(t))))[...n].some((t=>_t(t,i)))||(ft(i)||(n.add(i),s.add(i)),Et(i,e,s,n))}function Tt(t,e,s,n,i){for(const o of n)if(i&&!_t(o,i)||t.add(o),"parallel"===o.type)for(const n of tt(o).filter((t=>!ft(t))))[...t].some((t=>_t(t,n)))||(t.add(n),Et(n,e,s,t))}function Ot(t,e,s,n,i){Tt(s,n,i,et(t,e))}function jt(t,e,s,n,i,o){const{machine:r}=t;let a=t;for(const t of n){const n="function"==typeof t,c=n?t:r.implementations.actions["string"==typeof t?t:t.type];if(!c)continue;const u={context:a.context,event:e,self:s?.self,system:s?.system},h=n||"string"==typeof t?void 0:"params"in t?"function"==typeof t.params?t.params({context:a.context,event:e}):t.params:void 0;if(!("resolve"in c)){s?.self._processingStatus===A.Running?c(u,h):s?.defer((()=>{c(u,h)}));continue}const f=c,[d,p,l]=f.resolve(s,a,u,h,c,i);a=d,"retryResolve"in f&&o?.push([f,p]),"execute"in f&&(s?.self._processingStatus===A.Running?f.execute(s,p):s?.defer(f.execute.bind(null,s,p))),l&&(a=jt(a,e,s,l,i,o))}return a}function Mt(t,e,s,n,i,o){const r=o?[]:void 0,a=jt(t,e,s,n,{internalQueue:i,deferredActorIds:o},r);return r?.forEach((([t,e])=>{t.retryResolve(s,a,e)})),a}function Nt(t,e,s,n=[]){let i=t;const r=[];if(e.type===a)return i=Ut(At(i,e,s),{status:"stopped"}),r.push(i),{state:i,microstates:r};let c=e;if(c.type!==o){i=kt(Pt(c,i),t,s,c,!1,n),r.push(i)}let u=!0;for(;"active"===i.status;){let t=u?Rt(i,c):[];const e=t.length?i:void 0;if(!t.length){if(!n.length)break;c=n.shift(),t=Pt(c,i)}i=kt(t,i,s,c,!1,n),u=i!==e,r.push(i)}return"active"!==i.status&&At(i,c,s),{state:i,microstates:r}}function At(t,e,s){return Mt(t,e,s,Object.values(t.children).map((t=>F(t))),[])}function Pt(t,e){return e.machine.getTransitionData(e,t)}function Rt(t,e){const s=new Set,n=t._nodes.filter(Z);for(const i of n)t:for(const n of[i].concat(et(i,void 0)))if(n.always)for(const i of n.always)if(void 0===i.guard||Y(i.guard,t.context,e,t)){s.add(i);break t}return xt(Array.from(s),new Set(t._nodes),t.historyValue)}function Ct(t){return!!t&&"object"==typeof t&&"machine"in t&&"value"in t}const Dt=function(t){return g(t,this.value)},Jt=function(t){return this.tags.has(t)},Vt=function(t){const e=this.machine.getTransitionData(this,t);return!!e?.length&&e.some((t=>void 0!==t.target||t.actions.length))},Bt=function(){const{_nodes:t,tags:e,machine:s,getMeta:n,toJSON:i,can:o,hasTag:r,matches:a,...c}=this;return{...c,tags:Array.from(e)}},zt=function(){return this._nodes.reduce(((t,e)=>(void 0!==e.meta&&(t[e.id]=e.meta),t)),{})};function Wt(t,e){return{status:t.status,output:t.output,error:t.error,machine:e,context:t.context,_nodes:t._nodes,value:ot(e.root,t._nodes),tags:new Set(x(t._nodes.map((t=>t.tags)))),children:t.children,historyValue:t.historyValue||{},matches:Dt,hasTag:Jt,can:Vt,getMeta:zt,toJSON:Bt}}function Ut(t,e={}){return Wt({...t,...e},t.machine)}function qt(t){let e;for(const s in t){const n=t[s];if(n&&"object"==typeof n)if("sessionId"in n&&"send"in n&&"ref"in n)e??=Array.isArray(t)?t.slice():{...t},e[s]={xstate$$type:N,id:n.id};else{const i=qt(n);i!==n&&(e??=Array.isArray(t)?t.slice():{...t},e[s]=i)}}return e??t}function Qt(t,{machine:e,context:s},n,i){return(o,r)=>{const a=((o,r={})=>{const{systemId:a,input:c}=r;if("string"==typeof o){const u=j(e,o);if(!u)throw new Error(`Actor logic '${o}' not implemented in machine '${e.id}'`);const h=C(u,{id:r.id,parent:t.self,syncSnapshot:r.syncSnapshot,input:"function"==typeof c?c({context:s,event:n,self:t.self}):c,src:o,systemId:a});return i[h.id]=h,h}return C(o,{id:r.id,parent:t.self,syncSnapshot:r.syncSnapshot,input:r.input,src:o,systemId:a})})(o,r);return i[a.id]=a,t.defer((()=>{if(a._processingStatus!==A.Stopped)try{a.start?.()}catch(e){return void t.self.send(u(a.id,e))}})),a}}function Ft(t,e,s,n,{assignment:i}){if(!e.context)throw new Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");const o={},r={context:e.context,event:s.event,spawn:Qt(t,e,s.event,o),self:t?.self,system:t?.system};let a={};if("function"==typeof i)a=i(r,n);else for(const t of Object.keys(i)){const e=i[t];a[t]="function"==typeof e?e(r,n):e}return[Ut(e,{context:Object.assign({},e.context,a),children:Object.keys(o).length?{...e.children,...o}:e.children})]}function Gt(t){function e(t,e){}return e.type="xstate.assign",e.assignment=t,e.resolve=Ft,e}function Xt(t,e,s,n,{branches:i}){const o=i.find((t=>!t.guard||Y(t.guard,e.context,s.event,e)))?.actions;return[e,void 0,w(o)]}function Ht(t,e,s,n,{value:i,label:o}){return[e,{value:"function"==typeof i?i(s,n):i,label:o}]}function Kt({logger:t},{value:e,label:s}){s?t(s,e):t(e)}function Lt(t,e,s,n,{get:i}){return[e,void 0,w(i({context:s.context,event:s.event}))]}function Yt(t,e,s,n,{event:i,id:o,delay:r},{internalQueue:a}){const c=e.machine.implementations.delays;if("string"==typeof i)throw new Error(`Only event objects may be used with raise; use raise({ type: "${i}" }) instead`);const u="function"==typeof i?i(s,n):i;let h;if("string"==typeof r){const t=c&&c[r];h="function"==typeof t?t(s,n):t}else h="function"==typeof r?r(s,n):r;return"number"!=typeof h&&a.push(u),[e,{event:u,id:o,delay:h}]}function Zt(t,e){"number"!=typeof e.delay||t.self.delaySend(e)}function te(t,e){function s(t,e){}return s.type="xstate.raise",s.event=t,s.id=e?.id,s.delay=e?.delay,s.resolve=Yt,s.execute=Zt,s}let ee=function(t){return t.Parent="#_parent",t.Internal="#_internal",t}({});function se(t,e,s,n,{to:i,event:o,id:r,delay:a},c){const u=e.machine.implementations.delays;if("string"==typeof o)throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${o}" }) instead`);const h="function"==typeof o?o(s,n):o;let f;if("string"==typeof a){const t=u&&u[a];f="function"==typeof t?t(s,n):t}else f="function"==typeof a?a(s,n):a;const d="function"==typeof i?i(s,n):i;let p;if("string"==typeof d){if(p=d===ee.Parent?t?.self._parent:d===ee.Internal?t?.self:d.startsWith("#_")?e.children[d.slice(2)]:c.deferredActorIds?.includes(d)?d:e.children[d],!p)throw new Error(`Unable to send event to actor '${d}' from machine '${e.machine.id}'.`)}else p=d||t?.self;return[e,{to:p,event:h,id:r,delay:f}]}function ne(t,e,s){"string"==typeof s.to&&(s.to=e.children[s.to])}function ie(t,e){"number"!=typeof e.delay?t.defer((()=>{const{to:s,event:n}=e;t?.system._relay(t.self,s,n.type===r?u(t.self.id,n.data):n)})):t.self.delaySend(e)}function oe(t,e,s){function n(t,e){}return n.type="xstate.sendTo",n.to=t,n.event=e,n.id=s?.id,n.delay=s?.delay,n.resolve=se,n.retryResolve=ne,n.execute=ie,n}function re(t,e){return oe(ee.Parent,t,e)}function ae(t,e){return{config:t,transition:(e,s,n)=>({...e,context:t(e.context,s,n)}),getInitialState:(t,s)=>({status:"active",output:void 0,error:void 0,context:"function"==typeof e?e({input:s}):e}),getPersistedState:t=>t,restoreState:t=>t}}const ce="$$xstate.resolve",ue="$$xstate.reject";const he=ae((t=>{}),void 0);const fe=new WeakMap;function de(t,e,s){let n=fe.get(t);return n?e in n||(n[e]=s()):(n={[e]:s()},fe.set(t,n)),n[e]}const pe={},le=t=>"string"==typeof t?{type:t}:"function"==typeof t?"resolve"in t?{type:t.type}:{type:t.name}:t;class ye{constructor(t,e){if(this.config=t,this.key=void 0,this.id=void 0,this.type=void 0,this.path=void 0,this.states=void 0,this.history=void 0,this.entry=void 0,this.exit=void 0,this.parent=void 0,this.machine=void 0,this.meta=void 0,this.output=void 0,this.order=-1,this.description=void 0,this.tags=[],this.transitions=void 0,this.always=void 0,this.parent=e._parent,this.key=e._key,this.machine=e._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(s),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?S(this.config.states,((t,e)=>new ye(t,{_parent:this,_key:e,_machine:this.machine}))):pe,"compound"===this.type&&!this.config.initial)throw new Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);this.history=!0===this.config.history?"shallow":this.config.history||!1,this.entry=w(this.config.entry).slice(),this.exit=w(this.config.exit).slice(),this.meta=this.config.meta,this.output="final"!==this.type&&this.parent?void 0:this.config.output,this.tags=w(t.tags).slice()}_initialize(){this.transitions=function(t){const e=new Map;if(t.config.on)for(const s of Object.keys(t.config.on)){if(s===i)throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');const n=t.config.on[s];e.set(s,I(n).map((e=>ut(t,s,e))))}if(t.config.onDone){const s=`xstate.done.state.${t.id}`;e.set(s,I(t.config.onDone).map((e=>ut(t,s,e))))}for(const s of t.invoke){if(s.onDone){const n=`xstate.done.actor.${s.id}`;e.set(n,I(s.onDone).map((e=>ut(t,n,e))))}if(s.onError){const n=`xstate.error.actor.${s.id}`;e.set(n,I(s.onError).map((e=>ut(t,n,e))))}if(s.onSnapshot){const n=`xstate.snapshot.${s.id}`;e.set(n,I(s.onSnapshot).map((e=>ut(t,n,e))))}}for(const s of t.after){let t=e.get(s.eventType);t||(t=[],e.set(s.eventType,t)),t.push(s)}return e}(this),this.config.always&&(this.always=I(this.config.always).map((t=>ut(this,i,t)))),Object.keys(this.states).forEach((t=>{this.states[t]._initialize()}))}get definition(){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.map(le),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map((t=>`#${t.id}`)),source:`#${this.id}`,actions:this.initial.actions.map(le),eventType:null})}:void 0,history:this.history,states:S(this.states,(t=>t.definition)),on:this.on,transitions:[...this.transitions.values()].flat().map((t=>({...t,actions:t.actions.map(le)}))),entry:this.entry.map(le),exit:this.exit.map(le),meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}toJSON(){return this.definition}get invoke(){return de(this,"invoke",(()=>w(this.config.invoke).map(((t,e)=>{const{src:s,systemId:n}=t,i=t.id||O(this.id,e),o="string"==typeof s?s:`xstate#${O(this.id,e)}`;return{...t,src:o,id:i,systemId:n,toJSON(){const{onDone:e,onError:s,...n}=t;return{...n,type:"xstate.invoke",src:o,id:i}}}}))))}get on(){return de(this,"on",(()=>[...this.transitions].flatMap((([t,e])=>e.map((e=>[t,e])))).reduce(((t,[e,s])=>(t[e]=t[e]||[],t[e].push(s),t)),{})))}get after(){return de(this,"delayedTransitions",(()=>ct(this)))}get initial(){return de(this,"initial",(()=>function(t,e){const s="string"==typeof e?t.states[e]:e?t.states[e.target]:void 0;if(!s&&e)throw new Error(`Initial state node "${e}" not found on parent state node #${t.id}`);const n={source:t,actions:e&&"string"!=typeof e?w(e.actions):[],eventType:null,reenter:!1,target:s?[s]:[],toJSON:()=>({...n,source:`#${t.id}`,target:s?[`#${s.id}`]:[]})};return n}(this,this.config.initial)))}next(t,e){const s=e.type,n=[];let i;const o=de(this,`candidates-${s}`,(()=>{return e=s,(t=this).transitions.get(e)||[...t.transitions.keys()].filter((t=>{if("*"===t)return!0;if(!t.endsWith(".*"))return!1;const s=t.split("."),n=e.split(".");for(let t=0;t<s.length;t++){const e=s[t],i=n[t];if("*"===e)return t===s.length-1;if(e!==i)return!1}return!0})).sort(((t,e)=>e.length-t.length)).flatMap((e=>t.transitions.get(e)));var t,e}));for(const r of o){const{guard:o}=r,a=t.context;let c=!1;try{c=!o||Y(o,a,e,t)}catch(t){const e="string"==typeof o?o:"object"==typeof o?o.type:void 0;throw new Error(`Unable to evaluate guard ${e?`'${e}' `:""}in transition for event '${s}' in state node '${this.id}':\n${t.message}`)}if(c){n.push(...r.actions),i=r;break}}return i?[i]:void 0}get events(){return de(this,"events",(()=>{const{states:t}=this,e=new Set(this.ownEvents);if(t)for(const s of Object.keys(t)){const n=t[s];if(n.states)for(const t of n.events)e.add(`${t}`)}return Array.from(e)}))}get ownEvents(){const t=new Set([...this.transitions.keys()].filter((t=>this.transitions.get(t).some((t=>!(!t.target&&!t.actions.length&&!t.reenter))))));return Array.from(t)}}class ge{constructor(t,e){this.config=t,this.version=void 0,this.implementations=void 0,this.types=void 0,this.__xstatenode=!0,this.idMap=new Map,this.root=void 0,this.id=void 0,this.states=void 0,this.events=void 0,this.__TResolvedTypesMeta=void 0,this.id=t.id||"(machine)",this.implementations={actors:e?.actors??{},actions:e?.actions??{},delays:e?.delays??{},guards:e?.guards??{}},this.version=this.config.version,this.types=this.config.types??{},this.transition=this.transition.bind(this),this.getInitialState=this.getInitialState.bind(this),this.restoreState=this.restoreState.bind(this),this.start=this.start.bind(this),this.root=new ye(t,{_key:this.id,_machine:this}),this.root._initialize(),this.states=this.root.states,this.events=this.root.events}provide(t){const{actions:e,guards:s,actors:n,delays:i}=this.implementations;return new ge(this.config,{actions:{...e,...t.actions},guards:{...s,...t.guards},actors:{...n,...t.actors},delays:{...i,...t.delays}})}resolveState(t){const e=(s=this.root,n=t.value,ot(s,[...st(gt(s,n))]));var s,n;const i=st(gt(this.root,e));return Wt({_nodes:[...i],context:t.context||{},children:{},status:rt(i,this.root)?"done":t.status||"active",output:t.output,error:t.error,historyValue:t.historyValue},this)}transition(t,e,s){if(function(t){return t.type.startsWith("xstate.error.actor")}(e)&&!M(t).some((t=>t===e.type)))return Ut(t,{status:"error",error:e.data});const{state:n}=Nt(t,e,s);return n}microstep(t,e,s){return Nt(t,e,s).microstates}getTransitionData(t,e){return vt(this.root,t.value,t,e)||[]}getPreInitialState(t,e,s){const{context:n}=this.config,i=Wt({context:"function"!=typeof n&&n?n:{},_nodes:[this.root],children:{},status:"active"},this);if("function"==typeof n){return Mt(i,e,t,[Gt((({spawn:t,event:e})=>n({spawn:t,input:e.input})))],s)}return i}getInitialState(t,e){const s=h(e),n=[],i=this.getPreInitialState(t,s,n),o=kt([{target:[...pt(this.root)],source:this.root,reenter:!0,actions:[],eventType:null,toJSON:null}],i,t,s,!0,n),{state:r}=Nt(o,s,t,n);return r}start(t){Object.values(t.children).forEach((t=>{"active"===t.getSnapshot().status&&t.start()}))}getStateNodeById(t){const e=t.split(s),n=e.slice(1),i=at(e[0])?e[0].slice(1):e[0],o=this.idMap.get(i);if(!o)throw new Error(`Child state node '#${i}' does not exist on machine '${this.id}'`);return yt(o,n)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedState(t,e){return function(t,e){const{_nodes:s,tags:n,machine:i,children:o,context:r,can:a,hasTag:c,matches:u,getMeta:h,toJSON:f,...d}=t,p={};for(const t in o){const s=o[t];p[t]={state:s.getPersistedState(e),src:s.src,systemId:s._systemId,syncSnapshot:s._syncSnapshot}}return{...d,context:qt(r),children:p}}(t,e)}restoreState(t,e){const s={},n=t.children;Object.keys(n).forEach((t=>{const i=n[t],o=i.state,r=i.src,a="string"==typeof r?j(this,r):r;if(!a)return;const c=C(a,{id:t,parent:e?.self,syncSnapshot:i.syncSnapshot,state:o,src:r,systemId:i.systemId});s[t]=c}));const i=Wt({...t,children:s,_nodes:Array.from(st(gt(this.root,t.value)))},this);let o=new Set;return function t(e,s){if(!o.has(e)){o.add(e);for(let n in e){const i=e[n];if(i&&"object"==typeof i){if("xstate$$type"in i&&i.xstate$$type===N){e[n]=s[i.id];continue}t(i,s)}}}}(i.context,s),i}}const ve={timeout:1/0};function me(t,e){return new ge(t,e)}t.Actor=R,t.SimulatedClock=class{constructor(){this.timeouts=new Map,this._now=0,this._id=0}now(){return this._now}getId(){return this._id++}setTimeout(t,e){const s=this.getId();return this.timeouts.set(s,{start:this.now(),timeout:e,fn:t}),s}clearTimeout(t){this.timeouts.delete(t)}set(t){if(this._now>t)throw new Error("Unable to travel back in time");this._now=t,this.flushTimeouts()}flushTimeouts(){[...this.timeouts].sort((([t,e],[s,n])=>{const i=e.start+e.timeout;return n.start+n.timeout>i?-1:1})).forEach((([t,e])=>{this.now()-e.start>=e.timeout&&(this.timeouts.delete(t),e.fn.call(null))}))}increment(t){this._now+=t,this.flushTimeouts()}},t.SpecialTargets=ee,t.StateMachine=ge,t.StateNode=ye,t.__unsafe_getAllOwnEventDescriptors=M,t.and=function(t){function e(t,e){return!1}return e.check=K,e.guards=t,e},t.assign=Gt,t.cancel=B,t.choose=function(t){function e(t,e){}return e.type="xstate.choose",e.branches=t,e.resolve=Xt,e},t.createActor=C,t.createEmptyActor=function(){return C(he)},t.createMachine=me,t.escalate=function(t,e){return re((e=>({type:r,data:"function"==typeof t?t(e):t})),e)},t.forwardTo=function(t,e){return oe(t,(({event:t})=>t),e)},t.fromCallback=function(t){return{config:t,start:(t,{self:e,system:s})=>{s._relay(e,e,{type:"xstate.create"})},transition:(e,s,{self:n,system:i})=>{if("xstate.create"===s.type){const s=t=>{"stopped"!==e.status&&n._parent&&i._relay(n,n._parent,t)},o=t=>{e._receivers.add(t)};return e._dispose=t({input:e.input,system:i,self:n,sendBack:s,receive:o}),e}return s.type===a?("function"==typeof(e={...e,status:"stopped",error:void 0})._dispose&&e._dispose(),e):(e._receivers.forEach((t=>t(s))),e)},getInitialState:(t,e)=>({status:"active",output:void 0,error:void 0,input:e,_receivers:new Set,_dispose:void 0}),getPersistedState:({_dispose:t,_receivers:e,...s})=>s,restoreState:t=>({_receivers:new Set,_dispose:void 0,...t})}},t.fromEventObservable=function(t){const e="$$xstate.error",s="$$xstate.complete";return{config:t,transition:(t,n)=>{if("active"!==t.status)return t;switch(n.type){case e:return{...t,status:"error",error:n.data,input:void 0,_subscription:void 0};case s:return{...t,status:"done",input:void 0,_subscription:void 0};case a:return t._subscription.unsubscribe(),{...t,status:"stopped",input:void 0,_subscription:void 0};default:return t}},getInitialState:(t,e)=>({status:"active",output:void 0,error:void 0,context:void 0,input:e,_subscription:void 0}),start:(n,{self:i,system:o})=>{"done"!==n.status&&(n._subscription=t({input:n.input,system:o,self:i}).subscribe({next:t=>{i._parent&&o._relay(i,i._parent,t)},error:t=>{o._relay(i,i,{type:e,data:t})},complete:()=>{o._relay(i,i,{type:s})}}))},getPersistedState:({_subscription:t,...e})=>e,restoreState:t=>({...t,_subscription:void 0})}},t.fromObservable=function(t){const e="$$xstate.next",s="$$xstate.error",n="$$xstate.complete";return{config:t,transition:(t,i,{self:o,id:r,defer:c,system:u})=>{if("active"!==t.status)return t;switch(i.type){case e:return{...t,context:i.data};case s:return{...t,status:"error",error:i.data,input:void 0,_subscription:void 0};case n:return{...t,status:"done",input:void 0,_subscription:void 0};case a:return t._subscription.unsubscribe(),{...t,status:"stopped",input:void 0,_subscription:void 0};default:return t}},getInitialState:(t,e)=>({status:"active",output:void 0,error:void 0,context:void 0,input:e,_subscription:void 0}),start:(i,{self:o,system:r})=>{"done"!==i.status&&(i._subscription=t({input:i.input,system:r,self:o}).subscribe({next:t=>{r._relay(o,o,{type:e,data:t})},error:t=>{r._relay(o,o,{type:s,data:t})},complete:()=>{r._relay(o,o,{type:n})}}))},getPersistedState:({_subscription:t,...e})=>e,restoreState:t=>({...t,_subscription:void 0})}},t.fromPromise=function(t){return{config:t,transition:(t,e)=>{if("active"!==t.status)return t;switch(e.type){case ce:{const s=e.data;return{...t,status:"done",output:s,input:void 0}}case ue:return{...t,status:"error",error:e.data,input:void 0};case a:return{...t,status:"stopped",input:void 0};default:return t}},start:(e,{self:s,system:n})=>{if("active"!==e.status)return;Promise.resolve(t({input:e.input,system:n,self:s})).then((t=>{"active"===s.getSnapshot().status&&n._relay(s,s,{type:ce,data:t})}),(t=>{"active"===s.getSnapshot().status&&n._relay(s,s,{type:ue,data:t})}))},getInitialState:(t,e)=>({status:"active",output:void 0,error:void 0,input:e}),getPersistedState:t=>t,restoreState:t=>t}},t.fromTransition=ae,t.getStateNodes=gt,t.interpret=D,t.isMachineSnapshot=Ct,t.log=function(t=(({context:t,event:e})=>({context:t,event:e})),e){function s(t,e){}return s.type="xstate.log",s.value=t,s.label=e,s.resolve=Ht,s.execute=Kt,s},t.matchesState=g,t.not=function(t){function e(t,e){return!1}return e.check=H,e.guards=[t],e},t.or=function(t){function e(t,e){return!1}return e.check=L,e.guards=t,e},t.pathToStateValue=_,t.pure=function(t){function e(t,e){}return e.type="xstate.pure",e.get=t,e.resolve=Lt,e},t.raise=te,t.sendParent=re,t.sendTo=oe,t.setup=function({actors:t,actions:e,guards:s,delays:n}){return{createMachine:i=>me(i,{actors:t,actions:e,guards:s,delays:n})}},t.spawnChild=U,t.stateIn=function(t){function e(t,e){return!1}return e.check=X,e.stateValue=t,e},t.stop=G,t.stopChild=F,t.toObserver=T,t.waitFor=function(t,e,s){const n={...ve,...s};return new Promise(((s,i)=>{let o=!1;const r=n.timeout===1/0?void 0:setTimeout((()=>{u.unsubscribe(),i(new Error(`Timeout of ${n.timeout} ms exceeded`))}),n.timeout),a=()=>{clearTimeout(r),o=!0,u?.unsubscribe()};function c(t){e(t)&&(a(),s(t))}let u;c(t.getSnapshot()),o||(u=t.subscribe({next:c,error:t=>{a(),i(t)},complete:()=>{a(),i(new Error("Actor terminated without satisfying predicate"))}}),o&&u.unsubscribe())}))},Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
2
2
|
//# sourceMappingURL=xstate.umd.min.js.map
|