Files
owncast/static/web/_next/static/chunks/5888-3725c82b4e08ddd1.js
2023-11-24 06:25:00 +00:00

35 lines
100 KiB
JavaScript
Vendored

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5888],{99717:function(e,n,i){"use strict";i.d(n,{e:function(){return useMachine}});var o,s,u=i(67294),c=i(52798),f=i(63056),l=i(59043),d=i(54911),v=i(3884),y=i(30375),g=i(14066),m=i(89823),b={deferEvents:!1},S=function(){function Scheduler(e){this.processingEvent=!1,this.queue=[],this.initialized=!1,this.options=(0,f.pi)((0,f.pi)({},b),e)}return Scheduler.prototype.initialize=function(e){if(this.initialized=!0,e){if(!this.options.deferEvents){this.schedule(e);return}this.process(e)}this.flushEvents()},Scheduler.prototype.schedule=function(e){if(!this.initialized||this.processingEvent){this.queue.push(e);return}if(0!==this.queue.length)throw Error("Event queue should be empty when it is not processing events");this.process(e),this.flushEvents()},Scheduler.prototype.clear=function(){this.queue=[]},Scheduler.prototype.flushEvents=function(){for(var e=this.queue.shift();e;)this.process(e),e=this.queue.shift()},Scheduler.prototype.process=function(e){this.processingEvent=!0;try{e()}catch(e){throw this.clear(),e}finally{this.processingEvent=!1}},Scheduler}(),w=i(98933),x=new Map,A=0,E={bookId:function(){return"x:".concat(A++)},register:function(e,n){return x.set(e,n),e},get:function(e){return x.get(e)},free:function(e){x.delete(e)}};function getGlobal(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==i.g?i.g:void(g.M||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 getDevTools(){var e=getGlobal();if(e&&"__xstate__"in e)return e.__xstate__}function registerService(e){if(getGlobal()){var n=getDevTools();n&&n.register(e)}}var B=i(10797);function spawnBehavior(e,n){void 0===n&&(n={});var i=e.initialState,o=new Set,s=[],u=!1,flush=function(){if(!u){for(u=!0;s.length>0;){var n=s.shift();i=e.transition(i,n,f),o.forEach(function(e){return e.next(i)})}u=!1}},c=(0,w.vk)({id:n.id,send:function(e){s.push(e),flush()},getSnapshot:function(){return i},subscribe:function(e,n,s){var u=(0,m.zM)(e,n,s);return o.add(u),u.next(i),{unsubscribe:function(){o.delete(u)}}}}),f={parent:n.parent,self:c,id:n.id||"anonymous",observers:o};return i=e.start?e.start(f):i,c}var _={sync:!1,autoForward:!1};(o=s||(s={}))[o.NotStarted=0]="NotStarted",o[o.Running=1]="Running",o[o.Stopped=2]="Stopped";var O=function(){function Interpreter(e,n){void 0===n&&(n=Interpreter.defaultOptions);var i=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=s.NotStarted,this.children=new Map,this.forwardTo=new Set,this._outgoingQueue=[],this.init=this.start,this.send=function(e,n){if((0,m.kJ)(e))return i.batch(e),i.state;var o=(0,m.g5)((0,m._v)(e,n));if(i.status===s.Stopped)return g.M||(0,m.ZK)(!1,'Event "'.concat(o.name,'" was sent to stopped service "').concat(i.machine.id,'". This service has already reached its final state, and will not transition.\nEvent: ').concat(JSON.stringify(o.data))),i.state;if(i.status!==s.Running&&!i.options.deferEvents)throw Error('Event "'.concat(o.name,'" was sent to uninitialized service "').concat(i.machine.id,'". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.\nEvent: ').concat(JSON.stringify(o.data)));return i.scheduler.schedule(function(){i.forward(o);var e=i._nextState(o);i.update(e,o)}),i._state},this.sendTo=function(e,n,o){var u=i.parent&&(n===l.K.Parent||i.parent.id===n),c=u?i.parent:(0,m.HD)(n)?n===l.K.Internal?i:i.children.get(n)||E.get(n):(0,m.Bc)(n)?n:void 0;if(!c){if(!u)throw Error("Unable to send event to child '".concat(n,"' from service '").concat(i.id,"'."));g.M||(0,m.ZK)(!1,"Service '".concat(i.id,"' has no parent: unable to send event ").concat(e.type));return}if("machine"in c){if(i.status!==s.Stopped||i.parent!==c||i.state.done){var d=(0,f.pi)((0,f.pi)({},e),{name:e.name===v.vU?"".concat((0,y.vU)(i.id)):e.name,origin:i.sessionId});!o&&i.machine.config.predictableActionArguments?i._outgoingQueue.push([c,d]):c.send(d)}}else!o&&i.machine.config.predictableActionArguments?i._outgoingQueue.push([c,e.data]):c.send(e.data)},this._exec=function(e,n,o,u){void 0===u&&(u=i.machine.options.actions);var c=e.exec||(0,y.o$)(e.type,u),f=(0,m.mf)(c)?c:c?c.exec:e.exec;if(f)try{return f(n,o.data,i.machine.config.predictableActionArguments?{action:e,_event:o}:{action:e,state:i.state,_event:o})}catch(e){throw i.parent&&i.parent.send({type:"xstate.error",data:e}),e}switch(e.type){case v.OU:i.defer(e);break;case v.lW:if("number"==typeof e.delay){i.defer(e);return}e.to?i.sendTo(e._event,e.to,o===y.bf):i.send(e._event);break;case v.al:i.cancel(e.sendId);break;case v.BL:if(i.status!==s.Running)return;var d=e.activity;if(!i.machine.config.predictableActionArguments&&!i.state.activities[d.id||d.type])break;if(d.type===l.M.Invoke){var b=(0,m.j)(d.src),S=i.machine.options.services?i.machine.options.services[b.type]:void 0,w=d.id,x=d.data;g.M||(0,m.ZK)(!("forward"in d),"`forward` property is deprecated (found in invocation of '".concat(d.src,"' in in machine '").concat(i.machine.id,"'). ")+"Please use `autoForward` instead.");var A="autoForward"in d?d.autoForward:!!d.forward;if(!S){g.M||(0,m.ZK)(!1,"No service found for invocation '".concat(d.src,"' in machine '").concat(i.machine.id,"'."));return}var E=x?(0,m.QX)(x,n,o):void 0;if("string"==typeof S)return;var B=(0,m.mf)(S)?S(n,o.data,{data:E,src:b,meta:d.meta}):S;if(!B)return;var _=void 0;(0,m.O4)(B)&&(B=E?B.withContext(E):B,_={autoForward:A}),i.spawn(B,w,_)}else i.spawnActivity(d);break;case v.sT:i.stopChild(e.activity.id);break;case v.cM:var O=e.label,I=e.value;O?i.logger(O,I):i.logger(I);break;default:g.M||(0,m.ZK)(!1,"No implementation found for action type '".concat(e.type,"'"))}};var o=(0,f.pi)((0,f.pi)({},Interpreter.defaultOptions),n),u=o.clock,c=o.logger,d=o.parent,b=o.id,w=void 0!==b?b:e.id;this.id=w,this.logger=c,this.clock=u,this.parent=d,this.options=o,this.scheduler=new S({deferEvents:this.options.deferEvents}),this.sessionId=E.bookId()}return Object.defineProperty(Interpreter.prototype,"initialState",{get:function(){var e=this;return this._initialState?this._initialState:(0,B.J)(this,function(){return e._initialState=e.machine.initialState,e._initialState})},enumerable:!1,configurable:!0}),Object.defineProperty(Interpreter.prototype,"state",{get:function(){return g.M||(0,m.ZK)(this.status!==s.NotStarted,"Attempted to read state from uninitialized service '".concat(this.id,"'. Make sure the service is started first.")),this._state},enumerable:!1,configurable:!0}),Interpreter.prototype.execute=function(e,n){var i,o;try{for(var s=(0,f.XA)(e.actions),u=s.next();!u.done;u=s.next()){var c=u.value;this.exec(c,e,n)}}catch(e){i={error:e}}finally{try{u&&!u.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}},Interpreter.prototype.update=function(e,n){var i,o,s,u,c,l,d,v,g=this;if(e._sessionid=this.sessionId,this._state=e,(!this.machine.config.predictableActionArguments||n===y.bf)&&this.options.execute)this.execute(this.state);else for(var b=void 0;b=this._outgoingQueue.shift();)b[0].send(b[1]);if(this.children.forEach(function(e){g.state.children[e.id]=e}),this.devTools&&this.devTools.send(n.data,e),e.event)try{for(var S=(0,f.XA)(this.eventListeners),w=S.next();!w.done;w=S.next()){var x=w.value;x(e.event)}}catch(e){i={error:e}}finally{try{w&&!w.done&&(o=S.return)&&o.call(S)}finally{if(i)throw i.error}}try{for(var A=(0,f.XA)(this.listeners),B=A.next();!B.done;B=A.next()){var x=B.value;x(e,e.event)}}catch(e){s={error:e}}finally{try{B&&!B.done&&(u=A.return)&&u.call(A)}finally{if(s)throw s.error}}try{for(var _=(0,f.XA)(this.contextListeners),O=_.next();!O.done;O=_.next())(0,O.value)(this.state.context,this.state.history?this.state.history.context:void 0)}catch(e){c={error:e}}finally{try{O&&!O.done&&(l=_.return)&&l.call(_)}finally{if(c)throw c.error}}if(this.state.done){var I=e.configuration.find(function(e){return"final"===e.type&&e.parent===g.machine}),k=I&&I.doneData?(0,m.QX)(I.doneData,e.context,n):void 0;this._doneEvent=(0,y.Sl)(this.id,k);try{for(var N=(0,f.XA)(this.doneListeners),T=N.next();!T.done;T=N.next()){var x=T.value;x(this._doneEvent)}}catch(e){d={error:e}}finally{try{T&&!T.done&&(v=N.return)&&v.call(N)}finally{if(d)throw d.error}}this._stop(),this._stopChildren(),E.free(this.sessionId)}},Interpreter.prototype.onTransition=function(e){return this.listeners.add(e),this.status===s.Running&&e(this.state,this.state.event),this},Interpreter.prototype.subscribe=function(e,n,i){var o=this,u=(0,m.zM)(e,n,i);this.listeners.add(u.next),this.status!==s.NotStarted&&u.next(this.state);var completeOnce=function(){o.doneListeners.delete(completeOnce),o.stopListeners.delete(completeOnce),u.complete()};return this.status===s.Stopped?u.complete():(this.onDone(completeOnce),this.onStop(completeOnce)),{unsubscribe:function(){o.listeners.delete(u.next),o.doneListeners.delete(completeOnce),o.stopListeners.delete(completeOnce)}}},Interpreter.prototype.onEvent=function(e){return this.eventListeners.add(e),this},Interpreter.prototype.onSend=function(e){return this.sendListeners.add(e),this},Interpreter.prototype.onChange=function(e){return this.contextListeners.add(e),this},Interpreter.prototype.onStop=function(e){return this.stopListeners.add(e),this},Interpreter.prototype.onDone=function(e){return this.status===s.Stopped&&this._doneEvent?e(this._doneEvent):this.doneListeners.add(e),this},Interpreter.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},Interpreter.prototype.start=function(e){var n=this;if(this.status===s.Running)return this;this.machine._init(),E.register(this.sessionId,this),this.initialized=!0,this.status=s.Running;var i=void 0===e?this.initialState:(0,B.J)(this,function(){return(0,d.TL)(e)?n.machine.resolveState(e):n.machine.resolveState(d.ZM.from(e,n.machine.context))});return this.options.devTools&&this.attachDev(),this.scheduler.initialize(function(){n.update(i,y.bf)}),this},Interpreter.prototype._stopChildren=function(){this.children.forEach(function(e){(0,m.mf)(e.stop)&&e.stop()}),this.children.clear()},Interpreter.prototype._stop=function(){var e,n,i,o,u,c,l,d,v,y;try{for(var g=(0,f.XA)(this.listeners),m=g.next();!m.done;m=g.next()){var b=m.value;this.listeners.delete(b)}}catch(n){e={error:n}}finally{try{m&&!m.done&&(n=g.return)&&n.call(g)}finally{if(e)throw e.error}}try{for(var w=(0,f.XA)(this.stopListeners),x=w.next();!x.done;x=w.next()){var b=x.value;b(),this.stopListeners.delete(b)}}catch(e){i={error:e}}finally{try{x&&!x.done&&(o=w.return)&&o.call(w)}finally{if(i)throw i.error}}try{for(var A=(0,f.XA)(this.contextListeners),E=A.next();!E.done;E=A.next()){var b=E.value;this.contextListeners.delete(b)}}catch(e){u={error:e}}finally{try{E&&!E.done&&(c=A.return)&&c.call(A)}finally{if(u)throw u.error}}try{for(var B=(0,f.XA)(this.doneListeners),_=B.next();!_.done;_=B.next()){var b=_.value;this.doneListeners.delete(b)}}catch(e){l={error:e}}finally{try{_&&!_.done&&(d=B.return)&&d.call(B)}finally{if(l)throw l.error}}if(!this.initialized)return this;this.initialized=!1,this.status=s.Stopped,this._initialState=void 0;try{for(var O=(0,f.XA)(Object.keys(this.delayedEventsMap)),I=O.next();!I.done;I=O.next()){var k=I.value;this.clock.clearTimeout(this.delayedEventsMap[k])}}catch(e){v={error:e}}finally{try{I&&!I.done&&(y=O.return)&&y.call(O)}finally{if(v)throw v.error}}this.scheduler.clear(),this.scheduler=new S({deferEvents:this.options.deferEvents})},Interpreter.prototype.stop=function(){var e=this,n=this.scheduler;return this._stop(),n.schedule(function(){if(null===(n=e._state)||void 0===n||!n.done){var n,i=(0,m.g5)({type:"xstate.stop"}),o=(0,B.J)(e,function(){var n=(0,m.xH)((0,f.ev)([],(0,f.CR)(e.state.configuration),!1).sort(function(e,n){return n.order-e.order}).map(function(n){return(0,y.AE)(n.onExit,e.machine.options.actions)})),o=(0,f.CR)((0,y.yC)(e.machine,e.state,e.state.context,i,[{type:"exit",actions:n}],e.machine.config.predictableActionArguments?e._exec:void 0,e.machine.config.predictableActionArguments||e.machine.config.preserveActionOrder),2),s=o[0],u=o[1],c=new d.ZM({value:e.state.value,context:u,_event:i,_sessionid:e.sessionId,historyValue:void 0,history:e.state,actions:s.filter(function(e){return!(0,m.vK)(e)}),activities:{},events:[],configuration:[],transitions:[],children:{},done:e.state.done,tags:e.state.tags,machine:e.machine});return c.changed=!0,c});e.update(o,i),e._stopChildren(),E.free(e.sessionId)}}),this},Interpreter.prototype.batch=function(e){var n=this;if(this.status===s.NotStarted&&this.options.deferEvents)g.M||(0,m.ZK)(!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.\nEvent: ').concat(JSON.stringify(event)));else if(this.status!==s.Running)throw 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 i=!!this.machine.config.predictableActionArguments&&this._exec;this.scheduler.schedule(function(){var o,s,u=n.state,c=!1,l=[];try{for(var v=(0,f.XA)(e),y=v.next();!y.done;y=v.next()){var g=y.value;!function(e){var o=(0,m.g5)(e);n.forward(o),u=(0,B.J)(n,function(){return n.machine.transition(u,o,void 0,i||void 0)}),l.push.apply(l,(0,f.ev)([],(0,f.CR)(n.machine.config.predictableActionArguments?u.actions:u.actions.map(function(e){return(0,d.j1)(e,u)})),!1)),c=c||!!u.changed}(g)}}catch(e){o={error:e}}finally{try{y&&!y.done&&(s=v.return)&&s.call(v)}finally{if(o)throw o.error}}u.changed=c,u.actions=l,n.update(u,(0,m.g5)(e[e.length-1]))})}},Interpreter.prototype.sender=function(e){return this.send.bind(this,e)},Interpreter.prototype._nextState=function(e,n){var i=this;void 0===n&&(n=!!this.machine.config.predictableActionArguments&&this._exec);var o=(0,m.g5)(e);if(0===o.name.indexOf(v.Mg)&&!this.state.nextEvents.some(function(e){return 0===e.indexOf(v.Mg)}))throw o.data.data;return(0,B.J)(this,function(){return i.machine.transition(i.state,o,void 0,n||void 0)})},Interpreter.prototype.nextState=function(e){return this._nextState(e,!1)},Interpreter.prototype.forward=function(e){var n,i;try{for(var o=(0,f.XA)(this.forwardTo),s=o.next();!s.done;s=o.next()){var u=s.value,c=this.children.get(u);if(!c)throw Error("Unable to forward event '".concat(e,"' from interpreter '").concat(this.id,"' to nonexistant child '").concat(u,"'."));c.send(e)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}},Interpreter.prototype.defer=function(e){var n=this,i=this.clock.setTimeout(function(){"to"in e&&e.to?n.sendTo(e._event,e.to,!0):n.send(e._event)},e.delay);e.id&&(this.delayedEventsMap[e.id]=i)},Interpreter.prototype.cancel=function(e){this.clock.clearTimeout(this.delayedEventsMap[e]),delete this.delayedEventsMap[e]},Interpreter.prototype.exec=function(e,n,i){void 0===i&&(i=this.machine.options.actions),this._exec(e,n.context,n._event,i)},Interpreter.prototype.removeChild=function(e){var n;this.children.delete(e),this.forwardTo.delete(e),null===(n=this.state)||void 0===n||delete n.children[e]},Interpreter.prototype.stopChild=function(e){var n=this.children.get(e);n&&(this.removeChild(e),(0,m.mf)(n.stop)&&n.stop())},Interpreter.prototype.spawn=function(e,n,i){if(this.status!==s.Running)return(0,w.Xg)(e,n);if((0,m.y8)(e))return this.spawnPromise(Promise.resolve(e),n);if((0,m.mf)(e))return this.spawnCallback(e,n);if((0,w.f3)(e))return this.spawnActor(e,n);if((0,m.bi)(e))return this.spawnObservable(e,n);if((0,m.O4)(e))return this.spawnMachine(e,(0,f.pi)((0,f.pi)({},i),{id:n}));if((0,m.HV)(e))return this.spawnBehavior(e,n);throw Error('Unable to spawn entity "'.concat(n,'" of type "').concat(typeof e,'".'))},Interpreter.prototype.spawnMachine=function(e,n){var i=this;void 0===n&&(n={});var o=new Interpreter(e,(0,f.pi)((0,f.pi)({},this.options),{parent:this,id:n.id||e.id})),s=(0,f.pi)((0,f.pi)({},_),n);return s.sync&&o.onTransition(function(e){i.send(v.Vx,{state:e,id:o.id})}),this.children.set(o.id,o),s.autoForward&&this.forwardTo.add(o.id),o.onDone(function(e){i.removeChild(o.id),i.send((0,m.g5)(e,{origin:o.id}))}).start(),o},Interpreter.prototype.spawnBehavior=function(e,n){var i=spawnBehavior(e,{id:n,parent:this});return this.children.set(n,i),i},Interpreter.prototype.spawnPromise=function(e,n){var i,o,s=this,u=!1;e.then(function(e){u||(o=e,s.removeChild(n),s.send((0,m.g5)((0,y.Sl)(n,e),{origin:n})))},function(e){if(!u){s.removeChild(n);var i=(0,y.vU)(n,e);try{s.send((0,m.g5)(i,{origin:n}))}catch(o){(0,m.v4)(e,o,n),s.devTools&&s.devTools.send(i,s.state),s.machine.strict&&s.stop()}}});var c=((i={id:n,send:function(){},subscribe:function(n,i,o){var s=(0,m.zM)(n,i,o),u=!1;return e.then(function(e){!u&&(s.next(e),u||s.complete())},function(e){u||s.error(e)}),{unsubscribe:function(){return u=!0}}},stop:function(){u=!0},toJSON:function(){return{id:n}},getSnapshot:function(){return o}})[m.L$]=function(){return this},i);return this.children.set(n,c),c},Interpreter.prototype.spawnCallback=function(e,n){var i,o,s,u=this,c=!1,f=new Set,l=new Set;try{s=e(function(e){o=e,l.forEach(function(n){return n(e)}),c||u.send((0,m.g5)(e,{origin:n}))},function(e){f.add(e)})}catch(e){this.send((0,y.vU)(n,e))}if((0,m.y8)(s))return this.spawnPromise(s,n);var d=((i={id:n,send:function(e){return f.forEach(function(n){return n(e)})},subscribe:function(e){var n=(0,m.zM)(e);return l.add(n.next),{unsubscribe:function(){l.delete(n.next)}}},stop:function(){c=!0,(0,m.mf)(s)&&s()},toJSON:function(){return{id:n}},getSnapshot:function(){return o}})[m.L$]=function(){return this},i);return this.children.set(n,d),d},Interpreter.prototype.spawnObservable=function(e,n){var i,o,s=this,u=e.subscribe(function(e){o=e,s.send((0,m.g5)(e,{origin:n}))},function(e){s.removeChild(n),s.send((0,m.g5)((0,y.vU)(n,e),{origin:n}))},function(){s.removeChild(n),s.send((0,m.g5)((0,y.Sl)(n),{origin:n}))}),c=((i={id:n,send:function(){},subscribe:function(n,i,o){return e.subscribe(n,i,o)},stop:function(){return u.unsubscribe()},getSnapshot:function(){return o},toJSON:function(){return{id:n}}})[m.L$]=function(){return this},i);return this.children.set(n,c),c},Interpreter.prototype.spawnActor=function(e,n){return this.children.set(n,e),e},Interpreter.prototype.spawnActivity=function(e){var n=this.machine.options&&this.machine.options.activities?this.machine.options.activities[e.type]:void 0;if(!n){g.M||(0,m.ZK)(!1,"No implementation found for activity '".concat(e.type,"'"));return}var i=n(this.state.context,e);this.spawnEffect(e.id,i)},Interpreter.prototype.spawnEffect=function(e,n){var i;this.children.set(e,((i={id:e,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},stop:n||void 0,getSnapshot:function(){},toJSON:function(){return{id:e}}})[m.L$]=function(){return this},i))},Interpreter.prototype.attachDev=function(){var e=getGlobal();if(this.options.devTools&&e){if(e.__REDUX_DEVTOOLS_EXTENSION__){var n="object"==typeof this.options.devTools?this.options.devTools:void 0;this.devTools=e.__REDUX_DEVTOOLS_EXTENSION__.connect((0,f.pi)((0,f.pi)({name:this.id,autoPause:!0,stateSanitizer:function(e){return{value:e.value,context:e.context,actions:e.actions}}},n),{features:(0,f.pi)({jump:!1,skip:!1},n?n.features:void 0)}),this.machine),this.devTools.init(this.state)}registerService(this)}},Interpreter.prototype.toJSON=function(){return{id:this.id}},Interpreter.prototype[m.L$]=function(){return this},Interpreter.prototype.getSnapshot=function(){return this.status===s.NotStarted?this.initialState:this._state},Interpreter.defaultOptions={execute:!0,deferEvents:!0,clock:{setTimeout:function(e,n){return setTimeout(e,n)},clearTimeout:function(e){return clearTimeout(e)}},logger:console.log.bind(console),devTools:!1},Interpreter.interpret=interpret,Interpreter}();function interpret(e,n){return new O(e,n)}var I=u.useLayoutEffect;function useConstant(e){var n=u.useRef();return n.current||(n.current={v:e()}),n.current.v}var useInterpret_assign=function(){return(useInterpret_assign=Object.assign||function(e){for(var n,i=1,o=arguments.length;i<o;i++)for(var s in n=arguments[i])Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s]);return e}).apply(this,arguments)},__rest=function(e,n){var i={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&0>n.indexOf(o)&&(i[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var s=0,o=Object.getOwnPropertySymbols(e);s<o.length;s++)0>n.indexOf(o[s])&&Object.prototype.propertyIsEnumerable.call(e,o[s])&&(i[o[s]]=e[o[s]]);return i};function useIdleInterpreter(e,n){var i=useConstant(function(){return"function"==typeof e?e():e}),o=n.context,s=n.guards,u=n.actions,c=n.activities,f=n.services,l=n.delays,d=(n.state,__rest(n,["context","guards","actions","activities","services","delays","state"])),v=useConstant(function(){return interpret(i.withConfig({context:o,guards:s,actions:u,activities:c,services:f,delays:l},function(){return useInterpret_assign(useInterpret_assign({},i.context),o)}),d)});return I(function(){Object.assign(v.machine.options.actions,u),Object.assign(v.machine.options.guards,s),Object.assign(v.machine.options.activities,c),Object.assign(v.machine.options.services,f),Object.assign(v.machine.options.delays,l)},[u,s,c,f,l]),v}function isInterpreterStateEqual(e,n,i){if(e.status===s.NotStarted)return!0;var o=void 0===i.changed&&(Object.keys(i.children).length>0||"boolean"==typeof n.changed);return!(i.changed||o)}var useMachine_read=function(e,n){var i="function"==typeof Symbol&&e[Symbol.iterator];if(!i)return e;var o,s,u=i.call(e),c=[];try{for(;(void 0===n||n-- >0)&&!(o=u.next()).done;)c.push(o.value)}catch(e){s={error:e}}finally{try{o&&!o.done&&(i=u.return)&&i.call(u)}finally{if(s)throw s.error}}return c};function identity(e){return e}function useMachine(e){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];var o=useMachine_read(n,1)[0],f=void 0===o?{}:o,l=useIdleInterpreter(e,f),v=(0,u.useCallback)(function(){return l.status===s.NotStarted?f.state?d.ZM.create(f.state):l.machine.initialState:l.getSnapshot()},[l]),y=(0,u.useCallback)(function(e,n){return isInterpreterStateEqual(l,e,n)},[l]),g=(0,u.useCallback)(function(e){return l.subscribe(e).unsubscribe},[l]),m=(0,c.useSyncExternalStoreWithSelector)(g,v,v,identity,y);return(0,u.useEffect)(function(){var e=f.state;return l.start(e?d.ZM.create(e):void 0),function(){l.stop(),l.status=s.NotStarted}},[]),[m,l.send,l]}},79742:function(e,n){"use strict";n.byteLength=byteLength,n.toByteArray=toByteArray,n.fromByteArray=fromByteArray;for(var i=[],o=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,f=u.length;c<f;++c)i[c]=u[c],o[u.charCodeAt(c)]=c;function getLens(e){var n=e.length;if(n%4>0)throw Error("Invalid string. Length must be a multiple of 4");var i=e.indexOf("=");-1===i&&(i=n);var o=i===n?0:4-i%4;return[i,o]}function byteLength(e){var n=getLens(e),i=n[0],o=n[1];return(i+o)*3/4-o}function _byteLength(e,n,i){return(n+i)*3/4-i}function toByteArray(e){var n,i,u=getLens(e),c=u[0],f=u[1],l=new s(_byteLength(e,c,f)),d=0,v=f>0?c-4:c;for(i=0;i<v;i+=4)n=o[e.charCodeAt(i)]<<18|o[e.charCodeAt(i+1)]<<12|o[e.charCodeAt(i+2)]<<6|o[e.charCodeAt(i+3)],l[d++]=n>>16&255,l[d++]=n>>8&255,l[d++]=255&n;return 2===f&&(n=o[e.charCodeAt(i)]<<2|o[e.charCodeAt(i+1)]>>4,l[d++]=255&n),1===f&&(n=o[e.charCodeAt(i)]<<10|o[e.charCodeAt(i+1)]<<4|o[e.charCodeAt(i+2)]>>2,l[d++]=n>>8&255,l[d++]=255&n),l}function tripletToBase64(e){return i[e>>18&63]+i[e>>12&63]+i[e>>6&63]+i[63&e]}function encodeChunk(e,n,i){for(var o=[],s=n;s<i;s+=3)o.push(tripletToBase64((e[s]<<16&16711680)+(e[s+1]<<8&65280)+(255&e[s+2])));return o.join("")}function fromByteArray(e){for(var n,o=e.length,s=o%3,u=[],c=0,f=o-s;c<f;c+=16383)u.push(encodeChunk(e,c,c+16383>f?f:c+16383));return 1===s?u.push(i[(n=e[o-1])>>2]+i[n<<4&63]+"=="):2===s&&u.push(i[(n=(e[o-2]<<8)+e[o-1])>>10]+i[n>>4&63]+i[n<<2&63]+"="),u.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},48764:function(e,n,i){"use strict";/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/var o=i(79742),s=i(80645),u="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;function typedArraySupport(){try{var e=new Uint8Array(1),n={foo:function(){return 42}};return Object.setPrototypeOf(n,Uint8Array.prototype),Object.setPrototypeOf(e,n),42===e.foo()}catch(e){return!1}}function createBuffer(e){if(e>2147483647)throw RangeError('The value "'+e+'" is invalid for option "size"');var n=new Uint8Array(e);return Object.setPrototypeOf(n,Buffer.prototype),n}function Buffer(e,n,i){if("number"==typeof e){if("string"==typeof n)throw TypeError('The "string" argument must be of type string. Received type number');return allocUnsafe(e)}return from(e,n,i)}function from(e,n,i){if("string"==typeof e)return fromString(e,n);if(ArrayBuffer.isView(e))return fromArrayView(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(isInstance(e,ArrayBuffer)||e&&isInstance(e.buffer,ArrayBuffer)||"undefined"!=typeof SharedArrayBuffer&&(isInstance(e,SharedArrayBuffer)||e&&isInstance(e.buffer,SharedArrayBuffer)))return fromArrayBuffer(e,n,i);if("number"==typeof e)throw TypeError('The "value" argument must not be of type number. Received type number');var o=e.valueOf&&e.valueOf();if(null!=o&&o!==e)return Buffer.from(o,n,i);var s=fromObject(e);if(s)return s;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return Buffer.from(e[Symbol.toPrimitive]("string"),n,i);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function assertSize(e){if("number"!=typeof e)throw TypeError('"size" argument must be of type number');if(e<0)throw RangeError('The value "'+e+'" is invalid for option "size"')}function alloc(e,n,i){return(assertSize(e),e<=0)?createBuffer(e):void 0!==n?"string"==typeof i?createBuffer(e).fill(n,i):createBuffer(e).fill(n):createBuffer(e)}function allocUnsafe(e){return assertSize(e),createBuffer(e<0?0:0|checked(e))}function fromString(e,n){if(("string"!=typeof n||""===n)&&(n="utf8"),!Buffer.isEncoding(n))throw TypeError("Unknown encoding: "+n);var i=0|byteLength(e,n),o=createBuffer(i),s=o.write(e,n);return s!==i&&(o=o.slice(0,s)),o}function fromArrayLike(e){for(var n=e.length<0?0:0|checked(e.length),i=createBuffer(n),o=0;o<n;o+=1)i[o]=255&e[o];return i}function fromArrayView(e){if(isInstance(e,Uint8Array)){var n=new Uint8Array(e);return fromArrayBuffer(n.buffer,n.byteOffset,n.byteLength)}return fromArrayLike(e)}function fromArrayBuffer(e,n,i){var o;if(n<0||e.byteLength<n)throw RangeError('"offset" is outside of buffer bounds');if(e.byteLength<n+(i||0))throw RangeError('"length" is outside of buffer bounds');return Object.setPrototypeOf(o=void 0===n&&void 0===i?new Uint8Array(e):void 0===i?new Uint8Array(e,n):new Uint8Array(e,n,i),Buffer.prototype),o}function fromObject(e){if(Buffer.isBuffer(e)){var n,i=0|checked(e.length),o=createBuffer(i);return 0===o.length||e.copy(o,0,0,i),o}return void 0!==e.length?"number"!=typeof e.length||(n=e.length)!=n?createBuffer(0):fromArrayLike(e):"Buffer"===e.type&&Array.isArray(e.data)?fromArrayLike(e.data):void 0}function checked(e){if(e>=2147483647)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|e}function byteLength(e,n){if(Buffer.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||isInstance(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var i=e.length,o=arguments.length>2&&!0===arguments[2];if(!o&&0===i)return 0;for(var s=!1;;)switch(n){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return utf8ToBytes(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return base64ToBytes(e).length;default:if(s)return o?-1:utf8ToBytes(e).length;n=(""+n).toLowerCase(),s=!0}}function slowToString(e,n,i){var o=!1;if((void 0===n||n<0)&&(n=0),n>this.length||((void 0===i||i>this.length)&&(i=this.length),i<=0||(i>>>=0)<=(n>>>=0)))return"";for(e||(e="utf8");;)switch(e){case"hex":return hexSlice(this,n,i);case"utf8":case"utf-8":return utf8Slice(this,n,i);case"ascii":return asciiSlice(this,n,i);case"latin1":case"binary":return latin1Slice(this,n,i);case"base64":return base64Slice(this,n,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,n,i);default:if(o)throw TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0}}function swap(e,n,i){var o=e[n];e[n]=e[i],e[i]=o}function bidirectionalIndexOf(e,n,i,o,s){var u;if(0===e.length)return -1;if("string"==typeof i?(o=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),(u=i=+i)!=u&&(i=s?0:e.length-1),i<0&&(i=e.length+i),i>=e.length){if(s)return -1;i=e.length-1}else if(i<0){if(!s)return -1;i=0}if("string"==typeof n&&(n=Buffer.from(n,o)),Buffer.isBuffer(n))return 0===n.length?-1:arrayIndexOf(e,n,i,o,s);if("number"==typeof n)return(n&=255,"function"==typeof Uint8Array.prototype.indexOf)?s?Uint8Array.prototype.indexOf.call(e,n,i):Uint8Array.prototype.lastIndexOf.call(e,n,i):arrayIndexOf(e,[n],i,o,s);throw TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,n,i,o,s){var u,c=1,f=e.length,l=n.length;if(void 0!==o&&("ucs2"===(o=String(o).toLowerCase())||"ucs-2"===o||"utf16le"===o||"utf-16le"===o)){if(e.length<2||n.length<2)return -1;c=2,f/=2,l/=2,i/=2}function read(e,n){return 1===c?e[n]:e.readUInt16BE(n*c)}if(s){var d=-1;for(u=i;u<f;u++)if(read(e,u)===read(n,-1===d?0:u-d)){if(-1===d&&(d=u),u-d+1===l)return d*c}else -1!==d&&(u-=u-d),d=-1}else for(i+l>f&&(i=f-l),u=i;u>=0;u--){for(var v=!0,y=0;y<l;y++)if(read(e,u+y)!==read(n,y)){v=!1;break}if(v)return u}return -1}function hexWrite(e,n,i,o){i=Number(i)||0;var s=e.length-i;o?(o=Number(o))>s&&(o=s):o=s;var u=n.length;o>u/2&&(o=u/2);for(var c=0;c<o;++c){var f=parseInt(n.substr(2*c,2),16);if(f!=f)break;e[i+c]=f}return c}function utf8Write(e,n,i,o){return blitBuffer(utf8ToBytes(n,e.length-i),e,i,o)}function asciiWrite(e,n,i,o){return blitBuffer(asciiToBytes(n),e,i,o)}function base64Write(e,n,i,o){return blitBuffer(base64ToBytes(n),e,i,o)}function ucs2Write(e,n,i,o){return blitBuffer(utf16leToBytes(n,e.length-i),e,i,o)}function base64Slice(e,n,i){return 0===n&&i===e.length?o.fromByteArray(e):o.fromByteArray(e.slice(n,i))}function utf8Slice(e,n,i){i=Math.min(e.length,i);for(var o=[],s=n;s<i;){var u,c,f,l,d=e[s],v=null,y=d>239?4:d>223?3:d>191?2:1;if(s+y<=i)switch(y){case 1:d<128&&(v=d);break;case 2:(192&(u=e[s+1]))==128&&(l=(31&d)<<6|63&u)>127&&(v=l);break;case 3:u=e[s+1],c=e[s+2],(192&u)==128&&(192&c)==128&&(l=(15&d)<<12|(63&u)<<6|63&c)>2047&&(l<55296||l>57343)&&(v=l);break;case 4:u=e[s+1],c=e[s+2],f=e[s+3],(192&u)==128&&(192&c)==128&&(192&f)==128&&(l=(15&d)<<18|(63&u)<<12|(63&c)<<6|63&f)>65535&&l<1114112&&(v=l)}null===v?(v=65533,y=1):v>65535&&(v-=65536,o.push(v>>>10&1023|55296),v=56320|1023&v),o.push(v),s+=y}return decodeCodePointsArray(o)}function decodeCodePointsArray(e){var n=e.length;if(n<=4096)return String.fromCharCode.apply(String,e);for(var i="",o=0;o<n;)i+=String.fromCharCode.apply(String,e.slice(o,o+=4096));return i}function asciiSlice(e,n,i){var o="";i=Math.min(e.length,i);for(var s=n;s<i;++s)o+=String.fromCharCode(127&e[s]);return o}function latin1Slice(e,n,i){var o="";i=Math.min(e.length,i);for(var s=n;s<i;++s)o+=String.fromCharCode(e[s]);return o}function hexSlice(e,n,i){var o=e.length;(!n||n<0)&&(n=0),(!i||i<0||i>o)&&(i=o);for(var s="",u=n;u<i;++u)s+=f[e[u]];return s}function utf16leSlice(e,n,i){for(var o=e.slice(n,i),s="",u=0;u<o.length-1;u+=2)s+=String.fromCharCode(o[u]+256*o[u+1]);return s}function checkOffset(e,n,i){if(e%1!=0||e<0)throw RangeError("offset is not uint");if(e+n>i)throw RangeError("Trying to access beyond buffer length")}function checkInt(e,n,i,o,s,u){if(!Buffer.isBuffer(e))throw TypeError('"buffer" argument must be a Buffer instance');if(n>s||n<u)throw RangeError('"value" argument is out of bounds');if(i+o>e.length)throw RangeError("Index out of range")}function checkIEEE754(e,n,i,o,s,u){if(i+o>e.length||i<0)throw RangeError("Index out of range")}function writeFloat(e,n,i,o,u){return n=+n,i>>>=0,u||checkIEEE754(e,n,i,4,34028234663852886e22,-34028234663852886e22),s.write(e,n,i,o,23,4),i+4}function writeDouble(e,n,i,o,u){return n=+n,i>>>=0,u||checkIEEE754(e,n,i,8,17976931348623157e292,-17976931348623157e292),s.write(e,n,i,o,52,8),i+8}n.lW=Buffer,n.h2=50,Buffer.TYPED_ARRAY_SUPPORT=typedArraySupport(),Buffer.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(Buffer.prototype,"parent",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.buffer}}),Object.defineProperty(Buffer.prototype,"offset",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.byteOffset}}),Buffer.poolSize=8192,Buffer.from=function(e,n,i){return from(e,n,i)},Object.setPrototypeOf(Buffer.prototype,Uint8Array.prototype),Object.setPrototypeOf(Buffer,Uint8Array),Buffer.alloc=function(e,n,i){return alloc(e,n,i)},Buffer.allocUnsafe=function(e){return allocUnsafe(e)},Buffer.allocUnsafeSlow=function(e){return allocUnsafe(e)},Buffer.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==Buffer.prototype},Buffer.compare=function(e,n){if(isInstance(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),isInstance(n,Uint8Array)&&(n=Buffer.from(n,n.offset,n.byteLength)),!Buffer.isBuffer(e)||!Buffer.isBuffer(n))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===n)return 0;for(var i=e.length,o=n.length,s=0,u=Math.min(i,o);s<u;++s)if(e[s]!==n[s]){i=e[s],o=n[s];break}return i<o?-1:o<i?1:0},Buffer.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Buffer.concat=function(e,n){if(!Array.isArray(e))throw TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return Buffer.alloc(0);if(void 0===n)for(i=0,n=0;i<e.length;++i)n+=e[i].length;var i,o=Buffer.allocUnsafe(n),s=0;for(i=0;i<e.length;++i){var u=e[i];if(isInstance(u,Uint8Array))s+u.length>o.length?Buffer.from(u).copy(o,s):Uint8Array.prototype.set.call(o,u,s);else if(Buffer.isBuffer(u))u.copy(o,s);else throw TypeError('"list" argument must be an Array of Buffers');s+=u.length}return o},Buffer.byteLength=byteLength,Buffer.prototype._isBuffer=!0,Buffer.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw RangeError("Buffer size must be a multiple of 16-bits");for(var n=0;n<e;n+=2)swap(this,n,n+1);return this},Buffer.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw RangeError("Buffer size must be a multiple of 32-bits");for(var n=0;n<e;n+=4)swap(this,n,n+3),swap(this,n+1,n+2);return this},Buffer.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw RangeError("Buffer size must be a multiple of 64-bits");for(var n=0;n<e;n+=8)swap(this,n,n+7),swap(this,n+1,n+6),swap(this,n+2,n+5),swap(this,n+3,n+4);return this},Buffer.prototype.toString=function(){var e=this.length;return 0===e?"":0==arguments.length?utf8Slice(this,0,e):slowToString.apply(this,arguments)},Buffer.prototype.toLocaleString=Buffer.prototype.toString,Buffer.prototype.equals=function(e){if(!Buffer.isBuffer(e))throw TypeError("Argument must be a Buffer");return this===e||0===Buffer.compare(this,e)},Buffer.prototype.inspect=function(){var e="",i=n.h2;return e=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(e+=" ... "),"<Buffer "+e+">"},u&&(Buffer.prototype[u]=Buffer.prototype.inspect),Buffer.prototype.compare=function(e,n,i,o,s){if(isInstance(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),!Buffer.isBuffer(e))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===n&&(n=0),void 0===i&&(i=e?e.length:0),void 0===o&&(o=0),void 0===s&&(s=this.length),n<0||i>e.length||o<0||s>this.length)throw RangeError("out of range index");if(o>=s&&n>=i)return 0;if(o>=s)return -1;if(n>=i)return 1;if(n>>>=0,i>>>=0,o>>>=0,s>>>=0,this===e)return 0;for(var u=s-o,c=i-n,f=Math.min(u,c),l=this.slice(o,s),d=e.slice(n,i),v=0;v<f;++v)if(l[v]!==d[v]){u=l[v],c=d[v];break}return u<c?-1:c<u?1:0},Buffer.prototype.includes=function(e,n,i){return -1!==this.indexOf(e,n,i)},Buffer.prototype.indexOf=function(e,n,i){return bidirectionalIndexOf(this,e,n,i,!0)},Buffer.prototype.lastIndexOf=function(e,n,i){return bidirectionalIndexOf(this,e,n,i,!1)},Buffer.prototype.write=function(e,n,i,o){if(void 0===n)o="utf8",i=this.length,n=0;else if(void 0===i&&"string"==typeof n)o=n,i=this.length,n=0;else if(isFinite(n))n>>>=0,isFinite(i)?(i>>>=0,void 0===o&&(o="utf8")):(o=i,i=void 0);else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var s=this.length-n;if((void 0===i||i>s)&&(i=s),e.length>0&&(i<0||n<0)||n>this.length)throw RangeError("Attempt to write outside buffer bounds");o||(o="utf8");for(var u=!1;;)switch(o){case"hex":return hexWrite(this,e,n,i);case"utf8":case"utf-8":return utf8Write(this,e,n,i);case"ascii":case"latin1":case"binary":return asciiWrite(this,e,n,i);case"base64":return base64Write(this,e,n,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,e,n,i);default:if(u)throw TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),u=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},Buffer.prototype.slice=function(e,n){var i=this.length;e=~~e,n=void 0===n?i:~~n,e<0?(e+=i)<0&&(e=0):e>i&&(e=i),n<0?(n+=i)<0&&(n=0):n>i&&(n=i),n<e&&(n=e);var o=this.subarray(e,n);return Object.setPrototypeOf(o,Buffer.prototype),o},Buffer.prototype.readUintLE=Buffer.prototype.readUIntLE=function(e,n,i){e>>>=0,n>>>=0,i||checkOffset(e,n,this.length);for(var o=this[e],s=1,u=0;++u<n&&(s*=256);)o+=this[e+u]*s;return o},Buffer.prototype.readUintBE=Buffer.prototype.readUIntBE=function(e,n,i){e>>>=0,n>>>=0,i||checkOffset(e,n,this.length);for(var o=this[e+--n],s=1;n>0&&(s*=256);)o+=this[e+--n]*s;return o},Buffer.prototype.readUint8=Buffer.prototype.readUInt8=function(e,n){return e>>>=0,n||checkOffset(e,1,this.length),this[e]},Buffer.prototype.readUint16LE=Buffer.prototype.readUInt16LE=function(e,n){return e>>>=0,n||checkOffset(e,2,this.length),this[e]|this[e+1]<<8},Buffer.prototype.readUint16BE=Buffer.prototype.readUInt16BE=function(e,n){return e>>>=0,n||checkOffset(e,2,this.length),this[e]<<8|this[e+1]},Buffer.prototype.readUint32LE=Buffer.prototype.readUInt32LE=function(e,n){return e>>>=0,n||checkOffset(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Buffer.prototype.readUint32BE=Buffer.prototype.readUInt32BE=function(e,n){return e>>>=0,n||checkOffset(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Buffer.prototype.readIntLE=function(e,n,i){e>>>=0,n>>>=0,i||checkOffset(e,n,this.length);for(var o=this[e],s=1,u=0;++u<n&&(s*=256);)o+=this[e+u]*s;return o>=(s*=128)&&(o-=Math.pow(2,8*n)),o},Buffer.prototype.readIntBE=function(e,n,i){e>>>=0,n>>>=0,i||checkOffset(e,n,this.length);for(var o=n,s=1,u=this[e+--o];o>0&&(s*=256);)u+=this[e+--o]*s;return u>=(s*=128)&&(u-=Math.pow(2,8*n)),u},Buffer.prototype.readInt8=function(e,n){return(e>>>=0,n||checkOffset(e,1,this.length),128&this[e])?-((255-this[e]+1)*1):this[e]},Buffer.prototype.readInt16LE=function(e,n){e>>>=0,n||checkOffset(e,2,this.length);var i=this[e]|this[e+1]<<8;return 32768&i?4294901760|i:i},Buffer.prototype.readInt16BE=function(e,n){e>>>=0,n||checkOffset(e,2,this.length);var i=this[e+1]|this[e]<<8;return 32768&i?4294901760|i:i},Buffer.prototype.readInt32LE=function(e,n){return e>>>=0,n||checkOffset(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Buffer.prototype.readInt32BE=function(e,n){return e>>>=0,n||checkOffset(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Buffer.prototype.readFloatLE=function(e,n){return e>>>=0,n||checkOffset(e,4,this.length),s.read(this,e,!0,23,4)},Buffer.prototype.readFloatBE=function(e,n){return e>>>=0,n||checkOffset(e,4,this.length),s.read(this,e,!1,23,4)},Buffer.prototype.readDoubleLE=function(e,n){return e>>>=0,n||checkOffset(e,8,this.length),s.read(this,e,!0,52,8)},Buffer.prototype.readDoubleBE=function(e,n){return e>>>=0,n||checkOffset(e,8,this.length),s.read(this,e,!1,52,8)},Buffer.prototype.writeUintLE=Buffer.prototype.writeUIntLE=function(e,n,i,o){if(e=+e,n>>>=0,i>>>=0,!o){var s=Math.pow(2,8*i)-1;checkInt(this,e,n,i,s,0)}var u=1,c=0;for(this[n]=255&e;++c<i&&(u*=256);)this[n+c]=e/u&255;return n+i},Buffer.prototype.writeUintBE=Buffer.prototype.writeUIntBE=function(e,n,i,o){if(e=+e,n>>>=0,i>>>=0,!o){var s=Math.pow(2,8*i)-1;checkInt(this,e,n,i,s,0)}var u=i-1,c=1;for(this[n+u]=255&e;--u>=0&&(c*=256);)this[n+u]=e/c&255;return n+i},Buffer.prototype.writeUint8=Buffer.prototype.writeUInt8=function(e,n,i){return e=+e,n>>>=0,i||checkInt(this,e,n,1,255,0),this[n]=255&e,n+1},Buffer.prototype.writeUint16LE=Buffer.prototype.writeUInt16LE=function(e,n,i){return e=+e,n>>>=0,i||checkInt(this,e,n,2,65535,0),this[n]=255&e,this[n+1]=e>>>8,n+2},Buffer.prototype.writeUint16BE=Buffer.prototype.writeUInt16BE=function(e,n,i){return e=+e,n>>>=0,i||checkInt(this,e,n,2,65535,0),this[n]=e>>>8,this[n+1]=255&e,n+2},Buffer.prototype.writeUint32LE=Buffer.prototype.writeUInt32LE=function(e,n,i){return e=+e,n>>>=0,i||checkInt(this,e,n,4,4294967295,0),this[n+3]=e>>>24,this[n+2]=e>>>16,this[n+1]=e>>>8,this[n]=255&e,n+4},Buffer.prototype.writeUint32BE=Buffer.prototype.writeUInt32BE=function(e,n,i){return e=+e,n>>>=0,i||checkInt(this,e,n,4,4294967295,0),this[n]=e>>>24,this[n+1]=e>>>16,this[n+2]=e>>>8,this[n+3]=255&e,n+4},Buffer.prototype.writeIntLE=function(e,n,i,o){if(e=+e,n>>>=0,!o){var s=Math.pow(2,8*i-1);checkInt(this,e,n,i,s-1,-s)}var u=0,c=1,f=0;for(this[n]=255&e;++u<i&&(c*=256);)e<0&&0===f&&0!==this[n+u-1]&&(f=1),this[n+u]=(e/c>>0)-f&255;return n+i},Buffer.prototype.writeIntBE=function(e,n,i,o){if(e=+e,n>>>=0,!o){var s=Math.pow(2,8*i-1);checkInt(this,e,n,i,s-1,-s)}var u=i-1,c=1,f=0;for(this[n+u]=255&e;--u>=0&&(c*=256);)e<0&&0===f&&0!==this[n+u+1]&&(f=1),this[n+u]=(e/c>>0)-f&255;return n+i},Buffer.prototype.writeInt8=function(e,n,i){return e=+e,n>>>=0,i||checkInt(this,e,n,1,127,-128),e<0&&(e=255+e+1),this[n]=255&e,n+1},Buffer.prototype.writeInt16LE=function(e,n,i){return e=+e,n>>>=0,i||checkInt(this,e,n,2,32767,-32768),this[n]=255&e,this[n+1]=e>>>8,n+2},Buffer.prototype.writeInt16BE=function(e,n,i){return e=+e,n>>>=0,i||checkInt(this,e,n,2,32767,-32768),this[n]=e>>>8,this[n+1]=255&e,n+2},Buffer.prototype.writeInt32LE=function(e,n,i){return e=+e,n>>>=0,i||checkInt(this,e,n,4,2147483647,-2147483648),this[n]=255&e,this[n+1]=e>>>8,this[n+2]=e>>>16,this[n+3]=e>>>24,n+4},Buffer.prototype.writeInt32BE=function(e,n,i){return e=+e,n>>>=0,i||checkInt(this,e,n,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[n]=e>>>24,this[n+1]=e>>>16,this[n+2]=e>>>8,this[n+3]=255&e,n+4},Buffer.prototype.writeFloatLE=function(e,n,i){return writeFloat(this,e,n,!0,i)},Buffer.prototype.writeFloatBE=function(e,n,i){return writeFloat(this,e,n,!1,i)},Buffer.prototype.writeDoubleLE=function(e,n,i){return writeDouble(this,e,n,!0,i)},Buffer.prototype.writeDoubleBE=function(e,n,i){return writeDouble(this,e,n,!1,i)},Buffer.prototype.copy=function(e,n,i,o){if(!Buffer.isBuffer(e))throw TypeError("argument should be a Buffer");if(i||(i=0),o||0===o||(o=this.length),n>=e.length&&(n=e.length),n||(n=0),o>0&&o<i&&(o=i),o===i||0===e.length||0===this.length)return 0;if(n<0)throw RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw RangeError("Index out of range");if(o<0)throw RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-n<o-i&&(o=e.length-n+i);var s=o-i;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(n,i,o):Uint8Array.prototype.set.call(e,this.subarray(i,o),n),s},Buffer.prototype.fill=function(e,n,i,o){if("string"==typeof e){if("string"==typeof n?(o=n,n=0,i=this.length):"string"==typeof i&&(o=i,i=this.length),void 0!==o&&"string"!=typeof o)throw TypeError("encoding must be a string");if("string"==typeof o&&!Buffer.isEncoding(o))throw TypeError("Unknown encoding: "+o);if(1===e.length){var s,u=e.charCodeAt(0);("utf8"===o&&u<128||"latin1"===o)&&(e=u)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(n<0||this.length<n||this.length<i)throw RangeError("Out of range index");if(i<=n)return this;if(n>>>=0,i=void 0===i?this.length:i>>>0,e||(e=0),"number"==typeof e)for(s=n;s<i;++s)this[s]=e;else{var c=Buffer.isBuffer(e)?e:Buffer.from(e,o),f=c.length;if(0===f)throw TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<i-n;++s)this[s+n]=c[s%f]}return this};var c=/[^+/0-9A-Za-z-_]/g;function base64clean(e){if((e=(e=e.split("=")[0]).trim().replace(c,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}function utf8ToBytes(e,n){n=n||1/0;for(var i,o=e.length,s=null,u=[],c=0;c<o;++c){if((i=e.charCodeAt(c))>55295&&i<57344){if(!s){if(i>56319||c+1===o){(n-=3)>-1&&u.push(239,191,189);continue}s=i;continue}if(i<56320){(n-=3)>-1&&u.push(239,191,189),s=i;continue}i=(s-55296<<10|i-56320)+65536}else s&&(n-=3)>-1&&u.push(239,191,189);if(s=null,i<128){if((n-=1)<0)break;u.push(i)}else if(i<2048){if((n-=2)<0)break;u.push(i>>6|192,63&i|128)}else if(i<65536){if((n-=3)<0)break;u.push(i>>12|224,i>>6&63|128,63&i|128)}else if(i<1114112){if((n-=4)<0)break;u.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}else throw Error("Invalid code point")}return u}function asciiToBytes(e){for(var n=[],i=0;i<e.length;++i)n.push(255&e.charCodeAt(i));return n}function utf16leToBytes(e,n){for(var i,o,s=[],u=0;u<e.length&&!((n-=2)<0);++u)o=(i=e.charCodeAt(u))>>8,s.push(i%256),s.push(o);return s}function base64ToBytes(e){return o.toByteArray(base64clean(e))}function blitBuffer(e,n,i,o){for(var s=0;s<o&&!(s+i>=n.length)&&!(s>=e.length);++s)n[s+i]=e[s];return s}function isInstance(e,n){return e instanceof n||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===n.name}var f=function(){for(var e="0123456789abcdef",n=Array(256),i=0;i<16;++i)for(var o=16*i,s=0;s<16;++s)n[o+s]=e[i]+e[s];return n}()},80645:function(e,n){/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */n.read=function(e,n,i,o,s){var u,c,f=8*s-o-1,l=(1<<f)-1,d=l>>1,v=-7,y=i?s-1:0,g=i?-1:1,m=e[n+y];for(y+=g,u=m&(1<<-v)-1,m>>=-v,v+=f;v>0;u=256*u+e[n+y],y+=g,v-=8);for(c=u&(1<<-v)-1,u>>=-v,v+=o;v>0;c=256*c+e[n+y],y+=g,v-=8);if(0===u)u=1-d;else{if(u===l)return c?NaN:(m?-1:1)*(1/0);c+=Math.pow(2,o),u-=d}return(m?-1:1)*c*Math.pow(2,u-o)},n.write=function(e,n,i,o,s,u){var c,f,l,d=8*u-s-1,v=(1<<d)-1,y=v>>1,g=23===s?5960464477539062e-23:0,m=o?0:u-1,b=o?1:-1,S=n<0||0===n&&1/n<0?1:0;for(isNaN(n=Math.abs(n))||n===1/0?(f=isNaN(n)?1:0,c=v):(c=Math.floor(Math.log(n)/Math.LN2),n*(l=Math.pow(2,-c))<1&&(c--,l*=2),c+y>=1?n+=g/l:n+=g*Math.pow(2,1-y),n*l>=2&&(c++,l/=2),c+y>=v?(f=0,c=v):c+y>=1?(f=(n*l-1)*Math.pow(2,s),c+=y):(f=n*Math.pow(2,y-1)*Math.pow(2,s),c=0));s>=8;e[i+m]=255&f,m+=b,f/=256,s-=8);for(c=c<<s|f,d+=s;d>0;e[i+m]=255&c,m+=b,c/=256,d-=8);e[i+m-b]|=128*S}},4511:function(e,n,i){"use strict";i.d(n,{SV:function(){return ErrorBoundary}});var o=i(67294);let s=(0,o.createContext)(null),u={didCatch:!1,error:null};let ErrorBoundary=class ErrorBoundary extends o.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=u}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){let{error:e}=this.state;if(null!==e){for(var n,i,o=arguments.length,s=Array(o),c=0;c<o;c++)s[c]=arguments[c];null===(n=(i=this.props).onReset)||void 0===n||n.call(i,{args:s,reason:"imperative-api"}),this.setState(u)}}componentDidCatch(e,n){var i,o;null===(i=(o=this.props).onError)||void 0===i||i.call(o,e,n)}componentDidUpdate(e,n){let{didCatch:i}=this.state,{resetKeys:o}=this.props;if(i&&null!==n.error&&hasArrayChanged(e.resetKeys,o)){var s,c;null===(s=(c=this.props).onReset)||void 0===s||s.call(c,{next:o,prev:e.resetKeys,reason:"keys"}),this.setState(u)}}render(){let{children:e,fallbackRender:n,FallbackComponent:i,fallback:u}=this.props,{didCatch:c,error:f}=this.state,l=e;if(c){let e={error:f,resetErrorBoundary:this.resetErrorBoundary};if((0,o.isValidElement)(u))l=u;else if("function"==typeof n)l=n(e);else if(i)l=(0,o.createElement)(i,e);else throw f}return(0,o.createElement)(s.Provider,{value:{didCatch:c,error:f,resetErrorBoundary:this.resetErrorBoundary}},l)}};function hasArrayChanged(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.length!==n.length||e.some((e,i)=>!Object.is(e,n[i]))}},53250:function(e,n,i){"use strict";/**
* @license React
* use-sync-external-store-shim.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var o=i(67294);function h(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n}var s="function"==typeof Object.is?Object.is:h,u=o.useState,c=o.useEffect,f=o.useLayoutEffect,l=o.useDebugValue;function q(e,n){var i=n(),o=u({inst:{value:i,getSnapshot:n}}),s=o[0].inst,d=o[1];return f(function(){s.value=i,s.getSnapshot=n,r(s)&&d({inst:s})},[e,i,n]),c(function(){return r(s)&&d({inst:s}),e(function(){r(s)&&d({inst:s})})},[e]),l(i),i}function r(e){var n=e.getSnapshot;e=e.value;try{var i=n();return!s(e,i)}catch(e){return!0}}function t(e,n){return n()}var d="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?t:q;n.useSyncExternalStore=void 0!==o.useSyncExternalStore?o.useSyncExternalStore:d},50139:function(e,n,i){"use strict";/**
* @license React
* use-sync-external-store-shim/with-selector.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var o=i(67294),s=i(61688);function p(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n}var u="function"==typeof Object.is?Object.is:p,c=s.useSyncExternalStore,f=o.useRef,l=o.useEffect,d=o.useMemo,v=o.useDebugValue;n.useSyncExternalStoreWithSelector=function(e,n,i,o,s){var y=f(null);if(null===y.current){var g={hasValue:!1,value:null};y.current=g}else g=y.current;var m=c(e,(y=d(function(){function a(n){if(!f){if(f=!0,e=n,n=o(n),void 0!==s&&g.hasValue){var i=g.value;if(s(i,n))return c=i}return c=n}if(i=c,u(e,n))return i;var l=o(n);return void 0!==s&&s(i,l)?i:(e=n,c=l)}var e,c,f=!1,l=void 0===i?null:i;return[function(){return a(n())},null===l?void 0:function(){return a(l())}]},[n,i,o,s]))[0],y[1]);return l(function(){g.hasValue=!0,g.value=m},[m]),v(m),m}},61688:function(e,n,i){"use strict";e.exports=i(53250)},52798:function(e,n,i){"use strict";e.exports=i(50139)},98933:function(e,n,i){"use strict";i.d(n,{Xg:function(){return createDeferredActor},f3:function(){return isSpawnedActor},mu:function(){return createInvocableActor},vk:function(){return toActorRef}});var o=i(63056),s=i(89823),u=i(10797);function createNullActor(e){var n;return(n={id:e,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},getSnapshot:function(){},toJSON:function(){return{id:e}}})[s.L$]=function(){return this},n}function createInvocableActor(e,n,i,o){var u,c=(0,s.j)(e.src),f=null===(u=null==n?void 0:n.options.services)||void 0===u?void 0:u[c.type],l=e.data?(0,s.QX)(e.data,i,o):void 0,d=f?createDeferredActor(f,e.id,l):createNullActor(e.id);return d.meta=e,d}function createDeferredActor(e,n,i){var o=createNullActor(n);if(o.deferred=!0,(0,s.O4)(e)){var c=o.state=(0,u.J)(void 0,function(){return(i?e.withContext(i):e).initialState});o.getSnapshot=function(){return c}}return o}function isActor(e){try{return"function"==typeof e.send}catch(e){return!1}}function isSpawnedActor(e){return isActor(e)&&"id"in e}function toActorRef(e){var n;return(0,o.pi)(((n={subscribe:function(){return{unsubscribe:function(){}}},id:"anonymous",getSnapshot:function(){}})[s.L$]=function(){return this},n),e)}},4723:function(e,n,i){"use strict";i.d(n,{C:function(){return createMachine}});var o=i(63056),s=i(89823),u=i(54911),c=i(3884),f=i(30375),l=i(14066),d=i(87353),v=i(56115),y=i(98933);function toInvokeSource(e){if("string"==typeof e){var n={type:e};return n.toString=function(){return e},n}return e}function toInvokeDefinition(e){return(0,o.pi)((0,o.pi)({type:c.dw},e),{toJSON:function(){e.onDone,e.onError;var n=(0,o._T)(e,["onDone","onError"]);return(0,o.pi)((0,o.pi)({},n),{type:c.dw,src:toInvokeSource(e.src)})}})}var g={},isStateId=function(e){return"#"===e[0]},validateArrayifiedTransitions=function(e,n,i){var o=i.slice(0,-1).some(function(e){return!("cond"in e)&&!("in"in e)&&((0,s.HD)(e.target)||(0,s.O4)(e.target))});(0,s.ZK)(!o,"One or more transitions for ".concat(""===n?"the transient event":"event '".concat(n,"'")," on state '").concat(e.id,"' are unreachable. ")+"Make sure that the default transition is the last one defined.")},m=function(){function StateNode(e,n,i,u){void 0===i&&(i="context"in e?e.context:void 0);var c,y=this;this.config=e,this._context=i,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({actions:{},guards:{},services:{},activities:{},delays:{}},n),this.parent=null==u?void 0:u.parent,this.key=this.config.key||(null==u?void 0:u.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:d.iS),this.id=this.config.id||(0,o.ev)([this.machine.key],(0,o.CR)(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:null!==(c=this.config.schema)&&void 0!==c?c:{},this.description=this.config.description,l.M||(0,s.ZK)(!("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?(0,s.Q8)(this.config.states,function(e,n){var i,s=new StateNode(e,{},void 0,{parent:y,key:n});return Object.assign(y.idMap,(0,o.pi)(((i={})[s.id]=s,i),s.idMap)),s}):g;var m=0;function dfs(e){var n,i;e.order=m++;try{for(var s=(0,o.XA)((0,v.nI)(e)),u=s.next();!u.done;u=s.next()){var c=u.value;dfs(c)}}catch(e){n={error:e}}finally{try{u&&!u.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}}dfs(this),this.history=!0===this.config.history?"shallow":this.config.history||!1,this._transient=!!this.config.always||!!this.config.on&&(Array.isArray(this.config.on)?this.config.on.some(function(e){return""===e.event}):""in this.config.on),this.strict=!!this.config.strict,this.onEntry=(0,s.qo)(this.config.entry||this.config.onEntry).map(function(e){return(0,f.Q8)(e)}),this.onExit=(0,s.qo)(this.config.exit||this.config.onExit).map(function(e){return(0,f.Q8)(e)}),this.meta=this.config.meta,this.doneData="final"===this.type?this.config.data:void 0,this.invoke=(0,s.qo)(this.config.invoke).map(function(e,n){if((0,s.O4)(e)){var i,u,c=(0,s.bx)(y.id,n);return y.machine.options.services=(0,o.pi)(((i={})[c]=e,i),y.machine.options.services),toInvokeDefinition({src:c,id:c})}if((0,s.HD)(e.src)){var c=e.id||(0,s.bx)(y.id,n);return toInvokeDefinition((0,o.pi)((0,o.pi)({},e),{id:c,src:e.src}))}if((0,s.O4)(e.src)||(0,s.mf)(e.src)){var c=e.id||(0,s.bx)(y.id,n);return y.machine.options.services=(0,o.pi)(((u={})[c]=e.src,u),y.machine.options.services),toInvokeDefinition((0,o.pi)((0,o.pi)({id:c},e),{src:c}))}var f=e.src;return toInvokeDefinition((0,o.pi)((0,o.pi)({id:(0,s.bx)(y.id,n)},e),{src:f}))}),this.activities=(0,s.qo)(this.config.activities).concat(this.invoke).map(function(e){return(0,f.XA)(e)}),this.transition=this.transition.bind(this),this.tags=(0,s.qo)(this.config.tags)}return StateNode.prototype._init=function(){this.__cache.transitions||(0,v.ac)(this).forEach(function(e){return e.on})},StateNode.prototype.withConfig=function(e,n){var i=this.options,s=i.actions,u=i.activities,c=i.guards,f=i.services,l=i.delays;return new StateNode(this.config,{actions:(0,o.pi)((0,o.pi)({},s),e.actions),activities:(0,o.pi)((0,o.pi)({},u),e.activities),guards:(0,o.pi)((0,o.pi)({},c),e.guards),services:(0,o.pi)((0,o.pi)({},f),e.services),delays:(0,o.pi)((0,o.pi)({},l),e.delays)},null!=n?n:this.context)},StateNode.prototype.withContext=function(e){return new StateNode(this.config,this.options,e)},Object.defineProperty(StateNode.prototype,"context",{get:function(){return(0,s.mf)(this._context)?this._context():this._context},enumerable:!1,configurable:!0}),Object.defineProperty(StateNode.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:(0,s.Q8)(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}),StateNode.prototype.toJSON=function(){return this.definition},Object.defineProperty(StateNode.prototype,"on",{get:function(){if(this.__cache.on)return this.__cache.on;var e=this.transitions;return this.__cache.on=e.reduce(function(e,n){return e[n.eventType]=e[n.eventType]||[],e[n.eventType].push(n),e},{})},enumerable:!1,configurable:!0}),Object.defineProperty(StateNode.prototype,"after",{get:function(){return this.__cache.delayedTransitions||(this.__cache.delayedTransitions=this.getDelayedTransitions(),this.__cache.delayedTransitions)},enumerable:!1,configurable:!0}),Object.defineProperty(StateNode.prototype,"transitions",{get:function(){return this.__cache.transitions||(this.__cache.transitions=this.formatTransitions(),this.__cache.transitions)},enumerable:!1,configurable:!0}),StateNode.prototype.getCandidates=function(e){if(this.__cache.candidates[e])return this.__cache.candidates[e];var n=""===e,i=this.transitions.filter(function(i){var o=i.eventType===e;return n?o:o||"*"===i.eventType});return this.__cache.candidates[e]=i,i},StateNode.prototype.getDelayedTransitions=function(){var e=this,n=this.config.after;if(!n)return[];var mutateEntryExit=function(n,i){var o=(0,s.mf)(n)?"".concat(e.id,":delay[").concat(i,"]"):n,u=(0,f.e4)(o,e.id);return e.onEntry.push((0,f.lW)(u,{delay:n})),e.onExit.push((0,f.al)(u)),u};return((0,s.kJ)(n)?n.map(function(e,n){var i=mutateEntryExit(e.delay,n);return(0,o.pi)((0,o.pi)({},e),{event:i})}):(0,s.xH)(Object.keys(n).map(function(e,i){var u=n[e],c=(0,s.HD)(u)?{target:u}:u,f=isNaN(+e)?e:+e,l=mutateEntryExit(f,i);return(0,s.qo)(c).map(function(e){return(0,o.pi)((0,o.pi)({},e),{event:l,delay:f})})}))).map(function(n){var i=n.delay;return(0,o.pi)((0,o.pi)({},e.formatTransition(n)),{delay:i})})},StateNode.prototype.getStateNodes=function(e){var n,i=this;if(!e)return[];var c=e instanceof u.ZM?e.value:(0,s.WM)(e,this.delimiter);if((0,s.HD)(c)){var f=this.getStateNode(c).initial;return void 0!==f?this.getStateNodes(((n={})[c]=f,n)):[this,this.states[c]]}var l=Object.keys(c),d=[this];return d.push.apply(d,(0,o.ev)([],(0,o.CR)((0,s.xH)(l.map(function(e){return i.getStateNode(e).getStateNodes(c[e])}))),!1)),d},StateNode.prototype.handles=function(e){var n=(0,s.x6)(e);return this.events.includes(n)},StateNode.prototype.resolveState=function(e){var n=e instanceof u.ZM?e:u.ZM.create(e),i=Array.from((0,v.P_)([],this.getStateNodes(n.value)));return new u.ZM((0,o.pi)((0,o.pi)({},n),{value:this.resolve(n.value),configuration:i,done:(0,v.Ij)(i,this),tags:(0,v.Oe)(i),machine:this.machine}))},StateNode.prototype.transitionLeafNode=function(e,n,i){var o=this.getStateNode(e).next(n,i);return o&&o.transitions.length?o:this.next(n,i)},StateNode.prototype.transitionCompoundNode=function(e,n,i){var o=Object.keys(e),s=this.getStateNode(o[0])._transition(e[o[0]],n,i);return s&&s.transitions.length?s:this.next(n,i)},StateNode.prototype.transitionParallelNode=function(e,n,i){var u,c,f={};try{for(var l=(0,o.XA)(Object.keys(e)),d=l.next();!d.done;d=l.next()){var v=d.value,y=e[v];if(y){var g=this.getStateNode(v)._transition(y,n,i);g&&(f[v]=g)}}}catch(e){u={error:e}}finally{try{d&&!d.done&&(c=l.return)&&c.call(l)}finally{if(u)throw u.error}}var m=Object.keys(f).map(function(e){return f[e]}),b=(0,s.xH)(m.map(function(e){return e.transitions}));if(!m.some(function(e){return e.transitions.length>0}))return this.next(n,i);var S=(0,s.xH)(Object.keys(f).map(function(e){return f[e].configuration}));return{transitions:b,exitSet:(0,s.xH)(m.map(function(e){return e.exitSet})),configuration:S,source:n,actions:(0,s.xH)(Object.keys(f).map(function(e){return f[e].actions}))}},StateNode.prototype._transition=function(e,n,i){return(0,s.HD)(e)?this.transitionLeafNode(e,n,i):1===Object.keys(e).length?this.transitionCompoundNode(e,n,i):this.transitionParallelNode(e,n,i)},StateNode.prototype.getTransitionData=function(e,n){return this._transition(e.value,e,(0,s.g5)(n))},StateNode.prototype.next=function(e,n){var i,u,c,f=this,l=n.name,d=[],v=[];try{for(var y=(0,o.XA)(this.getCandidates(l)),g=y.next();!g.done;g=y.next()){var m=g.value,b=m.cond,S=m.in,w=e.context,x=!S||((0,s.HD)(S)&&isStateId(S)?e.matches((0,s.WM)(this.getStateNodeById(S).path,this.delimiter)):(0,s.W)((0,s.WM)(S,this.delimiter),(0,s.ET)(this.path.slice(0,-2))(e.value))),A=!1;try{A=!b||(0,s.vx)(this.machine,b,w,n,e)}catch(e){throw Error("Unable to evaluate guard '".concat(b.name||b.type,"' in transition for event '").concat(l,"' in state node '").concat(this.id,"':\n").concat(e.message))}if(A&&x){void 0!==m.target&&(v=m.target),d.push.apply(d,(0,o.ev)([],(0,o.CR)(m.actions),!1)),c=m;break}}}catch(e){i={error:e}}finally{try{g&&!g.done&&(u=y.return)&&u.call(y)}finally{if(i)throw i.error}}if(c){if(!v.length)return{transitions:[c],exitSet:[],configuration:e.value?[this]:[],source:e,actions:d};var E=(0,s.xH)(v.map(function(n){return f.getRelativeStateNodes(n,e.historyValue)})),B=!!c.internal;return{transitions:[c],exitSet:B?[]:(0,s.xH)(v.map(function(e){return f.getPotentiallyReenteringNodes(e)})),configuration:E,source:e,actions:d}}},StateNode.prototype.getPotentiallyReenteringNodes=function(e){if(this.order<e.order)return[this];for(var n=[],i=this;i&&i!==e;)n.push(i),i=i.parent;return i!==e?[]:(n.push(e),n)},StateNode.prototype.getActions=function(e,n,i,u,c,l,d){var y,g,m,b,S=this,w=l?(0,v.P_)([],this.getStateNodes(l.value)):[],x=new Set;try{for(var A=(0,o.XA)(Array.from(e).sort(function(e,n){return e.order-n.order})),E=A.next();!E.done;E=A.next()){var B=E.value;(!(0,v.e$)(w,B)||(0,v.e$)(i.exitSet,B)||B.parent&&x.has(B.parent))&&x.add(B)}}catch(e){y={error:e}}finally{try{E&&!E.done&&(g=A.return)&&g.call(A)}finally{if(y)throw y.error}}try{for(var _=(0,o.XA)(w),O=_.next();!O.done;O=_.next()){var B=O.value;(!(0,v.e$)(e,B)||(0,v.e$)(i.exitSet,B.parent))&&i.exitSet.push(B)}}catch(e){m={error:e}}finally{try{O&&!O.done&&(b=_.return)&&b.call(_)}finally{if(m)throw m.error}}i.exitSet.sort(function(e,n){return n.order-e.order});var I=Array.from(x).sort(function(e,n){return e.order-n.order}),k=new Set(i.exitSet),N=(0,s.xH)(I.map(function(e){var n=[];if("final"!==e.type)return n;var o=e.parent;if(!o.parent)return n;n.push((0,f.aT)(e.id,e.doneData),(0,f.aT)(o.id,e.doneData?(0,s.QX)(e.doneData,u,c):void 0));var l=o.parent;return"parallel"===l.type&&(0,v.G)(l).every(function(e){return(0,v.Ij)(i.configuration,e)})&&n.push((0,f.aT)(l.id)),n})),T=I.map(function(e){var n=e.onEntry,i=e.activities.map(function(e){return(0,f.BL)(e)});return{type:"entry",actions:(0,f.AE)(d?(0,o.ev)((0,o.ev)([],(0,o.CR)(n),!1),(0,o.CR)(i),!1):(0,o.ev)((0,o.ev)([],(0,o.CR)(i),!1),(0,o.CR)(n),!1),S.machine.options.actions)}}).concat({type:"state_done",actions:N.map(function(e){return(0,f.OU)(e)})}),C=Array.from(k).map(function(e){return{type:"exit",actions:(0,f.AE)((0,o.ev)((0,o.ev)([],(0,o.CR)(e.onExit),!1),(0,o.CR)(e.activities.map(function(e){return(0,f.sT)(e)})),!1),S.machine.options.actions)}}).concat({type:"transition",actions:(0,f.AE)(i.actions,this.machine.options.actions)}).concat(T);if(n){var M=(0,f.AE)((0,s.xH)((0,o.ev)([],(0,o.CR)(e),!1).sort(function(e,n){return n.order-e.order}).map(function(e){return e.onExit})),this.machine.options.actions).filter(function(e){return!(0,s.vK)(e)});return C.concat({type:"stop",actions:M})}return C},StateNode.prototype.transition=function(e,n,i,c){void 0===e&&(e=this.initialState);var f,d=(0,s.g5)(n);if(e instanceof u.ZM)f=void 0===i?e:this.resolveState(u.ZM.from(e,i));else{var y=(0,s.HD)(e)?this.resolve((0,s.on)(this.getResolvedPath(e))):this.resolve(e),g=null!=i?i:this.machine.context;f=this.resolveState(u.ZM.from(y,g))}if(!l.M&&"*"===d.name)throw Error("An event cannot have the wildcard type ('".concat("*","')"));if(this.strict&&!this.events.includes(d.name)&&!(0,s.JQ)(d.name))throw Error("Machine '".concat(this.id,"' does not accept event '").concat(d.name,"'"));var m=this._transition(f.value,f,d)||{transitions:[],configuration:[],exitSet:[],source:f,actions:[]},b=(0,v.P_)([],this.getStateNodes(f.value)),S=m.configuration.length?(0,v.P_)(b,m.configuration):b;return m.configuration=(0,o.ev)([],(0,o.CR)(S),!1),this.resolveTransition(m,f,f.context,c,d)},StateNode.prototype.resolveRaisedTransition=function(e,n,i,s){var u,c=e.actions;return(e=this.transition(e,n,void 0,s))._event=i,e.event=i.data,(u=e.actions).unshift.apply(u,(0,o.ev)([],(0,o.CR)(c),!1)),e},StateNode.prototype.resolveTransition=function(e,n,i,l,d){var g,m,b,S,w=this;void 0===d&&(d=f.bf);var x=e.configuration,A=!n||e.transitions.length>0,E=A?e.configuration:n?n.configuration:[],B=(0,v.Ij)(E,this),_=A?(0,v.NA)(this.machine,x):void 0,O=n?n.historyValue?n.historyValue:e.source?this.machine.historyValue(n.value):void 0:void 0,I=this.getActions(new Set(E),B,e,i,d,n,l),k=n?(0,o.pi)({},n.activities):{};try{for(var N=(0,o.XA)(I),T=N.next();!T.done;T=N.next()){var C=T.value;try{for(var M=(b=void 0,(0,o.XA)(C.actions)),j=M.next();!j.done;j=M.next()){var L=j.value;L.type===c.BL?k[L.activity.id||L.activity.type]=L:L.type===c.sT&&(k[L.activity.id||L.activity.type]=!1)}}catch(e){b={error:e}}finally{try{j&&!j.done&&(S=M.return)&&S.call(M)}finally{if(b)throw b.error}}}}catch(e){g={error:e}}finally{try{T&&!T.done&&(m=N.return)&&m.call(N)}finally{if(g)throw g.error}}var R=(0,o.CR)((0,f.yC)(this,n,i,d,I,l,this.machine.config.predictableActionArguments||this.machine.config.preserveActionOrder),2),U=R[0],P=R[1],D=(0,o.CR)((0,s.uK)(U,s.vK),2),V=D[0],H=D[1],X=U.filter(function(e){var n;return e.type===c.BL&&(null===(n=e.activity)||void 0===n?void 0:n.type)===c.dw}).reduce(function(e,n){return e[n.activity.id]=(0,y.mu)(n.activity,w.machine,P,d),e},n?(0,o.pi)({},n.children):{}),F=new u.ZM({value:_||n.value,context:P,_event:d,_sessionid:n?n._sessionid:null,historyValue:_?O?(0,s.yv)(O,_):void 0:n?n.historyValue:void 0,history:!_||e.source?n:void 0,actions:_?H:[],activities:_?k:n?n.activities:{},events:[],configuration:E,transitions:e.transitions,children:X,done:B,tags:(0,v.Oe)(E),machine:this}),z=i!==P;F.changed=d.name===c.Vx||z;var Z=F.history;Z&&delete Z.history;var W=!B&&(this._transient||x.some(function(e){return e._transient}));if(!A&&(!W||""===d.name))return F;var J=F;if(!B)for(W&&(J=this.resolveRaisedTransition(J,{type:c.IA},d,l));V.length;){var K=V.shift();J=this.resolveRaisedTransition(J,K._event,d,l)}var Q=J.changed||(Z?!!J.actions.length||z||typeof Z.value!=typeof J.value||!(0,u.j_)(J.value,Z.value):void 0);return J.changed=Q,J.history=Z,J},StateNode.prototype.getStateNode=function(e){if(isStateId(e))return this.machine.getStateNodeById(e);if(!this.states)throw Error("Unable to retrieve child state '".concat(e,"' from '").concat(this.id,"'; no child states exist."));var n=this.states[e];if(!n)throw Error("Child state '".concat(e,"' does not exist on '").concat(this.id,"'"));return n},StateNode.prototype.getStateNodeById=function(e){var n=isStateId(e)?e.slice(1):e;if(n===this.id)return this;var i=this.machine.idMap[n];if(!i)throw Error("Child state node '#".concat(n,"' does not exist on machine '").concat(this.id,"'"));return i},StateNode.prototype.getStateNodeByPath=function(e){if("string"==typeof e&&isStateId(e))try{return this.getStateNodeById(e.slice(1))}catch(e){}for(var n=(0,s.Q9)(e,this.delimiter).slice(),i=this;n.length;){var o=n.shift();if(!o.length)break;i=i.getStateNode(o)}return i},StateNode.prototype.resolve=function(e){var n,i=this;if(!e)return this.initialStateValue||g;switch(this.type){case"parallel":return(0,s.Q8)(this.initialStateValue,function(n,o){return n?i.getStateNode(o).resolve(e[o]||n):g});case"compound":if((0,s.HD)(e)){var o=this.getStateNode(e);if("parallel"===o.type||"compound"===o.type)return(n={})[e]=o.initialStateValue,n;return e}if(!Object.keys(e).length)return this.initialStateValue||{};return(0,s.Q8)(e,function(e,n){return e?i.getStateNode(n).resolve(e):g});default:return e||g}},StateNode.prototype.getResolvedPath=function(e){if(isStateId(e)){var n=this.machine.idMap[e.slice(1)];if(!n)throw Error("Unable to find state node '".concat(e,"'"));return n.path}return(0,s.Q9)(e,this.delimiter)},Object.defineProperty(StateNode.prototype,"initialStateValue",{get:function(){var e,n;if(this.__cache.initialStateValue)return this.__cache.initialStateValue;if("parallel"===this.type)n=(0,s.ib)(this.states,function(e){return e.initialStateValue||g},function(e){return"history"!==e.type});else if(void 0!==this.initial){if(!this.states[this.initial])throw Error("Initial state '".concat(this.initial,"' not found on '").concat(this.key,"'"));n=(0,v.N9)(this.states[this.initial])?this.initial:((e={})[this.initial]=this.states[this.initial].initialStateValue,e)}else n={};return this.__cache.initialStateValue=n,this.__cache.initialStateValue},enumerable:!1,configurable:!0}),StateNode.prototype.getInitialState=function(e,n){this._init();var i=this.getStateNodes(e);return this.resolveTransition({configuration:i,exitSet:[],transitions:[],source:void 0,actions:[]},void 0,null!=n?n:this.machine.context,void 0)},Object.defineProperty(StateNode.prototype,"initialState",{get:function(){var e=this.initialStateValue;if(!e)throw Error("Cannot retrieve initial state from simple state '".concat(this.id,"'."));return this.getInitialState(e)},enumerable:!1,configurable:!0}),Object.defineProperty(StateNode.prototype,"target",{get:function(){var e;if("history"===this.type){var n=this.config;e=(0,s.HD)(n.target)&&isStateId(n.target)?(0,s.on)(this.machine.getStateNodeById(n.target).path.slice(this.path.length-1)):n.target}return e},enumerable:!1,configurable:!0}),StateNode.prototype.getRelativeStateNodes=function(e,n,i){return void 0===i&&(i=!0),i?"history"===e.type?e.resolveHistory(n):e.initialStateNodes:[e]},Object.defineProperty(StateNode.prototype,"initialStateNodes",{get:function(){var e=this;if((0,v.N9)(this))return[this];if("compound"===this.type&&!this.initial)return l.M||(0,s.ZK)(!1,"Compound state node '".concat(this.id,"' has no initial state.")),[this];var n=(0,s.SA)(this.initialStateValue);return(0,s.xH)(n.map(function(n){return e.getFromRelativePath(n)}))},enumerable:!1,configurable:!0}),StateNode.prototype.getFromRelativePath=function(e){if(!e.length)return[this];var n=(0,o.CR)(e),i=n[0],s=n.slice(1);if(!this.states)throw Error("Cannot retrieve subPath '".concat(i,"' from node with no states"));var u=this.getStateNode(i);if("history"===u.type)return u.resolveHistory();if(!this.states[i])throw Error("Child state '".concat(i,"' does not exist on '").concat(this.id,"'"));return this.states[i].getFromRelativePath(s)},StateNode.prototype.historyValue=function(e){if(Object.keys(this.states).length)return{current:e||this.initialStateValue,states:(0,s.ib)(this.states,function(n,i){if(!e)return n.historyValue();var o=(0,s.HD)(e)?void 0:e[i];return n.historyValue(o||n.initialStateValue)},function(e){return!e.history})}},StateNode.prototype.resolveHistory=function(e){var n=this;if("history"!==this.type)return[this];var i=this.parent;if(!e){var o=this.target;return o?(0,s.xH)((0,s.SA)(o).map(function(e){return i.getFromRelativePath(e)})):i.initialStateNodes}var u=(0,s.gk)(i.path,"states")(e).current;return(0,s.HD)(u)?[i.getStateNode(u)]:(0,s.xH)((0,s.SA)(u).map(function(e){return"deep"===n.history?i.getFromRelativePath(e):[i.states[e[0]]]}))},Object.defineProperty(StateNode.prototype,"stateIds",{get:function(){var e=this,n=(0,s.xH)(Object.keys(this.states).map(function(n){return e.states[n].stateIds}));return[this.id].concat(n)},enumerable:!1,configurable:!0}),Object.defineProperty(StateNode.prototype,"events",{get:function(){if(this.__cache.events)return this.__cache.events;var e,n,i,s,u=this.states,c=new Set(this.ownEvents);if(u)try{for(var f=(0,o.XA)(Object.keys(u)),l=f.next();!l.done;l=f.next()){var d=u[l.value];if(d.states)try{for(var v=(i=void 0,(0,o.XA)(d.events)),y=v.next();!y.done;y=v.next()){var g=y.value;c.add("".concat(g))}}catch(e){i={error:e}}finally{try{y&&!y.done&&(s=v.return)&&s.call(v)}finally{if(i)throw i.error}}}}catch(n){e={error:n}}finally{try{l&&!l.done&&(n=f.return)&&n.call(f)}finally{if(e)throw e.error}}return this.__cache.events=Array.from(c)},enumerable:!1,configurable:!0}),Object.defineProperty(StateNode.prototype,"ownEvents",{get:function(){return Array.from(new Set(this.transitions.filter(function(e){return!(!e.target&&!e.actions.length&&e.internal)}).map(function(e){return e.eventType})))},enumerable:!1,configurable:!0}),StateNode.prototype.resolveTarget=function(e){var n=this;if(void 0!==e)return e.map(function(e){if(!(0,s.HD)(e))return e;var i=e[0]===n.delimiter;if(i&&!n.parent)return n.getStateNodeByPath(e.slice(1));var o=i?n.key+e:e;if(!n.parent)return n.getStateNodeByPath(o);try{return n.parent.getStateNodeByPath(o)}catch(e){throw Error("Invalid transition definition for state node '".concat(n.id,"':\n").concat(e.message))}})},StateNode.prototype.formatTransition=function(e){var n=this,i=(0,s.rg)(e.target),u="internal"in e?e.internal:!i||i.some(function(e){return(0,s.HD)(e)&&e[0]===n.delimiter}),c=this.machine.options.guards,l=this.resolveTarget(i),d=(0,o.pi)((0,o.pi)({},e),{actions:(0,f.AE)((0,s.qo)(e.actions)),cond:(0,s.Qi)(e.cond,c),target:l,source:this,internal:u,eventType:e.event,toJSON:function(){return(0,o.pi)((0,o.pi)({},d),{target:d.target?d.target.map(function(e){return"#".concat(e.id)}):void 0,source:"#".concat(n.id)})}});return d},StateNode.prototype.formatTransitions=function(){var e,n,i,u=this;if(this.config.on){if(Array.isArray(this.config.on))i=this.config.on;else{var c=this.config.on,d=c["*"],v=void 0===d?[]:d,y=(0,o._T)(c,["*"]);i=(0,s.xH)(Object.keys(y).map(function(e){l.M||""!==e||(0,s.ZK)(!1,"Empty string transition configs (e.g., `{ on: { '': ... }}`) for transient transitions are deprecated. Specify the transition in the `{ always: ... }` property instead. "+'Please check the `on` configuration for "#'.concat(u.id,'".'));var n=(0,s.jh)(e,y[e]);return l.M||validateArrayifiedTransitions(u,e,n),n}).concat((0,s.jh)("*",v)))}}else i=[];var g=this.config.always?(0,s.jh)("",this.config.always):[],m=this.config.onDone?(0,s.jh)(String((0,f.aT)(this.id)),this.config.onDone):[];l.M||(0,s.ZK)(!(this.config.onDone&&!this.parent),'Root nodes cannot have an ".onDone" transition. Please check the config of "'.concat(this.id,'".'));var b=(0,s.xH)(this.invoke.map(function(e){var n=[];return e.onDone&&n.push.apply(n,(0,o.ev)([],(0,o.CR)((0,s.jh)(String((0,f.Sl)(e.id)),e.onDone)),!1)),e.onError&&n.push.apply(n,(0,o.ev)([],(0,o.CR)((0,s.jh)(String((0,f.vU)(e.id)),e.onError)),!1)),n})),S=this.after,w=(0,s.xH)((0,o.ev)((0,o.ev)((0,o.ev)((0,o.ev)([],(0,o.CR)(m),!1),(0,o.CR)(b),!1),(0,o.CR)(i),!1),(0,o.CR)(g),!1).map(function(e){return(0,s.qo)(e).map(function(e){return u.formatTransition(e)})}));try{for(var x=(0,o.XA)(S),A=x.next();!A.done;A=x.next()){var E=A.value;w.push(E)}}catch(n){e={error:n}}finally{try{A&&!A.done&&(n=x.return)&&n.call(x)}finally{if(e)throw e.error}}return w},StateNode}(),b=!1;function createMachine(e,n){return l.M||"predictableActionArguments"in e||b||(b=!0,console.warn("It is highly recommended to set `predictableActionArguments` to `true` when using `createMachine`. https://xstate.js.org/docs/guides/actions.html")),new m(e,n)}},54911:function(e,n,i){"use strict";i.d(n,{TL:function(){return isStateConfig},ZM:function(){return d},j1:function(){return bindActionToState},j_:function(){return stateValuesEqual}});var o=i(63056),s=i(87353),u=i(89823),c=i(56115),f=i(30375),l=i(14066);function stateValuesEqual(e,n){if(e===n)return!0;if(void 0===e||void 0===n)return!1;if((0,u.HD)(e)||(0,u.HD)(n))return e===n;var i=Object.keys(e),o=Object.keys(n);return i.length===o.length&&i.every(function(i){return stateValuesEqual(e[i],n[i])})}function isStateConfig(e){return"object"==typeof e&&null!==e&&"value"in e&&"_event"in e}function bindActionToState(e,n){var i=e.exec;return(0,o.pi)((0,o.pi)({},e),{exec:void 0!==i?function(){return i(n.context,n.event,{action:e,state:n,_event:n._event})}:void 0})}var d=function(){function State(e){var n,i=this;this.actions=[],this.activities=s.qP,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||s.qP,this.meta=(0,c.xZ)(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=null!==(n=Array.isArray(e.tags)?new Set(e.tags):e.tags)&&void 0!==n?n:new Set,this.machine=e.machine,Object.defineProperty(this,"nextEvents",{get:function(){return(0,c.nJ)(i.configuration)}})}return State.from=function(e,n){return e instanceof State?e.context!==n?new State({value:e.value,context:n,_event:e._event,_sessionid:null,historyValue:e.historyValue,history:e.history,actions:[],activities:e.activities,meta:{},events:[],configuration:[],transitions:[],children:{}}):e:new State({value:e,context:n,_event:f.bf,_sessionid:null,historyValue:void 0,history:void 0,actions:[],activities:void 0,meta:void 0,events:[],configuration:[],transitions:[],children:{}})},State.create=function(e){return new State(e)},State.inert=function(e,n){if(e instanceof State){if(!e.actions.length)return e;var i=f.bf;return new State({value:e.value,context:n,_event:i,_sessionid:null,historyValue:e.historyValue,history:e.history,activities:e.activities,configuration:e.configuration,transitions:[],children:{}})}return State.from(e,n)},State.prototype.toStrings=function(e,n){var i=this;if(void 0===e&&(e=this.value),void 0===n&&(n="."),(0,u.HD)(e))return[e];var s=Object.keys(e);return s.concat.apply(s,(0,o.ev)([],(0,o.CR)(s.map(function(o){return i.toStrings(e[o],n).map(function(e){return o+n+e})})),!1))},State.prototype.toJSON=function(){this.configuration,this.transitions;var e=this.tags;this.machine;var n=(0,o._T)(this,["configuration","transitions","tags","machine"]);return(0,o.pi)((0,o.pi)({},n),{tags:Array.from(e)})},State.prototype.matches=function(e){return(0,u.W)(e,this.value)},State.prototype.hasTag=function(e){return this.tags.has(e)},State.prototype.can=function(e){l.M&&(0,u.ZK)(!!this.machine,"state.can(...) used outside of a machine-created State object; this will always return false.");var n,i=null===(n=this.machine)||void 0===n?void 0:n.getTransitionData(this,e);return!!(null==i?void 0:i.transitions.length)&&i.transitions.some(function(e){return void 0!==e.target||e.actions.length})},State}()},63056:function(e,n,i){"use strict";i.d(n,{CR:function(){return __read},XA:function(){return __values},_T:function(){return __rest},ev:function(){return __spreadArray},pi:function(){return __assign}});/*! *****************************************************************************
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 __assign=function(){return(__assign=Object.assign||function(e){for(var n,i=1,o=arguments.length;i<o;i++)for(var s in n=arguments[i])Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s]);return e}).apply(this,arguments)};function __rest(e,n){var i={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&0>n.indexOf(o)&&(i[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var s=0,o=Object.getOwnPropertySymbols(e);s<o.length;s++)0>n.indexOf(o[s])&&Object.prototype.propertyIsEnumerable.call(e,o[s])&&(i[o[s]]=e[o[s]]);return i}function __values(e){var n="function"==typeof Symbol&&Symbol.iterator,i=n&&e[n],o=0;if(i)return i.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function __read(e,n){var i="function"==typeof Symbol&&e[Symbol.iterator];if(!i)return e;var o,s,u=i.call(e),c=[];try{for(;(void 0===n||n-- >0)&&!(o=u.next()).done;)c.push(o.value)}catch(e){s={error:e}}finally{try{o&&!o.done&&(i=u.return)&&i.call(u)}finally{if(s)throw s.error}}return c}function __spreadArray(e,n,i){if(i||2==arguments.length)for(var o,s=0,u=n.length;s<u;s++)!o&&s in n||(o||(o=Array.prototype.slice.call(n,0,s)),o[s]=n[s]);return e.concat(o||Array.prototype.slice.call(n))}},3884:function(e,n,i){"use strict";i.d(n,{BL:function(){return s},IA:function(){return d},Le:function(){return A},Mg:function(){return b},OU:function(){return c},RN:function(){return x},S1:function(){return g},Vx:function(){return w},al:function(){return l},cM:function(){return y},dw:function(){return m},f0:function(){return v},lW:function(){return f},sT:function(){return u},vU:function(){return S}});var o=i(59043),s=o.M.Start,u=o.M.Stop,c=o.M.Raise,f=o.M.Send,l=o.M.Cancel,d=o.M.NullEvent,v=o.M.Assign;o.M.After,o.M.DoneState;var y=o.M.Log,g=o.M.Init,m=o.M.Invoke;o.M.ErrorExecution;var b=o.M.ErrorPlatform,S=o.M.ErrorCustom,w=o.M.Update,x=o.M.Choose,A=o.M.Pure},30375:function(e,n,i){"use strict";i.d(n,{AE:function(){return toActionObjects},BL:function(){return start},OU:function(){return raise},Q8:function(){return toActionObject},Sl:function(){return doneInvoke},XA:function(){return toActivityDefinition},aT:function(){return done},al:function(){return cancel},bf:function(){return l},e4:function(){return after},lW:function(){return send},o$:function(){return getActionFunction},sT:function(){return stop},vU:function(){return error},yC:function(){return resolveActions}});var o=i(63056),s=i(59043),u=i(3884),c=i(89823),f=i(14066),l=(0,c.g5)({type:u.S1});function getActionFunction(e,n){return n&&n[e]||void 0}function toActionObject(e,n){var i;if((0,c.HD)(e)||"number"==typeof e){var s=getActionFunction(e,n);i=(0,c.mf)(s)?{type:e,exec:s}:s||{type:e,exec:void 0}}else if((0,c.mf)(e))i={type:e.name||e.toString(),exec:e};else{var s=getActionFunction(e.type,n);if((0,c.mf)(s))i=(0,o.pi)((0,o.pi)({},e),{exec:s});else if(s){var u=s.type||e.type;i=(0,o.pi)((0,o.pi)((0,o.pi)({},s),e),{type:u})}else i=e}return i}var toActionObjects=function(e,n){return e?((0,c.kJ)(e)?e:[e]).map(function(e){return toActionObject(e,n)}):[]};function toActivityDefinition(e){var n=toActionObject(e);return(0,o.pi)((0,o.pi)({id:(0,c.HD)(e)?e:n.id},n),{type:n.type})}function raise(e,n){return{type:u.OU,event:"function"==typeof e?e:(0,c._v)(e),delay:n?n.delay:void 0,id:null==n?void 0:n.id}}function resolveRaise(e,n,i,s){var f,l={_event:i},d=(0,c.g5)((0,c.mf)(e.event)?e.event(n,i.data,l):e.event);if((0,c.HD)(e.delay)){var v=s&&s[e.delay];f=(0,c.mf)(v)?v(n,i.data,l):v}else f=(0,c.mf)(e.delay)?e.delay(n,i.data,l):e.delay;return(0,o.pi)((0,o.pi)({},e),{type:u.OU,_event:d,delay:f})}function send(e,n){return{to:n?n.to:void 0,type:u.lW,event:(0,c.mf)(e)?e:(0,c._v)(e),delay:n?n.delay:void 0,id:n&&void 0!==n.id?n.id:(0,c.mf)(e)?e.name:(0,c.x6)(e)}}function resolveSend(e,n,i,s){var u,f={_event:i},l=(0,c.g5)((0,c.mf)(e.event)?e.event(n,i.data,f):e.event);if((0,c.HD)(e.delay)){var d=s&&s[e.delay];u=(0,c.mf)(d)?d(n,i.data,f):d}else u=(0,c.mf)(e.delay)?e.delay(n,i.data,f):e.delay;var v=(0,c.mf)(e.to)?e.to(n,i.data,f):e.to;return(0,o.pi)((0,o.pi)({},e),{to:v,_event:l,event:l.data,delay:u})}var cancel=function(e){return{type:u.al,sendId:e}};function start(e){var n=toActivityDefinition(e);return{type:s.M.Start,activity:n,exec:void 0}}function stop(e){var n=(0,c.mf)(e)?e:toActivityDefinition(e);return{type:s.M.Stop,activity:n,exec:void 0}}function resolveStop(e,n,i){var o=(0,c.mf)(e.activity)?e.activity(n,i.data):e.activity;return{type:s.M.Stop,activity:"string"==typeof o?{id:o}:o}}function after(e,n){var i=n?"#".concat(n):"";return"".concat(s.M.After,"(").concat(e,")").concat(i)}function done(e,n){var i="".concat(s.M.DoneState,".").concat(e),o={type:i,data:n};return o.toString=function(){return i},o}function doneInvoke(e,n){var i="".concat(s.M.DoneInvoke,".").concat(e),o={type:i,data:n};return o.toString=function(){return i},o}function error(e,n){var i="".concat(s.M.ErrorPlatform,".").concat(e),o={type:i,data:n};return o.toString=function(){return i},o}var pluckAssigns=function(e){var n,i,s=[];try{for(var c=(0,o.XA)(e),f=c.next();!f.done;f=c.next())for(var l=f.value,d=0;d<l.actions.length;){if(l.actions[d].type===u.f0){s.push(l.actions[d]),l.actions.splice(d,1);continue}d++}}catch(e){n={error:e}}finally{try{f&&!f.done&&(i=c.return)&&i.call(c)}finally{if(n)throw n.error}}return s};function resolveActions(e,n,i,l,d,v,y){void 0===y&&(y=!1);var g=y?[]:pluckAssigns(d),m=g.length?(0,c.dt)(i,l,g,n):i,b=y?[i]:void 0,S=[];function handleAction(d,g){var w;switch(g.type){case u.OU:var x=resolveRaise(g,m,l,e.options.delays);return v&&"number"==typeof x.delay&&v(x,m,l),x;case u.lW:var A=resolveSend(g,m,l,e.options.delays);if(!f.M){var E=g.delay;(0,c.ZK)(!(0,c.HD)(E)||"number"==typeof A.delay,"No delay reference for delay expression '".concat(E,"' was found on machine '").concat(e.id,"'"))}return v&&A.to!==s.K.Internal&&("entry"===d?S.push(A):v(A,m,l)),A;case u.cM:var B,_=(B=m,(0,o.pi)((0,o.pi)({},g),{value:(0,c.HD)(g.expr)?g.expr:g.expr(B,l.data,{_event:l})}));return null==v||v(_,m,l),_;case u.RN:var O=null===(w=g.conds.find(function(i){var o=(0,c.Qi)(i.cond,e.options.guards);return!o||(0,c.vx)(e,o,m,l,v?void 0:n)}))||void 0===w?void 0:w.actions;if(!O)return[];var I=(0,o.CR)(resolveActions(e,n,m,l,[{type:d,actions:toActionObjects((0,c.qo)(O),e.options.actions)}],v,y),2),k=I[0];return m=I[1],null==b||b.push(m),k;case u.Le:var O=g.get(m,l.data);if(!O)return[];var N=(0,o.CR)(resolveActions(e,n,m,l,[{type:d,actions:toActionObjects((0,c.qo)(O),e.options.actions)}],v,y),2),T=N[0];return m=N[1],null==b||b.push(m),T;case u.sT:var _=resolveStop(g,m,l);return null==v||v(_,i,l),_;case u.f0:m=(0,c.dt)(m,l,[g],v?void 0:n),null==b||b.push(m);break;default:var C=toActionObject(g,e.options.actions),M=C.exec;if(v)v(C,m,l);else if(M&&b){var j=b.length-1;C=(0,o.pi)((0,o.pi)({},C),{exec:function(e){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];M.apply(void 0,(0,o.ev)([b[j]],(0,o.CR)(n),!1))}})}return C}}function processBlock(e){var n,i,s=[];try{for(var u=(0,o.XA)(e.actions),c=u.next();!c.done;c=u.next()){var f=c.value,d=handleAction(e.type,f);d&&(s=s.concat(d))}}catch(e){n={error:e}}finally{try{c&&!c.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}return S.forEach(function(e){v(e,m,l)}),S.length=0,s}return[(0,c.xH)(d.map(processBlock)),m]}},87353:function(e,n,i){"use strict";i.d(n,{TV:function(){return u},iS:function(){return o},qP:function(){return s},rt:function(){return c}});var o=".",s={},u="xstate.guard",c=""},14066:function(e,n,i){"use strict";i.d(n,{M:function(){return o}});var o=!0},10797:function(e,n,i){"use strict";i.d(n,{J:function(){return provide}});var o=[],provide=function(e,n){o.push(e);var i=n(e);return o.pop(),i}},56115:function(e,n,i){"use strict";i.d(n,{G:function(){return getChildren},Ij:function(){return isInFinalState},N9:function(){return isLeafNode},NA:function(){return getValue},Oe:function(){return getTagsFromConfiguration},P_:function(){return getConfiguration},ac:function(){return getAllStateNodes},e$:function(){return has},nI:function(){return getAllChildren},nJ:function(){return nextEvents},xZ:function(){return getMeta}});var o=i(63056),s=i(89823),isLeafNode=function(e){return"atomic"===e.type||"final"===e.type};function getAllChildren(e){return Object.keys(e.states).map(function(n){return e.states[n]})}function getChildren(e){return getAllChildren(e).filter(function(e){return"history"!==e.type})}function getAllStateNodes(e){var n=[e];return isLeafNode(e)?n:n.concat((0,s.xH)(getChildren(e).map(getAllStateNodes)))}function getConfiguration(e,n){var i,s,u,c,f,l,d,v,y=getAdjList(new Set(e)),g=new Set(n);try{for(var m=(0,o.XA)(g),b=m.next();!b.done;b=m.next())for(var S=b.value,w=S.parent;w&&!g.has(w);)g.add(w),w=w.parent}catch(e){i={error:e}}finally{try{b&&!b.done&&(s=m.return)&&s.call(m)}finally{if(i)throw i.error}}var x=getAdjList(g);try{for(var A=(0,o.XA)(g),E=A.next();!E.done;E=A.next()){var S=E.value;if("compound"!==S.type||x.get(S)&&x.get(S).length){if("parallel"===S.type)try{for(var B=(f=void 0,(0,o.XA)(getChildren(S))),_=B.next();!_.done;_=B.next()){var O=_.value;g.has(O)||(g.add(O),y.get(O)?y.get(O).forEach(function(e){return g.add(e)}):O.initialStateNodes.forEach(function(e){return g.add(e)}))}}catch(e){f={error:e}}finally{try{_&&!_.done&&(l=B.return)&&l.call(B)}finally{if(f)throw f.error}}}else y.get(S)?y.get(S).forEach(function(e){return g.add(e)}):S.initialStateNodes.forEach(function(e){return g.add(e)})}}catch(e){u={error:e}}finally{try{E&&!E.done&&(c=A.return)&&c.call(A)}finally{if(u)throw u.error}}try{for(var I=(0,o.XA)(g),k=I.next();!k.done;k=I.next())for(var S=k.value,w=S.parent;w&&!g.has(w);)g.add(w),w=w.parent}catch(e){d={error:e}}finally{try{k&&!k.done&&(v=I.return)&&v.call(I)}finally{if(d)throw d.error}}return g}function getValueFromAdj(e,n){var i=n.get(e);if(!i)return{};if("compound"===e.type){var o=i[0];if(!o)return{};if(isLeafNode(o))return o.key}var s={};return i.forEach(function(e){s[e.key]=getValueFromAdj(e,n)}),s}function getAdjList(e){var n,i,s=new Map;try{for(var u=(0,o.XA)(e),c=u.next();!c.done;c=u.next()){var f=c.value;s.has(f)||s.set(f,[]),f.parent&&(s.has(f.parent)||s.set(f.parent,[]),s.get(f.parent).push(f))}}catch(e){n={error:e}}finally{try{c&&!c.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}return s}function getValue(e,n){var i=getConfiguration([e],n);return getValueFromAdj(e,getAdjList(i))}function has(e,n){return Array.isArray(e)?e.some(function(e){return e===n}):e instanceof Set&&e.has(n)}function nextEvents(e){return(0,o.ev)([],(0,o.CR)(new Set((0,s.xH)((0,o.ev)([],(0,o.CR)(e.map(function(e){return e.ownEvents})),!1)))),!1)}function isInFinalState(e,n){return"compound"===n.type?getChildren(n).some(function(n){return"final"===n.type&&has(e,n)}):"parallel"===n.type&&getChildren(n).every(function(n){return isInFinalState(e,n)})}function getMeta(e){return void 0===e&&(e=[]),e.reduce(function(e,n){return void 0!==n.meta&&(e[n.id]=n.meta),e},{})}function getTagsFromConfiguration(e){return new Set((0,s.xH)(e.map(function(e){return e.tags})))}},59043:function(e,n,i){"use strict";var o,s,u,c;i.d(n,{K:function(){return s},M:function(){return o}}),(u=o||(o={})).Start="xstate.start",u.Stop="xstate.stop",u.Raise="xstate.raise",u.Send="xstate.send",u.Cancel="xstate.cancel",u.NullEvent="",u.Assign="xstate.assign",u.After="xstate.after",u.DoneState="done.state",u.DoneInvoke="done.invoke",u.Log="xstate.log",u.Init="xstate.init",u.Invoke="xstate.invoke",u.ErrorExecution="error.execution",u.ErrorCommunication="error.communication",u.ErrorPlatform="error.platform",u.ErrorCustom="xstate.error",u.Update="xstate.update",u.Pure="xstate.pure",u.Choose="xstate.choose",(c=s||(s={})).Parent="#_parent",c.Internal="#_internal"},89823:function(e,n,i){"use strict";i.d(n,{Bc:function(){return isActor},ET:function(){return path},HD:function(){return isString},HV:function(){return isBehavior},JQ:function(){return isBuiltInEvent},L$:function(){return d},O4:function(){return isMachine},Q8:function(){return mapValues},Q9:function(){return toStatePath},QX:function(){return mapContext},Qi:function(){return toGuard},SA:function(){return toStatePaths},W:function(){return matchesState},WM:function(){return toStateValue},ZK:function(){return warn},_v:function(){return toEventObject},bi:function(){return isObservable},bx:function(){return createInvokeId},dt:function(){return updateContext},g5:function(){return toSCXMLEvent},gk:function(){return nestedPath},ib:function(){return mapFilterValues},j:function(){return toInvokeSource},jh:function(){return toTransitionConfigArray},kJ:function(){return isArray},mf:function(){return isFunction},on:function(){return pathToStateValue},qo:function(){return toArray},rg:function(){return normalizeTarget},uK:function(){return partition},v4:function(){return reportUnhandledExceptionOnInvocation},vK:function(){return isRaisableAction},vx:function(){return evaluateGuard},x6:function(){return getEventType},xH:function(){return flatten},y8:function(){return isPromiseLike},yv:function(){return updateHistoryValue},zM:function(){return toObserver}});var o,s=i(63056),u=i(59043),c=i(3884),f=i(87353),l=i(14066);function matchesState(e,n,i){void 0===i&&(i=f.iS);var o=toStateValue(e,i),s=toStateValue(n,i);return isString(s)?!!isString(o)&&s===o:isString(o)?o in s:Object.keys(o).every(function(e){return e in s&&matchesState(o[e],s[e])})}function getEventType(e){try{return isString(e)||"number"==typeof e?"".concat(e):e.type}catch(e){throw Error("Events must be strings or objects with a string event.type property.")}}function toStatePath(e,n){try{if(isArray(e))return e;return e.toString().split(n)}catch(n){throw Error("'".concat(e,"' is not a valid state path."))}}function isStateLike(e){return"object"==typeof e&&"value"in e&&"context"in e&&"event"in e&&"_event"in e}function toStateValue(e,n){return isStateLike(e)?e.value:isArray(e)?pathToStateValue(e):"string"!=typeof e?e:pathToStateValue(toStatePath(e,n))}function pathToStateValue(e){if(1===e.length)return e[0];for(var n={},i=n,o=0;o<e.length-1;o++)o===e.length-2?i[e[o]]=e[o+1]:(i[e[o]]={},i=i[e[o]]);return n}function mapValues(e,n){for(var i={},o=Object.keys(e),s=0;s<o.length;s++){var u=o[s];i[u]=n(e[u],u,e,s)}return i}function mapFilterValues(e,n,i){var o,u,c={};try{for(var f=(0,s.XA)(Object.keys(e)),l=f.next();!l.done;l=f.next()){var d=l.value,v=e[d];i(v)&&(c[d]=n(v,d,e))}}catch(e){o={error:e}}finally{try{l&&!l.done&&(u=f.return)&&u.call(f)}finally{if(o)throw o.error}}return c}var path=function(e){return function(n){var i,o,u=n;try{for(var c=(0,s.XA)(e),f=c.next();!f.done;f=c.next())u=u[f.value]}catch(e){i={error:e}}finally{try{f&&!f.done&&(o=c.return)&&o.call(c)}finally{if(i)throw i.error}}return u}};function nestedPath(e,n){return function(i){var o,u,c=i;try{for(var f=(0,s.XA)(e),l=f.next();!l.done;l=f.next()){var d=l.value;c=c[n][d]}}catch(e){o={error:e}}finally{try{l&&!l.done&&(u=f.return)&&u.call(f)}finally{if(o)throw o.error}}return c}}function toStatePaths(e){return e?isString(e)?[[e]]:flatten(Object.keys(e).map(function(n){var i=e[n];return"string"==typeof i||i&&Object.keys(i).length?toStatePaths(e[n]).map(function(e){return[n].concat(e)}):[[n]]})):[[]]}function flatten(e){var n;return(n=[]).concat.apply(n,(0,s.ev)([],(0,s.CR)(e),!1))}function toArray(e){return void 0===e?[]:isArray(e)?e:[e]}function mapContext(e,n,i){if(isFunction(e))return e(n,i.data);var o,u,c={};try{for(var f=(0,s.XA)(Object.keys(e)),l=f.next();!l.done;l=f.next()){var d=l.value,v=e[d];isFunction(v)?c[d]=v(n,i.data):c[d]=v}}catch(e){o={error:e}}finally{try{l&&!l.done&&(u=f.return)&&u.call(f)}finally{if(o)throw o.error}}return c}function isBuiltInEvent(e){return/^(done|error)\./.test(e)}function isPromiseLike(e){return!!(e instanceof Promise||null!==e&&(isFunction(e)||"object"==typeof e)&&isFunction(e.then))}function isBehavior(e){return null!==e&&"object"==typeof e&&"transition"in e&&"function"==typeof e.transition}function partition(e,n){var i,o,u=(0,s.CR)([[],[]],2),c=u[0],f=u[1];try{for(var l=(0,s.XA)(e),d=l.next();!d.done;d=l.next()){var v=d.value;n(v)?c.push(v):f.push(v)}}catch(e){i={error:e}}finally{try{d&&!d.done&&(o=l.return)&&o.call(l)}finally{if(i)throw i.error}}return[c,f]}function updateHistoryStates(e,n){return mapValues(e.states,function(e,i){if(e){var o=(isString(n)?void 0:n[i])||(e?e.current:void 0);if(o)return{current:o,states:updateHistoryStates(e,o)}}})}function updateHistoryValue(e,n){return{current:n,states:updateHistoryStates(e,n)}}function updateContext(e,n,i,o){return l.M||warn(!!e,"Attempting to update undefined context"),e?i.reduce(function(e,i){var u,c,f=i.assignment,l={state:o,action:i,_event:n},d={};if(isFunction(f))d=f(e,n.data,l);else try{for(var v=(0,s.XA)(Object.keys(f)),y=v.next();!y.done;y=v.next()){var g=y.value,m=f[g];d[g]=isFunction(m)?m(e,n.data,l):m}}catch(e){u={error:e}}finally{try{y&&!y.done&&(c=v.return)&&c.call(v)}finally{if(u)throw u.error}}return Object.assign({},e,d)},e):e}var warn=function(){};function isArray(e){return Array.isArray(e)}function isFunction(e){return"function"==typeof e}function isString(e){return"string"==typeof e}function toGuard(e,n){return e?isString(e)?{type:f.TV,name:e,predicate:n?n[e]:void 0}:isFunction(e)?{type:f.TV,name:e.name,predicate:e}:e:void 0}function isObservable(e){try{return"subscribe"in e&&isFunction(e.subscribe)}catch(e){return!1}}l.M||(warn=function(e,n){var i=e instanceof Error?e:void 0;if((i||!e)&&void 0!==console){var o=["Warning: ".concat(n)];i&&o.push(i),console.warn.apply(console,o)}});var d="function"==typeof Symbol&&Symbol.observable||"@@observable";function isMachine(e){return!!e&&"__xstatenode"in e}function isActor(e){return!!e&&"function"==typeof e.send}function toEventObject(e,n){return isString(e)||"number"==typeof e?(0,s.pi)({type:e},n):e}function toSCXMLEvent(e,n){if(!isString(e)&&"$$type"in e&&"scxml"===e.$$type)return e;var i=toEventObject(e);return(0,s.pi)({name:i.type,data:i,$$type:"scxml",type:"external"},n)}function toTransitionConfigArray(e,n){return(isArray(n)?n:[n]).map(function(n){return void 0===n||"string"==typeof n||isMachine(n)?{target:n,event:e}:(0,s.pi)((0,s.pi)({},n),{event:e})})}function normalizeTarget(e){if(void 0!==e&&e!==f.rt)return toArray(e)}function reportUnhandledExceptionOnInvocation(e,n,i){if(!l.M){var o=e.stack?" Stacktrace was '".concat(e.stack,"'"):"";if(e===n)console.error("Missing onError handler for invocation '".concat(i,"', error was '").concat(e,"'.").concat(o));else{var s=n.stack?" Stacktrace was '".concat(n.stack,"'"):"";console.error("Missing onError handler and/or unhandled exception/promise rejection for invocation '".concat(i,"'. ")+"Original error: '".concat(e,"'. ").concat(o," Current error is '").concat(n,"'.").concat(s))}}}function evaluateGuard(e,n,i,o,s){var u=e.options.guards,c={state:s,cond:n,_event:o};if(n.type===f.TV)return((null==u?void 0:u[n.name])||n.predicate)(i,o.data,c);var l=null==u?void 0:u[n.type];if(!l)throw Error("Guard '".concat(n.type,"' is not implemented on machine '").concat(e.id,"'."));return l(i,o.data,c)}function toInvokeSource(e){return"string"==typeof e?{type:e}:e}function toObserver(e,n,i){var noop=function(){},o="object"==typeof e,s=o?e:null;return{next:((o?e.next:e)||noop).bind(s),error:((o?e.error:n)||noop).bind(s),complete:((o?e.complete:i)||noop).bind(s)}}function createInvokeId(e,n){return"".concat(e,":invocation[").concat(n,"]")}function isRaisableAction(e){return(e.type===c.OU||e.type===c.lW&&e.to===u.K.Internal)&&"number"!=typeof e.delay}(o={})[d]=function(){return this},o[Symbol.observable]=function(){return this}}}]);