PageSourceSearch

https://www.sindri.ai/_next/static/chunks/df08f92ec96a9f40.js

js sindri.ai collected 2026-10-05 15:50:47 UTC 73,834 bytes, 3 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,54531,56068,724596,399646,679925,329111,328077,56911,460982,2836,e=>{"use strict";var t,r;let n,s="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),i=new Uint8Array(16),o=[];for(let e=0;e<256;++e)o.push((e+256).toString(16).slice(1));e.s(["v4",0,function(e,t,r){if(s&&!t&&!e)return s();var a=e,c=r;let u=(a=a||{}).random??a.rng?.()??function(){if(!n){if("u"<typeof crypto||!crypto.getRandomValues)throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");n=crypto.getRandomValues.bind(crypto)}return n(i)}();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,t){if((c=c||0)<0||c+16>t.length)throw RangeError(`UUID byte range ${c}:${c+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[c+e]=u[e];return t}return function(e,t=0){return(o[e[t+0]]+o[e[t+1]]+o[e[t+2]]+o[e[t+3]]+"-"+o[e[t+4]]+o[e[t+5]]+"-"+o[e[t+6]]+o[e[t+7]]+"-"+o[e[t+8]]+o[e[t+9]]+"-"+o[e[t+10]]+o[e[t+11]]+o[e[t+12]]+o[e[t+13]]+o[e[t+14]]+o[e[t+15]]).toLowerCase()}(u)}],54531);class a{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 c="xstate.init",u="xstate.stop";function l(e,t){return{type:`xstate.done.state.${e}`,output:t}}function d(e,t){return{type:`xstate.error.actor.${e}`,error:t,actorId:e}}function p(e){return{type:c,input:e}}function h(e){setTimeout(()=>{throw e})}let f="function"==typeof Symbol&&Symbol.observable||"@@observable";function y(e){if(_(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 v(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}(y(e))}function g(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 m(e){var t;return void 0===e?[]:_(t=e)?t:[t]}function b(e,t,r,n){return"function"==typeof e?e({context:t,event:r,self:n}):e}function _(e){return Array.isArray(e)}function S(e){var t;return(_(t=e)?t:[t]).map(e=>void 0===e||"string"==typeof e?{target:e}:e)}function x(e){if(void 0!==e&&""!==e)return m(e)}function w(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(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 k(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 T(e,t){return`${e.sessionId}.${t}`}let I=0,A=!1,q=((t={})[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped",t),O={clock:{setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},logger:console.log.bind(console),devTools:!1};class ${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 a(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=q.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={...O,...t},{clock:n,logger:s,parent:i,syncSnapshot:o,id:c,systemId:u,inspect:l}=r;this.system=i?i.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=T(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=T(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:${I++}`,_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=w(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:n,logger:s}),l&&!i&&this.system.inspect(w(l)),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=i,this._syncSnapshot=o,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){h(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=A;try{A=!0,e.exec(e.info,e.params)}finally{A=t}};this._processingStatus===q.Running?t():this._deferred.push(t)}},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(t?.snapshot??t?.state),u&&"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){h(e)}break;case"done":var n;for(let t of this.observers)try{t.next?.(e)}catch(e){h(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=w(e,t,r);if(this._processingStatus!==q.Stopped)this.observers.add(n);else switch(this._snapshot.status){case"done":try{n.complete?.()}catch(e){h(e)}break;case"error":{let e=this._snapshot.error;if(n.error)try{n.error(e)}catch(e){h(e)}else h(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===q.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=q.Running;let e=p(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===u&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===q.Stopped||((this.mailbox.clear(),this._processingStatus===q.NotStarted)?this._processingStatus=q.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 e of this.observers)try{e.complete?.()}catch(e){h(e)}this.observers.clear(),this.eventListeners.clear()}_reportError(e){if(!this.observers.size){this._parent||h(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){h(e)}}this.observers.clear(),this.eventListeners.clear(),t&&h(e)}_error(e){this._stopProcedure(),this._reportError(e),this._parent&&this.system._relay(this,this._parent,d(this.id,e))}_stopProcedure(){return this._processingStatus!==q.Running||(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new a(this._process.bind(this)),this._processingStatus=q.Stopped,this.system._unregister(this)),this}_send(e){this._processingStatus!==q.Stopped&&this.mailbox.enqueue(e)}send(e){this.system._relay(void 0,this,e)}attachDevTools(){let{devTools:t}=this.options;t&&("function"==typeof t?t: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)})(this)}toJSON(){return{xstate$$type:1,id:this.id}}getPersistedSnapshot(e){return this.logic.getPersistedSnapshot(this._snapshot,e)}[f](){return this}getSnapshot(){return this._snapshot}}function R(e,...[t]){return new $(e,t)}function M(e,t,r,n,{sendId:s}){return[t,{sendId:"function"==typeof s?s(r,n):s},void 0]}function j(e,t){e.defer(()=>{e.system.scheduler.cancel(e.self,t.sendId)})}function P(e){function t(e,t){}return t.type="xstate.cancel",t.sendId=e,t.resolve=M,t.execute=j,t}function N(e,t,r,n,{id:s,systemId:i,src:o,input:a,syncSnapshot:c}){let u,l,d="string"==typeof o?E(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=R(d,{id:p,src:o,parent:e.self,syncSnapshot:c,systemId:i,input:l})),[ew(t,{children:{...t.children,[p]:u}}),{id:s,systemId:i,actorRef:u,src:o,input:l},void 0]}function C(e,{actorRef:t}){t&&e.defer(()=>{t._processingStatus!==q.Stopped&&t.start()})}function F(...[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=N,i.execute=C,i}function D(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]),[ew(t,{children:a}),o,void 0]}function L(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!==q.Running)return void e.stopChild(t);e.defer(()=>{e.stopChild(t)})}}function U(e){function t(e,t){}return t.type="xstate.stopChild",t.actorRef=e,t.resolve=D,t.execute=L,t}function z(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 z(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 B=e=>"atomic"===e.type||"final"===e.type;function V(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 H(e){let t=new Set(e),r=J(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 V(e))if("history"!==r.type&&!t.has(r))for(let e of ee(r))t.add(e)}}
1else ee(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 J(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 Y(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(B(e))return e.key}let s={};for(let t of n)s[t.key]=e(t,r);return s}(e,J(H(t)))}function G(e,t){return"compound"===t.type?V(t).some(t=>"final"===t.type&&e.has(t)):"parallel"===t.type?V(t).every(t=>G(e,t)):"final"===t.type}let K=e=>"#"===e[0];function Q(e,t,r){let n=x(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(K(t))return e.machine.getStateNodeById(t);let r="."===t[0];if(r&&!e.parent)return en(e,t.slice(1));let n=r?e.key+t:t;if(e.parent)try{return en(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:m(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 X(e){let t=x(e.config.target);return t?{target:t.map(t=>"string"==typeof t?en(e.parent,t):t)}:e.parent.initial}function Z(e){return"history"===e.type}function ee(e){let t=et(e);for(let r of t)for(let n of W(r,e))t.add(n);return t}function et(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 V(r))e(t)}}(e),t}function er(e,t){if(K(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 en(e,t){if("string"==typeof t&&K(t))try{return e.machine.getStateNodeById(t)}catch{}let r=y(t).slice(),n=e;for(;r.length;){let e=r.shift();if(!e.length)break;n=er(n,e)}return n}function es(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=>er(e,t)).filter(Boolean);return[e.machine.root,e].concat(n,r.reduce((r,n)=>{let s=er(e,n);if(!s)return r;let i=es(s,t[n]);return r.concat(i)},[]))}function ei(e,t){let r=e;for(;r.parent&&r.parent!==t;)r=r.parent;return r.parent===t}function eo(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}(eu([s],t,r),eu([o],t,r)))if(ei(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 ea(e,t){if(!e.target)return[];let r=new Set;for(let n of e.target)if(Z(n))if(t[n.id])for(let e of t[n.id])r.add(e);else for(let e of ea(X(n),t))r.add(e);else r.add(n);return[...r]}function ec(e,t){let r=ea(e,t);if(!r)return;if(!e.reenter&&r.every(t=>t===e.source||ei(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=>ei(t,e)))return e}(r.concat(e.source));return n||(e.reenter?void 0:e.source.machine.root)}function eu(e,t,r){let n=new Set;for(let s of e)if(s.target?.length){let e=ec(s,r);for(let r of(s.reenter&&s.source===e&&n.add(e),t))ei(r,e)&&n.add(r)}return[...n]}function el(e,t,r,n,s,i){if(!e.length)return t;let o=new Set(t._nodes),a=t.historyValue,c=eo(e,o,a),u=t;s||([u,a]=function(e,t,r,n,s,i,o,a){let c,u=e,l=eu(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=>B(t)&&ei(t,e):t=>t.parent===e,(c??={...i})[t.id]=Array.from(s).filter(r)}for(let e of l)u=eh(u,t,r,[...e.exit,...e.invoke.map(e=>U(e.id))],o,void 0),s.delete(e);return[u,c||i]}(u,n,r,c,o,a,i,r.actionExecutor)),u=function(e,t,r,n,s,i,o,a){let c=e,u=new Set,d=new Set;(function(e,t,r,n){for(let s of e){let e=ec(s,t);for(let i of s.target||[])!Z(i)&&(s.source!==i||s.source!==e||s.reenter)&&(n.add(i),r.add(i)),ed(i,t,r,n);for(let i of ea(s,t)){let o=W(i,e);e?.type==="parallel"&&o.push(e),ep(n,t,r,o,!s.source.parent&&s.reenter?void 0:e)}}})(n,o,d,u),a&&d.add(e.machine.root);let p=new Set;for(let e of[...u].sort((e,t)=>e.order-t.order)){s.add(e);let n=[];for(let t of(n.push(...e.entry),e.invoke))n.push(F(t.src,{...t,syncSnapshot:!!t.onSnapshot}));if(d.has(e)){let t=e.initial.actions;n.push(...t)}if(c=eh(c,t,r,n,i,e.invoke.map(e=>e.id)),"final"===e.type){let n=e.parent,o=n?.type==="parallel"?n:n?.parent,a=o||e;for(n?.type==="compound"&&i.push(l(n.id,void 0!==e.output?b(e.output,c.context,t,r.self):void 0));o?.type==="parallel"&&!p.has(o)&&G(s,o);)p.add(o),i.push(l(o.id)),a=o,o=o.parent;if(o)continue;c=ew(c,{status:"done",output:function(e,t,r,n,s){if(void 0===n.output)return;let i=l(s.id,void 0!==s.output&&s.parent?b(s.output,e.context,t,r.self):void 0);return b(n.output,e.context,i,r.self)}(c,t,r,c.machine.root,a)})}}return c}(u=eh(u,n,r,c.flatMap(e=>e.actions),i,void 0),n,r,c,o,i,a,s);let d=[...o];"done"===u.status&&(u=eh(u,n,r,d.sort((e,t)=>
2t.order-e.order).flatMap(e=>e.exit),i,void 0));try{if(a===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,o))return u;return ew(u,{_nodes:d,historyValue:a})}catch(e){throw e}}function ed(e,t,r,n){var s,i,o,a;if(Z(e))if(t[e.id]){let o=t[e.id];for(let e of o)n.add(e),ed(e,t,r,n);for(let a of o){s=a,i=e.parent,ep(n,t,r,W(s,i))}}else{let s=X(e);for(let i of s.target)n.add(i),s===e.parent?.initial&&r.add(e.parent),ed(i,t,r,n);for(let i of s.target){o=i,a=e.parent,ep(n,t,r,W(o,a))}}else if("compound"===e.type){let[s]=e.initial.target;Z(s)||(n.add(s),r.add(s)),ed(s,t,r,n),ep(n,t,r,W(s,e))}else if("parallel"===e.type)for(let s of V(e).filter(e=>!Z(e)))[...n].some(e=>ei(e,s))||(Z(s)||(n.add(s),r.add(s)),ed(s,t,r,n))}function ep(e,t,r,n,s){for(let i of n)if((!s||ei(i,s))&&e.add(i),"parallel"===i.type)for(let n of V(i).filter(e=>!Z(e)))[...e].some(e=>ei(e,n))||(e.add(n),ed(n,t,r,e))}function eh(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 ef(e,t,r,n){let s=e,i=[];function o(e,t,n){r.system._sendInspectionEvent({type:"@xstate.microstep",actorRef:r.self,event:t,snapshot:e,_transitions:n}),i.push(e)}if(t.type===u)return o(s=ew(ey(s,t,r),{status:"stopped"}),t,[]),{snapshot:s,microstates:i};let a=t;if(a.type!==c){let t=a,c=t.type.startsWith("xstate.error.actor"),u=ev(t,s);if(c&&!u.length)return o(s=ew(e,{status:"error",error:t.error}),t,[]),{snapshot:s,microstates:i};o(s=el(u,e,r,a,!1,n),t,u)}let l=!0;for(;"active"===s.status;){let e=l?function(e,t){let r=new Set;for(let n of e._nodes.filter(B))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||z(n.guard,e.context,t,e)){r.add(n);break e}}return eo(Array.from(r),new Set(e._nodes),e.historyValue)}(s,a):[],t=e.length?s:void 0;if(!e.length){if(!n.length)break;e=ev(a=n.shift(),s)}l=(s=el(e,s,r,a,!1,n))!==t,o(s,a,e)}return"active"!==s.status&&ey(s,a,r),{snapshot:s,microstates:i}}function ey(e,t,r){return eh(e,t,r,Object.values(e.children).map(e=>U(e)),[],void 0)}function ev(e,t){return t.machine.getTransitionData(t,e)}let eg=function(e){return function e(t,r){let n=v(t),s=v(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)},em=function(e){return this.tags.has(e)},eb=function(e){let t=this.machine.getTransitionData(this,e);return!!t?.length&&t.some(e=>void 0!==e.target||e.actions.length)},e_=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)}},eS=function(){return this._nodes.reduce((e,t)=>(void 0!==t.meta&&(e[t.id]=t.meta),e),{})};function ex(e,t){return{status:e.status,output:e.output,error:e.error,machine:t,context:e.context,_nodes:e._nodes,value:Y(t.root,e._nodes),tags:new Set(e._nodes.flatMap(e=>e.tags)),children:e.children,historyValue:e.historyValue||{},matches:eg,hasTag:em,can:eb,getMeta:eS,toJSON:e_}}function ew(e,t={}){return ex({...e,...t},e.machine)}function eE(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 ek(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 eT(e,t){function r(e,t){}return r.type="xstate.raise",r.event=e,r.id=t?.id,r.delay=t?.delay,r.resolve=eE,r.execute=ek,r}let eI=new WeakMap;function eA(e){return{config:e,start:(t,r)=>{let{self:n,system:s,emit:i}=r,o={receivers:void 0,dispose:void 0};eI.set(n,o),o.dispose=e({input:t.input,system:s,self:n,sendBack:e=>
2{"stopped"!==n.getSnapshot().status&&n._parent&&s._relay(n,n._parent,e)},receive:e=>{o.receivers??=new Set,o.receivers.add(e)},emit:i})},transition:(e,t,r)=>{let n=eI.get(r.self);return t.type===u?(e={...e,status:"stopped",error:void 0},eI.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 eq="xstate.observable.error",eO="xstate.observable.complete";function e$(e){return{config:e,transition:(e,t)=>{if("active"!==e.status)return e;switch(t.type){case eq:return{...e,status:"error",error:t.data,input:void 0,_subscription:void 0};case eO:return{...e,status:"done",input:void 0,_subscription:void 0};case u: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:eq,data:e})},complete:()=>{n._relay(r,r,{type:eO})}}))},getPersistedSnapshot:({_subscription:e,...t})=>t,restoreSnapshot:e=>({...e,_subscription:void 0})}}function eR(e,t,r,n,{assignment:s}){if(!t.context)throw Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");let i={},o={context:t.context,event:r.event,spawn:function(e,{machine:t,context:r},n,s){return(i,o)=>{let a=((i,o)=>{if("string"!=typeof i)return R(i,{id:o?.id,parent:e.self,syncSnapshot:o?.syncSnapshot,input:o?.input,src:i,systemId:o?.systemId});{let a=E(t,i);if(!a)throw Error(`Actor logic '${i}' not implemented in machine '${t.id}'`);let c=R(a,{id:o?.id,parent:e.self,syncSnapshot:o?.syncSnapshot,input:"function"==typeof o?.input?o.input({context:r,event:n,self:e.self}):o?.input,src:i,systemId:o?.systemId});return s[c.id]=c,c}})(i,o);return s[a.id]=a,e.defer(()=>{a._processingStatus!==q.Stopped&&a.start()}),a}}(e,t,r.event,i),self:e.self,system:e.system},a={};if("function"==typeof s)a=s(o,n);else for(let e of Object.keys(s)){let t=s[e];a[e]="function"==typeof t?t(o,n):t}let c=Object.assign({},t.context,a);return[ew(t,{context:c,children:Object.keys(i).length?{...t.children,...i}:t.children}),void 0,void 0]}function eM(e){function t(e,t){}return t.type="xstate.assign",t.assignment=e,t.resolve=eR,t}new WeakMap,e.s(["fromCallback",()=>eA,"fromEventObservable",()=>e$],56068);let ej=new WeakMap;function eP(e,t,r){let n=ej.get(e);return n?t in n||(n[t]=r()):(n={[t]:r()},ej.set(e,n)),n[t]}let eN={},eC=e=>"string"==typeof e?{type:e}:"function"==typeof e?"resolve"in e?{type:e.type}:{type:e.name}:e;class eF{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("."),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,(e,t)=>new eF(e,{_parent:this,_key:t,_machine:this.machine})):eN,"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(e.tags).slice()}_initialize(){this.transitions=function(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,S(n).map(t=>Q(e,r,t)))}if(e.config.onDone){let r=`xstate.done.state.${e.id}`;t.set(r,S(e.config.onDone).map(t=>Q(e,r,t)))}for(let r of e.invoke){if(r.onDone){let n=`xstate.done.actor.${r.id}`;t.set(n,S(r.onDone).map(t=>Q(e,n,t)))}if(r.onError){let n=`xstate.error.actor.${r.id}`;t.set(n,S(r.onError).map(t=>Q(e,n,t)))}if(r.onSnapshot){let n=`xstate.snapshot.${r.id}`;t.set(n,S(r.onSnapshot).map(t=>Q(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}(this),this.config.always&&(this.always=S(this.config.always).map(e=>
2Q(this,"",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.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(eC),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(e=>`#${e.id}`),source:`#${this.id}`,actions:this.initial.actions.map(eC),eventType:null})}:void 0,history:this.history,states:g(this.states,e=>e.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(e=>({...e,actions:e.actions.map(eC)})),entry:this.entry.map(eC),exit:this.exit.map(eC),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 eP(this,"invoke",()=>m(this.config.invoke).map((e,t)=>{var r,n;let{src:s,systemId:i}=e,o=e.id??(r=this.id,`${t}.${r}`),a="string"==typeof s?s:`xstate.invoke.${n=this.id,`${t}.${n}`}`;return{...e,src:a,id:o,systemId:i,toJSON(){let{onDone:t,onError:r,...n}=e;return{...n,type:"xstate.invoke",src:a,id:o}}}}))}get on(){return eP(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 eP(this,"delayedTransitions",()=>{var e;let t;return e=this,(t=e.config.after)?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(eT(s,{id:i,delay:a})),e.exit.push(P(i)),i);return m("string"==typeof o?{target:o}:o).map(e=>({...e,event:c,delay:a}))}).map(t=>{let{delay:r}=t;return{...Q(e,t.event,t),delay:r}}):[]})}get initial(){return eP(this,"initial",()=>(function(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?m(t.actions):[],eventType:null,reenter:!1,target:r?[r]:[],toJSON:()=>({...n,source:`#${e.id}`,target:r?[`#${r.id}`]:[]})};return n})(this,this.config.initial))}next(e,t){let r,n=t.type,s=[];for(let i of eP(this,`candidates-${n}`,()=>{var e;return e=this,e.transitions.get(n)||[...e.transitions.keys()].filter(e=>k(n,e)).sort((e,t)=>t.length-e.length).flatMap(t=>e.transitions.get(t))})){let{guard:o}=i,a=e.context,c=!1;try{c=!o||z(o,a,t,e)}catch(t){let e="string"==typeof o?o:"object"==typeof o?o.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(c){s.push(...i.actions),r=i;break}}return r?[r]:void 0}get events(){return eP(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 eD{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 eF(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 eD(this.config,{actions:{...t,...e.actions},guards:{...r,...e.guards},actors:{...n,...e.actors},delays:{...s,...e.delays}})}resolveState(e){var t;let r,n=(r=H(es(t=this.root,e.value)),Y(t,[...r])),s=H(es(this.root,n));return ex({_nodes:[...s],context:e.context||{},children:{},status:G(s,this.root)?"done":e.status||"active",output:e.output,error:e.error,historyValue:e.historyValue},this)}transition(e,t,r){return ef(e,t,r,[]).snapshot}microstep(e,t,r){return ef(e,t,r,[]).microstates}getTransitionData(e,t){return function e(t,r,n,s){if("string"==typeof r){let e;return(e=er(t,r).next(n,s))&&e.length?e:t.next(n,s)}if(1===Object.keys(r).length){let i,o;
3return(o=e(er(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(er(t,o),a,n,s);c&&i.push(...c)}return i.length?i:t.next(n,s)}(this.root,e.value,e,t)||[]}getPreInitialState(e,t,r){let{context:n}=this.config,s=ex({context:"function"!=typeof n&&n?n:{},_nodes:[this.root],children:{},status:"active"},this);return"function"==typeof n?eh(s,t,e,[eM(({spawn:e,event:t,self:r})=>n({spawn:e,input:t.input,self:r}))],r,void 0):s}getInitialSnapshot(e,t){let r=p(t),n=[],s=this.getPreInitialState(e,r,n),{snapshot:i}=ef(el([{target:[...et(this.root)],source:this.root,reenter:!0,actions:[],eventType:null,toJSON:null}],s,e,r,!0,n),r,e,n);return i}start(e){Object.values(e.children).forEach(e=>{"active"===e.getSnapshot().status&&e.start()})}getStateNodeById(e){let t=y(e),r=t.slice(1),n=K(t[0])?t[0].slice(1):t[0],s=this.idMap.get(n);if(!s)throw Error(`Child state node '#${n}' does not exist on machine '${this.id}'`);return en(s,r)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(e,t){return function(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)}}(e,t)}restoreSnapshot(e,t){let r={},n=e.children;Object.keys(n).forEach(e=>{let s=n[e],i=s.snapshot,o=s.src,a="string"==typeof o?E(this,o):o;if(!a)return;let c=R(a,{id:e,parent:t.self,syncSnapshot:s.syncSnapshot,snapshot:i,src:o,systemId:s.systemId});r[e]=c});let s=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 eF)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),i=ex({...e,children:r,_nodes:Array.from(H(es(this.root,e.value))),historyValue:s},this),o=new Set;return!function e(t,r){if(!o.has(t))for(let n in o.add(t),t){let s=t[n];if(s&&"object"==typeof s){if("xstate$$type"in s&&1===s.xstate$$type){t[n]=r[s.id];continue}e(s,r)}}}(i.context,r),i}}function eL(e,t,r,n,{event:s}){return[t,{event:"function"==typeof s?s(r,n):s},void 0]}function eU(e,{event:t}){e.defer(()=>e.emit(t))}function ez(e){function t(e,t){}return t.type="xstate.emit",t.event=e,t.resolve=eL,t.execute=eU,t}let eB=((r={}).Parent="#_parent",r.Internal="#_internal",r);function eV(e,t,r,n,{to:s,event:i,id:o,delay:a},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===eB.Parent?e.self._parent:h===eB.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 eW(e,t,r){"string"==typeof r.to&&(r.to=t.children[r.to])}function eH(e,t){e.defer(()=>{let{to:r,event:n,delay:s,id:i}=t;"number"==typeof s?e.system.scheduler.schedule(e.self,r,n,s,i):e.system._relay(e.self,r,"xstate.error"===n.type?d(e.self.id,n.data):n)})}function eJ(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=eV,n.retryResolve=eW,n.execute=eH,n}
3function eY(e,t,r,n,{collect:s}){let i=[],o=function(e){i.push(e)};return o.assign=(...e)=>{i.push(eM(...e))},o.cancel=(...e)=>{i.push(P(...e))},o.raise=(...e)=>{i.push(eT(...e))},o.sendTo=(...e)=>{i.push(eJ(...e))},o.sendParent=(...e)=>{i.push(function(e,t){return eJ(eB.Parent,e,t)}(...e))},o.spawnChild=(...e)=>{i.push(F(...e))},o.stopChild=(...e)=>{i.push(U(...e))},o.emit=(...e)=>{i.push(ez(...e))},s({context:r.context,event:r.event,enqueue:o,check:e=>z(e,t.context,r.event,t),self:e.self,system:e.system},n),[t,void 0,i]}function eG(e){function t(e,t){}return t.type="xstate.enqueueActions",t.collect=e,t.resolve=eY,t}function eK(e,t,r,n,{value:s,label:i}){return[t,{value:"function"==typeof s?s(r,n):s,label:i},void 0]}function eQ({logger:e},{value:t,label:r}){r?e(r,t):e(t)}function eX(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=eK,r.execute=eQ,r}function eZ(e,t){let r=m(t);if(!r.some(t=>k(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(["assertEvent",()=>eZ,"setup",()=>function e({schemas:t,actors:r,actions:n,guards:s,delays:i}){return{assign:eM,sendTo:eJ,raise:eT,log:eX,cancel:P,stopChild:U,enqueueActions:eG,emit:ez,spawnChild:F,createStateConfig:e=>e,createAction:e=>e,createMachine:e=>new eD({...e,schemas:t},{actors:r,actions:n,guards:s,delays:i}),extend:o=>e({schemas:t,actors:r,actions:{...n,...o.actions},guards:{...s,...o.guards},delays:{...i,...o.delays}})}}],724596),e.s(["sendTo",()=>eJ],399646),e.s(["assign",()=>eM],679925),e.s(["createActor",()=>R],329111),e.s(["enqueueActions",()=>eG],328077),e.s(["raise",()=>eT],56911),e.s(["emit",()=>ez],460982),e.s(["stopChild",()=>U],2836)},603752,e=>{"use strict";function t(e){return"function"==typeof e}e.s(["isFunction",()=>t])},240126,842093,586903,909116,543937,505698,114940,140260,e=>{"use strict";var t=e.i(290571),r=e.i(603752);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],842093);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],586903);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],909116);var l={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};e.s(["config",()=>l],543937);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],505698),e.s(["noop",()=>h],114940);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],140260);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],240126)},394426,979165,282541,987675,349449,717718,238331,254824,177650,23515,311902,220324,e=>{"use strict";var t=e.i(240126),r=e.i(909116),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],979165),e.s(["pipe",()=>i,"pipeFromArray",()=>o],282541);var a=e.i(543937),c=e.i(603752),u=e.i(140260),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],394426);var p=e.i(290571),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],987675),e.s(["isPromise",()=>f],349449),e.s(["isInteropObservable",()=>y],717718),e.s(["isAsyncIterable",()=>v],238331),e.s(["createInvalidObservableTypeError",()=>g],254824);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],177650),e.s(["isIterable",()=>b],23515),e.s(["isReadableStreamLike",()=>S,"readableStreamLikeToAsyncGenerator",()=>_],311902);var x=e.i(505698);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],220324)},172441,e=>{"use strict";var t=e.i(394426),r=e.i(220324);function n(e){return new t.Observable(function(t){(0,r.innerFrom)(e()).subscribe(t)})}e.s(["defer",()=>n])},902965,e=>{"use strict";var t=e.i(603752);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])},627608,e=>{"use strict";var t=e.i(290571);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(240126).Subscriber);e.s(["OperatorSubscriber",()=>n,"createOperatorSubscriber",()=>r])},94059,e=>{"use strict";var t=e.i(902965),r=e.i(627608);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])},175436,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])},484973,658474,e=>{"use strict";var t=e.i(94059),r=e.i(220324),n=e.i(902965),s=e.i(175436),i=e.i(627608);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],658474);var a=e.i(603752);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)}))}],484973)},272383,e=>{"use strict";var t=e.i(290571),r=e.i(94059),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])},807136,e=>{"use strict";var t=e.i(290571),r=e.i(220324),n=e.i(394426),s=e.i(484973),i=e.i(987675),o=e.i(603752),a=e.i(272383),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)}})}])},722249,e=>{"use strict";var t=e.i(902965),r=e.i(627608);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])},445556,e=>{"use strict";var t=e.i(290571),r=e.i(902965),n=e.i(627608),s=e.i(586903);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])},589293,e=>{"use strict";var t=e.i(484973),r=e.i(603752);function n(e,n){return(0,r.isFunction)(n)?(0,t.mergeMap)(e,n,1):(0,t.mergeMap)(e,1)}e.s(["concatMap",()=>n])},96623,e=>{"use strict";var t=e.i(394426),r=new t.Observable(function(e){return e.complete()});function n(e){var n;return e?(n=e,new t.Observable(function(e){return n.schedule(function(){return e.complete()})})):r}e.s(["EMPTY",()=>r,"empty",()=>n])},10839,e=>{"use strict";var t=e.i(96623),r=e.i(902965),n=e.i(627608);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])},800879,e=>{"use strict";var t=e.i(902965),r=e.i(627608),n=e.i(220324),s=e.i(114940);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])},881283,e=>{"use strict";var t=e.i(54531),r=e.i(56068),n=e.i(724596),s=e.i(399646),i=e.i(679925),o=e.i(329111),a=e.i(328077),c=e.i(56911),u=e.i(460982),l=e.i(2836),d=e.i(172441),p=e.i(807136),h=e.i(94059),f=e.i(282541),y=e.i(722249),v=e.i(445556),g=e.i(589293),m=e.i(10839),b=e.i(96623),_=e.i(800879);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"}}}}}),j=(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}}},P=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=j({...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=>{P(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=j({...e,target:r,targetOrigin:t},s);o.add(n)});else{let r=j({...e,targetOrigin:t},s);o.add(r)}let l=()=>{let e=i.connections;e.forEach(P),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(P),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.