PageSourceSearch

https://kongernesjelling.dk/_nuxt/C7DE8dgK.js

js kongernesjelling.dk collected 2026-10-02 12:50:19 UTC 52,002 bytes, 3 lines download raw bytes

1import{bC as St,bD as bt,bE as Tt,bF as fe,bG as Ke,bH as wt,bI as x,bJ as Se,bK as be,bL as ne,bM as xt,bN as Xe,bO as Et,bP as kt,bQ as he,bR as se,bS as Fe}from"./C4DTFQLm.js";var It=["addListener","removeListener"],At=["addEventListener","removeEventListener"],$t=["on","off"];function W(e,t,n,s){if(x(n)&&(s=n,n=void 0),s)return W(e,t,n).pipe(St(s));var r=bt(Ot(e)?At.map(function(a){return function(d){return e[a](t,d,n)}}):Mt(e)?It.map(Re(e,t)):Rt(e)?$t.map(Re(e,t)):[],2),i=r[0],o=r[1];if(!i&&Tt(e))return fe(function(a){return W(a,t,n)})(Ke(e));if(!i)throw new TypeError("Invalid event target");return new wt(function(a){var d=function(){for(var f=[],p=0;p<arguments.length;p++)f[p]=arguments[p];return a.next(1<f.length?f:f[0])};return i(d),function(){return o(d)}})}function Re(e,t){return function(n){return function(s){return e[n](t,s)}}}function Mt(e){return x(e.addListener)&&x(e.removeListener)}function Rt(e){return x(e.on)&&x(e.off)}function Ot(e){return x(e.addEventListener)&&x(e.removeEventListener)}function qt(e,t){return t===void 0&&(t=null),t=t??e,Se(function(n,s){var r=[],i=0;n.subscribe(be(s,function(o){var a,d,f,p,u=null;i++%t===0&&r.push([]);try{for(var c=ne(r),l=c.next();!l.done;l=c.next()){var h=l.value;h.push(o),e<=h.length&&(u=u??[],u.push(h))}}catch(v){a={error:v}}finally{try{l&&!l.done&&(d=c.return)&&d.call(c)}finally{if(a)throw a.error}}if(u)try{for(var y=ne(u),g=y.next();!g.done;g=y.next()){var h=g.value;xt(r,h),s.next(h)}}catch(v){f={error:v}}finally{try{g&&!g.done&&(p=y.return)&&p.call(y)}finally{if(f)throw f.error}}},function(){var o,a;try{for(var d=ne(r),f=d.next();!f.done;f=d.next()){var p=f.value;s.next(p)}}catch(u){o={error:u}}finally{try{f&&!f.done&&(a=d.return)&&a.call(d)}finally{if(o)throw o.error}}s.complete()},void 0,function(){r=null}))})}function Ct(e,t){return x(t)?fe(e,t,1):fe(e,1)}function Te(e){return e<=0?function(){return Xe}:Se(function(t,n){var s=0;t.subscribe(be(n,function(r){++s<=e&&(n.next(r),e<=s&&n.complete())}))})}function jt(e){return Se(function(t,n){Ke(e).subscribe(be(n,function(){return n.complete()},Et)),!n.closed&&t.subscribe(n)})}const m=[];for(let e=0;e<256;++e)m.push((e+256).toString(16).slice(1));function Dt(e,t=0){return(m[e[t+0]]+m[e[t+1]]+m[e[t+2]]+m[e[t+3]]+"-"+m[e[t+4]]+m[e[t+5]]+"-"+m[e[t+6]]+m[e[t+7]]+"-"+m[e[t+8]]+m[e[t+9]]+"-"+m[e[t+10]]+m[e[t+11]]+m[e[t+12]]+m[e[t+13]]+m[e[t+14]]+m[e[t+15]]).toLowerCase()}let re;const Lt=new Uint8Array(16);function Ut(){if(!re){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");re=crypto.getRandomValues.bind(crypto)}return re(Lt)}const Pt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Oe={randomUUID:Pt};function Ye(e,t,n){var r;if(Oe.randomUUID&&!e)return Oe.randomUUID();e=e||{};const s=e.random??((r=e.rng)==null?void 0:r.call(e))??Ut();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,Dt(s)}function Jt(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global}function Ht(){const e=Jt();if(e.__xstate__)return e.__xstate__}const Wt=e=>{if(typeof window>"u")return;const t=Ht();t&&t.register(e)};class qe{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){const n={value:t,next:null};if(this._current){this._last.next=n,this._last=n;return}this._current=n,this._last=n,this._active&&this.flush()}flush(){for(;this._current;){const t=this._current;this._process(t.value),this._current=t.next}this._last=null}}const Ve=".",Gt="",Ze="",Bt="#",zt="*",Ne="xstate.init",Kt="xstate.error",G="xstate.stop";function Xt(e,t){return{type:`xstate.after.${e}.${t}`}}function le(e,t){return{type:`xstate.done.state.${e}`,output:t}}function Ft(e,t){return{type:`xstate.done.actor.${e}`,output:t,actorId:e}}function Qe(e,t){return{type:`xstate.error.actor.${e}`,error:t,actorId:e}}function et(e){return{type:Ne,input:e}}function b(e){setTimeout(()=>{throw e})}const Yt=typeof Symbol=="function"&&Symbol.observable||"@@observable";function tt(e,t){const n=Ce(e),s=Ce(t);return typeof s=="string"?typeof n=="string"?s===n:!1:typeof n=="string"?n in s:Object.keys(n).every(r=>r in s?tt(n[r],s[r]):!1)}function we(e){if(st(e))return e;const t=[];let n="";for(let s=0;s<e.length;s++){switch(e.charCodeAt(s)){case 92:n+=e[s+1],s++;continue;case 46:t.push(n),n="";continue}n+=e[s]}return t.push(n),t}function Ce(e){if(An(e))return e.value;if(typeof e!="string")return e;const t=we(e);return Vt(t)}function Vt(e){if(e.length===1)return e[0];const t={};let n=t;for(let s=0;s<e.length-1;s++)if(s===e.length-2)n[e[s]]=e[s+1];else{const r=n;n={},r[e[s]]=n}return t}function je(e,t){const n={},s=Object.keys(e);for(let r=0;r<s.length;r++){const i=s[r];n[i]=t(e[i],i,e,r)}return n}function nt(e){return st(e)?e:[e]}function T(e){return e===void 0?[]:nt(e)}function pe(e,t,n,s){return typeof e=="function"?e({context:t,event:n,self:s}):e}function st(e){return Array.isArray(e)}function Zt(e){return e.type.startsWith("xstate.error.actor")}function R(e){return nt(e).map(t=>typeof t>"u"||typeof t=="string"?{target:t}:t)}function rt(e){if(!(e===void 0||e===Gt))return T(e)}function ye(e,t,n){var i,o,a;const s=typeof e=="object",r=s?e:void 0;return{next:(i=s?e.next:e)==null?void 0:i.bind(r),error:(o=s?e.error:t)==null?void 0:o.bind(r),complete:(a=s?e.complete:n)==null?void 0:a.bind(r)}}function De(e,t){return`${t}.${e}`}function xe(e,t){const n=t.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!n)return e.implementations.actors[t];const[,s,r]=n,o=e.getStateNodeById(r).config.invoke;return(Array.isArray(o)?o[s]:o).src}function Le(e,t){return`${e.sessionId}.${t}`}let Nt=0;function Qt(e,t){const n=new Map,s=new Map,r=new WeakMap,i=new Set,o={},{clock:a,logger:d}=t,f={schedule:(c,l,h,y,g=Math.random().toString(36).slice(2))=>{const v={source:c,target:l,event:h,delay:y,id:g,startedAt:Date.now()},w=Le(c,g);u._snapshot._scheduledEvents[w]=v;const _t=a.setTimeout(()=>{delete o[w],delete u._snapshot._scheduledEvents[w],u._relay(c,l,h)},y);o[w]=_t},cancel:(c,l)=>{const h=Le(c,l),y=o[h];delete o[h],delete u._snapshot._scheduledEvents[h],y!==void 0&&a.clearTimeout(y)}
1,cancelAll:c=>{for(const l in u._snapshot._scheduledEvents){const h=u._snapshot._scheduledEvents[l];h.source===c&&f.cancel(c,h.id)}}},p=c=>{if(!i.size)return;const l={...c,rootId:e.sessionId};i.forEach(h=>{var y;return(y=h.next)==null?void 0:y.call(h,l)})},u={_snapshot:{_scheduledEvents:((t==null?void 0:t.snapshot)&&t.snapshot.scheduler)??{}},_bookId:()=>`x:${Nt++}`,_register:(c,l)=>(n.set(c,l),c),_unregister:c=>{n.delete(c.sessionId);const l=r.get(c);l!==void 0&&(s.delete(l),r.delete(c))},get:c=>s.get(c),_set:(c,l)=>{const h=s.get(c);if(h&&h!==l)throw new Error(`Actor with system ID '${c}' already exists.`);s.set(c,l),r.set(l,c)},inspect:c=>{const l=ye(c);return i.add(l),{unsubscribe(){i.delete(l)}}},_sendInspectionEvent:p,_relay:(c,l,h)=>{u._sendInspectionEvent({type:"@xstate.event",sourceRef:c,actorRef:l,event:h}),l._send(h)},scheduler:f,getSnapshot:()=>({_scheduledEvents:{...u._snapshot._scheduledEvents}}),start:()=>{const c=u._snapshot._scheduledEvents;u._snapshot._scheduledEvents={};for(const l in c){const{source:h,target:y,event:g,delay:v,id:w}=c[l];f.schedule(h,y,g,v,w)}},_clock:a,_logger:d};return u}let ie=!1;const Ee=1;let _=function(e){return e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped",e}({});const en={clock:{setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},logger:console.log.bind(console),devTools:!1};class tn{constructor(t,n){this.logic=t,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new qe(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 s={...en,...n},{clock:r,logger:i,parent:o,syncSnapshot:a,id:d,systemId:f,inspect:p}=s;this.system=o?o.system:Qt(this,{clock:r,logger:i}),p&&!o&&this.system.inspect(ye(p)),this.sessionId=this.system._bookId(),this.id=d??this.sessionId,this.logger=(n==null?void 0:n.logger)??this.system._logger,this.clock=(n==null?void 0:n.clock)??this.system._clock,this._parent=o,this._syncSnapshot=a,this.options=s,this.src=s.src??t,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:u=>{this._deferred.push(u)},system:this.system,stopChild:u=>{if(u._parent!==this)throw new Error(`Cannot stop child actor ${u.id} of ${this.id} because it is not a child`);u._stop()},emit:u=>{const c=this.eventListeners.get(u.type),l=this.eventListeners.get("*");if(!c&&!l)return;const h=[...c?c.values():[],...l?l.values():[]];for(const y of h)y(u)},actionExecutor:u=>{const c=()=>{if(this._actorScope.system._sendInspectionEvent({type:"@xstate.action",actorRef:this,action:{type:u.type,params:u.params}}),!u.exec)return;const l=ie;try{ie=!0,u.exec(u.info,u.params)}finally{ie=l}};this._processingStatus===_.Running?c():this._deferred.push(c)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),f&&(this._systemId=f,this.system._set(f,this)),this._initState((n==null?void 0:n.snapshot)??(n==null?void 0:n.state)),f&&this._snapshot.status!=="active"&&this.system._unregister(this)}_initState(t){var n;try{this._snapshot=t?this.logic.restoreSnapshot?this.logic.restoreSnapshot(t,this._actorScope):t:this.logic.getInitialSnapshot(this._actorScope,(n=this.options)==null?void 0:n.input)}catch(s){this._snapshot={status:"error",output:void 0,error:s}}}update(t,n){var r,i;this._snapshot=t;let s;for(;s=this._deferred.shift();)try{s()}catch(o){this._deferred.length=0,this._snapshot={...t,status:"error",error:o}}switch(this._snapshot.status){case"active":for(const o of this.observers)try{(r=o.next)==null||r.call(o,t)}catch(a){b(a)}break;case"done":for(const o of this.observers)try{(i=o.next)==null||i.call(o,t)}catch(a){b(a)}this._stopProcedure(),this._complete(),this._doneEvent=Ft(this.id,this._snapshot.output),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case"error":this._error(this._snapshot.error);break}this.system._sendInspectionEvent({type:"@xstate.snapshot",actorRef:this,event:n,snapshot:t})}subscribe(t,n,s){var i;const r=ye(t,n,s);if(this._processingStatus!==_.Stopped)this.observers.add(r);else switch(this._snapshot.status){case"done":try{(i=r.complete)==null||i.call(r)}catch(o){b(o)}break;case"error":{const o=this._snapshot.error;if(!r.error)b(o);else try{r.error(o)}catch(a){b(a)}break}}return{unsubscribe:()=>{this.observers.delete(r)}}}on(t,n){let s=this.eventListeners.get(t);s||(s=new Set,this.eventListeners.set(t,s));const r=n.bind(void 0);return s.add(r),{unsubscribe:()=>{s.delete(r)}}}
1start(){if(this._processingStatus===_.Running)return this;this._syncSnapshot&&this.subscribe({next:s=>{s.status==="active"&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:s})},error:()=>{}}),this.system._register(this.sessionId,this),this._systemId&&this.system._set(this._systemId,this),this._processingStatus=_.Running;const t=et(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(s){return this._snapshot={...this._snapshot,status:"error",error:s},this._error(s),this}return this.update(this._snapshot,t),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(t){let n,s;try{n=this.logic.transition(this._snapshot,t,this._actorScope)}catch(r){s={err:r}}if(s){const{err:r}=s;this._snapshot={...this._snapshot,status:"error",error:r},this._error(r);return}this.update(n,t),t.type===G&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===_.Stopped?this:(this.mailbox.clear(),this._processingStatus===_.NotStarted?(this._processingStatus=_.Stopped,this):(this.mailbox.enqueue({type:G}),this))}stop(){if(this._parent)throw new Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){var t;for(const n of this.observers)try{(t=n.complete)==null||t.call(n)}catch(s){b(s)}this.observers.clear()}_reportError(t){if(!this.observers.size){this._parent||b(t);return}let n=!1;for(const s of this.observers){const r=s.error;n||(n=!r);try{r==null||r(t)}catch(i){b(i)}}this.observers.clear(),n&&b(t)}_error(t){this._stopProcedure(),this._reportError(t),this._parent&&this.system._relay(this,this._parent,Qe(this.id,t))}_stopProcedure(){return this._processingStatus!==_.Running?this:(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new qe(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(){const{devTools:t}=this.options;t&&(typeof t=="function"?t:Wt)(this)}toJSON(){return{xstate$$type:Ee,id:this.id}}getPersistedSnapshot(t){return this.logic.getPersistedSnapshot(this._snapshot,t)}[Yt](){return this}getSnapshot(){return this._snapshot}}function C(e,...[t]){return new tn(e,t)}function nn(e,t,n,s,{sendId:r}){const i=typeof r=="function"?r(n,s):r;return[t,{sendId:i},void 0]}function sn(e,t){e.defer(()=>{e.system.scheduler.cancel(e.self,t.sendId)})}function it(e){function t(n,s){}return t.type="xstate.cancel",t.sendId=e,t.resolve=nn,t.execute=sn,t}function rn(e,t,n,s,{id:r,systemId:i,src:o,input:a,syncSnapshot:d}){const f=typeof o=="string"?xe(t.machine,o):o,p=typeof r=="function"?r(n):r;let u,c;return f&&(c=typeof a=="function"?a({context:t.context,event:n.event,self:e.self}):a,u=C(f,{id:p,src:o,parent:e.self,syncSnapshot:d,systemId:i,input:c})),[$(t,{children:{...t.children,[p]:u}}),{id:r,systemId:i,actorRef:u,src:o,input:c},void 0]}function on(e,{actorRef:t}){t&&e.defer(()=>{t._processingStatus!==_.Stopped&&t.start()})}function ot(...[e,{id:t,systemId:n,input:s,syncSnapshot:r=!1}={}]){function i(o,a){}return i.type="xstate.spawnChild",i.id=t,i.systemId=n,i.src=e,i.input=s,i.syncSnapshot=r,i.resolve=rn,i.execute=on,i}function an(e,t,n,s,{actorRef:r}){const i=typeof r=="function"?r(n,s):r,o=typeof i=="string"?t.children[i]:i;let a=t.children;return o&&(a={...a},delete a[o.id]),[$(t,{children:a}),o,void 0]}function cn(e,t){if(t){if(e.system._unregister(t),t._processingStatus!==_.Running){e.stopChild(t);return}e.defer(()=>{e.stopChild(t)})}}function Q(e){function t(n,s){}return t.type="xstate.stopChild",t.actorRef=e,t.resolve=an,t.execute=cn,t}function ee(e,t,n,s){const{machine:r}=s,i=typeof e=="function",o=i?e:r.implementations.guards[typeof e=="string"?e:e.type];if(!i&&!o)throw new Error(`Guard '${typeof e=="string"?e:e.type}' is not implemented.'.`);if(typeof o!="function")return ee(o,t,n,s);const a={context:t,event:n},d=i||typeof e=="string"?void 0:"params"in e?typeof e.params=="function"?e.params({context:t,event:n}):e.params:void 0;return"check"in o?o.check(s,a,o):o(a,d)}const ke=e=>e.type==="atomic"||e.type==="final";function j(e){return Object.values(e.states).filter(t=>t.type!=="history")}function B(e,t){const n=[];if(t===e)return n;let s=e.parent;for(;s&&s!==t;)n.push(s),s=s.parent;return n}function Y(e){const t=new Set(e),n=ct(t);for(const s of t)if(s.type==="compound"&&(!n.get(s)||!n.get(s).length))Ue(s).forEac
1h(r=>t.add(r));else if(s.type==="parallel"){for(const r of j(s))if(r.type!=="history"&&!t.has(r)){const i=Ue(r);for(const o of i)t.add(o)}}for(const s of t){let r=s.parent;for(;r;)t.add(r),r=r.parent}return t}function at(e,t){const n=t.get(e);if(!n)return{};if(e.type==="compound"){const r=n[0];if(r){if(ke(r))return r.key}else return{}}const s={};for(const r of n)s[r.key]=at(r,t);return s}function ct(e){const t=new Map;for(const n of e)t.has(n)||t.set(n,[]),n.parent&&(t.has(n.parent)||t.set(n.parent,[]),t.get(n.parent).push(n));return t}function ut(e,t){const n=Y(t);return at(e,ct(n))}function Ie(e,t){return t.type==="compound"?j(t).some(n=>n.type==="final"&&e.has(n)):t.type==="parallel"?j(t).every(n=>Ie(e,n)):t.type==="final"}const te=e=>e[0]===Bt;function un(e,t){return e.transitions.get(t)||[...e.transitions.keys()].filter(s=>{if(s===zt)return!0;if(!s.endsWith(".*"))return!1;const r=s.split("."),i=t.split(".");for(let o=0;o<r.length;o++){const a=r[o],d=i[o];if(a==="*")return o===r.length-1;if(a!==d)return!1}return!0}).sort((s,r)=>r.length-s.length).flatMap(s=>e.transitions.get(s))}function dn(e){const t=e.config.after;if(!t)return[];const n=r=>{const i=Xt(r,e.id),o=i.type;return e.entry.push(J(i,{id:o,delay:r})),e.exit.push(it(o)),o};return Object.keys(t).flatMap(r=>{const i=t[r],o=typeof i=="string"?{target:i}:i,a=Number.isNaN(+r)?r:+r,d=n(a);return T(o).map(f=>({...f,event:d,delay:a}))}).map(r=>{const{delay:i}=r;return{...I(e,r.event,r),delay:i}})}function I(e,t,n){const s=rt(n.target),r=n.reenter??!1,i=ln(e,s),o={...n,actions:T(n.actions),guard:n.guard,target:i,source:e,reenter
1:r,eventType:t,toJSON:()=>({...o,source:`#${e.id}`,target:i?i.map(a=>`#${a.id}`):void 0})};return o}function fn(e){const t=new Map;if(e.config.on)for(const n of Object.keys(e.config.on)){if(n===Ze)throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');const s=e.config.on[n];t.set(n,R(s).map(r=>I(e,n,r)))}if(e.config.onDone){const n=`xstate.done.state.${e.id}`;t.set(n,R(e.config.onDone).map(s=>I(e,n,s)))}for(const n of e.invoke){if(n.onDone){const s=`xstate.done.actor.${n.id}`;t.set(s,R(n.onDone).map(r=>I(e,s,r)))}if(n.onError){const s=`xstate.error.actor.${n.id}`;t.set(s,R(n.onError).map(r=>I(e,s,r)))}if(n.onSnapshot){const s=`xstate.snapshot.${n.id}`;t.set(s,R(n.onSnapshot).map(r=>I(e,s,r)))}}for(const n of e.after){let s=t.get(n.eventType);s||(s=[],t.set(n.eventType,s)),s.push(n)}return t}function hn(e,t){const n=typeof t=="string"?e.states[t]:t?e.states[t.target]:void 0;if(!n&&t)throw new Error(`Initial state node "${t}" not found on parent state node #${e.id}`);const s={source:e,actions:!t||typeof t=="string"?[]:T(t.actions),eventType:null,reenter:!1,target:n?[n]:[],toJSON:()=>({...s,source:`#${e.id}`,target:n?[`#${n.id}`]:[]})};return s}function ln(e,t){if(t!==void 0)return t.map(n=>{if(typeof n!="string")return n;if(te(n))return e.machine.getStateNodeById(n);const s=n[0]===Ve;if(s&&!e.parent)return V(e,n.slice(1));const r=s?e.key+n:n;if(e.parent)try{return V(e.parent,r)}catch(i){throw new Error(`Invalid transition definition for state node '${e.id}':
2${i.message}`)}else throw new Error(`Invalid target: "${n}" is not a valid target from the root node. Did you mean ".${n}"?`)})}function dt(e){const t=rt(e.config.target);return t?{target:t.map(n=>typeof n=="string"?V(e.parent,n):n)}:e.parent.initial}function A(e){return e.type==="history"}function Ue(e){const t=ft(e);for(const n of t)for(const s of B(n,e))t.add(s);return t}function ft(e){const t=new Set;function n(s){if(!t.has(s)){if(t.add(s),s.type==="compound")n(s.initial.target[0]);else if(s.type==="parallel")for(const r of j(s))n(r)}}return n(e),t}function D(e,t){if(te(t))return e.machine.getStateNodeById(t);if(!e.states)throw new Error(`Unable to retrieve child state '${t}' from '${e.id}'; no child states exist.`);const n=e.states[t];if(!n)throw new Error(`Child state '${t}' does not exist on '${e.id}'`);return n}function V(e,t){if(typeof t=="string"&&te(t))try{return e.machine.getStateNodeById(t)}catch{}const n=we(t).slice();let s=e;for(;n.length;){const r=n.shift();if(!r.length)break;s=D(s,r)}return s}function Z(e,t){if(typeof t=="string"){const r=e.states[t];if(!r)throw new Error(`State '${t}' does not exist on '${e.id}'`);return[e,r]}const n=Object.keys(t),s=n.map(r=>D(e,r)).filter(Boolean);return[e.machine.root,e].concat(s,n.reduce((r,i)=>{const o=D(e,i);if(!o)return r;const a=Z(o,t[i]);return r.concat(a)},[]))}function pn(e,t,n,s){const i=D(e,t).next(n,s);return!i||!i.length?e.next(n,s):i}function yn(e,t,n,s){const r=Object.keys(t),i=D(e,r[0]),o=Ae(i,t[r[0]],n,s);return!o||!o.length?e.next(n,s):o}function gn(e,t,n,s){const r=[];for(const i of Object.keys(t)){const o=t[i];if(!o)continue;const a=D(e,i),d=Ae(a,o,n,s);d&&r.push(...d)}return r.length?r:e.next(n,s)}function Ae(e,t,n,s){return typeof t=="string"?pn(e,t,n,s):Object.keys(t).length===1?yn(e,t,n,s):gn(e,t,n,s)}function mn(e){return Object.keys(e.states).map(t=>e.states[t]).filter(t=>t.type==="history")}function E(e,t){let n=e;for(;n.parent&&n.parent!==t;)n=n.parent;return n.parent===t}function vn(e,t){const n=new Set(e),s=new Set(t);for(const r of n)if(s.has(r))return!0;for(const r of s)if(n.has(r))return!0;return!1}function ht(e,t,n){const s=new Set;for(const r of e){let i=!1;const o=new Set;for(const a of s)if(vn(ge([r],t,n),ge([a],t,n)))if(E(r.source,a.source))o.add(a);else{i=!0;break}if(!i){for(const a of o)s.delete(a);s.add(r)}}return Array.from(s)}function _n(e){const[t,...n]=e;for(const s of B(t,void 0))if(n.every(r=>E(r,s)))return s}function $e(e,t){if(!e.target)return[];const n=new Set;for(const s of e.target)if(A(s))if(t[s.id])for(const r of t[s.id])n.add(r);else for(const r of $e(dt(s),t))n.add(r);else n.add(s);return[...n]}function lt(e,t){const n=$e(e,t);if(!n)return;if(!e.reenter&&n.every(r=>r===e.source||E(r,e.source)))return e.source;const s=_n(n.concat(e.source));if(s)return s;if(!e.reenter)return e.source.machine.root}function ge(e,t,n){var r;const s=new Set;for(const i of e)if((r=i.target)!=null&&r.length){const o=lt(i,n);i.reenter&&i.source===o&&s.add(o);for(const a of t)E(a,o)&&s.add(a)}return[...s]}function Sn(e,t){if(e.length!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function me(e,t,n,s,r,i){if(!e.length)return t;const o=new Set(t._nodes);let a=t.historyValue;const d=ht(e,o,a);let f=t;
2r||([f,a]=xn(f,s,n,d,o,a,i,n.actionExecutor)),f=L(f,s,n,d.flatMap(u=>u.actions),i,void 0),f=Tn(f,s,n,d,o,i,a,r);const p=[...o];f.status==="done"&&(f=L(f,s,n,p.sort((u,c)=>c.order-u.order).flatMap(u=>u.exit),i,void 0));try{return a===t.historyValue&&Sn(t._nodes,o)?f:$(f,{_nodes:p,historyValue:a})}catch(u){throw u}}function bn(e,t,n,s,r){if(s.output===void 0)return;const i=le(r.id,r.output!==void 0&&r.parent?pe(r.output,e.context,t,n.self):void 0);return pe(s.output,e.context,i,n.self)}function Tn(e,t,n,s,r,i,o,a){let d=e;const f=new Set,p=new Set;wn(s,o,p,f),a&&p.add(e.machine.root);const u=new Set;for(const c of[...f].sort((l,h)=>l.order-h.order)){r.add(c);const l=[];l.push(...c.entry);for(const h of c.invoke)l.push(ot(h.src,{...h,syncSnapshot:!!h.onSnapshot}));if(p.has(c)){const h=c.initial.actions;l.push(...h)}if(d=L(d,t,n,l,i,c.invoke.map(h=>h.id)),c.type==="final"){const h=c.parent;let y=(h==null?void 0:h.type)==="parallel"?h:h==null?void 0:h.parent,g=y||c;for((h==null?void 0:h.type)==="compound"&&i.push(le(h.id,c.output!==void 0?pe(c.output,d.context,t,n.self):void 0));(y==null?void 0:y.type)==="parallel"&&!u.has(y)&&Ie(r,y);)u.add(y),i.push(le(y.id)),g=y,y=y.parent;if(y)continue;d=$(d,{status:"done",output:bn(d,t,n,d.machine.root,g)})}}return d}function wn(e,t,n,s){for(const r of e){const i=lt(r,t);for(const a of r.target||[])!A(a)&&(r.source!==a||r.source!==i||r.reenter)&&(s.add(a),n.add(a)),O(a,t,n,s);const o=$e(r,t);for(const a of o){const d=B(a,i);(i==null?void 0:i.type)==="parallel"&&d.push(i),pt(s,t,n,d,!r.source.parent&&r.reenter?void 0:i)}}}function O(e,t,n,s){var r;if(A(e))if(t[e.id]){const i=t[e.id];for(const o of i)s.add(o),O(o,t,n,s);for(const o of i)oe(o,e.parent,s,t,n)}else{const i=dt(e);for(const o of i.target)s.add(o),i===((r=e.parent)==null?void 0:r.initial)&&n.add(e.parent),O(o,t,n,s);for(const o of i.target)oe(o,e.parent,s,t,n)}else if(e.type==="compound"){const[i]=e.initial.target;A(i)||(s.add(i),n.add(i)),O(i,t,n,s),oe(i,e,s,t,n)}else if(e.type==="parallel")for(const i of j(e).filter(o=>!A(o)))[...s].some(o=>E(o,i))||(A(i)||(s.add(i),n.add(i)),O(i,t,n,s))}function pt(e,t,n,s,r){for(const i of s)if((!r||E(i,r))&&e.add(i),i.type==="parallel")for(const o of j(i).filter(a=>!A(a)))[...e].some(a=>E(a,o))||(e.add(o),O(o,t,n,e))}function oe(e,t,n,s,r){pt(n,s,r,B(e,t))}function xn(e,t,n,s,r,i,o,a){let d=e;const f=ge(s,r,i);f.sort((u,c)=>c.order-u.order);let p;for(const u of f)for(const c of mn(u)){let l;c.history==="deep"?l=h=>ke(h)&&E(h,u):l=h=>h.parent===u,p??(p={...i}),p[c.id]=Array.from(r).filter(l)}for(const u of f)d=L(d,t,n,[...u.exit,...u.invoke.map(c=>Q(c.id))],o,void 0),r.delete(u);return[d,p||i]}function En(e,t){return e.implementations.actions[t]}function yt(e,t,n,s,r,i){const{machine:o}=e;let a=e;for(const d of s){const f=typeof d=="function",p=f?d:En(o,typeof d=="string"?d:d.type),u={context:a.context,event:t,self:n.self,system:n.system},c=f||typeof d=="string"?void 0:"params"in d?typeof d.params=="function"?d.params({context:a.context,event:t}):d.params:void 0;if(!p||!("resolve"in p)){n.actionExecutor({type:typeof d=="string"?d:typeof d=="object"?d.type:d.name||"(anonymous)",info:u,params:c,exec:p});continue}const l=p,[h,y,g]=l.resolve(n,a,u,c,p,r);a=h,"retryResolve"in l&&(i==null||i.push([l,y])),"execute"in l&&n.actionExecutor({type:l.type,info:u,params:y,exec:l.execute.bind(null,n,y)}),g&&(a=yt(a,t,n,g,r,i))}return a}function L(e,t,n,s,r,i){const o=i?[]:void 0,a=yt(e,t,n,s,{internalQueue:r,deferredActorIds:i},o);return o==null||o.forEach(([d,f])=>{d.retryResolve(n,a,f)}),a}function ae(e,t,n,s){let r=e;const i=[];function o(f,p,u){n.system._sendInspectionEvent({type:"@xstate.microstep",actorRef:n.self,event:p,snapshot:f,_transitions:u}),i.push(f)}if(t.type===G)return r=$(Pe(r,t,n),{status:"stopped"}),o(r,t,[]),{snapshot:r,microstates:i};let a=t;if(a.type!==Ne){const f=a,p=Zt(f),u=Je(f,r);if(p&&!u.length)return r=$(e,{status:"error",error:f.error}),o(r,f,[]),{snapshot:r,microstates:i};r=me(u,e,n,a,!1,s),o(r,f,u)}let d=!0;for(;r.status==="active";){let f=d?kn(r,a):[];const p=f.length?r:void 0;if(!f.length){if(!s.length)break;a=s.shift(),f=Je(a,r)}r=me(f,r,n,a,!1,s),d=r!==p,o(r,a,f)}return r.status!=="active"&&Pe(r,a,n),{snapshot:r,microstates:i}}function Pe(e,t,n){return L(e,t,n,Object.values(e.children).map(s=>Q(s)),[],void 0)}function Je(e,t){return t.machine.getTransitionData(t,e)}function kn(e,t){const n=new Set,s=e._nodes.filter(ke);for(const r of s)e:for(const i of[r].concat(B(r,void 0)))if(i.always){for(const o of i.always)if(o.guard===void 0||ee(o.guard,e.context,t,e)){n.add(o);break e}}return ht(Array.from(n),new Set(e._nodes),e.historyValue)}function In(e,t){const n=Y(Z(e,t));return ut(e,[...n])}function An(e){return!!e&&typeof e=="object"&&"machine"in e&&"value"in e}const $n=function(t){return tt(t,this.value)},Mn=function(t){return this.tags.has(t)},Rn=function(t){const n=this.machine.getTransitionData(this,t);return!!(n!=null&&n.length)&&n.some(s=>s.target!==void 0||s.actions.length)},On=function(){const{_nodes:t,tags:n,machine:s,getMeta:r,toJSON:i,can:o,hasTag:a,matches:d,...f}=this;return{...f,tags:Array.from(n)}},qn=function(){return this._nodes.reduce((t,n)=>(n.meta!==void 0&&(t[n.id]=n.meta),t),{})};function X(e,t){return{status:e.status,output:e.output,error:e.error,machine:t,context:e.context,_nodes:e._nodes,value:ut(t.root,e._nodes),tags:new Set(e._nodes.flatMap(n=>n.tags)),children:e.children,historyValue:e.historyValue||{},matches:$n,hasTag:Mn,can:Rn,getMeta:qn,toJSON:On}}function $(e,t={}){return X({...e,...t},e.machine)}function Cn(e){if(typeof e!="object"||e===null)return{};const t={};for(const n in e){const s=e[n];Array.isArray(s)&&(t[n]=s.map(r=>({id:r.id})))}return t}function jn(e,t){const{_nodes:n,tags:s,machine:r,children:i,context:o,can:a,hasTag:d,matches:f,getMeta:p,toJSON:u,...c}=e,l={};for(const y in i){const g=i[y];l[y]={snapshot:g.getPersistedSnapshot(t),src:g.src,systemId:g._systemId,syncSnapshot:g._syncSnapshot}}return{...c,context:gt(o),children:l,historyValue:Cn(c.historyValue)}}function gt(e){let t;for(const n in e){const s=e[n];if(s&&typeof s=="object")if("sessionId"in s&&"send"in s&&"ref"in s)t??(t=Array.isArray(e)?e.slice():{...e}),t[n]={xstate$$type:Ee,id:s.id};else{const r=gt(s);r!==s&&(t??(t=Array.isArray(e)?e.slice():{...e}),t[n]=r)}}return t??e}function Dn(e,t,n,s,{event:r,id:i,delay:o},{internalQueue:a}){const d=t.machine.implementations.delays;if(typeof r=="string")throw new Error(`Only event objects may be used with raise; use raise({ type: "${r}" }) instead`);const f=typeof r=="function"?r(n,s):r;let p;
2if(typeof o=="string"){const u=d&&d[o];p=typeof u=="function"?u(n,s):u}else p=typeof o=="function"?o(n,s):o;return typeof p!="number"&&a.push(f),[t,{event:f,id:i,delay:p},void 0]}function Ln(e,t){const{event:n,delay:s,id:r}=t;if(typeof s=="number"){e.defer(()=>{const i=e.self;e.system.scheduler.schedule(i,i,n,s,r)});return}}function J(e,t){function n(s,r){}return n.type="xstate.raise",n.event=e,n.id=t==null?void 0:t.id,n.delay=t==null?void 0:t.delay,n.resolve=Dn,n.execute=Ln,n}function Un(e,t){return{config:e,transition:(n,s,r)=>({...n,context:e(n.context,s,r)}),getInitialSnapshot:(n,s)=>({status:"active",output:void 0,error:void 0,context:typeof t=="function"?t({input:s}):t}),getPersistedSnapshot:n=>n,restoreSnapshot:n=>n}}const He="xstate.observable.error",We="xstate.observable.complete";function mt(e){return{config:e,transition:(n,s)=>{if(n.status!=="active")return n;switch(s.type){case He:return{...n,status:"error",error:s.data,input:void 0,_subscription:void 0};case We:return{...n,status:"done",input:void 0,_subscription:void 0};case G:return n._subscription.unsubscribe(),{...n,status:"stopped",input:void 0,_subscription:void 0};default:return n}},getInitialSnapshot:(n,s)=>({status:"active",output:void 0,error:void 0,context:void 0,input:s,_subscription:void 0}),start:(n,{self:s,system:r,emit:i})=>{n.status!=="done"&&(n._subscription=e({input:n.input,system:r,self:s,emit:i}).subscribe({next:o=>{s._parent&&r._relay(s,s._parent,o)},error:o=>{r._relay(s,s,{type:He,data:o})},complete:()=>{r._relay(s,s,{type:We})}}))},getPersistedSnapshot:({_subscription:n,...s})=>s,restoreSnapshot:n=>({...n,_subscription:void 0})}}const Ge="xstate.promise.resolve",Be="xstate.promise.reject",z=new WeakMap;function fs(e){return{config:e,transition:(n,s,r)=>{var i;if(n.status!=="active")return n;switch(s.type){case Ge:{const o=s.data;return{...n,status:"done",output:o,input:void 0}}case Be:return{...n,status:"error",error:s.data,input:void 0};case G:return(i=z.get(r.self))==null||i.abort(),{...n,status:"stopped",input:void 0};default:return n}},start:(n,{self:s,system:r,emit:i})=>{if(n.status!=="active")return;const o=new AbortController;z.set(s,o),Promise.resolve(e({input:n.input,system:r,self:s,signal:o.signal,emit:i})).then(d=>{s.getSnapshot().status==="active"&&(z.delete(s),r._relay(s,s,{type:Ge,data:d}))},d=>{s.getSnapshot().status==="active"&&(z.delete(s),r._relay(s,s,{type:Be,data:d}))})},getInitialSnapshot:(n,s)=>({status:"active",output:void 0,error:void 0,input:s}),getPersistedSnapshot:n=>n,restoreSnapshot:n=>n}}const Pn=Un(e=>{},void 0);function hs(){return C(Pn)}function Jn(e,{machine:t,context:n},s,r){const i=(o,a)=>{if(typeof o=="string"){const d=xe(t,o);if(!d)throw new Error(`Actor logic '${o}' not implemented in machine '${t.id}'`);const f=C(d,{id:a==null?void 0:a.id,parent:e.self,syncSnapshot:a==null?void 0:a.syncSnapshot,input:typeof(a==null?void 0:a.input)=="function"?a.input({context:n,event:s,self:e.self}):a==null?void 0:a.input,src:o,systemId:a==null?void 0:a.systemId});return r[f.id]=f,f}else return C(o,{id:a==null?void 0:a.id,parent:e.self,syncSnapshot:a==null?void 0:a.syncSnapshot,input:a==null?void 0:a.input,src:o,systemId:a==null?void 0:a.systemId})};return(o,a)=>{const d=i(o,a);return r[d.id]=d,e.defer(()=>{d._processingStatus!==_.Stopped&&d.start()}),d}}function Hn(e,t,n,s,{assignment:r}){if(!t.context)throw new Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");const i={},o={context:t.context,event:n.event,spawn:Jn(e,t,n.event,i),self:e.self,system:e.system};let a={};if(typeof r=="function")a=r(o,s);else for(const f of Object.keys(r)){const p=r[f];a[f]=typeof p=="function"?p(o,s):p}const d=Object.assign({},t.context,a);return[$(t,{context:d,children:Object.keys(i).length?{...t.children,...i}:t.children}),void 0,void 0]}function q(e){function t(n,s){}return t.type="xstate.assign",t.assignment=e,t.resolve=Hn,t}const ze=new WeakMap;function M(e,t,n){let s=ze.get(e);return s?t in s||(s[t]=n()):(s={[t]:n()},ze.set(e,s)),s[t]}const Wn={},U=e=>typeof e=="string"?{type:e}:typeof e=="function"?"resolve"in e?{type:e.type}:{type:e.name}:e;class N{constructor(t,n){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=n._parent,this.key=n._key,this.machine=n._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(Ve),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?je(this.config.states,(s,r)=>new N(s,{_parent:this,_key:r,_machine:this.machine})):Wn,this.type==="compound"&&!this.config.initial)throw new Error(`No initial state specified for c
2ompound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);this.history=this.config.history===!0?"shallow":this.config.history||!1,this.entry=T(this.config.entry).slice(),this.exit=T(this.config.exit).slice(),this.meta=this.config.meta,this.output=this.type==="final"||!this.parent?this.config.output:void 0,this.tags=T(t.tags).slice()}_initialize(){this.transitions=fn(this),this.config.always&&(this.always=R(this.config.always).map(t=>I(this,Ze,t))),Object.keys(this.states).forEach(t=>{this.states[t]._initialize()})}get definition(){return{id:this.id,key:this.key,version:this.machine.version,type:this.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(U),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(t=>`#${t.id}`),source:`#${this.id}`,actions:this.initial.actions.map(U),eventType:null})}:void 0,history:this.history,states:je(this.states,t=>t.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(t=>({...t,actions:t.actions.map(U)})),entry:this.entry.map(U),exit:this.exit.map(U),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 M(this,"invoke",()=>T(this.config.invoke).map((t,n)=>{const{src:s,systemId:r}=t,i=t.id??De(this.id,n),o=typeof s=="string"?s:`xstate.invoke.${De(this.id,n)}`;return{...t,src:o,id:i,systemId:r,toJSON(){const{onDone:a,onError:d,...f}=t;return{...f,type:"xstate.invoke",src:o,id:i}}}}))}get on(){return M(this,"on",()=>[...this.transitions].flatMap(([n,s])=>s.map(r=>[n,r])).reduce((n,[s,r])=>(n[s]=n[s]||[],n[s].push(r),n),{}))}get after(){return M(this,"delayedTransitions",()=>dn(this))}get initial(){return M(this,"initial",()=>hn(this,this.config.initial))}next(t,n){const s=n.type,r=[];let i;const o=M(this,`candidates-${s}`,()=>un(this,s));for(const a of o){const{guard:d}=a,f=t.context;let p=!1;try{p=!d||ee(d,f,n,t)}catch(u){const c=typeof d=="string"?d:typeof d=="object"?d.type:void 0;throw new Error(`Unable to evaluate guard ${c?`'${c}' `:""}in transition for event '${s}' in state node '${this.id}':
3${u.message}`)}if(p){r.push(...a.actions),i=a;break}}return i?[i]:void 0}get events(){return M(this,"events",()=>{const{states:t}=this,n=new Set(this.ownEvents);if(t)for(const s of Object.keys(t)){const r=t[s];if(r.states)for(const i of r.events)n.add(`${i}`)}return Array.from(n)})}get ownEvents(){const t=new Set([...this.transitions.keys()].filter(n=>this.transitions.get(n).some(s=>!(!s.target&&!s.actions.length&&!s.reenter))));return Array.from(t)}}const Gn="#";class Me{constructor(t,n){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:(n==null?void 0:n.actors)??{},actions:(n==null?void 0:n.actions)??{},delays:(n==null?void 0:n.delays)??{},guards:(n==null?void 0:n.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 N(t,{_key:this.id,_machine:this}),this.root._initialize(),this.states=this.root.states,this.events=this.root.events}provide(t){const{actions:n,guards:s,actors:r,delays:i}=this.implementations;return new Me(this.config,{actions:{...n,...t.actions},guards:{...s,...t.guards},actors:{...r,...t.actors},delays:{...i,...t.delays}})}resolveState(t){const n=In(this.root,t.value),s=Y(Z(this.root,n));return X({_nodes:[...s],context:t.context||{},children:{},status:Ie(s,this.root)?"done":t.status||"active",output:t.output,error:t.error,historyValue:t.historyValue},this)}transition(t,n,s){return ae(t,n,s,[]).snapshot}microstep(t,n,s){return ae(t,n,s,[]).microstates}getTransitionData(t,n){return Ae(this.root,t.value,t,n)||[]}getPreInitialState(t,n,s){const{context:r}=this.config,i=X({context:typeof r!="function"&&r?r:{},_nodes:[this.root],children:{},status:"active"},this);return typeof r=="function"?L(i,n,t,[q(({spawn:a,event:d,self:f})=>r({spawn:a,input:d.input,self:f}))],s,void 0):i}getInitialSnapshot(t,n){const s=et(n),r=[],i=this.getPreInitialState(t,s,r),o=me([{target:[...ft(this.root)],source:this.root,reenter
3:!0,actions:[],eventType:null,toJSON:null}],i,t,s,!0,r),{snapshot:a}=ae(o,s,t,r);return a}start(t){Object.values(t.children).forEach(n=>{n.getSnapshot().status==="active"&&n.start()})}getStateNodeById(t){const n=we(t),s=n.slice(1),r=te(n[0])?n[0].slice(Gn.length):n[0],i=this.idMap.get(r);if(!i)throw new Error(`Child state node '#${r}' does not exist on machine '${this.id}'`);return V(i,s)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(t,n){return jn(t,n)}restoreSnapshot(t,n){const s={},r=t.children;Object.keys(r).forEach(u=>{const c=r[u],l=c.snapshot,h=c.src,y=typeof h=="string"?xe(this,h):h;if(!y)return;const g=C(y,{id:u,parent:n.self,syncSnapshot:c.syncSnapshot,snapshot:l,src:h,systemId:c.systemId});s[u]=g});function i(u,c){if(c instanceof N)return c;try{return u.machine.getStateNodeById(c.id)}catch{}}function o(u,c){if(!c||typeof c!="object")return{};const l={};for(const h in c){const y=c[h];for(const g of y){const v=i(u,g);v&&(l[h]??(l[h]=[]),l[h].push(v))}}return l}const a=o(this.root,t.historyValue),d=X({...t,children:s,_nodes:Array.from(Y(Z(this.root,t.value))),historyValue:a},this),f=new Set;function p(u,c){if(!f.has(u)){f.add(u);for(const l in u){const h=u[l];if(h&&typeof h=="object"){if("xstate$$type"in h&&h.xstate$$type===Ee){u[l]=c[h.id];continue}p(h,c)}}}}return p(d.context,s),d}}function Bn(e,t,n,s,{event:r}){const i=typeof r=="function"?r(n,s):r;return[t,{event:i},void 0]}function zn(e,{event:t}){e.defer(()=>e.emit(t))}function ve(e){function t(n,s){}return t.type="xstate.emit",t.event=e,t.resolve=Bn,t.execute=zn,t}let _e=function(e){return e.Parent="#_parent",e.Internal="#_internal",e}({});function Kn(e,t,n,s,{to:r,event:i,id:o,delay:a},d){var h;const f=t.machine.implementations.delays;if(typeof i=="string")throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${i}" }) instead`);const p=typeof i=="function"?i(n,s):i;let u;if(typeof a=="string"){const y=f&&f[a];u=typeof y=="function"?y(n,s):y}else u=typeof a=="function"?a(n,s):a;const c=typeof r=="function"?r(n,s):r;let l;if(typeof c=="string"){if(c===_e.Parent?l=e.self._parent:c===_e.Internal?l=e.self:c.startsWith("#_")?l=t.children[c.slice(2)]:l=(h=d.deferredActorIds)!=null&&h.includes(c)?c:t.children[c],!l)throw new Error(`Unable to send event to actor '${c}' from machine '${t.machine.id}'.`)}else l=c||e.self;return[t,{to:l,targetId:typeof c=="string"?c:void 0,event:p,id:o,delay:u},void 0]}function Xn(e,t,n){typeof n.to=="string"&&(n.to=t.children[n.to])}function Fn(e,t){e.defer(()=>{const{to:n,event:s,delay:r,id:i}=t;if(typeof r=="number"){e.system.scheduler.schedule(e.self,n,s,r,i);return}e.system._relay(e.self,n,s.type===Kt?Qe(e.self.id,s.data):s)})}function H(e,t,n){function s(r,i){}return s.type="xstate.sendTo",s.to=e,s.event=t,s.id=n==null?void 0:n.id,s.delay=n==null?void 0:n.delay,s.resolve=Kn,s.retryResolve=Xn,s.execute=Fn,s}function Yn(e,t){return H(_e.Parent,e,t)}function Vn(e,t,n,s,{collect:r}){const i=[],o=function(d){i.push(d)};return o.assign=(...a)=>{i.push(q(...a))},o.cancel=(...a)=>{i.push(it(...a))},o.raise=(...a)=>{i.push(J(...a))},o.sendTo=(...a)=>{i.push(H(...a))},o.sendParent=(...a)=>{i.push(Yn(...a))},o.spawnChild=(...a)=>{i.push(ot(...a))},o.stopChild=(...a)=>{i.push(Q(...a))},o.emit=(...a)=>{i.push(ve(...a))},r({context:n.context,event:n.event,enqueue:o,check:a=>ee(a,t.context,n.event,t),self:e.self,system:e.system},s),[t,void 0,i]}function P(e){function t(n,s){}return t.type="xstate.enqueueActions",t.collect=e,t.resolve=Vn,t}function S(e,t){const n=T(t);if(!n.includes(e.type)){const s=n.length===1?`type "${n[0]}"`:`one of types "${n.join('", "')}"`;throw new Error(`Expected event ${JSON.stringify(e)} to have ${s}`)}}function Zn(e,t){return new Me(e,t)}function vt({schemas:e,actors:t,actions:n,guards:s,delays:r}){return{createMachine:i=>Zn({...i,schemas:e},{actors:t,actions:n,guards:s,delays:r})}}const k=e=>({context:t})=>{const{count:n,include:s,exclude:r,responseType:i="message.received"}=e;return{count:n,domain:t.domain,from:t.connectTo,include:s?Array.isArray(s)?s:[s]:[],exclude:r?Array.isArray(r)?r:[r]:[],responseType:i,target:t.target,to:t.name}},Nn=e=>t=>{const{data:n}=t;
3return(e.include.length?e.include.includes(n.type):!0)&&(e.exclude.length?!e.exclude.includes(n.type):!0)&&n.domain===e.domain&&n.from===e.from&&n.to===e.to&&(!e.target||t.source===e.target)},Qn=e=>t=>({type:e,message:t}),es=kt(()=>W(window,"message")),ts=e=>mt(({input:t})=>es.pipe(e?he(e):se(),Fe(Nn(t)),he(Qn(t.responseType)),t.count?se(qt(t.count),Ct(n=>n),Te(t.count)):se())),ns="sanity/comlink",ss=3e3,rs=1e4,F="comlink/response",ce="comlink/heartbeat",K="comlink/disconnect",ue="comlink/handshake/syn",is="comlink/handshake/syn-ack",de="comlink/handshake/ack",os=e=>t=>t.pipe(Te(1),he(()=>{throw new Error(e)})),as=()=>vt({actors:{listen:mt(({input:e})=>{const t=e.signal?W(e.signal,"abort").pipe(os(`Request ${e.requestId} aborted`)):Xe,n=s=>{var r,i;return((r=s.data)==null?void 0:r.type)===F&&((i=s.data)==null?void 0:i.responseTo)===e.requestId&&!!s.source&&e.sources.has(s.source)};return W(window,"message").pipe(Fe(n),Te(e.sources.size),jt(t))})},actions:{"send message":({context:e},t)=>{const{sources:n,targetOrigin:s}=e,{message:r}=t;
3n.forEach(i=>{i.postMessage(r,{targetOrigin:s})})},"on success":H(({context:e})=>e.parentRef,({context:e,self:t})=>{var n;return e.response&&((n=e.resolvable)==null||n.resolve(e.response)),{type:"request.success",requestId:t.id,response:e.response,responseTo:e.responseTo}}),"on fail":H(({context:e})=>e.parentRef,({context:e,self:t})=>{var n;return e.suppressWarnings||console.warn(`[@sanity/comlink] Received no response to message '${e.type}' on client '${e.from}' (ID: '${e.id}').`),(n=e.resolvable)==null||n.reject(new Error("No response received")),{type:"request.failed",requestId:t.id}}),"on abort":H(({context:e})=>e.parentRef,({context:e,self:t})=>{var n;return(n=e.resolvable)==null||n.reject(new Error("Request aborted")),{type:"request.aborted",requestId:t.id}})},guards:{expectsResponse:({context:e})=>e.expectResponse},delays:{initialTimeout:0,responseTimeout:({context:e})=>e.responseTimeout??ss}}).createMachine({context:({input:e})=>({channelId:e.channelId,data:e.data,domain:e.domain,expectResponse:e.expectResponse??!1,from:e.from,id:`msg-${Ye()}`,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})=>{const{channelId:t,data:n,domain:s,from:r,id:i,responseTo:o,to:a,type:d}=e;return{message:{channelId:t,data:n,domain:s,from:r,id:i,to:a,type:d,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:q({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})});function cs(){if(typeof Promise.withResolvers=="function")return Promise.withResolvers();let e,t;return{promise:new Promise((n,s)=>{e=n,t=s}),resolve:e,reject:t}}const us=()=>vt({actors:{requestMachine:as(),listen:ts()},actions:{"buffer handshake":q({handshakeBuffer:({event:e,context:t})=>(S(e,"message.received"),[...t.handshakeBuffer,e])}),"buffer message":P(({enqueue:e})=>{e.assign({buffer:({event:t,context:n})=>(S(t,"post"),[...n.buffer,{data:t.data,resolvable:t.resolvable,options:t.options}])}),e.emit(({event:t})=>(S(t,"post"),{type:"buffer.added",message:t.data}))}),"create request":q({requests:({context:e,event:t,self:n,spawn:s})=>{S(t,"request");const r=(Array.isArray(t.data)?t.data:[t.data]).map(i=>{var a,d,f;const o=`req-${Ye()}`;return s("requestMachine",{id:o,input:{channelId:e.channelId,data:i.data,domain:e.domain,expectResponse:i.expectResponse,from:e.name,parentRef:n,resolvable:i.resolvable,responseTimeout:(a=i.options)==null?void 0:a.responseTimeout,responseTo:i.responseTo,signal:(d=i.options)==null?void 0:d.signal,sources:e.target,suppressWarnings:(f=i.options)==null?void 0:f.suppressWarnings,targetOrigin:e.targetOrigin,to:e.connectTo,type:i.type}})});return[...e.requests,...r]}}),"emit heartbeat":ve(()=>({type:"heartbeat"})),"emit received message":P(({enqueue:e})=>{e.emit(({event:t})=>(S(t,"message.received"),{type:"message",message:t.message.data}))}),"emit status":ve((e,t)=>({type:"status",status:t.status})),"post message":J(({event:e})=>(S(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":P(({context:e,enqueue:t})=>{e.handshakeBuffer.forEach(n=>t.raise(n)),t.assign({handshakeBuffer:[]})}),"remove request":P(({context:e,enqueue:t,event:n})=>{S(n,["request.success","request.failed","request.aborted"]),Q(n.requestId),t.assign({requests:e.requests.filter(({id:s})=>s!==n.requestId)})}),"send response":J(({event:e})=>(S(e,["message.received","heartbeat.received"]),{type:"request",data:{type:F,responseTo:e.message.data.id,data:void 0}})),"send handshake syn ack":J({type:"request",data:{type:is}}),"send pending messages":P(({enqueue:e})=>{e.raise(({context:t})=>({type:"request",data:t.buffer.map(({data:n,resolvable:s,options:r})=>
3({data:n.data,type:n.type,expectResponse:!!s,resolvable:s,options:r}))})),e.emit(({context:t})=>({type:"buffer.flushed",messages:t.buffer.map(({data:n})=>n)})),e.assign({buffer:[]})}),"set connection config":q({channelId:({event:e})=>(S(e,"handshake.syn"),e.message.data.channelId),target:({event:e})=>(S(e,"handshake.syn"),e.message.source||void 0),targetOrigin:({event:e})=>(S(e,"handshake.syn"),e.message.origin)})},guards:{hasSource:({context:e})=>e.target!==null}}).createMachine({id:"node",context:({input:e})=>({buffer:[],channelId:null,connectTo:e.connectTo,domain:e.domain??ns,handshakeBuffer:[],name:e.name,requests:[],target:void 0,targetOrigin:null}),invoke:{id:"listen for handshake syn",src:"listen",input:k({include:ue,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:k({include:de,count:1,responseType:"handshake.complete"}),onDone:"connected"},{id:"listen for disconnect",src:"listen",input:k({include:K,count:1,responseType:"disconnect"})},{id:"listen for messages",src:"listen",input:k({exclude:[K,ue,de,ce,F]})}],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:k({exclude:[K,ue,de,ce,F]})},{id:"listen for heartbeat",src:"listen",input:k({include:ce,responseType:"heartbeat.received"})},{id:"listen for disconnect",src:"listen",input:k({include:K,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"]}}}}}),ls=(e,t=us())=>{const n=C(t,{input:e}),s=new Map,r=new Map,i=(u,c,l)=>{const h=s.get(u)||new Set;s.has(u)||s.set(u,h),h.add(c);const y=r.get(u);if(y){const g=(l==null?void 0:l.replay)??1;Array.from(y).slice(-g).forEach(({data:v})=>c(v)),r.delete(u)}return()=>{h.delete(c)}};let o;const a=(u,c)=>{const{unsubscribe:l}=n.on("status",h=>{o=h.status,!(c&&h.status!==c)&&u(h.status)});return o&&u(o),l},d=(u,c)=>{const l={type:u,data:c};n.send({type:"post",data:l})},f=(u,c,l)=>{const{responseTimeout:h=rs,signal:y,suppressWarnings:g}=l||{},v=cs(),w={type:u,data:c};return n.send({type:"post",data:w,resolvable:v,options:{responseTimeout:h,signal:y,suppressWarnings:g}}),v.promise};n.on("message",({message:u})=>{const c=s.get(u.type);
3if(c){c.forEach(h=>h(u.data));return}const l=r.get(u.type);l?l.add(u):r.set(u.type,new Set([u]))});const p=()=>{n.stop()};return{actor:n,fetch:f,machine:t,on:i,onStatus:a,post:d,start:()=>(n.start(),p),stop:p}};export{ns as D,K as M,ts as a,ce as b,as as c,F as d,de as e,is as f,ue as g,ls as h,us as i,hs as j,Yn as k,P as l,q as m,S as n,Q as o,ot as p,fs as q,J as r,vt as s,mt as t,ve as u,C as v};

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.