1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,614677,t=>{"use strict";let e,n="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),r=new Uint8Array(16),s=[];for(let t=0;t<256;++t)s.push((t+256).toString(16).slice(1));t.s(["v4",0,function(t,i,o){if(n&&!i&&!t)return n();var a=t,c=o;let u=(a=a||{}).random??a.rng?.()??function(){if(!e){if("u"<typeof crypto||!crypto.getRandomValues)throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");e=crypto.getRandomValues.bind(crypto)}return e(r)}();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 t=0;t<16;++t)i[c+t]=u[t];return i}return function(t,e=0){return(s[t[e+0]]+s[t[e+1]]+s[t[e+2]]+s[t[e+3]]+"-"+s[t[e+4]]+s[t[e+5]]+"-"+s[t[e+6]]+s[t[e+7]]+"-"+s[t[e+8]]+s[t[e+9]]+"-"+s[t[e+10]]+s[t[e+11]]+s[t[e+12]]+s[t[e+13]]+s[t[e+14]]+s[t[e+15]]).toLowerCase()}(u)}],614677)},636536,908667,807574,214990,509820,663095,269193,721634,688236,681026,613650,290571,603752,842093,586903,909116,140260,240126,979165,282541,394426,987675,349449,717718,238331,254824,177650,23515,311902,220324,172441,902965,627608,94059,175436,484973,272383,722249,589293,96623,881283,t=>{"use strict";var e,n,r,s,i=t.i(614677);class o{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){let e={value:t,next:null};if(this._current){this._last.next=e,this._last=e;return}this._current=e,this._last=e,this._active&&this.flush()}flush(){for(;this._current;){let t=this._current;this._process(t.value),this._current=t.next}this._last=null}}let a="xstate.init",c="xstate.error",u="xstate.stop";function l(t,e){return{type:`xstate.done.state.${t}`,output:e}}function f(t,e){return{type:`xstate.error.actor.${t}`,error:e,actorId:t}}function h(t){return{type:a,input:t}}function p(t){setTimeout(()=>{throw t})}let d="function"==typeof Symbol&&Symbol.observable||"@@observable";function y(t){if(_(t))return t;let e=[],n="";for(let r=0;r<t.length;r++){switch(t.charCodeAt(r)){case 92:n+=t[r+1],r++;continue;case 46:e.push(n),n="";continue}n+=t[r]}return e.push(n),e}function v(t){var e;return(e=t)&&"object"==typeof e&&"machine"in e&&"value"in e?t.value:"string"!=typeof t?t:function(t){if(1===t.length)return t[0];let e={},n=e;for(let e=0;e<t.length-1;e++)if(e===t.length-2)n[t[e]]=t[e+1];else{let r=n;n={},r[t[e]]=n}return e}(y(t))}function g(t,e){let n={},r=Object.keys(t);for(let s=0;s<r.length;s++){let i=r[s];n[i]=e(t[i],i,t,s)}return n}function m(t){var e;return void 0===t?[]:_(e=t)?e:[e]}function b(t,e,n,r){return"function"==typeof t?t({context:e,event:n,self:r}):t}function _(t){return Array.isArray(t)}function S(t){var e;return(_(e=t)?e:[e]).map(t=>void 0===t||"string"==typeof t?{target:t}:t)}function x(t){if(void 0!==t&&""!==t)return m(t)}function w(t,e,n){let r="object"==typeof t,s=r?t:void 0;return{next:(r?t.next:t)?.bind(s),error:(r?t.error:e)?.bind(s),complete:(r?t.complete:n)?.bind(s)}}function k(t,e){return`${e}.${t}`}function E(t,e){let n=e.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!n)return t.implementations.actors[e];let[,r,s]=n,i=t.getStateNodeById(s).config.invoke;return(Array.isArray(i)?i[r]:i).src}function I(t,e){if(e===t||"*"===e)return!0;if(!e.endsWith(".*"))return!1;let n=e.split("."),r=t.split(".");for(let t=0;t<n.length;t++){let e=n[t],s=r[t];if("*"===e)return t===n.length-1;if(e!==s)return!1}return!0}function T(t,e){return`${t.sessionId}.${e}`}let O=0,A=!1,$=((e={})[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped",e),R={clock:{setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t)},logger:console.log.bind(console),devTools:!1};
1class j{constructor(t,e){this.logic=t,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new o(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=$.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this.systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];const n={...R,...e},{clock:r,logger:s,parent:i,syncSnapshot:a,id:c,systemId:u,inspect:l}=n;this.system=i?i.system:function(t,e){let n=new Map,r=new Map,s=new WeakMap,i=new Set,o={},{clock:a,logger:c}=e,u={schedule:(t,e,n,r,s=Math.random().toString(36).slice(2))=>{let i={source:t,target:e,event:n,delay:r,id:s,startedAt:Date.now()},c=T(t,s);l._snapshot._scheduledEvents[c]=i;let u=a.setTimeout(()=>{delete o[c],delete l._snapshot._scheduledEvents[c],l._relay(t,e,n)},r);o[c]=u},cancel:(t,e)=>{let n=T(t,e),r=o[n];delete o[n],delete l._snapshot._scheduledEvents[n],void 0!==r&&a.clearTimeout(r)},cancelAll:t=>{for(let e in l._snapshot._scheduledEvents){let n=l._snapshot._scheduledEvents[e];n.source===t&&u.cancel(t,n.id)}}},l={_snapshot:{_scheduledEvents:(e?.snapshot&&e.snapshot.scheduler)??{}},_bookId:()=>`x:${O++}`,_register:(t,e)=>(n.set(t,e),t),_unregister:t=>{n.delete(t.sessionId);let e=s.get(t);void 0!==e&&(r.delete(e),s.delete(t))},get:t=>r.get(t),getAll:()=>Object.fromEntries(r.entries()),_set:(t,e)=>{let n=r.get(t);if(n&&n!==e)throw Error(`Actor with system ID '${t}' already exists.`);r.set(t,e),s.set(e,t)},inspect:t=>{let e=w(t);return i.add(e),{unsubscribe(){i.delete(e)}}},_sendInspectionEvent:e=>{if(!i.size)return;let n={...e,rootId:t.sessionId};i.forEach(t=>t.next?.(n))},_relay:(t,e,n)=>{l._sendInspectionEvent({type:"@xstate.event",sourceRef:t,actorRef:e,event:n}),e._send(n)},scheduler:u,getSnapshot:()=>({_scheduledEvents:{...l._snapshot._scheduledEvents}}),start:()=>{let t=l._snapshot._scheduledEvents;for(let e in l._snapshot._scheduledEvents={},t){let{source:n,target:r,event:s,delay:i,id:o}=t[e];u.schedule(n,r,s,i,o)}},_clock:a,_logger:c};return l}(this,{clock:r,logger:s}),l&&!i&&this.system.inspect(w(l)),this.sessionId=this.system._bookId(),this.id=c??this.sessionId,this.logger=e?.logger??this.system._logger,this.clock=e?.clock??this.system._clock,this._parent=i,this._syncSnapshot=a,this.options=n,this.src=n.src??t,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:t=>{this._deferred.push(t)},system:this.system,stopChild:t=>{if(t._parent!==this)throw Error(`Cannot stop child actor ${t.id} of ${this.id} because it is not a child`);t._stop()},emit:t=>{let e=this.eventListeners.get(t.type),n=this.eventListeners.get("*");if(e||n)for(let r of[...e?e.values():[],...n?n.values():[]])try{r(t)}catch(t){p(t)}},actionExecutor:t=>{let e=()=>{if(this._actorScope.system._sendInspectionEvent({type:"@xstate.action",actorRef:this,action:{type:t.type,params:t.params}}),!t.exec)return;let e=A;try{A=!0,t.exec(t.info,t.params)}finally{A=e}};this._processingStatus===$.Running?e():this._deferred.push(e)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),u&&(this.systemId=u,this.system._set(u,this)),this._initState(e?.snapshot??e?.state),u&&"active"!==this._snapshot.status&&this.system._unregister(this)}_initState(t){try{this._snapshot=t?this.logic.restoreSnapshot?this.logic.restoreSnapshot(t,this._actorScope):t:this.logic.getInitialSnapshot(this._actorScope,this.options?.input)}catch(t){this._snapshot={status:"error",output:void 0,error:t}}}update(t,e){let n;for(this._snapshot=t;n=this._deferred.shift();)try{n()}catch(e){this._deferred.length=0,this._snapshot={...t,status:"error",error:e}}switch(this._snapshot.status){case"active":for(let e of this.observers)try{e.next?.(t)}catch(t){p(t)}break;case"done":var r;for(let e of this.observers)try{e.next?.(t)}catch(t){p(t)}this._stopProcedure(),this._complete(),this._doneEvent=(r=this.id,{type:`xstate.done.actor.${r}`,output:this._snapshot.output,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){let r=w(t,e,n);if(this._processingStatus!==$.Stopped)this.observers.add(r);else switch(this._snapshot.status){case"done":try{r.complete?.()}catch(t){p(t)}break;case"error":{let t=this._snapshot.error;if(r.error)try{r.error(t)}catch(t){p(t)}else p(t)}}return{unsubscribe:()=>{this.observers.delete(r)}}}on(t,e){let n=this.eventListeners.get(t);n||(n=new Set,this.eventListeners.set(t,n));let r=e.bind(void 0);return n.add(r),{unsubscribe:()=>{n.delete(r)}}}
1start(){if(this._processingStatus===$.Running)return this;this._syncSnapshot&&this.subscribe({next:t=>{"active"===t.status&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:t})},error:()=>{}}),this.system._register(this.sessionId,this),this.systemId&&this.system._set(this.systemId,this),this._processingStatus=$.Running;let t=h(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(t){return this._snapshot={...this._snapshot,status:"error",error:t},this._error(t),this}return this.update(this._snapshot,t),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(t){let e,n;try{e=this.logic.transition(this._snapshot,t,this._actorScope)}catch(t){n={err:t}}if(n){let{err:t}=n;this._snapshot={...this._snapshot,status:"error",error:t},this._error(t);return}this.update(e,t),t.type===u&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===$.Stopped||((this.mailbox.clear(),this._processingStatus===$.NotStarted)?this._processingStatus=$.Stopped:this.mailbox.enqueue({type:u})),this}stop(){if(this._parent)throw Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){for(let t of this.observers)try{t.complete?.()}catch(t){p(t)}this.observers.clear(),this.eventListeners.clear()}_reportError(t){if(!this.observers.size){this._parent||p(t),this.eventListeners.clear();return}let e=!1;for(let n of this.observers){let r=n.error;e||=!r;try{r?.(t)}catch(t){p(t)}}this.observers.clear(),this.eventListeners.clear(),e&&p(t)}_error(t){this._stopProcedure(),this._reportError(t),this._parent&&this.system._relay(this,this._parent,f(this.id,t))}_stopProcedure(){return this._processingStatus!==$.Running||(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new o(this._process.bind(this)),this._processingStatus=$.Stopped,this.system._unregister(this)),this}_send(t){this._processingStatus!==$.Stopped&&this.mailbox.enqueue(t)}send(t){this.system._relay(void 0,this,t)}attachDevTools(){let{devTools:e}=this.options;e&&("function"==typeof e?e:e=>{if("u"<typeof window)return;let n=function(){let e="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:t.g;if(e.__xstate__)return e.__xstate__}();n&&n.register(e)})(this)}toJSON(){return{xstate$$type:1,id:this.id}}getPersistedSnapshot(t){return this.logic.getPersistedSnapshot(this._snapshot,t)}[d](){return this}getSnapshot(){return this._snapshot}}function P(t,...[e]){return new j(t,e)}function M(t,e,n,r,{sendId:s}){return[e,{sendId:"function"==typeof s?s(n,r):s},void 0]}function q(t,e){t.defer(()=>{t.system.scheduler.cancel(t.self,e.sendId)})}function N(t){function e(t,e){}return e.type="xstate.cancel",e.sendId=t,e.resolve=M,e.execute=q,e}function C(t,e,n,r,{id:s,systemId:i,src:o,input:a,syncSnapshot:c}){let u,l,f="string"==typeof o?E(e.machine,o):o,h="function"==typeof s?s(n):s;return f&&(l="function"==typeof a?a({context:e.context,event:n.event,self:t.self}):a,u=P(f,{id:h,src:o,parent:t.self,syncSnapshot:c,systemId:i,input:l})),[tj(e,{children:{...e.children,[h]:u}}),{id:s,systemId:i,actorRef:u,src:o,input:l},void 0]}function L(t,{actorRef:e}){e&&t.defer(()=>{e._processingStatus!==$.Stopped&&e.start()})}function D(...[t,{id:e,systemId:n,input:r,syncSnapshot:s=!1}={}]){function i(t,e){}return i.type="xstate.spawnChild",i.id=e,i.systemId=n,i.src=t,i.input=r,i.syncSnapshot=s,i.resolve=C,i.execute=L,i}function U(t,e,n,r,{actorRef:s}){let i="function"==typeof s?s(n,r):s,o="string"==typeof i?e.children[i]:i,a=e.children;return o&&(a={...a},delete a[o.id]),[tj(e,{children:a}),o,void 0]}function B(t,e){if(e){if(!function t(e,n){let r=n.getSnapshot();if(r&&"children"in r)for(let n of Object.values(r.children))t(e,n);e.system._unregister(n)}(t,e),e._processingStatus!==$.Running)return void t.stopChild(e);t.defer(()=>{t.stopChild(e)})}}function z(t){function e(t,e){}return e.type="xstate.stopChild",e.actorRef=t,e.resolve=U,e.execute=B,e}function V(t,e,n,r){let{machine:s}=r,i="function"==typeof t,o=i?t:s.implementations.guards["string"==typeof t?t:t.type];if(!i&&!o)throw Error(`Guard '${"string"==typeof t?t:t.type}' is not implemented.'.`);if("function"!=typeof o)return V(o,e,n,r);let a={context:e,event:n},c=i||"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)}function W(t){return"atomic"===t.type||"final"===t.type}function G(t){return Object.values(t.states).filter(t=>"history"!==t.type)}function J(t,e){let n=[];if(e===t)return n;let r=t.parent;for(;r&&r!==e;)n.push(r),r=r.parent;return n}function Y(t){let e=new Set(t),n=H(e);for(let t of e)if("compound"!==t.type||n.get(t)&&n.get(t).length){if("parallel"===t.type){for(let n of G(t))if("history"!==n.type&&!e.has(n))for(let t of to(n))e.add(t)}}else to(t).forEach(t=>e.add(t));for(let t of e){let n=t.parent;for(;n;)e.add(n),n=n.parent}return e}function H(t){let e=new Map;for(let n of t)e.has(n)||e.set(n,[]),n.parent&&(e.has(n.parent)||e.set(n.parent,[]),e.get(n.parent).push(n));return e}function K(t,e){return function t(e,n){let r=n.get(e);if(!r)return{};if("compound"===e.type){let t=r[0];if(!t)return{};if(W(t))return t.key}let s={};for(let e of r)s[e.key]=t(e,n);return s}(t,H(Y(e)))}function F(t,e){return"compound"===e.type?G(e).some(e=>"final"===e.type&&t.has(e)):"parallel"===e.type?G(e).every(e=>F(t,e)):"final"===e.type}let Q=t=>"#"===t[0];function X(t,e){return t.transitions.get(e)||[...t.transitions.keys()].filter(t=>I(e,t)).sort((t,e)=>e.length-t.length).flatMap(e=>t.transitions.get(e))}function Z(t){let e=t.config.after;return e?Object.keys(e).flatMap(n=>{var r;let s,i,o=e[n],a=Number.isNaN(+n)?n:+n,c=(r=t.id,i=(s={type:`xstate.after.${a}.${r}`}).type,t.entry.push(tN(s,{id:i,delay:a})),t.exit.push(N(i)),i);return m("string"==typeof o?{target:o}:o).map(t=>({...t,event:c,delay:a}))}).map(e=>{let{delay:n}=e;return{...tt(t,e.event,e),delay:n}}):[]}function tt(t,e,n){let r=x(n.target),s=n.reenter??!1,i=function(t,e){if(void 0!==e)return e.map(e=>{if("string"!=typeof e)return e;if(Q(e))return t.machine.getStateNodeById(e);let n="."===e[0];if(n&&!t.parent)return tu(t,e.slice(1));let r=n?t.key+e:e;if(t.parent)try{return tu(t.parent,r)}catch(e){throw Error(`Invalid transition definition for state node '${t.id}': 2${e.message}`)}throw Error(`Invalid target: "${e}" is not a valid target from the root node. Did you mean ".${e}"?`)})}(t,r),o={...n,actions:m(n.actions),guard:n.guard,target:i,source:t,reenter
2:s,eventType:e,toJSON:()=>({...o,source:`#${t.id}`,target:i?i.map(t=>`#${t.id}`):void 0})};return o}function te(t){let e=new Map;if(t.config.on)for(let n of Object.keys(t.config.on)){if(""===n)throw Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');let r=t.config.on[n];e.set(n,S(r).map(e=>tt(t,n,e)))}if(t.config.onDone){let n=`xstate.done.state.${t.id}`;e.set(n,S(t.config.onDone).map(e=>tt(t,n,e)))}for(let n of t.invoke){if(n.onDone){let r=`xstate.done.actor.${n.id}`;e.set(r,S(n.onDone).map(e=>tt(t,r,e)))}if(n.onError){let r=`xstate.error.actor.${n.id}`;e.set(r,S(n.onError).map(e=>tt(t,r,e)))}if(n.onSnapshot){let r=`xstate.snapshot.${n.id}`;e.set(r,S(n.onSnapshot).map(e=>tt(t,r,e)))}}for(let n of t.after){let t=e.get(n.eventType);t||(t=[],e.set(n.eventType,t)),t.push(n)}return e}function tn(t){let e=[],n=r=>{Object.values(r).forEach(r=>{if(r.config.route&&r.config.id){let n=r.config.id,s=r.config.route.guard,i={...r.config.route,guard:(t,e)=>t.event.to===`#${n}`&&(!s||"function"!=typeof s||s(t,e)),target:`#${n}`};e.push(tt(t,"xstate.route",i))}r.states&&n(r.states)})};n(t.states),e.length>0&&t.transitions.set("xstate.route",e)}function tr(t,e){let n="string"==typeof e?t.states[e]:e?t.states[e.target]:void 0;if(!n&&e)throw Error(`Initial state node "${e}" not found on parent state node #${t.id}`);let r={source:t,actions:e&&"string"!=typeof e?m(e.actions):[],eventType:null,reenter:!1,target:n?[n]:[],toJSON:()=>({...r,source:`#${t.id}`,target:n?[`#${n.id}`]:[]})};return r}function ts(t){let e=x(t.config.target);return e?{target:e.map(e=>"string"==typeof e?tu(t.parent,e):e)}:t.parent.initial}function ti(t){return"history"===t.type}function to(t){let e=ta(t);for(let n of e)for(let r of J(n,t))e.add(r);return e}function ta(t){let 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)for(let e of G(n))t(e)}}(t),e}function tc(t,e){if(Q(e))return t.machine.getStateNodeById(e);if(!t.states)throw Error(`Unable to retrieve child state '${e}' from '${t.id}'; no child states exist.`);let n=t.states[e];if(!n)throw Error(`Child state '${e}' does not exist on '${t.id}'`);return n}function tu(t,e){if("string"==typeof e&&Q(e))try{return t.machine.getStateNodeById(e)}catch{}let n=y(e).slice(),r=t;for(;n.length;){let t=n.shift();if(!t.length)break;r=tc(r,t)}return r}function tl(t,e){if("string"==typeof e){let n=t.states[e];if(!n)throw Error(`State '${e}' does not exist on '${t.id}'`);return[t,n]}let n=Object.keys(e),r=n.map(e=>tc(t,e)).filter(Boolean);return[t.machine.root,t].concat(r,n.reduce((n,r)=>{let s=tc(t,r);if(!s)return n;let i=tl(s,e[r]);return n.concat(i)},[]))}function tf(t,e,n,r){if("string"==typeof e){let s;return(s=tc(t,e).next(n,r))&&s.length?s:t.next(n,r)}if(1===Object.keys(e).length){let s,i;return(i=tf(tc(t,(s=Object.keys(e))[0]),e[s[0]],n,r))&&i.length?i:t.next(n,r)}let s=[];for(let i of Object.keys(e)){let o=e[i];if(!o)continue;let a=tf(tc(t,i),o,n,r);a&&s.push(...a)}return s.length?s:t.next(n,r)}function th(t,e){let n=t;for(;n.parent&&n.parent!==e;)n=n.parent;return n.parent===e}function tp(t,e,n){let r=new Set;for(let s of t){let t=!1,i=new Set;for(let o of r)if(function(t,e){let n=new Set(t),r=new Set(e);for(let t of n)if(r.has(t))return!0;for(let t of r)if(n.has(t))return!0;return!1}(tv([s],e,n),tv([o],e,n)))if(th(s.source,o.source))i.add(o);else{t=!0;break}if(!t){for(let t of i)r.delete(t);r.add(s)}}return Array.from(r)}function td(t,e){if(!t.target)return[];let n=new Set;for(let r of t.target)if(ti(r))if(e[r.id])for(let t of e[r.id])n.add(t);else for(let t of td(ts(r),e))n.add(t);else n.add(r);return[...n]}function ty(t,e){let n=td(t,e);if(!n)return;if(!t.reenter&&n.every(e=>e===t.source||th(e,t.source)))return t.source;let r=function(t){let[e,...n]=t;for(let t of J(e,void 0))if(n.every(e=>th(e,t)))return t}(n.concat(t.source));return r||(t.reenter?void 0:t.source.machine.root)}function tv(t,e,n){let r=new Set;for(let s of t)if(s.target?.length){let t=ty(s,n);for(let n of(s.reenter&&s.source===t&&r.add(t),e))th(n,t)&&r.add(n)}return[...r]}function tg(t,e,n,r,s){return tm([{target:[...ta(t)],source:t,reenter
2:!0,actions:[],eventType:null,toJSON:null}],e,n,r,!0,s)}function tm(t,e,n,r,s,i){let o=[];if(!t.length)return[e,o];let a=n.actionExecutor;n.actionExecutor=t=>{o.push(t),a(t)};try{let a=new Set(e._nodes),c=e.historyValue,u=tp(t,a,c),f=e;s||([f,c]=function(t,e,n,r,s,i,o,a){let c,u=t,l=tv(r,s,i);for(let t of(l.sort((t,e)=>e.order-t.order),l))for(let e of function(t){return Object.keys(t.states).map(e=>t.states[e]).filter(t=>"history"===t.type)}(t)){let n;n="deep"===e.history?e=>W(e)&&th(e,t):e=>e.parent===t,(c??={...i})[e.id]=Array.from(s).filter(n)}for(let t of l)u=tS(u,e,n,[...t.exit,...t.invoke.map(t=>z(t.id))],o,void 0),s.delete(t);return[u,c||i]}(f,r,n,u,a,c,i,n.actionExecutor)),f=tS(f,r,n,u.flatMap(t=>t.actions),i,void 0),f=function(t,e,n,r,s,i,o,a){let c=t,u=new Set,f=new Set;(function(t,e,n,r){for(let s of t){let t=ty(s,e);for(let i of s.target||[])!ti(i)&&(s.source!==i||s.source!==t||s.reenter)&&(r.add(i),n.add(i)),tb(i,e,n,r);for(let i of td(s,e)){let o=J(i,t);t?.type==="parallel"&&o.push(t),t_(r,e,n,o,!s.source.parent&&s.reenter?void 0:t)}}})(r,o,f,u),a&&f.add(t.machine.root);let h=new Set;for(let t of[...u].sort((t,e)=>t.order-e.order)){s.add(t);let r=[];for(let e of(r.push(...t.entry),t.invoke))r.push(D(e.src,{...e,syncSnapshot:!!e.onSnapshot}));if(f.has(t)){let e=t.initial.actions;r.push(...e)}if(c=tS(c,e,n,r,i,t.invoke.map(t=>t.id)),"final"===t.type){let r=t.parent,o=r?.type==="parallel"?r:r?.parent,a=o||t;for(r?.type==="compound"&&i.push(l(r.id,void 0!==t.output?b(t.output,c.context,e,n.self):void 0));o?.type==="parallel"&&!h.has(o)&&F(s,o);)h.add(o),i.push(l(o.id)),a=o,o=o.parent;if(o)continue;c=tj(c,{status:"done",output:function(t,e,n,r,s){if(void 0===r.output)return;let i=l(s.id,void 0!==s.output&&s.parent?b(s.output,t.context,e,n.self):void 0);return b(r.output,t.context,i,n.self)}(c,e,n,c.machine.root,a)})}}return c}(f,r,n,u,a,i,c,s);let h=[...a];"done"===f.status&&(f=tS(f,r,n,h.sort((t,e)=>e.order-t.order).flatMap(t=>t.exit),i,void 0));try{if(c===e.historyValue&&function(t,e){if(t.length!==e.size)return!1;for(let n of t)if(!e.has(n))return!1;return!0}(e._nodes,a))return[f,o];return[tj(f,{_nodes:h,historyValue:c}),o]}catch(t){throw t}}finally{n.actionExecutor=a}}function tb(t,e,n,r){var s,i,o,a;if(ti(t))if(e[t.id]){let o=e[t.id];for(let t of o)r.add(t),tb(t,e,n,r);for(let a of o){s=a,i=t.parent,t_(r,e,n,J(s,i))}}else{let s=ts(t);for(let i of s.target)r.add(i),s===t.parent?.initial&&n.add(t.parent),tb(i,e,n,r);for(let i of s.target){o=i,a=t.parent,t_(r,e,n,J(o,a))}}else if("compound"===t.type){let[s]=t.initial.target;ti(s)||(r.add(s),n.add(s)),tb(s,e,n,r),t_(r,e,n,J(s,t))}else if("parallel"===t.type)for(let s of G(t).filter(t=>!ti(t)))[...r].some(t=>th(t,s))||(ti(s)||(r.add(s),n.add(s)),tb(s,e,n,r))}function t_(t,e,n,r,s){for(let i of r)if((!s||th(i,s))&&t.add(i),"parallel"===i.type)for(let r of G(i).filter(t=>!ti(t)))[...t].some(t=>th(t,r))||(t.add(r),tb(r,e,n,t))}function tS(t,e,n,r,s,i){let o=i?[]:void 0,a=function t(e,n,r,s,i,o){let{machine:a}=e,c=e;for(let e of s){var u;let s="function"==typeof e,l=s?e:(u="string"==typeof e?e:e.type,a.implementations.actions[u]),f={context:c.context,event:n,self:r.self,system:r.system},h=s||"string"==typeof e?void 0:"params"in e?"function"==typeof e.params?e.params({context:c.context,event:n}):e.params:void 0;if(!l||!("resolve"in l)){r.actionExecutor({type:"string"==typeof e?e:"object"==typeof e?e.type:e.name||"(anonymous)",info:f,params:h,exec:l});continue}let[p,d,y]=l.resolve(r,c,f,h,l,i);c=p,"retryResolve"in l&&o?.push([l,d]),"execute"in l&&r.actionExecutor({type:l.type,info:f,params:d,exec:l.execute.bind(null,r,d)}),y&&(c=t(c,n,r,y,i,o))}return c}(t,e,n,r,{internalQueue:s,deferredActorIds:i},o);return o?.forEach(([t,e])=>{t.retryResolve(n,a,e)}),a}function tx(t,e,n,r){let s=t,i=[];function o(t,e,r){n.system._sendInspectionEvent({type:"@xstate.microstep",actorRef:n.self,event:e,snapshot:t[0],_transitions:r}),i.push(t)}if(e.type===u)return o([s=tj(tw(s,e,n),{status:"stopped"}),[]],e,[]),{snapshot:s,microsteps:i};let c=e;if(c.type!==a){let e=c,a=e.type.startsWith("xstate.error.actor"),u=tk(e,s);if(a&&!u.length)return o([s=tj(t,{status:"error",error:e.error}),[]],e,[]),{snapshot:s,microsteps:i};let l=tm(u,t,n,c,!1,r);s=l[0],o(l,e,u)}
2let l=!0;for(;"active"===s.status;){let t=l?function(t,e){let n=new Set;for(let r of t._nodes.filter(W))t:for(let s of[r].concat(J(r,void 0)))if(s.always){for(let r of s.always)if(void 0===r.guard||V(r.guard,t.context,e,t)){n.add(r);break t}}return tp(Array.from(n),new Set(t._nodes),t.historyValue)}(s,c):[],e=t.length?s:void 0;if(!t.length){if(!r.length)break;t=tk(c=r.shift(),s)}let i=tm(t,s,n,c,!1,r);l=(s=i[0])!==e,o(i,c,t)}return"active"!==s.status&&tw(s,c,n),{snapshot:s,microsteps:i}}function tw(t,e,n){return tS(t,e,n,Object.values(t.children).map(t=>z(t)),[],void 0)}function tk(t,e){return e.machine.getTransitionData(e,t)}function tE(t,e){let n=Y(tl(t,e));return K(t,[...n])}let tI=function(t){return function t(e,n){let r=v(e),s=v(n);return"string"==typeof s?"string"==typeof r&&s===r:"string"==typeof r?r in s:Object.keys(r).every(e=>e in s&&t(r[e],s[e]))}(t,this.value)},tT=function(t){return this.tags.has(t)},tO=function(t){let e=this.machine.getTransitionData(this,t);return!!e?.length&&e.some(t=>void 0!==t.target||t.actions.length)},tA=function(){let{_nodes:t,tags:e,machine:n,getMeta:r,toJSON:s,can:i,hasTag:o,matches:a,...c}=this;return{...c,tags:Array.from(e)}},t$=function(){return this._nodes.reduce((t,e)=>(void 0!==e.meta&&(t[e.id]=e.meta),t),{})};function tR(t,e){return{status:t.status,output:t.output,error:t.error,machine:e,context:t.context,_nodes:t._nodes,value:K(e.root,t._nodes),tags:new Set(t._nodes.flatMap(t=>t.tags)),children:t.children,historyValue:t.historyValue||{},matches:tI,hasTag:tT,can:tO,getMeta:t$,toJSON:tA}}function tj(t,e={}){return tR({...t,...e},t.machine)}function tP(t,e){let{_nodes:n,tags:r,machine:s,children:i,context:o,can:a,hasTag:c,matches:u,getMeta:l,toJSON:f,...h}=t,p={};for(let t in i){let n=i[t];p[t]={snapshot:n.getPersistedSnapshot(e),src:n.src,systemId:n.systemId,syncSnapshot:n._syncSnapshot}}return{...h,context:function t(e){let n;for(let r in e){let s=e[r];if(s&&"object"==typeof s)if("sessionId"in s&&"send"in s&&"ref"in s)(n??=Array.isArray(e)?e.slice():{...e})[r]={xstate$$type:1,id:s.id};else{let i=t(s);i!==s&&((n??=Array.isArray(e)?e.slice():{...e})[r]=i)}}return n??e}(o),children:p,historyValue:function(t){if("object"!=typeof t||null===t)return{};let e={};for(let n in t){let r=t[n];Array.isArray(r)&&(e[n]=r.map(t=>({id:t.id})))}return e}(h.historyValue)}}function tM(t,e,n,r,{event:s,id:i,delay:o},{internalQueue:a}){let c,u=e.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(n,r):s;if("string"==typeof o){let t=u&&u[o];c="function"==typeof t?t(n,r):t}else c="function"==typeof o?o(n,r):o;return"number"!=typeof c&&a.push(l),[e,{event:l,id:i,delay:c},void 0]}function tq(t,e){let{event:n,delay:r,id:s}=e;if("number"==typeof r)return void t.defer(()=>{let e=t.self;t.system.scheduler.schedule(e,e,n,r,s)})}function tN(t,e){function n(t,e){}return n.type="xstate.raise",n.event=t,n.id=e?.id,n.delay=e?.delay,n.resolve=tM,n.execute=tq,n}t.s(["$",()=>1,"B",()=>S,"C",()=>tt,"D",()=>V,"E",()=>k,"F",()=>Z,"G",()=>tr,"H",()=>X,"I",()=>tn,"J",()=>tE,"K",()=>Y,"L",()=>tR,"M",()=>F,"N",()=>"","O",()=>tf,"P",()=>tS,"Q",()=>y,"R",()=>Q,"S",()=>".","T",()=>tu,"U",()=>tP,"V",()=>E,"W",()=>c,"X",()=>u,"Y",()=>f,"Z",()=>$,"_",()=>tj,"a",()=>N,"b",()=>D,"c",()=>P,"d",()=>tx,"e",()=>h,"f",()=>W,"g",()=>J,"i",()=>tg,"m",()=>I,"p",()=>tl,"r",()=>tN,"s",()=>z,"t",()=>m,"y",()=>g,"z",()=>te],908667);let tC=new WeakMap;function tL(t){return{config:t,start:(e,n)=>{let{self:r,system:s,emit:i}=n,o={receivers:void 0,dispose:void 0};tC.set(r,o),o.dispose=t({input:e.input,system:s,self:r,sendBack:t=>{"stopped"!==r.getSnapshot().status&&r._parent&&s._relay(r,r._parent,t)},receive:t=>{o.receivers??=new Set,o.receivers.add(t)},emit:i})},transition:(t,e,n)=>{let r=tC.get(n.self);return e.type===u?(t={...t,status:"stopped",error:void 0},tC.delete(n.self),r.receivers?.clear(),r.dispose?.()):r.receivers?.forEach(t=>t(e)),t},getInitialSnapshot:(t,e)=>({status:"active",output:void 0,error:void 0,input:e}),getPersistedSnapshot:t=>t,restoreSnapshot:t=>t}}let tD="xstate.observable.error",tU="xstate.observable.complete";function tB(t){return{config:t,transition:(t,e)=>{if("active"!==t.status)return t;switch(e.type){case tD:return{...t,status:"error",error:e.data,input:void 0,_subscription:void 0};case tU:return{...t,status:"done",input:void 0,_subscription:void 0};case u:return t._subscription.unsubscribe(),{...t,status:"stopped",input:void 0,_subscription:void 0};default:return t}},getInitialSnapshot:(t,e)=>({status:"active",output:void 0,error:void 0,context:void 0,input:e,_subscription:void 0}),start:(e,{self:n,system:r,emit:s})=>{"done"!==e.status&&(e._subscription=t({input:e.input,system:r,self:n,emit:s}).subscribe({next:t=>{n._parent&&r._relay(n,n._parent,t)},error:t=>{r._relay(n,n,{type:tD,data:t})},complete:()=>{r._relay(n,n,{type:tU})}}))},getPersistedSnapshot:({_subscription:t,...e})=>e,restoreSnapshot:t=>({...t,_subscription:void 0})}}let tz="xstate.promise.resolve",tV="xstate.promise.reject",tW=new WeakMap;function tG(t){return{config:t,transition:(t,e,n)=>{if("active"!==t.status)return t;switch(e.type){case tz:{let n=e.data;return{...t,status:"done",output:n,input:void 0}}case tV:return{...t,status:"error",error:e.data,input:void 0};case u:return tW.get(n.self)?.abort(),tW.delete(n.self),{...t,status:"stopped",input:void 0};default:return t}},start:(e,{self:n,system:r,emit:s})=>{if("active"!==e.status)return;let i=new AbortController;tW.set(n,i),Promise.resolve(t({input:e.input,system:r,self:n,signal:i.signal,emit:s})).then(t=>
2{"active"===n.getSnapshot().status&&(tW.delete(n),r._relay(n,n,{type:tz,data:t}))},t=>{"active"===n.getSnapshot().status&&(tW.delete(n),r._relay(n,n,{type:tV,data:t}))})},getInitialSnapshot:(t,e)=>({status:"active",output:void 0,error:void 0,input:e}),getPersistedSnapshot:t=>t,restoreSnapshot:t=>t}}let tJ=(r=void 0,{config:n=t=>void 0,transition:(t,e,r)=>({...t,context:n(t.context,e,r)}),getInitialSnapshot:(t,e)=>({status:"active",output:void 0,error:void 0,context:"function"==typeof r?r({input:e}):r}),getPersistedSnapshot:t=>t,restoreSnapshot:t=>t});function tY(){return P(tJ)}function tH(t,e,n,r,{assignment:s}){if(!e.context)throw Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");let i={},o={context:e.context,event:n.event,spawn:function(t,{machine:e,context:n},r,s){return(i,o)=>{let a=((i,o)=>{if("string"!=typeof i)return P(i,{id:o?.id,parent:t.self,syncSnapshot:o?.syncSnapshot,input:o?.input,src:i,systemId:o?.systemId});{let a=E(e,i);if(!a)throw Error(`Actor logic '${i}' not implemented in machine '${e.id}'`);let c=P(a,{id:o?.id,parent:t.self,syncSnapshot:o?.syncSnapshot,input:"function"==typeof o?.input?o.input({context:n,event:r,self:t.self}):o?.input,src:i,systemId:o?.systemId});return s[c.id]=c,c}})(i,o);return s[a.id]=a,t.defer(()=>{a._processingStatus!==$.Stopped&&a.start()}),a}}(t,e,n.event,i),self:t.self,system:t.system},a={};if("function"==typeof s)a=s(o,r);else for(let t of Object.keys(s)){let e=s[t];a[t]="function"==typeof e?e(o,r):e}let c=Object.assign({},e.context,a);return[tj(e,{context:c,children:Object.keys(i).length?{...e.children,...i}:e.children}),void 0,void 0]}function tK(t){function e(t,e){}return e.type="xstate.assign",e.assignment=t,e.resolve=tH,e}t.s(["createEmptyActor",()=>tY,"fromCallback",()=>tL,"fromEventObservable",()=>tB,"fromPromise",()=>tG],807574);let tF=new WeakMap;function tQ(t,e,n){let r=tF.get(t);return r?e in r||(r[e]=n()):(r={[e]:n()},tF.set(t,r)),r[e]}let tX={},tZ=t=>"string"==typeof t?{type:t}:"function"==typeof t?"resolve"in t?{type:t.type}:{type:t.name}:t;class t0{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("."),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?g(this.config.states,(t,e)=>new t0(t,{_parent:this,_key:e,_machine:this.machine})):tX,"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=m(this.config.entry).slice(),this.exit=m(this.config.exit).slice(),this.meta=this.config.meta,this.output="final"!==this.type&&this.parent?void 0:this.config.output,this.tags=m(t.tags).slice()}_initialize(){this.transitions=te(this),this.config.always&&(this.always=S(this.config.always).map(t=>tt(this,"",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.t
2ype,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(tZ),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(t=>`#${t.id}`),source:`#${this.id}`,actions:this.initial.actions.map(tZ),eventType:null})}:void 0,history:this.history,states:g(this.states,t=>t.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(t=>({...t,actions:t.actions.map(tZ)})),entry:this.entry.map(tZ),exit:this.exit.map(tZ),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 tQ(this,"invoke",()=>m(this.config.invoke).map((t,e)=>{let{src:n,systemId:r}=t,s=t.id??k(this.id,e),i="string"==typeof n?n:`xstate.invoke.${k(this.id,e)}`;return{...t,src:i,id:s,systemId:r,toJSON(){let{onDone:e,onError:n,...r}=t;return{...r,type:"xstate.invoke",src:i,id:s}}}}))}get on(){return tQ(this,"on",()=>[...this.transitions].flatMap(([t,e])=>e.map(e=>[t,e])).reduce((t,[e,n])=>(t[e]=t[e]||[],t[e].push(n),t),{}))}get after(){return tQ(this,"delayedTransitions",()=>Z(this))}get initial(){return tQ(this,"initial",()=>tr(this,this.config.initial))}next(t,e){let n,r=e.type,s=[];for(let i of tQ(this,`candidates-${r}`,()=>X(this,r))){let{guard:o}=i,a=t.context,c=!1;try{c=!o||V(o,a,e,t)}catch(e){let t="string"==typeof o?o:"object"==typeof o?o.type:void 0;throw Error(`Unable to evaluate guard ${t?`'${t}' `:""}in transition for event '${r}' in state node '${this.id}': 3${e.message}`)}if(c){s.push(...i.actions),n=i;break}}return n?[n]:void 0}get events(){return tQ(this,"events",()=>{let{states:t}=this,e=new Set(this.ownEvents);if(t)for(let n of Object.keys(t)){let r=t[n];if(r.states)for(let t of r.events)e.add(`${t}`)}return Array.from(e)})}get ownEvents(){return Array.from(new Set(Object.keys(Object.fromEntries(this.transitions)).filter(t=>this.transitions.get(t).some(t=>!(!t.target&&!t.actions.length&&!t.reenter)))))}}class t1{constructor(t,e){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:e?.actors??{},actions:e?.actions??{},delays:e?.delays??{},guards:e?.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 t0(t,{_key:this.id,_machine:this}),this.root._initialize(),tn(this.root),this.states=this.root.states,this.events=this.root.events}provide(t){let{actions:e,guards:n,actors:r,delays:s}=this.implementations;return new t1(this.config,{actions:{...e,...t.actions},guards:{...n,...t.guards},actors:{...r,...t.actors},delays:{...s,...t.delays}})}resolveState(t){let e=tE(this.root,t.value),n=Y(tl(this.root,e));return tR({_nodes:[...n],context:t.context||{},children:{},status:F(n,this.root)?"done":t.status||"active",output:t.output,error:t.error,historyValue:t.historyValue},this)}transition(t,e,n){return tx(t,e,n,[]).snapshot}microstep(t,e,n){return tx(t,e,n,[]).microsteps.map(([t])=>t)}getTransitionData(t,e){return tf(this.root,t.value,t,e)||[]}_getPreInitialState(t,e,n){let{context:r}=this.config,s=tR({context:"function"!=typeof r&&r?r:{},_nodes:[this.root],children:{},status:"active"},this);return"function"==typeof r?tS(s,e,t,[tK(({spawn:t,event:e,self:n})=>r({spawn:t,input:e.input,self:n}))],n,void 0):s}getInitialSnapshot(t,e){let n=h(e),r=[],s=this._getPreInitialState(t,n,r),[i]=tg(this.root,s,t,n,r),{snapshot:o}=tx(i,n,t,r);return o}start(t){Object.values(t.children).forEach(t=>{"active"===t.getSnapshot().status&&t.start()})}getStateNodeById(t){let e=y(t),n=e.slice(1),r=Q(e[0])?e[0].slice(1):e[0],s=this.idMap.get(r);if(!s)throw Error(`Child state node '#${r}' does not exist on machine '${this.id}'`);return tu(s,n)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(t,e){return tP(t,e)}restoreSnapshot(t,e){let n={},r=t.children;Object.keys(r).forEach(t=>{let s=r[t],i=s.snapshot,o=s.src,a="string"==typeof o?E(this,o):o;if(!a)return;let c=P(a,{id:t,parent:e.self,syncSnapshot:s.syncSnapshot,snapshot:i,src:o,systemId:s.systemId});n[t]=c});let s=function(t,e){if(!e||"object"!=typeof e)return{};let n={};for(let r in e)for(let s of e[r]){let e=function(t,e){if(e instanceof t0)return e;try{return t.machine.getStateNodeById(e.id)}catch{}}
3(t,s);e&&(n[r]??=[],n[r].push(e))}return n}(this.root,t.historyValue),i=tR({...t,children:n,_nodes:Array.from(Y(tl(this.root,t.value))),historyValue:s},this),o=new Set;return!function t(e,n){if(!o.has(e))for(let r in o.add(e),e){let s=e[r];if(s&&"object"==typeof s){if("xstate$$type"in s&&1===s.xstate$$type){e[r]=n[s.id];continue}t(s,n)}}}(i.context,n),i}}function t2(t,e,n,r,{event:s}){return[e,{event:"function"==typeof s?s(n,r):s},void 0]}function t6(t,{event:e}){t.defer(()=>t.emit(e))}function t3(t){function e(t,e){}return e.type="xstate.emit",e.event=t,e.resolve=t2,e.execute=t6,e}let t4=((s={}).Parent="#_parent",s.Internal="#_internal",s);function t9(t,e,n,r,{to:s,event:i,id:o,delay:a},c){let u,l,f=e.machine.implementations.delays;if("string"==typeof i)throw Error(`Only event objects may be used with sendTo; use sendTo({ type: "${i}" }) instead`);let h="function"==typeof i?i(n,r):i;if("string"==typeof a){let t=f&&f[a];u="function"==typeof t?t(n,r):t}else u="function"==typeof a?a(n,r):a;let p="function"==typeof s?s(n,r):s;if("string"==typeof p){if(!(l=p===t4.Parent?t.self._parent:p===t4.Internal?t.self:p.startsWith("#_")?e.children[p.slice(2)]:c.deferredActorIds?.includes(p)?p:e.children[p]))throw Error(`Unable to send event to actor '${p}' from machine '${e.machine.id}'.`)}else l=p||t.self;return[e,{to:l,targetId:"string"==typeof p?p:void 0,event:h,id:o,delay:u},void 0]}function t7(t,e,n){"string"==typeof n.to&&(n.to=e.children[n.to])}function t5(t,e){t.defer(()=>{let{to:n,event:r,delay:s,id:i}=e;"number"==typeof s?t.system.scheduler.schedule(t.self,n,r,s,i):t.system._relay(t.self,n,r.type===c?f(t.self.id,r.data):r)})}function t8(t,e,n){function r(t,e){}return r.type="xstate.sendTo",r.to=t,r.event=e,r.id=n?.id,r.delay=n?.delay,r.resolve=t9,r.retryResolve=t7,r.execute=t5,r}function et(t,e){return t8(t4.Parent,t,e)}function ee(t,e,n,r,{collect:s}){let i=[],o=function(t){i.push(t)};return o.assign=(...t)=>{i.push(tK(...t))},o.cancel=(...t)=>{i.push(N(...t))},o.raise=(...t)=>{i.push(tN(...t))},o.sendTo=(...t)=>{i.push(t8(...t))},o.sendParent=(...t)=>{i.push(et(...t))},o.spawnChild=(...t)=>{i.push(D(...t))},o.stopChild=(...t)=>{i.push(z(...t))},o.emit=(...t)=>{i.push(t3(...t))},s({context:n.context,event:n.event,enqueue:o,check:t=>V(t,e.context,n.event,e),self:t.self,system:t.system},r),[e,void 0,i]}function en(t){function e(t,e){}return e.type="xstate.enqueueActions",e.collect=t,e.resolve=ee,e}function er(t,e,n,r,{value:s,label:i}){return[e,{value:"function"==typeof s?s(n,r):s,label:i},void 0]}function es({logger:t},{value:e,label:n}){n?t(n,e):t(e)}function ei(t=({context:t,event:e})=>({context:t,event:e}),e){function n(t,e){}return n.type="xstate.log",n.value=t,n.label=e,n.resolve=er,n.execute=es,n}function eo(t,e){let n=m(e);if(!n.some(e=>I(t.type,e))){let e=1===n.length?`type matching "${n[0]}"`:`one of types matching "${n.join('", "')}"`;throw Error(`Expected event ${JSON.stringify(t)} to have ${e}`)}}function ea({schemas:t,actors:e,actions:n,guards:r,delays:s}){return{assign:tK,sendTo:t8,raise:tN,log:ei,cancel:N,stopChild:z,enqueueActions:en,emit:t3,spawnChild:D,createStateConfig:t=>t,createAction:t=>t,createMachine:i=>new t1({...i,schemas:t},{actors:e,actions:n,guards:r,delays:s}),extend:i=>ea({schemas:t,actors:e,actions:{...n,...i.actions},guards:{...r,...i.guards},delays:{...s,...i.delays}})}}t.s(["a",()=>t3,"b",()=>et,"e",()=>en,"l",()=>ei,"s",()=>t8],214990),t.s(["assertEvent",()=>eo,"setup",()=>ea],509820),t.s(["assign",()=>tK],663095),t.s(["createActor",()=>P],269193),t.s(["enqueueActions",()=>en],721634),t.s(["raise",()=>tN],688236),t.s(["emit",()=>t3],681026),t.s(["stopChild",()=>z],613650);var ec=function(t,e){return(ec=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function eu(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}ec(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}
3function el(t,e,n,r){return new(n||(n=Promise))(function(s,i){function o(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?s(t.value):((e=t.value)instanceof n?e:new n(function(t){t(e)})).then(o,a)}c((r=r.apply(t,e||[])).next())})}function ef(t,e){var n,r,s,i={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){var u=[a,c];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(s=2&u[0]?r.return:u[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,u[1])).done)return s;switch(r=0,s&&(u=[2&u[0],s.value]),u[0]){case 0:case 1:s=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(s=(s=i.trys).length>0&&s[s.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!s||u[1]>s[0]&&u[1]<s[3])){i.label=u[1];break}if(6===u[0]&&i.label<s[1]){i.label=s[1],s=u;break}if(s&&i.label<s[2]){i.label=s[2],i.ops.push(u);break}s[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=s=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function eh(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function ep(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,s,i=n.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)o.push(r.value)}catch(t){s={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(s)throw s.error}}return o}function ed(t,e,n){if(n||2==arguments.length)for(var r,s=0,i=e.length;s<i;s++)!r&&s in e||(r||(r=Array.prototype.slice.call(e,0,s)),r[s]=e[s]);return t.concat(r||Array.prototype.slice.call(e))}function ey(t){return this instanceof ey?(this.v=t,this):new ey(t)}function ev(t,e,n){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var r,s=n.apply(t,e||[]),i=[];return r=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",function(t){return function(e){return Promise.resolve(e).then(t,u)}}),r[Symbol.asyncIterator]=function(){return this},r;function o(t,e){s[t]&&(r[t]=function(e){return new Promise(function(n,r){i.push([t,e,n,r])>1||a(t,e)})},e&&(r[t]=e(r[t])))}function a(t,e){try{var n;(n=s[t](e)).value instanceof ey?Promise.resolve(n.value.v).then(c,u):l(i[0][2],n)}catch(t){l(i[0][3],t)}}function c(t){a("next",t)}function u(t){a("throw",t)}function l(t,e){t(e),i.shift(),i.length&&a(i[0][0],i[0][1])}}function eg(t){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=eh(t),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(n){e[n]=t[n]&&function(e){return new Promise(function(r,s){var i,o,a;i=r,o=s,a=(e=t[n](e)).done,Promise.resolve(e.value).then(function(t){i({value:t,done:a})},o)})}}}function em(t){return"function"==typeof t}function eb(t){var e=t(function(t){Error.call(t),t.stack=Error().stack});return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}"function"==typeof SuppressedError&&SuppressedError,t.s(["__asyncGenerator",()=>ev,"__asyncValues",()=>eg,"__await",()=>ey,"__awaiter",()=>el,"__extends",()=>eu,"__generator",()=>ef,"__read",()=>ep,"__spreadArray",()=>ed,"__values",()=>eh],290571),t.s(["isFunction",()=>em],603752),t.s(["createErrorClass",()=>eb],842093);var e_=eb(function(t){return function(e){t(this),this.message=e?e.length+" errors occurred during unsubscription:\n"+e.map(function(t,e){return e+1+") "+t.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=e}});function eS(t,e){if(t){var n=t.indexOf(e);0<=n&&t.splice(n,1)}}t.s(["arrRemove",()=>eS],586903);var ex=function(){var t;function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var t,e,n,r,s,i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var o=eh(i),a=o.next();!a.done;a=o.next())a.value.remove(this)}catch(e){t={error:e}}finally{try{a&&!a.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}else i.remove(this);var c=this.initialTeardown;
3if(em(c))try{c()}catch(t){s=t instanceof e_?t.errors:[t]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var l=eh(u),f=l.next();!f.done;f=l.next()){var h=f.value;try{eE(h)}catch(t){s=null!=s?s:[],t instanceof e_?s=ed(ed([],ep(s)),ep(t.errors)):s.push(t)}}}catch(t){n={error:t}}finally{try{f&&!f.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}}if(s)throw new e_(s)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)eE(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!=(n=this._finalizers)?n:[]).push(t)}},e.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},e.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},e.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&eS(e,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&eS(n,t),t instanceof e&&t._removeParent(this)},(t=new e).closed=!0,e.EMPTY=t,e}(),ew=ex.EMPTY;function ek(t){return t instanceof ex||t&&"closed"in t&&em(t.remove)&&em(t.add)&&em(t.unsubscribe)}function eE(t){em(t)?t():t.unsubscribe()}t.s(["EMPTY_SUBSCRIPTION",()=>ew,"Subscription",()=>ex,"isSubscription",()=>ek],909116);var eI=void 0,eT={setTimeout:function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var s=eT.delegate;return(null==s?void 0:s.setTimeout)?s.setTimeout.apply(s,ed([t,e],ep(n))):setTimeout.apply(void 0,ed([t,e],ep(n)))},clearTimeout:function(t){var e=eT.delegate;return((null==e?void 0:e.clearTimeout)||clearTimeout)(t)},delegate:void 0};function eO(t){eT.setTimeout(function(){!1;throw t})}function eA(){}var e$=eR("C",void 0,void 0);function eR(t,e,n){return{kind:t,value:e,error:n}}var ej=null;function eP(t){var e,n,r,s;1;t()}function eM(t){}t.s(["captureError",()=>eM,"errorContext",()=>eP],140260);var eq=function(t){function e(e){var n=t.call(this)||this;return n.isStopped=!1,e?(n.destination=e,ek(e)&&e.add(n)):n.destination=ez,n}return eu(e,t),e.create=function(t,e,n){return new eD(t,e,n)},e.prototype.next=function(t){this.isStopped?eB(eR("N",t,void 0),this):this._next(t)},e.prototype.error=function(t){this.isStopped?eB(eR("E",void 0,t),this):(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped?eB(e$,this):(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(ex),eN=Function.prototype.bind;function eC(t,e){return eN.call(t,e)}var eL=function(){function t(t){this.partialObserver=t}return t.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(t){eU(t)}},t.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(t){eU(t)}else eU(t)},t.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){eU(t)}},t}(),eD=function(t){function e(e,n,r){var s,i,o=t.call(this)||this;return em(e)||!e?s={next:null!=e?e:void 0,error:null!=n?n:void 0,complete:null!=r?r:void 0}:s=e,o.destination=new eL(s),o}return eu(e,t),e}(eq);function eU(t){eO(t)}function eB(t,e){}var ez={closed:!0,next:eA,error:function(t){throw t},complete:eA};t.s(["SafeSubscriber",()=>eD,"Subscriber",()=>eq],240126);var eV="function"==typeof Symbol&&Symbol.observable||"@@observable";function eW(t){return t}function eG(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return eJ(t)}function eJ(t){return 0===t.length?eW:1===t.length?t[0]:function(e){return t.reduce(function(t,e){return e(t)},e)}}t.s(["identity",()=>eW],979165),t.s(["pipe",()=>eG,"pipeFromArray",()=>eJ],282541);var eY=function(){function t(t){t&&(this._subscribe=t)}return t.prototype.lift=function(e){var n=new t;return n.source=this,n.operator=e,n},t.prototype.subscribe=function(t,e,n){var r=this,s=!function(t){return t&&t instanceof eq||t&&em(t.next)&&em(t.error)&&em(t.complete)&&ek(t)}(t)?new eD(t,e,n):t;return eP(function(){var t=r.operator,e=r.source;s.add(t?t.call(s,e):e?r._subscribe(s):r._trySubscribe(s))}),s},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},t.prototype.forEach=function(t,e){var n=this;return new(e=eH(e))(function(e,r){var s=new eD({next:function(e){try{t(e)}catch(t){r(t),s.unsubscribe()}},error:r,complete:e});n.subscribe(s)})},t.prototype._subscribe=function(t){var e;return null==(e=this.source)?void 0:e.subscribe(t)},t.prototype[eV]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return eJ(t)(this)},t.prototype.toPromise=function(t){var e=this;return new(t=eH(t))(function(t,n){var r;e.subscribe(function(t){return r=t},function(t){return n(t)},function(){return t(r)})})},t.create=function(e){return new t(e)},t}();function eH(t){var e;return null!=(e=null!=t?t:eI)?e:Promise}t.s(["Observable",()=>eY],394426);var eK=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t};function eF(t){return em(null==t?void 0:t.then)}function eQ(t){return em(t[eV])}function eX(t){return Symbol.asyncIterator&&em(null==t?void 0:t[Symbol.asyncIterator])}function eZ(t){return TypeError("You provided "+(null!==t&&"object"==typeof t?"an invali
3d object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}t.s(["isArrayLike",()=>eK],987675),t.s(["isPromise",()=>eF],349449),t.s(["isInteropObservable",()=>eQ],717718),t.s(["isAsyncIterable",()=>eX],238331),t.s(["createInvalidObservableTypeError",()=>eZ],254824);var e0="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function e1(t){return em(null==t?void 0:t[e0])}function e2(t){return ev(this,arguments,function(){var e,n,r;return ef(this,function(s){switch(s.label){case 0:e=t.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,ey(e.read())];case 3:if(r=(n=s.sent()).value,!n.done)return[3,5];return[4,ey(void 0)];case 4:return[2,s.sent()];case 5:return[4,ey(r)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function e6(t){return em(null==t?void 0:t.getReader)}function e3(t){if(t instanceof eY)return t;if(null!=t){var e,n,r,s;if(eQ(t)){return e=t,new eY(function(t){var n=e[eV]();if(em(n.subscribe))return n.subscribe(t);throw TypeError("Provided object does not correctly implement Symbol.observable")})}if(eK(t)){return n=t,new eY(function(t){for(var e=0;e<n.length&&!t.closed;e++)t.next(n[e]);t.complete()})}if(eF(t)){return r=t,new eY(function(t){r.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,eO)})}if(eX(t))return e4(t);if(e1(t)){return s=t,new eY(function(t){var e,n;try{for(var r=eh(s),i=r.next();!i.done;i=r.next()){var o=i.value;if(t.next(o),t.closed)return}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}t.complete()})}if(e6(t))return e4(e2(t))}throw eZ(t)}function e4(t){return new eY(function(e){(function(t,e){var n,r,s,i;return el(this,void 0,void 0,function(){var o;return ef(this,function(a){switch(a.label){case 0:a.trys.push([0,5,6,11]),n=eg(t),a.label=1;case 1:return[4,n.next()];case 2:if((r=a.sent()).done)return[3,4];if(o=r.value,e.next(o),e.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]),!(r&&!r.done&&(i=n.return)))return[3,8];return[4,i.call(n)];case 7:a.sent(),a.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})})(t,e).catch(function(t){return e.error(t)})})}function e9(t){return new eY(function(e){e3(t()).subscribe(e)})}function e7(t){return function(e){if(em(null==e?void 0:e.lift))return e.lift(function(e){try{return t(e,this)}catch(t){this.error(t)}});throw TypeError("Unable to lift unknown Observable type")}}function e5(t,e,n,r,s){return new e8(t,e,n,r,s)}t.s(["iterator",()=>e0],177650),t.s(["isIterable",()=>e1],23515),t.s(["isReadableStreamLike",()=>e6,"readableStreamLikeToAsyncGenerator",()=>e2],311902),t.s(["innerFrom",()=>e3],220324),t.s(["defer",()=>e9],172441),t.s(["operate",()=>e7],902965);var e8=function(t){function e(e,n,r,s,i,o){var a=t.call(this,e)||this;return a.onFinalize=i,a.shouldUnsubscribe=o,a._next=n?function(t){try{n(t)}catch(t){e.error(t)}}:t.prototype._next,a._error=s?function(t){try{s(t)}catch(t){e.error(t)}finally{this.unsubscribe()}}:t.prototype._error,a._complete=r?function(){try{r()}catch(t){e.error(t)}finally{this.unsubscribe()}}:t.prototype._complete,a}return eu(e,t),e.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;t.prototype.unsubscribe.call(this),n||null==(e=this.onFinalize)||e.call(this)}},e}(eq);function nt(t,e){return e7(function(n,r){var s=0;n.subscribe(e5(r,function(n){r.next(t.call(e,n,s++))}))})}function ne(t,e,n,r,s){void 0===r&&(r=0),void 0===s&&(s=!1);var i=e.schedule(function(){n(),s?t.add(this.schedule(null,r)):this.unsubscribe()},r);if(t.add(i),!s)return i}function nn(t,e,n){return(void 0===n&&(n=1/0),em(e))?nn(function(n,r){return nt(function(t,s){return e(n,t,r,s)})(e3(t(n,r)))},n):("number"==typeof e&&(n=e),e7(function(e,r){var s,i,o,a,c,u,l,f;return s=n,i=[],o=0,a=0,c=!1,u=function(){!c||i.length||o||r.complete()},l=function(t){return o<s?f(t):i.push(t)},f=function(e){o++;var n=!1;e3(t(e,a++)).subscribe(e5(r,function(t){r.next(t)},function(){n=!0},void 0,function(){if(n)try{for(o--;i.length&&o<s;)!function(){var t=i.shift();f(t)}();u()}catch(t){r.error(t)}}))},e.subscribe(e5(r,l,function(){c=!0,u()})),function(){}}))}t.s(["createOperatorSubscriber",()=>e5],627608),t.s(["map",()=>nt],94059),t.s(["executeSchedule",()=>ne],175436),t.s(["mergeMap",()=>nn],484973);var nr=Array.isArray;function ns(t){return nt(function(e){return nr(e)?t.apply(void 0,ed([],ep(e))):t(e)}
3)}t.s(["mapOneOrManyArgs",()=>ns],272383);var ni=["addListener","removeListener"],no=["addEventListener","removeEventListener"],na=["on","off"];function nc(t,e,n,r){if(em(n)&&(r=n,n=void 0),r)return nc(t,e,n).pipe(ns(r));var s,i,o,a=ep(em((s=t).addEventListener)&&em(s.removeEventListener)?no.map(function(r){return function(s){return t[r](e,s,n)}}):em((i=t).addListener)&&em(i.removeListener)?ni.map(nu(t,e)):em((o=t).on)&&em(o.off)?na.map(nu(t,e)):[],2),c=a[0],u=a[1];if(!c&&eK(t))return nn(function(t){return nc(t,e,n)})(e3(t));if(!c)throw TypeError("Invalid event target");return new eY(function(t){var e=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return t.next(1<e.length?e:e[0])};return c(e),function(){return u(e)}})}function nu(t,e){return function(n){return function(r){return t[n](e,r)}}}function nl(t,e){return e7(function(n,r){var s=0;n.subscribe(e5(r,function(n){return t.call(e,n,s++)&&r.next(n)}))})}function nf(t,e){return em(e)?nn(t,e,1):nn(t,1)}t.s(["filter",()=>nl],722249),t.s(["concatMap",()=>nf],589293);var nh=new eY(function(t){return t.complete()});function np(t){return t<=0?function(){return nh}:e7(function(e,n){var r=0;e.subscribe(e5(n,function(e){++r<=t&&(n.next(e),t<=r&&n.complete())}))})}t.s(["EMPTY",()=>nh],96623);let nd=t=>({context:e})=>{let{count:n,include:r,exclude:s,responseType:i="message.received"}=t;return{count:n,domain:e.domain,from:e.connectTo,include:r?Array.isArray(r)?r:[r]:[],exclude:s?Array.isArray(s)?s:[s]:[],responseType:i,target:e.target,to:e.name}},ny=e9(()=>nc(window,"message")),nv=t=>tB(({input:e})=>{var n,r;let s;return ny.pipe(t?nt(t):eG(),nl(t=>{let{data:n}=t;return(!e.include.length||e.include.includes(n.type))&&(!e.exclude.length||!e.exclude.includes(n.type))&&n.domain===e.domain&&n.from===e.from&&n.to===e.to&&(!e.target||t.source===e.target)}),nt((s=e.responseType,t=>({type:s,message:t}))),e.count?eG((n=e.count,void 0===r&&(r=null),r=null!=r?r:n,e7(function(t,e){var s=[],i=0;t.subscribe(e5(e,function(t){var o,a,c,u,l=null;i++%r==0&&s.push([]);try{for(var f=eh(s),h=f.next();!h.done;h=f.next()){var p=h.value;p.push(t),n<=p.length&&(l=null!=l?l:[]).push(p)}}catch(t){o={error:t}}finally{try{h&&!h.done&&(a=f.return)&&a.call(f)}finally{if(o)throw o.error}}if(l)try{for(var d=eh(l),y=d.next();!y.done;y=d.next()){var p=y.value;eS(s,p),e.next(p)}}catch(t){c={error:t}}finally{try{y&&!y.done&&(u=d.return)&&u.call(d)}finally{if(c)throw c.error}}},function(){var t,n;try{for(var r=eh(s),i=r.next();!i.done;i=r.next()){var o=i.value;e.next(o)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}e.complete()},void 0,function(){s=null}))})),nf(t=>t),np(e.count)):eG())}),ng="sanity/comlink",nm="comlink/response",nb="comlink/heartbeat",n_="comlink/disconnect",nS="comlink/handshake/syn",nx="comlink/handshake/syn-ack",nw="comlink/handshake/ack",nk=()=>ea({types:{},actors:{listen:tB(({input:t})=>{let e,n=t.signal?nc(t.signal,"abort").pipe((e=`Request ${t.requestId} aborted`,t=>t.pipe(np(1),nt(()=>{throw Error(e)})))):nh;return nc(window,"message").pipe(nl(e=>e.data?.type===nm&&e.data?.responseTo===t.requestId&&!!e.source&&t.sources.has(e.source)),np(t.sources.size),e7(function(t,e){e3(n).subscribe(e5(e,function(){return e.complete()},eA)),e.closed||t.subscribe(e)}))})},actions:{"send message":({context:t},e)=>{let{sources:n,targetOrigin:r}=t,{message:s}=e;n.forEach(t=>{t.postMessage(s,{targetOrigin:r})})},"on success":t8(({context:t})=>t.parentRef,({context:t,self:e})=>(t.response&&t.resolvable?.resolve(t.response),{type:"request.success",requestId:e.id,response:t.response,responseTo:t.responseTo})),"on fail":t8(({context:t})=>t.parentRef,({context:t,self:e})=>(t.suppressWarnings||console.warn(`[@sanity/comlink] Received no response to message '${t.type}' on client '${t.from}' (ID: '${t.id}').`),t.resolvable?.reject(Error("No response received")),{type:"request.failed",requestId:e.id})),"on abort":t8(({context:t})=>t.parentRef,({context:t,self:e})=>(t.resolvable?.reject(Error("Request aborted")),{type:"request.aborted",requestId:e.id}))},guards:{expectsResponse:({context:t})=>t.expectResponse},delays:{initialTimeout:0,responseTimeout:({context:t})=>t.responseTimeout??3e3}}).createMachine({context:({input:t})=>({channelId:t.channelId,data:t.data,domain:t.domain,expectResponse:t.expectResponse??!1,from:t.from,id:`msg-${(0,i.v4)()}`,parentRef:t.parentRef,resolvable:t.resolvable,response:null,responseTimeout:t.responseTimeout,responseTo:t.responseTo,signal:t.signal,sources:t.sources instanceof Set?t.sources:new Set([t.sources]),suppressWarnings:t.suppressWarnings,targetOrigin:t.targetOrigin,to:t.to,type:t.type}),initial:"idle",on:{abort:".aborted"},states:{idle:{after:{initialTimeout:[{target:"sending"}]}},sending:{entry:{type:"send message",params:({context:t})=>{let{channelId:e,data:n,domain:r,from:s,id:i,responseTo:o,to:a,type:c}=t;return{message:{channelId:e,data:n,domain:r,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:t})=>({requestId:t.id,sources:t.sources,signal:t.signal}),onError:"aborted"},after:{responseTimeout:"failed"},on:{message:{actions:tK({response:({event:t})=>t.data.data,responseTo:({event:t})=>t.data.responseTo}),target:"success"}}},failed:{type:"final",entry:"on fail"},success:{type:"final",entry:"on success"},aborted:{type:"final",entry:"on abort"}},output:({context:t,self:e})=>({requestId:e.id,response:t.response,responseTo:t.responseTo})});tL(({sendBack:t,input:e})=>{let n=()=>{t(e.event)};e.immediate&&n();let r=setInterval(n,e.interval);return()=>{clearInterval(r)}});let nE=()=>ea({types:{},actors:{requestMachine:nk(),listen:nv()},actions:{"buffer handshake":tK({handshakeBuffer:({event:t,context:e})=>(eo(t,"message.received"),[...e.handshakeBuffer,t])}),"buffer message":en(({enqueue:t})=>{t.assign({buffer:({event:t,context:e})=>(eo(t,"post"),[...e.buffer,{data:t.data,resolvable:t.resolvable,options:t.options}])}),t.emit(({event:t})=>(eo(t,"post"),{type:"buffer.added",message:t.data}))}),"create request":tK({requests:({context:t,event:e,self:n,spawn:r})=>{eo(e,"request");let s=(Array.isArray(e.data)?e.data:[e.data]).map(e=>r("requestMachine",{id:`req-${(0,i.v4)()}`,input:{channelId:t.channelId,data:e.data,domain:t.domain,expectResponse:e.expectResponse,from:t.name,parentRef:n,resolvable:e.resolvable,responseTimeout:e.options?.responseTimeout,responseTo:e.responseTo,signal:e.options?.signal,sources:t.target,suppressWarnings:e.options?.suppressWarnings,targetOrigin:t.targetOrigin,to:t.connectTo,type:e.type}}));return[...t.requests,...s]}}),"emit heartbeat":t3(()=>({type:"heartbeat"})),"emit received message":en(({enqueue:t})=>{t.emit(({event:t})=>(eo(t,"message.received"),{type:"message",message:t.message.data}))}),"emit status":t3((t,e)=>({type:"status",status:e.status})),"post message":tN(({event:t})=>(eo(t,"post"),{type:"request",data:{data:t.data.data,expectResponse:!!t.resolvable,type:t.data.type,resolvable:t.resolvable,options:t.options}})),"process pending handshakes":en(({context:t,enqueue:e})=>{t.handshakeBuffer.forEach(t=>e.raise(t)),e.assign({handshakeBuffer:[]})}),"remove request":en(({context:t,enqueue:e,event:n})=>{eo(n,["request.success","request.failed","request.aborted"]),z(n.requestId),e.assign({requests:t.requests.filter(({id:t})=>t!==n.requestId)})}),"send response":tN(({event:t})=>(eo(t,["message.received","heartbeat.received"]),{type:"request",data:{type:nm,responseTo:t.message.data.id,data:void 0}})),"send handshake syn ack":tN({type:"request",data:{type:nx}}),"send pending messages":en(({enqueue:t})=>{t.raise(({context:t})=>({type:"request",data:t.buffer.map(({data:t,resolvable:e,options:n})=>({data:t.data,type:t.type,expectResponse:!!e,resolvable:e,options:n}))})),t.emit(({context:t})=>({type:"buffer.flushed",messages:t.buffer.map(({data:t})=>t)})),t.assign({buffer:[]})}),"set connection config":tK({channelId:({event:t})=>(eo(t,"handshake.syn"),t.message.data.channelId),target:({event:t})=>(eo(t,"handshake.syn"),t.message.source||void 0),targetOrigin:({event:t})=>(eo(t,"handshake.syn"),t.message.origin)})},guards:{hasSource:({context:t})=>null!==t.target}}).createMachine({id:"node",context:({input:t})=>({buffer:[],channelId:null,connectTo:t.connectTo,domain:t.domain??ng,handshakeBuffer:[],name:t.name,requests:[],target:void 0,targetOrigin:null}),invoke:{id:"listen for handshake syn",src:"listen",input:nd({include:nS,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"}}
3,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:nd({include:nw,count:1,responseType:"handshake.complete"}),onDone:"connected"},{id:"listen for disconnect",src:"listen",input:nd({include:n_,count:1,responseType:"disconnect"})},{id:"listen for messages",src:"listen",input:nd({exclude:[n_,nS,nw,nb,nm]})}],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:nd({exclude:[n_,nS,nw,nb,nm]})},{id:"listen for heartbeat",src:"listen",input:nd({include:nb,responseType:"heartbeat.received"})},{id:"listen for disconnect",src:"listen",input:nd({include:n_,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"]}}}}}),nI=(t,e=nE())=>{let n,r=P(e,{input:t}),s=new Map,i=new Map;r.on("message",({message:t})=>{let e=s.get(t.type);if(e)return void e.forEach(e=>e(t.data));let n=i.get(t.type);n?n.add(t):i.set(t.type,new Set([t]))});let o=()=>{r.stop()};return{actor:r,fetch:(t,e,n)=>{let s,i,{responseTimeout:o=1e4,signal:a,suppressWarnings:c}=n||{},u="function"==typeof Promise.withResolvers?Promise.withResolvers():{promise:new Promise((t,e)=>{s=t,i=e}),resolve:s,reject:i};return r.send({type:"post",data:{type:t,data:e},resolvable:u,options:{responseTimeout:o,signal:a,suppressWarnings:c}}),u.promise},machine:e,on:(t,e,n)=>{let r=s.get(t)||new Set;s.has(t)||s.set(t,r),r.add(e);let o=i.get(t);if(o){let r=n?.replay??1;Array.from(o).slice(-r).forEach(({data:t})=>e(t)),i.delete(t)}return()=>{r.delete(e)}},onStatus:(t,e)=>{let s=r.on("status",r=>{n=r.status,e&&r.status!==e||t(r.status)});return n&&t(n),()=>s.unsubscribe()},post:(t,e)=>{r.send({type:"post",data:{type:t,data:e}})},start:()=>(r.start(),o),stop:o}};t.s(["DOMAIN",()=>ng,"MSG_DISCONNECT",()=>n_,"MSG_HANDSHAKE_ACK",()=>nw,"MSG_HANDSHAKE_SYN",()=>nS,"MSG_HANDSHAKE_SYN_ACK",()=>nx,"MSG_HEARTBEAT",()=>nb,"MSG_RESPONSE",()=>nm,"createListenLogic",()=>nv,"createNode",()=>nI,"createNodeMachine",()=>nE,"createRequestMachine",()=>nk],881283);let nT={"handshake/syn":nS,"handshake/syn-ack":nx,"handshake/ack":nw,"channel/response":nm,"channel/heartbeat":nb,"channel/disconnect":n_,"overlay/focus":"visual-editing/focus","overlay/navigate":"visual-editing/navigate","overlay/toggle":"visual-editing/toggle","presentation/toggleOverlay":"presentation/toggle-overlay"},nO={[nS]:"handshake/syn",[nx]:"handshake/syn-ack",[nw]:"handshake/ack",[nm]:"channel/response",[nb]:"channel/heartbeat",[n_]:"channel/disconnect","visual-editing/focus":"overlay/focus","visual-editing/navigate":"overlay/navigate","visual-editing/toggle":"overlay/toggle","presentation/toggle-overlay":"presentation/toggleOverlay"},nA=t=>{let{data:e}=t;return e&&"object"==typeof e&&"domain"in e&&"type"in e&&"from"in e&&"to"in e&&("sanity/channels"===e.domain&&(e.domain=ng),"overlays"===e.to&&(e.to="visual-editing"),"overlays"===e.from&&(e.from="visual-editing"),e.channelId=e.connectionId,delete e.connectionId,e.type=nT[e.type]??e.type),t},n$=({context:t},e)=>{let{sources:n,targetOrigin:r}=t,s=(t=>{let{channelId:e,...n}=t,r={...n,connectionId:e};return r.domain===ng&&(r.domain="sanity/channels"),"visual-editing"===r.to&&(r.to="overlays"),"visual-editing"===r.from&&(r.from="overlays"),r.type=nO[r.type]??r.type,"channel/response"===r.type&&r.responseTo&&!r.data&&(r.data={responseTo:r.responseTo}),("handshake/syn"===r.type||"handshake/syn-ack"===r.type||"handshake/ack"===r.type)&&(r.data={id:r.connectionId}),r})(e.message);n.forEach(t=>{t.postMessage(s,{targetOrigin:r})})},nR=()=>({listen:nv(nA),requestMachine:nk().provide({actions:{"send message":n$}}
3)});function nj(){return window.self!==window.top}function nP(){return!!window.opener}function nM(){return nj()||nP()}t.s(["createCompatibilityActors",()=>nR,"isMaybePresentation",()=>nM,"isMaybePreviewIframe",()=>nj,"isMaybePreviewWindow",()=>nP],636536)},95187,(t,e,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r={callServer:function(){return i.callServer},createServerReference:function(){return a.createServerReference},findSourceMapURL:function(){return o.findSourceMapURL}};for(var s in r)Object.defineProperty(n,s,{enumerable:!0,get:r[s]});let i=t.r(132120),o=t.r(92245),a=t.r(235326)}]);
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.