1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,627897,e=>{"use strict";let t,r="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),n=new Uint8Array(16),s=[];for(let e=0;e<256;++e)s.push((e+256).toString(16).slice(1));e.s(["v4",0,function(e,i,o){if(r&&!i&&!e)return r();var a=e,c=o;let u=(a=a||{}).random??a.rng?.()??function(){if(!t){if("u"<typeof crypto||!crypto.getRandomValues)throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");t=crypto.getRandomValues.bind(crypto)}return t(n)}();if(u.length<16)throw Error("Random bytes length must be >= 16");if(u[6]=15&u[6]|64,u[8]=63&u[8]|128,i){if((c=c||0)<0||c+16>i.length)throw RangeError(`UUID byte range ${c}:${c+15} is out of buffer bounds`);for(let e=0;e<16;++e)i[c+e]=u[e];return i}return function(e,t=0){return(s[e[t+0]]+s[e[t+1]]+s[e[t+2]]+s[e[t+3]]+"-"+s[e[t+4]]+s[e[t+5]]+"-"+s[e[t+6]]+s[e[t+7]]+"-"+s[e[t+8]]+s[e[t+9]]+"-"+s[e[t+10]]+s[e[t+11]]+s[e[t+12]]+s[e[t+13]]+s[e[t+14]]+s[e[t+15]]).toLowerCase()}(u)}],627897)},894241,439753,e=>{"use strict";var t;let r=t=>{if("u"<typeof window)return;let r=function(){let t="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:e.g;if(t.__xstate__)return t.__xstate__}();r&&r.register(t)};e.s(["devToolsAdapter",()=>r],439753);class n{constructor(e){this._process=e,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(e){let t={value:e,next:null};if(this._current){this._last.next=t,this._last=t;return}this._current=t,this._last=t,this._active&&this.flush()}flush(){for(;this._current;){let e=this._current;this._process(e.value),this._current=e.next}this._last=null}}let s="xstate.init",i="xstate.stop";function o(e,t){return{type:`xstate.done.state.${e}`,output:t}}function a(e,t){return{type:`xstate.error.actor.${e}`,error:t,actorId:e}}function c(e){return{type:s,input:e}}function u(e){setTimeout(()=>{throw e})}let l="function"==typeof Symbol&&Symbol.observable||"@@observable";function d(e){if(v(e))return e;let t=[],r="";for(let n=0;n<e.length;n++){switch(e.charCodeAt(n)){case 92:r+=e[n+1],n++;continue;case 46:t.push(r),r="";
1continue}r+=e[n]}return t.push(r),t}function p(e){var t;return(t=e)&&"object"==typeof t&&"machine"in t&&"value"in t?e.value:"string"!=typeof e?e:function(e){if(1===e.length)return e[0];let t={},r=t;for(let t=0;t<e.length-1;t++)if(t===e.length-2)r[e[t]]=e[t+1];else{let n=r;r={},n[e[t]]=r}return t}(d(e))}function h(e,t){let r={},n=Object.keys(e);for(let s=0;s<n.length;s++){let i=n[s];r[i]=t(e[i],i,e,s)}return r}function f(e){var t;return void 0===e?[]:v(t=e)?t:[t]}function y(e,t,r,n){return"function"==typeof e?e({context:t,event:r,self:n}):e}function v(e){return Array.isArray(e)}function g(e){var t;return(v(t=e)?t:[t]).map(e=>void 0===e||"string"==typeof e?{target:e}:e)}function m(e){if(void 0!==e&&""!==e)return f(e)}function b(e,t,r){let n="object"==typeof e,s=n?e:void 0;return{next:(n?e.next:e)?.bind(s),error:(n?e.error:t)?.bind(s),complete:(n?e.complete:r)?.bind(s)}}function _(e,t){return`${t}.${e}`}function S(e,t){let r=t.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!r)return e.implementations.actors[t];let[,n,s]=r,i=e.getStateNodeById(s).config.invoke;return(Array.isArray(i)?i[n]:i).src}function x(e,t){if(t===e||"*"===t)return!0;if(!t.endsWith(".*"))return!1;let r=t.split("."),n=e.split(".");for(let e=0;e<r.length;e++){let t=r[e],s=n[e];if("*"===t)return e===r.length-1;if(t!==s)return!1}return!0}function w(e,t){return`${e.sessionId}.${t}`}let E=0,k=!1,T=((t={})[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped",t),I={clock:{setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},logger:console.log.bind(console),devTools:!1};class A{constructor(e,t){this.logic=e,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new n(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=T.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this.systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];const r={...I,...t},{clock:s,logger:i,parent:o,syncSnapshot:a,id:c,systemId:l,inspect:d}=r;this.system=o?o.system:function(e,t){let r=new Map,n=new Map,s=new WeakMap,i=new Set,o={},{clock:a,logger:c}=t,u={schedule:(e,t,r,n,s=Math.random().toString(36).slice(2))=>{let i={source:e,target:t,event:r,delay:n,id:s,startedAt:Date.now()},c=w(e,s);l._snapshot._scheduledEvents[c]=i;let u=a.setTimeout(()=>{delete o[c],delete l._snapshot._scheduledEvents[c],l._relay(e,t,r)},n);o[c]=u},cancel:(e,t)=>{let r=w(e,t),n=o[r];delete o[r],delete l._snapshot._scheduledEvents[r],void 0!==n&&a.clearTimeout(n)},cancelAll:e=>{for(let t in l._snapshot._scheduledEvents){let r=l._snapshot._scheduledEvents[t];r.source===e&&u.cancel(e,r.id)}}},l={_snapshot:{_scheduledEvents:(t?.snapshot&&t.snapshot.scheduler)??{}},_bookId:()=>`x:${E++}`,_register:(e,t)=>(r.set(e,t),e),_unregister:e=>{r.delete(e.sessionId);let t=s.get(e);void 0!==t&&(n.delete(t),s.delete(e))},get:e=>n.get(e),getAll:()=>Object.fromEntries(n.entries()),_set:(e,t)=>{let r=n.get(e);if(r&&r!==t)throw Error(`Actor with system ID '${e}' already exists.`);n.set(e,t),s.set(t,e)},inspect:e=>{let t=b(e);return i.add(t),{unsubscribe(){i.delete(t)}}},_sendInspectionEvent:t=>{if(!i.size)return;let r={...t,rootId:e.sessionId};i.forEach(e=>e.next?.(r))},_relay:(e,t,r)=>{l._sendInspectionEvent({type:"@xstate.event",sourceRef:e,actorRef:t,event:r}),t._send(r)},scheduler:u,getSnapshot:()=>({_scheduledEvents:{...l._snapshot._scheduledEvents}}),start:()=>{let e=l._snapshot._scheduledEvents;for(let t in l._snapshot._scheduledEvents={},e){let{source:r,target:n,event:s,delay:i,id:o}=e[t];u.schedule(r,n,s,i,o)}},_clock:a,_logger:c};return l}(this,{clock:s,logger:i}),d&&!o&&this.system.inspect(b(d)),this.sessionId=this.system._bookId(),this.id=c??this.sessionId,this.logger=t?.logger??this.system._logger,this.clock=t?.clock??this.system._clock,this._parent=o,this._syncSnapshot=a,this.options=r,this.src=r.src??e,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:e=>{this._deferred.push(e)},system:this.system,stopChild:e=>
1{if(e._parent!==this)throw Error(`Cannot stop child actor ${e.id} of ${this.id} because it is not a child`);e._stop()},emit:e=>{let t=this.eventListeners.get(e.type),r=this.eventListeners.get("*");if(t||r)for(let n of[...t?t.values():[],...r?r.values():[]])try{n(e)}catch(e){u(e)}},actionExecutor:e=>{let t=()=>{if(this._actorScope.system._sendInspectionEvent({type:"@xstate.action",actorRef:this,action:{type:e.type,params:e.params}}),!e.exec)return;let t=k;try{k=!0,e.exec(e.info,e.params)}finally{k=t}};this._processingStatus===T.Running?t():this._deferred.push(t)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),l&&(this.systemId=l,this.system._set(l,this)),this._initState(t?.snapshot??t?.state),l&&"active"!==this._snapshot.status&&this.system._unregister(this)}_initState(e){try{this._snapshot=e?this.logic.restoreSnapshot?this.logic.restoreSnapshot(e,this._actorScope):e:this.logic.getInitialSnapshot(this._actorScope,this.options?.input)}catch(e){this._snapshot={status:"error",output:void 0,error:e}}}update(e,t){let r;for(this._snapshot=e;r=this._deferred.shift();)try{r()}catch(t){this._deferred.length=0,this._snapshot={...e,status:"error",error:t}}switch(this._snapshot.status){case"active":for(let t of this.observers)try{t.next?.(e)}catch(e){u(e)}break;case"done":var n;for(let t of this.observers)try{t.next?.(e)}catch(e){u(e)}this._stopProcedure(),this._complete(),this._doneEvent=(n=this.id,{type:`xstate.done.actor.${n}`,output:this._snapshot.output,actorId:n}),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:t,snapshot:e})}subscribe(e,t,r){let n=b(e,t,r);if(this._processingStatus!==T.Stopped)this.observers.add(n);else switch(this._snapshot.status){case"done":try{n.complete?.()}catch(e){u(e)}break;case"error":{let e=this._snapshot.error;if(n.error)try{n.error(e)}catch(e){u(e)}else u(e)}}return{unsubscribe:()=>{this.observers.delete(n)}}}on(e,t){let r=this.eventListeners.get(e);r||(r=new Set,this.eventListeners.set(e,r));let n=t.bind(void 0);return r.add(n),{unsubscribe:()=>{r.delete(n)}}}start(){if(this._processingStatus===T.Running)return this;this._syncSnapshot&&this.subscribe({next:e=>{"active"===e.status&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:e})},error:()=>{}}),this.system._register(this.sessionId,this),this.systemId&&this.system._set(this.systemId,this),this._processingStatus=T.Running;let e=c(this.options.input);switch(this.system._sendInspectionEvent({type:"@xstate.event",sourceRef:this._parent,actorRef:this,event:e}),this._snapshot.status){case"done":return this.update(this._snapshot,e),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={...this._snapshot,status:"error",error:e},this._error(e),this}return this.update(this._snapshot,e),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(e){let t,r;try{t=this.logic.transition(this._snapshot,e,this._actorScope)}catch(e){r={err:e}}if(r){let{err:e}=r;this._snapshot={...this._snapshot,status:"error",error:e},this._error(e);return}this.update(t,e),e.type===i&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===T.Stopped||((this.mailbox.clear(),this._processingStatus===T.NotStarted)?this._processingStatus=T.Stopped:this.mailbox.enqueue({type:i})),this}stop(){if(this._parent)throw Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){for(let e of this.observers)try{e.complete?.()}catch(e){u(e)}this.observers.clear(),this.eventListeners.clear()}_reportError(e){if(!this.observers.size){this._parent||u(e),this.eventListeners.clear();return}let t=!1;for(let r of this.observers){let n=r.error;t||=!n;try{n?.(e)}catch(e){u(e)}}this.observers.clear(),this.eventListeners.clear(),t&&u(e)}_error(e){this._stopProcedure(),this._reportError(e),this._parent&&this.system._relay(this,this._parent,a(this.id,e))}_stopProcedure(){return this._processingStatus!==T.Running||(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new n(this._process.bind(this)),this._processingStatus=T.Stopped,this.system._unregister(this)),this}_send(e){this._processingStatus!==T.Stopped&&this.mailbox.enqueue(e)}send(e){this.system._relay(void 0,this,e)}attachDevTools(){let{devTools:e}=this.options;e&&("function"==typeof e?e:r)(this)}toJSON(){return{xstate$$type:1,id:this.id}}getPersistedSnapshot(e){return this.logic.getPersistedSnapshot(this._snapshot,e)}[l](){return this}getSnapshot(){return this._snapshot}}function q(e,...[t]){return new A(e,t)}function O(e,t,r,n,{sendId:s}){return[t,{sendId:"function"==typeof s?s(r,n):s},void 0]}function $(e,t){e.defer(()=>{e.system.scheduler.cancel(e.self,t.sendId)})}function R(e){function t(e,t){}return t.type="xstate.cancel",t.sendId=e,t.resolve=O,t.execute=$,t}function M(e,t,r,n,{id:s,systemId:i,src:o,input:a,syncSnapshot:c}){let u,l,d="string"==typeof o?S(t.machine,o):o,p="function"==typeof s?s(r):s;return d&&(l="function"==typeof a?a({context:t.context,event:r.event,self:e.self}):a,u=q(d,{id:p,src:o,parent:e.self,syncSnapshot:c,systemId:i,input:l})),[eq(t,{children:{...t.children,[p]:u}}),{id:s,systemId:i,actorRef:u,src:o,input:l},void 0]}function P(e,{actorRef:t}){t&&e.defer(()=>{t._processingStatus!==T.Stopped&&t.start()})}function j(...[e,{id:t,systemId:r,input:n,syncSnapshot:s=!1}={}]){function i(e,t){}return i.type="xstate.spawnChild",i.id=t,i.systemId=r,i.src=e,i.input=n,i.syncSnapshot=s,i.resolve=M,i.execute=P,i}function N(e,t,r,n,{actorRef:s}){let i="function"==typeof s?s(r,n):s,o="string"==typeof i?t.children[i]:i,a=t.children;return o&&(a={...a},delete a[o.id]),[eq(t,{children:a}),o,void 0]}function C(e,t){if(t){if(!function e(t,r){let n=r.getSnapshot();if(n&&"children"in n)for(let r of Object.values(n.children))e(t,r);t.system._unregister(r)}(e,t),t._processingStatus!==T.Running)return void e.stopChild(t);e.defer(()=>{e.stopChild(t)})}}function F(e){function t(e,t){}return t.type="xstate.stopChild",t.actorRef=e,t.resolve=N,t.execute=C,t}function D(e,{context:t,event:r},{guards:n}){return!B(n[0],t,r,e)}function L(e){function t(e,t){return!1}return t.check=D,t.guards=[e],t}function U(e,{context:t,event:r},{guards:n}){return n.every(n=>B(n,t,r,e))}function z(e){function t(e,t){return!1}return t.check=U,t.guards=e,t}function B(e,t,r,n){let{machine:s}=n,i="function"==typeof e,o=i?e:s.implementations.guards["string"==typeof e?e:e.type];if(!i&&!o)throw Error(`Guard '${"string"==typeof e?e:e.type}' is not implemented.'.`);if("function"!=typeof o)return B(o,t,r,n);let a={context:t,event:r},c=i||"string"==typeof e?void 0:"params"in e?"function"==typeof e.params?e.params({context:t,event:r}):e.params:void 0;return"check"in o?o.check(n,a,o):o(a,c)}let V=e=>"atomic"===e.type||"final"===e.type;function H(e){return Object.values(e.states).filter(e=>"history"!==e.type)}function W(e,t){let r=[];if(t===e)return r;let n=e.parent;for(;n&&n!==t;)r.push(n),n=n.parent;return r}function J(e){let t=new Set(e),r=Y(t);for(let e of t)if("compound"!==e.type||r.get(e)&&r.get(e).length){if("parallel"===e.type){for(let r of H(e))if("history"!==r.type&&!t.has(r))for(let e of ei(r))t.add(e)}}
1else ei(e).forEach(e=>t.add(e));for(let e of t){let r=e.parent;for(;r;)t.add(r),r=r.parent}return t}function Y(e){let t=new Map;for(let r of e)t.has(r)||t.set(r,[]),r.parent&&(t.has(r.parent)||t.set(r.parent,[]),t.get(r.parent).push(r));return t}function G(e,t){return function e(t,r){let n=r.get(t);if(!n)return{};if("compound"===t.type){let e=n[0];if(!e)return{};if(V(e))return e.key}let s={};for(let t of n)s[t.key]=e(t,r);return s}(e,Y(J(t)))}function K(e,t){return"compound"===t.type?H(t).some(t=>"final"===t.type&&e.has(t)):"parallel"===t.type?H(t).every(t=>K(e,t)):"final"===t.type}let X=e=>"#"===e[0];function Q(e,t){return e.transitions.get(t)||[...e.transitions.keys()].filter(e=>x(t,e)).sort((e,t)=>t.length-e.length).flatMap(t=>e.transitions.get(t))}function Z(e){let t=e.config.after;return t?Object.keys(t).flatMap(r=>{var n;let s,i,o=t[r],a=Number.isNaN(+r)?r:+r,c=(n=e.id,i=(s={type:`xstate.after.${a}.${n}`}).type,e.entry.push(eM(s,{id:i,delay:a})),e.exit.push(R(i)),i);return f("string"==typeof o?{target:o}:o).map(e=>({...e,event:c,delay:a}))}).map(t=>{let{delay:r}=t;return{...ee(e,t.event,t),delay:r}}):[]}function ee(e,t,r){let n=m(r.target),s=r.reenter??!1,i=function(e,t){if(void 0!==t)return t.map(t=>{if("string"!=typeof t)return t;if(X(t))return e.machine.getStateNodeById(t);let r="."===t[0];if(r&&!e.parent)return ec(e,t.slice(1));let n=r?e.key+t:t;if(e.parent)try{return ec(e.parent,n)}catch(t){throw Error(`Invalid transition definition for state node '${e.id}': 2${t.message}`)}throw Error(`Invalid target: "${t}" is not a valid target from the root node. Did you mean ".${t}"?`)})}(e,n),o={...r,actions:f(r.actions),guard:r.guard,target:i,source:e,reenter
2:s,eventType:t,toJSON:()=>({...o,source:`#${e.id}`,target:i?i.map(e=>`#${e.id}`):void 0})};return o}function et(e){let t=new Map;if(e.config.on)for(let r of Object.keys(e.config.on)){if(""===r)throw Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');let n=e.config.on[r];t.set(r,g(n).map(t=>ee(e,r,t)))}if(e.config.onDone){let r=`xstate.done.state.${e.id}`;t.set(r,g(e.config.onDone).map(t=>ee(e,r,t)))}for(let r of e.invoke){if(r.onDone){let n=`xstate.done.actor.${r.id}`;t.set(n,g(r.onDone).map(t=>ee(e,n,t)))}if(r.onError){let n=`xstate.error.actor.${r.id}`;t.set(n,g(r.onError).map(t=>ee(e,n,t)))}if(r.onSnapshot){let n=`xstate.snapshot.${r.id}`;t.set(n,g(r.onSnapshot).map(t=>ee(e,n,t)))}}for(let r of e.after){let e=t.get(r.eventType);e||(e=[],t.set(r.eventType,e)),e.push(r)}return t}function er(e,t){let r="string"==typeof t?e.states[t]:t?e.states[t.target]:void 0;if(!r&&t)throw Error(`Initial state node "${t}" not found on parent state node #${e.id}`);let n={source:e,actions:t&&"string"!=typeof t?f(t.actions):[],eventType:null,reenter:!1,target:r?[r]:[],toJSON:()=>({...n,source:`#${e.id}`,target:r?[`#${r.id}`]:[]})};return n}function en(e){let t=m(e.config.target);return t?{target:t.map(t=>"string"==typeof t?ec(e.parent,t):t)}:e.parent.initial}function es(e){return"history"===e.type}function ei(e){let t=eo(e);for(let r of t)for(let n of W(r,e))t.add(n);return t}function eo(e){let t=new Set;return!function e(r){if(!t.has(r)){if(t.add(r),"compound"===r.type)e(r.initial.target[0]);else if("parallel"===r.type)for(let t of H(r))e(t)}}(e),t}function ea(e,t){if(X(t))return e.machine.getStateNodeById(t);if(!e.states)throw Error(`Unable to retrieve child state '${t}' from '${e.id}'; no child states exist.`);let r=e.states[t];if(!r)throw Error(`Child state '${t}' does not exist on '${e.id}'`);return r}function ec(e,t){if("string"==typeof t&&X(t))try{return e.machine.getStateNodeById(t)}catch{}let r=d(t).slice(),n=e;for(;r.length;){let e=r.shift();if(!e.length)break;n=ea(n,e)}return n}function eu(e,t){if("string"==typeof t){let r=e.states[t];if(!r)throw Error(`State '${t}' does not exist on '${e.id}'`);return[e,r]}let r=Object.keys(t),n=r.map(t=>ea(e,t)).filter(Boolean);return[e.machine.root,e].concat(n,r.reduce((r,n)=>{let s=ea(e,n);if(!s)return r;let i=eu(s,t[n]);return r.concat(i)},[]))}function el(e,t){let r=e;for(;r.parent&&r.parent!==t;)r=r.parent;return r.parent===t}function ed(e,t,r){let n=new Set;for(let s of e){let e=!1,i=new Set;for(let o of n)if(function(e,t){let r=new Set(e),n=new Set(t);for(let e of r)if(n.has(e))return!0;for(let e of n)if(r.has(e))return!0;return!1}(ef([s],t,r),ef([o],t,r)))if(el(s.source,o.source))i.add(o);else{e=!0;break}if(!e){for(let e of i)n.delete(e);n.add(s)}}return Array.from(n)}function ep(e,t){if(!e.target)return[];let r=new Set;for(let n of e.target)if(es(n))if(t[n.id])for(let e of t[n.id])r.add(e);else for(let e of ep(en(n),t))r.add(e);else r.add(n);return[...r]}function eh(e,t){let r=ep(e,t);if(!r)return;if(!e.reenter&&r.every(t=>t===e.source||el(t,e.source)))return e.source;let n=function(e){let[t,...r]=e;for(let e of W(t,void 0))if(r.every(t=>el(t,e)))return e}(r.concat(e.source));return n||(e.reenter?void 0:e.source.machine.root)}function ef(e,t,r){let n=new Set;for(let s of e)if(s.target?.length){let e=eh(s,r);for(let r of(s.reenter&&s.source===e&&n.add(e),t))el(r,e)&&n.add(r)}return[...n]}function ey(e,t,r,n,s,i){if(!e.length)return t;let a=new Set(t._nodes),c=t.historyValue,u=ed(e,a,c),l=t;s||([l,c]=function(e,t,r,n,s,i,o,a){let c,u=e,l=ef(n,s,i);for(let e of(l.sort((e,t)=>t.order-e.order),l))for(let t of function(e){return Object.keys(e.states).map(t=>e.states[t]).filter(e=>"history"===e.type)}(e)){let r;r="deep"===t.history?t=>V(t)&&el(t,e):t=>t.parent===e,(c??={...i})[t.id]=Array.from(s).filter(r)}for(let e of l)u=em(u,t,r,[...e.exit,...e.invoke.map(e=>F(e.id))],o,void 0),s.delete(e);return[u,c||i]}(l,n,r,u,a,c,i,r.actionExecutor)),l=function(e,t,r,n,s,i,a,c){let u=e,l=new Set,d=new Set;(function(e,t,r,n){for(let s of e){let e=eh(s,t);for(let i of s.target||[])!es(i)&&(s.source!==i||s.source!==e||s.reenter)&&(n.add(i),r.add(i)),ev(i,t,r,n);for(let i of ep(s,t)){let o=W(i,e);e?.type==="parallel"&&o.push(e),eg(n,t,r,o,!s.source.parent&&s.reenter?void 0:e)}}})(n,a,d,l),c&&d.add(e.machine.root);let p=new Set;for(let e of[...l].sort((e,t)=>
2e.order-t.order)){s.add(e);let n=[];for(let t of(n.push(...e.entry),e.invoke))n.push(j(t.src,{...t,syncSnapshot:!!t.onSnapshot}));if(d.has(e)){let t=e.initial.actions;n.push(...t)}if(u=em(u,t,r,n,i,e.invoke.map(e=>e.id)),"final"===e.type){let n=e.parent,a=n?.type==="parallel"?n:n?.parent,c=a||e;for(n?.type==="compound"&&i.push(o(n.id,void 0!==e.output?y(e.output,u.context,t,r.self):void 0));a?.type==="parallel"&&!p.has(a)&&K(s,a);)p.add(a),i.push(o(a.id)),c=a,a=a.parent;if(a)continue;u=eq(u,{status:"done",output:function(e,t,r,n,s){if(void 0===n.output)return;let i=o(s.id,void 0!==s.output&&s.parent?y(s.output,e.context,t,r.self):void 0);return y(n.output,e.context,i,r.self)}(u,t,r,u.machine.root,c)})}}return u}(l=em(l,n,r,u.flatMap(e=>e.actions),i,void 0),n,r,u,a,i,c,s);let d=[...a];"done"===l.status&&(l=em(l,n,r,d.sort((e,t)=>t.order-e.order).flatMap(e=>e.exit),i,void 0));try{if(c===t.historyValue&&function(e,t){if(e.length!==t.size)return!1;for(let r of e)if(!t.has(r))return!1;return!0}(t._nodes,a))return l;return eq(l,{_nodes:d,historyValue:c})}catch(e){throw e}}function ev(e,t,r,n){var s,i,o,a;if(es(e))if(t[e.id]){let o=t[e.id];for(let e of o)n.add(e),ev(e,t,r,n);for(let a of o){s=a,i=e.parent,eg(n,t,r,W(s,i))}}else{let s=en(e);for(let i of s.target)n.add(i),s===e.parent?.initial&&r.add(e.parent),ev(i,t,r,n);for(let i of s.target){o=i,a=e.parent,eg(n,t,r,W(o,a))}}else if("compound"===e.type){let[s]=e.initial.target;es(s)||(n.add(s),r.add(s)),ev(s,t,r,n),eg(n,t,r,W(s,e))}else if("parallel"===e.type)for(let s of H(e).filter(e=>!es(e)))[...n].some(e=>el(e,s))||(es(s)||(n.add(s),r.add(s)),ev(s,t,r,n))}function eg(e,t,r,n,s){for(let i of n)if((!s||el(i,s))&&e.add(i),"parallel"===i.type)for(let n of H(i).filter(e=>!es(e)))[...e].some(e=>el(e,n))||(e.add(n),ev(n,t,r,e))}function em(e,t,r,n,s,i){let o=i?[]:void 0,a=function e(t,r,n,s,i,o){let{machine:a}=t,c=t;for(let t of s){var u;let s="function"==typeof t,l=s?t:(u="string"==typeof t?t:t.type,a.implementations.actions[u]),d={context:c.context,event:r,self:n.self,system:n.system},p=s||"string"==typeof t?void 0:"params"in t?"function"==typeof t.params?t.params({context:c.context,event:r}):t.params:void 0;if(!l||!("resolve"in l)){n.actionExecutor({type:"string"==typeof t?t:"object"==typeof t?t.type:t.name||"(anonymous)",info:d,params:p,exec:l});continue}let[h,f,y]=l.resolve(n,c,d,p,l,i);c=h,"retryResolve"in l&&o?.push([l,f]),"execute"in l&&n.actionExecutor({type:l.type,info:d,params:f,exec:l.execute.bind(null,n,f)}),y&&(c=e(c,r,n,y,i,o))}return c}(e,t,r,n,{internalQueue:s,deferredActorIds:i},o);return o?.forEach(([e,t])=>{e.retryResolve(r,a,t)}),a}function eb(e,t,r,n){let o=e,a=[];function c(e,t,n){r.system._sendInspectionEvent({type:"@xstate.microstep",actorRef:r.self,event:t,snapshot:e,_transitions:n}),a.push(e)}if(t.type===i)return c(o=eq(e_(o,t,r),{status:"stopped"}),t,[]),{snapshot:o,microstates:a};let u=t;if(u.type!==s){let t=u,s=t.type.startsWith("xstate.error.actor"),i=eS(t,o);if(s&&!i.length)return c(o=eq(e,{status:"error",error:t.error}),t,[]),{snapshot:o,microstates:a};c(o=ey(i,e,r,u,!1,n),t,i)}let l=!0;for(;"active"===o.status;){let e=l?function(e,t){let r=new Set;for(let n of e._nodes.filter(V))e:for(let s of[n].concat(W(n,void 0)))if(s.always){for(let n of s.always)if(void 0===n.guard||B(n.guard,e.context,t,e)){r.add(n);break e}}return ed(Array.from(r),new Set(e._nodes),e.historyValue)}(o,u):[],t=e.length?o:void 0;if(!e.length){if(!n.length)break;e=eS(u=n.shift(),o)}l=(o=ey(e,o,r,u,!1,n))!==t,c(o,u,e)}return"active"!==o.status&&e_(o,u,r),{snapshot:o,microstates:a}}function e_(e,t,r){return em(e,t,r,Object.values(e.children).map(e=>F(e)),[],void 0)}function eS(e,t){return t.machine.getTransitionData(t,e)}function ex(e,t){let r=J(eu(e,t));return G(e,[...r])}let ew=function(e){return function e(t,r){let n=p(t),s=p(r);return"string"==typeof s?"string"==typeof n&&s===n:"string"==typeof n?n in s:Object.keys(n).every(t=>t in s&&e(n[t],s[t]))}(e,this.value)},eE=function(e){return this.tags.has(e)},ek=function(e){let t=this.machine.getTransitionData(this,e);return!!t?.length&&t.some(e=>void 0!==e.target||e.actions.length)},eT=function(){let{_nodes:e,tags:t,machine:r,getMeta:n,toJSON:s,can:i,hasTag:o,matches:a,...c}=this;return{...c,tags:Array.from(t)}},eI=function(){return this._nodes.reduce((e,t)=>
2(void 0!==t.meta&&(e[t.id]=t.meta),e),{})};function eA(e,t){return{status:e.status,output:e.output,error:e.error,machine:t,context:e.context,_nodes:e._nodes,value:G(t.root,e._nodes),tags:new Set(e._nodes.flatMap(e=>e.tags)),children:e.children,historyValue:e.historyValue||{},matches:ew,hasTag:eE,can:ek,getMeta:eI,toJSON:eT}}function eq(e,t={}){return eA({...e,...t},e.machine)}function eO(e,t){let{_nodes:r,tags:n,machine:s,children:i,context:o,can:a,hasTag:c,matches:u,getMeta:l,toJSON:d,...p}=e,h={};for(let e in i){let r=i[e];h[e]={snapshot:r.getPersistedSnapshot(t),src:r.src,systemId:r.systemId,syncSnapshot:r._syncSnapshot}}return{...p,context:function e(t){let r;for(let n in t){let s=t[n];if(s&&"object"==typeof s)if("sessionId"in s&&"send"in s&&"ref"in s)(r??=Array.isArray(t)?t.slice():{...t})[n]={xstate$$type:1,id:s.id};else{let i=e(s);i!==s&&((r??=Array.isArray(t)?t.slice():{...t})[n]=i)}}return r??t}(o),children:h,historyValue:function(e){if("object"!=typeof e||null===e)return{};let t={};for(let r in e){let n=e[r];Array.isArray(n)&&(t[r]=n.map(e=>({id:e.id})))}return t}(p.historyValue)}}function e$(e,t,r,n,{event:s,id:i,delay:o},{internalQueue:a}){let c,u=t.machine.implementations.delays;if("string"==typeof s)throw Error(`Only event objects may be used with raise; use raise({ type: "${s}" }) instead`);let l="function"==typeof s?s(r,n):s;if("string"==typeof o){let e=u&&u[o];c="function"==typeof e?e(r,n):e}else c="function"==typeof o?o(r,n):o;return"number"!=typeof c&&a.push(l),[t,{event:l,id:i,delay:c},void 0]}function eR(e,t){let{event:r,delay:n,id:s}=t;if("number"==typeof n)return void e.defer(()=>{let t=e.self;e.system.scheduler.schedule(t,t,r,n,s)})}function eM(e,t){function r(e,t){}return r.type="xstate.raise",r.event=e,r.id=t?.id,r.delay=t?.delay,r.resolve=e$,r.execute=eR,r}e.s(["$",()=>1,"B",()=>er,"C",()=>Q,"D",()=>ex,"E",()=>J,"F",()=>eA,"G",()=>K,"H",()=>eb,"I",()=>function e(t,r,n,s){if("string"==typeof r){let e;return(e=ea(t,r).next(n,s))&&e.length?e:t.next(n,s)}if(1===Object.keys(r).length){let i,o;
2return(o=e(ea(t,(i=Object.keys(r))[0]),r[i[0]],n,s))&&o.length?o:t.next(n,s)}let i=[];for(let o of Object.keys(r)){let a=r[o];if(!a)continue;let c=e(ea(t,o),a,n,s);c&&i.push(...c)}return i.length?i:t.next(n,s)},"J",()=>em,"K",()=>c,"L",()=>ey,"M",()=>eo,"N",()=>"","O",()=>d,"P",()=>X,"Q",()=>ec,"R",()=>eO,"S",()=>".","T",()=>S,"U",()=>"xstate.error","V",()=>a,"W",()=>T,"X",()=>i,"Y",()=>eq,"a",()=>R,"b",()=>j,"c",()=>q,"d",()=>z,"g",()=>eu,"k",()=>b,"m",()=>x,"n",()=>L,"q",()=>h,"r",()=>eM,"s",()=>F,"t",()=>f,"u",()=>et,"v",()=>g,"w",()=>ee,"x",()=>B,"y",()=>_,"z",()=>Z],894241)},171647,951717,158120,53008,e=>{"use strict";var t,r,n,s=e.i(894241);e.i(439753);let i=new WeakMap;function o(e){return{config:e,start:(t,r)=>{let{self:n,system:s,emit:o}=r,a={receivers:void 0,dispose:void 0};i.set(n,a),a.dispose=e({input:t.input,system:s,self:n,sendBack:e=>{"stopped"!==n.getSnapshot().status&&n._parent&&s._relay(n,n._parent,e)},receive:e=>{a.receivers??=new Set,a.receivers.add(e)},emit:o})},transition:(e,t,r)=>{let n=i.get(r.self);return t.type===s.X?(e={...e,status:"stopped",error:void 0},i.delete(r.self),n.receivers?.clear(),n.dispose?.()):n.receivers?.forEach(e=>e(t)),e},getInitialSnapshot:(e,t)=>({status:"active",output:void 0,error:void 0,input:t}),getPersistedSnapshot:e=>e,restoreSnapshot:e=>e}}let a="xstate.observable.next",c="xstate.observable.error",u="xstate.observable.complete";function l(e){return{config:e,transition:(e,t)=>{if("active"!==e.status)return e;switch(t.type){case a:return{...e,context:t.data};case c:return{...e,status:"error",error:t.data,input:void 0,_subscription:void 0};case u:return{...e,status:"done",input:void 0,_subscription:void 0};case s.X:return e._subscription.unsubscribe(),{...e,status:"stopped",input:void 0,_subscription:void 0};default:return e}},getInitialSnapshot:(e,t)=>({status:"active",output:void 0,error:void 0,context:void 0,input:t,_subscription:void 0}),start:(t,{self:r,system:n,emit:s})=>{"done"!==t.status&&(t._subscription=e({input:t.input,system:n,self:r,emit:s}).subscribe({next:e=>{n._relay(r,r,{type:a,data:e})},error:e=>{n._relay(r,r,{type:c,data:e})},complete:()=>{n._relay(r,r,{type:u})}}))},getPersistedSnapshot:({_subscription:e,...t})=>t,restoreSnapshot:e=>({...e,_subscription:void 0})}}function d(e){return{config:e,transition:(e,t)=>{if("active"!==e.status)return e;switch(t.type){case c:return{...e,status:"error",error:t.data,input:void 0,_subscription:void 0};case u:return{...e,status:"done",input:void 0,_subscription:void 0};case s.X:return e._subscription.unsubscribe(),{...e,status:"stopped",input:void 0,_subscription:void 0};default:return e}},getInitialSnapshot:(e,t)=>({status:"active",output:void 0,error:void 0,context:void 0,input:t,_subscription:void 0}),start:(t,{self:r,system:n,emit:s})=>{"done"!==t.status&&(t._subscription=e({input:t.input,system:n,self:r,emit:s}).subscribe({next:e=>{r._parent&&n._relay(r,r._parent,e)},error:e=>{n._relay(r,r,{type:c,data:e})},complete:()=>{n._relay(r,r,{type:u})}}))},getPersistedSnapshot:({_subscription:e,...t})=>t,restoreSnapshot:e=>({...e,_subscription:void 0})}}let p="xstate.promise.resolve",h="xstate.promise.reject",f=new WeakMap;function y(e){return{config:e,transition:(e,t,r)=>{if("active"!==e.status)return e;switch(t.type){case p:{let r=t.data;return{...e,status:"done",output:r,input:void 0}}case h:return{...e,status:"error",error:t.data,input:void 0};case s.X:return f.get(r.self)?.abort(),f.delete(r.self),{...e,status:"stopped",input:void 0};default:return e}},start:(t,{self:r,system:n,emit:s})=>{if("active"!==t.status)return;let i=new AbortController;f.set(r,i),Promise.resolve(e({input:t.input,system:n,self:r,signal:i.signal,emit:s})).then(e=>{"active"===r.getSnapshot().status&&(f.delete(r),n._relay(r,r,{type:p,data:e}))},e=>{"active"===r.getSnapshot().status&&(f.delete(r),n._relay(r,r,{type:h,data:e}))})},getInitialSnapshot:(e,t)=>({status:"active",output:void 0,error:void 0,input:t}),getPersistedSnapshot:e=>e,restoreSnapshot:e=>e}}let v=(r=void 0,{config:t=e=>void 0,transition:(e,r,n)=>({...e,context:t(e.context,r,n)}),getInitialSnapshot:(e,t)=>
2({status:"active",output:void 0,error:void 0,context:"function"==typeof r?r({input:t}):r}),getPersistedSnapshot:e=>e,restoreSnapshot:e=>e});function g(){return(0,s.c)(v)}function m(e,t,r,n,{assignment:i}){if(!t.context)throw Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");let o={},a={context:t.context,event:r.event,spawn:function(e,{machine:t,context:r},n,i){return(o,a)=>{let c=((o,a)=>{if("string"!=typeof o)return(0,s.c)(o,{id:a?.id,parent:e.self,syncSnapshot:a?.syncSnapshot,input:a?.input,src:o,systemId:a?.systemId});{let c=(0,s.T)(t,o);if(!c)throw Error(`Actor logic '${o}' not implemented in machine '${t.id}'`);let u=(0,s.c)(c,{id:a?.id,parent:e.self,syncSnapshot:a?.syncSnapshot,input:"function"==typeof a?.input?a.input({context:r,event:n,self:e.self}):a?.input,src:o,systemId:a?.systemId});return i[u.id]=u,u}})(o,a);return i[c.id]=c,e.defer(()=>{c._processingStatus!==s.W.Stopped&&c.start()}),c}}(e,t,r.event,o),self:e.self,system:e.system},c={};if("function"==typeof i)c=i(a,n);else for(let e of Object.keys(i)){let t=i[e];c[e]="function"==typeof t?t(a,n):t}let u=Object.assign({},t.context,c);return[(0,s.Y)(t,{context:u,children:Object.keys(o).length?{...t.children,...o}:t.children}),void 0,void 0]}function b(e){function t(e,t){}return t.type="xstate.assign",t.assignment=e,t.resolve=m,t}e.s(["createEmptyActor",()=>g,"fromCallback",()=>o,"fromEventObservable",()=>d,"fromObservable",()=>l,"fromPromise",()=>y],951717),e.s(["a",()=>b],158120);let _=new WeakMap;function S(e,t,r){let n=_.get(e);return n?t in n||(n[t]=r()):(n={[t]:r()},_.set(e,n)),n[t]}let x={},w=e=>"string"==typeof e?{type:e}:"function"==typeof e?"resolve"in e?{type:e.type}:{type:e.name}:e;class E{constructor(e,t){if(this.config=e,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=t._parent,this.key=t._key,this.machine=t._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(s.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,s.q)(this.config.states,(e,t)=>new E(e,{_parent:this,_key:t,_machine:this.machine})):x,"compound"===this.type&&!this.config.initial)throw Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);this.history=!0===this.config.history?"shallow":this.config.history||!1,this.entry=(0,s.t)(this.config.entry).slice(),this.exit=(0,s.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,s.t)(e.tags).slice()}_initialize(){this.transitions=(0,s.u)(this),this.config.always&&(this.always=(0,s.v)(this.config.always).map(e=>(0,s.w)(this,s.N,e))),Object.keys(this.states).forEach(e=>{this.states[e]._initialize()})}get definition(){return{id:this.id,key:this.key,version:this.machine.version,type:this.t
2ype,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(w),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(e=>`#${e.id}`),source:`#${this.id}`,actions:this.initial.actions.map(w),eventType:null})}:void 0,history:this.history,states:(0,s.q)(this.states,e=>e.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(e=>({...e,actions:e.actions.map(w)})),entry:this.entry.map(w),exit:this.exit.map(w),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 S(this,"invoke",()=>(0,s.t)(this.config.invoke).map((e,t)=>{let{src:r,systemId:n}=e,i=e.id??(0,s.y)(this.id,t),o="string"==typeof r?r:`xstate.invoke.${(0,s.y)(this.id,t)}`;return{...e,src:o,id:i,systemId:n,toJSON(){let{onDone:t,onError:r,...n}=e;return{...n,type:"xstate.invoke",src:o,id:i}}}}))}get on(){return S(this,"on",()=>[...this.transitions].flatMap(([e,t])=>t.map(t=>[e,t])).reduce((e,[t,r])=>(e[t]=e[t]||[],e[t].push(r),e),{}))}get after(){return S(this,"delayedTransitions",()=>(0,s.z)(this))}get initial(){return S(this,"initial",()=>(0,s.B)(this,this.config.initial))}next(e,t){let r,n=t.type,i=[];for(let o of S(this,`candidates-${n}`,()=>(0,s.C)(this,n))){let{guard:a}=o,c=e.context,u=!1;try{u=!a||(0,s.x)(a,c,t,e)}
2catch(t){let e="string"==typeof a?a:"object"==typeof a?a.type:void 0;throw Error(`Unable to evaluate guard ${e?`'${e}' `:""}in transition for event '${n}' in state node '${this.id}': 3${t.message}`)}if(u){i.push(...o.actions),r=o;break}}return r?[r]:void 0}get events(){return S(this,"events",()=>{let{states:e}=this,t=new Set(this.ownEvents);if(e)for(let r of Object.keys(e)){let n=e[r];if(n.states)for(let e of n.events)t.add(`${e}`)}return Array.from(t)})}get ownEvents(){return Array.from(new Set(Object.keys(Object.fromEntries(this.transitions)).filter(e=>this.transitions.get(e).some(e=>!(!e.target&&!e.actions.length&&!e.reenter)))))}}class k{constructor(e,t){this.config=e,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=e.id||"(machine)",this.implementations={actors:t?.actors??{},actions:t?.actions??{},delays:t?.delays??{},guards:t?.guards??{}},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 E(e,{_key:this.id,_machine:this}),this.root._initialize(),this.states=this.root.states,this.events=this.root.events}provide(e){let{actions:t,guards:r,actors:n,delays:s}=this.implementations;return new k(this.config,{actions:{...t,...e.actions},guards:{...r,...e.guards},actors:{...n,...e.actors},delays:{...s,...e.delays}})}resolveState(e){let t=(0,s.D)(this.root,e.value),r=(0,s.E)((0,s.g)(this.root,t));return(0,s.F)({_nodes:[...r],context:e.context||{},children:{},status:(0,s.G)(r,this.root)?"done":e.status||"active",output:e.output,error:e.error,historyValue:e.historyValue},this)}transition(e,t,r){return(0,s.H)(e,t,r,[]).snapshot}microstep(e,t,r){return(0,s.H)(e,t,r,[]).microstates}getTransitionData(e,t){return(0,s.I)(this.root,e.value,e,t)||[]}getPreInitialState(e,t,r){let{context:n}=this.config,i=(0,s.F)({context:"function"!=typeof n&&n?n:{},_nodes:[this.root],children:{},status:"active"},this);return"function"==typeof n?(0,s.J)(i,t,e,[b(({spawn:e,event:t,self:r})=>n({spawn:e,input:t.input,self:r}))],r,void 0):i}getInitialSnapshot(e,t){let r=(0,s.K)(t),n=[],i=this.getPreInitialState(e,r,n),o=(0,s.L)([{target:[...(0,s.M)(this.root)],source:this.root,reenter:!0,actions:[],eventType:null,toJSON:null}],i,e,r,!0,n),{snapshot:a}=(0,s.H)(o,r,e,n);return a}start(e){Object.values(e.children).forEach(e=>{"active"===e.getSnapshot().status&&e.start()})}getStateNodeById(e){let t=(0,s.O)(e),r=t.slice(1),n=(0,s.P)(t[0])?t[0].slice(1):t[0],i=this.idMap.get(n);if(!i)throw Error(`Child state node '#${n}' does not exist on machine '${this.id}'`);return(0,s.Q)(i,r)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(e,t){return(0,s.R)(e,t)}restoreSnapshot(e,t){let r={},n=e.children;Object.keys(n).forEach(e=>{let i=n[e],o=i.snapshot,a=i.src,c="string"==typeof a?(0,s.T)(this,a):a;if(!c)return;let u=(0,s.c)(c,{id:e,parent:t.self,syncSnapshot:i.syncSnapshot,snapshot:o,src:a,systemId:i.systemId});r[e]=u});let i=function(e,t){if(!t||"object"!=typeof t)return{};let r={};for(let n in t)for(let s of t[n]){let t=function(e,t){if(t instanceof E)return t;try{return e.machine.getStateNodeById(t.id)}catch{}}(e,s);t&&(r[n]??=[],r[n].push(t))}return r}(this.root,e.historyValue),o=(0,s.F)({...e,children:r,_nodes:Array.from((0,s.E)((0,s.g)(this.root,e.value))),historyValue:i},this),a=new Set;return!function e(t,r){if(!a.has(t))for(let n in a.add(t),t){let i=t[n];if(i&&"object"==typeof i){if("xstate$$type"in i&&i.xstate$$type===s.$){t[n]=r[i.id];continue}e(i,r)}}}(o.context,r),o}}function T(e,t,r,n,{event:s}){return[t,{event:"function"==typeof s?s(r,n):s},void 0]}function I(e,{event:t}){e.defer(()=>e.emit(t))}function A(e){function t(e,t){}return t.type="xstate.emit",t.event=e,t.resolve=T,t.execute=I,t}let q=((n={}).Parent="#_parent",n.Internal="#_internal",n);function O(e,t,r,n,{to:s,event:i,id:o,delay:a}
3,c){let u,l,d=t.machine.implementations.delays;if("string"==typeof i)throw Error(`Only event objects may be used with sendTo; use sendTo({ type: "${i}" }) instead`);let p="function"==typeof i?i(r,n):i;if("string"==typeof a){let e=d&&d[a];u="function"==typeof e?e(r,n):e}else u="function"==typeof a?a(r,n):a;let h="function"==typeof s?s(r,n):s;if("string"==typeof h){if(!(l=h===q.Parent?e.self._parent:h===q.Internal?e.self:h.startsWith("#_")?t.children[h.slice(2)]:c.deferredActorIds?.includes(h)?h:t.children[h]))throw Error(`Unable to send event to actor '${h}' from machine '${t.machine.id}'.`)}else l=h||e.self;return[t,{to:l,targetId:"string"==typeof h?h:void 0,event:p,id:o,delay:u},void 0]}function $(e,t,r){"string"==typeof r.to&&(r.to=t.children[r.to])}function R(e,t){e.defer(()=>{let{to:r,event:n,delay:i,id:o}=t;"number"==typeof i?e.system.scheduler.schedule(e.self,r,n,i,o):e.system._relay(e.self,r,n.type===s.U?(0,s.V)(e.self.id,n.data):n)})}function M(e,t,r){function n(e,t){}return n.type="xstate.sendTo",n.to=e,n.event=t,n.id=r?.id,n.delay=r?.delay,n.resolve=O,n.retryResolve=$,n.execute=R,n}function P(e,t){return M(q.Parent,e,t)}function j(e,t,r,n,{collect:i}){let o=[],a=function(e){o.push(e)};return a.assign=(...e)=>{o.push(b(...e))},a.cancel=(...e)=>{o.push((0,s.a)(...e))},a.raise=(...e)=>{o.push((0,s.r)(...e))},a.sendTo=(...e)=>{o.push(M(...e))},a.sendParent=(...e)=>{o.push(P(...e))},a.spawnChild=(...e)=>{o.push((0,s.b)(...e))},a.stopChild=(...e)=>{o.push((0,s.s)(...e))},a.emit=(...e)=>{o.push(A(...e))},i({context:r.context,event:r.event,enqueue:a,check:e=>(0,s.x)(e,t.context,r.event,t),self:e.self,system:e.system},n),[t,void 0,o]}function N(e){function t(e,t){}return t.type="xstate.enqueueActions",t.collect=e,t.resolve=j,t}function C(e,t,r,n,{value:s,label:i}){return[t,{value:"function"==typeof s?s(r,n):s,label:i},void 0]}function F({logger:e},{value:t,label:r}){r?e(r,t):e(t)}function D(e=({context:e,event:t})=>({context:e,event:t}),t){function r(e,t){}return r.type="xstate.log",r.value=e,r.label=t,r.resolve=C,r.execute=F,r}function L(e,t){let r=(0,s.t)(t);if(!r.some(t=>(0,s.m)(e.type,t))){let t=1===r.length?`type matching "${r[0]}
3"`:`one of types matching "${r.join('", "')}"`;throw Error(`Expected event ${JSON.stringify(e)} to have ${t}`)}}e.s(["a",()=>A,"b",()=>P,"e",()=>N,"l",()=>D,"s",()=>M],53008),e.s(["assertEvent",()=>L,"setup",()=>function e({schemas:t,actors:r,actions:n,guards:i,delays:o}){return{assign:b,sendTo:M,raise:s.r,log:D,cancel:s.a,stopChild:s.s,enqueueActions:N,emit:A,spawnChild:s.b,createStateConfig:e=>e,createAction:e=>e,createMachine:e=>new k({...e,schemas:t},{actors:r,actions:n,guards:i,delays:o}),extend:s=>e({schemas:t,actors:r,actions:{...n,...s.actions},guards:{...i,...s.guards},delays:{...o,...s.delays}})}}],171647)},899020,e=>{"use strict";var t=e.i(53008);e.s(["sendTo",()=>t.s])},400406,e=>{"use strict";var t=e.i(158120);e.s(["assign",()=>t.a])},522703,e=>{"use strict";var t=e.i(894241);e.s(["createActor",()=>t.c])},979097,e=>{"use strict";var t=e.i(53008);e.s(["enqueueActions",()=>t.e])},29509,e=>{"use strict";var t=e.i(894241);e.s(["raise",()=>t.r])},571241,e=>{"use strict";var t=e.i(53008);e.s(["emit",()=>t.a])},955452,e=>{"use strict";var t=e.i(894241);e.s(["stopChild",()=>t.s])},827540,e=>{"use strict";function t(e){return"function"==typeof e}e.s(["isFunction",()=>t])},521879,949918,907844,337902,662696,758357,450363,558869,e=>{"use strict";var t=e.i(824627),r=e.i(827540);function n(e){var t=e(function(e){Error.call(e),e.stack=Error().stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}e.s(["createErrorClass",()=>n],949918);var s=n(function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map(function(e,t){return t+1+") "+e.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}});function i(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}e.s(["arrRemove",()=>i],907844);var o=function(){var e;function n(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return n.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var e,n,i,o,a,c=this._parentage;if(c)if(this._parentage=null,Array.isArray(c))try{for(var l=(0,t.__values)(c),d=l.next();!d.done;d=l.next())d.value.remove(this)}catch(t){e={error:t}}finally{try{d&&!d.done&&(n=l.return)&&n.call(l)}finally{if(e)throw e.error}}else c.remove(this);var p=this.initialTeardown;if((0,r.isFunction)(p))try{p()}catch(e){a=e instanceof s?e.errors:[e]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var f=(0,t.__values)(h),y=f.next();!y.done;y=f.next()){var v=y.value;try{u(v)}catch(e){a=null!=a?a:[],e instanceof s?a=(0,t.__spreadArray)((0,t.__spreadArray)([],(0,t.__read)(a)),(0,t.__read)(e.errors)):a.push(e)}}}catch(e){i={error:e}}finally{try{y&&!y.done&&(o=f.return)&&o.call(f)}finally{if(i)throw i.error}}}if(a)throw new s(a)}},n.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)u(e);else{if(e instanceof n){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=null!=(t=this._finalizers)?t:[]).push(e)}},n.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},n.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},n.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&i(t,e)},n.prototype.remove=function(e){var t=this._finalizers;t&&i(t,e),e instanceof n&&e._removeParent(this)},(e=new n).closed=!0,n.EMPTY=e,n}(),a=o.EMPTY;function c(e){return e instanceof o||e&&"closed"in e&&(0,r.isFunction)(e.remove)&&(0,r.isFunction)(e.add)&&(0,r.isFunction)(e.unsubscribe)}function u(e){(0,r.isFunction)(e)?e():e.unsubscribe()}e.s(["EMPTY_SUBSCRIPTION",()=>a,"Subscription",()=>o,"isSubscription",()=>c],337902);var l={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};e.s(["config",()=>l],662696);var d={setTimeout:function(e,r){for(var n=[],s=2;s<arguments.length;s++)n[s-2]=arguments[s];var i=d.delegate;return(null==i?void 0:i.setTimeout)?i.setTimeout.apply(i,(0,t.__spreadArray)([e,r],(0,t.__read)(n))):setTimeout.apply(void 0,(0,t.__spreadArray)([e,r],(0,t.__read)(n)))},clearTimeout:function(e){var t=d.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function p(e){d.setTimeout(function(){var t=l.onUnhandledError;if(t)t(e);else throw e})}function h(){}e.s(["reportUnhandledError",()=>p],758357),e.s(["noop",()=>h],450363);var f=y("C",void 0,void 0);function y(e,t,r){return{kind:e,value:t,error:r}}var v=null;function g(e){if(l.useDeprecatedSynchronousErrorHandling){var t=!v;if(t&&(v={errorThrown:!1,error:null}),e(),t){var r=v,n=r.errorThrown,s=r.error;if(v=null,n)throw s}}else e()}function m(e){l.useDeprecatedSynchronousErrorHandling&&v&&(v.errorThrown=!0,v.error=e)}e.s(["captureError",()=>m,"errorContext",()=>g],558869);var b=function(e){function r(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,c(t)&&t.add(r)):r.destination=T,r}return(0,t.__extends)(r,e),r.create=function(e,t,r){return new w(e,t,r)},r.prototype.next=function(e){this.isStopped?k(y("N",e,void 0),this):this._next(e)},r.prototype.error=function(e){this.isStopped?k(y("E",void 0,e),this):(this.isStopped=!0,this._error(e))},r.prototype.complete=function(){this.isStopped?k(f,this):(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(e){this.destination.next(e)},r.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r}(o),_=Function.prototype.bind;function S(e,t){return _.call(e,t)}var x=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){E(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){E(e)}else E(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){E(e)}},e}(),w=function(e){function n(t,n,s){var i,o,a=e.call(this)||this;return(0,r.isFunction)(t)||!t?i={next:null!=t?t:void 0,error:null!=n?n:void 0,complete:null!=s?s:void 0}
3:a&&l.useDeprecatedNextContext?((o=Object.create(t)).unsubscribe=function(){return a.unsubscribe()},i={next:t.next&&S(t.next,o),error:t.error&&S(t.error,o),complete:t.complete&&S(t.complete,o)}):i=t,a.destination=new x(i),a}return(0,t.__extends)(n,e),n}(b);function E(e){l.useDeprecatedSynchronousErrorHandling?m(e):p(e)}function k(e,t){var r=l.onStoppedNotification;r&&d.setTimeout(function(){return r(e,t)})}var T={closed:!0,next:h,error:function(e){throw e},complete:h};e.s(["SafeSubscriber",()=>w,"Subscriber",()=>b],521879)},516165,448971,913072,602435,902190,411844,939584,841471,43533,990156,12436,633482,e=>{"use strict";var t=e.i(521879),r=e.i(337902),n="function"==typeof Symbol&&Symbol.observable||"@@observable";function s(e){return e}function i(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return o(e)}function o(e){return 0===e.length?s:1===e.length?e[0]:function(t){return e.reduce(function(e,t){return t(e)},t)}}e.s(["identity",()=>s],448971),e.s(["pipe",()=>i,"pipeFromArray",()=>o],913072);var a=e.i(662696),c=e.i(827540),u=e.i(558869),l=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,n,s){var i=this,o=!function(e){return e&&e instanceof t.Subscriber||e&&(0,c.isFunction)(e.next)&&(0,c.isFunction)(e.error)&&(0,c.isFunction)(e.complete)&&(0,r.isSubscription)(e)}(e)?new t.SafeSubscriber(e,n,s):e;return(0,u.errorContext)(function(){var e=i.operator,t=i.source;o.add(e?e.call(o,t):t?i._subscribe(o):i._trySubscribe(o))}),o},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,r){var n=this;return new(r=d(r))(function(r,s){var i=new t.SafeSubscriber({next:function(t){try{e(t)}catch(e){s(e),i.unsubscribe()}},error:s,complete:r});n.subscribe(i)})},e.prototype._subscribe=function(e){var t;return null==(t=this.source)?void 0:t.subscribe(e)},e.prototype[n]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return o(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=d(e))(function(e,r){var n;t.subscribe(function(e){return n=e},function(e){return r(e)},function(){return e(n)})})},e.create=function(t){return new e(t)},e}();function d(e){var t;return null!=(t=null!=e?e:a.config.Promise)?t:Promise}e.s(["Observable",()=>l],516165);var p=e.i(824627),h=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function f(e){return(0,c.isFunction)(null==e?void 0:e.then)}function y(e){return(0,c.isFunction)(e[n])}function v(e){return Symbol.asyncIterator&&(0,c.isFunction)(null==e?void 0:e[Symbol.asyncIterator])}function g(e){return TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}e.s(["isArrayLike",()=>h],602435),e.s(["isPromise",()=>f],902190),e.s(["isInteropObservable",()=>y],411844),e.s(["isAsyncIterable",()=>v],939584),e.s(["createInvalidObservableTypeError",()=>g],841471);var m="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function b(e){return(0,c.isFunction)(null==e?void 0:e[m])}function _(e){return(0,p.__asyncGenerator)(this,arguments,function(){var t,r,n;return(0,p.__generator)(this,function(s){switch(s.label){case 0:t=e.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,(0,p.__await)(t.read())];case 3:if(n=(r=s.sent()).value,!r.done)return[3,5];return[4,(0,p.__await)(void 0)];case 4:return[2,s.sent()];case 5:return[4,(0,p.__await)(n)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function S(e){return(0,c.isFunction)(null==e?void 0:e.getReader)}e.s(["iterator",()=>m],43533),e.s(["isIterable",()=>b],990156),e.s(["isReadableStreamLike",()=>S,"readableStreamLikeToAsyncGenerator",()=>_],12436);var x=e.i(758357);function w(e){if(e instanceof l)return e;if(null!=e){var t,r,s,i;if(y(e)){return t=e,new l(function(e){var r=t[n]();if((0,c.isFunction)(r.subscribe))return r.subscribe(e);throw TypeError("Provided object does not correctly implement Symbol.observable")})}if(h(e)){return r=e,new l(function(e){for(var t=0;t<r.length&&!e.closed;t++)e.next(r[t]);e.complete()})}if(f(e)){return s=e,new l(function(e){s.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,x.reportUnhandledError)})}if(v(e))return E(e);if(b(e)){return i=e,new l(function(e){var t,r;try{for(var n=(0,p.__values)(i),s=n.next();!s.done;s=n.next()){var o=s.value;if(e.next(o),e.closed)return}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}e.complete()})}if(S(e))return E(_(e))}throw g(e)}function E(e){return new l(function(t){(function(e,t){var r,n,s,i;return(0,p.__awaiter)(this,void 0,void 0,function(){var o;return(0,p.__generator)(this,function(a){switch(a.label){case 0:a.trys.push([0,5,6,11]),r=(0,p.__asyncValues)(e),a.label=1;case 1:return[4,r.next()];case 2:if((n=a.sent()).done)return[3,4];if(o=n.value,t.next(o),t.closed)return[2];a.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return s={error:a.sent()},[3,11];case 6:if(a.trys.push([6,,9,10]),!(n&&!n.done&&(i=r.return)))return[3,8];return[4,i.call(r)];case 7:a.sent(),a.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];
3case 10:return[7];case 11:return t.complete(),[2]}})})})(e,t).catch(function(e){return t.error(e)})})}e.s(["innerFrom",()=>w],633482)},159862,e=>{"use strict";var t=e.i(516165),r=e.i(633482);function n(e){return new t.Observable(function(t){(0,r.innerFrom)(e()).subscribe(t)})}e.s(["defer",()=>n])},866312,e=>{"use strict";var t=e.i(827540);function r(e){return(0,t.isFunction)(null==e?void 0:e.lift)}function n(e){return function(t){if(r(t))return t.lift(function(t){try{return e(t,this)}catch(e){this.error(e)}});throw TypeError("Unable to lift unknown Observable type")}}e.s(["hasLift",()=>r,"operate",()=>n])},7560,e=>{"use strict";var t=e.i(824627);function r(e,t,r,s,i){return new n(e,t,r,s,i)}var n=function(e){function r(t,r,n,s,i,o){var a=e.call(this,t)||this;return a.onFinalize=i,a.shouldUnsubscribe=o,a._next=r?function(e){try{r(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=s?function(e){try{s(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return(0,t.__extends)(r,e),r.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),r||null==(t=this.onFinalize)||t.call(this)}},r}(e.i(521879).Subscriber);e.s(["OperatorSubscriber",()=>n,"createOperatorSubscriber",()=>r])},913186,e=>{"use strict";var t=e.i(866312),r=e.i(7560);function n(e,n){return(0,t.operate)(function(t,s){var i=0;t.subscribe((0,r.createOperatorSubscriber)(s,function(t){s.next(e.call(n,t,i++))}))})}e.s(["map",()=>n])},168,e=>{"use strict";function t(e,t,r,n,s){void 0===n&&(n=0),void 0===s&&(s=!1);var i=t.schedule(function(){r(),s?e.add(this.schedule(null,n)):this.unsubscribe()},n);if(e.add(i),!s)return i}e.s(["executeSchedule",()=>t])},806298,484430,e=>{"use strict";var t=e.i(913186),r=e.i(633482),n=e.i(866312),s=e.i(168),i=e.i(7560);function o(e,t,n,o,a,c,u,l){var d=[],p=0,h=0,f=!1,y=function(){!f||d.length||p||t.complete()},v=function(e){return p<o?g(e):d.push(e)},g=function(e){c&&t.next(e),p++;var l=!1;(0,r.innerFrom)(n(e,h++)).subscribe((0,i.createOperatorSubscriber)(t,function(e){null==a||a(e),c?v(e):t.next(e)},function(){l=!0},void 0,function(){if(l)try{for(p--;d.length&&p<o;)!function(){var e=d.shift();u?(0,s.executeSchedule)(t,u,function(){return g(e)}):g(e)}();y()}catch(e){t.error(e)}}))};return e.subscribe((0,i.createOperatorSubscriber)(t,v,function(){f=!0,y()})),function(){null==l||l()}}e.s(["mergeInternals",()=>o],484430);var a=e.i(827540);e.s(["mergeMap",()=>function e(s,i,c){return(void 0===c&&(c=1/0),(0,a.isFunction)(i))?e(function(e,n){return(0,t.map)(function(t,r){return i(e,t,n,r)})((0,r.innerFrom)(s(e,n)))},c):("number"==typeof i&&(c=i),(0,n.operate)(function(e,t){return o(e,t,s,c)}))}],806298)},591607,e=>{"use strict";var t=e.i(824627),r=e.i(913186),n=Array.isArray;function s(e){return(0,r.map)(function(r){return n(r)?e.apply(void 0,(0,t.__spreadArray)([],(0,t.__read)(r))):e(r)})}e.s(["mapOneOrManyArgs",()=>s])},828640,e=>{"use strict";var t=e.i(824627),r=e.i(633482),n=e.i(516165),s=e.i(806298),i=e.i(602435),o=e.i(827540),a=e.i(591607),c=["addListener","removeListener"],u=["addEventListener","removeEventListener"],l=["on","off"];function d(e,t){return function(r){return function(n){return e[r](t,n)}}}e.s(["fromEvent",()=>function e(p,h,f,y){if((0,o.isFunction)(f)&&(y=f,f=void 0),y)return e(p,h,f).pipe((0,a.mapOneOrManyArgs)(y));var v,g,m,b=(0,t.__read)((v=p,(0,o.isFunction)(v.addEventListener)&&(0,o.isFunction)(v.removeEventListener))?u.map(function(e){return function(t){return p[e](h,t,f)}}):(g=p,(0,o.isFunction)(g.addListener)&&(0,o.isFunction)(g.removeListener))?c.map(d(p,h)):(m=p,(0,o.isFunction)(m.on)&&(0,o.isFunction)(m.off))?l.map(d(p,h)):[],2),_=b[0],S=b[1];if(!_&&(0,i.isArrayLike)(p))return(0,s.mergeMap)(function(t){return e(t,h,f)})((0,r.innerFrom)(p));if(!_)throw TypeError("Invalid event target");return new n.Observable(function(e){var t=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e.next(1<t.length?t:t[0])};return _(t),function(){return S(t)}})}])},80205,e=>{"use strict";var t=e.i(866312),r=e.i(7560);function n(e,n){return(0,t.operate)(function(t,s){var i=0;t.subscribe((0,r.createOperatorSubscriber)(s,function(t){return e.call(n,t,i++)&&s.next(t)}))})}e.s(["filter",()=>n])},473948,e=>{"use strict";var t=e.i(824627),r=e.i(866312),n=e.i(7560),s=e.i(907844);function i(e,i){return void 0===i&&(i=null),i=null!=i?i:e,(0,r.operate)(function(r,o){var a=[],c=0;r.subscribe((0,n.createOperatorSubscriber)(o,function(r){var n,u,l,d,p=null;c++%i==0&&a.push([]);try{for(var h=(0,t.__values)(a),f=h.next();!f.done;f=h.next()){var y=f.value;y.push(r),e<=y.length&&(p=null!=p?p:[]).push(y)}}catch(e){n={error:e}}finally{try{f&&!f.done&&(u=h.return)&&u.call(h)}finally{if(n)throw n.error}}if(p)try{for(var v=(0,t.__values)(p),g=v.next();!g.done;g=v.next()){var y=g.value;(0,s.arrRemove)(a,y),o.next(y)}}catch(e){l={error:e}}finally{try{g&&!g.done&&(d=v.return)&&d.call(v)}finally{if(l)throw l.error}}},function(){var e,r;try{for(var n=(0,t.__values)(a),s=n.next();!s.done;s=n.next()){var i=s.value;o.next(i)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}o.complete()},void 0,function(){a=null}))})}e.s(["bufferCount",()=>i])},262940,e=>{"use strict";var t=e.i(806298),r=e.i(827540);function n(e,n){return(0,r.isFunction)(n)?(0,t.mergeMap)(e,n,1):(0,t.mergeMap)(e,1)}e.s(["concatMap",()=>n])},982100,e=>{"use strict";var t=new(e.i(516165)).Observable(function(e){return e.complete()});e.s(["EMPTY",()=>t])},83507,e=>{"use strict";var t=e.i(982100),r=e.i(866312),n=e.i(7560);function s(e){return e<=0?function(){return t.EMPTY}:(0,r.operate)(function(t,r){var s=0;t.subscribe((0,n.createOperatorSubscriber)(r,function(t){++s<=e&&(r.next(t),e<=s&&r.complete())}))})}e.s(["take",()=>s])},592110,e=>{"use strict";var t=e.i(866312),r=e.i(7560),n=e.i(633482),s=e.i(450363);function i(e){return(0,t.operate)(function(t,i){(0,n.innerFrom)(e).subscribe((0,r.createOperatorSubscriber)(i,function(){return i.complete()},s.noop)),i.closed||t.subscribe(i)})}e.s(["takeUntil",()=>i])},10412,e=>{"use strict";var t=e.i(627897),r=e.i(951717),n=e.i(171647),s=e.i(899020),i=e.i(400406),o=e.i(522703),a=e.i(979097),c=e.i(29509),u=e.i(571241),l=e.i(955452),d=e.i(159862),p=e.i(828640),h=e.i(913186),f=e.i(913072),y=e.i(80205),v=e.i(473948),g=e.i(262940),m=e.i(83507),b=e.i(982100),_=e.i(592110);let S=e=>({context:t})=>{let{count:r,include:n,exclude:s,responseType:i="message.received"}=e;return{count:r,domain:t.domain,from:t.connectTo,include:n?Array.isArray(n)?n:[n]:[],exclude:s?Array.isArray(s)?s:[s]:[],responseType:i,target:t.target,to:t.name}},x=(0,d.defer)(()=>(0,p.fromEvent)(window,"message")),w=e=>(0,r.fromEventObservable)(({input:t})=>{let r;return x.pipe(e?(0,h.map)(e):(0,f.pipe)(),(0,y.filter)(e=>{let{data:r}=e;return(!t.include.length||t.include.includes(r.type))&&(!t.exclude.length||!t.exclude.includes(r.type))&&r.domain===t.domain&&r.from===t.from&&r.to===t.to&&(!t.target||e.source===t.target)}),(0,h.map)((r=t.responseType,e=>({type:r,message:e}))),t.count?(0,f.pipe)((0,v.bufferCount)(t.count),(0,g.concatMap)(e=>e),(0,m.take)(t.count)):(0,f.pipe)())}),E="sanity/comlink",k="comlink/response",T="comlink/heartbeat",I="comlink/disconnect",A="comlink/handshake/syn",q="comlink/handshake/syn-ack",O="comlink/handshake/ack",$=()=>(0,n.setup)({types:{},actors:{listen:(0,r.fromEventObservable)(({input:e})=>{let t,r=e.signal?(0,p.fromEvent)(e.signal,"abort").pipe((t=`Request ${e.requestId} aborted`,e=>e.pipe((0,m.take)(1),(0,h.map)(()=>{throw Error(t)})))):b.EMPTY;return(0,p.fromEvent)(window,"message").pipe((0,y.filter)(t=>t.data?.type===k&&t.data?.responseTo===e.requestId&&!!t.source&&e.sources.has(t.source)),(0,m.take)(e.sources.size),(0,_.takeUntil)(r))})},actions:{"send message":({context:e},t)=>{let{sources:r,targetOrigin:n}=e,{message:s}=t;
3r.forEach(e=>{e.postMessage(s,{targetOrigin:n})})},"on success":(0,s.sendTo)(({context:e})=>e.parentRef,({context:e,self:t})=>(e.response&&e.resolvable?.resolve(e.response),{type:"request.success",requestId:t.id,response:e.response,responseTo:e.responseTo})),"on fail":(0,s.sendTo)(({context:e})=>e.parentRef,({context:e,self:t})=>(e.suppressWarnings||console.warn(`[@sanity/comlink] Received no response to message '${e.type}' on client '${e.from}' (ID: '${e.id}').`),e.resolvable?.reject(Error("No response received")),{type:"request.failed",requestId:t.id})),"on abort":(0,s.sendTo)(({context:e})=>e.parentRef,({context:e,self:t})=>(e.resolvable?.reject(Error("Request aborted")),{type:"request.aborted",requestId:t.id}))},guards:{expectsResponse:({context:e})=>e.expectResponse},delays:{initialTimeout:0,responseTimeout:({context:e})=>e.responseTimeout??3e3}}).createMachine({context:({input:e})=>({channelId:e.channelId,data:e.data,domain:e.domain,expectResponse:e.expectResponse??!1,from:e.from,id:`msg-${(0,t.v4)()}`,parentRef:e.parentRef,resolvable:e.resolvable,response:null,responseTimeout:e.responseTimeout,responseTo:e.responseTo,signal:e.signal,sources:e.sources instanceof Set?e.sources:new Set([e.sources]),suppressWarnings:e.suppressWarnings,targetOrigin:e.targetOrigin,to:e.to,type:e.type}),initial:"idle",on:{abort:".aborted"},states:{idle:{after:{initialTimeout:[{target:"sending"}]}},sending:{entry:{type:"send message",params:({context:e})=>{let{channelId:t,data:r,domain:n,from:s,id:i,responseTo:o,to:a,type:c}=e;return{message:{channelId:t,data:r,domain:n,from:s,id:i,to:a,type:c,responseTo:o}}}},always:[{guard:"expectsResponse",target:"awaiting"},"success"]},awaiting:{invoke:{id:"listen for response",src:"listen",input:({context:e})=>({requestId:e.id,sources:e.sources,signal:e.signal}),onError:"aborted"},after:{responseTimeout:"failed"},on:{message:{actions:(0,i.assign)({response:({event:e})=>e.data.data,responseTo:({event:e})=>e.data.responseTo}),target:"success"}}},failed:{type:"final",entry:"on fail"},success:{type:"final",entry:"on success"},aborted:{type:"final",entry:"on abort"}},output:({context:e,self:t})=>({requestId:t.id,response:e.response,responseTo:e.responseTo})}),R=(0,r.fromCallback)(({sendBack:e,input:t})=>{let r=()=>{e(t.event)};t.immediate&&r();let n=setInterval(r,t.interval);return()=>{clearInterval(n)}}),M=()=>(0,n.setup)({types:{},actors:{requestMachine:$(),listen:w(),sendBackAtInterval:R},actions:{"buffer message":(0,a.enqueueActions)(({enqueue:e})=>{e.assign({buffer:({event:e,context:t})=>((0,n.assertEvent)(e,"post"),[...t.buffer,e.data])}),e.emit(({event:e})=>((0,n.assertEvent)(e,"post"),{type:"buffer.added",message:e.data}))}),"create request":(0,i.assign)({requests:({context:e,event:r,self:s,spawn:i})=>{(0,n.assertEvent)(r,"request");let o=(Array.isArray(r.data)?r.data:[r.data]).map(r=>i("requestMachine",{id:`req-${(0,t.v4)()}`,input:{channelId:e.channelId,data:r.data,domain:e.domain,expectResponse:r.expectResponse,from:e.name,parentRef:s,responseTo:r.responseTo,sources:e.target,targetOrigin:e.targetOrigin,to:e.connectTo,type:r.type}}));return[...e.requests,...o]}}),"emit received message":(0,a.enqueueActions)(({enqueue:e})=>{e.emit(({event:e})=>((0,n.assertEvent)(e,"message.received"),{type:"message",message:e.message.data}))}),"emit status":(0,u.emit)((e,t)=>({type:"status",status:t.status})),"post message":(0,c.raise)(({event:e})=>((0,n.assertEvent)(e,"post"),{type:"request",data:{data:e.data.data,expectResponse:!0,type:e.data.type}})),"remove request":(0,a.enqueueActions)(({context:e,enqueue:t,event:r})=>{(0,n.assertEvent)(r,["request.success","request.failed","request.aborted"]),(0,l.stopChild)(r.requestId),t.assign({requests:e.requests.filter(({id:e})=>e!==r.requestId)})}),respond:(0,c.raise)(({event:e})=>((0,n.assertEvent)(e,"response"),{type:"request",data:{data:e.data,type:k,responseTo:e.respondTo}})),"send handshake ack":(0,c.raise)({type:"request",data:{type:O}}),"send disconnect":(0,c.raise)(()=>({type:"request",data:{type:I}})),"send handshake syn":(0,c.raise)({type:"request",data:{type:A}}),"send pending messages":(0,a.enqueueActions)(({enqueue:e})=>{e.raise(({context:e})=>({type:"request",data:e.buffer.map(({data:e,type:t})=>({data:e,type:t}))})),e.emit(({context:e})=>({type:"buffer.flushed",messages:e.buffer})),e.assign({buffer:[]})}),"set target":(0,i.assign)({target:({event:e})=>((0,n.assertEvent)(e,"target.set"),e.target)})},guards:{"has target":({context:e})=>!!e.target,"should send heartbeats":({context:e})=>e.heartbeat}}).createMachine({id:"connection",context:({input:e})=>({id:e.id||`${e.name}-${(0,t.v4)()}`,buffer:[],channelId:`chn-${(0,t.v4)()}`,connectTo:e.connectTo,domain:e.domain??E,heartbeat:e.heartbeat??!1,name:e.name,requests:[],target:e.target,targetOrigin:e.targetOrigin}),on:{"target.set":{actions:"set target"},"request.success":{actions:"remove request"},"request.failed":{actions:"remove request"}}
3,initial:"idle",states:{idle:{entry:[{type:"emit status",params:{status:"idle"}}],on:{connect:{target:"handshaking",guard:"has target"},post:{actions:"buffer message"}}},handshaking:{id:"handshaking",entry:[{type:"emit status",params:{status:"handshaking"}}],invoke:[{id:"send syn",src:"sendBackAtInterval",input:()=>({event:{type:"syn"},interval:500,immediate:!0})},{id:"listen for handshake",src:"listen",input:e=>S({include:q,count:1})(e)}],on:{syn:{actions:"send handshake syn"},request:{actions:"create request"},post:{actions:"buffer message"},"message.received":{target:"connected"},disconnect:{target:"disconnected"}},exit:"send handshake ack"},connected:{entry:["send pending messages",{type:"emit status",params:{status:"connected"}}],invoke:{id:"listen for messages",src:"listen",input:S({exclude:[k,T]})},on:{post:{actions:"post message"},request:{actions:"create request"},response:{actions:"respond"},"message.received":{actions:"emit received message"},disconnect:{target:"disconnected"}},initial:"heartbeat",states:{heartbeat:{initial:"checking",states:{checking:{always:{guard:"should send heartbeats",target:"sending"}},sending:{on:{"request.failed":{target:"#handshaking"}},invoke:{id:"send heartbeat",src:"sendBackAtInterval",input:()=>({event:{type:"post",data:{type:T,data:void 0}},interval:2e3,immediate:!1})}}}}}},disconnected:{id:"disconnected",entry:["send disconnect",{type:"emit status",params:{status:"disconnected"}}],on:{request:{actions:"create request"},post:{actions:"buffer message"},connect:{target:"handshaking",guard:"has target"}}}}}),P=(e,r=M())=>{let n=e.id||`${e.name}-${(0,t.v4)()}`,s=(0,o.createActor)(r,{input:{...e,id:n}}),i=new Map,a=new Map;s.on("message",async({message:e})=>{let t=i.get(e.type);if(t)return void t.forEach(async t=>{let r=await t(e.data);r&&s.send({type:"response",respondTo:e.id,data:r})});let r=a.get(e.type);r?r.add(e):a.set(e.type,new Set([e]))});let c=()=>{s.stop()};return{actor:s,connect:()=>{s.send({type:"connect"})},disconnect:()=>{s.send({type:"disconnect"})},id:n,name:e.name,machine:r,on:(e,t,r)=>{let n=i.get(e)||new Set;i.has(e)||i.set(e,n),n.add(t);let o=a.get(e);if(o){let n=r?.replay??1;Array.from(o).slice(-n).forEach(async({data:e,id:r})=>{let n=await t(e);n&&s.send({type:"response",respondTo:r,data:n})}),a.delete(e)}return()=>{n.delete(t)}},onStatus:(e,t)=>{let r=s.on("status",r=>{t&&r.status!==t||e(r.status)});return()=>r.unsubscribe()},post:(e,t)=>{s.send({type:"post",data:{type:e,data:t}})},setTarget:e=>{s.send({type:"target.set",target:e})},start:()=>(s.start(),c),stop:c,get target(){return s.getSnapshot().context.target}}},j=e=>{e.disconnect(),setTimeout(()=>{e.stop()},0)},N=()=>{},C=e=>{let{targetOrigin:t}=e,r=new Set,n=new Set;return{addTarget:e=>{if(r.has(e))return N;if(!r.size||!n.size)return r.add(e),n.forEach(t=>{t.connections.forEach(t=>{t.setTarget(e),t.connect()})}),()=>{r.delete(e),n.forEach(t=>{t.connections.forEach(t=>{t.target===e&&t.disconnect()})})};r.add(e);let s=new Set;return n.forEach(r=>{let n=P({...r.input,target:e,targetOrigin:t},r.machine);s.add(n),r.connections.add(n),r.subscribers.forEach(({type:e,handler:t,unsubscribers:r})=>{r.push(n.on(e,t))}),r.internalEventSubscribers.forEach(({type:e,handler:t,unsubscribers:r})=>{let s=n.actor.on(e,t);r.push(()=>s.unsubscribe())}),r.statusSubscribers.forEach(({handler:e,unsubscribers:t})=>{t.push(n.onStatus(t=>e({connection:n.id,status:t})))}),n.start(),n.connect()}),()=>{r.delete(e),s.forEach(e=>{j(e),n.forEach(t=>{t.connections.delete(e)})})}},createChannel:(e,s=M())=>{let i={connections:new Set,input:e,internalEventSubscribers:new Set,machine:s,statusSubscribers:new Set,subscribers:new Set};n.add(i);let{connections:o,internalEventSubscribers:a,statusSubscribers:c,subscribers:u}=i;if(r.size)r.forEach(r=>{let n=P({...e,target:r,targetOrigin:t},s);o.add(n)});else{let r=P({...e,targetOrigin:t},s);o.add(r)}let l=()=>{let e=i.connections;e.forEach(j),e.clear(),n.delete(i)};return{on:(e,t)=>{let r=[];o.forEach(n=>{r.push(n.on(e,t))});let n={type:e,handler:t,unsubscribers:r};return u.add(n),()=>{r.forEach(e=>e()),u.delete(n)}},onInternalEvent:(e,t)=>
3{let r=[];o.forEach(n=>{let s=n.actor.on(e,t);r.push(()=>s.unsubscribe())});let n={type:e,handler:t,unsubscribers:r};return a.add(n),()=>{r.forEach(e=>e()),a.delete(n)}},onStatus:e=>{let t=[];o.forEach(r=>{t.push(r.onStatus(t=>e({connection:r.id,status:t})))});let r={handler:e,unsubscribers:t};return c.add(r),()=>{t.forEach(e=>e()),c.delete(r)}},post:(...e)=>{let[t,r]=e;o.forEach(e=>{e.post(t,r)})},start:()=>(o.forEach(e=>{e.start(),e.connect()}),l),stop:l}},destroy:()=>{n.forEach(({connections:e})=>{e.forEach(j),e.clear()}),n.clear(),r.clear()}}},F=()=>(0,n.setup)({types:{},actors:{requestMachine:$(),listen:w()},actions:{"buffer handshake":(0,i.assign)({handshakeBuffer:({event:e,context:t})=>((0,n.assertEvent)(e,"message.received"),[...t.handshakeBuffer,e])}),"buffer message":(0,a.enqueueActions)(({enqueue:e})=>{e.assign({buffer:({event:e,context:t})=>((0,n.assertEvent)(e,"post"),[...t.buffer,{data:e.data,resolvable:e.resolvable,options:e.options}])}),e.emit(({event:e})=>((0,n.assertEvent)(e,"post"),{type:"buffer.added",message:e.data}))}),"create request":(0,i.assign)({requests:({context:e,event:r,self:s,spawn:i})=>{(0,n.assertEvent)(r,"request");let o=(Array.isArray(r.data)?r.data:[r.data]).map(r=>i("requestMachine",{id:`req-${(0,t.v4)()}`,input:{channelId:e.channelId,data:r.data,domain:e.domain,expectResponse:r.expectResponse,from:e.name,parentRef:s,resolvable:r.resolvable,responseTimeout:r.options?.responseTimeout,responseTo:r.responseTo,signal:r.options?.signal,sources:e.target,suppressWarnings:r.options?.suppressWarnings,targetOrigin:e.targetOrigin,to:e.connectTo,type:r.type}}));return[...e.requests,...o]}}),"emit heartbeat":(0,u.emit)(()=>({type:"heartbeat"})),"emit received message":(0,a.enqueueActions)(({enqueue:e})=>{e.emit(({event:e})=>((0,n.assertEvent)(e,"message.received"),{type:"message",message:e.message.data}))}),"emit status":(0,u.emit)((e,t)=>({type:"status",status:t.status})),"post message":(0,c.raise)(({event:e})=>((0,n.assertEvent)(e,"post"),{type:"request",data:{data:e.data.data,expectResponse:!!e.resolvable,type:e.data.type,resolvable:e.resolvable,options:e.options}})),"process pending handshakes":(0,a.enqueueActions)(({context:e,enqueue:t})=>{e.handshakeBuffer.forEach(e=>t.raise(e)),t.assign({handshakeBuffer:[]})}),"remove request":(0,a.enqueueActions)(({context:e,enqueue:t,event:r})=>{(0,n.assertEvent)(r,["request.success","request.failed","request.aborted"]),(0,l.stopChild)(r.requestId),t.assign({requests:e.requests.filter(({id:e})=>e!==r.requestId)})}),"send response":(0,c.raise)(({event:e})=>((0,n.assertEvent)(e,["message.received","heartbeat.received"]),{type:"request",data:{type:k,responseTo:e.message.data.id,data:void 0}})),"send handshake syn ack":(0,c.raise)({type:"request",data:{type:q}}),"send pending messages":(0,a.enqueueActions)(({enqueue:e})=>{e.raise(({context:e})=>({type:"request",data:e.buffer.map(({data:e,resolvable:t,options:r})=>({data:e.data,type:e.type,expectResponse:!!t,resolvable:t,options:r}))})),e.emit(({context:e})=>({type:"buffer.flushed",messages:e.buffer.map(({data:e})=>e)})),e.assign({buffer:[]})}),"set connection config":(0,i.assign)({channelId:({event:e})=>((0,n.assertEvent)(e,"handshake.syn"),e.message.data.channelId),target:({event:e})=>((0,n.assertEvent)(e,"handshake.syn"),e.message.source||void 0),targetOrigin:({event:e})=>((0,n.assertEvent)(e,"handshake.syn"),e.message.origin)})},guards:{hasSource:({context:e})=>null!==e.target}}).createMachine({id:"node",context:({input:e})=>({buffer:[],channelId:null,connectTo:e.connectTo,domain:e.domain??E,handshakeBuffer:[],name:e.name,requests:[],target:void 0,targetOrigin:null}),invoke:{id:"listen for handshake syn",src:"listen",input:S({include:A,responseType:"handshake.syn"})},on:{"request.success":{actions:"remove request"},"request.failed":{actions:"remove request"},"request.aborted":{actions:"remove request"},"handshake.syn":{actions:"set connection config",target:".handshaking"}},initial:"idle",states:{idle:{entry:[{type:"emit status",params:{status:"idle"}}],on:{post:{actions:"buffer message"}}},handshaking:{guard:"hasSource",entry:["send handshake syn ack",{type:"emit status",params:{status:"handshaking"}}],invoke:[{id:"listen for handshake ack",src:"listen",input:S({include:O,count:1,responseType:"handshake.complete"}),onDone:"connected"},{id:"listen for disconnect",src:"listen",input:S({include:I,count:1,responseType:"disconnect"})},{id:"listen for messages",src:"listen",input:S({exclude:[I,A,O,T,k]})}],on:{request:{actions:"create request"},post:{actions:"buffer message"},"message.received":{actions:"buffer handshake"},disconnect:{target:"idle"}}},connected:{entry:["process pending handshakes","send pending messages",{type:"emit status",params:{status:"connected"}}],invoke:[{id:"listen for messages",src:"listen",input:S({exclude:[I,A,O,T,k]})},{id:"listen for heartbeat",src:"listen",input:S({include:T,responseType:"heartbeat.received"})},{id:"listen for disconnect",src:"listen",input:S({include:I,count:1,responseType:"disconnect"})}],on:{request:{actions:"create request"},post:{actions:"post message"},disconnect:{target:"idle"},"message.received":{actions:["send response","emit received message"]},"heartbeat.received":{actions:["send response","emit heartbeat"]}}}}}),D=(e,t=F())=>{let r,n=(0,o.createActor)(t,{input:e}),s=new Map,i=new Map;n.on("message",({message:e})=>{let t=s.get(e.type);if(t)return void t.forEach(t=>t(e.data));let r=i.get(e.type);r?r.add(e):i.set(e.type,new Set([e]))});let a=()=>{n.stop()};return{actor:n,fetch:(e,t,r)=>{let s,i,{responseTimeout:o=1e4,signal:a,suppressWarnings:c}=r||{},u="function"==typeof Promise.withResolvers?Promise.withResolvers():{promise:new Promise((e,t)=>
3{s=e,i=t}),resolve:s,reject:i};return n.send({type:"post",data:{type:e,data:t},resolvable:u,options:{responseTimeout:o,signal:a,suppressWarnings:c}}),u.promise},machine:t,on:(e,t,r)=>{let n=s.get(e)||new Set;s.has(e)||s.set(e,n),n.add(t);let o=i.get(e);if(o){let n=r?.replay??1;Array.from(o).slice(-n).forEach(({data:e})=>t(e)),i.delete(e)}return()=>{n.delete(t)}},onStatus:(e,t)=>{let s=n.on("status",n=>{r=n.status,t&&n.status!==t||e(n.status)});return r&&e(r),()=>s.unsubscribe()},post:(e,t)=>{n.send({type:"post",data:{type:e,data:t}})},start:()=>(n.start(),a),stop:a}};e.s(["DOMAIN",()=>E,"MSG_DISCONNECT",()=>I,"MSG_HANDSHAKE_ACK",()=>O,"MSG_HANDSHAKE_SYN",()=>A,"MSG_HANDSHAKE_SYN_ACK",()=>q,"MSG_HEARTBEAT",()=>T,"MSG_RESPONSE",()=>k,"createConnectionMachine",()=>M,"createController",()=>C,"createListenLogic",()=>w,"createNode",()=>D,"createNodeMachine",()=>F,"createRequestMachine",()=>$])}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.