"use strict";(this.webpackChunk_gorgias_chat_client=this.webpackChunk_gorgias_chat_client||[]).push([[682],{24758:(t,e,n)=>{n.d(e,{$:()=>B,B:()=>pt,C:()=>Gt,D:()=>ut,E:()=>Yt,F:()=>vt,G:()=>Lt,H:()=>It,I:()=>Bt,J:()=>x,K:()=>Ct,L:()=>bt,M:()=>E,N:()=>p,O:()=>ft,P:()=>kt,Q:()=>ee,R:()=>J,S:()=>v,T:()=>m,U:()=>S,V:()=>L,W:()=>Zt,X:()=>_,a:()=>F,b:()=>X,c:()=>U,d:()=>it,g:()=>Et,l:()=>T,n:()=>nt,q:()=>mt,r:()=>se,s:()=>tt,t:()=>j,u:()=>R,v:()=>gt,w:()=>st,x:()=>D,y:()=>yt,z:()=>_t});var r=n(35980),i=n(1848),s=n(62684),o=n(57970),a=n(32663);function c(){var t="undefined"!==typeof globalThis?globalThis:"undefined"!==typeof self?self:"undefined"!==typeof window?window:"undefined"!==typeof n.g?n.g:void 0;if(t.__xstate__)return t.__xstate__}var u=t=>{if("undefined"!==typeof window){var e=c();e&&e.register(t)}},h=["_nodes","tags","machine","getMeta","toJSON","can","hasTag","matches"],l=["_nodes","tags","machine","children","context","can","hasTag","matches","getMeta","toJSON"];class d{constructor(t){this._process=t,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(t){var e={value:t,next:null};if(this._current)return this._last.next=e,void(this._last=e);this._current=e,this._last=e,this._active&&this.flush()}flush(){for(;this._current;){var t=this._current;this._process(t.value),this._current=t.next}this._last=null}}var v=".",f="",p="",y="*",g="xstate.init",m="xstate.error",_="xstate.stop";function A(t,e){return{type:"xstate.done.state.".concat(t),output:e}}function S(t,e){return{type:"xstate.error.actor.".concat(t),error:e,actorId:t}}function x(t){return{type:g,input:t}}function b(t){setTimeout(()=>{throw t})}var w="function"===typeof Symbol&&Symbol.observable||"@@observable";function k(t,e){var n=I(t),r=I(e);return"string"===typeof r?"string"===typeof n&&r===n:"string"===typeof n?n in r:Object.keys(n).every(t=>t in r&&k(n[t],r[t]))}function E(t){if(M(t))return t;for(var e=[],n="",r=0;r"undefined"===typeof t||"string"===typeof t?{target:t}:t)}function C(t){if(void 0!==t&&t!==f)return j(t)}function P(t,e,n){var r,i,s,o="object"===typeof t,a=o?t:void 0;return{next:null===(r=o?t.next:t)||void 0===r?void 0:r.bind(a),error:null===(i=o?t.error:e)||void 0===i?void 0:i.bind(a),complete:null===(s=o?t.complete:n)||void 0===s?void 0:s.bind(a)}}function D(t,e){return"".concat(e,".").concat(t)}function J(t,e){var n=e.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!n)return t.implementations.actors[e];var r=(0,a.A)(n,3),i=r[1],s=r[2],o=t.getStateNodeById(s).config.invoke;return(Array.isArray(o)?o[i]:o).src}function V(t,e){return"".concat(t.sessionId,".").concat(e)}var z=0;var $=!1,B=1,L=function(t){return t[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped",t}({}),W={clock:{setTimeout:function(t){function e(e,n){return t.apply(this,arguments)}return e.toString=function(){return t.toString()},e}((t,e)=>setTimeout(t,e)),clearTimeout:function(t){function e(e){return t.apply(this,arguments)}return e.toString=function(){return t.toString()},e}(t=>clearTimeout(t))},logger:console.log.bind(console),devTools:!1};class q{constructor(t,e){var n,r,i,s;this.logic=t,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new d(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=L.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this._systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];var a=(0,o.A)((0,o.A)({},W),e),c=a.clock,u=a.logger,h=a.parent,l=a.syncSnapshot,v=a.id,f=a.systemId,p=a.inspect;this.system=h?h.system:function(t,e){var n,r=new Map,i=new Map,s=new WeakMap,a=new Set,c={},u=e.clock,h=e.logger,l={schedule:function(t,e,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Math.random().toString(36).slice(2),s={source:t,target:e,event:n,delay:r,id:i,startedAt:Date.now()},o=V(t,i);d._snapshot._scheduledEvents[o]=s;var a=u.setTimeout(()=>{delete c[o],delete d._snapshot._scheduledEvents[o],d._relay(t,e,n)},r);c[o]=a},cancel:(t,e)=>{var n=V(t,e),r=c[n];delete c[n],delete d._snapshot._scheduledEvents[n],void 0!==r&&u.clearTimeout(r)},cancelAll:t=>{for(var e in d._snapshot._scheduledEvents){var n=d._snapshot._scheduledEvents[e];n.source===t&&l.cancel(t,n.id)}}},d={_snapshot:{_scheduledEvents:null!==(n=(null===e||void 0===e?void 0:e.snapshot)&&e.snapshot.scheduler)&&void 0!==n?n:{}},_bookId:()=>"x:".concat(z++),_register:(t,e)=>(r.set(t,e),t),_unregister:t=>{r.delete(t.sessionId);var e=s.get(t);void 0!==e&&(i.delete(e),s.delete(t))},get:t=>i.get(t),_set:(t,e)=>{var n=i.get(t);if(n&&n!==e)throw new Error("Actor with system ID '".concat(t,"' already exists."));i.set(t,e),s.set(e,t)},inspect:t=>{var e=P(t);return a.add(e),{unsubscribe(){a.delete(e)}}},_sendInspectionEvent:e=>{if(a.size){var n=(0,o.A)((0,o.A)({},e),{},{rootId:t.sessionId});a.forEach(t=>{var e;return null===(e=t.next)||void 0===e?void 0:e.call(t,n)})}},_relay:(t,e,n)=>{d._sendInspectionEvent({type:"@xstate.event",sourceRef:t,actorRef:e,event:n}),e._send(n)},scheduler:l,getSnapshot:()=>({_scheduledEvents:(0,o.A)({},d._snapshot._scheduledEvents)}),start:()=>{var t=d._snapshot._scheduledEvents;for(var e in d._snapshot._scheduledEvents={},t){var n=t[e],r=n.source,i=n.target,s=n.event,o=n.delay,a=n.id;l.schedule(r,i,s,o,a)}},_clock:u,_logger:h};return d}(this,{clock:c,logger:u}),p&&!h&&this.system.inspect(P(p)),this.sessionId=this.system._bookId(),this.id=null!==v&&void 0!==v?v:this.sessionId,this.logger=null!==(n=null===e||void 0===e?void 0:e.logger)&&void 0!==n?n:this.system._logger,this.clock=null!==(r=null===e||void 0===e?void 0:e.clock)&&void 0!==r?r:this.system._clock,this._parent=h,this._syncSnapshot=l,this.options=a,this.src=null!==(i=a.src)&&void 0!==i?i:t,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:t=>{this._deferred.push(t)},system:this.system,stopChild:t=>{if(t._parent!==this)throw new Error("Cannot stop child actor ".concat(t.id," of ").concat(this.id," because it is not a child"));t._stop()},emit:t=>{var e=this.eventListeners.get(t.type),n=this.eventListeners.get("*");if(e||n)for(var r=0,i=[...e?e.values():[],...n?n.values():[]];r{var e=()=>{if(this._actorScope.system._sendInspectionEvent({type:"@xstate.action",actorRef:this,action:{type:t.type,params:t.params}}),t.exec){var e=$;try{$=!0,t.exec(t.info,t.params)}finally{$=e}}};this._processingStatus===L.Running?e():this._deferred.push(e)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),f&&(this._systemId=f,this.system._set(f,this)),this._initState(null!==(s=null===e||void 0===e?void 0:e.snapshot)&&void 0!==s?s:null===e||void 0===e?void 0:e.state),f&&"active"!==this._snapshot.status&&this.system._unregister(this)}_initState(t){try{var e;this._snapshot=t?this.logic.restoreSnapshot?this.logic.restoreSnapshot(t,this._actorScope):t:this.logic.getInitialSnapshot(this._actorScope,null===(e=this.options)||void 0===e?void 0:e.input)}catch(n){this._snapshot={status:"error",output:void 0,error:n}}}update(t,e){var n,r,i;for(this._snapshot=t;n=this._deferred.shift();)try{n()}catch(p){this._deferred.length=0,this._snapshot=(0,o.A)((0,o.A)({},t),{},{status:"error",error:p})}switch(this._snapshot.status){case"active":var a,c=(0,s.A)(this.observers);try{for(c.s();!(a=c.n()).done;){var u=a.value;try{var h;null===(h=u.next)||void 0===h||h.call(u,t)}catch(p){b(p)}}}catch(p){c.e(p)}finally{c.f()}break;case"done":var l,d=(0,s.A)(this.observers);try{for(d.s();!(l=d.n()).done;){var v=l.value;try{var f;null===(f=v.next)||void 0===f||f.call(v,t)}catch(p){b(p)}}}catch(p){d.e(p)}finally{d.f()}this._stopProcedure(),this._complete(),this._doneEvent=(r=this.id,i=this._snapshot.output,{type:"xstate.done.actor.".concat(r),output:i,actorId:r}),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case"error":this._error(this._snapshot.error)}this.system._sendInspectionEvent({type:"@xstate.snapshot",actorRef:this,event:e,snapshot:t})}subscribe(t,e,n){var r=P(t,e,n);if(this._processingStatus!==L.Stopped)this.observers.add(r);else switch(this._snapshot.status){case"done":try{var i;null===(i=r.complete)||void 0===i||i.call(r)}catch(s){b(s)}break;case"error":var s=this._snapshot.error;if(r.error)try{r.error(s)}catch(s){b(s)}else b(s)}return{unsubscribe:()=>{this.observers.delete(r)}}}on(t,e){var n=this.eventListeners.get(t);n||(n=new Set,this.eventListeners.set(t,n));var r=e.bind(void 0);return n.add(r),{unsubscribe:()=>{n.delete(r)}}}start(){if(this._processingStatus===L.Running)return this;this._syncSnapshot&&this.subscribe({next:t=>{"active"===t.status&&this.system._relay(this,this._parent,{type:"xstate.snapshot.".concat(this.id),snapshot:t})},error:()=>{}}),this.system._register(this.sessionId,this),this._systemId&&this.system._set(this._systemId,this),this._processingStatus=L.Running;var t=x(this.options.input);switch(this.system._sendInspectionEvent({type:"@xstate.event",sourceRef:this._parent,actorRef:this,event:t}),this._snapshot.status){case"done":return this.update(this._snapshot,t),this;case"error":return this._error(this._snapshot.error),this}if(this._parent||this.system.start(),this.logic.start)try{this.logic.start(this._snapshot,this._actorScope)}catch(e){return this._snapshot=(0,o.A)((0,o.A)({},this._snapshot),{},{status:"error",error:e}),this._error(e),this}return this.update(this._snapshot,t),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(t){var e,n;try{e=this.logic.transition(this._snapshot,t,this._actorScope)}catch(r){n={err:r}}if(n){var r=n.err;return this._snapshot=(0,o.A)((0,o.A)({},this._snapshot),{},{status:"error",error:r}),void this._error(r)}this.update(e,t),t.type===_&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===L.Stopped?this:(this.mailbox.clear(),this._processingStatus===L.NotStarted?(this._processingStatus=L.Stopped,this):(this.mailbox.enqueue({type:_}),this))}stop(){if(this._parent)throw new Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){var t,e=(0,s.A)(this.observers);try{for(e.s();!(t=e.n()).done;){var n=t.value;try{var r;null===(r=n.complete)||void 0===r||r.call(n)}catch(i){b(i)}}}catch(i){e.e(i)}finally{e.f()}this.observers.clear()}_reportError(t){if(this.observers.size){var e,n=!1,r=(0,s.A)(this.observers);try{for(r.s();!(e=r.n()).done;){var i=e.value.error;n||(n=!i);try{null===i||void 0===i||i(t)}catch(o){b(o)}}}catch(t){r.e(t)}finally{r.f()}this.observers.clear(),n&&b(t)}else this._parent||b(t)}_error(t){this._stopProcedure(),this._reportError(t),this._parent&&this.system._relay(this,this._parent,S(this.id,t))}_stopProcedure(){return this._processingStatus!==L.Running||(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new d(this._process.bind(this)),this._processingStatus=L.Stopped,this.system._unregister(this)),this}_send(t){this._processingStatus!==L.Stopped&&this.mailbox.enqueue(t)}send(t){this.system._relay(void 0,this,t)}attachDevTools(){var t=this.options.devTools;t&&("function"===typeof t?t:u)(this)}toJSON(){return{xstate$$type:B,id:this.id}}getPersistedSnapshot(t){return this.logic.getPersistedSnapshot(this._snapshot,t)}[w](){return this}getSnapshot(){return this._snapshot}}function U(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r{t.system.scheduler.cancel(t.self,e.sendId)})}function F(t){function e(t,e){}return e.type="xstate.cancel",e.sendId=t,e.resolve=G,e.execute=Q,e}function H(t,e,n,r,i){var s,a=i.id,c=i.systemId,u=i.src,h=i.input,l=i.syncSnapshot,d="string"===typeof u?J(e.machine,u):u,v="function"===typeof a?a(n):a,f=void 0;return d&&(f="function"===typeof h?h({context:e.context,event:n.event,self:t.self}):h,s=U(d,{id:v,src:u,parent:t.self,syncSnapshot:l,systemId:c,input:f})),[Zt(e,{children:(0,o.A)((0,o.A)({},e.children),{},{[v]:s})}),{id:a,systemId:c,actorRef:s,src:u,input:f},void 0]}function K(t,e){var n=e.actorRef;n&&t.defer(()=>{n._processingStatus!==L.Stopped&&n.start()})}function X(){for(var t=arguments.length,e=new Array(t),n=0;n{t.stopChild(e)}):t.stopChild(e))}function tt(t){function e(t,e){}return e.type="xstate.stopChild",e.actorRef=t,e.resolve=Y,e.execute=Z,e}function et(t,e,n){var r=e.context,i=e.event;return!st(n.guards[0],r,i,t)}function nt(t){function e(t,e){return!1}return e.check=et,e.guards=[t],e}function rt(t,e,n){var r=e.context,i=e.event;return n.guards.every(e=>st(e,r,i,t))}function it(t){function e(t,e){return!1}return e.check=rt,e.guards=t,e}function st(t,e,n,r){var i=r.machine,s="function"===typeof t,o=s?t:i.implementations.guards["string"===typeof t?t:t.type];if(!s&&!o)throw new Error("Guard '".concat("string"===typeof t?t:t.type,"' is not implemented.'."));if("function"!==typeof o)return st(o,e,n,r);var a={context:e,event:n},c=s||"string"===typeof t?void 0:"params"in t?"function"===typeof t.params?t.params({context:e,event:n}):t.params:void 0;return"check"in o?o.check(r,a,o):o(a,c)}var ot=t=>"atomic"===t.type||"final"===t.type;function at(t){return Object.values(t.states).filter(t=>"history"!==t.type)}function ct(t,e){var n=[];if(e===t)return n;for(var r=t.parent;r&&r!==e;)n.push(r),r=r.parent;return n}function ut(t){var e,n=new Set(t),r=lt(n),i=(0,s.A)(n);try{for(i.s();!(e=i.n()).done;){var o=e.value;if("compound"!==o.type||r.get(o)&&r.get(o).length){if("parallel"===o.type){var a,c=(0,s.A)(at(o));try{for(c.s();!(a=c.n()).done;){var u=a.value;if("history"!==u.type&&!n.has(u)){var h,l=xt(u),d=(0,s.A)(l);try{for(d.s();!(h=d.n()).done;){var v=h.value;n.add(v)}}catch(g){d.e(g)}finally{d.f()}}}}catch(g){c.e(g)}finally{c.f()}}}else xt(o).forEach(t=>n.add(t))}}catch(g){i.e(g)}finally{i.f()}var f,p=(0,s.A)(n);try{for(p.s();!(f=p.n()).done;)for(var y=f.value.parent;y;)n.add(y),y=y.parent}catch(g){p.e(g)}finally{p.f()}return n}function ht(t,e){var n=e.get(t);if(!n)return{};if("compound"===t.type){var r=n[0];if(!r)return{};if(ot(r))return r.key}var i,o={},a=(0,s.A)(n);try{for(a.s();!(i=a.n()).done;){var c=i.value;o[c.key]=ht(c,e)}}catch(u){a.e(u)}finally{a.f()}return o}function lt(t){var e,n=new Map,r=(0,s.A)(t);try{for(r.s();!(e=r.n()).done;){var i=e.value;n.has(i)||n.set(i,[]),i.parent&&(n.has(i.parent)||n.set(i.parent,[]),n.get(i.parent).push(i))}}catch(o){r.e(o)}finally{r.f()}return n}function dt(t,e){return ht(t,lt(ut(e)))}function vt(t,e){return"compound"===e.type?at(e).some(e=>"final"===e.type&&t.has(e)):"parallel"===e.type?at(e).every(e=>vt(t,e)):"final"===e.type}var ft=t=>"#"===t[0];function pt(t,e){return t.transitions.get(e)||[...t.transitions.keys()].filter(t=>{if(t===y)return!0;if(!t.endsWith(".*"))return!1;for(var n=t.split("."),r=e.split("."),i=0;ie.length-t.length).flatMap(e=>t.transitions.get(e))}function yt(t){var e=t.config.after;if(!e)return[];return Object.keys(e).flatMap(n=>{var r=e[n],i="string"===typeof r?{target:r}:r,s=Number.isNaN(+n)?n:+n,a=(e=>{var n,r,i=(n=e,r=t.id,{type:"xstate.after.".concat(n,".").concat(r)}),s=i.type;return t.entry.push(se(i,{id:s,delay:e})),t.exit.push(F(s)),s})(s);return j(i).map(t=>(0,o.A)((0,o.A)({},t),{},{event:a,delay:s}))}).map(e=>{var n=e.delay;return(0,o.A)((0,o.A)({},gt(t,e.event,e)),{},{delay:n})})}function gt(t,e,n){var r,i=C(n.target),s=null!==(r=n.reenter)&&void 0!==r&&r,a=function(t,e){if(void 0===e)return;return e.map(e=>{if("string"!==typeof e)return e;if(ft(e))return t.machine.getStateNodeById(e);var n=e[0]===v;if(n&&!t.parent)return kt(t,e.slice(1));var r=n?t.key+e:e;if(!t.parent)throw new Error('Invalid target: "'.concat(e,'" is not a valid target from the root node. Did you mean ".').concat(e,'"?'));try{return kt(t.parent,r)}catch(i){throw new Error("Invalid transition definition for state node '".concat(t.id,"':\n").concat(i.message))}})}(t,i),c=(0,o.A)((0,o.A)({},n),{},{actions:j(n.actions),guard:n.guard,target:a,source:t,reenter:s,eventType:e,toJSON:()=>(0,o.A)((0,o.A)({},c),{},{source:"#".concat(t.id),target:a?a.map(t=>"#".concat(t.id)):void 0})});return c}function mt(t){var e=new Map;if(t.config.on)for(var n=function(){var n=i[r];if(n===p)throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');var s=t.config.on[n];e.set(n,R(s).map(e=>gt(t,n,e)))},r=0,i=Object.keys(t.config.on);rgt(t,o,e)))}var a,c=(0,s.A)(t.invoke);try{var u=function(){var n=a.value;if(n.onDone){var r="xstate.done.actor.".concat(n.id);e.set(r,R(n.onDone).map(e=>gt(t,r,e)))}if(n.onError){var i="xstate.error.actor.".concat(n.id);e.set(i,R(n.onError).map(e=>gt(t,i,e)))}if(n.onSnapshot){var s="xstate.snapshot.".concat(n.id);e.set(s,R(n.onSnapshot).map(e=>gt(t,s,e)))}};for(c.s();!(a=c.n()).done;)u()}catch(f){c.e(f)}finally{c.f()}var h,l=(0,s.A)(t.after);try{for(l.s();!(h=l.n()).done;){var d=h.value,v=e.get(d.eventType);v||(v=[],e.set(d.eventType,v)),v.push(d)}}catch(f){l.e(f)}finally{l.f()}return e}function _t(t,e){var n="string"===typeof e?t.states[e]:e?t.states[e.target]:void 0;if(!n&&e)throw new Error('Initial state node "'.concat(e,'" not found on parent state node #').concat(t.id));var r={source:t,actions:e&&"string"!==typeof e?j(e.actions):[],eventType:null,reenter:!1,target:n?[n]:[],toJSON:()=>(0,o.A)((0,o.A)({},r),{},{source:"#".concat(t.id),target:n?["#".concat(n.id)]:[]})};return r}function At(t){var e=C(t.config.target);return e?{target:e.map(e=>"string"===typeof e?kt(t.parent,e):e)}:t.parent.initial}function St(t){return"history"===t.type}function xt(t){var e,n=bt(t),r=(0,s.A)(n);try{for(r.s();!(e=r.n()).done;){var i,o=e.value,a=(0,s.A)(ct(o,t));try{for(a.s();!(i=a.n()).done;){var c=i.value;n.add(c)}}catch(u){a.e(u)}finally{a.f()}}}catch(u){r.e(u)}finally{r.f()}return n}function bt(t){var e=new Set;return function t(n){if(!e.has(n))if(e.add(n),"compound"===n.type)t(n.initial.target[0]);else if("parallel"===n.type){var r,i=(0,s.A)(at(n));try{for(i.s();!(r=i.n()).done;){t(r.value)}}catch(o){i.e(o)}finally{i.f()}}}(t),e}function wt(t,e){if(ft(e))return t.machine.getStateNodeById(e);if(!t.states)throw new Error("Unable to retrieve child state '".concat(e,"' from '").concat(t.id,"'; no child states exist."));var n=t.states[e];if(!n)throw new Error("Child state '".concat(e,"' does not exist on '").concat(t.id,"'"));return n}function kt(t,e){if("string"===typeof e&&ft(e))try{return t.machine.getStateNodeById(e)}catch(s){}for(var n=E(e).slice(),r=t;n.length;){var i=n.shift();if(!i.length)break;r=wt(r,i)}return r}function Et(t,e){if("string"===typeof e){var n=t.states[e];if(!n)throw new Error("State '".concat(e,"' does not exist on '").concat(t.id,"'"));return[t,n]}var r=Object.keys(e),i=r.map(e=>wt(t,e)).filter(Boolean);return[t.machine.root,t].concat(i,r.reduce((n,r)=>{var i=wt(t,r);if(!i)return n;var s=Et(i,e[r]);return n.concat(s)},[]))}function It(t,e,n,r){return"string"===typeof e?function(t,e,n,r){var i=wt(t,e).next(n,r);return i&&i.length?i:t.next(n,r)}(t,e,n,r):1===Object.keys(e).length?function(t,e,n,r){var i=Object.keys(e),s=It(wt(t,i[0]),e[i[0]],n,r);return s&&s.length?s:t.next(n,r)}(t,e,n,r):function(t,e,n,r){for(var i=[],s=0,o=Object.keys(e);se===t.source||Tt(e,t.source)))return t.source;var r=function(t){var e,n=(0,i.A)(t),r=n[0],o=n.slice(1),a=(0,s.A)(ct(r,void 0));try{var c,u=function(){var t=e.value;if(o.every(e=>Tt(e,t)))return{v:t}};for(a.s();!(e=a.n()).done;)if(c=u())return c.v}catch(h){a.e(h)}finally{a.f()}}(n.concat(t.source));if(r)return r;if(!t.reenter)return t.source.machine.root}}function Rt(t,e,n){var r,i=new Set,o=(0,s.A)(t);try{for(o.s();!(r=o.n()).done;){var a,c=r.value;if(null!==(a=c.target)&&void 0!==a&&a.length){var u=Mt(c,n);c.reenter&&c.source===u&&i.add(u);var h,l=(0,s.A)(e);try{for(l.s();!(h=l.n()).done;){var d=h.value;Tt(d,u)&&i.add(d)}}catch(v){l.e(v)}finally{l.f()}}}}catch(v){o.e(v)}finally{o.f()}return[...i]}function Ct(t,e,n,r,i,c){if(!t.length)return e;var u=new Set(e._nodes),h=e.historyValue,l=jt(t,u,h),d=e;if(!i){var v=function(t,e,n,r,i,a,c){var u,h=t,l=Rt(r,i,a);l.sort((t,e)=>e.order-t.order);var d,v=(0,s.A)(l);try{var f=function(){var t,e,n=d.value,r=(0,s.A)((e=n,Object.keys(e.states).map(t=>e.states[t]).filter(t=>"history"===t.type)));try{for(r.s();!(t=r.n()).done;){var c=t.value,h=void 0;h="deep"===c.history?t=>ot(t)&&Tt(t,n):t=>t.parent===n,null!==u&&void 0!==u||(u=(0,o.A)({},a)),u[c.id]=Array.from(i).filter(h)}}catch(l){r.e(l)}finally{r.f()}};for(v.s();!(d=v.n()).done;)f()}catch(m){v.e(m)}finally{v.f()}var p,y=(0,s.A)(l);try{for(y.s();!(p=y.n()).done;){var g=p.value;h=Bt(h,e,n,[...g.exit,...g.invoke.map(t=>tt(t.id))],c,void 0),i.delete(g)}}catch(m){y.e(m)}finally{y.f()}return[h,u||a]}(d,r,n,l,u,h,c,n.actionExecutor),f=(0,a.A)(v,2);d=f[0],h=f[1]}d=function(t,e,n,r,i,a,c,u){var h=t,l=new Set,d=new Set;(function(t,e,n,r){var i,o=(0,s.A)(t);try{for(o.s();!(i=o.n()).done;){var a,c=i.value,u=Mt(c,e),h=(0,s.A)(c.target||[]);try{for(h.s();!(a=h.n()).done;){var l=a.value;St(l)||c.source===l&&c.source===u&&!c.reenter||(r.add(l),n.add(l)),Dt(l,e,n,r)}}catch(y){h.e(y)}finally{h.f()}var d,v=Nt(c,e),f=(0,s.A)(v);try{for(f.s();!(d=f.n()).done;){var p=ct(d.value,u);"parallel"===(null===u||void 0===u?void 0:u.type)&&p.push(u),Jt(r,e,n,p,!c.source.parent&&c.reenter?void 0:u)}}catch(y){f.e(y)}finally{f.f()}}}catch(y){o.e(y)}finally{o.f()}})(r,c,d,l),u&&d.add(t.machine.root);var v,f=new Set,p=(0,s.A)([...l].sort((t,e)=>t.order-e.order));try{for(p.s();!(v=p.n()).done;){var y=v.value;i.add(y);var g=[];g.push(...y.entry);var m,_=(0,s.A)(y.invoke);try{for(_.s();!(m=_.n()).done;){var S=m.value;g.push(X(S.src,(0,o.A)((0,o.A)({},S),{},{syncSnapshot:!!S.onSnapshot})))}}catch(I){_.e(I)}finally{_.f()}if(d.has(y)){var x=y.initial.actions;g.push(...x)}if(h=Bt(h,e,n,g,a,y.invoke.map(t=>t.id)),"final"===y.type){var b=y.parent,w="parallel"===(null===b||void 0===b?void 0:b.type)?b:null===b||void 0===b?void 0:b.parent,k=w||y;for("compound"===(null===b||void 0===b?void 0:b.type)&&a.push(A(b.id,void 0!==y.output?N(y.output,h.context,e,n.self):void 0));"parallel"===(null===(E=w)||void 0===E?void 0:E.type)&&!f.has(w)&&vt(i,w);){var E;f.add(w),a.push(A(w.id)),k=w,w=w.parent}if(w)continue;h=Zt(h,{status:"done",output:Pt(h,e,n,h.machine.root,k)})}}}catch(I){p.e(I)}finally{p.f()}return h}(d=Bt(d,r,n,l.flatMap(t=>t.actions),c,void 0),r,n,l,u,c,h,i);var p=[...u];"done"===d.status&&(d=Bt(d,r,n,p.sort((t,e)=>e.order-t.order).flatMap(t=>t.exit),c,void 0));try{return h===e.historyValue&&function(t,e){if(t.length!==e.size)return!1;var n,r=(0,s.A)(t);try{for(r.s();!(n=r.n()).done;){var i=n.value;if(!e.has(i))return!1}}catch(o){r.e(o)}finally{r.f()}return!0}(e._nodes,u)?d:Zt(d,{_nodes:p,historyValue:h})}catch(y){throw y}}function Pt(t,e,n,r,i){if(void 0!==r.output){var s=A(i.id,void 0!==i.output&&i.parent?N(i.output,t.context,e,n.self):void 0);return N(r.output,t.context,s,n.self)}}function Dt(t,e,n,r){if(St(t))if(e[t.id]){var i,o=e[t.id],c=(0,s.A)(o);try{for(c.s();!(i=c.n()).done;){var u=i.value;r.add(u),Dt(u,e,n,r)}}catch(b){c.e(b)}finally{c.f()}var h,l=(0,s.A)(o);try{for(l.s();!(h=l.n()).done;){Vt(h.value,t.parent,r,e,n)}}catch(b){l.e(b)}finally{l.f()}}else{var d,v=At(t),f=(0,s.A)(v.target);try{for(f.s();!(d=f.n()).done;){var p,y=d.value;r.add(y),v===(null===(p=t.parent)||void 0===p?void 0:p.initial)&&n.add(t.parent),Dt(y,e,n,r)}}catch(b){f.e(b)}finally{f.f()}var g,m=(0,s.A)(v.target);try{for(m.s();!(g=m.n()).done;){Vt(g.value,t.parent,r,e,n)}}catch(b){m.e(b)}finally{m.f()}}else if("compound"===t.type){var _=(0,a.A)(t.initial.target,1)[0];St(_)||(r.add(_),n.add(_)),Dt(_,e,n,r),Vt(_,t,r,e,n)}else if("parallel"===t.type){var A,S=(0,s.A)(at(t).filter(t=>!St(t)));try{var x=function(){var t=A.value;[...r].some(e=>Tt(e,t))||(St(t)||(r.add(t),n.add(t)),Dt(t,e,n,r))};for(S.s();!(A=S.n()).done;)x()}catch(b){S.e(b)}finally{S.f()}}}function Jt(t,e,n,r,i){var o,a=(0,s.A)(r);try{for(a.s();!(o=a.n()).done;){var c=o.value;if(i&&!Tt(c,i)||t.add(c),"parallel"===c.type){var u,h=(0,s.A)(at(c).filter(t=>!St(t)));try{var l=function(){var r=u.value;[...t].some(t=>Tt(t,r))||(t.add(r),Dt(r,e,n,t))};for(h.s();!(u=h.n()).done;)l()}catch(d){h.e(d)}finally{h.f()}}}}catch(d){a.e(d)}finally{a.f()}}function Vt(t,e,n,r,i){Jt(n,r,i,ct(t,e))}function zt(t,e){return t.implementations.actions[e]}function $t(t,e,n,r,i,o){var c,u=t.machine,h=t,l=(0,s.A)(r);try{for(l.s();!(c=l.n()).done;){var d=c.value,v="function"===typeof d,f=v?d:zt(u,"string"===typeof d?d:d.type),p={context:h.context,event:e,self:n.self,system:n.system},y=v||"string"===typeof d?void 0:"params"in d?"function"===typeof d.params?d.params({context:h.context,event:e}):d.params:void 0;if(f&&"resolve"in f){var g=f,m=g.resolve(n,h,p,y,f,i),_=(0,a.A)(m,3),A=_[0],S=_[1],x=_[2];h=A,"retryResolve"in g&&(null===o||void 0===o||o.push([g,S])),"execute"in g&&n.actionExecutor({type:g.type,info:p,params:S,exec:g.execute.bind(null,n,S)}),x&&(h=$t(h,e,n,x,i,o))}else n.actionExecutor({type:"string"===typeof d?d:"object"===typeof d?d.type:d.name||"(anonymous)",info:p,params:y,exec:f})}}catch(b){l.e(b)}finally{l.f()}return h}function Bt(t,e,n,r,i,s){var o=s?[]:void 0,c=$t(t,e,n,r,{internalQueue:i,deferredActorIds:s},o);return null===o||void 0===o||o.forEach(t=>{var e=(0,a.A)(t,2),r=e[0],i=e[1];r.retryResolve(n,c,i)}),c}function Lt(t,e,n,r){var i=t,s=[];function o(t,e,r){n.system._sendInspectionEvent({type:"@xstate.microstep",actorRef:n.self,event:e,snapshot:t,_transitions:r}),s.push(t)}if(e.type===_)return o(i=Zt(Wt(i,e,n),{status:"stopped"}),e,[]),{snapshot:i,microstates:s};var a=e;if(a.type!==g){var c=a,u=function(t){return t.type.startsWith("xstate.error.actor")}(c),h=qt(c,i);if(u&&!h.length)return o(i=Zt(t,{status:"error",error:c.error}),c,[]),{snapshot:i,microstates:s};o(i=Ct(h,t,n,a,!1,r),c,h)}for(var l=!0;"active"===i.status;){var d=l?Ut(i,a):[],v=d.length?i:void 0;if(!d.length){if(!r.length)break;d=qt(a=r.shift(),i)}l=(i=Ct(d,i,n,a,!1,r))!==v,o(i,a,d)}return"active"!==i.status&&Wt(i,a,n),{snapshot:i,microstates:s}}function Wt(t,e,n){return Bt(t,e,n,Object.values(t.children).map(t=>tt(t)),[],void 0)}function qt(t,e){return e.machine.getTransitionData(e,t)}function Ut(t,e){var n,r=new Set,i=t._nodes.filter(ot),o=(0,s.A)(i);try{for(o.s();!(n=o.n()).done;){var a,c=n.value,u=(0,s.A)([c].concat(ct(c,void 0)));try{t:for(u.s();!(a=u.n()).done;){var h=a.value;if(h.always){var l,d=(0,s.A)(h.always);try{for(d.s();!(l=d.n()).done;){var v=l.value;if(void 0===v.guard||st(v.guard,t.context,e,t)){r.add(v);break t}}}catch(f){d.e(f)}finally{d.f()}}}}catch(f){u.e(f)}finally{u.f()}}}catch(f){o.e(f)}finally{o.f()}return jt(Array.from(r),new Set(t._nodes),t.historyValue)}function Gt(t,e){return dt(t,[...ut(Et(t,e))])}var Qt=function(t){return k(t,this.value)},Ft=function(t){return this.tags.has(t)},Ht=function(t){var e=this.machine.getTransitionData(this,t);return!(null===e||void 0===e||!e.length)&&e.some(t=>void 0!==t.target||t.actions.length)},Kt=function(){this._nodes;var t=this.tags,e=(this.machine,this.getMeta,this.toJSON,this.can,this.hasTag,this.matches,(0,r.A)(this,h));return(0,o.A)((0,o.A)({},e),{},{tags:Array.from(t)})},Xt=function(){return this._nodes.reduce((t,e)=>(void 0!==e.meta&&(t[e.id]=e.meta),t),{})};function Yt(t,e){return{status:t.status,output:t.output,error:t.error,machine:e,context:t.context,_nodes:t._nodes,value:dt(e.root,t._nodes),tags:new Set(t._nodes.flatMap(t=>t.tags)),children:t.children,historyValue:t.historyValue||{},matches:Qt,hasTag:Ft,can:Ht,getMeta:Xt,toJSON:Kt}}function Zt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Yt((0,o.A)((0,o.A)({},t),e),t.machine)}function te(t){if("object"!==typeof t||null===t)return{};var e={};for(var n in t){var r=t[n];Array.isArray(r)&&(e[n]=r.map(t=>({id:t.id})))}return e}function ee(t,e){t._nodes,t.tags,t.machine;var n=t.children,i=t.context,s=(t.can,t.hasTag,t.matches,t.getMeta,t.toJSON,(0,r.A)(t,l)),a={};for(var c in n){var u=n[c];a[c]={snapshot:u.getPersistedSnapshot(e),src:u.src,systemId:u._systemId,syncSnapshot:u._syncSnapshot}}return(0,o.A)((0,o.A)({},s),{},{context:ne(i),children:a,historyValue:te(s.historyValue)})}function ne(t){var e;for(var n in t){var r=t[n];if(r&&"object"===typeof r)if("sessionId"in r&&"send"in r&&"ref"in r)null!==e&&void 0!==e||(e=Array.isArray(t)?t.slice():(0,o.A)({},t)),e[n]={xstate$$type:B,id:r.id};else{var i=ne(r);i!==r&&(null!==e&&void 0!==e||(e=Array.isArray(t)?t.slice():(0,o.A)({},t)),e[n]=i)}}return null!==e&&void 0!==e?e:t}function re(t,e,n,r,i,s){var o=i.event,a=i.id,c=i.delay,u=s.internalQueue,h=e.machine.implementations.delays;if("string"===typeof o)throw new Error('Only event objects may be used with raise; use raise({ type: "'.concat(o,'" }) instead'));var l,d="function"===typeof o?o(n,r):o;if("string"===typeof c){var v=h&&h[c];l="function"===typeof v?v(n,r):v}else l="function"===typeof c?c(n,r):c;return"number"!==typeof l&&u.push(d),[e,{event:d,id:a,delay:l},void 0]}function ie(t,e){var n=e.event,r=e.delay,i=e.id;"number"!==typeof r||t.defer(()=>{var e=t.self;t.system.scheduler.schedule(e,e,n,r,i)})}function se(t,e){function n(t,e){}return n.type="xstate.raise",n.event=t,n.id=null===e||void 0===e?void 0:e.id,n.delay=null===e||void 0===e?void 0:e.delay,n.resolve=re,n.execute=ie,n}},52652:(t,e,n)=>{n.d(e,{a:()=>a,e:()=>f,l:()=>g,s:()=>d});var r=n(24758),i=n(73857);function s(t,e,n,r,i){var s=i.event;return[e,{event:"function"===typeof s?s(n,r):s},void 0]}function o(t,e){var n=e.event;t.defer(()=>t.emit(n))}function a(t){function e(t,e){}return e.type="xstate.emit",e.event=t,e.resolve=s,e.execute=o,e}var c=function(t){return t.Parent="#_parent",t.Internal="#_internal",t}({});function u(t,e,n,r,i,s){var o=i.to,a=i.event,u=i.id,h=i.delay,l=e.machine.implementations.delays;if("string"===typeof a)throw new Error('Only event objects may be used with sendTo; use sendTo({ type: "'.concat(a,'" }) instead'));var d,v="function"===typeof a?a(n,r):a;if("string"===typeof h){var f=l&&l[h];d="function"===typeof f?f(n,r):f}else d="function"===typeof h?h(n,r):h;var p,y="function"===typeof o?o(n,r):o;if("string"===typeof y){if(y===c.Parent)p=t.self._parent;else if(y===c.Internal)p=t.self;else if(y.startsWith("#_"))p=e.children[y.slice(2)];else{var g;p=null!==(g=s.deferredActorIds)&&void 0!==g&&g.includes(y)?y:e.children[y]}if(!p)throw new Error("Unable to send event to actor '".concat(y,"' from machine '").concat(e.machine.id,"'."))}else p=y||t.self;return[e,{to:p,targetId:"string"===typeof y?y:void 0,event:v,id:u,delay:d},void 0]}function h(t,e,n){"string"===typeof n.to&&(n.to=e.children[n.to])}function l(t,e){t.defer(()=>{var n=e.to,i=e.event,s=e.delay,o=e.id;"number"!==typeof s?t.system._relay(t.self,n,i.type===r.T?(0,r.U)(t.self.id,i.data):i):t.system.scheduler.schedule(t.self,n,i,s,o)})}function d(t,e,n){function r(t,e){}return r.type="xstate.sendTo",r.to=t,r.event=e,r.id=null===n||void 0===n?void 0:n.id,r.delay=null===n||void 0===n?void 0:n.delay,r.resolve=u,r.retryResolve=h,r.execute=l,r}function v(t,e,n,s,o){var u=o.collect,h=[],l=function(t){h.push(t)};return l.assign=function(){h.push((0,i.a)(...arguments))},l.cancel=function(){h.push((0,r.a)(...arguments))},l.raise=function(){h.push((0,r.r)(...arguments))},l.sendTo=function(){h.push(d(...arguments))},l.sendParent=function(){h.push(function(t,e){return d(c.Parent,t,e)}(...arguments))},l.spawnChild=function(){h.push((0,r.b)(...arguments))},l.stopChild=function(){h.push((0,r.s)(...arguments))},l.emit=function(){h.push(a(...arguments))},u({context:n.context,event:n.event,enqueue:l,check:t=>(0,r.w)(t,e.context,n.event,e),self:t.self,system:t.system},s),[e,void 0,h]}function f(t){function e(t,e){}return e.type="xstate.enqueueActions",e.collect=t,e.resolve=v,e}function p(t,e,n,r,i){var s=i.value,o=i.label;return[e,{value:"function"===typeof s?s(n,r):s,label:o},void 0]}function y(t,e){var n=t.logger,r=e.value,i=e.label;i?n(i,r):n(r)}function g(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:t=>({context:t.context,event:t.event}),e=arguments.length>1?arguments[1]:void 0;function n(t,e){}return n.type="xstate.log",n.value=t,n.label=e,n.resolve=p,n.execute=y,n}},54607:(t,e,n)=>{n.d(e,{Sx:()=>c});var r=n(57970),i=n(24758);var s="xstate.promise.resolve",o="xstate.promise.reject",a=new WeakMap;function c(t){return{config:t,transition:(t,e,n)=>{if("active"!==t.status)return t;switch(e.type){case s:var c=e.data;return(0,r.A)((0,r.A)({},t),{},{status:"done",output:c,input:void 0});case o:return(0,r.A)((0,r.A)({},t),{},{status:"error",error:e.data,input:void 0});case i.X:var u;return null===(u=a.get(n.self))||void 0===u||u.abort(),(0,r.A)((0,r.A)({},t),{},{status:"stopped",input:void 0});default:return t}},start:(e,n)=>{var r=n.self,i=n.system,c=n.emit;if("active"===e.status){var u=new AbortController;a.set(r,u),Promise.resolve(t({input:e.input,system:i,self:r,signal:u.signal,emit:c})).then(t=>{"active"===r.getSnapshot().status&&(a.delete(r),i._relay(r,r,{type:s,data:t}))},t=>{"active"===r.getSnapshot().status&&(a.delete(r),i._relay(r,r,{type:o,data:t}))})}},getInitialSnapshot:(t,e)=>({status:"active",output:void 0,error:void 0,input:e}),getPersistedSnapshot:t=>t,restoreSnapshot:t=>t}}var u,h;h=void 0,u=t=>{}},69593:(t,e,n)=>{n.d(e,{d4:()=>f,zl:()=>p});var r=n(57970),i=n(32663),s=n(21253),o=n(80127),a=n(24758),c=n(98445),u=n(75135),h=(t,e)=>{e(t);var n=t.getSnapshot().children;n&&Object.values(n).forEach(t=>{h(t,e)})};function l(t){var e,n,r=[];h(t,t=>{r.push([t,t.getSnapshot()]),t.observers=new Set});var s=null===(e=(n=t.system).getSnapshot)||void 0===e?void 0:e.call(n);t.stop(),t.system._snapshot=s,r.forEach(t=>{var e=(0,i.A)(t,2),n=e[0],r=e[1];n._processingStatus=0,n._snapshot=r})}function d(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),c=1;c{var e=(0,a.c)(t,u);return[t.config,e]}),l=(0,i.A)(h,2),d=(0,i.A)(l[0],2),v=d[0],f=d[1],p=l[1];if(t.config!==v){var y=(0,a.c)(t,(0,r.A)((0,r.A)({},u),{},{snapshot:f.getPersistedSnapshot({__unsafeAllowInlineActors:!0})}));p([t.config,y]),f=y}return(0,o.A)(()=>{f.logic.implementations=t.implementations}),f}function v(t,e){return t===e}function f(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:v,r=(0,s.useCallback)(e=>t?t.subscribe(e).unsubscribe:()=>{},[t]),i=(0,s.useCallback)(()=>null===t||void 0===t?void 0:t.getSnapshot(),[t]);return(0,c.useSyncExternalStoreWithSelector)(r,i,i,e,n)}function p(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r1?e-1:0),r=1;ri.getSnapshot(),[i]),a=(0,s.useCallback)(t=>i.subscribe(t).unsubscribe,[i]),c=(0,u.useSyncExternalStore)(a,o,o);return(0,s.useEffect)(()=>(i.start(),()=>{l(i)}),[i]),[c,i.send,i]}(t,n[0])}},71674:(t,e,n)=>{n.d(e,{mj:()=>g,fm:()=>_});var r=n(57970),i=(n(54607),n(24758)),s=n(62684),o=n(32663),a=n(35980),c=n(73857),u=["onDone","onError"],h=new WeakMap;function l(t,e,n){var r=h.get(t);return r?e in r||(r[e]=n()):(r={[e]:n()},h.set(t,r)),r[e]}var d={},v=t=>"string"===typeof t?{type:t}:"function"===typeof t?"resolve"in t?{type:t.type}:{type:t.name}:t;class f{constructor(t,e){if(this.config=t,this.key=void 0,this.id=void 0,this.type=void 0,this.path=void 0,this.states=void 0,this.history=void 0,this.entry=void 0,this.exit=void 0,this.parent=void 0,this.machine=void 0,this.meta=void 0,this.output=void 0,this.order=-1,this.description=void 0,this.tags=[],this.transitions=void 0,this.always=void 0,this.parent=e._parent,this.key=e._key,this.machine=e._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(i.S),this.type=this.config.type||(this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.description=this.config.description,this.order=this.machine.idMap.size,this.machine.idMap.set(this.id,this),this.states=this.config.states?(0,i.l)(this.config.states,(t,e)=>new f(t,{_parent:this,_key:e,_machine:this.machine})):d,"compound"===this.type&&!this.config.initial)throw new Error('No initial state specified for compound state node "#'.concat(this.id,'". Try adding { initial: "').concat(Object.keys(this.states)[0],'" } to the state config.'));this.history=!0===this.config.history?"shallow":this.config.history||!1,this.entry=(0,i.t)(this.config.entry).slice(),this.exit=(0,i.t)(this.config.exit).slice(),this.meta=this.config.meta,this.output="final"!==this.type&&this.parent?void 0:this.config.output,this.tags=(0,i.t)(t.tags).slice()}_initialize(){this.transitions=(0,i.q)(this),this.config.always&&(this.always=(0,i.u)(this.config.always).map(t=>(0,i.v)(this,i.N,t))),Object.keys(this.states).forEach(t=>{this.states[t]._initialize()})}get definition(){return{id:this.id,key:this.key,version:this.machine.version,type:this.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(v),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(t=>"#".concat(t.id)),source:"#".concat(this.id),actions:this.initial.actions.map(v),eventType:null})}:void 0,history:this.history,states:(0,i.l)(this.states,t=>t.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(t=>(0,r.A)((0,r.A)({},t),{},{actions:t.actions.map(v)})),entry:this.entry.map(v),exit:this.exit.map(v),meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}toJSON(){return this.definition}get invoke(){return l(this,"invoke",()=>(0,i.t)(this.config.invoke).map((t,e)=>{var n,s=t.src,o=t.systemId,c=null!==(n=t.id)&&void 0!==n?n:(0,i.x)(this.id,e),h="string"===typeof s?s:"xstate.invoke.".concat((0,i.x)(this.id,e));return(0,r.A)((0,r.A)({},t),{},{src:h,id:c,systemId:o,toJSON(){t.onDone,t.onError;var e=(0,a.A)(t,u);return(0,r.A)((0,r.A)({},e),{},{type:"xstate.invoke",src:h,id:c})}})}))}get on(){return l(this,"on",()=>[...this.transitions].flatMap(t=>{var e=(0,o.A)(t,2),n=e[0];return e[1].map(t=>[n,t])}).reduce((t,e)=>{var n=(0,o.A)(e,2),r=n[0],i=n[1];return t[r]=t[r]||[],t[r].push(i),t},{}))}get after(){return l(this,"delayedTransitions",()=>(0,i.y)(this))}get initial(){return l(this,"initial",()=>(0,i.z)(this,this.config.initial))}next(t,e){var n,r,o=e.type,a=[],c=l(this,"candidates-".concat(o),()=>(0,i.B)(this,o)),u=(0,s.A)(c);try{for(u.s();!(r=u.n()).done;){var h=r.value,d=h.guard,v=t.context,f=!1;try{f=!d||(0,i.w)(d,v,e,t)}catch(y){var p="string"===typeof d?d:"object"===typeof d?d.type:void 0;throw new Error("Unable to evaluate guard ".concat(p?"'".concat(p,"' "):"","in transition for event '").concat(o,"' in state node '").concat(this.id,"':\n").concat(y.message))}if(f){a.push(...h.actions),n=h;break}}}catch(y){u.e(y)}finally{u.f()}return n?[n]:void 0}get events(){return l(this,"events",()=>{var t=this.states,e=new Set(this.ownEvents);if(t)for(var n=0,r=Object.keys(t);nthis.transitions.get(t).some(t=>!(!t.target&&!t.actions.length&&!t.reenter))));return Array.from(t)}}class p{constructor(t,e){var n,r,i,s;this.config=t,this.version=void 0,this.schemas=void 0,this.implementations=void 0,this.__xstatenode=!0,this.idMap=new Map,this.root=void 0,this.id=void 0,this.states=void 0,this.events=void 0,this.id=t.id||"(machine)",this.implementations={actors:null!==(n=null===e||void 0===e?void 0:e.actors)&&void 0!==n?n:{},actions:null!==(r=null===e||void 0===e?void 0:e.actions)&&void 0!==r?r:{},delays:null!==(i=null===e||void 0===e?void 0:e.delays)&&void 0!==i?i:{},guards:null!==(s=null===e||void 0===e?void 0:e.guards)&&void 0!==s?s:{}},this.version=this.config.version,this.schemas=this.config.schemas,this.transition=this.transition.bind(this),this.getInitialSnapshot=this.getInitialSnapshot.bind(this),this.getPersistedSnapshot=this.getPersistedSnapshot.bind(this),this.restoreSnapshot=this.restoreSnapshot.bind(this),this.start=this.start.bind(this),this.root=new f(t,{_key:this.id,_machine:this}),this.root._initialize(),this.states=this.root.states,this.events=this.root.events}provide(t){var e=this.implementations,n=e.actions,i=e.guards,s=e.actors,o=e.delays;return new p(this.config,{actions:(0,r.A)((0,r.A)({},n),t.actions),guards:(0,r.A)((0,r.A)({},i),t.guards),actors:(0,r.A)((0,r.A)({},s),t.actors),delays:(0,r.A)((0,r.A)({},o),t.delays)})}resolveState(t){var e=(0,i.C)(this.root,t.value),n=(0,i.D)((0,i.g)(this.root,e));return(0,i.E)({_nodes:[...n],context:t.context||{},children:{},status:(0,i.F)(n,this.root)?"done":t.status||"active",output:t.output,error:t.error,historyValue:t.historyValue},this)}transition(t,e,n){return(0,i.G)(t,e,n,[]).snapshot}microstep(t,e,n){return(0,i.G)(t,e,n,[]).microstates}getTransitionData(t,e){return(0,i.H)(this.root,t.value,t,e)||[]}getPreInitialState(t,e,n){var r=this.config.context,s=(0,i.E)({context:"function"!==typeof r&&r?r:{},_nodes:[this.root],children:{},status:"active"},this);if("function"===typeof r){return(0,i.I)(s,e,t,[(0,c.a)(t=>{var e=t.spawn,n=t.event,i=t.self;return r({spawn:e,input:n.input,self:i})})],n,void 0)}return s}getInitialSnapshot(t,e){var n=(0,i.J)(e),r=[],s=this.getPreInitialState(t,n,r),o=(0,i.K)([{target:[...(0,i.L)(this.root)],source:this.root,reenter:!0,actions:[],eventType:null,toJSON:null}],s,t,n,!0,r);return(0,i.G)(o,n,t,r).snapshot}start(t){Object.values(t.children).forEach(t=>{"active"===t.getSnapshot().status&&t.start()})}getStateNodeById(t){var e=(0,i.M)(t),n=e.slice(1),r=(0,i.O)(e[0])?e[0].slice(1):e[0],s=this.idMap.get(r);if(!s)throw new Error("Child state node '#".concat(r,"' does not exist on machine '").concat(this.id,"'"));return(0,i.P)(s,n)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(t,e){return(0,i.Q)(t,e)}restoreSnapshot(t,e){var n={},o=t.children;function a(t,e){if(e instanceof f)return e;try{return t.machine.getStateNodeById(e.id)}catch(n){}}Object.keys(o).forEach(t=>{var r=o[t],s=r.snapshot,a=r.src,c="string"===typeof a?(0,i.R)(this,a):a;if(c){var u=(0,i.c)(c,{id:t,parent:e.self,syncSnapshot:r.syncSnapshot,snapshot:s,src:a,systemId:r.systemId});n[t]=u}});var c=function(t,e){if(!e||"object"!==typeof e)return{};var n={};for(var r in e){var i,o=e[r],c=(0,s.A)(o);try{for(c.s();!(i=c.n()).done;){var u,h=a(t,i.value);h&&(null!==(u=n[r])&&void 0!==u||(n[r]=[]),n[r].push(h))}}catch(l){c.e(l)}finally{c.f()}}return n}(this.root,t.historyValue),u=(0,i.E)((0,r.A)((0,r.A)({},t),{},{children:n,_nodes:Array.from((0,i.D)((0,i.g)(this.root,t.value))),historyValue:c}),this),h=new Set;return function t(e,n){if(!h.has(e))for(var r in h.add(e),e){var s=e[r];if(s&&"object"===typeof s){if("xstate$$type"in s&&s.xstate$$type===i.$){e[r]=n[s.id];continue}t(s,n)}}}(u.context,n),u}}var y=n(52652);function g(t){var e=t.schemas,n=t.actors,s=t.actions,o=t.guards,a=t.delays;return{assign:c.a,sendTo:y.s,raise:i.r,log:y.l,cancel:i.a,stopChild:i.s,enqueueActions:y.e,emit:y.a,spawnChild:i.b,createStateConfig:t=>t,createAction:t=>t,createMachine:t=>function(t,e){return new p(t,e)}((0,r.A)((0,r.A)({},t),{},{schemas:e}),{actors:n,actions:s,guards:o,delays:a})}}var m={timeout:1/0};function _(t,e,n){var i=(0,r.A)((0,r.A)({},m),n);return new Promise((n,r)=>{var s=i.signal;if(null!==s&&void 0!==s&&s.aborted)r(s.reason);else{var o,a,c=!1,u=i.timeout===1/0?void 0:setTimeout(()=>{h(),r(new Error("Timeout of ".concat(i.timeout," ms exceeded")))},i.timeout),h=()=>{var t;clearTimeout(u),c=!0,null===(t=a)||void 0===t||t.unsubscribe(),o&&s.removeEventListener("abort",o)};l(t.getSnapshot()),c||(s&&(o=()=>{h(),r(s.reason)},s.addEventListener("abort",o)),a=t.subscribe({next:l,error:t=>{h(),r(t)},complete:()=>{h(),r(new Error("Actor terminated without satisfying predicate"))}}),c&&a.unsubscribe())}function l(t){e(t)&&(h(),n(t))}})}},73857:(t,e,n)=>{n.d(e,{a:()=>a});var r=n(57970),i=n(24758);function s(t,e,n,r){var s=e.machine,o=e.context;return(e,a)=>{var c=((e,a)=>{if("string"===typeof e){var c=(0,i.R)(s,e);if(!c)throw new Error("Actor logic '".concat(e,"' not implemented in machine '").concat(s.id,"'"));var u=(0,i.c)(c,{id:null===a||void 0===a?void 0:a.id,parent:t.self,syncSnapshot:null===a||void 0===a?void 0:a.syncSnapshot,input:"function"===typeof(null===a||void 0===a?void 0:a.input)?a.input({context:o,event:n,self:t.self}):null===a||void 0===a?void 0:a.input,src:e,systemId:null===a||void 0===a?void 0:a.systemId});return r[u.id]=u,u}return(0,i.c)(e,{id:null===a||void 0===a?void 0:a.id,parent:t.self,syncSnapshot:null===a||void 0===a?void 0:a.syncSnapshot,input:null===a||void 0===a?void 0:a.input,src:e,systemId:null===a||void 0===a?void 0:a.systemId})})(e,a);return r[c.id]=c,t.defer(()=>{c._processingStatus!==i.V.Stopped&&c.start()}),c}}function o(t,e,n,o,a){var c=a.assignment;if(!e.context)throw new Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");var u={},h={context:e.context,event:n.event,spawn:s(t,e,n.event,u),self:t.self,system:t.system},l={};if("function"===typeof c)l=c(h,o);else for(var d=0,v=Object.keys(c);d