@nhost/react
Version:
Nhost React library
17 lines (15 loc) • 220 kB
JavaScript
(function(I,P){typeof exports=="object"&&typeof module!="undefined"?P(exports,require("react"),require("react/jsx-runtime")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime"],P):(I=typeof globalThis!="undefined"?globalThis:I||self,P(I["@nhost/react"]={},I.React,I._jsx))})(this,function(I,P,zi){"use strict";function Ji(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const Wi=Ji(P);class Ze extends Error{}Ze.prototype.name="InvalidTokenError";function Qi(t){return decodeURIComponent(atob(t).replace(/(.)/g,(e,r)=>{let n=r.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n}))}function Xi(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return Qi(e)}catch{return atob(e)}}function Xt(t,e){if(typeof t!="string")throw new Ze("Invalid token specified: must be a string");e||(e={});const r=e.header===!0?0:1,n=t.split(".")[r];if(typeof n!="string")throw new Ze(`Invalid token specified: missing part #${r+1}`);let i;try{i=Xi(n)}catch(s){throw new Ze(`Invalid token specified: invalid base64 for part #${r+1} (${s.message})`)}try{return JSON.parse(i)}catch(s){throw new Ze(`Invalid token specified: invalid json for part #${r+1} (${s.message})`)}}/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var S=function(){return S=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},S.apply(this,arguments)};function Zt(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}function F(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function V(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(l){o={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s}function z(t,e,r){if(arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))}var Y;(function(t){t.Start="xstate.start",t.Stop="xstate.stop",t.Raise="xstate.raise",t.Send="xstate.send",t.Cancel="xstate.cancel",t.NullEvent="",t.Assign="xstate.assign",t.After="xstate.after",t.DoneState="done.state",t.DoneInvoke="done.invoke",t.Log="xstate.log",t.Init="xstate.init",t.Invoke="xstate.invoke",t.ErrorExecution="error.execution",t.ErrorCommunication="error.communication",t.ErrorPlatform="error.platform",t.ErrorCustom="xstate.error",t.Update="xstate.update",t.Pure="xstate.pure",t.Choose="xstate.choose"})(Y||(Y={}));var Ae;(function(t){t.Parent="#_parent",t.Internal="#_internal"})(Ae||(Ae={}));var mt=Y.Start,yt=Y.Stop,Ue=Y.Raise,et=Y.Send,er=Y.Cancel,Wr=Y.NullEvent,gt=Y.Assign,Zi=Y.After,es=Y.DoneState,Et=Y.Log,Qr=Y.Init,Tt=Y.Invoke,ts=Y.ErrorExecution,tr=Y.ErrorPlatform,rr=Y.ErrorCustom,St=Y.Update,Xr=Y.Choose,Zr=Y.Pure;const rs=Object.freeze(Object.defineProperty({__proto__:null,after:Zi,assign:gt,cancel:er,choose:Xr,doneState:es,error:rr,errorExecution:ts,errorPlatform:tr,init:Qr,invoke:Tt,log:Et,nullEvent:Wr,pure:Zr,raise:Ue,send:et,start:mt,stop:yt,update:St},Symbol.toStringTag,{value:"Module"}));var en=".",tn={},nr="xstate.guard",ns="",Q=process.env.NODE_ENV==="production",wt;function ir(t,e,r){r===void 0&&(r=en);var n=tt(t,r),i=tt(e,r);return G(i)?G(n)?i===n:!1:G(n)?n in i:Object.keys(n).every(function(s){return s in i?ir(n[s],i[s]):!1})}function rn(t){try{return G(t)||typeof t=="number"?"".concat(t):t.type}catch{throw new Error("Events must be strings or objects with a string event.type property.")}}function sr(t,e){try{return Me(t)?t:t.toString().split(e)}catch{throw new Error("'".concat(t,"' is not a valid state path."))}}function is(t){return typeof t=="object"&&"value"in t&&"context"in t&&"event"in t&&"_event"in t}function tt(t,e){if(is(t))return t.value;if(Me(t))return xt(t);if(typeof t!="string")return t;var r=sr(t,e);return xt(r)}function xt(t){if(t.length===1)return t[0];for(var e={},r=e,n=0;n<t.length-1;n++)n===t.length-2?r[t[n]]=t[n+1]:(r[t[n]]={},r=r[t[n]]);return e}function rt(t,e){for(var r={},n=Object.keys(t),i=0;i<n.length;i++){var s=n[i];r[s]=e(t[s],s,t,i)}return r}function nn(t,e,r){var n,i,s={};try{for(var o=F(Object.keys(t)),l=o.next();!l.done;l=o.next()){var c=l.value,a=t[c];r(a)&&(s[c]=e(a,c,t))}}catch(u){n={error:u}}finally{try{l&&!l.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return s}var ss=function(t){return function(e){var r,n,i=e;try{for(var s=F(t),o=s.next();!o.done;o=s.next()){var l=o.value;i=i[l]}}catch(c){r={error:c}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return i}};function os(t,e){return function(r){var n,i,s=r;try{for(var o=F(t),l=o.next();!l.done;l=o.next()){var c=l.value;s=s[e][c]}}catch(a){n={error:a}}finally{try{l&&!l.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return s}}function Ot(t){if(!t)return[[]];if(G(t))return[[t]];var e=X(Object.keys(t).map(function(r){var n=t[r];return typeof n!="string"&&(!n||!Object.keys(n).length)?[[r]]:Ot(t[r]).map(function(i){return[r].concat(i)})}));return e}function X(t){var e;return(e=[]).concat.apply(e,z([],V(t),!1))}function sn(t){return Me(t)?t:[t]}function fe(t){return t===void 0?[]:sn(t)}function kt(t,e,r){var n,i;if(B(t))return t(e,r.data);var s={};try{for(var o=F(Object.keys(t)),l=o.next();!l.done;l=o.next()){var c=l.value,a=t[c];B(a)?s[c]=a(e,r.data):s[c]=a}}catch(u){n={error:u}}finally{try{l&&!l.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return s}function as(t){return/^(done|error)\./.test(t)}function on(t){return!!(t instanceof Promise||t!==null&&(B(t)||typeof t=="object")&&B(t.then))}function cs(t){return t!==null&&typeof t=="object"&&"transition"in t&&typeof t.transition=="function"}function us(t,e){var r,n,i=V([[],[]],2),s=i[0],o=i[1];try{for(var l=F(t),c=l.next();!c.done;c=l.next()){var a=c.value;e(a)?s.push(a):o.push(a)}}catch(u){r={error:u}}finally{try{c&&!c.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}return[s,o]}function an(t,e){return rt(t.states,function(r,n){if(r){var i=(G(e)?void 0:e[n])||(r?r.current:void 0);if(i)return{current:i,states:an(r,i)}}})}function ls(t,e){return{current:e,states:an(t,e)}}function cn(t,e,r,n){Q||ie(!!t,"Attempting to update undefined context");var i=t&&r.reduce(function(s,o){var l,c,a=o.assignment,u={state:n,action:o,_event:e},f={};if(B(a))f=a(s,e.data,u);else try{for(var d=F(Object.keys(a)),h=d.next();!h.done;h=d.next()){var p=h.value,v=a[p];f[p]=B(v)?v(s,e.data,u):v}}catch(E){l={error:E}}finally{try{h&&!h.done&&(c=d.return)&&c.call(d)}finally{if(l)throw l.error}}return Object.assign({},s,f)},t);return i}var ie=function(){};Q||(ie=function(t,e){var r=t instanceof Error?t:void 0;if(!(!r&&t)&&console!==void 0){var n=["Warning: ".concat(e)];r&&n.push(r),console.warn.apply(console,n)}});function Me(t){return Array.isArray(t)}function B(t){return typeof t=="function"}function G(t){return typeof t=="string"}function un(t,e){if(t)return G(t)?{type:nr,name:t,predicate:e?e[t]:void 0}:B(t)?{type:nr,name:t.name,predicate:t}:t}function ds(t){try{return"subscribe"in t&&B(t.subscribe)}catch{return!1}}var Ie=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();wt={},wt[Ie]=function(){return this},wt[Symbol.observable]=function(){return this};function xe(t){return!!t&&"__xstatenode"in t}function hs(t){return!!t&&typeof t.send=="function"}var fs=function(){var t=0;return function(){return t++,t.toString(16)}}();function At(t,e){return G(t)||typeof t=="number"?S({type:t},e):t}function ae(t,e){if(!G(t)&&"$$type"in t&&t.$$type==="scxml")return t;var r=At(t);return S({name:r.type,data:r,$$type:"scxml",type:"external"},e)}function je(t,e){var r=sn(e).map(function(n){return typeof n=="undefined"||typeof n=="string"||xe(n)?{target:n,event:t}:S(S({},n),{event:t})});return r}function ps(t){if(!(t===void 0||t===ns))return fe(t)}function vs(t,e,r){if(!Q){var n=t.stack?" Stacktrace was '".concat(t.stack,"'"):"";if(t===e)console.error("Missing onError handler for invocation '".concat(r,"', error was '").concat(t,"'.").concat(n));else{var i=e.stack?" Stacktrace was '".concat(e.stack,"'"):"";console.error("Missing onError handler and/or unhandled exception/promise rejection for invocation '".concat(r,"'. ")+"Original error: '".concat(t,"'. ").concat(n," Current error is '").concat(e,"'.").concat(i))}}}function ln(t,e,r,n,i){var s=t.options.guards,o={state:i,cond:e,_event:n};if(e.type===nr)return((s==null?void 0:s[e.name])||e.predicate)(r,n.data,o);var l=s==null?void 0:s[e.type];if(!l)throw new Error("Guard '".concat(e.type,"' is not implemented on machine '").concat(t.id,"'."));return l(r,n.data,o)}function dn(t){return typeof t=="string"?{type:t}:t}function nt(t,e,r){var n=function(){},i=typeof t=="object",s=i?t:null;return{next:((i?t.next:t)||n).bind(s),error:((i?t.error:e)||n).bind(s),complete:((i?t.complete:r)||n).bind(s)}}function It(t,e){return"".concat(t,":invocation[").concat(e,"]")}function or(t){return(t.type===Ue||t.type===et&&t.to===Ae.Internal)&&typeof t.delay!="number"}var Ne=ae({type:Qr});function bt(t,e){return e&&e[t]||void 0}function Fe(t,e){var r;if(G(t)||typeof t=="number"){var n=bt(t,e);B(n)?r={type:t,exec:n}:n?r=n:r={type:t,exec:void 0}}else if(B(t))r={type:t.name||t.toString(),exec:t};else{var n=bt(t.type,e);if(B(n))r=S(S({},t),{exec:n});else if(n){var i=n.type||t.type;r=S(S(S({},n),t),{type:i})}else r=t}return r}var Oe=function(t,e){if(!t)return[];var r=Me(t)?t:[t];return r.map(function(n){return Fe(n,e)})};function _t(t){var e=Fe(t);return S(S({id:G(t)?t:e.id},e),{type:e.type})}function hn(t,e){return{type:Ue,event:typeof t=="function"?t:At(t),delay:e?e.delay:void 0,id:e==null?void 0:e.id}}function fn(t,e,r,n){var i={_event:r},s=ae(B(t.event)?t.event(e,r.data,i):t.event),o;if(G(t.delay)){var l=n&&n[t.delay];o=B(l)?l(e,r.data,i):l}else o=B(t.delay)?t.delay(e,r.data,i):t.delay;return S(S({},t),{type:Ue,_event:s,delay:o})}function Re(t,e){return{to:e?e.to:void 0,type:et,event:B(t)?t:At(t),delay:e?e.delay:void 0,id:e&&e.id!==void 0?e.id:B(t)?t.name:rn(t)}}function pn(t,e,r,n){var i={_event:r},s=ae(B(t.event)?t.event(e,r.data,i):t.event),o;if(G(t.delay)){var l=n&&n[t.delay];o=B(l)?l(e,r.data,i):l}else o=B(t.delay)?t.delay(e,r.data,i):t.delay;var c=B(t.to)?t.to(e,r.data,i):t.to;return S(S({},t),{to:c,_event:s,event:s.data,delay:o})}function ar(t,e){return Re(t,S(S({},e),{to:Ae.Parent}))}function ms(t,e,r){return Re(e,S(S({},r),{to:t}))}function ys(){return ar(St)}function gs(t,e){return Re(t,S(S({},e),{to:function(r,n,i){var s=i._event;return s.origin}}))}var Es=function(t,e){return{context:t,event:e}};function Ts(t,e){return t===void 0&&(t=Es),{type:Et,label:e,expr:t}}var vn=function(t,e,r){return S(S({},t),{value:G(t.expr)?t.expr:t.expr(e,r.data,{_event:r})})},mn=function(t){return{type:er,sendId:t}};function yn(t){var e=_t(t);return{type:Y.Start,activity:e,exec:void 0}}function gn(t){var e=B(t)?t:_t(t);return{type:Y.Stop,activity:e,exec:void 0}}function En(t,e,r){var n=B(t.activity)?t.activity(e,r.data):t.activity,i=typeof n=="string"?{id:n}:n,s={type:Y.Stop,activity:i};return s}var Tn=function(t){return{type:gt,assignment:t}};function Ss(t){return typeof t=="object"&&"type"in t}function Sn(t,e){var r=e?"#".concat(e):"";return"".concat(Y.After,"(").concat(t,")").concat(r)}function it(t,e){var r="".concat(Y.DoneState,".").concat(t),n={type:r,data:e};return n.toString=function(){return r},n}function st(t,e){var r="".concat(Y.DoneInvoke,".").concat(t),n={type:r,data:e};return n.toString=function(){return r},n}function Ve(t,e){var r="".concat(Y.ErrorPlatform,".").concat(t),n={type:r,data:e};return n.toString=function(){return r},n}function ws(t){return{type:Y.Pure,get:t}}function xs(t,e){if(!Q&&(!t||typeof t=="function")){var r=t;t=function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var s=typeof r=="function"?r.apply(void 0,z([],V(n),!1)):r;if(!s)throw new Error("Attempted to forward event to undefined actor. This risks an infinite loop in the sender.");return s}}return Re(function(n,i){return i},S(S({},e),{to:t}))}function Os(t,e){return ar(function(r,n,i){return{type:rr,data:B(t)?t(r,n,i):t}},S(S({},e),{to:Ae.Parent}))}function ks(t){return{type:Y.Choose,conds:t}}var As=function(t){var e,r,n=[];try{for(var i=F(t),s=i.next();!s.done;s=i.next())for(var o=s.value,l=0;l<o.actions.length;){if(o.actions[l].type===gt){n.push(o.actions[l]),o.actions.splice(l,1);continue}l++}}catch(c){e={error:c}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return n};function ot(t,e,r,n,i,s,o){o===void 0&&(o=!1);var l=o?[]:As(i),c=l.length?cn(r,n,l,e):r,a=o?[r]:void 0,u=[];function f(p,v){var E;switch(v.type){case Ue:{var g=fn(v,c,n,t.options.delays);return s&&typeof g.delay=="number"&&s(g,c,n),g}case et:var x=pn(v,c,n,t.options.delays);if(!Q){var O=v.delay;ie(!G(O)||typeof x.delay=="number","No delay reference for delay expression '".concat(O,"' was found on machine '").concat(t.id,"'"))}return s&&x.to!==Ae.Internal&&(p==="entry"?u.push(x):s(x,c,n)),x;case Et:{var k=vn(v,c,n);return s==null||s(k,c,n),k}case Xr:{var C=v,b=(E=C.conds.find(function(m){var w=un(m.cond,t.options.guards);return!w||ln(t,w,c,n,s?void 0:e)}))===null||E===void 0?void 0:E.actions;if(!b)return[];var _=V(ot(t,e,c,n,[{type:p,actions:Oe(fe(b),t.options.actions)}],s,o),2),M=_[0],j=_[1];return c=j,a==null||a.push(c),M}case Zr:{var b=v.get(c,n.data);if(!b)return[];var Z=V(ot(t,e,c,n,[{type:p,actions:Oe(fe(b),t.options.actions)}],s,o),2),D=Z[0],$=Z[1];return c=$,a==null||a.push(c),D}case yt:{var k=En(v,c,n);return s==null||s(k,r,n),k}case gt:{c=cn(c,n,[v],s?void 0:e),a==null||a.push(c);break}default:var re=Fe(v,t.options.actions),W=re.exec;if(s)s(re,c,n);else if(W&&a){var Ce=a.length-1,Le=S(S({},re),{exec:function(m){for(var w=[],N=1;N<arguments.length;N++)w[N-1]=arguments[N];W.apply(void 0,z([a[Ce]],V(w),!1))}});re=Le}return re}}function d(p){var v,E,g=[];try{for(var x=F(p.actions),O=x.next();!O.done;O=x.next()){var k=O.value,C=f(p.type,k);C&&(g=g.concat(C))}}catch(b){v={error:b}}finally{try{O&&!O.done&&(E=x.return)&&E.call(x)}finally{if(v)throw v.error}}return u.forEach(function(b){s(b,c,n)}),u.length=0,g}var h=X(i.map(d));return[h,c]}const Is=Object.freeze(Object.defineProperty({__proto__:null,actionTypes:rs,after:Sn,assign:Tn,cancel:mn,choose:ks,done:it,doneInvoke:st,error:Ve,escalate:Os,forwardTo:xs,getActionFunction:bt,initEvent:Ne,isActionObject:Ss,log:Ts,pure:ws,raise:hn,resolveActions:ot,resolveLog:vn,resolveRaise:fn,resolveSend:pn,resolveStop:En,respond:gs,send:Re,sendParent:ar,sendTo:ms,sendUpdate:ys,start:yn,stop:gn,toActionObject:Fe,toActionObjects:Oe,toActivityDefinition:_t},Symbol.toStringTag,{value:"Module"}));var Nt=[],Be=function(t,e){Nt.push(t);var r=e(t);return Nt.pop(),r},bs=function(t){return t(Nt[Nt.length-1])};function wn(t){var e;return e={id:t,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},getSnapshot:function(){},toJSON:function(){return{id:t}}},e[Ie]=function(){return this},e}function _s(t,e,r,n){var i,s=dn(t.src),o=(i=e==null?void 0:e.options.services)===null||i===void 0?void 0:i[s.type],l=t.data?kt(t.data,r,n):void 0,c=o?cr(o,t.id,l):wn(t.id);return c.meta=t,c}function cr(t,e,r){var n=wn(e);if(n.deferred=!0,xe(t)){var i=n.state=Be(void 0,function(){return(r?t.withContext(r):t).initialState});n.getSnapshot=function(){return i}}return n}function Ns(t){try{return typeof t.send=="function"}catch{return!1}}function Rs(t){return Ns(t)&&"id"in t}function Ds(t){var e;return S((e={subscribe:function(){return{unsubscribe:function(){}}},id:"anonymous",getSnapshot:function(){}},e[Ie]=function(){return this},e),t)}var Rt=function(t){return t.type==="atomic"||t.type==="final"};function xn(t){return Object.keys(t.states).map(function(e){return t.states[e]})}function at(t){return xn(t).filter(function(e){return e.type!=="history"})}function On(t){var e=[t];return Rt(t)?e:e.concat(X(at(t).map(On)))}function ct(t,e){var r,n,i,s,o,l,c,a,u=new Set(t),f=ur(u),d=new Set(e);try{for(var h=F(d),p=h.next();!p.done;p=h.next())for(var v=p.value,E=v.parent;E&&!d.has(E);)d.add(E),E=E.parent}catch(j){r={error:j}}finally{try{p&&!p.done&&(n=h.return)&&n.call(h)}finally{if(r)throw r.error}}var g=ur(d);try{for(var x=F(d),O=x.next();!O.done;O=x.next()){var v=O.value;if(v.type==="compound"&&(!g.get(v)||!g.get(v).length))f.get(v)?f.get(v).forEach(function(Z){return d.add(Z)}):v.initialStateNodes.forEach(function(Z){return d.add(Z)});else if(v.type==="parallel")try{for(var k=(o=void 0,F(at(v))),C=k.next();!C.done;C=k.next()){var b=C.value;d.has(b)||(d.add(b),f.get(b)?f.get(b).forEach(function(Z){return d.add(Z)}):b.initialStateNodes.forEach(function(Z){return d.add(Z)}))}}catch(Z){o={error:Z}}finally{try{C&&!C.done&&(l=k.return)&&l.call(k)}finally{if(o)throw o.error}}}}catch(j){i={error:j}}finally{try{O&&!O.done&&(s=x.return)&&s.call(x)}finally{if(i)throw i.error}}try{for(var _=F(d),M=_.next();!M.done;M=_.next())for(var v=M.value,E=v.parent;E&&!d.has(E);)d.add(E),E=E.parent}catch(j){c={error:j}}finally{try{M&&!M.done&&(a=_.return)&&a.call(_)}finally{if(c)throw c.error}}return d}function kn(t,e){var r=e.get(t);if(!r)return{};if(t.type==="compound"){var n=r[0];if(n){if(Rt(n))return n.key}else return{}}var i={};return r.forEach(function(s){i[s.key]=kn(s,e)}),i}function ur(t){var e,r,n=new Map;try{for(var i=F(t),s=i.next();!s.done;s=i.next()){var o=s.value;n.has(o)||n.set(o,[]),o.parent&&(n.has(o.parent)||n.set(o.parent,[]),n.get(o.parent).push(o))}}catch(l){e={error:l}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return n}function Ps(t,e){var r=ct([t],e);return kn(t,ur(r))}function ut(t,e){return Array.isArray(t)?t.some(function(r){return r===e}):t instanceof Set?t.has(e):!1}function Cs(t){return z([],V(new Set(X(z([],V(t.map(function(e){return e.ownEvents})),!1)))),!1)}function Dt(t,e){return e.type==="compound"?at(e).some(function(r){return r.type==="final"&&ut(t,r)}):e.type==="parallel"?at(e).every(function(r){return Dt(t,r)}):!1}function Ls(t){return t===void 0&&(t=[]),t.reduce(function(e,r){return r.meta!==void 0&&(e[r.id]=r.meta),e},{})}function An(t){return new Set(X(t.map(function(e){return e.tags})))}function In(t,e){if(t===e)return!0;if(t===void 0||e===void 0)return!1;if(G(t)||G(e))return t===e;var r=Object.keys(t),n=Object.keys(e);return r.length===n.length&&r.every(function(i){return In(t[i],e[i])})}function Us(t){return typeof t!="object"||t===null?!1:"value"in t&&"_event"in t}function Ms(t,e){var r=t.exec,n=S(S({},t),{exec:r!==void 0?function(){return r(e.context,e.event,{action:t,state:e,_event:e._event})}:void 0});return n}var pe=function(){function t(e){var r=this,n;this.actions=[],this.activities=tn,this.meta={},this.events=[],this.value=e.value,this.context=e.context,this._event=e._event,this._sessionid=e._sessionid,this.event=this._event.data,this.historyValue=e.historyValue,this.history=e.history,this.actions=e.actions||[],this.activities=e.activities||tn,this.meta=Ls(e.configuration),this.events=e.events||[],this.matches=this.matches.bind(this),this.toStrings=this.toStrings.bind(this),this.configuration=e.configuration,this.transitions=e.transitions,this.children=e.children,this.done=!!e.done,this.tags=(n=Array.isArray(e.tags)?new Set(e.tags):e.tags)!==null&&n!==void 0?n:new Set,this.machine=e.machine,Object.defineProperty(this,"nextEvents",{get:function(){return Cs(r.configuration)}})}return t.from=function(e,r){if(e instanceof t)return e.context!==r?new t({value:e.value,context:r,_event:e._event,_sessionid:null,historyValue:e.historyValue,history:e.history,actions:[],activities:e.activities,meta:{},events:[],configuration:[],transitions:[],children:{}}):e;var n=Ne;return new t({value:e,context:r,_event:n,_sessionid:null,historyValue:void 0,history:void 0,actions:[],activities:void 0,meta:void 0,events:[],configuration:[],transitions:[],children:{}})},t.create=function(e){return new t(e)},t.inert=function(e,r){if(e instanceof t){if(!e.actions.length)return e;var n=Ne;return new t({value:e.value,context:r,_event:n,_sessionid:null,historyValue:e.historyValue,history:e.history,activities:e.activities,configuration:e.configuration,transitions:[],children:{}})}return t.from(e,r)},t.prototype.toStrings=function(e,r){var n=this;if(e===void 0&&(e=this.value),r===void 0&&(r="."),G(e))return[e];var i=Object.keys(e);return i.concat.apply(i,z([],V(i.map(function(s){return n.toStrings(e[s],r).map(function(o){return s+r+o})})),!1))},t.prototype.toJSON=function(){var e=this;e.configuration,e.transitions;var r=e.tags;e.machine;var n=Zt(e,["configuration","transitions","tags","machine"]);return S(S({},n),{tags:Array.from(r)})},t.prototype.matches=function(e){return ir(e,this.value)},t.prototype.hasTag=function(e){return this.tags.has(e)},t.prototype.can=function(e){var r;Q&&ie(!!this.machine,"state.can(...) used outside of a machine-created State object; this will always return false.");var n=(r=this.machine)===null||r===void 0?void 0:r.getTransitionData(this,e);return!!(n!=null&&n.transitions.length)&&n.transitions.some(function(i){return i.target!==void 0||i.actions.length})},t}(),js={deferEvents:!1},bn=function(){function t(e){this.processingEvent=!1,this.queue=[],this.initialized=!1,this.options=S(S({},js),e)}return t.prototype.initialize=function(e){if(this.initialized=!0,e){if(!this.options.deferEvents){this.schedule(e);return}this.process(e)}this.flushEvents()},t.prototype.schedule=function(e){if(!this.initialized||this.processingEvent){this.queue.push(e);return}if(this.queue.length!==0)throw new Error("Event queue should be empty when it is not processing events");this.process(e),this.flushEvents()},t.prototype.clear=function(){this.queue=[]},t.prototype.flushEvents=function(){for(var e=this.queue.shift();e;)this.process(e),e=this.queue.shift()},t.prototype.process=function(e){this.processingEvent=!0;try{e()}catch(r){throw this.clear(),r}finally{this.processingEvent=!1}},t}(),lr=new Map,Fs=0,lt={bookId:function(){return"x:".concat(Fs++)},register:function(t,e){return lr.set(t,e),t},get:function(t){return lr.get(t)},free:function(t){lr.delete(t)}};function dr(){if(typeof globalThis!="undefined")return globalThis;if(typeof self!="undefined")return self;if(typeof window!="undefined")return window;if(typeof global!="undefined")return global;Q||console.warn("XState could not find a global object in this environment. Please let the maintainers know and raise an issue here: https://github.com/statelyai/xstate/issues")}function Vs(){var t=dr();if(t&&"__xstate__"in t)return t.__xstate__}function Bs(t){if(dr()){var e=Vs();e&&e.register(t)}}function Gs(t,e){e===void 0&&(e={});var r=t.initialState,n=new Set,i=[],s=!1,o=function(){if(!s){for(s=!0;i.length>0;){var a=i.shift();r=t.transition(r,a,c),n.forEach(function(u){return u.next(r)})}s=!1}},l=Ds({id:e.id,send:function(a){i.push(a),o()},getSnapshot:function(){return r},subscribe:function(a,u,f){var d=nt(a,u,f);return n.add(d),d.next(r),{unsubscribe:function(){n.delete(d)}}}}),c={parent:e.parent,self:l,id:e.id||"anonymous",observers:n};return r=t.start?t.start(c):r,l}var hr={sync:!1,autoForward:!1},ee;(function(t){t[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped"})(ee||(ee={}));var Hs=function(){function t(e,r){r===void 0&&(r=t.defaultOptions);var n=this;this.machine=e,this.delayedEventsMap={},this.listeners=new Set,this.contextListeners=new Set,this.stopListeners=new Set,this.doneListeners=new Set,this.eventListeners=new Set,this.sendListeners=new Set,this.initialized=!1,this.status=ee.NotStarted,this.children=new Map,this.forwardTo=new Set,this._outgoingQueue=[],this.init=this.start,this.send=function(u,f){if(Me(u))return n.batch(u),n.state;var d=ae(At(u,f));if(n.status===ee.Stopped)return Q||ie(!1,'Event "'.concat(d.name,'" was sent to stopped service "').concat(n.machine.id,`". This service has already reached its final state, and will not transition.
Event: `).concat(JSON.stringify(d.data))),n.state;if(n.status!==ee.Running&&!n.options.deferEvents)throw new Error('Event "'.concat(d.name,'" was sent to uninitialized service "').concat(n.machine.id,`". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.
Event: `).concat(JSON.stringify(d.data)));return n.scheduler.schedule(function(){n.forward(d);var h=n._nextState(d);n.update(h,d)}),n._state},this.sendTo=function(u,f,d){var h=n.parent&&(f===Ae.Parent||n.parent.id===f),p=h?n.parent:G(f)?f===Ae.Internal?n:n.children.get(f)||lt.get(f):hs(f)?f:void 0;if(!p){if(!h)throw new Error("Unable to send event to child '".concat(f,"' from service '").concat(n.id,"'."));Q||ie(!1,"Service '".concat(n.id,"' has no parent: unable to send event ").concat(u.type));return}if("machine"in p){if(n.status!==ee.Stopped||n.parent!==p||n.state.done){var v=S(S({},u),{name:u.name===rr?"".concat(Ve(n.id)):u.name,origin:n.sessionId});!d&&n.machine.config.predictableActionArguments?n._outgoingQueue.push([p,v]):p.send(v)}}else!d&&n.machine.config.predictableActionArguments?n._outgoingQueue.push([p,u.data]):p.send(u.data)},this._exec=function(u,f,d,h){h===void 0&&(h=n.machine.options.actions);var p=u.exec||bt(u.type,h),v=B(p)?p:p?p.exec:u.exec;if(v)try{return v(f,d.data,n.machine.config.predictableActionArguments?{action:u,_event:d}:{action:u,state:n.state,_event:d})}catch(W){throw n.parent&&n.parent.send({type:"xstate.error",data:W}),W}switch(u.type){case Ue:{var E=u;n.defer(E);break}case et:var g=u;if(typeof g.delay=="number"){n.defer(g);return}else g.to?n.sendTo(g._event,g.to,d===Ne):n.send(g._event);break;case er:n.cancel(u.sendId);break;case mt:{if(n.status!==ee.Running)return;var x=u.activity;if(!n.machine.config.predictableActionArguments&&!n.state.activities[x.id||x.type])break;if(x.type===Y.Invoke){var O=dn(x.src),k=n.machine.options.services?n.machine.options.services[O.type]:void 0,C=x.id,b=x.data;Q||ie(!("forward"in x),"`forward` property is deprecated (found in invocation of '".concat(x.src,"' in in machine '").concat(n.machine.id,"'). ")+"Please use `autoForward` instead.");var _="autoForward"in x?x.autoForward:!!x.forward;if(!k){Q||ie(!1,"No service found for invocation '".concat(x.src,"' in machine '").concat(n.machine.id,"'."));return}var M=b?kt(b,f,d):void 0;if(typeof k=="string")return;var j=B(k)?k(f,d.data,{data:M,src:O,meta:x.meta}):k;if(!j)return;var Z=void 0;xe(j)&&(j=M?j.withContext(M):j,Z={autoForward:_}),n.spawn(j,C,Z)}else n.spawnActivity(x);break}case yt:{n.stopChild(u.activity.id);break}case Et:var D=u,$=D.label,re=D.value;$?n.logger($,re):n.logger(re);break;default:Q||ie(!1,"No implementation found for action type '".concat(u.type,"'"));break}};var i=S(S({},t.defaultOptions),r),s=i.clock,o=i.logger,l=i.parent,c=i.id,a=c!==void 0?c:e.id;this.id=a,this.logger=o,this.clock=s,this.parent=l,this.options=i,this.scheduler=new bn({deferEvents:this.options.deferEvents}),this.sessionId=lt.bookId()}return Object.defineProperty(t.prototype,"initialState",{get:function(){var e=this;return this._initialState?this._initialState:Be(this,function(){return e._initialState=e.machine.initialState,e._initialState})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return Q||ie(this.status!==ee.NotStarted,"Attempted to read state from uninitialized service '".concat(this.id,"'. Make sure the service is started first.")),this._state},enumerable:!1,configurable:!0}),t.prototype.execute=function(e,r){var n,i;try{for(var s=F(e.actions),o=s.next();!o.done;o=s.next()){var l=o.value;this.exec(l,e,r)}}catch(c){n={error:c}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}},t.prototype.update=function(e,r){var n,i,s,o,l,c,a,u,f=this;if(e._sessionid=this.sessionId,this._state=e,(!this.machine.config.predictableActionArguments||r===Ne)&&this.options.execute)this.execute(this.state);else for(var d=void 0;d=this._outgoingQueue.shift();)d[0].send(d[1]);if(this.children.forEach(function(j){f.state.children[j.id]=j}),this.devTools&&this.devTools.send(r.data,e),e.event)try{for(var h=F(this.eventListeners),p=h.next();!p.done;p=h.next()){var v=p.value;v(e.event)}}catch(j){n={error:j}}finally{try{p&&!p.done&&(i=h.return)&&i.call(h)}finally{if(n)throw n.error}}try{for(var E=F(this.listeners),g=E.next();!g.done;g=E.next()){var v=g.value;v(e,e.event)}}catch(j){s={error:j}}finally{try{g&&!g.done&&(o=E.return)&&o.call(E)}finally{if(s)throw s.error}}try{for(var x=F(this.contextListeners),O=x.next();!O.done;O=x.next()){var k=O.value;k(this.state.context,this.state.history?this.state.history.context:void 0)}}catch(j){l={error:j}}finally{try{O&&!O.done&&(c=x.return)&&c.call(x)}finally{if(l)throw l.error}}if(this.state.done){var C=e.configuration.find(function(j){return j.type==="final"&&j.parent===f.machine}),b=C&&C.doneData?kt(C.doneData,e.context,r):void 0;this._doneEvent=st(this.id,b);try{for(var _=F(this.doneListeners),M=_.next();!M.done;M=_.next()){var v=M.value;v(this._doneEvent)}}catch(j){a={error:j}}finally{try{M&&!M.done&&(u=_.return)&&u.call(_)}finally{if(a)throw a.error}}this._stop(),this._stopChildren(),lt.free(this.sessionId)}},t.prototype.onTransition=function(e){return this.listeners.add(e),this.status===ee.Running&&e(this.state,this.state.event),this},t.prototype.subscribe=function(e,r,n){var i=this,s=nt(e,r,n);this.listeners.add(s.next),this.status!==ee.NotStarted&&s.next(this.state);var o=function(){i.doneListeners.delete(o),i.stopListeners.delete(o),s.complete()};return this.status===ee.Stopped?s.complete():(this.onDone(o),this.onStop(o)),{unsubscribe:function(){i.listeners.delete(s.next),i.doneListeners.delete(o),i.stopListeners.delete(o)}}},t.prototype.onEvent=function(e){return this.eventListeners.add(e),this},t.prototype.onSend=function(e){return this.sendListeners.add(e),this},t.prototype.onChange=function(e){return this.contextListeners.add(e),this},t.prototype.onStop=function(e){return this.stopListeners.add(e),this},t.prototype.onDone=function(e){return this.status===ee.Stopped&&this._doneEvent?e(this._doneEvent):this.doneListeners.add(e),this},t.prototype.off=function(e){return this.listeners.delete(e),this.eventListeners.delete(e),this.sendListeners.delete(e),this.stopListeners.delete(e),this.doneListeners.delete(e),this.contextListeners.delete(e),this},t.prototype.start=function(e){var r=this;if(this.status===ee.Running)return this;this.machine._init(),lt.register(this.sessionId,this),this.initialized=!0,this.status=ee.Running;var n=e===void 0?this.initialState:Be(this,function(){return Us(e)?r.machine.resolveState(e):r.machine.resolveState(pe.from(e,r.machine.context))});return this.options.devTools&&this.attachDev(),this.scheduler.initialize(function(){r.update(n,Ne)}),this},t.prototype._stopChildren=function(){this.children.forEach(function(e){B(e.stop)&&e.stop()}),this.children.clear()},t.prototype._stop=function(){var e,r,n,i,s,o,l,c,a,u;try{for(var f=F(this.listeners),d=f.next();!d.done;d=f.next()){var h=d.value;this.listeners.delete(h)}}catch(_){e={error:_}}finally{try{d&&!d.done&&(r=f.return)&&r.call(f)}finally{if(e)throw e.error}}try{for(var p=F(this.stopListeners),v=p.next();!v.done;v=p.next()){var h=v.value;h(),this.stopListeners.delete(h)}}catch(_){n={error:_}}finally{try{v&&!v.done&&(i=p.return)&&i.call(p)}finally{if(n)throw n.error}}try{for(var E=F(this.contextListeners),g=E.next();!g.done;g=E.next()){var h=g.value;this.contextListeners.delete(h)}}catch(_){s={error:_}}finally{try{g&&!g.done&&(o=E.return)&&o.call(E)}finally{if(s)throw s.error}}try{for(var x=F(this.doneListeners),O=x.next();!O.done;O=x.next()){var h=O.value;this.doneListeners.delete(h)}}catch(_){l={error:_}}finally{try{O&&!O.done&&(c=x.return)&&c.call(x)}finally{if(l)throw l.error}}if(!this.initialized)return this;this.initialized=!1,this.status=ee.Stopped,this._initialState=void 0;try{for(var k=F(Object.keys(this.delayedEventsMap)),C=k.next();!C.done;C=k.next()){var b=C.value;this.clock.clearTimeout(this.delayedEventsMap[b])}}catch(_){a={error:_}}finally{try{C&&!C.done&&(u=k.return)&&u.call(k)}finally{if(a)throw a.error}}this.scheduler.clear(),this.scheduler=new bn({deferEvents:this.options.deferEvents})},t.prototype.stop=function(){var e=this,r=this.scheduler;return this._stop(),r.schedule(function(){var n;if(!(!((n=e._state)===null||n===void 0)&&n.done)){var i=ae({type:"xstate.stop"}),s=Be(e,function(){var o=X(z([],V(e.state.configuration),!1).sort(function(f,d){return d.order-f.order}).map(function(f){return Oe(f.onExit,e.machine.options.actions)})),l=V(ot(e.machine,e.state,e.state.context,i,[{type:"exit",actions:o}],e.machine.config.predictableActionArguments?e._exec:void 0,e.machine.config.predictableActionArguments||e.machine.config.preserveActionOrder),2),c=l[0],a=l[1],u=new pe({value:e.state.value,context:a,_event:i,_sessionid:e.sessionId,historyValue:void 0,history:e.state,actions:c.filter(function(f){return!or(f)}),activities:{},events:[],configuration:[],transitions:[],children:{},done:e.state.done,tags:e.state.tags,machine:e.machine});return u.changed=!0,u});e.update(s,i),e._stopChildren(),lt.free(e.sessionId)}}),this},t.prototype.batch=function(e){var r=this;if(this.status===ee.NotStarted&&this.options.deferEvents)Q||ie(!1,"".concat(e.length,' event(s) were sent to uninitialized service "').concat(this.machine.id,`" and are deferred. Make sure .start() is called for this service.
Event: `).concat(JSON.stringify(event)));else if(this.status!==ee.Running)throw new Error("".concat(e.length,' event(s) were sent to uninitialized service "').concat(this.machine.id,'". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.'));if(e.length){var n=!!this.machine.config.predictableActionArguments&&this._exec;this.scheduler.schedule(function(){var i,s,o=r.state,l=!1,c=[],a=function(h){var p=ae(h);r.forward(p),o=Be(r,function(){return r.machine.transition(o,p,void 0,n||void 0)}),c.push.apply(c,z([],V(r.machine.config.predictableActionArguments?o.actions:o.actions.map(function(v){return Ms(v,o)})),!1)),l=l||!!o.changed};try{for(var u=F(e),f=u.next();!f.done;f=u.next()){var d=f.value;a(d)}}catch(h){i={error:h}}finally{try{f&&!f.done&&(s=u.return)&&s.call(u)}finally{if(i)throw i.error}}o.changed=l,o.actions=c,r.update(o,ae(e[e.length-1]))})}},t.prototype.sender=function(e){return this.send.bind(this,e)},t.prototype._nextState=function(e,r){var n=this;r===void 0&&(r=!!this.machine.config.predictableActionArguments&&this._exec);var i=ae(e);if(i.name.indexOf(tr)===0&&!this.state.nextEvents.some(function(o){return o.indexOf(tr)===0}))throw i.data.data;var s=Be(this,function(){return n.machine.transition(n.state,i,void 0,r||void 0)});return s},t.prototype.nextState=function(e){return this._nextState(e,!1)},t.prototype.forward=function(e){var r,n;try{for(var i=F(this.forwardTo),s=i.next();!s.done;s=i.next()){var o=s.value,l=this.children.get(o);if(!l)throw new Error("Unable to forward event '".concat(e,"' from interpreter '").concat(this.id,"' to nonexistant child '").concat(o,"'."));l.send(e)}}catch(c){r={error:c}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}},t.prototype.defer=function(e){var r=this,n=this.clock.setTimeout(function(){"to"in e&&e.to?r.sendTo(e._event,e.to,!0):r.send(e._event)},e.delay);e.id&&(this.delayedEventsMap[e.id]=n)},t.prototype.cancel=function(e){this.clock.clearTimeout(this.delayedEventsMap[e]),delete this.delayedEventsMap[e]},t.prototype.exec=function(e,r,n){n===void 0&&(n=this.machine.options.actions),this._exec(e,r.context,r._event,n)},t.prototype.removeChild=function(e){var r;this.children.delete(e),this.forwardTo.delete(e),(r=this.state)===null||r===void 0||delete r.children[e]},t.prototype.stopChild=function(e){var r=this.children.get(e);r&&(this.removeChild(e),B(r.stop)&&r.stop())},t.prototype.spawn=function(e,r,n){if(this.status!==ee.Running)return cr(e,r);if(on(e))return this.spawnPromise(Promise.resolve(e),r);if(B(e))return this.spawnCallback(e,r);if(Rs(e))return this.spawnActor(e,r);if(ds(e))return this.spawnObservable(e,r);if(xe(e))return this.spawnMachine(e,S(S({},n),{id:r}));if(cs(e))return this.spawnBehavior(e,r);throw new Error('Unable to spawn entity "'.concat(r,'" of type "').concat(typeof e,'".'))},t.prototype.spawnMachine=function(e,r){var n=this;r===void 0&&(r={});var i=new t(e,S(S({},this.options),{parent:this,id:r.id||e.id})),s=S(S({},hr),r);s.sync&&i.onTransition(function(l){n.send(St,{state:l,id:i.id})});var o=i;return this.children.set(i.id,o),s.autoForward&&this.forwardTo.add(i.id),i.onDone(function(l){n.removeChild(i.id),n.send(ae(l,{origin:i.id}))}).start(),o},t.prototype.spawnBehavior=function(e,r){var n=Gs(e,{id:r,parent:this});return this.children.set(r,n),n},t.prototype.spawnPromise=function(e,r){var n,i=this,s=!1,o;e.then(function(c){s||(o=c,i.removeChild(r),i.send(ae(st(r,c),{origin:r})))},function(c){if(!s){i.removeChild(r);var a=Ve(r,c);try{i.send(ae(a,{origin:r}))}catch(u){vs(c,u,r),i.devTools&&i.devTools.send(a,i.state),i.machine.strict&&i.stop()}}});var l=(n={id:r,send:function(){},subscribe:function(c,a,u){var f=nt(c,a,u),d=!1;return e.then(function(h){d||(f.next(h),!d&&f.complete())},function(h){d||f.error(h)}),{unsubscribe:function(){return d=!0}}},stop:function(){s=!0},toJSON:function(){return{id:r}},getSnapshot:function(){return o}},n[Ie]=function(){return this},n);return this.children.set(r,l),l},t.prototype.spawnCallback=function(e,r){var n,i=this,s=!1,o=new Set,l=new Set,c,a=function(d){c=d,l.forEach(function(h){return h(d)}),!s&&i.send(ae(d,{origin:r}))},u;try{u=e(a,function(d){o.add(d)})}catch(d){this.send(Ve(r,d))}if(on(u))return this.spawnPromise(u,r);var f=(n={id:r,send:function(d){return o.forEach(function(h){return h(d)})},subscribe:function(d){var h=nt(d);return l.add(h.next),{unsubscribe:function(){l.delete(h.next)}}},stop:function(){s=!0,B(u)&&u()},toJSON:function(){return{id:r}},getSnapshot:function(){return c}},n[Ie]=function(){return this},n);return this.children.set(r,f),f},t.prototype.spawnObservable=function(e,r){var n,i=this,s,o=e.subscribe(function(c){s=c,i.send(ae(c,{origin:r}))},function(c){i.removeChild(r),i.send(ae(Ve(r,c),{origin:r}))},function(){i.removeChild(r),i.send(ae(st(r),{origin:r}))}),l=(n={id:r,send:function(){},subscribe:function(c,a,u){return e.subscribe(c,a,u)},stop:function(){return o.unsubscribe()},getSnapshot:function(){return s},toJSON:function(){return{id:r}}},n[Ie]=function(){return this},n);return this.children.set(r,l),l},t.prototype.spawnActor=function(e,r){return this.children.set(r,e),e},t.prototype.spawnActivity=function(e){var r=this.machine.options&&this.machine.options.activities?this.machine.options.activities[e.type]:void 0;if(!r){Q||ie(!1,"No implementation found for activity '".concat(e.type,"'"));return}var n=r(this.state.context,e);this.spawnEffect(e.id,n)},t.prototype.spawnEffect=function(e,r){var n;this.children.set(e,(n={id:e,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},stop:r||void 0,getSnapshot:function(){},toJSON:function(){return{id:e}}},n[Ie]=function(){return this},n))},t.prototype.attachDev=function(){var e=dr();if(this.options.devTools&&e){if(e.__REDUX_DEVTOOLS_EXTENSION__){var r=typeof this.options.devTools=="object"?this.options.devTools:void 0;this.devTools=e.__REDUX_DEVTOOLS_EXTENSION__.connect(S(S({name:this.id,autoPause:!0,stateSanitizer:function(n){return{value:n.value,context:n.context,actions:n.actions}}},r),{features:S({jump:!1,skip:!1},r?r.features:void 0)}),this.machine),this.devTools.init(this.state)}Bs(this)}},t.prototype.toJSON=function(){return{id:this.id}},t.prototype[Ie]=function(){return this},t.prototype.getSnapshot=function(){return this.status===ee.NotStarted?this.initialState:this._state},t.defaultOptions={execute:!0,deferEvents:!0,clock:{setTimeout:function(e,r){return setTimeout(e,r)},clearTimeout:function(e){return clearTimeout(e)}},logger:console.log.bind(console),devTools:!1},t.interpret=De,t}(),Ks=function(t){return G(t)?S(S({},hr),{name:t}):S(S(S({},hr),{name:fs()}),t)};function Ys(t,e){var r=Ks(e);return bs(function(n){if(!Q){var i=xe(t)||B(t);ie(!!n||i,'Attempted to spawn an Actor (ID: "'.concat(xe(t)?t.id:"undefined",'") outside of a service. This will have no effect.'))}return n?n.spawn(t,r.name,r):cr(t,r.name)})}function De(t,e){var r=new Hs(t,e);return r}function $s(t){if(typeof t=="string"){var e={type:t};return e.toString=function(){return t},e}return t}function Pt(t){return S(S({type:Tt},t),{toJSON:function(){t.onDone,t.onError;var e=Zt(t,["onDone","onError"]);return S(S({},e),{type:Tt,src:$s(t.src)})}})}var Ge="",fr="#",dt="*",He={},Ke=function(t){return t[0]===fr},qs=function(){return{actions:{},guards:{},services:{},activities:{},delays:{}}},zs=function(t,e,r){var n=r.slice(0,-1).some(function(s){return!("cond"in s)&&!("in"in s)&&(G(s.target)||xe(s.target))}),i=e===Ge?"the transient event":"event '".concat(e,"'");ie(!n,"One or more transitions for ".concat(i," on state '").concat(t.id,"' are unreachable. ")+"Make sure that the default transition is the last one defined.")},Js=function(){function t(e,r,n,i){n===void 0&&(n="context"in e?e.context:void 0);var s=this,o;this.config=e,this._context=n,this.order=-1,this.__xstatenode=!0,this.__cache={events:void 0,relativeValue:new Map,initialStateValue:void 0,initialState:void 0,on:void 0,transitions:void 0,candidates:{},delayedTransitions:void 0},this.idMap={},this.tags=[],this.options=Object.assign(qs(),r),this.parent=i==null?void 0:i.parent,this.key=this.config.key||(i==null?void 0:i.key)||this.config.id||"(machine)",this.machine=this.parent?this.parent.machine:this,this.path=this.parent?this.parent.path.concat(this.key):[],this.delimiter=this.config.delimiter||(this.parent?this.parent.delimiter:en),this.id=this.config.id||z([this.machine.key],V(this.path),!1).join(this.delimiter),this.version=this.parent?this.parent.version:this.config.version,this.type=this.config.type||(this.config.parallel?"parallel":this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.schema=this.parent?this.machine.schema:(o=this.config.schema)!==null&&o!==void 0?o:{},this.description=this.config.description,Q||ie(!("parallel"in this.config),'The "parallel" property is deprecated and will be removed in version 4.1. '.concat(this.config.parallel?"Replace with `type: 'parallel'`":"Use `type: '".concat(this.type,"'`")," in the config for state node '").concat(this.id,"' instead.")),this.initial=this.config.initial,this.states=this.config.states?rt(this.config.states,function(a,u){var f,d=new t(a,{},void 0,{parent:s,key:u});return Object.assign(s.idMap,S((f={},f[d.id]=d,f),d.idMap)),d}):He;var l=0;function c(a){var u,f;a.order=l++;try{for(var d=F(xn(a)),h=d.next();!h.done;h=d.next()){var p=h.value;c(p)}}catch(v){u={error:v}}finally{try{h&&!h.done&&(f=d.return)&&f.call(d)}finally{if(u)throw u.error}}}c(this),this.history=this.config.history===!0?"shallow":this.config.history||!1,this._transient=!!this.config.always||(this.config.on?Array.isArray(this.config.on)?this.config.on.some(function(a){var u=a.event;return u===Ge}):Ge in this.config.on:!1),this.strict=!!this.config.strict,this.onEntry=fe(this.config.entry||this.config.onEntry).map(function(a){return Fe(a)}),this.onExit=fe(this.config.exit||this.config.onExit).map(function(a){return Fe(a)}),this.meta=this.config.meta,this.doneData=this.type==="final"?this.config.data:void 0,this.invoke=fe(this.config.invoke).map(function(a,u){var f,d;if(xe(a)){var h=It(s.id,u);return s.machine.options.services=S((f={},f[h]=a,f),s.machine.options.services),Pt({src:h,id:h})}else if(G(a.src)){var h=a.id||It(s.id,u);return Pt(S(S({},a),{id:h,src:a.src}))}else if(xe(a.src)||B(a.src)){var h=a.id||It(s.id,u);return s.machine.options.services=S((d={},d[h]=a.src,d),s.machine.options.services),Pt(S(S({id:h},a),{src:h}))}else{var p=a.src;return Pt(S(S({id:It(s.id,u)},a),{src:p}))}}),this.activities=fe(this.config.activities).concat(this.invoke).map(function(a){return _t(a)}),this.transition=this.transition.bind(this),this.tags=fe(this.config.tags)}return t.prototype._init=function(){this.__cache.transitions||On(this).forEach(function(e){return e.on})},t.prototype.withConfig=function(e,r){var n=this.options,i=n.actions,s=n.activities,o=n.guards,l=n.services,c=n.delays;return new t(this.config,{actions:S(S({},i),e.actions),activities:S(S({},s),e.activities),guards:S(S({},o),e.guards),services:S(S({},l),e.services),delays:S(S({},c),e.delays)},r!=null?r:this.context)},t.prototype.withContext=function(e){return new t(this.config,this.options,e)},Object.defineProperty(t.prototype,"context",{get:function(){return B(this._context)?this._context():this._context},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"definition",{get:function(){return{id:this.id,key:this.key,version:this.version,context:this.context,type:this.type,initial:this.initial,history:this.history,states:rt(this.states,function(e){return e.definition}),on:this.on,transitions:this.transitions,entry:this.onEntry,exit:this.onExit,activities:this.activities||[],meta:this.meta,order:this.order||-1,data:this.doneData,invoke:this.invoke,description:this.description,tags:this.tags}},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){return this.definition},Object.defineProperty(t.prototype,"on",{get:function(){if(this.__cache.on)return this.__cache.on;var e=this.transitions;return this.__cache.on=e.reduce(function(r,n){return r[n.eventType]=r[n.eventType]||[],r[n.eventType].push(n),r},{})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"after",{get:function(){return this.__cache.delayedTransitions||(this.__cache.delayedTransitions=this.getDelayedTransitions(),this.__cache.delayedTransitions)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transitions",{get:function(){return this.__cache.transitions||(this.__cache.transitions=this.formatTransitions(),this.__cache.transitions)},enumerable:!1,configurable:!0}),t.prototype.getCandidates=function(e){if(this.__cache.candidates[e])return this.__cache.candidates[e];var r=e===Ge,n=this.transitions.filter(function(i){var s=i.eventType===e;return r?s:s||i.eventType===dt});return this.__cache.candidates[e]=n,n},t.prototype.getDelayedTransitions=function(){var e=this,r=this.config.after;if(!r)return[];var n=function(s,o){var l=B(s)?"".concat(e.id,":delay[").concat(o,"]"):s,c=Sn(l,e.id);return e.onEntry.push(Re(c,{delay:s})),e.onExit.push(mn(c)),c},i=Me(r)?r.map(function(s,o){var l=n(s.delay,o);return S(S({},s),{event:l})}):X(Object.keys(r).map(function(s,o){var l=r[s],c=G(l)?{target:l}:l,a=isNaN(+s)?s:+s,u=n(a,o);return fe(c).map(function(f){return S(S({},f),{event:u,delay:a})})}));return i.map(function(s){var o=s.delay;return S(S({},e.formatTransition(s)),{delay:o})})},t.prototype.getStateNodes=function(e){var r,n=this;if(!e)return[];var i=e instanceof pe?e.value:tt(e,this.delimiter);if(G(i)){var s=this.getStateNode(i).initial;return s!==void 0?this.getStateNodes((r={},r[i]=s,r)):[this,this.states[i]]}var o=Object.keys(i),l=[this];return l.push.apply(l,z([],V(X(o.map(function(c){return n.getStateNode(c).getStateNodes(i[c])}))),!1)),l},t.prototype.handles=function(e){var r=rn(e);return this.events.includes(r)},t.prototype.resolveState=function(e){var r=e instanceof pe?e:pe.create(e),n=Array.from(ct([],this.getStateNodes(r.value)));return new pe(S(S({},r),{value:this.resolve(r.value),configuration:n,done:Dt(n,this),tags:An(n),machine:this.machine}))},t.prototype.transitionLeafNode=function(e,r,n){var i=this.getStateNode(e),s=i.next(r,n);return!s||!s.transitions.length?this.next(r,n):s},t.prototype.transitionCompoundNode=function(e,r,n){var i=Object.keys(e),s=this.getStateNode(i[0]),o=s._transition(e[i[0]],r,n);return!o||!o.transitions.length?this.next(r,n):o},t.prototype.transitionParallelNode=function(e,r,n){var i,s,o={};try{for(var l=F(Object.keys(e)),c=l.next();!c.done;c=l.next()){var a=c.value,u=e[a];if(u){var f=this.getStateNode(a),d=f._transition(u,r,n);d&&(o[a]=d)}}}catch(g){i={error:g}}finally{try{c&&!c.done&&(s=l.return)&&s.call(l)}finally{if(i)throw i.error}}var h=Object.keys(o).map(function(g){return o[g]}),p=X(h.map(function(g){return g.tra