PageSourceSearch

https://cdn3.complex.com/6b763dc60f4b3681dfe7e134a7b1bc3ac09655b3/_next/static/chunks/42vaxq962-qce.js

js complex.com collected 2026-09-24 06:53:58 UTC 64,115 bytes, 3 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,636536,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,96623,881283,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));let i=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)};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.stop";function u(t,e){return{type:`xstate.done.state.${t}`,output:e}}function l(t,e){return{type:`xstate.error.actor.${t}`,error:e,actorId:t}}function h(t){return{type:a,input:t}}function f(t){setTimeout(()=>{throw t})}let d="function"==typeof Symbol&&Symbol.observable||"@@observable";function p(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 y(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}(p(t))}function v(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 g(t){var e;return void 0===t?[]:_(e=t)?e:[e]}function m(t,e,n,r){return"function"==typeof t?t({context:e,event:n,self:r}):t}function _(t){return Array.isArray(t)}function b(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 g(t)}function S(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 w(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 k(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 E(t,e){return`${t.sessionId}.${e}`}let I=0,T=!1,$=((tX={})[tX.NotStarted=0]="NotStarted",tX[tX.Running=1]="Running",tX[tX.Stopped=2]="Stopped",tX),A={clock:{setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t)},logger:console.log.bind(console),devTools:!1};class O{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={...A,...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=E(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=E(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:${I++}`,_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=S(t);return i.add(e),{unsubscribe(){i.delete(e)}}},_sendInspectionEvent:e=>{if(!i.size)return;let n={...e,rootId:t.sessionId};
1i.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(S(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){f(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=T;try{T=!0,t.exec(t.info,t.params)}finally{T=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){f(t)}break;case"done":var r;for(let e of this.observers)try{e.next?.(t)}catch(t){f(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=S(t,e,n);if(this._processingStatus!==$.Stopped)this.observers.add(r);else switch(this._snapshot.status){case"done":try{r.complete?.()}catch(t){f(t)}break;case"error":{let t=this._snapshot.error;if(r.error)try{r.error(t)}catch(t){f(t)}else f(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)}}}select(t,e=Object.is){return{subscribe:n=>{let r=S(n),s=t(this.getSnapshot());return this.subscribe(n=>{let i=t(n);e(s,i)||(s=i,r.next?.(i))})},get:()=>t(this.getSnapshot())}}start(){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===c&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===$.Stopped||((this.mailbox.clear(),this._processingStatus===$.NotStarted)?this._processingStatus=$.Stopped:this.mailbox.enqueue({type:c})),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){f(t)}this.observers.clear(),this.eventListeners.clear()}_reportError(t){if(!this.observers.size){this._parent||f(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){f(t)}}this.observers.clear(),this.eventListeners.clear(),e&&f(t)}_error(t){this._stopProcedure(),this._reportError(t),this._parent&&this.system._relay(this,this._parent,l(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 R(t,...[e]){return new O(t,e)}function M(t,e,n,r,{sendId:s}){return[e,{sendId:"function"==typeof s?s(n,r):s},void 0]}function j(t,e){t.defer(()=>{t.system.scheduler.cancel(t.self,e.sendId)})}function q(t){function e(t,e){}return e.type="xstate.cancel",e.sendId=t,e.resolve=M,e.execute=j,e}function P(t,e,n,r,{id:s,systemId:i,src:o,input:a,syncSnapshot:c}){let u,l,h="string"==typeof o?w(e.machine,o):o,f="function"==typeof s?s(n):s;return h&&(l="function"==typeof a?a({context:e.context,event:n.event,self:t.self}):a,u=R(h,{id:f,src:o,parent:t.self,syncSnapshot:c,systemId:i,input:l})),[tS(e,{children:{...e.children,[f]:u}}),{id:s,systemId:i,actorRef:u,src:o,input:l},void 0]}function N(t,{actorRef:e}){e&&t.defer(()=>{e._processingStatus!==$.Stopped&&e.start()})}function C(...[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=P,i.execute=N,i}function L(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]),[tS(e,{children:a}),o,void 0]}function D(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 U(t){function e(t,e){}return e.type="xstate.stopChild",e.actorRef=t,e.resolve=L,e.execute=D,e}function z(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 z(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 B(t){return"atomic"===t.type||"final"===t.type}function V(t){return Object.values(t.states).filter(t=>"history"!==t.type)}function W(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 J(t){let e=new Set(t),n=G(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 V(t))if("history"!==n.type&&!e.has(n))for(let t of Z(n))e.add(t)}}else Z(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 G(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 Y(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(B(t))return t.key}let s={};for(let e of r)s[e.key]=t(e,n);return s}(t,G(J(e)))}function H(t,e){return"compound"===e.type?V(e).some(e=>"final"===e.type&&t.has(e)):"parallel"===e.type?V(e).every(e=>H(t,e)):"final"===e.type}let K=t=>"#"===t[0];function F(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(K(e))return t.machine.getStateNodeById(e);let n="."===e[0];if(n&&!t.parent)return tn(t,e.slice(1));let r=n?t.key+e:e;if(t.parent)try{return tn(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:g(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 Q(t){let e=x(t.config.target);return e?{target:e.map(e=>"string"==typeof e?tn(t.parent,e):e)}:t.parent.initial}function X(t){return"history"===t.type}function Z(t){let e=tt(t);for(let n of e)for(let r of W(n,t))e.add(r);return e}function tt(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 V(n))t(e)}}(t),e}function te(t,e){if(K(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 tn(t,e){if("string"==typeof e&&K(e))try{return t.machine.getStateNodeById(e)}catch{}let n=p(e).slice(),r=t;for(;n.length;){let t=n.shift();if(!t.length)break;r=te(r,t)}return r}function tr(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=>te(t,e)).filter(Boolean);return[t.machine.root,t].concat(r,n.reduce((n,r)=>{let s=te(t,r);if(!s)return n;let i=tr(s,e[r]);return n.concat(i)},[]))}function ts(t,e){let n=t;for(;n.parent&&n.parent!==e;)n=n.parent;return n.parent===e}function ti(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}(tc([s],e,n),tc([o],e,n)))if(ts(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 to(t,e){if(!t.target)return[];let n=new Set;for(let r of t.target)if(X(r))if(e[r.id])for(let t of e[r.id])n.add(t);else for(let t of to(Q(r),e))n.add(t);else n.add(r);return[...n]}function ta(t,e){let n=to(t,e);if(!n)return;if(!t.reenter&&n.every(e=>e===t.source||ts(e,t.source)))return t.source;let r=function(t){let[e,...n]=t;for(let t of W(e,void 0))if(n.every(e=>ts(e,t)))return t}(n.concat(t.source));return r||(t.reenter?void 0:t.source.machine.root)}function tc(t,e,n){let r=new Set;for(let s of t)if(s.target?.length){let t=ta(s,n);for(let n of(s.reenter&&s.source===t&&r.add(t),e))ts(n,t)&&r.add(n)}return[...r]}function tu(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,l=ti(t,a,c),h=e;s||([h,c]=function(t,e,n,r,s,i,o,a){let c,u=t,l=tc(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=>B(e)&&ts(e,t):e=>e.parent===t,(c??={...i})[e.id]=Array.from(s).filter(n)}for(let t of l)u=tf(u,e,n,[...t.exit,...t.invoke.map(t=>U(t.id))],o,void 0),s.delete(t);return[u,c||i]}(h,r,n,l,a,c,i,n.actionExecutor)),h=tf(h,r,n,l.flatMap(t=>t.actions),i,void 0),h=function(t,e,n,r,s,i,o,a){let c=t,l=new Set,h=new Set;(function(t,e,n,r){for(let s of t){let t=ta(s,e);for(let i of s.target||[])!X(i)&&(s.source!==i||s.source!==t||s.reenter)&&(r.add(i),n.add(i)),tl(i,e,n,r);for(let i of to(s,e)){let o=W(i,t);t?.type==="parallel"&&o.push(t),th(r,e,n,o,!s.source.parent&&s.reenter?void 0:t)}}})(r,o,h,l),a&&h.add(t.machine.root);let f=new Set;for(let t of[...l].sort((t,e)=>t.order-e.order)){s.add(t);let r=[];for(let e of(r.push(...t.entry),t.invoke))r.push(C(e.src,{...e,syncSnapshot:!!e.onSnapshot}));if(h.has(t)){let e=t.initial.actions;r.push(...e)}if(c=tf(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(u(r.id,void 0!==t.output?m(t.output,c.context,e,n.self):void 0));o?.type==="parallel"&&!f.has(o)&&H(s,o);)f.add(o),i.push(u(o.id)),a=o,o=o.parent;if(o)continue;c=tS(c,{status:"done",output:function(t,e,n,r,s){if(void 0===r.output)return;let i=u(s.id,void 0!==s.output&&s.parent?m(s.output,t.context,e,n.self):void 0);return m(r.output,t.context,i,n.self)}(c,e,n,c.machine.root,a)})}}return c}(h,r,n,l,a,i,c,s);let f=[...a];"done"===h.status&&(h=tf(h,r,n,f.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[h,o];return[tS(h,{_nodes:f,historyValue:c}),o]}catch(t){throw t}}finally{n.actionExecutor=a}}function tl(t,e,n,r){var s,i,o,a;if(X(t))if(e[t.id]){let o=e[t.id];for(let t of o)r.add(t),tl(t,e,n,r);for(let a of o){s=a,i=t.parent,th(r,e,n,W(s,i))}}else{let s=Q(t);for(let i of s.target)r.add(i),s===t.parent?.initial&&n.add(t.parent),tl(i,e,
2n,r);for(let i of s.target){o=i,a=t.parent,th(r,e,n,W(o,a))}}else if("compound"===t.type){let[s]=t.initial.target;X(s)||(r.add(s),n.add(s)),tl(s,e,n,r),th(r,e,n,W(s,t))}else if("parallel"===t.type)for(let s of V(t).filter(t=>!X(t)))[...r].some(t=>ts(t,s))||(X(s)||(r.add(s),n.add(s)),tl(s,e,n,r))}function th(t,e,n,r,s){for(let i of r)if((!s||ts(i,s))&&t.add(i),"parallel"===i.type)for(let r of V(i).filter(t=>!X(t)))[...t].some(t=>ts(t,r))||(t.add(r),tl(r,e,n,t))}function tf(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]),h={context:c.context,event:n,self:r.self,system:r.system},f=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:h,params:f,exec:l});continue}let[d,p,y]=l.resolve(r,c,h,f,l,i);c=d,"retryResolve"in l&&o?.push([l,p]),"execute"in l&&r.actionExecutor({type:l.type,info:h,params:p,exec:l.execute.bind(null,r,p)}),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 td(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===c)return o([s=tS(tp(s,e,n),{status:"stopped"}),[]],e,[]),{snapshot:s,microsteps:i};let u=e;if(u.type!==a){let e=u,a=e.type.startsWith("xstate.error.actor"),c=ty(e,s);if(a&&!c.length)return o([s=tS(t,{status:"error",error:e.error}),[]],e,[]),{snapshot:s,microsteps:i};let l=tu(c,t,n,u,!1,r);s=l[0],o(l,e,c)}let l=!0;for(;"active"===s.status;){let t=l?function(t,e){let n=new Set;for(let r of t._nodes.filter(B))t:for(let s of[r].concat(W(r,void 0)))if(s.always){for(let r of s.always)if(void 0===r.guard||z(r.guard,t.context,e,t)){n.add(r);break t}}return ti(Array.from(n),new Set(t._nodes),t.historyValue)}(s,u):[],e=t.length?s:void 0;if(!t.length){if(!r.length)break;t=ty(u=r.shift(),s)}let i=tu(t,s,n,u,!1,r);l=(s=i[0])!==e,o(i,u,t)}return"active"!==s.status&&tp(s,u,n),{snapshot:s,microsteps:i}}function tp(t,e,n){return tf(t,e,n,Object.values(t.children).map(t=>U(t)),[],void 0)}function ty(t,e){return e.machine.getTransitionData(e,t)}let tv=function(t){return function t(e,n){let r=y(e),s=y(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)},tg=function(t){return this.tags.has(t)},tm=function(t){let e=this.machine.getTransitionData(this,t);return!!e?.length&&e.some(t=>void 0!==t.target||t.actions.length)},t_=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)}},tb=function(){return this._nodes.reduce((t,e)=>(void 0!==e.meta&&(t[e.id]=e.meta),t),{})};function tx(t,e){return{status:t.status,output:t.output,error:t.error,machine:e,context:t.context,_nodes:t._nodes,value:Y(e.root,t._nodes),tags:new Set(t._nodes.flatMap(t=>t.tags)),children:t.children,historyValue:t.historyValue||{},matches:tv,hasTag:tg,can:tm,getMeta:tb,toJSON:t_}}function tS(t,e={}){return tx({...t,...e},t.machine)}function tw(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 tk(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 tE(t,e){function n(t,e){}return n.type="xstate.raise",n.event=t,n.id=e?.id,n.delay=e?.delay,n.resolve=tw,n.execute=tk,n}let tI="xstate.observable.error",tT="xstate.observable.complete";function t$(t){return{config:t,transition:(t,e)=>{if("active"!==t.status)return t;switch(e.type){case tI:return{...t,status:"error",error:e.data,input:void 0,_subscription:void 0};case tT:return{...t,status:"done",input:void 0,_subscription:void 0};case c: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:tI,data:t})},complete:()=>{r._relay(n,n,{type:tT})}}))},getPersistedSnapshot:({_subscription:t,...e})=>e,restoreSnapshot:t=>({...t,_subscription:void 0})}}function tA(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)=>
2{if("string"!=typeof i)return R(i,{id:o?.id,parent:t.self,syncSnapshot:o?.syncSnapshot,input:o?.input,src:i,systemId:o?.systemId});{let a=w(e,i);if(!a)throw Error(`Actor logic '${i}' not implemented in machine '${e.id}'`);let c=R(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[tS(e,{context:c,children:Object.keys(i).length?{...e.children,...i}:e.children}),void 0,void 0]}function tO(t){function e(t,e){}return e.type="xstate.assign",e.assignment=t,e.resolve=tA,e}new WeakMap;let tR=new WeakMap;function tM(t,e,n){let r=tR.get(t);return r?e in r||(r[e]=n()):(r={[e]:n()},tR.set(t,r)),r[e]}let tj={},tq=t=>"string"==typeof t?{type:t}:"function"==typeof t?"resolve"in t?{type:t.type}:{type:t.name}:t;class tP{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?v(this.config.states,(t,e)=>new tP(t,{_parent:this,_key:e,_machine:this.machine})):tj,"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=g(this.config.entry).slice(),this.exit=g(this.config.exit).slice(),this.meta=this.config.meta,this.output="final"!==this.type&&this.parent?void 0:this.config.output,this.tags=g(t.tags).slice()}_initialize(){this.transitions=function(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,b(r).map(e=>F(t,n,e)))}if(t.config.onDone){let n=`xstate.done.state.${t.id}`;e.set(n,b(t.config.onDone).map(e=>F(t,n,e)))}for(let n of t.invoke){if(n.onDone){let r=`xstate.done.actor.${n.id}`;e.set(r,b(n.onDone).map(e=>F(t,r,e)))}if(n.onError){let r=`xstate.error.actor.${n.id}`;e.set(r,b(n.onError).map(e=>F(t,r,e)))}if(n.onSnapshot){let r=`xstate.snapshot.${n.id}`;e.set(r,b(n.onSnapshot).map(e=>F(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}(this),this.config.always&&(this.always=b(this.config.always).map(t=>F(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(tq),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(t=>`#${t.id}`),source:`#${this.id}`,actions:this.initial.actions.map(tq),eventType:null})}:void 0,history:this.history,states:v(this.states,t=>t.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(t=>({...t,actions:t.actions.map(tq)})),entry:this.entry.map(tq),exit:this.exit.map(tq),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 tM(this,"invoke",()=>g(this.config.invoke).map((t,e)=>{var n,r;let{src:s,systemId:i}=t,o=t.id??(n=this.id,`${e}.${n}`),a="string"==typeof s?s:`xstate.invoke.${r=this.id,`${e}.${r}`}`;return{...t,src:a,id:o,systemId:i,toJSON(){let{onDone:e,onError:n,...r}=t;return{...r,type:"xstate.invoke",src:a,id:o}}}}))}get on(){return tM(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 tM(this,"delayedTransitions",()=>{var t;let e;return t=this,(e=t.config.after)?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(tE(s,{id:i,delay:a})),t.exit.push(q(i)),i);return g("string"==typeof o?{target:o}:o).map(t=>({...t,event:c,delay:a}))}).map(e=>{let{delay:n}=e;return{...F(t,e.event,e),delay:n}}):[]})}get initial(){return tM(this,"initial",()=>(function(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?g(e.actions):[],eventType:null,reenter:!1,target:n?[n]:[],toJSON:()=>({...r,source:`#${t.id}`,target:n?[`#${n.id}`]:[]})};return r})(this,this.config.initial))}next(t,e){let n,r=e.type,s=[];for(let i of tM(this,`candidates-${r}`,()=>{var t;return t=this,t.transitions.get(r)||[...t.transitions.keys()].filter(t=>k(r,t)).sort((t,e)=>e.length-t.length).flatMap(e=>t.transitions.get(e))})){let{guard:o}=i,a=t.context,c=!1;try{c=!o||z(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 tM(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 tN{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 tP(t,{_key:this.id,_machine:this}),this.root._initialize(),function(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(F(t,"xstate.route",i))}r.states&&n(r.states)})};n(t.states),e.length>0&&t.transitions.set("xstate.route",e)}(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 tN(this.config,{actions:{...e,...t.actions},guards:{...n,...t.guards},actors:{...r,...t.actors},delays:{...s,...t.delays}})}resolveState(t){var e;let n,r=(n=J(tr(e=this.root,t.value)),Y(e,[...n])),s=J(tr(this.root,r));return tx({_nodes:[...s],context:t.context||{},children:{},status:H(s,this.root)?"done":t.status||"active",output:t.output,error:t.error,historyValue:t.historyValue},this)}transition(t,e,n){return td(t,e,n,[]).snapshot}microstep(t,e,n){return td(t,e,n,[]).microsteps.map(([t])=>t)}getTransitionData(t,e){return function t(e,n,r,s){if("string"==typeof n){let t;
3return(t=te(e,n).next(r,s))&&t.length?t:e.next(r,s)}if(1===Object.keys(n).length){let i,o;return(o=t(te(e,(i=Object.keys(n))[0]),n[i[0]],r,s))&&o.length?o:e.next(r,s)}let i=[];for(let o of Object.keys(n)){let a=n[o];if(!a)continue;let c=t(te(e,o),a,r,s);c&&i.push(...c)}return i.length?i:e.next(r,s)}(this.root,t.value,t,e)||[]}_getPreInitialState(t,e,n){let{context:r}=this.config,s=tx({context:"function"!=typeof r&&r?r:{},_nodes:[this.root],children:{},status:"active"},this);return"function"==typeof r?tf(s,e,t,[tO(({spawn:t,event:e,self:n})=>r({spawn:t,input:e.input,self:n}))],n,void 0):s}getInitialSnapshot(t,e){var n;let r=h(e),s=[],i=this._getPreInitialState(t,r,s),[o]=(n=this.root,tu([{target:[...tt(n)],source:n,reenter:!0,actions:[],eventType:null,toJSON:null}],i,t,r,!0,s)),{snapshot:a}=td(o,r,t,s);return a}start(t){Object.values(t.children).forEach(t=>{"active"===t.getSnapshot().status&&t.start()})}getStateNodeById(t){let e=p(t),n=e.slice(1),r=K(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 tn(s,n)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(t,e){return function(t,e){let{_nodes:n,tags:r,machine:s,children:i,context:o,can:a,hasTag:c,matches:u,getMeta:l,toJSON:h,...f}=t,d={};for(let t in i){let n=i[t];d[t]={snapshot:n.getPersistedSnapshot(e),src:n.src,systemId:n.systemId,syncSnapshot:n._syncSnapshot}}return{...f,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:d,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}(f.historyValue)}}(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?w(this,o):o;if(!a)return;let c=R(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 tP)return e;try{return t.machine.getStateNodeById(e.id)}catch{}}(t,s);e&&(n[r]??=[],n[r].push(e))}return n}(this.root,t.historyValue),i=tx({...t,children:n,_nodes:Array.from(J(tr(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 tC(t,e,n,r,{event:s}){return[e,{event:"function"==typeof s?s(n,r):s},void 0]}function tL(t,{event:e}){t.defer(()=>t.emit(e))}function tD(t){function e(t,e){}return e.type="xstate.emit",e.event=t,e.resolve=tC,e.execute=tL,e}let tU=((tZ={}).Parent="#_parent",tZ.Internal="#_internal",tZ);function tz(t,e,n,r,{to:s,event:i,id:o,delay:a},c){let u,l,h=e.machine.implementations.delays;if("string"==typeof i)throw Error(`Only event objects may be used with sendTo; use sendTo({ type: "${i}" }) instead`);let f="function"==typeof i?i(n,r):i;if("string"==typeof a){let t=h&&h[a];u="function"==typeof t?t(n,r):t}else u="function"==typeof a?a(n,r):a;let d="function"==typeof s?s(n,r):s;if("string"==typeof d){if(!(l=d===tU.Parent?t.self._parent:d===tU.Internal?t.self:d.startsWith("#_")?e.children[d.slice(2)]:c.deferredActorIds?.includes(d)?d:e.children[d]))throw Error(`Unable to send event to actor '${d}' from machine '${e.machine.id}'.`)}else l=d||t.self;return[e,{to:l,targetId:"string"==typeof d?d:void 0,event:f,id:o,delay:u},void 0]}function tB(t,e,n){"string"==typeof n.to&&(n.to=e.children[n.to])}function tV(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,"xstate.error"===r.type?l(t.self.id,r.data):r)})}function tW(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=tz,r.retryResolve=tB,r.execute=tV,r}function tJ(t,e,n,r,{collect:s}){let i=[],o=function(t){i.push(t)};return o.assign=(...t)=>{i.push(tO(...t))},o.cancel=(...t)=>{i.push(q(...t))},o.raise=(...t)=>{i.push(tE(...t))},o.sendTo=(...t)=>{i.push(tW(...t))},o.sendParent=(...t)=>{i.push(function(t,e){return tW(tU.Parent,t,e)}(...t))},o.spawnChild=(...t)=>{i.push(C(...t))},o.stopChild=(...t)=>{i.push(U(...t))},o.emit=(...t)=>{i.push(tD(...t))},s({context:n.context,event:n.event,enqueue:o,check:t=>z(t,e.context,n.event,e),self:t.self,system:t.system},r),[e,void 0,i]}function tG(t){function e(t,e){}return e.type="xstate.enqueueActions",e.collect=t,e.resolve=tJ,e}function tY(t,e,n,r,{value:s,label:i}){return[e,{value:"function"==typeof s?s(n,r):s,label:i},void 0]}function tH({logger:t},{value:e,label:n}){n?t(n,e):t(e)}function tK(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=tY,n.execute=tH,n}function tF(t,e){let n=g(e);if(!n.some(e=>k(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 tQ({schemas:t,actors:e,actions:n,guards:r,delays:s}){return{assign:tO,sendTo:tW,raise:tE,log:tK,cancel:q,stopChild:U,enqueueActions:tG,emit:tD,spawnChild:C,createStateConfig:t=>t,createAction:t=>t,createMachine:i=>new tN({...i,schemas:t},{actors:e,actions:n,guards:r,delays:s}),extend:i=>tQ({schemas:t,actors:e,actions:{...n,...i.actions},guards:{...r,...i.guards},delays:{...s,...i.delays}})}}var tX,tZ,t0=t.i(290571);function t1(t){return"function"==typeof t}function t2(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}t.s(["isFunction",0,t1],603752),t.s(["createErrorClass",0,t2],842093);var t3=t2(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 t6(t,e){if(t){var n=t.indexOf(e);0<=n&&t.splice(n,1)}}t.s(["arrRemove",0,t6],586903);var t4=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=(0,t0.__values)(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(t1(c))try{c()}catch(t){s=t instanceof t3?t.errors:[t]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var l=(0,t0.__values)(u),h=l.next();!h.done;h=l.next()){var f=h.value;try{t7(f)}catch(t){s=null!=s?s:[],t instanceof t3?s=(0,t0.__spreadArray)((0,t0.__spreadArray)([],(0,t0.__read)(s)),(0,t0.__read)(t.errors)):s.push(t)}}}catch(t){n={error:t}}finally{try{h&&!h.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}}if(s)throw new t3(s)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)t7(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)&&t6(e,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&t6(n,t),t instanceof e&&t._removeParent(this)},(t=new e).closed=!0,e.EMPTY=t,e}(),t9=t4.EMPTY;function t5(t){return t instanceof t4||t&&"closed"in t&&t1(t.remove)&&t1(t.add)&&t1(t.unsubscribe)}function t7(t){t1(t)?t():t.unsubscribe()}t.s(["EMPTY_SUBSCRIPTION",0,t9,"Subscription",0,t4,"isSubscription",0,t5],909116);var t8=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,(0,t0.__spreadArray)([t,e],(0,t0.__read)(n))):setTimeout.apply(void 0,(0,t0.__spreadArray)([t,e],(0,t0.__read)(n)))},clearTimeout:function(t){var e=et.delegate;return((null==e?void 0:e.clearTimeout)||clearTimeout)(t)},delegate:void 0};function ee(t){et.setTimeout(function(){!1;throw t})}function en(){}var er=es("C",void 0,void 0);function es(t,e,n){return{kind:t,value:e,error:n}}var ei=null;function eo(t){var e,n,r,s;1;t()}function ea(t){}t.s(["captureError",0,ea,"errorContext",0,eo],140260);var ec=function(t){function e(e){var n=t.call(this)||this;return n.isStopped=!1,e?(n.destination=e,t5(e)&&e.add(n)):n.destination=ey,n}return(0,t0.__extends)(e,t),e.create=function(t,e,n){return new ef(t,e,n)},e.prototype.next=function(t){this.isStopped?ep(es("N",t,void 0),this):this._next(t)},e.prototype.error=function(t){this.isStopped?ep(es("E",void 0,t),this):(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped?ep(er,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}(t4),eu=Function.prototype.bind;function el(t,e){return eu.call(t,e)}var eh=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){ed(t)}},t.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(t){ed(t)}else ed(t)},t.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){ed(t)}},t}(),ef=function(t){function e(e,n,r){var s,i,o=t.call(this)||this;return t1(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 eh(s),o}return(0,t0.__extends)(e,t),e}(ec);function ed(t){ee(t)}function ep(t,e){}var ey={closed:!0,next:en,error:function(t){throw t},complete:en};t.s(["SafeSubscriber",0,ef,"Subscriber",0,ec],240126);var ev="function"==typeof Symbol&&Symbol.observable||"@@observable";function eg(t){return t}function em(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return e_(t)}function e_(t){return 0===t.length?eg:1===t.length?t[0]:function(e){return t.reduce(function(t,e){return e(t)},e)}}t.s(["identity",0,eg],979165),t.s(["pipe",0,em,"pipeFromArray",0,e_],282541);var eb=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 ec||t&&t1(t.next)&&t1(t.error)&&t1(t.complete)&&t5(t)}(t)?new ef(t,e,n):t;return eo(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=ex(e))(function(e,r){var s=new ef({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 e_(t)(this)},t.prototype.toPromise=function(t){var e=this;return new(t=ex(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 ex(t){var e;return null!=(e=null!=t?t:t8)?e:Promise}t.s(["Observable",0,eb],394426);var eS=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t};function ew(t){return t1(null==t?void 0:t.then)}function ek(t){return t1(t[ev])}function eE(t){return Symbol.asyncIterator&&t1(null==t?void 0:t[Symbol.asyncIterator])}function eI(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",0,eS],987675),t.s(["isPromise",0,ew],349449),t.s(["isInteropObservable",0,ek],717718),t.s(["isAsyncIterable",0,eE],238331),t.s(["createInvalidObservableTypeError",0,eI],254824);var eT="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function e$(t){return t1(null==t?void 0:t[eT])}function eA(t){return(0,t0.__asyncGenerator)(this,arguments,function(){var e,n,r;return(0,t0.__generator)(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,(0,t0.__await)(e.read())];case 3:if(r=(n=s.sent()).value,!n.done)return[3,5];return[4,(0,t0.__await)(void 0)];case 4:return[2,s.sent()];case 5:return[4,(0,t0.__await)(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 eO(t){return t1(null==t?void 0:t.getReader)}function eR(t){if(t instanceof eb)return t;if(null!=t){var e,n,r,s;if(ek(t)){return e=t,new eb(function(t){var n=e[ev]();if(t1(n.subscribe))return n.subscribe(t);throw TypeError("Provided object does not correctly implement Symbol.observable")})}if(eS(t)){return n=t,new eb(function(t){for(var e=0;e<n.length&&!t.closed;e++)t.next(n[e]);t.complete()})}if(ew(t)){return r=t,new eb(function(t){r.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,ee)})}if(eE(t))return eM(t);if(e$(t)){return s=t,new eb(function(t){var e,n;try{for(var r=(0,t0.__values)(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(eO(t))return eM(eA(t))}throw eI(t)}function eM(t){return new eb(function(e){(function(t,e){var n,r,s,i;return(0,t0.__awaiter)(this,void 0,void 0,function(){var o;return(0,t0.__generator)(this,function(a){switch(a.label){case 0:a.trys.push([0,5,6,11]),n=(0,t0.__asyncValues)(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 ej(t){return new eb(function(e){eR(t()).subscribe(e)})}function eq(t){return function(e){if(t1(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 eP(t,e,n,r,s){return new eN(t,e,n,r,s)}t.s(["iterator",0,eT],177650),t.s(["isIterable",0,e$],23515),t.s(["isReadableStreamLike",0,eO,"readableStreamLikeToAsyncGenerator",0,eA],311902),t.s(["innerFrom",0,eR],220324),t.s(["defer",0,ej],172441),t.s(["operate",0,eq],902965);var eN=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(0,t0.__extends)(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}(ec);function eC(t,e){return eq(function(n,r){var s=0;n.subscribe(eP(r,function(n){r.next(t.call(e,n,s++))}))})}function eL(t,e,n){return(void 0===n&&(n=1/0),t1(e))?eL(function(n,r){return eC(function(t,s){return e(n,t,r,s)})(eR(t(n,r)))},n):("number"==typeof e&&(n=e),eq(function(e,r){var s,i,o,a,c,u,l,h;return s=n,i=[],o=0,a=0,c=!1,u=function(){!c||i.length||o||r.complete()},l=function(t){return o<s?h(t):i.push(t)},h=function(e){o++;var n=!1;eR(t(e,a++)).subscribe(eP(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();h(t)}();u()}catch(t){r.error(t)}}))},e.subscribe(eP(r,l,function(){c=!0,u()})),function(){}}))}t.s(["createOperatorSubscriber",0,eP],627608),t.s(["map",0,eC],94059),t.s(["executeSchedule",0,function(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}],175436),t.s(["mergeMap",0,eL],484973);var eD=Array.isArray;function eU(t){return eC(function(e){return eD(e)?t.apply(void 0,(0,t0.__spreadArray)([],(0,t0.__read)(e))):t(e)}
3)}t.s(["mapOneOrManyArgs",0,eU],272383);var ez=["addListener","removeListener"],eB=["addEventListener","removeEventListener"],eV=["on","off"];function eW(t,e,n,r){if(t1(n)&&(r=n,n=void 0),r)return eW(t,e,n).pipe(eU(r));var s,i,o,a=(0,t0.__read)(t1((s=t).addEventListener)&&t1(s.removeEventListener)?eB.map(function(r){return function(s){return t[r](e,s,n)}}):t1((i=t).addListener)&&t1(i.removeListener)?ez.map(eJ(t,e)):t1((o=t).on)&&t1(o.off)?eV.map(eJ(t,e)):[],2),c=a[0],u=a[1];if(!c&&eS(t))return eL(function(t){return eW(t,e,n)})(eR(t));if(!c)throw TypeError("Invalid event target");return new eb(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 eJ(t,e){return function(n){return function(r){return t[n](e,r)}}}function eG(t,e){return eq(function(n,r){var s=0;n.subscribe(eP(r,function(n){return t.call(e,n,s++)&&r.next(n)}))})}t.s(["filter",0,eG],722249);var eY=new eb(function(t){return t.complete()});function eH(t){return t<=0?function(){return eY}:eq(function(e,n){var r=0;e.subscribe(eP(n,function(e){++r<=t&&(n.next(e),t<=r&&n.complete())}))})}t.s(["EMPTY",0,eY],96623);let eK=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}},eF=ej(()=>eW(window,"message")),eQ=t=>t$(({input:e})=>{var n,r,s;let i;return eF.pipe(t?eC(t):em(),eG(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)}),eC((i=e.responseType,t=>({type:i,message:t}))),e.count?em((n=e.count,void 0===r&&(r=null),r=null!=r?r:n,eq(function(t,e){var s=[],i=0;t.subscribe(eP(e,function(t){var o,a,c,u,l=null;i++%r==0&&s.push([]);try{for(var h=(0,t0.__values)(s),f=h.next();!f.done;f=h.next()){var d=f.value;d.push(t),n<=d.length&&(l=null!=l?l:[]).push(d)}}catch(t){o={error:t}}finally{try{f&&!f.done&&(a=h.return)&&a.call(h)}finally{if(o)throw o.error}}if(l)try{for(var p=(0,t0.__values)(l),y=p.next();!y.done;y=p.next()){var d=y.value;t6(s,d),e.next(d)}}catch(t){c={error:t}}finally{try{y&&!y.done&&(u=p.return)&&u.call(p)}finally{if(c)throw c.error}}},function(){var t,n;try{for(var r=(0,t0.__values)(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}))})),(s=t=>t,t1(void 0)?eL(s,void 0,1):eL(s,1)),eH(e.count)):em())}),eX="sanity/comlink",eZ="comlink/response",e0="comlink/heartbeat",e1="comlink/disconnect",e2="comlink/handshake/syn",e3="comlink/handshake/syn-ack",e6="comlink/handshake/ack",e4=()=>tQ({types:{},actors:{listen:t$(({input:t})=>{let e,n=t.signal?eW(t.signal,"abort").pipe((e=`Request ${t.requestId} aborted`,t=>t.pipe(eH(1),eC(()=>{throw Error(e)})))):eY;return eW(window,"message").pipe(eG(e=>e.data?.type===eZ&&e.data?.responseTo===t.requestId&&!!e.source&&t.sources.has(e.source)),eH(t.sources.size),eq(function(t,e){eR(n).subscribe(eP(e,function(){return e.complete()},en)),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":tW(({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":tW(({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":tW(({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-${i()}`,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:tO({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})}),e9=()=>tQ({types:{},actors:{requestMachine:e4(),listen:eQ()},actions:{"buffer handshake":tO({handshakeBuffer:({event:t,context:e})=>(tF(t,"message.received"),[...e.handshakeBuffer,t])}),"buffer message":tG(({enqueue:t})=>{t.assign({buffer:({event:t,context:e})=>(tF(t,"post"),[...e.buffer,{data:t.data,resolvable:t.resolvable,options:t.options}])}),t.emit(({event:t})=>(tF(t,"post"),{type:"buffer.added",message:t.data}))}),"create request":tO({requests:({context:t,event:e,self:n,spawn:r})=>{tF(e,"request");let s=(Array.isArray(e.data)?e.data:[e.data]).map(e=>r("requestMachine",{id:`req-${i()}`,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":tD(()=>({type:"heartbeat"})),"emit received message":tG(({enqueue:t})=>{t.emit(({event:t})=>(tF(t,"message.received"),{type:"message",message:t.message.data}))}),"emit status":tD((t,e)=>({type:"status",status:e.status})),"post message":tE(({event:t})=>(tF(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":tG(({context:t,enqueue:e})=>{t.handshakeBuffer.forEach(t=>e.raise(t)),e.assign({handshakeBuffer:[]})}),"remove request":tG(({context:t,enqueue:e,event:n})=>{tF(n,["request.success","request.failed","request.aborted"]),U(n.requestId),e.assign({requests:t.requests.filter(({id:t})=>t!==n.requestId)})}),"send response":tE(({event:t})=>(tF(t,["message.received","heartbeat.received"]),{type:"request",data:{type:eZ,responseTo:t.message.data.id,data:void 0}})),"send handshake syn ack":tE({type:"request",data:{type:e3}}),"send pending messages":tG(({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":tO({channelId:({event:t})=>(tF(t,"handshake.syn"),t.message.data.channelId),target:({event:t})=>(tF(t,"handshake.syn"),t.message.source||void 0),targetOrigin:({event:t})=>(tF(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??eX,handshakeBuffer:[],name:t.name,requests:[],target:void 0,targetOrigin:null}),invoke:{id:"listen for handshake syn",src:"listen",input:eK({include:e2,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:eK({include:e6,count:1,responseType:"handshake.complete"}),onDone:"connected"},{id:"listen for disconnect",src:"listen",input:eK({include:e1,count:1,responseType:"disconnect"})},{id:"listen for messages",src:"listen",input:eK({exclude:[e1,e2,e6,e0,eZ]})}],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:eK({exclude:[e1,e2,e6,e0,eZ]})},{id:"listen for heartbeat",src:"listen",input:eK({include:e0,responseType:"heartbeat.received"})},{id:"listen for disconnect",src:"listen",input:eK({include:e1,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"]}}}}});t.s(["DOMAIN",0,eX,"MSG_DISCONNECT",0,e1,"MSG_HANDSHAKE_ACK",0,e6,"MSG_HANDSHAKE_SYN",0,e2,"MSG_HANDSHAKE_SYN_ACK",0,e3,"MSG_HEARTBEAT",0,e0,"MSG_RESPONSE",0,eZ,"createListenLogic",0,eQ,"createNode",0,(t,e=e9())=>{let n,r=R(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}},"createNodeMachine",0,e9,"createRequestMachine",0,e4],881283);let e5={"handshake/syn":e2,"handshake/syn-ack":e3,"handshake/ack":e6,"channel/response":eZ,"channel/heartbeat":e0,"channel/disconnect":e1,"overlay/focus":"visual-editing/focus","overlay/navigate":"visual-editing/navigate","overlay/toggle":"visual-editing/toggle","presentation/toggleOverlay":"presentation/toggle-overlay"},e7={[e2]:"handshake/syn",[e3]:"handshake/syn-ack",[e6]:"handshake/ack",[eZ]:"channel/response",[e0]:"channel/heartbeat",[e1]:"channel/disconnect","visual-editing/focus":"overlay/focus","visual-editing/navigate":"overlay/navigate","visual-editing/toggle":"overlay/toggle","presentation/toggle-overlay":"presentation/toggleOverlay"},e8=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=eX),"overlays"===e.to&&(e.to="visual-editing"),"overlays"===e.from&&(e.from="visual-editing"),e.channelId=e.connectionId,delete e.connectionId,e.type=e5[e.type]??e.type),t},nt=({context:t},e)=>{let{sources:n,targetOrigin:r}=t,s=(t=>{let{channelId:e,...n}=t,r={...n,connectionId:e};return r.domain===eX&&(r.domain="sanity/channels"),"visual-editing"===r.to&&(r.to="overlays"),"visual-editing"===r.from&&(r.from="overlays"),r.type=e7[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})})};function ne(){return!!window.opener}t.s(["createCompatibilityActors",0,()=>({listen:eQ(e8),requestMachine:e4().provide({actions:{"send message":nt}}
3)}),"isMaybePresentation",0,function(){return window.self!==window.top||ne()},"isMaybePreviewWindow",0,ne],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.