@joy-ride/game 0.26.1 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/THIRD_PARTY_NOTICES.md +35 -0
- package/bookmarklet.d.ts +1 -1
- package/bookmarklet.js +1 -1
- package/embed-assets/boost-2QB6phrp.opus +0 -0
- package/embed-assets/chevrolet-corvette-c8-z06-top-DTz9k7Fu.webp +0 -0
- package/embed-assets/collision-r7KCgXfr.opus +0 -0
- package/embed-assets/crush-CN-lxC7x.opus +0 -0
- package/embed-assets/explosion-DyvbNXFI.opus +0 -0
- package/embed-assets/ferrari-812-superfast-top-C3DkIkN7.webp +0 -0
- package/embed-assets/fire-BYgTEP5X.opus +0 -0
- package/embed-assets/gunfire-DUWyQGGm.opus +0 -0
- package/embed-assets/mazda-mx5-nd-top-CLqHp7ox.webp +0 -0
- package/embed-assets/mazda-rx7-fd-top-C3bZMAQw.webp +0 -0
- package/embed-assets/mclaren-720s-top-8TdR01SB.webp +0 -0
- package/embed-assets/nissan-gtr-r35-top-DSpGgr3L.webp +0 -0
- package/embed-assets/ram-2500-top-B653eJDL.webp +0 -0
- package/embed-assets/ricochet-BTW-Iqeu.opus +0 -0
- package/embed-assets/tires-B_97_Y5P.opus +0 -0
- package/embed-assets/toyota-gr-corolla-top-B0NnJP3L.webp +0 -0
- package/embed-assets/toyota-supra-a80-top-BjqFr9TR.webp +0 -0
- package/embed-chunks/{CodeBlock-Dn8EZ_BP.js → CodeBlock-CpSBaaOX.js} +1 -1
- package/embed-chunks/{Documentation-FnghYLFE.js → Documentation-8cbCUZ0p.js} +2 -2
- package/embed-chunks/{EmbedPanel-DZGEiiy9.js → EmbedPanel-DCPAjVqp.js} +1 -1
- package/embed-chunks/JoyRideView-CgMxrhvT.js +1 -0
- package/embed-chunks/{configuration~index~embed-0luxl74s.js → configuration~index~embed-ynFxJP_I.js} +1 -1
- package/embed-chunks/configuration~index~embed~bookmarklet-BGiS_NuJ.js +1 -0
- package/embed-chunks/{controls~index~embed-B_C92tUz.js → controls~index~embed-CFqR-DAK.js} +1 -1
- package/embed-chunks/{definitions~index~embed-CDMM_m1T.js → definitions~index~embed-CnmHo4Z4.js} +1 -1
- package/embed-chunks/definitions~index~embed~bookmarklet-CfH2mYuH.js +1 -0
- package/embed-chunks/definitions~index~embed~bookmarklet~vehicle-popover~Documentation~JoyRideView~browser-sessi~fklztn3g-BG7sJuWo.js +1 -0
- package/embed-chunks/{runtime~JoyRideView~browser-session-core-D3nCbCee.js → runtime~JoyRideView~browser-session-core-D5ZWMVDY.js} +1 -1
- package/embed-chunks/runtime~browser-session-core-CDPI_Sw8.js +1 -0
- package/embed-chunks/runtime~index~embed-BdtYsSkV.js +210 -0
- package/embed-chunks/{runtime~index~embed~vehicle-popover~browser-session-core~renderer-YuWj6rHi.js → runtime~index~embed~vehicle-popover~browser-session-core~renderer-ZRVlax1L.js} +1 -1
- package/embed-chunks/{runtime~vehicle-popover-vmgt62ll.js → runtime~vehicle-popover-DRMddEZO.js} +1 -1
- package/embed-chunks/runtime~vehicle-popover~browser-session-core-0GDQdij8.js +1 -0
- package/embed-chunks/runtime~vehicle-popover~browser-session-core~renderer-Cf4rBrLo.js +4 -0
- package/embed-chunks/runtime~vehicle-popover~renderer-JCHjG7Oa.js +849 -0
- package/embed-chunks/src-BJ7McU4o.js +2 -0
- package/embed-chunks/vehicle-catalog~index~embed-DVqfWMzi.js +1 -0
- package/embed-chunks/vehicle-popover-zFwrdc1h.js +1 -0
- package/embed.js +1 -1
- package/{index-BeKl7UbC.d.ts → index-epZszWQ8.d.ts} +8 -109
- package/index.d.ts +2 -2
- package/index.js +1 -1
- package/npm-chunks/{Documentation-_R0nI0HT.js → Documentation-Cc_tsq8d.js} +2 -2
- package/npm-chunks/{EmbedPanel-lzZkV-zO.js → EmbedPanel-ByMHNOc2.js} +1 -1
- package/npm-chunks/JoyRideView-DHvlq6T7.js +1 -0
- package/npm-chunks/{configuration~react-CgNlw0cC.js → configuration~react-CPx5MlF4.js} +1 -1
- package/npm-chunks/{configuration~react~browser-session-core-CyXr42pk.js → configuration~react~browser-session-core-Ca4_fO4n.js} +1 -1
- package/npm-chunks/configuration~react~vehicle-popover~JoyRideView~browser-session-core~renderer-CPZkP_Db.js +1 -0
- package/npm-chunks/{controls~react~vehicle-popover~Documentation~JoyRideView~browser-session-core-CLDwfJ48.js → controls~react~vehicle-popover~Documentation~JoyRideView~browser-session-core-CoAcght5.js} +1 -1
- package/npm-chunks/{definitions~react~browser-session-core-acRq5AYt.js → definitions~react~browser-session-core-Bc5BhqaX.js} +1 -1
- package/npm-chunks/definitions~react~vehicle-popover~Documentation~JoyRideView~browser-session-core-DcDccU8O.js +1 -0
- package/npm-chunks/definitions~react~vehicle-popover~Documentation~JoyRideView~browser-session-core~renderer-BG7sJuWo.js +1 -0
- package/npm-chunks/{runtime~JoyRideView~browser-session-core-BkwDrc9q.js → runtime~JoyRideView~browser-session-core-DkTKYWMV.js} +1 -1
- package/npm-chunks/runtime~browser-session-core-CuS-sVVB.js +1 -0
- package/npm-chunks/{runtime~react-CoMJOwyg.js → runtime~react-DQ3peDbc.js} +1 -1
- package/npm-chunks/{runtime~react~browser-session-core-35T1PZHO.js → runtime~react~browser-session-core-B9a1rLNB.js} +1 -1
- package/npm-chunks/runtime~react~vehicle-popover~browser-session-core-CLFQjhrw.js +210 -0
- package/npm-chunks/{runtime~react~vehicle-popover~browser-session-core~renderer-Be8cIaU4.js → runtime~react~vehicle-popover~browser-session-core~renderer-Dmgs7E8f.js} +1 -1
- package/npm-chunks/{runtime~vehicle-popover-PLJOXbUU.js → runtime~vehicle-popover-VyqXHkfB.js} +1 -1
- package/npm-chunks/runtime~vehicle-popover~browser-session-core-DCZajgun.js +1 -0
- package/npm-chunks/runtime~vehicle-popover~browser-session-core~renderer-EswVyRVp.js +4 -0
- package/npm-chunks/runtime~vehicle-popover~renderer-4RpQDOHk.js +849 -0
- package/npm-chunks/theme-CjrpDpKE.js +2 -0
- package/npm-chunks/vehicle-catalog~react~browser-session-core-D5_CJzRM.js +1 -0
- package/npm-chunks/vehicle-catalog~react~vehicle-popover~browser-session-core-sqHgtPeO.js +1 -0
- package/npm-chunks/vehicle-popover-PaJpv-M-.js +1 -0
- package/package.json +1 -1
- package/{playground-e0rOBXY5.d.ts → playground-BcoLBJrj.d.ts} +12 -70
- package/react.d.ts +2 -2
- package/react.js +2 -2
- package/embed-assets/attractor-B0xCt_Fj.mp3 +0 -0
- package/embed-assets/boost-BLJDRtPH.mp3 +0 -0
- package/embed-assets/bullet-ricochet-1-BKWD_WRI.mp3 +0 -0
- package/embed-assets/bullet-ricochet-2-CmbSTqg5.mp3 +0 -0
- package/embed-assets/bullet-ricochet-3-DV3Th6nn.mp3 +0 -0
- package/embed-assets/burning-fire--0zItqR0.mp3 +0 -0
- package/embed-assets/collision-hard-b_eauD-v.mp3 +0 -0
- package/embed-assets/collision-medium-Bhw86k_p.mp3 +0 -0
- package/embed-assets/collision-soft-DIwEkPCV.mp3 +0 -0
- package/embed-assets/collision-soft-fVT-mQmJ.mp3 +0 -0
- package/embed-assets/combustible-explosion-XvpDzpm9.mp3 +0 -0
- package/embed-assets/crush-BZKARh2Y.mp3 +0 -0
- package/embed-assets/electric-bolt-Cg9Fmi6S.mp3 +0 -0
- package/embed-assets/electric-charge-zw1IjLo4.mp3 +0 -0
- package/embed-assets/electric-gt-top-DTcvEjMR.webp +0 -0
- package/embed-assets/flamethrower-B5pUrS5p.mp3 +0 -0
- package/embed-assets/ghost-mode-B33_bxYX.mp3 +0 -0
- package/embed-assets/machine-gun-C4ag4X6T.mp3 +0 -0
- package/embed-assets/rocket-explosion-DKnN7_wY.mp3 +0 -0
- package/embed-assets/rocket-launch-C-Yvbb7P.mp3 +0 -0
- package/embed-assets/tire-screech-DEsAg1CH.mp3 +0 -0
- package/embed-chunks/JoyRideView-EDSeeY9m.js +0 -1
- package/embed-chunks/configuration~index~embed~bookmarklet-BH7GyoGh.js +0 -1
- package/embed-chunks/definitions~index~embed~bookmarklet-BfjknPZN.js +0 -1
- package/embed-chunks/definitions~index~embed~bookmarklet~vehicle-popover~Documentation~JoyRideView~browser-sessi~fklztn3g-Dt96jol6.js +0 -1
- package/embed-chunks/runtime~browser-session-core-CXDCVDsi.js +0 -1
- package/embed-chunks/runtime~index~embed-BVbNVFHj.js +0 -210
- package/embed-chunks/runtime~vehicle-popover~browser-session-core-CjXpkmYi.js +0 -1
- package/embed-chunks/runtime~vehicle-popover~browser-session-core~renderer-CLLM7CAb.js +0 -4
- package/embed-chunks/runtime~vehicle-popover~renderer-Cx3wjyMH.js +0 -1077
- package/embed-chunks/src-BBr94UQ7.js +0 -2
- package/embed-chunks/vehicle-catalog~index~embed-CZzI6C0M.js +0 -1
- package/embed-chunks/vehicle-popover-DxuDMFyq.js +0 -1
- package/npm-chunks/JoyRideView-fHWzVVNB.js +0 -1
- package/npm-chunks/configuration~react~vehicle-popover~JoyRideView~browser-session-core~renderer-B70Mpi9X.js +0 -1
- package/npm-chunks/definitions~react~vehicle-popover~Documentation~JoyRideView~browser-session-core-BZJqthWX.js +0 -1
- package/npm-chunks/definitions~react~vehicle-popover~Documentation~JoyRideView~browser-session-core~renderer-Dt96jol6.js +0 -1
- package/npm-chunks/runtime~browser-session-core-Y1rfFp6D.js +0 -1
- package/npm-chunks/runtime~react~vehicle-popover~browser-session-core-BzXBN4rK.js +0 -210
- package/npm-chunks/runtime~vehicle-popover~browser-session-core-Ce3U7qky.js +0 -1
- package/npm-chunks/runtime~vehicle-popover~browser-session-core~renderer-jVG7K050.js +0 -4
- package/npm-chunks/runtime~vehicle-popover~renderer-Dmf1M43y.js +0 -1077
- package/npm-chunks/theme-C4ZE2-nQ.js +0 -2
- package/npm-chunks/vehicle-catalog~react~browser-session-core-BzB5J-Lm.js +0 -1
- package/npm-chunks/vehicle-catalog~react~vehicle-popover~browser-session-core-CX066OIY.js +0 -1
- package/npm-chunks/vehicle-popover-Deuulng7.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e,r as t}from"./definitions~index~embed~bookmarklet~vehicle-popover~Documentation~JoyRideView~browser-sessi~fklztn3g-Dt96jol6.js";import{S as n,b as r,x as i}from"./definitions~index~embed~bookmarklet-BfjknPZN.js";import{r as a}from"./definitions~index~embed~vehicle-popover~browser-session-core~renderer-RDNEXk_b.js";import{a as o,b as s,c,i as l,l as u,n as d,o as f,s as p,u as m}from"./runtime~index~embed~vehicle-popover~browser-session-core~renderer-YuWj6rHi.js";import{i as h,o as g,r as _}from"./configuration~index~embed~bookmarklet-BH7GyoGh.js";import{n as v,r as y}from"./vehicle-catalog~index~embed-CZzI6C0M.js";import{D as b,E as x,O as ee,T as S,d as te,o as ne,s as re}from"./runtime~vehicle-popover~browser-session-core~renderer-CLLM7CAb.js";function ie(){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 ae(){let e=ie();if(e.__xstate__)return e.__xstate__}var oe=e=>{if(typeof window>`u`)return;let t=ae();t&&t.register(e)},se=class{constructor(e){this._process=e,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(e){let t={value:e,next:null};this._current?(this._last.next=t,this._last=t):(this._current=t,this._last=t,this._active&&this.flush())}flush(){for(;this._current;){let e=this._current;this._process(e.value),this._current=e.next}this._last=null}},ce=``,le=`#`,ue=`*`,de=`xstate.init`,fe=`xstate.stop`;function pe(e,t){return{type:`xstate.after.${e}.${t}`}}function me(e,t){return{type:`xstate.done.state.${e}`,output:t}}function he(e,t){return{type:`xstate.done.actor.${e}`,output:t,actorId:e}}function ge(e,t){return{type:`xstate.error.actor.${e}`,error:t,actorId:e}}function _e(e){return{type:de,input:e}}function C(e){setTimeout(()=>{throw e})}var ve=typeof Symbol==`function`&&Symbol.observable||`@@observable`;function ye(e,t){let n=xe(e),r=xe(t);return typeof r==`string`?typeof n==`string`&&r===n:typeof n==`string`?n in r:Object.keys(n).every(e=>e in r&&ye(n[e],r[e]))}function be(e){if(Ee(e))return e;let t=[],n=``;for(let r=0;r<e.length;r++){switch(e.charCodeAt(r)){case 92:n+=e[r+1],r++;continue;case 46:t.push(n),n=``;continue}n+=e[r]}return t.push(n),t}function xe(e){return Nt(e)?e.value:typeof e==`string`?Se(be(e)):e}function Se(e){if(e.length===1)return e[0];let t={},n=t;for(let t=0;t<e.length-1;t++)if(t===e.length-2)n[e[t]]=e[t+1];else{let r=n;n={},r[e[t]]=n}return t}function Ce(e,t){let n={},r=Object.keys(e);for(let i=0;i<r.length;i++){let a=r[i];n[a]=t(e[a],a,e,i)}return n}function we(e){return Ee(e)?e:[e]}function w(e){return e===void 0?[]:we(e)}function Te(e,t,n,r){return typeof e==`function`?e({context:t,event:n,self:r}):e}function Ee(e){return Array.isArray(e)}function De(e){return e.type.startsWith(`xstate.error.actor`)}function T(e){return we(e).map(e=>e===void 0||typeof e==`string`?{target:e}:e)}function Oe(e){if(e!==void 0&&e!==ce)return w(e)}function E(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}function ke(e,t){return`${t}.${e}`}function D(e,t){let n=t.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!n)return e.implementations.actors[t];let[,r,i]=n,a=e.getStateNodeById(i).config.invoke;return(Array.isArray(a)?a[r]:a).src}function Ae(e,t){if(t===e||t===ue)return!0;if(!t.endsWith(`.*`))return!1;let n=t.split(`.`),r=e.split(`.`);for(let e=0;e<n.length;e++){let t=n[e],i=r[e];if(t===`*`)return e===n.length-1;if(t!==i)return!1}return!0}function je(e,t){return`${e.sessionId}.${t}`}var Me=0;function Ne(e,t){let n=new Map,r=new Map,i=new WeakMap,a=new Set,o={},{clock:s,logger:c}=t,l={schedule:(e,t,n,r,i=Math.random().toString(36).slice(2))=>{let a={source:e,target:t,event:n,delay:r,id:i,startedAt:Date.now()},c=je(e,i);u._snapshot._scheduledEvents[c]=a;let l=s.setTimeout(()=>{delete o[c],delete u._snapshot._scheduledEvents[c],u._relay(e,t,n)},r);o[c]=l},cancel:(e,t)=>{let n=je(e,t),r=o[n];delete o[n],delete u._snapshot._scheduledEvents[n],r!==void 0&&s.clearTimeout(r)},cancelAll:e=>{for(let t in u._snapshot._scheduledEvents){let n=u._snapshot._scheduledEvents[t];n.source===e&&l.cancel(e,n.id)}}},u={_snapshot:{_scheduledEvents:(t?.snapshot&&t.snapshot.scheduler)??{}},_bookId:()=>`x:${Me++}`,_register:(e,t)=>(n.set(e,t),e),_unregister:e=>{n.delete(e.sessionId);let t=i.get(e);t!==void 0&&(r.delete(t),i.delete(e))},get:e=>r.get(e),getAll:()=>Object.fromEntries(r.entries()),_set:(e,t)=>{let n=r.get(e);if(n&&n!==t)throw Error(`Actor with system ID '${e}' already exists.`);r.set(e,t),i.set(t,e)},inspect:e=>{let t=E(e);return a.add(t),{unsubscribe(){a.delete(t)}}},_sendInspectionEvent:t=>{if(!a.size)return;let n={...t,rootId:e.sessionId};a.forEach(e=>e.next?.(n))},_relay:(e,t,n)=>{u._sendInspectionEvent({type:`@xstate.event`,sourceRef:e,actorRef:t,event:n}),t._send(n)},scheduler:l,getSnapshot:()=>({_scheduledEvents:{...u._snapshot._scheduledEvents}}),start:()=>{let e=u._snapshot._scheduledEvents;u._snapshot._scheduledEvents={};for(let t in e){let{source:n,target:r,event:i,delay:a,id:o}=e[t];l.schedule(n,r,i,a,o)}},_clock:s,_logger:c};return u}var O=!1,k=function(e){return e[e.NotStarted=0]=`NotStarted`,e[e.Running=1]=`Running`,e[e.Stopped=2]=`Stopped`,e}({}),Pe={clock:{setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},logger:console.log.bind(console),devTools:!1},Fe=class{constructor(e,t){this.logic=e,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new se(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=k.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=[];let n={...Pe,...t},{clock:r,logger:i,parent:a,syncSnapshot:o,id:s,systemId:c,inspect:l}=n;this.system=a?a.system:Ne(this,{clock:r,logger:i}),l&&!a&&this.system.inspect(E(l)),this.sessionId=this.system._bookId(),this.id=s??this.sessionId,this.logger=t?.logger??this.system._logger,this.clock=t?.clock??this.system._clock,this._parent=a,this._syncSnapshot=o,this.options=n,this.src=n.src??e,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:e=>{this._deferred.push(e)},system:this.system,stopChild:e=>{if(e._parent!==this)throw Error(`Cannot stop child actor ${e.id} of ${this.id} because it is not a child`);e._stop()},emit:e=>{let t=this.eventListeners.get(e.type),n=this.eventListeners.get(`*`);if(!t&&!n)return;let r=[...t?t.values():[],...n?n.values():[]];for(let t of r)try{t(e)}catch(e){C(e)}},actionExecutor:e=>{let t=()=>{if(this._actorScope.system._sendInspectionEvent({type:`@xstate.action`,actorRef:this,action:{type:e.type,params:e.params}}),!e.exec)return;let t=O;try{O=!0,e.exec(e.info,e.params)}finally{O=t}};this._processingStatus===k.Running?t():this._deferred.push(t)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:`@xstate.actor`,actorRef:this}),c&&(this.systemId=c,this.system._set(c,this)),this._initState(t?.snapshot??t?.state),c&&this._snapshot.status!==`active`&&this.system._unregister(this)}_initState(e){try{this._snapshot=e?this.logic.restoreSnapshot?this.logic.restoreSnapshot(e,this._actorScope):e:this.logic.getInitialSnapshot(this._actorScope,this.options?.input)}catch(e){this._snapshot={status:`error`,output:void 0,error:e}}}update(e,t){this._snapshot=e;let n;for(;n=this._deferred.shift();)try{n()}catch(t){this._deferred.length=0,this._snapshot={...e,status:`error`,error:t}}switch(this._snapshot.status){case`active`:for(let t of this.observers)try{t.next?.(e)}catch(e){C(e)}break;case`done`:for(let t of this.observers)try{t.next?.(e)}catch(e){C(e)}this._stopProcedure(),this._complete(),this._doneEvent=he(this.id,this._snapshot.output),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case`error`:this._error(this._snapshot.error)}this.system._sendInspectionEvent({type:`@xstate.snapshot`,actorRef:this,event:t,snapshot:e})}subscribe(e,t,n){let r=E(e,t,n);if(this._processingStatus!==k.Stopped)this.observers.add(r);else switch(this._snapshot.status){case`done`:try{r.complete?.()}catch(e){C(e)}break;case`error`:{let e=this._snapshot.error;if(!r.error)C(e);else try{r.error(e)}catch(e){C(e)}break}}return{unsubscribe:()=>{this.observers.delete(r)}}}on(e,t){let n=this.eventListeners.get(e);n||(n=new Set,this.eventListeners.set(e,n));let r=t.bind(void 0);return n.add(r),{unsubscribe:()=>{n.delete(r)}}}select(e,t=Object.is){return{subscribe:n=>{let r=E(n),i=e(this.getSnapshot());return this.subscribe(n=>{let a=e(n);t(i,a)||(i=a,r.next?.(a))})},get:()=>e(this.getSnapshot())}}start(){if(this._processingStatus===k.Running)return this;this._syncSnapshot&&this.subscribe({next:e=>{e.status===`active`&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:e})},error:()=>{}}),this.system._register(this.sessionId,this),this.systemId&&this.system._set(this.systemId,this),this._processingStatus=k.Running;let e=_e(this.options.input);switch(this.system._sendInspectionEvent({type:`@xstate.event`,sourceRef:this._parent,actorRef:this,event:e}),this._snapshot.status){case`done`:return this.update(this._snapshot,e),this;case`error`:return this._error(this._snapshot.error),this}if(this._parent||this.system.start(),this.logic.start)try{this.logic.start(this._snapshot,this._actorScope)}catch(e){return this._snapshot={...this._snapshot,status:`error`,error:e},this._error(e),this}return this.update(this._snapshot,e),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(e){let t,n;try{t=this.logic.transition(this._snapshot,e,this._actorScope)}catch(e){n={err:e}}if(n){let{err:e}=n;this._snapshot={...this._snapshot,status:`error`,error:e},this._error(e)}else this.update(t,e),e.type===`xstate.stop`&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===k.Stopped?this:(this.mailbox.clear(),this._processingStatus===k.NotStarted?(this._processingStatus=k.Stopped,this):(this.mailbox.enqueue({type:fe}),this))}stop(){if(this._parent)throw Error(`A non-root actor cannot be stopped directly.`);return this._stop()}_complete(){for(let e of this.observers)try{e.complete?.()}catch(e){C(e)}this.observers.clear(),this.eventListeners.clear()}_reportError(e){if(!this.observers.size){this._parent||C(e),this.eventListeners.clear();return}let t=!1;for(let n of this.observers){let r=n.error;t||=!r;try{r?.(e)}catch(e){C(e)}}this.observers.clear(),this.eventListeners.clear(),t&&C(e)}_error(e){this._stopProcedure(),this._reportError(e),this._parent&&this.system._relay(this,this._parent,ge(this.id,e))}_stopProcedure(){return this._processingStatus===k.Running&&(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new se(this._process.bind(this)),this._processingStatus=k.Stopped,this.system._unregister(this)),this}_send(e){this._processingStatus!==k.Stopped&&this.mailbox.enqueue(e)}send(e){this.system._relay(void 0,this,e)}attachDevTools(){let{devTools:e}=this.options;e&&(typeof e==`function`?e:oe)(this)}toJSON(){return{xstate$$type:1,id:this.id}}getPersistedSnapshot(e){return this.logic.getPersistedSnapshot(this._snapshot,e)}[ve](){return this}getSnapshot(){return this._snapshot}};function A(e,...[t]){return new Fe(e,t)}function Ie(e,t,n,r,{sendId:i}){return[t,{sendId:typeof i==`function`?i(n,r):i},void 0]}function Le(e,t){e.defer(()=>{e.system.scheduler.cancel(e.self,t.sendId)})}function Re(e){function t(e,t){}return t.type=`xstate.cancel`,t.sendId=e,t.resolve=Ie,t.execute=Le,t}function ze(e,t,n,r,{id:i,systemId:a,src:o,input:s,syncSnapshot:c}){let l=typeof o==`string`?D(t.machine,o):o,u=typeof i==`function`?i(n):i,d,f;return l&&(f=typeof s==`function`?s({context:t.context,event:n.event,self:e.self}):s,d=A(l,{id:u,src:o,parent:e.self,syncSnapshot:c,systemId:a,input:f})),[q(t,{children:{...t.children,[u]:d}}),{id:i,systemId:a,actorRef:d,src:o,input:f},void 0]}function Be(e,{actorRef:t}){t&&e.defer(()=>{t._processingStatus!==k.Stopped&&t.start()})}function Ve(...[e,{id:t,systemId:n,input:r,syncSnapshot:i=!1}={}]){function a(e,t){}return a.type=`xstate.spawnChild`,a.id=t,a.systemId=n,a.src=e,a.input=r,a.syncSnapshot=i,a.resolve=ze,a.execute=Be,a}function He(e,t,n,r,{actorRef:i}){let a=typeof i==`function`?i(n,r):i,o=typeof a==`string`?t.children[a]:a,s=t.children;return o&&(s={...s},delete s[o.id]),[q(t,{children:s}),o,void 0]}function Ue(e,t){let n=t.getSnapshot();if(n&&`children`in n)for(let t of Object.values(n.children))Ue(e,t);e.system._unregister(t)}function We(e,t){t&&(Ue(e,t),t._processingStatus===k.Running?e.defer(()=>{e.stopChild(t)}):e.stopChild(t))}function j(e){function t(e,t){}return t.type=`xstate.stopChild`,t.actorRef=e,t.resolve=He,t.execute=We,t}function Ge(e,{context:t,event:n},{guards:r}){return r.every(r=>M(r,t,n,e))}function Ke(e){function t(e,t){return!1}return t.check=Ge,t.guards=e,t}function M(e,t,n,r){let{machine:i}=r,a=typeof e==`function`,o=a?e:i.implementations.guards[typeof e==`string`?e:e.type];if(!a&&!o)throw Error(`Guard '${typeof e==`string`?e:e.type}' is not implemented.'.`);if(typeof o!=`function`)return M(o,t,n,r);let s={context:t,event:n},c=a||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(r,s,o):o(s,c)}function qe(e){return e.type===`atomic`||e.type===`final`}function N(e){return Object.values(e.states).filter(e=>e.type!==`history`)}function P(e,t){let n=[];if(t===e)return n;let r=e.parent;for(;r&&r!==t;)n.push(r),r=r.parent;return n}function F(e){let t=new Set(e),n=Ye(t);for(let e of t)if(e.type===`compound`&&(!n.get(e)||!n.get(e).length))at(e).forEach(e=>t.add(e));else if(e.type===`parallel`){for(let n of N(e))if(n.type!==`history`&&!t.has(n)){let e=at(n);for(let n of e)t.add(n)}}for(let e of t){let n=e.parent;for(;n;)t.add(n),n=n.parent}return t}function Je(e,t){let n=t.get(e);if(!n)return{};if(e.type===`compound`){let e=n[0];if(e){if(qe(e))return e.key}else return{}}let r={};for(let e of n)r[e.key]=Je(e,t);return r}function Ye(e){let t=new Map;for(let 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 Xe(e,t){return Je(e,Ye(F(t)))}function Ze(e,t){return t.type===`compound`?N(t).some(t=>t.type===`final`&&e.has(t)):t.type===`parallel`?N(t).every(t=>Ze(e,t)):t.type===`final`}var I=e=>e[0]===le;function Qe(e,t){let n=e.transitions.get(t),r=[...e.transitions.keys()].filter(e=>e!==t&&Ae(t,e)).sort((e,t)=>t.length-e.length).flatMap(t=>e.transitions.get(t));return n?[...n,...r]:r}function $e(e){let t=e.config.after;if(!t)return[];let n=t=>{let n=pe(t,e.id),r=n.type;return e.entry.push(Wt(n,{id:r,delay:t})),e.exit.push(Re(r)),r};return Object.keys(t).flatMap(e=>{let r=t[e],i=typeof r==`string`?{target:r}:r,a=Number.isNaN(+e)?e:+e,o=n(a);return w(i).map(e=>({...e,event:o,delay:a}))}).map(t=>{let{delay:n}=t;return{...L(e,t.event,t),delay:n}})}function L(e,t,n){let r=Oe(n.target),i=n.reenter??!1,a=rt(e,r),o={...n,actions:w(n.actions),guard:n.guard,target:a,source:e,reenter:i,eventType:t,toJSON:()=>({...o,source:`#${e.id}`,target:a?a.map(e=>`#${e.id}`):void 0})};return o}function et(e){let t=new Map;if(e.config.on)for(let n of Object.keys(e.config.on)){if(n===``)throw Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');let r=e.config.on[n];t.set(n,T(r).map(t=>L(e,n,t)))}if(e.config.onDone){let n=`xstate.done.state.${e.id}`;t.set(n,T(e.config.onDone).map(t=>L(e,n,t)))}for(let n of e.invoke){if(n.onDone){let r=`xstate.done.actor.${n.id}`;t.set(r,T(n.onDone).map(t=>L(e,r,t)))}if(n.onError){let r=`xstate.error.actor.${n.id}`;t.set(r,T(n.onError).map(t=>L(e,r,t)))}if(n.onSnapshot){let r=`xstate.snapshot.${n.id}`;t.set(r,T(n.onSnapshot).map(t=>L(e,r,t)))}}for(let n of e.after){let e=t.get(n.eventType);e||(e=[],t.set(n.eventType,e)),e.push(n)}return t}function tt(e){let t=[],n=r=>{Object.values(r).forEach(r=>{if(r.config.route&&r.config.id){let n=r.config.id,i=r.config.route.guard,a=({event:e})=>e.to===`#${n}`,o={...r.config.route,guard:i?Ke([a,i]):a,target:`#${n}`};t.push(L(e,`xstate.route`,o))}r.states&&n(r.states)})};n(e.states),t.length>0&&e.transitions.set(`xstate.route`,t)}function nt(e,t){let n=typeof t==`string`?e.states[t]:t?e.states[t.target]:void 0;if(!n&&t)throw Error(`Initial state node "${t}" not found on parent state node #${e.id}`);let r={source:e,actions:!t||typeof t==`string`?[]:w(t.actions),eventType:null,reenter:!1,target:n?[n]:[],meta:typeof t==`object`?t.meta:void 0,description:typeof t==`object`?t.description:void 0,toJSON:()=>({...r,source:`#${e.id}`,target:n?[`#${n.id}`]:[]})};return r}function rt(e,t){if(t!==void 0)return t.map(t=>{if(typeof t!=`string`)return t;if(I(t))return e.machine.getStateNodeById(t);let n=t[0]===`.`;if(n&&!e.parent)return B(e,t.slice(1));let r=n?e.key+t:t;if(e.parent)try{return B(e.parent,r)}catch(t){throw Error(`Invalid transition definition for state node '${e.id}':\n${t.message}`)}throw Error(`Invalid target: "${t}" is not a valid target from the root node. Did you mean ".${t}"?`)})}function it(e){let t=Oe(e.config.target);return t?{target:t.map(t=>typeof t==`string`?B(e.parent,t):t)}:e.parent.type===`parallel`?{target:[e.parent]}:e.parent.initial}function R(e){return e.type===`history`}function at(e){let t=ot(e);for(let n of t)for(let r of P(n,e))t.add(r);return t}function ot(e){let t=new Set;function n(e){if(!t.has(e)){if(t.add(e),e.type===`compound`)n(e.initial.target[0]);else if(e.type===`parallel`)for(let t of N(e))n(t)}}return n(e),t}function z(e,t){if(I(t))return e.machine.getStateNodeById(t);if(!e.states)throw Error(`Unable to retrieve child state '${t}' from '${e.id}'; no child states exist.`);let n=e.states[t];if(!n)throw Error(`Child state '${t}' does not exist on '${e.id}'`);return n}function B(e,t){if(typeof t==`string`&&I(t))try{return e.machine.getStateNodeById(t)}catch{}let n=be(t).slice(),r=e;for(;n.length;){let e=n.shift();if(!e.length)break;r=z(r,e)}return r}function V(e,t){if(typeof t==`string`){let n=e.states[t];if(!n)throw Error(`State '${t}' does not exist on '${e.id}'`);return[e,n]}let n=Object.keys(t),r=n.map(t=>z(e,t)).filter(Boolean);return[e.machine.root,e].concat(r,n.reduce((n,r)=>{let i=z(e,r);if(!i)return n;let a=V(i,t[r]);return n.concat(a)},[]))}function st(e,t,n,r){let i=z(e,t).next(n,r);return!i||!i.length?e.next(n,r):i}function ct(e,t,n,r){let i=Object.keys(t),a=ut(z(e,i[0]),t[i[0]],n,r);return!a||!a.length?e.next(n,r):a}function lt(e,t,n,r){let i=[];for(let a of Object.keys(t)){let o=t[a];if(!o)continue;let s=ut(z(e,a),o,n,r);s&&i.push(...s)}return i.length?i:e.next(n,r)}function ut(e,t,n,r){return typeof t==`string`?st(e,t,n,r):Object.keys(t).length===1?ct(e,t,n,r):lt(e,t,n,r)}function dt(e){return Object.keys(e.states).map(t=>e.states[t]).filter(e=>e.type===`history`)}function H(e,t){let n=e;for(;n.parent&&n.parent!==t;)n=n.parent;return n.parent===t}function ft(e,t){let n=new Set(e),r=new Set(t);for(let e of n)if(r.has(e))return!0;for(let e of r)if(n.has(e))return!0;return!1}function pt(e,t,n){let r=new Set;for(let i of e){let e=!1,a=new Set;for(let o of r)if(ft(_t([i],t,n),_t([o],t,n))){if(H(i.source,o.source))a.add(o);else{e=!0;break}}if(!e){for(let e of a)r.delete(e);r.add(i)}}return Array.from(r)}function mt(e){let[t,...n]=e;for(let e of P(t,void 0))if(n.every(t=>H(t,e)))return e}function ht(e,t){if(!e.target)return[];let n=new Set;for(let r of e.target)if(R(r)){if(t[r.id])for(let e of t[r.id])n.add(e);else for(let e of ht(it(r),t))n.add(e)}else n.add(r);return[...n]}function gt(e,t){let n=ht(e,t);if(!n)return;if(!e.reenter&&n.every(t=>t===e.source||H(t,e.source)))return e.source;let r=mt(n.concat(e.source));if(r)return r;if(!e.reenter)return e.source.machine.root}function _t(e,t,n){let r=new Set;for(let i of e)if(i.target?.length){let e=gt(i,n);i.reenter&&i.source===e&&r.add(e);for(let n of t)H(n,e)&&r.add(n)}return[...r]}function vt(e,t){if(e.length!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function yt(e,t,n,r,i){return U([{target:[...ot(e)],source:e,reenter:!0,actions:[],eventType:null,toJSON:null}],t,n,r,!0,i)}function U(e,t,n,r,i,a){let o=[];if(!e.length)return[t,o];let s=n.actionExecutor;n.actionExecutor=e=>{o.push(e),s(e)};try{let s=new Set(t._nodes),c=t.historyValue,l=pt(e,s,c),u=t;i||([u,c]=Tt(u,r,n,l,s,c,a,n.actionExecutor)),u=G(u,r,n,l.flatMap(e=>e.actions),a,void 0),u=xt(u,r,n,l,s,a,c,i);let d=[...s];u.status===`done`&&(u=G(u,r,n,d.sort((e,t)=>t.order-e.order).flatMap(e=>e.exit),a,void 0));try{return c===t.historyValue&&vt(t._nodes,s)?[u,o]:[q(u,{_nodes:d,historyValue:c}),o]}catch(e){throw e}}finally{n.actionExecutor=s}}function bt(e,t,n,r,i){if(r.output===void 0)return;let a=me(i.id,i.output!==void 0&&i.parent?Te(i.output,e.context,t,n.self):void 0);return Te(r.output,e.context,a,n.self)}function xt(e,t,n,r,i,a,o,s){let c=e,l=new Set,u=new Set;St(r,o,u,l),s&&u.add(e.machine.root);let d=new Set;for(let e of[...l].sort((e,t)=>e.order-t.order)){i.add(e);let r=[];r.push(...e.entry);for(let t of e.invoke)r.push(Ve(t.src,{...t,syncSnapshot:!!t.onSnapshot}));if(u.has(e)){let t=e.initial.actions;r.push(...t)}if(c=G(c,t,n,r,a,e.invoke.map(e=>e.id)),e.type===`final`){let r=e.parent,o=r?.type===`parallel`?r:r?.parent,s=o||e;for(r?.type===`compound`&&a.push(me(r.id,e.output===void 0?void 0:Te(e.output,c.context,t,n.self)));o?.type===`parallel`&&!d.has(o)&&Ze(i,o);)d.add(o),a.push(me(o.id)),s=o,o=o.parent;if(o)continue;c=q(c,{status:`done`,output:bt(c,t,n,c.machine.root,s)})}}return c}function St(e,t,n,r){for(let i of e){let e=gt(i,t);for(let a of i.target||[])!R(a)&&(i.source!==a||i.source!==e||i.reenter)&&(r.add(a),n.add(a)),W(a,t,n,r);let a=ht(i,t);for(let o of a){let a=P(o,e);e?.type===`parallel`&&a.push(e),Ct(r,t,n,a,!i.source.parent&&i.reenter?void 0:e)}}}function W(e,t,n,r){if(R(e)){if(t[e.id]){let i=t[e.id];for(let e of i)r.add(e),W(e,t,n,r);for(let a of i)wt(a,e.parent,r,t,n)}else{let i=it(e);for(let a of i.target)r.add(a),i===e.parent?.initial&&n.add(e.parent),W(a,t,n,r);for(let a of i.target)wt(a,e.parent,r,t,n)}}else if(e.type===`compound`){let[i]=e.initial.target;R(i)||(r.add(i),n.add(i)),W(i,t,n,r),wt(i,e,r,t,n)}else if(e.type===`parallel`)for(let i of N(e).filter(e=>!R(e)))[...r].some(e=>H(e,i))||(R(i)||(r.add(i),n.add(i)),W(i,t,n,r))}function Ct(e,t,n,r,i){for(let a of r)if((!i||H(a,i))&&e.add(a),a.type===`parallel`)for(let r of N(a).filter(e=>!R(e)))[...e].some(e=>H(e,r))||(e.add(r),W(r,t,n,e))}function wt(e,t,n,r,i){Ct(n,r,i,P(e,t))}function Tt(e,t,n,r,i,a,o,s){let c=e,l=_t(r,i,a);l.sort((e,t)=>t.order-e.order);let u;for(let e of l)for(let t of dt(e)){let n;n=t.history===`deep`?t=>qe(t)&&H(t,e):t=>t.parent===e,u??={...a},u[t.id]=Array.from(i).filter(n)}for(let e of l)c=G(c,t,n,[...e.exit,...e.invoke.map(e=>j(e.id))],o,void 0),i.delete(e);return[c,u||a]}function Et(e,t){return e.implementations.actions[t]}function Dt(e,t,n,r,i,a){let{machine:o}=e,s=e;for(let e of r){let r=typeof e==`function`,c=r?e:Et(o,typeof e==`string`?e:e.type),l={context:s.context,event:t,self:n.self,system:n.system},u=r||typeof e==`string`?void 0:`params`in e?typeof e.params==`function`?e.params({context:s.context,event:t}):e.params:void 0;if(!c||!(`resolve`in c)){n.actionExecutor({type:typeof e==`string`?e:typeof e==`object`?e.type:e.name||`(anonymous)`,info:l,params:u,exec:c});continue}let d=c,[f,p,m]=d.resolve(n,s,l,u,c,i);s=f,`retryResolve`in d&&a?.push([d,p]),`execute`in d&&n.actionExecutor({type:d.type,info:l,params:p,exec:d.execute.bind(null,n,p)}),m&&(s=Dt(s,t,n,m,i,a))}return s}function G(e,t,n,r,i,a){let o=a?[]:void 0,s=Dt(e,t,n,r,{internalQueue:i,deferredActorIds:a},o);return o?.forEach(([e,t])=>{e.retryResolve(n,s,t)}),s}function Ot(e,t,n,r){let i=e,a=[];function o(e,t,r){n.system._sendInspectionEvent({type:`@xstate.microstep`,actorRef:n.self,event:t,snapshot:e[0],_transitions:r}),a.push(e)}if(t.type===`xstate.stop`)return i=q(kt(i,t,n),{status:`stopped`}),o([i,[]],t,[]),{snapshot:i,microsteps:a};let s=t;if(s.type!==de){let t=s,c=De(t),l=At(t,i);if(c&&!l.length)return i=q(kt(i,t,n),{status:`error`,error:t.error}),o([i,[]],t,[]),{snapshot:i,microsteps:a};let u=U(l,e,n,s,!1,r);i=u[0],o(u,t,l)}let c=!0,l=e.machine.options?.maxIterations??1/0,u=0;for(;i.status===`active`;){if(u++,u>l)throw Error(`Infinite loop detected: the machine has processed more than ${l} microsteps without reaching a stable state. This usually happens when there's a cycle of transitions (e.g., eventless transitions or raised events causing state A -> B -> C -> A).`);let e=c?jt(i,s):[],t=e.length?i:void 0;if(!e.length){if(!r.length)break;s=r.shift(),e=At(s,i)}let a=U(e,i,n,s,!1,r);i=a[0],c=i!==t,o(a,s,e)}return i.status!==`active`&&kt(i,s,n),{snapshot:i,microsteps:a}}function kt(e,t,n){return G(e,t,n,Object.values(e.children).map(e=>j(e)),[],void 0)}function At(e,t){return t.machine.getTransitionData(t,e)}function jt(e,t){let n=new Set,r=e._nodes.filter(qe);for(let i of r)loop:for(let r of[i].concat(P(i,void 0)))if(r.always){for(let i of r.always)if(i.guard===void 0||M(i.guard,e.context,t,e)){n.add(i);break loop}}return pt(Array.from(n),new Set(e._nodes),e.historyValue)}function Mt(e,t){return Xe(e,[...F(V(e,t))])}function Nt(e){return!!e&&typeof e==`object`&&`machine`in e&&`value`in e}var Pt=function(e){return ye(e,this.value)},Ft=function(e){return this.tags.has(e)},It=function(e){let t=this.machine.getTransitionData(this,e);return!!t?.length&&t.some(e=>e.target!==void 0||e.actions.length)},Lt=function(){let{_nodes:e,tags:t,machine:n,getMeta:r,toJSON:i,can:a,hasTag:o,matches:s,...c}=this;return{...c,tags:Array.from(t)}},Rt=function(){return this._nodes.reduce((e,t)=>(t.meta!==void 0&&(e[t.id]=t.meta),e),{})};function K(e,t){return{status:e.status,output:e.output,error:e.error,machine:t,context:e.context,_nodes:e._nodes,value:Xe(t.root,e._nodes),tags:new Set(e._nodes.flatMap(e=>e.tags)),children:e.children,historyValue:e.historyValue||{},matches:Pt,hasTag:Ft,can:It,getMeta:Rt,toJSON:Lt}}function q(e,t={}){return K({...e,...t},e.machine)}function zt(e){if(typeof e!=`object`||!e)return{};let t={};for(let n in e){let r=e[n];Array.isArray(r)&&(t[n]=r.map(e=>({id:e.id})))}return t}function Bt(e,t){let{_nodes:n,tags:r,machine:i,children:a,context:o,can:s,hasTag:c,matches:l,getMeta:u,toJSON:d,...f}=e,p={};for(let e in a){let n=a[e];p[e]={snapshot:n.getPersistedSnapshot(t),src:n.src,systemId:n.systemId,syncSnapshot:n._syncSnapshot}}return{...f,context:Vt(o),children:p,historyValue:zt(f.historyValue)}}function Vt(e){let t;for(let n in e){let r=e[n];if(r&&typeof r==`object`){if(`sessionId`in r&&`send`in r&&`ref`in r)t??=Array.isArray(e)?e.slice():{...e},t[n]={xstate$$type:1,id:r.id};else{let i=Vt(r);i!==r&&(t??=Array.isArray(e)?e.slice():{...e},t[n]=i)}}}return t??e}function Ht(e,t,n,r,{event:i,id:a,delay:o},{internalQueue:s}){let c=t.machine.implementations.delays;if(typeof i==`string`)throw Error(`Only event objects may be used with raise; use raise({ type: "${i}" }) instead`);let l=typeof i==`function`?i(n,r):i,u;if(typeof o==`string`){let e=c&&c[o];u=typeof e==`function`?e(n,r):e}else u=typeof o==`function`?o(n,r):o;return typeof u!=`number`&&s.push(l),[t,{event:l,id:a,delay:u},void 0]}function Ut(e,t){let{event:n,delay:r,id:i}=t;typeof r==`number`&&e.defer(()=>{let t=e.self;e.system.scheduler.schedule(t,t,n,r,i)})}function Wt(e,t){function n(e,t){}return n.type=`xstate.raise`,n.event=e,n.id=t?.id,n.delay=t?.delay,n.resolve=Ht,n.execute=Ut,n}function Gt(e,{machine:t,context:n},r,i){let a=(a,o)=>{if(typeof a==`string`){let s=D(t,a);if(!s)throw Error(`Actor logic '${a}' not implemented in machine '${t.id}'`);let c=A(s,{id:o?.id,parent:e.self,syncSnapshot:o?.syncSnapshot,input:typeof o?.input==`function`?o.input({context:n,event:r,self:e.self}):o?.input,src:a,systemId:o?.systemId});return i[c.id]=c,c}return A(a,{id:o?.id,parent:e.self,syncSnapshot:o?.syncSnapshot,input:o?.input,src:a,systemId:o?.systemId})};return(t,n)=>{let r=a(t,n);return i[r.id]=r,e.defer(()=>{r._processingStatus!==k.Stopped&&r.start()}),r}}function Kt(e,t,n,r,{assignment:i}){if(!t.context)throw Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");let a={},o={context:t.context,event:n.event,spawn:Gt(e,t,n.event,a),self:e.self,system:e.system},s={};if(typeof i==`function`)s=i(o,r);else for(let e of Object.keys(i)){let t=i[e];s[e]=typeof t==`function`?t(o,r):t}return[q(t,{context:Object.assign({},t.context,s),children:Object.keys(a).length?{...t.children,...a}:t.children}),void 0,void 0]}function qt(e){function t(e,t){}return t.type=`xstate.assign`,t.assignment=e,t.resolve=Kt,t}var Jt=new WeakMap;function J(e,t,n){let r=Jt.get(e);return r?t in r||(r[t]=n()):(r={[t]:n()},Jt.set(e,r)),r[t]}var Yt={},Y=e=>typeof e==`string`?{type:e}:typeof e==`function`?`resolve`in e?{type:e.type}:{type:e.name}:e,Xt=class e{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(`.`),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?Ce(this.config.states,(t,n)=>new e(t,{_parent:this,_key:n,_machine:this.machine})):Yt,this.type===`compound`&&!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=this.config.history===!0?`shallow`:this.config.history||!1,this.entry=w(this.config.entry).slice(),this.exit=w(this.config.exit).slice(),this.meta=this.config.meta,this.output=this.type===`final`||!this.parent?this.config.output:void 0,this.tags=w(t.tags).slice()}_initialize(){this.transitions=et(this),this.config.always&&(this.always=T(this.config.always).map(e=>L(this,``,e))),Object.keys(this.states).forEach(e=>{this.states[e]._initialize()})}get definition(){return{id:this.id,key:this.key,version:this.machine.version,type:this.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(Y),eventType:null,reenter:!1,meta:this.initial.meta,description:this.initial.description,toJSON:()=>({target:this.initial.target.map(e=>`#${e.id}`),source:`#${this.id}`,actions:this.initial.actions.map(Y),eventType:null,meta:this.initial.meta,description:this.initial.description})}:void 0,history:this.history,states:Ce(this.states,e=>e.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(e=>({...e,actions:e.actions.map(Y)})),entry:this.entry.map(Y),exit:this.exit.map(Y),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 J(this,`invoke`,()=>w(this.config.invoke).map((e,t)=>{let{src:n,systemId:r}=e,i=e.id??ke(this.id,t),a=typeof n==`string`?n:`xstate.invoke.${ke(this.id,t)}`;return{...e,src:a,id:i,systemId:r,toJSON(){let{onDone:t,onError:n,...r}=e;return{...r,type:`xstate.invoke`,src:a,id:i}}}}))}get on(){return J(this,`on`,()=>[...this.transitions].flatMap(([e,t])=>t.map(t=>[e,t])).reduce((e,[t,n])=>(e[t]=e[t]||[],e[t].push(n),e),{}))}get after(){return J(this,`delayedTransitions`,()=>$e(this))}get initial(){return J(this,`initial`,()=>nt(this,this.config.initial))}next(e,t){let n=t.type,r=[],i,a=J(this,`candidates-${n}`,()=>Qe(this,n));for(let o of a){let{guard:a}=o,s=e.context,c=!1;try{c=!a||M(a,s,t,e)}catch(e){let t=typeof a==`string`?a:typeof a==`object`?a.type:void 0;throw Error(`Unable to evaluate guard ${t?`'${t}' `:``}in transition for event '${n}' in state node '${this.id}':\n${e.message}`)}if(c){r.push(...o.actions),i=o;break}}return i?[i]:void 0}get events(){return J(this,`events`,()=>{let{states:e}=this,t=new Set(this.ownEvents);if(e)for(let n of Object.keys(e)){let r=e[n];if(r.states)for(let e of r.events)t.add(`${e}`)}return Array.from(t)})}get ownEvents(){let e=Object.keys(Object.fromEntries(this.transitions)),t=new Set(e.filter(e=>this.transitions.get(e).some(e=>!(!e.target&&!e.actions.length&&!e.reenter))));return Array.from(t)}},Zt=class e{constructor(e,t){this.config=e,this.version=void 0,this.schemas=void 0,this.implementations=void 0,this.options=void 0,this.__xstatenode=!0,this.idMap=new Map,this.root=void 0,this.id=void 0,this.states=void 0,this.events=void 0,this.id=e.id||`(machine)`,this.implementations={actors:t?.actors??{},actions:t?.actions??{},delays:t?.delays??{},guards:t?.guards??{}},this.version=this.config.version,this.schemas=this.config.schemas,this.options={maxIterations:1/0,...this.config.options},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 Xt(e,{_key:this.id,_machine:this}),this.root._initialize(),tt(this.root),this.states=this.root.states,this.events=this.root.events}provide(t){let{actions:n,guards:r,actors:i,delays:a}=this.implementations;return new e(this.config,{actions:{...n,...t.actions},guards:{...r,...t.guards},actors:{...i,...t.actors},delays:{...a,...t.delays}})}resolveState(e){let t=Mt(this.root,e.value),n=F(V(this.root,t));return K({_nodes:[...n],context:e.context||{},children:{},status:Ze(n,this.root)?`done`:e.status||`active`,output:e.output,error:e.error,historyValue:e.historyValue},this)}transition(e,t,n){return Ot(e,t,n,[]).snapshot}microstep(e,t,n){return Ot(e,t,n,[]).microsteps.map(([e])=>e)}getTransitionData(e,t){return ut(this.root,e.value,e,t)||[]}_getPreInitialState(e,t,n){let{context:r}=this.config,i=K({context:typeof r!=`function`&&r?r:{},_nodes:[this.root],children:{},status:`active`},this);return typeof r==`function`?G(i,t,e,[qt(({spawn:e,event:t,self:n})=>r({spawn:e,input:t.input,self:n}))],n,void 0):i}getInitialSnapshot(e,t){let n=_e(t),r=[],i=K({context:typeof this.config.context!=`function`&&this.config.context?this.config.context:{},_nodes:[this.root],children:{},status:`active`},this);try{i=this._getPreInitialState(e,n,r);let[t]=yt(this.root,i,e,n,r),{snapshot:a}=Ot(t,n,e,r);return a}catch(e){return q(i,{status:`error`,error:e})}}start(e){Object.values(e.children).forEach(e=>{e.getSnapshot().status===`active`&&e.start()})}getStateNodeById(e){let t=be(e),n=t.slice(1),r=I(t[0])?t[0].slice(1):t[0],i=this.idMap.get(r);if(!i)throw Error(`Child state node '#${r}' does not exist on machine '${this.id}'`);return B(i,n)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(e,t){return Bt(e,t)}restoreSnapshot(e,t){let n={},r=e.children;Object.keys(r).forEach(e=>{let i=r[e],a=i.snapshot,o=i.src,s=typeof o==`string`?D(this,o):o;if(!s)return;let c=A(s,{id:e,parent:t.self,syncSnapshot:i.syncSnapshot,snapshot:a,src:o,systemId:i.systemId});n[e]=c});function i(e,t){if(t instanceof Xt)return t;try{return e.machine.getStateNodeById(t.id)}catch{}}function a(e,t){if(!t||typeof t!=`object`)return{};let n={};for(let r in t){let a=t[r];for(let t of a){let a=i(e,t);a&&(n[r]??=[],n[r].push(a))}}return n}let o=a(this.root,e.historyValue),s=K({...e,children:n,_nodes:Array.from(F(V(this.root,e.value))),historyValue:o},this),c=new Set;function l(e,t){if(!c.has(e)){c.add(e);for(let n in e){let r=e[n];if(r&&typeof r==`object`){if(`xstate$$type`in r&&r.xstate$$type===1){e[n]=t[r.id];continue}l(r,t)}}}}return l(s.context,n),s}};function Qt(e,t,n,r,{event:i}){return[t,{event:typeof i==`function`?i(n,r):i},void 0]}function $t(e,{event:t}){e.defer(()=>e.emit(t))}function en(e){function t(e,t){}return t.type=`xstate.emit`,t.event=e,t.resolve=Qt,t.execute=$t,t}var tn=function(e){return e.Parent=`#_parent`,e.Internal=`#_internal`,e}({});function nn(e,t,n,r,{to:i,event:a,id:o,delay:s},c){let l=t.machine.implementations.delays;if(typeof a==`string`)throw Error(`Only event objects may be used with sendTo; use sendTo({ type: "${a}" }) instead`);let u=typeof a==`function`?a(n,r):a,d;if(typeof s==`string`){let e=l&&l[s];d=typeof e==`function`?e(n,r):e}else d=typeof s==`function`?s(n,r):s;let f=typeof i==`function`?i(n,r):i,p;if(typeof f==`string`){if(p=f===tn.Parent?e.self._parent:f===tn.Internal?e.self:f.startsWith(`#_`)?t.children[f.slice(2)]:c.deferredActorIds?.includes(f)?f:t.children[f],!p)throw Error(`Unable to send event to actor '${f}' from machine '${t.machine.id}'.`)}else p=f||e.self;return[t,{to:p,targetId:typeof f==`string`?f:void 0,event:u,id:o,delay:d},void 0]}function rn(e,t,n){typeof n.to==`string`&&(n.to=t.children[n.to])}function an(e,t){e.defer(()=>{let{to:n,event:r,delay:i,id:a}=t;typeof i==`number`?e.system.scheduler.schedule(e.self,n,r,i,a):e.system._relay(e.self,n,r.type===`xstate.error`?ge(e.self.id,r.data):r)})}function on(e,t,n){function r(e,t){}return r.type=`xstate.sendTo`,r.to=e,r.event=t,r.id=n?.id,r.delay=n?.delay,r.resolve=nn,r.retryResolve=rn,r.execute=an,r}function sn(e,t){return on(tn.Parent,e,t)}function cn(e,t,n,r,{collect:i}){let a=[],o=function(e){a.push(e)};return o.assign=(...e)=>{a.push(qt(...e))},o.cancel=(...e)=>{a.push(Re(...e))},o.raise=(...e)=>{a.push(Wt(...e))},o.sendTo=(...e)=>{a.push(on(...e))},o.sendParent=(...e)=>{a.push(sn(...e))},o.spawnChild=(...e)=>{a.push(Ve(...e))},o.stopChild=(...e)=>{a.push(j(...e))},o.emit=(...e)=>{a.push(en(...e))},i({context:n.context,event:n.event,enqueue:o,check:e=>M(e,t.context,n.event,t),self:e.self,system:e.system},r),[t,void 0,a]}function ln(e){function t(e,t){}return t.type=`xstate.enqueueActions`,t.collect=e,t.resolve=cn,t}function un(e,t,n,r,{value:i,label:a}){return[t,{value:typeof i==`function`?i(n,r):i,label:a},void 0]}function dn({logger:e},{value:t,label:n}){n?e(n,t):e(t)}function fn(e=({context:e,event:t})=>({context:e,event:t}),t){function n(e,t){}return n.type=`xstate.log`,n.value=e,n.label=t,n.resolve=un,n.execute=dn,n}function pn(e,t){return new Zt(e,t)}function mn({schemas:e,actors:t,actions:n,guards:r,delays:i}){return{assign:qt,sendTo:on,raise:Wt,log:fn,cancel:Re,stopChild:j,enqueueActions:ln,emit:en,spawnChild:Ve,createStateConfig:e=>e,createAction:e=>e,createMachine:a=>pn({...a,schemas:e},{actors:t,actions:n,guards:r,delays:i}),extend:a=>mn({schemas:e,actors:t,actions:{...n,...a.actions},guards:{...r,...a.guards},delays:{...i,...a.delays}})}}var hn=(e,t,n)=>Math.max(t,Math.min(n,e)),gn=class{dents=[];revision=0;enabled=!1;maxDepthM=0;maskCache=new WeakMap;spriteCache=null;captureState(){return a({dents:this.dents,revision:this.revision,enabled:this.enabled,maxDepthM:this.maxDepthM})}restoreState(e){let t=a(e);this.dents=t.dents,this.revision=t.revision,this.enabled=t.enabled,this.maxDepthM=t.maxDepthM,this.maskCache=new WeakMap,this.spriteCache=null}get hasDamage(){return this.enabled&&this.dents.length>0}get geometryRevision(){return this.revision}setEnabled(e){this.enabled!==e&&(this.enabled=e,e||this.reset())}reset(){this.dents=[],this.maxDepthM=0,this.revision++,this.spriteCache=null}hit(e,t,n,r,i){if(!this.enabled||r<=2.5||!Number.isFinite(r))return!1;let a=Math.max(1,i),s=f(e,n.center),c=m(l(s,n.forward)/a,l(s,n.side)/a),d=m(l(t,n.forward),l(t,n.side)),p=o(d);if(p<.001)return!1;let h=hn((r-2.5)/17.5,0,1)**1.5;return this.maxDepthM=Math.min(.25,8/a),this.dents.push({center:c,inward:u(d,1/p),depthM:this.maxDepthM*h,radiusAlongM:.65+h*.5,radiusAcrossM:.55+h*.55}),this.dents.length>12&&this.dents.shift(),this.revision++,this.spriteCache=null,!0}point(e){if(!this.hasDamage)return e;let t=m();for(let n of this.dents){let r=(e.x-n.center.x)/n.radiusAlongM,i=(e.y-n.center.y)/n.radiusAcrossM,a=Math.hypot(r,i);if(a>=1)continue;let o=(1-a*a)**2;t=p(t,u(n.inward,n.depthM*o))}let n=o(t);return n>this.maxDepthM&&(t=u(t,this.maxDepthM/n)),p(e,t)}maskFor(e){if(!this.hasDamage)return e;let t=this.maskCache.get(e);if(t?.revision===this.revision)return t.value;let{columns:n,rows:r,solid:i}=e.alpha,a=new Uint8Array(i.length),o=e.lengthM/n,s=e.widthM/r;for(let t=0;t<r;t++)for(let c=0;c<n;c++){let l=m((c+.5)*o-e.lengthM/2,(t+.5)*s-e.widthM/2),u=l;for(let e=0;e<5;e++)u=p(u,f(l,this.point(u)));let d=Math.floor((u.x/e.lengthM+.5)*n),h=Math.floor((u.y/e.widthM+.5)*r);d>=0&&d<n&&h>=0&&h<r&&(a[t*n+c]=i[h*n+d])}let c={...e,alpha:{columns:n,rows:r,solid:a}};return this.maskCache.set(e,{revision:this.revision,value:c}),c}spriteFor(e,t){if(!this.hasDamage)return null;let n=`${t.source.x}:${t.source.y}:${t.source.width}:${t.source.height}:${t.lengthM}:${t.widthM}`;if(this.spriteCache?.image===e&&this.spriteCache.key===n&&this.spriteCache.revision===this.revision)return this.spriteCache.canvas;let r=document.createElement(`canvas`);r.width=Math.max(1,Math.round(t.source.width)),r.height=Math.max(1,Math.round(t.source.height));let i=r.getContext(`2d`);if(!i)return null;let a=e=>{let n=m((e.x/r.width-.5)*t.lengthM,(e.y/r.height-.5)*t.widthM),i=this.point(n);return m((i.x/t.lengthM+.5)*r.width,(i.y/t.widthM+.5)*r.height)};for(let n=0;n<10;n++)for(let o=0;o<20;o++){let s=o*r.width/20,c=(o+1)*r.width/20,l=n*r.height/10,u=(n+1)*r.height/10,d=m(s,l),f=m(c,l),p=m(s,u),h=m(c,u);this.drawTriangle(i,e,t,[d,f,p],[a(d),a(f),a(p)]),this.drawTriangle(i,e,t,[h,p,f],[a(h),a(p),a(f)])}return this.spriteCache={image:e,key:n,revision:this.revision,canvas:r},r}drawTriangle(e,t,n,r,i){let[a,o,s]=r,[c,l,u]=i,d=o.x-a.x,f=o.y-a.y,p=s.x-a.x,m=s.y-a.y,h=d*m-p*f;if(Math.abs(h)<1e-4)return;let g=l.x-c.x,_=l.y-c.y,v=u.x-c.x,y=u.y-c.y,b=(g*m-v*f)/h,x=(_*m-y*f)/h,ee=(v*d-g*p)/h,S=(y*d-_*p)/h,te=c.x-b*a.x-ee*a.y,ne=c.y-x*a.x-S*a.y;e.save(),e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(l.x,l.y),e.lineTo(u.x,u.y),e.closePath(),e.clip(),e.transform(b,x,ee,S,te,ne),e.drawImage(t,n.source.x,n.source.y,n.source.width,n.source.height,0,0,e.canvas.width,e.canvas.height),e.restore()}},_n=class{random;pulses=[];constructor(e=Math.random){this.random=e}get active(){return this.pulses}trigger({color:e,angle:n,velocity:r,origin:i}){if(!Number.isFinite(n)||!Number.isFinite(r))throw RangeError(`Pickup angle and velocity must be finite`);if(i&&(!Number.isFinite(i.x)||!Number.isFinite(i.y)||Math.abs(i.x)>.5||Math.abs(i.y)>.5))throw RangeError(`Pickup origin must lie within normalized body coordinates [-0.5, 0.5]`);let a=t(e),o=Math.min(1,Math.abs(r)/32);this.pulses.push({color:[a[0]/255,a[1]/255,a[2]/255],angle:Math.atan2(Math.sin(n),Math.cos(n)),strength:o,velocity:Math.abs(r),origin:i?{...i}:null,variation:this.random(),age:0,duration:.38-o*.1}),this.pulses.length>3&&this.pulses.shift()}step(e){if(!(!this.pulses.length||!Number.isFinite(e)||e<=0)){for(let t of this.pulses)t.age+=e;this.pulses=this.pulses.filter(e=>e.age<e.duration)}}reset(){this.pulses=[]}captureState(){return structuredClone(this.pulses)}restoreState(e){this.pulses=structuredClone(e)}},vn=new Map,X=null;function yn(e){let t=e.match(/^#([\da-f]{3}|[\da-f]{6})$/i)?.[1];if(t){let e=t.length===3?[...t].map(e=>e+e).join(``):t;return[0,2,4].map(t=>parseInt(e.slice(t,t+2),16))}let n=e.match(/^rgba?\(\s*(\d{1,3})[,\s]+(\d{1,3})[,\s]+(\d{1,3})/i);return n?[d(+n[1],0,255),d(+n[2],0,255),d(+n[3],0,255)]:null}function bn(e){let t=yn(e);if(t)return t;if(vn.has(e))return vn.get(e);let n=null;return typeof document<`u`&&(X??=document.createElement(`canvas`).getContext(`2d`),X&&(X.fillStyle=`#010203`,X.fillStyle=e,X.fillStyle!==`#010203`&&(n=yn(X.fillStyle)))),vn.set(e,n),n}var xn=[[0,0],[60,120],[120,180],[240,240],[300,300],[360,360]];function Sn(e,t=!1){let n=(e%360+360)%360;for(let e=1;e<xn.length;e++){let[r,i]=xn[e-1],[a,o]=xn[e],s=t?i:r,c=t?o:a;if(n<=c){let e=(n-s)/(c-s);return(t?r+(a-r)*e:i+(o-i)*e)%360}}return 0}function Cn([e,t,n]){let r=e/255,i=t/255,a=n/255,o=Math.max(r,i,a),s=Math.min(r,i,a),c=o-s,l=(o+s)/2;if(c===0)return{hue:0,saturation:0,light:l};let u=c/(1-Math.abs(2*l-1));return{hue:((o===r?(i-a)/c%6:o===i?(a-r)/c+2:(r-i)/c+4)*60+360)%360,saturation:u,light:l}}function wn(e,t,n){let r=(1-Math.abs(2*n-1))*t,i=r*(1-Math.abs(e/60%2-1)),a=Math.floor(e/60)%6,o=[[r,i,0],[i,r,0],[0,r,i],[0,i,r],[i,0,r],[r,0,i]][a],s=n-r/2;return`rgb(${o.map(e=>Math.round((e+s)*255)).join(` `)})`}function Tn(e){let t=e.filter(e=>e.strength>0&&bn(e.color));if(!t.length)return e.at(-1)?.color??`rgb(0 0 0)`;if(t.length===1)return`rgb(${bn(t[0].color).join(` `)})`;let n=0,r=0,i=0,a=0,o=0;for(let e of t){let t=Cn(bn(e.color)),s=Sn(t.hue)*Math.PI/180,c=e.strength*t.saturation;n+=Math.cos(s)*c,r+=Math.sin(s)*c,i+=t.light*e.strength,a+=c,o+=e.strength}return wn(Sn((Math.atan2(r,n)*180/Math.PI+360)%360,!0),Math.min(1,a/o),i/o)}var En=class{coatings=new Map;previous=new Map;travelM=new Map;previousLayer=new Map;wetPaths=new Map;exits=new Map;sprayRemainder=new Map;marks=[];markCount=0;captureState(){return a({coatings:this.coatings,previous:this.previous,travelM:this.travelM,previousLayer:this.previousLayer,wetPaths:this.wetPaths,exits:this.exits,sprayRemainder:this.sprayRemainder,marks:this.marks,markCount:this.markCount})}restoreState(e){let t=a(e);this.coatings=t.coatings,this.previous=t.previous,this.travelM=t.travelM,this.previousLayer=t.previousLayer,this.wetPaths=t.wetPaths,this.exits=t.exits,this.sprayRemainder=t.sprayRemainder,this.marks.length=0;for(let e of t.marks)this.marks.push(e);this.markCount=t.markCount}get totalMarks(){return this.markCount}get managedBytes(){return this.marks.length*136+this.travelM.size*16+[...this.coatings.values()].reduce((e,t)=>e+t.size*72,0)+this.previous.size*24+this.previousLayer.size*8+[...this.wetPaths.values()].reduce((e,t)=>e+t.marks.length*160,0)+this.exits.size*24+this.sprayRemainder.size*16}reset(){this.travelM.clear(),this.coatings.clear(),this.previous.clear(),this.previousLayer.clear(),this.wetPaths.clear(),this.exits.clear(),this.sprayRemainder.clear(),this.marks.length=0,this.markCount=0}step(e){e.forEach((e,t)=>this.travelM.set(t,(this.travelM.get(t)??0)+Math.max(0,e)));for(let[t,n]of this.coatings){let r=Math.max(0,e[t]??0);for(let[e,t]of n)t.remaining=Math.max(0,t.remaining-r),t.remaining===0&&n.delete(e);n.size===0&&(this.coatings.delete(t),this.previous.delete(t),this.previousLayer.delete(t),this.wetPaths.delete(t),this.exits.delete(t))}}touch(e,t){if(!t||t.opacity<=0||t.distanceM<=0)return;let n=this.coatings.get(e);n||(n=new Map,this.coatings.set(e,n));let r=t.id??t.color,i=n.get(r);if(n.set(r,{...t,opacity:Math.max(i?.opacity??0,d(t.opacity,0,1)),remaining:t.distanceM}),n.size>16){let e=[...n.entries()].filter(([e])=>e!==r).sort((e,t)=>e[1].opacity*e[1].remaining/e[1].distanceM-t[1].opacity*t[1].remaining/t[1].distanceM)[0];e&&n.delete(e[0])}}wash(e,t=[]){let n=this.coatings.get(e);if(n&&t.length){let e=new Set(t.map(e=>e.id??e.color));for(let t of n.keys())e.has(t)||n.delete(t);if(n.size)return}this.coatings.delete(e),this.previous.delete(e),this.previousLayer.delete(e),this.sprayRemainder.delete(e),this.wetPaths.delete(e),this.exits.delete(e)}splatter(t,n,r,i,a,o,s){let c=this.coating(t);if(!c||a<=0||s<=0)return;let l=e.paint.thickness,u=(this.sprayRemainder.get(t)??0)+a*(9+(1-l)*7)*(c.material?.spray??.5),d=Math.min(24,Math.floor(u));this.sprayRemainder.set(t,u-Math.floor(u));for(let e of te(n,r,i,d,o,l)){let t=1+e.angularity*1.7,n={x:e.x,y:e.y};this.marks.push({from:n,point:n,angle:Math.atan2(r.y,r.x),widthM:e.radius*2*t/(s*.76),color:c.color,opacity:c.opacity*e.opacity,droplet:{aspect:(.5+Math.random()*.45)/t}}),this.markCount++}this.marks.length>3e4&&this.marks.splice(0,1e3)}trackWet(e,t,n,r,i,a=0,s=!1){let c=this.coating(e);if(!c){this.pauseTrack(e);return}let l=this.previous.get(e),u=this.wetPaths.get(e);if(!u||!l||o(f(t,l))>=1.5*i)u={marks:[],distanceM:0},this.wetPaths.set(e,u),s&&(this.marks.push({...c,from:{...t},point:{...t},angle:n,widthM:r,phaseM:this.travelM.get(e)??0,slip:d(a,0,1),overPuddle:!0}),this.markCount++);else{let p=u.marks.at(-1),m=p&&o(f(p.point,p.from))/i<.02,h=m?p.from:l;m&&(u.distanceM-=o(f(p.point,p.from))/i);let g=o(f(t,h))/i,_={...c,from:{...h},point:{...t},angle:n,widthM:r,phaseM:(this.travelM.get(e)??0)-g,slip:d(a,0,1)};m?u.marks[u.marks.length-1]=_:u.marks.push(_),u.distanceM+=g,s&&g>=.02&&(this.marks.push({..._,overPuddle:!0}),this.markCount++,this.marks.length>3e4&&this.marks.splice(0,1e3));let v=Math.max(.5,r*6);for(;u.marks.length>1&&(u.distanceM>v||u.marks.length>128);){let e=u.marks.shift();u.distanceM-=o(f(e.point,e.from))/i}}this.exits.delete(e),this.previous.set(e,{...t}),this.previousLayer.set(e,!1)}pauseTrack(e){this.wetPaths.delete(e),this.exits.delete(e),this.previous.delete(e),this.previousLayer.delete(e)}track(e,t,n,r,i,a=!1,s=0){let c=this.coating(e);if(!c)return;let l=this.previous.get(e),u=l?o(f(t,l)):0,p=this.wetPaths.has(e)||this.exits.has(e)?.01:.05;if(l&&u<p*i)return;let m=l&&u<1.5*i,h=this.wetPaths.get(e);if(h&&m){let t=Math.max(.35,r*(2+4*(c.material?.film??.6))),n=-h.distanceM;for(let e of h.marks){let r=n+o(f(e.point,e.from))/i;this.marks.push({...e,overPuddle:!1,exit:{fromM:n,toM:r,lengthM:t,leadInM:h.distanceM}}),this.markCount++,n=r}this.exits.set(e,{distanceM:0,lengthM:t})}else m||this.exits.delete(e);this.wetPaths.delete(e);let g=this.exits.get(e),_=g&&g.distanceM<g.lengthM?{fromM:g.distanceM,toM:g.distanceM+u/i,lengthM:g.lengthM}:void 0;g&&(g.distanceM+=u/i,g.distanceM>=g.lengthM&&this.exits.delete(e)),this.marks.push({from:m?{...l}:{...t},point:{...t},angle:n,widthM:r,phaseM:(this.travelM.get(e)??0)-(m?o(f(t,l))/i:0),wetness:c.wetness,material:c.material,slip:d(s,0,1),color:c.color,opacity:c.opacity,overPuddle:a,exit:_}),this.markCount++,this.previous.set(e,{...t}),this.previousLayer.set(e,a),this.marks.length>3e4&&this.marks.splice(0,1e3)}coating(e){let t=this.coatings.get(e);if(!t?.size)return null;let n=[...t.values()].map(e=>({color:e.color,strength:e.opacity*d(e.remaining/e.distanceM,0,1)})),r=[...t.values()].sort((e,t)=>t.opacity*t.remaining/t.distanceM-e.opacity*e.remaining/e.distanceM)[0],i=d(r.remaining/r.distanceM,0,1);return{material:r.material,wetness:i,color:Tn(n),opacity:Math.max(...n.map(e=>e.strength))*i**+Math.max(0,(r.material?.drain??1)-1),remaining:Math.max(...[...t.values()].map(e=>e.remaining)),distanceM:Math.max(...[...t.values()].map(e=>e.distanceM))}}},Z={opening:.32,raising:.52,igniting:.48,closing:.36},Dn=class{previewOpen=!1;inspecting=!1;phase=`idle`;elapsed=0;held=!1;presetId=null;flights=[];launchClock=0;queuedShots=0;launches=0;ignitionDuration=Z.igniting;captureState(){return a({previewOpen:this.previewOpen,inspecting:this.inspecting,phase:this.phase,elapsed:this.elapsed,held:this.held,presetId:this.presetId,flights:this.flights,launchClock:this.launchClock,queuedShots:this.queuedShots,launches:this.launches,ignitionDuration:this.ignitionDuration})}restoreState(e){let t=a(e);this.previewOpen=t.previewOpen,this.inspecting=t.inspecting,this.phase=t.phase,this.elapsed=t.elapsed,this.held=t.held,this.presetId=t.presetId,this.flights=t.flights,this.launchClock=t.launchClock,this.queuedShots=t.queuedShots,this.launches=t.launches,this.ignitionDuration=t.ignitionDuration}get state(){return this.phase}get projectile(){let e=this.flights[0];return e?{...e,position:{...e.position}}:null}get projectileCount(){return this.flights.length}get managedBytes(){return this.flights.length*64}get launchCount(){return this.launches}reset(){this.previewOpen=!1,this.inspecting=!1,this.phase=`idle`,this.elapsed=0,this.held=!1,this.flights=[],this.launchClock=0,this.queuedShots=0,this.launches=0,this.ignitionDuration=Z.igniting,this.presetId=null}disarm(){this.held=!1,this.queuedShots=0,(this.phase===`opening`||this.phase===`raising`||this.phase===`igniting`)&&this.transition(`closing`)}transition(e){this.phase=e,this.elapsed=0}step(e,t,n,r,i,a,o,s){if(t.mode!==`car`){this.reset();return}if(this.presetId&&this.presetId!==t.car.preset.id&&this.reset(),this.previewOpen){this.inspecting=!0,this.presetId=t.car.preset.id,(this.phase===`idle`||this.phase===`closing`)&&this.transition(`opening`),this.elapsed+=e,this.phase===`opening`&&this.elapsed>=Z.opening&&this.transition(`raising`),this.phase===`raising`&&(this.elapsed=Math.min(this.elapsed,Z.raising));return}this.inspecting&&(this.inspecting=!1,this.transition(`closing`));let f=!!t.lastInput.rocket;f&&!this.held&&(this.queuedShots++,(this.phase===`idle`||this.phase===`closing`)&&(this.presetId=t.car.preset.id,this.transition(`opening`))),this.held=f;let h=g(t.car.preset);if(this.phase===`idle`&&!this.flights.length)return;this.elapsed+=e,this.launchClock+=e;let _=t.car.preset.roofRocket,v=Math.max(1.05,_.sizeM*1.12);if(this.phase===`opening`&&this.elapsed>=Z.opening)this.transition(`raising`);else if(this.phase===`raising`&&this.elapsed>=Z.raising)this.ignitionDuration=Z.igniting,this.transition(`igniting`),s?.(t.body.world(m(_.xM,_.yM)));else if(this.phase===`igniting`&&this.elapsed>=this.ignitionDuration){let e=c(m(1,0),t.body.angle),n=t.body.world(m(_.xM,_.yM));this.flights.push({position:n,angle:t.body.angle,speedMps:h.launchSpeedMps+Math.max(0,l(t.body.velocity,e)),distanceM:0,age:0}),this.launches++,a?.(n),this.queuedShots=Math.max(0,this.queuedShots-1),this.launchClock=0,this.transition(`flying`)}else this.phase===`closing`&&this.elapsed>=Z.closing&&this.transition(`idle`);if(this.phase===`igniting`){let r=d(this.elapsed/Math.min(.27,this.ignitionDuration*.65),0,.9),a=c(m(-1,0),t.body.angle),o=t.body.world(m(_.xM-v*.52,_.yM));n({point:o,flow:u(a,3.5),amount:e*14*r,radiusM:.2}),i?.({from:o,to:o,flow:u(a,12),widthM:.16,intensity:r*.75})}this.phase===`flying`&&(!f&&this.queuedShots===0?this.transition(`closing`):this.launchClock>=Math.max(0,1/h.roundsPerSecond-Math.min(Z.igniting,.7/h.roundsPerSecond))&&(this.ignitionDuration=Math.min(Z.igniting,.7/h.roundsPerSecond),this.transition(`igniting`),s?.(t.body.world(m(_.xM,_.yM)))));for(let t=this.flights.length-1;t>=0;t--){let a=this.flights[t],s=c(m(1,0),a.angle);a.speedMps=Math.min(h.maxSpeedMps,a.speedMps+h.accelerationMps2*e);let l=a.speedMps*e,d=a.position,f=p(d,u(s,l)),g=r?.(d,f,_.sizeM*.18);a.position=g??f,a.distanceM+=l,a.age+=e;let y=p(a.position,u(s,-v*.53)),b=p(d,u(s,-v*.53));if(n({point:y,flow:u(s,-5),amount:e*h.smokePerSecond,radiusM:.2}),i?.({from:b,to:y,flow:u(s,-18),widthM:.13,intensity:.9}),g){o?.(g);for(let e=0;e<7;e++){let t=c(m(1,0),e*Math.PI*2/7);n({point:g,flow:u(t,5.5),amount:.18,radiusM:.22})}this.flights.splice(t,1)}else(a.age>=h.lifetimeSeconds||a.distanceM>100)&&this.flights.splice(t,1)}this.phase===`closing`&&this.elapsed>=Z.closing&&this.transition(`idle`)}get open(){return this.phase===`idle`?0:this.phase===`opening`?d(this.elapsed/Z.opening,0,1):this.phase===`closing`?1-d(this.elapsed/Z.closing,0,1):1}drawMount(e,t,n,r,i,a=1,o){let s=this.open;if(s<=0)return;ee();let c=r.roofRocket,l=c.sizeM*i,u=s*s*(3-2*s);e.save(),e.translate(t.x,t.y),e.rotate(-n),e.translate(c.xM*i,-c.yM*i),e.globalAlpha*=a;let f=e.createLinearGradient(0,-l/2,0,l/2);f.addColorStop(0,`#11171b`),f.addColorStop(.45,`#030609`),f.addColorStop(1,`#222a2e`),e.fillStyle=f,e.beginPath(),e.roundRect(-l/2,-l/2,l,l,l*.06),e.fill(),e.strokeStyle=`#525c62`,e.lineWidth=Math.max(.45,i*.018),e.stroke();for(let t of[-1,1]){e.fillStyle=`#687279`,e.fillRect(-l*.42,t*l*.2,l*.84,l*.035),e.fillStyle=`#161d22`,e.fillRect(-l*.34,-l*.28,l*.065,l*.56);let n=l*.5*(1-u*.78),r=t*(l*.25+u*l*.22);if(e.save(),e.translate(0,r),e.shadowColor=`rgba(0,0,0,.55)`,e.shadowBlur=l*.08,e.shadowOffsetY=l*.035,e.fillStyle=c.panelColor,e.beginPath(),e.roundRect(-l/2,-n/2,l,n,l*.035),e.fill(),e.shadowBlur=0,e.shadowOffsetY=0,o){e.save(),e.clip();let r=o.source.x+(c.xM-c.sizeM/2+o.lengthM/2)/o.lengthM*o.source.width,i=o.source.y+(-c.yM+(t<0?-c.sizeM/2:0)+o.widthM/2)/o.widthM*o.source.height;e.drawImage(o.image,r,i,c.sizeM/o.lengthM*o.source.width,c.sizeM/2/o.widthM*o.source.height,-l/2,-n/2,l,n),e.restore()}e.strokeStyle=`rgba(8,13,17,.7)`,e.lineWidth=Math.max(.45,i*.018),e.stroke(),e.restore()}if(this.phase===`raising`||this.phase===`igniting`){let t=this.phase===`igniting`?1:d(this.elapsed/Z.raising,0,1);e.save(),e.globalAlpha*=t,e.scale(.35+t*.65,.35+t*.65),this.drawBody(e,Math.max(1.05,c.sizeM*1.12)*i,1),e.restore()}e.restore()}drawFlight(e,t,n,r,i=1){for(let a of this.flights){let o=t(a.position);e.save(),e.translate(o.x,o.y),e.rotate(-a.angle),e.globalAlpha=i,this.drawBody(e,Math.max(1.05,n.roofRocket.sizeM*1.12)*r,1),e.restore()}}drawBody(e,t,n){if(e.save(),e.globalAlpha*=n,e.shadowColor=`rgba(0,0,0,.5)`,e.shadowBlur=t*.055,e.shadowOffsetY=t*.025,!b(e,`rocket`,-t*.53,0,t*1.06)){let n=e.createLinearGradient(0,-t*.045,0,t*.045);n.addColorStop(0,`#3b454d`),n.addColorStop(.35,`#d8dddc`),n.addColorStop(1,`#3e484f`),e.fillStyle=n,e.beginPath(),e.moveTo(-t*.53,-t*.045),e.lineTo(t*.3,-t*.045),e.lineTo(t*.53,0),e.lineTo(t*.3,t*.045),e.lineTo(-t*.53,t*.045),e.closePath(),e.fill(),e.fillStyle=`#30383e`;for(let n of[-1,1])e.beginPath(),e.moveTo(-t*.48,n*t*.12),e.lineTo(-t*.22,n*t*.04),e.lineTo(-t*.44,n*t*.04),e.closePath(),e.fill()}e.restore()}},On=.22,kn=.24,An=class{phase=`closed`;phaseTime=0;shotClock=0;flashAge=1/0;presetId=null;bullets=[];captureState(){return a({phase:this.phase,phaseTime:this.phaseTime,shotClock:this.shotClock,flashAge:this.flashAge,presetId:this.presetId,bullets:this.bullets})}restoreState(e){let t=a(e);this.phase=t.phase,this.phaseTime=t.phaseTime,this.shotClock=t.shotClock,this.flashAge=t.flashAge,this.presetId=t.presetId,this.bullets=t.bullets}get state(){return this.phase}get openAmount(){return this.open}get projectileCount(){return this.bullets.length}get managedBytes(){return this.bullets.length*56}reset(){this.phase=`closed`,this.phaseTime=0,this.shotClock=0,this.flashAge=1/0,this.presetId=null,this.bullets=[]}step(e,t,n,r,i){if(t.mode!==`car`){this.reset();return}this.presetId&&this.presetId!==t.car.preset.id&&this.reset();let a=h(t.car.preset),o=!!t.lastInput.machineGun;if(o&&(this.phase===`closed`||this.phase===`closing`)){this.presetId=t.car.preset.id;let e=this.open;this.phase=`opening`,this.phaseTime=e*On}else if(!o&&(this.phase===`opening`||this.phase===`active`)){let e=this.open;this.phase=`closing`,this.phaseTime=(1-e)*kn}if(this.phaseTime+=e,this.flashAge+=e,this.phase===`opening`&&this.phaseTime>=On&&(this.phase=`active`,this.phaseTime=0,this.shotClock=1/a.roundsPerSecond),this.phase===`active`){if(o){let n=1/Math.max(1,a.roundsPerSecond);this.shotClock+=e;for(let e=0;this.shotClock>=n&&e<4;e++)this.shotClock-=n,this.fire(t),r?.()}}else this.phase===`closing`&&this.phaseTime>=kn&&(this.phase=`closed`,this.phaseTime=0);for(let t=this.bullets.length-1;t>=0;t--){let r=this.bullets[t],o=r.position,s=p(o,u(r.velocity,e)),c=n?.(o,s,.075);r.age+=e,c||r.age>=a.bulletLifetimeSeconds?(c&&i?.(c,r.velocity),this.bullets.splice(t,1)):r.position=s}}fire(e){let t=h(e.car.preset),n=c(m(1,0),e.body.angle);for(let r of[-1,1]){let i=e.body.world(x(e.car.preset,r)),a=p(u(n,t.bulletSpeedMps),e.body.velocityAt(i));this.bullets.push({position:i,velocity:a,age:0})}this.flashAge=0}get open(){return this.phase===`closed`?0:this.phase===`opening`?d(this.phaseTime/On,0,1):this.phase===`closing`?1-d(this.phaseTime/kn,0,1):1}drawMount(e,t,n,r,i,a=1,o){S(e,t,n,r,i,this.open,`gun`,Math.max(0,1-this.flashAge/.075),a,o)}drawProjectiles(e,t,n,r=1){e.save(),e.lineCap=`round`;for(let i of this.bullets){let a=t(i.position),o=Math.hypot(i.velocity.x,i.velocity.y),s=t(p(i.position,u(i.velocity,-.75/Math.max(1,o)))),c=e.createLinearGradient(s.x,s.y,a.x,a.y);c.addColorStop(0,`rgba(224,153,63,0)`),c.addColorStop(.7,`rgba(224,153,63,.25)`),c.addColorStop(1,`rgba(255,225,157,.7)`),e.globalAlpha=r,e.strokeStyle=c,e.lineWidth=Math.max(.65,n*.025),e.beginPath(),e.moveTo(s.x,s.y),e.lineTo(a.x,a.y),e.stroke();let l=t(p(i.position,u(i.velocity,-.09/Math.max(1,o))));e.strokeStyle=`#fff6d7`,e.lineWidth=Math.max(.55,n*.018),e.beginPath(),e.moveTo(l.x,l.y),e.lineTo(a.x,a.y),e.stroke()}e.restore()}},jn=.22,Mn=.24,Q=1/45,Nn=class{phase=`closed`;phaseTime=0;emitting=!1;presetId=null;fireClock=0;jets=[];captureState(){return a({phase:this.phase,phaseTime:this.phaseTime,emitting:this.emitting,presetId:this.presetId,fireClock:this.fireClock,jets:this.jets})}restoreState(e){let t=a(e);this.phase=t.phase,this.phaseTime=t.phaseTime,this.emitting=t.emitting,this.presetId=t.presetId,this.fireClock=t.fireClock,this.jets=t.jets}get state(){return this.phase}get firing(){return this.emitting}get openAmount(){return this.open}get managedBytes(){return this.jets.length*64}reset(){this.phase=`closed`,this.phaseTime=0,this.emitting=!1,this.presetId=null,this.fireClock=0,this.jets=[]}step(e,t,n,r,i){if(t.mode!==`car`){(this.phase!==`closed`||this.jets.length)&&this.reset();return}this.presetId&&this.presetId!==t.car.preset.id&&this.reset();let a=!!t.lastInput.flamethrower,o=_(t.car.preset);if(a&&(this.phase===`closed`||this.phase===`closing`)){this.presetId=t.car.preset.id;let e=this.open;this.phase=`opening`,this.phaseTime=e*jn}else if(!a&&(this.phase===`opening`||this.phase===`active`)){let e=this.open;this.phase=`closing`,this.phaseTime=(1-e)*Mn}if(this.phaseTime+=e,this.phase===`opening`&&this.phaseTime>=jn&&(this.phase=`active`,this.phaseTime=0,this.fireClock=Q),this.emitting=this.phase===`active`&&a,this.phase===`closing`&&this.phaseTime>=Mn&&(this.phase=`closed`,this.phaseTime=0),this.emitting){let r=c(m(1,0),t.body.angle),i=o.rangeM/.3;for(this.fireClock+=e;this.fireClock>=Q;){this.fireClock-=Q;for(let e of[-1,1]){let n=t.body.world(x(t.car.preset,e));this.jets.push({point:n,velocity:p(u(r,i),u(t.body.velocity,.25)),traveled:0,range:o.rangeM,speed:i,width:o.jetWidthM*o.flowRate})}}for(let i of[-1,1]){let a=t.body.world(x(t.car.preset,i));n({point:p(a,u(r,.06)),flow:u(r,5.5),amount:e*o.smokePerSecond*o.flowRate*.38,radiusM:.12})}}let s=[];for(let t of this.jets){let a=Math.min(t.range-t.traveled,t.speed*e),c=t.point,l=p(c,u(t.velocity,a/t.speed)),d=(t.traveled+a)/t.range,f=t.width*(.65+1.45*d),m=r?.(c,l,Math.max(.3,f*1.25),Q*o.flowRate),h=m??l;t.point=h,t.traveled+=a,i?.(c,h,f,t.velocity,d),(d>.62||m)&&n({point:h,flow:u(t.velocity,.42),amount:e*o.smokePerSecond*o.flowRate*(m?.42:.18),radiusM:Math.max(.11,f*.48)}),m?i?.(h,h,f*1.35,t.velocity,d):t.traveled+1e-6<t.range&&s.push(t)}this.jets=s}get open(){return this.phase===`closed`?0:this.phase===`opening`?d(this.phaseTime/jn,0,1):this.phase===`closing`?1-d(this.phaseTime/Mn,0,1):1}drawMount(e,t,n,r,i,a=1,o){S(e,t,n,r,i,this.open,`flame`,this.phase===`active`?.8:0,a,o)}},Pn=class{rocket=new Dn;machineGuns=new An;flamethrower=new Nn;lightning=new ne;reset(){this.rocket.reset(),this.machineGuns.reset(),this.flamethrower.reset(),this.lightning.reset()}stopFiring(){this.rocket.disarm(),this.lightning.reset()}captureState(){return{rocket:this.rocket.captureState(),machineGuns:this.machineGuns.captureState(),flamethrower:this.flamethrower.captureState(),lightning:this.lightning.captureState()}}restoreState(e){this.rocket.restoreState(e.rocket),this.machineGuns.restoreState(e.machineGuns),this.flamethrower.restoreState(e.flamethrower),e.lightning?this.lightning.restoreState(e.lightning):this.lightning.reset()}get managedBytes(){return this.rocket.managedBytes+this.machineGuns.managedBytes+this.flamethrower.managedBytes}},$=e=>({...e,slots:e.slots?[...e.slots]:void 0,slotPresses:e.slotPresses?[...e.slotPresses]:void 0}),Fn=mn({types:{events:{}}}).createMachine({id:`vehicleLifecycle`,initial:`drivable`,states:{drivable:{on:{DESTROYED:`destroyed`}},destroyed:{on:{RESPAWNED:`drivable`}}}}),In=class{id;sim;damage=new gn;weapons=new Pn;tirePaint=new En;pickupEffect=new _n;lifecycle=A(Fn).start();controls={throttle:0,steer:0,action:!1};controlSource=`player`;label=``;appearance=`auto`;slotConfiguration=r;toolPolicy={};numberedSlots=y(r);slotHeld=new Set;slotPulses=new Set;slotPresses=new Set;blockedSlots=new Set;disposed=!1;previousSlotInput=new Set;activeEmitters=[];get slots(){return this.slotConfiguration}set slots(e){if(this.disposed)throw Error(`Vehicle is disposed.`);let t=i(e);this.clearSlotInput(),this.slotConfiguration=t,this.numberedSlots=y(t,this.toolPolicy)}liquidEmissions(e){return!this.sim.lastInput.eject||this.isGhost||this.lifecycleState!==`drivable`?[]:this.activeEmitters.map(({slot:t,liquid:n,pulse:r,rate:i,amount:a})=>({slot:t,liquid:n,amount:r?a:Math.max(0,e)*i})).filter(e=>e.amount>0)}useSlot(e){let t=n(e);return this.disposed||!this.numberedSlots[t-1]||this.lifecycleState!==`drivable`?!1:(this.slotPulses.add(t),!0)}startSlot(e){let t=n(e);return this.disposed||!this.numberedSlots[t-1]||this.lifecycleState!==`drivable`?!1:(this.slotHeld.has(t)||this.slotPresses.add(t),this.slotHeld.add(t),!0)}stopSlot(e){this.slotHeld.delete(n(e))}clearSlotInput(){this.slotHeld.clear(),this.slotPulses.clear(),this.slotPresses.clear(),this.blockedSlots.clear(),this.previousSlotInput.clear(),this.activeEmitters=[]}resolveSlots(e){let t=new Set((e.slots??[]).map(n)),r=new Set((e.slotPresses??[]).map(n));for(let e of this.blockedSlots)!t.has(e)&&!r.has(e)?this.blockedSlots.delete(e):(t.delete(e),r.delete(e));let i=new Set([...this.slotHeld,...t]),a=new Set([...this.slotPresses,...r]),o=$(e);this.activeEmitters=[];for(let{number:e,slot:t}of this.numberedSlots){let n=i.has(e)&&!this.previousSlotInput.has(e),r=this.slotPulses.has(e)||(t.activation===`tap`?n||a.has(e):a.has(e)&&!i.has(e));(r||t.activation!==`tap`&&i.has(e))&&(t.action===`eject`?(o.eject=!0,this.activeEmitters.push({slot:e,liquid:t.liquid,pulse:r,rate:t.rate??6,amount:t.amount??.65})):o[t.action]=!0)}if(e.eject&&!this.activeEmitters.length){for(let{number:e,slot:t}of this.numberedSlots)if(t.action===`eject`){this.activeEmitters.push({slot:e,liquid:t.liquid,pulse:!1,rate:t.rate??6,amount:t.amount??.65});break}}return this.previousSlotInput=i,o}constructor(e,t){this.id=e,this.sim=t}get lifecycleState(){return this.lifecycle.getSnapshot().value}get isGhost(){return this.sim.mode===`car`&&this.lifecycleState===`drivable`&&!!this.controls.ghost}setControls(e,t,r={}){if(r.toolsEnabled!==this.toolPolicy.toolsEnabled){let t=y(this.slotConfiguration,r);if(t.length!==this.numberedSlots.length||t.some(({source:e},t)=>e!==this.numberedSlots[t].source)){this.clearSlotInput();for(let t of[...e.slots??[],...e.slotPresses??[]])this.blockedSlots.add(n(t))}this.toolPolicy=r,this.numberedSlots=t}this.controls=v(this.resolveSlots(e),r.toolsEnabled),this.controlSource=t}step(e,t,n=!1){this.pickupEffect.step(e),n?this.sim.lastInput={throttle:0,steer:0,action:!1,boost:!1}:this.sim.tick(this.lifecycleState===`drivable`?this.controls:{throttle:0,steer:0,action:!1},e,t),this.weapons.lightning.step(e,!n&&!!this.sim.lastInput.lightning&&this.lifecycleState===`drivable`,re(this.sim.car.preset).chargeSeconds),this.slotPulses.clear(),this.slotPresses.clear()}synchronizeLifecycle(){let e=this.sim.car.explodedAt!==null;e&&this.lifecycleState===`drivable`?(this.lifecycle.send({type:`DESTROYED`}),this.weapons.stopFiring(),this.clearSlotInput(),this.sim.lastInput={throttle:0,steer:0,action:!1,boost:!1}):!e&&this.lifecycleState===`destroyed`&&this.lifecycle.send({type:`RESPAWNED`})}reset(){this.clearSlotInput(),this.sim.reset(),this.damage.reset(),this.weapons.reset(),this.tirePaint.reset(),this.pickupEffect.reset(),this.synchronizeLifecycle()}restoreHealth(){this.sim.car.resetBurnable(),this.synchronizeLifecycle()}setMode(e){this.clearSlotInput(),this.sim.setMode(e),this.damage.reset(),this.weapons.reset(),this.tirePaint.reset(),this.pickupEffect.reset(),this.synchronizeLifecycle()}setPreset(e){this.clearSlotInput(),this.sim.setPreset(e),this.damage.reset(),this.weapons.reset(),this.tirePaint.reset(),this.pickupEffect.reset(),this.synchronizeLifecycle()}advanceBurn(e){if(this.sim.mode!==`car`)return null;let{car:t}=this.sim;t.advanceBurn(e),this.synchronizeLifecycle();let n=t.stage;if(n===`intact`)return null;let r=!1,i=!1;this.lifecycleState===`destroyed`&&(t.blastQueued||(t.blastQueued=!0,r=!0),t.blastAge+=e,t.blastAge<.36&&t.blastAge-t.lastBlastEmission>=1/30&&(i=!0,t.lastBlastEmission=t.blastAge));let a={stage:n,health:t.health,maxHealth:t.maxHealth,key:t,burnOriginLocal:{...t.burnOriginLocal},blastAge:t.blastAge,explosionStarted:r,blastPulse:i};return this.lifecycleState===`destroyed`&&t.blastAge>=s.respawnSeconds&&(this.sim.resetAtCurrentPose(),this.damage.reset(),this.synchronizeLifecycle()),a}captureState(){return{id:this.id,label:this.label,appearance:this.appearance,slots:structuredClone(this.slots),slotHeld:[...this.slotHeld],slotPulses:[...this.slotPulses],slotPresses:[...this.slotPresses],blockedSlots:[...this.blockedSlots],previousSlotInput:[...this.previousSlotInput],activeEmitters:this.activeEmitters.map(e=>({...e})),simulation:this.sim.captureState(),damage:this.damage.captureState(),weapons:this.weapons.captureState(),tirePaint:this.tirePaint.captureState(),pickupEffect:this.pickupEffect.captureState(),controls:$(this.controls),controlSource:this.controlSource,lifecycle:this.lifecycle.getPersistedSnapshot()}}restoreState(e){if(e.id!==this.id)throw Error(`Checkpoint vehicle does not match`);this.label=e.label,this.appearance=e.appearance,this.slots=structuredClone(e.slots),this.slotHeld=new Set(e.slotHeld),this.slotPulses=new Set(e.slotPulses),this.slotPresses=new Set(e.slotPresses),this.blockedSlots=new Set(e.blockedSlots),this.previousSlotInput=new Set(e.previousSlotInput),this.activeEmitters=e.activeEmitters.map(e=>({...e})),this.sim.restoreState(e.simulation),this.damage.restoreState(e.damage),this.weapons.restoreState(e.weapons),this.tirePaint.restoreState(e.tirePaint),this.pickupEffect.restoreState(e.pickupEffect),this.controls=$(e.controls),this.controlSource=e.controlSource,this.lifecycle.stop(),this.lifecycle=A(Fn,{snapshot:e.lifecycle}).start()}dispose(){this.disposed=!0,this.pickupEffect.reset(),this.clearSlotInput(),this.lifecycle.stop()}};export{gn as n,In as t};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./definitions~index~embed~vehicle-popover~browser-session-core~renderer-RDNEXk_b.js";import{a as t,i as n,l as r,o as i,s as a,u as o}from"./runtime~index~embed~vehicle-popover~browser-session-core~renderer-YuWj6rHi.js";import{i as s}from"./configuration~index~embed~bookmarklet-BH7GyoGh.js";function c(e,t,n){let r=e.image?.crop??{x:0,y:0,width:1,height:1},i={x:r.x*t,y:r.y*n,width:r.width*t,height:r.height*n},a=i.width/i.height,o=e.geometry,s=o.lengthM/o.widthM,c=e.image?.scale??1;return{source:i,lengthM:(a>s?o.lengthM:o.widthM*a)*c,widthM:(a>s?o.lengthM/a:o.widthM)*c}}function l(e,t){let n=1/0,r=-1/0,i=1/0,a=-1/0,o=2*t.halfLength/e.columns,s=2*t.halfWidth/e.rows,c=Math.max(o,s)*.5;for(let c=0;c<e.rows;c++){let l=(c+.5)*s-t.halfWidth;for(let s=0;s<e.columns;s++){if(!e.solid[c*e.columns+s])continue;let u=(s+.5)*o-t.halfLength,d=t.center.x+t.forward.x*u+t.side.x*l,f=t.center.y+t.forward.y*u+t.side.y*l;n=Math.min(n,d),r=Math.max(r,d),i=Math.min(i,f),a=Math.max(a,f)}}return Number.isFinite(n)?{x:n-c,y:i-c,width:r-n+c*2,height:a-i+c*2}:{x:t.center.x,y:t.center.y,width:0,height:0}}function u(e,t,i){let o=-1/0,s=t.center;for(let c=0;c<e.rows;c++){let l=(2*(c+.5)/e.rows-1)*t.halfWidth;for(let u=0;u<e.columns;u++){if(!e.solid[c*e.columns+u])continue;let d=(2*(u+.5)/e.columns-1)*t.halfLength,f=a(t.center,a(r(t.forward,d),r(t.side,l))),p=n(f,i);p>o&&(o=p,s=f)}}return{...s}}var d=(e,t,n)=>{let{columns:r,rows:i,solid:a}=e,o=n*r+t;return!!a[o]&&(t===0||t===r-1||n===0||n===i-1||!a[o-1]||!a[o+1]||!a[o-r]||!a[o+r])};function f(e,t,n){let i=1/0,o=t.center;for(let s=0;s<e.rows;s++){let c=(2*(s+.5)/e.rows-1)*t.halfWidth;for(let l=0;l<e.columns;l++){if(!d(e,l,s))continue;let u=(2*(l+.5)/e.columns-1)*t.halfLength,f=a(t.center,a(r(t.forward,u),r(t.side,c))),p=Math.max(n.x-f.x,0,f.x-n.x-n.width),m=Math.max(n.y-f.y,0,f.y-n.y-n.height),h=p*p+m*m+(p||m?0:Math.min(f.x-n.x,n.x+n.width-f.x,f.y-n.y,n.y+n.height-f.y)**2);h<i&&(i=h,o=f)}}return{...o}}function p(e,t,r){let a=i(r,t.center),o=n(a,t.forward)/t.halfLength,s=n(a,t.side)/t.halfWidth,c=Math.floor((o+1)*e.columns/2),l=Math.floor((s+1)*e.rows/2);return c>=0&&c<e.columns&&l>=0&&l<e.rows&&!!e.solid[l*e.columns+c]}function m(e,t,n){if(t.halfLength<=0||t.halfWidth<=0||Math.abs(n.halfX.x*n.halfY.y-n.halfX.y*n.halfY.x)<1e-4)return 0;let r=0;for(let i=0;i<16;i++){let a=2*(i+.5)/16-1;for(let i=0;i<16;i++){let o=2*(i+.5)/16-1;p(e,t,{x:n.center.x+n.halfX.x*o+n.halfY.x*a,y:n.center.y+n.halfX.y*o+n.halfY.y*a})&&r++}}return r/256}function h(e,t,o){let s=t.halfLength*2/e.columns,c=t.halfWidth*2/e.rows,l=t.forward,u=t.side,d=Number(p(e,t,a(o,r(l,-s))))-Number(p(e,t,a(o,r(l,s)))),f=Number(p(e,t,a(o,r(u,-c))))-Number(p(e,t,a(o,r(u,c)))),m=a(r(l,d),r(u,f)),h=Math.hypot(m.x,m.y);if(h>.001)return r(m,1/h);let g=i(o,t.center),_=a(r(l,n(g,l)/Math.max(s,t.halfLength)),r(u,n(g,u)/Math.max(c,t.halfWidth))),v=Math.hypot(_.x,_.y);return v>.001?r(_,1/v):{...l}}function g(e,t,r){if(r.width<=0||r.height<=0||t.halfLength<=0||t.halfWidth<=0)return!1;let a=[o(r.x,r.y),o(r.x+r.width,r.y),o(r.x,r.y+r.height),o(r.x+r.width,r.y+r.height)].map(e=>{let r=i(e,t.center);return o(n(r,t.forward),n(r,t.side))}),s=e.columns,c=e.rows,l=(e,t,n)=>Math.floor((e/t+1)*n/2),u=Math.max(0,l(Math.min(...a.map(e=>e.x)),t.halfLength,s)-1),d=Math.min(s-1,l(Math.max(...a.map(e=>e.x)),t.halfLength,s)+1),f=Math.max(0,l(Math.min(...a.map(e=>e.y)),t.halfWidth,c)-1),p=Math.min(c-1,l(Math.max(...a.map(e=>e.y)),t.halfWidth,c)+1);if(u>d||f>p)return!1;let m=Math.min(1,Math.max(t.halfLength/s,t.halfWidth/c));for(let n=f;n<=p;n++)for(let i=u;i<=d;i++){if(!e.solid[n*s+i])continue;let a=(2*(i+.5)/s-1)*t.halfLength,o=(2*(n+.5)/c-1)*t.halfWidth,l=t.center.x+t.forward.x*a+t.side.x*o,u=t.center.y+t.forward.y*a+t.side.y*o;if(l>=r.x-m&&l<=r.x+r.width+m&&u>=r.y-m&&u<=r.y+r.height+m)return!0}return!1}function _(e,t,n,i,o){if(!g(e,t,n))return 0;let s=0,c=Math.max(1,o);for(let o=0;o<3&&g(e,{...t,center:a(t.center,r(i,c))},n);o++)c*=2;for(let o=0;o<10;o++){let o=(s+c)/2;g(e,{...t,center:a(t.center,r(i,o))},n)?s=o:c=o}return c+.25}var v=class{loaded=new Map;pending=new Set;failed=new Set;fallback=new Map;keys=new WeakMap;assembled=new WeakMap;forPreset(e){let t=this.assembled.get(e);if(t)return t;let n=e.image?.src;if(n){let t=this.keys.get(e);t||(t=`${n}|${JSON.stringify(e.image?.crop??null)}`,this.keys.set(e,t));let r=this.loaded.get(t);if(r){let t=c(e,r.imageWidth,r.imageHeight),n={alpha:r,lengthM:t.lengthM,widthM:t.widthM};return this.assembled.set(e,n),n}!this.pending.has(t)&&!this.failed.has(t)&&this.load(t,n,e)}let r=`${e.geometry.lengthM}:${e.geometry.widthM}`,i=this.fallback.get(r);i||(i={columns:96,rows:48,solid:new Uint8Array(4608).fill(1)},this.fallback.set(r,i));let a={alpha:i,lengthM:e.geometry.lengthM,widthM:e.geometry.widthM};return(!n||this.failed.has(this.keys.get(e)??``))&&this.assembled.set(e,a),a}load(e,t,n){this.pending.add(e);let r=new Image;r.crossOrigin=`anonymous`,r.onload=()=>{try{let t=c(n,r.naturalWidth,r.naturalHeight),i=Math.max(24,Math.round(128*t.source.height/t.source.width)),a=document.createElement(`canvas`);a.width=128,a.height=i;let o=a.getContext(`2d`,{willReadFrequently:!0});if(!o)throw Error(`No 2D canvas for vehicle alpha mask`);o.drawImage(r,t.source.x,t.source.y,t.source.width,t.source.height,0,0,128,i);let s=o.getImageData(0,0,128,i).data,l=new Uint8Array(128*i);for(let e=0;e<l.length;e++)l[e]=+(s[e*4+3]>=96);this.loaded.set(e,{columns:128,rows:i,solid:l,imageWidth:r.naturalWidth,imageHeight:r.naturalHeight})}catch{this.failed.add(e)}finally{this.pending.delete(e)}},r.onerror=()=>{this.pending.delete(e),this.failed.add(e)},r.src=t}},ee=e=>({x:e.x*28,y:-e.y*28}),te=e=>({x:e.x/28,y:-e.y/28}),ne=class{masks=new v;events;get totalPoints(){return 0}get managedBytes(){return 0}setEvents(e){this.events=e}prepare(e){this.masks.forPreset(e)}vehicleMask(e,t){let n=this.masks.forPreset(e);return t?t.maskFor(n):n}wallRects(){return[]}beginStep(e,t){}stepVehicle(e,t,n=!1,r,i,a=!1){}endStep(e,t){}forgetVehicle(e){}tirePaintAt(e){return e.map(()=>null)}projectileHit(e,t,n){return null}arcTargets(e,t){return[]}applyAreaImpact(e,t,n){}bulletImpact(e,t,n,r){return this.projectileHit(e,t,n)?.point??null}rocketImpact(e,t,n,r=1,i){return this.projectileHit(e,t,n)?.point??null}flameContact(e,t,n,r,i){return this.projectileHit(e,t,n)?.point??null}burningProximity(e){return 0}draw(e,t,n){}captureState(){return null}restoreState(e){}destroy(){}},re={gun:new URL(`../embed-assets/side-gun-v1-BnpvZN1b.webp`,import.meta.url).href,rocket:new URL(`../embed-assets/roof-rocket-v1-Bs4IEw-s.webp`,import.meta.url).href},ie={gun:.55,rocket:.5},ae=new Map;function oe(e){if(typeof Image>`u`)return null;let t=ae.get(e);return t||(t=new Image,t.decoding=`async`,t.crossOrigin=`anonymous`,t.src=re[e],ae.set(e,t)),t.complete&&t.naturalWidth>0?t:null}function se(){oe(`gun`),oe(`rocket`)}function ce(e,t,n,r,i){let a=oe(t);if(!a)return!1;let o=i*a.naturalHeight/a.naturalWidth;return e.drawImage(a,n,r-o*ie[t],i,o),!0}var y=-.65,le=.35,b=1.04;function ue(e,t){let n=s(e);return{x:n.xM+le,y:t*(e.geometry.widthM/2+n.revealM*.45)}}function de(e,t,n,r,i,a,o=0){if(a<=0)return;let c=a*a*(3-2*a),l=s(t),u=t.geometry.widthM*n/2,d=n*.16*c;e.beginPath(),e.rect((-r/2-o)*n,(-i/2-o)*n,(r+o*2)*n,(i+o*2)*n);for(let t of[-1,1])e.rect((l.xM+y)*n,t>0?-u:u-d,n*b,d);e.clip(`evenodd`)}function fe(e,t,n,r,i,a,o,c=0,l=1,u){if(a<=0)return;se();let d=s(r),f=r.geometry.widthM*i/2,p=a*a*(3-2*a),m=d.revealM*p*i,h=i*.08*(1-p*.7);e.save(),e.translate(t.x,t.y),e.rotate(-n),e.globalAlpha*=l*Math.min(1,a*10);for(let t of[-1,1]){e.save(),e.translate(d.xM*i,-t*f),e.scale(1,-t);let n=e.createLinearGradient(0,-i*.16,0,i*.045);n.addColorStop(0,`#070b0e`),n.addColorStop(.75,`#252d31`),n.addColorStop(1,`rgba(12,18,22,0)`),e.fillStyle=n,e.fillRect(i*y,-i*.16*p,i*b,i*.205*p);let a=Math.max(0,m-h);if(a>0){e.save(),e.beginPath(),e.rect(i*y,0,i*1.34,a),e.clip();for(let t of[-.5,.16]){let n=e.createLinearGradient((t-.02)*i,0,(t+.02)*i,0);n.addColorStop(0,`#1b2227`),n.addColorStop(.45,`#b8c2c7`),n.addColorStop(.6,`#68767d`),n.addColorStop(1,`#242d32`),e.fillStyle=n,e.fillRect((t-.022)*i,0,i*.044,a)}let t=m*.45;e.translate(0,t);let n=o===`gun`?c*i*.018:0;if(e.shadowColor=`rgba(0,0,0,.6)`,e.shadowBlur=i*.045,e.shadowOffsetY=i*.025,!ce(e,`gun`,y*i-n,0,i)){let t=e.createLinearGradient(0,-i*.07,0,i*.07);t.addColorStop(0,`#30383c`),t.addColorStop(.3,`#adb5b6`),t.addColorStop(.55,`#59646a`),t.addColorStop(1,`#141b20`),e.fillStyle=t,e.fillRect(y*i,-i*.085,i*.43,i*.17),e.fillRect(-i*.22,-i*.035,i*.57,i*.07)}if(e.shadowBlur=0,e.shadowOffsetY=0,c>0){e.save(),e.globalAlpha*=c;let t=le*i,n=i*(o===`flame`?.075:.14),r=e.createRadialGradient(t,0,0,t,0,n);r.addColorStop(0,o===`flame`?`#b2d8ff`:`#fffbea`),r.addColorStop(.22,o===`flame`?`#ffb14d`:`#ffcf75`),r.addColorStop(1,`rgba(255,128,24,0)`),e.fillStyle=r,e.fillRect(t-n,-n,n*2,n*2),o===`gun`&&(e.fillStyle=`#fff4c7`,e.beginPath(),e.moveTo(t,-i*.025),e.lineTo(t+i*.19,-i*.008),e.lineTo(t+i*.24,0),e.lineTo(t+i*.19,i*.008),e.lineTo(t,i*.025),e.closePath(),e.fill()),e.restore()}e.restore()}if(e.fillStyle=r.roofRocket.panelColor,e.strokeStyle=`#22292b`,e.lineWidth=Math.max(.8,i*.025),e.beginPath(),e.roundRect(i*y,m-h,i*b,h*2,i*.025),e.fill(),e.stroke(),u){let n=b/u.lengthM*u.source.width,a=.16/u.widthM*u.source.height,o=u.source.x+(d.xM+y+u.lengthM/2)/u.lengthM*u.source.width,s=-t*(r.geometry.widthM/2-.08),c=u.source.y+(s-.08+u.widthM/2)/u.widthM*u.source.height;e.save(),e.scale(1,-t),e.beginPath(),e.roundRect(i*y,-t*m-h,i*b,h*2,i*.025),e.clip(),e.drawImage(u.image,o,c,n,a,i*y,-t*m-h,i*b,h*2),e.restore()}e.restore()}e.restore()}var x=null,S=()=>{x&&(x=null,window.removeEventListener(`scroll`,S))};function pe(){if(x)return x;let e={x:window.scrollX,y:window.scrollY};return typeof window.addEventListener==`function`?(window.addEventListener(`scroll`,S,{passive:!0}),x=e):e}var me=S,C={};function he(e,t={x:0,y:0},n=1){let r=pe();return{x:e.left/n+r.x+t.x,y:e.top/n+r.y+t.y,width:e.width/n,height:e.height/n}}var ge={scale:1,viewportRectToDocument:he},_e=`[data-jr-overlay],[data-jr-ui],[data-jr-touch-controls],[data-jr-embed],script,style,link`,ve=class{scale=1;signature=``;originals=new Map;viewportRectToDocument(e,t={x:0,y:0}){return he(e,t,this.scale)}apply(e,t){let n=pe(),r=`${e}:${t.x}:${t.y}:${n.x}:${n.y}:${document.body.children.length}`;if(r!==this.signature||C.owner!==this){this.signature=r;for(let r of Array.from(document.body.children))if(r instanceof HTMLElement&&!r.matches(_e)){if(!this.originals.has(r)){this.originals.set(r,{translate:r.style.translate,scale:r.style.scale,origin:r.style.transformOrigin});let e=0,t=0;for(let n=r;n;n=n.offsetParent)e+=n.offsetLeft,t+=n.offsetTop;r.style.transformOrigin=`${-e}px ${-t}px`}r.style.scale=String(e),r.style.translate=`${n.x-t.x*e}px ${n.y-t.y*e}px`}this.scale=e,C.owner=this}}clear(){for(let[e,t]of this.originals)e.style.translate=t.translate,e.style.scale=t.scale,e.style.transformOrigin=t.origin;this.originals.clear(),this.signature=``,this.scale=1,C.owner===this&&(C.owner=void 0)}},ye=class{frameStart=null;lastFrame=null;frames=0;fps=0;sample(e){if(!Number.isFinite(e))return this.fps;if(this.frameStart===null||this.lastFrame===null||e-this.lastFrame>1e3||e<=this.lastFrame)return this.frameStart=e,this.lastFrame=e,this.frames=0,this.fps=0,this.fps;this.frames++,this.lastFrame=e;let t=e-this.frameStart;return t>=500&&(this.fps=this.frames*1e3/t,this.frameStart=e,this.frames=0),this.fps}reset(){this.frameStart=null,this.lastFrame=null,this.frames=0,this.fps=0}captureState(){return{frameStart:this.frameStart,lastFrame:this.lastFrame,frames:this.frames,fps:this.fps}}restoreState(e){this.frameStart=e.frameStart,this.lastFrame=e.lastFrame,this.frames=e.frames,this.fps=e.fps}},be=(e,t)=>{if(typeof e==`number`){if(t===3)return{mode:`rgb`,r:(e>>8&15|e>>4&240)/255,g:(e>>4&15|e&240)/255,b:(e&15|e<<4&240)/255};if(t===4)return{mode:`rgb`,r:(e>>12&15|e>>8&240)/255,g:(e>>8&15|e>>4&240)/255,b:(e>>4&15|e&240)/255,alpha:(e&15|e<<4&240)/255};if(t===6)return{mode:`rgb`,r:(e>>16&255)/255,g:(e>>8&255)/255,b:(e&255)/255};if(t===8)return{mode:`rgb`,r:(e>>24&255)/255,g:(e>>16&255)/255,b:(e>>8&255)/255,alpha:(e&255)/255}}},xe={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Se=e=>be(xe[e.toLowerCase()],6),Ce=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,we=e=>{let t;return(t=e.match(Ce))?be(parseInt(t[1],16),t[1].length):void 0},w=`([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)`,T=`${w}%`,Te=`(?:${w}%|${w})`,Ee=`(?:${w}%|${w}|none)`,De=`(?:${w}(deg|grad|rad|turn)|${w})`,E=`\\s*,\\s*`;RegExp(`^`+Ee+`$`);var Oe=RegExp(`^rgba?\\(\\s*${w}${E}${w}${E}${w}\\s*(?:,\\s*${Te}\\s*)?\\)$`),ke=RegExp(`^rgba?\\(\\s*${T}${E}${T}${E}${T}\\s*(?:,\\s*${Te}\\s*)?\\)$`),Ae=e=>{let t={mode:`rgb`},n;if(n=e.match(Oe))n[1]!==void 0&&(t.r=n[1]/255),n[2]!==void 0&&(t.g=n[2]/255),n[3]!==void 0&&(t.b=n[3]/255);else if(n=e.match(ke))n[1]!==void 0&&(t.r=n[1]/100),n[2]!==void 0&&(t.g=n[2]/100),n[3]!==void 0&&(t.b=n[3]/100);else return;return n[4]===void 0?n[5]!==void 0&&(t.alpha=Math.max(0,Math.min(1,+n[5]))):t.alpha=Math.max(0,Math.min(1,n[4]/100)),t},je=(e,t)=>e===void 0?void 0:typeof e==`object`?e.mode===void 0?t?{...e,mode:t}:void 0:e:qe(e),Me=(e=`rgb`)=>t=>(t=je(t,e))===void 0?void 0:t.mode===e?t:D[t.mode][e]?D[t.mode][e](t):e===`rgb`?D[t.mode].rgb(t):D.rgb[e](D[t.mode].rgb(t)),D={},Ne={},O=[],Pe={},Fe=e=>e,k=e=>(D[e.mode]={...D[e.mode],...e.toMode},Object.keys(e.fromMode||{}).forEach(t=>{D[t]||(D[t]={}),D[t][e.mode]=e.fromMode[t]}),e.ranges||={},e.difference||={},e.channels.forEach(t=>{if(e.ranges[t]===void 0&&(e.ranges[t]=[0,1]),!e.interpolate[t])throw Error(`Missing interpolator for: ${t}`);typeof e.interpolate[t]==`function`&&(e.interpolate[t]={use:e.interpolate[t]}),e.interpolate[t].fixup||(e.interpolate[t].fixup=Fe)}),Ne[e.mode]=e,(e.parse||[]).forEach(t=>{Le(t,e.mode)}),Me(e.mode)),Ie=e=>Ne[e],Le=(e,t)=>{if(typeof e==`string`){if(!t)throw Error(`'mode' required when 'parser' is a string`);Pe[e]=t}else typeof e==`function`&&O.indexOf(e)<0&&O.push(e)},Re=/[^\x00-\x7F]|[a-zA-Z_]/,ze=/[^\x00-\x7F]|[-\w]/,A={Function:`function`,Ident:`ident`,Number:`number`,Percentage:`percentage`,ParenClose:`)`,None:`none`,Hue:`hue`,Alpha:`alpha`},j=0;function M(e){let t=e[j],n=e[j+1];return t===`-`||t===`+`?/\d/.test(n)||n===`.`&&/\d/.test(e[j+2]):t===`.`?/\d/.test(n):/\d/.test(t)}function Be(e){if(j>=e.length)return!1;let t=e[j];if(Re.test(t))return!0;if(t===`-`){if(e.length-j<2)return!1;let t=e[j+1];return!!(t===`-`||Re.test(t))}return!1}var Ve={deg:1,rad:180/Math.PI,grad:9/10,turn:360};function N(e){let t=``;if((e[j]===`-`||e[j]===`+`)&&(t+=e[j++]),t+=P(e),e[j]===`.`&&/\d/.test(e[j+1])&&(t+=e[j++]+P(e)),(e[j]===`e`||e[j]===`E`)&&((e[j+1]===`-`||e[j+1]===`+`)&&/\d/.test(e[j+2])?t+=e[j++]+e[j++]+P(e):/\d/.test(e[j+1])&&(t+=e[j++]+P(e))),Be(e)){let n=F(e);return n===`deg`||n===`rad`||n===`turn`||n===`grad`?{type:A.Hue,value:t*Ve[n]}:void 0}return e[j]===`%`?(j++,{type:A.Percentage,value:+t}):{type:A.Number,value:+t}}function P(e){let t=``;for(;/\d/.test(e[j]);)t+=e[j++];return t}function F(e){let t=``;for(;j<e.length&&ze.test(e[j]);)t+=e[j++];return t}function He(e){let t=F(e);return e[j]===`(`?(j++,{type:A.Function,value:t}):t===`none`?{type:A.None,value:void 0}:{type:A.Ident,value:t}}function Ue(e=``){let t=e.trim(),n=[],r;for(j=0;j<t.length;)if(r=t[j++],r===`
|
|
2
|
-
`||r===` `||r===` `)for(;j<t.length&&(t[j]===`
|
|
3
|
-
`||t[j]===` `||t[j]===` `);)j++;else{if(r===`,`)return;if(r===`)`)n.push({type:A.ParenClose});else{if(r===`+`){if(j--,M(t)){n.push(N(t));continue}return}if(r===`-`){if(j--,M(t)){n.push(N(t));continue}if(Be(t)){n.push({type:A.Ident,value:F(t)});continue}return}if(r===`.`){if(j--,M(t)){n.push(N(t));continue}return}if(r===`/`){for(;j<t.length&&(t[j]===`
|
|
4
|
-
`||t[j]===` `||t[j]===` `);)j++;let e;if(M(t)&&(e=N(t),e.type!==A.Hue)){n.push({type:A.Alpha,value:e});continue}if(Be(t)&&F(t)===`none`){n.push({type:A.Alpha,value:{type:A.None,value:void 0}});continue}return}if(/\d/.test(r))j--,n.push(N(t));else if(Re.test(r))j--,n.push(He(t));else return}}return n}function We(e){e._i=0;let t=e[e._i++];if(!t||t.type!==A.Function||t.value!==`color`||(t=e[e._i++],t.type!==A.Ident))return;let n=Pe[t.value];if(!n)return;let r={mode:n},i=Ge(e,!1);if(!i)return;let a=Ie(n).channels;for(let e=0,t,n;e<a.length;e++)t=i[e],n=a[e],t.type!==A.None&&(r[n]=t.type===A.Number?t.value:t.value/100,n===`alpha`&&(r[n]=Math.max(0,Math.min(1,r[n]))));return r}function Ge(e,t){let n=[],r;for(;e._i<e.length;)if(r=e[e._i++],r.type===A.None||r.type===A.Number||r.type===A.Alpha||r.type===A.Percentage||t&&r.type===A.Hue)n.push(r);else if(r.type===A.ParenClose){if(e._i<e.length)return}else return;if(!(n.length<3||n.length>4)){if(n.length===4){if(n[3].type!==A.Alpha)return;n[3]=n[3].value}return n.length===3&&n.push({type:A.None,value:void 0}),n.every(e=>e.type!==A.Alpha)?n:void 0}}function Ke(e,t){e._i=0;let n=e[e._i++];if(!n||n.type!==A.Function)return;let r=Ge(e,t);if(r)return r.unshift(n.value),r}var qe=e=>{if(typeof e!=`string`)return;let t=Ue(e),n=t?Ke(t,!0):void 0,r,i=0,a=O.length;for(;i<a;)if((r=O[i++](e,n))!==void 0)return r;return t?We(t):void 0};function Je(e,t){if(!t||t[0]!==`rgb`&&t[0]!==`rgba`)return;let n={mode:`rgb`},[,r,i,a,o]=t;if(r.type!==A.Hue&&i.type!==A.Hue&&a.type!==A.Hue)return r.type!==A.None&&(n.r=r.type===A.Number?r.value/255:r.value/100),i.type!==A.None&&(n.g=i.type===A.Number?i.value/255:i.value/100),a.type!==A.None&&(n.b=a.type===A.Number?a.value/255:a.value/100),o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}var Ye=e=>e===`transparent`?{mode:`rgb`,r:0,g:0,b:0,alpha:0}:void 0,Xe=(e,t,n)=>e+n*(t-e),Ze=e=>{let t=[];for(let n=0;n<e.length-1;n++){let r=e[n],i=e[n+1];r===void 0&&i===void 0?t.push(void 0):r!==void 0&&i!==void 0?t.push([r,i]):t.push(r===void 0?[i,i]:[r,r])}return t},I=(e=>t=>{let n=Ze(t);return t=>{let r=t*n.length,i=t>=1?n.length-1:Math.max(Math.floor(r),0),a=n[i];return a===void 0?void 0:e(a[0],a[1],r-i)}})(Xe),L=e=>{let t=!1,n=e.map(e=>e===void 0?1:(t=!0,e));return t?n:e},R={mode:`rgb`,channels:[`r`,`g`,`b`,`alpha`],parse:[Je,we,Ae,Se,Ye,`srgb`],serialize:`srgb`,interpolate:{r:I,g:I,b:I,alpha:{use:I,fixup:L}},gamut:!0,white:{r:1,g:1,b:1},black:{r:0,g:0,b:0}},z=(e=0)=>Math.abs(e)**(563/256)*Math.sign(e),Qe=e=>{let t=z(e.r),n=z(e.g),r=z(e.b),i={mode:`xyz65`,x:.5766690429101305*t+.1855582379065463*n+.1882286462349947*r,y:.297344975250536*t+.6273635662554661*n+.0752914584939979*r,z:.0270313613864123*t+.0706888525358272*n+.9913375368376386*r};return e.alpha!==void 0&&(i.alpha=e.alpha),i},B=e=>Math.abs(e)**(256/563)*Math.sign(e),$e=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`a98`,r:B(e*2.0415879038107465-t*.5650069742788597-.3447313507783297*n),g:B(e*-.9692436362808798+t*1.8759675015077206+.0415550574071756*n),b:B(e*.0134442806320312-t*.1183623922310184+1.0151749943912058*n)};return r!==void 0&&(i.alpha=r),i},V=(e=0)=>{let t=Math.abs(e);return t<=.04045?e/12.92:(Math.sign(e)||1)*((t+.055)/1.055)**2.4},H=({r:e,g:t,b:n,alpha:r})=>{let i={mode:`lrgb`,r:V(e),g:V(t),b:V(n)};return r!==void 0&&(i.alpha=r),i},U=e=>{let{r:t,g:n,b:r,alpha:i}=H(e),a={mode:`xyz65`,x:.4123907992659593*t+.357584339383878*n+.1804807884018343*r,y:.2126390058715102*t+.715168678767756*n+.0721923153607337*r,z:.0193308187155918*t+.119194779794626*n+.9505321522496607*r};return i!==void 0&&(a.alpha=i),a},et=(e=0)=>{let t=Math.abs(e);return t>.0031308?(Math.sign(e)||1)*(1.055*t**(1/2.4)-.055):e*12.92},W=({r:e,g:t,b:n,alpha:r},i=`rgb`)=>{let a={mode:i,r:et(e),g:et(t),b:et(n)};return r!==void 0&&(a.alpha=r),a},G=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=W({r:e*3.2409699419045226-t*1.537383177570094-.4986107602930034*n,g:e*-.9692436362808796+t*1.8759675015077204+.0415550574071756*n,b:e*.0556300796969936-t*.2039769588889765+1.0569715142428784*n});return r!==void 0&&(i.alpha=r),i},tt={...R,mode:`a98`,parse:[`a98-rgb`],serialize:`a98-rgb`,fromMode:{rgb:e=>$e(U(e)),xyz65:$e},toMode:{rgb:e=>G(Qe(e)),xyz65:Qe}},K=e=>(e%=360)<0?e+360:e,nt=(e,t)=>e.map((n,r,i)=>{if(n===void 0)return n;let a=K(n);return r===0||e[r-1]===void 0?a:t(a-K(i[r-1]))}).reduce((e,t)=>!e.length||t===void 0||e[e.length-1]===void 0?(e.push(t),e):(e.push(t+e[e.length-1]),e),[]),rt=e=>nt(e,e=>Math.abs(e)<=180?e:e-360*Math.sign(e)),it=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.s||!t.s)return 0;let n=K(e.h),r=K(t.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.s*t.s)*i},at=(e,t)=>{if(e.h===void 0||t.h===void 0)return 0;let n=K(e.h),r=K(t.h);return Math.abs(r-n)>180?n-(r-360*Math.sign(r-n)):r-n},ot=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.c||!t.c)return 0;let n=K(e.h),r=K(t.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.c*t.c)*i},st=e=>{let t=e.reduce((e,t)=>{if(t!==void 0){let n=t*Math.PI/180;e.sin+=Math.sin(n),e.cos+=Math.cos(n)}return e},{sin:0,cos:0}),n=Math.atan2(t.sin,t.cos)*180/Math.PI;return n<0?360+n:n},q=({l:e,a:t,b:n,alpha:r},i=`lch`)=>{t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.sqrt(t*t+n*n),o={mode:i,l:e,c:a};return a&&(o.h=K(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(o.alpha=r),o},J=({l:e,c:t,h:n,alpha:r},i=`lab`)=>{n===void 0&&(n=0);let a={mode:i,l:e,a:t?t*Math.cos(n/180*Math.PI):0,b:t?t*Math.sin(n/180*Math.PI):0};return r!==void 0&&(a.alpha=r),a},Y={X:.3457/.3585,Y:1,Z:.2958/.3585};function ct({h:e,s:t,l:n,alpha:r}){e=K(e===void 0?0:e),t===void 0&&(t=0),n===void 0&&(n=0);let i=n+t*(n<.5?n:1-n),a=i-(i-n)*2*Math.abs(e/60%2-1),o;switch(Math.floor(e/60)){case 0:o={r:i,g:a,b:2*n-i};break;case 1:o={r:a,g:i,b:2*n-i};break;case 2:o={r:2*n-i,g:i,b:a};break;case 3:o={r:2*n-i,g:a,b:i};break;case 4:o={r:a,g:2*n-i,b:i};break;case 5:o={r:i,g:2*n-i,b:a};break;default:o={r:2*n-i,g:2*n-i,b:2*n-i}}return o.mode=`rgb`,r!==void 0&&(o.alpha=r),o}function lt({r:e,g:t,b:n,alpha:r}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.max(e,t,n),a=Math.min(e,t,n),o={mode:`hsl`,s:i===a?0:(i-a)/(1-Math.abs(i+a-1)),l:.5*(i+a)};return i-a!==0&&(o.h=(i===e?(t-n)/(i-a)+(t<n)*6:i===t?(n-e)/(i-a)+2:(e-t)/(i-a)+4)*60),r!==void 0&&(o.alpha=r),o}var ut=(e,t)=>{switch(t){case`deg`:return+e;case`rad`:return e/Math.PI*180;case`grad`:return e/10*9;case`turn`:return e*360}},dt=RegExp(`^hsla?\\(\\s*${De}${E}${T}${E}${T}\\s*(?:,\\s*${Te}\\s*)?\\)$`),ft=e=>{let t=e.match(dt);if(!t)return;let n={mode:`hsl`};return t[3]===void 0?t[1]!==void 0&&t[2]!==void 0&&(n.h=ut(t[1],t[2])):n.h=+t[3],t[4]!==void 0&&(n.s=Math.min(Math.max(0,t[4]/100),1)),t[5]!==void 0&&(n.l=Math.min(Math.max(0,t[5]/100),1)),t[6]===void 0?t[7]!==void 0&&(n.alpha=Math.max(0,Math.min(1,+t[7]))):n.alpha=Math.max(0,Math.min(1,t[6]/100)),n};function pt(e,t){if(!t||t[0]!==`hsl`&&t[0]!==`hsla`)return;let n={mode:`hsl`},[,r,i,a,o]=t;if(r.type!==A.None){if(r.type===A.Percentage)return;n.h=r.value}if(i.type!==A.None){if(i.type===A.Hue)return;n.s=i.value/100}if(a.type!==A.None){if(a.type===A.Hue)return;n.l=a.value/100}return o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}var mt={mode:`hsl`,toMode:{rgb:ct},fromMode:{rgb:lt},channels:[`h`,`s`,`l`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,parse:[pt,ft],serialize:e=>`hsl(${e.h===void 0?`none`:e.h} ${e.s===void 0?`none`:e.s*100+`%`} ${e.l===void 0?`none`:e.l*100+`%`}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{h:{use:I,fixup:rt},s:I,l:I,alpha:{use:I,fixup:L}},difference:{h:it},average:{h:st}};function ht({h:e,s:t,v:n,alpha:r}){e=K(e===void 0?0:e),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.abs(e/60%2-1),a;switch(Math.floor(e/60)){case 0:a={r:n,g:n*(1-t*i),b:n*(1-t)};break;case 1:a={r:n*(1-t*i),g:n,b:n*(1-t)};break;case 2:a={r:n*(1-t),g:n,b:n*(1-t*i)};break;case 3:a={r:n*(1-t),g:n*(1-t*i),b:n};break;case 4:a={r:n*(1-t*i),g:n*(1-t),b:n};break;case 5:a={r:n,g:n*(1-t),b:n*(1-t*i)};break;default:a={r:n*(1-t),g:n*(1-t),b:n*(1-t)}}return a.mode=`rgb`,r!==void 0&&(a.alpha=r),a}function gt({r:e,g:t,b:n,alpha:r}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.max(e,t,n),a=Math.min(e,t,n),o={mode:`hsv`,s:i===0?0:1-a/i,v:i};return i-a!==0&&(o.h=(i===e?(t-n)/(i-a)+(t<n)*6:i===t?(n-e)/(i-a)+2:(e-t)/(i-a)+4)*60),r!==void 0&&(o.alpha=r),o}function _t({h:e,w:t,b:n,alpha:r}){if(t===void 0&&(t=0),n===void 0&&(n=0),t+n>1){let e=t+n;t/=e,n/=e}return ht({h:e,s:n===1?1:1-t/(1-n),v:1-n,alpha:r})}function vt(e){let t=gt(e);if(t===void 0)return;let n=t.s===void 0?0:t.s,r=t.v===void 0?0:t.v,i={mode:`hwb`,w:(1-n)*r,b:1-r};return t.h!==void 0&&(i.h=t.h),t.alpha!==void 0&&(i.alpha=t.alpha),i}function yt(e,t){if(!t||t[0]!==`hwb`)return;let n={mode:`hwb`},[,r,i,a,o]=t;if(r.type!==A.None){if(r.type===A.Percentage)return;n.h=r.value}if(i.type!==A.None){if(i.type===A.Hue)return;n.w=i.value/100}if(a.type!==A.None){if(a.type===A.Hue)return;n.b=a.value/100}return o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}var bt={mode:`hwb`,toMode:{rgb:_t},fromMode:{rgb:vt},channels:[`h`,`w`,`b`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,parse:[yt],serialize:e=>`hwb(${e.h===void 0?`none`:e.h} ${e.w===void 0?`none`:e.w*100+`%`} ${e.b===void 0?`none`:e.b*100+`%`}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{h:{use:I,fixup:rt},w:I,b:I,alpha:{use:I,fixup:L}},difference:{h:at},average:{h:st}},xt=29**3/27,St=216/29**3,Ct=e=>e**3>St?e**3:(116*e-16)/xt,wt=({l:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(e+16)/116,a=t/500+i,o=i-n/200,s={mode:`xyz50`,x:Ct(a)*Y.X,y:Ct(i)*Y.Y,z:Ct(o)*Y.Z};return r!==void 0&&(s.alpha=r),s},Tt=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=W({r:e*3.1341359569958707-t*1.6173863321612538-.4906619460083532*n,g:e*-.978795502912089+t*1.916254567259524+.03344273116131949*n,b:e*.07195537988411677-t*.2289768264158322+1.405386058324125*n});return r!==void 0&&(i.alpha=r),i},Et=e=>Tt(wt(e)),Dt=e=>{let{r:t,g:n,b:r,alpha:i}=H(e),a={mode:`xyz50`,x:.436065742824811*t+.3851514688337912*n+.14307845442264197*r,y:.22249319175623702*t+.7168870538238823*n+.06061979053616537*r,z:.013923904500943465*t+.09708128566574634*n+.7140993584005155*r};return i!==void 0&&(a.alpha=i),a},Ot=e=>e>St?Math.cbrt(e):(xt*e+16)/116,kt=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Ot(e/Y.X),a=Ot(t/Y.Y),o=Ot(n/Y.Z),s={mode:`lab`,l:116*a-16,a:500*(i-a),b:200*(a-o)};return r!==void 0&&(s.alpha=r),s},At=e=>{let t=kt(Dt(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t};function jt(e,t){if(!t||t[0]!==`lab`)return;let n={mode:`lab`},[,r,i,a,o]=t;if(r.type!==A.Hue&&i.type!==A.Hue&&a.type!==A.Hue)return r.type!==A.None&&(n.l=Math.min(Math.max(0,r.value),100)),i.type!==A.None&&(n.a=i.type===A.Number?i.value:i.value*125/100),a.type!==A.None&&(n.b=a.type===A.Number?a.value:a.value*125/100),o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}var Mt={mode:`lab`,toMode:{xyz50:wt,rgb:Et},fromMode:{xyz50:kt,rgb:At},channels:[`l`,`a`,`b`,`alpha`],ranges:{l:[0,100],a:[-125,125],b:[-125,125]},parse:[jt],serialize:e=>`lab(${e.l===void 0?`none`:e.l} ${e.a===void 0?`none`:e.a} ${e.b===void 0?`none`:e.b}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{l:I,a:I,b:I,alpha:{use:I,fixup:L}}};function Nt(e,t){if(!t||t[0]!==`lch`)return;let n={mode:`lch`},[,r,i,a,o]=t;if(r.type!==A.None){if(r.type===A.Hue)return;n.l=Math.min(Math.max(0,r.value),100)}if(i.type!==A.None&&(n.c=Math.max(0,i.type===A.Number?i.value:i.value*150/100)),a.type!==A.None){if(a.type===A.Percentage)return;n.h=a.value}return o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}var Pt={mode:`lch`,toMode:{lab:J,rgb:e=>Et(J(e))},fromMode:{rgb:e=>q(At(e)),lab:q},channels:[`l`,`c`,`h`,`alpha`],ranges:{l:[0,100],c:[0,150],h:[0,360]},parse:[Nt],serialize:e=>`lch(${e.l===void 0?`none`:e.l} ${e.c===void 0?`none`:e.c} ${e.h===void 0?`none`:e.h}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{h:{use:I,fixup:rt},c:I,l:I,alpha:{use:I,fixup:L}},difference:{h:ot},average:{h:st}},Ft={...R,mode:`lrgb`,toMode:{rgb:W},fromMode:{rgb:H},parse:[`srgb-linear`],serialize:`srgb-linear`},It=({r:e,g:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.cbrt(.412221469470763*e+.5363325372617348*t+.0514459932675022*n),a=Math.cbrt(.2119034958178252*e+.6806995506452344*t+.1073969535369406*n),o=Math.cbrt(.0883024591900564*e+.2817188391361215*t+.6299787016738222*n),s={mode:`oklab`,l:.210454268309314*i+.7936177747023054*a-.0040720430116193*o,a:1.9779985324311684*i-2.42859224204858*a+.450593709617411*o,b:.0259040424655478*i+.7827717124575296*a-.8086757549230774*o};return r!==void 0&&(s.alpha=r),s},Lt=e=>{let t=It(H(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},Rt=({l:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(e+.3963377773761749*t+.2158037573099136*n)**3,a=(e-.1055613458156586*t-.0638541728258133*n)**3,o=(e-.0894841775298119*t-1.2914855480194092*n)**3,s={mode:`lrgb`,r:4.076741636075957*i-3.3077115392580616*a+.2309699031821044*o,g:-1.2684379732850317*i+2.6097573492876887*a-.3413193760026573*o,b:-.0041960761386756*i-.7034186179359362*a+1.7076146940746117*o};return r!==void 0&&(s.alpha=r),s},zt=e=>W(Rt(e));function Bt(e,t){if(!t||t[0]!==`oklab`)return;let n={mode:`oklab`},[,r,i,a,o]=t;if(r.type!==A.Hue&&i.type!==A.Hue&&a.type!==A.Hue)return r.type!==A.None&&(n.l=Math.min(Math.max(0,r.type===A.Number?r.value:r.value/100),1)),i.type!==A.None&&(n.a=i.type===A.Number?i.value:i.value*.4/100),a.type!==A.None&&(n.b=a.type===A.Number?a.value:a.value*.4/100),o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}var Vt={...Mt,mode:`oklab`,toMode:{lrgb:Rt,rgb:zt},fromMode:{lrgb:It,rgb:Lt},ranges:{l:[0,1],a:[-.4,.4],b:[-.4,.4]},parse:[Bt],serialize:e=>`oklab(${e.l===void 0?`none`:e.l} ${e.a===void 0?`none`:e.a} ${e.b===void 0?`none`:e.b}${e.alpha<1?` / ${e.alpha}`:``})`};function Ht(e,t){if(!t||t[0]!==`oklch`)return;let n={mode:`oklch`},[,r,i,a,o]=t;if(r.type!==A.None){if(r.type===A.Hue)return;n.l=Math.min(Math.max(0,r.type===A.Number?r.value:r.value/100),1)}if(i.type!==A.None&&(n.c=Math.max(0,i.type===A.Number?i.value:i.value*.4/100)),a.type!==A.None){if(a.type===A.Percentage)return;n.h=a.value}return o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}var Ut={...Pt,mode:`oklch`,toMode:{oklab:e=>J(e,`oklab`),rgb:e=>zt(J(e,`oklab`))},fromMode:{rgb:e=>q(Lt(e),`oklch`),oklab:e=>q(e,`oklch`)},parse:[Ht],serialize:e=>`oklch(${e.l===void 0?`none`:e.l} ${e.c===void 0?`none`:e.c} ${e.h===void 0?`none`:e.h}${e.alpha<1?` / ${e.alpha}`:``})`,ranges:{l:[0,1],c:[0,.4],h:[0,360]}},Wt=e=>{let{r:t,g:n,b:r,alpha:i}=H(e),a={mode:`xyz65`,x:.486570948648216*t+.265667693169093*n+.1982172852343625*r,y:.2289745640697487*t+.6917385218365062*n+.079286914093745*r,z:0*t+.0451133818589026*n+1.043944368900976*r};return i!==void 0&&(a.alpha=i),a},Gt=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=W({r:e*2.4934969119414263-t*.9313836179191242-.402710784450717*n,g:e*-.8294889695615749+t*1.7626640603183465+.0236246858419436*n,b:e*.0358458302437845-t*.0761723892680418+.9568845240076871*n},`p3`);return r!==void 0&&(i.alpha=r),i},Kt={...R,mode:`p3`,parse:[`display-p3`],serialize:`display-p3`,fromMode:{rgb:e=>Gt(U(e)),xyz65:Gt},toMode:{rgb:e=>G(Wt(e)),xyz65:Wt}},qt=e=>{let t=Math.abs(e);return t>=1/512?Math.sign(e)*t**(1/1.8):16*e},Jt=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`prophoto`,r:qt(e*1.3457868816471585-t*.2555720873797946-.0511018649755453*n),g:qt(e*-.5446307051249019+t*1.5082477428451466+.0205274474364214*n),b:qt(e*0+t*0+1.2119675456389452*n)};return r!==void 0&&(i.alpha=r),i},Yt=(e=0)=>{let t=Math.abs(e);return t>=16/512?Math.sign(e)*t**1.8:e/16},Xt=e=>{let t=Yt(e.r),n=Yt(e.g),r=Yt(e.b),i={mode:`xyz50`,x:.7977666449006423*t+.1351812974005331*n+.0313477341283922*r,y:.2880748288194013*t+.7118352342418731*n+899369387256e-16*r,z:0*t+0*n+.8251046025104602*r};return e.alpha!==void 0&&(i.alpha=e.alpha),i},Zt={...R,mode:`prophoto`,parse:[`prophoto-rgb`],serialize:`prophoto-rgb`,fromMode:{xyz50:Jt,rgb:e=>Jt(Dt(e))},toMode:{xyz50:Xt,rgb:e=>Tt(Xt(e))}},Qt=1.09929682680944,$t=.018053968510807,en=e=>{let t=Math.abs(e);return t>$t?(Math.sign(e)||1)*(Qt*t**.45-.09929682680944008):4.5*e},tn=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`rec2020`,r:en(e*1.7166511879712683-t*.3556707837763925-.2533662813736599*n),g:en(e*-.6666843518324893+t*1.6164812366349395+.0157685458139111*n),b:en(e*.0176398574453108-t*.0427706132578085+.9421031212354739*n)};return r!==void 0&&(i.alpha=r),i},nn=1.09929682680944,rn=.018053968510807,an=(e=0)=>{let t=Math.abs(e);return t<rn*4.5?e/4.5:(Math.sign(e)||1)*((t+nn-1)/nn)**(1/.45)},on=e=>{let t=an(e.r),n=an(e.g),r=an(e.b),i={mode:`xyz65`,x:.6369580483012911*t+.1446169035862083*n+.1688809751641721*r,y:.262700212011267*t+.6779980715188708*n+.059301716469862*r,z:0*t+.0280726930490874*n+1.0609850577107909*r};return e.alpha!==void 0&&(i.alpha=e.alpha),i},sn={...R,mode:`rec2020`,fromMode:{xyz65:tn,rgb:e=>tn(U(e))},toMode:{xyz65:on,rgb:e=>G(on(e))},parse:[`rec2020`],serialize:`rec2020`},cn={mode:`xyz50`,parse:[`xyz-d50`],serialize:`xyz-d50`,toMode:{rgb:Tt,lab:kt},fromMode:{rgb:Dt,lab:wt},channels:[`x`,`y`,`z`,`alpha`],ranges:{x:[0,.964],y:[0,.999],z:[0,.825]},interpolate:{x:I,y:I,z:I,alpha:{use:I,fixup:L}}},ln={mode:`xyz65`,toMode:{rgb:G,xyz50:e=>{let{x:t,y:n,z:r,alpha:i}=e;t===void 0&&(t=0),n===void 0&&(n=0),r===void 0&&(r=0);let a={mode:`xyz50`,x:1.0479298208405488*t+.0229467933410191*n-.0501922295431356*r,y:.0296278156881593*t+.990434484573249*n-.0170738250293851*r,z:-.0092430581525912*t+.0150551448965779*n+.7518742899580008*r};return i!==void 0&&(a.alpha=i),a}},fromMode:{rgb:U,xyz50:e=>{let{x:t,y:n,z:r,alpha:i}=e;t===void 0&&(t=0),n===void 0&&(n=0),r===void 0&&(r=0);let a={mode:`xyz65`,x:.9554734527042182*t-.0230985368742614*n+.0632593086610217*r,y:-.0283697069632081*t+1.0099954580058226*n+.021041398966943*r,z:.0123140016883199*t-.0205076964334779*n+1.3303659366080753*r};return i!==void 0&&(a.alpha=i),a}},ranges:{x:[0,.95],y:[0,1],z:[0,1.088]},channels:[`x`,`y`,`z`,`alpha`],parse:[`xyz`,`xyz-d65`],serialize:`xyz-d65`,interpolate:{x:I,y:I,z:I,alpha:{use:I,fixup:L}}},un=k(R);k(Ft),k(mt),k(bt),k(Mt),k(Pt),k(Vt);var dn=k(Ut);k(Kt),k(tt),k(Zt),k(sn),k(cn),k(ln);var X=new Map,fn=e=>Math.max(0,Math.min(1,e));function pn(e){let t=e.trim().toLowerCase();if(!t||t===`transparent`)return null;if(X.has(t))return X.get(t);let n=un(t),r=null;if(n){let e=[n.r??0,n.g??0,n.b??0],t=n.alpha??1;if([...e,t].every(Number.isFinite)){let[n,i,a]=e.map(fn),o=fn(t),s=dn({mode:`rgb`,r:n,g:i,b:a});r=Object.freeze({paint:Object.freeze({color:`rgb(${[n,i,a].map(e=>Math.round(e*255)).join(` `)})`,alpha:o}),appearance:Object.freeze({lightness:s.l,chroma:s.c,alpha:o})})}}return X.size>=256&&X.delete(X.keys().next().value),X.set(t,r),r}function mn(e){return pn(e)?.paint??null}function hn(e){return pn(e)?.appearance??null}function gn(e){let{ignitionSeconds:t,spreadSeconds:n,spreadRadiusPx:r,burnSeconds:i,smokePerSecond:a}=e;return{ignitionSeconds:t,spreadSeconds:n,spreadRadiusPx:r,burnSeconds:i,smokePerSecond:a}}function _n(e){let t=(...e)=>e.every(Number.isFinite);if(!e||!t(e.point?.x,e.point?.y,e.radiusPx)||e.radiusPx<0||e.spreadSeconds!==void 0&&(!t(e.spreadSeconds)||e.spreadSeconds<0)||e.mask&&(!e.bounds||!(e.mask.alpha instanceof Uint8Array)||!Number.isInteger(e.mask.pixelWidth)||!Number.isInteger(e.mask.pixelHeight)||e.mask.pixelWidth<=0||e.mask.pixelHeight<=0||e.mask.alpha.length!==e.mask.pixelWidth*e.mask.pixelHeight||!t(e.mask.origin?.x,e.mask.origin?.y)||e.mask.frontRadius!==1/0&&(!t(e.mask.frontRadius)||e.mask.frontRadius<0))||e.bounds&&(!t(e.bounds.x,e.bounds.y,e.bounds.width,e.bounds.height)||e.bounds.width<0||e.bounds.height<0))throw Error(`Invalid fire source: expected finite coordinates and nonnegative geometry`);return{...e,point:{...e.point},...e.bounds&&{bounds:{...e.bounds}},...e.profile&&{profile:{...e.profile}},...e.mask&&{mask:{...e.mask,alpha:e.mask.alpha.slice(),origin:{...e.mask.origin}}}}}function vn(e,t){if(e.mask&&e.bounds)return Sn({rect:e.bounds,alpha:e.mask.alpha,pixelWidth:e.mask.pixelWidth,pixelHeight:e.mask.pixelHeight},e.mask.origin,e.mask.frontRadius,t,e.radiusPx);if(e.bounds){let n=e.bounds;return Math.hypot(Math.max(t.x-n.x-n.width,n.x-t.x-t.width,0),Math.max(t.y-n.y-n.height,n.y-t.y-t.height,0))}return Math.hypot(Math.max(t.x-e.point.x,0,e.point.x-t.x-t.width),Math.max(t.y-e.point.y,0,e.point.y-t.y-t.height))}function yn(e,t,n,r){let i=vn(t,n);return i>t.radiusPx?0:e/Math.max(.01,t.spreadSeconds??r)*(1.5-.5*i/Math.max(t.radiusPx,1))}function bn(e,t,n=1024){let{x:r,y:i,width:a,height:o}=e,s=Math.max(1,Math.ceil(a/Math.max(1,t))),c=Math.max(1,Math.ceil(o/Math.max(1,t))),l=Math.min(1,Math.sqrt(n/(s*c))),u=Math.min(n,Math.max(1,Math.floor(s*l))),d=Math.min(n,Math.max(1,Math.floor(c*l)));u=Math.min(u,Math.max(1,Math.floor(n/d)));let f=[];for(let e=0;e<d;e++)for(let t=0;t<u;t++)f.push({x:r+(t+.5)*a/u,y:i+(e+.5)*o/d});return f}function xn(e,t){if(!e.bounds)return[e.point];let n=e.bounds,r=e.radiusPx,i=t?{x:Math.max(n.x,t.x-r),y:Math.max(n.y,t.y-r),width:Math.min(n.x+n.width,t.x+t.width+r)-Math.max(n.x,t.x-r),height:Math.min(n.y+n.height,t.y+t.height+r)-Math.max(n.y,t.y-r)}:n;return i.width<=0||i.height<=0?[]:bn(i,Math.max(1,e.radiusPx)).filter(t=>!e.mask||vn({...e,radiusPx:0},{...t,width:0,height:0})===0)}function Sn(e,t,n,r,i){let{rect:a,alpha:o,pixelWidth:s,pixelHeight:c}=e;if(a.width<=0||a.height<=0)return 1/0;let l=Math.max(0,Math.floor((r.x-i-a.x)/a.width*s)),u=Math.min(s-1,Math.floor((r.x+r.width+i-a.x)/a.width*s)),d=Math.max(0,Math.floor((r.y-i-a.y)/a.height*c)),f=Math.min(c-1,Math.floor((r.y+r.height+i-a.y)/a.height*c)),p=1/0;for(let e=d;e<=f;e++)for(let i=l;i<=u;i++){if(o[e*s+i]<=32)continue;let l={x:a.x+i*a.width/s,y:a.y+e*a.height/c,width:a.width/s,height:a.height/c};Math.hypot(l.x+l.width/2-t.x,l.y+l.height/2-t.y)>n||(p=Math.min(p,Math.hypot(Math.max(r.x-l.x-l.width,l.x-r.x-r.width,0),Math.max(r.y-l.y-l.height,l.y-r.y-r.height,0))))}return p}var Cn=new WeakMap;function wn(e,t){let{rect:n,alpha:r,pixelWidth:i,pixelHeight:a}=e,o=t.spreadRadiusPx,s=Cn.get(e);if(!s||s.alpha!==r||s.width!==n.width||s.height!==n.height||s.pixelWidth!==i||s.pixelHeight!==a||s.radius!==o){let t=Math.max(1,o*.75),c=Math.max(1,Math.ceil(n.width/t)),l=Math.max(1,Math.ceil(n.height/t)),u=Array(c*l),d=(e,r)=>{let i=Math.min(c-1,Math.floor(e/t)),a=Math.min(l-1,Math.floor(r/t)),o=a*c+i,s=(i+.5)*n.width/c,d=(a+.5)*n.height/l,f=(e-s)**2+(r-d)**2;(!u[o]||f<u[o].distance)&&(u[o]={x:e,y:r,distance:f})};for(let e=0;e<l;e++)for(let t=0;t<c;t++){let o=(t+.5)*n.width/c,s=(e+.5)*n.height/l,u=Math.min(i-1,Math.floor(o/n.width*i));r[Math.min(a-1,Math.floor(s/n.height*a))*i+u]>32&&d(o,s)}for(let e=0;e<a;e++)for(let t=0;t<i;t++)r[e*i+t]<=32||d((t+.5)*n.width/i,(e+.5)*n.height/a);s={alpha:r,width:n.width,height:n.height,pixelWidth:i,pixelHeight:a,radius:o,points:u.filter(e=>e!==void 0).map(({x:e,y:t})=>({x:e,y:t}))},Cn.set(e,s)}return s.points.map(e=>({point:{x:n.x+e.x,y:n.y+e.y},radiusPx:o,spreadSeconds:t.spreadSeconds,profile:t}))}function Tn(e,t,n,r,i,a,o=Math.random){let s=Math.hypot(t.x,t.y)||1,c={x:t.x/s,y:t.y/s},l={x:-c.y,y:c.x},u=Math.max(.4,Math.min(2,i)),d=[];for(let t=0;t<r;t++){let t=o()<.985-a*.045,r=(t?1+o()**.65*(12+u*15):.8+o()*7)*(1-a*.38),i=(o()+o()-1)*r*(.1+o()*.32),s=t?.025+o()**2.8*n*.14:n*(.16+o()**2*(.2+a*.35));d.push({x:e.x+n*(c.x*r+l.x*i),y:e.y+n*(c.y*r+l.y*i),radius:s,angularity:t?u*(.25+o()*.75):u*o(),opacity:t?.28+o()*.62:.85+o()*.15})}return d}function En(e,t){return e===null?1:Math.max(0,1-(t-e)/240)}var Z={rangeM:10,forwardBias:1.5,chargeSeconds:1.1,statusSeconds:4,speedFactor:.5,impactRadiusM:1.6,damage:75,impulse:1,ignite:!0};function Dn(e){let t={...Z,...e.lightning};for(let e of Object.keys(Z)){if(e===`ignite`)continue;let n=t[e];(!Number.isFinite(n)||n<0)&&(t[e]=Z[e])}return t.forwardBias=Math.max(0,Math.min(4,t.forwardBias)),t.rangeM=Math.max(1,Math.min(30,t.rangeM)),t.chargeSeconds=Math.max(.1,Math.min(10,t.chargeSeconds)),t.speedFactor=Math.max(.1,Math.min(1,t.speedFactor)),t.statusSeconds=Math.max(.1,Math.min(30,t.statusSeconds)),t.impactRadiusM=Math.max(.1,Math.min(10,t.impactRadiusM)),t.damage=Math.min(1e4,t.damage),t.impulse=Math.min(4,t.impulse),t.ignite=typeof t.ignite==`boolean`?t.ignite:Z.ignite,t}function On(e,t,n=28){let r=Dn(e);return e.lightning?.rangeM!==void 0||!Number.isFinite(t)||!t||n<=0?r.rangeM:Math.max(4,Math.min(60,t/(3*n)))}function kn(e,t,n,r){let i=t.x-e.x,a=t.y-e.y,o=Math.hypot(i,a),s=o>.001?(i*Math.cos(n)-a*Math.sin(n))/o:1;return o*(1+Math.max(0,r)*(1-Math.max(-1,Math.min(1,s))))}var An=class{charging=!1;charge=0;target=null;dischargeAge=1/0;dischargeId=0;dischargeTargets=[];dischargePaths=[];pending=!1;elapsed=0;captureState(){return e({charging:this.charging,charge:this.charge,target:this.target,dischargeAge:this.dischargeAge,dischargeId:this.dischargeId,dischargeTargets:this.dischargeTargets,dischargePaths:this.dischargePaths,pending:this.pending,elapsed:this.elapsed})}restoreState(t){let n=e(t);this.charging=n.charging,this.charge=n.charge,this.target=n.target,this.dischargeAge=n.dischargeAge,this.dischargeId=n.dischargeId,this.dischargeTargets=n.dischargeTargets,this.dischargePaths=n.dischargePaths,this.pending=n.pending,this.elapsed=n.elapsed}get visual(){let e=this.dischargeAge<.6;return{phase:e?`discharged`:this.charging?`charging`:`idle`,charge:this.charge,target:e?this.dischargeTargets[0]??this.dischargePaths[0]?.[0]??null:this.target,dischargeAge:this.dischargeAge,dischargeId:this.dischargeId,branches:this.dischargeTargets,paths:this.dischargePaths}}step(e,t,n){this.dischargeAge+=e,this.dischargeAge>.6&&(this.dischargeTargets=[],this.dischargePaths=[]),this.charging=t,t?(this.elapsed+=e,this.charge=Math.min(1,this.elapsed/n),this.elapsed>=n&&(this.charge=1,this.pending=!0,this.elapsed=0,this.charging=!1)):(this.charge=this.elapsed=0,this.target=null)}takeDischarge(){let e=this.pending;return this.pending=!1,e}discharge(e,t=[]){this.dischargeTargets=e.map(e=>({...e})),this.dischargePaths=t.map(e=>e.map(e=>({...e}))),this.dischargeAge=0,this.dischargeId++}reset(){this.charging=this.pending=!1,this.charge=this.elapsed=this.dischargeId=0,this.target=null,this.dischargeAge=1/0,this.dischargeTargets=[],this.dischargePaths=[]}};function Q(e){if(!e.detached)return e.ink;let t=Math.cos(e.angle),n=Math.sin(e.angle),r=e.ink.width/2,i=e.ink.height/2,a=e.ink.x+r-e.base.x-e.base.width/2,o=e.ink.y+i-e.base.y-e.base.height/2,s=e.base.x+e.base.width/2+e.offset.x+a*t-o*n,c=e.base.y+e.base.height/2+e.offset.y+a*n+o*t,l=Math.abs(t)*r+Math.abs(n)*i,u=Math.abs(n)*r+Math.abs(t)*i;return{x:s-l,y:c-u,width:2*l,height:2*u}}function jn(e,t){let{ink:n}=e;if(!e.detached)return n.x<t.x+t.width&&n.x+n.width>t.x&&n.y<t.y+t.height&&n.y+n.height>t.y;let r=e.base.x+e.base.width/2,i=e.base.y+e.base.height/2,a=Math.max(Math.abs(n.x-r),Math.abs(n.x+n.width-r)),o=Math.max(Math.abs(n.y-i),Math.abs(n.y+n.height-i)),s=Math.sqrt(a*a+o*o),c=r+e.offset.x,l=i+e.offset.y;return c-s<t.x+t.width&&c+s>t.x&&l-s<t.y+t.height&&l+s>t.y}function Mn(e,n,i,o){let s=a(n,r(e.velocity,-1));e.detached=!0,e.velocity=a(r(e.velocity,.35),a(r(s,.55),r(i,80+Math.min(220,t(s)*.3)))),e.spin=e.spin*.3+o,e.offset=a(e.offset,r(i,2)),e.impactCooldown=.12}function Nn(e,t){e.impactCooldown=Math.max(0,e.impactCooldown-t),e.detached&&(e.velocity=r(e.velocity,Math.exp(-(e.attractorInfluenced?.35:1.6)*t)),e.offset=a(e.offset,r(e.velocity,t)),e.angle+=e.spin*t,e.spin*=Math.exp(-1.25*t))}function $(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Pn(e,t,n){let r=-1/0,i=1/0,a={x:0,y:0};for(let o of[`x`,`y`]){let s=n[o],c=s+(o===`x`?n.width:n.height),l=e[o],u=t[o],d=l+(o===`x`?e.width:e.height),f=u+(o===`x`?t.width:t.height);for(let[e,t,n]of[[d-s,f-d,-1],[c-l,l-u,1]]){if(Math.abs(t)<1e-8){if(e<0)return null;continue}let s=-e/t;t>0&&s>r?(r=s,a=o===`x`?{x:n,y:0}:{x:0,y:n}):t<0&&(i=Math.min(i,s))}if(r>i)return null}return r>=0&&r<=1&&r<=i&&i>=0&&(a.x!==0||a.y!==0)?{time:r,normal:a}:null}function Fn(e,t){let n=Q(e);if(!$(n,t))return null;let r=[{amount:t.x-n.x-n.width-.1,normal:{x:-1,y:0}},{amount:t.x+t.width-n.x+.1,normal:{x:1,y:0}},{amount:t.y-n.y-n.height-.1,normal:{x:0,y:-1}},{amount:t.y+t.height-n.y+.1,normal:{x:0,y:1}}].reduce((e,t)=>Math.abs(t.amount)<Math.abs(e.amount)?t:e);return r.normal.x?e.offset.x+=r.amount:e.offset.y+=r.amount,r.normal}function In(e,t){let n=e.velocity.x*t.x+e.velocity.y*t.y;n>=0||(e.velocity=a(r(e.velocity,.82),r(t,-n*1.1)),e.spin*=-.45)}function Ln(e,t,n){if(e.detached)for(let t of n){if($(e.ink,t))continue;let n=Fn(e,t);n&&In(e,n)}if(!e.detached||n.length===0){Nn(e,t);return}let r=Q(e);Nn(e,t);let i=Q(e),a=null;for(let t of n){if($(e.ink,t))continue;let n=Pn(r,i,t);n&&(!a||n.time<a.time)&&(a={...n,wall:t})}if(a){let t=1-a.time;e.offset.x-=(i.x+i.width/2-r.x-r.width/2)*t,e.offset.y-=(i.y+i.height/2-r.y-r.height/2)*t,Fn(e,a.wall),In(e,a.normal)}for(let t=0;t<3;t++){let t=!1;for(let r of n){if($(e.ink,r))continue;let n=Fn(e,r);n&&(In(e,n),t=!0)}if(!t)break}}function Rn(e,n,o,s=!1){if(!n||n.radiusPx<=0||!e.detached&&!s)return e.attractorInfluenced=!1,!1;let c=Q(e),l={x:c.x+c.width/2,y:c.y+c.height/2},u=i(l,n.center),d=t(u);if(d>n.radiusPx)return e.attractorInfluenced=!1,!1;e.detached||=!0,e.attractorInfluenced=!0;let f=r(u,-Math.min(1,300/Math.max(1,d*5))*5),p=i(n.velocity,e.velocity),m=a(f,r(p,.15));return e.velocity=a(e.velocity,r(m,Math.max(0,o))),e.spin*=Math.exp(-.7*Math.max(0,o)),!0}export{te as A,h as B,pe as C,ce as D,ue as E,p as F,l as I,g as L,v as M,m as N,se as O,f as P,_ as R,me as S,fe as T,c as V,hn as _,jn as a,ve as b,On as c,Tn as d,wn as f,_n as g,xn as h,Q as i,ee as j,ne as k,kn as l,yn as m,Ln as n,An as o,gn as p,Mn as r,Dn as s,Rn as t,En as u,mn as v,de as w,ge as x,ye as y,u as z};
|